Docs: fix local_scan decsription for new message-id format. Bug 3051
[exim.git] / doc / doc-docbook / spec.xfpt
1
2 . /////////////////////////////////////////////////////////////////////////////
3 . This is the primary source of the Exim Manual. It is an xfpt document that is
4 . converted into DocBook XML for subsequent conversion into printable and online
5 . formats. The markup used herein is "standard" xfpt markup, with some extras.
6 . The markup is summarized in a file called Markup.txt.
7 .
8 . WARNING: When you use the .new macro, make sure it appears *before* any
9 . adjacent index items; otherwise you get an empty "paragraph" which causes
10 . unwanted vertical space.
11 . /////////////////////////////////////////////////////////////////////////////
12
13 .include stdflags
14 .include stdmacs
15
16 . /////////////////////////////////////////////////////////////////////////////
17 . This outputs the standard DocBook boilerplate.
18 . /////////////////////////////////////////////////////////////////////////////
19
20 .docbook
21
22 . /////////////////////////////////////////////////////////////////////////////
23 . These lines are processing instructions for the Simple DocBook Processor that
24 . Philip Hazel has developed as a less cumbersome way of making PostScript and
25 . PDFs than using xmlto and fop. They will be ignored by all other XML
26 . processors.
27 . /////////////////////////////////////////////////////////////////////////////
28
29 .literal xml
30 <?sdop
31   foot_right_recto="&chaptertitle; (&chapternumber;)"
32   foot_right_verso="&chaptertitle; (&chapternumber;)"
33   toc_chapter_blanks="yes,yes"
34   table_warn_overflow="overprint"
35 ?>
36 .literal off
37
38 . /////////////////////////////////////////////////////////////////////////////
39 . This generates the outermost <book> element that wraps the entire document.
40 . /////////////////////////////////////////////////////////////////////////////
41
42 .book
43
44 . /////////////////////////////////////////////////////////////////////////////
45 . These definitions set some parameters and save some typing.
46 . Update the Copyright year (only) when changing content.
47 . /////////////////////////////////////////////////////////////////////////////
48
49 .set previousversion "4.97"
50 .include ./local_params
51
52 .set ACL "access control lists (ACLs)"
53 .set I   "&nbsp;&nbsp;&nbsp;&nbsp;"
54
55 .set drivernamemax "64"
56
57 .macro copyyear
58 2023
59 .endmacro
60
61 . /////////////////////////////////////////////////////////////////////////////
62 . Additional xfpt markup used by this document, over and above the default
63 . provided in the xfpt library.
64 . /////////////////////////////////////////////////////////////////////////////
65
66 . --- Override the &$ flag to automatically insert a $ with the variable name.
67
68 .flag &$  $&   "<varname>$"  "</varname>"
69
70 . --- Short flags for daggers in option headings. They will always be inside
71 . --- an italic string, but we want the daggers to be in Roman.
72
73 .flag &!!      "</emphasis>&dagger;<emphasis>"
74 .flag &!?      "</emphasis>&Dagger;<emphasis>"
75
76 . --- A macro for an Exim option definition heading, generating a one-line
77 . --- table with four columns. For cases when the option name is given with
78 . --- a space, so that it can be split, a fifth argument is used for the
79 . --- index entry.
80 . --- Also one for multiple option def headings be grouped in a single
81 . --- table (but without the split capability).
82
83 .macro otable
84 .itable all 0 0 4 8* left 6* center 6* center 6* right
85 .endmacro
86
87 .macro orow
88 .row "&%$1%&" "Use: &'$2'&" "Type: &'$3'&" "Default: &'$4'&"
89 .endmacro
90
91 .macro option
92 .arg 5
93 .oindex "&%$5%&"
94 .endarg
95 .arg -5
96 .oindex "&%$1%&"
97 .endarg
98 .otable
99 .orow "$1" "$2" "$3" "$4"
100 .endtable
101 .endmacro
102
103 .macro options
104 .eacharg
105 .oindex "&%$+1%&"
106 .endeach 4
107 .otable
108 .eacharg
109 .orow "$+1" "$+2" "$+3" "$+4"
110 .endeach 4
111 .endtable
112 .endmacro
113
114 . --- A macro for the common 2-column tables. The width of the first column
115 . --- is suitable for the many tables at the start of the main options chapter;
116 . --- a small number of other 2-column tables override it.
117
118 .macro table2 196pt 254pt
119 .itable none 0 0 2 $1 left $2 left
120 .endmacro
121
122
123 . --- A macro for a plain variable, including the .vitem and .vindex
124 .macro var
125 .vitem $1
126 .vindex $1
127 .endmacro
128
129 . --- A macro for a "tainted" marker, done as a one-element table
130 .macro tmark
131 .itable none 0 0 1 10pt left
132 .row &'Tainted'&
133 .endtable
134 .endmacro
135
136 . --- A macro for a tainted variable, adding a taint-marker
137 .macro tvar
138 .var $1
139 .tmark
140 .endmacro
141
142 . --- A macro for a cmdline option, including a .oindex
143 . --- 1st arg is the option name, undecorated (we do that here).
144 . --- 2nd arg, optional, text (decorated as needed) to be appended to the name
145 .macro cmdopt
146 .vitem  &%$1%&$=2+&~$2+
147 .oindex &%$1%&
148 .endmacro
149
150 . --- A macro that generates .row, but puts &I; at the start of the first
151 . --- argument, thus indenting it. Assume a minimum of two arguments, and
152 . --- allow up to four arguments, which is as many as we'll ever need.
153
154 .macro irow
155 .arg 4
156 .row "&I;$1" "$2" "$3" "$4"
157 .endarg
158 .arg -4
159 .arg 3
160 .row "&I;$1" "$2" "$3"
161 .endarg
162 .arg -3
163 .row "&I;$1" "$2"
164 .endarg
165 .endarg
166 .endmacro
167
168 . --- Macros for option, variable, and concept index entries. For a "range"
169 . --- style of entry, use .scindex for the start and .ecindex for the end. The
170 . --- first argument of .scindex and the only argument of .ecindex must be the
171 . --- ID that ties them together.
172 . --- The index entry points to the most-recent chapter head, section or subsection
173 . --- head, or list-item.
174
175 .macro cindex
176 &<indexterm role="concept">&
177 &<primary>&$1&</primary>&
178 .arg 2
179 &<secondary>&$2&</secondary>&
180 .endarg
181 &</indexterm>&
182 .endmacro
183
184 .macro scindex
185 &<indexterm role="concept" id="$1" class="startofrange">&
186 &<primary>&$2&</primary>&
187 .arg 3
188 &<secondary>&$3&</secondary>&
189 .endarg
190 &</indexterm>&
191 .endmacro
192
193 .macro ecindex
194 &<indexterm role="concept" startref="$1" class="endofrange"/>&
195 .endmacro
196
197 .macro oindex
198 &<indexterm role="option">&
199 &<primary>&$1&</primary>&
200 .arg 2
201 &<secondary>&$2&</secondary>&
202 .endarg
203 &</indexterm>&
204 .endmacro
205
206 . --- The index entry points to the most-recent chapter head, section or subsection
207 . --- head, or varlist item.
208
209 .macro vindex
210 &<indexterm role="variable">&
211 &<primary>&$1&</primary>&
212 .arg 2
213 &<secondary>&$2&</secondary>&
214 .endarg
215 &</indexterm>&
216 .endmacro
217
218 .macro index
219 .echo "** Don't use .index; use .cindex or .oindex or .vindex"
220 .endmacro
221
222
223 . use this for a concept-index entry for a header line
224 .macro chindex
225 .cindex "&'$1'& header line"
226 .cindex "header lines" $1
227 .endmacro
228 . ////////////////////////////////////////////////////////////////////////////
229
230
231 . ////////////////////////////////////////////////////////////////////////////
232 . The <bookinfo> element is removed from the XML before processing for ASCII
233 . output formats.
234 . ////////////////////////////////////////////////////////////////////////////
235
236 .literal xml
237 <bookinfo>
238 <title>Specification of the Exim Mail Transfer Agent</title>
239 <titleabbrev>The Exim MTA</titleabbrev>
240 <date>
241 .fulldate
242 </date>
243 <author><firstname>Exim</firstname><surname>Maintainers</surname></author>
244 <authorinitials>EM</authorinitials>
245 <revhistory><revision>
246 .versiondatexml
247   <authorinitials>EM</authorinitials>
248 </revision></revhistory>
249 <copyright><year>
250 .copyyear
251            </year><holder>The Exim Maintainers</holder></copyright>
252 </bookinfo>
253 .literal off
254
255
256 . /////////////////////////////////////////////////////////////////////////////
257 . These implement index entries of the form "x, see y" and "x, see also y".
258 . However, the DocBook DTD doesn't allow <indexterm> entries
259 . at the top level, so we have to put the .chapter directive first.
260 . /////////////////////////////////////////////////////////////////////////////
261
262 .chapter "Introduction" "CHID1"
263
264 .macro seeother
265 .literal xml
266 <indexterm role="$2">
267   <primary>$3</primary>
268 .arg 5
269   <secondary>$5</secondary>
270 .endarg
271   <$1><emphasis>$4</emphasis></$1>
272 </indexterm>
273 .literal off
274 .endmacro
275
276 . NB: for the 4-arg variant the ordering is awkward
277 .macro see
278 .seeother see "$1" "$2" "$3" "$4"
279 .endmacro
280 .macro seealso
281 .seeother seealso "$1" "$2" "$3" "$4"
282 .endmacro
283
284 .see     variable "<emphasis>$1</emphasis>, <emphasis>$2</emphasis>, etc." "numerical variables"
285 .see     concept address        rewriting                       rewriting
286 .see     concept "Bounce Address Tag Validation"        BATV
287 .see     concept "Client SMTP Authorization"            CSA
288 .see     concept "CR character" "carriage return"
289 .see     concept CRL            "certificate revocation list"
290 .seealso concept de-tainting    "tainted data"
291 .see     concept delivery       "bounce message"                "failure report"
292 .see     concept dialup         "intermittently connected hosts"
293 .see     concept exiscan        "content scanning"
294 .see     concept fallover       fallback
295 .see     concept filter         "Sieve filter"                  Sieve
296 .see     concept headers        "header lines"
297 .see     concept ident          "RFC 1413"
298 .see     concept "LF character" "linefeed"
299 .seealso concept maximum        limit
300 .see     concept monitor        "Exim monitor"
301 .see     concept "no_<emphasis>xxx</emphasis>"          "entry for xxx"
302 .see     concept NUL            "binary zero"
303 .see     concept "passwd file"  "/etc/passwd"
304 .see     concept "process id"   pid
305 .see     concept RBL            "DNS list"
306 .see     concept redirection    "address redirection"
307 .see     concept "return path"  "envelope sender"
308 .see     concept scanning       "content scanning"
309 .see     concept SSL            TLS
310 .see     concept string         expansion expansion
311 .see     concept "top bit"      "8-bit characters"
312 .see     concept variables      "expansion, variables"
313 .see     concept "zero, binary" "binary zero"
314
315
316 . /////////////////////////////////////////////////////////////////////////////
317 . This is the real start of the first chapter. See the comment above as to why
318 . we can't have the .chapter line here.
319 . chapter "Introduction"
320 . /////////////////////////////////////////////////////////////////////////////
321
322 Exim is a mail transfer agent (MTA) for hosts that are running Unix or
323 Unix-like operating systems. It was designed on the assumption that it would be
324 run on hosts that are permanently connected to the Internet. However, it can be
325 used on intermittently connected hosts with suitable configuration adjustments.
326
327 Configuration files currently exist for the following operating systems: AIX,
328 BSD/OS (aka BSDI), Darwin (Mac OS X), DGUX, Dragonfly, FreeBSD, GNU/Hurd,
329 GNU/Linux, HI-OSF (Hitachi), HI-UX, HP-UX, IRIX, MIPS RISCOS, NetBSD, OpenBSD,
330 OpenUNIX, QNX, SCO, SCO SVR4.2 (aka UNIX-SV), Solaris (aka SunOS5), SunOS4,
331 Tru64-Unix (formerly Digital UNIX, formerly DEC-OSF1), Ultrix, and UnixWare.
332 Some of these operating systems are no longer current and cannot easily be
333 tested, so the configuration files may no longer work in practice.
334
335 There are also configuration files for compiling Exim in the Cygwin environment
336 that can be installed on systems running Windows. However, this document does
337 not contain any information about running Exim in the Cygwin environment.
338
339 The terms and conditions for the use and distribution of Exim are contained in
340 the file &_NOTICE_&. Exim is distributed under the terms of the GNU General
341 Public Licence, a copy of which may be found in the file &_LICENCE_&.
342
343 The use, supply, or promotion of Exim for the purpose of sending bulk,
344 unsolicited electronic mail is incompatible with the basic aims of Exim,
345 which revolve around the free provision of a service that enhances the quality
346 of personal communications. The author of Exim regards indiscriminate
347 mass-mailing as an antisocial, irresponsible abuse of the Internet.
348
349 Exim owes a great deal to Smail 3 and its author, Ron Karr. Without the
350 experience of running and working on the Smail 3 code, I could never have
351 contemplated starting to write a new MTA. Many of the ideas and user interfaces
352 were originally taken from Smail 3, though the actual code of Exim is entirely
353 new, and has developed far beyond the initial concept.
354
355 Many people, both in Cambridge and around the world, have contributed to the
356 development and the testing of Exim, and to porting it to various operating
357 systems. I am grateful to them all. The distribution now contains a file called
358 &_ACKNOWLEDGMENTS_&, in which I have started recording the names of
359 contributors.
360
361
362 .section "Exim documentation" "SECID1"
363 . Keep this example change bar when updating the documentation!
364
365 .new
366 .cindex "documentation"
367 This edition of the Exim specification applies to version &version() of Exim.
368 Substantive changes from the &previousversion; edition are marked in some
369 renditions of this document; this paragraph is so marked if the rendition is
370 capable of showing a change indicator.
371 .wen
372
373 This document is very much a reference manual; it is not a tutorial. The reader
374 is expected to have some familiarity with the SMTP mail transfer protocol and
375 with general Unix system administration. Although there are some discussions
376 and examples in places, the information is mostly organized in a way that makes
377 it easy to look up, rather than in a natural order for sequential reading.
378 Furthermore, this manual aims to cover every aspect of Exim in detail, including
379 a number of rarely-used, special-purpose features that are unlikely to be of
380 very wide interest.
381
382 .cindex "books about Exim"
383 An &"easier"& discussion of Exim which provides more in-depth explanatory,
384 introductory, and tutorial material can be found in a book entitled &'The Exim
385 SMTP Mail Server'& (second edition, 2007), published by UIT Cambridge
386 (&url(https://www.uit.co.uk/exim-book/)).
387
388 The book also contains a chapter that gives a general introduction to SMTP and
389 Internet mail. Inevitably, however, the book is unlikely to be fully up-to-date
390 with the latest release of Exim. (Note that the earlier book about Exim,
391 published by O'Reilly, covers Exim 3, and many things have changed in Exim 4.)
392
393 .cindex "Debian" "information sources"
394 If you are using a Debian distribution of Exim, you will find information about
395 Debian-specific features in the file
396 &_/usr/share/doc/exim4-base/README.Debian_&.
397 The command &(man update-exim.conf)& is another source of Debian-specific
398 information.
399
400 .cindex "&_doc/NewStuff_&"
401 .cindex "&_doc/ChangeLog_&"
402 .cindex "change log"
403 As Exim develops, there may be features in newer versions that have not
404 yet made it into this document, which is updated only when the most significant
405 digit of the fractional part of the version number changes. Specifications of
406 new features that are not yet in this manual are placed in the file
407 &_doc/NewStuff_& in the Exim distribution.
408
409 Some features may be classified as &"experimental"&. These may change
410 incompatibly while they are developing, or even be withdrawn. For this reason,
411 they are not documented in this manual. Information about experimental features
412 can be found in the file &_doc/experimental.txt_&.
413
414 All changes to Exim (whether new features, bug fixes, or other kinds of
415 change) are noted briefly in the file called &_doc/ChangeLog_&.
416
417 .cindex "&_doc/spec.txt_&"
418 This specification itself is available as an ASCII file in &_doc/spec.txt_& so
419 that it can easily be searched with a text editor. Other files in the &_doc_&
420 directory are:
421
422 .table2 100pt
423 .row &_OptionLists.txt_&     "list of all options in alphabetical order"
424 .row &_dbm.discuss.txt_&     "discussion about DBM libraries"
425 .row &_exim.8_&              "a man page of Exim's command line options"
426 .row &_experimental.txt_&    "documentation of experimental features"
427 .row &_filter.txt_&          "specification of the filter language"
428 .row &_Exim3.upgrade_&       "upgrade notes from release 2 to release 3"
429 .row &_Exim4.upgrade_&       "upgrade notes from release 3 to release 4"
430 .row &_openssl.txt_&         "installing a current OpenSSL release"
431 .endtable
432
433 The main specification and the specification of the filtering language are also
434 available in other formats (HTML, PostScript, PDF, and Texinfo). Section
435 &<<SECTavail>>& below tells you how to get hold of these.
436
437
438
439 .section "FTP site and websites" "SECID2"
440 .cindex "website"
441 .cindex "FTP site"
442 The primary site for Exim source distributions is the &%exim.org%& FTP site,
443 available over HTTPS, HTTP and FTP.  These services, and the &%exim.org%&
444 website, are hosted at the University of Cambridge.
445
446 .cindex "wiki"
447 .cindex "FAQ"
448 As well as Exim distribution tar files, the Exim website contains a number of
449 differently formatted versions of the documentation. A recent addition to the
450 online information is the Exim wiki (&url(https://wiki.exim.org)),
451 which contains what used to be a separate FAQ, as well as various other
452 examples, tips, and know-how that have been contributed by Exim users.
453 The wiki site should always redirect to the correct place, which is currently
454 provided by GitHub, and is open to editing by anyone with a GitHub account.
455
456 .cindex Bugzilla
457 An Exim Bugzilla exists at &url(https://bugs.exim.org). You can use
458 this to report bugs, and also to add items to the wish list. Please search
459 first to check that you are not duplicating a previous entry.
460 Please do not ask for configuration help in the bug-tracker.
461
462
463 .section "Mailing lists" "SECID3"
464 .cindex "mailing lists" "for Exim users"
465 The following Exim mailing lists exist:
466
467 .table2 140pt
468 .row &'exim-announce@lists.exim.org'&   "Moderated, low volume announcements list"
469 .row &'exim-users@lists.exim.org'&      "General discussion list"
470 .row &'exim-users-de@lists.exim.org'&   "General discussion list in German language"
471 .row &'exim-dev@lists.exim.org'&        "Discussion of bugs, enhancements, etc."
472 .row &'exim-cvs@lists.exim.org'&        "Automated commit messages from the VCS"
473 .endtable
474
475 You can subscribe to these lists, change your existing subscriptions, and view
476 or search the archives via the mailing lists link on the Exim home page.
477 .cindex "Debian" "mailing list for"
478 If you are using a Debian distribution of Exim, you may wish to subscribe to
479 the Debian-specific mailing list &'pkg-exim4-users@lists.alioth.debian.org'&
480 via this web page:
481 .display
482 &url(https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-exim4-users)
483 .endd
484 Please ask Debian-specific questions on that list and not on the general Exim
485 lists.
486
487 .section "Bug reports" "SECID5"
488 .cindex "bug reports"
489 .cindex "reporting bugs"
490 Reports of obvious bugs can be emailed to &'bugs@exim.org'& or reported
491 via the Bugzilla (&url(https://bugs.exim.org)). However, if you are unsure
492 whether some behaviour is a bug or not, the best thing to do is to post a
493 message to the &'exim-dev'& mailing list and have it discussed.
494
495
496
497 .section "Where to find the Exim distribution" "SECTavail"
498 .cindex "FTP site"
499 .cindex "HTTPS download site"
500 .cindex "distribution" "FTP site"
501 .cindex "distribution" "https site"
502 The master distribution site for the Exim distribution is
503 .display
504 &url(https://downloads.exim.org/)
505 .endd
506 The service is available over HTTPS, HTTP and FTP.
507 We encourage people to migrate to HTTPS.
508
509 The content served at &url(https://downloads.exim.org/) is identical to the
510 content served at &url(https://ftp.exim.org/pub/exim) and
511 &url(ftp://ftp.exim.org/pub/exim).
512
513 If accessing via a hostname containing &'ftp'&, then the file references that
514 follow are relative to the &_exim_& directories at these sites.
515 If accessing via the hostname &'downloads'& then the subdirectories described
516 here are top-level directories.
517
518 There are now quite a number of independent mirror sites around
519 the world. Those that I know about are listed in the file called &_Mirrors_&.
520
521 Within the top exim directory there are subdirectories called &_exim3_& (for
522 previous Exim 3 distributions), &_exim4_& (for the latest Exim 4
523 distributions), and &_Testing_& for testing versions. In the &_exim4_&
524 subdirectory, the current release can always be found in files called
525 .display
526 &_exim-n.nn.tar.xz_&
527 &_exim-n.nn.tar.gz_&
528 &_exim-n.nn.tar.bz2_&
529 .endd
530 where &'n.nn'& is the highest such version number in the directory. The three
531 files contain identical data; the only difference is the type of compression.
532 The &_.xz_& file is usually the smallest, while the &_.gz_& file is the
533 most portable to old systems.
534
535 .cindex "distribution" "signing details"
536 .cindex "distribution" "public key"
537 .cindex "public key for signed distribution"
538 The distributions will be PGP signed by an individual key of the Release
539 Coordinator.  This key will have a uid containing an email address in the
540 &'exim.org'& domain and will have signatures from other people, including
541 other Exim maintainers.  We expect that the key will be in the "strong set" of
542 PGP keys.  There should be a trust path to that key from the Exim Maintainer's
543 PGP keys, a version of which can be found in the release directory in the file
544 &_Exim-Maintainers-Keyring.asc_&.  All keys used will be available in public keyserver pools,
545 such as &'pool.sks-keyservers.net'&.
546
547 At the time of the last update, releases were being made by Jeremy Harris and signed
548 with key &'0xBCE58C8CE41F32DF'&.  Other recent keys used for signing are those
549 of Heiko Schlittermann, &'0x26101B62F69376CE'&,
550 and of Phil Pennock, &'0x4D1E900E14C1CC04'&.
551
552 The signatures for the tar bundles are in:
553 .display
554 &_exim-n.nn.tar.xz.asc_&
555 &_exim-n.nn.tar.gz.asc_&
556 &_exim-n.nn.tar.bz2.asc_&
557 .endd
558 For each released version, the log of changes is made available in a
559 separate file in the directory &_ChangeLogs_& so that it is possible to
560 find out what has changed without having to download the entire distribution.
561
562 .cindex "documentation" "available formats"
563 The main distribution contains ASCII versions of this specification and other
564 documentation; other formats of the documents are available in separate files
565 inside the &_exim4_& directory of the FTP site:
566 .display
567 &_exim-html-n.nn.tar.gz_&
568 &_exim-pdf-n.nn.tar.gz_&
569 &_exim-postscript-n.nn.tar.gz_&
570 &_exim-texinfo-n.nn.tar.gz_&
571 .endd
572 These tar files contain only the &_doc_& directory, not the complete
573 distribution, and are also available in &_.bz2_& and &_.xz_& forms.
574
575
576 .section "Limitations" "SECID6"
577 .ilist
578 .cindex "limitations of Exim"
579 .cindex "bang paths" "not handled by Exim"
580 Exim is designed for use as an Internet MTA, and therefore handles addresses in
581 RFC 2822 domain format only. It cannot handle UUCP &"bang paths"&, though
582 simple two-component bang paths can be converted by a straightforward rewriting
583 configuration. This restriction does not prevent Exim from being interfaced to
584 UUCP as a transport mechanism, provided that domain addresses are used.
585 .next
586 .cindex "domainless addresses"
587 .cindex "address" "without domain"
588 Exim insists that every address it handles has a domain attached. For incoming
589 local messages, domainless addresses are automatically qualified with a
590 configured domain value. Configuration options specify from which remote
591 systems unqualified addresses are acceptable. These are then qualified on
592 arrival.
593 .next
594 .cindex "transport" "external"
595 .cindex "external transports"
596 The only external transport mechanisms that are currently implemented are SMTP
597 and LMTP over a TCP/IP network (including support for IPv6). However, a pipe
598 transport is available, and there are facilities for writing messages to files
599 and pipes, optionally in &'batched SMTP'& format; these facilities can be used
600 to send messages to other transport mechanisms such as UUCP, provided they can
601 handle domain-style addresses. Batched SMTP input is also catered for.
602 .next
603 Exim is not designed for storing mail for dial-in hosts. When the volumes of
604 such mail are large, it is better to get the messages &"delivered"& into files
605 (that is, off Exim's queue) and subsequently passed on to the dial-in hosts by
606 other means.
607 .next
608 Although Exim does have basic facilities for scanning incoming messages, these
609 are not comprehensive enough to do full virus or spam scanning. Such operations
610 are best carried out using additional specialized software packages. If you
611 compile Exim with the content-scanning extension, straightforward interfaces to
612 a number of common scanners are provided.
613 .endlist
614
615
616 .section "Runtime configuration" "SECID7"
617 Exim's runtime configuration is held in a single text file that is divided
618 into a number of sections. The entries in this file consist of keywords and
619 values, in the style of Smail 3 configuration files. A default configuration
620 file which is suitable for simple online installations is provided in the
621 distribution, and is described in chapter &<<CHAPdefconfil>>& below.
622
623
624 .section "Calling interface" "SECID8"
625 .cindex "Sendmail compatibility" "command line interface"
626 Like many MTAs, Exim has adopted the Sendmail command line interface so that it
627 can be a straight replacement for &_/usr/lib/sendmail_& or
628 &_/usr/sbin/sendmail_& when sending mail, but you do not need to know anything
629 about Sendmail in order to run Exim. For actions other than sending messages,
630 Sendmail-compatible options also exist, but those that produce output (for
631 example, &%-bp%&, which lists the messages in the queue) do so in Exim's own
632 format. There are also some additional options that are compatible with Smail
633 3, and some further options that are new to Exim. Chapter &<<CHAPcommandline>>&
634 documents all Exim's command line options. This information is automatically
635 made into the man page that forms part of the Exim distribution.
636
637 Control of messages in the queue can be done via certain privileged command
638 line options. There is also an optional monitor program called &'eximon'&,
639 which displays current information in an X window, and which contains a menu
640 interface to Exim's command line administration options.
641
642
643
644 .section "Terminology" "SECID9"
645 .cindex "terminology definitions"
646 .cindex "body of message" "definition of"
647 The &'body'& of a message is the actual data that the sender wants to transmit.
648 It is the last part of a message and is separated from the &'header'& (see
649 below) by a blank line.
650
651 .cindex "bounce message" "definition of"
652 When a message cannot be delivered, it is normally returned to the sender in a
653 delivery failure message or a &"non-delivery report"& (NDR). The term
654 &'bounce'& is commonly used for this action, and the error reports are often
655 called &'bounce messages'&. This is a convenient shorthand for &"delivery
656 failure error report"&. Such messages have an empty sender address in the
657 message's &'envelope'& (see below) to ensure that they cannot themselves give
658 rise to further bounce messages.
659
660 The term &'default'& appears frequently in this manual. It is used to qualify a
661 value which is used in the absence of any setting in the configuration. It may
662 also qualify an action which is taken unless a configuration setting specifies
663 otherwise.
664
665 The term &'defer'& is used when the delivery of a message to a specific
666 destination cannot immediately take place for some reason (a remote host may be
667 down, or a user's local mailbox may be full). Such deliveries are &'deferred'&
668 until a later time.
669
670 The word &'domain'& is sometimes used to mean all but the first component of a
671 host's name. It is &'not'& used in that sense here, where it normally refers to
672 the part of an email address following the @ sign.
673
674 .cindex "envelope, definition of"
675 .cindex "sender" "definition of"
676 A message in transit has an associated &'envelope'&, as well as a header and a
677 body. The envelope contains a sender address (to which bounce messages should
678 be delivered), and any number of recipient addresses. References to the
679 sender or the recipients of a message usually mean the addresses in the
680 envelope. An MTA uses these addresses for delivery, and for returning bounce
681 messages, not the addresses that appear in the header lines.
682
683 .cindex "message" "header, definition of"
684 .cindex "header section" "definition of"
685 The &'header'& of a message is the first part of a message's text, consisting
686 of a number of lines, each of which has a name such as &'From:'&, &'To:'&,
687 &'Subject:'&, etc. Long header lines can be split over several text lines by
688 indenting the continuations. The header is separated from the body by a blank
689 line.
690
691 .cindex "local part" "definition of"
692 .cindex "domain" "definition of"
693 The term &'local part'&, which is taken from RFC 2822, is used to refer to the
694 part of an email address that precedes the @ sign. The part that follows the
695 @ sign is called the &'domain'& or &'mail domain'&.
696
697 .cindex "local delivery" "definition of"
698 .cindex "remote delivery, definition of"
699 The terms &'local delivery'& and &'remote delivery'& are used to distinguish
700 delivery to a file or a pipe on the local host from delivery by SMTP over
701 TCP/IP to another host. As far as Exim is concerned, all hosts other than the
702 host it is running on are &'remote'&.
703
704 .cindex "return path" "definition of"
705 &'Return path'& is another name that is used for the sender address in a
706 message's envelope.
707
708 .cindex "queue" "definition of"
709 The term &'queue'& is used to refer to the set of messages awaiting delivery
710 because this term is in widespread use in the context of MTAs. However, in
711 Exim's case, the reality is more like a pool than a queue, because there is
712 normally no ordering of waiting messages.
713
714 .cindex "queue runner" "definition of"
715 The term &'queue runner'& is used to describe a process that scans the queue
716 and attempts to deliver those messages whose retry times have come. This term
717 is used by other MTAs and also relates to the command &%runq%&, but in Exim
718 the waiting messages are normally processed in an unpredictable order.
719
720 .cindex "spool directory" "definition of"
721 The term &'spool directory'& is used for a directory in which Exim keeps the
722 messages in its queue &-- that is, those that it is in the process of
723 delivering. This should not be confused with the directory in which local
724 mailboxes are stored, which is called a &"spool directory"& by some people. In
725 the Exim documentation, &"spool"& is always used in the first sense.
726
727
728
729
730
731
732 . ////////////////////////////////////////////////////////////////////////////
733 . ////////////////////////////////////////////////////////////////////////////
734
735 .chapter "Incorporated code" "CHID2"
736 .cindex "incorporated code"
737 .cindex "regular expressions" "library"
738 .cindex "PCRE2"
739 .cindex "OpenDMARC"
740 A number of pieces of external code are included in the Exim distribution.
741
742 .ilist
743 Regular expressions are supported in the main Exim program and in the
744 Exim monitor using the freely-distributable PCRE2 library, copyright
745 &copy; University of Cambridge. The source to PCRE2 is not longer shipped with
746 Exim, so you will need to use the version of PCRE2 shipped with your system,
747 or obtain and install the full version of the library from
748 &url(https://github.com/PhilipHazel/pcre2/releases).
749 .next
750 .cindex "cdb" "acknowledgment"
751 Support for the cdb (Constant DataBase) lookup method is provided by code
752 contributed by Nigel Metheringham of (at the time he contributed it) Planet
753 Online Ltd. The implementation is completely contained within the code of Exim.
754 It does not link against an external cdb library. The code contains the
755 following statements:
756
757 .blockquote
758 Copyright &copy; 1998 Nigel Metheringham, Planet Online Ltd
759
760 This program is free software; you can redistribute it and/or modify it under
761 the terms of the GNU General Public License as published by the Free Software
762 Foundation; either version 2 of the License, or (at your option) any later
763 version.
764 This code implements Dan Bernstein's Constant DataBase (cdb) spec. Information,
765 the spec and sample code for cdb can be obtained from
766 &url(https://cr.yp.to/cdb.html). This implementation borrows
767 some code from Dan Bernstein's implementation (which has no license
768 restrictions applied to it).
769 .endblockquote
770 .next
771 .cindex "SPA authentication"
772 .cindex "Samba project"
773 .cindex "Microsoft Secure Password Authentication"
774 Client support for Microsoft's &'Secure Password Authentication'& is provided
775 by code contributed by Marc Prud'hommeaux. Server support was contributed by
776 Tom Kistner. This includes code taken from the Samba project, which is released
777 under the Gnu GPL.
778 .next
779 .cindex "Cyrus"
780 .cindex "&'pwcheck'& daemon"
781 .cindex "&'pwauthd'& daemon"
782 Support for calling the Cyrus &'pwcheck'& and &'saslauthd'& daemons is provided
783 by code taken from the Cyrus-SASL library and adapted by Alexander S.
784 Sabourenkov. The permission notice appears below, in accordance with the
785 conditions expressed therein.
786
787 .blockquote
788 Copyright &copy; 2001 Carnegie Mellon University.  All rights reserved.
789
790 Redistribution and use in source and binary forms, with or without
791 modification, are permitted provided that the following conditions
792 are met:
793
794 .olist
795 Redistributions of source code must retain the above copyright
796 notice, this list of conditions and the following disclaimer.
797 .next
798 Redistributions in binary form must reproduce the above copyright
799 notice, this list of conditions and the following disclaimer in
800 the documentation and/or other materials provided with the
801 distribution.
802 .next
803 The name &"Carnegie Mellon University"& must not be used to
804 endorse or promote products derived from this software without
805 prior written permission. For permission or any other legal
806 details, please contact
807 .display
808               Office of Technology Transfer
809               Carnegie Mellon University
810               5000 Forbes Avenue
811               Pittsburgh, PA  15213-3890
812               (412) 268-4387, fax: (412) 268-7395
813               tech-transfer@andrew.cmu.edu
814 .endd
815 .next
816 Redistributions of any form whatsoever must retain the following
817 acknowledgment:
818
819 &"This product includes software developed by Computing Services
820 at Carnegie Mellon University (&url(https://www.cmu.edu/computing/)."&
821
822 CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
823 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
824 AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
825 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
826 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
827 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
828 OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
829 .endlist
830 .endblockquote
831
832 .next
833 .cindex "Exim monitor" "acknowledgment"
834 .cindex "X-windows"
835 .cindex "Athena"
836 The Exim Monitor program, which is an X-Window application, includes
837 modified versions of the Athena StripChart and TextPop widgets.
838 This code is copyright by DEC and MIT, and their permission notice appears
839 below, in accordance with the conditions expressed therein.
840
841 .blockquote
842 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
843 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
844
845 All Rights Reserved
846
847 Permission to use, copy, modify, and distribute this software and its
848 documentation for any purpose and without fee is hereby granted,
849 provided that the above copyright notice appear in all copies and that
850 both that copyright notice and this permission notice appear in
851 supporting documentation, and that the names of Digital or MIT not be
852 used in advertising or publicity pertaining to distribution of the
853 software without specific, written prior permission.
854
855 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
856 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
857 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
858 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
859 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
860 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
861 SOFTWARE.
862 .endblockquote
863
864 .next
865 .cindex "opendmarc" "acknowledgment"
866 The DMARC implementation uses the OpenDMARC library which is Copyrighted by
867 The Trusted Domain Project. Portions of Exim source which use OpenDMARC
868 derived code are indicated in the respective source files. The full OpenDMARC
869 license is provided in the LICENSE.opendmarc file contained in the distributed
870 source code.
871
872 .next
873 Many people have contributed code fragments, some large, some small, that were
874 not covered by any specific license requirements. It is assumed that the
875 contributors are happy to see their code incorporated into Exim under the GPL.
876 .endlist
877
878
879
880
881
882 . ////////////////////////////////////////////////////////////////////////////
883 . ////////////////////////////////////////////////////////////////////////////
884
885 .chapter "How Exim receives and delivers mail" "CHID11" &&&
886          "Receiving and delivering mail"
887
888
889 .section "Overall philosophy" "SECID10"
890 .cindex "design philosophy"
891 Exim is designed to work efficiently on systems that are permanently connected
892 to the Internet and are handling a general mix of mail. In such circumstances,
893 most messages can be delivered immediately. Consequently, Exim does not
894 maintain independent queues of messages for specific domains or hosts, though
895 it does try to send several messages in a single SMTP connection after a host
896 has been down, and it also maintains per-host retry information.
897
898
899 .section "Policy control" "SECID11"
900 .cindex "policy control" "overview"
901 Policy controls are now an important feature of MTAs that are connected to the
902 Internet. Perhaps their most important job is to stop MTAs from being abused as
903 &"open relays"& by misguided individuals who send out vast amounts of
904 unsolicited junk and want to disguise its source. Exim provides flexible
905 facilities for specifying policy controls on incoming mail:
906
907 .ilist
908 .cindex "&ACL;" "introduction"
909 Exim 4 (unlike previous versions of Exim) implements policy controls on
910 incoming mail by means of &'Access Control Lists'& (ACLs). Each list is a
911 series of statements that may either grant or deny access. ACLs can be used at
912 several places in the SMTP dialogue while receiving a message from a remote
913 host. However, the most common places are after each RCPT command, and at the
914 very end of the message. The sysadmin can specify conditions for accepting or
915 rejecting individual recipients or the entire message, respectively, at these
916 two points (see chapter &<<CHAPACL>>&). Denial of access results in an SMTP
917 error code.
918 .next
919 An ACL is also available for locally generated, non-SMTP messages. In this
920 case, the only available actions are to accept or deny the entire message.
921 .next
922 When Exim is compiled with the content-scanning extension, facilities are
923 provided in the ACL mechanism for passing the message to external virus and/or
924 spam scanning software. The result of such a scan is passed back to the ACL,
925 which can then use it to decide what to do with the message.
926 .next
927 When a message has been received, either from a remote host or from the local
928 host, but before the final acknowledgment has been sent, a locally supplied C
929 function called &[local_scan()]& can be run to inspect the message and decide
930 whether to accept it or not (see chapter &<<CHAPlocalscan>>&). If the message
931 is accepted, the list of recipients can be modified by the function.
932 .next
933 Using the &[local_scan()]& mechanism is another way of calling external scanner
934 software. The &%SA-Exim%& add-on package works this way. It does not require
935 Exim to be compiled with the content-scanning extension.
936 .next
937 After a message has been accepted, a further checking mechanism is available in
938 the form of the &'system filter'& (see chapter &<<CHAPsystemfilter>>&). This
939 runs at the start of every delivery process.
940 .endlist
941
942
943
944 .section "User filters" "SECID12"
945 .cindex "filter" "introduction"
946 .cindex "Sieve filter"
947 In a conventional Exim configuration, users are able to run private filters by
948 setting up appropriate &_.forward_& files in their home directories. See
949 chapter &<<CHAPredirect>>& (about the &(redirect)& router) for the
950 configuration needed to support this, and the separate document entitled
951 &'Exim's interfaces to mail filtering'& for user details. Two different kinds
952 of filtering are available:
953
954 .ilist
955 Sieve filters are written in the standard filtering language that is defined
956 by RFC 3028.
957 .next
958 Exim filters are written in a syntax that is unique to Exim, but which is more
959 powerful than Sieve, which it pre-dates.
960 .endlist
961
962 User filters are run as part of the routing process, described below.
963
964
965
966 .section "Message identification" "SECTmessiden"
967 .cindex "message ids" "details of format"
968 .cindex "format" "of message id"
969 .cindex "id of message"
970 .cindex "base62"
971 .cindex "base36"
972 .cindex "Darwin"
973 .cindex "Cygwin"
974 .cindex "exim_msgdate"
975 Every message handled by Exim is given a &'message id'& which is 23
976 characters long. It is divided into three parts, separated by hyphens, for
977 example &`16VDhn-000000001bo-D342`&. Each part is a sequence of letters and digits,
978 normally encoding numbers in base 62. However, in the Darwin operating
979 system (Mac OS X) and when Exim is compiled to run under Cygwin, base 36
980 (avoiding the use of lower case letters) is used instead, because the message
981 id is used to construct filenames, and the names of files in those systems are
982 not always case-sensitive.
983
984 .cindex "pid (process id)" "re-use of"
985 The detail of the contents of the message id have changed as Exim has evolved.
986 Earlier versions relied on the operating system not re-using a process id (pid)
987 within one second. On modern operating systems, this assumption can no longer
988 be made, so the algorithm had to be changed. To retain backward compatibility,
989 the format of the message id was retained, which is why the following rules are
990 somewhat eccentric:
991
992 .ilist
993 The first six characters of the message id are the time at which the message
994 started to be received, to a granularity of one second. That is, this field
995 contains the number of seconds since the start of the epoch (the normal Unix
996 way of representing the date and time of day).
997 .next
998 After the first hyphen, the next
999 eleven
1000 characters are the id of the process that received the message.
1001 .next
1002 There are two different possibilities for the final four characters:
1003 .olist
1004 .oindex "&%localhost_number%&"
1005 If &%localhost_number%& is not set, this value is the fractional part of the
1006 time of reception, normally in units of
1007 microseconds.
1008 but for systems
1009 that must use base 36 instead of base 62 (because of case-insensitive file
1010 systems), the units are
1011 2 us.
1012 .next
1013 If &%localhost_number%& is set, it is multiplied by
1014 500000 (250000) and added to
1015 the fractional part of the time, which in this case is in units of 2 us (4 us).
1016 .endlist
1017 .endlist
1018
1019 After a message has been received, Exim waits for the clock to tick at the
1020 appropriate resolution before proceeding, so that if another message is
1021 received by the same process, or by another process with the same (re-used)
1022 pid, it is guaranteed that the time will be different. In most cases, the clock
1023 will already have ticked while the message was being received.
1024
1025 The exim_msgdate utility (see section &<<SECTexim_msgdate>>&) can be
1026 used to display the date, and optionally the process id, of an Exim
1027 Message ID.
1028
1029
1030 .section "Receiving mail" "SECID13"
1031 .cindex "receiving mail"
1032 .cindex "message" "reception"
1033 The only way Exim can receive mail from another host is using SMTP over
1034 TCP/IP, in which case the sender and recipient addresses are transferred using
1035 SMTP commands. However, from a locally running process (such as a user's MUA),
1036 there are several possibilities:
1037
1038 .ilist
1039 If the process runs Exim with the &%-bm%& option, the message is read
1040 non-interactively (usually via a pipe), with the recipients taken from the
1041 command line, or from the body of the message if &%-t%& is also used.
1042 .next
1043 If the process runs Exim with the &%-bS%& option, the message is also read
1044 non-interactively, but in this case the recipients are listed at the start of
1045 the message in a series of SMTP RCPT commands, terminated by a DATA
1046 command. This is called &"batch SMTP"& format,
1047 but it isn't really SMTP. The SMTP commands are just another way of passing
1048 envelope addresses in a non-interactive submission.
1049 .next
1050 If the process runs Exim with the &%-bs%& option, the message is read
1051 interactively, using the SMTP protocol. A two-way pipe is normally used for
1052 passing data between the local process and the Exim process.
1053 This is &"real"& SMTP and is handled in the same way as SMTP over TCP/IP. For
1054 example, the ACLs for SMTP commands are used for this form of submission.
1055 .next
1056 A local process may also make a TCP/IP call to the host's loopback address
1057 (127.0.0.1) or any other of its IP addresses. When receiving messages, Exim
1058 does not treat the loopback address specially. It treats all such connections
1059 in the same way as connections from other hosts.
1060 .endlist
1061
1062
1063 .cindex "message sender, constructed by Exim"
1064 .cindex "sender" "constructed by Exim"
1065 In the three cases that do not involve TCP/IP, the sender address is
1066 constructed from the login name of the user that called Exim and a default
1067 qualification domain (which can be set by the &%qualify_domain%& configuration
1068 option). For local or batch SMTP, a sender address that is passed using the
1069 SMTP MAIL command is ignored. However, the system administrator may allow
1070 certain users (&"trusted users"&) to specify a different sender addresses
1071 unconditionally, or all users to specify certain forms of different sender
1072 address. The &%-f%& option or the SMTP MAIL command is used to specify these
1073 different addresses. See section &<<SECTtrustedadmin>>& for details of trusted
1074 users, and the &%untrusted_set_sender%& option for a way of allowing untrusted
1075 users to change sender addresses.
1076
1077 Messages received by either of the non-interactive mechanisms are subject to
1078 checking by the non-SMTP ACL if one is defined. Messages received using SMTP
1079 (either over TCP/IP or interacting with a local process) can be checked by a
1080 number of ACLs that operate at different times during the SMTP session. Either
1081 individual recipients or the entire message can be rejected if local policy
1082 requirements are not met. The &[local_scan()]& function (see chapter
1083 &<<CHAPlocalscan>>&) is run for all incoming messages.
1084
1085 Exim can be configured not to start a delivery process when a message is
1086 received; this can be unconditional, or depend on the number of incoming SMTP
1087 connections or the system load. In these situations, new messages wait on the
1088 queue until a queue runner process picks them up. However, in standard
1089 configurations under normal conditions, delivery is started as soon as a
1090 message is received.
1091
1092
1093
1094
1095
1096 .section "Handling an incoming message" "SECID14"
1097 .cindex "spool directory" "files that hold a message"
1098 .cindex "file" "how a message is held"
1099 When Exim accepts a message, it writes two files in its spool directory. The
1100 first contains the envelope information, the current status of the message, and
1101 the header lines, and the second contains the body of the message. The names of
1102 the two spool files consist of the message id, followed by &`-H`& for the
1103 file containing the envelope and header, and &`-D`& for the data file.
1104
1105 .cindex "spool directory" "&_input_& sub-directory"
1106 By default, all these message files are held in a single directory called
1107 &_input_& inside the general Exim spool directory. Some operating systems do
1108 not perform very well if the number of files in a directory gets large; to
1109 improve performance in such cases, the &%split_spool_directory%& option can be
1110 used. This causes Exim to split up the input files into 62 sub-directories
1111 whose names are single letters or digits. When this is done, the queue is
1112 processed one sub-directory at a time instead of all at once, which can improve
1113 overall performance even when there are not enough files in each directory to
1114 affect file system performance.
1115
1116 The envelope information consists of the address of the message's sender and
1117 the addresses of the recipients. This information is entirely separate from
1118 any addresses contained in the header lines. The status of the message includes
1119 a list of recipients who have already received the message. The format of the
1120 first spool file is described in chapter &<<CHAPspool>>&.
1121
1122 .cindex "rewriting" "addresses"
1123 Address rewriting that is specified in the rewrite section of the configuration
1124 (see chapter &<<CHAPrewrite>>&) is done once and for all on incoming addresses,
1125 both in the header lines and the envelope, at the time the message is accepted.
1126 If during the course of delivery additional addresses are generated (for
1127 example, via aliasing), these new addresses are rewritten as soon as they are
1128 generated. At the time a message is actually delivered (transported) further
1129 rewriting can take place; because this is a transport option, it can be
1130 different for different forms of delivery. It is also possible to specify the
1131 addition or removal of certain header lines at the time the message is
1132 delivered (see chapters &<<CHAProutergeneric>>& and
1133 &<<CHAPtransportgeneric>>&).
1134
1135
1136
1137 .section "Life of a message" "SECID15"
1138 .cindex "message" "life of"
1139 .cindex "message" "frozen"
1140 A message remains in the spool directory until it is completely delivered to
1141 its recipients or to an error address, or until it is deleted by an
1142 administrator or by the user who originally created it. In cases when delivery
1143 cannot proceed &-- for example when a message can neither be delivered to its
1144 recipients nor returned to its sender, the message is marked &"frozen"& on the
1145 spool, and no more deliveries are attempted.
1146
1147 .cindex "frozen messages" "thawing"
1148 .cindex "message" "thawing frozen"
1149 An administrator can &"thaw"& such messages when the problem has been
1150 corrected, and can also freeze individual messages by hand if necessary. In
1151 addition, an administrator can force a delivery error, causing a bounce message
1152 to be sent.
1153
1154 .oindex "&%timeout_frozen_after%&"
1155 .oindex "&%ignore_bounce_errors_after%&"
1156 There are options called &%ignore_bounce_errors_after%& and
1157 &%timeout_frozen_after%&, which discard frozen messages after a certain time.
1158 The first applies only to frozen bounces, the second to all frozen messages.
1159
1160 .cindex "message" "log file for"
1161 .cindex "log" "file for each message"
1162 While Exim is working on a message, it writes information about each delivery
1163 attempt to its main log file. This includes successful, unsuccessful, and
1164 delayed deliveries for each recipient (see chapter &<<CHAPlog>>&). The log
1165 lines are also written to a separate &'message log'& file for each message.
1166 These logs are solely for the benefit of the administrator and are normally
1167 deleted along with the spool files when processing of a message is complete.
1168 The use of individual message logs can be disabled by setting
1169 &%no_message_logs%&; this might give an improvement in performance on very busy
1170 systems.
1171
1172 .cindex "journal file"
1173 .cindex "file" "journal"
1174 All the information Exim itself needs to set up a delivery is kept in the first
1175 spool file, along with the header lines. When a successful delivery occurs, the
1176 address is immediately written at the end of a journal file, whose name is the
1177 message id followed by &`-J`&. At the end of a delivery run, if there are some
1178 addresses left to be tried again later, the first spool file (the &`-H`& file)
1179 is updated to indicate which these are, and the journal file is then deleted.
1180 Updating the spool file is done by writing a new file and renaming it, to
1181 minimize the possibility of data loss.
1182
1183 Should the system or Exim crash after a successful delivery but before
1184 the spool file has been updated, the journal is left lying around. The next
1185 time Exim attempts to deliver the message, it reads the journal file and
1186 updates the spool file before proceeding. This minimizes the chances of double
1187 deliveries caused by crashes.
1188
1189
1190
1191 .section "Processing an address for delivery" "SECTprocaddress"
1192 .cindex "drivers" "definition of"
1193 .cindex "router" "definition of"
1194 .cindex "transport" "definition of"
1195 The main delivery processing elements of Exim are called &'routers'& and
1196 &'transports'&, and collectively these are known as &'drivers'&. Code for a
1197 number of them is provided in the source distribution, and compile-time options
1198 specify which ones are included in the binary. Runtime options specify which
1199 ones are actually used for delivering messages.
1200
1201 .cindex "drivers" "instance definition"
1202 Each driver that is specified in the runtime configuration is an &'instance'&
1203 of that particular driver type. Multiple instances are allowed; for example,
1204 you can set up several different &(smtp)& transports, each with different
1205 option values that might specify different ports or different timeouts. Each
1206 instance has its own identifying name. In what follows we will normally use the
1207 instance name when discussing one particular instance (that is, one specific
1208 configuration of the driver), and the generic driver name when discussing
1209 the driver's features in general.
1210
1211 A &'router'& is a driver that operates on an address, either determining how
1212 its delivery should happen, by assigning it to a specific transport, or
1213 converting the address into one or more new addresses (for example, via an
1214 alias file). A router may also explicitly choose to fail an address, causing it
1215 to be bounced.
1216
1217 A &'transport'& is a driver that transmits a copy of the message from Exim's
1218 spool to some destination. There are two kinds of transport: for a &'local'&
1219 transport, the destination is a file or a pipe on the local host, whereas for a
1220 &'remote'& transport the destination is some other host. A message is passed
1221 to a specific transport as a result of successful routing. If a message has
1222 several recipients, it may be passed to a number of different transports.
1223
1224 .cindex "preconditions" "definition of"
1225 An address is processed by passing it to each configured router instance in
1226 turn, subject to certain preconditions, until a router accepts the address or
1227 specifies that it should be bounced. We will describe this process in more
1228 detail shortly. First, as a simple example, we consider how each recipient
1229 address in a message is processed in a small configuration of three routers.
1230
1231 To make this a more concrete example, it is described in terms of some actual
1232 routers, but remember, this is only an example. You can configure Exim's
1233 routers in many different ways, and there may be any number of routers in a
1234 configuration.
1235
1236 The first router that is specified in a configuration is often one that handles
1237 addresses in domains that are not recognized specifically by the local host.
1238 Typically these are addresses for arbitrary domains on the Internet. A precondition
1239 is set up which looks for the special domains known to the host (for example,
1240 its own domain name), and the router is run for addresses that do &'not'&
1241 match. Typically, this is a router that looks up domains in the DNS in order to
1242 find the hosts to which this address routes. If it succeeds, the address is
1243 assigned to a suitable SMTP transport; if it does not succeed, the router is
1244 configured to fail the address.
1245
1246 The second router is reached only when the domain is recognized as one that
1247 &"belongs"& to the local host. This router does redirection &-- also known as
1248 aliasing and forwarding. When it generates one or more new addresses from the
1249 original, each of them is routed independently from the start. Otherwise, the
1250 router may cause an address to fail, or it may simply decline to handle the
1251 address, in which case the address is passed to the next router.
1252
1253 The final router in many configurations is one that checks to see if the
1254 address belongs to a local mailbox. The precondition may involve a check to
1255 see if the local part is the name of a login account, or it may look up the
1256 local part in a file or a database. If its preconditions are not met, or if
1257 the router declines, we have reached the end of the routers. When this happens,
1258 the address is bounced.
1259
1260
1261
1262 .section "Processing an address for verification" "SECID16"
1263 .cindex "router" "for verification"
1264 .cindex "verifying address" "overview"
1265 As well as being used to decide how to deliver to an address, Exim's routers
1266 are also used for &'address verification'&. Verification can be requested as
1267 one of the checks to be performed in an ACL for incoming messages, on both
1268 sender and recipient addresses, and it can be tested using the &%-bv%& and
1269 &%-bvs%& command line options.
1270
1271 When an address is being verified, the routers are run in &"verify mode"&. This
1272 does not affect the way the routers work, but it is a state that can be
1273 detected. By this means, a router can be skipped or made to behave differently
1274 when verifying. A common example is a configuration in which the first router
1275 sends all messages to a message-scanning program unless they have been
1276 previously scanned. Thus, the first router accepts all addresses without any
1277 checking, making it useless for verifying. Normally, the &%no_verify%& option
1278 would be set for such a router, causing it to be skipped in verify mode.
1279
1280
1281
1282
1283 .section "Running an individual router" "SECTrunindrou"
1284 .cindex "router" "running details"
1285 .cindex "preconditions" "checking"
1286 .cindex "router" "result of running"
1287 As explained in the example above, a number of preconditions are checked before
1288 running a router. If any are not met, the router is skipped, and the address is
1289 passed to the next router. When all the preconditions on a router &'are'& met,
1290 the router is run. What happens next depends on the outcome, which is one of
1291 the following:
1292
1293 .ilist
1294 &'accept'&: The router accepts the address, and either assigns it to a
1295 transport or generates one or more &"child"& addresses. Processing the
1296 original address ceases
1297 .oindex "&%unseen%&"
1298 unless the &%unseen%& option is set on the router. This option
1299 can be used to set up multiple deliveries with different routing (for example,
1300 for keeping archive copies of messages). When &%unseen%& is set, the address is
1301 passed to the next router. Normally, however, an &'accept'& return marks the
1302 end of routing.
1303
1304 Any child addresses generated by the router are processed independently,
1305 starting with the first router by default. It is possible to change this by
1306 setting the &%redirect_router%& option to specify which router to start at for
1307 child addresses. Unlike &%pass_router%& (see below) the router specified by
1308 &%redirect_router%& may be anywhere in the router configuration.
1309 .next
1310 &'pass'&: The router recognizes the address, but cannot handle it itself. It
1311 requests that the address be passed to another router. By default, the address
1312 is passed to the next router, but this can be changed by setting the
1313 &%pass_router%& option. However, (unlike &%redirect_router%&) the named router
1314 must be below the current router (to avoid loops).
1315 .next
1316 &'decline'&: The router declines to accept the address because it does not
1317 recognize it at all. By default, the address is passed to the next router, but
1318 this can be prevented by setting the &%no_more%& option. When &%no_more%& is
1319 set, all the remaining routers are skipped. In effect, &%no_more%& converts
1320 &'decline'& into &'fail'&.
1321 .next
1322 &'fail'&: The router determines that the address should fail, and queues it for
1323 the generation of a bounce message. There is no further processing of the
1324 original address unless &%unseen%& is set on the router.
1325 .next
1326 &'defer'&: The router cannot handle the address at the present time. (A
1327 database may be offline, or a DNS lookup may have timed out.) No further
1328 processing of the address happens in this delivery attempt. It is tried again
1329 next time the message is considered for delivery.
1330 .next
1331 &'error'&: There is some error in the router (for example, a syntax error in
1332 its configuration). The action is as for defer.
1333 .endlist
1334
1335 If an address reaches the end of the routers without having been accepted by
1336 any of them, it is bounced as unrouteable. The default error message in this
1337 situation is &"unrouteable address"&, but you can set your own message by
1338 making use of the &%cannot_route_message%& option. This can be set for any
1339 router; the value from the last router that &"saw"& the address is used.
1340
1341 Sometimes while routing you want to fail a delivery when some conditions are
1342 met but others are not, instead of passing the address on for further routing.
1343 You can do this by having a second router that explicitly fails the delivery
1344 when the relevant conditions are met. The &(redirect)& router has a &"fail"&
1345 facility for this purpose.
1346
1347
1348 .section "Duplicate addresses" "SECID17"
1349 .cindex "case of local parts"
1350 .cindex "address duplicate, discarding"
1351 .cindex "duplicate addresses"
1352 Once routing is complete, Exim scans the addresses that are assigned to local
1353 and remote transports and discards any duplicates that it finds. During this
1354 check, local parts are treated case-sensitively. This happens only when
1355 actually delivering a message; when testing routers with &%-bt%&, all the
1356 routed addresses are shown.
1357
1358
1359
1360 .section "Router preconditions" "SECTrouprecon"
1361 .cindex "router" "preconditions, order of processing"
1362 .cindex "preconditions" "order of processing"
1363 The preconditions that are tested for each router are listed below, in the
1364 order in which they are tested. The individual configuration options are
1365 described in more detail in chapter &<<CHAProutergeneric>>&.
1366
1367 .olist
1368 .cindex affix "router precondition"
1369 The &%local_part_prefix%& and &%local_part_suffix%& options can specify that
1370 the local parts handled by the router may or must have certain prefixes and/or
1371 suffixes. If a mandatory affix (prefix or suffix) is not present, the router is
1372 skipped. These conditions are tested first. When an affix is present, it is
1373 removed from the local part before further processing, including the evaluation
1374 of any other conditions.
1375 .next
1376 Routers can be designated for use only when not verifying an address, that is,
1377 only when routing it for delivery (or testing its delivery routing). If the
1378 &%verify%& option is set false, the router is skipped when Exim is verifying an
1379 address.
1380 Setting the &%verify%& option actually sets two options, &%verify_sender%& and
1381 &%verify_recipient%&, which independently control the use of the router for
1382 sender and recipient verification. You can set these options directly if
1383 you want a router to be used for only one type of verification.
1384 Note that cutthrough delivery is classed as a recipient verification for this purpose.
1385 .next
1386 If the &%address_test%& option is set false, the router is skipped when Exim is
1387 run with the &%-bt%& option to test an address routing. This can be helpful
1388 when the first router sends all new messages to a scanner of some sort; it
1389 makes it possible to use &%-bt%& to test subsequent delivery routing without
1390 having to simulate the effect of the scanner.
1391 .next
1392 Routers can be designated for use only when verifying an address, as
1393 opposed to routing it for delivery. The &%verify_only%& option controls this.
1394 Again, cutthrough delivery counts as a verification.
1395 .next
1396 Individual routers can be explicitly skipped when running the routers to
1397 check an address given in the SMTP EXPN command (see the &%expn%& option).
1398
1399 .next
1400 If the &%domains%& option is set, the domain of the address must be in the set
1401 of domains that it defines.
1402 .cindex "tainted data" "de-tainting"
1403 .cindex "de-tainting" "using router domains option"
1404 A match verifies the variable &$domain$& (which carries tainted data)
1405 and assigns an untainted value to the &$domain_data$& variable.
1406 Such an untainted value is often needed in the transport.
1407 For specifics of the matching operation and the resulting untainted value,
1408 refer to section &<<SECTdomainlist>>&.
1409
1410 When an untainted value is wanted, use this option
1411 rather than the generic &%condition%& option.
1412
1413 .next
1414 .vindex "&$local_part_prefix$&"
1415 .vindex "&$local_part_prefix_v$&"
1416 .vindex "&$local_part$&"
1417 .vindex "&$local_part_suffix$&"
1418 .vindex "&$local_part_suffix_v$&"
1419 .cindex affix "router precondition"
1420 If the &%local_parts%& option is set, the local part of the address must be in
1421 the set of local parts that it defines.
1422 A match verifies the variable &$local_part$& (which carries tainted data)
1423 and assigns an untainted value to the &$local_part_data$& variable.
1424 Such an untainted value is often needed in the transport.
1425 For specifics of the matching operation and the resulting untainted value,
1426 refer to section &<<SECTlocparlis>>&.
1427
1428 When an untainted value is wanted, use this option
1429 rather than the generic &%condition%& option.
1430
1431 If &%local_part_prefix%& or
1432 &%local_part_suffix%& is in use, the prefix or suffix is removed from the local
1433 part before this check. If you want to do precondition tests on local parts
1434 that include affixes, you can do so by using a &%condition%& option (see below)
1435 that uses the variables &$local_part$&, &$local_part_prefix$&,
1436 &$local_part_prefix_v$&, &$local_part_suffix$&
1437 and &$local_part_suffix_v$& as necessary.
1438
1439 .next
1440 .vindex "&$local_user_uid$&"
1441 .vindex "&$local_user_gid$&"
1442 .vindex "&$home$&"
1443 If the &%check_local_user%& option is set, the local part must be the name of
1444 an account on the local host. If this check succeeds, the uid and gid of the
1445 local user are placed in &$local_user_uid$& and &$local_user_gid$& and the
1446 user's home directory is placed in &$home$&; these values can be used in the
1447 remaining preconditions.
1448
1449 .next
1450 If the &%router_home_directory%& option is set, it is expanded at this point,
1451 because it overrides the value of &$home$&. If this expansion were left till
1452 later, the value of &$home$& as set by &%check_local_user%& would be used in
1453 subsequent tests. Having two different values of &$home$& in the same router
1454 could lead to confusion.
1455
1456 .next
1457 If the &%senders%& option is set, the envelope sender address must be in the
1458 set of addresses that it defines.
1459
1460 .next
1461 If the &%require_files%& option is set, the existence or non-existence of
1462 specified files is tested.
1463
1464 .next
1465 .cindex "customizing" "precondition"
1466 If the &%condition%& option is set, it is evaluated and tested. This option
1467 uses an expanded string to allow you to set up your own custom preconditions.
1468 Expanded strings are described in chapter &<<CHAPexpand>>&.
1469
1470 Note that while using
1471 this option for address matching technically works,
1472 it does not set any de-tainted values.
1473 Such values are often needed, either for router-specific options or
1474 for transport options.
1475 Using the &%domains%& and &%local_parts%& options is usually the most
1476 convenient way to obtain them.
1477 .endlist
1478
1479
1480 Note that &%require_files%& comes near the end of the list, so you cannot use
1481 it to check for the existence of a file in which to lookup up a domain, local
1482 part, or sender. However, as these options are all expanded, you can use the
1483 &%exists%& expansion condition to make such tests within each condition. The
1484 &%require_files%& option is intended for checking files that the router may be
1485 going to use internally, or which are needed by a specific transport (for
1486 example, &_.procmailrc_&).
1487
1488
1489
1490 .section "Delivery in detail" "SECID18"
1491 .cindex "delivery" "in detail"
1492 When a message is to be delivered, the sequence of events is as follows:
1493
1494 .olist
1495 If a system-wide filter file is specified, the message is passed to it. The
1496 filter may add recipients to the message, replace the recipients, discard the
1497 message, cause a new message to be generated, or cause the message delivery to
1498 fail. The format of the system filter file is the same as for Exim user filter
1499 files, described in the separate document entitled &'Exim's interfaces to mail
1500 filtering'&.
1501 .cindex "Sieve filter" "not available for system filter"
1502 (&*Note*&: Sieve cannot be used for system filter files.)
1503
1504 Some additional features are available in system filters &-- see chapter
1505 &<<CHAPsystemfilter>>& for details. Note that a message is passed to the system
1506 filter only once per delivery attempt, however many recipients it has. However,
1507 if there are several delivery attempts because one or more addresses could not
1508 be immediately delivered, the system filter is run each time. The filter
1509 condition &%first_delivery%& can be used to detect the first run of the system
1510 filter.
1511 .next
1512 Each recipient address is offered to each configured router, in turn, subject to
1513 its preconditions, until one is able to handle it. If no router can handle the
1514 address, that is, if they all decline, the address is failed. Because routers
1515 can be targeted at particular domains, several locally handled domains can be
1516 processed entirely independently of each other.
1517 .next
1518 .cindex "routing" "loops in"
1519 .cindex "loop" "while routing"
1520 A router that accepts an address may assign it to a local or a remote
1521 transport. However, the transport is not run at this time. Instead, the address
1522 is placed on a list for the particular transport, which will be run later.
1523 Alternatively, the router may generate one or more new addresses (typically
1524 from alias, forward, or filter files). New addresses are fed back into this
1525 process from the top, but in order to avoid loops, a router ignores any address
1526 which has an identically-named ancestor that was processed by itself.
1527 .next
1528 When all the routing has been done, addresses that have been successfully
1529 handled are passed to their assigned transports. When local transports are
1530 doing real local deliveries, they handle only one address at a time, but if a
1531 local transport is being used as a pseudo-remote transport (for example, to
1532 collect batched SMTP messages for transmission by some other means) multiple
1533 addresses can be handled. Remote transports can always handle more than one
1534 address at a time, but can be configured not to do so, or to restrict multiple
1535 addresses to the same domain.
1536 .next
1537 Each local delivery to a file or a pipe runs in a separate process under a
1538 non-privileged uid, and these deliveries are run one at a time. Remote
1539 deliveries also run in separate processes, normally under a uid that is private
1540 to Exim (&"the Exim user"&), but in this case, several remote deliveries can be
1541 run in parallel. The maximum number of simultaneous remote deliveries for any
1542 one message is set by the &%remote_max_parallel%& option.
1543 The order in which deliveries are done is not defined, except that all local
1544 deliveries happen before any remote deliveries.
1545 .next
1546 .cindex "queue runner"
1547 When it encounters a local delivery during a queue run, Exim checks its retry
1548 database to see if there has been a previous temporary delivery failure for the
1549 address before running the local transport. If there was a previous failure,
1550 Exim does not attempt a new delivery until the retry time for the address is
1551 reached. However, this happens only for delivery attempts that are part of a
1552 queue run. Local deliveries are always attempted when delivery immediately
1553 follows message reception, even if retry times are set for them. This makes for
1554 better behaviour if one particular message is causing problems (for example,
1555 causing quota overflow, or provoking an error in a filter file).
1556 .next
1557 .cindex "delivery" "retry in remote transports"
1558 Remote transports do their own retry handling, since an address may be
1559 deliverable to one of a number of hosts, each of which may have a different
1560 retry time. If there have been previous temporary failures and no host has
1561 reached its retry time, no delivery is attempted, whether in a queue run or
1562 not. See chapter &<<CHAPretry>>& for details of retry strategies.
1563 .next
1564 If there were any permanent errors, a bounce message is returned to an
1565 appropriate address (the sender in the common case), with details of the error
1566 for each failing address. Exim can be configured to send copies of bounce
1567 messages to other addresses.
1568 .next
1569 .cindex "delivery" "deferral"
1570 If one or more addresses suffered a temporary failure, the message is left on
1571 the queue, to be tried again later. Delivery of these addresses is said to be
1572 &'deferred'&.
1573 .next
1574 When all the recipient addresses have either been delivered or bounced,
1575 handling of the message is complete. The spool files and message log are
1576 deleted, though the message log can optionally be preserved if required.
1577 .endlist
1578
1579
1580
1581
1582 .section "Retry mechanism" "SECID19"
1583 .cindex "delivery" "retry mechanism"
1584 .cindex "retry" "description of mechanism"
1585 .cindex "queue runner"
1586 Exim's mechanism for retrying messages that fail to get delivered at the first
1587 attempt is the queue runner process. You must either run an Exim daemon that
1588 uses the &%-q%& option with a time interval to start queue runners at regular
1589 intervals or use some other means (such as &'cron'&) to start them. If you do
1590 not arrange for queue runners to be run, messages that fail temporarily at the
1591 first attempt will remain in your queue forever. A queue runner process works
1592 its way through the queue, one message at a time, trying each delivery that has
1593 passed its retry time.
1594 You can run several queue runners at once.
1595
1596 Exim uses a set of configured rules to determine when next to retry the failing
1597 address (see chapter &<<CHAPretry>>&). These rules also specify when Exim
1598 should give up trying to deliver to the address, at which point it generates a
1599 bounce message. If no retry rules are set for a particular host, address, and
1600 error combination, no retries are attempted, and temporary errors are treated
1601 as permanent.
1602
1603
1604
1605 .subsection "Temporary delivery failure" SECID20
1606 .cindex "delivery" "temporary failure"
1607 There are many reasons why a message may not be immediately deliverable to a
1608 particular address. Failure to connect to a remote machine (because it, or the
1609 connection to it, is down) is one of the most common. Temporary failures may be
1610 detected during routing as well as during the transport stage of delivery.
1611 Local deliveries may be delayed if NFS files are unavailable, or if a mailbox
1612 is on a file system where the user is over quota. Exim can be configured to
1613 impose its own quotas on local mailboxes; where system quotas are set they will
1614 also apply.
1615
1616 If a host is unreachable for a period of time, a number of messages may be
1617 waiting for it by the time it recovers, and sending them in a single SMTP
1618 connection is clearly beneficial. Whenever a delivery to a remote host is
1619 deferred,
1620 .cindex "hints database" "deferred deliveries"
1621 Exim makes a note in its hints database, and whenever a successful
1622 SMTP delivery has happened, it looks to see if any other messages are waiting
1623 for the same host. If any are found, they are sent over the same SMTP
1624 connection, subject to a configuration limit as to the maximum number in any
1625 one connection.
1626
1627
1628
1629 .subsection "Permanent delivery failure" SECID21
1630 .cindex "delivery" "permanent failure"
1631 .cindex "bounce message" "when generated"
1632 When a message cannot be delivered to some or all of its intended recipients, a
1633 bounce message is generated. Temporary delivery failures turn into permanent
1634 errors when their timeout expires. All the addresses that fail in a given
1635 delivery attempt are listed in a single message. If the original message has
1636 many recipients, it is possible for some addresses to fail in one delivery
1637 attempt and others to fail subsequently, giving rise to more than one bounce
1638 message. The wording of bounce messages can be customized by the administrator.
1639 See chapter &<<CHAPemsgcust>>& for details.
1640
1641 .cindex "&'X-Failed-Recipients:'& header line"
1642 Bounce messages contain an &'X-Failed-Recipients:'& header line that lists the
1643 failed addresses, for the benefit of programs that try to analyse such messages
1644 automatically.
1645
1646 .cindex "bounce message" "recipient of"
1647 A bounce message is normally sent to the sender of the original message, as
1648 obtained from the message's envelope. For incoming SMTP messages, this is the
1649 address given in the MAIL command. However, when an address is expanded via a
1650 forward or alias file, an alternative address can be specified for delivery
1651 failures of the generated addresses. For a mailing list expansion (see section
1652 &<<SECTmailinglists>>&) it is common to direct bounce messages to the manager
1653 of the list.
1654
1655
1656
1657 .subsection "Failures to deliver bounce messages" SECID22
1658 .cindex "bounce message" "failure to deliver"
1659 If a bounce message (either locally generated or received from a remote host)
1660 itself suffers a permanent delivery failure, the message is left in the queue,
1661 but it is frozen, awaiting the attention of an administrator. There are options
1662 that can be used to make Exim discard such failed messages, or to keep them
1663 for only a short time (see &%timeout_frozen_after%& and
1664 &%ignore_bounce_errors_after%&).
1665
1666
1667
1668
1669
1670 . ////////////////////////////////////////////////////////////////////////////
1671 . ////////////////////////////////////////////////////////////////////////////
1672
1673 .chapter "Building and installing Exim" "CHID3"
1674 .scindex IIDbuex "building Exim"
1675
1676 .section "Unpacking" "SECID23"
1677 Exim is distributed as a gzipped or bzipped tar file which, when unpacked,
1678 creates a directory with the name of the current release (for example,
1679 &_exim-&version()_&) into which the following files are placed:
1680
1681 .table2 140pt
1682 .irow &_ACKNOWLEDGMENTS_& "contains some acknowledgments"
1683 .irow &_CHANGES_&         "contains a reference to where changes are &&&
1684   documented"
1685 .irow &_LICENCE_&         "the GNU General Public Licence"
1686 .irow &_Makefile_&        "top-level make file"
1687 .irow &_NOTICE_&          "conditions for the use of Exim"
1688 .irow &_README_&          "list of files, directories and simple build &&&
1689   instructions"
1690 .endtable
1691
1692 Other files whose names begin with &_README_& may also be present. The
1693 following subdirectories are created:
1694
1695 .table2 140pt
1696 .irow &_Local_&           "an empty directory for local configuration files"
1697 .irow &_OS_&              "OS-specific files"
1698 .irow &_doc_&             "documentation files"
1699 .irow &_exim_monitor_&    "source files for the Exim monitor"
1700 .irow &_scripts_&         "scripts used in the build process"
1701 .irow &_src_&             "remaining source files"
1702 .irow &_util_&            "independent utilities"
1703 .endtable
1704
1705 The main utility programs are contained in the &_src_& directory and are built
1706 with the Exim binary. The &_util_& directory contains a few optional scripts
1707 that may be useful to some sites.
1708
1709
1710 .section "Multiple machine architectures and operating systems" "SECID24"
1711 .cindex "building Exim" "multiple OS/architectures"
1712 The building process for Exim is arranged to make it easy to build binaries for
1713 a number of different architectures and operating systems from the same set of
1714 source files. Compilation does not take place in the &_src_& directory.
1715 Instead, a &'build directory'& is created for each architecture and operating
1716 system.
1717 .cindex "symbolic link" "to build directory"
1718 Symbolic links to the sources are installed in this directory, which is where
1719 the actual building takes place. In most cases, Exim can discover the machine
1720 architecture and operating system for itself, but the defaults can be
1721 overridden if necessary.
1722 .cindex compiler requirements
1723 .cindex compiler version
1724 A C99-capable compiler will be required for the build.
1725
1726
1727 .section "PCRE2 library" "SECTpcre"
1728 .cindex "PCRE2 library"
1729 Exim no longer has an embedded regular-expression library as the vast majority of
1730 modern systems include PCRE2 as a system library, although you may need to
1731 install the PCRE2 package or the PCRE2 development package for your operating
1732 system. If your system has a normal PCRE2 installation the Exim build
1733 process will need no further configuration. If the library or the
1734 headers are in an unusual location you will need to either set the PCRE2_LIBS
1735 and INCLUDE directives appropriately,
1736 or set PCRE2_CONFIG=yes to use the installed &(pcre-config)& command.
1737 If your operating system has no
1738 PCRE2 support then you will need to obtain and build the current PCRE2
1739 from &url(https://github.com/PhilipHazel/pcre2/releases).
1740 More information on PCRE2 is available at &url(https://www.pcre.org/).
1741
1742 .section "DBM libraries" "SECTdb"
1743 .cindex "DBM libraries" "discussion of"
1744 .cindex "hints database" "DBM files used for"
1745 Even if you do not use any DBM files in your configuration, Exim still needs a
1746 DBM library in order to operate, because it uses indexed files for its hints
1747 databases. Unfortunately, there are a number of DBM libraries in existence, and
1748 different operating systems often have different ones installed.
1749
1750 .cindex "Solaris" "DBM library for"
1751 .cindex "IRIX, DBM library for"
1752 .cindex "BSD, DBM library for"
1753 .cindex "Linux, DBM library for"
1754 If you are using Solaris, IRIX, one of the modern BSD systems, or a modern
1755 Linux distribution, the DBM configuration should happen automatically, and you
1756 may be able to ignore this section. Otherwise, you may have to learn more than
1757 you would like about DBM libraries from what follows.
1758
1759 .cindex "&'ndbm'& DBM library"
1760 Licensed versions of Unix normally contain a library of DBM functions operating
1761 via the &'ndbm'& interface, and this is what Exim expects by default. Free
1762 versions of Unix seem to vary in what they contain as standard. In particular,
1763 some early versions of Linux have no default DBM library, and different
1764 distributors have chosen to bundle different libraries with their packaged
1765 versions. However, the more recent releases seem to have standardized on the
1766 Berkeley DB library.
1767
1768 Different DBM libraries have different conventions for naming the files they
1769 use. When a program opens a file called &_dbmfile_&, there are several
1770 possibilities:
1771
1772 .olist
1773 A traditional &'ndbm'& implementation, such as that supplied as part of
1774 Solaris, operates on two files called &_dbmfile.dir_& and &_dbmfile.pag_&.
1775 .next
1776 .cindex "&'gdbm'& DBM library"
1777 The GNU library, &'gdbm'&, operates on a single file. If used via its &'ndbm'&
1778 compatibility interface it makes two different hard links to it with names
1779 &_dbmfile.dir_& and &_dbmfile.pag_&, but if used via its native interface, the
1780 filename is used unmodified.
1781 .next
1782 .cindex "Berkeley DB library"
1783 The Berkeley DB package, if called via its &'ndbm'& compatibility interface,
1784 operates on a single file called &_dbmfile.db_&, but otherwise looks to the
1785 programmer exactly the same as the traditional &'ndbm'& implementation.
1786 .next
1787 If the Berkeley package is used in its native mode, it operates on a single
1788 file called &_dbmfile_&; the programmer's interface is somewhat different to
1789 the traditional &'ndbm'& interface.
1790 .next
1791 To complicate things further, there are several very different versions of the
1792 Berkeley DB package. Version 1.85 was stable for a very long time, releases
1793 2.&'x'& and 3.&'x'& were current for a while,
1794 but the latest versions when Exim last revamped support were numbered 5.&'x'&.
1795 Maintenance of some of the earlier releases has ceased,
1796 and Exim no longer supports versions before 3.&'x'&.
1797 All versions of Berkeley DB could be obtained from
1798 &url(http://www.sleepycat.com/), which is now a redirect to their new owner's
1799 page with far newer versions listed.
1800 It is probably wise to plan to move your storage configurations away from
1801 Berkeley DB format, as today there are smaller and simpler alternatives more
1802 suited to Exim's usage model.
1803 .next
1804 .cindex "&'tdb'& DBM library"
1805 Yet another DBM library, called &'tdb'&, is available from
1806 &url(https://sourceforge.net/projects/tdb/files/). It has its own interface, and also
1807 operates on a single file.
1808 .endlist
1809
1810 .cindex "USE_DB"
1811 .cindex "DBM libraries" "configuration for building"
1812 Exim and its utilities can be compiled to use any of these interfaces. In order
1813 to use any version of the Berkeley DB package in native mode, you must set
1814 USE_DB in an appropriate configuration file (typically
1815 &_Local/Makefile_&). For example:
1816 .code
1817 USE_DB=yes
1818 .endd
1819 Similarly, for gdbm you set USE_GDBM, and for tdb you set USE_TDB. An
1820 error is diagnosed if you set more than one of these.
1821 You can set USE_NDBM if needed to override an operating system default.
1822
1823 At the lowest level, the build-time configuration sets none of these options,
1824 thereby assuming an interface of type (1). However, some operating system
1825 configuration files (for example, those for the BSD operating systems and
1826 Linux) assume type (4) by setting USE_DB as their default, and the
1827 configuration files for Cygwin set USE_GDBM. Anything you set in
1828 &_Local/Makefile_&, however, overrides these system defaults.
1829
1830 As well as setting USE_DB, USE_GDBM, or USE_TDB, it may also be
1831 necessary to set DBMLIB, to cause inclusion of the appropriate library, as
1832 in one of these lines:
1833 .code
1834 DBMLIB = -ldb
1835 DBMLIB = -ltdb
1836 DBMLIB = -lgdbm -lgdbm_compat
1837 .endd
1838 The last of those was for a Linux having GDBM provide emulated NDBM facilities.
1839 Settings like that will work if the DBM library is installed in the standard
1840 place. Sometimes it is not, and the library's header file may also not be in
1841 the default path. You may need to set INCLUDE to specify where the header
1842 file is, and to specify the path to the library more fully in DBMLIB, as in
1843 this example:
1844 .code
1845 INCLUDE=-I/usr/local/include/db-4.1
1846 DBMLIB=/usr/local/lib/db-4.1/libdb.a
1847 .endd
1848 There is further detailed discussion about the various DBM libraries in the
1849 file &_doc/dbm.discuss.txt_& in the Exim distribution.
1850
1851
1852
1853 .section "Pre-building configuration" "SECID25"
1854 .cindex "building Exim" "pre-building configuration"
1855 .cindex "configuration for building Exim"
1856 .cindex "&_Local/Makefile_&"
1857 .cindex "&_src/EDITME_&"
1858 Before building Exim, a local configuration file that specifies options
1859 independent of any operating system has to be created with the name
1860 &_Local/Makefile_&. A template for this file is supplied as the file
1861 &_src/EDITME_&, and it contains full descriptions of all the option settings
1862 therein. These descriptions are therefore not repeated here. If you are
1863 building Exim for the first time, the simplest thing to do is to copy
1864 &_src/EDITME_& to &_Local/Makefile_&, then read it and edit it appropriately.
1865
1866 There are three settings that you must supply, because Exim will not build
1867 without them. They are the location of the runtime configuration file
1868 (CONFIGURE_FILE), the directory in which Exim binaries will be installed
1869 (BIN_DIRECTORY), and the identity of the Exim user (EXIM_USER and
1870 maybe EXIM_GROUP as well). The value of CONFIGURE_FILE can in fact be
1871 a colon-separated list of filenames; Exim uses the first of them that exists.
1872
1873 There are a few other parameters that can be specified either at build time or
1874 at runtime, to enable the same binary to be used on a number of different
1875 machines. However, if the locations of Exim's spool directory and log file
1876 directory (if not within the spool directory) are fixed, it is recommended that
1877 you specify them in &_Local/Makefile_& instead of at runtime, so that errors
1878 detected early in Exim's execution (such as a malformed configuration file) can
1879 be logged.
1880
1881 .cindex "content scanning" "specifying at build time"
1882 Exim's interfaces for calling virus and spam scanning software directly from
1883 access control lists are not compiled by default. If you want to include these
1884 facilities, you need to set
1885 .code
1886 WITH_CONTENT_SCAN=yes
1887 .endd
1888 in your &_Local/Makefile_&. For details of the facilities themselves, see
1889 chapter &<<CHAPexiscan>>&.
1890
1891
1892 .cindex "&_Local/eximon.conf_&"
1893 .cindex "&_exim_monitor/EDITME_&"
1894 If you are going to build the Exim monitor, a similar configuration process is
1895 required. The file &_exim_monitor/EDITME_& must be edited appropriately for
1896 your installation and saved under the name &_Local/eximon.conf_&. If you are
1897 happy with the default settings described in &_exim_monitor/EDITME_&,
1898 &_Local/eximon.conf_& can be empty, but it must exist.
1899
1900 This is all the configuration that is needed in straightforward cases for known
1901 operating systems. However, the building process is set up so that it is easy
1902 to override options that are set by default or by operating-system-specific
1903 configuration files, for example, to change the C compiler, which
1904 defaults to &%gcc%&. See section &<<SECToverride>>& below for details of how to
1905 do this.
1906
1907
1908
1909 .section "Support for iconv()" "SECID26"
1910 .cindex "&[iconv()]& support"
1911 .cindex "RFC 2047"
1912 The contents of header lines in messages may be encoded according to the rules
1913 described RFC 2047. This makes it possible to transmit characters that are not
1914 in the ASCII character set, and to label them as being in a particular
1915 character set. When Exim is inspecting header lines by means of the &%$h_%&
1916 mechanism, it decodes them, and translates them into a specified character set
1917 (default is set at build time). The translation is possible only if the operating system
1918 supports the &[iconv()]& function.
1919
1920 However, some of the operating systems that supply &[iconv()]& do not support
1921 very many conversions. The GNU &%libiconv%& library (available from
1922 &url(https://www.gnu.org/software/libiconv/)) can be installed on such
1923 systems to remedy this deficiency, as well as on systems that do not supply
1924 &[iconv()]& at all. After installing &%libiconv%&, you should add
1925 .code
1926 HAVE_ICONV=yes
1927 .endd
1928 to your &_Local/Makefile_& and rebuild Exim.
1929
1930
1931
1932 .section "Including TLS/SSL encryption support" "SECTinctlsssl"
1933 .cindex "TLS" "including support for TLS"
1934 .cindex "encryption" "including support for"
1935 .cindex "OpenSSL" "building Exim with"
1936 .cindex "GnuTLS" "building Exim with"
1937 Exim is usually built to support encrypted SMTP connections, using the STARTTLS
1938 command as per RFC 2487. It can also support clients that expect to
1939 start a TLS session immediately on connection to a non-standard port (see the
1940 &%tls_on_connect_ports%& runtime option and the &%-tls-on-connect%& command
1941 line option).
1942
1943 If you want to build Exim with TLS support, you must first install either the
1944 OpenSSL or GnuTLS library. There is no cryptographic code in Exim itself for
1945 implementing SSL.
1946
1947 If you do not want TLS support you should set
1948 .code
1949 DISABLE_TLS=yes
1950 .endd
1951 in &_Local/Makefile_&.
1952
1953 If OpenSSL is installed, you should set
1954 .code
1955 USE_OPENSL=yes
1956 TLS_LIBS=-lssl -lcrypto
1957 .endd
1958 in &_Local/Makefile_&. You may also need to specify the locations of the
1959 OpenSSL library and include files. For example:
1960 .code
1961 USE_OPENSSL=yes
1962 TLS_LIBS=-L/usr/local/openssl/lib -lssl -lcrypto
1963 TLS_INCLUDE=-I/usr/local/openssl/include/
1964 .endd
1965 .cindex "pkg-config" "OpenSSL"
1966 If you have &'pkg-config'& available, then instead you can just use:
1967 .code
1968 USE_OPENSSL=yes
1969 USE_OPENSSL_PC=openssl
1970 .endd
1971 .cindex "USE_GNUTLS"
1972 If GnuTLS is installed, you should set
1973 .code
1974 USE_GNUTLS=yes
1975 TLS_LIBS=-lgnutls -ltasn1 -lgcrypt
1976 .endd
1977 in &_Local/Makefile_&, and again you may need to specify the locations of the
1978 library and include files. For example:
1979 .code
1980 USE_GNUTLS=yes
1981 TLS_LIBS=-L/usr/gnu/lib -lgnutls -ltasn1 -lgcrypt
1982 TLS_INCLUDE=-I/usr/gnu/include
1983 .endd
1984 .cindex "pkg-config" "GnuTLS"
1985 If you have &'pkg-config'& available, then instead you can just use:
1986 .code
1987 USE_GNUTLS=yes
1988 USE_GNUTLS_PC=gnutls
1989 .endd
1990
1991 You do not need to set TLS_INCLUDE if the relevant directory is already
1992 specified in INCLUDE. Details of how to configure Exim to make use of TLS are
1993 given in chapter &<<CHAPTLS>>&.
1994
1995
1996
1997
1998 .section "Use of tcpwrappers" "SECID27"
1999
2000 .cindex "tcpwrappers, building Exim to support"
2001 .cindex "USE_TCP_WRAPPERS"
2002 .cindex "TCP_WRAPPERS_DAEMON_NAME"
2003 .cindex "tcp_wrappers_daemon_name"
2004 Exim can be linked with the &'tcpwrappers'& library in order to check incoming
2005 SMTP calls using the &'tcpwrappers'& control files. This may be a convenient
2006 alternative to Exim's own checking facilities for installations that are
2007 already making use of &'tcpwrappers'& for other purposes. To do this, you
2008 should set USE_TCP_WRAPPERS in &_Local/Makefile_&, arrange for the file
2009 &_tcpd.h_& to be available at compile time, and also ensure that the library
2010 &_libwrap.a_& is available at link time, typically by including &%-lwrap%& in
2011 EXTRALIBS_EXIM. For example, if &'tcpwrappers'& is installed in &_/usr/local_&,
2012 you might have
2013 .code
2014 USE_TCP_WRAPPERS=yes
2015 CFLAGS=-O -I/usr/local/include
2016 EXTRALIBS_EXIM=-L/usr/local/lib -lwrap
2017 .endd
2018 in &_Local/Makefile_&. The daemon name to use in the &'tcpwrappers'& control
2019 files is &"exim"&. For example, the line
2020 .code
2021 exim : LOCAL  192.168.1.  .friendly.domain.example
2022 .endd
2023 in your &_/etc/hosts.allow_& file allows connections from the local host, from
2024 the subnet 192.168.1.0/24, and from all hosts in &'friendly.domain.example'&.
2025 All other connections are denied. The daemon name used by &'tcpwrappers'&
2026 can be changed at build time by setting TCP_WRAPPERS_DAEMON_NAME in
2027 &_Local/Makefile_&, or by setting tcp_wrappers_daemon_name in the
2028 configure file. Consult the &'tcpwrappers'& documentation for
2029 further details.
2030
2031
2032 .section "Including support for IPv6" "SECID28"
2033 .cindex "IPv6" "including support for"
2034 Exim contains code for use on systems that have IPv6 support. Setting
2035 &`HAVE_IPV6=YES`& in &_Local/Makefile_& causes the IPv6 code to be included;
2036 it may also be necessary to set IPV6_INCLUDE and IPV6_LIBS on systems
2037 where the IPv6 support is not fully integrated into the normal include and
2038 library files.
2039
2040 Two different types of DNS record for handling IPv6 addresses have been
2041 defined. AAAA records (analogous to A records for IPv4) are in use, and are
2042 currently seen as the mainstream. Another record type called A6 was proposed
2043 as better than AAAA because it had more flexibility. However, it was felt to be
2044 over-complex, and its status was reduced to &"experimental"&.
2045 Exim used to
2046 have a compile option for including A6 record support but this has now been
2047 withdrawn.
2048
2049
2050
2051 .section "Dynamically loaded lookup module support" "SECTdynamicmodules"
2052 .cindex "lookup modules"
2053 .cindex "dynamic modules"
2054 .cindex ".so building"
2055 On some platforms, Exim supports not compiling all lookup types directly into
2056 the main binary, instead putting some into external modules which can be loaded
2057 on demand.
2058 This permits packagers to build Exim with support for lookups with extensive
2059 library dependencies without requiring all users to install all of those
2060 dependencies.
2061 Most, but not all, lookup types can be built this way.
2062
2063 Set &`LOOKUP_MODULE_DIR`& to the directory into which the modules will be
2064 installed; Exim will only load modules from that directory, as a security
2065 measure.  You will need to set &`CFLAGS_DYNAMIC`& if not already defined
2066 for your OS; see &_OS/Makefile-Linux_& for an example.
2067 Some other requirements for adjusting &`EXTRALIBS`& may also be necessary,
2068 see &_src/EDITME_& for details.
2069
2070 Then, for each module to be loaded dynamically, define the relevant
2071 &`LOOKUP_`&<&'lookup_type'&> flags to have the value "2" instead of "yes".
2072 For example, this will build in lsearch but load sqlite and mysql support
2073 on demand:
2074 .code
2075 LOOKUP_LSEARCH=yes
2076 LOOKUP_SQLITE=2
2077 LOOKUP_MYSQL=2
2078 .endd
2079
2080
2081 .section "The building process" "SECID29"
2082 .cindex "build directory"
2083 Once &_Local/Makefile_& (and &_Local/eximon.conf_&, if required) have been
2084 created, run &'make'& at the top level. It determines the architecture and
2085 operating system types, and creates a build directory if one does not exist.
2086 For example, on a Sun system running Solaris 8, the directory
2087 &_build-SunOS5-5.8-sparc_& is created.
2088 .cindex "symbolic link" "to source files"
2089 Symbolic links to relevant source files are installed in the build directory.
2090
2091 If this is the first time &'make'& has been run, it calls a script that builds
2092 a make file inside the build directory, using the configuration files from the
2093 &_Local_& directory. The new make file is then passed to another instance of
2094 &'make'&. This does the real work, building a number of utility scripts, and
2095 then compiling and linking the binaries for the Exim monitor (if configured), a
2096 number of utility programs, and finally Exim itself. The command &`make
2097 makefile`& can be used to force a rebuild of the make file in the build
2098 directory, should this ever be necessary.
2099
2100 If you have problems building Exim, check for any comments there may be in the
2101 &_README_& file concerning your operating system, and also take a look at the
2102 FAQ, where some common problems are covered.
2103
2104
2105
2106 .section 'Output from &"make"&' "SECID283"
2107 The output produced by the &'make'& process for compile lines is often very
2108 unreadable, because these lines can be very long. For this reason, the normal
2109 output is suppressed by default, and instead output similar to that which
2110 appears when compiling the 2.6 Linux kernel is generated: just a short line for
2111 each module that is being compiled or linked. However, it is still possible to
2112 get the full output, by calling &'make'& like this:
2113 .code
2114 FULLECHO='' make -e
2115 .endd
2116 The value of FULLECHO defaults to &"@"&, the flag character that suppresses
2117 command reflection in &'make'&. When you ask for the full output, it is
2118 given in addition to the short output.
2119
2120
2121
2122 .section "Overriding build-time options for Exim" "SECToverride"
2123 .cindex "build-time options, overriding"
2124 The main make file that is created at the beginning of the building process
2125 consists of the concatenation of a number of files which set configuration
2126 values, followed by a fixed set of &'make'& instructions. If a value is set
2127 more than once, the last setting overrides any previous ones. This provides a
2128 convenient way of overriding defaults. The files that are concatenated are, in
2129 order:
2130 .display
2131 &_OS/Makefile-Default_&
2132 &_OS/Makefile-_&<&'ostype'&>
2133 &_Local/Makefile_&
2134 &_Local/Makefile-_&<&'ostype'&>
2135 &_Local/Makefile-_&<&'archtype'&>
2136 &_Local/Makefile-_&<&'ostype'&>-<&'archtype'&>
2137 &_OS/Makefile-Base_&
2138 .endd
2139 .cindex "&_Local/Makefile_&"
2140 .cindex "building Exim" "operating system type"
2141 .cindex "building Exim" "architecture type"
2142 where <&'ostype'&> is the operating system type and <&'archtype'&> is the
2143 architecture type. &_Local/Makefile_& is required to exist, and the building
2144 process fails if it is absent. The other three &_Local_& files are optional,
2145 and are often not needed.
2146
2147 The values used for <&'ostype'&> and <&'archtype'&> are obtained from scripts
2148 called &_scripts/os-type_& and &_scripts/arch-type_& respectively. If either of
2149 the environment variables EXIM_OSTYPE or EXIM_ARCHTYPE is set, their
2150 values are used, thereby providing a means of forcing particular settings.
2151 Otherwise, the scripts try to get values from the &%uname%& command. If this
2152 fails, the shell variables OSTYPE and ARCHTYPE are inspected. A number
2153 of &'ad hoc'& transformations are then applied, to produce the standard names
2154 that Exim expects. You can run these scripts directly from the shell in order
2155 to find out what values are being used on your system.
2156
2157
2158 &_OS/Makefile-Default_& contains comments about the variables that are set
2159 therein. Some (but not all) are mentioned below. If there is something that
2160 needs changing, review the contents of this file and the contents of the make
2161 file for your operating system (&_OS/Makefile-<ostype>_&) to see what the
2162 default values are.
2163
2164
2165 .cindex "building Exim" "overriding default settings"
2166 If you need to change any of the values that are set in &_OS/Makefile-Default_&
2167 or in &_OS/Makefile-<ostype>_&, or to add any new definitions, you do not
2168 need to change the original files. Instead, you should make the changes by
2169 putting the new values in an appropriate &_Local_& file. For example,
2170 .cindex "Tru64-Unix build-time settings"
2171 when building Exim in many releases of the Tru64-Unix (formerly Digital UNIX,
2172 formerly DEC-OSF1) operating system, it is necessary to specify that the C
2173 compiler is called &'cc'& rather than &'gcc'&. Also, the compiler must be
2174 called with the option &%-std1%&, to make it recognize some of the features of
2175 Standard C that Exim uses. (Most other compilers recognize Standard C by
2176 default.) To do this, you should create a file called &_Local/Makefile-OSF1_&
2177 containing the lines
2178 .code
2179 CC=cc
2180 CFLAGS=-std1
2181 .endd
2182 If you are compiling for just one operating system, it may be easier to put
2183 these lines directly into &_Local/Makefile_&.
2184
2185 Keeping all your local configuration settings separate from the distributed
2186 files makes it easy to transfer them to new versions of Exim simply by copying
2187 the contents of the &_Local_& directory.
2188
2189
2190 .cindex "NIS lookup type" "including support for"
2191 .cindex "NIS+ lookup type" "including support for"
2192 .cindex "LDAP" "including support for"
2193 .cindex "lookup" "inclusion in binary"
2194 Exim contains support for doing LDAP, NIS, NIS+, and other kinds of file
2195 lookup, but not all systems have these components installed, so the default is
2196 not to include the relevant code in the binary. All the different kinds of file
2197 and database lookup that Exim supports are implemented as separate code modules
2198 which are included only if the relevant compile-time options are set. In the
2199 case of LDAP, NIS, and NIS+, the settings for &_Local/Makefile_& are:
2200 .code
2201 LOOKUP_LDAP=yes
2202 LOOKUP_NIS=yes
2203 LOOKUP_NISPLUS=yes
2204 .endd
2205 and similar settings apply to the other lookup types. They are all listed in
2206 &_src/EDITME_&. In many cases the relevant include files and interface
2207 libraries need to be installed before compiling Exim.
2208 .cindex "cdb" "including support for"
2209 However, there are some optional lookup types (such as cdb) for which
2210 the code is entirely contained within Exim, and no external include
2211 files or libraries are required. When a lookup type is not included in the
2212 binary, attempts to configure Exim to use it cause runtime configuration
2213 errors.
2214
2215 .cindex "pkg-config" "lookups"
2216 .cindex "pkg-config" "authenticators"
2217 Many systems now use a tool called &'pkg-config'& to encapsulate information
2218 about how to compile against a library; Exim has some initial support for
2219 being able to use pkg-config for lookups and authenticators.  For any given
2220 makefile variable which starts &`LOOKUP_`& or &`AUTH_`&, you can add a new
2221 variable with the &`_PC`& suffix in the name and assign as the value the
2222 name of the package to be queried.  The results of querying via the
2223 &'pkg-config'& command will be added to the appropriate Makefile variables
2224 with &`+=`& directives, so your version of &'make'& will need to support that
2225 syntax.  For instance:
2226 .code
2227 LOOKUP_SQLITE=yes
2228 LOOKUP_SQLITE_PC=sqlite3
2229 AUTH_GSASL=yes
2230 AUTH_GSASL_PC=libgsasl
2231 AUTH_HEIMDAL_GSSAPI=yes
2232 AUTH_HEIMDAL_GSSAPI_PC=heimdal-gssapi
2233 .endd
2234
2235 .cindex "Perl" "including support for"
2236 Exim can be linked with an embedded Perl interpreter, allowing Perl
2237 subroutines to be called during string expansion. To enable this facility,
2238 .code
2239 EXIM_PERL=perl.o
2240 .endd
2241 must be defined in &_Local/Makefile_&. Details of this facility are given in
2242 chapter &<<CHAPperl>>&.
2243
2244 .cindex "X11 libraries, location of"
2245 The location of the X11 libraries is something that varies a lot between
2246 operating systems, and there may be different versions of X11 to cope
2247 with. Exim itself makes no use of X11, but if you are compiling the Exim
2248 monitor, the X11 libraries must be available.
2249 The following three variables are set in &_OS/Makefile-Default_&:
2250 .code
2251 X11=/usr/X11R6
2252 XINCLUDE=-I$(X11)/include
2253 XLFLAGS=-L$(X11)/lib
2254 .endd
2255 These are overridden in some of the operating-system configuration files. For
2256 example, in &_OS/Makefile-SunOS5_& there is
2257 .code
2258 X11=/usr/openwin
2259 XINCLUDE=-I$(X11)/include
2260 XLFLAGS=-L$(X11)/lib -R$(X11)/lib
2261 .endd
2262 If you need to override the default setting for your operating system, place a
2263 definition of all three of these variables into your
2264 &_Local/Makefile-<ostype>_& file.
2265
2266 .cindex "EXTRALIBS"
2267 If you need to add any extra libraries to the link steps, these can be put in a
2268 variable called EXTRALIBS, which appears in all the link commands, but by
2269 default is not defined. In contrast, EXTRALIBS_EXIM is used only on the
2270 command for linking the main Exim binary, and not for any associated utilities.
2271
2272 .cindex "DBM libraries" "configuration for building"
2273 There is also DBMLIB, which appears in the link commands for binaries that
2274 use DBM functions (see also section &<<SECTdb>>&). Finally, there is
2275 EXTRALIBS_EXIMON, which appears only in the link step for the Exim monitor
2276 binary, and which can be used, for example, to include additional X11
2277 libraries.
2278
2279 .cindex "configuration file" "editing"
2280 The make file copes with rebuilding Exim correctly if any of the configuration
2281 files are edited. However, if an optional configuration file is deleted, it is
2282 necessary to touch the associated non-optional file (that is,
2283 &_Local/Makefile_& or &_Local/eximon.conf_&) before rebuilding.
2284
2285
2286 .section "OS-specific header files" "SECID30"
2287 .cindex "&_os.h_&"
2288 .cindex "building Exim" "OS-specific C header files"
2289 The &_OS_& directory contains a number of files with names of the form
2290 &_os.h-<ostype>_&. These are system-specific C header files that should not
2291 normally need to be changed. There is a list of macro settings that are
2292 recognized in the file &_OS/os.configuring_&, which should be consulted if you
2293 are porting Exim to a new operating system.
2294
2295
2296
2297 .section "Overriding build-time options for the monitor" "SECID31"
2298 .cindex "building Eximon"
2299 A similar process is used for overriding things when building the Exim monitor,
2300 where the files that are involved are
2301 .display
2302 &_OS/eximon.conf-Default_&
2303 &_OS/eximon.conf-_&<&'ostype'&>
2304 &_Local/eximon.conf_&
2305 &_Local/eximon.conf-_&<&'ostype'&>
2306 &_Local/eximon.conf-_&<&'archtype'&>
2307 &_Local/eximon.conf-_&<&'ostype'&>-<&'archtype'&>
2308 .endd
2309 .cindex "&_Local/eximon.conf_&"
2310 As with Exim itself, the final three files need not exist, and in this case the
2311 &_OS/eximon.conf-<ostype>_& file is also optional. The default values in
2312 &_OS/eximon.conf-Default_& can be overridden dynamically by setting environment
2313 variables of the same name, preceded by EXIMON_. For example, setting
2314 EXIMON_LOG_DEPTH in the environment overrides the value of
2315 LOG_DEPTH at runtime.
2316 .ecindex IIDbuex
2317
2318
2319 .section "Installing Exim binaries and scripts" "SECID32"
2320 .cindex "installing Exim"
2321 .cindex "BIN_DIRECTORY"
2322 The command &`make install`& runs the &(exim_install)& script with no
2323 arguments. The script copies binaries and utility scripts into the directory
2324 whose name is specified by the BIN_DIRECTORY setting in &_Local/Makefile_&.
2325 .cindex "setuid" "installing Exim with"
2326 The install script copies files only if they are newer than the files they are
2327 going to replace. The Exim binary is required to be owned by root and have the
2328 &'setuid'& bit set, for normal configurations. Therefore, you must run &`make
2329 install`& as root so that it can set up the Exim binary in this way. However, in
2330 some special situations (for example, if a host is doing no local deliveries)
2331 it may be possible to run Exim without making the binary setuid root (see
2332 chapter &<<CHAPsecurity>>& for details).
2333
2334 .cindex "CONFIGURE_FILE"
2335 Exim's runtime configuration file is named by the CONFIGURE_FILE setting
2336 in &_Local/Makefile_&. If this names a single file, and the file does not
2337 exist, the default configuration file &_src/configure.default_& is copied there
2338 by the installation script. If a runtime configuration file already exists, it
2339 is left alone. If CONFIGURE_FILE is a colon-separated list, naming several
2340 alternative files, no default is installed.
2341
2342 .cindex "system aliases file"
2343 .cindex "&_/etc/aliases_&"
2344 One change is made to the default configuration file when it is installed: the
2345 default configuration contains a router that references a system aliases file.
2346 The path to this file is set to the value specified by
2347 SYSTEM_ALIASES_FILE in &_Local/Makefile_& (&_/etc/aliases_& by default).
2348 If the system aliases file does not exist, the installation script creates it,
2349 and outputs a comment to the user.
2350
2351 The created file contains no aliases, but it does contain comments about the
2352 aliases a site should normally have. Mail aliases have traditionally been
2353 kept in &_/etc/aliases_&. However, some operating systems are now using
2354 &_/etc/mail/aliases_&. You should check if yours is one of these, and change
2355 Exim's configuration if necessary.
2356
2357 The default configuration uses the local host's name as the only local domain,
2358 and is set up to do local deliveries into the shared directory &_/var/mail_&,
2359 running as the local user. System aliases and &_.forward_& files in users' home
2360 directories are supported, but no NIS or NIS+ support is configured. Domains
2361 other than the name of the local host are routed using the DNS, with delivery
2362 over SMTP.
2363
2364 It is possible to install Exim for special purposes (such as building a binary
2365 distribution) in a private part of the file system. You can do this by a
2366 command such as
2367 .code
2368 make DESTDIR=/some/directory/ install
2369 .endd
2370 This has the effect of pre-pending the specified directory to all the file
2371 paths, except the name of the system aliases file that appears in the default
2372 configuration. (If a default alias file is created, its name &'is'& modified.)
2373 For backwards compatibility, ROOT is used if DESTDIR is not set,
2374 but this usage is deprecated.
2375
2376 .cindex "installing Exim" "what is not installed"
2377 Running &'make install'& does not copy the Exim 4 conversion script
2378 &'convert4r4'&. You will probably run this only once if you are
2379 upgrading from Exim 3. None of the documentation files in the &_doc_&
2380 directory are copied, except for the info files when you have set
2381 INFO_DIRECTORY, as described in section &<<SECTinsinfdoc>>& below.
2382
2383 For the utility programs, old versions are renamed by adding the suffix &_.O_&
2384 to their names. The Exim binary itself, however, is handled differently. It is
2385 installed under a name that includes the version number and the compile number,
2386 for example, &_exim-&version()-1_&. The script then arranges for a symbolic link
2387 called &_exim_& to point to the binary. If you are updating a previous version
2388 of Exim, the script takes care to ensure that the name &_exim_& is never absent
2389 from the directory (as seen by other processes).
2390
2391 .cindex "installing Exim" "testing the script"
2392 If you want to see what the &'make install'& will do before running it for
2393 real, you can pass the &%-n%& option to the installation script by this
2394 command:
2395 .code
2396 make INSTALL_ARG=-n install
2397 .endd
2398 The contents of the variable INSTALL_ARG are passed to the installation
2399 script. You do not need to be root to run this test. Alternatively, you can run
2400 the installation script directly, but this must be from within the build
2401 directory. For example, from the top-level Exim directory you could use this
2402 command:
2403 .code
2404 (cd build-SunOS5-5.5.1-sparc; ../scripts/exim_install -n)
2405 .endd
2406 .cindex "installing Exim" "install script options"
2407 There are two other options that can be supplied to the installation script.
2408
2409 .ilist
2410 &%-no_chown%& bypasses the call to change the owner of the installed binary
2411 to root, and the call to make it a setuid binary.
2412 .next
2413 &%-no_symlink%& bypasses the setting up of the symbolic link &_exim_& to the
2414 installed binary.
2415 .endlist
2416
2417 INSTALL_ARG can be used to pass these options to the script. For example:
2418 .code
2419 make INSTALL_ARG=-no_symlink install
2420 .endd
2421 The installation script can also be given arguments specifying which files are
2422 to be copied. For example, to install just the Exim binary, and nothing else,
2423 without creating the symbolic link, you could use:
2424 .code
2425 make INSTALL_ARG='-no_symlink exim' install
2426 .endd
2427
2428
2429
2430 .section "Installing info documentation" "SECTinsinfdoc"
2431 .cindex "installing Exim" "&'info'& documentation"
2432 Not all systems use the GNU &'info'& system for documentation, and for this
2433 reason, the Texinfo source of Exim's documentation is not included in the main
2434 distribution. Instead it is available separately from the FTP site (see section
2435 &<<SECTavail>>&).
2436
2437 If you have defined INFO_DIRECTORY in &_Local/Makefile_& and the Texinfo
2438 source of the documentation is found in the source tree, running &`make
2439 install`& automatically builds the info files and installs them.
2440
2441
2442
2443 .section "Setting up the spool directory" "SECID33"
2444 .cindex "spool directory" "creating"
2445 When it starts up, Exim tries to create its spool directory if it does not
2446 exist. The Exim uid and gid are used for the owner and group of the spool
2447 directory. Sub-directories are automatically created in the spool directory as
2448 necessary.
2449
2450
2451
2452
2453 .section "Testing" "SECID34"
2454 .cindex "testing" "installation"
2455 Having installed Exim, you can check that the runtime configuration file is
2456 syntactically valid by running the following command, which assumes that the
2457 Exim binary directory is within your PATH environment variable:
2458 .code
2459 exim -bV
2460 .endd
2461 If there are any errors in the configuration file, Exim outputs error messages.
2462 Otherwise it outputs the version number and build date,
2463 the DBM library that is being used, and information about which drivers and
2464 other optional code modules are included in the binary.
2465 Some simple routing tests can be done by using the address testing option. For
2466 example,
2467 .display
2468 &`exim -bt`& <&'local username'&>
2469 .endd
2470 should verify that it recognizes a local mailbox, and
2471 .display
2472 &`exim -bt`& <&'remote address'&>
2473 .endd
2474 a remote one. Then try getting it to deliver mail, both locally and remotely.
2475 This can be done by passing messages directly to Exim, without going through a
2476 user agent. For example:
2477 .code
2478 exim -v postmaster@your.domain.example
2479 From: user@your.domain.example
2480 To: postmaster@your.domain.example
2481 Subject: Testing Exim
2482
2483 This is a test message.
2484 ^D
2485 .endd
2486 The &%-v%& option causes Exim to output some verification of what it is doing.
2487 In this case you should see copies of three log lines, one for the message's
2488 arrival, one for its delivery, and one containing &"Completed"&.
2489
2490 .cindex "delivery" "problems with"
2491 If you encounter problems, look at Exim's log files (&'mainlog'& and
2492 &'paniclog'&) to see if there is any relevant information there. Another source
2493 of information is running Exim with debugging turned on, by specifying the
2494 &%-d%& option. If a message is stuck on Exim's spool, you can force a delivery
2495 with debugging turned on by a command of the form
2496 .display
2497 &`exim -d -M`& <&'exim-message-id'&>
2498 .endd
2499 You must be root or an &"admin user"& in order to do this. The &%-d%& option
2500 produces rather a lot of output, but you can cut this down to specific areas.
2501 For example, if you use &%-d-all+route%& only the debugging information
2502 relevant to routing is included. (See the &%-d%& option in chapter
2503 &<<CHAPcommandline>>& for more details.)
2504
2505 .cindex '&"sticky"& bit'
2506 .cindex "lock files"
2507 One specific problem that has shown up on some sites is the inability to do
2508 local deliveries into a shared mailbox directory, because it does not have the
2509 &"sticky bit"& set on it. By default, Exim tries to create a lock file before
2510 writing to a mailbox file, and if it cannot create the lock file, the delivery
2511 is deferred. You can get round this either by setting the &"sticky bit"& on the
2512 directory, or by setting a specific group for local deliveries and allowing
2513 that group to create files in the directory (see the comments above the
2514 &(local_delivery)& transport in the default configuration file). Another
2515 approach is to configure Exim not to use lock files, but just to rely on
2516 &[fcntl()]& locking instead. However, you should do this only if all user
2517 agents also use &[fcntl()]& locking. For further discussion of locking issues,
2518 see chapter &<<CHAPappendfile>>&.
2519
2520 One thing that cannot be tested on a system that is already running an MTA is
2521 the receipt of incoming SMTP mail on the standard SMTP port. However, the
2522 &%-oX%& option can be used to run an Exim daemon that listens on some other
2523 port, or &'inetd'& can be used to do this. The &%-bh%& option and the
2524 &'exim_checkaccess'& utility can be used to check out policy controls on
2525 incoming SMTP mail.
2526
2527 Testing a new version on a system that is already running Exim can most easily
2528 be done by building a binary with a different CONFIGURE_FILE setting. From
2529 within the runtime configuration, all other file and directory names
2530 that Exim uses can be altered, in order to keep it entirely clear of the
2531 production version.
2532
2533
2534 .section "Replacing another MTA with Exim" "SECID35"
2535 .cindex "replacing another MTA"
2536 Building and installing Exim for the first time does not of itself put it in
2537 general use. The name by which the system's MTA is called by mail user agents
2538 is either &_/usr/sbin/sendmail_&, or &_/usr/lib/sendmail_& (depending on the
2539 operating system), and it is necessary to make this name point to the &'exim'&
2540 binary in order to get the user agents to pass messages to Exim. This is
2541 normally done by renaming any existing file and making &_/usr/sbin/sendmail_&
2542 or &_/usr/lib/sendmail_&
2543 .cindex "symbolic link" "to &'exim'& binary"
2544 a symbolic link to the &'exim'& binary. It is a good idea to remove any setuid
2545 privilege and executable status from the old MTA. It is then necessary to stop
2546 and restart the mailer daemon, if one is running.
2547
2548 .cindex "FreeBSD, MTA indirection"
2549 .cindex "&_/etc/mail/mailer.conf_&"
2550 Some operating systems have introduced alternative ways of switching MTAs. For
2551 example, if you are running FreeBSD, you need to edit the file
2552 &_/etc/mail/mailer.conf_& instead of setting up a symbolic link as just
2553 described. A typical example of the contents of this file for running Exim is
2554 as follows:
2555 .code
2556 sendmail            /usr/exim/bin/exim
2557 send-mail           /usr/exim/bin/exim
2558 mailq               /usr/exim/bin/exim -bp
2559 newaliases          /usr/bin/true
2560 .endd
2561 Once you have set up the symbolic link, or edited &_/etc/mail/mailer.conf_&,
2562 your Exim installation is &"live"&. Check it by sending a message from your
2563 favourite user agent.
2564
2565 You should consider what to tell your users about the change of MTA. Exim may
2566 have different capabilities to what was previously running, and there are
2567 various operational differences such as the text of messages produced by
2568 command line options and in bounce messages. If you allow your users to make
2569 use of Exim's filtering capabilities, you should make the document entitled
2570 &'Exim's interface to mail filtering'& available to them.
2571
2572
2573
2574 .section "Running the daemon" SECTdaemonLaunch
2575 The most common command line for launching the Exim daemon looks like
2576 .code
2577 exim -bd -q5m
2578 .endd
2579 This starts a daemon which
2580 .ilist
2581 listens for incoming smtp connections, launching handler processes for
2582 each new one
2583 .next
2584 starts a queue-runner process every five minutes, to inspect queued messages
2585 and run delivery attempts on any that have arrived at their retry time
2586 .endlist
2587 Should a queue run take longer than the time between queue-runner starts,
2588 they will run in parallel.
2589 Numbers of jobs of the various types are subject to policy controls
2590 defined in the configuration.
2591
2592
2593 .section "Upgrading Exim" "SECID36"
2594 .cindex "upgrading Exim"
2595 If you are already running Exim on your host, building and installing a new
2596 version automatically makes it available to MUAs, or any other programs that
2597 call the MTA directly. However, if you are running an Exim daemon, you do need
2598 .cindex restart "on HUP signal"
2599 .cindex signal "HUP, to restart"
2600 to send it a HUP signal, to make it re-execute itself, and thereby pick up the
2601 new binary. You do not need to stop processing mail in order to install a new
2602 version of Exim. The install script does not modify an existing runtime
2603 configuration file.
2604
2605
2606
2607
2608 .section "Stopping the Exim daemon on Solaris" "SECID37"
2609 .cindex "Solaris" "stopping Exim on"
2610 The standard command for stopping the mailer daemon on Solaris is
2611 .code
2612 /etc/init.d/sendmail stop
2613 .endd
2614 If &_/usr/lib/sendmail_& has been turned into a symbolic link, this script
2615 fails to stop Exim because it uses the command &'ps -e'& and greps the output
2616 for the text &"sendmail"&; this is not present because the actual program name
2617 (that is, &"exim"&) is given by the &'ps'& command with these options. A
2618 solution is to replace the line that finds the process id with something like
2619 .code
2620 pid=`cat /var/spool/exim/exim-daemon.pid`
2621 .endd
2622 to obtain the daemon's pid directly from the file that Exim saves it in.
2623
2624 Note, however, that stopping the daemon does not &"stop Exim"&. Messages can
2625 still be received from local processes, and if automatic delivery is configured
2626 (the normal case), deliveries will still occur.
2627
2628
2629
2630
2631 . ////////////////////////////////////////////////////////////////////////////
2632 . ////////////////////////////////////////////////////////////////////////////
2633
2634 .chapter "The Exim command line" "CHAPcommandline"
2635 .scindex IIDclo1 "command line" "options"
2636 .scindex IIDclo2 "options" "command line"
2637 Exim's command line takes the standard Unix form of a sequence of options,
2638 each starting with a hyphen character, followed by a number of arguments. The
2639 options are compatible with the main options of Sendmail, and there are also
2640 some additional options, some of which are compatible with Smail 3. Certain
2641 combinations of options do not make sense, and provoke an error if used.
2642 The form of the arguments depends on which options are set.
2643
2644
2645 .section "Setting options by program name" "SECID38"
2646 .cindex "&'mailq'&"
2647 If Exim is called under the name &'mailq'&, it behaves as if the option &%-bp%&
2648 were present before any other options.
2649 The &%-bp%& option requests a listing of the contents of the mail queue on the
2650 standard output.
2651 This feature is for compatibility with some systems that contain a command of
2652 that name in one of the standard libraries, symbolically linked to
2653 &_/usr/sbin/sendmail_& or &_/usr/lib/sendmail_&.
2654
2655 .cindex "&'rsmtp'&"
2656 If Exim is called under the name &'rsmtp'& it behaves as if the option &%-bS%&
2657 were present before any other options, for compatibility with Smail. The
2658 &%-bS%& option is used for reading in a number of messages in batched SMTP
2659 format.
2660
2661 .cindex "&'rmail'&"
2662 If Exim is called under the name &'rmail'& it behaves as if the &%-i%& and
2663 &%-oee%& options were present before any other options, for compatibility with
2664 Smail. The name &'rmail'& is used as an interface by some UUCP systems.
2665
2666 .cindex "&'runq'&"
2667 .cindex "queue runner"
2668 If Exim is called under the name &'runq'& it behaves as if the option &%-q%&
2669 were present before any other options, for compatibility with Smail. The &%-q%&
2670 option causes a single queue runner process to be started.
2671
2672 .cindex "&'newaliases'&"
2673 .cindex "alias file" "building"
2674 .cindex "Sendmail compatibility" "calling Exim as &'newaliases'&"
2675 If Exim is called under the name &'newaliases'& it behaves as if the option
2676 &%-bi%& were present before any other options, for compatibility with Sendmail.
2677 This option is used for rebuilding Sendmail's alias file. Exim does not have
2678 the concept of a single alias file, but can be configured to run a given
2679 command if called with the &%-bi%& option.
2680
2681
2682 .section "Trusted and admin users" "SECTtrustedadmin"
2683 Some Exim options are available only to &'trusted users'& and others are
2684 available only to &'admin users'&. In the description below, the phrases &"Exim
2685 user"& and &"Exim group"& mean the user and group defined by EXIM_USER and
2686 EXIM_GROUP in &_Local/Makefile_& or set by the &%exim_user%& and
2687 &%exim_group%& options. These do not necessarily have to use the name &"exim"&.
2688
2689 .ilist
2690 .cindex "trusted users" "definition of"
2691 .cindex "user" "trusted definition of"
2692 The trusted users are root, the Exim user, any user listed in the
2693 &%trusted_users%& configuration option, and any user whose current group or any
2694 supplementary group is one of those listed in the &%trusted_groups%&
2695 configuration option. Note that the Exim group is not automatically trusted.
2696
2697 .cindex '&"From"& line'
2698 .cindex "envelope from"
2699 .cindex "envelope sender"
2700 Trusted users are always permitted to use the &%-f%& option or a leading
2701 &"From&~"& line to specify the envelope sender of a message that is passed to
2702 Exim through the local interface (see the &%-bm%& and &%-f%& options below).
2703 See the &%untrusted_set_sender%& option for a way of permitting non-trusted
2704 users to set envelope senders.
2705
2706 .chindex From:
2707 .chindex Sender:
2708 For a trusted user, there is never any check on the contents of the &'From:'&
2709 header line, and a &'Sender:'& line is never added. Furthermore, any existing
2710 &'Sender:'& line in incoming local (non-TCP/IP) messages is not removed.
2711
2712 Trusted users may also specify a host name, host address, interface address,
2713 protocol name, ident value, and authentication data when submitting a message
2714 locally. Thus, they are able to insert messages into Exim's queue locally that
2715 have the characteristics of messages received from a remote host. Untrusted
2716 users may in some circumstances use &%-f%&, but can never set the other values
2717 that are available to trusted users.
2718 .next
2719 .cindex "user" "admin definition of"
2720 .cindex "admin user" "definition of"
2721 The admin users are root, the Exim user, and any user that is a member of the
2722 Exim group or of any group listed in the &%admin_groups%& configuration option.
2723 The current group does not have to be one of these groups.
2724
2725 Admin users are permitted to list the queue, and to carry out certain
2726 operations on messages, for example, to force delivery failures. It is also
2727 necessary to be an admin user in order to see the full information provided by
2728 the Exim monitor, and full debugging output.
2729
2730 By default, the use of the &%-M%&, &%-q%&, &%-R%&, and &%-S%& options to cause
2731 Exim to attempt delivery of messages on its queue is restricted to admin users.
2732 However, this restriction can be relaxed by setting the &%prod_requires_admin%&
2733 option false (that is, specifying &%no_prod_requires_admin%&).
2734
2735 Similarly, the use of the &%-bp%& option to list all the messages in the queue
2736 is restricted to admin users unless &%queue_list_requires_admin%& is set
2737 false.
2738 .endlist
2739
2740
2741 &*Warning*&: If you configure your system so that admin users are able to
2742 edit Exim's configuration file, you are giving those users an easy way of
2743 getting root. There is further discussion of this issue at the start of chapter
2744 &<<CHAPconf>>&.
2745
2746
2747
2748
2749 .section "Command line options" "SECID39"
2750 Exim's command line options are described in alphabetical order below. If none
2751 of the options that specifies a specific action (such as starting the daemon or
2752 a queue runner, or testing an address, or receiving a message in a specific
2753 format, or listing the queue) are present, and there is at least one argument
2754 on the command line, &%-bm%& (accept a local message on the standard input,
2755 with the arguments specifying the recipients) is assumed. Otherwise, Exim
2756 outputs a brief message about itself and exits.
2757
2758 . ////////////////////////////////////////////////////////////////////////////
2759 . Insert a stylized XML comment here, to identify the start of the command line
2760 . options. This is for the benefit of the Perl script that automatically
2761 . creates a man page for the options.
2762 . ////////////////////////////////////////////////////////////////////////////
2763
2764 .literal xml
2765 <!-- === Start of command line options === -->
2766 .literal off
2767
2768
2769 .vlist
2770 .cmdopt "--" "--"
2771 .cindex "options" "command line; terminating"
2772 This is a pseudo-option whose only purpose is to terminate the options and
2773 therefore to cause subsequent command line items to be treated as arguments
2774 rather than options, even if they begin with hyphens.
2775
2776 .cmdopt --help
2777 This option causes Exim to output a few sentences stating what it is.
2778 The same output is generated if the Exim binary is called with no options and
2779 no arguments.
2780
2781 .cmdopt --version
2782 This option is an alias for &%-bV%& and causes version information to be
2783 displayed.
2784
2785 .vitem &%-Ac%& &&&
2786        &%-Am%&
2787 .oindex "&%-Ac%&"
2788 .oindex "&%-Am%&"
2789 These options are used by Sendmail for selecting configuration files and are
2790 ignored by Exim.
2791
2792 .cmdopt -B <&'type'&>
2793 .oindex "&%-B%&"
2794 .cindex "8-bit characters"
2795 .cindex "Sendmail compatibility" "8-bit characters"
2796 This is a Sendmail option for selecting 7 or 8 bit processing. Exim is 8-bit
2797 clean; it ignores this option.
2798
2799 .cmdopt -bd
2800 .cindex "daemon"
2801 .cindex "SMTP" "listener"
2802 .cindex "queue runner"
2803 This option runs Exim as a daemon, awaiting incoming SMTP connections. Usually
2804 the &%-bd%& option is combined with the &%-q%&<&'time'&> option, to specify
2805 that the daemon should also initiate periodic queue runs.
2806
2807 The &%-bd%& option can be used only by an admin user. If either of the &%-d%&
2808 (debugging) or &%-v%& (verifying) options are set, the daemon does not
2809 disconnect from the controlling terminal. When running this way, it can be
2810 stopped by pressing ctrl-C.
2811
2812 By default, Exim listens for incoming connections to the standard SMTP port on
2813 all the host's running interfaces. However, it is possible to listen on other
2814 ports, on multiple ports, and only on specific interfaces. Chapter
2815 &<<CHAPinterfaces>>& contains a description of the options that control this.
2816
2817 When a listening daemon
2818 .cindex "daemon" "process id (pid)"
2819 .cindex "pid (process id)" "of daemon"
2820 is started without the use of &%-oX%& (that is, without overriding the normal
2821 configuration), it writes its process id to a file called &_exim-daemon.pid_&
2822 in Exim's spool directory. This location can be overridden by setting
2823 PID_FILE_PATH in &_Local/Makefile_&. The file is written while Exim is still
2824 running as root.
2825
2826 When &%-oX%& is used on the command line to start a listening daemon, the
2827 process id is not written to the normal pid file path. However, &%-oP%& can be
2828 used to specify a path on the command line if a pid file is required.
2829
2830 The SIGHUP signal
2831 .cindex "SIGHUP"
2832 .cindex restart "on HUP signal"
2833 .cindex signal "HUP, to restart"
2834 .cindex "daemon" "restarting"
2835 .cindex signal "to reload configuration"
2836 .cindex daemon "reload configuration"
2837 .cindex reload configuration
2838 can be used to cause the daemon to re-execute itself. This should be done
2839 whenever Exim's configuration file, or any file that is incorporated into it by
2840 means of the &%.include%& facility, is changed, and also whenever a new version
2841 of Exim is installed. It is not necessary to do this when other files that are
2842 referenced from the configuration (for example, alias files) are changed,
2843 because these are reread each time they are used.
2844
2845 Either a SIGTERM or a SIGINT signal should be used to cause the daemon
2846 to cleanly shut down.
2847 Subprocesses handling recceiving or delivering messages,
2848 or for scanning the queue,
2849 will not be affected by the termination of the daemon process.
2850
2851 .cmdopt -bdf
2852 This option has the same effect as &%-bd%& except that it never disconnects
2853 from the controlling terminal, even when no debugging is specified.
2854
2855 .cmdopt -be
2856 .cindex "testing" "string expansion"
2857 .cindex "expansion" "testing"
2858 Run Exim in expansion testing mode. Exim discards its root privilege, to
2859 prevent ordinary users from using this mode to read otherwise inaccessible
2860 files. If no arguments are given, Exim runs interactively, prompting for lines
2861 of data. Otherwise, it processes each argument in turn.
2862
2863 If Exim was built with USE_READLINE=yes in &_Local/Makefile_&, it tries
2864 to load the &%libreadline%& library dynamically whenever the &%-be%& option is
2865 used without command line arguments. If successful, it uses the &[readline()]&
2866 function, which provides extensive line-editing facilities, for reading the
2867 test data. A line history is supported.
2868
2869 Long expansion expressions can be split over several lines by using backslash
2870 continuations. As in Exim's runtime configuration, white space at the start of
2871 continuation lines is ignored. Each argument or data line is passed through the
2872 string expansion mechanism, and the result is output. Variable values from the
2873 configuration file (for example, &$qualify_domain$&) are available, but no
2874 message-specific values (such as &$message_exim_id$&) are set, because no message
2875 is being processed (but see &%-bem%& and &%-Mset%&).
2876
2877 &*Note*&: If you use this mechanism to test lookups, and you change the data
2878 files or databases you are using, you must exit and restart Exim before trying
2879 the same lookup again. Otherwise, because each Exim process caches the results
2880 of lookups, you will just get the same result as before.
2881
2882 Macro processing is done on lines before string-expansion: new macros can be
2883 defined and macros will be expanded.
2884 Because macros in the config file are often used for secrets, those are only
2885 available to admin users.
2886
2887 The word &"set"& at the start of a line, followed by a single space,
2888 is recognised specially as defining a value for a variable.
2889 The syntax is otherwise the same as the ACL modifier &"set ="&.
2890
2891 .cmdopt -bem <&'filename'&>
2892 .cindex "testing" "string expansion"
2893 .cindex "expansion" "testing"
2894 This option operates like &%-be%& except that it must be followed by the name
2895 of a file. For example:
2896 .code
2897 exim -bem /tmp/testmessage
2898 .endd
2899 The file is read as a message (as if receiving a locally-submitted non-SMTP
2900 message) before any of the test expansions are done. Thus, message-specific
2901 variables such as &$message_size$& and &$header_from:$& are available. However,
2902 no &'Received:'& header is added to the message. If the &%-t%& option is set,
2903 recipients are read from the headers in the normal way, and are shown in the
2904 &$recipients$& variable. Note that recipients cannot be given on the command
2905 line, because further arguments are taken as strings to expand (just like
2906 &%-be%&).
2907
2908 .cmdopt -bF <&'filename'&>
2909 .cindex "system filter" "testing"
2910 .cindex "testing" "system filter"
2911 This option is the same as &%-bf%& except that it assumes that the filter being
2912 tested is a system filter. The additional commands that are available only in
2913 system filters are recognized.
2914
2915 .cmdopt -bf <&'filename'&>
2916 .cindex "filter" "testing"
2917 .cindex "testing" "filter file"
2918 .cindex "forward file" "testing"
2919 .cindex "testing" "forward file"
2920 .cindex "Sieve filter" "testing"
2921 This option runs Exim in user filter testing mode; the file is the filter file
2922 to be tested, and a test message must be supplied on the standard input. If
2923 there are no message-dependent tests in the filter, an empty file can be
2924 supplied.
2925
2926 If you want to test a system filter file, use &%-bF%& instead of &%-bf%&. You
2927 can use both &%-bF%& and &%-bf%& on the same command, in order to test a system
2928 filter and a user filter in the same run. For example:
2929 .code
2930 exim -bF /system/filter -bf /user/filter </test/message
2931 .endd
2932 This is helpful when the system filter adds header lines or sets filter
2933 variables that are used by the user filter.
2934
2935 If the test filter file does not begin with one of the special lines
2936 .code
2937 # Exim filter
2938 # Sieve filter
2939 .endd
2940 it is taken to be a normal &_.forward_& file, and is tested for validity under
2941 that interpretation. See sections &<<SECTitenonfilred>>& to
2942 &<<SECTspecitredli>>& for a description of the possible contents of non-filter
2943 redirection lists.
2944
2945 The result of an Exim command that uses &%-bf%&, provided no errors are
2946 detected, is a list of the actions that Exim would try to take if presented
2947 with the message for real. More details of filter testing are given in the
2948 separate document entitled &'Exim's interfaces to mail filtering'&.
2949
2950 When testing a filter file,
2951 .cindex "&""From""& line"
2952 .cindex "envelope from"
2953 .cindex "envelope sender"
2954 .oindex "&%-f%&" "for filter testing"
2955 the envelope sender can be set by the &%-f%& option,
2956 or by a &"From&~"& line at the start of the test message. Various parameters
2957 that would normally be taken from the envelope recipient address of the message
2958 can be set by means of additional command line options (see the next four
2959 options).
2960
2961 .cmdopt -bfd <&'domain'&>
2962 .vindex "&$qualify_domain$&"
2963 This sets the domain of the recipient address when a filter file is being
2964 tested by means of the &%-bf%& option. The default is the value of
2965 &$qualify_domain$&.
2966
2967 .cmdopt -bfl <&'local&~part'&>
2968 This sets the local part of the recipient address when a filter file is being
2969 tested by means of the &%-bf%& option. The default is the username of the
2970 process that calls Exim. A local part should be specified with any prefix or
2971 suffix stripped, because that is how it appears to the filter when a message is
2972 actually being delivered.
2973
2974 .cmdopt -bfp <&'prefix'&>
2975 .cindex affix "filter testing"
2976 This sets the prefix of the local part of the recipient address when a filter
2977 file is being tested by means of the &%-bf%& option. The default is an empty
2978 prefix.
2979
2980 .cmdopt -bfs <&'suffix'&>
2981 .cindex affix "filter testing"
2982 This sets the suffix of the local part of the recipient address when a filter
2983 file is being tested by means of the &%-bf%& option. The default is an empty
2984 suffix.
2985
2986 .cmdopt -bh <&'IP&~address'&>
2987 .cindex "testing" "incoming SMTP"
2988 .cindex "SMTP" "testing incoming"
2989 .cindex "testing" "relay control"
2990 .cindex "relaying" "testing configuration"
2991 .cindex "policy control" "testing"
2992 .cindex "debugging" "&%-bh%& option"
2993 This option runs a fake SMTP session as if from the given IP address, using the
2994 standard input and output. The IP address may include a port number at the end,
2995 after a full stop. For example:
2996 .code
2997 exim -bh 10.9.8.7.1234
2998 exim -bh fe80::a00:20ff:fe86:a061.5678
2999 .endd
3000 When an IPv6 address is given, it is converted into canonical form. In the case
3001 of the second example above, the value of &$sender_host_address$& after
3002 conversion to the canonical form is
3003 &`fe80:0000:0000:0a00:20ff:fe86:a061.5678`&.
3004
3005 Comments as to what is going on are written to the standard error file. These
3006 include lines beginning with &"LOG"& for anything that would have been logged.
3007 This facility is provided for testing configuration options for incoming
3008 messages, to make sure they implement the required policy. For example, you can
3009 test your relay controls using &%-bh%&.
3010
3011 &*Warning 1*&:
3012 .cindex "RFC 1413"
3013 You can test features of the configuration that rely on ident (RFC 1413)
3014 information by using the &%-oMt%& option. However, Exim cannot actually perform
3015 an ident callout when testing using &%-bh%& because there is no incoming SMTP
3016 connection.
3017
3018 &*Warning 2*&: Address verification callouts (see section &<<SECTcallver>>&)
3019 are also skipped when testing using &%-bh%&. If you want these callouts to
3020 occur, use &%-bhc%& instead.
3021
3022 Messages supplied during the testing session are discarded, and nothing is
3023 written to any of the real log files. There may be pauses when DNS (and other)
3024 lookups are taking place, and of course these may time out. The &%-oMi%& option
3025 can be used to specify a specific IP interface and port if this is important,
3026 and &%-oMaa%& and &%-oMai%& can be used to set parameters as if the SMTP
3027 session were authenticated.
3028
3029 The &'exim_checkaccess'& utility is a &"packaged"& version of &%-bh%& whose
3030 output just states whether a given recipient address from a given host is
3031 acceptable or not. See section &<<SECTcheckaccess>>&.
3032
3033 Features such as authentication and encryption, where the client input is not
3034 plain text, cannot easily be tested with &%-bh%&. Instead, you should use a
3035 specialized SMTP test program such as
3036 &url(https://www.jetmore.org/john/code/swaks/,swaks).
3037
3038 .cmdopt -bhc <&'IP&~address'&>
3039 This option operates in the same way as &%-bh%&, except that address
3040 verification callouts are performed if required. This includes consulting and
3041 updating the callout cache database.
3042
3043 .cmdopt -bi
3044 .cindex "alias file" "building"
3045 .cindex "building alias file"
3046 .cindex "Sendmail compatibility" "&%-bi%& option"
3047 Sendmail interprets the &%-bi%& option as a request to rebuild its alias file.
3048 Exim does not have the concept of a single alias file, and so it cannot mimic
3049 this behaviour. However, calls to &_/usr/lib/sendmail_& with the &%-bi%& option
3050 tend to appear in various scripts such as NIS make files, so the option must be
3051 recognized.
3052
3053 If &%-bi%& is encountered, the command specified by the &%bi_command%&
3054 configuration option is run, under the uid and gid of the caller of Exim. If
3055 the &%-oA%& option is used, its value is passed to the command as an argument.
3056 The command set by &%bi_command%& may not contain arguments. The command can
3057 use the &'exim_dbmbuild'& utility, or some other means, to rebuild alias files
3058 if this is required. If the &%bi_command%& option is not set, calling Exim with
3059 &%-bi%& is a no-op.
3060
3061 . // Keep :help first, then the rest in alphabetical order
3062 .cmdopt -bI:help
3063 .cindex "querying exim information"
3064 We shall provide various options starting &`-bI:`& for querying Exim for
3065 information.  The output of many of these will be intended for machine
3066 consumption.  This one is not.  The &%-bI:help%& option asks Exim for a
3067 synopsis of supported options beginning &`-bI:`&.  Use of any of these
3068 options shall cause Exim to exit after producing the requested output.
3069
3070 .cmdopt -bI:dscp
3071 .cindex "DSCP" "values"
3072 This option causes Exim to emit an alphabetically sorted list of all
3073 recognised DSCP names.
3074
3075 .cmdopt -bI:sieve
3076 .cindex "Sieve filter" "capabilities"
3077 This option causes Exim to emit an alphabetically sorted list of all supported
3078 Sieve protocol extensions on stdout, one per line.  This is anticipated to be
3079 useful for ManageSieve (RFC 5804) implementations, in providing that protocol's
3080 &`SIEVE`& capability response line.  As the precise list may depend upon
3081 compile-time build options, which this option will adapt to, this is the only
3082 way to guarantee a correct response.
3083
3084 .cmdopt -bm
3085 .cindex "local message reception"
3086 This option runs an Exim receiving process that accepts an incoming,
3087 locally-generated message on the standard input. The recipients are given as the
3088 command arguments (except when &%-t%& is also present &-- see below). Each
3089 argument can be a comma-separated list of RFC 2822 addresses. This is the
3090 default option for selecting the overall action of an Exim call; it is assumed
3091 if no other conflicting option is present.
3092
3093 If any addresses in the message are unqualified (have no domain), they are
3094 qualified by the values of the &%qualify_domain%& or &%qualify_recipient%&
3095 options, as appropriate. The &%-bnq%& option (see below) provides a way of
3096 suppressing this for special cases.
3097
3098 Policy checks on the contents of local messages can be enforced by means of
3099 the non-SMTP ACL. See chapter &<<CHAPACL>>& for details.
3100
3101 .cindex "return code" "for &%-bm%&"
3102 The return code is zero if the message is successfully accepted. Otherwise, the
3103 action is controlled by the &%-oe%&&'x'& option setting &-- see below.
3104
3105 The format
3106 .cindex "message" "format"
3107 .cindex "format" "message"
3108 .cindex "&""From""& line"
3109 .cindex "UUCP" "&""From""& line"
3110 .cindex "Sendmail compatibility" "&""From""& line"
3111 of the message must be as defined in RFC 2822, except that, for
3112 compatibility with Sendmail and Smail, a line in one of the forms
3113 .code
3114 From sender Fri Jan  5 12:55 GMT 1997
3115 From sender Fri, 5 Jan 97 12:55:01
3116 .endd
3117 (with the weekday optional, and possibly with additional text after the date)
3118 is permitted to appear at the start of the message. There appears to be no
3119 authoritative specification of the format of this line. Exim recognizes it by
3120 matching against the regular expression defined by the &%uucp_from_pattern%&
3121 option, which can be changed if necessary.
3122
3123 .oindex "&%-f%&" "overriding &""From""& line"
3124 The specified sender is treated as if it were given as the argument to the
3125 &%-f%& option, but if a &%-f%& option is also present, its argument is used in
3126 preference to the address taken from the message. The caller of Exim must be a
3127 trusted user for the sender of a message to be set in this way.
3128
3129 .cmdopt -bmalware <&'filename'&>
3130 .cindex "testing", "malware"
3131 .cindex "malware scan test"
3132 This debugging option causes Exim to scan the given file or directory
3133 (depending on the used scanner interface),
3134 using the malware scanning framework.  The option of &%av_scanner%& influences
3135 this option, so if &%av_scanner%&'s value is dependent upon an expansion then
3136 the expansion should have defaults which apply to this invocation.  ACLs are
3137 not invoked, so if &%av_scanner%& references an ACL variable then that variable
3138 will never be populated and &%-bmalware%& will fail.
3139
3140 Exim will have changed working directory before resolving the filename, so
3141 using fully qualified pathnames is advisable.  Exim will be running as the Exim
3142 user when it tries to open the file, rather than as the invoking user.
3143 This option requires admin privileges.
3144
3145 The &%-bmalware%& option will not be extended to be more generally useful,
3146 there are better tools for file-scanning.  This option exists to help
3147 administrators verify their Exim and AV scanner configuration.
3148
3149 .cmdopt -bnq
3150 .cindex "address qualification, suppressing"
3151 By default, Exim automatically qualifies unqualified addresses (those
3152 without domains) that appear in messages that are submitted locally (that
3153 is, not over TCP/IP). This qualification applies both to addresses in
3154 envelopes, and addresses in header lines. Sender addresses are qualified using
3155 &%qualify_domain%&, and recipient addresses using &%qualify_recipient%& (which
3156 defaults to the value of &%qualify_domain%&).
3157
3158 Sometimes, qualification is not wanted. For example, if &%-bS%& (batch SMTP) is
3159 being used to re-submit messages that originally came from remote hosts after
3160 content scanning, you probably do not want to qualify unqualified addresses in
3161 header lines. (Such lines will be present only if you have not enabled a header
3162 syntax check in the appropriate ACL.)
3163
3164 The &%-bnq%& option suppresses all qualification of unqualified addresses in
3165 messages that originate on the local host. When this is used, unqualified
3166 addresses in the envelope provoke errors (causing message rejection) and
3167 unqualified addresses in header lines are left alone.
3168
3169
3170 .cmdopt -bP
3171 .cindex "configuration options" "extracting"
3172 .cindex "options" "configuration &-- extracting"
3173 If this option is given with no arguments, it causes the values of all Exim's
3174 main configuration options to be written to the standard output. The values
3175 of one or more specific options can be requested by giving their names as
3176 arguments, for example:
3177 .code
3178 exim -bP qualify_domain hold_domains
3179 .endd
3180 .cindex "hiding configuration option values"
3181 .cindex "configuration options" "hiding value of"
3182 .cindex "options" "hiding value of"
3183 However, any option setting that is preceded by the word &"hide"& in the
3184 configuration file is not shown in full, except to an admin user. For other
3185 users, the output is as in this example:
3186 .code
3187 mysql_servers = <value not displayable>
3188 .endd
3189 If &%config%& is given as an argument, the config is
3190 output, as it was parsed, any include file resolved, any comment removed.
3191
3192 If &%config_file%& is given as an argument, the name of the runtime
3193 configuration file is output. (&%configure_file%& works too, for
3194 backward compatibility.)
3195 If a list of configuration files was supplied, the value that is output here
3196 is the name of the file that was actually used.
3197
3198 .cindex "options" "hiding name of"
3199 If the &%-n%& flag is given, then for most modes of &%-bP%& operation the
3200 name will not be output.
3201
3202 .cindex "daemon" "process id (pid)"
3203 .cindex "pid (process id)" "of daemon"
3204 If &%log_file_path%& or &%pid_file_path%& are given, the names of the
3205 directories where log files and daemon pid files are written are output,
3206 respectively. If these values are unset, log files are written in a
3207 sub-directory of the spool directory called &%log%&, and the pid file is
3208 written directly into the spool directory.
3209
3210 If &%-bP%& is followed by a name preceded by &`+`&, for example,
3211 .code
3212 exim -bP +local_domains
3213 .endd
3214 it searches for a matching named list of any type (domain, host, address, or
3215 local part) and outputs what it finds.
3216
3217 .cindex "options" "router &-- extracting"
3218 .cindex "options" "transport &-- extracting"
3219 .cindex "options" "authenticator &-- extracting"
3220 If one of the words &%router%&, &%transport%&, or &%authenticator%& is given,
3221 followed by the name of an appropriate driver instance, the option settings for
3222 that driver are output. For example:
3223 .code
3224 exim -bP transport local_delivery
3225 .endd
3226 The generic driver options are output first, followed by the driver's private
3227 options. A list of the names of drivers of a particular type can be obtained by
3228 using one of the words &%router_list%&, &%transport_list%&, or
3229 &%authenticator_list%&, and a complete list of all drivers with their option
3230 settings can be obtained by using &%routers%&, &%transports%&, or
3231 &%authenticators%&.
3232
3233 .cindex "environment"
3234 If &%environment%& is given as an argument, the set of environment
3235 variables is output, line by line. Using the &%-n%& flag suppresses the value of the
3236 variables.
3237
3238 .cindex "options" "macro &-- extracting"
3239 If invoked by an admin user, then &%macro%&, &%macro_list%& and &%macros%&
3240 are available, similarly to the drivers.  Because macros are sometimes used
3241 for storing passwords, this option is restricted.
3242 The output format is one item per line.
3243 For the "-bP macro <name>" form, if no such macro is found
3244 the exit status will be nonzero.
3245
3246 .cmdopt -bp
3247 .cindex "queue" "listing messages in"
3248 .cindex "listing" "messages in the queue"
3249 This option requests a listing of the contents of the mail queue on the
3250 standard output. If the &%-bp%& option is followed by a list of message ids,
3251 just those messages are listed. By default, this option can be used only by an
3252 admin user. However, the &%queue_list_requires_admin%& option can be set false
3253 to allow any user to see the queue.
3254
3255 Each message in the queue is displayed as in the following example:
3256 .code
3257 25m  2.9K 0t5C6f-0000c8-00 <alice@wonderland.fict.example>
3258           red.king@looking-glass.fict.example
3259           <other addresses>
3260 .endd
3261 .cindex "message" "size in queue listing"
3262 .cindex "size" "of message"
3263 The first line contains the length of time the message has been in the queue
3264 (in this case 25 minutes), the size of the message (2.9K), the unique local
3265 identifier for the message, and the message sender, as contained in the
3266 envelope. For bounce messages, the sender address is empty, and appears as
3267 &"<>"&. If the message was submitted locally by an untrusted user who overrode
3268 the default sender address, the user's login name is shown in parentheses
3269 before the sender address.
3270
3271 .cindex "frozen messages" "in queue listing"
3272 If the message is frozen (attempts to deliver it are suspended) then the text
3273 &"*** frozen ***"& is displayed at the end of this line.
3274
3275 The recipients of the message (taken from the envelope, not the headers) are
3276 displayed on subsequent lines. Those addresses to which the message has already
3277 been delivered are marked with the letter D. If an original address gets
3278 expanded into several addresses via an alias or forward file, the original is
3279 displayed with a D only when deliveries for all of its child addresses are
3280 complete.
3281
3282
3283 .cmdopt -bpa
3284 This option operates like &%-bp%&, but in addition it shows delivered addresses
3285 that were generated from the original top level address(es) in each message by
3286 alias or forwarding operations. These addresses are flagged with &"+D"& instead
3287 of just &"D"&.
3288
3289
3290 .cmdopt -bpc
3291 .cindex "queue" "count of messages on"
3292 This option counts the number of messages in the queue, and writes the total
3293 to the standard output. It is restricted to admin users, unless
3294 &%queue_list_requires_admin%& is set false.
3295
3296
3297 .cmdopt -bpi
3298 .cindex queue "list of message IDs"
3299 This option operates like &%-bp%&, but only outputs message ids
3300 (one per line).
3301
3302
3303 .cmdopt -bpr
3304 This option operates like &%-bp%&, but the output is not sorted into
3305 chronological order of message arrival. This can speed it up when there are
3306 lots of messages in the queue, and is particularly useful if the output is
3307 going to be post-processed in a way that doesn't need the sorting.
3308
3309 .cmdopt -bpra
3310 This option is a combination of &%-bpr%& and &%-bpa%&.
3311
3312 .cmdopt -bpri
3313 This option is a combination of &%-bpr%& and &%-bpi%&.
3314
3315 .cmdopt -bpru
3316 This option is a combination of &%-bpr%& and &%-bpu%&.
3317
3318
3319 .cmdopt -bpu
3320 This option operates like &%-bp%& but shows only undelivered top-level
3321 addresses for each message displayed. Addresses generated by aliasing or
3322 forwarding are not shown, unless the message was deferred after processing by a
3323 router with the &%one_time%& option set.
3324
3325
3326 .cmdopt -brt
3327 .cindex "testing" "retry configuration"
3328 .cindex "retry" "configuration testing"
3329 This option is for testing retry rules, and it must be followed by up to three
3330 arguments. It causes Exim to look for a retry rule that matches the values
3331 and to write it to the standard output. For example:
3332 .code
3333 exim -brt bach.comp.mus.example
3334 Retry rule: *.comp.mus.example  F,2h,15m; F,4d,30m;
3335 .endd
3336 See chapter &<<CHAPretry>>& for a description of Exim's retry rules. The first
3337 argument, which is required, can be a complete address in the form
3338 &'local_part@domain'&, or it can be just a domain name. If the second argument
3339 contains a dot, it is interpreted as an optional second domain name; if no
3340 retry rule is found for the first argument, the second is tried. This ties in
3341 with Exim's behaviour when looking for retry rules for remote hosts &-- if no
3342 rule is found that matches the host, one that matches the mail domain is
3343 sought. Finally, an argument that is the name of a specific delivery error, as
3344 used in setting up retry rules, can be given. For example:
3345 .code
3346 exim -brt haydn.comp.mus.example quota_3d
3347 Retry rule: *@haydn.comp.mus.example quota_3d  F,1h,15m
3348 .endd
3349
3350 .cmdopt -brw
3351 .cindex "testing" "rewriting"
3352 .cindex "rewriting" "testing"
3353 This option is for testing address rewriting rules, and it must be followed by
3354 a single argument, consisting of either a local part without a domain, or a
3355 complete address with a fully qualified domain. Exim outputs how this address
3356 would be rewritten for each possible place it might appear. See chapter
3357 &<<CHAPrewrite>>& for further details.
3358
3359 .cmdopt -bS
3360 .cindex "SMTP" "batched incoming"
3361 .cindex "batched SMTP input"
3362 This option is used for batched SMTP input, which is an alternative interface
3363 for non-interactive local message submission. A number of messages can be
3364 submitted in a single run. However, despite its name, this is not really SMTP
3365 input. Exim reads each message's envelope from SMTP commands on the standard
3366 input, but generates no responses. If the caller is trusted, or
3367 &%untrusted_set_sender%& is set, the senders in the SMTP MAIL commands are
3368 believed; otherwise the sender is always the caller of Exim.
3369
3370 The message itself is read from the standard input, in SMTP format (leading
3371 dots doubled), terminated by a line containing just a single dot. An error is
3372 provoked if the terminating dot is missing. A further message may then follow.
3373
3374 As for other local message submissions, the contents of incoming batch SMTP
3375 messages can be checked using the non-SMTP ACL (see chapter &<<CHAPACL>>&).
3376 Unqualified addresses are automatically qualified using &%qualify_domain%& and
3377 &%qualify_recipient%&, as appropriate, unless the &%-bnq%& option is used.
3378
3379 Some other SMTP commands are recognized in the input. HELO and EHLO act
3380 as RSET; VRFY, EXPN, ETRN, and HELP act as NOOP;
3381 QUIT quits, ignoring the rest of the standard input.
3382
3383 .cindex "return code" "for &%-bS%&"
3384 If any error is encountered, reports are written to the standard output and
3385 error streams, and Exim gives up immediately. The return code is 0 if no error
3386 was detected; it is 1 if one or more messages were accepted before the error
3387 was detected; otherwise it is 2.
3388
3389 More details of input using batched SMTP are given in section
3390 &<<SECTincomingbatchedSMTP>>&.
3391
3392 .cmdopt -bs
3393 .cindex "SMTP" "local input"
3394 .cindex "local SMTP input"
3395 This option causes Exim to accept one or more messages by reading SMTP commands
3396 on the standard input, and producing SMTP replies on the standard output. SMTP
3397 policy controls, as defined in ACLs (see chapter &<<CHAPACL>>&) are applied.
3398 Some user agents use this interface as a way of passing locally-generated
3399 messages to the MTA.
3400
3401 In
3402 .cindex "sender" "source of"
3403 this usage, if the caller of Exim is trusted, or &%untrusted_set_sender%& is
3404 set, the senders of messages are taken from the SMTP MAIL commands.
3405 Otherwise the content of these commands is ignored and the sender is set up as
3406 the calling user. Unqualified addresses are automatically qualified using
3407 &%qualify_domain%& and &%qualify_recipient%&, as appropriate, unless the
3408 &%-bnq%& option is used.
3409
3410 .cindex "inetd"
3411 The
3412 &%-bs%& option is also used to run Exim from &'inetd'&, as an alternative to
3413 using a listening daemon. Exim can distinguish the two cases by checking
3414 whether the standard input is a TCP/IP socket. When Exim is called from
3415 &'inetd'&, the source of the mail is assumed to be remote, and the comments
3416 above concerning senders and qualification do not apply. In this situation,
3417 Exim behaves in exactly the same way as it does when receiving a message via
3418 the listening daemon.
3419
3420 .cmdopt -bt
3421 .cindex "testing" "addresses"
3422 .cindex "address" "testing"
3423 This option runs Exim in address testing mode, in which each argument is taken
3424 as a recipient address to be tested for deliverability. The results are
3425 written to the standard output. If a test fails, and the caller is not an admin
3426 user, no details of the failure are output, because these might contain
3427 sensitive information such as usernames and passwords for database lookups.
3428
3429 If no arguments are given, Exim runs in an interactive manner, prompting with a
3430 right angle bracket for addresses to be tested.
3431
3432 Unlike the &%-be%& test option, you cannot arrange for Exim to use the
3433 &[readline()]& function, because it is running as &'root'& and there are
3434 security issues.
3435
3436 Each address is handled as if it were the recipient address of a message
3437 (compare the &%-bv%& option). It is passed to the routers and the result is
3438 written to the standard output. However, any router that has
3439 &%no_address_test%& set is bypassed. This can make &%-bt%& easier to use for
3440 genuine routing tests if your first router passes everything to a scanner
3441 program.
3442
3443 .cindex "return code" "for &%-bt%&"
3444 The return code is 2 if any address failed outright; it is 1 if no address
3445 failed outright but at least one could not be resolved for some reason. Return
3446 code 0 is given only when all addresses succeed.
3447
3448 .cindex "duplicate addresses"
3449 &*Note*&: When actually delivering a message, Exim removes duplicate recipient
3450 addresses after routing is complete, so that only one delivery takes place.
3451 This does not happen when testing with &%-bt%&; the full results of routing are
3452 always shown.
3453
3454 &*Warning*&: &%-bt%& can only do relatively simple testing. If any of the
3455 routers in the configuration makes any tests on the sender address of a
3456 message,
3457 .oindex "&%-f%&" "for address testing"
3458 you can use the &%-f%& option to set an appropriate sender when running
3459 &%-bt%& tests. Without it, the sender is assumed to be the calling user at the
3460 default qualifying domain. However, if you have set up (for example) routers
3461 whose behaviour depends on the contents of an incoming message, you cannot test
3462 those conditions using &%-bt%&. The &%-N%& option provides a possible way of
3463 doing such tests.
3464
3465 .cmdopt -bV
3466 .cindex "version number of Exim"
3467 This option causes Exim to write the current version number, compilation
3468 number, and compilation date of the &'exim'& binary to the standard output.
3469 It also lists the DBM library that is being used, the optional modules (such as
3470 specific lookup types), the drivers that are included in the binary, and the
3471 name of the runtime configuration file that is in use.
3472
3473 As part of its operation, &%-bV%& causes Exim to read and syntax check its
3474 configuration file. However, this is a static check only. It cannot check
3475 values that are to be expanded. For example, although a misspelt ACL verb is
3476 detected, an error in the verb's arguments is not. You cannot rely on &%-bV%&
3477 alone to discover (for example) all the typos in the configuration; some
3478 realistic testing is needed. The &%-bh%& and &%-N%& options provide more
3479 dynamic testing facilities.
3480
3481 .cmdopt -bv
3482 .cindex "verifying address" "using &%-bv%&"
3483 .cindex "address" "verification"
3484 This option runs Exim in address verification mode, in which each argument is
3485 taken as a recipient address to be verified by the routers. (This does
3486 not involve any verification callouts). During normal operation, verification
3487 happens mostly as a consequence processing a &%verify%& condition in an ACL
3488 (see chapter &<<CHAPACL>>&). If you want to test an entire ACL, possibly
3489 including callouts, see the &%-bh%& and &%-bhc%& options.
3490
3491 If verification fails, and the caller is not an admin user, no details of the
3492 failure are output, because these might contain sensitive information such as
3493 usernames and passwords for database lookups.
3494
3495 If no arguments are given, Exim runs in an interactive manner, prompting with a
3496 right angle bracket for addresses to be verified.
3497
3498 Unlike the &%-be%& test option, you cannot arrange for Exim to use the
3499 &[readline()]& function, because it is running as &'exim'& and there are
3500 security issues.
3501
3502 Verification differs from address testing (the &%-bt%& option) in that routers
3503 that have &%no_verify%& set are skipped, and if the address is accepted by a
3504 router that has &%fail_verify%& set, verification fails. The address is
3505 verified as a recipient if &%-bv%& is used; to test verification for a sender
3506 address, &%-bvs%& should be used.
3507
3508 If the &%-v%& option is not set, the output consists of a single line for each
3509 address, stating whether it was verified or not, and giving a reason in the
3510 latter case. Without &%-v%&, generating more than one address by redirection
3511 causes verification to end successfully, without considering the generated
3512 addresses. However, if just one address is generated, processing continues,
3513 and the generated address must verify successfully for the overall verification
3514 to succeed.
3515
3516 When &%-v%& is set, more details are given of how the address has been handled,
3517 and in the case of address redirection, all the generated addresses are also
3518 considered. Verification may succeed for some and fail for others.
3519
3520 The
3521 .cindex "return code" "for &%-bv%&"
3522 return code is 2 if any address failed outright; it is 1 if no address
3523 failed outright but at least one could not be resolved for some reason. Return
3524 code 0 is given only when all addresses succeed.
3525
3526 If any of the routers in the configuration makes any tests on the sender
3527 address of a message, you should use the &%-f%& option to set an appropriate
3528 sender when running &%-bv%& tests. Without it, the sender is assumed to be the
3529 calling user at the default qualifying domain.
3530
3531 .cmdopt -bvs
3532 This option acts like &%-bv%&, but verifies the address as a sender rather
3533 than a recipient address. This affects any rewriting and qualification that
3534 might happen.
3535
3536 .cmdopt -bw
3537 .cindex "daemon"
3538 .cindex "inetd"
3539 .cindex "inetd" "wait mode"
3540 This option runs Exim as a daemon, awaiting incoming SMTP connections,
3541 similarly to the &%-bd%& option.  All port specifications on the command-line
3542 and in the configuration file are ignored.  Queue-running may not be specified.
3543
3544 In this mode, Exim expects to be passed a socket as fd 0 (stdin) which is
3545 listening for connections.  This permits the system to start up and have
3546 inetd (or equivalent) listen on the SMTP ports, starting an Exim daemon for
3547 each port only when the first connection is received.
3548
3549 If the option is given as &%-bw%&<&'time'&> then the time is a timeout, after
3550 which the daemon will exit, which should cause inetd to listen once more.
3551
3552 .cmdopt -C <&'filelist'&>
3553 .cindex "configuration file" "alternate"
3554 .cindex "CONFIGURE_FILE"
3555 .cindex "alternate configuration file"
3556 This option causes Exim to find the runtime configuration file from the given
3557 list instead of from the list specified by the CONFIGURE_FILE
3558 compile-time setting. Usually, the list will consist of just a single filename,
3559 but it can be a colon-separated list of names. In this case, the first
3560 file that exists is used. Failure to open an existing file stops Exim from
3561 proceeding any further along the list, and an error is generated.
3562
3563 When this option is used by a caller other than root, and the list is different
3564 from the compiled-in list, Exim gives up its root privilege immediately, and
3565 runs with the real and effective uid and gid set to those of the caller.
3566 However, if a TRUSTED_CONFIG_LIST file is defined in &_Local/Makefile_&, that
3567 file contains a list of full pathnames, one per line, for configuration files
3568 which are trusted. Root privilege is retained for any configuration file so
3569 listed, as long as the caller is the Exim user (or the user specified in the
3570 CONFIGURE_OWNER option, if any), and as long as the configuration file is
3571 not writeable by inappropriate users or groups.
3572
3573 Leaving TRUSTED_CONFIG_LIST unset precludes the possibility of testing a
3574 configuration using &%-C%& right through message reception and delivery,
3575 even if the caller is root. The reception works, but by that time, Exim is
3576 running as the Exim user, so when it re-executes to regain privilege for the
3577 delivery, the use of &%-C%& causes privilege to be lost. However, root can
3578 test reception and delivery using two separate commands (one to put a message
3579 in the queue, using &%-odq%&, and another to do the delivery, using &%-M%&).
3580
3581 If ALT_CONFIG_PREFIX is defined &_in Local/Makefile_&, it specifies a
3582 prefix string with which any file named in a &%-C%& command line option
3583 must start. In addition, the filename must not contain the sequence &`/../`&.
3584 However, if the value of the &%-C%& option is identical to the value of
3585 CONFIGURE_FILE in &_Local/Makefile_&, Exim ignores &%-C%& and proceeds as
3586 usual. There is no default setting for ALT_CONFIG_PREFIX; when it is
3587 unset, any filename can be used with &%-C%&.
3588
3589 ALT_CONFIG_PREFIX can be used to confine alternative configuration files
3590 to a directory to which only root has access. This prevents someone who has
3591 broken into the Exim account from running a privileged Exim with an arbitrary
3592 configuration file.
3593
3594 The &%-C%& facility is useful for ensuring that configuration files are
3595 syntactically correct, but cannot be used for test deliveries, unless the
3596 caller is privileged, or unless it is an exotic configuration that does not
3597 require privilege. No check is made on the owner or group of the files
3598 specified by this option.
3599
3600
3601 .vitem &%-D%&<&'macro'&>=<&'value'&>
3602 .oindex "&%-D%&"
3603 .cindex "macro" "setting on command line"
3604 This option can be used to override macro definitions in the configuration file
3605 (see section &<<SECTmacrodefs>>&). However, like &%-C%&, if it is used by an
3606 unprivileged caller, it causes Exim to give up its root privilege.
3607 If DISABLE_D_OPTION is defined in &_Local/Makefile_&, the use of &%-D%& is
3608 completely disabled, and its use causes an immediate error exit.
3609
3610 If WHITELIST_D_MACROS is defined in &_Local/Makefile_& then it should be a
3611 colon-separated list of macros which are considered safe and, if &%-D%& only
3612 supplies macros from this list, and the values are acceptable, then Exim will
3613 not give up root privilege if the caller is root, the Exim run-time user, or
3614 the CONFIGURE_OWNER, if set.  This is a transition mechanism and is expected
3615 to be removed in the future.  Acceptable values for the macros satisfy the
3616 regexp: &`^[A-Za-z0-9_/.-]*$`&
3617
3618 The entire option (including equals sign if present) must all be within one
3619 command line item. &%-D%& can be used to set the value of a macro to the empty
3620 string, in which case the equals sign is optional. These two commands are
3621 synonymous:
3622 .code
3623 exim -DABC  ...
3624 exim -DABC= ...
3625 .endd
3626 To include spaces in a macro definition item, quotes must be used. If you use
3627 quotes, spaces are permitted around the macro name and the equals sign. For
3628 example:
3629 .code
3630 exim '-D ABC = something' ...
3631 .endd
3632 &%-D%& may be repeated up to 10 times on a command line.
3633 Only macro names up to 22 letters long can be set.
3634
3635
3636 .vitem &%-d%&<&'debug&~options'&>
3637 .oindex "&%-d%&"
3638 .cindex "debugging" "list of selectors"
3639 .cindex "debugging" "&%-d%& option"
3640 This option causes debugging information to be written to the standard
3641 error stream. It is restricted to admin users because debugging output may show
3642 database queries that contain password information. Also, the details of users'
3643 filter files should be protected. If a non-admin user uses &%-d%&, Exim
3644 writes an error message to the standard error stream and exits with a non-zero
3645 return code.
3646
3647 When &%-d%& is used, &%-v%& is assumed. If &%-d%& is given on its own, a lot of
3648 standard debugging data is output. This can be reduced, or increased to include
3649 some more rarely needed information, by directly following &%-d%& with a string
3650 made up of names preceded by plus or minus characters. These add or remove sets
3651 of debugging data, respectively. For example, &%-d+filter%& adds filter
3652 debugging, whereas &%-d-all+filter%& selects only filter debugging. Note that
3653 no spaces are allowed in the debug setting. The available debugging categories
3654 are:
3655 .itable none 0 0 2 20* left 80* left
3656 .irow acl            "ACL interpretation"
3657 .irow auth           "authenticators"
3658 .irow deliver        "general delivery logic"
3659 .irow dns            "DNS lookups (see also resolver)"
3660 .irow dnsbl          "DNS black list (aka RBL) code"
3661 .irow exec           "arguments for &[execv()]& calls"
3662 .irow expand         "detailed debugging for string expansions"
3663 .irow filter         "filter handling"
3664 .irow hints_lookup   "hints data lookups"
3665 .irow host_lookup    "all types of name-to-IP address handling"
3666 .irow ident          "ident lookup"
3667 .irow interface      "lists of local interfaces"
3668 .irow lists          "matching things in lists"
3669 .irow load           "system load checks"
3670 .irow local_scan     "can be used by &[local_scan()]& (see chapter &&&
3671                     &<<CHAPlocalscan>>&)"
3672 .irow lookup         "general lookup code and all lookups"
3673 .irow memory         "memory handling"
3674 .irow noutf8         "modifier: avoid UTF-8 line-drawing"
3675 .irow pid            "modifier: add pid to debug output lines"
3676 .irow process_info   "setting info for the process log"
3677 .irow queue_run      "queue runs"
3678 .irow receive        "general message reception logic"
3679 .irow resolver       "turn on the DNS resolver's debugging output"
3680 .irow retry          "retry handling"
3681 .irow rewrite        "address rewriting""
3682 .irow route          "address routing"
3683 .irow timestamp      "modifier: add timestamp to debug output lines"
3684 .irow tls            "TLS logic"
3685 .irow transport      "transports"
3686 .irow uid            "changes of uid/gid and looking up uid/gid"
3687 .irow verify         "address verification logic"
3688 .irow all            "almost all of the above (see below), and also &%-v%&"
3689 .endtable
3690 The &`all`& option excludes &`memory`& when used as &`+all`&, but includes it
3691 for &`-all`&. The reason for this is that &`+all`& is something that people
3692 tend to use when generating debug output for Exim maintainers. If &`+memory`&
3693 is included, an awful lot of output that is very rarely of interest is
3694 generated, so it now has to be explicitly requested. However, &`-all`& does
3695 turn everything off.
3696
3697 .cindex "resolver, debugging output"
3698 .cindex "DNS resolver, debugging output"
3699 The &`resolver`& option produces output only if the DNS resolver was compiled
3700 with DEBUG enabled. This is not the case in some operating systems. Also,
3701 unfortunately, debugging output from the DNS resolver is written to stdout
3702 rather than stderr.
3703
3704 The default (&%-d%& with no argument) omits &`expand`&, &`filter`&,
3705 &`interface`&, &`load`&, &`memory`&, &`pid`&, &`resolver`&, and &`timestamp`&.
3706 However, the &`pid`& selector is forced when debugging is turned on for a
3707 daemon, which then passes it on to any re-executed Exims. Exim also
3708 automatically adds the pid to debug lines when several remote deliveries are
3709 run in parallel.
3710
3711 The &`timestamp`& selector causes the current time to be inserted at the start
3712 of all debug output lines. This can be useful when trying to track down delays
3713 in processing.
3714
3715 .cindex debugging "UTF-8 in"
3716 .cindex UTF-8 "in debug output"
3717 The &`noutf8`& selector disables the use of
3718 UTF-8 line-drawing characters to group related information.
3719 When disabled. ascii-art is used instead.
3720 Using the &`+all`& option does not set this modifier,
3721
3722 If the &%debug_print%& option is set in any driver, it produces output whenever
3723 any debugging is selected, or if &%-v%& is used.
3724
3725 .vitem &%-dd%&<&'debug&~options'&>
3726 .oindex "&%-dd%&"
3727 This option behaves exactly like &%-d%& except when used on a command that
3728 starts a daemon process. In that case, debugging is turned off for the
3729 subprocesses that the daemon creates. Thus, it is useful for monitoring the
3730 behaviour of the daemon without creating as much output as full debugging does.
3731
3732 .cmdopt -dropcr
3733 This is an obsolete option that is now a no-op. It used to affect the way Exim
3734 handled CR and LF characters in incoming messages. What happens now is
3735 described in section &<<SECTlineendings>>&.
3736
3737 .cmdopt -E
3738 .cindex "bounce message" "generating"
3739 This option specifies that an incoming message is a locally-generated delivery
3740 failure report. It is used internally by Exim when handling delivery failures
3741 and is not intended for external use. Its only effect is to stop Exim
3742 generating certain messages to the postmaster, as otherwise message cascades
3743 could occur in some situations. As part of the same option, a message id may
3744 follow the characters &%-E%&. If it does, the log entry for the receipt of the
3745 new message contains the id, following &"R="&, as a cross-reference.
3746
3747 .vitem &%-e%&&'x'&
3748 .oindex "&%-e%&&'x'&"
3749 There are a number of Sendmail options starting with &%-oe%& which seem to be
3750 called by various programs without the leading &%o%& in the option. For
3751 example, the &%vacation%& program uses &%-eq%&. Exim treats all options of the
3752 form &%-e%&&'x'& as synonymous with the corresponding &%-oe%&&'x'& options.
3753
3754 .cmdopt -F <&'string'&>
3755 .cindex "sender" "name"
3756 .cindex "name" "of sender"
3757 This option sets the sender's full name for use when a locally-generated
3758 message is being accepted. In the absence of this option, the user's &'gecos'&
3759 entry from the password data is used. As users are generally permitted to alter
3760 their &'gecos'& entries, no security considerations are involved. White space
3761 between &%-F%& and the <&'string'&> is optional.
3762
3763 .cmdopt -f <&'address'&>
3764 .cindex "sender" "address"
3765 .cindex "address" "sender"
3766 .cindex "trusted users"
3767 .cindex "envelope from"
3768 .cindex "envelope sender"
3769 .cindex "user" "trusted"
3770 This option sets the address of the envelope sender of a locally-generated
3771 message (also known as the return path). The option can normally be used only
3772 by a trusted user, but &%untrusted_set_sender%& can be set to allow untrusted
3773 users to use it.
3774
3775 Processes running as root or the Exim user are always trusted. Other
3776 trusted users are defined by the &%trusted_users%& or &%trusted_groups%&
3777 options. In the absence of &%-f%&, or if the caller is not trusted, the sender
3778 of a local message is set to the caller's login name at the default qualify
3779 domain.
3780
3781 There is one exception to the restriction on the use of &%-f%&: an empty sender
3782 can be specified by any user, trusted or not, to create a message that can
3783 never provoke a bounce. An empty sender can be specified either as an empty
3784 string, or as a pair of angle brackets with nothing between them, as in these
3785 examples of shell commands:
3786 .code
3787 exim -f '<>' user@domain
3788 exim -f "" user@domain
3789 .endd
3790 In addition, the use of &%-f%& is not restricted when testing a filter file
3791 with &%-bf%& or when testing or verifying addresses using the &%-bt%& or
3792 &%-bv%& options.
3793
3794 Allowing untrusted users to change the sender address does not of itself make
3795 it possible to send anonymous mail. Exim still checks that the &'From:'& header
3796 refers to the local user, and if it does not, it adds a &'Sender:'& header,
3797 though this can be overridden by setting &%no_local_from_check%&.
3798
3799 White
3800 .cindex "&""From""& line"
3801 space between &%-f%& and the <&'address'&> is optional (that is, they can be
3802 given as two arguments or one combined argument). The sender of a
3803 locally-generated message can also be set (when permitted) by an initial
3804 &"From&~"& line in the message &-- see the description of &%-bm%& above &-- but
3805 if &%-f%& is also present, it overrides &"From&~"&.
3806
3807 .cmdopt -G
3808 .cindex "submission fixups, suppressing (command-line)"
3809 This option is equivalent to an ACL applying:
3810 .code
3811 control = suppress_local_fixups
3812 .endd
3813 for every message received.  Note that Sendmail will complain about such
3814 bad formatting, where Exim silently just does not fix it up.  This may change
3815 in future.
3816
3817 As this affects audit information, the caller must be a trusted user to use
3818 this option.
3819
3820 .cmdopt -h <&'number'&>
3821 .cindex "Sendmail compatibility" "&%-h%& option ignored"
3822 This option is accepted for compatibility with Sendmail, but has no effect. (In
3823 Sendmail it overrides the &"hop count"& obtained by counting &'Received:'&
3824 headers.)
3825
3826 .cmdopt -i
3827 .cindex "Solaris" "&'mail'& command"
3828 .cindex "dot" "in incoming non-SMTP message"
3829 This option, which has the same effect as &%-oi%&, specifies that a dot on a
3830 line by itself should not terminate an incoming, non-SMTP message.
3831 Solaris 2.4 (SunOS 5.4) Sendmail has a similar &%-i%& processing option
3832 &url(https://docs.oracle.com/cd/E19457-01/801-6680-1M/801-6680-1M.pdf),
3833 p. 1M-529), and therefore a &%-oi%& command line option, which both are used
3834 by its &'mailx'& command.
3835
3836 .cmdopt -L <&'tag'&>
3837 .cindex "syslog" "process name; set with flag"
3838 This option is equivalent to setting &%syslog_processname%& in the config
3839 file and setting &%log_file_path%& to &`syslog`&.
3840 Its use is restricted to administrators.  The configuration file has to be
3841 read and parsed, to determine access rights, before this is set and takes
3842 effect, so early configuration file errors will not honour this flag.
3843
3844 The tag should not be longer than 32 characters.
3845
3846 .cmdopt -M <&'message&~id'&>&~<&'message&~id'&>&~...
3847 .cindex "forcing delivery"
3848 .cindex "delivery" "forcing attempt"
3849 .cindex "frozen messages" "forcing delivery"
3850 This option requests Exim to run a delivery attempt on each message in turn. If
3851 any of the messages are frozen, they are automatically thawed before the
3852 delivery attempt. The settings of &%queue_domains%&, &%queue_smtp_domains%&,
3853 and &%hold_domains%& are ignored.
3854
3855 Retry
3856 .cindex "hints database" "overriding retry hints"
3857 hints for any of the addresses are overridden &-- Exim tries to deliver even if
3858 the normal retry time has not yet been reached. This option requires the caller
3859 to be an admin user. However, there is an option called &%prod_requires_admin%&
3860 which can be set false to relax this restriction (and also the same requirement
3861 for the &%-q%&, &%-R%&, and &%-S%& options).
3862
3863 The deliveries happen synchronously, that is, the original Exim process does
3864 not terminate until all the delivery attempts have finished. No output is
3865 produced unless there is a serious error. If you want to see what is happening,
3866 use the &%-v%& option as well, or inspect Exim's main log.
3867
3868 .cmdopt -Mar <&'message&~id'&>&~<&'address'&>&~<&'address'&>&~...
3869 .cindex "message" "adding recipients"
3870 .cindex "recipient" "adding"
3871 This option requests Exim to add the addresses to the list of recipients of the
3872 message (&"ar"& for &"add recipients"&). The first argument must be a message
3873 id, and the remaining ones must be email addresses. However, if the message is
3874 active (in the middle of a delivery attempt), it is not altered. This option
3875 can be used only by an admin user.
3876
3877 .vitem "&%-MC%&&~<&'transport'&>&~<&'hostname'&>&&&
3878         &~<&'host&~IP'&>&&&
3879         &~<&'sequence&~number'&>&&&
3880         &~<&'message&~id'&>"
3881 .oindex "&%-MC%&"
3882 .cindex "SMTP" "passed connection"
3883 .cindex "SMTP" "multiple deliveries"
3884 .cindex "multiple SMTP deliveries"
3885 This option is not intended for use by external callers. It is used internally
3886 by Exim to invoke another instance of itself to deliver a waiting message using
3887 an existing SMTP connection, which is passed as the standard input. Details are
3888 given in chapter &<<CHAPSMTP>>&. This must be the final option, and the caller
3889 must be root or the Exim user in order to use it.
3890
3891 .cmdopt -MCA
3892 This option is not intended for use by external callers. It is used internally
3893 by Exim in conjunction with the &%-MC%& option. It signifies that the
3894 connection to the remote host has been authenticated.
3895
3896 .cmdopt -MCD
3897 This option is not intended for use by external callers. It is used internally
3898 by Exim in conjunction with the &%-MC%& option. It signifies that the
3899 remote host supports the ESMTP &_DSN_& extension.
3900
3901 .cmdopt -MCd
3902 This option is not intended for use by external callers. It is used internally
3903 by Exim in conjunction with the &%-d%& option
3904 to pass on an information string on the purpose of the process.
3905
3906 .cmdopt -MCG <&'queue&~name'&>
3907 This option is not intended for use by external callers. It is used internally
3908 by Exim in conjunction with the &%-MC%& option. It signifies that an
3909 alternate queue is used, named by the following argument.
3910
3911 .cmdopt -MCK
3912 This option is not intended for use by external callers. It is used internally
3913 by Exim in conjunction with the &%-MC%& option. It signifies that a
3914 remote host supports the ESMTP &_CHUNKING_& extension.
3915
3916 .cmdopt -MCL
3917 This option is not intended for use by external callers. It is used internally
3918 by Exim in conjunction with the &%-MC%& option. It signifies that the server to
3919 which Exim is connected advertised limits on numbers of mails, recipients or
3920 recipient domains.
3921 The limits are given by the following three arguments.
3922
3923 .cmdopt -MCP
3924 This option is not intended for use by external callers. It is used internally
3925 by Exim in conjunction with the &%-MC%& option. It signifies that the server to
3926 which Exim is connected supports pipelining.
3927
3928 .cmdopt -MCp
3929 This option is not intended for use by external callers. It is used internally
3930 by Exim in conjunction with the &%-MC%& option. It signifies that the connection
3931 t a remote server is via a SOCKS proxy, using addresses and ports given by
3932 the following four arguments.
3933
3934 .cmdopt -MCQ <&'process&~id'&>&~<&'pipe&~fd'&>
3935 This option is not intended for use by external callers. It is used internally
3936 by Exim in conjunction with the &%-MC%& option when the original delivery was
3937 started by a queue runner. It passes on the process id of the queue runner,
3938 together with the file descriptor number of an open pipe. Closure of the pipe
3939 signals the final completion of the sequence of processes that are passing
3940 messages through the same SMTP connection.
3941
3942 .cmdopt -MCq <&'recipient&~address'&>&~<&'size'&>
3943 This option is not intended for use by external callers. It is used internally
3944 by Exim to implement quota checking for local users.
3945
3946 .cmdopt -MCS
3947 This option is not intended for use by external callers. It is used internally
3948 by Exim in conjunction with the &%-MC%& option, and passes on the fact that the
3949 ESMTP SIZE option should be used on messages delivered down the existing
3950 connection.
3951
3952 .cmdopt -MCT
3953 This option is not intended for use by external callers. It is used internally
3954 by Exim in conjunction with the &%-MC%& option, and passes on the fact that the
3955 host to which Exim is connected supports TLS encryption.
3956
3957 .vitem &%-MCr%&&~<&'SNI'&> &&&
3958        &%-MCs%&&~<&'SNI'&>
3959 .oindex "&%-MCs%&"
3960 .oindex "&%-MCr%&"
3961 These options are not intended for use by external callers. It is used internally
3962 by Exim in conjunction with the &%-MCt%& option, and passes on the fact that
3963 a TLS Server Name Indication was sent as part of the channel establishment.
3964 The argument gives the SNI string.
3965 The "r" variant indicates a DANE-verified connection.
3966
3967 .cmdopt -MCt <&'IP&~address'&>&~<&'port'&>&~<&'cipher'&>
3968 This option is not intended for use by external callers. It is used internally
3969 by Exim in conjunction with the &%-MC%& option, and passes on the fact that the
3970 connection is being proxied by a parent process for handling TLS encryption.
3971 The arguments give the local address and port being proxied, and the TLS cipher.
3972
3973 .cmdopt -Mc <&'message&~id'&>&~<&'message&~id'&>&~...
3974 .cindex "hints database" "not overridden by &%-Mc%&"
3975 .cindex "delivery" "manually started &-- not forced"
3976 This option requests Exim to run a delivery attempt on each message, in turn,
3977 but unlike the &%-M%& option, it does check for retry hints, and respects any
3978 that are found. This option is not very useful to external callers. It is
3979 provided mainly for internal use by Exim when it needs to re-invoke itself in
3980 order to regain root privilege for a delivery (see chapter &<<CHAPsecurity>>&).
3981 However, &%-Mc%& can be useful when testing, in order to run a delivery that
3982 respects retry times and other options such as &%hold_domains%& that are
3983 overridden when &%-M%& is used. Such a delivery does not count as a queue run.
3984 If you want to run a specific delivery as if in a queue run, you should use
3985 &%-q%& with a message id argument. A distinction between queue run deliveries
3986 and other deliveries is made in one or two places.
3987
3988 .cmdopt -Mes <&'message&~id'&>&~<&'address'&>
3989 .cindex "message" "changing sender"
3990 .cindex "sender" "changing"
3991 This option requests Exim to change the sender address in the message to the
3992 given address, which must be a fully qualified address or &"<>"& (&"es"& for
3993 &"edit sender"&). There must be exactly two arguments. The first argument must
3994 be a message id, and the second one an email address. However, if the message
3995 is active (in the middle of a delivery attempt), its status is not altered.
3996 This option can be used only by an admin user.
3997
3998 .cmdopt -Mf <&'message&~id'&>&~<&'message&~id'&>&~...
3999 .cindex "freezing messages"
4000 .cindex "message" "manually freezing"
4001 This option requests Exim to mark each listed message as &"frozen"&. This
4002 prevents any delivery attempts taking place until the message is &"thawed"&,
4003 either manually or as a result of the &%auto_thaw%& configuration option.
4004 However, if any of the messages are active (in the middle of a delivery
4005 attempt), their status is not altered. This option can be used only by an admin
4006 user.
4007
4008 .cmdopt -Mg <&'message&~id'&>&~<&'message&~id'&>&~...
4009 .cindex "giving up on messages"
4010 .cindex "message" "abandoning delivery attempts"
4011 .cindex "delivery" "abandoning further attempts"
4012 This option requests Exim to give up trying to deliver the listed messages,
4013 including any that are frozen. However, if any of the messages are active,
4014 their status is not altered. For non-bounce messages, a delivery error message
4015 is sent to the sender.
4016 Bounce messages are just discarded. This option can be used only by an admin
4017 user.
4018
4019 .cmdopt -MG <&'queue&~name'&>&~<&'message&~id'&>&~<&'message&~id'&>&~...
4020 .cindex queue named
4021 .cindex "named queues" "moving messages"
4022 .cindex "queue" "moving messages"
4023 This option requests that each listed message be moved from its current
4024 queue to the given named queue.
4025 The destination queue name argument is required, but can be an empty
4026 string to define the default queue.
4027 If the messages are not currently located in the default queue,
4028 a &%-qG<name>%& option will be required to define the source queue.
4029
4030 .cmdopt -Mmad <&'message&~id'&>&~<&'message&~id'&>&~...
4031 .cindex "delivery" "cancelling all"
4032 This option requests Exim to mark all the recipient addresses in the messages
4033 as already delivered (&"mad"& for &"mark all delivered"&). However, if any
4034 message is active (in the middle of a delivery attempt), its status is not
4035 altered. This option can be used only by an admin user.
4036
4037 .cmdopt -Mmd <&'message&~id'&>&~<&'address'&>&~<&'address'&>&~...
4038 .cindex "delivery" "cancelling by address"
4039 .cindex "recipient" "removing"
4040 .cindex "removing recipients"
4041 This option requests Exim to mark the given addresses as already delivered
4042 (&"md"& for &"mark delivered"&). The first argument must be a message id, and
4043 the remaining ones must be email addresses. These are matched to recipient
4044 addresses in the message in a case-sensitive manner. If the message is active
4045 (in the middle of a delivery attempt), its status is not altered. This option
4046 can be used only by an admin user.
4047
4048 .cmdopt -Mrm <&'message&~id'&>&~<&'message&~id'&>&~...
4049 .cindex "removing messages"
4050 .cindex "abandoning mail"
4051 .cindex "message" "manually discarding"
4052 This option requests Exim to remove the given messages from the queue. No
4053 bounce messages are sent; each message is simply forgotten. However, if any of
4054 the messages are active, their status is not altered. This option can be used
4055 only by an admin user or by the user who originally caused the message to be
4056 placed in the queue.
4057
4058 . .new
4059 . .vitem &%-MS%&
4060 . .oindex "&%-MS%&"
4061 . .cindex REQUIRETLS
4062 . This option is used to request REQUIRETLS processing on the message.
4063 . It is used internally by Exim in conjunction with -E when generating
4064 . a bounce message.
4065 . .wen
4066
4067 .cmdopt -Mset <&'message&~id'&>
4068 .cindex "testing" "string expansion"
4069 .cindex "expansion" "testing"
4070 This option is useful only in conjunction with &%-be%& (that is, when testing
4071 string expansions). Exim loads the given message from its spool before doing
4072 the test expansions, thus setting message-specific variables such as
4073 &$message_size$& and the header variables. The &$recipients$& variable is made
4074 available. This feature is provided to make it easier to test expansions that
4075 make use of these variables. However, this option can be used only by an admin
4076 user. See also &%-bem%&.
4077
4078 .cmdopt -Mt <&'message&~id'&>&~<&'message&~id'&>&~...
4079 .cindex "thawing messages"
4080 .cindex "unfreezing messages"
4081 .cindex "frozen messages" "thawing"
4082 .cindex "message" "thawing frozen"
4083 This option requests Exim to &"thaw"& any of the listed messages that are
4084 &"frozen"&, so that delivery attempts can resume. However, if any of the
4085 messages are active, their status is not altered. This option can be used only
4086 by an admin user.
4087
4088 .cmdopt -Mvb <&'message&~id'&>
4089 .cindex "listing" "message body"
4090 .cindex "message" "listing body of"
4091 This option causes the contents of the message body (-D) spool file to be
4092 written to the standard output. This option can be used only by an admin user.
4093
4094 .cmdopt -Mvc <&'message&~id'&>
4095 .cindex "message" "listing in RFC 2822 format"
4096 .cindex "listing" "message in RFC 2822 format"
4097 This option causes a copy of the complete message (header lines plus body) to
4098 be written to the standard output in RFC 2822 format. This option can be used
4099 only by an admin user.
4100
4101 .cmdopt -Mvh <&'message&~id'&>
4102 .cindex "listing" "message headers"
4103 .cindex "header lines" "listing"
4104 .cindex "message" "listing header lines"
4105 This option causes the contents of the message headers (-H) spool file to be
4106 written to the standard output. This option can be used only by an admin user.
4107
4108 .cmdopt -Mvl <&'message&~id'&>
4109 .cindex "listing" "message log"
4110 .cindex "message" "listing message log"
4111 This option causes the contents of the message log spool file to be written to
4112 the standard output. This option can be used only by an admin user.
4113
4114 .cmdopt -m
4115 This is a synonym for &%-om%& that is accepted by Sendmail
4116 (&url(https://docs.oracle.com/cd/E19457-01/801-6680-1M/801-6680-1M.pdf)
4117 p. 1M-258), so Exim treats it that way too.
4118
4119 .cmdopt -N
4120 .cindex "debugging" "&%-N%& option"
4121 .cindex "debugging" "suppressing delivery"
4122 This is a debugging option that inhibits delivery of a message at the transport
4123 level. It implies &%-v%&. Exim goes through many of the motions of delivery &--
4124 it just doesn't actually transport the message, but instead behaves as if it
4125 had successfully done so. However, it does not make any updates to the retry
4126 database, and the log entries for deliveries are flagged with &"*>"& rather
4127 than &"=>"&.
4128
4129 Because &%-N%& discards any message to which it applies, only root or the Exim
4130 user are allowed to use it with &%-bd%&, &%-q%&, &%-R%& or &%-M%&. In other
4131 words, an ordinary user can use it only when supplying an incoming message to
4132 which it will apply. Although transportation never fails when &%-N%& is set, an
4133 address may be deferred because of a configuration problem on a transport, or a
4134 routing problem. Once &%-N%& has been used for a delivery attempt, it sticks to
4135 the message, and applies to any subsequent delivery attempts that may happen
4136 for that message.
4137
4138 .cmdopt -n
4139 This option is interpreted by Sendmail to mean &"no aliasing"&.
4140 For normal modes of operation, it is ignored by Exim.
4141 When combined with &%-bP%& it makes the output more terse (suppresses
4142 option names, environment values and config pretty printing).
4143
4144 .cmdopt -O <&'data'&>
4145 This option is interpreted by Sendmail to mean &`set option`&. It is ignored by
4146 Exim.
4147
4148 .cmdopt -oA <&'file&~name'&>
4149 .cindex "Sendmail compatibility" "&%-oA%& option"
4150 This option is used by Sendmail in conjunction with &%-bi%& to specify an
4151 alternative alias filename. Exim handles &%-bi%& differently; see the
4152 description above.
4153
4154 .cmdopt -oB <&'n'&>
4155 .cindex "SMTP" "passed connection"
4156 .cindex "SMTP" "multiple deliveries"
4157 .cindex "multiple SMTP deliveries"
4158 This is a debugging option which limits the maximum number of messages that can
4159 be delivered down one SMTP connection, overriding the value set in any &(smtp)&
4160 transport. If <&'n'&> is omitted, the limit is set to 1.
4161
4162 .cmdopt -odb
4163 .cindex "background delivery"
4164 .cindex "delivery" "in the background"
4165 This option applies to all modes in which Exim accepts incoming messages,
4166 including the listening daemon. It requests &"background"& delivery of such
4167 messages, which means that the accepting process automatically starts a
4168 delivery process for each message received, but does not wait for the delivery
4169 processes to finish.
4170
4171 When all the messages have been received, the reception process exits,
4172 leaving the delivery processes to finish in their own time. The standard output
4173 and error streams are closed at the start of each delivery process.
4174 This is the default action if none of the &%-od%& options are present.
4175
4176 If one of the queueing options in the configuration file
4177 (&%queue_only%& or &%queue_only_file%&, for example) is in effect, &%-odb%&
4178 overrides it if &%queue_only_override%& is set true, which is the default
4179 setting. If &%queue_only_override%& is set false, &%-odb%& has no effect.
4180
4181 .cmdopt -odf
4182 .cindex "foreground delivery"
4183 .cindex "delivery" "in the foreground"
4184 This option requests &"foreground"& (synchronous) delivery when Exim has
4185 accepted a locally-generated message. (For the daemon it is exactly the same as
4186 &%-odb%&.) A delivery process is automatically started to deliver the message,
4187 and Exim waits for it to complete before proceeding.
4188
4189 The original Exim reception process does not finish until the delivery
4190 process for the final message has ended. The standard error stream is left open
4191 during deliveries.
4192
4193 However, like &%-odb%&, this option has no effect if &%queue_only_override%& is
4194 false and one of the queueing options in the configuration file is in effect.
4195
4196 If there is a temporary delivery error during foreground delivery, the
4197 message is left in the queue for later delivery, and the original reception
4198 process exits. See chapter &<<CHAPnonqueueing>>& for a way of setting up a
4199 restricted configuration that never queues messages.
4200
4201
4202 .cmdopt -odi
4203 This option is synonymous with &%-odf%&. It is provided for compatibility with
4204 Sendmail.
4205
4206 .cmdopt -odq
4207 .cindex "non-immediate delivery"
4208 .cindex "delivery" "suppressing immediate"
4209 .cindex "queueing incoming messages"
4210 This option applies to all modes in which Exim accepts incoming messages,
4211 including the listening daemon. It specifies that the accepting process should
4212 not automatically start a delivery process for each message received. Messages
4213 are placed in the queue, and remain there until a subsequent queue runner
4214 process encounters them. There are several configuration options (such as
4215 &%queue_only%&) that can be used to queue incoming messages under certain
4216 conditions. This option overrides all of them and also &%-odqs%&. It always
4217 forces queueing.
4218
4219 .cmdopt -odqs
4220 .cindex "SMTP" "delaying delivery"
4221 .cindex "first pass routing"
4222 This option is a hybrid between &%-odb%&/&%-odi%& and &%-odq%&.
4223 However, like &%-odb%& and &%-odi%&, this option has no effect if
4224 &%queue_only_override%& is false and one of the queueing options in the
4225 configuration file is in effect.
4226
4227 When &%-odqs%& does operate, a delivery process is started for each incoming
4228 message, in the background by default, but in the foreground if &%-odi%& is
4229 also present. The recipient addresses are routed, and local deliveries are done
4230 in the normal way. However, if any SMTP deliveries are required, they are not
4231 done at this time, so the message remains in the queue until a subsequent queue
4232 runner process encounters it. Because routing was done, Exim knows which
4233 messages are waiting for which hosts, and so a number of messages for the same
4234 host can be sent in a single SMTP connection. The &%queue_smtp_domains%&
4235 configuration option has the same effect for specific domains. See also the
4236 &%-qq%& option.
4237
4238 .cmdopt -oee
4239 .cindex "error" "reporting"
4240 If an error is detected while a non-SMTP message is being received (for
4241 example, a malformed address), the error is reported to the sender in a mail
4242 message.
4243
4244 .cindex "return code" "for &%-oee%&"
4245 Provided
4246 this error message is successfully sent, the Exim receiving process
4247 exits with a return code of zero. If not, the return code is 2 if the problem
4248 is that the original message has no recipients, or 1 for any other error.
4249 This is the default &%-oe%&&'x'& option if Exim is called as &'rmail'&.
4250
4251 .cmdopt -oem
4252 .cindex "error" "reporting"
4253 .cindex "return code" "for &%-oem%&"
4254 This is the same as &%-oee%&, except that Exim always exits with a non-zero
4255 return code, whether or not the error message was successfully sent.
4256 This is the default &%-oe%&&'x'& option, unless Exim is called as &'rmail'&.
4257
4258 .cmdopt -oep
4259 .cindex "error" "reporting"
4260 If an error is detected while a non-SMTP message is being received, the
4261 error is reported by writing a message to the standard error file (stderr).
4262 .cindex "return code" "for &%-oep%&"
4263 The return code is 1 for all errors.
4264
4265 .cmdopt -oeq
4266 .cindex "error" "reporting"
4267 This option is supported for compatibility with Sendmail, but has the same
4268 effect as &%-oep%&.
4269
4270 .cmdopt -oew
4271 .cindex "error" "reporting"
4272 This option is supported for compatibility with Sendmail, but has the same
4273 effect as &%-oem%&.
4274
4275 .cmdopt -oi
4276 .cindex "dot" "in incoming non-SMTP message"
4277 This option, which has the same effect as &%-i%&, specifies that a dot on a
4278 line by itself should not terminate an incoming, non-SMTP message. Otherwise, a
4279 single dot does terminate, though Exim does no special processing for other
4280 lines that start with a dot. This option is set by default if Exim is called as
4281 &'rmail'&. See also &%-ti%&.
4282
4283 .cmdopt -oitrue
4284 This option is treated as synonymous with &%-oi%&.
4285
4286 .cmdopt -oMa <&'host&~address'&>
4287 .cindex "sender" "host address, specifying for local message"
4288 A number of options starting with &%-oM%& can be used to set values associated
4289 with remote hosts on locally-submitted messages (that is, messages not received
4290 over TCP/IP). These options can be used by any caller in conjunction with the
4291 &%-bh%&, &%-be%&, &%-bf%&, &%-bF%&, &%-bt%&, or &%-bv%& testing options. In
4292 other circumstances, they are ignored unless the caller is trusted.
4293
4294 The &%-oMa%& option sets the sender host address. This may include a port
4295 number at the end, after a full stop (period). For example:
4296 .code
4297 exim -bs -oMa 10.9.8.7.1234
4298 .endd
4299 An alternative syntax is to enclose the IP address in square brackets,
4300 followed by a colon and the port number:
4301 .code
4302 exim -bs -oMa [10.9.8.7]:1234
4303 .endd
4304 The IP address is placed in the &$sender_host_address$& variable, and the
4305 port, if present, in &$sender_host_port$&. If both &%-oMa%& and &%-bh%&
4306 are present on the command line, the sender host IP address is taken from
4307 whichever one is last.
4308
4309 .cmdopt -oMaa <&'name'&>
4310 .cindex "authentication" "name, specifying for local message"
4311 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMaa%&
4312 option sets the value of &$sender_host_authenticated$& (the authenticator
4313 name). See chapter &<<CHAPSMTPAUTH>>& for a discussion of SMTP authentication.
4314 This option can be used with &%-bh%& and &%-bs%& to set up an
4315 authenticated SMTP session without actually using the SMTP AUTH command.
4316
4317 .cmdopt -oMai <&'string'&>
4318 .cindex "authentication" "id, specifying for local message"
4319 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMai%&
4320 option sets the value of &$authenticated_id$& (the id that was authenticated).
4321 This overrides the default value (the caller's login id, except with &%-bh%&,
4322 where there is no default) for messages from local sources. See chapter
4323 &<<CHAPSMTPAUTH>>& for a discussion of authenticated ids.
4324
4325 .cmdopt -oMas <&'address'&>
4326 .cindex "authentication" "sender, specifying for local message"
4327 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMas%&
4328 option sets the authenticated sender value in &$authenticated_sender$&. It
4329 overrides the sender address that is created from the caller's login id for
4330 messages from local sources, except when &%-bh%& is used, when there is no
4331 default. For both &%-bh%& and &%-bs%&, an authenticated sender that is
4332 specified on a MAIL command overrides this value. See chapter
4333 &<<CHAPSMTPAUTH>>& for a discussion of authenticated senders.
4334
4335 .cmdopt -oMi <&'interface&~address'&>
4336 .cindex "interface" "address, specifying for local message"
4337 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMi%&
4338 option sets the IP interface address value. A port number may be included,
4339 using the same syntax as for &%-oMa%&. The interface address is placed in
4340 &$received_ip_address$& and the port number, if present, in &$received_port$&.
4341
4342 .cmdopt -oMm <&'message&~reference'&>
4343 .cindex "message reference" "message reference, specifying for local message"
4344 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMm%&
4345 option sets the message reference, e.g. message-id, and is logged during
4346 delivery. This is useful when some kind of audit trail is required to tie
4347 messages together. The format of the message reference is checked and will
4348 abort if the format is invalid. The option will only be accepted if exim is
4349 running in trusted mode, not as any regular user.
4350
4351 The best example of a message reference is when Exim sends a bounce message.
4352 The message reference is the message-id of the original message for which Exim
4353 is sending the bounce.
4354
4355 .cmdopt -oMr <&'protocol&~name'&>
4356 .cindex "protocol, specifying for local message"
4357 .vindex "&$received_protocol$&"
4358 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMr%&
4359 option sets the received protocol value that is stored in
4360 &$received_protocol$&. However, it does not apply (and is ignored) when &%-bh%&
4361 or &%-bs%& is used. For &%-bh%&, the protocol is forced to one of the standard
4362 SMTP protocol names (see the description of &$received_protocol$& in section
4363 &<<SECTexpvar>>&). For &%-bs%&, the protocol is always &"local-"& followed by
4364 one of those same names. For &%-bS%& (batched SMTP) however, the protocol can
4365 be set by &%-oMr%&. Repeated use of this option is not supported.
4366
4367 .cmdopt -oMs <&'host&~name'&>
4368 .cindex "sender" "host name, specifying for local message"
4369 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMs%&
4370 option sets the sender host name in &$sender_host_name$&. When this option is
4371 present, Exim does not attempt to look up a host name from an IP address; it
4372 uses the name it is given.
4373
4374 .cmdopt -oMt <&'ident&~string'&>
4375 .cindex "sender" "ident string, specifying for local message"
4376 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMt%&
4377 option sets the sender ident value in &$sender_ident$&. The default setting for
4378 local callers is the login id of the calling process, except when &%-bh%& is
4379 used, when there is no default.
4380
4381 .cmdopt -om
4382 .cindex "Sendmail compatibility" "&%-om%& option ignored"
4383 In Sendmail, this option means &"me too"&, indicating that the sender of a
4384 message should receive a copy of the message if the sender appears in an alias
4385 expansion. Exim always does this, so the option does nothing.
4386
4387 .cmdopt -oo
4388 .cindex "Sendmail compatibility" "&%-oo%& option ignored"
4389 This option is ignored. In Sendmail it specifies &"old style headers"&,
4390 whatever that means.
4391
4392 .cmdopt -oP <&'path'&>
4393 .cindex "pid (process id)" "of daemon"
4394 .cindex "daemon" "process id (pid)"
4395 This option is useful only in conjunction with &%-bd%& or &%-q%& with a time
4396 value. The option specifies the file to which the process id of the daemon is
4397 written. When &%-oX%& is used with &%-bd%&, or when &%-q%& with a time is used
4398 without &%-bd%&, this is the only way of causing Exim to write a pid file,
4399 because in those cases, the normal pid file is not used.
4400
4401 .cmdopt -oPX
4402 .cindex "pid (process id)" "of daemon"
4403 .cindex "daemon" "process id (pid)"
4404 This option is not intended for general use.
4405 The daemon uses it when terminating due to a SIGTEM, possibly in
4406 combination with &%-oP%&&~<&'path'&>.
4407 It causes the pid file to be removed.
4408
4409 .cmdopt -or <&'time'&>
4410 .cindex "timeout" "for non-SMTP input"
4411 This option sets a timeout value for incoming non-SMTP messages. If it is not
4412 set, Exim will wait forever for the standard input. The value can also be set
4413 by the &%receive_timeout%& option. The format used for specifying times is
4414 described in section &<<SECTtimeformat>>&.
4415
4416 .cmdopt -os <&'time'&>
4417 .cindex "timeout" "for SMTP input"
4418 .cindex "SMTP" "input timeout"
4419 This option sets a timeout value for incoming SMTP messages. The timeout
4420 applies to each SMTP command and block of data. The value can also be set by
4421 the &%smtp_receive_timeout%& option; it defaults to 5 minutes. The format used
4422 for specifying times is described in section &<<SECTtimeformat>>&.
4423
4424 .cmdopt -ov
4425 This option has exactly the same effect as &%-v%&.
4426
4427 .cmdopt -oX <&'number&~or&~string'&>
4428 .cindex "TCP/IP" "setting listening ports"
4429 .cindex "TCP/IP" "setting listening interfaces"
4430 .cindex "port" "receiving TCP/IP"
4431 This option is relevant only when the &%-bd%& (start listening daemon) option
4432 is also given. It controls which ports and interfaces the daemon uses. Details
4433 of the syntax, and how it interacts with configuration file options, are given
4434 in chapter &<<CHAPinterfaces>>&. When &%-oX%& is used to start a daemon, no pid
4435 file is written unless &%-oP%& is also present to specify a pid filename.
4436
4437 .cmdopt -oY
4438 .cindex "daemon notifier socket"
4439 This option controls the creation of an inter-process communications endpoint
4440 by the Exim daemon.
4441 It is only relevant when the &%-bd%& (start listening daemon) option is also
4442 given.
4443 Normally the daemon creates this socket, unless a &%-oX%& and &*no*& &%-oP%&
4444 option is also present.
4445 If this option is given then the socket will not be created.  This is required
4446 if the system is running multiple daemons, in which case it should
4447 be used on all.
4448 The features supported by the socket will not be available in such cases.
4449
4450 The socket is currently used for
4451 .ilist
4452 fast ramp-up of queue runner processes
4453 .next
4454 caching compiled regexes
4455 .next
4456 obtaining a current queue size
4457 .endlist
4458
4459 .cmdopt -pd
4460 .cindex "Perl" "starting the interpreter"
4461 This option applies when an embedded Perl interpreter is linked with Exim (see
4462 chapter &<<CHAPperl>>&). It overrides the setting of the &%perl_at_start%&
4463 option, forcing the starting of the interpreter to be delayed until it is
4464 needed.
4465
4466 .cmdopt -ps
4467 .cindex "Perl" "starting the interpreter"
4468 This option applies when an embedded Perl interpreter is linked with Exim (see
4469 chapter &<<CHAPperl>>&). It overrides the setting of the &%perl_at_start%&
4470 option, forcing the starting of the interpreter to occur as soon as Exim is
4471 started.
4472
4473 .vitem &%-p%&<&'rval'&>:<&'sval'&>
4474 .oindex "&%-p%&"
4475 For compatibility with Sendmail, this option is equivalent to
4476 .display
4477 &`-oMr`& <&'rval'&> &`-oMs`& <&'sval'&>
4478 .endd
4479 It sets the incoming protocol and host name (for trusted callers). The
4480 host name and its colon can be omitted when only the protocol is to be set.
4481 Note the Exim already has two private options, &%-pd%& and &%-ps%&, that refer
4482 to embedded Perl. It is therefore impossible to set a protocol value of &`d`&
4483 or &`s`& using this option (but that does not seem a real limitation).
4484 Repeated use of this option is not supported.
4485
4486 .cmdopt -q
4487 .cindex "queue runner" "starting manually"
4488 This option is normally restricted to admin users. However, there is a
4489 configuration option called &%prod_requires_admin%& which can be set false to
4490 relax this restriction (and also the same requirement for the &%-M%&, &%-R%&,
4491 and &%-S%& options).
4492
4493 .cindex "queue runner" "description of operation"
4494 If other commandline options do not specify an action,
4495 the &%-q%& option starts one queue runner process. This scans the queue of
4496 waiting messages, and runs a delivery process for each one in turn. It waits
4497 for each delivery process to finish before starting the next one. A delivery
4498 process may not actually do any deliveries if the retry times for the addresses
4499 have not been reached. Use &%-qf%& (see below) if you want to override this.
4500
4501 If
4502 .cindex "SMTP" "passed connection"
4503 .cindex "SMTP" "multiple deliveries"
4504 .cindex "multiple SMTP deliveries"
4505 the delivery process spawns other processes to deliver other messages down
4506 passed SMTP connections, the queue runner waits for these to finish before
4507 proceeding.
4508
4509 When all the queued messages have been considered, the original queue runner
4510 process terminates. In other words, a single pass is made over the waiting
4511 mail, one message at a time. Use &%-q%& with a time (see below) if you want
4512 this to be repeated periodically.
4513
4514 Exim processes the waiting messages in an unpredictable order. It isn't very
4515 random, but it is likely to be different each time, which is all that matters.
4516 If one particular message screws up a remote MTA, other messages to the same
4517 MTA have a chance of getting through if they get tried first.
4518
4519 It is possible to cause the messages to be processed in lexical message id
4520 order, which is essentially the order in which they arrived, by setting the
4521 &%queue_run_in_order%& option, but this is not recommended for normal use.
4522
4523 .vitem &%-q%&<&'qflags'&>
4524 The &%-q%& option may be followed by one or more flag letters that change its
4525 behaviour. They are all optional, but if more than one is present, they must
4526 appear in the correct order. Each flag is described in a separate item below.
4527
4528 .vitem &%-qq...%&
4529 .oindex "&%-qq%&"
4530 .cindex "queue" "double scanning"
4531 .cindex "queue" "routing"
4532 .cindex "routing" "whole queue before delivery"
4533 .cindex "first pass routing"
4534 .cindex "queue runner" "two phase"
4535 An option starting with &%-qq%& requests a two-stage queue run. In the first
4536 stage, the queue is scanned as if the &%queue_smtp_domains%& option matched
4537 every domain. Addresses are routed, local deliveries happen, but no remote
4538 transports are run.
4539
4540 Performance will be best if the &%queue_run_in_order%& option is false.
4541 If that is so and
4542 the &%queue_fast_ramp%& option is true
4543 and a daemon-notifier socket is available
4544 then in the first phase of the run,
4545 once a threshold number of messages are routed for a given host,
4546 a delivery process is forked in parallel with the rest of the scan.
4547
4548 .cindex "hints database" "remembering routing"
4549 The hints database that remembers which messages are waiting for specific hosts
4550 is updated, as if delivery to those hosts had been deferred.
4551
4552 After the first queue scan complete,
4553 a second, normal queue scan is done, with routing and delivery taking
4554 place as normal.
4555 Messages that are routed to the same host should mostly be
4556 delivered down a single SMTP
4557 .cindex "SMTP" "passed connection"
4558 .cindex "SMTP" "multiple deliveries"
4559 .cindex "multiple SMTP deliveries"
4560 connection because of the hints that were set up during the first queue scan.
4561
4562 Two-phase queue runs should be used on systems which, even intermittently,
4563 have a large queue (such as mailing-list operators).
4564 They may also be useful for hosts that are connected to the Internet
4565 intermittently.
4566
4567 .vitem &%-q[q]i...%&
4568 .oindex "&%-qi%&"
4569 .cindex "queue" "initial delivery"
4570 If the &'i'& flag is present, the queue runner runs delivery processes only for
4571 those messages that haven't previously been tried. (&'i'& stands for &"initial
4572 delivery"&.) This can be helpful if you are putting messages in the queue using
4573 &%-odq%& and want a queue runner just to process the new messages.
4574
4575 .vitem &%-q[q][i]f...%&
4576 .oindex "&%-qf%&"
4577 .cindex "queue" "forcing delivery"
4578 .cindex "delivery" "forcing in queue run"
4579 If one &'f'& flag is present, a delivery attempt is forced for each non-frozen
4580 message, whereas without &'f'& only those non-frozen addresses that have passed
4581 their retry times are tried.
4582
4583 .vitem &%-q[q][i]ff...%&
4584 .oindex "&%-qff%&"
4585 .cindex "frozen messages" "forcing delivery"
4586 If &'ff'& is present, a delivery attempt is forced for every message, whether
4587 frozen or not.
4588
4589 .vitem &%-q[q][i][f[f]]l%&
4590 .oindex "&%-ql%&"
4591 .cindex "queue" "local deliveries only"
4592 The &'l'& (the letter &"ell"&) flag specifies that only local deliveries are to
4593 be done. If a message requires any remote deliveries, it remains in the queue
4594 for later delivery.
4595
4596 .vitem &%-q[q][i][f[f]][l][G<name>[/<time>]]]%&
4597 .oindex "&%-qG%&"
4598 .cindex queue named
4599 .cindex "named queues"  "deliver from"
4600 .cindex "queue" "delivering specific messages"
4601 If the &'G'& flag and a name is present, the queue runner operates on the
4602 queue with the given name rather than the default queue.
4603 The name should not contain a &'/'& character.
4604 For a periodic queue run (see below)
4605 append to the name a slash and a time value.
4606
4607 If other commandline options specify an action, a &'-qG<name>'& option
4608 will specify a queue to operate on.
4609 For example:
4610 .code
4611 exim -bp -qGquarantine
4612 mailq -qGquarantine
4613 exim -qGoffpeak -Rf @special.domain.example
4614 .endd
4615
4616 .vitem &%-q%&<&'qflags'&>&~<&'start&~id'&>&~<&'end&~id'&>
4617 When scanning the queue, Exim can be made to skip over messages whose ids are
4618 lexically less than a given value by following the &%-q%& option with a
4619 starting message id. For example:
4620 .code
4621 exim -q 0t5C6f-0000c8-00
4622 .endd
4623 Messages that arrived earlier than &`0t5C6f-0000c8-00`& are not inspected. If a
4624 second message id is given, messages whose ids are lexically greater than it
4625 are also skipped. If the same id is given twice, for example,
4626 .code
4627 exim -q 0t5C6f-0000c8-00 0t5C6f-0000c8-00
4628 .endd
4629 just one delivery process is started, for that message. This differs from
4630 &%-M%& in that retry data is respected, and it also differs from &%-Mc%& in
4631 that it counts as a delivery from a queue run. Note that the selection
4632 mechanism does not affect the order in which the messages are scanned. There
4633 are also other ways of selecting specific sets of messages for delivery in a
4634 queue run &-- see &%-R%& and &%-S%&.
4635
4636 .vitem &%-q%&<&'qflags'&><&'time'&>
4637 .cindex "queue runner" "starting periodically"
4638 .cindex "periodic queue running"
4639 When a time value is present, the &%-q%& option causes Exim to run as a daemon,
4640 starting a queue runner process at intervals specified by the given time value
4641 (whose format is described in section &<<SECTtimeformat>>&). This form of the
4642 &%-q%& option is commonly combined with the &%-bd%& option, in which case a
4643 single daemon process handles both functions. A common way of starting up a
4644 combined daemon at system boot time is to use a command such as
4645 .code
4646 /usr/exim/bin/exim -bd -q30m
4647 .endd
4648 Such a daemon listens for incoming SMTP calls, and also starts a queue runner
4649 process every 30 minutes.
4650
4651 .cindex "named queues" "queue runners"
4652 It is possible to set up runners for multiple named queues within one daemon,
4653 For example:
4654 .code
4655 exim -qGhipri/2m -q10m -qqGmailinglist/1h
4656 .endd
4657
4658 When a daemon is started by &%-q%& with a time value, but without &%-bd%&, no
4659 pid file is written unless one is explicitly requested by the &%-oP%& option.
4660
4661 .vitem &%-qR%&<&'rsflags'&>&~<&'string'&>
4662 .oindex "&%-qR%&"
4663 This option is synonymous with &%-R%&. It is provided for Sendmail
4664 compatibility.
4665
4666 .vitem &%-qS%&<&'rsflags'&>&~<&'string'&>
4667 .oindex "&%-qS%&"
4668 This option is synonymous with &%-S%&.
4669
4670 .vitem &%-R%&<&'rsflags'&>&~<&'string'&>
4671 .oindex "&%-R%&"
4672 .cindex "queue runner" "for specific recipients"
4673 .cindex "delivery" "to given domain"
4674 .cindex "domain" "delivery to"
4675 The <&'rsflags'&> may be empty, in which case the white space before the string
4676 is optional, unless the string is &'f'&, &'ff'&, &'r'&, &'rf'&, or &'rff'&,
4677 which are the possible values for <&'rsflags'&>. White space is required if
4678 <&'rsflags'&> is not empty.
4679
4680 This option is similar to &%-q%& with no time value, that is, it causes Exim to
4681 perform a single queue run, except that, when scanning the messages on the
4682 queue, Exim processes only those that have at least one undelivered recipient
4683 address containing the given string, which is checked in a case-independent
4684 way. If the <&'rsflags'&> start with &'r'&, <&'string'&> is interpreted as a
4685 regular expression; otherwise it is a literal string.
4686
4687 If you want to do periodic queue runs for messages with specific recipients,
4688 you can combine &%-R%& with &%-q%& and a time value. For example:
4689 .code
4690 exim -q25m -R @special.domain.example
4691 .endd
4692 This example does a queue run for messages with recipients in the given domain
4693 every 25 minutes. Any additional flags that are specified with &%-q%& are
4694 applied to each queue run.
4695
4696 Once a message is selected for delivery by this mechanism, all its addresses
4697 are processed. For the first selected message, Exim overrides any retry
4698 information and forces a delivery attempt for each undelivered address. This
4699 means that if delivery of any address in the first message is successful, any
4700 existing retry information is deleted, and so delivery attempts for that
4701 address in subsequently selected messages (which are processed without forcing)
4702 will run. However, if delivery of any address does not succeed, the retry
4703 information is updated, and in subsequently selected messages, the failing
4704 address will be skipped.
4705
4706 .cindex "frozen messages" "forcing delivery"
4707 If the <&'rsflags'&> contain &'f'& or &'ff'&, the delivery forcing applies to
4708 all selected messages, not just the first; frozen messages are included when
4709 &'ff'& is present.
4710
4711 The &%-R%& option makes it straightforward to initiate delivery of all messages
4712 to a given domain after a host has been down for some time. When the SMTP
4713 command ETRN is accepted by its ACL (see chapter &<<CHAPACL>>&), its default
4714 effect is to run Exim with the &%-R%& option, but it can be configured to run
4715 an arbitrary command instead.
4716
4717 .cmdopt -r
4718 This is a documented (for Sendmail) obsolete alternative name for &%-f%&.
4719
4720 .vitem &%-S%&<&'rsflags'&>&~<&'string'&>
4721 .oindex "&%-S%&"
4722 .cindex "delivery" "from given sender"
4723 .cindex "queue runner" "for specific senders"
4724 This option acts like &%-R%& except that it checks the string against each
4725 message's sender instead of against the recipients. If &%-R%& is also set, both
4726 conditions must be met for a message to be selected. If either of the options
4727 has &'f'& or &'ff'& in its flags, the associated action is taken.
4728
4729 .cmdopt -Tqt <&'times'&>
4730 This is an option that is exclusively for use by the Exim testing suite. It is not
4731 recognized when Exim is run normally. It allows for the setting up of explicit
4732 &"queue times"& so that various warning/retry features can be tested.
4733
4734 .cmdopt -t
4735 .cindex "recipient" "extracting from header lines"
4736 .chindex Bcc:
4737 .chindex Cc:
4738 .chindex To:
4739 When Exim is receiving a locally-generated, non-SMTP message on its standard
4740 input, the &%-t%& option causes the recipients of the message to be obtained
4741 from the &'To:'&, &'Cc:'&, and &'Bcc:'& header lines in the message instead of
4742 from the command arguments. The addresses are extracted before any rewriting
4743 takes place and the &'Bcc:'& header line, if present, is then removed.
4744
4745 .cindex "Sendmail compatibility" "&%-t%& option"
4746 If the command has any arguments, they specify addresses to which the message
4747 is &'not'& to be delivered. That is, the argument addresses are removed from
4748 the recipients list obtained from the headers. This is compatible with Smail 3
4749 and in accordance with the documented behaviour of several versions of
4750 Sendmail, as described in man pages on a number of operating systems (e.g.
4751 Solaris 8, IRIX 6.5, HP-UX 11). However, some versions of Sendmail &'add'&
4752 argument addresses to those obtained from the headers, and the O'Reilly
4753 Sendmail book documents it that way. Exim can be made to add argument addresses
4754 instead of subtracting them by setting the option
4755 &%extract_addresses_remove_arguments%& false.
4756
4757 .cindex "&%Resent-%& header lines" "with &%-t%&"
4758 If there are any &%Resent-%& header lines in the message, Exim extracts
4759 recipients from all &'Resent-To:'&, &'Resent-Cc:'&, and &'Resent-Bcc:'& header
4760 lines instead of from &'To:'&, &'Cc:'&, and &'Bcc:'&. This is for compatibility
4761 with Sendmail and other MTAs. (Prior to release 4.20, Exim gave an error if
4762 &%-t%& was used in conjunction with &%Resent-%& header lines.)
4763
4764 RFC 2822 talks about different sets of &%Resent-%& header lines (for when a
4765 message is resent several times). The RFC also specifies that they should be
4766 added at the front of the message, and separated by &'Received:'& lines. It is
4767 not at all clear how &%-t%& should operate in the present of multiple sets,
4768 nor indeed exactly what constitutes a &"set"&.
4769 In practice, it seems that MUAs do not follow the RFC. The &%Resent-%& lines
4770 are often added at the end of the header, and if a message is resent more than
4771 once, it is common for the original set of &%Resent-%& headers to be renamed as
4772 &%X-Resent-%& when a new set is added. This removes any possible ambiguity.
4773
4774 .cmdopt -ti
4775 This option is exactly equivalent to &%-t%& &%-i%&. It is provided for
4776 compatibility with Sendmail.
4777
4778 .cmdopt -tls-on-connect
4779 .cindex "TLS" "use without STARTTLS"
4780 .cindex "TLS" "automatic start"
4781 This option is available when Exim is compiled with TLS support. It forces all
4782 incoming SMTP connections to behave as if the incoming port is listed in the
4783 &%tls_on_connect_ports%& option. See section &<<SECTsupobssmt>>& and chapter
4784 &<<CHAPTLS>>& for further details.
4785
4786
4787 .cmdopt -U
4788 .cindex "Sendmail compatibility" "&%-U%& option ignored"
4789 Sendmail uses this option for &"initial message submission"&, and its
4790 documentation states that in future releases, it may complain about
4791 syntactically invalid messages rather than fixing them when this flag is not
4792 set. Exim ignores this option.
4793
4794 .cmdopt -v
4795 This option causes Exim to write information to the standard error stream,
4796 describing what it is doing. In particular, it shows the log lines for
4797 receiving and delivering a message, and if an SMTP connection is made, the SMTP
4798 dialogue is shown. Some of the log lines shown may not actually be written to
4799 the log if the setting of &%log_selector%& discards them. Any relevant
4800 selectors are shown with each log line. If none are shown, the logging is
4801 unconditional.
4802
4803 .cmdopt -x
4804 AIX uses &%-x%& for a private purpose (&"mail from a local mail program has
4805 National Language Support extended characters in the body of the mail item"&).
4806 It sets &%-x%& when calling the MTA from its &%mail%& command. Exim ignores
4807 this option.
4808
4809 .cmdopt -X <&'logfile'&>
4810 This option is interpreted by Sendmail to cause debug information to be sent
4811 to the named file.  It is ignored by Exim.
4812
4813 .cmdopt -z <&'log-line'&>
4814 This option writes its argument to Exim's logfile.
4815 Use is restricted to administrators; the intent is for operational notes.
4816 Quotes should be used to maintain a multi-word item as a single argument,
4817 under most shells.
4818 .endlist
4819
4820 .ecindex IIDclo1
4821 .ecindex IIDclo2
4822
4823
4824 . ////////////////////////////////////////////////////////////////////////////
4825 . Insert a stylized DocBook comment here, to identify the end of the command
4826 . line options. This is for the benefit of the Perl script that automatically
4827 . creates a man page for the options.
4828 . ////////////////////////////////////////////////////////////////////////////
4829
4830 .literal xml
4831 <!-- === End of command line options === -->
4832 .literal off
4833
4834
4835
4836
4837
4838 . ////////////////////////////////////////////////////////////////////////////
4839 . ////////////////////////////////////////////////////////////////////////////
4840
4841
4842 .chapter "The Exim runtime configuration file" "CHAPconf" &&&
4843          "The runtime configuration file"
4844
4845 .cindex "runtime configuration"
4846 .cindex "configuration file" "general description"
4847 .cindex "CONFIGURE_FILE"
4848 .cindex "configuration file" "errors in"
4849 .cindex "error" "in configuration file"
4850 .cindex "return code" "for bad configuration"
4851 Exim uses a single runtime configuration file that is read whenever an Exim
4852 binary is executed. Note that in normal operation, this happens frequently,
4853 because Exim is designed to operate in a distributed manner, without central
4854 control.
4855
4856 If a syntax error is detected while reading the configuration file, Exim
4857 writes a message on the standard error, and exits with a non-zero return code.
4858 The message is also written to the panic log. &*Note*&: Only simple syntax
4859 errors can be detected at this time. The values of any expanded options are
4860 not checked until the expansion happens, even when the expansion does not
4861 actually alter the string.
4862
4863 The name of the configuration file is compiled into the binary for security
4864 reasons, and is specified by the CONFIGURE_FILE compilation option. In
4865 most configurations, this specifies a single file. However, it is permitted to
4866 give a colon-separated list of filenames, in which case Exim uses the first
4867 existing file in the list.
4868
4869 .cindex "EXIM_USER"
4870 .cindex "EXIM_GROUP"
4871 .cindex "CONFIGURE_OWNER"
4872 .cindex "CONFIGURE_GROUP"
4873 .cindex "configuration file" "ownership"
4874 .cindex "ownership" "configuration file"
4875 The runtime configuration file must be owned by root or by the user that is
4876 specified at compile time by the CONFIGURE_OWNER option (if set). The
4877 configuration file must not be world-writeable, or group-writeable unless its
4878 group is the root group or the one specified at compile time by the
4879 CONFIGURE_GROUP option.
4880
4881 &*Warning*&: In a conventional configuration, where the Exim binary is setuid
4882 to root, anybody who is able to edit the runtime configuration file has an
4883 easy way to run commands as root. If you specify a user or group in the
4884 CONFIGURE_OWNER or CONFIGURE_GROUP options, then that user and/or any users
4885 who are members of that group will trivially be able to obtain root privileges.
4886
4887 Up to Exim version 4.72, the runtime configuration file was also permitted to
4888 be writeable by the Exim user and/or group. That has been changed in Exim 4.73
4889 since it offered a simple privilege escalation for any attacker who managed to
4890 compromise the Exim user account.
4891
4892 A default configuration file, which will work correctly in simple situations,
4893 is provided in the file &_src/configure.default_&. If CONFIGURE_FILE
4894 defines just one filename, the installation process copies the default
4895 configuration to a new file of that name if it did not previously exist. If
4896 CONFIGURE_FILE is a list, no default is automatically installed. Chapter
4897 &<<CHAPdefconfil>>& is a &"walk-through"& discussion of the default
4898 configuration.
4899
4900
4901
4902 .section "Using a different configuration file" "SECID40"
4903 .cindex "configuration file" "alternate"
4904 A one-off alternate configuration can be specified by the &%-C%& command line
4905 option, which may specify a single file or a list of files. However, when
4906 &%-C%& is used, Exim gives up its root privilege, unless called by root (or
4907 unless the argument for &%-C%& is identical to the built-in value from
4908 CONFIGURE_FILE), or is listed in the TRUSTED_CONFIG_LIST file and the caller
4909 is the Exim user or the user specified in the CONFIGURE_OWNER setting. &%-C%&
4910 is useful mainly for checking the syntax of configuration files before
4911 installing them. No owner or group checks are done on a configuration file
4912 specified by &%-C%&, if root privilege has been dropped.
4913
4914 Even the Exim user is not trusted to specify an arbitrary configuration file
4915 with the &%-C%& option to be used with root privileges, unless that file is
4916 listed in the TRUSTED_CONFIG_LIST file. This locks out the possibility of
4917 testing a configuration using &%-C%& right through message reception and
4918 delivery, even if the caller is root. The reception works, but by that time,
4919 Exim is running as the Exim user, so when it re-execs to regain privilege for
4920 the delivery, the use of &%-C%& causes privilege to be lost. However, root
4921 can test reception and delivery using two separate commands (one to put a
4922 message in the queue, using &%-odq%&, and another to do the delivery, using
4923 &%-M%&).
4924
4925 If ALT_CONFIG_PREFIX is defined &_in Local/Makefile_&, it specifies a
4926 prefix string with which any file named in a &%-C%& command line option must
4927 start. In addition, the filename must not contain the sequence &"&`/../`&"&.
4928 There is no default setting for ALT_CONFIG_PREFIX; when it is unset, any
4929 filename can be used with &%-C%&.
4930
4931 One-off changes to a configuration can be specified by the &%-D%& command line
4932 option, which defines and overrides values for macros used inside the
4933 configuration file. However, like &%-C%&, the use of this option by a
4934 non-privileged user causes Exim to discard its root privilege.
4935 If DISABLE_D_OPTION is defined in &_Local/Makefile_&, the use of &%-D%& is
4936 completely disabled, and its use causes an immediate error exit.
4937
4938 The WHITELIST_D_MACROS option in &_Local/Makefile_& permits the binary builder
4939 to declare certain macro names trusted, such that root privilege will not
4940 necessarily be discarded.
4941 WHITELIST_D_MACROS defines a colon-separated list of macros which are
4942 considered safe and, if &%-D%& only supplies macros from this list, and the
4943 values are acceptable, then Exim will not give up root privilege if the caller
4944 is root, the Exim run-time user, or the CONFIGURE_OWNER, if set.  This is a
4945 transition mechanism and is expected to be removed in the future.  Acceptable
4946 values for the macros satisfy the regexp: &`^[A-Za-z0-9_/.-]*$`&
4947
4948 Some sites may wish to use the same Exim binary on different machines that
4949 share a file system, but to use different configuration files on each machine.
4950 If CONFIGURE_FILE_USE_NODE is defined in &_Local/Makefile_&, Exim first
4951 looks for a file whose name is the configuration filename followed by a dot
4952 and the machine's node name, as obtained from the &[uname()]& function. If this
4953 file does not exist, the standard name is tried. This processing occurs for
4954 each filename in the list given by CONFIGURE_FILE or &%-C%&.
4955
4956 In some esoteric situations different versions of Exim may be run under
4957 different effective uids and the CONFIGURE_FILE_USE_EUID is defined to
4958 help with this. See the comments in &_src/EDITME_& for details.
4959
4960
4961
4962 .section "Configuration file format" "SECTconffilfor"
4963 .cindex "configuration file" "format of"
4964 .cindex "format" "configuration file"
4965 Exim's configuration file is divided into a number of different parts. General
4966 option settings must always appear at the start of the file. The other parts
4967 are all optional, and may appear in any order. Each part other than the first
4968 is introduced by the word &"begin"& followed by at least one literal
4969 space, and the name of the part. The optional parts are:
4970
4971 .ilist
4972 &'ACL'&: Access control lists for controlling incoming SMTP mail (see chapter
4973 &<<CHAPACL>>&).
4974 .next
4975 .cindex "AUTH" "configuration"
4976 &'authenticators'&: Configuration settings for the authenticator drivers. These
4977 are concerned with the SMTP AUTH command (see chapter &<<CHAPSMTPAUTH>>&).
4978 .next
4979 &'routers'&: Configuration settings for the router drivers. Routers process
4980 addresses and determine how the message is to be delivered (see chapters
4981 &<<CHAProutergeneric>>&&--&<<CHAPredirect>>&).
4982 .next
4983 &'transports'&: Configuration settings for the transport drivers. Transports
4984 define mechanisms for copying messages to destinations (see chapters
4985 &<<CHAPtransportgeneric>>&&--&<<CHAPsmtptrans>>&).
4986 .next
4987 &'retry'&: Retry rules, for use when a message cannot be delivered immediately.
4988 If there is no retry section, or if it is empty (that is, no retry rules are
4989 defined), Exim will not retry deliveries. In this situation, temporary errors
4990 are treated the same as permanent errors. Retry rules are discussed in chapter
4991 &<<CHAPretry>>&.
4992 .next
4993 &'rewrite'&: Global address rewriting rules, for use when a message arrives and
4994 when new addresses are generated during delivery. Rewriting is discussed in
4995 chapter &<<CHAPrewrite>>&.
4996 .next
4997 &'local_scan'&: Private options for the &[local_scan()]& function. If you
4998 want to use this feature, you must set
4999 .code
5000 LOCAL_SCAN_HAS_OPTIONS=yes
5001 .endd
5002 in &_Local/Makefile_& before building Exim. Details of the &[local_scan()]&
5003 facility are given in chapter &<<CHAPlocalscan>>&.
5004 .endlist
5005
5006 .cindex "configuration file" "leading white space in"
5007 .cindex "configuration file" "trailing white space in"
5008 .cindex "white space" "in configuration file"
5009 Leading and trailing white space in configuration lines is always ignored.
5010
5011 Blank lines in the file, and lines starting with a # character (ignoring
5012 leading white space) are treated as comments and are ignored. &*Note*&: A
5013 # character other than at the beginning of a line is not treated specially,
5014 and does not introduce a comment.
5015
5016 Any non-comment line can be continued by ending it with a backslash. Note that
5017 the general rule for white space means that trailing white space after the
5018 backslash and leading white space at the start of continuation
5019 lines is ignored. Comment lines beginning with # (but not empty lines) may
5020 appear in the middle of a sequence of continuation lines.
5021
5022 A convenient way to create a configuration file is to start from the
5023 default, which is supplied in &_src/configure.default_&, and add, delete, or
5024 change settings as required.
5025
5026 The ACLs, retry rules, and rewriting rules have their own syntax which is
5027 described in chapters &<<CHAPACL>>&, &<<CHAPretry>>&, and &<<CHAPrewrite>>&,
5028 respectively. The other parts of the configuration file have some syntactic
5029 items in common, and these are described below, from section &<<SECTcos>>&
5030 onwards. Before that, the inclusion, macro, and conditional facilities are
5031 described.
5032
5033
5034
5035 .section "File inclusions in the configuration file" "SECID41"
5036 .cindex "inclusions in configuration file"
5037 .cindex "configuration file" "including other files"
5038 .cindex "&`.include`& in configuration file"
5039 .cindex "&`.include_if_exists`& in configuration file"
5040 You can include other files inside Exim's runtime configuration file by
5041 using this syntax:
5042 .display
5043 &`.include`& <&'filename'&>
5044 &`.include_if_exists`& <&'filename'&>
5045 .endd
5046 on a line by itself. Double quotes round the filename are optional. If you use
5047 the first form, a configuration error occurs if the file does not exist; the
5048 second form does nothing for non-existent files.
5049 The first form allows a relative name. It is resolved relative to
5050 the directory of the including file. For the second form an absolute filename
5051 is required.
5052
5053 Includes may be nested to any depth, but remember that Exim reads its
5054 configuration file often, so it is a good idea to keep them to a minimum.
5055 If you change the contents of an included file, you must HUP the daemon,
5056 because an included file is read only when the configuration itself is read.
5057
5058 The processing of inclusions happens early, at a physical line level, so, like
5059 comment lines, an inclusion can be used in the middle of an option setting,
5060 for example:
5061 .code
5062 hosts_lookup = a.b.c \
5063                .include /some/file
5064 .endd
5065 Include processing happens after macro processing (see below). Its effect is to
5066 process the lines of the included file as if they occurred inline where the
5067 inclusion appears.
5068
5069
5070
5071 .section "Macros in the configuration file" "SECTmacrodefs"
5072 .cindex "macro" "description of"
5073 .cindex "configuration file" "macros"
5074 If a line in the main part of the configuration (that is, before the first
5075 &"begin"& line) begins with an upper case letter, it is taken as a macro
5076 definition, and must be of the form
5077 .display
5078 <&'name'&> = <&'rest of line'&>
5079 .endd
5080 The name must consist of letters, digits, and underscores, and need not all be
5081 in upper case, though that is recommended. The rest of the line, including any
5082 continuations, is the replacement text, and has leading and trailing white
5083 space removed. Quotes are not removed. The replacement text can never end with
5084 a backslash character, but this doesn't seem to be a serious limitation.
5085
5086 Macros may also be defined between router, transport, authenticator, or ACL
5087 definitions. They may not, however, be defined within an individual driver or
5088 ACL, or in the &%local_scan%&, retry, or rewrite sections of the configuration.
5089
5090 .section "Macro substitution" "SECID42"
5091 Once a macro is defined, all subsequent lines in the file (and any included
5092 files) are scanned for the macro name; if there are several macros, the line is
5093 scanned for each, in turn, in the order in which the macros are defined. The
5094 replacement text is not re-scanned for the current macro, though it is scanned
5095 for subsequently defined macros. For this reason, a macro name may not contain
5096 the name of a previously defined macro as a substring. You could, for example,
5097 define
5098 .display
5099 &`ABCD_XYZ = `&<&'something'&>
5100 &`ABCD = `&<&'something else'&>
5101 .endd
5102 but putting the definitions in the opposite order would provoke a configuration
5103 error. Macro expansion is applied to individual physical lines from the file,
5104 before checking for line continuation or file inclusion (see above). If a line
5105 consists solely of a macro name, and the expansion of the macro is empty, the
5106 line is ignored. A macro at the start of a line may turn the line into a
5107 comment line or a &`.include`& line.
5108
5109
5110 .section "Redefining macros" "SECID43"
5111 Once defined, the value of a macro can be redefined later in the configuration
5112 (or in an included file). Redefinition is specified by using &'=='& instead of
5113 &'='&. For example:
5114 .code
5115 MAC =  initial value
5116 ...
5117 MAC == updated value
5118 .endd
5119 Redefinition does not alter the order in which the macros are applied to the
5120 subsequent lines of the configuration file. It is still the same order in which
5121 the macros were originally defined. All that changes is the macro's value.
5122 Redefinition makes it possible to accumulate values. For example:
5123 .code
5124 MAC =  initial value
5125 ...
5126 MAC == MAC and something added
5127 .endd
5128 This can be helpful in situations where the configuration file is built
5129 from a number of other files.
5130
5131 .section "Overriding macro values" "SECID44"
5132 The values set for macros in the configuration file can be overridden by the
5133 &%-D%& command line option, but Exim gives up its root privilege when &%-D%& is
5134 used, unless called by root or the Exim user. A definition on the command line
5135 using the &%-D%& option causes all definitions and redefinitions within the
5136 file to be ignored.
5137
5138
5139
5140 .section "Example of macro usage" "SECID45"
5141 As an example of macro usage, consider a configuration where aliases are looked
5142 up in a MySQL database. It helps to keep the file less cluttered if long
5143 strings such as SQL statements are defined separately as macros, for example:
5144 .code
5145 ALIAS_QUERY = select mailbox from user where \
5146               login='${quote_mysql:$local_part}';
5147 .endd
5148 This can then be used in a &(redirect)& router setting like this:
5149 .code
5150 data = ${lookup mysql{ALIAS_QUERY}}
5151 .endd
5152 In earlier versions of Exim macros were sometimes used for domain, host, or
5153 address lists. In Exim 4 these are handled better by named lists &-- see
5154 section &<<SECTnamedlists>>&.
5155
5156
5157 .section "Builtin macros" "SECTbuiltinmacros"
5158 Exim defines some macros depending on facilities available, which may
5159 differ due to build-time definitions and from one release to another.
5160 All of these macros start with an underscore.
5161 They can be used to conditionally include parts of a configuration
5162 (see below).
5163
5164 The following classes of macros are defined:
5165 .display
5166 &` _HAVE_*                    `&  build-time defines
5167 &` _DRIVER_ROUTER_*           `&  router drivers
5168 &` _DRIVER_TRANSPORT_*        `&  transport drivers
5169 &` _DRIVER_AUTHENTICATOR_*    `&  authenticator drivers
5170 &` _EXP_COND_*                `&  expansion conditions
5171 &` _EXP_ITEM_*                `&  expansion items
5172 &` _EXP_OP_*                  `&  expansion operators
5173 &` _EXP_VAR_*                 `&  expansion variables
5174 &` _LOG_*                     `&  log_selector values
5175 &` _OPT_MAIN_*                `&  main config options
5176 &` _OPT_ROUTERS_*             `&  generic router options
5177 &` _OPT_TRANSPORTS_*          `&  generic transport options
5178 &` _OPT_AUTHENTICATORS_*      `&  generic authenticator options
5179 &` _OPT_ROUTER_*_*            `&  private router options
5180 &` _OPT_TRANSPORT_*_*         `&  private transport options
5181 &` _OPT_AUTHENTICATOR_*_*     `&  private authenticator options
5182 .endd
5183
5184 Use an &"exim -bP macros"& command to get the list of macros.
5185
5186
5187 .section "Conditional skips in the configuration file" "SECID46"
5188 .cindex "configuration file" "conditional skips"
5189 .cindex "&`.ifdef`&"
5190 You can use the directives &`.ifdef`&, &`.ifndef`&, &`.elifdef`&,
5191 &`.elifndef`&, &`.else`&, and &`.endif`& to dynamically include or exclude
5192 portions of the configuration file. The processing happens whenever the file is
5193 read (that is, when an Exim binary starts to run).
5194
5195 The implementation is very simple. Instances of the first four directives must
5196 be followed by text that includes the names of one or macros. The condition
5197 that is tested is whether or not any macro substitution has taken place in the
5198 line. Thus:
5199 .code
5200 .ifdef AAA
5201 message_size_limit = 50M
5202 .else
5203 message_size_limit = 100M
5204 .endif
5205 .endd
5206 sets a message size limit of 50M if the macro &`AAA`& is defined
5207 (or &`A`& or &`AA`&), and 100M
5208 otherwise. If there is more than one macro named on the line, the condition
5209 is true if any of them are defined. That is, it is an &"or"& condition. To
5210 obtain an &"and"& condition, you need to use nested &`.ifdef`&s.
5211
5212 Although you can use a macro expansion to generate one of these directives,
5213 it is not very useful, because the condition &"there was a macro substitution
5214 in this line"& will always be true.
5215
5216 Text following &`.else`& and &`.endif`& is ignored, and can be used as comment
5217 to clarify complicated nestings.
5218
5219
5220
5221 .section "Common option syntax" "SECTcos"
5222 .cindex "common option syntax"
5223 .cindex "syntax of common options"
5224 .cindex "configuration file" "common option syntax"
5225 For the main set of options, driver options, and &[local_scan()]& options,
5226 each setting is on a line by itself, and starts with a name consisting of
5227 lower-case letters and underscores. Many options require a data value, and in
5228 these cases the name must be followed by an equals sign (with optional white
5229 space) and then the value. For example:
5230 .code
5231 qualify_domain = mydomain.example.com
5232 .endd
5233 .cindex "hiding configuration option values"
5234 .cindex "configuration options" "hiding value of"
5235 .cindex "options" "hiding value of"
5236 Some option settings may contain sensitive data, for example, passwords for
5237 accessing databases. To stop non-admin users from using the &%-bP%& command
5238 line option to read these values, you can precede the option settings with the
5239 word &"hide"&. For example:
5240 .code
5241 hide mysql_servers = localhost/users/admin/secret-password
5242 .endd
5243 For non-admin users, such options are displayed like this:
5244 .code
5245 mysql_servers = <value not displayable>
5246 .endd
5247 If &"hide"& is used on a driver option, it hides the value of that option on
5248 all instances of the same driver.
5249
5250 The following sections describe the syntax used for the different data types
5251 that are found in option settings.
5252
5253
5254 .section "Boolean options" "SECID47"
5255 .cindex "format" "boolean"
5256 .cindex "boolean configuration values"
5257 .oindex "&%no_%&&'xxx'&"
5258 .oindex "&%not_%&&'xxx'&"
5259 Options whose type is given as boolean are on/off switches. There are two
5260 different ways of specifying such options: with and without a data value. If
5261 the option name is specified on its own without data, the switch is turned on;
5262 if it is preceded by &"no_"& or &"not_"& the switch is turned off. However,
5263 boolean options may be followed by an equals sign and one of the words
5264 &"true"&, &"false"&, &"yes"&, or &"no"&, as an alternative syntax. For example,
5265 the following two settings have exactly the same effect:
5266 .code
5267 queue_only
5268 queue_only = true
5269 .endd
5270 The following two lines also have the same (opposite) effect:
5271 .code
5272 no_queue_only
5273 queue_only = false
5274 .endd
5275 You can use whichever syntax you prefer.
5276
5277
5278
5279
5280 .section "Integer values" "SECID48"
5281 .cindex "integer configuration values"
5282 .cindex "format" "integer"
5283 If an option's type is given as &"integer"&, the value can be given in decimal,
5284 hexadecimal, or octal. If it starts with a digit greater than zero, a decimal
5285 number is assumed. Otherwise, it is treated as an octal number unless it starts
5286 with the characters &"0x"&, in which case the remainder is interpreted as a
5287 hexadecimal number.
5288
5289 If an integer value is followed by the letter K, it is multiplied by 1024; if
5290 it is followed by the letter M, it is multiplied by 1024x1024;
5291 if by the letter G, 1024x1024x1024.
5292 When the values
5293 of integer option settings are output, values which are an exact multiple of
5294 1024 or 1024x1024 are sometimes, but not always, printed using the letters K
5295 and M. The printing style is independent of the actual input format that was
5296 used.
5297
5298
5299 .section "Octal integer values" "SECID49"
5300 .cindex "integer format"
5301 .cindex "format" "octal integer"
5302 If an option's type is given as &"octal integer"&, its value is always
5303 interpreted as an octal number, whether or not it starts with the digit zero.
5304 Such options are always output in octal.
5305
5306
5307 .section "Fixed point numbers" "SECID50"
5308 .cindex "fixed point configuration values"
5309 .cindex "format" "fixed point"
5310 If an option's type is given as &"fixed-point"&, its value must be a decimal
5311 integer, optionally followed by a decimal point and up to three further digits.
5312
5313
5314
5315 .section "Time intervals" "SECTtimeformat"
5316 .cindex "time interval" "specifying in configuration"
5317 .cindex "format" "time interval"
5318 A time interval is specified as a sequence of numbers, each followed by one of
5319 the following letters, with no intervening white space:
5320
5321 .table2 30pt
5322 .irow &%s%& seconds
5323 .irow &%m%& minutes
5324 .irow &%h%& hours
5325 .irow &%d%& days
5326 .irow &%w%& weeks
5327 .endtable
5328
5329 For example, &"3h50m"& specifies 3 hours and 50 minutes. The values of time
5330 intervals are output in the same format. Exim does not restrict the values; it
5331 is perfectly acceptable, for example, to specify &"90m"& instead of &"1h30m"&.
5332
5333
5334
5335 .section "String values" "SECTstrings"
5336 .cindex "string" "format of configuration values"
5337 .cindex "format" "string"
5338 If an option's type is specified as &"string"&, the value can be specified with
5339 or without double-quotes. If it does not start with a double-quote, the value
5340 consists of the remainder of the line plus any continuation lines, starting at
5341 the first character after any leading white space, with trailing white space
5342 removed, and with no interpretation of the characters in the string. Because
5343 Exim removes comment lines (those beginning with #) at an early stage, they can
5344 appear in the middle of a multi-line string. The following two settings are
5345 therefore equivalent:
5346 .code
5347 trusted_users = uucp:mail
5348 trusted_users = uucp:\
5349                 # This comment line is ignored
5350                 mail
5351 .endd
5352 .cindex "string" "quoted"
5353 .cindex "escape characters in quoted strings"
5354 If a string does start with a double-quote, it must end with a closing
5355 double-quote, and any backslash characters other than those used for line
5356 continuation are interpreted as escape characters, as follows:
5357
5358 .table2 100pt
5359 .irow &`\\`&                     "single backslash"
5360 .irow &`\n`&                     "newline"
5361 .irow &`\r`&                     "carriage return"
5362 .irow &`\t`&                     "tab"
5363 .irow "&`\`&<&'octal digits'&>"  "up to 3 octal digits specify one character"
5364 .irow "&`\x`&<&'hex digits'&>"   "up to 2 hexadecimal digits specify one &&&
5365                                    character"
5366 .endtable
5367
5368 If a backslash is followed by some other character, including a double-quote
5369 character, that character replaces the pair.
5370
5371 Quoting is necessary only if you want to make use of the backslash escapes to
5372 insert special characters, or if you need to specify a value with leading or
5373 trailing spaces. These cases are rare, so quoting is almost never needed in
5374 current versions of Exim. In versions of Exim before 3.14, quoting was required
5375 in order to continue lines, so you may come across older configuration files
5376 and examples that apparently quote unnecessarily.
5377
5378
5379 .section "Expanded strings" "SECID51"
5380 .cindex "expansion" "definition of"
5381 Some strings in the configuration file are subjected to &'string expansion'&,
5382 by which means various parts of the string may be changed according to the
5383 circumstances (see chapter &<<CHAPexpand>>&). The input syntax for such strings
5384 is as just described; in particular, the handling of backslashes in quoted
5385 strings is done as part of the input process, before expansion takes place.
5386 However, backslash is also an escape character for the expander, so any
5387 backslashes that are required for that reason must be doubled if they are
5388 within a quoted configuration string.
5389
5390
5391 .section "User and group names" "SECID52"
5392 .cindex "user name" "format of"
5393 .cindex "format" "user name"
5394 .cindex "groups" "name format"
5395 .cindex "format" "group name"
5396 User and group names are specified as strings, using the syntax described
5397 above, but the strings are interpreted specially. A user or group name must
5398 either consist entirely of digits, or be a name that can be looked up using the
5399 &[getpwnam()]& or &[getgrnam()]& function, as appropriate.
5400
5401
5402 .section "List construction" "SECTlistconstruct"
5403 .cindex "list" "syntax of in configuration"
5404 .cindex "format" "list item in configuration"
5405 .cindex "string" "list, definition of"
5406 The data for some configuration options is a list of items, with colon as the
5407 default separator. Many of these options are shown with type &"string list"& in
5408 the descriptions later in this document. Others are listed as &"domain list"&,
5409 &"host list"&, &"address list"&, or &"local part list"&. Syntactically, they
5410 are all the same; however, those other than &"string list"& are subject to
5411 particular kinds of interpretation, as described in chapter
5412 &<<CHAPdomhosaddlists>>&.
5413
5414 In all these cases, the entire list is treated as a single string as far as the
5415 input syntax is concerned. The &%trusted_users%& setting in section
5416 &<<SECTstrings>>& above is an example. If a colon is actually needed in an item
5417 in a list, it must be entered as two colons. Leading and trailing white space
5418 on each item in a list is ignored. This makes it possible to include items that
5419 start with a colon, and in particular, certain forms of IPv6 address. For
5420 example, the list
5421 .code
5422 local_interfaces = 127.0.0.1 : ::::1
5423 .endd
5424 contains two IP addresses, the IPv4 address 127.0.0.1 and the IPv6 address ::1.
5425
5426 &*Note*&: Although leading and trailing white space is ignored in individual
5427 list items, it is not ignored when parsing the list. The spaces around the first
5428 colon in the example above are necessary. If they were not there, the list would
5429 be interpreted as the two items 127.0.0.1:: and 1.
5430
5431 .section "Changing list separators" "SECTlistsepchange"
5432 .cindex "list separator" "changing"
5433 .cindex "IPv6" "addresses in lists"
5434 Doubling colons in IPv6 addresses is an unwelcome chore, so a mechanism was
5435 introduced to allow the separator character to be changed. If a list begins
5436 with a left angle bracket, followed by any punctuation character, that
5437 character is used instead of colon as the list separator. For example, the list
5438 above can be rewritten to use a semicolon separator like this:
5439 .code
5440 local_interfaces = <; 127.0.0.1 ; ::1
5441 .endd
5442 This facility applies to all lists, with the exception of the list in
5443 &%log_file_path%&. It is recommended that the use of non-colon separators be
5444 confined to circumstances where they really are needed.
5445
5446 .cindex "list separator" "newline as"
5447 .cindex "newline" "as list separator"
5448 It is also possible to use newline and other control characters (those with
5449 code values less than 32, plus DEL) as separators in lists. Such separators
5450 must be provided literally at the time the list is processed. For options that
5451 are string-expanded, you can write the separator using a normal escape
5452 sequence. This will be processed by the expander before the string is
5453 interpreted as a list. For example, if a newline-separated list of domains is
5454 generated by a lookup, you can process it directly by a line such as this:
5455 .code
5456 domains = <\n ${lookup mysql{.....}}
5457 .endd
5458 This avoids having to change the list separator in such data. You are unlikely
5459 to want to use a control character as a separator in an option that is not
5460 expanded, because the value is literal text. However, it can be done by giving
5461 the value in quotes. For example:
5462 .code
5463 local_interfaces = "<\n 127.0.0.1 \n ::1"
5464 .endd
5465 Unlike printing character separators, which can be included in list items by
5466 doubling, it is not possible to include a control character as data when it is
5467 set as the separator. Two such characters in succession are interpreted as
5468 enclosing an empty list item.
5469
5470
5471
5472 .section "Empty items in lists" "SECTempitelis"
5473 .cindex "list" "empty item in"
5474 An empty item at the end of a list is always ignored. In other words, trailing
5475 separator characters are ignored. Thus, the list in
5476 .code
5477 senders = user@domain :
5478 .endd
5479 contains only a single item. If you want to include an empty string as one item
5480 in a list, it must not be the last item. For example, this list contains three
5481 items, the second of which is empty:
5482 .code
5483 senders = user1@domain : : user2@domain
5484 .endd
5485 &*Note*&: There must be white space between the two colons, as otherwise they
5486 are interpreted as representing a single colon data character (and the list
5487 would then contain just one item). If you want to specify a list that contains
5488 just one, empty item, you can do it as in this example:
5489 .code
5490 senders = :
5491 .endd
5492 In this case, the first item is empty, and the second is discarded because it
5493 is at the end of the list.
5494
5495
5496
5497
5498 .section "Format of driver configurations" "SECTfordricon"
5499 .cindex "drivers" "configuration format"
5500 There are separate parts in the configuration for defining routers, transports,
5501 and authenticators. In each part, you are defining a number of driver
5502 instances, each with its own set of options. Each driver instance is defined by
5503 a sequence of lines like this:
5504 .display
5505 <&'instance name'&>:
5506   <&'option'&>
5507   ...
5508   <&'option'&>
5509 .endd
5510 In the following example, the instance name is &(localuser)&, and it is
5511 followed by three options settings:
5512 .code
5513 localuser:
5514   driver = accept
5515   check_local_user
5516   transport = local_delivery
5517 .endd
5518 For each driver instance, you specify which Exim code module it uses &-- by the
5519 setting of the &%driver%& option &-- and (optionally) some configuration
5520 settings. For example, in the case of transports, if you want a transport to
5521 deliver with SMTP you would use the &(smtp)& driver; if you want to deliver to
5522 a local file you would use the &(appendfile)& driver. Each of the drivers is
5523 described in detail in its own separate chapter later in this manual.
5524
5525 You can have several routers, transports, or authenticators that are based on
5526 the same underlying driver (each must have a different instance name).
5527
5528 The order in which routers are defined is important, because addresses are
5529 passed to individual routers one by one, in order. The order in which
5530 transports are defined does not matter at all. The order in which
5531 authenticators are defined is used only when Exim, as a client, is searching
5532 them to find one that matches an authentication mechanism offered by the
5533 server.
5534
5535 .cindex "generic options"
5536 .cindex "options" "generic &-- definition of"
5537 Within a driver instance definition, there are two kinds of option: &'generic'&
5538 and &'private'&. The generic options are those that apply to all drivers of the
5539 same type (that is, all routers, all transports or all authenticators). The
5540 &%driver%& option is a generic option that must appear in every definition.
5541 .cindex "private options"
5542 The private options are special for each driver, and none need appear, because
5543 they all have default values.
5544
5545 The options may appear in any order, except that the &%driver%& option must
5546 precede any private options, since these depend on the particular driver. For
5547 this reason, it is recommended that &%driver%& always be the first option.
5548
5549 Driver instance names, which are used for reference in log entries and
5550 elsewhere, can be any sequence of letters, digits, and underscores (starting
5551 with a letter) and must be unique among drivers of the same type. A router and
5552 a transport (for example) can each have the same name, but no two router
5553 instances can have the same name. The name of a driver instance should not be
5554 confused with the name of the underlying driver module. For example, the
5555 configuration lines:
5556 .code
5557 remote_smtp:
5558   driver = smtp
5559 .endd
5560 create an instance of the &(smtp)& transport driver whose name is
5561 &(remote_smtp)&. The same driver code can be used more than once, with
5562 different instance names and different option settings each time. A second
5563 instance of the &(smtp)& transport, with different options, might be defined
5564 thus:
5565 .code
5566 special_smtp:
5567   driver = smtp
5568   port = 1234
5569   command_timeout = 10s
5570 .endd
5571 The names &(remote_smtp)& and &(special_smtp)& would be used to reference
5572 these transport instances from routers, and these names would appear in log
5573 lines.
5574
5575 Comment lines may be present in the middle of driver specifications. The full
5576 list of option settings for any particular driver instance, including all the
5577 defaulted values, can be extracted by making use of the &%-bP%& command line
5578 option.
5579
5580
5581
5582
5583
5584
5585 . ////////////////////////////////////////////////////////////////////////////
5586 . ////////////////////////////////////////////////////////////////////////////
5587
5588 .chapter "The default configuration file" "CHAPdefconfil"
5589 .scindex IIDconfiwal "configuration file" "default &""walk through""&"
5590 .cindex "default" "configuration file &""walk through""&"
5591 The default configuration file supplied with Exim as &_src/configure.default_&
5592 is sufficient for a host with simple mail requirements. As an introduction to
5593 the way Exim is configured, this chapter &"walks through"& the default
5594 configuration, giving brief explanations of the settings. Detailed descriptions
5595 of the options are given in subsequent chapters. The default configuration file
5596 itself contains extensive comments about ways you might want to modify the
5597 initial settings. However, note that there are many options that are not
5598 mentioned at all in the default configuration.
5599
5600
5601
5602 .section "Macros" "SECTdefconfmacros"
5603 All macros should be defined before any options.
5604
5605 One macro is specified, but commented out, in the default configuration:
5606 .code
5607 # ROUTER_SMARTHOST=MAIL.HOSTNAME.FOR.CENTRAL.SERVER.EXAMPLE
5608 .endd
5609 If all off-site mail is expected to be delivered to a "smarthost", then set the
5610 hostname here and uncomment the macro.  This will affect which router is used
5611 later on.  If this is left commented out, then Exim will perform direct-to-MX
5612 deliveries using a &(dnslookup)& router.
5613
5614 In addition to macros defined here, Exim includes a number of built-in macros
5615 to enable configuration to be guarded by a binary built with support for a
5616 given feature.  See section &<<SECTbuiltinmacros>>& for more details.
5617
5618
5619 .section "Main configuration settings" "SECTdefconfmain"
5620 The main (global) configuration option settings section must always come first
5621 in the file, after the macros.
5622 The first thing you'll see in the file, after some initial comments, is the line
5623 .code
5624 # primary_hostname =
5625 .endd
5626 This is a commented-out setting of the &%primary_hostname%& option. Exim needs
5627 to know the official, fully qualified name of your host, and this is where you
5628 can specify it. However, in most cases you do not need to set this option. When
5629 it is unset, Exim uses the &[uname()]& system function to obtain the host name.
5630
5631 The first three non-comment configuration lines are as follows:
5632 .code
5633 domainlist local_domains    = @
5634 domainlist relay_to_domains =
5635 hostlist   relay_from_hosts = 127.0.0.1
5636 .endd
5637 These are not, in fact, option settings. They are definitions of two named
5638 domain lists and one named host list. Exim allows you to give names to lists of
5639 domains, hosts, and email addresses, in order to make it easier to manage the
5640 configuration file (see section &<<SECTnamedlists>>&).
5641
5642 The first line defines a domain list called &'local_domains'&; this is used
5643 later in the configuration to identify domains that are to be delivered
5644 on the local host.
5645
5646 .cindex "@ in a domain list"
5647 There is just one item in this list, the string &"@"&. This is a special form
5648 of entry which means &"the name of the local host"&. Thus, if the local host is
5649 called &'a.host.example'&, mail to &'any.user@a.host.example'& is expected to
5650 be delivered locally. Because the local host's name is referenced indirectly,
5651 the same configuration file can be used on different hosts.
5652
5653 The second line defines a domain list called &'relay_to_domains'&, but the
5654 list itself is empty. Later in the configuration we will come to the part that
5655 controls mail relaying through the local host; it allows relaying to any
5656 domains in this list. By default, therefore, no relaying on the basis of a mail
5657 domain is permitted.
5658
5659 The third line defines a host list called &'relay_from_hosts'&. This list is
5660 used later in the configuration to permit relaying from any host or IP address
5661 that matches the list. The default contains just the IP address of the IPv4
5662 loopback interface, which means that processes on the local host are able to
5663 submit mail for relaying by sending it over TCP/IP to that interface. No other
5664 hosts are permitted to submit messages for relaying.
5665
5666 Just to be sure there's no misunderstanding: at this point in the configuration
5667 we aren't actually setting up any controls. We are just defining some domains
5668 and hosts that will be used in the controls that are specified later.
5669
5670 The next two configuration lines are genuine option settings:
5671 .code
5672 acl_smtp_rcpt = acl_check_rcpt
5673 acl_smtp_data = acl_check_data
5674 .endd
5675 These options specify &'Access Control Lists'& (ACLs) that are to be used
5676 during an incoming SMTP session for every recipient of a message (every RCPT
5677 command), and after the contents of the message have been received,
5678 respectively. The names of the lists are &'acl_check_rcpt'& and
5679 &'acl_check_data'&, and we will come to their definitions below, in the ACL
5680 section of the configuration. The RCPT ACL controls which recipients are
5681 accepted for an incoming message &-- if a configuration does not provide an ACL
5682 to check recipients, no SMTP mail can be accepted. The DATA ACL allows the
5683 contents of a message to be checked.
5684
5685 Two commented-out option settings are next:
5686 .code
5687 # av_scanner = clamd:/tmp/clamd
5688 # spamd_address = 127.0.0.1 783
5689 .endd
5690 These are example settings that can be used when Exim is compiled with the
5691 content-scanning extension. The first specifies the interface to the virus
5692 scanner, and the second specifies the interface to SpamAssassin. Further
5693 details are given in chapter &<<CHAPexiscan>>&.
5694
5695 Three more commented-out option settings follow:
5696 .code
5697 # tls_advertise_hosts = *
5698 # tls_certificate = /etc/ssl/exim.crt
5699 # tls_privatekey = /etc/ssl/exim.pem
5700 .endd
5701 These are example settings that can be used when Exim is compiled with
5702 support for TLS (aka SSL) as described in section &<<SECTinctlsssl>>&. The
5703 first one specifies the list of clients that are allowed to use TLS when
5704 connecting to this server; in this case, the wildcard means all clients. The
5705 other options specify where Exim should find its TLS certificate and private
5706 key, which together prove the server's identity to any clients that connect.
5707 More details are given in chapter &<<CHAPTLS>>&.
5708
5709 Another two commented-out option settings follow:
5710 .code
5711 # daemon_smtp_ports = 25 : 465 : 587
5712 # tls_on_connect_ports = 465
5713 .endd
5714 .cindex "port" "465 and 587"
5715 .cindex "port" "for message submission"
5716 .cindex "message" "submission, ports for"
5717 .cindex "submissions protocol"
5718 .cindex "smtps protocol"
5719 .cindex "ssmtp protocol"
5720 .cindex "SMTP" "submissions protocol"
5721 .cindex "SMTP" "ssmtp protocol"
5722 .cindex "SMTP" "smtps protocol"
5723 These options provide better support for roaming users who wish to use this
5724 server for message submission. They are not much use unless you have turned on
5725 TLS (as described in the previous paragraph) and authentication (about which
5726 more in section &<<SECTdefconfauth>>&).
5727 Mail submission from mail clients (MUAs) should be separate from inbound mail
5728 to your domain (MX delivery) for various good reasons (eg, ability to impose
5729 much saner TLS protocol and ciphersuite requirements without unintended
5730 consequences).
5731 RFC 6409 (previously 4409) specifies use of port 587 for SMTP Submission,
5732 which uses STARTTLS, so this is the &"submission"& port.
5733 RFC 8314 specifies use of port 465 as the &"submissions"& protocol,
5734 which should be used in preference to 587.
5735 You should also consider deploying SRV records to help clients find
5736 these ports.
5737 Older names for &"submissions"& are &"smtps"& and &"ssmtp"&.
5738
5739 Two more commented-out options settings follow:
5740 .code
5741 # qualify_domain =
5742 # qualify_recipient =
5743 .endd
5744 The first of these specifies a domain that Exim uses when it constructs a
5745 complete email address from a local login name. This is often needed when Exim
5746 receives a message from a local process. If you do not set &%qualify_domain%&,
5747 the value of &%primary_hostname%& is used. If you set both of these options,
5748 you can have different qualification domains for sender and recipient
5749 addresses. If you set only the first one, its value is used in both cases.
5750
5751 .cindex "domain literal" "recognizing format"
5752 The following line must be uncommented if you want Exim to recognize
5753 addresses of the form &'user@[10.11.12.13]'& that is, with a &"domain literal"&
5754 (an IP address within square brackets) instead of a named domain.
5755 .code
5756 # allow_domain_literals
5757 .endd
5758 The RFCs still require this form, but many people think that in the modern
5759 Internet it makes little sense to permit mail to be sent to specific hosts by
5760 quoting their IP addresses. This ancient format has been used by people who
5761 try to abuse hosts by using them for unwanted relaying. However, some
5762 people believe there are circumstances (for example, messages addressed to
5763 &'postmaster'&) where domain literals are still useful.
5764
5765 The next configuration line is a kind of trigger guard:
5766 .code
5767 never_users = root
5768 .endd
5769 It specifies that no delivery must ever be run as the root user. The normal
5770 convention is to set up &'root'& as an alias for the system administrator. This
5771 setting is a guard against slips in the configuration.
5772 The list of users specified by &%never_users%& is not, however, the complete
5773 list; the build-time configuration in &_Local/Makefile_& has an option called
5774 FIXED_NEVER_USERS specifying a list that cannot be overridden. The
5775 contents of &%never_users%& are added to this list. By default
5776 FIXED_NEVER_USERS also specifies root.
5777
5778 When a remote host connects to Exim in order to send mail, the only information
5779 Exim has about the host's identity is its IP address. The next configuration
5780 line,
5781 .code
5782 host_lookup = *
5783 .endd
5784 specifies that Exim should do a reverse DNS lookup on all incoming connections,
5785 in order to get a host name. This improves the quality of the logging
5786 information, but if you feel it is too expensive, you can remove it entirely,
5787 or restrict the lookup to hosts on &"nearby"& networks.
5788 Note that it is not always possible to find a host name from an IP address,
5789 because not all DNS reverse zones are maintained, and sometimes DNS servers are
5790 unreachable.
5791
5792 The next two lines are concerned with &'ident'& callbacks, as defined by RFC
5793 1413 (hence their names):
5794 .code
5795 rfc1413_hosts = *
5796 rfc1413_query_timeout = 0s
5797 .endd
5798 These settings cause Exim to avoid ident callbacks for all incoming SMTP calls.
5799 Few hosts offer RFC1413 service these days; calls have to be
5800 terminated by a timeout and this needlessly delays the startup
5801 of an incoming SMTP connection.
5802 If you have hosts for which you trust RFC1413 and need this
5803 information, you can change this.
5804
5805 This line enables an efficiency SMTP option.  It is negotiated by clients
5806 and not expected to cause problems but can be disabled if needed.
5807 .code
5808 prdr_enable = true
5809 .endd
5810
5811 When Exim receives messages over SMTP connections, it expects all addresses to
5812 be fully qualified with a domain, as required by the SMTP definition. However,
5813 if you are running a server to which simple clients submit messages, you may
5814 find that they send unqualified addresses. The two commented-out options:
5815 .code
5816 # sender_unqualified_hosts =
5817 # recipient_unqualified_hosts =
5818 .endd
5819 show how you can specify hosts that are permitted to send unqualified sender
5820 and recipient addresses, respectively.
5821
5822 The &%log_selector%& option is used to increase the detail of logging
5823 over the default:
5824 .code
5825 log_selector = +smtp_protocol_error +smtp_syntax_error \
5826                +tls_certificate_verified
5827 .endd
5828
5829 The &%percent_hack_domains%& option is also commented out:
5830 .code
5831 # percent_hack_domains =
5832 .endd
5833 It provides a list of domains for which the &"percent hack"& is to operate.
5834 This is an almost obsolete form of explicit email routing. If you do not know
5835 anything about it, you can safely ignore this topic.
5836
5837 The next two settings in the main part of the default configuration are
5838 concerned with messages that have been &"frozen"& on Exim's queue. When a
5839 message is frozen, Exim no longer continues to try to deliver it. Freezing
5840 occurs when a bounce message encounters a permanent failure because the sender
5841 address of the original message that caused the bounce is invalid, so the
5842 bounce cannot be delivered. This is probably the most common case, but there
5843 are also other conditions that cause freezing, and frozen messages are not
5844 always bounce messages.
5845 .code
5846 ignore_bounce_errors_after = 2d
5847 timeout_frozen_after = 7d
5848 .endd
5849 The first of these options specifies that failing bounce messages are to be
5850 discarded after 2 days in the queue. The second specifies that any frozen
5851 message (whether a bounce message or not) is to be timed out (and discarded)
5852 after a week. In this configuration, the first setting ensures that no failing
5853 bounce message ever lasts a week.
5854
5855 Exim queues it's messages in a spool directory. If you expect to have
5856 large queues, you may consider using this option. It splits the spool
5857 directory into subdirectories to avoid file system degradation from
5858 many files in a single directory, resulting in better performance.
5859 Manual manipulation of queued messages becomes more complex (though fortunately
5860 not often needed).
5861 .code
5862 # split_spool_directory = true
5863 .endd
5864
5865 In an ideal world everybody follows the standards. For non-ASCII
5866 messages RFC 2047 is a standard, allowing a maximum line length of 76
5867 characters. Exim adheres that standard and won't process messages which
5868 violate this standard. (Even ${rfc2047:...} expansions will fail.)
5869 In particular, the Exim maintainers have had multiple reports of
5870 problems from Russian administrators of issues until they disable this
5871 check, because of some popular, yet buggy, mail composition software.
5872 .code
5873 # check_rfc2047_length = false
5874 .endd
5875
5876 If you need to be strictly RFC compliant you may wish to disable the
5877 8BITMIME advertisement. Use this, if you exchange mails with systems
5878 that are not 8-bit clean.
5879 .code
5880 # accept_8bitmime = false
5881 .endd
5882
5883 Libraries you use may depend on specific environment settings.  This
5884 imposes a security risk (e.g. PATH). There are two lists:
5885 &%keep_environment%& for the variables to import as they are, and
5886 &%add_environment%& for variables we want to set to a fixed value.
5887 Note that TZ is handled separately, by the &%timezone%& runtime
5888 option and by the TIMEZONE_DEFAULT buildtime option.
5889 .code
5890 # keep_environment = ^LDAP
5891 # add_environment = PATH=/usr/bin::/bin
5892 .endd
5893
5894
5895 .section "ACL configuration" "SECID54"
5896 .cindex "default" "ACLs"
5897 .cindex "&ACL;" "default configuration"
5898 In the default configuration, the ACL section follows the main configuration.
5899 It starts with the line
5900 .code
5901 begin acl
5902 .endd
5903 and it contains the definitions of two ACLs, called &'acl_check_rcpt'& and
5904 &'acl_check_data'&, that were referenced in the settings of &%acl_smtp_rcpt%&
5905 and &%acl_smtp_data%& above.
5906
5907 .cindex "RCPT" "ACL for"
5908 The first ACL is used for every RCPT command in an incoming SMTP message. Each
5909 RCPT command specifies one of the message's recipients. The ACL statements
5910 are considered in order, until the recipient address is either accepted or
5911 rejected. The RCPT command is then accepted or rejected, according to the
5912 result of the ACL processing.
5913 .code
5914 acl_check_rcpt:
5915 .endd
5916 This line, consisting of a name terminated by a colon, marks the start of the
5917 ACL, and names it.
5918 .code
5919 accept  hosts = :
5920 .endd
5921 This ACL statement accepts the recipient if the sending host matches the list.
5922 But what does that strange list mean? It doesn't actually contain any host
5923 names or IP addresses. The presence of the colon puts an empty item in the
5924 list; Exim matches this only if the incoming message did not come from a remote
5925 host, because in that case, the remote hostname is empty. The colon is
5926 important. Without it, the list itself is empty, and can never match anything.
5927
5928 What this statement is doing is to accept unconditionally all recipients in
5929 messages that are submitted by SMTP from local processes using the standard
5930 input and output (that is, not using TCP/IP). A number of MUAs operate in this
5931 manner.
5932 .code
5933 deny    domains       = +local_domains
5934         local_parts   = ^[.] : ^.*[@%!/|]
5935         message       = Restricted characters in address
5936
5937 deny    domains       = !+local_domains
5938         local_parts   = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
5939         message       = Restricted characters in address
5940 .endd
5941 These statements are concerned with local parts that contain any of the
5942 characters &"@"&, &"%"&, &"!"&, &"/"&, &"|"&, or dots in unusual places.
5943 Although these characters are entirely legal in local parts (in the case of
5944 &"@"& and leading dots, only if correctly quoted), they do not commonly occur
5945 in Internet mail addresses.
5946
5947 The first three have in the past been associated with explicitly routed
5948 addresses (percent is still sometimes used &-- see the &%percent_hack_domains%&
5949 option). Addresses containing these characters are regularly tried by spammers
5950 in an attempt to bypass relaying restrictions, and also by open relay testing
5951 programs. Unless you really need them it is safest to reject these characters
5952 at this early stage. This configuration is heavy-handed in rejecting these
5953 characters for all messages it accepts from remote hosts. This is a deliberate
5954 policy of being as safe as possible.
5955
5956 The first rule above is stricter, and is applied to messages that are addressed
5957 to one of the local domains handled by this host. This is implemented by the
5958 first condition, which restricts it to domains that are listed in the
5959 &'local_domains'& domain list. The &"+"& character is used to indicate a
5960 reference to a named list. In this configuration, there is just one domain in
5961 &'local_domains'&, but in general there may be many.
5962
5963 The second condition on the first statement uses two regular expressions to
5964 block local parts that begin with a dot or contain &"@"&, &"%"&, &"!"&, &"/"&,
5965 or &"|"&. If you have local accounts that include these characters, you will
5966 have to modify this rule.
5967
5968 Empty components (two dots in a row) are not valid in RFC 2822, but Exim
5969 allows them because they have been encountered in practice. (Consider the
5970 common convention of local parts constructed as
5971 &"&'first-initial.second-initial.family-name'&"& when applied to someone like
5972 the author of Exim, who has no second initial.) However, a local part starting
5973 with a dot or containing &"/../"& can cause trouble if it is used as part of a
5974 filename (for example, for a mailing list). This is also true for local parts
5975 that contain slashes. A pipe symbol can also be troublesome if the local part
5976 is incorporated unthinkingly into a shell command line.
5977
5978 The second rule above applies to all other domains, and is less strict. This
5979 allows your own users to send outgoing messages to sites that use slashes
5980 and vertical bars in their local parts. It blocks local parts that begin
5981 with a dot, slash, or vertical bar, but allows these characters within the
5982 local part. However, the sequence &"/../"& is barred. The use of &"@"&, &"%"&,
5983 and &"!"& is blocked, as before. The motivation here is to prevent your users
5984 (or your users' viruses) from mounting certain kinds of attack on remote sites.
5985 .code
5986 accept  local_parts   = postmaster
5987         domains       = +local_domains
5988 .endd
5989 This statement, which has two conditions, accepts an incoming address if the
5990 local part is &'postmaster'& and the domain is one of those listed in the
5991 &'local_domains'& domain list. The &"+"& character is used to indicate a
5992 reference to a named list. In this configuration, there is just one domain in
5993 &'local_domains'&, but in general there may be many.
5994
5995 The presence of this statement means that mail to postmaster is never blocked
5996 by any of the subsequent tests. This can be helpful while sorting out problems
5997 in cases where the subsequent tests are incorrectly denying access.
5998 .code
5999 require verify        = sender
6000 .endd
6001 This statement requires the sender address to be verified before any subsequent
6002 ACL statement can be used. If verification fails, the incoming recipient
6003 address is refused. Verification consists of trying to route the address, to
6004 see if a bounce message could be delivered to it. In the case of remote
6005 addresses, basic verification checks only the domain, but &'callouts'& can be
6006 used for more verification if required. Section &<<SECTaddressverification>>&
6007 discusses the details of address verification.
6008 .code
6009 accept  hosts         = +relay_from_hosts
6010         control       = submission
6011 .endd
6012 This statement accepts the address if the message is coming from one of the
6013 hosts that are defined as being allowed to relay through this host. Recipient
6014 verification is omitted here, because in many cases the clients are dumb MUAs
6015 that do not cope well with SMTP error responses. For the same reason, the
6016 second line specifies &"submission mode"& for messages that are accepted. This
6017 is described in detail in section &<<SECTsubmodnon>>&; it causes Exim to fix
6018 messages that are deficient in some way, for example, because they lack a
6019 &'Date:'& header line. If you are actually relaying out from MTAs, you should
6020 probably add recipient verification here, and disable submission mode.
6021 .code
6022 accept  authenticated = *
6023         control       = submission
6024 .endd
6025 This statement accepts the address if the client host has authenticated itself.
6026 Submission mode is again specified, on the grounds that such messages are most
6027 likely to come from MUAs. The default configuration does not define any
6028 authenticators, though it does include some nearly complete commented-out
6029 examples described in &<<SECTdefconfauth>>&. This means that no client can in
6030 fact authenticate until you complete the authenticator definitions.
6031 .code
6032 require message = relay not permitted
6033         domains = +local_domains : +relay_to_domains
6034 .endd
6035 This statement rejects the address if its domain is neither a local domain nor
6036 one of the domains for which this host is a relay.
6037 .code
6038 require verify = recipient
6039 .endd
6040 This statement requires the recipient address to be verified; if verification
6041 fails, the address is rejected.
6042 .code
6043 # deny    dnslists    = black.list.example
6044 #         message     = rejected because $sender_host_address \
6045 #                       is in a black list at $dnslist_domain\n\
6046 #                       $dnslist_text
6047 #
6048 # warn    dnslists    = black.list.example
6049 #         add_header  = X-Warning: $sender_host_address is in \
6050 #                       a black list at $dnslist_domain
6051 #         log_message = found in $dnslist_domain
6052 .endd
6053 These commented-out lines are examples of how you could configure Exim to check
6054 sending hosts against a DNS black list. The first statement rejects messages
6055 from blacklisted hosts, whereas the second just inserts a warning header
6056 line.
6057 .code
6058 # require verify = csa
6059 .endd
6060 This commented-out line is an example of how you could turn on client SMTP
6061 authorization (CSA) checking. Such checks do DNS lookups for special SRV
6062 records.
6063 .code
6064 accept
6065 .endd
6066 The final statement in the first ACL unconditionally accepts any recipient
6067 address that has successfully passed all the previous tests.
6068 .code
6069 acl_check_data:
6070 .endd
6071 This line marks the start of the second ACL, and names it. Most of the contents
6072 of this ACL are commented out:
6073 .code
6074 # deny    malware   = *
6075 #         message   = This message contains a virus \
6076 #                     ($malware_name).
6077 .endd
6078 These lines are examples of how to arrange for messages to be scanned for
6079 viruses when Exim has been compiled with the content-scanning extension, and a
6080 suitable virus scanner is installed. If the message is found to contain a
6081 virus, it is rejected with the given custom error message.
6082 .code
6083 # warn    spam      = nobody
6084 #         message   = X-Spam_score: $spam_score\n\
6085 #                     X-Spam_score_int: $spam_score_int\n\
6086 #                     X-Spam_bar: $spam_bar\n\
6087 #                     X-Spam_report: $spam_report
6088 .endd
6089 These lines are an example of how to arrange for messages to be scanned by
6090 SpamAssassin when Exim has been compiled with the content-scanning extension,
6091 and SpamAssassin has been installed. The SpamAssassin check is run with
6092 &`nobody`& as its user parameter, and the results are added to the message as a
6093 series of extra header line. In this case, the message is not rejected,
6094 whatever the spam score.
6095 .code
6096 accept
6097 .endd
6098 This final line in the DATA ACL accepts the message unconditionally.
6099
6100
6101 .section "Router configuration" "SECID55"
6102 .cindex "default" "routers"
6103 .cindex "routers" "default"
6104 The router configuration comes next in the default configuration, introduced
6105 by the line
6106 .code
6107 begin routers
6108 .endd
6109 Routers are the modules in Exim that make decisions about where to send
6110 messages. An address is passed to each router, in turn, until it is either
6111 accepted, or failed. This means that the order in which you define the routers
6112 matters. Each router is fully described in its own chapter later in this
6113 manual. Here we give only brief overviews.
6114 .code
6115 # domain_literal:
6116 #   driver = ipliteral
6117 #   domains = !+local_domains
6118 #   transport = remote_smtp
6119 .endd
6120 .cindex "domain literal" "default router"
6121 This router is commented out because the majority of sites do not want to
6122 support domain literal addresses (those of the form &'user@[10.9.8.7]'&). If
6123 you uncomment this router, you also need to uncomment the setting of
6124 &%allow_domain_literals%& in the main part of the configuration.
6125
6126 Which router is used next depends upon whether or not the ROUTER_SMARTHOST
6127 macro has been defined, per
6128 .code
6129 .ifdef ROUTER_SMARTHOST
6130 smarthost:
6131 #...
6132 .else
6133 dnslookup:
6134 #...
6135 .endif
6136 .endd
6137
6138 If ROUTER_SMARTHOST has been defined, either at the top of the file or on the
6139 command-line, then we route all non-local mail to that smarthost; otherwise, we'll
6140 perform DNS lookups for direct-to-MX lookup.  Any mail which is to a local domain will
6141 skip these routers because of the &%domains%& option.
6142
6143 .code
6144 smarthost:
6145   driver = manualroute
6146   domains = ! +local_domains
6147   transport = smarthost_smtp
6148   route_data = ROUTER_SMARTHOST
6149   ignore_target_hosts = <; 0.0.0.0 ; 127.0.0.0/8 ; ::1
6150   no_more
6151 .endd
6152 This router only handles mail which is not to any local domains; this is
6153 specified by the line
6154 .code
6155 domains = ! +local_domains
6156 .endd
6157 The &%domains%& option lists the domains to which this router applies, but the
6158 exclamation mark is a negation sign, so the router is used only for domains
6159 that are not in the domain list called &'local_domains'& (which was defined at
6160 the start of the configuration). The plus sign before &'local_domains'&
6161 indicates that it is referring to a named list. Addresses in other domains are
6162 passed on to the following routers.
6163
6164 The name of the router driver is &(manualroute)& because we are manually
6165 specifying how mail should be routed onwards, instead of using DNS MX.
6166 While the name of this router instance is arbitrary, the &%driver%& option must
6167 be one of the driver modules that is in the Exim binary.
6168
6169 With no pre-conditions other than &%domains%&, all mail for non-local domains
6170 will be handled by this router, and the &%no_more%& setting will ensure that no
6171 other routers will be used for messages matching the pre-conditions.  See
6172 &<<SECTrouprecon>>& for more on how the pre-conditions apply.  For messages which
6173 are handled by this router, we provide a hostname to deliver to in &%route_data%&
6174 and the macro supplies the value; the address is then queued for the
6175 &(smarthost_smtp)& transport.
6176
6177 .code
6178 dnslookup:
6179   driver = dnslookup
6180   domains = ! +local_domains
6181   transport = remote_smtp
6182   ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
6183   no_more
6184 .endd
6185 The &%domains%& option behaves as per smarthost, above.
6186
6187 The name of the router driver is &(dnslookup)&,
6188 and is specified by the &%driver%& option. Do not be confused by the fact that
6189 the name of this router instance is the same as the name of the driver. The
6190 instance name is arbitrary, but the name set in the &%driver%& option must be
6191 one of the driver modules that is in the Exim binary.
6192
6193 The &(dnslookup)& router routes addresses by looking up their domains in the
6194 DNS in order to obtain a list of hosts to which the address is routed. If the
6195 router succeeds, the address is queued for the &(remote_smtp)& transport, as
6196 specified by the &%transport%& option. If the router does not find the domain
6197 in the DNS, no further routers are tried because of the &%no_more%& setting, so
6198 the address fails and is bounced.
6199
6200 The &%ignore_target_hosts%& option specifies a list of IP addresses that are to
6201 be entirely ignored. This option is present because a number of cases have been
6202 encountered where MX records in the DNS point to host names
6203 whose IP addresses are 0.0.0.0 or are in the 127 subnet (typically 127.0.0.1).
6204 Completely ignoring these IP addresses causes Exim to fail to route the
6205 email address, so it bounces. Otherwise, Exim would log a routing problem, and
6206 continue to try to deliver the message periodically until the address timed
6207 out.
6208 .code
6209 system_aliases:
6210   driver = redirect
6211   allow_fail
6212   allow_defer
6213   data = ${lookup{$local_part}lsearch{/etc/aliases}}
6214 # user = exim
6215   file_transport = address_file
6216   pipe_transport = address_pipe
6217 .endd
6218 Control reaches this and subsequent routers only for addresses in the local
6219 domains. This router checks to see whether the local part is defined as an
6220 alias in the &_/etc/aliases_& file, and if so, redirects it according to the
6221 data that it looks up from that file. If no data is found for the local part,
6222 the value of the &%data%& option is empty, causing the address to be passed to
6223 the next router.
6224
6225 &_/etc/aliases_& is a conventional name for the system aliases file that is
6226 often used. That is why it is referenced by from the default configuration
6227 file. However, you can change this by setting SYSTEM_ALIASES_FILE in
6228 &_Local/Makefile_& before building Exim.
6229 .code
6230 userforward:
6231   driver = redirect
6232   check_local_user
6233 # local_part_suffix = +* : -*
6234 # local_part_suffix_optional
6235   file = $home/.forward
6236 # allow_filter
6237   no_verify
6238   no_expn
6239   check_ancestor
6240   file_transport = address_file
6241   pipe_transport = address_pipe
6242   reply_transport = address_reply
6243 .endd
6244 This is the most complicated router in the default configuration. It is another
6245 redirection router, but this time it is looking for forwarding data set up by
6246 individual users. The &%check_local_user%& setting specifies a check that the
6247 local part of the address is the login name of a local user. If it is not, the
6248 router is skipped. The two commented options that follow &%check_local_user%&,
6249 namely:
6250 .code
6251 # local_part_suffix = +* : -*
6252 # local_part_suffix_optional
6253 .endd
6254 .vindex "&$local_part_suffix$&"
6255 show how you can specify the recognition of local part suffixes. If the first
6256 is uncommented, a suffix beginning with either a plus or a minus sign, followed
6257 by any sequence of characters, is removed from the local part and placed in the
6258 variable &$local_part_suffix$&. The second suffix option specifies that the
6259 presence of a suffix in the local part is optional. When a suffix is present,
6260 the check for a local login uses the local part with the suffix removed.
6261
6262 When a local user account is found, the file called &_.forward_& in the user's
6263 home directory is consulted. If it does not exist, or is empty, the router
6264 declines. Otherwise, the contents of &_.forward_& are interpreted as
6265 redirection data (see chapter &<<CHAPredirect>>& for more details).
6266
6267 .cindex "Sieve filter" "enabling in default router"
6268 Traditional &_.forward_& files contain just a list of addresses, pipes, or
6269 files. Exim supports this by default. However, if &%allow_filter%& is set (it
6270 is commented out by default), the contents of the file are interpreted as a set
6271 of Exim or Sieve filtering instructions, provided the file begins with &"#Exim
6272 filter"& or &"#Sieve filter"&, respectively. User filtering is discussed in the
6273 separate document entitled &'Exim's interfaces to mail filtering'&.
6274
6275 The &%no_verify%& and &%no_expn%& options mean that this router is skipped when
6276 verifying addresses, or when running as a consequence of an SMTP EXPN command.
6277 There are two reasons for doing this:
6278
6279 .olist
6280 Whether or not a local user has a &_.forward_& file is not really relevant when
6281 checking an address for validity; it makes sense not to waste resources doing
6282 unnecessary work.
6283 .next
6284 More importantly, when Exim is verifying addresses or handling an EXPN
6285 command during an SMTP session, it is running as the Exim user, not as root.
6286 The group is the Exim group, and no additional groups are set up.
6287 It may therefore not be possible for Exim to read users' &_.forward_& files at
6288 this time.
6289 .endlist
6290
6291 The setting of &%check_ancestor%& prevents the router from generating a new
6292 address that is the same as any previous address that was redirected. (This
6293 works round a problem concerning a bad interaction between aliasing and
6294 forwarding &-- see section &<<SECTredlocmai>>&).
6295
6296 The final three option settings specify the transports that are to be used when
6297 forwarding generates a direct delivery to a file, or to a pipe, or sets up an
6298 auto-reply, respectively. For example, if a &_.forward_& file contains
6299 .code
6300 a.nother@elsewhere.example, /home/spqr/archive
6301 .endd
6302 the delivery to &_/home/spqr/archive_& is done by running the &%address_file%&
6303 transport.
6304 .code
6305 localuser:
6306   driver = accept
6307   check_local_user
6308 # local_part_suffix = +* : -*
6309 # local_part_suffix_optional
6310   transport = local_delivery
6311 .endd
6312 The final router sets up delivery into local mailboxes, provided that the local
6313 part is the name of a local login, by accepting the address and assigning it to
6314 the &(local_delivery)& transport. Otherwise, we have reached the end of the
6315 routers, so the address is bounced. The commented suffix settings fulfil the
6316 same purpose as they do for the &(userforward)& router.
6317
6318
6319 .section "Transport configuration" "SECID56"
6320 .cindex "default" "transports"
6321 .cindex "transports" "default"
6322 Transports define mechanisms for actually delivering messages. They operate
6323 only when referenced from routers, so the order in which they are defined does
6324 not matter. The transports section of the configuration starts with
6325 .code
6326 begin transports
6327 .endd
6328 Two remote transports and four local transports are defined.
6329 .code
6330 remote_smtp:
6331   driver = smtp
6332   message_size_limit = ${if > {$max_received_linelength}{998} {1}{0}}
6333 .ifdef _HAVE_PRDR
6334   hosts_try_prdr = *
6335 .endif
6336 .endd
6337 This transport is used for delivering messages over SMTP connections.
6338 The list of remote hosts comes from the router.
6339 The &%message_size_limit%& usage is a hack to avoid sending on messages
6340 with over-long lines.
6341
6342 The &%hosts_try_prdr%& option enables an efficiency SMTP option.  It is
6343 negotiated between client and server and not expected to cause problems
6344 but can be disabled if needed.  The built-in macro _HAVE_PRDR guards the
6345 use of the &%hosts_try_prdr%& configuration option.
6346
6347 The other remote transport is used when delivering to a specific smarthost
6348 with whom there must be some kind of existing relationship, instead of the
6349 usual federated system.
6350
6351 .code
6352 smarthost_smtp:
6353   driver = smtp
6354   message_size_limit = ${if > {$max_received_linelength}{998} {1}{0}}
6355   multi_domain
6356   #
6357 .ifdef _HAVE_TLS
6358   # Comment out any of these which you have to, then file a Support
6359   # request with your smarthost provider to get things fixed:
6360   hosts_require_tls = *
6361   tls_verify_hosts = *
6362   # As long as tls_verify_hosts is enabled, this this will have no effect,
6363   # but if you have to comment it out then this will at least log whether
6364   # you succeed or not:
6365   tls_try_verify_hosts = *
6366   #
6367   # The SNI name should match the name which we'll expect to verify;
6368   # many mail systems don't use SNI and this doesn't matter, but if it does,
6369   # we need to send a name which the remote site will recognize.
6370   # This _should_ be the name which the smarthost operators specified as
6371   # the hostname for sending your mail to.
6372   tls_sni = ROUTER_SMARTHOST
6373   #
6374 .ifdef _HAVE_OPENSSL
6375   tls_require_ciphers = HIGH:!aNULL:@STRENGTH
6376 .endif
6377 .ifdef _HAVE_GNUTLS
6378   tls_require_ciphers = SECURE192:-VERS-SSL3.0:-VERS-TLS1.0:-VERS-TLS1.1
6379 .endif
6380 .endif
6381 .ifdef _HAVE_PRDR
6382   hosts_try_prdr = *
6383 .endif
6384 .endd
6385 After the same &%message_size_limit%& hack, we then specify that this Transport
6386 can handle messages to multiple domains in one run.  The assumption here is
6387 that you're routing all non-local mail to the same place and that place is
6388 happy to take all messages from you as quickly as possible.
6389 All other options depend upon built-in macros; if Exim was built without TLS support
6390 then no other options are defined.
6391 If TLS is available, then we configure "stronger than default" TLS ciphersuites
6392 and versions using the &%tls_require_ciphers%& option, where the value to be
6393 used depends upon the library providing TLS.
6394 Beyond that, the options adopt the stance that you should have TLS support available
6395 from your smarthost on today's Internet, so we turn on requiring TLS for the
6396 mail to be delivered, and requiring that the certificate be valid, and match
6397 the expected hostname.  The &%tls_sni%& option can be used by service providers
6398 to select an appropriate certificate to present to you and here we re-use the
6399 ROUTER_SMARTHOST macro, because that is unaffected by CNAMEs present in DNS.
6400 You want to specify the hostname which you'll expect to validate for, and that
6401 should not be subject to insecure tampering via DNS results.
6402
6403 For the &%hosts_try_prdr%& option see the previous transport.
6404
6405 All other options are defaulted.
6406 .code
6407 local_delivery:
6408   driver = appendfile
6409   file = /var/mail/$local_part_data
6410   delivery_date_add
6411   envelope_to_add
6412   return_path_add
6413 # group = mail
6414 # mode = 0660
6415 .endd
6416 This &(appendfile)& transport is used for local delivery to user mailboxes in
6417 traditional BSD mailbox format.
6418
6419 We prefer to avoid using &$local_part$& directly to define the mailbox filename,
6420 as it is provided by a potential bad actor.
6421 Instead we use &$local_part_data$&,
6422 the result of looking up &$local_part$& in the user database
6423 (done by using &%check_local_user%& in the the router).
6424
6425 By default &(appendfile)& runs under the uid and gid of the
6426 local user, which requires the sticky bit to be set on the &_/var/mail_&
6427 directory. Some systems use the alternative approach of running mail deliveries
6428 under a particular group instead of using the sticky bit. The commented options
6429 show how this can be done.
6430
6431 Exim adds three headers to the message as it delivers it: &'Delivery-date:'&,
6432 &'Envelope-to:'& and &'Return-path:'&. This action is requested by the three
6433 similarly-named options above.
6434 .code
6435 address_pipe:
6436   driver = pipe
6437   return_output
6438 .endd
6439 This transport is used for handling deliveries to pipes that are generated by
6440 redirection (aliasing or users' &_.forward_& files). The &%return_output%&
6441 option specifies that any output on stdout or stderr generated by the pipe is to
6442 be returned to the sender.
6443 .code
6444 address_file:
6445   driver = appendfile
6446   delivery_date_add
6447   envelope_to_add
6448   return_path_add
6449 .endd
6450 This transport is used for handling deliveries to files that are generated by
6451 redirection. The name of the file is not specified in this instance of
6452 &(appendfile)&, because it comes from the &(redirect)& router.
6453 .code
6454 address_reply:
6455   driver = autoreply
6456 .endd
6457 This transport is used for handling automatic replies generated by users'
6458 filter files.
6459
6460
6461
6462 .section "Default retry rule" "SECID57"
6463 .cindex "retry" "default rule"
6464 .cindex "default" "retry rule"
6465 The retry section of the configuration file contains rules which affect the way
6466 Exim retries deliveries that cannot be completed at the first attempt. It is
6467 introduced by the line
6468 .code
6469 begin retry
6470 .endd
6471 In the default configuration, there is just one rule, which applies to all
6472 errors:
6473 .code
6474 *   *   F,2h,15m; G,16h,1h,1.5; F,4d,6h
6475 .endd
6476 This causes any temporarily failing address to be retried every 15 minutes for
6477 2 hours, then at intervals starting at one hour and increasing by a factor of
6478 1.5 until 16 hours have passed, then every 6 hours up to 4 days. If an address
6479 is not delivered after 4 days of temporary failure, it is bounced. The time is
6480 measured from first failure, not from the time the message was received.
6481
6482 If the retry section is removed from the configuration, or is empty (that is,
6483 if no retry rules are defined), Exim will not retry deliveries. This turns
6484 temporary errors into permanent errors.
6485
6486
6487 .section "Rewriting configuration" "SECID58"
6488 The rewriting section of the configuration, introduced by
6489 .code
6490 begin rewrite
6491 .endd
6492 contains rules for rewriting addresses in messages as they arrive. There are no
6493 rewriting rules in the default configuration file.
6494
6495
6496
6497 .section "Authenticators configuration" "SECTdefconfauth"
6498 .cindex "AUTH" "configuration"
6499 The authenticators section of the configuration, introduced by
6500 .code
6501 begin authenticators
6502 .endd
6503 defines mechanisms for the use of the SMTP AUTH command. The default
6504 configuration file contains two commented-out example authenticators
6505 which support plaintext username/password authentication using the
6506 standard PLAIN mechanism and the traditional but non-standard LOGIN
6507 mechanism, with Exim acting as the server. PLAIN and LOGIN are enough
6508 to support most MUA software.
6509
6510 The example PLAIN authenticator looks like this:
6511 .code
6512 #PLAIN:
6513 #  driver                  = plaintext
6514 #  server_set_id           = $auth2
6515 #  server_prompts          = :
6516 #  server_condition        = Authentication is not yet configured
6517 #  server_advertise_condition = ${if def:tls_in_cipher }
6518 .endd
6519 And the example LOGIN authenticator looks like this:
6520 .code
6521 #LOGIN:
6522 #  driver                  = plaintext
6523 #  server_set_id           = $auth1
6524 #  server_prompts          = <| Username: | Password:
6525 #  server_condition        = Authentication is not yet configured
6526 #  server_advertise_condition = ${if def:tls_in_cipher }
6527 .endd
6528
6529 The &%server_set_id%& option makes Exim remember the authenticated username
6530 in &$authenticated_id$&, which can be used later in ACLs or routers. The
6531 &%server_prompts%& option configures the &(plaintext)& authenticator so
6532 that it implements the details of the specific authentication mechanism,
6533 i.e. PLAIN or LOGIN. The &%server_advertise_condition%& setting controls
6534 when Exim offers authentication to clients; in the examples, this is only
6535 when TLS or SSL has been started, so to enable the authenticators you also
6536 need to add support for TLS as described in section &<<SECTdefconfmain>>&.
6537
6538 The &%server_condition%& setting defines how to verify that the username and
6539 password are correct. In the examples it just produces an error message.
6540 To make the authenticators work, you can use a string expansion
6541 expression like one of the examples in chapter &<<CHAPplaintext>>&.
6542
6543 Beware that the sequence of the parameters to PLAIN and LOGIN differ; the
6544 usercode and password are in different positions.
6545 Chapter &<<CHAPplaintext>>& covers both.
6546
6547 .ecindex IIDconfiwal
6548
6549
6550
6551 . ////////////////////////////////////////////////////////////////////////////
6552 . ////////////////////////////////////////////////////////////////////////////
6553
6554 .chapter "Regular expressions" "CHAPregexp"
6555
6556 .cindex "regular expressions" "library"
6557 .cindex "PCRE2"
6558 Exim supports the use of regular expressions in many of its options. It
6559 uses the PCRE2 regular expression library; this provides regular expression
6560 matching that is compatible with Perl 5. The syntax and semantics of
6561 regular expressions is discussed in
6562 online Perl manpages, in
6563 many Perl reference books, and also in
6564 Jeffrey Friedl's &'Mastering Regular Expressions'&, which is published by
6565 O'Reilly (see &url(http://www.oreilly.com/catalog/regex2/)).
6566 . --- the http: URL here redirects to another page with the ISBN in the URL
6567 . --- where trying to use https: just redirects back to http:, so sticking
6568 . --- to the old URL for now.  2018-09-07.
6569
6570 The documentation for the syntax and semantics of the regular expressions that
6571 are supported by PCRE2 is included in the PCRE2 distribution, and no further
6572 description is included here. The PCRE2 functions are called from Exim using
6573 the default option settings (that is, with no PCRE2 options set), except that
6574 the PCRE2_CASELESS option is set when the matching is required to be
6575 case-insensitive.
6576
6577 In most cases, when a regular expression is required in an Exim configuration,
6578 it has to start with a circumflex, in order to distinguish it from plain text
6579 or an &"ends with"& wildcard. In this example of a configuration setting, the
6580 second item in the colon-separated list is a regular expression.
6581 .code
6582 domains = a.b.c : ^\\d{3} : *.y.z : ...
6583 .endd
6584 The doubling of the backslash is required because of string expansion that
6585 precedes interpretation &-- see section &<<SECTlittext>>& for more discussion
6586 of this issue, and a way of avoiding the need for doubling backslashes. The
6587 regular expression that is eventually used in this example contains just one
6588 backslash. The circumflex is included in the regular expression, and has the
6589 normal effect of &"anchoring"& it to the start of the string that is being
6590 matched.
6591
6592 There are, however, two cases where a circumflex is not required for the
6593 recognition of a regular expression: these are the &%match%& condition in a
6594 string expansion, and the &%matches%& condition in an Exim filter file. In
6595 these cases, the relevant string is always treated as a regular expression; if
6596 it does not start with a circumflex, the expression is not anchored, and can
6597 match anywhere in the subject string.
6598
6599 In all cases, if you want a regular expression to match at the end of a string,
6600 you must code the $ metacharacter to indicate this. For example:
6601 .code
6602 domains = ^\\d{3}\\.example
6603 .endd
6604 matches the domain &'123.example'&, but it also matches &'123.example.com'&.
6605 You need to use:
6606 .code
6607 domains = ^\\d{3}\\.example\$
6608 .endd
6609 if you want &'example'& to be the top-level domain. The backslash before the
6610 $ is needed because string expansion also interprets dollar characters.
6611
6612
6613
6614 . ////////////////////////////////////////////////////////////////////////////
6615 . ////////////////////////////////////////////////////////////////////////////
6616
6617 .chapter "File and database lookups" "CHAPfdlookup"
6618 .scindex IIDfidalo1 "file" "lookups"
6619 .scindex IIDfidalo2 "database" "lookups"
6620 .cindex "lookup" "description of"
6621 Exim can be configured to look up data in files or databases as it processes
6622 messages. Two different kinds of syntax are used:
6623
6624 .olist
6625 A string that is to be expanded may contain explicit lookup requests. These
6626 cause parts of the string to be replaced by data that is obtained from the
6627 lookup. Lookups of this type are conditional expansion items. Different results
6628 can be defined for the cases of lookup success and failure. See chapter
6629 &<<CHAPexpand>>&, where string expansions are described in detail.
6630 The key for the lookup is &*specified*& as part of the string to be expanded.
6631 .next
6632 Lists of domains, hosts, and email addresses can contain lookup requests as a
6633 way of avoiding excessively long linear lists. In this case, the data that is
6634 returned by the lookup is often (but not always) discarded; whether the lookup
6635 succeeds or fails is what really counts. These kinds of list are described in
6636 chapter &<<CHAPdomhosaddlists>>&.
6637 Depending on the lookup type (see below)
6638 the key for the lookup may need to be &*specified*& as above
6639 or may be &*implicit*&,
6640 given by the context in which the list is being checked.
6641 .endlist
6642
6643 String expansions, lists, and lookups interact with each other in such a way
6644 that there is no order in which to describe any one of them that does not
6645 involve references to the others. Each of these three chapters makes more sense
6646 if you have read the other two first. If you are reading this for the first
6647 time, be aware that some of it will make a lot more sense after you have read
6648 chapters &<<CHAPdomhosaddlists>>& and &<<CHAPexpand>>&.
6649
6650 .section "Examples of different lookup syntax" "SECID60"
6651 It is easy to confuse the two different kinds of lookup, especially as the
6652 lists that may contain the second kind are always expanded before being
6653 processed as lists. Therefore, they may also contain lookups of the first kind.
6654 Be careful to distinguish between the following two examples:
6655 .code
6656 domains = ${lookup{$sender_host_address}lsearch{/some/file}}
6657 domains = lsearch;/some/file
6658 .endd
6659 .ilist
6660 The first uses a string expansion, the result of which must be a domain list.
6661 The key for an expansion-style lookup must be given explicitly.
6662 No strings have been specified for a successful or a failing lookup; the
6663 defaults in this case are the looked-up data and an empty string, respectively.
6664 The expansion takes place before the string is processed as a list, and the
6665 file that is searched could contain lines like this:
6666 .code
6667 192.168.3.4: domain1:domain2:...
6668 192.168.1.9: domain3:domain4:...
6669 .endd
6670 When the lookup succeeds, the result of the expansion is a list of domains (and
6671 possibly other types of item that are allowed in domain lists).
6672 .cindex "tainted data" "de-tainting"
6673 .cindex "de-tainting" "using a lookup expansion"
6674 The result of the expansion is not tainted.
6675
6676 .next
6677 In the second example, the lookup is a single item in a domain list. It causes
6678 Exim to use a lookup to see if the domain that is being processed can be found
6679 in the file.
6680 The file could contains lines like this:
6681 .code
6682 domain1:
6683 domain2:
6684 .endd
6685 Any data that follows the keys is not relevant when checking that the domain
6686 matches the list item.
6687
6688 The key for a list-style lookup is implicit, from the lookup context, if
6689 the lookup is a single-key type (see below).
6690 For query-style lookup types the query must be given explicitly.
6691 .endlist
6692
6693 It is possible, though no doubt confusing, to use both kinds of lookup at once.
6694 Consider a file containing lines like this:
6695 .code
6696 192.168.5.6: lsearch;/another/file
6697 .endd
6698 If the value of &$sender_host_address$& is 192.168.5.6, expansion of the
6699 first &%domains%& setting above generates the second setting, which therefore
6700 causes a second lookup to occur.
6701
6702 The lookup type may optionally be followed by a comma
6703 and a comma-separated list of options.
6704 Each option is a &"name=value"& pair.
6705 Whether an option is meaningful depends on the lookup type.
6706
6707 All lookups support the option &"cache=no_rd"&.
6708 If this is given then the cache that Exim manages for lookup results
6709 is not checked before doing the lookup.
6710 The result of the lookup is still written to the cache.
6711
6712 The rest of this chapter describes the different lookup types that are
6713 available. Any of them can be used in any part of the configuration where a
6714 lookup is permitted.
6715
6716
6717 .section "Lookup types" "SECID61"
6718 .cindex "lookup" "types of"
6719 .cindex "single-key lookup" "definition of"
6720 Two different types of data lookup are implemented:
6721
6722 .ilist
6723 The &'single-key'& type requires the specification of a file in which to look,
6724 and a single key to search for. The key must be a non-empty string for the
6725 lookup to succeed. The lookup type determines how the file is searched.
6726 .cindex "tainted data" "single-key lookups"
6727 The file string may not be tainted.
6728
6729 .cindex "tainted data" "de-tainting"
6730 .cindex "de-tainting" "using a single-key lookup"
6731 All single-key lookups support the option &"ret=key"&.
6732 If this is given and the lookup
6733 (either underlying implementation or cached value)
6734 returns data, the result is replaced with a non-tainted
6735 version of the lookup key.
6736
6737 .next
6738 .cindex "query-style lookup" "definition of"
6739 The &'query-style'& type accepts a generalized database query. No particular
6740 key value is assumed by Exim for query-style lookups. You can use whichever
6741 Exim variables you need to construct the database query.
6742
6743 For the string-expansion kind of lookups, the query is given in the first
6744 bracketed argument of the &${lookup ...}$& expansion.
6745 For the list-argument kind of lookup the quury is given by the remainder of the
6746 list item after the first semicolon.
6747
6748 .cindex "tainted data" "quoting for lookups"
6749 If tainted data is used in the query then it should be quuted by
6750 using the &*${quote_*&<&'lookup-type'&>&*:*&<&'string'&>&*}*& expansion operator
6751 appropriate for the lookup.
6752 .endlist
6753
6754 The code for each lookup type is in a separate source file that is included in
6755 the binary of Exim only if the corresponding compile-time option is set. The
6756 default settings in &_src/EDITME_& are:
6757 .code
6758 LOOKUP_DBM=yes
6759 LOOKUP_LSEARCH=yes
6760 .endd
6761 which means that only linear searching and DBM lookups are included by default.
6762 For some types of lookup (e.g. SQL databases), you need to install appropriate
6763 libraries and header files before building Exim.
6764
6765
6766
6767
6768 .section "Single-key lookup types" "SECTsinglekeylookups"
6769 .cindex "lookup" "single-key types"
6770 .cindex "single-key lookup" "list of types"
6771 The following single-key lookup types are implemented:
6772
6773 .subsection cdb
6774 .cindex "cdb" "description of"
6775 .cindex "lookup" "cdb"
6776 .cindex "binary zero" "in lookup key"
6777 The given file is searched as a Constant DataBase file, using the key
6778 string without a terminating binary zero. The cdb format is designed for
6779 indexed files that are read frequently and never updated, except by total
6780 re-creation. As such, it is particularly suitable for large files containing
6781 aliases or other indexed data referenced by an MTA. Information about cdb and
6782 tools for building the files can be found in several places:
6783 .display
6784 &url(https://cr.yp.to/cdb.html)
6785 &url(https://www.corpit.ru/mjt/tinycdb.html)
6786 &url(https://packages.debian.org/stable/utils/freecdb)
6787 &url(https://github.com/philpennock/cdbtools) (in Go)
6788 .endd
6789 A cdb distribution is not needed in order to build Exim with cdb support,
6790 because the code for reading cdb files is included directly in Exim itself.
6791 However, no means of building or testing cdb files is provided with Exim, so
6792 you need to obtain a cdb distribution in order to do this.
6793
6794 .subsection dbm
6795 .cindex "DBM" "lookup type"
6796 .cindex "lookup" "dbm"
6797 .cindex "binary zero" "in lookup key"
6798 Calls to DBM library functions are used to extract data from the given
6799 DBM file by looking up the record with the given key. A terminating binary
6800 zero is included in the key that is passed to the DBM library. See section
6801 &<<SECTdb>>& for a discussion of DBM libraries.
6802
6803 .cindex "Berkeley DB library" "file format"
6804 For all versions of Berkeley DB, Exim uses the DB_HASH style of database
6805 when building DBM files using the &%exim_dbmbuild%& utility. However, when
6806 using Berkeley DB versions 3 or 4, it opens existing databases for reading with
6807 the DB_UNKNOWN option. This enables it to handle any of the types of database
6808 that the library supports, and can be useful for accessing DBM files created by
6809 other applications. (For earlier DB versions, DB_HASH is always used.)
6810
6811 .subsection dbmjz
6812 .cindex "lookup" "dbmjz"
6813 .cindex "lookup" "dbm &-- embedded NULs"
6814 .cindex "sasldb2"
6815 .cindex "dbmjz lookup type"
6816 This is the same as &(dbm)&, except that the lookup key is
6817 interpreted as an Exim list; the elements of the list are joined together with
6818 ASCII NUL characters to form the lookup key.  An example usage would be to
6819 authenticate incoming SMTP calls using the passwords from Cyrus SASL's
6820 &_/etc/sasldb2_& file with the &(gsasl)& authenticator or Exim's own
6821 &(cram_md5)& authenticator.
6822
6823 .subsection dbmnz
6824 .cindex "lookup" "dbmnz"
6825 .cindex "lookup" "dbm &-- terminating zero"
6826 .cindex "binary zero" "in lookup key"
6827 .cindex "Courier"
6828 .cindex "&_/etc/userdbshadow.dat_&"
6829 .cindex "dbmnz lookup type"
6830 This is the same as &(dbm)&, except that a terminating binary zero
6831 is not included in the key that is passed to the DBM library. You may need this
6832 if you want to look up data in files that are created by or shared with some
6833 other application that does not use terminating zeros. For example, you need to
6834 use &(dbmnz)& rather than &(dbm)& if you want to authenticate incoming SMTP
6835 calls using the passwords from Courier's &_/etc/userdbshadow.dat_& file. Exim's
6836 utility program for creating DBM files (&'exim_dbmbuild'&) includes the zeros
6837 by default, but has an option to omit them (see section &<<SECTdbmbuild>>&).
6838
6839 .subsection dsearch
6840 .cindex "lookup" "dsearch"
6841 .cindex "dsearch lookup type"
6842 The given file must be an absolute directory path; this is searched for an entry
6843 whose name is the key by calling the &[lstat()]& function.
6844 The key may not contain any forward slash characters.
6845 If &[lstat()]& succeeds then so does the lookup.
6846 .cindex "tainted data" "dsearch result"
6847 The result is regarded as untainted.
6848
6849 Options for the lookup can be given by appending them after the word "dsearch",
6850 separated by a comma.  Options, if present, are a comma-separated list having
6851 each element starting with a tag name and an equals.
6852
6853 Two options are supported, for the return value and for filtering match
6854 candidates.
6855 The "ret" option requests an alternate result value of
6856 the entire path for the entry. Example:
6857 .code
6858 ${lookup {passwd} dsearch,ret=full {/etc}}
6859 .endd
6860 The default result is just the requested entry.
6861 The "filter" option requests that only directory entries of a given type
6862 are matched. The match value is one of "file", "dir" or "subdir" (the latter
6863 not matching "." or ".."). Example:
6864 .code
6865 ${lookup {passwd} dsearch,filter=file {/etc}}
6866 .endd
6867 The default matching is for any entry type, including directories
6868 and symlinks.
6869
6870 An example of how this
6871 lookup can be used to support virtual domains is given in section
6872 &<<SECTvirtualdomains>>&.
6873
6874 .subsection iplsearch
6875 .cindex "lookup" "iplsearch"
6876 .cindex "iplsearch lookup type"
6877 The given file is a text file containing keys and data. A key is
6878 terminated by a colon or white space or the end of the line. The keys in the
6879 file must be IP addresses, or IP addresses with CIDR masks. Keys that involve
6880 IPv6 addresses must be enclosed in quotes to prevent the first internal colon
6881 being interpreted as a key terminator. For example:
6882 .code
6883 1.2.3.4:           data for 1.2.3.4
6884 192.168.0.0/16:    data for 192.168.0.0/16
6885 "abcd::cdab":      data for abcd::cdab
6886 "abcd:abcd::/32"   data for abcd:abcd::/32
6887 .endd
6888 The key for an &(iplsearch)& lookup must be an IP address (without a mask). The
6889 file is searched linearly, using the CIDR masks where present, until a matching
6890 key is found. The first key that matches is used; there is no attempt to find a
6891 &"best"& match. Apart from the way the keys are matched, the processing for
6892 &(iplsearch)& is the same as for &(lsearch)&.
6893
6894 &*Warning 1*&: Unlike most other single-key lookup types, a file of data for
6895 &(iplsearch)& can &'not'& be turned into a DBM or cdb file, because those
6896 lookup types support only literal keys.
6897
6898 &*Warning 2*&: In a host list, you must always use &(net-iplsearch)& so that
6899 the implicit key is the host's IP address rather than its name (see section
6900 &<<SECThoslispatsikey>>&).
6901
6902 &*Warning 3*&: Do not use an IPv4-mapped IPv6 address for a key; use the
6903 IPv4, in dotted-quad form. (Exim converts IPv4-mapped IPv6 addresses to this
6904 notation before executing the lookup.)
6905
6906 One option is supported, "ret=full", to request the return of the entire line
6907 rather than omitting the key portion.
6908 Note however that the key portion will have been de-quoted.
6909
6910 .subsection json
6911 .cindex lookup json
6912 .cindex json "lookup type"
6913 .cindex JSON expansions
6914 The given file is a text file with a JSON structure.
6915 An element of the structure is extracted, defined by the search key.
6916 The key is a list of subelement selectors
6917 (colon-separated by default but changeable in the usual way)
6918 which are applied in turn to select smaller and smaller portions
6919 of the JSON structure.
6920 If a selector is numeric, it must apply to a JSON array; the (zero-based)
6921 nunbered array element is selected.
6922 Otherwise it must apply to a JSON object; the named element is selected.
6923 The final resulting element can be a simple JSON type or a JSON object
6924 or array; for the latter two a string-representation of the JSON
6925 is returned.
6926 For elements of type string, the returned value is de-quoted.
6927
6928
6929 .subsection lmdb
6930 .cindex LMDB
6931 .cindex lookup lmdb
6932 .cindex database lmdb
6933 The given file is an LMDB database.
6934 LMDB is a memory-mapped key-value store,
6935 with API modeled loosely on that of BerkeleyDB.
6936 See &url(https://symas.com/products/lightning-memory-mapped-database/)
6937 for the feature set and operation modes.
6938
6939 Exim provides read-only access via the LMDB C library.
6940 The library can be obtained from &url(https://github.com/LMDB/lmdb)
6941 or your operating system package repository.
6942 To enable LMDB support in Exim set LOOKUP_LMDB=yes in &_Local/Makefile_&.
6943
6944 You will need to separately create the LMDB database file,
6945 possibly using the &"mdb_load"& utility.
6946
6947
6948 .subsection lsearch
6949 .cindex "linear search"
6950 .cindex "lookup" "lsearch"
6951 .cindex "lsearch lookup type"
6952 .cindex "case sensitivity" "in lsearch lookup"
6953 The given file is a text file that is searched linearly for a
6954 line beginning with the search key, terminated by a colon or white space or the
6955 end of the line. The search is case-insensitive; that is, upper and lower case
6956 letters are treated as the same. The first occurrence of the key that is found
6957 in the file is used.
6958
6959 White space between the key and the colon is permitted. The remainder of the
6960 line, with leading and trailing white space removed, is the data. This can be
6961 continued onto subsequent lines by starting them with any amount of white
6962 space, but only a single space character is included in the data at such a
6963 junction. If the data begins with a colon, the key must be terminated by a
6964 colon, for example:
6965 .code
6966 baduser:  :fail:
6967 .endd
6968 Empty lines and lines beginning with # are ignored, even if they occur in the
6969 middle of an item. This is the traditional textual format of alias files. Note
6970 that the keys in an &(lsearch)& file are literal strings. There is no
6971 wildcarding of any kind.
6972
6973 .cindex "lookup" "lsearch &-- colons in keys"
6974 .cindex "white space" "in lsearch key"
6975 In most &(lsearch)& files, keys are not required to contain colons or #
6976 characters, or white space. However, if you need this feature, it is available.
6977 If a key begins with a doublequote character, it is terminated only by a
6978 matching quote (or end of line), and the normal escaping rules apply to its
6979 contents (see section &<<SECTstrings>>&). An optional colon is permitted after
6980 quoted keys (exactly as for unquoted keys). There is no special handling of
6981 quotes for the data part of an &(lsearch)& line.
6982
6983 .subsection nis
6984 .cindex "NIS lookup type"
6985 .cindex "lookup" "NIS"
6986 .cindex "binary zero" "in lookup key"
6987 The given file is the name of a NIS map, and a NIS lookup is done with
6988 the given key, without a terminating binary zero. There is a variant called
6989 &(nis0)& which does include the terminating binary zero in the key. This is
6990 reportedly needed for Sun-style alias files. Exim does not recognize NIS
6991 aliases; the full map names must be used.
6992
6993 .subsection (n)wildlsearch
6994 .cindex "wildlsearch lookup type"
6995 .cindex "lookup" "wildlsearch"
6996 .cindex "nwildlsearch lookup type"
6997 .cindex "lookup" "nwildlsearch"
6998 &(wildlsearch)& or &(nwildlsearch)&: These search a file linearly, like
6999 &(lsearch)&, but instead of being interpreted as a literal string, each key in
7000 the file may be wildcarded. The difference between these two lookup types is
7001 that for &(wildlsearch)&, each key in the file is string-expanded before being
7002 used, whereas for &(nwildlsearch)&, no expansion takes place.
7003
7004 .cindex "case sensitivity" "in (n)wildlsearch lookup"
7005 Like &(lsearch)&, the testing is done case-insensitively. However, keys in the
7006 file that are regular expressions can be made case-sensitive by the use of
7007 &`(-i)`& within the pattern. The following forms of wildcard are recognized:
7008
7009 .olist
7010 The string may begin with an asterisk to mean &"ends with"&. For example:
7011 .code
7012 *.a.b.c       data for anything.a.b.c
7013 *fish         data for anythingfish
7014 .endd
7015 .next
7016 The string may begin with a circumflex to indicate a regular expression. For
7017 example, for &(wildlsearch)&:
7018 .code
7019 ^\N\d+\.a\.b\N    data for <digits>.a.b
7020 .endd
7021 Note the use of &`\N`& to disable expansion of the contents of the regular
7022 expression. If you are using &(nwildlsearch)&, where the keys are not
7023 string-expanded, the equivalent entry is:
7024 .code
7025 ^\d+\.a\.b        data for <digits>.a.b
7026 .endd
7027 The case-insensitive flag is set at the start of compiling the regular
7028 expression, but it can be turned off by using &`(-i)`& at an appropriate point.
7029 For example, to make the entire pattern case-sensitive:
7030 .code
7031 ^(?-i)\d+\.a\.b        data for <digits>.a.b
7032 .endd
7033
7034 If the regular expression contains white space or colon characters, you must
7035 either quote it (see &(lsearch)& above), or represent these characters in other
7036 ways. For example, &`\s`& can be used for white space and &`\x3A`& for a
7037 colon. This may be easier than quoting, because if you quote, you have to
7038 escape all the backslashes inside the quotes.
7039
7040 &*Note*&: It is not possible to capture substrings in a regular expression
7041 match for later use, because the results of all lookups are cached. If a lookup
7042 is repeated, the result is taken from the cache, and no actual pattern matching
7043 takes place. The values of all the numeric variables are unset after a
7044 &((n)wildlsearch)& match.
7045
7046 .next
7047 Although I cannot see it being of much use, the general matching function that
7048 is used to implement &((n)wildlsearch)& means that the string may begin with a
7049 lookup name terminated by a semicolon, and followed by lookup data. For
7050 example:
7051 .code
7052 cdb;/some/file  data for keys that match the file
7053 .endd
7054 The data that is obtained from the nested lookup is discarded.
7055 .endlist olist
7056
7057 Keys that do not match any of these patterns are interpreted literally. The
7058 continuation rules for the data are the same as for &(lsearch)&, and keys may
7059 be followed by optional colons.
7060
7061 &*Warning*&: Unlike most other single-key lookup types, a file of data for
7062 &((n)wildlsearch)& can &'not'& be turned into a DBM or cdb file, because those
7063 lookup types support only literal keys.
7064
7065 .subsection spf
7066 .cindex "spf lookup type"
7067 .cindex "lookup" "spf"
7068 If Exim is built with SPF support, manual lookups can be done
7069 (as opposed to the standard ACL condition method).
7070 For details see section &<<SECSPF>>&.
7071
7072
7073 .section "Query-style lookup types" "SECTquerystylelookups"
7074 .cindex "lookup" "query-style types"
7075 .cindex "query-style lookup" "list of types"
7076 The supported query-style lookup types are listed below. Further details about
7077 many of them are given in later sections.
7078
7079 .subsection dnsdb
7080 .cindex "DNS" "as a lookup type"
7081 .cindex "lookup" "DNS"
7082 This does a DNS search for one or more records whose domain names
7083 are given in the supplied query. The resulting data is the contents of the
7084 records. See section &<<SECTdnsdb>>&.
7085
7086 .subsection ibase
7087 .cindex "InterBase lookup type"
7088 .cindex "lookup" "InterBase"
7089 This does a lookup in an InterBase database.
7090
7091 .subsection ldap
7092 .cindex "LDAP" "lookup type"
7093 .cindex "lookup" "LDAP"
7094 This does an LDAP lookup using a query in the form of a URL, and
7095 returns attributes from a single entry. There is a variant called &(ldapm)&
7096 that permits values from multiple entries to be returned. A third variant
7097 called &(ldapdn)& returns the Distinguished Name of a single entry instead of
7098 any attribute values. See section &<<SECTldap>>&.
7099
7100 .subsection mysql
7101 .cindex "MySQL" "lookup type"
7102 .cindex "lookup" "MySQL"
7103 The format of the query is an SQL statement that is passed to a
7104 MySQL database. See section &<<SECTsql>>&.
7105
7106 .subsection nisplus
7107 .cindex "NIS+ lookup type"
7108 .cindex "lookup" "NIS+"
7109 This does a NIS+ lookup using a query that can specify the name of
7110 the field to be returned. See section &<<SECTnisplus>>&.
7111
7112 .subsection oracle
7113 .cindex "Oracle" "lookup type"
7114 .cindex "lookup" "Oracle"
7115 The format of the query is an SQL statement that is passed to an
7116 Oracle database. See section &<<SECTsql>>&.
7117
7118 .subsection passwd
7119 .cindex "lookup" "passwd"
7120 .cindex "passwd lookup type"
7121 .cindex "&_/etc/passwd_&"
7122 This is a query-style lookup with queries that are just user names. The
7123 lookup calls &[getpwnam()]& to interrogate the system password data, and on
7124 success, the result string is the same as you would get from an &(lsearch)&
7125 lookup on a traditional &_/etc/passwd file_&, though with &`*`& for the
7126 password value. For example:
7127 .code
7128 *:42:42:King Rat:/home/kr:/bin/bash
7129 .endd
7130
7131 .subsection pgsql
7132 .cindex "PostgreSQL lookup type"
7133 .cindex "lookup" "PostgreSQL"
7134 The format of the query is an SQL statement that is passed to a
7135 PostgreSQL database. See section &<<SECTsql>>&.
7136
7137 .subsection redis
7138 .cindex "Redis lookup type"
7139 .cindex lookup Redis
7140 The format of the query is either a simple get or simple set,
7141 passed to a Redis database. See section &<<SECTsql>>&.
7142
7143 .subsection sqlite
7144 .cindex "sqlite lookup type"
7145 .cindex "lookup" "sqlite"
7146 The format of the query is
7147 an SQL statement that is passed to an SQLite database. See section &<<SECTsqlite>>&.
7148
7149 .subsection testdb
7150 This is a lookup type that is used for testing Exim. It is
7151 not likely to be useful in normal operation.
7152
7153 .subsection whoson
7154 .cindex "whoson lookup type"
7155 .cindex "lookup" "whoson"
7156 &'Whoson'& (&url(http://whoson.sourceforge.net)) is a protocol that
7157 allows a server to check whether a particular (dynamically allocated) IP
7158 address is currently allocated to a known (trusted) user and, optionally, to
7159 obtain the identity of the said user. For SMTP servers, &'Whoson'& was popular
7160 at one time for &"POP before SMTP"& authentication, but that approach has been
7161 superseded by SMTP authentication. In Exim, &'Whoson'& can be used to implement
7162 &"POP before SMTP"& checking using ACL statements such as
7163 .code
7164 require condition = \
7165   ${lookup whoson {$sender_host_address}{yes}{no}}
7166 .endd
7167 The query consists of a single IP address. The value returned is the name of
7168 the authenticated user, which is stored in the variable &$value$&. However, in
7169 this example, the data in &$value$& is not used; the result of the lookup is
7170 one of the fixed strings &"yes"& or &"no"&.
7171
7172
7173
7174 .section "Temporary errors in lookups" "SECID63"
7175 .cindex "lookup" "temporary error in"
7176 Lookup functions can return temporary error codes if the lookup cannot be
7177 completed. For example, an SQL or LDAP database might be unavailable. For this
7178 reason, it is not advisable to use a lookup that might do this for critical
7179 options such as a list of local domains.
7180
7181 When a lookup cannot be completed in a router or transport, delivery
7182 of the message (to the relevant address) is deferred, as for any other
7183 temporary error. In other circumstances Exim may assume the lookup has failed,
7184 or may give up altogether.
7185
7186
7187
7188 .section "Default values in single-key lookups" "SECTdefaultvaluelookups"
7189 .cindex "wildcard lookups"
7190 .cindex "lookup" "default values"
7191 .cindex "lookup" "wildcard"
7192 .cindex "lookup" "* added to type"
7193 .cindex "default" "in single-key lookups"
7194 In this context, a &"default value"& is a value specified by the administrator
7195 that is to be used if a lookup fails.
7196
7197 &*Note:*& This section applies only to single-key lookups. For query-style
7198 lookups, the facilities of the query language must be used. An attempt to
7199 specify a default for a query-style lookup provokes an error.
7200
7201 If &"*"& is added to a single-key lookup type (for example, &%lsearch*%&)
7202 and the initial lookup fails, the key &"*"& is looked up in the file to
7203 provide a default value. See also the section on partial matching below.
7204
7205 .cindex "*@ with single-key lookup"
7206 .cindex "lookup" "*@ added to type"
7207 .cindex "alias file" "per-domain default"
7208 Alternatively, if &"*@"& is added to a single-key lookup type (for example
7209 &%dbm*@%&) then, if the initial lookup fails and the key contains an @
7210 character, a second lookup is done with everything before the last @ replaced
7211 by *. This makes it possible to provide per-domain defaults in alias files
7212 that include the domains in the keys. If the second lookup fails (or doesn't
7213 take place because there is no @ in the key), &"*"& is looked up.
7214 For example, a &(redirect)& router might contain:
7215 .code
7216 data = ${lookup{$local_part@$domain}lsearch*@{/etc/mix-aliases}}
7217 .endd
7218 Suppose the address that is being processed is &'jane@eyre.example'&. Exim
7219 looks up these keys, in this order:
7220 .code
7221 jane@eyre.example
7222 *@eyre.example
7223 *
7224 .endd
7225 The data is taken from whichever key it finds first. &*Note*&: In an
7226 &(lsearch)& file, this does not mean the first of these keys in the file. A
7227 complete scan is done for each key, and only if it is not found at all does
7228 Exim move on to try the next key.
7229
7230
7231
7232 .section "Partial matching in single-key lookups" "SECTpartiallookup"
7233 .cindex "partial matching"
7234 .cindex "wildcard lookups"
7235 .cindex "lookup" "partial matching"
7236 .cindex "lookup" "wildcard"
7237 .cindex "asterisk" "in search type"
7238 The normal operation of a single-key lookup is to search the file for an exact
7239 match with the given key. However, in a number of situations where domains are
7240 being looked up, it is useful to be able to do partial matching. In this case,
7241 information in the file that has a key starting with &"*."& is matched by any
7242 domain that ends with the components that follow the full stop. For example, if
7243 a key in a DBM file is
7244 .code
7245 *.dates.fict.example
7246 .endd
7247 then when partial matching is enabled this is matched by (amongst others)
7248 &'2001.dates.fict.example'& and &'1984.dates.fict.example'&. It is also matched
7249 by &'dates.fict.example'&, if that does not appear as a separate key in the
7250 file.
7251
7252 &*Note*&: Partial matching is not available for query-style lookups. It is
7253 also not available for any lookup items in address lists (see section
7254 &<<SECTaddresslist>>&).
7255
7256 Partial matching is implemented by doing a series of separate lookups using
7257 keys constructed by modifying the original subject key. This means that it can
7258 be used with any of the single-key lookup types, provided that
7259 partial matching keys
7260 beginning with a special prefix (default &"*."&) are included in the data file.
7261 Keys in the file that do not begin with the prefix are matched only by
7262 unmodified subject keys when partial matching is in use.
7263
7264 Partial matching is requested by adding the string &"partial-"& to the front of
7265 the name of a single-key lookup type, for example, &%partial-dbm%&. When this
7266 is done, the subject key is first looked up unmodified; if that fails, &"*."&
7267 is added at the start of the subject key, and it is looked up again. If that
7268 fails, further lookups are tried with dot-separated components removed from the
7269 start of the subject key, one-by-one, and &"*."& added on the front of what
7270 remains.
7271
7272 A minimum number of two non-* components are required. This can be adjusted
7273 by including a number before the hyphen in the search type. For example,
7274 &%partial3-lsearch%& specifies a minimum of three non-* components in the
7275 modified keys. Omitting the number is equivalent to &"partial2-"&. If the
7276 subject key is &'2250.dates.fict.example'& then the following keys are looked
7277 up when the minimum number of non-* components is two:
7278 .code
7279 2250.dates.fict.example
7280 *.2250.dates.fict.example
7281 *.dates.fict.example
7282 *.fict.example
7283 .endd
7284 As soon as one key in the sequence is successfully looked up, the lookup
7285 finishes.
7286
7287 .cindex "lookup" "partial matching &-- changing prefix"
7288 .cindex "prefix" "for partial matching"
7289 The use of &"*."& as the partial matching prefix is a default that can be
7290 changed. The motivation for this feature is to allow Exim to operate with file
7291 formats that are used by other MTAs. A different prefix can be supplied in
7292 parentheses instead of the hyphen after &"partial"&. For example:
7293 .code
7294 domains = partial(.)lsearch;/some/file
7295 .endd
7296 In this example, if the domain is &'a.b.c'&, the sequence of lookups is
7297 &`a.b.c`&, &`.a.b.c`&, and &`.b.c`& (the default minimum of 2 non-wild
7298 components is unchanged). The prefix may consist of any punctuation characters
7299 other than a closing parenthesis. It may be empty, for example:
7300 .code
7301 domains = partial1()cdb;/some/file
7302 .endd
7303 For this example, if the domain is &'a.b.c'&, the sequence of lookups is
7304 &`a.b.c`&, &`b.c`&, and &`c`&.
7305
7306 If &"partial0"& is specified, what happens at the end (when the lookup with
7307 just one non-wild component has failed, and the original key is shortened right
7308 down to the null string) depends on the prefix:
7309
7310 .ilist
7311 If the prefix has zero length, the whole lookup fails.
7312 .next
7313 If the prefix has length 1, a lookup for just the prefix is done. For
7314 example, the final lookup for &"partial0(.)"& is for &`.`& alone.
7315 .next
7316 Otherwise, if the prefix ends in a dot, the dot is removed, and the
7317 remainder is looked up. With the default prefix, therefore, the final lookup is
7318 for &"*"& on its own.
7319 .next
7320 Otherwise, the whole prefix is looked up.
7321 .endlist
7322
7323
7324 If the search type ends in &"*"& or &"*@"& (see section
7325 &<<SECTdefaultvaluelookups>>& above), the search for an ultimate default that
7326 this implies happens after all partial lookups have failed. If &"partial0"& is
7327 specified, adding &"*"& to the search type has no effect with the default
7328 prefix, because the &"*"& key is already included in the sequence of partial
7329 lookups. However, there might be a use for lookup types such as
7330 &"partial0(.)lsearch*"&.
7331
7332 The use of &"*"& in lookup partial matching differs from its use as a wildcard
7333 in domain lists and the like. Partial matching works only in terms of
7334 dot-separated components; a key such as &`*fict.example`&
7335 in a database file is useless, because the asterisk in a partial matching
7336 subject key is always followed by a dot.
7337
7338 When the lookup is done from a string-expansion,
7339 the variables &$1$& and &$2$& contain the wild and non-wild parts of the key
7340 during the expansion of the replacement text.
7341 They return to their previous values at the end of the lookup item.
7342
7343
7344
7345
7346 .section "Lookup caching" "SECID64"
7347 .cindex "lookup" "caching"
7348 .cindex "caching" "lookup data"
7349 Exim caches all lookup results in order to avoid needless repetition of
7350 lookups. However, because (apart from the daemon) Exim operates as a collection
7351 of independent, short-lived processes, this caching applies only within a
7352 single Exim process. There is no inter-process lookup caching facility.
7353
7354 If an option &"cache=no_rd"& is used on the lookup then
7355 the cache is only written to, cached data is not used for the operation
7356 and a real lookup is done.
7357
7358 For single-key lookups, Exim keeps the relevant files open in case there is
7359 another lookup that needs them. In some types of configuration this can lead to
7360 many files being kept open for messages with many recipients. To avoid hitting
7361 the operating system limit on the number of simultaneously open files, Exim
7362 closes the least recently used file when it needs to open more files than its
7363 own internal limit, which can be changed via the &%lookup_open_max%& option.
7364
7365 The single-key lookup files are closed and the lookup caches are flushed at
7366 strategic points during delivery &-- for example, after all routing is
7367 complete.
7368
7369
7370
7371
7372 .section "Quoting lookup data" "SECID65"
7373 .cindex "lookup" "quoting"
7374 .cindex "quoting" "in lookups"
7375 When data from an incoming message is included in a query-style lookup, there
7376 is the possibility of special characters in the data messing up the syntax of
7377 the query. For example, a NIS+ query that contains
7378 .code
7379 [name=$local_part]
7380 .endd
7381 will be broken if the local part happens to contain a closing square bracket.
7382 For NIS+, data can be enclosed in double quotes like this:
7383 .code
7384 [name="$local_part"]
7385 .endd
7386 but this still leaves the problem of a double quote in the data. The rule for
7387 NIS+ is that double quotes must be doubled. Other lookup types have different
7388 rules, and to cope with the differing requirements, an expansion operator
7389 of the following form is provided:
7390 .code
7391 ${quote_<lookup-type>:<string>}
7392 .endd
7393 For example, the way to write the NIS+ query is
7394 .code
7395 [name="${quote_nisplus:$local_part}"]
7396 .endd
7397 .cindex "tainted data" "in lookups"
7398 &*All*& tainted data used in a query-style lookup must be quoted
7399 using a mechanism appropriate for the lookup type.
7400 See chapter &<<CHAPexpand>>& for full coverage of string expansions. The quote
7401 operator can be used for all lookup types, but has no effect for single-key
7402 lookups, since no quoting is ever needed in their key strings.
7403
7404
7405
7406
7407 .section "More about dnsdb" "SECTdnsdb"
7408 .cindex "dnsdb lookup"
7409 .cindex "lookup" "dnsdb"
7410 .cindex "DNS" "as a lookup type"
7411 The &(dnsdb)& lookup type uses the DNS as its database. A simple query consists
7412 of a record type and a domain name, separated by an equals sign. For example,
7413 an expansion string could contain:
7414 .code
7415 ${lookup dnsdb{mx=a.b.example}{$value}fail}
7416 .endd
7417 If the lookup succeeds, the result is placed in &$value$&, which in this case
7418 is used on its own as the result. If the lookup does not succeed, the
7419 &`fail`& keyword causes a &'forced expansion failure'& &-- see section
7420 &<<SECTforexpfai>>& for an explanation of what this means.
7421
7422 The supported DNS record types are A, CNAME, MX, NS, PTR, SOA, SPF, SRV, TLSA
7423 and TXT, and, when Exim is compiled with IPv6 support, AAAA.
7424 If no type is given, TXT is assumed.
7425
7426 For any record type, if multiple records are found, the data is returned as a
7427 concatenation, with newline as the default separator. The order, of course,
7428 depends on the DNS resolver. You can specify a different separator character
7429 between multiple records by putting a right angle-bracket followed immediately
7430 by the new separator at the start of the query. For example:
7431 .code
7432 ${lookup dnsdb{>: a=host1.example}}
7433 .endd
7434 It is permitted to specify a space as the separator character. Further
7435 white space is ignored.
7436 For lookup types that return multiple fields per record,
7437 an alternate field separator can be specified using a comma after the main
7438 separator character, followed immediately by the field separator.
7439
7440 .cindex "PTR record" "in &(dnsdb)& lookup"
7441 When the type is PTR,
7442 the data can be an IP address, written as normal; inversion and the addition of
7443 &%in-addr.arpa%& or &%ip6.arpa%& happens automatically. For example:
7444 .code
7445 ${lookup dnsdb{ptr=192.168.4.5}{$value}fail}
7446 .endd
7447 If the data for a PTR record is not a syntactically valid IP address, it is not
7448 altered and nothing is added.
7449
7450 .cindex "MX record" "in &(dnsdb)& lookup"
7451 .cindex "SRV record" "in &(dnsdb)& lookup"
7452 For an MX lookup, both the preference value and the host name are returned for
7453 each record, separated by a space. For an SRV lookup, the priority, weight,
7454 port, and host name are returned for each record, separated by spaces.
7455 The field separator can be modified as above.
7456
7457 .cindex "TXT record" "in &(dnsdb)& lookup"
7458 .cindex "SPF record" "in &(dnsdb)& lookup"
7459 For TXT records with multiple items of data, only the first item is returned,
7460 unless a field separator is specified.
7461 To concatenate items without a separator, use a semicolon instead.
7462 For SPF records the
7463 default behaviour is to concatenate multiple items without using a separator.
7464 .code
7465 ${lookup dnsdb{>\n,: txt=a.b.example}}
7466 ${lookup dnsdb{>\n; txt=a.b.example}}
7467 ${lookup dnsdb{spf=example.org}}
7468 .endd
7469 It is permitted to specify a space as the separator character. Further
7470 white space is ignored.
7471
7472 .cindex "SOA record" "in &(dnsdb)& lookup"
7473 For an SOA lookup, while no result is obtained the lookup is redone with
7474 successively more leading components dropped from the given domain.
7475 Only the primary-nameserver field is returned unless a field separator is
7476 specified.
7477 .code
7478 ${lookup dnsdb{>:,; soa=a.b.example.com}}
7479 .endd
7480
7481 .subsection "Dnsdb lookup modifiers" SECTdnsdb_mod
7482 .cindex "dnsdb modifiers"
7483 .cindex "modifiers" "dnsdb"
7484 .cindex "options" "dnsdb"
7485 Modifiers for &(dnsdb)& lookups are given by optional keywords,
7486 each followed by a comma,
7487 that may appear before the record type.
7488
7489 The &(dnsdb)& lookup fails only if all the DNS lookups fail. If there is a
7490 temporary DNS error for any of them, the behaviour is controlled by
7491 a defer-option modifier.
7492 The possible keywords are
7493 &"defer_strict"&, &"defer_never"&, and &"defer_lax"&.
7494 With &"strict"& behaviour, any temporary DNS error causes the
7495 whole lookup to defer. With &"never"& behaviour, a temporary DNS error is
7496 ignored, and the behaviour is as if the DNS lookup failed to find anything.
7497 With &"lax"& behaviour, all the queries are attempted, but a temporary DNS
7498 error causes the whole lookup to defer only if none of the other lookups
7499 succeed. The default is &"lax"&, so the following lookups are equivalent:
7500 .code
7501 ${lookup dnsdb{defer_lax,a=one.host.com:two.host.com}}
7502 ${lookup dnsdb{a=one.host.com:two.host.com}}
7503 .endd
7504 Thus, in the default case, as long as at least one of the DNS lookups
7505 yields some data, the lookup succeeds.
7506
7507 .cindex "DNSSEC" "dns lookup"
7508 Use of &(DNSSEC)& is controlled by a dnssec modifier.
7509 The possible keywords are
7510 &"dnssec_strict"&, &"dnssec_lax"&, and &"dnssec_never"&.
7511 With &"strict"& or &"lax"& DNSSEC information is requested
7512 with the lookup.
7513 With &"strict"& a response from the DNS resolver that
7514 is not labelled as authenticated data
7515 is treated as equivalent to a temporary DNS error.
7516 The default is &"lax"&.
7517
7518 See also the &$lookup_dnssec_authenticated$& variable.
7519
7520 .cindex timeout "dns lookup"
7521 .cindex "DNS" timeout
7522 Timeout for the dnsdb lookup can be controlled by a retrans modifier.
7523 The form is &"retrans_VAL"& where VAL is an Exim time specification
7524 (e.g. &"5s"&).
7525 The default value is set by the main configuration option &%dns_retrans%&.
7526
7527 Retries for the dnsdb lookup can be controlled by a retry modifier.
7528 The form if &"retry_VAL"& where VAL is an integer.
7529 The default count is set by the main configuration option &%dns_retry%&.
7530
7531 .cindex caching "of dns lookup"
7532 .cindex TTL "of dns lookup"
7533 .cindex DNS TTL
7534 Dnsdb lookup results are cached within a single process (and its children).
7535 The cache entry lifetime is limited to the smallest time-to-live (TTL)
7536 value of the set of returned DNS records.
7537
7538
7539 .subsection "Pseudo dnsdb record types" SECID66
7540 .cindex "MX record" "in &(dnsdb)& lookup"
7541 By default, both the preference value and the host name are returned for
7542 each MX record, separated by a space. If you want only host names, you can use
7543 the pseudo-type MXH:
7544 .code
7545 ${lookup dnsdb{mxh=a.b.example}}
7546 .endd
7547 In this case, the preference values are omitted, and just the host names are
7548 returned.
7549
7550 .cindex "name server for enclosing domain"
7551 Another pseudo-type is ZNS (for &"zone NS"&). It performs a lookup for NS
7552 records on the given domain, but if none are found, it removes the first
7553 component of the domain name, and tries again. This process continues until NS
7554 records are found or there are no more components left (or there is a DNS
7555 error). In other words, it may return the name servers for a top-level domain,
7556 but it never returns the root name servers. If there are no NS records for the
7557 top-level domain, the lookup fails. Consider these examples:
7558 .code
7559 ${lookup dnsdb{zns=xxx.quercite.com}}
7560 ${lookup dnsdb{zns=xxx.edu}}
7561 .endd
7562 Assuming that in each case there are no NS records for the full domain name,
7563 the first returns the name servers for &%quercite.com%&, and the second returns
7564 the name servers for &%edu%&.
7565
7566 You should be careful about how you use this lookup because, unless the
7567 top-level domain does not exist, the lookup always returns some host names. The
7568 sort of use to which this might be put is for seeing if the name servers for a
7569 given domain are on a blacklist. You can probably assume that the name servers
7570 for the high-level domains such as &%com%& or &%co.uk%& are not going to be on
7571 such a list.
7572
7573 .cindex "CSA" "in &(dnsdb)& lookup"
7574 A third pseudo-type is CSA (Client SMTP Authorization). This looks up SRV
7575 records according to the CSA rules, which are described in section
7576 &<<SECTverifyCSA>>&. Although &(dnsdb)& supports SRV lookups directly, this is
7577 not sufficient because of the extra parent domain search behaviour of CSA. The
7578 result of a successful lookup such as:
7579 .code
7580 ${lookup dnsdb {csa=$sender_helo_name}}
7581 .endd
7582 has two space-separated fields: an authorization code and a target host name.
7583 The authorization code can be &"Y"& for yes, &"N"& for no, &"X"& for explicit
7584 authorization required but absent, or &"?"& for unknown.
7585
7586 .cindex "A+" "in &(dnsdb)& lookup"
7587 The pseudo-type A+ performs an AAAA
7588 and then an A lookup.  All results are returned; defer processing
7589 (see below) is handled separately for each lookup.  Example:
7590 .code
7591 ${lookup dnsdb {>; a+=$sender_helo_name}}
7592 .endd
7593
7594
7595 .subsection "Multiple dnsdb lookups" SECID67
7596 In the previous sections, &(dnsdb)& lookups for a single domain are described.
7597 However, you can specify a list of domains or IP addresses in a single
7598 &(dnsdb)& lookup. The list is specified in the normal Exim way, with colon as
7599 the default separator, but with the ability to change this. For example:
7600 .code
7601 ${lookup dnsdb{one.domain.com:two.domain.com}}
7602 ${lookup dnsdb{a=one.host.com:two.host.com}}
7603 ${lookup dnsdb{ptr = <; 1.2.3.4 ; 4.5.6.8}}
7604 .endd
7605 In order to retain backwards compatibility, there is one special case: if
7606 the lookup type is PTR and no change of separator is specified, Exim looks
7607 to see if the rest of the string is precisely one IPv6 address. In this
7608 case, it does not treat it as a list.
7609
7610 The data from each lookup is concatenated, with newline separators by default,
7611 in the same way that multiple DNS records for a single item are handled. A
7612 different separator can be specified, as described above.
7613
7614
7615
7616
7617 .section "More about LDAP" "SECTldap"
7618 .cindex "LDAP" "lookup, more about"
7619 .cindex "lookup" "LDAP"
7620 .cindex "Solaris" "LDAP"
7621 The original LDAP implementation came from the University of Michigan; this has
7622 become &"Open LDAP"&, and there are now two different releases. Another
7623 implementation comes from Netscape, and Solaris 7 and subsequent releases
7624 contain inbuilt LDAP support. Unfortunately, though these are all compatible at
7625 the lookup function level, their error handling is different. For this reason
7626 it is necessary to set a compile-time variable when building Exim with LDAP, to
7627 indicate which LDAP library is in use. One of the following should appear in
7628 your &_Local/Makefile_&:
7629 .code
7630 LDAP_LIB_TYPE=UMICHIGAN
7631 LDAP_LIB_TYPE=OPENLDAP1
7632 LDAP_LIB_TYPE=OPENLDAP2
7633 LDAP_LIB_TYPE=NETSCAPE
7634 LDAP_LIB_TYPE=SOLARIS
7635 .endd
7636 If LDAP_LIB_TYPE is not set, Exim assumes &`OPENLDAP1`&, which has the
7637 same interface as the University of Michigan version.
7638
7639 There are three LDAP lookup types in Exim. These behave slightly differently in
7640 the way they handle the results of a query:
7641
7642 .ilist
7643 &(ldap)& requires the result to contain just one entry; if there are more, it
7644 gives an error.
7645 .next
7646 &(ldapdn)& also requires the result to contain just one entry, but it is the
7647 Distinguished Name that is returned rather than any attribute values.
7648 .next
7649 &(ldapm)& permits the result to contain more than one entry; the attributes
7650 from all of them are returned.
7651 .endlist
7652
7653
7654 For &(ldap)& and &(ldapm)&, if a query finds only entries with no attributes,
7655 Exim behaves as if the entry did not exist, and the lookup fails. The format of
7656 the data returned by a successful lookup is described in the next section.
7657 First we explain how LDAP queries are coded.
7658
7659
7660 .subsection "Format of LDAP queries" SECTforldaque
7661 .cindex "LDAP" "query format"
7662 An LDAP query takes the form of a URL as defined in RFC 2255. For example, in
7663 the configuration of a &(redirect)& router one might have this setting:
7664 .code
7665 data = ${lookup ldap \
7666   {ldap:///cn=$local_part,o=University%20of%20Cambridge,\
7667   c=UK?mailbox?base?}}
7668 .endd
7669 .cindex "LDAP" "with TLS"
7670 The URL may begin with &`ldap`& or &`ldaps`& if your LDAP library supports
7671 secure (encrypted) LDAP connections. The second of these ensures that an
7672 encrypted TLS connection is used.
7673
7674 With sufficiently modern LDAP libraries, Exim supports forcing TLS over regular
7675 LDAP connections, rather than the SSL-on-connect &`ldaps`&.
7676 See the &%ldap_start_tls%& option.
7677
7678 Starting with Exim 4.83, the initialization of LDAP with TLS is more tightly
7679 controlled. Every part of the TLS configuration can be configured by settings in
7680 &_exim.conf_&. Depending on the version of the client libraries installed on
7681 your system, some of the initialization may have required setting options in
7682 &_/etc/ldap.conf_& or &_~/.ldaprc_& to get TLS working with self-signed
7683 certificates. This revealed a nuance where the current UID that exim was
7684 running as could affect which config files it read. With Exim 4.83, these
7685 methods become optional, only taking effect if not specifically set in
7686 &_exim.conf_&.
7687
7688
7689 .subsection "LDAP quoting" SECID68
7690 .cindex "LDAP" "quoting"
7691 Two levels of quoting are required in LDAP queries, the first for LDAP itself
7692 and the second because the LDAP query is represented as a URL. Furthermore,
7693 within an LDAP query, two different kinds of quoting are required. For this
7694 reason, there are two different LDAP-specific quoting operators.
7695
7696 The &%quote_ldap%& operator is designed for use on strings that are part of
7697 filter specifications. Conceptually, it first does the following conversions on
7698 the string:
7699 .code
7700 *   =>   \2A
7701 (   =>   \28
7702 )   =>   \29
7703 \   =>   \5C
7704 .endd
7705 in accordance with RFC 2254. The resulting string is then quoted according
7706 to the rules for URLs, that is, all non-alphanumeric characters except
7707 .code
7708 ! $ ' - . _ ( ) * +
7709 .endd
7710 are converted to their hex values, preceded by a percent sign. For example:
7711 .code
7712 ${quote_ldap: a(bc)*, a<yz>; }
7713 .endd
7714 yields
7715 .code
7716 %20a%5C28bc%5C29%5C2A%2C%20a%3Cyz%3E%3B%20
7717 .endd
7718 Removing the URL quoting, this is (with a leading and a trailing space):
7719 .code
7720 a\28bc\29\2A, a<yz>;
7721 .endd
7722 The &%quote_ldap_dn%& operator is designed for use on strings that are part of
7723 base DN specifications in queries. Conceptually, it first converts the string
7724 by inserting a backslash in front of any of the following characters:
7725 .code
7726 , + " \ < > ;
7727 .endd
7728 It also inserts a backslash before any leading spaces or # characters, and
7729 before any trailing spaces. (These rules are in RFC 2253.) The resulting string
7730 is then quoted according to the rules for URLs. For example:
7731 .code
7732 ${quote_ldap_dn: a(bc)*, a<yz>; }
7733 .endd
7734 yields
7735 .code
7736 %5C%20a(bc)*%5C%2C%20a%5C%3Cyz%5C%3E%5C%3B%5C%20
7737 .endd
7738 Removing the URL quoting, this is (with a trailing space):
7739 .code
7740 \ a(bc)*\, a\<yz\>\;\
7741 .endd
7742 There are some further comments about quoting in the section on LDAP
7743 authentication below.
7744
7745
7746 .subsection "LDAP connections" SECID69
7747 .cindex "LDAP" "connections"
7748 The connection to an LDAP server may either be over TCP/IP, or, when OpenLDAP
7749 is in use, via a Unix domain socket. The example given above does not specify
7750 an LDAP server. A server that is reached by TCP/IP can be specified in a query
7751 by starting it with
7752 .code
7753 ldap://<hostname>:<port>/...
7754 .endd
7755 If the port (and preceding colon) are omitted, the standard LDAP port (389) is
7756 used. When no server is specified in a query, a list of default servers is
7757 taken from the &%ldap_default_servers%& configuration option. This supplies a
7758 colon-separated list of servers which are tried in turn until one successfully
7759 handles a query, or there is a serious error. Successful handling either
7760 returns the requested data, or indicates that it does not exist. Serious errors
7761 are syntactical, or multiple values when only a single value is expected.
7762 Errors which cause the next server to be tried are connection failures, bind
7763 failures, and timeouts.
7764
7765 For each server name in the list, a port number can be given. The standard way
7766 of specifying a host and port is to use a colon separator (RFC 1738). Because
7767 &%ldap_default_servers%& is a colon-separated list, such colons have to be
7768 doubled. For example
7769 .code
7770 ldap_default_servers = ldap1.example.com::145:ldap2.example.com
7771 .endd
7772 If &%ldap_default_servers%& is unset, a URL with no server name is passed
7773 to the LDAP library with no server name, and the library's default (normally
7774 the local host) is used.
7775
7776 If you are using the OpenLDAP library, you can connect to an LDAP server using
7777 a Unix domain socket instead of a TCP/IP connection. This is specified by using
7778 &`ldapi`& instead of &`ldap`& in LDAP queries. What follows here applies only
7779 to OpenLDAP. If Exim is compiled with a different LDAP library, this feature is
7780 not available.
7781
7782 For this type of connection, instead of a host name for the server, a pathname
7783 for the socket is required, and the port number is not relevant. The pathname
7784 can be specified either as an item in &%ldap_default_servers%&, or inline in
7785 the query. In the former case, you can have settings such as
7786 .code
7787 ldap_default_servers = /tmp/ldap.sock : backup.ldap.your.domain
7788 .endd
7789 When the pathname is given in the query, you have to escape the slashes as
7790 &`%2F`& to fit in with the LDAP URL syntax. For example:
7791 .code
7792 ${lookup ldap {ldapi://%2Ftmp%2Fldap.sock/o=...
7793 .endd
7794 When Exim processes an LDAP lookup and finds that the &"hostname"& is really
7795 a pathname, it uses the Unix domain socket code, even if the query actually
7796 specifies &`ldap`& or &`ldaps`&. In particular, no encryption is used for a
7797 socket connection. This behaviour means that you can use a setting of
7798 &%ldap_default_servers%& such as in the example above with traditional &`ldap`&
7799 or &`ldaps`& queries, and it will work. First, Exim tries a connection via
7800 the Unix domain socket; if that fails, it tries a TCP/IP connection to the
7801 backup host.
7802
7803 If an explicit &`ldapi`& type is given in a query when a host name is
7804 specified, an error is diagnosed. However, if there are more items in
7805 &%ldap_default_servers%&, they are tried. In other words:
7806
7807 .ilist
7808 Using a pathname with &`ldap`& or &`ldaps`& forces the use of the Unix domain
7809 interface.
7810 .next
7811 Using &`ldapi`& with a host name causes an error.
7812 .endlist
7813
7814
7815 Using &`ldapi`& with no host or path in the query, and no setting of
7816 &%ldap_default_servers%&, does whatever the library does by default.
7817
7818
7819
7820 .subsection "LDAP authentication and control information" SECID70
7821 .cindex "LDAP" "authentication"
7822 The LDAP URL syntax provides no way of passing authentication and other control
7823 information to the server. To make this possible, the URL in an LDAP query may
7824 be preceded by any number of <&'name'&>=<&'value'&> settings, separated by
7825 spaces. If a value contains spaces it must be enclosed in double quotes, and
7826 when double quotes are used, backslash is interpreted in the usual way inside
7827 them. The following names are recognized:
7828 .itable none 0 0 2 20* left 80* left
7829 .irow DEREFERENCE "set the dereferencing parameter"
7830 .irow NETTIME     "set a timeout for a network operation"
7831 .irow USER        "set the DN, for authenticating the LDAP bind"
7832 .irow PASS        "set the password, likewise"
7833 .irow REFERRALS   "set the referrals parameter"
7834 .irow SERVERS     "set alternate server list for this query only"
7835 .irow SIZE        "set the limit for the number of entries returned"
7836 .irow TIME        "set the maximum waiting time for a query"
7837 .endtable
7838 The value of the DEREFERENCE parameter must be one of the words &"never"&,
7839 &"searching"&, &"finding"&, or &"always"&. The value of the REFERRALS parameter
7840 must be &"follow"& (the default) or &"nofollow"&. The latter stops the LDAP
7841 library from trying to follow referrals issued by the LDAP server.
7842
7843 .cindex LDAP timeout
7844 .cindex timeout "LDAP lookup"
7845 The name CONNECT is an obsolete name for NETTIME, retained for
7846 backwards compatibility. This timeout (specified as a number of seconds) is
7847 enforced from the client end for operations that can be carried out over a
7848 network. Specifically, it applies to network connections and calls to the
7849 &'ldap_result()'& function. If the value is greater than zero, it is used if
7850 LDAP_OPT_NETWORK_TIMEOUT is defined in the LDAP headers (OpenLDAP), or
7851 if LDAP_X_OPT_CONNECT_TIMEOUT is defined in the LDAP headers (Netscape
7852 SDK 4.1). A value of zero forces an explicit setting of &"no timeout"& for
7853 Netscape SDK; for OpenLDAP no action is taken.
7854
7855 The TIME parameter (also a number of seconds) is passed to the server to
7856 set a server-side limit on the time taken to complete a search.
7857
7858 The SERVERS parameter allows you to specify an alternate list of ldap servers
7859 to use for an individual lookup.  The global &%ldap_default_servers%& option provides a
7860 default list of ldap servers, and a single lookup can specify a single ldap
7861 server to use.  But when you need to do a lookup with a list of servers that is
7862 different than the default list (maybe different order, maybe a completely
7863 different set of servers), the SERVERS parameter allows you to specify this
7864 alternate list (colon-separated).
7865
7866 Here is an example of an LDAP query in an Exim lookup that uses some of these
7867 values. This is a single line, folded to fit on the page:
7868 .code
7869 ${lookup ldap
7870   {user="cn=manager,o=University of Cambridge,c=UK" pass=secret
7871   ldap:///o=University%20of%20Cambridge,c=UK?sn?sub?(cn=foo)}
7872   {$value}fail}
7873 .endd
7874 The encoding of spaces as &`%20`& is a URL thing which should not be done for
7875 any of the auxiliary data. Exim configuration settings that include lookups
7876 which contain password information should be preceded by &"hide"& to prevent
7877 non-admin users from using the &%-bP%& option to see their values.
7878
7879 The auxiliary data items may be given in any order. The default is no
7880 connection timeout (the system timeout is used), no user or password, no limit
7881 on the number of entries returned, and no time limit on queries.
7882
7883 When a DN is quoted in the USER= setting for LDAP authentication, Exim
7884 removes any URL quoting that it may contain before passing it to the LDAP library.
7885 Apparently
7886 some libraries do this for themselves, but some do not. Removing the URL
7887 quoting has two advantages:
7888
7889 .ilist
7890 It makes it possible to use the same &%quote_ldap_dn%& expansion for USER=
7891 DNs as with DNs inside actual queries.
7892 .next
7893 It permits spaces inside USER= DNs.
7894 .endlist
7895
7896 For example, a setting such as
7897 .code
7898 USER=cn=${quote_ldap_dn:$1}
7899 .endd
7900 should work even if &$1$& contains spaces.
7901
7902 Expanded data for the PASS= value should be quoted using the &%quote%&
7903 expansion operator, rather than the LDAP quote operators. The only reason this
7904 field needs quoting is to ensure that it conforms to the Exim syntax, which
7905 does not allow unquoted spaces. For example:
7906 .code
7907 PASS=${quote:$3}
7908 .endd
7909 The LDAP authentication mechanism can be used to check passwords as part of
7910 SMTP authentication. See the &%ldapauth%& expansion string condition in chapter
7911 &<<CHAPexpand>>&.
7912
7913
7914
7915 .subsection "Format of data returned by LDAP" SECID71
7916 .cindex "LDAP" "returned data formats"
7917 The &(ldapdn)& lookup type returns the Distinguished Name from a single entry
7918 as a sequence of values, for example
7919 .code
7920 cn=manager,o=University of Cambridge,c=UK
7921 .endd
7922 The &(ldap)& lookup type generates an error if more than one entry matches the
7923 search filter, whereas &(ldapm)& permits this case, and inserts a newline in
7924 the result between the data from different entries. It is possible for multiple
7925 values to be returned for both &(ldap)& and &(ldapm)&, but in the former case
7926 you know that whatever values are returned all came from a single entry in the
7927 directory.
7928
7929 In the common case where you specify a single attribute in your LDAP query, the
7930 result is not quoted, and does not contain the attribute name. If the attribute
7931 has multiple values, they are separated by commas. Any comma that is
7932 part of an attribute's value is doubled.
7933
7934 If you specify multiple attributes, the result contains space-separated, quoted
7935 strings, each preceded by the attribute name and an equals sign. Within the
7936 quotes, the quote character, backslash, and newline are escaped with
7937 backslashes, and commas are used to separate multiple values for the attribute.
7938 Any commas in attribute values are doubled
7939 (permitting treatment of the values as a comma-separated list).
7940 Apart from the escaping, the string within quotes takes the same form as the
7941 output when a single attribute is requested. Specifying no attributes is the
7942 same as specifying all of an entry's attributes.
7943
7944 Here are some examples of the output format. The first line of each pair is an
7945 LDAP query, and the second is the data that is returned. The attribute called
7946 &%attr1%& has two values, one of them with an embedded comma, whereas
7947 &%attr2%& has only one value. Both attributes are derived from &%attr%&
7948 (they have SUP &%attr%& in their schema definitions).
7949
7950 .code
7951 ldap:///o=base?attr1?sub?(uid=fred)
7952 value1.1,value1,,2
7953
7954 ldap:///o=base?attr2?sub?(uid=fred)
7955 value two
7956
7957 ldap:///o=base?attr?sub?(uid=fred)
7958 value1.1,value1,,2,value two
7959
7960 ldap:///o=base?attr1,attr2?sub?(uid=fred)
7961 attr1="value1.1,value1,,2" attr2="value two"
7962
7963 ldap:///o=base??sub?(uid=fred)
7964 objectClass="top" attr1="value1.1,value1,,2" attr2="value two"
7965 .endd
7966 You can
7967 make use of Exim's &%-be%& option to run expansion tests and thereby check the
7968 results of LDAP lookups.
7969 The &%extract%& operator in string expansions can be used to pick out
7970 individual fields from data that consists of &'key'&=&'value'& pairs.
7971 The &%listextract%& operator should be used to pick out individual values
7972 of attributes, even when only a single value is expected.
7973 The doubling of embedded commas allows you to use the returned data as a
7974 comma separated list (using the "<," syntax for changing the input list separator).
7975
7976
7977
7978
7979 .section "More about NIS+" "SECTnisplus"
7980 .cindex "NIS+ lookup type"
7981 .cindex "lookup" "NIS+"
7982 NIS+ queries consist of a NIS+ &'indexed name'& followed by an optional colon
7983 and field name. If this is given, the result of a successful query is the
7984 contents of the named field; otherwise the result consists of a concatenation
7985 of &'field-name=field-value'& pairs, separated by spaces. Empty values and
7986 values containing spaces are quoted. For example, the query
7987 .code
7988 [name=mg1456],passwd.org_dir
7989 .endd
7990 might return the string
7991 .code
7992 name=mg1456 passwd="" uid=999 gid=999 gcos="Martin Guerre"
7993 home=/home/mg1456 shell=/bin/bash shadow=""
7994 .endd
7995 (split over two lines here to fit on the page), whereas
7996 .code
7997 [name=mg1456],passwd.org_dir:gcos
7998 .endd
7999 would just return
8000 .code
8001 Martin Guerre
8002 .endd
8003 with no quotes. A NIS+ lookup fails if NIS+ returns more than one table entry
8004 for the given indexed key. The effect of the &%quote_nisplus%& expansion
8005 operator is to double any quote characters within the text.
8006
8007
8008
8009 .section "SQL lookups" "SECTsql"
8010 .cindex "SQL lookup types"
8011 .cindex "MySQL" "lookup type"
8012 .cindex "PostgreSQL lookup type"
8013 .cindex "lookup" "MySQL"
8014 .cindex "lookup" "PostgreSQL"
8015 .cindex "Oracle" "lookup type"
8016 .cindex "lookup" "Oracle"
8017 .cindex "InterBase lookup type"
8018 .cindex "lookup" "InterBase"
8019 .cindex "Redis lookup type"
8020 .cindex lookup Redis
8021 Exim can support lookups in InterBase, MySQL, Oracle, PostgreSQL, Redis,
8022 and SQLite
8023 databases. Queries for these databases contain SQL statements, so an example
8024 might be
8025 .code
8026 ${lookup mysql{select mailbox from users where id='userx'}\
8027   {$value}fail}
8028 .endd
8029 If the result of the query contains more than one field, the data for each
8030 field in the row is returned, preceded by its name, so the result of
8031 .code
8032 ${lookup pgsql{select home,name from users where id='userx'}\
8033   {$value}}
8034 .endd
8035 might be
8036 .code
8037 home=/home/userx name="Mister X"
8038 .endd
8039 Empty values and values containing spaces are double quoted, with embedded
8040 quotes escaped by a backslash. If the result of the query contains just one
8041 field, the value is passed back verbatim, without a field name, for example:
8042 .code
8043 Mister X
8044 .endd
8045 If the result of the query yields more than one row, it is all concatenated,
8046 with a newline between the data for each row.
8047
8048
8049 .subsection "More about MySQL, PostgreSQL, Oracle, InterBase, and Redis" SECID72
8050 .cindex "MySQL" "lookup type"
8051 .cindex "PostgreSQL lookup type"
8052 .cindex "lookup" "MySQL"
8053 .cindex "lookup" "PostgreSQL"
8054 .cindex "Oracle" "lookup type"
8055 .cindex "lookup" "Oracle"
8056 .cindex "InterBase lookup type"
8057 .cindex "lookup" "InterBase"
8058 .cindex "Redis lookup type"
8059 .cindex lookup Redis
8060 If any MySQL, PostgreSQL, Oracle, InterBase or Redis lookups are used, the
8061 &%mysql_servers%&, &%pgsql_servers%&, &%oracle_servers%&, &%ibase_servers%&,
8062 or &%redis_servers%&
8063 option (as appropriate) must be set to a colon-separated list of server
8064 information.
8065 .oindex &%mysql_servers%&
8066 .oindex &%pgsql_servers%&
8067 .oindex &%oracle_servers%&
8068 .oindex &%ibase_servers%&
8069 .oindex &%redis_servers%&
8070 (For MySQL and PostgreSQL, the global option need not be set if all
8071 queries contain their own server information &-- see section
8072 &<<SECTspeserque>>&.)
8073 For all but Redis
8074 each item in the list is a slash-separated list of four
8075 items: host name, database name, user name, and password. In the case of
8076 Oracle, the host name field is used for the &"service name"&, and the database
8077 name field is not used and should be empty. For example:
8078 .code
8079 hide oracle_servers = oracle.plc.example//userx/abcdwxyz
8080 .endd
8081 Because password data is sensitive, you should always precede the setting with
8082 &"hide"&, to prevent non-admin users from obtaining the setting via the &%-bP%&
8083 option. Here is an example where two MySQL servers are listed:
8084 .code
8085 hide mysql_servers = localhost/users/root/secret:\
8086                      otherhost/users/root/othersecret
8087 .endd
8088 For MySQL and PostgreSQL, a host may be specified as <&'name'&>:<&'port'&> but
8089 because this is a colon-separated list, the colon has to be doubled. For each
8090 query, these parameter groups are tried in order until a connection is made and
8091 a query is successfully processed. The result of a query may be that no data is
8092 found, but that is still a successful query. In other words, the list of
8093 servers provides a backup facility, not a list of different places to look.
8094
8095 For Redis the global option need not be specified if all queries contain their
8096 own server information &-- see section &<<SECTspeserque>>&.
8097 If specified, the option must be set to a colon-separated list of server
8098 information.
8099 Each item in the list is a slash-separated list of three items:
8100 host, database number, and password.
8101 .olist
8102 The host is required and may be either an IPv4 address and optional
8103 port number (separated by a colon, which needs doubling due to the
8104 higher-level list), or a Unix socket pathname enclosed in parentheses
8105 .next
8106 The database number is optional; if present that number is selected in the backend
8107 .next
8108 The password is optional; if present it is used to authenticate to the backend
8109 .endlist
8110
8111 The &%quote_mysql%&, &%quote_pgsql%&, and &%quote_oracle%& expansion operators
8112 convert newline, tab, carriage return, and backspace to \n, \t, \r, and \b
8113 respectively, and the characters single-quote, double-quote, and backslash
8114 itself are escaped with backslashes.
8115
8116 The &%quote_redis%& expansion operator
8117 escapes whitespace and backslash characters with a backslash.
8118
8119 .subsection "Specifying the server in the query" SECTspeserque
8120 For MySQL, PostgreSQL and Redis lookups (but not currently for Oracle and InterBase),
8121 it is possible to specify a list of servers with an individual query. This is
8122 done by appending a comma-separated option to the query type:
8123 .display
8124 &`,servers=`&&'server1:server2:server3:...'&
8125 .endd
8126 Each item in the list may take one of two forms:
8127 .olist
8128 If it contains no slashes it is assumed to be just a host name. The appropriate
8129 global option (&%mysql_servers%& or &%pgsql_servers%&) is searched for a host
8130 of the same name, and the remaining parameters (database, user, password) are
8131 taken from there.
8132 .next
8133 If it contains any slashes, it is taken as a complete parameter set.
8134 .endlist
8135 The list of servers is used in exactly the same way as the global list.
8136 Once a connection to a server has happened and a query has been
8137 successfully executed, processing of the lookup ceases.
8138
8139 This feature is intended for use in master/slave situations where updates
8140 are occurring and you want to update the master rather than a slave. If the
8141 master is in the list as a backup for reading, you might have a global setting
8142 like this:
8143 .code
8144 mysql_servers = slave1/db/name/pw:\
8145                 slave2/db/name/pw:\
8146                 master/db/name/pw
8147 .endd
8148 In an updating lookup, you could then write:
8149 .code
8150 ${lookup mysql,servers=master {UPDATE ...} }
8151 .endd
8152 That query would then be sent only to the master server. If, on the other hand,
8153 the master is not to be used for reading, and so is not present in the global
8154 option, you can still update it by a query of this form:
8155 .code
8156 ${lookup pgsql,servers=master/db/name/pw {UPDATE ...} }
8157 .endd
8158
8159 An older syntax places the servers specification before the query,
8160 semicolon separated:
8161 .code
8162 ${lookup mysql{servers=master; UPDATE ...} }
8163 .endd
8164 The new version avoids potential issues with tainted
8165 arguments in the query, for explicit expansion.
8166 &*Note*&: server specifications in list-style lookups are still problematic.
8167
8168
8169 .subsection "Special MySQL features" SECID73
8170 For MySQL, an empty host name or the use of &"localhost"& in &%mysql_servers%&
8171 causes a connection to the server on the local host by means of a Unix domain
8172 socket. An alternate socket can be specified in parentheses.
8173 An option group name for MySQL option files can be specified in square brackets;
8174 the default value is &"exim"&.
8175 The full syntax of each item in &%mysql_servers%& is:
8176 .display
8177 <&'hostname'&>::<&'port'&>(<&'socket name'&>)[<&'option group'&>]/&&&
8178   <&'database'&>/<&'user'&>/<&'password'&>
8179 .endd
8180 Any of the four sub-parts of the first field can be omitted. For normal use on
8181 the local host it can be left blank or set to just &"localhost"&.
8182
8183 No database need be supplied &-- but if it is absent here, it must be given in
8184 the queries.
8185
8186 If a MySQL query is issued that does not request any data (an insert, update,
8187 or delete command), the result of the lookup is the number of rows affected.
8188
8189 &*Warning*&: This can be misleading. If an update does not actually change
8190 anything (for example, setting a field to the value it already has), the result
8191 is zero because no rows are affected.
8192
8193
8194 .subsection "Special PostgreSQL features" SECID74
8195 PostgreSQL lookups can also use Unix domain socket connections to the database.
8196 This is usually faster and costs less CPU time than a TCP/IP connection.
8197 However it can be used only if the mail server runs on the same machine as the
8198 database server. A configuration line for PostgreSQL via Unix domain sockets
8199 looks like this:
8200 .code
8201 hide pgsql_servers = (/tmp/.s.PGSQL.5432)/db/user/password : ...
8202 .endd
8203 In other words, instead of supplying a host name, a path to the socket is
8204 given. The path name is enclosed in parentheses so that its slashes aren't
8205 visually confused with the delimiters for the other server parameters.
8206
8207 If a PostgreSQL query is issued that does not request any data (an insert,
8208 update, or delete command), the result of the lookup is the number of rows
8209 affected.
8210
8211 .subsection "More about SQLite" SECTsqlite
8212 .cindex "lookup" "SQLite"
8213 .cindex "sqlite lookup type"
8214 SQLite is different to the other SQL lookups because a filename is required in
8215 addition to the SQL query. An SQLite database is a single file, and there is no
8216 daemon as in the other SQL databases.
8217
8218 .oindex &%sqlite_dbfile%&
8219 There are two ways of
8220 specifying the file.
8221 The first is by using the &%sqlite_dbfile%& main option.
8222 The second, which allows separate files for each query,
8223 is to use an option appended, comma-separated, to the &"sqlite"&
8224 lookup type word.  The option is the word &"file"&, then an equals,
8225 then the filename.
8226 The filename in this case cannot contain whitespace or open-brace charachters.
8227
8228 A deprecated method is available, prefixing the query with the filename
8229 separated by white space.
8230 This means that
8231 .cindex "tainted data" "sqlite file"
8232 the query cannot use any tainted values, as that taints
8233 the entire query including the filename - resulting in a refusal to open
8234 the file.
8235
8236 In all the above cases the filename must be an absolute path.
8237
8238 Here is a lookup expansion example:
8239 .code
8240 sqlite_dbfile = /some/thing/sqlitedb
8241 ...
8242 ${lookup sqlite {select name from aliases where id='userx';}}
8243 .endd
8244 In a list, the syntax is similar. For example:
8245 .code
8246 domainlist relay_to_domains = sqlite;\
8247    select * from relays where ip='$sender_host_address';
8248 .endd
8249 The only character affected by the &%quote_sqlite%& operator is a single
8250 quote, which it doubles.
8251
8252 .cindex timeout SQLite
8253 .cindex sqlite "lookup timeout"
8254 The SQLite library handles multiple simultaneous accesses to the database
8255 internally. Multiple readers are permitted, but only one process can
8256 update at once. Attempts to access the database while it is being updated
8257 are rejected after a timeout period, during which the SQLite library
8258 waits for the lock to be released. In Exim, the default timeout is set
8259 to 5 seconds, but it can be changed by means of the &%sqlite_lock_timeout%&
8260 option.
8261
8262 .subsection "More about Redis" SECTredis
8263 .cindex "lookup" "Redis"
8264 .cindex "redis lookup type"
8265 Redis is a non-SQL database. Commands are simple get and set.
8266 Examples:
8267 .code
8268 ${lookup redis{set keyname ${quote_redis:objvalue plus}}}
8269 ${lookup redis{get keyname}}
8270 .endd
8271
8272 As of release 4.91, "lightweight" support for Redis Cluster is available.
8273 Requires &%redis_servers%& list to contain all the servers in the cluster, all
8274 of which must be reachable from the running exim instance. If the cluster has
8275 master/slave replication, the list must contain all the master and slave
8276 servers.
8277
8278 When the Redis Cluster returns a "MOVED" response to a query, Exim does not
8279 immediately follow the redirection but treats the response as a DEFER, moving on
8280 to the next server in the &%redis_servers%& list until the correct server is
8281 reached.
8282
8283 .ecindex IIDfidalo1
8284 .ecindex IIDfidalo2
8285
8286
8287 . ////////////////////////////////////////////////////////////////////////////
8288 . ////////////////////////////////////////////////////////////////////////////
8289
8290 .chapter "Domain, host, address, and local part lists" &&&
8291          "CHAPdomhosaddlists" &&&
8292          "Domain, host, and address lists"
8293 .scindex IIDdohoadli "lists of domains; hosts; etc."
8294 A number of Exim configuration options contain lists of domains, hosts,
8295 email addresses, or local parts. For example, the &%hold_domains%& option
8296 contains a list of domains whose delivery is currently suspended. These lists
8297 are also used as data in ACL statements (see chapter &<<CHAPACL>>&), and as
8298 arguments to expansion conditions such as &%match_domain%&.
8299
8300 Each item in one of these lists is a pattern to be matched against a domain,
8301 host, email address, or local part, respectively. In the sections below, the
8302 different types of pattern for each case are described, but first we cover some
8303 general facilities that apply to all four kinds of list.
8304
8305 Note that other parts of Exim use a &'string list'& which does not
8306 support all the complexity available in
8307 domain, host, address and local part lists.
8308
8309
8310
8311 .section "Results of list checking" SECTlistresults
8312 The primary result of doing a list check is a truth value.
8313 In some contexts additional information is stored
8314 about the list element that matched:
8315 .vlist
8316 .vitem hosts
8317 A &%hosts%& ACL condition
8318 will store a result in the &$host_data$& variable.
8319 .vitem local_parts
8320 A &%local_parts%& router option or &%local_parts%& ACL condition
8321 will store a result in the &$local_part_data$& variable.
8322 .vitem domains
8323 A &%domains%& router option or &%domains%& ACL condition
8324 will store a result in the &$domain_data$& variable.
8325 .vitem senders
8326 A &%senders%& router option or &%senders%& ACL condition
8327 will store a result in the &$sender_data$& variable.
8328 .vitem recipients
8329 A &%recipients%& ACL condition
8330 will store a result in the &$recipient_data$& variable.
8331 .endlist
8332
8333 The detail of the additional information depends on the
8334 type of match and is given below as the &*value*& information.
8335
8336
8337
8338
8339 .section "Expansion of lists" "SECTlistexpand"
8340 .cindex "expansion" "of lists"
8341 Each list is expanded as a single string before it is used.
8342
8343 &'Exception: the router headers_remove option, where list-item
8344 splitting is done before string-expansion.'&
8345
8346 The result of
8347 expansion must be a list, possibly containing empty items, which is split up
8348 into separate items for matching. By default, colon is the separator character,
8349 but this can be varied if necessary. See sections &<<SECTlistconstruct>>& and
8350 &<<SECTempitelis>>& for details of the list syntax; the second of these
8351 discusses the way to specify empty list items.
8352
8353
8354 If the string expansion is forced to fail, Exim behaves as if the item it is
8355 testing (domain, host, address, or local part) is not in the list. Other
8356 expansion failures cause temporary errors.
8357
8358 If an item in a list is a regular expression, backslashes, dollars and possibly
8359 other special characters in the expression must be protected against
8360 misinterpretation by the string expander. The easiest way to do this is to use
8361 the &`\N`& expansion feature to indicate that the contents of the regular
8362 expression should not be expanded. For example, in an ACL you might have:
8363 .code
8364 deny senders = \N^\d{8}\w@.*\.baddomain\.example$\N : \
8365                ${lookup{$domain}lsearch{/badsenders/bydomain}}
8366 .endd
8367 The first item is a regular expression that is protected from expansion by
8368 &`\N`&, whereas the second uses the expansion to obtain a list of unwanted
8369 senders based on the receiving domain.
8370
8371
8372
8373
8374 .subsection "Negated items in lists" SECID76
8375 .cindex "list" "negation"
8376 .cindex "negation" "in lists"
8377 Items in a list may be positive or negative. Negative items are indicated by a
8378 leading exclamation mark, which may be followed by optional white space. A list
8379 defines a set of items (domains, etc). When Exim processes one of these lists,
8380 it is trying to find out whether a domain, host, address, or local part
8381 (respectively) is in the set that is defined by the list. It works like this:
8382
8383 The list is scanned from left to right. If a positive item is matched, the
8384 subject that is being checked is in the set; if a negative item is matched, the
8385 subject is not in the set. If the end of the list is reached without the
8386 subject having matched any of the patterns, it is in the set if the last item
8387 was a negative one, but not if it was a positive one. For example, the list in
8388 .code
8389 domainlist relay_to_domains = !a.b.c : *.b.c
8390 .endd
8391 matches any domain ending in &'.b.c'& except for &'a.b.c'&. Domains that match
8392 neither &'a.b.c'& nor &'*.b.c'& do not match, because the last item in the
8393 list is positive. However, if the setting were
8394 .code
8395 domainlist relay_to_domains = !a.b.c
8396 .endd
8397 then all domains other than &'a.b.c'& would match because the last item in the
8398 list is negative. In other words, a list that ends with a negative item behaves
8399 as if it had an extra item &`:*`& on the end.
8400
8401 Another way of thinking about positive and negative items in lists is to read
8402 the connector as &"or"& after a positive item and as &"and"& after a negative
8403 item.
8404
8405
8406
8407 .subsection "File names in lists" SECTfilnamlis
8408 .cindex "list" "filename in"
8409 If an item in a domain, host, address, or local part list is an absolute
8410 filename (beginning with a slash character), each line of the file is read and
8411 processed as if it were an independent item in the list, except that further
8412 filenames are not allowed,
8413 and no expansion of the data from the file takes place.
8414 Empty lines in the file are ignored, and the file may also contain comment
8415 lines:
8416
8417 .ilist
8418 For domain and host lists, if a # character appears anywhere in a line of the
8419 file, it and all following characters are ignored.
8420 .next
8421 Because local parts may legitimately contain # characters, a comment in an
8422 address list or local part list file is recognized only if # is preceded by
8423 white space or the start of the line. For example:
8424 .code
8425 not#comment@x.y.z   # but this is a comment
8426 .endd
8427 .endlist
8428
8429 Putting a filename in a list has the same effect as inserting each line of the
8430 file as an item in the list (blank lines and comments excepted). However, there
8431 is one important difference: the file is read each time the list is processed,
8432 so if its contents vary over time, Exim's behaviour changes.
8433
8434 If a filename is preceded by an exclamation mark, the sense of any match
8435 within the file is inverted. For example, if
8436 .code
8437 hold_domains = !/etc/nohold-domains
8438 .endd
8439 and the file contains the lines
8440 .code
8441 !a.b.c
8442 *.b.c
8443 .endd
8444 then &'a.b.c'& is in the set of domains defined by &%hold_domains%&, whereas
8445 any domain matching &`*.b.c`& is not.
8446
8447
8448
8449 .subsection "An lsearch file is not an out-of-line list" SECID77
8450 As will be described in the sections that follow, lookups can be used in lists
8451 to provide indexed methods of checking list membership. There has been some
8452 confusion about the way &(lsearch)& lookups work in lists. Because
8453 an &(lsearch)& file contains plain text and is scanned sequentially, it is
8454 sometimes thought that it is allowed to contain wild cards and other kinds of
8455 non-constant pattern. This is not the case. The keys in an &(lsearch)& file are
8456 always fixed strings, just as for any other single-key lookup type.
8457
8458 If you want to use a file to contain wild-card patterns that form part of a
8459 list, just give the filename on its own, without a search type, as described
8460 in the previous section. You could also use the &(wildlsearch)& or
8461 &(nwildlsearch)&, but there is no advantage in doing this.
8462
8463
8464
8465
8466 .subsection "Named lists" SECTnamedlists
8467 .cindex "named lists"
8468 .cindex "list" "named"
8469 A list of domains, hosts, email addresses, or local parts can be given a name
8470 which is then used to refer to the list elsewhere in the configuration. This is
8471 particularly convenient if the same list is required in several different
8472 places. It also allows lists to be given meaningful names, which can improve
8473 the readability of the configuration. For example, it is conventional to define
8474 a domain list called &'local_domains'& for all the domains that are handled
8475 locally on a host, using a configuration line such as
8476 .code
8477 domainlist local_domains = localhost:my.dom.example
8478 .endd
8479 Named lists are referenced by giving their name preceded by a plus sign, so,
8480 for example, a router that is intended to handle local domains would be
8481 configured with the line
8482 .code
8483 domains = +local_domains
8484 .endd
8485 The first router in a configuration is often one that handles all domains
8486 except the local ones, using a configuration with a negated item like this:
8487 .code
8488 dnslookup:
8489   driver = dnslookup
8490   domains = ! +local_domains
8491   transport = remote_smtp
8492   no_more
8493 .endd
8494 The four kinds of named list are created by configuration lines starting with
8495 the words &%domainlist%&, &%hostlist%&, &%addresslist%&, or &%localpartlist%&,
8496 respectively. Then there follows the name that you are defining, followed by an
8497 equals sign and the list itself. For example:
8498 .code
8499 hostlist    relay_from_hosts = 192.168.23.0/24 : my.friend.example
8500 addresslist bad_senders = cdb;/etc/badsenders
8501 .endd
8502 A named list may refer to other named lists:
8503 .code
8504 domainlist  dom1 = first.example : second.example
8505 domainlist  dom2 = +dom1 : third.example
8506 domainlist  dom3 = fourth.example : +dom2 : fifth.example
8507 .endd
8508 &*Warning*&: If the last item in a referenced list is a negative one, the
8509 effect may not be what you intended, because the negation does not propagate
8510 out to the higher level. For example, consider:
8511 .code
8512 domainlist  dom1 = !a.b
8513 domainlist  dom2 = +dom1 : *.b
8514 .endd
8515 The second list specifies &"either in the &%dom1%& list or &'*.b'&"&. The first
8516 list specifies just &"not &'a.b'&"&, so the domain &'x.y'& matches it. That
8517 means it matches the second list as well. The effect is not the same as
8518 .code
8519 domainlist  dom2 = !a.b : *.b
8520 .endd
8521 where &'x.y'& does not match. It's best to avoid negation altogether in
8522 referenced lists if you can.
8523
8524 .cindex "hiding named list values"
8525 .cindex "named lists" "hiding value of"
8526 Some named list definitions may contain sensitive data, for example, passwords for
8527 accessing databases. To stop non-admin users from using the &%-bP%& command
8528 line option to read these values, you can precede the definition with the
8529 word &"hide"&. For example:
8530 .code
8531 hide domainlist filter_for_domains = ldap;PASS=secret ldap::/// ...
8532 .endd
8533
8534
8535 Named lists may have a performance advantage. When Exim is routing an
8536 address or checking an incoming message, it caches the result of tests on named
8537 lists. So, if you have a setting such as
8538 .code
8539 domains = +local_domains
8540 .endd
8541 on several of your routers
8542 or in several ACL statements,
8543 the actual test is done only for the first one. However, the caching works only
8544 if there are no expansions within the list itself or any sublists that it
8545 references. In other words, caching happens only for lists that are known to be
8546 the same each time they are referenced.
8547
8548 By default, there may be up to 16 named lists of each type. This limit can be
8549 extended by changing a compile-time variable. The use of domain and host lists
8550 is recommended for concepts such as local domains, relay domains, and relay
8551 hosts. The default configuration is set up like this.
8552
8553
8554
8555 .subsection "Named lists compared with macros" SECID78
8556 .cindex "list" "named compared with macro"
8557 .cindex "macro" "compared with named list"
8558 At first sight, named lists might seem to be no different from macros in the
8559 configuration file. However, macros are just textual substitutions. If you
8560 write
8561 .code
8562 ALIST = host1 : host2
8563 auth_advertise_hosts = !ALIST
8564 .endd
8565 it probably won't do what you want, because that is exactly the same as
8566 .code
8567 auth_advertise_hosts = !host1 : host2
8568 .endd
8569 Notice that the second host name is not negated. However, if you use a host
8570 list, and write
8571 .code
8572 hostlist alist = host1 : host2
8573 auth_advertise_hosts = ! +alist
8574 .endd
8575 the negation applies to the whole list, and so that is equivalent to
8576 .code
8577 auth_advertise_hosts = !host1 : !host2
8578 .endd
8579
8580
8581 .subsection "Named list caching" SECID79
8582 .cindex "list" "caching of named"
8583 .cindex "caching" "named lists"
8584 While processing a message, Exim caches the result of checking a named list if
8585 it is sure that the list is the same each time. In practice, this means that
8586 the cache operates only if the list contains no $ characters, which guarantees
8587 that it will not change when it is expanded. Sometimes, however, you may have
8588 an expanded list that you know will be the same each time within a given
8589 message. For example:
8590 .code
8591 domainlist special_domains = \
8592            ${lookup{$sender_host_address}cdb{/some/file}}
8593 .endd
8594 This provides a list of domains that depends only on the sending host's IP
8595 address. If this domain list is referenced a number of times (for example,
8596 in several ACL lines, or in several routers) the result of the check is not
8597 cached by default, because Exim does not know that it is going to be the
8598 same list each time.
8599
8600 By appending &`_cache`& to &`domainlist`& you can tell Exim to go ahead and
8601 cache the result anyway. For example:
8602 .code
8603 domainlist_cache special_domains = ${lookup{...
8604 .endd
8605 If you do this, you should be absolutely sure that caching is going to do
8606 the right thing in all cases. When in doubt, leave it out.
8607
8608
8609
8610 .section "Domain lists" "SECTdomainlist"
8611 .cindex "domain list" "patterns for"
8612 .cindex "list" "domain list"
8613 Domain lists contain patterns that are to be matched against a mail domain.
8614 The following types of item may appear in domain lists:
8615
8616 .ilist
8617 .cindex "primary host name"
8618 .cindex "host name" "matched in domain list"
8619 .oindex "&%primary_hostname%&"
8620 .cindex "domain list" "matching primary host name"
8621 .cindex "@ in a domain list"
8622 If a pattern consists of a single @ character, it matches the local host name,
8623 as set by the &%primary_hostname%& option (or defaulted). This makes it
8624 possible to use the same configuration file on several different hosts that
8625 differ only in their names.
8626
8627 The value for a match will be the primary host name.
8628
8629
8630 .next
8631 .cindex "@[] in a domain list"
8632 .cindex "domain list" "matching local IP interfaces"
8633 .cindex "domain literal"
8634 If a pattern consists of the string &`@[]`& it matches an IP address enclosed
8635 in square brackets (as in an email address that contains a domain literal), but
8636 only if that IP address is recognized as local for email routing purposes. The
8637 &%local_interfaces%& and &%extra_local_interfaces%& options can be used to
8638 control which of a host's several IP addresses are treated as local.
8639 In today's Internet, the use of domain literals is controversial;
8640 see the &%allow_domain_literals%& main option.
8641
8642 The value for a match will be the string &`@[]`&.
8643
8644
8645 .next
8646 .cindex "@mx_any"
8647 .cindex "@mx_primary"
8648 .cindex "@mx_secondary"
8649 .cindex "domain list" "matching MX pointers to local host"
8650 If a pattern consists of the string &`@mx_any`& it matches any domain that
8651 has an MX record pointing to the local host or to any host that is listed in
8652 .oindex "&%hosts_treat_as_local%&"
8653 &%hosts_treat_as_local%&. The items &`@mx_primary`& and &`@mx_secondary`&
8654 are similar, except that the first matches only when a primary MX target is the
8655 local host, and the second only when no primary MX target is the local host,
8656 but a secondary MX target is. &"Primary"& means an MX record with the lowest
8657 preference value &-- there may of course be more than one of them.
8658
8659 The MX lookup that takes place when matching a pattern of this type is
8660 performed with the resolver options for widening names turned off. Thus, for
8661 example, a single-component domain will &'not'& be expanded by adding the
8662 resolver's default domain. See the &%qualify_single%& and &%search_parents%&
8663 options of the &(dnslookup)& router for a discussion of domain widening.
8664
8665 Sometimes you may want to ignore certain IP addresses when using one of these
8666 patterns. You can specify this by following the pattern with &`/ignore=`&<&'ip
8667 list'&>, where <&'ip list'&> is a list of IP addresses. These addresses are
8668 ignored when processing the pattern (compare the &%ignore_target_hosts%& option
8669 on a router). For example:
8670 .code
8671 domains = @mx_any/ignore=127.0.0.1
8672 .endd
8673 This example matches any domain that has an MX record pointing to one of
8674 the local host's IP addresses other than 127.0.0.1.
8675
8676 The list of IP addresses is in fact processed by the same code that processes
8677 host lists, so it may contain CIDR-coded network specifications and it may also
8678 contain negative items.
8679
8680 Because the list of IP addresses is a sublist within a domain list, you have to
8681 be careful about delimiters if there is more than one address. Like any other
8682 list, the default delimiter can be changed. Thus, you might have:
8683 .code
8684 domains = @mx_any/ignore=<;127.0.0.1;0.0.0.0 : \
8685           an.other.domain : ...
8686 .endd
8687 so that the sublist uses semicolons for delimiters. When IPv6 addresses are
8688 involved, it is easiest to change the delimiter for the main list as well:
8689 .code
8690 domains = <? @mx_any/ignore=<;127.0.0.1;::1 ? \
8691           an.other.domain ? ...
8692 .endd
8693 The value for a match will be the list element string (starting &`@mx_`&).
8694
8695
8696 .next
8697 .cindex "asterisk" "in domain list"
8698 .cindex "domain list" "asterisk in"
8699 .cindex "domain list" "matching &""ends with""&"
8700 If a pattern starts with an asterisk, the remaining characters of the pattern
8701 are compared with the terminating characters of the domain. The use of &"*"& in
8702 domain lists differs from its use in partial matching lookups. In a domain
8703 list, the character following the asterisk need not be a dot, whereas partial
8704 matching works only in terms of dot-separated components. For example, a domain
8705 list item such as &`*key.ex`& matches &'donkey.ex'& as well as
8706 &'cipher.key.ex'&.
8707
8708 The value for a match will be the list element string (starting with the asterisk).
8709 Additionally, &$0$& will be set to the matched string
8710 and &$1$& to the variable portion which the asterisk matched.
8711
8712 .next
8713 .cindex "regular expressions" "in domain list"
8714 .cindex "domain list" "matching regular expression"
8715 If a pattern starts with a circumflex character, it is treated as a regular
8716 expression, and matched against the domain using a regular expression matching
8717 function. The circumflex is treated as part of the regular expression.
8718 Email domains are case-independent, so this regular expression match is by
8719 default case-independent, but you can make it case-dependent by starting it
8720 with &`(?-i)`&. References to descriptions of the syntax of regular expressions
8721 are given in chapter &<<CHAPregexp>>&.
8722
8723 &*Warning*&: Because domain lists are expanded before being processed, you
8724 must escape any backslash and dollar characters in the regular expression, or
8725 use the special &`\N`& sequence (see chapter &<<CHAPexpand>>&) to specify that
8726 it is not to be expanded (unless you really do want to build a regular
8727 expression by expansion, of course).
8728
8729 The value for a match will be the list element string (starting with the circumflex).
8730 Additionally, &$0$& will be set to the string matching the regular expression,
8731 and &$1$& (onwards) to any submatches identified by parentheses.
8732
8733
8734
8735 .next
8736 .cindex "lookup" "in domain list"
8737 .cindex "domain list" "matching by lookup"
8738 If a pattern starts with the name of a single-key lookup type followed by a
8739 semicolon (for example, &"dbm;"& or &"lsearch;"&), the remainder of the pattern
8740 must be a filename in a suitable format for the lookup type. For example, for
8741 &"cdb;"& it must be an absolute path:
8742 .code
8743 domains = cdb;/etc/mail/local_domains.cdb
8744 .endd
8745 The appropriate type of lookup is done on the file using the domain name as the
8746 key. In most cases, the value resulting from the lookup is not used; Exim is interested
8747 only in whether or not the key is present in the file. However, when a lookup
8748 is used for the &%domains%& option on a router
8749 or a &%domains%& condition in an ACL statement, the value is preserved in the
8750 &$domain_data$& variable and can be referred to in other router options or
8751 other statements in the same ACL.
8752 .cindex "tainted data" "de-tainting"
8753 .cindex "de-tainting" "using ACL domains condition"
8754 The value will be untainted.
8755
8756 &*Note*&: If the data result of the lookup (as opposed to the key)
8757 is empty, then this empty value is stored in &$domain_data$&.
8758 The option to return the key for the lookup, as the value,
8759 may be what is wanted.
8760
8761
8762 .next
8763 Any of the single-key lookup type names may be preceded by
8764 &`partial`&<&'n'&>&`-`&, where the <&'n'&> is optional, for example,
8765 .code
8766 domains = partial-dbm;/partial/domains
8767 .endd
8768 This causes partial matching logic to be invoked; a description of how this
8769 works is given in section &<<SECTpartiallookup>>&.
8770
8771 .next
8772 .cindex "asterisk" "in lookup type"
8773 Any of the single-key lookup types may be followed by an asterisk. This causes
8774 a default lookup for a key consisting of a single asterisk to be done if the
8775 original lookup fails. This is not a useful feature when using a domain list to
8776 select particular domains (because any domain would match), but it might have
8777 value if the result of the lookup is being used via the &$domain_data$&
8778 expansion variable.
8779
8780 .next
8781 If the pattern starts with the name of a query-style lookup type followed by a
8782 semicolon (for example, &"nisplus;"& or &"ldap;"&), the remainder of the
8783 pattern must be an appropriate query for the lookup type, as described in
8784 chapter &<<CHAPfdlookup>>&. For example:
8785 .code
8786 hold_domains = mysql;select domain from holdlist \
8787   where domain = '${quote_mysql:$domain}';
8788 .endd
8789 In most cases, the value resulting from the lookup is not used (so for an SQL query, for
8790 example, it doesn't matter what field you select). Exim is interested only in
8791 whether or not the query succeeds. However, when a lookup is used for the
8792 &%domains%& option on a router, the value is preserved in the &$domain_data$&
8793 variable and can be referred to in other options.
8794 .cindex "tainted data" "de-tainting"
8795 .cindex "de-tainting" "using router domains option"
8796 The value will be untainted.
8797
8798 .next
8799 If the pattern starts with the name of a lookup type
8800 of either kind (single-key or query-style) it may be
8801 followed by a comma and options,
8802 The options are lookup-type specific and consist of a comma-separated list.
8803 Each item starts with a tag and and equals "=" sign.
8804
8805 .next
8806 .cindex "domain list" "matching literal domain name"
8807 If none of the above cases apply, a caseless textual comparison is made
8808 between the pattern and the domain.
8809
8810 The value for a match will be the list element string.
8811 .cindex "tainted data" "de-tainting"
8812 Note that this is commonly untainted
8813 (depending on the way the list was created).
8814 Specifically, explicit text in the configuration file in not tainted.
8815 This is a useful way of obtaining an untainted equivalent to
8816 the domain, for later operations.
8817
8818 However if the list (including one-element lists)
8819 is created by expanding a variable containing tainted data,
8820 it is tainted and so will the match value be.
8821 .endlist
8822
8823
8824 Here is an example that uses several different kinds of pattern:
8825 .code
8826 domainlist funny_domains = \
8827   @ : \
8828   lib.unseen.edu : \
8829   *.foundation.fict.example : \
8830   \N^[1-2]\d{3}\.fict\.example$\N : \
8831   partial-dbm;/opt/data/penguin/book : \
8832   nis;domains.byname : \
8833   nisplus;[name=$domain,status=local],domains.org_dir
8834 .endd
8835 There are obvious processing trade-offs among the various matching modes. Using
8836 an asterisk is faster than a regular expression, and listing a few names
8837 explicitly probably is too. The use of a file or database lookup is expensive,
8838 but may be the only option if hundreds of names are required. Because the
8839 patterns are tested in order, it makes sense to put the most commonly matched
8840 patterns earlier.
8841
8842
8843
8844 .section "Host lists" "SECThostlist"
8845 .cindex "host list" "patterns in"
8846 .cindex "list" "host list"
8847 Host lists are used to control what remote hosts are allowed to do. For
8848 example, some hosts may be allowed to use the local host as a relay, and some
8849 may be permitted to use the SMTP ETRN command. Hosts can be identified in
8850 two different ways, by name or by IP address. In a host list, some types of
8851 pattern are matched to a host name, and some are matched to an IP address.
8852 You need to be particularly careful with this when single-key lookups are
8853 involved, to ensure that the right value is being used as the key.
8854
8855
8856 .subsection "Special host list patterns" SECID80
8857 .cindex "empty item in hosts list"
8858 .cindex "host list" "empty string in"
8859 If a host list item is the empty string, it matches only when no remote host is
8860 involved. This is the case when a message is being received from a local
8861 process using SMTP on the standard input, that is, when a TCP/IP connection is
8862 not used.
8863
8864 .cindex "asterisk" "in host list"
8865 The special pattern &"*"& in a host list matches any host or no host. Neither
8866 the IP address nor the name is actually inspected.
8867
8868
8869
8870 .subsection "Host list patterns that match by IP address" SECThoslispatip
8871 .cindex "host list" "matching IP addresses"
8872 If an IPv4 host calls an IPv6 host and the call is accepted on an IPv6 socket,
8873 the incoming address actually appears in the IPv6 host as
8874 &`::ffff:`&<&'v4address'&>. When such an address is tested against a host
8875 list, it is converted into a traditional IPv4 address first. (Not all operating
8876 systems accept IPv4 calls on IPv6 sockets, as there have been some security
8877 concerns.)
8878
8879 The following types of pattern in a host list check the remote host by
8880 inspecting its IP address:
8881
8882 .ilist
8883 If the pattern is a plain domain name (not a regular expression, not starting
8884 with *, not a lookup of any kind), Exim calls the operating system function
8885 to find the associated IP address(es). Exim uses the newer
8886 &[getipnodebyname()]& function when available, otherwise &[gethostbyname()]&.
8887 This typically causes a forward DNS lookup of the name. The result is compared
8888 with the IP address of the subject host.
8889
8890 If there is a temporary problem (such as a DNS timeout) with the host name
8891 lookup, a temporary error occurs. For example, if the list is being used in an
8892 ACL condition, the ACL gives a &"defer"& response, usually leading to a
8893 temporary SMTP error code. If no IP address can be found for the host name,
8894 what happens is described in section &<<SECTbehipnot>>& below.
8895
8896 .next
8897 .cindex "@ in a host list"
8898 If the pattern is &"@"&, the primary host name is substituted and used as a
8899 domain name, as just described.
8900
8901 .next
8902 If the pattern is an IP address, it is matched against the IP address of the
8903 subject host. IPv4 addresses are given in the normal &"dotted-quad"& notation.
8904 IPv6 addresses can be given in colon-separated format, but the colons have to
8905 be doubled so as not to be taken as item separators when the default list
8906 separator is used. IPv6 addresses are recognized even when Exim is compiled
8907 without IPv6 support. This means that if they appear in a host list on an
8908 IPv4-only host, Exim will not treat them as host names. They are just addresses
8909 that can never match a client host.
8910
8911 .next
8912 .cindex "@[] in a host list"
8913 If the pattern is &"@[]"&, it matches the IP address of any IP interface on
8914 the local host. For example, if the local host is an IPv4 host with one
8915 interface address 10.45.23.56, these two ACL statements have the same effect:
8916 .code
8917 accept hosts = 127.0.0.1 : 10.45.23.56
8918 accept hosts = @[]
8919 .endd
8920 .next
8921 .cindex "CIDR notation"
8922 If the pattern is an IP address followed by a slash and a mask length, for
8923 example
8924 .code
8925 10.11.42.0/24
8926 .endd
8927 , it is matched against the IP address of the subject
8928 host under the given mask. This allows an entire network of hosts to be
8929 included (or excluded) by a single item. The mask uses CIDR notation; it
8930 specifies the number of address bits that must match, starting from the most
8931 significant end of the address.
8932
8933 &*Note*&: The mask is &'not'& a count of addresses, nor is it the high number
8934 of a range of addresses. It is the number of bits in the network portion of the
8935 address. The above example specifies a 24-bit netmask, so it matches all 256
8936 addresses in the 10.11.42.0 network. An item such as
8937 .code
8938 192.168.23.236/31
8939 .endd
8940 matches just two addresses, 192.168.23.236 and 192.168.23.237. A mask value of
8941 32 for an IPv4 address is the same as no mask at all; just a single address
8942 matches.
8943
8944 Here is another example which shows an IPv4 and an IPv6 network:
8945 .code
8946 recipient_unqualified_hosts = 192.168.0.0/16: \
8947                               3ffe::ffff::836f::::/48
8948 .endd
8949 The doubling of list separator characters applies only when these items
8950 appear inline in a host list. It is not required when indirecting via a file.
8951 For example:
8952 .code
8953 recipient_unqualified_hosts = /opt/exim/unqualnets
8954 .endd
8955 could make use of a file containing
8956 .code
8957 172.16.0.0/12
8958 3ffe:ffff:836f::/48
8959 .endd
8960 to have exactly the same effect as the previous example. When listing IPv6
8961 addresses inline, it is usually more convenient to use the facility for
8962 changing separator characters. This list contains the same two networks:
8963 .code
8964 recipient_unqualified_hosts = <; 172.16.0.0/12; \
8965                                  3ffe:ffff:836f::/48
8966 .endd
8967 The separator is changed to semicolon by the leading &"<;"& at the start of the
8968 list.
8969 .endlist
8970
8971
8972
8973 .subsection "Host list patterns for single-key lookups by host address" &&&
8974          SECThoslispatsikey
8975 .cindex "host list" "lookup of IP address"
8976 When a host is to be identified by a single-key lookup of its complete IP
8977 address, the pattern takes this form:
8978 .display
8979 &`net-<`&&'single-key-search-type'&&`>;<`&&'search-data'&&`>`&
8980 .endd
8981 For example:
8982 .code
8983 hosts_lookup = net-cdb;/hosts-by-ip.db
8984 .endd
8985 The text form of the IP address of the subject host is used as the lookup key.
8986 IPv6 addresses are converted to an unabbreviated form, using lower case
8987 letters, with dots as separators because colon is the key terminator in
8988 &(lsearch)& files. [Colons can in fact be used in keys in &(lsearch)& files by
8989 quoting the keys, but this is a facility that was added later.] The data
8990 returned by the lookup is not used.
8991
8992 .cindex "IP address" "masking"
8993 .cindex "host list" "masked IP address"
8994 Single-key lookups can also be performed using masked IP addresses, using
8995 patterns of this form:
8996 .display
8997 &`net<`&&'number'&&`>-<`&&'single-key-search-type'&&`>;<`&&'search-data'&&`>`&
8998 .endd
8999 For example:
9000 .code
9001 net24-dbm;/networks.db
9002 .endd
9003 The IP address of the subject host is masked using <&'number'&> as the mask
9004 length. A textual string is constructed from the masked value, followed by the
9005 mask, and this is used as the lookup key. For example, if the host's IP address
9006 is 192.168.34.6, the key that is looked up for the above example is
9007 &"192.168.34.0/24"&.
9008
9009 When an IPv6 address is converted to a string, dots are normally used instead
9010 of colons, so that keys in &(lsearch)& files need not contain colons (which
9011 terminate &(lsearch)& keys). This was implemented some time before the ability
9012 to quote keys was made available in &(lsearch)& files. However, the more
9013 recently implemented &(iplsearch)& files do require colons in IPv6 keys
9014 (notated using the quoting facility) so as to distinguish them from IPv4 keys.
9015 For this reason, when the lookup type is &(iplsearch)&, IPv6 addresses are
9016 converted using colons and not dots.
9017 In all cases except IPv4-mapped IPv6, full, unabbreviated IPv6
9018 addresses are always used.
9019 The latter are converted to IPv4 addresses, in dotted-quad form.
9020
9021 Ideally, it would be nice to tidy up this anomalous situation by changing to
9022 colons in all cases, given that quoting is now available for &(lsearch)&.
9023 However, this would be an incompatible change that might break some existing
9024 configurations.
9025
9026 &*Warning*&: Specifying &%net32-%& (for an IPv4 address) or &%net128-%& (for an
9027 IPv6 address) is not the same as specifying just &%net-%& without a number. In
9028 the former case the key strings include the mask value, whereas in the latter
9029 case the IP address is used on its own.
9030
9031
9032
9033 .subsection "Host list patterns that match by host name" SECThoslispatnam
9034 .cindex "host" "lookup failures"
9035 .cindex "unknown host name"
9036 .cindex "host list" "matching host name"
9037 There are several types of pattern that require Exim to know the name of the
9038 remote host. These are either wildcard patterns or lookups by name. (If a
9039 complete hostname is given without any wildcarding, it is used to find an IP
9040 address to match against, as described in section &<<SECThoslispatip>>&
9041 above.)
9042
9043 If the remote host name is not already known when Exim encounters one of these
9044 patterns, it has to be found from the IP address.
9045 Although many sites on the Internet are conscientious about maintaining reverse
9046 DNS data for their hosts, there are also many that do not do this.
9047 Consequently, a name cannot always be found, and this may lead to unwanted
9048 effects. Take care when configuring host lists with wildcarded name patterns.
9049 Consider what will happen if a name cannot be found.
9050
9051 Because of the problems of determining host names from IP addresses, matching
9052 against host names is not as common as matching against IP addresses.
9053
9054 By default, in order to find a host name, Exim first does a reverse DNS lookup;
9055 if no name is found in the DNS, the system function (&[gethostbyaddr()]& or
9056 &[getipnodebyaddr()]& if available) is tried. The order in which these lookups
9057 are done can be changed by setting the &%host_lookup_order%& option. For
9058 security, once Exim has found one or more names, it looks up the IP addresses
9059 for these names and compares them with the IP address that it started with.
9060 Only those names whose IP addresses match are accepted. Any other names are
9061 discarded. If no names are left, Exim behaves as if the host name cannot be
9062 found. In the most common case there is only one name and one IP address.
9063
9064 There are some options that control what happens if a host name cannot be
9065 found. These are described in section &<<SECTbehipnot>>& below.
9066
9067 .cindex "host" "alias for"
9068 .cindex "alias for host"
9069 As a result of aliasing, hosts may have more than one name. When processing any
9070 of the following types of pattern, all the host's names are checked:
9071
9072 .ilist
9073 .cindex "asterisk" "in host list"
9074 If a pattern starts with &"*"& the remainder of the item must match the end of
9075 the host name. For example, &`*.b.c`& matches all hosts whose names end in
9076 &'.b.c'&. This special simple form is provided because this is a very common
9077 requirement. Other kinds of wildcarding require the use of a regular
9078 expression.
9079 .next
9080 .cindex "regular expressions" "in host list"
9081 .cindex "host list" "regular expression in"
9082 If the item starts with &"^"& it is taken to be a regular expression which is
9083 matched against the host name. Host names are case-independent, so this regular
9084 expression match is by default case-independent, but you can make it
9085 case-dependent by starting it with &`(?-i)`&. References to descriptions of the
9086 syntax of regular expressions are given in chapter &<<CHAPregexp>>&. For
9087 example,
9088 .code
9089 ^(a|b)\.c\.d$
9090 .endd
9091 is a regular expression that matches either of the two hosts &'a.c.d'& or
9092 &'b.c.d'&. When a regular expression is used in a host list, you must take care
9093 that backslash and dollar characters are not misinterpreted as part of the
9094 string expansion. The simplest way to do this is to use &`\N`& to mark that
9095 part of the string as non-expandable. For example:
9096 .code
9097 sender_unqualified_hosts = \N^(a|b)\.c\.d$\N : ....
9098 .endd
9099 &*Warning*&: If you want to match a complete host name, you must include the
9100 &`$`& terminating metacharacter in the regular expression, as in the above
9101 example. Without it, a match at the start of the host name is all that is
9102 required.
9103 .endlist
9104
9105
9106
9107
9108 .subsection "Behaviour when an IP address or name cannot be found" SECTbehipnot
9109 .cindex "host" "lookup failures, permanent"
9110 While processing a host list, Exim may need to look up an IP address from a
9111 name (see section &<<SECThoslispatip>>&), or it may need to look up a host name
9112 from an IP address (see section &<<SECThoslispatnam>>&). In either case, the
9113 behaviour when it fails to find the information it is seeking is the same.
9114
9115 &*Note*&: This section applies to permanent lookup failures. It does &'not'&
9116 apply to temporary DNS errors, whose handling is described in the next section.
9117
9118 .cindex "&`+include_unknown`&"
9119 .cindex "&`+ignore_unknown`&"
9120 Exim parses a host list from left to right. If it encounters a permanent
9121 lookup failure in any item in the host list before it has found a match,
9122 Exim treats it as a failure and the default behavior is as if the host
9123 does not match the list. This may not always be what you want to happen.
9124 To change Exim's behaviour, the special items &`+include_unknown`& or
9125 &`+ignore_unknown`& may appear in the list (at top level &-- they are
9126 not recognized in an indirected file).
9127
9128 .ilist
9129 If any item that follows &`+include_unknown`& requires information that
9130 cannot found, Exim behaves as if the host does match the list. For example,
9131 .code
9132 host_reject_connection = +include_unknown:*.enemy.ex
9133 .endd
9134 rejects connections from any host whose name matches &`*.enemy.ex`&, and also
9135 any hosts whose name it cannot find.
9136
9137 .next
9138 If any item that follows &`+ignore_unknown`& requires information that cannot
9139 be found, Exim ignores that item and proceeds to the rest of the list. For
9140 example:
9141 .code
9142 accept hosts = +ignore_unknown : friend.example : \
9143                192.168.4.5
9144 .endd
9145 accepts from any host whose name is &'friend.example'& and from 192.168.4.5,
9146 whether or not its host name can be found. Without &`+ignore_unknown`&, if no
9147 name can be found for 192.168.4.5, it is rejected.
9148 .endlist
9149
9150 Both &`+include_unknown`& and &`+ignore_unknown`& may appear in the same
9151 list. The effect of each one lasts until the next, or until the end of the
9152 list.
9153
9154 .subsection "Mixing wildcarded host names and addresses in host lists" &&&
9155          SECTmixwilhos
9156 .cindex "host list" "mixing names and addresses in"
9157
9158 This section explains the host/ip processing logic with the same concepts
9159 as the previous section, but specifically addresses what happens when a
9160 wildcarded hostname is one of the items in the hostlist.
9161
9162 .ilist
9163 If you have name lookups or wildcarded host names and
9164 IP addresses in the same host list, you should normally put the IP
9165 addresses first. For example, in an ACL you could have:
9166 .code
9167 accept hosts = 10.9.8.7 : *.friend.example
9168 .endd
9169 The reason you normally would order it this way lies in the
9170 left-to-right way that Exim processes lists.  It can test IP addresses
9171 without doing any DNS lookups, but when it reaches an item that requires
9172 a host name, it fails if it cannot find a host name to compare with the
9173 pattern. If the above list is given in the opposite order, the
9174 &%accept%& statement fails for a host whose name cannot be found, even
9175 if its IP address is 10.9.8.7.
9176
9177 .next
9178 If you really do want to do the name check first, and still recognize the IP
9179 address, you can rewrite the ACL like this:
9180 .code
9181 accept hosts = *.friend.example
9182 accept hosts = 10.9.8.7
9183 .endd
9184 If the first &%accept%& fails, Exim goes on to try the second one. See chapter
9185 &<<CHAPACL>>& for details of ACLs. Alternatively, you can use
9186 &`+ignore_unknown`&, which was discussed in depth in the first example in
9187 this section.
9188 .endlist
9189
9190
9191 .subsection "Temporary DNS errors when looking up host information" &&&
9192          SECTtemdnserr
9193 .cindex "host" "lookup failures, temporary"
9194 .cindex "&`+include_defer`&"
9195 .cindex "&`+ignore_defer`&"
9196 A temporary DNS lookup failure normally causes a defer action (except when
9197 &%dns_again_means_nonexist%& converts it into a permanent error). However,
9198 host lists can include &`+ignore_defer`& and &`+include_defer`&, analogous to
9199 &`+ignore_unknown`& and &`+include_unknown`&, as described in the previous
9200 section. These options should be used with care, probably only in non-critical
9201 host lists such as whitelists.
9202
9203
9204
9205 .subsection "Host list patterns for single-key lookups by host name" &&&
9206          SECThoslispatnamsk
9207 .cindex "unknown host name"
9208 .cindex "host list" "matching host name"
9209 If a pattern is of the form
9210 .display
9211 <&'single-key-search-type'&>;<&'search-data'&>
9212 .endd
9213 for example
9214 .code
9215 dbm;/host/accept/list
9216 .endd
9217 a single-key lookup is performed, using the host name as its key. If the
9218 lookup succeeds, the host matches the item. The actual data that is looked up
9219 is not used.
9220
9221 &*Reminder*&: With this kind of pattern, you must have host &'names'& as
9222 keys in the file, not IP addresses. If you want to do lookups based on IP
9223 addresses, you must precede the search type with &"net-"& (see section
9224 &<<SECThoslispatsikey>>&). There is, however, no reason why you could not use
9225 two items in the same list, one doing an address lookup and one doing a name
9226 lookup, both using the same file.
9227
9228
9229
9230 .subsection "Host list patterns for query-style lookups" SECID81
9231 If a pattern is of the form
9232 .display
9233 <&'query-style-search-type'&>;<&'query'&>
9234 .endd
9235 the query is obeyed, and if it succeeds, the host matches the item. The actual
9236 data that is looked up is not used. The variables &$sender_host_address$& and
9237 &$sender_host_name$& can be used in the query. For example:
9238 .code
9239 hosts_lookup = pgsql;\
9240   select ip from hostlist where ip='$sender_host_address'
9241 .endd
9242 The value of &$sender_host_address$& for an IPv6 address contains colons. You
9243 can use the &%sg%& expansion item to change this if you need to. If you want to
9244 use masked IP addresses in database queries, you can use the &%mask%& expansion
9245 operator.
9246
9247 If the query contains a reference to &$sender_host_name$&, Exim automatically
9248 looks up the host name if it has not already done so. (See section
9249 &<<SECThoslispatnam>>& for comments on finding host names.)
9250
9251 Historical note: prior to release 4.30, Exim would always attempt to find a
9252 host name before running the query, unless the search type was preceded by
9253 &`net-`&. This is no longer the case. For backwards compatibility, &`net-`& is
9254 still recognized for query-style lookups, but its presence or absence has no
9255 effect. (Of course, for single-key lookups, &`net-`& &'is'& important.
9256 See section &<<SECThoslispatsikey>>&.)
9257
9258
9259
9260
9261
9262 .section "Address lists" "SECTaddresslist"
9263 .cindex "list" "address list"
9264 .cindex "address list" "empty item"
9265 .cindex "address list" "patterns"
9266 Address lists contain patterns that are matched against mail addresses. There
9267 is one special case to be considered: the sender address of a bounce message is
9268 always empty. You can test for this by providing an empty item in an address
9269 list. For example, you can set up a router to process bounce messages by
9270 using this option setting:
9271 .code
9272 senders = :
9273 .endd
9274 The presence of the colon creates an empty item. If you do not provide any
9275 data, the list is empty and matches nothing. The empty sender can also be
9276 detected by a regular expression that matches an empty string,
9277 and by a query-style lookup that succeeds when &$sender_address$& is empty.
9278
9279 Non-empty items in an address list can be straightforward email addresses. For
9280 example:
9281 .code
9282 senders = jbc@askone.example : hs@anacreon.example
9283 .endd
9284 A certain amount of wildcarding is permitted. If a pattern contains an @
9285 character, but is not a regular expression and does not begin with a
9286 semicolon-terminated lookup type (described below), the local part of the
9287 subject address is compared with the local part of the pattern, which may start
9288 with an asterisk. If the local parts match, the domain is checked in exactly
9289 the same way as for a pattern in a domain list. For example, the domain can be
9290 wildcarded, refer to a named list, or be a lookup:
9291 .code
9292 deny senders = *@*.spamming.site:\
9293                *@+hostile_domains:\
9294                bozo@partial-lsearch;/list/of/dodgy/sites:\
9295                *@dbm;/bad/domains.db
9296 .endd
9297 .cindex "local part" "starting with !"
9298 .cindex "address list" "local part starting with !"
9299 If a local part that begins with an exclamation mark is required, it has to be
9300 specified using a regular expression, because otherwise the exclamation mark is
9301 treated as a sign of negation, as is standard in lists.
9302
9303 If a non-empty pattern that is not a regular expression or a lookup does not
9304 contain an @ character, it is matched against the domain part of the subject
9305 address. The only two formats that are recognized this way are a literal
9306 domain, or a domain pattern that starts with *. In both these cases, the effect
9307 is the same as if &`*@`& preceded the pattern. For example:
9308 .code
9309 deny senders = enemy.domain : *.enemy.domain
9310 .endd
9311
9312 The following kinds of more complicated address list pattern can match any
9313 address, including the empty address that is characteristic of bounce message
9314 senders:
9315
9316 .ilist
9317 .cindex "regular expressions" "in address list"
9318 .cindex "address list" "regular expression in"
9319 If (after expansion) a pattern starts with &"^"&, a regular expression match is
9320 done against the complete address, with the pattern as the regular expression.
9321 You must take care that backslash and dollar characters are not misinterpreted
9322 as part of the string expansion. The simplest way to do this is to use &`\N`&
9323 to mark that part of the string as non-expandable. For example:
9324 .code
9325 deny senders = \N^.*this.*@example\.com$\N : \
9326                \N^\d{8}.+@spamhaus.example$\N : ...
9327 .endd
9328 The &`\N`& sequences are removed by the expansion, so these items do indeed
9329 start with &"^"& by the time they are being interpreted as address patterns.
9330
9331 .next
9332 .cindex "address list" "lookup for complete address"
9333 Complete addresses can be looked up by using a pattern that starts with a
9334 lookup type terminated by a semicolon, followed by the data for the lookup. For
9335 example:
9336 .code
9337 deny senders = cdb;/etc/blocked.senders : \
9338   mysql;select address from blocked where \
9339   address='${quote_mysql:$sender_address}'
9340 .endd
9341 Both query-style and single-key lookup types can be used. For a single-key
9342 lookup type, Exim uses the complete address as the key. However, empty keys are
9343 not supported for single-key lookups, so a match against the empty address
9344 always fails. This restriction does not apply to query-style lookups.
9345
9346 Partial matching for single-key lookups (section &<<SECTpartiallookup>>&)
9347 cannot be used, and is ignored if specified, with an entry being written to the
9348 panic log.
9349 .cindex "*@ with single-key lookup"
9350 However, you can configure lookup defaults, as described in section
9351 &<<SECTdefaultvaluelookups>>&, but this is useful only for the &"*@"& type of
9352 default. For example, with this lookup:
9353 .code
9354 accept senders = lsearch*@;/some/file
9355 .endd
9356 the file could contains lines like this:
9357 .code
9358 user1@domain1.example
9359 *@domain2.example
9360 .endd
9361 and for the sender address &'nimrod@jaeger.example'&, the sequence of keys
9362 that are tried is:
9363 .code
9364 nimrod@jaeger.example
9365 *@jaeger.example
9366 *
9367 .endd
9368 &*Warning 1*&: Do not include a line keyed by &"*"& in the file, because that
9369 would mean that every address matches, thus rendering the test useless.
9370
9371 &*Warning 2*&: Do not confuse these two kinds of item:
9372 .code
9373 deny recipients = dbm*@;/some/file
9374 deny recipients = *@dbm;/some/file
9375 .endd
9376 The first does a whole address lookup, with defaulting, as just described,
9377 because it starts with a lookup type. The second matches the local part and
9378 domain independently, as described in a bullet point below.
9379 .endlist
9380
9381
9382 The following kinds of address list pattern can match only non-empty addresses.
9383 If the subject address is empty, a match against any of these pattern types
9384 always fails.
9385
9386
9387 .ilist
9388 .cindex "@@ with single-key lookup"
9389 .cindex "address list" "@@ lookup type"
9390 .cindex "address list" "split local part and domain"
9391 If a pattern starts with &"@@"& followed by a single-key lookup item
9392 (for example, &`@@lsearch;/some/file`&), the address that is being checked is
9393 split into a local part and a domain. The domain is looked up in the file. If
9394 it is not found, there is no match. If it is found, the data that is looked up
9395 from the file is treated as a colon-separated list of local part patterns, each
9396 of which is matched against the subject local part in turn.
9397
9398 .cindex "asterisk" "in address list"
9399 The lookup may be a partial one, and/or one involving a search for a default
9400 keyed by &"*"& (see section &<<SECTdefaultvaluelookups>>&). The local part
9401 patterns that are looked up can be regular expressions or begin with &"*"&, or
9402 even be further lookups. They may also be independently negated. For example,
9403 with
9404 .code
9405 deny senders = @@dbm;/etc/reject-by-domain
9406 .endd
9407 the data from which the DBM file is built could contain lines like
9408 .code
9409 baddomain.com:  !postmaster : *
9410 .endd
9411 to reject all senders except &%postmaster%& from that domain.
9412
9413 .cindex "local part" "starting with !"
9414 If a local part that actually begins with an exclamation mark is required, it
9415 has to be specified using a regular expression. In &(lsearch)& files, an entry
9416 may be split over several lines by indenting the second and subsequent lines,
9417 but the separating colon must still be included at line breaks. White space
9418 surrounding the colons is ignored. For example:
9419 .code
9420 aol.com:  spammer1 : spammer2 : ^[0-9]+$ :
9421   spammer3 : spammer4
9422 .endd
9423 As in all colon-separated lists in Exim, a colon can be included in an item by
9424 doubling.
9425
9426 If the last item in the list starts with a right angle-bracket, the remainder
9427 of the item is taken as a new key to look up in order to obtain a continuation
9428 list of local parts. The new key can be any sequence of characters. Thus one
9429 might have entries like
9430 .code
9431 aol.com: spammer1 : spammer 2 : >*
9432 xyz.com: spammer3 : >*
9433 *:       ^\d{8}$
9434 .endd
9435 in a file that was searched with &%@@dbm*%&, to specify a match for 8-digit
9436 local parts for all domains, in addition to the specific local parts listed for
9437 each domain. Of course, using this feature costs another lookup each time a
9438 chain is followed, but the effort needed to maintain the data is reduced.
9439
9440 .cindex "loop" "in lookups"
9441 It is possible to construct loops using this facility, and in order to catch
9442 them, the chains may be no more than fifty items long.
9443
9444 .next
9445 The @@<&'lookup'&> style of item can also be used with a query-style
9446 lookup, but in this case, the chaining facility is not available. The lookup
9447 can only return a single list of local parts.
9448 .endlist
9449
9450 &*Warning*&: There is an important difference between the address list items
9451 in these two examples:
9452 .code
9453 senders = +my_list
9454 senders = *@+my_list
9455 .endd
9456 In the first one, &`my_list`& is a named address list, whereas in the second
9457 example it is a named domain list.
9458
9459
9460
9461
9462 .subsection "Case of letters in address lists" SECTcasletadd
9463 .cindex "case of local parts"
9464 .cindex "address list" "case forcing"
9465 .cindex "case forcing in address lists"
9466 Domains in email addresses are always handled caselessly, but for local parts
9467 case may be significant on some systems (see &%caseful_local_part%& for how
9468 Exim deals with this when routing addresses). However, RFC 2505 (&'Anti-Spam
9469 Recommendations for SMTP MTAs'&) suggests that matching of addresses to
9470 blocking lists should be done in a case-independent manner. Since most address
9471 lists in Exim are used for this kind of control, Exim attempts to do this by
9472 default.
9473
9474 The domain portion of an address is always lowercased before matching it to an
9475 address list. The local part is lowercased by default, and any string
9476 comparisons that take place are done caselessly. This means that the data in
9477 the address list itself, in files included as plain filenames, and in any file
9478 that is looked up using the &"@@"& mechanism, can be in any case. However, the
9479 keys in files that are looked up by a search type other than &(lsearch)& (which
9480 works caselessly) must be in lower case, because these lookups are not
9481 case-independent.
9482
9483 .cindex "&`+caseful`&"
9484 To allow for the possibility of caseful address list matching, if an item in
9485 an address list is the string &"+caseful"&, the original case of the local
9486 part is restored for any comparisons that follow, and string comparisons are no
9487 longer case-independent. This does not affect the domain, which remains in
9488 lower case. However, although independent matches on the domain alone are still
9489 performed caselessly, regular expressions that match against an entire address
9490 become case-sensitive after &"+caseful"& has been seen.
9491
9492
9493
9494 .section "Local part lists" "SECTlocparlis"
9495 .cindex "list" "local part list"
9496 .cindex "local part" "list"
9497 These behave in the same way as domain and host lists, with the following
9498 changes:
9499
9500 Case-sensitivity in local part lists is handled in the same way as for address
9501 lists, as just described. The &"+caseful"& item can be used if required. In a
9502 setting of the &%local_parts%& option in a router with &%caseful_local_part%&
9503 set false, the subject is lowercased and the matching is initially
9504 case-insensitive. In this case, &"+caseful"& will restore case-sensitive
9505 matching in the local part list, but not elsewhere in the router. If
9506 &%caseful_local_part%& is set true in a router, matching in the &%local_parts%&
9507 option is case-sensitive from the start.
9508
9509 If a local part list is indirected to a file (see section &<<SECTfilnamlis>>&),
9510 comments are handled in the same way as address lists &-- they are recognized
9511 only if the # is preceded by white space or the start of the line.
9512 Otherwise, local part lists are matched in the same way as domain lists, except
9513 that the special items that refer to the local host (&`@`&, &`@[]`&,
9514 &`@mx_any`&, &`@mx_primary`&, and &`@mx_secondary`&) are not recognized.
9515 Refer to section &<<SECTdomainlist>>& for details of the other available item
9516 types.
9517 .ecindex IIDdohoadli
9518
9519
9520
9521
9522 . ////////////////////////////////////////////////////////////////////////////
9523 . ////////////////////////////////////////////////////////////////////////////
9524
9525 .chapter "String expansions" "CHAPexpand"
9526 .scindex IIDstrexp "expansion" "of strings"
9527 Many strings in Exim's runtime configuration are expanded before use. Some of
9528 them are expanded every time they are used; others are expanded only once.
9529
9530 When a string is being expanded it is copied verbatim from left to right except
9531 .cindex expansion "string concatenation"
9532 when a dollar or backslash character is encountered. A dollar specifies the
9533 start of a portion of the string that is interpreted and replaced as described
9534 below in section &<<SECTexpansionitems>>& onwards. Backslash is used as an
9535 escape character, as described in the following section.
9536
9537 Whether a string is expanded depends upon the context.  Usually this is solely
9538 dependent upon the option for which a value is sought; in this documentation,
9539 options for which string expansion is performed are marked with &dagger; after
9540 the data type.  ACL rules always expand strings.  A couple of expansion
9541 conditions do not expand some of the brace-delimited branches, for security
9542 reasons,
9543 .cindex "tainted data" expansion
9544 .cindex "tainted data" definition
9545 .cindex expansion "tainted data"
9546 and expansion of data deriving from the sender (&"tainted data"&)
9547 is not permitted (including acessing a file using a tainted name).
9548
9549 Common ways of obtaining untainted equivalents of variables with
9550 tainted values
9551 .cindex "tainted data" "de-tainting"
9552 come down to using the tainted value as a lookup key in a trusted database.
9553 This database could be the filesystem structure,
9554 or the password file,
9555 or accessed via a DBMS.
9556 Specific methods are indexed under &"de-tainting"&.
9557
9558
9559
9560 .section "Literal text in expanded strings" "SECTlittext"
9561 .cindex "expansion" "including literal text"
9562 An uninterpreted dollar can be included in an expanded string by putting a
9563 backslash in front of it. A backslash can be used to prevent any special
9564 character being treated specially in an expansion, including backslash itself.
9565 If the string appears in quotes in the configuration file, two backslashes are
9566 required because the quotes themselves cause interpretation of backslashes when
9567 the string is read in (see section &<<SECTstrings>>&).
9568
9569 .cindex "expansion" "non-expandable substrings"
9570 A portion of the string can specified as non-expandable by placing it between
9571 two occurrences of &`\N`&. This is particularly useful for protecting regular
9572 expressions, which often contain backslashes and dollar signs. For example:
9573 .code
9574 deny senders = \N^\d{8}[a-z]@some\.site\.example$\N
9575 .endd
9576 On encountering the first &`\N`&, the expander copies subsequent characters
9577 without interpretation until it reaches the next &`\N`& or the end of the
9578 string.
9579
9580
9581
9582 .section "Character escape sequences in expanded strings" "SECID82"
9583 .cindex "expansion" "escape sequences"
9584 A backslash followed by one of the letters &"n"&, &"r"&, or &"t"& in an
9585 expanded string is recognized as an escape sequence for the character newline,
9586 carriage return, or tab, respectively. A backslash followed by up to three
9587 octal digits is recognized as an octal encoding for a single character, and a
9588 backslash followed by &"x"& and up to two hexadecimal digits is a hexadecimal
9589 encoding.
9590
9591 These escape sequences are also recognized in quoted strings when they are read
9592 in. Their interpretation in expansions as well is useful for unquoted strings,
9593 and for other cases such as looked-up strings that are then expanded.
9594
9595
9596 .section "Testing string expansions" "SECID83"
9597 .cindex "expansion" "testing"
9598 .cindex "testing" "string expansion"
9599 .oindex "&%-be%&"
9600 Many expansions can be tested by calling Exim with the &%-be%& option. This
9601 takes the command arguments, or lines from the standard input if there are no
9602 arguments, runs them through the string expansion code, and writes the results
9603 to the standard output. Variables based on configuration values are set up, but
9604 since no message is being processed, variables such as &$local_part$& have no
9605 value. Nevertheless the &%-be%& option can be useful for checking out file and
9606 database lookups, and the use of expansion operators such as &%sg%&, &%substr%&
9607 and &%nhash%&.
9608
9609 When reading lines from the standard input,
9610 macros can be defined and ACL variables can be set.
9611 For example:
9612 .code
9613 MY_MACRO = foo
9614 set acl_m_myvar = bar
9615 .endd
9616 Such macros and variables can then be used in later input lines.
9617
9618 Exim gives up its root privilege when it is called with the &%-be%& option, and
9619 instead runs under the uid and gid it was called with, to prevent users from
9620 using &%-be%& for reading files to which they do not have access.
9621
9622 .oindex "&%-bem%&"
9623 If you want to test expansions that include variables whose values are taken
9624 from a message, there are two other options that can be used. The &%-bem%&
9625 option is like &%-be%& except that it is followed by a filename. The file is
9626 read as a message before doing the test expansions. For example:
9627 .code
9628 exim -bem /tmp/test.message '$h_subject:'
9629 .endd
9630 The &%-Mset%& option is used in conjunction with &%-be%& and is followed by an
9631 Exim message identifier. For example:
9632 .code
9633 exim -be -Mset 1GrA8W-0004WS-LQ '$recipients'
9634 .endd
9635 This loads the message from Exim's spool before doing the test expansions, and
9636 is therefore restricted to admin users.
9637
9638
9639 .section "Forced expansion failure" "SECTforexpfai"
9640 .cindex "expansion" "forced failure"
9641 A number of expansions that are described in the following section have
9642 alternative &"true"& and &"false"& substrings, enclosed in brace characters
9643 (which are sometimes called &"curly brackets"&). Which of the two strings is
9644 used depends on some condition that is evaluated as part of the expansion. If,
9645 instead of a &"false"& substring, the word &"fail"& is used (not in braces),
9646 the entire string expansion fails in a way that can be detected by the code
9647 that requested the expansion. This is called &"forced expansion failure"&, and
9648 its consequences depend on the circumstances. In some cases it is no different
9649 from any other expansion failure, but in others a different action may be
9650 taken. Such variations are mentioned in the documentation of the option that is
9651 being expanded.
9652
9653
9654
9655
9656 .section "Expansion items" "SECTexpansionitems"
9657 The following items are recognized in expanded strings. White space may be used
9658 between sub-items that are keywords or substrings enclosed in braces inside an
9659 outer set of braces, to improve readability. &*Warning*&: Within braces,
9660 white space is significant.
9661
9662 .vlist
9663 .vitem &*$*&<&'variable&~name'&>&~or&~&*${*&<&'variable&~name'&>&*}*&
9664 .cindex "expansion" "variables"
9665 Substitute the contents of the named variable, for example:
9666 .code
9667 $local_part
9668 ${domain}
9669 .endd
9670 The second form can be used to separate the name from subsequent alphanumeric
9671 characters. This form (using braces) is available only for variables; it does
9672 &'not'& apply to message headers. The names of the variables are given in
9673 section &<<SECTexpvar>>& below. If the name of a non-existent variable is
9674 given, the expansion fails.
9675
9676 .vitem &*${*&<&'op'&>&*:*&<&'string'&>&*}*&
9677 .cindex "expansion" "operators"
9678 The string is first itself expanded, and then the operation specified by
9679 <&'op'&> is applied to it. For example:
9680 .code
9681 ${lc:$local_part}
9682 .endd
9683 The string starts with the first character after the colon, which may be
9684 leading white space. A list of operators is given in section &<<SECTexpop>>&
9685 below. The operator notation is used for simple expansion items that have just
9686 one argument, because it reduces the number of braces and therefore makes the
9687 string easier to understand.
9688
9689 .vitem &*$bheader_*&<&'header&~name'&>&*:*&&~or&~&*$bh_*&<&'header&~name'&>&*:*&
9690 This item inserts &"basic"& header lines. It is described with the &%header%&
9691 expansion item below.
9692
9693
9694 .vitem "&*${acl{*&<&'name'&>&*}{*&<&'arg'&>&*}...}*&"
9695 .cindex "expansion" "calling an acl"
9696 .cindex "&%acl%&" "call from expansion"
9697 The name and zero to nine argument strings are first expanded separately.  The expanded
9698 arguments are assigned to the variables &$acl_arg1$& to &$acl_arg9$& in order.
9699 Any unused are made empty.  The variable &$acl_narg$& is set to the number of
9700 arguments.  The named ACL (see chapter &<<CHAPACL>>&) is called
9701 and may use the variables; if another acl expansion is used the values
9702 are restored after it returns.  If the ACL sets
9703 a value using a "message =" modifier and returns accept or deny, the value becomes
9704 the result of the expansion.
9705 If no message is set and the ACL returns accept or deny
9706 the expansion result is an empty string.
9707 If the ACL returns defer the result is a forced-fail.  Otherwise the expansion fails.
9708
9709
9710 .vitem "&*${authresults{*&<&'authserv-id'&>&*}}*&"
9711 .cindex authentication "results header"
9712 .chindex Authentication-Results:
9713 .cindex authentication "expansion item"
9714 This item returns a string suitable for insertion as an
9715 &'Authentication-Results:'&
9716 header line.
9717 The given <&'authserv-id'&> is included in the result; typically this
9718 will be a domain name identifying the system performing the authentications.
9719 Methods that might be present in the result include:
9720 .code
9721 none
9722 iprev
9723 auth
9724 spf
9725 dkim
9726 .endd
9727
9728 Example use (as an ACL modifier):
9729 .code
9730       add_header = :at_start:${authresults {$primary_hostname}}
9731 .endd
9732 This is safe even if no authentication results are available
9733 and would generally be placed in the DATA ACL.
9734
9735
9736 .vitem "&*${certextract{*&<&'field'&>&*}{*&<&'certificate'&>&*}&&&
9737        {*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&"
9738 .cindex "expansion" "extracting certificate fields"
9739 .cindex "&%certextract%&" "certificate fields"
9740 .cindex "certificate" "extracting fields"
9741 The <&'certificate'&> must be a variable of type certificate.
9742 The field name is expanded and used to retrieve the relevant field from
9743 the certificate.  Supported fields are:
9744 .display
9745 &`version        `&
9746 &`serial_number  `&
9747 &`subject        `& RFC4514 DN
9748 &`issuer         `& RFC4514 DN
9749 &`notbefore      `& time
9750 &`notafter       `& time
9751 &`sig_algorithm  `&
9752 &`signature      `&
9753 &`subj_altname   `& tagged list
9754 &`ocsp_uri       `& list
9755 &`crl_uri        `& list
9756 .endd
9757 If the field is found,
9758 <&'string2'&> is expanded, and replaces the whole item;
9759 otherwise <&'string3'&> is used. During the expansion of <&'string2'&> the
9760 variable &$value$& contains the value that has been extracted. Afterwards, it
9761 is restored to any previous value it might have had.
9762
9763 If {<&'string3'&>} is omitted, the item is replaced by an empty string if the
9764 key is not found. If {<&'string2'&>} is also omitted, the value that was
9765 extracted is used.
9766
9767 Some field names take optional modifiers, appended and separated by commas.
9768
9769 The field selectors marked as "RFC4514" above
9770 output a Distinguished Name string which is
9771 not quite
9772 parseable by Exim as a comma-separated tagged list
9773 (the exceptions being elements containing commas).
9774 RDN elements of a single type may be selected by
9775 a modifier of the type label; if so the expansion
9776 result is a list (newline-separated by default).
9777 The separator may be changed by another modifier of
9778 a right angle-bracket followed immediately by the new separator.
9779 Recognised RDN type labels include "CN", "O", "OU" and "DC".
9780
9781 The field selectors marked as "time" above
9782 take an optional modifier of "int"
9783 for which the result is the number of seconds since epoch.
9784 Otherwise the result is a human-readable string
9785 in the timezone selected by the main "timezone" option.
9786
9787 The field selectors marked as "list" above return a list,
9788 newline-separated by default,
9789 (embedded separator characters in elements are doubled).
9790 The separator may be changed by a modifier of
9791 a right angle-bracket followed immediately by the new separator.
9792
9793 The field selectors marked as "tagged" above
9794 prefix each list element with a type string and an equals sign.
9795 Elements of only one type may be selected by a modifier
9796 which is one of "dns", "uri" or "mail";
9797 if so the element tags are omitted.
9798
9799 If not otherwise noted field values are presented in human-readable form.
9800
9801 .vitem "&*${dlfunc{*&<&'file'&>&*}{*&<&'function'&>&*}{*&<&'arg'&>&*}&&&
9802        {*&<&'arg'&>&*}...}*&"
9803 .cindex &%dlfunc%&
9804 This expansion dynamically loads and then calls a locally-written C function.
9805 This functionality is available only if Exim is compiled with
9806 .code
9807 EXPAND_DLFUNC=yes
9808 .endd
9809 set in &_Local/Makefile_&. Once loaded, Exim remembers the dynamically loaded
9810 object so that it doesn't reload the same object file in the same Exim process
9811 (but of course Exim does start new processes frequently).
9812
9813 There may be from zero to eight arguments to the function.
9814
9815 When compiling
9816 a local function that is to be called in this way,
9817 first &_DLFUNC_IMPL_& should be defined,
9818 and second &_local_scan.h_& should be included.
9819 The Exim variables and functions that are defined by that API
9820 are also available for dynamically loaded functions. The function itself
9821 must have the following type:
9822 .code
9823 int dlfunction(uschar **yield, int argc, uschar *argv[])
9824 .endd
9825 Where &`uschar`& is a typedef for &`unsigned char`& in &_local_scan.h_&. The
9826 function should return one of the following values:
9827
9828 &`OK`&: Success. The string that is placed in the variable &'yield'& is put
9829 into the expanded string that is being built.
9830
9831 &`FAIL`&: A non-forced expansion failure occurs, with the error message taken
9832 from &'yield'&, if it is set.
9833
9834 &`FAIL_FORCED`&: A forced expansion failure occurs, with the error message
9835 taken from &'yield'& if it is set.
9836
9837 &`ERROR`&: Same as &`FAIL`&, except that a panic log entry is written.
9838
9839 When compiling a function that is to be used in this way with gcc,
9840 you need to add &%-shared%& to the gcc command. Also, in the Exim build-time
9841 configuration, you must add &%-export-dynamic%& to EXTRALIBS.
9842
9843
9844 .vitem "&*${env{*&<&'key'&>&*}{*&<&'string1'&>&*}{*&<&'string2'&>&*}}*&"
9845 .cindex "expansion" "extracting value from environment"
9846 .cindex "environment" "values from"
9847 The key is first expanded separately, and leading and trailing white space
9848 removed.
9849 This is then searched for as a name in the environment.
9850 If a variable is found then its value is placed in &$value$&
9851 and <&'string1'&> is expanded, otherwise <&'string2'&> is expanded.
9852
9853 Instead of {<&'string2'&>} the word &"fail"& (not in curly brackets) can
9854 appear, for example:
9855 .code
9856 ${env{USER}{$value} fail }
9857 .endd
9858 This forces an expansion failure (see section &<<SECTforexpfai>>&);
9859 {<&'string1'&>} must be present for &"fail"& to be recognized.
9860
9861 If {<&'string2'&>} is omitted an empty string is substituted on
9862 search failure.
9863 If {<&'string1'&>} is omitted the search result is substituted on
9864 search success.
9865
9866 The environment is adjusted by the &%keep_environment%& and
9867 &%add_environment%& main section options.
9868
9869
9870 .vitem "&*${extract{*&<&'key'&>&*}{*&<&'string1'&>&*}{*&<&'string2'&>&*}&&&
9871        {*&<&'string3'&>&*}}*&"
9872 .cindex "expansion" "extracting substrings by key"
9873 .cindex "&%extract%&" "substrings by key"
9874 The key and <&'string1'&> are first expanded separately. Leading and trailing
9875 white space is removed from the key (but not from any of the strings). The key
9876 must not be empty and must not consist entirely of digits.
9877 The expanded <&'string1'&> must be of the form:
9878 .display
9879 <&'key1'&> = <&'value1'&>  <&'key2'&> = <&'value2'&> ...
9880 .endd
9881 .vindex "&$value$&"
9882 where the equals signs and spaces (but not both) are optional. If any of the
9883 values contain white space, they must be enclosed in double quotes, and any
9884 values that are enclosed in double quotes are subject to escape processing as
9885 described in section &<<SECTstrings>>&. The expanded <&'string1'&> is searched
9886 for the value that corresponds to the key. The search is case-insensitive. If
9887 the key is found, <&'string2'&> is expanded, and replaces the whole item;
9888 otherwise <&'string3'&> is used. During the expansion of <&'string2'&> the
9889 variable &$value$& contains the value that has been extracted. Afterwards, it
9890 is restored to any previous value it might have had.
9891
9892 If {<&'string3'&>} is omitted, the item is replaced by an empty string if the
9893 key is not found. If {<&'string2'&>} is also omitted, the value that was
9894 extracted is used. Thus, for example, these two expansions are identical, and
9895 yield &"2001"&:
9896 .code
9897 ${extract{gid}{uid=1984 gid=2001}}
9898 ${extract{gid}{uid=1984 gid=2001}{$value}}
9899 .endd
9900 Instead of {<&'string3'&>} the word &"fail"& (not in curly brackets) can
9901 appear, for example:
9902 .code
9903 ${extract{Z}{A=... B=...}{$value} fail }
9904 .endd
9905 This forces an expansion failure (see section &<<SECTforexpfai>>&);
9906 {<&'string2'&>} must be present for &"fail"& to be recognized.
9907
9908 .vitem "&*${extract json{*&<&'key'&>&*}{*&<&'string1'&>&*}{*&<&'string2'&>&*}&&&
9909        {*&<&'string3'&>&*}}*&" &&&
9910        "&*${extract jsons{*&<&'key'&>&*}{*&<&'string1'&>&*}{*&<&'string2'&>&*}&&&
9911        {*&<&'string3'&>&*}}*&"
9912 .cindex "expansion" "extracting from JSON object"
9913 .cindex JSON expansions
9914 The key and <&'string1'&> are first expanded separately. Leading and trailing
9915 white space is removed from the key (but not from any of the strings). The key
9916 must not be empty and must not consist entirely of digits.
9917 The expanded <&'string1'&> must be of the form:
9918 .display
9919 { <&'"key1"'&> : <&'value1'&> ,  <&'"key2"'&> , <&'value2'&> ... }
9920 .endd
9921 .vindex "&$value$&"
9922 The braces, commas and colons, and the quoting of the member name are required;
9923 the spaces are optional.
9924 Matching of the key against the member names is done case-sensitively.
9925 For the &"json"& variant,
9926 if a returned value is a JSON string, it retains its leading and
9927 trailing quotes.
9928 For the &"jsons"& variant, which is intended for use with JSON strings, the
9929 leading and trailing quotes are removed from the returned value.
9930 . XXX should be a UTF-8 compare
9931
9932 The results of matching are handled as above.
9933
9934
9935 .vitem "&*${extract{*&<&'number'&>&*}{*&<&'separators'&>&*}&&&
9936         {*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&"
9937 .cindex "expansion" "extracting substrings by number"
9938 .cindex "&%extract%&" "substrings by number"
9939 The <&'number'&> argument must consist entirely of decimal digits,
9940 apart from leading and trailing white space, which is ignored.
9941 This is what distinguishes this form of &%extract%& from the previous kind. It
9942 behaves in the same way, except that, instead of extracting a named field, it
9943 extracts from <&'string1'&> the field whose number is given as the first
9944 argument. You can use &$value$& in <&'string2'&> or &`fail`& instead of
9945 <&'string3'&> as before.
9946
9947 The fields in the string are separated by any one of the characters in the
9948 separator string. These may include space or tab characters.
9949 The first field is numbered one. If the number is negative, the fields are
9950 counted from the end of the string, with the rightmost one numbered -1. If the
9951 number given is zero, the entire string is returned. If the modulus of the
9952 number is greater than the number of fields in the string, the result is the
9953 expansion of <&'string3'&>, or the empty string if <&'string3'&> is not
9954 provided. For example:
9955 .code
9956 ${extract{2}{:}{x:42:99:& Mailer::/bin/bash}}
9957 .endd
9958 yields &"42"&, and
9959 .code
9960 ${extract{-4}{:}{x:42:99:& Mailer::/bin/bash}}
9961 .endd
9962 yields &"99"&. Two successive separators mean that the field between them is
9963 empty (for example, the fifth field above).
9964
9965
9966 .vitem "&*${extract json {*&<&'number'&>&*}}&&&
9967         {*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&" &&&
9968        "&*${extract jsons{*&<&'number'&>&*}}&&&
9969         {*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&"
9970 .cindex "expansion" "extracting from JSON array"
9971 .cindex JSON expansions
9972 The <&'number'&> argument must consist entirely of decimal digits,
9973 apart from leading and trailing white space, which is ignored.
9974
9975 Field selection and result handling is as above;
9976 there is no choice of field separator.
9977 For the &"json"& variant,
9978 if a returned value is a JSON string, it retains its leading and
9979 trailing quotes.
9980 For the &"jsons"& variant, which is intended for use with JSON strings, the
9981 leading and trailing quotes are removed from the returned value.
9982
9983
9984 .vitem &*${filter{*&<&'string'&>&*}{*&<&'condition'&>&*}}*&
9985 .cindex "list" "selecting by condition"
9986 .cindex "expansion" "selecting from list by condition"
9987 .vindex "&$item$&"
9988 After expansion, <&'string'&> is interpreted as a list, colon-separated by
9989 default, but the separator can be changed in the usual way (&<<SECTlistsepchange>>&).
9990 For each item
9991 in this list, its value is placed in &$item$&, and then the condition is
9992 evaluated.
9993 Any modification of &$value$& by this evaluation is discarded.
9994 If the condition is true, &$item$& is added to the output as an
9995 item in a new list; if the condition is false, the item is discarded. The
9996 separator used for the output list is the same as the one used for the
9997 input, but a separator setting is not included in the output. For example:
9998 .code
9999 ${filter{a:b:c}{!eq{$item}{b}}}
10000 .endd
10001 yields &`a:c`&. At the end of the expansion, the value of &$item$& is restored
10002 to what it was before.
10003 See also the &%map%& and &%reduce%& expansion items.
10004
10005
10006 .vitem &*${hash{*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&
10007 .cindex "hash function" "textual"
10008 .cindex "expansion" "textual hash"
10009 This is a textual hashing function, and was the first to be implemented in
10010 early versions of Exim. In current releases, there are other hashing functions
10011 (numeric, MD5, and SHA-1), which are described below.
10012
10013 The first two strings, after expansion, must be numbers. Call them <&'m'&> and
10014 <&'n'&>. If you are using fixed values for these numbers, that is, if
10015 <&'string1'&> and <&'string2'&> do not change when they are expanded, you can
10016 use the simpler operator notation that avoids some of the braces:
10017 .code
10018 ${hash_<n>_<m>:<string>}
10019 .endd
10020 The second number is optional (in both notations). If <&'n'&> is greater than
10021 or equal to the length of the string, the expansion item returns the string.
10022 Otherwise it computes a new string of length <&'n'&> by applying a hashing
10023 function to the string. The new string consists of characters taken from the
10024 first <&'m'&> characters of the string
10025 .code
10026 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQWRSTUVWXYZ0123456789
10027 .endd
10028 If <&'m'&> is not present the value 26 is used, so that only lower case
10029 letters appear. For example:
10030 .display
10031 &`$hash{3}{monty}}           `&   yields  &`jmg`&
10032 &`$hash{5}{monty}}           `&   yields  &`monty`&
10033 &`$hash{4}{62}{monty python}}`&   yields  &`fbWx`&
10034 .endd
10035
10036 .vitem "&*$header_*&<&'header&~name'&>&*:*&&~or&~&&&
10037         &*$h_*&<&'header&~name'&>&*:*&" &&&
10038        "&*$bheader_*&<&'header&~name'&>&*:*&&~or&~&&&
10039         &*$bh_*&<&'header&~name'&>&*:*&" &&&
10040        "&*$lheader_*&<&'header&~name'&>&*:*&&~or&~&&&
10041         &*$lh_*&<&'header&~name'&>&*:*&" &&&
10042        "&*$rheader_*&<&'header&~name'&>&*:*&&~or&~&&&
10043         &*$rh_*&<&'header&~name'&>&*:*&"
10044 .cindex "expansion" "header insertion"
10045 .vindex "&$header_$&"
10046 .vindex "&$bheader_$&"
10047 .vindex "&$lheader_$&"
10048 .vindex "&$rheader_$&"
10049 .cindex "header lines" "in expansion strings"
10050 .cindex "header lines" "character sets"
10051 .cindex "header lines" "decoding"
10052 Substitute the contents of the named message header line, for example
10053 .code
10054 $header_reply-to:
10055 .endd
10056 The newline that terminates a header line is not included in the expansion, but
10057 internal newlines (caused by splitting the header line over several physical
10058 lines) may be present.
10059
10060 The difference between the four pairs of expansions is in the way
10061 the data in the header line is interpreted.
10062
10063 .ilist
10064 .cindex "white space" "in header lines"
10065 &%rheader%& gives the original &"raw"& content of the header line, with no
10066 processing at all, and without the removal of leading and trailing white space.
10067
10068 .next
10069 .cindex "list" "of header lines"
10070 &%lheader%& gives a colon-separated list, one element per header when there
10071 are multiple headers with a given name.
10072 Any embedded colon characters within an element are doubled, so normal Exim
10073 list-processing facilities can be used.
10074 The terminating newline of each element is removed; in other respects
10075 the content is &"raw"&.
10076
10077 .next
10078 .cindex "base64 encoding" "in header lines"
10079 &%bheader%& removes leading and trailing white space, and then decodes base64
10080 or quoted-printable MIME &"words"& within the header text, but does no
10081 character set translation. If decoding of what looks superficially like a MIME
10082 &"word"& fails, the raw string is returned. If decoding
10083 .cindex "binary zero" "in header line"
10084 produces a binary zero character, it is replaced by a question mark &-- this is
10085 what Exim does for binary zeros that are actually received in header lines.
10086
10087 .next
10088 &%header%& tries to translate the string as decoded by &%bheader%& to a
10089 standard character set. This is an attempt to produce the same string as would
10090 be displayed on a user's MUA. If translation fails, the &%bheader%& string is
10091 returned. Translation is attempted only on operating systems that support the
10092 &[iconv()]& function. This is indicated by the compile-time macro HAVE_ICONV in
10093 a system Makefile or in &_Local/Makefile_&.
10094 .endlist ilist
10095
10096 In a filter file, the target character set for &%header%& can be specified by a
10097 command of the following form:
10098 .code
10099 headers charset "UTF-8"
10100 .endd
10101 This command affects all references to &$h_$& (or &$header_$&) expansions in
10102 subsequently obeyed filter commands. In the absence of this command, the target
10103 character set in a filter is taken from the setting of the &%headers_charset%&
10104 option in the runtime configuration. The value of this option defaults to the
10105 value of HEADERS_CHARSET in &_Local/Makefile_&. The ultimate default is
10106 ISO-8859-1.
10107
10108 Header names follow the syntax of RFC 2822, which states that they may contain
10109 any printing characters except space and colon. Consequently, curly brackets
10110 &'do not'& terminate header names, and should not be used to enclose them as
10111 if they were variables. Attempting to do so causes a syntax error.
10112
10113 Only header lines that are common to all copies of a message are visible to
10114 this mechanism. These are the original header lines that are received with the
10115 message, and any that are added by an ACL statement or by a system
10116 filter. Header lines that are added to a particular copy of a message by a
10117 router or transport are not accessible.
10118
10119 For incoming SMTP messages, no header lines are visible in
10120 ACLs that are obeyed before the data phase completes,
10121 because the header structure is not set up until the message is received.
10122 They are visible in DKIM, PRDR and DATA ACLs.
10123 Header lines that are added in a RCPT ACL (for example)
10124 are saved until the message's incoming header lines are available, at which
10125 point they are added.
10126 When any of the above ACLs are
10127 running, however, header lines added by earlier ACLs are visible.
10128
10129 Upper case and lower case letters are synonymous in header names. If the
10130 following character is white space, the terminating colon may be omitted, but
10131 this is not recommended, because you may then forget it when it is needed. When
10132 white space terminates the header name, this white space is included in the
10133 expanded string.  If the message does not contain the given header, the
10134 expansion item is replaced by an empty string. (See the &%def%& condition in
10135 section &<<SECTexpcond>>& for a means of testing for the existence of a
10136 header.)
10137
10138 If there is more than one header with the same name, they are all concatenated
10139 to form the substitution string, up to a maximum length of 64K. Unless
10140 &%rheader%& is being used, leading and trailing white space is removed from
10141 each header before concatenation, and a completely empty header is ignored. A
10142 newline character is then inserted between non-empty headers, but there is no
10143 newline at the very end. For the &%header%& and &%bheader%& expansion, for
10144 those headers that contain lists of addresses, a comma is also inserted at the
10145 junctions between headers. This does not happen for the &%rheader%& expansion.
10146
10147 .cindex "tainted data" "message headers"
10148 When the headers are from an incoming message,
10149 the result of expanding any of these variables is tainted.
10150
10151
10152 .vitem &*${hmac{*&<&'hashname'&>&*}{*&<&'secret'&>&*}{*&<&'string'&>&*}}*&
10153 .cindex "expansion" "hmac hashing"
10154 .cindex &%hmac%&
10155 This function uses cryptographic hashing (either MD5 or SHA-1) to convert a
10156 shared secret and some text into a message authentication code, as specified in
10157 RFC 2104. This differs from &`${md5:secret_text...}`& or
10158 &`${sha1:secret_text...}`& in that the hmac step adds a signature to the
10159 cryptographic hash, allowing for authentication that is not possible with MD5
10160 or SHA-1 alone. The hash name must expand to either &`md5`& or &`sha1`& at
10161 present. For example:
10162 .code
10163 ${hmac{md5}{somesecret}{$primary_hostname $tod_log}}
10164 .endd
10165 For the hostname &'mail.example.com'& and time 2002-10-17 11:30:59, this
10166 produces:
10167 .code
10168 dd97e3ba5d1a61b5006108f8c8252953
10169 .endd
10170 As an example of how this might be used, you might put in the main part of
10171 an Exim configuration:
10172 .code
10173 SPAMSCAN_SECRET=cohgheeLei2thahw
10174 .endd
10175 In a router or a transport you could then have:
10176 .code
10177 headers_add = \
10178   X-Spam-Scanned: ${primary_hostname} ${message_exim_id} \
10179   ${hmac{md5}{SPAMSCAN_SECRET}\
10180   {${primary_hostname},${message_exim_id},$h_message-id:}}
10181 .endd
10182 Then given a message, you can check where it was scanned by looking at the
10183 &'X-Spam-Scanned:'& header line. If you know the secret, you can check that
10184 this header line is authentic by recomputing the authentication code from the
10185 host name, message ID and the &'Message-id:'& header line. This can be done
10186 using Exim's &%-be%& option, or by other means, for example, by using the
10187 &'hmac_md5_hex()'& function in Perl.
10188
10189
10190 .vitem &*${if&~*&<&'condition'&>&*&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}}*&
10191 .cindex "expansion" "conditional"
10192 .cindex "&%if%&, expansion item"
10193 If <&'condition'&> is true, <&'string1'&> is expanded and replaces the whole
10194 item; otherwise <&'string2'&> is used. The available conditions are described
10195 in section &<<SECTexpcond>>& below. For example:
10196 .code
10197 ${if eq {$local_part}{postmaster} {yes}{no} }
10198 .endd
10199 The second string need not be present; if it is not and the condition is not
10200 true, the item is replaced with nothing. Alternatively, the word &"fail"& may
10201 be present instead of the second string (without any curly brackets). In this
10202 case, the expansion is forced to fail if the condition is not true (see section
10203 &<<SECTforexpfai>>&).
10204
10205 If both strings are omitted, the result is the string &`true`& if the condition
10206 is true, and the empty string if the condition is false. This makes it less
10207 cumbersome to write custom ACL and router conditions. For example, instead of
10208 .code
10209 condition = ${if >{$acl_m4}{3}{true}{false}}
10210 .endd
10211 you can use
10212 .code
10213 condition = ${if >{$acl_m4}{3}}
10214 .endd
10215
10216
10217
10218 .vitem &*${imapfolder{*&<&'foldername'&>&*}}*&
10219 .cindex expansion "imap folder"
10220 .cindex "&%imapfolder%& expansion item"
10221 This item converts a (possibly multilevel, or with non-ASCII characters)
10222 folder specification to a Maildir name for filesystem use.
10223 For information on internationalisation support see &<<SECTi18nMDA>>&.
10224
10225
10226
10227 .vitem &*${length{*&<&'string1'&>&*}{*&<&'string2'&>&*}}*&
10228 .cindex "expansion" "string truncation"
10229 .cindex "&%length%& expansion item"
10230 The &%length%& item is used to extract the initial portion of a string. Both
10231 strings are expanded, and the first one must yield a number, <&'n'&>, say. If
10232 you are using a fixed value for the number, that is, if <&'string1'&> does not
10233 change when expanded, you can use the simpler operator notation that avoids
10234 some of the braces:
10235 .code
10236 ${length_<n>:<string>}
10237 .endd
10238 The result of this item is either the first <&'n'&> bytes or the whole
10239 of <&'string2'&>, whichever is the shorter. Do not confuse &%length%& with
10240 &%strlen%&, which gives the length of a string.
10241 All measurement is done in bytes and is not UTF-8 aware.
10242
10243
10244 .vitem "&*${listextract{*&<&'number'&>&*}&&&
10245         {*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&"
10246 .cindex "expansion" "extracting list elements by number"
10247 .cindex "&%listextract%&" "extract list elements by number"
10248 .cindex "list" "extracting elements by number"
10249 The <&'number'&> argument must consist entirely of decimal digits,
10250 apart from an optional leading minus,
10251 and leading and trailing white space (which is ignored).
10252
10253 After expansion, <&'string1'&> is interpreted as a list, colon-separated by
10254 default, but the separator can be changed in the usual way (&<<SECTlistsepchange>>&).
10255
10256 The first field of the list is numbered one.
10257 If the number is negative, the fields are
10258 counted from the end of the list, with the rightmost one numbered -1.
10259 The numbered element of the list is extracted and placed in &$value$&,
10260 then <&'string2'&> is expanded as the result.
10261
10262 If the modulus of the
10263 number is zero or greater than the number of fields in the string,
10264 the result is the expansion of <&'string3'&>.
10265
10266 For example:
10267 .code
10268 ${listextract{2}{x:42:99}}
10269 .endd
10270 yields &"42"&, and
10271 .code
10272 ${listextract{-3}{<, x,42,99,& Mailer,,/bin/bash}{result: $value}}
10273 .endd
10274 yields &"result: 42"&.
10275
10276 If {<&'string3'&>} is omitted, an empty string is used for string3.
10277 If {<&'string2'&>} is also omitted, the value that was
10278 extracted is used.
10279 You can use &`fail`& instead of {<&'string3'&>} as in a string extract.
10280
10281
10282 .vitem &*${listquote{*&<&'separator'&>&*}{*&<&'string'&>&*}}*&
10283 .cindex quoting "for list"
10284 .cindex list quoting
10285 This item doubles any occurrence of the separator character
10286 in the given string.
10287 An empty string is replaced with a single space.
10288 This converts the string into a safe form for use as a list element,
10289 in a list using the given separator.
10290
10291
10292 .vitem "&*${lookup&~{*&<&'key'&>&*}&~*&<&'search&~type'&>&*&~&&&
10293         {*&<&'file'&>&*}&~{*&<&'string1'&>&*}&~{*&<&'string2'&>&*}}*&" &&&
10294        "&*${lookup&~*&<&'search&~type'&>&*&~{*&<&'query'&>&*}&~&&&
10295         {*&<&'string1'&>&*}&~{*&<&'string2'&>&*}}*&"
10296 .cindex "expansion" "lookup in"
10297 .cindex "file" "lookups"
10298 .cindex "lookup" "in expanded string"
10299 The two forms of lookup item specify data lookups in files and databases, as
10300 discussed in chapter &<<CHAPfdlookup>>&. The first form is used for single-key
10301 lookups, and the second is used for query-style lookups. The <&'key'&>,
10302 <&'file'&>, and <&'query'&> strings are expanded before use.
10303
10304 If there is any white space in a lookup item which is part of a filter command,
10305 a retry or rewrite rule, a routing rule for the &(manualroute)& router, or any
10306 other place where white space is significant, the lookup item must be enclosed
10307 in double quotes. The use of data lookups in users' filter files may be locked
10308 out by the system administrator.
10309
10310 .vindex "&$value$&"
10311 If the lookup succeeds, <&'string1'&> is expanded and replaces the entire item.
10312 During its expansion, the variable &$value$& contains the data returned by the
10313 lookup. Afterwards it reverts to the value it had previously (at the outer
10314 level it is empty). If the lookup fails, <&'string2'&> is expanded and replaces
10315 the entire item. If {<&'string2'&>} is omitted, the replacement is the empty
10316 string on failure. If <&'string2'&> is provided, it can itself be a nested
10317 lookup, thus providing a mechanism for looking up a default value when the
10318 original lookup fails.
10319
10320 If a nested lookup is used as part of <&'string1'&>, &$value$& contains the
10321 data for the outer lookup while the parameters of the second lookup are
10322 expanded, and also while <&'string2'&> of the second lookup is expanded, should
10323 the second lookup fail. Instead of {<&'string2'&>} the word &"fail"& can
10324 appear, and in this case, if the lookup fails, the entire expansion is forced
10325 to fail (see section &<<SECTforexpfai>>&). If both {<&'string1'&>} and
10326 {<&'string2'&>} are omitted, the result is the looked up value in the case of a
10327 successful lookup, and nothing in the case of failure.
10328
10329 For single-key lookups, the string &"partial"& is permitted to precede the
10330 search type in order to do partial matching, and * or *@ may follow a search
10331 type to request default lookups if the key does not match (see sections
10332 &<<SECTdefaultvaluelookups>>& and &<<SECTpartiallookup>>& for details).
10333
10334 .cindex "numerical variables (&$1$& &$2$& etc)" "in lookup expansion"
10335 If a partial search is used, the variables &$1$& and &$2$& contain the wild
10336 and non-wild parts of the key during the expansion of the replacement text.
10337 They return to their previous values at the end of the lookup item.
10338
10339 This example looks up the postmaster alias in the conventional alias file:
10340 .code
10341 ${lookup {postmaster} lsearch {/etc/aliases} {$value}}
10342 .endd
10343 This example uses NIS+ to look up the full name of the user corresponding to
10344 the local part of an address, forcing the expansion to fail if it is not found:
10345 .code
10346 ${lookup nisplus {[name=$local_part],passwd.org_dir:gcos} \
10347   {$value}fail}
10348 .endd
10349
10350
10351 .vitem &*${map{*&<&'string1'&>&*}{*&<&'string2'&>&*}}*&
10352 .cindex "expansion" "list creation"
10353 .vindex "&$item$&"
10354 After expansion, <&'string1'&> is interpreted as a list, colon-separated by
10355 default, but the separator can be changed in the usual way (&<<SECTlistsepchange>>&).
10356 For each item
10357 in this list, its value is place in &$item$&, and then <&'string2'&> is
10358 expanded and added to the output as an item in a new list. The separator used
10359 for the output list is the same as the one used for the input, but a separator
10360 setting is not included in the output. For example:
10361 .code
10362 ${map{a:b:c}{[$item]}} ${map{<- x-y-z}{($item)}}
10363 .endd
10364 expands to &`[a]:[b]:[c] (x)-(y)-(z)`&. At the end of the expansion, the
10365 value of &$item$& is restored to what it was before. See also the &%filter%&
10366 and &%reduce%& expansion items.
10367
10368 .vitem &*${nhash{*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&
10369 .cindex "expansion" "numeric hash"
10370 .cindex "hash function" "numeric"
10371 The three strings are expanded; the first two must yield numbers. Call them
10372 <&'n'&> and <&'m'&>. If you are using fixed values for these numbers, that is,
10373 if <&'string1'&> and <&'string2'&> do not change when they are expanded, you
10374 can use the simpler operator notation that avoids some of the braces:
10375 .code
10376 ${nhash_<n>_<m>:<string>}
10377 .endd
10378 The second number is optional (in both notations). If there is only one number,
10379 the result is a number in the range 0&--<&'n'&>-1. Otherwise, the string is
10380 processed by a div/mod hash function that returns two numbers, separated by a
10381 slash, in the ranges 0 to <&'n'&>-1 and 0 to <&'m'&>-1, respectively. For
10382 example,
10383 .code
10384 ${nhash{8}{64}{supercalifragilisticexpialidocious}}
10385 .endd
10386 returns the string &"6/33"&.
10387
10388
10389
10390 .vitem &*${perl{*&<&'subroutine'&>&*}{*&<&'arg'&>&*}{*&<&'arg'&>&*}...}*&
10391 .cindex "Perl" "use in expanded string"
10392 .cindex "expansion" "calling Perl from"
10393 This item is available only if Exim has been built to include an embedded Perl
10394 interpreter. The subroutine name and the arguments are first separately
10395 expanded, and then the Perl subroutine is called with those arguments. No
10396 additional arguments need be given; the maximum number permitted, including the
10397 name of the subroutine, is nine.
10398
10399 The return value of the subroutine is inserted into the expanded string, unless
10400 the return value is &%undef%&. In that case, the entire expansion is
10401 forced to fail, in the same way as an explicit &"fail"& on a lookup item
10402 does (see section &<<SECTforexpfai>>&).  Whatever you return is evaluated
10403 in a scalar context, thus the return value is a scalar.  For example, if you
10404 return a Perl vector, the return value is the size of the vector,
10405 not its contents.
10406
10407 If the subroutine exits by calling Perl's &%die%& function, the expansion fails
10408 with the error message that was passed to &%die%&. More details of the embedded
10409 Perl facility are given in chapter &<<CHAPperl>>&.
10410
10411 The &(redirect)& router has an option called &%forbid_filter_perl%& which locks
10412 out the use of this expansion item in filter files.
10413
10414
10415 .vitem &*${prvs{*&<&'address'&>&*}{*&<&'secret'&>&*}{*&<&'keynumber'&>&*}}*&
10416 .cindex "&%prvs%& expansion item"
10417 The first argument is a complete email address and the second is secret
10418 keystring. The third argument, specifying a key number, is optional. If absent,
10419 it defaults to 0. The result of the expansion is a prvs-signed email address,
10420 to be typically used with the &%return_path%& option on an &(smtp)& transport
10421 as part of a bounce address tag validation (BATV) scheme. For more discussion
10422 and an example, see section &<<SECTverifyPRVS>>&.
10423
10424 .vitem "&*${prvscheck{*&<&'address'&>&*}{*&<&'secret'&>&*}&&&
10425         {*&<&'string'&>&*}}*&"
10426 .cindex "&%prvscheck%& expansion item"
10427 This expansion item is the complement of the &%prvs%& item. It is used for
10428 checking prvs-signed addresses. If the expansion of the first argument does not
10429 yield a syntactically valid prvs-signed address, the whole item expands to the
10430 empty string. When the first argument does expand to a syntactically valid
10431 prvs-signed address, the second argument is expanded, with the prvs-decoded
10432 version of the address and the key number extracted from the address in the
10433 variables &$prvscheck_address$& and &$prvscheck_keynum$&, respectively.
10434
10435 These two variables can be used in the expansion of the second argument to
10436 retrieve the secret. The validity of the prvs-signed address is then checked
10437 against the secret. The result is stored in the variable &$prvscheck_result$&,
10438 which is empty for failure or &"1"& for success.
10439
10440 The third argument is optional; if it is missing, it defaults to an empty
10441 string. This argument is now expanded. If the result is an empty string, the
10442 result of the expansion is the decoded version of the address. This is the case
10443 whether or not the signature was valid. Otherwise, the result of the expansion
10444 is the expansion of the third argument.
10445
10446 All three variables can be used in the expansion of the third argument.
10447 However, once the expansion is complete, only &$prvscheck_result$& remains set.
10448 For more discussion and an example, see section &<<SECTverifyPRVS>>&.
10449
10450 .vitem &*${readfile{*&<&'file&~name'&>&*}{*&<&'eol&~string'&>&*}}*&
10451 .cindex "expansion" "inserting an entire file"
10452 .cindex "file" "inserting into expansion"
10453 .cindex "&%readfile%& expansion item"
10454 The filename and end-of-line (eol) string are first expanded separately. The file is
10455 then read, and its contents replace the entire item. All newline characters in
10456 the file are replaced by the end-of-line string if it is present. Otherwise,
10457 newlines are left in the string.
10458 String expansion is not applied to the contents of the file. If you want this,
10459 you must wrap the item in an &%expand%& operator. If the file cannot be read,
10460 the string expansion fails.
10461
10462 The &(redirect)& router has an option called &%forbid_filter_readfile%& which
10463 locks out the use of this expansion item in filter files.
10464
10465
10466
10467 .vitem "&*${readsocket{*&<&'name'&>&*}{*&<&'request'&>&*}&&&
10468         {*&<&'options'&>&*}{*&<&'eol&~string'&>&*}{*&<&'fail&~string'&>&*}}*&"
10469 .cindex "expansion" "inserting from a socket"
10470 .cindex "socket, use of in expansion"
10471 .cindex "&%readsocket%& expansion item"
10472 This item inserts data from a Unix domain or TCP socket into the expanded
10473 string. The minimal way of using it uses just two arguments, as in these
10474 examples:
10475 .code
10476 ${readsocket{/socket/name}{request string}}
10477 ${readsocket{inet:some.host:1234}{request string}}
10478 .endd
10479 For a Unix domain socket, the first substring must be the path to the socket.
10480 For an Internet socket, the first substring must contain &`inet:`& followed by
10481 a host name or IP address, followed by a colon and a port, which can be a
10482 number or the name of a TCP port in &_/etc/services_&. An IP address may
10483 optionally be enclosed in square brackets. This is best for IPv6 addresses. For
10484 example:
10485 .code
10486 ${readsocket{inet:[::1]:1234}{request string}}
10487 .endd
10488 Only a single host name may be given, but if looking it up yields more than
10489 one IP address, they are each tried in turn until a connection is made. For
10490 both kinds of socket, Exim makes a connection, writes the request string
10491 (unless it is an empty string; no terminating NUL is ever sent)
10492 and reads from the socket until an end-of-file
10493 is read. A timeout of 5 seconds is applied. Additional, optional arguments
10494 extend what can be done. Firstly, you can vary the timeout. For example:
10495 .code
10496 ${readsocket{/socket/name}{request string}{3s}}
10497 .endd
10498
10499 The third argument is a list of options, of which the first element is the timeout
10500 and must be present if any options are given.
10501 Further elements are options of form &'name=value'&.
10502 Example:
10503 .code
10504 ${readsocket{/socket/name}{request string}{3s:shutdown=no}}
10505 .endd
10506
10507 The following option names are recognised:
10508 .ilist
10509 &*cache*&
10510 Defines if the result data can be cached for use by a later identical
10511 request in the same process.
10512 Values are &"yes"& or &"no"& (the default).
10513 If not, all cached results for this connection specification
10514 will be invalidated.
10515
10516 .next
10517 &*shutdown*&
10518 Defines whether or not a write-shutdown is done on the connection after
10519 sending the request. Values are &"yes"& (the default) or &"no"&
10520 (preferred, eg. by some webservers).
10521
10522 .next
10523 &*sni*&
10524 Controls the use of Server Name Identification on the connection.
10525 Any nonempty value will be the SNI sent; TLS will be forced.
10526
10527 .next
10528 &*tls*&
10529 Controls the use of TLS on the connection.
10530 Values are &"yes"& or &"no"& (the default).
10531 If it is enabled, a shutdown as described above is never done.
10532 .endlist
10533
10534
10535 A fourth argument allows you to change any newlines that are in the data
10536 that is read, in the same way as for &%readfile%& (see above). This example
10537 turns them into spaces:
10538 .code
10539 ${readsocket{inet:127.0.0.1:3294}{request string}{3s}{ }}
10540 .endd
10541 As with all expansions, the substrings are expanded before the processing
10542 happens. Errors in these sub-expansions cause the expansion to fail. In
10543 addition, the following errors can occur:
10544
10545 .ilist
10546 Failure to create a socket file descriptor;
10547 .next
10548 Failure to connect the socket;
10549 .next
10550 Failure to write the request string;
10551 .next
10552 Timeout on reading from the socket.
10553 .endlist
10554
10555 By default, any of these errors causes the expansion to fail. However, if
10556 you supply a fifth substring, it is expanded and used when any of the above
10557 errors occurs. For example:
10558 .code
10559 ${readsocket{/socket/name}{request string}{3s}{\n}\
10560   {socket failure}}
10561 .endd
10562 You can test for the existence of a Unix domain socket by wrapping this
10563 expansion in &`${if exists`&, but there is a race condition between that test
10564 and the actual opening of the socket, so it is safer to use the fifth argument
10565 if you want to be absolutely sure of avoiding an expansion error for a
10566 non-existent Unix domain socket, or a failure to connect to an Internet socket.
10567
10568 The &(redirect)& router has an option called &%forbid_filter_readsocket%& which
10569 locks out the use of this expansion item in filter files.
10570
10571
10572 .vitem &*${reduce{*&<&'string1'&>}{<&'string2'&>&*}{*&<&'string3'&>&*}}*&
10573 .cindex "expansion" "reducing a list to a scalar"
10574 .cindex "list" "reducing to a scalar"
10575 .vindex "&$value$&"
10576 .vindex "&$item$&"
10577 This operation reduces a list to a single, scalar string. After expansion,
10578 <&'string1'&> is interpreted as a list, colon-separated by default, but the
10579 separator can be changed in the usual way (&<<SECTlistsepchange>>&).
10580 Then <&'string2'&> is expanded and
10581 assigned to the &$value$& variable. After this, each item in the <&'string1'&>
10582 list is assigned to &$item$&, in turn, and <&'string3'&> is expanded for each of
10583 them. The result of that expansion is assigned to &$value$& before the next
10584 iteration. When the end of the list is reached, the final value of &$value$& is
10585 added to the expansion output. The &%reduce%& expansion item can be used in a
10586 number of ways. For example, to add up a list of numbers:
10587 .code
10588 ${reduce {<, 1,2,3}{0}{${eval:$value+$item}}}
10589 .endd
10590 The result of that expansion would be &`6`&. The maximum of a list of numbers
10591 can be found:
10592 .code
10593 ${reduce {3:0:9:4:6}{0}{${if >{$item}{$value}{$item}{$value}}}}
10594 .endd
10595 At the end of a &*reduce*& expansion, the values of &$item$& and &$value$& are
10596 restored to what they were before. See also the &%filter%& and &%map%&
10597 expansion items.
10598
10599 . A bit of a special-case logic error in writing an expansion;
10600 . probably not worth including in the mainline of documentation.
10601 . If only we had footnotes (the html output variant is the problem).
10602 .
10603 . .new
10604 . &*Note*&: if an &'expansion condition'& is used in <&'string3'&>
10605 . and that condition modifies &$value$&,
10606 . then the string expansions dependent on the condition cannot use
10607 . the &$value$& of the reduce iteration.
10608 . .wen
10609
10610 .vitem &*$rheader_*&<&'header&~name'&>&*:*&&~or&~&*$rh_*&<&'header&~name'&>&*:*&
10611 This item inserts &"raw"& header lines. It is described with the &%header%&
10612 expansion item in section &<<SECTexpansionitems>>& above.
10613
10614 .vitem "&*${run<&'options'&> {*&<&'command&~string'&>&*}{*&<&'string1'&>&*}&&&
10615         {*&<&'string2'&>&*}}*&"
10616 .cindex "expansion" "running a command"
10617 .cindex "&%run%& expansion item"
10618 This item runs an external command, as a subprocess.
10619 One option is supported after the word &'run'&, comma-separated
10620 and without whitespace.
10621
10622 If the option &'preexpand'& is not used,
10623 the command string before expansion is split into individual arguments by spaces
10624 and then each argument is separately expanded.
10625 Then the command is run
10626 in a separate process, but under the same uid and gid.  As in other command
10627 executions from Exim, a shell is not used by default. If the command requires
10628 a shell, you must explicitly code it.
10629 The command name may not be tainted, but the remaining arguments can be.
10630
10631 &*Note*&: if tainted arguments are used, they are supplied by a
10632 potential attacker;
10633 a careful assessment for security vulnerabilities should be done.
10634
10635 If the option &'preexpand'& is used,
10636 the command string is first expanded as a whole.
10637 The expansion result is split apart into individual arguments by spaces,
10638 and then the command is run as above.
10639 Since the arguments are split by spaces, when there is a variable expansion
10640 which has an empty result, it will cause the situation that the argument will
10641 simply be omitted when the program is actually executed by Exim. If the
10642 script/program requires a specific number of arguments and the expanded
10643 variable could possibly result in this empty expansion, the variable must be
10644 quoted. This is more difficult if the expanded variable itself could result
10645 in a string containing quotes, because it would interfere with the quotes
10646 around the command arguments. A possible guard against this is to wrap the
10647 variable in the &%sg%& operator to change any quote marks to some other
10648 character.
10649 Neither the command nor any argument may be tainted.
10650
10651 The standard input for the command exists, but is empty. The standard output
10652 and standard error are set to the same file descriptor.
10653 .cindex "return code" "from &%run%& expansion"
10654 .vindex "&$value$&"
10655 If the command succeeds (gives a zero return code) <&'string1'&> is expanded
10656 and replaces the entire item; during this expansion, the standard output/error
10657 from the command is in the variable &$value$&. If the command fails,
10658 <&'string2'&>, if present, is expanded and used. Once again, during the
10659 expansion, the standard output/error from the command is in the variable
10660 &$value$&.
10661
10662 If <&'string2'&> is absent, the result is empty. Alternatively, <&'string2'&>
10663 can be the word &"fail"& (not in braces) to force expansion failure if the
10664 command does not succeed. If both strings are omitted, the result is contents
10665 of the standard output/error on success, and nothing on failure.
10666
10667 .vindex "&$run_in_acl$&"
10668 The standard output/error of the command is put in the variable &$value$&.
10669 In this ACL example, the output of a command is logged for the admin to
10670 troubleshoot:
10671 .code
10672 warn  condition    = ${run{/usr/bin/id}{yes}{no}}
10673       log_message  = Output of id: $value
10674 .endd
10675 If the command requires shell idioms, such as the > redirect operator, the
10676 shell must be invoked directly, such as with:
10677 .code
10678 ${run{/bin/bash -c "/usr/bin/id >/tmp/id"}{yes}{yes}}
10679 .endd
10680 Note that &$value$& will not persist beyond the reception of a single message.
10681
10682 .vindex "&$runrc$&"
10683 The return code from the command is put in the variable &$runrc$&, and this
10684 remains set afterwards, so in a filter file you can do things like this:
10685 .code
10686 if "${run{x y z}{}}$runrc" is 1 then ...
10687   elif $runrc is 2 then ...
10688   ...
10689 endif
10690 .endd
10691 If execution of the command fails (for example, the command does not exist),
10692 the return code is 127 &-- the same code that shells use for non-existent
10693 commands.
10694
10695 &*Warning*&: In a router or transport, you cannot assume the order in which
10696 option values are expanded, except for those preconditions whose order of
10697 testing is documented. Therefore, you cannot reliably expect to set &$runrc$&
10698 by the expansion of one option, and use it in another.
10699
10700 The &(redirect)& router has an option called &%forbid_filter_run%& which locks
10701 out the use of this expansion item in filter files.
10702
10703
10704 .vitem &*${sg{*&<&'subject'&>&*}{*&<&'regex'&>&*}{*&<&'replacement'&>&*}}*&
10705 .cindex "expansion" "string substitution"
10706 .cindex "&%sg%& expansion item"
10707 This item works like Perl's substitution operator (s) with the global (/g)
10708 option; hence its name. However, unlike the Perl equivalent, Exim does not
10709 modify the subject string; instead it returns the modified string for insertion
10710 into the overall expansion. The item takes three arguments: the subject string,
10711 a regular expression, and a substitution string. For example:
10712 .code
10713 ${sg{abcdefabcdef}{abc}{xyz}}
10714 .endd
10715 yields &"xyzdefxyzdef"&. Because all three arguments are expanded before use,
10716 if any $, } or \ characters are required in the regular expression or in the
10717 substitution string, they have to be escaped. For example:
10718 .code
10719 ${sg{abcdef}{^(...)(...)\$}{\$2\$1}}
10720 .endd
10721 yields &"defabc"&, and
10722 .code
10723 ${sg{1=A 4=D 3=C}{\N(\d+)=\N}{K\$1=}}
10724 .endd
10725 yields &"K1=A K4=D K3=C"&. Note the use of &`\N`& to protect the contents of
10726 the regular expression from string expansion.
10727
10728 The regular expression is compiled in 8-bit mode, working against bytes
10729 rather than any Unicode-aware character handling.
10730
10731
10732 .vitem &*${sort{*&<&'string'&>&*}{*&<&'comparator'&>&*}{*&<&'extractor'&>&*}}*&
10733 .cindex sorting "a list"
10734 .cindex list sorting
10735 .cindex expansion "list sorting"
10736 After expansion, <&'string'&> is interpreted as a list, colon-separated by
10737 default, but the separator can be changed in the usual way (&<<SECTlistsepchange>>&).
10738 The <&'comparator'&> argument is interpreted as the operator
10739 of a two-argument expansion condition.
10740 The numeric operators plus ge, gt, le, lt (and ~i variants) are supported.
10741 The comparison should return true when applied to two values
10742 if the first value should sort before the second value.
10743 The <&'extractor'&> expansion is applied repeatedly to elements of the list,
10744 the element being placed in &$item$&,
10745 to give values for comparison.
10746
10747 The item result is a sorted list,
10748 with the original list separator,
10749 of the list elements (in full) of the original.
10750
10751 Examples:
10752 .code
10753 ${sort{3:2:1:4}{<}{$item}}
10754 .endd
10755 sorts a list of numbers, and
10756 .code
10757 ${sort {${lookup dnsdb{>:,,mx=example.com}}} {<} {${listextract{1}{<,$item}}}}
10758 .endd
10759 will sort an MX lookup into priority order.
10760
10761
10762
10763 .vitem &*${srs_encode&~{*&<&'secret'&>&*}{*&<&'return&~path'&>&*}{*&<&'original&~domain'&>&*}}*&
10764 SRS encoding.  See SECT &<<SECTSRS>>& for details.
10765
10766
10767
10768 .vitem &*${substr{*&<&'start'&>&*}{*&<&'len'&>&*}{*&<&'subject'&>&*}}*&
10769 .cindex "&%substr%& expansion item"
10770 .cindex "substring extraction"
10771 .cindex "expansion" "substring extraction"
10772 The three strings are expanded; the first two must yield numbers. Call them
10773 <&'n'&> and <&'m'&>. If you are using fixed values for these numbers, that is,
10774 if <&'start'&> and <&'len'&> do not change when they are expanded, you
10775 can use the simpler operator notation that avoids some of the braces:
10776 .code
10777 ${substr_<n>_<m>:<subject>}
10778 .endd
10779 The second number is optional (in both notations).
10780 If it is absent in the simpler format, the preceding underscore must also be
10781 omitted.
10782
10783 The &%substr%& item can be used to extract more general substrings than
10784 &%length%&. The first number, <&'n'&>, is a starting offset, and <&'m'&> is the
10785 length required. For example
10786 .code
10787 ${substr{3}{2}{$local_part}}
10788 .endd
10789 If the starting offset is greater than the string length the result is the
10790 null string; if the length plus starting offset is greater than the string
10791 length, the result is the right-hand part of the string, starting from the
10792 given offset. The first byte (character) in the string has offset zero.
10793
10794 The &%substr%& expansion item can take negative offset values to count
10795 from the right-hand end of its operand. The last byte (character) is offset -1,
10796 the second-last is offset -2, and so on. Thus, for example,
10797 .code
10798 ${substr{-5}{2}{1234567}}
10799 .endd
10800 yields &"34"&. If the absolute value of a negative offset is greater than the
10801 length of the string, the substring starts at the beginning of the string, and
10802 the length is reduced by the amount of overshoot. Thus, for example,
10803 .code
10804 ${substr{-5}{2}{12}}
10805 .endd
10806 yields an empty string, but
10807 .code
10808 ${substr{-3}{2}{12}}
10809 .endd
10810 yields &"1"&.
10811
10812 When the second number is omitted from &%substr%&, the remainder of the string
10813 is taken if the offset is positive. If it is negative, all bytes (characters) in the
10814 string preceding the offset point are taken. For example, an offset of -1 and
10815 no length, as in these semantically identical examples:
10816 .code
10817 ${substr_-1:abcde}
10818 ${substr{-1}{abcde}}
10819 .endd
10820 yields all but the last character of the string, that is, &"abcd"&.
10821
10822 All measurement is done in bytes and is not UTF-8 aware.
10823
10824
10825
10826 .vitem "&*${tr{*&<&'subject'&>&*}{*&<&'characters'&>&*}&&&
10827         {*&<&'replacements'&>&*}}*&"
10828 .cindex "expansion" "character translation"
10829 .cindex "&%tr%& expansion item"
10830 This item does single-character (in bytes) translation on its subject string. The second
10831 argument is a list of characters to be translated in the subject string. Each
10832 matching character is replaced by the corresponding character from the
10833 replacement list. For example
10834 .code
10835 ${tr{abcdea}{ac}{13}}
10836 .endd
10837 yields &`1b3de1`&. If there are duplicates in the second character string, the
10838 last occurrence is used. If the third string is shorter than the second, its
10839 last character is replicated. However, if it is empty, no translation takes
10840 place.
10841
10842 All character handling is done in bytes and is not UTF-8 aware.
10843
10844 .endlist
10845
10846
10847
10848 .section "Expansion operators" "SECTexpop"
10849 .cindex "expansion" "operators"
10850 For expansion items that perform transformations on a single argument string,
10851 the &"operator"& notation is used because it is simpler and uses fewer braces.
10852 The substring is first expanded before the operation is applied to it. The
10853 following operations can be performed:
10854
10855 .vlist
10856 .vitem &*${address:*&<&'string'&>&*}*&
10857 .cindex "expansion" "RFC 2822 address handling"
10858 .cindex "&%address%& expansion item"
10859 The string is interpreted as an RFC 2822 address, as it might appear in a
10860 header line, and the effective address is extracted from it. If the string does
10861 not parse successfully, the result is empty.
10862
10863 The parsing correctly handles SMTPUTF8 Unicode in the string.
10864
10865
10866 .vitem &*${addresses:*&<&'string'&>&*}*&
10867 .cindex "expansion" "RFC 2822 address handling"
10868 .cindex "&%addresses%& expansion item"
10869 The string (after expansion) is interpreted as a list of addresses in RFC
10870 2822 format, such as can be found in a &'To:'& or &'Cc:'& header line. The
10871 operative address (&'local-part@domain'&) is extracted from each item, and the
10872 result of the expansion is a colon-separated list, with appropriate
10873 doubling of colons should any happen to be present in the email addresses.
10874 Syntactically invalid RFC2822 address items are omitted from the output.
10875
10876 It is possible to specify a character other than colon for the output
10877 separator by starting the string with > followed by the new separator
10878 character. For example:
10879 .code
10880 ${addresses:>& Chief <ceo@up.stairs>, sec@base.ment (dogsbody)}
10881 .endd
10882 expands to &`ceo@up.stairs&&sec@base.ment`&. The string is expanded
10883 first, so if the expanded string starts with >, it may change the output
10884 separator unintentionally. This can be avoided by setting the output
10885 separator explicitly:
10886 .code
10887 ${addresses:>:$h_from:}
10888 .endd
10889
10890 Compare the &%address%& (singular)
10891 expansion item, which extracts the working address from a single RFC2822
10892 address. See the &%filter%&, &%map%&, and &%reduce%& items for ways of
10893 processing lists.
10894
10895 To clarify "list of addresses in RFC 2822 format" mentioned above, Exim follows
10896 a strict interpretation of header line formatting.  Exim parses the bare,
10897 unquoted portion of an email address and if it finds a comma, treats it as an
10898 email address separator. For the example header line:
10899 .code
10900 From: =?iso-8859-2?Q?Last=2C_First?= <user@example.com>
10901 .endd
10902 The first example below demonstrates that Q-encoded email addresses are parsed
10903 properly if it is given the raw header (in this example, &`$rheader_from:`&).
10904 It does not see the comma because it's still encoded as "=2C".  The second
10905 example below is passed the contents of &`$header_from:`&, meaning it gets
10906 de-mimed. Exim sees the decoded "," so it treats it as &*two*& email addresses.
10907 The third example shows that the presence of a comma is skipped when it is
10908 quoted.  The fourth example shows SMTPUTF8 handling.
10909 .code
10910 # exim -be '${addresses:From: \
10911 =?iso-8859-2?Q?Last=2C_First?= <user@example.com>}'
10912 user@example.com
10913 # exim -be '${addresses:From: Last, First <user@example.com>}'
10914 Last:user@example.com
10915 # exim -be '${addresses:From: "Last, First" <user@example.com>}'
10916 user@example.com
10917 # exim -be '${addresses:フィル <フィリップ@example.jp>}'
10918 フィリップ@example.jp
10919 .endd
10920
10921 .vitem &*${base32:*&<&'digits'&>&*}*&
10922 .cindex "&%base32%& expansion item"
10923 .cindex "expansion" "conversion to base 32"
10924 The string must consist entirely of decimal digits. The number is converted to
10925 base 32 and output as a (empty, for zero) string of characters.
10926 Only lowercase letters are used.
10927
10928 .vitem &*${base32d:*&<&'base-32&~digits'&>&*}*&
10929 .cindex "&%base32d%& expansion item"
10930 .cindex "expansion" "conversion to base 32"
10931 The string must consist entirely of base-32 digits.
10932 The number is converted to decimal and output as a string.
10933
10934 .vitem &*${base62:*&<&'digits'&>&*}*&
10935 .cindex "&%base62%& expansion item"
10936 .cindex "expansion" "conversion to base 62"
10937 The string must consist entirely of decimal digits. The number is converted to
10938 base 62 and output as a string of six characters, including leading zeros. In
10939 the few operating environments where Exim uses base 36 instead of base 62 for
10940 its message identifiers (because those systems do not have case-sensitive
10941 filenames), base 36 is used by this operator, despite its name. &*Note*&: Just
10942 to be absolutely clear: this is &'not'& base64 encoding.
10943
10944 .vitem &*${base62d:*&<&'base-62&~digits'&>&*}*&
10945 .cindex "&%base62d%& expansion item"
10946 .cindex "expansion" "conversion to base 62"
10947 The string must consist entirely of base-62 digits, or, in operating
10948 environments where Exim uses base 36 instead of base 62 for its message
10949 identifiers, base-36 digits. The number is converted to decimal and output as a
10950 string.
10951
10952 .vitem &*${base64:*&<&'string'&>&*}*&
10953 .cindex "expansion" "base64 encoding"
10954 .cindex "base64 encoding" "in string expansion"
10955 .cindex "&%base64%& expansion item"
10956 .cindex certificate "base64 of DER"
10957 This operator converts a string into one that is base64 encoded.
10958
10959 If the string is a single variable of type certificate,
10960 returns the base64 encoding of the DER form of the certificate.
10961
10962
10963 .vitem &*${base64d:*&<&'string'&>&*}*&
10964 .cindex "expansion" "base64 decoding"
10965 .cindex "base64 decoding" "in string expansion"
10966 .cindex "&%base64d%& expansion item"
10967 This operator converts a base64-encoded string into the un-coded form.
10968
10969
10970 .vitem &*${domain:*&<&'string'&>&*}*&
10971 .cindex "domain" "extraction"
10972 .cindex "expansion" "domain extraction"
10973 The string is interpreted as an RFC 2822 address and the domain is extracted
10974 from it. If the string does not parse successfully, the result is empty.
10975
10976
10977 .vitem &*${escape:*&<&'string'&>&*}*&
10978 .cindex "expansion" "escaping non-printing characters"
10979 .cindex "&%escape%& expansion item"
10980 If the string contains any non-printing characters, they are converted to
10981 escape sequences starting with a backslash. Whether characters with the most
10982 significant bit set (so-called &"8-bit characters"&) count as printing or not
10983 is controlled by the &%print_topbitchars%& option.
10984
10985 .vitem &*${escape8bit:*&<&'string'&>&*}*&
10986 .cindex "expansion" "escaping 8-bit characters"
10987 .cindex "&%escape8bit%& expansion item"
10988 If the string contains any characters with the most significant bit set,
10989 they are converted to escape sequences starting with a backslash.
10990 Backslashes and DEL characters are also converted.
10991
10992
10993 .vitem &*${eval:*&<&'string'&>&*}*&&~and&~&*${eval10:*&<&'string'&>&*}*&
10994 .cindex "expansion" "expression evaluation"
10995 .cindex "expansion" "arithmetic expression"
10996 .cindex "&%eval%& expansion item"
10997 These items supports simple arithmetic and bitwise logical operations in
10998 expansion strings. The string (after expansion) must be a conventional
10999 arithmetic expression, but it is limited to basic arithmetic operators, bitwise
11000 logical operators, and parentheses. All operations are carried out using
11001 integer arithmetic. The operator priorities are as follows (the same as in the
11002 C programming language):
11003 .table2 70pt 300pt
11004 .irow &'highest:'& "not (~), negate (-)"
11005 .irow ""   "multiply (*), divide (/), remainder (%)"
11006 .irow ""   "plus (+), minus (-)"
11007 .irow ""   "shift-left (<<), shift-right (>>)"
11008 .irow ""   "and (&&)"
11009 .irow ""   "xor (^)"
11010 .irow &'lowest:'&  "or (|)"
11011 .endtable
11012 Binary operators with the same priority are evaluated from left to right. White
11013 space is permitted before or after operators.
11014
11015 For &%eval%&, numbers may be decimal, octal (starting with &"0"&) or
11016 hexadecimal (starting with &"0x"&). For &%eval10%&, all numbers are taken as
11017 decimal, even if they start with a leading zero; hexadecimal numbers are not
11018 permitted. This can be useful when processing numbers extracted from dates or
11019 times, which often do have leading zeros.
11020
11021 A number may be followed by &"K"&, &"M"& or &"G"& to multiply it by 1024, 1024*1024
11022 or 1024*1024*1024,
11023 respectively. Negative numbers are supported. The result of the computation is
11024 a decimal representation of the answer (without &"K"&, &"M"& or &"G"&). For example:
11025
11026 .display
11027 &`${eval:1+1}            `&  yields 2
11028 &`${eval:1+2*3}          `&  yields 7
11029 &`${eval:(1+2)*3}        `&  yields 9
11030 &`${eval:2+42%5}         `&  yields 4
11031 &`${eval:0xc&amp;5}          `&  yields 4
11032 &`${eval:0xc|5}          `&  yields 13
11033 &`${eval:0xc^5}          `&  yields 9
11034 &`${eval:0xc>>1}         `&  yields 6
11035 &`${eval:0xc<<1}         `&  yields 24
11036 &`${eval:~255&amp;0x1234}    `&  yields 4608
11037 &`${eval:-(~255&amp;0x1234)} `&  yields -4608
11038 .endd
11039
11040 As a more realistic example, in an ACL you might have
11041 .code
11042 deny   condition =                    \
11043          ${if and {                   \
11044            {>{$rcpt_count}{10}}       \
11045            {                          \
11046            <                          \
11047              {$recipients_count}      \
11048              {${eval:$rcpt_count/2}}  \
11049            }                          \
11050          }{yes}{no}}
11051        message = Too many bad recipients
11052 .endd
11053 The condition is true if there have been more than 10 RCPT commands and
11054 fewer than half of them have resulted in a valid recipient.
11055
11056
11057 .vitem &*${expand:*&<&'string'&>&*}*&
11058 .cindex "expansion" "re-expansion of substring"
11059 The &%expand%& operator causes a string to be expanded for a second time. For
11060 example,
11061 .code
11062 ${expand:${lookup{$domain}dbm{/some/file}{$value}}}
11063 .endd
11064 first looks up a string in a file while expanding the operand for &%expand%&,
11065 and then re-expands what it has found.
11066
11067
11068 .vitem &*${from_utf8:*&<&'string'&>&*}*&
11069 .cindex "Unicode"
11070 .cindex "UTF-8" "conversion from"
11071 .cindex "expansion" "UTF-8 conversion"
11072 .cindex "&%from_utf8%& expansion item"
11073 The world is slowly moving towards Unicode, although there are no standards for
11074 email yet. However, other applications (including some databases) are starting
11075 to store data in Unicode, using UTF-8 encoding. This operator converts from a
11076 UTF-8 string to an ISO-8859-1 string. UTF-8 code values greater than 255 are
11077 converted to underscores. The input must be a valid UTF-8 string. If it is not,
11078 the result is an undefined sequence of bytes.
11079
11080 Unicode code points with values less than 256 are compatible with ASCII and
11081 ISO-8859-1 (also known as Latin-1).
11082 For example, character 169 is the copyright symbol in both cases, though the
11083 way it is encoded is different. In UTF-8, more than one byte is needed for
11084 characters with code values greater than 127, whereas ISO-8859-1 is a
11085 single-byte encoding (but thereby limited to 256 characters). This makes
11086 translation from UTF-8 to ISO-8859-1 straightforward.
11087
11088
11089 .vitem &*${hash_*&<&'n'&>&*_*&<&'m'&>&*:*&<&'string'&>&*}*&
11090 .cindex "hash function" "textual"
11091 .cindex "expansion" "textual hash"
11092 The &%hash%& operator is a simpler interface to the hashing function that can
11093 be used when the two parameters are fixed numbers (as opposed to strings that
11094 change when expanded). The effect is the same as
11095 .code
11096 ${hash{<n>}{<m>}{<string>}}
11097 .endd
11098 See the description of the general &%hash%& item above for details. The
11099 abbreviation &%h%& can be used when &%hash%& is used as an operator.
11100
11101
11102
11103 .vitem &*${headerwrap_*&<&'cols'&>&*_*&<&'limit'&>&*:*&<&'string'&>&*}*&
11104 .cindex header "wrapping operator"
11105 .cindex expansion "header wrapping"
11106 This operator line-wraps its argument in a way useful for headers.
11107 The &'cols'& value gives the column number to wrap after,
11108 the &'limit'& gives a limit number of result characters to truncate at.
11109 Either just the &'limit'& and the preceding underbar, or both, can be omitted;
11110 the defaults are 80 and 998.
11111 Wrapping will be inserted at a space if possible before the
11112 column number is reached.
11113 Whitespace at a chosen wrap point is removed.
11114 A line-wrap consists of a newline followed by a tab,
11115 and the tab is counted as 8 columns.
11116
11117
11118
11119 .vitem &*${hex2b64:*&<&'hexstring'&>&*}*&
11120 .cindex "base64 encoding" "conversion from hex"
11121 .cindex "expansion" "hex to base64"
11122 .cindex "&%hex2b64%& expansion item"
11123 This operator converts a hex string into one that is base64 encoded. This can
11124 be useful for processing the output of the various hashing functions.
11125
11126
11127
11128 .vitem &*${hexquote:*&<&'string'&>&*}*&
11129 .cindex "quoting" "hex-encoded unprintable characters"
11130 .cindex "&%hexquote%& expansion item"
11131 This operator converts non-printable characters in a string into a hex
11132 escape form. Byte values between 33 (!) and 126 (~) inclusive are left
11133 as is, and other byte values are converted to &`\xNN`&, for example, a
11134 byte value 127 is converted to &`\x7f`&.
11135
11136
11137 .vitem &*${ipv6denorm:*&<&'string'&>&*}*&
11138 .cindex "&%ipv6denorm%& expansion item"
11139 .cindex "IP address" normalisation
11140 This expands an IPv6 address to a full eight-element colon-separated set
11141 of hex digits including leading zeroes.
11142 A trailing ipv4-style dotted-decimal set is converted to hex.
11143 Pure IPv4 addresses are converted to IPv4-mapped IPv6.
11144
11145 .vitem &*${ipv6norm:*&<&'string'&>&*}*&
11146 .cindex "&%ipv6norm%& expansion item"
11147 .cindex "IP address" normalisation
11148 .cindex "IP address" "canonical form"
11149 This converts an IPv6 address to canonical form.
11150 Leading zeroes of groups are omitted, and the longest
11151 set of zero-valued groups is replaced with a double colon.
11152 A trailing ipv4-style dotted-decimal set is converted to hex.
11153 Pure IPv4 addresses are converted to IPv4-mapped IPv6.
11154
11155
11156 .vitem &*${lc:*&<&'string'&>&*}*&
11157 .cindex "case forcing in strings"
11158 .cindex "string" "case forcing"
11159 .cindex "lower casing"
11160 .cindex "expansion" "case forcing"
11161 .cindex "&%lc%& expansion item"
11162 This forces the letters in the string into lower-case, for example:
11163 .code
11164 ${lc:$local_part}
11165 .endd
11166 Case is defined per the system C locale.
11167
11168 .vitem &*${length_*&<&'number'&>&*:*&<&'string'&>&*}*&
11169 .cindex "expansion" "string truncation"
11170 .cindex "&%length%& expansion item"
11171 The &%length%& operator is a simpler interface to the &%length%& function that
11172 can be used when the parameter is a fixed number (as opposed to a string that
11173 changes when expanded). The effect is the same as
11174 .code
11175 ${length{<number>}{<string>}}
11176 .endd
11177 See the description of the general &%length%& item above for details. Note that
11178 &%length%& is not the same as &%strlen%&. The abbreviation &%l%& can be used
11179 when &%length%& is used as an operator.
11180 All measurement is done in bytes and is not UTF-8 aware.
11181
11182
11183 .vitem &*${listcount:*&<&'string'&>&*}*&
11184 .cindex "expansion" "list item count"
11185 .cindex "list" "item count"
11186 .cindex "list" "count of items"
11187 .cindex "&%listcount%& expansion item"
11188 The string is interpreted as a list and the number of items is returned.
11189
11190
11191 .vitem &*${listnamed:*&<&'name'&>&*}*&&~and&~&*${listnamed_*&<&'type'&>&*:*&<&'name'&>&*}*&
11192 .cindex "expansion" "named list"
11193 .cindex "&%listnamed%& expansion item"
11194 The name is interpreted as a named list and the content of the list is returned,
11195 expanding any referenced lists, re-quoting as needed for colon-separation.
11196 If the optional type is given it must be one of "a", "d", "h" or "l"
11197 and selects address-, domain-, host- or localpart- lists to search among respectively.
11198 Otherwise all types are searched in an undefined order and the first
11199 matching list is returned.
11200 &*Note*&: Neither string-expansion of lists referenced by named-list syntax elements,
11201 nor expansion of lookup elements, is done by the &%listnamed%& operator.
11202
11203
11204 .vitem &*${local_part:*&<&'string'&>&*}*&
11205 .cindex "expansion" "local part extraction"
11206 .cindex "&%local_part%& expansion item"
11207 The string is interpreted as an RFC 2822 address and the local part is
11208 extracted from it. If the string does not parse successfully, the result is
11209 empty.
11210 The parsing correctly handles SMTPUTF8 Unicode in the string.
11211
11212
11213 .vitem &*${mask:*&<&'IP&~address'&>&*/*&<&'bit&~count'&>&*}*& &&&
11214        &*${mask_n:*&<&'IP&~address'&>&*/*&<&'bit&~count'&>&*}*&
11215 .cindex "masked IP address"
11216 .cindex "IP address" "masking"
11217 .cindex "CIDR notation"
11218 .cindex "expansion" "IP address masking"
11219 .cindex "&%mask%& expansion item"
11220 If the form of the string to be operated on is not an IP address followed by a
11221 slash and an integer (that is, a network address in CIDR notation), the
11222 expansion fails. Otherwise, this operator converts the IP address to binary,
11223 masks off the least significant bits according to the bit count, and converts
11224 the result back to text, with mask appended. For example,
11225 .code
11226 ${mask:10.111.131.206/28}
11227 .endd
11228 returns the string &"10.111.131.192/28"&.
11229
11230 Since this operation is expected to
11231 be mostly used for looking up masked addresses in files, the
11232 normal
11233 result for an IPv6
11234 address uses dots to separate components instead of colons, because colon
11235 terminates a key string in lsearch files. So, for example,
11236 .code
11237 ${mask:3ffe:ffff:836f:0a00:000a:0800:200a:c031/99}
11238 .endd
11239 returns the string
11240 .code
11241 3ffe.ffff.836f.0a00.000a.0800.2000.0000/99
11242 .endd
11243 If the optional form &*mask_n*& is used, IPv6 address result are instead
11244 returned in normailsed form, using colons and with zero-compression.
11245 Letters in IPv6 addresses are always output in lower case.
11246
11247
11248 .vitem &*${md5:*&<&'string'&>&*}*&
11249 .cindex "MD5 hash"
11250 .cindex "expansion" "MD5 hash"
11251 .cindex certificate fingerprint
11252 .cindex "&%md5%& expansion item"
11253 The &%md5%& operator computes the MD5 hash value of the string, and returns it
11254 as a 32-digit hexadecimal number, in which any letters are in lower case.
11255
11256 If the string is a single variable of type certificate,
11257 returns the MD5 hash fingerprint of the certificate.
11258
11259
11260 .vitem &*${nhash_*&<&'n'&>&*_*&<&'m'&>&*:*&<&'string'&>&*}*&
11261 .cindex "expansion" "numeric hash"
11262 .cindex "hash function" "numeric"
11263 The &%nhash%& operator is a simpler interface to the numeric hashing function
11264 that can be used when the two parameters are fixed numbers (as opposed to
11265 strings that change when expanded). The effect is the same as
11266 .code
11267 ${nhash{<n>}{<m>}{<string>}}
11268 .endd
11269 See the description of the general &%nhash%& item above for details.
11270
11271
11272 .vitem &*${quote:*&<&'string'&>&*}*&
11273 .cindex "quoting" "in string expansions"
11274 .cindex "expansion" "quoting"
11275 .cindex "&%quote%& expansion item"
11276 The &%quote%& operator puts its argument into double quotes if it
11277 is an empty string or
11278 contains anything other than letters, digits, underscores, dots, and hyphens.
11279 Any occurrences of double quotes and backslashes are escaped with a backslash.
11280 Newlines and carriage returns are converted to &`\n`& and &`\r`&,
11281 respectively For example,
11282 .code
11283 ${quote:ab"*"cd}
11284 .endd
11285 becomes
11286 .code
11287 "ab\"*\"cd"
11288 .endd
11289 The place where this is useful is when the argument is a substitution from a
11290 variable or a message header.
11291
11292 .vitem &*${quote_local_part:*&<&'string'&>&*}*&
11293 .cindex "&%quote_local_part%& expansion item"
11294 This operator is like &%quote%&, except that it quotes the string only if
11295 required to do so by the rules of RFC 2822 for quoting local parts. For
11296 example, a plus sign would not cause quoting (but it would for &%quote%&).
11297 If you are creating a new email address from the contents of &$local_part$&
11298 (or any other unknown data), you should always use this operator.
11299
11300 This quoting determination is not SMTPUTF8-aware, thus quoting non-ASCII data
11301 will likely use the quoting form.
11302 Thus &'${quote_local_part:フィル}'& will always become &'"フィル"'&.
11303
11304
11305 .vitem &*${quote_*&<&'lookup-type'&>&*:*&<&'string'&>&*}*&
11306 .cindex "quoting" "lookup-specific"
11307 This operator applies lookup-specific quoting rules to the string. Each
11308 query-style lookup type has its own quoting rules which are described with
11309 the lookups in chapter &<<CHAPfdlookup>>&. For example,
11310 .code
11311 ${quote_ldap:two * two}
11312 .endd
11313 returns
11314 .code
11315 two%20%5C2A%20two
11316 .endd
11317 For single-key lookup types, no quoting is ever necessary and this operator
11318 yields an unchanged string.
11319
11320
11321 .vitem &*${randint:*&<&'n'&>&*}*&
11322 .cindex "random number"
11323 This operator returns a somewhat random number which is less than the
11324 supplied number and is at least 0.  The quality of this randomness depends
11325 on how Exim was built; the values are not suitable for keying material.
11326 If Exim is linked against OpenSSL then RAND_pseudo_bytes() is used.
11327 If Exim is linked against GnuTLS then gnutls_rnd(GNUTLS_RND_NONCE) is used,
11328 for versions of GnuTLS with that function.
11329 Otherwise, the implementation may be arc4random(), random() seeded by
11330 srandomdev() or srandom(), or a custom implementation even weaker than
11331 random().
11332
11333
11334 .vitem &*${reverse_ip:*&<&'ipaddr'&>&*}*&
11335 .cindex "expansion" "IP address"
11336 This operator reverses an IP address; for IPv4 addresses, the result is in
11337 dotted-quad decimal form, while for IPv6 addresses the result is in
11338 dotted-nibble hexadecimal form.  In both cases, this is the "natural" form
11339 for DNS.  For example,
11340 .code
11341 ${reverse_ip:192.0.2.4}
11342 ${reverse_ip:2001:0db8:c42:9:1:abcd:192.0.2.127}
11343 .endd
11344 returns
11345 .code
11346 4.2.0.192
11347 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
11348 .endd
11349
11350
11351 .vitem &*${rfc2047:*&<&'string'&>&*}*&
11352 .cindex "expansion" "RFC 2047"
11353 .cindex "RFC 2047" "expansion operator"
11354 .cindex "&%rfc2047%& expansion item"
11355 This operator encodes text according to the rules of RFC 2047. This is an
11356 encoding that is used in header lines to encode non-ASCII characters. It is
11357 assumed that the input string is in the encoding specified by the
11358 &%headers_charset%& option, which gets its default at build time. If the string
11359 contains only characters in the range 33&--126, and no instances of the
11360 characters
11361 .code
11362 ? = ( ) < > @ , ; : \ " . [ ] _
11363 .endd
11364 it is not modified. Otherwise, the result is the RFC 2047 encoding of the
11365 string, using as many &"encoded words"& as necessary to encode all the
11366 characters.
11367
11368
11369 .vitem &*${rfc2047d:*&<&'string'&>&*}*&
11370 .cindex "expansion" "RFC 2047"
11371 .cindex "RFC 2047" "decoding"
11372 .cindex "&%rfc2047d%& expansion item"
11373 This operator decodes strings that are encoded as per RFC 2047. Binary zero
11374 bytes are replaced by question marks. Characters are converted into the
11375 character set defined by &%headers_charset%&. Overlong RFC 2047 &"words"& are
11376 not recognized unless &%check_rfc2047_length%& is set false.
11377
11378 &*Note*&: If you use &%$header%&_&'xxx'&&*:*& (or &%$h%&_&'xxx'&&*:*&) to
11379 access a header line, RFC 2047 decoding is done automatically. You do not need
11380 to use this operator as well.
11381
11382
11383
11384 .vitem &*${rxquote:*&<&'string'&>&*}*&
11385 .cindex "quoting" "in regular expressions"
11386 .cindex "regular expressions" "quoting"
11387 .cindex "&%rxquote%& expansion item"
11388 The &%rxquote%& operator inserts a backslash before any non-alphanumeric
11389 characters in its argument. This is useful when substituting the values of
11390 variables or headers inside regular expressions.
11391
11392
11393 .vitem &*${sha1:*&<&'string'&>&*}*&
11394 .cindex "SHA-1 hash"
11395 .cindex "expansion" "SHA-1 hashing"
11396 .cindex certificate fingerprint
11397 .cindex "&%sha1%& expansion item"
11398 The &%sha1%& operator computes the SHA-1 hash value of the string, and returns
11399 it as a 40-digit hexadecimal number, in which any letters are in upper case.
11400
11401 If the string is a single variable of type certificate,
11402 returns the SHA-1 hash fingerprint of the certificate.
11403
11404
11405 .vitem &*${sha256:*&<&'string'&>&*}*& &&&
11406        &*${sha2:*&<&'string'&>&*}*& &&&
11407        &*${sha2_<n>:*&<&'string'&>&*}*&
11408 .cindex "SHA-256 hash"
11409 .cindex "SHA-2 hash"
11410 .cindex certificate fingerprint
11411 .cindex "expansion" "SHA-256 hashing"
11412 .cindex "&%sha256%& expansion item"
11413 .cindex "&%sha2%& expansion item"
11414 The &%sha256%& operator computes the SHA-256 hash value of the string
11415 and returns
11416 it as a 64-digit hexadecimal number, in which any letters are in upper case.
11417
11418 If the string is a single variable of type certificate,
11419 returns the SHA-256 hash fingerprint of the certificate.
11420
11421 The operator can also be spelled &%sha2%& and does the same as &%sha256%&
11422 (except for certificates, which are not supported).
11423 Finally, if an underbar
11424 and a number is appended it specifies the output length, selecting a
11425 member of the SHA-2 family of hash functions.
11426 Values of 256, 384 and 512 are accepted, with 256 being the default.
11427
11428
11429 .vitem &*${sha3:*&<&'string'&>&*}*& &&&
11430        &*${sha3_<n>:*&<&'string'&>&*}*&
11431 .cindex "SHA3 hash"
11432 .cindex "expansion" "SHA3 hashing"
11433 .cindex "&%sha3%& expansion item"
11434 The &%sha3%& operator computes the SHA3-256 hash value of the string
11435 and returns
11436 it as a 64-digit hexadecimal number, in which any letters are in upper case.
11437
11438 If a number is appended, separated by an underbar, it specifies
11439 the output length.  Values of 224, 256, 384 and 512 are accepted;
11440 with 256 being the default.
11441
11442 The &%sha3%& expansion item is only supported if Exim has been
11443 compiled with GnuTLS 3.5.0 or later,
11444 or OpenSSL 1.1.1 or later.
11445 The macro "_CRYPTO_HASH_SHA3" will be defined if it is supported.
11446
11447
11448 .vitem &*${stat:*&<&'string'&>&*}*&
11449 .cindex "expansion" "statting a file"
11450 .cindex "file" "extracting characteristics"
11451 .cindex "&%stat%& expansion item"
11452 The string, after expansion, must be a file path. A call to the &[stat()]&
11453 function is made for this path. If &[stat()]& fails, an error occurs and the
11454 expansion fails. If it succeeds, the data from the stat replaces the item, as a
11455 series of <&'name'&>=<&'value'&> pairs, where the values are all numerical,
11456 except for the value of &"smode"&. The names are: &"mode"& (giving the mode as
11457 a 4-digit octal number), &"smode"& (giving the mode in symbolic format as a
11458 10-character string, as for the &'ls'& command), &"inode"&, &"device"&,
11459 &"links"&, &"uid"&, &"gid"&, &"size"&, &"atime"&, &"mtime"&, and &"ctime"&. You
11460 can extract individual fields using the &%extract%& expansion item.
11461
11462 The use of the &%stat%& expansion in users' filter files can be locked out by
11463 the system administrator. &*Warning*&: The file size may be incorrect on 32-bit
11464 systems for files larger than 2GB.
11465
11466 .vitem &*${str2b64:*&<&'string'&>&*}*&
11467 .cindex "&%str2b64%& expansion item"
11468 Now deprecated, a synonym for the &%base64%& expansion operator.
11469
11470
11471
11472 .vitem &*${strlen:*&<&'string'&>&*}*&
11473 .cindex "expansion" "string length"
11474 .cindex "string" "length in expansion"
11475 .cindex "&%strlen%& expansion item"
11476 The item is replaced by the length of the expanded string, expressed as a
11477 decimal number. &*Note*&: Do not confuse &%strlen%& with &%length%&.
11478 All measurement is done in bytes and is not UTF-8 aware.
11479
11480
11481 .vitem &*${substr_*&<&'start'&>&*_*&<&'length'&>&*:*&<&'string'&>&*}*&
11482 .cindex "&%substr%& expansion item"
11483 .cindex "substring extraction"
11484 .cindex "expansion" "substring expansion"
11485 The &%substr%& operator is a simpler interface to the &%substr%& function that
11486 can be used when the two parameters are fixed numbers (as opposed to strings
11487 that change when expanded). The effect is the same as
11488 .code
11489 ${substr{<start>}{<length>}{<string>}}
11490 .endd
11491 See the description of the general &%substr%& item above for details. The
11492 abbreviation &%s%& can be used when &%substr%& is used as an operator.
11493 All measurement is done in bytes and is not UTF-8 aware.
11494
11495 .vitem &*${time_eval:*&<&'string'&>&*}*&
11496 .cindex "&%time_eval%& expansion item"
11497 .cindex "time interval" "decoding"
11498 This item converts an Exim time interval such as &`2d4h5m`& into a number of
11499 seconds.
11500
11501 .vitem &*${time_interval:*&<&'string'&>&*}*&
11502 .cindex "&%time_interval%& expansion item"
11503 .cindex "time interval" "formatting"
11504 The argument (after sub-expansion) must be a sequence of decimal digits that
11505 represents an interval of time as a number of seconds. It is converted into a
11506 number of larger units and output in Exim's normal time format, for example,
11507 &`1w3d4h2m6s`&.
11508
11509 .vitem &*${uc:*&<&'string'&>&*}*&
11510 .cindex "case forcing in strings"
11511 .cindex "string" "case forcing"
11512 .cindex "upper casing"
11513 .cindex "expansion" "case forcing"
11514 .cindex "&%uc%& expansion item"
11515 This forces the letters in the string into upper-case.
11516 Case is defined per the system C locale.
11517
11518 .vitem &*${utf8clean:*&<&'string'&>&*}*&
11519 .cindex "correction of invalid utf-8 sequences in strings"
11520 .cindex "utf-8" "utf-8 sequences"
11521 .cindex "incorrect utf-8"
11522 .cindex "expansion" "utf-8 forcing"
11523 .cindex "&%utf8clean%& expansion item"
11524 This replaces any invalid utf-8 sequence in the string by the character &`?`&.
11525 In versions of Exim before 4.92, this did not correctly do so for a truncated
11526 final codepoint's encoding, and the character would be silently dropped.
11527 If you must handle detection of this scenario across both sets of Exim behavior,
11528 the complexity will depend upon the task.
11529 For instance, to detect if the first character is multibyte and a 1-byte
11530 extraction can be successfully used as a path component (as is common for
11531 dividing up delivery folders), you might use:
11532 .code
11533 condition = ${if inlist{${utf8clean:${length_1:$local_part}}}{:?}{yes}{no}}
11534 .endd
11535 (which will false-positive if the first character of the local part is a
11536 literal question mark).
11537
11538 .vitem "&*${utf8_domain_to_alabel:*&<&'string'&>&*}*&" &&&
11539        "&*${utf8_domain_from_alabel:*&<&'string'&>&*}*&" &&&
11540        "&*${utf8_localpart_to_alabel:*&<&'string'&>&*}*&" &&&
11541        "&*${utf8_localpart_from_alabel:*&<&'string'&>&*}*&"
11542 .cindex expansion UTF-8
11543 .cindex UTF-8 expansion
11544 .cindex EAI
11545 .cindex internationalisation
11546 .cindex "&%utf8_domain_to_alabel%& expansion item"
11547 .cindex "&%utf8_domain_from_alabel%& expansion item"
11548 .cindex "&%utf8_localpart_to_alabel%& expansion item"
11549 .cindex "&%utf8_localpart_from_alabel%& expansion item"
11550 These convert EAI mail name components between UTF-8 and a-label forms.
11551 For information on internationalisation support see &<<SECTi18nMTA>>&.
11552 .endlist
11553
11554
11555
11556
11557
11558
11559 .section "Expansion conditions" "SECTexpcond"
11560 .scindex IIDexpcond "expansion" "conditions"
11561 The following conditions are available for testing by the &%${if%& construct
11562 while expanding strings:
11563
11564 .vlist
11565 .vitem &*!*&<&'condition'&>
11566 .cindex "expansion" "negating a condition"
11567 .cindex "negation" "in expansion condition"
11568 Preceding any condition with an exclamation mark negates the result of the
11569 condition.
11570
11571 .vitem <&'symbolic&~operator'&>&~&*{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
11572 .cindex "numeric comparison"
11573 .cindex "expansion" "numeric comparison"
11574 There are a number of symbolic operators for doing numeric comparisons. They
11575 are:
11576 .itable none 0 0 2 10* left 90* left
11577 .irow "=   " "equal"
11578 .irow "==  " "equal"
11579 .irow ">   " "greater"
11580 .irow ">=  " "greater or equal"
11581 .irow "<   " "less"
11582 .irow "<=  " "less or equal"
11583 .endtable
11584 For example:
11585 .code
11586 ${if >{$message_size}{10M} ...
11587 .endd
11588 Note that the general negation operator provides for inequality testing. The
11589 two strings must take the form of optionally signed decimal integers,
11590 optionally followed by one of the letters &"K"&, &"M"& or &"G"& (in either upper or
11591 lower case), signifying multiplication by 1024, 1024*1024 or 1024*1024*1024, respectively.
11592 As a special case, the numerical value of an empty string is taken as
11593 zero.
11594
11595 In all cases, a relative comparator OP is testing if <&'string1'&> OP
11596 <&'string2'&>; the above example is checking if &$message_size$& is larger than
11597 10M, not if 10M is larger than &$message_size$&.
11598
11599
11600 .vitem &*acl&~{{*&<&'name'&>&*}{*&<&'arg1'&>&*}&&&
11601         {*&<&'arg2'&>&*}...}*&
11602 .cindex "expansion" "calling an acl"
11603 .cindex "&%acl%&" "expansion condition"
11604 The name and zero to nine argument strings are first expanded separately.  The expanded
11605 arguments are assigned to the variables &$acl_arg1$& to &$acl_arg9$& in order.
11606 Any unused are made empty.  The variable &$acl_narg$& is set to the number of
11607 arguments.  The named ACL (see chapter &<<CHAPACL>>&) is called
11608 and may use the variables; if another acl expansion is used the values
11609 are restored after it returns.  If the ACL sets
11610 a value using a "message =" modifier the variable $value becomes
11611 the result of the expansion, otherwise it is empty.
11612 If the ACL returns accept the condition is true; if deny, false.
11613 If the ACL returns defer the result is a forced-fail.
11614
11615 .vitem &*bool&~{*&<&'string'&>&*}*&
11616 .cindex "expansion" "boolean parsing"
11617 .cindex "&%bool%& expansion condition"
11618 This condition turns a string holding a true or false representation into
11619 a boolean state.  It parses &"true"&, &"false"&, &"yes"& and &"no"&
11620 (case-insensitively); also integer numbers map to true if non-zero,
11621 false if zero.
11622 An empty string is treated as false.
11623 Leading and trailing whitespace is ignored;
11624 thus a string consisting only of whitespace is false.
11625 All other string values will result in expansion failure.
11626
11627 When combined with ACL variables, this expansion condition will let you
11628 make decisions in one place and act on those decisions in another place.
11629 For example:
11630 .code
11631 ${if bool{$acl_m_privileged_sender} ...
11632 .endd
11633
11634
11635 .vitem &*bool_lax&~{*&<&'string'&>&*}*&
11636 .cindex "expansion" "boolean parsing"
11637 .cindex "&%bool_lax%& expansion condition"
11638 Like &%bool%&, this condition turns a string into a boolean state.  But
11639 where &%bool%& accepts a strict set of strings, &%bool_lax%& uses the same
11640 loose definition that the Router &%condition%& option uses.  The empty string
11641 and the values &"false"&, &"no"& and &"0"& map to false, all others map to
11642 true.  Leading and trailing whitespace is ignored.
11643
11644 Note that where &"bool{00}"& is false, &"bool_lax{00}"& is true.
11645
11646 .vitem &*crypteq&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
11647 .cindex "expansion" "encrypted comparison"
11648 .cindex "encrypted strings, comparing"
11649 .cindex "&%crypteq%& expansion condition"
11650 This condition is included in the Exim binary if it is built to support any
11651 authentication mechanisms (see chapter &<<CHAPSMTPAUTH>>&). Otherwise, it is
11652 necessary to define SUPPORT_CRYPTEQ in &_Local/Makefile_& to get &%crypteq%&
11653 included in the binary.
11654
11655 The &%crypteq%& condition has two arguments. The first is encrypted and
11656 compared against the second, which is already encrypted. The second string may
11657 be in the LDAP form for storing encrypted strings, which starts with the
11658 encryption type in curly brackets, followed by the data. If the second string
11659 does not begin with &"{"& it is assumed to be encrypted with &[crypt()]& or
11660 &[crypt16()]& (see below), since such strings cannot begin with &"{"&.
11661 Typically this will be a field from a password file. An example of an encrypted
11662 string in LDAP form is:
11663 .code
11664 {md5}CY9rzUYh03PK3k6DJie09g==
11665 .endd
11666 If such a string appears directly in an expansion, the curly brackets have to
11667 be quoted, because they are part of the expansion syntax. For example:
11668 .code
11669 ${if crypteq {test}{\{md5\}CY9rzUYh03PK3k6DJie09g==}{yes}{no}}
11670 .endd
11671 The following encryption types (whose names are matched case-independently) are
11672 supported:
11673
11674 .ilist
11675 .cindex "MD5 hash"
11676 .cindex "base64 encoding" "in encrypted password"
11677 &%{md5}%& computes the MD5 digest of the first string, and expresses this as
11678 printable characters to compare with the remainder of the second string. If the
11679 length of the comparison string is 24, Exim assumes that it is base64 encoded
11680 (as in the above example). If the length is 32, Exim assumes that it is a
11681 hexadecimal encoding of the MD5 digest. If the length not 24 or 32, the
11682 comparison fails.
11683
11684 .next
11685 .cindex "SHA-1 hash"
11686 &%{sha1}%& computes the SHA-1 digest of the first string, and expresses this as
11687 printable characters to compare with the remainder of the second string. If the
11688 length of the comparison string is 28, Exim assumes that it is base64 encoded.
11689 If the length is 40, Exim assumes that it is a hexadecimal encoding of the
11690 SHA-1 digest. If the length is not 28 or 40, the comparison fails.
11691
11692 .next
11693 .cindex "&[crypt()]&"
11694 &%{crypt}%& calls the &[crypt()]& function, which traditionally used to use
11695 only the first eight characters of the password. However, in modern operating
11696 systems this is no longer true, and in many cases the entire password is used,
11697 whatever its length.
11698
11699 .next
11700 .cindex "&[crypt16()]&"
11701 &%{crypt16}%& calls the &[crypt16()]& function, which was originally created to
11702 use up to 16 characters of the password in some operating systems. Again, in
11703 modern operating systems, more characters may be used.
11704 .endlist
11705 Exim has its own version of &[crypt16()]&, which is just a double call to
11706 &[crypt()]&. For operating systems that have their own version, setting
11707 HAVE_CRYPT16 in &_Local/Makefile_& when building Exim causes it to use the
11708 operating system version instead of its own. This option is set by default in
11709 the OS-dependent &_Makefile_& for those operating systems that are known to
11710 support &[crypt16()]&.
11711
11712 Some years after Exim's &[crypt16()]& was implemented, a user discovered that
11713 it was not using the same algorithm as some operating systems' versions. It
11714 turns out that as well as &[crypt16()]& there is a function called
11715 &[bigcrypt()]& in some operating systems. This may or may not use the same
11716 algorithm, and both of them may be different to Exim's built-in &[crypt16()]&.
11717
11718 However, since there is now a move away from the traditional &[crypt()]&
11719 functions towards using SHA1 and other algorithms, tidying up this area of
11720 Exim is seen as very low priority.
11721
11722 If you do not put a encryption type (in curly brackets) in a &%crypteq%&
11723 comparison, the default is usually either &`{crypt}`& or &`{crypt16}`&, as
11724 determined by the setting of DEFAULT_CRYPT in &_Local/Makefile_&. The default
11725 default is &`{crypt}`&. Whatever the default, you can always use either
11726 function by specifying it explicitly in curly brackets.
11727
11728 .vitem &*def:*&<&'variable&~name'&>
11729 .cindex "expansion" "checking for empty variable"
11730 .cindex "&%def%& expansion condition"
11731 The &%def%& condition must be followed by the name of one of the expansion
11732 variables defined in section &<<SECTexpvar>>&. The condition is true if the
11733 variable does not contain the empty string. For example:
11734 .code
11735 ${if def:sender_ident {from $sender_ident}}
11736 .endd
11737 Note that the variable name is given without a leading &%$%& character. If the
11738 variable does not exist, the expansion fails.
11739
11740 .vitem "&*def:header_*&<&'header&~name'&>&*:*&&~&~or&~&&&
11741         &~&*def:h_*&<&'header&~name'&>&*:*&"
11742 .cindex "expansion" "checking header line existence"
11743 This condition is true if a message is being processed and the named header
11744 exists in the message. For example,
11745 .code
11746 ${if def:header_reply-to:{$h_reply-to:}{$h_from:}}
11747 .endd
11748 &*Note*&: No &%$%& appears before &%header_%& or &%h_%& in the condition, and
11749 the header name must be terminated by a colon if white space does not follow.
11750
11751 .vitem &*eq&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*& &&&
11752        &*eqi&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
11753 .cindex "string" "comparison"
11754 .cindex "expansion" "string comparison"
11755 .cindex "&%eq%& expansion condition"
11756 .cindex "&%eqi%& expansion condition"
11757 The two substrings are first expanded. The condition is true if the two
11758 resulting strings are identical. For &%eq%& the comparison includes the case of
11759 letters, whereas for &%eqi%& the comparison is case-independent, where
11760 case is defined per the system C locale.
11761
11762 .vitem &*exists&~{*&<&'file&~name'&>&*}*&
11763 .cindex "expansion" "file existence test"
11764 .cindex "file" "existence test"
11765 .cindex "&%exists%&, expansion condition"
11766 The substring is first expanded and then interpreted as an absolute path. The
11767 condition is true if the named file (or directory) exists. The existence test
11768 is done by calling the &[stat()]& function. The use of the &%exists%& test in
11769 users' filter files may be locked out by the system administrator.
11770
11771 &*Note:*& Testing a path using this condition is not a sufficient way of
11772 de-tainting it.
11773 Consider using a dsearch lookup.
11774
11775 .vitem &*first_delivery*&
11776 .cindex "delivery" "first"
11777 .cindex "first delivery"
11778 .cindex "expansion" "first delivery test"
11779 .cindex "&%first_delivery%& expansion condition"
11780 .cindex retry condition
11781 This condition, which has no data, is true during a message's first delivery
11782 attempt. It is false during any subsequent delivery attempts.
11783
11784
11785 .vitem "&*forall{*&<&'a list'&>&*}{*&<&'a condition'&>&*}*&" &&&
11786        "&*forany{*&<&'a list'&>&*}{*&<&'a condition'&>&*}*&"
11787 .cindex "list" "iterative conditions"
11788 .cindex "expansion" "&*forall*& condition"
11789 .cindex "expansion" "&*forany*& condition"
11790 .vindex "&$item$&"
11791 These conditions iterate over a list. The first argument is expanded to form
11792 the list. By default, the list separator is a colon, but it can be changed by
11793 the normal method (&<<SECTlistsepchange>>&).
11794 The second argument is interpreted as a condition that is to
11795 be applied to each item in the list in turn. During the interpretation of the
11796 condition, the current list item is placed in a variable called &$item$&.
11797 .ilist
11798 For &*forany*&, interpretation stops if the condition is true for any item, and
11799 the result of the whole condition is true. If the condition is false for all
11800 items in the list, the overall condition is false.
11801 .next
11802 For &*forall*&, interpretation stops if the condition is false for any item,
11803 and the result of the whole condition is false. If the condition is true for
11804 all items in the list, the overall condition is true.
11805 .endlist
11806 Note that negation of &*forany*& means that the condition must be false for all
11807 items for the overall condition to succeed, and negation of &*forall*& means
11808 that the condition must be false for at least one item.
11809
11810 Example:
11811 .code
11812 ${if forany{$recipients_list}{match{$item}{^user3@}}{yes}{no}}
11813 .endd
11814 The value of &$item$& is saved and restored while &%forany%& or &%forall%& is
11815 being processed, to enable these expansion items to be nested.
11816
11817 To scan a named list, expand it with the &*listnamed*& operator.
11818
11819 .vitem "&*forall_json{*&<&'a JSON array'&>&*}{*&<&'a condition'&>&*}*&" &&&
11820        "&*forany_json{*&<&'a JSON array'&>&*}{*&<&'a condition'&>&*}*&" &&&
11821        "&*forall_jsons{*&<&'a JSON array'&>&*}{*&<&'a condition'&>&*}*&" &&&
11822        "&*forany_jsons{*&<&'a JSON array'&>&*}{*&<&'a condition'&>&*}*&"
11823 .cindex JSON "iterative conditions"
11824 .cindex JSON expansions
11825 .cindex expansion "&*forall_json*& condition"
11826 .cindex expansion "&*forany_json*& condition"
11827 .cindex expansion "&*forall_jsons*& condition"
11828 .cindex expansion "&*forany_jsons*& condition"
11829 As for the above, except that the first argument must, after expansion,
11830 be a JSON array.
11831 The array separator is not changeable.
11832 For the &"jsons"& variants the elements are expected to be JSON strings
11833 and have their quotes removed before the evaluation of the condition.
11834
11835
11836
11837 .vitem &*ge&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*& &&&
11838        &*gei&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
11839 .cindex "string" "comparison"
11840 .cindex "expansion" "string comparison"
11841 .cindex "&%ge%& expansion condition"
11842 .cindex "&%gei%& expansion condition"
11843 The two substrings are first expanded. The condition is true if the first
11844 string is lexically greater than or equal to the second string. For &%ge%& the
11845 comparison includes the case of letters, whereas for &%gei%& the comparison is
11846 case-independent.
11847 Case and collation order are defined per the system C locale.
11848
11849 .vitem &*gt&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*& &&&
11850        &*gti&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
11851 .cindex "string" "comparison"
11852 .cindex "expansion" "string comparison"
11853 .cindex "&%gt%& expansion condition"
11854 .cindex "&%gti%& expansion condition"
11855 The two substrings are first expanded. The condition is true if the first
11856 string is lexically greater than the second string. For &%gt%& the comparison
11857 includes the case of letters, whereas for &%gti%& the comparison is
11858 case-independent.
11859 Case and collation order are defined per the system C locale.
11860
11861
11862 .vitem &*inbound_srs&~{*&<&'local&~part'&>&*}{*&<&'secret'&>&*}*&
11863 SRS decode.  See SECT &<<SECTSRS>>& for details.
11864
11865
11866 .vitem &*inlist&~{*&<&'subject'&>&*}{*&<&'list'&>&*}*& &&&
11867        &*inlisti&~{*&<&'subject'&>&*}{*&<&'list'&>&*}*&
11868 .cindex "string" "comparison"
11869 .cindex "list" "iterative conditions"
11870 Both strings are expanded; the second string is treated as a list of simple
11871 strings; if the first string is a member of the second, then the condition
11872 is true.
11873 For the case-independent &%inlisti%& condition, case is defined per the system C locale.
11874
11875 These are simpler to use versions of the more powerful &*forany*& condition.
11876 Examples, and the &*forany*& equivalents:
11877 .code
11878 ${if inlist{needle}{foo:needle:bar}}
11879   ${if forany{foo:needle:bar}{eq{$item}{needle}}}
11880 ${if inlisti{Needle}{fOo:NeeDLE:bAr}}
11881   ${if forany{fOo:NeeDLE:bAr}{eqi{$item}{Needle}}}
11882 .endd
11883
11884 The variable &$value$& will be set for a successful match and can be
11885 used in the success clause of an &%if%& expansion item using the condition.
11886 .cindex "tainted data" "de-tainting"
11887 .cindex "de-tainting" "using an inlist expansion condition"
11888 It will have the same taint status as the list; expansions such as
11889 .code
11890 ${if inlist {$h_mycode:} {0 : 1 : 42} {$value}}
11891 .endd
11892 can be used for de-tainting.
11893 Any previous &$value$& is restored after the if.
11894
11895
11896 .vitem &*isip&~{*&<&'string'&>&*}*&  &&&
11897        &*isip4&~{*&<&'string'&>&*}*& &&&
11898        &*isip6&~{*&<&'string'&>&*}*&
11899 .cindex "IP address" "testing string format"
11900 .cindex "string" "testing for IP address"
11901 .cindex "&%isip%& expansion condition"
11902 .cindex "&%isip4%& expansion condition"
11903 .cindex "&%isip6%& expansion condition"
11904 The substring is first expanded, and then tested to see if it has the form of
11905 an IP address. Both IPv4 and IPv6 addresses are valid for &%isip%&, whereas
11906 &%isip4%& and &%isip6%& test specifically for IPv4 or IPv6 addresses.
11907
11908 For an IPv4 address, the test is for four dot-separated components, each of
11909 which consists of from one to three digits. For an IPv6 address, up to eight
11910 colon-separated components are permitted, each containing from one to four
11911 hexadecimal digits. There may be fewer than eight components if an empty
11912 component (adjacent colons) is present. Only one empty component is permitted.
11913
11914 &*Note*&: The checks used to be just on the form of the address; actual numerical
11915 values were not considered. Thus, for example, 999.999.999.999 passed the IPv4
11916 check.
11917 This is no longer the case.
11918
11919 The main use of these tests is to distinguish between IP addresses and
11920 host names, or between IPv4 and IPv6 addresses. For example, you could use
11921 .code
11922 ${if isip4{$sender_host_address}...
11923 .endd
11924 to test which IP version an incoming SMTP connection is using.
11925
11926 .vitem &*ldapauth&~{*&<&'ldap&~query'&>&*}*&
11927 .cindex "LDAP" "use for authentication"
11928 .cindex "expansion" "LDAP authentication test"
11929 .cindex "&%ldapauth%& expansion condition"
11930 This condition supports user authentication using LDAP. See section
11931 &<<SECTldap>>& for details of how to use LDAP in lookups and the syntax of
11932 queries. For this use, the query must contain a user name and password. The
11933 query itself is not used, and can be empty. The condition is true if the
11934 password is not empty, and the user name and password are accepted by the LDAP
11935 server. An empty password is rejected without calling LDAP because LDAP binds
11936 with an empty password are considered anonymous regardless of the username, and
11937 will succeed in most configurations. See chapter &<<CHAPSMTPAUTH>>& for details
11938 of SMTP authentication, and chapter &<<CHAPplaintext>>& for an example of how
11939 this can be used.
11940
11941
11942 .vitem &*le&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*& &&&
11943        &*lei&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
11944 .cindex "string" "comparison"
11945 .cindex "expansion" "string comparison"
11946 .cindex "&%le%& expansion condition"
11947 .cindex "&%lei%& expansion condition"
11948 The two substrings are first expanded. The condition is true if the first
11949 string is lexically less than or equal to the second string. For &%le%& the
11950 comparison includes the case of letters, whereas for &%lei%& the comparison is
11951 case-independent.
11952 Case and collation order are defined per the system C locale.
11953
11954 .vitem &*lt&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*& &&&
11955        &*lti&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
11956 .cindex "string" "comparison"
11957 .cindex "expansion" "string comparison"
11958 .cindex "&%lt%& expansion condition"
11959 .cindex "&%lti%& expansion condition"
11960 The two substrings are first expanded. The condition is true if the first
11961 string is lexically less than the second string. For &%lt%& the comparison
11962 includes the case of letters, whereas for &%lti%& the comparison is
11963 case-independent.
11964 Case and collation order are defined per the system C locale.
11965
11966
11967 .vitem &*match&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
11968 .cindex "expansion" "regular expression comparison"
11969 .cindex "regular expressions" "match in expanded string"
11970 .cindex "&%match%& expansion condition"
11971 The two substrings are first expanded. The second is then treated as a regular
11972 expression and applied to the first. Because of the pre-expansion, if the
11973 regular expression contains dollar, or backslash characters, they must be
11974 escaped. Care must also be taken if the regular expression contains braces
11975 (curly brackets). A closing brace must be escaped so that it is not taken as a
11976 premature termination of <&'string2'&>. The easiest approach is to use the
11977 &`\N`& feature to disable expansion of the regular expression.
11978 For example,
11979 .code
11980 ${if match {$local_part}{\N^\d{3}\N} ...
11981 .endd
11982 If the whole expansion string is in double quotes, further escaping of
11983 backslashes is also required.
11984
11985 The condition is true if the regular expression match succeeds.
11986 The regular expression is not required to begin with a circumflex
11987 metacharacter, but if there is no circumflex, the expression is not anchored,
11988 and it may match anywhere in the subject, not just at the start. If you want
11989 the pattern to match at the end of the subject, you must include the &`$`&
11990 metacharacter at an appropriate point.
11991 All character handling is done in bytes and is not UTF-8 aware,
11992 but we might change this in a future Exim release.
11993
11994 .cindex "numerical variables (&$1$& &$2$& etc)" "in &%if%& expansion"
11995 At the start of an &%if%& expansion the values of the numeric variable
11996 substitutions &$1$& etc. are remembered. Obeying a &%match%& condition that
11997 succeeds causes them to be reset to the substrings of that condition and they
11998 will have these values during the expansion of the success string. At the end
11999 of the &%if%& expansion, the previous values are restored. After testing a
12000 combination of conditions using &%or%&, the subsequent values of the numeric
12001 variables are those of the condition that succeeded.
12002
12003 .vitem &*match_address&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
12004 .cindex "&%match_address%& expansion condition"
12005 See &*match_local_part*&.
12006
12007 .vitem &*match_domain&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
12008 .cindex "&%match_domain%& expansion condition"
12009 See &*match_local_part*&.
12010
12011 .vitem &*match_ip&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
12012 .cindex "&%match_ip%& expansion condition"
12013 This condition matches an IP address to a list of IP address patterns. It must
12014 be followed by two argument strings. The first (after expansion) must be an IP
12015 address or an empty string. The second (not expanded) is a restricted host
12016 list that can match only an IP address, not a host name. For example:
12017 .code
12018 ${if match_ip{$sender_host_address}{1.2.3.4:5.6.7.8}{...}{...}}
12019 .endd
12020 The specific types of host list item that are permitted in the list are:
12021
12022 .ilist
12023 An IP address, optionally with a CIDR mask.
12024 .next
12025 A single asterisk, which matches any IP address.
12026 .next
12027 An empty item, which matches only if the IP address is empty. This could be
12028 useful for testing for a locally submitted message or one from specific hosts
12029 in a single test such as
12030 . ==== As this is a nested list, any displays it contains must be indented
12031 . ==== as otherwise they are too far to the left. This comment applies to
12032 . ==== the use of xmlto plus fop. There's no problem when formatting with
12033 . ==== sdop, with or without the extra indent.
12034 .code
12035   ${if match_ip{$sender_host_address}{:4.3.2.1:...}{...}{...}}
12036 .endd
12037 where the first item in the list is the empty string.
12038 .next
12039 The item @[] matches any of the local host's interface addresses.
12040 .next
12041 Single-key lookups are assumed to be like &"net-"& style lookups in host lists,
12042 even if &`net-`& is not specified. There is never any attempt to turn the IP
12043 address into a host name. The most common type of linear search for
12044 &*match_ip*& is likely to be &*iplsearch*&, in which the file can contain CIDR
12045 masks. For example:
12046 .code
12047   ${if match_ip{$sender_host_address}{iplsearch;/some/file}...
12048 .endd
12049 It is of course possible to use other kinds of lookup, and in such a case, you
12050 do need to specify the &`net-`& prefix if you want to specify a specific
12051 address mask, for example:
12052 .code
12053   ${if match_ip{$sender_host_address}{net24-dbm;/some/file}...
12054 .endd
12055 However, unless you are combining a &%match_ip%& condition with others, it is
12056 just as easy to use the fact that a lookup is itself a condition, and write:
12057 .code
12058   ${lookup{${mask:$sender_host_address/24}}dbm{/a/file}...
12059 .endd
12060 .endlist ilist
12061
12062 Note that <&'string2'&> is not itself subject to string expansion, unless
12063 Exim was built with the EXPAND_LISTMATCH_RHS option.
12064
12065 Consult section &<<SECThoslispatip>>& for further details of these patterns.
12066
12067 The variable &$value$& will be set for a successful match and can be
12068 used in the success clause of an &%if%& expansion item using the condition.
12069 Any previous &$value$& is restored after the if.
12070
12071 .vitem &*match_local_part&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
12072 .cindex "domain list" "in expansion condition"
12073 .cindex "address list" "in expansion condition"
12074 .cindex "local part" "list, in expansion condition"
12075 .cindex "&%match_local_part%& expansion condition"
12076 This condition, together with &%match_address%& and &%match_domain%&, make it
12077 possible to test domain, address, and local part lists within expansions. Each
12078 condition requires two arguments: an item and a list to match. A trivial
12079 example is:
12080 .code
12081 ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
12082 .endd
12083 In each case, the second argument may contain any of the allowable items for a
12084 list of the appropriate type. Also, because the second argument
12085 is a standard form of list, it is possible to refer to a named list.
12086 Thus, you can use conditions like this:
12087 .code
12088 ${if match_domain{$domain}{+local_domains}{...
12089 .endd
12090 .cindex "&`+caseful`&"
12091 For address lists, the matching starts off caselessly, but the &`+caseful`&
12092 item can be used, as in all address lists, to cause subsequent items to
12093 have their local parts matched casefully. Domains are always matched
12094 caselessly.
12095
12096 The variable &$value$& will be set for a successful match and can be
12097 used in the success clause of an &%if%& expansion item using the condition.
12098 .cindex "tainted data" "de-tainting"
12099 .cindex "de-tainting" "using a match_local_part expansion condition"
12100 It will have the same taint status as the list; expansions such as
12101 .code
12102 ${if match_local_part {$local_part} {alice : bill : charlotte : dave} {$value}}
12103 .endd
12104 can be used for de-tainting.
12105 Any previous &$value$& is restored after the if.
12106
12107 Note that <&'string2'&> is not itself subject to string expansion, unless
12108 Exim was built with the EXPAND_LISTMATCH_RHS option.
12109
12110 &*Note*&: Host lists are &'not'& supported in this way. This is because
12111 hosts have two identities: a name and an IP address, and it is not clear
12112 how to specify cleanly how such a test would work. However, IP addresses can be
12113 matched using &%match_ip%&.
12114
12115 .vitem &*pam&~{*&<&'string1'&>&*:*&<&'string2'&>&*:...}*&
12116 .cindex "PAM authentication"
12117 .cindex "AUTH" "with PAM"
12118 .cindex "Solaris" "PAM support"
12119 .cindex "expansion" "PAM authentication test"
12120 .cindex "&%pam%& expansion condition"
12121 &'Pluggable Authentication Modules'&
12122 (&url(https://mirrors.edge.kernel.org/pub/linux/libs/pam/)) are a facility that is
12123 available in Solaris
12124 and in some GNU/Linux distributions.
12125 The Exim support, which is intended for use in conjunction with
12126 the SMTP AUTH command, is available only if Exim is compiled with
12127 .code
12128 SUPPORT_PAM=yes
12129 .endd
12130 in &_Local/Makefile_&. You probably need to add &%-lpam%& to EXTRALIBS, and
12131 in some releases of GNU/Linux &%-ldl%& is also needed.
12132
12133 The argument string is first expanded, and the result must be a
12134 colon-separated list of strings. Leading and trailing white space is ignored.
12135 The PAM module is initialized with the service name &"exim"& and the user name
12136 taken from the first item in the colon-separated data string (<&'string1'&>).
12137 The remaining items in the data string are passed over in response to requests
12138 from the authentication function. In the simple case there will only be one
12139 request, for a password, so the data consists of just two strings.
12140
12141 There can be problems if any of the strings are permitted to contain colon
12142 characters. In the usual way, these have to be doubled to avoid being taken as
12143 separators.
12144 The &%listquote%& expansion item can be used for this.
12145 For example, the configuration
12146 of a LOGIN authenticator might contain this setting:
12147 .code
12148 server_condition = ${if pam{$auth1:${listquote{:}{$auth2}}}}
12149 .endd
12150 In some operating systems, PAM authentication can be done only from a process
12151 running as root. Since Exim is running as the Exim user when receiving
12152 messages, this means that PAM cannot be used directly in those systems.
12153 . --- 2018-09-07: the pam_exim modified variant has gone, removed claims re using Exim via that
12154
12155
12156 .vitem &*pwcheck&~{*&<&'string1'&>&*:*&<&'string2'&>&*}*&
12157 .cindex "&'pwcheck'& daemon"
12158 .cindex "Cyrus"
12159 .cindex "expansion" "&'pwcheck'& authentication test"
12160 .cindex "&%pwcheck%& expansion condition"
12161 This condition supports user authentication using the Cyrus &'pwcheck'& daemon.
12162 This is one way of making it possible for passwords to be checked by a process
12163 that is not running as root. &*Note*&: The use of &'pwcheck'& is now
12164 deprecated. Its replacement is &'saslauthd'& (see below).
12165
12166 The pwcheck support is not included in Exim by default. You need to specify
12167 the location of the pwcheck daemon's socket in &_Local/Makefile_& before
12168 building Exim. For example:
12169 .code
12170 CYRUS_PWCHECK_SOCKET=/var/pwcheck/pwcheck
12171 .endd
12172 You do not need to install the full Cyrus software suite in order to use
12173 the pwcheck daemon. You can compile and install just the daemon alone
12174 from the Cyrus SASL library. Ensure that &'exim'& is the only user that has
12175 access to the &_/var/pwcheck_& directory.
12176
12177 The &%pwcheck%& condition takes one argument, which must be the user name and
12178 password, separated by a colon. For example, in a LOGIN authenticator
12179 configuration, you might have this:
12180 .code
12181 server_condition = ${if pwcheck{$auth1:$auth2}}
12182 .endd
12183 Again, for a PLAIN authenticator configuration, this would be:
12184 .code
12185 server_condition = ${if pwcheck{$auth2:$auth3}}
12186 .endd
12187 .vitem &*queue_running*&
12188 .cindex "queue runner" "detecting when delivering from"
12189 .cindex "expansion" "queue runner test"
12190 .cindex "&%queue_running%& expansion condition"
12191 This condition, which has no data, is true during delivery attempts that are
12192 initiated by queue runner processes, and false otherwise.
12193
12194
12195 .vitem &*radius&~{*&<&'authentication&~string'&>&*}*&
12196 .cindex "Radius"
12197 .cindex "expansion" "Radius authentication"
12198 .cindex "&%radius%& expansion condition"
12199 Radius authentication (RFC 2865) is supported in a similar way to PAM. You must
12200 set RADIUS_CONFIG_FILE in &_Local/Makefile_& to specify the location of
12201 the Radius client configuration file in order to build Exim with Radius
12202 support.
12203
12204 With just that one setting, Exim expects to be linked with the &%radiusclient%&
12205 library, using the original API. If you are using release 0.4.0 or later of
12206 this library, you need to set
12207 .code
12208 RADIUS_LIB_TYPE=RADIUSCLIENTNEW
12209 .endd
12210 in &_Local/Makefile_& when building Exim. You can also link Exim with the
12211 &%libradius%& library that comes with FreeBSD. To do this, set
12212 .code
12213 RADIUS_LIB_TYPE=RADLIB
12214 .endd
12215 in &_Local/Makefile_&, in addition to setting RADIUS_CONFIGURE_FILE.
12216 You may also have to supply a suitable setting in EXTRALIBS so that the
12217 Radius library can be found when Exim is linked.
12218
12219 The string specified by RADIUS_CONFIG_FILE is expanded and passed to the
12220 Radius client library, which calls the Radius server. The condition is true if
12221 the authentication is successful. For example:
12222 .code
12223 server_condition = ${if radius{<arguments>}}
12224 .endd
12225
12226
12227 .vitem "&*saslauthd&~{{*&<&'user'&>&*}{*&<&'password'&>&*}&&&
12228         {*&<&'service'&>&*}{*&<&'realm'&>&*}}*&"
12229 .cindex "&'saslauthd'& daemon"
12230 .cindex "Cyrus"
12231 .cindex "expansion" "&'saslauthd'& authentication test"
12232 .cindex "&%saslauthd%& expansion condition"
12233 This condition supports user authentication using the Cyrus &'saslauthd'&
12234 daemon. This replaces the older &'pwcheck'& daemon, which is now deprecated.
12235 Using this daemon is one way of making it possible for passwords to be checked
12236 by a process that is not running as root.
12237
12238 The saslauthd support is not included in Exim by default. You need to specify
12239 the location of the saslauthd daemon's socket in &_Local/Makefile_& before
12240 building Exim. For example:
12241 .code
12242 CYRUS_SASLAUTHD_SOCKET=/var/state/saslauthd/mux
12243 .endd
12244 You do not need to install the full Cyrus software suite in order to use
12245 the saslauthd daemon. You can compile and install just the daemon alone
12246 from the Cyrus SASL library.
12247
12248 Up to four arguments can be supplied to the &%saslauthd%& condition, but only
12249 two are mandatory. For example:
12250 .code
12251 server_condition = ${if saslauthd{{$auth1}{$auth2}}}
12252 .endd
12253 The service and the realm are optional (which is why the arguments are enclosed
12254 in their own set of braces). For details of the meaning of the service and
12255 realm, and how to run the daemon, consult the Cyrus documentation.
12256 .endlist vlist
12257
12258
12259
12260 .section "Combining expansion conditions" "SECID84"
12261 .cindex "expansion" "combining conditions"
12262 Several conditions can be tested at once by combining them using the &%and%&
12263 and &%or%& combination conditions. Note that &%and%& and &%or%& are complete
12264 conditions on their own, and precede their lists of sub-conditions. Each
12265 sub-condition must be enclosed in braces within the overall braces that contain
12266 the list. No repetition of &%if%& is used.
12267
12268
12269 .vlist
12270 .vitem &*or&~{{*&<&'cond1'&>&*}{*&<&'cond2'&>&*}...}*&
12271 .cindex "&""or""& expansion condition"
12272 .cindex "expansion" "&""or""& of conditions"
12273 The sub-conditions are evaluated from left to right. The condition is true if
12274 any one of the sub-conditions is true.
12275 For example,
12276 .code
12277 ${if or {{eq{$local_part}{spqr}}{eq{$domain}{testing.com}}}...
12278 .endd
12279 When a true sub-condition is found, the following ones are parsed but not
12280 evaluated. If there are several &"match"& sub-conditions the values of the
12281 numeric variables afterwards are taken from the first one that succeeds.
12282
12283 .vitem &*and&~{{*&<&'cond1'&>&*}{*&<&'cond2'&>&*}...}*&
12284 .cindex "&""and""& expansion condition"
12285 .cindex "expansion" "&""and""& of conditions"
12286 The sub-conditions are evaluated from left to right. The condition is true if
12287 all of the sub-conditions are true. If there are several &"match"&
12288 sub-conditions, the values of the numeric variables afterwards are taken from
12289 the last one. When a false sub-condition is found, the following ones are
12290 parsed but not evaluated.
12291 .endlist
12292 .ecindex IIDexpcond
12293
12294
12295
12296
12297 .section "Expansion variables" "SECTexpvar"
12298 .cindex "expansion" "variables, list of"
12299 This section contains an alphabetical list of all the expansion variables. Some
12300 of them are available only when Exim is compiled with specific options such as
12301 support for TLS or the content scanning extension.
12302 .cindex "tainted data"
12303 Variables marked as &'tainted'& are likely to carry data supplied by
12304 a potential attacker.
12305 Variables without such marking may also, depending on how their
12306 values are created.
12307 Such variables should not be further expanded,
12308 used as filenames
12309 or used as command-line arguments for external commands.
12310
12311 .vlist
12312 .vitem "&$0$&, &$1$&, etc"
12313 .cindex "numerical variables (&$1$& &$2$& etc)"
12314 When a &%match%& expansion condition succeeds, these variables contain the
12315 captured substrings identified by the regular expression during subsequent
12316 processing of the success string of the containing &%if%& expansion item.
12317 In the expansion condition case
12318 they do not retain their values afterwards; in fact, their previous
12319 values are restored at the end of processing an &%if%& item. The numerical
12320 variables may also be set externally by some other matching process which
12321 precedes the expansion of the string. For example, the commands available in
12322 Exim filter files include an &%if%& command with its own regular expression
12323 matching condition.
12324 If the subject string was tainted then any captured substring will also be.
12325
12326 .vitem "&$acl_arg1$&, &$acl_arg2$&, etc"
12327 Within an acl condition, expansion condition or expansion item
12328 any arguments are copied to these variables,
12329 any unused variables being made empty.
12330
12331 .vitem "&$acl_c...$&"
12332 Values can be placed in these variables by the &%set%& modifier in an ACL. They
12333 can be given any name that starts with &$acl_c$& and is at least six characters
12334 long, but the sixth character must be either a digit or an underscore. For
12335 example: &$acl_c5$&, &$acl_c_mycount$&. The values of the &$acl_c...$&
12336 variables persist throughout the lifetime of an SMTP connection. They can be
12337 used to pass information between ACLs and between different invocations of the
12338 same ACL. When a message is received, the values of these variables are saved
12339 with the message, and can be accessed by filters, routers, and transports
12340 during subsequent delivery.
12341
12342 .vitem "&$acl_m...$&"
12343 These variables are like the &$acl_c...$& variables, except that their values
12344 are reset after a message has been received. Thus, if several messages are
12345 received in one SMTP connection, &$acl_m...$& values are not passed on from one
12346 message to the next, as &$acl_c...$& values are. The &$acl_m...$& variables are
12347 also reset by MAIL, RSET, EHLO, HELO, and after starting a TLS session. When a
12348 message is received, the values of these variables are saved with the message,
12349 and can be accessed by filters, routers, and transports during subsequent
12350 delivery.
12351
12352 .vitem &$acl_narg$&
12353 Within an acl condition, expansion condition or expansion item
12354 this variable has the number of arguments.
12355
12356 .vitem &$acl_verify_message$&
12357 .vindex "&$acl_verify_message$&"
12358 After an address verification has failed, this variable contains the failure
12359 message. It retains its value for use in subsequent modifiers of the verb.
12360 The message can be preserved by coding like this:
12361 .code
12362 warn !verify = sender
12363      set acl_m0 = $acl_verify_message
12364 .endd
12365 You can use &$acl_verify_message$& during the expansion of the &%message%& or
12366 &%log_message%& modifiers, to include information about the verification
12367 failure.
12368 &*Note*&: The variable is cleared at the end of processing the ACL verb.
12369
12370 .vitem &$address_data$&
12371 .vindex "&$address_data$&"
12372 This variable is set by means of the &%address_data%& option in routers. The
12373 value then remains with the address while it is processed by subsequent routers
12374 and eventually a transport. If the transport is handling multiple addresses,
12375 the value from the first address is used. See chapter &<<CHAProutergeneric>>&
12376 for more details. &*Note*&: The contents of &$address_data$& are visible in
12377 user filter files.
12378
12379 If &$address_data$& is set when the routers are called from an ACL to verify
12380 a recipient address, the final value is still in the variable for subsequent
12381 conditions and modifiers of the ACL statement. If routing the address caused it
12382 to be redirected to just one address, the child address is also routed as part
12383 of the verification, and in this case the final value of &$address_data$& is
12384 from the child's routing.
12385
12386 If &$address_data$& is set when the routers are called from an ACL to verify a
12387 sender address, the final value is also preserved, but this time in
12388 &$sender_address_data$&, to distinguish it from data from a recipient
12389 address.
12390
12391 In both cases (recipient and sender verification), the value does not persist
12392 after the end of the current ACL statement. If you want to preserve
12393 these values for longer, you can save them in ACL variables.
12394
12395 .vitem &$address_file$&
12396 .vindex "&$address_file$&"
12397 When, as a result of aliasing, forwarding, or filtering, a message is directed
12398 to a specific file, this variable holds the name of the file when the transport
12399 is running. At other times, the variable is empty. For example, using the
12400 default configuration, if user &%r2d2%& has a &_.forward_& file containing
12401 .code
12402 /home/r2d2/savemail
12403 .endd
12404 then when the &(address_file)& transport is running, &$address_file$&
12405 contains the text string &`/home/r2d2/savemail`&.
12406 .cindex "Sieve filter" "value of &$address_file$&"
12407 For Sieve filters, the value may be &"inbox"& or a relative folder name. It is
12408 then up to the transport configuration to generate an appropriate absolute path
12409 to the relevant file.
12410
12411 .vitem &$address_pipe$&
12412 .vindex "&$address_pipe$&"
12413 When, as a result of aliasing or forwarding, a message is directed to a pipe,
12414 this variable holds the pipe command when the transport is running.
12415
12416 .vitem "&$auth1$& &-- &$auth4$&"
12417 .vindex "&$auth1$&, &$auth2$&, etc"
12418 These variables are used in SMTP authenticators (see chapters
12419 &<<CHAPplaintext>>&&--&<<CHAPtlsauth>>&). Elsewhere, they are empty.
12420
12421 .vitem &$authenticated_id$&
12422 .cindex "authentication" "id"
12423 .vindex "&$authenticated_id$&"
12424 When a server successfully authenticates a client it may be configured to
12425 preserve some of the authentication information in the variable
12426 &$authenticated_id$& (see chapter &<<CHAPSMTPAUTH>>&). For example, a
12427 user/password authenticator configuration might preserve the user name for use
12428 in the routers. Note that this is not the same information that is saved in
12429 &$sender_host_authenticated$&.
12430
12431 When a message is submitted locally (that is, not over a TCP connection)
12432 the value of &$authenticated_id$& is normally the login name of the calling
12433 process. However, a trusted user can override this by means of the &%-oMai%&
12434 command line option.
12435 This second case also sets up information used by the
12436 &$authresults$& expansion item.
12437
12438 .vitem &$authenticated_fail_id$&
12439 .cindex "authentication" "fail" "id"
12440 .vindex "&$authenticated_fail_id$&"
12441 When an authentication attempt fails, the variable &$authenticated_fail_id$&
12442 will contain the failed authentication id. If more than one authentication
12443 id is attempted, it will contain only the last one. The variable is
12444 available for processing in the ACL's, generally the quit or notquit ACL.
12445 A message to a local recipient could still be accepted without requiring
12446 authentication, which means this variable could also be visible in all of
12447 the ACL's as well.
12448
12449
12450 .tvar &$authenticated_sender$&
12451 .cindex "sender" "authenticated"
12452 .cindex "authentication" "sender"
12453 .cindex "AUTH" "on MAIL command"
12454 When acting as a server, Exim takes note of the AUTH= parameter on an incoming
12455 SMTP MAIL command if it believes the sender is sufficiently trusted, as
12456 described in section &<<SECTauthparamail>>&. Unless the data is the string
12457 &"<>"&, it is set as the authenticated sender of the message, and the value is
12458 available during delivery in the &$authenticated_sender$& variable. If the
12459 sender is not trusted, Exim accepts the syntax of AUTH=, but ignores the data.
12460
12461 .vindex "&$qualify_domain$&"
12462 When a message is submitted locally (that is, not over a TCP connection), the
12463 value of &$authenticated_sender$& is an address constructed from the login
12464 name of the calling process and &$qualify_domain$&, except that a trusted user
12465 can override this by means of the &%-oMas%& command line option.
12466
12467
12468 .vitem &$authentication_failed$&
12469 .cindex "authentication" "failure"
12470 .vindex "&$authentication_failed$&"
12471 This variable is set to &"1"& in an Exim server if a client issues an AUTH
12472 command that does not succeed. Otherwise it is set to &"0"&. This makes it
12473 possible to distinguish between &"did not try to authenticate"&
12474 (&$sender_host_authenticated$& is empty and &$authentication_failed$& is set to
12475 &"0"&) and &"tried to authenticate but failed"& (&$sender_host_authenticated$&
12476 is empty and &$authentication_failed$& is set to &"1"&).
12477 Failure includes cancellation of a authentication attempt,
12478 and any negative response to an AUTH command,
12479 (including, for example, an attempt to use an undefined mechanism).
12480
12481 .vitem &$av_failed$&
12482 .cindex "content scanning" "AV scanner failure"
12483 This variable is available when Exim is compiled with the content-scanning
12484 extension. It is set to &"0"& by default, but will be set to &"1"& if any
12485 problem occurs with the virus scanner (specified by &%av_scanner%&) during
12486 the ACL malware condition.
12487
12488 .vitem &$body_linecount$&
12489 .cindex "message body" "line count"
12490 .cindex "body of message" "line count"
12491 .vindex "&$body_linecount$&"
12492 When a message is being received or delivered, this variable contains the
12493 number of lines in the message's body. See also &$message_linecount$&.
12494
12495 .vitem &$body_zerocount$&
12496 .cindex "message body" "binary zero count"
12497 .cindex "body of message" "binary zero count"
12498 .cindex "binary zero" "in message body"
12499 .vindex "&$body_zerocount$&"
12500 When a message is being received or delivered, this variable contains the
12501 number of binary zero bytes (ASCII NULs) in the message's body.
12502
12503 .vitem &$bounce_recipient$&
12504 .vindex "&$bounce_recipient$&"
12505 This is set to the recipient address of a bounce message while Exim is creating
12506 it. It is useful if a customized bounce message text file is in use (see
12507 chapter &<<CHAPemsgcust>>&).
12508
12509 .vitem &$bounce_return_size_limit$&
12510 .vindex "&$bounce_return_size_limit$&"
12511 This contains the value set in the &%bounce_return_size_limit%& option, rounded
12512 up to a multiple of 1000. It is useful when a customized error message text
12513 file is in use (see chapter &<<CHAPemsgcust>>&).
12514
12515 .vitem &$caller_gid$&
12516 .cindex "gid (group id)" "caller"
12517 .vindex "&$caller_gid$&"
12518 The real group id under which the process that called Exim was running. This is
12519 not the same as the group id of the originator of a message (see
12520 &$originator_gid$&). If Exim re-execs itself, this variable in the new
12521 incarnation normally contains the Exim gid.
12522
12523 .vitem &$caller_uid$&
12524 .cindex "uid (user id)" "caller"
12525 .vindex "&$caller_uid$&"
12526 The real user id under which the process that called Exim was running. This is
12527 not the same as the user id of the originator of a message (see
12528 &$originator_uid$&). If Exim re-execs itself, this variable in the new
12529 incarnation normally contains the Exim uid.
12530
12531 .vitem &$callout_address$&
12532 .vindex "&$callout_address$&"
12533 After a callout for verification, spamd or malware daemon service, the
12534 address that was connected to.
12535
12536 .vitem &$compile_number$&
12537 .vindex "&$compile_number$&"
12538 The building process for Exim keeps a count of the number
12539 of times it has been compiled. This serves to distinguish different
12540 compilations of the same version of Exim.
12541
12542 .vitem &$config_dir$&
12543 .vindex "&$config_dir$&"
12544 The directory name of the main configuration file. That is, the content of
12545 &$config_file$& with the last component stripped. The value does not
12546 contain the trailing slash. If &$config_file$& does not contain a slash,
12547 &$config_dir$& is ".".
12548
12549 .vitem &$config_file$&
12550 .vindex "&$config_file$&"
12551 The name of the main configuration file Exim is using.
12552
12553 .vitem &$dkim_verify_status$&
12554 Results of DKIM verification.
12555 For details see section &<<SECDKIMVFY>>&.
12556
12557 .vitem &$dkim_cur_signer$& &&&
12558        &$dkim_verify_reason$& &&&
12559        &$dkim_domain$& &&&
12560        &$dkim_identity$& &&&
12561        &$dkim_selector$& &&&
12562        &$dkim_algo$& &&&
12563        &$dkim_canon_body$& &&&
12564        &$dkim_canon_headers$& &&&
12565        &$dkim_copiedheaders$& &&&
12566        &$dkim_bodylength$& &&&
12567        &$dkim_created$& &&&
12568        &$dkim_expires$& &&&
12569        &$dkim_headernames$& &&&
12570        &$dkim_key_testing$& &&&
12571        &$dkim_key_nosubdomains$& &&&
12572        &$dkim_key_srvtype$& &&&
12573        &$dkim_key_granularity$& &&&
12574        &$dkim_key_notes$& &&&
12575        &$dkim_key_length$&
12576 These variables are only available within the DKIM ACL.
12577 For details see section &<<SECDKIMVFY>>&.
12578
12579 .vitem &$dkim_signers$&
12580 .vindex &$dkim_signers$&
12581 When a message has been received this variable contains
12582 a colon-separated list of signer domains and identities for the message.
12583 For details see section &<<SECDKIMVFY>>&.
12584
12585 .vitem &$dmarc_domain_policy$& &&&
12586        &$dmarc_status$& &&&
12587        &$dmarc_status_text$& &&&
12588        &$dmarc_used_domains$&
12589 Results of DMARC verification.
12590 For details see section &<<SECDMARC>>&.
12591
12592 .vitem &$dnslist_domain$& &&&
12593        &$dnslist_matched$& &&&
12594        &$dnslist_text$& &&&
12595        &$dnslist_value$&
12596 .vindex "&$dnslist_domain$&"
12597 .vindex "&$dnslist_matched$&"
12598 .vindex "&$dnslist_text$&"
12599 .vindex "&$dnslist_value$&"
12600 .cindex "black list (DNS)"
12601 When a DNS (black) list lookup succeeds, these variables are set to contain
12602 the following data from the lookup: the list's domain name, the key that was
12603 looked up, the contents of any associated TXT record, and the value from the
12604 main A record. See section &<<SECID204>>& for more details.
12605
12606 .tvar &$domain$&
12607 When an address is being routed, or delivered on its own, this variable
12608 contains the domain. Uppercase letters in the domain are converted into lower
12609 case for &$domain$&.
12610
12611 Global address rewriting happens when a message is received, so the value of
12612 &$domain$& during routing and delivery is the value after rewriting. &$domain$&
12613 is set during user filtering, but not during system filtering, because a
12614 message may have many recipients and the system filter is called just once.
12615
12616 When more than one address is being delivered at once (for example, several
12617 RCPT commands in one SMTP delivery), &$domain$& is set only if they all
12618 have the same domain. Transports can be restricted to handling only one domain
12619 at a time if the value of &$domain$& is required at transport time &-- this is
12620 the default for local transports. For further details of the environment in
12621 which local transports are run, see chapter &<<CHAPenvironment>>&.
12622
12623 .oindex "&%delay_warning_condition%&"
12624 At the end of a delivery, if all deferred addresses have the same domain, it is
12625 set in &$domain$& during the expansion of &%delay_warning_condition%&.
12626
12627 The &$domain$& variable is also used in some other circumstances:
12628
12629 .ilist
12630 When an ACL is running for a RCPT command, &$domain$& contains the domain of
12631 the recipient address. The domain of the &'sender'& address is in
12632 &$sender_address_domain$& at both MAIL time and at RCPT time. &$domain$& is not
12633 normally set during the running of the MAIL ACL. However, if the sender address
12634 is verified with a callout during the MAIL ACL, the sender domain is placed in
12635 &$domain$& during the expansions of &%hosts%&, &%interface%&, and &%port%& in
12636 the &(smtp)& transport.
12637
12638 .next
12639 When a rewrite item is being processed (see chapter &<<CHAPrewrite>>&),
12640 &$domain$& contains the domain portion of the address that is being rewritten;
12641 it can be used in the expansion of the replacement address, for example, to
12642 rewrite domains by file lookup.
12643
12644 .next
12645 With one important exception, whenever a domain list is being scanned,
12646 &$domain$& contains the subject domain. &*Exception*&: When a domain list in
12647 a &%sender_domains%& condition in an ACL is being processed, the subject domain
12648 is in &$sender_address_domain$& and not in &$domain$&. It works this way so
12649 that, in a RCPT ACL, the sender domain list can be dependent on the
12650 recipient domain (which is what is in &$domain$& at this time).
12651
12652 .next
12653 .cindex "ETRN" "value of &$domain$&"
12654 .oindex "&%smtp_etrn_command%&"
12655 When the &%smtp_etrn_command%& option is being expanded, &$domain$& contains
12656 the complete argument of the ETRN command (see section &<<SECTETRN>>&).
12657 .endlist
12658
12659 .cindex "tainted data"
12660 If the origin of the data is an incoming message,
12661 the result of expanding this variable is tainted and may not
12662 be further expanded or used as a filename.
12663 When an untainted version is needed, one should be obtained from
12664 looking up the value in a local (therefore trusted) database.
12665 Often &$domain_data$& is usable in this role.
12666
12667
12668 .vitem &$domain_data$&
12669 .vindex "&$domain_data$&"
12670 When the &%domains%& condition on a router
12671 or an ACL
12672 matches a domain
12673 against a list, the match value is copied to &$domain_data$&.
12674 This is an enhancement over previous versions of Exim, when it only
12675 applied to the data read by a lookup.
12676 For details on match values see section &<<SECTlistresults>>& et. al.
12677
12678 If the router routes the
12679 address to a transport, the value is available in that transport. If the
12680 transport is handling multiple addresses, the value from the first address is
12681 used.
12682
12683 &$domain_data$& set in an ACL is available during
12684 the rest of the ACL statement.
12685
12686 .vitem &$exim_gid$&
12687 .vindex "&$exim_gid$&"
12688 This variable contains the numerical value of the Exim group id.
12689
12690 .vitem &$exim_path$&
12691 .vindex "&$exim_path$&"
12692 This variable contains the path to the Exim binary.
12693
12694 .vitem &$exim_uid$&
12695 .vindex "&$exim_uid$&"
12696 This variable contains the numerical value of the Exim user id.
12697
12698 .vitem &$exim_version$&
12699 .vindex "&$exim_version$&"
12700 This variable contains the version string of the Exim build.
12701 The first character is a major version number, currently 4.
12702 Then after a dot, the next group of digits is a minor version number.
12703 There may be other characters following the minor version.
12704 This value may be overridden by the &%exim_version%& main config option.
12705
12706 .vitem &$header_$&<&'name'&>
12707 .tmark
12708 This is not strictly an expansion variable. It is expansion syntax for
12709 inserting the message header line with the given name. Note that the name must
12710 be terminated by colon or white space, because it may contain a wide variety of
12711 characters. Note also that braces must &'not'& be used.
12712 See the full description in section &<<SECTexpansionitems>>& above.
12713
12714 .vitem &$headers_added$&
12715 .vindex "&$headers_added$&"
12716 Within an ACL this variable contains the headers added so far by
12717 the ACL modifier add_header (section &<<SECTaddheadacl>>&).
12718 The headers are a newline-separated list.
12719
12720 .vitem &$home$&
12721 .vindex "&$home$&"
12722 When the &%check_local_user%& option is set for a router, the user's home
12723 directory is placed in &$home$& when the check succeeds. In particular, this
12724 means it is set during the running of users' filter files. A router may also
12725 explicitly set a home directory for use by a transport; this can be overridden
12726 by a setting on the transport itself.
12727
12728 When running a filter test via the &%-bf%& option, &$home$& is set to the value
12729 of the environment variable HOME, which is subject to the
12730 &%keep_environment%& and &%add_environment%& main config options.
12731
12732 .vitem &$host$&
12733 .vindex "&$host$&"
12734 If a router assigns an address to a transport (any transport), and passes a
12735 list of hosts with the address, the value of &$host$& when the transport starts
12736 to run is the name of the first host on the list. Note that this applies both
12737 to local and remote transports.
12738
12739 .cindex "transport" "filter"
12740 .cindex "filter" "transport filter"
12741 For the &(smtp)& transport, if there is more than one host, the value of
12742 &$host$& changes as the transport works its way through the list. In
12743 particular, when the &(smtp)& transport is expanding its options for encryption
12744 using TLS, or for specifying a transport filter (see chapter
12745 &<<CHAPtransportgeneric>>&), &$host$& contains the name of the host to which it
12746 is connected.
12747
12748 When used in the client part of an authenticator configuration (see chapter
12749 &<<CHAPSMTPAUTH>>&), &$host$& contains the name of the server to which the
12750 client is connected.
12751
12752
12753 .vitem &$host_address$&
12754 .vindex "&$host_address$&"
12755 This variable is set to the remote host's IP address whenever &$host$& is set
12756 for a remote connection. It is also set to the IP address that is being checked
12757 when the &%ignore_target_hosts%& option is being processed.
12758
12759 .vitem &$host_data$&
12760 .vindex "&$host_data$&"
12761 If a &%hosts%& condition in an ACL is satisfied by means of a lookup, the
12762 result of the lookup is made available in the &$host_data$& variable. This
12763 allows you, for example, to do things like this:
12764 .code
12765 deny  hosts = net-lsearch;/some/file
12766       message = $host_data
12767 .endd
12768
12769 .vitem &$host_lookup_deferred$&
12770 .cindex "host name" "lookup, failure of"
12771 .vindex "&$host_lookup_deferred$&"
12772 This variable normally contains &"0"&, as does &$host_lookup_failed$&. When a
12773 message comes from a remote host and there is an attempt to look up the host's
12774 name from its IP address, and the attempt is not successful, one of these
12775 variables is set to &"1"&.
12776
12777 .ilist
12778 If the lookup receives a definite negative response (for example, a DNS lookup
12779 succeeded, but no records were found), &$host_lookup_failed$& is set to &"1"&.
12780
12781 .next
12782 If there is any kind of problem during the lookup, such that Exim cannot
12783 tell whether or not the host name is defined (for example, a timeout for a DNS
12784 lookup), &$host_lookup_deferred$& is set to &"1"&.
12785 .endlist ilist
12786
12787 Looking up a host's name from its IP address consists of more than just a
12788 single reverse lookup. Exim checks that a forward lookup of at least one of the
12789 names it receives from a reverse lookup yields the original IP address. If this
12790 is not the case, Exim does not accept the looked up name(s), and
12791 &$host_lookup_failed$& is set to &"1"&. Thus, being able to find a name from an
12792 IP address (for example, the existence of a PTR record in the DNS) is not
12793 sufficient on its own for the success of a host name lookup. If the reverse
12794 lookup succeeds, but there is a lookup problem such as a timeout when checking
12795 the result, the name is not accepted, and &$host_lookup_deferred$& is set to
12796 &"1"&. See also &$sender_host_name$&.
12797
12798 .cindex authentication "expansion item"
12799 Performing these checks sets up information used by the
12800 &%authresults%& expansion item.
12801
12802
12803 .vitem &$host_lookup_failed$&
12804 .vindex "&$host_lookup_failed$&"
12805 See &$host_lookup_deferred$&.
12806
12807 .vitem &$host_port$&
12808 .vindex "&$host_port$&"
12809 This variable is set to the remote host's TCP port whenever &$host$& is set
12810 for an outbound connection.
12811
12812 .vitem &$initial_cwd$&
12813 .vindex "&$initial_cwd$&
12814 This variable contains the full path name of the initial working
12815 directory of the current Exim process. This may differ from the current
12816 working directory, as Exim changes this to "/" during early startup, and
12817 to &$spool_directory$& later.
12818
12819 .vitem &$inode$&
12820 .vindex "&$inode$&"
12821 The only time this variable is set is while expanding the &%directory_file%&
12822 option in the &(appendfile)& transport. The variable contains the inode number
12823 of the temporary file which is about to be renamed. It can be used to construct
12824 a unique name for the file.
12825
12826 .vitem &$interface_address$& &&&
12827        &$interface_port$&
12828 .vindex "&$interface_address$&"
12829 .vindex "&$interface_port$&"
12830 These are obsolete names for &$received_ip_address$& and &$received_port$&.
12831
12832 .vitem &$item$&
12833 .vindex "&$item$&"
12834 This variable is used during the expansion of &*forall*& and &*forany*&
12835 conditions (see section &<<SECTexpcond>>&), and &*filter*&, &*map*&, and
12836 &*reduce*& items (see section &<<SECTexpcond>>&). In other circumstances, it is
12837 empty.
12838
12839 .vitem &$ldap_dn$&
12840 .vindex "&$ldap_dn$&"
12841 This variable, which is available only when Exim is compiled with LDAP support,
12842 contains the DN from the last entry in the most recently successful LDAP
12843 lookup.
12844
12845 .vitem &$load_average$&
12846 .vindex "&$load_average$&"
12847 This variable contains the system load average, multiplied by 1000 so that it
12848 is an integer. For example, if the load average is 0.21, the value of the
12849 variable is 210. The value is recomputed every time the variable is referenced.
12850
12851 .tvar &$local_part$&
12852 When an address is being routed, or delivered on its own, this
12853 variable contains the local part. When a number of addresses are being
12854 delivered together (for example, multiple RCPT commands in an SMTP
12855 session), &$local_part$& is not set.
12856
12857 Global address rewriting happens when a message is received, so the value of
12858 &$local_part$& during routing and delivery is the value after rewriting.
12859 &$local_part$& is set during user filtering, but not during system filtering,
12860 because a message may have many recipients and the system filter is called just
12861 once.
12862
12863 .cindex "tainted data"
12864 If the origin of the data is an incoming message,
12865 the result of expanding this variable is tainted and
12866 may not be further expanded or used as a filename.
12867
12868 &*Warning*&: the content of this variable is usually provided by a potential
12869 attacker.
12870 Consider carefully the implications of using it unvalidated as a name
12871 for file access.
12872 This presents issues for users' &_.forward_& and filter files.
12873 For traditional full user accounts, use &%check_local_users%& and the
12874 &$local_part_data$& variable rather than this one.
12875 For virtual users, store a suitable pathname component in the database
12876 which is used for account name validation, and use that retrieved value
12877 rather than this variable.
12878 Often &$local_part_data$& is usable in this role.
12879 If needed, use a router &%address_data%& or &%set%& option for
12880 the retrieved data.
12881
12882 When a message is being delivered to a file, pipe, or autoreply transport as a
12883 result of aliasing or forwarding, &$local_part$& is set to the local part of
12884 the parent address, not to the filename or command (see &$address_file$& and
12885 &$address_pipe$&).
12886
12887 When an ACL is running for a RCPT command, &$local_part$& contains the
12888 local part of the recipient address.
12889
12890 When a rewrite item is being processed (see chapter &<<CHAPrewrite>>&),
12891 &$local_part$& contains the local part of the address that is being rewritten;
12892 it can be used in the expansion of the replacement address, for example.
12893
12894 In all cases, all quoting is removed from the local part. For example, for both
12895 the addresses
12896 .code
12897 "abc:xyz"@test.example
12898 abc\:xyz@test.example
12899 .endd
12900 the value of &$local_part$& is
12901 .code
12902 abc:xyz
12903 .endd
12904 If you use &$local_part$& to create another address, you should always wrap it
12905 inside a quoting operator. For example, in a &(redirect)& router you could
12906 have:
12907 .code
12908 data = ${quote_local_part:$local_part}@new.domain.example
12909 .endd
12910 &*Note*&: The value of &$local_part$& is normally lower cased. If you want
12911 to process local parts in a case-dependent manner in a router, you can set the
12912 &%caseful_local_part%& option (see chapter &<<CHAProutergeneric>>&).
12913
12914 .vitem &$local_part_data$&
12915 .vindex "&$local_part_data$&"
12916 When the &%local_parts%& condition on a router or ACL
12917 matches a local part list
12918 the match value is copied to &$local_part_data$&.
12919 This is an enhancement over previous versions of Exim, when it only
12920 applied to the data read by a lookup.
12921 For details on match values see section &<<SECTlistresults>>& et. al.
12922
12923 The &%check_local_user%& router option also sets this variable.
12924
12925 .vindex &$local_part_prefix$& &&&
12926         &$local_part_prefix_v$& &&&
12927         &$local_part_suffix$& &&&
12928         &$local_part_suffix_v$&
12929 .cindex affix variables
12930 If a local part prefix or suffix has been recognized, it is not included in the
12931 value of &$local_part$& during routing and subsequent delivery. The values of
12932 any prefix or suffix are in &$local_part_prefix$& and
12933 &$local_part_suffix$&, respectively.
12934 .cindex "tainted data"
12935 If the specification did not include a wildcard then
12936 the affix variable value is not tainted.
12937
12938 If the affix specification included a wildcard then the portion of
12939 the affix matched by the wildcard is in
12940 &$local_part_prefix_v$& or &$local_part_suffix_v$& as appropriate,
12941 and both the whole and varying values are tainted.
12942
12943 .vitem &$local_scan_data$&
12944 .vindex "&$local_scan_data$&"
12945 This variable contains the text returned by the &[local_scan()]& function when
12946 a message is received. See chapter &<<CHAPlocalscan>>& for more details.
12947
12948 .vitem &$local_user_gid$&
12949 .vindex "&$local_user_gid$&"
12950 See &$local_user_uid$&.
12951
12952 .vitem &$local_user_uid$&
12953 .vindex "&$local_user_uid$&"
12954 This variable and &$local_user_gid$& are set to the uid and gid after the
12955 &%check_local_user%& router precondition succeeds. This means that their values
12956 are available for the remaining preconditions (&%senders%&, &%require_files%&,
12957 and &%condition%&), for the &%address_data%& expansion, and for any
12958 router-specific expansions. At all other times, the values in these variables
12959 are &`(uid_t)(-1)`& and &`(gid_t)(-1)`&, respectively.
12960
12961 .vitem &$localhost_number$&
12962 .vindex "&$localhost_number$&"
12963 This contains the expanded value of the
12964 &%localhost_number%& option. The expansion happens after the main options have
12965 been read.
12966
12967 .vitem &$log_inodes$&
12968 .vindex "&$log_inodes$&"
12969 The number of free inodes in the disk partition where Exim's
12970 log files are being written. The value is recalculated whenever the variable is
12971 referenced. If the relevant file system does not have the concept of inodes,
12972 the value of is -1. See also the &%check_log_inodes%& option.
12973
12974 .vitem &$log_space$&
12975 .vindex "&$log_space$&"
12976 The amount of free space (as a number of kilobytes) in the disk
12977 partition where Exim's log files are being written. The value is recalculated
12978 whenever the variable is referenced. If the operating system does not have the
12979 ability to find the amount of free space (only true for experimental systems),
12980 the space value is -1. See also the &%check_log_space%& option.
12981
12982
12983 .vitem &$lookup_dnssec_authenticated$&
12984 .vindex "&$lookup_dnssec_authenticated$&"
12985 This variable is set after a DNS lookup done by
12986 a dnsdb lookup expansion, dnslookup router or smtp transport.
12987 .cindex "DNS" "DNSSEC"
12988 It will be empty if &(DNSSEC)& was not requested,
12989 &"no"& if the result was not labelled as authenticated data
12990 and &"yes"& if it was.
12991 Results that are labelled as authoritative answer that match
12992 the &%dns_trust_aa%& configuration variable count also
12993 as authenticated data.
12994
12995 .vitem &$mailstore_basename$&
12996 .vindex "&$mailstore_basename$&"
12997 This variable is set only when doing deliveries in &"mailstore"& format in the
12998 &(appendfile)& transport. During the expansion of the &%mailstore_prefix%&,
12999 &%mailstore_suffix%&, &%message_prefix%&, and &%message_suffix%& options, it
13000 contains the basename of the files that are being written, that is, the name
13001 without the &".tmp"&, &".env"&, or &".msg"& suffix. At all other times, this
13002 variable is empty.
13003
13004 .vitem &$malware_name$&
13005 .vindex "&$malware_name$&"
13006 This variable is available when Exim is compiled with the
13007 content-scanning extension. It is set to the name of the virus that was found
13008 when the ACL &%malware%& condition is true (see section &<<SECTscanvirus>>&).
13009
13010 .vitem &$max_received_linelength$&
13011 .vindex "&$max_received_linelength$&"
13012 .cindex "maximum" "line length"
13013 .cindex "line length" "maximum"
13014 This variable contains the number of bytes in the longest line that was
13015 received as part of the message, not counting the line termination
13016 character(s).
13017 It is not valid if the &%spool_wireformat%& option is used.
13018
13019 .vitem &$message_age$&
13020 .cindex "message" "age of"
13021 .vindex "&$message_age$&"
13022 This variable is set at the start of a delivery attempt to contain the number
13023 of seconds since the message was received. It does not change during a single
13024 delivery attempt.
13025
13026 .tvar &$message_body$&
13027 .cindex "body of message" "expansion variable"
13028 .cindex "message body" "in expansion"
13029 .cindex "binary zero" "in message body"
13030 .oindex "&%message_body_visible%&"
13031 This variable contains the initial portion of a message's body while it is
13032 being delivered, and is intended mainly for use in filter files. The maximum
13033 number of characters of the body that are put into the variable is set by the
13034 &%message_body_visible%& configuration option; the default is 500.
13035
13036 .oindex "&%message_body_newlines%&"
13037 By default, newlines are converted into spaces in &$message_body$&, to make it
13038 easier to search for phrases that might be split over a line break. However,
13039 this can be disabled by setting &%message_body_newlines%& to be true. Binary
13040 zeros are always converted into spaces.
13041
13042 .tvar &$message_body_end$&
13043 .cindex "body of message" "expansion variable"
13044 .cindex "message body" "in expansion"
13045 This variable contains the final portion of a message's
13046 body while it is being delivered. The format and maximum size are as for
13047 &$message_body$&.
13048
13049 .vitem &$message_body_size$&
13050 .cindex "body of message" "size"
13051 .cindex "message body" "size"
13052 .vindex "&$message_body_size$&"
13053 When a message is being delivered, this variable contains the size of the body
13054 in bytes. The count starts from the character after the blank line that
13055 separates the body from the header. Newlines are included in the count. See
13056 also &$message_size$&, &$body_linecount$&, and &$body_zerocount$&.
13057
13058 If the spool file is wireformat
13059 (see the &%spool_wireformat%& main option)
13060 the CRLF line-terminators are included in the count.
13061
13062 .vitem &$message_exim_id$&
13063 .vindex "&$message_exim_id$&"
13064 When a message is being received or delivered, this variable contains the
13065 unique message id that is generated and used by Exim to identify the message.
13066 An id is not created for a message until after its header has been successfully
13067 received. &*Note*&: This is &'not'& the contents of the &'Message-ID:'& header
13068 line; it is the local id that Exim assigns to the message, for example:
13069 &`1BXTIK-0001yO-VA`&.
13070
13071 .tvar &$message_headers$&
13072 This variable contains a concatenation of all the header lines when a message
13073 is being processed, except for lines added by routers or transports. The header
13074 lines are separated by newline characters. Their contents are decoded in the
13075 same way as a header line that is inserted by &%bheader%&.
13076
13077 .tvar &$message_headers_raw$&
13078 This variable is like &$message_headers$& except that no processing of the
13079 contents of header lines is done.
13080
13081 .vitem &$message_id$&
13082 This is an old name for &$message_exim_id$&. It is now deprecated.
13083
13084 .vitem &$message_linecount$&
13085 .vindex "&$message_linecount$&"
13086 This variable contains the total number of lines in the header and body of the
13087 message. Compare &$body_linecount$&, which is the count for the body only.
13088 During the DATA and content-scanning ACLs, &$message_linecount$& contains the
13089 number of lines received. Before delivery happens (that is, before filters,
13090 routers, and transports run) the count is increased to include the
13091 &'Received:'& header line that Exim standardly adds, and also any other header
13092 lines that are added by ACLs. The blank line that separates the message header
13093 from the body is not counted.
13094
13095 As with the special case of &$message_size$&, during the expansion of the
13096 appendfile transport's maildir_tag option in maildir format, the value of
13097 &$message_linecount$& is the precise size of the number of newlines in the
13098 file that has been written (minus one for the blank line between the
13099 header and the body).
13100
13101 Here is an example of the use of this variable in a DATA ACL:
13102 .code
13103 deny condition = \
13104       ${if <{250}{${eval:$message_linecount - $body_linecount}}}
13105      message   = Too many lines in message header
13106 .endd
13107 In the MAIL and RCPT ACLs, the value is zero because at that stage the
13108 message has not yet been received.
13109
13110 This variable is not valid if the &%spool_wireformat%& option is used.
13111
13112 .vitem &$message_size$&
13113 .cindex "size" "of message"
13114 .cindex "message" "size"
13115 .vindex "&$message_size$&"
13116 When a message is being processed, this variable contains its size in bytes. In
13117 most cases, the size includes those headers that were received with the
13118 message, but not those (such as &'Envelope-to:'&) that are added to individual
13119 deliveries as they are written. However, there is one special case: during the
13120 expansion of the &%maildir_tag%& option in the &(appendfile)& transport while
13121 doing a delivery in maildir format, the value of &$message_size$& is the
13122 precise size of the file that has been written. See also
13123 &$message_body_size$&, &$body_linecount$&, and &$body_zerocount$&.
13124
13125 .cindex "RCPT" "value of &$message_size$&"
13126 While running a per message ACL (mail/rcpt/predata), &$message_size$&
13127 contains the size supplied on the MAIL command, or -1 if no size was given. The
13128 value may not, of course, be truthful.
13129
13130 .vitem &$mime_anomaly_level$& &&&
13131        &$mime_anomaly_text$& &&&
13132        &$mime_boundary$& &&&
13133        &$mime_charset$& &&&
13134        &$mime_content_description$& &&&
13135        &$mime_content_disposition$& &&&
13136        &$mime_content_id$& &&&
13137        &$mime_content_size$& &&&
13138        &$mime_content_transfer_encoding$& &&&
13139        &$mime_content_type$& &&&
13140        &$mime_decoded_filename$& &&&
13141        &$mime_filename$& &&&
13142        &$mime_is_coverletter$& &&&
13143        &$mime_is_multipart$& &&&
13144        &$mime_is_rfc822$& &&&
13145        &$mime_part_count$&
13146 A number of variables whose names start with &$mime$& are
13147 available when Exim is compiled with the content-scanning extension. For
13148 details, see section &<<SECTscanmimepart>>&.
13149
13150 .vitem "&$n0$& &-- &$n9$&"
13151 These variables are counters that can be incremented by means
13152 of the &%add%& command in filter files.
13153
13154 .tvar &$original_domain$&
13155 .vindex "&$domain$&"
13156 When a top-level address is being processed for delivery, this contains the
13157 same value as &$domain$&. However, if a &"child"& address (for example,
13158 generated by an alias, forward, or filter file) is being processed, this
13159 variable contains the domain of the original address (lower cased). This
13160 differs from &$parent_domain$& only when there is more than one level of
13161 aliasing or forwarding. When more than one address is being delivered in a
13162 single transport run, &$original_domain$& is not set.
13163
13164 If a new address is created by means of a &%deliver%& command in a system
13165 filter, it is set up with an artificial &"parent"& address. This has the local
13166 part &'system-filter'& and the default qualify domain.
13167
13168 .tvar &$original_local_part$&
13169 .vindex "&$local_part$&"
13170 When a top-level address is being processed for delivery, this contains the
13171 same value as &$local_part$&, unless a prefix or suffix was removed from the
13172 local part, because &$original_local_part$& always contains the full local
13173 part. When a &"child"& address (for example, generated by an alias, forward, or
13174 filter file) is being processed, this variable contains the full local part of
13175 the original address.
13176
13177 If the router that did the redirection processed the local part
13178 case-insensitively, the value in &$original_local_part$& is in lower case.
13179 This variable differs from &$parent_local_part$& only when there is more than
13180 one level of aliasing or forwarding. When more than one address is being
13181 delivered in a single transport run, &$original_local_part$& is not set.
13182
13183 If a new address is created by means of a &%deliver%& command in a system
13184 filter, it is set up with an artificial &"parent"& address. This has the local
13185 part &'system-filter'& and the default qualify domain.
13186
13187 .vitem &$originator_gid$&
13188 .cindex "gid (group id)" "of originating user"
13189 .cindex "sender" "gid"
13190 .vindex "&$caller_gid$&"
13191 .vindex "&$originator_gid$&"
13192 This variable contains the value of &$caller_gid$& that was set when the
13193 message was received. For messages received via the command line, this is the
13194 gid of the sending user. For messages received by SMTP over TCP/IP, this is
13195 normally the gid of the Exim user.
13196
13197 .vitem &$originator_uid$&
13198 .cindex "uid (user id)" "of originating user"
13199 .cindex "sender" "uid"
13200 .vindex "&$caller_uid$&"
13201 .vindex "&$originator_uid$&"
13202 The value of &$caller_uid$& that was set when the message was received. For
13203 messages received via the command line, this is the uid of the sending user.
13204 For messages received by SMTP over TCP/IP, this is normally the uid of the Exim
13205 user.
13206
13207 .tvar &$parent_domain$&
13208 This variable is similar to &$original_domain$& (see
13209 above), except that it refers to the immediately preceding parent address.
13210
13211 .tvar &$parent_local_part$&
13212 This variable is similar to &$original_local_part$&
13213 (see above), except that it refers to the immediately preceding parent address.
13214
13215 .vitem &$pid$&
13216 .cindex "pid (process id)" "of current process"
13217 .vindex "&$pid$&"
13218 This variable contains the current process id.
13219
13220 .vitem &$pipe_addresses$&
13221 .cindex "filter" "transport filter"
13222 .cindex "transport" "filter"
13223 .vindex "&$pipe_addresses$&"
13224 This is not an expansion variable, but is mentioned here because the string
13225 &`$pipe_addresses`& is handled specially in the command specification for the
13226 &(pipe)& transport (chapter &<<CHAPpipetransport>>&) and in transport filters
13227 (described under &%transport_filter%& in chapter &<<CHAPtransportgeneric>>&).
13228 It cannot be used in general expansion strings, and provokes an &"unknown
13229 variable"& error if encountered.
13230 &*Note*&: This value permits data supplied by a potential attacker to
13231 be used in the command for a &(pipe)& transport.
13232 Such configurations should be carefully assessed for security vulnerbilities.
13233
13234 .vitem &$primary_hostname$&
13235 .vindex "&$primary_hostname$&"
13236 This variable contains the value set by &%primary_hostname%& in the
13237 configuration file, or read by the &[uname()]& function. If &[uname()]& returns
13238 a single-component name, Exim calls &[gethostbyname()]& (or
13239 &[getipnodebyname()]& where available) in an attempt to acquire a fully
13240 qualified host name. See also &$smtp_active_hostname$&.
13241
13242
13243 .vitem &$proxy_external_address$& &&&
13244        &$proxy_external_port$& &&&
13245        &$proxy_local_address$& &&&
13246        &$proxy_local_port$& &&&
13247        &$proxy_session$&
13248 These variables are only available when built with Proxy Protocol
13249 or SOCKS5 support.
13250 For details see chapter &<<SECTproxyInbound>>&.
13251
13252 .vitem &$prdr_requested$&
13253 .cindex "PRDR" "variable for"
13254 This variable is set to &"yes"& if PRDR was requested by the client for the
13255 current message, otherwise &"no"&.
13256
13257 .vitem &$prvscheck_address$& &&&
13258        &$prvscheck_keynum$& &&&
13259        &$prvscheck_result$&
13260 These variables are used in conjunction with the &%prvscheck%& expansion item,
13261 which is described in sections &<<SECTexpansionitems>>& and
13262 &<<SECTverifyPRVS>>&.
13263
13264 .vitem &$qualify_domain$&
13265 .vindex "&$qualify_domain$&"
13266 The value set for the &%qualify_domain%& option in the configuration file.
13267
13268 .vitem &$qualify_recipient$&
13269 .vindex "&$qualify_recipient$&"
13270 The value set for the &%qualify_recipient%& option in the configuration file,
13271 or if not set, the value of &$qualify_domain$&.
13272
13273 .vitem &$queue_name$&
13274 .vindex &$queue_name$&
13275 .cindex "named queues" variable
13276 .cindex queues named
13277 The name of the spool queue in use; empty for the default queue.
13278
13279 .vitem &$queue_size$&
13280 .vindex "&$queue_size$&"
13281 .cindex "queue" "size of"
13282 .cindex "spool" "number of messages"
13283 This variable contains the number of messages queued.
13284 It is evaluated on demand, but no more often than once every minute.
13285 If there is no daemon notifier socket open, the value will be
13286 an empty string.
13287
13288 .vitem &$r_...$&
13289 .vindex &$r_...$&
13290 .cindex router variables
13291 Values can be placed in these variables by the &%set%& option of a router.
13292 They can be given any name that starts with &$r_$&.
13293 The values persist for the address being handled through subsequent routers
13294 and the eventual transport.
13295
13296 .vitem &$rcpt_count$&
13297 .vindex "&$rcpt_count$&"
13298 When a message is being received by SMTP, this variable contains the number of
13299 RCPT commands received for the current message. If this variable is used in a
13300 RCPT ACL, its value includes the current command.
13301
13302 .vitem &$rcpt_defer_count$&
13303 .vindex "&$rcpt_defer_count$&"
13304 .cindex "4&'xx'& responses" "count of"
13305 When a message is being received by SMTP, this variable contains the number of
13306 RCPT commands in the current message that have previously been rejected with a
13307 temporary (4&'xx'&) response.
13308
13309 .vitem &$rcpt_fail_count$&
13310 .vindex "&$rcpt_fail_count$&"
13311 When a message is being received by SMTP, this variable contains the number of
13312 RCPT commands in the current message that have previously been rejected with a
13313 permanent (5&'xx'&) response.
13314
13315 .vitem &$received_count$&
13316 .vindex "&$received_count$&"
13317 This variable contains the number of &'Received:'& header lines in the message,
13318 including the one added by Exim (so its value is always greater than zero). It
13319 is available in the DATA ACL, the non-SMTP ACL, and while routing and
13320 delivering.
13321
13322 .tvar &$received_for$&
13323 If there is only a single recipient address in an incoming message, this
13324 variable contains that address when the &'Received:'& header line is being
13325 built. The value is copied after recipient rewriting has happened, but before
13326 the &[local_scan()]& function is run.
13327
13328 .vitem &$received_ip_address$& &&&
13329        &$received_port$&
13330 .vindex "&$received_ip_address$&"
13331 .vindex "&$received_port$&"
13332 As soon as an Exim server starts processing an incoming TCP/IP connection, these
13333 variables are set to the address and port on the local IP interface.
13334 (The remote IP address and port are in
13335 &$sender_host_address$& and &$sender_host_port$&.) When testing with &%-bh%&,
13336 the port value is -1 unless it has been set using the &%-oMi%& command line
13337 option.
13338
13339 As well as being useful in ACLs (including the &"connect"& ACL), these variable
13340 could be used, for example, to make the filename for a TLS certificate depend
13341 on which interface and/or port is being used for the incoming connection. The
13342 values of &$received_ip_address$& and &$received_port$& are saved with any
13343 messages that are received, thus making these variables available at delivery
13344 time.
13345 For outbound connections see &$sending_ip_address$&.
13346
13347 .vitem &$received_protocol$&
13348 .vindex "&$received_protocol$&"
13349 When a message is being processed, this variable contains the name of the
13350 protocol by which it was received. Most of the names used by Exim are defined
13351 by RFCs 821, 2821, and 3848. They start with &"smtp"& (the client used HELO) or
13352 &"esmtp"& (the client used EHLO). This can be followed by &"s"& for secure
13353 (encrypted) and/or &"a"& for authenticated. Thus, for example, if the protocol
13354 is set to &"esmtpsa"&, the message was received over an encrypted SMTP
13355 connection and the client was successfully authenticated.
13356
13357 Exim uses the protocol name &"smtps"& for the case when encryption is
13358 automatically set up on connection without the use of STARTTLS (see
13359 &%tls_on_connect_ports%&), and the client uses HELO to initiate the
13360 encrypted SMTP session. The name &"smtps"& is also used for the rare situation
13361 where the client initially uses EHLO, sets up an encrypted connection using
13362 STARTTLS, and then uses HELO afterwards.
13363
13364 The &%-oMr%& option provides a way of specifying a custom protocol name for
13365 messages that are injected locally by trusted callers. This is commonly used to
13366 identify messages that are being re-injected after some kind of scanning.
13367
13368 .vitem &$received_time$&
13369 .vindex "&$received_time$&"
13370 This variable contains the date and time when the current message was received,
13371 as a number of seconds since the start of the Unix epoch.
13372
13373 .vitem &$recipient_data$&
13374 .vindex "&$recipient_data$&"
13375 This variable is set after an indexing lookup success in an ACL &%recipients%&
13376 condition. It contains the data from the lookup, and the value remains set
13377 until the next &%recipients%& test. Thus, you can do things like this:
13378 .display
13379 &`require recipients  = cdb*@;/some/file`&
13380 &`deny    `&&'some further test involving'& &`$recipient_data`&
13381 .endd
13382 &*Warning*&: This variable is set only when a lookup is used as an indexing
13383 method in the address list, using the semicolon syntax as in the example above.
13384 The variable is not set for a lookup that is used as part of the string
13385 expansion that all such lists undergo before being interpreted.
13386
13387 .vitem &$recipient_verify_failure$&
13388 .vindex "&$recipient_verify_failure$&"
13389 In an ACL, when a recipient verification fails, this variable contains
13390 information about the failure. It is set to one of the following words:
13391
13392 .ilist
13393 &"qualify"&: The address was unqualified (no domain), and the message
13394 was neither local nor came from an exempted host.
13395
13396 .next
13397 &"route"&: Routing failed.
13398
13399 .next
13400 &"mail"&: Routing succeeded, and a callout was attempted; rejection occurred at
13401 or before the MAIL command (that is, on initial connection, HELO, or
13402 MAIL).
13403
13404 .next
13405 &"recipient"&: The RCPT command in a callout was rejected.
13406 .next
13407
13408 &"postmaster"&: The postmaster check in a callout was rejected.
13409 .endlist
13410
13411 The main use of this variable is expected to be to distinguish between
13412 rejections of MAIL and rejections of RCPT.
13413
13414 .tvar &$recipients$&
13415 .tvar &$recipients_list$&
13416 These variables both contain the envelope recipients for a message.
13417
13418 The first uses a comma and a space separate the addresses in the replacement text.
13419 &*Note*&: an address can legitimately contain a comma;
13420 this variable is not intended for further processing.
13421
13422 The second is a proper Exim list; colon-separated.
13423
13424 However, the variables
13425 are not generally available, to prevent exposure of Bcc recipients in
13426 unprivileged users' filter files. You can use either of them  only in these
13427 cases:
13428
13429 .olist
13430 In a system filter file.
13431 .next
13432 In the ACLs associated with the DATA command and with non-SMTP messages, that
13433 is, the ACLs defined by &%acl_smtp_predata%&, &%acl_smtp_data%&,
13434 &%acl_smtp_mime%&, &%acl_not_smtp_start%&, &%acl_not_smtp%&, and
13435 &%acl_not_smtp_mime%&.
13436 .next
13437 From within a &[local_scan()]& function.
13438 .endlist
13439
13440
13441 .vitem &$recipients_count$&
13442 .vindex "&$recipients_count$&"
13443 When a message is being processed, this variable contains the number of
13444 envelope recipients that came with the message. Duplicates are not excluded
13445 from the count. While a message is being received over SMTP, the number
13446 increases for each accepted recipient. It can be referenced in an ACL.
13447
13448
13449 .vitem &$regex_match_string$&
13450 .vindex "&$regex_match_string$&"
13451 This variable is set to contain the matching regular expression after a
13452 &%regex%& ACL condition has matched (see section &<<SECTscanregex>>&).
13453
13454 .vitem "&$regex1$&, &$regex2$&, etc"
13455 .cindex "regex submatch variables (&$1regex$& &$2regex$& etc)"
13456 When a &%regex%& or &%mime_regex%& ACL condition succeeds,
13457 these variables contain the
13458 captured substrings identified by the regular expression.
13459 If the subject string was tainted then so will any captured substring.
13460
13461
13462 .tvar &$reply_address$&
13463 When a message is being processed, this variable contains the contents of the
13464 &'Reply-To:'& header line if one exists and it is not empty, or otherwise the
13465 contents of the &'From:'& header line. Apart from the removal of leading
13466 white space, the value is not processed in any way. In particular, no RFC 2047
13467 decoding or character code translation takes place.
13468
13469 .vitem &$return_path$&
13470 .vindex "&$return_path$&"
13471 When a message is being delivered, this variable contains the return path &--
13472 the sender field that will be sent as part of the envelope. It is not enclosed
13473 in <> characters. At the start of routing an address, &$return_path$& has the
13474 same value as &$sender_address$&, but if, for example, an incoming message to a
13475 mailing list has been expanded by a router which specifies a different address
13476 for bounce messages, &$return_path$& subsequently contains the new bounce
13477 address, whereas &$sender_address$& always contains the original sender address
13478 that was received with the message. In other words, &$sender_address$& contains
13479 the incoming envelope sender, and &$return_path$& contains the outgoing
13480 envelope sender.
13481
13482 .vitem &$return_size_limit$&
13483 .vindex "&$return_size_limit$&"
13484 This is an obsolete name for &$bounce_return_size_limit$&.
13485
13486 .vitem &$router_name$&
13487 .cindex "router" "name"
13488 .cindex "name" "of router"
13489 .vindex "&$router_name$&"
13490 During the running of a router, or a transport called,
13491 this variable contains the router name.
13492
13493 .vitem &$runrc$&
13494 .cindex "return code" "from &%run%& expansion"
13495 .vindex "&$runrc$&"
13496 This variable contains the return code from a command that is run by the
13497 &%${run...}%& expansion item. &*Warning*&: In a router or transport, you cannot
13498 assume the order in which option values are expanded, except for those
13499 preconditions whose order of testing is documented. Therefore, you cannot
13500 reliably expect to set &$runrc$& by the expansion of one option, and use it in
13501 another.
13502
13503 .vitem &$self_hostname$&
13504 .oindex "&%self%&" "value of host name"
13505 .vindex "&$self_hostname$&"
13506 When an address is routed to a supposedly remote host that turns out to be the
13507 local host, what happens is controlled by the &%self%& generic router option.
13508 One of its values causes the address to be passed to another router. When this
13509 happens, &$self_hostname$& is set to the name of the local host that the
13510 original router encountered. In other circumstances its contents are null.
13511
13512 .tvar &$sender_address$&
13513 When a message is being processed, this variable contains the sender's address
13514 that was received in the message's envelope. The case of letters in the address
13515 is retained, in both the local part and the domain. For bounce messages, the
13516 value of this variable is the empty string. See also &$return_path$&.
13517
13518 .vitem &$sender_address_data$&
13519 .vindex "&$address_data$&"
13520 .vindex "&$sender_address_data$&"
13521 If &$address_data$& is set when the routers are called from an ACL to verify a
13522 sender address, the final value is preserved in &$sender_address_data$&, to
13523 distinguish it from data from a recipient address. The value does not persist
13524 after the end of the current ACL statement. If you want to preserve it for
13525 longer, you can save it in an ACL variable.
13526
13527 .tvar &$sender_address_domain$&
13528 The domain portion of &$sender_address$&.
13529
13530 .tvar &$sender_address_local_part$&
13531 The local part portion of &$sender_address$&.
13532
13533 .vitem &$sender_data$&
13534 .vindex "&$sender_data$&"
13535 This variable is set after a lookup success in an ACL &%senders%& condition or
13536 in a router &%senders%& option. It contains the data from the lookup, and the
13537 value remains set until the next &%senders%& test. Thus, you can do things like
13538 this:
13539 .display
13540 &`require senders      = cdb*@;/some/file`&
13541 &`deny    `&&'some further test involving'& &`$sender_data`&
13542 .endd
13543 &*Warning*&: This variable is set only when a lookup is used as an indexing
13544 method in the address list, using the semicolon syntax as in the example above.
13545 The variable is not set for a lookup that is used as part of the string
13546 expansion that all such lists undergo before being interpreted.
13547
13548 .vitem &$sender_fullhost$&
13549 .vindex "&$sender_fullhost$&"
13550 When a message is received from a remote host, this variable contains the host
13551 name and IP address in a single string. It ends with the IP address in square
13552 brackets, followed by a colon and a port number if the logging of ports is
13553 enabled. The format of the rest of the string depends on whether the host
13554 issued a HELO or EHLO SMTP command, and whether the host name was verified by
13555 looking up its IP address. (Looking up the IP address can be forced by the
13556 &%host_lookup%& option, independent of verification.) A plain host name at the
13557 start of the string is a verified host name; if this is not present,
13558 verification either failed or was not requested. A host name in parentheses is
13559 the argument of a HELO or EHLO command. This is omitted if it is identical to
13560 the verified host name or to the host's IP address in square brackets.
13561
13562 .vitem &$sender_helo_dnssec$&
13563 .vindex "&$sender_helo_dnssec$&"
13564 This boolean variable is true if a successful HELO verification was
13565 .cindex "DNS" "DNSSEC"
13566 done using DNS information the resolver library stated was authenticated data.
13567
13568 .tvar &$sender_helo_name$&
13569 When a message is received from a remote host that has issued a HELO or EHLO
13570 command, the argument of that command is placed in this variable. It is also
13571 set if HELO or EHLO is used when a message is received using SMTP locally via
13572 the &%-bs%& or &%-bS%& options.
13573
13574 .vitem &$sender_host_address$&
13575 .vindex "&$sender_host_address$&"
13576 When a message is received from a remote host using SMTP,
13577 this variable contains that
13578 host's IP address. For locally non-SMTP submitted messages, it is empty.
13579
13580 .vitem &$sender_host_authenticated$&
13581 .vindex "&$sender_host_authenticated$&"
13582 This variable contains the name (not the public name) of the authenticator
13583 driver that successfully authenticated the client from which the message was
13584 received. It is empty if there was no successful authentication. See also
13585 &$authenticated_id$&.
13586
13587 .vitem &$sender_host_dnssec$&
13588 .vindex "&$sender_host_dnssec$&"
13589 If an attempt to populate &$sender_host_name$& has been made
13590 (by reference, &%hosts_lookup%& or
13591 otherwise) then this boolean will have been set true if, and only if, the
13592 resolver library states that both
13593 the reverse and forward DNS were authenticated data.  At all
13594 other times, this variable is false.
13595
13596 .cindex "DNS" "DNSSEC"
13597 It is likely that you will need to coerce DNSSEC support on in the resolver
13598 library, by setting:
13599 .code
13600 dns_dnssec_ok = 1
13601 .endd
13602
13603 In addition, on Linux with glibc 2.31 or newer the resolver library will
13604 default to stripping out a successful validation status.
13605 This will break a previously working Exim installation.
13606 Provided that you do trust the resolver (ie, is on localhost) you can tell
13607 glibc to pass through any successful validation with a new option in
13608 &_/etc/resolv.conf_&:
13609 .code
13610 options trust-ad
13611 .endd
13612
13613 Exim does not perform DNSSEC validation itself, instead leaving that to a
13614 validating resolver (e.g. unbound, or bind with suitable configuration).
13615
13616 If you have changed &%host_lookup_order%& so that &`bydns`& is not the first
13617 mechanism in the list, then this variable will be false.
13618
13619 This requires that your system resolver library support EDNS0 (and that
13620 DNSSEC flags exist in the system headers).  If the resolver silently drops
13621 all EDNS0 options, then this will have no effect.  OpenBSD's asr resolver
13622 is known to currently ignore EDNS0, documented in CAVEATS of asr_run(3).
13623
13624
13625 .tvar &$sender_host_name$&
13626 When a message is received from a remote host, this variable contains the
13627 host's name as obtained by looking up its IP address. For messages received by
13628 other means, this variable is empty.
13629
13630 .vindex "&$host_lookup_failed$&"
13631 If the host name has not previously been looked up, a reference to
13632 &$sender_host_name$& triggers a lookup (for messages from remote hosts).
13633 A looked up name is accepted only if it leads back to the original IP address
13634 via a forward lookup. If either the reverse or the forward lookup fails to find
13635 any data, or if the forward lookup does not yield the original IP address,
13636 &$sender_host_name$& remains empty, and &$host_lookup_failed$& is set to &"1"&.
13637
13638 .vindex "&$host_lookup_deferred$&"
13639 However, if either of the lookups cannot be completed (for example, there is a
13640 DNS timeout), &$host_lookup_deferred$& is set to &"1"&, and
13641 &$host_lookup_failed$& remains set to &"0"&.
13642
13643 Once &$host_lookup_failed$& is set to &"1"&, Exim does not try to look up the
13644 host name again if there is a subsequent reference to &$sender_host_name$&
13645 in the same Exim process, but it does try again if &$host_lookup_deferred$&
13646 is set to &"1"&.
13647
13648 Exim does not automatically look up every calling host's name. If you want
13649 maximum efficiency, you should arrange your configuration so that it avoids
13650 these lookups altogether. The lookup happens only if one or more of the
13651 following are true:
13652
13653 .ilist
13654 A string containing &$sender_host_name$& is expanded.
13655 .next
13656 The calling host matches the list in &%host_lookup%&. In the default
13657 configuration, this option is set to *, so it must be changed if lookups are
13658 to be avoided. (In the code, the default for &%host_lookup%& is unset.)
13659 .next
13660 Exim needs the host name in order to test an item in a host list. The items
13661 that require this are described in sections &<<SECThoslispatnam>>& and
13662 &<<SECThoslispatnamsk>>&.
13663 .next
13664 The calling host matches &%helo_try_verify_hosts%& or &%helo_verify_hosts%&.
13665 In this case, the host name is required to compare with the name quoted in any
13666 EHLO or HELO commands that the client issues.
13667 .next
13668 The remote host issues a EHLO or HELO command that quotes one of the
13669 domains in &%helo_lookup_domains%&. The default value of this option is
13670 . ==== As this is a nested list, any displays it contains must be indented
13671 . ==== as otherwise they are too far to the left.
13672 .code
13673   helo_lookup_domains = @ : @[]
13674 .endd
13675 which causes a lookup if a remote host (incorrectly) gives the server's name or
13676 IP address in an EHLO or HELO command.
13677 .endlist
13678
13679
13680 .vitem &$sender_host_port$&
13681 .vindex "&$sender_host_port$&"
13682 When a message is received from a remote host, this variable contains the port
13683 number that was used on the remote host.
13684
13685 .vitem &$sender_ident$&
13686 .vindex "&$sender_ident$&"
13687 When a message is received from a remote host, this variable contains the
13688 identification received in response to an RFC 1413 request. When a message has
13689 been received locally, this variable contains the login name of the user that
13690 called Exim.
13691
13692 .vitem &$sender_rate_$&&'xxx'&
13693 A number of variables whose names begin &$sender_rate_$& are set as part of the
13694 &%ratelimit%& ACL condition. Details are given in section
13695 &<<SECTratelimiting>>&.
13696
13697 .vitem &$sender_rcvhost$&
13698 .cindex "DNS" "reverse lookup"
13699 .cindex "reverse DNS lookup"
13700 .vindex "&$sender_rcvhost$&"
13701 This is provided specifically for use in &'Received:'& headers. It starts with
13702 either the verified host name (as obtained from a reverse DNS lookup) or, if
13703 there is no verified host name, the IP address in square brackets. After that
13704 there may be text in parentheses. When the first item is a verified host name,
13705 the first thing in the parentheses is the IP address in square brackets,
13706 followed by a colon and a port number if port logging is enabled. When the
13707 first item is an IP address, the port is recorded as &"port=&'xxxx'&"& inside
13708 the parentheses.
13709
13710 There may also be items of the form &"helo=&'xxxx'&"& if HELO or EHLO
13711 was used and its argument was not identical to the real host name or IP
13712 address, and &"ident=&'xxxx'&"& if an RFC 1413 ident string is available. If
13713 all three items are present in the parentheses, a newline and tab are inserted
13714 into the string, to improve the formatting of the &'Received:'& header.
13715
13716 .vitem &$sender_verify_failure$&
13717 .vindex "&$sender_verify_failure$&"
13718 In an ACL, when a sender verification fails, this variable contains information
13719 about the failure. The details are the same as for
13720 &$recipient_verify_failure$&.
13721
13722 .vitem &$sending_ip_address$&
13723 .vindex "&$sending_ip_address$&"
13724 This variable is set whenever an outgoing SMTP connection to another host has
13725 been set up. It contains the IP address of the local interface that is being
13726 used. This is useful if a host that has more than one IP address wants to take
13727 on different personalities depending on which one is being used. For incoming
13728 connections, see &$received_ip_address$&.
13729
13730 .vitem &$sending_port$&
13731 .vindex "&$sending_port$&"
13732 This variable is set whenever an outgoing SMTP connection to another host has
13733 been set up. It contains the local port that is being used. For incoming
13734 connections, see &$received_port$&.
13735
13736 .vitem &$smtp_active_hostname$&
13737 .vindex "&$smtp_active_hostname$&"
13738 During an incoming SMTP session, this variable contains the value of the active
13739 host name, as specified by the &%smtp_active_hostname%& option. The value of
13740 &$smtp_active_hostname$& is saved with any message that is received, so its
13741 value can be consulted during routing and delivery.
13742
13743 .tvar &$smtp_command$&
13744 During the processing of an incoming SMTP command, this variable contains the
13745 entire command. This makes it possible to distinguish between HELO and EHLO in
13746 the HELO ACL, and also to distinguish between commands such as these:
13747 .code
13748 MAIL FROM:<>
13749 MAIL FROM: <>
13750 .endd
13751 For a MAIL command, extra parameters such as SIZE can be inspected. For a RCPT
13752 command, the address in &$smtp_command$& is the original address before any
13753 rewriting, whereas the values in &$local_part$& and &$domain$& are taken from
13754 the address after SMTP-time rewriting.
13755
13756 .tvar &$smtp_command_argument$&
13757 .cindex "SMTP" "command, argument for"
13758 While an ACL is running to check an SMTP command, this variable contains the
13759 argument, that is, the text that follows the command name, with leading white
13760 space removed. Following the introduction of &$smtp_command$&, this variable is
13761 somewhat redundant, but is retained for backwards compatibility.
13762
13763 .vitem &$smtp_command_history$&
13764 .cindex SMTP "command history"
13765 .vindex "&$smtp_command_history$&"
13766 A comma-separated list (with no whitespace) of the most-recent SMTP commands
13767 received, in time-order left to right.  Only a limited number of commands
13768 are remembered.
13769
13770 .vitem &$smtp_count_at_connection_start$&
13771 .vindex "&$smtp_count_at_connection_start$&"
13772 This variable is set greater than zero only in processes spawned by the Exim
13773 daemon for handling incoming SMTP connections. The name is deliberately long,
13774 in order to emphasize what the contents are. When the daemon accepts a new
13775 connection, it increments this variable. A copy of the variable is passed to
13776 the child process that handles the connection, but its value is fixed, and
13777 never changes. It is only an approximation of how many incoming connections
13778 there actually are, because many other connections may come and go while a
13779 single connection is being processed. When a child process terminates, the
13780 daemon decrements its copy of the variable.
13781
13782 .vitem &$smtp_notquit_reason$&
13783 .vindex "&$smtp_notquit_reason$&"
13784 When the not-QUIT ACL is running, this variable is set to a string
13785 that indicates the reason for the termination of the SMTP connection.
13786
13787 .vitem "&$sn0$& &-- &$sn9$&"
13788 These variables are copies of the values of the &$n0$& &-- &$n9$& accumulators
13789 that were current at the end of the system filter file. This allows a system
13790 filter file to set values that can be tested in users' filter files. For
13791 example, a system filter could set a value indicating how likely it is that a
13792 message is junk mail.
13793
13794 .vitem &$spam_score$& &&&
13795        &$spam_score_int$& &&&
13796        &$spam_bar$& &&&
13797        &$spam_report$& &&&
13798        &$spam_action$&
13799 A number of variables whose names start with &$spam$& are available when Exim
13800 is compiled with the content-scanning extension. For details, see section
13801 &<<SECTscanspamass>>&.
13802
13803 .vitem &$spf_header_comment$& &&&
13804        &$spf_received$& &&&
13805        &$spf_result$& &&&
13806        &$spf_result_guessed$& &&&
13807        &$spf_smtp_comment$&
13808 These variables are only available if Exim is built with SPF support.
13809 For details see section &<<SECSPF>>&.
13810
13811 .vitem &$spool_directory$&
13812 .vindex "&$spool_directory$&"
13813 The name of Exim's spool directory.
13814
13815 .vitem &$spool_inodes$&
13816 .vindex "&$spool_inodes$&"
13817 The number of free inodes in the disk partition where Exim's spool files are
13818 being written. The value is recalculated whenever the variable is referenced.
13819 If the relevant file system does not have the concept of inodes, the value of
13820 is -1. See also the &%check_spool_inodes%& option.
13821
13822 .vitem &$spool_space$&
13823 .vindex "&$spool_space$&"
13824 The amount of free space (as a number of kilobytes) in the disk partition where
13825 Exim's spool files are being written. The value is recalculated whenever the
13826 variable is referenced. If the operating system does not have the ability to
13827 find the amount of free space (only true for experimental systems), the space
13828 value is -1. For example, to check in an ACL that there is at least 50
13829 megabytes free on the spool, you could write:
13830 .code
13831 condition = ${if > {$spool_space}{50000}}
13832 .endd
13833 See also the &%check_spool_space%& option.
13834
13835
13836 .vitem &$thisaddress$&
13837 .vindex "&$thisaddress$&"
13838 This variable is set only during the processing of the &%foranyaddress%&
13839 command in a filter file. Its use is explained in the description of that
13840 command, which can be found in the separate document entitled &'Exim's
13841 interfaces to mail filtering'&.
13842
13843 .vitem &$tls_in_bits$&
13844 .vindex "&$tls_in_bits$&"
13845 Contains an approximation of the TLS cipher's bit-strength
13846 on the inbound connection; the meaning of
13847 this depends upon the TLS implementation used.
13848 If TLS has not been negotiated, the value will be 0.
13849 The value of this is automatically fed into the Cyrus SASL authenticator
13850 when acting as a server, to specify the "external SSF" (a SASL term).
13851
13852 The deprecated &$tls_bits$& variable refers to the inbound side
13853 except when used in the context of an outbound SMTP delivery, when it refers to
13854 the outbound.
13855
13856 .vitem &$tls_out_bits$&
13857 .vindex "&$tls_out_bits$&"
13858 Contains an approximation of the TLS cipher's bit-strength
13859 on an outbound SMTP connection; the meaning of
13860 this depends upon the TLS implementation used.
13861 If TLS has not been negotiated, the value will be 0.
13862
13863 .vitem &$tls_in_ourcert$&
13864 .vindex "&$tls_in_ourcert$&"
13865 .cindex certificate variables
13866 This variable refers to the certificate presented to the peer of an
13867 inbound connection when the message was received.
13868 It is only useful as the argument of a
13869 &%certextract%& expansion item, &%md5%&, &%sha1%& or &%sha256%& operator,
13870 or a &%def%& condition.
13871
13872 &*Note*&: Under versions of OpenSSL preceding 1.1.1,
13873 when a list of more than one
13874 file is used for &%tls_certificate%&, this variable is not reliable.
13875 The macro "_TLS_BAD_MULTICERT_IN_OURCERT" will be defined for those versions.
13876
13877 .vitem &$tls_in_peercert$&
13878 .vindex "&$tls_in_peercert$&"
13879 This variable refers to the certificate presented by the peer of an
13880 inbound connection when the message was received.
13881 It is only useful as the argument of a
13882 &%certextract%& expansion item, &%md5%&, &%sha1%& or &%sha256%& operator,
13883 or a &%def%& condition.
13884 If certificate verification fails it may refer to a failing chain element
13885 which is not the leaf.
13886
13887 .vitem &$tls_out_ourcert$&
13888 .vindex "&$tls_out_ourcert$&"
13889 This variable refers to the certificate presented to the peer of an
13890 outbound connection.  It is only useful as the argument of a
13891 &%certextract%& expansion item, &%md5%&, &%sha1%& or &%sha256%& operator,
13892 or a &%def%& condition.
13893
13894 .vitem &$tls_out_peercert$&
13895 .vindex "&$tls_out_peercert$&"
13896 This variable refers to the certificate presented by the peer of an
13897 outbound connection.  It is only useful as the argument of a
13898 &%certextract%& expansion item, &%md5%&, &%sha1%& or &%sha256%& operator,
13899 or a &%def%& condition.
13900 If certificate verification fails it may refer to a failing chain element
13901 which is not the leaf.
13902
13903 .vitem &$tls_in_certificate_verified$&
13904 .vindex "&$tls_in_certificate_verified$&"
13905 This variable is set to &"1"& if a TLS certificate was verified when the
13906 message was received, and &"0"& otherwise.
13907
13908 The deprecated &$tls_certificate_verified$& variable refers to the inbound side
13909 except when used in the context of an outbound SMTP delivery, when it refers to
13910 the outbound.
13911
13912 .vitem &$tls_out_certificate_verified$&
13913 .vindex "&$tls_out_certificate_verified$&"
13914 This variable is set to &"1"& if a TLS certificate was verified when an
13915 outbound SMTP connection was made,
13916 and &"0"& otherwise.
13917
13918 .vitem &$tls_in_cipher$&
13919 .vindex "&$tls_in_cipher$&"
13920 .vindex "&$tls_cipher$&"
13921 When a message is received from a remote host over an encrypted SMTP
13922 connection, this variable is set to the cipher suite that was negotiated, for
13923 example DES-CBC3-SHA. In other circumstances, in particular, for message
13924 received over unencrypted connections, the variable is empty. Testing
13925 &$tls_in_cipher$& for emptiness is one way of distinguishing between encrypted and
13926 non-encrypted connections during ACL processing.
13927
13928 The deprecated &$tls_cipher$& variable is the same as &$tls_in_cipher$& during message reception,
13929 but in the context of an outward SMTP delivery taking place via the &(smtp)& transport
13930 becomes the same as &$tls_out_cipher$&.
13931
13932 .vitem &$tls_in_cipher_std$&
13933 .vindex "&$tls_in_cipher_std$&"
13934 As above, but returning the RFC standard name for the cipher suite.
13935
13936 .vitem &$tls_out_cipher$&
13937 .vindex "&$tls_out_cipher$&"
13938 This variable is
13939 cleared before any outgoing SMTP connection is made,
13940 and then set to the outgoing cipher suite if one is negotiated. See chapter
13941 &<<CHAPTLS>>& for details of TLS support and chapter &<<CHAPsmtptrans>>& for
13942 details of the &(smtp)& transport.
13943
13944 .vitem &$tls_out_cipher_std$&
13945 .vindex "&$tls_out_cipher_std$&"
13946 As above, but returning the RFC standard name for the cipher suite.
13947
13948 .vitem &$tls_out_dane$&
13949 .vindex &$tls_out_dane$&
13950 DANE active status.  See section &<<SECDANE>>&.
13951
13952 .vitem &$tls_in_ocsp$&
13953 .vindex "&$tls_in_ocsp$&"
13954 When a message is received from a remote client connection
13955 the result of any OCSP request from the client is encoded in this variable:
13956 .code
13957 0 OCSP proof was not requested (default value)
13958 1 No response to request
13959 2 Response not verified
13960 3 Verification failed
13961 4 Verification succeeded
13962 .endd
13963
13964 .vitem &$tls_out_ocsp$&
13965 .vindex "&$tls_out_ocsp$&"
13966 When a message is sent to a remote host connection
13967 the result of any OCSP request made is encoded in this variable.
13968 See &$tls_in_ocsp$& for values.
13969
13970 .vitem &$tls_in_peerdn$&
13971 .vindex "&$tls_in_peerdn$&"
13972 .vindex "&$tls_peerdn$&"
13973 .cindex certificate "extracting fields"
13974 When a message is received from a remote host over an encrypted SMTP
13975 connection, and Exim is configured to request a certificate from the client,
13976 the value of the Distinguished Name of the certificate is made available in the
13977 &$tls_in_peerdn$& during subsequent processing.
13978 If certificate verification fails it may refer to a failing chain element
13979 which is not the leaf.
13980
13981 The deprecated &$tls_peerdn$& variable refers to the inbound side
13982 except when used in the context of an outbound SMTP delivery, when it refers to
13983 the outbound.
13984
13985 .vitem &$tls_out_peerdn$&
13986 .vindex "&$tls_out_peerdn$&"
13987 When a message is being delivered to a remote host over an encrypted SMTP
13988 connection, and Exim is configured to request a certificate from the server,
13989 the value of the Distinguished Name of the certificate is made available in the
13990 &$tls_out_peerdn$& during subsequent processing.
13991 If certificate verification fails it may refer to a failing chain element
13992 which is not the leaf.
13993
13994
13995 .vitem &$tls_in_resumption$& &&&
13996        &$tls_out_resumption$&
13997 .vindex &$tls_in_resumption$&
13998 .vindex &$tls_out_resumption$&
13999 .cindex TLS resumption
14000 Observability for TLS session resumption.  See &<<SECTresumption>>& for details.
14001
14002
14003 .tvar &$tls_in_sni$&
14004 .vindex "&$tls_sni$&"
14005 .cindex "TLS" "Server Name Indication"
14006 .cindex "TLS" SNI
14007 .cindex SNI "observability on server"
14008 When a TLS session is being established, if the client sends the Server
14009 Name Indication extension, the value will be placed in this variable.
14010 If the variable appears in &%tls_certificate%& then this option and
14011 some others, described in &<<SECTtlssni>>&,
14012 will be re-expanded early in the TLS session, to permit
14013 a different certificate to be presented (and optionally a different key to be
14014 used) to the client, based upon the value of the SNI extension.
14015
14016 The deprecated &$tls_sni$& variable refers to the inbound side
14017 except when used in the context of an outbound SMTP delivery, when it refers to
14018 the outbound.
14019
14020 .vitem &$tls_out_sni$&
14021 .vindex "&$tls_out_sni$&"
14022 .cindex "TLS" "Server Name Indication"
14023 .cindex "TLS" SNI
14024 .cindex SNI "observability in client"
14025 During outbound
14026 SMTP deliveries, this variable reflects the value of the &%tls_sni%& option on
14027 the transport.
14028
14029 .vitem &$tls_out_tlsa_usage$&
14030 .vindex &$tls_out_tlsa_usage$&
14031 Bitfield of TLSA record types found.  See section &<<SECDANE>>&.
14032
14033 .vitem &$tls_in_ver$&
14034 .vindex "&$tls_in_ver$&"
14035 When a message is received from a remote host over an encrypted SMTP connection
14036 this variable is set to the protocol version, eg &'TLS1.2'&.
14037
14038 .vitem &$tls_out_ver$&
14039 .vindex "&$tls_out_ver$&"
14040 When a message is being delivered to a remote host over an encrypted SMTP connection
14041 this variable is set to the protocol version.
14042
14043
14044 .vitem &$tod_bsdinbox$&
14045 .vindex "&$tod_bsdinbox$&"
14046 The time of day and the date, in the format required for BSD-style mailbox
14047 files, for example: Thu Oct 17 17:14:09 1995.
14048
14049 .vitem &$tod_epoch$&
14050 .vindex "&$tod_epoch$&"
14051 The time and date as a number of seconds since the start of the Unix epoch.
14052
14053 .vitem &$tod_epoch_l$&
14054 .vindex "&$tod_epoch_l$&"
14055 The time and date as a number of microseconds since the start of the Unix epoch.
14056
14057 .vitem &$tod_full$&
14058 .vindex "&$tod_full$&"
14059 A full version of the time and date, for example: Wed, 16 Oct 1995 09:51:40
14060 +0100. The timezone is always given as a numerical offset from UTC, with
14061 positive values used for timezones that are ahead (east) of UTC, and negative
14062 values for those that are behind (west).
14063
14064 .vitem &$tod_log$&
14065 .vindex "&$tod_log$&"
14066 The time and date in the format used for writing Exim's log files, for example:
14067 1995-10-12 15:32:29, but without a timezone.
14068
14069 .vitem &$tod_logfile$&
14070 .vindex "&$tod_logfile$&"
14071 This variable contains the date in the format yyyymmdd. This is the format that
14072 is used for datestamping log files when &%log_file_path%& contains the &`%D`&
14073 flag.
14074
14075 .vitem &$tod_zone$&
14076 .vindex "&$tod_zone$&"
14077 This variable contains the numerical value of the local timezone, for example:
14078 -0500.
14079
14080 .vitem &$tod_zulu$&
14081 .vindex "&$tod_zulu$&"
14082 This variable contains the UTC date and time in &"Zulu"& format, as specified
14083 by ISO 8601, for example: 20030221154023Z.
14084
14085 .vitem &$transport_name$&
14086 .cindex "transport" "name"
14087 .cindex "name" "of transport"
14088 .vindex "&$transport_name$&"
14089 During the running of a transport, this variable contains its name.
14090
14091 .vitem &$value$&
14092 .vindex "&$value$&"
14093 This variable contains the result of an expansion lookup, extraction operation,
14094 or external command, as described above. It is also used during a
14095 &*reduce*& expansion.
14096
14097 .vitem &$verify_mode$&
14098 .vindex "&$verify_mode$&"
14099 While a router or transport is being run in verify mode or for cutthrough delivery,
14100 contains "S" for sender-verification or "R" for recipient-verification.
14101 Otherwise, empty.
14102
14103 .vitem &$version_number$&
14104 .vindex "&$version_number$&"
14105 The version number of Exim. Same as &$exim_version$&, may be overridden
14106 by the &%exim_version%& main config option.
14107
14108 .vitem &$warn_message_delay$&
14109 .vindex "&$warn_message_delay$&"
14110 This variable is set only during the creation of a message warning about a
14111 delivery delay. Details of its use are explained in section &<<SECTcustwarn>>&.
14112
14113 .vitem &$warn_message_recipients$&
14114 .vindex "&$warn_message_recipients$&"
14115 This variable is set only during the creation of a message warning about a
14116 delivery delay. Details of its use are explained in section &<<SECTcustwarn>>&.
14117 .endlist
14118 .ecindex IIDstrexp
14119
14120
14121
14122 . ////////////////////////////////////////////////////////////////////////////
14123 . ////////////////////////////////////////////////////////////////////////////
14124
14125 .chapter "Embedded Perl" "CHAPperl"
14126 .scindex IIDperl "Perl" "calling from Exim"
14127 Exim can be built to include an embedded Perl interpreter. When this is done,
14128 Perl subroutines can be called as part of the string expansion process. To make
14129 use of the Perl support, you need version 5.004 or later of Perl installed on
14130 your system. To include the embedded interpreter in the Exim binary, include
14131 the line
14132 .code
14133 EXIM_PERL = perl.o
14134 .endd
14135 in your &_Local/Makefile_& and then build Exim in the normal way.
14136
14137
14138 .section "Setting up so Perl can be used" "SECID85"
14139 .oindex "&%perl_startup%&"
14140 Access to Perl subroutines is via a global configuration option called
14141 &%perl_startup%& and an expansion string operator &%${perl ...}%&. If there is
14142 no &%perl_startup%& option in the Exim configuration file then no Perl
14143 interpreter is started and there is almost no overhead for Exim (since none of
14144 the Perl library will be paged in unless used). If there is a &%perl_startup%&
14145 option then the associated value is taken to be Perl code which is executed in
14146 a newly created Perl interpreter.
14147
14148 The value of &%perl_startup%& is not expanded in the Exim sense, so you do not
14149 need backslashes before any characters to escape special meanings. The option
14150 should usually be something like
14151 .code
14152 perl_startup = do '/etc/exim.pl'
14153 .endd
14154 where &_/etc/exim.pl_& is Perl code which defines any subroutines you want to
14155 use from Exim. Exim can be configured either to start up a Perl interpreter as
14156 soon as it is entered, or to wait until the first time it is needed. Starting
14157 the interpreter at the beginning ensures that it is done while Exim still has
14158 its setuid privilege, but can impose an unnecessary overhead if Perl is not in
14159 fact used in a particular run. Also, note that this does not mean that Exim is
14160 necessarily running as root when Perl is called at a later time. By default,
14161 the interpreter is started only when it is needed, but this can be changed in
14162 two ways:
14163
14164 .ilist
14165 .oindex "&%perl_at_start%&"
14166 Setting &%perl_at_start%& (a boolean option) in the configuration requests
14167 a startup when Exim is entered.
14168 .next
14169 The command line option &%-ps%& also requests a startup when Exim is entered,
14170 overriding the setting of &%perl_at_start%&.
14171 .endlist
14172
14173 There is also a command line option &%-pd%& (for delay) which suppresses the
14174 initial startup, even if &%perl_at_start%& is set.
14175
14176 .ilist
14177 .oindex "&%perl_taintmode%&"
14178 .cindex "Perl" "taintmode"
14179 To provide more security executing Perl code via the embedded Perl
14180 interpreter, the &%perl_taintmode%& option can be set. This enables the
14181 taint mode of the Perl interpreter. You are encouraged to set this
14182 option to a true value. To avoid breaking existing installations, it
14183 defaults to false.
14184
14185 &*Note*&: This is entirely separate from Exim's tainted-data tracking.
14186
14187
14188 .section "Calling Perl subroutines" "SECID86"
14189 When the configuration file includes a &%perl_startup%& option you can make use
14190 of the string expansion item to call the Perl subroutines that are defined
14191 by the &%perl_startup%& code. The operator is used in any of the following
14192 forms:
14193 .code
14194 ${perl{foo}}
14195 ${perl{foo}{argument}}
14196 ${perl{foo}{argument1}{argument2} ... }
14197 .endd
14198 which calls the subroutine &%foo%& with the given arguments. A maximum of eight
14199 arguments may be passed. Passing more than this results in an expansion failure
14200 with an error message of the form
14201 .code
14202 Too many arguments passed to Perl subroutine "foo" (max is 8)
14203 .endd
14204 The return value of the Perl subroutine is evaluated in a scalar context before
14205 it is passed back to Exim to be inserted into the expanded string. If the
14206 return value is &'undef'&, the expansion is forced to fail in the same way as
14207 an explicit &"fail"& on an &%if%& or &%lookup%& item. If the subroutine aborts
14208 by obeying Perl's &%die%& function, the expansion fails with the error message
14209 that was passed to &%die%&.
14210
14211
14212 .section "Calling Exim functions from Perl" "SECID87"
14213 Within any Perl code called from Exim, the function &'Exim::expand_string()'&
14214 is available to call back into Exim's string expansion function. For example,
14215 the Perl code
14216 .code
14217 my $lp = Exim::expand_string('$local_part');
14218 .endd
14219 makes the current Exim &$local_part$& available in the Perl variable &$lp$&.
14220 Note those are single quotes and not double quotes to protect against
14221 &$local_part$& being interpolated as a Perl variable.
14222
14223 If the string expansion is forced to fail by a &"fail"& item, the result of
14224 &'Exim::expand_string()'& is &%undef%&. If there is a syntax error in the
14225 expansion string, the Perl call from the original expansion string fails with
14226 an appropriate error message, in the same way as if &%die%& were used.
14227
14228 .cindex "debugging" "from embedded Perl"
14229 .cindex "log" "writing from embedded Perl"
14230 Two other Exim functions are available for use from within Perl code.
14231 &'Exim::debug_write()'& writes a string to the standard error stream if Exim's
14232 debugging is enabled. If you want a newline at the end, you must supply it.
14233 &'Exim::log_write()'& writes a string to Exim's main log, adding a leading
14234 timestamp. In this case, you should not supply a terminating newline.
14235
14236
14237 .section "Use of standard output and error by Perl" "SECID88"
14238 .cindex "Perl" "standard output and error"
14239 You should not write to the standard error or output streams from within your
14240 Perl code, as it is not defined how these are set up. In versions of Exim
14241 before 4.50, it is possible for the standard output or error to refer to the
14242 SMTP connection during message reception via the daemon. Writing to this stream
14243 is certain to cause chaos. From Exim 4.50 onwards, the standard output and
14244 error streams are connected to &_/dev/null_& in the daemon. The chaos is
14245 avoided, but the output is lost.
14246
14247 .cindex "Perl" "use of &%warn%&"
14248 The Perl &%warn%& statement writes to the standard error stream by default.
14249 Calls to &%warn%& may be embedded in Perl modules that you use, but over which
14250 you have no control. When Exim starts up the Perl interpreter, it arranges for
14251 output from the &%warn%& statement to be written to the Exim main log. You can
14252 change this by including appropriate Perl magic somewhere in your Perl code.
14253 For example, to discard &%warn%& output completely, you need this:
14254 .code
14255 $SIG{__WARN__} = sub { };
14256 .endd
14257 Whenever a &%warn%& is obeyed, the anonymous subroutine is called. In this
14258 example, the code for the subroutine is empty, so it does nothing, but you can
14259 include any Perl code that you like. The text of the &%warn%& message is passed
14260 as the first subroutine argument.
14261 .ecindex IIDperl
14262
14263
14264 . ////////////////////////////////////////////////////////////////////////////
14265 . ////////////////////////////////////////////////////////////////////////////
14266
14267 .chapter "Starting the daemon and the use of network interfaces" &&&
14268          "CHAPinterfaces" &&&
14269          "Starting the daemon"
14270 .cindex "daemon" "starting"
14271 .cindex "interface" "listening"
14272 .cindex "network interface"
14273 .cindex "interface" "network"
14274 .cindex "IP address" "for listening"
14275 .cindex "daemon" "listening IP addresses"
14276 .cindex "TCP/IP" "setting listening interfaces"
14277 .cindex "TCP/IP" "setting listening ports"
14278 A host that is connected to a TCP/IP network may have one or more physical
14279 hardware network interfaces. Each of these interfaces may be configured as one
14280 or more &"logical"& interfaces, which are the entities that a program actually
14281 works with. Each of these logical interfaces is associated with an IP address.
14282 In addition, TCP/IP software supports &"loopback"& interfaces (127.0.0.1 in
14283 IPv4 and ::1 in IPv6), which do not use any physical hardware. Exim requires
14284 knowledge about the host's interfaces for use in three different circumstances:
14285
14286 .olist
14287 When a listening daemon is started, Exim needs to know which interfaces
14288 and ports to listen on.
14289 .next
14290 When Exim is routing an address, it needs to know which IP addresses
14291 are associated with local interfaces. This is required for the correct
14292 processing of MX lists by removing the local host and others with the
14293 same or higher priority values. Also, Exim needs to detect cases
14294 when an address is routed to an IP address that in fact belongs to the
14295 local host. Unless the &%self%& router option or the &%allow_localhost%&
14296 option of the smtp transport is set (as appropriate), this is treated
14297 as an error situation.
14298 .next
14299 When Exim connects to a remote host, it may need to know which interface to use
14300 for the outgoing connection.
14301 .endlist
14302
14303
14304 Exim's default behaviour is likely to be appropriate in the vast majority
14305 of cases. If your host has only one interface, and you want all its IP
14306 addresses to be treated in the same way, and you are using only the
14307 standard SMTP port, you should not need to take any special action. The
14308 rest of this chapter does not apply to you.
14309
14310 In a more complicated situation you may want to listen only on certain
14311 interfaces, or on different ports, and for this reason there are a number of
14312 options that can be used to influence Exim's behaviour. The rest of this
14313 chapter describes how they operate.
14314
14315 When a message is received over TCP/IP, the interface and port that were
14316 actually used are set in &$received_ip_address$& and &$received_port$&.
14317
14318
14319
14320 .section "Starting a listening daemon" "SECID89"
14321 When a listening daemon is started (by means of the &%-bd%& command line
14322 option), the interfaces and ports on which it listens are controlled by the
14323 following options:
14324
14325 .ilist
14326 &%daemon_smtp_ports%& contains a list of default ports
14327 or service names.
14328 (For backward compatibility, this option can also be specified in the singular.)
14329 .next
14330 &%local_interfaces%& contains list of interface IP addresses on which to
14331 listen. Each item may optionally also specify a port.
14332 .endlist
14333
14334 The default list separator in both cases is a colon, but this can be changed as
14335 described in section &<<SECTlistsepchange>>&. When IPv6 addresses are involved,
14336 it is usually best to change the separator to avoid having to double all the
14337 colons. For example:
14338 .code
14339 local_interfaces = <; 127.0.0.1 ; \
14340                       192.168.23.65 ; \
14341                       ::1 ; \
14342                       3ffe:ffff:836f::fe86:a061
14343 .endd
14344 There are two different formats for specifying a port along with an IP address
14345 in &%local_interfaces%&:
14346
14347 .olist
14348 The port is added onto the address with a dot separator. For example, to listen
14349 on port 1234 on two different IP addresses:
14350 .code
14351 local_interfaces = <; 192.168.23.65.1234 ; \
14352                       3ffe:ffff:836f::fe86:a061.1234
14353 .endd
14354 .next
14355 The IP address is enclosed in square brackets, and the port is added
14356 with a colon separator, for example:
14357 .code
14358 local_interfaces = <; [192.168.23.65]:1234 ; \
14359                       [3ffe:ffff:836f::fe86:a061]:1234
14360 .endd
14361 .endlist
14362
14363 When a port is not specified, the value of &%daemon_smtp_ports%& is used. The
14364 default setting contains just one port:
14365 .code
14366 daemon_smtp_ports = smtp
14367 .endd
14368 If more than one port is listed, each interface that does not have its own port
14369 specified listens on all of them. Ports that are listed in
14370 &%daemon_smtp_ports%& can be identified either by name (defined in
14371 &_/etc/services_&) or by number. However, when ports are given with individual
14372 IP addresses in &%local_interfaces%&, only numbers (not names) can be used.
14373
14374
14375
14376 .section "Special IP listening addresses" "SECID90"
14377 The addresses 0.0.0.0 and ::0 are treated specially. They are interpreted
14378 as &"all IPv4 interfaces"& and &"all IPv6 interfaces"&, respectively. In each
14379 case, Exim tells the TCP/IP stack to &"listen on all IPv&'x'& interfaces"&
14380 instead of setting up separate listening sockets for each interface. The
14381 default value of &%local_interfaces%& is
14382 .code
14383 local_interfaces = 0.0.0.0
14384 .endd
14385 when Exim is built without IPv6 support; otherwise it is:
14386 .code
14387 local_interfaces = <; ::0 ; 0.0.0.0
14388 .endd
14389 Thus, by default, Exim listens on all available interfaces, on the SMTP port.
14390
14391
14392
14393 .section "Overriding local_interfaces and daemon_smtp_ports" "SECID91"
14394 The &%-oX%& command line option can be used to override the values of
14395 &%daemon_smtp_ports%& and/or &%local_interfaces%& for a particular daemon
14396 instance. Another way of doing this would be to use macros and the &%-D%&
14397 option. However, &%-oX%& can be used by any admin user, whereas modification of
14398 the runtime configuration by &%-D%& is allowed only when the caller is root or
14399 exim.
14400
14401 The value of &%-oX%& is a list of items. The default colon separator can be
14402 changed in the usual way (&<<SECTlistsepchange>>&) if required.
14403 If there are any items that do not
14404 contain dots or colons (that is, are not IP addresses), the value of
14405 &%daemon_smtp_ports%& is replaced by the list of those items. If there are any
14406 items that do contain dots or colons, the value of &%local_interfaces%& is
14407 replaced by those items. Thus, for example,
14408 .code
14409 -oX 1225
14410 .endd
14411 overrides &%daemon_smtp_ports%&, but leaves &%local_interfaces%& unchanged,
14412 whereas
14413 .code
14414 -oX 192.168.34.5.1125
14415 .endd
14416 overrides &%local_interfaces%&, leaving &%daemon_smtp_ports%& unchanged.
14417 (However, since &%local_interfaces%& now contains no items without ports, the
14418 value of &%daemon_smtp_ports%& is no longer relevant in this example.)
14419
14420
14421
14422 .section "Support for the submissions (aka SSMTP or SMTPS) protocol" "SECTsupobssmt"
14423 .cindex "submissions protocol"
14424 .cindex "ssmtp protocol"
14425 .cindex "smtps protocol"
14426 .cindex "SMTP" "ssmtp protocol"
14427 .cindex "SMTP" "smtps protocol"
14428 Exim supports the use of TLS-on-connect, used by mail clients in the
14429 &"submissions"& protocol, historically also known as SMTPS or SSMTP.
14430 For some years, IETF Standards Track documents only blessed the
14431 STARTTLS-based Submission service (port 587) while common practice was to support
14432 the same feature set on port 465, but using TLS-on-connect.
14433 If your installation needs to provide service to mail clients
14434 (Mail User Agents, MUAs) then you should provide service on both the 587 and
14435 the 465 TCP ports.
14436
14437 If the &%tls_on_connect_ports%& option is set to a list of port numbers or
14438 service names, connections to those ports must first establish TLS, before
14439 proceeding to the application layer use of the SMTP protocol.
14440
14441 The common use of this option is expected to be
14442 .code
14443 tls_on_connect_ports = 465
14444 .endd
14445 per RFC 8314.
14446 There is also a command line option &%-tls-on-connect%&, which forces all ports
14447 to behave in this way when a daemon is started.
14448
14449 &*Warning*&: Setting &%tls_on_connect_ports%& does not of itself cause the
14450 daemon to listen on those ports. You must still specify them in
14451 &%daemon_smtp_ports%&, &%local_interfaces%&, or the &%-oX%& option. (This is
14452 because &%tls_on_connect_ports%& applies to &%inetd%& connections as well as to
14453 connections via the daemon.)
14454
14455
14456
14457
14458 .section "IPv6 address scopes" "SECID92"
14459 .cindex "IPv6" "address scopes"
14460 IPv6 addresses have &"scopes"&, and a host with multiple hardware interfaces
14461 can, in principle, have the same link-local IPv6 address on different
14462 interfaces. Thus, additional information is needed, over and above the IP
14463 address, to distinguish individual interfaces. A convention of using a
14464 percent sign followed by something (often the interface name) has been
14465 adopted in some cases, leading to addresses like this:
14466 .code
14467 fe80::202:b3ff:fe03:45c1%eth0
14468 .endd
14469 To accommodate this usage, a percent sign followed by an arbitrary string is
14470 allowed at the end of an IPv6 address. By default, Exim calls &[getaddrinfo()]&
14471 to convert a textual IPv6 address for actual use. This function recognizes the
14472 percent convention in operating systems that support it, and it processes the
14473 address appropriately. Unfortunately, some older libraries have problems with
14474 &[getaddrinfo()]&. If
14475 .code
14476 IPV6_USE_INET_PTON=yes
14477 .endd
14478 is set in &_Local/Makefile_& (or an OS-dependent Makefile) when Exim is built,
14479 Exim uses &'inet_pton()'& to convert a textual IPv6 address for actual use,
14480 instead of &[getaddrinfo()]&. (Before version 4.14, it always used this
14481 function.) Of course, this means that the additional functionality of
14482 &[getaddrinfo()]& &-- recognizing scoped addresses &-- is lost.
14483
14484 .section "Disabling IPv6" "SECID93"
14485 .cindex "IPv6" "disabling"
14486 Sometimes it happens that an Exim binary that was compiled with IPv6 support is
14487 run on a host whose kernel does not support IPv6. The binary will fall back to
14488 using IPv4, but it may waste resources looking up AAAA records, and trying to
14489 connect to IPv6 addresses, causing delays to mail delivery. If you set the
14490 .oindex "&%disable_ipv6%&"
14491 &%disable_ipv6%& option true, even if the Exim binary has IPv6 support, no IPv6
14492 activities take place. AAAA records are never looked up, and any IPv6 addresses
14493 that are listed in &%local_interfaces%&, data for the &(manualroute)& router,
14494 etc. are ignored. If IP literals are enabled, the &(ipliteral)& router declines
14495 to handle IPv6 literal addresses.
14496
14497 On the other hand, when IPv6 is in use, there may be times when you want to
14498 disable it for certain hosts or domains. You can use the &%dns_ipv4_lookup%&
14499 option to globally suppress the lookup of AAAA records for specified domains,
14500 and you can use the &%ignore_target_hosts%& generic router option to ignore
14501 IPv6 addresses in an individual router.
14502
14503
14504
14505 .section "Examples of starting a listening daemon" "SECID94"
14506 The default case in an IPv6 environment is
14507 .code
14508 daemon_smtp_ports = smtp
14509 local_interfaces = <; ::0 ; 0.0.0.0
14510 .endd
14511 This specifies listening on the smtp port on all IPv6 and IPv4 interfaces.
14512 Either one or two sockets may be used, depending on the characteristics of
14513 the TCP/IP stack. (This is complicated and messy; for more information,
14514 read the comments in the &_daemon.c_& source file.)
14515
14516 To specify listening on ports 25 and 26 on all interfaces:
14517 .code
14518 daemon_smtp_ports = 25 : 26
14519 .endd
14520 (leaving &%local_interfaces%& at the default setting) or, more explicitly:
14521 .code
14522 local_interfaces = <; ::0.25     ; ::0.26 \
14523                       0.0.0.0.25 ; 0.0.0.0.26
14524 .endd
14525 To listen on the default port on all IPv4 interfaces, and on port 26 on the
14526 IPv4 loopback address only:
14527 .code
14528 local_interfaces = 0.0.0.0 : 127.0.0.1.26
14529 .endd
14530 To specify listening on the default port on specific interfaces only:
14531 .code
14532 local_interfaces = 10.0.0.67 : 192.168.34.67
14533 .endd
14534 &*Warning*&: Such a setting excludes listening on the loopback interfaces.
14535
14536
14537
14538 .section "Recognizing the local host" "SECTreclocipadd"
14539 The &%local_interfaces%& option is also used when Exim needs to determine
14540 whether or not an IP address refers to the local host. That is, the IP
14541 addresses of all the interfaces on which a daemon is listening are always
14542 treated as local.
14543
14544 For this usage, port numbers in &%local_interfaces%& are ignored. If either of
14545 the items 0.0.0.0 or ::0 are encountered, Exim gets a complete list of
14546 available interfaces from the operating system, and extracts the relevant
14547 (that is, IPv4 or IPv6) addresses to use for checking.
14548
14549 Some systems set up large numbers of virtual interfaces in order to provide
14550 many virtual web servers. In this situation, you may want to listen for
14551 email on only a few of the available interfaces, but nevertheless treat all
14552 interfaces as local when routing. You can do this by setting
14553 &%extra_local_interfaces%& to a list of IP addresses, possibly including the
14554 &"all"& wildcard values. These addresses are recognized as local, but are not
14555 used for listening. Consider this example:
14556 .code
14557 local_interfaces = <; 127.0.0.1 ; ::1 ; \
14558                       192.168.53.235 ; \
14559                       3ffe:2101:12:1:a00:20ff:fe86:a061
14560
14561 extra_local_interfaces = <; ::0 ; 0.0.0.0
14562 .endd
14563 The daemon listens on the loopback interfaces and just one IPv4 and one IPv6
14564 address, but all available interface addresses are treated as local when
14565 Exim is routing.
14566
14567 In some environments the local host name may be in an MX list, but with an IP
14568 address that is not assigned to any local interface. In other cases it may be
14569 desirable to treat other host names as if they referred to the local host. Both
14570 these cases can be handled by setting the &%hosts_treat_as_local%& option.
14571 This contains host names rather than IP addresses. When a host is referenced
14572 during routing, either via an MX record or directly, it is treated as the local
14573 host if its name matches &%hosts_treat_as_local%&, or if any of its IP
14574 addresses match &%local_interfaces%& or &%extra_local_interfaces%&.
14575
14576
14577
14578 .section "Delivering to a remote host" "SECID95"
14579 Delivery to a remote host is handled by the smtp transport. By default, it
14580 allows the system's TCP/IP functions to choose which interface to use (if
14581 there is more than one) when connecting to a remote host. However, the
14582 &%interface%& option can be set to specify which interface is used. See the
14583 description of the smtp transport in chapter &<<CHAPsmtptrans>>& for more
14584 details.
14585
14586
14587
14588
14589 . ////////////////////////////////////////////////////////////////////////////
14590 . ////////////////////////////////////////////////////////////////////////////
14591
14592 .chapter "Main configuration" "CHAPmainconfig"
14593 .scindex IIDconfima "configuration file" "main section"
14594 .scindex IIDmaiconf "main configuration"
14595 The first part of the runtime configuration file contains three types of item:
14596
14597 .ilist
14598 Macro definitions: These lines start with an upper case letter. See section
14599 &<<SECTmacrodefs>>& for details of macro processing.
14600 .next
14601 Named list definitions: These lines start with one of the words &"domainlist"&,
14602 &"hostlist"&, &"addresslist"&, or &"localpartlist"&. Their use is described in
14603 section &<<SECTnamedlists>>&.
14604 .next
14605 Main configuration settings: Each setting occupies one line of the file
14606 (with possible continuations). If any setting is preceded by the word
14607 &"hide"&, the &%-bP%& command line option displays its value to admin users
14608 only. See section &<<SECTcos>>& for a description of the syntax of these option
14609 settings.
14610 .endlist
14611
14612 This chapter specifies all the main configuration options, along with their
14613 types and default values. For ease of finding a particular option, they appear
14614 in alphabetical order in section &<<SECTalomo>>& below. However, because there
14615 are now so many options, they are first listed briefly in functional groups, as
14616 an aid to finding the name of the option you are looking for. Some options are
14617 listed in more than one group.
14618
14619 .section "Miscellaneous" "SECID96"
14620 .table2
14621 .row &%add_environment%&             "environment variables"
14622 .row &%bi_command%&                  "to run for &%-bi%& command line option"
14623 .row &%debug_store%&                 "do extra internal checks"
14624 .row &%disable_ipv6%&                "do no IPv6 processing"
14625 .row &%keep_environment%&            "environment variables"
14626 .row &%keep_malformed%&              "for broken files &-- should not happen"
14627 .row &%localhost_number%&            "for unique message ids in clusters"
14628 .row &%message_body_newlines%&       "retain newlines in &$message_body$&"
14629 .row &%message_body_visible%&        "how much to show in &$message_body$&"
14630 .row &%mua_wrapper%&                 "run in &""MUA wrapper""& mode"
14631 .row &%print_topbitchars%&           "top-bit characters are printing"
14632 .row &%spool_wireformat%&            "use wire-format spool data files when possible"
14633 .row &%timezone%&                    "force time zone"
14634 .endtable
14635
14636
14637 .section "Exim parameters" "SECID97"
14638 .table2
14639 .row &%exim_group%&                  "override compiled-in value"
14640 .row &%exim_path%&                   "override compiled-in value"
14641 .row &%exim_user%&                   "override compiled-in value"
14642 .row &%primary_hostname%&            "default from &[uname()]&"
14643 .row &%split_spool_directory%&       "use multiple directories"
14644 .row &%spool_directory%&             "override compiled-in value"
14645 .endtable
14646
14647
14648
14649 .section "Privilege controls" "SECID98"
14650 .table2
14651 .row &%admin_groups%&                "groups that are Exim admin users"
14652 .row &%commandline_checks_require_admin%& "require admin for various checks"
14653 .row &%deliver_drop_privilege%&      "drop root for delivery processes"
14654 .row &%local_from_check%&            "insert &'Sender:'& if necessary"
14655 .row &%local_from_prefix%&           "for testing &'From:'& for local sender"
14656 .row &%local_from_suffix%&           "for testing &'From:'& for local sender"
14657 .row &%local_sender_retain%&         "keep &'Sender:'& from untrusted user"
14658 .row &%never_users%&                 "do not run deliveries as these"
14659 .row &%prod_requires_admin%&         "forced delivery requires admin user"
14660 .row &%queue_list_requires_admin%&   "queue listing requires admin user"
14661 .row &%trusted_groups%&              "groups that are trusted"
14662 .row &%trusted_users%&               "users that are trusted"
14663 .endtable
14664
14665
14666
14667 .section "Logging" "SECID99"
14668 .table2
14669 .row &%event_action%&                "custom logging"
14670 .row &%hosts_connection_nolog%&      "exemption from connect logging"
14671 .row &%log_file_path%&               "override compiled-in value"
14672 .row &%log_selector%&                "set/unset optional logging"
14673 .row &%log_timezone%&                "add timezone to log lines"
14674 .row &%message_logs%&                "create per-message logs"
14675 .row &%preserve_message_logs%&       "after message completion"
14676 .row &%panic_coredump%&              "request coredump on fatal errors"
14677 .row &%process_log_path%&            "for SIGUSR1 and &'exiwhat'&"
14678 .row &%slow_lookup_log%&             "control logging of slow DNS lookups"
14679 .row &%syslog_duplication%&          "controls duplicate log lines on syslog"
14680 .row &%syslog_facility%&             "set syslog &""facility""& field"
14681 .row &%syslog_pid%&                  "pid in syslog lines"
14682 .row &%syslog_processname%&          "set syslog &""ident""& field"
14683 .row &%syslog_timestamp%&            "timestamp syslog lines"
14684 .row &%write_rejectlog%&             "control use of message log"
14685 .endtable
14686
14687
14688
14689 .section "Frozen messages" "SECID100"
14690 .table2
14691 .row &%auto_thaw%&                   "sets time for retrying frozen messages"
14692 .row &%freeze_tell%&                 "send message when freezing"
14693 .row &%move_frozen_messages%&        "to another directory"
14694 .row &%timeout_frozen_after%&        "keep frozen messages only so long"
14695 .endtable
14696
14697
14698
14699 .section "Data lookups" "SECID101"
14700 .table2
14701 .row &%ibase_servers%&               "InterBase servers"
14702 .row &%ldap_ca_cert_dir%&            "dir of CA certs to verify LDAP server's"
14703 .row &%ldap_ca_cert_file%&           "file of CA certs to verify LDAP server's"
14704 .row &%ldap_cert_file%&              "client cert file for LDAP"
14705 .row &%ldap_cert_key%&               "client key file for LDAP"
14706 .row &%ldap_cipher_suite%&           "TLS negotiation preference control"
14707 .row &%ldap_default_servers%&        "used if no server in query"
14708 .row &%ldap_require_cert%&           "action to take without LDAP server cert"
14709 .row &%ldap_start_tls%&              "require TLS within LDAP"
14710 .row &%ldap_version%&                "set protocol version"
14711 .row &%lookup_open_max%&             "lookup files held open"
14712 .row &%mysql_servers%&               "default MySQL servers"
14713 .row &%oracle_servers%&              "Oracle servers"
14714 .row &%pgsql_servers%&               "default PostgreSQL servers"
14715 .row &%sqlite_lock_timeout%&         "as it says"
14716 .endtable
14717
14718
14719
14720 .section "Message ids" "SECID102"
14721 .table2
14722 .row &%message_id_header_domain%&    "used to build &'Message-ID:'& header"
14723 .row &%message_id_header_text%&      "ditto"
14724 .endtable
14725
14726
14727
14728 .section "Embedded Perl Startup" "SECID103"
14729 .table2
14730 .row &%perl_at_start%&               "always start the interpreter"
14731 .row &%perl_startup%&                "code to obey when starting Perl"
14732 .row &%perl_taintmode%&              "enable taint mode in Perl"
14733 .endtable
14734
14735
14736
14737 .section "Daemon" "SECID104"
14738 .table2
14739 .row &%daemon_smtp_ports%&           "default ports"
14740 .row &%daemon_startup_retries%&      "number of times to retry"
14741 .row &%daemon_startup_sleep%&        "time to sleep between tries"
14742 .row &%extra_local_interfaces%&      "not necessarily listened on"
14743 .row &%local_interfaces%&            "on which to listen, with optional ports"
14744 .row &%notifier_socket%&             "override compiled-in value"
14745 .row &%pid_file_path%&               "override compiled-in value"
14746 .row &%queue_run_max%&               "maximum simultaneous queue runners"
14747 .row &%smtp_backlog_monitor%&        "level to log listen backlog"
14748 .endtable
14749
14750
14751
14752 .section "Resource control" "SECID105"
14753 .table2
14754 .row &%check_log_inodes%&            "before accepting a message"
14755 .row &%check_log_space%&             "before accepting a message"
14756 .row &%check_spool_inodes%&          "before accepting a message"
14757 .row &%check_spool_space%&           "before accepting a message"
14758 .row &%deliver_queue_load_max%&      "no queue deliveries if load high"
14759 .row &%queue_only_load%&             "queue incoming if load high"
14760 .row &%queue_only_load_latch%&       "don't re-evaluate load for each message"
14761 .row &%queue_run_max%&               "maximum simultaneous queue runners"
14762 .row &%remote_max_parallel%&         "parallel SMTP delivery per message"
14763 .row &%smtp_accept_max%&             "simultaneous incoming connections"
14764 .row &%smtp_accept_max_nonmail%&     "non-mail commands"
14765 .row &%smtp_accept_max_nonmail_hosts%& "hosts to which the limit applies"
14766 .row &%smtp_accept_max_per_connection%& "messages per connection"
14767 .row &%smtp_accept_max_per_host%&    "connections from one host"
14768 .row &%smtp_accept_queue%&           "queue mail if more connections"
14769 .row &%smtp_accept_queue_per_connection%& "queue if more messages per &&&
14770                                            connection"
14771 .row &%smtp_accept_reserve%&         "only reserve hosts if more connections"
14772 .row &%smtp_check_spool_space%&      "from SIZE on MAIL command"
14773 .row &%smtp_connect_backlog%&        "passed to TCP/IP stack"
14774 .row &%smtp_load_reserve%&           "SMTP from reserved hosts if load high"
14775 .row &%smtp_reserve_hosts%&          "these are the reserve hosts"
14776 .endtable
14777
14778
14779
14780 .section "Policy controls" "SECID106"
14781 .table2
14782 .row &%acl_not_smtp%&                "ACL for non-SMTP messages"
14783 .row &%acl_not_smtp_mime%&           "ACL for non-SMTP MIME parts"
14784 .row &%acl_not_smtp_start%&          "ACL for start of non-SMTP message"
14785 .row &%acl_smtp_auth%&               "ACL for AUTH"
14786 .row &%acl_smtp_connect%&            "ACL for connection"
14787 .row &%acl_smtp_data%&               "ACL for DATA"
14788 .row &%acl_smtp_data_prdr%&          "ACL for DATA, per-recipient"
14789 .row &%acl_smtp_dkim%&               "ACL for DKIM verification"
14790 .row &%acl_smtp_etrn%&               "ACL for ETRN"
14791 .row &%acl_smtp_expn%&               "ACL for EXPN"
14792 .row &%acl_smtp_helo%&               "ACL for EHLO or HELO"
14793 .row &%acl_smtp_mail%&               "ACL for MAIL"
14794 .row &%acl_smtp_mailauth%&           "ACL for AUTH on MAIL command"
14795 .row &%acl_smtp_mime%&               "ACL for MIME parts"
14796 .row &%acl_smtp_notquit%&            "ACL for non-QUIT terminations"
14797 .row &%acl_smtp_predata%&            "ACL for start of data"
14798 .row &%acl_smtp_quit%&               "ACL for QUIT"
14799 .row &%acl_smtp_rcpt%&               "ACL for RCPT"
14800 .row &%acl_smtp_starttls%&           "ACL for STARTTLS"
14801 .row &%acl_smtp_vrfy%&               "ACL for VRFY"
14802 .row &%av_scanner%&                  "specify virus scanner"
14803 .row &%check_rfc2047_length%&        "check length of RFC 2047 &""encoded &&&
14804                                       words""&"
14805 .row &%dns_cname_loops%&             "follow CNAMEs returned by resolver"
14806 .row &%dns_csa_search_limit%&        "control CSA parent search depth"
14807 .row &%dns_csa_use_reverse%&         "en/disable CSA IP reverse search"
14808 .row &%header_maxsize%&              "total size of message header"
14809 .row &%header_line_maxsize%&         "individual header line limit"
14810 .row &%helo_accept_junk_hosts%&      "allow syntactic junk from these hosts"
14811 .row &%helo_allow_chars%&            "allow illegal chars in HELO names"
14812 .row &%helo_lookup_domains%&         "lookup hostname for these HELO names"
14813 .row &%helo_try_verify_hosts%&       "HELO soft-checked for these hosts"
14814 .row &%helo_verify_hosts%&           "HELO hard-checked for these hosts"
14815 .row &%host_lookup%&                 "host name looked up for these hosts"
14816 .row &%host_lookup_order%&           "order of DNS and local name lookups"
14817 .row &%hosts_proxy%&                 "use proxy protocol for these hosts"
14818 .row &%host_reject_connection%&      "reject connection from these hosts"
14819 .row &%hosts_treat_as_local%&        "useful in some cluster configurations"
14820 .row &%local_scan_timeout%&          "timeout for &[local_scan()]&"
14821 .row &%message_size_limit%&          "for all messages"
14822 .row &%percent_hack_domains%&        "recognize %-hack for these domains"
14823 .row &%proxy_protocol_timeout%&      "timeout for proxy protocol negotiation"
14824 .row &%spamd_address%&               "set interface to SpamAssassin"
14825 .row &%strict_acl_vars%&             "object to unset ACL variables"
14826 .row &%spf_smtp_comment_template%&   "template for &$spf_smtp_comment$&"
14827 .endtable
14828
14829
14830
14831 .section "Callout cache" "SECID107"
14832 .table2
14833 .row &%callout_domain_negative_expire%& "timeout for negative domain cache &&&
14834                                          item"
14835 .row &%callout_domain_positive_expire%& "timeout for positive domain cache &&&
14836                                          item"
14837 .row &%callout_negative_expire%&     "timeout for negative address cache item"
14838 .row &%callout_positive_expire%&     "timeout for positive address cache item"
14839 .row &%callout_random_local_part%&   "string to use for &""random""& testing"
14840 .endtable
14841
14842
14843
14844 .section "TLS" "SECID108"
14845 .table2
14846 .row &%gnutls_compat_mode%&          "use GnuTLS compatibility mode"
14847 .row &%gnutls_allow_auto_pkcs11%&    "allow GnuTLS to autoload PKCS11 modules"
14848 .row &%hosts_require_alpn%&          "mandatory ALPN"
14849 .row &%hosts_require_helo%&          "mandatory HELO/EHLO"
14850 .row &%openssl_options%&             "adjust OpenSSL compatibility options"
14851 .row &%tls_advertise_hosts%&         "advertise TLS to these hosts"
14852 .row &%tls_alpn%&                    "acceptable protocol names"
14853 .row &%tls_certificate%&             "location of server certificate"
14854 .row &%tls_crl%&                     "certificate revocation list"
14855 .row &%tls_dh_max_bits%&             "clamp D-H bit count suggestion"
14856 .row &%tls_dhparam%&                 "DH parameters for server"
14857 .row &%tls_eccurve%&                 "EC curve selection for server"
14858 .row &%tls_ocsp_file%&               "location of server certificate status proof"
14859 .row &%tls_on_connect_ports%&        "specify SSMTP (SMTPS) ports"
14860 .row &%tls_privatekey%&              "location of server private key"
14861 .row &%tls_remember_esmtp%&          "don't reset after starting TLS"
14862 .row &%tls_require_ciphers%&         "specify acceptable ciphers"
14863 .row &%tls_try_verify_hosts%&        "try to verify client certificate"
14864 .row &%tls_verify_certificates%&     "expected client certificates"
14865 .row &%tls_verify_hosts%&            "insist on client certificate verify"
14866 .endtable
14867
14868
14869
14870 .section "Local user handling" "SECID109"
14871 .table2
14872 .row &%finduser_retries%&            "useful in NIS environments"
14873 .row &%gecos_name%&                  "used when creating &'Sender:'&"
14874 .row &%gecos_pattern%&               "ditto"
14875 .row &%max_username_length%&         "for systems that truncate"
14876 .row &%unknown_login%&               "used when no login name found"
14877 .row &%unknown_username%&            "ditto"
14878 .row &%uucp_from_pattern%&           "for recognizing &""From ""& lines"
14879 .row &%uucp_from_sender%&            "ditto"
14880 .endtable
14881
14882
14883
14884 .section "All incoming messages (SMTP and non-SMTP)" "SECID110"
14885 .table2
14886 .row &%header_maxsize%&              "total size of message header"
14887 .row &%header_line_maxsize%&         "individual header line limit"
14888 .row &%message_size_limit%&          "applies to all messages"
14889 .row &%percent_hack_domains%&        "recognize %-hack for these domains"
14890 .row &%received_header_text%&        "expanded to make &'Received:'&"
14891 .row &%received_headers_max%&        "for mail loop detection"
14892 .row &%recipients_max%&              "limit per message"
14893 .row &%recipients_max_reject%&       "permanently reject excess recipients"
14894 .endtable
14895
14896
14897
14898
14899 .section "Non-SMTP incoming messages" "SECID111"
14900 .table2
14901 .row &%receive_timeout%&             "for non-SMTP messages"
14902 .endtable
14903
14904
14905
14906
14907
14908 .section "Incoming SMTP messages" "SECID112"
14909 See also the &'Policy controls'& section above.
14910
14911 .table2
14912 .row &%dkim_verify_hashes%&          "DKIM hash methods accepted for signatures"
14913 .row &%dkim_verify_keytypes%&        "DKIM key types accepted for signatures"
14914 .row &%dkim_verify_min_keysizes%&    "DKIM key sizes accepted for signatures"
14915 .row &%dkim_verify_signers%&         "DKIM domains for which DKIM ACL is run"
14916 .row &%dmarc_forensic_sender%&       "DMARC sender for report messages"
14917 .row &%dmarc_history_file%&          "DMARC results log"
14918 .row &%dmarc_tld_file%&              "DMARC toplevel domains file"
14919 .row &%host_lookup%&                 "host name looked up for these hosts"
14920 .row &%host_lookup_order%&           "order of DNS and local name lookups"
14921 .row &%recipient_unqualified_hosts%& "may send unqualified recipients"
14922 .row &%rfc1413_hosts%&               "make ident calls to these hosts"
14923 .row &%rfc1413_query_timeout%&       "zero disables ident calls"
14924 .row &%sender_unqualified_hosts%&    "may send unqualified senders"
14925 .row &%smtp_accept_keepalive%&       "some TCP/IP magic"
14926 .row &%smtp_accept_max%&             "simultaneous incoming connections"
14927 .row &%smtp_accept_max_nonmail%&     "non-mail commands"
14928 .row &%smtp_accept_max_nonmail_hosts%& "hosts to which the limit applies"
14929 .row &%smtp_accept_max_per_connection%& "messages per connection"
14930 .row &%smtp_accept_max_per_host%&    "connections from one host"
14931 .row &%smtp_accept_queue%&           "queue mail if more connections"
14932 .row &%smtp_accept_queue_per_connection%& "queue if more messages per &&&
14933                                            connection"
14934 .row &%smtp_accept_reserve%&         "only reserve hosts if more connections"
14935 .row &%smtp_active_hostname%&        "host name to use in messages"
14936 .row &%smtp_banner%&                 "text for welcome banner"
14937 .row &%smtp_check_spool_space%&      "from SIZE on MAIL command"
14938 .row &%smtp_connect_backlog%&        "passed to TCP/IP stack"
14939 .row &%smtp_enforce_sync%&           "of SMTP command/responses"
14940 .row &%smtp_etrn_command%&           "what to run for ETRN"
14941 .row &%smtp_etrn_serialize%&         "only one at once"
14942 .row &%smtp_load_reserve%&           "only reserve hosts if this load"
14943 .row &%smtp_max_unknown_commands%&   "before dropping connection"
14944 .row &%smtp_ratelimit_hosts%&        "apply ratelimiting to these hosts"
14945 .row &%smtp_ratelimit_mail%&         "ratelimit for MAIL commands"
14946 .row &%smtp_ratelimit_rcpt%&         "ratelimit for RCPT commands"
14947 .row &%smtp_receive_timeout%&        "per command or data line"
14948 .row &%smtp_reserve_hosts%&          "these are the reserve hosts"
14949 .row &%smtp_return_error_details%&   "give detail on rejections"
14950 .endtable
14951
14952
14953
14954 .section "SMTP extensions" "SECID113"
14955 .table2
14956 .row &%accept_8bitmime%&             "advertise 8BITMIME"
14957 .row &%auth_advertise_hosts%&        "advertise AUTH to these hosts"
14958 .row &%chunking_advertise_hosts%&    "advertise CHUNKING to these hosts"
14959 .row &%dsn_advertise_hosts%&         "advertise DSN extensions to these hosts"
14960 .row &%ignore_fromline_hosts%&       "allow &""From ""& from these hosts"
14961 .row &%ignore_fromline_local%&       "allow &""From ""& from local SMTP"
14962 .row &%pipelining_advertise_hosts%&  "advertise pipelining to these hosts"
14963 .row &%pipelining_connect_advertise_hosts%& "advertise pipelining to these hosts"
14964 .row &%prdr_enable%&                 "advertise PRDR to all hosts"
14965 .row &%smtputf8_advertise_hosts%&    "advertise SMTPUTF8 to these hosts"
14966 .row &%tls_advertise_hosts%&         "advertise TLS to these hosts"
14967 .endtable
14968
14969
14970
14971 .section "Processing messages" "SECID114"
14972 .table2
14973 .row &%allow_domain_literals%&       "recognize domain literal syntax"
14974 .row &%allow_mx_to_ip%&              "allow MX to point to IP address"
14975 .row &%allow_utf8_domains%&          "in addresses"
14976 .row &%check_rfc2047_length%&        "check length of RFC 2047 &""encoded &&&
14977                                       words""&"
14978 .row &%delivery_date_remove%&        "from incoming messages"
14979 .row &%envelope_to_remove%&          "from incoming messages"
14980 .row &%extract_addresses_remove_arguments%& "affects &%-t%& processing"
14981 .row &%headers_charset%&             "default for translations"
14982 .row &%qualify_domain%&              "default for senders"
14983 .row &%qualify_recipient%&           "default for recipients"
14984 .row &%return_path_remove%&          "from incoming messages"
14985 .row &%strip_excess_angle_brackets%& "in addresses"
14986 .row &%strip_trailing_dot%&          "at end of addresses"
14987 .row &%untrusted_set_sender%&        "untrusted can set envelope sender"
14988 .endtable
14989
14990
14991
14992 .section "System filter" "SECID115"
14993 .table2
14994 .row &%system_filter%&               "locate system filter"
14995 .row &%system_filter_directory_transport%& "transport for delivery to a &&&
14996                                             directory"
14997 .row &%system_filter_file_transport%& "transport for delivery to a file"
14998 .row &%system_filter_group%&         "group for filter running"
14999 .row &%system_filter_pipe_transport%& "transport for delivery to a pipe"
15000 .row &%system_filter_reply_transport%& "transport for autoreply delivery"
15001 .row &%system_filter_user%&          "user for filter running"
15002 .endtable
15003
15004
15005
15006 .section "Routing and delivery" "SECID116"
15007 .table2
15008 .row &%disable_ipv6%&                "do no IPv6 processing"
15009 .row &%dns_again_means_nonexist%&    "for broken domains"
15010 .row &%dns_check_names_pattern%&     "pre-DNS syntax check"
15011 .row &%dns_dnssec_ok%&               "parameter for resolver"
15012 .row &%dns_ipv4_lookup%&             "only v4 lookup for these domains"
15013 .row &%dns_retrans%&                 "parameter for resolver"
15014 .row &%dns_retry%&                   "parameter for resolver"
15015 .row &%dns_trust_aa%&                "DNS zones trusted as authentic"
15016 .row &%dns_use_edns0%&               "parameter for resolver"
15017 .row &%hold_domains%&                "hold delivery for these domains"
15018 .row &%local_interfaces%&            "for routing checks"
15019 .row &%queue_domains%&               "no immediate delivery for these"
15020 .row &%queue_fast_ramp%&             "parallel delivery with 2-phase queue run"
15021 .row &%queue_only%&                  "no immediate delivery at all"
15022 .row &%queue_only_file%&             "no immediate delivery if file exists"
15023 .row &%queue_only_load%&             "no immediate delivery if load is high"
15024 .row &%queue_only_load_latch%&       "don't re-evaluate load for each message"
15025 .row &%queue_only_override%&         "allow command line to override"
15026 .row &%queue_run_in_order%&          "order of arrival"
15027 .row &%queue_run_max%&               "of simultaneous queue runners"
15028 .row &%queue_smtp_domains%&          "no immediate SMTP delivery for these"
15029 .row &%remote_max_parallel%&         "parallel SMTP delivery per message"
15030 .row &%remote_sort_domains%&         "order of remote deliveries"
15031 .row &%retry_data_expire%&           "timeout for retry data"
15032 .row &%retry_interval_max%&          "safety net for retry rules"
15033 .endtable
15034
15035
15036
15037 .section "Bounce and warning messages" "SECID117"
15038 .table2
15039 .row &%bounce_message_file%&         "content of bounce"
15040 .row &%bounce_message_text%&         "content of bounce"
15041 .row &%bounce_return_body%&          "include body if returning message"
15042 .row &%bounce_return_linesize_limit%& "limit on returned message line length"
15043 .row &%bounce_return_message%&       "include original message in bounce"
15044 .row &%bounce_return_size_limit%&    "limit on returned message"
15045 .row &%bounce_sender_authentication%& "send authenticated sender with bounce"
15046 .row &%dsn_from%&                    "set &'From:'& contents in bounces"
15047 .row &%errors_copy%&                 "copy bounce messages"
15048 .row &%errors_reply_to%&             "&'Reply-to:'& in bounces"
15049 .row &%delay_warning%&               "time schedule"
15050 .row &%delay_warning_condition%&     "condition for warning messages"
15051 .row &%ignore_bounce_errors_after%&  "discard undeliverable bounces"
15052 .row &%smtp_return_error_details%&   "give detail on rejections"
15053 .row &%warn_message_file%&           "content of warning message"
15054 .endtable
15055
15056
15057
15058 .section "Alphabetical list of main options" "SECTalomo"
15059 Those options that undergo string expansion before use are marked with
15060 &dagger;.
15061
15062 .option accept_8bitmime main boolean true
15063 .cindex "8BITMIME"
15064 .cindex "8-bit characters"
15065 .cindex "log" "selectors"
15066 .cindex "log" "8BITMIME"
15067 .cindex "ESMTP extensions" 8BITMIME
15068 This option causes Exim to send 8BITMIME in its response to an SMTP
15069 EHLO command, and to accept the BODY= parameter on MAIL commands.
15070 However, though Exim is 8-bit clean, it is not a protocol converter, and it
15071 takes no steps to do anything special with messages received by this route.
15072
15073 Historically Exim kept this option off by default, but the maintainers
15074 feel that in today's Internet, this causes more problems than it solves.
15075 It now defaults to true.
15076 A more detailed analysis of the issues is provided by Dan Bernstein:
15077 .display
15078 &url(https://cr.yp.to/smtp/8bitmime.html)
15079 .endd
15080
15081 To log received 8BITMIME status use
15082 .code
15083 log_selector = +8bitmime
15084 .endd
15085
15086 .option acl_not_smtp main string&!! unset
15087 .cindex "&ACL;" "for non-SMTP messages"
15088 .cindex "non-SMTP messages" "ACLs for"
15089 This option defines the ACL that is run when a non-SMTP message has been
15090 read and is on the point of being accepted. See chapter &<<CHAPACL>>& for
15091 further details.
15092
15093 .option acl_not_smtp_mime main string&!! unset
15094 This option defines the ACL that is run for individual MIME parts of non-SMTP
15095 messages. It operates in exactly the same way as &%acl_smtp_mime%& operates for
15096 SMTP messages.
15097
15098 .option acl_not_smtp_start main string&!! unset
15099 .cindex "&ACL;" "at start of non-SMTP message"
15100 .cindex "non-SMTP messages" "ACLs for"
15101 This option defines the ACL that is run before Exim starts reading a
15102 non-SMTP message. See chapter &<<CHAPACL>>& for further details.
15103
15104 .option acl_smtp_auth main string&!! unset
15105 .cindex "&ACL;" "setting up for SMTP commands"
15106 .cindex "AUTH" "ACL for"
15107 This option defines the ACL that is run when an SMTP AUTH command is
15108 received. See chapter &<<CHAPACL>>& for further details.
15109
15110 .option acl_smtp_connect main string&!! unset
15111 .cindex "&ACL;" "on SMTP connection"
15112 This option defines the ACL that is run when an SMTP connection is received.
15113 See chapter &<<CHAPACL>>& for further details.
15114
15115 .option acl_smtp_data main string&!! unset
15116 .cindex "DATA" "ACL for"
15117 This option defines the ACL that is run after an SMTP DATA command has been
15118 processed and the message itself has been received, but before the final
15119 acknowledgment is sent. See chapter &<<CHAPACL>>& for further details.
15120
15121 .option acl_smtp_data_prdr main string&!! accept
15122 .cindex "PRDR" "ACL for"
15123 .cindex "DATA" "PRDR ACL for"
15124 .cindex "&ACL;" "PRDR-related"
15125 .cindex "&ACL;" "per-user data processing"
15126 This option defines the ACL that,
15127 if the PRDR feature has been negotiated,
15128 is run for each recipient after an SMTP DATA command has been
15129 processed and the message itself has been received, but before the
15130 acknowledgment is sent. See chapter &<<CHAPACL>>& for further details.
15131
15132 .option acl_smtp_dkim main string&!! unset
15133 .cindex DKIM "ACL for"
15134 This option defines the ACL that is run for each DKIM signature
15135 (by default, or as specified in the dkim_verify_signers option)
15136 of a received message.
15137 See section &<<SECDKIMVFY>>& for further details.
15138
15139 .option acl_smtp_etrn main string&!! unset
15140 .cindex "ETRN" "ACL for"
15141 This option defines the ACL that is run when an SMTP ETRN command is
15142 received. See chapter &<<CHAPACL>>& for further details.
15143
15144 .option acl_smtp_expn main string&!! unset
15145 .cindex "EXPN" "ACL for"
15146 This option defines the ACL that is run when an SMTP EXPN command is
15147 received. See chapter &<<CHAPACL>>& for further details.
15148
15149 .option acl_smtp_helo main string&!! unset
15150 .cindex "EHLO" "ACL for"
15151 .cindex "HELO" "ACL for"
15152 This option defines the ACL that is run when an SMTP EHLO or HELO
15153 command is received. See chapter &<<CHAPACL>>& for further details.
15154
15155
15156 .option acl_smtp_mail main string&!! unset
15157 .cindex "MAIL" "ACL for"
15158 This option defines the ACL that is run when an SMTP MAIL command is
15159 received. See chapter &<<CHAPACL>>& for further details.
15160
15161 .option acl_smtp_mailauth main string&!! unset
15162 .cindex "AUTH" "on MAIL command"
15163 This option defines the ACL that is run when there is an AUTH parameter on
15164 a MAIL command. See chapter &<<CHAPACL>>& for details of ACLs, and chapter
15165 &<<CHAPSMTPAUTH>>& for details of authentication.
15166
15167 .option acl_smtp_mime main string&!! unset
15168 .cindex "MIME content scanning" "ACL for"
15169 This option is available when Exim is built with the content-scanning
15170 extension. It defines the ACL that is run for each MIME part in a message. See
15171 section &<<SECTscanmimepart>>& for details.
15172
15173 .option acl_smtp_notquit main string&!! unset
15174 .cindex "not-QUIT, ACL for"
15175 This option defines the ACL that is run when an SMTP session
15176 ends without a QUIT command being received.
15177 See chapter &<<CHAPACL>>& for further details.
15178
15179 .option acl_smtp_predata main string&!! unset
15180 This option defines the ACL that is run when an SMTP DATA command is
15181 received, before the message itself is received. See chapter &<<CHAPACL>>& for
15182 further details.
15183
15184 .option acl_smtp_quit main string&!! unset
15185 .cindex "QUIT, ACL for"
15186 This option defines the ACL that is run when an SMTP QUIT command is
15187 received. See chapter &<<CHAPACL>>& for further details.
15188
15189 .option acl_smtp_rcpt main string&!! unset
15190 .cindex "RCPT" "ACL for"
15191 This option defines the ACL that is run when an SMTP RCPT command is
15192 received. See chapter &<<CHAPACL>>& for further details.
15193
15194 .option acl_smtp_starttls main string&!! unset
15195 .cindex "STARTTLS, ACL for"
15196 This option defines the ACL that is run when an SMTP STARTTLS command is
15197 received. See chapter &<<CHAPACL>>& for further details.
15198
15199 .option acl_smtp_vrfy main string&!! unset
15200 .cindex "VRFY" "ACL for"
15201 This option defines the ACL that is run when an SMTP VRFY command is
15202 received. See chapter &<<CHAPACL>>& for further details.
15203
15204 .option add_environment main "string list" empty
15205 .cindex "environment" "set values"
15206 This option adds individual environment variables that the
15207 currently linked libraries and programs in child processes may use.
15208 Each list element should be of the form &"name=value"&.
15209
15210 See &<<SECTpipeenv>>& for the environment of &(pipe)& transports.
15211
15212 .option admin_groups main "string list&!!" unset
15213 .cindex "admin user"
15214 This option is expanded just once, at the start of Exim's processing. If the
15215 current group or any of the supplementary groups of an Exim caller is in this
15216 colon-separated list, the caller has admin privileges. If all your system
15217 programmers are in a specific group, for example, you can give them all Exim
15218 admin privileges by putting that group in &%admin_groups%&. However, this does
15219 not permit them to read Exim's spool files (whose group owner is the Exim gid).
15220 To permit this, you have to add individuals to the Exim group.
15221
15222 .option allow_domain_literals main boolean false
15223 .cindex "domain literal"
15224 If this option is set, the RFC 2822 domain literal format is permitted in
15225 email addresses. The option is not set by default, because the domain literal
15226 format is not normally required these days, and few people know about it. It
15227 has, however, been exploited by mail abusers.
15228
15229 Unfortunately, it seems that some DNS black list maintainers are using this
15230 format to report black listing to postmasters. If you want to accept messages
15231 addressed to your hosts by IP address, you need to set
15232 &%allow_domain_literals%& true, and also to add &`@[]`& to the list of local
15233 domains (defined in the named domain list &%local_domains%& in the default
15234 configuration). This &"magic string"& matches the domain literal form of all
15235 the local host's IP addresses.
15236
15237 .option allow_mx_to_ip main boolean false
15238 .cindex "MX record" "pointing to IP address"
15239 It appears that more and more DNS zone administrators are breaking the rules
15240 and putting domain names that look like IP addresses on the right hand side of
15241 MX records. Exim follows the rules and rejects this, giving an error message
15242 that explains the misconfiguration. However, some other MTAs support this
15243 practice, so to avoid &"Why can't Exim do this?"& complaints,
15244 &%allow_mx_to_ip%& exists, in order to enable this heinous activity. It is not
15245 recommended, except when you have no other choice.
15246
15247 .option allow_utf8_domains main boolean false
15248 .cindex "domain" "UTF-8 characters in"
15249 .cindex "UTF-8" "in domain name"
15250 Lots of discussion is going on about internationalized domain names. One
15251 camp is strongly in favour of just using UTF-8 characters, and it seems
15252 that at least two other MTAs permit this.
15253 This option allows Exim users to experiment if they wish.
15254
15255 If it is set true, Exim's domain parsing function allows valid
15256 UTF-8 multicharacters to appear in domain name components, in addition to
15257 letters, digits, and hyphens.
15258
15259 If Exim is built with internationalization support
15260 and the SMTPUTF8 ESMTP option is in use (see chapter &<<CHAPi18n>>&)
15261 this option can be left as default.
15262 Without that,
15263 if you want to look up such domain names in the DNS, you must also
15264 adjust the value of &%dns_check_names_pattern%& to match the extended form. A
15265 suitable setting is:
15266 .code
15267 dns_check_names_pattern = (?i)^(?>(?(1)\.|())[a-z0-9\xc0-\xff]\
15268   (?>[-a-z0-9\x80-\xff]*[a-z0-9\x80-\xbf])?)+$
15269 .endd
15270 Alternatively, you can just disable this feature by setting
15271 .code
15272 dns_check_names_pattern =
15273 .endd
15274 That is, set the option to an empty string so that no check is done.
15275
15276
15277 .option auth_advertise_hosts main "host list&!!" *
15278 .cindex "authentication" "advertising"
15279 .cindex "AUTH" "advertising"
15280 .cindex "ESMTP extensions" AUTH
15281 If any server authentication mechanisms are configured, Exim advertises them in
15282 response to an EHLO command only if the calling host matches this list.
15283 Otherwise, Exim does not advertise AUTH.
15284 Exim does not accept AUTH commands from clients to which it has not
15285 advertised the availability of AUTH. The advertising of individual
15286 authentication mechanisms can be controlled by the use of the
15287 &%server_advertise_condition%& generic authenticator option on the individual
15288 authenticators. See chapter &<<CHAPSMTPAUTH>>& for further details.
15289
15290 Certain mail clients (for example, Netscape) require the user to provide a name
15291 and password for authentication if AUTH is advertised, even though it may
15292 not be needed (the host may accept messages from hosts on its local LAN without
15293 authentication, for example). The &%auth_advertise_hosts%& option can be used
15294 to make these clients more friendly by excluding them from the set of hosts to
15295 which Exim advertises AUTH.
15296
15297 .cindex "AUTH" "advertising when encrypted"
15298 If you want to advertise the availability of AUTH only when the connection
15299 is encrypted using TLS, you can make use of the fact that the value of this
15300 option is expanded, with a setting like this:
15301 .code
15302 auth_advertise_hosts = ${if eq{$tls_in_cipher}{}{}{*}}
15303 .endd
15304 .vindex "&$tls_in_cipher$&"
15305 If &$tls_in_cipher$& is empty, the session is not encrypted, and the result of
15306 the expansion is empty, thus matching no hosts. Otherwise, the result of the
15307 expansion is *, which matches all hosts.
15308
15309
15310 .option auto_thaw main time 0s
15311 .cindex "thawing messages"
15312 .cindex "unfreezing messages"
15313 If this option is set to a time greater than zero, a queue runner will try a
15314 new delivery attempt on any frozen message, other than a bounce message, if
15315 this much time has passed since it was frozen. This may result in the message
15316 being re-frozen if nothing has changed since the last attempt. It is a way of
15317 saying &"keep on trying, even though there are big problems"&.
15318
15319 &*Note*&: This is an old option, which predates &%timeout_frozen_after%& and
15320 &%ignore_bounce_errors_after%&. It is retained for compatibility, but it is not
15321 thought to be very useful any more, and its use should probably be avoided.
15322
15323
15324 .option av_scanner main string "see below"
15325 This option is available if Exim is built with the content-scanning extension.
15326 It specifies which anti-virus scanner to use. The default value is:
15327 .code
15328 sophie:/var/run/sophie
15329 .endd
15330 If the value of &%av_scanner%& starts with a dollar character, it is expanded
15331 before use. See section &<<SECTscanvirus>>& for further details.
15332
15333
15334 .option bi_command main string unset
15335 .oindex "&%-bi%&"
15336 This option supplies the name of a command that is run when Exim is called with
15337 the &%-bi%& option (see chapter &<<CHAPcommandline>>&). The string value is
15338 just the command name, it is not a complete command line. If an argument is
15339 required, it must come from the &%-oA%& command line option.
15340
15341
15342 .option bounce_message_file main string&!! unset
15343 .cindex "bounce message" "customizing"
15344 .cindex "customizing" "bounce message"
15345 This option defines a template file containing paragraphs of text to be used
15346 for constructing bounce messages.  Details of the file's contents are given in
15347 chapter &<<CHAPemsgcust>>&.
15348 .cindex bounce_message_file "tainted data"
15349 The option is expanded to give the file path, which must be
15350 absolute and untainted.
15351 See also &%warn_message_file%&.
15352
15353
15354 .option bounce_message_text main string unset
15355 When this option is set, its contents are included in the default bounce
15356 message immediately after &"This message was created automatically by mail
15357 delivery software."& It is not used if &%bounce_message_file%& is set.
15358
15359 .option bounce_return_body main boolean true
15360 .cindex "bounce message" "including body"
15361 This option controls whether the body of an incoming message is included in a
15362 bounce message when &%bounce_return_message%& is true. The default setting
15363 causes the entire message, both header and body, to be returned (subject to the
15364 value of &%bounce_return_size_limit%&). If this option is false, only the
15365 message header is included. In the case of a non-SMTP message containing an
15366 error that is detected during reception, only those header lines preceding the
15367 point at which the error was detected are returned.
15368 .cindex "bounce message" "including original"
15369
15370 .option bounce_return_linesize_limit main integer 998
15371 .cindex "size" "of bounce lines, limit"
15372 .cindex "bounce message" "line length limit"
15373 .cindex "limit" "bounce message line length"
15374 This option sets a limit in bytes on the line length of messages
15375 that are returned to senders due to delivery problems,
15376 when &%bounce_return_message%& is true.
15377 The default value corresponds to RFC limits.
15378 If the message being returned has lines longer than this value it is
15379 treated as if the &%bounce_return_size_limit%& (below) restriction was exceeded.
15380
15381 The option also applies to bounces returned when an error is detected
15382 during reception of a message.
15383 In this case lines from the original are truncated.
15384
15385 The option does not apply to messages generated by an &(autoreply)& transport.
15386
15387
15388 .option bounce_return_message main boolean true
15389 If this option is set false, none of the original message is included in
15390 bounce messages generated by Exim. See also &%bounce_return_size_limit%& and
15391 &%bounce_return_body%&.
15392
15393
15394 .option bounce_return_size_limit main integer 100K
15395 .cindex "size" "of bounce, limit"
15396 .cindex "bounce message" "size limit"
15397 .cindex "limit" "bounce message size"
15398 This option sets a limit in bytes on the size of messages that are returned to
15399 senders as part of bounce messages when &%bounce_return_message%& is true. The
15400 limit should be less than the value of the global &%message_size_limit%& and of
15401 any &%message_size_limit%& settings on transports, to allow for the bounce text
15402 that Exim generates. If this option is set to zero there is no limit.
15403
15404 When the body of any message that is to be included in a bounce message is
15405 greater than the limit, it is truncated, and a comment pointing this out is
15406 added at the top. The actual cutoff may be greater than the value given, owing
15407 to the use of buffering for transferring the message in chunks (typically 8K in
15408 size). The idea is to save bandwidth on those undeliverable 15-megabyte
15409 messages.
15410
15411 .option bounce_sender_authentication main string unset
15412 .cindex "bounce message" "sender authentication"
15413 .cindex "authentication" "bounce message"
15414 .cindex "AUTH" "on bounce message"
15415 This option provides an authenticated sender address that is sent with any
15416 bounce messages generated by Exim that are sent over an authenticated SMTP
15417 connection. A typical setting might be:
15418 .code
15419 bounce_sender_authentication = mailer-daemon@my.domain.example
15420 .endd
15421 which would cause bounce messages to be sent using the SMTP command:
15422 .code
15423 MAIL FROM:<> AUTH=mailer-daemon@my.domain.example
15424 .endd
15425 The value of &%bounce_sender_authentication%& must always be a complete email
15426 address.
15427
15428 .option callout_domain_negative_expire main time 3h
15429 .cindex "caching" "callout timeouts"
15430 .cindex "callout" "caching timeouts"
15431 This option specifies the expiry time for negative callout cache data for a
15432 domain. See section &<<SECTcallver>>& for details of callout verification, and
15433 section &<<SECTcallvercache>>& for details of the caching.
15434
15435
15436 .option callout_domain_positive_expire main time 7d
15437 This option specifies the expiry time for positive callout cache data for a
15438 domain. See section &<<SECTcallver>>& for details of callout verification, and
15439 section &<<SECTcallvercache>>& for details of the caching.
15440
15441
15442 .option callout_negative_expire main time 2h
15443 This option specifies the expiry time for negative callout cache data for an
15444 address. See section &<<SECTcallver>>& for details of callout verification, and
15445 section &<<SECTcallvercache>>& for details of the caching.
15446
15447
15448 .option callout_positive_expire main time 24h
15449 This option specifies the expiry time for positive callout cache data for an
15450 address. See section &<<SECTcallver>>& for details of callout verification, and
15451 section &<<SECTcallvercache>>& for details of the caching.
15452
15453
15454 .option callout_random_local_part main string&!! "see below"
15455 This option defines the &"random"& local part that can be used as part of
15456 callout verification. The default value is
15457 .code
15458 $primary_hostname-$tod_epoch-testing
15459 .endd
15460 See section &<<CALLaddparcall>>& for details of how this value is used.
15461
15462
15463 .options check_log_inodes main integer 100 &&&
15464          check_log_space main integer 10M
15465 See &%check_spool_space%& below.
15466
15467 .oindex "&%check_rfc2047_length%&"
15468 .cindex "RFC 2047" "disabling length check"
15469 .option check_rfc2047_length main boolean true
15470 RFC 2047 defines a way of encoding non-ASCII characters in headers using a
15471 system of &"encoded words"&. The RFC specifies a maximum length for an encoded
15472 word; strings to be encoded that exceed this length are supposed to use
15473 multiple encoded words. By default, Exim does not recognize encoded words that
15474 exceed the maximum length. However, it seems that some software, in violation
15475 of the RFC, generates overlong encoded words. If &%check_rfc2047_length%& is
15476 set false, Exim recognizes encoded words of any length.
15477
15478
15479 .options check_spool_inodes main integer 100 &&&
15480          check_spool_space main integer 10M
15481 .cindex "checking disk space"
15482 .cindex "disk space, checking"
15483 .cindex "spool directory" "checking space"
15484 The four &%check_...%& options allow for checking of disk resources before a
15485 message is accepted.
15486
15487 .vindex "&$log_inodes$&"
15488 .vindex "&$log_space$&"
15489 .vindex "&$spool_inodes$&"
15490 .vindex "&$spool_space$&"
15491 When any of these options are nonzero, they apply to all incoming messages. If you
15492 want to apply different checks to different kinds of message, you can do so by
15493 testing the variables &$log_inodes$&, &$log_space$&, &$spool_inodes$&, and
15494 &$spool_space$& in an ACL with appropriate additional conditions.
15495
15496
15497 &%check_spool_space%& and &%check_spool_inodes%& check the spool partition if
15498 either value is greater than zero, for example:
15499 .code
15500 check_spool_space = 100M
15501 check_spool_inodes = 100
15502 .endd
15503 The spool partition is the one that contains the directory defined by
15504 SPOOL_DIRECTORY in &_Local/Makefile_&. It is used for holding messages in
15505 transit.
15506
15507 &%check_log_space%& and &%check_log_inodes%&  check the partition in which log
15508 files are written if either is greater than zero. These should be set only if
15509 &%log_file_path%& and &%spool_directory%& refer to different partitions.
15510
15511 If there is less space or fewer inodes than requested, Exim refuses to accept
15512 incoming mail. In the case of SMTP input this is done by giving a 452 temporary
15513 error response to the MAIL command. If ESMTP is in use and there was a
15514 SIZE parameter on the MAIL command, its value is added to the
15515 &%check_spool_space%& value, and the check is performed even if
15516 &%check_spool_space%& is zero, unless &%no_smtp_check_spool_space%& is set.
15517
15518 The values for &%check_spool_space%& and &%check_log_space%& are held as a
15519 number of kilobytes (though specified in bytes).
15520 If a non-multiple of 1024 is specified, it is rounded up.
15521
15522 For non-SMTP input and for batched SMTP input, the test is done at start-up; on
15523 failure a message is written to stderr and Exim exits with a non-zero code, as
15524 it obviously cannot send an error message of any kind.
15525
15526 There is a slight performance penalty for these checks.
15527 Versions of Exim preceding 4.88 had these disabled by default;
15528 high-rate installations confident they will never run out of resources
15529 may wish to deliberately disable them.
15530
15531 .option chunking_advertise_hosts main "host list&!!" *
15532 .cindex CHUNKING advertisement
15533 .cindex "RFC 3030" "CHUNKING"
15534 .cindex "ESMTP extensions" CHUNKING
15535 The CHUNKING extension (RFC3030) will be advertised in the EHLO message to
15536 these hosts.
15537 Hosts may use the BDAT command as an alternate to DATA.
15538
15539 .option commandline_checks_require_admin main boolean &`false`&
15540 .cindex "restricting access to features"
15541 This option restricts various basic checking features to require an
15542 administrative user.
15543 This affects most of the &%-b*%& options, such as &%-be%&.
15544
15545 .option debug_store main boolean &`false`&
15546 .cindex debugging "memory corruption"
15547 .cindex memory debugging
15548 This option, when true, enables extra checking in Exim's internal memory
15549 management.  For use when a memory corruption issue is being investigated,
15550 it should normally be left as default.
15551
15552 .option daemon_smtp_ports main string &`smtp`&
15553 .cindex "port" "for daemon"
15554 .cindex "TCP/IP" "setting listening ports"
15555 This option specifies one or more default SMTP ports on which the Exim daemon
15556 listens. See chapter &<<CHAPinterfaces>>& for details of how it is used. For
15557 backward compatibility, &%daemon_smtp_port%& (singular) is a synonym.
15558
15559 .options daemon_startup_retries main integer 9 &&&
15560          daemon_startup_sleep main time 30s
15561 .cindex "daemon startup, retrying"
15562 These options control the retrying done by
15563 the daemon at startup when it cannot immediately bind a listening socket
15564 (typically because the socket is already in use): &%daemon_startup_retries%&
15565 defines the number of retries after the first failure, and
15566 &%daemon_startup_sleep%& defines the length of time to wait between retries.
15567
15568 .option delay_warning main "time list" 24h
15569 .cindex "warning of delay"
15570 .cindex "delay warning, specifying"
15571 .cindex "queue" "delay warning"
15572 When a message is delayed, Exim sends a warning message to the sender at
15573 intervals specified by this option. The data is a colon-separated list of times
15574 after which to send warning messages. If the value of the option is an empty
15575 string or a zero time, no warnings are sent. Up to 10 times may be given. If a
15576 message has been in the queue for longer than the last time, the last interval
15577 between the times is used to compute subsequent warning times. For example,
15578 with
15579 .code
15580 delay_warning = 4h:8h:24h
15581 .endd
15582 the first message is sent after 4 hours, the second after 8 hours, and
15583 the third one after 24 hours. After that, messages are sent every 16 hours,
15584 because that is the interval between the last two times on the list. If you set
15585 just one time, it specifies the repeat interval. For example, with:
15586 .code
15587 delay_warning = 6h
15588 .endd
15589 messages are repeated every six hours. To stop warnings after a given time, set
15590 a very large time at the end of the list. For example:
15591 .code
15592 delay_warning = 2h:12h:99d
15593 .endd
15594 Note that the option is only evaluated at the time a delivery attempt fails,
15595 which depends on retry and queue-runner configuration.
15596 Typically retries will be configured more frequently than warning messages.
15597
15598 .option delay_warning_condition main string&!! "see below"
15599 .vindex "&$domain$&"
15600 The string is expanded at the time a warning message might be sent. If all the
15601 deferred addresses have the same domain, it is set in &$domain$& during the
15602 expansion. Otherwise &$domain$& is empty. If the result of the expansion is a
15603 forced failure, an empty string, or a string matching any of &"0"&, &"no"& or
15604 &"false"& (the comparison being done caselessly) then the warning message is
15605 not sent. The default is:
15606 .code
15607 delay_warning_condition = ${if or {\
15608   { !eq{$h_list-id:$h_list-post:$h_list-subscribe:}{} }\
15609   { match{$h_precedence:}{(?i)bulk|list|junk} }\
15610   { match{$h_auto-submitted:}{(?i)auto-generated|auto-replied} }\
15611   } {no}{yes}}
15612 .endd
15613 This suppresses the sending of warnings for messages that contain &'List-ID:'&,
15614 &'List-Post:'&, or &'List-Subscribe:'& headers, or have &"bulk"&, &"list"& or
15615 &"junk"& in a &'Precedence:'& header, or have &"auto-generated"& or
15616 &"auto-replied"& in an &'Auto-Submitted:'& header.
15617
15618 .option deliver_drop_privilege main boolean false
15619 .cindex "unprivileged delivery"
15620 .cindex "delivery" "unprivileged"
15621 If this option is set true, Exim drops its root privilege at the start of a
15622 delivery process, and runs as the Exim user throughout. This severely restricts
15623 the kinds of local delivery that are possible, but is viable in certain types
15624 of configuration. There is a discussion about the use of root privilege in
15625 chapter &<<CHAPsecurity>>&.
15626
15627 .option deliver_queue_load_max main fixed-point unset
15628 .cindex "load average"
15629 .cindex "queue runner" "abandoning"
15630 When this option is set, a queue run is abandoned if the system load average
15631 becomes greater than the value of the option. The option has no effect on
15632 ancient operating systems on which Exim cannot determine the load average.
15633 See also &%queue_only_load%& and &%smtp_load_reserve%&.
15634
15635
15636 .option delivery_date_remove main boolean true
15637 .cindex "&'Delivery-date:'& header line"
15638 Exim's transports have an option for adding a &'Delivery-date:'& header to a
15639 message when it is delivered, in exactly the same way as &'Return-path:'& is
15640 handled. &'Delivery-date:'& records the actual time of delivery. Such headers
15641 should not be present in incoming messages, and this option causes them to be
15642 removed at the time the message is received, to avoid any problems that might
15643 occur when a delivered message is subsequently sent on to some other recipient.
15644
15645 .option disable_fsync main boolean false
15646 .cindex "&[fsync()]&, disabling"
15647 This option is available only if Exim was built with the compile-time option
15648 ENABLE_DISABLE_FSYNC. When this is not set, a reference to &%disable_fsync%& in
15649 a runtime configuration generates an &"unknown option"& error. You should not
15650 build Exim with ENABLE_DISABLE_FSYNC or set &%disable_fsync%& unless you
15651 really, really, really understand what you are doing. &'No pre-compiled
15652 distributions of Exim should ever make this option available.'&
15653
15654 When &%disable_fsync%& is set true, Exim no longer calls &[fsync()]& to force
15655 updated files' data to be written to disc before continuing. Unexpected events
15656 such as crashes and power outages may cause data to be lost or scrambled.
15657 Here be Dragons. &*Beware.*&
15658
15659
15660 .option disable_ipv6 main boolean false
15661 .cindex "IPv6" "disabling"
15662 If this option is set true, even if the Exim binary has IPv6 support, no IPv6
15663 activities take place. AAAA records are never looked up, and any IPv6 addresses
15664 that are listed in &%local_interfaces%&, data for the &%manualroute%& router,
15665 etc. are ignored. If IP literals are enabled, the &(ipliteral)& router declines
15666 to handle IPv6 literal addresses.
15667
15668
15669 .option dkim_verify_hashes main "string list" "sha256 : sha512"
15670 .cindex DKIM "selecting signature algorithms"
15671 This option gives a list of hash types which are acceptable in signatures,
15672 and an order of processing.
15673 Signatures with algorithms not in the list will be ignored.
15674
15675 Acceptable values include:
15676 .code
15677 sha1
15678 sha256
15679 sha512
15680 .endd
15681
15682 Note that the acceptance of sha1 violates RFC 8301.
15683
15684 .option dkim_verify_keytypes main "string list" "ed25519 : rsa"
15685 This option gives a list of key types which are acceptable in signatures,
15686 and an order of processing.
15687 Signatures with algorithms not in the list will be ignored.
15688
15689
15690 .option dkim_verify_min_keysizes main "string list" "rsa=1024 ed25519=250"
15691 This option gives a list of key sizes which are acceptable in signatures.
15692 The list is keyed by the algorithm type for the key; the values are in bits.
15693 Signatures with keys smaller than given by this option will fail verification.
15694
15695 The default enforces the RFC 8301 minimum key size for RSA signatures.
15696
15697 .option dkim_verify_minimal main boolean false
15698 If set to true, verification of signatures will terminate after the
15699 first success.
15700
15701 .option dkim_verify_signers main "domain list&!!" $dkim_signers
15702 .cindex DKIM "controlling calls to the ACL"
15703 This option gives a list of DKIM domains for which the DKIM ACL is run.
15704 It is expanded after the message is received; by default it runs
15705 the ACL once for each signature in the message.
15706 See section &<<SECDKIMVFY>>&.
15707
15708
15709 .option dmarc_forensic_sender main string&!! unset
15710 .option dmarc_history_file main string unset
15711 .option dmarc_tld_file main string unset
15712 .cindex DMARC "main section options"
15713 These options control DMARC processing.
15714 See section &<<SECDMARC>>& for details.
15715
15716
15717 .option dns_again_means_nonexist main "domain list&!!" unset
15718 .cindex "DNS" "&""try again""& response; overriding"
15719 DNS lookups give a &"try again"& response for the DNS errors
15720 &"non-authoritative host not found"& and &"SERVERFAIL"&. This can cause Exim to
15721 keep trying to deliver a message, or to give repeated temporary errors to
15722 incoming mail. Sometimes the effect is caused by a badly set up name server and
15723 may persist for a long time. If a domain which exhibits this problem matches
15724 anything in &%dns_again_means_nonexist%&, it is treated as if it did not exist.
15725 This option should be used with care. You can make it apply to reverse lookups
15726 by a setting such as this:
15727 .code
15728 dns_again_means_nonexist = *.in-addr.arpa
15729 .endd
15730 This option applies to all DNS lookups that Exim does,
15731 except for TLSA lookups (where knowing about such failures
15732 is security-relevant).
15733 It also applies when the
15734 &[gethostbyname()]& or &[getipnodebyname()]& functions give temporary errors,
15735 since these are most likely to be caused by DNS lookup problems. The
15736 &(dnslookup)& router has some options of its own for controlling what happens
15737 when lookups for MX or SRV records give temporary errors. These more specific
15738 options are applied after this global option.
15739
15740 .option dns_check_names_pattern main string "see below"
15741 .cindex "DNS" "pre-check of name syntax"
15742 When this option is set to a non-empty string, it causes Exim to check domain
15743 names for characters that are not allowed in host names before handing them to
15744 the DNS resolver, because some resolvers give temporary errors for names that
15745 contain unusual characters. If a domain name contains any unwanted characters,
15746 a &"not found"& result is forced, and the resolver is not called. The check is
15747 done by matching the domain name against a regular expression, which is the
15748 value of this option. The default pattern is
15749 .code
15750 dns_check_names_pattern = \
15751   (?i)^(?>(?(1)\.|())[^\W_](?>[a-z0-9/-]*[^\W_])?)+$
15752 .endd
15753 which permits only letters, digits, slashes, and hyphens in components, but
15754 they must start and end with a letter or digit. Slashes are not, in fact,
15755 permitted in host names, but they are found in certain NS records (which can be
15756 accessed in Exim by using a &%dnsdb%& lookup). If you set
15757 &%allow_utf8_domains%&, you must modify this pattern, or set the option to an
15758 empty string.
15759
15760 .option dns_csa_search_limit main integer 5
15761 This option controls the depth of parental searching for CSA SRV records in the
15762 DNS, as described in more detail in section &<<SECTverifyCSA>>&.
15763
15764 .option dns_csa_use_reverse main boolean true
15765 This option controls whether or not an IP address, given as a CSA domain, is
15766 reversed and looked up in the reverse DNS, as described in more detail in
15767 section &<<SECTverifyCSA>>&.
15768
15769 .option dns_cname_loops main integer 1
15770 .cindex DNS "CNAME following"
15771 This option controls the following of CNAME chains, needed if the resolver does
15772 not do it internally.
15773 As of 2018 most should, and the default can be left.
15774 If you have an ancient one, a value of 10 is likely needed.
15775
15776 The default value of one CNAME-follow is needed
15777 thanks to the observed return for an MX request,
15778 given no MX presence but a CNAME to an A, of the CNAME.
15779
15780
15781 .option dns_dnssec_ok main integer -1
15782 .cindex "DNS" "resolver options"
15783 .cindex "DNS" "DNSSEC"
15784 If this option is set to a non-negative number then Exim will initialise the
15785 DNS resolver library to either use or not use DNSSEC, overriding the system
15786 default. A value of 0 coerces DNSSEC off, a value of 1 coerces DNSSEC on.
15787
15788 If the resolver library does not support DNSSEC then this option has no effect.
15789
15790 On Linux with glibc 2.31 or newer this is insufficient, the resolver library
15791 will default to stripping out a successful validation status.
15792 This will break a previously working Exim installation.
15793 Provided that you do trust the resolver (ie, is on localhost) you can tell
15794 glibc to pass through any successful validation with a new option in
15795 &_/etc/resolv.conf_&:
15796 .code
15797 options trust-ad
15798 .endd
15799
15800
15801 .option dns_ipv4_lookup main "domain list&!!" unset
15802 .cindex "IPv6" "DNS lookup for AAAA records"
15803 .cindex "DNS" "IPv6 lookup for AAAA records"
15804 .cindex DNS "IPv6 disabling"
15805 When Exim is compiled with IPv6 support and &%disable_ipv6%& is not set, it
15806 looks for IPv6 address records (AAAA records) as well as IPv4 address records
15807 (A records) when trying to find IP addresses for hosts, unless the host's
15808 domain matches this list.
15809
15810 This is a fudge to help with name servers that give big delays or otherwise do
15811 not work for the AAAA record type. In due course, when the world's name
15812 servers have all been upgraded, there should be no need for this option.
15813 Note that all lookups, including those done for verification, are affected;
15814 this will result in verify failure for IPv6 connections or ones using names
15815 only valid for IPv6 addresses.
15816
15817
15818 .option dns_retrans main time 0s
15819 .cindex "DNS" "resolver options"
15820 .cindex timeout "dns lookup"
15821 .cindex "DNS" timeout
15822 The options &%dns_retrans%& and &%dns_retry%& can be used to set the
15823 retransmission and retry parameters for DNS lookups. Values of zero (the
15824 defaults) leave the system default settings unchanged. The first value is the
15825 time between retries, and the second is the number of retries. It isn't
15826 totally clear exactly how these settings affect the total time a DNS lookup may
15827 take. I haven't found any documentation about timeouts on DNS lookups; these
15828 parameter values are available in the external resolver interface structure,
15829 but nowhere does it seem to describe how they are used or what you might want
15830 to set in them.
15831 See also the &%slow_lookup_log%& option.
15832
15833
15834 .option dns_retry main integer 0
15835 See &%dns_retrans%& above.
15836
15837
15838 .option dns_trust_aa main "domain list&!!" unset
15839 .cindex "DNS" "resolver options"
15840 .cindex "DNS" "DNSSEC"
15841 If this option is set then lookup results marked with the AA bit
15842 (Authoritative Answer) are trusted the same way as if they were
15843 DNSSEC-verified. The authority section's name of the answer must
15844 match with this expanded domain list.
15845
15846 Use this option only if you talk directly to a resolver that is
15847 authoritative for some zones and does not set the AD (Authentic Data)
15848 bit in the answer. Some DNS servers may have an configuration option to
15849 mark the answers from their own zones as verified (they set the AD bit).
15850 Others do not have this option. It is considered as poor practice using
15851 a resolver that is an authoritative server for some zones.
15852
15853 Use this option only if you really have to (e.g. if you want
15854 to use DANE for remote delivery to a server that is listed in the DNS
15855 zones that your resolver is authoritative for).
15856
15857 If the DNS answer packet has the AA bit set and contains resource record
15858 in the answer section, the name of the first NS record appearing in the
15859 authority section is compared against the list. If the answer packet is
15860 authoritative but the answer section is empty, the name of the first SOA
15861 record in the authoritative section is used instead.
15862
15863 .cindex "DNS" "resolver options"
15864 .option dns_use_edns0 main integer -1
15865 .cindex "DNS" "resolver options"
15866 .cindex "DNS" "EDNS0"
15867 .cindex "DNS" "OpenBSD
15868 If this option is set to a non-negative number then Exim will initialise the
15869 DNS resolver library to either use or not use EDNS0 extensions, overriding
15870 the system default. A value of 0 coerces EDNS0 off, a value of 1 coerces EDNS0
15871 on.
15872
15873 If the resolver library does not support EDNS0 then this option has no effect.
15874
15875 OpenBSD's asr resolver routines are known to ignore the EDNS0 option; this
15876 means that DNSSEC will not work with Exim on that platform either, unless Exim
15877 is linked against an alternative DNS client library.
15878
15879
15880 .option drop_cr main boolean false
15881 This is an obsolete option that is now a no-op. It used to affect the way Exim
15882 handled CR and LF characters in incoming messages. What happens now is
15883 described in section &<<SECTlineendings>>&.
15884
15885 .option dsn_advertise_hosts main "host list&!!" unset
15886 .cindex "bounce messages" "success"
15887 .cindex "DSN" "success"
15888 .cindex "Delivery Status Notification" "success"
15889 .cindex "ESMTP extensions" DSN
15890 DSN extensions (RFC3461) will be advertised in the EHLO message to,
15891 and accepted from, these hosts.
15892 Hosts may use the NOTIFY and ORCPT options on RCPT TO commands,
15893 and RET and ENVID options on MAIL FROM commands.
15894 A NOTIFY=SUCCESS option requests success-DSN messages.
15895 A NOTIFY= option with no argument requests that no delay or failure DSNs
15896 are sent.
15897 &*Note*&: Supplying success-DSN messages has been criticised
15898 on privacy grounds; it can leak details of internal forwarding.
15899
15900 .option dsn_from main "string&!!" "see below"
15901 .cindex "&'From:'& header line" "in bounces"
15902 .cindex "bounce messages" "&'From:'& line, specifying"
15903 This option can be used to vary the contents of &'From:'& header lines in
15904 bounces and other automatically generated messages (&"Delivery Status
15905 Notifications"& &-- hence the name of the option). The default setting is:
15906 .code
15907 dsn_from = Mail Delivery System <Mailer-Daemon@$qualify_domain>
15908 .endd
15909 The value is expanded every time it is needed. If the expansion fails, a
15910 panic is logged, and the default value is used.
15911
15912 .option envelope_to_remove main boolean true
15913 .cindex "&'Envelope-to:'& header line"
15914 Exim's transports have an option for adding an &'Envelope-to:'& header to a
15915 message when it is delivered, in exactly the same way as &'Return-path:'& is
15916 handled. &'Envelope-to:'& records the original recipient address from the
15917 message's envelope that caused the delivery to happen. Such headers should not
15918 be present in incoming messages, and this option causes them to be removed at
15919 the time the message is received, to avoid any problems that might occur when a
15920 delivered message is subsequently sent on to some other recipient.
15921
15922
15923 .option errors_copy main "string list&!!" unset
15924 .cindex "bounce message" "copy to other address"
15925 .cindex "copy of bounce message"
15926 Setting this option causes Exim to send bcc copies of bounce messages that it
15927 generates to other addresses. &*Note*&: This does not apply to bounce messages
15928 coming from elsewhere. The value of the option is a colon-separated list of
15929 items. Each item consists of a pattern, terminated by white space, followed by
15930 a comma-separated list of email addresses. If a pattern contains spaces, it
15931 must be enclosed in double quotes.
15932
15933 Each pattern is processed in the same way as a single item in an address list
15934 (see section &<<SECTaddresslist>>&). When a pattern matches the recipient of
15935 the bounce message, the message is copied to the addresses on the list. The
15936 items are scanned in order, and once a matching one is found, no further items
15937 are examined. For example:
15938 .code
15939 errors_copy = spqr@mydomain   postmaster@mydomain.example :\
15940               rqps@mydomain   hostmaster@mydomain.example,\
15941                               postmaster@mydomain.example
15942 .endd
15943 .vindex "&$domain$&"
15944 .vindex "&$local_part$&"
15945 The address list is expanded before use. The expansion variables &$local_part$&
15946 and &$domain$& are set from the original recipient of the error message, and if
15947 there was any wildcard matching in the pattern, the expansion
15948 .cindex "numerical variables (&$1$& &$2$& etc)" "in &%errors_copy%&"
15949 variables &$0$&, &$1$&, etc. are set in the normal way.
15950
15951
15952 .option errors_reply_to main string unset
15953 .cindex "bounce message" "&'Reply-to:'& in"
15954 By default, Exim's bounce and delivery warning messages contain the header line
15955 .display
15956 &`From: Mail Delivery System <Mailer-Daemon@`&&'qualify-domain'&&`>`&
15957 .endd
15958 .oindex &%quota_warn_message%&
15959 where &'qualify-domain'& is the value of the &%qualify_domain%& option.
15960 A warning message that is generated by the &%quota_warn_message%& option in an
15961 &(appendfile)& transport may contain its own &'From:'& header line that
15962 overrides the default.
15963
15964 Experience shows that people reply to bounce messages. If the
15965 &%errors_reply_to%& option is set, a &'Reply-To:'& header is added to bounce
15966 and warning messages. For example:
15967 .code
15968 errors_reply_to = postmaster@my.domain.example
15969 .endd
15970 The value of the option is not expanded. It must specify a valid RFC 2822
15971 address. However, if a warning message that is generated by the
15972 &%quota_warn_message%& option in an &(appendfile)& transport contain its
15973 own &'Reply-To:'& header line, the value of the &%errors_reply_to%& option is
15974 not used.
15975
15976
15977 .option event_action main string&!! unset
15978 .cindex events
15979 This option declares a string to be expanded for Exim's events mechanism.
15980 For details see chapter &<<CHAPevents>>&.
15981
15982
15983 .option exim_group main string "compile-time configured"
15984 .cindex "gid (group id)" "Exim's own"
15985 .cindex "Exim group"
15986 This option changes the gid under which Exim runs when it gives up root
15987 privilege. The default value is compiled into the binary. The value of this
15988 option is used only when &%exim_user%& is also set. Unless it consists entirely
15989 of digits, the string is looked up using &[getgrnam()]&, and failure causes a
15990 configuration error. See chapter &<<CHAPsecurity>>& for a discussion of
15991 security issues.
15992
15993
15994 .option exim_path main string "see below"
15995 .cindex "Exim binary, path name"
15996 This option specifies the path name of the Exim binary, which is used when Exim
15997 needs to re-exec itself. The default is set up to point to the file &'exim'& in
15998 the directory configured at compile time by the BIN_DIRECTORY setting. It
15999 is necessary to change &%exim_path%& if, exceptionally, Exim is run from some
16000 other place.
16001 &*Warning*&: Do not use a macro to define the value of this option, because
16002 you will break those Exim utilities that scan the configuration file to find
16003 where the binary is. (They then use the &%-bP%& option to extract option
16004 settings such as the value of &%spool_directory%&.)
16005
16006
16007 .option exim_user main string "compile-time configured"
16008 .cindex "uid (user id)" "Exim's own"
16009 .cindex "Exim user"
16010 This option changes the uid under which Exim runs when it gives up root
16011 privilege. The default value is compiled into the binary. Ownership of the run
16012 time configuration file and the use of the &%-C%& and &%-D%& command line
16013 options is checked against the values in the binary, not what is set here.
16014
16015 Unless it consists entirely of digits, the string is looked up using
16016 &[getpwnam()]&, and failure causes a configuration error. If &%exim_group%& is
16017 not also supplied, the gid is taken from the result of &[getpwnam()]& if it is
16018 used. See chapter &<<CHAPsecurity>>& for a discussion of security issues.
16019
16020
16021 .option exim_version main string "current version"
16022 .cindex "Exim version"
16023 .cindex customizing "version number"
16024 .cindex "version number of Exim" override
16025 This option overrides the &$version_number$&/&$exim_version$& that Exim reports in
16026 various places.  Use with care; this may fool stupid security scanners.
16027
16028
16029 .option extra_local_interfaces main "string list" unset
16030 This option defines network interfaces that are to be considered local when
16031 routing, but which are not used for listening by the daemon. See section
16032 &<<SECTreclocipadd>>& for details.
16033
16034
16035 . Allow this long option name to split; give it unsplit as a fifth argument
16036 . for the automatic .oindex that is generated by .option.
16037
16038 .option "extract_addresses_remove_arguments" main boolean true &&&
16039          extract_addresses_remove_arguments
16040 .oindex "&%-t%&"
16041 .cindex "command line" "addresses with &%-t%&"
16042 .cindex "Sendmail compatibility" "&%-t%& option"
16043 According to some Sendmail documentation (Sun, IRIX, HP-UX), if any addresses
16044 are present on the command line when the &%-t%& option is used to build an
16045 envelope from a message's &'To:'&, &'Cc:'& and &'Bcc:'& headers, the command
16046 line addresses are removed from the recipients list. This is also how Smail
16047 behaves. However, other Sendmail documentation (the O'Reilly book) states that
16048 command line addresses are added to those obtained from the header lines. When
16049 &%extract_addresses_remove_arguments%& is true (the default), Exim subtracts
16050 argument headers. If it is set false, Exim adds rather than removes argument
16051 addresses.
16052
16053
16054 .option finduser_retries main integer 0
16055 .cindex "NIS, retrying user lookups"
16056 On systems running NIS or other schemes in which user and group information is
16057 distributed from a remote system, there can be times when &[getpwnam()]& and
16058 related functions fail, even when given valid data, because things time out.
16059 Unfortunately these failures cannot be distinguished from genuine &"not found"&
16060 errors. If &%finduser_retries%& is set greater than zero, Exim will try that
16061 many extra times to find a user or a group, waiting for one second between
16062 retries.
16063
16064 .cindex "&_/etc/passwd_&" "multiple reading of"
16065 You should not set this option greater than zero if your user information is in
16066 a traditional &_/etc/passwd_& file, because it will cause Exim needlessly to
16067 search the file multiple times for non-existent users, and also cause delay.
16068
16069
16070
16071 .option freeze_tell main "string list, comma separated" unset
16072 .cindex "freezing messages" "sending a message when freezing"
16073 .cindex "frozen messages" "sending a message when freezing"
16074 On encountering certain errors, or when configured to do so in a system filter,
16075 ACL, or special router, Exim freezes a message. This means that no further
16076 delivery attempts take place until an administrator thaws the message, or the
16077 &%auto_thaw%&, &%ignore_bounce_errors_after%&, or &%timeout_frozen_after%&
16078 feature cause it to be processed. If &%freeze_tell%& is set, Exim generates a
16079 warning message whenever it freezes something, unless the message it is
16080 freezing is a locally-generated bounce message. (Without this exception there
16081 is the possibility of looping.) The warning message is sent to the addresses
16082 supplied as the comma-separated value of this option. If several of the
16083 message's addresses cause freezing, only a single message is sent. If the
16084 freezing was automatic, the reason(s) for freezing can be found in the message
16085 log. If you configure freezing in a filter or ACL, you must arrange for any
16086 logging that you require.
16087
16088
16089 .options gecos_name main string&!! unset &&&
16090          gecos_pattern main string unset
16091 .cindex "HP-UX"
16092 .cindex "&""gecos""& field, parsing"
16093 Some operating systems, notably HP-UX, use the &"gecos"& field in the system
16094 password file to hold other information in addition to users' real names. Exim
16095 looks up this field for use when it is creating &'Sender:'& or &'From:'&
16096 headers. If either &%gecos_pattern%& or &%gecos_name%& are unset, the contents
16097 of the field are used unchanged, except that, if an ampersand is encountered,
16098 it is replaced by the user's login name with the first character forced to
16099 upper case, since this is a convention that is observed on many systems.
16100
16101 When these options are set, &%gecos_pattern%& is treated as a regular
16102 expression that is to be applied to the field (again with && replaced by the
16103 login name), and if it matches, &%gecos_name%& is expanded and used as the
16104 user's name.
16105
16106 .cindex "numerical variables (&$1$& &$2$& etc)" "in &%gecos_name%&"
16107 Numeric variables such as &$1$&, &$2$&, etc. can be used in the expansion to
16108 pick up sub-fields that were matched by the pattern. In HP-UX, where the user's
16109 name terminates at the first comma, the following can be used:
16110 .code
16111 gecos_pattern = ([^,]*)
16112 gecos_name = $1
16113 .endd
16114
16115
16116 .option gnutls_compat_mode main boolean unset
16117 This option controls whether GnuTLS is used in compatibility mode in an Exim
16118 server. This reduces security slightly, but improves interworking with older
16119 implementations of TLS.
16120
16121
16122 .option gnutls_allow_auto_pkcs11 main boolean unset
16123 This option will let GnuTLS (2.12.0 or later) autoload PKCS11 modules with
16124 the p11-kit configuration files in &_/etc/pkcs11/modules/_&.
16125
16126 See
16127 &url(https://www.gnutls.org/manual/gnutls.html#Smart-cards-and-HSMs)
16128 for documentation.
16129
16130
16131
16132 .option headers_charset main string "see below"
16133 This option sets a default character set for translating from encoded MIME
16134 &"words"& in header lines, when referenced by an &$h_xxx$& expansion item. The
16135 default is the value of HEADERS_CHARSET in &_Local/Makefile_&. The
16136 ultimate default is ISO-8859-1. For more details see the description of header
16137 insertions in section &<<SECTexpansionitems>>&.
16138
16139
16140
16141 .option header_maxsize main integer "see below"
16142 .cindex "header section" "maximum size of"
16143 .cindex "limit" "size of message header section"
16144 This option controls the overall maximum size of a message's header
16145 section. The default is the value of HEADER_MAXSIZE in
16146 &_Local/Makefile_&; the default for that is 1M. Messages with larger header
16147 sections are rejected.
16148
16149
16150 .option header_line_maxsize main integer 0
16151 .cindex "header lines" "maximum size of"
16152 .cindex "limit" "size of one header line"
16153 This option limits the length of any individual header line in a message, after
16154 all the continuations have been joined together. Messages with individual
16155 header lines that are longer than the limit are rejected. The default value of
16156 zero means &"no limit"&.
16157
16158
16159
16160
16161 .option helo_accept_junk_hosts main "host list&!!" unset
16162 .cindex "HELO" "accepting junk data"
16163 .cindex "EHLO" "accepting junk data"
16164 Exim checks the syntax of HELO and EHLO commands for incoming SMTP
16165 mail, and gives an error response for invalid data. Unfortunately, there are
16166 some SMTP clients that send syntactic junk. They can be accommodated by setting
16167 this option. Note that this is a syntax check only. See &%helo_verify_hosts%&
16168 if you want to do semantic checking.
16169 See also &%helo_allow_chars%& for a way of extending the permitted character
16170 set.
16171
16172
16173 .option helo_allow_chars main string unset
16174 .cindex "HELO" "underscores in"
16175 .cindex "EHLO" "underscores in"
16176 .cindex "underscore in EHLO/HELO"
16177 This option can be set to a string of rogue characters that are permitted in
16178 all EHLO and HELO names in addition to the standard letters, digits,
16179 hyphens, and dots. If you really must allow underscores, you can set
16180 .code
16181 helo_allow_chars = _
16182 .endd
16183 Note that the value is one string, not a list.
16184
16185
16186 .option helo_lookup_domains main "domain list&!!" &`@:@[]`&
16187 .cindex "HELO" "forcing reverse lookup"
16188 .cindex "EHLO" "forcing reverse lookup"
16189 If the domain given by a client in a HELO or EHLO command matches this
16190 list, a reverse lookup is done in order to establish the host's true name. The
16191 default forces a lookup if the client host gives the server's name or any of
16192 its IP addresses (in brackets), something that broken clients have been seen to
16193 do.
16194
16195
16196 .option helo_try_verify_hosts main "host list&!!" unset
16197 .cindex "HELO verifying" "optional"
16198 .cindex "EHLO" "verifying, optional"
16199 By default, Exim just checks the syntax of HELO and EHLO commands (see
16200 &%helo_accept_junk_hosts%& and &%helo_allow_chars%&). However, some sites like
16201 to do more extensive checking of the data supplied by these commands. The ACL
16202 condition &`verify = helo`& is provided to make this possible.
16203 Formerly, it was necessary also to set this option (&%helo_try_verify_hosts%&)
16204 to force the check to occur. From release 4.53 onwards, this is no longer
16205 necessary. If the check has not been done before &`verify = helo`& is
16206 encountered, it is done at that time. Consequently, this option is obsolete.
16207 Its specification is retained here for backwards compatibility.
16208
16209 When an EHLO or HELO command is received, if the calling host matches
16210 &%helo_try_verify_hosts%&, Exim checks that the host name given in the HELO or
16211 EHLO command either:
16212
16213 .ilist
16214 is an IP literal matching the calling address of the host, or
16215 .next
16216 .cindex "DNS" "reverse lookup"
16217 .cindex "reverse DNS lookup"
16218 matches the host name that Exim obtains by doing a reverse lookup of the
16219 calling host address, or
16220 .next
16221 when looked up in DNS yields the calling host address.
16222 .endlist
16223
16224 However, the EHLO or HELO command is not rejected if any of the checks
16225 fail. Processing continues, but the result of the check is remembered, and can
16226 be detected later in an ACL by the &`verify = helo`& condition.
16227
16228 If DNS was used for successful verification, the variable
16229 .cindex "DNS" "DNSSEC"
16230 &$helo_verify_dnssec$& records the DNSSEC status of the lookups.
16231
16232 .option helo_verify_hosts main "host list&!!" unset
16233 .cindex "HELO verifying" "mandatory"
16234 .cindex "EHLO" "verifying, mandatory"
16235 Like &%helo_try_verify_hosts%&, this option is obsolete, and retained only for
16236 backwards compatibility. For hosts that match this option, Exim checks the host
16237 name given in the HELO or EHLO in the same way as for
16238 &%helo_try_verify_hosts%&. If the check fails, the HELO or EHLO command is
16239 rejected with a 550 error, and entries are written to the main and reject logs.
16240 If a MAIL command is received before EHLO or HELO, it is rejected with a 503
16241 error.
16242
16243 .option hold_domains main "domain list&!!" unset
16244 .cindex "domain" "delaying delivery"
16245 .cindex "delivery" "delaying certain domains"
16246 This option allows mail for particular domains to be held in the queue
16247 manually. The option is overridden if a message delivery is forced with the
16248 &%-M%&, &%-qf%&, &%-Rf%& or &%-Sf%& options, and also while testing or
16249 verifying addresses using &%-bt%& or &%-bv%&. Otherwise, if a domain matches an
16250 item in &%hold_domains%&, no routing or delivery for that address is done, and
16251 it is deferred every time the message is looked at.
16252
16253 This option is intended as a temporary operational measure for delaying the
16254 delivery of mail while some problem is being sorted out, or some new
16255 configuration tested. If you just want to delay the processing of some
16256 domains until a queue run occurs, you should use &%queue_domains%& or
16257 &%queue_smtp_domains%&, not &%hold_domains%&.
16258
16259 A setting of &%hold_domains%& does not override Exim's code for removing
16260 messages from the queue if they have been there longer than the longest retry
16261 time in any retry rule. If you want to hold messages for longer than the normal
16262 retry times, insert a dummy retry rule with a long retry time.
16263
16264
16265 .option host_lookup main "host list&!!" unset
16266 .cindex "host name" "lookup, forcing"
16267 Exim does not look up the name of a calling host from its IP address unless it
16268 is required to compare against some host list, or the host matches
16269 &%helo_try_verify_hosts%& or &%helo_verify_hosts%&, or the host matches this
16270 option (which normally contains IP addresses rather than host names). The
16271 default configuration file contains
16272 .code
16273 host_lookup = *
16274 .endd
16275 which causes a lookup to happen for all hosts. If the expense of these lookups
16276 is felt to be too great, the setting can be changed or removed.
16277
16278 After a successful reverse lookup, Exim does a forward lookup on the name it
16279 has obtained, to verify that it yields the IP address that it started with. If
16280 this check fails, Exim behaves as if the name lookup failed.
16281
16282 .vindex "&$host_lookup_failed$&"
16283 .vindex "&$sender_host_name$&"
16284 After any kind of failure, the host name (in &$sender_host_name$&) remains
16285 unset, and &$host_lookup_failed$& is set to the string &"1"&. See also
16286 &%dns_again_means_nonexist%&, &%helo_lookup_domains%&, and
16287 &`verify = reverse_host_lookup`& in ACLs.
16288
16289
16290 .option host_lookup_order main "string list" &`bydns:byaddr`&
16291 This option specifies the order of different lookup methods when Exim is trying
16292 to find a host name from an IP address. The default is to do a DNS lookup
16293 first, and then to try a local lookup (using &[gethostbyaddr()]& or equivalent)
16294 if that fails. You can change the order of these lookups, or omit one entirely,
16295 if you want.
16296
16297 &*Warning*&: The &"byaddr"& method does not always yield aliases when there are
16298 multiple PTR records in the DNS and the IP address is not listed in
16299 &_/etc/hosts_&. Different operating systems give different results in this
16300 case. That is why the default tries a DNS lookup first.
16301
16302
16303
16304 .option host_reject_connection main "host list&!!" unset
16305 .cindex "host" "rejecting connections from"
16306 If this option is set, incoming SMTP calls from the hosts listed are rejected
16307 as soon as the connection is made.
16308 This option is obsolete, and retained only for backward compatibility, because
16309 nowadays the ACL specified by &%acl_smtp_connect%& can also reject incoming
16310 connections immediately.
16311
16312 If the connection is on a TLS-on-connect port then the TCP connection is
16313 just dropped.  Otherwise, an SMTP error is sent first.
16314
16315 The ability to give an immediate rejection (either by this option or using an
16316 ACL) is provided for use in unusual cases. Many hosts will just try again,
16317 sometimes without much delay. Normally, it is better to use an ACL to reject
16318 incoming messages at a later stage, such as after RCPT commands. See
16319 chapter &<<CHAPACL>>&.
16320
16321
16322 .option hosts_connection_nolog main "host list&!!" unset
16323 .cindex "host" "not logging connections from"
16324 This option defines a list of hosts for which connection logging does not
16325 happen, even though the &%smtp_connection%& log selector is set. For example,
16326 you might want not to log SMTP connections from local processes, or from
16327 127.0.0.1, or from your local LAN. This option is consulted in the main loop of
16328 the daemon; you should therefore strive to restrict its value to a short inline
16329 list of IP addresses and networks. To disable logging SMTP connections from
16330 local processes, you must create a host list with an empty item. For example:
16331 .code
16332 hosts_connection_nolog = :
16333 .endd
16334 The hosts affected by this option also do not log "no MAIL in SMTP connection"
16335 lines, as may commonly be produced by a monitoring system.
16336
16337
16338 .option hosts_require_alpn main "host list&!!" unset
16339 .cindex ALPN "require negotiation in server"
16340 .cindex TLS ALPN
16341 .cindex TLS "Application Layer Protocol Names"
16342 If the TLS library supports ALPN
16343 then a successful negotiation of ALPN will be required for any client
16344 matching the list, for TLS to be used.
16345 See also the &%tls_alpn%& option.
16346
16347 &*Note*&: prevention of fallback to in-clear connection is not
16348 managed by this option, and should be done separately.
16349
16350
16351 .option hosts_require_helo main "host list&!!" *
16352 .cindex "HELO/EHLO" requiring
16353 Exim will require an accepted HELO or EHLO command from a host matching
16354 this list, before accepting a MAIL command.
16355
16356
16357 .option hosts_proxy main "host list&!!" unset
16358 .cindex proxy "proxy protocol"
16359 This option enables use of Proxy Protocol proxies for incoming
16360 connections.  For details see section &<<SECTproxyInbound>>&.
16361
16362
16363 .option hosts_treat_as_local main "domain list&!!" unset
16364 .cindex "local host" "domains treated as"
16365 .cindex "host" "treated as local"
16366 If this option is set, any host names that match the domain list are treated as
16367 if they were the local host when Exim is scanning host lists obtained from MX
16368 records
16369 or other sources. Note that the value of this option is a domain list, not a
16370 host list, because it is always used to check host names, not IP addresses.
16371
16372 This option also applies when Exim is matching the special items
16373 &`@mx_any`&, &`@mx_primary`&, and &`@mx_secondary`& in a domain list (see
16374 section &<<SECTdomainlist>>&), and when checking the &%hosts%& option in the
16375 &(smtp)& transport for the local host (see the &%allow_localhost%& option in
16376 that transport). See also &%local_interfaces%&, &%extra_local_interfaces%&, and
16377 chapter &<<CHAPinterfaces>>&, which contains a discussion about local network
16378 interfaces and recognizing the local host.
16379
16380
16381 .option ibase_servers main "string list" unset
16382 .cindex "InterBase" "server list"
16383 This option provides a list of InterBase servers and associated connection data,
16384 to be used in conjunction with &(ibase)& lookups (see section &<<SECID72>>&).
16385 The option is available only if Exim has been built with InterBase support.
16386
16387
16388
16389 .option ignore_bounce_errors_after main time 10w
16390 .cindex "bounce message" "discarding"
16391 .cindex "discarding bounce message"
16392 This option affects the processing of bounce messages that cannot be delivered,
16393 that is, those that suffer a permanent delivery failure. (Bounce messages that
16394 suffer temporary delivery failures are of course retried in the usual way.)
16395
16396 After a permanent delivery failure, bounce messages are frozen,
16397 because there is no sender to whom they can be returned. When a frozen bounce
16398 message has been in the queue for more than the given time, it is unfrozen at
16399 the next queue run, and a further delivery is attempted. If delivery fails
16400 again, the bounce message is discarded. This makes it possible to keep failed
16401 bounce messages around for a shorter time than the normal maximum retry time
16402 for frozen messages. For example,
16403 .code
16404 ignore_bounce_errors_after = 12h
16405 .endd
16406 retries failed bounce message deliveries after 12 hours, discarding any further
16407 failures. If the value of this option is set to a zero time period, bounce
16408 failures are discarded immediately. Setting a very long time (as in the default
16409 value) has the effect of disabling this option. For ways of automatically
16410 dealing with other kinds of frozen message, see &%auto_thaw%& and
16411 &%timeout_frozen_after%&.
16412
16413
16414 .options ignore_fromline_hosts main "host list&!!" unset &&&
16415          ignore_fromline_local main boolean false
16416 .cindex "&""From""& line"
16417 .cindex "UUCP" "&""From""& line"
16418 Some broken SMTP clients insist on sending a UUCP-like &"From&~"& line before
16419 the headers of a message. By default this is treated as the start of the
16420 message's body, which means that any following headers are not recognized as
16421 such. Exim can be made to ignore it by setting &%ignore_fromline_hosts%& to
16422 match those hosts that insist on sending it. If the sender is actually a local
16423 process rather than a remote host, and is using &%-bs%& to inject the messages,
16424 &%ignore_fromline_local%& must be set to achieve this effect.
16425
16426
16427
16428 .option keep_environment main "string list" unset
16429 .cindex "environment" "values from"
16430 This option contains a string list of environment variables to keep.
16431 You have to trust these variables or you have to be sure that
16432 these variables do not impose any security risk. Keep in mind that
16433 during the startup phase Exim is running with an effective UID 0 in most
16434 installations. As the default value is an empty list, the default
16435 environment for using libraries, running embedded Perl code, or running
16436 external binaries is empty, and does not not even contain PATH or HOME.
16437
16438 Actually the list is interpreted as a list of patterns
16439 (&<<SECTlistexpand>>&), except that it is not expanded first.
16440
16441 WARNING: Macro substitution is still done first, so having a macro
16442 FOO and having FOO_HOME in your &%keep_environment%& option may have
16443 unexpected results. You may work around this using a regular expression
16444 that does not match the macro name: ^[F]OO_HOME$.
16445
16446 Current versions of Exim issue a warning during startup if you do not mention
16447 &%keep_environment%& in your runtime configuration file and if your
16448 current environment is not empty. Future versions may not issue that warning
16449 anymore.
16450
16451 See the &%add_environment%& main config option for a way to set
16452 environment variables to a fixed value.  The environment for &(pipe)&
16453 transports is handled separately, see section &<<SECTpipeenv>>& for
16454 details.
16455
16456
16457 .option keep_malformed main time 4d
16458 This option specifies the length of time to keep messages whose spool files
16459 have been corrupted in some way. This should, of course, never happen. At the
16460 next attempt to deliver such a message, it gets removed. The incident is
16461 logged.
16462
16463
16464 .option ldap_ca_cert_dir main string unset
16465 .cindex "LDAP", "TLS CA certificate directory"
16466 .cindex certificate "directory for LDAP"
16467 This option indicates which directory contains CA certificates for verifying
16468 a TLS certificate presented by an LDAP server.
16469 While Exim does not provide a default value, your SSL library may.
16470 Analogous to &%tls_verify_certificates%& but as a client-side option for LDAP
16471 and constrained to be a directory.
16472
16473
16474 .option ldap_ca_cert_file main string unset
16475 .cindex "LDAP", "TLS CA certificate file"
16476 .cindex certificate "file for LDAP"
16477 This option indicates which file contains CA certificates for verifying
16478 a TLS certificate presented by an LDAP server.
16479 While Exim does not provide a default value, your SSL library may.
16480 Analogous to &%tls_verify_certificates%& but as a client-side option for LDAP
16481 and constrained to be a file.
16482
16483
16484 .option ldap_cert_file main string unset
16485 .cindex "LDAP" "TLS client certificate file"
16486 .cindex certificate "file for LDAP"
16487 This option indicates which file contains an TLS client certificate which
16488 Exim should present to the LDAP server during TLS negotiation.
16489 Should be used together with &%ldap_cert_key%&.
16490
16491
16492 .option ldap_cert_key main string unset
16493 .cindex "LDAP" "TLS client key file"
16494 .cindex certificate "key for LDAP"
16495 This option indicates which file contains the secret/private key to use
16496 to prove identity to the LDAP server during TLS negotiation.
16497 Should be used together with &%ldap_cert_file%&, which contains the
16498 identity to be proven.
16499
16500
16501 .option ldap_cipher_suite main string unset
16502 .cindex "LDAP" "TLS cipher suite"
16503 This controls the TLS cipher-suite negotiation during TLS negotiation with
16504 the LDAP server.  See &<<SECTreqciphssl>>& for more details of the format of
16505 cipher-suite options with OpenSSL (as used by LDAP client libraries).
16506
16507
16508 .option ldap_default_servers main "string list" unset
16509 .cindex "LDAP" "default servers"
16510 This option provides a list of LDAP servers which are tried in turn when an
16511 LDAP query does not contain a server. See section &<<SECTforldaque>>& for
16512 details of LDAP queries. This option is available only when Exim has been built
16513 with LDAP support.
16514
16515
16516 .option ldap_require_cert main string unset.
16517 .cindex "LDAP" "policy for LDAP server TLS cert presentation"
16518 This should be one of the values "hard", "demand", "allow", "try" or "never".
16519 A value other than one of these is interpreted as "never".
16520 See the entry "TLS_REQCERT" in your system man page for ldap.conf(5).
16521 Although Exim does not set a default, the LDAP library probably defaults
16522 to hard/demand.
16523
16524
16525 .option ldap_start_tls main boolean false
16526 .cindex "LDAP" "whether or not to negotiate TLS"
16527 If set, Exim will attempt to negotiate TLS with the LDAP server when
16528 connecting on a regular LDAP port.  This is the LDAP equivalent of SMTP's
16529 "STARTTLS".  This is distinct from using "ldaps", which is the LDAP form
16530 of SSL-on-connect.
16531 In the event of failure to negotiate TLS, the action taken is controlled
16532 by &%ldap_require_cert%&.
16533 This option is ignored for &`ldapi`& connections.
16534
16535
16536 .option ldap_version main integer unset
16537 .cindex "LDAP" "protocol version, forcing"
16538 This option can be used to force Exim to set a specific protocol version for
16539 LDAP. If it option is unset, it is shown by the &%-bP%& command line option as
16540 -1. When this is the case, the default is 3 if LDAP_VERSION3 is defined in
16541 the LDAP headers; otherwise it is 2. This option is available only when Exim
16542 has been built with LDAP support.
16543
16544
16545
16546 .option local_from_check main boolean true
16547 .cindex "&'Sender:'& header line" "disabling addition of"
16548 .cindex "&'From:'& header line" "disabling checking of"
16549 When a message is submitted locally (that is, not over a TCP/IP connection) by
16550 an untrusted user, Exim removes any existing &'Sender:'& header line, and
16551 checks that the &'From:'& header line matches the login of the calling user and
16552 the domain specified by &%qualify_domain%&.
16553
16554 &*Note*&: An unqualified address (no domain) in the &'From:'& header in a
16555 locally submitted message is automatically qualified by Exim, unless the
16556 &%-bnq%& command line option is used.
16557
16558 You can use &%local_from_prefix%& and &%local_from_suffix%& to permit affixes
16559 on the local part. If the &'From:'& header line does not match, Exim adds a
16560 &'Sender:'& header with an address constructed from the calling user's login
16561 and the default qualify domain.
16562
16563 If &%local_from_check%& is set false, the &'From:'& header check is disabled,
16564 and no &'Sender:'& header is ever added. If, in addition, you want to retain
16565 &'Sender:'& header lines supplied by untrusted users, you must also set
16566 &%local_sender_retain%& to be true.
16567
16568 .cindex "envelope from"
16569 .cindex "envelope sender"
16570 These options affect only the header lines in the message. The envelope sender
16571 is still forced to be the login id at the qualify domain unless
16572 &%untrusted_set_sender%& permits the user to supply an envelope sender.
16573
16574 For messages received over TCP/IP, an ACL can specify &"submission mode"& to
16575 request similar header line checking. See section &<<SECTthesenhea>>&, which
16576 has more details about &'Sender:'& processing.
16577
16578
16579
16580
16581 .options local_from_prefix main string unset &&&
16582          local_from_suffix main string unset
16583 When Exim checks the &'From:'& header line of locally submitted messages for
16584 matching the login id (see &%local_from_check%& above), it can be configured to
16585 ignore certain prefixes and suffixes in the local part of the address. This is
16586 done by setting &%local_from_prefix%& and/or &%local_from_suffix%& to
16587 appropriate lists, in the same form as the &%local_part_prefix%& and
16588 &%local_part_suffix%& router options (see chapter &<<CHAProutergeneric>>&). For
16589 example, if
16590 .code
16591 local_from_prefix = *-
16592 .endd
16593 is set, a &'From:'& line containing
16594 .code
16595 From: anything-user@your.domain.example
16596 .endd
16597 will not cause a &'Sender:'& header to be added if &'user@your.domain.example'&
16598 matches the actual sender address that is constructed from the login name and
16599 qualify domain.
16600
16601
16602 .option local_interfaces main "string list" "see below"
16603 This option controls which network interfaces are used by the daemon for
16604 listening; they are also used to identify the local host when routing. Chapter
16605 &<<CHAPinterfaces>>& contains a full description of this option and the related
16606 options &%daemon_smtp_ports%&, &%extra_local_interfaces%&,
16607 &%hosts_treat_as_local%&, and &%tls_on_connect_ports%&. The default value for
16608 &%local_interfaces%& is
16609 .code
16610 local_interfaces = 0.0.0.0
16611 .endd
16612 when Exim is built without IPv6 support; otherwise it is
16613 .code
16614 local_interfaces = <; ::0 ; 0.0.0.0
16615 .endd
16616
16617 .option local_scan_timeout main time 5m
16618 .cindex "timeout" "for &[local_scan()]& function"
16619 .cindex "&[local_scan()]& function" "timeout"
16620 This timeout applies to the &[local_scan()]& function (see chapter
16621 &<<CHAPlocalscan>>&). Zero means &"no timeout"&. If the timeout is exceeded,
16622 the incoming message is rejected with a temporary error if it is an SMTP
16623 message. For a non-SMTP message, the message is dropped and Exim ends with a
16624 non-zero code. The incident is logged on the main and reject logs.
16625
16626
16627
16628 .option local_sender_retain main boolean false
16629 .cindex "&'Sender:'& header line" "retaining from local submission"
16630 When a message is submitted locally (that is, not over a TCP/IP connection) by
16631 an untrusted user, Exim removes any existing &'Sender:'& header line. If you
16632 do not want this to happen, you must set &%local_sender_retain%&, and you must
16633 also set &%local_from_check%& to be false (Exim will complain if you do not).
16634 See also the ACL modifier &`control = suppress_local_fixups`&. Section
16635 &<<SECTthesenhea>>& has more details about &'Sender:'& processing.
16636
16637
16638
16639
16640 .option localhost_number main string&!! unset
16641 .cindex "host" "locally unique number for"
16642 .cindex "message ids" "with multiple hosts"
16643 .vindex "&$localhost_number$&"
16644 Exim's message ids are normally unique only within the local host. If
16645 uniqueness among a set of hosts is required, each host must set a different
16646 value for the &%localhost_number%& option. The string is expanded immediately
16647 after reading the configuration file (so that a number can be computed from the
16648 host name, for example) and the result of the expansion must be a number in the
16649 range 0&--16 (or 0&--10 on operating systems with case-insensitive file
16650 systems). This is available in subsequent string expansions via the variable
16651 &$localhost_number$&. When &%localhost_number is set%&, the final two
16652 characters of the message id, instead of just being a fractional part of the
16653 time, are computed from the time and the local host number as described in
16654 section &<<SECTmessiden>>&.
16655
16656
16657
16658 .option log_file_path main "string list&!!" "set at compile time"
16659 .cindex "log" "file path for"
16660 This option sets the path which is used to determine the names of Exim's log
16661 files, or indicates that logging is to be to syslog, or both. It is expanded
16662 when Exim is entered, so it can, for example, contain a reference to the host
16663 name. If no specific path is set for the log files at compile or runtime,
16664 or if the option is unset at runtime (i.e.  &`log_file_path = `&)
16665 they are written in a sub-directory called &_log_& in Exim's spool directory.
16666 A path must start with a slash.
16667 To send to syslog, use the word &"syslog"&.
16668 Chapter &<<CHAPlog>>& contains further details about Exim's logging, and
16669 section &<<SECTwhelogwri>>& describes how the contents of &%log_file_path%& are
16670 used. If this string is fixed at your installation (contains no expansion
16671 variables) it is recommended that you do not set this option in the
16672 configuration file, but instead supply the path using LOG_FILE_PATH in
16673 &_Local/Makefile_& so that it is available to Exim for logging errors detected
16674 early on &-- in particular, failure to read the configuration file.
16675
16676
16677 .option log_selector main string unset
16678 .cindex "log" "selectors"
16679 This option can be used to reduce or increase the number of things that Exim
16680 writes to its log files. Its argument is made up of names preceded by plus or
16681 minus characters. For example:
16682 .code
16683 log_selector = +arguments -retry_defer
16684 .endd
16685 A list of possible names and what they control is given in the chapter on
16686 logging, in section &<<SECTlogselector>>&.
16687
16688
16689 .option log_timezone main boolean false
16690 .cindex "log" "timezone for entries"
16691 .vindex "&$tod_log$&"
16692 .vindex "&$tod_zone$&"
16693 By default, the timestamps on log lines are in local time without the
16694 timezone. This means that if your timezone changes twice a year, the timestamps
16695 in log lines are ambiguous for an hour when the clocks go back. One way of
16696 avoiding this problem is to set the timezone to UTC. An alternative is to set
16697 &%log_timezone%& true. This turns on the addition of the timezone offset to
16698 timestamps in log lines. Turning on this option can add quite a lot to the size
16699 of log files because each line is extended by 6 characters. Note that the
16700 &$tod_log$& variable contains the log timestamp without the zone, but there is
16701 another variable called &$tod_zone$& that contains just the timezone offset.
16702
16703
16704 .option lookup_open_max main integer 25
16705 .cindex "too many open files"
16706 .cindex "open files, too many"
16707 .cindex "file" "too many open"
16708 .cindex "lookup" "maximum open files"
16709 .cindex "limit" "open files for lookups"
16710 This option limits the number of simultaneously open files for single-key
16711 lookups that use regular files (that is, &(lsearch)&, &(dbm)&, and &(cdb)&).
16712 Exim normally keeps these files open during routing, because often the same
16713 file is required several times. If the limit is reached, Exim closes the least
16714 recently used file. Note that if you are using the &'ndbm'& library, it
16715 actually opens two files for each logical DBM database, though it still counts
16716 as one for the purposes of &%lookup_open_max%&. If you are getting &"too many
16717 open files"& errors with NDBM, you need to reduce the value of
16718 &%lookup_open_max%&.
16719
16720
16721 .option max_username_length main integer 0
16722 .cindex "length of login name"
16723 .cindex "user name" "maximum length"
16724 .cindex "limit" "user name length"
16725 Some operating systems are broken in that they truncate long arguments to
16726 &[getpwnam()]& to eight characters, instead of returning &"no such user"&. If
16727 this option is set greater than zero, any attempt to call &[getpwnam()]& with
16728 an argument that is longer behaves as if &[getpwnam()]& failed.
16729
16730
16731 .option message_body_newlines main bool false
16732 .cindex "message body" "newlines in variables"
16733 .cindex "newline" "in message body variables"
16734 .vindex "&$message_body$&"
16735 .vindex "&$message_body_end$&"
16736 By default, newlines in the message body are replaced by spaces when setting
16737 the &$message_body$& and &$message_body_end$& expansion variables. If this
16738 option is set true, this no longer happens.
16739
16740
16741 .option message_body_visible main integer 500
16742 .cindex "body of message" "visible size"
16743 .cindex "message body" "visible size"
16744 .vindex "&$message_body$&"
16745 .vindex "&$message_body_end$&"
16746 This option specifies how much of a message's body is to be included in the
16747 &$message_body$& and &$message_body_end$& expansion variables.
16748
16749
16750 .option message_id_header_domain main string&!! unset
16751 .cindex "&'Message-ID:'& header line"
16752 If this option is set, the string is expanded and used as the right hand side
16753 (domain) of the &'Message-ID:'& header that Exim creates if a
16754 locally-originated incoming message does not have one. &"Locally-originated"&
16755 means &"not received over TCP/IP."&
16756 Otherwise, the primary host name is used.
16757 Only letters, digits, dot and hyphen are accepted; any other characters are
16758 replaced by hyphens. If the expansion is forced to fail, or if the result is an
16759 empty string, the option is ignored.
16760
16761
16762 .option message_id_header_text main string&!! unset
16763 If this variable is set, the string is expanded and used to augment the text of
16764 the &'Message-id:'& header that Exim creates if a locally-originated incoming
16765 message does not have one. The text of this header is required by RFC 2822 to
16766 take the form of an address. By default, Exim uses its internal message id as
16767 the local part, and the primary host name as the domain. If this option is set,
16768 it is expanded, and provided the expansion is not forced to fail, and does not
16769 yield an empty string, the result is inserted into the header immediately
16770 before the @, separated from the internal message id by a dot. Any characters
16771 that are illegal in an address are automatically converted into hyphens. This
16772 means that variables such as &$tod_log$& can be used, because the spaces and
16773 colons will become hyphens.
16774
16775
16776 .option message_logs main boolean true
16777 .cindex "message logs" "disabling"
16778 .cindex "log" "message log; disabling"
16779 If this option is turned off, per-message log files are not created in the
16780 &_msglog_& spool sub-directory. This reduces the amount of disk I/O required by
16781 Exim, by reducing the number of files involved in handling a message from a
16782 minimum of four (header spool file, body spool file, delivery journal, and
16783 per-message log) to three. The other major I/O activity is Exim's main log,
16784 which is not affected by this option.
16785
16786
16787 .option message_size_limit main string&!! 50M
16788 .cindex "message" "size limit"
16789 .cindex "limit" "message size"
16790 .cindex "size" "of message, limit"
16791 This option limits the maximum size of message that Exim will process. The
16792 value is expanded for each incoming connection so, for example, it can be made
16793 to depend on the IP address of the remote host for messages arriving via
16794 TCP/IP. After expansion, the value must be a sequence of decimal digits,
16795 optionally followed by K or M.
16796
16797 .cindex "SIZE" "ESMTP extension, advertising"
16798 .cindex "ESMTP extensions" SIZE
16799 If nonzero the value will be advertised as a parameter to the ESMTP SIZE
16800 service extension keyword.
16801
16802 &*Note*&: This limit cannot be made to depend on a message's sender or any
16803 other properties of an individual message, because it has to be advertised in
16804 the server's response to EHLO. String expansion failure causes a temporary
16805 error. A value of zero means no limit, but its use is not recommended. See also
16806 &%bounce_return_size_limit%&.
16807
16808 Incoming SMTP messages are failed with a 552 error if the limit is
16809 exceeded; locally-generated messages either get a stderr message or a delivery
16810 failure message to the sender, depending on the &%-oe%& setting. Rejection of
16811 an oversized message is logged in both the main and the reject logs. See also
16812 the generic transport option &%message_size_limit%&, which limits the size of
16813 message that an individual transport can process.
16814
16815 If you use a virus-scanner and set this option to to a value larger than the
16816 maximum size that your virus-scanner is configured to support, you may get
16817 failures triggered by large mails.  The right size to configure for the
16818 virus-scanner depends upon what data is passed and the options in use but it's
16819 probably safest to just set it to a little larger than this value.  E.g., with a
16820 default Exim message size of 50M and a default ClamAV StreamMaxLength of 10M,
16821 some problems may result.
16822
16823 A value of 0 will disable size limit checking; Exim will still advertise the
16824 SIZE extension in an EHLO response, but without a limit, so as to permit
16825 SMTP clients to still indicate the message size along with the MAIL verb.
16826
16827
16828 .option move_frozen_messages main boolean false
16829 .cindex "frozen messages" "moving"
16830 This option, which is available only if Exim has been built with the setting
16831 .code
16832 SUPPORT_MOVE_FROZEN_MESSAGES=yes
16833 .endd
16834 in &_Local/Makefile_&, causes frozen messages and their message logs to be
16835 moved from the &_input_& and &_msglog_& directories on the spool to &_Finput_&
16836 and &_Fmsglog_&, respectively. There is currently no support in Exim or the
16837 standard utilities for handling such moved messages, and they do not show up in
16838 lists generated by &%-bp%& or by the Exim monitor.
16839
16840
16841 .option mua_wrapper main boolean false
16842 Setting this option true causes Exim to run in a very restrictive mode in which
16843 it passes messages synchronously to a smart host. Chapter &<<CHAPnonqueueing>>&
16844 contains a full description of this facility.
16845
16846
16847
16848 .option mysql_servers main "string list" unset
16849 .cindex "MySQL" "server list"
16850 This option provides a list of MySQL servers and associated connection data, to
16851 be used in conjunction with &(mysql)& lookups (see section &<<SECID72>>&). The
16852 option is available only if Exim has been built with MySQL support.
16853
16854
16855 .option never_users main "string list&!!" unset
16856 This option is expanded just once, at the start of Exim's processing. Local
16857 message deliveries are normally run in processes that are setuid to the
16858 recipient, and remote deliveries are normally run under Exim's own uid and gid.
16859 It is usually desirable to prevent any deliveries from running as root, as a
16860 safety precaution.
16861
16862 When Exim is built, an option called FIXED_NEVER_USERS can be set to a
16863 list of users that must not be used for local deliveries. This list is fixed in
16864 the binary and cannot be overridden by the configuration file. By default, it
16865 contains just the single user name &"root"&. The &%never_users%& runtime option
16866 can be used to add more users to the fixed list.
16867
16868 If a message is to be delivered as one of the users on the fixed list or the
16869 &%never_users%& list, an error occurs, and delivery is deferred. A common
16870 example is
16871 .code
16872 never_users = root:daemon:bin
16873 .endd
16874 Including root is redundant if it is also on the fixed list, but it does no
16875 harm. This option overrides the &%pipe_as_creator%& option of the &(pipe)&
16876 transport driver.
16877
16878
16879 .option notifier_socket main string "$spool_directory/exim_daemon_notify"
16880 This option gives the name for a unix-domain socket on which the daemon
16881 listens for work and information-requests.
16882 Only installations running multiple daemons sharing a spool directory
16883 should need to modify the default.
16884
16885 The option is expanded before use.
16886 If the platform supports Linux-style abstract socket names, the result
16887 is used with a nul byte prefixed.
16888 Otherwise,
16889 it should be a full path name and use a directory accessible
16890 to Exim.
16891
16892 If this option is set as empty,
16893 or the command line &%-oY%& option is used, or
16894 the command line uses a &%-oX%& option and does not use &%-oP%&,
16895 then a notifier socket is not created.
16896
16897
16898 .option openssl_options main "string list" "+no_sslv2 +no_sslv3 +single_dh_use +no_ticket +no_renegotiation"
16899 .cindex "OpenSSL "compatibility options"
16900 This option allows an administrator to adjust the SSL options applied
16901 by OpenSSL to connections.  It is given as a space-separated list of items,
16902 each one to be +added or -subtracted from the current value.
16903
16904 This option is only available if Exim is built against OpenSSL.  The values
16905 available for this option vary according to the age of your OpenSSL install.
16906 The &"all"& value controls a subset of flags which are available, typically
16907 the bug workaround options.  The &'SSL_CTX_set_options'& man page will
16908 list the values known on your system and Exim should support all the
16909 &"bug workaround"& options and many of the &"modifying"& options.  The Exim
16910 names lose the leading &"SSL_OP_"& and are lower-cased.
16911
16912 Note that adjusting the options can have severe impact upon the security of
16913 SSL as used by Exim.  It is possible to disable safety checks and shoot
16914 yourself in the foot in various unpleasant ways.  This option should not be
16915 adjusted lightly.  An unrecognised item will be detected at startup, by
16916 invoking Exim with the &%-bV%& flag.
16917
16918 The option affects Exim operating both as a server and as a client.
16919
16920 Historical note: prior to release 4.80, Exim defaulted this value to
16921 "+dont_insert_empty_fragments", which may still be needed for compatibility
16922 with some clients, but which lowers security by increasing exposure to
16923 some now infamous attacks.
16924
16925 Examples:
16926 .code
16927 # Make both old MS and old Eudora happy:
16928 openssl_options = -all +microsoft_big_sslv3_buffer \
16929                        +dont_insert_empty_fragments
16930
16931 # Disable older protocol versions:
16932 openssl_options = +no_sslv2 +no_sslv3
16933 .endd
16934
16935 Possible options may include:
16936 .ilist
16937 &`all`&
16938 .next
16939 &`allow_unsafe_legacy_renegotiation`&
16940 .next
16941 &`cipher_server_preference`&
16942 .next
16943 &`dont_insert_empty_fragments`&
16944 .next
16945 &`ephemeral_rsa`&
16946 .next
16947 &`legacy_server_connect`&
16948 .next
16949 &`microsoft_big_sslv3_buffer`&
16950 .next
16951 &`microsoft_sess_id_bug`&
16952 .next
16953 &`msie_sslv2_rsa_padding`&
16954 .next
16955 &`netscape_challenge_bug`&
16956 .next
16957 &`netscape_reuse_cipher_change_bug`&
16958 .next
16959 &`no_compression`&
16960 .next
16961 &`no_session_resumption_on_renegotiation`&
16962 .next
16963 &`no_sslv2`&
16964 .next
16965 &`no_sslv3`&
16966 .next
16967 &`no_ticket`&
16968 .next
16969 &`no_tlsv1`&
16970 .next
16971 &`no_tlsv1_1`&
16972 .next
16973 &`no_tlsv1_2`&
16974 .next
16975 &`safari_ecdhe_ecdsa_bug`&
16976 .next
16977 &`single_dh_use`&
16978 .next
16979 &`single_ecdh_use`&
16980 .next
16981 &`ssleay_080_client_dh_bug`&
16982 .next
16983 &`sslref2_reuse_cert_type_bug`&
16984 .next
16985 &`tls_block_padding_bug`&
16986 .next
16987 &`tls_d5_bug`&
16988 .next
16989 &`tls_rollback_bug`&
16990 .endlist
16991
16992 As an aside, the &`safari_ecdhe_ecdsa_bug`& item is a misnomer and affects
16993 all clients connecting using the MacOS SecureTransport TLS facility prior
16994 to MacOS 10.8.4, including email clients.  If you see old MacOS clients failing
16995 to negotiate TLS then this option value might help, provided that your OpenSSL
16996 release is new enough to contain this work-around.  This may be a situation
16997 where you have to upgrade OpenSSL to get buggy clients working.
16998
16999
17000 .option oracle_servers main "string list" unset
17001 .cindex "Oracle" "server list"
17002 This option provides a list of Oracle servers and associated connection data,
17003 to be used in conjunction with &(oracle)& lookups (see section &<<SECID72>>&).
17004 The option is available only if Exim has been built with Oracle support.
17005
17006
17007 .option panic_coredump main boolean false
17008 This option is rarely needed but can help for some debugging investigations.
17009 If set, when an internal error is detected by Exim which is sufficient
17010 to terminate the process
17011 (all such are logged in the paniclog)
17012 then a coredump is requested.
17013
17014 Note that most systems require additional administrative configuration
17015 to permit write a core file for a setuid program, which is Exim's
17016 common installed configuration.
17017
17018 .option percent_hack_domains main "domain list&!!" unset
17019 .cindex "&""percent hack""&"
17020 .cindex "source routing" "in email address"
17021 .cindex "address" "source-routed"
17022 The &"percent hack"& is the convention whereby a local part containing a
17023 percent sign is re-interpreted as a new email address, with the percent
17024 replaced by @. This is sometimes called &"source routing"&, though that term is
17025 also applied to RFC 2822 addresses that begin with an @ character. If this
17026 option is set, Exim implements the percent facility for those domains listed,
17027 but no others. This happens before an incoming SMTP address is tested against
17028 an ACL.
17029
17030 &*Warning*&: The &"percent hack"& has often been abused by people who are
17031 trying to get round relaying restrictions. For this reason, it is best avoided
17032 if at all possible. Unfortunately, a number of less security-conscious MTAs
17033 implement it unconditionally. If you are running Exim on a gateway host, and
17034 routing mail through to internal MTAs without processing the local parts, it is
17035 a good idea to reject recipient addresses with percent characters in their
17036 local parts. Exim's default configuration does this.
17037
17038
17039 .options perl_at_start main boolean false &&&
17040          perl_startup main string unset
17041 .cindex "Perl"
17042 These options are available only when Exim is built with an embedded Perl
17043 interpreter. See chapter &<<CHAPperl>>& for details of their use.
17044
17045 .option perl_taintmode main boolean false
17046 .cindex "Perl"
17047 This option enables the taint mode of the embedded Perl interpreter.
17048
17049
17050 .option pgsql_servers main "string list" unset
17051 .cindex "PostgreSQL lookup type" "server list"
17052 This option provides a list of PostgreSQL servers and associated connection
17053 data, to be used in conjunction with &(pgsql)& lookups (see section
17054 &<<SECID72>>&). The option is available only if Exim has been built with
17055 PostgreSQL support.
17056
17057
17058 .option pid_file_path main string&!! "set at compile time"
17059 .cindex "daemon" "pid file path"
17060 .cindex "pid file, path for"
17061 This option sets the name of the file to which the Exim daemon writes its
17062 process id. The string is expanded, so it can contain, for example, references
17063 to the host name:
17064 .code
17065 pid_file_path = /var/log/$primary_hostname/exim.pid
17066 .endd
17067 If no path is set, the pid is written to the file &_exim-daemon.pid_& in Exim's
17068 spool directory.
17069 The value set by the option can be overridden by the &%-oP%& command line
17070 option. A pid file is not written if a &"non-standard"& daemon is run by means
17071 of the &%-oX%& option, unless a path is explicitly supplied by &%-oP%&.
17072
17073
17074 .option pipelining_advertise_hosts main "host list&!!" *
17075 .cindex "PIPELINING" "suppressing advertising"
17076 .cindex "ESMTP extensions" PIPELINING
17077 This option can be used to suppress the advertisement of the SMTP
17078 PIPELINING extension to specific hosts. See also the &*no_pipelining*&
17079 control in section &<<SECTcontrols>>&. When PIPELINING is not advertised and
17080 &%smtp_enforce_sync%& is true, an Exim server enforces strict synchronization
17081 for each SMTP command and response. When PIPELINING is advertised, Exim assumes
17082 that clients will use it; &"out of order"& commands that are &"expected"& do
17083 not count as protocol errors (see &%smtp_max_synprot_errors%&).
17084
17085 .option pipelining_connect_advertise_hosts main "host list&!!" *
17086 .cindex "pipelining" "early connection"
17087 .cindex "pipelining" PIPECONNECT
17088 .cindex "ESMTP extensions" PIPECONNECT
17089 If Exim is built without the DISABLE_PIPE_CONNECT build option
17090 this option controls which hosts the facility is advertised to
17091 and from which pipeline early-connection (before MAIL) SMTP
17092 commands are acceptable.
17093 When used, the pipelining saves on roundtrip times.
17094
17095 See also the &%hosts_pipe_connect%& smtp transport option.
17096
17097 The SMTP service extension keyword advertised is &"PIPECONNECT"&;
17098 it permits the client to pipeline
17099 TCP connection and hello command (inclear phase),
17100 or TLS-establishment and hello command (encrypted phase),
17101 on later connections to the same host.
17102
17103
17104 .option prdr_enable main boolean false
17105 .cindex "PRDR" "enabling on server"
17106 .cindex "ESMTP extensions" PRDR
17107 This option can be used to enable the Per-Recipient Data Response extension
17108 to SMTP, defined by Eric Hall.
17109 If the option is set, PRDR is advertised by Exim when operating as a server.
17110 If the client requests PRDR, and more than one recipient, for a message
17111 an additional ACL is called for each recipient after the message content
17112 is received.  See section &<<SECTPRDRACL>>&.
17113
17114 .option preserve_message_logs main boolean false
17115 .cindex "message logs" "preserving"
17116 If this option is set, message log files are not deleted when messages are
17117 completed. Instead, they are moved to a sub-directory of the spool directory
17118 called &_msglog.OLD_&, where they remain available for statistical or debugging
17119 purposes. This is a dangerous option to set on systems with any appreciable
17120 volume of mail. Use with care!
17121
17122
17123 .option primary_hostname main string "see below"
17124 .cindex "name" "of local host"
17125 .cindex "host" "name of local"
17126 .cindex "local host" "name of"
17127 .vindex "&$primary_hostname$&"
17128 This specifies the name of the current host. It is used in the default EHLO or
17129 HELO command for outgoing SMTP messages (changeable via the &%helo_data%&
17130 option in the &(smtp)& transport), and as the default for &%qualify_domain%&.
17131 The value is also used by default in some SMTP response messages from an Exim
17132 server. This can be changed dynamically by setting &%smtp_active_hostname%&.
17133
17134 If &%primary_hostname%& is not set, Exim calls &[uname()]& to find the host
17135 name. If this fails, Exim panics and dies. If the name returned by &[uname()]&
17136 contains only one component, Exim passes it to &[gethostbyname()]& (or
17137 &[getipnodebyname()]& when available) in order to obtain the fully qualified
17138 version. The variable &$primary_hostname$& contains the host name, whether set
17139 explicitly by this option, or defaulted.
17140
17141
17142 .option print_topbitchars main boolean false
17143 .cindex "printing characters"
17144 .cindex "8-bit characters"
17145 By default, Exim considers only those characters whose codes lie in the range
17146 32&--126 to be printing characters. In a number of circumstances (for example,
17147 when writing log entries) non-printing characters are converted into escape
17148 sequences, primarily to avoid messing up the layout. If &%print_topbitchars%&
17149 is set, code values of 128 and above are also considered to be printing
17150 characters.
17151
17152 This option also affects the header syntax checks performed by the
17153 &(autoreply)& transport, and whether Exim uses RFC 2047 encoding of
17154 the user's full name when constructing From: and Sender: addresses (as
17155 described in section &<<SECTconstr>>&). Setting this option can cause
17156 Exim to generate eight bit message headers that do not conform to the
17157 standards.
17158
17159
17160 .option process_log_path main string unset
17161 .cindex "process log path"
17162 .cindex "log" "process log"
17163 .cindex "&'exiwhat'&"
17164 This option sets the name of the file to which an Exim process writes its
17165 &"process log"& when sent a USR1 signal. This is used by the &'exiwhat'&
17166 utility script. If this option is unset, the file called &_exim-process.info_&
17167 in Exim's spool directory is used. The ability to specify the name explicitly
17168 can be useful in environments where two different Exims are running, using
17169 different spool directories.
17170
17171
17172 .option prod_requires_admin main boolean true
17173 .cindex "restricting access to features"
17174 .oindex "&%-M%&"
17175 .oindex "&%-R%&"
17176 .oindex "&%-q%&"
17177 The &%-M%&, &%-R%&, and &%-q%& command-line options require the caller to be an
17178 admin user unless &%prod_requires_admin%& is set false. See also
17179 &%queue_list_requires_admin%& and &%commandline_checks_require_admin%&.
17180
17181
17182 .option proxy_protocol_timeout main time 3s
17183 .cindex proxy "proxy protocol"
17184 This option sets the timeout for proxy protocol negotiation.
17185 For details see section &<<SECTproxyInbound>>&.
17186
17187
17188 .option qualify_domain main string "see below"
17189 .cindex "domain" "for qualifying addresses"
17190 .cindex "address" "qualification"
17191 This option specifies the domain name that is added to any envelope sender
17192 addresses that do not have a domain qualification. It also applies to
17193 recipient addresses if &%qualify_recipient%& is not set. Unqualified addresses
17194 are accepted by default only for locally-generated messages. Qualification is
17195 also applied to addresses in header lines such as &'From:'& and &'To:'& for
17196 locally-generated messages, unless the &%-bnq%& command line option is used.
17197
17198 Messages from external sources must always contain fully qualified addresses,
17199 unless the sending host matches &%sender_unqualified_hosts%& or
17200 &%recipient_unqualified_hosts%& (as appropriate), in which case incoming
17201 addresses are qualified with &%qualify_domain%& or &%qualify_recipient%& as
17202 necessary. Internally, Exim always works with fully qualified envelope
17203 addresses. If &%qualify_domain%& is not set, it defaults to the
17204 &%primary_hostname%& value.
17205
17206
17207 .option qualify_recipient main string "see below"
17208 This option allows you to specify a different domain for qualifying recipient
17209 addresses to the one that is used for senders. See &%qualify_domain%& above.
17210
17211
17212
17213 .option queue_domains main "domain list&!!" unset
17214 .cindex "domain" "specifying non-immediate delivery"
17215 .cindex "queueing incoming messages"
17216 .cindex "message" "queueing certain domains"
17217 This option lists domains for which immediate delivery is not required.
17218 A delivery process is started whenever a message is received, but only those
17219 domains that do not match are processed. All other deliveries wait until the
17220 next queue run. See also &%hold_domains%& and &%queue_smtp_domains%&.
17221
17222
17223 .option queue_fast_ramp main boolean true
17224 .cindex "queue runner" "two phase"
17225 .cindex "queue" "double scanning"
17226 If set to true, two-phase queue runs, initiated using &%-qq%& on the
17227 command line, may start parallel delivery processes during their first
17228 phase.  This will be done when a threshold number of messages have been
17229 routed for a single host.
17230
17231
17232 .option queue_list_requires_admin main boolean true
17233 .cindex "restricting access to features"
17234 .oindex "&%-bp%&"
17235 The &%-bp%& command-line option, which lists the messages that are on the
17236 queue, requires the caller to be an admin user unless
17237 &%queue_list_requires_admin%& is set false.
17238 See also &%prod_requires_admin%& and &%commandline_checks_require_admin%&.
17239
17240
17241 .option queue_only main boolean false
17242 .cindex "queueing incoming messages"
17243 .cindex "message" "queueing unconditionally"
17244 If &%queue_only%& is set, a delivery process is not automatically started
17245 whenever a message is received. Instead, the message waits in the queue for the
17246 next queue run. Even if &%queue_only%& is false, incoming messages may not get
17247 delivered immediately when certain conditions (such as heavy load) occur.
17248
17249 The &%-odq%& command line has the same effect as &%queue_only%&. The &%-odb%&
17250 and &%-odi%& command line options override &%queue_only%& unless
17251 &%queue_only_override%& is set false. See also &%queue_only_file%&,
17252 &%queue_only_load%&, and &%smtp_accept_queue%&.
17253
17254
17255 .option queue_only_file main "string list" unset
17256 .cindex "queueing incoming messages"
17257 .cindex "message" "queueing by file existence"
17258 This option can be set to a colon-separated list of absolute path names, each
17259 one optionally preceded by &"smtp"&. When Exim is receiving a message,
17260 it tests for the existence of each listed path using a call to &[stat()]&. For
17261 each path that exists, the corresponding queueing option is set.
17262 For paths with no prefix, &%queue_only%& is set; for paths prefixed by
17263 &"smtp"&, &%queue_smtp_domains%& is set to match all domains. So, for example,
17264 .code
17265 queue_only_file = smtp/some/file
17266 .endd
17267 causes Exim to behave as if &%queue_smtp_domains%& were set to &"*"& whenever
17268 &_/some/file_& exists.
17269
17270
17271 .option queue_only_load main fixed-point unset
17272 .cindex "load average"
17273 .cindex "queueing incoming messages"
17274 .cindex "message" "queueing by load"
17275 If the system load average is higher than this value, incoming messages from
17276 all sources are queued, and no automatic deliveries are started. If this
17277 happens during local or remote SMTP input, all subsequent messages received on
17278 the same SMTP connection are queued by default, whatever happens to the load in
17279 the meantime, but this can be changed by setting &%queue_only_load_latch%&
17280 false.
17281
17282 Deliveries will subsequently be performed by queue runner processes. This
17283 option has no effect on ancient operating systems on which Exim cannot
17284 determine the load average. See also &%deliver_queue_load_max%& and
17285 &%smtp_load_reserve%&.
17286
17287
17288 .option queue_only_load_latch main boolean true
17289 .cindex "load average" "re-evaluating per message"
17290 When this option is true (the default), once one message has been queued
17291 because the load average is higher than the value set by &%queue_only_load%&,
17292 all subsequent messages received on the same SMTP connection are also queued.
17293 This is a deliberate choice; even though the load average may fall below the
17294 threshold, it doesn't seem right to deliver later messages on the same
17295 connection when not delivering earlier ones. However, there are special
17296 circumstances such as very long-lived connections from scanning appliances
17297 where this is not the best strategy. In such cases, &%queue_only_load_latch%&
17298 should be set false. This causes the value of the load average to be
17299 re-evaluated for each message.
17300
17301
17302 .option queue_only_override main boolean true
17303 .cindex "queueing incoming messages"
17304 When this option is true, the &%-od%&&'x'& command line options override the
17305 setting of &%queue_only%& or &%queue_only_file%& in the configuration file. If
17306 &%queue_only_override%& is set false, the &%-od%&&'x'& options cannot be used
17307 to override; they are accepted, but ignored.
17308
17309
17310 .option queue_run_in_order main boolean false
17311 .cindex "queue runner" "processing messages in order"
17312 If this option is set, queue runs happen in order of message arrival instead of
17313 in an arbitrary order. For this to happen, a complete list of the entire queue
17314 must be set up before the deliveries start. When the queue is all held in a
17315 single directory (the default), a single list is created for both the ordered
17316 and the non-ordered cases. However, if &%split_spool_directory%& is set, a
17317 single list is not created when &%queue_run_in_order%& is false. In this case,
17318 the sub-directories are processed one at a time (in a random order), and this
17319 avoids setting up one huge list for the whole queue. Thus, setting
17320 &%queue_run_in_order%& with &%split_spool_directory%& may degrade performance
17321 when the queue is large, because of the extra work in setting up the single,
17322 large list. In most situations, &%queue_run_in_order%& should not be set.
17323
17324
17325
17326 .option queue_run_max main integer&!! 5
17327 .cindex "queue runner" "maximum number of"
17328 This controls the maximum number of queue runner processes that an Exim daemon
17329 can run simultaneously. This does not mean that it starts them all at once,
17330 but rather that if the maximum number are still running when the time comes to
17331 start another one, it refrains from starting another one. This can happen with
17332 very large queues and/or very sluggish deliveries. This option does not,
17333 however, interlock with other processes, so additional queue runners can be
17334 started by other means, or by killing and restarting the daemon.
17335
17336 Setting this option to zero does not suppress queue runs; rather, it disables
17337 the limit, allowing any number of simultaneous queue runner processes to be
17338 run. If you do not want queue runs to occur, omit the &%-q%&&'xx'& setting on
17339 the daemon's command line.
17340
17341 .cindex queues named
17342 .cindex "named queues" "resource limit"
17343 To set limits for different named queues use
17344 an expansion depending on the &$queue_name$& variable.
17345
17346 .option queue_smtp_domains main "domain list&!!" unset
17347 .cindex "queueing incoming messages"
17348 .cindex "message" "queueing remote deliveries"
17349 .cindex "first pass routing"
17350 When this option is set, a delivery process is started whenever a message is
17351 received, routing is performed, and local deliveries take place.
17352 However, if any SMTP deliveries are required for domains that match
17353 &%queue_smtp_domains%&, they are not immediately delivered, but instead the
17354 message waits in the queue for the next queue run. Since routing of the message
17355 has taken place, Exim knows to which remote hosts it must be delivered, and so
17356 when the queue run happens, multiple messages for the same host are delivered
17357 over a single SMTP connection. The &%-odqs%& command line option causes all
17358 SMTP deliveries to be queued in this way, and is equivalent to setting
17359 &%queue_smtp_domains%& to &"*"&. See also &%hold_domains%& and
17360 &%queue_domains%&.
17361
17362
17363 .option receive_timeout main time 0s
17364 .cindex "timeout" "for non-SMTP input"
17365 This option sets the timeout for accepting a non-SMTP message, that is, the
17366 maximum time that Exim waits when reading a message on the standard input. If
17367 the value is zero, it will wait forever. This setting is overridden by the
17368 &%-or%& command line option. The timeout for incoming SMTP messages is
17369 controlled by &%smtp_receive_timeout%&.
17370
17371 .option received_header_text main string&!! "see below"
17372 .cindex "customizing" "&'Received:'& header"
17373 .cindex "&'Received:'& header line" "customizing"
17374 This string defines the contents of the &'Received:'& message header that is
17375 added to each message, except for the timestamp, which is automatically added
17376 on at the end (preceded by a semicolon). The string is expanded each time it is
17377 used. If the expansion yields an empty string, no &'Received:'& header line is
17378 added to the message. Otherwise, the string should start with the text
17379 &"Received:"& and conform to the RFC 2822 specification for &'Received:'&
17380 header lines.
17381 The default setting is:
17382
17383 .code
17384 received_header_text = Received: \
17385   ${if def:sender_rcvhost {from $sender_rcvhost\n\t}\
17386     {${if def:sender_ident \
17387       {from ${quote_local_part:$sender_ident} }}\
17388         ${if def:sender_helo_name {(helo=$sender_helo_name)\n\t}}}}\
17389   by $primary_hostname \
17390   ${if def:received_protocol {with $received_protocol }}\
17391   ${if def:tls_in_ver        { ($tls_in_ver)}}\
17392   ${if def:tls_in_cipher_std { tls $tls_in_cipher_std\n\t}}\
17393   (Exim $version_number)\n\t\
17394   ${if def:sender_address \
17395   {(envelope-from <$sender_address>)\n\t}}\
17396   id $message_exim_id\
17397   ${if def:received_for {\n\tfor $received_for}}
17398 .endd
17399
17400 The references to the TLS version and cipher are
17401 omitted when Exim is built without TLS
17402 support. The use of conditional expansions ensures that this works for both
17403 locally generated messages and messages received from remote hosts, giving
17404 header lines such as the following:
17405 .code
17406 Received: from scrooge.carol.example ([192.168.12.25] ident=root)
17407 by marley.carol.example with esmtp (Exim 4.00)
17408 (envelope-from <bob@carol.example>)
17409 id 16IOWa-00019l-00
17410 for chas@dickens.example; Tue, 25 Dec 2001 14:43:44 +0000
17411 Received: by scrooge.carol.example with local (Exim 4.00)
17412 id 16IOWW-000083-00; Tue, 25 Dec 2001 14:43:41 +0000
17413 .endd
17414 Until the body of the message has been received, the timestamp is the time when
17415 the message started to be received. Once the body has arrived, and all policy
17416 checks have taken place, the timestamp is updated to the time at which the
17417 message was accepted.
17418
17419
17420 .option received_headers_max main integer 30
17421 .cindex "loop" "prevention"
17422 .cindex "mail loop prevention"
17423 .cindex "&'Received:'& header line" "counting"
17424 When a message is to be delivered, the number of &'Received:'& headers is
17425 counted, and if it is greater than this parameter, a mail loop is assumed to
17426 have occurred, the delivery is abandoned, and an error message is generated.
17427 This applies to both local and remote deliveries.
17428
17429
17430 .option recipient_unqualified_hosts main "host list&!!" unset
17431 .cindex "unqualified addresses"
17432 .cindex "host" "unqualified addresses from"
17433 This option lists those hosts from which Exim is prepared to accept unqualified
17434 recipient addresses in message envelopes. The addresses are made fully
17435 qualified by the addition of the &%qualify_recipient%& value. This option also
17436 affects message header lines. Exim does not reject unqualified recipient
17437 addresses in headers, but it qualifies them only if the message came from a
17438 host that matches &%recipient_unqualified_hosts%&,
17439 or if the message was submitted locally (not using TCP/IP), and the &%-bnq%&
17440 option was not set.
17441
17442
17443 .option recipients_max main integer 50000
17444 .cindex "limit" "number of recipients"
17445 .cindex "recipient" "maximum number"
17446 If this option is set greater than zero, it specifies the maximum number of
17447 original recipients for any message. Additional recipients that are generated
17448 by aliasing or forwarding do not count. SMTP messages get a 452 response for
17449 all recipients over the limit; earlier recipients are delivered as normal.
17450 Non-SMTP messages with too many recipients are failed, and no deliveries are
17451 done.
17452
17453 .cindex "RCPT" "maximum number of incoming"
17454 &*Note*&: The RFCs specify that an SMTP server should accept at least 100
17455 RCPT commands in a single message.
17456
17457
17458 .option recipients_max_reject main boolean false
17459 If this option is set true, Exim rejects SMTP messages containing too many
17460 recipients by giving 552 errors to the surplus RCPT commands, and a 554
17461 error to the eventual DATA command. Otherwise (the default) it gives a 452
17462 error to the surplus RCPT commands and accepts the message on behalf of the
17463 initial set of recipients. The remote server should then re-send the message
17464 for the remaining recipients at a later time.
17465
17466
17467 .option remote_max_parallel main integer 4
17468 .cindex "delivery" "parallelism for remote"
17469 This option controls parallel delivery of one message to a number of remote
17470 hosts. If the value is less than 2, parallel delivery is disabled, and Exim
17471 does all the remote deliveries for a message one by one. Otherwise, if a single
17472 message has to be delivered to more than one remote host, or if several copies
17473 have to be sent to the same remote host, up to &%remote_max_parallel%&
17474 deliveries are done simultaneously. If more than &%remote_max_parallel%&
17475 deliveries are required, the maximum number of processes are started, and as
17476 each one finishes, another is begun. The order of starting processes is the
17477 same as if sequential delivery were being done, and can be controlled by the
17478 &%remote_sort_domains%& option. If parallel delivery takes place while running
17479 with debugging turned on, the debugging output from each delivery process is
17480 tagged with its process id.
17481
17482 This option controls only the maximum number of parallel deliveries for one
17483 message in one Exim delivery process. Because Exim has no central queue
17484 manager, there is no way of controlling the total number of simultaneous
17485 deliveries if the configuration allows a delivery attempt as soon as a message
17486 is received.
17487
17488 See also the &%max_parallel%& generic transport option,
17489 and the &%serialize_hosts%& smtp transport option.
17490
17491 .cindex "number of deliveries"
17492 .cindex "delivery" "maximum number of"
17493 If you want to control the total number of deliveries on the system, you
17494 need to set the &%queue_only%& option. This ensures that all incoming messages
17495 are added to the queue without starting a delivery process. Then set up an Exim
17496 daemon to start queue runner processes at appropriate intervals (probably
17497 fairly often, for example, every minute), and limit the total number of queue
17498 runners by setting the &%queue_run_max%& parameter. Because each queue runner
17499 delivers only one message at a time, the maximum number of deliveries that can
17500 then take place at once is &%queue_run_max%& multiplied by
17501 &%remote_max_parallel%&.
17502
17503 If it is purely remote deliveries you want to control, use
17504 &%queue_smtp_domains%& instead of &%queue_only%&. This has the added benefit of
17505 doing the SMTP routing before queueing, so that several messages for the same
17506 host will eventually get delivered down the same connection.
17507
17508
17509 .option remote_sort_domains main "domain list&!!" unset
17510 .cindex "sorting remote deliveries"
17511 .cindex "delivery" "sorting remote"
17512 When there are a number of remote deliveries for a message, they are sorted by
17513 domain into the order given by this list. For example,
17514 .code
17515 remote_sort_domains = *.cam.ac.uk:*.uk
17516 .endd
17517 would attempt to deliver to all addresses in the &'cam.ac.uk'& domain first,
17518 then to those in the &%uk%& domain, then to any others.
17519
17520
17521 .option retry_data_expire main time 7d
17522 .cindex "hints database" "data expiry"
17523 This option sets a &"use before"& time on retry information in Exim's hints
17524 database. Any older retry data is ignored. This means that, for example, once a
17525 host has not been tried for 7 days, Exim behaves as if it has no knowledge of
17526 past failures.
17527
17528
17529 .option retry_interval_max main time 24h
17530 .cindex "retry" "limit on interval"
17531 .cindex "limit" "on retry interval"
17532 Chapter &<<CHAPretry>>& describes Exim's mechanisms for controlling the
17533 intervals between delivery attempts for messages that cannot be delivered
17534 straight away. This option sets an overall limit to the length of time between
17535 retries. It cannot be set greater than 24 hours; any attempt to do so forces
17536 the default value.
17537
17538
17539 .option return_path_remove main boolean true
17540 .cindex "&'Return-path:'& header line" "removing"
17541 RFC 2821, section 4.4, states that an SMTP server must insert a
17542 &'Return-path:'& header line into a message when it makes a &"final delivery"&.
17543 The &'Return-path:'& header preserves the sender address as received in the
17544 MAIL command. This description implies that this header should not be present
17545 in an incoming message. If &%return_path_remove%& is true, any existing
17546 &'Return-path:'& headers are removed from messages at the time they are
17547 received. Exim's transports have options for adding &'Return-path:'& headers at
17548 the time of delivery. They are normally used only for final local deliveries.
17549
17550
17551 .option return_size_limit main integer 100K
17552 This option is an obsolete synonym for &%bounce_return_size_limit%&.
17553
17554
17555 .option rfc1413_hosts main "host list&!!" @[]
17556 .cindex "RFC 1413"
17557 .cindex "host" "for RFC 1413 calls"
17558 RFC 1413 identification calls are made to any client host which matches
17559 an item in the list.
17560 The default value specifies just this host, being any local interface
17561 for the system.
17562
17563 .option rfc1413_query_timeout main time 0s
17564 .cindex "RFC 1413" "query timeout"
17565 .cindex "timeout" "for RFC 1413 call"
17566 This sets the timeout on RFC 1413 identification calls. If it is set to zero,
17567 no RFC 1413 calls are ever made.
17568
17569
17570 .option sender_unqualified_hosts main "host list&!!" unset
17571 .cindex "unqualified addresses"
17572 .cindex "host" "unqualified addresses from"
17573 This option lists those hosts from which Exim is prepared to accept unqualified
17574 sender addresses. The addresses are made fully qualified by the addition of
17575 &%qualify_domain%&. This option also affects message header lines. Exim does
17576 not reject unqualified addresses in headers that contain sender addresses, but
17577 it qualifies them only if the message came from a host that matches
17578 &%sender_unqualified_hosts%&, or if the message was submitted locally (not
17579 using TCP/IP), and the &%-bnq%& option was not set.
17580
17581
17582 .option slow_lookup_log main integer 0
17583 .cindex "logging" "slow lookups"
17584 .cindex "dns" "logging slow lookups"
17585 This option controls logging of slow lookups.
17586 If the value is nonzero it is taken as a number of milliseconds
17587 and lookups taking longer than this are logged.
17588 Currently this applies only to DNS lookups.
17589
17590
17591
17592 .option smtp_accept_keepalive main boolean true
17593 .cindex "keepalive" "on incoming connection"
17594 This option controls the setting of the SO_KEEPALIVE option on incoming
17595 TCP/IP socket connections. When set, it causes the kernel to probe idle
17596 connections periodically, by sending packets with &"old"& sequence numbers. The
17597 other end of the connection should send an acknowledgment if the connection is
17598 still okay or a reset if the connection has been aborted. The reason for doing
17599 this is that it has the beneficial effect of freeing up certain types of
17600 connection that can get stuck when the remote host is disconnected without
17601 tidying up the TCP/IP call properly. The keepalive mechanism takes several
17602 hours to detect unreachable hosts.
17603
17604
17605
17606 .option smtp_accept_max main integer 20
17607 .cindex "limit" "incoming SMTP connections"
17608 .cindex "SMTP" "incoming connection count"
17609 .cindex "inetd"
17610 This option specifies the maximum number of simultaneous incoming SMTP calls
17611 that Exim will accept. It applies only to the listening daemon; there is no
17612 control (in Exim) when incoming SMTP is being handled by &'inetd'&. If the
17613 value is set to zero, no limit is applied. However, it is required to be
17614 non-zero if either &%smtp_accept_max_per_host%& or &%smtp_accept_queue%& is
17615 set. See also &%smtp_accept_reserve%& and &%smtp_load_reserve%&.
17616
17617 A new SMTP connection is immediately rejected if the &%smtp_accept_max%& limit
17618 has been reached. If not, Exim first checks &%smtp_accept_max_per_host%&. If
17619 that limit has not been reached for the client host, &%smtp_accept_reserve%&
17620 and &%smtp_load_reserve%& are then checked before accepting the connection.
17621
17622
17623 .option smtp_accept_max_nonmail main integer 10
17624 .cindex "limit" "non-mail SMTP commands"
17625 .cindex "SMTP" "limiting non-mail commands"
17626 Exim counts the number of &"non-mail"& commands in an SMTP session, and drops
17627 the connection if there are too many. This option defines &"too many"&. The
17628 check catches some denial-of-service attacks, repeated failing AUTHs, or a mad
17629 client looping sending EHLO, for example. The check is applied only if the
17630 client host matches &%smtp_accept_max_nonmail_hosts%&.
17631
17632 When a new message is expected, one occurrence of RSET is not counted. This
17633 allows a client to send one RSET between messages (this is not necessary,
17634 but some clients do it). Exim also allows one uncounted occurrence of HELO
17635 or EHLO, and one occurrence of STARTTLS between messages. After
17636 starting up a TLS session, another EHLO is expected, and so it too is not
17637 counted. The first occurrence of AUTH in a connection, or immediately
17638 following STARTTLS is not counted. Otherwise, all commands other than
17639 MAIL, RCPT, DATA, and QUIT are counted.
17640
17641
17642 .option smtp_accept_max_nonmail_hosts main "host list&!!" *
17643 You can control which hosts are subject to the &%smtp_accept_max_nonmail%&
17644 check by setting this option. The default value makes it apply to all hosts. By
17645 changing the value, you can exclude any badly-behaved hosts that you have to
17646 live with.
17647
17648
17649 . Allow this long option name to split; give it unsplit as a fifth argument
17650 . for the automatic .oindex that is generated by .option.
17651 . We insert " &~&~" which is both pretty nasty visually and results in
17652 . non-searchable text.  HowItWorks.txt mentions an option for inserting
17653 . zero-width-space, which would be nicer visually and results in (at least)
17654 . html that Firefox will split on when it's forced to reflow (rather than
17655 . inserting a horizontal scrollbar).  However, the text is still not
17656 . searchable.  NM changed this occurrence for bug 1197 to no longer allow
17657 . the option name to split.
17658
17659 .option "smtp_accept_max_per_connection" main integer&!! 1000 &&&
17660          smtp_accept_max_per_connection
17661 .cindex "SMTP" "limiting incoming message count"
17662 .cindex "limit" "messages per SMTP connection"
17663 The value of this option limits the number of MAIL commands that Exim is
17664 prepared to accept over a single SMTP connection, whether or not each command
17665 results in the transfer of a message. After the limit is reached, a 421
17666 response is given to subsequent MAIL commands. This limit is a safety
17667 precaution against a client that goes mad (incidents of this type have been
17668 seen).
17669 The option is expanded after the HELO or EHLO is received
17670 and may depend on values available at that time.
17671 An empty or zero value after expansion removes the limit.
17672
17673
17674 .option smtp_accept_max_per_host main string&!! unset
17675 .cindex "limit" "SMTP connections from one host"
17676 .cindex "host" "limiting SMTP connections from"
17677 This option restricts the number of simultaneous IP connections from a single
17678 host (strictly, from a single IP address) to the Exim daemon. The option is
17679 expanded, to enable different limits to be applied to different hosts by
17680 reference to &$sender_host_address$&. Once the limit is reached, additional
17681 connection attempts from the same host are rejected with error code 421. This
17682 is entirely independent of &%smtp_accept_reserve%&. The option's default value
17683 of zero imposes no limit. If this option is set greater than zero, it is
17684 required that &%smtp_accept_max%& be non-zero.
17685
17686 &*Warning*&: When setting this option you should not use any expansion
17687 constructions that take an appreciable amount of time. The expansion and test
17688 happen in the main daemon loop, in order to reject additional connections
17689 without forking additional processes (otherwise a denial-of-service attack
17690 could cause a vast number or processes to be created). While the daemon is
17691 doing this processing, it cannot accept any other incoming connections.
17692
17693
17694
17695 .option smtp_accept_queue main integer 0
17696 .cindex "SMTP" "incoming connection count"
17697 .cindex "queueing incoming messages"
17698 .cindex "message" "queueing by SMTP connection count"
17699 If the number of simultaneous incoming SMTP connections being handled via the
17700 listening daemon exceeds this value, messages received by SMTP are just placed
17701 in the queue; no delivery processes are started automatically. The count is
17702 fixed at the start of an SMTP connection. It cannot be updated in the
17703 subprocess that receives messages, and so the queueing or not queueing applies
17704 to all messages received in the same connection.
17705
17706 A value of zero implies no limit, and clearly any non-zero value is useful only
17707 if it is less than the &%smtp_accept_max%& value (unless that is zero). See
17708 also &%queue_only%&, &%queue_only_load%&, &%queue_smtp_domains%&, and the
17709 various &%-od%&&'x'& command line options.
17710
17711
17712 . See the comment on smtp_accept_max_per_connection
17713
17714 .option "smtp_accept_queue_per_connection" main integer 10 &&&
17715          smtp_accept_queue_per_connection
17716 .cindex "queueing incoming messages"
17717 .cindex "message" "queueing by message count"
17718 This option limits the number of delivery processes that Exim starts
17719 automatically when receiving messages via SMTP, whether via the daemon or by
17720 the use of &%-bs%& or &%-bS%&. If the value of the option is greater than zero,
17721 and the number of messages received in a single SMTP session exceeds this
17722 number, subsequent messages are placed in the queue, but no delivery processes
17723 are started. This helps to limit the number of Exim processes when a server
17724 restarts after downtime and there is a lot of mail waiting for it on other
17725 systems. On large systems, the default should probably be increased, and on
17726 dial-in client systems it should probably be set to zero (that is, disabled).
17727
17728
17729 .option smtp_accept_reserve main integer 0
17730 .cindex "SMTP" "incoming call count"
17731 .cindex "host" "reserved"
17732 When &%smtp_accept_max%& is set greater than zero, this option specifies a
17733 number of SMTP connections that are reserved for connections from the hosts
17734 that are specified in &%smtp_reserve_hosts%&. The value set in
17735 &%smtp_accept_max%& includes this reserve pool. The specified hosts are not
17736 restricted to this number of connections; the option specifies a minimum number
17737 of connection slots for them, not a maximum. It is a guarantee that this group
17738 of hosts can always get at least &%smtp_accept_reserve%& connections. However,
17739 the limit specified by &%smtp_accept_max_per_host%& is still applied to each
17740 individual host.
17741
17742 For example, if &%smtp_accept_max%& is set to 50 and &%smtp_accept_reserve%& is
17743 set to 5, once there are 45 active connections (from any hosts), new
17744 connections are accepted only from hosts listed in &%smtp_reserve_hosts%&,
17745 provided the other criteria for acceptance are met.
17746
17747
17748 .option smtp_active_hostname main string&!! unset
17749 .cindex "host" "name in SMTP responses"
17750 .cindex "SMTP" "host name in responses"
17751 .vindex "&$primary_hostname$&"
17752 This option is provided for multi-homed servers that want to masquerade as
17753 several different hosts. At the start of an incoming SMTP connection, its value
17754 is expanded and used instead of the value of &$primary_hostname$& in SMTP
17755 responses. For example, it is used as domain name in the response to an
17756 incoming HELO or EHLO command.
17757
17758 .vindex "&$smtp_active_hostname$&"
17759 The active hostname is placed in the &$smtp_active_hostname$& variable, which
17760 is saved with any messages that are received. It is therefore available for use
17761 in routers and transports when the message is later delivered.
17762
17763 If this option is unset, or if its expansion is forced to fail, or if the
17764 expansion results in an empty string, the value of &$primary_hostname$& is
17765 used. Other expansion failures cause a message to be written to the main and
17766 panic logs, and the SMTP command receives a temporary error. Typically, the
17767 value of &%smtp_active_hostname%& depends on the incoming interface address.
17768 For example:
17769 .code
17770 smtp_active_hostname = ${if eq{$received_ip_address}{10.0.0.1}\
17771   {cox.mydomain}{box.mydomain}}
17772 .endd
17773
17774 Although &$smtp_active_hostname$& is primarily concerned with incoming
17775 messages, it is also used as the default for HELO commands in callout
17776 verification if there is no remote transport from which to obtain a
17777 &%helo_data%& value.
17778
17779 .option smtp_backlog_monitor main integer 0
17780 .cindex "connection backlog" monitoring
17781 If this option is set to greater than zero, and the backlog of available
17782 TCP connections on a socket listening for SMTP is larger than it, a line
17783 is logged giving the value and the socket address and port.
17784 The value is retrived jsut before an accept call.
17785 This facility is only available on Linux.
17786
17787 .option smtp_banner main string&!! "see below"
17788 .cindex "SMTP" "welcome banner"
17789 .cindex "banner for SMTP"
17790 .cindex "welcome banner for SMTP"
17791 .cindex "customizing" "SMTP banner"
17792 If a connect ACL does not supply a message,
17793 this string (which is expanded every time it is used) is output as the initial
17794 positive response to an SMTP connection. The default setting is:
17795 .code
17796 smtp_banner = $smtp_active_hostname ESMTP Exim \
17797   $version_number $tod_full
17798 .endd
17799 Failure to expand the string causes a panic error;
17800 a forced fail just closes the connection.
17801 If you want to create a
17802 multiline response to the initial SMTP connection, use &"\n"& in the string at
17803 appropriate points, but not at the end. Note that the 220 code is not included
17804 in this string. Exim adds it automatically (several times in the case of a
17805 multiline response).
17806
17807
17808 .option smtp_check_spool_space main boolean true
17809 .cindex "checking disk space"
17810 .cindex "disk space, checking"
17811 .cindex "spool directory" "checking space"
17812 When this option is set, if an incoming SMTP session encounters the SIZE
17813 option on a MAIL command, it checks that there is enough space in the
17814 spool directory's partition to accept a message of that size, while still
17815 leaving free the amount specified by &%check_spool_space%& (even if that value
17816 is zero). If there isn't enough space, a temporary error code is returned.
17817
17818
17819 .option smtp_connect_backlog main integer 20
17820 .cindex "connection backlog" "set maximum"
17821 .cindex "SMTP" "connection backlog"
17822 .cindex "backlog of connections"
17823 This option specifies a maximum number of waiting SMTP connections. Exim passes
17824 this value to the TCP/IP system when it sets up its listener. Once this number
17825 of connections are waiting for the daemon's attention, subsequent connection
17826 attempts are refused at the TCP/IP level. At least, that is what the manuals
17827 say; in some circumstances such connection attempts have been observed to time
17828 out instead. For large systems it is probably a good idea to increase the
17829 value (to 50, say). It also gives some protection against denial-of-service
17830 attacks by SYN flooding.
17831
17832
17833 .option smtp_enforce_sync main boolean true
17834 .cindex "SMTP" "synchronization checking"
17835 .cindex "synchronization checking in SMTP"
17836 The SMTP protocol specification requires the client to wait for a response from
17837 the server at certain points in the dialogue. Without PIPELINING these
17838 synchronization points are after every command; with PIPELINING they are
17839 fewer, but they still exist.
17840
17841 Some spamming sites send out a complete set of SMTP commands without waiting
17842 for any response. Exim protects against this by rejecting a message if the
17843 client has sent further input when it should not have. The error response &"554
17844 SMTP synchronization error"& is sent, and the connection is dropped. Testing
17845 for this error cannot be perfect because of transmission delays (unexpected
17846 input may be on its way but not yet received when Exim checks). However, it
17847 does detect many instances.
17848
17849 The check can be globally disabled by setting &%smtp_enforce_sync%& false.
17850 If you want to disable the check selectively (for example, only for certain
17851 hosts), you can do so by an appropriate use of a &%control%& modifier in an ACL
17852 (see section &<<SECTcontrols>>&). See also &%pipelining_advertise_hosts%&.
17853
17854
17855
17856 .option smtp_etrn_command main string&!! unset
17857 .cindex "ETRN" "command to be run"
17858 .cindex "ESMTP extensions" ETRN
17859 .vindex "&$domain$&"
17860 If this option is set, the given command is run whenever an SMTP ETRN
17861 command is received from a host that is permitted to issue such commands (see
17862 chapter &<<CHAPACL>>&). The string is split up into separate arguments which
17863 are independently expanded. The expansion variable &$domain$& is set to the
17864 argument of the ETRN command, and no syntax checking is done on it. For
17865 example:
17866 .code
17867 smtp_etrn_command = /etc/etrn_command $domain \
17868                     $sender_host_address
17869 .endd
17870 If the option is not set, the argument for the ETRN command must
17871 be a &'#'& followed by an address string.
17872 In this case an &'exim -R <string>'& command is used;
17873 if the ETRN ACL has set up a named-queue then &'-MCG <queue>'& is appended.
17874
17875 A new process is created to run the command, but Exim does not wait for it to
17876 complete. Consequently, its status cannot be checked. If the command cannot be
17877 run, a line is written to the panic log, but the ETRN caller still receives
17878 a 250 success response. Exim is normally running under its own uid when
17879 receiving SMTP, so it is not possible for it to change the uid before running
17880 the command.
17881
17882
17883 .option smtp_etrn_serialize main boolean true
17884 .cindex "ETRN" "serializing"
17885 When this option is set, it prevents the simultaneous execution of more than
17886 one identical command as a result of ETRN in an SMTP connection. See
17887 section &<<SECTETRN>>& for details.
17888
17889
17890 .option smtp_load_reserve main fixed-point unset
17891 .cindex "load average"
17892 If the system load average ever gets higher than this, incoming SMTP calls are
17893 accepted only from those hosts that match an entry in &%smtp_reserve_hosts%&.
17894 If &%smtp_reserve_hosts%& is not set, no incoming SMTP calls are accepted when
17895 the load is over the limit. The option has no effect on ancient operating
17896 systems on which Exim cannot determine the load average. See also
17897 &%deliver_queue_load_max%& and &%queue_only_load%&.
17898
17899
17900
17901 .option smtp_max_synprot_errors main integer 3
17902 .cindex "SMTP" "limiting syntax and protocol errors"
17903 .cindex "limit" "SMTP syntax and protocol errors"
17904 Exim rejects SMTP commands that contain syntax or protocol errors. In
17905 particular, a syntactically invalid email address, as in this command:
17906 .code
17907 RCPT TO:<abc xyz@a.b.c>
17908 .endd
17909 causes immediate rejection of the command, before any other tests are done.
17910 (The ACL cannot be run if there is no valid address to set up for it.) An
17911 example of a protocol error is receiving RCPT before MAIL. If there are
17912 too many syntax or protocol errors in one SMTP session, the connection is
17913 dropped. The limit is set by this option.
17914
17915 .cindex "PIPELINING" "expected errors"
17916 When the PIPELINING extension to SMTP is in use, some protocol errors are
17917 &"expected"&, for instance, a RCPT command after a rejected MAIL command.
17918 Exim assumes that PIPELINING will be used if it advertises it (see
17919 &%pipelining_advertise_hosts%&), and in this situation, &"expected"& errors do
17920 not count towards the limit.
17921
17922
17923
17924 .option smtp_max_unknown_commands main integer 3
17925 .cindex "SMTP" "limiting unknown commands"
17926 .cindex "limit" "unknown SMTP commands"
17927 If there are too many unrecognized commands in an incoming SMTP session, an
17928 Exim server drops the connection. This is a defence against some kinds of abuse
17929 that subvert web
17930 clients
17931 into making connections to SMTP ports; in these circumstances, a number of
17932 non-SMTP command lines are sent first.
17933
17934
17935
17936 .options smtp_ratelimit_hosts main "host list&!!" unset &&&
17937          smtp_ratelimit_mail main string unset &&&
17938          smtp_ratelimit_rcpt main string unset
17939 .cindex "SMTP" "rate limiting"
17940 .cindex "limit" "rate of message arrival"
17941 .cindex "RCPT" "rate limiting"
17942 Some sites find it helpful to be able to limit the rate at which certain hosts
17943 can send them messages, and the rate at which an individual message can specify
17944 recipients.
17945
17946 Exim has two rate-limiting facilities. This section describes the older
17947 facility, which can limit rates within a single connection. The newer
17948 &%ratelimit%& ACL condition can limit rates across all connections. See section
17949 &<<SECTratelimiting>>& for details of the newer facility.
17950
17951 When a host matches &%smtp_ratelimit_hosts%&, the values of
17952 &%smtp_ratelimit_mail%& and &%smtp_ratelimit_rcpt%& are used to control the
17953 rate of acceptance of MAIL and RCPT commands in a single SMTP session,
17954 respectively. Each option, if set, must contain a set of four comma-separated
17955 values:
17956
17957 .ilist
17958 A threshold, before which there is no rate limiting.
17959 .next
17960 An initial time delay. Unlike other times in Exim, numbers with decimal
17961 fractional parts are allowed here.
17962 .next
17963 A factor by which to increase the delay each time.
17964 .next
17965 A maximum value for the delay. This should normally be less than 5 minutes,
17966 because after that time, the client is liable to timeout the SMTP command.
17967 .endlist
17968
17969 For example, these settings have been used successfully at the site which
17970 first suggested this feature, for controlling mail from their customers:
17971 .code
17972 smtp_ratelimit_mail = 2,0.5s,1.05,4m
17973 smtp_ratelimit_rcpt = 4,0.25s,1.015,4m
17974 .endd
17975 The first setting specifies delays that are applied to MAIL commands after
17976 two have been received over a single connection. The initial delay is 0.5
17977 seconds, increasing by a factor of 1.05 each time. The second setting applies
17978 delays to RCPT commands when more than four occur in a single message.
17979
17980
17981
17982 .option smtp_receive_timeout main time&!! 5m
17983 .cindex "timeout" "for SMTP input"
17984 .cindex "SMTP" "input timeout"
17985 This sets a timeout value for SMTP reception. It applies to all forms of SMTP
17986 input, including batch SMTP. If a line of input (either an SMTP command or a
17987 data line) is not received within this time, the SMTP connection is dropped and
17988 the message is abandoned.
17989 A line is written to the log containing one of the following messages:
17990 .code
17991 SMTP command timeout on connection from...
17992 SMTP data timeout on connection from...
17993 .endd
17994 The former means that Exim was expecting to read an SMTP command; the latter
17995 means that it was in the DATA phase, reading the contents of a message.
17996
17997 If the first character of the option is a &"$"& the option is
17998 expanded before use and may depend on
17999 &$sender_host_name$&, &$sender_host_address$& and &$sender_host_port$&.
18000
18001
18002 .oindex "&%-os%&"
18003 The value set by this option can be overridden by the
18004 &%-os%& command-line option. A setting of zero time disables the timeout, but
18005 this should never be used for SMTP over TCP/IP. (It can be useful in some cases
18006 of local input using &%-bs%& or &%-bS%&.) For non-SMTP input, the reception
18007 timeout is controlled by &%receive_timeout%& and &%-or%&.
18008
18009
18010 .option smtp_reserve_hosts main "host list&!!" unset
18011 This option defines hosts for which SMTP connections are reserved; see
18012 &%smtp_accept_reserve%& and &%smtp_load_reserve%& above.
18013
18014
18015 .option smtp_return_error_details main boolean false
18016 .cindex "SMTP" "details policy failures"
18017 .cindex "policy control" "rejection, returning details"
18018 In the default state, Exim uses bland messages such as
18019 &"Administrative prohibition"& when it rejects SMTP commands for policy
18020 reasons. Many sysadmins like this because it gives away little information
18021 to spammers. However, some other sysadmins who are applying strict checking
18022 policies want to give out much fuller information about failures. Setting
18023 &%smtp_return_error_details%& true causes Exim to be more forthcoming. For
18024 example, instead of &"Administrative prohibition"&, it might give:
18025 .code
18026 550-Rejected after DATA: '>' missing at end of address:
18027 550 failing address in "From" header is: <user@dom.ain
18028 .endd
18029
18030
18031 .option smtputf8_advertise_hosts main "host list&!!" *
18032 .cindex "SMTPUTF8" "ESMTP extension, advertising"
18033 .cindex "ESMTP extensions" SMTPUTF8
18034 When Exim is built with support for internationalised mail names,
18035 the availability thereof is advertised in
18036 response to EHLO only to those client hosts that match this option. See
18037 chapter &<<CHAPi18n>>& for details of Exim's support for internationalisation.
18038
18039
18040 .option spamd_address main string "127.0.0.1 783"
18041 This option is available when Exim is compiled with the content-scanning
18042 extension. It specifies how Exim connects to SpamAssassin's &%spamd%& daemon.
18043 See section &<<SECTscanspamass>>& for more details.
18044
18045
18046
18047 .option spf_guess main string "v=spf1 a/24 mx/24 ptr ?all"
18048 This option is available when Exim is compiled with SPF support.
18049 See section &<<SECSPF>>& for more details.
18050
18051 .option spf_smtp_comment_template main string&!! "Please%_see%_http://www.open-spf.org/Why"
18052 This option is available when Exim is compiled with SPF support.  It
18053 allows the customisation of the SMTP comment that the SPF library
18054 generates.  You are strongly encouraged to link to your own explanative
18055 site. The template must not contain spaces. If you need spaces in the
18056 output, use the proper placeholder. If libspf2 can not parse the
18057 template, it uses a built-in default broken link. The following placeholders
18058 (along with Exim variables (but see below)) are allowed in the template:
18059 .ilist
18060 &*%_*&: A space.
18061 .next
18062 &*%{L}*&: Envelope sender's local part.
18063 .next
18064 &*%{S}*&: Envelope sender.
18065 .next
18066 &*%{O}*&: Envelope sender's domain.
18067 .next
18068 &*%{D}*&: Current(?) domain.
18069 .next
18070 &*%{I}*&: SMTP client Ip.
18071 .next
18072 &*%{C}*&: SMTP client pretty IP.
18073 .next
18074 &*%{T}*&: Epoch time (UTC).
18075 .next
18076 &*%{P}*&: SMTP client domain name.
18077 .next
18078 &*%{V}*&: IP version.
18079 .next
18080 &*%{H}*&: EHLO/HELO domain.
18081 .next
18082 &*%{R}*&: Receiving domain.
18083 .endlist
18084 The capitalized placeholders do proper URL encoding, if you use them
18085 lowercased, no encoding takes place.  This list was compiled from the
18086 libspf2 sources.
18087
18088 A note on using Exim variables: As
18089 currently the SPF library is initialized before the SMTP EHLO phase,
18090 the variables useful for expansion are quite limited.
18091
18092
18093 .option split_spool_directory main boolean false
18094 .cindex "multiple spool directories"
18095 .cindex "spool directory" "split"
18096 .cindex "directories, multiple"
18097 If this option is set, it causes Exim to split its input directory into 62
18098 subdirectories, each with a single alphanumeric character as its name. The
18099 sixth character of the message id is used to allocate messages to
18100 subdirectories; this is the least significant base-62 digit of the time of
18101 arrival of the message.
18102
18103 Splitting up the spool in this way may provide better performance on systems
18104 where there are long mail queues, by reducing the number of files in any one
18105 directory. The msglog directory is also split up in a similar way to the input
18106 directory; however, if &%preserve_message_logs%& is set, all old msglog files
18107 are still placed in the single directory &_msglog.OLD_&.
18108
18109 It is not necessary to take any special action for existing messages when
18110 changing &%split_spool_directory%&. Exim notices messages that are in the
18111 &"wrong"& place, and continues to process them. If the option is turned off
18112 after a period of being on, the subdirectories will eventually empty and be
18113 automatically deleted.
18114
18115 When &%split_spool_directory%& is set, the behaviour of queue runner processes
18116 changes. Instead of creating a list of all messages in the queue, and then
18117 trying to deliver each one, in turn, it constructs a list of those in one
18118 sub-directory and tries to deliver them, before moving on to the next
18119 sub-directory. The sub-directories are processed in a random order. This
18120 spreads out the scanning of the input directories, and uses less memory. It is
18121 particularly beneficial when there are lots of messages in the queue. However,
18122 if &%queue_run_in_order%& is set, none of this new processing happens. The
18123 entire queue has to be scanned and sorted before any deliveries can start.
18124
18125
18126 .option spool_directory main string&!! "set at compile time"
18127 .cindex "spool directory" "path to"
18128 This defines the directory in which Exim keeps its spool, that is, the messages
18129 it is waiting to deliver. The default value is taken from the compile-time
18130 configuration setting, if there is one. If not, this option must be set. The
18131 string is expanded, so it can contain, for example, a reference to
18132 &$primary_hostname$&.
18133
18134 If the spool directory name is fixed on your installation, it is recommended
18135 that you set it at build time rather than from this option, particularly if the
18136 log files are being written to the spool directory (see &%log_file_path%&).
18137 Otherwise log files cannot be used for errors that are detected early on, such
18138 as failures in the configuration file.
18139
18140 By using this option to override the compiled-in path, it is possible to run
18141 tests of Exim without using the standard spool.
18142
18143 .option spool_wireformat main boolean false
18144 .cindex "spool directory" "file formats"
18145 If this option is set, Exim may for some messages use an alternative format
18146 for data-files in the spool which matches the wire format.
18147 Doing this permits more efficient message reception and transmission.
18148 Currently it is only done for messages received using the ESMTP CHUNKING
18149 option.
18150
18151 The following variables will not have useful values:
18152 .code
18153 $max_received_linelength
18154 $body_linecount
18155 $body_zerocount
18156 .endd
18157
18158 Users of the local_scan() API (see &<<CHAPlocalscan>>&),
18159 and any external programs which are passed a reference to a message data file
18160 (except via the &"regex"&, &"malware"& or &"spam"&) ACL conditions)
18161 will need to be aware of the different formats potentially available.
18162
18163 Using any of the ACL conditions noted will negate the reception benefit
18164 (as a Unix-mbox-format file is constructed for them).
18165 The transmission benefit is maintained.
18166
18167 .option sqlite_lock_timeout main time 5s
18168 .cindex "sqlite lookup type" "lock timeout"
18169 This option controls the timeout that the &(sqlite)& lookup uses when trying to
18170 access an SQLite database. See section &<<SECTsqlite>>& for more details.
18171
18172 .option strict_acl_vars main boolean false
18173 .cindex "&ACL;" "variables, handling unset"
18174 This option controls what happens if a syntactically valid but undefined ACL
18175 variable is referenced. If it is false (the default), an empty string
18176 is substituted; if it is true, an error is generated. See section
18177 &<<SECTaclvariables>>& for details of ACL variables.
18178
18179 .option strip_excess_angle_brackets main boolean false
18180 .cindex "angle brackets, excess"
18181 If this option is set, redundant pairs of angle brackets round &"route-addr"&
18182 items in addresses are stripped. For example, &'<<xxx@a.b.c.d>>'& is
18183 treated as &'<xxx@a.b.c.d>'&. If this is in the envelope and the message is
18184 passed on to another MTA, the excess angle brackets are not passed on. If this
18185 option is not set, multiple pairs of angle brackets cause a syntax error.
18186
18187
18188 .option strip_trailing_dot main boolean false
18189 .cindex "trailing dot on domain"
18190 .cindex "dot" "trailing on domain"
18191 If this option is set, a trailing dot at the end of a domain in an address is
18192 ignored. If this is in the envelope and the message is passed on to another
18193 MTA, the dot is not passed on. If this option is not set, a dot at the end of a
18194 domain causes a syntax error.
18195 However, addresses in header lines are checked only when an ACL requests header
18196 syntax checking.
18197
18198
18199 .option syslog_duplication main boolean true
18200 .cindex "syslog" "duplicate log lines; suppressing"
18201 When Exim is logging to syslog, it writes the log lines for its three
18202 separate logs at different syslog priorities so that they can in principle
18203 be separated on the logging hosts. Some installations do not require this
18204 separation, and in those cases, the duplication of certain log lines is a
18205 nuisance. If &%syslog_duplication%& is set false, only one copy of any
18206 particular log line is written to syslog. For lines that normally go to
18207 both the main log and the reject log, the reject log version (possibly
18208 containing message header lines) is written, at LOG_NOTICE priority.
18209 Lines that normally go to both the main and the panic log are written at
18210 the LOG_ALERT priority.
18211
18212
18213 .option syslog_facility main string unset
18214 .cindex "syslog" "facility; setting"
18215 This option sets the syslog &"facility"& name, used when Exim is logging to
18216 syslog. The value must be one of the strings &"mail"&, &"user"&, &"news"&,
18217 &"uucp"&, &"daemon"&, or &"local&'x'&"& where &'x'& is a digit between 0 and 7.
18218 If this option is unset, &"mail"& is used. See chapter &<<CHAPlog>>& for
18219 details of Exim's logging.
18220
18221
18222 .option syslog_pid main boolean true
18223 .cindex "syslog" "pid"
18224 If &%syslog_pid%& is set false, the PID on Exim's log lines are
18225 omitted when these lines are sent to syslog. (Syslog normally prefixes
18226 the log lines with the PID of the logging process automatically.) You need
18227 to enable the &`+pid`& log selector item, if you want Exim to write it's PID
18228 into the logs.) See chapter &<<CHAPlog>>& for details of Exim's logging.
18229
18230
18231
18232 .option syslog_processname main string &`exim`&
18233 .cindex "syslog" "process name; setting"
18234 This option sets the syslog &"ident"& name, used when Exim is logging to
18235 syslog. The value must be no longer than 32 characters. See chapter
18236 &<<CHAPlog>>& for details of Exim's logging.
18237
18238
18239
18240 .option syslog_timestamp main boolean true
18241 .cindex "syslog" "timestamps"
18242 .cindex timestamps syslog
18243 If &%syslog_timestamp%& is set false, the timestamps on Exim's log lines are
18244 omitted when these lines are sent to syslog. See chapter &<<CHAPlog>>& for
18245 details of Exim's logging.
18246
18247
18248 .option system_filter main string&!! unset
18249 .cindex "filter" "system filter"
18250 .cindex "system filter" "specifying"
18251 .cindex "Sieve filter" "not available for system filter"
18252 This option specifies an Exim filter file that is applied to all messages at
18253 the start of each delivery attempt, before any routing is done. System filters
18254 must be Exim filters; they cannot be Sieve filters. If the system filter
18255 generates any deliveries to files or pipes, or any new mail messages, the
18256 appropriate &%system_filter_..._transport%& option(s) must be set, to define
18257 which transports are to be used. Details of this facility are given in chapter
18258 &<<CHAPsystemfilter>>&.
18259 A forced expansion failure results in no filter operation.
18260
18261
18262 .option system_filter_directory_transport main string&!! unset
18263 .vindex "&$address_file$&"
18264 This sets the name of the transport driver that is to be used when the
18265 &%save%& command in a system message filter specifies a path ending in &"/"&,
18266 implying delivery of each message into a separate file in some directory.
18267 During the delivery, the variable &$address_file$& contains the path name.
18268
18269
18270 .option system_filter_file_transport main string&!! unset
18271 .cindex "file" "transport for system filter"
18272 This sets the name of the transport driver that is to be used when the &%save%&
18273 command in a system message filter specifies a path not ending in &"/"&. During
18274 the delivery, the variable &$address_file$& contains the path name.
18275
18276 .option system_filter_group main string unset
18277 .cindex "gid (group id)" "system filter"
18278 This option is used only when &%system_filter_user%& is also set. It sets the
18279 gid under which the system filter is run, overriding any gid that is associated
18280 with the user. The value may be numerical or symbolic.
18281
18282 .option system_filter_pipe_transport main string&!! unset
18283 .cindex "&(pipe)& transport" "for system filter"
18284 .vindex "&$address_pipe$&"
18285 This specifies the transport driver that is to be used when a &%pipe%& command
18286 is used in a system filter. During the delivery, the variable &$address_pipe$&
18287 contains the pipe command.
18288
18289
18290 .option system_filter_reply_transport main string&!! unset
18291 .cindex "&(autoreply)& transport" "for system filter"
18292 This specifies the transport driver that is to be used when a &%mail%& command
18293 is used in a system filter.
18294
18295
18296 .option system_filter_user main string unset
18297 .cindex "uid (user id)" "system filter"
18298 If this option is set to root, the system filter is run in the main Exim
18299 delivery process, as root.  Otherwise, the system filter runs in a separate
18300 process, as the given user, defaulting to the Exim run-time user.
18301 Unless the string consists entirely of digits, it
18302 is looked up in the password data. Failure to find the named user causes a
18303 configuration error. The gid is either taken from the password data, or
18304 specified by &%system_filter_group%&. When the uid is specified numerically,
18305 &%system_filter_group%& is required to be set.
18306
18307 If the system filter generates any pipe, file, or reply deliveries, the uid
18308 under which the filter is run is used when transporting them, unless a
18309 transport option overrides.
18310
18311
18312 .option tcp_nodelay main boolean true
18313 .cindex "daemon" "TCP_NODELAY on sockets"
18314 .cindex "Nagle algorithm"
18315 .cindex "TCP_NODELAY on listening sockets"
18316 If this option is set false, it stops the Exim daemon setting the
18317 TCP_NODELAY option on its listening sockets. Setting TCP_NODELAY
18318 turns off the &"Nagle algorithm"&, which is a way of improving network
18319 performance in interactive (character-by-character) situations. Turning it off
18320 should improve Exim's performance a bit, so that is what happens by default.
18321 However, it appears that some broken clients cannot cope, and time out. Hence
18322 this option. It affects only those sockets that are set up for listening by the
18323 daemon. Sockets created by the smtp transport for delivering mail always set
18324 TCP_NODELAY.
18325
18326
18327 .option timeout_frozen_after main time 0s
18328 .cindex "frozen messages" "timing out"
18329 .cindex "timeout" "frozen messages"
18330 If &%timeout_frozen_after%& is set to a time greater than zero, a frozen
18331 message of any kind that has been in the queue for longer than the given time
18332 is automatically cancelled at the next queue run. If the frozen message is a
18333 bounce message, it is just discarded; otherwise, a bounce is sent to the
18334 sender, in a similar manner to cancellation by the &%-Mg%& command line option.
18335 If you want to timeout frozen bounce messages earlier than other kinds of
18336 frozen message, see &%ignore_bounce_errors_after%&.
18337
18338 &*Note:*& the default value of zero means no timeouts; with this setting,
18339 frozen messages remain in the queue forever (except for any frozen bounce
18340 messages that are released by &%ignore_bounce_errors_after%&).
18341
18342
18343 .option timezone main string unset
18344 .cindex "timezone, setting"
18345 .cindex "environment" "values from"
18346 The value of &%timezone%& is used to set the environment variable TZ while
18347 running Exim (if it is different on entry). This ensures that all timestamps
18348 created by Exim are in the required timezone. If you want all your timestamps
18349 to be in UTC (aka GMT) you should set
18350 .code
18351 timezone = UTC
18352 .endd
18353 The default value is taken from TIMEZONE_DEFAULT in &_Local/Makefile_&,
18354 or, if that is not set, from the value of the TZ environment variable when Exim
18355 is built. If &%timezone%& is set to the empty string, either at build or run
18356 time, any existing TZ variable is removed from the environment when Exim
18357 runs. This is appropriate behaviour for obtaining wall-clock time on some, but
18358 unfortunately not all, operating systems.
18359
18360
18361 .option tls_advertise_hosts main "host list&!!" *
18362 .cindex "TLS" "advertising"
18363 .cindex "encryption" "on SMTP connection"
18364 .cindex "SMTP" "encrypted connection"
18365 .cindex "ESMTP extensions" STARTTLS
18366 When Exim is built with support for TLS encrypted connections, the availability
18367 of the STARTTLS command to set up an encrypted session is advertised in
18368 response to EHLO only to those client hosts that match this option. See
18369 chapter &<<CHAPTLS>>& for details of Exim's support for TLS.
18370 Note that the default value requires that a certificate be supplied
18371 using the &%tls_certificate%& option.  If TLS support for incoming connections
18372 is not required the &%tls_advertise_hosts%& option should be set empty.
18373
18374
18375 .option tls_alpn main "string list&!!" "smtp : esmtp"
18376 .cindex TLS "Application Layer Protocol Names"
18377 .cindex TLS ALPN
18378 .cindex ALPN "set acceptable names for server"
18379 If this option is set,
18380 the TLS library supports ALPN,
18381 and the client offers either more than one
18382 ALPN name or a name which does not match the list,
18383 the TLS connection is declined.
18384
18385
18386 .option tls_certificate main "string list&!!" unset
18387 .cindex "TLS" "server certificate; location of"
18388 .cindex "certificate" "server, location of"
18389 The value of this option is expanded, and must then be a list of absolute paths to
18390 files which contain the server's certificates (in PEM format).
18391 Commonly only one file is needed.
18392 The server's private key is also
18393 assumed to be in this file if &%tls_privatekey%& is unset. See chapter
18394 &<<CHAPTLS>>& for further details.
18395
18396 &*Note*&: The certificates defined by this option are used only when Exim is
18397 receiving incoming messages as a server. If you want to supply certificates for
18398 use when sending messages as a client, you must set the &%tls_certificate%&
18399 option in the relevant &(smtp)& transport.
18400
18401 &*Note*&: If you use filenames based on IP addresses, change the list
18402 separator in the usual way (&<<SECTlistsepchange>>&) to avoid confusion under IPv6.
18403
18404 &*Note*&: Under versions of OpenSSL preceding 1.1.1,
18405 when a list of more than one
18406 file is used, the &$tls_in_ourcert$& variable is unreliable.
18407 The macro "_TLS_BAD_MULTICERT_IN_OURCERT" will be defined for those versions.
18408
18409 .cindex SNI "selecting server certificate based on"
18410 If the option contains &$tls_out_sni$& and Exim is built against OpenSSL, then
18411 if the OpenSSL build supports TLS extensions and the TLS client sends the
18412 Server Name Indication extension, then this option and others documented in
18413 &<<SECTtlssni>>& will be re-expanded.
18414
18415 If this option is unset or empty a self-signed certificate will be
18416 used.
18417 Under Linux this is generated at daemon startup; on other platforms it will be
18418 generated fresh for every connection.
18419
18420 .option tls_crl main string&!! unset
18421 .cindex "TLS" "server certificate revocation list"
18422 .cindex "certificate" "revocation list for server"
18423 This option specifies a certificate revocation list. The expanded value must
18424 be the name of a file that contains CRLs in PEM format.
18425
18426 Under OpenSSL the option can specify a directory with CRL files.
18427
18428 &*Note:*& Under OpenSSL the option must, if given, supply a CRL
18429 for each signing element of the certificate chain (i.e. all but the leaf).
18430 For the file variant this can be multiple PEM blocks in the one file.
18431
18432 See &<<SECTtlssni>>& for discussion of when this option might be re-expanded.
18433
18434
18435 .option tls_dh_max_bits main integer 2236
18436 .cindex "TLS" "D-H bit count"
18437 The number of bits used for Diffie-Hellman key-exchange may be suggested by
18438 the chosen TLS library.  That value might prove to be too high for
18439 interoperability.  This option provides a maximum clamp on the value
18440 suggested, trading off security for interoperability.
18441
18442 The value must be at least 1024.
18443
18444 The value 2236 was chosen because, at time of adding the option, it was the
18445 hard-coded maximum value supported by the NSS cryptographic library, as used
18446 by Thunderbird, while GnuTLS was suggesting 2432 bits as normal.
18447
18448 If you prefer more security and are willing to break some clients, raise this
18449 number.
18450
18451 Note that the value passed to GnuTLS for *generating* a new prime may be a
18452 little less than this figure, because GnuTLS is inexact and may produce a
18453 larger prime than requested.
18454
18455
18456 .option tls_dhparam main string&!! unset
18457 .cindex "TLS" "D-H parameters for server"
18458 The value of this option is expanded and indicates the source of DH parameters
18459 to be used by Exim.
18460
18461 &*Note: The Exim Maintainers strongly recommend using a filename with site-generated
18462 local DH parameters*&, which has been supported across all versions of Exim.  The
18463 other specific constants available are a fallback so that even when
18464 "unconfigured", Exim can offer Perfect Forward Secrecy in older ciphersuites in TLS.
18465
18466 If &%tls_dhparam%& is a filename starting with a &`/`&,
18467 then it names a file from which DH
18468 parameters should be loaded.  If the file exists, it should hold a PEM-encoded
18469 PKCS#3 representation of the DH prime.  If the file does not exist, for
18470 OpenSSL it is an error.  For GnuTLS, Exim will attempt to create the file and
18471 fill it with a generated DH prime.  For OpenSSL, if the DH bit-count from
18472 loading the file is greater than &%tls_dh_max_bits%& then it will be ignored,
18473 and treated as though the &%tls_dhparam%& were set to "none".
18474
18475 If this option expands to the string "none", then no DH parameters will be
18476 loaded by Exim.
18477
18478 If this option expands to the string "historic" and Exim is using GnuTLS, then
18479 Exim will attempt to load a file from inside the spool directory.  If the file
18480 does not exist, Exim will attempt to create it.
18481 See section &<<SECTgnutlsparam>>& for further details.
18482
18483 If Exim is using OpenSSL and this option is empty or unset, then Exim will load
18484 a default DH prime; the default is Exim-specific but lacks verifiable provenance.
18485
18486 In older versions of Exim the default was the 2048 bit prime described in section
18487 2.2 of RFC 5114, "2048-bit MODP Group with 224-bit Prime Order Subgroup", which
18488 in IKE is assigned number 23.
18489
18490 Otherwise, the option must expand to the name used by Exim for any of a number
18491 of DH primes specified in RFC 2409, RFC 3526, RFC 5114, RFC 7919, or from other
18492 sources.  As names, Exim uses a standard specified name, else "ike" followed by
18493 the number used by IKE, or "default" which corresponds to
18494 &`exim.dev.20160529.3`&.
18495
18496 The available standard primes are:
18497 &`ffdhe2048`&, &`ffdhe3072`&, &`ffdhe4096`&, &`ffdhe6144`&, &`ffdhe8192`&,
18498 &`ike1`&, &`ike2`&, &`ike5`&,
18499 &`ike14`&, &`ike15`&, &`ike16`&, &`ike17`&, &`ike18`&,
18500 &`ike22`&, &`ike23`& and &`ike24`&.
18501
18502 The available additional primes are:
18503 &`exim.dev.20160529.1`&, &`exim.dev.20160529.2`& and &`exim.dev.20160529.3`&.
18504
18505 Some of these will be too small to be accepted by clients.
18506 Some may be too large to be accepted by clients.
18507 The open cryptographic community has suspicions about the integrity of some
18508 of the later IKE values, which led into RFC7919 providing new fixed constants
18509 (the "ffdhe" identifiers).
18510
18511 At this point, all of the "ike" values should be considered obsolete;
18512 they are still in Exim to avoid breaking unusual configurations, but are
18513 candidates for removal the next time we have backwards-incompatible changes.
18514 Two of them in particular (&`ike1`& and &`ike22`&) are called out by RFC 8247
18515 as MUST NOT use for IPSEC, and two more (&`ike23`& and &`ike24`&) as
18516 SHOULD NOT.
18517 Because of this, Exim regards them as deprecated; if either of the first pair
18518 are used, warnings will be logged in the paniclog, and if any are used then
18519 warnings will be logged in the mainlog.
18520 All four will be removed in a future Exim release.
18521
18522 The TLS protocol does not negotiate an acceptable size for this; clients tend
18523 to hard-drop connections if what is offered by the server is unacceptable,
18524 whether too large or too small, and there's no provision for the client to
18525 tell the server what these constraints are.  Thus, as a server operator, you
18526 need to make an educated guess as to what is most likely to work for your
18527 userbase.
18528
18529 Some known size constraints suggest that a bit-size in the range 2048 to 2236
18530 is most likely to maximise interoperability.  The upper bound comes from
18531 applications using the Mozilla Network Security Services (NSS) library, which
18532 used to set its &`DH_MAX_P_BITS`& upper-bound to 2236.  This affects many
18533 mail user agents (MUAs). The lower bound comes from Debian installs of Exim4
18534 prior to the 4.80 release, as Debian used to patch Exim to raise the minimum
18535 acceptable bound from 1024 to 2048.
18536
18537
18538 .option tls_eccurve main string list&!! &`auto`&
18539 .cindex TLS "EC cryptography"
18540 This option selects EC curves for use by Exim when used with OpenSSL.
18541 It has no effect when Exim is used with GnuTLS
18542 (the equivalent can be done using a priority string for the
18543 &%tls_require_ciphers%& option).
18544
18545 After expansion it must contain
18546 one or (only for OpenSSL versiona 1.1.1 onwards) more
18547 EC curve names, such as &`prime256v1`&, &`secp384r1`&, or &`P-521`&.
18548 Consult your OpenSSL manual for valid curve names.
18549
18550 For OpenSSL versions before (and not including) 1.0.2, the string
18551 &`auto`& selects &`prime256v1`&. For more recent OpenSSL versions
18552 &`auto`& tells the library to choose.
18553
18554 If the option expands to an empty string, the effect is undefined.
18555
18556
18557 .option tls_ocsp_file main string&!! unset
18558 .cindex TLS "certificate status"
18559 .cindex TLS "OCSP proof file"
18560 This option
18561 must if set expand to the absolute path to a file which contains a current
18562 status proof for the server's certificate, as obtained from the
18563 Certificate Authority.
18564
18565 Usable for GnuTLS 3.4.4 or 3.3.17 or OpenSSL 1.1.0 (or later).
18566 The macro "_HAVE_TLS_OCSP" will be defined for those versions.
18567
18568 For OpenSSL 1.1.0 or later, and
18569 for GnuTLS 3.5.6 or later the expanded value of this option can be a list
18570 of files, to match a list given for the &%tls_certificate%& option.
18571 The ordering of the two lists must match.
18572 The macro "_HAVE_TLS_OCSP_LIST" will be defined for those versions.
18573
18574 The file(s) should be in DER format,
18575 except for GnuTLS 3.6.3 or later
18576 or for OpenSSL,
18577 when an optional filetype prefix can be used.
18578 The prefix must be one of "DER" or "PEM", followed by
18579 a single space.  If one is used it sets the format for subsequent
18580 files in the list; the initial format is DER.
18581 If multiple proofs are wanted, for multiple chain elements
18582 (this only works under TLS1.3)
18583 they must be coded as a combined OCSP response.
18584
18585 Although GnuTLS will accept PEM files with multiple separate
18586 PEM blobs (ie. separate OCSP responses), it sends them in the
18587 TLS Certificate record interleaved with the certificates of the chain;
18588 although a GnuTLS client is happy with that, an OpenSSL client is not.
18589
18590 .option tls_on_connect_ports main "string list" unset
18591 .cindex SSMTP
18592 .cindex SMTPS
18593 This option specifies a list of incoming SSMTP (aka SMTPS) ports that should
18594 operate the SSMTP (SMTPS) protocol, where a TLS session is immediately
18595 set up without waiting for the client to issue a STARTTLS command. For
18596 further details, see section &<<SECTsupobssmt>>&.
18597
18598
18599
18600 .option tls_privatekey main "string list&!!" unset
18601 .cindex "TLS" "server private key; location of"
18602 The value of this option is expanded, and must then be a list of absolute paths to
18603 files which contains the server's private keys.
18604 If this option is unset, or if
18605 the expansion is forced to fail, or the result is an empty string, the private
18606 key is assumed to be in the same file as the server's certificates. See chapter
18607 &<<CHAPTLS>>& for further details.
18608
18609 See &<<SECTtlssni>>& for discussion of when this option might be re-expanded.
18610
18611
18612 .option tls_remember_esmtp main boolean false
18613 .cindex "TLS" "esmtp state; remembering"
18614 .cindex "TLS" "broken clients"
18615 If this option is set true, Exim violates the RFCs by remembering that it is in
18616 &"esmtp"& state after successfully negotiating a TLS session. This provides
18617 support for broken clients that fail to send a new EHLO after starting a
18618 TLS session.
18619
18620
18621 .option tls_require_ciphers main string&!! unset
18622 .cindex "TLS" "requiring specific ciphers"
18623 .cindex "cipher" "requiring specific"
18624 This option controls which ciphers can be used for incoming TLS connections.
18625 The &(smtp)& transport has an option of the same name for controlling outgoing
18626 connections. This option is expanded for each connection, so can be varied for
18627 different clients if required. The value of this option must be a list of
18628 permitted cipher suites. The OpenSSL and GnuTLS libraries handle cipher control
18629 in somewhat different ways. If GnuTLS is being used, the client controls the
18630 preference order of the available ciphers. Details are given in sections
18631 &<<SECTreqciphssl>>& and &<<SECTreqciphgnu>>&.
18632
18633
18634 .option tls_resumption_hosts main "host list&!!" unset
18635 .cindex TLS resumption
18636 This option controls which connections to offer the TLS resumption feature.
18637 See &<<SECTresumption>>& for details.
18638
18639
18640 .option tls_try_verify_hosts main "host list&!!" unset
18641 .cindex "TLS" "client certificate verification"
18642 .cindex "certificate" "verification of client"
18643 See &%tls_verify_hosts%& below.
18644
18645
18646 .option tls_verify_certificates main string&!! system
18647 .cindex "TLS" "client certificate verification"
18648 .cindex "certificate" "verification of client"
18649 The value of this option is expanded, and must then be either the
18650 word "system"
18651 or the absolute path to
18652 a file or directory containing permitted certificates for clients that
18653 match &%tls_verify_hosts%& or &%tls_try_verify_hosts%&.
18654
18655 The "system" value for the option will use a
18656 system default location compiled into the SSL library.
18657 This is not available for GnuTLS versions preceding 3.0.20,
18658 and will be taken as empty; an explicit location
18659 must be specified.
18660
18661 The use of a directory for the option value is not available for GnuTLS versions
18662 preceding 3.3.6 and a single file must be used.
18663
18664 With OpenSSL the certificates specified
18665 explicitly
18666 either by file or directory
18667 are added to those given by the system default location.
18668
18669 These certificates should be for the certificate authorities trusted, rather
18670 than the public cert of individual clients.  With both OpenSSL and GnuTLS, if
18671 the value is a file then the certificates are sent by Exim as a server to
18672 connecting clients, defining the list of accepted certificate authorities.
18673 Thus the values defined should be considered public data.  To avoid this,
18674 use the explicit directory version. (If your peer is Exim up to 4.85,
18675 using GnuTLS, you may need to send the CAs (thus using the file
18676 variant). Otherwise the peer doesn't send its certificate.)
18677
18678 See &<<SECTtlssni>>& for discussion of when this option might be re-expanded.
18679
18680 A forced expansion failure or setting to an empty string is equivalent to
18681 being unset.
18682
18683
18684 .option tls_verify_hosts main "host list&!!" unset
18685 .cindex "TLS" "client certificate verification"
18686 .cindex "certificate" "verification of client"
18687 This option, along with &%tls_try_verify_hosts%&, controls the checking of
18688 certificates from clients. The expected certificates are defined by
18689 &%tls_verify_certificates%&, which must be set. A configuration error occurs if
18690 either &%tls_verify_hosts%& or &%tls_try_verify_hosts%& is set and
18691 &%tls_verify_certificates%& is not set.
18692
18693 Any client that matches &%tls_verify_hosts%& is constrained by
18694 &%tls_verify_certificates%&. When the client initiates a TLS session, it must
18695 present one of the listed certificates. If it does not, the connection is
18696 aborted.
18697 &*Warning*&: Including a host in &%tls_verify_hosts%& does not require
18698 the host to use TLS. It can still send SMTP commands through unencrypted
18699 connections. Forcing a client to use TLS has to be done separately using an
18700 ACL to reject inappropriate commands when the connection is not encrypted.
18701
18702 A weaker form of checking is provided by &%tls_try_verify_hosts%&. If a client
18703 matches this option (but not &%tls_verify_hosts%&), Exim requests a
18704 certificate and checks it against &%tls_verify_certificates%&, but does not
18705 abort the connection if there is no certificate or if it does not match. This
18706 state can be detected in an ACL, which makes it possible to implement policies
18707 such as &"accept for relay only if a verified certificate has been received,
18708 but accept for local delivery if encrypted, even without a verified
18709 certificate"&.
18710
18711 Client hosts that match neither of these lists are not asked to present
18712 certificates.
18713
18714
18715 .option trusted_groups main "string list&!!" unset
18716 .cindex "trusted groups"
18717 .cindex "groups" "trusted"
18718 This option is expanded just once, at the start of Exim's processing. If this
18719 option is set, any process that is running in one of the listed groups, or
18720 which has one of them as a supplementary group, is trusted. The groups can be
18721 specified numerically or by name. See section &<<SECTtrustedadmin>>& for
18722 details of what trusted callers are permitted to do. If neither
18723 &%trusted_groups%& nor &%trusted_users%& is set, only root and the Exim user
18724 are trusted.
18725
18726 .option trusted_users main "string list&!!" unset
18727 .cindex "trusted users"
18728 .cindex "user" "trusted"
18729 This option is expanded just once, at the start of Exim's processing. If this
18730 option is set, any process that is running as one of the listed users is
18731 trusted. The users can be specified numerically or by name. See section
18732 &<<SECTtrustedadmin>>& for details of what trusted callers are permitted to do.
18733 If neither &%trusted_groups%& nor &%trusted_users%& is set, only root and the
18734 Exim user are trusted.
18735
18736 .option unknown_login main string&!! unset
18737 .cindex "uid (user id)" "unknown caller"
18738 .vindex "&$caller_uid$&"
18739 This is a specialized feature for use in unusual configurations. By default, if
18740 the uid of the caller of Exim cannot be looked up using &[getpwuid()]&, Exim
18741 gives up. The &%unknown_login%& option can be used to set a login name to be
18742 used in this circumstance. It is expanded, so values like &%user$caller_uid%&
18743 can be set. When &%unknown_login%& is used, the value of &%unknown_username%&
18744 is used for the user's real name (gecos field), unless this has been set by the
18745 &%-F%& option.
18746
18747 .option unknown_username main string unset
18748 See &%unknown_login%&.
18749
18750 .option untrusted_set_sender main "address list&!!" unset
18751 .cindex "trusted users"
18752 .cindex "sender" "setting by untrusted user"
18753 .cindex "untrusted user setting sender"
18754 .cindex "user" "untrusted setting sender"
18755 .cindex "envelope from"
18756 .cindex "envelope sender"
18757 When an untrusted user submits a message to Exim using the standard input, Exim
18758 normally creates an envelope sender address from the user's login and the
18759 default qualification domain. Data from the &%-f%& option (for setting envelope
18760 senders on non-SMTP messages) or the SMTP MAIL command (if &%-bs%& or &%-bS%&
18761 is used) is ignored.
18762
18763 However, untrusted users are permitted to set an empty envelope sender address,
18764 to declare that a message should never generate any bounces. For example:
18765 .code
18766 exim -f '<>' user@domain.example
18767 .endd
18768 .vindex "&$sender_ident$&"
18769 The &%untrusted_set_sender%& option allows you to permit untrusted users to set
18770 other envelope sender addresses in a controlled way. When it is set, untrusted
18771 users are allowed to set envelope sender addresses that match any of the
18772 patterns in the list. Like all address lists, the string is expanded. The
18773 identity of the user is in &$sender_ident$&, so you can, for example, restrict
18774 users to setting senders that start with their login ids
18775 followed by a hyphen
18776 by a setting like this:
18777 .code
18778 untrusted_set_sender = ^$sender_ident-
18779 .endd
18780 If you want to allow untrusted users to set envelope sender addresses without
18781 restriction, you can use
18782 .code
18783 untrusted_set_sender = *
18784 .endd
18785 The &%untrusted_set_sender%& option applies to all forms of local input, but
18786 only to the setting of the envelope sender. It does not permit untrusted users
18787 to use the other options which trusted user can use to override message
18788 parameters. Furthermore, it does not stop Exim from removing an existing
18789 &'Sender:'& header in the message, or from adding a &'Sender:'& header if
18790 necessary. See &%local_sender_retain%& and &%local_from_check%& for ways of
18791 overriding these actions. The handling of the &'Sender:'& header is also
18792 described in section &<<SECTthesenhea>>&.
18793
18794 The log line for a message's arrival shows the envelope sender following
18795 &"<="&. For local messages, the user's login always follows, after &"U="&. In
18796 &%-bp%& displays, and in the Exim monitor, if an untrusted user sets an
18797 envelope sender address, the user's login is shown in parentheses after the
18798 sender address.
18799
18800
18801 .option uucp_from_pattern main string "see below"
18802 .cindex "&""From""& line"
18803 .cindex "UUCP" "&""From""& line"
18804 Some applications that pass messages to an MTA via a command line interface use
18805 an initial line starting with &"From&~"& to pass the envelope sender. In
18806 particular, this is used by UUCP software. Exim recognizes such a line by means
18807 of a regular expression that is set in &%uucp_from_pattern%&. When the pattern
18808 matches, the sender address is constructed by expanding the contents of
18809 &%uucp_from_sender%&, provided that the caller of Exim is a trusted user. The
18810 default pattern recognizes lines in the following two forms:
18811 .code
18812 From ph10 Fri Jan  5 12:35 GMT 1996
18813 From ph10 Fri, 7 Jan 97 14:00:00 GMT
18814 .endd
18815 The pattern can be seen by running
18816 .code
18817 exim -bP uucp_from_pattern
18818 .endd
18819 It checks only up to the hours and minutes, and allows for a 2-digit or 4-digit
18820 year in the second case. The first word after &"From&~"& is matched in the
18821 regular expression by a parenthesized subpattern. The default value for
18822 &%uucp_from_sender%& is &"$1"&, which therefore just uses this first word
18823 (&"ph10"& in the example above) as the message's sender. See also
18824 &%ignore_fromline_hosts%&.
18825
18826
18827 .option uucp_from_sender main string&!! &`$1`&
18828 See &%uucp_from_pattern%& above.
18829
18830
18831 .option warn_message_file main string&!! unset
18832 .cindex "warning of delay" "customizing the message"
18833 .cindex "customizing" "warning message"
18834 This option defines a template file containing paragraphs of text to be used
18835 for constructing the warning message which is sent by Exim when a message has
18836 been in the queue for a specified amount of time, as specified by
18837 &%delay_warning%&. Details of the file's contents are given in chapter
18838 &<<CHAPemsgcust>>&.
18839 .cindex warn_message_file "tainted data"
18840 The option is expanded to give the file path, which must be
18841 absolute and untainted.
18842 See also &%bounce_message_file%&.
18843
18844
18845 .option write_rejectlog main boolean true
18846 .cindex "reject log" "disabling"
18847 If this option is set false, Exim no longer writes anything to the reject log.
18848 See chapter &<<CHAPlog>>& for details of what Exim writes to its logs.
18849 .ecindex IIDconfima
18850 .ecindex IIDmaiconf
18851
18852
18853
18854
18855 . ////////////////////////////////////////////////////////////////////////////
18856 . ////////////////////////////////////////////////////////////////////////////
18857
18858 .chapter "Generic options for routers" "CHAProutergeneric"
18859 .scindex IIDgenoprou1 "options" "generic; for routers"
18860 .scindex IIDgenoprou2 "generic options" "router"
18861 This chapter describes the generic options that apply to all routers.
18862 Those that are preconditions are marked with &Dagger; in the &"use"& field.
18863
18864 For a general description of how a router operates, see sections
18865 &<<SECTrunindrou>>& and &<<SECTrouprecon>>&. The latter specifies the order in
18866 which the preconditions are tested. The order of expansion of the options that
18867 provide data for a transport is: &%errors_to%&, &%headers_add%&,
18868 &%headers_remove%&, &%transport%&.
18869
18870 The name of a router is limited to be &drivernamemax; ASCII characters long;
18871 prior to Exim 4.95 names would be silently truncated at this length, but now
18872 it is enforced.
18873
18874
18875 .option address_data routers string&!! unset
18876 .cindex "router" "data attached to address"
18877 The string is expanded just before the router is run, that is, after all the
18878 precondition tests have succeeded. If the expansion is forced to fail, the
18879 router declines, the value of &%address_data%& remains unchanged, and the
18880 &%more%& option controls what happens next. Other expansion failures cause
18881 delivery of the address to be deferred.
18882
18883 .vindex "&$address_data$&"
18884 When the expansion succeeds, the value is retained with the address, and can be
18885 accessed using the variable &$address_data$& in the current router, subsequent
18886 routers, and the eventual transport.
18887
18888 &*Warning*&: If the current or any subsequent router is a &(redirect)& router
18889 that runs a user's filter file, the contents of &$address_data$& are accessible
18890 in the filter. This is not normally a problem, because such data is usually
18891 either not confidential or it &"belongs"& to the current user, but if you do
18892 put confidential data into &$address_data$& you need to remember this point.
18893
18894 Even if the router declines or passes, the value of &$address_data$& remains
18895 with the address, though it can be changed by another &%address_data%& setting
18896 on a subsequent router. If a router generates child addresses, the value of
18897 &$address_data$& propagates to them. This also applies to the special kind of
18898 &"child"& that is generated by a router with the &%unseen%& option.
18899
18900 The idea of &%address_data%& is that you can use it to look up a lot of data
18901 for the address once, and then pick out parts of the data later. For example,
18902 you could use a single LDAP lookup to return a string of the form
18903 .code
18904 uid=1234 gid=5678 mailbox=/mail/xyz forward=/home/xyz/.forward
18905 .endd
18906 In the transport you could pick out the mailbox by a setting such as
18907 .code
18908 file = ${extract{mailbox}{$address_data}}
18909 .endd
18910 This makes the configuration file less messy, and also reduces the number of
18911 lookups (though Exim does cache lookups).
18912
18913 See also the &%set%& option below.
18914
18915 .vindex "&$sender_address_data$&"
18916 .vindex "&$address_data$&"
18917 The &%address_data%& facility is also useful as a means of passing information
18918 from one router to another, and from a router to a transport. In addition, if
18919 &$address_data$& is set by a router when verifying a recipient address from an
18920 ACL, it remains available for use in the rest of the ACL statement. After
18921 verifying a sender, the value is transferred to &$sender_address_data$&.
18922
18923
18924
18925 .option address_test routers&!? boolean true
18926 .oindex "&%-bt%&"
18927 .cindex "router" "skipping when address testing"
18928 If this option is set false, the router is skipped when routing is being tested
18929 by means of the &%-bt%& command line option. This can be a convenience when
18930 your first router sends messages to an external scanner, because it saves you
18931 having to set the &"already scanned"& indicator when testing real address
18932 routing.
18933
18934
18935
18936 .option cannot_route_message routers string&!! unset
18937 .cindex "router" "customizing &""cannot route""& message"
18938 .cindex "customizing" "&""cannot route""& message"
18939 This option specifies a text message that is used when an address cannot be
18940 routed because Exim has run out of routers. The default message is
18941 &"Unrouteable address"&. This option is useful only on routers that have
18942 &%more%& set false, or on the very last router in a configuration, because the
18943 value that is used is taken from the last router that is considered. This
18944 includes a router that is skipped because its preconditions are not met, as
18945 well as a router that declines. For example, using the default configuration,
18946 you could put:
18947 .code
18948 cannot_route_message = Remote domain not found in DNS
18949 .endd
18950 on the first router, which is a &(dnslookup)& router with &%more%& set false,
18951 and
18952 .code
18953 cannot_route_message = Unknown local user
18954 .endd
18955 on the final router that checks for local users. If string expansion fails for
18956 this option, the default message is used. Unless the expansion failure was
18957 explicitly forced, a message about the failure is written to the main and panic
18958 logs, in addition to the normal message about the routing failure.
18959
18960
18961 .option caseful_local_part routers boolean false
18962 .cindex "case of local parts"
18963 .cindex "router" "case of local parts"
18964 By default, routers handle the local parts of addresses in a case-insensitive
18965 manner, though the actual case is preserved for transmission with the message.
18966 If you want the case of letters to be significant in a router, you must set
18967 this option true. For individual router options that contain address or local
18968 part lists (for example, &%local_parts%&), case-sensitive matching can be
18969 turned on by &"+caseful"& as a list item. See section &<<SECTcasletadd>>& for
18970 more details.
18971
18972 .vindex "&$local_part$&"
18973 .vindex "&$original_local_part$&"
18974 .vindex "&$parent_local_part$&"
18975 The value of the &$local_part$& variable is forced to lower case while a
18976 router is running unless &%caseful_local_part%& is set. When a router assigns
18977 an address to a transport, the value of &$local_part$& when the transport runs
18978 is the same as it was in the router. Similarly, when a router generates child
18979 addresses by aliasing or forwarding, the values of &$original_local_part$&
18980 and &$parent_local_part$& are those that were used by the redirecting router.
18981
18982 This option applies to the processing of an address by a router. When a
18983 recipient address is being processed in an ACL, there is a separate &%control%&
18984 modifier that can be used to specify case-sensitive processing within the ACL
18985 (see section &<<SECTcontrols>>&).
18986
18987
18988
18989 .option check_local_user routers&!? boolean false
18990 .cindex "local user, checking in router"
18991 .cindex "router" "checking for local user"
18992 .cindex "&_/etc/passwd_&"
18993 .vindex "&$home$&"
18994 When this option is true, Exim checks that the local part of the recipient
18995 address (with affixes removed if relevant) is the name of an account on the
18996 local system. The check is done by calling the &[getpwnam()]& function rather
18997 than trying to read &_/etc/passwd_& directly. This means that other methods of
18998 holding password data (such as NIS) are supported. If the local part is a local
18999 user,
19000 .cindex "tainted data" "de-tainting"
19001 .cindex "de-tainting" "using router check_local_user option"
19002 &$local_part_data$& is set to an untainted version of the local part and
19003 &$home$& is set from the password data. The latter can be tested in other
19004 preconditions that are evaluated after this one (the order of evaluation is
19005 given in section &<<SECTrouprecon>>&). However, the value of &$home$& can be
19006 overridden by &%router_home_directory%&. If the local part is not a local user,
19007 the router is skipped.
19008
19009 If you want to check that the local part is either the name of a local user
19010 or matches something else, you cannot combine &%check_local_user%& with a
19011 setting of &%local_parts%&, because that specifies the logical &'and'& of the
19012 two conditions. However, you can use a &(passwd)& lookup in a &%local_parts%&
19013 setting to achieve this. For example:
19014 .code
19015 local_parts = passwd;$local_part : lsearch;/etc/other/users
19016 .endd
19017 Note, however, that the side effects of &%check_local_user%& (such as setting
19018 up a home directory) do not occur when a &(passwd)& lookup is used in a
19019 &%local_parts%& (or any other) precondition.
19020
19021
19022
19023 .option condition routers&!? string&!! unset
19024 .cindex "router" "customized precondition"
19025 This option specifies a general precondition test that has to succeed for the
19026 router to be called. The &%condition%& option is the last precondition to be
19027 evaluated (see section &<<SECTrouprecon>>&). The string is expanded, and if the
19028 result is a forced failure, or an empty string, or one of the strings &"0"& or
19029 &"no"& or &"false"& (checked without regard to the case of the letters), the
19030 router is skipped, and the address is offered to the next one.
19031
19032 If the result is any other value, the router is run (as this is the last
19033 precondition to be evaluated, all the other preconditions must be true).
19034
19035 This option is unusual in that multiple &%condition%& options may be present.
19036 All &%condition%& options must succeed.
19037
19038 The &%condition%& option provides a means of applying custom conditions to the
19039 running of routers. Note that in the case of a simple conditional expansion,
19040 the default expansion values are exactly what is wanted. For example:
19041 .code
19042 condition = ${if >{$message_age}{600}}
19043 .endd
19044 Because of the default behaviour of the string expansion, this is equivalent to
19045 .code
19046 condition = ${if >{$message_age}{600}{true}{}}
19047 .endd
19048
19049 A multiple condition example, which succeeds:
19050 .code
19051 condition = ${if >{$message_age}{600}}
19052 condition = ${if !eq{${lc:$local_part}}{postmaster}}
19053 condition = foobar
19054 .endd
19055
19056 If the expansion fails (other than forced failure) delivery is deferred. Some
19057 of the other precondition options are common special cases that could in fact
19058 be specified using &%condition%&.
19059
19060 Historical note: We have &%condition%& on ACLs and on Routers.  Routers
19061 are far older, and use one set of semantics.  ACLs are newer and when
19062 they were created, the ACL &%condition%& process was given far stricter
19063 parse semantics.  The &%bool{}%& expansion condition uses the same rules as
19064 ACLs.  The &%bool_lax{}%& expansion condition uses the same rules as
19065 Routers.  More pointedly, the &%bool_lax{}%& was written to match the existing
19066 Router rules processing behavior.
19067
19068 This is best illustrated in an example:
19069 .code
19070 # If used in an ACL condition will fail with a syntax error, but
19071 # in a router condition any extra characters are treated as a string
19072
19073 $ exim -be '${if eq {${lc:GOOGLE.com}} {google.com}} {yes} {no}}'
19074 true {yes} {no}}
19075
19076 $ exim -be '${if eq {${lc:WHOIS.com}} {google.com}} {yes} {no}}'
19077  {yes} {no}}
19078 .endd
19079 In each example above, the &%if%& statement actually ends after
19080 &"{google.com}}"&.  Since no true or false braces were defined, the
19081 default &%if%& behavior is to return a boolean true or a null answer
19082 (which evaluates to false). The rest of the line is then treated as a
19083 string. So the first example resulted in the boolean answer &"true"&
19084 with the string &" {yes} {no}}"& appended to it. The second example
19085 resulted in the null output (indicating false) with the string
19086 &" {yes} {no}}"& appended to it.
19087
19088 In fact you can put excess forward braces in too.  In the router
19089 &%condition%&, Exim's parser only looks for &"{"& symbols when they
19090 mean something, like after a &"$"& or when required as part of a
19091 conditional.  But otherwise &"{"& and &"}"& are treated as ordinary
19092 string characters.
19093
19094 Thus, in a Router, the above expansion strings will both always evaluate
19095 true, as the result of expansion is a non-empty string which doesn't
19096 match an explicit false value.  This can be tricky to debug.  By
19097 contrast, in an ACL either of those strings will always result in an
19098 expansion error because the result doesn't look sufficiently boolean.
19099
19100
19101 .option debug_print routers string&!! unset
19102 .cindex "testing" "variables in drivers"
19103 If this option is set and debugging is enabled (see the &%-d%& command line
19104 option) or in address-testing mode (see the &%-bt%& command line option),
19105 the string is expanded and included in the debugging output.
19106 If expansion of the string fails, the error message is written to the debugging
19107 output, and Exim carries on processing.
19108 This option is provided to help with checking out the values of variables and
19109 so on when debugging router configurations. For example, if a &%condition%&
19110 option appears not to be working, &%debug_print%& can be used to output the
19111 variables it references. The output happens after checks for &%domains%&,
19112 &%local_parts%&, and &%check_local_user%& but before any other preconditions
19113 are tested. A newline is added to the text if it does not end with one.
19114 The variable &$router_name$& contains the name of the router.
19115
19116
19117
19118 .option disable_logging routers boolean false
19119 If this option is set true, nothing is logged for any routing errors
19120 or for any deliveries caused by this router. You should not set this option
19121 unless you really, really know what you are doing. See also the generic
19122 transport option of the same name.
19123
19124 .option dnssec_request_domains routers "domain list&!!" *
19125 .cindex "MX record" "security"
19126 .cindex "DNSSEC" "MX lookup"
19127 .cindex "security" "MX lookup"
19128 .cindex "DNS" "DNSSEC"
19129 DNS lookups for domains matching &%dnssec_request_domains%& will be done with
19130 the DNSSEC request bit set.
19131 This applies to all of the SRV, MX, AAAA, A lookup sequence.
19132
19133 .option dnssec_require_domains routers "domain list&!!" unset
19134 .cindex "MX record" "security"
19135 .cindex "DNSSEC" "MX lookup"
19136 .cindex "security" "MX lookup"
19137 .cindex "DNS" "DNSSEC"
19138 DNS lookups for domains matching &%dnssec_require_domains%& will be done with
19139 the DNSSEC request bit set.  Any returns not having the Authenticated Data bit
19140 (AD bit) set will be ignored and logged as a host-lookup failure.
19141 This applies to all of the SRV, MX, AAAA, A lookup sequence.
19142
19143
19144 .option domains routers&!? "domain list&!!" unset
19145 .cindex "router" "restricting to specific domains"
19146 .vindex "&$domain_data$&"
19147 If this option is set, the router is skipped unless the current domain matches
19148 the list.
19149 The data returned by the list check
19150 is placed in &$domain_data$& for use in string
19151 expansions of the driver's private options and in the transport.
19152 See section &<<SECTrouprecon>>& for
19153 a list of the order in which preconditions are evaluated.
19154
19155 A complex example, using a file like:
19156 .code
19157 alice@dom1
19158 bill@dom1
19159 maggie@dom1
19160 .endd
19161 and checking both domain and local_part
19162 .code
19163 domains =         ${domain:${lookup {$local_part@$domain} lseach,ret=key {/path/to/accountsfile}}}
19164 local_parts = ${local_part:${lookup {$local_part@$domain} lseach,ret=key {/path/to/accountsfile}}}
19165 .endd
19166
19167
19168
19169 .option driver routers string unset
19170 This option must always be set. It specifies which of the available routers is
19171 to be used.
19172
19173
19174 .option dsn_lasthop routers boolean false
19175 .cindex "DSN" "success"
19176 .cindex "Delivery Status Notification" "success"
19177 If this option is set true, and extended DSN (RFC3461) processing is in effect,
19178 Exim will not pass on DSN requests to downstream DSN-aware hosts but will
19179 instead send a success DSN as if the next hop does not support DSN.
19180 Not effective on redirect routers.
19181
19182
19183
19184 .option errors_to routers string&!! unset
19185 .cindex "envelope from"
19186 .cindex "envelope sender"
19187 .cindex "router" "changing address for errors"
19188 If a router successfully handles an address, it may assign the address to a
19189 transport for delivery or it may generate child addresses. In both cases, if
19190 there is a delivery problem during later processing, the resulting bounce
19191 message is sent to the address that results from expanding this string,
19192 provided that the address verifies successfully. The &%errors_to%& option is
19193 expanded before &%headers_add%&, &%headers_remove%&, and &%transport%&.
19194
19195 The &%errors_to%& setting associated with an address can be overridden if it
19196 subsequently passes through other routers that have their own &%errors_to%&
19197 settings, or if the message is delivered by a transport with a &%return_path%&
19198 setting.
19199
19200 If &%errors_to%& is unset, or the expansion is forced to fail, or the result of
19201 the expansion fails to verify, the errors address associated with the incoming
19202 address is used. At top level, this is the envelope sender. A non-forced
19203 expansion failure causes delivery to be deferred.
19204
19205 If an address for which &%errors_to%& has been set ends up being delivered over
19206 SMTP, the envelope sender for that delivery is the &%errors_to%& value, so that
19207 any bounces that are generated by other MTAs on the delivery route are also
19208 sent there. You can set &%errors_to%& to the empty string by either of these
19209 settings:
19210 .code
19211 errors_to =
19212 errors_to = ""
19213 .endd
19214 An expansion item that yields an empty string has the same effect. If you do
19215 this, a locally detected delivery error for addresses processed by this router
19216 no longer gives rise to a bounce message; the error is discarded. If the
19217 address is delivered to a remote host, the return path is set to &`<>`&, unless
19218 overridden by the &%return_path%& option on the transport.
19219
19220 .vindex "&$address_data$&"
19221 If for some reason you want to discard local errors, but use a non-empty
19222 MAIL command for remote delivery, you can preserve the original return
19223 path in &$address_data$& in the router, and reinstate it in the transport by
19224 setting &%return_path%&.
19225
19226 The most common use of &%errors_to%& is to direct mailing list bounces to the
19227 manager of the list, as described in section &<<SECTmailinglists>>&, or to
19228 implement VERP (Variable Envelope Return Paths) (see section &<<SECTverp>>&).
19229
19230
19231
19232 .option expn routers&!? boolean true
19233 .cindex "address" "testing"
19234 .cindex "testing" "addresses"
19235 .cindex "EXPN" "router skipping"
19236 .cindex "router" "skipping for EXPN"
19237 If this option is turned off, the router is skipped when testing an address
19238 as a result of processing an SMTP EXPN command. You might, for example,
19239 want to turn it off on a router for users' &_.forward_& files, while leaving it
19240 on for the system alias file.
19241 See section &<<SECTrouprecon>>& for a list of the order in which preconditions
19242 are evaluated.
19243
19244 The use of the SMTP EXPN command is controlled by an ACL (see chapter
19245 &<<CHAPACL>>&). When Exim is running an EXPN command, it is similar to testing
19246 an address with &%-bt%&. Compare VRFY, whose counterpart is &%-bv%&.
19247
19248
19249
19250 .option fail_verify routers boolean false
19251 .cindex "router" "forcing verification failure"
19252 Setting this option has the effect of setting both &%fail_verify_sender%& and
19253 &%fail_verify_recipient%& to the same value.
19254
19255
19256
19257 .option fail_verify_recipient routers boolean false
19258 If this option is true and an address is accepted by this router when
19259 verifying a recipient, verification fails.
19260
19261
19262
19263 .option fail_verify_sender routers boolean false
19264 If this option is true and an address is accepted by this router when
19265 verifying a sender, verification fails.
19266
19267
19268
19269 .option fallback_hosts routers "string list" unset
19270 .cindex "router" "fallback hosts"
19271 .cindex "fallback" "hosts specified on router"
19272 String expansion is not applied to this option. The argument must be a
19273 colon-separated list of host names or IP addresses. The list separator can be
19274 changed (see section &<<SECTlistsepchange>>&), and a port can be specified with
19275 each name or address. In fact, the format of each item is exactly the same as
19276 defined for the list of hosts in a &(manualroute)& router (see section
19277 &<<SECTformatonehostitem>>&).
19278
19279 If a router queues an address for a remote transport, this host list is
19280 associated with the address, and used instead of the transport's fallback host
19281 list. If &%hosts_randomize%& is set on the transport, the order of the list is
19282 randomized for each use. See the &%fallback_hosts%& option of the &(smtp)&
19283 transport for further details.
19284
19285
19286 .option group routers string&!! "see below"
19287 .cindex "gid (group id)" "local delivery"
19288 .cindex "local transports" "uid and gid"
19289 .cindex "transport" "local"
19290 .cindex "router" "setting group"
19291 When a router queues an address for a transport, and the transport does not
19292 specify a group, the group given here is used when running the delivery
19293 process.
19294 The group may be specified numerically or by name. If expansion fails, the
19295 error is logged and delivery is deferred.
19296 The default is unset, unless &%check_local_user%& is set, when the default
19297 is taken from the password information. See also &%initgroups%& and &%user%&
19298 and the discussion in chapter &<<CHAPenvironment>>&.
19299
19300
19301
19302 .option headers_add routers list&!! unset
19303 .cindex "header lines" "adding"
19304 .cindex "router" "adding header lines"
19305 This option specifies a list of text headers,
19306 newline-separated (by default, changeable in the usual way &<<SECTlistsepchange>>&),
19307 that is associated with any addresses that are accepted by the router.
19308 Each item is separately expanded, at routing time.  However, this
19309 option has no effect when an address is just being verified. The way in which
19310 the text is used to add header lines at transport time is described in section
19311 &<<SECTheadersaddrem>>&. New header lines are not actually added until the
19312 message is in the process of being transported. This means that references to
19313 header lines in string expansions in the transport's configuration do not
19314 &"see"& the added header lines.
19315
19316 The &%headers_add%& option is expanded after &%errors_to%&, but before
19317 &%headers_remove%& and &%transport%&. If an item is empty, or if
19318 an item expansion is forced to fail, the item has no effect. Other expansion
19319 failures are treated as configuration errors.
19320
19321 Unlike most options, &%headers_add%& can be specified multiple times
19322 for a router; all listed headers are added.
19323
19324 &*Warning 1*&: The &%headers_add%& option cannot be used for a &(redirect)&
19325 router that has the &%one_time%& option set.
19326
19327 .cindex "duplicate addresses"
19328 .oindex "&%unseen%&"
19329 &*Warning 2*&: If the &%unseen%& option is set on the router, all header
19330 additions are deleted when the address is passed on to subsequent routers.
19331 For a &%redirect%& router, if a generated address is the same as the incoming
19332 address, this can lead to duplicate addresses with different header
19333 modifications. Exim does not do duplicate deliveries (except, in certain
19334 circumstances, to pipes -- see section &<<SECTdupaddr>>&), but it is undefined
19335 which of the duplicates is discarded, so this ambiguous situation should be
19336 avoided. The &%repeat_use%& option of the &%redirect%& router may be of help.
19337
19338
19339
19340 .option headers_remove routers list&!! unset
19341 .cindex "header lines" "removing"
19342 .cindex "router" "removing header lines"
19343 This option specifies a list of text headers,
19344 colon-separated (by default, changeable in the usual way &<<SECTlistsepchange>>&),
19345 that is associated with any addresses that are accepted by the router.
19346 However, the option has no effect when an address is just being verified.
19347 Each list item is separately expanded, at transport time.
19348 If an item ends in *, it will match any header with the given prefix.
19349 The way in which
19350 the text is used to remove header lines at transport time is described in
19351 section &<<SECTheadersaddrem>>&. Header lines are not actually removed until
19352 the message is in the process of being transported. This means that references
19353 to header lines in string expansions in the transport's configuration still
19354 &"see"& the original header lines.
19355
19356 The &%headers_remove%& option is handled after &%errors_to%& and
19357 &%headers_add%&, but before &%transport%&. If an item expansion is forced to fail,
19358 the item has no effect. Other expansion failures are treated as configuration
19359 errors.
19360
19361 Unlike most options, &%headers_remove%& can be specified multiple times
19362 for a router; all listed headers are removed.
19363
19364 &*Warning 1*&: The &%headers_remove%& option cannot be used for a &(redirect)&
19365 router that has the &%one_time%& option set.
19366
19367 &*Warning 2*&: If the &%unseen%& option is set on the router, all header
19368 removal requests are deleted when the address is passed on to subsequent
19369 routers, and this can lead to problems with duplicates -- see the similar
19370 warning for &%headers_add%& above.
19371
19372 &*Warning 3*&: Because of the separate expansion of the list items,
19373 items that contain a list separator must have it doubled.
19374 To avoid this, change the list separator (&<<SECTlistsepchange>>&).
19375
19376
19377
19378 .option ignore_target_hosts routers "host list&!!" unset
19379 .cindex "IP address" "discarding"
19380 .cindex "router" "discarding IP addresses"
19381 Although this option is a host list, it should normally contain IP address
19382 entries rather than names. If any host that is looked up by the router has an
19383 IP address that matches an item in this list, Exim behaves as if that IP
19384 address did not exist. This option allows you to cope with rogue DNS entries
19385 like
19386 .code
19387 remote.domain.example.  A  127.0.0.1
19388 .endd
19389 by setting
19390 .code
19391 ignore_target_hosts = 127.0.0.1
19392 .endd
19393 on the relevant router. If all the hosts found by a &(dnslookup)& router are
19394 discarded in this way, the router declines. In a conventional configuration, an
19395 attempt to mail to such a domain would normally provoke the &"unrouteable
19396 domain"& error, and an attempt to verify an address in the domain would fail.
19397 Similarly, if &%ignore_target_hosts%& is set on an &(ipliteral)& router, the
19398 router declines if presented with one of the listed addresses.
19399
19400 You can use this option to disable the use of IPv4 or IPv6 for mail delivery by
19401 means of the first or the second of the following settings, respectively:
19402 .code
19403 ignore_target_hosts = 0.0.0.0/0
19404 ignore_target_hosts = <; 0::0/0
19405 .endd
19406 The pattern in the first line matches all IPv4 addresses, whereas the pattern
19407 in the second line matches all IPv6 addresses.
19408
19409 This option may also be useful for ignoring link-local and site-local IPv6
19410 addresses. Because, like all host lists, the value of &%ignore_target_hosts%&
19411 is expanded before use as a list, it is possible to make it dependent on the
19412 domain that is being routed.
19413
19414 .vindex "&$host_address$&"
19415 During its expansion, &$host_address$& is set to the IP address that is being
19416 checked.
19417
19418 .option initgroups routers boolean false
19419 .cindex "additional groups"
19420 .cindex "groups" "additional"
19421 .cindex "local transports" "uid and gid"
19422 .cindex "transport" "local"
19423 If the router queues an address for a transport, and this option is true, and
19424 the uid supplied by the router is not overridden by the transport, the
19425 &[initgroups()]& function is called when running the transport to ensure that
19426 any additional groups associated with the uid are set up. See also &%group%&
19427 and &%user%& and the discussion in chapter &<<CHAPenvironment>>&.
19428
19429
19430
19431 .option local_part_prefix routers&!? "string list" unset
19432 .cindex affix "router precondition"
19433 .cindex "router" "prefix for local part"
19434 .cindex "prefix" "for local part, used in router"
19435 If this option is set, the router is skipped unless the local part starts with
19436 one of the given strings, or &%local_part_prefix_optional%& is true. See
19437 section &<<SECTrouprecon>>& for a list of the order in which preconditions are
19438 evaluated.
19439
19440 The list is scanned from left to right, and the first prefix that matches is
19441 used. A limited form of wildcard is available; if the prefix begins with an
19442 asterisk, it matches the longest possible sequence of arbitrary characters at
19443 the start of the local part. An asterisk should therefore always be followed by
19444 some character that does not occur in normal local parts.
19445 .cindex "multiple mailboxes"
19446 .cindex "mailbox" "multiple"
19447 Wildcarding can be used to set up multiple user mailboxes, as described in
19448 section &<<SECTmulbox>>&.
19449
19450 .vindex "&$local_part$&"
19451 .vindex "&$local_part_prefix$&"
19452 During the testing of the &%local_parts%& option, and while the router is
19453 running, the prefix is removed from the local part, and is available in the
19454 expansion variable &$local_part_prefix$&. When a message is being delivered, if
19455 the router accepts the address, this remains true during subsequent delivery by
19456 a transport. In particular, the local part that is transmitted in the RCPT
19457 command for LMTP, SMTP, and BSMTP deliveries has the prefix removed by default.
19458 This behaviour can be overridden by setting &%rcpt_include_affixes%& true on
19459 the relevant transport.
19460
19461 .vindex &$local_part_prefix_v$&
19462 If wildcarding (above) was used then the part of the prefix matching the
19463 wildcard is available in &$local_part_prefix_v$&.
19464
19465 When an address is being verified, &%local_part_prefix%& affects only the
19466 behaviour of the router. If the callout feature of verification is in use, this
19467 means that the full address, including the prefix, will be used during the
19468 callout.
19469
19470 The prefix facility is commonly used to handle local parts of the form
19471 &%owner-something%&. Another common use is to support local parts of the form
19472 &%real-username%& to bypass a user's &_.forward_& file &-- helpful when trying
19473 to tell a user their forwarding is broken &-- by placing a router like this one
19474 immediately before the router that handles &_.forward_& files:
19475 .code
19476 real_localuser:
19477   driver = accept
19478   local_part_prefix = real-
19479   check_local_user
19480   transport = local_delivery
19481 .endd
19482 For security, it would probably be a good idea to restrict the use of this
19483 router to locally-generated messages, using a condition such as this:
19484 .code
19485   condition = ${if match {$sender_host_address}\
19486                          {\N^(|127\.0\.0\.1)$\N}}
19487 .endd
19488
19489 If both &%local_part_prefix%& and &%local_part_suffix%& are set for a router,
19490 both conditions must be met if not optional. Care must be taken if wildcards
19491 are used in both a prefix and a suffix on the same router. Different
19492 separator characters must be used to avoid ambiguity.
19493
19494
19495 .option local_part_prefix_optional routers boolean false
19496 See &%local_part_prefix%& above.
19497
19498
19499
19500 .option local_part_suffix routers&!? "string list" unset
19501 .cindex "router" "suffix for local part"
19502 .cindex "suffix for local part" "used in router"
19503 This option operates in the same way as &%local_part_prefix%&, except that the
19504 local part must end (rather than start) with the given string, the
19505 &%local_part_suffix_optional%& option determines whether the suffix is
19506 mandatory, and the wildcard * character, if present, must be the last
19507 character of the suffix. This option facility is commonly used to handle local
19508 parts of the form &%something-request%& and multiple user mailboxes of the form
19509 &%username-foo%&.
19510
19511
19512 .option local_part_suffix_optional routers boolean false
19513 See &%local_part_suffix%& above.
19514
19515
19516
19517 .option local_parts routers&!? "local part list&!!" unset
19518 .cindex "router" "restricting to specific local parts"
19519 .cindex "local part" "checking in router"
19520 The router is run only if the local part of the address matches the list.
19521 See section &<<SECTrouprecon>>& for a list of the order in which preconditions
19522 are evaluated, and
19523 section &<<SECTlocparlis>>& for a discussion of local part lists. Because the
19524 string is expanded, it is possible to make it depend on the domain, for
19525 example:
19526 .code
19527 local_parts = dbm;/usr/local/specials/$domain_data
19528 .endd
19529 .vindex "&$local_part_data$&"
19530 the data returned by the list check
19531 for the local part is placed in the variable &$local_part_data$& for use in
19532 expansions of the router's private options or in the transport.
19533 You might use this option, for
19534 example, if you have a large number of local virtual domains, and you want to
19535 send all postmaster mail to the same place without having to set up an alias in
19536 each virtual domain:
19537 .code
19538 postmaster:
19539   driver = redirect
19540   local_parts = postmaster
19541   data = postmaster@real.domain.example
19542 .endd
19543
19544
19545 .option log_as_local routers boolean "see below"
19546 .cindex "log" "delivery line"
19547 .cindex "delivery" "log line format"
19548 Exim has two logging styles for delivery, the idea being to make local
19549 deliveries stand out more visibly from remote ones. In the &"local"& style, the
19550 recipient address is given just as the local part, without a domain. The use of
19551 this style is controlled by this option. It defaults to true for the &(accept)&
19552 router, and false for all the others. This option applies only when a
19553 router assigns an address to a transport. It has no effect on routers that
19554 redirect addresses.
19555
19556
19557
19558 .option more routers boolean&!! true
19559 The result of string expansion for this option must be a valid boolean value,
19560 that is, one of the strings &"yes"&, &"no"&, &"true"&, or &"false"&. Any other
19561 result causes an error, and delivery is deferred. If the expansion is forced to
19562 fail, the default value for the option (true) is used. Other failures cause
19563 delivery to be deferred.
19564
19565 If this option is set false, and the router declines to handle the address, no
19566 further routers are tried, routing fails, and the address is bounced.
19567 .oindex "&%self%&"
19568 However, if the router explicitly passes an address to the following router by
19569 means of the setting
19570 .code
19571 self = pass
19572 .endd
19573 or otherwise, the setting of &%more%& is ignored. Also, the setting of &%more%&
19574 does not affect the behaviour if one of the precondition tests fails. In that
19575 case, the address is always passed to the next router.
19576
19577 Note that &%address_data%& is not considered to be a precondition. If its
19578 expansion is forced to fail, the router declines, and the value of &%more%&
19579 controls what happens next.
19580
19581
19582 .option pass_on_timeout routers boolean false
19583 .cindex "timeout" "of router"
19584 .cindex "router" "timeout"
19585 If a router times out during a host lookup, it normally causes deferral of the
19586 address. If &%pass_on_timeout%& is set, the address is passed on to the next
19587 router, overriding &%no_more%&. This may be helpful for systems that are
19588 intermittently connected to the Internet, or those that want to pass to a smart
19589 host any messages that cannot immediately be delivered.
19590
19591 There are occasional other temporary errors that can occur while doing DNS
19592 lookups. They are treated in the same way as a timeout, and this option
19593 applies to all of them.
19594
19595
19596
19597 .option pass_router routers string unset
19598 .cindex "router" "go to after &""pass""&"
19599 Routers that recognize the generic &%self%& option (&(dnslookup)&,
19600 &(ipliteral)&, and &(manualroute)&) are able to return &"pass"&, forcing
19601 routing to continue, and overriding a false setting of &%more%&. When one of
19602 these routers returns &"pass"&, the address is normally handed on to the next
19603 router in sequence. This can be changed by setting &%pass_router%& to the name
19604 of another router. However (unlike &%redirect_router%&) the named router must
19605 be below the current router, to avoid loops. Note that this option applies only
19606 to the special case of &"pass"&. It does not apply when a router returns
19607 &"decline"& because it cannot handle an address.
19608
19609
19610
19611 .option redirect_router routers string unset
19612 .cindex "router" "start at after redirection"
19613 Sometimes an administrator knows that it is pointless to reprocess addresses
19614 generated from alias or forward files with the same router again. For
19615 example, if an alias file translates real names into login ids there is no
19616 point searching the alias file a second time, especially if it is a large file.
19617
19618 The &%redirect_router%& option can be set to the name of any router instance.
19619 It causes the routing of any generated addresses to start at the named router
19620 instead of at the first router. This option has no effect if the router in
19621 which it is set does not generate new addresses.
19622
19623
19624
19625 .option require_files routers&!? "string list&!!" unset
19626 .cindex "file" "requiring for router"
19627 .cindex "router" "requiring file existence"
19628 This option provides a general mechanism for predicating the running of a
19629 router on the existence or non-existence of certain files or directories.
19630 Before running a router, as one of its precondition tests, Exim works its way
19631 through the &%require_files%& list, expanding each item separately.
19632
19633 Because the list is split before expansion, any colons in expansion items must
19634 be doubled, or the facility for using a different list separator must be used
19635 (&<<SECTlistsepchange>>&).
19636 If any expansion is forced to fail, the item is ignored. Other expansion
19637 failures cause routing of the address to be deferred.
19638
19639 If any expanded string is empty, it is ignored. Otherwise, except as described
19640 below, each string must be a fully qualified file path, optionally preceded by
19641 &"!"&. The paths are passed to the &[stat()]& function to test for the
19642 existence of the files or directories. The router is skipped if any paths not
19643 preceded by &"!"& do not exist, or if any paths preceded by &"!"& do exist.
19644
19645 .cindex "NFS"
19646 If &[stat()]& cannot determine whether a file exists or not, delivery of
19647 the message is deferred. This can happen when NFS-mounted filesystems are
19648 unavailable.
19649
19650 This option is checked after the &%domains%&, &%local_parts%&, and &%senders%&
19651 options, so you cannot use it to check for the existence of a file in which to
19652 look up a domain, local part, or sender. (See section &<<SECTrouprecon>>& for a
19653 full list of the order in which preconditions are evaluated.) However, as
19654 these options are all expanded, you can use the &%exists%& expansion condition
19655 to make such tests. The &%require_files%& option is intended for checking files
19656 that the router may be going to use internally, or which are needed by a
19657 transport (e.g., &_.procmailrc_&).
19658
19659 During delivery, the &[stat()]& function is run as root, but there is a
19660 facility for some checking of the accessibility of a file by another user.
19661 This is not a proper permissions check, but just a &"rough"& check that
19662 operates as follows:
19663
19664 If an item in a &%require_files%& list does not contain any forward slash
19665 characters, it is taken to be the user (and optional group, separated by a
19666 comma) to be checked for subsequent files in the list. If no group is specified
19667 but the user is specified symbolically, the gid associated with the uid is
19668 used. For example:
19669 .code
19670 require_files = mail:/some/file
19671 require_files = $local_part_data:$home/.procmailrc
19672 .endd
19673 If a user or group name in a &%require_files%& list does not exist, the
19674 &%require_files%& condition fails.
19675
19676 Exim performs the check by scanning along the components of the file path, and
19677 checking the access for the given uid and gid. It checks for &"x"& access on
19678 directories, and &"r"& access on the final file. Note that this means that file
19679 access control lists, if the operating system has them, are ignored.
19680
19681 &*Warning 1*&: When the router is being run to verify addresses for an
19682 incoming SMTP message, Exim is not running as root, but under its own uid. This
19683 may affect the result of a &%require_files%& check. In particular, &[stat()]&
19684 may yield the error EACCES (&"Permission denied"&). This means that the Exim
19685 user is not permitted to read one of the directories on the file's path.
19686
19687 &*Warning 2*&: Even when Exim is running as root while delivering a message,
19688 &[stat()]& can yield EACCES for a file in an NFS directory that is mounted
19689 without root access. In this case, if a check for access by a particular user
19690 is requested, Exim creates a subprocess that runs as that user, and tries the
19691 check again in that process.
19692
19693 The default action for handling an unresolved EACCES is to consider it to
19694 be caused by a configuration error, and routing is deferred because the
19695 existence or non-existence of the file cannot be determined. However, in some
19696 circumstances it may be desirable to treat this condition as if the file did
19697 not exist. If the filename (or the exclamation mark that precedes the filename
19698 for non-existence) is preceded by a plus sign, the EACCES error is treated
19699 as if the file did not exist. For example:
19700 .code
19701 require_files = +/some/file
19702 .endd
19703 If the router is not an essential part of verification (for example, it
19704 handles users' &_.forward_& files), another solution is to set the &%verify%&
19705 option false so that the router is skipped when verifying.
19706
19707
19708
19709 .option retry_use_local_part routers boolean "see below"
19710 .cindex "hints database" "retry keys"
19711 .cindex "local part" "in retry keys"
19712 When a delivery suffers a temporary routing failure, a retry record is created
19713 in Exim's hints database. For addresses whose routing depends only on the
19714 domain, the key for the retry record should not involve the local part, but for
19715 other addresses, both the domain and the local part should be included.
19716 Usually, remote routing is of the former kind, and local routing is of the
19717 latter kind.
19718
19719 This option controls whether the local part is used to form the key for retry
19720 hints for addresses that suffer temporary errors while being handled by this
19721 router. The default value is true for any router that has any of
19722 &%check_local_user%&,
19723 &%local_parts%&,
19724 &%condition%&,
19725 &%local_part_prefix%&,
19726 &%local_part_suffix%&,
19727 &%senders%& or
19728 &%require_files%&
19729 set, and false otherwise. Note that this option does not apply to hints keys
19730 for transport delays; they are controlled by a generic transport option of the
19731 same name.
19732
19733 Failing to set this option when it is needed
19734 (because a remote router handles only some of the local-parts for a domain)
19735 can result in incorrect error messages being generated.
19736
19737 The setting of &%retry_use_local_part%& applies only to the router on which it
19738 appears. If the router generates child addresses, they are routed
19739 independently; this setting does not become attached to them.
19740
19741
19742
19743 .option router_home_directory routers string&!! unset
19744 .cindex "router" "home directory for"
19745 .cindex "home directory" "for router"
19746 .vindex "&$home$&"
19747 This option sets a home directory for use while the router is running. (Compare
19748 &%transport_home_directory%&, which sets a home directory for later
19749 transporting.) In particular, if used on a &(redirect)& router, this option
19750 sets a value for &$home$& while a filter is running. The value is expanded;
19751 forced expansion failure causes the option to be ignored &-- other failures
19752 cause the router to defer.
19753
19754 Expansion of &%router_home_directory%& happens immediately after the
19755 &%check_local_user%& test (if configured), before any further expansions take
19756 place.
19757 (See section &<<SECTrouprecon>>& for a list of the order in which preconditions
19758 are evaluated.)
19759 While the router is running, &%router_home_directory%& overrides the value of
19760 &$home$& that came from &%check_local_user%&.
19761
19762 When a router accepts an address and assigns it to a local transport (including
19763 the cases when a &(redirect)& router generates a pipe, file, or autoreply
19764 delivery), the home directory setting for the transport is taken from the first
19765 of these values that is set:
19766
19767 .ilist
19768 The &%home_directory%& option on the transport;
19769 .next
19770 The &%transport_home_directory%& option on the router;
19771 .next
19772 The password data if &%check_local_user%& is set on the router;
19773 .next
19774 The &%router_home_directory%& option on the router.
19775 .endlist
19776
19777 In other words, &%router_home_directory%& overrides the password data for the
19778 router, but not for the transport.
19779
19780
19781
19782 .option self routers string freeze
19783 .cindex "MX record" "pointing to local host"
19784 .cindex "local host" "MX pointing to"
19785 This option applies to those routers that use a recipient address to find a
19786 list of remote hosts. Currently, these are the &(dnslookup)&, &(ipliteral)&,
19787 and &(manualroute)& routers.
19788 Certain configurations of the &(queryprogram)& router can also specify a list
19789 of remote hosts.
19790 Usually such routers are configured to send the message to a remote host via an
19791 &(smtp)& transport. The &%self%& option specifies what happens when the first
19792 host on the list turns out to be the local host.
19793 The way in which Exim checks for the local host is described in section
19794 &<<SECTreclocipadd>>&.
19795
19796 Normally this situation indicates either an error in Exim's configuration (for
19797 example, the router should be configured not to process this domain), or an
19798 error in the DNS (for example, the MX should not point to this host). For this
19799 reason, the default action is to log the incident, defer the address, and
19800 freeze the message. The following alternatives are provided for use in special
19801 cases:
19802
19803 .vlist
19804 .vitem &%defer%&
19805 Delivery of the message is tried again later, but the message is not frozen.
19806
19807 .vitem "&%reroute%&: <&'domain'&>"
19808 The domain is changed to the given domain, and the address is passed back to
19809 be reprocessed by the routers. No rewriting of headers takes place. This
19810 behaviour is essentially a redirection.
19811
19812 .vitem "&%reroute: rewrite:%& <&'domain'&>"
19813 The domain is changed to the given domain, and the address is passed back to be
19814 reprocessed by the routers. Any headers that contain the original domain are
19815 rewritten.
19816
19817 .vitem &%pass%&
19818 .oindex "&%more%&"
19819 .vindex "&$self_hostname$&"
19820 The router passes the address to the next router, or to the router named in the
19821 &%pass_router%& option if it is set. This overrides &%no_more%&. During
19822 subsequent routing and delivery, the variable &$self_hostname$& contains the
19823 name of the local host that the router encountered. This can be used to
19824 distinguish between different cases for hosts with multiple names. The
19825 combination
19826 .code
19827 self = pass
19828 no_more
19829 .endd
19830 ensures that only those addresses that routed to the local host are passed on.
19831 Without &%no_more%&, addresses that were declined for other reasons would also
19832 be passed to the next router.
19833
19834 .vitem &%fail%&
19835 Delivery fails and an error report is generated.
19836
19837 .vitem &%send%&
19838 .cindex "local host" "sending to"
19839 The anomaly is ignored and the address is queued for the transport. This
19840 setting should be used with extreme caution. For an &(smtp)& transport, it
19841 makes sense only in cases where the program that is listening on the SMTP port
19842 is not this version of Exim. That is, it must be some other MTA, or Exim with a
19843 different configuration file that handles the domain in another way.
19844 .endlist
19845
19846
19847
19848 .option senders routers&!? "address list&!!" unset
19849 .cindex "router" "checking senders"
19850 If this option is set, the router is skipped unless the message's sender
19851 address matches something on the list.
19852 See section &<<SECTrouprecon>>& for a list of the order in which preconditions
19853 are evaluated.
19854
19855 There are issues concerning verification when the running of routers is
19856 dependent on the sender. When Exim is verifying the address in an &%errors_to%&
19857 setting, it sets the sender to the null string. When using the &%-bt%& option
19858 to check a configuration file, it is necessary also to use the &%-f%& option to
19859 set an appropriate sender. For incoming mail, the sender is unset when
19860 verifying the sender, but is available when verifying any recipients. If the
19861 SMTP VRFY command is enabled, it must be used after MAIL if the sender address
19862 matters.
19863
19864
19865 .option set routers "string list" unset
19866 .cindex router variables
19867 This option may be used multiple times on a router;
19868 because of this the list aspect is mostly irrelevant.
19869 The list separator is a semicolon but can be changed in the
19870 usual way.
19871
19872 Each list-element given must be of the form &"name = value"&
19873 and the names used must start with the string &"r_"&.
19874 Values containing a list-separator should have them doubled.
19875 When a router runs, the strings are evaluated in order,
19876 to create variables which are added to the set associated with
19877 the address.
19878 This is done immediately after all the preconditions, before the
19879 evaluation of the &%address_data%& option.
19880 The variable is set with the expansion of the value.
19881 The variables can be used by the router options
19882 (not including any preconditions)
19883 and by the transport.
19884 Later definitions of a given named variable will override former ones.
19885 Variable use is via the usual &$r_...$& syntax.
19886
19887 This is similar to the &%address_data%& option, except that
19888 many independent variables can be used, with choice of naming.
19889
19890
19891 .option translate_ip_address routers string&!! unset
19892 .cindex "IP address" "translating"
19893 .cindex "packet radio"
19894 .cindex "router" "IP address translation"
19895 There exist some rare networking situations (for example, packet radio) where
19896 it is helpful to be able to translate IP addresses generated by normal routing
19897 mechanisms into other IP addresses, thus performing a kind of manual IP
19898 routing. This should be done only if the normal IP routing of the TCP/IP stack
19899 is inadequate or broken. Because this is an extremely uncommon requirement, the
19900 code to support this option is not included in the Exim binary unless
19901 SUPPORT_TRANSLATE_IP_ADDRESS=yes is set in &_Local/Makefile_&.
19902
19903 .vindex "&$host_address$&"
19904 The &%translate_ip_address%& string is expanded for every IP address generated
19905 by the router, with the generated address set in &$host_address$&. If the
19906 expansion is forced to fail, no action is taken.
19907 For any other expansion error, delivery of the message is deferred.
19908 If the result of the expansion is an IP address, that replaces the original
19909 address; otherwise the result is assumed to be a host name &-- this is looked
19910 up using &[gethostbyname()]& (or &[getipnodebyname()]& when available) to
19911 produce one or more replacement IP addresses. For example, to subvert all IP
19912 addresses in some specific networks, this could be added to a router:
19913 .code
19914 translate_ip_address = \
19915   ${lookup{${mask:$host_address/26}}lsearch{/some/file}\
19916     {$value}fail}}
19917 .endd
19918 The file would contain lines like
19919 .code
19920 10.2.3.128/26    some.host
19921 10.8.4.34/26     10.44.8.15
19922 .endd
19923 You should not make use of this facility unless you really understand what you
19924 are doing.
19925
19926
19927
19928 .option transport routers string&!! unset
19929 This option specifies the transport to be used when a router accepts an address
19930 and sets it up for delivery. A transport is never needed if a router is used
19931 only for verification. The value of the option is expanded at routing time,
19932 after the expansion of &%errors_to%&, &%headers_add%&, and &%headers_remove%&,
19933 and result must be the name of one of the configured transports. If it is not,
19934 delivery is deferred.
19935
19936 The &%transport%& option is not used by the &(redirect)& router, but it does
19937 have some private options that set up transports for pipe and file deliveries
19938 (see chapter &<<CHAPredirect>>&).
19939
19940
19941
19942 .option transport_current_directory routers string&!! unset
19943 .cindex "current directory for local transport"
19944 This option associates a current directory with any address that is routed
19945 to a local transport. This can happen either because a transport is
19946 explicitly configured for the router, or because it generates a delivery to a
19947 file or a pipe. During the delivery process (that is, at transport time), this
19948 option string is expanded and is set as the current directory, unless
19949 overridden by a setting on the transport.
19950 If the expansion fails for any reason, including forced failure, an error is
19951 logged, and delivery is deferred.
19952 See chapter &<<CHAPenvironment>>& for details of the local delivery
19953 environment.
19954
19955
19956
19957
19958 .option transport_home_directory routers string&!! "see below"
19959 .cindex "home directory" "for local transport"
19960 This option associates a home directory with any address that is routed to a
19961 local transport. This can happen either because a transport is explicitly
19962 configured for the router, or because it generates a delivery to a file or a
19963 pipe. During the delivery process (that is, at transport time), the option
19964 string is expanded and is set as the home directory, unless overridden by a
19965 setting of &%home_directory%& on the transport.
19966 If the expansion fails for any reason, including forced failure, an error is
19967 logged, and delivery is deferred.
19968
19969 If the transport does not specify a home directory, and
19970 &%transport_home_directory%& is not set for the router, the home directory for
19971 the transport is taken from the password data if &%check_local_user%& is set for
19972 the router. Otherwise it is taken from &%router_home_directory%& if that option
19973 is set; if not, no home directory is set for the transport.
19974
19975 See chapter &<<CHAPenvironment>>& for further details of the local delivery
19976 environment.
19977
19978
19979
19980
19981 .option unseen routers boolean&!! false
19982 .cindex "router" "carrying on after success"
19983 The result of string expansion for this option must be a valid boolean value,
19984 that is, one of the strings &"yes"&, &"no"&, &"true"&, or &"false"&. Any other
19985 result causes an error, and delivery is deferred. If the expansion is forced to
19986 fail, the default value for the option (false) is used. Other failures cause
19987 delivery to be deferred.
19988
19989 When this option is set true, routing does not cease if the router accepts the
19990 address. Instead, a copy of the incoming address is passed to the next router,
19991 overriding a false setting of &%more%&. There is little point in setting
19992 &%more%& false if &%unseen%& is always true, but it may be useful in cases when
19993 the value of &%unseen%& contains expansion items (and therefore, presumably, is
19994 sometimes true and sometimes false).
19995
19996 .cindex "copy of message (&%unseen%& option)"
19997 Setting the &%unseen%& option has a similar effect to the &%unseen%& command
19998 qualifier in filter files. It can be used to cause copies of messages to be
19999 delivered to some other destination, while also carrying out a normal delivery.
20000 In effect, the current address is made into a &"parent"& that has two children
20001 &-- one that is delivered as specified by this router, and a clone that goes on
20002 to be routed further. For this reason, &%unseen%& may not be combined with the
20003 &%one_time%& option in a &(redirect)& router.
20004
20005 &*Warning*&: Header lines added to the address (or specified for removal) by
20006 this router or by previous routers affect the &"unseen"& copy of the message
20007 only. The clone that continues to be processed by further routers starts with
20008 no added headers and none specified for removal. For a &%redirect%& router, if
20009 a generated address is the same as the incoming address, this can lead to
20010 duplicate addresses with different header modifications. Exim does not do
20011 duplicate deliveries (except, in certain circumstances, to pipes -- see section
20012 &<<SECTdupaddr>>&), but it is undefined which of the duplicates is discarded,
20013 so this ambiguous situation should be avoided. The &%repeat_use%& option of the
20014 &%redirect%& router may be of help.
20015
20016 Unlike the handling of header modifications, any data that was set by the
20017 &%address_data%& option in the current or previous routers &'is'& passed on to
20018 subsequent routers.
20019
20020
20021 .option user routers string&!! "see below"
20022 .cindex "uid (user id)" "local delivery"
20023 .cindex "local transports" "uid and gid"
20024 .cindex "transport" "local"
20025 .cindex "router" "user for filter processing"
20026 .cindex "filter" "user for processing"
20027 When a router queues an address for a transport, and the transport does not
20028 specify a user, the user given here is used when running the delivery process.
20029 The user may be specified numerically or by name. If expansion fails, the
20030 error is logged and delivery is deferred.
20031 This user is also used by the &(redirect)& router when running a filter file.
20032 The default is unset, except when &%check_local_user%& is set. In this case,
20033 the default is taken from the password information. If the user is specified as
20034 a name, and &%group%& is not set, the group associated with the user is used.
20035 See also &%initgroups%& and &%group%& and the discussion in chapter
20036 &<<CHAPenvironment>>&.
20037
20038
20039
20040 .option verify routers&!? boolean true
20041 Setting this option has the effect of setting &%verify_sender%& and
20042 &%verify_recipient%& to the same value.
20043
20044
20045 .option verify_only routers&!? boolean false
20046 .cindex "EXPN" "with &%verify_only%&"
20047 .oindex "&%-bv%&"
20048 .cindex "router" "used only when verifying"
20049 If this option is set, the router is used only when verifying an address,
20050 delivering in cutthrough mode or
20051 testing with the &%-bv%& option, not when actually doing a delivery, testing
20052 with the &%-bt%& option, or running the SMTP EXPN command. It can be further
20053 restricted to verifying only senders or recipients by means of
20054 &%verify_sender%& and &%verify_recipient%&.
20055
20056 &*Warning*&: When the router is being run to verify addresses for an incoming
20057 SMTP message, Exim is not running as root, but under its own uid. If the router
20058 accesses any files, you need to make sure that they are accessible to the Exim
20059 user or group.
20060
20061
20062 .option verify_recipient routers&!? boolean true
20063 If this option is false, the router is skipped when verifying recipient
20064 addresses,
20065 delivering in cutthrough mode
20066 or testing recipient verification using &%-bv%&.
20067 See section &<<SECTrouprecon>>& for a list of the order in which preconditions
20068 are evaluated.
20069 See also the &$verify_mode$& variable.
20070
20071
20072 .option verify_sender routers&!? boolean true
20073 If this option is false, the router is skipped when verifying sender addresses
20074 or testing sender verification using &%-bvs%&.
20075 See section &<<SECTrouprecon>>& for a list of the order in which preconditions
20076 are evaluated.
20077 See also the &$verify_mode$& variable.
20078 .ecindex IIDgenoprou1
20079 .ecindex IIDgenoprou2
20080
20081
20082
20083
20084
20085
20086 . ////////////////////////////////////////////////////////////////////////////
20087 . ////////////////////////////////////////////////////////////////////////////
20088
20089 .chapter "The accept router" "CHID4"
20090 .cindex "&(accept)& router"
20091 .cindex "routers" "&(accept)&"
20092 The &(accept)& router has no private options of its own. Unless it is being
20093 used purely for verification (see &%verify_only%&) a transport is required to
20094 be defined by the generic &%transport%& option. If the preconditions that are
20095 specified by generic options are met, the router accepts the address and queues
20096 it for the given transport. The most common use of this router is for setting
20097 up deliveries to local mailboxes. For example:
20098 .code
20099 localusers:
20100   driver = accept
20101   domains = mydomain.example
20102   check_local_user
20103   transport = local_delivery
20104 .endd
20105 The &%domains%& condition in this example checks the domain of the address, and
20106 &%check_local_user%& checks that the local part is the login of a local user.
20107 When both preconditions are met, the &(accept)& router runs, and queues the
20108 address for the &(local_delivery)& transport.
20109
20110
20111
20112
20113
20114
20115 . ////////////////////////////////////////////////////////////////////////////
20116 . ////////////////////////////////////////////////////////////////////////////
20117
20118 .chapter "The dnslookup router" "CHAPdnslookup"
20119 .scindex IIDdnsrou1 "&(dnslookup)& router"
20120 .scindex IIDdnsrou2 "routers" "&(dnslookup)&"
20121 The &(dnslookup)& router looks up the hosts that handle mail for the
20122 recipient's domain in the DNS. A transport must always be set for this router,
20123 unless &%verify_only%& is set.
20124
20125 If SRV support is configured (see &%check_srv%& below), Exim first searches for
20126 SRV records. If none are found, or if SRV support is not configured,
20127 MX records are looked up. If no MX records exist, address records are sought.
20128 However, &%mx_domains%& can be set to disable the direct use of address
20129 records.
20130
20131 MX records of equal priority are sorted by Exim into a random order. Exim then
20132 looks for address records for the host names obtained from MX or SRV records.
20133 When a host has more than one IP address, they are sorted into a random order,
20134 except that IPv6 addresses are sorted before IPv4 addresses. If all the
20135 IP addresses found are discarded by a setting of the &%ignore_target_hosts%&
20136 generic option, the router declines.
20137
20138 Unless they have the highest priority (lowest MX value), MX records that point
20139 to the local host, or to any host name that matches &%hosts_treat_as_local%&,
20140 are discarded, together with any other MX records of equal or lower priority.
20141
20142 .cindex "MX record" "pointing to local host"
20143 .cindex "local host" "MX pointing to"
20144 .oindex "&%self%&" "in &(dnslookup)& router"
20145 If the host pointed to by the highest priority MX record, or looked up as an
20146 address record, is the local host, or matches &%hosts_treat_as_local%&, what
20147 happens is controlled by the generic &%self%& option.
20148
20149
20150 .section "Problems with DNS lookups" "SECTprowitdnsloo"
20151 There have been problems with DNS servers when SRV records are looked up.
20152 Some misbehaving servers return a DNS error or timeout when a non-existent
20153 SRV record is sought. Similar problems have in the past been reported for
20154 MX records. The global &%dns_again_means_nonexist%& option can help with this
20155 problem, but it is heavy-handed because it is a global option.
20156
20157 For this reason, there are two options, &%srv_fail_domains%& and
20158 &%mx_fail_domains%&, that control what happens when a DNS lookup in a
20159 &(dnslookup)& router results in a DNS failure or a &"try again"& response. If
20160 an attempt to look up an SRV or MX record causes one of these results, and the
20161 domain matches the relevant list, Exim behaves as if the DNS had responded &"no
20162 such record"&. In the case of an SRV lookup, this means that the router
20163 proceeds to look for MX records; in the case of an MX lookup, it proceeds to
20164 look for A or AAAA records, unless the domain matches &%mx_domains%&, in which
20165 case routing fails.
20166
20167
20168 .section "Declining addresses by dnslookup" "SECTdnslookupdecline"
20169 .cindex "&(dnslookup)& router" "declines"
20170 There are a few cases where a &(dnslookup)& router will decline to accept
20171 an address; if such a router is expected to handle "all remaining non-local
20172 domains", then it is important to set &%no_more%&.
20173
20174 The router will defer rather than decline if the domain
20175 is found in the &%fail_defer_domains%& router option.
20176
20177 Reasons for a &(dnslookup)& router to decline currently include:
20178 .ilist
20179 The domain does not exist in DNS
20180 .next
20181 The domain exists but the MX record's host part is just "."; this is a common
20182 convention (borrowed from SRV) used to indicate that there is no such service
20183 for this domain and to not fall back to trying A/AAAA records.
20184 .next
20185 Ditto, but for SRV records, when &%check_srv%& is set on this router.
20186 .next
20187 MX record points to a non-existent host.
20188 .next
20189 MX record points to an IP address and the main section option
20190 &%allow_mx_to_ip%& is not set.
20191 .next
20192 MX records exist and point to valid hosts, but all hosts resolve only to
20193 addresses blocked by the &%ignore_target_hosts%& generic option on this router.
20194 .next
20195 The domain is not syntactically valid (see also &%allow_utf8_domains%& and
20196 &%dns_check_names_pattern%& for handling one variant of this)
20197 .next
20198 &%check_secondary_mx%& is set on this router but the local host can
20199 not be found in the MX records (see below)
20200 .endlist
20201
20202
20203
20204
20205 .section "Private options for dnslookup" "SECID118"
20206 .cindex "options" "&(dnslookup)& router"
20207 The private options for the &(dnslookup)& router are as follows:
20208
20209 .option check_secondary_mx dnslookup boolean false
20210 .cindex "MX record" "checking for secondary"
20211 If this option is set, the router declines unless the local host is found in
20212 (and removed from) the list of hosts obtained by MX lookup. This can be used to
20213 process domains for which the local host is a secondary mail exchanger
20214 differently to other domains. The way in which Exim decides whether a host is
20215 the local host is described in section &<<SECTreclocipadd>>&.
20216
20217
20218 .option check_srv dnslookup string&!! unset
20219 .cindex "SRV record" "enabling use of"
20220 The &(dnslookup)& router supports the use of SRV records (see RFC 2782) in
20221 addition to MX and address records. The support is disabled by default. To
20222 enable SRV support, set the &%check_srv%& option to the name of the service
20223 required. For example,
20224 .code
20225 check_srv = smtp
20226 .endd
20227 looks for SRV records that refer to the normal smtp service. The option is
20228 expanded, so the service name can vary from message to message or address
20229 to address. This might be helpful if SRV records are being used for a
20230 submission service. If the expansion is forced to fail, the &%check_srv%&
20231 option is ignored, and the router proceeds to look for MX records in the
20232 normal way.
20233
20234 When the expansion succeeds, the router searches first for SRV records for
20235 the given service (it assumes TCP protocol). A single SRV record with a
20236 host name that consists of just a single dot indicates &"no such service for
20237 this domain"&; if this is encountered, the router declines. If other kinds of
20238 SRV record are found, they are used to construct a host list for delivery
20239 according to the rules of RFC 2782. MX records are not sought in this case.
20240
20241 When no SRV records are found, MX records (and address records) are sought in
20242 the traditional way. In other words, SRV records take precedence over MX
20243 records, just as MX records take precedence over address records. Note that
20244 this behaviour is not sanctioned by RFC 2782, though a previous draft RFC
20245 defined it. It is apparently believed that MX records are sufficient for email
20246 and that SRV records should not be used for this purpose. However, SRV records
20247 have an additional &"weight"& feature which some people might find useful when
20248 trying to split an SMTP load between hosts of different power.
20249
20250 See section &<<SECTprowitdnsloo>>& above for a discussion of Exim's behaviour
20251 when there is a DNS lookup error.
20252
20253
20254
20255
20256 .option fail_defer_domains dnslookup "domain list&!!" unset
20257 .cindex "MX record" "not found"
20258 DNS lookups for domains matching &%fail_defer_domains%&
20259 which find no matching record will cause the router to defer
20260 rather than the default behaviour of decline.
20261 This maybe be useful for queueing messages for a newly created
20262 domain while the DNS configuration is not ready.
20263 However, it will result in any message with mistyped domains
20264 also being queued.
20265
20266
20267 .option ipv4_only "string&!!" unset
20268 .cindex IPv6 disabling
20269 .cindex DNS "IPv6 disabling"
20270 The string is expanded, and if the result is anything but a forced failure,
20271 or an empty string, or one of the strings “0” or “no” or “false”
20272 (checked without regard to the case of the letters),
20273 only A records are used.
20274
20275 .option ipv4_prefer "string&!!" unset
20276 .cindex IPv4 preference
20277 .cindex DNS "IPv4 preference"
20278 The string is expanded, and if the result is anything but a forced failure,
20279 or an empty string, or one of the strings “0” or “no” or “false”
20280 (checked without regard to the case of the letters),
20281 A records are sorted before AAAA records (inverting the default).
20282
20283 .option mx_domains dnslookup "domain list&!!" unset
20284 .cindex "MX record" "required to exist"
20285 .cindex "SRV record" "required to exist"
20286 A domain that matches &%mx_domains%& is required to have either an MX or an SRV
20287 record in order to be recognized. (The name of this option could be improved.)
20288 For example, if all the mail hosts in &'fict.example'& are known to have MX
20289 records, except for those in &'discworld.fict.example'&, you could use this
20290 setting:
20291 .code
20292 mx_domains = ! *.discworld.fict.example : *.fict.example
20293 .endd
20294 This specifies that messages addressed to a domain that matches the list but
20295 has no MX record should be bounced immediately instead of being routed using
20296 the address record.
20297
20298
20299 .option mx_fail_domains dnslookup "domain list&!!" unset
20300 If the DNS lookup for MX records for one of the domains in this list causes a
20301 DNS lookup error, Exim behaves as if no MX records were found. See section
20302 &<<SECTprowitdnsloo>>& for more discussion.
20303
20304
20305
20306
20307 .option qualify_single dnslookup boolean true
20308 .cindex "DNS" "resolver options"
20309 .cindex "DNS" "qualifying single-component names"
20310 When this option is true, the resolver option RES_DEFNAMES is set for DNS
20311 lookups. Typically, but not standardly, this causes the resolver to qualify
20312 single-component names with the default domain. For example, on a machine
20313 called &'dictionary.ref.example'&, the domain &'thesaurus'& would be changed to
20314 &'thesaurus.ref.example'& inside the resolver. For details of what your
20315 resolver actually does, consult your man pages for &'resolver'& and
20316 &'resolv.conf'&.
20317
20318
20319
20320 .option rewrite_headers dnslookup boolean true
20321 .cindex "rewriting" "header lines"
20322 .cindex "header lines" "rewriting"
20323 If the domain name in the address that is being processed is not fully
20324 qualified, it may be expanded to its full form by a DNS lookup. For example, if
20325 an address is specified as &'dormouse@teaparty'&, the domain might be
20326 expanded to &'teaparty.wonderland.fict.example'&. Domain expansion can also
20327 occur as a result of setting the &%widen_domains%& option. If
20328 &%rewrite_headers%& is true, all occurrences of the abbreviated domain name in
20329 any &'Bcc:'&, &'Cc:'&, &'From:'&, &'Reply-to:'&, &'Sender:'&, and &'To:'&
20330 header lines of the message are rewritten with the full domain name.
20331
20332 This option should be turned off only when it is known that no message is
20333 ever going to be sent outside an environment where the abbreviation makes
20334 sense.
20335
20336 When an MX record is looked up in the DNS and matches a wildcard record, name
20337 servers normally return a record containing the name that has been looked up,
20338 making it impossible to detect whether a wildcard was present or not. However,
20339 some name servers have recently been seen to return the wildcard entry. If the
20340 name returned by a DNS lookup begins with an asterisk, it is not used for
20341 header rewriting.
20342
20343
20344 .option same_domain_copy_routing dnslookup boolean false
20345 .cindex "address" "copying routing"
20346 Addresses with the same domain are normally routed by the &(dnslookup)& router
20347 to the same list of hosts. However, this cannot be presumed, because the router
20348 options and preconditions may refer to the local part of the address. By
20349 default, therefore, Exim routes each address in a message independently. DNS
20350 servers run caches, so repeated DNS lookups are not normally expensive, and in
20351 any case, personal messages rarely have more than a few recipients.
20352
20353 If you are running mailing lists with large numbers of subscribers at the same
20354 domain, and you are using a &(dnslookup)& router which is independent of the
20355 local part, you can set &%same_domain_copy_routing%& to bypass repeated DNS
20356 lookups for identical domains in one message. In this case, when &(dnslookup)&
20357 routes an address to a remote transport, any other unrouted addresses in the
20358 message that have the same domain are automatically given the same routing
20359 without processing them independently,
20360 provided the following conditions are met:
20361
20362 .ilist
20363 No router that processed the address specified &%headers_add%& or
20364 &%headers_remove%&.
20365 .next
20366 The router did not change the address in any way, for example, by &"widening"&
20367 the domain.
20368 .endlist
20369
20370
20371
20372
20373 .option search_parents dnslookup boolean false
20374 .cindex "DNS" "resolver options"
20375 When this option is true, the resolver option RES_DNSRCH is set for DNS
20376 lookups. This is different from the &%qualify_single%& option in that it
20377 applies to domains containing dots. Typically, but not standardly, it causes
20378 the resolver to search for the name in the current domain and in parent
20379 domains. For example, on a machine in the &'fict.example'& domain, if looking
20380 up &'teaparty.wonderland'& failed, the resolver would try
20381 &'teaparty.wonderland.fict.example'&. For details of what your resolver
20382 actually does, consult your man pages for &'resolver'& and &'resolv.conf'&.
20383
20384 Setting this option true can cause problems in domains that have a wildcard MX
20385 record, because any domain that does not have its own MX record matches the
20386 local wildcard.
20387
20388
20389
20390 .option srv_fail_domains dnslookup "domain list&!!" unset
20391 If the DNS lookup for SRV records for one of the domains in this list causes a
20392 DNS lookup error, Exim behaves as if no SRV records were found. See section
20393 &<<SECTprowitdnsloo>>& for more discussion.
20394
20395
20396
20397
20398 .option widen_domains dnslookup "string list" unset
20399 .cindex "domain" "partial; widening"
20400 If a DNS lookup fails and this option is set, each of its strings in turn is
20401 added onto the end of the domain, and the lookup is tried again. For example,
20402 if
20403 .code
20404 widen_domains = fict.example:ref.example
20405 .endd
20406 is set and a lookup of &'klingon.dictionary'& fails,
20407 &'klingon.dictionary.fict.example'& is looked up, and if this fails,
20408 &'klingon.dictionary.ref.example'& is tried. Note that the &%qualify_single%&
20409 and &%search_parents%& options can cause some widening to be undertaken inside
20410 the DNS resolver. &%widen_domains%& is not applied to sender addresses
20411 when verifying, unless &%rewrite_headers%& is false (not the default).
20412
20413
20414 .section "Effect of qualify_single and search_parents" "SECID119"
20415 When a domain from an envelope recipient is changed by the resolver as a result
20416 of the &%qualify_single%& or &%search_parents%& options, Exim rewrites the
20417 corresponding address in the message's header lines unless &%rewrite_headers%&
20418 is set false. Exim then re-routes the address, using the full domain.
20419
20420 These two options affect only the DNS lookup that takes place inside the router
20421 for the domain of the address that is being routed. They do not affect lookups
20422 such as that implied by
20423 .code
20424 domains = @mx_any
20425 .endd
20426 that may happen while processing a router precondition before the router is
20427 entered. No widening ever takes place for these lookups.
20428 .ecindex IIDdnsrou1
20429 .ecindex IIDdnsrou2
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439 . ////////////////////////////////////////////////////////////////////////////
20440 . ////////////////////////////////////////////////////////////////////////////
20441
20442 .chapter "The ipliteral router" "CHID5"
20443 .cindex "&(ipliteral)& router"
20444 .cindex "domain literal" "routing"
20445 .cindex "routers" "&(ipliteral)&"
20446 This router has no private options. Unless it is being used purely for
20447 verification (see &%verify_only%&) a transport is required to be defined by the
20448 generic &%transport%& option. The router accepts the address if its domain part
20449 takes the form of an RFC 2822 domain literal. For example, the &(ipliteral)&
20450 router handles the address
20451 .code
20452 root@[192.168.1.1]
20453 .endd
20454 by setting up delivery to the host with that IP address. IPv4 domain literals
20455 consist of an IPv4 address enclosed in square brackets. IPv6 domain literals
20456 are similar, but the address is preceded by &`ipv6:`&. For example:
20457 .code
20458 postmaster@[ipv6:fe80::a00:20ff:fe86:a061.5678]
20459 .endd
20460 Exim allows &`ipv4:`& before IPv4 addresses, for consistency, and on the
20461 grounds that sooner or later somebody will try it.
20462
20463 .oindex "&%self%&" "in &(ipliteral)& router"
20464 If the IP address matches something in &%ignore_target_hosts%&, the router
20465 declines. If an IP literal turns out to refer to the local host, the generic
20466 &%self%& option determines what happens.
20467
20468 The RFCs require support for domain literals; however, their use is
20469 controversial in today's Internet. If you want to use this router, you must
20470 also set the main configuration option &%allow_domain_literals%&. Otherwise,
20471 Exim will not recognize the domain literal syntax in addresses.
20472
20473
20474
20475 . ////////////////////////////////////////////////////////////////////////////
20476 . ////////////////////////////////////////////////////////////////////////////
20477
20478 .chapter "The iplookup router" "CHID6"
20479 .cindex "&(iplookup)& router"
20480 .cindex "routers" "&(iplookup)&"
20481 The &(iplookup)& router was written to fulfil a specific requirement in
20482 Cambridge University (which in fact no longer exists). For this reason, it is
20483 not included in the binary of Exim by default. If you want to include it, you
20484 must set
20485 .code
20486 ROUTER_IPLOOKUP=yes
20487 .endd
20488 in your &_Local/Makefile_& configuration file.
20489
20490 The &(iplookup)& router routes an address by sending it over a TCP or UDP
20491 connection to one or more specific hosts. The host can then return the same or
20492 a different address &-- in effect rewriting the recipient address in the
20493 message's envelope. The new address is then passed on to subsequent routers. If
20494 this process fails, the address can be passed on to other routers, or delivery
20495 can be deferred. Since &(iplookup)& is just a rewriting router, a transport
20496 must not be specified for it.
20497
20498 .cindex "options" "&(iplookup)& router"
20499 .option hosts iplookup string unset
20500 This option must be supplied. Its value is a colon-separated list of host
20501 names. The hosts are looked up using &[gethostbyname()]&
20502 (or &[getipnodebyname()]& when available)
20503 and are tried in order until one responds to the query. If none respond, what
20504 happens is controlled by &%optional%&.
20505
20506
20507 .option optional iplookup boolean false
20508 If &%optional%& is true, if no response is obtained from any host, the address
20509 is passed to the next router, overriding &%no_more%&. If &%optional%& is false,
20510 delivery to the address is deferred.
20511
20512
20513 .option port iplookup integer 0
20514 .cindex "port" "&(iplookup)& router"
20515 This option must be supplied. It specifies the port number for the TCP or UDP
20516 call.
20517
20518
20519 .option protocol iplookup string udp
20520 This option can be set to &"udp"& or &"tcp"& to specify which of the two
20521 protocols is to be used.
20522
20523
20524 .option query iplookup string&!! "see below"
20525 This defines the content of the query that is sent to the remote hosts. The
20526 default value is:
20527 .code
20528 $local_part@$domain $local_part@$domain
20529 .endd
20530 The repetition serves as a way of checking that a response is to the correct
20531 query in the default case (see &%response_pattern%& below).
20532
20533
20534 .option reroute iplookup string&!! unset
20535 If this option is not set, the rerouted address is precisely the byte string
20536 returned by the remote host, up to the first white space, if any. If set, the
20537 string is expanded to form the rerouted address. It can include parts matched
20538 in the response by &%response_pattern%& by means of numeric variables such as
20539 &$1$&, &$2$&, etc. The variable &$0$& refers to the entire input string,
20540 whether or not a pattern is in use. In all cases, the rerouted address must end
20541 up in the form &'local_part@domain'&.
20542
20543
20544 .option response_pattern iplookup string unset
20545 This option can be set to a regular expression that is applied to the string
20546 returned from the remote host. If the pattern does not match the response, the
20547 router declines. If &%response_pattern%& is not set, no checking of the
20548 response is done, unless the query was defaulted, in which case there is a
20549 check that the text returned after the first white space is the original
20550 address. This checks that the answer that has been received is in response to
20551 the correct question. For example, if the response is just a new domain, the
20552 following could be used:
20553 .code
20554 response_pattern = ^([^@]+)$
20555 reroute = $local_part@$1
20556 .endd
20557
20558 .option timeout iplookup time 5s
20559 This specifies the amount of time to wait for a response from the remote
20560 machine. The same timeout is used for the &[connect()]& function for a TCP
20561 call. It does not apply to UDP.
20562
20563
20564
20565
20566 . ////////////////////////////////////////////////////////////////////////////
20567 . ////////////////////////////////////////////////////////////////////////////
20568
20569 .chapter "The manualroute router" "CHID7"
20570 .scindex IIDmanrou1 "&(manualroute)& router"
20571 .scindex IIDmanrou2 "routers" "&(manualroute)&"
20572 .cindex "domain" "manually routing"
20573 The &(manualroute)& router is so-called because it provides a way of manually
20574 routing an address according to its domain. It is mainly used when you want to
20575 route addresses to remote hosts according to your own rules, bypassing the
20576 normal DNS routing that looks up MX records. However, &(manualroute)& can also
20577 route to local transports, a facility that may be useful if you want to save
20578 messages for dial-in hosts in local files.
20579
20580 The &(manualroute)& router compares a list of domain patterns with the domain
20581 it is trying to route. If there is no match, the router declines. Each pattern
20582 has associated with it a list of hosts and some other optional data, which may
20583 include a transport. The combination of a pattern and its data is called a
20584 &"routing rule"&. For patterns that do not have an associated transport, the
20585 generic &%transport%& option must specify a transport, unless the router is
20586 being used purely for verification (see &%verify_only%&).
20587
20588 .vindex "&$host$&"
20589 In the case of verification, matching the domain pattern is sufficient for the
20590 router to accept the address. When actually routing an address for delivery,
20591 an address that matches a domain pattern is queued for the associated
20592 transport. If the transport is not a local one, a host list must be associated
20593 with the pattern; IP addresses are looked up for the hosts, and these are
20594 passed to the transport along with the mail address. For local transports, a
20595 host list is optional. If it is present, it is passed in &$host$& as a single
20596 text string.
20597
20598 The list of routing rules can be provided as an inline string in
20599 &%route_list%&, or the data can be obtained by looking up the domain in a file
20600 or database by setting &%route_data%&. Only one of these settings may appear in
20601 any one instance of &(manualroute)&. The format of routing rules is described
20602 below, following the list of private options.
20603
20604
20605 .section "Private options for manualroute" "SECTprioptman"
20606
20607 .cindex "options" "&(manualroute)& router"
20608 The private options for the &(manualroute)& router are as follows:
20609
20610 .option host_all_ignored manualroute string defer
20611 See &%host_find_failed%&.
20612
20613 .option host_find_failed manualroute string freeze
20614 This option controls what happens when &(manualroute)& tries to find an IP
20615 address for a host, and the host does not exist. The option can be set to one
20616 of the following values:
20617 .code
20618 decline
20619 defer
20620 fail
20621 freeze
20622 ignore
20623 pass
20624 .endd
20625 The default (&"freeze"&) assumes that this state is a serious configuration
20626 error. The difference between &"pass"& and &"decline"& is that the former
20627 forces the address to be passed to the next router (or the router defined by
20628 &%pass_router%&),
20629 .oindex "&%more%&"
20630 overriding &%no_more%&, whereas the latter passes the address to the next
20631 router only if &%more%& is true.
20632
20633 The value &"ignore"& causes Exim to completely ignore a host whose IP address
20634 cannot be found. If all the hosts in the list are ignored, the behaviour is
20635 controlled by the &%host_all_ignored%& option. This takes the same values
20636 as &%host_find_failed%&, except that it cannot be set to &"ignore"&.
20637
20638 The &%host_find_failed%& option applies only to a definite &"does not exist"&
20639 state; if a host lookup gets a temporary error, delivery is deferred unless the
20640 generic &%pass_on_timeout%& option is set.
20641
20642
20643 .option hosts_randomize manualroute boolean false
20644 .cindex "randomized host list"
20645 .cindex "host" "list of; randomized"
20646 If this option is set, the order of the items in a host list in a routing rule
20647 is randomized each time the list is used, unless an option in the routing rule
20648 overrides (see below). Randomizing the order of a host list can be used to do
20649 crude load sharing. However, if more than one mail address is routed by the
20650 same router to the same host list, the host lists are considered to be the same
20651 (even though they may be randomized into different orders) for the purpose of
20652 deciding whether to batch the deliveries into a single SMTP transaction.
20653
20654 When &%hosts_randomize%& is true, a host list may be split
20655 into groups whose order is separately randomized. This makes it possible to
20656 set up MX-like behaviour. The boundaries between groups are indicated by an
20657 item that is just &`+`& in the host list. For example:
20658 .code
20659 route_list = * host1:host2:host3:+:host4:host5
20660 .endd
20661 The order of the first three hosts and the order of the last two hosts is
20662 randomized for each use, but the first three always end up before the last two.
20663 If &%hosts_randomize%& is not set, a &`+`& item in the list is ignored. If a
20664 randomized host list is passed to an &(smtp)& transport that also has
20665 &%hosts_randomize set%&, the list is not re-randomized.
20666
20667
20668 .option route_data manualroute string&!! unset
20669 If this option is set, it must expand to yield the data part of a routing rule.
20670 Typically, the expansion string includes a lookup based on the domain. For
20671 example:
20672 .code
20673 route_data = ${lookup{$domain}dbm{/etc/routes}}
20674 .endd
20675 If the expansion is forced to fail, or the result is an empty string, the
20676 router declines. Other kinds of expansion failure cause delivery to be
20677 deferred.
20678
20679
20680 .option route_list manualroute "string list" unset
20681 This string is a list of routing rules, in the form defined below. Note that,
20682 unlike most string lists, the items are separated by semicolons. This is so
20683 that they may contain colon-separated host lists.
20684
20685
20686 .option same_domain_copy_routing manualroute boolean false
20687 .cindex "address" "copying routing"
20688 Addresses with the same domain are normally routed by the &(manualroute)&
20689 router to the same list of hosts. However, this cannot be presumed, because the
20690 router options and preconditions may refer to the local part of the address. By
20691 default, therefore, Exim routes each address in a message independently. DNS
20692 servers run caches, so repeated DNS lookups are not normally expensive, and in
20693 any case, personal messages rarely have more than a few recipients.
20694
20695 If you are running mailing lists with large numbers of subscribers at the same
20696 domain, and you are using a &(manualroute)& router which is independent of the
20697 local part, you can set &%same_domain_copy_routing%& to bypass repeated DNS
20698 lookups for identical domains in one message. In this case, when
20699 &(manualroute)& routes an address to a remote transport, any other unrouted
20700 addresses in the message that have the same domain are automatically given the
20701 same routing without processing them independently. However, this is only done
20702 if &%headers_add%& and &%headers_remove%& are unset.
20703
20704
20705
20706
20707 .section "Routing rules in route_list" "SECID120"
20708 The value of &%route_list%& is a string consisting of a sequence of routing
20709 rules, separated by semicolons. If a semicolon is needed in a rule, it can be
20710 entered as two semicolons. Alternatively, the list separator can be changed as
20711 described (for colon-separated lists) in section &<<SECTlistconstruct>>&.
20712 Empty rules are ignored. The format of each rule is
20713 .display
20714 <&'domain pattern'&>  <&'list of hosts'&>  <&'options'&>
20715 .endd
20716 The following example contains two rules, each with a simple domain pattern and
20717 no options:
20718 .code
20719 route_list = \
20720   dict.ref.example  mail-1.ref.example:mail-2.ref.example ; \
20721   thes.ref.example  mail-3.ref.example:mail-4.ref.example
20722 .endd
20723 The three parts of a rule are separated by white space. The pattern and the
20724 list of hosts can be enclosed in quotes if necessary, and if they are, the
20725 usual quoting rules apply. Each rule in a &%route_list%& must start with a
20726 single domain pattern, which is the only mandatory item in the rule. The
20727 pattern is in the same format as one item in a domain list (see section
20728 &<<SECTdomainlist>>&),
20729 except that it may not be the name of an interpolated file.
20730 That is, it may be wildcarded, or a regular expression, or a file or database
20731 lookup (with semicolons doubled, because of the use of semicolon as a separator
20732 in a &%route_list%&).
20733
20734 The rules in &%route_list%& are searched in order until one of the patterns
20735 matches the domain that is being routed. The list of hosts and then options are
20736 then used as described below. If there is no match, the router declines. When
20737 &%route_list%& is set, &%route_data%& must not be set.
20738
20739
20740
20741 .section "Routing rules in route_data" "SECID121"
20742 The use of &%route_list%& is convenient when there are only a small number of
20743 routing rules. For larger numbers, it is easier to use a file or database to
20744 hold the routing information, and use the &%route_data%& option instead.
20745 The value of &%route_data%& is a list of hosts, followed by (optional) options.
20746 Most commonly, &%route_data%& is set as a string that contains an
20747 expansion lookup. For example, suppose we place two routing rules in a file
20748 like this:
20749 .code
20750 dict.ref.example:  mail-1.ref.example:mail-2.ref.example
20751 thes.ref.example:  mail-3.ref.example:mail-4.ref.example
20752 .endd
20753 This data can be accessed by setting
20754 .code
20755 route_data = ${lookup{$domain}lsearch{/the/file/name}}
20756 .endd
20757 Failure of the lookup results in an empty string, causing the router to
20758 decline. However, you do not have to use a lookup in &%route_data%&. The only
20759 requirement is that the result of expanding the string is a list of hosts,
20760 possibly followed by options, separated by white space. The list of hosts must
20761 be enclosed in quotes if it contains white space.
20762
20763
20764
20765
20766 .section "Format of the list of hosts" "SECID122"
20767 A list of hosts, whether obtained via &%route_data%& or &%route_list%&, is
20768 always separately expanded before use. If the expansion fails, the router
20769 declines. The result of the expansion must be a colon-separated list of names
20770 and/or IP addresses, optionally also including ports.
20771 If the list is written with spaces, it must be protected with quotes.
20772 The format of each item
20773 in the list is described in the next section. The list separator can be changed
20774 as described in section &<<SECTlistsepchange>>&.
20775
20776 If the list of hosts was obtained from a &%route_list%& item, the following
20777 variables are set during its expansion:
20778
20779 .ilist
20780 .cindex "numerical variables (&$1$& &$2$&  etc)" "in &(manualroute)& router"
20781 If the domain was matched against a regular expression, the numeric variables
20782 &$1$&, &$2$&, etc. may be set. For example:
20783 .code
20784 route_list = ^domain(\d+)   host-$1.text.example
20785 .endd
20786 .next
20787 &$0$& is always set to the entire domain.
20788 .next
20789 &$1$& is also set when partial matching is done in a file lookup.
20790
20791 .next
20792 .vindex "&$value$&"
20793 If the pattern that matched the domain was a lookup item, the data that was
20794 looked up is available in the expansion variable &$value$&. For example:
20795 .code
20796 route_list = lsearch;;/some/file.routes  $value
20797 .endd
20798 .endlist
20799
20800 Note the doubling of the semicolon in the pattern that is necessary because
20801 semicolon is the default route list separator.
20802
20803
20804
20805 .section "Format of one host item" "SECTformatonehostitem"
20806 Each item in the list of hosts can be either a host name or an IP address,
20807 optionally with an attached port number, or it can be a single "+"
20808 (see &%hosts_randomize%&).
20809 When no port is given, an IP address
20810 is not enclosed in brackets. When a port is specified, it overrides the port
20811 specification on the transport. The port is separated from the name or address
20812 by a colon. This leads to some complications:
20813
20814 .ilist
20815 Because colon is the default separator for the list of hosts, either
20816 the colon that specifies a port must be doubled, or the list separator must
20817 be changed. The following two examples have the same effect:
20818 .code
20819 route_list = * "host1.tld::1225 : host2.tld::1226"
20820 route_list = * "<+ host1.tld:1225 + host2.tld:1226"
20821 .endd
20822 .next
20823 When IPv6 addresses are involved, it gets worse, because they contain
20824 colons of their own. To make this case easier, it is permitted to
20825 enclose an IP address (either v4 or v6) in square brackets if a port
20826 number follows. For example:
20827 .code
20828 route_list = * "</ [10.1.1.1]:1225 / [::1]:1226"
20829 .endd
20830 .endlist
20831
20832 .section "How the list of hosts is used" "SECThostshowused"
20833 When an address is routed to an &(smtp)& transport by &(manualroute)&, each of
20834 the hosts is tried, in the order specified, when carrying out the SMTP
20835 delivery. However, the order can be changed by setting the &%hosts_randomize%&
20836 option, either on the router (see section &<<SECTprioptman>>& above), or on the
20837 transport.
20838
20839 Hosts may be listed by name or by IP address. An unadorned name in the list of
20840 hosts is interpreted as a host name. A name that is followed by &`/MX`& is
20841 interpreted as an indirection to a sublist of hosts obtained by looking up MX
20842 records in the DNS. For example:
20843 .code
20844 route_list = *  x.y.z:p.q.r/MX:e.f.g
20845 .endd
20846 If this feature is used with a port specifier, the port must come last. For
20847 example:
20848 .code
20849 route_list = *  dom1.tld/mx::1225
20850 .endd
20851 If the &%hosts_randomize%& option is set, the order of the items in the list is
20852 randomized before any lookups are done. Exim then scans the list; for any name
20853 that is not followed by &`/MX`& it looks up an IP address. If this turns out to
20854 be an interface on the local host and the item is not the first in the list,
20855 Exim discards it and any subsequent items. If it is the first item, what
20856 happens is controlled by the
20857 .oindex "&%self%&" "in &(manualroute)& router"
20858 &%self%& option of the router.
20859
20860 A name on the list that is followed by &`/MX`& is replaced with the list of
20861 hosts obtained by looking up MX records for the name. This is always a DNS
20862 lookup; the &%bydns%& and &%byname%& options (see section &<<SECThowoptused>>&
20863 below) are not relevant here. The order of these hosts is determined by the
20864 preference values in the MX records, according to the usual rules. Because
20865 randomizing happens before the MX lookup, it does not affect the order that is
20866 defined by MX preferences.
20867
20868 If the local host is present in the sublist obtained from MX records, but is
20869 not the most preferred host in that list, it and any equally or less
20870 preferred hosts are removed before the sublist is inserted into the main list.
20871
20872 If the local host is the most preferred host in the MX list, what happens
20873 depends on where in the original list of hosts the &`/MX`& item appears. If it
20874 is not the first item (that is, there are previous hosts in the main list),
20875 Exim discards this name and any subsequent items in the main list.
20876
20877 If the MX item is first in the list of hosts, and the local host is the
20878 most preferred host, what happens is controlled by the &%self%& option of the
20879 router.
20880
20881 DNS failures when lookup up the MX records are treated in the same way as DNS
20882 failures when looking up IP addresses: &%pass_on_timeout%& and
20883 &%host_find_failed%& are used when relevant.
20884
20885 The generic &%ignore_target_hosts%& option applies to all hosts in the list,
20886 whether obtained from an MX lookup or not.
20887
20888
20889
20890 .section "How the options are used" "SECThowoptused"
20891 The options are a sequence of words, space-separated.
20892 One of the words can be the name of a transport; this overrides the
20893 &%transport%& option on the router for this particular routing rule only. The
20894 other words (if present) control randomization of the list of hosts on a
20895 per-rule basis, and how the IP addresses of the hosts are to be found when
20896 routing to a remote transport. These options are as follows:
20897
20898 .ilist
20899 &%randomize%&: randomize the order of the hosts in this list, overriding the
20900 setting of &%hosts_randomize%& for this routing rule only.
20901 .next
20902 &%no_randomize%&: do not randomize the order of the hosts in this list,
20903 overriding the setting of &%hosts_randomize%& for this routing rule only.
20904 .next
20905 &%byname%&: use &[getipnodebyname()]& (&[gethostbyname()]& on older systems) to
20906 find IP addresses. This function may ultimately cause a DNS lookup, but it may
20907 also look in &_/etc/hosts_& or other sources of information.
20908 .next
20909 &%bydns%&: look up address records for the hosts directly in the DNS; fail if
20910 no address records are found. If there is a temporary DNS error (such as a
20911 timeout), delivery is deferred.
20912 .next
20913 &%ipv4_only%&: in direct DNS lookups, look up only A records.
20914 .next
20915 &%ipv4_prefer%&: in direct DNS lookups, sort A records before AAAA records.
20916 .endlist
20917
20918 For example:
20919 .code
20920 route_list = domain1  host1:host2:host3  randomize bydns;\
20921              domain2  host4:host5
20922 .endd
20923 If neither &%byname%& nor &%bydns%& is given, Exim behaves as follows: First, a
20924 DNS lookup is done. If this yields anything other than HOST_NOT_FOUND, that
20925 result is used. Otherwise, Exim goes on to try a call to &[getipnodebyname()]&
20926 or &[gethostbyname()]&, and the result of the lookup is the result of that
20927 call.
20928
20929 &*Warning*&: It has been discovered that on some systems, if a DNS lookup
20930 called via &[getipnodebyname()]& times out, HOST_NOT_FOUND is returned
20931 instead of TRY_AGAIN. That is why the default action is to try a DNS
20932 lookup first. Only if that gives a definite &"no such host"& is the local
20933 function called.
20934
20935 &*Compatibility*&: From Exim 4.85 until fixed for 4.90, there was an
20936 inadvertent constraint that a transport name as an option had to be the last
20937 option specified.
20938
20939
20940
20941 If no IP address for a host can be found, what happens is controlled by the
20942 &%host_find_failed%& option.
20943
20944 .vindex "&$host$&"
20945 When an address is routed to a local transport, IP addresses are not looked up.
20946 The host list is passed to the transport in the &$host$& variable.
20947
20948
20949
20950 .section "Manualroute examples" "SECID123"
20951 In some of the examples that follow, the presence of the &%remote_smtp%&
20952 transport, as defined in the default configuration file, is assumed:
20953
20954 .ilist
20955 .cindex "smart host" "example router"
20956 The &(manualroute)& router can be used to forward all external mail to a
20957 &'smart host'&. If you have set up, in the main part of the configuration, a
20958 named domain list that contains your local domains, for example:
20959 .code
20960 domainlist local_domains = my.domain.example
20961 .endd
20962 You can arrange for all other domains to be routed to a smart host by making
20963 your first router something like this:
20964 .code
20965 smart_route:
20966   driver = manualroute
20967   domains = !+local_domains
20968   transport = remote_smtp
20969   route_list = * smarthost.ref.example
20970 .endd
20971 This causes all non-local addresses to be sent to the single host
20972 &'smarthost.ref.example'&. If a colon-separated list of smart hosts is given,
20973 they are tried in order
20974 (but you can use &%hosts_randomize%& to vary the order each time).
20975 Another way of configuring the same thing is this:
20976 .code
20977 smart_route:
20978   driver = manualroute
20979   transport = remote_smtp
20980   route_list = !+local_domains  smarthost.ref.example
20981 .endd
20982 There is no difference in behaviour between these two routers as they stand.
20983 However, they behave differently if &%no_more%& is added to them. In the first
20984 example, the router is skipped if the domain does not match the &%domains%&
20985 precondition; the following router is always tried. If the router runs, it
20986 always matches the domain and so can never decline. Therefore, &%no_more%&
20987 would have no effect. In the second case, the router is never skipped; it
20988 always runs. However, if it doesn't match the domain, it declines. In this case
20989 &%no_more%& would prevent subsequent routers from running.
20990
20991 .next
20992 .cindex "mail hub example"
20993 A &'mail hub'& is a host which receives mail for a number of domains via MX
20994 records in the DNS and delivers it via its own private routing mechanism. Often
20995 the final destinations are behind a firewall, with the mail hub being the one
20996 machine that can connect to machines both inside and outside the firewall. The
20997 &(manualroute)& router is usually used on a mail hub to route incoming messages
20998 to the correct hosts. For a small number of domains, the routing can be inline,
20999 using the &%route_list%& option, but for a larger number a file or database
21000 lookup is easier to manage.
21001
21002 If the domain names are in fact the names of the machines to which the mail is
21003 to be sent by the mail hub, the configuration can be quite simple. For
21004 example:
21005 .code
21006 hub_route:
21007   driver = manualroute
21008   transport = remote_smtp
21009   route_list = *.rhodes.tvs.example  $domain
21010 .endd
21011 This configuration routes domains that match &`*.rhodes.tvs.example`& to hosts
21012 whose names are the same as the mail domains. A similar approach can be taken
21013 if the host name can be obtained from the domain name by a string manipulation
21014 that the expansion facilities can handle. Otherwise, a lookup based on the
21015 domain can be used to find the host:
21016 .code
21017 through_firewall:
21018   driver = manualroute
21019   transport = remote_smtp
21020   route_data = ${lookup {$domain} cdb {/internal/host/routes}}
21021 .endd
21022 The result of the lookup must be the name or IP address of the host (or
21023 hosts) to which the address is to be routed. If the lookup fails, the route
21024 data is empty, causing the router to decline. The address then passes to the
21025 next router.
21026
21027 .next
21028 .cindex "batched SMTP output example"
21029 .cindex "SMTP" "batched outgoing; example"
21030 You can use &(manualroute)& to deliver messages to pipes or files in batched
21031 SMTP format for onward transportation by some other means. This is one way of
21032 storing mail for a dial-up host when it is not connected. The route list entry
21033 can be as simple as a single domain name in a configuration like this:
21034 .code
21035 save_in_file:
21036   driver = manualroute
21037   transport = batchsmtp_appendfile
21038   route_list = saved.domain.example
21039 .endd
21040 though often a pattern is used to pick up more than one domain. If there are
21041 several domains or groups of domains with different transport requirements,
21042 different transports can be listed in the routing information:
21043 .code
21044 save_in_file:
21045   driver = manualroute
21046   route_list = \
21047     *.saved.domain1.example  $domain  batch_appendfile; \
21048     *.saved.domain2.example  \
21049       ${lookup{$domain}dbm{/domain2/hosts}{$value}fail} \
21050       batch_pipe
21051 .endd
21052 .vindex "&$domain$&"
21053 .vindex "&$host$&"
21054 The first of these just passes the domain in the &$host$& variable, which
21055 doesn't achieve much (since it is also in &$domain$&), but the second does a
21056 file lookup to find a value to pass, causing the router to decline to handle
21057 the address if the lookup fails.
21058
21059 .next
21060 .cindex "UUCP" "example of router for"
21061 Routing mail directly to UUCP software is a specific case of the use of
21062 &(manualroute)& in a gateway to another mail environment. This is an example of
21063 one way it can be done:
21064 .code
21065 # Transport
21066 uucp:
21067   driver = pipe
21068   user = nobody
21069   command = /usr/local/bin/uux -r - \
21070     ${substr_-5:$host}!rmail ${local_part}
21071   return_fail_output = true
21072
21073 # Router
21074 uucphost:
21075   transport = uucp
21076   driver = manualroute
21077   route_data = \
21078     ${lookup{$domain}lsearch{/usr/local/exim/uucphosts}}
21079 .endd
21080 The file &_/usr/local/exim/uucphosts_& contains entries like
21081 .code
21082 darksite.ethereal.example:           darksite.UUCP
21083 .endd
21084 It can be set up more simply without adding and removing &".UUCP"& but this way
21085 makes clear the distinction between the domain name
21086 &'darksite.ethereal.example'& and the UUCP host name &'darksite'&.
21087 .endlist
21088 .ecindex IIDmanrou1
21089 .ecindex IIDmanrou2
21090
21091
21092
21093
21094
21095
21096
21097
21098 . ////////////////////////////////////////////////////////////////////////////
21099 . ////////////////////////////////////////////////////////////////////////////
21100
21101 .chapter "The queryprogram router" "CHAPdriverlast"
21102 .scindex IIDquerou1 "&(queryprogram)& router"
21103 .scindex IIDquerou2 "routers" "&(queryprogram)&"
21104 .cindex "routing" "by external program"
21105 The &(queryprogram)& router routes an address by running an external command
21106 and acting on its output. This is an expensive way to route, and is intended
21107 mainly for use in lightly-loaded systems, or for performing experiments.
21108 However, if it is possible to use the precondition options (&%domains%&,
21109 &%local_parts%&, etc) to skip this router for most addresses, it could sensibly
21110 be used in special cases, even on a busy host. There are the following private
21111 options:
21112 .cindex "options" "&(queryprogram)& router"
21113
21114 .option command queryprogram string&!! unset
21115 This option must be set. It specifies the command that is to be run. The
21116 command is split up into a command name and arguments, and then each is
21117 expanded separately (exactly as for a &(pipe)& transport, described in chapter
21118 &<<CHAPpipetransport>>&).
21119
21120
21121 .option command_group queryprogram string unset
21122 .cindex "gid (group id)" "in &(queryprogram)& router"
21123 This option specifies a gid to be set when running the command while routing an
21124 address for deliver. It must be set if &%command_user%& specifies a numerical
21125 uid. If it begins with a digit, it is interpreted as the numerical value of the
21126 gid. Otherwise it is looked up using &[getgrnam()]&.
21127
21128
21129 .option command_user queryprogram string unset
21130 .cindex "uid (user id)" "for &(queryprogram)&"
21131 This option must be set. It specifies the uid which is set when running the
21132 command while routing an address for delivery. If the value begins with a digit,
21133 it is interpreted as the numerical value of the uid. Otherwise, it is looked up
21134 using &[getpwnam()]& to obtain a value for the uid and, if &%command_group%& is
21135 not set, a value for the gid also.
21136
21137 &*Warning:*& Changing uid and gid is possible only when Exim is running as
21138 root, which it does during a normal delivery in a conventional configuration.
21139 However, when an address is being verified during message reception, Exim is
21140 usually running as the Exim user, not as root. If the &(queryprogram)& router
21141 is called from a non-root process, Exim cannot change uid or gid before running
21142 the command. In this circumstance the command runs under the current uid and
21143 gid.
21144
21145
21146 .option current_directory queryprogram string /
21147 This option specifies an absolute path which is made the current directory
21148 before running the command.
21149
21150
21151 .option timeout queryprogram time 1h
21152 If the command does not complete within the timeout period, its process group
21153 is killed and the message is frozen. A value of zero time specifies no
21154 timeout.
21155
21156
21157 The standard output of the command is connected to a pipe, which is read when
21158 the command terminates. It should consist of a single line of output,
21159 containing up to five fields, separated by white space. The maximum length of
21160 the line is 1023 characters. Longer lines are silently truncated. The first
21161 field is one of the following words (case-insensitive):
21162
21163 .ilist
21164 &'Accept'&: routing succeeded; the remaining fields specify what to do (see
21165 below).
21166 .next
21167 &'Decline'&: the router declines; pass the address to the next router, unless
21168 &%no_more%& is set.
21169 .next
21170 &'Fail'&: routing failed; do not pass the address to any more routers. Any
21171 subsequent text on the line is an error message. If the router is run as part
21172 of address verification during an incoming SMTP message, the message is
21173 included in the SMTP response.
21174 .next
21175 &'Defer'&: routing could not be completed at this time; try again later. Any
21176 subsequent text on the line is an error message which is logged. It is not
21177 included in any SMTP response.
21178 .next
21179 &'Freeze'&: the same as &'defer'&, except that the message is frozen.
21180 .next
21181 &'Pass'&: pass the address to the next router (or the router specified by
21182 &%pass_router%&), overriding &%no_more%&.
21183 .next
21184 &'Redirect'&: the message is redirected. The remainder of the line is a list of
21185 new addresses, which are routed independently, starting with the first router,
21186 or the router specified by &%redirect_router%&, if set.
21187 .endlist
21188
21189 When the first word is &'accept'&, the remainder of the line consists of a
21190 number of keyed data values, as follows (split into two lines here, to fit on
21191 the page):
21192 .code
21193 ACCEPT TRANSPORT=<transport> HOSTS=<list of hosts>
21194 LOOKUP=byname|bydns DATA=<text>
21195 .endd
21196 The data items can be given in any order, and all are optional. If no transport
21197 is included, the transport specified by the generic &%transport%& option is
21198 used. The list of hosts and the lookup type are needed only if the transport is
21199 an &(smtp)& transport that does not itself supply a list of hosts.
21200
21201 The format of the list of hosts is the same as for the &(manualroute)& router.
21202 As well as host names and IP addresses with optional port numbers, as described
21203 in section &<<SECTformatonehostitem>>&, it may contain names followed by
21204 &`/MX`& to specify sublists of hosts that are obtained by looking up MX records
21205 (see section &<<SECThostshowused>>&).
21206
21207 If the lookup type is not specified, Exim behaves as follows when trying to
21208 find an IP address for each host: First, a DNS lookup is done. If this yields
21209 anything other than HOST_NOT_FOUND, that result is used. Otherwise, Exim
21210 goes on to try a call to &[getipnodebyname()]& or &[gethostbyname()]&, and the
21211 result of the lookup is the result of that call.
21212
21213 .vindex "&$address_data$&"
21214 If the DATA field is set, its value is placed in the &$address_data$&
21215 variable. For example, this return line
21216 .code
21217 accept hosts=x1.y.example:x2.y.example data="rule1"
21218 .endd
21219 routes the address to the default transport, passing a list of two hosts. When
21220 the transport runs, the string &"rule1"& is in &$address_data$&.
21221 .ecindex IIDquerou1
21222 .ecindex IIDquerou2
21223
21224
21225
21226
21227 . ////////////////////////////////////////////////////////////////////////////
21228 . ////////////////////////////////////////////////////////////////////////////
21229
21230 .chapter "The redirect router" "CHAPredirect"
21231 .scindex IIDredrou1 "&(redirect)& router"
21232 .scindex IIDredrou2 "routers" "&(redirect)&"
21233 .cindex "alias file" "in a &(redirect)& router"
21234 .cindex "address redirection" "&(redirect)& router"
21235 The &(redirect)& router handles several kinds of address redirection. Its most
21236 common uses are for resolving local part aliases from a central alias file
21237 (usually called &_/etc/aliases_&) and for handling users' personal &_.forward_&
21238 files, but it has many other potential uses. The incoming address can be
21239 redirected in several different ways:
21240
21241 .ilist
21242 It can be replaced by one or more new addresses which are themselves routed
21243 independently.
21244 .next
21245 It can be routed to be delivered to a given file or directory.
21246 .next
21247 It can be routed to be delivered to a specified pipe command.
21248 .next
21249 It can cause an automatic reply to be generated.
21250 .next
21251 It can be forced to fail, optionally with a custom error message.
21252 .next
21253 It can be temporarily deferred, optionally with a custom message.
21254 .next
21255 It can be discarded.
21256 .endlist
21257
21258 The generic &%transport%& option must not be set for &(redirect)& routers.
21259 However, there are some private options which define transports for delivery to
21260 files and pipes, and for generating autoreplies. See the &%file_transport%&,
21261 &%pipe_transport%& and &%reply_transport%& descriptions below.
21262
21263 If success DSNs have been requested
21264 .cindex "DSN" "success"
21265 .cindex "Delivery Status Notification" "success"
21266 redirection triggers one and the DSN options are not passed any further.
21267
21268
21269
21270 .section "Redirection data" "SECID124"
21271 The router operates by interpreting a text string which it obtains either by
21272 expanding the contents of the &%data%& option, or by reading the entire
21273 contents of a file whose name is given in the &%file%& option. These two
21274 options are mutually exclusive. The first is commonly used for handling system
21275 aliases, in a configuration like this:
21276 .code
21277 system_aliases:
21278   driver = redirect
21279   data = ${lookup{$local_part}lsearch{/etc/aliases}}
21280 .endd
21281 If the lookup fails, the expanded string in this example is empty. When the
21282 expansion of &%data%& results in an empty string, the router declines. A forced
21283 expansion failure also causes the router to decline; other expansion failures
21284 cause delivery to be deferred.
21285
21286 A configuration using &%file%& is commonly used for handling users'
21287 &_.forward_& files, like this:
21288 .code
21289 userforward:
21290   driver = redirect
21291   check_local_user
21292   file = $home/.forward
21293   no_verify
21294 .endd
21295 If the file does not exist, or causes no action to be taken (for example, it is
21296 empty or consists only of comments), the router declines. &*Warning*&: This
21297 is not the case when the file contains syntactically valid items that happen to
21298 yield empty addresses, for example, items containing only RFC 2822 address
21299 comments.
21300
21301 .cindex "tainted data" "in filenames"
21302 .cindex redirect "tainted data"
21303 Tainted data may not be used for a filename.
21304
21305 &*Warning*&: It is unwise to use &$local_part$& or &$domain$&
21306 directly for redirection,
21307 as they are provided by a potential attacker.
21308 In the examples above, &$local_part$& is used for looking up data held locally
21309 on the system, and not used directly (the second example derives &$home$& via
21310 the passsword file or database, using &$local_part$&).
21311
21312
21313
21314 .section "Forward files and address verification" "SECID125"
21315 .cindex "address redirection" "while verifying"
21316 It is usual to set &%no_verify%& on &(redirect)& routers which handle users'
21317 &_.forward_& files, as in the example above. There are two reasons for this:
21318
21319 .ilist
21320 When Exim is receiving an incoming SMTP message from a remote host, it is
21321 running under the Exim uid, not as root. Exim is unable to change uid to read
21322 the file as the user, and it may not be able to read it as the Exim user. So in
21323 practice the router may not be able to operate.
21324 .next
21325 However, even when the router can operate, the existence of a &_.forward_& file
21326 is unimportant when verifying an address. What should be checked is whether the
21327 local part is a valid user name or not. Cutting out the redirection processing
21328 saves some resources.
21329 .endlist
21330
21331
21332
21333
21334
21335
21336 .section "Interpreting redirection data" "SECID126"
21337 .cindex "Sieve filter" "specifying in redirection data"
21338 .cindex "filter" "specifying in redirection data"
21339 The contents of the data string, whether obtained from &%data%& or &%file%&,
21340 can be interpreted in two different ways:
21341
21342 .ilist
21343 If the &%allow_filter%& option is set true, and the data begins with the text
21344 &"#Exim filter"& or &"#Sieve filter"&, it is interpreted as a list of
21345 &'filtering'& instructions in the form of an Exim or Sieve filter file,
21346 respectively. Details of the syntax and semantics of filter files are described
21347 in a separate document entitled &'Exim's interfaces to mail filtering'&; this
21348 document is intended for use by end users.
21349 .next
21350 Otherwise, the data must be a comma-separated list of redirection items, as
21351 described in the next section.
21352 .endlist
21353
21354 When a message is redirected to a file (a &"mail folder"&), the filename given
21355 in a non-filter redirection list must always be an absolute path. A filter may
21356 generate a relative path &-- how this is handled depends on the transport's
21357 configuration. See section &<<SECTfildiropt>>& for a discussion of this issue
21358 for the &(appendfile)& transport.
21359
21360
21361
21362 .section "Items in a non-filter redirection list" "SECTitenonfilred"
21363 .cindex "address redirection" "non-filter list items"
21364 When the redirection data is not an Exim or Sieve filter, for example, if it
21365 comes from a conventional alias or forward file, it consists of a list of
21366 addresses, filenames, pipe commands, or certain special items (see section
21367 &<<SECTspecitredli>>& below). The special items can be individually enabled or
21368 disabled by means of options whose names begin with &%allow_%& or &%forbid_%&,
21369 depending on their default values. The items in the list are separated by
21370 commas or newlines.
21371 If a comma is required in an item, the entire item must be enclosed in double
21372 quotes.
21373
21374 Lines starting with a # character are comments, and are ignored, and # may
21375 also appear following a comma, in which case everything between the # and the
21376 next newline character is ignored.
21377
21378 If an item is entirely enclosed in double quotes, these are removed. Otherwise
21379 double quotes are retained because some forms of mail address require their use
21380 (but never to enclose the entire address). In the following description,
21381 &"item"& refers to what remains after any surrounding double quotes have been
21382 removed.
21383
21384 .vindex "&$local_part$&"
21385 &*Warning*&: If you use an Exim expansion to construct a redirection address,
21386 and the expansion contains a reference to &$local_part$&, you should make use
21387 of the &%quote_local_part%& expansion operator, in case the local part contains
21388 special characters. For example, to redirect all mail for the domain
21389 &'obsolete.example'&, retaining the existing local part, you could use this
21390 setting:
21391 .code
21392 data = ${quote_local_part:$local_part}@newdomain.example
21393 .endd
21394
21395
21396 .section "Redirecting to a local mailbox" "SECTredlocmai"
21397 .cindex "routing" "loops in"
21398 .cindex "loop" "while routing, avoidance of"
21399 .cindex "address redirection" "to local mailbox"
21400 A redirection item may safely be the same as the address currently under
21401 consideration. This does not cause a routing loop, because a router is
21402 automatically skipped if any ancestor of the address that is being processed
21403 is the same as the current address and was processed by the current router.
21404 Such an address is therefore passed to the following routers, so it is handled
21405 as if there were no redirection. When making this loop-avoidance test, the
21406 complete local part, including any prefix or suffix, is used.
21407
21408 .cindex "address redirection" "local part without domain"
21409 Specifying the same local part without a domain is a common usage in personal
21410 filter files when the user wants to have messages delivered to the local
21411 mailbox and also forwarded elsewhere. For example, the user whose login is
21412 &'cleo'& might have a &_.forward_& file containing this:
21413 .code
21414 cleo, cleopatra@egypt.example
21415 .endd
21416 .cindex "backslash in alias file"
21417 .cindex "alias file" "backslash in"
21418 For compatibility with other MTAs, such unqualified local parts may be
21419 preceded by &"\"&, but this is not a requirement for loop prevention. However,
21420 it does make a difference if more than one domain is being handled
21421 synonymously.
21422
21423 If an item begins with &"\"& and the rest of the item parses as a valid RFC
21424 2822 address that does not include a domain, the item is qualified using the
21425 domain of the incoming address. In the absence of a leading &"\"&, unqualified
21426 addresses are qualified using the value in &%qualify_recipient%&, but you can
21427 force the incoming domain to be used by setting &%qualify_preserve_domain%&.
21428
21429 Care must be taken if there are alias names for local users.
21430 Consider an MTA handling a single local domain where the system alias file
21431 contains:
21432 .code
21433 Sam.Reman: spqr
21434 .endd
21435 Now suppose that Sam (whose login id is &'spqr'&) wants to save copies of
21436 messages in the local mailbox, and also forward copies elsewhere. He creates
21437 this forward file:
21438 .code
21439 Sam.Reman, spqr@reme.elsewhere.example
21440 .endd
21441 With these settings, an incoming message addressed to &'Sam.Reman'& fails. The
21442 &(redirect)& router for system aliases does not process &'Sam.Reman'& the
21443 second time round, because it has previously routed it,
21444 and the following routers presumably cannot handle the alias. The forward file
21445 should really contain
21446 .code
21447 spqr, spqr@reme.elsewhere.example
21448 .endd
21449 but because this is such a common error, the &%check_ancestor%& option (see
21450 below) exists to provide a way to get round it. This is normally set on a
21451 &(redirect)& router that is handling users' &_.forward_& files.
21452
21453
21454
21455 .section "Special items in redirection lists" "SECTspecitredli"
21456 In addition to addresses, the following types of item may appear in redirection
21457 lists (that is, in non-filter redirection data):
21458
21459 .ilist
21460 .cindex "pipe" "in redirection list"
21461 .cindex "address redirection" "to pipe"
21462 An item is treated as a pipe command if it begins with &"|"& and does not parse
21463 as a valid RFC 2822 address that includes a domain. A transport for running the
21464 command must be specified by the &%pipe_transport%& option.
21465 Normally, either the router or the transport specifies a user and a group under
21466 which to run the delivery. The default is to use the Exim user and group.
21467
21468 Single or double quotes can be used for enclosing the individual arguments of
21469 the pipe command; no interpretation of escapes is done for single quotes. If
21470 the command contains a comma character, it is necessary to put the whole item
21471 in double quotes, for example:
21472 .code
21473 "|/some/command ready,steady,go"
21474 .endd
21475 since items in redirection lists are terminated by commas. Do not, however,
21476 quote just the command. An item such as
21477 .code
21478 |"/some/command ready,steady,go"
21479 .endd
21480 is interpreted as a pipe with a rather strange command name, and no arguments.
21481
21482 Note that the above example assumes that the text comes from a lookup source
21483 of some sort, so that the quotes are part of the data.  If composing a
21484 redirect router with a &%data%& option directly specifying this command, the
21485 quotes will be used by the configuration parser to define the extent of one
21486 string, but will not be passed down into the redirect router itself.  There
21487 are two main approaches to get around this: escape quotes to be part of the
21488 data itself, or avoid using this mechanism and instead create a custom
21489 transport with the &%command%& option set and reference that transport from
21490 an &%accept%& router.
21491
21492 .next
21493 .cindex "file" "in redirection list"
21494 .cindex "address redirection" "to file"
21495 An item is interpreted as a path name if it begins with &"/"& and does not
21496 parse as a valid RFC 2822 address that includes a domain. For example,
21497 .code
21498 /home/world/minbari
21499 .endd
21500 is treated as a filename, but
21501 .code
21502 /s=molari/o=babylon/@x400gate.way
21503 .endd
21504 is treated as an address. For a filename, a transport must be specified using
21505 the &%file_transport%& option. However, if the generated path name ends with a
21506 forward slash character, it is interpreted as a directory name rather than a
21507 filename, and &%directory_transport%& is used instead.
21508
21509 Normally, either the router or the transport specifies a user and a group under
21510 which to run the delivery. The default is to use the Exim user and group.
21511
21512 .cindex "&_/dev/null_&"
21513 However, if a redirection item is the path &_/dev/null_&, delivery to it is
21514 bypassed at a high level, and the log entry shows &"**bypassed**"&
21515 instead of a transport name. In this case the user and group are not used.
21516
21517 .next
21518 .cindex "included address list"
21519 .cindex "address redirection" "included external list"
21520 If an item is of the form
21521 .code
21522 :include:<path name>
21523 .endd
21524 a list of further items is taken from the given file and included at that
21525 point. &*Note*&: Such a file can not be a filter file; it is just an
21526 out-of-line addition to the list. The items in the included list are separated
21527 by commas or newlines and are not subject to expansion. If this is the first
21528 item in an alias list in an &(lsearch)& file, a colon must be used to terminate
21529 the alias name. This example is incorrect:
21530 .code
21531 list1    :include:/opt/lists/list1
21532 .endd
21533 It must be given as
21534 .code
21535 list1:   :include:/opt/lists/list1
21536 .endd
21537 .cindex "tainted data" "in filenames"
21538 .cindex redirect "tainted data"
21539 Tainted data may not be used for a filename.
21540 .next
21541 .cindex "address redirection" "to black hole"
21542 .cindex "delivery" "discard"
21543 .cindex "delivery" "blackhole"
21544 .cindex "black hole"
21545 .cindex "abandoning mail"
21546 Sometimes you want to throw away mail to a particular local part.  Making the
21547 &%data%& option expand to an empty string does not work, because that causes
21548 the router to decline. Instead, the alias item
21549 .code
21550 :blackhole:
21551 .endd
21552 can be used. It does what its name implies. No delivery is
21553 done, and no error message is generated. This has the same effect as specifying
21554 &_/dev/null_& as a destination, but it can be independently disabled.
21555
21556 &*Warning*&: If &':blackhole:'& appears anywhere in a redirection list, no
21557 delivery is done for the original local part, even if other redirection items
21558 are present. If you are generating a multi-item list (for example, by reading a
21559 database) and need the ability to provide a no-op item, you must use
21560 &_/dev/null_&.
21561
21562 .next
21563 .cindex "delivery" "forcing failure"
21564 .cindex "delivery" "forcing deferral"
21565 .cindex "failing delivery" "forcing"
21566 .cindex "deferred delivery, forcing"
21567 .cindex "customizing" "failure message"
21568 An attempt to deliver a particular address can be deferred or forced to fail by
21569 redirection items of the form
21570 .code
21571 :defer:
21572 :fail:
21573 .endd
21574 respectively. When a redirection list contains such an item, it applies
21575 to the entire redirection; any other items in the list are ignored. Any
21576 text following &':fail:'& or &':defer:'& is placed in the error text
21577 associated with the failure. For example, an alias file might contain:
21578 .code
21579 X.Employee:  :fail: Gone away, no forwarding address
21580 .endd
21581 In the case of an address that is being verified from an ACL or as the subject
21582 of a
21583 .cindex "VRFY" "error text, display of"
21584 VRFY command, the text is included in the SMTP error response by
21585 default.
21586 .cindex "EXPN" "error text, display of"
21587 The text is not included in the response to an EXPN command. In non-SMTP cases
21588 the text is included in the error message that Exim generates.
21589
21590 .cindex "SMTP" "error codes"
21591 By default for verify, Exim sends a 451 SMTP code for a &':defer:'&, and 550 for
21592 &':fail:'&. However, if the message starts with three digits followed by a
21593 space, optionally followed by an extended code of the form &'n.n.n'&, also
21594 followed by a space, and the very first digit is the same as the default error
21595 code, the code from the message is used instead. If the very first digit is
21596 incorrect, a panic error is logged, and the default code is used. You can
21597 suppress the use of the supplied code in a redirect router by setting the
21598 &%forbid_smtp_code%& option true. In this case, any SMTP code is quietly
21599 ignored.
21600
21601 .vindex "&$acl_verify_message$&"
21602 In an ACL, an explicitly provided message overrides the default, but the
21603 default message is available in the variable &$acl_verify_message$& and can
21604 therefore be included in a custom message if this is desired.
21605
21606 Normally the error text is the rest of the redirection list &-- a comma does
21607 not terminate it &-- but a newline does act as a terminator. Newlines are not
21608 normally present in alias expansions. In &(lsearch)& lookups they are removed
21609 as part of the continuation process, but they may exist in other kinds of
21610 lookup and in &':include:'& files.
21611
21612 During routing for message delivery (as opposed to verification), a redirection
21613 containing &':fail:'& causes an immediate failure of the incoming address,
21614 whereas &':defer:'& causes the message to remain in the queue so that a
21615 subsequent delivery attempt can happen at a later time. If an address is
21616 deferred for too long, it will ultimately fail, because the normal retry
21617 rules still apply.
21618
21619 .next
21620 .cindex "alias file" "exception to default"
21621 Sometimes it is useful to use a single-key search type with a default (see
21622 chapter &<<CHAPfdlookup>>&) to look up aliases. However, there may be a need
21623 for exceptions to the default. These can be handled by aliasing them to
21624 &':unknown:'&. This differs from &':fail:'& in that it causes the &(redirect)&
21625 router to decline, whereas &':fail:'& forces routing to fail. A lookup which
21626 results in an empty redirection list has the same effect.
21627 .endlist
21628
21629
21630 .section "Duplicate addresses" "SECTdupaddr"
21631 .cindex "duplicate addresses"
21632 .cindex "address duplicate, discarding"
21633 .cindex "pipe" "duplicated"
21634 Exim removes duplicate addresses from the list to which it is delivering, so as
21635 to deliver just one copy to each address. This does not apply to deliveries
21636 routed to pipes by different immediate parent addresses, but an indirect
21637 aliasing scheme of the type
21638 .code
21639 pipe:       |/some/command $local_part
21640 localpart1: pipe
21641 localpart2: pipe
21642 .endd
21643 does not work with a message that is addressed to both local parts, because
21644 when the second is aliased to the intermediate local part &"pipe"& it gets
21645 discarded as being the same as a previously handled address. However, a scheme
21646 such as
21647 .code
21648 localpart1: |/some/command $local_part
21649 localpart2: |/some/command $local_part
21650 .endd
21651 does result in two different pipe deliveries, because the immediate parents of
21652 the pipes are distinct.
21653
21654
21655
21656 .section "Repeated redirection expansion" "SECID128"
21657 .cindex "repeated redirection expansion"
21658 .cindex "address redirection" "repeated for each delivery attempt"
21659 When a message cannot be delivered to all of its recipients immediately,
21660 leading to two or more delivery attempts, redirection expansion is carried out
21661 afresh each time for those addresses whose children were not all previously
21662 delivered. If redirection is being used as a mailing list, this can lead to new
21663 members of the list receiving copies of old messages. The &%one_time%& option
21664 can be used to avoid this.
21665
21666
21667 .section "Errors in redirection lists" "SECID129"
21668 .cindex "address redirection" "errors"
21669 If &%skip_syntax_errors%& is set, a malformed address that causes a parsing
21670 error is skipped, and an entry is written to the main log. This may be useful
21671 for mailing lists that are automatically managed. Otherwise, if an error is
21672 detected while generating the list of new addresses, the original address is
21673 deferred. See also &%syntax_errors_to%&.
21674
21675
21676
21677 .section "Private options for the redirect router" "SECID130"
21678
21679 .cindex "options" "&(redirect)& router"
21680 The private options for the &(redirect)& router are as follows:
21681
21682
21683 .option allow_defer redirect boolean false
21684 Setting this option allows the use of &':defer:'& in non-filter redirection
21685 data, or the &%defer%& command in an Exim filter file.
21686
21687
21688 .option allow_fail redirect boolean false
21689 .cindex "failing delivery" "from filter"
21690 If this option is true, the &':fail:'& item can be used in a redirection list,
21691 and the &%fail%& command may be used in an Exim filter file.
21692
21693
21694 .option allow_filter redirect boolean false
21695 .cindex "filter" "enabling use of"
21696 .cindex "Sieve filter" "enabling use of"
21697 Setting this option allows Exim to interpret redirection data that starts with
21698 &"#Exim filter"& or &"#Sieve filter"& as a set of filtering instructions. There
21699 are some features of Exim filter files that some administrators may wish to
21700 lock out; see the &%forbid_filter_%&&'xxx'& options below.
21701
21702 It is also possible to lock out Exim filters or Sieve filters while allowing
21703 the other type; see &%forbid_exim_filter%& and &%forbid_sieve_filter%&.
21704
21705
21706 The filter is run using the uid and gid set by the generic &%user%& and
21707 &%group%& options. These take their defaults from the password data if
21708 &%check_local_user%& is set, so in the normal case of users' personal filter
21709 files, the filter is run as the relevant user. When &%allow_filter%& is set
21710 true, Exim insists that either &%check_local_user%& or &%user%& is set.
21711
21712
21713
21714 .option allow_freeze redirect boolean false
21715 .cindex "freezing messages" "allowing in filter"
21716 Setting this option allows the use of the &%freeze%& command in an Exim filter.
21717 This command is more normally encountered in system filters, and is disabled by
21718 default for redirection filters because it isn't something you usually want to
21719 let ordinary users do.
21720
21721
21722
21723 .option check_ancestor redirect boolean false
21724 This option is concerned with handling generated addresses that are the same
21725 as some address in the list of redirection ancestors of the current address.
21726 Although it is turned off by default in the code, it is set in the default
21727 configuration file for handling users' &_.forward_& files. It is recommended
21728 for this use of the &(redirect)& router.
21729
21730 When &%check_ancestor%& is set, if a generated address (including the domain)
21731 is the same as any ancestor of the current address, it is replaced by a copy of
21732 the current address. This helps in the case where local part A is aliased to B,
21733 and B has a &_.forward_& file pointing back to A. For example, within a single
21734 domain, the local part &"Joe.Bloggs"& is aliased to &"jb"& and
21735 &_&~jb/.forward_& contains:
21736 .code
21737 \Joe.Bloggs, <other item(s)>
21738 .endd
21739 Without the &%check_ancestor%& setting, either local part (&"jb"& or
21740 &"joe.bloggs"&) gets processed once by each router and so ends up as it was
21741 originally. If &"jb"& is the real mailbox name, mail to &"jb"& gets delivered
21742 (having been turned into &"joe.bloggs"& by the &_.forward_& file and back to
21743 &"jb"& by the alias), but mail to &"joe.bloggs"& fails. Setting
21744 &%check_ancestor%& on the &(redirect)& router that handles the &_.forward_&
21745 file prevents it from turning &"jb"& back into &"joe.bloggs"& when that was the
21746 original address. See also the &%repeat_use%& option below.
21747
21748
21749 .option check_group redirect boolean "see below"
21750 When the &%file%& option is used, the group owner of the file is checked only
21751 when this option is set. The permitted groups are those listed in the
21752 &%owngroups%& option, together with the user's default group if
21753 &%check_local_user%& is set. If the file has the wrong group, routing is
21754 deferred. The default setting for this option is true if &%check_local_user%&
21755 is set and the &%modemask%& option permits the group write bit, or if the
21756 &%owngroups%& option is set. Otherwise it is false, and no group check occurs.
21757
21758
21759
21760 .option check_owner redirect boolean "see below"
21761 When the &%file%& option is used, the owner of the file is checked only when
21762 this option is set. If &%check_local_user%& is set, the local user is
21763 permitted; otherwise the owner must be one of those listed in the &%owners%&
21764 option. The default value for this option is true if &%check_local_user%& or
21765 &%owners%& is set. Otherwise the default is false, and no owner check occurs.
21766
21767
21768 .option data redirect string&!! unset
21769 This option is mutually exclusive with &%file%&. One or other of them must be
21770 set, but not both. The contents of &%data%& are expanded, and then used as the
21771 list of forwarding items, or as a set of filtering instructions. If the
21772 expansion is forced to fail, or the result is an empty string or a string that
21773 has no effect (consists entirely of comments), the router declines.
21774
21775 When filtering instructions are used, the string must begin with &"#Exim
21776 filter"&, and all comments in the string, including this initial one, must be
21777 terminated with newline characters. For example:
21778 .code
21779 data = #Exim filter\n\
21780        if $h_to: contains Exim then save $home/mail/exim endif
21781 .endd
21782 If you are reading the data from a database where newlines cannot be included,
21783 you can use the &${sg}$& expansion item to turn the escape string of your
21784 choice into a newline.
21785
21786
21787 .option directory_transport redirect string&!! unset
21788 A &(redirect)& router sets up a direct delivery to a directory when a path name
21789 ending with a slash is specified as a new &"address"&. The transport used is
21790 specified by this option, which, after expansion, must be the name of a
21791 configured transport. This should normally be an &(appendfile)& transport.
21792
21793
21794 .option file redirect string&!! unset
21795 This option specifies the name of a file that contains the redirection data. It
21796 is mutually exclusive with the &%data%& option. The string is expanded before
21797 use; if the expansion is forced to fail, the router declines. Other expansion
21798 failures cause delivery to be deferred. The result of a successful expansion
21799 must be an absolute path. The entire file is read and used as the redirection
21800 data. If the data is an empty string or a string that has no effect (consists
21801 entirely of comments), the router declines.
21802
21803 .cindex "NFS" "checking for file existence"
21804 If the attempt to open the file fails with a &"does not exist"& error, Exim
21805 runs a check on the containing directory,
21806 unless &%ignore_enotdir%& is true (see below).
21807 If the directory does not appear to exist, delivery is deferred. This can
21808 happen when users' &_.forward_& files are in NFS-mounted directories, and there
21809 is a mount problem. If the containing directory does exist, but the file does
21810 not, the router declines.
21811
21812
21813 .option file_transport redirect string&!! unset
21814 .vindex "&$address_file$&"
21815 A &(redirect)& router sets up a direct delivery to a file when a path name not
21816 ending in a slash is specified as a new &"address"&. The transport used is
21817 specified by this option, which, after expansion, must be the name of a
21818 configured transport. This should normally be an &(appendfile)& transport. When
21819 it is running, the filename is in &$address_file$&.
21820
21821
21822 .option filter_prepend_home redirect boolean true
21823 When this option is true, if a &(save)& command in an Exim filter specifies a
21824 relative path, and &$home$& is defined, it is automatically prepended to the
21825 relative path. If this option is set false, this action does not happen. The
21826 relative path is then passed to the transport unmodified.
21827
21828
21829 .option forbid_blackhole redirect boolean false
21830 .cindex "restricting access to features"
21831 .cindex "filter" "locking out certain features"
21832 If this option is true, the &':blackhole:'& item may not appear in a
21833 redirection list.
21834
21835
21836 .option forbid_exim_filter redirect boolean false
21837 .cindex "restricting access to features"
21838 .cindex "filter" "locking out certain features"
21839 If this option is set true, only Sieve filters are permitted when
21840 &%allow_filter%& is true.
21841
21842
21843
21844
21845 .option forbid_file redirect boolean false
21846 .cindex "restricting access to features"
21847 .cindex "delivery" "to file; forbidding"
21848 .cindex "filter" "locking out certain features"
21849 .cindex "Sieve filter" "forbidding delivery to a file"
21850 .cindex "Sieve filter" "&""keep""& facility; disabling"
21851 If this option is true, this router may not generate a new address that
21852 specifies delivery to a local file or directory, either from a filter or from a
21853 conventional forward file. This option is forced to be true if &%one_time%& is
21854 set. It applies to Sieve filters as well as to Exim filters, but if true, it
21855 locks out the Sieve's &"keep"& facility.
21856
21857
21858 .option forbid_filter_dlfunc redirect boolean false
21859 .cindex "restricting access to features"
21860 .cindex "filter" "locking out certain features"
21861 If this option is true, string expansions in Exim filters are not allowed to
21862 make use of the &%dlfunc%& expansion facility to run dynamically loaded
21863 functions.
21864
21865 .option forbid_filter_existstest redirect boolean false
21866 .cindex "restricting access to features"
21867 .cindex "filter" "locking out certain features"
21868 .cindex "expansion" "statting a file"
21869 If this option is true, string expansions in Exim filters are not allowed to
21870 make use of the &%exists%& condition or the &%stat%& expansion item.
21871
21872 .option forbid_filter_logwrite redirect boolean false
21873 .cindex "restricting access to features"
21874 .cindex "filter" "locking out certain features"
21875 If this option is true, use of the logging facility in Exim filters is not
21876 permitted. Logging is in any case available only if the filter is being run
21877 under some unprivileged uid (which is normally the case for ordinary users'
21878 &_.forward_& files).
21879
21880
21881 .option forbid_filter_lookup redirect boolean false
21882 .cindex "restricting access to features"
21883 .cindex "filter" "locking out certain features"
21884 If this option is true, string expansions in Exim filter files are not allowed
21885 to make use of &%lookup%& items.
21886
21887
21888 .option forbid_filter_perl redirect boolean false
21889 .cindex "restricting access to features"
21890 .cindex "filter" "locking out certain features"
21891 This option has an effect only if Exim is built with embedded Perl support. If
21892 it is true, string expansions in Exim filter files are not allowed to make use
21893 of the embedded Perl support.
21894
21895
21896 .option forbid_filter_readfile redirect boolean false
21897 .cindex "restricting access to features"
21898 .cindex "filter" "locking out certain features"
21899 If this option is true, string expansions in Exim filter files are not allowed
21900 to make use of &%readfile%& items.
21901
21902
21903 .option forbid_filter_readsocket redirect boolean false
21904 .cindex "restricting access to features"
21905 .cindex "filter" "locking out certain features"
21906 If this option is true, string expansions in Exim filter files are not allowed
21907 to make use of &%readsocket%& items.
21908
21909
21910 .option forbid_filter_reply redirect boolean false
21911 .cindex "restricting access to features"
21912 .cindex "filter" "locking out certain features"
21913 If this option is true, this router may not generate an automatic reply
21914 message. Automatic replies can be generated only from Exim or Sieve filter
21915 files, not from traditional forward files. This option is forced to be true if
21916 &%one_time%& is set.
21917
21918
21919 .option forbid_filter_run redirect boolean false
21920 .cindex "restricting access to features"
21921 .cindex "filter" "locking out certain features"
21922 If this option is true, string expansions in Exim filter files are not allowed
21923 to make use of &%run%& items.
21924
21925
21926 .option forbid_include redirect boolean false
21927 .cindex "restricting access to features"
21928 .cindex "filter" "locking out certain features"
21929 If this option is true, items of the form
21930 .code
21931 :include:<path name>
21932 .endd
21933 are not permitted in non-filter redirection lists.
21934
21935
21936 .option forbid_pipe redirect boolean false
21937 .cindex "restricting access to features"
21938 .cindex "filter" "locking out certain features"
21939 .cindex "delivery" "to pipe; forbidding"
21940 If this option is true, this router may not generate a new address which
21941 specifies delivery to a pipe, either from an Exim filter or from a conventional
21942 forward file. This option is forced to be true if &%one_time%& is set.
21943
21944
21945 .option forbid_sieve_filter redirect boolean false
21946 .cindex "restricting access to features"
21947 .cindex "filter" "locking out certain features"
21948 If this option is set true, only Exim filters are permitted when
21949 &%allow_filter%& is true.
21950
21951
21952 .cindex "SMTP" "error codes"
21953 .option forbid_smtp_code redirect boolean false
21954 If this option is set true, any SMTP error codes that are present at the start
21955 of messages specified for &`:defer:`& or &`:fail:`& are quietly ignored, and
21956 the default codes (451 and 550, respectively) are always used.
21957
21958
21959
21960
21961 .option hide_child_in_errmsg redirect boolean false
21962 .cindex "bounce message" "redirection details; suppressing"
21963 If this option is true, it prevents Exim from quoting a child address if it
21964 generates a bounce or delay message for it. Instead it says &"an address
21965 generated from <&'the top level address'&>"&. Of course, this applies only to
21966 bounces generated locally. If a message is forwarded to another host, &'its'&
21967 bounce may well quote the generated address.
21968
21969
21970 .option ignore_eacces redirect boolean false
21971 .cindex "EACCES"
21972 If this option is set and an attempt to open a redirection file yields the
21973 EACCES error (permission denied), the &(redirect)& router behaves as if the
21974 file did not exist.
21975
21976
21977 .option ignore_enotdir redirect boolean false
21978 .cindex "ENOTDIR"
21979 If this option is set and an attempt to open a redirection file yields the
21980 ENOTDIR error (something on the path is not a directory), the &(redirect)&
21981 router behaves as if the file did not exist.
21982
21983 Setting &%ignore_enotdir%& has another effect as well: When a &(redirect)&
21984 router that has the &%file%& option set discovers that the file does not exist
21985 (the ENOENT error), it tries to &[stat()]& the parent directory, as a check
21986 against unmounted NFS directories. If the parent can not be statted, delivery
21987 is deferred. However, it seems wrong to do this check when &%ignore_enotdir%&
21988 is set, because that option tells Exim to ignore &"something on the path is not
21989 a directory"& (the ENOTDIR error). This is a confusing area, because it seems
21990 that some operating systems give ENOENT where others give ENOTDIR.
21991
21992
21993
21994 .option include_directory redirect string unset
21995 If this option is set, the path names of any &':include:'& items in a
21996 redirection list must start with this directory.
21997
21998
21999 .option modemask redirect "octal integer" 022
22000 This specifies mode bits which must not be set for a file specified by the
22001 &%file%& option. If any of the forbidden bits are set, delivery is deferred.
22002
22003
22004 .option one_time redirect boolean false
22005 .cindex "one-time aliasing/forwarding expansion"
22006 .cindex "alias file" "one-time expansion"
22007 .cindex "forward file" "one-time expansion"
22008 .cindex "mailing lists" "one-time expansion"
22009 .cindex "address redirection" "one-time expansion"
22010 Sometimes the fact that Exim re-evaluates aliases and reprocesses redirection
22011 files each time it tries to deliver a message causes a problem when one or more
22012 of the generated addresses fails be delivered at the first attempt. The problem
22013 is not one of duplicate delivery &-- Exim is clever enough to handle that &--
22014 but of what happens when the redirection list changes during the time that the
22015 message is on Exim's queue. This is particularly true in the case of mailing
22016 lists, where new subscribers might receive copies of messages that were posted
22017 before they subscribed.
22018
22019 If &%one_time%& is set and any addresses generated by the router fail to
22020 deliver at the first attempt, the failing addresses are added to the message as
22021 &"top level"& addresses, and the parent address that generated them is marked
22022 &"delivered"&. Thus, redirection does not happen again at the next delivery
22023 attempt.
22024
22025 &*Warning 1*&: Any header line addition or removal that is specified by this
22026 router would be lost if delivery did not succeed at the first attempt. For this
22027 reason, the &%headers_add%& and &%headers_remove%& generic options are not
22028 permitted when &%one_time%& is set.
22029
22030 &*Warning 2*&: To ensure that the router generates only addresses (as opposed
22031 to pipe or file deliveries or auto-replies) &%forbid_file%&, &%forbid_pipe%&,
22032 and &%forbid_filter_reply%& are forced to be true when &%one_time%& is set.
22033
22034 &*Warning 3*&: The &%unseen%& generic router option may not be set with
22035 &%one_time%&.
22036
22037 The original top-level address is remembered with each of the generated
22038 addresses, and is output in any log messages. However, any intermediate parent
22039 addresses are not recorded. This makes a difference to the log only if
22040 &%all_parents%& log selector is set. It is expected that &%one_time%& will
22041 typically be used for mailing lists, where there is normally just one level of
22042 expansion.
22043
22044
22045 .option owners redirect "string list" unset
22046 .cindex "ownership" "alias file"
22047 .cindex "ownership" "forward file"
22048 .cindex "alias file" "ownership"
22049 .cindex "forward file" "ownership"
22050 This specifies a list of permitted owners for the file specified by &%file%&.
22051 This list is in addition to the local user when &%check_local_user%& is set.
22052 See &%check_owner%& above.
22053
22054
22055 .option owngroups redirect "string list" unset
22056 This specifies a list of permitted groups for the file specified by &%file%&.
22057 The list is in addition to the local user's primary group when
22058 &%check_local_user%& is set. See &%check_group%& above.
22059
22060
22061 .option pipe_transport redirect string&!! unset
22062 .vindex "&$address_pipe$&"
22063 A &(redirect)& router sets up a direct delivery to a pipe when a string
22064 starting with a vertical bar character is specified as a new &"address"&. The
22065 transport used is specified by this option, which, after expansion, must be the
22066 name of a configured transport. This should normally be a &(pipe)& transport.
22067 When the transport is run, the pipe command is in &$address_pipe$&.
22068
22069
22070 .option qualify_domain redirect string&!! unset
22071 .vindex "&$qualify_recipient$&"
22072 If this option is set, and an unqualified address (one without a domain) is
22073 generated, and that address would normally be qualified by the global setting
22074 in &%qualify_recipient%&, it is instead qualified with the domain specified by
22075 expanding this string. If the expansion fails, the router declines. If you want
22076 to revert to the default, you can have the expansion generate
22077 &$qualify_recipient$&.
22078
22079 This option applies to all unqualified addresses generated by Exim filters,
22080 but for traditional &_.forward_& files, it applies only to addresses that are
22081 not preceded by a backslash. Sieve filters cannot generate unqualified
22082 addresses.
22083
22084 .option qualify_preserve_domain redirect boolean false
22085 .cindex "domain" "in redirection; preserving"
22086 .cindex "preserving domain in redirection"
22087 .cindex "address redirection" "domain; preserving"
22088 If this option is set, the router's local &%qualify_domain%& option must not be
22089 set (a configuration error occurs if it is). If an unqualified address (one
22090 without a domain) is generated, it is qualified with the domain of the parent
22091 address (the immediately preceding ancestor) instead of the global
22092 &%qualify_recipient%& value. In the case of a traditional &_.forward_& file,
22093 this applies whether or not the address is preceded by a backslash.
22094
22095
22096 .option repeat_use redirect boolean true
22097 If this option is set false, the router is skipped for a child address that has
22098 any ancestor that was routed by this router. This test happens before any of
22099 the other preconditions are tested. Exim's default anti-looping rules skip
22100 only when the ancestor is the same as the current address. See also
22101 &%check_ancestor%& above and the generic &%redirect_router%& option.
22102
22103
22104 .option reply_transport redirect string&!! unset
22105 A &(redirect)& router sets up an automatic reply when a &%mail%& or
22106 &%vacation%& command is used in a filter file. The transport used is specified
22107 by this option, which, after expansion, must be the name of a configured
22108 transport. This should normally be an &(autoreply)& transport. Other transports
22109 are unlikely to do anything sensible or useful.
22110
22111
22112 .option rewrite redirect boolean true
22113 .cindex "address redirection" "disabling rewriting"
22114 If this option is set false, addresses generated by the router are not
22115 subject to address rewriting. Otherwise, they are treated like new addresses
22116 and are rewritten according to the global rewriting rules.
22117
22118
22119 .option sieve_subaddress redirect string&!! unset
22120 The value of this option is passed to a Sieve filter to specify the
22121 :subaddress part of an address.
22122
22123 .option sieve_useraddress redirect string&!! unset
22124 The value of this option is passed to a Sieve filter to specify the :user part
22125 of an address. However, if it is unset, the entire original local part
22126 (including any prefix or suffix) is used for :user.
22127
22128
22129 .option sieve_vacation_directory redirect string&!! unset
22130 .cindex "Sieve filter" "vacation directory"
22131 To enable the &"vacation"& extension for Sieve filters, you must set
22132 &%sieve_vacation_directory%& to the directory where vacation databases are held
22133 (do not put anything else in that directory), and ensure that the
22134 &%reply_transport%& option refers to an &(autoreply)& transport. Each user
22135 needs their own directory; Exim will create it if necessary.
22136
22137
22138
22139 .option skip_syntax_errors redirect boolean false
22140 .cindex "forward file" "broken"
22141 .cindex "address redirection" "broken files"
22142 .cindex "alias file" "broken"
22143 .cindex "broken alias or forward files"
22144 .cindex "ignoring faulty addresses"
22145 .cindex "skipping faulty addresses"
22146 .cindex "error" "skipping bad syntax"
22147 If &%skip_syntax_errors%& is set, syntactically malformed addresses in
22148 non-filter redirection data are skipped, and each failing address is logged. If
22149 &%syntax_errors_to%& is set, a message is sent to the address it defines,
22150 giving details of the failures. If &%syntax_errors_text%& is set, its contents
22151 are expanded and placed at the head of the error message generated by
22152 &%syntax_errors_to%&. Usually it is appropriate to set &%syntax_errors_to%& to
22153 be the same address as the generic &%errors_to%& option. The
22154 &%skip_syntax_errors%& option is often used when handling mailing lists.
22155
22156 If all the addresses in a redirection list are skipped because of syntax
22157 errors, the router declines to handle the original address, and it is passed to
22158 the following routers.
22159
22160 If &%skip_syntax_errors%& is set when an Exim filter is interpreted, any syntax
22161 error in the filter causes filtering to be abandoned without any action being
22162 taken. The incident is logged, and the router declines to handle the address,
22163 so it is passed to the following routers.
22164
22165 .cindex "Sieve filter" "syntax errors in"
22166 Syntax errors in a Sieve filter file cause the &"keep"& action to occur. This
22167 action is specified by RFC 3028. The values of &%skip_syntax_errors%&,
22168 &%syntax_errors_to%&, and &%syntax_errors_text%& are not used.
22169
22170 &%skip_syntax_errors%& can be used to specify that errors in users' forward
22171 lists or filter files should not prevent delivery. The &%syntax_errors_to%&
22172 option, used with an address that does not get redirected, can be used to
22173 notify users of these errors, by means of a router like this:
22174 .code
22175 userforward:
22176   driver = redirect
22177   allow_filter
22178   check_local_user
22179   file = $home/.forward
22180   file_transport = address_file
22181   pipe_transport = address_pipe
22182   reply_transport = address_reply
22183   no_verify
22184   skip_syntax_errors
22185   syntax_errors_to = real-$local_part@$domain
22186   syntax_errors_text = \
22187    This is an automatically generated message. An error has\n\
22188    been found in your .forward file. Details of the error are\n\
22189    reported below. While this error persists, you will receive\n\
22190    a copy of this message for every message that is addressed\n\
22191    to you. If your .forward file is a filter file, or if it is\n\
22192    a non-filter file containing no valid forwarding addresses,\n\
22193    a copy of each incoming message will be put in your normal\n\
22194    mailbox. If a non-filter file contains at least one valid\n\
22195    forwarding address, forwarding to the valid addresses will\n\
22196    happen, and those will be the only deliveries that occur.
22197 .endd
22198 You also need a router to ensure that local addresses that are prefixed by
22199 &`real-`& are recognized, but not forwarded or filtered. For example, you could
22200 put this immediately before the &(userforward)& router:
22201 .code
22202 real_localuser:
22203   driver = accept
22204   check_local_user
22205   local_part_prefix = real-
22206   transport = local_delivery
22207 .endd
22208 For security, it would probably be a good idea to restrict the use of this
22209 router to locally-generated messages, using a condition such as this:
22210 .code
22211   condition = ${if match {$sender_host_address}\
22212                          {\N^(|127\.0\.0\.1)$\N}}
22213 .endd
22214
22215
22216 .option syntax_errors_text redirect string&!! unset
22217 See &%skip_syntax_errors%& above.
22218
22219
22220 .option syntax_errors_to redirect string unset
22221 See &%skip_syntax_errors%& above.
22222 .ecindex IIDredrou1
22223 .ecindex IIDredrou2
22224
22225
22226
22227
22228
22229
22230 . ////////////////////////////////////////////////////////////////////////////
22231 . ////////////////////////////////////////////////////////////////////////////
22232
22233 .chapter "Environment for running local transports" "CHAPenvironment" &&&
22234          "Environment for local transports"
22235 .scindex IIDenvlotra1 "local transports" "environment for"
22236 .scindex IIDenvlotra2 "environment" "local transports"
22237 .scindex IIDenvlotra3 "transport" "local; environment for"
22238 Local transports handle deliveries to files and pipes. (The &(autoreply)&
22239 transport can be thought of as similar to a pipe.) Exim always runs transports
22240 in subprocesses, under specified uids and gids. Typical deliveries to local
22241 mailboxes run under the uid and gid of the local user.
22242
22243 Exim also sets a specific current directory while running the transport; for
22244 some transports a home directory setting is also relevant. The &(pipe)&
22245 transport is the only one that sets up environment variables; see section
22246 &<<SECTpipeenv>>& for details.
22247
22248 The values used for the uid, gid, and the directories may come from several
22249 different places. In many cases, the router that handles the address associates
22250 settings with that address as a result of its &%check_local_user%&, &%group%&,
22251 or &%user%& options. However, values may also be given in the transport's own
22252 configuration, and these override anything that comes from the router.
22253
22254
22255
22256 .section "Concurrent deliveries" "SECID131"
22257 .cindex "concurrent deliveries"
22258 .cindex "simultaneous deliveries"
22259 If two different messages for the same local recipient arrive more or less
22260 simultaneously, the two delivery processes are likely to run concurrently. When
22261 the &(appendfile)& transport is used to write to a file, Exim applies locking
22262 rules to stop concurrent processes from writing to the same file at the same
22263 time.
22264
22265 However, when you use a &(pipe)& transport, it is up to you to arrange any
22266 locking that is needed. Here is a silly example:
22267 .code
22268 my_transport:
22269   driver = pipe
22270   command = /bin/sh -c 'cat >>/some/file'
22271 .endd
22272 This is supposed to write the message at the end of the file. However, if two
22273 messages arrive at the same time, the file will be scrambled. You can use the
22274 &%exim_lock%& utility program (see section &<<SECTmailboxmaint>>&) to lock a
22275 file using the same algorithm that Exim itself uses.
22276
22277
22278
22279
22280 .section "Uids and gids" "SECTenvuidgid"
22281 .cindex "local transports" "uid and gid"
22282 .cindex "transport" "local; uid and gid"
22283 All transports have the options &%group%& and &%user%&. If &%group%& is set, it
22284 overrides any group that the router set in the address, even if &%user%& is not
22285 set for the transport. This makes it possible, for example, to run local mail
22286 delivery under the uid of the recipient (set by the router), but in a special
22287 group (set by the transport). For example:
22288 .code
22289 # Routers ...
22290 # User/group are set by check_local_user in this router
22291 local_users:
22292   driver = accept
22293   check_local_user
22294   transport = group_delivery
22295
22296 # Transports ...
22297 # This transport overrides the group
22298 group_delivery:
22299   driver = appendfile
22300   file = /var/spool/mail/$local_part_data
22301   group = mail
22302 .endd
22303 If &%user%& is set for a transport, its value overrides what is set in the
22304 address by the router. If &%user%& is non-numeric and &%group%& is not set, the
22305 gid associated with the user is used. If &%user%& is numeric, &%group%& must be
22306 set.
22307
22308 .oindex "&%initgroups%&"
22309 When the uid is taken from the transport's configuration, the &[initgroups()]&
22310 function is called for the groups associated with that uid if the
22311 &%initgroups%& option is set for the transport. When the uid is not specified
22312 by the transport, but is associated with the address by a router, the option
22313 for calling &[initgroups()]& is taken from the router configuration.
22314
22315 .cindex "&(pipe)& transport" "uid for"
22316 The &(pipe)& transport contains the special option &%pipe_as_creator%&. If this
22317 is set and &%user%& is not set, the uid of the process that called Exim to
22318 receive the message is used, and if &%group%& is not set, the corresponding
22319 original gid is also used.
22320
22321 This is the detailed preference order for obtaining a gid; the first of the
22322 following that is set is used:
22323
22324 .ilist
22325 A &%group%& setting of the transport;
22326 .next
22327 A &%group%& setting of the router;
22328 .next
22329 A gid associated with a user setting of the router, either as a result of
22330 &%check_local_user%& or an explicit non-numeric &%user%& setting;
22331 .next
22332 The group associated with a non-numeric &%user%& setting of the transport;
22333 .next
22334 In a &(pipe)& transport, the creator's gid if &%deliver_as_creator%& is set and
22335 the uid is the creator's uid;
22336 .next
22337 The Exim gid if the Exim uid is being used as a default.
22338 .endlist
22339
22340 If, for example, the user is specified numerically on the router and there are
22341 no group settings, no gid is available. In this situation, an error occurs.
22342 This is different for the uid, for which there always is an ultimate default.
22343 The first of the following that is set is used:
22344
22345 .ilist
22346 A &%user%& setting of the transport;
22347 .next
22348 In a &(pipe)& transport, the creator's uid if &%deliver_as_creator%& is set;
22349 .next
22350 A &%user%& setting of the router;
22351 .next
22352 A &%check_local_user%& setting of the router;
22353 .next
22354 The Exim uid.
22355 .endlist
22356
22357 Of course, an error will still occur if the uid that is chosen is on the
22358 &%never_users%& list.
22359
22360
22361
22362
22363
22364 .section "Current and home directories" "SECID132"
22365 .cindex "current directory for local transport"
22366 .cindex "home directory" "for local transport"
22367 .cindex "transport" "local; home directory for"
22368 .cindex "transport" "local; current directory for"
22369 Routers may set current and home directories for local transports by means of
22370 the &%transport_current_directory%& and &%transport_home_directory%& options.
22371 However, if the transport's &%current_directory%& or &%home_directory%& options
22372 are set, they override the router's values. In detail, the home directory
22373 for a local transport is taken from the first of these values that is set:
22374
22375 .ilist
22376 The &%home_directory%& option on the transport;
22377 .next
22378 The &%transport_home_directory%& option on the router;
22379 .next
22380 The password data if &%check_local_user%& is set on the router;
22381 .next
22382 The &%router_home_directory%& option on the router.
22383 .endlist
22384
22385 The current directory is taken from the first of these values that is set:
22386
22387 .ilist
22388 The &%current_directory%& option on the transport;
22389 .next
22390 The &%transport_current_directory%& option on the router.
22391 .endlist
22392
22393
22394 If neither the router nor the transport sets a current directory, Exim uses the
22395 value of the home directory, if it is set. Otherwise it sets the current
22396 directory to &_/_& before running a local transport.
22397
22398
22399
22400 .section "Expansion variables derived from the address" "SECID133"
22401 .vindex "&$domain$&"
22402 .vindex "&$local_part$&"
22403 .vindex "&$original_domain$&"
22404 Normally a local delivery is handling a single address, and in that case the
22405 variables such as &$domain$& and &$local_part$& are set during local
22406 deliveries. However, in some circumstances more than one address may be handled
22407 at once (for example, while writing batch SMTP for onward transmission by some
22408 other means). In this case, the variables associated with the local part are
22409 never set, &$domain$& is set only if all the addresses have the same domain,
22410 and &$original_domain$& is never set.
22411 .ecindex IIDenvlotra1
22412 .ecindex IIDenvlotra2
22413 .ecindex IIDenvlotra3
22414
22415
22416
22417
22418
22419
22420
22421 . ////////////////////////////////////////////////////////////////////////////
22422 . ////////////////////////////////////////////////////////////////////////////
22423
22424 .chapter "Generic options for transports" "CHAPtransportgeneric"
22425 .scindex IIDgenoptra1 "generic options" "transport"
22426 .scindex IIDgenoptra2 "options" "generic; for transports"
22427 .scindex IIDgenoptra3 "transport" "generic options for"
22428 The name of a transport is limited to be &drivernamemax; ASCII characters long;
22429 prior to Exim 4.95 names would be silently truncated at this length, but now
22430 it is enforced.
22431
22432 The following generic options apply to all transports:
22433
22434
22435 .option body_only transports boolean false
22436 .cindex "transport" "body only"
22437 .cindex "message" "transporting body only"
22438 .cindex "body of message" "transporting"
22439 If this option is set, the message's headers are not transported. It is
22440 mutually exclusive with &%headers_only%&. If it is used with the &(appendfile)&
22441 or &(pipe)& transports, the settings of &%message_prefix%& and
22442 &%message_suffix%& should be checked, because this option does not
22443 automatically suppress them.
22444
22445
22446 .option current_directory transports string&!! unset
22447 .cindex "transport" "current directory for"
22448 This specifies the current directory that is to be set while running the
22449 transport, overriding any value that may have been set by the router.
22450 If the expansion fails for any reason, including forced failure, an error is
22451 logged, and delivery is deferred.
22452
22453
22454 .option disable_logging transports boolean false
22455 If this option is set true, nothing is logged for any
22456 deliveries by the transport or for any
22457 transport errors. You should not set this option unless you really, really know
22458 what you are doing.
22459
22460
22461 .option debug_print transports string&!! unset
22462 .cindex "testing" "variables in drivers"
22463 If this option is set and debugging is enabled (see the &%-d%& command line
22464 option), the string is expanded and included in the debugging output when the
22465 transport is run.
22466 If expansion of the string fails, the error message is written to the debugging
22467 output, and Exim carries on processing.
22468 This facility is provided to help with checking out the values of variables and
22469 so on when debugging driver configurations. For example, if a &%headers_add%&
22470 option is not working properly, &%debug_print%& could be used to output the
22471 variables it references. A newline is added to the text if it does not end with
22472 one.
22473 The variables &$transport_name$& and &$router_name$& contain the name of the
22474 transport and the router that called it.
22475
22476 .option delivery_date_add transports boolean false
22477 .cindex "&'Delivery-date:'& header line"
22478 If this option is true, a &'Delivery-date:'& header is added to the message.
22479 This gives the actual time the delivery was made. As this is not a standard
22480 header, Exim has a configuration option (&%delivery_date_remove%&) which
22481 requests its removal from incoming messages, so that delivered messages can
22482 safely be resent to other recipients.
22483
22484
22485 .option driver transports string unset
22486 This specifies which of the available transport drivers is to be used.
22487 There is no default, and this option must be set for every transport.
22488
22489
22490 .option envelope_to_add transports boolean false
22491 .cindex "&'Envelope-to:'& header line"
22492 If this option is true, an &'Envelope-to:'& header is added to the message.
22493 This gives the original address(es) in the incoming envelope that caused this
22494 delivery to happen. More than one address may be present if the transport is
22495 configured to handle several addresses at once, or if more than one original
22496 address was redirected to the same final address. As this is not a standard
22497 header, Exim has a configuration option (&%envelope_to_remove%&) which requests
22498 its removal from incoming messages, so that delivered messages can safely be
22499 resent to other recipients.
22500
22501 &*Note:*& If used on a transport handling multiple recipients
22502 (the smtp transport unless &%max_rcpt%& is 1, the appendfile, pipe or lmtp
22503 transport if &%batch_max%& is greater than 1)
22504 then information about Bcc recipients will be leaked.
22505 Doing so is generally not advised.
22506
22507
22508 .option event_action transports string&!! unset
22509 .cindex events
22510 This option declares a string to be expanded for Exim's events mechanism.
22511 For details see chapter &<<CHAPevents>>&.
22512
22513
22514 .option group transports string&!! "Exim group"
22515 .cindex "transport" "group; specifying"
22516 This option specifies a gid for running the transport process, overriding any
22517 value that the router supplies, and also overriding any value associated with
22518 &%user%& (see below).
22519
22520
22521 .option headers_add transports list&!! unset
22522 .cindex "header lines" "adding in transport"
22523 .cindex "transport" "header lines; adding"
22524 This option specifies a list of text headers,
22525 newline-separated (by default, changeable in the usual way &<<SECTlistsepchange>>&),
22526 which are (separately) expanded and added to the header
22527 portion of a message as it is transported, as described in section
22528 &<<SECTheadersaddrem>>&. Additional header lines can also be specified by
22529 routers. If the result of the expansion is an empty string, or if the expansion
22530 is forced to fail, no action is taken. Other expansion failures are treated as
22531 errors and cause the delivery to be deferred.
22532
22533 Unlike most options, &%headers_add%& can be specified multiple times
22534 for a transport; all listed headers are added.
22535
22536
22537 .option headers_only transports boolean false
22538 .cindex "transport" "header lines only"
22539 .cindex "message" "transporting headers only"
22540 .cindex "header lines" "transporting"
22541 If this option is set, the message's body is not transported. It is mutually
22542 exclusive with &%body_only%&. If it is used with the &(appendfile)& or &(pipe)&
22543 transports, the settings of &%message_prefix%& and &%message_suffix%& should be
22544 checked, since this option does not automatically suppress them.
22545
22546
22547 .option headers_remove transports list&!! unset
22548 .cindex "header lines" "removing"
22549 .cindex "transport" "header lines; removing"
22550 This option specifies a list of text headers,
22551 colon-separated (by default, changeable in the usual way &<<SECTlistsepchange>>&),
22552 to be removed from the message.
22553 However, the option has no effect when an address is just being verified.
22554 Each list item is separately expanded.
22555 If the result of the expansion is an empty string, or if the expansion
22556 is forced to fail, no action is taken. Other expansion failures are treated as
22557 errors and cause the delivery to be deferred.
22558 If an item ends in *, it will match any header with the given prefix.
22559
22560 Matching headers are omitted from the message as it is transported, as described
22561 in section &<<SECTheadersaddrem>>&. Header removal can also be specified by
22562 routers.
22563
22564 Unlike most options, &%headers_remove%& can be specified multiple times
22565 for a transport; all listed headers are removed.
22566
22567 &*Warning*&: Because of the separate expansion of the list items,
22568 items that contain a list separator must have it doubled.
22569 To avoid this, change the list separator (&<<SECTlistsepchange>>&).
22570
22571
22572
22573 .option headers_rewrite transports string unset
22574 .cindex "transport" "header lines; rewriting"
22575 .cindex "rewriting" "at transport time"
22576 This option allows addresses in header lines to be rewritten at transport time,
22577 that is, as the message is being copied to its destination. The contents of the
22578 option are a colon-separated list of rewriting rules. Each rule is in exactly
22579 the same form as one of the general rewriting rules that are applied when a
22580 message is received. These are described in chapter &<<CHAPrewrite>>&. For
22581 example,
22582 .code
22583 headers_rewrite = a@b c@d f : \
22584                   x@y w@z
22585 .endd
22586 changes &'a@b'& into &'c@d'& in &'From:'& header lines, and &'x@y'& into
22587 &'w@z'& in all address-bearing header lines. The rules are applied to the
22588 header lines just before they are written out at transport time, so they affect
22589 only those copies of the message that pass through the transport. However, only
22590 the message's original header lines, and any that were added by a system
22591 filter, are rewritten. If a router or transport adds header lines, they are not
22592 affected by this option. These rewriting rules are &'not'& applied to the
22593 envelope. You can change the return path using &%return_path%&, but you cannot
22594 change envelope recipients at this time.
22595
22596
22597 .option home_directory transports string&!! unset
22598 .cindex "transport" "home directory for"
22599 .vindex "&$home$&"
22600 This option specifies a home directory setting for a local transport,
22601 overriding any value that may be set by the router. The home directory is
22602 placed in &$home$& while expanding the transport's private options. It is also
22603 used as the current directory if no current directory is set by the
22604 &%current_directory%& option on the transport or the
22605 &%transport_current_directory%& option on the router. If the expansion fails
22606 for any reason, including forced failure, an error is logged, and delivery is
22607 deferred.
22608
22609
22610 .option initgroups transports boolean false
22611 .cindex "additional groups"
22612 .cindex "groups" "additional"
22613 .cindex "transport" "group; additional"
22614 If this option is true and the uid for the delivery process is provided by the
22615 transport, the &[initgroups()]& function is called when running the transport
22616 to ensure that any additional groups associated with the uid are set up.
22617
22618
22619 .option max_parallel transports integer&!! unset
22620 .cindex limit "transport parallelism"
22621 .cindex transport "parallel processes"
22622 .cindex transport "concurrency limit"
22623 .cindex "delivery" "parallelism for transport"
22624 If this option is set and expands to an integer greater than zero
22625 it limits the number of concurrent runs of the transport.
22626 The control does not apply to shadow transports.
22627
22628 .cindex "hints database" "transport concurrency control"
22629 Exim implements this control by means of a hints database in which a record is
22630 incremented whenever a transport process is being created. The record
22631 is decremented and possibly removed when the process terminates.
22632 Obviously there is scope for
22633 records to get left lying around if there is a system or program crash. To
22634 guard against this, Exim ignores any records that are more than six hours old.
22635
22636 If you use this option, you should also arrange to delete the
22637 relevant hints database whenever your system reboots. The names of the files
22638 start with &_misc_& and they are kept in the &_spool/db_& directory. There
22639 may be one or two files, depending on the type of DBM in use. The same files
22640 are used for ETRN and smtp transport serialization.
22641
22642
22643 .option message_size_limit transports string&!! 0
22644 .cindex "limit" "message size per transport"
22645 .cindex "size" "of message, limit"
22646 .cindex "transport" "message size; limiting"
22647 This option controls the size of messages passed through the transport. It is
22648 expanded before use; the result of the expansion must be a sequence of decimal
22649 digits, optionally followed by K or M. If the expansion fails for any reason,
22650 including forced failure, or if the result is not of the required form,
22651 delivery is deferred. If the value is greater than zero and the size of a
22652 message exceeds this limit, the address is failed. If there is any chance that
22653 the resulting bounce message could be routed to the same transport, you should
22654 ensure that &%return_size_limit%& is less than the transport's
22655 &%message_size_limit%&, as otherwise the bounce message will fail to get
22656 delivered.
22657
22658
22659
22660 .option rcpt_include_affixes transports boolean false
22661 .cindex "prefix" "for local part, including in envelope"
22662 .cindex "suffix for local part" "including in envelope"
22663 .cindex "local part" "prefix"
22664 .cindex "local part" "suffix"
22665 When this option is false (the default), and an address that has had any
22666 affixes (prefixes or suffixes) removed from the local part is delivered by any
22667 form of SMTP or LMTP, the affixes are not included. For example, if a router
22668 that contains
22669 .code
22670 local_part_prefix = *-
22671 .endd
22672 routes the address &'abc-xyz@some.domain'& to an SMTP transport, the envelope
22673 is delivered with
22674 .code
22675 RCPT TO:<xyz@some.domain>
22676 .endd
22677 This is also the case when an ACL-time callout is being used to verify a
22678 recipient address. However, if &%rcpt_include_affixes%& is set true, the
22679 whole local part is included in the RCPT command. This option applies to BSMTP
22680 deliveries by the &(appendfile)& and &(pipe)& transports as well as to the
22681 &(lmtp)& and &(smtp)& transports.
22682
22683
22684 .option retry_use_local_part transports boolean "see below"
22685 .cindex "hints database" "retry keys"
22686 When a delivery suffers a temporary failure, a retry record is created
22687 in Exim's hints database. For remote deliveries, the key for the retry record
22688 is based on the name and/or IP address of the failing remote host. For local
22689 deliveries, the key is normally the entire address, including both the local
22690 part and the domain. This is suitable for most common cases of local delivery
22691 temporary failure &-- for example, exceeding a mailbox quota should delay only
22692 deliveries to that mailbox, not to the whole domain.
22693
22694 However, in some special cases you may want to treat a temporary local delivery
22695 as a failure associated with the domain, and not with a particular local part.
22696 (For example, if you are storing all mail for some domain in files.) You can do
22697 this by setting &%retry_use_local_part%& false.
22698
22699 For all the local transports, its default value is true. For remote transports,
22700 the default value is false for tidiness, but changing the value has no effect
22701 on a remote transport in the current implementation.
22702
22703
22704 .option return_path transports string&!! unset
22705 .cindex "envelope sender"
22706 .cindex "envelope from"
22707 .cindex "transport" "return path; changing"
22708 .cindex "return path" "changing in transport"
22709 If this option is set, the string is expanded at transport time and replaces
22710 the existing return path (envelope sender) value in the copy of the message
22711 that is being delivered. An empty return path is permitted. This feature is
22712 designed for remote deliveries, where the value of this option is used in the
22713 SMTP MAIL command. If you set &%return_path%& for a local transport, the
22714 only effect is to change the address that is placed in the &'Return-path:'&
22715 header line, if one is added to the message (see the next option).
22716
22717 &*Note:*& A changed return path is not logged unless you add
22718 &%return_path_on_delivery%& to the log selector.
22719
22720 .vindex "&$return_path$&"
22721 The expansion can refer to the existing value via &$return_path$&. This is
22722 either the message's envelope sender, or an address set by the
22723 &%errors_to%& option on a router. If the expansion is forced to fail, no
22724 replacement occurs; if it fails for another reason, delivery is deferred. This
22725 option can be used to support VERP (Variable Envelope Return Paths) &-- see
22726 section &<<SECTverp>>&.
22727
22728 &*Note*&: If a delivery error is detected locally, including the case when a
22729 remote server rejects a message at SMTP time, the bounce message is not sent to
22730 the value of this option. It is sent to the previously set errors address.
22731 This defaults to the incoming sender address, but can be changed by setting
22732 &%errors_to%& in a router.
22733
22734
22735
22736 .option return_path_add transports boolean false
22737 .chindex Return-path:
22738 If this option is true, a &'Return-path:'& header is added to the message.
22739 Although the return path is normally available in the prefix line of BSD
22740 mailboxes, this is commonly not displayed by MUAs, and so the user does not
22741 have easy access to it.
22742
22743 RFC 2821 states that the &'Return-path:'& header is added to a message &"when
22744 the delivery SMTP server makes the final delivery"&. This implies that this
22745 header should not be present in incoming messages. Exim has a configuration
22746 option, &%return_path_remove%&, which requests removal of this header from
22747 incoming messages, so that delivered messages can safely be resent to other
22748 recipients.
22749
22750
22751 .option shadow_condition transports string&!! unset
22752 See &%shadow_transport%& below.
22753
22754
22755 .option shadow_transport transports string unset
22756 .cindex "shadow transport"
22757 .cindex "transport" "shadow"
22758 A local transport may set the &%shadow_transport%& option to the name of
22759 another local transport. Shadow remote transports are not supported.
22760
22761 Whenever a delivery to the main transport succeeds, and either
22762 &%shadow_condition%& is unset, or its expansion does not result in the empty
22763 string or one of the strings &"0"& or &"no"& or &"false"&, the message is also
22764 passed to the shadow transport, with the same delivery address or addresses. If
22765 expansion fails, no action is taken except that non-forced expansion failures
22766 cause a log line to be written.
22767
22768 The result of the shadow transport is discarded and does not affect the
22769 subsequent processing of the message. Only a single level of shadowing is
22770 provided; the &%shadow_transport%& option is ignored on any transport when it
22771 is running as a shadow. Options concerned with output from pipes are also
22772 ignored. The log line for the successful delivery has an item added on the end,
22773 of the form
22774 .code
22775 ST=<shadow transport name>
22776 .endd
22777 If the shadow transport did not succeed, the error message is put in
22778 parentheses afterwards. Shadow transports can be used for a number of different
22779 purposes, including keeping more detailed log information than Exim normally
22780 provides, and implementing automatic acknowledgment policies based on message
22781 headers that some sites insist on.
22782
22783
22784 .option transport_filter transports string&!! unset
22785 .cindex "transport" "filter"
22786 .cindex "filter" "transport filter"
22787 This option sets up a filtering (in the Unix shell sense) process for messages
22788 at transport time. It should not be confused with mail filtering as set up by
22789 individual users or via a system filter.
22790 If unset, or expanding to an empty string, no filtering is done.
22791
22792 When the message is about to be written out, the command specified by
22793 &%transport_filter%& is started up in a separate, parallel process, and
22794 the entire message, including the header lines, is passed to it on its standard
22795 input (this in fact is done from a third process, to avoid deadlock).
22796 The command must be specified as an absolute path.
22797
22798 The process run by the command must use its standard input as the message
22799 data to be transformed, and write the results on its standard output.
22800
22801 The lines of the message that are written to the transport filter are
22802 terminated by newline (&"\n"&). The message is passed to the filter before any
22803 SMTP-specific processing, such as turning &"\n"& into &"\r\n"& and escaping
22804 lines beginning with a dot, and also before any processing implied by the
22805 settings of &%check_string%& and &%escape_string%& in the &(appendfile)& or
22806 &(pipe)& transports.
22807
22808 The standard error for the filter process is set to the same destination as its
22809 standard output; this is read and written to the message's ultimate
22810 destination. The process that writes the message to the filter, the
22811 filter itself, and the original process that reads the result and delivers it
22812 are all run in parallel, like a shell pipeline.
22813
22814 The filter can perform any transformations it likes, but of course should take
22815 care not to break RFC 2822 syntax. Exim does not check the result, except to
22816 test for a final newline when SMTP is in use. All messages transmitted over
22817 SMTP must end with a newline, so Exim supplies one if it is missing.
22818
22819 .cindex "content scanning" "per user"
22820 A transport filter can be used to provide content-scanning on a per-user basis
22821 at delivery time if the only required effect of the scan is to modify the
22822 message. For example, a content scan could insert a new header line containing
22823 a spam score. This could be interpreted by a filter in the user's MUA. It is
22824 not possible to discard a message at this stage.
22825
22826 .cindex "SIZE" "ESMTP extension"
22827 A problem might arise if the filter increases the size of a message that is
22828 being sent down an SMTP connection. If the receiving SMTP server has indicated
22829 support for the SIZE parameter, Exim will have sent the size of the message
22830 at the start of the SMTP session. If what is actually sent is substantially
22831 more, the server might reject the message. This can be worked round by setting
22832 the &%size_addition%& option on the &(smtp)& transport, either to allow for
22833 additions to the message, or to disable the use of SIZE altogether.
22834
22835 .vindex "&$pipe_addresses$&"
22836 The value of the &%transport_filter%& option is the command string for starting
22837 the filter, which is run directly from Exim, not under a shell. The string is
22838 parsed by Exim in the same way as a command string for the &(pipe)& transport:
22839 Exim breaks it up into arguments and then expands each argument separately (see
22840 section &<<SECThowcommandrun>>&). Any kind of expansion failure causes delivery
22841 to be deferred. The special argument &$pipe_addresses$& is replaced by a number
22842 of arguments, one for each address that applies to this delivery. (This isn't
22843 an ideal name for this feature here, but as it was already implemented for the
22844 &(pipe)& transport, it seemed sensible not to change it.)
22845
22846 .vindex "&$host$&"
22847 .vindex "&$host_address$&"
22848 The expansion variables &$host$& and &$host_address$& are available when the
22849 transport is a remote one. They contain the name and IP address of the host to
22850 which the message is being sent. For example:
22851 . used to have $sender_address in this cmdline, but it's tainted
22852 .code
22853 transport_filter = /some/directory/transport-filter.pl \
22854   $host $host_address $pipe_addresses
22855 .endd
22856
22857 Two problems arise if you want to use more complicated expansion items to
22858 generate transport filter commands, both of which due to the fact that the
22859 command is split up &'before'& expansion.
22860 .ilist
22861 If an expansion item contains white space, you must quote it, so that it is all
22862 part of the same command item. If the entire option setting is one such
22863 expansion item, you have to take care what kind of quoting you use. For
22864 example:
22865 .code
22866 transport_filter = '/bin/cmd${if eq{$host}{a.b.c}{1}{2}}'
22867 .endd
22868 This runs the command &(/bin/cmd1)& if the host name is &'a.b.c'&, and
22869 &(/bin/cmd2)& otherwise.
22870
22871 Option strings in general have any fully-surrounding double quote wrapping
22872 removed early in parsing (see &<<SECTstrings>>&).
22873 Then, for this option, quotes protect against whitespace being
22874 regarded as a separator while splitting into the command argument vector.
22875 Either double or single quotes can be used here;
22876 the former interprets backlash-quoted charachters
22877 and the latter does not.
22878
22879 If double quotes had been used in this example, they would have been
22880 stripped by Exim when it read the option's value. When the value is used, if
22881 the single quotes were missing, the line would be split into two items,
22882 &`/bin/cmd${if`& and &`eq{$host}{a.b.c}{1}{2}`&, and an error would occur when
22883 Exim tried to expand the first one.
22884 .next
22885 Except for the special case of &$pipe_addresses$& that is mentioned above, an
22886 expansion cannot generate multiple arguments, or a command name followed by
22887 arguments. Consider this example:
22888 .code
22889 transport_filter = ${lookup{$host}lsearch{/a/file}\
22890                     {$value}{/bin/cat}}
22891 .endd
22892 The result of the lookup is interpreted as the name of the command, even
22893 if it contains white space. The simplest way round this is to use a shell:
22894 .code
22895 transport_filter = /bin/sh -c ${lookup{$host}lsearch{/a/file}\
22896                                {$value}{/bin/cat}}
22897 .endd
22898 .endlist
22899
22900 The filter process is run under the same uid and gid as the normal delivery.
22901 For remote deliveries this is the Exim uid/gid by default. The command should
22902 normally yield a zero return code. Transport filters are not supposed to fail.
22903 A non-zero code is taken to mean that the transport filter encountered some
22904 serious problem. Delivery of the message is deferred; the message remains on
22905 the queue and is tried again later. It is not possible to cause a message to be
22906 bounced from a transport filter.
22907
22908 If a transport filter is set on an autoreply transport, the original message is
22909 passed through the filter as it is being copied into the newly generated
22910 message, which happens if the &%return_message%& option is set.
22911
22912
22913 .option transport_filter_timeout transports time 5m
22914 .cindex "transport" "filter, timeout"
22915 When Exim is reading the output of a transport filter, it applies a timeout
22916 that can be set by this option. Exceeding the timeout is normally treated as a
22917 temporary delivery failure. However, if a transport filter is used with a
22918 &(pipe)& transport, a timeout in the transport filter is treated in the same
22919 way as a timeout in the pipe command itself. By default, a timeout is a hard
22920 error, but if the &(pipe)& transport's &%timeout_defer%& option is set true, it
22921 becomes a temporary error.
22922
22923
22924 .option user transports string&!! "Exim user"
22925 .cindex "uid (user id)" "local delivery"
22926 .cindex "transport" "user, specifying"
22927 This option specifies the user under whose uid the delivery process is to be
22928 run, overriding any uid that may have been set by the router. If the user is
22929 given as a name, the uid is looked up from the password data, and the
22930 associated group is taken as the value of the gid to be used if the &%group%&
22931 option is not set.
22932
22933 For deliveries that use local transports, a user and group are normally
22934 specified explicitly or implicitly (for example, as a result of
22935 &%check_local_user%&) by the router or transport.
22936
22937 .cindex "hints database" "access by remote transport"
22938 For remote transports, you should leave this option unset unless you really are
22939 sure you know what you are doing. When a remote transport is running, it needs
22940 to be able to access Exim's hints databases, because each host may have its own
22941 retry data.
22942 .ecindex IIDgenoptra1
22943 .ecindex IIDgenoptra2
22944 .ecindex IIDgenoptra3
22945
22946
22947
22948
22949
22950
22951 . ////////////////////////////////////////////////////////////////////////////
22952 . ////////////////////////////////////////////////////////////////////////////
22953
22954 .chapter "Address batching in local transports" "CHAPbatching" &&&
22955          "Address batching"
22956 .cindex "transport" "local; address batching in"
22957 The only remote transport (&(smtp)&) is normally configured to handle more than
22958 one address at a time, so that when several addresses are routed to the same
22959 remote host, just one copy of the message is sent. Local transports, however,
22960 normally handle one address at a time. That is, a separate instance of the
22961 transport is run for each address that is routed to the transport. A separate
22962 copy of the message is delivered each time.
22963
22964 .cindex "batched local delivery"
22965 .oindex "&%batch_max%&"
22966 .oindex "&%batch_id%&"
22967 In special cases, it may be desirable to handle several addresses at once in a
22968 local transport, for example:
22969
22970 .ilist
22971 In an &(appendfile)& transport, when storing messages in files for later
22972 delivery by some other means, a single copy of the message with multiple
22973 recipients saves space.
22974 .next
22975 In an &(lmtp)& transport, when delivering over &"local SMTP"& to some process,
22976 a single copy saves time, and is the normal way LMTP is expected to work.
22977 .next
22978 In a &(pipe)& transport, when passing the message
22979 to a scanner program or
22980 to some other delivery mechanism such as UUCP, multiple recipients may be
22981 acceptable.
22982 .endlist
22983
22984 These three local transports all have the same options for controlling multiple
22985 (&"batched"&) deliveries, namely &%batch_max%& and &%batch_id%&. To save
22986 repeating the information for each transport, these options are described here.
22987
22988 The &%batch_max%& option specifies the maximum number of addresses that can be
22989 delivered together in a single run of the transport. Its default value is one
22990 (no batching). When more than one address is routed to a transport that has a
22991 &%batch_max%& value greater than one, the addresses are delivered in a batch
22992 (that is, in a single run of the transport with multiple recipients), subject
22993 to certain conditions:
22994
22995 .ilist
22996 .vindex "&$local_part$&"
22997 If any of the transport's options contain a reference to &$local_part$&, no
22998 batching is possible.
22999 .next
23000 .vindex "&$domain$&"
23001 If any of the transport's options contain a reference to &$domain$&, only
23002 addresses with the same domain are batched.
23003 .next
23004 .cindex "customizing" "batching condition"
23005 If &%batch_id%& is set, it is expanded for each address, and only those
23006 addresses with the same expanded value are batched. This allows you to specify
23007 customized batching conditions. Failure of the expansion for any reason,
23008 including forced failure, disables batching, but it does not stop the delivery
23009 from taking place.
23010 .next
23011 Batched addresses must also have the same errors address (where to send
23012 delivery errors), the same header additions and removals, the same user and
23013 group for the transport, and if a host list is present, the first host must
23014 be the same.
23015 .endlist
23016
23017 In the case of the &(appendfile)& and &(pipe)& transports, batching applies
23018 both when the file or pipe command is specified in the transport, and when it
23019 is specified by a &(redirect)& router, but all the batched addresses must of
23020 course be routed to the same file or pipe command. These two transports have an
23021 option called &%use_bsmtp%&, which causes them to deliver the message in
23022 &"batched SMTP"& format, with the envelope represented as SMTP commands. The
23023 &%check_string%& and &%escape_string%& options are forced to the values
23024 .code
23025 check_string = "."
23026 escape_string = ".."
23027 .endd
23028 when batched SMTP is in use. A full description of the batch SMTP mechanism is
23029 given in section &<<SECTbatchSMTP>>&. The &(lmtp)& transport does not have a
23030 &%use_bsmtp%& option, because it always delivers using the SMTP protocol.
23031
23032 .cindex "&'Envelope-to:'& header line"
23033 If the generic &%envelope_to_add%& option is set for a batching transport, the
23034 &'Envelope-to:'& header that is added to the message contains all the addresses
23035 that are being processed together. If you are using a batching &(appendfile)&
23036 transport without &%use_bsmtp%&, the only way to preserve the recipient
23037 addresses is to set the &%envelope_to_add%& option.
23038
23039 .cindex "&(pipe)& transport" "with multiple addresses"
23040 .vindex "&$pipe_addresses$&"
23041 If you are using a &(pipe)& transport without BSMTP, and setting the
23042 transport's &%command%& option, you can include &$pipe_addresses$& as part of
23043 the command. This is not a true variable; it is a bit of magic that causes each
23044 of the recipient addresses to be inserted into the command as a separate
23045 argument. This provides a way of accessing all the addresses that are being
23046 delivered in the batch. &*Note:*& This is not possible for pipe commands that
23047 are specified by a &(redirect)& router.
23048
23049
23050
23051
23052 . ////////////////////////////////////////////////////////////////////////////
23053 . ////////////////////////////////////////////////////////////////////////////
23054
23055 .chapter "The appendfile transport" "CHAPappendfile"
23056 .scindex IIDapptra1 "&(appendfile)& transport"
23057 .scindex IIDapptra2 "transports" "&(appendfile)&"
23058 .cindex "directory creation"
23059 .cindex "creating directories"
23060 The &(appendfile)& transport delivers a message by appending it to an existing
23061 file, or by creating an entirely new file in a specified directory. Single
23062 files to which messages are appended can be in the traditional Unix mailbox
23063 format, or optionally in the MBX format supported by the Pine MUA and
23064 University of Washington IMAP daemon, &'inter alia'&. When each message is
23065 being delivered as a separate file, &"maildir"& format can optionally be used
23066 to give added protection against failures that happen part-way through the
23067 delivery. A third form of separate-file delivery known as &"mailstore"& is also
23068 supported. For all file formats, Exim attempts to create as many levels of
23069 directory as necessary, provided that &%create_directory%& is set.
23070
23071 The code for the optional formats is not included in the Exim binary by
23072 default. It is necessary to set SUPPORT_MBX, SUPPORT_MAILDIR and/or
23073 SUPPORT_MAILSTORE in &_Local/Makefile_& to have the appropriate code
23074 included.
23075
23076 .cindex "quota" "system"
23077 Exim recognizes system quota errors, and generates an appropriate message. Exim
23078 also supports its own quota control within the transport, for use when the
23079 system facility is unavailable or cannot be used for some reason.
23080
23081 If there is an error while appending to a file (for example, quota exceeded or
23082 partition filled), Exim attempts to reset the file's length and last
23083 modification time back to what they were before. If there is an error while
23084 creating an entirely new file, the new file is removed.
23085
23086 Before appending to a file, a number of security checks are made, and the
23087 file is locked. A detailed description is given below, after the list of
23088 private options.
23089
23090 The &(appendfile)& transport is most commonly used for local deliveries to
23091 users' mailboxes. However, it can also be used as a pseudo-remote transport for
23092 putting messages into files for remote delivery by some means other than Exim.
23093 &"Batch SMTP"& format is often used in this case (see the &%use_bsmtp%&
23094 option).
23095
23096
23097
23098 .section "The file and directory options" "SECTfildiropt"
23099 The &%file%& option specifies a single file, to which the message is appended;
23100 the &%directory%& option specifies a directory, in which a new file containing
23101 the message is created. Only one of these two options can be set, and for
23102 normal deliveries to mailboxes, one of them &'must'& be set.
23103
23104 .vindex "&$address_file$&"
23105 .vindex "&$local_part$&"
23106 However, &(appendfile)& is also used for delivering messages to files or
23107 directories whose names (or parts of names) are obtained from alias,
23108 forwarding, or filtering operations (for example, a &%save%& command in a
23109 user's Exim filter). When such a transport is running, &$local_part$& contains
23110 the local part that was aliased or forwarded, and &$address_file$& contains the
23111 name (or partial name) of the file or directory generated by the redirection
23112 operation. There are two cases:
23113
23114 .ilist
23115 If neither &%file%& nor &%directory%& is set, the redirection operation
23116 must specify an absolute path (one that begins with &`/`&). This is the most
23117 common case when users with local accounts use filtering to sort mail into
23118 different folders. See for example, the &(address_file)& transport in the
23119 default configuration. If the path ends with a slash, it is assumed to be the
23120 name of a directory. A delivery to a directory can also be forced by setting
23121 &%maildir_format%& or &%mailstore_format%&.
23122 .next
23123 If &%file%& or &%directory%& is set for a delivery from a redirection, it is
23124 used to determine the file or directory name for the delivery. Normally, the
23125 contents of &$address_file$& are used in some way in the string expansion.
23126 .endlist
23127 If the &%create_file%& option is set to a path which
23128 matches (see the option definition below for details)
23129 a file or directory name
23130 for the delivery, that name becomes de-tainted.
23131
23132 .cindex "tainted data" "in filenames"
23133 .cindex appendfile "tainted data"
23134 Tainted data may not be used for a file or directory name.
23135 This means that, for instance, &$local_part$& cannot be used directly
23136 as a component of a path.  It can however be used as the key for a lookup
23137 which returns a path (or component).
23138
23139
23140 .cindex "Sieve filter" "configuring &(appendfile)&"
23141 .cindex "Sieve filter" "relative mailbox path handling"
23142 As an example of the second case, consider an environment where users do not
23143 have home directories. They may be permitted to use Exim filter commands of the
23144 form:
23145 .code
23146 save folder23
23147 .endd
23148 or Sieve filter commands of the form:
23149 .code
23150 require "fileinto";
23151 fileinto "folder23";
23152 .endd
23153 In this situation, the expansion of &%file%& or &%directory%& in the transport
23154 must transform the relative path into an appropriate absolute filename. In the
23155 case of Sieve filters, the name &'inbox'& must be handled. It is the name that
23156 is used as a result of a &"keep"& action in the filter. This example shows one
23157 way of handling this requirement:
23158 .code
23159 file = ${if eq{$address_file}{inbox} \
23160             {/var/mail/$local_part_data} \
23161             {${if eq{${substr_0_1:$address_file}}{/} \
23162                   {$address_file} \
23163                   {$home/mail/$address_file} \
23164             }} \
23165        }
23166 .endd
23167 With this setting of &%file%&, &'inbox'& refers to the standard mailbox
23168 location, absolute paths are used without change, and other folders are in the
23169 &_mail_& directory within the home directory.
23170
23171 &*Note 1*&: While processing an Exim filter, a relative path such as
23172 &_folder23_& is turned into an absolute path if a home directory is known to
23173 the router. In particular, this is the case if &%check_local_user%& is set. If
23174 you want to prevent this happening at routing time, you can set
23175 &%router_home_directory%& empty. This forces the router to pass the relative
23176 path to the transport.
23177
23178 &*Note 2*&: An absolute path in &$address_file$& is not treated specially;
23179 the &%file%& or &%directory%& option is still used if it is set.
23180
23181
23182
23183
23184 .section "Private options for appendfile" "SECID134"
23185 .cindex "options" "&(appendfile)& transport"
23186
23187
23188
23189 .option allow_fifo appendfile boolean false
23190 .cindex "fifo (named pipe)"
23191 .cindex "named pipe (fifo)"
23192 .cindex "pipe" "named (fifo)"
23193 Setting this option permits delivery to named pipes (FIFOs) as well as to
23194 regular files. If no process is reading the named pipe at delivery time, the
23195 delivery is deferred.
23196
23197
23198 .option allow_symlink appendfile boolean false
23199 .cindex "symbolic link" "to mailbox"
23200 .cindex "mailbox" "symbolic link"
23201 By default, &(appendfile)& will not deliver if the path name for the file is
23202 that of a symbolic link. Setting this option relaxes that constraint, but there
23203 are security issues involved in the use of symbolic links. Be sure you know
23204 what you are doing if you set this. Details of exactly what this option affects
23205 are included in the discussion which follows this list of options.
23206
23207
23208 .option batch_id appendfile string&!! unset
23209 See the description of local delivery batching in chapter &<<CHAPbatching>>&.
23210 However, batching is automatically disabled for &(appendfile)& deliveries that
23211 happen as a result of forwarding or aliasing or other redirection directly to a
23212 file.
23213
23214
23215 .option batch_max appendfile integer 1
23216 See the description of local delivery batching in chapter &<<CHAPbatching>>&.
23217
23218
23219 .option check_group appendfile boolean false
23220 When this option is set, the group owner of the file defined by the &%file%&
23221 option is checked to see that it is the same as the group under which the
23222 delivery process is running. The default setting is false because the default
23223 file mode is 0600, which means that the group is irrelevant.
23224
23225
23226 .option check_owner appendfile boolean true
23227 When this option is set, the owner of the file defined by the &%file%& option
23228 is checked to ensure that it is the same as the user under which the delivery
23229 process is running.
23230
23231
23232 .option check_string appendfile string "see below"
23233 .cindex "&""From""& line"
23234 As &(appendfile)& writes the message, the start of each line is tested for
23235 matching &%check_string%&, and if it does, the initial matching characters are
23236 replaced by the contents of &%escape_string%&. The value of &%check_string%& is
23237 a literal string, not a regular expression, and the case of any letters it
23238 contains is significant.
23239
23240 If &%use_bsmtp%& is set the values of &%check_string%& and &%escape_string%&
23241 are forced to &"."& and &".."& respectively, and any settings in the
23242 configuration are ignored. Otherwise, they default to &"From&~"& and
23243 &">From&~"& when the &%file%& option is set, and unset when any of the
23244 &%directory%&, &%maildir%&, or &%mailstore%& options are set.
23245
23246 The default settings, along with &%message_prefix%& and &%message_suffix%&, are
23247 suitable for traditional &"BSD"& mailboxes, where a line beginning with
23248 &"From&~"& indicates the start of a new message. All four options need changing
23249 if another format is used. For example, to deliver to mailboxes in MMDF format:
23250 .cindex "MMDF format mailbox"
23251 .cindex "mailbox" "MMDF format"
23252 .code
23253 check_string = "\1\1\1\1\n"
23254 escape_string = "\1\1\1\1 \n"
23255 message_prefix = "\1\1\1\1\n"
23256 message_suffix = "\1\1\1\1\n"
23257 .endd
23258 .option create_directory appendfile boolean true
23259 .cindex "directory creation"
23260 When this option is true, Exim attempts to create any missing superior
23261 directories for the file that it is about to write. A created directory's mode
23262 is given by the &%directory_mode%& option.
23263
23264 The group ownership of a newly created directory is highly dependent on the
23265 operating system (and possibly the file system) that is being used. For
23266 example, in Solaris, if the parent directory has the setgid bit set, its group
23267 is propagated to the child; if not, the currently set group is used. However,
23268 in FreeBSD, the parent's group is always used.
23269
23270
23271
23272 .option create_file appendfile string anywhere
23273 This option constrains the location of files and directories that are created
23274 by this transport. It applies to files defined by the &%file%& option and
23275 directories defined by the &%directory%& option. In the case of maildir
23276 delivery, it applies to the top level directory, not the maildir directories
23277 beneath.
23278
23279 The option must be set to one of the words &"anywhere"&, &"inhome"&, or
23280 &"belowhome"&, or to an absolute path.
23281
23282 In the second and third cases, a home directory must have been
23283 set for the transport, and the file or directory being created must
23284 reside within it.
23285 The "belowhome" checking additionally checks for attempts to use "../"
23286 to evade the testing.
23287 This option is not useful when an explicit filename is
23288 given for normal mailbox deliveries. It is intended for the case when filenames
23289 are generated from users' &_.forward_& files. These are usually handled
23290 by an &(appendfile)& transport called &%address_file%&. See also
23291 &%file_must_exist%&.
23292
23293 In the fourth case,
23294 the value given for this option must be an absolute path for an
23295 existing directory.
23296 The value is used for checking instead of a home directory;
23297 checking is done in "belowhome" mode.
23298
23299 .cindex "tainted data" "de-tainting"
23300 .cindex "de-tainting" "using appendfile create_file option"
23301 If "belowhome" checking is used, the file or directory path
23302 becomes de-tainted.
23303
23304
23305 .option directory appendfile string&!! unset
23306 This option is mutually exclusive with the &%file%& option, but one of &%file%&
23307 or &%directory%& must be set, unless the delivery is the direct result of a
23308 redirection (see section &<<SECTfildiropt>>&).
23309
23310 When &%directory%& is set, the string is expanded, and the message is delivered
23311 into a new file or files in or below the given directory, instead of being
23312 appended to a single mailbox file. A number of different formats are provided
23313 (see &%maildir_format%& and &%mailstore_format%&), and see section
23314 &<<SECTopdir>>& for further details of this form of delivery.
23315
23316 The result of expansion must not be tainted, unless the &%create_file%& option
23317 specifies a path.
23318
23319
23320 .option directory_file appendfile string&!! "see below"
23321 .cindex "base62"
23322 .vindex "&$inode$&"
23323 When &%directory%& is set, but neither &%maildir_format%& nor
23324 &%mailstore_format%& is set, &(appendfile)& delivers each message into a file
23325 whose name is obtained by expanding this string. The default value is:
23326 .code
23327 q${base62:$tod_epoch}-$inode
23328 .endd
23329 This generates a unique name from the current time, in base 62 form, and the
23330 inode of the file. The variable &$inode$& is available only when expanding this
23331 option.
23332
23333
23334 .option directory_mode appendfile "octal integer" 0700
23335 If &(appendfile)& creates any directories as a result of the
23336 &%create_directory%& option, their mode is specified by this option.
23337
23338
23339 .option escape_string appendfile string "see description"
23340 See &%check_string%& above.
23341
23342
23343 .option file appendfile string&!! unset
23344 This option is mutually exclusive with the &%directory%& option, but one of
23345 &%file%& or &%directory%& must be set, unless the delivery is the direct result
23346 of a redirection (see section &<<SECTfildiropt>>&). The &%file%& option
23347 specifies a single file, to which the message is appended. One or more of
23348 &%use_fcntl_lock%&, &%use_flock_lock%&, or &%use_lockfile%& must be set with
23349 &%file%&.
23350
23351 The result of expansion must not be tainted, unless the &%create_file%& option
23352 specifies a path.
23353
23354 .cindex "NFS" "lock file"
23355 .cindex "locking files"
23356 .cindex "lock files"
23357 If you are using more than one host to deliver over NFS into the same
23358 mailboxes, you should always use lock files.
23359
23360 The string value is expanded for each delivery, and must yield an absolute
23361 path. The most common settings of this option are variations on one of these
23362 examples:
23363 .code
23364 file = /var/spool/mail/$local_part_data
23365 file = /home/$local_part_data/inbox
23366 file = $home/inbox
23367 .endd
23368 .cindex "&""sticky""& bit"
23369 In the first example, all deliveries are done into the same directory. If Exim
23370 is configured to use lock files (see &%use_lockfile%& below) it must be able to
23371 create a file in the directory, so the &"sticky"& bit must be turned on for
23372 deliveries to be possible, or alternatively the &%group%& option can be used to
23373 run the delivery under a group id which has write access to the directory.
23374
23375
23376
23377 .option file_format appendfile string unset
23378 .cindex "file" "mailbox; checking existing format"
23379 This option requests the transport to check the format of an existing file
23380 before adding to it. The check consists of matching a specific string at the
23381 start of the file. The value of the option consists of an even number of
23382 colon-separated strings. The first of each pair is the test string, and the
23383 second is the name of a transport. If the transport associated with a matched
23384 string is not the current transport, control is passed over to the other
23385 transport. For example, suppose the standard &(local_delivery)& transport has
23386 this added to it:
23387 .code
23388 file_format = "From       : local_delivery :\
23389                \1\1\1\1\n : local_mmdf_delivery"
23390 .endd
23391 Mailboxes that begin with &"From"& are still handled by this transport, but if
23392 a mailbox begins with four binary ones followed by a newline, control is passed
23393 to a transport called &%local_mmdf_delivery%&, which presumably is configured
23394 to do the delivery in MMDF format. If a mailbox does not exist or is empty, it
23395 is assumed to match the current transport. If the start of a mailbox doesn't
23396 match any string, or if the transport named for a given string is not defined,
23397 delivery is deferred.
23398
23399
23400 .option file_must_exist appendfile boolean false
23401 If this option is true, the file specified by the &%file%& option must exist.
23402 A temporary error occurs if it does not, causing delivery to be deferred.
23403 If this option is false, the file is created if it does not exist.
23404
23405
23406 .option lock_fcntl_timeout appendfile time 0s
23407 .cindex "timeout" "mailbox locking"
23408 .cindex "mailbox" "locking, blocking and non-blocking"
23409 .cindex "locking files"
23410 By default, the &(appendfile)& transport uses non-blocking calls to &[fcntl()]&
23411 when locking an open mailbox file. If the call fails, the delivery process
23412 sleeps for &%lock_interval%& and tries again, up to &%lock_retries%& times.
23413 Non-blocking calls are used so that the file is not kept open during the wait
23414 for the lock; the reason for this is to make it as safe as possible for
23415 deliveries over NFS in the case when processes might be accessing an NFS
23416 mailbox without using a lock file. This should not be done, but
23417 misunderstandings and hence misconfigurations are not unknown.
23418
23419 On a busy system, however, the performance of a non-blocking lock approach is
23420 not as good as using a blocking lock with a timeout. In this case, the waiting
23421 is done inside the system call, and Exim's delivery process acquires the lock
23422 and can proceed as soon as the previous lock holder releases it.
23423
23424 If &%lock_fcntl_timeout%& is set to a non-zero time, blocking locks, with that
23425 timeout, are used. There may still be some retrying: the maximum number of
23426 retries is
23427 .code
23428 (lock_retries * lock_interval) / lock_fcntl_timeout
23429 .endd
23430 rounded up to the next whole number. In other words, the total time during
23431 which &(appendfile)& is trying to get a lock is roughly the same, unless
23432 &%lock_fcntl_timeout%& is set very large.
23433
23434 You should consider setting this option if you are getting a lot of delayed
23435 local deliveries because of errors of the form
23436 .code
23437 failed to lock mailbox /some/file (fcntl)
23438 .endd
23439
23440 .option lock_flock_timeout appendfile time 0s
23441 This timeout applies to file locking when using &[flock()]& (see
23442 &%use_flock%&); the timeout operates in a similar manner to
23443 &%lock_fcntl_timeout%&.
23444
23445
23446 .option lock_interval appendfile time 3s
23447 This specifies the time to wait between attempts to lock the file. See below
23448 for details of locking.
23449
23450
23451 .option lock_retries appendfile integer 10
23452 This specifies the maximum number of attempts to lock the file. A value of zero
23453 is treated as 1. See below for details of locking.
23454
23455
23456 .option lockfile_mode appendfile "octal integer" 0600
23457 This specifies the mode of the created lock file, when a lock file is being
23458 used (see &%use_lockfile%& and &%use_mbx_lock%&).
23459
23460
23461 .option lockfile_timeout appendfile time 30m
23462 .cindex "timeout" "mailbox locking"
23463 When a lock file is being used (see &%use_lockfile%&), if a lock file already
23464 exists and is older than this value, it is assumed to have been left behind by
23465 accident, and Exim attempts to remove it.
23466
23467
23468 .option mailbox_filecount appendfile string&!! unset
23469 .cindex "mailbox" "specifying size of"
23470 .cindex "size" "of mailbox"
23471 If this option is set, it is expanded, and the result is taken as the current
23472 number of files in the mailbox. It must be a decimal number, optionally
23473 followed by K or M. This provides a way of obtaining this information from an
23474 external source that maintains the data.
23475
23476
23477 .option mailbox_size appendfile string&!! unset
23478 .cindex "mailbox" "specifying size of"
23479 .cindex "size" "of mailbox"
23480 If this option is set, it is expanded, and the result is taken as the current
23481 size the mailbox. It must be a decimal number, optionally followed by K or M.
23482 This provides a way of obtaining this information from an external source that
23483 maintains the data. This is likely to be helpful for maildir deliveries where
23484 it is computationally expensive to compute the size of a mailbox.
23485
23486
23487
23488 .option maildir_format appendfile boolean false
23489 .cindex "maildir format" "specifying"
23490 If this option is set with the &%directory%& option, the delivery is into a new
23491 file, in the &"maildir"& format that is used by other mail software. When the
23492 transport is activated directly from a &(redirect)& router (for example, the
23493 &(address_file)& transport in the default configuration), setting
23494 &%maildir_format%& causes the path received from the router to be treated as a
23495 directory, whether or not it ends with &`/`&. This option is available only if
23496 SUPPORT_MAILDIR is present in &_Local/Makefile_&. See section
23497 &<<SECTmaildirdelivery>>& below for further details.
23498
23499
23500 .option maildir_quota_directory_regex appendfile string "See below"
23501 .cindex "maildir format" "quota; directories included in"
23502 .cindex "quota" "maildir; directories included in"
23503 This option is relevant only when &%maildir_use_size_file%& is set. It defines
23504 a regular expression for specifying directories, relative to the quota
23505 directory (see &%quota_directory%&), that should be included in the quota
23506 calculation. The default value is:
23507 .code
23508 maildir_quota_directory_regex = ^(?:cur|new|\..*)$
23509 .endd
23510 This includes the &_cur_& and &_new_& directories, and any maildir++ folders
23511 (directories whose names begin with a dot). If you want to exclude the
23512 &_Trash_&
23513 folder from the count (as some sites do), you need to change this setting to
23514 .code
23515 maildir_quota_directory_regex = ^(?:cur|new|\.(?!Trash).*)$
23516 .endd
23517 This uses a negative lookahead in the regular expression to exclude the
23518 directory whose name is &_.Trash_&. When a directory is excluded from quota
23519 calculations, quota processing is bypassed for any messages that are delivered
23520 directly into that directory.
23521
23522
23523 .option maildir_retries appendfile integer 10
23524 This option specifies the number of times to retry when writing a file in
23525 &"maildir"& format. See section &<<SECTmaildirdelivery>>& below.
23526
23527
23528 .option maildir_tag appendfile string&!! unset
23529 This option applies only to deliveries in maildir format, and is described in
23530 section &<<SECTmaildirdelivery>>& below.
23531
23532
23533 .option maildir_use_size_file appendfile&!! boolean false
23534 .cindex "maildir format" "&_maildirsize_& file"
23535 The result of string expansion for this option must be a valid boolean value.
23536 If it is true, it enables support for &_maildirsize_& files. Exim
23537 creates a &_maildirsize_& file in a maildir if one does not exist, taking the
23538 quota from the &%quota%& option of the transport. If &%quota%& is unset, the
23539 value is zero. See &%maildir_quota_directory_regex%& above and section
23540 &<<SECTmaildirdelivery>>& below for further details.
23541
23542 .option maildirfolder_create_regex appendfile string unset
23543 .cindex "maildir format" "&_maildirfolder_& file"
23544 .cindex "&_maildirfolder_&, creating"
23545 The value of this option is a regular expression. If it is unset, it has no
23546 effect. Otherwise, before a maildir delivery takes place, the pattern is
23547 matched against the name of the maildir directory, that is, the directory
23548 containing the &_new_& and &_tmp_& subdirectories that will be used for the
23549 delivery. If there is a match, Exim checks for the existence of a file called
23550 &_maildirfolder_& in the directory, and creates it if it does not exist.
23551 See section &<<SECTmaildirdelivery>>& for more details.
23552
23553
23554 .option mailstore_format appendfile boolean false
23555 .cindex "mailstore format" "specifying"
23556 If this option is set with the &%directory%& option, the delivery is into two
23557 new files in  &"mailstore"& format. The option is available only if
23558 SUPPORT_MAILSTORE is present in &_Local/Makefile_&. See section &<<SECTopdir>>&
23559 below for further details.
23560
23561
23562 .option mailstore_prefix appendfile string&!! unset
23563 This option applies only to deliveries in mailstore format, and is described in
23564 section &<<SECTopdir>>& below.
23565
23566
23567 .option mailstore_suffix appendfile string&!! unset
23568 This option applies only to deliveries in mailstore format, and is described in
23569 section &<<SECTopdir>>& below.
23570
23571
23572 .option mbx_format appendfile boolean false
23573 .cindex "locking files"
23574 .cindex "file" "locking"
23575 .cindex "file" "MBX format"
23576 .cindex "MBX format, specifying"
23577 This option is available only if Exim has been compiled with SUPPORT_MBX
23578 set in &_Local/Makefile_&. If &%mbx_format%& is set with the &%file%& option,
23579 the message is appended to the mailbox file in MBX format instead of
23580 traditional Unix format. This format is supported by Pine4 and its associated
23581 IMAP and POP daemons, by means of the &'c-client'& library that they all use.
23582
23583 &*Note*&: The &%message_prefix%& and &%message_suffix%& options are not
23584 automatically changed by the use of &%mbx_format%&. They should normally be set
23585 empty when using MBX format, so this option almost always appears in this
23586 combination:
23587 .code
23588 mbx_format = true
23589 message_prefix =
23590 message_suffix =
23591 .endd
23592 If none of the locking options are mentioned in the configuration,
23593 &%use_mbx_lock%& is assumed and the other locking options default to false. It
23594 is possible to specify the other kinds of locking with &%mbx_format%&, but
23595 &%use_fcntl_lock%& and &%use_mbx_lock%& are mutually exclusive. MBX locking
23596 interworks with &'c-client'&, providing for shared access to the mailbox. It
23597 should not be used if any program that does not use this form of locking is
23598 going to access the mailbox, nor should it be used if the mailbox file is NFS
23599 mounted, because it works only when the mailbox is accessed from a single host.
23600
23601 If you set &%use_fcntl_lock%& with an MBX-format mailbox, you cannot use
23602 the standard version of &'c-client'&, because as long as it has a mailbox open
23603 (this means for the whole of a Pine or IMAP session), Exim will not be able to
23604 append messages to it.
23605
23606
23607 .option message_prefix appendfile string&!! "see below"
23608 .cindex "&""From""& line"
23609 The string specified here is expanded and output at the start of every message.
23610 The default is unset unless &%file%& is specified and &%use_bsmtp%& is not set,
23611 in which case it is:
23612 .code
23613 message_prefix = "From ${if def:return_path{$return_path}\
23614   {MAILER-DAEMON}} $tod_bsdinbox\n"
23615 .endd
23616 &*Note:*& If you set &%use_crlf%& true, you must change any occurrences of
23617 &`\n`& to &`\r\n`& in &%message_prefix%&.
23618
23619 .option message_suffix appendfile string&!! "see below"
23620 The string specified here is expanded and output at the end of every message.
23621 The default is unset unless &%file%& is specified and &%use_bsmtp%& is not set,
23622 in which case it is a single newline character. The suffix can be suppressed by
23623 setting
23624 .code
23625 message_suffix =
23626 .endd
23627 &*Note:*& If you set &%use_crlf%& true, you must change any occurrences of
23628 &`\n`& to &`\r\n`& in &%message_suffix%&.
23629
23630 .option mode appendfile "octal integer" 0600
23631 If the output file is created, it is given this mode. If it already exists and
23632 has wider permissions, they are reduced to this mode. If it has narrower
23633 permissions, an error occurs unless &%mode_fail_narrower%& is false. However,
23634 if the delivery is the result of a &%save%& command in a filter file specifying
23635 a particular mode, the mode of the output file is always forced to take that
23636 value, and this option is ignored.
23637
23638
23639 .option mode_fail_narrower appendfile boolean true
23640 This option applies in the case when an existing mailbox file has a narrower
23641 mode than that specified by the &%mode%& option. If &%mode_fail_narrower%& is
23642 true, the delivery is deferred (&"mailbox has the wrong mode"&); otherwise Exim
23643 continues with the delivery attempt, using the existing mode of the file.
23644
23645
23646 .option notify_comsat appendfile boolean false
23647 If this option is true, the &'comsat'& daemon is notified after every
23648 successful delivery to a user mailbox. This is the daemon that notifies logged
23649 on users about incoming mail.
23650
23651
23652 .option quota appendfile string&!! unset
23653 .cindex "quota" "imposed by Exim"
23654 This option imposes a limit on the size of the file to which Exim is appending,
23655 or to the total space used in the directory tree when the &%directory%& option
23656 is set. In the latter case, computation of the space used is expensive, because
23657 all the files in the directory (and any sub-directories) have to be
23658 individually inspected and their sizes summed. (See &%quota_size_regex%& and
23659 &%maildir_use_size_file%& for ways to avoid this in environments where users
23660 have no shell access to their mailboxes).
23661
23662 As there is no interlock against two simultaneous deliveries into a
23663 multi-file mailbox, it is possible for the quota to be overrun in this case.
23664 For single-file mailboxes, of course, an interlock is a necessity.
23665
23666 A file's size is taken as its &'used'& value. Because of blocking effects, this
23667 may be a lot less than the actual amount of disk space allocated to the file.
23668 If the sizes of a number of files are being added up, the rounding effect can
23669 become quite noticeable, especially on systems that have large block sizes.
23670 Nevertheless, it seems best to stick to the &'used'& figure, because this is
23671 the obvious value which users understand most easily.
23672
23673 The value of the option is expanded, and must then be a numerical value
23674 (decimal point allowed), optionally followed by one of the letters K, M, or G,
23675 for kilobytes, megabytes, or gigabytes, optionally followed by a slash
23676 and further option modifiers. If Exim is running on a system with
23677 large file support (Linux and FreeBSD have this), mailboxes larger than 2G can
23678 be handled.
23679
23680 The option modifier &%no_check%& can be used to force delivery even if the over
23681 quota condition is met. The quota gets updated as usual.
23682
23683 &*Note*&: A value of zero is interpreted as &"no quota"&.
23684
23685 The expansion happens while Exim is running as root, before it changes uid for
23686 the delivery. This means that files that are inaccessible to the end user can
23687 be used to hold quota values that are looked up in the expansion. When delivery
23688 fails because this quota is exceeded, the handling of the error is as for
23689 system quota failures.
23690
23691 By default, Exim's quota checking mimics system quotas, and restricts the
23692 mailbox to the specified maximum size, though the value is not accurate to the
23693 last byte, owing to separator lines and additional headers that may get added
23694 during message delivery. When a mailbox is nearly full, large messages may get
23695 refused even though small ones are accepted, because the size of the current
23696 message is added to the quota when the check is made. This behaviour can be
23697 changed by setting &%quota_is_inclusive%& false. When this is done, the check
23698 for exceeding the quota does not include the current message. Thus, deliveries
23699 continue until the quota has been exceeded; thereafter, no further messages are
23700 delivered. See also &%quota_warn_threshold%&.
23701
23702
23703 .option quota_directory appendfile string&!! unset
23704 This option defines the directory to check for quota purposes when delivering
23705 into individual files. The default is the delivery directory, or, if a file
23706 called &_maildirfolder_& exists in a maildir directory, the parent of the
23707 delivery directory.
23708
23709
23710 .option quota_filecount appendfile string&!! 0
23711 This option applies when the &%directory%& option is set. It limits the total
23712 number of files in the directory (compare the inode limit in system quotas). It
23713 can only be used if &%quota%& is also set. The value is expanded; an expansion
23714 failure causes delivery to be deferred. A value of zero is interpreted as
23715 &"no quota"&.
23716
23717 The option modifier &%no_check%& can be used to force delivery even if the over
23718 quota condition is met. The quota gets updated as usual.
23719
23720 .option quota_is_inclusive appendfile boolean true
23721 See &%quota%& above.
23722
23723
23724 .option quota_size_regex appendfile string unset
23725 This option applies when one of the delivery modes that writes a separate file
23726 for each message is being used. When Exim wants to find the size of one of
23727 these files in order to test the quota, it first checks &%quota_size_regex%&.
23728 If this is set to a regular expression that matches the filename, and it
23729 captures one string, that string is interpreted as a representation of the
23730 file's size. The value of &%quota_size_regex%& is not expanded.
23731
23732 This feature is useful only when users have no shell access to their mailboxes
23733 &-- otherwise they could defeat the quota simply by renaming the files. This
23734 facility can be used with maildir deliveries, by setting &%maildir_tag%& to add
23735 the file length to the filename. For example:
23736 .code
23737 maildir_tag = ,S=$message_size
23738 quota_size_regex = ,S=(\d+)
23739 .endd
23740 An alternative to &$message_size$& is &$message_linecount$&, which contains the
23741 number of lines in the message.
23742
23743 The regular expression should not assume that the length is at the end of the
23744 filename (even though &%maildir_tag%& puts it there) because maildir MUAs
23745 sometimes add other information onto the ends of message filenames.
23746
23747 Section &<<SECID136>>& contains further information.
23748
23749 This option should not be used when other message-handling software
23750 may duplicate messages by making hardlinks to the files.  When that is done Exim
23751 will count the message size once for each filename, in contrast with the actual
23752 disk usage.  When the option is not set, calculating total usage requires
23753 a system-call per file to get the size; the number of links is then available also
23754 as is used to adjust the effective size.
23755
23756
23757 .option quota_warn_message appendfile string&!! "see below"
23758 See below for the use of this option. If it is not set when
23759 &%quota_warn_threshold%& is set, it defaults to
23760 .code
23761 quota_warn_message = "\
23762   To: $local_part@$domain\n\
23763   Subject: Your mailbox\n\n\
23764   This message is automatically created \
23765   by mail delivery software.\n\n\
23766   The size of your mailbox has exceeded \
23767   a warning threshold that is\n\
23768   set by the system administrator.\n"
23769 .endd
23770
23771
23772 .option quota_warn_threshold appendfile string&!! 0
23773 .cindex "quota" "warning threshold"
23774 .cindex "mailbox" "size warning"
23775 .cindex "size" "of mailbox"
23776 This option is expanded in the same way as &%quota%& (see above). If the
23777 resulting value is greater than zero, and delivery of the message causes the
23778 size of the file or total space in the directory tree to cross the given
23779 threshold, a warning message is sent. If &%quota%& is also set, the threshold
23780 may be specified as a percentage of it by following the value with a percent
23781 sign. For example:
23782 .code
23783 quota = 10M
23784 quota_warn_threshold = 75%
23785 .endd
23786 If &%quota%& is not set, a setting of &%quota_warn_threshold%& that ends with a
23787 percent sign is ignored.
23788
23789 The warning message itself is specified by the &%quota_warn_message%& option,
23790 and it must start with a &'To:'& header line containing the recipient(s) of the
23791 warning message. These do not necessarily have to include the recipient(s) of
23792 the original message. A &'Subject:'& line should also normally be supplied. You
23793 can include any other header lines that you want. If you do not include a
23794 &'From:'& line, the default is:
23795 .code
23796 From: Mail Delivery System <mailer-daemon@$qualify_domain_sender>
23797 .endd
23798 .oindex &%errors_reply_to%&
23799 If you supply a &'Reply-To:'& line, it overrides the global &%errors_reply_to%&
23800 option.
23801
23802 The &%quota%& option does not have to be set in order to use this option; they
23803 are independent of one another except when the threshold is specified as a
23804 percentage.
23805
23806
23807 .option use_bsmtp appendfile boolean false
23808 .cindex "envelope from"
23809 .cindex "envelope sender"
23810 If this option is set true, &(appendfile)& writes messages in &"batch SMTP"&
23811 format, with the envelope sender and recipient(s) included as SMTP commands. If
23812 you want to include a leading HELO command with such messages, you can do
23813 so by setting the &%message_prefix%& option. See section &<<SECTbatchSMTP>>&
23814 for details of batch SMTP.
23815
23816
23817 .option use_crlf appendfile boolean false
23818 .cindex "carriage return"
23819 .cindex "linefeed"
23820 This option causes lines to be terminated with the two-character CRLF sequence
23821 (carriage return, linefeed) instead of just a linefeed character. In the case
23822 of batched SMTP, the byte sequence written to the file is then an exact image
23823 of what would be sent down a real SMTP connection.
23824
23825 &*Note:*& The contents of the &%message_prefix%& and &%message_suffix%& options
23826 (which are used to supply the traditional &"From&~"& and blank line separators
23827 in Berkeley-style mailboxes) are written verbatim, so must contain their own
23828 carriage return characters if these are needed. In cases where these options
23829 have non-empty defaults, the values end with a single linefeed, so they must be
23830 changed to end with &`\r\n`& if &%use_crlf%& is set.
23831
23832
23833 .option use_fcntl_lock appendfile boolean "see below"
23834 This option controls the use of the &[fcntl()]& function to lock a file for
23835 exclusive use when a message is being appended. It is set by default unless
23836 &%use_flock_lock%& is set. Otherwise, it should be turned off only if you know
23837 that all your MUAs use lock file locking. When both &%use_fcntl_lock%& and
23838 &%use_flock_lock%& are unset, &%use_lockfile%& must be set.
23839
23840
23841 .option use_flock_lock appendfile boolean false
23842 This option is provided to support the use of &[flock()]& for file locking, for
23843 the few situations where it is needed. Most modern operating systems support
23844 &[fcntl()]& and &[lockf()]& locking, and these two functions interwork with
23845 each other. Exim uses &[fcntl()]& locking by default.
23846
23847 This option is required only if you are using an operating system where
23848 &[flock()]& is used by programs that access mailboxes (typically MUAs), and
23849 where &[flock()]& does not correctly interwork with &[fcntl()]&. You can use
23850 both &[fcntl()]& and &[flock()]& locking simultaneously if you want.
23851
23852 .cindex "Solaris" "&[flock()]& support"
23853 Not all operating systems provide &[flock()]&. Some versions of Solaris do not
23854 have it (and some, I think, provide a not quite right version built on top of
23855 &[lockf()]&). If the OS does not have &[flock()]&, Exim will be built without
23856 the ability to use it, and any attempt to do so will cause a configuration
23857 error.
23858
23859 &*Warning*&: &[flock()]& locks do not work on NFS files (unless &[flock()]&
23860 is just being mapped onto &[fcntl()]& by the OS).
23861
23862
23863 .option use_lockfile appendfile boolean "see below"
23864 If this option is turned off, Exim does not attempt to create a lock file when
23865 appending to a mailbox file. In this situation, the only locking is by
23866 &[fcntl()]&. You should only turn &%use_lockfile%& off if you are absolutely
23867 sure that every MUA that is ever going to look at your users' mailboxes uses
23868 &[fcntl()]& rather than a lock file, and even then only when you are not
23869 delivering over NFS from more than one host.
23870
23871 .cindex "NFS" "lock file"
23872 In order to append to an NFS file safely from more than one host, it is
23873 necessary to take out a lock &'before'& opening the file, and the lock file
23874 achieves this. Otherwise, even with &[fcntl()]& locking, there is a risk of
23875 file corruption.
23876
23877 The &%use_lockfile%& option is set by default unless &%use_mbx_lock%& is set.
23878 It is not possible to turn both &%use_lockfile%& and &%use_fcntl_lock%& off,
23879 except when &%mbx_format%& is set.
23880
23881
23882 .option use_mbx_lock appendfile boolean "see below"
23883 This option is available only if Exim has been compiled with SUPPORT_MBX
23884 set in &_Local/Makefile_&. Setting the option specifies that special MBX
23885 locking rules be used. It is set by default if &%mbx_format%& is set and none
23886 of the locking options are mentioned in the configuration. The locking rules
23887 are the same as are used by the &'c-client'& library that underlies Pine and
23888 the IMAP4 and POP daemons that come with it (see the discussion below). The
23889 rules allow for shared access to the mailbox. However, this kind of locking
23890 does not work when the mailbox is NFS mounted.
23891
23892 You can set &%use_mbx_lock%& with either (or both) of &%use_fcntl_lock%& and
23893 &%use_flock_lock%& to control what kind of locking is used in implementing the
23894 MBX locking rules. The default is to use &[fcntl()]& if &%use_mbx_lock%& is set
23895 without &%use_fcntl_lock%& or &%use_flock_lock%&.
23896
23897
23898
23899
23900 .section "Operational details for appending" "SECTopappend"
23901 .cindex "appending to a file"
23902 .cindex "file" "appending"
23903 Before appending to a file, the following preparations are made:
23904
23905 .ilist
23906 If the name of the file is &_/dev/null_&, no action is taken, and a success
23907 return is given.
23908
23909 .next
23910 .cindex "directory creation"
23911 If any directories on the file's path are missing, Exim creates them if the
23912 &%create_directory%& option is set. A created directory's mode is given by the
23913 &%directory_mode%& option.
23914
23915 .next
23916 If &%file_format%& is set, the format of an existing file is checked. If this
23917 indicates that a different transport should be used, control is passed to that
23918 transport.
23919
23920 .next
23921 .cindex "file" "locking"
23922 .cindex "locking files"
23923 .cindex "NFS" "lock file"
23924 If &%use_lockfile%& is set, a lock file is built in a way that will work
23925 reliably over NFS, as follows:
23926
23927 .olist
23928 Create a &"hitching post"& file whose name is that of the lock file with the
23929 current time, primary host name, and process id added, by opening for writing
23930 as a new file. If this fails with an access error, delivery is deferred.
23931 .next
23932 Close the hitching post file, and hard link it to the lock filename.
23933 .next
23934 If the call to &[link()]& succeeds, creation of the lock file has succeeded.
23935 Unlink the hitching post name.
23936 .next
23937 Otherwise, use &[stat()]& to get information about the hitching post file, and
23938 then unlink hitching post name. If the number of links is exactly two, creation
23939 of the lock file succeeded but something (for example, an NFS server crash and
23940 restart) caused this fact not to be communicated to the &[link()]& call.
23941 .next
23942 If creation of the lock file failed, wait for &%lock_interval%& and try again,
23943 up to &%lock_retries%& times. However, since any program that writes to a
23944 mailbox should complete its task very quickly, it is reasonable to time out old
23945 lock files that are normally the result of user agent and system crashes. If an
23946 existing lock file is older than &%lockfile_timeout%& Exim attempts to unlink
23947 it before trying again.
23948 .endlist olist
23949
23950 .next
23951 A call is made to &[lstat()]& to discover whether the main file exists, and if
23952 so, what its characteristics are. If &[lstat()]& fails for any reason other
23953 than non-existence, delivery is deferred.
23954
23955 .next
23956 .cindex "symbolic link" "to mailbox"
23957 .cindex "mailbox" "symbolic link"
23958 If the file does exist and is a symbolic link, delivery is deferred, unless the
23959 &%allow_symlink%& option is set, in which case the ownership of the link is
23960 checked, and then &[stat()]& is called to find out about the real file, which
23961 is then subjected to the checks below. The check on the top-level link
23962 ownership prevents one user creating a link for another's mailbox in a sticky
23963 directory, though allowing symbolic links in this case is definitely not a good
23964 idea. If there is a chain of symbolic links, the intermediate ones are not
23965 checked.
23966
23967 .next
23968 If the file already exists but is not a regular file, or if the file's owner
23969 and group (if the group is being checked &-- see &%check_group%& above) are
23970 different from the user and group under which the delivery is running,
23971 delivery is deferred.
23972
23973 .next
23974 If the file's permissions are more generous than specified, they are reduced.
23975 If they are insufficient, delivery is deferred, unless &%mode_fail_narrower%&
23976 is set false, in which case the delivery is tried using the existing
23977 permissions.
23978
23979 .next
23980 The file's inode number is saved, and the file is then opened for appending.
23981 If this fails because the file has vanished, &(appendfile)& behaves as if it
23982 hadn't existed (see below). For any other failures, delivery is deferred.
23983
23984 .next
23985 If the file is opened successfully, check that the inode number hasn't
23986 changed, that it is still a regular file, and that the owner and permissions
23987 have not changed. If anything is wrong, defer delivery and freeze the message.
23988
23989 .next
23990 If the file did not exist originally, defer delivery if the &%file_must_exist%&
23991 option is set. Otherwise, check that the file is being created in a permitted
23992 directory if the &%create_file%& option is set (deferring on failure), and then
23993 open for writing as a new file, with the O_EXCL and O_CREAT options,
23994 except when dealing with a symbolic link (the &%allow_symlink%& option must be
23995 set). In this case, which can happen if the link points to a non-existent file,
23996 the file is opened for writing using O_CREAT but not O_EXCL, because
23997 that prevents link following.
23998
23999 .next
24000 .cindex "loop" "while file testing"
24001 If opening fails because the file exists, obey the tests given above for
24002 existing files. However, to avoid looping in a situation where the file is
24003 being continuously created and destroyed, the exists/not-exists loop is broken
24004 after 10 repetitions, and the message is then frozen.
24005
24006 .next
24007 If opening fails with any other error, defer delivery.
24008
24009 .next
24010 .cindex "file" "locking"
24011 .cindex "locking files"
24012 Once the file is open, unless both &%use_fcntl_lock%& and &%use_flock_lock%&
24013 are false, it is locked using &[fcntl()]& or &[flock()]& or both. If
24014 &%use_mbx_lock%& is false, an exclusive lock is requested in each case.
24015 However, if &%use_mbx_lock%& is true, Exim takes out a shared lock on the open
24016 file, and an exclusive lock on the file whose name is
24017 .code
24018 /tmp/.<device-number>.<inode-number>
24019 .endd
24020 using the device and inode numbers of the open mailbox file, in accordance with
24021 the MBX locking rules. This file is created with a mode that is specified by
24022 the &%lockfile_mode%& option.
24023
24024 If Exim fails to lock the file, there are two possible courses of action,
24025 depending on the value of the locking timeout. This is obtained from
24026 &%lock_fcntl_timeout%& or &%lock_flock_timeout%&, as appropriate.
24027
24028 If the timeout value is zero, the file is closed, Exim waits for
24029 &%lock_interval%&, and then goes back and re-opens the file as above and tries
24030 to lock it again. This happens up to &%lock_retries%& times, after which the
24031 delivery is deferred.
24032
24033 If the timeout has a value greater than zero, blocking calls to &[fcntl()]& or
24034 &[flock()]& are used (with the given timeout), so there has already been some
24035 waiting involved by the time locking fails. Nevertheless, Exim does not give up
24036 immediately. It retries up to
24037 .code
24038 (lock_retries * lock_interval) / <timeout>
24039 .endd
24040 times (rounded up).
24041 .endlist
24042
24043 At the end of delivery, Exim closes the file (which releases the &[fcntl()]&
24044 and/or &[flock()]& locks) and then deletes the lock file if one was created.
24045
24046
24047 .section "Operational details for delivery to a new file" "SECTopdir"
24048 .cindex "delivery" "to single file"
24049 .cindex "&""From""& line"
24050 When the &%directory%& option is set instead of &%file%&, each message is
24051 delivered into a newly-created file or set of files. When &(appendfile)& is
24052 activated directly from a &(redirect)& router, neither &%file%& nor
24053 &%directory%& is normally set, because the path for delivery is supplied by the
24054 router. (See for example, the &(address_file)& transport in the default
24055 configuration.) In this case, delivery is to a new file if either the path name
24056 ends in &`/`&, or the &%maildir_format%& or &%mailstore_format%& option is set.
24057
24058 No locking is required while writing the message to a new file, so the various
24059 locking options of the transport are ignored. The &"From"& line that by default
24060 separates messages in a single file is not normally needed, nor is the escaping
24061 of message lines that start with &"From"&, and there is no need to ensure a
24062 newline at the end of each message. Consequently, the default values for
24063 &%check_string%&, &%message_prefix%&, and &%message_suffix%& are all unset when
24064 any of &%directory%&, &%maildir_format%&, or &%mailstore_format%& is set.
24065
24066 If Exim is required to check a &%quota%& setting, it adds up the sizes of all
24067 the files in the delivery directory by default. However, you can specify a
24068 different directory by setting &%quota_directory%&. Also, for maildir
24069 deliveries (see below) the &_maildirfolder_& convention is honoured.
24070
24071
24072 .cindex "maildir format"
24073 .cindex "mailstore format"
24074 There are three different ways in which delivery to individual files can be
24075 done, controlled by the settings of the &%maildir_format%& and
24076 &%mailstore_format%& options. Note that code to support maildir or mailstore
24077 formats is not included in the binary unless SUPPORT_MAILDIR or
24078 SUPPORT_MAILSTORE, respectively, is set in &_Local/Makefile_&.
24079
24080 .cindex "directory creation"
24081 In all three cases an attempt is made to create the directory and any necessary
24082 sub-directories if they do not exist, provided that the &%create_directory%&
24083 option is set (the default). The location of a created directory can be
24084 constrained by setting &%create_file%&. A created directory's mode is given by
24085 the &%directory_mode%& option. If creation fails, or if the
24086 &%create_directory%& option is not set when creation is required, delivery is
24087 deferred.
24088
24089
24090
24091 .section "Maildir delivery" "SECTmaildirdelivery"
24092 .cindex "maildir format" "description of"
24093 If the &%maildir_format%& option is true, Exim delivers each message by writing
24094 it to a file whose name is &_tmp/<stime>.H<mtime>P<pid>.<host>_& in the
24095 directory that is defined by the &%directory%& option (the &"delivery
24096 directory"&). If the delivery is successful, the file is renamed into the
24097 &_new_& subdirectory.
24098
24099 In the filename, <&'stime'&> is the current time of day in seconds, and
24100 <&'mtime'&> is the microsecond fraction of the time. After a maildir delivery,
24101 Exim checks that the time-of-day clock has moved on by at least one microsecond
24102 before terminating the delivery process. This guarantees uniqueness for the
24103 filename. However, as a precaution, Exim calls &[stat()]& for the file before
24104 opening it. If any response other than ENOENT (does not exist) is given,
24105 Exim waits 2 seconds and tries again, up to &%maildir_retries%& times.
24106
24107 Before Exim carries out a maildir delivery, it ensures that subdirectories
24108 called &_new_&, &_cur_&, and &_tmp_& exist in the delivery directory. If they
24109 do not exist, Exim tries to create them and any superior directories in their
24110 path, subject to the &%create_directory%& and &%create_file%& options. If the
24111 &%maildirfolder_create_regex%& option is set, and the regular expression it
24112 contains matches the delivery directory, Exim also ensures that a file called
24113 &_maildirfolder_& exists in the delivery directory. If a missing directory or
24114 &_maildirfolder_& file cannot be created, delivery is deferred.
24115
24116 These features make it possible to use Exim to create all the necessary files
24117 and directories in a maildir mailbox, including subdirectories for maildir++
24118 folders. Consider this example:
24119 .code
24120 maildir_format = true
24121 directory = /var/mail/$local_part_data\
24122            ${if eq{$local_part_suffix}{}{}\
24123            {/.${substr_1:$local_part_suffix}}}
24124 maildirfolder_create_regex = /\.[^/]+$
24125 .endd
24126 If &$local_part_suffix$& is empty (there was no suffix for the local part),
24127 delivery is into a toplevel maildir with a name like &_/var/mail/pimbo_& (for
24128 the user called &'pimbo'&). The pattern in &%maildirfolder_create_regex%& does
24129 not match this name, so Exim will not look for or create the file
24130 &_/var/mail/pimbo/maildirfolder_&, though it will create
24131 &_/var/mail/pimbo/{cur,new,tmp}_& if necessary.
24132
24133 However, if &$local_part_suffix$& contains &`-eximusers`& (for example),
24134 delivery is into the maildir++ folder &_/var/mail/pimbo/.eximusers_&, which
24135 does match &%maildirfolder_create_regex%&. In this case, Exim will create
24136 &_/var/mail/pimbo/.eximusers/maildirfolder_& as well as the three maildir
24137 directories &_/var/mail/pimbo/.eximusers/{cur,new,tmp}_&.
24138
24139 &*Warning:*& Take care when setting &%maildirfolder_create_regex%& that it does
24140 not inadvertently match the toplevel maildir directory, because a
24141 &_maildirfolder_& file at top level would completely break quota calculations.
24142
24143 .cindex "quota" "in maildir delivery"
24144 .cindex "maildir++"
24145 If Exim is required to check a &%quota%& setting before a maildir delivery, and
24146 &%quota_directory%& is not set, it looks for a file called &_maildirfolder_& in
24147 the maildir directory (alongside &_new_&, &_cur_&, &_tmp_&). If this exists,
24148 Exim assumes the directory is a maildir++ folder directory, which is one level
24149 down from the user's top level mailbox directory. This causes it to start at
24150 the parent directory instead of the current directory when calculating the
24151 amount of space used.
24152
24153 One problem with delivering into a multi-file mailbox is that it is
24154 computationally expensive to compute the size of the mailbox for quota
24155 checking. Various approaches have been taken to reduce the amount of work
24156 needed. The next two sections describe two of them. A third alternative is to
24157 use some external process for maintaining the size data, and use the expansion
24158 of the &%mailbox_size%& option as a way of importing it into Exim.
24159
24160
24161
24162
24163 .section "Using tags to record message sizes" "SECID135"
24164 If &%maildir_tag%& is set, the string is expanded for each delivery.
24165 When the maildir file is renamed into the &_new_& sub-directory, the
24166 tag is added to its name. However, if adding the tag takes the length of the
24167 name to the point where the test &[stat()]& call fails with ENAMETOOLONG,
24168 the tag is dropped and the maildir file is created with no tag.
24169
24170
24171 .vindex "&$message_size$&"
24172 Tags can be used to encode the size of files in their names; see
24173 &%quota_size_regex%& above for an example. The expansion of &%maildir_tag%&
24174 happens after the message has been written. The value of the &$message_size$&
24175 variable is set to the number of bytes actually written. If the expansion is
24176 forced to fail, the tag is ignored, but a non-forced failure causes delivery to
24177 be deferred. The expanded tag may contain any printing characters except &"/"&.
24178 Non-printing characters in the string are ignored; if the resulting string is
24179 empty, it is ignored. If it starts with an alphanumeric character, a leading
24180 colon is inserted; this default has not proven to be the path that popular
24181 maildir implementations have chosen (but changing it in Exim would break
24182 backwards compatibility).
24183
24184 For one common implementation, you might set:
24185 .code
24186 maildir_tag = ,S=${message_size}
24187 .endd
24188 but you should check the documentation of the other software to be sure.
24189
24190 It is advisable to also set &%quota_size_regex%& when setting &%maildir_tag%&
24191 as this allows Exim to extract the size from your tag, instead of having to
24192 &[stat()]& each message file.
24193
24194
24195 .section "Using a maildirsize file" "SECID136"
24196 .cindex "quota" "in maildir delivery"
24197 .cindex "maildir format" "&_maildirsize_& file"
24198 If &%maildir_use_size_file%& is true, Exim implements the maildir++ rules for
24199 storing quota and message size information in a file called &_maildirsize_&
24200 within the toplevel maildir directory. If this file does not exist, Exim
24201 creates it, setting the quota from the &%quota%& option of the transport. If
24202 the maildir directory itself does not exist, it is created before any attempt
24203 to write a &_maildirsize_& file.
24204
24205 The &_maildirsize_& file is used to hold information about the sizes of
24206 messages in the maildir, thus speeding up quota calculations. The quota value
24207 in the file is just a cache; if the quota is changed in the transport, the new
24208 value overrides the cached value when the next message is delivered. The cache
24209 is maintained for the benefit of other programs that access the maildir and
24210 need to know the quota.
24211
24212 If the &%quota%& option in the transport is unset or zero, the &_maildirsize_&
24213 file is maintained (with a zero quota setting), but no quota is imposed.
24214
24215 A regular expression is available for controlling which directories in the
24216 maildir participate in quota calculations when a &_maildirsizefile_& is in use.
24217 See the description of the &%maildir_quota_directory_regex%& option above for
24218 details.
24219
24220
24221 .section "Mailstore delivery" "SECID137"
24222 .cindex "mailstore format" "description of"
24223 If the &%mailstore_format%& option is true, each message is written as two
24224 files in the given directory. A unique base name is constructed from the
24225 message id and the current delivery process, and the files that are written use
24226 this base name plus the suffixes &_.env_& and &_.msg_&. The &_.env_& file
24227 contains the message's envelope, and the &_.msg_& file contains the message
24228 itself. The base name is placed in the variable &$mailstore_basename$&.
24229
24230 During delivery, the envelope is first written to a file with the suffix
24231 &_.tmp_&. The &_.msg_& file is then written, and when it is complete, the
24232 &_.tmp_& file is renamed as the &_.env_& file. Programs that access messages in
24233 mailstore format should wait for the presence of both a &_.msg_& and a &_.env_&
24234 file before accessing either of them. An alternative approach is to wait for
24235 the absence of a &_.tmp_& file.
24236
24237 The envelope file starts with any text defined by the &%mailstore_prefix%&
24238 option, expanded and terminated by a newline if there isn't one. Then follows
24239 the sender address on one line, then all the recipient addresses, one per line.
24240 There can be more than one recipient only if the &%batch_max%& option is set
24241 greater than one. Finally, &%mailstore_suffix%& is expanded and the result
24242 appended to the file, followed by a newline if it does not end with one.
24243
24244 If expansion of &%mailstore_prefix%& or &%mailstore_suffix%& ends with a forced
24245 failure, it is ignored. Other expansion errors are treated as serious
24246 configuration errors, and delivery is deferred. The variable
24247 &$mailstore_basename$& is available for use during these expansions.
24248
24249
24250 .section "Non-special new file delivery" "SECID138"
24251 If neither &%maildir_format%& nor &%mailstore_format%& is set, a single new
24252 file is created directly in the named directory. For example, when delivering
24253 messages into files in batched SMTP format for later delivery to some host (see
24254 section &<<SECTbatchSMTP>>&), a setting such as
24255 .code
24256 directory = /var/bsmtp/$host
24257 .endd
24258 might be used. A message is written to a file with a temporary name, which is
24259 then renamed when the delivery is complete. The final name is obtained by
24260 expanding the contents of the &%directory_file%& option.
24261 .ecindex IIDapptra1
24262 .ecindex IIDapptra2
24263
24264
24265
24266
24267
24268
24269 . ////////////////////////////////////////////////////////////////////////////
24270 . ////////////////////////////////////////////////////////////////////////////
24271
24272 .chapter "The autoreply transport" "CHID8"
24273 .scindex IIDauttra1 "transports" "&(autoreply)&"
24274 .scindex IIDauttra2 "&(autoreply)& transport"
24275 The &(autoreply)& transport is not a true transport in that it does not cause
24276 the message to be transmitted. Instead, it generates a new mail message as an
24277 automatic reply to the incoming message. &'References:'& and
24278 &'Auto-Submitted:'& header lines are included. These are constructed according
24279 to the rules in RFCs 2822 and 3834, respectively.
24280
24281 If the router that passes the message to this transport does not have the
24282 &%unseen%& option set, the original message (for the current recipient) is not
24283 delivered anywhere. However, when the &%unseen%& option is set on the router
24284 that passes the message to this transport, routing of the address continues, so
24285 another router can set up a normal message delivery.
24286
24287
24288 The &(autoreply)& transport is usually run as the result of mail filtering, a
24289 &"vacation"& message being the standard example. However, it can also be run
24290 directly from a router like any other transport. To reduce the possibility of
24291 message cascades, messages created by the &(autoreply)& transport always have
24292 empty envelope sender addresses, like bounce messages.
24293
24294 The parameters of the message to be sent can be specified in the configuration
24295 by options described below. However, these are used only when the address
24296 passed to the transport does not contain its own reply information. When the
24297 transport is run as a consequence of a
24298 &%mail%&
24299 or &%vacation%& command in a filter file, the parameters of the message are
24300 supplied by the filter, and passed with the address. The transport's options
24301 that define the message are then ignored (so they are not usually set in this
24302 case). The message is specified entirely by the filter or by the transport; it
24303 is never built from a mixture of options. However, the &%file_optional%&,
24304 &%mode%&, and &%return_message%& options apply in all cases.
24305
24306 &(Autoreply)& is implemented as a local transport. When used as a result of a
24307 command in a user's filter file, &(autoreply)& normally runs under the uid and
24308 gid of the user, and with appropriate current and home directories (see chapter
24309 &<<CHAPenvironment>>&).
24310
24311 There is a subtle difference between routing a message to a &(pipe)& transport
24312 that generates some text to be returned to the sender, and routing it to an
24313 &(autoreply)& transport. This difference is noticeable only if more than one
24314 address from the same message is so handled. In the case of a pipe, the
24315 separate outputs from the different addresses are gathered up and returned to
24316 the sender in a single message, whereas if &(autoreply)& is used, a separate
24317 message is generated for each address that is passed to it.
24318
24319 Non-printing characters are not permitted in the header lines generated for the
24320 message that &(autoreply)& creates, with the exception of newlines that are
24321 immediately followed by white space. If any non-printing characters are found,
24322 the transport defers.
24323 Whether characters with the top bit set count as printing characters or not is
24324 controlled by the &%print_topbitchars%& global option.
24325
24326 If any of the generic options for manipulating headers (for example,
24327 &%headers_add%&) are set on an &(autoreply)& transport, they apply to the copy
24328 of the original message that is included in the generated message when
24329 &%return_message%& is set. They do not apply to the generated message itself.
24330
24331 .vindex "&$sender_address$&"
24332 If the &(autoreply)& transport receives return code 2 from Exim when it submits
24333 the message, indicating that there were no recipients, it does not treat this
24334 as an error. This means that autoreplies sent to &$sender_address$& when this
24335 is empty (because the incoming message is a bounce message) do not cause
24336 problems. They are just discarded.
24337
24338
24339
24340 .section "Private options for autoreply" "SECID139"
24341 .cindex "options" "&(autoreply)& transport"
24342
24343 .option bcc autoreply string&!! unset
24344 This specifies the addresses that are to receive &"blind carbon copies"& of the
24345 message when the message is specified by the transport.
24346
24347
24348 .option cc autoreply string&!! unset
24349 This specifies recipients of the message and the contents of the &'Cc:'& header
24350 when the message is specified by the transport.
24351
24352
24353 .option file autoreply string&!! unset
24354 The contents of the file are sent as the body of the message when the message
24355 is specified by the transport. If both &%file%& and &%text%& are set, the text
24356 string comes first.
24357
24358
24359 .option file_expand autoreply boolean false
24360 If this is set, the contents of the file named by the &%file%& option are
24361 subjected to string expansion as they are added to the message.
24362
24363
24364 .option file_optional autoreply boolean false
24365 If this option is true, no error is generated if the file named by the &%file%&
24366 option or passed with the address does not exist or cannot be read.
24367
24368
24369 .option from autoreply string&!! unset
24370 This specifies the contents of the &'From:'& header when the message is
24371 specified by the transport.
24372
24373
24374 .option headers autoreply string&!! unset
24375 This specifies additional RFC 2822 headers that are to be added to the message
24376 when the message is specified by the transport. Several can be given by using
24377 &"\n"& to separate them. There is no check on the format.
24378
24379
24380 .option log autoreply string&!! unset
24381 This option names a file in which a record of every message sent is logged when
24382 the message is specified by the transport.
24383
24384
24385 .option mode autoreply "octal integer" 0600
24386 If either the log file or the &"once"& file has to be created, this mode is
24387 used.
24388
24389
24390 .option never_mail autoreply "address list&!!" unset
24391 If any run of the transport creates a message with a recipient that matches any
24392 item in the list, that recipient is quietly discarded. If all recipients are
24393 discarded, no message is created. This applies both when the recipients are
24394 generated by a filter and when they are specified in the transport.
24395
24396
24397
24398 .option once autoreply string&!! unset
24399 This option names a file or DBM database in which a record of each &'To:'&
24400 recipient is kept when the message is specified by the transport. &*Note*&:
24401 This does not apply to &'Cc:'& or &'Bcc:'& recipients.
24402
24403 If &%once%& is unset, or is set to an empty string, the message is always sent.
24404 By default, if &%once%& is set to a non-empty filename, the message
24405 is not sent if a potential recipient is already listed in the database.
24406 However, if the &%once_repeat%& option specifies a time greater than zero, the
24407 message is sent if that much time has elapsed since a message was last sent to
24408 this recipient. A setting of zero time for &%once_repeat%& (the default)
24409 prevents a message from being sent a second time &-- in this case, zero means
24410 infinity.
24411
24412 If &%once_file_size%& is zero, a DBM database is used to remember recipients,
24413 and it is allowed to grow as large as necessary. If &%once_file_size%& is set
24414 greater than zero, it changes the way Exim implements the &%once%& option.
24415 Instead of using a DBM file to record every recipient it sends to, it uses a
24416 regular file, whose size will never get larger than the given value.
24417
24418 In the file, Exim keeps a linear list of recipient addresses and the times at
24419 which they were sent messages. If the file is full when a new address needs to
24420 be added, the oldest address is dropped. If &%once_repeat%& is not set, this
24421 means that a given recipient may receive multiple messages, but at
24422 unpredictable intervals that depend on the rate of turnover of addresses in the
24423 file. If &%once_repeat%& is set, it specifies a maximum time between repeats.
24424
24425
24426 .option once_file_size autoreply integer 0
24427 See &%once%& above.
24428
24429
24430 .option once_repeat autoreply time&!! 0s
24431 See &%once%& above.
24432 After expansion, the value of this option must be a valid time value.
24433
24434
24435 .option reply_to autoreply string&!! unset
24436 This specifies the contents of the &'Reply-To:'& header when the message is
24437 specified by the transport.
24438
24439
24440 .option return_message autoreply boolean false
24441 If this is set, a copy of the original message is returned with the new
24442 message, subject to the maximum size set in the &%return_size_limit%& global
24443 configuration option.
24444
24445
24446 .option subject autoreply string&!! unset
24447 This specifies the contents of the &'Subject:'& header when the message is
24448 specified by the transport. It is tempting to quote the original subject in
24449 automatic responses. For example:
24450 .code
24451 subject = Re: $h_subject:
24452 .endd
24453 There is a danger in doing this, however. It may allow a third party to
24454 subscribe your users to an opt-in mailing list, provided that the list accepts
24455 bounce messages as subscription confirmations. Well-managed lists require a
24456 non-bounce message to confirm a subscription, so the danger is relatively
24457 small.
24458
24459
24460
24461 .option text autoreply string&!! unset
24462 This specifies a single string to be used as the body of the message when the
24463 message is specified by the transport. If both &%text%& and &%file%& are set,
24464 the text comes first.
24465
24466
24467 .option to autoreply string&!! unset
24468 This specifies recipients of the message and the contents of the &'To:'& header
24469 when the message is specified by the transport.
24470 .ecindex IIDauttra1
24471 .ecindex IIDauttra2
24472
24473
24474
24475
24476 . ////////////////////////////////////////////////////////////////////////////
24477 . ////////////////////////////////////////////////////////////////////////////
24478
24479 .chapter "The lmtp transport" "CHAPLMTP"
24480 .cindex "transports" "&(lmtp)&"
24481 .cindex "&(lmtp)& transport"
24482 .cindex "LMTP" "over a pipe"
24483 .cindex "LMTP" "over a socket"
24484 The &(lmtp)& transport runs the LMTP protocol (RFC 2033) over a pipe to a
24485 specified command
24486 or by interacting with a Unix domain socket.
24487 This transport is something of a cross between the &(pipe)& and &(smtp)&
24488 transports. Exim also has support for using LMTP over TCP/IP; this is
24489 implemented as an option for the &(smtp)& transport. Because LMTP is expected
24490 to be of minority interest, the default build-time configure in &_src/EDITME_&
24491 has it commented out. You need to ensure that
24492 .code
24493 TRANSPORT_LMTP=yes
24494 .endd
24495 .cindex "options" "&(lmtp)& transport"
24496 is present in your &_Local/Makefile_& in order to have the &(lmtp)& transport
24497 included in the Exim binary. The private options of the &(lmtp)& transport are
24498 as follows:
24499
24500 .option batch_id lmtp string&!! unset
24501 See the description of local delivery batching in chapter &<<CHAPbatching>>&.
24502
24503
24504 .option batch_max lmtp integer 1
24505 This limits the number of addresses that can be handled in a single delivery.
24506 Most LMTP servers can handle several addresses at once, so it is normally a
24507 good idea to increase this value. See the description of local delivery
24508 batching in chapter &<<CHAPbatching>>&.
24509
24510
24511 .option command lmtp string&!! unset
24512 This option must be set if &%socket%& is not set. The string is a command which
24513 is run in a separate process. It is split up into a command name and list of
24514 arguments, each of which is separately expanded (so expansion cannot change the
24515 number of arguments). The command is run directly, not via a shell. The message
24516 is passed to the new process using the standard input and output to operate the
24517 LMTP protocol.
24518
24519 .option ignore_quota lmtp boolean false
24520 .cindex "LMTP" "ignoring quota errors"
24521 If this option is set true, the string &`IGNOREQUOTA`& is added to RCPT
24522 commands, provided that the LMTP server has advertised support for IGNOREQUOTA
24523 in its response to the LHLO command.
24524
24525 .option socket lmtp string&!! unset
24526 This option must be set if &%command%& is not set. The result of expansion must
24527 be the name of a Unix domain socket. The transport connects to the socket and
24528 delivers the message to it using the LMTP protocol.
24529
24530
24531 .option timeout lmtp time 5m
24532 The transport is aborted if the created process or Unix domain socket does not
24533 respond to LMTP commands or message input within this timeout. Delivery
24534 is deferred, and will be tried again later. Here is an example of a typical
24535 LMTP transport:
24536 .code
24537 lmtp:
24538   driver = lmtp
24539   command = /some/local/lmtp/delivery/program
24540   batch_max = 20
24541   user = exim
24542 .endd
24543 This delivers up to 20 addresses at a time, in a mixture of domains if
24544 necessary, running as the user &'exim'&.
24545
24546
24547
24548 . ////////////////////////////////////////////////////////////////////////////
24549 . ////////////////////////////////////////////////////////////////////////////
24550
24551 .chapter "The pipe transport" "CHAPpipetransport"
24552 .scindex IIDpiptra1 "transports" "&(pipe)&"
24553 .scindex IIDpiptra2 "&(pipe)& transport"
24554 The &(pipe)& transport is used to deliver messages via a pipe to a command
24555 running in another process. One example is the use of &(pipe)& as a
24556 pseudo-remote transport for passing messages to some other delivery mechanism
24557 (such as UUCP). Another is the use by individual users to automatically process
24558 their incoming messages. The &(pipe)& transport can be used in one of the
24559 following ways:
24560
24561 .ilist
24562 .vindex "&$local_part$&"
24563 A router routes one address to a transport in the normal way, and the
24564 transport is configured as a &(pipe)& transport. In this case, &$local_part$&
24565 contains the local part of the address (as usual), and the command that is run
24566 is specified by the &%command%& option on the transport.
24567 .next
24568 .vindex "&$pipe_addresses$&"
24569 If the &%batch_max%& option is set greater than 1 (the default is 1), the
24570 transport can handle more than one address in a single run. In this case, when
24571 more than one address is routed to the transport, &$local_part$& is not set
24572 (because it is not unique). However, the pseudo-variable &$pipe_addresses$&
24573 (described in section &<<SECThowcommandrun>>& below) contains all the addresses
24574 that are routed to the transport.
24575 .next
24576 .vindex "&$address_pipe$&"
24577 A router redirects an address directly to a pipe command (for example, from an
24578 alias or forward file). In this case, &$address_pipe$& contains the text of the
24579 pipe command, and the &%command%& option on the transport is ignored unless
24580 &%force_command%& is set. If only one address is being transported
24581 (&%batch_max%& is not greater than one, or only one address was redirected to
24582 this pipe command), &$local_part$& contains the local part that was redirected.
24583 .endlist
24584
24585
24586 The &(pipe)& transport is a non-interactive delivery method. Exim can also
24587 deliver messages over pipes using the LMTP interactive protocol. This is
24588 implemented by the &(lmtp)& transport.
24589
24590 In the case when &(pipe)& is run as a consequence of an entry in a local user's
24591 &_.forward_& file, the command runs under the uid and gid of that user. In
24592 other cases, the uid and gid have to be specified explicitly, either on the
24593 transport or on the router that handles the address. Current and &"home"&
24594 directories are also controllable. See chapter &<<CHAPenvironment>>& for
24595 details of the local delivery environment and chapter &<<CHAPbatching>>&
24596 for a discussion of local delivery batching.
24597
24598 .cindex "tainted data" "in pipe command"
24599 .cindex pipe "tainted data"
24600 Tainted data may not be used for the command name.
24601
24602
24603 .section "Concurrent delivery" "SECID140"
24604 If two messages arrive at almost the same time, and both are routed to a pipe
24605 delivery, the two pipe transports may be run concurrently. You must ensure that
24606 any pipe commands you set up are robust against this happening. If the commands
24607 write to a file, the &%exim_lock%& utility might be of use.
24608 Alternatively the &%max_parallel%& option could be used with a value
24609 of "1" to enforce serialization.
24610
24611
24612
24613
24614 .section "Returned status and data" "SECID141"
24615 .cindex "&(pipe)& transport" "returned data"
24616 If the command exits with a non-zero return code, the delivery is deemed to
24617 have failed, unless either the &%ignore_status%& option is set (in which case
24618 the return code is treated as zero), or the return code is one of those listed
24619 in the &%temp_errors%& option, which are interpreted as meaning &"try again
24620 later"&. In this case, delivery is deferred. Details of a permanent failure are
24621 logged, but are not included in the bounce message, which merely contains
24622 &"local delivery failed"&.
24623
24624 If the command exits on a signal and the &%freeze_signal%& option is set then
24625 the message will be frozen in the queue. If that option is not set, a bounce
24626 will be sent as normal.
24627
24628 If the return code is greater than 128 and the command being run is a shell
24629 script, it normally means that the script was terminated by a signal whose
24630 value is the return code minus 128. The &%freeze_signal%& option does not
24631 apply in this case.
24632
24633 If Exim is unable to run the command (that is, if &[execve()]& fails), the
24634 return code is set to 127. This is the value that a shell returns if it is
24635 asked to run a non-existent command. The wording for the log line suggests that
24636 a non-existent command may be the problem.
24637
24638 The &%return_output%& option can affect the result of a pipe delivery. If it is
24639 set and the command produces any output on its standard output or standard
24640 error streams, the command is considered to have failed, even if it gave a zero
24641 return code or if &%ignore_status%& is set. The output from the command is
24642 included as part of the bounce message. The &%return_fail_output%& option is
24643 similar, except that output is returned only when the command exits with a
24644 failure return code, that is, a value other than zero or a code that matches
24645 &%temp_errors%&.
24646
24647
24648
24649 .section "How the command is run" "SECThowcommandrun"
24650 .cindex "&(pipe)& transport" "path for command"
24651 The command line is (by default) broken down into a command name and arguments
24652 by the &(pipe)& transport itself. The &%allow_commands%& and
24653 &%restrict_to_path%& options can be used to restrict the commands that may be
24654 run.
24655
24656 .cindex "quoting" "in pipe command"
24657 Unquoted arguments are delimited by white space. If an argument appears in
24658 double quotes, backslash is interpreted as an escape character in the usual
24659 way. If an argument appears in single quotes, no escaping is done.
24660
24661 String expansion is applied to the command line except when it comes from a
24662 traditional &_.forward_& file (commands from a filter file are expanded). The
24663 expansion is applied to each argument in turn rather than to the whole line.
24664 For this reason, any string expansion item that contains white space must be
24665 quoted so as to be contained within a single argument. A setting such as
24666 .code
24667 command = /some/path ${if eq{$local_part}{postmaster}{xx}{yy}}
24668 .endd
24669 will not work, because the expansion item gets split between several
24670 arguments. You have to write
24671 .code
24672 command = /some/path "${if eq{$local_part}{postmaster}{xx}{yy}}"
24673 .endd
24674 to ensure that it is all in one argument. The expansion is done in this way,
24675 argument by argument, so that the number of arguments cannot be changed as a
24676 result of expansion, and quotes or backslashes in inserted variables do not
24677 interact with external quoting. However, this leads to problems if you want to
24678 generate multiple arguments (or the command name plus arguments) from a single
24679 expansion. In this situation, the simplest solution is to use a shell. For
24680 example:
24681 .code
24682 command = /bin/sh -c ${lookup{$local_part}lsearch{/some/file}}
24683 .endd
24684
24685 .cindex "transport" "filter"
24686 .cindex "filter" "transport filter"
24687 .vindex "&$pipe_addresses$&"
24688 Special handling takes place when an argument consists of precisely the text
24689 &`$pipe_addresses`& (no quotes).
24690 This is not a general expansion variable; the only
24691 place this string is recognized is when it appears as an argument for a pipe or
24692 transport filter command. It causes each address that is being handled to be
24693 inserted in the argument list at that point &'as a separate argument'&. This
24694 avoids any problems with spaces or shell metacharacters, and is of use when a
24695 &(pipe)& transport is handling groups of addresses in a batch.
24696
24697 If &%force_command%& is enabled on the transport, special handling takes place
24698 for an argument that consists of precisely the text &`$address_pipe`&.  It
24699 is handled similarly to &$pipe_addresses$& above.  It is expanded and each
24700 argument is inserted in the argument list at that point
24701 &'as a separate argument'&.  The &`$address_pipe`& item does not need to be
24702 the only item in the argument; in fact, if it were then &%force_command%&
24703 should behave as a no-op.  Rather, it should be used to adjust the command
24704 run while preserving the argument vector separation.
24705
24706 After splitting up into arguments and expansion, the resulting command is run
24707 in a subprocess directly from the transport, &'not'& under a shell. The
24708 message that is being delivered is supplied on the standard input, and the
24709 standard output and standard error are both connected to a single pipe that is
24710 read by Exim. The &%max_output%& option controls how much output the command
24711 may produce, and the &%return_output%& and &%return_fail_output%& options
24712 control what is done with it.
24713
24714 Not running the command under a shell (by default) lessens the security risks
24715 in cases when a command from a user's filter file is built out of data that was
24716 taken from an incoming message. If a shell is required, it can of course be
24717 explicitly specified as the command to be run. However, there are circumstances
24718 where existing commands (for example, in &_.forward_& files) expect to be run
24719 under a shell and cannot easily be modified. To allow for these cases, there is
24720 an option called &%use_shell%&, which changes the way the &(pipe)& transport
24721 works. Instead of breaking up the command line as just described, it expands it
24722 as a single string and passes the result to &_/bin/sh_&. The
24723 &%restrict_to_path%& option and the &$pipe_addresses$& facility cannot be used
24724 with &%use_shell%&, and the whole mechanism is inherently less secure.
24725
24726
24727
24728 .section "Environment variables" "SECTpipeenv"
24729 .cindex "&(pipe)& transport" "environment for command"
24730 .cindex "environment" "&(pipe)& transport"
24731 The environment variables listed below are set up when the command is invoked.
24732 This list is a compromise for maximum compatibility with other MTAs. Note that
24733 the &%environment%& option can be used to add additional variables to this
24734 environment. The environment for the &(pipe)& transport is not subject
24735 to the &%add_environment%& and &%keep_environment%& main config options.
24736 &*Note*&: Using enviroment variables loses track of tainted data.
24737 Writers of &(pipe)& transport commands should be wary of data supplied
24738 by potential attackers.
24739 .display
24740 &`DOMAIN            `&   the domain of the address
24741 &`HOME              `&   the home directory, if set
24742 &`HOST              `&   the host name when called from a router (see below)
24743 &`LOCAL_PART        `&   see below
24744 &`LOCAL_PART_PREFIX `&   see below
24745 &`LOCAL_PART_SUFFIX `&   see below
24746 &`LOGNAME           `&   see below
24747 &`MESSAGE_ID        `&   Exim's local ID for the message
24748 &`PATH              `&   as specified by the &%path%& option below
24749 &`QUALIFY_DOMAIN    `&   the sender qualification domain
24750 &`RECIPIENT         `&   the complete recipient address
24751 &`SENDER            `&   the sender of the message (empty if a bounce)
24752 &`SHELL             `&   &`/bin/sh`&
24753 &`TZ                `&   the value of the &%timezone%& option, if set
24754 &`USER              `&   see below
24755 .endd
24756 When a &(pipe)& transport is called directly from (for example) an &(accept)&
24757 router, LOCAL_PART is set to the local part of the address. When it is
24758 called as a result of a forward or alias expansion, LOCAL_PART is set to
24759 the local part of the address that was expanded. In both cases, any affixes are
24760 removed from the local part, and made available in LOCAL_PART_PREFIX and
24761 LOCAL_PART_SUFFIX, respectively. LOGNAME and USER are set to the
24762 same value as LOCAL_PART for compatibility with other MTAs.
24763
24764 .cindex "HOST"
24765 HOST is set only when a &(pipe)& transport is called from a router that
24766 associates hosts with an address, typically when using &(pipe)& as a
24767 pseudo-remote transport. HOST is set to the first host name specified by
24768 the router.
24769
24770 .cindex "HOME"
24771 If the transport's generic &%home_directory%& option is set, its value is used
24772 for the HOME environment variable. Otherwise, a home directory may be set
24773 by the router's &%transport_home_directory%& option, which defaults to the
24774 user's home directory if &%check_local_user%& is set.
24775
24776
24777 .section "Private options for pipe" "SECID142"
24778 .cindex "options" "&(pipe)& transport"
24779
24780
24781
24782 .option allow_commands pipe "string list&!!" unset
24783 .cindex "&(pipe)& transport" "permitted commands"
24784 The string is expanded, and is then interpreted as a colon-separated list of
24785 permitted commands. If &%restrict_to_path%& is not set, the only commands
24786 permitted are those in the &%allow_commands%& list. They need not be absolute
24787 paths; the &%path%& option is still used for relative paths. If
24788 &%restrict_to_path%& is set with &%allow_commands%&, the command must either be
24789 in the &%allow_commands%& list, or a name without any slashes that is found on
24790 the path. In other words, if neither &%allow_commands%& nor
24791 &%restrict_to_path%& is set, there is no restriction on the command, but
24792 otherwise only commands that are permitted by one or the other are allowed. For
24793 example, if
24794 .code
24795 allow_commands = /usr/bin/vacation
24796 .endd
24797 and &%restrict_to_path%& is not set, the only permitted command is
24798 &_/usr/bin/vacation_&. The &%allow_commands%& option may not be set if
24799 &%use_shell%& is set.
24800
24801
24802 .option batch_id pipe string&!! unset
24803 See the description of local delivery batching in chapter &<<CHAPbatching>>&.
24804
24805
24806 .option batch_max pipe integer 1
24807 This limits the number of addresses that can be handled in a single delivery.
24808 See the description of local delivery batching in chapter &<<CHAPbatching>>&.
24809
24810
24811 .option check_string pipe string unset
24812 As &(pipe)& writes the message, the start of each line is tested for matching
24813 &%check_string%&, and if it does, the initial matching characters are replaced
24814 by the contents of &%escape_string%&, provided both are set. The value of
24815 &%check_string%& is a literal string, not a regular expression, and the case of
24816 any letters it contains is significant. When &%use_bsmtp%& is set, the contents
24817 of &%check_string%& and &%escape_string%& are forced to values that implement
24818 the SMTP escaping protocol. Any settings made in the configuration file are
24819 ignored.
24820
24821
24822 .option command pipe string&!! unset
24823 This option need not be set when &(pipe)& is being used to deliver to pipes
24824 obtained directly from address redirections. In other cases, the option must be
24825 set, to provide a command to be run. It need not yield an absolute path (see
24826 the &%path%& option below). The command is split up into separate arguments by
24827 Exim, and each argument is separately expanded, as described in section
24828 &<<SECThowcommandrun>>& above.
24829
24830 .cindex "tainted data"
24831 No part of the resulting command may be tainted.
24832
24833
24834 .option environment pipe "string list&!!" unset
24835 .cindex "&(pipe)& transport" "environment for command"
24836 .cindex "environment" "&(pipe)& transport"
24837 This option is used to add additional variables to the environment in which the
24838 command runs (see section &<<SECTpipeenv>>& for the default list). Its value is
24839 a string which is expanded, and then interpreted as a colon-separated list of
24840 environment settings of the form <&'name'&>=<&'value'&>.
24841
24842
24843 .option escape_string pipe string unset
24844 See &%check_string%& above.
24845
24846
24847 .option freeze_exec_fail pipe boolean false
24848 .cindex "exec failure"
24849 .cindex "failure of exec"
24850 .cindex "&(pipe)& transport" "failure of exec"
24851 Failure to exec the command in a pipe transport is by default treated like
24852 any other failure while running the command. However, if &%freeze_exec_fail%&
24853 is set, failure to exec is treated specially, and causes the message to be
24854 frozen, whatever the setting of &%ignore_status%&.
24855
24856
24857 .option freeze_signal pipe boolean false
24858 .cindex "signal exit"
24859 .cindex "&(pipe)& transport", "signal exit"
24860 Normally if the process run by a command in a pipe transport exits on a signal,
24861 a bounce message is sent. If &%freeze_signal%& is set, the message will be
24862 frozen in Exim's queue instead.
24863
24864
24865 .option force_command pipe boolean false
24866 .cindex "force command"
24867 .cindex "&(pipe)& transport", "force command"
24868 Normally when a router redirects an address directly to a pipe command
24869 the &%command%& option on the transport is ignored.  If &%force_command%&
24870 is set, the &%command%& option will used. This is especially
24871 useful for forcing a wrapper or additional argument to be added to the
24872 command. For example:
24873 .code
24874 command = /usr/bin/remote_exec myhost -- $address_pipe
24875 force_command
24876 .endd
24877
24878 Note that &$address_pipe$& is handled specially in &%command%& when
24879 &%force_command%& is set, expanding out to the original argument vector as
24880 separate items, similarly to a Unix shell &`"$@"`& construct.
24881
24882
24883 .option ignore_status pipe boolean false
24884 If this option is true, the status returned by the subprocess that is set up to
24885 run the command is ignored, and Exim behaves as if zero had been returned.
24886 Otherwise, a non-zero status or termination by signal causes an error return
24887 from the transport unless the status value is one of those listed in
24888 &%temp_errors%&; these cause the delivery to be deferred and tried again later.
24889
24890 &*Note*&: This option does not apply to timeouts, which do not return a status.
24891 See the &%timeout_defer%& option for how timeouts are handled.
24892
24893
24894 .option log_defer_output pipe boolean false
24895 .cindex "&(pipe)& transport" "logging output"
24896 If this option is set, and the status returned by the command is
24897 one of the codes listed in &%temp_errors%& (that is, delivery was deferred),
24898 and any output was produced on stdout or stderr, the first line of it is
24899 written to the main log.
24900
24901
24902 .option log_fail_output pipe boolean false
24903 If this option is set, and the command returns any output on stdout or
24904 stderr, and also ends with a return code that is neither zero nor one of
24905 the return codes listed in &%temp_errors%& (that is, the delivery
24906 failed), the first line of output is written to the main log. This
24907 option and &%log_output%& are mutually exclusive.  Only one of them may
24908 be set.
24909
24910
24911 .option log_output pipe boolean false
24912 If this option is set and the command returns any output on stdout or
24913 stderr, the first line of output is written to the main log, whatever
24914 the return code. This option and &%log_fail_output%& are mutually
24915 exclusive. Only one of them may be set.
24916
24917
24918 .option max_output pipe integer 20K
24919 This specifies the maximum amount of output that the command may produce on its
24920 standard output and standard error file combined. If the limit is exceeded, the
24921 process running the command is killed. This is intended as a safety measure to
24922 catch runaway processes. The limit is applied independently of the settings of
24923 the options that control what is done with such output (for example,
24924 &%return_output%&). Because of buffering effects, the amount of output may
24925 exceed the limit by a small amount before Exim notices.
24926
24927
24928 .option message_prefix pipe string&!! "see below"
24929 The string specified here is expanded and output at the start of every message.
24930 The default is unset if &%use_bsmtp%& is set. Otherwise it is
24931 .code
24932 message_prefix = \
24933   From ${if def:return_path{$return_path}{MAILER-DAEMON}}\
24934   ${tod_bsdinbox}\n
24935 .endd
24936 .cindex "Cyrus"
24937 .cindex "&%tmail%&"
24938 .cindex "&""From""& line"
24939 This is required by the commonly used &_/usr/bin/vacation_& program.
24940 However, it must &'not'& be present if delivery is to the Cyrus IMAP server,
24941 or to the &%tmail%& local delivery agent. The prefix can be suppressed by
24942 setting
24943 .code
24944 message_prefix =
24945 .endd
24946 &*Note:*& If you set &%use_crlf%& true, you must change any occurrences of
24947 &`\n`& to &`\r\n`& in &%message_prefix%&.
24948
24949
24950 .option message_suffix pipe string&!! "see below"
24951 The string specified here is expanded and output at the end of every message.
24952 The default is unset if &%use_bsmtp%& is set. Otherwise it is a single newline.
24953 The suffix can be suppressed by setting
24954 .code
24955 message_suffix =
24956 .endd
24957 &*Note:*& If you set &%use_crlf%& true, you must change any occurrences of
24958 &`\n`& to &`\r\n`& in &%message_suffix%&.
24959
24960
24961 .option path pipe string&!! "/bin:/usr/bin"
24962 This option is expanded and
24963 specifies the string that is set up in the PATH environment
24964 variable of the subprocess.
24965 If the &%command%& option does not yield an absolute path name, the command is
24966 sought in the PATH directories, in the usual way. &*Warning*&: This does not
24967 apply to a command specified as a transport filter.
24968
24969
24970 .option permit_coredump pipe boolean false
24971 Normally Exim inhibits core-dumps during delivery.  If you have a need to get
24972 a core-dump of a pipe command, enable this command.  This enables core-dumps
24973 during delivery and affects both the Exim binary and the pipe command run.
24974 It is recommended that this option remain off unless and until you have a need
24975 for it and that this only be enabled when needed, as the risk of excessive
24976 resource consumption can be quite high.  Note also that Exim is typically
24977 installed as a setuid binary and most operating systems will inhibit coredumps
24978 of these by default, so further OS-specific action may be required.
24979
24980
24981 .option pipe_as_creator pipe boolean false
24982 .cindex "uid (user id)" "local delivery"
24983 If the generic &%user%& option is not set and this option is true, the delivery
24984 process is run under the uid that was in force when Exim was originally called
24985 to accept the message. If the group id is not otherwise set (via the generic
24986 &%group%& option), the gid that was in force when Exim was originally called to
24987 accept the message is used.
24988
24989
24990 .option restrict_to_path pipe boolean false
24991 When this option is set, any command name not listed in &%allow_commands%& must
24992 contain no slashes. The command is searched for only in the directories listed
24993 in the &%path%& option. This option is intended for use in the case when a pipe
24994 command has been generated from a user's &_.forward_& file. This is usually
24995 handled by a &(pipe)& transport called &%address_pipe%&.
24996
24997
24998 .option return_fail_output pipe boolean false
24999 If this option is true, and the command produced any output and ended with a
25000 return code other than zero or one of the codes listed in &%temp_errors%& (that
25001 is, the delivery failed), the output is returned in the bounce message.
25002 However, if the message has a null sender (that is, it is itself a bounce
25003 message), output from the command is discarded. This option and
25004 &%return_output%& are mutually exclusive. Only one of them may be set.
25005
25006
25007
25008 .option return_output pipe boolean false
25009 If this option is true, and the command produced any output, the delivery is
25010 deemed to have failed whatever the return code from the command, and the output
25011 is returned in the bounce message. Otherwise, the output is just discarded.
25012 However, if the message has a null sender (that is, it is a bounce message),
25013 output from the command is always discarded, whatever the setting of this
25014 option. This option and &%return_fail_output%& are mutually exclusive. Only one
25015 of them may be set.
25016
25017
25018
25019 .option temp_errors pipe "string list" "see below"
25020 .cindex "&(pipe)& transport" "temporary failure"
25021 This option contains either a colon-separated list of numbers, or a single
25022 asterisk. If &%ignore_status%& is false
25023 and &%return_output%& is not set,
25024 and the command exits with a non-zero return code, the failure is treated as
25025 temporary and the delivery is deferred if the return code matches one of the
25026 numbers, or if the setting is a single asterisk. Otherwise, non-zero return
25027 codes are treated as permanent errors. The default setting contains the codes
25028 defined by EX_TEMPFAIL and EX_CANTCREAT in &_sysexits.h_&. If Exim is
25029 compiled on a system that does not define these macros, it assumes values of 75
25030 and 73, respectively.
25031
25032
25033 .option timeout pipe time 1h
25034 If the command fails to complete within this time, it is killed. This normally
25035 causes the delivery to fail (but see &%timeout_defer%&). A zero time interval
25036 specifies no timeout. In order to ensure that any subprocesses created by the
25037 command are also killed, Exim makes the initial process a process group leader,
25038 and kills the whole process group on a timeout. However, this can be defeated
25039 if one of the processes starts a new process group.
25040
25041 .option timeout_defer pipe boolean false
25042 A timeout in a &(pipe)& transport, either in the command that the transport
25043 runs, or in a transport filter that is associated with it, is by default
25044 treated as a hard error, and the delivery fails. However, if &%timeout_defer%&
25045 is set true, both kinds of timeout become temporary errors, causing the
25046 delivery to be deferred.
25047
25048 .option umask pipe "octal integer" 022
25049 This specifies the umask setting for the subprocess that runs the command.
25050
25051
25052 .option use_bsmtp pipe boolean false
25053 .cindex "envelope sender"
25054 If this option is set true, the &(pipe)& transport writes messages in &"batch
25055 SMTP"& format, with the envelope sender and recipient(s) included as SMTP
25056 commands. If you want to include a leading HELO command with such messages,
25057 you can do so by setting the &%message_prefix%& option. See section
25058 &<<SECTbatchSMTP>>& for details of batch SMTP.
25059
25060 .option use_classresources pipe boolean false
25061 .cindex "class resources (BSD)"
25062 This option is available only when Exim is running on FreeBSD, NetBSD, or
25063 BSD/OS. If it is set true, the &[setclassresources()]& function is used to set
25064 resource limits when a &(pipe)& transport is run to perform a delivery. The
25065 limits for the uid under which the pipe is to run are obtained from the login
25066 class database.
25067
25068
25069 .option use_crlf pipe boolean false
25070 .cindex "carriage return"
25071 .cindex "linefeed"
25072 This option causes lines to be terminated with the two-character CRLF sequence
25073 (carriage return, linefeed) instead of just a linefeed character. In the case
25074 of batched SMTP, the byte sequence written to the pipe is then an exact image
25075 of what would be sent down a real SMTP connection.
25076
25077 The contents of the &%message_prefix%& and &%message_suffix%& options are
25078 written verbatim, so must contain their own carriage return characters if these
25079 are needed. When &%use_bsmtp%& is not set, the default values for both
25080 &%message_prefix%& and &%message_suffix%& end with a single linefeed, so their
25081 values must be changed to end with &`\r\n`& if &%use_crlf%& is set.
25082
25083
25084 .option use_shell pipe boolean false
25085 .vindex "&$pipe_addresses$&"
25086 If this option is set, it causes the command to be passed to &_/bin/sh_&
25087 instead of being run directly from the transport, as described in section
25088 &<<SECThowcommandrun>>&. This is less secure, but is needed in some situations
25089 where the command is expected to be run under a shell and cannot easily be
25090 modified. The &%allow_commands%& and &%restrict_to_path%& options, and the
25091 &`$pipe_addresses`& facility are incompatible with &%use_shell%&. The
25092 command is expanded as a single string, and handed to &_/bin/sh_& as data for
25093 its &%-c%& option.
25094
25095
25096
25097 .section "Using an external local delivery agent" "SECID143"
25098 .cindex "local delivery" "using an external agent"
25099 .cindex "&'procmail'&"
25100 .cindex "external local delivery"
25101 .cindex "delivery" "&'procmail'&"
25102 .cindex "delivery" "by external agent"
25103 The &(pipe)& transport can be used to pass all messages that require local
25104 delivery to a separate local delivery agent such as &%procmail%&. When doing
25105 this, care must be taken to ensure that the pipe is run under an appropriate
25106 uid and gid. In some configurations one wants this to be a uid that is trusted
25107 by the delivery agent to supply the correct sender of the message. It may be
25108 necessary to recompile or reconfigure the delivery agent so that it trusts an
25109 appropriate user. The following is an example transport and router
25110 configuration for &%procmail%&:
25111 .code
25112 # transport
25113 procmail_pipe:
25114   driver = pipe
25115   command = /usr/local/bin/procmail -d $local_part_data
25116   return_path_add
25117   delivery_date_add
25118   envelope_to_add
25119   check_string = "From "
25120   escape_string = ">From "
25121   umask = 077
25122   user = $local_part_data
25123   group = mail
25124
25125 # router
25126 procmail:
25127   driver = accept
25128   check_local_user
25129   transport = procmail_pipe
25130 .endd
25131 In this example, the pipe is run as the local user, but with the group set to
25132 &'mail'&. An alternative is to run the pipe as a specific user such as &'mail'&
25133 or &'exim'&, but in this case you must arrange for &%procmail%& to trust that
25134 user to supply a correct sender address. If you do not specify either a
25135 &%group%& or a &%user%& option, the pipe command is run as the local user. The
25136 home directory is the user's home directory by default.
25137
25138 &*Note*&: The command that the pipe transport runs does &'not'& begin with
25139 .code
25140 IFS=" "
25141 .endd
25142 as shown in some &%procmail%& documentation, because Exim does not by default
25143 use a shell to run pipe commands.
25144
25145 .cindex "Cyrus"
25146 The next example shows a transport and a router for a system where local
25147 deliveries are handled by the Cyrus IMAP server.
25148 . Used to have R: local_part_suffix = .* +  T:   -m $local_part_suffix_v
25149 . but that suffix is tainted so cannot be used in a command arg
25150 . Really, you'd want to use a lookup for acceptable suffixes to do real detainting
25151 .code
25152 # transport
25153 local_delivery_cyrus:
25154   driver = pipe
25155   command = /usr/cyrus/bin/deliver \
25156             -- $local_part_data
25157   user = cyrus
25158   group = mail
25159   return_output
25160   log_output
25161   message_prefix =
25162   message_suffix =
25163
25164 # router
25165 local_user_cyrus:
25166   driver = accept
25167   check_local_user
25168   transport = local_delivery_cyrus
25169 .endd
25170 Note the unsetting of &%message_prefix%& and &%message_suffix%&, and the use of
25171 &%return_output%& to cause any text written by Cyrus to be returned to the
25172 sender.
25173 .ecindex IIDpiptra1
25174 .ecindex IIDpiptra2
25175
25176
25177 . ////////////////////////////////////////////////////////////////////////////
25178 . ////////////////////////////////////////////////////////////////////////////
25179
25180 .chapter "The smtp transport" "CHAPsmtptrans"
25181 .scindex IIDsmttra1 "transports" "&(smtp)&"
25182 .scindex IIDsmttra2 "&(smtp)& transport"
25183 The &(smtp)& transport delivers messages over TCP/IP connections using the SMTP
25184 or LMTP protocol. The list of hosts to try can either be taken from the address
25185 that is being processed (having been set up by the router), or specified
25186 explicitly for the transport. Timeout and retry processing (see chapter
25187 &<<CHAPretry>>&) is applied to each IP address independently.
25188
25189
25190 .section "Multiple messages on a single connection" "SECID144"
25191 The sending of multiple messages over a single TCP/IP connection can arise in
25192 two ways:
25193
25194 .ilist
25195 If a message contains more than &%max_rcpt%& (see below) addresses that are
25196 routed to the same host, more than one copy of the message has to be sent to
25197 that host. In this situation, multiple copies may be sent in a single run of
25198 the &(smtp)& transport over a single TCP/IP connection. (What Exim actually
25199 does when it has too many addresses to send in one message also depends on the
25200 value of the global &%remote_max_parallel%& option. Details are given in
25201 section &<<SECToutSMTPTCP>>&.)
25202 .next
25203 .cindex "hints database" "remembering routing"
25204 When a message has been successfully delivered over a TCP/IP connection, Exim
25205 looks in its hints database to see if there are any other messages awaiting a
25206 connection to the same host. If there are, a new delivery process is started
25207 for one of them, and the current TCP/IP connection is passed on to it. The new
25208 process may in turn send multiple copies and possibly create yet another
25209 process.
25210 .endlist
25211
25212
25213 For each copy sent over the same TCP/IP connection, a sequence counter is
25214 incremented, and if it ever gets to the value of &%connection_max_messages%&,
25215 no further messages are sent over that connection.
25216
25217
25218
25219 .section "Use of the $host and $host_address variables" "SECID145"
25220 .vindex "&$host$&"
25221 .vindex "&$host_address$&"
25222 At the start of a run of the &(smtp)& transport, the values of &$host$& and
25223 &$host_address$& are the name and IP address of the first host on the host list
25224 passed by the router. However, when the transport is about to connect to a
25225 specific host, and while it is connected to that host, &$host$& and
25226 &$host_address$& are set to the values for that host. These are the values
25227 that are in force when the &%helo_data%&, &%hosts_try_auth%&, &%interface%&,
25228 &%serialize_hosts%&, and the various TLS options are expanded.
25229
25230
25231 .section "Use of $tls_cipher and $tls_peerdn" "usecippeer"
25232 .vindex &$tls_bits$&
25233 .vindex &$tls_cipher$&
25234 .vindex &$tls_peerdn$&
25235 .vindex &$tls_sni$&
25236 At the start of a run of the &(smtp)& transport, the values of &$tls_bits$&,
25237 &$tls_cipher$&, &$tls_peerdn$& and &$tls_sni$&
25238 are the values that were set when the message was received.
25239 These are the values that are used for options that are expanded before any
25240 SMTP connections are made. Just before each connection is made, these four
25241 variables are emptied. If TLS is subsequently started, they are set to the
25242 appropriate values for the outgoing connection, and these are the values that
25243 are in force when any authenticators are run and when the
25244 &%authenticated_sender%& option is expanded.
25245
25246 These variables are deprecated in favour of &$tls_in_cipher$& et. al.
25247 and will be removed in a future release.
25248
25249
25250 .section "Private options for smtp" "SECID146"
25251 .cindex "options" "&(smtp)& transport"
25252 The private options of the &(smtp)& transport are as follows:
25253
25254
25255 .option address_retry_include_sender smtp boolean true
25256 .cindex "4&'xx'& responses" "retrying after"
25257 When an address is delayed because of a 4&'xx'& response to a RCPT command, it
25258 is the combination of sender and recipient that is delayed in subsequent queue
25259 runs until the retry time is reached. You can delay the recipient without
25260 reference to the sender (which is what earlier versions of Exim did), by
25261 setting &%address_retry_include_sender%& false. However, this can lead to
25262 problems with servers that regularly issue 4&'xx'& responses to RCPT commands.
25263
25264 .option allow_localhost smtp boolean false
25265 .cindex "local host" "sending to"
25266 .cindex "fallback" "hosts specified on transport"
25267 When a host specified in &%hosts%& or &%fallback_hosts%& (see below) turns out
25268 to be the local host, or is listed in &%hosts_treat_as_local%&, delivery is
25269 deferred by default. However, if &%allow_localhost%& is set, Exim goes on to do
25270 the delivery anyway. This should be used only in special cases when the
25271 configuration ensures that no looping will result (for example, a differently
25272 configured Exim is listening on the port to which the message is sent).
25273
25274
25275 .option authenticated_sender smtp string&!! unset
25276 .cindex "Cyrus"
25277 When Exim has authenticated as a client, or if &%authenticated_sender_force%&
25278 is true, this option sets a value for the AUTH= item on outgoing MAIL commands,
25279 overriding any existing authenticated sender value. If the string expansion is
25280 forced to fail, the option is ignored. Other expansion failures cause delivery
25281 to be deferred. If the result of expansion is an empty string, that is also
25282 ignored.
25283
25284 The expansion happens after the outgoing connection has been made and TLS
25285 started, if required. This means that the &$host$&, &$host_address$&,
25286 &$tls_out_cipher$&, and &$tls_out_peerdn$& variables are set according to the
25287 particular connection.
25288
25289 If the SMTP session is not authenticated, the expansion of
25290 &%authenticated_sender%& still happens (and can cause the delivery to be
25291 deferred if it fails), but no AUTH= item is added to MAIL commands
25292 unless &%authenticated_sender_force%& is true.
25293
25294 This option allows you to use the &(smtp)& transport in LMTP mode to
25295 deliver mail to Cyrus IMAP and provide the proper local part as the
25296 &"authenticated sender"&, via a setting such as:
25297 .code
25298 authenticated_sender = $local_part
25299 .endd
25300 This removes the need for IMAP subfolders to be assigned special ACLs to
25301 allow direct delivery to those subfolders.
25302
25303 Because of expected uses such as that just described for Cyrus (when no
25304 domain is involved), there is no checking on the syntax of the provided
25305 value.
25306
25307
25308 .option authenticated_sender_force smtp boolean false
25309 If this option is set true, the &%authenticated_sender%& option's value
25310 is used for the AUTH= item on outgoing MAIL commands, even if Exim has not
25311 authenticated as a client.
25312
25313
25314 .option command_timeout smtp time 5m
25315 .cindex timeout "smtp transport command"
25316 This sets a timeout for receiving a response to an SMTP command that has been
25317 sent out. It is also used when waiting for the initial banner line from the
25318 remote host. Its value must not be zero.
25319
25320
25321 .option connect_timeout smtp time 5m
25322 .cindex timeout "smtp transport connect"
25323 This sets a timeout for the &[connect()]& function, which sets up a TCP/IP call
25324 to a remote host. A setting of zero allows the system timeout (typically
25325 several minutes) to act. To have any effect, the value of this option must be
25326 less than the system timeout. However, it has been observed that on some
25327 systems there is no system timeout, which is why the default value for this
25328 option is 5 minutes, a value recommended by RFC 1123.
25329
25330
25331 .option connection_max_messages smtp integer 500
25332 .cindex "SMTP" "passed connection"
25333 .cindex "SMTP" "multiple deliveries"
25334 .cindex "multiple SMTP deliveries"
25335 This controls the maximum number of separate message deliveries that are sent
25336 over a single TCP/IP connection. If the value is zero, there is no limit.
25337 For testing purposes, this value can be overridden by the &%-oB%& command line
25338 option.
25339
25340
25341 .option dane_require_tls_ciphers smtp string&!! unset
25342 .cindex "TLS" "requiring specific ciphers for DANE"
25343 .cindex "cipher" "requiring specific"
25344 .cindex DANE "TLS ciphers"
25345 This option may be used to override &%tls_require_ciphers%& for connections
25346 where DANE has been determined to be in effect.
25347 If not set, then &%tls_require_ciphers%& will be used.
25348 Normal SMTP delivery is not able to make strong demands of TLS cipher
25349 configuration, because delivery will fall back to plaintext.  Once DANE has
25350 been determined to be in effect, there is no plaintext fallback and making the
25351 TLS cipherlist configuration stronger will increase security, rather than
25352 counter-intuitively decreasing it.
25353 If the option expands to be empty or is forced to fail, then it will
25354 be treated as unset and &%tls_require_ciphers%& will be used instead.
25355
25356
25357 .option data_timeout smtp time 5m
25358 .cindex timeout "for transmitted SMTP data blocks"
25359 This sets a timeout for the transmission of each block in the data portion of
25360 the message. As a result, the overall timeout for a message depends on the size
25361 of the message. Its value must not be zero. See also &%final_timeout%&.
25362
25363
25364 .option dkim_canon smtp string&!! unset
25365 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25366 .option dkim_domain smtp "string list&!!" unset
25367 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25368 .option dkim_hash smtp string&!! sha256
25369 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25370 .option dkim_identity smtp string&!! unset
25371 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25372 .option dkim_private_key smtp string&!! unset
25373 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25374 .option dkim_selector smtp string&!! unset
25375 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25376 .option dkim_strict smtp string&!! unset
25377 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25378 .option dkim_sign_headers smtp string&!! "per RFC"
25379 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25380 .option dkim_timestamps smtp string&!! unset
25381 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25382
25383
25384 .option delay_after_cutoff smtp boolean true
25385 .cindex "final cutoff" "retries, controlling"
25386 .cindex retry "final cutoff"
25387 This option controls what happens when all remote IP addresses for a given
25388 domain have been inaccessible for so long that they have passed their retry
25389 cutoff times.
25390
25391 In the default state, if the next retry time has not been reached for any of
25392 them, the address is bounced without trying any deliveries. In other words,
25393 Exim delays retrying an IP address after the final cutoff time until a new
25394 retry time is reached, and can therefore bounce an address without ever trying
25395 a delivery, when machines have been down for a long time. Some people are
25396 unhappy at this prospect, so...
25397
25398 If &%delay_after_cutoff%& is set false, Exim behaves differently. If all IP
25399 addresses are past their final cutoff time, Exim tries to deliver to those
25400 IP addresses that have not been tried since the message arrived. If there are
25401 none, of if they all fail, the address is bounced. In other words, it does not
25402 delay when a new message arrives, but immediately tries those expired IP
25403 addresses that haven't been tried since the message arrived. If there is a
25404 continuous stream of messages for the dead hosts, unsetting
25405 &%delay_after_cutoff%& means that there will be many more attempts to deliver
25406 to them.
25407
25408
25409 .option dns_qualify_single smtp boolean true
25410 If the &%hosts%& or &%fallback_hosts%& option is being used,
25411 and the &%gethostbyname%& option is false,
25412 the RES_DEFNAMES resolver option is set. See the &%qualify_single%& option
25413 in chapter &<<CHAPdnslookup>>& for more details.
25414
25415
25416 .option dns_search_parents smtp boolean false
25417 If the &%hosts%& or &%fallback_hosts%& option is being used, and the
25418 &%gethostbyname%& option is false, the RES_DNSRCH resolver option is set.
25419 See the &%search_parents%& option in chapter &<<CHAPdnslookup>>& for more
25420 details.
25421
25422
25423 .option dnssec_request_domains smtp "domain list&!!" *
25424 .cindex "MX record" "security"
25425 .cindex "DNSSEC" "MX lookup"
25426 .cindex "security" "MX lookup"
25427 .cindex "DNS" "DNSSEC"
25428 DNS lookups for domains matching &%dnssec_request_domains%& will be done with
25429 the DNSSEC request bit set. Setting this transport option is only useful if the
25430 transport overrides or sets the host names. See the &%dnssec_request_domains%&
25431 router option.
25432
25433
25434
25435 .option dnssec_require_domains smtp "domain list&!!" unset
25436 .cindex "MX record" "security"
25437 .cindex "DNSSEC" "MX lookup"
25438 .cindex "security" "MX lookup"
25439 .cindex "DNS" "DNSSEC"
25440 DNS lookups for domains matching &%dnssec_require_domains%& will be done with
25441 the DNSSEC request bit set.  Setting this transport option is only
25442 useful if the transport overrides or sets the host names. See the
25443 &%dnssec_require_domains%& router option.
25444
25445
25446
25447 .option dscp smtp string&!! unset
25448 .cindex "DCSP" "outbound"
25449 This option causes the DSCP value associated with a socket to be set to one
25450 of a number of fixed strings or to numeric value.
25451 The &%-bI:dscp%& option may be used to ask Exim which names it knows of.
25452 Common values include &`throughput`&, &`mincost`&, and on newer systems
25453 &`ef`&, &`af41`&, etc.  Numeric values may be in the range 0 to 0x3F.
25454
25455 The outbound packets from Exim will be marked with this value in the header
25456 (for IPv4, the TOS field; for IPv6, the TCLASS field); there is no guarantee
25457 that these values will have any effect, not be stripped by networking
25458 equipment, or do much of anything without cooperation with your Network
25459 Engineer and those of all network operators between the source and destination.
25460
25461
25462 .option fallback_hosts smtp "string list" unset
25463 .cindex "fallback" "hosts specified on transport"
25464 String expansion is not applied to this option. The argument must be a
25465 colon-separated list of host names or IP addresses, optionally also including
25466 port numbers, though the separator can be changed, as described in section
25467 &<<SECTlistconstruct>>&. Each individual item in the list is the same as an
25468 item in a &%route_list%& setting for the &(manualroute)& router, as described
25469 in section &<<SECTformatonehostitem>>&.
25470
25471 Fallback hosts can also be specified on routers, which associate them with the
25472 addresses they process. As for the &%hosts%& option without &%hosts_override%&,
25473 &%fallback_hosts%& specified on the transport is used only if the address does
25474 not have its own associated fallback host list. Unlike &%hosts%&, a setting of
25475 &%fallback_hosts%& on an address is not overridden by &%hosts_override%&.
25476 However, &%hosts_randomize%& does apply to fallback host lists.
25477
25478 If Exim is unable to deliver to any of the hosts for a particular address, and
25479 the errors are not permanent rejections, the address is put on a separate
25480 transport queue with its host list replaced by the fallback hosts, unless the
25481 address was routed via MX records and the current host was in the original MX
25482 list. In that situation, the fallback host list is not used.
25483
25484 Once normal deliveries are complete, the fallback queue is delivered by
25485 re-running the same transports with the new host lists. If several failing
25486 addresses have the same fallback hosts (and &%max_rcpt%& permits it), a single
25487 copy of the message is sent.
25488
25489 The resolution of the host names on the fallback list is controlled by the
25490 &%gethostbyname%& option, as for the &%hosts%& option. Fallback hosts apply
25491 both to cases when the host list comes with the address and when it is taken
25492 from &%hosts%&. This option provides a &"use a smart host only if delivery
25493 fails"& facility.
25494
25495
25496 .option final_timeout smtp time 10m
25497 .cindex timeout "for transmitted SMTP data accept"
25498 This is the timeout that applies while waiting for the response to the final
25499 line containing just &"."& that terminates a message. Its value must not be
25500 zero.
25501
25502 .option gethostbyname smtp boolean false
25503 If this option is true when the &%hosts%& and/or &%fallback_hosts%& options are
25504 being used, names are looked up using &[gethostbyname()]&
25505 (or &[getipnodebyname()]& when available)
25506 instead of using the DNS. Of course, that function may in fact use the DNS, but
25507 it may also consult other sources of information such as &_/etc/hosts_&.
25508
25509 .option gnutls_compat_mode smtp boolean unset
25510 This option controls whether GnuTLS is used in compatibility mode in an Exim
25511 server. This reduces security slightly, but improves interworking with older
25512 implementations of TLS.
25513
25514 .option helo_data smtp string&!! "see below"
25515 .cindex "HELO" "argument, setting"
25516 .cindex "EHLO" "argument, setting"
25517 .cindex "LHLO argument setting"
25518 The value of this option is expanded after a connection to a another host has
25519 been set up. The result is used as the argument for the EHLO, HELO, or LHLO
25520 command that starts the outgoing SMTP or LMTP session. The default value of the
25521 option is:
25522 .code
25523 $primary_hostname
25524 .endd
25525 During the expansion, the variables &$host$& and &$host_address$& are set to
25526 the identity of the remote host, and the variables &$sending_ip_address$& and
25527 &$sending_port$& are set to the local IP address and port number that are being
25528 used. These variables can be used to generate different values for different
25529 servers or different local IP addresses. For example, if you want the string
25530 that is used for &%helo_data%& to be obtained by a DNS lookup of the outgoing
25531 interface address, you could use this:
25532 .code
25533 helo_data = ${lookup dnsdb{ptr=$sending_ip_address} \
25534   {${listextract{1}{<\n $value}}} \
25535   {$primary_hostname}}
25536 .endd
25537 The use of &%helo_data%& applies both to sending messages and when doing
25538 callouts.
25539
25540 .option host_name_extract smtp "string list&!!" "see below"
25541 .cindex "load balancer" "hosts behind"
25542 .cindex TLS resumption
25543 Some mail-accepting sites
25544 (notably Microsoft)
25545 operate many servers behind a network load-balancer.  When this is done,
25546 with separated TLS session caches, TLS session resuption becomes problematic.
25547 It will only succeed when the same server happens to be selected by the
25548 load-balancer, matching the session stored in the client's cache.
25549
25550 Exim can pull out a server name, if there is one, from the response to the
25551 client's SMTP EHLO command.
25552 For normal STARTTLS use, the default value of this option:
25553 .code
25554     ${if and { {match {$host} {.outlook.com\$}} \
25555                {match {$item} {\N^250-([\w.]+)\s\N}} \
25556              } {$1}}
25557 .endd
25558 suffices for one known case.
25559
25560 During the expansion of this option the &$item$& variable will have the
25561 server's EHLO response.
25562
25563 .new
25564 For TLS-on-connect connections we do not have an EHLO
25565 response to use. Because of this the default value of this option is
25566 set to a static string for those cases, meaning that resumption will
25567 always be attempted if permitted by the &%tls_resumption_hosts%& option.
25568 .wen
25569
25570 The result of the option expansion is included in the key used to store and
25571 retrieve the TLS session, for session resumption.
25572
25573 Operators of high-load sites may wish to evaluate their logs for indications
25574 of other destination sites operating load-balancers, and develop a suitable
25575 expression for this option.
25576 The smtp:ehlo event and the &$tls_out_resumption$& variable
25577 will be useful for such work.
25578
25579 .option hosts smtp "string list&!!" unset
25580 Hosts are associated with an address by a router such as &(dnslookup)&, which
25581 finds the hosts by looking up the address domain in the DNS, or by
25582 &(manualroute)&, which has lists of hosts in its configuration. However,
25583 email addresses can be passed to the &(smtp)& transport by any router, and not
25584 all of them can provide an associated list of hosts.
25585
25586 The &%hosts%& option specifies a list of hosts to be used if the address being
25587 processed does not have any hosts associated with it. The hosts specified by
25588 &%hosts%& are also used, whether or not the address has its own hosts, if
25589 &%hosts_override%& is set.
25590
25591 The string is first expanded, before being interpreted as a colon-separated
25592 list of host names or IP addresses, possibly including port numbers. The
25593 separator may be changed to something other than colon, as described in section
25594 &<<SECTlistconstruct>>&. Each individual item in the list is the same as an
25595 item in a &%route_list%& setting for the &(manualroute)& router, as described
25596 in section &<<SECTformatonehostitem>>&. However, note that the &`/MX`& facility
25597 of the &(manualroute)& router is not available here.
25598
25599 If the expansion fails, delivery is deferred. Unless the failure was caused by
25600 the inability to complete a lookup, the error is logged to the panic log as
25601 well as the main log. Host names are looked up either by searching directly for
25602 address records in the DNS or by calling &[gethostbyname()]& (or
25603 &[getipnodebyname()]& when available), depending on the setting of the
25604 &%gethostbyname%& option. When Exim is compiled with IPv6 support, if a host
25605 that is looked up in the DNS has both IPv4 and IPv6 addresses, both types of
25606 address are used.
25607
25608 During delivery, the hosts are tried in order, subject to their retry status,
25609 unless &%hosts_randomize%& is set.
25610
25611
25612 .option hosts_avoid_esmtp smtp "host list&!!" unset
25613 .cindex "ESMTP, avoiding use of"
25614 .cindex "HELO" "forcing use of"
25615 .cindex "EHLO" "avoiding use of"
25616 .cindex "PIPELINING" "avoiding the use of"
25617 This option is for use with broken hosts that announce ESMTP facilities (for
25618 example, PIPELINING) and then fail to implement them properly. When a host
25619 matches &%hosts_avoid_esmtp%&, Exim sends HELO rather than EHLO at the
25620 start of the SMTP session. This means that it cannot use any of the ESMTP
25621 facilities such as AUTH, PIPELINING, SIZE, and STARTTLS.
25622
25623
25624 .option hosts_avoid_pipelining smtp "host list&!!" unset
25625 .cindex "PIPELINING" "avoiding the use of"
25626 .cindex "ESMTP extensions" PIPELINING
25627 Exim will not use the ESMTP PIPELINING extension when delivering to any host
25628 that matches this list, even if the server host advertises PIPELINING support.
25629
25630 .option hosts_pipe_connect smtp "host list&!!" unset
25631 .cindex "pipelining" "early connection"
25632 .cindex "pipelining" PIPECONNECT
25633 If Exim is built with the SUPPORT_PIPE_CONNECT build option
25634 this option controls which to hosts the facility watched for
25635 and recorded, and used for subsequent connections.
25636
25637 The retry hints database is used for the record,
25638 and records are subject to the &%retry_data_expire%& option.
25639 When used, the pipelining saves on roundtrip times.
25640 It also turns SMTP into a client-first protocol
25641 so combines well with TCP Fast Open.
25642
25643 See also the &%pipelining_connect_advertise_hosts%& main option.
25644
25645 Note:
25646 When the facility is used, if the transport &%interface%& option is unset
25647 the &%helo_data%& option
25648 will be expanded before the &$sending_ip_address$& variable
25649 is filled in.
25650 A check is made for the use of that variable, without the
25651 presence of a &"def:"& test on it, but suitably complex coding
25652 can avoid the check and produce unexpected results.
25653 You have been warned.
25654
25655
25656 .option hosts_avoid_tls smtp "host list&!!" unset
25657 .cindex "TLS" "avoiding for certain hosts"
25658 Exim will not try to start a TLS session when delivering to any host that
25659 matches this list. See chapter &<<CHAPTLS>>& for details of TLS.
25660
25661 .option hosts_verify_avoid_tls smtp "host list&!!" unset
25662 .cindex "TLS" "avoiding for certain hosts"
25663 Exim will not try to start a TLS session for a verify callout,
25664 or when delivering in cutthrough mode,
25665 to any host that matches this list.
25666
25667
25668 .option hosts_max_try smtp integer 5
25669 .cindex "host" "maximum number to try"
25670 .cindex "limit" "number of hosts tried"
25671 .cindex "limit" "number of MX tried"
25672 .cindex "MX record" "maximum tried"
25673 This option limits the number of IP addresses that are tried for any one
25674 delivery in cases where there are temporary delivery errors. Section
25675 &<<SECTvalhosmax>>& describes in detail how the value of this option is used.
25676
25677
25678 .option hosts_max_try_hardlimit smtp integer 50
25679 This is an additional check on the maximum number of IP addresses that Exim
25680 tries for any one delivery. Section &<<SECTvalhosmax>>& describes its use and
25681 why it exists.
25682
25683
25684
25685 .option hosts_nopass_tls smtp "host list&!!" unset
25686 .cindex "TLS" "passing connection"
25687 .cindex "multiple SMTP deliveries"
25688 .cindex "TLS" "multiple message deliveries"
25689 For any host that matches this list, a connection on which a TLS session has
25690 been started will not be passed to a new delivery process for sending another
25691 message on the same connection. See section &<<SECTmulmessam>>& for an
25692 explanation of when this might be needed.
25693
25694 .option hosts_noproxy_tls smtp "host list&!!" unset
25695 .cindex "TLS" "passing connection"
25696 .cindex "multiple SMTP deliveries"
25697 .cindex "TLS" "multiple message deliveries"
25698 For any host that matches this list, a TLS session which has
25699 been started will not be passed to a new delivery process for sending another
25700 message on the same session.
25701
25702 The traditional implementation closes down TLS and re-starts it in the new
25703 process, on the same open TCP connection, for each successive message
25704 sent.  If permitted by this option a pipe to to the new process is set up
25705 instead, and the original process maintains the TLS connection and proxies
25706 the SMTP connection from and to the new process and any subsequents.
25707 The new process has no access to TLS information, so cannot include it in
25708 logging.
25709
25710
25711
25712 .option hosts_override smtp boolean false
25713 If this option is set and the &%hosts%& option is also set, any hosts that are
25714 attached to the address are ignored, and instead the hosts specified by the
25715 &%hosts%& option are always used. This option does not apply to
25716 &%fallback_hosts%&.
25717
25718
25719 .option hosts_randomize smtp boolean false
25720 .cindex "randomized host list"
25721 .cindex "host" "list of; randomized"
25722 .cindex "fallback" "randomized hosts"
25723 If this option is set, and either the list of hosts is taken from the
25724 &%hosts%& or the &%fallback_hosts%& option, or the hosts supplied by the router
25725 were not obtained from MX records (this includes fallback hosts from the
25726 router), and were not randomized by the router, the order of trying the hosts
25727 is randomized each time the transport runs. Randomizing the order of a host
25728 list can be used to do crude load sharing.
25729
25730 When &%hosts_randomize%& is true, a host list may be split into groups whose
25731 order is separately randomized. This makes it possible to set up MX-like
25732 behaviour. The boundaries between groups are indicated by an item that is just
25733 &`+`& in the host list. For example:
25734 .code
25735 hosts = host1:host2:host3:+:host4:host5
25736 .endd
25737 The order of the first three hosts and the order of the last two hosts is
25738 randomized for each use, but the first three always end up before the last two.
25739 If &%hosts_randomize%& is not set, a &`+`& item in the list is ignored.
25740
25741 .option hosts_require_auth smtp "host list&!!" unset
25742 .cindex "authentication" "required by client"
25743 This option provides a list of servers for which authentication must succeed
25744 before Exim will try to transfer a message. If authentication fails for
25745 servers which are not in this list, Exim tries to send unauthenticated. If
25746 authentication fails for one of these servers, delivery is deferred. This
25747 temporary error is detectable in the retry rules, so it can be turned into a
25748 hard failure if required. See also &%hosts_try_auth%&, and chapter
25749 &<<CHAPSMTPAUTH>>& for details of authentication.
25750
25751
25752 .option hosts_request_ocsp smtp "host list&!!" "see below"
25753 .cindex "TLS" "requiring for certain servers"
25754 Exim will request a Certificate Status on a
25755 TLS session for any host that matches this list.
25756 &%tls_verify_certificates%& should also be set for the transport.
25757
25758 The default is &"**"& if DANE is not in use for the connection,
25759 or if DANE-TA us used.
25760 It is empty if DANE-EE is used.
25761
25762 .option hosts_require_alpn smtp "host list&!!" unset
25763 .cindex ALPN "require negotiation in client"
25764 .cindex TLS ALPN
25765 .cindex TLS "Application Layer Protocol Names"
25766 If the TLS library supports ALPN
25767 then a successful negotiation of ALPN will be required for any host
25768 matching the list, for TLS to be used.
25769 See also the &%tls_alpn%& option.
25770
25771 &*Note*&: prevention of fallback to in-clear connection is not
25772 managed by this option; see &%hosts_require_tls%&.
25773
25774 .option hosts_require_dane smtp "host list&!!" unset
25775 .cindex DANE "transport options"
25776 .cindex DANE "requiring for certain servers"
25777 If built with DANE support, Exim  will require that a DNSSEC-validated
25778 TLSA record is present for any host matching the list,
25779 and that a DANE-verified TLS connection is made.
25780 There will be no fallback to in-clear communication.
25781 See the &%dnssec_request_domains%& router and transport options.
25782 See section &<<SECDANE>>&.
25783
25784 .option hosts_require_ocsp smtp "host list&!!" unset
25785 .cindex "TLS" "requiring for certain servers"
25786 Exim will request, and check for a valid Certificate Status being given, on a
25787 TLS session for any host that matches this list.
25788 &%tls_verify_certificates%& should also be set for the transport.
25789
25790 .option hosts_require_tls smtp "host list&!!" unset
25791 .cindex "TLS" "requiring for certain servers"
25792 Exim will insist on using a TLS session when delivering to any host that
25793 matches this list. See chapter &<<CHAPTLS>>& for details of TLS.
25794 &*Note*&: This option affects outgoing mail only. To insist on TLS for
25795 incoming messages, use an appropriate ACL.
25796
25797 .option hosts_try_auth smtp "host list&!!" unset
25798 .cindex "authentication" "optional in client"
25799 This option provides a list of servers to which, provided they announce
25800 authentication support, Exim will attempt to authenticate as a client when it
25801 connects. If authentication fails
25802 and &%hosts_require_auth%& permits,
25803 Exim will try to transfer the message unauthenticated.
25804 See also chapter &<<CHAPSMTPAUTH>>& for details of authentication.
25805
25806 .option hosts_try_chunking smtp "host list&!!" *
25807 .cindex CHUNKING "enabling, in client"
25808 .cindex BDAT "SMTP command"
25809 .cindex "RFC 3030" "CHUNKING"
25810 This option provides a list of servers to which, provided they announce
25811 CHUNKING support, Exim will attempt to use BDAT commands rather than DATA.
25812 Unless DKIM signing is being done,
25813 BDAT will not be used in conjunction with a transport filter.
25814
25815 .option hosts_try_dane smtp "host list&!!" *
25816 .cindex DANE "transport options"
25817 .cindex DANE "attempting for certain servers"
25818 If built with DANE support, Exim  will look up a
25819 TLSA record for any host matching the list,
25820 If one is found and that lookup was DNSSEC-validated,
25821 then Exim requires that a DANE-verified TLS connection is made for that host;
25822 there will be no fallback to in-clear communication.
25823 See the &%dnssec_request_domains%& router and transport options.
25824 See section &<<SECDANE>>&.
25825
25826 .option hosts_try_fastopen smtp "host list&!!" *
25827 .cindex "fast open, TCP" "enabling, in client"
25828 .cindex "TCP Fast Open" "enabling, in client"
25829 .cindex "RFC 7413" "TCP Fast Open"
25830 This option provides a list of servers to which, provided
25831 the facility is supported by this system, Exim will attempt to
25832 perform a TCP Fast Open.
25833 No data is sent on the SYN segment but, if the remote server also
25834 supports the facility, it can send its SMTP banner immediately after
25835 the SYN,ACK segment.  This can save up to one round-trip time.
25836
25837 The facility is only active for previously-contacted servers,
25838 as the initiator must present a cookie in the SYN segment.
25839
25840 On (at least some) current Linux distributions the facility must be enabled
25841 in the kernel by the sysadmin before the support is usable.
25842 There is no option for control of the server side; if the system supports
25843 it it is always enabled.  Note that lengthy operations in the connect ACL,
25844 such as DNSBL lookups, will still delay the emission of the SMTP banner.
25845
25846 .option hosts_try_prdr smtp "host list&!!" *
25847 .cindex "PRDR" "enabling, optional in client"
25848 .cindex "ESMTP extensions" PRDR
25849 This option provides a list of servers to which, provided they announce
25850 PRDR support, Exim will attempt to negotiate PRDR
25851 for multi-recipient messages.
25852 The option can usually be left as default.
25853
25854 .option interface smtp "string list&!!" unset
25855 .cindex "bind IP address"
25856 .cindex "IP address" "binding"
25857 .vindex "&$host$&"
25858 .vindex "&$host_address$&"
25859 This option specifies which interface to bind to when making an outgoing SMTP
25860 call. The value is an IP address, not an interface name such as
25861 &`eth0`&. Do not confuse this with the interface address that was used when a
25862 message was received, which is in &$received_ip_address$&, formerly known as
25863 &$interface_address$&. The name was changed to minimize confusion with the
25864 outgoing interface address. There is no variable that contains an outgoing
25865 interface address because, unless it is set by this option, its value is
25866 unknown.
25867
25868 During the expansion of the &%interface%& option the variables &$host$& and
25869 &$host_address$& refer to the host to which a connection is about to be made
25870 during the expansion of the string. Forced expansion failure, or an empty
25871 string result causes the option to be ignored. Otherwise, after expansion, the
25872 string must be a list of IP addresses, colon-separated by default, but the
25873 separator can be changed in the usual way (&<<SECTlistsepchange>>&).
25874 For example:
25875 .code
25876 interface = <; 192.168.123.123 ; 3ffe:ffff:836f::fe86:a061
25877 .endd
25878 The first interface of the correct type (IPv4 or IPv6) is used for the outgoing
25879 connection. If none of them are the correct type, the option is ignored. If
25880 &%interface%& is not set, or is ignored, the system's IP functions choose which
25881 interface to use if the host has more than one.
25882
25883
25884 .option keepalive smtp boolean true
25885 .cindex "keepalive" "on outgoing connection"
25886 This option controls the setting of SO_KEEPALIVE on outgoing TCP/IP socket
25887 connections. When set, it causes the kernel to probe idle connections
25888 periodically, by sending packets with &"old"& sequence numbers. The other end
25889 of the connection should send a acknowledgment if the connection is still okay
25890 or a reset if the connection has been aborted. The reason for doing this is
25891 that it has the beneficial effect of freeing up certain types of connection
25892 that can get stuck when the remote host is disconnected without tidying up the
25893 TCP/IP call properly. The keepalive mechanism takes several hours to detect
25894 unreachable hosts.
25895
25896
25897 .option lmtp_ignore_quota smtp boolean false
25898 .cindex "LMTP" "ignoring quota errors"
25899 If this option is set true when the &%protocol%& option is set to &"lmtp"&, the
25900 string &`IGNOREQUOTA`& is added to RCPT commands, provided that the LMTP server
25901 has advertised support for IGNOREQUOTA in its response to the LHLO command.
25902
25903 .option max_rcpt smtp integer&!! 100
25904 .cindex "RCPT" "maximum number of outgoing"
25905 This option,
25906 after expansion,
25907 limits the number of RCPT commands that are sent in a single
25908 SMTP message transaction.
25909 A value setting of zero disables the limit.
25910
25911 If a constant is given,
25912 each set of addresses is treated independently, and
25913 so can cause parallel connections to the same host if &%remote_max_parallel%&
25914 permits this.
25915
25916
25917 .option message_linelength_limit smtp integer 998
25918 .cindex "line length" limit
25919 This option sets the maximum line length, in bytes, that the transport
25920 will send.  Any messages with lines exceeding the given value
25921 will fail and a failure-DSN ("bounce") message will if possible be returned
25922 to the sender.
25923 The default value is that defined by the SMTP standards.
25924
25925 It is generally wise to also check in the data ACL so that messages
25926 received via SMTP can be refused without producing a bounce.
25927
25928
25929 .option multi_domain smtp boolean&!! true
25930 .vindex "&$domain$&"
25931 When this option is set, the &(smtp)& transport can handle a number of
25932 addresses containing a mixture of different domains provided they all resolve
25933 to the same list of hosts. Turning the option off restricts the transport to
25934 handling only one domain at a time. This is useful if you want to use
25935 &$domain$& in an expansion for the transport, because it is set only when there
25936 is a single domain involved in a remote delivery.
25937
25938 It is expanded per-address and can depend on any of
25939 &$address_data$&, &$domain_data$&, &$local_part_data$&,
25940 &$host$&, &$host_address$& and &$host_port$&.
25941
25942 If the connection is DANE-enabled then this option is ignored;
25943 only messages having the domain used for the DANE TLSA lookup are
25944 sent on the connection.
25945
25946 .option port smtp string&!! "see below"
25947 .cindex "port" "sending TCP/IP"
25948 .cindex "TCP/IP" "setting outgoing port"
25949 This option specifies the TCP/IP port on the server to which Exim connects.
25950 &*Note:*& Do not confuse this with the port that was used when a message was
25951 received, which is in &$received_port$&, formerly known as &$interface_port$&.
25952 The name was changed to minimize confusion with the outgoing port. There is no
25953 variable that contains an outgoing port.
25954
25955 If the value of this option begins with a digit it is taken as a port number;
25956 otherwise it is looked up using &[getservbyname()]&. The default value is
25957 normally &"smtp"&,
25958 but if &%protocol%& is set to &"lmtp"& the default is &"lmtp"&
25959 and if &%protocol%& is set to &"smtps"& the default is &"smtps"&.
25960 If the expansion fails, or if a port number cannot be found, delivery
25961 is deferred.
25962
25963 Note that at least one Linux distribution has been seen failing
25964 to put &"smtps"& in its &"/etc/services"& file, resulting is such deferrals.
25965
25966
25967
25968 .option protocol smtp string smtp
25969 .cindex "LMTP" "over TCP/IP"
25970 .cindex "ssmtp protocol" "outbound"
25971 .cindex "TLS" "SSL-on-connect outbound"
25972 .vindex "&$port$&"
25973 If this option is set to &"lmtp"& instead of &"smtp"&, the default value for
25974 the &%port%& option changes to &"lmtp"&, and the transport operates the LMTP
25975 protocol (RFC 2033) instead of SMTP. This protocol is sometimes used for local
25976 deliveries into closed message stores. Exim also has support for running LMTP
25977 over a pipe to a local process &-- see chapter &<<CHAPLMTP>>&.
25978
25979 If this option is set to &"smtps"&, the default value for the &%port%& option
25980 changes to &"smtps"&, and the transport initiates TLS immediately after
25981 connecting, as an outbound SSL-on-connect, instead of using STARTTLS to upgrade.
25982 The Internet standards bodies used to strongly discourage use of this mode,
25983 but as of RFC 8314 it is preferred over STARTTLS for message submission
25984 (as distinct from MTA-MTA communication).
25985
25986
25987 .option retry_include_ip_address smtp boolean&!! true
25988 Exim normally includes both the host name and the IP address in the key it
25989 constructs for indexing retry data after a temporary delivery failure. This
25990 means that when one of several IP addresses for a host is failing, it gets
25991 tried periodically (controlled by the retry rules), but use of the other IP
25992 addresses is not affected.
25993
25994 However, in some dialup environments hosts are assigned a different IP address
25995 each time they connect. In this situation the use of the IP address as part of
25996 the retry key leads to undesirable behaviour. Setting this option false causes
25997 Exim to use only the host name.
25998 Since it is expanded it can be made to depend on the host or domain.
25999
26000
26001 .option serialize_hosts smtp "host list&!!" unset
26002 .cindex "serializing connections"
26003 .cindex "host" "serializing connections"
26004 Because Exim operates in a distributed manner, if several messages for the same
26005 host arrive at around the same time, more than one simultaneous connection to
26006 the remote host can occur. This is not usually a problem except when there is a
26007 slow link between the hosts. In that situation it may be helpful to restrict
26008 Exim to one connection at a time. This can be done by setting
26009 &%serialize_hosts%& to match the relevant hosts.
26010
26011 .cindex "hints database" "serializing deliveries to a host"
26012 Exim implements serialization by means of a hints database in which a record is
26013 written whenever a process connects to one of the restricted hosts. The record
26014 is deleted when the connection is completed. Obviously there is scope for
26015 records to get left lying around if there is a system or program crash. To
26016 guard against this, Exim ignores any records that are more than six hours old.
26017
26018 If you set up this kind of serialization, you should also arrange to delete the
26019 relevant hints database whenever your system reboots. The names of the files
26020 start with &_misc_& and they are kept in the &_spool/db_& directory. There
26021 may be one or two files, depending on the type of DBM in use. The same files
26022 are used for ETRN serialization.
26023
26024 See also the &%max_parallel%& generic transport option.
26025
26026
26027 .option size_addition smtp integer 1024
26028 .cindex "SIZE" "ESMTP extension"
26029 .cindex "message" "size issue for transport filter"
26030 .cindex "size" "of message"
26031 .cindex "transport" "filter"
26032 .cindex "filter" "transport filter"
26033 If a remote SMTP server indicates that it supports the SIZE option of the
26034 MAIL command, Exim uses this to pass over the message size at the start of
26035 an SMTP transaction. It adds the value of &%size_addition%& to the value it
26036 sends, to allow for headers and other text that may be added during delivery by
26037 configuration options or in a transport filter. It may be necessary to increase
26038 this if a lot of text is added to messages.
26039
26040 Alternatively, if the value of &%size_addition%& is set negative, it disables
26041 the use of the SIZE option altogether.
26042
26043
26044 .option socks_proxy smtp string&!! unset
26045 .cindex proxy SOCKS
26046 This option enables use of SOCKS proxies for connections made by the
26047 transport.  For details see section &<<SECTproxySOCKS>>&.
26048
26049
26050 .option tls_alpn smtp string&!! unset
26051 .cindex TLS "Application Layer Protocol Names"
26052 .cindex TLS ALPN
26053 .cindex ALPN "set name in client"
26054 If this option is set
26055 and the TLS library supports ALPN,
26056 the value given is used.
26057
26058 As of writing no value has been standardised for email use.
26059 The authors suggest using &"smtp"&.
26060
26061
26062
26063 .option tls_certificate smtp string&!! unset
26064 .cindex "TLS" "client certificate, location of"
26065 .cindex "certificate" "client, location of"
26066 .vindex "&$host$&"
26067 .vindex "&$host_address$&"
26068 The value of this option must be the absolute path to a file which contains the
26069 client's certificate, for possible use when sending a message over an encrypted
26070 connection. The values of &$host$& and &$host_address$& are set to the name and
26071 address of the server during the expansion. See chapter &<<CHAPTLS>>& for
26072 details of TLS.
26073
26074 &*Note*&: This option must be set if you want Exim to be able to use a TLS
26075 certificate when sending messages as a client. The global option of the same
26076 name specifies the certificate for Exim as a server; it is not automatically
26077 assumed that the same certificate should be used when Exim is operating as a
26078 client.
26079
26080
26081 .option tls_crl smtp string&!! unset
26082 .cindex "TLS" "client certificate revocation list"
26083 .cindex "certificate" "revocation list for client"
26084 This option specifies a certificate revocation list. The expanded value must
26085 be the name of a file that contains a CRL in PEM format.
26086
26087
26088 .option tls_dh_min_bits smtp integer 1024
26089 .cindex "TLS" "Diffie-Hellman minimum acceptable size"
26090 When establishing a TLS session, if a ciphersuite which uses Diffie-Hellman
26091 key agreement is negotiated, the server will provide a large prime number
26092 for use.  This option establishes the minimum acceptable size of that number.
26093 If the parameter offered by the server is too small, then the TLS handshake
26094 will fail.
26095
26096 Only supported when using GnuTLS.
26097
26098
26099 .option tls_privatekey smtp string&!! unset
26100 .cindex "TLS" "client private key, location of"
26101 .vindex "&$host$&"
26102 .vindex "&$host_address$&"
26103 The value of this option must be the absolute path to a file which contains the
26104 client's private key. This is used when sending a message over an encrypted
26105 connection using a client certificate. The values of &$host$& and
26106 &$host_address$& are set to the name and address of the server during the
26107 expansion. If this option is unset, or the expansion is forced to fail, or the
26108 result is an empty string, the private key is assumed to be in the same file as
26109 the certificate. See chapter &<<CHAPTLS>>& for details of TLS.
26110
26111
26112 .option tls_require_ciphers smtp string&!! unset
26113 .cindex "TLS" "requiring specific ciphers"
26114 .cindex "cipher" "requiring specific"
26115 .vindex "&$host$&"
26116 .vindex "&$host_address$&"
26117 The value of this option must be a list of permitted cipher suites, for use
26118 when setting up an outgoing encrypted connection. (There is a global option of
26119 the same name for controlling incoming connections.) The values of &$host$& and
26120 &$host_address$& are set to the name and address of the server during the
26121 expansion. See chapter &<<CHAPTLS>>& for details of TLS; note that this option
26122 is used in different ways by OpenSSL and GnuTLS (see sections
26123 &<<SECTreqciphssl>>& and &<<SECTreqciphgnu>>&). For GnuTLS, the order of the
26124 ciphers is a preference order.
26125
26126
26127 .option tls_resumption_hosts smtp "host list&!!" unset
26128 .cindex TLS resumption
26129 This option controls which connections to use the TLS resumption feature.
26130 See &<<SECTresumption>>& for details.
26131
26132
26133
26134 .option tls_sni smtp string&!! unset
26135 .cindex "TLS" "Server Name Indication"
26136 .cindex "TLS" SNI
26137 .cindex SNI "setting in client"
26138 .vindex "&$tls_sni$&"
26139 If this option is set
26140 and the connection is not DANE-validated
26141 then it sets the $tls_out_sni variable and causes any
26142 TLS session to pass this value as the Server Name Indication extension to
26143 the remote side, which can be used by the remote side to select an appropriate
26144 certificate and private key for the session.
26145
26146 See &<<SECTtlssni>>& for more information.
26147
26148 Note that for OpenSSL, this feature requires a build of OpenSSL that supports
26149 TLS extensions.
26150
26151
26152
26153
26154 .option tls_tempfail_tryclear smtp boolean true
26155 .cindex "4&'xx'& responses" "to STARTTLS"
26156 When the server host is not in &%hosts_require_tls%&, and there is a problem in
26157 setting up a TLS session, this option determines whether or not Exim should try
26158 to deliver the message unencrypted. If it is set false, delivery to the
26159 current host is deferred; if there are other hosts, they are tried. If this
26160 option is set true, Exim attempts to deliver unencrypted after a 4&'xx'&
26161 response to STARTTLS. Also, if STARTTLS is accepted, but the subsequent
26162 TLS negotiation fails, Exim closes the current connection (because it is in an
26163 unknown state), opens a new one to the same host, and then tries the delivery
26164 in clear.
26165
26166
26167 .option tls_try_verify_hosts smtp "host list&!!" *
26168 .cindex "TLS" "server certificate verification"
26169 .cindex "certificate" "verification of server"
26170 This option gives a list of hosts for which, on encrypted connections,
26171 certificate verification will be tried but need not succeed.
26172 The &%tls_verify_certificates%& option must also be set.
26173 Note that unless the host is in this list
26174 TLS connections will be denied to hosts using self-signed certificates
26175 when &%tls_verify_certificates%& is matched.
26176 The &$tls_out_certificate_verified$& variable is set when
26177 certificate verification succeeds.
26178
26179
26180 .option tls_verify_cert_hostnames smtp "host list&!!" *
26181 .cindex "TLS" "server certificate hostname verification"
26182 .cindex "certificate" "verification of server"
26183 This option give a list of hosts for which,
26184 while verifying the server certificate,
26185 checks will be included on the host name
26186 (note that this will generally be the result of a DNS MX lookup)
26187 versus the Subject-Alternate-Name (or, if none, Subject-Name) fields.
26188 Wildcard names are permitted,
26189 limited to being the initial component of a 3-or-more component FQDN.
26190
26191 There is no equivalent checking on client certificates.
26192
26193
26194 .option tls_verify_certificates smtp string&!! system
26195 .cindex "TLS" "server certificate verification"
26196 .cindex "certificate" "verification of server"
26197 .vindex "&$host$&"
26198 .vindex "&$host_address$&"
26199 The value of this option must be either the
26200 word "system"
26201 or the absolute path to
26202 a file or directory containing permitted certificates for servers,
26203 for use when setting up an encrypted connection.
26204
26205 The "system" value for the option will use a location compiled into the SSL library.
26206 This is not available for GnuTLS versions preceding 3.0.20; a value of "system"
26207 is taken as empty and an explicit location
26208 must be specified.
26209
26210 The use of a directory for the option value is not available for GnuTLS versions
26211 preceding 3.3.6 and a single file must be used.
26212
26213 With OpenSSL the certificates specified
26214 explicitly
26215 either by file or directory
26216 are added to those given by the system default location.
26217
26218 The values of &$host$& and
26219 &$host_address$& are set to the name and address of the server during the
26220 expansion of this option. See chapter &<<CHAPTLS>>& for details of TLS.
26221
26222 For back-compatibility,
26223 if neither tls_verify_hosts nor tls_try_verify_hosts are set
26224 (a single-colon empty list counts as being set)
26225 and certificate verification fails the TLS connection is closed.
26226
26227
26228 .option tls_verify_hosts smtp "host list&!!" unset
26229 .cindex "TLS" "server certificate verification"
26230 .cindex "certificate" "verification of server"
26231 This option gives a list of hosts for which, on encrypted connections,
26232 certificate verification must succeed.
26233 The &%tls_verify_certificates%& option must also be set.
26234 If both this option and &%tls_try_verify_hosts%& are unset
26235 operation is as if this option selected all hosts.
26236 &*Warning*&: Including a host in &%tls_verify_hosts%& does not require
26237 that connections use TLS.
26238 Fallback to in-clear communication will be done unless restricted by
26239 the &%hosts_require_tls%& option.
26240
26241 .option utf8_downconvert smtp integer&!! -1
26242 .cindex utf8 "address downconversion"
26243 .cindex i18n "utf8 address downconversion"
26244 If built with internationalization support,
26245 this option controls conversion of UTF-8 in message envelope addresses
26246 to a-label form.
26247 If, after expansion, the value is 1, 0, or -1 then this value overrides
26248 any value previously set for the message.  Otherwise, any previously
26249 set value is used.  To permit use of a previous value,
26250 set this option to an empty string.
26251 For details on the values see section &<<SECTi18nMTA>>&.
26252
26253
26254
26255
26256 .section "How the limits for the number of hosts to try are used" &&&
26257          "SECTvalhosmax"
26258 .cindex "host" "maximum number to try"
26259 .cindex "limit" "hosts; maximum number tried"
26260 There are two options that are concerned with the number of hosts that are
26261 tried when an SMTP delivery takes place. They are &%hosts_max_try%& and
26262 &%hosts_max_try_hardlimit%&.
26263
26264
26265 The &%hosts_max_try%& option limits the number of hosts that are tried
26266 for a single delivery. However, despite the term &"host"& in its name, the
26267 option actually applies to each IP address independently. In other words, a
26268 multihomed host is treated as several independent hosts, just as it is for
26269 retrying.
26270
26271 Many of the larger ISPs have multiple MX records which often point to
26272 multihomed hosts. As a result, a list of a dozen or more IP addresses may be
26273 created as a result of routing one of these domains.
26274
26275 Trying every single IP address on such a long list does not seem sensible; if
26276 several at the top of the list fail, it is reasonable to assume there is some
26277 problem that is likely to affect all of them. Roughly speaking, the value of
26278 &%hosts_max_try%& is the maximum number that are tried before deferring the
26279 delivery. However, the logic cannot be quite that simple.
26280
26281 Firstly, IP addresses that are skipped because their retry times have not
26282 arrived do not count, and in addition, addresses that are past their retry
26283 limits are also not counted, even when they are tried. This means that when
26284 some IP addresses are past their retry limits, more than the value of
26285 &%hosts_max_retry%& may be tried. The reason for this behaviour is to ensure
26286 that all IP addresses are considered before timing out an email address (but
26287 see below for an exception).
26288
26289 Secondly, when the &%hosts_max_try%& limit is reached, Exim looks down the host
26290 list to see if there is a subsequent host with a different (higher valued) MX.
26291 If there is, that host is considered next, and the current IP address is used
26292 but not counted. This behaviour helps in the case of a domain with a retry rule
26293 that hardly ever delays any hosts, as is now explained:
26294
26295 Consider the case of a long list of hosts with one MX value, and a few with a
26296 higher MX value. If &%hosts_max_try%& is small (the default is 5) only a few
26297 hosts at the top of the list are tried at first. With the default retry rule,
26298 which specifies increasing retry times, the higher MX hosts are eventually
26299 tried when those at the top of the list are skipped because they have not
26300 reached their retry times.
26301
26302 However, it is common practice to put a fixed short retry time on domains for
26303 large ISPs, on the grounds that their servers are rarely down for very long.
26304 Unfortunately, these are exactly the domains that tend to resolve to long lists
26305 of hosts. The short retry time means that the lowest MX hosts are tried every
26306 time. The attempts may be in a different order because of random sorting, but
26307 without the special MX check, the higher MX hosts would never be tried until
26308 all the lower MX hosts had timed out (which might be several days), because
26309 there are always some lower MX hosts that have reached their retry times. With
26310 the special check, Exim considers at least one IP address from each MX value at
26311 every delivery attempt, even if the &%hosts_max_try%& limit has already been
26312 reached.
26313
26314 The above logic means that &%hosts_max_try%& is not a hard limit, and in
26315 particular, Exim normally eventually tries all the IP addresses before timing
26316 out an email address. When &%hosts_max_try%& was implemented, this seemed a
26317 reasonable thing to do. Recently, however, some lunatic DNS configurations have
26318 been set up with hundreds of IP addresses for some domains. It can
26319 take a very long time indeed for an address to time out in these cases.
26320
26321 The &%hosts_max_try_hardlimit%& option was added to help with this problem.
26322 Exim never tries more than this number of IP addresses; if it hits this limit
26323 and they are all timed out, the email address is bounced, even though not all
26324 possible IP addresses have been tried.
26325 .ecindex IIDsmttra1
26326 .ecindex IIDsmttra2
26327
26328
26329
26330
26331
26332 . ////////////////////////////////////////////////////////////////////////////
26333 . ////////////////////////////////////////////////////////////////////////////
26334
26335 .chapter "Address rewriting" "CHAPrewrite"
26336 .scindex IIDaddrew "rewriting" "addresses"
26337 There are some circumstances in which Exim automatically rewrites domains in
26338 addresses. The two most common are when an address is given without a domain
26339 (referred to as an &"unqualified address"&) or when an address contains an
26340 abbreviated domain that is expanded by DNS lookup.
26341
26342 Unqualified envelope addresses are accepted only for locally submitted
26343 messages, or for messages that are received from hosts matching
26344 &%sender_unqualified_hosts%& or &%recipient_unqualified_hosts%&, as
26345 appropriate. Unqualified addresses in header lines are qualified if they are in
26346 locally submitted messages, or messages from hosts that are permitted to send
26347 unqualified envelope addresses. Otherwise, unqualified addresses in header
26348 lines are neither qualified nor rewritten.
26349
26350 One situation in which Exim does &'not'& automatically rewrite a domain is
26351 when it is the name of a CNAME record in the DNS. The older RFCs suggest that
26352 such a domain should be rewritten using the &"canonical"& name, and some MTAs
26353 do this. The new RFCs do not contain this suggestion.
26354
26355
26356 .section "Explicitly configured address rewriting" "SECID147"
26357 This chapter describes the rewriting rules that can be used in the
26358 main rewrite section of the configuration file, and also in the generic
26359 &%headers_rewrite%& option that can be set on any transport.
26360
26361 Some people believe that configured address rewriting is a Mortal Sin.
26362 Others believe that life is not possible without it. Exim provides the
26363 facility; you do not have to use it.
26364
26365 The main rewriting rules that appear in the &"rewrite"& section of the
26366 configuration file are applied to addresses in incoming messages, both envelope
26367 addresses and addresses in header lines. Each rule specifies the types of
26368 address to which it applies.
26369
26370 Whether or not addresses in header lines are rewritten depends on the origin of
26371 the headers and the type of rewriting. Global rewriting, that is, rewriting
26372 rules from the rewrite section of the configuration file, is applied only to
26373 those headers that were received with the message. Header lines that are added
26374 by ACLs or by a system filter or by individual routers or transports (which
26375 are specific to individual recipient addresses) are not rewritten by the global
26376 rules.
26377
26378 Rewriting at transport time, by means of the &%headers_rewrite%& option,
26379 applies all headers except those added by routers and transports. That is, as
26380 well as the headers that were received with the message, it also applies to
26381 headers that were added by an ACL or a system filter.
26382
26383
26384 In general, rewriting addresses from your own system or domain has some
26385 legitimacy. Rewriting other addresses should be done only with great care and
26386 in special circumstances. The author of Exim believes that rewriting should be
26387 used sparingly, and mainly for &"regularizing"& addresses in your own domains.
26388 Although it can sometimes be used as a routing tool, this is very strongly
26389 discouraged.
26390
26391 There are two commonly encountered circumstances where rewriting is used, as
26392 illustrated by these examples:
26393
26394 .ilist
26395 The company whose domain is &'hitch.fict.example'& has a number of hosts that
26396 exchange mail with each other behind a firewall, but there is only a single
26397 gateway to the outer world. The gateway rewrites &'*.hitch.fict.example'& as
26398 &'hitch.fict.example'& when sending mail off-site.
26399 .next
26400 A host rewrites the local parts of its own users so that, for example,
26401 &'fp42@hitch.fict.example'& becomes &'Ford.Prefect@hitch.fict.example'&.
26402 .endlist
26403
26404
26405
26406 .section "When does rewriting happen?" "SECID148"
26407 .cindex "rewriting" "timing of"
26408 .cindex "&ACL;" "rewriting addresses in"
26409 Configured address rewriting can take place at several different stages of a
26410 message's processing.
26411
26412 .vindex "&$sender_address$&"
26413 At the start of an ACL for MAIL, the sender address may have been rewritten
26414 by a special SMTP-time rewrite rule (see section &<<SSECTrewriteS>>&), but no
26415 ordinary rewrite rules have yet been applied. If, however, the sender address
26416 is verified in the ACL, it is rewritten before verification, and remains
26417 rewritten thereafter. The subsequent value of &$sender_address$& is the
26418 rewritten address. This also applies if sender verification happens in a
26419 RCPT ACL. Otherwise, when the sender address is not verified, it is
26420 rewritten as soon as a message's header lines have been received.
26421
26422 .vindex "&$domain$&"
26423 .vindex "&$local_part$&"
26424 Similarly, at the start of an ACL for RCPT, the current recipient's address
26425 may have been rewritten by a special SMTP-time rewrite rule, but no ordinary
26426 rewrite rules have yet been applied to it. However, the behaviour is different
26427 from the sender address when a recipient is verified. The address is rewritten
26428 for the verification, but the rewriting is not remembered at this stage. The
26429 value of &$local_part$& and &$domain$& after verification are always the same
26430 as they were before (that is, they contain the unrewritten &-- except for
26431 SMTP-time rewriting &-- address).
26432
26433 As soon as a message's header lines have been received, all the envelope
26434 recipient addresses are permanently rewritten, and rewriting is also applied to
26435 the addresses in the header lines (if configured). This happens before adding
26436 any header lines that were specified in MAIL or RCPT ACLs, and
26437 .cindex "&[local_scan()]& function" "address rewriting; timing of"
26438 before the DATA ACL and &[local_scan()]& functions are run.
26439
26440 When an address is being routed, either for delivery or for verification,
26441 rewriting is applied immediately to child addresses that are generated by
26442 redirection, unless &%no_rewrite%& is set on the router.
26443
26444 .cindex "envelope from"
26445 .cindex "envelope sender" "rewriting at transport time"
26446 .cindex "rewriting" "at transport time"
26447 .cindex "header lines" "rewriting at transport time"
26448 At transport time, additional rewriting of addresses in header lines can be
26449 specified by setting the generic &%headers_rewrite%& option on a transport.
26450 This option contains rules that are identical in form to those in the rewrite
26451 section of the configuration file. They are applied to the original message
26452 header lines and any that were added by ACLs or a system filter. They are not
26453 applied to header lines that are added by routers or the transport.
26454
26455 The outgoing envelope sender can be rewritten by means of the &%return_path%&
26456 transport option. However, it is not possible to rewrite envelope recipients at
26457 transport time.
26458
26459
26460
26461
26462 .section "Testing the rewriting rules that apply on input" "SECID149"
26463 .cindex "rewriting" "testing"
26464 .cindex "testing" "rewriting"
26465 Exim's input rewriting configuration appears in a part of the runtime
26466 configuration file headed by &"begin rewrite"&. It can be tested by the
26467 &%-brw%& command line option. This takes an address (which can be a full RFC
26468 2822 address) as its argument. The output is a list of how the address would be
26469 transformed by the rewriting rules for each of the different places it might
26470 appear in an incoming message, that is, for each different header and for the
26471 envelope sender and recipient fields. For example,
26472 .code
26473 exim -brw ph10@exim.workshop.example
26474 .endd
26475 might produce the output
26476 .code
26477 sender: Philip.Hazel@exim.workshop.example
26478 from: Philip.Hazel@exim.workshop.example
26479 to: ph10@exim.workshop.example
26480 cc: ph10@exim.workshop.example
26481 bcc: ph10@exim.workshop.example
26482 reply-to: Philip.Hazel@exim.workshop.example
26483 env-from: Philip.Hazel@exim.workshop.example
26484 env-to: ph10@exim.workshop.example
26485 .endd
26486 which shows that rewriting has been set up for that address when used in any of
26487 the source fields, but not when it appears as a recipient address. At the
26488 present time, there is no equivalent way of testing rewriting rules that are
26489 set for a particular transport.
26490
26491
26492 .section "Rewriting rules" "SECID150"
26493 .cindex "rewriting" "rules"
26494 The rewrite section of the configuration file consists of lines of rewriting
26495 rules in the form
26496 .display
26497 <&'source pattern'&>  <&'replacement'&>  <&'flags'&>
26498 .endd
26499 Rewriting rules that are specified for the &%headers_rewrite%& generic
26500 transport option are given as a colon-separated list. Each item in the list
26501 takes the same form as a line in the main rewriting configuration (except that
26502 any colons must be doubled, of course).
26503
26504 The formats of source patterns and replacement strings are described below.
26505 Each is terminated by white space, unless enclosed in double quotes, in which
26506 case normal quoting conventions apply inside the quotes. The flags are single
26507 characters which may appear in any order. Spaces and tabs between them are
26508 ignored.
26509
26510 For each address that could potentially be rewritten, the rules are scanned in
26511 order, and replacements for the address from earlier rules can themselves be
26512 replaced by later rules (but see the &"q"& and &"R"& flags).
26513
26514 The order in which addresses are rewritten is undefined, may change between
26515 releases, and must not be relied on, with one exception: when a message is
26516 received, the envelope sender is always rewritten first, before any header
26517 lines are rewritten. For example, the replacement string for a rewrite of an
26518 address in &'To:'& must not assume that the message's address in &'From:'& has
26519 (or has not) already been rewritten. However, a rewrite of &'From:'& may assume
26520 that the envelope sender has already been rewritten.
26521
26522 .vindex "&$domain$&"
26523 .vindex "&$local_part$&"
26524 The variables &$local_part$& and &$domain$& can be used in the replacement
26525 string to refer to the address that is being rewritten. Note that lookup-driven
26526 rewriting can be done by a rule of the form
26527 .code
26528 *@*   ${lookup ...
26529 .endd
26530 where the lookup key uses &$1$& and &$2$& or &$local_part$& and &$domain$& to
26531 refer to the address that is being rewritten.
26532
26533
26534 .section "Rewriting patterns" "SECID151"
26535 .cindex "rewriting" "patterns"
26536 .cindex "address list" "in a rewriting pattern"
26537 The source pattern in a rewriting rule is any item which may appear in an
26538 address list (see section &<<SECTaddresslist>>&). It is in fact processed as a
26539 single-item address list, which means that it is expanded before being tested
26540 against the address. As always, if you use a regular expression as a pattern,
26541 you must take care to escape dollar and backslash characters, or use the &`\N`&
26542 facility to suppress string expansion within the regular expression.
26543
26544 Domains in patterns should be given in lower case. Local parts in patterns are
26545 case-sensitive. If you want to do case-insensitive matching of local parts, you
26546 can use a regular expression that starts with &`^(?i)`&.
26547
26548 .cindex "numerical variables (&$1$& &$2$& etc)" "in rewriting rules"
26549 After matching, the numerical variables &$1$&, &$2$&, etc. may be set,
26550 depending on the type of match which occurred. These can be used in the
26551 replacement string to insert portions of the incoming address. &$0$& always
26552 refers to the complete incoming address. When a regular expression is used, the
26553 numerical variables are set from its capturing subexpressions. For other types
26554 of pattern they are set as follows:
26555
26556 .ilist
26557 If a local part or domain starts with an asterisk, the numerical variables
26558 refer to the character strings matched by asterisks, with &$1$& associated with
26559 the first asterisk, and &$2$& with the second, if present. For example, if the
26560 pattern
26561 .code
26562 *queen@*.fict.example
26563 .endd
26564 is matched against the address &'hearts-queen@wonderland.fict.example'& then
26565 .code
26566 $0 = hearts-queen@wonderland.fict.example
26567 $1 = hearts-
26568 $2 = wonderland
26569 .endd
26570 Note that if the local part does not start with an asterisk, but the domain
26571 does, it is &$1$& that contains the wild part of the domain.
26572
26573 .next
26574 If the domain part of the pattern is a partial lookup, the wild and fixed parts
26575 of the domain are placed in the next available numerical variables. Suppose,
26576 for example, that the address &'foo@bar.baz.example'& is processed by a
26577 rewriting rule of the form
26578 .display
26579 &`*@partial-dbm;/some/dbm/file`&    <&'replacement string'&>
26580 .endd
26581 and the key in the file that matches the domain is &`*.baz.example`&. Then
26582 .code
26583 $1 = foo
26584 $2 = bar
26585 $3 = baz.example
26586 .endd
26587 If the address &'foo@baz.example'& is looked up, this matches the same
26588 wildcard file entry, and in this case &$2$& is set to the empty string, but
26589 &$3$& is still set to &'baz.example'&. If a non-wild key is matched in a
26590 partial lookup, &$2$& is again set to the empty string and &$3$& is set to the
26591 whole domain. For non-partial domain lookups, no numerical variables are set.
26592 .endlist
26593
26594
26595 .section "Rewriting replacements" "SECID152"
26596 .cindex "rewriting" "replacements"
26597 If the replacement string for a rule is a single asterisk, addresses that
26598 match the pattern and the flags are &'not'& rewritten, and no subsequent
26599 rewriting rules are scanned. For example,
26600 .code
26601 hatta@lookingglass.fict.example  *  f
26602 .endd
26603 specifies that &'hatta@lookingglass.fict.example'& is never to be rewritten in
26604 &'From:'& headers.
26605
26606 .vindex "&$domain$&"
26607 .vindex "&$local_part$&"
26608 If the replacement string is not a single asterisk, it is expanded, and must
26609 yield a fully qualified address. Within the expansion, the variables
26610 &$local_part$& and &$domain$& refer to the address that is being rewritten.
26611 Any letters they contain retain their original case &-- they are not lower
26612 cased. The numerical variables are set up according to the type of pattern that
26613 matched the address, as described above. If the expansion is forced to fail by
26614 the presence of &"fail"& in a conditional or lookup item, rewriting by the
26615 current rule is abandoned, but subsequent rules may take effect. Any other
26616 expansion failure causes the entire rewriting operation to be abandoned, and an
26617 entry written to the panic log.
26618
26619
26620
26621 .subsection "Rewriting flags" "SSECID153"
26622 There are three different kinds of flag that may appear on rewriting rules:
26623
26624 .ilist
26625 Flags that specify which headers and envelope addresses to rewrite: E, F, T, b,
26626 c, f, h, r, s, t.
26627 .next
26628 A flag that specifies rewriting at SMTP time: S.
26629 .next
26630 Flags that control the rewriting process: Q, q, R, w.
26631 .endlist
26632
26633 For rules that are part of the &%headers_rewrite%& generic transport option,
26634 E, F, T, and S are not permitted.
26635
26636
26637
26638 .subsection "Flags specifying which headers and envelope addresses to rewrite" &&&
26639          "SSECID154"
26640 .cindex rewriting flags
26641 If none of the following flag letters, nor the &"S"& flag (see section
26642 &<<SSECTrewriteS>>&) are present, a main rewriting rule applies to all headers
26643 and to both the sender and recipient fields of the envelope, whereas a
26644 transport-time rewriting rule just applies to all headers. Otherwise, the
26645 rewriting rule is skipped unless the relevant addresses are being processed.
26646 .display
26647 &`E`&       rewrite all envelope fields
26648 &`F`&       rewrite the envelope From field
26649 &`T`&       rewrite the envelope To field
26650 &`b`&       rewrite the &'Bcc:'& header
26651 &`c`&       rewrite the &'Cc:'& header
26652 &`f`&       rewrite the &'From:'& header
26653 &`h`&       rewrite all headers
26654 &`r`&       rewrite the &'Reply-To:'& header
26655 &`s`&       rewrite the &'Sender:'& header
26656 &`t`&       rewrite the &'To:'& header
26657 .endd
26658 "All headers" means all of the headers listed above that can be selected
26659 individually, plus their &'Resent-'& versions. It does not include
26660 other headers such as &'Subject:'& etc.
26661
26662 You should be particularly careful about rewriting &'Sender:'& headers, and
26663 restrict this to special known cases in your own domains.
26664
26665
26666 .subsection "The SMTP-time rewriting flag" SSECTrewriteS
26667 .cindex SMTP "rewriting malformed addresses"
26668 .cindex RCPT "rewriting argument of"
26669 .cindex MAIL "rewriting argument of"
26670 The rewrite flag &"S"& specifies a rewrite of incoming envelope addresses at
26671 SMTP time, as soon as an address is received in a MAIL or RCPT command, and
26672 before any other processing; even before syntax checking. The pattern is
26673 required to be a regular expression, and it is matched against the whole of the
26674 data for the command, including any surrounding angle brackets.
26675
26676 .vindex "&$domain$&"
26677 .vindex "&$local_part$&"
26678 This form of rewrite rule allows for the handling of addresses that are not
26679 compliant with RFCs 2821 and 2822 (for example, &"bang paths"& in batched SMTP
26680 input). Because the input is not required to be a syntactically valid address,
26681 the variables &$local_part$& and &$domain$& are not available during the
26682 expansion of the replacement string. The result of rewriting replaces the
26683 original address in the MAIL or RCPT command.
26684
26685
26686 .subsection "Flags controlling the rewriting process" SSECID155
26687 There are four flags which control the way the rewriting process works. These
26688 take effect only when a rule is invoked, that is, when the address is of the
26689 correct type (matches the flags) and matches the pattern:
26690
26691 .ilist
26692 If the &"Q"& flag is set on a rule, the rewritten address is permitted to be an
26693 unqualified local part. It is qualified with &%qualify_recipient%&. In the
26694 absence of &"Q"& the rewritten address must always include a domain.
26695 .next
26696 If the &"q"& flag is set on a rule, no further rewriting rules are considered,
26697 even if no rewriting actually takes place because of a &"fail"& in the
26698 expansion. The &"q"& flag is not effective if the address is of the wrong type
26699 (does not match the flags) or does not match the pattern.
26700 .next
26701 The &"R"& flag causes a successful rewriting rule to be re-applied to the new
26702 address, up to ten times. It can be combined with the &"q"& flag, to stop
26703 rewriting once it fails to match (after at least one successful rewrite).
26704 .next
26705 .cindex "rewriting" "whole addresses"
26706 When an address in a header is rewritten, the rewriting normally applies only
26707 to the working part of the address, with any comments and RFC 2822 &"phrase"&
26708 left unchanged. For example, rewriting might change
26709 .code
26710 From: Ford Prefect <fp42@restaurant.hitch.fict.example>
26711 .endd
26712 into
26713 .code
26714 From: Ford Prefect <prefectf@hitch.fict.example>
26715 .endd
26716 .cindex "RFC 2047"
26717 Sometimes there is a need to replace the whole address item, and this can be
26718 done by adding the flag letter &"w"& to a rule. If this is set on a rule that
26719 causes an address in a header line to be rewritten, the entire address is
26720 replaced, not just the working part. The replacement must be a complete RFC
26721 2822 address, including the angle brackets if necessary. If text outside angle
26722 brackets contains a character whose value is greater than 126 or less than 32
26723 (except for tab), the text is encoded according to RFC 2047. The character set
26724 is taken from &%headers_charset%&, which gets its default at build time.
26725
26726 When the &"w"& flag is set on a rule that causes an envelope address to be
26727 rewritten, all but the working part of the replacement address is discarded.
26728 .endlist
26729
26730
26731 .section "Rewriting examples" "SECID156"
26732 Here is an example of the two common rewriting paradigms:
26733 .code
26734 *@*.hitch.fict.example  $1@hitch.fict.example
26735 *@hitch.fict.example    ${lookup{$1}dbm{/etc/realnames}\
26736                      {$value}fail}@hitch.fict.example bctfrF
26737 .endd
26738 Note the use of &"fail"& in the lookup expansion in the second rule, forcing
26739 the string expansion to fail if the lookup does not succeed. In this context it
26740 has the effect of leaving the original address unchanged, but Exim goes on to
26741 consider subsequent rewriting rules, if any, because the &"q"& flag is not
26742 present in that rule. An alternative to &"fail"& would be to supply &$1$&
26743 explicitly, which would cause the rewritten address to be the same as before,
26744 at the cost of a small bit of processing. Not supplying either of these is an
26745 error, since the rewritten address would then contain no local part.
26746
26747 The first example above replaces the domain with a superior, more general
26748 domain. This may not be desirable for certain local parts. If the rule
26749 .code
26750 root@*.hitch.fict.example  *
26751 .endd
26752 were inserted before the first rule, rewriting would be suppressed for the
26753 local part &'root'& at any domain ending in &'hitch.fict.example'&.
26754
26755 Rewriting can be made conditional on a number of tests, by making use of
26756 &${if$& in the expansion item. For example, to apply a rewriting rule only to
26757 messages that originate outside the local host:
26758 .code
26759 *@*.hitch.fict.example  "${if !eq {$sender_host_address}{}\
26760                          {$1@hitch.fict.example}fail}"
26761 .endd
26762 The replacement string is quoted in this example because it contains white
26763 space.
26764
26765 .cindex "rewriting" "bang paths"
26766 .cindex "bang paths" "rewriting"
26767 Exim does not handle addresses in the form of &"bang paths"&. If it sees such
26768 an address it treats it as an unqualified local part which it qualifies with
26769 the local qualification domain (if the source of the message is local or if the
26770 remote host is permitted to send unqualified addresses). Rewriting can
26771 sometimes be used to handle simple bang paths with a fixed number of
26772 components. For example, the rule
26773 .code
26774 \N^([^!]+)!(.*)@your.domain.example$\N   $2@$1
26775 .endd
26776 rewrites a two-component bang path &'host.name!user'& as the domain address
26777 &'user@host.name'&. However, there is a security implication in using this as
26778 a global rewriting rule for envelope addresses. It can provide a backdoor
26779 method for using your system as a relay, because the incoming addresses appear
26780 to be local. If the bang path addresses are received via SMTP, it is safer to
26781 use the &"S"& flag to rewrite them as they are received, so that relay checking
26782 can be done on the rewritten addresses.
26783 .ecindex IIDaddrew
26784
26785
26786
26787
26788
26789 . ////////////////////////////////////////////////////////////////////////////
26790 . ////////////////////////////////////////////////////////////////////////////
26791
26792 .chapter "Retry configuration" "CHAPretry"
26793 .scindex IIDretconf1 "retry" "configuration, description of"
26794 .scindex IIDregconf2 "configuration file" "retry section"
26795 The &"retry"& section of the runtime configuration file contains a list of
26796 retry rules that control how often Exim tries to deliver messages that cannot
26797 be delivered at the first attempt. If there are no retry rules (the section is
26798 empty or not present), there are no retries. In this situation, temporary
26799 errors are treated as permanent. The default configuration contains a single,
26800 general-purpose retry rule (see section &<<SECID57>>&). The &%-brt%& command
26801 line option can be used to test which retry rule will be used for a given
26802 address, domain and error.
26803
26804 The most common cause of retries is temporary failure to deliver to a remote
26805 host because the host is down, or inaccessible because of a network problem.
26806 Exim's retry processing in this case is applied on a per-host (strictly, per IP
26807 address) basis, not on a per-message basis. Thus, if one message has recently
26808 been delayed, delivery of a new message to the same host is not immediately
26809 tried, but waits for the host's retry time to arrive. If the &%retry_defer%&
26810 log selector is set, the message
26811 .cindex "retry" "time not reached"
26812 &"retry time not reached"& is written to the main log whenever a delivery is
26813 skipped for this reason. Section &<<SECToutSMTPerr>>& contains more details of
26814 the handling of errors during remote deliveries.
26815
26816 Retry processing applies to routing as well as to delivering, except as covered
26817 in the next paragraph. The retry rules do not distinguish between these
26818 actions. It is not possible, for example, to specify different behaviour for
26819 failures to route the domain &'snark.fict.example'& and failures to deliver to
26820 the host &'snark.fict.example'&. I didn't think anyone would ever need this
26821 added complication, so did not implement it. However, although they share the
26822 same retry rule, the actual retry times for routing and transporting a given
26823 domain are maintained independently.
26824
26825 When a delivery is not part of a queue run (typically an immediate delivery on
26826 receipt of a message), the routers are always run, and local deliveries are
26827 always attempted, even if retry times are set for them. This makes for better
26828 behaviour if one particular message is causing problems (for example, causing
26829 quota overflow, or provoking an error in a filter file). If such a delivery
26830 suffers a temporary failure, the retry data is updated as normal, and
26831 subsequent delivery attempts from queue runs occur only when the retry time for
26832 the local address is reached.
26833
26834 .section "Changing retry rules" "SECID157"
26835 If you change the retry rules in your configuration, you should consider
26836 whether or not to delete the retry data that is stored in Exim's spool area in
26837 files with names like &_db/retry_&. Deleting any of Exim's hints files is
26838 always safe; that is why they are called &"hints"&.
26839
26840 The hints retry data contains suggested retry times based on the previous
26841 rules. In the case of a long-running problem with a remote host, it might
26842 record the fact that the host has timed out. If your new rules increase the
26843 timeout time for such a host, you should definitely remove the old retry data
26844 and let Exim recreate it, based on the new rules. Otherwise Exim might bounce
26845 messages that it should now be retaining.
26846
26847
26848
26849 .section "Format of retry rules" "SECID158"
26850 .cindex "retry" "rules"
26851 Each retry rule occupies one line and consists of three or four parts,
26852 separated by white space: a pattern, an error name, an optional list of sender
26853 addresses, and a list of retry parameters. The pattern and sender lists must be
26854 enclosed in double quotes if they contain white space. The rules are searched
26855 in order until one is found where the pattern, error name, and sender list (if
26856 present) match the failing host or address, the error that occurred, and the
26857 message's sender, respectively.
26858
26859
26860 The pattern is any single item that may appear in an address list (see section
26861 &<<SECTaddresslist>>&). It is in fact processed as a one-item address list,
26862 which means that it is expanded before being tested against the address that
26863 has been delayed. A negated address list item is permitted. Address
26864 list processing treats a plain domain name as if it were preceded by &"*@"&,
26865 which makes it possible for many retry rules to start with just a domain. For
26866 example,
26867 .code
26868 lookingglass.fict.example        *  F,24h,30m;
26869 .endd
26870 provides a rule for any address in the &'lookingglass.fict.example'& domain,
26871 whereas
26872 .code
26873 alice@lookingglass.fict.example  *  F,24h,30m;
26874 .endd
26875 applies only to temporary failures involving the local part &%alice%&.
26876 In practice, almost all rules start with a domain name pattern without a local
26877 part.
26878
26879 .cindex "regular expressions" "in retry rules"
26880 &*Warning*&: If you use a regular expression in a retry rule pattern, it
26881 must match a complete address, not just a domain, because that is how regular
26882 expressions work in address lists.
26883 .display
26884 &`^\Nxyz\d+\.abc\.example$\N        *  G,1h,10m,2`&     &%Wrong%&
26885 &`^\N[^@]+@xyz\d+\.abc\.example$\N  *  G,1h,10m,2`&     &%Right%&
26886 .endd
26887
26888
26889 .section "Choosing which retry rule to use for address errors" "SECID159"
26890 When Exim is looking for a retry rule after a routing attempt has failed (for
26891 example, after a DNS timeout), each line in the retry configuration is tested
26892 against the complete address only if &%retry_use_local_part%& is set for the
26893 router. Otherwise, only the domain is used, except when matching against a
26894 regular expression, when the local part of the address is replaced with &"*"&.
26895 A domain on its own can match a domain pattern, or a pattern that starts with
26896 &"*@"&. By default, &%retry_use_local_part%& is true for routers where
26897 &%check_local_user%& is true, and false for other routers.
26898
26899 Similarly, when Exim is looking for a retry rule after a local delivery has
26900 failed (for example, after a mailbox full error), each line in the retry
26901 configuration is tested against the complete address only if
26902 &%retry_use_local_part%& is set for the transport (it defaults true for all
26903 local transports).
26904
26905 .cindex "4&'xx'& responses" "retry rules for"
26906 However, when Exim is looking for a retry rule after a remote delivery attempt
26907 suffers an address error (a 4&'xx'& SMTP response for a recipient address), the
26908 whole address is always used as the key when searching the retry rules. The
26909 rule that is found is used to create a retry time for the combination of the
26910 failing address and the message's sender. It is the combination of sender and
26911 recipient that is delayed in subsequent queue runs until its retry time is
26912 reached. You can delay the recipient without regard to the sender by setting
26913 &%address_retry_include_sender%& false in the &(smtp)& transport but this can
26914 lead to problems with servers that regularly issue 4&'xx'& responses to RCPT
26915 commands.
26916
26917
26918
26919 .section "Choosing which retry rule to use for host and message errors" &&&
26920          "SECID160"
26921 For a temporary error that is not related to an individual address (for
26922 example, a connection timeout), each line in the retry configuration is checked
26923 twice. First, the name of the remote host is used as a domain name (preceded by
26924 &"*@"& when matching a regular expression). If this does not match the line,
26925 the domain from the email address is tried in a similar fashion. For example,
26926 suppose the MX records for &'a.b.c.example'& are
26927 .code
26928 a.b.c.example  MX  5  x.y.z.example
26929                MX  6  p.q.r.example
26930                MX  7  m.n.o.example
26931 .endd
26932 and the retry rules are
26933 .code
26934 p.q.r.example    *      F,24h,30m;
26935 a.b.c.example    *      F,4d,45m;
26936 .endd
26937 and a delivery to the host &'x.y.z.example'& suffers a connection failure. The
26938 first rule matches neither the host nor the domain, so Exim looks at the second
26939 rule. This does not match the host, but it does match the domain, so it is used
26940 to calculate the retry time for the host &'x.y.z.example'&. Meanwhile, Exim
26941 tries to deliver to &'p.q.r.example'&. If this also suffers a host error, the
26942 first retry rule is used, because it matches the host.
26943
26944 In other words, temporary failures to deliver to host &'p.q.r.example'& use the
26945 first rule to determine retry times, but for all the other hosts for the domain
26946 &'a.b.c.example'&, the second rule is used. The second rule is also used if
26947 routing to &'a.b.c.example'& suffers a temporary failure.
26948
26949 &*Note*&: The host name is used when matching the patterns, not its IP address.
26950 However, if a message is routed directly to an IP address without the use of a
26951 host name, for example, if a &(manualroute)& router contains a setting such as:
26952 .code
26953 route_list = *.a.example  192.168.34.23
26954 .endd
26955 then the &"host name"& that is used when searching for a retry rule is the
26956 textual form of the IP address.
26957
26958 .section "Retry rules for specific errors" "SECID161"
26959 .cindex "retry" "specific errors; specifying"
26960 The second field in a retry rule is the name of a particular error, or an
26961 asterisk, which matches any error. The errors that can be tested for are:
26962
26963 .vlist
26964 .vitem &%auth_failed%&
26965 Authentication failed when trying to send to a host in the
26966 &%hosts_require_auth%& list in an &(smtp)& transport.
26967
26968 .vitem &%data_4xx%&
26969 A 4&'xx'& error was received for an outgoing DATA command, either immediately
26970 after the command, or after sending the message's data.
26971
26972 .vitem &%mail_4xx%&
26973 A 4&'xx'& error was received for an outgoing MAIL command.
26974
26975 .vitem &%rcpt_4xx%&
26976 A 4&'xx'& error was received for an outgoing RCPT command.
26977 .endlist
26978
26979 For the three 4&'xx'& errors, either the first or both of the x's can be given
26980 as specific digits, for example: &`mail_45x`& or &`rcpt_436`&. For example, to
26981 recognize 452 errors given to RCPT commands for addresses in a certain domain,
26982 and have retries every ten minutes with a one-hour timeout, you could set up a
26983 retry rule of this form:
26984 .code
26985 the.domain.name  rcpt_452   F,1h,10m
26986 .endd
26987 These errors apply to both outgoing SMTP (the &(smtp)& transport) and outgoing
26988 LMTP (either the &(lmtp)& transport, or the &(smtp)& transport in LMTP mode).
26989
26990 .vlist
26991 .vitem &%lost_connection%&
26992 A server unexpectedly closed the SMTP connection. There may, of course,
26993 legitimate reasons for this (host died, network died), but if it repeats a lot
26994 for the same host, it indicates something odd.
26995
26996 .vitem &%lookup%&
26997 A DNS lookup for a host failed.
26998 Note that a &%dnslookup%& router will need to have matched
26999 its &%fail_defer_domains%& option for this retry type to be usable.
27000 Also note that a &%manualroute%& router will probably need
27001 its &%host_find_failed%& option set to &%defer%&.
27002
27003 .vitem &%refused_MX%&
27004 A connection to a host obtained from an MX record was refused.
27005
27006 .vitem &%refused_A%&
27007 A connection to a host not obtained from an MX record was refused.
27008
27009 .vitem &%refused%&
27010 A connection was refused.
27011
27012 .vitem &%timeout_connect_MX%&
27013 A connection attempt to a host obtained from an MX record timed out.
27014
27015 .vitem &%timeout_connect_A%&
27016 A connection attempt to a host not obtained from an MX record timed out.
27017
27018 .vitem &%timeout_connect%&
27019 A connection attempt timed out.
27020
27021 .vitem &%timeout_MX%&
27022 There was a timeout while connecting or during an SMTP session with a host
27023 obtained from an MX record.
27024
27025 .vitem &%timeout_A%&
27026 There was a timeout while connecting or during an SMTP session with a host not
27027 obtained from an MX record.
27028
27029 .vitem &%timeout%&
27030 There was a timeout while connecting or during an SMTP session.
27031
27032 .vitem &%tls_required%&
27033 The server was required to use TLS (it matched &%hosts_require_tls%& in the
27034 &(smtp)& transport), but either did not offer TLS, or it responded with 4&'xx'&
27035 to STARTTLS, or there was a problem setting up the TLS connection.
27036
27037 .vitem &%quota%&
27038 A mailbox quota was exceeded in a local delivery by the &(appendfile)&
27039 transport.
27040
27041 .vitem &%quota_%&<&'time'&>
27042 .cindex "quota" "error testing in retry rule"
27043 .cindex "retry" "quota error testing"
27044 A mailbox quota was exceeded in a local delivery by the &(appendfile)&
27045 transport, and the mailbox has not been accessed for <&'time'&>. For example,
27046 &'quota_4d'& applies to a quota error when the mailbox has not been accessed
27047 for four days.
27048 .endlist
27049
27050 .cindex "mailbox" "time of last read"
27051 The idea of &%quota_%&<&'time'&> is to make it possible to have shorter
27052 timeouts when the mailbox is full and is not being read by its owner. Ideally,
27053 it should be based on the last time that the user accessed the mailbox.
27054 However, it is not always possible to determine this. Exim uses the following
27055 heuristic rules:
27056
27057 .ilist
27058 If the mailbox is a single file, the time of last access (the &"atime"&) is
27059 used. As no new messages are being delivered (because the mailbox is over
27060 quota), Exim does not access the file, so this is the time of last user access.
27061 .next
27062 .cindex "maildir format" "time of last read"
27063 For a maildir delivery, the time of last modification of the &_new_&
27064 subdirectory is used. As the mailbox is over quota, no new files are created in
27065 the &_new_& subdirectory, because no new messages are being delivered. Any
27066 change to the &_new_& subdirectory is therefore assumed to be the result of an
27067 MUA moving a new message to the &_cur_& directory when it is first read. The
27068 time that is used is therefore the last time that the user read a new message.
27069 .next
27070 For other kinds of multi-file mailbox, the time of last access cannot be
27071 obtained, so a retry rule that uses this type of error field is never matched.
27072 .endlist
27073
27074 The quota errors apply both to system-enforced quotas and to Exim's own quota
27075 mechanism in the &(appendfile)& transport. The &'quota'& error also applies
27076 when a local delivery is deferred because a partition is full (the ENOSPC
27077 error).
27078
27079
27080
27081 .section "Retry rules for specified senders" "SECID162"
27082 .cindex "retry" "rules; sender-specific"
27083 You can specify retry rules that apply only when the failing message has a
27084 specific sender. In particular, this can be used to define retry rules that
27085 apply only to bounce messages. The third item in a retry rule can be of this
27086 form:
27087 .display
27088 &`senders=`&<&'address list'&>
27089 .endd
27090 The retry timings themselves are then the fourth item. For example:
27091 .code
27092 *   rcpt_4xx   senders=:   F,1h,30m
27093 .endd
27094 matches recipient 4&'xx'& errors for bounce messages sent to any address at any
27095 host. If the address list contains white space, it must be enclosed in quotes.
27096 For example:
27097 .code
27098 a.domain  rcpt_452  senders="xb.dom : yc.dom"  G,8h,10m,1.5
27099 .endd
27100 &*Warning*&: This facility can be unhelpful if it is used for host errors
27101 (which do not depend on the recipient). The reason is that the sender is used
27102 only to match the retry rule. Once the rule has been found for a host error,
27103 its contents are used to set a retry time for the host, and this will apply to
27104 all messages, not just those with specific senders.
27105
27106 When testing retry rules using &%-brt%&, you can supply a sender using the
27107 &%-f%& command line option, like this:
27108 .code
27109 exim -f "" -brt user@dom.ain
27110 .endd
27111 If you do not set &%-f%& with &%-brt%&, a retry rule that contains a senders
27112 list is never matched.
27113
27114
27115
27116
27117
27118 .section "Retry parameters" "SECID163"
27119 .cindex "retry" "parameters in rules"
27120 The third (or fourth, if a senders list is present) field in a retry rule is a
27121 sequence of retry parameter sets, separated by semicolons. Each set consists of
27122 .display
27123 <&'letter'&>,<&'cutoff time'&>,<&'arguments'&>
27124 .endd
27125 The letter identifies the algorithm for computing a new retry time; the cutoff
27126 time is the time beyond which this algorithm no longer applies, and the
27127 arguments vary the algorithm's action. The cutoff time is measured from the
27128 time that the first failure for the domain (combined with the local part if
27129 relevant) was detected, not from the time the message was received.
27130
27131 .cindex "retry" "algorithms"
27132 .cindex "retry" "fixed intervals"
27133 .cindex "retry" "increasing intervals"
27134 .cindex "retry" "random intervals"
27135 The available algorithms are:
27136
27137 .ilist
27138 &'F'&: retry at fixed intervals. There is a single time parameter specifying
27139 the interval.
27140 .next
27141 &'G'&: retry at geometrically increasing intervals. The first argument
27142 specifies a starting value for the interval, and the second a multiplier, which
27143 is used to increase the size of the interval at each retry.
27144 .next
27145 &'H'&: retry at randomized intervals. The arguments are as for &'G'&. For each
27146 retry, the previous interval is multiplied by the factor in order to get a
27147 maximum for the next interval. The minimum interval is the first argument of
27148 the parameter, and an actual interval is chosen randomly between them. Such a
27149 rule has been found to be helpful in cluster configurations when all the
27150 members of the cluster restart at once, and may therefore synchronize their
27151 queue processing times.
27152 .endlist
27153
27154 When computing the next retry time, the algorithm definitions are scanned in
27155 order until one whose cutoff time has not yet passed is reached. This is then
27156 used to compute a new retry time that is later than the current time. In the
27157 case of fixed interval retries, this simply means adding the interval to the
27158 current time. For geometrically increasing intervals, retry intervals are
27159 computed from the rule's parameters until one that is greater than the previous
27160 interval is found. The main configuration variable
27161 .cindex "limit" "retry interval"
27162 .cindex "retry" "interval, maximum"
27163 .oindex "&%retry_interval_max%&"
27164 &%retry_interval_max%& limits the maximum interval between retries. It
27165 cannot be set greater than &`24h`&, which is its default value.
27166
27167 A single remote domain may have a number of hosts associated with it, and each
27168 host may have more than one IP address. Retry algorithms are selected on the
27169 basis of the domain name, but are applied to each IP address independently. If,
27170 for example, a host has two IP addresses and one is unusable, Exim will
27171 generate retry times for it and will not try to use it until its next retry
27172 time comes. Thus the good IP address is likely to be tried first most of the
27173 time.
27174
27175 .cindex "hints database" "use for retrying"
27176 Retry times are hints rather than promises. Exim does not make any attempt to
27177 run deliveries exactly at the computed times. Instead, a queue runner process
27178 starts delivery processes for delayed messages periodically, and these attempt
27179 new deliveries only for those addresses that have passed their next retry time.
27180 If a new message arrives for a deferred address, an immediate delivery attempt
27181 occurs only if the address has passed its retry time. In the absence of new
27182 messages, the minimum time between retries is the interval between queue runner
27183 processes. There is not much point in setting retry times of five minutes if
27184 your queue runners happen only once an hour, unless there are a significant
27185 number of incoming messages (which might be the case on a system that is
27186 sending everything to a smart host, for example).
27187
27188 The data in the retry hints database can be inspected by using the
27189 &'exim_dumpdb'& or &'exim_fixdb'& utility programs (see chapter
27190 &<<CHAPutils>>&). The latter utility can also be used to change the data. The
27191 &'exinext'& utility script can be used to find out what the next retry times
27192 are for the hosts associated with a particular mail domain, and also for local
27193 deliveries that have been deferred.
27194
27195
27196 .section "Retry rule examples" "SECID164"
27197 Here are some example retry rules:
27198 .code
27199 alice@wonderland.fict.example quota_5d  F,7d,3h
27200 wonderland.fict.example       quota_5d
27201 wonderland.fict.example       *         F,1h,15m; G,2d,1h,2;
27202 lookingglass.fict.example     *         F,24h,30m;
27203 *                 refused_A   F,2h,20m;
27204 *                 *           F,2h,15m; G,16h,1h,1.5; F,5d,8h
27205 .endd
27206 The first rule sets up special handling for mail to
27207 &'alice@wonderland.fict.example'& when there is an over-quota error and the
27208 mailbox has not been read for at least 5 days. Retries continue every three
27209 hours for 7 days. The second rule handles over-quota errors for all other local
27210 parts at &'wonderland.fict.example'&; the absence of a local part has the same
27211 effect as supplying &"*@"&. As no retry algorithms are supplied, messages that
27212 fail are bounced immediately if the mailbox has not been read for at least 5
27213 days.
27214
27215 The third rule handles all other errors at &'wonderland.fict.example'&; retries
27216 happen every 15 minutes for an hour, then with geometrically increasing
27217 intervals until two days have passed since a delivery first failed. After the
27218 first hour there is a delay of one hour, then two hours, then four hours, and
27219 so on (this is a rather extreme example).
27220
27221 The fourth rule controls retries for the domain &'lookingglass.fict.example'&.
27222 They happen every 30 minutes for 24 hours only. The remaining two rules handle
27223 all other domains, with special action for connection refusal from hosts that
27224 were not obtained from an MX record.
27225
27226 The final rule in a retry configuration should always have asterisks in the
27227 first two fields so as to provide a general catch-all for any addresses that do
27228 not have their own special handling. This example tries every 15 minutes for 2
27229 hours, then with intervals starting at one hour and increasing by a factor of
27230 1.5 up to 16 hours, then every 8 hours up to 5 days.
27231
27232
27233
27234 .section "Timeout of retry data" "SECID165"
27235 .cindex "timeout" "of retry data"
27236 .oindex "&%retry_data_expire%&"
27237 .cindex "hints database" "data expiry"
27238 .cindex "retry" "timeout of data"
27239 Exim timestamps the data that it writes to its retry hints database. When it
27240 consults the data during a delivery it ignores any that is older than the value
27241 set in &%retry_data_expire%& (default 7 days). If, for example, a host hasn't
27242 been tried for 7 days, Exim will try to deliver to it immediately a message
27243 arrives, and if that fails, it will calculate a retry time as if it were
27244 failing for the first time.
27245
27246 This improves the behaviour for messages routed to rarely-used hosts such as MX
27247 backups. If such a host was down at one time, and happens to be down again when
27248 Exim tries a month later, using the old retry data would imply that it had been
27249 down all the time, which is not a justified assumption.
27250
27251 If a host really is permanently dead, this behaviour causes a burst of retries
27252 every now and again, but only if messages routed to it are rare. If there is a
27253 message at least once every 7 days the retry data never expires.
27254
27255
27256
27257
27258 .section "Long-term failures" "SECID166"
27259 .cindex "delivery failure, long-term"
27260 .cindex "retry" "after long-term failure"
27261 Special processing happens when an email address has been failing for so long
27262 that the cutoff time for the last algorithm is reached. For example, using the
27263 default retry rule:
27264 .code
27265 * * F,2h,15m; G,16h,1h,1.5; F,4d,6h
27266 .endd
27267 the cutoff time is four days. Reaching the retry cutoff is independent of how
27268 long any specific message has been failing; it is the length of continuous
27269 failure for the recipient address that counts.
27270
27271 When the cutoff time is reached for a local delivery, or for all the IP
27272 addresses associated with a remote delivery, a subsequent delivery failure
27273 causes Exim to give up on the address, and a bounce message is generated.
27274 In order to cater for new messages that use the failing address, a next retry
27275 time is still computed from the final algorithm, and is used as follows:
27276
27277 For local deliveries, one delivery attempt is always made for any subsequent
27278 messages. If this delivery fails, the address fails immediately. The
27279 post-cutoff retry time is not used.
27280
27281 .cindex "final cutoff" "retries, controlling"
27282 .cindex retry "final cutoff"
27283 If the delivery is remote, there are two possibilities, controlled by the
27284 .oindex "&%delay_after_cutoff%&"
27285 &%delay_after_cutoff%& option of the &(smtp)& transport. The option is true by
27286 default. Until the post-cutoff retry time for one of the IP addresses,
27287 as set by the &%retry_data_expire%& option, is
27288 reached, the failing email address is bounced immediately, without a delivery
27289 attempt taking place. After that time, one new delivery attempt is made to
27290 those IP addresses that are past their retry times, and if that still fails,
27291 the address is bounced and new retry times are computed.
27292
27293 In other words, when all the hosts for a given email address have been failing
27294 for a long time, Exim bounces rather then defers until one of the hosts' retry
27295 times is reached. Then it tries once, and bounces if that attempt fails. This
27296 behaviour ensures that few resources are wasted in repeatedly trying to deliver
27297 to a broken destination, but if the host does recover, Exim will eventually
27298 notice.
27299
27300 If &%delay_after_cutoff%& is set false, Exim behaves differently. If all IP
27301 addresses are past their final cutoff time, Exim tries to deliver to those IP
27302 addresses that have not been tried since the message arrived. If there are
27303 no suitable IP addresses, or if they all fail, the address is bounced. In other
27304 words, it does not delay when a new message arrives, but tries the expired
27305 addresses immediately, unless they have been tried since the message arrived.
27306 If there is a continuous stream of messages for the failing domains, setting
27307 &%delay_after_cutoff%& false means that there will be many more attempts to
27308 deliver to permanently failing IP addresses than when &%delay_after_cutoff%& is
27309 true.
27310
27311 .section "Deliveries that work intermittently" "SECID167"
27312 .cindex "retry" "intermittently working deliveries"
27313 Some additional logic is needed to cope with cases where a host is
27314 intermittently available, or when a message has some attribute that prevents
27315 its delivery when others to the same address get through. In this situation,
27316 because some messages are successfully delivered, the &"retry clock"& for the
27317 host or address keeps getting reset by the successful deliveries, and so
27318 failing messages remain in the queue for ever because the cutoff time is never
27319 reached.
27320
27321 Two exceptional actions are applied to prevent this happening. The first
27322 applies to errors that are related to a message rather than a remote host.
27323 Section &<<SECToutSMTPerr>>& has a discussion of the different kinds of error;
27324 examples of message-related errors are 4&'xx'& responses to MAIL or DATA
27325 commands, and quota failures. For this type of error, if a message's arrival
27326 time is earlier than the &"first failed"& time for the error, the earlier time
27327 is used when scanning the retry rules to decide when to try next and when to
27328 time out the address.
27329
27330 The exceptional second action applies in all cases. If a message has been on
27331 the queue for longer than the cutoff time of any applicable retry rule for a
27332 given address, a delivery is attempted for that address, even if it is not yet
27333 time, and if this delivery fails, the address is timed out. A new retry time is
27334 not computed in this case, so that other messages for the same address are
27335 considered immediately.
27336 .ecindex IIDretconf1
27337 .ecindex IIDregconf2
27338
27339
27340
27341
27342
27343
27344 . ////////////////////////////////////////////////////////////////////////////
27345 . ////////////////////////////////////////////////////////////////////////////
27346
27347 .chapter "SMTP authentication" "CHAPSMTPAUTH"
27348 .scindex IIDauthconf1 "SMTP" "authentication configuration"
27349 .scindex IIDauthconf2 "authentication"
27350 The &"authenticators"& section of Exim's runtime configuration is concerned
27351 with SMTP authentication. This facility is an extension to the SMTP protocol,
27352 described in RFC 2554, which allows a client SMTP host to authenticate itself
27353 to a server. This is a common way for a server to recognize clients that are
27354 permitted to use it as a relay. SMTP authentication is not of relevance to the
27355 transfer of mail between servers that have no managerial connection with each
27356 other.
27357
27358 The name of an authenticator is limited to be &drivernamemax; ASCII characters long;
27359 prior to Exim 4.95 names would be silently truncated at this length, but now
27360 it is enforced.
27361
27362 .cindex "AUTH" "description of"
27363 .cindex "ESMTP extensions" AUTH
27364 Very briefly, the way SMTP authentication works is as follows:
27365
27366 .olist
27367 The server advertises a number of authentication &'mechanisms'& in response to
27368 the client's EHLO command.
27369 .next
27370 The client issues an AUTH command, naming a specific mechanism. The command
27371 may, optionally, contain some authentication data.
27372 .next
27373 The server may issue one or more &'challenges'&, to which the client must send
27374 appropriate responses. In simple authentication mechanisms, the challenges are
27375 just prompts for user names and passwords. The server does not have to issue
27376 any challenges &-- in some mechanisms the relevant data may all be transmitted
27377 with the AUTH command.
27378 .next
27379 The server either accepts or denies authentication.
27380 .next
27381 If authentication succeeds, the client may optionally make use of the AUTH
27382 option on the MAIL command to pass an authenticated sender in subsequent
27383 mail transactions. Authentication lasts for the remainder of the SMTP
27384 connection.
27385 .next
27386 If authentication fails, the client may give up, or it may try a different
27387 authentication mechanism, or it may try transferring mail over the
27388 unauthenticated connection.
27389 .endlist
27390
27391 If you are setting up a client, and want to know which authentication
27392 mechanisms the server supports, you can use Telnet to connect to port 25 (the
27393 SMTP port) on the server, and issue an EHLO command. The response to this
27394 includes the list of supported mechanisms. For example:
27395 .display
27396 &`$ `&&*&`telnet server.example 25`&*&
27397 &`Trying 192.168.34.25...`&
27398 &`Connected to server.example.`&
27399 &`Escape character is &#x0027;^]&#x0027;.`&
27400 &`220 server.example ESMTP Exim 4.20 ...`&
27401 &*&`ehlo client.example`&*&
27402 &`250-server.example Hello client.example [10.8.4.5]`&
27403 &`250-SIZE 52428800`&
27404 &`250-PIPELINING`&
27405 &`250-AUTH PLAIN`&
27406 &`250 HELP`&
27407 .endd
27408 The second-last line of this example output shows that the server supports
27409 authentication using the PLAIN mechanism. In Exim, the different authentication
27410 mechanisms are configured by specifying &'authenticator'& drivers. Like the
27411 routers and transports, which authenticators are included in the binary is
27412 controlled by build-time definitions. The following are currently available,
27413 included by setting
27414 .code
27415 AUTH_CRAM_MD5=yes
27416 AUTH_CYRUS_SASL=yes
27417 AUTH_DOVECOT=yes
27418 AUTH_EXTERNAL=yes
27419 AUTH_GSASL=yes
27420 AUTH_HEIMDAL_GSSAPI=yes
27421 AUTH_PLAINTEXT=yes
27422 AUTH_SPA=yes
27423 AUTH_TLS=yes
27424 .endd
27425 in &_Local/Makefile_&, respectively. The first of these supports the CRAM-MD5
27426 authentication mechanism (RFC 2195), and the second provides an interface to
27427 the Cyrus SASL authentication library.
27428 The third is an interface to Dovecot's authentication system, delegating the
27429 work via a socket interface.
27430 The fourth provides for negotiation of authentication done via non-SMTP means,
27431 as defined by RFC 4422 Appendix A.
27432 The fifth provides an interface to the GNU SASL authentication library, which
27433 provides mechanisms but typically not data sources.
27434 The sixth provides direct access to Heimdal GSSAPI, geared for Kerberos, but
27435 supporting setting a server keytab.
27436 The seventh can be configured to support
27437 the PLAIN authentication mechanism (RFC 2595) or the LOGIN mechanism, which is
27438 not formally documented, but used by several MUAs.
27439 The eighth authenticator
27440 supports Microsoft's &'Secure Password Authentication'& mechanism.
27441 The last is an Exim authenticator but not an SMTP one;
27442 instead it can use information from a TLS negotiation.
27443
27444 The authenticators are configured using the same syntax as other drivers (see
27445 section &<<SECTfordricon>>&). If no authenticators are required, no
27446 authentication section need be present in the configuration file. Each
27447 authenticator can in principle have both server and client functions. When Exim
27448 is receiving SMTP mail, it is acting as a server; when it is sending out
27449 messages over SMTP, it is acting as a client. Authenticator configuration
27450 options are provided for use in both these circumstances.
27451
27452 To make it clear which options apply to which situation, the prefixes
27453 &%server_%& and &%client_%& are used on option names that are specific to
27454 either the server or the client function, respectively. Server and client
27455 functions are disabled if none of their options are set. If an authenticator is
27456 to be used for both server and client functions, a single definition, using
27457 both sets of options, is required. For example:
27458 .code
27459 cram:
27460   driver = cram_md5
27461   public_name = CRAM-MD5
27462   server_secret = ${if eq{$auth1}{ph10}{secret1}fail}
27463   client_name = ph10
27464   client_secret = secret2
27465 .endd
27466 The &%server_%& option is used when Exim is acting as a server, and the
27467 &%client_%& options when it is acting as a client.
27468
27469 Descriptions of the individual authenticators are given in subsequent chapters.
27470 The remainder of this chapter covers the generic options for the
27471 authenticators, followed by general discussion of the way authentication works
27472 in Exim.
27473
27474 &*Beware:*& the meaning of &$auth1$&, &$auth2$&, ... varies on a per-driver and
27475 per-mechanism basis.  Please read carefully to determine which variables hold
27476 account labels such as usercodes and which hold passwords or other
27477 authenticating data.
27478
27479 Note that some mechanisms support two different identifiers for accounts: the
27480 &'authentication id'& and the &'authorization id'&.  The contractions &'authn'&
27481 and &'authz'& are commonly encountered.  The American spelling is standard here.
27482 Conceptually, authentication data such as passwords are tied to the identifier
27483 used to authenticate; servers may have rules to permit one user to act as a
27484 second user, so that after login the session is treated as though that second
27485 user had logged in.  That second user is the &'authorization id'&.  A robust
27486 configuration might confirm that the &'authz'& field is empty or matches the
27487 &'authn'& field.  Often this is just ignored.  The &'authn'& can be considered
27488 as verified data, the &'authz'& as an unverified request which the server might
27489 choose to honour.
27490
27491 A &'realm'& is a text string, typically a domain name, presented by a server
27492 to a client to help it select an account and credentials to use.  In some
27493 mechanisms, the client and server provably agree on the realm, but clients
27494 typically can not treat the realm as secure data to be blindly trusted.
27495
27496
27497
27498 .section "Generic options for authenticators" "SECID168"
27499 .cindex "authentication" "generic options"
27500 .cindex "options" "generic; for authenticators"
27501
27502 .option client_condition authenticators string&!! unset
27503 When Exim is authenticating as a client, it skips any authenticator whose
27504 &%client_condition%& expansion yields &"0"&, &"no"&, or &"false"&. This can be
27505 used, for example, to skip plain text authenticators when the connection is not
27506 encrypted by a setting such as:
27507 .code
27508 client_condition = ${if !eq{$tls_out_cipher}{}}
27509 .endd
27510
27511
27512 .option client_set_id authenticators string&!! unset
27513 When client authentication succeeds, this condition is expanded; the
27514 result is used in the log lines for outbound messages.
27515 Typically it will be the user name used for authentication.
27516
27517
27518 .option driver authenticators string unset
27519 This option must always be set. It specifies which of the available
27520 authenticators is to be used.
27521
27522
27523 .option public_name authenticators string unset
27524 This option specifies the name of the authentication mechanism that the driver
27525 implements, and by which it is known to the outside world. These names should
27526 contain only upper case letters, digits, underscores, and hyphens (RFC 2222),
27527 but Exim in fact matches them caselessly. If &%public_name%& is not set, it
27528 defaults to the driver's instance name.
27529
27530
27531 .option server_advertise_condition authenticators string&!! unset
27532 When a server is about to advertise an authentication mechanism, the condition
27533 is expanded. If it yields the empty string, &"0"&, &"no"&, or &"false"&, the
27534 mechanism is not advertised.
27535 If the expansion fails, the mechanism is not advertised. If the failure was not
27536 forced, and was not caused by a lookup defer, the incident is logged.
27537 See section &<<SECTauthexiser>>& below for further discussion.
27538
27539
27540 .option server_condition authenticators string&!! unset
27541 This option must be set for a &%plaintext%& server authenticator, where it
27542 is used directly to control authentication. See section &<<SECTplainserver>>&
27543 for details.
27544
27545 For the &(gsasl)& authenticator, this option is required for various
27546 mechanisms; see chapter &<<CHAPgsasl>>& for details.
27547
27548 For the other authenticators, &%server_condition%& can be used as an additional
27549 authentication or authorization mechanism that is applied after the other
27550 authenticator conditions succeed. If it is set, it is expanded when the
27551 authenticator would otherwise return a success code. If the expansion is forced
27552 to fail, authentication fails. Any other expansion failure causes a temporary
27553 error code to be returned. If the result of a successful expansion is an empty
27554 string, &"0"&, &"no"&, or &"false"&, authentication fails. If the result of the
27555 expansion is &"1"&, &"yes"&, or &"true"&, authentication succeeds. For any
27556 other result, a temporary error code is returned, with the expanded string as
27557 the error text.
27558
27559
27560 .option server_debug_print authenticators string&!! unset
27561 If this option is set and authentication debugging is enabled (see the &%-d%&
27562 command line option), the string is expanded and included in the debugging
27563 output when the authenticator is run as a server. This can help with checking
27564 out the values of variables.
27565 If expansion of the string fails, the error message is written to the debugging
27566 output, and Exim carries on processing.
27567
27568
27569 .option server_set_id authenticators string&!! unset
27570 .vindex "&$authenticated_id$&"
27571 .vindex "&$authenticated_fail_id$&"
27572 When an Exim server successfully authenticates a client, this string is
27573 expanded using data from the authentication, and preserved for any incoming
27574 messages in the variable &$authenticated_id$&. It is also included in the log
27575 lines for incoming messages. For example, a user/password authenticator
27576 configuration might preserve the user name that was used to authenticate, and
27577 refer to it subsequently during delivery of the message.
27578 On a failing authentication the expansion result is instead saved in
27579 the &$authenticated_fail_id$& variable.
27580 If expansion fails, the option is ignored.
27581
27582
27583 .option server_mail_auth_condition authenticators string&!! unset
27584 This option allows a server to discard authenticated sender addresses supplied
27585 as part of MAIL commands in SMTP connections that are authenticated by the
27586 driver on which &%server_mail_auth_condition%& is set. The option is not used
27587 as part of the authentication process; instead its (unexpanded) value is
27588 remembered for later use.
27589 How it is used is described in the following section.
27590
27591
27592
27593
27594
27595 .section "The AUTH parameter on MAIL commands" "SECTauthparamail"
27596 .cindex "authentication" "sender; authenticated"
27597 .cindex "AUTH" "on MAIL command"
27598 When a client supplied an AUTH= item on a MAIL command, Exim applies
27599 the following checks before accepting it as the authenticated sender of the
27600 message:
27601
27602 .ilist
27603 If the connection is not using extended SMTP (that is, HELO was used rather
27604 than EHLO), the use of AUTH= is a syntax error.
27605 .next
27606 If the value of the AUTH= parameter is &"<>"&, it is ignored.
27607 .next
27608 .vindex "&$authenticated_sender$&"
27609 If &%acl_smtp_mailauth%& is defined, the ACL it specifies is run. While it is
27610 running, the value of &$authenticated_sender$& is set to the value obtained
27611 from the AUTH= parameter. If the ACL does not yield &"accept"&, the value of
27612 &$authenticated_sender$& is deleted. The &%acl_smtp_mailauth%& ACL may not
27613 return &"drop"& or &"discard"&. If it defers, a temporary error code (451) is
27614 given for the MAIL command.
27615 .next
27616 If &%acl_smtp_mailauth%& is not defined, the value of the AUTH= parameter
27617 is accepted and placed in &$authenticated_sender$& only if the client has
27618 authenticated.
27619 .next
27620 If the AUTH= value was accepted by either of the two previous rules, and
27621 the client has authenticated, and the authenticator has a setting for the
27622 &%server_mail_auth_condition%&, the condition is checked at this point. The
27623 valued that was saved from the authenticator is expanded. If the expansion
27624 fails, or yields an empty string, &"0"&, &"no"&, or &"false"&, the value of
27625 &$authenticated_sender$& is deleted. If the expansion yields any other value,
27626 the value of &$authenticated_sender$& is retained and passed on with the
27627 message.
27628 .endlist
27629
27630
27631 When &$authenticated_sender$& is set for a message, it is passed on to other
27632 hosts to which Exim authenticates as a client. Do not confuse this value with
27633 &$authenticated_id$&, which is a string obtained from the authentication
27634 process, and which is not usually a complete email address.
27635
27636 .vindex "&$sender_address$&"
27637 Whenever an AUTH= value is ignored, the incident is logged. The ACL for
27638 MAIL, if defined, is run after AUTH= is accepted or ignored. It can
27639 therefore make use of &$authenticated_sender$&. The converse is not true: the
27640 value of &$sender_address$& is not yet set up when the &%acl_smtp_mailauth%&
27641 ACL is run.
27642
27643
27644
27645 .section "Authentication on an Exim server" "SECTauthexiser"
27646 .cindex "authentication" "on an Exim server"
27647 When Exim receives an EHLO command, it advertises the public names of those
27648 authenticators that are configured as servers, subject to the following
27649 conditions:
27650
27651 .ilist
27652 The client host must match &%auth_advertise_hosts%& (default *).
27653 .next
27654 If the &%server_advertise_condition%& option is set, its expansion must not
27655 yield the empty string, &"0"&, &"no"&, or &"false"&.
27656 .endlist
27657
27658 The order in which the authenticators are defined controls the order in which
27659 the mechanisms are advertised.
27660
27661 Some mail clients (for example, some versions of Netscape) require the user to
27662 provide a name and password for authentication whenever AUTH is advertised,
27663 even though authentication may not in fact be needed (for example, Exim may be
27664 set up to allow unconditional relaying from the client by an IP address check).
27665 You can make such clients more friendly by not advertising AUTH to them.
27666 For example, if clients on the 10.9.8.0/24 network are permitted (by the ACL
27667 that runs for RCPT) to relay without authentication, you should set
27668 .code
27669 auth_advertise_hosts = ! 10.9.8.0/24
27670 .endd
27671 so that no authentication mechanisms are advertised to them.
27672
27673 The &%server_advertise_condition%& controls the advertisement of individual
27674 authentication mechanisms. For example, it can be used to restrict the
27675 advertisement of a particular mechanism to encrypted connections, by a setting
27676 such as:
27677 .code
27678 server_advertise_condition = ${if eq{$tls_in_cipher}{}{no}{yes}}
27679 .endd
27680 .vindex "&$tls_in_cipher$&"
27681 If the session is encrypted, &$tls_in_cipher$& is not empty, and so the expansion
27682 yields &"yes"&, which allows the advertisement to happen.
27683
27684 When an Exim server receives an AUTH command from a client, it rejects it
27685 immediately if AUTH was not advertised in response to an earlier EHLO
27686 command. This is the case if
27687
27688 .ilist
27689 The client host does not match &%auth_advertise_hosts%&; or
27690 .next
27691 No authenticators are configured with server options; or
27692 .next
27693 Expansion of &%server_advertise_condition%& blocked the advertising of all the
27694 server authenticators.
27695 .endlist
27696
27697
27698 Otherwise, Exim runs the ACL specified by &%acl_smtp_auth%& in order
27699 to decide whether to accept the command. If &%acl_smtp_auth%& is not set,
27700 AUTH is accepted from any client host.
27701
27702 If AUTH is not rejected by the ACL, Exim searches its configuration for a
27703 server authentication mechanism that was advertised in response to EHLO and
27704 that matches the one named in the AUTH command. If it finds one, it runs
27705 the appropriate authentication protocol, and authentication either succeeds or
27706 fails. If there is no matching advertised mechanism, the AUTH command is
27707 rejected with a 504 error.
27708
27709 .vindex "&$received_protocol$&"
27710 .vindex "&$sender_host_authenticated$&"
27711 When a message is received from an authenticated host, the value of
27712 &$received_protocol$& is set to &"esmtpa"& or &"esmtpsa"& instead of &"esmtp"&
27713 or &"esmtps"&, and &$sender_host_authenticated$& contains the name (not the
27714 public name) of the authenticator driver that successfully authenticated the
27715 client from which the message was received. This variable is empty if there was
27716 no successful authentication.
27717
27718 .cindex authentication "expansion item"
27719 Successful authentication sets up information used by the
27720 &%authresults%& expansion item.
27721
27722 .cindex authentication "failure event, server"
27723 If an authenticator is run and does not succeed,
27724 an event (see &<<CHAPevents>>&) of type "auth:fail" is raised.
27725 While the event is being processed the variables
27726 &$sender_host_authenticated$& (with the authenticator name)
27727 and &$authenticated_fail_id$& (as set by the authenticator &%server_set_id%& option)
27728 will be valid.
27729 If the event is serviced and a string is returned then the string will be logged
27730 instead of the default log line.
27731 See <<CHAPevents>> for details on events.
27732
27733
27734 .section "Testing server authentication" "SECID169"
27735 .cindex "authentication" "testing a server"
27736 .cindex "AUTH" "testing a server"
27737 .cindex "base64 encoding" "creating authentication test data"
27738 Exim's &%-bh%& option can be useful for testing server authentication
27739 configurations. The data for the AUTH command has to be sent using base64
27740 encoding. A quick way to produce such data for testing is the following Perl
27741 script:
27742 .code
27743 use MIME::Base64;
27744 printf ("%s", encode_base64(eval "\"$ARGV[0]\""));
27745 .endd
27746 .cindex "binary zero" "in authentication data"
27747 This interprets its argument as a Perl string, and then encodes it. The
27748 interpretation as a Perl string allows binary zeros, which are required for
27749 some kinds of authentication, to be included in the data. For example, a
27750 command line to run this script on such data might be
27751 .code
27752 encode '\0user\0password'
27753 .endd
27754 Note the use of single quotes to prevent the shell interpreting the
27755 backslashes, so that they can be interpreted by Perl to specify characters
27756 whose code value is zero.
27757
27758 &*Warning 1*&: If either of the user or password strings starts with an octal
27759 digit, you must use three zeros instead of one after the leading backslash. If
27760 you do not, the octal digit that starts your string will be incorrectly
27761 interpreted as part of the code for the first character.
27762
27763 &*Warning 2*&: If there are characters in the strings that Perl interprets
27764 specially, you must use a Perl escape to prevent them being misinterpreted. For
27765 example, a command such as
27766 .code
27767 encode '\0user@domain.com\0pas$$word'
27768 .endd
27769 gives an incorrect answer because of the unescaped &"@"& and &"$"& characters.
27770
27771 If you have the &%mimencode%& command installed, another way to produce
27772 base64-encoded strings is to run the command
27773 .code
27774 echo -e -n `\0user\0password' | mimencode
27775 .endd
27776 The &%-e%& option of &%echo%& enables the interpretation of backslash escapes
27777 in the argument, and the &%-n%& option specifies no newline at the end of its
27778 output. However, not all versions of &%echo%& recognize these options, so you
27779 should check your version before relying on this suggestion.
27780
27781
27782
27783 .section "Authentication by an Exim client" "SECID170"
27784 .cindex "authentication" "on an Exim client"
27785 The &(smtp)& transport has two options called &%hosts_require_auth%& and
27786 &%hosts_try_auth%&. When the &(smtp)& transport connects to a server that
27787 announces support for authentication, and the host matches an entry in either
27788 of these options, Exim (as a client) tries to authenticate as follows:
27789
27790 .ilist
27791 For each authenticator that is configured as a client, in the order in which
27792 they are defined in the configuration, it searches the authentication
27793 mechanisms announced by the server for one whose name matches the public name
27794 of the authenticator.
27795 .next
27796 .vindex "&$host$&"
27797 .vindex "&$host_address$&"
27798 When it finds one that matches, it runs the authenticator's client code. The
27799 variables &$host$& and &$host_address$& are available for any string expansions
27800 that the client might do. They are set to the server's name and IP address. If
27801 any expansion is forced to fail, the authentication attempt is abandoned, and
27802 Exim moves on to the next authenticator. Otherwise an expansion failure causes
27803 delivery to be deferred.
27804 .next
27805 If the result of the authentication attempt is a temporary error or a timeout,
27806 Exim abandons trying to send the message to the host for the moment. It will
27807 try again later. If there are any backup hosts available, they are tried in the
27808 usual way.
27809
27810 .next
27811 .cindex authentication "failure event, client"
27812 If the response to authentication is a permanent error (5&'xx'& code),
27813 an event (see &<<CHAPevents>>&) of type "auth:fail" is raised.
27814 While the event is being processed the variable
27815 &$sender_host_authenticated$& (with the authenticator name)
27816 will be valid.
27817 If the event is serviced and a string is returned then the string will be logged.
27818 See <<CHAPevents>> for details on events.
27819
27820 .next
27821 If the response to authentication is a permanent error (5&'xx'& code), Exim
27822 carries on searching the list of authenticators and tries another one if
27823 possible. If all authentication attempts give permanent errors, or if there are
27824 no attempts because no mechanisms match (or option expansions force failure),
27825 what happens depends on whether the host matches &%hosts_require_auth%& or
27826 &%hosts_try_auth%&. In the first case, a temporary error is generated, and
27827 delivery is deferred. The error can be detected in the retry rules, and thereby
27828 turned into a permanent error if you wish. In the second case, Exim tries to
27829 deliver the message unauthenticated.
27830 .endlist
27831
27832 Note that the hostlist test for whether to do authentication can be
27833 confused if name-IP lookups change between the time the peer is decided
27834 upon and the time that the transport runs.  For example, with a manualroute
27835 router given a host name, and with DNS "round-robin" used by that name: if
27836 the local resolver cache times out between the router and the transport
27837 running, the transport may get an IP for the name for its authentication
27838 check which does not match the connection peer IP.
27839 No authentication will then be done, despite the names being identical.
27840
27841 For such cases use a separate transport which always authenticates.
27842
27843 .cindex "AUTH" "on MAIL command"
27844 When Exim has authenticated itself to a remote server, it adds the AUTH
27845 parameter to the MAIL commands it sends, if it has an authenticated sender for
27846 the message. If the message came from a remote host, the authenticated sender
27847 is the one that was receiving on an incoming MAIL command, provided that the
27848 incoming connection was authenticated and the &%server_mail_auth%& condition
27849 allowed the authenticated sender to be retained. If a local process calls Exim
27850 to send a message, the sender address that is built from the login name and
27851 &%qualify_domain%& is treated as authenticated. However, if the
27852 &%authenticated_sender%& option is set on the &(smtp)& transport, it overrides
27853 the authenticated sender that was received with the message.
27854 .ecindex IIDauthconf1
27855 .ecindex IIDauthconf2
27856
27857
27858
27859
27860
27861
27862 . ////////////////////////////////////////////////////////////////////////////
27863 . ////////////////////////////////////////////////////////////////////////////
27864
27865 .chapter "The plaintext authenticator" "CHAPplaintext"
27866 .scindex IIDplaiauth1 "&(plaintext)& authenticator"
27867 .scindex IIDplaiauth2 "authenticators" "&(plaintext)&"
27868 The &(plaintext)& authenticator can be configured to support the PLAIN and
27869 LOGIN authentication mechanisms, both of which transfer authentication data as
27870 plain (unencrypted) text (though base64 encoded). The use of plain text is a
27871 security risk; you are strongly advised to insist on the use of SMTP encryption
27872 (see chapter &<<CHAPTLS>>&) if you use the PLAIN or LOGIN mechanisms. If you do
27873 use unencrypted plain text, you should not use the same passwords for SMTP
27874 connections as you do for login accounts.
27875
27876 .section "Avoiding cleartext use" "SECTplain_TLS"
27877 The following generic option settings will disable &(plaintext)& authenticators when
27878 TLS is not being used:
27879 .code
27880   server_advertise_condition = ${if def:tls_in_cipher }
27881   client_condition =           ${if def:tls_out_cipher}
27882 .endd
27883
27884 &*Note*&: a plaintext SMTP AUTH done inside TLS is not vulnerable to casual snooping,
27885 but is still vulnerable to a Man In The Middle attack unless certificates
27886 (including their names) have been properly verified.
27887
27888 .section "Plaintext server options" "SECID171"
27889 .cindex "options" "&(plaintext)& authenticator (server)"
27890 When configured as a server, &(plaintext)& uses the following options:
27891
27892 .option server_condition authenticators string&!! unset
27893 This is actually a global authentication option, but it must be set in order to
27894 configure the &(plaintext)& driver as a server. Its use is described below.
27895
27896 .option server_prompts plaintext "string list&!!" unset
27897 The contents of this option, after expansion, must be a colon-separated list of
27898 prompt strings. If expansion fails, a temporary authentication rejection is
27899 given.
27900
27901 .section "Using plaintext in a server" "SECTplainserver"
27902 .cindex "AUTH" "in &(plaintext)& authenticator"
27903 .cindex "binary zero" "in &(plaintext)& authenticator"
27904 .cindex "numerical variables (&$1$& &$2$& etc)" &&&
27905         "in &(plaintext)& authenticator"
27906 .vindex "&$auth1$&, &$auth2$&, etc"
27907 .cindex "base64 encoding" "in &(plaintext)& authenticator"
27908
27909 When running as a server, &(plaintext)& performs the authentication test by
27910 expanding a string. The data sent by the client with the AUTH command, or in
27911 response to subsequent prompts, is base64 encoded, and so may contain any byte
27912 values when decoded. If any data is supplied with the command, it is treated as
27913 a list of strings, separated by NULs (binary zeros), the first three of which
27914 are placed in the expansion variables &$auth1$&, &$auth2$&, and &$auth3$&
27915 (neither LOGIN nor PLAIN uses more than three strings).
27916
27917 For compatibility with previous releases of Exim, the values are also placed in
27918 the expansion variables &$1$&, &$2$&, and &$3$&. However, the use of these
27919 variables for this purpose is now deprecated, as it can lead to confusion in
27920 string expansions that also use them for other things.
27921
27922 If there are more strings in &%server_prompts%& than the number of strings
27923 supplied with the AUTH command, the remaining prompts are used to obtain more
27924 data. Each response from the client may be a list of NUL-separated strings.
27925
27926 .vindex "&$authenticated_id$&"
27927 Once a sufficient number of data strings have been received,
27928 &%server_condition%& is expanded. If the expansion is forced to fail,
27929 authentication fails. Any other expansion failure causes a temporary error code
27930 to be returned. If the result of a successful expansion is an empty string,
27931 &"0"&, &"no"&, or &"false"&, authentication fails. If the result of the
27932 expansion is &"1"&, &"yes"&, or &"true"&, authentication succeeds and the
27933 generic &%server_set_id%& option is expanded and saved in &$authenticated_id$&.
27934 For any other result, a temporary error code is returned, with the expanded
27935 string as the error text.
27936
27937 &*Warning*&: If you use a lookup in the expansion to find the user's
27938 password, be sure to make the authentication fail if the user is unknown.
27939 There are good and bad examples at the end of the next section.
27940
27941
27942
27943 .section "The PLAIN authentication mechanism" "SECID172"
27944 .cindex "PLAIN authentication mechanism"
27945 .cindex authentication PLAIN
27946 .cindex "binary zero" "in &(plaintext)& authenticator"
27947 The PLAIN authentication mechanism (RFC 2595) specifies that three strings be
27948 sent as one item of data (that is, one combined string containing two NUL
27949 separators). The data is sent either as part of the AUTH command, or
27950 subsequently in response to an empty prompt from the server.
27951
27952 The second and third strings are a user name and a corresponding password.
27953 Using a single fixed user name and password as an example, this could be
27954 configured as follows:
27955 .code
27956 fixed_plain:
27957   driver = plaintext
27958   public_name = PLAIN
27959   server_prompts = :
27960   server_condition = \
27961     ${if and {{eq{$auth2}{username}}{eq{$auth3}{mysecret}}}}
27962   server_set_id = $auth2
27963 .endd
27964 Note that the default result strings from &%if%& (&"true"& or an empty string)
27965 are exactly what we want here, so they need not be specified. Obviously, if the
27966 password contains expansion-significant characters such as dollar, backslash,
27967 or closing brace, they have to be escaped.
27968
27969 The &%server_prompts%& setting specifies a single, empty prompt (empty items at
27970 the end of a string list are ignored). If all the data comes as part of the
27971 AUTH command, as is commonly the case, the prompt is not used. This
27972 authenticator is advertised in the response to EHLO as
27973 .code
27974 250-AUTH PLAIN
27975 .endd
27976 and a client host can authenticate itself by sending the command
27977 .code
27978 AUTH PLAIN AHVzZXJuYW1lAG15c2VjcmV0
27979 .endd
27980 As this contains three strings (more than the number of prompts), no further
27981 data is required from the client. Alternatively, the client may just send
27982 .code
27983 AUTH PLAIN
27984 .endd
27985 to initiate authentication, in which case the server replies with an empty
27986 prompt. The client must respond with the combined data string.
27987
27988 The data string is base64 encoded, as required by the RFC. This example,
27989 when decoded, is <&'NUL'&>&`username`&<&'NUL'&>&`mysecret`&, where <&'NUL'&>
27990 represents a zero byte. This is split up into three strings, the first of which
27991 is empty. The &%server_condition%& option in the authenticator checks that the
27992 second two are &`username`& and &`mysecret`& respectively.
27993
27994 Having just one fixed user name and password, as in this example, is not very
27995 realistic, though for a small organization with only a handful of
27996 authenticating clients it could make sense.
27997
27998 A more sophisticated instance of this authenticator could use the user name in
27999 &$auth2$& to look up a password in a file or database, and maybe do an encrypted
28000 comparison (see &%crypteq%& in chapter &<<CHAPexpand>>&). Here is a example of
28001 this approach, where the passwords are looked up in a DBM file. &*Warning*&:
28002 This is an incorrect example:
28003 .code
28004 server_condition = \
28005   ${if eq{$auth3}{${lookup{$auth2}dbm{/etc/authpwd}}}}
28006 .endd
28007 The expansion uses the user name (&$auth2$&) as the key to look up a password,
28008 which it then compares to the supplied password (&$auth3$&). Why is this example
28009 incorrect? It works fine for existing users, but consider what happens if a
28010 non-existent user name is given. The lookup fails, but as no success/failure
28011 strings are given for the lookup, it yields an empty string. Thus, to defeat
28012 the authentication, all a client has to do is to supply a non-existent user
28013 name and an empty password. The correct way of writing this test is:
28014 .code
28015 server_condition = ${lookup{$auth2}dbm{/etc/authpwd}\
28016   {${if eq{$value}{$auth3}}} {false}}
28017 .endd
28018 In this case, if the lookup succeeds, the result is checked; if the lookup
28019 fails, &"false"& is returned and authentication fails. If &%crypteq%& is being
28020 used instead of &%eq%&, the first example is in fact safe, because &%crypteq%&
28021 always fails if its second argument is empty. However, the second way of
28022 writing the test makes the logic clearer.
28023
28024
28025 .section "The LOGIN authentication mechanism" "SECID173"
28026 .cindex "LOGIN authentication mechanism"
28027 .cindex authentication LOGIN
28028 The LOGIN authentication mechanism is not documented in any RFC, but is in use
28029 in a number of programs. No data is sent with the AUTH command. Instead, a
28030 user name and password are supplied separately, in response to prompts. The
28031 plaintext authenticator can be configured to support this as in this example:
28032 .code
28033 fixed_login:
28034   driver = plaintext
28035   public_name = LOGIN
28036   server_prompts = User Name : Password
28037   server_condition = \
28038     ${if and {{eq{$auth1}{username}}{eq{$auth2}{mysecret}}}}
28039   server_set_id = $auth1
28040 .endd
28041 Because of the way plaintext operates, this authenticator accepts data supplied
28042 with the AUTH command (in contravention of the specification of LOGIN), but
28043 if the client does not supply it (as is the case for LOGIN clients), the prompt
28044 strings are used to obtain two data items.
28045
28046 Some clients are very particular about the precise text of the prompts. For
28047 example, Outlook Express is reported to recognize only &"Username:"& and
28048 &"Password:"&. Here is an example of a LOGIN authenticator that uses those
28049 strings. It uses the &%ldapauth%& expansion condition to check the user
28050 name and password by binding to an LDAP server:
28051 .code
28052 login:
28053   driver = plaintext
28054   public_name = LOGIN
28055   server_prompts = Username:: : Password::
28056   server_condition = ${if and{{ \
28057     !eq{}{$auth1} }{ \
28058     ldapauth{\
28059       user="uid=${quote_ldap_dn:$auth1},ou=people,o=example.org" \
28060       pass=${quote:$auth2} \
28061       ldap://ldap.example.org/} }} }
28062   server_set_id = uid=$auth1,ou=people,o=example.org
28063 .endd
28064 We have to check that the username is not empty before using it, because LDAP
28065 does not permit empty DN components. We must also use the &%quote_ldap_dn%&
28066 operator to correctly quote the DN for authentication. However, the basic
28067 &%quote%& operator, rather than any of the LDAP quoting operators, is the
28068 correct one to use for the password, because quoting is needed only to make
28069 the password conform to the Exim syntax. At the LDAP level, the password is an
28070 uninterpreted string.
28071
28072
28073 .section "Support for different kinds of authentication" "SECID174"
28074 A number of string expansion features are provided for the purpose of
28075 interfacing to different ways of user authentication. These include checking
28076 traditionally encrypted passwords from &_/etc/passwd_& (or equivalent), PAM,
28077 Radius, &%ldapauth%&, &'pwcheck'&, and &'saslauthd'&. For details see section
28078 &<<SECTexpcond>>&.
28079
28080
28081
28082
28083 .section "Using plaintext in a client" "SECID175"
28084 .cindex "options" "&(plaintext)& authenticator (client)"
28085 The &(plaintext)& authenticator has two client options:
28086
28087 .option client_ignore_invalid_base64 plaintext boolean false
28088 If the client receives a server prompt that is not a valid base64 string,
28089 authentication is abandoned by default. However, if this option is set true,
28090 the error in the challenge is ignored and the client sends the response as
28091 usual.
28092
28093 .option client_send plaintext string&!! unset
28094 The string is a colon-separated list of authentication data strings. Each
28095 string is independently expanded before being sent to the server. The first
28096 string is sent with the AUTH command; any more strings are sent in response
28097 to prompts from the server. Before each string is expanded, the value of the
28098 most recent prompt is placed in the next &$auth$&<&'n'&> variable, starting
28099 with &$auth1$& for the first prompt. Up to three prompts are stored in this
28100 way. Thus, the prompt that is received in response to sending the first string
28101 (with the AUTH command) can be used in the expansion of the second string, and
28102 so on. If an invalid base64 string is received when
28103 &%client_ignore_invalid_base64%& is set, an empty string is put in the
28104 &$auth$&<&'n'&> variable.
28105
28106 &*Note*&: You cannot use expansion to create multiple strings, because
28107 splitting takes priority and happens first.
28108
28109 Because the PLAIN authentication mechanism requires NUL (binary zero) bytes in
28110 the data, further processing is applied to each string before it is sent. If
28111 there are any single circumflex characters in the string, they are converted to
28112 NULs. Should an actual circumflex be required as data, it must be doubled in
28113 the string.
28114
28115 This is an example of a client configuration that implements the PLAIN
28116 authentication mechanism with a fixed user name and password:
28117 .code
28118 fixed_plain:
28119   driver = plaintext
28120   public_name = PLAIN
28121   client_send = ^username^mysecret
28122 .endd
28123 The lack of colons means that the entire text is sent with the AUTH
28124 command, with the circumflex characters converted to NULs.
28125 Note that due to the ambiguity of parsing three consectutive circumflex characters
28126 there is no way to provide a password having a leading circumflex.
28127
28128
28129 A similar example
28130 that uses the LOGIN mechanism is:
28131 .code
28132 fixed_login:
28133   driver = plaintext
28134   public_name = LOGIN
28135   client_send = : username : mysecret
28136 .endd
28137 The initial colon means that the first string is empty, so no data is sent with
28138 the AUTH command itself. The remaining strings are sent in response to
28139 prompts.
28140 .ecindex IIDplaiauth1
28141 .ecindex IIDplaiauth2
28142
28143
28144
28145
28146 . ////////////////////////////////////////////////////////////////////////////
28147 . ////////////////////////////////////////////////////////////////////////////
28148
28149 .chapter "The cram_md5 authenticator" "CHID9"
28150 .scindex IIDcramauth1 "&(cram_md5)& authenticator"
28151 .scindex IIDcramauth2 "authenticators" "&(cram_md5)&"
28152 .cindex "CRAM-MD5 authentication mechanism"
28153 .cindex authentication CRAM-MD5
28154 The CRAM-MD5 authentication mechanism is described in RFC 2195. The server
28155 sends a challenge string to the client, and the response consists of a user
28156 name and the CRAM-MD5 digest of the challenge string combined with a secret
28157 string (password) which is known to both server and client. Thus, the secret
28158 is not sent over the network as plain text, which makes this authenticator more
28159 secure than &(plaintext)&. However, the downside is that the secret has to be
28160 available in plain text at either end.
28161
28162
28163 .section "Using cram_md5 as a server" "SECID176"
28164 .cindex "options" "&(cram_md5)& authenticator (server)"
28165 This authenticator has one server option, which must be set to configure the
28166 authenticator as a server:
28167
28168 .option server_secret cram_md5 string&!! unset
28169 .cindex "numerical variables (&$1$& &$2$& etc)" "in &(cram_md5)& authenticator"
28170 When the server receives the client's response, the user name is placed in
28171 the expansion variable &$auth1$&, and &%server_secret%& is expanded to
28172 obtain the password for that user. The server then computes the CRAM-MD5 digest
28173 that the client should have sent, and checks that it received the correct
28174 string. If the expansion of &%server_secret%& is forced to fail, authentication
28175 fails. If the expansion fails for some other reason, a temporary error code is
28176 returned to the client.
28177
28178 For compatibility with previous releases of Exim, the user name is also placed
28179 in &$1$&. However, the use of this variables for this purpose is now
28180 deprecated, as it can lead to confusion in string expansions that also use
28181 numeric variables for other things.
28182
28183 For example, the following authenticator checks that the user name given by the
28184 client is &"ph10"&, and if so, uses &"secret"& as the password. For any other
28185 user name, authentication fails.
28186 .code
28187 fixed_cram:
28188   driver = cram_md5
28189   public_name = CRAM-MD5
28190   server_secret = ${if eq{$auth1}{ph10}{secret}fail}
28191   server_set_id = $auth1
28192 .endd
28193 .vindex "&$authenticated_id$&"
28194 If authentication succeeds, the setting of &%server_set_id%& preserves the user
28195 name in &$authenticated_id$&. A more typical configuration might look up the
28196 secret string in a file, using the user name as the key. For example:
28197 .code
28198 lookup_cram:
28199   driver = cram_md5
28200   public_name = CRAM-MD5
28201   server_secret = ${lookup{$auth1}lsearch{/etc/authpwd}\
28202                   {$value}fail}
28203   server_set_id = $auth1
28204 .endd
28205 Note that this expansion explicitly forces failure if the lookup fails
28206 because &$auth1$& contains an unknown user name.
28207
28208 As another example, if you wish to re-use a Cyrus SASL sasldb2 file without
28209 using the relevant libraries, you need to know the realm to specify in the
28210 lookup and then ask for the &"userPassword"& attribute for that user in that
28211 realm, with:
28212 .code
28213 cyrusless_crammd5:
28214   driver = cram_md5
28215   public_name = CRAM-MD5
28216   server_secret = ${lookup{$auth1:mail.example.org:userPassword}\
28217                   dbmjz{/etc/sasldb2}{$value}fail}
28218   server_set_id = $auth1
28219 .endd
28220
28221 .section "Using cram_md5 as a client" "SECID177"
28222 .cindex "options" "&(cram_md5)& authenticator (client)"
28223 When used as a client, the &(cram_md5)& authenticator has two options:
28224
28225
28226
28227 .option client_name cram_md5 string&!! "the primary host name"
28228 This string is expanded, and the result used as the user name data when
28229 computing the response to the server's challenge.
28230
28231
28232 .option client_secret cram_md5 string&!! unset
28233 This option must be set for the authenticator to work as a client. Its value is
28234 expanded and the result used as the secret string when computing the response.
28235
28236
28237 .vindex "&$host$&"
28238 .vindex "&$host_address$&"
28239 Different user names and secrets can be used for different servers by referring
28240 to &$host$& or &$host_address$& in the options. Forced failure of either
28241 expansion string is treated as an indication that this authenticator is not
28242 prepared to handle this case. Exim moves on to the next configured client
28243 authenticator. Any other expansion failure causes Exim to give up trying to
28244 send the message to the current server.
28245
28246 A simple example configuration of a &(cram_md5)& authenticator, using fixed
28247 strings, is:
28248 .code
28249 fixed_cram:
28250   driver = cram_md5
28251   public_name = CRAM-MD5
28252   client_name = ph10
28253   client_secret = secret
28254 .endd
28255 .ecindex IIDcramauth1
28256 .ecindex IIDcramauth2
28257
28258
28259
28260 . ////////////////////////////////////////////////////////////////////////////
28261 . ////////////////////////////////////////////////////////////////////////////
28262
28263 .chapter "The cyrus_sasl authenticator" "CHID10"
28264 .scindex IIDcyrauth1 "&(cyrus_sasl)& authenticator"
28265 .scindex IIDcyrauth2 "authenticators" "&(cyrus_sasl)&"
28266 .cindex "Cyrus" "SASL library"
28267 .cindex "Kerberos"
28268 The code for this authenticator was provided by Matthew Byng-Maddick while
28269 at A L Digital Ltd.
28270
28271 The &(cyrus_sasl)& authenticator provides server support for the Cyrus SASL
28272 library implementation of the RFC 2222 (&"Simple Authentication and Security
28273 Layer"&). This library supports a number of authentication mechanisms,
28274 including PLAIN and LOGIN, but also several others that Exim does not support
28275 directly. In particular, there is support for Kerberos authentication.
28276
28277 The &(cyrus_sasl)& authenticator provides a gatewaying mechanism directly to
28278 the Cyrus interface, so if your Cyrus library can do, for example, CRAM-MD5,
28279 then so can the &(cyrus_sasl)& authenticator. By default it uses the public
28280 name of the driver to determine which mechanism to support.
28281
28282 Where access to some kind of secret file is required, for example, in GSSAPI
28283 or CRAM-MD5, it is worth noting that the authenticator runs as the Exim
28284 user, and that the Cyrus SASL library has no way of escalating privileges
28285 by default. You may also find you need to set environment variables,
28286 depending on the driver you are using.
28287
28288 The application name provided by Exim is &"exim"&, so various SASL options may
28289 be set in &_exim.conf_& in your SASL directory. If you are using GSSAPI for
28290 Kerberos, note that because of limitations in the GSSAPI interface,
28291 changing the server keytab might need to be communicated down to the Kerberos
28292 layer independently. The mechanism for doing so is dependent upon the Kerberos
28293 implementation.
28294
28295 For example, for older releases of Heimdal, the environment variable KRB5_KTNAME
28296 may be set to point to an alternative keytab file. Exim will pass this
28297 variable through from its own inherited environment when started as root or the
28298 Exim user. The keytab file needs to be readable by the Exim user.
28299 With newer releases of Heimdal, a setuid Exim may cause Heimdal to discard the
28300 environment variable.  In practice, for those releases, the Cyrus authenticator
28301 is not a suitable interface for GSSAPI (Kerberos) support.  Instead, consider
28302 the &(heimdal_gssapi)& authenticator, described in chapter &<<CHAPheimdalgss>>&
28303
28304
28305 .section "Using cyrus_sasl as a server" "SECID178"
28306 The &(cyrus_sasl)& authenticator has four private options. It puts the username
28307 (on a successful authentication) into &$auth1$&. For compatibility with
28308 previous releases of Exim, the username is also placed in &$1$&. However, the
28309 use of this variable for this purpose is now deprecated, as it can lead to
28310 confusion in string expansions that also use numeric variables for other
28311 things.
28312
28313
28314 .option server_hostname cyrus_sasl string&!! "see below"
28315 This option selects the hostname that is used when communicating with the
28316 library. The default value is &`$primary_hostname`&. It is up to the underlying
28317 SASL plug-in what it does with this data.
28318
28319
28320 .option server_mech cyrus_sasl string "see below"
28321 This option selects the authentication mechanism this driver should use. The
28322 default is the value of the generic &%public_name%& option. This option allows
28323 you to use a different underlying mechanism from the advertised name. For
28324 example:
28325 .code
28326 sasl:
28327   driver = cyrus_sasl
28328   public_name = X-ANYTHING
28329   server_mech = CRAM-MD5
28330   server_set_id = $auth1
28331 .endd
28332
28333 .option server_realm cyrus_sasl string&!! unset
28334 This specifies the SASL realm that the server claims to be in.
28335
28336
28337 .option server_service cyrus_sasl string &`smtp`&
28338 This is the SASL service that the server claims to implement.
28339
28340
28341 For straightforward cases, you do not need to set any of the authenticator's
28342 private options. All you need to do is to specify an appropriate mechanism as
28343 the public name. Thus, if you have a SASL library that supports CRAM-MD5 and
28344 PLAIN, you could have two authenticators as follows:
28345 .code
28346 sasl_cram_md5:
28347   driver = cyrus_sasl
28348   public_name = CRAM-MD5
28349   server_set_id = $auth1
28350
28351 sasl_plain:
28352   driver = cyrus_sasl
28353   public_name = PLAIN
28354   server_set_id = $auth2
28355 .endd
28356 Cyrus SASL does implement the LOGIN authentication method, even though it is
28357 not a standard method. It is disabled by default in the source distribution,
28358 but it is present in many binary distributions.
28359 .ecindex IIDcyrauth1
28360 .ecindex IIDcyrauth2
28361
28362
28363
28364
28365 . ////////////////////////////////////////////////////////////////////////////
28366 . ////////////////////////////////////////////////////////////////////////////
28367 .chapter "The dovecot authenticator" "CHAPdovecot"
28368 .scindex IIDdcotauth1 "&(dovecot)& authenticator"
28369 .scindex IIDdcotauth2 "authenticators" "&(dovecot)&"
28370 This authenticator is an interface to the authentication facility of the
28371 Dovecot 2 POP/IMAP server, which can support a number of authentication methods.
28372 Note that Dovecot must be configured to use auth-client not auth-userdb.
28373 If you are using Dovecot to authenticate POP/IMAP clients, it might be helpful
28374 to use the same mechanisms for SMTP authentication. This is a server
28375 authenticator only. There is only one non-generic option:
28376
28377 .option server_socket dovecot string unset
28378
28379 This option must specify the UNIX socket that is the interface to Dovecot
28380 authentication. The &%public_name%& option must specify an authentication
28381 mechanism that Dovecot is configured to support. You can have several
28382 authenticators for different mechanisms. For example:
28383 .code
28384 dovecot_plain:
28385   driver = dovecot
28386   public_name = PLAIN
28387   server_advertise_condition = ${if def:tls_in_cipher}
28388   server_socket = /var/run/dovecot/auth-client
28389   server_set_id = $auth1
28390
28391 dovecot_ntlm:
28392   driver = dovecot
28393   public_name = NTLM
28394   server_socket = /var/run/dovecot/auth-client
28395   server_set_id = $auth1
28396 .endd
28397
28398 &*Note*&: plaintext authentication methods such as PLAIN and LOGIN
28399 should not be advertised on cleartext SMTP connections.
28400 See the discussion in section &<<SECTplain_TLS>>&.
28401
28402 If the SMTP connection is encrypted, or if &$sender_host_address$& is equal to
28403 &$received_ip_address$& (that is, the connection is local), the &"secured"&
28404 option is passed in the Dovecot authentication command. If, for a TLS
28405 connection, a client certificate has been verified, the &"valid-client-cert"&
28406 option is passed. When authentication succeeds, the identity of the user
28407 who authenticated is placed in &$auth1$&.
28408
28409 The Dovecot configuration to match the above will look
28410 something like:
28411 .code
28412 conf.d/10-master.conf :-
28413
28414 service auth {
28415 ...
28416 #SASL
28417   unix_listener auth-client {
28418     mode = 0660
28419     user = mail
28420   }
28421 ...
28422 }
28423
28424 conf.d/10-auth.conf :-
28425
28426 auth_mechanisms = plain login ntlm
28427 .endd
28428
28429 .ecindex IIDdcotauth1
28430 .ecindex IIDdcotauth2
28431
28432
28433 . ////////////////////////////////////////////////////////////////////////////
28434 . ////////////////////////////////////////////////////////////////////////////
28435 .chapter "The gsasl authenticator" "CHAPgsasl"
28436 .scindex IIDgsaslauth1 "&(gsasl)& authenticator"
28437 .scindex IIDgsaslauth2 "authenticators" "&(gsasl)&"
28438 .cindex "authentication" "GNU SASL"
28439 .cindex "authentication" "SASL"
28440 .cindex "authentication" "EXTERNAL"
28441 .cindex "authentication" "ANONYMOUS"
28442 .cindex "authentication" "PLAIN"
28443 .cindex "authentication" "LOGIN"
28444 .cindex "authentication" "DIGEST-MD5"
28445 .cindex "authentication" "CRAM-MD5"
28446 .cindex "authentication" "SCRAM family"
28447 The &(gsasl)& authenticator provides integration for the GNU SASL
28448 library and the mechanisms it provides.  This is new as of the 4.80 release
28449 and there are a few areas where the library does not let Exim smoothly
28450 scale to handle future authentication mechanisms, so no guarantee can be
28451 made that any particular new authentication mechanism will be supported
28452 without code changes in Exim.
28453
28454 The library is expected to add support in an upcoming
28455 realease for the SCRAM-SHA-256 method.
28456 The macro _HAVE_AUTH_GSASL_SCRAM_SHA_256 will be defined
28457 when this happens.
28458
28459 To see the list of mechanisms supported by the library run Exim with "auth" debug
28460 enabled and look for a line containing "GNU SASL supports".
28461 Note however that some may not have been tested from Exim.
28462
28463
28464 .option client_authz gsasl string&!! unset
28465 This option can be used to supply an &'authorization id'&
28466 which is different to the &'authentication_id'& provided
28467 by &%client_username%& option.
28468 If unset or (after expansion) empty it is not used,
28469 which is the common case.
28470
28471 .option client_channelbinding gsasl boolean false
28472 See &%server_channelbinding%& below.
28473
28474 .option client_password gsasl string&!! unset
28475 This option is exapanded before use, and should result in
28476 the password to be used, in clear.
28477
28478 .option client_username gsasl string&!! unset
28479 This option is exapanded before use, and should result in
28480 the account name to be used.
28481
28482
28483 .option client_spassword gsasl string&!! unset
28484 This option is only supported for library versions 1.9.1 and greater.
28485 The macro _HAVE_AUTH_GSASL_SCRAM_S_KEY will be defined when this is so.
28486
28487 If a SCRAM mechanism is being used and this option is set
28488 and correctly sized
28489 it is used in preference to &%client_password%&.
28490 The value after expansion should be
28491 a 40 (for SHA-1) or 64 (for SHA-256) character string
28492 with the PBKDF2-prepared password, hex-encoded.
28493
28494 Note that this value will depend on the salt and iteration-count
28495 supplied by the server.
28496 The option is expanded before use.
28497 During the expansion &$auth1$& is set with the client username,
28498 &$auth2$& with the iteration count, and
28499 &$auth3$& with the salt.
28500
28501 The intent of this option
28502 is to support clients that can cache thes salted password
28503 to save on recalculation costs.
28504 The cache lookup should return an unusable value
28505 (eg. an empty string)
28506 if the salt or iteration count has changed
28507
28508 If the authentication succeeds then the above variables are set,
28509 .vindex "&$auth4$&"
28510 plus the calculated salted password value value in &$auth4$&,
28511 during the expansion of the &%client_set_id%& option.
28512 A side-effect of this expansion can be used to prime the cache.
28513
28514
28515 .option server_channelbinding gsasl boolean false
28516 Some authentication mechanisms are able to use external context at both ends
28517 of the session to bind the authentication to that context, and fail the
28518 authentication process if that context differs.  Specifically, some TLS
28519 ciphersuites can provide identifying information about the cryptographic
28520 context.
28521
28522 This should have meant that certificate identity and verification becomes a
28523 non-issue, as a man-in-the-middle attack will cause the correct client and
28524 server to see different identifiers and authentication will fail.
28525
28526 This is
28527 only usable by mechanisms which support "channel binding"; at time of
28528 writing, that's the SCRAM family.
28529 When using this feature the "-PLUS" variants of the method names need to be used.
28530
28531 This defaults off to ensure smooth upgrade across Exim releases, in case
28532 this option causes some clients to start failing.  Some future release
28533 of Exim might have switched the default to be true.
28534
28535 . However, Channel Binding in TLS has proven to be vulnerable in current versions.
28536 . Do not plan to rely upon this feature for security, ever, without consulting
28537 . with a subject matter expert (a cryptographic engineer).
28538
28539 This option was deprecated in previous releases due to doubts over
28540 the "Triple Handshake" vulnerability.
28541 Exim takes suitable precausions (requiring Extended Master Secret if TLS
28542 Session Resumption was used) for safety.
28543
28544
28545 .option server_hostname gsasl string&!! "see below"
28546 This option selects the hostname that is used when communicating with the
28547 library. The default value is &`$primary_hostname`&.
28548 Some mechanisms will use this data.
28549
28550
28551 .option server_mech gsasl string "see below"
28552 This option selects the authentication mechanism this driver should use. The
28553 default is the value of the generic &%public_name%& option. This option allows
28554 you to use a different underlying mechanism from the advertised name. For
28555 example:
28556 .code
28557 sasl:
28558   driver = gsasl
28559   public_name = X-ANYTHING
28560   server_mech = CRAM-MD5
28561   server_set_id = $auth1
28562 .endd
28563
28564
28565 .option server_password gsasl string&!! unset
28566 Various mechanisms need access to the cleartext password on the server, so
28567 that proof-of-possession can be demonstrated on the wire, without sending
28568 the password itself.
28569
28570 The data available for lookup varies per mechanism.
28571 In all cases, &$auth1$& is set to the &'authentication id'&.
28572 The &$auth2$& variable will always be the &'authorization id'& (&'authz'&)
28573 if available, else the empty string.
28574 The &$auth3$& variable will always be the &'realm'& if available,
28575 else the empty string.
28576
28577 A forced failure will cause authentication to defer.
28578
28579 If using this option, it may make sense to set the &%server_condition%&
28580 option to be simply "true".
28581
28582
28583 .option server_realm gsasl string&!! unset
28584 This specifies the SASL realm that the server claims to be in.
28585 Some mechanisms will use this data.
28586
28587
28588 .option server_scram_iter gsasl string&!! 4096
28589 This option provides data for the SCRAM family of mechanisms.
28590 The &$auth1$&, &$auth2$& and &$auth3$& variables are available
28591 when this option is expanded.
28592
28593 The result of expansion should be a decimal number,
28594 and represents both a lower-bound on the security, and
28595 a compute cost factor imposed on the client
28596 (if it does not cache results, or the server changes
28597 either the iteration count or the salt).
28598 A minimum value of 4096 is required by the standards
28599 for all current SCRAM mechanism variants.
28600
28601 .option server_scram_salt gsasl string&!! unset
28602 This option provides data for the SCRAM family of mechanisms.
28603 The &$auth1$&, &$auth2$& and &$auth3$& variables are available
28604 when this option is expanded.
28605 The value should be a base64-encoded string,
28606 of random data typically 4-to-16 bytes long.
28607 If unset or empty after expansion the library will provides a value for the
28608 protocol conversation.
28609
28610
28611 .option server_key gsasl string&!! unset
28612 .option server_skey gsasl string&!! unset
28613 These options can be used for the SCRAM family of mechanisms
28614 to provide stored information related to a password,
28615 the storage of which is preferable to plaintext.
28616
28617 &%server_key%& is the value defined in the SCRAM standards as ServerKey;
28618 &%server_skey%& is StoredKey.
28619
28620 They are only available for version 1.9.0 (or later) of the gsasl library.
28621 When this is so, the macros
28622 _OPT_AUTHENTICATOR_GSASL_SERVER_KEY
28623 and _HAVE_AUTH_GSASL_SCRAM_S_KEY
28624 will be defined.
28625
28626 The &$authN$& variables are available when these options are expanded.
28627
28628 If set, the results of expansion should for each
28629 should be a 28 (for SHA-1) or 44 (for SHA-256) character string
28630 of base64-coded data, and will be used in preference to the
28631 &%server_password%& option.
28632 If unset or not of the right length, &%server_password%& will be used.
28633
28634 The libgsasl library release includes a utility &'gsasl'& which can be used
28635 to generate these values.
28636
28637
28638 .option server_service gsasl string &`smtp`&
28639 This is the SASL service that the server claims to implement.
28640 Some mechanisms will use this data.
28641
28642
28643 .section "&(gsasl)& auth variables" "SECTgsaslauthvar"
28644 .vindex "&$auth1$&, &$auth2$&, etc"
28645 These may be set when evaluating specific options, as detailed above.
28646 They will also be set when evaluating &%server_condition%&.
28647
28648 Unless otherwise stated below, the &(gsasl)& integration will use the following
28649 meanings for these variables:
28650
28651 .ilist
28652 .vindex "&$auth1$&"
28653 &$auth1$&: the &'authentication id'&
28654 .next
28655 .vindex "&$auth2$&"
28656 &$auth2$&: the &'authorization id'&
28657 .next
28658 .vindex "&$auth3$&"
28659 &$auth3$&: the &'realm'&
28660 .endlist
28661
28662 On a per-mechanism basis:
28663
28664 .ilist
28665 .cindex "authentication" "EXTERNAL"
28666 EXTERNAL: only &$auth1$& is set, to the possibly empty &'authorization id'&;
28667 the &%server_condition%& option must be present.
28668 .next
28669 .cindex "authentication" "ANONYMOUS"
28670 ANONYMOUS: only &$auth1$& is set, to the possibly empty &'anonymous token'&;
28671 the &%server_condition%& option must be present.
28672 .next
28673 .cindex "authentication" "GSSAPI"
28674 GSSAPI: &$auth1$& will be set to the &'GSSAPI Display Name'&;
28675 &$auth2$& will be set to the &'authorization id'&,
28676 the &%server_condition%& option must be present.
28677 .endlist
28678
28679 An &'anonymous token'& is something passed along as an unauthenticated
28680 identifier; this is analogous to FTP anonymous authentication passing an
28681 email address, or software-identifier@, as the "password".
28682
28683
28684 An example showing the password having the realm specified in the callback
28685 and demonstrating a Cyrus SASL to GSASL migration approach is:
28686 .code
28687 gsasl_cyrusless_crammd5:
28688   driver = gsasl
28689   public_name = CRAM-MD5
28690   server_realm = imap.example.org
28691   server_password = ${lookup{$auth1:$auth3:userPassword}\
28692                     dbmjz{/etc/sasldb2}{$value}fail}
28693   server_set_id = ${quote:$auth1}
28694   server_condition = yes
28695 .endd
28696
28697
28698 . ////////////////////////////////////////////////////////////////////////////
28699 . ////////////////////////////////////////////////////////////////////////////
28700
28701 .chapter "The heimdal_gssapi authenticator" "CHAPheimdalgss"
28702 .scindex IIDheimdalgssauth1 "&(heimdal_gssapi)& authenticator"
28703 .scindex IIDheimdalgssauth2 "authenticators" "&(heimdal_gssapi)&"
28704 .cindex "authentication" "GSSAPI"
28705 .cindex "authentication" "Kerberos"
28706 The &(heimdal_gssapi)& authenticator provides server integration for the
28707 Heimdal GSSAPI/Kerberos library, permitting Exim to set a keytab pathname
28708 reliably.
28709
28710 .option server_hostname heimdal_gssapi string&!! "see below"
28711 This option selects the hostname that is used, with &%server_service%&,
28712 for constructing the GSS server name, as a &'GSS_C_NT_HOSTBASED_SERVICE'&
28713 identifier.  The default value is &`$primary_hostname`&.
28714
28715 .option server_keytab heimdal_gssapi string&!! unset
28716 If set, then Heimdal will not use the system default keytab (typically
28717 &_/etc/krb5.keytab_&) but instead the pathname given in this option.
28718 The value should be a pathname, with no &"file:"& prefix.
28719
28720 .option server_service heimdal_gssapi string&!! "smtp"
28721 This option specifies the service identifier used, in conjunction with
28722 &%server_hostname%&, for building the identifier for finding credentials
28723 from the keytab.
28724
28725
28726 .section "&(heimdal_gssapi)& auth variables" "SECTheimdalgssauthvar"
28727 Beware that these variables will typically include a realm, thus will appear
28728 to be roughly like an email address already.  The &'authzid'& in &$auth2$& is
28729 not verified, so a malicious client can set it to anything.
28730
28731 The &$auth1$& field should be safely trustable as a value from the Key
28732 Distribution Center.  Note that these are not quite email addresses.
28733 Each identifier is for a role, and so the left-hand-side may include a
28734 role suffix.  For instance, &"joe/admin@EXAMPLE.ORG"&.
28735
28736 .vindex "&$auth1$&, &$auth2$&, etc"
28737 .ilist
28738 .vindex "&$auth1$&"
28739 &$auth1$&: the &'authentication id'&, set to the GSS Display Name.
28740 .next
28741 .vindex "&$auth2$&"
28742 &$auth2$&: the &'authorization id'&, sent within SASL encapsulation after
28743 authentication.  If that was empty, this will also be set to the
28744 GSS Display Name.
28745 .endlist
28746
28747
28748 . ////////////////////////////////////////////////////////////////////////////
28749 . ////////////////////////////////////////////////////////////////////////////
28750
28751 .chapter "The spa authenticator" "CHAPspa"
28752 .scindex IIDspaauth1 "&(spa)& authenticator"
28753 .scindex IIDspaauth2 "authenticators" "&(spa)&"
28754 .cindex "authentication" "Microsoft Secure Password"
28755 .cindex "authentication" "NTLM"
28756 .cindex "Microsoft Secure Password Authentication"
28757 .cindex "NTLM authentication"
28758 The &(spa)& authenticator provides client support for Microsoft's &'Secure
28759 Password Authentication'& mechanism,
28760 which is also sometimes known as NTLM (NT LanMan). The code for client side of
28761 this authenticator was contributed by Marc Prud'hommeaux, and much of it is
28762 taken from the Samba project (&url(https://www.samba.org/)). The code for the
28763 server side was subsequently contributed by Tom Kistner. The mechanism works as
28764 follows:
28765
28766 .ilist
28767 After the AUTH command has been accepted, the client sends an SPA
28768 authentication request based on the user name and optional domain.
28769 .next
28770 The server sends back a challenge.
28771 .next
28772 The client builds a challenge response which makes use of the user's password
28773 and sends it to the server, which then accepts or rejects it.
28774 .endlist
28775
28776 Encryption is used to protect the password in transit.
28777
28778
28779
28780 .section "Using spa as a server" "SECID179"
28781 .cindex "options" "&(spa)& authenticator (server)"
28782 The &(spa)& authenticator has just one server option:
28783
28784 .option server_password spa string&!! unset
28785 .cindex "numerical variables (&$1$& &$2$& etc)" "in &(spa)& authenticator"
28786 This option is expanded, and the result must be the cleartext password for the
28787 authenticating user, whose name is at this point in &$auth1$&. For
28788 compatibility with previous releases of Exim, the user name is also placed in
28789 &$1$&. However, the use of this variable for this purpose is now deprecated, as
28790 it can lead to confusion in string expansions that also use numeric variables
28791 for other things. For example:
28792 .code
28793 spa:
28794   driver = spa
28795   public_name = NTLM
28796   server_password = \
28797     ${lookup{$auth1}lsearch{/etc/exim/spa_clearpass}{$value}fail}
28798 .endd
28799 If the expansion is forced to fail, authentication fails. Any other expansion
28800 failure causes a temporary error code to be returned.
28801
28802
28803
28804
28805
28806 .section "Using spa as a client" "SECID180"
28807 .cindex "options" "&(spa)& authenticator (client)"
28808 The &(spa)& authenticator has the following client options:
28809
28810
28811
28812 .option client_domain spa string&!! unset
28813 This option specifies an optional domain for the authentication.
28814
28815
28816 .option client_password spa string&!! unset
28817 This option specifies the user's password, and must be set.
28818
28819
28820 .option client_username spa string&!! unset
28821 This option specifies the user name, and must be set. Here is an example of a
28822 configuration of this authenticator for use with the mail servers at
28823 &'msn.com'&:
28824 .code
28825 msn:
28826   driver = spa
28827   public_name = MSN
28828   client_username = msn/msn_username
28829   client_password = msn_plaintext_password
28830   client_domain = DOMAIN_OR_UNSET
28831 .endd
28832 .ecindex IIDspaauth1
28833 .ecindex IIDspaauth2
28834
28835
28836
28837
28838
28839 . ////////////////////////////////////////////////////////////////////////////
28840 . ////////////////////////////////////////////////////////////////////////////
28841
28842 .chapter "The external authenticator" "CHAPexternauth"
28843 .scindex IIDexternauth1 "&(external)& authenticator"
28844 .scindex IIDexternauth2 "authenticators" "&(external)&"
28845 .cindex "authentication" "Client Certificate"
28846 .cindex "authentication" "X509"
28847 .cindex "Certificate-based authentication"
28848 The &(external)& authenticator provides support for
28849 authentication based on non-SMTP information.
28850 The specification is in RFC 4422 Appendix A
28851 (&url(https://tools.ietf.org/html/rfc4422)).
28852 It is only a transport and negotiation mechanism;
28853 the process of authentication is entirely controlled
28854 by the server configuration.
28855
28856 The client presents an identity in-clear.
28857 It is probably wise for a server to only advertise,
28858 and for clients to only attempt,
28859 this authentication method on a secure (eg. under TLS) connection.
28860
28861 One possible use, compatible with the
28862 K-9 Mail Android client (&url(https://k9mail.github.io/)),
28863 is for using X509 client certificates.
28864
28865 It thus overlaps in function with the TLS authenticator
28866 (see &<<CHAPtlsauth>>&)
28867 but is a full SMTP SASL authenticator
28868 rather than being implicit for TLS-connection carried
28869 client certificates only.
28870
28871 The examples and discussion in this chapter assume that
28872 client-certificate authentication is being done.
28873
28874 The client must present a certificate,
28875 for which it must have been requested via the
28876 &%tls_verify_hosts%& or &%tls_try_verify_hosts%& main options
28877 (see &<<CHAPTLS>>&).
28878 For authentication to be effective the certificate should be
28879 verifiable against a trust-anchor certificate known to the server.
28880
28881 .section "External options" "SECTexternsoptions"
28882 .cindex "options" "&(external)& authenticator (server)"
28883 The &(external)& authenticator has two server options:
28884
28885 .option server_param2 external string&!! unset
28886 .option server_param3 external string&!! unset
28887 .cindex "variables (&$auth1$& &$auth2$& etc)" "in &(external)& authenticator"
28888 These options are expanded before the &%server_condition%& option
28889 and the result are placed in &$auth2$& and &$auth3$& resectively.
28890 If the expansion is forced to fail, authentication fails. Any other expansion
28891 failure causes a temporary error code to be returned.
28892
28893 They can be used to clarify the coding of a complex &%server_condition%&.
28894
28895 .section "Using external in a server" "SECTexternserver"
28896 .cindex "AUTH" "in &(external)& authenticator"
28897 .cindex "numerical variables (&$1$& &$2$& etc)" &&&
28898         "in &(external)& authenticator"
28899 .vindex "&$auth1$&, &$auth2$&, etc"
28900 .cindex "base64 encoding" "in &(external)& authenticator"
28901
28902 When running as a server, &(external)& performs the authentication test by
28903 expanding a string. The data sent by the client with the AUTH command, or in
28904 response to subsequent prompts, is base64 encoded, and so may contain any byte
28905 values when decoded. The decoded value is treated as
28906 an identity for authentication and
28907 placed in the expansion variable &$auth1$&.
28908
28909 For compatibility with previous releases of Exim, the value is also placed in
28910 the expansion variable &$1$&. However, the use of this
28911 variable for this purpose is now deprecated, as it can lead to confusion in
28912 string expansions that also use them for other things.
28913
28914 .vindex "&$authenticated_id$&"
28915 Once an identity has been received,
28916 &%server_condition%& is expanded. If the expansion is forced to fail,
28917 authentication fails. Any other expansion failure causes a temporary error code
28918 to be returned. If the result of a successful expansion is an empty string,
28919 &"0"&, &"no"&, or &"false"&, authentication fails. If the result of the
28920 expansion is &"1"&, &"yes"&, or &"true"&, authentication succeeds and the
28921 generic &%server_set_id%& option is expanded and saved in &$authenticated_id$&.
28922 For any other result, a temporary error code is returned, with the expanded
28923 string as the error text.
28924
28925 Example:
28926 .code
28927 ext_ccert_san_mail:
28928   driver =            external
28929   public_name =       EXTERNAL
28930
28931   server_advertise_condition = $tls_in_certificate_verified
28932   server_param2 =     ${certextract {subj_altname,mail,>:} \
28933                                     {$tls_in_peercert}}
28934   server_condition =  ${if forany {$auth2} \
28935                             {eq {$item}{$auth1}}}
28936   server_set_id =     $auth1
28937 .endd
28938 This accepts a client certificate that is verifiable against any
28939 of your configured trust-anchors
28940 (which usually means the full set of public CAs)
28941 and which has a mail-SAN matching the claimed identity sent by the client.
28942
28943 &*Note*&: up to TLS1.2, the client cert is on the wire in-clear, including the SAN.
28944 The account name is therefore guessable by an opponent.
28945 TLS 1.3 protects both server and client certificates, and is not vulnerable
28946 in this way.
28947
28948
28949 .section "Using external in a client" "SECTexternclient"
28950 .cindex "options" "&(external)& authenticator (client)"
28951 The &(external)& authenticator has one client option:
28952
28953 .option client_send external string&!! unset
28954 This option is expanded and sent with the AUTH command as the
28955 identity being asserted.
28956
28957 Example:
28958 .code
28959 ext_ccert:
28960   driver =      external
28961   public_name = EXTERNAL
28962
28963   client_condition = ${if !eq{$tls_out_cipher}{}}
28964   client_send = myaccount@smarthost.example.net
28965 .endd
28966
28967
28968 .ecindex IIDexternauth1
28969 .ecindex IIDexternauth2
28970
28971
28972
28973
28974
28975 . ////////////////////////////////////////////////////////////////////////////
28976 . ////////////////////////////////////////////////////////////////////////////
28977
28978 .chapter "The tls authenticator" "CHAPtlsauth"
28979 .scindex IIDtlsauth1 "&(tls)& authenticator"
28980 .scindex IIDtlsauth2 "authenticators" "&(tls)&"
28981 .cindex "authentication" "Client Certificate"
28982 .cindex "authentication" "X509"
28983 .cindex "Certificate-based authentication"
28984 The &(tls)& authenticator provides server support for
28985 authentication based on client certificates.
28986
28987 It is not an SMTP authentication mechanism and is not
28988 advertised by the server as part of the SMTP EHLO response.
28989 It is an Exim authenticator in the sense that it affects
28990 the protocol element of the log line, can be tested for
28991 by the &%authenticated%& ACL condition, and can set
28992 the &$authenticated_id$& variable.
28993
28994 The client must present a verifiable certificate,
28995 for which it must have been requested via the
28996 &%tls_verify_hosts%& or &%tls_try_verify_hosts%& main options
28997 (see &<<CHAPTLS>>&).
28998
28999 If an authenticator of this type is configured it is
29000 run immediately after a TLS connection being negotiated
29001 (due to either STARTTLS or TLS-on-connect)
29002 and can authenticate the connection.
29003 If it does, SMTP authentication is not subsequently offered.
29004
29005 A maximum of one authenticator of this type may be present.
29006
29007
29008 .cindex "options" "&(tls)& authenticator (server)"
29009 The &(tls)& authenticator has three server options:
29010
29011 .option server_param1 tls string&!! unset
29012 .cindex "variables (&$auth1$& &$auth2$& etc)" "in &(tls)& authenticator"
29013 This option is expanded after the TLS negotiation and
29014 the result is placed in &$auth1$&.
29015 If the expansion is forced to fail, authentication fails. Any other expansion
29016 failure causes a temporary error code to be returned.
29017
29018 .option server_param2 tls string&!! unset
29019 .option server_param3 tls string&!! unset
29020 As above, for &$auth2$& and &$auth3$&.
29021
29022 &%server_param1%& may also be spelled &%server_param%&.
29023
29024
29025 Example:
29026 .code
29027 tls:
29028   driver = tls
29029   server_param1 =     ${certextract {subj_altname,mail,>:} \
29030                                     {$tls_in_peercert}}
29031   server_condition =  ${if and { {eq{$tls_in_certificate_verified}{1}} \
29032                                  {forany {$auth1} \
29033                             {!= {0} \
29034                                 {${lookup ldap{ldap:///\
29035                          mailname=${quote_ldap_dn:${lc:$item}},\
29036                          ou=users,LDAP_DC?mailid} {$value}{0} \
29037                        }    }  } }}}
29038   server_set_id =     ${if = {1}{${listcount:$auth1}} {$auth1}{}}
29039 .endd
29040 This accepts a client certificate that is verifiable against any
29041 of your configured trust-anchors
29042 (which usually means the full set of public CAs)
29043 and which has a SAN with a good account name.
29044
29045 Note that, up to TLS1.2, the client cert is on the wire in-clear, including the SAN,
29046 The account name is therefore guessable by an opponent.
29047 TLS 1.3 protects both server and client certificates, and is not vulnerable
29048 in this way.
29049 Likewise, a traditional plaintext SMTP AUTH done inside TLS is not.
29050
29051 . An alternative might use
29052 . .code
29053 .   server_param1 = ${sha256:$tls_in_peercert}
29054 . .endd
29055 . to require one of a set of specific certs that define a given account
29056 . (the verification is still required, but mostly irrelevant).
29057 . This would help for per-device use.
29058 .
29059 . However, for the future we really need support for checking a
29060 . user cert in LDAP - which probably wants a base-64 DER.
29061
29062 .ecindex IIDtlsauth1
29063 .ecindex IIDtlsauth2
29064
29065
29066 Note that because authentication is traditionally an SMTP operation,
29067 the &%authenticated%& ACL condition cannot be used in
29068 a connect- or helo-ACL.
29069
29070
29071
29072 . ////////////////////////////////////////////////////////////////////////////
29073 . ////////////////////////////////////////////////////////////////////////////
29074
29075 .chapter "Encrypted SMTP connections using TLS/SSL" "CHAPTLS" &&&
29076          "Encrypted SMTP connections"
29077 .scindex IIDencsmtp1 "encryption" "on SMTP connection"
29078 .scindex IIDencsmtp2 "SMTP" "encryption"
29079 .cindex "TLS" "on SMTP connection"
29080 .cindex "OpenSSL"
29081 .cindex "GnuTLS"
29082 Support for TLS (Transport Layer Security), formerly known as SSL (Secure
29083 Sockets Layer), is implemented by making use of the OpenSSL library or the
29084 GnuTLS library (Exim requires GnuTLS release 1.0 or later). There is no
29085 cryptographic code in the Exim distribution itself for implementing TLS. In
29086 order to use this feature you must install OpenSSL or GnuTLS, and then build a
29087 version of Exim that includes TLS support (see section &<<SECTinctlsssl>>&).
29088 You also need to understand the basic concepts of encryption at a managerial
29089 level, and in particular, the way that public keys, private keys, and
29090 certificates are used.
29091
29092 RFC 3207 defines how SMTP connections can make use of encryption. Once a
29093 connection is established, the client issues a STARTTLS command. If the
29094 server accepts this, the client and the server negotiate an encryption
29095 mechanism. If the negotiation succeeds, the data that subsequently passes
29096 between them is encrypted.
29097
29098 Exim's ACLs can detect whether the current SMTP session is encrypted or not,
29099 and if so, what cipher suite is in use, whether the client supplied a
29100 certificate, and whether or not that certificate was verified. This makes it
29101 possible for an Exim server to deny or accept certain commands based on the
29102 encryption state.
29103
29104 &*Warning*&: Certain types of firewall and certain anti-virus products can
29105 disrupt TLS connections. You need to turn off SMTP scanning for these products
29106 in order to get TLS to work.
29107
29108
29109
29110 .section "Support for the &""submissions""& (aka &""ssmtp""& and &""smtps""&) protocol" &&&
29111          "SECID284"
29112 .cindex "submissions protocol"
29113 .cindex "ssmtp protocol"
29114 .cindex "smtps protocol"
29115 .cindex "SMTP" "submissions protocol"
29116 .cindex "SMTP" "ssmtp protocol"
29117 .cindex "SMTP" "smtps protocol"
29118 The history of port numbers for TLS in SMTP is a little messy and has been
29119 contentious.  As of RFC 8314, the common practice of using the historically
29120 allocated port 465 for "email submission but with TLS immediately upon connect
29121 instead of using STARTTLS" is officially blessed by the IETF, and recommended
29122 by them in preference to STARTTLS.
29123
29124 The name originally assigned to the port was &"ssmtp"& or &"smtps"&, but as
29125 clarity emerged over the dual roles of SMTP, for MX delivery and Email
29126 Submission, nomenclature has shifted.  The modern name is now &"submissions"&.
29127
29128 This approach was, for a while, officially abandoned when encrypted SMTP was
29129 standardized, but many clients kept using it, even as the TCP port number was
29130 reassigned for other use.
29131 Thus you may encounter guidance claiming that you shouldn't enable use of
29132 this port.
29133 In practice, a number of mail-clients have only ever supported submissions,
29134 not submission with STARTTLS upgrade.
29135 Ideally, offer both submission (587) and submissions (465) service.
29136
29137 Exim supports TLS-on-connect by means of the &%tls_on_connect_ports%&
29138 global option. Its value must be a list of port numbers;
29139 the most common use is expected to be:
29140 .code
29141 tls_on_connect_ports = 465
29142 .endd
29143 The port numbers specified by this option apply to all SMTP connections, both
29144 via the daemon and via &'inetd'&. You still need to specify all the ports that
29145 the daemon uses (by setting &%daemon_smtp_ports%& or &%local_interfaces%& or
29146 the &%-oX%& command line option) because &%tls_on_connect_ports%& does not add
29147 an extra port &-- rather, it specifies different behaviour on a port that is
29148 defined elsewhere.
29149
29150 There is also a &%-tls-on-connect%& command line option. This overrides
29151 &%tls_on_connect_ports%&; it forces the TLS-only behaviour for all ports.
29152
29153
29154
29155
29156
29157
29158 .section "OpenSSL vs GnuTLS" "SECTopenvsgnu"
29159 .cindex "TLS" "OpenSSL &'vs'& GnuTLS"
29160 TLS is supported in Exim using either the OpenSSL or GnuTLS library.
29161 To build Exim to use OpenSSL you need to set
29162 .code
29163 USE_OPENSSL=yes
29164 .endd
29165 in Local/Makefile.
29166
29167 To build Exim to use GnuTLS, you need to set
29168 .code
29169 USE_GNUTLS=yes
29170 .endd
29171 in Local/Makefile.
29172
29173 You must also set TLS_LIBS and TLS_INCLUDE appropriately, so that the
29174 include files and libraries for GnuTLS can be found.
29175
29176 There are some differences in usage when using GnuTLS instead of OpenSSL:
29177
29178 .ilist
29179 The &%tls_verify_certificates%& option
29180 cannot be the path of a directory
29181 for GnuTLS versions before 3.3.6
29182 (for later versions, or OpenSSL, it can be either).
29183 .next
29184 The default value for &%tls_dhparam%& differs for historical reasons.
29185 .next
29186 .vindex "&$tls_in_peerdn$&"
29187 .vindex "&$tls_out_peerdn$&"
29188 Distinguished Name (DN) strings reported by the OpenSSL library use a slash for
29189 separating fields; GnuTLS uses commas, in accordance with RFC 2253. This
29190 affects the value of the &$tls_in_peerdn$& and &$tls_out_peerdn$& variables.
29191 .next
29192 OpenSSL identifies cipher suites using hyphens as separators, for example:
29193 DES-CBC3-SHA. GnuTLS historically used underscores, for example:
29194 RSA_ARCFOUR_SHA. What is more, OpenSSL complains if underscores are present
29195 in a cipher list. To make life simpler, Exim changes underscores to hyphens
29196 for OpenSSL and passes the string unchanged to GnuTLS (expecting the library
29197 to handle its own older variants) when processing lists of cipher suites in the
29198 &%tls_require_ciphers%& options (the global option and the &(smtp)& transport
29199 option).
29200 .next
29201 The &%tls_require_ciphers%& options operate differently, as described in the
29202 sections &<<SECTreqciphssl>>& and &<<SECTreqciphgnu>>&.
29203 .next
29204 The &%tls_dh_min_bits%& SMTP transport option is only honoured by GnuTLS.
29205 When using OpenSSL, this option is ignored.
29206 (If an API is found to let OpenSSL be configured in this way,
29207 let the Exim Maintainers know and we'll likely use it).
29208 .next
29209 With GnuTLS, if an explicit list is used for the &%tls_privatekey%& main option,
29210 it must be ordered to match the &%tls_certificate%& list.
29211 .next
29212 Some other recently added features may only be available in one or the other.
29213 This should be documented with the feature.  If the documentation does not
29214 explicitly state that the feature is infeasible in the other TLS
29215 implementation, then patches are welcome.
29216 .next
29217 The output from "exim -bV" will show which (if any) support was included
29218 in the build.
29219 Also, the macro "_HAVE_OPENSSL" or "_HAVE_GNUTLS" will be defined.
29220 .endlist
29221
29222
29223 .section "GnuTLS parameter computation" "SECTgnutlsparam"
29224 This section only applies if &%tls_dhparam%& is set to &`historic`& or to
29225 an explicit path; if the latter, then the text about generation still applies,
29226 but not the chosen filename.
29227 By default, as of Exim 4.80 a hard-coded D-H prime is used.
29228 See the documentation of &%tls_dhparam%& for more information.
29229
29230 GnuTLS uses D-H parameters that may take a substantial amount of time
29231 to compute. It is unreasonable to re-compute them for every TLS session.
29232 Therefore, Exim keeps this data in a file in its spool directory, called
29233 &_gnutls-params-NNNN_& for some value of NNNN, corresponding to the number
29234 of bits requested.
29235 The file is owned by the Exim user and is readable only by
29236 its owner. Every Exim process that start up GnuTLS reads the D-H
29237 parameters from this file. If the file does not exist, the first Exim process
29238 that needs it computes the data and writes it to a temporary file which is
29239 renamed once it is complete. It does not matter if several Exim processes do
29240 this simultaneously (apart from wasting a few resources). Once a file is in
29241 place, new Exim processes immediately start using it.
29242
29243 For maximum security, the parameters that are stored in this file should be
29244 recalculated periodically, the frequency depending on your paranoia level.
29245 If you are avoiding using the fixed D-H primes published in RFCs, then you
29246 are concerned about some advanced attacks and will wish to do this; if you do
29247 not regenerate then you might as well stick to the standard primes.
29248
29249 Arranging this is easy in principle; just delete the file when you want new
29250 values to be computed. However, there may be a problem. The calculation of new
29251 parameters needs random numbers, and these are obtained from &_/dev/random_&.
29252 If the system is not very active, &_/dev/random_& may delay returning data
29253 until enough randomness (entropy) is available. This may cause Exim to hang for
29254 a substantial amount of time, causing timeouts on incoming connections.
29255
29256 The solution is to generate the parameters externally to Exim. They are stored
29257 in &_gnutls-params-N_& in PEM format, which means that they can be
29258 generated externally using the &(certtool)& command that is part of GnuTLS.
29259
29260 To replace the parameters with new ones, instead of deleting the file
29261 and letting Exim re-create it, you can generate new parameters using
29262 &(certtool)& and, when this has been done, replace Exim's cache file by
29263 renaming. The relevant commands are something like this:
29264 .code
29265 # ls
29266 [ look for file; assume gnutls-params-2236 is the most recent ]
29267 # rm -f new-params
29268 # touch new-params
29269 # chown exim:exim new-params
29270 # chmod 0600 new-params
29271 # certtool --generate-dh-params --bits 2236 >>new-params
29272 # openssl dhparam -noout -text -in new-params | head
29273 [ check the first line, make sure it's not more than 2236;
29274   if it is, then go back to the start ("rm") and repeat
29275   until the size generated is at most the size requested ]
29276 # chmod 0400 new-params
29277 # mv new-params gnutls-params-2236
29278 .endd
29279 If Exim never has to generate the parameters itself, the possibility of
29280 stalling is removed.
29281
29282 The filename changed in Exim 4.80, to gain the -bits suffix.  The value which
29283 Exim will choose depends upon the version of GnuTLS in use.  For older GnuTLS,
29284 the value remains hard-coded in Exim as 1024.  As of GnuTLS 2.12.x, there is
29285 a way for Exim to ask for the "normal" number of bits for D-H public-key usage,
29286 and Exim does so.  This attempt to remove Exim from TLS policy decisions
29287 failed, as GnuTLS 2.12 returns a value higher than the current hard-coded limit
29288 of the NSS library.  Thus Exim gains the &%tls_dh_max_bits%& global option,
29289 which applies to all D-H usage, client or server.  If the value returned by
29290 GnuTLS is greater than &%tls_dh_max_bits%& then the value will be clamped down
29291 to &%tls_dh_max_bits%&.  The default value has been set at the current NSS
29292 limit, which is still much higher than Exim historically used.
29293
29294 The filename and bits used will change as the GnuTLS maintainers change the
29295 value for their parameter &`GNUTLS_SEC_PARAM_NORMAL`&, as clamped by
29296 &%tls_dh_max_bits%&.  At the time of writing (mid 2012), GnuTLS 2.12 recommends
29297 2432 bits, while NSS is limited to 2236 bits.
29298
29299 In fact, the requested value will be *lower* than &%tls_dh_max_bits%&, to
29300 increase the chance of the generated prime actually being within acceptable
29301 bounds, as GnuTLS has been observed to overshoot.  Note the check step in the
29302 procedure above.  There is no sane procedure available to Exim to double-check
29303 the size of the generated prime, so it might still be too large.
29304
29305
29306 .section "Requiring specific ciphers in OpenSSL" "SECTreqciphssl"
29307 .cindex "TLS" "requiring specific ciphers (OpenSSL)"
29308 .oindex "&%tls_require_ciphers%&" "OpenSSL"
29309 There is a function in the OpenSSL library that can be passed a list of cipher
29310 suites before the cipher negotiation takes place. This specifies which ciphers
29311 are acceptable for TLS versions prior to 1.3.
29312 The list is colon separated and may contain names like
29313 DES-CBC3-SHA. Exim passes the expanded value of &%tls_require_ciphers%&
29314 directly to this function call.
29315 Many systems will install the OpenSSL manual-pages, so you may have
29316 &'ciphers(1)'& available to you.
29317 The following quotation from the OpenSSL
29318 documentation specifies what forms of item are allowed in the cipher string:
29319
29320 .ilist
29321 It can consist of a single cipher suite such as RC4-SHA.
29322 .next
29323 It can represent a list of cipher suites containing a certain algorithm,
29324 or cipher suites of a certain type. For example SHA1 represents all
29325 ciphers suites using the digest algorithm SHA1 and SSLv3 represents all
29326 SSL v3 algorithms.
29327 .next
29328 Lists of cipher suites can be combined in a single cipher string using
29329 the + character. This is used as a logical and operation. For example
29330 SHA1+DES represents all cipher suites containing the SHA1 and the DES
29331 algorithms.
29332 .endlist
29333
29334 Each cipher string can be optionally preceded by one of the characters &`!`&,
29335 &`-`& or &`+`&.
29336 .ilist
29337 If &`!`& is used, the ciphers are permanently deleted from the list. The
29338 ciphers deleted can never reappear in the list even if they are explicitly
29339 stated.
29340 .next
29341 If &`-`& is used, the ciphers are deleted from the list, but some or all
29342 of the ciphers can be added again by later options.
29343 .next
29344 If &`+`& is used, the ciphers are moved to the end of the list. This
29345 option does not add any new ciphers; it just moves matching existing ones.
29346 .endlist
29347
29348 If none of these characters is present, the string is interpreted as
29349 a list of ciphers to be appended to the current preference list. If the list
29350 includes any ciphers already present they will be ignored: that is, they will
29351 not be moved to the end of the list.
29352 .endlist
29353
29354 The OpenSSL &'ciphers(1)'& command may be used to test the results of a given
29355 string:
29356 .code
29357 # note single-quotes to get ! past any shell history expansion
29358 $ openssl ciphers 'HIGH:!MD5:!SHA1'
29359 .endd
29360
29361 This example will let the library defaults be permitted on the MX port, where
29362 there's probably no identity verification anyway, but ups the ante on the
29363 submission ports where the administrator might have some influence on the
29364 choice of clients used:
29365 .code
29366 # OpenSSL variant; see man ciphers(1)
29367 tls_require_ciphers = ${if =={$received_port}{25}\
29368                            {DEFAULT}\
29369                            {HIGH:!MD5:!SHA1}}
29370 .endd
29371
29372 This example will prefer ECDSA-authenticated ciphers over RSA ones:
29373 .code
29374 tls_require_ciphers = ECDSA:RSA:!COMPLEMENTOFDEFAULT
29375 .endd
29376
29377 For TLS version 1.3 the control available is less fine-grained
29378 and Exim does not provide access to it at present.
29379 The value of the &%tls_require_ciphers%& option is ignored when
29380 TLS version 1.3 is negotiated.
29381
29382 As of writing the library default cipher suite list for TLSv1.3 is
29383 .code
29384 TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256
29385 .endd
29386
29387
29388 .section "Requiring specific ciphers or other parameters in GnuTLS" &&&
29389          "SECTreqciphgnu"
29390 .cindex "GnuTLS" "specifying parameters for"
29391 .cindex "TLS" "specifying ciphers (GnuTLS)"
29392 .cindex "TLS" "specifying key exchange methods (GnuTLS)"
29393 .cindex "TLS" "specifying MAC algorithms (GnuTLS)"
29394 .cindex "TLS" "specifying protocols (GnuTLS)"
29395 .cindex "TLS" "specifying priority string (GnuTLS)"
29396 .oindex "&%tls_require_ciphers%&" "GnuTLS"
29397 The GnuTLS library allows the caller to provide a "priority string", documented
29398 as part of the &[gnutls_priority_init]& function.  This is very similar to the
29399 ciphersuite specification in OpenSSL.
29400
29401 The &%tls_require_ciphers%& option is treated as the GnuTLS priority string
29402 and controls both protocols and ciphers.
29403
29404 The &%tls_require_ciphers%& option is available both as an global option,
29405 controlling how Exim behaves as a server, and also as an option of the
29406 &(smtp)& transport, controlling how Exim behaves as a client.  In both cases
29407 the value is string expanded.  The resulting string is not an Exim list and
29408 the string is given to the GnuTLS library, so that Exim does not need to be
29409 aware of future feature enhancements of GnuTLS.
29410
29411 Documentation of the strings accepted may be found in the GnuTLS manual, under
29412 "Priority strings".  This is online as
29413 &url(https://www.gnutls.org/manual/html_node/Priority-Strings.html),
29414 but beware that this relates to GnuTLS 3, which may be newer than the version
29415 installed on your system.  If you are using GnuTLS 3,
29416 then the example code
29417 &url(https://www.gnutls.org/manual/gnutls.html#Listing-the-ciphersuites-in-a-priority-string)
29418 on that site can be used to test a given string.
29419
29420 For example:
29421 .code
29422 # Disable older versions of protocols
29423 tls_require_ciphers = NORMAL:%LATEST_RECORD_VERSION:-VERS-SSL3.0
29424 .endd
29425
29426 Prior to Exim 4.80, an older API of GnuTLS was used, and Exim supported three
29427 additional options, "&%gnutls_require_kx%&", "&%gnutls_require_mac%&" and
29428 "&%gnutls_require_protocols%&".  &%tls_require_ciphers%& was an Exim list.
29429
29430 This example will let the library defaults be permitted on the MX port, where
29431 there's probably no identity verification anyway, and lowers security further
29432 by increasing compatibility; but this ups the ante on the submission ports
29433 where the administrator might have some influence on the choice of clients
29434 used:
29435 .code
29436 # GnuTLS variant
29437 tls_require_ciphers = ${if =={$received_port}{25}\
29438                            {NORMAL:%COMPAT}\
29439                            {SECURE128}}
29440 .endd
29441
29442
29443 .section "Configuring an Exim server to use TLS" "SECID182"
29444 .cindex "TLS" "configuring an Exim server"
29445 .cindex "ESMTP extensions" STARTTLS
29446 When Exim has been built with TLS support, it advertises the availability of
29447 the STARTTLS command to client hosts that match &%tls_advertise_hosts%&,
29448 but not to any others. The default value of this option is *, which means
29449 that STARTTLS is always advertised.  Set it to blank to never advertise;
29450 this is reasonable for systems that want to use TLS only as a client.
29451
29452 If STARTTLS is to be used you
29453 need to set some other options in order to make TLS available.
29454
29455 If a client issues a STARTTLS command and there is some configuration
29456 problem in the server, the command is rejected with a 454 error. If the client
29457 persists in trying to issue SMTP commands, all except QUIT are rejected
29458 with the error
29459 .code
29460 554 Security failure
29461 .endd
29462 If a STARTTLS command is issued within an existing TLS session, it is
29463 rejected with a 554 error code.
29464
29465 To enable TLS operations on a server, the &%tls_advertise_hosts%& option
29466 must be set to match some hosts. The default is * which matches all hosts.
29467
29468 If this is all you do, TLS encryption will be enabled but not authentication -
29469 meaning that the peer has no assurance it is actually you he is talking to.
29470 You gain protection from a passive sniffer listening on the wire but not
29471 from someone able to intercept the communication.
29472
29473 Further protection requires some further configuration at the server end.
29474
29475 To make TLS work you need to set, in the server,
29476 .code
29477 tls_certificate = /some/file/name
29478 tls_privatekey = /some/file/name
29479 .endd
29480 These options are, in fact, expanded strings, so you can make them depend on
29481 the identity of the client that is connected if you wish. The first file
29482 contains the server's X509 certificate, and the second contains the private key
29483 that goes with it. These files need to be
29484 PEM format and readable by the Exim user, and must
29485 always be given as full path names.
29486 The key must not be password-protected.
29487 They can be the same file if both the
29488 certificate and the key are contained within it. If &%tls_privatekey%& is not
29489 set, or if its expansion is forced to fail or results in an empty string, this
29490 is assumed to be the case. The certificate file may also contain intermediate
29491 certificates that need to be sent to the client to enable it to authenticate
29492 the server's certificate.
29493
29494 For dual-stack (eg. RSA and ECDSA) configurations, these options can be
29495 colon-separated lists of file paths.  Ciphers using given authentication
29496 algorithms require the presence of a suitable certificate to supply the
29497 public-key.  The server selects among the certificates to present to the
29498 client depending on the selected cipher, hence the priority ordering for
29499 ciphers will affect which certificate is used.
29500
29501 If you do not understand about certificates and keys, please try to find a
29502 source of this background information, which is not Exim-specific. (There are a
29503 few comments below in section &<<SECTcerandall>>&.)
29504
29505 &*Note*&: These options do not apply when Exim is operating as a client &--
29506 they apply only in the case of a server. If you need to use a certificate in an
29507 Exim client, you must set the options of the same names in an &(smtp)&
29508 transport.
29509
29510 With just these options, an Exim server will be able to use TLS. It does not
29511 require the client to have a certificate (but see below for how to insist on
29512 this). There is one other option that may be needed in other situations. If
29513 .code
29514 tls_dhparam = /some/file/name
29515 .endd
29516 is set, the SSL library is initialized for the use of Diffie-Hellman ciphers
29517 with the parameters contained in the file.
29518 Set this to &`none`& to disable use of DH entirely, by making no prime
29519 available:
29520 .code
29521 tls_dhparam = none
29522 .endd
29523 This may also be set to a string identifying a standard prime to be used for
29524 DH; if it is set to &`default`& or, for OpenSSL, is unset, then the prime
29525 used is &`ike23`&.  There are a few standard primes available, see the
29526 documentation for &%tls_dhparam%& for the complete list.
29527
29528 See the command
29529 .code
29530 openssl dhparam
29531 .endd
29532 for a way of generating file data.
29533
29534 The strings supplied for these three options are expanded every time a client
29535 host connects. It is therefore possible to use different certificates and keys
29536 for different hosts, if you so wish, by making use of the client's IP address
29537 in &$sender_host_address$& to control the expansion. If a string expansion is
29538 forced to fail, Exim behaves as if the option is not set.
29539
29540 .cindex "cipher" "logging"
29541 .cindex "log" "TLS cipher"
29542 .vindex "&$tls_in_cipher$&"
29543 The variable &$tls_in_cipher$& is set to the cipher suite that was negotiated for
29544 an incoming TLS connection. It is included in the &'Received:'& header of an
29545 incoming message (by default &-- you can, of course, change this), and it is
29546 also included in the log line that records a message's arrival, keyed by
29547 &"X="&, unless the &%tls_cipher%& log selector is turned off. The &%encrypted%&
29548 condition can be used to test for specific cipher suites in ACLs.
29549
29550 Once TLS has been established, the ACLs that run for subsequent SMTP commands
29551 can check the name of the cipher suite and vary their actions accordingly. The
29552 cipher suite names vary, depending on which TLS library is being used. For
29553 example, OpenSSL uses the name DES-CBC3-SHA for the cipher suite which in other
29554 contexts is known as TLS_RSA_WITH_3DES_EDE_CBC_SHA. Check the OpenSSL or GnuTLS
29555 documentation for more details.
29556
29557 For outgoing SMTP deliveries, &$tls_out_cipher$& is used and logged
29558 (again depending on the &%tls_cipher%& log selector).
29559
29560
29561 .subsection "Requesting and verifying client certificates"
29562 .cindex "certificate" "verification of client"
29563 .cindex "TLS" "client certificate verification"
29564 If you want an Exim server to request a certificate when negotiating a TLS
29565 session with a client, you must set either &%tls_verify_hosts%& or
29566 &%tls_try_verify_hosts%&. You can, of course, set either of them to * to
29567 apply to all TLS connections. For any host that matches one of these options,
29568 Exim requests a certificate as part of the setup of the TLS session. The
29569 contents of the certificate are verified by comparing it with a list of
29570 expected trust-anchors or certificates.
29571 These may be the system default set (depending on library version),
29572 an explicit file or,
29573 depending on library version, a directory, identified by
29574 &%tls_verify_certificates%&.
29575
29576 A file can contain multiple certificates, concatenated end to end. If a
29577 directory is used
29578 (OpenSSL only),
29579 each certificate must be in a separate file, with a name (or a symbolic link)
29580 of the form <&'hash'&>.0, where <&'hash'&> is a hash value constructed from the
29581 certificate. You can compute the relevant hash by running the command
29582 .code
29583 openssl x509 -hash -noout -in /cert/file
29584 .endd
29585 where &_/cert/file_& contains a single certificate.
29586
29587 There is no checking of names of the client against the certificate
29588 Subject Name or Subject Alternate Names.
29589
29590 The difference between &%tls_verify_hosts%& and &%tls_try_verify_hosts%& is
29591 what happens if the client does not supply a certificate, or if the certificate
29592 does not match any of the certificates in the collection named by
29593 &%tls_verify_certificates%&. If the client matches &%tls_verify_hosts%&, the
29594 attempt to set up a TLS session is aborted, and the incoming connection is
29595 dropped. If the client matches &%tls_try_verify_hosts%&, the (encrypted) SMTP
29596 session continues. ACLs that run for subsequent SMTP commands can detect the
29597 fact that no certificate was verified, and vary their actions accordingly. For
29598 example, you can insist on a certificate before accepting a message for
29599 relaying, but not when the message is destined for local delivery.
29600
29601 .vindex "&$tls_in_peerdn$&"
29602 When a client supplies a certificate (whether it verifies or not), the value of
29603 the Distinguished Name of the certificate is made available in the variable
29604 &$tls_in_peerdn$& during subsequent processing of the message.
29605
29606 .cindex "log" "distinguished name"
29607 Because it is often a long text string, it is not included in the log line or
29608 &'Received:'& header by default. You can arrange for it to be logged, keyed by
29609 &"DN="&, by setting the &%tls_peerdn%& log selector, and you can use
29610 &%received_header_text%& to change the &'Received:'& header. When no
29611 certificate is supplied, &$tls_in_peerdn$& is empty.
29612
29613
29614 .subsection "Caching of static server configuration items" "SSECTserverTLScache"
29615 .cindex certificate caching
29616 .cindex privatekey caching
29617 .cindex crl caching
29618 .cindex ocsp caching
29619 .cindex ciphers caching
29620 .cindex "CA bundle" caching
29621 .cindex "certificate authorities" caching
29622 .cindex tls_certificate caching
29623 .cindex tls_privatekey caching
29624 .cindex tls_crl caching
29625 .cindex tls_ocsp_file caching
29626 .cindex tls_require_ciphers caching
29627 .cindex tls_verify_certificate caching
29628 .cindex caching certificate
29629 .cindex caching privatekey
29630 .cindex caching crl
29631 .cindex caching ocsp
29632 .cindex caching ciphers
29633 .cindex caching "certificate authorities
29634 If any of the main configuration options &%tls_certificate%&, &%tls_privatekey%&,
29635 &%tls_crl%& and &%tls_ocsp_file%& have values with no
29636 expandable elements,
29637 then the associated information is loaded at daemon startup.
29638 It is made available
29639 to child processes forked for handling received SMTP connections.
29640
29641 This caching is currently only supported under Linux and FreeBSD.
29642
29643 If caching is not possible, for example if an item has to be dependent
29644 on the peer host so contains a &$sender_host_name$& expansion, the load
29645 of the associated information is done at the startup of the TLS connection.
29646
29647 The cache is invalidated and reloaded after any changes to the directories
29648 containing files specified by these options.
29649
29650 The information specified by the main option &%tls_verify_certificates%&
29651 is similarly cached so long as it specifies files explicitly
29652 or (under GnuTLS) is the string &"system,cache"&.
29653 The latter case is not automatically invalidated;
29654 it is the operator's responsibility to arrange for a daemon restart
29655 any time the system certificate authority bundle is updated.
29656 A HUP signal is sufficient for this.
29657 The value &"system"& results in no caching under GnuTLS.
29658
29659 The macro _HAVE_TLS_CA_CACHE will be defined if the suffix for "system"
29660 is acceptable in configurations for the Exim executable.
29661
29662 Caching of the system Certificate Authorities bundle can
29663 save significant time and processing on every TLS connection
29664 accepted by Exim.
29665
29666
29667
29668
29669 .section "Configuring an Exim client to use TLS" "SECTclientTLS"
29670 .cindex "cipher" "logging"
29671 .cindex "log" "TLS cipher"
29672 .cindex "log" "distinguished name"
29673 .cindex "TLS" "configuring an Exim client"
29674 The &%tls_cipher%& and &%tls_peerdn%& log selectors apply to outgoing SMTP
29675 deliveries as well as to incoming, the latter one causing logging of the
29676 server certificate's DN. The remaining client configuration for TLS is all
29677 within the &(smtp)& transport.
29678
29679 .cindex "ESMTP extensions" STARTTLS
29680 It is not necessary to set any options to have TLS work in the &(smtp)&
29681 transport. If Exim is built with TLS support, and TLS is advertised by a
29682 server, the &(smtp)& transport always tries to start a TLS session. However,
29683 this can be prevented by setting &%hosts_avoid_tls%& (an option of the
29684 transport) to a list of server hosts for which TLS should not be used.
29685
29686 If you do not want Exim to attempt to send messages unencrypted when an attempt
29687 to set up an encrypted connection fails in any way, you can set
29688 &%hosts_require_tls%& to a list of hosts for which encryption is mandatory. For
29689 those hosts, delivery is always deferred if an encrypted connection cannot be
29690 set up. If there are any other hosts for the address, they are tried in the
29691 usual way.
29692
29693 When the server host is not in &%hosts_require_tls%&, Exim may try to deliver
29694 the message unencrypted. It always does this if the response to STARTTLS is
29695 a 5&'xx'& code. For a temporary error code, or for a failure to negotiate a TLS
29696 session after a success response code, what happens is controlled by the
29697 &%tls_tempfail_tryclear%& option of the &(smtp)& transport. If it is false,
29698 delivery to this host is deferred, and other hosts (if available) are tried. If
29699 it is true, Exim attempts to deliver unencrypted after a 4&'xx'& response to
29700 STARTTLS, and if STARTTLS is accepted, but the subsequent TLS
29701 negotiation fails, Exim closes the current connection (because it is in an
29702 unknown state), opens a new one to the same host, and then tries the delivery
29703 unencrypted.
29704
29705 The &%tls_certificate%& and &%tls_privatekey%& options of the &(smtp)&
29706 transport provide the client with a certificate, which is passed to the server
29707 if it requests it.
29708 This is an optional thing for TLS connections, although either end
29709 may insist on it.
29710 If the server is Exim, it will request a certificate only if
29711 &%tls_verify_hosts%& or &%tls_try_verify_hosts%& matches the client.
29712
29713 &*Note*&: Do not use a certificate which has the OCSP-must-staple extension,
29714 for client use (they are usable for server use).
29715 As the TLS protocol has no means for the client to staple before TLS 1.3 it will result
29716 in failed connections.
29717
29718 If the &%tls_verify_certificates%& option is set on the &(smtp)& transport, it
29719 specifies a collection of expected server certificates.
29720 These may be
29721 the system default set (depending on library version),
29722 a file,
29723 or (depending on library version) a directory.
29724 The client verifies the server's certificate
29725 against this collection, taking into account any revoked certificates that are
29726 in the list defined by &%tls_crl%&.
29727 Failure to verify fails the TLS connection unless either of the
29728 &%tls_verify_hosts%& or &%tls_try_verify_hosts%& options are set.
29729
29730 The &%tls_verify_hosts%& and &%tls_try_verify_hosts%& options restrict
29731 certificate verification to the listed servers.  Verification either must
29732 or need not succeed respectively.
29733
29734 The &%tls_verify_cert_hostnames%& option lists hosts for which additional
29735 name checks are made on the server certificate.
29736 The match against this list is, as per other Exim usage, the
29737 IP for the host.  That is most closely associated with the
29738 name on the DNS A (or AAAA) record for the host.
29739 However, the name that needs to be in the certificate
29740 is the one at the head of any CNAME chain leading to the A record.
29741 The option defaults to always checking.
29742
29743 The &(smtp)& transport has two OCSP-related options:
29744 &%hosts_require_ocsp%&; a host-list for which a Certificate Status
29745 is requested and required for the connection to proceed.  The default
29746 value is empty.
29747 &%hosts_request_ocsp%&; a host-list for which (additionally)
29748 a Certificate Status is requested (but not necessarily verified).  The default
29749 value is "*" meaning that requests are made unless configured
29750 otherwise.
29751
29752 The host(s) should also be in &%hosts_require_tls%&, and
29753 &%tls_verify_certificates%& configured for the transport,
29754 for OCSP to be relevant.
29755
29756 If
29757 &%tls_require_ciphers%& is set on the &(smtp)& transport, it must contain a
29758 list of permitted cipher suites. If either of these checks fails, delivery to
29759 the current host is abandoned, and the &(smtp)& transport tries to deliver to
29760 alternative hosts, if any.
29761
29762  &*Note*&:
29763 These options must be set in the &(smtp)& transport for Exim to use TLS when it
29764 is operating as a client. Exim does not assume that a server certificate (set
29765 by the global options of the same name) should also be used when operating as a
29766 client.
29767
29768 .vindex "&$host$&"
29769 .vindex "&$host_address$&"
29770 All the TLS options in the &(smtp)& transport are expanded before use, with
29771 &$host$& and &$host_address$& containing the name and address of the server to
29772 which the client is connected. Forced failure of an expansion causes Exim to
29773 behave as if the relevant option were unset.
29774
29775 .vindex &$tls_out_bits$&
29776 .vindex &$tls_out_cipher$&
29777 .vindex &$tls_out_peerdn$&
29778 .vindex &$tls_out_sni$&
29779 Before an SMTP connection is established, the
29780 &$tls_out_bits$&, &$tls_out_cipher$&, &$tls_out_peerdn$& and &$tls_out_sni$&
29781 variables are emptied. (Until the first connection, they contain the values
29782 that were set when the message was received.) If STARTTLS is subsequently
29783 successfully obeyed, these variables are set to the relevant values for the
29784 outgoing connection.
29785
29786
29787
29788 .subsection "Caching of static client configuration items" SECTclientTLScache
29789 .cindex certificate caching
29790 .cindex privatekey caching
29791 .cindex crl caching
29792 .cindex ciphers caching
29793 .cindex "CA bundle" caching
29794 .cindex "certificate authorities" caching
29795 .cindex tls_certificate caching
29796 .cindex tls_privatekey caching
29797 .cindex tls_crl caching
29798 .cindex tls_require_ciphers caching
29799 .cindex tls_verify_certificate caching
29800 .cindex caching certificate
29801 .cindex caching privatekey
29802 .cindex caching crl
29803 .cindex caching ciphers
29804 .cindex caching "certificate authorities
29805 If any of the transport configuration options &%tls_certificate%&, &%tls_privatekey%&
29806 and &%tls_crl%& have values with no
29807 expandable elements,
29808 then the associated information is loaded per smtp transport
29809 at daemon startup, at the start of a queue run, or on a
29810 command-line specified message delivery.
29811 It is made available
29812 to child processes forked for handling making SMTP connections.
29813
29814 This caching is currently only supported under Linux.
29815
29816 If caching is not possible, the load
29817 of the associated information is done at the startup of the TLS connection.
29818
29819 The cache is invalidated in the daemon
29820 and reloaded after any changes to the directories
29821 containing files specified by these options.
29822
29823 The information specified by the main option &%tls_verify_certificates%&
29824 is similarly cached so long as it specifies files explicitly
29825 or (under GnuTLS) is the string &"system,cache"&.
29826 The latter case is not automatically invaludated;
29827 it is the operator's responsibility to arrange for a daemon restart
29828 any time the system certificate authority bundle is updated.
29829 A HUP signal is sufficient for this.
29830 The value &"system"& results in no caching under GnuTLS.
29831
29832 The macro _HAVE_TLS_CA_CACHE will be defined if the suffix for "system"
29833 is acceptable in configurations for the Exim executable.
29834
29835 Caching of the system Certificate Authorities bundle can
29836 save significant time and processing on every TLS connection
29837 initiated by Exim.
29838
29839
29840
29841
29842 .section "Use of TLS Server Name Indication" "SECTtlssni"
29843 .cindex "TLS" "Server Name Indication"
29844 .cindex "TLS" SNI
29845 .cindex SNI
29846 .vindex "&$tls_in_sni$&"
29847 .oindex "&%tls_in_sni%&"
29848 With TLS1.0 or above, there is an extension mechanism by which extra
29849 information can be included at various points in the protocol.  One of these
29850 extensions, documented in RFC 6066 (and before that RFC 4366) is
29851 &"Server Name Indication"&, commonly &"SNI"&.  This extension is sent by the
29852 client in the initial handshake, so that the server can examine the servername
29853 within and possibly choose to use different certificates and keys (and more)
29854 for this session.
29855
29856 This is analogous to HTTP's &"Host:"& header, and is the main mechanism by
29857 which HTTPS-enabled web-sites can be virtual-hosted, many sites to one IP
29858 address.
29859
29860 With SMTP to MX, there are the same problems here as in choosing the identity
29861 against which to validate a certificate: you can't rely on insecure DNS to
29862 provide the identity which you then cryptographically verify.  So this will
29863 be of limited use in that environment.
29864
29865 With SMTP to Submission, there is a well-defined hostname which clients are
29866 connecting to and can validate certificates against.  Thus clients &*can*&
29867 choose to include this information in the TLS negotiation.  If this becomes
29868 wide-spread, then hosters can choose to present different certificates to
29869 different clients.  Or even negotiate different cipher suites.
29870
29871 The &%tls_sni%& option on an SMTP transport is an expanded string; the result,
29872 if not empty, will be sent on a TLS session as part of the handshake.  There's
29873 nothing more to it.  Choosing a sensible value not derived insecurely is the
29874 only point of caution.  The &$tls_out_sni$& variable will be set to this string
29875 for the lifetime of the client connection (including during authentication).
29876
29877 If DANE validated the connection attempt then the value of the &%tls_sni%& option
29878 is forced to the name of the destination host, after any MX- or CNAME-following.
29879
29880 Except during SMTP client sessions, if &$tls_in_sni$& is set then it is a string
29881 received from a client.
29882 It can be logged with the &%log_selector%& item &`+tls_sni`&.
29883
29884 If the string &`tls_in_sni`& appears in the main section's &%tls_certificate%&
29885 option (prior to expansion) then the following options will be re-expanded
29886 during TLS session handshake, to permit alternative values to be chosen:
29887
29888 .ilist
29889 &%tls_certificate%&
29890 .next
29891 &%tls_crl%&
29892 .next
29893 &%tls_privatekey%&
29894 .next
29895 &%tls_verify_certificates%&
29896 .next
29897 &%tls_ocsp_file%&
29898 .endlist
29899
29900 Great care should be taken to deal with matters of case, various injection
29901 attacks in the string (&`../`& or SQL), and ensuring that a valid filename
29902 can always be referenced; it is important to remember that &$tls_in_sni$& is
29903 arbitrary unverified data provided prior to authentication.
29904 Further, the initial certificate is loaded before SNI has arrived, so
29905 an expansion for &%tls_certificate%& must have a default which is used
29906 when &$tls_in_sni$& is empty.
29907
29908 The Exim developers are proceeding cautiously and so far no other TLS options
29909 are re-expanded.
29910
29911 When Exim is built against OpenSSL, OpenSSL must have been built with support
29912 for TLS Extensions.  This holds true for OpenSSL 1.0.0+ and 0.9.8+ with
29913 enable-tlsext in EXTRACONFIGURE.  If you invoke &(openssl s_client -h)& and
29914 see &`-servername`& in the output, then OpenSSL has support.
29915
29916 When Exim is built against GnuTLS, SNI support is available as of GnuTLS
29917 0.5.10.  (Its presence predates the current API which Exim uses, so if Exim
29918 built, then you have SNI support).
29919
29920 .subsection ALPN
29921 .cindex TLS ALPN
29922 .cindex ALPN "general information"
29923 .cindex TLS "Application Layer Protocol Names"
29924 There is a TLS feature related to SNI
29925 called Application Layer Protocol Name (ALPN).
29926 This is intended to declare, or select, what protocol layer will be using a TLS
29927 connection.
29928 The client for the connection proposes a set of protocol names, and
29929 the server responds with a selected one.
29930 It is not, as of 2021, commonly used for SMTP connections.
29931 However, to guard against misdirected or malicious use of web clients
29932 (which often do use ALPN) against MTA ports, Exim by default check that
29933 there is no incompatible ALPN specified by a client for a TLS connection.
29934 If there is, the connection is rejected.
29935
29936 As a client Exim does not supply ALPN by default.
29937 The behaviour of both client and server can be configured using the options
29938 &%tls_alpn%& and &%hosts_require_alpn%&.
29939 There are no variables providing observability.
29940 Some feature-specific logging may appear on denied connections, but this
29941 depends on the behaviour of the peer
29942 (not all peers can send a feature-specific TLS Alert).
29943
29944 This feature is available when Exim is built with
29945 OpenSSL 1.1.0 or later or GnuTLS 3.2.0 or later;
29946 the macro _HAVE_TLS_ALPN will be defined when this is so.
29947
29948
29949
29950 .section "Multiple messages on the same encrypted TCP/IP connection" &&&
29951          "SECTmulmessam"
29952 .cindex "multiple SMTP deliveries with TLS"
29953 .cindex "TLS" "multiple message deliveries"
29954 Exim sends multiple messages down the same TCP/IP connection by starting up
29955 an entirely new delivery process for each message, passing the socket from
29956 one process to the next. This implementation does not fit well with the use
29957 of TLS, because there is quite a lot of state information associated with a TLS
29958 connection, not just a socket identification. Passing all the state information
29959 to a new process is not feasible. Consequently, for sending using TLS Exim
29960 starts an additional proxy process for handling the encryption, piping the
29961 unencrypted data stream from and to the delivery processes.
29962
29963 An older mode of operation can be enabled on a per-host basis by the
29964 &%hosts_noproxy_tls%& option on the &(smtp)& transport.  If the host matches
29965 this list the proxy process described above is not used; instead Exim
29966 shuts down an existing TLS session being run by the delivery process
29967 before passing the socket to a new process. The new process may then
29968 try to start a new TLS session, and if successful, may try to re-authenticate
29969 if AUTH is in use, before sending the next message.
29970
29971 The RFC is not clear as to whether or not an SMTP session continues in clear
29972 after TLS has been shut down, or whether TLS may be restarted again later, as
29973 just described. However, if the server is Exim, this shutdown and
29974 reinitialization works. It is not known which (if any) other servers operate
29975 successfully if the client closes a TLS session and continues with unencrypted
29976 SMTP, but there are certainly some that do not work. For such servers, Exim
29977 should not pass the socket to another process, because the failure of the
29978 subsequent attempt to use it would cause Exim to record a temporary host error,
29979 and delay other deliveries to that host.
29980
29981 To test for this case, Exim sends an EHLO command to the server after
29982 closing down the TLS session. If this fails in any way, the connection is
29983 closed instead of being passed to a new delivery process, but no retry
29984 information is recorded.
29985
29986 There is also a manual override; you can set &%hosts_nopass_tls%& on the
29987 &(smtp)& transport to match those hosts for which Exim should not pass
29988 connections to new processes if TLS has been used.
29989
29990
29991
29992
29993 .section "Certificates and all that" "SECTcerandall"
29994 .cindex "certificate" "references to discussion"
29995 In order to understand fully how TLS works, you need to know about
29996 certificates, certificate signing, and certificate authorities.
29997 This is a large topic and an introductory guide is unsuitable for the Exim
29998 reference manual, so instead we provide pointers to existing documentation.
29999
30000 The Apache web-server was for a long time the canonical guide, so their
30001 documentation is a good place to start; their SSL module's Introduction
30002 document is currently at
30003 .display
30004 &url(https://httpd.apache.org/docs/current/ssl/ssl_intro.html)
30005 .endd
30006 and their FAQ is at
30007 .display
30008 &url(https://httpd.apache.org/docs/current/ssl/ssl_faq.html)
30009 .endd
30010
30011 Eric Rescorla's book, &'SSL and TLS'&, published by Addison-Wesley (ISBN
30012 0-201-61598-3) in 2001, contains both introductory and more in-depth
30013 descriptions.
30014 More recently Ivan Ristić's book &'Bulletproof SSL and TLS'&,
30015 published by Feisty Duck (ISBN 978-1907117046) in 2013 is good.
30016 Ivan is the author of the popular TLS testing tools at
30017 &url(https://www.ssllabs.com/).
30018
30019
30020 .subsection "Certificate chains" SECID186
30021 A file named by &%tls_certificate%& may contain more than one
30022 certificate. This is useful in the case where the certificate that is being
30023 sent is validated by an intermediate certificate which the other end does
30024 not have. Multiple certificates must be in the correct order in the file.
30025 First the host's certificate itself, then the first intermediate
30026 certificate to validate the issuer of the host certificate, then the next
30027 intermediate certificate to validate the issuer of the first intermediate
30028 certificate, and so on, until finally (optionally) the root certificate.
30029 The root certificate must already be trusted by the recipient for
30030 validation to succeed, of course, but if it's not preinstalled, sending the
30031 root certificate along with the rest makes it available for the user to
30032 install if the receiving end is a client MUA that can interact with a user.
30033
30034 Note that certificates using MD5 are unlikely to work on today's Internet;
30035 even if your libraries allow loading them for use in Exim when acting as a
30036 server, increasingly clients will not accept such certificates.  The error
30037 diagnostics in such a case can be frustratingly vague.
30038
30039
30040
30041 .subsection "Self-signed certificates" SECID187
30042 .cindex "certificate" "self-signed"
30043 You can create a self-signed certificate using the &'req'& command provided
30044 with OpenSSL, like this:
30045 . ==== Do not shorten the duration here without reading and considering
30046 . ==== the text below.  Please leave it at 9999 days.
30047 .code
30048 openssl req -x509 -newkey rsa:1024 -keyout file1 -out file2 \
30049             -days 9999 -nodes
30050 .endd
30051 &_file1_& and &_file2_& can be the same file; the key and the certificate are
30052 delimited and so can be identified independently. The &%-days%& option
30053 specifies a period for which the certificate is valid. The &%-nodes%& option is
30054 important: if you do not set it, the key is encrypted with a passphrase
30055 that you are prompted for, and any use that is made of the key causes more
30056 prompting for the passphrase. This is not helpful if you are going to use
30057 this certificate and key in an MTA, where prompting is not possible.
30058
30059 . ==== I expect to still be working 26 years from now.  The less technical
30060 . ==== debt I create, in terms of storing up trouble for my later years, the
30061 . ==== happier I will be then.  We really have reached the point where we
30062 . ==== should start, at the very least, provoking thought and making folks
30063 . ==== pause before proceeding, instead of leaving all the fixes until two
30064 . ==== years before 2^31 seconds after the 1970 Unix epoch.
30065 . ==== -pdp, 2012
30066 NB: we are now past the point where 9999 days takes us past the 32-bit Unix
30067 epoch.  If your system uses unsigned time_t (most do) and is 32-bit, then
30068 the above command might produce a date in the past.  Think carefully about
30069 the lifetime of the systems you're deploying, and either reduce the duration
30070 of the certificate or reconsider your platform deployment.  (At time of
30071 writing, reducing the duration is the most likely choice, but the inexorable
30072 progression of time takes us steadily towards an era where this will not
30073 be a sensible resolution).
30074
30075 A self-signed certificate made in this way is sufficient for testing, and
30076 may be adequate for all your requirements if you are mainly interested in
30077 encrypting transfers, and not in secure identification.
30078
30079 However, many clients require that the certificate presented by the server be a
30080 user (also called &"leaf"& or &"site"&) certificate, and not a self-signed
30081 certificate. In this situation, the self-signed certificate described above
30082 must be installed on the client host as a trusted root &'certification
30083 authority'& (CA), and the certificate used by Exim must be a user certificate
30084 signed with that self-signed certificate.
30085
30086 For information on creating self-signed CA certificates and using them to sign
30087 user certificates, see the &'General implementation overview'& chapter of the
30088 Open-source PKI book, available online at
30089 &url(https://sourceforge.net/projects/ospkibook/).
30090
30091
30092 .subsection "Revoked certificates"
30093 .cindex "TLS" "revoked certificates"
30094 .cindex "revocation list"
30095 .cindex "certificate" "revocation list"
30096 .cindex "OCSP" "stapling"
30097 There are three ways for a certificate to be made unusable
30098 before its expiry.
30099
30100 .ilist
30101 Certificate issuing authorities issue Certificate Revocation Lists (CRLs) when
30102 certificates are revoked. If you have such a list, you can pass it to an Exim
30103 server using the global option called &%tls_crl%& and to an Exim client using
30104 an identically named option for the &(smtp)& transport. In each case, the value
30105 of the option is expanded and must then be the name of a file that contains a
30106 CRL in PEM format.
30107 The downside is that clients have to periodically re-download a potentially huge
30108 file from every certificate authority they know of.
30109
30110 .next
30111 The way with most moving parts at query time is Online Certificate
30112 Status Protocol (OCSP), where the client verifies the certificate
30113 against an OCSP server run by the CA.  This lets the CA track all
30114 usage of the certs.  It requires running software with access to the
30115 private key of the CA, to sign the responses to the OCSP queries.  OCSP
30116 is based on HTTP and can be proxied accordingly.
30117
30118 The only widespread OCSP server implementation (known to this writer)
30119 comes as part of OpenSSL and aborts on an invalid request, such as
30120 connecting to the port and then disconnecting.  This requires
30121 re-entering the passphrase each time some random client does this.
30122
30123 .next
30124 The third way is OCSP Stapling; in this, the server using a certificate
30125 issued by the CA periodically requests an OCSP proof of validity from
30126 the OCSP server, then serves it up inline as part of the TLS
30127 negotiation.   This approach adds no extra round trips, does not let the
30128 CA track users, scales well with number of certs issued by the CA and is
30129 resilient to temporary OCSP server failures, as long as the server
30130 starts retrying to fetch an OCSP proof some time before its current
30131 proof expires.  The downside is that it requires server support.
30132
30133 Unless Exim is built with the support disabled,
30134 or with GnuTLS earlier than version 3.3.16 / 3.4.8
30135 support for OCSP stapling is included.
30136
30137 There is a global option called &%tls_ocsp_file%&.
30138 The file specified therein is expected to be in DER format, and contain
30139 an OCSP proof.  Exim will serve it as part of the TLS handshake.  This
30140 option will be re-expanded for SNI, if the &%tls_certificate%& option
30141 contains &`tls_in_sni`&, as per other TLS options.
30142
30143 Exim does not at this time implement any support for fetching a new OCSP
30144 proof.  The burden is on the administrator to handle this, outside of
30145 Exim.  The file specified should be replaced atomically, so that the
30146 contents are always valid.  Exim will expand the &%tls_ocsp_file%& option
30147 on each connection, so a new file will be handled transparently on the
30148 next connection.
30149
30150 When built with OpenSSL Exim will check for a valid next update timestamp
30151 in the OCSP proof; if not present, or if the proof has expired, it will be
30152 ignored.
30153
30154 For the client to be able to verify the stapled OCSP the server must
30155 also supply, in its stapled information, any intermediate
30156 certificates for the chain leading to the OCSP proof from the signer
30157 of the server certificate.  There may be zero or one such. These
30158 intermediate certificates should be added to the server OCSP stapling
30159 file named by &%tls_ocsp_file%&.
30160
30161 Note that the proof only covers the terminal server certificate,
30162 not any of the chain from CA to it.
30163
30164 There is no current way to staple a proof for a client certificate.
30165
30166 .code
30167   A helper script "ocsp_fetch.pl" for fetching a proof from a CA
30168   OCSP server is supplied.  The server URL may be included in the
30169   server certificate, if the CA is helpful.
30170
30171   One failure mode seen was the OCSP Signer cert expiring before the end
30172   of validity of the OCSP proof. The checking done by Exim/OpenSSL
30173   noted this as invalid overall, but the re-fetch script did not.
30174 .endd
30175 .endlist
30176
30177
30178 .ecindex IIDencsmtp1
30179 .ecindex IIDencsmtp2
30180
30181
30182 .section "TLS Resumption" "SECTresumption"
30183 .cindex TLS resumption
30184 TLS Session Resumption for TLS 1.2 and TLS 1.3 connections can be used (defined
30185 in RFC 5077 for 1.2).  The support for this requires GnuTLS 3.6.3 or OpenSSL 1.1.1
30186 (or later).
30187
30188 Session resumption (this is the "stateless" variant) involves the server sending
30189 a "session ticket" to the client on one connection, which can be stored by the
30190 client and used for a later session.  The ticket contains sufficient state for
30191 the server to reconstruct the TLS session, avoiding some expensive crypto
30192 calculation and (on TLS1.2) one full packet roundtrip time.
30193
30194 .ilist
30195 Operational cost/benefit:
30196
30197  The extra data being transmitted costs a minor amount, and the client has
30198  extra costs in storing and retrieving the data.
30199
30200  In the Exim/Gnutls implementation the extra cost on an initial connection
30201  which is TLS1.2 over a loopback path is about 6ms on 2017-laptop class hardware.
30202  The saved cost on a subsequent connection is about 4ms; three or more
30203  connections become a net win.  On longer network paths, two or more
30204  connections will have an average lower startup time thanks to the one
30205  saved packet roundtrip.  TLS1.3 will save the crypto cpu costs but not any
30206  packet roundtrips.
30207
30208 .cindex "hints database" tls
30209  Since a new hints DB is used on the TLS client,
30210  the hints DB maintenance should be updated to additionally handle "tls".
30211
30212 .next
30213 Security aspects:
30214
30215  The session ticket is encrypted, but is obviously an additional security
30216  vulnarability surface.  An attacker able to decrypt it would have access
30217  all connections using the resumed session.
30218  The session ticket encryption key is not committed to storage by the server
30219  and is rotated regularly (OpenSSL: 1hr, and one previous key is used for
30220  overlap; GnuTLS 6hr but does not specify any overlap).
30221  Tickets have limited lifetime (2hr, and new ones issued after 1hr under
30222  OpenSSL.  GnuTLS 2hr, appears to not do overlap).
30223
30224  There is a question-mark over the security of the Diffie-Helman parameters
30225  used for session negotiation.
30226
30227 .next
30228 Observability:
30229
30230  The &%log_selector%& "tls_resumption" appends an asterisk to the tls_cipher "X="
30231  element.
30232
30233  The variables &$tls_in_resumption$& and &$tls_out_resumption$&
30234  have bits 0-4 indicating respectively
30235  support built, client requested ticket, client offered session,
30236  server issued ticket, resume used.  A suitable decode list is provided
30237  in the builtin macro _RESUME_DECODE for in &%listextract%& expansions.
30238
30239 .next
30240 Control:
30241
30242 The &%tls_resumption_hosts%& main option specifies a hostlist for which
30243 exim, operating as a server, will offer resumption to clients.
30244 Current best practice is to not offer the feature to MUA connection.
30245 Commonly this can be done like this:
30246 .code
30247 tls_resumption_hosts = ${if inlist {$received_port}{587:465} {:}{*}}
30248 .endd
30249 If the peer host matches the list after expansion then resumption
30250 is offered and/or accepted.
30251
30252 The &%tls_resumption_hosts%& smtp transport option performs the
30253 equivalent function for operation as a client.
30254 If the peer host matches the list after expansion then resumption
30255 is attempted (if a stored session is available) or the information
30256 stored (if supplied by the peer).
30257
30258
30259 .next
30260 Issues:
30261
30262  In a resumed session:
30263 .ilist
30264   The variables &$tls_{in,out}_cipher$& will have values different
30265  to the original (under GnuTLS).
30266 .next
30267   The variables &$tls_{in,out}_ocsp$& will be "not requested" or "no response",
30268  and the &%hosts_require_ocsp%& smtp trasnport option will fail.
30269 . XXX need to do something with that hosts_require_ocsp
30270 .endlist
30271
30272 .endlist
30273
30274
30275 .section DANE "SECDANE"
30276 .cindex DANE
30277 DNS-based Authentication of Named Entities, as applied to SMTP over TLS, provides assurance to a client that
30278 it is actually talking to the server it wants to rather than some attacker operating a Man In The Middle (MITM)
30279 operation.  The latter can terminate the TLS connection you make, and make another one to the server (so both
30280 you and the server still think you have an encrypted connection) and, if one of the "well known" set of
30281 Certificate Authorities has been suborned - something which *has* been seen already (2014), a verifiable
30282 certificate (if you're using normal root CAs, eg. the Mozilla set, as your trust anchors).
30283
30284 What DANE does is replace the CAs with the DNS as the trust anchor.  The assurance is limited to a) the possibility
30285 that the DNS has been suborned, b) mistakes made by the admins of the target server.   The attack surface presented
30286 by (a) is thought to be smaller than that of the set of root CAs.
30287
30288 It also allows the server to declare (implicitly) that connections to it should use TLS.  An MITM could simply
30289 fail to pass on a server's STARTTLS.
30290
30291 DANE scales better than having to maintain (and communicate via side-channel) copies of server certificates
30292 for every possible target server.  It also scales (slightly) better than having to maintain on an SMTP
30293 client a copy of the standard CAs bundle.  It also means not having to pay a CA for certificates.
30294
30295 DANE requires a server operator to do three things:
30296 .olist
30297 Run DNSSEC.  This provides assurance to clients
30298 that DNS lookups they do for the server have not been tampered with.  The domain MX record applying
30299 to this server, its A record, its TLSA record and any associated CNAME records must all be covered by
30300 DNSSEC.
30301 .next
30302 Add TLSA DNS records.  These say what the server certificate for a TLS connection should be.
30303 .next
30304 Offer a server certificate, or certificate chain, in TLS connections which is anchored by one of the TLSA records.
30305 .endlist
30306
30307 There are no changes to Exim specific to server-side operation of DANE.
30308 Support for client-side operation of DANE can be included at compile time by defining SUPPORT_DANE=yes
30309 in &_Local/Makefile_&.
30310 If it has been included, the macro "_HAVE_DANE" will be defined.
30311
30312 .subsection "DNS records"
30313 A TLSA record consist of 4 fields, the "Certificate Usage", the
30314 "Selector", the "Matching type", and the "Certificate Association Data".
30315 For a detailed description of the TLSA record see
30316 &url(https://tools.ietf.org/html/rfc7671#page-5,RFC 7671).
30317
30318 The TLSA record for the server may have "Certificate Usage" (1st) field of DANE-TA(2) or DANE-EE(3).
30319 These are the "Trust Anchor" and "End Entity" variants.
30320 The latter specifies the End Entity directly, i.e. the certificate involved is that of the server
30321 (and if only DANE-EE is used then it should be the sole one transmitted during the TLS handshake);
30322 this is appropriate for a single system, using a self-signed certificate.
30323 DANE-TA usage is effectively declaring a specific CA to be used; this might be a private CA or a public,
30324 well-known one.
30325 A private CA at simplest is just a self-signed certificate (with certain
30326 attributes) which is used to sign server certificates, but running one securely
30327 does require careful arrangement.
30328 With DANE-TA, as implemented in Exim and commonly in other MTAs,
30329 the server TLS handshake must transmit the entire certificate chain from CA to server-certificate.
30330 DANE-TA is commonly used for several services and/or servers, each having a TLSA query-domain CNAME record,
30331 all of which point to a single TLSA record.
30332 DANE-TA and DANE-EE can both be used together.
30333
30334 Our recommendation is to use DANE with a certificate from a public CA,
30335 because this enables a variety of strategies for remote clients to verify
30336 your certificate.
30337 You can then publish information both via DANE and another technology,
30338 "MTA-STS", described below.
30339
30340 When you use DANE-TA to publish trust anchor information, you ask entities
30341 outside your administrative control to trust the Certificate Authority for
30342 connections to you.
30343 If using a private CA then you should expect others to still apply the
30344 technical criteria they'd use for a public CA to your certificates.
30345 In particular, you should probably try to follow current best practices for CA
30346 operation around hash algorithms and key sizes.
30347 Do not expect other organizations to lower their security expectations just
30348 because a particular profile might be reasonable for your own internal use.
30349
30350 When this text was last updated, this in practice means to avoid use of SHA-1
30351 and MD5; if using RSA to use key sizes of at least 2048 bits (and no larger
30352 than 4096, for interoperability); to use keyUsage fields correctly; to use
30353 random serial numbers.
30354 The list of requirements is subject to change as best practices evolve.
30355 If you're not already using a private CA, or it doesn't meet these
30356 requirements, then we encourage you to avoid all these issues and use a public
30357 CA such as &url(https://letsencrypt.org/,Let's Encrypt) instead.
30358
30359 The TLSA record should have a "Selector" (2nd) field of SPKI(1) and
30360 a "Matching Type" (3rd) field of SHA2-512(2).
30361
30362 For the "Certificate Authority Data" (4th) field, commands like
30363
30364 .code
30365   openssl x509 -pubkey -noout <certificate.pem \
30366   | openssl rsa -outform der -pubin 2>/dev/null \
30367   | openssl sha512 \
30368   | awk '{print $2}'
30369 .endd
30370
30371 are workable to create a hash of the certificate's public key.
30372
30373 An example TLSA record for DANE-EE(3), SPKI(1), and SHA-512 (2) looks like
30374
30375 .code
30376   _25._tcp.mail.example.com. TLSA 3 1 2 8BA8A336E...
30377 .endd
30378
30379 At the time of writing, &url(https://www.huque.com/bin/gen_tlsa)
30380 is useful for quickly generating TLSA records.
30381
30382
30383 For use with the DANE-TA model, server certificates must have a correct name (SubjectName or SubjectAltName).
30384
30385 The Certificate issued by the CA published in the DANE-TA model should be
30386 issued using a strong hash algorithm.
30387 Exim, and importantly various other MTAs sending to you, will not
30388 re-enable hash algorithms which have been disabled by default in TLS
30389 libraries.
30390 This means no MD5 and no SHA-1.  SHA2-256 is the minimum for reliable
30391 interoperability (and probably the maximum too, in 2018).
30392
30393 .subsection "Interaction with OCSP"
30394 The use of OCSP-stapling should be considered, allowing for fast revocation of certificates (which would otherwise
30395 be limited by the DNS TTL on the TLSA records).  However, this is likely to only be usable with DANE-TA.  NOTE: the
30396 default of requesting OCSP for all hosts is modified iff DANE is in use, to:
30397
30398 .code
30399   hosts_request_ocsp = ${if or { {= {0}{$tls_out_tlsa_usage}} \
30400                                  {= {4}{$tls_out_tlsa_usage}} } \
30401                          {*}{}}
30402 .endd
30403
30404 The (new) variable &$tls_out_tlsa_usage$& is a bitfield with numbered bits set for TLSA record usage codes.
30405 The zero above means DANE was not in use, the four means that only DANE-TA usage TLSA records were
30406 found. If the definition of &%hosts_request_ocsp%& includes the
30407 string "tls_out_tlsa_usage", they are re-expanded in time to
30408 control the OCSP request.
30409
30410 This modification of hosts_request_ocsp is only done if it has the default value of "*".  Admins who change it, and
30411 those who use &%hosts_require_ocsp%&, should consider the interaction with DANE in their OCSP settings.
30412
30413
30414 .subsection "Client configuration"
30415 For client-side DANE there are three new smtp transport options, &%hosts_try_dane%&, &%hosts_require_dane%&
30416 and &%dane_require_tls_ciphers%&.
30417 The &"require"& variant will result in failure if the target host is not
30418 DNSSEC-secured. To get DNSSEC-secured hostname resolution, use
30419 the &%dnssec_request_domains%& router or transport option.
30420
30421 DANE will only be usable if the target host has DNSSEC-secured MX, A and TLSA records.
30422
30423 A TLSA lookup will be done if either of the above options match and the host-lookup succeeded using DNSSEC.
30424 If a TLSA lookup is done and succeeds, a DANE-verified TLS connection
30425 will be required for the host.  If it does not, the host will not
30426 be used; there is no fallback to non-DANE or non-TLS.
30427
30428 If DANE is requested and usable, then the TLS cipher list configuration
30429 prefers to use the option &%dane_require_tls_ciphers%& and falls
30430 back to &%tls_require_ciphers%& only if that is unset.
30431 This lets you configure "decent crypto" for DANE and "better than nothing
30432 crypto" as the default.  Note though that while GnuTLS lets the string control
30433 which versions of TLS/SSL will be negotiated, OpenSSL does not and you're
30434 limited to ciphersuite constraints.
30435
30436 If DANE is requested and useable (see above) the following transport options are ignored:
30437 .code
30438   hosts_require_tls
30439   tls_verify_hosts
30440   tls_try_verify_hosts
30441   tls_verify_certificates
30442   tls_crl
30443   tls_verify_cert_hostnames
30444   tls_sni
30445 .endd
30446
30447 If DANE is not usable, whether requested or not, and CA-anchored
30448 verification evaluation is wanted, the above variables should be set appropriately.
30449
30450 The router and transport option &%dnssec_request_domains%& must not be
30451 set to &"never"&, and &%dnssec_require_domains%& is ignored.
30452
30453 .subsection Observability
30454 If verification was successful using DANE then the "CV" item in the delivery log line will show as "CV=dane".
30455
30456 There is a new variable &$tls_out_dane$& which will have "yes" if
30457 verification succeeded using DANE and "no" otherwise (only useful
30458 in combination with events; see &<<CHAPevents>>&),
30459 and a new variable &$tls_out_tlsa_usage$& (detailed above).
30460
30461 .cindex DANE reporting
30462 An event (see &<<CHAPevents>>&) of type "dane:fail" will be raised on failures
30463 to achieve DANE-verified connection, if one was either requested and offered, or
30464 required.  This is intended to support TLS-reporting as defined in
30465 &url(https://tools.ietf.org/html/draft-ietf-uta-smtp-tlsrpt-17).
30466 The &$event_data$& will be one of the Result Types defined in
30467 Section 4.3 of that document.
30468
30469 .subsection General
30470 Under GnuTLS, DANE is only supported from version 3.0.0 onwards.
30471
30472 DANE is specified in published RFCs and decouples certificate authority trust
30473 selection from a "race to the bottom" of "you must trust everything for mail
30474 to get through".
30475 There is an alternative technology called MTA-STS, which
30476 instead publishes MX trust anchor information on an HTTPS website.  At the
30477 time this text was last updated, MTA-STS was still a draft, not yet an RFC.
30478 Exim has no support for MTA-STS as a client, but Exim mail server operators
30479 can choose to publish information describing their TLS configuration using
30480 MTA-STS to let those clients who do use that protocol derive trust
30481 information.
30482
30483 The MTA-STS design requires a certificate from a public Certificate Authority
30484 which is recognized by clients sending to you.
30485 That selection of which CAs are trusted by others is outside your control.
30486
30487 The most interoperable course of action is probably to use
30488 &url(https://letsencrypt.org/,Let's Encrypt), with automated certificate
30489 renewal; to publish the anchor information in DNSSEC-secured DNS via TLSA
30490 records for DANE clients (such as Exim and Postfix) and to publish anchor
30491 information for MTA-STS as well.  This is what is done for the &'exim.org'&
30492 domain itself (with caveats around occasionally broken MTA-STS because of
30493 incompatible specification changes prior to reaching RFC status).
30494
30495
30496
30497 . ////////////////////////////////////////////////////////////////////////////
30498 . ////////////////////////////////////////////////////////////////////////////
30499
30500 .chapter "Access control lists" "CHAPACL"
30501 .scindex IIDacl "&ACL;" "description"
30502 .cindex "control of incoming mail"
30503 .cindex "message" "controlling incoming"
30504 .cindex "policy control" "access control lists"
30505 Access Control Lists (ACLs) are defined in a separate section of the runtime
30506 configuration file, headed by &"begin acl"&. Each ACL definition starts with a
30507 name, terminated by a colon. Here is a complete ACL section that contains just
30508 one very small ACL:
30509 .code
30510 begin acl
30511 small_acl:
30512   accept   hosts = one.host.only
30513 .endd
30514 You can have as many lists as you like in the ACL section, and the order in
30515 which they appear does not matter. The lists are self-terminating.
30516
30517 The majority of ACLs are used to control Exim's behaviour when it receives
30518 certain SMTP commands. This applies both to incoming TCP/IP connections, and
30519 when a local process submits a message using SMTP by specifying the &%-bs%&
30520 option. The most common use is for controlling which recipients are accepted
30521 in incoming messages. In addition, you can define an ACL that is used to check
30522 local non-SMTP messages. The default configuration file contains an example of
30523 a realistic ACL for checking RCPT commands. This is discussed in chapter
30524 &<<CHAPdefconfil>>&.
30525
30526
30527 .section "Testing ACLs" "SECID188"
30528 The &%-bh%& command line option provides a way of testing your ACL
30529 configuration locally by running a fake SMTP session with which you interact.
30530
30531
30532 .section "Specifying when ACLs are used" "SECID189"
30533 .cindex "&ACL;" "options for specifying"
30534 In order to cause an ACL to be used, you have to name it in one of the relevant
30535 options in the main part of the configuration. These options are:
30536 .cindex "AUTH" "ACL for"
30537 .cindex "DATA" "ACLs for"
30538 .cindex "ETRN" "ACL for"
30539 .cindex "EXPN" "ACL for"
30540 .cindex "HELO" "ACL for"
30541 .cindex "EHLO" "ACL for"
30542 .cindex "DKIM" "ACL for"
30543 .cindex "MAIL" "ACL for"
30544 .cindex "QUIT, ACL for"
30545 .cindex "RCPT" "ACL for"
30546 .cindex "STARTTLS, ACL for"
30547 .cindex "VRFY" "ACL for"
30548 .cindex "SMTP" "connection, ACL for"
30549 .cindex "non-SMTP messages" "ACLs for"
30550 .cindex "MIME content scanning" "ACL for"
30551 .cindex "PRDR" "ACL for"
30552
30553 .table2 140pt
30554 .irow &%acl_not_smtp%&         "ACL for non-SMTP messages"
30555 .irow &%acl_not_smtp_mime%&    "ACL for non-SMTP MIME parts"
30556 .irow &%acl_not_smtp_start%&   "ACL at start of non-SMTP message"
30557 .irow &%acl_smtp_auth%&        "ACL for AUTH"
30558 .irow &%acl_smtp_connect%&     "ACL for start of SMTP connection"
30559 .irow &%acl_smtp_data%&        "ACL after DATA is complete"
30560 .irow &%acl_smtp_data_prdr%&   "ACL for each recipient, after DATA is complete"
30561 .irow &%acl_smtp_dkim%&        "ACL for each DKIM signer"
30562 .irow &%acl_smtp_etrn%&        "ACL for ETRN"
30563 .irow &%acl_smtp_expn%&        "ACL for EXPN"
30564 .irow &%acl_smtp_helo%&        "ACL for HELO or EHLO"
30565 .irow &%acl_smtp_mail%&        "ACL for MAIL"
30566 .irow &%acl_smtp_mailauth%&    "ACL for the AUTH parameter of MAIL"
30567 .irow &%acl_smtp_mime%&        "ACL for content-scanning MIME parts"
30568 .irow &%acl_smtp_notquit%&     "ACL for non-QUIT terminations"
30569 .irow &%acl_smtp_predata%&     "ACL at start of DATA command"
30570 .irow &%acl_smtp_quit%&        "ACL for QUIT"
30571 .irow &%acl_smtp_rcpt%&        "ACL for RCPT"
30572 .irow &%acl_smtp_starttls%&    "ACL for STARTTLS"
30573 .irow &%acl_smtp_vrfy%&        "ACL for VRFY"
30574 .endtable
30575
30576 For example, if you set
30577 .code
30578 acl_smtp_rcpt = small_acl
30579 .endd
30580 the little ACL defined above is used whenever Exim receives a RCPT command
30581 in an SMTP dialogue. The majority of policy tests on incoming messages can be
30582 done when RCPT commands arrive. A rejection of RCPT should cause the
30583 sending MTA to give up on the recipient address contained in the RCPT
30584 command, whereas rejection at other times may cause the client MTA to keep on
30585 trying to deliver the message. It is therefore recommended that you do as much
30586 testing as possible at RCPT time.
30587
30588
30589 .subsection "The non-SMTP ACLs" SECID190
30590 .cindex "non-SMTP messages" "ACLs for"
30591 The non-SMTP ACLs apply to all non-interactive incoming messages, that is, they
30592 apply to batched SMTP as well as to non-SMTP messages. (Batched SMTP is not
30593 really SMTP.) Many of the ACL conditions (for example, host tests, and tests on
30594 the state of the SMTP connection such as encryption and authentication) are not
30595 relevant and are forbidden in these ACLs. However, the sender and recipients
30596 are known, so the &%senders%& and &%sender_domains%& conditions and the
30597 &$sender_address$& and &$recipients$& variables can be used. Variables such as
30598 &$authenticated_sender$& are also available. You can specify added header lines
30599 in any of these ACLs.
30600
30601 The &%acl_not_smtp_start%& ACL is run right at the start of receiving a
30602 non-SMTP message, before any of the message has been read. (This is the
30603 analogue of the &%acl_smtp_predata%& ACL for SMTP input.) In the case of
30604 batched SMTP input, it runs after the DATA command has been reached. The
30605 result of this ACL is ignored; it cannot be used to reject a message. If you
30606 really need to, you could set a value in an ACL variable here and reject based
30607 on that in the &%acl_not_smtp%& ACL. However, this ACL can be used to set
30608 controls, and in particular, it can be used to set
30609 .code
30610 control = suppress_local_fixups
30611 .endd
30612 This cannot be used in the other non-SMTP ACLs because by the time they are
30613 run, it is too late.
30614
30615 The &%acl_not_smtp_mime%& ACL is available only when Exim is compiled with the
30616 content-scanning extension. For details, see chapter &<<CHAPexiscan>>&.
30617
30618 The &%acl_not_smtp%& ACL is run just before the &[local_scan()]& function. Any
30619 kind of rejection is treated as permanent, because there is no way of sending a
30620 temporary error for these kinds of message.
30621
30622
30623 .subsection "The SMTP connect ACL" SECID191
30624 .cindex "SMTP" "connection, ACL for"
30625 .oindex &%smtp_banner%&
30626 The ACL test specified by &%acl_smtp_connect%& happens at the start of an SMTP
30627 session, after the test specified by &%host_reject_connection%& (which is now
30628 an anomaly) and any TCP Wrappers testing (if configured). If the connection is
30629 accepted by an &%accept%& verb that has a &%message%& modifier, the contents of
30630 the message override the banner message that is otherwise specified by the
30631 &%smtp_banner%& option.
30632
30633 For tls-on-connect connections, the ACL is run before the TLS connection
30634 is accepted; if the ACL does not accept then the TCP connection is dropped without
30635 any TLS startup attempt and without any SMTP response being transmitted.
30636
30637
30638 .subsection "The EHLO/HELO ACL" SECID192
30639 .cindex "EHLO" "ACL for"
30640 .cindex "HELO" "ACL for"
30641 The ACL test specified by &%acl_smtp_helo%& happens when the client issues an
30642 EHLO or HELO command, after the tests specified by &%helo_accept_junk_hosts%&,
30643 &%helo_allow_chars%&, &%helo_verify_hosts%&, and &%helo_try_verify_hosts%&.
30644 Note that a client may issue more than one EHLO or HELO command in an SMTP
30645 session, and indeed is required to issue a new EHLO or HELO after successfully
30646 setting up encryption following a STARTTLS command.
30647
30648 Note also that a deny neither forces the client to go away nor means that
30649 mail will be refused on the connection.  Consider checking for
30650 &$sender_helo_name$& being defined in a MAIL or RCPT ACL to do that.
30651
30652 If the command is accepted by an &%accept%& verb that has a &%message%&
30653 modifier, the message may not contain more than one line (it will be truncated
30654 at the first newline and a panic logged if it does). Such a message cannot
30655 affect the EHLO options that are listed on the second and subsequent lines of
30656 an EHLO response.
30657
30658
30659 .subsection "The DATA ACLs" SECID193
30660 .cindex "DATA" "ACLs for"
30661 Two ACLs are associated with the DATA command, because it is two-stage
30662 command, with two responses being sent to the client.
30663 When the DATA command is received, the ACL defined by &%acl_smtp_predata%&
30664 is obeyed. This gives you control after all the RCPT commands, but before
30665 the message itself is received. It offers the opportunity to give a negative
30666 response to the DATA command before the data is transmitted. Header lines
30667 added by MAIL or RCPT ACLs are not visible at this time, but any that
30668 are defined here are visible when the &%acl_smtp_data%& ACL is run.
30669
30670 You cannot test the contents of the message, for example, to verify addresses
30671 in the headers, at RCPT time or when the DATA command is received. Such
30672 tests have to appear in the ACL that is run after the message itself has been
30673 received, before the final response to the DATA command is sent. This is
30674 the ACL specified by &%acl_smtp_data%&, which is the second ACL that is
30675 associated with the DATA command.
30676
30677 .cindex CHUNKING "BDAT command"
30678 .cindex BDAT "SMTP command"
30679 .cindex "RFC 3030" CHUNKING
30680 If CHUNKING was advertised and a BDAT command sequence is received,
30681 the &%acl_smtp_predata%& ACL is not run.
30682 . XXX why not?  It should be possible, for the first BDAT.
30683 The &%acl_smtp_data%& is run after the last BDAT command and all of
30684 the data specified is received.
30685
30686 For both of these ACLs, it is not possible to reject individual recipients. An
30687 error response rejects the entire message. Unfortunately, it is known that some
30688 MTAs do not treat hard (5&'xx'&) responses to the DATA command (either
30689 before or after the data) correctly &-- they keep the message on their queues
30690 and try again later, but that is their problem, though it does waste some of
30691 your resources.
30692
30693 The &%acl_smtp_data%& ACL is run after
30694 the &%acl_smtp_data_prdr%&,
30695 the &%acl_smtp_dkim%&
30696 and the &%acl_smtp_mime%& ACLs.
30697
30698 .subsection "The SMTP DKIM ACL" SECTDKIMACL
30699 The &%acl_smtp_dkim%& ACL is available only when Exim is compiled with DKIM support
30700 enabled (which is the default).
30701
30702 The ACL test specified by &%acl_smtp_dkim%& happens after a message has been
30703 received, and is executed for each DKIM signature found in a message.  If not
30704 otherwise specified, the default action is to accept.
30705
30706 This ACL is evaluated before &%acl_smtp_mime%& and &%acl_smtp_data%&.
30707
30708 For details on the operation of DKIM, see section &<<SECDKIM>>&.
30709
30710
30711 .subsection "The SMTP MIME ACL" SECID194
30712 The &%acl_smtp_mime%& option is available only when Exim is compiled with the
30713 content-scanning extension. For details, see chapter &<<CHAPexiscan>>&.
30714
30715 This ACL is evaluated after &%acl_smtp_dkim%& but before &%acl_smtp_data%&.
30716
30717
30718 .subsection "The SMTP PRDR ACL" SECTPRDRACL
30719 .cindex "PRDR" "ACL for"
30720 .oindex "&%prdr_enable%&"
30721 The &%acl_smtp_data_prdr%& ACL is available only when Exim is compiled
30722 with PRDR support enabled (which is the default).
30723 It becomes active only when the PRDR feature is negotiated between
30724 client and server for a message, and more than one recipient
30725 has been accepted.
30726
30727 The ACL test specified by &%acl_smtp_data_prdr%& happens after a message
30728 has been received, and is executed once for each recipient of the message
30729 with &$local_part$& and &$domain$& valid.
30730 The test may accept, defer or deny for individual recipients.
30731 The &%acl_smtp_data%& will still be called after this ACL and
30732 can reject the message overall, even if this ACL has accepted it
30733 for some or all recipients.
30734
30735 PRDR may be used to support per-user content filtering.  Without it
30736 one must defer any recipient after the first that has a different
30737 content-filter configuration.  With PRDR, the RCPT-time check
30738 .cindex "PRDR" "variable for"
30739 for this can be disabled when the variable &$prdr_requested$&
30740 is &"yes"&.
30741 Any required difference in behaviour of the main DATA-time
30742 ACL should however depend on the PRDR-time ACL having run, as Exim
30743 will avoid doing so in some situations (e.g. single-recipient mails).
30744
30745 See also the &%prdr_enable%& global option
30746 and the &%hosts_try_prdr%& smtp transport option.
30747
30748 This ACL is evaluated after &%acl_smtp_dkim%& but before &%acl_smtp_data%&.
30749 If the ACL is not defined, processing completes as if
30750 the feature was not requested by the client.
30751
30752 .subsection "The QUIT ACL" SECTQUITACL
30753 .cindex "QUIT, ACL for"
30754 The ACL for the SMTP QUIT command is anomalous, in that the outcome of the ACL
30755 does not affect the response code to QUIT, which is always 221. Thus, the ACL
30756 does not in fact control any access.
30757 For this reason, it may only accept
30758 or warn as its final result.
30759
30760 This ACL can be used for tasks such as custom logging at the end of an SMTP
30761 session. For example, you can use ACL variables in other ACLs to count
30762 messages, recipients, etc., and log the totals at QUIT time using one or
30763 more &%logwrite%& modifiers on a &%warn%& verb.
30764
30765 &*Warning*&: Only the &$acl_c$&&'x'& variables can be used for this, because
30766 the &$acl_m$&&'x'& variables are reset at the end of each incoming message.
30767
30768 You do not need to have a final &%accept%&, but if you do, you can use a
30769 &%message%& modifier to specify custom text that is sent as part of the 221
30770 response to QUIT.
30771
30772 This ACL is run only for a &"normal"& QUIT. For certain kinds of disastrous
30773 failure (for example, failure to open a log file, or when Exim is bombing out
30774 because it has detected an unrecoverable error), all SMTP commands from the
30775 client are given temporary error responses until QUIT is received or the
30776 connection is closed. In these special cases, the QUIT ACL does not run.
30777
30778
30779 .subsection "The not-QUIT ACL" SECTNOTQUITACL
30780 .vindex &$acl_smtp_notquit$&
30781 The not-QUIT ACL, specified by &%acl_smtp_notquit%&, is run in most cases when
30782 an SMTP session ends without sending QUIT. However, when Exim itself is in bad
30783 trouble, such as being unable to write to its log files, this ACL is not run,
30784 because it might try to do things (such as write to log files) that make the
30785 situation even worse.
30786
30787 Like the QUIT ACL, this ACL is provided to make it possible to do customized
30788 logging or to gather statistics, and its outcome is ignored. The &%delay%&
30789 modifier is forbidden in this ACL, and the only permitted verbs are &%accept%&
30790 and &%warn%&.
30791
30792 .vindex &$smtp_notquit_reason$&
30793 When the not-QUIT ACL is running, the variable &$smtp_notquit_reason$& is set
30794 to a string that indicates the reason for the termination of the SMTP
30795 connection. The possible values are:
30796 .table2
30797 .irow &`acl-drop`&                 "Another ACL issued a &%drop%& command"
30798 .irow &`bad-commands`&             "Too many unknown or non-mail commands"
30799 .irow &`command-timeout`&          "Timeout while reading SMTP commands"
30800 .irow &`connection-lost`&          "The SMTP connection has been lost"
30801 .irow &`data-timeout`&             "Timeout while reading message data"
30802 .irow &`local-scan-error`&         "The &[local_scan()]& function crashed"
30803 .irow &`local-scan-timeout`&       "The &[local_scan()]& function timed out"
30804 .irow &`signal-exit`&              "SIGTERM or SIGINT"
30805 .irow &`synchronization-error`&    "SMTP synchronization error"
30806 .irow &`tls-failed`&               "TLS failed to start"
30807 .endtable
30808 In most cases when an SMTP connection is closed without having received QUIT,
30809 Exim sends an SMTP response message before actually closing the connection.
30810 With the exception of the &`acl-drop`& case, the default message can be
30811 overridden by the &%message%& modifier in the not-QUIT ACL. In the case of a
30812 &%drop%& verb in another ACL, it is the message from the other ACL that is
30813 used.
30814
30815
30816 .section "Finding an ACL to use" "SECID195"
30817 .cindex "&ACL;" "finding which to use"
30818 The value of an &%acl_smtp_%&&'xxx'& option is expanded before use, so
30819 you can use different ACLs in different circumstances. For example,
30820 .code
30821 acl_smtp_rcpt = ${if ={25}{$interface_port} \
30822                      {acl_check_rcpt} {acl_check_rcpt_submit} }
30823 .endd
30824 In the default configuration file there are some example settings for
30825 providing an RFC 4409 message &"submission"& service on port 587 and
30826 an RFC 8314 &"submissions"& service on port 465. You can use a string
30827 expansion like this to choose an ACL for MUAs on these ports which is
30828 more appropriate for this purpose than the default ACL on port 25.
30829
30830 The expanded string does not have to be the name of an ACL in the
30831 configuration file; there are other possibilities. Having expanded the
30832 string, Exim searches for an ACL as follows:
30833
30834 .ilist
30835 If the string begins with a slash, Exim uses it as a filename, and reads its
30836 contents as an ACL. The lines are processed in the same way as lines in the
30837 Exim configuration file. In particular, continuation lines are supported, blank
30838 lines are ignored, as are lines whose first non-whitespace character is &"#"&.
30839 If the file does not exist or cannot be read, an error occurs (typically
30840 causing a temporary failure of whatever caused the ACL to be run). For example:
30841 .code
30842 acl_smtp_data = /etc/acls/\
30843   ${lookup{$sender_host_address}lsearch\
30844   {/etc/acllist}{$value}{default}}
30845 .endd
30846 This looks up an ACL file to use on the basis of the host's IP address, falling
30847 back to a default if the lookup fails. If an ACL is successfully read from a
30848 file, it is retained in memory for the duration of the Exim process, so that it
30849 can be re-used without having to re-read the file.
30850 .next
30851 If the string does not start with a slash, and does not contain any spaces,
30852 Exim searches the ACL section of the configuration for an ACL whose name
30853 matches the string.
30854 .next
30855 If no named ACL is found, or if the string contains spaces, Exim parses
30856 the string as an inline ACL. This can save typing in cases where you just
30857 want to have something like
30858 .code
30859 acl_smtp_vrfy = accept
30860 .endd
30861 in order to allow free use of the VRFY command. Such a string may contain
30862 newlines; it is processed in the same way as an ACL that is read from a file.
30863 .endlist
30864
30865
30866
30867
30868 .section "ACL return codes" "SECID196"
30869 .cindex "&ACL;" "return codes"
30870 Except for the QUIT ACL, which does not affect the SMTP return code (see
30871 section &<<SECTQUITACL>>& above), the result of running an ACL is either
30872 &"accept"& or &"deny"&, or, if some test cannot be completed (for example, if a
30873 database is down), &"defer"&. These results cause 2&'xx'&, 5&'xx'&, and 4&'xx'&
30874 return codes, respectively, to be used in the SMTP dialogue. A fourth return,
30875 &"error"&, occurs when there is an error such as invalid syntax in the ACL.
30876 This also causes a 4&'xx'& return code.
30877
30878 For the non-SMTP ACL, &"defer"& and &"error"& are treated in the same way as
30879 &"deny"&, because there is no mechanism for passing temporary errors to the
30880 submitters of non-SMTP messages.
30881
30882
30883 ACLs that are relevant to message reception may also return &"discard"&. This
30884 has the effect of &"accept"&, but causes either the entire message or an
30885 individual recipient address to be discarded. In other words, it is a
30886 blackholing facility. Use it with care.
30887
30888 If the ACL for MAIL returns &"discard"&, all recipients are discarded, and no
30889 ACL is run for subsequent RCPT commands. The effect of &"discard"& in a
30890 RCPT ACL is to discard just the one recipient address. If there are no
30891 recipients left when the message's data is received, the DATA ACL is not
30892 run. A &"discard"& return from the DATA or the non-SMTP ACL discards all the
30893 remaining recipients. The &"discard"& return is not permitted for the
30894 &%acl_smtp_predata%& ACL.
30895
30896 If the ACL for VRFY returns &"accept"&, a recipient verify (without callout)
30897 is done on the address and the result determines the SMTP response.
30898
30899
30900 .cindex "&[local_scan()]& function" "when all recipients discarded"
30901 The &[local_scan()]& function is always run, even if there are no remaining
30902 recipients; it may create new recipients.
30903
30904
30905
30906 .section "Unset ACL options" "SECID197"
30907 .cindex "&ACL;" "unset options"
30908 The default actions when any of the &%acl_%&&'xxx'& options are unset are not
30909 all the same. &*Note*&: These defaults apply only when the relevant ACL is
30910 not defined at all. For any defined ACL, the default action when control
30911 reaches the end of the ACL statements is &"deny"&.
30912
30913 For &%acl_smtp_quit%& and &%acl_not_smtp_start%& there is no default because
30914 these two are ACLs that are used only for their side effects. They cannot be
30915 used to accept or reject anything.
30916
30917 For &%acl_not_smtp%&, &%acl_smtp_auth%&, &%acl_smtp_connect%&,
30918 &%acl_smtp_data%&, &%acl_smtp_helo%&, &%acl_smtp_mail%&, &%acl_smtp_mailauth%&,
30919 &%acl_smtp_mime%&, &%acl_smtp_predata%&, and &%acl_smtp_starttls%&, the action
30920 when the ACL is not defined is &"accept"&.
30921
30922 For the others (&%acl_smtp_etrn%&, &%acl_smtp_expn%&, &%acl_smtp_rcpt%&, and
30923 &%acl_smtp_vrfy%&), the action when the ACL is not defined is &"deny"&.
30924 This means that &%acl_smtp_rcpt%& must be defined in order to receive any
30925 messages over an SMTP connection. For an example, see the ACL in the default
30926 configuration file.
30927
30928
30929
30930
30931 .section "Data for message ACLs" "SECID198"
30932 .cindex "&ACL;" "data for message ACL"
30933 .vindex &$domain$&
30934 .vindex &$local_part$&
30935 .vindex &$sender_address$&
30936 .vindex &$sender_host_address$&
30937 .vindex &$smtp_command$&
30938 When a MAIL or RCPT ACL, or either of the DATA ACLs, is running, the variables
30939 that contain information about the host and the message's sender (for example,
30940 &$sender_host_address$& and &$sender_address$&) are set, and can be used in ACL
30941 statements. In the case of RCPT (but not MAIL or DATA), &$domain$& and
30942 &$local_part$& are set from the argument address. The entire SMTP command
30943 is available in &$smtp_command$&.
30944
30945 When an ACL for the AUTH parameter of MAIL is running, the variables that
30946 contain information about the host are set, but &$sender_address$& is not yet
30947 set. Section &<<SECTauthparamail>>& contains a discussion of this parameter and
30948 how it is used.
30949
30950 .vindex "&$message_size$&"
30951 The &$message_size$& variable is set to the value of the SIZE parameter on
30952 the MAIL command at MAIL, RCPT and pre-data time, or to -1 if
30953 that parameter is not given. The value is updated to the true message size by
30954 the time the final DATA ACL is run (after the message data has been
30955 received).
30956
30957 .vindex "&$rcpt_count$&"
30958 .vindex "&$recipients_count$&"
30959 The &$rcpt_count$& variable increases by one for each RCPT command received.
30960 The &$recipients_count$& variable increases by one each time a RCPT command is
30961 accepted, so while an ACL for RCPT is being processed, it contains the number
30962 of previously accepted recipients. At DATA time (for both the DATA ACLs),
30963 &$rcpt_count$& contains the total number of RCPT commands, and
30964 &$recipients_count$& contains the total number of accepted recipients.
30965
30966
30967
30968
30969
30970 .section "Data for non-message ACLs" "SECTdatfornon"
30971 .cindex "&ACL;" "data for non-message ACL"
30972 .vindex &$smtp_command_argument$&
30973 .vindex &$smtp_command$&
30974 When an ACL is being run for AUTH, EHLO, ETRN, EXPN, HELO, STARTTLS, or VRFY,
30975 the remainder of the SMTP command line is placed in &$smtp_command_argument$&,
30976 and the entire SMTP command is available in &$smtp_command$&.
30977 These variables can be tested using a &%condition%& condition. For example,
30978 here is an ACL for use with AUTH, which insists that either the session is
30979 encrypted, or the CRAM-MD5 authentication method is used. In other words, it
30980 does not permit authentication methods that use cleartext passwords on
30981 unencrypted connections.
30982 .code
30983 acl_check_auth:
30984   accept encrypted = *
30985   accept condition = ${if eq{${uc:$smtp_command_argument}}\
30986                      {CRAM-MD5}}
30987   deny   message   = TLS encryption or CRAM-MD5 required
30988 .endd
30989 (Another way of applying this restriction is to arrange for the authenticators
30990 that use cleartext passwords not to be advertised when the connection is not
30991 encrypted. You can use the generic &%server_advertise_condition%& authenticator
30992 option to do this.)
30993
30994
30995
30996 .section "Format of an ACL" "SECID199"
30997 .cindex "&ACL;" "format of"
30998 .cindex "&ACL;" "verbs, definition of"
30999 An individual ACL consists of a number of statements. Each statement starts
31000 with a verb, optionally followed by a number of conditions and &"modifiers"&.
31001 Modifiers can change the way the verb operates, define error and log messages,
31002 set variables, insert delays, and vary the processing of accepted messages.
31003
31004 If all the conditions are met, the verb is obeyed. The same condition may be
31005 used (with different arguments) more than once in the same statement. This
31006 provides a means of specifying an &"and"& conjunction between conditions. For
31007 example:
31008 .code
31009 deny  dnslists = list1.example
31010       dnslists = list2.example
31011 .endd
31012 If there are no conditions, the verb is always obeyed. Exim stops evaluating
31013 the conditions and modifiers when it reaches a condition that fails. What
31014 happens then depends on the verb (and in one case, on a special modifier). Not
31015 all the conditions make sense at every testing point. For example, you cannot
31016 test a sender address in the ACL that is run for a VRFY command.
31017
31018
31019 .section "ACL verbs" "SECID200"
31020 The ACL verbs are as follows:
31021
31022 .ilist
31023 .cindex "&%accept%& ACL verb"
31024 &%accept%&: If all the conditions are met, the ACL returns &"accept"&. If any
31025 of the conditions are not met, what happens depends on whether &%endpass%&
31026 appears among the conditions (for syntax see below). If the failing condition
31027 is before &%endpass%&, control is passed to the next ACL statement; if it is
31028 after &%endpass%&, the ACL returns &"deny"&. Consider this statement, used to
31029 check a RCPT command:
31030 .code
31031 accept domains = +local_domains
31032        endpass
31033        verify = recipient
31034 .endd
31035 If the recipient domain does not match the &%domains%& condition, control
31036 passes to the next statement. If it does match, the recipient is verified, and
31037 the command is accepted if verification succeeds. However, if verification
31038 fails, the ACL yields &"deny"&, because the failing condition is after
31039 &%endpass%&.
31040
31041 The &%endpass%& feature has turned out to be confusing to many people, so its
31042 use is not recommended nowadays. It is always possible to rewrite an ACL so
31043 that &%endpass%& is not needed, and it is no longer used in the default
31044 configuration.
31045
31046 .cindex "&%message%& ACL modifier" "with &%accept%&"
31047 If a &%message%& modifier appears on an &%accept%& statement, its action
31048 depends on whether or not &%endpass%& is present. In the absence of &%endpass%&
31049 (when an &%accept%& verb either accepts or passes control to the next
31050 statement), &%message%& can be used to vary the message that is sent when an
31051 SMTP command is accepted. For example, in a RCPT ACL you could have:
31052 .display
31053 &`accept  `&<&'some conditions'&>
31054 &`        message = OK, I will allow you through today`&
31055 .endd
31056 You can specify an SMTP response code, optionally followed by an &"extended
31057 response code"& at the start of the message, but the first digit must be the
31058 same as would be sent by default, which is 2 for an &%accept%& verb.
31059
31060 If &%endpass%& is present in an &%accept%& statement, &%message%& specifies
31061 an error message that is used when access is denied. This behaviour is retained
31062 for backward compatibility, but current &"best practice"& is to avoid the use
31063 of &%endpass%&.
31064
31065
31066 .next
31067 .cindex "&%defer%& ACL verb"
31068 &%defer%&: If all the conditions are true, the ACL returns &"defer"& which, in
31069 an SMTP session, causes a 4&'xx'& response to be given. For a non-SMTP ACL,
31070 &%defer%& is the same as &%deny%&, because there is no way of sending a
31071 temporary error. For a RCPT command, &%defer%& is much the same as using a
31072 &(redirect)& router and &`:defer:`& while verifying, but the &%defer%& verb can
31073 be used in any ACL, and even for a recipient it might be a simpler approach.
31074
31075
31076 .next
31077 .cindex "&%deny%& ACL verb"
31078 &%deny%&: If all the conditions are met, the ACL returns &"deny"&. If any of
31079 the conditions are not met, control is passed to the next ACL statement. For
31080 example,
31081 .code
31082 deny dnslists = blackholes.mail-abuse.org
31083 .endd
31084 rejects commands from hosts that are on a DNS black list.
31085
31086
31087 .next
31088 .cindex "&%discard%& ACL verb"
31089 &%discard%&: This verb behaves like &%accept%&, except that it returns
31090 &"discard"& from the ACL instead of &"accept"&. It is permitted only on ACLs
31091 that are concerned with receiving messages. When all the conditions are true,
31092 the sending entity receives a &"success"& response. However, &%discard%& causes
31093 recipients to be discarded. If it is used in an ACL for RCPT, just the one
31094 recipient is discarded; if used for MAIL, DATA or in the non-SMTP ACL, all the
31095 message's recipients are discarded. Recipients that are discarded before DATA
31096 do not appear in the log line when the &%received_recipients%& log selector is set.
31097
31098 If the &%log_message%& modifier is set when &%discard%& operates,
31099 its contents are added to the line that is automatically written to the log.
31100 The &%message%& modifier operates exactly as it does for &%accept%&.
31101
31102
31103 .next
31104 .cindex "&%drop%& ACL verb"
31105 &%drop%&: This verb behaves like &%deny%&, except that an SMTP connection is
31106 forcibly closed after the 5&'xx'& error message has been sent. For example:
31107 .code
31108 drop   condition = ${if > {$rcpt_count}{20}}
31109        message   = I don't take more than 20 RCPTs
31110 .endd
31111 There is no difference between &%deny%& and &%drop%& for the connect-time ACL.
31112 The connection is always dropped after sending a 550 response.
31113
31114 .next
31115 .cindex "&%require%& ACL verb"
31116 &%require%&: If all the conditions are met, control is passed to the next ACL
31117 statement. If any of the conditions are not met, the ACL returns &"deny"&. For
31118 example, when checking a RCPT command,
31119 .code
31120 require message = Sender did not verify
31121         verify  = sender
31122 .endd
31123 passes control to subsequent statements only if the message's sender can be
31124 verified. Otherwise, it rejects the command. Note the positioning of the
31125 &%message%& modifier, before the &%verify%& condition. The reason for this is
31126 discussed in section &<<SECTcondmodproc>>&.
31127
31128 .next
31129 .cindex "&%warn%& ACL verb"
31130 &%warn%&: If all the conditions are true, a line specified by the
31131 &%log_message%& modifier is written to Exim's main log. Control always passes
31132 to the next ACL statement. If any condition is false, the log line is not
31133 written. If an identical log line is requested several times in the same
31134 message, only one copy is actually written to the log. If you want to force
31135 duplicates to be written, use the &%logwrite%& modifier instead.
31136
31137 If &%log_message%& is not present, a &%warn%& verb just checks its conditions
31138 and obeys any &"immediate"& modifiers (such as &%control%&, &%set%&,
31139 &%logwrite%&, &%add_header%&, and &%remove_header%&) that appear before the
31140 first failing condition. There is more about adding header lines in section
31141 &<<SECTaddheadacl>>&.
31142
31143 If any condition on a &%warn%& statement cannot be completed (that is, there is
31144 some sort of defer), the log line specified by &%log_message%& is not written.
31145 This does not include the case of a forced failure from a lookup, which
31146 is considered to be a successful completion. After a defer, no further
31147 conditions or modifiers in the &%warn%& statement are processed. The incident
31148 is logged, and the ACL continues to be processed, from the next statement
31149 onwards.
31150
31151
31152 .vindex "&$acl_verify_message$&"
31153 When one of the &%warn%& conditions is an address verification that fails, the
31154 text of the verification failure message is in &$acl_verify_message$&. If you
31155 want this logged, you must set it up explicitly. For example:
31156 .code
31157 warn   !verify = sender
31158        log_message = sender verify failed: $acl_verify_message
31159 .endd
31160 .endlist
31161
31162 At the end of each ACL there is an implicit unconditional &%deny%&.
31163
31164 As you can see from the examples above, the conditions and modifiers are
31165 written one to a line, with the first one on the same line as the verb, and
31166 subsequent ones on following lines. If you have a very long condition, you can
31167 continue it onto several physical lines by the usual backslash continuation
31168 mechanism. It is conventional to align the conditions vertically.
31169
31170
31171
31172 .section "ACL variables" "SECTaclvariables"
31173 .cindex "&ACL;" "variables"
31174 There are some special variables that can be set during ACL processing. They
31175 can be used to pass information between different ACLs, different invocations
31176 of the same ACL in the same SMTP connection, and between ACLs and the routers,
31177 transports, and filters that are used to deliver a message. The names of these
31178 variables must begin with &$acl_c$& or &$acl_m$&, followed either by a digit or
31179 an underscore, but the remainder of the name can be any sequence of
31180 alphanumeric characters and underscores that you choose. There is no limit on
31181 the number of ACL variables. The two sets act as follows:
31182 .ilist
31183 The values of those variables whose names begin with &$acl_c$& persist
31184 throughout an SMTP connection. They are never reset. Thus, a value that is set
31185 while receiving one message is still available when receiving the next message
31186 on the same SMTP connection.
31187 .next
31188 The values of those variables whose names begin with &$acl_m$& persist only
31189 while a message is being received. They are reset afterwards. They are also
31190 reset by MAIL, RSET, EHLO, HELO, and after starting up a TLS session.
31191 .endlist
31192
31193 When a message is accepted, the current values of all the ACL variables are
31194 preserved with the message and are subsequently made available at delivery
31195 time. The ACL variables are set by a modifier called &%set%&. For example:
31196 .code
31197 accept hosts = whatever
31198        set acl_m4 = some value
31199 accept authenticated = *
31200        set acl_c_auth = yes
31201 .endd
31202 &*Note*&: A leading dollar sign is not used when naming a variable that is to
31203 be set. If you want to set a variable without taking any action, you can use a
31204 &%warn%& verb without any other modifiers or conditions.
31205
31206 .oindex &%strict_acl_vars%&
31207 What happens if a syntactically valid but undefined ACL variable is
31208 referenced depends on the setting of the &%strict_acl_vars%& option. If it is
31209 false (the default), an empty string is substituted; if it is true, an
31210 error is generated.
31211
31212 Versions of Exim before 4.64 have a limited set of numbered variables, but
31213 their names are compatible, so there is no problem with upgrading.
31214
31215
31216 .section "Condition and modifier processing" "SECTcondmodproc"
31217 .cindex "&ACL;" "conditions; processing"
31218 .cindex "&ACL;" "modifiers; processing"
31219 An exclamation mark preceding a condition negates its result. For example:
31220 .code
31221 deny   domains = *.dom.example
31222       !verify  = recipient
31223 .endd
31224 causes the ACL to return &"deny"& if the recipient domain ends in
31225 &'dom.example'& and the recipient address cannot be verified. Sometimes
31226 negation can be used on the right-hand side of a condition. For example, these
31227 two statements are equivalent:
31228 .code
31229 deny  hosts = !192.168.3.4
31230 deny !hosts =  192.168.3.4
31231 .endd
31232 However, for many conditions (&%verify%& being a good example), only left-hand
31233 side negation of the whole condition is possible.
31234
31235 The arguments of conditions and modifiers are expanded. A forced failure
31236 of an expansion causes a condition to be ignored, that is, it behaves as if the
31237 condition is true. Consider these two statements:
31238 .code
31239 accept  senders = ${lookup{$host_name}lsearch\
31240                   {/some/file}{$value}fail}
31241 accept  senders = ${lookup{$host_name}lsearch\
31242                   {/some/file}{$value}{}}
31243 .endd
31244 Each attempts to look up a list of acceptable senders. If the lookup succeeds,
31245 the returned list is searched, but if the lookup fails the behaviour is
31246 different in the two cases. The &%fail%& in the first statement causes the
31247 condition to be ignored, leaving no further conditions. The &%accept%& verb
31248 therefore succeeds. The second statement, however, generates an empty list when
31249 the lookup fails. No sender can match an empty list, so the condition fails,
31250 and therefore the &%accept%& also fails.
31251
31252 ACL modifiers appear mixed in with conditions in ACL statements. Some of them
31253 specify actions that are taken as the conditions for a statement are checked;
31254 others specify text for messages that are used when access is denied or a
31255 warning is generated. The &%control%& modifier affects the way an incoming
31256 message is handled.
31257
31258 The positioning of the modifiers in an ACL statement is important, because the
31259 processing of a verb ceases as soon as its outcome is known. Only those
31260 modifiers that have already been encountered will take effect. For example,
31261 consider this use of the &%message%& modifier:
31262 .code
31263 require message = Can't verify sender
31264         verify  = sender
31265         message = Can't verify recipient
31266         verify  = recipient
31267         message = This message cannot be used
31268 .endd
31269 If sender verification fails, Exim knows that the result of the statement is
31270 &"deny"&, so it goes no further. The first &%message%& modifier has been seen,
31271 so its text is used as the error message. If sender verification succeeds, but
31272 recipient verification fails, the second message is used. If recipient
31273 verification succeeds, the third message becomes &"current"&, but is never used
31274 because there are no more conditions to cause failure.
31275
31276 For the &%deny%& verb, on the other hand, it is always the last &%message%&
31277 modifier that is used, because all the conditions must be true for rejection to
31278 happen. Specifying more than one &%message%& modifier does not make sense, and
31279 the message can even be specified after all the conditions. For example:
31280 .code
31281 deny   hosts = ...
31282       !senders = *@my.domain.example
31283        message = Invalid sender from client host
31284 .endd
31285 The &"deny"& result does not happen until the end of the statement is reached,
31286 by which time Exim has set up the message.
31287
31288
31289
31290 .section "ACL modifiers" "SECTACLmodi"
31291 .cindex "&ACL;" "modifiers; list of"
31292 The ACL modifiers are as follows:
31293
31294 .vlist
31295 .vitem &*add_header*&&~=&~<&'text'&>
31296 This modifier specifies one or more header lines that are to be added to an
31297 incoming message, assuming, of course, that the message is ultimately
31298 accepted. For details, see section &<<SECTaddheadacl>>&.
31299
31300 .vitem &*continue*&&~=&~<&'text'&>
31301 .cindex "&%continue%& ACL modifier"
31302 .cindex "database" "updating in ACL"
31303 This modifier does nothing of itself, and processing of the ACL always
31304 continues with the next condition or modifier. The value of &%continue%& is in
31305 the side effects of expanding its argument. Typically this could be used to
31306 update a database. It is really just a syntactic tidiness, to avoid having to
31307 write rather ugly lines like this:
31308 .display
31309 &`condition = ${if eq{0}{`&<&'some expansion'&>&`}{true}{true}}`&
31310 .endd
31311 Instead, all you need is
31312 .display
31313 &`continue = `&<&'some expansion'&>
31314 .endd
31315
31316 .vitem &*control*&&~=&~<&'text'&>
31317 .cindex "&%control%& ACL modifier"
31318 This modifier affects the subsequent processing of the SMTP connection or of an
31319 incoming message that is accepted. The effect of the first type of control
31320 lasts for the duration of the connection, whereas the effect of the second type
31321 lasts only until the current message has been received. The message-specific
31322 controls always apply to the whole message, not to individual recipients,
31323 even if the &%control%& modifier appears in a RCPT ACL.
31324
31325 As there are now quite a few controls that can be applied, they are described
31326 separately in section &<<SECTcontrols>>&. The &%control%& modifier can be used
31327 in several different ways. For example:
31328
31329 . ==== As this is a nested list, any displays it contains must be indented
31330 . ==== as otherwise they are too far to the left. That comment applies only
31331 . ==== when xmlto and fop are used; formatting with sdop gets it right either
31332 . ==== way.
31333
31334 .ilist
31335 It can be at the end of an &%accept%& statement:
31336 .code
31337     accept  ...some conditions
31338             control = queue
31339 .endd
31340 In this case, the control is applied when this statement yields &"accept"&, in
31341 other words, when the conditions are all true.
31342
31343 .next
31344 It can be in the middle of an &%accept%& statement:
31345 .code
31346     accept  ...some conditions...
31347             control = queue
31348             ...some more conditions...
31349 .endd
31350 If the first set of conditions are true, the control is applied, even if the
31351 statement does not accept because one of the second set of conditions is false.
31352 In this case, some subsequent statement must yield &"accept"& for the control
31353 to be relevant.
31354
31355 .next
31356 It can be used with &%warn%& to apply the control, leaving the
31357 decision about accepting or denying to a subsequent verb. For
31358 example:
31359 .code
31360     warn    ...some conditions...
31361             control = freeze
31362     accept  ...
31363 .endd
31364 This example of &%warn%& does not contain &%message%&, &%log_message%&, or
31365 &%logwrite%&, so it does not add anything to the message and does not write a
31366 log entry.
31367
31368 .next
31369 If you want to apply a control unconditionally, you can use it with a
31370 &%require%& verb. For example:
31371 .code
31372     require  control = no_multiline_responses
31373 .endd
31374 .endlist
31375
31376 .vitem &*delay*&&~=&~<&'time'&>
31377 .cindex "&%delay%& ACL modifier"
31378 .oindex "&%-bh%&"
31379 This modifier may appear in any ACL except notquit. It causes Exim to wait for
31380 the time interval before proceeding. However, when testing Exim using the
31381 &%-bh%& option, the delay is not actually imposed (an appropriate message is
31382 output instead). The time is given in the usual Exim notation, and the delay
31383 happens as soon as the modifier is processed. In an SMTP session, pending
31384 output is flushed before the delay is imposed.
31385
31386 Like &%control%&, &%delay%& can be used with &%accept%& or &%deny%&, for
31387 example:
31388 .code
31389 deny    ...some conditions...
31390         delay = 30s
31391 .endd
31392 The delay happens if all the conditions are true, before the statement returns
31393 &"deny"&. Compare this with:
31394 .code
31395 deny    delay = 30s
31396         ...some conditions...
31397 .endd
31398 which waits for 30s before processing the conditions. The &%delay%& modifier
31399 can also be used with &%warn%& and together with &%control%&:
31400 .code
31401 warn    ...some conditions...
31402         delay = 2m
31403         control = freeze
31404 accept  ...
31405 .endd
31406
31407 If &%delay%& is encountered when the SMTP PIPELINING extension is in use,
31408 responses to several commands are no longer buffered and sent in one packet (as
31409 they would normally be) because all output is flushed before imposing the
31410 delay. This optimization is disabled so that a number of small delays do not
31411 appear to the client as one large aggregated delay that might provoke an
31412 unwanted timeout. You can, however, disable output flushing for &%delay%& by
31413 using a &%control%& modifier to set &%no_delay_flush%&.
31414
31415
31416 .vitem &*endpass*&
31417 .cindex "&%endpass%& ACL modifier"
31418 This modifier, which has no argument, is recognized only in &%accept%& and
31419 &%discard%& statements. It marks the boundary between the conditions whose
31420 failure causes control to pass to the next statement, and the conditions whose
31421 failure causes the ACL to return &"deny"&. This concept has proved to be
31422 confusing to some people, so the use of &%endpass%& is no longer recommended as
31423 &"best practice"&. See the description of &%accept%& above for more details.
31424
31425
31426 .vitem &*log_message*&&~=&~<&'text'&>
31427 .cindex "&%log_message%& ACL modifier"
31428 This modifier sets up a message that is used as part of the log message if the
31429 ACL denies access or a &%warn%& statement's conditions are true. For example:
31430 .code
31431 require log_message = wrong cipher suite $tls_in_cipher
31432         encrypted   = DES-CBC3-SHA
31433 .endd
31434 &%log_message%& is also used when recipients are discarded by &%discard%&. For
31435 example:
31436 .display
31437 &`discard `&<&'some conditions'&>
31438 &`        log_message = Discarded $local_part@$domain because...`&
31439 .endd
31440 When access is denied, &%log_message%& adds to any underlying error message
31441 that may exist because of a condition failure. For example, while verifying a
31442 recipient address, a &':fail:'& redirection might have already set up a
31443 message.
31444
31445 The message may be defined before the conditions to which it applies, because
31446 the string expansion does not happen until Exim decides that access is to be
31447 denied. This means that any variables that are set by the condition are
31448 available for inclusion in the message. For example, the &$dnslist_$&<&'xxx'&>
31449 variables are set after a DNS black list lookup succeeds. If the expansion of
31450 &%log_message%& fails, or if the result is an empty string, the modifier is
31451 ignored.
31452
31453 .vindex "&$acl_verify_message$&"
31454 If you want to use a &%warn%& statement to log the result of an address
31455 verification, you can use &$acl_verify_message$& to include the verification
31456 error message.
31457
31458 If &%log_message%& is used with a &%warn%& statement, &"Warning:"& is added to
31459 the start of the logged message. If the same warning log message is requested
31460 more than once while receiving  a single email message, only one copy is
31461 actually logged. If you want to log multiple copies, use &%logwrite%& instead
31462 of &%log_message%&. In the absence of &%log_message%& and &%logwrite%&, nothing
31463 is logged for a successful &%warn%& statement.
31464
31465 If &%log_message%& is not present and there is no underlying error message (for
31466 example, from the failure of address verification), but &%message%& is present,
31467 the &%message%& text is used for logging rejections. However, if any text for
31468 logging contains newlines, only the first line is logged. In the absence of
31469 both &%log_message%& and &%message%&, a default built-in message is used for
31470 logging rejections.
31471
31472
31473 .vitem "&*log_reject_target*&&~=&~<&'log name list'&>"
31474 .cindex "&%log_reject_target%& ACL modifier"
31475 .cindex "logging in ACL" "specifying which log"
31476 This modifier makes it possible to specify which logs are used for messages
31477 about ACL rejections. Its argument is a colon-separated list of words that can
31478 be &"main"&, &"reject"&, or &"panic"&. The default is &`main:reject`&. The list
31479 may be empty, in which case a rejection is not logged at all. For example, this
31480 ACL fragment writes no logging information when access is denied:
31481 .display
31482 &`deny `&<&'some conditions'&>
31483 &`     log_reject_target =`&
31484 .endd
31485 This modifier can be used in SMTP and non-SMTP ACLs. It applies to both
31486 permanent and temporary rejections. Its effect lasts for the rest of the
31487 current ACL.
31488
31489
31490 .vitem &*logwrite*&&~=&~<&'text'&>
31491 .cindex "&%logwrite%& ACL modifier"
31492 .cindex "logging in ACL" "immediate"
31493 This modifier writes a message to a log file as soon as it is encountered when
31494 processing an ACL. (Compare &%log_message%&, which, except in the case of
31495 &%warn%& and &%discard%&, is used only if the ACL statement denies
31496 access.) The &%logwrite%& modifier can be used to log special incidents in
31497 ACLs. For example:
31498 .display
31499 &`accept `&<&'some special conditions'&>
31500 &`       control  = freeze`&
31501 &`       logwrite = froze message because ...`&
31502 .endd
31503 By default, the message is written to the main log. However, it may begin
31504 with a colon, followed by a comma-separated list of log names, and then
31505 another colon, to specify exactly which logs are to be written. For
31506 example:
31507 .code
31508 logwrite = :main,reject: text for main and reject logs
31509 logwrite = :panic: text for panic log only
31510 .endd
31511
31512
31513 .vitem &*message*&&~=&~<&'text'&>
31514 .cindex "&%message%& ACL modifier"
31515 This modifier sets up a text string that is expanded and used as a response
31516 message when an ACL statement terminates the ACL with an &"accept"&, &"deny"&,
31517 or &"defer"& response. (In the case of the &%accept%& and &%discard%& verbs,
31518 there is some complication if &%endpass%& is involved; see the description of
31519 &%accept%& for details.)
31520
31521 The expansion of the message happens at the time Exim decides that the ACL is
31522 to end, not at the time it processes &%message%&. If the expansion fails, or
31523 generates an empty string, the modifier is ignored. Here is an example where
31524 &%message%& must be specified first, because the ACL ends with a rejection if
31525 the &%hosts%& condition fails:
31526 .code
31527 require  message = Host not recognized
31528          hosts = 10.0.0.0/8
31529 .endd
31530 (Once a condition has failed, no further conditions or modifiers are
31531 processed.)
31532
31533 .cindex "SMTP" "error codes"
31534 .oindex "&%smtp_banner%&
31535 For ACLs that are triggered by SMTP commands, the message is returned as part
31536 of the SMTP response. The use of &%message%& with &%accept%& (or &%discard%&)
31537 is meaningful only for SMTP, as no message is returned when a non-SMTP message
31538 is accepted. In the case of the connect ACL, accepting with a message modifier
31539 overrides the value of &%smtp_banner%&. For the EHLO/HELO ACL, a customized
31540 accept message may not contain more than one line (otherwise it will be
31541 truncated at the first newline and a panic logged), and it cannot affect the
31542 EHLO options.
31543
31544 When SMTP is involved, the message may begin with an overriding response code,
31545 consisting of three digits optionally followed by an &"extended response code"&
31546 of the form &'n.n.n'&, each code being followed by a space. For example:
31547 .code
31548 deny  message = 599 1.2.3 Host not welcome
31549       hosts = 192.168.34.0/24
31550 .endd
31551 The first digit of the supplied response code must be the same as would be sent
31552 by default. A panic occurs if it is not. Exim uses a 550 code when it denies
31553 access, but for the predata ACL, note that the default success code is 354, not
31554 2&'xx'&.
31555
31556 Notwithstanding the previous paragraph, for the QUIT ACL, unlike the others,
31557 the message modifier cannot override the 221 response code.
31558
31559 The text in a &%message%& modifier is literal; any quotes are taken as
31560 literals, but because the string is expanded, backslash escapes are processed
31561 anyway.
31562 If the message contains newlines, this gives rise to a multi-line SMTP
31563 response.
31564 A long message line will also be split into multi-line SMTP responses,
31565 on word boundaries if possible.
31566
31567 .vindex "&$acl_verify_message$&"
31568 While the text is being expanded, the &$acl_verify_message$& variable
31569 contains any message previously set.
31570 Afterwards, &$acl_verify_message$& is cleared.
31571
31572 If &%message%& is used on a statement that verifies an address, the message
31573 specified overrides any message that is generated by the verification process.
31574 However, the original message is available in the variable
31575 &$acl_verify_message$&, so you can incorporate it into your message if you
31576 wish. In particular, if you want the text from &%:fail:%& items in &(redirect)&
31577 routers to be passed back as part of the SMTP response, you should either not
31578 use a &%message%& modifier, or make use of &$acl_verify_message$&.
31579
31580 For compatibility with previous releases of Exim, a &%message%& modifier that
31581 is used with a &%warn%& verb behaves in a similar way to the &%add_header%&
31582 modifier, but this usage is now deprecated. However, &%message%& acts only when
31583 all the conditions are true, wherever it appears in an ACL command, whereas
31584 &%add_header%& acts as soon as it is encountered. If &%message%& is used with
31585 &%warn%& in an ACL that is not concerned with receiving a message, it has no
31586 effect.
31587
31588
31589 .vitem &*queue*&&~=&~<&'text'&>
31590 .cindex "&%queue%& ACL modifier"
31591 .cindex "named queues" "selecting in ACL"
31592 This modifier specifies the use of a named queue for spool files
31593 for the message.
31594 It can only be used before the message is received (i.e. not in
31595 the DATA ACL).
31596 This could be used, for example, for known high-volume burst sources
31597 of traffic, or for quarantine of messages.
31598 Separate queue-runner processes will be needed for named queues.
31599 If the text after expansion is empty, the default queue is used.
31600
31601
31602 .vitem &*remove_header*&&~=&~<&'text'&>
31603 This modifier specifies one or more header names in a colon-separated list
31604  that are to be removed from an incoming message, assuming, of course, that
31605 the message is ultimately accepted. For details, see section &<<SECTremoveheadacl>>&.
31606
31607
31608 .vitem &*set*&&~<&'acl_name'&>&~=&~<&'value'&>
31609 .cindex "&%set%& ACL modifier"
31610 This modifier puts a value into one of the ACL variables (see section
31611 &<<SECTaclvariables>>&).
31612
31613
31614 .vitem &*udpsend*&&~=&~<&'parameters'&>
31615 .cindex "UDP communications"
31616 This modifier sends a UDP packet, for purposes such as statistics
31617 collection or behaviour monitoring. The parameters are expanded, and
31618 the result of the expansion must be a colon-separated list consisting
31619 of a destination server, port number, and the packet contents. The
31620 server can be specified as a host name or IPv4 or IPv6 address. The
31621 separator can be changed with the usual angle bracket syntax. For
31622 example, you might want to collect information on which hosts connect
31623 when:
31624 .code
31625 udpsend = <; 2001:dB8::dead:beef ; 1234 ;\
31626              $tod_zulu $sender_host_address
31627 .endd
31628 .endlist
31629
31630
31631
31632
31633 .section "Use of the control modifier" "SECTcontrols"
31634 .cindex "&%control%& ACL modifier"
31635 The &%control%& modifier supports the following settings:
31636
31637 .vlist
31638 .vitem &*control&~=&~allow_auth_unadvertised*&
31639 This modifier allows a client host to use the SMTP AUTH command even when it
31640 has not been advertised in response to EHLO. Furthermore, because there are
31641 apparently some really broken clients that do this, Exim will accept AUTH after
31642 HELO (rather than EHLO) when this control is set. It should be used only if you
31643 really need it, and you should limit its use to those broken clients that do
31644 not work without it. For example:
31645 .code
31646 warn hosts   = 192.168.34.25
31647      control = allow_auth_unadvertised
31648 .endd
31649 Normally, when an Exim server receives an AUTH command, it checks the name of
31650 the authentication mechanism that is given in the command to ensure that it
31651 matches an advertised mechanism. When this control is set, the check that a
31652 mechanism has been advertised is bypassed. Any configured mechanism can be used
31653 by the client. This control is permitted only in the connection and HELO ACLs.
31654
31655
31656 .vitem &*control&~=&~caseful_local_part*& &&&
31657        &*control&~=&~caselower_local_part*&
31658 .cindex "&ACL;" "case of local part in"
31659 .cindex "case of local parts"
31660 .vindex "&$local_part$&"
31661 These two controls are permitted only in the ACL specified by &%acl_smtp_rcpt%&
31662 (that is, during RCPT processing). By default, the contents of &$local_part$&
31663 are lower cased before ACL processing. If &"caseful_local_part"& is specified,
31664 any uppercase letters in the original local part are restored in &$local_part$&
31665 for the rest of the ACL, or until a control that sets &"caselower_local_part"&
31666 is encountered.
31667
31668 These controls affect only the current recipient. Moreover, they apply only to
31669 local part handling that takes place directly in the ACL (for example, as a key
31670 in lookups). If a test to verify the recipient is obeyed, the case-related
31671 handling of the local part during the verification is controlled by the router
31672 configuration (see the &%caseful_local_part%& generic router option).
31673
31674 This facility could be used, for example, to add a spam score to local parts
31675 containing upper case letters. For example, using &$acl_m4$& to accumulate the
31676 spam score:
31677 .code
31678 warn  control = caseful_local_part
31679       set acl_m4 = ${eval:\
31680                      $acl_m4 + \
31681                      ${if match{$local_part}{[A-Z]}{1}{0}}\
31682                     }
31683       control = caselower_local_part
31684 .endd
31685 Notice that we put back the lower cased version afterwards, assuming that
31686 is what is wanted for subsequent tests.
31687
31688
31689 .vitem &*control&~=&~cutthrough_delivery/*&<&'options'&>
31690 .cindex "&ACL;" "cutthrough routing"
31691 .cindex "cutthrough" "requesting"
31692 This option requests delivery be attempted while the item is being received.
31693
31694 The option is usable in the RCPT ACL.
31695 If enabled for a message received via smtp and routed to an smtp transport,
31696 and only one transport, interface, destination host and port combination
31697 is used for all recipients of the message,
31698 then the delivery connection is made while the receiving connection is open
31699 and data is copied from one to the other.
31700
31701 An attempt to set this option for any recipient but the first
31702 for a mail will be quietly ignored.
31703 If a recipient-verify callout
31704 (with use_sender)
31705 connection is subsequently
31706 requested in the same ACL it is held open and used for
31707 any subsequent recipients and the data,
31708 otherwise one is made after the initial RCPT ACL completes.
31709
31710 Note that routers are used in verify mode,
31711 and cannot depend on content of received headers.
31712 Note also that headers cannot be
31713 modified by any of the post-data ACLs (DATA, MIME and DKIM).
31714 Headers may be modified by routers (subject to the above) and transports.
31715 The &'Received-By:'& header is generated as soon as the body reception starts,
31716 rather than the traditional time after the full message is received;
31717 this will affect the timestamp.
31718
31719 All the usual ACLs are called; if one results in the message being
31720 rejected, all effort spent in delivery (including the costs on
31721 the ultimate destination) will be wasted.
31722 Note that in the case of data-time ACLs this includes the entire
31723 message body.
31724
31725 Cutthrough delivery is not supported via transport-filters or when DKIM signing
31726 of outgoing messages is done, because it sends data to the ultimate destination
31727 before the entire message has been received from the source.
31728 It is not supported for messages received with the SMTP PRDR
31729 or CHUNKING
31730 options in use.
31731
31732 Should the ultimate destination system positively accept or reject the mail,
31733 a corresponding indication is given to the source system and nothing is queued.
31734 If the item is successfully delivered in cutthrough mode
31735 the delivery log lines are tagged with ">>" rather than "=>" and appear
31736 before the acceptance "<=" line.
31737
31738 If there is a temporary error the item is queued for later delivery in the
31739 usual fashion.
31740 This behaviour can be adjusted by appending the option &*defer=*&<&'value'&>
31741 to the control; the default value is &"spool"& and the alternate value
31742 &"pass"& copies an SMTP defer response from the target back to the initiator
31743 and does not queue the message.
31744 Note that this is independent of any recipient verify conditions in the ACL.
31745
31746 Delivery in this mode avoids the generation of a bounce mail to a
31747 (possibly faked)
31748 sender when the destination system is doing content-scan based rejection.
31749
31750
31751 .vitem &*control&~=&~debug/*&<&'options'&>
31752 .cindex "&ACL;" "enabling debug logging"
31753 .cindex "debugging" "enabling from an ACL"
31754 This control turns on debug logging, almost as though Exim had been invoked
31755 with &`-d`&, with the output going to a new logfile in the usual logs directory,
31756 by default called &'debuglog'&.
31757
31758 Logging set up by the control will be maintained across spool residency.
31759
31760 Options are a slash-separated list.
31761 If an option takes an argument, the option name and argument are separated by
31762 an equals character.
31763 Several options are supported:
31764 .display
31765 tag=<&'suffix'&>         The filename can be adjusted with thise option.
31766                      The argument, which may access any variables already defined,
31767                      is appended to the default name.
31768
31769 opts=<&'debug&~options'&> The argument specififes what is to be logged,
31770                      using the same values as the &`-d`& command-line option.
31771
31772 stop                 Logging started with this control may be
31773                      stopped by using this option.
31774
31775 kill                 Logging started with this control may be
31776                      stopped by using this option.
31777                      Additionally the debug file will be removed,
31778                      providing one means for speculative debug tracing.
31779
31780 pretrigger=<&'size'&>    This option specifies a memory buffuer to be used
31781                      for pre-trigger debug capture.
31782                      Debug lines are recorded in the buffer until
31783                      and if) a trigger occurs; at which time they are
31784                      dumped to the debug file.  Newer lines displace the
31785                      oldest if the buffer is full.  After a trigger,
31786                      immediate writes to file are done as normal.
31787
31788 trigger=<&'reason'&>     This option selects cause for the pretrigger buffer
31789                      see above) to be copied to file.  A reason of &*now*&
31790                      take effect immediately; one of &*paniclog*& triggers
31791                      on a write to the panic log.
31792 .endd
31793
31794 Some examples (which depend on variables that don't exist in all
31795 contexts):
31796 .code
31797       control = debug
31798       control = debug/tag=.$sender_host_address
31799       control = debug/opts=+expand+acl
31800       control = debug/tag=.$message_exim_id/opts=+expand
31801       control = debug/kill
31802       control = debug/opts=+all/pretrigger=1024/trigger=paniclog
31803       control = debug/trigger=now
31804 .endd
31805
31806
31807 .vitem &*control&~=&~dkim_disable_verify*&
31808 .cindex "disable DKIM verify"
31809 .cindex "DKIM" "disable verify"
31810 This control turns off DKIM verification processing entirely.  For details on
31811 the operation and configuration of DKIM, see section &<<SECDKIM>>&.
31812
31813
31814 .vitem &*control&~=&~dmarc_disable_verify*&
31815 .cindex "disable DMARC verify"
31816 .cindex "DMARC" "disable verify"
31817 This control turns off DMARC verification processing entirely.  For details on
31818 the operation and configuration of DMARC, see section &<<SECDMARC>>&.
31819
31820
31821 .vitem &*control&~=&~dscp/*&<&'value'&>
31822 .cindex "&ACL;" "setting DSCP value"
31823 .cindex "DSCP" "inbound"
31824 This option causes the DSCP value associated with the socket for the inbound
31825 connection to be adjusted to a given value, given as one of a number of fixed
31826 strings or to numeric value.
31827 The &%-bI:dscp%& option may be used to ask Exim which names it knows of.
31828 Common values include &`throughput`&, &`mincost`&, and on newer systems
31829 &`ef`&, &`af41`&, etc.  Numeric values may be in the range 0 to 0x3F.
31830
31831 The outbound packets from Exim will be marked with this value in the header
31832 (for IPv4, the TOS field; for IPv6, the TCLASS field); there is no guarantee
31833 that these values will have any effect, not be stripped by networking
31834 equipment, or do much of anything without cooperation with your Network
31835 Engineer and those of all network operators between the source and destination.
31836
31837
31838 .vitem &*control&~=&~enforce_sync*& &&&
31839        &*control&~=&~no_enforce_sync*&
31840 .cindex "SMTP" "synchronization checking"
31841 .cindex "synchronization checking in SMTP"
31842 These controls make it possible to be selective about when SMTP synchronization
31843 is enforced. The global option &%smtp_enforce_sync%& specifies the initial
31844 state of the switch (it is true by default). See the description of this option
31845 in chapter &<<CHAPmainconfig>>& for details of SMTP synchronization checking.
31846
31847 The effect of these two controls lasts for the remainder of the SMTP
31848 connection. They can appear in any ACL except the one for the non-SMTP
31849 messages. The most straightforward place to put them is in the ACL defined by
31850 &%acl_smtp_connect%&, which is run at the start of an incoming SMTP connection,
31851 before the first synchronization check. The expected use is to turn off the
31852 synchronization checks for badly-behaved hosts that you nevertheless need to
31853 work with.
31854
31855
31856 .vitem &*control&~=&~fakedefer/*&<&'message'&>
31857 .cindex "fake defer"
31858 .cindex "defer, fake"
31859 .cindex fakedefer
31860 This control works in exactly the same way as &%fakereject%& (described below)
31861 except that it causes an SMTP 450 response after the message data instead of a
31862 550 response. You must take care when using &%fakedefer%& because it causes the
31863 messages to be duplicated when the sender retries. Therefore, you should not
31864 use &%fakedefer%& if the message is to be delivered normally.
31865
31866 .vitem &*control&~=&~fakereject/*&<&'message'&>
31867 .cindex "fake rejection"
31868 .cindex "rejection, fake"
31869 .cindex fakereject
31870 This control is permitted only for the MAIL, RCPT, and DATA ACLs, in other
31871 words, only when an SMTP message is being received. If Exim accepts the
31872 message, instead the final 250 response, a 550 rejection message is sent.
31873 However, Exim proceeds to deliver the message as normal. The control applies
31874 only to the current message, not to any subsequent ones that may be received in
31875 the same SMTP connection.
31876
31877 The text for the 550 response is taken from the &%control%& modifier. If no
31878 message is supplied, the following is used:
31879 .code
31880 550-Your message has been rejected but is being
31881 550-kept for evaluation.
31882 550-If it was a legitimate message, it may still be
31883 550 delivered to the target recipient(s).
31884 .endd
31885 This facility should be used with extreme caution.
31886
31887 .vitem &*control&~=&~freeze*&
31888 .cindex "frozen messages" "forcing in ACL"
31889 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs, in
31890 other words, only when a message is being received. If the message is accepted,
31891 it is placed on Exim's queue and frozen. The control applies only to the
31892 current message, not to any subsequent ones that may be received in the same
31893 SMTP connection.
31894
31895 This modifier can optionally be followed by &`/no_tell`&. If the global option
31896 &%freeze_tell%& is set, it is ignored for the current message (that is, nobody
31897 is told about the freezing), provided all the &*control=freeze*& modifiers that
31898 are obeyed for the current message have the &`/no_tell`& option.
31899
31900 .vitem &*control&~=&~no_delay_flush*&
31901 .cindex "SMTP" "output flushing, disabling for delay"
31902 Exim normally flushes SMTP output before implementing a delay in an ACL, to
31903 avoid unexpected timeouts in clients when the SMTP PIPELINING extension is in
31904 use. This control, as long as it is encountered before the &%delay%& modifier,
31905 disables such output flushing.
31906
31907 .vitem &*control&~=&~no_callout_flush*&
31908 .cindex "SMTP" "output flushing, disabling for callout"
31909 Exim normally flushes SMTP output before performing a callout in an ACL, to
31910 avoid unexpected timeouts in clients when the SMTP PIPELINING extension is in
31911 use. This control, as long as it is encountered before the &%verify%& condition
31912 that causes the callout, disables such output flushing.
31913
31914 .vitem &*control&~=&~no_mbox_unspool*&
31915 This control is available when Exim is compiled with the content scanning
31916 extension. Content scanning may require a copy of the current message, or parts
31917 of it, to be written in &"mbox format"& to a spool file, for passing to a virus
31918 or spam scanner. Normally, such copies are deleted when they are no longer
31919 needed. If this control is set, the copies are not deleted. The control applies
31920 only to the current message, not to any subsequent ones that may be received in
31921 the same SMTP connection. It is provided for debugging purposes and is unlikely
31922 to be useful in production.
31923
31924 .vitem &*control&~=&~no_multiline_responses*&
31925 .cindex "multiline responses, suppressing"
31926 This control is permitted for any ACL except the one for non-SMTP messages.
31927 It seems that there are broken clients in use that cannot handle multiline
31928 SMTP responses, despite the fact that RFC 821 defined them over 20 years ago.
31929
31930 If this control is set, multiline SMTP responses from ACL rejections are
31931 suppressed. One way of doing this would have been to put out these responses as
31932 one long line. However, RFC 2821 specifies a maximum of 512 bytes per response
31933 (&"use multiline responses for more"& it says &-- ha!), and some of the
31934 responses might get close to that. So this facility, which is after all only a
31935 sop to broken clients, is implemented by doing two very easy things:
31936
31937 .ilist
31938 Extra information that is normally output as part of a rejection caused by
31939 sender verification failure is omitted. Only the final line (typically &"sender
31940 verification failed"&) is sent.
31941 .next
31942 If a &%message%& modifier supplies a multiline response, only the first
31943 line is output.
31944 .endlist
31945
31946 The setting of the switch can, of course, be made conditional on the
31947 calling host. Its effect lasts until the end of the SMTP connection.
31948
31949 .vitem &*control&~=&~no_pipelining*&
31950 .cindex "PIPELINING" "suppressing advertising"
31951 .cindex "ESMTP extensions" PIPELINING
31952 This control turns off the advertising of the PIPELINING extension to SMTP in
31953 the current session. To be useful, it must be obeyed before Exim sends its
31954 response to an EHLO command. Therefore, it should normally appear in an ACL
31955 controlled by &%acl_smtp_connect%& or &%acl_smtp_helo%&. See also
31956 &%pipelining_advertise_hosts%&.
31957
31958 .vitem &*control&~=&~queue/*&<&'options'&>* &&&
31959        &*control&~=&~queue_only*&
31960 .oindex "&%queue%&"
31961 .oindex "&%queue_only%&"
31962 .cindex "queueing incoming messages"
31963 .cindex queueing "forcing in ACL"
31964 .cindex "first pass routing"
31965 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs, in
31966 other words, only when a message is being received. If the message is accepted,
31967 it is placed on Exim's queue and left there for delivery by a subsequent queue
31968 runner.
31969 If used with no options set,
31970 no immediate delivery process is started. In other words, it has the
31971 effect as the &%queue_only%& global option or &'-odq'& command-line option.
31972
31973 If the &'first_pass_route'& option is given then
31974 the behaviour is like the command-line &'-oqds'& option;
31975 a delivery process is started which stops short of making
31976 any SMTP delivery.  The benefit is that the hints database will be updated for
31977 the message being waiting for a specific host, and a later queue run will be
31978 able to send all such messages on a single connection.
31979
31980 The control only applies to the current message, not to any subsequent ones that
31981  may be received in the same SMTP connection.
31982
31983 .vitem &*control&~=&~submission/*&<&'options'&>
31984 .cindex "message" "submission"
31985 .cindex "submission mode"
31986 This control is permitted only for the MAIL, RCPT, and start of data ACLs (the
31987 latter is the one defined by &%acl_smtp_predata%&). Setting it tells Exim that
31988 the current message is a submission from a local MUA. In this case, Exim
31989 operates in &"submission mode"&, and applies certain fixups to the message if
31990 necessary. For example, it adds a &'Date:'& header line if one is not present.
31991 This control is not permitted in the &%acl_smtp_data%& ACL, because that is too
31992 late (the message has already been created).
31993
31994 Chapter &<<CHAPmsgproc>>& describes the processing that Exim applies to
31995 messages. Section &<<SECTsubmodnon>>& covers the processing that happens in
31996 submission mode; the available options for this control are described there.
31997 The control applies only to the current message, not to any subsequent ones
31998 that may be received in the same SMTP connection.
31999
32000 .vitem &*control&~=&~suppress_local_fixups*&
32001 .cindex "submission fixups, suppressing"
32002 This control applies to locally submitted (non TCP/IP) messages, and is the
32003 complement of &`control = submission`&. It disables the fixups that are
32004 normally applied to locally-submitted messages. Specifically:
32005
32006 .ilist
32007 Any &'Sender:'& header line is left alone (in this respect, it is a
32008 dynamic version of &%local_sender_retain%&).
32009 .next
32010 No &'Message-ID:'&, &'From:'&, or &'Date:'& header lines are added.
32011 .next
32012 There is no check that &'From:'& corresponds to the actual sender.
32013 .endlist ilist
32014
32015 This control may be useful when a remotely-originated message is accepted,
32016 passed to some scanning program, and then re-submitted for delivery. It can be
32017 used only in the &%acl_smtp_mail%&, &%acl_smtp_rcpt%&, &%acl_smtp_predata%&,
32018 and &%acl_not_smtp_start%& ACLs, because it has to be set before the message's
32019 data is read.
32020
32021 &*Note:*& This control applies only to the current message, not to any others
32022 that are being submitted at the same time using &%-bs%& or &%-bS%&.
32023
32024 .vitem &*control&~=&~utf8_downconvert*&
32025 This control enables conversion of UTF-8 in message envelope addresses
32026 to a-label form.
32027 For details see section &<<SECTi18nMTA>>&.
32028 .endlist vlist
32029
32030
32031 .section "Summary of message fixup control" "SECTsummesfix"
32032 All four possibilities for message fixups can be specified:
32033
32034 .ilist
32035 Locally submitted, fixups applied: the default.
32036 .next
32037 Locally submitted, no fixups applied: use
32038 &`control = suppress_local_fixups`&.
32039 .next
32040 Remotely submitted, no fixups applied: the default.
32041 .next
32042 Remotely submitted, fixups applied: use &`control = submission`&.
32043 .endlist
32044
32045
32046
32047 .section "Adding header lines in ACLs" "SECTaddheadacl"
32048 .cindex "header lines" "adding in an ACL"
32049 .cindex "header lines" "position of added lines"
32050 .cindex "&%add_header%& ACL modifier"
32051 The &%add_header%& modifier can be used to add one or more extra header lines
32052 to an incoming message, as in this example:
32053 .code
32054 warn dnslists = sbl.spamhaus.org : \
32055                 dialup.mail-abuse.org
32056      add_header = X-blacklisted-at: $dnslist_domain
32057 .endd
32058 The &%add_header%& modifier is permitted in the MAIL, RCPT, PREDATA, DATA,
32059 MIME, DKIM, and non-SMTP ACLs (in other words, those that are concerned with
32060 receiving a message). The message must ultimately be accepted for
32061 &%add_header%& to have any significant effect. You can use &%add_header%& with
32062 any ACL verb, including &%deny%& (though this is potentially useful only in a
32063 RCPT ACL).
32064
32065 Headers will not be added to the message if the modifier is used in
32066 DATA, MIME or DKIM ACLs for a message delivered by cutthrough routing.
32067
32068 Leading and trailing newlines are removed from
32069 the data for the &%add_header%& modifier; if it then
32070 contains one or more newlines that
32071 are not followed by a space or a tab, it is assumed to contain multiple header
32072 lines. Each one is checked for valid syntax; &`X-ACL-Warn:`& is added to the
32073 front of any line that is not a valid header line.
32074
32075 Added header lines are accumulated during the MAIL, RCPT, and predata ACLs.
32076 They are added to the message before processing the DATA and MIME ACLs.
32077 However, if an identical header line is requested more than once, only one copy
32078 is actually added to the message. Further header lines may be accumulated
32079 during the DATA and MIME ACLs, after which they are added to the message, again
32080 with duplicates suppressed. Thus, it is possible to add two identical header
32081 lines to an SMTP message, but only if one is added before DATA and one after.
32082 In the case of non-SMTP messages, new headers are accumulated during the
32083 non-SMTP ACLs, and are added to the message after all the ACLs have run. If a
32084 message is rejected after DATA or by the non-SMTP ACL, all added header lines
32085 are included in the entry that is written to the reject log.
32086
32087 .cindex "header lines" "added; visibility of"
32088 Header lines are not visible in string expansions
32089 of message headers
32090 until they are added to the
32091 message. It follows that header lines defined in the MAIL, RCPT, and predata
32092 ACLs are not visible until the DATA ACL and MIME ACLs are run. Similarly,
32093 header lines that are added by the DATA or MIME ACLs are not visible in those
32094 ACLs. Because of this restriction, you cannot use header lines as a way of
32095 passing data between (for example) the MAIL and RCPT ACLs. If you want to do
32096 this, you can use ACL variables, as described in section
32097 &<<SECTaclvariables>>&.
32098
32099 The list of headers yet to be added is given by the &%$headers_added%& variable.
32100
32101 The &%add_header%& modifier acts immediately as it is encountered during the
32102 processing of an ACL. Notice the difference between these two cases:
32103 .display
32104 &`accept add_header = ADDED: some text`&
32105 &`       `&<&'some condition'&>
32106
32107 &`accept `&<&'some condition'&>
32108 &`       add_header = ADDED: some text`&
32109 .endd
32110 In the first case, the header line is always added, whether or not the
32111 condition is true. In the second case, the header line is added only if the
32112 condition is true. Multiple occurrences of &%add_header%& may occur in the same
32113 ACL statement. All those that are encountered before a condition fails are
32114 honoured.
32115
32116 .cindex "&%warn%& ACL verb"
32117 For compatibility with previous versions of Exim, a &%message%& modifier for a
32118 &%warn%& verb acts in the same way as &%add_header%&, except that it takes
32119 effect only if all the conditions are true, even if it appears before some of
32120 them. Furthermore, only the last occurrence of &%message%& is honoured. This
32121 usage of &%message%& is now deprecated. If both &%add_header%& and &%message%&
32122 are present on a &%warn%& verb, both are processed according to their
32123 specifications.
32124
32125 By default, new header lines are added to a message at the end of the existing
32126 header lines. However, you can specify that any particular header line should
32127 be added right at the start (before all the &'Received:'& lines), immediately
32128 after the first block of &'Received:'& lines, or immediately before any line
32129 that is not a &'Received:'& or &'Resent-something:'& header.
32130
32131 This is done by specifying &":at_start:"&, &":after_received:"&, or
32132 &":at_start_rfc:"& (or, for completeness, &":at_end:"&) before the text of the
32133 header line, respectively. (Header text cannot start with a colon, as there has
32134 to be a header name first.) For example:
32135 .code
32136 warn add_header = \
32137        :after_received:X-My-Header: something or other...
32138 .endd
32139 If more than one header line is supplied in a single &%add_header%& modifier,
32140 each one is treated independently and can therefore be placed differently. If
32141 you add more than one line at the start, or after the Received: block, they end
32142 up in reverse order.
32143
32144 &*Warning*&: This facility currently applies only to header lines that are
32145 added in an ACL. It does NOT work for header lines that are added in a
32146 system filter or in a router or transport.
32147
32148
32149
32150 .section "Removing header lines in ACLs" "SECTremoveheadacl"
32151 .cindex "header lines" "removing in an ACL"
32152 .cindex "header lines" "position of removed lines"
32153 .cindex "&%remove_header%& ACL modifier"
32154 The &%remove_header%& modifier can be used to remove one or more header lines
32155 from an incoming message, as in this example:
32156 .code
32157 warn   message        = Remove internal headers
32158        remove_header  = x-route-mail1 : x-route-mail2
32159 .endd
32160 The &%remove_header%& modifier is permitted in the MAIL, RCPT, PREDATA, DATA,
32161 MIME, DKIM, and non-SMTP ACLs (in other words, those that are concerned with
32162 receiving a message). The message must ultimately be accepted for
32163 &%remove_header%& to have any significant effect. You can use &%remove_header%&
32164 with any ACL verb, including &%deny%&, though this is really not useful for
32165 any verb that doesn't result in a delivered message.
32166
32167 Headers will not be removed from the message if the modifier is used in
32168 DATA, MIME or DKIM ACLs for a message delivered by cutthrough routing.
32169
32170 More than one header can be removed at the same time by using a colon separated
32171 list of header specifiers.
32172 If a specifier does not start with a circumflex (^)
32173 then it is treated as a header name.
32174 The header name matching is case insensitive.
32175 If it does, then it is treated as a (front-anchored)
32176 regular expression applied to the whole header.
32177
32178 &*Note*&: The colon terminating a header name will need to be doubled
32179 if used in an RE, and there can legitimately be whitepace before it.
32180
32181 Example:
32182 .code
32183 remove_header = \N^(?i)Authentication-Results\s*::\s*example.org;\N
32184 .endd
32185
32186 List expansion is not performed, so you cannot use hostlists to
32187 create a list of headers, however both connection and message variable expansion
32188 are performed (&%$acl_c_*%& and &%$acl_m_*%&), illustrated in this example:
32189 .code
32190 warn   hosts           = +internal_hosts
32191        set acl_c_ihdrs = x-route-mail1 : x-route-mail2
32192 warn   message         = Remove internal headers
32193        remove_header   = $acl_c_ihdrs
32194 .endd
32195 Header specifiers for removal are accumulated during the MAIL, RCPT, and predata ACLs.
32196 Matching header lines are removed from the message before processing the DATA and MIME ACLs.
32197 If multiple header lines match, all are removed.
32198 There is no harm in attempting to remove the same header twice nor in removing
32199 a non-existent header. Further header specifiers for removal may be accumulated
32200 during the DATA and MIME ACLs, after which matching headers are removed
32201 if present. In the case of non-SMTP messages, remove specifiers are
32202 accumulated during the non-SMTP ACLs, and are acted on after
32203 all the ACLs have run. If a message is rejected after DATA or by the non-SMTP
32204 ACL, there really is no effect because there is no logging of what headers
32205 would have been removed.
32206
32207 .cindex "header lines" "removed; visibility of"
32208 Header lines are not visible in string expansions until the DATA phase when it
32209 is received. Any header lines removed in the MAIL, RCPT, and predata ACLs are
32210 not visible in the DATA ACL and MIME ACLs. Similarly, header lines that are
32211 removed by the DATA or MIME ACLs are still visible in those ACLs. Because of
32212 this restriction, you cannot use header lines as a way of controlling data
32213 passed between (for example) the MAIL and RCPT ACLs. If you want to do this,
32214 you should instead use ACL variables, as described in section
32215 &<<SECTaclvariables>>&.
32216
32217 The &%remove_header%& modifier acts immediately as it is encountered during the
32218 processing of an ACL. Notice the difference between these two cases:
32219 .display
32220 &`accept remove_header = X-Internal`&
32221 &`       `&<&'some condition'&>
32222
32223 &`accept `&<&'some condition'&>
32224 &`       remove_header = X-Internal`&
32225 .endd
32226 In the first case, the header line is always removed, whether or not the
32227 condition is true. In the second case, the header line is removed only if the
32228 condition is true. Multiple occurrences of &%remove_header%& may occur in the
32229 same ACL statement. All those that are encountered before a condition fails
32230 are honoured.
32231
32232 &*Warning*&: This facility currently applies only to header lines that are
32233 present during ACL processing. It does NOT remove header lines that are added
32234 in a system filter or in a router or transport.
32235
32236
32237
32238
32239 .section "ACL conditions" "SECTaclconditions"
32240 .cindex "&ACL;" "conditions; list of"
32241 Some of the conditions listed in this section are available only when Exim is
32242 compiled with the content-scanning extension. They are included here briefly
32243 for completeness. More detailed descriptions can be found in the discussion on
32244 content scanning in chapter &<<CHAPexiscan>>&.
32245
32246 Not all conditions are relevant in all circumstances. For example, testing
32247 senders and recipients does not make sense in an ACL that is being run as the
32248 result of the arrival of an ETRN command, and checks on message headers can be
32249 done only in the ACLs specified by &%acl_smtp_data%& and &%acl_not_smtp%&. You
32250 can use the same condition (with different parameters) more than once in the
32251 same ACL statement. This provides a way of specifying an &"and"& conjunction.
32252 The conditions are as follows:
32253
32254
32255 .vlist
32256 .vitem &*acl&~=&~*&<&'name&~of&~acl&~or&~ACL&~string&~or&~file&~name&~'&>
32257 .cindex "&ACL;" "nested"
32258 .cindex "&ACL;" "indirect"
32259 .cindex "&ACL;" "arguments"
32260 .cindex "&%acl%& ACL condition"
32261 The possible values of the argument are the same as for the
32262 &%acl_smtp_%&&'xxx'& options. The named or inline ACL is run. If it returns
32263 &"accept"& the condition is true; if it returns &"deny"& the condition is
32264 false. If it returns &"defer"&, the current ACL returns &"defer"& unless the
32265 condition is on a &%warn%& verb. In that case, a &"defer"& return makes the
32266 condition false. This means that further processing of the &%warn%& verb
32267 ceases, but processing of the ACL continues.
32268
32269 If the argument is a named ACL, up to nine space-separated optional values
32270 can be appended; they appear within the called ACL in $acl_arg1 to $acl_arg9,
32271 and $acl_narg is set to the count of values.
32272 Previous values of these variables are restored after the call returns.
32273 The name and values are expanded separately.
32274 Note that spaces in complex expansions which are used as arguments
32275 will act as argument separators.
32276
32277 If the nested &%acl%& returns &"drop"& and the outer condition denies access,
32278 the connection is dropped. If it returns &"discard"&, the verb must be
32279 &%accept%& or &%discard%&, and the action is taken immediately &-- no further
32280 conditions are tested.
32281
32282 ACLs may be nested up to 20 deep; the limit exists purely to catch runaway
32283 loops. This condition allows you to use different ACLs in different
32284 circumstances. For example, different ACLs can be used to handle RCPT commands
32285 for different local users or different local domains.
32286
32287 .vitem &*authenticated&~=&~*&<&'string&~list'&>
32288 .cindex "&%authenticated%& ACL condition"
32289 .cindex "authentication" "ACL checking"
32290 .cindex "&ACL;" "testing for authentication"
32291 If the SMTP connection is not authenticated, the condition is false. Otherwise,
32292 the name of the authenticator is tested against the list. To test for
32293 authentication by any authenticator, you can set
32294 .code
32295 authenticated = *
32296 .endd
32297
32298 .vitem &*condition&~=&~*&<&'string'&>
32299 .cindex "&%condition%& ACL condition"
32300 .cindex "customizing" "ACL condition"
32301 .cindex "&ACL;" "customized test"
32302 .cindex "&ACL;" "testing, customized"
32303 This feature allows you to make up custom conditions. If the result of
32304 expanding the string is an empty string, the number zero, or one of the strings
32305 &"no"& or &"false"&, the condition is false. If the result is any non-zero
32306 number, or one of the strings &"yes"& or &"true"&, the condition is true. For
32307 any other value, some error is assumed to have occurred, and the ACL returns
32308 &"defer"&. However, if the expansion is forced to fail, the condition is
32309 ignored. The effect is to treat it as true, whether it is positive or
32310 negative.
32311
32312 .vitem &*decode&~=&~*&<&'location'&>
32313 .cindex "&%decode%& ACL condition"
32314 This condition is available only when Exim is compiled with the
32315 content-scanning extension, and it is allowed only in the ACL defined by
32316 &%acl_smtp_mime%&. It causes the current MIME part to be decoded into a file.
32317 If all goes well, the condition is true. It is false only if there are
32318 problems such as a syntax error or a memory shortage. For more details, see
32319 chapter &<<CHAPexiscan>>&.
32320
32321 .vitem &*dnslists&~=&~*&<&'list&~of&~domain&~names&~and&~other&~data'&>
32322 .cindex "&%dnslists%& ACL condition"
32323 .cindex "DNS list" "in ACL"
32324 .cindex "black list (DNS)"
32325 .cindex "&ACL;" "testing a DNS list"
32326 This condition checks for entries in DNS black lists. These are also known as
32327 &"RBL lists"&, after the original Realtime Blackhole List, but note that the
32328 use of the lists at &'mail-abuse.org'& now carries a charge. There are too many
32329 different variants of this condition to describe briefly here. See sections
32330 &<<SECTmorednslists>>&&--&<<SECTmorednslistslast>>& for details.
32331
32332 .vitem &*domains&~=&~*&<&'domain&~list'&>
32333 .cindex "&%domains%& ACL condition"
32334 .cindex "domain" "ACL checking"
32335 .cindex "&ACL;" "testing a recipient domain"
32336 .vindex "&$domain_data$&"
32337 This condition is relevant only in a RCPT ACL. It checks that the domain
32338 of the recipient address is in the domain list. If percent-hack processing is
32339 enabled, it is done before this test is done. If the check succeeds with a
32340 lookup, the result of the lookup is placed in &$domain_data$& until the next
32341 &%domains%& test.
32342
32343 &*Note carefully*& (because many people seem to fall foul of this): you cannot
32344 use &%domains%& in a DATA ACL.
32345
32346
32347 .vitem &*encrypted&~=&~*&<&'string&~list'&>
32348 .cindex "&%encrypted%& ACL condition"
32349 .cindex "encryption" "checking in an ACL"
32350 .cindex "&ACL;" "testing for encryption"
32351 If the SMTP connection is not encrypted, the condition is false. Otherwise, the
32352 name of the cipher suite in use is tested against the list. To test for
32353 encryption without testing for any specific cipher suite(s), set
32354 .code
32355 encrypted = *
32356 .endd
32357
32358
32359 .vitem &*hosts&~=&~*&<&'host&~list'&>
32360 .cindex "&%hosts%& ACL condition"
32361 .cindex "host" "ACL checking"
32362 .cindex "&ACL;" "testing the client host"
32363 This condition tests that the calling host matches the host list. If you have
32364 name lookups or wildcarded host names and IP addresses in the same host list,
32365 you should normally put the IP addresses first. For example, you could have:
32366 .code
32367 accept hosts = 10.9.8.7 : dbm;/etc/friendly/hosts
32368 .endd
32369 The lookup in this example uses the host name for its key. This is implied by
32370 the lookup type &"dbm"&. (For a host address lookup you would use &"net-dbm"&
32371 and it wouldn't matter which way round you had these two items.)
32372
32373 The reason for the problem with host names lies in the left-to-right way that
32374 Exim processes lists. It can test IP addresses without doing any DNS lookups,
32375 but when it reaches an item that requires a host name, it fails if it cannot
32376 find a host name to compare with the pattern. If the above list is given in the
32377 opposite order, the &%accept%& statement fails for a host whose name cannot be
32378 found, even if its IP address is 10.9.8.7.
32379
32380 If you really do want to do the name check first, and still recognize the IP
32381 address even if the name lookup fails, you can rewrite the ACL like this:
32382 .code
32383 accept hosts = dbm;/etc/friendly/hosts
32384 accept hosts = 10.9.8.7
32385 .endd
32386 The default action on failing to find the host name is to assume that the host
32387 is not in the list, so the first &%accept%& statement fails. The second
32388 statement can then check the IP address.
32389
32390 .vindex "&$host_data$&"
32391 If a &%hosts%& condition is satisfied by means of a lookup, the result
32392 of the lookup is made available in the &$host_data$& variable. This
32393 allows you, for example, to set up a statement like this:
32394 .code
32395 deny  hosts = net-lsearch;/some/file
32396       message = $host_data
32397 .endd
32398 which gives a custom error message for each denied host.
32399
32400 .vitem &*local_parts&~=&~*&<&'local&~part&~list'&>
32401 .cindex "&%local_parts%& ACL condition"
32402 .cindex "local part" "ACL checking"
32403 .cindex "&ACL;" "testing a local part"
32404 .vindex "&$local_part_data$&"
32405 This condition is relevant only in a RCPT ACL. It checks that the local
32406 part of the recipient address is in the list. If percent-hack processing is
32407 enabled, it is done before this test. If the check succeeds with a lookup, the
32408 result of the lookup is placed in &$local_part_data$&, which remains set until
32409 the next &%local_parts%& test.
32410
32411 .vitem &*malware&~=&~*&<&'option'&>
32412 .cindex "&%malware%& ACL condition"
32413 .cindex "&ACL;" "virus scanning"
32414 .cindex "&ACL;" "scanning for viruses"
32415 This condition is available only when Exim is compiled with the
32416 content-scanning extension
32417 and only after a DATA command.
32418 It causes the incoming message to be scanned for
32419 viruses. For details, see chapter &<<CHAPexiscan>>&.
32420
32421 .vitem &*mime_regex&~=&~*&<&'list&~of&~regular&~expressions'&>
32422 .cindex "&%mime_regex%& ACL condition"
32423 .cindex "&ACL;" "testing by regex matching"
32424 This condition is available only when Exim is compiled with the
32425 content-scanning extension, and it is allowed only in the ACL defined by
32426 &%acl_smtp_mime%&. It causes the current MIME part to be scanned for a match
32427 with any of the regular expressions. For details, see chapter
32428 &<<CHAPexiscan>>&.
32429
32430 .vitem &*ratelimit&~=&~*&<&'parameters'&>
32431 .cindex "rate limiting"
32432 This condition can be used to limit the rate at which a user or host submits
32433 messages. Details are given in section &<<SECTratelimiting>>&.
32434
32435 .vitem &*recipients&~=&~*&<&'address&~list'&>
32436 .cindex "&%recipients%& ACL condition"
32437 .cindex "recipient" "ACL checking"
32438 .cindex "&ACL;" "testing a recipient"
32439 This condition is relevant only in a RCPT ACL. It checks the entire
32440 recipient address against a list of recipients.
32441
32442 .vitem &*regex&~=&~*&<&'list&~of&~regular&~expressions'&>
32443 .cindex "&%regex%& ACL condition"
32444 .cindex "&ACL;" "testing by regex matching"
32445 This condition is available only when Exim is compiled with the
32446 content-scanning extension, and is available only in the DATA, MIME, and
32447 non-SMTP ACLs. It causes the incoming message to be scanned for a match with
32448 any of the regular expressions. For details, see chapter &<<CHAPexiscan>>&.
32449
32450 .vitem &*seen&~=&~*&<&'parameters'&>
32451 .cindex "&%seen%& ACL condition"
32452 This condition can be used to test if a situation has been previously met,
32453 for example for greylisting.
32454 Details are given in section &<<SECTseen>>&.
32455
32456 .vitem &*sender_domains&~=&~*&<&'domain&~list'&>
32457 .cindex "&%sender_domains%& ACL condition"
32458 .cindex "sender" "ACL checking"
32459 .cindex "&ACL;" "testing a sender domain"
32460 .vindex "&$domain$&"
32461 .vindex "&$sender_address_domain$&"
32462 This condition tests the domain of the sender of the message against the given
32463 domain list. &*Note*&: The domain of the sender address is in
32464 &$sender_address_domain$&. It is &'not'& put in &$domain$& during the testing
32465 of this condition. This is an exception to the general rule for testing domain
32466 lists. It is done this way so that, if this condition is used in an ACL for a
32467 RCPT command, the recipient's domain (which is in &$domain$&) can be used to
32468 influence the sender checking.
32469
32470 &*Warning*&: It is a bad idea to use this condition on its own as a control on
32471 relaying, because sender addresses are easily, and commonly, forged.
32472
32473 .vitem &*senders&~=&~*&<&'address&~list'&>
32474 .cindex "&%senders%& ACL condition"
32475 .cindex "sender" "ACL checking"
32476 .cindex "&ACL;" "testing a sender"
32477 This condition tests the sender of the message against the given list. To test
32478 for a bounce message, which has an empty sender, set
32479 .code
32480 senders = :
32481 .endd
32482 &*Warning*&: It is a bad idea to use this condition on its own as a control on
32483 relaying, because sender addresses are easily, and commonly, forged.
32484
32485 .vitem &*spam&~=&~*&<&'username'&>
32486 .cindex "&%spam%& ACL condition"
32487 .cindex "&ACL;" "scanning for spam"
32488 This condition is available only when Exim is compiled with the
32489 content-scanning extension. It causes the incoming message to be scanned by
32490 SpamAssassin. For details, see chapter &<<CHAPexiscan>>&.
32491
32492 .vitem &*verify&~=&~certificate*&
32493 .cindex "&%verify%& ACL condition"
32494 .cindex "TLS" "client certificate verification"
32495 .cindex "certificate" "verification of client"
32496 .cindex "&ACL;" "certificate verification"
32497 .cindex "&ACL;" "testing a TLS certificate"
32498 This condition is true in an SMTP session if the session is encrypted, and a
32499 certificate was received from the client, and the certificate was verified. The
32500 server requests a certificate only if the client matches &%tls_verify_hosts%&
32501 or &%tls_try_verify_hosts%& (see chapter &<<CHAPTLS>>&).
32502
32503 .vitem &*verify&~=&~csa*&
32504 .cindex "CSA verification"
32505 This condition checks whether the sending host (the client) is authorized to
32506 send email. Details of how this works are given in section
32507 &<<SECTverifyCSA>>&.
32508
32509 .vitem &*verify&~=&~header_names_ascii*&
32510 .cindex "&%verify%& ACL condition"
32511 .cindex "&ACL;" "verifying header names only ASCII"
32512 .cindex "header lines" "verifying header names only ASCII"
32513 .cindex "verifying" "header names only ASCII"
32514 This condition is relevant only in an ACL that is run after a message has been
32515 received.
32516 This usually means an ACL specified by &%acl_smtp_data%& or &%acl_not_smtp%&.
32517 It checks all header names (not the content) to make sure
32518 there are no non-ASCII characters, also excluding control characters.  The
32519 allowable characters are decimal ASCII values 33 through 126.
32520
32521 Exim itself will handle headers with non-ASCII characters, but it can cause
32522 problems for downstream applications, so this option will allow their
32523 detection and rejection in the DATA ACL's.
32524
32525 .vitem &*verify&~=&~header_sender/*&<&'options'&>
32526 .cindex "&%verify%& ACL condition"
32527 .cindex "&ACL;" "verifying sender in the header"
32528 .cindex "header lines" "verifying the sender in"
32529 .cindex "sender" "verifying in header"
32530 .cindex "verifying" "sender in header"
32531 This condition is relevant only in an ACL that is run after a message has been
32532 received, that is, in an ACL specified by &%acl_smtp_data%& or
32533 &%acl_not_smtp%&. It checks that there is a verifiable address in at least one
32534 of the &'Sender:'&, &'Reply-To:'&, or &'From:'& header lines. Such an address
32535 is loosely thought of as a &"sender"& address (hence the name of the test).
32536 However, an address that appears in one of these headers need not be an address
32537 that accepts bounce messages; only sender addresses in envelopes are required
32538 to accept bounces. Therefore, if you use the callout option on this check, you
32539 might want to arrange for a non-empty address in the MAIL command.
32540
32541 Details of address verification and the options are given later, starting at
32542 section &<<SECTaddressverification>>& (callouts are described in section
32543 &<<SECTcallver>>&). You can combine this condition with the &%senders%&
32544 condition to restrict it to bounce messages only:
32545 .code
32546 deny    senders = :
32547        !verify  = header_sender
32548         message = A valid sender header is required for bounces
32549 .endd
32550
32551 .vitem &*verify&~=&~header_syntax*&
32552 .cindex "&%verify%& ACL condition"
32553 .cindex "&ACL;" "verifying header syntax"
32554 .cindex "header lines" "verifying syntax"
32555 .cindex "verifying" "header syntax"
32556 This condition is relevant only in an ACL that is run after a message has been
32557 received, that is, in an ACL specified by &%acl_smtp_data%& or
32558 &%acl_not_smtp%&. It checks the syntax of all header lines that can contain
32559 lists of addresses (&'Sender:'&, &'From:'&, &'Reply-To:'&, &'To:'&, &'Cc:'&,
32560 and &'Bcc:'&), returning true if there are no problems.
32561 Unqualified addresses (local parts without domains) are
32562 permitted only in locally generated messages and from hosts that match
32563 &%sender_unqualified_hosts%& or &%recipient_unqualified_hosts%&, as
32564 appropriate.
32565
32566 Note that this condition is a syntax check only. However, a common spamming
32567 ploy used to be to send syntactically invalid headers such as
32568 .code
32569 To: @
32570 .endd
32571 and this condition can be used to reject such messages, though they are not as
32572 common as they used to be.
32573
32574 .vitem &*verify&~=&~helo*&
32575 .cindex "&%verify%& ACL condition"
32576 .cindex "&ACL;" "verifying HELO/EHLO"
32577 .cindex "HELO" "verifying"
32578 .cindex "EHLO" "verifying"
32579 .cindex "verifying" "EHLO"
32580 .cindex "verifying" "HELO"
32581 This condition is true if a HELO or EHLO command has been received from the
32582 client host, and its contents have been verified. If there has been no previous
32583 attempt to verify the HELO/EHLO contents, it is carried out when this
32584 condition is encountered. See the description of the &%helo_verify_hosts%& and
32585 &%helo_try_verify_hosts%& options for details of how to request verification
32586 independently of this condition, and for detail of the verification.
32587
32588 For SMTP input that does not come over TCP/IP (the &%-bs%& command line
32589 option), this condition is always true.
32590
32591
32592 .vitem &*verify&~=&~not_blind/*&<&'options'&>
32593 .cindex "verifying" "not blind"
32594 .cindex "bcc recipients, verifying none"
32595 This condition checks that there are no blind (bcc) recipients in the message.
32596 Every envelope recipient must appear either in a &'To:'& header line or in a
32597 &'Cc:'& header line for this condition to be true. Local parts are checked
32598 case-sensitively; domains are checked case-insensitively. If &'Resent-To:'& or
32599 &'Resent-Cc:'& header lines exist, they are also checked. This condition can be
32600 used only in a DATA or non-SMTP ACL.
32601
32602 There is one possible option, &`case_insensitive`&.  If this is present then
32603 local parts are checked case-insensitively.
32604
32605 There are, of course, many legitimate messages that make use of blind (bcc)
32606 recipients. This check should not be used on its own for blocking messages.
32607
32608
32609 .vitem &*verify&~=&~recipient/*&<&'options'&>
32610 .cindex "&%verify%& ACL condition"
32611 .cindex "&ACL;" "verifying recipient"
32612 .cindex "recipient" "verifying"
32613 .cindex "verifying" "recipient"
32614 .vindex "&$address_data$&"
32615 This condition is relevant only after a RCPT command. It verifies the current
32616 recipient. Details of address verification are given later, starting at section
32617 &<<SECTaddressverification>>&. After a recipient has been verified, the value
32618 of &$address_data$& is the last value that was set while routing the address.
32619 This applies even if the verification fails. When an address that is being
32620 verified is redirected to a single address, verification continues with the new
32621 address, and in that case, the subsequent value of &$address_data$& is the
32622 value for the child address.
32623
32624 .vitem &*verify&~=&~reverse_host_lookup/*&<&'options'&>
32625 .cindex "&%verify%& ACL condition"
32626 .cindex "&ACL;" "verifying host reverse lookup"
32627 .cindex "host" "verifying reverse lookup"
32628 This condition ensures that a verified host name has been looked up from the IP
32629 address of the client host. (This may have happened already if the host name
32630 was needed for checking a host list, or if the host matched &%host_lookup%&.)
32631 Verification ensures that the host name obtained from a reverse DNS lookup, or
32632 one of its aliases, does, when it is itself looked up in the DNS, yield the
32633 original IP address.
32634
32635 There is one possible option, &`defer_ok`&.  If this is present and a
32636 DNS operation returns a temporary error, the verify condition succeeds.
32637
32638 If this condition is used for a locally generated message (that is, when there
32639 is no client host involved), it always succeeds.
32640
32641 .vitem &*verify&~=&~sender/*&<&'options'&>
32642 .cindex "&%verify%& ACL condition"
32643 .cindex "&ACL;" "verifying sender"
32644 .cindex "sender" "verifying"
32645 .cindex "verifying" "sender"
32646 This condition is relevant only after a MAIL or RCPT command, or after a
32647 message has been received (the &%acl_smtp_data%& or &%acl_not_smtp%& ACLs). If
32648 the message's sender is empty (that is, this is a bounce message), the
32649 condition is true. Otherwise, the sender address is verified.
32650
32651 .vindex "&$address_data$&"
32652 .vindex "&$sender_address_data$&"
32653 If there is data in the &$address_data$& variable at the end of routing, its
32654 value is placed in &$sender_address_data$& at the end of verification. This
32655 value can be used in subsequent conditions and modifiers in the same ACL
32656 statement. It does not persist after the end of the current statement. If you
32657 want to preserve the value for longer, you can save it in an ACL variable.
32658
32659 Details of verification are given later, starting at section
32660 &<<SECTaddressverification>>&. Exim caches the result of sender verification,
32661 to avoid doing it more than once per message.
32662
32663 .vitem &*verify&~=&~sender=*&<&'address'&>&*/*&<&'options'&>
32664 .cindex "&%verify%& ACL condition"
32665 This is a variation of the previous option, in which a modified address is
32666 verified as a sender.
32667
32668 Note that '/' is legal in local-parts; if the address may have such
32669 (eg. is generated from the received message)
32670 they must be protected from the options parsing by doubling:
32671 .code
32672 verify = sender=${listquote{/}{${address:$h_sender:}}}
32673 .endd
32674 .endlist
32675
32676
32677
32678 .section "Using DNS lists" "SECTmorednslists"
32679 .cindex "DNS list" "in ACL"
32680 .cindex "black list (DNS)"
32681 .cindex "&ACL;" "testing a DNS list"
32682 In its simplest form, the &%dnslists%& condition tests whether the calling host
32683 is on at least one of a number of DNS lists by looking up the inverted IP
32684 address in one or more DNS domains. (Note that DNS list domains are not mail
32685 domains, so the &`+`& syntax for named lists doesn't work - it is used for
32686 special options instead.) For example, if the calling host's IP
32687 address is 192.168.62.43, and the ACL statement is
32688 .code
32689 deny dnslists = blackholes.mail-abuse.org : \
32690                 dialups.mail-abuse.org
32691 .endd
32692 the following records are looked up:
32693 .code
32694 43.62.168.192.blackholes.mail-abuse.org
32695 43.62.168.192.dialups.mail-abuse.org
32696 .endd
32697 As soon as Exim finds an existing DNS record, processing of the list stops.
32698 Thus, multiple entries on the list provide an &"or"& conjunction. If you want
32699 to test that a host is on more than one list (an &"and"& conjunction), you can
32700 use two separate conditions:
32701 .code
32702 deny dnslists = blackholes.mail-abuse.org
32703      dnslists = dialups.mail-abuse.org
32704 .endd
32705 If a DNS lookup times out or otherwise fails to give a decisive answer, Exim
32706 behaves as if the host does not match the list item, that is, as if the DNS
32707 record does not exist. If there are further items in the DNS list, they are
32708 processed.
32709
32710 This is usually the required action when &%dnslists%& is used with &%deny%&
32711 (which is the most common usage), because it prevents a DNS failure from
32712 blocking mail. However, you can change this behaviour by putting one of the
32713 following special items in the list:
32714 .itable none 0 0 2 25* left 75* left
32715 .irow "+include_unknown"   "behave as if the item is on the list"
32716 .irow "+exclude_unknown"   "behave as if the item is not on the list (default)"
32717 .irow "+defer_unknown  "   "give a temporary error"
32718 .endtable
32719 .cindex "&`+include_unknown`&"
32720 .cindex "&`+exclude_unknown`&"
32721 .cindex "&`+defer_unknown`&"
32722 Each of these applies to any subsequent items on the list. For example:
32723 .code
32724 deny dnslists = +defer_unknown : foo.bar.example
32725 .endd
32726 Testing the list of domains stops as soon as a match is found. If you want to
32727 warn for one list and block for another, you can use two different statements:
32728 .code
32729 deny  dnslists = blackholes.mail-abuse.org
32730 warn  dnslists = dialups.mail-abuse.org
32731       message  = X-Warn: sending host is on dialups list
32732 .endd
32733 .cindex caching "of dns lookup"
32734 .cindex DNS TTL
32735 DNS list lookups are cached by Exim for the duration of the SMTP session
32736 (but limited by the DNS return TTL value),
32737 so a lookup based on the IP address is done at most once for any incoming
32738 connection (assuming long-enough TTL).
32739 Exim does not share information between multiple incoming
32740 connections (but your local name server cache should be active).
32741
32742 There are a number of DNS lists to choose from, some commercial, some free,
32743 or free for small deployments.  An overview can be found at
32744 &url(https://en.wikipedia.org/wiki/Comparison_of_DNS_blacklists).
32745
32746
32747
32748 .subsection "Specifying the IP address for a DNS list lookup" SECID201
32749 .cindex "DNS list" "keyed by explicit IP address"
32750 By default, the IP address that is used in a DNS list lookup is the IP address
32751 of the calling host. However, you can specify another IP address by listing it
32752 after the domain name, introduced by a slash. For example:
32753 .code
32754 deny dnslists = black.list.tld/192.168.1.2
32755 .endd
32756 This feature is not very helpful with explicit IP addresses; it is intended for
32757 use with IP addresses that are looked up, for example, the IP addresses of the
32758 MX hosts or nameservers of an email sender address. For an example, see section
32759 &<<SECTmulkeyfor>>& below.
32760
32761
32762
32763
32764 .subsection "DNS lists keyed on domain names" SECID202
32765 .cindex "DNS list" "keyed by domain name"
32766 There are some lists that are keyed on domain names rather than inverted IP
32767 addresses (see, e.g., the &'domain based zones'& link at
32768 &url(http://www.rfc-ignorant.org/)). No reversing of components is used
32769 with these lists. You can change the name that is looked up in a DNS list by
32770 listing it after the domain name, introduced by a slash. For example,
32771 .code
32772 deny  dnslists = dsn.rfc-ignorant.org/$sender_address_domain
32773       message  = Sender's domain is listed at $dnslist_domain
32774 .endd
32775 This particular example is useful only in ACLs that are obeyed after the
32776 RCPT or DATA commands, when a sender address is available. If (for
32777 example) the message's sender is &'user@tld.example'& the name that is looked
32778 up by this example is
32779 .code
32780 tld.example.dsn.rfc-ignorant.org
32781 .endd
32782 A single &%dnslists%& condition can contain entries for both names and IP
32783 addresses. For example:
32784 .code
32785 deny dnslists = sbl.spamhaus.org : \
32786                 dsn.rfc-ignorant.org/$sender_address_domain
32787 .endd
32788 The first item checks the sending host's IP address; the second checks a domain
32789 name. The whole condition is true if either of the DNS lookups succeeds.
32790
32791
32792
32793
32794 .subsection "Multiple explicit keys for a DNS list" SECTmulkeyfor
32795 .cindex "DNS list" "multiple keys for"
32796 The syntax described above for looking up explicitly-defined values (either
32797 names or IP addresses) in a DNS blacklist is a simplification. After the domain
32798 name for the DNS list, what follows the slash can in fact be a list of items.
32799 As with all lists in Exim, the default separator is a colon. However, because
32800 this is a sublist within the list of DNS blacklist domains, it is necessary
32801 either to double the separators like this:
32802 .code
32803 dnslists = black.list.tld/name.1::name.2
32804 .endd
32805 or to change the separator character, like this:
32806 .code
32807 dnslists = black.list.tld/<;name.1;name.2
32808 .endd
32809 If an item in the list is an IP address, it is inverted before the DNS
32810 blacklist domain is appended. If it is not an IP address, no inversion
32811 occurs. Consider this condition:
32812 .code
32813 dnslists = black.list.tld/<;192.168.1.2;a.domain
32814 .endd
32815 The DNS lookups that occur are:
32816 .code
32817 2.1.168.192.black.list.tld
32818 a.domain.black.list.tld
32819 .endd
32820 Once a DNS record has been found (that matches a specific IP return
32821 address, if specified &-- see section &<<SECTaddmatcon>>&), no further lookups
32822 are done. If there is a temporary DNS error, the rest of the sublist of domains
32823 or IP addresses is tried. A temporary error for the whole dnslists item occurs
32824 only if no other DNS lookup in this sublist succeeds. In other words, a
32825 successful lookup for any of the items in the sublist overrides a temporary
32826 error for a previous item.
32827
32828 The ability to supply a list of items after the slash is in some sense just a
32829 syntactic convenience. These two examples have the same effect:
32830 .code
32831 dnslists = black.list.tld/a.domain : black.list.tld/b.domain
32832 dnslists = black.list.tld/a.domain::b.domain
32833 .endd
32834 However, when the data for the list is obtained from a lookup, the second form
32835 is usually much more convenient. Consider this example:
32836 .code
32837 deny dnslists = sbl.spamhaus.org/<|${lookup dnsdb {>|a=<|\
32838                                    ${lookup dnsdb {>|mxh=\
32839                                    $sender_address_domain} }} }
32840      message  = The mail servers for the domain \
32841                 $sender_address_domain \
32842                 are listed at $dnslist_domain ($dnslist_value); \
32843                 see $dnslist_text.
32844 .endd
32845 Note the use of &`>|`& in the dnsdb lookup to specify the separator for
32846 multiple DNS records. The inner dnsdb lookup produces a list of MX hosts
32847 and the outer dnsdb lookup finds the IP addresses for these hosts. The result
32848 of expanding the condition might be something like this:
32849 .code
32850 dnslists = sbl.spamhaus.org/<|192.168.2.3|192.168.5.6|...
32851 .endd
32852 Thus, this example checks whether or not the IP addresses of the sender
32853 domain's mail servers are on the Spamhaus black list.
32854
32855 The key that was used for a successful DNS list lookup is put into the variable
32856 &$dnslist_matched$& (see section &<<SECID204>>&).
32857
32858
32859
32860
32861 .subsection "Data returned by DNS lists" SECID203
32862 .cindex "DNS list" "data returned from"
32863 DNS lists are constructed using address records in the DNS. The original RBL
32864 just used the address 127.0.0.1 on the right hand side of each record, but the
32865 RBL+ list and some other lists use a number of values with different meanings.
32866 The values used on the RBL+ list are:
32867 .itable none 0 0 2 20* left 80* left
32868 .irow 127.1.0.1  "RBL"
32869 .irow 127.1.0.2  "DUL"
32870 .irow 127.1.0.3  "DUL and RBL"
32871 .irow 127.1.0.4  "RSS"
32872 .irow 127.1.0.5  "RSS and RBL"
32873 .irow 127.1.0.6  "RSS and DUL"
32874 .irow 127.1.0.7  "RSS and DUL and RBL"
32875 .endtable
32876 Section &<<SECTaddmatcon>>& below describes how you can distinguish between
32877 different values. Some DNS lists may return more than one address record;
32878 see section &<<SECThanmuldnsrec>>& for details of how they are checked.
32879
32880 Values returned by a properly running DBSBL should be in the 127.0.0.0/8
32881 range. If a DNSBL operator loses control of the domain, lookups on it
32882 may start returning other addresses.  Because of this, Exim now ignores
32883 returned values outside the 127/8 region.
32884
32885
32886 .subsection "Variables set from DNS lists" SECID204
32887 .cindex "expansion" "variables, set from DNS list"
32888 .cindex "DNS list" "variables set from"
32889 .vindex "&$dnslist_domain$&"
32890 .vindex "&$dnslist_matched$&"
32891 .vindex "&$dnslist_text$&"
32892 .vindex "&$dnslist_value$&"
32893 When an entry is found in a DNS list, the variable &$dnslist_domain$& contains
32894 the name of the overall domain that matched (for example,
32895 &`spamhaus.example`&), &$dnslist_matched$& contains the key within that domain
32896 (for example, &`192.168.5.3`&), and &$dnslist_value$& contains the data from
32897 the DNS record. When the key is an IP address, it is not reversed in
32898 &$dnslist_matched$& (though it is, of course, in the actual lookup). In simple
32899 cases, for example:
32900 .code
32901 deny dnslists = spamhaus.example
32902 .endd
32903 the key is also available in another variable (in this case,
32904 &$sender_host_address$&). In more complicated cases, however, this is not true.
32905 For example, using a data lookup (as described in section &<<SECTmulkeyfor>>&)
32906 might generate a dnslists lookup like this:
32907 .code
32908 deny dnslists = spamhaus.example/<|192.168.1.2|192.168.6.7|...
32909 .endd
32910 If this condition succeeds, the value in &$dnslist_matched$& might be
32911 &`192.168.6.7`& (for example).
32912
32913 If more than one address record is returned by the DNS lookup, all the IP
32914 addresses are included in &$dnslist_value$&, separated by commas and spaces.
32915 The variable &$dnslist_text$& contains the contents of any associated TXT
32916 record. For lists such as RBL+ the TXT record for a merged entry is often not
32917 very meaningful. See section &<<SECTmordetinf>>& for a way of obtaining more
32918 information.
32919
32920 You can use the DNS list variables in &%message%& or &%log_message%& modifiers
32921 &-- even if these appear before the condition in the ACL, they are not
32922 expanded until after it has failed. For example:
32923 .code
32924 deny    hosts = !+local_networks
32925         message = $sender_host_address is listed \
32926                   at $dnslist_domain
32927         dnslists = rbl-plus.mail-abuse.example
32928 .endd
32929
32930
32931
32932 .subsection "Additional matching conditions for DNS lists" SECTaddmatcon
32933 .cindex "DNS list" "matching specific returned data"
32934 You can add an equals sign and an IP address after a &%dnslists%& domain name
32935 in order to restrict its action to DNS records with a matching right hand side.
32936 For example,
32937 .code
32938 deny dnslists = rblplus.mail-abuse.org=127.0.0.2
32939 .endd
32940 rejects only those hosts that yield 127.0.0.2. Without this additional data,
32941 any address record is considered to be a match. For the moment, we assume
32942 that the DNS lookup returns just one record. Section &<<SECThanmuldnsrec>>&
32943 describes how multiple records are handled.
32944
32945 More than one IP address may be given for checking, using a comma as a
32946 separator. These are alternatives &-- if any one of them matches, the
32947 &%dnslists%& condition is true. For example:
32948 .code
32949 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
32950 .endd
32951 If you want to specify a constraining address list and also specify names or IP
32952 addresses to be looked up, the constraining address list must be specified
32953 first. For example:
32954 .code
32955 deny dnslists = dsn.rfc-ignorant.org\
32956                 =127.0.0.2/$sender_address_domain
32957 .endd
32958
32959 If the character &`&&`& is used instead of &`=`&, the comparison for each
32960 listed IP address is done by a bitwise &"and"& instead of by an equality test.
32961 In other words, the listed addresses are used as bit masks. The comparison is
32962 true if all the bits in the mask are present in the address that is being
32963 tested. For example:
32964 .code
32965 dnslists = a.b.c&0.0.0.3
32966 .endd
32967 matches if the address is &'x.x.x.'&3, &'x.x.x.'&7, &'x.x.x.'&11, etc. If you
32968 want to test whether one bit or another bit is present (as opposed to both
32969 being present), you must use multiple values. For example:
32970 .code
32971 dnslists = a.b.c&0.0.0.1,0.0.0.2
32972 .endd
32973 matches if the final component of the address is an odd number or two times
32974 an odd number.
32975
32976
32977
32978 .subsection "Negated DNS matching conditions" SECID205
32979 You can supply a negative list of IP addresses as part of a &%dnslists%&
32980 condition. Whereas
32981 .code
32982 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
32983 .endd
32984 means &"deny if the host is in the black list at the domain &'a.b.c'& and the
32985 IP address yielded by the list is either 127.0.0.2 or 127.0.0.3"&,
32986 .code
32987 deny  dnslists = a.b.c!=127.0.0.2,127.0.0.3
32988 .endd
32989 means &"deny if the host is in the black list at the domain &'a.b.c'& and the
32990 IP address yielded by the list is not 127.0.0.2 and not 127.0.0.3"&. In other
32991 words, the result of the test is inverted if an exclamation mark appears before
32992 the &`=`& (or the &`&&`&) sign.
32993
32994 &*Note*&: This kind of negation is not the same as negation in a domain,
32995 host, or address list (which is why the syntax is different).
32996
32997 If you are using just one list, the negation syntax does not gain you much. The
32998 previous example is precisely equivalent to
32999 .code
33000 deny  dnslists = a.b.c
33001      !dnslists = a.b.c=127.0.0.2,127.0.0.3
33002 .endd
33003 However, if you are using multiple lists, the negation syntax is clearer.
33004 Consider this example:
33005 .code
33006 deny  dnslists = sbl.spamhaus.org : \
33007                  list.dsbl.org : \
33008                  dnsbl.njabl.org!=127.0.0.3 : \
33009                  relays.ordb.org
33010 .endd
33011 Using only positive lists, this would have to be:
33012 .code
33013 deny  dnslists = sbl.spamhaus.org : \
33014                  list.dsbl.org
33015 deny  dnslists = dnsbl.njabl.org
33016      !dnslists = dnsbl.njabl.org=127.0.0.3
33017 deny  dnslists = relays.ordb.org
33018 .endd
33019 which is less clear, and harder to maintain.
33020
33021 Negation can also be used with a bitwise-and restriction.
33022 The dnslists condition with only be trus if a result is returned
33023 by the lookup which, anded with the restriction, is all zeroes.
33024 For example:
33025 .code
33026 deny dnslists = zen.spamhaus.org!&0.255.255.0
33027 .endd
33028
33029
33030
33031
33032 .subsection "Handling multiple DNS records from a DNS list" SECThanmuldnsrec
33033 A DNS lookup for a &%dnslists%& condition may return more than one DNS record,
33034 thereby providing more than one IP address. When an item in a &%dnslists%& list
33035 is followed by &`=`& or &`&&`& and a list of IP addresses, in order to restrict
33036 the match to specific results from the DNS lookup, there are two ways in which
33037 the checking can be handled. For example, consider the condition:
33038 .code
33039 dnslists = a.b.c=127.0.0.1
33040 .endd
33041 What happens if the DNS lookup for the incoming IP address yields both
33042 127.0.0.1 and 127.0.0.2 by means of two separate DNS records? Is the
33043 condition true because at least one given value was found, or is it false
33044 because at least one of the found values was not listed? And how does this
33045 affect negated conditions? Both possibilities are provided for with the help of
33046 additional separators &`==`& and &`=&&`&.
33047
33048 .ilist
33049 If &`=`& or &`&&`& is used, the condition is true if any one of the looked up
33050 IP addresses matches one of the listed addresses. For the example above, the
33051 condition is true because 127.0.0.1 matches.
33052 .next
33053 If &`==`& or &`=&&`& is used, the condition is true only if every one of the
33054 looked up IP addresses matches one of the listed addresses. If the condition is
33055 changed to:
33056 .code
33057 dnslists = a.b.c==127.0.0.1
33058 .endd
33059 and the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
33060 false because 127.0.0.2 is not listed. You would need to have:
33061 .code
33062 dnslists = a.b.c==127.0.0.1,127.0.0.2
33063 .endd
33064 for the condition to be true.
33065 .endlist
33066
33067 When &`!`& is used to negate IP address matching, it inverts the result, giving
33068 the precise opposite of the behaviour above. Thus:
33069 .ilist
33070 If &`!=`& or &`!&&`& is used, the condition is true if none of the looked up IP
33071 addresses matches one of the listed addresses. Consider:
33072 .code
33073 dnslists = a.b.c!&0.0.0.1
33074 .endd
33075 If the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
33076 false because 127.0.0.1 matches.
33077 .next
33078 If &`!==`& or &`!=&&`& is used, the condition is true if there is at least one
33079 looked up IP address that does not match. Consider:
33080 .code
33081 dnslists = a.b.c!=&0.0.0.1
33082 .endd
33083 If the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
33084 true, because 127.0.0.2 does not match. You would need to have:
33085 .code
33086 dnslists = a.b.c!=&0.0.0.1,0.0.0.2
33087 .endd
33088 for the condition to be false.
33089 .endlist
33090 When the DNS lookup yields only a single IP address, there is no difference
33091 between &`=`& and &`==`& and between &`&&`& and &`=&&`&.
33092
33093
33094
33095
33096 .subsection "Detailed information from merged DNS lists" SECTmordetinf
33097 .cindex "DNS list" "information from merged"
33098 When the facility for restricting the matching IP values in a DNS list is used,
33099 the text from the TXT record that is set in &$dnslist_text$& may not reflect
33100 the true reason for rejection. This happens when lists are merged and the IP
33101 address in the A record is used to distinguish them; unfortunately there is
33102 only one TXT record. One way round this is not to use merged lists, but that
33103 can be inefficient because it requires multiple DNS lookups where one would do
33104 in the vast majority of cases when the host of interest is not on any of the
33105 lists.
33106
33107 A less inefficient way of solving this problem is available. If
33108 two domain names, comma-separated, are given, the second is used first to
33109 do an initial check, making use of any IP value restrictions that are set.
33110 If there is a match, the first domain is used, without any IP value
33111 restrictions, to get the TXT record. As a byproduct of this, there is also
33112 a check that the IP being tested is indeed on the first list. The first
33113 domain is the one that is put in &$dnslist_domain$&. For example:
33114 .code
33115 deny   dnslists = \
33116          sbl.spamhaus.org,sbl-xbl.spamhaus.org=127.0.0.2 : \
33117          dul.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.10
33118        message  = \
33119          rejected because $sender_host_address is blacklisted \
33120          at $dnslist_domain\n$dnslist_text
33121 .endd
33122 For the first blacklist item, this starts by doing a lookup in
33123 &'sbl-xbl.spamhaus.org'& and testing for a 127.0.0.2 return. If there is a
33124 match, it then looks in &'sbl.spamhaus.org'&, without checking the return
33125 value, and as long as something is found, it looks for the corresponding TXT
33126 record. If there is no match in &'sbl-xbl.spamhaus.org'&, nothing more is done.
33127 The second blacklist item is processed similarly.
33128
33129 If you are interested in more than one merged list, the same list must be
33130 given several times, but because the results of the DNS lookups are cached,
33131 the DNS calls themselves are not repeated. For example:
33132 .code
33133 deny dnslists = \
33134          http.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.2 : \
33135          socks.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.3 : \
33136          misc.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.4 : \
33137          dul.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.10
33138 .endd
33139 In this case there is one lookup in &'dnsbl.sorbs.net'&, and if none of the IP
33140 values matches (or if no record is found), this is the only lookup that is
33141 done. Only if there is a match is one of the more specific lists consulted.
33142
33143
33144
33145 .subsection "DNS lists and IPv6" SECTmorednslistslast
33146 .cindex "IPv6" "DNS black lists"
33147 .cindex "DNS list" "IPv6 usage"
33148 If Exim is asked to do a dnslist lookup for an IPv6 address, it inverts it
33149 nibble by nibble. For example, if the calling host's IP address is
33150 3ffe:ffff:836f:0a00:000a:0800:200a:c031, Exim might look up
33151 .code
33152 1.3.0.c.a.0.0.2.0.0.8.0.a.0.0.0.0.0.a.0.f.6.3.8.
33153   f.f.f.f.e.f.f.3.blackholes.mail-abuse.org
33154 .endd
33155 (split over two lines here to fit on the page). Unfortunately, some of the DNS
33156 lists contain wildcard records, intended for IPv4, that interact badly with
33157 IPv6. For example, the DNS entry
33158 .code
33159 *.3.some.list.example.    A    127.0.0.1
33160 .endd
33161 is probably intended to put the entire 3.0.0.0/8 IPv4 network on the list.
33162 Unfortunately, it also matches the entire 3::/4 IPv6 network.
33163
33164 You can exclude IPv6 addresses from DNS lookups by making use of a suitable
33165 &%condition%& condition, as in this example:
33166 .code
33167 deny   condition = ${if isip4{$sender_host_address}}
33168        dnslists  = some.list.example
33169 .endd
33170
33171 If an explicit key is being used for a DNS lookup and it may be an IPv6
33172 address you should specify alternate list separators for both the outer
33173 (DNS list name) list and inner (lookup keys) list:
33174 .code
33175        dnslists = <; dnsbl.example.com/<|$acl_m_addrslist
33176 .endd
33177
33178
33179 .section "Previously seen user and hosts" "SECTseen"
33180 .cindex "&%seen%& ACL condition"
33181 .cindex greylisting
33182 The &%seen%& ACL condition can be used to test whether a
33183 situation has been previously met.
33184 It uses a hints database to record a timestamp against a key.
33185 The syntax of the condition is:
33186 .display
33187 &`seen =`& <&'optional flag'&><&'time interval'&> &`/`& <&'options'&>
33188 .endd
33189
33190 For example,
33191 .code
33192 defer   seen = -5m / key=${sender_host_address}_$local_part@$domain
33193 .endd
33194 in a RCPT ACL will implement simple greylisting.
33195
33196 The parameters for the condition are
33197 a possible minus sign,
33198 then an interval,
33199 then, slash-separated, a list of options.
33200 The interval is taken as an offset before the current time,
33201 and used for the test.
33202 If the interval is preceded by a minus sign then the condition returns
33203 whether a record is found which is before the test time.
33204 Otherwise, the condition returns whether one is found which is since the
33205 test time.
33206
33207 Options are read in order with later ones overriding earlier ones.
33208
33209 The default key is &$sender_host_address$&.
33210 An explicit key can be set using a &%key=value%& option.
33211
33212 If a &%readonly%& option is given then
33213 no record create or update is done.
33214 If a &%write%& option is given then
33215 a record create or update is always done.
33216 An update is done if the test is for &"since"&.
33217 If none of those hold and there was no existing record,
33218 a record is created.
33219
33220 Creates and updates are marked with the current time.
33221
33222 Finally, a &"before"& test which succeeds, and for which the record
33223 is old enough, will be refreshed with a timestamp of the test time.
33224 This can prevent tidying of the database from removing the entry.
33225 The interval for this is, by default, 10 days.
33226 An explicit interval can be set using a
33227 &%refresh=value%& option.
33228
33229 Note that &"seen"& should be added to the list of hints databases
33230 for maintenance if this ACL condition is used.
33231
33232
33233 .section "Rate limiting incoming messages" "SECTratelimiting"
33234 .cindex "rate limiting" "client sending"
33235 .cindex "limiting client sending rates"
33236 .oindex "&%smtp_ratelimit_*%&"
33237 The &%ratelimit%& ACL condition can be used to measure and control the rate at
33238 which clients can send email. This is more powerful than the
33239 &%smtp_ratelimit_*%& options, because those options control the rate of
33240 commands in a single SMTP session only, whereas the &%ratelimit%& condition
33241 works across all connections (concurrent and sequential) from the same client
33242 host. The syntax of the &%ratelimit%& condition is:
33243 .display
33244 &`ratelimit =`& <&'m'&> &`/`& <&'p'&> &`/`& <&'options'&> &`/`& <&'key'&>
33245 .endd
33246 If the average client sending rate is less than &'m'& messages per time
33247 period &'p'& then the condition is false; otherwise it is true.
33248
33249 As a side-effect, the &%ratelimit%& condition sets the expansion variable
33250 &$sender_rate$& to the client's computed rate, &$sender_rate_limit$& to the
33251 configured value of &'m'&, and &$sender_rate_period$& to the configured value
33252 of &'p'&.
33253
33254 The parameter &'p'& is the smoothing time constant, in the form of an Exim
33255 time interval, for example, &`8h`& for eight hours. A larger time constant
33256 means that it takes Exim longer to forget a client's past behaviour. The
33257 parameter &'m'& is the maximum number of messages that a client is permitted to
33258 send in each time interval. It also specifies the number of messages permitted
33259 in a fast burst. By increasing both &'m'& and &'p'& but keeping &'m/p'&
33260 constant, you can allow a client to send more messages in a burst without
33261 changing its long-term sending rate limit. Conversely, if &'m'& and &'p'& are
33262 both small, messages must be sent at an even rate.
33263
33264 There is a script in &_util/ratelimit.pl_& which extracts sending rates from
33265 log files, to assist with choosing appropriate settings for &'m'& and &'p'&
33266 when deploying the &%ratelimit%& ACL condition. The script prints usage
33267 instructions when it is run with no arguments.
33268
33269 The key is used to look up the data for calculating the client's average
33270 sending rate. This data is stored in Exim's spool directory, alongside the
33271 retry and other hints databases. The default key is &$sender_host_address$&,
33272 which means Exim computes the sending rate of each client host IP address.
33273 By changing the key you can change how Exim identifies clients for the purpose
33274 of ratelimiting. For example, to limit the sending rate of each authenticated
33275 user, independent of the computer they are sending from, set the key to
33276 &$authenticated_id$&. You must ensure that the lookup key is meaningful; for
33277 example, &$authenticated_id$& is only meaningful if the client has
33278 authenticated (which you can check with the &%authenticated%& ACL condition).
33279
33280 The lookup key does not have to identify clients: If you want to limit the
33281 rate at which a recipient receives messages, you can use the key
33282 &`$local_part@$domain`& with the &%per_rcpt%& option (see below) in a RCPT
33283 ACL.
33284
33285 Each &%ratelimit%& condition can have up to four options. A &%per_*%& option
33286 specifies what Exim measures the rate of, for example, messages or recipients
33287 or bytes. You can adjust the measurement using the &%unique=%& and/or
33288 &%count=%& options. You can also control when Exim updates the recorded rate
33289 using a &%strict%&, &%leaky%&, or &%readonly%& option. The options are
33290 separated by a slash, like the other parameters. They may appear in any order.
33291
33292 Internally, Exim appends the smoothing constant &'p'& onto the lookup key with
33293 any options that alter the meaning of the stored data. The limit &'m'& is not
33294 stored, so you can alter the configured maximum rate and Exim will still
33295 remember clients' past behaviour. If you change the &%per_*%& mode or add or
33296 remove the &%unique=%& option, the lookup key changes so Exim will forget past
33297 behaviour. The lookup key is not affected by changes to the update mode and
33298 the &%count=%& option.
33299
33300
33301 .subsection "Ratelimit options for what is being measured" ratoptmea
33302 .cindex "rate limiting" "per_* options"
33303 .vlist
33304 .vitem per_conn
33305 .cindex "rate limiting" per_conn
33306 This option limits the client's connection rate. It is not
33307 normally used in the &%acl_not_smtp%&, &%acl_not_smtp_mime%&, or
33308 &%acl_not_smtp_start%& ACLs.
33309
33310 .vitem per_mail
33311 .cindex "rate limiting" per_conn
33312 This option limits the client's rate of sending messages. This is
33313 the default if none of the &%per_*%& options is specified. It can be used in
33314 &%acl_smtp_mail%&, &%acl_smtp_rcpt%&, &%acl_smtp_predata%&, &%acl_smtp_mime%&,
33315 &%acl_smtp_data%&, or &%acl_not_smtp%&.
33316
33317 .vitem per_byte
33318 .cindex "rate limiting" per_conn
33319 This option limits the sender's email bandwidth. It can be used in
33320 the same ACLs as the &%per_mail%& option, though it is best to use this option
33321 in the &%acl_smtp_mime%&, &%acl_smtp_data%& or &%acl_not_smtp%& ACLs; if it is
33322 used in an earlier ACL, Exim relies on the SIZE parameter given by the client
33323 in its MAIL command, which may be inaccurate or completely missing. You can
33324 follow the limit &'m'& in the configuration with K, M, or G to specify limits
33325 in kilobytes, megabytes, or gigabytes, respectively.
33326
33327 .vitem per_rcpt
33328 .cindex "rate limiting" per_rcpt
33329 This option causes Exim to limit the rate at which recipients are
33330 accepted. It can be used in the &%acl_smtp_rcpt%&, &%acl_smtp_predata%&,
33331 &%acl_smtp_mime%&, or &%acl_smtp_data%& ACLs. In
33332 &%acl_smtp_rcpt%& the rate is updated one recipient at a time; in the other
33333 ACLs the rate is updated with the total (accepted) recipient count in one go. Note that
33334 in either case the rate limiting engine will see a message with many
33335 recipients as a large high-speed burst.
33336
33337 .vitem per_addr
33338 .cindex "rate limiting" per_addr
33339 This option is like the &%per_rcpt%& option, except it counts the
33340 number of different recipients that the client has sent messages to in the
33341 last time period. That is, if the client repeatedly sends messages to the same
33342 recipient, its measured rate is not increased. This option can only be used in
33343 &%acl_smtp_rcpt%&.
33344
33345 .vitem per_cmd
33346 .cindex "rate limiting" per_cmd
33347 This option causes Exim to recompute the rate every time the
33348 condition is processed. This can be used to limit the rate of any SMTP
33349 command. If it is used in multiple ACLs it can limit the aggregate rate of
33350 multiple different commands.
33351
33352 .vitem count
33353 .cindex "rate limiting" count
33354 This option can be used to alter how much Exim adds to the client's
33355 measured rate.
33356 A value is required, after an equals sign.
33357 For example, the &%per_byte%& option is equivalent to
33358 &`per_mail/count=$message_size`&.
33359 If there is no &%count=%& option, Exim
33360 increases the measured rate by one (except for the &%per_rcpt%& option in ACLs
33361 other than &%acl_smtp_rcpt%&).
33362 The count does not have to be an integer.
33363
33364 .vitem unique
33365 .cindex "rate limiting" unique
33366 This option is described in section &<<ratoptuniq>>& below.
33367 .endlist
33368
33369
33370 .subsection "Ratelimit update modes" ratoptupd
33371 .cindex "rate limiting" "reading data without updating"
33372 You can specify one of three options with the &%ratelimit%& condition to
33373 control when its database is updated. This section describes the &%readonly%&
33374 mode, and the next section describes the &%strict%& and &%leaky%& modes.
33375
33376 If the &%ratelimit%& condition is used in &%readonly%& mode, Exim looks up a
33377 previously-computed rate to check against the limit.
33378
33379 For example, you can test the client's sending rate and deny it access (when
33380 it is too fast) in the connect ACL. If the client passes this check then it
33381 can go on to send a message, in which case its recorded rate will be updated
33382 in the MAIL ACL. Subsequent connections from the same client will check this
33383 new rate.
33384 .code
33385 acl_check_connect:
33386  deny ratelimit = 100 / 5m / readonly
33387       log_message = RATE CHECK: $sender_rate/$sender_rate_period \
33388                   (max $sender_rate_limit)
33389 # ...
33390 acl_check_mail:
33391  warn ratelimit = 100 / 5m / strict
33392       log_message = RATE UPDATE: $sender_rate/$sender_rate_period \
33393                   (max $sender_rate_limit)
33394 .endd
33395
33396 If Exim encounters multiple &%ratelimit%& conditions with the same key when
33397 processing a message then it may increase the client's measured rate more than
33398 it should. For example, this will happen if you check the &%per_rcpt%& option
33399 in both &%acl_smtp_rcpt%& and &%acl_smtp_data%&. However it's OK to check the
33400 same &%ratelimit%& condition multiple times in the same ACL. You can avoid any
33401 multiple update problems by using the &%readonly%& option on later ratelimit
33402 checks.
33403
33404 The &%per_*%& options described above do not make sense in some ACLs. If you
33405 use a &%per_*%& option in an ACL where it is not normally permitted then the
33406 update mode defaults to &%readonly%& and you cannot specify the &%strict%& or
33407 &%leaky%& modes. In other ACLs the default update mode is &%leaky%& (see the
33408 next section) so you must specify the &%readonly%& option explicitly.
33409
33410
33411 .subsection "Ratelimit options for handling fast clients" ratoptfast
33412 .cindex "rate limiting" "strict and leaky modes"
33413 If a client's average rate is greater than the maximum, the rate limiting
33414 engine can react in two possible ways, depending on the presence of the
33415 &%strict%& or &%leaky%& update modes. This is independent of the other
33416 counter-measures (such as rejecting the message) that may be specified by the
33417 rest of the ACL.
33418
33419 The &%leaky%& (default) option means that the client's recorded rate is not
33420 updated if it is above the limit. The effect of this is that Exim measures the
33421 client's average rate of successfully sent email,
33422 up to the given limit.
33423 This is appropriate if the countermeasure when the condition is true
33424 consists of refusing the message, and
33425 is generally the better choice if you have clients that retry automatically.
33426 If the action when true is anything more complex then this option is
33427 likely not what is wanted.
33428
33429 The &%strict%& option means that the client's recorded rate is always
33430 updated. The effect of this is that Exim measures the client's average rate
33431 of attempts to send email, which can be much higher than the maximum it is
33432 actually allowed. If the client is over the limit it may be subjected to
33433 counter-measures by the ACL. It must slow down and allow sufficient time to
33434 pass that its computed rate falls below the maximum before it can send email
33435 again. The time (the number of smoothing periods) it must wait and not
33436 attempt to send mail can be calculated with this formula:
33437 .code
33438         ln(peakrate/maxrate)
33439 .endd
33440
33441
33442 .subsection "Limiting the rate of different events" ratoptuniq
33443 .cindex "rate limiting" "counting unique events"
33444 The &%ratelimit%& &%unique=%& option controls a mechanism for counting the
33445 rate of different events. For example, the &%per_addr%& option uses this
33446 mechanism to count the number of different recipients that the client has
33447 sent messages to in the last time period; it is equivalent to
33448 &`per_rcpt/unique=$local_part@$domain`&. You could use this feature to
33449 measure the rate that a client uses different sender addresses with the
33450 options &`per_mail/unique=$sender_address`&.
33451
33452 For each &%ratelimit%& key Exim stores the set of &%unique=%& values that it
33453 has seen for that key. The whole set is thrown away when it is older than the
33454 rate smoothing period &'p'&, so each different event is counted at most once
33455 per period. In the &%leaky%& update mode, an event that causes the client to
33456 go over the limit is not added to the set, in the same way that the client's
33457 recorded rate is not updated in the same situation.
33458
33459 When you combine the &%unique=%& and &%readonly%& options, the specific
33460 &%unique=%& value is ignored, and Exim just retrieves the client's stored
33461 rate.
33462
33463 The &%unique=%& mechanism needs more space in the ratelimit database than the
33464 other &%ratelimit%& options in order to store the event set. The number of
33465 unique values is potentially as large as the rate limit, so the extra space
33466 required increases with larger limits.
33467
33468 The uniqueification is not perfect: there is a small probability that Exim
33469 will think a new event has happened before. If the sender's rate is less than
33470 the limit, Exim should be more than 99.9% correct. However in &%strict%& mode
33471 the measured rate can go above the limit, in which case Exim may under-count
33472 events by a significant margin. Fortunately, if the rate is high enough (2.7
33473 times the limit) that the false positive rate goes above 9%, then Exim will
33474 throw away the over-full event set before the measured rate falls below the
33475 limit. Therefore the only harm should be that exceptionally high sending rates
33476 are logged incorrectly; any countermeasures you configure will be as effective
33477 as intended.
33478
33479
33480 .subsection "Using rate limiting" useratlim
33481 Exim's other ACL facilities are used to define what counter-measures are taken
33482 when the rate limit is exceeded. This might be anything from logging a warning
33483 (for example, while measuring existing sending rates in order to define
33484 policy), through time delays to slow down fast senders, up to rejecting the
33485 message. For example:
33486 .code
33487 # Log all senders' rates
33488 warn ratelimit = 0 / 1h / strict
33489      log_message = Sender rate $sender_rate / $sender_rate_period
33490
33491 # Slow down fast senders; note the need to truncate $sender_rate
33492 # at the decimal point.
33493 warn ratelimit = 100 / 1h / per_rcpt / strict
33494      delay     = ${eval: ${sg{$sender_rate}{[.].*}{}} - \
33495                    $sender_rate_limit }s
33496
33497 # Keep authenticated users under control
33498 deny authenticated = *
33499      ratelimit = 100 / 1d / strict / $authenticated_id
33500
33501 # System-wide rate limit
33502 defer ratelimit = 10 / 1s / $primary_hostname
33503       message = Sorry, too busy. Try again later.
33504
33505 # Restrict incoming rate from each host, with a default
33506 # set using a macro and special cases looked up in a table.
33507 defer ratelimit = ${lookup {$sender_host_address} \
33508                    cdb {DB/ratelimits.cdb} \
33509                    {$value} {RATELIMIT} }
33510       message = Sender rate exceeds $sender_rate_limit \
33511                messages per $sender_rate_period
33512 .endd
33513 &*Warning*&: If you have a busy server with a lot of &%ratelimit%& tests,
33514 especially with the &%per_rcpt%& option, you may suffer from a performance
33515 bottleneck caused by locking on the ratelimit hints database. Apart from
33516 making your ACLs less complicated, you can reduce the problem by using a
33517 RAM disk for Exim's hints directory (usually &_/var/spool/exim/db/_&). However
33518 this means that Exim will lose its hints data after a reboot (including retry
33519 hints, the callout cache, and ratelimit data).
33520
33521
33522
33523 .section "Address verification" "SECTaddressverification"
33524 .cindex "verifying address" "options for"
33525 .cindex "policy control" "address verification"
33526 Several of the &%verify%& conditions described in section
33527 &<<SECTaclconditions>>& cause addresses to be verified. Section
33528 &<<SECTsenaddver>>& discusses the reporting of sender verification failures.
33529 The verification conditions can be followed by options that modify the
33530 verification process. The options are separated from the keyword and from each
33531 other by slashes, and some of them contain parameters. For example:
33532 .code
33533 verify = sender/callout
33534 verify = recipient/defer_ok/callout=10s,defer_ok
33535 .endd
33536 The first stage of address verification, which always happens, is to run the
33537 address through the routers, in &"verify mode"&. Routers can detect the
33538 difference between verification and routing for delivery, and their actions can
33539 be varied by a number of generic options such as &%verify%& and &%verify_only%&
33540 (see chapter &<<CHAProutergeneric>>&). If routing fails, verification fails.
33541 The available options are as follows:
33542
33543 .ilist
33544 If the &%callout%& option is specified, successful routing to one or more
33545 remote hosts is followed by a &"callout"& to those hosts as an additional
33546 check. Callouts and their sub-options are discussed in the next section.
33547 .next
33548 If there is a defer error while doing verification routing, the ACL
33549 normally returns &"defer"&. However, if you include &%defer_ok%& in the
33550 options, the condition is forced to be true instead. Note that this is a main
33551 verification option as well as a suboption for callouts.
33552 .next
33553 The &%no_details%& option is covered in section &<<SECTsenaddver>>&, which
33554 discusses the reporting of sender address verification failures.
33555 .next
33556 The &%success_on_redirect%& option causes verification always to succeed
33557 immediately after a successful redirection. By default, if a redirection
33558 generates just one address, that address is also verified. See further
33559 discussion in section &<<SECTredirwhilveri>>&.
33560 .next
33561 If the &%quota%& option is specified for recipient verify,
33562 successful routing to an appendfile transport is followed by a call into
33563 the transport to evaluate the quota status for the recipient.
33564 No actual delivery is done, but verification will succeed if the quota
33565 is sufficient for the message (if the sender gave a message size) or
33566 not already exceeded (otherwise).
33567 .endlist
33568
33569 .cindex "verifying address" "differentiating failures"
33570 .vindex "&$recipient_verify_failure$&"
33571 .vindex "&$sender_verify_failure$&"
33572 .vindex "&$acl_verify_message$&"
33573 After an address verification failure, &$acl_verify_message$& contains the
33574 error message that is associated with the failure. It can be preserved by
33575 coding like this:
33576 .code
33577 warn  !verify = sender
33578        set acl_m0 = $acl_verify_message
33579 .endd
33580 If you are writing your own custom rejection message or log message when
33581 denying access, you can use this variable to include information about the
33582 verification failure.
33583 This variable is cleared at the end of processing the ACL verb.
33584
33585 In addition, &$sender_verify_failure$& or &$recipient_verify_failure$& (as
33586 appropriate) contains one of the following words:
33587
33588 .ilist
33589 &%qualify%&: The address was unqualified (no domain), and the message
33590 was neither local nor came from an exempted host.
33591 .next
33592 &%route%&: Routing failed.
33593 .next
33594 &%mail%&: Routing succeeded, and a callout was attempted; rejection
33595 occurred at or before the MAIL command (that is, on initial
33596 connection, HELO, or MAIL).
33597 .next
33598 &%recipient%&: The RCPT command in a callout was rejected.
33599 .next
33600 &%postmaster%&: The postmaster check in a callout was rejected.
33601 .next
33602 &%quota%&: The quota check for a local recipient did non pass.
33603 .endlist
33604
33605 The main use of these variables is expected to be to distinguish between
33606 rejections of MAIL and rejections of RCPT in callouts.
33607
33608 The above variables may also be set after a &*successful*&
33609 address verification to:
33610
33611 .ilist
33612 &%random%&: A random local-part callout succeeded
33613 .endlist
33614
33615
33616
33617
33618 .section "Callout verification" "SECTcallver"
33619 .cindex "verifying address" "by callout"
33620 .cindex "callout" "verification"
33621 .cindex "SMTP" "callout verification"
33622 For non-local addresses, routing verifies the domain, but is unable to do any
33623 checking of the local part. There are situations where some means of verifying
33624 the local part is desirable. One way this can be done is to make an SMTP
33625 &'callback'& to a delivery host for the sender address or a &'callforward'& to
33626 a subsequent host for a recipient address, to see if the host accepts the
33627 address. We use the term &'callout'& to cover both cases. Note that for a
33628 sender address, the callback is not to the client host that is trying to
33629 deliver the message, but to one of the hosts that accepts incoming mail for the
33630 sender's domain.
33631
33632 Exim does not do callouts by default. If you want them to happen, you must
33633 request them by setting appropriate options on the &%verify%& condition, as
33634 described below. This facility should be used with care, because it can add a
33635 lot of resource usage to the cost of verifying an address. However, Exim does
33636 cache the results of callouts, which helps to reduce the cost. Details of
33637 caching are in section &<<SECTcallvercache>>&.
33638
33639 Recipient callouts are usually used only between hosts that are controlled by
33640 the same administration. For example, a corporate gateway host could use
33641 callouts to check for valid recipients on an internal mailserver. A successful
33642 callout does not guarantee that a real delivery to the address would succeed;
33643 on the other hand, a failing callout does guarantee that a delivery would fail.
33644
33645 If the &%callout%& option is present on a condition that verifies an address, a
33646 second stage of verification occurs if the address is successfully routed to
33647 one or more remote hosts. The usual case is routing by a &(dnslookup)& or a
33648 &(manualroute)& router, where the router specifies the hosts. However, if a
33649 router that does not set up hosts routes to an &(smtp)& transport with a
33650 &%hosts%& setting, the transport's hosts are used. If an &(smtp)& transport has
33651 &%hosts_override%& set, its hosts are always used, whether or not the router
33652 supplies a host list.
33653 Callouts are only supported on &(smtp)& transports.
33654
33655 The port that is used is taken from the transport, if it is specified and is a
33656 remote transport. (For routers that do verification only, no transport need be
33657 specified.) Otherwise, the default SMTP port is used. If a remote transport
33658 specifies an outgoing interface, this is used; otherwise the interface is not
33659 specified. Likewise, the text that is used for the HELO command is taken from
33660 the transport's &%helo_data%& option; if there is no transport, the value of
33661 &$smtp_active_hostname$& is used.
33662
33663 For a sender callout check, Exim makes SMTP connections to the remote hosts, to
33664 test whether a bounce message could be delivered to the sender address. The
33665 following SMTP commands are sent:
33666 .display
33667 &`HELO `&<&'local host name'&>
33668 &`MAIL FROM:<>`&
33669 &`RCPT TO:`&<&'the address to be tested'&>
33670 &`QUIT`&
33671 .endd
33672 LHLO is used instead of HELO if the transport's &%protocol%& option is
33673 set to &"lmtp"&.
33674
33675 The callout may use EHLO, AUTH and/or STARTTLS given appropriate option
33676 settings.
33677
33678 A recipient callout check is similar. By default, it also uses an empty address
33679 for the sender. This default is chosen because most hosts do not make use of
33680 the sender address when verifying a recipient. Using the same address means
33681 that a single cache entry can be used for each recipient. Some sites, however,
33682 do make use of the sender address when verifying. These are catered for by the
33683 &%use_sender%& and &%use_postmaster%& options, described in the next section.
33684
33685 If the response to the RCPT command is a 2&'xx'& code, the verification
33686 succeeds. If it is 5&'xx'&, the verification fails. For any other condition,
33687 Exim tries the next host, if any. If there is a problem with all the remote
33688 hosts, the ACL yields &"defer"&, unless the &%defer_ok%& parameter of the
33689 &%callout%& option is given, in which case the condition is forced to succeed.
33690
33691 .cindex "SMTP" "output flushing, disabling for callout"
33692 A callout may take a little time. For this reason, Exim normally flushes SMTP
33693 output before performing a callout in an ACL, to avoid unexpected timeouts in
33694 clients when the SMTP PIPELINING extension is in use. The flushing can be
33695 disabled by using a &%control%& modifier to set &%no_callout_flush%&.
33696
33697 .cindex "tainted data" "de-tainting"
33698 .cindex "de-tainting" "using recipient verify"
33699 A recipient callout which gets a 2&'xx'& code
33700 will assign untainted values to the
33701 &$domain_data$& and &$local_part_data$& variables,
33702 corresponding to the domain and local parts of the recipient address.
33703
33704
33705
33706
33707 .subsection "Additional parameters for callouts" CALLaddparcall
33708 .cindex "callout" "additional parameters for"
33709 The &%callout%& option can be followed by an equals sign and a number of
33710 optional parameters, separated by commas. For example:
33711 .code
33712 verify = recipient/callout=10s,defer_ok
33713 .endd
33714 The old syntax, which had &%callout_defer_ok%& and &%check_postmaster%& as
33715 separate verify options, is retained for backwards compatibility, but is now
33716 deprecated. The additional parameters for &%callout%& are as follows:
33717
33718
33719 .vlist
33720 .vitem <&'a&~time&~interval'&>
33721 .cindex "callout" "timeout, specifying"
33722 This specifies the timeout that applies for the callout attempt to each host.
33723 For example:
33724 .code
33725 verify = sender/callout=5s
33726 .endd
33727 The default is 30 seconds. The timeout is used for each response from the
33728 remote host. It is also used for the initial connection, unless overridden by
33729 the &%connect%& parameter.
33730
33731
33732 .vitem &*connect&~=&~*&<&'time&~interval'&>
33733 .cindex "callout" "connection timeout, specifying"
33734 This parameter makes it possible to set a different (usually smaller) timeout
33735 for making the SMTP connection. For example:
33736 .code
33737 verify = sender/callout=5s,connect=1s
33738 .endd
33739 If not specified, this timeout defaults to the general timeout value.
33740
33741 .vitem &*defer_ok*&
33742 .cindex "callout" "defer, action on"
33743 When this parameter is present, failure to contact any host, or any other kind
33744 of temporary error, is treated as success by the ACL. However, the cache is not
33745 updated in this circumstance.
33746
33747 .vitem &*fullpostmaster*&
33748 .cindex "callout" "full postmaster check"
33749 This operates like the &%postmaster%& option (see below), but if the check for
33750 &'postmaster@domain'& fails, it tries just &'postmaster'&, without a domain, in
33751 accordance with the specification in RFC 2821. The RFC states that the
33752 unqualified address &'postmaster'& should be accepted.
33753
33754
33755 .vitem &*mailfrom&~=&~*&<&'email&~address'&>
33756 .cindex "callout" "sender when verifying header"
33757 When verifying addresses in header lines using the &%header_sender%&
33758 verification option, Exim behaves by default as if the addresses are envelope
33759 sender addresses from a message. Callout verification therefore tests to see
33760 whether a bounce message could be delivered, by using an empty address in the
33761 MAIL command. However, it is arguable that these addresses might never be used
33762 as envelope senders, and could therefore justifiably reject bounce messages
33763 (empty senders). The &%mailfrom%& callout parameter allows you to specify what
33764 address to use in the MAIL command. For example:
33765 .code
33766 require  verify = header_sender/callout=mailfrom=abcd@x.y.z
33767 .endd
33768 This parameter is available only for the &%header_sender%& verification option.
33769
33770
33771 .vitem &*maxwait&~=&~*&<&'time&~interval'&>
33772 .cindex "callout" "overall timeout, specifying"
33773 This parameter sets an overall timeout for performing a callout verification.
33774 For example:
33775 .code
33776 verify = sender/callout=5s,maxwait=30s
33777 .endd
33778 This timeout defaults to four times the callout timeout for individual SMTP
33779 commands. The overall timeout applies when there is more than one host that can
33780 be tried. The timeout is checked before trying the next host. This prevents
33781 very long delays if there are a large number of hosts and all are timing out
33782 (for example, when network connections are timing out).
33783
33784
33785 .vitem &*no_cache*&
33786 .cindex "callout" "cache, suppressing"
33787 .cindex "caching callout, suppressing"
33788 When this parameter is given, the callout cache is neither read nor updated.
33789
33790 .vitem &*postmaster*&
33791 .cindex "callout" "postmaster; checking"
33792 When this parameter is set, a successful callout check is followed by a similar
33793 check for the local part &'postmaster'& at the same domain. If this address is
33794 rejected, the callout fails (but see &%fullpostmaster%& above). The result of
33795 the postmaster check is recorded in a cache record; if it is a failure, this is
33796 used to fail subsequent callouts for the domain without a connection being
33797 made, until the cache record expires.
33798
33799 .vitem &*postmaster_mailfrom&~=&~*&<&'email&~address'&>
33800 The postmaster check uses an empty sender in the MAIL command by default.
33801 You can use this parameter to do a postmaster check using a different address.
33802 For example:
33803 .code
33804 require  verify = sender/callout=postmaster_mailfrom=abc@x.y.z
33805 .endd
33806 If both &%postmaster%& and &%postmaster_mailfrom%& are present, the rightmost
33807 one overrides. The &%postmaster%& parameter is equivalent to this example:
33808 .code
33809 require  verify = sender/callout=postmaster_mailfrom=
33810 .endd
33811 &*Warning*&: The caching arrangements for postmaster checking do not take
33812 account of the sender address. It is assumed that either the empty address or
33813 a fixed non-empty address will be used. All that Exim remembers is that the
33814 postmaster check for the domain succeeded or failed.
33815
33816
33817 .vitem &*random*&
33818 .cindex "callout" "&""random""& check"
33819 When this parameter is set, before doing the normal callout check, Exim does a
33820 check for a &"random"& local part at the same domain. The local part is not
33821 really random &-- it is defined by the expansion of the option
33822 &%callout_random_local_part%&, which defaults to
33823 .code
33824 $primary_hostname-$tod_epoch-testing
33825 .endd
33826 The idea here is to try to determine whether the remote host accepts all local
33827 parts without checking. If it does, there is no point in doing callouts for
33828 specific local parts. If the &"random"& check succeeds, the result is saved in
33829 a cache record, and used to force the current and subsequent callout checks to
33830 succeed without a connection being made, until the cache record expires.
33831
33832 .vitem &*use_postmaster*&
33833 .cindex "callout" "sender for recipient check"
33834 This parameter applies to recipient callouts only. For example:
33835 .code
33836 deny  !verify = recipient/callout=use_postmaster
33837 .endd
33838 .vindex "&$qualify_domain$&"
33839 It causes a non-empty postmaster address to be used in the MAIL command when
33840 performing the callout for the recipient, and also for a &"random"& check if
33841 that is configured. The local part of the address is &`postmaster`& and the
33842 domain is the contents of &$qualify_domain$&.
33843
33844 .vitem &*use_sender*&
33845 This option applies to recipient callouts only. For example:
33846 .code
33847 require  verify = recipient/callout=use_sender
33848 .endd
33849 It causes the message's actual sender address to be used in the MAIL
33850 command when performing the callout, instead of an empty address. There is no
33851 need to use this option unless you know that the called hosts make use of the
33852 sender when checking recipients. If used indiscriminately, it reduces the
33853 usefulness of callout caching.
33854
33855 .vitem &*hold*&
33856 This option applies to recipient callouts only. For example:
33857 .code
33858 require  verify = recipient/callout=use_sender,hold
33859 .endd
33860 It causes the connection to be held open and used for any further recipients
33861 and for eventual delivery (should that be done quickly).
33862 Doing this saves on TCP and SMTP startup costs, and TLS costs also
33863 when that is used for the connections.
33864 The advantage is only gained if there are no callout cache hits
33865 (which could be enforced by the no_cache option),
33866 if the use_sender option is used,
33867 if neither the random nor the use_postmaster option is used,
33868 and if no other callouts intervene.
33869 .endlist
33870
33871 If you use any of the parameters that set a non-empty sender for the MAIL
33872 command (&%mailfrom%&, &%postmaster_mailfrom%&, &%use_postmaster%&, or
33873 &%use_sender%&), you should think about possible loops. Recipient checking is
33874 usually done between two hosts that are under the same management, and the host
33875 that receives the callouts is not normally configured to do callouts itself.
33876 Therefore, it is normally safe to use &%use_postmaster%& or &%use_sender%& in
33877 these circumstances.
33878
33879 However, if you use a non-empty sender address for a callout to an arbitrary
33880 host, there is the likelihood that the remote host will itself initiate a
33881 callout check back to your host. As it is checking what appears to be a message
33882 sender, it is likely to use an empty address in MAIL, thus avoiding a
33883 callout loop. However, to be on the safe side it would be best to set up your
33884 own ACLs so that they do not do sender verification checks when the recipient
33885 is the address you use for header sender or postmaster callout checking.
33886
33887 Another issue to think about when using non-empty senders for callouts is
33888 caching. When you set &%mailfrom%& or &%use_sender%&, the cache record is keyed
33889 by the sender/recipient combination; thus, for any given recipient, many more
33890 actual callouts are performed than when an empty sender or postmaster is used.
33891
33892
33893
33894
33895 .subsection "Callout caching" SECTcallvercache
33896 .cindex "hints database" "callout cache"
33897 .cindex "callout" "cache, description of"
33898 .cindex "caching" "callout"
33899 Exim caches the results of callouts in order to reduce the amount of resources
33900 used, unless you specify the &%no_cache%& parameter with the &%callout%&
33901 option. A hints database called &"callout"& is used for the cache. Two
33902 different record types are used: one records the result of a callout check for
33903 a specific address, and the other records information that applies to the
33904 entire domain (for example, that it accepts the local part &'postmaster'&).
33905
33906 When an original callout fails, a detailed SMTP error message is given about
33907 the failure. However, for subsequent failures that use the cache data, this message
33908 is not available.
33909
33910 The expiry times for negative and positive address cache records are
33911 independent, and can be set by the global options &%callout_negative_expire%&
33912 (default 2h) and &%callout_positive_expire%& (default 24h), respectively.
33913
33914 If a host gives a negative response to an SMTP connection, or rejects any
33915 commands up to and including
33916 .code
33917 MAIL FROM:<>
33918 .endd
33919 (but not including the MAIL command with a non-empty address),
33920 any callout attempt is bound to fail. Exim remembers such failures in a
33921 domain cache record, which it uses to fail callouts for the domain without
33922 making new connections, until the domain record times out. There are two
33923 separate expiry times for domain cache records:
33924 &%callout_domain_negative_expire%& (default 3h) and
33925 &%callout_domain_positive_expire%& (default 7d).
33926
33927 Domain records expire when the negative expiry time is reached if callouts
33928 cannot be made for the domain, or if the postmaster check failed.
33929 Otherwise, they expire when the positive expiry time is reached. This
33930 ensures that, for example, a host that stops accepting &"random"& local parts
33931 will eventually be noticed.
33932
33933 The callout caching mechanism is based on the domain of the address that is
33934 being tested. If the domain routes to several hosts, it is assumed that their
33935 behaviour will be the same.
33936
33937
33938
33939 .section "Quota caching" "SECTquotacache"
33940 .cindex "hints database" "quota cache"
33941 .cindex "quota" "cache, description of"
33942 .cindex "caching" "quota"
33943 Exim caches the results of quota verification
33944 in order to reduce the amount of resources used.
33945 The &"callout"& hints database is used.
33946
33947 The default cache periods are five minutes for a positive (good) result
33948 and one hour for a negative result.
33949 To change the periods the &%quota%& option can be followed by an equals sign
33950 and a number of optional paramemters, separated by commas.
33951 For example:
33952 .code
33953 verify = recipient/quota=cachepos=1h,cacheneg=1d
33954 .endd
33955 Possible parameters are:
33956 .vlist
33957 .vitem &*cachepos&~=&~*&<&'time&~interval'&>
33958 .cindex "quota cache" "positive entry expiry, specifying"
33959 Set the lifetime for a positive cache entry.
33960 A value of zero seconds is legitimate.
33961
33962 .vitem &*cacheneg&~=&~*&<&'time&~interval'&>
33963 .cindex "quota cache" "negative entry expiry, specifying"
33964 As above, for a negative entry.
33965
33966 .vitem &*no_cache*&
33967 Set both positive and negative lifetimes to zero.
33968
33969 .section "Sender address verification reporting" "SECTsenaddver"
33970 .cindex "verifying" "suppressing error details"
33971 See section &<<SECTaddressverification>>& for a general discussion of
33972 verification. When sender verification fails in an ACL, the details of the
33973 failure are given as additional output lines before the 550 response to the
33974 relevant SMTP command (RCPT or DATA). For example, if sender callout is in use,
33975 you might see:
33976 .code
33977 MAIL FROM:<xyz@abc.example>
33978 250 OK
33979 RCPT TO:<pqr@def.example>
33980 550-Verification failed for <xyz@abc.example>
33981 550-Called:   192.168.34.43
33982 550-Sent:     RCPT TO:<xyz@abc.example>
33983 550-Response: 550 Unknown local part xyz in <xyz@abc.example>
33984 550 Sender verification failed
33985 .endd
33986 If more than one RCPT command fails in the same way, the details are given
33987 only for the first of them. However, some administrators do not want to send
33988 out this much information. You can suppress the details by adding
33989 &`/no_details`& to the ACL statement that requests sender verification. For
33990 example:
33991 .code
33992 verify = sender/no_details
33993 .endd
33994
33995 .section "Redirection while verifying" "SECTredirwhilveri"
33996 .cindex "verifying" "redirection while"
33997 .cindex "address redirection" "while verifying"
33998 A dilemma arises when a local address is redirected by aliasing or forwarding
33999 during verification: should the generated addresses themselves be verified,
34000 or should the successful expansion of the original address be enough to verify
34001 it? By default, Exim takes the following pragmatic approach:
34002
34003 .ilist
34004 When an incoming address is redirected to just one child address, verification
34005 continues with the child address, and if that fails to verify, the original
34006 verification also fails.
34007 .next
34008 When an incoming address is redirected to more than one child address,
34009 verification does not continue. A success result is returned.
34010 .endlist
34011
34012 This seems the most reasonable behaviour for the common use of aliasing as a
34013 way of redirecting different local parts to the same mailbox. It means, for
34014 example, that a pair of alias entries of the form
34015 .code
34016 A.Wol:   aw123
34017 aw123:   :fail: Gone away, no forwarding address
34018 .endd
34019 work as expected, with both local parts causing verification failure. When a
34020 redirection generates more than one address, the behaviour is more like a
34021 mailing list, where the existence of the alias itself is sufficient for
34022 verification to succeed.
34023
34024 It is possible, however, to change the default behaviour so that all successful
34025 redirections count as successful verifications, however many new addresses are
34026 generated. This is specified by the &%success_on_redirect%& verification
34027 option. For example:
34028 .code
34029 require verify = recipient/success_on_redirect/callout=10s
34030 .endd
34031 In this example, verification succeeds if a router generates a new address, and
34032 the callout does not occur, because no address was routed to a remote host.
34033
34034 When verification is being tested via the &%-bv%& option, the treatment of
34035 redirections is as just described, unless the &%-v%& or any debugging option is
34036 also specified. In that case, full verification is done for every generated
34037 address and a report is output for each of them.
34038
34039
34040
34041 .section "Client SMTP authorization (CSA)" "SECTverifyCSA"
34042 .cindex "CSA" "verifying"
34043 Client SMTP Authorization is a system that allows a site to advertise
34044 which machines are and are not permitted to send email. This is done by placing
34045 special SRV records in the DNS; these are looked up using the client's HELO
34046 domain. At the time of writing, CSA is still an Internet Draft. Client SMTP
34047 Authorization checks in Exim are performed by the ACL condition:
34048 .code
34049 verify = csa
34050 .endd
34051 This fails if the client is not authorized. If there is a DNS problem, or if no
34052 valid CSA SRV record is found, or if the client is authorized, the condition
34053 succeeds. These three cases can be distinguished using the expansion variable
34054 &$csa_status$&, which can take one of the values &"fail"&, &"defer"&,
34055 &"unknown"&, or &"ok"&. The condition does not itself defer because that would
34056 be likely to cause problems for legitimate email.
34057
34058 The error messages produced by the CSA code include slightly more
34059 detail. If &$csa_status$& is &"defer"&, this may be because of problems
34060 looking up the CSA SRV record, or problems looking up the CSA target
34061 address record. There are four reasons for &$csa_status$& being &"fail"&:
34062
34063 .ilist
34064 The client's host name is explicitly not authorized.
34065 .next
34066 The client's IP address does not match any of the CSA target IP addresses.
34067 .next
34068 The client's host name is authorized but it has no valid target IP addresses
34069 (for example, the target's addresses are IPv6 and the client is using IPv4).
34070 .next
34071 The client's host name has no CSA SRV record but a parent domain has asserted
34072 that all subdomains must be explicitly authorized.
34073 .endlist
34074
34075 The &%csa%& verification condition can take an argument which is the domain to
34076 use for the DNS query. The default is:
34077 .code
34078 verify = csa/$sender_helo_name
34079 .endd
34080 This implementation includes an extension to CSA. If the query domain
34081 is an address literal such as [192.0.2.95], or if it is a bare IP
34082 address, Exim searches for CSA SRV records in the reverse DNS as if
34083 the HELO domain was (for example) &'95.2.0.192.in-addr.arpa'&. Therefore it is
34084 meaningful to say:
34085 .code
34086 verify = csa/$sender_host_address
34087 .endd
34088 In fact, this is the check that Exim performs if the client does not say HELO.
34089 This extension can be turned off by setting the main configuration option
34090 &%dns_csa_use_reverse%& to be false.
34091
34092 If a CSA SRV record is not found for the domain itself, a search
34093 is performed through its parent domains for a record which might be
34094 making assertions about subdomains. The maximum depth of this search is limited
34095 using the main configuration option &%dns_csa_search_limit%&, which is 5 by
34096 default. Exim does not look for CSA SRV records in a top level domain, so the
34097 default settings handle HELO domains as long as seven
34098 (&'hostname.five.four.three.two.one.com'&). This encompasses the vast majority
34099 of legitimate HELO domains.
34100
34101 The &'dnsdb'& lookup also has support for CSA. Although &'dnsdb'& also supports
34102 direct SRV lookups, this is not sufficient because of the extra parent domain
34103 search behaviour of CSA, and (as with PTR lookups) &'dnsdb'& also turns IP
34104 addresses into lookups in the reverse DNS space. The result of a successful
34105 lookup such as:
34106 .code
34107 ${lookup dnsdb {csa=$sender_helo_name}}
34108 .endd
34109 has two space-separated fields: an authorization code and a target host name.
34110 The authorization code can be &"Y"& for yes, &"N"& for no, &"X"& for explicit
34111 authorization required but absent, or &"?"& for unknown.
34112
34113
34114
34115
34116 .section "Bounce address tag validation" "SECTverifyPRVS"
34117 .cindex "BATV, verifying"
34118 Bounce address tag validation (BATV) is a scheme whereby the envelope senders
34119 of outgoing messages have a cryptographic, timestamped &"tag"& added to them.
34120 Genuine incoming bounce messages should therefore always be addressed to
34121 recipients that have a valid tag. This scheme is a way of detecting unwanted
34122 bounce messages caused by sender address forgeries (often called &"collateral
34123 spam"&), because the recipients of such messages do not include valid tags.
34124
34125 There are two expansion items to help with the implementation of the BATV
34126 &"prvs"& (private signature) scheme in an Exim configuration. This scheme signs
34127 the original envelope sender address by using a simple key to add a hash of the
34128 address and some time-based randomizing information. The &%prvs%& expansion
34129 item creates a signed address, and the &%prvscheck%& expansion item checks one.
34130 The syntax of these expansion items is described in section
34131 &<<SECTexpansionitems>>&.
34132 The validity period on signed addresses is seven days.
34133
34134 As an example, suppose the secret per-address keys are stored in an MySQL
34135 database. A query to look up the key for an address could be defined as a macro
34136 like this:
34137 .code
34138 PRVSCHECK_SQL = ${lookup mysql{SELECT secret FROM batv_prvs \
34139                 WHERE sender='${quote_mysql:$prvscheck_address}'\
34140                 }{$value}}
34141 .endd
34142 Suppose also that the senders who make use of BATV are defined by an address
34143 list called &%batv_senders%&. Then, in the ACL for RCPT commands, you could
34144 use this:
34145 .code
34146 # Bounces: drop unsigned addresses for BATV senders
34147 deny senders = :
34148      recipients = +batv_senders
34149      message = This address does not send an unsigned reverse path
34150
34151 # Bounces: In case of prvs-signed address, check signature.
34152 deny senders = :
34153      condition  = ${prvscheck {$local_part@$domain}\
34154                   {PRVSCHECK_SQL}{1}}
34155      !condition = $prvscheck_result
34156      message = Invalid reverse path signature.
34157 .endd
34158 The first statement rejects recipients for bounce messages that are addressed
34159 to plain BATV sender addresses, because it is known that BATV senders do not
34160 send out messages with plain sender addresses. The second statement rejects
34161 recipients that are prvs-signed, but with invalid signatures (either because
34162 the key is wrong, or the signature has timed out).
34163
34164 A non-prvs-signed address is not rejected by the second statement, because the
34165 &%prvscheck%& expansion yields an empty string if its first argument is not a
34166 prvs-signed address, thus causing the &%condition%& condition to be false. If
34167 the first argument is a syntactically valid prvs-signed address, the yield is
34168 the third string (in this case &"1"&), whether or not the cryptographic and
34169 timeout checks succeed. The &$prvscheck_result$& variable contains the result
34170 of the checks (empty for failure, &"1"& for success).
34171
34172 There is one more issue you must consider when implementing prvs-signing:
34173 you have to ensure that the routers accept prvs-signed addresses and
34174 deliver them correctly. The easiest way to handle this is to use a &(redirect)&
34175 router to remove the signature with a configuration along these lines:
34176 .code
34177 batv_redirect:
34178   driver = redirect
34179   data = ${prvscheck {$local_part@$domain}{PRVSCHECK_SQL}}
34180 .endd
34181 This works because, if the third argument of &%prvscheck%& is empty, the result
34182 of the expansion of a prvs-signed address is the decoded value of the original
34183 address. This router should probably be the first of your routers that handles
34184 local addresses.
34185
34186 To create BATV-signed addresses in the first place, a transport of this form
34187 can be used:
34188 .code
34189 external_smtp_batv:
34190   driver = smtp
34191   return_path = ${prvs {$return_path} \
34192                        {${lookup mysql{SELECT \
34193                        secret FROM batv_prvs WHERE \
34194                        sender='${quote_mysql:$sender_address}'} \
34195                        {$value}fail}}}
34196 .endd
34197 If no key can be found for the existing return path, no signing takes place.
34198
34199
34200
34201 .section "Using an ACL to control relaying" "SECTrelaycontrol"
34202 .cindex "&ACL;" "relay control"
34203 .cindex "relaying" "control by ACL"
34204 .cindex "policy control" "relay control"
34205 An MTA is said to &'relay'& a message if it receives it from some host and
34206 delivers it directly to another host as a result of a remote address contained
34207 within it. Redirecting a local address via an alias or forward file and then
34208 passing the message on to another host is not relaying,
34209 .cindex "&""percent hack""&"
34210 but a redirection as a result of the &"percent hack"& is.
34211
34212 Two kinds of relaying exist, which are termed &"incoming"& and &"outgoing"&.
34213 A host which is acting as a gateway or an MX backup is concerned with incoming
34214 relaying from arbitrary hosts to a specific set of domains. On the other hand,
34215 a host which is acting as a smart host for a number of clients is concerned
34216 with outgoing relaying from those clients to the Internet at large. Often the
34217 same host is fulfilling both functions,
34218 . ///
34219 . as illustrated in the diagram below,
34220 . ///
34221 but in principle these two kinds of relaying are entirely independent. What is
34222 not wanted is the transmission of mail from arbitrary remote hosts through your
34223 system to arbitrary domains.
34224
34225
34226 You can implement relay control by means of suitable statements in the ACL that
34227 runs for each RCPT command. For convenience, it is often easiest to use
34228 Exim's named list facility to define the domains and hosts involved. For
34229 example, suppose you want to do the following:
34230
34231 .ilist
34232 Deliver a number of domains to mailboxes on the local host (or process them
34233 locally in some other way). Let's say these are &'my.dom1.example'& and
34234 &'my.dom2.example'&.
34235 .next
34236 Relay mail for a number of other domains for which you are the secondary MX.
34237 These might be &'friend1.example'& and &'friend2.example'&.
34238 .next
34239 Relay mail from the hosts on your local LAN, to whatever domains are involved.
34240 Suppose your LAN is 192.168.45.0/24.
34241 .endlist
34242
34243
34244 In the main part of the configuration, you put the following definitions:
34245 .code
34246 domainlist local_domains    = my.dom1.example : my.dom2.example
34247 domainlist relay_to_domains = friend1.example : friend2.example
34248 hostlist   relay_from_hosts = 192.168.45.0/24
34249 .endd
34250 Now you can use these definitions in the ACL that is run for every RCPT
34251 command:
34252 .code
34253 acl_check_rcpt:
34254   accept domains = +local_domains : +relay_to_domains
34255   accept hosts   = +relay_from_hosts
34256 .endd
34257 The first statement accepts any RCPT command that contains an address in
34258 the local or relay domains. For any other domain, control passes to the second
34259 statement, which accepts the command only if it comes from one of the relay
34260 hosts. In practice, you will probably want to make your ACL more sophisticated
34261 than this, for example, by including sender and recipient verification. The
34262 default configuration includes a more comprehensive example, which is described
34263 in chapter &<<CHAPdefconfil>>&.
34264
34265
34266
34267 .section "Checking a relay configuration" "SECTcheralcon"
34268 .cindex "relaying" "checking control of"
34269 You can check the relay characteristics of your configuration in the same way
34270 that you can test any ACL behaviour for an incoming SMTP connection, by using
34271 the &%-bh%& option to run a fake SMTP session with which you interact.
34272 .ecindex IIDacl
34273
34274
34275
34276 . ////////////////////////////////////////////////////////////////////////////
34277 . ////////////////////////////////////////////////////////////////////////////
34278
34279 .chapter "Content scanning at ACL time" "CHAPexiscan"
34280 .scindex IIDcosca "content scanning" "at ACL time"
34281 The extension of Exim to include content scanning at ACL time, formerly known
34282 as &"exiscan"&, was originally implemented as a patch by Tom Kistner. The code
34283 was integrated into the main source for Exim release 4.50, and Tom continues to
34284 maintain it. Most of the wording of this chapter is taken from Tom's
34285 specification.
34286
34287 It is also possible to scan the content of messages at other times. The
34288 &[local_scan()]& function (see chapter &<<CHAPlocalscan>>&) allows for content
34289 scanning after all the ACLs have run. A transport filter can be used to scan
34290 messages at delivery time (see the &%transport_filter%& option, described in
34291 chapter &<<CHAPtransportgeneric>>&).
34292
34293 If you want to include the ACL-time content-scanning features when you compile
34294 Exim, you need to arrange for WITH_CONTENT_SCAN to be defined in your
34295 &_Local/Makefile_&. When you do that, the Exim binary is built with:
34296
34297 .ilist
34298 Two additional ACLs (&%acl_smtp_mime%& and &%acl_not_smtp_mime%&) that are run
34299 for all MIME parts for SMTP and non-SMTP messages, respectively.
34300 .next
34301 Additional ACL conditions and modifiers: &%decode%&, &%malware%&,
34302 &%mime_regex%&, &%regex%&, and &%spam%&. These can be used in the ACL that is
34303 run at the end of message reception (the &%acl_smtp_data%& ACL).
34304 .next
34305 An additional control feature (&"no_mbox_unspool"&) that saves spooled copies
34306 of messages, or parts of messages, for debugging purposes.
34307 .next
34308 Additional expansion variables that are set in the new ACL and by the new
34309 conditions.
34310 .next
34311 Two new main configuration options: &%av_scanner%& and &%spamd_address%&.
34312 .endlist
34313
34314 Content-scanning is continually evolving, and new features are still being
34315 added. While such features are still unstable and liable to incompatible
34316 changes, they are made available in Exim by setting options whose names begin
34317 EXPERIMENTAL_ in &_Local/Makefile_&. Such features are not documented in
34318 this manual. You can find out about them by reading the file called
34319 &_doc/experimental.txt_&.
34320
34321 All the content-scanning facilities work on a MBOX copy of the message that is
34322 temporarily created in a file called:
34323 .display
34324 <&'spool_directory'&>&`/scan/`&<&'message_id'&>/<&'message_id'&>&`.eml`&
34325 .endd
34326 The &_.eml_& extension is a friendly hint to virus scanners that they can
34327 expect an MBOX-like structure inside that file. The file is created when the
34328 first content scanning facility is called. Subsequent calls to content
34329 scanning conditions open the same file again. The directory is recursively
34330 removed when the &%acl_smtp_data%& ACL has finished running, unless
34331 .code
34332 control = no_mbox_unspool
34333 .endd
34334 has been encountered. When the MIME ACL decodes files, they are put into the
34335 same directory by default.
34336
34337
34338
34339 .section "Scanning for viruses" "SECTscanvirus"
34340 .cindex "virus scanning"
34341 .cindex "content scanning" "for viruses"
34342 .cindex "content scanning" "the &%malware%& condition"
34343 The &%malware%& ACL condition lets you connect virus scanner software to Exim.
34344 It supports a &"generic"& interface to scanners called via the shell, and
34345 specialized interfaces for &"daemon"& type virus scanners, which are resident
34346 in memory and thus are much faster.
34347
34348 Since message data needs to have arrived,
34349 the condition may be only called in ACL defined by
34350 &%acl_smtp_data%&,
34351 &%acl_smtp_data_prdr%&,
34352 &%acl_smtp_mime%& or
34353 &%acl_smtp_dkim%&
34354
34355 A timeout of 2 minutes is applied to a scanner call (by default);
34356 if it expires then a defer action is taken.
34357
34358 .oindex "&%av_scanner%&"
34359 You can set the &%av_scanner%& option in the main part of the configuration
34360 to specify which scanner to use, together with any additional options that
34361 are needed. The basic syntax is as follows:
34362 .display
34363 &`av_scanner = <`&&'scanner-type'&&`>:<`&&'option1'&&`>:<`&&'option2'&&`>:[...]`&
34364 .endd
34365 If you do not set &%av_scanner%&, it defaults to
34366 .code
34367 av_scanner = sophie:/var/run/sophie
34368 .endd
34369 If the value of &%av_scanner%& starts with a dollar character, it is expanded
34370 before use.
34371 The usual list-parsing of the content (see &<<SECTlistconstruct>>&) applies.
34372 The following scanner types are supported in this release,
34373 though individual ones can be included or not at build time:
34374
34375 .vlist
34376 .vitem &%avast%&
34377 .cindex "virus scanners" "avast"
34378 This is the scanner daemon of Avast. It has been tested with Avast Core
34379 Security (currently at version 2.2.0).
34380 You can get a trial version at &url(https://www.avast.com) or for Linux
34381 at &url(https://www.avast.com/linux-server-antivirus).
34382 This scanner type takes one option,
34383 which can be either a full path to a UNIX socket,
34384 or host and port specifiers separated by white space.
34385 The host may be a name or an IP address; the port is either a
34386 single number or a pair of numbers with a dash between.
34387 A list of options may follow. These options are interpreted on the
34388 Exim's side of the malware scanner, or are given on separate lines to
34389 the daemon as options before the main scan command.
34390
34391 .cindex &`pass_unscanned`& "avast"
34392 If &`pass_unscanned`&
34393 is set, any files the Avast scanner can't scan (e.g.
34394 decompression bombs, or invalid archives) are considered clean. Use with
34395 care.
34396
34397 For example:
34398 .code
34399 av_scanner = avast:/var/run/avast/scan.sock:FLAGS -fullfiles:SENSITIVITY -pup
34400 av_scanner = avast:/var/run/avast/scan.sock:pass_unscanned:FLAGS -fullfiles:SENSITIVITY -pup
34401 av_scanner = avast:192.168.2.22 5036
34402 .endd
34403 If you omit the argument, the default path
34404 &_/var/run/avast/scan.sock_&
34405 is used.
34406 If you use a remote host,
34407 you need to make Exim's spool directory available to it,
34408 as the scanner is passed a file path, not file contents.
34409 For information about available commands and their options you may use
34410 .code
34411 $ socat UNIX:/var/run/avast/scan.sock STDIO:
34412     FLAGS
34413     SENSITIVITY
34414     PACK
34415 .endd
34416
34417 If the scanner returns a temporary failure (e.g. license issues, or
34418 permission problems), the message is deferred and a paniclog entry is
34419 written.  The usual &`defer_ok`& option is available.
34420
34421 .vitem &%aveserver%&
34422 .cindex "virus scanners" "Kaspersky"
34423 This is the scanner daemon of Kaspersky Version 5. You can get a trial version
34424 at &url(https://www.kaspersky.com/). This scanner type takes one option,
34425 which is the path to the daemon's UNIX socket. The default is shown in this
34426 example:
34427 .code
34428 av_scanner = aveserver:/var/run/aveserver
34429 .endd
34430
34431
34432 .vitem &%clamd%&
34433 .cindex "virus scanners" "clamd"
34434 This daemon-type scanner is GPL and free. You can get it at
34435 &url(https://www.clamav.net/). Some older versions of clamd do not seem to
34436 unpack MIME containers, so it used to be recommended to unpack MIME attachments
34437 in the MIME ACL. This is no longer believed to be necessary.
34438
34439 The options are a list of server specifiers, which may be
34440 a UNIX socket specification,
34441 a TCP socket specification,
34442 or a (global) option.
34443
34444 A socket specification consists of a space-separated list.
34445 For a Unix socket the first element is a full path for the socket,
34446 for a TCP socket the first element is the IP address
34447 and the second a port number,
34448 Any further elements are per-server (non-global) options.
34449 These per-server options are supported:
34450 .code
34451 retry=<timespec>        Retry on connect fail
34452 .endd
34453
34454 The &`retry`& option specifies a time after which a single retry for
34455 a failed connect is made.  The default is to not retry.
34456
34457 If a Unix socket file is specified, only one server is supported.
34458
34459 Examples:
34460 .code
34461 av_scanner = clamd:/opt/clamd/socket
34462 av_scanner = clamd:192.0.2.3 1234
34463 av_scanner = clamd:192.0.2.3 1234:local
34464 av_scanner = clamd:192.0.2.3 1234 retry=10s
34465 av_scanner = clamd:192.0.2.3 1234 : 192.0.2.4 1234
34466 .endd
34467 If the value of av_scanner points to a UNIX socket file or contains the
34468 &`local`&
34469 option, then the ClamAV interface will pass a filename containing the data
34470 to be scanned, which should normally result in less I/O happening and be
34471 more efficient.  Normally in the TCP case, the data is streamed to ClamAV as
34472 Exim does not assume that there is a common filesystem with the remote host.
34473
34474 The final example shows that multiple TCP targets can be specified.  Exim will
34475 randomly use one for each incoming email (i.e. it load balances them).  Note
34476 that only TCP targets may be used if specifying a list of scanners; a UNIX
34477 socket cannot be mixed in with TCP targets.  If one of the servers becomes
34478 unavailable, Exim will try the remaining one(s) until it finds one that works.
34479 When a clamd server becomes unreachable, Exim will log a message.  Exim does
34480 not keep track of scanner state between multiple messages, and the scanner
34481 selection is random, so the message will get logged in the mainlog for each
34482 email that the down scanner gets chosen first (message wrapped to be readable):
34483 .code
34484 2013-10-09 14:30:39 1VTumd-0000Y8-BQ malware acl condition:
34485    clamd: connection to localhost, port 3310 failed
34486    (Connection refused)
34487 .endd
34488
34489 If the option is unset, the default is &_/tmp/clamd_&. Thanks to David Saez for
34490 contributing the code for this scanner.
34491
34492 .vitem &%cmdline%&
34493 .cindex "virus scanners" "command line interface"
34494 This is the keyword for the generic command line scanner interface. It can be
34495 used to attach virus scanners that are invoked from the shell. This scanner
34496 type takes 3 mandatory options:
34497
34498 .olist
34499 The full path and name of the scanner binary, with all command line options,
34500 and a placeholder (&`%s`&) for the directory to scan.
34501
34502 .next
34503 A regular expression to match against the STDOUT and STDERR output of the
34504 virus scanner. If the expression matches, a virus was found. You must make
34505 absolutely sure that this expression matches on &"virus found"&. This is called
34506 the &"trigger"& expression.
34507
34508 .next
34509 Another regular expression, containing exactly one pair of parentheses, to
34510 match the name of the virus found in the scanners output. This is called the
34511 &"name"& expression.
34512 .endlist olist
34513
34514 For example, Sophos Sweep reports a virus on a line like this:
34515 .code
34516 Virus 'W32/Magistr-B' found in file ./those.bat
34517 .endd
34518 For the trigger expression, we can match the phrase &"found in file"&. For the
34519 name expression, we want to extract the W32/Magistr-B string, so we can match
34520 for the single quotes left and right of it. Altogether, this makes the
34521 configuration setting:
34522 .code
34523 av_scanner = cmdline:\
34524              /path/to/sweep -ss -all -rec -archive %s:\
34525              found in file:'(.+)'
34526 .endd
34527 .vitem &%drweb%&
34528 .cindex "virus scanners" "DrWeb"
34529 The DrWeb daemon scanner (&url(https://www.sald.ru/)) interface
34530 takes one option,
34531 either a full path to a UNIX socket,
34532 or host and port specifiers separated by white space.
34533 The host may be a name or an IP address; the port is either a
34534 single number or a pair of numbers with a dash between.
34535 For example:
34536 .code
34537 av_scanner = drweb:/var/run/drwebd.sock
34538 av_scanner = drweb:192.168.2.20 31337
34539 .endd
34540 If you omit the argument, the default path &_/usr/local/drweb/run/drwebd.sock_&
34541 is used. Thanks to Alex Miller for contributing the code for this scanner.
34542
34543 .vitem &%f-protd%&
34544 .cindex "virus scanners" "f-protd"
34545 The f-protd scanner is accessed via HTTP over TCP.
34546 One argument is taken, being a space-separated hostname and port number
34547 (or port-range).
34548 For example:
34549 .code
34550 av_scanner = f-protd:localhost 10200-10204
34551 .endd
34552 If you omit the argument, the default values shown above are used.
34553
34554 .vitem &%f-prot6d%&
34555 .cindex "virus scanners" "f-prot6d"
34556 The f-prot6d scanner is accessed using the FPSCAND protocol over TCP.
34557 One argument is taken, being a space-separated hostname and port number.
34558 For example:
34559 .code
34560 av_scanner = f-prot6d:localhost 10200
34561 .endd
34562 If you omit the argument, the default values show above are used.
34563
34564 .vitem &%fsecure%&
34565 .cindex "virus scanners" "F-Secure"
34566 The F-Secure daemon scanner (&url(https://www.f-secure.com/)) takes one
34567 argument which is the path to a UNIX socket. For example:
34568 .code
34569 av_scanner = fsecure:/path/to/.fsav
34570 .endd
34571 If no argument is given, the default is &_/var/run/.fsav_&. Thanks to Johan
34572 Thelmen for contributing the code for this scanner.
34573
34574 .vitem &%kavdaemon%&
34575 .cindex "virus scanners" "Kaspersky"
34576 This is the scanner daemon of Kaspersky Version 4. This version of the
34577 Kaspersky scanner is outdated. Please upgrade (see &%aveserver%& above). This
34578 scanner type takes one option, which is the path to the daemon's UNIX socket.
34579 For example:
34580 .code
34581 av_scanner = kavdaemon:/opt/AVP/AvpCtl
34582 .endd
34583 The default path is &_/var/run/AvpCtl_&.
34584
34585 .vitem &%mksd%&
34586 .cindex "virus scanners" "mksd"
34587 This was a daemon type scanner that is aimed mainly at Polish users,
34588 though some documentation was available in English.
34589 The history can be shown at &url(https://en.wikipedia.org/wiki/Mks_vir)
34590 and this appears to be a candidate for removal from Exim, unless
34591 we are informed of other virus scanners which use the same protocol
34592 to integrate.
34593 The only option for this scanner type is
34594 the maximum number of processes used simultaneously to scan the attachments,
34595 provided that mksd has
34596 been run with at least the same number of child processes. For example:
34597 .code
34598 av_scanner = mksd:2
34599 .endd
34600 You can safely omit this option (the default value is 1).
34601
34602 .vitem &%sock%&
34603 .cindex "virus scanners" "simple socket-connected"
34604 This is a general-purpose way of talking to simple scanner daemons
34605 running on the local machine.
34606 There are four options:
34607 an address (which may be an IP address and port, or the path of a Unix socket),
34608 a commandline to send (may include a single %s which will be replaced with
34609 the path to the mail file to be scanned),
34610 an RE to trigger on from the returned data,
34611 and an RE to extract malware_name from the returned data.
34612 For example:
34613 .code
34614 av_scanner = sock:127.0.0.1 6001:%s:(SPAM|VIRUS):(.*)$
34615 .endd
34616 Note that surrounding whitespace is stripped from each option, meaning
34617 there is no way to specify a trailing newline.
34618 The socket specifier and both regular-expressions are required.
34619 Default for the commandline is &_%s\n_& (note this does have a trailing newline);
34620 specify an empty element to get this.
34621
34622 .vitem &%sophie%&
34623 .cindex "virus scanners" "Sophos and Sophie"
34624 Sophie is a daemon that uses Sophos' &%libsavi%& library to scan for viruses.
34625 You can get Sophie at &url(http://sophie.sourceforge.net/). The only option
34626 for this scanner type is the path to the UNIX socket that Sophie uses for
34627 client communication. For example:
34628 .code
34629 av_scanner = sophie:/tmp/sophie
34630 .endd
34631 The default path is &_/var/run/sophie_&, so if you are using this, you can omit
34632 the option.
34633 .endlist
34634
34635 When &%av_scanner%& is correctly set, you can use the &%malware%& condition in
34636 the DATA ACL. &*Note*&: You cannot use the &%malware%& condition in the MIME
34637 ACL.
34638
34639 The &%av_scanner%& option is expanded each time &%malware%& is called. This
34640 makes it possible to use different scanners. See further below for an example.
34641 The &%malware%& condition caches its results, so when you use it multiple times
34642 for the same message, the actual scanning process is only carried out once.
34643 However, using expandable items in &%av_scanner%& disables this caching, in
34644 which case each use of the &%malware%& condition causes a new scan of the
34645 message.
34646
34647 The &%malware%& condition takes a right-hand argument that is expanded before
34648 use and taken as a list, slash-separated by default.
34649 The first element can then be one of
34650
34651 .ilist
34652 &"true"&, &"*"&, or &"1"&, in which case the message is scanned for viruses.
34653 The condition succeeds if a virus was found, and fail otherwise. This is the
34654 recommended usage.
34655 .next
34656 &"false"& or &"0"& or an empty string, in which case no scanning is done and
34657 the condition fails immediately.
34658 .next
34659 A regular expression, in which case the message is scanned for viruses. The
34660 condition succeeds if a virus is found and its name matches the regular
34661 expression. This allows you to take special actions on certain types of virus.
34662 Note that &"/"& characters in the RE must be doubled due to the list-processing,
34663 unless the separator is changed (in the usual way &<<SECTlistsepchange>>&).
34664 .endlist
34665
34666 You can append a &`defer_ok`& element to the &%malware%& argument list to accept
34667 messages even if there is a problem with the virus scanner.
34668 Otherwise, such a problem causes the ACL to defer.
34669
34670 You can append a &`tmo=<val>`& element to the &%malware%& argument list to
34671 specify a non-default timeout.  The default is two minutes.
34672 For example:
34673 .code
34674 malware = * / defer_ok / tmo=10s
34675 .endd
34676 A timeout causes the ACL to defer.
34677
34678 .vindex "&$callout_address$&"
34679 When a connection is made to the scanner the expansion variable &$callout_address$&
34680 is set to record the actual address used.
34681
34682 .vindex "&$malware_name$&"
34683 When a virus is found, the condition sets up an expansion variable called
34684 &$malware_name$& that contains the name of the virus. You can use it in a
34685 &%message%& modifier that specifies the error returned to the sender, and/or in
34686 logging data.
34687
34688 Beware the interaction of Exim's &%message_size_limit%& with any size limits
34689 imposed by your anti-virus scanner.
34690
34691 Here is a very simple scanning example:
34692 .code
34693 deny malware = *
34694      message = This message contains malware ($malware_name)
34695 .endd
34696 The next example accepts messages when there is a problem with the scanner:
34697 .code
34698 deny malware = */defer_ok
34699      message = This message contains malware ($malware_name)
34700 .endd
34701 The next example shows how to use an ACL variable to scan with both sophie and
34702 aveserver. It assumes you have set:
34703 .code
34704 av_scanner = $acl_m0
34705 .endd
34706 in the main Exim configuration.
34707 .code
34708 deny set acl_m0 = sophie
34709      malware = *
34710      message = This message contains malware ($malware_name)
34711
34712 deny set acl_m0 = aveserver
34713      malware = *
34714      message = This message contains malware ($malware_name)
34715 .endd
34716
34717
34718 .section "Scanning with SpamAssassin and Rspamd" "SECTscanspamass"
34719 .cindex "content scanning" "for spam"
34720 .cindex "spam scanning"
34721 .cindex "SpamAssassin"
34722 .cindex "Rspamd"
34723 The &%spam%& ACL condition calls SpamAssassin's &%spamd%& daemon to get a spam
34724 score and a report for the message.
34725 Support is also provided for Rspamd.
34726
34727 For more information about installation and configuration of SpamAssassin or
34728 Rspamd refer to their respective websites at
34729 &url(https://spamassassin.apache.org/) and &url(https://www.rspamd.com/)
34730
34731 SpamAssassin can be installed with CPAN by running:
34732 .code
34733 perl -MCPAN -e 'install Mail::SpamAssassin'
34734 .endd
34735 SpamAssassin has its own set of configuration files. Please review its
34736 documentation to see how you can tweak it. The default installation should work
34737 nicely, however.
34738
34739 .oindex "&%spamd_address%&"
34740 By default, SpamAssassin listens on 127.0.0.1, TCP port 783 and if you
34741 intend to use an instance running on the local host you do not need to set
34742 &%spamd_address%&. If you intend to use another host or port for SpamAssassin,
34743 you must set the &%spamd_address%& option in the global part of the Exim
34744 configuration as follows (example):
34745 .code
34746 spamd_address = 192.168.99.45 783
34747 .endd
34748 The SpamAssassin protocol relies on a TCP half-close from the client.
34749 If your SpamAssassin client side is running a Linux system with an
34750 iptables firewall, consider setting
34751 &%net.netfilter.nf_conntrack_tcp_timeout_close_wait%& to at least the
34752 timeout, Exim uses when waiting for a response from the SpamAssassin
34753 server (currently defaulting to 120s).  With a lower value the Linux
34754 connection tracking may consider your half-closed connection as dead too
34755 soon.
34756
34757
34758 To use Rspamd (which by default listens on all local addresses
34759 on TCP port 11333)
34760 you should add &%variant=rspamd%& after the address/port pair, for example:
34761 .code
34762 spamd_address = 127.0.0.1 11333 variant=rspamd
34763 .endd
34764
34765 As of version 2.60, &%SpamAssassin%& also supports communication over UNIX
34766 sockets. If you want to us these, supply &%spamd_address%& with an absolute
34767 filename instead of an address/port pair:
34768 .code
34769 spamd_address = /var/run/spamd_socket
34770 .endd
34771 You can have multiple &%spamd%& servers to improve scalability. These can
34772 reside on other hardware reachable over the network. To specify multiple
34773 &%spamd%& servers, put multiple address/port pairs in the &%spamd_address%&
34774 option, separated with colons (the separator can be changed in the usual way &<<SECTlistsepchange>>&):
34775 .code
34776 spamd_address = 192.168.2.10 783 : \
34777                 192.168.2.11 783 : \
34778                 192.168.2.12 783
34779 .endd
34780 Up to 32 &%spamd%& servers are supported.
34781 When a server fails to respond to the connection attempt, all other
34782 servers are tried until one succeeds. If no server responds, the &%spam%&
34783 condition defers.
34784
34785 Unix and TCP socket specifications may be mixed in any order.
34786 Each element of the list is a list itself, space-separated by default
34787 and changeable in the usual way (&<<SECTlistsepchange>>&);
34788 take care to not double the separator.
34789
34790 For TCP socket specifications a host name or IP (v4 or v6, but
34791 subject to list-separator quoting rules) address can be used,
34792 and the port can be one or a dash-separated pair.
34793 In the latter case, the range is tried in strict order.
34794
34795 Elements after the first for Unix sockets, or second for TCP socket,
34796 are options.
34797 The supported options are:
34798 .code
34799 pri=<priority>      Selection priority
34800 weight=<value>      Selection bias
34801 time=<start>-<end>  Use only between these times of day
34802 retry=<timespec>    Retry on connect fail
34803 tmo=<timespec>      Connection time limit
34804 variant=rspamd      Use Rspamd rather than SpamAssassin protocol
34805 .endd
34806
34807 The &`pri`& option specifies a priority for the server within the list,
34808 higher values being tried first.
34809 The default priority is 1.
34810
34811 The &`weight`& option specifies a selection bias.
34812 Within a priority set
34813 servers are queried in a random fashion, weighted by this value.
34814 The default value for selection bias is 1.
34815
34816 Time specifications for the &`time`& option are <hour>.<minute>.<second>
34817 in the local time zone; each element being one or more digits.
34818 Either the seconds or both minutes and seconds, plus the leading &`.`&
34819 characters, may be omitted and will be taken as zero.
34820
34821 Timeout specifications for the &`retry`& and &`tmo`& options
34822 are the usual Exim time interval standard, e.g. &`20s`& or &`1m`&.
34823
34824 The &`tmo`& option specifies an overall timeout for communication.
34825 The default value is two minutes.
34826
34827 The &`retry`& option specifies a time after which a single retry for
34828 a failed connect is made.
34829 The default is to not retry.
34830
34831 The &%spamd_address%& variable is expanded before use if it starts with
34832 a dollar sign. In this case, the expansion may return a string that is
34833 used as the list so that multiple spamd servers can be the result of an
34834 expansion.
34835
34836 .vindex "&$callout_address$&"
34837 When a connection is made to the server the expansion variable &$callout_address$&
34838 is set to record the actual address used.
34839
34840 .section "Calling SpamAssassin from an Exim ACL" "SECID206"
34841 Here is a simple example of the use of the &%spam%& condition in a DATA ACL:
34842 .code
34843 deny spam = joe
34844      message = This message was classified as SPAM
34845 .endd
34846 The right-hand side of the &%spam%& condition specifies a name. This is
34847 relevant if you have set up multiple SpamAssassin profiles. If you do not want
34848 to scan using a specific profile, but rather use the SpamAssassin system-wide
34849 default profile, you can scan for an unknown name, or simply use &"nobody"&.
34850 Rspamd does not use this setting. However, you must put something on the
34851 right-hand side.
34852
34853 The name allows you to use per-domain or per-user antispam profiles in
34854 principle, but this is not straightforward in practice, because a message may
34855 have multiple recipients, not necessarily all in the same domain. Because the
34856 &%spam%& condition has to be called from a DATA-time ACL in order to be able to
34857 read the contents of the message, the variables &$local_part$& and &$domain$&
34858 are not set.
34859 Careful enforcement of single-recipient messages
34860 (e.g. by responding with defer in the recipient ACL for all recipients
34861 after the first),
34862 or the use of PRDR,
34863 .cindex "PRDR" "use for per-user SpamAssassin profiles"
34864 are needed to use this feature.
34865
34866 The right-hand side of the &%spam%& condition is expanded before being used, so
34867 you can put lookups or conditions there. When the right-hand side evaluates to
34868 &"0"& or &"false"&, no scanning is done and the condition fails immediately.
34869
34870
34871 Scanning with SpamAssassin uses a lot of resources. If you scan every message,
34872 large ones may cause significant performance degradation. As most spam messages
34873 are quite small, it is recommended that you do not scan the big ones. For
34874 example:
34875 .code
34876 deny condition = ${if < {$message_size}{10K}}
34877      spam = nobody
34878      message = This message was classified as SPAM
34879 .endd
34880
34881 The &%spam%& condition returns true if the threshold specified in the user's
34882 SpamAssassin profile has been matched or exceeded. If you want to use the
34883 &%spam%& condition for its side effects (see the variables below), you can make
34884 it always return &"true"& by appending &`:true`& to the username.
34885
34886 .cindex "spam scanning" "returned variables"
34887 When the &%spam%& condition is run, it sets up a number of expansion
34888 variables.
34889 Except for &$spam_report$&,
34890 these variables are saved with the received message so are
34891 available for use at delivery time.
34892
34893 .vlist
34894 .vitem &$spam_score$&
34895 The spam score of the message, for example, &"3.4"& or &"30.5"&. This is useful
34896 for inclusion in log or reject messages.
34897
34898 .vitem &$spam_score_int$&
34899 The spam score of the message, multiplied by ten, as an integer value. For
34900 example &"34"& or &"305"&. It may appear to disagree with &$spam_score$&
34901 because &$spam_score$& is rounded and &$spam_score_int$& is truncated.
34902 The integer value is useful for numeric comparisons in conditions.
34903
34904 .vitem &$spam_bar$&
34905 A string consisting of a number of &"+"& or &"-"& characters, representing the
34906 integer part of the spam score value. A spam score of 4.4 would have a
34907 &$spam_bar$& value of &"++++"&. This is useful for inclusion in warning
34908 headers, since MUAs can match on such strings. The maximum length of the
34909 spam bar is 50 characters.
34910
34911 .vitem &$spam_report$&
34912 A multiline text table, containing the full SpamAssassin report for the
34913 message. Useful for inclusion in headers or reject messages.
34914 This variable is only usable in a DATA-time ACL.
34915 Beware that SpamAssassin may return non-ASCII characters, especially
34916 when running in country-specific locales, which are not legal
34917 unencoded in headers.
34918
34919 .vitem &$spam_action$&
34920 For SpamAssassin either 'reject' or 'no action' depending on the
34921 spam score versus threshold.
34922 For Rspamd, the recommended action.
34923
34924 .endlist
34925
34926 The &%spam%& condition caches its results unless expansion in
34927 spamd_address was used. If you call it again with the same user name, it
34928 does not scan again, but rather returns the same values as before.
34929
34930 The &%spam%& condition returns DEFER if there is any error while running
34931 the message through SpamAssassin or if the expansion of spamd_address
34932 failed. If you want to treat DEFER as FAIL (to pass on to the next ACL
34933 statement block), append &`/defer_ok`& to the right-hand side of the
34934 spam condition, like this:
34935 .code
34936 deny spam    = joe/defer_ok
34937      message = This message was classified as SPAM
34938 .endd
34939 This causes messages to be accepted even if there is a problem with &%spamd%&.
34940
34941 Here is a longer, commented example of the use of the &%spam%&
34942 condition:
34943 .code
34944 # put headers in all messages (no matter if spam or not)
34945 warn  spam = nobody:true
34946       add_header = X-Spam-Score: $spam_score ($spam_bar)
34947       add_header = X-Spam-Report: $spam_report
34948
34949 # add second subject line with *SPAM* marker when message
34950 # is over threshold
34951 warn  spam = nobody
34952       add_header = Subject: *SPAM* $h_Subject:
34953
34954 # reject spam at high scores (> 12)
34955 deny  spam = nobody:true
34956       condition = ${if >{$spam_score_int}{120}{1}{0}}
34957       message = This message scored $spam_score spam points.
34958 .endd
34959
34960
34961
34962 .section "Scanning MIME parts" "SECTscanmimepart"
34963 .cindex "content scanning" "MIME parts"
34964 .cindex "MIME content scanning"
34965 .oindex "&%acl_smtp_mime%&"
34966 .oindex "&%acl_not_smtp_mime%&"
34967 The &%acl_smtp_mime%& global option specifies an ACL that is called once for
34968 each MIME part of an SMTP message, including multipart types, in the sequence
34969 of their position in the message. Similarly, the &%acl_not_smtp_mime%& option
34970 specifies an ACL that is used for the MIME parts of non-SMTP messages. These
34971 options may both refer to the same ACL if you want the same processing in both
34972 cases.
34973
34974 These ACLs are called (possibly many times) just before the &%acl_smtp_data%&
34975 ACL in the case of an SMTP message, or just before the &%acl_not_smtp%& ACL in
34976 the case of a non-SMTP message. However, a MIME ACL is called only if the
34977 message contains a &'Content-Type:'& header line. When a call to a MIME
34978 ACL does not yield &"accept"&, ACL processing is aborted and the appropriate
34979 result code is sent to the client. In the case of an SMTP message, the
34980 &%acl_smtp_data%& ACL is not called when this happens.
34981
34982 You cannot use the &%malware%& or &%spam%& conditions in a MIME ACL; these can
34983 only be used in the DATA or non-SMTP ACLs. However, you can use the &%regex%&
34984 condition to match against the raw MIME part. You can also use the
34985 &%mime_regex%& condition to match against the decoded MIME part (see section
34986 &<<SECTscanregex>>&).
34987
34988 At the start of a MIME ACL, a number of variables are set from the header
34989 information for the relevant MIME part. These are described below. The contents
34990 of the MIME part are not by default decoded into a disk file except for MIME
34991 parts whose content-type is &"message/rfc822"&. If you want to decode a MIME
34992 part into a disk file, you can use the &%decode%& condition. The general
34993 syntax is:
34994 .display
34995 &`decode = [/`&<&'path'&>&`/]`&<&'filename'&>
34996 .endd
34997 The right hand side is expanded before use. After expansion,
34998 the value can be:
34999
35000 .olist
35001 &"0"& or &"false"&, in which case no decoding is done.
35002 .next
35003 The string &"default"&. In that case, the file is put in the temporary
35004 &"default"& directory <&'spool_directory'&>&_/scan/_&<&'message_id'&>&_/_& with
35005 a sequential filename consisting of the message id and a sequence number. The
35006 full path and name is available in &$mime_decoded_filename$& after decoding.
35007 .next
35008 A full path name starting with a slash. If the full name is an existing
35009 directory, it is used as a replacement for the default directory. The filename
35010 is then sequentially assigned. If the path does not exist, it is used as
35011 the full path and filename.
35012 .next
35013 If the string does not start with a slash, it is used as the
35014 filename, and the default path is then used.
35015 .endlist
35016 The &%decode%& condition normally succeeds. It is only false for syntax
35017 errors or unusual circumstances such as memory shortages. You can easily decode
35018 a file with its original, proposed filename using
35019 .code
35020 decode = $mime_filename
35021 .endd
35022 However, you should keep in mind that &$mime_filename$& might contain
35023 anything. If you place files outside of the default path, they are not
35024 automatically unlinked.
35025
35026 For RFC822 attachments (these are messages attached to messages, with a
35027 content-type of &"message/rfc822"&), the ACL is called again in the same manner
35028 as for the primary message, only that the &$mime_is_rfc822$& expansion
35029 variable is set (see below). Attached messages are always decoded to disk
35030 before being checked, and the files are unlinked once the check is done.
35031
35032 The MIME ACL supports the &%regex%& and &%mime_regex%& conditions. These can be
35033 used to match regular expressions against raw and decoded MIME parts,
35034 respectively. They are described in section &<<SECTscanregex>>&.
35035
35036 .cindex "MIME content scanning" "returned variables"
35037 The following list describes all expansion variables that are
35038 available in the MIME ACL:
35039
35040 .vlist
35041 .vitem &$mime_anomaly_level$& &&&
35042        &$mime_anomaly_text$&
35043 .vindex &$mime_anomaly_level$&
35044 .vindex &$mime_anomaly_text$&
35045 If there are problems decoding, these variables contain information on
35046 the detected issue.
35047
35048 .vitem &$mime_boundary$&
35049 .vindex &$mime_boundary$&
35050 If the current part is a multipart (see &$mime_is_multipart$& below), it should
35051 have a boundary string, which is stored in this variable. If the current part
35052 has no boundary parameter in the &'Content-Type:'& header, this variable
35053 contains the empty string.
35054
35055 .vitem &$mime_charset$&
35056 .vindex &$mime_charset$&
35057 This variable contains the character set identifier, if one was found in the
35058 &'Content-Type:'& header. Examples for charset identifiers are:
35059 .code
35060 us-ascii
35061 gb2312 (Chinese)
35062 iso-8859-1
35063 .endd
35064 Please note that this value is not normalized, so you should do matches
35065 case-insensitively.
35066
35067 .vitem &$mime_content_description$&
35068 .vindex &$mime_content_description$&
35069 This variable contains the normalized content of the &'Content-Description:'&
35070 header. It can contain a human-readable description of the parts content. Some
35071 implementations repeat the filename for attachments here, but they are usually
35072 only used for display purposes.
35073
35074 .vitem &$mime_content_disposition$&
35075 .vindex &$mime_content_disposition$&
35076 This variable contains the normalized content of the &'Content-Disposition:'&
35077 header. You can expect strings like &"attachment"& or &"inline"& here.
35078
35079 .vitem &$mime_content_id$&
35080 .vindex &$mime_content_id$&
35081 This variable contains the normalized content of the &'Content-ID:'& header.
35082 This is a unique ID that can be used to reference a part from another part.
35083
35084 .vitem &$mime_content_size$&
35085 .vindex &$mime_content_size$&
35086 This variable is set only after the &%decode%& modifier (see above) has been
35087 successfully run. It contains the size of the decoded part in kilobytes. The
35088 size is always rounded up to full kilobytes, so only a completely empty part
35089 has a &$mime_content_size$& of zero.
35090
35091 .vitem &$mime_content_transfer_encoding$&
35092 .vindex &$mime_content_transfer_encoding$&
35093 This variable contains the normalized content of the
35094 &'Content-transfer-encoding:'& header. This is a symbolic name for an encoding
35095 type. Typical values are &"base64"& and &"quoted-printable"&.
35096
35097 .vitem &$mime_content_type$&
35098 .vindex &$mime_content_type$&
35099 If the MIME part has a &'Content-Type:'& header, this variable contains its
35100 value, lowercased, and without any options (like &"name"& or &"charset"&). Here
35101 are some examples of popular MIME types, as they may appear in this variable:
35102 .code
35103 text/plain
35104 text/html
35105 application/octet-stream
35106 image/jpeg
35107 audio/midi
35108 .endd
35109 If the MIME part has no &'Content-Type:'& header, this variable contains the
35110 empty string.
35111
35112 .vitem &$mime_decoded_filename$&
35113 .vindex &$mime_decoded_filename$&
35114 This variable is set only after the &%decode%& modifier (see above) has been
35115 successfully run. It contains the full path and filename of the file
35116 containing the decoded data.
35117 .endlist
35118
35119 .cindex "RFC 2047"
35120 .vlist
35121 .vitem &$mime_filename$&
35122 .vindex &$mime_filename$&
35123 This is perhaps the most important of the MIME variables. It contains a
35124 proposed filename for an attachment, if one was found in either the
35125 &'Content-Type:'& or &'Content-Disposition:'& headers. The filename will be
35126 RFC2047
35127 or RFC2231
35128 decoded, but no additional sanity checks are done.
35129  If no filename was
35130 found, this variable contains the empty string.
35131
35132 .vitem &$mime_is_coverletter$&
35133 .vindex &$mime_is_coverletter$&
35134 This variable attempts to differentiate the &"cover letter"& of an e-mail from
35135 attached data. It can be used to clamp down on flashy or unnecessarily encoded
35136 content in the cover letter, while not restricting attachments at all.
35137
35138 The variable contains 1 (true) for a MIME part believed to be part of the
35139 cover letter, and 0 (false) for an attachment. At present, the algorithm is as
35140 follows:
35141
35142 .olist
35143 The outermost MIME part of a message is always a cover letter.
35144
35145 .next
35146 If a multipart/alternative or multipart/related MIME part is a cover letter,
35147 so are all MIME subparts within that multipart.
35148
35149 .next
35150 If any other multipart is a cover letter, the first subpart is a cover letter,
35151 and the rest are attachments.
35152
35153 .next
35154 All parts contained within an attachment multipart are attachments.
35155 .endlist olist
35156
35157 As an example, the following will ban &"HTML mail"& (including that sent with
35158 alternative plain text), while allowing HTML files to be attached. HTML
35159 coverletter mail attached to non-HTML coverletter mail will also be allowed:
35160 .code
35161 deny !condition = $mime_is_rfc822
35162      condition = $mime_is_coverletter
35163      condition = ${if eq{$mime_content_type}{text/html}{1}{0}}
35164      message = HTML mail is not accepted here
35165 .endd
35166
35167 .vitem &$mime_is_multipart$&
35168 .vindex &$mime_is_multipart$&
35169 This variable has the value 1 (true) when the current part has the main type
35170 &"multipart"&, for example, &"multipart/alternative"& or &"multipart/mixed"&.
35171 Since multipart entities only serve as containers for other parts, you may not
35172 want to carry out specific actions on them.
35173
35174 .vitem &$mime_is_rfc822$&
35175 .vindex &$mime_is_rfc822$&
35176 This variable has the value 1 (true) if the current part is not a part of the
35177 checked message itself, but part of an attached message. Attached message
35178 decoding is fully recursive.
35179
35180 .vitem &$mime_part_count$&
35181 .vindex &$mime_part_count$&
35182 This variable is a counter that is raised for each processed MIME part. It
35183 starts at zero for the very first part (which is usually a multipart). The
35184 counter is per-message, so it is reset when processing RFC822 attachments (see
35185 &$mime_is_rfc822$&). The counter stays set after &%acl_smtp_mime%& is
35186 complete, so you can use it in the DATA ACL to determine the number of MIME
35187 parts of a message. For non-MIME messages, this variable contains the value -1.
35188 .endlist
35189
35190
35191
35192 .section "Scanning with regular expressions" "SECTscanregex"
35193 .cindex "content scanning" "with regular expressions"
35194 .cindex "regular expressions" "content scanning with"
35195 You can specify your own custom regular expression matches on the full body of
35196 the message, or on individual MIME parts.
35197
35198 The &%regex%& condition takes one or more regular expressions as arguments and
35199 matches them against the full message (when called in the DATA ACL) or a raw
35200 MIME part (when called in the MIME ACL). The &%regex%& condition matches
35201 linewise, with a maximum line length of 32K characters. That means you cannot
35202 have multiline matches with the &%regex%& condition.
35203
35204 The &%mime_regex%& condition can be called only in the MIME ACL. It matches up
35205 to 32K of decoded content (the whole content at once, not linewise). If the
35206 part has not been decoded with the &%decode%& modifier earlier in the ACL, it
35207 is decoded automatically when &%mime_regex%& is executed (using default path
35208 and filename values). If the decoded data is larger than  32K, only the first
35209 32K characters are checked.
35210
35211 The regular expressions are passed as a colon-separated list. To include a
35212 literal colon, you must double it. Since the whole right-hand side string is
35213 expanded before being used, you must also escape dollar signs and backslashes
35214 with more backslashes, or use the &`\N`& facility to disable expansion.
35215 Here is a simple example that contains two regular expressions:
35216 .code
35217 deny regex = [Mm]ortgage : URGENT BUSINESS PROPOSAL
35218      message = contains blacklisted regex ($regex_match_string)
35219 .endd
35220 The conditions returns true if any one of the regular expressions matches. The
35221 &$regex_match_string$& expansion variable is then set up and contains the
35222 matching regular expression.
35223 The expansion variables &$regex1$& &$regex2$& etc
35224 are set to any substrings captured by the regular expression.
35225
35226 &*Warning*&: With large messages, these conditions can be fairly
35227 CPU-intensive.
35228
35229 .ecindex IIDcosca
35230
35231
35232
35233
35234 . ////////////////////////////////////////////////////////////////////////////
35235 . ////////////////////////////////////////////////////////////////////////////
35236
35237 .chapter "Adding a local scan function to Exim" "CHAPlocalscan" &&&
35238          "Local scan function"
35239 .scindex IIDlosca "&[local_scan()]& function" "description of"
35240 .cindex "customizing" "input scan using C function"
35241 .cindex "policy control" "by local scan function"
35242 In these days of email worms, viruses, and ever-increasing spam, some sites
35243 want to apply a lot of checking to messages before accepting them.
35244
35245 The content scanning extension (chapter &<<CHAPexiscan>>&) has facilities for
35246 passing messages to external virus and spam scanning software. You can also do
35247 a certain amount in Exim itself through string expansions and the &%condition%&
35248 condition in the ACL that runs after the SMTP DATA command or the ACL for
35249 non-SMTP messages (see chapter &<<CHAPACL>>&), but this has its limitations.
35250
35251 To allow for further customization to a site's own requirements, there is the
35252 possibility of linking Exim with a private message scanning function, written
35253 in C. If you want to run code that is written in something other than C, you
35254 can of course use a little C stub to call it.
35255
35256 The local scan function is run once for every incoming message, at the point
35257 when Exim is just about to accept the message.
35258 It can therefore be used to control non-SMTP messages from local processes as
35259 well as messages arriving via SMTP.
35260
35261 Exim applies a timeout to calls of the local scan function, and there is an
35262 option called &%local_scan_timeout%& for setting it. The default is 5 minutes.
35263 Zero means &"no timeout"&.
35264 Exim also sets up signal handlers for SIGSEGV, SIGILL, SIGFPE, and SIGBUS
35265 before calling the local scan function, so that the most common types of crash
35266 are caught. If the timeout is exceeded or one of those signals is caught, the
35267 incoming message is rejected with a temporary error if it is an SMTP message.
35268 For a non-SMTP message, the message is dropped and Exim ends with a non-zero
35269 code. The incident is logged on the main and reject logs.
35270
35271
35272
35273 .section "Building Exim to use a local scan function" "SECID207"
35274 .cindex "&[local_scan()]& function" "building Exim to use"
35275 To make use of the local scan function feature, you must tell Exim where your
35276 function is before building Exim, by setting
35277 both HAVE_LOCAL_SCAN and
35278 LOCAL_SCAN_SOURCE in your
35279 &_Local/Makefile_&. A recommended place to put it is in the &_Local_&
35280 directory, so you might set
35281 .code
35282 HAVE_LOCAL_SCAN=yes
35283 LOCAL_SCAN_SOURCE=Local/local_scan.c
35284 .endd
35285 for example. The function must be called &[local_scan()]&;
35286 the source file(s) for it should first #define LOCAL_SCAN
35287 and then #include "local_scan.h".
35288 It is called by
35289 Exim after it has received a message, when the success return code is about to
35290 be sent. This is after all the ACLs have been run. The return code from your
35291 function controls whether the message is actually accepted or not. There is a
35292 commented template function (that just accepts the message) in the file
35293 _src/local_scan.c_.
35294
35295 If you want to make use of Exim's runtime configuration file to set options
35296 for your &[local_scan()]& function, you must also set
35297 .code
35298 LOCAL_SCAN_HAS_OPTIONS=yes
35299 .endd
35300 in &_Local/Makefile_& (see section &<<SECTconoptloc>>& below).
35301
35302
35303
35304
35305 .section "API for local_scan()" "SECTapiforloc"
35306 .cindex "&[local_scan()]& function" "API description"
35307 .cindex &%dlfunc%& "API description"
35308 You must include this line near the start of your code:
35309 .code
35310 #define LOCAL_SCAN
35311 #include "local_scan.h"
35312 .endd
35313 This header file defines a number of variables and other values, and the
35314 prototype for the function itself. Exim is coded to use unsigned char values
35315 almost exclusively, and one of the things this header defines is a shorthand
35316 for &`unsigned char`& called &`uschar`&.
35317 It also makes available the following macro definitions, to simplify casting character
35318 strings and pointers to character strings:
35319 .code
35320 #define CS   (char *)
35321 #define CCS  (const char *)
35322 #define CSS  (char **)
35323 #define US   (unsigned char *)
35324 #define CUS  (const unsigned char *)
35325 #define USS  (unsigned char **)
35326 .endd
35327 The function prototype for &[local_scan()]& is:
35328 .code
35329 extern int local_scan(int fd, uschar **return_text);
35330 .endd
35331 The arguments are as follows:
35332
35333 .ilist
35334 &%fd%& is a file descriptor for the file that contains the body of the message
35335 (the -D file). The file is open for reading and writing, but updating it is not
35336 recommended. &*Warning*&: You must &'not'& close this file descriptor.
35337
35338 The descriptor is positioned at character 26 of the file, which is the first
35339 character of the body itself, because the first 26 characters (19 characters
35340 before Exim  4.97) are the message id followed by &`-D`& and a newline.
35341 If you rewind the file, you should use the
35342 macro SPOOL_DATA_START_OFFSET to reset to the start of the data, just in
35343 case this changes in some future version.
35344 .next
35345 &%return_text%& is an address which you can use to return a pointer to a text
35346 string at the end of the function. The value it points to on entry is NULL.
35347 .endlist
35348
35349 The function must return an &%int%& value which is one of the following macros:
35350
35351 .vlist
35352 .vitem &`LOCAL_SCAN_ACCEPT`&
35353 .vindex "&$local_scan_data$&"
35354 The message is accepted. If you pass back a string of text, it is saved with
35355 the message, and made available in the variable &$local_scan_data$&. No
35356 newlines are permitted (if there are any, they are turned into spaces) and the
35357 maximum length of text is 1000 characters.
35358
35359 .vitem &`LOCAL_SCAN_ACCEPT_FREEZE`&
35360 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
35361 queued without immediate delivery, and is frozen.
35362
35363 .vitem &`LOCAL_SCAN_ACCEPT_QUEUE`&
35364 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
35365 queued without immediate delivery.
35366
35367 .vitem &`LOCAL_SCAN_REJECT`&
35368 The message is rejected; the returned text is used as an error message which is
35369 passed back to the sender and which is also logged. Newlines are permitted &--
35370 they cause a multiline response for SMTP rejections, but are converted to
35371 &`\n`& in log lines. If no message is given, &"Administrative prohibition"& is
35372 used.
35373
35374 .vitem &`LOCAL_SCAN_TEMPREJECT`&
35375 The message is temporarily rejected; the returned text is used as an error
35376 message as for LOCAL_SCAN_REJECT. If no message is given, &"Temporary local
35377 problem"& is used.
35378
35379 .vitem &`LOCAL_SCAN_REJECT_NOLOGHDR`&
35380 This behaves as LOCAL_SCAN_REJECT, except that the header of the rejected
35381 message is not written to the reject log. It has the effect of unsetting the
35382 &%rejected_header%& log selector for just this rejection. If
35383 &%rejected_header%& is already unset (see the discussion of the
35384 &%log_selection%& option in section &<<SECTlogselector>>&), this code is the
35385 same as LOCAL_SCAN_REJECT.
35386
35387 .vitem &`LOCAL_SCAN_TEMPREJECT_NOLOGHDR`&
35388 This code is a variation of LOCAL_SCAN_TEMPREJECT in the same way that
35389 LOCAL_SCAN_REJECT_NOLOGHDR is a variation of LOCAL_SCAN_REJECT.
35390 .endlist
35391
35392 If the message is not being received by interactive SMTP, rejections are
35393 reported by writing to &%stderr%& or by sending an email, as configured by the
35394 &%-oe%& command line options.
35395
35396
35397
35398 .section "Configuration options for local_scan()" "SECTconoptloc"
35399 .cindex "&[local_scan()]& function" "configuration options"
35400 It is possible to have option settings in the main configuration file
35401 that set values in static variables in the &[local_scan()]& module. If you
35402 want to do this, you must have the line
35403 .code
35404 LOCAL_SCAN_HAS_OPTIONS=yes
35405 .endd
35406 in your &_Local/Makefile_& when you build Exim. (This line is in
35407 &_OS/Makefile-Default_&, commented out). Then, in the &[local_scan()]& source
35408 file, you must define static variables to hold the option values, and a table
35409 to define them.
35410
35411 The table must be a vector called &%local_scan_options%&, of type
35412 &`optionlist`&. Each entry is a triplet, consisting of a name, an option type,
35413 and a pointer to the variable that holds the value. The entries must appear in
35414 alphabetical order. Following &%local_scan_options%& you must also define a
35415 variable called &%local_scan_options_count%& that contains the number of
35416 entries in the table. Here is a short example, showing two kinds of option:
35417 .code
35418 static int my_integer_option = 42;
35419 static uschar *my_string_option = US"a default string";
35420
35421 optionlist local_scan_options[] = {
35422   { "my_integer", opt_int,       &my_integer_option },
35423   { "my_string",  opt_stringptr, &my_string_option }
35424 };
35425
35426 int local_scan_options_count =
35427   sizeof(local_scan_options)/sizeof(optionlist);
35428 .endd
35429 The values of the variables can now be changed from Exim's runtime
35430 configuration file by including a local scan section as in this example:
35431 .code
35432 begin local_scan
35433 my_integer = 99
35434 my_string = some string of text...
35435 .endd
35436 The available types of option data are as follows:
35437
35438 .vlist
35439 .vitem &*opt_bool*&
35440 This specifies a boolean (true/false) option. The address should point to a
35441 variable of type &`BOOL`&, which will be set to TRUE or FALSE, which are macros
35442 that are defined as &"1"& and &"0"&, respectively. If you want to detect
35443 whether such a variable has been set at all, you can initialize it to
35444 TRUE_UNSET. (BOOL variables are integers underneath, so can hold more than two
35445 values.)
35446
35447 .vitem &*opt_fixed*&
35448 This specifies a fixed point number, such as is used for load averages.
35449 The address should point to a variable of type &`int`&. The value is stored
35450 multiplied by 1000, so, for example, 1.4142 is truncated and stored as 1414.
35451
35452 .vitem &*opt_int*&
35453 This specifies an integer; the address should point to a variable of type
35454 &`int`&. The value may be specified in any of the integer formats accepted by
35455 Exim.
35456
35457 .vitem &*opt_mkint*&
35458 This is the same as &%opt_int%&, except that when such a value is output in a
35459 &%-bP%& listing, if it is an exact number of kilobytes or megabytes, it is
35460 printed with the suffix K or M.
35461
35462 .vitem &*opt_octint*&
35463 This also specifies an integer, but the value is always interpreted as an
35464 octal integer, whether or not it starts with the digit zero, and it is
35465 always output in octal.
35466
35467 .vitem &*opt_stringptr*&
35468 This specifies a string value; the address must be a pointer to a
35469 variable that points to a string (for example, of type &`uschar *`&).
35470
35471 .vitem &*opt_time*&
35472 This specifies a time interval value. The address must point to a variable of
35473 type &`int`&. The value that is placed there is a number of seconds.
35474 .endlist
35475
35476 If the &%-bP%& command line option is followed by &`local_scan`&, Exim prints
35477 out the values of all the &[local_scan()]& options.
35478
35479
35480
35481 .section "Available Exim variables" "SECID208"
35482 .cindex "&[local_scan()]& function" "available Exim variables"
35483 The header &_local_scan.h_& gives you access to a number of C variables. These
35484 are the only ones that are guaranteed to be maintained from release to release.
35485 Note, however, that you can obtain the value of any Exim expansion variable,
35486 including &$recipients$&, by calling &'expand_string()'&. The exported
35487 C variables are as follows:
35488
35489 .vlist
35490 .vitem &*int&~body_linecount*&
35491 This variable contains the number of lines in the message's body.
35492 It is not valid if the &%spool_wireformat%& option is used.
35493
35494 .vitem &*int&~body_zerocount*&
35495 This variable contains the number of binary zero bytes in the message's body.
35496 It is not valid if the &%spool_wireformat%& option is used.
35497
35498 .vitem &*unsigned&~int&~debug_selector*&
35499 This variable is set to zero when no debugging is taking place. Otherwise, it
35500 is a bitmap of debugging selectors. Two bits are identified for use in
35501 &[local_scan()]&; they are defined as macros:
35502
35503 .ilist
35504 The &`D_v`& bit is set when &%-v%& was present on the command line. This is a
35505 testing option that is not privileged &-- any caller may set it. All the
35506 other selector bits can be set only by admin users.
35507
35508 .next
35509 The &`D_local_scan`& bit is provided for use by &[local_scan()]&; it is set
35510 by the &`+local_scan`& debug selector. It is not included in the default set
35511 of debugging bits.
35512 .endlist ilist
35513
35514 Thus, to write to the debugging output only when &`+local_scan`& has been
35515 selected, you should use code like this:
35516 .code
35517 if ((debug_selector & D_local_scan) != 0)
35518   debug_printf("xxx", ...);
35519 .endd
35520 .vitem &*uschar&~*expand_string_message*&
35521 After a failing call to &'expand_string()'& (returned value NULL), the
35522 variable &%expand_string_message%& contains the error message, zero-terminated.
35523
35524 .vitem &*header_line&~*header_list*&
35525 A pointer to a chain of header lines. The &%header_line%& structure is
35526 discussed below.
35527
35528 .vitem &*header_line&~*header_last*&
35529 A pointer to the last of the header lines.
35530
35531 .vitem &*const&~uschar&~*headers_charset*&
35532 The value of the &%headers_charset%& configuration option.
35533
35534 .vitem &*BOOL&~host_checking*&
35535 This variable is TRUE during a host checking session that is initiated by the
35536 &%-bh%& command line option.
35537
35538 .vitem &*uschar&~*interface_address*&
35539 The IP address of the interface that received the message, as a string. This
35540 is NULL for locally submitted messages.
35541
35542 .vitem &*int&~interface_port*&
35543 The port on which this message was received. When testing with the &%-bh%&
35544 command line option, the value of this variable is -1 unless a port has been
35545 specified via the &%-oMi%& option.
35546
35547 .vitem &*uschar&~*message_id*&
35548 This variable contains Exim's message id for the incoming message (the value of
35549 &$message_exim_id$&) as a zero-terminated string.
35550
35551 .vitem &*uschar&~*received_protocol*&
35552 The name of the protocol by which the message was received.
35553
35554 .vitem &*int&~recipients_count*&
35555 The number of accepted recipients.
35556
35557 .vitem &*recipient_item&~*recipients_list*&
35558 .cindex "recipient" "adding in local scan"
35559 .cindex "recipient" "removing in local scan"
35560 The list of accepted recipients, held in a vector of length
35561 &%recipients_count%&. The &%recipient_item%& structure is discussed below. You
35562 can add additional recipients by calling &'receive_add_recipient()'& (see
35563 below). You can delete recipients by removing them from the vector and
35564 adjusting the value in &%recipients_count%&. In particular, by setting
35565 &%recipients_count%& to zero you remove all recipients. If you then return the
35566 value &`LOCAL_SCAN_ACCEPT`&, the message is accepted, but immediately
35567 blackholed. To replace the recipients, you can set &%recipients_count%& to zero
35568 and then call &'receive_add_recipient()'& as often as needed.
35569
35570 .vitem &*uschar&~*sender_address*&
35571 The envelope sender address. For bounce messages this is the empty string.
35572
35573 .vitem &*uschar&~*sender_host_address*&
35574 The IP address of the sending host, as a string. This is NULL for
35575 locally-submitted messages.
35576
35577 .vitem &*uschar&~*sender_host_authenticated*&
35578 The name of the authentication mechanism that was used, or NULL if the message
35579 was not received over an authenticated SMTP connection.
35580
35581 .vitem &*uschar&~*sender_host_name*&
35582 The name of the sending host, if known.
35583
35584 .vitem &*int&~sender_host_port*&
35585 The port on the sending host.
35586
35587 .vitem &*BOOL&~smtp_input*&
35588 This variable is TRUE for all SMTP input, including BSMTP.
35589
35590 .vitem &*BOOL&~smtp_batched_input*&
35591 This variable is TRUE for BSMTP input.
35592
35593 .vitem &*int&~store_pool*&
35594 The contents of this variable control which pool of memory is used for new
35595 requests. See section &<<SECTmemhanloc>>& for details.
35596 .endlist
35597
35598
35599 .section "Structure of header lines" "SECID209"
35600 The &%header_line%& structure contains the members listed below.
35601 You can add additional header lines by calling the &'header_add()'& function
35602 (see below). You can cause header lines to be ignored (deleted) by setting
35603 their type to *.
35604
35605
35606 .vlist
35607 .vitem &*struct&~header_line&~*next*&
35608 A pointer to the next header line, or NULL for the last line.
35609
35610 .vitem &*int&~type*&
35611 A code identifying certain headers that Exim recognizes. The codes are printing
35612 characters, and are documented in chapter &<<CHAPspool>>& of this manual.
35613 Notice in particular that any header line whose type is * is not transmitted
35614 with the message. This flagging is used for header lines that have been
35615 rewritten, or are to be removed (for example, &'Envelope-sender:'& header
35616 lines.) Effectively, * means &"deleted"&.
35617
35618 .vitem &*int&~slen*&
35619 The number of characters in the header line, including the terminating and any
35620 internal newlines.
35621
35622 .vitem &*uschar&~*text*&
35623 A pointer to the text of the header. It always ends with a newline, followed by
35624 a zero byte. Internal newlines are preserved.
35625 .endlist
35626
35627
35628
35629 .section "Structure of recipient items" "SECID210"
35630 The &%recipient_item%& structure contains these members:
35631
35632 .vlist
35633 .vitem &*uschar&~*address*&
35634 This is a pointer to the recipient address as it was received.
35635
35636 .vitem &*int&~pno*&
35637 This is used in later Exim processing when top level addresses are created by
35638 the &%one_time%& option. It is not relevant at the time &[local_scan()]& is run
35639 and must always contain -1 at this stage.
35640
35641 .vitem &*uschar&~*errors_to*&
35642 If this value is not NULL, bounce messages caused by failing to deliver to the
35643 recipient are sent to the address it contains. In other words, it overrides the
35644 envelope sender for this one recipient. (Compare the &%errors_to%& generic
35645 router option.) If a &[local_scan()]& function sets an &%errors_to%& field to
35646 an unqualified address, Exim qualifies it using the domain from
35647 &%qualify_recipient%&. When &[local_scan()]& is called, the &%errors_to%& field
35648 is NULL for all recipients.
35649 .endlist
35650
35651
35652
35653 .section "Available Exim functions" "SECID211"
35654 .cindex "&[local_scan()]& function" "available Exim functions"
35655 The header &_local_scan.h_& gives you access to a number of Exim functions.
35656 These are the only ones that are guaranteed to be maintained from release to
35657 release:
35658
35659 .vlist
35660 .vitem "&*pid_t&~child_open(uschar&~**argv,&~uschar&~**envp,&~int&~newumask,&&&
35661        &~int&~*infdptr,&~int&~*outfdptr, &~&~BOOL&~make_leader)*&"
35662
35663 This function creates a child process that runs the command specified by
35664 &%argv%&. The environment for the process is specified by &%envp%&, which can
35665 be NULL if no environment variables are to be passed. A new umask is supplied
35666 for the process in &%newumask%&.
35667
35668 Pipes to the standard input and output of the new process are set up
35669 and returned to the caller via the &%infdptr%& and &%outfdptr%& arguments. The
35670 standard error is cloned to the standard output. If there are any file
35671 descriptors &"in the way"& in the new process, they are closed. If the final
35672 argument is TRUE, the new process is made into a process group leader.
35673
35674 The function returns the pid of the new process, or -1 if things go wrong.
35675
35676 .vitem &*int&~child_close(pid_t&~pid,&~int&~timeout)*&
35677 This function waits for a child process to terminate, or for a timeout (in
35678 seconds) to expire. A timeout value of zero means wait as long as it takes. The
35679 return value is as follows:
35680
35681 .ilist
35682 >= 0
35683
35684 The process terminated by a normal exit and the value is the process
35685 ending status.
35686
35687 .next
35688 < 0 and > &--256
35689
35690 The process was terminated by a signal and the value is the negation of the
35691 signal number.
35692
35693 .next
35694 &--256
35695
35696 The process timed out.
35697 .next
35698 &--257
35699
35700 The was some other error in wait(); &%errno%& is still set.
35701 .endlist
35702
35703 .vitem &*pid_t&~child_open_exim(int&~*fd)*&
35704 This function provide you with a means of submitting a new message to
35705 Exim. (Of course, you can also call &_/usr/sbin/sendmail_& yourself if you
35706 want, but this packages it all up for you.) The function creates a pipe,
35707 forks a subprocess that is running
35708 .code
35709 exim -t -oem -oi -f <>
35710 .endd
35711 and returns to you (via the &`int *`& argument) a file descriptor for the pipe
35712 that is connected to the standard input. The yield of the function is the PID
35713 of the subprocess. You can then write a message to the file descriptor, with
35714 recipients in &'To:'&, &'Cc:'&, and/or &'Bcc:'& header lines.
35715
35716 When you have finished, call &'child_close()'& to wait for the process to
35717 finish and to collect its ending status. A timeout value of zero is usually
35718 fine in this circumstance. Unless you have made a mistake with the recipient
35719 addresses, you should get a return code of zero.
35720
35721
35722 .vitem &*pid_t&~child_open_exim2(int&~*fd,&~uschar&~*sender,&~uschar&~&&&
35723        *sender_authentication)*&
35724 This function is a more sophisticated version of &'child_open()'&. The command
35725 that it runs is:
35726 .display
35727 &`exim -t -oem -oi -f `&&'sender'&&` -oMas `&&'sender_authentication'&
35728 .endd
35729 The third argument may be NULL, in which case the &%-oMas%& option is omitted.
35730
35731
35732 .vitem &*void&~debug_printf(char&~*,&~...)*&
35733 This is Exim's debugging function, with arguments as for &'(printf()'&. The
35734 output is written to the standard error stream. If no debugging is selected,
35735 calls to &'debug_printf()'& have no effect. Normally, you should make calls
35736 conditional on the &`local_scan`& debug selector by coding like this:
35737 .code
35738 if ((debug_selector & D_local_scan) != 0)
35739   debug_printf("xxx", ...);
35740 .endd
35741
35742 .vitem &*uschar&~*expand_string(uschar&~*string)*&
35743 This is an interface to Exim's string expansion code. The return value is the
35744 expanded string, or NULL if there was an expansion failure.
35745 The C variable &%expand_string_message%& contains an error message after an
35746 expansion failure. If expansion does not change the string, the return value is
35747 the pointer to the input string. Otherwise, the return value points to a new
35748 block of memory that was obtained by a call to &'store_get()'&. See section
35749 &<<SECTmemhanloc>>& below for a discussion of memory handling.
35750
35751 .vitem &*void&~header_add(int&~type,&~char&~*format,&~...)*&
35752 This function allows you to an add additional header line at the end of the
35753 existing ones. The first argument is the type, and should normally be a space
35754 character. The second argument is a format string and any number of
35755 substitution arguments as for &[sprintf()]&. You may include internal newlines
35756 if you want, and you must ensure that the string ends with a newline.
35757
35758 .vitem "&*void&~header_add_at_position(BOOL&~after,&~uschar&~*name,&~&&&
35759         BOOL&~topnot,&~int&~type,&~char&~*format, &~&~...)*&"
35760 This function adds a new header line at a specified point in the header
35761 chain. The header itself is specified as for &'header_add()'&.
35762
35763 If &%name%& is NULL, the new header is added at the end of the chain if
35764 &%after%& is true, or at the start if &%after%& is false. If &%name%& is not
35765 NULL, the header lines are searched for the first non-deleted header that
35766 matches the name. If one is found, the new header is added before it if
35767 &%after%& is false. If &%after%& is true, the new header is added after the
35768 found header and any adjacent subsequent ones with the same name (even if
35769 marked &"deleted"&). If no matching non-deleted header is found, the &%topnot%&
35770 option controls where the header is added. If it is true, addition is at the
35771 top; otherwise at the bottom. Thus, to add a header after all the &'Received:'&
35772 headers, or at the top if there are no &'Received:'& headers, you could use
35773 .code
35774 header_add_at_position(TRUE, US"Received", TRUE,
35775   ' ', "X-xxx: ...");
35776 .endd
35777 Normally, there is always at least one non-deleted &'Received:'& header, but
35778 there may not be if &%received_header_text%& expands to an empty string.
35779
35780
35781 .vitem &*void&~header_remove(int&~occurrence,&~uschar&~*name)*&
35782 This function removes header lines. If &%occurrence%& is zero or negative, all
35783 occurrences of the header are removed. If occurrence is greater than zero, that
35784 particular instance of the header is removed. If no header(s) can be found that
35785 match the specification, the function does nothing.
35786
35787
35788 .vitem "&*BOOL&~header_testname(header_line&~*hdr,&~uschar&~*name,&~&&&
35789         int&~length,&~BOOL&~notdel)*&"
35790 This function tests whether the given header has the given name. It is not just
35791 a string comparison, because white space is permitted between the name and the
35792 colon. If the &%notdel%& argument is true, a false return is forced for all
35793 &"deleted"& headers; otherwise they are not treated specially. For example:
35794 .code
35795 if (header_testname(h, US"X-Spam", 6, TRUE)) ...
35796 .endd
35797 .vitem &*uschar&~*lss_b64encode(uschar&~*cleartext,&~int&~length)*&
35798 .cindex "base64 encoding" "functions for &[local_scan()]& use"
35799 This function base64-encodes a string, which is passed by address and length.
35800 The text may contain bytes of any value, including zero. The result is passed
35801 back in dynamic memory that is obtained by calling &'store_get()'&. It is
35802 zero-terminated.
35803
35804 .vitem &*int&~lss_b64decode(uschar&~*codetext,&~uschar&~**cleartext)*&
35805 This function decodes a base64-encoded string. Its arguments are a
35806 zero-terminated base64-encoded string and the address of a variable that is set
35807 to point to the result, which is in dynamic memory. The length of the decoded
35808 string is the yield of the function. If the input is invalid base64 data, the
35809 yield is -1. A zero byte is added to the end of the output string to make it
35810 easy to interpret as a C string (assuming it contains no zeros of its own). The
35811 added zero byte is not included in the returned count.
35812
35813 .vitem &*int&~lss_match_domain(uschar&~*domain,&~uschar&~*list)*&
35814 This function checks for a match in a domain list. Domains are always
35815 matched caselessly. The return value is one of the following:
35816 .itable none 0 0 2 15* left 85* left
35817 .irow &`OK`&    "match succeeded"
35818 .irow &`FAIL`&  "match failed"
35819 .irow &`DEFER`& "match deferred"
35820 .endtable
35821 DEFER is usually caused by some kind of lookup defer, such as the
35822 inability to contact a database.
35823
35824 .vitem "&*int&~lss_match_local_part(uschar&~*localpart,&~uschar&~*list,&~&&&
35825         BOOL&~caseless)*&"
35826 This function checks for a match in a local part list. The third argument
35827 controls case-sensitivity. The return values are as for
35828 &'lss_match_domain()'&.
35829
35830 .vitem "&*int&~lss_match_address(uschar&~*address,&~uschar&~*list,&~&&&
35831         BOOL&~caseless)*&"
35832 This function checks for a match in an address list. The third argument
35833 controls the case-sensitivity of the local part match. The domain is always
35834 matched caselessly. The return values are as for &'lss_match_domain()'&.
35835
35836 .vitem "&*int&~lss_match_host(uschar&~*host_name,&~uschar&~*host_address,&~&&&
35837         uschar&~*list)*&"
35838 This function checks for a match in a host list. The most common usage is
35839 expected to be
35840 .code
35841 lss_match_host(sender_host_name, sender_host_address, ...)
35842 .endd
35843 .vindex "&$sender_host_address$&"
35844 An empty address field matches an empty item in the host list. If the host name
35845 is NULL, the name corresponding to &$sender_host_address$& is automatically
35846 looked up if a host name is required to match an item in the list. The return
35847 values are as for &'lss_match_domain()'&, but in addition, &'lss_match_host()'&
35848 returns ERROR in the case when it had to look up a host name, but the lookup
35849 failed.
35850
35851 .vitem "&*void&~log_write(unsigned&~int&~selector,&~int&~which,&~char&~&&&
35852         *format,&~...)*&"
35853 This function writes to Exim's log files. The first argument should be zero (it
35854 is concerned with &%log_selector%&). The second argument can be &`LOG_MAIN`& or
35855 &`LOG_REJECT`& or &`LOG_PANIC`& or the inclusive &"or"& of any combination of
35856 them. It specifies to which log or logs the message is written. The remaining
35857 arguments are a format and relevant insertion arguments. The string should not
35858 contain any newlines, not even at the end.
35859
35860
35861 .vitem &*void&~receive_add_recipient(uschar&~*address,&~int&~pno)*&
35862 This function adds an additional recipient to the message. The first argument
35863 is the recipient address. If it is unqualified (has no domain), it is qualified
35864 with the &%qualify_recipient%& domain. The second argument must always be -1.
35865
35866 This function does not allow you to specify a private &%errors_to%& address (as
35867 described with the structure of &%recipient_item%& above), because it pre-dates
35868 the addition of that field to the structure. However, it is easy to add such a
35869 value afterwards. For example:
35870 .code
35871  receive_add_recipient(US"monitor@mydom.example", -1);
35872  recipients_list[recipients_count-1].errors_to =
35873    US"postmaster@mydom.example";
35874 .endd
35875
35876 .vitem &*BOOL&~receive_remove_recipient(uschar&~*recipient)*&
35877 This is a convenience function to remove a named recipient from the list of
35878 recipients. It returns true if a recipient was removed, and false if no
35879 matching recipient could be found. The argument must be a complete email
35880 address.
35881 .endlist
35882
35883
35884 .cindex "RFC 2047"
35885 .vlist
35886 .vitem "&*uschar&~rfc2047_decode(uschar&~*string,&~BOOL&~lencheck,&&&
35887   &~uschar&~*target,&~int&~zeroval,&~int&~*lenptr, &~&~uschar&~**error)*&"
35888 This function decodes strings that are encoded according to RFC 2047. Typically
35889 these are the contents of header lines. First, each &"encoded word"& is decoded
35890 from the Q or B encoding into a byte-string. Then, if provided with the name of
35891 a charset encoding, and if the &[iconv()]& function is available, an attempt is
35892 made  to translate the result to the named character set. If this fails, the
35893 binary string is returned with an error message.
35894
35895 The first argument is the string to be decoded. If &%lencheck%& is TRUE, the
35896 maximum MIME word length is enforced. The third argument is the target
35897 encoding, or NULL if no translation is wanted.
35898
35899 .cindex "binary zero" "in RFC 2047 decoding"
35900 .cindex "RFC 2047" "binary zero in"
35901 If a binary zero is encountered in the decoded string, it is replaced by the
35902 contents of the &%zeroval%& argument. For use with Exim headers, the value must
35903 not be 0 because header lines are handled as zero-terminated strings.
35904
35905 The function returns the result of processing the string, zero-terminated; if
35906 &%lenptr%& is not NULL, the length of the result is set in the variable to
35907 which it points. When &%zeroval%& is 0, &%lenptr%& should not be NULL.
35908
35909 If an error is encountered, the function returns NULL and uses the &%error%&
35910 argument to return an error message. The variable pointed to by &%error%& is
35911 set to NULL if there is no error; it may be set non-NULL even when the function
35912 returns a non-NULL value if decoding was successful, but there was a problem
35913 with translation.
35914
35915
35916 .vitem &*int&~smtp_fflush(void)*&
35917 This function is used in conjunction with &'smtp_printf()'&, as described
35918 below.
35919
35920 .vitem &*void&~smtp_printf(char&~*,BOOL,&~...)*&
35921 The arguments of this function are almost like &[printf()]&; it writes to the SMTP
35922 output stream. You should use this function only when there is an SMTP output
35923 stream, that is, when the incoming message is being received via interactive
35924 SMTP. This is the case when &%smtp_input%& is TRUE and &%smtp_batched_input%&
35925 is FALSE. If you want to test for an incoming message from another host (as
35926 opposed to a local process that used the &%-bs%& command line option), you can
35927 test the value of &%sender_host_address%&, which is non-NULL when a remote host
35928 is involved.
35929
35930 If an SMTP TLS connection is established, &'smtp_printf()'& uses the TLS
35931 output function, so it can be used for all forms of SMTP connection.
35932
35933 The second argument is used to request that the data be buffered
35934 (when TRUE) or flushed (along with any previously buffered, when FALSE).
35935 This is advisory only, but likely to save on system-calls and packets
35936 sent when a sequence of calls to the function are made.
35937
35938 The argument was added in Exim version 4.90 - changing the API/ABI.
35939 Nobody noticed until 4.93 was imminent, at which point the
35940 ABI version number was incremented.
35941
35942 Strings that are written by &'smtp_printf()'& from within &[local_scan()]&
35943 must start with an appropriate response code: 550 if you are going to return
35944 LOCAL_SCAN_REJECT, 451 if you are going to return
35945 LOCAL_SCAN_TEMPREJECT, and 250 otherwise. Because you are writing the
35946 initial lines of a multi-line response, the code must be followed by a hyphen
35947 to indicate that the line is not the final response line. You must also ensure
35948 that the lines you write terminate with CRLF. For example:
35949 .code
35950 smtp_printf("550-this is some extra info\r\n");
35951 return LOCAL_SCAN_REJECT;
35952 .endd
35953 Note that you can also create multi-line responses by including newlines in
35954 the data returned via the &%return_text%& argument. The added value of using
35955 &'smtp_printf()'& is that, for instance, you could introduce delays between
35956 multiple output lines.
35957
35958 The &'smtp_printf()'& function does not return any error indication, because it
35959 does not
35960 guarantee a flush of
35961 pending output, and therefore does not test
35962 the state of the stream. (In the main code of Exim, flushing and error
35963 detection is done when Exim is ready for the next SMTP input command.) If
35964 you want to flush the output and check for an error (for example, the
35965 dropping of a TCP/IP connection), you can call &'smtp_fflush()'&, which has no
35966 arguments. It flushes the output stream, and returns a non-zero value if there
35967 is an error.
35968
35969 .vitem &*void&~*store_get(int,BOOL)*&
35970 This function accesses Exim's internal store (memory) manager. It gets a new
35971 chunk of memory whose size is given by the first argument.
35972 The second argument should be given as TRUE if the memory will be used for
35973 data possibly coming from an attacker (eg. the message content),
35974 FALSE if it is locally-sourced.
35975 Exim bombs out if it ever
35976 runs out of memory. See the next section for a discussion of memory handling.
35977
35978 .vitem &*void&~*store_get_perm(int,BOOL)*&
35979 This function is like &'store_get()'&, but it always gets memory from the
35980 permanent pool. See the next section for a discussion of memory handling.
35981
35982 .vitem &*uschar&~*string_copy(uschar&~*string)*&
35983 See below.
35984
35985 .vitem &*uschar&~*string_copyn(uschar&~*string,&~int&~length)*&
35986 See below.
35987
35988 .vitem &*uschar&~*string_sprintf(char&~*format,&~...)*&
35989 These three functions create strings using Exim's dynamic memory facilities.
35990 The first makes a copy of an entire string. The second copies up to a maximum
35991 number of characters, indicated by the second argument. The third uses a format
35992 and insertion arguments to create a new string. In each case, the result is a
35993 pointer to a new string in the current memory pool. See the next section for
35994 more discussion.
35995 .endlist
35996
35997
35998
35999 .section "More about Exim's memory handling" "SECTmemhanloc"
36000 .cindex "&[local_scan()]& function" "memory handling"
36001 No function is provided for freeing memory, because that is never needed.
36002 The dynamic memory that Exim uses when receiving a message is automatically
36003 recycled if another message is received by the same process (this applies only
36004 to incoming SMTP connections &-- other input methods can supply only one
36005 message at a time). After receiving the last message, a reception process
36006 terminates.
36007
36008 Because it is recycled, the normal dynamic memory cannot be used for holding
36009 data that must be preserved over a number of incoming messages on the same SMTP
36010 connection. However, Exim in fact uses two pools of dynamic memory; the second
36011 one is not recycled, and can be used for this purpose.
36012
36013 If you want to allocate memory that remains available for subsequent messages
36014 in the same SMTP connection, you should set
36015 .code
36016 store_pool = POOL_PERM
36017 .endd
36018 before calling the function that does the allocation. There is no need to
36019 restore the value if you do not need to; however, if you do want to revert to
36020 the normal pool, you can either restore the previous value of &%store_pool%& or
36021 set it explicitly to POOL_MAIN.
36022
36023 The pool setting applies to all functions that get dynamic memory, including
36024 &'expand_string()'&, &'store_get()'&, and the &'string_xxx()'& functions.
36025 There is also a convenience function called &'store_get_perm()'& that gets a
36026 block of memory from the permanent pool while preserving the value of
36027 &%store_pool%&.
36028 .ecindex IIDlosca
36029
36030
36031
36032
36033 . ////////////////////////////////////////////////////////////////////////////
36034 . ////////////////////////////////////////////////////////////////////////////
36035
36036 .chapter "System-wide message filtering" "CHAPsystemfilter"
36037 .scindex IIDsysfil1 "filter" "system filter"
36038 .scindex IIDsysfil2 "filtering all mail"
36039 .scindex IIDsysfil3 "system filter"
36040 The previous chapters (on ACLs and the local scan function) describe checks
36041 that can be applied to messages before they are accepted by a host. There is
36042 also a mechanism for checking messages once they have been received, but before
36043 they are delivered. This is called the &'system filter'&.
36044
36045 The system filter operates in a similar manner to users' filter files, but it
36046 is run just once per message (however many recipients the message has).
36047 It should not normally be used as a substitute for routing, because &%deliver%&
36048 commands in a system router provide new envelope recipient addresses.
36049 The system filter must be an Exim filter. It cannot be a Sieve filter.
36050
36051 The system filter is run at the start of a delivery attempt, before any routing
36052 is done. If a message fails to be completely delivered at the first attempt,
36053 the system filter is run again at the start of every retry.
36054 If you want your filter to do something only once per message, you can make use
36055 .cindex retry condition
36056 of the &%first_delivery%& condition in an &%if%& command in the filter to
36057 prevent it happening on retries.
36058
36059 .vindex "&$domain$&"
36060 .vindex "&$local_part$&"
36061 &*Warning*&: Because the system filter runs just once, variables that are
36062 specific to individual recipient addresses, such as &$local_part$& and
36063 &$domain$&, are not set, and the &"personal"& condition is not meaningful. If
36064 you want to run a centrally-specified filter for each recipient address
36065 independently, you can do so by setting up a suitable &(redirect)& router, as
36066 described in section &<<SECTperaddfil>>& below.
36067
36068
36069 .section "Specifying a system filter" "SECID212"
36070 .cindex "uid (user id)" "system filter"
36071 .cindex "gid (group id)" "system filter"
36072 The name of the file that contains the system filter must be specified by
36073 setting &%system_filter%&. If you want the filter to run under a uid and gid
36074 other than root, you must also set &%system_filter_user%& and
36075 &%system_filter_group%& as appropriate. For example:
36076 .code
36077 system_filter = /etc/mail/exim.filter
36078 system_filter_user = exim
36079 .endd
36080 If a system filter generates any deliveries directly to files or pipes (via the
36081 &%save%& or &%pipe%& commands), transports to handle these deliveries must be
36082 specified by setting &%system_filter_file_transport%& and
36083 &%system_filter_pipe_transport%&, respectively. Similarly,
36084 &%system_filter_reply_transport%& must be set to handle any messages generated
36085 by the &%reply%& command.
36086
36087
36088 .section "Testing a system filter" "SECID213"
36089 You can run simple tests of a system filter in the same way as for a user
36090 filter, but you should use &%-bF%& rather than &%-bf%&, so that features that
36091 are permitted only in system filters are recognized.
36092
36093 If you want to test the combined effect of a system filter and a user filter,
36094 you can use both &%-bF%& and &%-bf%& on the same command line.
36095
36096
36097
36098 .section "Contents of a system filter" "SECID214"
36099 The language used to specify system filters is the same as for users' filter
36100 files. It is described in the separate end-user document &'Exim's interface to
36101 mail filtering'&. However, there are some additional features that are
36102 available only in system filters; these are described in subsequent sections.
36103 If they are encountered in a user's filter file or when testing with &%-bf%&,
36104 they cause errors.
36105
36106 .cindex "frozen messages" "manual thaw; testing in filter"
36107 There are two special conditions which, though available in users' filter
36108 files, are designed for use in system filters. The condition &%first_delivery%&
36109 is true only for the first attempt at delivering a message, and
36110 &%manually_thawed%& is true only if the message has been frozen, and
36111 subsequently thawed by an admin user. An explicit forced delivery counts as a
36112 manual thaw, but thawing as a result of the &%auto_thaw%& setting does not.
36113
36114 &*Warning*&: If a system filter uses the &%first_delivery%& condition to
36115 specify an &"unseen"& (non-significant) delivery, and that delivery does not
36116 succeed, it will not be tried again.
36117 If you want Exim to retry an unseen delivery until it succeeds, you should
36118 arrange to set it up every time the filter runs.
36119
36120 When a system filter finishes running, the values of the variables &$n0$& &--
36121 &$n9$& are copied into &$sn0$& &-- &$sn9$& and are thereby made available to
36122 users' filter files. Thus a system filter can, for example, set up &"scores"&
36123 to which users' filter files can refer.
36124
36125
36126
36127 .section "Additional variable for system filters" "SECID215"
36128 .vindex "&$recipients$&"
36129 The expansion variable &$recipients$&, containing a list of all the recipients
36130 of the message (separated by commas and white space), is available in system
36131 filters. It is not available in users' filters for privacy reasons.
36132
36133
36134
36135 .section "Defer, freeze, and fail commands for system filters" "SECID216"
36136 .cindex "freezing messages"
36137 .cindex "message" "freezing"
36138 .cindex "message" "forced failure"
36139 .cindex "&%fail%&" "in system filter"
36140 .cindex "&%freeze%& in system filter"
36141 .cindex "&%defer%& in system filter"
36142 There are three extra commands (&%defer%&, &%freeze%& and &%fail%&) which are
36143 always available in system filters, but are not normally enabled in users'
36144 filters. (See the &%allow_defer%&, &%allow_freeze%& and &%allow_fail%& options
36145 for the &(redirect)& router.) These commands can optionally be followed by the
36146 word &%text%& and a string containing an error message, for example:
36147 .code
36148 fail text "this message looks like spam to me"
36149 .endd
36150 The keyword &%text%& is optional if the next character is a double quote.
36151
36152 The &%defer%& command defers delivery of the original recipients of the
36153 message. The &%fail%& command causes all the original recipients to be failed,
36154 and a bounce message to be created. The &%freeze%& command suspends all
36155 delivery attempts for the original recipients. In all cases, any new deliveries
36156 that are specified by the filter are attempted as normal after the filter has
36157 run.
36158
36159 The &%freeze%& command is ignored if the message has been manually unfrozen and
36160 not manually frozen since. This means that automatic freezing by a system
36161 filter can be used as a way of checking out suspicious messages. If a message
36162 is found to be all right, manually unfreezing it allows it to be delivered.
36163
36164 .cindex "log" "&%fail%& command log line"
36165 .cindex "&%fail%&" "log line; reducing"
36166 The text given with a fail command is used as part of the bounce message as
36167 well as being written to the log. If the message is quite long, this can fill
36168 up a lot of log space when such failures are common. To reduce the size of the
36169 log message, Exim interprets the text in a special way if it starts with the
36170 two characters &`<<`& and contains &`>>`& later. The text between these two
36171 strings is written to the log, and the rest of the text is used in the bounce
36172 message. For example:
36173 .code
36174 fail "<<filter test 1>>Your message is rejected \
36175      because it contains attachments that we are \
36176      not prepared to receive."
36177 .endd
36178
36179 .cindex "loop" "caused by &%fail%&"
36180 Take great care with the &%fail%& command when basing the decision to fail on
36181 the contents of the message, because the bounce message will of course include
36182 the contents of the original message and will therefore trigger the &%fail%&
36183 command again (causing a mail loop) unless steps are taken to prevent this.
36184 Testing the &%error_message%& condition is one way to prevent this. You could
36185 use, for example
36186 .code
36187 if $message_body contains "this is spam" and not error_message
36188 then fail text "spam is not wanted here" endif
36189 .endd
36190 though of course that might let through unwanted bounce messages. The
36191 alternative is clever checking of the body and/or headers to detect bounces
36192 generated by the filter.
36193
36194 The interpretation of a system filter file ceases after a
36195 &%defer%&,
36196 &%freeze%&, or &%fail%& command is obeyed. However, any deliveries that were
36197 set up earlier in the filter file are honoured, so you can use a sequence such
36198 as
36199 .code
36200 mail ...
36201 freeze
36202 .endd
36203 to send a specified message when the system filter is freezing (or deferring or
36204 failing) a message. The normal deliveries for the message do not, of course,
36205 take place.
36206
36207
36208
36209 .section "Adding and removing headers in a system filter" "SECTaddremheasys"
36210 .cindex "header lines" "adding; in system filter"
36211 .cindex "header lines" "removing; in system filter"
36212 .cindex "filter" "header lines; adding/removing"
36213 Two filter commands that are available only in system filters are:
36214 .code
36215 headers add <string>
36216 headers remove <string>
36217 .endd
36218 The argument for the &%headers add%& is a string that is expanded and then
36219 added to the end of the message's headers. It is the responsibility of the
36220 filter maintainer to make sure it conforms to RFC 2822 syntax. Leading white
36221 space is ignored, and if the string is otherwise empty, or if the expansion is
36222 forced to fail, the command has no effect.
36223
36224 You can use &"\n"& within the string, followed by white space, to specify
36225 continued header lines. More than one header may be added in one command by
36226 including &"\n"& within the string without any following white space. For
36227 example:
36228 .code
36229 headers add "X-header-1: ....\n  \
36230              continuation of X-header-1 ...\n\
36231              X-header-2: ...."
36232 .endd
36233 Note that the header line continuation white space after the first newline must
36234 be placed before the backslash that continues the input string, because white
36235 space after input continuations is ignored.
36236
36237 The argument for &%headers remove%& is a colon-separated list of header names.
36238 This command applies only to those headers that are stored with the message;
36239 those that are added at delivery time (such as &'Envelope-To:'& and
36240 &'Return-Path:'&) cannot be removed by this means. If there is more than one
36241 header with the same name, they are all removed.
36242
36243 The &%headers%& command in a system filter makes an immediate change to the set
36244 of header lines that was received with the message (with possible additions
36245 from ACL processing). Subsequent commands in the system filter operate on the
36246 modified set, which also forms the basis for subsequent message delivery.
36247 Unless further modified during routing or transporting, this set of headers is
36248 used for all recipients of the message.
36249
36250 During routing and transporting, the variables that refer to the contents of
36251 header lines refer only to those lines that are in this set. Thus, header lines
36252 that are added by a system filter are visible to users' filter files and to all
36253 routers and transports. This contrasts with the manipulation of header lines by
36254 routers and transports, which is not immediate, but which instead is saved up
36255 until the message is actually being written (see section
36256 &<<SECTheadersaddrem>>&).
36257
36258 If the message is not delivered at the first attempt, header lines that were
36259 added by the system filter are stored with the message, and so are still
36260 present at the next delivery attempt. Header lines that were removed are still
36261 present, but marked &"deleted"& so that they are not transported with the
36262 message. For this reason, it is usual to make the &%headers%& command
36263 conditional on &%first_delivery%& so that the set of header lines is not
36264 modified more than once.
36265
36266 Because header modification in a system filter acts immediately, you have to
36267 use an indirect approach if you want to modify the contents of a header line.
36268 For example:
36269 .code
36270 headers add "Old-Subject: $h_subject:"
36271 headers remove "Subject"
36272 headers add "Subject: new subject (was: $h_old-subject:)"
36273 headers remove "Old-Subject"
36274 .endd
36275
36276
36277
36278 .section "Setting an errors address in a system filter" "SECID217"
36279 .cindex "envelope from"
36280 .cindex "envelope sender"
36281 In a system filter, if a &%deliver%& command is followed by
36282 .code
36283 errors_to <some address>
36284 .endd
36285 in order to change the envelope sender (and hence the error reporting) for that
36286 delivery, any address may be specified. (In a user filter, only the current
36287 user's address can be set.) For example, if some mail is being monitored, you
36288 might use
36289 .code
36290 unseen deliver monitor@spying.example errors_to root@local.example
36291 .endd
36292 to take a copy which would not be sent back to the normal error reporting
36293 address if its delivery failed.
36294
36295
36296
36297 .section "Per-address filtering" "SECTperaddfil"
36298 .vindex "&$domain_data$&"
36299 .vindex "&$local_part_data$&"
36300 In contrast to the system filter, which is run just once per message for each
36301 delivery attempt, it is also possible to set up a system-wide filtering
36302 operation that runs once for each recipient address. In this case, variables
36303 such as &$local_part_data$& and &$domain_data$& can be used,
36304 and indeed, the choice of filter file could be made dependent on them.
36305 This is an example of a router which implements such a filter:
36306 .code
36307 central_filter:
36308   check_local_user
36309   driver = redirect
36310   domains = +local_domains
36311   file = /central/filters/$local_part_data
36312   no_verify
36313   allow_filter
36314   allow_freeze
36315 .endd
36316 The filter is run in a separate process under its own uid. Therefore, either
36317 &%check_local_user%& must be set (as above), in which case the filter is run as
36318 the local user, or the &%user%& option must be used to specify which user to
36319 use. If both are set, &%user%& overrides.
36320
36321 Care should be taken to ensure that none of the commands in the filter file
36322 specify a significant delivery if the message is to go on to be delivered to
36323 its intended recipient. The router will not then claim to have dealt with the
36324 address, so it will be passed on to subsequent routers to be delivered in the
36325 normal way.
36326 .ecindex IIDsysfil1
36327 .ecindex IIDsysfil2
36328 .ecindex IIDsysfil3
36329
36330
36331
36332
36333
36334
36335 . ////////////////////////////////////////////////////////////////////////////
36336 . ////////////////////////////////////////////////////////////////////////////
36337
36338 .chapter "Message processing" "CHAPmsgproc"
36339 .scindex IIDmesproc "message" "general processing"
36340 Exim performs various transformations on the sender and recipient addresses of
36341 all messages that it handles, and also on the messages' header lines. Some of
36342 these are optional and configurable, while others always take place. All of
36343 this processing, except rewriting as a result of routing, and the addition or
36344 removal of header lines while delivering, happens when a message is received,
36345 before it is placed on Exim's queue.
36346
36347 Some of the automatic processing takes place by default only for
36348 &"locally-originated"& messages. This adjective is used to describe messages
36349 that are not received over TCP/IP, but instead are passed to an Exim process on
36350 its standard input. This includes the interactive &"local SMTP"& case that is
36351 set up by the &%-bs%& command line option.
36352
36353 &*Note*&: Messages received over TCP/IP on the loopback interface (127.0.0.1
36354 or ::1) are not considered to be locally-originated. Exim does not treat the
36355 loopback interface specially in any way.
36356
36357 If you want the loopback interface to be treated specially, you must ensure
36358 that there are appropriate entries in your ACLs.
36359
36360
36361
36362
36363 .section "Submission mode for non-local messages" "SECTsubmodnon"
36364 .cindex "message" "submission"
36365 .cindex "submission mode"
36366 Processing that happens automatically for locally-originated messages (unless
36367 &%suppress_local_fixups%& is set) can also be requested for messages that are
36368 received over TCP/IP. The term &"submission mode"& is used to describe this
36369 state. Submission mode is set by the modifier
36370 .code
36371 control = submission
36372 .endd
36373 in a MAIL, RCPT, or pre-data ACL for an incoming message (see sections
36374 &<<SECTACLmodi>>& and &<<SECTcontrols>>&). This makes Exim treat the message as
36375 a local submission, and is normally used when the source of the message is
36376 known to be an MUA running on a client host (as opposed to an MTA). For
36377 example, to set submission mode for messages originating on the IPv4 loopback
36378 interface, you could include the following in the MAIL ACL:
36379 .code
36380 warn  hosts = 127.0.0.1
36381       control = submission
36382 .endd
36383 .cindex "&%sender_retain%& submission option"
36384 There are some options that can be used when setting submission mode. A slash
36385 is used to separate options. For example:
36386 .code
36387 control = submission/sender_retain
36388 .endd
36389 Specifying &%sender_retain%& has the effect of setting &%local_sender_retain%&
36390 true and &%local_from_check%& false for the current incoming message. The first
36391 of these allows an existing &'Sender:'& header in the message to remain, and
36392 the second suppresses the check to ensure that &'From:'& matches the
36393 authenticated sender. With this setting, Exim still fixes up messages by adding
36394 &'Date:'& and &'Message-ID:'& header lines if they are missing, but makes no
36395 attempt to check sender authenticity in header lines.
36396
36397 When &%sender_retain%& is not set, a submission mode setting may specify a
36398 domain to be used when generating a &'From:'& or &'Sender:'& header line. For
36399 example:
36400 .code
36401 control = submission/domain=some.domain
36402 .endd
36403 The domain may be empty. How this value is used is described in sections
36404 &<<SECTthefrohea>>& and &<<SECTthesenhea>>&. There is also a &%name%& option
36405 that allows you to specify the user's full name for inclusion in a created
36406 &'Sender:'& or &'From:'& header line. For example:
36407 .code
36408 accept authenticated = *
36409        control = submission/domain=wonderland.example/\
36410                             name=${lookup {$authenticated_id} \
36411                                    lsearch {/etc/exim/namelist}}
36412 .endd
36413 Because the name may contain any characters, including slashes, the &%name%&
36414 option must be given last. The remainder of the string is used as the name. For
36415 the example above, if &_/etc/exim/namelist_& contains:
36416 .code
36417 bigegg:  Humpty Dumpty
36418 .endd
36419 then when the sender has authenticated as &'bigegg'&, the generated &'Sender:'&
36420 line would be:
36421 .code
36422 Sender: Humpty Dumpty <bigegg@wonderland.example>
36423 .endd
36424 .cindex "return path" "in submission mode"
36425 By default, submission mode forces the return path to the same address as is
36426 used to create the &'Sender:'& header. However, if &%sender_retain%& is
36427 specified, the return path is also left unchanged.
36428
36429 &*Note*&: The changes caused by submission mode take effect after the predata
36430 ACL. This means that any sender checks performed before the fix-ups use the
36431 untrusted sender address specified by the user, not the trusted sender address
36432 specified by submission mode. Although this might be slightly unexpected, it
36433 does mean that you can configure ACL checks to spot that a user is trying to
36434 spoof another's address.
36435
36436 .section "Line endings" "SECTlineendings"
36437 .cindex "line endings"
36438 .cindex "carriage return"
36439 .cindex "linefeed"
36440 RFC 2821 specifies that CRLF (two characters: carriage-return, followed by
36441 linefeed) is the line ending for messages transmitted over the Internet using
36442 SMTP over TCP/IP. However, within individual operating systems, different
36443 conventions are used. For example, Unix-like systems use just LF, but others
36444 use CRLF or just CR.
36445
36446 Exim was designed for Unix-like systems, and internally, it stores messages
36447 using the system's convention of a single LF as a line terminator. When
36448 receiving a message, all line endings are translated to this standard format.
36449 Originally, it was thought that programs that passed messages directly to an
36450 MTA within an operating system would use that system's convention. Experience
36451 has shown that this is not the case; for example, there are Unix applications
36452 that use CRLF in this circumstance. For this reason, and for compatibility with
36453 other MTAs, the way Exim handles line endings for all messages is now as
36454 follows:
36455
36456 .ilist
36457 LF not preceded by CR is treated as a line ending.
36458 .next
36459 CR is treated as a line ending; if it is immediately followed by LF, the LF
36460 is ignored.
36461 .next
36462 The sequence &"CR, dot, CR"& does not terminate an incoming SMTP message,
36463 nor a local message in the state where a line containing only a dot is a
36464 terminator.
36465 .next
36466 If a bare CR is encountered within a header line, an extra space is added after
36467 the line terminator so as not to end the header line. The reasoning behind this
36468 is that bare CRs in header lines are most likely either to be mistakes, or
36469 people trying to play silly games.
36470 .next
36471 If the first header line received in a message ends with CRLF, a subsequent
36472 bare LF in a header line is treated in the same way as a bare CR in a header
36473 line.
36474 .endlist
36475
36476
36477
36478
36479
36480 .section "Unqualified addresses" "SECID218"
36481 .cindex "unqualified addresses"
36482 .cindex "address" "qualification"
36483 By default, Exim expects every envelope address it receives from an external
36484 host to be fully qualified. Unqualified addresses cause negative responses to
36485 SMTP commands. However, because SMTP is used as a means of transporting
36486 messages from MUAs running on personal workstations, there is sometimes a
36487 requirement to accept unqualified addresses from specific hosts or IP networks.
36488
36489 Exim has two options that separately control which hosts may send unqualified
36490 sender or recipient addresses in SMTP commands, namely
36491 &%sender_unqualified_hosts%& and &%recipient_unqualified_hosts%&. In both
36492 cases, if an unqualified address is accepted, it is qualified by adding the
36493 value of &%qualify_domain%& or &%qualify_recipient%&, as appropriate.
36494
36495 .oindex "&%qualify_domain%&"
36496 .oindex "&%qualify_recipient%&"
36497 Unqualified addresses in header lines are automatically qualified for messages
36498 that are locally originated, unless the &%-bnq%& option is given on the command
36499 line. For messages received over SMTP, unqualified addresses in header lines
36500 are qualified only if unqualified addresses are permitted in SMTP commands. In
36501 other words, such qualification is also controlled by
36502 &%sender_unqualified_hosts%& and &%recipient_unqualified_hosts%&,
36503
36504
36505
36506
36507 .section "The UUCP From line" "SECID219"
36508 .cindex "&""From""& line"
36509 .cindex "UUCP" "&""From""& line"
36510 .cindex "sender" "address"
36511 .oindex "&%uucp_from_pattern%&"
36512 .oindex "&%uucp_from_sender%&"
36513 .cindex "envelope from"
36514 .cindex "envelope sender"
36515 .cindex "Sendmail compatibility" "&""From""& line"
36516 Messages that have come from UUCP (and some other applications) often begin
36517 with a line containing the envelope sender and a timestamp, following the word
36518 &"From"&. Examples of two common formats are:
36519 .code
36520 From a.oakley@berlin.mus Fri Jan  5 12:35 GMT 1996
36521 From f.butler@berlin.mus Fri, 7 Jan 97 14:00:00 GMT
36522 .endd
36523 This line precedes the RFC 2822 header lines. For compatibility with Sendmail,
36524 Exim recognizes such lines at the start of messages that are submitted to it
36525 via the command line (that is, on the standard input). It does not recognize
36526 such lines in incoming SMTP messages, unless the sending host matches
36527 &%ignore_fromline_hosts%& or the &%-bs%& option was used for a local message
36528 and &%ignore_fromline_local%& is set. The recognition is controlled by a
36529 regular expression that is defined by the &%uucp_from_pattern%& option, whose
36530 default value matches the two common cases shown above and puts the address
36531 that follows &"From"& into &$1$&.
36532
36533 .cindex "numerical variables (&$1$& &$2$& etc)" "in &""From ""& line handling"
36534 When the caller of Exim for a non-SMTP message that contains a &"From"& line is
36535 a trusted user, the message's sender address is constructed by expanding the
36536 contents of &%uucp_sender_address%&, whose default value is &"$1"&. This is
36537 then parsed as an RFC 2822 address. If there is no domain, the local part is
36538 qualified with &%qualify_domain%& unless it is the empty string. However, if
36539 the command line &%-f%& option is used, it overrides the &"From"& line.
36540
36541 If the caller of Exim is not trusted, the &"From"& line is recognized, but the
36542 sender address is not changed. This is also the case for incoming SMTP messages
36543 that are permitted to contain &"From"& lines.
36544
36545 Only one &"From"& line is recognized. If there is more than one, the second is
36546 treated as a data line that starts the body of the message, as it is not valid
36547 as a header line. This also happens if a &"From"& line is present in an
36548 incoming SMTP message from a source that is not permitted to send them.
36549
36550
36551
36552 .section "Header lines"
36553 .subsection "Resent- header lines" SECID220
36554 .chindex Resent-
36555 RFC 2822 makes provision for sets of header lines starting with the string
36556 &`Resent-`& to be added to a message when it is resent by the original
36557 recipient to somebody else. These headers are &'Resent-Date:'&,
36558 &'Resent-From:'&, &'Resent-Sender:'&, &'Resent-To:'&, &'Resent-Cc:'&,
36559 &'Resent-Bcc:'& and &'Resent-Message-ID:'&. The RFC says:
36560
36561 .blockquote
36562 &'Resent fields are strictly informational. They MUST NOT be used in the normal
36563 processing of replies or other such automatic actions on messages.'&
36564 .endblockquote
36565
36566 This leaves things a bit vague as far as other processing actions such as
36567 address rewriting are concerned. Exim treats &%Resent-%& header lines as
36568 follows:
36569
36570 .ilist
36571 A &'Resent-From:'& line that just contains the login id of the submitting user
36572 is automatically rewritten in the same way as &'From:'& (see below).
36573 .next
36574 If there's a rewriting rule for a particular header line, it is also applied to
36575 &%Resent-%& header lines of the same type. For example, a rule that rewrites
36576 &'From:'& also rewrites &'Resent-From:'&.
36577 .next
36578 For local messages, if &'Sender:'& is removed on input, &'Resent-Sender:'& is
36579 also removed.
36580 .next
36581 For a locally-submitted message,
36582 if there are any &%Resent-%& header lines but no &'Resent-Date:'&,
36583 &'Resent-From:'&, or &'Resent-Message-Id:'&, they are added as necessary. It is
36584 the contents of &'Resent-Message-Id:'& (rather than &'Message-Id:'&) which are
36585 included in log lines in this case.
36586 .next
36587 The logic for adding &'Sender:'& is duplicated for &'Resent-Sender:'& when any
36588 &%Resent-%& header lines are present.
36589 .endlist
36590
36591
36592
36593
36594 .subsection Auto-Submitted: SECID221
36595 Whenever Exim generates an autoreply, a bounce, or a delay warning message, it
36596 includes the header line:
36597 .code
36598 Auto-Submitted: auto-replied
36599 .endd
36600
36601 .subsection Bcc: SECID222
36602 .cindex "&'Bcc:'& header line"
36603 If Exim is called with the &%-t%& option, to take recipient addresses from a
36604 message's header, it removes any &'Bcc:'& header line that may exist (after
36605 extracting its addresses). If &%-t%& is not present on the command line, any
36606 existing &'Bcc:'& is not removed.
36607
36608
36609 .subsection Date: SECID223
36610 .cindex Date:
36611 If a locally-generated or submission-mode message has no &'Date:'& header line,
36612 Exim adds one, using the current date and time, unless the
36613 &%suppress_local_fixups%& control has been specified.
36614
36615 .subsection Delivery-date: SECID224
36616 .cindex "&'Delivery-date:'& header line"
36617 .oindex "&%delivery_date_remove%&"
36618 &'Delivery-date:'& header lines are not part of the standard RFC 2822 header
36619 set. Exim can be configured to add them to the final delivery of messages. (See
36620 the generic &%delivery_date_add%& transport option.) They should not be present
36621 in messages in transit. If the &%delivery_date_remove%& configuration option is
36622 set (the default), Exim removes &'Delivery-date:'& header lines from incoming
36623 messages.
36624
36625
36626 .subsection Envelope-to: SECID225
36627 .chindex Envelope-to:
36628 .oindex "&%envelope_to_remove%&"
36629 &'Envelope-to:'& header lines are not part of the standard RFC 2822 header set.
36630 Exim can be configured to add them to the final delivery of messages. (See the
36631 generic &%envelope_to_add%& transport option.) They should not be present in
36632 messages in transit. If the &%envelope_to_remove%& configuration option is set
36633 (the default), Exim removes &'Envelope-to:'& header lines from incoming
36634 messages.
36635
36636
36637 .subsection From: SECTthefrohea
36638 .chindex From:
36639 .cindex "Sendmail compatibility" "&""From""& line"
36640 .cindex "message" "submission"
36641 .cindex "submission mode"
36642 If a submission-mode message does not contain a &'From:'& header line, Exim
36643 adds one if either of the following conditions is true:
36644
36645 .ilist
36646 The envelope sender address is not empty (that is, this is not a bounce
36647 message). The added header line copies the envelope sender address.
36648 .next
36649 .vindex "&$authenticated_id$&"
36650 The SMTP session is authenticated and &$authenticated_id$& is not empty.
36651 .olist
36652 .vindex "&$qualify_domain$&"
36653 If no domain is specified by the submission control, the local part is
36654 &$authenticated_id$& and the domain is &$qualify_domain$&.
36655 .next
36656 If a non-empty domain is specified by the submission control, the local
36657 part is &$authenticated_id$&, and the domain is the specified domain.
36658 .next
36659 If an empty domain is specified by the submission control,
36660 &$authenticated_id$& is assumed to be the complete address.
36661 .endlist
36662 .endlist
36663
36664 A non-empty envelope sender takes precedence.
36665
36666 If a locally-generated incoming message does not contain a &'From:'& header
36667 line, and the &%suppress_local_fixups%& control is not set, Exim adds one
36668 containing the sender's address. The calling user's login name and full name
36669 are used to construct the address, as described in section &<<SECTconstr>>&.
36670 They are obtained from the password data by calling &[getpwuid()]& (but see the
36671 &%unknown_login%& configuration option). The address is qualified with
36672 &%qualify_domain%&.
36673
36674 For compatibility with Sendmail, if an incoming, non-SMTP message has a
36675 &'From:'& header line containing just the unqualified login name of the calling
36676 user, this is replaced by an address containing the user's login name and full
36677 name as described in section &<<SECTconstr>>&.
36678
36679
36680 .subsection Message-ID: SECID226
36681 .chindex Message-ID:
36682 .cindex "message" "submission"
36683 .oindex "&%message_id_header_text%&"
36684 If a locally-generated or submission-mode incoming message does not contain a
36685 &'Message-ID:'& or &'Resent-Message-ID:'& header line, and the
36686 &%suppress_local_fixups%& control is not set, Exim adds a suitable header line
36687 to the message. If there are any &'Resent-:'& headers in the message, it
36688 creates &'Resent-Message-ID:'&. The id is constructed from Exim's internal
36689 message id, preceded by the letter E to ensure it starts with a letter, and
36690 followed by @ and the primary host name. Additional information can be included
36691 in this header line by setting the &%message_id_header_text%& and/or
36692 &%message_id_header_domain%& options.
36693
36694
36695 .subsection Received: SECID227
36696 .chindex Received:
36697 A &'Received:'& header line is added at the start of every message. The
36698 contents are defined by the &%received_header_text%& configuration option, and
36699 Exim automatically adds a semicolon and a timestamp to the configured string.
36700
36701 The &'Received:'& header is generated as soon as the message's header lines
36702 have been received. At this stage, the timestamp in the &'Received:'& header
36703 line is the time that the message started to be received. This is the value
36704 that is seen by the DATA ACL and by the &[local_scan()]& function.
36705
36706 Once a message is accepted, the timestamp in the &'Received:'& header line is
36707 changed to the time of acceptance, which is (apart from a small delay while the
36708 -H spool file is written) the earliest time at which delivery could start.
36709
36710
36711 .subsection References: SECID228
36712 .chindex References:
36713 Messages created by the &(autoreply)& transport include a &'References:'&
36714 header line. This is constructed according to the rules that are described in
36715 section 3.64 of RFC 2822 (which states that replies should contain such a
36716 header line), and section 3.14 of RFC 3834 (which states that automatic
36717 responses are not different in this respect). However, because some mail
36718 processing software does not cope well with very long header lines, no more
36719 than 12 message IDs are copied from the &'References:'& header line in the
36720 incoming message. If there are more than 12, the first one and then the final
36721 11 are copied, before adding the message ID of the incoming message.
36722
36723
36724
36725 .subsection Return-path: SECID229
36726 .chindex Return-path:
36727 .oindex "&%return_path_remove%&"
36728 &'Return-path:'& header lines are defined as something an MTA may insert when
36729 it does the final delivery of messages. (See the generic &%return_path_add%&
36730 transport option.) Therefore, they should not be present in messages in
36731 transit. If the &%return_path_remove%& configuration option is set (the
36732 default), Exim removes &'Return-path:'& header lines from incoming messages.
36733
36734
36735
36736 .subsection Sender: SECTthesenhea
36737 .cindex "&'Sender:'& header line"
36738 .cindex "message" "submission"
36739 .chindex Sender:
36740 For a locally-originated message from an untrusted user, Exim may remove an
36741 existing &'Sender:'& header line, and it may add a new one. You can modify
36742 these actions by setting the &%local_sender_retain%& option true, the
36743 &%local_from_check%& option false, or by using the &%suppress_local_fixups%&
36744 control setting.
36745
36746 When a local message is received from an untrusted user and
36747 &%local_from_check%& is true (the default), and the &%suppress_local_fixups%&
36748 control has not been set, a check is made to see if the address given in the
36749 &'From:'& header line is the correct (local) sender of the message. The address
36750 that is expected has the login name as the local part and the value of
36751 &%qualify_domain%& as the domain. Prefixes and suffixes for the local part can
36752 be permitted by setting &%local_from_prefix%& and &%local_from_suffix%&
36753 appropriately. If &'From:'& does not contain the correct sender, a &'Sender:'&
36754 line is added to the message.
36755
36756 If you set &%local_from_check%& false, this checking does not occur. However,
36757 the removal of an existing &'Sender:'& line still happens, unless you also set
36758 &%local_sender_retain%& to be true. It is not possible to set both of these
36759 options true at the same time.
36760
36761 .cindex "submission mode"
36762 By default, no processing of &'Sender:'& header lines is done for messages
36763 received over TCP/IP or for messages submitted by trusted users. However, when
36764 a message is received over TCP/IP in submission mode, and &%sender_retain%& is
36765 not specified on the submission control, the following processing takes place:
36766
36767 .vindex "&$authenticated_id$&"
36768 First, any existing &'Sender:'& lines are removed. Then, if the SMTP session is
36769 authenticated, and &$authenticated_id$& is not empty, a sender address is
36770 created as follows:
36771
36772 .ilist
36773 .vindex "&$qualify_domain$&"
36774 If no domain is specified by the submission control, the local part is
36775 &$authenticated_id$& and the domain is &$qualify_domain$&.
36776 .next
36777 If a non-empty domain is specified by the submission control, the local part
36778 is &$authenticated_id$&, and the domain is the specified domain.
36779 .next
36780 If an empty domain is specified by the submission control,
36781 &$authenticated_id$& is assumed to be the complete address.
36782 .endlist
36783
36784 This address is compared with the address in the &'From:'& header line. If they
36785 are different, a &'Sender:'& header line containing the created address is
36786 added. Prefixes and suffixes for the local part in &'From:'& can be permitted
36787 by setting &%local_from_prefix%& and &%local_from_suffix%& appropriately.
36788
36789 .cindex "return path" "created from &'Sender:'&"
36790 &*Note*&: Whenever a &'Sender:'& header line is created, the return path for
36791 the message (the envelope sender address) is changed to be the same address,
36792 except in the case of submission mode when &%sender_retain%& is specified.
36793
36794
36795
36796 .section "Adding and removing header lines in routers and transports" &&&
36797          "SECTheadersaddrem"
36798 .cindex "header lines" "adding; in router or transport"
36799 .cindex "header lines" "removing; in router or transport"
36800 When a message is delivered, the addition and removal of header lines can be
36801 specified in a system filter, or on any of the routers and transports that
36802 process the message. Section &<<SECTaddremheasys>>& contains details about
36803 modifying headers in a system filter. Header lines can also be added in an ACL
36804 as a message is received (see section &<<SECTaddheadacl>>&).
36805
36806 In contrast to what happens in a system filter, header modifications that are
36807 specified on routers and transports apply only to the particular recipient
36808 addresses that are being processed by those routers and transports. These
36809 changes do not actually take place until a copy of the message is being
36810 transported. Therefore, they do not affect the basic set of header lines, and
36811 they do not affect the values of the variables that refer to header lines.
36812
36813 &*Note*&: In particular, this means that any expansions in the configuration of
36814 the transport cannot refer to the modified header lines, because such
36815 expansions all occur before the message is actually transported.
36816
36817 For both routers and transports, the argument of a &%headers_add%&
36818 option must be in the form of one or more RFC 2822 header lines, separated by
36819 newlines (coded as &"\n"&). For example:
36820 .code
36821 headers_add = X-added-header: added by $primary_hostname\n\
36822               X-added-second: another added header line
36823 .endd
36824 Exim does not check the syntax of these added header lines.
36825
36826 Multiple &%headers_add%& options for a single router or transport can be
36827 specified; the values will append to a single list of header lines.
36828 Each header-line is separately expanded.
36829
36830 The argument of a &%headers_remove%& option must consist of a colon-separated
36831 list of header names. This is confusing, because header names themselves are
36832 often terminated by colons. In this case, the colons are the list separators,
36833 not part of the names. For example:
36834 .code
36835 headers_remove = return-receipt-to:acknowledge-to
36836 .endd
36837
36838 Multiple &%headers_remove%& options for a single router or transport can be
36839 specified; the arguments will append to a single header-names list.
36840 Each item is separately expanded.
36841 Note that colons in complex expansions which are used to
36842 form all or part of a &%headers_remove%& list
36843 will act as list separators.
36844
36845 When &%headers_add%& or &%headers_remove%& is specified on a router,
36846 items are expanded at routing time,
36847 and then associated with all addresses that are
36848 accepted by that router, and also with any new addresses that it generates. If
36849 an address passes through several routers as a result of aliasing or
36850 forwarding, the changes are cumulative.
36851
36852 .oindex "&%unseen%&"
36853 However, this does not apply to multiple routers that result from the use of
36854 the &%unseen%& option. Any header modifications that were specified by the
36855 &"unseen"& router or its predecessors apply only to the &"unseen"& delivery.
36856
36857 Addresses that end up with different &%headers_add%& or &%headers_remove%&
36858 settings cannot be delivered together in a batch, so a transport is always
36859 dealing with a set of addresses that have the same header-processing
36860 requirements.
36861
36862 The transport starts by writing the original set of header lines that arrived
36863 with the message, possibly modified by the system filter. As it writes out
36864 these lines, it consults the list of header names that were attached to the
36865 recipient address(es) by &%headers_remove%& options in routers, and it also
36866 consults the transport's own &%headers_remove%& option. Header lines whose
36867 names are on either of these lists are not written out. If there are multiple
36868 instances of any listed header, they are all skipped.
36869
36870 After the remaining original header lines have been written, new header
36871 lines that were specified by routers' &%headers_add%& options are written, in
36872 the order in which they were attached to the address. These are followed by any
36873 header lines specified by the transport's &%headers_add%& option.
36874
36875 This way of handling header line modifications in routers and transports has
36876 the following consequences:
36877
36878 .ilist
36879 The original set of header lines, possibly modified by the system filter,
36880 remains &"visible"&, in the sense that the &$header_$&&'xxx'& variables refer
36881 to it, at all times.
36882 .next
36883 Header lines that are added by a router's
36884 &%headers_add%& option are not accessible by means of the &$header_$&&'xxx'&
36885 expansion syntax in subsequent routers or the transport.
36886 .next
36887 Conversely, header lines that are specified for removal by &%headers_remove%&
36888 in a router remain visible to subsequent routers and the transport.
36889 .next
36890 Headers added to an address by &%headers_add%& in a router cannot be removed by
36891 a later router or by a transport.
36892 .next
36893 An added header can refer to the contents of an original header that is to be
36894 removed, even it has the same name as the added header. For example:
36895 .code
36896 headers_remove = subject
36897 headers_add = Subject: new subject (was: $h_subject:)
36898 .endd
36899 .endlist
36900
36901 &*Warning*&: The &%headers_add%& and &%headers_remove%& options cannot be used
36902 for a &(redirect)& router that has the &%one_time%& option set.
36903
36904
36905
36906
36907
36908 .section "Constructed addresses" "SECTconstr"
36909 .cindex "address" "constructed"
36910 .cindex "constructed address"
36911 When Exim constructs a sender address for a locally-generated message, it uses
36912 the form
36913 .display
36914 <&'user name'&>&~&~<&'login'&&`@`&&'qualify_domain'&>
36915 .endd
36916 For example:
36917 .code
36918 Zaphod Beeblebrox <zaphod@end.univ.example>
36919 .endd
36920 The user name is obtained from the &%-F%& command line option if set, or
36921 otherwise by looking up the calling user by &[getpwuid()]& and extracting the
36922 &"gecos"& field from the password entry. If the &"gecos"& field contains an
36923 ampersand character, this is replaced by the login name with the first letter
36924 upper cased, as is conventional in a number of operating systems. See the
36925 &%gecos_name%& option for a way to tailor the handling of the &"gecos"& field.
36926 The &%unknown_username%& option can be used to specify user names in cases when
36927 there is no password file entry.
36928
36929 .cindex "RFC 2047"
36930 In all cases, the user name is made to conform to RFC 2822 by quoting all or
36931 parts of it if necessary. In addition, if it contains any non-printing
36932 characters, it is encoded as described in RFC 2047, which defines a way of
36933 including non-ASCII characters in header lines. The value of the
36934 &%headers_charset%& option specifies the name of the encoding that is used (the
36935 characters are assumed to be in this encoding). The setting of
36936 &%print_topbitchars%& controls whether characters with the top bit set (that
36937 is, with codes greater than 127) count as printing characters or not.
36938
36939
36940
36941 .section "Case of local parts" "SECID230"
36942 .cindex "case of local parts"
36943 .cindex "local part" "case of"
36944 RFC 2822 states that the case of letters in the local parts of addresses cannot
36945 be assumed to be non-significant. Exim preserves the case of local parts of
36946 addresses, but by default it uses a lower-cased form when it is routing,
36947 because on most Unix systems, usernames are in lower case and case-insensitive
36948 routing is required. However, any particular router can be made to use the
36949 original case for local parts by setting the &%caseful_local_part%& generic
36950 router option.
36951
36952 .cindex "mixed-case login names"
36953 If you must have mixed-case user names on your system, the best way to proceed,
36954 assuming you want case-independent handling of incoming email, is to set up
36955 your first router to convert incoming local parts in your domains to the
36956 correct case by means of a file lookup. For example:
36957 .code
36958 correct_case:
36959   driver = redirect
36960   domains = +local_domains
36961   data = ${lookup{$local_part}cdb\
36962               {/etc/usercased.cdb}{$value}fail}\
36963               @$domain
36964 .endd
36965 For this router, the local part is forced to lower case by the default action
36966 (&%caseful_local_part%& is not set). The lower-cased local part is used to look
36967 up a new local part in the correct case. If you then set &%caseful_local_part%&
36968 on any subsequent routers which process your domains, they will operate on
36969 local parts with the correct case in a case-sensitive manner.
36970
36971
36972
36973 .section "Dots in local parts" "SECID231"
36974 .cindex "dot" "in local part"
36975 .cindex "local part" "dots in"
36976 RFC 2822 forbids empty components in local parts. That is, an unquoted local
36977 part may not begin or end with a dot, nor have two consecutive dots in the
36978 middle. However, it seems that many MTAs do not enforce this, so Exim permits
36979 empty components for compatibility.
36980
36981
36982
36983 .section "Rewriting addresses" "SECID232"
36984 .cindex "rewriting" "addresses"
36985 Rewriting of sender and recipient addresses, and addresses in headers, can
36986 happen automatically, or as the result of configuration options, as described
36987 in chapter &<<CHAPrewrite>>&. The headers that may be affected by this are
36988 &'Bcc:'&, &'Cc:'&, &'From:'&, &'Reply-To:'&, &'Sender:'&, and &'To:'&.
36989
36990 Automatic rewriting includes qualification, as mentioned above. The other case
36991 in which it can happen is when an incomplete non-local domain is given. The
36992 routing process may cause this to be expanded into the full domain name. For
36993 example, a header such as
36994 .code
36995 To: hare@teaparty
36996 .endd
36997 might get rewritten as
36998 .code
36999 To: hare@teaparty.wonderland.fict.example
37000 .endd
37001 Rewriting as a result of routing is the one kind of message processing that
37002 does not happen at input time, as it cannot be done until the address has
37003 been routed.
37004
37005 Strictly, one should not do &'any'& deliveries of a message until all its
37006 addresses have been routed, in case any of the headers get changed as a
37007 result of routing. However, doing this in practice would hold up many
37008 deliveries for unreasonable amounts of time, just because one address could not
37009 immediately be routed. Exim therefore does not delay other deliveries when
37010 routing of one or more addresses is deferred.
37011 .ecindex IIDmesproc
37012
37013
37014
37015 . ////////////////////////////////////////////////////////////////////////////
37016 . ////////////////////////////////////////////////////////////////////////////
37017
37018 .chapter "SMTP processing" "CHAPSMTP"
37019 .scindex IIDsmtpproc1 "SMTP" "processing details"
37020 .scindex IIDsmtpproc2 "LMTP" "processing details"
37021 Exim supports a number of different ways of using the SMTP protocol, and its
37022 LMTP variant, which is an interactive protocol for transferring messages into a
37023 closed mail store application. This chapter contains details of how SMTP is
37024 processed. For incoming mail, the following are available:
37025
37026 .ilist
37027 SMTP over TCP/IP (Exim daemon or &'inetd'&);
37028 .next
37029 SMTP over the standard input and output (the &%-bs%& option);
37030 .next
37031 Batched SMTP on the standard input (the &%-bS%& option).
37032 .endlist
37033
37034 For mail delivery, the following are available:
37035
37036 .ilist
37037 SMTP over TCP/IP (the &(smtp)& transport);
37038 .next
37039 LMTP over TCP/IP (the &(smtp)& transport with the &%protocol%& option set to
37040 &"lmtp"&);
37041 .next
37042 LMTP over a pipe to a process running in the local host (the &(lmtp)&
37043 transport);
37044 .next
37045 Batched SMTP to a file or pipe (the &(appendfile)& and &(pipe)& transports with
37046 the &%use_bsmtp%& option set).
37047 .endlist
37048
37049 &'Batched SMTP'& is the name for a process in which batches of messages are
37050 stored in or read from files (or pipes), in a format in which SMTP commands are
37051 used to contain the envelope information.
37052
37053
37054
37055 .section "Outgoing SMTP and LMTP over TCP/IP" "SECToutSMTPTCP"
37056 .cindex "SMTP" "outgoing over TCP/IP"
37057 .cindex "outgoing SMTP over TCP/IP"
37058 .cindex "LMTP" "over TCP/IP"
37059 .cindex "outgoing LMTP over TCP/IP"
37060 .cindex "EHLO"
37061 .cindex "HELO"
37062 .cindex "SIZE" "option on MAIL command"
37063 Outgoing SMTP and LMTP over TCP/IP is implemented by the &(smtp)& transport.
37064 The &%protocol%& option selects which protocol is to be used, but the actual
37065 processing is the same in both cases.
37066
37067 .cindex "ESMTP extensions" SIZE
37068 If, in response to its EHLO command, Exim is told that the SIZE
37069 extension is supported, it adds SIZE=<&'n'&> to each subsequent MAIL
37070 command. The value of <&'n'&> is the message size plus the value of the
37071 &%size_addition%& option (default 1024) to allow for additions to the message
37072 such as per-transport header lines, or changes made in a
37073 .cindex "transport" "filter"
37074 .cindex "filter" "transport filter"
37075 transport filter. If &%size_addition%& is set negative, the use of SIZE is
37076 suppressed.
37077
37078 If the remote server advertises support for PIPELINING, Exim uses the
37079 pipelining extension to SMTP (RFC 2197) to reduce the number of TCP/IP packets
37080 required for the transaction.
37081
37082 If the remote server advertises support for the STARTTLS command, and Exim
37083 was built to support TLS encryption, it tries to start a TLS session unless the
37084 server matches &%hosts_avoid_tls%&. See chapter &<<CHAPTLS>>& for more details.
37085 Either a match in that or &%hosts_verify_avoid_tls%& apply when the transport
37086 is called for verification.
37087
37088 If the remote server advertises support for the AUTH command, Exim scans
37089 the authenticators configuration for any suitable client settings, as described
37090 in chapter &<<CHAPSMTPAUTH>>&.
37091
37092 .cindex "carriage return"
37093 .cindex "linefeed"
37094 Responses from the remote host are supposed to be terminated by CR followed by
37095 LF. However, there are known to be hosts that do not send CR characters, so in
37096 order to be able to interwork with such hosts, Exim treats LF on its own as a
37097 line terminator.
37098
37099 If a message contains a number of different addresses, all those with the same
37100 characteristics (for example, the same envelope sender) that resolve to the
37101 same set of hosts, in the same order, are sent in a single SMTP transaction,
37102 even if they are for different domains, unless there are more than the setting
37103 of the &%max_rcpt%&s option in the &(smtp)& transport allows, in which case
37104 they are split into groups containing no more than &%max_rcpt%&s addresses
37105 each. If &%remote_max_parallel%& is greater than one, such groups may be sent
37106 in parallel sessions. The order of hosts with identical MX values is not
37107 significant when checking whether addresses can be batched in this way.
37108
37109 When the &(smtp)& transport suffers a temporary failure that is not
37110 message-related, Exim updates its transport-specific database, which contains
37111 records indexed by host name that remember which messages are waiting for each
37112 particular host. It also updates the retry database with new retry times.
37113
37114 .cindex "hints database" "retry keys"
37115 Exim's retry hints are based on host name plus IP address, so if one address of
37116 a multi-homed host is broken, it will soon be skipped most of the time.
37117 See the next section for more detail about error handling.
37118
37119 .cindex "SMTP" "passed connection"
37120 .cindex "SMTP" "batching over TCP/IP"
37121 When a message is successfully delivered over a TCP/IP SMTP connection, Exim
37122 looks in the hints database for the transport to see if there are any queued
37123 messages waiting for the host to which it is connected. If it finds one, it
37124 creates a new Exim process using the &%-MC%& option (which can only be used by
37125 a process running as root or the Exim user) and passes the TCP/IP socket to it
37126 so that it can deliver another message using the same socket. The new process
37127 does only those deliveries that are routed to the connected host, and may in
37128 turn pass the socket on to a third process, and so on.
37129
37130 The &%connection_max_messages%& option of the &(smtp)& transport can be used to
37131 limit the number of messages sent down a single TCP/IP connection.
37132
37133 .cindex "asterisk" "after IP address"
37134 The second and subsequent messages delivered down an existing connection are
37135 identified in the main log by the addition of an asterisk after the closing
37136 square bracket of the IP address.
37137
37138
37139
37140
37141 .subsection "Errors in outgoing SMTP" SECToutSMTPerr
37142 .cindex "error" "in outgoing SMTP"
37143 .cindex "SMTP" "errors in outgoing"
37144 .cindex "host" "error"
37145 Three different kinds of error are recognized for outgoing SMTP: host errors,
37146 message errors, and recipient errors.
37147
37148 .vlist
37149 .vitem "&*Host errors*&"
37150 A host error is not associated with a particular message or with a
37151 particular recipient of a message. The host errors are:
37152
37153 .ilist
37154 Connection refused or timed out,
37155 .next
37156 Any error response code on connection,
37157 .next
37158 Any error response code to EHLO or HELO,
37159 .next
37160 Loss of connection at any time, except after &"."&,
37161 .next
37162 I/O errors at any time,
37163 .next
37164 Timeouts during the session, other than in response to MAIL, RCPT or
37165 the &"."& at the end of the data.
37166 .endlist ilist
37167
37168 For a host error, a permanent error response on connection, or in response to
37169 EHLO, causes all addresses routed to the host to be failed. Any other host
37170 error causes all addresses to be deferred, and retry data to be created for the
37171 host. It is not tried again, for any message, until its retry time arrives. If
37172 the current set of addresses are not all delivered in this run (to some
37173 alternative host), the message is added to the list of those waiting for this
37174 host, so if it is still undelivered when a subsequent successful delivery is
37175 made to the host, it will be sent down the same SMTP connection.
37176
37177 .vitem "&*Message errors*&"
37178 .cindex "message" "error"
37179 A message error is associated with a particular message when sent to a
37180 particular host, but not with a particular recipient of the message. The
37181 message errors are:
37182
37183 .ilist
37184 Any error response code to MAIL, DATA, or the &"."& that terminates
37185 the data,
37186 .next
37187 Timeout after MAIL,
37188 .next
37189 Timeout or loss of connection after the &"."& that terminates the data. A
37190 timeout after the DATA command itself is treated as a host error, as is loss of
37191 connection at any other time.
37192 .endlist ilist
37193
37194 For a message error, a permanent error response (5&'xx'&) causes all addresses
37195 to be failed, and a delivery error report to be returned to the sender. A
37196 temporary error response (4&'xx'&), or one of the timeouts, causes all
37197 addresses to be deferred. Retry data is not created for the host, but instead,
37198 a retry record for the combination of host plus message id is created. The
37199 message is not added to the list of those waiting for this host. This ensures
37200 that the failing message will not be sent to this host again until the retry
37201 time arrives. However, other messages that are routed to the host are not
37202 affected, so if it is some property of the message that is causing the error,
37203 it will not stop the delivery of other mail.
37204
37205 If the remote host specified support for the SIZE parameter in its response
37206 to EHLO, Exim adds SIZE=&'nnn'& to the MAIL command, so an
37207 over-large message will cause a message error because the error arrives as a
37208 response to MAIL.
37209
37210 .vitem "&*Recipient errors*&"
37211 .cindex "recipient" "error"
37212 A recipient error is associated with a particular recipient of a message. The
37213 recipient errors are:
37214
37215 .ilist
37216 Any error response to RCPT,
37217 .next
37218 Timeout after RCPT.
37219 .endlist
37220
37221 For a recipient error, a permanent error response (5&'xx'&) causes the
37222 recipient address to be failed, and a bounce message to be returned to the
37223 sender. A temporary error response (4&'xx'&) or a timeout causes the failing
37224 address to be deferred, and routing retry data to be created for it. This is
37225 used to delay processing of the address in subsequent queue runs, until its
37226 routing retry time arrives. This applies to all messages, but because it
37227 operates only in queue runs, one attempt will be made to deliver a new message
37228 to the failing address before the delay starts to operate. This ensures that,
37229 if the failure is really related to the message rather than the recipient
37230 (&"message too big for this recipient"& is a possible example), other messages
37231 have a chance of getting delivered. If a delivery to the address does succeed,
37232 the retry information gets cleared, so all stuck messages get tried again, and
37233 the retry clock is reset.
37234
37235 The message is not added to the list of those waiting for this host. Use of the
37236 host for other messages is unaffected, and except in the case of a timeout,
37237 other recipients are processed independently, and may be successfully delivered
37238 in the current SMTP session. After a timeout it is of course impossible to
37239 proceed with the session, so all addresses get deferred. However, those other
37240 than the one that failed do not suffer any subsequent retry delays. Therefore,
37241 if one recipient is causing trouble, the others have a chance of getting
37242 through when a subsequent delivery attempt occurs before the failing
37243 recipient's retry time.
37244 .endlist
37245
37246 In all cases, if there are other hosts (or IP addresses) available for the
37247 current set of addresses (for example, from multiple MX records), they are
37248 tried in this run for any undelivered addresses, subject of course to their
37249 own retry data. In other words, recipient error retry data does not take effect
37250 until the next delivery attempt.
37251
37252 Some hosts have been observed to give temporary error responses to every
37253 MAIL command at certain times (&"insufficient space"& has been seen). It
37254 would be nice if such circumstances could be recognized, and defer data for the
37255 host itself created, but this is not possible within the current Exim design.
37256 What actually happens is that retry data for every (host, message) combination
37257 is created.
37258
37259 The reason that timeouts after MAIL and RCPT are treated specially is that
37260 these can sometimes arise as a result of the remote host's verification
37261 procedures. Exim makes this assumption, and treats them as if a temporary error
37262 response had been received. A timeout after &"."& is treated specially because
37263 it is known that some broken implementations fail to recognize the end of the
37264 message if the last character of the last line is a binary zero. Thus, it is
37265 helpful to treat this case as a message error.
37266
37267 Timeouts at other times are treated as host errors, assuming a problem with the
37268 host, or the connection to it. If a timeout after MAIL, RCPT,
37269 or &"."& is really a connection problem, the assumption is that at the next try
37270 the timeout is likely to occur at some other point in the dialogue, causing it
37271 then to be treated as a host error.
37272
37273 There is experimental evidence that some MTAs drop the connection after the
37274 terminating &"."& if they do not like the contents of the message for some
37275 reason, in contravention of the RFC, which indicates that a 5&'xx'& response
37276 should be given. That is why Exim treats this case as a message rather than a
37277 host error, in order not to delay other messages to the same host.
37278
37279
37280
37281
37282 .section "Incoming SMTP messages over TCP/IP" "SECID233"
37283 .cindex "SMTP" "incoming over TCP/IP"
37284 .cindex "incoming SMTP over TCP/IP"
37285 .cindex "inetd"
37286 .cindex "daemon"
37287 Incoming SMTP messages can be accepted in one of two ways: by running a
37288 listening daemon, or by using &'inetd'&. In the latter case, the entry in
37289 &_/etc/inetd.conf_& should be like this:
37290 .code
37291 smtp stream tcp nowait exim /opt/exim/bin/exim in.exim -bs
37292 .endd
37293 Exim distinguishes between this case and the case of a locally running user
37294 agent using the &%-bs%& option by checking whether or not the standard input is
37295 a socket. When it is, either the port must be privileged (less than 1024), or
37296 the caller must be root or the Exim user. If any other user passes a socket
37297 with an unprivileged port number, Exim prints a message on the standard error
37298 stream and exits with an error code.
37299
37300 By default, Exim does not make a log entry when a remote host connects or
37301 disconnects (either via the daemon or &'inetd'&), unless the disconnection is
37302 unexpected. It can be made to write such log entries by setting the
37303 &%smtp_connection%& log selector.
37304
37305 .cindex "carriage return"
37306 .cindex "linefeed"
37307 Commands from the remote host are supposed to be terminated by CR followed by
37308 LF. However, there are known to be hosts that do not send CR characters. In
37309 order to be able to interwork with such hosts, Exim treats LF on its own as a
37310 line terminator.
37311 Furthermore, because common code is used for receiving messages from all
37312 sources, a CR on its own is also interpreted as a line terminator. However, the
37313 sequence &"CR, dot, CR"& does not terminate incoming SMTP data.
37314
37315 .cindex "EHLO" "invalid data"
37316 .cindex "HELO" "invalid data"
37317 One area that sometimes gives rise to problems concerns the EHLO or
37318 HELO commands. Some clients send syntactically invalid versions of these
37319 commands, which Exim rejects by default. (This is nothing to do with verifying
37320 the data that is sent, so &%helo_verify_hosts%& is not relevant.) You can tell
37321 Exim not to apply a syntax check by setting &%helo_accept_junk_hosts%& to
37322 match the broken hosts that send invalid commands.
37323
37324 .cindex "SIZE option on MAIL command"
37325 .cindex "MAIL" "SIZE option"
37326 The amount of disk space available is checked whenever SIZE is received on
37327 a MAIL command, independently of whether &%message_size_limit%& or
37328 &%check_spool_space%& is configured, unless &%smtp_check_spool_space%& is set
37329 false. A temporary error is given if there is not enough space. If
37330 &%check_spool_space%& is set, the check is for that amount of space plus the
37331 value given with SIZE, that is, it checks that the addition of the incoming
37332 message will not reduce the space below the threshold.
37333
37334 When a message is successfully received, Exim includes the local message id in
37335 its response to the final &"."& that terminates the data. If the remote host
37336 logs this text it can help with tracing what has happened to a message.
37337
37338 The Exim daemon can limit the number of simultaneous incoming connections it is
37339 prepared to handle (see the &%smtp_accept_max%& option). It can also limit the
37340 number of simultaneous incoming connections from a single remote host (see the
37341 &%smtp_accept_max_per_host%& option). Additional connection attempts are
37342 rejected using the SMTP temporary error code 421.
37343
37344 The Exim daemon does not rely on the SIGCHLD signal to detect when a
37345 subprocess has finished, as this can get lost at busy times. Instead, it looks
37346 for completed subprocesses every time it wakes up. Provided there are other
37347 things happening (new incoming calls, starts of queue runs), completed
37348 processes will be noticed and tidied away. On very quiet systems you may
37349 sometimes see a &"defunct"& Exim process hanging about. This is not a problem;
37350 it will be noticed when the daemon next wakes up.
37351
37352 When running as a daemon, Exim can reserve some SMTP slots for specific hosts,
37353 and can also be set up to reject SMTP calls from non-reserved hosts at times of
37354 high system load &-- for details see the &%smtp_accept_reserve%&,
37355 &%smtp_load_reserve%&, and &%smtp_reserve_hosts%& options. The load check
37356 applies in both the daemon and &'inetd'& cases.
37357
37358 Exim normally starts a delivery process for each message received, though this
37359 can be varied by means of the &%-odq%& command line option and the
37360 &%queue_only%&, &%queue_only_file%&, and &%queue_only_load%& options. The
37361 number of simultaneously running delivery processes started in this way from
37362 SMTP input can be limited by the &%smtp_accept_queue%& and
37363 &%smtp_accept_queue_per_connection%& options. When either limit is reached,
37364 subsequently received messages are just put on the input queue without starting
37365 a delivery process.
37366
37367 The controls that involve counts of incoming SMTP calls (&%smtp_accept_max%&,
37368 &%smtp_accept_queue%&, &%smtp_accept_reserve%&) are not available when Exim is
37369 started up from the &'inetd'& daemon, because in that case each connection is
37370 handled by an entirely independent Exim process. Control by load average is,
37371 however, available with &'inetd'&.
37372
37373 Exim can be configured to verify addresses in incoming SMTP commands as they
37374 are received. See chapter &<<CHAPACL>>& for details. It can also be configured
37375 to rewrite addresses at this time &-- before any syntax checking is done. See
37376 section &<<SSECTrewriteS>>&.
37377
37378 Exim can also be configured to limit the rate at which a client host submits
37379 MAIL and RCPT commands in a single SMTP session. See the
37380 &%smtp_ratelimit_hosts%& option.
37381
37382
37383
37384 .subsection "Unrecognized SMTP commands" SECID234
37385 .cindex "SMTP" "unrecognized commands"
37386 If Exim receives more than &%smtp_max_unknown_commands%& unrecognized SMTP
37387 commands during a single SMTP connection, it drops the connection after sending
37388 the error response to the last command. The default value for
37389 &%smtp_max_unknown_commands%& is 3. This is a defence against some kinds of
37390 abuse that subvert web servers into making connections to SMTP ports; in these
37391 circumstances, a number of non-SMTP lines are sent first.
37392
37393
37394 .subsection "Syntax and protocol errors in SMTP commands" SECID235
37395 .cindex "SMTP" "syntax errors"
37396 .cindex "SMTP" "protocol errors"
37397 A syntax error is detected if an SMTP command is recognized, but there is
37398 something syntactically wrong with its data, for example, a malformed email
37399 address in a RCPT command. Protocol errors include invalid command
37400 sequencing such as RCPT before MAIL. If Exim receives more than
37401 &%smtp_max_synprot_errors%& such commands during a single SMTP connection, it
37402 drops the connection after sending the error response to the last command. The
37403 default value for &%smtp_max_synprot_errors%& is 3. This is a defence against
37404 broken clients that loop sending bad commands (yes, it has been seen).
37405
37406
37407
37408 .subsection "Use of non-mail SMTP commands" SECID236
37409 .cindex "SMTP" "non-mail commands"
37410 The &"non-mail"& SMTP commands are those other than MAIL, RCPT, and
37411 DATA. Exim counts such commands, and drops the connection if there are too
37412 many of them in a single SMTP session. This action catches some
37413 denial-of-service attempts and things like repeated failing AUTHs, or a mad
37414 client looping sending EHLO. The global option &%smtp_accept_max_nonmail%&
37415 defines what &"too many"& means. Its default value is 10.
37416
37417 When a new message is expected, one occurrence of RSET is not counted. This
37418 allows a client to send one RSET between messages (this is not necessary,
37419 but some clients do it). Exim also allows one uncounted occurrence of HELO
37420 or EHLO, and one occurrence of STARTTLS between messages. After
37421 starting up a TLS session, another EHLO is expected, and so it too is not
37422 counted.
37423
37424 The first occurrence of AUTH in a connection, or immediately following
37425 STARTTLS is also not counted. Otherwise, all commands other than MAIL,
37426 RCPT, DATA, and QUIT are counted.
37427
37428 You can control which hosts are subject to the limit set by
37429 &%smtp_accept_max_nonmail%& by setting
37430 &%smtp_accept_max_nonmail_hosts%&. The default value is &`*`&, which makes
37431 the limit apply to all hosts. This option means that you can exclude any
37432 specific badly-behaved hosts that you have to live with.
37433
37434
37435
37436
37437 .subsection "The VRFY and EXPN commands" SECID237
37438 When Exim receives a VRFY or EXPN command on a TCP/IP connection, it
37439 runs the ACL specified by &%acl_smtp_vrfy%& or &%acl_smtp_expn%& (as
37440 appropriate) in order to decide whether the command should be accepted or not.
37441
37442 .cindex "VRFY" "processing"
37443 When no ACL is defined for VRFY, or if it rejects without
37444 setting an explicit response code, the command is accepted
37445 (with a 252 SMTP response code)
37446 in order to support awkward clients that do a VRFY before every RCPT.
37447 When VRFY is accepted, it runs exactly the same code as when Exim is
37448 called with the &%-bv%& option, and returns 250/451/550
37449 SMTP response codes.
37450
37451 .cindex "EXPN" "processing"
37452 If no ACL for EXPN is defined, the command is rejected.
37453 When EXPN is accepted, a single-level expansion of the address is done.
37454 EXPN is treated as an &"address test"& (similar to the &%-bt%& option) rather
37455 than a verification (the &%-bv%& option). If an unqualified local part is given
37456 as the argument to EXPN, it is qualified with &%qualify_domain%&. Rejections
37457 of VRFY and EXPN commands are logged on the main and reject logs, and
37458 VRFY verification failures are logged in the main log for consistency with
37459 RCPT failures.
37460
37461
37462
37463 .subsection "The ETRN command" SECTETRN
37464 .cindex "ETRN" "processing"
37465 .cindex "ESMTP extensions" ETRN
37466 RFC 1985 describes an ESMTP command called ETRN that is designed to
37467 overcome the security problems of the TURN command (which has fallen into
37468 disuse). When Exim receives an ETRN command on a TCP/IP connection, it runs
37469 the ACL specified by &%acl_smtp_etrn%& in order to decide whether the command
37470 should be accepted or not. If no ACL is defined, the command is rejected.
37471
37472 The ETRN command is concerned with &"releasing"& messages that are awaiting
37473 delivery to certain hosts. As Exim does not organize its message queue by host,
37474 the only form of ETRN that is supported by default is the one where the
37475 text starts with the &"#"& prefix, in which case the remainder of the text is
37476 specific to the SMTP server. A valid ETRN command causes a run of Exim with
37477 the &%-R%& option to happen, with the remainder of the ETRN text as its
37478 argument. For example,
37479 .code
37480 ETRN #brigadoon
37481 .endd
37482 runs the command
37483 .code
37484 exim -R brigadoon
37485 .endd
37486 which causes a delivery attempt on all messages with undelivered addresses
37487 containing the text &"brigadoon"&. When &%smtp_etrn_serialize%& is set (the
37488 default), Exim prevents the simultaneous execution of more than one queue run
37489 for the same argument string as a result of an ETRN command. This stops
37490 a misbehaving client from starting more than one queue runner at once.
37491
37492 .cindex "hints database" "ETRN serialization"
37493 Exim implements the serialization by means of a hints database in which a
37494 record is written whenever a process is started by ETRN, and deleted when
37495 the process completes. However, Exim does not keep the SMTP session waiting for
37496 the ETRN process to complete. Once ETRN is accepted, the client is sent
37497 a &"success"& return code. Obviously there is scope for hints records to get
37498 left lying around if there is a system or program crash. To guard against this,
37499 Exim ignores any records that are more than six hours old.
37500
37501 .oindex "&%smtp_etrn_command%&"
37502 For more control over what ETRN does, the &%smtp_etrn_command%& option can
37503 used. This specifies a command that is run whenever ETRN is received,
37504 whatever the form of its argument. For
37505 example:
37506 .code
37507 smtp_etrn_command = /etc/etrn_command $domain \
37508                     $sender_host_address
37509 .endd
37510 .vindex "&$domain$&"
37511 The string is split up into arguments which are independently expanded. The
37512 expansion variable &$domain$& is set to the argument of the ETRN command,
37513 and no syntax checking is done on the contents of this argument. Exim does not
37514 wait for the command to complete, so its status code is not checked. Exim runs
37515 under its own uid and gid when receiving incoming SMTP, so it is not possible
37516 for it to change them before running the command.
37517
37518
37519
37520 .section "Incoming local SMTP" "SECID238"
37521 .cindex "SMTP" "local incoming"
37522 Some user agents use SMTP to pass messages to their local MTA using the
37523 standard input and output, as opposed to passing the envelope on the command
37524 line and writing the message to the standard input. This is supported by the
37525 &%-bs%& option. This form of SMTP is handled in the same way as incoming
37526 messages over TCP/IP (including the use of ACLs), except that the envelope
37527 sender given in a MAIL command is ignored unless the caller is trusted. In
37528 an ACL you can detect this form of SMTP input by testing for an empty host
37529 identification. It is common to have this as the first line in the ACL that
37530 runs for RCPT commands:
37531 .code
37532 accept hosts = :
37533 .endd
37534 This accepts SMTP messages from local processes without doing any other tests.
37535
37536
37537
37538 .section "Outgoing batched SMTP" "SECTbatchSMTP"
37539 .cindex "SMTP" "batched outgoing"
37540 .cindex "batched SMTP output"
37541 Both the &(appendfile)& and &(pipe)& transports can be used for handling
37542 batched SMTP. Each has an option called &%use_bsmtp%& which causes messages to
37543 be output in BSMTP format. No SMTP responses are possible for this form of
37544 delivery. All it is doing is using SMTP commands as a way of transmitting the
37545 envelope along with the message.
37546
37547 The message is written to the file or pipe preceded by the SMTP commands
37548 MAIL and RCPT, and followed by a line containing a single dot. Lines in
37549 the message that start with a dot have an extra dot added. The SMTP command
37550 HELO is not normally used. If it is required, the &%message_prefix%& option
37551 can be used to specify it.
37552
37553 Because &(appendfile)& and &(pipe)& are both local transports, they accept only
37554 one recipient address at a time by default. However, you can arrange for them
37555 to handle several addresses at once by setting the &%batch_max%& option. When
37556 this is done for BSMTP, messages may contain multiple RCPT commands. See
37557 chapter &<<CHAPbatching>>& for more details.
37558
37559 .vindex "&$host$&"
37560 When one or more addresses are routed to a BSMTP transport by a router that
37561 sets up a host list, the name of the first host on the list is available to the
37562 transport in the variable &$host$&. Here is an example of such a transport and
37563 router:
37564 .code
37565 begin routers
37566 route_append:
37567   driver = manualroute
37568   transport = smtp_appendfile
37569   route_list = domain.example  batch.host.example
37570
37571 begin transports
37572 smtp_appendfile:
37573   driver = appendfile
37574   directory = /var/bsmtp/$host
37575   batch_max = 1000
37576   use_bsmtp
37577   user = exim
37578 .endd
37579 This causes messages addressed to &'domain.example'& to be written in BSMTP
37580 format to &_/var/bsmtp/batch.host.example_&, with only a single copy of each
37581 message (unless there are more than 1000 recipients).
37582
37583
37584
37585 .section "Incoming batched SMTP" "SECTincomingbatchedSMTP"
37586 .cindex "SMTP" "batched incoming"
37587 .cindex "batched SMTP input"
37588 The &%-bS%& command line option causes Exim to accept one or more messages by
37589 reading SMTP on the standard input, but to generate no responses. If the caller
37590 is trusted, the senders in the MAIL commands are believed; otherwise the
37591 sender is always the caller of Exim. Unqualified senders and receivers are not
37592 rejected (there seems little point) but instead just get qualified. HELO
37593 and EHLO act as RSET; VRFY, EXPN, ETRN and  HELP, act
37594 as NOOP; QUIT quits.
37595
37596 Minimal policy checking is done for BSMTP input. Only the non-SMTP
37597 ACL is run in the same way as for non-SMTP local input.
37598
37599 If an error is detected while reading a message, including a missing &"."& at
37600 the end, Exim gives up immediately. It writes details of the error to the
37601 standard output in a stylized way that the calling program should be able to
37602 make some use of automatically, for example:
37603 .code
37604 554 Unexpected end of file
37605 Transaction started in line 10
37606 Error detected in line 14
37607 .endd
37608 It writes a more verbose version, for human consumption, to the standard error
37609 file, for example:
37610 .code
37611 An error was detected while processing a file of BSMTP input.
37612 The error message was:
37613
37614 501 '>' missing at end of address
37615
37616 The SMTP transaction started in line 10.
37617 The error was detected in line 12.
37618 The SMTP command at fault was:
37619
37620 rcpt to:<malformed@in.com.plete
37621
37622 1 previous message was successfully processed.
37623 The rest of the batch was abandoned.
37624 .endd
37625 The return code from Exim is zero only if there were no errors. It is 1 if some
37626 messages were accepted before an error was detected, and 2 if no messages were
37627 accepted.
37628 .ecindex IIDsmtpproc1
37629 .ecindex IIDsmtpproc2
37630
37631
37632
37633 . ////////////////////////////////////////////////////////////////////////////
37634 . ////////////////////////////////////////////////////////////////////////////
37635
37636 .chapter "Customizing bounce and warning messages" "CHAPemsgcust" &&&
37637          "Customizing messages"
37638 When a message fails to be delivered, or remains in the queue for more than a
37639 configured amount of time, Exim sends a message to the original sender, or
37640 to an alternative configured address. The text of these messages is built into
37641 the code of Exim, but it is possible to change it, either by adding a single
37642 string, or by replacing each of the paragraphs by text supplied in a file.
37643
37644 The &'From:'& and &'To:'& header lines are automatically generated; you can
37645 cause a &'Reply-To:'& line to be added by setting the &%errors_reply_to%&
37646 option. Exim also adds the line
37647 .code
37648 Auto-Submitted: auto-generated
37649 .endd
37650 to all warning and bounce messages,
37651
37652
37653 .section "Customizing bounce messages" "SECID239"
37654 .cindex "customizing" "bounce message"
37655 .cindex "bounce message" "customizing"
37656 If &%bounce_message_text%& is set, its contents are included in the default
37657 message immediately after &"This message was created automatically by mail
37658 delivery software."& The string is not expanded. It is not used if
37659 &%bounce_message_file%& is set.
37660
37661 When &%bounce_message_file%& is set, it must point to a template file for
37662 constructing error messages. The file consists of a series of text items,
37663 separated by lines consisting of exactly four asterisks. If the file cannot be
37664 opened, default text is used and a message is written to the main and panic
37665 logs. If any text item in the file is empty, default text is used for that
37666 item.
37667
37668 .vindex "&$bounce_recipient$&"
37669 .vindex "&$bounce_return_size_limit$&"
37670 Each item of text that is read from the file is expanded, and there are two
37671 expansion variables which can be of use here: &$bounce_recipient$& is set to
37672 the recipient of an error message while it is being created, and
37673 &$bounce_return_size_limit$& contains the value of the &%return_size_limit%&
37674 option, rounded to a whole number.
37675
37676 The items must appear in the file in the following order:
37677
37678 .ilist
37679 The first item is included in the headers, and should include at least a
37680 &'Subject:'& header. Exim does not check the syntax of these headers.
37681 .next
37682 The second item forms the start of the error message. After it, Exim lists the
37683 failing addresses with their error messages.
37684 .next
37685 The third item is used to introduce any text from pipe transports that is to be
37686 returned to the sender. It is omitted if there is no such text.
37687 .next
37688 The fourth, fifth and sixth items will be ignored and may be empty.
37689 The fields exist for back-compatibility
37690 .endlist
37691
37692 The default state (&%bounce_message_file%& unset) is equivalent to the
37693 following file, in which the sixth item is empty. The &'Subject:'& and some
37694 other lines have been split in order to fit them on the page:
37695 .code
37696 Subject: Mail delivery failed
37697   ${if eq{$sender_address}{$bounce_recipient}
37698   {: returning message to sender}}
37699 ****
37700 This message was created automatically by mail delivery software.
37701
37702 A message ${if eq{$sender_address}{$bounce_recipient}
37703   {that you sent }{sent by
37704
37705 <$sender_address>
37706
37707 }}could not be delivered to all of its recipients.
37708 This is a permanent error. The following address(es) failed:
37709 ****
37710 The following text was generated during the delivery attempt(s):
37711 ****
37712 ------ This is a copy of the message, including all the headers.
37713   ------
37714 ****
37715 ------ The body of the message is $message_size characters long;
37716   only the first
37717 ------ $bounce_return_size_limit or so are included here.
37718 ****
37719 .endd
37720 .section "Customizing warning messages" "SECTcustwarn"
37721 .cindex "customizing" "warning message"
37722 .cindex "warning of delay" "customizing the message"
37723 The option &%warn_message_file%& can be pointed at a template file for use when
37724 warnings about message delays are created. In this case there are only three
37725 text sections:
37726
37727 .ilist
37728 The first item is included in the headers, and should include at least a
37729 &'Subject:'& header. Exim does not check the syntax of these headers.
37730 .next
37731 The second item forms the start of the warning message. After it, Exim lists
37732 the delayed addresses.
37733 .next
37734 The third item then ends the message.
37735 .endlist
37736
37737 The default state is equivalent to the following file, except that some lines
37738 have been split here, in order to fit them on the page:
37739 .code
37740 Subject: Warning: message $message_exim_id delayed
37741   $warn_message_delay
37742 ****
37743 This message was created automatically by mail delivery software.
37744
37745 A message ${if eq{$sender_address}{$warn_message_recipients}
37746 {that you sent }{sent by
37747
37748 <$sender_address>
37749
37750 }}has not been delivered to all of its recipients after
37751 more than $warn_message_delay in the queue on $primary_hostname.
37752
37753 The message identifier is:     $message_exim_id
37754 The subject of the message is: $h_subject
37755 The date of the message is:    $h_date
37756
37757 The following address(es) have not yet been delivered:
37758 ****
37759 No action is required on your part. Delivery attempts will
37760 continue for some time, and this warning may be repeated at
37761 intervals if the message remains undelivered. Eventually the
37762 mail delivery software will give up, and when that happens,
37763 the message will be returned to you.
37764 .endd
37765 .vindex "&$warn_message_delay$&"
37766 .vindex "&$warn_message_recipients$&"
37767 However, in the default state the subject and date lines are omitted if no
37768 appropriate headers exist. During the expansion of this file,
37769 &$warn_message_delay$& is set to the delay time in one of the forms &"<&'n'&>
37770 minutes"& or &"<&'n'&> hours"&, and &$warn_message_recipients$& contains a list
37771 of recipients for the warning message. There may be more than one if there are
37772 multiple addresses with different &%errors_to%& settings on the routers that
37773 handled them.
37774
37775
37776
37777
37778 . ////////////////////////////////////////////////////////////////////////////
37779 . ////////////////////////////////////////////////////////////////////////////
37780
37781 .chapter "Some common configuration settings" "CHAPcomconreq"
37782 This chapter discusses some configuration settings that seem to be fairly
37783 common. More examples and discussion can be found in the Exim book.
37784
37785
37786
37787 .section "Sending mail to a smart host" "SECID240"
37788 .cindex "smart host" "example router"
37789 If you want to send all mail for non-local domains to a &"smart host"&, you
37790 should replace the default &(dnslookup)& router with a router which does the
37791 routing explicitly:
37792 .code
37793 send_to_smart_host:
37794   driver = manualroute
37795   route_list = !+local_domains smart.host.name
37796   transport = remote_smtp
37797 .endd
37798 You can use the smart host's IP address instead of the name if you wish.
37799 If you are using Exim only to submit messages to a smart host, and not for
37800 receiving incoming messages, you can arrange for it to do the submission
37801 synchronously by setting the &%mua_wrapper%& option (see chapter
37802 &<<CHAPnonqueueing>>&).
37803
37804
37805
37806
37807 .section "Using Exim to handle mailing lists" "SECTmailinglists"
37808 .cindex "mailing lists"
37809 Exim can be used to run simple mailing lists, but for large and/or complicated
37810 requirements, the use of additional specialized mailing list software such as
37811 Majordomo or Mailman is recommended.
37812
37813 The &(redirect)& router can be used to handle mailing lists where each list
37814 is maintained in a separate file, which can therefore be managed by an
37815 independent manager. The &%domains%& router option can be used to run these
37816 lists in a separate domain from normal mail. For example:
37817 .code
37818 lists:
37819   driver = redirect
37820   domains = lists.example
37821   file = ${lookup {$local_part} dsearch,ret=full {/usr/lists}}
37822   forbid_pipe
37823   forbid_file
37824   errors_to = ${quote_local_part:$local_part-request}@lists.example
37825   no_more
37826 .endd
37827 This router is skipped for domains other than &'lists.example'&. For addresses
37828 in that domain, it looks for a file that matches the local part. If there is no
37829 such file, the router declines, but because &%no_more%& is set, no subsequent
37830 routers are tried, and so the whole delivery fails.
37831
37832 The &%forbid_pipe%& and &%forbid_file%& options prevent a local part from being
37833 expanded into a filename or a pipe delivery, which is usually inappropriate in
37834 a mailing list.
37835
37836 .oindex "&%errors_to%&"
37837 The &%errors_to%& option specifies that any delivery errors caused by addresses
37838 taken from a mailing list are to be sent to the given address rather than the
37839 original sender of the message. However, before acting on this, Exim verifies
37840 the error address, and ignores it if verification fails.
37841
37842 For example, using the configuration above, mail sent to
37843 &'dicts@lists.example'& is passed on to those addresses contained in
37844 &_/usr/lists/dicts_&, with error reports directed to
37845 &'dicts-request@lists.example'&, provided that this address can be verified.
37846 There could be a file called &_/usr/lists/dicts-request_& containing
37847 the address(es) of this particular list's manager(s), but other approaches,
37848 such as setting up an earlier router (possibly using the &%local_part_prefix%&
37849 or &%local_part_suffix%& options) to handle addresses of the form
37850 &%owner-%&&'xxx'& or &%xxx-%&&'request'&, are also possible.
37851
37852
37853
37854 .section "Syntax errors in mailing lists" "SECID241"
37855 .cindex "mailing lists" "syntax errors in"
37856 If an entry in redirection data contains a syntax error, Exim normally defers
37857 delivery of the original address. That means that a syntax error in a mailing
37858 list holds up all deliveries to the list. This may not be appropriate when a
37859 list is being maintained automatically from data supplied by users, and the
37860 addresses are not rigorously checked.
37861
37862 If the &%skip_syntax_errors%& option is set, the &(redirect)& router just skips
37863 entries that fail to parse, noting the incident in the log. If in addition
37864 &%syntax_errors_to%& is set to a verifiable address, a message is sent to it
37865 whenever a broken address is skipped. It is usually appropriate to set
37866 &%syntax_errors_to%& to the same address as &%errors_to%&.
37867
37868
37869
37870 .section "Re-expansion of mailing lists" "SECID242"
37871 .cindex "mailing lists" "re-expansion of"
37872 Exim remembers every individual address to which a message has been delivered,
37873 in order to avoid duplication, but it normally stores only the original
37874 recipient addresses with a message. If all the deliveries to a mailing list
37875 cannot be done at the first attempt, the mailing list is re-expanded when the
37876 delivery is next tried. This means that alterations to the list are taken into
37877 account at each delivery attempt, so addresses that have been added to
37878 the list since the message arrived will therefore receive a copy of the
37879 message, even though it pre-dates their subscription.
37880
37881 If this behaviour is felt to be undesirable, the &%one_time%& option can be set
37882 on the &(redirect)& router. If this is done, any addresses generated by the
37883 router that fail to deliver at the first attempt are added to the message as
37884 &"top level"& addresses, and the parent address that generated them is marked
37885 &"delivered"&. Thus, expansion of the mailing list does not happen again at the
37886 subsequent delivery attempts. The disadvantage of this is that if any of the
37887 failing addresses are incorrect, correcting them in the file has no effect on
37888 pre-existing messages.
37889
37890 The original top-level address is remembered with each of the generated
37891 addresses, and is output in any log messages. However, any intermediate parent
37892 addresses are not recorded. This makes a difference to the log only if the
37893 &%all_parents%& selector is set, but for mailing lists there is normally only
37894 one level of expansion anyway.
37895
37896
37897
37898 .section "Closed mailing lists" "SECID243"
37899 .cindex "mailing lists" "closed"
37900 The examples so far have assumed open mailing lists, to which anybody may
37901 send mail. It is also possible to set up closed lists, where mail is accepted
37902 from specified senders only. This is done by making use of the generic
37903 &%senders%& option to restrict the router that handles the list.
37904
37905 The following example uses the same file as a list of recipients and as a list
37906 of permitted senders. It requires three routers:
37907 .code
37908 lists_request:
37909   driver = redirect
37910   domains = lists.example
37911   local_part_suffix = -request
37912   local_parts = ${lookup {$local_part} dsearch,filter=file {/usr/lists}}
37913   file = /usr/lists/${local_part_data}-request
37914   no_more
37915
37916 lists_post:
37917   driver = redirect
37918   domains = lists.example
37919   local_parts = ${lookup {$local_part} dsearch,filter=file,ret=full {/usr/lists}}
37920   senders = ${if exists {$local_part_data} {lsearch;$local_part_data}{*}}
37921   file = ${lookup {$local_part} dsearch,ret=full {/usr/lists}}
37922   forbid_pipe
37923   forbid_file
37924   errors_to = ${quote_local_part:$local_part-request}@lists.example
37925   no_more
37926
37927 lists_closed:
37928   driver = redirect
37929   domains = lists.example
37930   allow_fail
37931   data = :fail: $local_part@lists.example is a closed mailing list
37932 .endd
37933 All three routers have the same &%domains%& setting, so for any other domains,
37934 they are all skipped. The first router runs only if the local part ends in
37935 &%-request%&. It handles messages to the list manager(s) by means of an open
37936 mailing list.
37937
37938 The second router runs only if the &%senders%& precondition is satisfied. It
37939 checks for the existence of a list that corresponds to the local part, and then
37940 checks that the sender is on the list by means of a linear search. It is
37941 necessary to check for the existence of the file before trying to search it,
37942 because otherwise Exim thinks there is a configuration error. If the file does
37943 not exist, the expansion of &%senders%& is *, which matches all senders. This
37944 means that the router runs, but because there is no list, declines, and
37945 &%no_more%& ensures that no further routers are run. The address fails with an
37946 &"unrouteable address"& error.
37947
37948 The third router runs only if the second router is skipped, which happens when
37949 a mailing list exists, but the sender is not on it. This router forcibly fails
37950 the address, giving a suitable error message.
37951
37952
37953
37954
37955 .section "Variable Envelope Return Paths (VERP)" "SECTverp"
37956 .cindex "VERP"
37957 .cindex "Variable Envelope Return Paths"
37958 .cindex "envelope from"
37959 .cindex "envelope sender"
37960 Variable Envelope Return Paths &-- see &url(https://cr.yp.to/proto/verp.txt) &--
37961 are a way of helping mailing list administrators discover which subscription
37962 address is the cause of a particular delivery failure. The idea is to encode
37963 the original recipient address in the outgoing envelope sender address, so that
37964 if the message is forwarded by another host and then subsequently bounces, the
37965 original recipient can be extracted from the recipient address of the bounce.
37966
37967 .oindex &%errors_to%&
37968 .oindex &%return_path%&
37969 Envelope sender addresses can be modified by Exim using two different
37970 facilities: the &%errors_to%& option on a router (as shown in previous mailing
37971 list examples), or the &%return_path%& option on a transport. The second of
37972 these is effective only if the message is successfully delivered to another
37973 host; it is not used for errors detected on the local host (see the description
37974 of &%return_path%& in chapter &<<CHAPtransportgeneric>>&). Here is an example
37975 of the use of &%return_path%& to implement VERP on an &(smtp)& transport:
37976 .code
37977 verp_smtp:
37978   driver = smtp
37979   max_rcpt = 1
37980   return_path = \
37981     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
37982       {${quote_local_part:$1-request+$local_part=$domain}@your.dom.example}fail}
37983 .endd
37984 This has the effect of rewriting the return path (envelope sender) on outgoing
37985 SMTP messages, if the local part of the original return path ends in
37986 &"-request"&, and the domain is &'your.dom.example'&. The rewriting inserts the
37987 local part and domain of the recipient into the return path. Suppose, for
37988 example, that a message whose return path has been set to
37989 &'somelist-request@your.dom.example'& is sent to
37990 &'subscriber@other.dom.example'&. In the transport, the return path is
37991 rewritten as
37992 .code
37993 somelist-request+subscriber=other.dom.example@your.dom.example
37994 .endd
37995 .vindex "&$local_part$&"
37996 For this to work, you must tell Exim to send multiple copies of messages that
37997 have more than one recipient, so that each copy has just one recipient. This is
37998 achieved by setting &%max_rcpt%& to 1. Without this, a single copy of a message
37999 might be sent to several different recipients in the same domain, in which case
38000 &$local_part$& is not available in the transport, because it is not unique.
38001
38002 Unless your host is doing nothing but mailing list deliveries, you should
38003 probably use a separate transport for the VERP deliveries, so as not to use
38004 extra resources in making one-per-recipient copies for other deliveries. This
38005 can easily be done by expanding the &%transport%& option in the router:
38006 .code
38007 dnslookup:
38008   driver = dnslookup
38009   domains = ! +local_domains
38010   transport = \
38011     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
38012       {verp_smtp}{remote_smtp}}
38013   no_more
38014 .endd
38015 If you want to change the return path using &%errors_to%& in a router instead
38016 of using &%return_path%& in the transport, you need to set &%errors_to%& on all
38017 routers that handle mailing list addresses. This will ensure that all delivery
38018 errors, including those detected on the local host, are sent to the VERP
38019 address.
38020
38021 On a host that does no local deliveries and has no manual routing, only the
38022 &(dnslookup)& router needs to be changed. A special transport is not needed for
38023 SMTP deliveries. Every mailing list recipient has its own return path value,
38024 and so Exim must hand them to the transport one at a time. Here is an example
38025 of a &(dnslookup)& router that implements VERP:
38026 .code
38027 verp_dnslookup:
38028   driver = dnslookup
38029   domains = ! +local_domains
38030   transport = remote_smtp
38031   errors_to = \
38032     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}}
38033      {${quote_local_part:$1-request+$local_part=$domain}@your.dom.example}fail}
38034   no_more
38035 .endd
38036 Before you start sending out messages with VERPed return paths, you must also
38037 configure Exim to accept the bounce messages that come back to those paths.
38038 Typically this is done by setting a &%local_part_suffix%& option for a
38039 router, and using this to route the messages to wherever you want to handle
38040 them.
38041
38042 The overhead incurred in using VERP depends very much on the size of the
38043 message, the number of recipient addresses that resolve to the same remote
38044 host, and the speed of the connection over which the message is being sent. If
38045 a lot of addresses resolve to the same host and the connection is slow, sending
38046 a separate copy of the message for each address may take substantially longer
38047 than sending a single copy with many recipients (for which VERP cannot be
38048 used).
38049
38050
38051
38052
38053
38054
38055 .section "Virtual domains" "SECTvirtualdomains"
38056 .cindex "virtual domains"
38057 .cindex "domain" "virtual"
38058 The phrase &'virtual domain'& is unfortunately used with two rather different
38059 meanings:
38060
38061 .ilist
38062 A domain for which there are no real mailboxes; all valid local parts are
38063 aliases for other email addresses. Common examples are organizational
38064 top-level domains and &"vanity"& domains.
38065 .next
38066 One of a number of independent domains that are all handled by the same host,
38067 with mailboxes on that host, but where the mailbox owners do not necessarily
38068 have login accounts on that host.
38069 .endlist
38070
38071 The first usage is probably more common, and does seem more &"virtual"& than
38072 the second. This kind of domain can be handled in Exim with a straightforward
38073 aliasing router. One approach is to create a separate alias file for each
38074 virtual domain. Exim can test for the existence of the alias file to determine
38075 whether the domain exists. The &(dsearch)& lookup type is useful here, leading
38076 to a router of this form:
38077 .code
38078 virtual:
38079   driver = redirect
38080   domains = dsearch;/etc/mail/virtual
38081   data = ${lookup{$local_part}lsearch{/etc/mail/virtual/$domain_data}}
38082   no_more
38083 .endd
38084 The &%domains%& option specifies that the router is to be skipped, unless there
38085 is a file in the &_/etc/mail/virtual_& directory whose name is the same as the
38086 domain that is being processed.
38087 The &(dsearch)& lookup used results in an untainted version of &$domain$&
38088 being placed into the &$domain_data$& variable.
38089
38090 When the router runs, it looks up the local
38091 part in the file to find a new address (or list of addresses). The &%no_more%&
38092 setting ensures that if the lookup fails (leading to &%data%& being an empty
38093 string), Exim gives up on the address without trying any subsequent routers.
38094
38095 This one router can handle all the virtual domains because the alias filenames
38096 follow a fixed pattern. Permissions can be arranged so that appropriate people
38097 can edit the different alias files. A successful aliasing operation results in
38098 a new envelope recipient address, which is then routed from scratch.
38099
38100 The other kind of &"virtual"& domain can also be handled in a straightforward
38101 way. One approach is to create a file for each domain containing a list of
38102 valid local parts, and use it in a router like this:
38103 .code
38104 my_domains:
38105   driver = accept
38106   domains = dsearch;/etc/mail/domains
38107   local_parts = lsearch;/etc/mail/domains/$domain
38108   transport = my_mailboxes
38109 .endd
38110 The address is accepted if there is a file for the domain, and the local part
38111 can be found in the file. The &%domains%& option is used to check for the
38112 file's existence because &%domains%& is tested before the &%local_parts%&
38113 option (see section &<<SECTrouprecon>>&). You cannot use &%require_files%&,
38114 because that option is tested after &%local_parts%&. The transport is as
38115 follows:
38116 .code
38117 my_mailboxes:
38118   driver = appendfile
38119   file = /var/mail/$domain_data/$local_part_data
38120   user = mail
38121 .endd
38122 This uses a directory of mailboxes for each domain. The &%user%& setting is
38123 required, to specify which uid is to be used for writing to the mailboxes.
38124
38125 The configuration shown here is just one example of how you might support this
38126 requirement. There are many other ways this kind of configuration can be set
38127 up, for example, by using a database instead of separate files to hold all the
38128 information about the domains.
38129
38130
38131
38132 .section "Multiple user mailboxes" "SECTmulbox"
38133 .cindex "multiple mailboxes"
38134 .cindex "mailbox" "multiple"
38135 .cindex "local part" "prefix"
38136 .cindex "local part" "suffix"
38137 Heavy email users often want to operate with multiple mailboxes, into which
38138 incoming mail is automatically sorted. A popular way of handling this is to
38139 allow users to use multiple sender addresses, so that replies can easily be
38140 identified. Users are permitted to add prefixes or suffixes to their local
38141 parts for this purpose. The wildcard facility of the generic router options
38142 &%local_part_prefix%& and &%local_part_suffix%& can be used for this. For
38143 example, consider this router:
38144 .code
38145 userforward:
38146   driver = redirect
38147   check_local_user
38148   file = $home/.forward
38149   local_part_suffix = -*
38150   local_part_suffix_optional
38151   allow_filter
38152 .endd
38153 .vindex "&$local_part_suffix$&"
38154 It runs a user's &_.forward_& file for all local parts of the form
38155 &'username-*'&. Within the filter file the user can distinguish different
38156 cases by testing the variable &$local_part_suffix$&. For example:
38157 .code
38158 if $local_part_suffix contains -special then
38159 save /home/$local_part_data/Mail/special
38160 endif
38161 .endd
38162 If the filter file does not exist, or does not deal with such addresses, they
38163 fall through to subsequent routers, and, assuming no subsequent use of the
38164 &%local_part_suffix%& option is made, they presumably fail. Thus, users have
38165 control over which suffixes are valid.
38166
38167 Alternatively, a suffix can be used to trigger the use of a different
38168 &_.forward_& file &-- which is the way a similar facility is implemented in
38169 another MTA:
38170 .code
38171 userforward:
38172   driver = redirect
38173   check_local_user
38174   local_part_suffix = -*
38175   local_part_suffix_optional
38176   file = ${lookup {.forward$local_part_suffix} dsearch,ret=full {$home} {$value}fail}
38177   allow_filter
38178 .endd
38179 If there is no suffix, &_.forward_& is used; if the suffix is &'-special'&, for
38180 example, &_.forward-special_& is used. Once again, if the appropriate file
38181 does not exist, or does not deal with the address, it is passed on to
38182 subsequent routers, which could, if required, look for an unqualified
38183 &_.forward_& file to use as a default.
38184
38185
38186
38187 .section "Simplified vacation processing" "SECID244"
38188 .cindex "vacation processing"
38189 The traditional way of running the &'vacation'& program is for a user to set up
38190 a pipe command in a &_.forward_& file
38191 (see section &<<SECTspecitredli>>& for syntax details).
38192 This is prone to error by inexperienced users. There are two features of Exim
38193 that can be used to make this process simpler for users:
38194
38195 .ilist
38196 A local part prefix such as &"vacation-"& can be specified on a router which
38197 can cause the message to be delivered directly to the &'vacation'& program, or
38198 alternatively can use Exim's &(autoreply)& transport. The contents of a user's
38199 &_.forward_& file are then much simpler. For example:
38200 .code
38201 spqr, vacation-spqr
38202 .endd
38203 .next
38204 The &%require_files%& generic router option can be used to trigger a
38205 vacation delivery by checking for the existence of a certain file in the
38206 user's home directory. The &%unseen%& generic option should also be used, to
38207 ensure that the original delivery also proceeds. In this case, all the user has
38208 to do is to create a file called, say, &_.vacation_&, containing a vacation
38209 message.
38210 .endlist
38211
38212 Another advantage of both these methods is that they both work even when the
38213 use of arbitrary pipes by users is locked out.
38214
38215
38216
38217 .section "Taking copies of mail" "SECID245"
38218 .cindex "message" "copying every"
38219 Some installations have policies that require archive copies of all messages to
38220 be made. A single copy of each message can easily be taken by an appropriate
38221 command in a system filter, which could, for example, use a different file for
38222 each day's messages.
38223
38224 There is also a shadow transport mechanism that can be used to take copies of
38225 messages that are successfully delivered by local transports, one copy per
38226 delivery. This could be used, &'inter alia'&, to implement automatic
38227 notification of delivery by sites that insist on doing such things.
38228
38229
38230
38231 .section "Intermittently connected hosts" "SECID246"
38232 .cindex "intermittently connected hosts"
38233 It has become quite common (because it is cheaper) for hosts to connect to the
38234 Internet periodically rather than remain connected all the time. The normal
38235 arrangement is that mail for such hosts accumulates on a system that is
38236 permanently connected.
38237
38238 Exim was designed for use on permanently connected hosts, and so it is not
38239 particularly well-suited to use in an intermittently connected environment.
38240 Nevertheless there are some features that can be used.
38241
38242
38243 .section "Exim on the upstream server host" "SECID247"
38244 It is tempting to arrange for incoming mail for the intermittently connected
38245 host to remain in Exim's queue until the client connects. However, this
38246 approach does not scale very well. Two different kinds of waiting message are
38247 being mixed up in the same queue &-- those that cannot be delivered because of
38248 some temporary problem, and those that are waiting for their destination host
38249 to connect. This makes it hard to manage the queue, as well as wasting
38250 resources, because each queue runner scans the entire queue.
38251
38252 A better approach is to separate off those messages that are waiting for an
38253 intermittently connected host. This can be done by delivering these messages
38254 into local files in batch SMTP, &"mailstore"&, or other envelope-preserving
38255 format, from where they are transmitted by other software when their
38256 destination connects. This makes it easy to collect all the mail for one host
38257 in a single directory, and to apply local timeout rules on a per-message basis
38258 if required.
38259
38260 On a very small scale, leaving the mail on Exim's queue can be made to work. If
38261 you are doing this, you should configure Exim with a long retry period for the
38262 intermittent host. For example:
38263 .code
38264 cheshire.wonderland.fict.example    *   F,5d,24h
38265 .endd
38266 This stops a lot of failed delivery attempts from occurring, but Exim remembers
38267 which messages it has queued up for that host. Once the intermittent host comes
38268 online, forcing delivery of one message (either by using the &%-M%& or &%-R%&
38269 options, or by using the ETRN SMTP command (see section &<<SECTETRN>>&)
38270 causes all the queued up messages to be delivered, often down a single SMTP
38271 connection. While the host remains connected, any new messages get delivered
38272 immediately.
38273
38274 If the connecting hosts do not have fixed IP addresses, that is, if a host is
38275 issued with a different IP address each time it connects, Exim's retry
38276 mechanisms on the holding host get confused, because the IP address is normally
38277 used as part of the key string for holding retry information. This can be
38278 avoided by unsetting &%retry_include_ip_address%& on the &(smtp)& transport.
38279 Since this has disadvantages for permanently connected hosts, it is best to
38280 arrange a separate transport for the intermittently connected ones.
38281
38282
38283
38284 .section "Exim on the intermittently connected client host" "SECID248"
38285 The value of &%smtp_accept_queue_per_connection%& should probably be
38286 increased, or even set to zero (that is, disabled) on the intermittently
38287 connected host, so that all incoming messages down a single connection get
38288 delivered immediately.
38289
38290 .cindex "SMTP" "passed connection"
38291 .cindex "SMTP" "multiple deliveries"
38292 .cindex "multiple SMTP deliveries"
38293 .cindex "first pass routing"
38294 Mail waiting to be sent from an intermittently connected host will probably
38295 not have been routed, because without a connection DNS lookups are not
38296 possible. This means that if a normal queue run is done at connection time,
38297 each message is likely to be sent in a separate SMTP session. This can be
38298 avoided by starting the queue run with a command line option beginning with
38299 &%-qq%& instead of &%-q%&. In this case, the queue is scanned twice. In the
38300 first pass, routing is done but no deliveries take place. The second pass is a
38301 normal queue run; since all the messages have been previously routed, those
38302 destined for the same host are likely to get sent as multiple deliveries in a
38303 single SMTP connection.
38304
38305
38306
38307 . ////////////////////////////////////////////////////////////////////////////
38308 . ////////////////////////////////////////////////////////////////////////////
38309
38310 .chapter "Using Exim as a non-queueing client" "CHAPnonqueueing" &&&
38311          "Exim as a non-queueing client"
38312 .cindex "client, non-queueing"
38313 .cindex "smart host" "suppressing queueing"
38314 On a personal computer, it is a common requirement for all
38315 email to be sent to a &"smart host"&. There are plenty of MUAs that can be
38316 configured to operate that way, for all the popular operating systems.
38317 However, there are some MUAs for Unix-like systems that cannot be so
38318 configured: they submit messages using the command line interface of
38319 &_/usr/sbin/sendmail_&. Furthermore, utility programs such as &'cron'& submit
38320 messages this way.
38321
38322 If the personal computer runs continuously, there is no problem, because it can
38323 run a conventional MTA that handles delivery to the smart host, and deal with
38324 any delays via its queueing mechanism. However, if the computer does not run
38325 continuously or runs different operating systems at different times, queueing
38326 email is not desirable.
38327
38328 There is therefore a requirement for something that can provide the
38329 &_/usr/sbin/sendmail_& interface but deliver messages to a smart host without
38330 any queueing or retrying facilities. Furthermore, the delivery to the smart
38331 host should be synchronous, so that if it fails, the sending MUA is immediately
38332 informed. In other words, we want something that extends an MUA that submits
38333 to a local MTA via the command line so that it behaves like one that submits
38334 to a remote smart host using TCP/SMTP.
38335
38336 There are a number of applications (for example, there is one called &'ssmtp'&)
38337 that do this job. However, people have found them to be lacking in various
38338 ways. For instance, you might want to allow aliasing and forwarding to be done
38339 before sending a message to the smart host.
38340
38341 Exim already had the necessary infrastructure for doing this job. Just a few
38342 tweaks were needed to make it behave as required, though it is somewhat of an
38343 overkill to use a fully-featured MTA for this purpose.
38344
38345 .oindex "&%mua_wrapper%&"
38346 There is a Boolean global option called &%mua_wrapper%&, defaulting false.
38347 Setting &%mua_wrapper%& true causes Exim to run in a special mode where it
38348 assumes that it is being used to &"wrap"& a command-line MUA in the manner
38349 just described. As well as setting &%mua_wrapper%&, you also need to provide a
38350 compatible router and transport configuration. Typically there will be just one
38351 router and one transport, sending everything to a smart host.
38352
38353 When run in MUA wrapping mode, the behaviour of Exim changes in the
38354 following ways:
38355
38356 .ilist
38357 A daemon cannot be run, nor will Exim accept incoming messages from &'inetd'&.
38358 In other words, the only way to submit messages is via the command line.
38359 .next
38360 Each message is synchronously delivered as soon as it is received (&%-odi%& is
38361 assumed). All queueing options (&%queue_only%&, &%queue_smtp_domains%&,
38362 &%control%& in an ACL, etc.) are quietly ignored. The Exim reception process
38363 does not finish until the delivery attempt is complete. If the delivery is
38364 successful, a zero return code is given.
38365 .next
38366 Address redirection is permitted, but the final routing for all addresses must
38367 be to the same remote transport, and to the same list of hosts. Furthermore,
38368 the return address (envelope sender) must be the same for all recipients, as
38369 must any added or deleted header lines. In other words, it must be possible to
38370 deliver the message in a single SMTP transaction, however many recipients there
38371 are.
38372 .next
38373 If these conditions are not met, or if routing any address results in a
38374 failure or defer status, or if Exim is unable to deliver all the recipients
38375 successfully to one of the smart hosts, delivery of the entire message fails.
38376 .next
38377 Because no queueing is allowed, all failures are treated as permanent; there
38378 is no distinction between 4&'xx'& and 5&'xx'& SMTP response codes from the
38379 smart host. Furthermore, because only a single yes/no response can be given to
38380 the caller, it is not possible to deliver to some recipients and not others. If
38381 there is an error (temporary or permanent) for any recipient, all are failed.
38382 .next
38383 If more than one smart host is listed, Exim will try another host after a
38384 connection failure or a timeout, in the normal way. However, if this kind of
38385 failure happens for all the hosts, the delivery fails.
38386 .next
38387 When delivery fails, an error message is written to the standard error stream
38388 (as well as to Exim's log), and Exim exits to the caller with a return code
38389 value 1. The message is expunged from Exim's spool files. No bounce messages
38390 are ever generated.
38391 .next
38392 No retry data is maintained, and any retry rules are ignored.
38393 .next
38394 A number of Exim options are overridden: &%deliver_drop_privilege%& is forced
38395 true, &%max_rcpt%& in the &(smtp)& transport is forced to &"unlimited"&,
38396 &%remote_max_parallel%& is forced to one, and fallback hosts are ignored.
38397 .endlist
38398
38399 The overall effect is that Exim makes a single synchronous attempt to deliver
38400 the message, failing if there is any kind of problem. Because no local
38401 deliveries are done and no daemon can be run, Exim does not need root
38402 privilege. It should be possible to run it setuid to &'exim'& instead of setuid
38403 to &'root'&. See section &<<SECTrunexiwitpri>>& for a general discussion about
38404 the advantages and disadvantages of running without root privilege.
38405
38406
38407
38408
38409 . ////////////////////////////////////////////////////////////////////////////
38410 . ////////////////////////////////////////////////////////////////////////////
38411
38412 .chapter "Log files" "CHAPlog"
38413 .scindex IIDloggen "log" "general description"
38414 .cindex "log" "types of"
38415 Exim writes three different logs, referred to as the main log, the reject log,
38416 and the panic log:
38417
38418 .ilist
38419 .cindex "main log"
38420 The main log records the arrival of each message and each delivery in a single
38421 line in each case. The format is as compact as possible, in an attempt to keep
38422 down the size of log files. Two-character flag sequences make it easy to pick
38423 out these lines. A number of other events are recorded in the main log. Some of
38424 them are optional, in which case the &%log_selector%& option controls whether
38425 they are included or not. A Perl script called &'eximstats'&, which does simple
38426 analysis of main log files, is provided in the Exim distribution (see section
38427 &<<SECTmailstat>>&).
38428 .next
38429 .cindex "reject log"
38430 The reject log records information from messages that are rejected as a result
38431 of a configuration option (that is, for policy reasons).
38432 The first line of each rejection is a copy of the line that is also written to
38433 the main log. Then, if the message's header has been read at the time the log
38434 is written, its contents are written to this log. Only the original header
38435 lines are available; header lines added by ACLs are not logged. You can use the
38436 reject log to check that your policy controls are working correctly; on a busy
38437 host this may be easier than scanning the main log for rejection messages. You
38438 can suppress the writing of the reject log by setting &%write_rejectlog%&
38439 false.
38440 .next
38441 .cindex "panic log"
38442 .cindex "system log"
38443 When certain serious errors occur, Exim writes entries to its panic log. If the
38444 error is sufficiently disastrous, Exim bombs out afterwards. Panic log entries
38445 are usually written to the main log as well, but can get lost amid the mass of
38446 other entries. The panic log should be empty under normal circumstances. It is
38447 therefore a good idea to check it (or to have a &'cron'& script check it)
38448 regularly, in order to become aware of any problems. When Exim cannot open its
38449 panic log, it tries as a last resort to write to the system log (syslog). This
38450 is opened with LOG_PID+LOG_CONS and the facility code of LOG_MAIL. The
38451 message itself is written at priority LOG_CRIT.
38452 .endlist
38453
38454 Every log line starts with a timestamp, in the format shown in the following
38455 example. Note that many of the examples shown in this chapter are line-wrapped.
38456 In the log file, this would be all on one line:
38457 .code
38458 2001-09-16 16:09:47 SMTP connection from [127.0.0.1] closed
38459   by QUIT
38460 .endd
38461 By default, the timestamps are in the local timezone. There are two
38462 ways of changing this:
38463
38464 .ilist
38465 You can set the &%timezone%& option to a different time zone; in particular, if
38466 you set
38467 .code
38468 timezone = UTC
38469 .endd
38470 the timestamps will be in UTC (aka GMT).
38471 .next
38472 If you set &%log_timezone%& true, the time zone is added to the timestamp, for
38473 example:
38474 .code
38475 2003-04-25 11:17:07 +0100 Start queue run: pid=12762
38476 .endd
38477 .endlist
38478
38479 .cindex "log" "process ids in"
38480 .cindex "pid (process id)" "in log lines"
38481 Exim does not include its process id in log lines by default, but you can
38482 request that it does so by specifying the &`pid`& log selector (see section
38483 &<<SECTlogselector>>&). When this is set, the process id is output, in square
38484 brackets, immediately after the time and date.
38485
38486
38487
38488
38489 .section "Where the logs are written" "SECTwhelogwri"
38490 .cindex "log" "destination"
38491 .cindex "log" "to file"
38492 .cindex "log" "to syslog"
38493 .cindex "syslog"
38494 The logs may be written to local files, or to syslog, or both. However, it
38495 should be noted that many syslog implementations use UDP as a transport, and
38496 are therefore unreliable in the sense that messages are not guaranteed to
38497 arrive at the loghost, nor is the ordering of messages necessarily maintained.
38498 It has also been reported that on large log files (tens of megabytes) you may
38499 need to tweak syslog to prevent it syncing the file with each write &-- on
38500 Linux this has been seen to make syslog take 90% plus of CPU time.
38501
38502 The destination for Exim's logs is configured by setting LOG_FILE_PATH in
38503 &_Local/Makefile_& or by setting &%log_file_path%& in the runtime
38504 configuration. This latter string is expanded, so it can contain, for example,
38505 references to the host name:
38506 .code
38507 log_file_path = /var/log/$primary_hostname/exim_%slog
38508 .endd
38509 It is generally advisable, however, to set the string in &_Local/Makefile_&
38510 rather than at runtime, because then the setting is available right from the
38511 start of Exim's execution. Otherwise, if there's something it wants to log
38512 before it has read the configuration file (for example, an error in the
38513 configuration file) it will not use the path you want, and may not be able to
38514 log at all.
38515
38516 The value of LOG_FILE_PATH or &%log_file_path%& is a colon-separated
38517 list, currently limited to at most two items. This is one option where the
38518 facility for changing a list separator may not be used. The list must always be
38519 colon-separated. If an item in the list is &"syslog"& then syslog is used;
38520 otherwise the item must either be an absolute path, containing &`%s`& at the
38521 point where &"main"&, &"reject"&, or &"panic"& is to be inserted, or be empty,
38522 implying the use of a default path.
38523
38524 When Exim encounters an empty item in the list, it searches the list defined by
38525 LOG_FILE_PATH, and uses the first item it finds that is neither empty nor
38526 &"syslog"&. This means that an empty item in &%log_file_path%& can be used to
38527 mean &"use the path specified at build time"&. If no such item exists, log
38528 files are written in the &_log_& subdirectory of the spool directory. This is
38529 equivalent to the configuration file setting:
38530 .code
38531 log_file_path = $spool_directory/log/%slog
38532 .endd
38533 If you do not specify anything at build time or runtime,
38534 or if you unset the option at runtime (i.e. &`log_file_path = `&),
38535 that is where the logs are written.
38536
38537 A log file path may also contain &`%D`& or &`%M`& if datestamped log filenames
38538 are in use &-- see section &<<SECTdatlogfil>>& below.
38539
38540 Here are some examples of possible Makefile settings:
38541 .display
38542 &`LOG_FILE_PATH=syslog                    `& syslog only
38543 &`LOG_FILE_PATH=:syslog                   `& syslog and default path
38544 &`LOG_FILE_PATH=syslog : /usr/log/exim_%s `& syslog and specified path
38545 &`LOG_FILE_PATH=/usr/log/exim_%s          `& specified path only
38546 .endd
38547 If there are more than two paths in the list, the first is used and a panic
38548 error is logged.
38549
38550
38551
38552 .section "Logging to local files that are periodically &""cycled""&" "SECID285"
38553 .cindex "log" "cycling local files"
38554 .cindex "cycling logs"
38555 .cindex "&'exicyclog'&"
38556 .cindex "log" "local files; writing to"
38557 Some operating systems provide centralized and standardized methods for cycling
38558 log files. For those that do not, a utility script called &'exicyclog'& is
38559 provided (see section &<<SECTcyclogfil>>&). This renames and compresses the
38560 main and reject logs each time it is called. The maximum number of old logs to
38561 keep can be set. It is suggested this script is run as a daily &'cron'& job.
38562
38563 An Exim delivery process opens the main log when it first needs to write to it,
38564 and it keeps the file open in case subsequent entries are required &-- for
38565 example, if a number of different deliveries are being done for the same
38566 message. However, remote SMTP deliveries can take a long time, and this means
38567 that the file may be kept open long after it is renamed if &'exicyclog'& or
38568 something similar is being used to rename log files on a regular basis. To
38569 ensure that a switch of log files is noticed as soon as possible, Exim calls
38570 &[stat()]& on the main log's name before reusing an open file, and if the file
38571 does not exist, or its inode has changed, the old file is closed and Exim
38572 tries to open the main log from scratch. Thus, an old log file may remain open
38573 for quite some time, but no Exim processes should write to it once it has been
38574 renamed.
38575
38576
38577
38578 .section "Datestamped log files" "SECTdatlogfil"
38579 .cindex "log" "datestamped files"
38580 Instead of cycling the main and reject log files by renaming them
38581 periodically, some sites like to use files whose names contain a datestamp,
38582 for example, &_mainlog-20031225_&. The datestamp is in the form &_yyyymmdd_& or
38583 &_yyyymm_&. Exim has support for this way of working. It is enabled by setting
38584 the &%log_file_path%& option to a path that includes &`%D`& or &`%M`& at the
38585 point where the datestamp is required. For example:
38586 .code
38587 log_file_path = /var/spool/exim/log/%slog-%D
38588 log_file_path = /var/log/exim-%s-%D.log
38589 log_file_path = /var/spool/exim/log/%D-%slog
38590 log_file_path = /var/log/exim/%s.%M
38591 .endd
38592 As before, &`%s`& is replaced by &"main"& or &"reject"&; the following are
38593 examples of names generated by the above examples:
38594 .code
38595 /var/spool/exim/log/mainlog-20021225
38596 /var/log/exim-reject-20021225.log
38597 /var/spool/exim/log/20021225-mainlog
38598 /var/log/exim/main.200212
38599 .endd
38600 When this form of log file is specified, Exim automatically switches to new
38601 files at midnight. It does not make any attempt to compress old logs; you
38602 will need to write your own script if you require this. You should not
38603 run &'exicyclog'& with this form of logging.
38604
38605 The location of the panic log is also determined by &%log_file_path%&, but it
38606 is not datestamped, because rotation of the panic log does not make sense.
38607 When generating the name of the panic log, &`%D`& or &`%M`& are removed from
38608 the string. In addition, if it immediately follows a slash, a following
38609 non-alphanumeric character is removed; otherwise a preceding non-alphanumeric
38610 character is removed. Thus, the four examples above would give these panic
38611 log names:
38612 .code
38613 /var/spool/exim/log/paniclog
38614 /var/log/exim-panic.log
38615 /var/spool/exim/log/paniclog
38616 /var/log/exim/panic
38617 .endd
38618
38619
38620 .section "Logging to syslog" "SECID249"
38621 .cindex "log" "syslog; writing to"
38622 The use of syslog does not change what Exim logs or the format of its messages,
38623 except in one respect. If &%syslog_timestamp%& is set false, the timestamps on
38624 Exim's log lines are omitted when these lines are sent to syslog. Apart from
38625 that, the same strings are written to syslog as to log files. The syslog
38626 &"facility"& is set to LOG_MAIL, and the program name to &"exim"&
38627 by default, but you can change these by setting the &%syslog_facility%& and
38628 &%syslog_processname%& options, respectively. If Exim was compiled with
38629 SYSLOG_LOG_PID set in &_Local/Makefile_& (this is the default in
38630 &_src/EDITME_&), then, on systems that permit it (all except ULTRIX), the
38631 LOG_PID flag is set so that the &[syslog()]& call adds the pid as well as
38632 the time and host name to each line.
38633 The three log streams are mapped onto syslog priorities as follows:
38634
38635 .ilist
38636 &'mainlog'& is mapped to LOG_INFO
38637 .next
38638 &'rejectlog'& is mapped to LOG_NOTICE
38639 .next
38640 &'paniclog'& is mapped to LOG_ALERT
38641 .endlist
38642
38643 Many log lines are written to both &'mainlog'& and &'rejectlog'&, and some are
38644 written to both &'mainlog'& and &'paniclog'&, so there will be duplicates if
38645 these are routed by syslog to the same place. You can suppress this duplication
38646 by setting &%syslog_duplication%& false.
38647
38648 Exim's log lines can sometimes be very long, and some of its &'rejectlog'&
38649 entries contain multiple lines when headers are included. To cope with both
38650 these cases, entries written to syslog are split into separate &[syslog()]&
38651 calls at each internal newline, and also after a maximum of
38652 870 data characters. (This allows for a total syslog line length of 1024, when
38653 additions such as timestamps are added.) If you are running a syslog
38654 replacement that can handle lines longer than the 1024 characters allowed by
38655 RFC 3164, you should set
38656 .code
38657 SYSLOG_LONG_LINES=yes
38658 .endd
38659 in &_Local/Makefile_& before building Exim. That stops Exim from splitting long
38660 lines, but it still splits at internal newlines in &'reject'& log entries.
38661
38662 To make it easy to re-assemble split lines later, each component of a split
38663 entry starts with a string of the form [<&'n'&>/<&'m'&>] or [<&'n'&>\<&'m'&>]
38664 where <&'n'&> is the component number and <&'m'&> is the total number of
38665 components in the entry. The / delimiter is used when the line was split
38666 because it was too long; if it was split because of an internal newline, the \
38667 delimiter is used. For example, supposing the length limit to be 50 instead of
38668 870, the following would be the result of a typical rejection message to
38669 &'mainlog'& (LOG_INFO), each line in addition being preceded by the time, host
38670 name, and pid as added by syslog:
38671 .code
38672 [1/5] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from
38673 [2/5]  [127.0.0.1] (ph10): syntax error in 'From' header
38674 [3/5]  when scanning for sender: missing or malformed lo
38675 [4/5] cal part in "<>" (envelope sender is <ph10@cam.exa
38676 [5/5] mple>)
38677 .endd
38678 The same error might cause the following lines to be written to &"rejectlog"&
38679 (LOG_NOTICE):
38680 .code
38681 [1/18] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected fro
38682 [2/18] m [127.0.0.1] (ph10): syntax error in 'From' head
38683 [3/18] er when scanning for sender: missing or malformed
38684 [4/18]  local part in "<>" (envelope sender is <ph10@cam
38685 [5\18] .example>)
38686 [6\18] Recipients: ph10@some.domain.cam.example
38687 [7\18] P Received: from [127.0.0.1] (ident=ph10)
38688 [8\18]        by xxxxx.cam.example with smtp (Exim 4.00)
38689 [9\18]        id 16RdAL-0006pc-00
38690 [10/18]        for ph10@cam.example; Mon, 16 Sep 2002 16:
38691 [11\18] 09:43 +0100
38692 [12\18] F From: <>
38693 [13\18]   Subject: this is a test header
38694 [18\18]   X-something: this is another header
38695 [15/18] I Message-Id: <E16RdAL-0006pc-00@xxxxx.cam.examp
38696 [16\18] le>
38697 [17\18] B Bcc:
38698 [18/18]   Date: Mon, 16 Sep 2002 16:09:43 +0100
38699 .endd
38700 Log lines that are neither too long nor contain newlines are written to syslog
38701 without modification.
38702
38703 If only syslog is being used, the Exim monitor is unable to provide a log tail
38704 display, unless syslog is routing &'mainlog'& to a file on the local host and
38705 the environment variable EXIMON_LOG_FILE_PATH is set to tell the monitor
38706 where it is.
38707
38708
38709
38710 .section "Log line flags" "SECID250"
38711 One line is written to the main log for each message received, and for each
38712 successful, unsuccessful, and delayed delivery. These lines can readily be
38713 picked out by the distinctive two-character flags that immediately follow the
38714 timestamp. The flags are:
38715 .itable none 0 0 2 10* left 90* left
38716 .irow &%<=%&     "message arrival"
38717 .irow &%(=%&     "message fakereject"
38718 .irow &%=>%&     "normal message delivery"
38719 .irow &%->%&     "additional address in same delivery"
38720 .irow &%>>%&     "cutthrough message delivery"
38721 .irow &%*>%&     "delivery suppressed by &%-N%&"
38722 .irow &%**%&     "delivery failed; address bounced"
38723 .irow &%==%&     "delivery deferred; temporary problem"
38724 .endtable
38725
38726
38727 .section "Logging message reception" "SECID251"
38728 .cindex "log" "reception line"
38729 The format of the single-line entry in the main log that is written for every
38730 message received is shown in the basic example below, which is split over
38731 several lines in order to fit it on the page:
38732 .code
38733 2002-10-31 08:57:53 16ZCW1-0005MB-00 <= kryten@dwarf.fict.example
38734   H=mailer.fict.example [192.168.123.123] U=exim
38735   P=smtp S=5678 id=<incoming message id>
38736 .endd
38737 The address immediately following &"<="& is the envelope sender address. A
38738 bounce message is shown with the sender address &"<>"&, and if it is locally
38739 generated, this is followed by an item of the form
38740 .code
38741 R=<message id>
38742 .endd
38743 which is a reference to the message that caused the bounce to be sent.
38744
38745 .cindex "HELO"
38746 .cindex "EHLO"
38747 For messages from other hosts, the H and U fields identify the remote host and
38748 record the RFC 1413 identity of the user that sent the message, if one was
38749 received. The number given in square brackets is the IP address of the sending
38750 host. If there is a single, unparenthesized  host name in the H field, as
38751 above, it has been verified to correspond to the IP address (see the
38752 &%host_lookup%& option). If the name is in parentheses, it was the name quoted
38753 by the remote host in the SMTP HELO or EHLO command, and has not been
38754 verified. If verification yields a different name to that given for HELO or
38755 EHLO, the verified name appears first, followed by the HELO or EHLO
38756 name in parentheses.
38757
38758 Misconfigured hosts (and mail forgers) sometimes put an IP address, with or
38759 without brackets, in the HELO or EHLO command, leading to entries in
38760 the log containing text like these examples:
38761 .code
38762 H=(10.21.32.43) [192.168.8.34]
38763 H=([10.21.32.43]) [192.168.8.34]
38764 .endd
38765 This can be confusing. Only the final address in square brackets can be relied
38766 on.
38767
38768 For locally generated messages (that is, messages not received over TCP/IP),
38769 the H field is omitted, and the U field contains the login name of the caller
38770 of Exim.
38771
38772 .cindex "authentication" "logging"
38773 .cindex "AUTH" "logging"
38774 For all messages, the P field specifies the protocol used to receive the
38775 message. This is the value that is stored in &$received_protocol$&. In the case
38776 of incoming SMTP messages, the value indicates whether or not any SMTP
38777 extensions (ESMTP), encryption, or authentication were used. If the SMTP
38778 session was encrypted, there is an additional X field that records the cipher
38779 suite that was used.
38780
38781 .cindex log protocol
38782 The protocol is set to &"esmtpsa"& or &"esmtpa"& for messages received from
38783 hosts that have authenticated themselves using the SMTP AUTH command. The first
38784 value is used when the SMTP connection was encrypted (&"secure"&). In this case
38785 there is an additional item A= followed by the name of the authenticator that
38786 was used. If an authenticated identification was set up by the authenticator's
38787 &%server_set_id%& option, this is logged too, separated by a colon from the
38788 authenticator name.
38789
38790 .cindex "size" "of message"
38791 The id field records the existing message id, if present. The size of the
38792 received message is given by the S field. When the message is delivered,
38793 headers may be removed or added, so that the size of delivered copies of the
38794 message may not correspond with this value (and indeed may be different to each
38795 other).
38796
38797 The &%log_selector%& option can be used to request the logging of additional
38798 data when a message is received. See section &<<SECTlogselector>>& below.
38799
38800
38801
38802 .section "Logging deliveries" "SECID252"
38803 .cindex "log" "delivery line"
38804 The format of the single-line entry in the main log that is written for every
38805 delivery is shown in one of the examples below, for local and remote
38806 deliveries, respectively. Each example has been split into multiple lines in order
38807 to fit it on the page:
38808 .code
38809 2002-10-31 08:59:13 16ZCW1-0005MB-00 => marv
38810   <marv@hitch.fict.example> R=localuser T=local_delivery
38811 2002-10-31 09:00:10 16ZCW1-0005MB-00 =>
38812   monk@holistic.fict.example R=dnslookup T=remote_smtp
38813   H=holistic.fict.example [192.168.234.234]
38814 .endd
38815 For ordinary local deliveries, the original address is given in angle brackets
38816 after the final delivery address, which might be a pipe or a file. If
38817 intermediate address(es) exist between the original and the final address, the
38818 last of these is given in parentheses after the final address. The R and T
38819 fields record the router and transport that were used to process the address.
38820
38821 If SMTP AUTH was used for the delivery there is an additional item A=
38822 followed by the name of the authenticator that was used.
38823 If an authenticated identification was set up by the authenticator's &%client_set_id%&
38824 option, this is logged too, as a second colon-separated list item.
38825 Optionally (see the &%smtp_mailauth%& &%log_selector%&) there may be a third list item.
38826
38827 If a shadow transport was run after a successful local delivery, the log line
38828 for the successful delivery has an item added on the end, of the form
38829 .display
38830 &`ST=<`&&'shadow transport name'&&`>`&
38831 .endd
38832 If the shadow transport did not succeed, the error message is put in
38833 parentheses afterwards.
38834
38835 .cindex "asterisk" "after IP address"
38836 When more than one address is included in a single delivery (for example, two
38837 SMTP RCPT commands in one transaction) the second and subsequent addresses are
38838 flagged with &`->`& instead of &`=>`&. When two or more messages are delivered
38839 down a single SMTP connection, an asterisk follows the
38840 remote IP address (and port if enabled)
38841 in the log lines for the second and subsequent messages.
38842 When two or more messages are delivered down a single TLS connection, the
38843 DNS and some TLS-related information logged for the first message delivered
38844 will not be present in the log lines for the second and subsequent messages.
38845 TLS cipher information is still available.
38846
38847 .cindex "delivery" "cutthrough; logging"
38848 .cindex "cutthrough" "logging"
38849 When delivery is done in cutthrough mode it is flagged with &`>>`& and the log
38850 line precedes the reception line, since cutthrough waits for a possible
38851 rejection from the destination in case it can reject the sourced item.
38852
38853 The generation of a reply message by a filter file gets logged as a
38854 &"delivery"& to the addressee, preceded by &">"&.
38855
38856 The &%log_selector%& option can be used to request the logging of additional
38857 data when a message is delivered. See section &<<SECTlogselector>>& below.
38858
38859
38860 .section "Discarded deliveries" "SECID253"
38861 .cindex "discarded messages"
38862 .cindex "message" "discarded"
38863 .cindex "delivery" "discarded; logging"
38864 When a message is discarded as a result of the command &"seen finish"& being
38865 obeyed in a filter file which generates no deliveries, a log entry of the form
38866 .code
38867 2002-12-10 00:50:49 16auJc-0001UB-00 => discarded
38868   <low.club@bridge.example> R=userforward
38869 .endd
38870 is written, to record why no deliveries are logged. When a message is discarded
38871 because it is aliased to &":blackhole:"& the log line is like this:
38872 .code
38873 1999-03-02 09:44:33 10HmaX-0005vi-00 => :blackhole:
38874   <hole@nowhere.example> R=blackhole_router
38875 .endd
38876
38877
38878 .section "Deferred deliveries" "SECID254"
38879 When a delivery is deferred, a line of the following form is logged:
38880 .code
38881 2002-12-19 16:20:23 16aiQz-0002Q5-00 == marvin@endrest.example
38882   R=dnslookup T=smtp defer (146): Connection refused
38883 .endd
38884 In the case of remote deliveries, the error is the one that was given for the
38885 last IP address that was tried. Details of individual SMTP failures are also
38886 written to the log, so the above line would be preceded by something like
38887 .code
38888 2002-12-19 16:20:23 16aiQz-0002Q5-00 Failed to connect to
38889   mail1.endrest.example [192.168.239.239]: Connection refused
38890 .endd
38891 When a deferred address is skipped because its retry time has not been reached,
38892 a message is written to the log, but this can be suppressed by setting an
38893 appropriate value in &%log_selector%&.
38894
38895
38896
38897 .section "Delivery failures" "SECID255"
38898 .cindex "delivery" "failure; logging"
38899 If a delivery fails because an address cannot be routed, a line of the
38900 following form is logged:
38901 .code
38902 1995-12-19 16:20:23 0tRiQz-0002Q5-00 ** jim@trek99.example
38903   <jim@trek99.example>: unknown mail domain
38904 .endd
38905 If a delivery fails at transport time, the router and transport are shown, and
38906 the response from the remote host is included, as in this example:
38907 .code
38908 2002-07-11 07:14:17 17SXDU-000189-00 ** ace400@pb.example
38909   R=dnslookup T=remote_smtp: SMTP error from remote mailer
38910   after pipelined RCPT TO:<ace400@pb.example>: host
38911   pbmail3.py.example [192.168.63.111]: 553 5.3.0
38912   <ace400@pb.example>...Addressee unknown
38913 .endd
38914 The word &"pipelined"& indicates that the SMTP PIPELINING extension was being
38915 used. See &%hosts_avoid_esmtp%& in the &(smtp)& transport for a way of
38916 disabling PIPELINING. The log lines for all forms of delivery failure are
38917 flagged with &`**`&.
38918
38919
38920
38921 .section "Fake deliveries" "SECID256"
38922 .cindex "delivery" "fake; logging"
38923 If a delivery does not actually take place because the &%-N%& option has been
38924 used to suppress it, a normal delivery line is written to the log, except that
38925 &"=>"& is replaced by &"*>"&.
38926
38927
38928
38929 .section "Completion" "SECID257"
38930 A line of the form
38931 .code
38932 2002-10-31 09:00:11 16ZCW1-0005MB-00 Completed
38933 .endd
38934 is written to the main log when a message is about to be removed from the spool
38935 at the end of its processing.
38936
38937
38938
38939
38940 .section "Summary of Fields in Log Lines" "SECID258"
38941 .cindex "log" "summary of fields"
38942 A summary of the field identifiers that are used in log lines is shown in
38943 the following table:
38944 .display
38945 &`A   `&        authenticator name (and optional id and sender)
38946 &`C   `&        SMTP confirmation on delivery
38947 &`Ci  `&        connection identifier
38948 &`    `&        command list for &"no mail in SMTP session"&
38949 &`CV  `&        certificate verification status
38950 &`D   `&        duration of &"no mail in SMTP session"&
38951 &`DKIM`&        domain verified in incoming message
38952 &`DN  `&        distinguished name from peer certificate
38953 &`DS  `&        DNSSEC secured lookups
38954 &`DT  `&        on &`=>`&, &'=='& and &'**'& lines: time taken for, or to attempt, a delivery
38955 &`F   `&        sender address (on delivery lines)
38956 &`H   `&        host name and IP address
38957 &`I   `&        local interface used
38958 &`id  `&        message id (from header) for incoming message
38959 &`K   `&        CHUNKING extension used
38960 &`L   `&        on &`<=`& and &`=>`& lines: PIPELINING extension used
38961 &`M8S `&        8BITMIME status for incoming message
38962 &`P   `&        on &`<=`& lines: protocol used
38963 &`    `&        on &`=>`& and &`**`& lines: return path
38964 &`PRDR`&        PRDR extension used
38965 &`PRX `&        on &`<=`& and &`=>`& lines: proxy address
38966 &`Q   `&        alternate queue name
38967 &`QT  `&        on &`=>`& lines: time spent on queue so far
38968 &`    `&        on &"Completed"& lines: time spent on queue
38969 &`R   `&        on &`<=`& lines: reference for local bounce
38970 &`    `&        on &`=>`&  &`>>`& &`**`& and &`==`& lines: router name
38971 &`RT  `&        on &`<=`& lines: time taken for reception
38972 &`S   `&        size of message in bytes
38973 &`SNI `&        server name indication from TLS client hello
38974 &`ST  `&        shadow transport name
38975 &`T   `&        on &`<=`& lines: message subject (topic)
38976 &`TFO `&        connection took advantage of TCP Fast Open
38977 &`    `&        on &`=>`& &`**`& and &`==`& lines: transport name
38978 &`U   `&        local user or RFC 1413 identity
38979 &`X   `&        TLS cipher suite
38980 .endd
38981
38982
38983 .section "Other log entries" "SECID259"
38984 Various other types of log entry are written from time to time. Most should be
38985 self-explanatory. Among the more common are:
38986
38987 .ilist
38988 .cindex "retry" "time not reached"
38989 &'retry time not reached'&&~&~An address previously suffered a temporary error
38990 during routing or local delivery, and the time to retry has not yet arrived.
38991 This message is not written to an individual message log file unless it happens
38992 during the first delivery attempt.
38993 .next
38994 &'retry time not reached for any host'&&~&~An address previously suffered
38995 temporary errors during remote delivery, and the retry time has not yet arrived
38996 for any of the hosts to which it is routed.
38997 .next
38998 .cindex "spool directory" "file locked"
38999 &'spool file locked'&&~&~An attempt to deliver a message cannot proceed because
39000 some other Exim process is already working on the message. This can be quite
39001 common if queue running processes are started at frequent intervals. The
39002 &'exiwhat'& utility script can be used to find out what Exim processes are
39003 doing.
39004 .next
39005 .cindex "error" "ignored"
39006 &'error ignored'&&~&~There are several circumstances that give rise to this
39007 message:
39008 .olist
39009 Exim failed to deliver a bounce message whose age was greater than
39010 &%ignore_bounce_errors_after%&. The bounce was discarded.
39011 .next
39012 A filter file set up a delivery using the &"noerror"& option, and the delivery
39013 failed. The delivery was discarded.
39014 .next
39015 A delivery set up by a router configured with
39016 . ==== As this is a nested list, any displays it contains must be indented
39017 . ==== as otherwise they are too far to the left.
39018 .code
39019     errors_to = <>
39020 .endd
39021 failed. The delivery was discarded.
39022 .endlist olist
39023 .next
39024 .cindex DKIM "log line"
39025 &'DKIM: d='&&~&~Verbose results of a DKIM verification attempt, if enabled for
39026 logging and the message has a DKIM signature header.
39027 .endlist ilist
39028
39029
39030
39031
39032
39033 .section "Reducing or increasing what is logged" "SECTlogselector"
39034 .cindex "log" "selectors"
39035 By setting the &%log_selector%& global option, you can disable some of Exim's
39036 default logging to the main log, or you can request additional logging. The value of
39037 &%log_selector%& is made up of names preceded by plus or minus characters. For
39038 example:
39039 .code
39040 log_selector = +arguments -retry_defer
39041 .endd
39042 The list of optional log items is in the following table, with the default
39043 selection marked by asterisks:
39044 .itable none 0 0 3 2.8in left 10pt center 3in left
39045 .irow &`8bitmime`&                      &nbsp; "received 8BITMIME status"
39046 .irow &`acl_warn_skipped`&              *       "skipped &%warn%& statement in ACL"
39047 .irow &`address_rewrite`&               &nbsp; "address rewriting"
39048 .irow &`all_parents`&                   &nbsp; "all parents in => lines"
39049 .irow &`arguments`&                     &nbsp; "command line arguments"
39050 .irow &`connection_id`&                 &nbsp;  "connection identifier"
39051 .irow &`connection_reject`&             *       "connection rejections"
39052 .irow &`delay_delivery`&                *       "immediate delivery delayed"
39053 .irow &`deliver_time`&                  &nbsp; "time taken to attempt delivery"
39054 .irow &`delivery_size`&                 &nbsp; "add &`S=`&&'nnn'& to => lines"
39055 .irow &`dkim`&                          *       "DKIM verified domain on <= lines"
39056 .irow &`dkim_verbose`&                  &nbsp; "separate full DKIM verification result line, per signature"
39057 .irow &`dnslist_defer`&                 *       "defers of DNS list (aka RBL) lookups"
39058 .irow &`dnssec`&                        &nbsp; "DNSSEC secured lookups"
39059 .irow &`etrn`&                          *       "ETRN commands"
39060 .irow &`host_lookup_failed`&            *       "as it says"
39061 .irow &`ident_timeout`&                 &nbsp; "timeout for ident connection"
39062 .irow &`incoming_interface`&            &nbsp; "local interface &amp; port on <= and => lines"
39063 .irow &`incoming_port`&                 &nbsp; "remote port on <= lines"
39064 .irow &`lost_incoming_connection`&      *       "as it says (includes timeouts)"
39065 .irow &`millisec`&                      &nbsp; "millisecond timestamps and RT,QT,DT,D times"
39066 .irow &`msg_id`&                        *       "on <= lines, Message-ID: header value"
39067 .irow &`msg_id_created`&                &nbsp; "on <= lines, Message-ID: header value when one had to be added"
39068 .irow &`outgoing_interface`&            &nbsp; "local interface on => lines"
39069 .irow &`outgoing_port`&                 &nbsp; "add remote port to => lines"
39070 .irow &`queue_run`&                     *       "start and end queue runs"
39071 .irow &`queue_time`&                    &nbsp; "time on queue for one recipient"
39072 .irow &`queue_time_exclusive`&          &nbsp; "exclude recieve time from QT times"
39073 .irow &`queue_time_overall`&            &nbsp; "time on queue for whole message"
39074 .irow &`pid`&                           &nbsp; "Exim process id"
39075 .irow &`pipelining`&                    &nbsp; "PIPELINING use, on <= and => lines"
39076 .irow &`proxy`&                         &nbsp; "proxy address on <= and => lines"
39077 .irow &`receive_time`&                  &nbsp; "time taken to receive message"
39078 .irow &`received_recipients`&           &nbsp; "recipients on <= lines"
39079 .irow &`received_sender`&               &nbsp; "sender on <= lines"
39080 .irow &`rejected_header`&               *       "header contents on reject log"
39081 .irow &`retry_defer`&                   *       "&<quote>&retry time not reached&</quote>&"
39082 .irow &`return_path_on_delivery`&       &nbsp; "put return path on => and ** lines"
39083 .irow &`sender_on_delivery`&            &nbsp; "add sender to => lines"
39084 .irow &`sender_verify_fail`&            *       "sender verification failures"
39085 .irow &`size_reject`&                   *       "rejection because too big"
39086 .irow &`skip_delivery`&                 *       "delivery skipped in a queue run"
39087 .irow &`smtp_confirmation`&             *       "SMTP confirmation on => lines"
39088 .irow &`smtp_connection`&               &nbsp; "incoming SMTP connections"
39089 .irow &`smtp_incomplete_transaction`&   &nbsp; "incomplete SMTP transactions"
39090 .irow &`smtp_mailauth`&                 &nbsp; "AUTH argument to MAIL commands"
39091 .irow &`smtp_no_mail`&                  &nbsp; "session with no MAIL commands"
39092 .irow &`smtp_protocol_error`&           &nbsp; "SMTP protocol errors"
39093 .irow &`smtp_syntax_error`&             &nbsp; "SMTP syntax errors"
39094 .irow &`subject`&                       &nbsp; "contents of &'Subject:'& on <= lines"
39095 .irow &`tls_certificate_verified`&      *       "certificate verification status"
39096 .irow &`tls_cipher`&                    *       "TLS cipher suite on <= and => lines"
39097 .irow &`tls_peerdn`&                    &nbsp; "TLS peer DN on <= and => lines"
39098 .irow &`tls_resumption`&                &nbsp; "append * to cipher field"
39099 .irow &`tls_sni`&                       &nbsp; "TLS SNI on <= lines"
39100 .irow &`unknown_in_list`&               &nbsp; "DNS lookup failed in list match"
39101 .irow &`all`&                           &nbsp; "&*all of the above*&"
39102 .endtable
39103 See also the &%slow_lookup_log%& main configuration option,
39104 section &<<SECID99>>&
39105
39106 More details on each of these items follows:
39107
39108 .ilist
39109 .cindex "8BITMIME"
39110 .cindex "log" "8BITMIME"
39111 &%8bitmime%&: This causes Exim to log any 8BITMIME status of received messages,
39112 which may help in tracking down interoperability issues with ancient MTAs
39113 that are not 8bit clean.  This is added to the &"<="& line, tagged with
39114 &`M8S=`& and a value of &`0`&, &`7`& or &`8`&, corresponding to "not given",
39115 &`7BIT`& and &`8BITMIME`& respectively.
39116 .next
39117 .cindex "&%warn%& ACL verb" "log when skipping"
39118 &%acl_warn_skipped%&: When an ACL &%warn%& statement is skipped because one of
39119 its conditions cannot be evaluated, a log line to this effect is written if
39120 this log selector is set.
39121 .next
39122 .cindex "log" "rewriting"
39123 .cindex "rewriting" "logging"
39124 &%address_rewrite%&: This applies both to global rewrites and per-transport
39125 rewrites, but not to rewrites in filters run as an unprivileged user (because
39126 such users cannot access the log).
39127 .next
39128 .cindex "log" "full parentage"
39129 &%all_parents%&: Normally only the original and final addresses are logged on
39130 delivery lines; with this selector, intermediate parents are given in
39131 parentheses between them.
39132 .next
39133 .cindex "log" "Exim arguments"
39134 .cindex "Exim arguments, logging"
39135 &%arguments%&: This causes Exim to write the arguments with which it was called
39136 to the main log, preceded by the current working directory. This is a debugging
39137 feature, added to make it easier to find out how certain MUAs call
39138 &_/usr/sbin/sendmail_&. The logging does not happen if Exim has given up root
39139 privilege because it was called with the &%-C%& or &%-D%& options. Arguments
39140 that are empty or that contain white space are quoted. Non-printing characters
39141 are shown as escape sequences. This facility cannot log unrecognized arguments,
39142 because the arguments are checked before the configuration file is read. The
39143 only way to log such cases is to interpose a script such as &_util/logargs.sh_&
39144 between the caller and Exim.
39145 .next
39146 .cindex "log" "connection identifier"
39147 &%connection_identifier%&: An identifier for the accepted connection is added to
39148 connection start and end lines and to message accept lines.
39149 The identifier is tagged by Ci=.
39150 The value is PID-based, so will reset on reboot and will wrap.
39151 .next
39152 .cindex "log" "connection rejections"
39153 &%connection_reject%&: A log entry is written whenever an incoming SMTP
39154 connection is rejected, for whatever reason.
39155 .next
39156 .cindex "log" "delayed delivery"
39157 .cindex "delayed delivery, logging"
39158 &%delay_delivery%&: A log entry is written whenever a delivery process is not
39159 started for an incoming message because the load is too high or too many
39160 messages were received on one connection. Logging does not occur if no delivery
39161 process is started because &%queue_only%& is set or &%-odq%& was used.
39162 .next
39163 .cindex "log" "delivery duration"
39164 &%deliver_time%&: For each delivery, the amount of real time it has taken to
39165 perform the actual delivery is logged as DT=<&'time'&>, for example, &`DT=1s`&.
39166 If millisecond logging is enabled, short times will be shown with greater
39167 precision, eg. &`DT=0.304s`&.
39168 .next
39169 .cindex "log" "message size on delivery"
39170 .cindex "size" "of message"
39171 &%delivery_size%&: For each delivery, the size of message delivered is added to
39172 the &"=>"& line, tagged with S=.
39173 .next
39174 .cindex log "DKIM verification"
39175 .cindex DKIM "verification logging"
39176 &%dkim%&: For message acceptance log lines, when an DKIM signature in the header
39177 verifies successfully a tag of DKIM is added, with one of the verified domains.
39178 .next
39179 .cindex log "DKIM verification"
39180 .cindex DKIM "verification logging"
39181 &%dkim_verbose%&: A log entry is written for each attempted DKIM verification.
39182 .next
39183 .cindex "log" "dnslist defer"
39184 .cindex "DNS list" "logging defer"
39185 .cindex "black list (DNS)"
39186 &%dnslist_defer%&: A log entry is written if an attempt to look up a host in a
39187 DNS black list suffers a temporary error.
39188 .next
39189 .cindex log dnssec
39190 .cindex dnssec logging
39191 &%dnssec%&: For message acceptance and (attempted) delivery log lines, when
39192 dns lookups gave secure results a tag of DS is added.
39193 For acceptance this covers the reverse and forward lookups for host name verification.
39194 It does not cover helo-name verification.
39195 For delivery this covers the SRV, MX, A and/or AAAA lookups.
39196 .next
39197 .cindex "log" "ETRN commands"
39198 .cindex "ETRN" "logging"
39199 &%etrn%&: Every valid ETRN command that is received is logged, before the ACL
39200 is run to determine whether or not it is actually accepted. An invalid ETRN
39201 command, or one received within a message transaction is not logged by this
39202 selector (see &%smtp_syntax_error%& and &%smtp_protocol_error%&).
39203 .next
39204 .cindex "log" "host lookup failure"
39205 &%host_lookup_failed%&: When a lookup of a host's IP addresses fails to find
39206 any addresses, or when a lookup of an IP address fails to find a host name, a
39207 log line is written. This logging does not apply to direct DNS lookups when
39208 routing email addresses, but it does apply to &"byname"& lookups.
39209 .next
39210 .cindex "log" "ident timeout"
39211 .cindex "RFC 1413" "logging timeout"
39212 &%ident_timeout%&: A log line is written whenever an attempt to connect to a
39213 client's ident port times out.
39214 .next
39215 .cindex "log" "incoming interface"
39216 .cindex "log" "outgoing interface"
39217 .cindex "log" "local interface"
39218 .cindex "log" "local address and port"
39219 .cindex "TCP/IP" "logging local address and port"
39220 .cindex "interface" "logging"
39221 &%incoming_interface%&: The interface on which a message was received is added
39222 to the &"<="& line as an IP address in square brackets, tagged by I= and
39223 followed by a colon and the port number. The local interface and port are also
39224 added to other SMTP log lines, for example, &"SMTP connection from"&, to
39225 rejection lines, and (despite the name) to outgoing
39226 &"=>"&, &"->"&, &"=="& and &"**"& lines.
39227 The latter can be disabled by turning off the &%outgoing_interface%& option.
39228 .next
39229 .cindex log "incoming proxy address"
39230 .cindex proxy "logging proxy address"
39231 .cindex "TCP/IP" "logging proxy address"
39232 &%proxy%&: The internal (closest to the system running Exim) IP address
39233 of the proxy, tagged by PRX=, on the &"<="& line for a message accepted
39234 on a proxied connection
39235 or the &"=>"& line for a message delivered on a proxied connection.
39236 See &<<SECTproxyInbound>>& for more information.
39237 .next
39238 .cindex "log" "incoming remote port"
39239 .cindex "port" "logging remote"
39240 .cindex "TCP/IP" "logging incoming remote port"
39241 .vindex "&$sender_fullhost$&"
39242 .vindex "&$sender_rcvhost$&"
39243 &%incoming_port%&: The remote port number from which a message was received is
39244 added to log entries and &'Received:'& header lines, following the IP address
39245 in square brackets, and separated from it by a colon. This is implemented by
39246 changing the value that is put in the &$sender_fullhost$& and
39247 &$sender_rcvhost$& variables. Recording the remote port number has become more
39248 important with the widening use of NAT (see RFC 2505).
39249 .next
39250 .cindex "log" "dropped connection"
39251 &%lost_incoming_connection%&: A log line is written when an incoming SMTP
39252 connection is unexpectedly dropped.
39253 .next
39254 .cindex "log" "millisecond timestamps"
39255 .cindex millisecond logging
39256 .cindex timestamps "millisecond, in logs"
39257 &%millisec%&: Timestamps have a period and three decimal places of finer granularity
39258 appended to the seconds value.
39259 .next
39260 .cindex "log" "message id"
39261 &%msg_id%&: The value of the Message-ID: header.
39262 .next
39263 &%msg_id_created%&: The value of the Message-ID: header, when one had to be created.
39264 This will be either because the message is a bounce, or was submitted locally
39265 (submission mode) without one.
39266 The field identifier will have an asterix appended: &"id*="&.
39267 .next
39268 .cindex "log" "outgoing interface"
39269 .cindex "log" "local interface"
39270 .cindex "log" "local address and port"
39271 .cindex "TCP/IP" "logging local address and port"
39272 .cindex "interface" "logging"
39273 &%outgoing_interface%&: If &%incoming_interface%& is turned on, then the
39274 interface on which a message was sent is added to delivery lines as an I= tag
39275 followed by IP address in square brackets. You can disable this by turning
39276 off the &%outgoing_interface%& option.
39277 .next
39278 .cindex "log" "outgoing remote port"
39279 .cindex "port" "logging outgoing remote"
39280 .cindex "TCP/IP" "logging outgoing remote port"
39281 &%outgoing_port%&: The remote port number is added to delivery log lines (those
39282 containing => tags) following the IP address.
39283 The local port is also added if &%incoming_interface%& and
39284 &%outgoing_interface%& are both enabled.
39285 This option is not included in the default setting, because for most ordinary
39286 configurations, the remote port number is always 25 (the SMTP port), and the
39287 local port is a random ephemeral port.
39288 .next
39289 .cindex "log" "process ids in"
39290 .cindex "pid (process id)" "in log lines"
39291 &%pid%&: The current process id is added to every log line, in square brackets,
39292 immediately after the time and date.
39293 .next
39294 .cindex log pipelining
39295 .cindex pipelining "logging outgoing"
39296 &%pipelining%&: A field is added to delivery and accept
39297 log lines when the ESMTP PIPELINING extension was used.
39298 The field is a single "L".
39299
39300 On accept lines, where PIPELINING was offered but not used by the client,
39301 the field has a minus appended.
39302
39303 .cindex "pipelining" "early connection"
39304 If Exim is built without the DISABLE_PIPE_CONNECT build option
39305 accept "L" fields have a period appended if the feature was
39306 offered but not used, or an asterisk appended if used.
39307 Delivery "L" fields have an asterisk appended if used.
39308
39309 .next
39310 .cindex "log" "queue run"
39311 .cindex "queue runner" "logging"
39312 &%queue_run%&: The start and end of every queue run are logged.
39313 .next
39314 .cindex "log" "queue time"
39315 &%queue_time%&: The amount of time the message has been in the queue on the
39316 local host is logged as QT=<&'time'&> on delivery (&`=>`&) lines, for example,
39317 &`QT=3m45s`&.
39318 If millisecond logging is enabled, short times will be shown with greater
39319 precision, eg. &`QT=1.578s`&.
39320 .next
39321 &%queue_time_overall%&: The amount of time the message has been in the queue on
39322 the local host is logged as QT=<&'time'&> on &"Completed"& lines, for
39323 example, &`QT=3m45s`&.
39324 .next
39325 .cindex "log" "receive duration"
39326 &%receive_time%&: For each message, the amount of real time it has taken to
39327 perform the reception is logged as RT=<&'time'&>, for example, &`RT=1s`&.
39328 If millisecond logging is enabled, short times will be shown with greater
39329 precision, eg. &`RT=0.204s`&.
39330 .next
39331 .cindex "log" "recipients"
39332 &%received_recipients%&: The recipients of a message are listed in the main log
39333 as soon as the message is received. The list appears at the end of the log line
39334 that is written when a message is received, preceded by the word &"for"&. The
39335 addresses are listed after they have been qualified, but before any rewriting
39336 has taken place.
39337 Recipients that were discarded by an ACL for MAIL or RCPT do not appear
39338 in the list.
39339 .next
39340 .cindex "log" "sender reception"
39341 &%received_sender%&: The unrewritten original sender of a message is added to
39342 the end of the log line that records the message's arrival, after the word
39343 &"from"& (before the recipients if &%received_recipients%& is also set).
39344 .next
39345 .cindex "log" "header lines for rejection"
39346 &%rejected_header%&: If a message's header has been received at the time a
39347 rejection is written to the reject log, the complete header is added to the
39348 log. Header logging can be turned off individually for messages that are
39349 rejected by the &[local_scan()]& function (see section &<<SECTapiforloc>>&).
39350 .next
39351 .cindex "log" "retry defer"
39352 &%retry_defer%&: A log line is written if a delivery is deferred because a
39353 retry time has not yet been reached. However, this &"retry time not reached"&
39354 message is always omitted from individual message logs after the first delivery
39355 attempt.
39356 .next
39357 .cindex "log" "return path"
39358 &%return_path_on_delivery%&: The return path that is being transmitted with
39359 the message is included in delivery and bounce lines, using the tag P=.
39360 This is omitted if no delivery actually happens, for example, if routing fails,
39361 or if delivery is to &_/dev/null_& or to &`:blackhole:`&.
39362 .next
39363 .cindex "log" "sender on delivery"
39364 &%sender_on_delivery%&: The message's sender address is added to every delivery
39365 and bounce line, tagged by F= (for &"from"&).
39366 This is the original sender that was received with the message; it is not
39367 necessarily the same as the outgoing return path.
39368 .next
39369 .cindex "log" "sender verify failure"
39370 &%sender_verify_fail%&: If this selector is unset, the separate log line that
39371 gives details of a sender verification failure is not written. Log lines for
39372 the rejection of SMTP commands contain just &"sender verify failed"&, so some
39373 detail is lost.
39374 .next
39375 .cindex "log" "size rejection"
39376 &%size_reject%&: A log line is written whenever a message is rejected because
39377 it is too big.
39378 .next
39379 .cindex "log" "frozen messages; skipped"
39380 .cindex "frozen messages" "logging skipping"
39381 &%skip_delivery%&: A log line is written whenever a message is skipped during a
39382 queue run because it another process is already delivering it or because
39383 it is frozen.
39384 .cindex "&""spool file is locked""&"
39385 .cindex "&""message is frozen""&"
39386 The message that is written is either &"spool file is locked"& or
39387 &"message is frozen"&.
39388 .next
39389 .cindex "log" "smtp confirmation"
39390 .cindex "SMTP" "logging confirmation"
39391 .cindex "LMTP" "logging confirmation"
39392 &%smtp_confirmation%&: The response to the final &"."& in the SMTP or LMTP dialogue for
39393 outgoing messages is added to delivery log lines in the form &`C=`&<&'text'&>.
39394 A number of MTAs (including Exim) return an identifying string in this
39395 response.
39396 .next
39397 .cindex "log" "SMTP connections"
39398 .cindex "SMTP" "logging connections"
39399 &%smtp_connection%&: A log line is written whenever an incoming SMTP connection is
39400 established or closed, unless the connection is from a host that matches
39401 &%hosts_connection_nolog%&. (In contrast, &%lost_incoming_connection%& applies
39402 only when the closure is unexpected.) This applies to connections from local
39403 processes that use &%-bs%& as well as to TCP/IP connections. If a connection is
39404 dropped in the middle of a message, a log line is always written, whether or
39405 not this selector is set, but otherwise nothing is written at the start and end
39406 of connections unless this selector is enabled.
39407
39408 For TCP/IP connections to an Exim daemon, the current number of connections is
39409 included in the log message for each new connection, but note that the count is
39410 reset if the daemon is restarted.
39411 Also, because connections are closed (and the closure is logged) in
39412 subprocesses, the count may not include connections that have been closed but
39413 whose termination the daemon has not yet noticed. Thus, while it is possible to
39414 match up the opening and closing of connections in the log, the value of the
39415 logged counts may not be entirely accurate.
39416 .next
39417 .cindex "log" "SMTP transaction; incomplete"
39418 .cindex "SMTP" "logging incomplete transactions"
39419 &%smtp_incomplete_transaction%&: When a mail transaction is aborted by
39420 RSET, QUIT, loss of connection, or otherwise, the incident is logged,
39421 and the message sender plus any accepted recipients are included in the log
39422 line. This can provide evidence of dictionary attacks.
39423 .next
39424 .cindex "log" "non-MAIL SMTP sessions"
39425 .cindex "MAIL" "logging session without"
39426 &%smtp_no_mail%&: A line is written to the main log whenever an accepted SMTP
39427 connection terminates without having issued a MAIL command. This includes both
39428 the case when the connection is dropped, and the case when QUIT is used. It
39429 does not include cases where the connection is rejected right at the start (by
39430 an ACL, or because there are too many connections, or whatever). These cases
39431 already have their own log lines.
39432
39433 The log line that is written contains the identity of the client in the usual
39434 way, followed by D= and a time, which records the duration of the connection.
39435 If the connection was authenticated, this fact is logged exactly as it is for
39436 an incoming message, with an A= item. If the connection was encrypted, CV=,
39437 DN=, and X= items may appear as they do for an incoming message, controlled by
39438 the same logging options.
39439
39440 Finally, if any SMTP commands were issued during the connection, a C= item
39441 is added to the line, listing the commands that were used. For example,
39442 .code
39443 C=EHLO,QUIT
39444 .endd
39445 shows that the client issued QUIT straight after EHLO. If there were fewer
39446 than 20 commands, they are all listed. If there were more than 20 commands,
39447 the last 20 are listed, preceded by &"..."&. However, with the default
39448 setting of 10 for &%smtp_accept_max_nonmail%&, the connection will in any case
39449 have been aborted before 20 non-mail commands are processed.
39450 .next
39451 &%smtp_mailauth%&: A third subfield with the authenticated sender,
39452 colon-separated, is appended to the A= item for a message arrival or delivery
39453 log line, if an AUTH argument to the SMTP MAIL command (see &<<SECTauthparamail>>&)
39454 was accepted or used.
39455 .next
39456 .cindex "log" "SMTP protocol error"
39457 .cindex "SMTP" "logging protocol error"
39458 &%smtp_protocol_error%&: A log line is written for every SMTP protocol error
39459 encountered. Exim does not have perfect detection of all protocol errors
39460 because of transmission delays and the use of pipelining. If PIPELINING has
39461 been advertised to a client, an Exim server assumes that the client will use
39462 it, and therefore it does not count &"expected"& errors (for example, RCPT
39463 received after rejecting MAIL) as protocol errors.
39464 .next
39465 .cindex "SMTP" "logging syntax errors"
39466 .cindex "SMTP" "syntax errors; logging"
39467 .cindex "SMTP" "unknown command; logging"
39468 .cindex "log" "unknown SMTP command"
39469 .cindex "log" "SMTP syntax error"
39470 &%smtp_syntax_error%&: A log line is written for every SMTP syntax error
39471 encountered. An unrecognized command is treated as a syntax error. For an
39472 external connection, the host identity is given; for an internal connection
39473 using &%-bs%& the sender identification (normally the calling user) is given.
39474 .next
39475 .cindex "log" "subject"
39476 .cindex "subject, logging"
39477 &%subject%&: The subject of the message is added to the arrival log line,
39478 preceded by &"T="& (T for &"topic"&, since S is already used for &"size"&).
39479 Any MIME &"words"& in the subject are decoded. The &%print_topbitchars%& option
39480 specifies whether characters with values greater than 127 should be logged
39481 unchanged, or whether they should be rendered as escape sequences.
39482 .next
39483 .cindex "log" "certificate verification"
39484 .cindex log DANE
39485 .cindex DANE logging
39486 &%tls_certificate_verified%&: An extra item is added to <= and => log lines
39487 when TLS is in use. The item is &`CV=yes`& if the peer's certificate was
39488 verified
39489 using a CA trust anchor,
39490 &`CV=dane`& if using a DNS trust anchor,
39491 and &`CV=no`& if not.
39492 .next
39493 .cindex "log" "TLS cipher"
39494 .cindex "TLS" "logging cipher"
39495 &%tls_cipher%&: When a message is sent or received over an encrypted
39496 connection, the cipher suite used is added to the log line, preceded by X=.
39497 .next
39498 .cindex "log" "TLS peer DN"
39499 .cindex "TLS" "logging peer DN"
39500 &%tls_peerdn%&: When a message is sent or received over an encrypted
39501 connection, and a certificate is supplied by the remote host, the peer DN is
39502 added to the log line, preceded by DN=.
39503 .next
39504 .cindex "log" "TLS resumption"
39505 .cindex "TLS" "logging session resumption"
39506 &%tls_resumption%&: When a message is sent or received over an encrypted
39507 connection and the TLS session resumed one used on a previous TCP connection,
39508 an asterisk is appended to the X= cipher field in the log line.
39509 .next
39510 .cindex "log" "TLS SNI"
39511 .cindex "TLS" "logging SNI"
39512 .cindex SNI logging
39513 &%tls_sni%&: When a message is received over an encrypted connection, and
39514 the remote host provided the Server Name Indication extension, the SNI is
39515 added to the log line, preceded by SNI=.
39516 .next
39517 .cindex "log" "DNS failure in list"
39518 &%unknown_in_list%&: This setting causes a log entry to be written when the
39519 result of a list match is failure because a DNS lookup failed.
39520 .endlist
39521
39522
39523 .section "Message log" "SECID260"
39524 .cindex "message" "log file for"
39525 .cindex "log" "message log; description of"
39526 .cindex "&_msglog_& directory"
39527 .oindex "&%preserve_message_logs%&"
39528 In addition to the general log files, Exim writes a log file for each message
39529 that it handles. The names of these per-message logs are the message ids, and
39530 they are kept in the &_msglog_& sub-directory of the spool directory. Each
39531 message log contains copies of the log lines that apply to the message. This
39532 makes it easier to inspect the status of an individual message without having
39533 to search the main log. A message log is deleted when processing of the message
39534 is complete, unless &%preserve_message_logs%& is set, but this should be used
39535 only with great care because they can fill up your disk very quickly.
39536
39537 On a heavily loaded system, it may be desirable to disable the use of
39538 per-message logs, in order to reduce disk I/O. This can be done by setting the
39539 &%message_logs%& option false.
39540 .ecindex IIDloggen
39541
39542
39543
39544
39545 . ////////////////////////////////////////////////////////////////////////////
39546 . ////////////////////////////////////////////////////////////////////////////
39547
39548 .chapter "Exim utilities" "CHAPutils"
39549 .scindex IIDutils "utilities"
39550 A number of utility scripts and programs are supplied with Exim and are
39551 described in this chapter. There is also the Exim Monitor, which is covered in
39552 the next chapter. The utilities described here are:
39553
39554 .itable none 0 0 3  7* left  15* left  40* left
39555 .irow &<<SECTfinoutwha>>&     &'exiwhat'&       &&&
39556   "list what Exim processes are doing"
39557 .irow &<<SECTgreptheque>>&    &'exiqgrep'&      "grep the queue"
39558 .irow &<<SECTsumtheque>>&     &'exiqsumm'&      "summarize the queue"
39559 .irow &<<SECTextspeinf>>&     &'exigrep'&       "search the main log"
39560 .irow &<<SECTexipick>>&       &'exipick'&       "select messages on &&&
39561                                                 various criteria"
39562 .irow &<<SECTcyclogfil>>&     &'exicyclog'&     "cycle (rotate) log files"
39563 .irow &<<SECTmailstat>>&      &'eximstats'&     &&&
39564   "extract statistics from the log"
39565 .irow &<<SECTcheckaccess>>&   &'exim_checkaccess'& &&&
39566   "check address acceptance from given IP"
39567 .irow &<<SECTdbmbuild>>&      &'exim_dbmbuild'& "build a DBM file"
39568 .irow &<<SECTfinindret>>&     &'exinext'&       "extract retry information"
39569 .irow &<<SECTdumpdb>>&        &'exim_dumpdb'&   "dump a hints database"
39570 .irow &<<SECTtidydb>>&        &'exim_tidydb'&   "clean up a hints database"
39571 .irow &<<SECTfixdb>>&         &'exim_fixdb'&    "patch a hints database"
39572 .irow &<<SECTmailboxmaint>>&  &'exim_lock'&     "lock a mailbox file"
39573 .irow &<<SECTexim_msgdate>>&  &'exim_msgdate'&  "Message Ids for humans (exim_msgdate)"
39574 .endtable
39575
39576 Another utility that might be of use to sites with many MTAs is Tom Kistner's
39577 &'exilog'&. It provides log visualizations across multiple Exim servers. See
39578 &url(https://duncanthrax.net/exilog/) for details.
39579
39580
39581
39582
39583 .section "Finding out what Exim processes are doing (exiwhat)" "SECTfinoutwha"
39584 .cindex "&'exiwhat'&"
39585 .cindex "process, querying"
39586 .cindex "SIGUSR1"
39587 On operating systems that can restart a system call after receiving a signal
39588 (most modern OS), an Exim process responds to the SIGUSR1 signal by writing
39589 a line describing what it is doing to the file &_exim-process.info_& in the
39590 Exim spool directory. The &'exiwhat'& script sends the signal to all Exim
39591 processes it can find, having first emptied the file. It then waits for one
39592 second to allow the Exim processes to react before displaying the results. In
39593 order to run &'exiwhat'& successfully you have to have sufficient privilege to
39594 send the signal to the Exim processes, so it is normally run as root.
39595
39596 &*Warning*&: This is not an efficient process. It is intended for occasional
39597 use by system administrators. It is not sensible, for example, to set up a
39598 script that sends SIGUSR1 signals to Exim processes at short intervals.
39599
39600
39601 Unfortunately, the &'ps'& command that &'exiwhat'& uses to find Exim processes
39602 varies in different operating systems. Not only are different options used,
39603 but the format of the output is different. For this reason, there are some
39604 system configuration options that configure exactly how &'exiwhat'& works. If
39605 it doesn't seem to be working for you, check the following compile-time
39606 options:
39607 .itable none 0 0 2 30* left 70* left
39608 .irow &`EXIWHAT_PS_CMD`&        "the command for running &'ps'&"
39609 .irow &`EXIWHAT_PS_ARG`&        "the argument for &'ps'&"
39610 .irow &`EXIWHAT_EGREP_ARG`&     "the argument for &'egrep'& to select from &'ps'& output"
39611 .irow &`EXIWHAT_KILL_ARG`&      "the argument for the &'kill'& command"
39612 .endtable
39613 An example of typical output from &'exiwhat'& is
39614 .code
39615 164 daemon: -q1h, listening on port 25
39616 10483 running queue: waiting for 0tAycK-0002ij-00 (10492)
39617 10492 delivering 0tAycK-0002ij-00 to mail.ref.example
39618   [10.19.42.42] (editor@ref.example)
39619 10592 handling incoming call from [192.168.243.242]
39620 10628 accepting a local non-SMTP message
39621 .endd
39622 The first number in the output line is the process number. The third line has
39623 been split here, in order to fit it on the page.
39624
39625
39626
39627 .section "Selective queue listing (exiqgrep)" "SECTgreptheque"
39628 .cindex "&'exiqgrep'&"
39629 .cindex "queue" "grepping"
39630 This utility is a Perl script contributed by Matt Hubbard. It runs
39631 .code
39632 exim -bpu
39633 .endd
39634 or (in case &*-a*& switch is specified)
39635 .code
39636 exim -bp
39637 .endd
39638 to obtain a queue listing, and then greps the output to select messages
39639 that match given criteria. The following selection options are available:
39640
39641 .vlist
39642 .vitem &*-f*&&~<&'regex'&>
39643 Match the sender address using a case-insensitive search. The field that is
39644 tested is enclosed in angle brackets, so you can test for bounce messages with
39645 .code
39646 exiqgrep -f '^<>$'
39647 .endd
39648 .vitem &*-r*&&~<&'regex'&>
39649 Match a recipient address using a case-insensitive search. The field that is
39650 tested is not enclosed in angle brackets.
39651
39652 .vitem &*-s*&&~<&'regex'&>
39653 Match against the size field.
39654
39655 .vitem &*-y*&&~<&'seconds'&>
39656 Match messages that are younger than the given time.
39657
39658 .vitem &*-o*&&~<&'seconds'&>
39659 Match messages that are older than the given time.
39660
39661 .vitem &*-z*&
39662 Match only frozen messages.
39663
39664 .vitem &*-x*&
39665 Match only non-frozen messages.
39666
39667 .vitem &*-G*&&~<&'queuename'&>
39668 Match only messages in the given queue.  Without this, the default queue is searched.
39669 .endlist
39670
39671 The following options control the format of the output:
39672
39673 .vlist
39674 .vitem &*-c*&
39675 Display only the count of matching messages.
39676
39677 .vitem &*-l*&
39678 Long format &-- display the full message information as output by Exim. This is
39679 the default.
39680
39681 .vitem &*-i*&
39682 Display message ids only.
39683
39684 .vitem &*-b*&
39685 Brief format &-- one line per message.
39686
39687 .vitem &*-R*&
39688 Display messages in reverse order.
39689
39690 .vitem &*-a*&
39691 Include delivered recipients in queue listing.
39692 .endlist
39693
39694 The following options give alternates for configuration:
39695
39696 .vlist
39697 .vitem &*-C*&&~<&'config&~file'&>
39698 is used to specify an alternate &_exim.conf_& which might
39699 contain alternate exim configuration the queue management might be using.
39700
39701 .vitem &*-E*&&~<&'path'&>
39702 can be used to specify a path for the exim binary,
39703 overriding the built-in one.
39704 .endlist
39705
39706 There is one more option, &%-h%&, which outputs a list of options.
39707 At least one selection option, or either the &*-c*& or &*-h*& option, must be given.
39708
39709
39710
39711 .section "Summarizing the queue (exiqsumm)" "SECTsumtheque"
39712 .cindex "&'exiqsumm'&"
39713 .cindex "queue" "summary"
39714 The &'exiqsumm'& utility is a Perl script which reads the output of &`exim
39715 -bp`& and produces a summary of the messages in the queue. Thus, you use it by
39716 running a command such as
39717 .code
39718 exim -bp | exiqsumm
39719 .endd
39720 The output consists of one line for each domain that has messages waiting for
39721 it, as in the following example:
39722 .code
39723 3   2322   74m   66m  msn.com.example
39724 .endd
39725 Each line lists the number of pending deliveries for a domain, their total
39726 volume, and the length of time that the oldest and the newest messages have
39727 been waiting. Note that the number of pending deliveries is greater than the
39728 number of messages when messages have more than one recipient.
39729
39730 A summary line is output at the end. By default the output is sorted on the
39731 domain name, but &'exiqsumm'& has the options &%-a%& and &%-c%&, which cause
39732 the output to be sorted by oldest message and by count of messages,
39733 respectively. There are also three options that split the messages for each
39734 domain into two or more subcounts: &%-b%& separates bounce messages, &%-f%&
39735 separates frozen messages, and &%-s%& separates messages according to their
39736 sender.
39737
39738 The output of &'exim -bp'& contains the original addresses in the message, so
39739 this also applies to the output from &'exiqsumm'&. No domains from addresses
39740 generated by aliasing or forwarding are included (unless the &%one_time%&
39741 option of the &(redirect)& router has been used to convert them into &"top
39742 level"& addresses).
39743
39744
39745
39746
39747 .section "Extracting specific information from the log (exigrep)" &&&
39748          "SECTextspeinf"
39749 .cindex "&'exigrep'&"
39750 .cindex "log" "extracts; grepping for"
39751 The &'exigrep'& utility is a Perl script that searches one or more main log
39752 files for entries that match a given pattern. When it finds a match, it
39753 extracts all the log entries for the relevant message, not just those that
39754 match the pattern. Thus, &'exigrep'& can extract complete log entries for a
39755 given message, or all mail for a given user, or for a given host, for example.
39756 The input files can be in Exim log format or syslog format.
39757 If a matching log line is not associated with a specific message, it is
39758 included in &'exigrep'&'s output without any additional lines. The usage is:
39759 .display
39760 &`exigrep [-t<`&&'n'&&`>] [-I] [-l] [-M] [-v] <`&&'pattern'&&`> [<`&&'log file'&&`>] ...`&
39761 .endd
39762 If no log filenames are given on the command line, the standard input is read.
39763
39764 The &%-t%& argument specifies a number of seconds. It adds an additional
39765 condition for message selection. Messages that are complete are shown only if
39766 they spent more than <&'n'&> seconds in the queue.
39767
39768 By default, &'exigrep'& does case-insensitive matching. The &%-I%& option
39769 makes it case-sensitive. This may give a performance improvement when searching
39770 large log files. Without &%-I%&, the Perl pattern matches use Perl's &`/i`&
39771 option; with &%-I%& they do not. In both cases it is possible to change the
39772 case sensitivity within the pattern by using &`(?i)`& or &`(?-i)`&.
39773
39774 The &%-l%& option means &"literal"&, that is, treat all characters in the
39775 pattern as standing for themselves. Otherwise the pattern must be a Perl
39776 regular expression.
39777
39778 The &%-v%& option inverts the matching condition. That is, a line is selected
39779 if it does &'not'& match the pattern.
39780
39781 The &%-M%& options means &"related messages"&. &'exigrep'& will show messages
39782 that are generated as a result/response to a message that &'exigrep'& matched
39783 normally.
39784
39785 Example of &%-M%&:
39786 user_a sends a message to user_b, which generates a bounce back to user_b. If
39787 &'exigrep'& is used to search for &"user_a"&, only the first message will be
39788 displayed.  But if &'exigrep'& is used to search for &"user_b"&, the first and
39789 the second (bounce) message will be displayed. Using &%-M%& with &'exigrep'&
39790 when searching for &"user_a"& will show both messages since the bounce is
39791 &"related"& to or a &"result"& of the first message that was found by the
39792 search term.
39793
39794 If the location of a &'zcat'& command is known from the definition of
39795 ZCAT_COMMAND in &_Local/Makefile_&, &'exigrep'& automatically passes any file
39796 whose name ends in COMPRESS_SUFFIX through &'zcat'& as it searches it.
39797 If the ZCAT_COMMAND is not executable, &'exigrep'& tries to use
39798 autodetection of some well known compression extensions.
39799
39800
39801 .section "Selecting messages by various criteria (exipick)" "SECTexipick"
39802 .cindex "&'exipick'&"
39803 John Jetmore's &'exipick'& utility is included in the Exim distribution. It
39804 lists messages from the queue according to a variety of criteria. For details
39805 of &'exipick'&'s facilities, run &'exipick'& with
39806 the &%--help%& option.
39807
39808
39809 .section "Cycling log files (exicyclog)" "SECTcyclogfil"
39810 .cindex "log" "cycling local files"
39811 .cindex "cycling logs"
39812 .cindex "&'exicyclog'&"
39813 The &'exicyclog'& script can be used to cycle (rotate) &'mainlog'& and
39814 &'rejectlog'& files. This is not necessary if only syslog is being used, or if
39815 you are using log files with datestamps in their names (see section
39816 &<<SECTdatlogfil>>&). Some operating systems have their own standard mechanisms
39817 for log cycling, and these can be used instead of &'exicyclog'& if preferred.
39818 There are two command line options for &'exicyclog'&:
39819 .ilist
39820 &%-k%& <&'count'&> specifies the number of log files to keep, overriding the
39821 default that is set when Exim is built. The default default is 10.
39822 .next
39823 &%-l%& <&'path'&> specifies the log file path, in the same format as Exim's
39824 &%log_file_path%& option (for example, &`/var/log/exim_%slog`&), again
39825 overriding the script's default, which is to find the setting from Exim's
39826 configuration.
39827 .endlist
39828
39829 Each time &'exicyclog'& is run the filenames get &"shuffled down"& by one. If
39830 the main log filename is &_mainlog_& (the default) then when &'exicyclog'& is
39831 run &_mainlog_& becomes &_mainlog.01_&, the previous &_mainlog.01_& becomes
39832 &_mainlog.02_& and so on, up to the limit that is set in the script or by the
39833 &%-k%& option. Log files whose numbers exceed the limit are discarded. Reject
39834 logs are handled similarly.
39835
39836 If the limit is greater than 99, the script uses 3-digit numbers such as
39837 &_mainlog.001_&, &_mainlog.002_&, etc. If you change from a number less than 99
39838 to one that is greater, or &'vice versa'&, you will have to fix the names of
39839 any existing log files.
39840
39841 If no &_mainlog_& file exists, the script does nothing. Files that &"drop off"&
39842 the end are deleted. All files with numbers greater than 01 are compressed,
39843 using a compression command which is configured by the COMPRESS_COMMAND
39844 setting in &_Local/Makefile_&. It is usual to run &'exicyclog'& daily from a
39845 root &%crontab%& entry of the form
39846 .code
39847 1 0 * * * su exim -c /usr/exim/bin/exicyclog
39848 .endd
39849 assuming you have used the name &"exim"& for the Exim user. You can run
39850 &'exicyclog'& as root if you wish, but there is no need.
39851
39852
39853
39854 .section "Mail statistics (eximstats)" "SECTmailstat"
39855 .cindex "statistics"
39856 .cindex "&'eximstats'&"
39857 A Perl script called &'eximstats'& is provided for extracting statistical
39858 information from log files. The output is either plain text, or HTML.
39859 . --- 2018-09-07: LogReport's Lire appears to be dead; website is a Yahoo Japan
39860 . --- 404 error and everything else points to that.
39861
39862 The &'eximstats'& script has been hacked about quite a bit over time. The
39863 latest version is the result of some extensive revision by Steve Campbell. A
39864 lot of information is given by default, but there are options for suppressing
39865 various parts of it. Following any options, the arguments to the script are a
39866 list of files, which should be main log files. For example:
39867 .code
39868 eximstats -nr /var/spool/exim/log/mainlog.01
39869 .endd
39870 By default, &'eximstats'& extracts information about the number and volume of
39871 messages received from or delivered to various hosts. The information is sorted
39872 both by message count and by volume, and the top fifty hosts in each category
39873 are listed on the standard output. Similar information, based on email
39874 addresses or domains instead of hosts can be requested by means of various
39875 options. For messages delivered and received locally, similar statistics are
39876 also produced per user.
39877
39878 The output also includes total counts and statistics about delivery errors, and
39879 histograms showing the number of messages received and deliveries made in each
39880 hour of the day. A delivery with more than one address in its envelope (for
39881 example, an SMTP transaction with more than one RCPT command) is counted
39882 as a single delivery by &'eximstats'&.
39883
39884 Though normally more deliveries than receipts are reported (as messages may
39885 have multiple recipients), it is possible for &'eximstats'& to report more
39886 messages received than delivered, even though the queue is empty at the start
39887 and end of the period in question. If an incoming message contains no valid
39888 recipients, no deliveries are recorded for it. A bounce message is handled as
39889 an entirely separate message.
39890
39891 &'eximstats'& always outputs a grand total summary giving the volume and number
39892 of messages received and deliveries made, and the number of hosts involved in
39893 each case. It also outputs the number of messages that were delayed (that is,
39894 not completely delivered at the first attempt), and the number that had at
39895 least one address that failed.
39896
39897 The remainder of the output is in sections that can be independently disabled
39898 or modified by various options. It consists of a summary of deliveries by
39899 transport, histograms of messages received and delivered per time interval
39900 (default per hour), information about the time messages spent in the queue,
39901 a list of relayed messages, lists of the top fifty sending hosts, local
39902 senders, destination hosts, and destination local users by count and by volume,
39903 and a list of delivery errors that occurred.
39904
39905 The relay information lists messages that were actually relayed, that is, they
39906 came from a remote host and were directly delivered to some other remote host,
39907 without being processed (for example, for aliasing or forwarding) locally.
39908
39909 There are quite a few options for &'eximstats'& to control exactly what it
39910 outputs. These are documented in the Perl script itself, and can be extracted
39911 by running the command &(perldoc)& on the script. For example:
39912 .code
39913 perldoc /usr/exim/bin/eximstats
39914 .endd
39915
39916 .section "Checking access policy (exim_checkaccess)" "SECTcheckaccess"
39917 .cindex "&'exim_checkaccess'&"
39918 .cindex "policy control" "checking access"
39919 .cindex "checking access"
39920 The &%-bh%& command line argument allows you to run a fake SMTP session with
39921 debugging output, in order to check what Exim is doing when it is applying
39922 policy controls to incoming SMTP mail. However, not everybody is sufficiently
39923 familiar with the SMTP protocol to be able to make full use of &%-bh%&, and
39924 sometimes you just want to answer the question &"Does this address have
39925 access?"& without bothering with any further details.
39926
39927 The &'exim_checkaccess'& utility is a &"packaged"& version of &%-bh%&. It takes
39928 two arguments, an IP address and an email address:
39929 .code
39930 exim_checkaccess 10.9.8.7 A.User@a.domain.example
39931 .endd
39932 The utility runs a call to Exim with the &%-bh%& option, to test whether the
39933 given email address would be accepted in a RCPT command in a TCP/IP
39934 connection from the host with the given IP address. The output of the utility
39935 is either the word &"accepted"&, or the SMTP error response, for example:
39936 .code
39937 Rejected:
39938 550 Relay not permitted
39939 .endd
39940 When running this test, the utility uses &`<>`& as the envelope sender address
39941 for the MAIL command, but you can change this by providing additional
39942 options. These are passed directly to the Exim command. For example, to specify
39943 that the test is to be run with the sender address &'himself@there.example'&
39944 you can use:
39945 .code
39946 exim_checkaccess 10.9.8.7 A.User@a.domain.example \
39947                  -f himself@there.example
39948 .endd
39949 Note that these additional Exim command line items must be given after the two
39950 mandatory arguments.
39951
39952 Because the &%exim_checkaccess%& uses &%-bh%&, it does not perform callouts
39953 while running its checks. You can run checks that include callouts by using
39954 &%-bhc%&, but this is not yet available in a &"packaged"& form.
39955
39956
39957
39958 .section "Making DBM files (exim_dbmbuild)" "SECTdbmbuild"
39959 .cindex "DBM" "building dbm files"
39960 .cindex "building DBM files"
39961 .cindex "&'exim_dbmbuild'&"
39962 .cindex "lower casing"
39963 .cindex "binary zero" "in lookup key"
39964 The &'exim_dbmbuild'& program reads an input file containing keys and data in
39965 the format used by the &(lsearch)& lookup (see section
39966 &<<SECTsinglekeylookups>>&). It writes a DBM file using the lower-cased alias
39967 names as keys and the remainder of the information as data. The lower-casing
39968 can be prevented by calling the program with the &%-nolc%& option.
39969
39970 A terminating zero is included as part of the key string. This is expected by
39971 the &(dbm)& lookup type. However, if the option &%-nozero%& is given,
39972 &'exim_dbmbuild'& creates files without terminating zeroes in either the key
39973 strings or the data strings. The &(dbmnz)& lookup type can be used with such
39974 files.
39975
39976 The program requires two arguments: the name of the input file (which can be a
39977 single hyphen to indicate the standard input), and the name of the output file.
39978 It creates the output under a temporary name, and then renames it if all went
39979 well.
39980
39981 .cindex "USE_DB"
39982 If the native DB interface is in use (USE_DB is set in a compile-time
39983 configuration file &-- this is common in free versions of Unix) the two
39984 filenames must be different, because in this mode the Berkeley DB functions
39985 create a single output file using exactly the name given. For example,
39986 .code
39987 exim_dbmbuild /etc/aliases /etc/aliases.db
39988 .endd
39989 reads the system alias file and creates a DBM version of it in
39990 &_/etc/aliases.db_&.
39991
39992 In systems that use the &'ndbm'& routines (mostly proprietary versions of
39993 Unix), two files are used, with the suffixes &_.dir_& and &_.pag_&. In this
39994 environment, the suffixes are added to the second argument of
39995 &'exim_dbmbuild'&, so it can be the same as the first. This is also the case
39996 when the Berkeley functions are used in compatibility mode (though this is not
39997 recommended), because in that case it adds a &_.db_& suffix to the filename.
39998
39999 If a duplicate key is encountered, the program outputs a warning, and when it
40000 finishes, its return code is 1 rather than zero, unless the &%-noduperr%&
40001 option is used. By default, only the first of a set of duplicates is used &--
40002 this makes it compatible with &(lsearch)& lookups. There is an option
40003 &%-lastdup%& which causes it to use the data for the last duplicate instead.
40004 There is also an option &%-nowarn%&, which stops it listing duplicate keys to
40005 &%stderr%&. For other errors, where it doesn't actually make a new file, the
40006 return code is 2.
40007
40008
40009
40010
40011 .section "Finding individual retry times (exinext)" "SECTfinindret"
40012 .cindex "retry" "times"
40013 .cindex "&'exinext'&"
40014 A utility called &'exinext'& (mostly a Perl script) provides the ability to
40015 fish specific information out of the retry database. Given a mail domain (or a
40016 complete address), it looks up the hosts for that domain, and outputs any retry
40017 information for the hosts or for the domain. At present, the retry information
40018 is obtained by running &'exim_dumpdb'& (see below) and post-processing the
40019 output. For example:
40020 .code
40021 $ exinext piglet@milne.fict.example
40022 kanga.milne.example:192.168.8.1 error 146: Connection refused
40023   first failed: 21-Feb-1996 14:57:34
40024   last tried:   21-Feb-1996 14:57:34
40025   next try at:  21-Feb-1996 15:02:34
40026 roo.milne.example:192.168.8.3 error 146: Connection refused
40027   first failed: 20-Jan-1996 13:12:08
40028   last tried:   21-Feb-1996 11:42:03
40029   next try at:  21-Feb-1996 19:42:03
40030   past final cutoff time
40031 .endd
40032 You can also give &'exinext'& a local part, without a domain, and it
40033 will give any retry information for that local part in your default domain.
40034 A message id can be used to obtain retry information pertaining to a specific
40035 message. This exists only when an attempt to deliver a message to a remote host
40036 suffers a message-specific error (see section &<<SECToutSMTPerr>>&).
40037 &'exinext'& is not particularly efficient, but then it is not expected to be
40038 run very often.
40039
40040 The &'exinext'& utility calls Exim to find out information such as the location
40041 of the spool directory. The utility has &%-C%& and &%-D%& options, which are
40042 passed on to the &'exim'& commands. The first specifies an alternate Exim
40043 configuration file, and the second sets macros for use within the configuration
40044 file. These features are mainly to help in testing, but might also be useful in
40045 environments where more than one configuration file is in use.
40046
40047
40048
40049 .section "Hints database maintenance" "SECThindatmai"
40050 .cindex "hints database" "maintenance"
40051 .cindex "maintaining Exim's hints database"
40052 Three utility programs are provided for maintaining the DBM files that Exim
40053 uses to contain its delivery hint information. Each program requires two
40054 arguments. The first specifies the name of Exim's spool directory, and the
40055 second is the name of the database it is to operate on. These are as follows:
40056
40057 .ilist
40058 &'retry'&: the database of retry information
40059 .next
40060 &'wait-'&<&'transport name'&>: databases of information about messages waiting
40061 for remote hosts
40062 .next
40063 &'callout'&: the callout cache
40064 .next
40065 &'ratelimit'&: the data for implementing the ratelimit ACL condition
40066 .next
40067 &'tls'&: TLS session resumption data
40068 .next
40069 &'misc'&: other hints data
40070 .endlist
40071
40072 The &'misc'& database is used for
40073
40074 .ilist
40075 Serializing ETRN runs (when &%smtp_etrn_serialize%& is set)
40076 .next
40077 Serializing delivery to a specific host (when &%serialize_hosts%& is set in an
40078 &(smtp)& transport)
40079 .next
40080 Limiting the concurrency of specific transports (when &%max_parallel%& is set
40081 in a transport)
40082 .next
40083 Recording EHLO-time facilities advertised by hosts
40084 .endlist
40085
40086
40087
40088 .section "exim_dumpdb" "SECTdumpdb"
40089 .cindex "&'exim_dumpdb'&"
40090 The entire contents of a database are written to the standard output by the
40091 &'exim_dumpdb'& program,
40092 taking as arguments the spool and database names.
40093 An option &'-z'& may be given to request times in UTC;
40094 otherwise times are in the local timezone.
40095 An option &'-k'& may be given to dump only the record keys.
40096 For example, to dump the retry database:
40097 .code
40098 exim_dumpdb /var/spool/exim retry
40099 .endd
40100 For the retry database
40101 two lines of output are produced for each entry:
40102 .code
40103 T:mail.ref.example:192.168.242.242 146 77 Connection refused
40104 31-Oct-1995 12:00:12 02-Nov-1995 12:21:39 02-Nov-1995 20:21:39 *
40105 .endd
40106 The first item on the first line is the key of the record. It starts with one
40107 of the letters R, or T, depending on whether it refers to a routing or
40108 transport retry. For a local delivery, the next part is the local address; for
40109 a remote delivery it is the name of the remote host, followed by its failing IP
40110 address (unless &%retry_include_ip_address%& is set false on the &(smtp)&
40111 transport). If the remote port is not the standard one (port 25), it is added
40112 to the IP address. Then there follows an error code, an additional error code,
40113 and a textual description of the error.
40114
40115 The three times on the second line are the time of first failure, the time of
40116 the last delivery attempt, and the computed time for the next attempt. The line
40117 ends with an asterisk if the cutoff time for the last retry rule has been
40118 exceeded.
40119
40120 Each output line from &'exim_dumpdb'& for the &'wait-xxx'& databases
40121 consists of a host name followed by a list of ids for messages that are or were
40122 waiting to be delivered to that host. If there are a very large number for any
40123 one host, continuation records, with a sequence number added to the host name,
40124 may be seen. The data in these records is often out of date, because a message
40125 may be routed to several alternative hosts, and Exim makes no effort to keep
40126 cross-references.
40127
40128
40129
40130 .section "exim_tidydb" "SECTtidydb"
40131 .cindex "&'exim_tidydb'&"
40132 The &'exim_tidydb'& utility program is used to tidy up the contents of a hints
40133 database. If run with no options, it removes all records that are more than 30
40134 days old. The age is calculated from the date and time that the record was last
40135 updated. Note that, in the case of the retry database, it is &'not'& the time
40136 since the first delivery failure. Information about a host that has been down
40137 for more than 30 days will remain in the database, provided that the record is
40138 updated sufficiently often.
40139
40140 The cutoff date can be altered by means of the &%-t%& option, which must be
40141 followed by a time. For example, to remove all records older than a week from
40142 the retry database:
40143 .code
40144 exim_tidydb -t 7d /var/spool/exim retry
40145 .endd
40146 Both the &'wait-xxx'& and &'retry'& databases contain items that involve
40147 message ids. In the former these appear as data in records keyed by host &--
40148 they were messages that were waiting for that host &-- and in the latter they
40149 are the keys for retry information for messages that have suffered certain
40150 types of error. When &'exim_tidydb'& is run, a check is made to ensure that
40151 message ids in database records are those of messages that are still on the
40152 queue. Message ids for messages that no longer exist are removed from
40153 &'wait-xxx'& records, and if this leaves any records empty, they are deleted.
40154 For the &'retry'& database, records whose keys are non-existent message ids are
40155 removed. The &'exim_tidydb'& utility outputs comments on the standard output
40156 whenever it removes information from the database.
40157
40158 Certain records are automatically removed by Exim when they are no longer
40159 needed, but others are not. For example, if all the MX hosts for a domain are
40160 down, a retry record is created for each one. If the primary MX host comes back
40161 first, its record is removed when Exim successfully delivers to it, but the
40162 records for the others remain because Exim has not tried to use those hosts.
40163
40164 It is important, therefore, to run &'exim_tidydb'& periodically on all the
40165 hints databases. You should do this at a quiet time of day, because it requires
40166 a database to be locked (and therefore inaccessible to Exim) while it does its
40167 work. Removing records from a DBM file does not normally make the file smaller,
40168 but all the common DBM libraries are able to re-use the space that is released.
40169 After an initial phase of increasing in size, the databases normally reach a
40170 point at which they no longer get any bigger, as long as they are regularly
40171 tidied.
40172
40173 &*Warning*&: If you never run &'exim_tidydb'&, the space used by the hints
40174 databases is likely to keep on increasing.
40175
40176
40177
40178
40179 .section "exim_fixdb" "SECTfixdb"
40180 .cindex "&'exim_fixdb'&"
40181 The &'exim_fixdb'& program is a utility for interactively modifying databases.
40182 Its main use is for testing Exim, but it might also be occasionally useful for
40183 getting round problems in a live system. Its interface
40184 is somewhat crude. On entry, it prompts for input with a right angle-bracket. A
40185 key of a database record can then be entered, and the data for that record is
40186 displayed.
40187
40188 If &"d"& is typed at the next prompt, the entire record is deleted. For all
40189 except the &'retry'& database, that is the only operation that can be carried
40190 out. For the &'retry'& database, each field is output preceded by a number, and
40191 data for individual fields can be changed by typing the field number followed
40192 by new data, for example:
40193 .code
40194 > 4 951102:1000
40195 .endd
40196 resets the time of the next delivery attempt. Time values are given as a
40197 sequence of digit pairs for year, month, day, hour, and minute. Colons can be
40198 used as optional separators.
40199
40200 Both displayed and input times are in the local timezone by default.
40201 If an option &'-z'& is used on the command line, displayed times
40202 are in UTC.
40203
40204
40205
40206
40207 .section "Mailbox maintenance (exim_lock)" "SECTmailboxmaint"
40208 .cindex "mailbox" "maintenance"
40209 .cindex "&'exim_lock'&"
40210 .cindex "locking mailboxes"
40211 The &'exim_lock'& utility locks a mailbox file using the same algorithm as
40212 Exim. For a discussion of locking issues, see section &<<SECTopappend>>&.
40213 &'Exim_lock'& can be used to prevent any modification of a mailbox by Exim or
40214 a user agent while investigating a problem. The utility requires the name of
40215 the file as its first argument. If the locking is successful, the second
40216 argument is run as a command (using C's &[system()]& function); if there is no
40217 second argument, the value of the SHELL environment variable is used; if this
40218 is unset or empty, &_/bin/sh_& is run. When the command finishes, the mailbox
40219 is unlocked and the utility ends. The following options are available:
40220
40221 .vlist
40222 .vitem &%-fcntl%&
40223 Use &[fcntl()]& locking on the open mailbox.
40224
40225 .vitem &%-flock%&
40226 Use &[flock()]& locking on the open mailbox, provided the operating system
40227 supports it.
40228
40229 .vitem &%-interval%&
40230 This must be followed by a number, which is a number of seconds; it sets the
40231 interval to sleep between retries (default 3).
40232
40233 .vitem &%-lockfile%&
40234 Create a lock file before opening the mailbox.
40235
40236 .vitem &%-mbx%&
40237 Lock the mailbox using MBX rules.
40238
40239 .vitem &%-q%&
40240 Suppress verification output.
40241
40242 .vitem &%-retries%&
40243 This must be followed by a number; it sets the number of times to try to get
40244 the lock (default 10).
40245
40246 .vitem &%-restore_time%&
40247 This option causes &%exim_lock%& to restore the modified and read times to the
40248 locked file before exiting. This allows you to access a locked mailbox (for
40249 example, to take a backup copy) without disturbing the times that the user
40250 subsequently sees.
40251
40252 .vitem &%-timeout%&
40253 This must be followed by a number, which is a number of seconds; it sets a
40254 timeout to be used with a blocking &[fcntl()]& lock. If it is not set (the
40255 default), a non-blocking call is used.
40256
40257 .vitem &%-v%&
40258 Generate verbose output.
40259 .endlist
40260
40261 If none of &%-fcntl%&, &%-flock%&, &%-lockfile%& or &%-mbx%& are given, the
40262 default is to create a lock file and also to use &[fcntl()]& locking on the
40263 mailbox, which is the same as Exim's default. The use of &%-flock%& or
40264 &%-fcntl%& requires that the file be writeable; the use of &%-lockfile%&
40265 requires that the directory containing the file be writeable. Locking by lock
40266 file does not last forever; Exim assumes that a lock file is expired if it is
40267 more than 30 minutes old.
40268
40269 The &%-mbx%& option can be used with either or both of &%-fcntl%& or
40270 &%-flock%&. It assumes &%-fcntl%& by default. MBX locking causes a shared lock
40271 to be taken out on the open mailbox, and an exclusive lock on the file
40272 &_/tmp/.n.m_& where &'n'& and &'m'& are the device number and inode
40273 number of the mailbox file. When the locking is released, if an exclusive lock
40274 can be obtained for the mailbox, the file in &_/tmp_& is deleted.
40275
40276 The default output contains verification of the locking that takes place. The
40277 &%-v%& option causes some additional information to be given. The &%-q%& option
40278 suppresses all output except error messages.
40279
40280 A command such as
40281 .code
40282 exim_lock /var/spool/mail/spqr
40283 .endd
40284 runs an interactive shell while the file is locked, whereas
40285 .display
40286 &`exim_lock -q /var/spool/mail/spqr <<End`&
40287 <&'some commands'&>
40288 &`End`&
40289 .endd
40290 runs a specific non-interactive sequence of commands while the file is locked,
40291 suppressing all verification output. A single command can be run by a command
40292 such as
40293 .code
40294 exim_lock -q /var/spool/mail/spqr \
40295   "cp /var/spool/mail/spqr /some/where"
40296 .endd
40297 Note that if a command is supplied, it must be entirely contained within the
40298 second argument &-- hence the quotes.
40299
40300
40301 .section "Message Ids for humans (exim_msgdate)" "SECTexim_msgdate"
40302 .cindex "exim_msgdate"
40303 The &'exim_msgdate'& utility is written by Andrew Aitchison and included in the Exim distribution.
40304 This Perl script converts an Exim Mesage ID back into a human readable form.
40305 For details of &'exim_msgdate'&'s options, run &'exim_msgdate'& with the &%--help%& option.
40306
40307 Section &<<SECTmessiden>>& (Message identification) describes Exim Mesage IDs.
40308 .ecindex IIDutils
40309 . ////////////////////////////////////////////////////////////////////////////
40310 . ////////////////////////////////////////////////////////////////////////////
40311
40312 .chapter "The Exim monitor" "CHAPeximon"
40313 .scindex IIDeximon "Exim monitor" "description"
40314 .cindex "X-windows"
40315 .cindex "&'eximon'&"
40316 .cindex "Local/eximon.conf"
40317 .cindex "&_exim_monitor/EDITME_&"
40318 The Exim monitor is an application which displays in an X window information
40319 about the state of Exim's queue and what Exim is doing. An admin user can
40320 perform certain operations on messages from this GUI interface; however all
40321 such facilities are also available from the command line, and indeed, the
40322 monitor itself makes use of the command line to perform any actions requested.
40323
40324
40325
40326 .section "Running the monitor" "SECID264"
40327 The monitor is started by running the script called &'eximon'&. This is a shell
40328 script that sets up a number of environment variables, and then runs the
40329 binary called &_eximon.bin_&. The default appearance of the monitor window can
40330 be changed by editing the &_Local/eximon.conf_& file created by editing
40331 &_exim_monitor/EDITME_&. Comments in that file describe what the various
40332 parameters are for.
40333
40334 The parameters that get built into the &'eximon'& script can be overridden for
40335 a particular invocation by setting up environment variables of the same names,
40336 preceded by &`EXIMON_`&. For example, a shell command such as
40337 .code
40338 EXIMON_LOG_DEPTH=400 eximon
40339 .endd
40340 (in a Bourne-compatible shell) runs &'eximon'& with an overriding setting of
40341 the LOG_DEPTH parameter. If EXIMON_LOG_FILE_PATH is set in the environment, it
40342 overrides the Exim log file configuration. This makes it possible to have
40343 &'eximon'& tailing log data that is written to syslog, provided that MAIL.INFO
40344 syslog messages are routed to a file on the local host.
40345
40346 X resources can be used to change the appearance of the window in the normal
40347 way. For example, a resource setting of the form
40348 .code
40349 Eximon*background: gray94
40350 .endd
40351 changes the colour of the background to light grey rather than white. The
40352 stripcharts are drawn with both the data lines and the reference lines in
40353 black. This means that the reference lines are not visible when on top of the
40354 data. However, their colour can be changed by setting a resource called
40355 &"highlight"& (an odd name, but that's what the Athena stripchart widget uses).
40356 For example, if your X server is running Unix, you could set up lighter
40357 reference lines in the stripcharts by obeying
40358 .code
40359 xrdb -merge <<End
40360 Eximon*highlight: gray
40361 End
40362 .endd
40363 .cindex "admin user"
40364 In order to see the contents of messages in the queue, and to operate on them,
40365 &'eximon'& must either be run as root or by an admin user.
40366
40367 The command-line parameters of &'eximon'& are passed to &_eximon.bin_& and may
40368 contain X11 resource parameters interpreted by the X11 library.  In addition,
40369 if the first parameter starts with the string "gdb" then it is removed and the
40370 binary is invoked under gdb (the parameter is used as the gdb command-name, so
40371 versioned variants of gdb can be invoked).
40372
40373 The monitor's window is divided into three parts. The first contains one or
40374 more stripcharts and two action buttons, the second contains a &"tail"& of the
40375 main log file, and the third is a display of the queue of messages awaiting
40376 delivery, with two more action buttons. The following sections describe these
40377 different parts of the display.
40378
40379
40380
40381
40382 .section "The stripcharts" "SECID265"
40383 .cindex "stripchart"
40384 The first stripchart is always a count of messages in the queue. Its name can
40385 be configured by setting QUEUE_STRIPCHART_NAME in the
40386 &_Local/eximon.conf_& file. The remaining stripcharts are defined in the
40387 configuration script by regular expression matches on log file entries, making
40388 it possible to display, for example, counts of messages delivered to certain
40389 hosts or using certain transports. The supplied defaults display counts of
40390 received and delivered messages, and of local and SMTP deliveries. The default
40391 period between stripchart updates is one minute; this can be adjusted by a
40392 parameter in the &_Local/eximon.conf_& file.
40393
40394 The stripchart displays rescale themselves automatically as the value they are
40395 displaying changes. There are always 10 horizontal lines in each chart; the
40396 title string indicates the value of each division when it is greater than one.
40397 For example, &"x2"& means that each division represents a value of 2.
40398
40399 It is also possible to have a stripchart which shows the percentage fullness of
40400 a particular disk partition, which is useful when local deliveries are confined
40401 to a single partition.
40402
40403 .cindex "&%statvfs%& function"
40404 This relies on the availability of the &[statvfs()]& function or equivalent in
40405 the operating system. Most, but not all versions of Unix that support Exim have
40406 this. For this particular stripchart, the top of the chart always represents
40407 100%, and the scale is given as &"x10%"&. This chart is configured by setting
40408 SIZE_STRIPCHART and (optionally) SIZE_STRIPCHART_NAME in the
40409 &_Local/eximon.conf_& file.
40410
40411
40412
40413
40414 .section "Main action buttons" "SECID266"
40415 .cindex "size" "of monitor window"
40416 .cindex "Exim monitor" "window size"
40417 .cindex "window size"
40418 Below the stripcharts there is an action button for quitting the monitor. Next
40419 to this is another button marked &"Size"&. They are placed here so that
40420 shrinking the window to its default minimum size leaves just the queue count
40421 stripchart and these two buttons visible. Pressing the &"Size"& button causes
40422 the window to expand to its maximum size, unless it is already at the maximum,
40423 in which case it is reduced to its minimum.
40424
40425 When expanding to the maximum, if the window cannot be fully seen where it
40426 currently is, it is moved back to where it was the last time it was at full
40427 size. When it is expanding from its minimum size, the old position is
40428 remembered, and next time it is reduced to the minimum it is moved back there.
40429
40430 The idea is that you can keep a reduced window just showing one or two
40431 stripcharts at a convenient place on your screen, easily expand it to show
40432 the full window when required, and just as easily put it back to what it was.
40433 The idea is copied from what the &'twm'& window manager does for its
40434 &'f.fullzoom'& action. The minimum size of the window can be changed by setting
40435 the MIN_HEIGHT and MIN_WIDTH values in &_Local/eximon.conf_&.
40436
40437 Normally, the monitor starts up with the window at its full size, but it can be
40438 built so that it starts up with the window at its smallest size, by setting
40439 START_SMALL=yes in &_Local/eximon.conf_&.
40440
40441
40442
40443 .section "The log display" "SECID267"
40444 .cindex "log" "tail of; in monitor"
40445 The second section of the window is an area in which a display of the tail of
40446 the main log is maintained.
40447 To save space on the screen, the timestamp on each log line is shortened by
40448 removing the date and, if &%log_timezone%& is set, the timezone.
40449 The log tail is not available when the only destination for logging data is
40450 syslog, unless the syslog lines are routed to a local file whose name is passed
40451 to &'eximon'& via the EXIMON_LOG_FILE_PATH environment variable.
40452
40453 The log sub-window has a scroll bar at its lefthand side which can be used to
40454 move back to look at earlier text, and the up and down arrow keys also have a
40455 scrolling effect. The amount of log that is kept depends on the setting of
40456 LOG_BUFFER in &_Local/eximon.conf_&, which specifies the amount of memory
40457 to use. When this is full, the earlier 50% of data is discarded &-- this is
40458 much more efficient than throwing it away line by line. The sub-window also has
40459 a horizontal scroll bar for accessing the ends of long log lines. This is the
40460 only means of horizontal scrolling; the right and left arrow keys are not
40461 available. Text can be cut from this part of the window using the mouse in the
40462 normal way. The size of this subwindow is controlled by parameters in the
40463 configuration file &_Local/eximon.conf_&.
40464
40465 Searches of the text in the log window can be carried out by means of the ^R
40466 and ^S keystrokes, which default to a reverse and a forward search,
40467 respectively. The search covers only the text that is displayed in the window.
40468 It cannot go further back up the log.
40469
40470 The point from which the search starts is indicated by a caret marker. This is
40471 normally at the end of the text in the window, but can be positioned explicitly
40472 by pointing and clicking with the left mouse button, and is moved automatically
40473 by a successful search. If new text arrives in the window when it is scrolled
40474 back, the caret remains where it is, but if the window is not scrolled back,
40475 the caret is moved to the end of the new text.
40476
40477 Pressing ^R or ^S pops up a window into which the search text can be typed.
40478 There are buttons for selecting forward or reverse searching, for carrying out
40479 the search, and for cancelling. If the &"Search"& button is pressed, the search
40480 happens and the window remains so that further searches can be done. If the
40481 &"Return"& key is pressed, a single search is done and the window is closed. If
40482 ^C is typed the search is cancelled.
40483
40484 The searching facility is implemented using the facilities of the Athena text
40485 widget. By default this pops up a window containing both &"search"& and
40486 &"replace"& options. In order to suppress the unwanted &"replace"& portion for
40487 eximon, a modified version of the &%TextPop%& widget is distributed with Exim.
40488 However, the linkers in BSDI and HP-UX seem unable to handle an externally
40489 provided version of &%TextPop%& when the remaining parts of the text widget
40490 come from the standard libraries. The compile-time option EXIMON_TEXTPOP can be
40491 unset to cut out the modified &%TextPop%&, making it possible to build Eximon
40492 on these systems, at the expense of having unwanted items in the search popup
40493 window.
40494
40495
40496
40497 .section "The queue display" "SECID268"
40498 .cindex "queue" "display in monitor"
40499 The bottom section of the monitor window contains a list of all messages that
40500 are in the queue, which includes those currently being received or delivered,
40501 as well as those awaiting delivery. The size of this subwindow is controlled by
40502 parameters in the configuration file &_Local/eximon.conf_&, and the frequency
40503 at which it is updated is controlled by another parameter in the same file &--
40504 the default is 5 minutes, since queue scans can be quite expensive. However,
40505 there is an &"Update"& action button just above the display which can be used
40506 to force an update of the queue display at any time.
40507
40508 When a host is down for some time, a lot of pending mail can build up for it,
40509 and this can make it hard to deal with other messages in the queue. To help
40510 with this situation there is a button next to &"Update"& called &"Hide"&. If
40511 pressed, a dialogue box called &"Hide addresses ending with"& is put up. If you
40512 type anything in here and press &"Return"&, the text is added to a chain of
40513 such texts, and if every undelivered address in a message matches at least one
40514 of the texts, the message is not displayed.
40515
40516 If there is an address that does not match any of the texts, all the addresses
40517 are displayed as normal. The matching happens on the ends of addresses so, for
40518 example, &'cam.ac.uk'& specifies all addresses in Cambridge, while
40519 &'xxx@foo.com.example'& specifies just one specific address. When any hiding
40520 has been set up, a button called &"Unhide"& is displayed. If pressed, it
40521 cancels all hiding. Also, to ensure that hidden messages do not get forgotten,
40522 a hide request is automatically cancelled after one hour.
40523
40524 While the dialogue box is displayed, you can't press any buttons or do anything
40525 else to the monitor window. For this reason, if you want to cut text from the
40526 queue display to use in the dialogue box, you have to do the cutting before
40527 pressing the &"Hide"& button.
40528
40529 The queue display contains, for each unhidden queued message, the length of
40530 time it has been in the queue, the size of the message, the message id, the
40531 message sender, and the first undelivered recipient, all on one line. If it is
40532 a bounce message, the sender is shown as &"<>"&. If there is more than one
40533 recipient to which the message has not yet been delivered, subsequent ones are
40534 listed on additional lines, up to a maximum configured number, following which
40535 an ellipsis is displayed. Recipients that have already received the message are
40536 not shown.
40537
40538 .cindex "frozen messages" "display"
40539 If a message is frozen, an asterisk is displayed at the left-hand side.
40540
40541 The queue display has a vertical scroll bar, and can also be scrolled by means
40542 of the arrow keys. Text can be cut from it using the mouse in the normal way.
40543 The text searching facilities, as described above for the log window, are also
40544 available, but the caret is always moved to the end of the text when the queue
40545 display is updated.
40546
40547
40548
40549 .section "The queue menu" "SECID269"
40550 .cindex "queue" "menu in monitor"
40551 If the &%shift%& key is held down and the left button is clicked when the mouse
40552 pointer is over the text for any message, an action menu pops up, and the first
40553 line of the queue display for the message is highlighted. This does not affect
40554 any selected text.
40555
40556 If you want to use some other event for popping up the menu, you can set the
40557 MENU_EVENT parameter in &_Local/eximon.conf_& to change the default, or
40558 set EXIMON_MENU_EVENT in the environment before starting the monitor. The
40559 value set in this parameter is a standard X event description. For example, to
40560 run eximon using &%ctrl%& rather than &%shift%& you could use
40561 .code
40562 EXIMON_MENU_EVENT='Ctrl<Btn1Down>' eximon
40563 .endd
40564 The title of the menu is the message id, and it contains entries which act as
40565 follows:
40566
40567 .ilist
40568 &'message log'&: The contents of the message log for the message are displayed
40569 in a new text window.
40570 .next
40571 &'headers'&: Information from the spool file that contains the envelope
40572 information and headers is displayed in a new text window. See chapter
40573 &<<CHAPspool>>& for a description of the format of spool files.
40574 .next
40575 &'body'&: The contents of the spool file containing the body of the message are
40576 displayed in a new text window. There is a default limit of 20,000 bytes to the
40577 amount of data displayed. This can be changed by setting the BODY_MAX
40578 option at compile time, or the EXIMON_BODY_MAX option at runtime.
40579 .next
40580 &'deliver message'&: A call to Exim is made using the &%-M%& option to request
40581 delivery of the message. This causes an automatic thaw if the message is
40582 frozen. The &%-v%& option is also set, and the output from Exim is displayed in
40583 a new text window. The delivery is run in a separate process, to avoid holding
40584 up the monitor while the delivery proceeds.
40585 .next
40586 &'freeze message'&: A call to Exim is made using the &%-Mf%& option to request
40587 that the message be frozen.
40588 .next
40589 .cindex "thawing messages"
40590 .cindex "unfreezing messages"
40591 .cindex "frozen messages" "thawing"
40592 &'thaw message'&: A call to Exim is made using the &%-Mt%& option to request
40593 that the message be thawed.
40594 .next
40595 .cindex "delivery" "forcing failure"
40596 &'give up on msg'&: A call to Exim is made using the &%-Mg%& option to request
40597 that Exim gives up trying to deliver the message. A bounce message is generated
40598 for any remaining undelivered addresses.
40599 .next
40600 &'remove message'&: A call to Exim is made using the &%-Mrm%& option to request
40601 that the message be deleted from the system without generating a bounce
40602 message.
40603 .next
40604 &'add recipient'&: A dialog box is displayed into which a recipient address can
40605 be typed. If the address is not qualified and the QUALIFY_DOMAIN parameter
40606 is set in &_Local/eximon.conf_&, the address is qualified with that domain.
40607 Otherwise it must be entered as a fully qualified address. Pressing RETURN
40608 causes a call to Exim to be made using the &%-Mar%& option to request that an
40609 additional recipient be added to the message, unless the entry box is empty, in
40610 which case no action is taken.
40611 .next
40612 &'mark delivered'&: A dialog box is displayed into which a recipient address
40613 can be typed. If the address is not qualified and the QUALIFY_DOMAIN parameter
40614 is set in &_Local/eximon.conf_&, the address is qualified with that domain.
40615 Otherwise it must be entered as a fully qualified address. Pressing RETURN
40616 causes a call to Exim to be made using the &%-Mmd%& option to mark the given
40617 recipient address as already delivered, unless the entry box is empty, in which
40618 case no action is taken.
40619 .next
40620 &'mark all delivered'&: A call to Exim is made using the &%-Mmad%& option to
40621 mark all recipient addresses as already delivered.
40622 .next
40623 &'edit sender'&: A dialog box is displayed initialized with the current
40624 sender's address. Pressing RETURN causes a call to Exim to be made using the
40625 &%-Mes%& option to replace the sender address, unless the entry box is empty,
40626 in which case no action is taken. If you want to set an empty sender (as in
40627 bounce messages), you must specify it as &"<>"&. Otherwise, if the address is
40628 not qualified and the QUALIFY_DOMAIN parameter is set in &_Local/eximon.conf_&,
40629 the address is qualified with that domain.
40630 .endlist
40631
40632 When a delivery is forced, a window showing the &%-v%& output is displayed. In
40633 other cases when a call to Exim is made, if there is any output from Exim (in
40634 particular, if the command fails) a window containing the command and the
40635 output is displayed. Otherwise, the results of the action are normally apparent
40636 from the log and queue displays. However, if you set ACTION_OUTPUT=yes in
40637 &_Local/eximon.conf_&, a window showing the Exim command is always opened, even
40638 if no output is generated.
40639
40640 The queue display is automatically updated for actions such as freezing and
40641 thawing, unless ACTION_QUEUE_UPDATE=no has been set in
40642 &_Local/eximon.conf_&. In this case the &"Update"& button has to be used to
40643 force an update of the display after one of these actions.
40644
40645 In any text window that is displayed as result of a menu action, the normal
40646 cut-and-paste facility is available, and searching can be carried out using ^R
40647 and ^S, as described above for the log tail window.
40648 .ecindex IIDeximon
40649
40650
40651
40652
40653
40654 . ////////////////////////////////////////////////////////////////////////////
40655 . ////////////////////////////////////////////////////////////////////////////
40656
40657 .chapter "Security considerations" "CHAPsecurity"
40658 .scindex IIDsecurcon "security" "discussion of"
40659 This chapter discusses a number of issues concerned with security, some of
40660 which are also covered in other parts of this manual.
40661
40662 For reasons that this author does not understand, some people have promoted
40663 Exim as a &"particularly secure"& mailer. Perhaps it is because of the
40664 existence of this chapter in the documentation. However, the intent of the
40665 chapter is simply to describe the way Exim works in relation to certain
40666 security concerns, not to make any specific claims about the effectiveness of
40667 its security as compared with other MTAs.
40668
40669 What follows is a description of the way Exim is supposed to be. Best efforts
40670 have been made to try to ensure that the code agrees with the theory, but an
40671 absence of bugs can never be guaranteed. Any that are reported will get fixed
40672 as soon as possible.
40673
40674
40675 .section "Building a more &""hardened""& Exim" "SECID286"
40676 .cindex "security" "build-time features"
40677 There are a number of build-time options that can be set in &_Local/Makefile_&
40678 to create Exim binaries that are &"harder"& to attack, in particular by a rogue
40679 Exim administrator who does not have the root password, or by someone who has
40680 penetrated the Exim (but not the root) account. These options are as follows:
40681
40682 .ilist
40683 ALT_CONFIG_PREFIX can be set to a string that is required to match the
40684 start of any filenames used with the &%-C%& option. When it is set, these
40685 filenames are also not allowed to contain the sequence &"/../"&. (However, if
40686 the value of the &%-C%& option is identical to the value of CONFIGURE_FILE in
40687 &_Local/Makefile_&, Exim ignores &%-C%& and proceeds as usual.) There is no
40688 default setting for &%ALT_CONFIG_PREFIX%&.
40689
40690 If the permitted configuration files are confined to a directory to
40691 which only root has access, this guards against someone who has broken
40692 into the Exim account from running a privileged Exim with an arbitrary
40693 configuration file, and using it to break into other accounts.
40694 .next
40695
40696 If a non-trusted configuration file (i.e. not the default configuration file
40697 or one which is trusted by virtue of being listed in the TRUSTED_CONFIG_LIST
40698 file) is specified with &%-C%&, or if macros are given with &%-D%& (but see
40699 the next item), then root privilege is retained only if the caller of Exim is
40700 root. This locks out the possibility of testing a configuration using &%-C%&
40701 right through message reception and delivery, even if the caller is root. The
40702 reception works, but by that time, Exim is running as the Exim user, so when
40703 it re-execs to regain privilege for the delivery, the use of &%-C%& causes
40704 privilege to be lost. However, root can test reception and delivery using two
40705 separate commands.
40706
40707 .next
40708 The WHITELIST_D_MACROS build option declares some macros to be safe to override
40709 with &%-D%& if the real uid is one of root, the Exim run-time user or the
40710 CONFIGURE_OWNER, if defined.  The potential impact of this option is limited by
40711 requiring the run-time value supplied to &%-D%& to match a regex that errs on
40712 the restrictive side.  Requiring build-time selection of safe macros is onerous
40713 but this option is intended solely as a transition mechanism to permit
40714 previously-working configurations to continue to work after release 4.73.
40715 .next
40716 If DISABLE_D_OPTION is defined, the use of the &%-D%& command line option
40717 is disabled.
40718 .next
40719 FIXED_NEVER_USERS can be set to a colon-separated list of users that are
40720 never to be used for any deliveries. This is like the &%never_users%& runtime
40721 option, but it cannot be overridden; the runtime option adds additional users
40722 to the list. The default setting is &"root"&; this prevents a non-root user who
40723 is permitted to modify the runtime file from using Exim as a way to get root.
40724 .endlist
40725
40726
40727
40728 .section "Root privilege" "SECID270"
40729 .cindex "setuid"
40730 .cindex "root privilege"
40731 The Exim binary is normally setuid to root, which means that it gains root
40732 privilege (runs as root) when it starts execution. In some special cases (for
40733 example, when the daemon is not in use and there are no local deliveries), it
40734 may be possible to run Exim setuid to some user other than root. This is
40735 discussed in the next section. However, in most installations, root privilege
40736 is required for two things:
40737
40738 .ilist
40739 To set up a socket connected to the standard SMTP port (25) when initialising
40740 the listening daemon. If Exim is run from &'inetd'&, this privileged action is
40741 not required.
40742 .next
40743 To be able to change uid and gid in order to read users' &_.forward_& files and
40744 perform local deliveries as the receiving user or as specified in the
40745 configuration.
40746 .endlist
40747
40748 It is not necessary to be root to do any of the other things Exim does, such as
40749 receiving messages and delivering them externally over SMTP, and it is
40750 obviously more secure if Exim does not run as root except when necessary.
40751 For this reason, a user and group for Exim to use must be defined in
40752 &_Local/Makefile_&. These are known as &"the Exim user"& and &"the Exim
40753 group"&. Their values can be changed by the runtime configuration, though this
40754 is not recommended. Often a user called &'exim'& is used, but some sites use
40755 &'mail'& or another user name altogether.
40756
40757 Exim uses &[setuid()]& whenever it gives up root privilege. This is a permanent
40758 abdication; the process cannot regain root afterwards. Prior to release 4.00,
40759 &[seteuid()]& was used in some circumstances, but this is no longer the case.
40760
40761 After a new Exim process has interpreted its command line options, it changes
40762 uid and gid in the following cases:
40763
40764 .ilist
40765 .oindex "&%-C%&"
40766 .oindex "&%-D%&"
40767 If the &%-C%& option is used to specify an alternate configuration file, or if
40768 the &%-D%& option is used to define macro values for the configuration, and the
40769 calling process is not running as root, the uid and gid are changed to those of
40770 the calling process.
40771 However, if DISABLE_D_OPTION is defined in &_Local/Makefile_&, the &%-D%&
40772 option may not be used at all.
40773 If WHITELIST_D_MACROS is defined in &_Local/Makefile_&, then some macro values
40774 can be supplied if the calling process is running as root, the Exim run-time
40775 user or CONFIGURE_OWNER, if defined.
40776 .next
40777 .oindex "&%-be%&"
40778 .oindex "&%-bf%&"
40779 .oindex "&%-bF%&"
40780 If the expansion test option (&%-be%&) or one of the filter testing options
40781 (&%-bf%& or &%-bF%&) are used, the uid and gid are changed to those of the
40782 calling process.
40783 .next
40784 If the process is not a daemon process or a queue runner process or a delivery
40785 process or a process for testing address routing (started with &%-bt%&), the
40786 uid and gid are changed to the Exim user and group. This means that Exim always
40787 runs under its own uid and gid when receiving messages. This also applies when
40788 testing address verification
40789 .oindex "&%-bv%&"
40790 .oindex "&%-bh%&"
40791 (the &%-bv%& option) and testing incoming message policy controls (the &%-bh%&
40792 option).
40793 .next
40794 For a daemon, queue runner, delivery, or address testing process, the uid
40795 remains as root at this stage, but the gid is changed to the Exim group.
40796 .endlist
40797
40798 The processes that initially retain root privilege behave as follows:
40799
40800 .ilist
40801 A daemon process changes the gid to the Exim group and the uid to the Exim
40802 user after setting up one or more listening sockets. The &[initgroups()]&
40803 function is called, so that if the Exim user is in any additional groups, they
40804 will be used during message reception.
40805 .next
40806 A queue runner process retains root privilege throughout its execution. Its
40807 job is to fork a controlled sequence of delivery processes.
40808 .next
40809 A delivery process retains root privilege throughout most of its execution,
40810 but any actual deliveries (that is, the transports themselves) are run in
40811 subprocesses which always change to a non-root uid and gid. For local
40812 deliveries this is typically the uid and gid of the owner of the mailbox; for
40813 remote deliveries, the Exim uid and gid are used. Once all the delivery
40814 subprocesses have been run, a delivery process changes to the Exim uid and gid
40815 while doing post-delivery tidying up such as updating the retry database and
40816 generating bounce and warning messages.
40817
40818 While the recipient addresses in a message are being routed, the delivery
40819 process runs as root. However, if a user's filter file has to be processed,
40820 this is done in a subprocess that runs under the individual user's uid and
40821 gid. A system filter is run as root unless &%system_filter_user%& is set.
40822 .next
40823 A process that is testing addresses (the &%-bt%& option) runs as root so that
40824 the routing is done in the same environment as a message delivery.
40825 .endlist
40826
40827
40828
40829
40830 .section "Running Exim without privilege" "SECTrunexiwitpri"
40831 .cindex "privilege, running without"
40832 .cindex "unprivileged running"
40833 .cindex "root privilege" "running without"
40834 Some installations like to run Exim in an unprivileged state for more of its
40835 operation, for added security. Support for this mode of operation is provided
40836 by the global option &%deliver_drop_privilege%&. When this is set, the uid and
40837 gid are changed to the Exim user and group at the start of a delivery process
40838 (and also queue runner and address testing processes). This means that address
40839 routing is no longer run as root, and the deliveries themselves cannot change
40840 to any other uid.
40841
40842 .cindex SIGHUP
40843 .cindex "daemon" "restarting"
40844 Leaving the binary setuid to root, but setting &%deliver_drop_privilege%& means
40845 that the daemon can still be started in the usual way, and it can respond
40846 correctly to SIGHUP because the re-invocation regains root privilege.
40847
40848 An alternative approach is to make Exim setuid to the Exim user and also setgid
40849 to the Exim group. If you do this, the daemon must be started from a root
40850 process. (Calling Exim from a root process makes it behave in the way it does
40851 when it is setuid root.) However, the daemon cannot restart itself after a
40852 SIGHUP signal because it cannot regain privilege.
40853
40854 It is still useful to set &%deliver_drop_privilege%& in this case, because it
40855 stops Exim from trying to re-invoke itself to do a delivery after a message has
40856 been received. Such a re-invocation is a waste of resources because it has no
40857 effect.
40858
40859 If restarting the daemon is not an issue (for example, if &%mua_wrapper%& is
40860 set, or &'inetd'& is being used instead of a daemon), having the binary setuid
40861 to the Exim user seems a clean approach, but there is one complication:
40862
40863 In this style of operation, Exim is running with the real uid and gid set to
40864 those of the calling process, and the effective uid/gid set to Exim's values.
40865 Ideally, any association with the calling process' uid/gid should be dropped,
40866 that is, the real uid/gid should be reset to the effective values so as to
40867 discard any privileges that the caller may have. While some operating systems
40868 have a function that permits this action for a non-root effective uid, quite a
40869 number of them do not. Because of this lack of standardization, Exim does not
40870 address this problem at this time.
40871
40872 For this reason, the recommended approach for &"mostly unprivileged"& running
40873 is to keep the Exim binary setuid to root, and to set
40874 &%deliver_drop_privilege%&. This also has the advantage of allowing a daemon to
40875 be used in the most straightforward way.
40876
40877 If you configure Exim not to run delivery processes as root, there are a
40878 number of restrictions on what you can do:
40879
40880 .ilist
40881 You can deliver only as the Exim user/group. You should  explicitly use the
40882 &%user%& and &%group%& options to override routers or local transports that
40883 normally deliver as the recipient. This makes sure that configurations that
40884 work in this mode function the same way in normal mode. Any implicit or
40885 explicit specification of another user causes an error.
40886 .next
40887 Use of &_.forward_& files is severely restricted, such that it is usually
40888 not worthwhile to include them in the configuration.
40889 .next
40890 Users who wish to use &_.forward_& would have to make their home directory and
40891 the file itself accessible to the Exim user. Pipe and append-to-file entries,
40892 and their equivalents in Exim filters, cannot be used. While they could be
40893 enabled in the Exim user's name, that would be insecure and not very useful.
40894 .next
40895 Unless the local user mailboxes are all owned by the Exim user (possible in
40896 some POP3 or IMAP-only environments):
40897
40898 .olist
40899 They must be owned by the Exim group and be writeable by that group. This
40900 implies you must set &%mode%& in the appendfile configuration, as well as the
40901 mode of the mailbox files themselves.
40902 .next
40903 You must set &%no_check_owner%&, since most or all of the files will not be
40904 owned by the Exim user.
40905 .next
40906 You must set &%file_must_exist%&, because Exim cannot set the owner correctly
40907 on a newly created mailbox when unprivileged. This also implies that new
40908 mailboxes need to be created manually.
40909 .endlist olist
40910 .endlist ilist
40911
40912
40913 These restrictions severely restrict what can be done in local deliveries.
40914 However, there are no restrictions on remote deliveries. If you are running a
40915 gateway host that does no local deliveries, setting &%deliver_drop_privilege%&
40916 gives more security at essentially no cost.
40917
40918 If you are using the &%mua_wrapper%& facility (see chapter
40919 &<<CHAPnonqueueing>>&), &%deliver_drop_privilege%& is forced to be true.
40920
40921
40922
40923
40924 .section "Delivering to local files" "SECID271"
40925 Full details of the checks applied by &(appendfile)& before it writes to a file
40926 are given in chapter &<<CHAPappendfile>>&.
40927
40928
40929
40930 .section "Running local commands" "SECTsecconslocalcmds"
40931 .cindex "security" "local commands"
40932 .cindex "security" "command injection attacks"
40933 There are a number of ways in which an administrator can configure Exim to run
40934 commands based upon received, untrustworthy, data. Further, in some
40935 configurations a user who can control a &_.forward_& file can also arrange to
40936 run commands. Configuration to check includes, but is not limited to:
40937
40938 .ilist
40939 Use of &%use_shell%& in the pipe transport: various forms of shell command
40940 injection may be possible with this option present. It is dangerous and should
40941 be used only with considerable caution. Consider constraints which whitelist
40942 allowed characters in a variable which is to be used in a pipe transport that
40943 has &%use_shell%& enabled.
40944 .next
40945 A number of options such as &%forbid_filter_run%&, &%forbid_filter_perl%&,
40946 &%forbid_filter_dlfunc%& and so forth which restrict facilities available to
40947 &_.forward_& files in a redirect router. If Exim is running on a central mail
40948 hub to which ordinary users do not have shell access, but home directories are
40949 NFS mounted (for instance) then administrators should review the list of these
40950 forbid options available, and should bear in mind that the options that may
40951 need forbidding can change as new features are added between releases.
40952 .next
40953 The &%${run...}%& expansion item does not use a shell by default, but
40954 administrators can configure use of &_/bin/sh_& as part of the command.
40955 Such invocations should be viewed with prejudicial suspicion.
40956 .next
40957 Administrators who use embedded Perl are advised to explore how Perl's
40958 taint checking might apply to their usage.
40959 .next
40960 Use of &%${expand...}%& is somewhat analogous to shell's eval builtin and
40961 administrators are well advised to view its use with suspicion, in case (for
40962 instance) it allows a local-part to contain embedded Exim directives.
40963 .next
40964 Use of &%${match_local_part...}%& and friends becomes more dangerous if
40965 Exim was built with EXPAND_LISTMATCH_RHS defined: the second string in
40966 each can reference arbitrary lists and files, rather than just being a list
40967 of opaque strings.
40968 The EXPAND_LISTMATCH_RHS option was added and set false by default because of
40969 real-world security vulnerabilities caused by its use with untrustworthy data
40970 injected in, for SQL injection attacks.
40971 Consider the use of the &%inlisti%& expansion condition instead.
40972 .endlist
40973
40974
40975
40976
40977 .section "Trust in configuration data" "SECTsecconfdata"
40978 .cindex "security" "data sources"
40979 .cindex "security" "regular expressions"
40980 .cindex "regular expressions" "security"
40981 .cindex "PCRE2" "security"
40982 If configuration data for Exim can come from untrustworthy sources, there
40983 are some issues to be aware of:
40984
40985 .ilist
40986 Use of &%${expand...}%& may provide a path for shell injection attacks.
40987 .next
40988 Letting untrusted data provide a regular expression is unwise.
40989 .next
40990 Using &%${match...}%& to apply a fixed regular expression against untrusted
40991 data may result in pathological behaviour within PCRE2.  Be aware of what
40992 "backtracking" means and consider options for being more strict with a regular
40993 expression. Avenues to explore include limiting what can match (avoiding &`.`&
40994 when &`[a-z0-9]`& or other character class will do), use of atomic grouping and
40995 possessive quantifiers or just not using regular expressions against untrusted
40996 data.
40997 .next
40998 It can be important to correctly use &%${quote:...}%&,
40999 &%${quote_local_part:...}%& and &%${quote_%&<&'lookup-type'&>&%:...}%& expansion
41000 items to ensure that data is correctly constructed.
41001 .next
41002 Some lookups might return multiple results, even though normal usage is only
41003 expected to yield one result.
41004 .endlist
41005
41006
41007
41008
41009 .section "IPv4 source routing" "SECID272"
41010 .cindex "source routing" "in IP packets"
41011 .cindex "IP source routing"
41012 Many operating systems suppress IP source-routed packets in the kernel, but
41013 some cannot be made to do this, so Exim does its own check. It logs incoming
41014 IPv4 source-routed TCP calls, and then drops them. Things are all different in
41015 IPv6. No special checking is currently done.
41016
41017
41018
41019 .section "The VRFY, EXPN, and ETRN commands in SMTP" "SECID273"
41020 Support for these SMTP commands is disabled by default. If required, they can
41021 be enabled by defining suitable ACLs.
41022
41023
41024
41025
41026 .section "Privileged users" "SECID274"
41027 .cindex "trusted users"
41028 .cindex "admin user"
41029 .cindex "privileged user"
41030 .cindex "user" "trusted"
41031 .cindex "user" "admin"
41032 Exim recognizes two sets of users with special privileges. Trusted users are
41033 able to submit new messages to Exim locally, but supply their own sender
41034 addresses and information about a sending host. For other users submitting
41035 local messages, Exim sets up the sender address from the uid, and doesn't
41036 permit a remote host to be specified.
41037
41038 .oindex "&%-f%&"
41039 However, an untrusted user is permitted to use the &%-f%& command line option
41040 in the special form &%-f <>%& to indicate that a delivery failure for the
41041 message should not cause an error report. This affects the message's envelope,
41042 but it does not affect the &'Sender:'& header. Untrusted users may also be
41043 permitted to use specific forms of address with the &%-f%& option by setting
41044 the &%untrusted_set_sender%& option.
41045
41046 Trusted users are used to run processes that receive mail messages from some
41047 other mail domain and pass them on to Exim for delivery either locally, or over
41048 the Internet. Exim trusts a caller that is running as root, as the Exim user,
41049 as any user listed in the &%trusted_users%& configuration option, or under any
41050 group listed in the &%trusted_groups%& option.
41051
41052 Admin users are permitted to do things to the messages on Exim's queue. They
41053 can freeze or thaw messages, cause them to be returned to their senders, remove
41054 them entirely, or modify them in various ways. In addition, admin users can run
41055 the Exim monitor and see all the information it is capable of providing, which
41056 includes the contents of files on the spool.
41057
41058 .oindex "&%-M%&"
41059 .oindex "&%-q%&"
41060 By default, the use of the &%-M%& and &%-q%& options to cause Exim to attempt
41061 delivery of messages on its queue is restricted to admin users. This
41062 restriction can be relaxed by setting the &%no_prod_requires_admin%& option.
41063 Similarly, the use of &%-bp%& (and its variants) to list the contents of the
41064 queue is also restricted to admin users. This restriction can be relaxed by
41065 setting &%no_queue_list_requires_admin%&.
41066
41067 Exim recognizes an admin user if the calling process is running as root or as
41068 the Exim user or if any of the groups associated with the calling process is
41069 the Exim group. It is not necessary actually to be running under the Exim
41070 group. However, if admin users who are not root or the Exim user are to access
41071 the contents of files on the spool via the Exim monitor (which runs
41072 unprivileged), Exim must be built to allow group read access to its spool
41073 files.
41074
41075 By default, regular users are trusted to perform basic testing and
41076 introspection commands, as themselves.  This setting can be tightened by
41077 setting the &%commandline_checks_require_admin%& option.
41078 This affects most of the checking options,
41079 such as &%-be%& and anything else &%-b*%&.
41080
41081
41082 .section "Spool files" "SECID275"
41083 .cindex "spool directory" "files"
41084 Exim's spool directory and everything it contains is owned by the Exim user and
41085 set to the Exim group. The mode for spool files is defined in the
41086 &_Local/Makefile_& configuration file, and defaults to 0640. This means that
41087 any user who is a member of the Exim group can access these files.
41088
41089
41090
41091 .section "Use of argv[0]" "SECID276"
41092 Exim examines the last component of &%argv[0]%&, and if it matches one of a set
41093 of specific strings, Exim assumes certain options. For example, calling Exim
41094 with the last component of &%argv[0]%& set to &"rsmtp"& is exactly equivalent
41095 to calling it with the option &%-bS%&. There are no security implications in
41096 this.
41097
41098
41099
41100 .section "Use of %f formatting" "SECID277"
41101 The only use made of &"%f"& by Exim is in formatting load average values. These
41102 are actually stored in integer variables as 1000 times the load average.
41103 Consequently, their range is limited and so therefore is the length of the
41104 converted output.
41105
41106
41107
41108 .section "Embedded Exim path" "SECID278"
41109 Exim uses its own path name, which is embedded in the code, only when it needs
41110 to re-exec in order to regain root privilege. Therefore, it is not root when it
41111 does so. If some bug allowed the path to get overwritten, it would lead to an
41112 arbitrary program's being run as exim, not as root.
41113
41114
41115
41116 .section "Dynamic module directory" "SECTdynmoddir"
41117 Any dynamically loadable modules must be installed into the directory
41118 defined in &`LOOKUP_MODULE_DIR`& in &_Local/Makefile_& for Exim to permit
41119 loading it.
41120
41121
41122 .section "Use of sprintf()" "SECID279"
41123 .cindex "&[sprintf()]&"
41124 A large number of occurrences of &"sprintf"& in the code are actually calls to
41125 &'string_sprintf()'&, a function that returns the result in malloc'd store.
41126 The intermediate formatting is done into a large fixed buffer by a function
41127 that runs through the format string itself, and checks the length of each
41128 conversion before performing it, thus preventing buffer overruns.
41129
41130 The remaining uses of &[sprintf()]& happen in controlled circumstances where
41131 the output buffer is known to be sufficiently long to contain the converted
41132 string.
41133
41134
41135
41136 .section "Use of debug_printf() and log_write()" "SECID280"
41137 Arbitrary strings are passed to both these functions, but they do their
41138 formatting by calling the function &'string_vformat()'&, which runs through
41139 the format string itself, and checks the length of each conversion.
41140
41141
41142
41143 .section "Use of strcat() and strcpy()" "SECID281"
41144 These are used only in cases where the output buffer is known to be large
41145 enough to hold the result.
41146 .ecindex IIDsecurcon
41147
41148
41149
41150
41151 . ////////////////////////////////////////////////////////////////////////////
41152 . ////////////////////////////////////////////////////////////////////////////
41153
41154 .chapter "Format of spool files" "CHAPspool"
41155 .scindex IIDforspo1 "format" "spool files"
41156 .scindex IIDforspo2 "spool directory" "format of files"
41157 .scindex IIDforspo3 "spool files" "format of"
41158 .cindex "spool files" "editing"
41159 A message on Exim's queue consists of two files, whose names are the message id
41160 followed by -D and -H, respectively. The data portion of the message is kept in
41161 the -D file on its own. The message's envelope, status, and headers are all
41162 kept in the -H file, whose format is described in this chapter. Each of these
41163 two files contains the final component of its own name as its first line. This
41164 is insurance against disk crashes where the directory is lost but the files
41165 themselves are recoverable.
41166
41167 The file formats may be changed, or new formats added, at any release.
41168 Spool files are not intended as an interface to other programs
41169 and should not be used as such.
41170
41171 Some people are tempted into editing -D files in order to modify messages. You
41172 need to be extremely careful if you do this; it is not recommended and you are
41173 on your own if you do it. Here are some of the pitfalls:
41174
41175 .ilist
41176 You must ensure that Exim does not try to deliver the message while you are
41177 fiddling with it. The safest way is to take out a write lock on the -D file,
41178 which is what Exim itself does, using &[fcntl()]&. If you update the file in
41179 place, the lock will be retained. If you write a new file and rename it, the
41180 lock will be lost at the instant of rename.
41181 .next
41182 .vindex "&$body_linecount$&"
41183 If you change the number of lines in the file, the value of
41184 &$body_linecount$&, which is stored in the -H file, will be incorrect and can
41185 cause incomplete transmission of messages or undeliverable messages.
41186 .next
41187 If the message is in MIME format, you must take care not to break it.
41188 .next
41189 If the message is cryptographically signed, any change will invalidate the
41190 signature.
41191 .endlist
41192 All in all, modifying -D files is fraught with danger.
41193
41194 Files whose names end with -J may also be seen in the &_input_& directory (or
41195 its subdirectories when &%split_spool_directory%& is set). These are journal
41196 files, used to record addresses to which the message has been delivered during
41197 the course of a delivery attempt. If there are still undelivered recipients at
41198 the end, the -H file is updated, and the -J file is deleted. If, however, there
41199 is some kind of crash (for example, a power outage) before this happens, the -J
41200 file remains in existence. When Exim next processes the message, it notices the
41201 -J file and uses it to update the -H file before starting the next delivery
41202 attempt.
41203
41204 Files whose names end with -K or .eml may also be seen in the spool.
41205 These are temporaries used for DKIM or malware processing, when that is used.
41206 They should be tidied up by normal operations; any old ones are probably
41207 relics of crashes and can be removed.
41208
41209 .section "Format of the -H file" "SECID282"
41210 .cindex "uid (user id)" "in spool file"
41211 .cindex "gid (group id)" "in spool file"
41212 The second line of the -H file contains the login name for the uid of the
41213 process that called Exim to read the message, followed by the numerical uid and
41214 gid. For a locally generated message, this is normally the user who sent the
41215 message. For a message received over TCP/IP via the daemon, it is
41216 normally the Exim user.
41217
41218 The third line of the file contains the address of the message's sender as
41219 transmitted in the envelope, contained in angle brackets. The sender address is
41220 empty for bounce messages. For incoming SMTP mail, the sender address is given
41221 in the MAIL command. For locally generated mail, the sender address is
41222 created by Exim from the login name of the current user and the configured
41223 &%qualify_domain%&. However, this can be overridden by the &%-f%& option or a
41224 leading &"From&~"& line if the caller is trusted, or if the supplied address is
41225 &"<>"& or an address that matches &%untrusted_set_senders%&.
41226
41227 The fourth line contains two numbers. The first is the time that the message
41228 was received, in the conventional Unix form &-- the number of seconds since the
41229 start of the epoch. The second number is a count of the number of messages
41230 warning of delayed delivery that have been sent to the sender.
41231
41232 There follow a number of lines starting with a hyphen.
41233 These contain variables, can appear in any
41234 order, and are omitted when not relevant.
41235
41236 If there is a second hyphen after the first,
41237 the corresponding data is tainted.
41238 If there is a value in parentheses, the data is quoted for a lookup.
41239
41240 The following word specifies a variable,
41241 and the remainder of the item depends on the variable.
41242
41243 .vlist
41244 .vitem "&%-acl%&&~<&'number'&>&~<&'length'&>"
41245 This item is obsolete, and is not generated from Exim release 4.61 onwards;
41246 &%-aclc%& and &%-aclm%& are used instead. However, &%-acl%& is still
41247 recognized, to provide backward compatibility. In the old format, a line of
41248 this form is present for every ACL variable that is not empty. The number
41249 identifies the variable; the &%acl_c%&&*x*& variables are numbered 0&--9 and
41250 the &%acl_m%&&*x*& variables are numbered 10&--19. The length is the length of
41251 the data string for the variable. The string itself starts at the beginning of
41252 the next line, and is followed by a newline character. It may contain internal
41253 newlines.
41254
41255 .vitem "&%-aclc%&&~<&'rest-of-name'&>&~<&'length'&>"
41256 A line of this form is present for every ACL connection variable that is
41257 defined. Note that there is a space between &%-aclc%& and the rest of the name.
41258 The length is the length of the data string for the variable. The string itself
41259 starts at the beginning of the next line, and is followed by a newline
41260 character. It may contain internal newlines.
41261
41262 .vitem "&%-aclm%&&~<&'rest-of-name'&>&~<&'length'&>"
41263 A line of this form is present for every ACL message variable that is defined.
41264 Note that there is a space between &%-aclm%& and the rest of the name. The
41265 length is the length of the data string for the variable. The string itself
41266 starts at the beginning of the next line, and is followed by a newline
41267 character. It may contain internal newlines.
41268
41269 .vitem "&%-active_hostname%&&~<&'hostname'&>"
41270 This is present if, when the message was received over SMTP, the value of
41271 &$smtp_active_hostname$& was different to the value of &$primary_hostname$&.
41272
41273 .vitem &%-allow_unqualified_recipient%&
41274 This is present if unqualified recipient addresses are permitted in header
41275 lines (to stop such addresses from being qualified if rewriting occurs at
41276 transport time). Local messages that were input using &%-bnq%& and remote
41277 messages from hosts that match &%recipient_unqualified_hosts%& set this flag.
41278
41279 .vitem &%-allow_unqualified_sender%&
41280 This is present if unqualified sender addresses are permitted in header lines
41281 (to stop such addresses from being qualified if rewriting occurs at transport
41282 time). Local messages that were input using &%-bnq%& and remote messages from
41283 hosts that match &%sender_unqualified_hosts%& set this flag.
41284
41285 .vitem "&%-auth_id%&&~<&'text'&>"
41286 The id information for a message received on an authenticated SMTP connection
41287 &-- the value of the &$authenticated_id$& variable.
41288
41289 .vitem "&%-auth_sender%&&~<&'address'&>"
41290 The address of an authenticated sender &-- the value of the
41291 &$authenticated_sender$& variable.
41292
41293 .vitem "&%-body_linecount%&&~<&'number'&>"
41294 This records the number of lines in the body of the message, and is
41295 present unless &%-spool_file_wireformat%& is.
41296
41297 .vitem "&%-body_zerocount%&&~<&'number'&>"
41298 This records the number of binary zero bytes in the body of the message, and is
41299 present if the number is greater than zero.
41300
41301 .vitem &%-deliver_firsttime%&
41302 This is written when a new message is first added to the spool. When the spool
41303 file is updated after a deferral, it is omitted.
41304
41305 .vitem "&%-frozen%&&~<&'time'&>"
41306 .cindex "frozen messages" "spool data"
41307 The message is frozen, and the freezing happened at <&'time'&>.
41308
41309 .vitem "&%-helo_name%&&~<&'text'&>"
41310 This records the host name as specified by a remote host in a HELO or EHLO
41311 command.
41312
41313 .vitem "&%-host_address%&&~<&'address'&>.<&'port'&>"
41314 This records the IP address of the host from which the message was received and
41315 the remote port number that was used. It is omitted for locally generated
41316 messages.
41317
41318 .vitem "&%-host_auth%&&~<&'text'&>"
41319 If the message was received on an authenticated SMTP connection, this records
41320 the name of the authenticator &-- the value of the
41321 &$sender_host_authenticated$& variable.
41322
41323 .vitem &%-host_lookup_failed%&
41324 This is present if an attempt to look up the sending host's name from its IP
41325 address failed. It corresponds to the &$host_lookup_failed$& variable.
41326
41327 .vitem "&%-host_name%&&~<&'text'&>"
41328 .cindex "reverse DNS lookup"
41329 .cindex "DNS" "reverse lookup"
41330 This records the name of the remote host from which the message was received,
41331 if the host name was looked up from the IP address when the message was being
41332 received. It is not present if no reverse lookup was done.
41333
41334 .vitem "&%-ident%&&~<&'text'&>"
41335 For locally submitted messages, this records the login of the originating user,
41336 unless it was a trusted user and the &%-oMt%& option was used to specify an
41337 ident value. For messages received over TCP/IP, this records the ident string
41338 supplied by the remote host, if any.
41339
41340 .vitem "&%-interface_address%&&~<&'address'&>.<&'port'&>"
41341 This records the IP address of the local interface and the port number through
41342 which a message was received from a remote host. It is omitted for locally
41343 generated messages.
41344
41345 .vitem &%-local%&
41346 The message is from a local sender.
41347
41348 .vitem &%-localerror%&
41349 The message is a locally-generated bounce message.
41350
41351 .vitem "&%-local_scan%&&~<&'string'&>"
41352 This records the data string that was returned by the &[local_scan()]& function
41353 when the message was received &-- the value of the &$local_scan_data$&
41354 variable. It is omitted if no data was returned.
41355
41356 .vitem &%-manual_thaw%&
41357 The message was frozen but has been thawed manually, that is, by an explicit
41358 Exim command rather than via the auto-thaw process.
41359
41360 .vitem &%-N%&
41361 A testing delivery process was started using the &%-N%& option to suppress any
41362 actual deliveries, but delivery was deferred. At any further delivery attempts,
41363 &%-N%& is assumed.
41364
41365 .vitem &%-received_protocol%&
41366 This records the value of the &$received_protocol$& variable, which contains
41367 the name of the protocol by which the message was received.
41368
41369 .vitem &%-sender_set_untrusted%&
41370 The envelope sender of this message was set by an untrusted local caller (used
41371 to ensure that the caller is displayed in queue listings).
41372
41373 .vitem "&%-spam_score_int%&&~<&'number'&>"
41374 If a message was scanned by SpamAssassin, this is present. It records the value
41375 of &$spam_score_int$&.
41376
41377 .vitem &%-spool_file_wireformat%&
41378 The -D file for this message is in wire-format (for ESMTP CHUNKING)
41379 rather than Unix-format.
41380 The line-ending is CRLF rather than newline.
41381 There is still, however, no leading-dot-stuffing.
41382
41383 .vitem &%-tls_certificate_verified%&
41384 A TLS certificate was received from the client that sent this message, and the
41385 certificate was verified by the server.
41386
41387 .vitem "&%-tls_cipher%&&~<&'cipher name'&>"
41388 When the message was received over an encrypted connection, this records the
41389 name of the cipher suite that was used.
41390
41391 .vitem "&%-tls_peerdn%&&~<&'peer DN'&>"
41392 When the message was received over an encrypted connection, and a certificate
41393 was received from the client, this records the Distinguished Name from that
41394 certificate.
41395 .endlist
41396
41397 Following the options there is a list of those addresses to which the message
41398 is not to be delivered. This set of addresses is initialized from the command
41399 line when the &%-t%& option is used and &%extract_addresses_remove_arguments%&
41400 is set; otherwise it starts out empty. Whenever a successful delivery is made,
41401 the address is added to this set. The addresses are kept internally as a
41402 balanced binary tree, and it is a representation of that tree which is written
41403 to the spool file. If an address is expanded via an alias or forward file, the
41404 original address is added to the tree when deliveries to all its child
41405 addresses are complete.
41406
41407 If the tree is empty, there is a single line in the spool file containing just
41408 the text &"XX"&. Otherwise, each line consists of two letters, which are either
41409 Y or N, followed by an address. The address is the value for the node of the
41410 tree, and the letters indicate whether the node has a left branch and/or a
41411 right branch attached to it, respectively. If branches exist, they immediately
41412 follow. Here is an example of a three-node tree:
41413 .code
41414 YY darcy@austen.fict.example
41415 NN alice@wonderland.fict.example
41416 NN editor@thesaurus.ref.example
41417 .endd
41418 After the non-recipients tree, there is a list of the message's recipients.
41419 This is a simple list, preceded by a count. It includes all the original
41420 recipients of the message, including those to whom the message has already been
41421 delivered. In the simplest case, the list contains one address per line. For
41422 example:
41423 .code
41424 4
41425 editor@thesaurus.ref.example
41426 darcy@austen.fict.example
41427 rdo@foundation
41428 alice@wonderland.fict.example
41429 .endd
41430 However, when a child address has been added to the top-level addresses as a
41431 result of the use of the &%one_time%& option on a &(redirect)& router, each
41432 line is of the following form:
41433 .display
41434 <&'top-level address'&> <&'errors_to address'&> &&&
41435   <&'length'&>,<&'parent number'&>#<&'flag bits'&>
41436 .endd
41437 The 01 flag bit indicates the presence of the three other fields that follow
41438 the top-level address. Other bits may be used in future to support additional
41439 fields. The <&'parent number'&> is the offset in the recipients list of the
41440 original parent of the &"one time"& address. The first two fields are the
41441 envelope sender that is associated with this address and its length. If the
41442 length is zero, there is no special envelope sender (there are then two space
41443 characters in the line). A non-empty field can arise from a &(redirect)& router
41444 that has an &%errors_to%& setting.
41445
41446
41447 A blank line separates the envelope and status information from the headers
41448 which follow. A header may occupy several lines of the file, and to save effort
41449 when reading it in, each header is preceded by a number and an identifying
41450 character. The number is the number of characters in the header, including any
41451 embedded newlines and the terminating newline. The character is one of the
41452 following:
41453
41454 .table2 50pt
41455 .row <&'blank'&>         "header in which Exim has no special interest"
41456 .row &`B`&               "&'Bcc:'& header"
41457 .row &`C`&               "&'Cc:'& header"
41458 .row &`F`&               "&'From:'& header"
41459 .row &`I`&               "&'Message-id:'& header"
41460 .row &`P`&               "&'Received:'& header &-- P for &""postmark""&"
41461 .row &`R`&               "&'Reply-To:'& header"
41462 .row &`S`&               "&'Sender:'& header"
41463 .row &`T`&               "&'To:'& header"
41464 .row &`*`&               "replaced or deleted header"
41465 .endtable
41466
41467 Deleted or replaced (rewritten) headers remain in the spool file for debugging
41468 purposes. They are not transmitted when the message is delivered. Here is a
41469 typical set of headers:
41470 .code
41471 111P Received: by hobbit.fict.example with local (Exim 4.00)
41472 id 14y9EI-00026G-00; Fri, 11 May 2001 10:28:59 +0100
41473 049  Message-Id: <E14y9EI-00026G-00@hobbit.fict.example>
41474 038* X-rewrote-sender: bb@hobbit.fict.example
41475 042* From: Bilbo Baggins <bb@hobbit.fict.example>
41476 049F From: Bilbo Baggins <B.Baggins@hobbit.fict.example>
41477 099* To: alice@wonderland.fict.example, rdo@foundation,
41478 darcy@austen.fict.example, editor@thesaurus.ref.example
41479 104T To: alice@wonderland.fict.example, rdo@foundation.example,
41480 darcy@austen.fict.example, editor@thesaurus.ref.example
41481 038  Date: Fri, 11 May 2001 10:28:59 +0100
41482 .endd
41483 The asterisked headers indicate that the envelope sender, &'From:'& header, and
41484 &'To:'& header have been rewritten, the last one because routing expanded the
41485 unqualified domain &'foundation'&.
41486 .ecindex IIDforspo1
41487 .ecindex IIDforspo2
41488 .ecindex IIDforspo3
41489
41490 .section "Format of the -D file" "SECID282a"
41491 The data file is traditionally in Unix-standard format: lines are ended with
41492 an ASCII newline character.
41493 However, when the &%spool_wireformat%& main option is used some -D files
41494 can have an alternate format.
41495 This is flagged by a &%-spool_file_wireformat%& line in the corresponding -H file.
41496 The -D file lines (not including the first name-component line) are
41497 suitable for direct copying to the wire when transmitting using the
41498 ESMTP CHUNKING option, meaning lower processing overhead.
41499 Lines are terminated with an ASCII CRLF pair.
41500 There is no dot-stuffing (and no dot-termination).
41501
41502 . ////////////////////////////////////////////////////////////////////////////
41503 . ////////////////////////////////////////////////////////////////////////////
41504
41505 .chapter "DKIM, SPF, SRS and DMARC" "CHAPdkim" &&&
41506          "DKIM, SPF, SRS and DMARC Support"
41507
41508 .section "DKIM (DomainKeys Identified Mail)" SECDKIM
41509 .cindex "DKIM"
41510
41511 DKIM is a mechanism by which messages sent by some entity can be provably
41512 linked to a domain which that entity controls.  It permits reputation to
41513 be tracked on a per-domain basis, rather than merely upon source IP address.
41514 DKIM is documented in RFC 6376.
41515
41516 As DKIM relies on the message being unchanged in transit, messages handled
41517 by a mailing-list (which traditionally adds to the message) will not match
41518 any original DKIM signature.
41519
41520 DKIM support is compiled into Exim by default if TLS support is present.
41521 It can be disabled by setting DISABLE_DKIM=yes in &_Local/Makefile_&.
41522
41523 Exim's DKIM implementation allows for
41524 .olist
41525 Signing outgoing messages: This function is implemented in the SMTP transport.
41526 It can co-exist with all other Exim features
41527 (including transport filters)
41528 except cutthrough delivery.
41529 .next
41530 Verifying signatures in incoming messages: This is implemented by an additional
41531 ACL (acl_smtp_dkim), which can be called several times per message, with
41532 different signature contexts.
41533 .endlist
41534
41535 In typical Exim style, the verification implementation does not include any
41536 default "policy". Instead it enables you to build your own policy using
41537 Exim's standard controls.
41538
41539 Please note that verification of DKIM signatures in incoming mail is turned
41540 on by default for logging (in the <= line) purposes.
41541
41542 Additional log detail can be enabled using the &%dkim_verbose%& log_selector.
41543 When set, for each signature in incoming email,
41544 exim will log a line displaying the most important signature details, and the
41545 signature status. Here is an example (with line-breaks added for clarity):
41546 .code
41547 2009-09-09 10:22:28 1MlIRf-0003LU-U3 DKIM:
41548     d=facebookmail.com s=q1-2009b
41549     c=relaxed/relaxed a=rsa-sha1
41550     i=@facebookmail.com t=1252484542 [verification succeeded]
41551 .endd
41552
41553 You might want to turn off DKIM verification processing entirely for internal
41554 or relay mail sources. To do that, set the &%dkim_disable_verify%& ACL
41555 control modifier. This should typically be done in the RCPT ACL, at points
41556 where you accept mail from relay sources (internal hosts or authenticated
41557 senders).
41558
41559
41560 .subsection "Signing outgoing messages" SECDKIMSIGN
41561 .cindex DKIM signing
41562
41563 For signing to be usable you must have published a DKIM record in DNS.
41564 Note that RFC 8301 (which does not cover EC keys) says:
41565 .code
41566 rsa-sha1 MUST NOT be used for signing or verifying.
41567
41568 Signers MUST use RSA keys of at least 1024 bits for all keys.
41569 Signers SHOULD use RSA keys of at least 2048 bits.
41570 .endd
41571
41572 Note also that the key content (the 'p=' field)
41573 in the DNS record is different between RSA and EC keys;
41574 for the former it is the base64 of the ASN.1 for the RSA public key
41575 (equivalent to the private-key .pem with the header/trailer stripped)
41576 but for EC keys it is the base64 of the pure key; no ASN.1 wrapping.
41577
41578 Signing is enabled by setting private options on the SMTP transport.
41579 These options take (expandable) strings as arguments.
41580
41581 .option dkim_domain smtp "string list&!!" unset
41582 The domain(s) you want to sign with.
41583 After expansion, this can be a list.
41584 Each element in turn,
41585 lowercased,
41586 .vindex "&$dkim_domain$&"
41587 is put into the &%$dkim_domain%& expansion variable
41588 while expanding the remaining signing options.
41589 If it is empty after expansion, DKIM signing is not done,
41590 and no error will result even if &%dkim_strict%& is set.
41591
41592 .option dkim_selector smtp "string list&!!" unset
41593 This sets the key selector string.
41594 After expansion, which can use &$dkim_domain$&, this can be a list.
41595 Each element in turn is put in the expansion
41596 .vindex "&$dkim_selector$&"
41597 variable &%$dkim_selector%& which may be used in the &%dkim_private_key%&
41598 option along with &%$dkim_domain%&.
41599 If the option is empty after expansion, DKIM signing is not done for this domain,
41600 and no error will result even if &%dkim_strict%& is set.
41601
41602 To do, for example, dual-signing with RSA and EC keys
41603 this could be be used:
41604 .code
41605 dkim_selector = ec_sel : rsa_sel
41606 dkim_private_key = KEYS_DIR/$dkim_selector
41607 .endd
41608
41609 .option dkim_private_key smtp string&!! unset
41610 This sets the private key to use.
41611 You can use the &%$dkim_domain%& and
41612 &%$dkim_selector%& expansion variables to determine the private key to use.
41613 The result can either
41614 .ilist
41615 be a valid RSA private key in ASCII armor (.pem file), including line breaks
41616 .next
41617 with GnuTLS 3.6.0 or OpenSSL 1.1.1 or later,
41618 be a valid Ed25519 private key (same format as above)
41619 .next
41620 start with a slash, in which case it is treated as a file that contains
41621 the private key
41622 .next
41623 be "0", "false" or the empty string, in which case the message will not
41624 be signed. This case will not result in an error, even if &%dkim_strict%&
41625 is set.
41626 .endlist
41627
41628 To generate keys under OpenSSL:
41629 .code
41630 openssl genrsa -out dkim_rsa.private 2048
41631 openssl rsa -in dkim_rsa.private -out /dev/stdout -pubout -outform PEM
41632 .endd
41633 The result file from the first command should be retained, and
41634 this option set to use it.
41635 Take the base-64 lines from the output of the second command, concatenated,
41636 for the DNS TXT record.
41637 See section 3.6 of RFC6376 for the record specification.
41638
41639 Under GnuTLS:
41640 .code
41641 certtool --generate-privkey --rsa --bits=2048 --password='' -8 --outfile=dkim_rsa.private
41642 certtool --load-privkey=dkim_rsa.private --pubkey-info
41643 .endd
41644
41645 Note that RFC 8301 says:
41646 .code
41647 Signers MUST use RSA keys of at least 1024 bits for all keys.
41648 Signers SHOULD use RSA keys of at least 2048 bits.
41649 .endd
41650
41651 EC keys for DKIM are defined by RFC 8463.
41652 They are considerably smaller than RSA keys for equivalent protection.
41653 As they are a recent development, users should consider dual-signing
41654 (by setting a list of selectors, and an expansion for this option)
41655 for some transition period.
41656 The "_CRYPTO_SIGN_ED25519" macro will be defined if support is present
41657 for EC keys.
41658
41659 OpenSSL 1.1.1 and GnuTLS 3.6.0 can create Ed25519 private keys:
41660 .code
41661 openssl genpkey -algorithm ed25519 -out dkim_ed25519.private
41662 certtool --generate-privkey --key-type=ed25519 --outfile=dkim_ed25519.private
41663 .endd
41664
41665 To produce the required public key value for a DNS record:
41666 .code
41667 openssl pkey -outform DER -pubout -in dkim_ed25519.private | tail -c +13 | base64
41668 certtool --load_privkey=dkim_ed25519.private --pubkey_info --outder | tail -c +13 | base64
41669 .endd
41670
41671 Exim also supports an alternate format
41672 of Ed25519 keys in DNS which was a candidate during development
41673 of the standard, but not adopted.
41674 A future release will probably drop that support.
41675
41676 .option dkim_hash smtp string&!! sha256
41677 Can be set to any one of the supported hash methods, which are:
41678 .ilist
41679 &`sha1`& &-- should not be used, is old and insecure
41680 .next
41681 &`sha256`& &-- the default
41682 .next
41683 &`sha512`& &-- possibly more secure but less well supported
41684 .endlist
41685
41686 Note that RFC 8301 says:
41687 .code
41688 rsa-sha1 MUST NOT be used for signing or verifying.
41689 .endd
41690
41691 .option dkim_identity smtp string&!! unset
41692 If set after expansion, the value is used to set an "i=" tag in
41693 the signing header.  The DKIM standards restrict the permissible
41694 syntax of this optional tag to a mail address, with possibly-empty
41695 local part, an @, and a domain identical to or subdomain of the "d="
41696 tag value.  Note that Exim does not check the value.
41697
41698 .option dkim_canon smtp string&!! unset
41699 This option sets the canonicalization method used when signing a message.
41700 The DKIM RFC currently supports two methods: "simple" and "relaxed".
41701 The option defaults to "relaxed" when unset. Note: the current implementation
41702 only supports signing with the same canonicalization method for both headers and body.
41703
41704 .option dkim_strict smtp string&!! unset
41705 This  option  defines  how  Exim  behaves  when  signing a message that
41706 should be signed fails for some reason.  When the expansion evaluates to
41707 either &"1"& or &"true"&, Exim will defer. Otherwise Exim will send the message
41708 unsigned. You can use the &%$dkim_domain%& and &%$dkim_selector%& expansion
41709 variables here.
41710
41711 .option dkim_sign_headers smtp string&!! "see below"
41712 If set, this option must expand to a colon-separated
41713 list of header names.
41714 Headers with these names, or the absence or such a header, will be included
41715 in the message signature.
41716 When unspecified, the header names listed in RFC4871 will be used,
41717 whether or not each header is present in the message.
41718 The default list is available for the expansion in the macro
41719 &"_DKIM_SIGN_HEADERS"&
41720 and an oversigning variant is in &"_DKIM_OVERSIGN_HEADERS"&.
41721
41722 If a name is repeated, multiple headers by that name (or the absence thereof)
41723 will be signed.  The textually later headers in the headers part of the
41724 message are signed first, if there are multiples.
41725
41726 A name can be prefixed with either an &"="& or a &"+"& character.
41727 If an &"="& prefix is used, all headers that are present with this name
41728 will be signed.
41729 If a &"+"& prefix if used, all headers that are present with this name
41730 will be signed, and one signature added for a missing header with the
41731 name will be appended.
41732
41733 .option dkim_timestamps smtp integer&!! unset
41734 This option controls the inclusion of timestamp information in the signature.
41735 If not set, no such information will be included.
41736 Otherwise, must be an unsigned number giving an offset in seconds from the current time
41737 for the expiry tag
41738 (eg. 1209600 for two weeks);
41739 both creation (t=) and expiry (x=) tags will be included.
41740
41741 RFC 6376 lists these tags as RECOMMENDED.
41742
41743
41744 .subsection "Verifying DKIM signatures in incoming mail" SECDKIMVFY
41745 .cindex DKIM verification
41746
41747 Verification of DKIM signatures in SMTP incoming email is done for all
41748 messages for which an ACL control &%dkim_disable_verify%& has not been set.
41749
41750 .cindex DKIM "selecting signature algorithms"
41751 Individual classes of DKIM signature algorithm can be ignored by changing
41752 the main options &%dkim_verify_hashes%& or &%dkim_verify_keytypes%&.
41753 The &%dkim_verify_minimal%& option can be set to cease verification
41754 processing for a message once the first passing signature is found.
41755
41756 .cindex authentication "expansion item"
41757 Performing verification sets up information used by the
41758 &%authresults%& expansion item.
41759
41760 For most purposes the default option settings suffice and the remainder
41761 of this section can be ignored.
41762
41763 The results of verification are made available to the
41764 &%acl_smtp_dkim%& ACL, which (for complex needs) can examine and modify them.
41765 A missing ACL definition defaults to accept.
41766 By default, the ACL is called once for each
41767 syntactically(!) correct signature in the incoming message.
41768 If any ACL call does not accept, the message is not accepted.
41769 If a cutthrough delivery was in progress for the message, that is
41770 summarily dropped (having wasted the transmission effort).
41771
41772 To evaluate the verification result in the ACL
41773 a large number of expansion variables
41774 containing the signature status and its details are set up during the
41775 runtime of the ACL.
41776
41777 Calling the ACL only for existing signatures is not sufficient to build
41778 more advanced policies. For that reason, the main option
41779 &%dkim_verify_signers%&, and an expansion variable
41780 &%$dkim_signers%& exist.
41781
41782 The main option &%dkim_verify_signers%& can be set to a colon-separated
41783 list of DKIM domains or identities for which the ACL &%acl_smtp_dkim%& is
41784 called. It is expanded when the message has been received. At this point,
41785 the expansion variable &%$dkim_signers%& already contains a colon-separated
41786 list of signer domains and identities for the message. When
41787 &%dkim_verify_signers%& is not specified in the main configuration,
41788 it defaults as:
41789 .code
41790 dkim_verify_signers = $dkim_signers
41791 .endd
41792 This leads to the default behaviour of calling &%acl_smtp_dkim%& for each
41793 DKIM signature in the message. Current DKIM verifiers may want to explicitly
41794 call the ACL for known domains or identities. This would be achieved as follows:
41795 .code
41796 dkim_verify_signers = paypal.com:ebay.com:$dkim_signers
41797 .endd
41798 This would result in &%acl_smtp_dkim%& always being called for "paypal.com"
41799 and "ebay.com", plus all domains and identities that have signatures in the message.
41800 You can also be more creative in constructing your policy. For example:
41801 .code
41802 dkim_verify_signers = $sender_address_domain:$dkim_signers
41803 .endd
41804
41805 If a domain or identity is listed several times in the (expanded) value of
41806 &%dkim_verify_signers%&, the ACL is only called once for that domain or identity.
41807
41808 Note that if the option is set using untrustworthy data
41809 (such as the From: header)
41810 care should be taken to force lowercase for domains
41811 and for the domain part if identities.
41812 The default setting can be regarded as trustworthy in this respect.
41813
41814 If multiple signatures match a domain (or identity), the ACL is called once
41815 for each matching signature.
41816
41817
41818 Inside the DKIM ACL, the following expansion variables are
41819 available (from most to least important):
41820
41821
41822 .vlist
41823 .vitem &%$dkim_cur_signer%&
41824 The signer that is being evaluated in this ACL run. This can be a domain or
41825 an identity. This is one of the list items from the expanded main option
41826 &%dkim_verify_signers%& (see above).
41827
41828 .vitem &%$dkim_verify_status%&
41829 So long as a DKIM ACL is defined
41830 (it need do no more than accept, which is the default),
41831 after all the DKIM ACL runs have completed, the value becomes a
41832 colon-separated list of the values after each run.
41833 The value is maintained for the MIME, PRDR and DATA ACLs.
41834
41835 Within the DKIM ACL,
41836 a string describing the general status of the signature. One of
41837 .ilist
41838 &%none%&: There is no signature in the message for the current domain or
41839 identity (as reflected by &%$dkim_cur_signer%&).
41840 .next
41841 &%invalid%&: The signature could not be verified due to a processing error.
41842 More detail is available in &%$dkim_verify_reason%&.
41843 .next
41844 &%fail%&: Verification of the signature failed.  More detail is
41845 available in &%$dkim_verify_reason%&.
41846 .next
41847 &%pass%&: The signature passed verification. It is valid.
41848 .endlist
41849
41850 This variable can be overwritten using an ACL 'set' modifier.
41851 This might, for instance, be done to enforce a policy restriction on
41852 hash-method or key-size:
41853 .code
41854   warn condition       = ${if eq {$dkim_verify_status}{pass}}
41855        condition       = ${if eq {${length_3:$dkim_algo}}{rsa}}
41856        condition       = ${if or {{eq {$dkim_algo}{rsa-sha1}} \
41857                                   {< {$dkim_key_length}{1024}}}}
41858        logwrite        = NOTE: forcing DKIM verify fail (was pass)
41859        set dkim_verify_status = fail
41860        set dkim_verify_reason = hash too weak or key too short
41861 .endd
41862
41863 .vitem &%$dkim_verify_reason%&
41864 A string giving a little bit more detail when &%$dkim_verify_status%& is either
41865 "fail" or "invalid". One of
41866 .ilist
41867 &%pubkey_unavailable%& (when &%$dkim_verify_status%&="invalid"): The public
41868 key for the domain could not be retrieved. This may be a temporary problem.
41869 .next
41870 &%pubkey_syntax%& (when &%$dkim_verify_status%&="invalid"): The public key
41871 record for the domain is syntactically invalid.
41872 .next
41873 &%bodyhash_mismatch%& (when &%$dkim_verify_status%&="fail"): The calculated
41874 body hash does not match the one specified in the signature header. This
41875 means that the message body was modified in transit.
41876 .next
41877 &%signature_incorrect%& (when &%$dkim_verify_status%&="fail"): The signature
41878 could not be verified. This may mean that headers were modified,
41879 re-written or otherwise changed in a way which is incompatible with
41880 DKIM verification. It may of course also mean that the signature is forged.
41881 .endlist
41882
41883 This variable can be overwritten, with any value, using an ACL 'set' modifier.
41884
41885 .vitem &%$dkim_domain%&
41886 The signing domain. IMPORTANT: This variable is only populated if there is
41887 an actual signature in the message for the current domain or identity (as
41888 reflected by &%$dkim_cur_signer%&).
41889
41890 .vitem &%$dkim_identity%&
41891 The signing identity, if present. IMPORTANT: This variable is only populated
41892 if there is an actual signature in the message for the current domain or
41893 identity (as reflected by &%$dkim_cur_signer%&).
41894
41895 .vitem &%$dkim_selector%&
41896 The key record selector string.
41897
41898 .vitem &%$dkim_algo%&
41899 The algorithm used. One of 'rsa-sha1' or 'rsa-sha256'.
41900 If running under GnuTLS 3.6.0 or OpenSSL 1.1.1 or later,
41901 may also be 'ed25519-sha256'.
41902 The "_CRYPTO_SIGN_ED25519" macro will be defined if support is present
41903 for EC keys.
41904
41905 Note that RFC 8301 says:
41906 .code
41907 rsa-sha1 MUST NOT be used for signing or verifying.
41908
41909 DKIM signatures identified as having been signed with historic
41910 algorithms (currently, rsa-sha1) have permanently failed evaluation
41911 .endd
41912
41913 To enforce this you must either have a DKIM ACL which checks this variable
41914 and overwrites the &$dkim_verify_status$& variable as discussed above,
41915 or have set the main option &%dkim_verify_hashes%& to exclude
41916 processing of such signatures.
41917
41918 .vitem &%$dkim_canon_body%&
41919 The body canonicalization method. One of 'relaxed' or 'simple'.
41920
41921 .vitem &%$dkim_canon_headers%&
41922 The header canonicalization method. One of 'relaxed' or 'simple'.
41923
41924 .vitem &%$dkim_copiedheaders%&
41925 A transcript of headers and their values which are included in the signature
41926 (copied from the 'z=' tag of the signature).
41927 Note that RFC6376 requires that verification fail if the From: header is
41928 not included in the signature.  Exim does not enforce this; sites wishing
41929 strict enforcement should code the check explicitly.
41930
41931 .vitem &%$dkim_bodylength%&
41932 The number of signed body bytes. If zero ("0"), the body is unsigned. If no
41933 limit was set by the signer, "9999999999999" is returned. This makes sure
41934 that this variable always expands to an integer value.
41935 &*Note:*& The presence of the signature tag specifying a signing body length
41936 is one possible route to spoofing of valid DKIM signatures.
41937 A paranoid implementation might wish to regard signature where this variable
41938 shows less than the "no limit" return as being invalid.
41939
41940 .vitem &%$dkim_created%&
41941 UNIX timestamp reflecting the date and time when the signature was created.
41942 When this was not specified by the signer, "0" is returned.
41943
41944 .vitem &%$dkim_expires%&
41945 UNIX timestamp reflecting the date and time when the signer wants the
41946 signature to be treated as "expired". When this was not specified by the
41947 signer, "9999999999999" is returned. This makes it possible to do useful
41948 integer size comparisons against this value.
41949 Note that Exim does not check this value.
41950
41951 .vitem &%$dkim_headernames%&
41952 A colon-separated list of names of headers included in the signature.
41953
41954 .vitem &%$dkim_key_testing%&
41955 "1" if the key record has the "testing" flag set, "0" if not.
41956
41957 .vitem &%$dkim_key_nosubdomains%&
41958 "1" if the key record forbids subdomaining, "0" otherwise.
41959
41960 .vitem &%$dkim_key_srvtype%&
41961 Service type (tag s=) from the key record. Defaults to "*" if not specified
41962 in the key record.
41963
41964 .vitem &%$dkim_key_granularity%&
41965 Key granularity (tag g=) from the key record. Defaults to "*" if not specified
41966 in the key record.
41967
41968 .vitem &%$dkim_key_notes%&
41969 Notes from the key record (tag n=).
41970
41971 .vitem &%$dkim_key_length%&
41972 Number of bits in the key.
41973 Valid only once the key is loaded, which is at the time the header signature
41974 is verified, which is after the body hash is.
41975
41976 Note that RFC 8301 says:
41977 .code
41978 Verifiers MUST NOT consider signatures using RSA keys of
41979 less than 1024 bits as valid signatures.
41980 .endd
41981
41982 This is enforced by the default setting for the &%dkim_verify_min_keysizes%&
41983 option.
41984
41985 .endlist
41986
41987 In addition, two ACL conditions are provided:
41988
41989 .vlist
41990 .vitem &%dkim_signers%&
41991 ACL condition that checks a colon-separated list of domains or identities
41992 for a match against the domain or identity that the ACL is currently verifying
41993 (reflected by &%$dkim_cur_signer%&).
41994 This condition is only usable in a DKIM ACL.
41995 This is typically used to restrict an ACL
41996 verb to a group of domains or identities. For example:
41997
41998 .code
41999 # Warn when Mail purportedly from GMail has no gmail signature
42000 warn sender_domains = gmail.com
42001      dkim_signers = gmail.com
42002      dkim_status = none
42003      log_message = GMail sender without gmail.com DKIM signature
42004 .endd
42005
42006 Note that the above does not check for a total lack of DKIM signing;
42007 for that check for empty &$h_DKIM-Signature:$& in the data ACL.
42008
42009 .vitem &%dkim_status%&
42010 ACL condition that checks a colon-separated list of possible DKIM verification
42011 results against the actual result of verification,
42012 given by &$dkim_verify_status$& if that is non-empty or "none" if empty.
42013 .new
42014 This condition may be used in DKIM, MIME, PRDR and DATA ACLs.
42015 .wen
42016
42017 A basic verification might be:
42018 .code
42019 deny !dkim_status = pass:none:invalid
42020 .endd
42021
42022 A more complex use could be
42023 to restrict an ACL verb to a list of verification outcomes, for example:
42024
42025 .code
42026 deny sender_domains = paypal.com:paypal.de
42027      dkim_signers = paypal.com:paypal.de
42028      dkim_status = none:invalid:fail
42029      message = Mail from Paypal with invalid/missing signature
42030 .endd
42031
42032 The possible status keywords are: 'none','invalid','fail' and 'pass'. Please
42033 see the documentation of the &%$dkim_verify_status%& expansion variable above
42034 for more information of what they mean.
42035
42036 The condition is true if the status
42037 .new
42038 (or any of the list of status values)
42039 .wen
42040 is any one of the supplied list.
42041 .endlist
42042
42043
42044
42045
42046 .section "SPF (Sender Policy Framework)" SECSPF
42047 .cindex SPF verification
42048
42049 SPF is a mechanism whereby a domain may assert which IP addresses may transmit
42050 messages with its domain in the envelope from, documented by RFC 7208.
42051 For more information on SPF see &url(http://www.open-spf.org), a static copy of
42052 the &url(http://openspf.org).
42053 . --- 2019-10-28: still not https, open-spf.org is told to be a
42054 . --- web-archive copy of the now dead openspf.org site
42055 . --- See https://www.mail-archive.com/mailop@mailop.org/msg08019.html for a
42056 . --- discussion.
42057
42058 Messages sent by a system not authorised will fail checking of such assertions.
42059 This includes retransmissions done by traditional forwarders.
42060
42061 SPF verification support is built into Exim if SUPPORT_SPF=yes is set in
42062 &_Local/Makefile_&.  The support uses the &_libspf2_& library
42063 &url(https://www.libspf2.org/).
42064 There is no Exim involvement in the transmission of messages;
42065 publishing certain DNS records is all that is required.
42066
42067 For verification, an ACL condition and an expansion lookup are provided.
42068 .cindex authentication "expansion item"
42069 Performing verification sets up information used by the
42070 &%authresults%& expansion item.
42071
42072
42073 .cindex SPF "ACL condition"
42074 .cindex ACL "spf condition"
42075 The ACL condition "spf" can be used at or after the MAIL ACL.
42076 It takes as an argument a list of strings giving the outcome of the SPF check,
42077 and will succeed for any matching outcome.
42078 Valid strings are:
42079 .vlist
42080 .vitem &%pass%&
42081 The SPF check passed, the sending host is positively verified by SPF.
42082
42083 .vitem &%fail%&
42084 The SPF check failed, the sending host is NOT allowed to send mail for the
42085 domain in the envelope-from address.
42086
42087 .vitem &%softfail%&
42088 The SPF check failed, but the queried domain can't absolutely confirm that this
42089 is a forgery.
42090
42091 .vitem &%none%&
42092 The queried domain does not publish SPF records.
42093
42094 .vitem &%neutral%&
42095 The SPF check returned a "neutral" state.  This means the queried domain has
42096 published a SPF record, but wants to allow outside servers to send mail under
42097 its domain as well.  This should be treated like "none".
42098
42099 .vitem &%permerror%&
42100 This indicates a syntax error in the SPF record of the queried domain.
42101 You may deny messages when this occurs.
42102
42103 .vitem &%temperror%&
42104 This indicates a temporary error during all processing, including Exim's
42105 SPF processing.  You may defer messages when this occurs.
42106
42107 .vitem &%invalid%&
42108 There was an error during processing of the SPF lookup
42109 .endlist
42110
42111 You can prefix each string with an exclamation mark to  invert
42112 its meaning,  for example  "!fail" will  match all  results but
42113 "fail".  The  string  list is  evaluated  left-to-right,  in a
42114 short-circuit fashion.
42115
42116 Example:
42117 .code
42118 deny spf = fail
42119      message = $sender_host_address is not allowed to send mail from \
42120                ${if def:sender_address_domain \
42121                     {$sender_address_domain}{$sender_helo_name}}.  \
42122                Please see http://www.open-spf.org/Why;\
42123                identity=${if def:sender_address_domain \
42124                              {$sender_address}{$sender_helo_name}};\
42125                ip=$sender_host_address
42126 .endd
42127
42128 Note: The above mentioned URL may not be as helpful as expected. You are
42129 encouraged to replace the link with a link to a site with more
42130 explanations.
42131
42132 When the spf condition has run, it sets up several expansion
42133 variables:
42134
42135 .cindex SPF "verification variables"
42136 .vlist
42137 .vitem &$spf_header_comment$&
42138 .vindex &$spf_header_comment$&
42139   This contains a human-readable string describing the outcome
42140   of the SPF check. You can add it to a custom header or use
42141   it for logging purposes.
42142
42143 .vitem &$spf_received$&
42144 .vindex &$spf_received$&
42145   This contains a complete Received-SPF: header (name and
42146   content) that can be added to the message. Please note that
42147   according to the SPF draft, this header must be added at the
42148   top of the header list, i.e. with
42149 .code
42150 add_header = :at_start:$spf_received
42151 .endd
42152   See section &<<SECTaddheadacl>>& for further details.
42153
42154   Note: in case of "Best-guess" (see below), the convention is
42155   to put this string in a header called X-SPF-Guess: instead.
42156
42157 .vitem &$spf_result$&
42158 .vindex &$spf_result$&
42159   This contains the outcome of the SPF check in string form,
42160   currently one of pass, fail, softfail, none, neutral, permerror,
42161   temperror, or &"(invalid)"&.
42162
42163 .vitem &$spf_result_guessed$&
42164 .vindex &$spf_result_guessed$&
42165   This boolean is true only if a best-guess operation was used
42166   and required in order to obtain a result.
42167
42168 .vitem &$spf_smtp_comment$&
42169 .vindex &$spf_smtp_comment$&
42170 .vindex &%spf_smtp_comment_template%&
42171   This contains a string that can be used in a SMTP response
42172   to the calling party. Useful for "fail".
42173   The string is generated by the SPF library from the template configured in the main config
42174   option &%spf_smtp_comment_template%&.
42175 .endlist
42176
42177
42178 .cindex SPF "ACL condition"
42179 .cindex ACL "spf_guess condition"
42180 .cindex SPF "best guess"
42181 In addition to SPF, you can also perform checks for so-called
42182 "Best-guess".  Strictly speaking, "Best-guess" is not standard
42183 SPF, but it is supported by the same framework that enables SPF
42184 capability.
42185 Refer to &url(http://www.open-spf.org/FAQ/Best_guess_record)
42186 for a description of what it means.
42187 . --- 2019-10-28: still not https:
42188
42189 To access this feature, simply use the spf_guess condition in place
42190 of the spf one.  For example:
42191
42192 .code
42193 deny spf_guess = fail
42194      message = $sender_host_address doesn't look trustworthy to me
42195 .endd
42196
42197 In case you decide to reject messages based on this check, you
42198 should note that although it uses the same framework, "Best-guess"
42199 is not SPF, and therefore you should not mention SPF at all in your
42200 reject message.
42201
42202 When the spf_guess condition has run, it sets up the same expansion
42203 variables as when spf condition is run, described above.
42204
42205 Additionally, since Best-guess is not standardized, you may redefine
42206 what "Best-guess" means to you by redefining the main configuration
42207 &%spf_guess%& option.
42208 For example, the following:
42209
42210 .code
42211 spf_guess = v=spf1 a/16 mx/16 ptr ?all
42212 .endd
42213
42214 would relax host matching rules to a broader network range.
42215
42216
42217 .cindex SPF "lookup expansion"
42218 .cindex lookup spf
42219 A lookup expansion is also available. It takes an email
42220 address as the key and an IP address
42221 (v4 or v6)
42222 as the database:
42223
42224 .code
42225   ${lookup {username@domain} spf {ip.ip.ip.ip}}
42226 .endd
42227
42228 The lookup will return the same result strings as can appear in
42229 &$spf_result$& (pass,fail,softfail,neutral,none,err_perm,err_temp).
42230
42231
42232
42233
42234
42235 .subsection "SRS (Sender Rewriting Scheme)" SECTSRS
42236 .cindex SRS "sender rewriting scheme"
42237
42238 SRS can be used to modify sender addresses when forwarding so that
42239 SPF verification does not object to them.
42240 It operates by encoding the original envelope sender in a new
42241 sender local part and using a domain run by the forwarding site
42242 as the new domain for the sender.  Any DSN message should be returned
42243 to this new sender at the forwarding site, which can extract the
42244 original sender from the coded local part and forward the DSN to
42245 the originator.
42246
42247 This is a way of avoiding the breakage that SPF does to forwarding.
42248 The constructed local-part will be longer than the original,
42249 leading to possible problems with very long addresses.
42250 The changing of the sender address also hinders the tracing of mail
42251 problems.
42252
42253 Exim can be built to include native SRS support.  To do this
42254 SUPPORT_SRS=yes must be defined in &_Local/Makefile_&.
42255 If this has been done, the macros _HAVE_SRS and _HAVE_NATIVE_SRS
42256 will be defined.
42257 The support is limited to SRS0-encoding; SRS1 is not supported.
42258
42259 .cindex SRS excoding
42260 To encode an address use this expansion item:
42261 .vlist
42262 .vitem &*${srs_encode&~{*&<&'secret'&>&*}{*&<&'return&~path'&>&*}{*&<&'original&~domain'&>&*}}*&
42263 .cindex "&%srs_encode%& expansion item"
42264 .cindex SRS "expansion item"
42265 The first argument should be a secret known and used by all systems
42266 handling the recipient domain for the original message.
42267 There is no need to periodically change this key; a timestamp is also
42268 encoded.
42269 The second argument should be given as the envelope sender address before this
42270 encoding operation.
42271 If this value is empty the the expansion result will be empty.
42272 The third argument should be the recipient domain of the message when
42273 it arrived at this system.
42274 All arguments are expanded before use.
42275
42276 The result of the expansion is the replacement envelope-from (return path)
42277 to be used.
42278 .endlist
42279
42280 .cindex SRS decoding
42281 To decode an address use this expansion condition:
42282 .vlist
42283 .vitem &*inbound_srs&~{*&<&'local&~part'&>&*}{*&<&'secret'&>&*}*&
42284 The first argument should be the recipient local part as it was received.
42285 The second argument is the site secret.
42286 Both arguments are expanded before use.
42287
42288 If the messages is not for an SRS-encoded recipient the condition will
42289 return false.
42290 If it is, the condition will return true and the variable
42291 &$srs_recipient$& will be set to the decoded (original) value.
42292
42293 If the second argument is empty then the condition returns true if
42294 the first argument is in valid SRS formet, else false.
42295 The variable &$srs_recipient$& is not set for this case.
42296 .endlist
42297
42298 Example usage:
42299 .code
42300   #macro
42301   SRS_SECRET = <pick something unique for your site for this. Use on all MXs.>
42302
42303   #routers
42304
42305   outbound:
42306     driver =    dnslookup
42307     # if outbound, and forwarding has been done, use an alternate transport
42308     domains =   ! +my_domains
42309     transport = ${if eq {$local_part@$domain} \
42310                         {$original_local_part@$original_domain} \
42311                      {remote_smtp} {remote_forwarded_smtp}}
42312
42313   inbound_srs:
42314     driver =    redirect
42315     senders =   :
42316     domains =   +my_domains
42317     # detect inbound bounces which are SRS'd, and decode them
42318     condition = ${if inbound_srs {$local_part} {SRS_SECRET}}
42319     data =      $srs_recipient
42320
42321   inbound_srs_failure:
42322     driver =    redirect
42323     senders =   :
42324     domains =   +my_domains
42325     # detect inbound bounces which look SRS'd but are invalid
42326     condition = ${if inbound_srs {$local_part} {}}
42327     allow_fail
42328     data =      :fail: Invalid SRS recipient address
42329
42330   #... further routers here
42331
42332
42333   # transport; should look like the non-forward outbound
42334   # one, plus the max_rcpt and return_path options
42335   remote_forwarded_smtp:
42336     driver =              smtp
42337     # single-recipient so that $original_domain is valid
42338     max_rcpt =            1
42339     # modify the envelope from, for mails that we forward
42340     return_path =         ${srs_encode {SRS_SECRET} {$return_path} {$original_domain}}
42341 .endd
42342
42343
42344
42345
42346
42347 .section DMARC SECDMARC
42348 .cindex DMARC verification
42349
42350 DMARC combines feedback from SPF, DKIM, and header From: in order
42351 to attempt to provide better indicators of the authenticity of an
42352 email.  This document does not explain the fundamentals; you
42353 should read and understand how it works by visiting the website at
42354 &url(http://www.dmarc.org/).
42355
42356 If Exim is built with DMARC support,
42357 the libopendmarc library is used.
42358
42359 For building Exim yourself, obtain the library from
42360 &url(http://sourceforge.net/projects/opendmarc/)
42361 to obtain a copy, or find it in your favorite package
42362 repository.  You will need to attend to the local/Makefile feature
42363 SUPPORT_DMARC and the associated LDFLAGS addition.
42364 This description assumes
42365 that headers will be in /usr/local/include, and that the libraries
42366 are in /usr/local/lib.
42367
42368 .subsection Configuration SSECDMARCCONFIG
42369 .cindex DMARC configuration
42370
42371 There are three main-configuration options:
42372 .cindex DMARC "configuration options"
42373
42374 The &%dmarc_tld_file%& option
42375 .oindex &%dmarc_tld_file%&
42376 defines the location of a text file of valid
42377 top level domains the opendmarc library uses
42378 during domain parsing. Maintained by Mozilla,
42379 the most current version can be downloaded
42380 from a link at &url(https://publicsuffix.org/list/public_suffix_list.dat).
42381 See also the util/renew-opendmarc-tlds.sh script.
42382 The default for the option is unset.
42383 If not set, DMARC processing is disabled.
42384
42385
42386 The &%dmarc_history_file%& option, if set
42387 .oindex &%dmarc_history_file%&
42388 defines the location of a file to log results
42389 of dmarc verification on inbound emails. The
42390 contents are importable by the opendmarc tools
42391 which will manage the data, send out DMARC
42392 reports, and expire the data. Make sure the
42393 directory of this file is writable by the user
42394 exim runs as.
42395 The default is unset.
42396
42397 The &%dmarc_forensic_sender%& option
42398 .oindex &%dmarc_forensic_sender%&
42399 defines an alternate email address to use when sending a
42400 forensic report detailing alignment failures
42401 if a sender domain's dmarc record specifies it
42402 and you have configured Exim to send them.
42403 If set, this is expanded and used for the
42404 From: header line; the address is extracted
42405 from it and used for the envelope from.
42406 If not set (the default), the From: header is expanded from
42407 the dsn_from option, and <> is used for the
42408 envelope from.
42409
42410 .subsection Controls SSECDMARCCONTROLS
42411 .cindex DMARC controls
42412
42413 By default, the DMARC processing will run for any remote,
42414 non-authenticated user.  It makes sense to only verify DMARC
42415 status of messages coming from remote, untrusted sources.  You can
42416 use standard conditions such as hosts, senders, etc, to decide that
42417 DMARC verification should *not* be performed for them and disable
42418 DMARC with an ACL control modifier:
42419 .code
42420   control = dmarc_disable_verify
42421 .endd
42422 A DMARC record can also specify a "forensic address", which gives
42423 exim an email address to submit reports about failed alignment.
42424 Exim does not do this by default because in certain conditions it
42425 results in unintended information leakage (what lists a user might
42426 be subscribed to, etc).  You must configure exim to submit forensic
42427 reports to the owner of the domain.  If the DMARC record contains a
42428 forensic address and you specify the control statement below, then
42429 exim will send these forensic emails.  It is also advised that you
42430 configure a &%dmarc_forensic_sender%& because the default sender address
42431 construction might be inadequate.
42432 .code
42433   control = dmarc_enable_forensic
42434 .endd
42435 (AGAIN: You can choose not to send these forensic reports by simply
42436 not putting the dmarc_enable_forensic control line at any point in
42437 your exim config.  If you don't tell exim to send them, it will not
42438 send them.)
42439
42440 There are no options to either control.  Both must appear before
42441 the DATA acl.
42442
42443 .subsection ACL SSECDMARCACL
42444 .cindex DMARC "ACL condition"
42445
42446 DMARC checks can be run on incoming SMTP  messages by using the
42447 &"dmarc_status"& ACL condition in the DATA ACL.  You are required to
42448 call the &"spf"& condition first in the ACLs, then the &"dmarc_status"&
42449 condition.  Putting this condition in the ACLs is required in order
42450 for a DMARC check to actually occur.  All of the variables are set
42451 up before the DATA ACL, but there is no actual DMARC check that
42452 occurs until a &"dmarc_status"& condition is encountered in the ACLs.
42453
42454 The &"dmarc_status"& condition takes a list of strings on its
42455 right-hand side.  These strings describe recommended action based
42456 on the DMARC check.  To understand what the policy recommendations
42457 mean, refer to the DMARC website above.  Valid strings are:
42458 .itable none 0 0 2 20* left 80* left
42459 .irow &'accept'&        "The DMARC check passed and the library recommends accepting the email"
42460 .irow &'reject'&        "The DMARC check failed and the library recommends rejecting the email"
42461 .irow &'quarantine'&    "The DMARC check failed and the library recommends keeping it for further inspection"
42462 .irow &'none'&          "The DMARC check passed and the library recommends no specific action, neutral"
42463 .irow &'norecord'&      "No policy section in the DMARC record for this RFC5322.From field"
42464 .irow &'nofrom'&        "Unable to determine the domain of the sender"
42465 .irow &'temperror'&     "Library error or dns error"
42466 .irow &'off'&           "The DMARC check was disabled for this email"
42467 .endtable
42468 You can prefix each string with an exclamation mark to invert its
42469 meaning, for example "!accept" will match all results but
42470 "accept".  The string list is evaluated left-to-right in a
42471 short-circuit fashion.  When a string matches the outcome of the
42472 DMARC check, the condition succeeds.  If none of the listed
42473 strings matches the outcome of the DMARC check, the condition
42474 fails.
42475
42476 Of course, you can also use any other lookup method that Exim
42477 supports, including LDAP, Postgres, MySQL, etc, as long as the
42478 result is a list of colon-separated strings.
42479
42480 Performing the check sets up information used by the
42481 &%authresults%& expansion item.
42482
42483 Several expansion variables are set before the DATA ACL is
42484 processed, and you can use them in this ACL.  The following
42485 expansion variables are available:
42486
42487 .vlist
42488 .vitem &$dmarc_status$&
42489 .vindex &$dmarc_status$&
42490 .cindex DMARC result
42491 A one word status indicating what the DMARC library
42492 thinks of the email.  It is a combination of the results of
42493 DMARC record lookup and the SPF/DKIM/DMARC processing results
42494 (if a DMARC record was found).  The actual policy declared
42495 in the DMARC record is in a separate expansion variable.
42496
42497 .vitem &$dmarc_status_text$&
42498 .vindex &$dmarc_status_text$&
42499 Slightly longer, human readable status.
42500
42501 .vitem &$dmarc_used_domain$&
42502 .vindex &$dmarc_used_domain$&
42503 The domain which DMARC used to look up the DMARC policy record.
42504
42505 .vitem &$dmarc_domain_policy$&
42506 .vindex &$dmarc_domain_policy$&
42507 The policy declared in the DMARC record.  Valid values
42508 are "none", "reject" and "quarantine".  It is blank when there
42509 is any error, including no DMARC record.
42510 .endlist
42511
42512 .subsection Logging SSECDMARCLOGGING
42513 .cindex DMARC logging
42514
42515 By default, Exim's DMARC configuration is intended to be
42516 non-intrusive and conservative.  To facilitate this, Exim will not
42517 create any type of logging files without explicit configuration by
42518 you, the admin.  Nor will Exim send out any emails/reports about
42519 DMARC issues without explicit configuration by you, the admin (other
42520 than typical bounce messages that may come about due to ACL
42521 processing or failure delivery issues).
42522
42523 In order to log statistics suitable to be imported by the opendmarc
42524 tools, you need to:
42525 .ilist
42526 Configure the global option &%dmarc_history_file%&
42527 .next
42528 Configure cron jobs to call the appropriate opendmarc history
42529 import scripts and truncating the dmarc_history_file
42530 .endlist
42531
42532 In order to send forensic reports, you need to:
42533 .ilist
42534 Configure the global option &%dmarc_forensic_sender%&
42535 .next
42536 Configure, somewhere before the DATA ACL, the control option to
42537 enable sending DMARC forensic reports
42538 .endlist
42539
42540 .subsection Example SSECDMARCEXAMPLE
42541 .cindex DMARC example
42542
42543 Example usage:
42544 .code
42545 (RCPT ACL)
42546   warn    domains        = +local_domains
42547           hosts          = +local_hosts
42548           control        = dmarc_disable_verify
42549
42550   warn    !domains       = +screwed_up_dmarc_records
42551           control        = dmarc_enable_forensic
42552
42553   warn    condition      = (lookup if destined to mailing list)
42554           set acl_m_mailing_list = 1
42555
42556 (DATA ACL)
42557   warn    dmarc_status   = accept : none : off
42558           !authenticated = *
42559           log_message    = DMARC DEBUG: $dmarc_status $dmarc_used_domain
42560
42561   warn    dmarc_status   = !accept
42562           !authenticated = *
42563           log_message    = DMARC DEBUG: '$dmarc_status' for $dmarc_used_domain
42564
42565   warn    dmarc_status   = quarantine
42566           !authenticated = *
42567           set $acl_m_quarantine = 1
42568           # Do something in a transport with this flag variable
42569
42570   deny    condition      = ${if eq{$dmarc_domain_policy}{reject}}
42571           condition      = ${if eq{$acl_m_mailing_list}{1}}
42572           message        = Messages from $dmarc_used_domain break mailing lists
42573
42574   deny    dmarc_status   = reject
42575           !authenticated = *
42576           message        = Message from $dmarc_used_domain failed sender's DMARC policy, REJECT
42577
42578   warn    add_header     = :at_start:${authresults {$primary_hostname}}
42579 .endd
42580
42581
42582
42583
42584
42585 . ////////////////////////////////////////////////////////////////////////////
42586 . ////////////////////////////////////////////////////////////////////////////
42587
42588 .chapter "Proxies" "CHAPproxies" &&&
42589          "Proxy support"
42590 .cindex "proxy support"
42591 .cindex "proxy" "access via"
42592
42593 A proxy is an intermediate system through which communication is passed.
42594 Proxies may provide a security, availability or load-distribution function.
42595
42596
42597 .section "Inbound proxies" SECTproxyInbound
42598 .cindex proxy inbound
42599 .cindex proxy "server side"
42600 .cindex proxy "Proxy protocol"
42601 .cindex "Proxy protocol" proxy
42602
42603 Exim has support for receiving inbound SMTP connections via a proxy
42604 that uses &"Proxy Protocol"& to speak to it.
42605 To include this support, include &"SUPPORT_PROXY=yes"&
42606 in Local/Makefile.
42607
42608 It was built on the HAProxy specification, found at
42609 &url(https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt).
42610
42611 The purpose of this facility is so that an application load balancer,
42612 such as HAProxy, can sit in front of several Exim servers
42613 to distribute load.
42614 Exim uses the local protocol communication with the proxy to obtain
42615 the remote SMTP system IP address and port information.
42616 There is no logging if a host passes or
42617 fails Proxy Protocol negotiation, but it can easily be determined and
42618 recorded in an ACL (example is below).
42619
42620 Use of a proxy is enabled by setting the &%hosts_proxy%&
42621 main configuration option to a hostlist; connections from these
42622 hosts will use Proxy Protocol.
42623 Exim supports both version 1 and version 2 of the Proxy Protocol and
42624 automatically determines which version is in use.
42625
42626 The Proxy Protocol header is the first data received on a TCP connection
42627 and is inserted before any TLS-on-connect handshake from the client; Exim
42628 negotiates TLS between Exim-as-server and the remote client, not between
42629 Exim and the proxy server. The Proxy Protocol header must be received
42630 within &%proxy_protocol_timeout%&, which defaults to 3s.
42631
42632 The following expansion variables are usable
42633 (&"internal"& and &"external"& here refer to the interfaces
42634 of the proxy):
42635 .itable none 0 0 2 30* left 70* left
42636 .irow $proxy_external_address   "IP of host being proxied or IP of remote interface of proxy"
42637 .irow $proxy_external_port      "Port of host being proxied or Port on remote interface of proxy"
42638 .irow $proxy_local_address      "IP of proxy server inbound or IP of local interface of proxy"
42639 .irow $proxy_local_port         "Port of proxy server inbound or Port on local interface of proxy"
42640 .irow $proxy_session            "boolean: SMTP connection via proxy"
42641 .endtable
42642 If &$proxy_session$& is set but &$proxy_external_address$& is empty
42643 there was a protocol error.
42644 The variables &$sender_host_address$& and &$sender_host_port$&
42645 will have values for the actual client system, not the proxy.
42646
42647 Since the real connections are all coming from the proxy, and the
42648 per host connection tracking is done before Proxy Protocol is
42649 evaluated, &%smtp_accept_max_per_host%& must be set high enough to
42650 handle all of the parallel volume you expect per inbound proxy.
42651 With the option set so high, you lose the ability
42652 to protect your server from many connections from one IP.
42653 In order to prevent your server from overload, you
42654 need to add a per connection ratelimit to your connect ACL.
42655 A possible solution is:
42656 .display
42657   # Set max number of connections per host
42658   LIMIT   = 5
42659   # Or do some kind of IP lookup in a flat file or database
42660   # LIMIT = ${lookup{$sender_host_address}iplsearch{/etc/exim/proxy_limits}}
42661
42662   defer   ratelimit      = LIMIT / 5s / per_conn / strict
42663           message        = Too many connections from this IP right now
42664 .endd
42665
42666
42667
42668 .section "Outbound proxies" SECTproxySOCKS
42669 .cindex proxy outbound
42670 .cindex proxy "client side"
42671 .cindex proxy SOCKS
42672 .cindex SOCKS proxy
42673 Exim has support for sending outbound SMTP via a proxy
42674 using a protocol called SOCKS5 (defined by RFC1928).
42675 The support can be optionally included by defining SUPPORT_SOCKS=yes in
42676 Local/Makefile.
42677
42678 Use of a proxy is enabled by setting the &%socks_proxy%& option
42679 on an smtp transport.
42680 The option value is expanded and should then be a list
42681 (colon-separated by default) of proxy specifiers.
42682 Each proxy specifier is a list
42683 (space-separated by default) where the initial element
42684 is an IP address and any subsequent elements are options.
42685
42686 Options are a string <name>=<value>.
42687 The list of options is in the following table:
42688 .itable none 0 0 2 10* left 90* left
42689 .irow &'auth'&  "authentication method"
42690 .irow &'name'&  "authentication username"
42691 .irow &'pass'&  "authentication password"
42692 .irow &'port'&  "tcp port"
42693 .irow &'tmo'&   "connection timeout"
42694 .irow &'pri'&   "priority"
42695 .irow &'weight'& "selection bias"
42696 .endtable
42697
42698 More details on each of these options follows:
42699
42700 .ilist
42701 .cindex authentication "to proxy"
42702 .cindex proxy authentication
42703 &%auth%&: Either &"none"& (default) or &"name"&.
42704 Using &"name"& selects username/password authentication per RFC 1929
42705 for access to the proxy.
42706 Default is &"none"&.
42707 .next
42708 &%name%&: sets the username for the &"name"& authentication method.
42709 Default is empty.
42710 .next
42711 &%pass%&: sets the password for the &"name"& authentication method.
42712 Default is empty.
42713 .next
42714 &%port%&: the TCP port number to use for the connection to the proxy.
42715 Default is 1080.
42716 .next
42717 &%tmo%&: sets a connection timeout in seconds for this proxy.
42718 Default is 5.
42719 .next
42720 &%pri%&: specifies a priority for the proxy within the list,
42721 higher values being tried first.
42722 The default priority is 1.
42723 .next
42724 &%weight%&: specifies a selection bias.
42725 Within a priority set servers are queried in a random fashion,
42726 weighted by this value.
42727 The default value for selection bias is 1.
42728 .endlist
42729
42730 Proxies from the list are tried according to their priority
42731 and weight settings until one responds.  The timeout for the
42732 overall connection applies to the set of proxied attempts.
42733
42734 .section Logging SECTproxyLog
42735 To log the (local) IP of a proxy in the incoming or delivery logline,
42736 add &"+proxy"& to the &%log_selector%& option.
42737 This will add a component tagged with &"PRX="& to the line.
42738
42739 . ////////////////////////////////////////////////////////////////////////////
42740 . ////////////////////////////////////////////////////////////////////////////
42741
42742 .chapter "Internationalisation" "CHAPi18n" &&&
42743          "Internationalisation""
42744 .cindex internationalisation "email address"
42745 .cindex EAI
42746 .cindex i18n
42747 .cindex utf8 "mail name handling"
42748
42749 Exim has support for Internationalised mail names.
42750 To include this it must be built with SUPPORT_I18N and the libidn library.
42751 Standards supported are RFCs 2060, 5890, 6530 and 6533.
42752
42753 If Exim is built with SUPPORT_I18N_2008 (in addition to SUPPORT_I18N, not
42754 instead of it) then IDNA2008 is supported; this adds an extra library
42755 requirement, upon libidn2.
42756
42757 .section "MTA operations" SECTi18nMTA
42758 .cindex SMTPUTF8 "ESMTP option"
42759 .cindex "ESMTP extensions" SMTPUTF8
42760 The main configuration option &%smtputf8_advertise_hosts%& specifies
42761 a host list.  If this matches the sending host and
42762 accept_8bitmime is true (the default) then the ESMTP option
42763 SMTPUTF8 will be advertised.
42764
42765 If the sender specifies the SMTPUTF8 option on a MAIL command
42766 international handling for the message is enabled and
42767 the expansion variable &$message_smtputf8$& will have value TRUE.
42768
42769 The option &%allow_utf8_domains%& is set to true for this
42770 message. All DNS lookups are converted to a-label form
42771 whatever the setting of &%allow_utf8_domains%&
42772 when Exim is built with SUPPORT_I18N.
42773
42774 Both localparts and domain are maintained as the original
42775 UTF-8 form internally; any comparison or regular-expression use will
42776 require appropriate care.  Filenames created, eg. by
42777 the appendfile transport, will have UTF-8 names.
42778
42779 HELO names sent by the smtp transport will have any UTF-8
42780 components expanded to a-label form,
42781 and any certificate name checks will be done using the a-label
42782 form of the name.
42783
42784 .cindex log protocol
42785 .cindex SMTPUTF8 logging
42786 .cindex i18n logging
42787 Log lines and Received-by: header lines will acquire a "utf8"
42788 prefix on the protocol element, eg. utf8esmtp.
42789
42790 The following expansion operators can be used:
42791 .code
42792 ${utf8_domain_to_alabel:str}
42793 ${utf8_domain_from_alabel:str}
42794 ${utf8_localpart_to_alabel:str}
42795 ${utf8_localpart_from_alabel:str}
42796 .endd
42797
42798 .cindex utf8 "address downconversion"
42799 .cindex i18n "utf8 address downconversion"
42800 The RCPT ACL
42801 may use the following modifier:
42802 .display
42803 control = utf8_downconvert
42804 control = utf8_downconvert/<value>
42805 .endd
42806 This sets a flag requiring that envelope addresses are converted to
42807 a-label form before smtp delivery.
42808 This is usually for use in a Message Submission Agent context,
42809 but could be used for any message.
42810
42811 If a value is appended it may be:
42812 .itable none 0 0 2 5* right 95* left
42813 .irow &`1`&     "mandatory downconversion"
42814 .irow &`0`&     "no downconversion"
42815 .irow &`-1`&    "if SMTPUTF8 not supported by destination host"
42816 .endtable
42817 If no value is given, 1 is used.
42818
42819 If mua_wrapper is set, the utf8_downconvert control
42820 is initially set to -1.
42821
42822 The smtp transport has an option &%utf8_downconvert%&.
42823 If set it must expand to one of the three values described above,
42824 or an empty string.
42825 If non-empty it overrides value previously set
42826 (due to mua_wrapper or by an ACL control).
42827
42828
42829 There is no explicit support for VRFY and EXPN.
42830 Configurations supporting these should inspect
42831 &$smtp_command_argument$& for an SMTPUTF8 argument.
42832
42833 There is no support for LMTP on Unix sockets.
42834 Using the "lmtp" protocol option on an smtp transport,
42835 for LMTP over TCP, should work as expected.
42836
42837 There is no support for DSN unitext handling,
42838 and no provision for converting logging from or to UTF-8.
42839
42840
42841
42842 .section "MDA operations" SECTi18nMDA
42843 To aid in constructing names suitable for IMAP folders
42844 the following expansion operator can be used:
42845 .code
42846 ${imapfolder {<string>} {<sep>} {<specials>}}
42847 .endd
42848
42849 The string is converted from the charset specified by
42850 the "headers charset" command (in a filter file)
42851 or &%headers_charset%& main configuration option (otherwise),
42852 to the
42853 modified UTF-7 encoding specified by RFC 2060,
42854 with the following exception: All occurrences of <sep>
42855 (which has to be a single character)
42856 are replaced with periods ("."), and all periods and slashes that are not
42857 <sep> and are not in the <specials> string are BASE64 encoded.
42858
42859 The third argument can be omitted, defaulting to an empty string.
42860 The second argument can be omitted, defaulting to "/".
42861
42862 This is the encoding used by Courier for Maildir names on disk, and followed
42863 by many other IMAP servers.
42864
42865 Examples:
42866 .display
42867 &`${imapfolder {Foo/Bar}}       `& yields &`Foo.Bar`&
42868 &`${imapfolder {Foo/Bar}{.}{/}} `& yields &`Foo&&AC8-Bar`&
42869 &`${imapfolder {Räksmörgås}}    `& yields &`R&&AOQ-ksm&&APY-rg&&AOU-s`&
42870 .endd
42871
42872 Note that the source charset setting is vital, and also that characters
42873 must be representable in UTF-16.
42874
42875
42876 . ////////////////////////////////////////////////////////////////////////////
42877 . ////////////////////////////////////////////////////////////////////////////
42878
42879 .chapter "Events" "CHAPevents" &&&
42880          "Events"
42881 .cindex events
42882
42883 The events mechanism in Exim can be used to intercept processing at a number
42884 of points.  It was originally invented to give a way to do customised logging
42885 actions (for example, to a database) but can also be used to modify some
42886 processing actions.
42887
42888 Most installations will never need to use Events.
42889 The support can be left out of a build by defining DISABLE_EVENT=yes
42890 in &_Local/Makefile_&.
42891
42892 There are two major classes of events: main and transport.
42893 The main configuration option &%event_action%& controls reception events;
42894 a transport option &%event_action%& controls delivery events.
42895
42896 Both options are a string which is expanded when the event fires.
42897 An example might look like:
42898 .cindex logging custom
42899 .code
42900 event_action = ${if eq {msg:delivery}{$event_name} \
42901 {${lookup pgsql {SELECT * FROM record_Delivery( \
42902     '${quote_pgsql:$sender_address_domain}',\
42903     '${quote_pgsql:${lc:$sender_address_local_part}}', \
42904     '${quote_pgsql:$domain}', \
42905     '${quote_pgsql:${lc:$local_part}}', \
42906     '${quote_pgsql:$host_address}', \
42907     '${quote_pgsql:${lc:$host}}', \
42908     '${quote_pgsql:$message_exim_id}')}} \
42909 } {}}
42910 .endd
42911
42912 Events have names which correspond to the point in process at which they fire.
42913 The name is placed in the variable &$event_name$& and the event action
42914 expansion must check this, as it will be called for every possible event type.
42915
42916 The current list of events is:
42917 .itable all 0 0 4 25* left 10* center 15* center 50* left
42918 .row auth:fail              after    both       "per driver per authentication attempt"
42919 .row dane:fail              after    transport  "per connection"
42920 .row msg:complete           after    main       "per message"
42921 .row msg:defer              after    transport  "per message per delivery try"
42922 .row msg:delivery           after    transport  "per recipient"
42923 .row msg:rcpt:host:defer    after    transport  "per recipient per host"
42924 .row msg:rcpt:defer         after    transport  "per recipient"
42925 .row msg:host:defer         after    transport  "per host per delivery try; host errors"
42926 .row msg:fail:delivery      after    transport  "per recipient"
42927 .row msg:fail:internal      after    main       "per recipient"
42928 .row tcp:connect            before   transport  "per connection"
42929 .row tcp:close              after    transport  "per connection"
42930 .row tls:cert               before   both       "per certificate in verification chain"
42931 .row tls:fail:connect       after    main       "per connection"
42932 .row smtp:connect           after    transport  "per connection"
42933 .row smtp:ehlo              after    transport  "per connection"
42934 .endtable
42935 New event types may be added in future.
42936
42937 The event name is a colon-separated list, defining the type of
42938 event in a tree of possibilities.  It may be used as a list
42939 or just matched on as a whole.  There will be no spaces in the name.
42940
42941 The second column in the table above describes whether the event fires
42942 before or after the action is associates with.  Those which fire before
42943 can be used to affect that action (more on this below).
42944
42945 The third column in the table above says what section of the configuration
42946 should define the event action.
42947
42948 An additional variable, &$event_data$&, is filled with information varying
42949 with the event type:
42950 .itable all 0 0 2 20* left 80* left
42951 .row auth:fail            "smtp response"
42952 .row dane:fail            "failure reason"
42953 .row msg:defer            "error string"
42954 .row msg:delivery         "smtp confirmation message"
42955 .row msg:fail:internal    "failure reason"
42956 .row msg:fail:delivery    "smtp error message"
42957 .row msg:host:defer       "error string"
42958 .row msg:rcpt:host:defer  "error string"
42959 .row msg:rcpt:defer       "error string"
42960 .row tls:cert             "verification chain depth"
42961 .row tls:fail:connect     "error string"
42962 .row smtp:connect         "smtp banner"
42963 .row smtp:ehlo            "smtp ehlo response"
42964 .endtable
42965
42966 The :defer events populate one extra variable: &$event_defer_errno$&.
42967
42968 For complex operations an ACL expansion can be used in &%event_action%&,
42969 however due to the multiple contexts that Exim operates in during
42970 the course of its processing:
42971 .ilist
42972 variables set in transport events will not be visible outside that
42973 transport call
42974 .next
42975 acl_m variables in a server context are lost on a new connection,
42976 and after smtp helo/ehlo/mail/starttls/rset commands
42977 .endlist
42978 Using an ACL expansion with the logwrite modifier can be
42979 a useful way of writing to the main log.
42980
42981 The expansion of the event_action option should normally
42982 return an empty string.  Should it return anything else the
42983 following will be forced:
42984 .itable all 0 0 2 20* left 80* left
42985 .row auth:fail        "log information to write"
42986 .row tcp:connect      "do not connect"
42987 .row tls:cert         "refuse verification"
42988 .row smtp:connect     "close connection"
42989 .endtable
42990 All other message types ignore the result string, and
42991 no other use is made of it.
42992
42993 For a tcp:connect event, if the connection is being made to a proxy
42994 then the &$host_address$& and &$host_port$& variables
42995 will be that of the proxy and not the target system.
42996
42997 For tls:cert events, if GnuTLS is in use this will trigger only per
42998 chain element received on the connection.
42999 For OpenSSL it will trigger for every chain element including those
43000 loaded locally.
43001
43002 . ////////////////////////////////////////////////////////////////////////////
43003 . ////////////////////////////////////////////////////////////////////////////
43004
43005 .chapter "Adding new drivers or lookup types" "CHID13" &&&
43006          "Adding drivers or lookups"
43007 .cindex "adding drivers"
43008 .cindex "new drivers, adding"
43009 .cindex "drivers" "adding new"
43010 The following actions have to be taken in order to add a new router, transport,
43011 authenticator, or lookup type to Exim:
43012
43013 .olist
43014 Choose a name for the driver or lookup type that does not conflict with any
43015 existing name; I will use &"newdriver"& in what follows.
43016 .next
43017 Add to &_src/EDITME_& the line:
43018 .display
43019 <&'type'&>&`_NEWDRIVER=yes`&
43020 .endd
43021 where <&'type'&> is ROUTER, TRANSPORT, AUTH, or LOOKUP. If the
43022 code is not to be included in the binary by default, comment this line out. You
43023 should also add any relevant comments about the driver or lookup type.
43024 .next
43025 Add to &_src/config.h.defaults_& the line:
43026 .code
43027 #define <type>_NEWDRIVER
43028 .endd
43029 .next
43030 Edit &_src/drtables.c_&, adding conditional code to pull in the private header
43031 and create a table entry as is done for all the other drivers and lookup types.
43032 .next
43033 Edit &_scripts/lookups-Makefile_& if this is a new lookup; there is a for-loop
43034 near the bottom, ranging the &`name_mod`& variable over a list of all lookups.
43035 Add your &`NEWDRIVER`& to that list.
43036 As long as the dynamic module would be named &_newdriver.so_&, you can use the
43037 simple form that most lookups have.
43038 .next
43039 Edit &_Makefile_& in the appropriate sub-directory (&_src/routers_&,
43040 &_src/transports_&, &_src/auths_&, or &_src/lookups_&); add a line for the new
43041 driver or lookup type and add it to the definition of OBJ.
43042 .next
43043 Edit &_OS/Makefile-Base_& adding a &_.o_& file for the predefined-macros, to the
43044 definition of OBJ_MACRO.  Add a set of line to do the compile also.
43045 .next
43046 Create &_newdriver.h_& and &_newdriver.c_& in the appropriate sub-directory of
43047 &_src_&.
43048 .next
43049 Edit &_scripts/MakeLinks_& and add commands to link the &_.h_& and &_.c_& files
43050 as for other drivers and lookups.
43051 .endlist
43052
43053 Then all you need to do is write the code! A good way to start is to make a
43054 proforma by copying an existing module of the same type, globally changing all
43055 occurrences of the name, and cutting out most of the code. Note that any
43056 options you create must be listed in alphabetical order, because the tables are
43057 searched using a binary chop procedure.
43058
43059 There is a &_README_& file in each of the sub-directories of &_src_& describing
43060 the interface that is expected.
43061
43062
43063
43064
43065 . ////////////////////////////////////////////////////////////////////////////
43066 . ////////////////////////////////////////////////////////////////////////////
43067
43068 . /////////////////////////////////////////////////////////////////////////////
43069 . These lines are processing instructions for the Simple DocBook Processor that
43070 . Philip Hazel has developed as a less cumbersome way of making PostScript and
43071 . PDFs than using xmlto and fop. They will be ignored by all other XML
43072 . processors.
43073 . /////////////////////////////////////////////////////////////////////////////
43074
43075 .literal xml
43076 <?sdop
43077   format="newpage"
43078   foot_right_recto="&chaptertitle;"
43079   foot_right_verso="&chaptertitle;"
43080 ?>
43081 .literal off
43082
43083 .makeindex "Options index"   "option"
43084 .makeindex "Variables index" "variable"
43085 .makeindex "Concept index"   "concept"
43086
43087
43088 . /////////////////////////////////////////////////////////////////////////////
43089 . /////////////////////////////////////////////////////////////////////////////