Update documentation and associated files for 4.64.
[exim.git] / doc / doc-docbook / spec.xfpt
1 . $Cambridge: exim/doc/doc-docbook/spec.xfpt,v 1.13 2006/12/19 12:28:35 ph10 Exp $
2 .
3 . /////////////////////////////////////////////////////////////////////////////
4 . This is the primary source of the Exim Manual. It is an xfpt document that is
5 . converted into DocBook XML for subsequent conversion into printing and online
6 . formats. The markup used herein is "standard" xfpt markup, with some extras.
7 . The markup is summarized in a file called Markup.txt.
8 . /////////////////////////////////////////////////////////////////////////////
9
10 .include stdflags
11 .include stdmacs
12 .docbook
13 .book
14
15 . /////////////////////////////////////////////////////////////////////////////
16 . These definitions set some parameters and save some typing. Remember that
17 . the <bookinfo> element must also be updated for each new edition.
18 . /////////////////////////////////////////////////////////////////////////////
19
20 .set ACL "access control lists (ACLs)"
21 .set previousversion "4.63"
22 .set version "4.64"
23
24
25 . /////////////////////////////////////////////////////////////////////////////
26 . These lines are processing instructions for the Simple DocBook Processor that
27 . Philip Hazel is developing in odd moments as a less cumbersome way of making
28 . PostScript and PDFs than using xmlto and fop. They will be ignored by all
29 . other XML processors.
30 . /////////////////////////////////////////////////////////////////////////////
31
32 .literal xml
33 <?sdop
34   toc_chapter_blanks="yes,yes"
35   table_warn_soft_overflow="no"
36 ?>
37 .literal off
38
39
40 . /////////////////////////////////////////////////////////////////////////////
41 . Additional xfpt markup used by this document, over and above the default
42 . provided in the xfpt library.
43 . /////////////////////////////////////////////////////////////////////////////
44
45 . --- Override the &$ flag to automatically insert a $ with the variable name
46
47 .flag &$  $&   "<varname>$"  "</varname>"
48
49 . --- Short flags for daggers in option headings. They will always be inside
50 . --- an italic string, but we want the daggers to be roman.
51
52 .flag &!!      "</emphasis>&dagger;<emphasis>"
53 .flag &!?      "</emphasis>&Dagger;<emphasis>"
54
55 . --- A macro for an Exim option definition heading, generating a one-line
56 . --- table with four columns.
57
58 .macro option
59 .oindex "&%$1%&"
60 .itable all 0 0 4 8* left 5* center 5* center 6* right
61 .row "&%$1%&" "Use: &'$2'&" "Type: &'$3'&" "Default: &'$4'&"
62 .endtable
63 .endmacro
64
65 . --- A macro for the common 2-column tables. The width of the first column
66 . --- is suitable for the many tables at the start of the main options chapter;
67 . --- the small number of other 2-column tables override it.
68
69 .macro table2 196pt 254pt
70 .itable none 0 0 2 $1 left $2 left
71 .endmacro
72
73 . --- Macros for the concept and option index entries. For a "range" style of
74 . --- entry, use .scindex for the start and .ecindex for the end. The first
75 . --- argument of .scindex and the only argument of .ecindex must be the ID
76 . --- that ties them together.
77
78 .macro cindex
79 &<indexterm role="concept">&
80 &<primary>&$1&</primary>&
81 .arg 2
82 &<secondary>&$2&</secondary>&
83 .endarg
84 &</indexterm>&
85 .endmacro
86
87 .macro scindex
88 &<indexterm role="concept" id="$1" class="startofrange">&
89 &<primary>&$2&</primary>&
90 .arg 3
91 &<secondary>&$3&</secondary>&
92 .endarg
93 &</indexterm>&
94 .endmacro
95
96 .macro ecindex
97 &<indexterm role="concept" startref="$1" class="endofrange"/>&
98 .endmacro
99
100 .macro oindex
101 &<indexterm role="option">&
102 &<primary>&$1&</primary>&
103 .arg 2
104 &<secondary>&$2&</secondary>&
105 .endarg
106 &</indexterm>&
107 .endmacro
108
109 .macro index
110 .echo "** Don't use .index; use .cindex or .oindex"
111 .endmacro
112 . ////////////////////////////////////////////////////////////////////////////
113
114
115 . ////////////////////////////////////////////////////////////////////////////
116 . The <bookinfo> element is removed from the XML before processing for Ascii
117 . output formats.
118 . ////////////////////////////////////////////////////////////////////////////
119
120 .literal xml
121 <bookinfo>
122 <title>Specification of the Exim Mail Transfer Agent</title>
123 <titleabbrev>The Exim MTA</titleabbrev>
124 <date>11 December 2006</date>
125 <author><firstname>Philip</firstname><surname>Hazel</surname></author>
126 <authorinitials>PH</authorinitials>
127 <affiliation><orgname>University of Cambridge Computing Service</orgname></affiliation>
128 <address>New Museums Site, Pembroke Street, Cambridge CB2 3QH, England</address>
129 <revhistory><revision>
130   <revnumber>4.64</revnumber>
131   <date>11 December 2006</date>
132   <authorinitials>PH</authorinitials>
133 </revision></revhistory>
134 <copyright><year>2006</year><holder>University of Cambridge</holder></copyright>
135 </bookinfo>
136 .literal off
137
138
139 . /////////////////////////////////////////////////////////////////////////////
140 . This chunk of literal XML implements index entries of the form "x, see y" and
141 . "x, see also y". However, the DocBook DTD doesn't allow <indexterm> entries
142 . at the top level, so we have to put the .chapter directive first.
143 . /////////////////////////////////////////////////////////////////////////////
144
145 .chapter "Introduction"
146 .literal xml
147
148 <indexterm role="concept">
149   <primary>$1, $2, etc.</primary>
150   <see><emphasis>numerical variables</emphasis></see>
151 </indexterm>
152 <indexterm role="concept">
153   <primary>address</primary>
154   <secondary>rewriting</secondary>
155   <see><emphasis>rewriting</emphasis></see>
156 </indexterm>
157 <indexterm role="concept">
158   <primary>Bounce Address Tag Validation</primary>
159   <see><emphasis>BATV</emphasis></see>
160 </indexterm>
161 <indexterm role="concept">
162   <primary>Client SMTP Authorization</primary>
163   <see><emphasis>CSA</emphasis></see>
164 </indexterm>
165 <indexterm role="concept">
166   <primary>CR character</primary>
167   <see><emphasis>carriage return</emphasis></see>
168 </indexterm>
169 <indexterm role="concept">
170   <primary>CRL</primary>
171   <see><emphasis>certificate revocation list</emphasis></see>
172 </indexterm>
173 <indexterm role="concept">
174   <primary>delivery</primary>
175   <secondary>failure report</secondary>
176   <see><emphasis>bounce message</emphasis></see>
177 </indexterm>
178 <indexterm role="concept">
179   <primary>dialup</primary>
180   <see><emphasis>intermittently connected hosts</emphasis></see>
181 </indexterm>
182 <indexterm role="concept">
183   <primary>exiscan</primary>
184   <see><emphasis>content scanning</emphasis></see>
185 </indexterm>
186 <indexterm role="concept">
187   <primary>failover</primary>
188   <see><emphasis>fallback</emphasis></see>
189 </indexterm>
190 <indexterm role="concept">
191   <primary>fallover</primary>
192   <see><emphasis>fallback</emphasis></see>
193 </indexterm>
194 <indexterm role="concept">
195   <primary>filter</primary>
196   <secondary>Sieve</secondary>
197   <see><emphasis>Sieve filter</emphasis></see>
198 </indexterm>
199 <indexterm role="concept">
200   <primary>ident</primary>
201   <see><emphasis>RFC 1413</emphasis></see>
202 </indexterm>
203 <indexterm role="concept">
204   <primary>LF character</primary>
205   <see><emphasis>linefeed</emphasis></see>
206 </indexterm>
207 <indexterm role="concept">
208   <primary>maximum</primary>
209   <see><emphasis>limit</emphasis></see>
210 </indexterm>
211 <indexterm role="concept">
212   <primary>monitor</primary>
213   <see><emphasis>Exim monitor</emphasis></see>
214 </indexterm>
215 <indexterm role="concept">
216   <primary>no_<emphasis>xxx</emphasis></primary>
217   <see>entry for xxx</see>
218 </indexterm>
219 <indexterm role="concept">
220   <primary>NUL</primary>
221   <see><emphasis>binary zero</emphasis></see>
222 </indexterm>
223 <indexterm role="concept">
224   <primary>passwd file</primary>
225   <see><emphasis>/etc/passwd</emphasis></see>
226 </indexterm>
227 <indexterm role="concept">
228   <primary>process id</primary>
229   <see><emphasis>pid</emphasis></see>
230 </indexterm>
231 <indexterm role="concept">
232   <primary>RBL</primary>
233   <see><emphasis>DNS list</emphasis></see>
234 </indexterm>
235 <indexterm role="concept">
236   <primary>redirection</primary>
237   <see><emphasis>address redirection</emphasis></see>
238 </indexterm>
239 <indexterm role="concept">
240   <primary>return path</primary>
241   <seealso><emphasis>envelope sender</emphasis></seealso>
242 </indexterm>
243 <indexterm role="concept">
244   <primary>scanning</primary>
245   <see><emphasis>content scanning</emphasis></see>
246 </indexterm>
247 <indexterm role="concept">
248   <primary>SSL</primary>
249   <see><emphasis>TLS</emphasis></see>
250 </indexterm>
251 <indexterm role="concept">
252   <primary>string</primary>
253   <secondary>expansion</secondary>
254   <see><emphasis>expansion</emphasis></see>
255 </indexterm>
256 <indexterm role="concept">
257   <primary>top bit</primary>
258   <see><emphasis>8-bit characters</emphasis></see>
259 </indexterm>
260 <indexterm role="concept">
261   <primary>variables</primary>
262   <see><emphasis>expansion, variables</emphasis></see>
263 </indexterm>
264 <indexterm role="concept">
265   <primary>zero, binary</primary>
266   <see><emphasis>binary zero</emphasis></see>
267 </indexterm>
268
269 .literal off
270
271
272 . /////////////////////////////////////////////////////////////////////////////
273 . This is the real start of the first chapter. See the comment above as to why
274 . we can't have the .chapter line here.
275 . chapter "Introduction"
276 . /////////////////////////////////////////////////////////////////////////////
277
278 Exim is a mail transfer agent (MTA) for hosts that are running Unix or
279 Unix-like operating systems. It was designed on the assumption that it would be
280 run on hosts that are permanently connected to the Internet. However, it can be
281 used on intermittently connected hosts with suitable configuration adjustments.
282
283 Configuration files currently exist for the following operating systems: AIX,
284 BSD/OS (aka BSDI), Darwin (Mac OS X), DGUX, Dragonfly, FreeBSD, GNU/Hurd,
285 GNU/Linux, HI-OSF (Hitachi), HI-UX, HP-UX, IRIX, MIPS RISCOS, NetBSD, OpenBSD,
286 OpenUNIX, QNX, SCO, SCO SVR4.2 (aka UNIX-SV), Solaris (aka SunOS5), SunOS4,
287 Tru64-Unix (formerly Digital UNIX, formerly DEC-OSF1), Ultrix, and Unixware.
288 Some of these operating systems are no longer current and cannot easily be
289 tested, so the configuration files may no longer work in practice.
290
291 There are also configuration files for compiling Exim in the Cygwin environment
292 that can be installed on systems running Windows. However, this document does
293 not contain any information about running Exim in the Cygwin environment.
294
295 The terms and conditions for the use and distribution of Exim are contained in
296 the file &_NOTICE_&. Exim is distributed under the terms of the GNU General
297 Public Licence, a copy of which may be found in the file &_LICENCE_&.
298
299 The use, supply or promotion of Exim for the purpose of sending bulk,
300 unsolicited electronic mail is incompatible with the basic aims of the program,
301 which revolve around the free provision of a service that enhances the quality
302 of personal communications. The author of Exim regards indiscriminate
303 mass-mailing as an antisocial, irresponsible abuse of the Internet.
304
305 Exim owes a great deal to Smail 3 and its author, Ron Karr. Without the
306 experience of running and working on the Smail 3 code, I could never have
307 contemplated starting to write a new MTA. Many of the ideas and user interfaces
308 were originally taken from Smail 3, though the actual code of Exim is entirely
309 new, and has developed far beyond the initial concept.
310
311 Many people, both in Cambridge and around the world, have contributed to the
312 development and the testing of Exim, and to porting it to various operating
313 systems. I am grateful to them all. The distribution now contains a file called
314 &_ACKNOWLEDGMENTS_&, in which I have started recording the names of
315 contributors.
316
317
318 .section "Exim documentation"
319 .new
320 .cindex "documentation"
321 This edition of the Exim specification applies to version &version; of Exim.
322 Substantive changes from the &previousversion; edition are marked in some
323 renditions of the document; this paragraph is so marked if the rendition is
324 capable of showing a change indicator.
325 .wen
326
327 This document is very much a reference manual; it is not a tutorial. The reader
328 is expected to have some familiarity with the SMTP mail transfer protocol and
329 with general Unix system administration. Although there are some discussions
330 and examples in places, the information is mostly organized in a way that makes
331 it easy to look up, rather than in a natural order for sequential reading.
332 Furthermore, the manual aims to cover every aspect of Exim in detail, including
333 a number of rarely-used, special-purpose features that are unlikely to be of
334 very wide interest.
335
336 .cindex "books about Exim"
337 An &"easier"& discussion of Exim which provides more in-depth explanatory,
338 introductory, and tutorial material can be found in a book entitled &'The Exim
339 SMTP Mail Server'&, published by UIT Cambridge
340 (&url(http://www.uit.co.uk/exim-book/)).
341
342 This book also contains a chapter that gives a general introduction to SMTP and
343 Internet mail. Inevitably, however, the book is unlikely to be fully up-to-date
344 with the latest release of Exim. (Note that the earlier book about Exim,
345 published by O'Reilly, covers Exim 3, and many things have changed in Exim 4.)
346
347 .cindex "Debian" "information sources"
348 If you are using a Debian distribution of Exim, you will find information about
349 Debian-specific features in the file
350 .display
351 &_/usr/share/doc/exim4-base/README.Debian_&
352 .endd
353 The command &(man update-exim.conf)& is another source of Debian-specific
354 information.
355
356 .cindex "&_doc/NewStuff_&"
357 .cindex "&_doc/ChangeLog_&"
358 .cindex "change log"
359 As the program develops, there may be features in newer versions that have not
360 yet made it into this document, which is updated only when the most significant
361 digit of the fractional part of the version number changes. Specifications of
362 new features that are not yet in this manual are placed in the file
363 &_doc/NewStuff_& in the Exim distribution.
364
365 Some features may be classified as &"experimental"&. These may change
366 incompatibly while they are developing, or even be withdrawn. For this reason,
367 they are not documented in this manual. Information about experimental features
368 can be found in the file &_doc/experimental.txt_&.
369
370 All changes to the program (whether new features, bug fixes, or other kinds of
371 change) are noted briefly in the file called &_doc/ChangeLog_&.
372
373 .cindex "&_doc/spec.txt_&"
374 This specification itself is available as an ASCII file in &_doc/spec.txt_& so
375 that it can easily be searched with a text editor. Other files in the &_doc_&
376 directory are:
377
378 .table2 100pt
379 .row &_OptionLists.txt_&     "list of all options in alphabetical order"
380 .row &_dbm.discuss.txt_&     "discussion about DBM libraries"
381 .row &_exim.8_&              "a man page of Exim's command line options"
382 .row &_experimental.txt_&    "documentation of experimental features"
383 .row &_filter.txt_&          "specification of the filter language"
384 .row &_pcrepattern.txt_&     "specification of PCRE regular expressions"
385 .row &_pcretest.txt_&        "specification of the PCRE testing program"
386 .row &_Exim3.upgrade_&       "upgrade notes from release 2 to release 3"
387 .row &_Exim4.upgrade_&       "upgrade notes from release 3 to release 4"
388 .endtable
389
390 The main specification and the specification of the filtering language are also
391 available in other formats (HTML, PostScript, PDF, and Texinfo). Section
392 &<<SECTavail>>& below tells you how to get hold of these.
393
394
395
396 .section "FTP and web sites"
397 .cindex "web site"
398 .cindex "FTP site"
399 The primary site for Exim source distributions is currently the University of
400 Cambridge's FTP site, whose contents are described in &'Where to find the Exim
401 distribution'& below. In addition, there is a web site and an FTP site at
402 &%exim.org%&. These are now also hosted at the University of Cambridge. The
403 &%exim.org%& site was previously hosted for a number of years by Energis
404 Squared, formerly Planet Online Ltd, whose support I gratefully acknowledge.
405
406 .cindex "wiki"
407 .cindex "FAQ"
408 As well as Exim distribution tar files, the Exim web site contains a number of
409 differently formatted versions of the documentation, including the FAQ in both
410 text and HTML formats. The HTML version comes with a keyword-in-context index.
411 A recent addition to the online information is the Exim wiki
412 (&url(http://www.exim.org/eximwiki/)). We hope that this will make it easier
413 for Exim users to contribute examples, tips, and know-how for the benefit of
414 others.
415
416
417
418 .section "Mailing lists"
419 .cindex "mailing lists" "for Exim users"
420 The following are the three main Exim mailing lists:
421
422 .table2 140pt
423 .row &'exim-users@exim.org'&      "general discussion list"
424 .row &'exim-dev@exim.org'&        "discussion of bugs, enhancements, etc."
425 .row &'exim-announce@exim.org'&   "moderated, low volume announcements list"
426 .endtable
427
428 You can subscribe to these lists, change your existing subscriptions, and view
429 or search the archives via the mailing lists link on the Exim home page.
430 .cindex "Debian" "mailing list for"
431 If you are using a Debian distribution of Exim, you may wish to subscribe to
432 the Debian-specific mailing list &'pkg-exim4-users@lists.alioth.debian.org'&
433 via this web page:
434 .display
435 &url(http://lists.alioth.debian.org/mailman/listinfo/pkg-exim4-users)
436 .endd
437 Please ask Debian-specific questions on this list and not on the general Exim
438 lists.
439
440 .section "Exim training"
441 .cindex "training courses"
442 From time to time (approximately annually at the time of writing), training
443 courses are run by the author of Exim in Cambridge, UK. Details of any
444 forthcoming courses can be found on the web site
445 &url(http://www-tus.csx.cam.ac.uk/courses/exim/).
446
447
448 .section "Bug reports"
449 .cindex "bug reports"
450 .cindex "reporting bugs"
451 Reports of obvious bugs should be emailed to &'bugs@exim.org'&. However, if you
452 are unsure whether some behaviour is a bug or not, the best thing to do is to
453 post a message to the &'exim-dev'& mailing list and have it discussed.
454
455
456
457 .section "Where to find the Exim distribution" "SECTavail"
458 .cindex "FTP site"
459 .cindex "distribution" "ftp site"
460 The master ftp site for the Exim distribution is
461 .display
462 &*ftp://ftp.csx.cam.ac.uk/pub/software/email/exim*&
463 .endd
464 This is mirrored by
465 .display
466 &*ftp://ftp.exim.org/pub/exim*&
467 .endd
468 The file references that follow are relative to the &_exim_& directories at
469 these sites. There are now quite a number of independent mirror sites around
470 the world. Those that I know about are listed in the file called &_Mirrors_&.
471
472 Within the &_exim_& directory there are subdirectories called &_exim3_& (for
473 previous Exim 3 distributions), &_exim4_& (for the latest Exim 4
474 distributions), and &_Testing_& for testing versions. In the &_exim4_&
475 subdirectory, the current release can always be found in files called
476 .display
477 &_exim-n.nn.tar.gz_&
478 &_exim-n.nn.tar.bz2_&
479 .endd
480 where &'n.nn'& is the highest such version number in the directory. The two
481 files contain identical data; the only difference is the type of compression.
482 The &_.bz2_& file is usually a lot smaller than the &_.gz_& file.
483
484 .cindex "distribution" "signing details"
485 .cindex "distribution" "public key"
486 .cindex "public key for signed distribution"
487 The distributions are currently signed with Philip Hazel's GPG key. The
488 corresponding public key is available from a number of keyservers, and there is
489 also a copy in the file &_Public-Key_&. The signatures for the tar bundles are
490 in:
491 .display
492 &_exim-n.nn.tar.gz.sig_&
493 &_exim-n.nn.tar.bz2.sig_&
494 .endd
495 For each released version, the log of changes is made separately available in a
496 separate file in the directory &_ChangeLogs_& so that it is possible to
497 find out what has changed without having to download the entire distribution.
498
499 .cindex "documentation" "available formats"
500 The main distribution contains ASCII versions of this specification and other
501 documentation; other formats of the documents are available in separate files
502 inside the &_exim4_& directory of the FTP site:
503 .display
504 &_exim-html-n.nn.tar.gz_&
505 &_exim-pdf-n.nn.tar.gz_&
506 &_exim-postscript-n.nn.tar.gz_&
507 &_exim-texinfo-n.nn.tar.gz_&
508 .endd
509 These tar files contain only the &_doc_& directory, not the complete
510 distribution, and are also available in &_.bz2_& as well as &_.gz_& forms.
511 .cindex "FAQ"
512 The FAQ is available for downloading in two different formats in these files:
513 .display
514 &_exim4/FAQ.txt.gz_&
515 &_exim4/FAQ.html.tar.gz_&
516 .endd
517 The first of these is a single ASCII file that can be searched with a text
518 editor. The second is a directory of HTML files, normally accessed by starting
519 at &_index.html_&. The HTML version of the FAQ (which is also included in the
520 HTML documentation tarbundle) includes a keyword-in-context index, which is
521 often the most convenient way of finding your way around.
522
523
524 .section "Wish list"
525 .cindex "wish list"
526 A wish list is maintained, containing ideas for new features that have been
527 submitted. This used to be a single file that from time to time was exported to
528 the ftp site into the file &_exim4/WishList_&. However, it has now been
529 imported into Exim's Bugzilla data.
530
531
532 .section "Contributed material"
533 .cindex "contributed material"
534 At the ftp site, there is a directory called &_Contrib_& that contains
535 miscellaneous files contributed to the Exim community by Exim users. There is
536 also a collection of contributed configuration examples in
537 &_exim4/config.samples.tar.gz_&. These samples are referenced from the FAQ.
538
539
540
541 .section "Limitations"
542 .ilist
543 .cindex "limitations of Exim"
544 .cindex "bang paths" "not handled by Exim"
545 Exim is designed for use as an Internet MTA, and therefore handles addresses in
546 RFC 2822 domain format only. It cannot handle UUCP &"bang paths"&, though
547 simple two-component bang paths can be converted by a straightforward rewriting
548 configuration. This restriction does not prevent Exim from being interfaced to
549 UUCP as a transport mechanism, provided that domain addresses are used.
550 .next
551 .cindex "domainless addresses"
552 .cindex "address" "without domain"
553 Exim insists that every address it handles has a domain attached. For incoming
554 local messages, domainless addresses are automatically qualified with a
555 configured domain value. Configuration options specify from which remote
556 systems unqualified addresses are acceptable. These are then qualified on
557 arrival.
558 .next
559 .cindex "transport" "external"
560 .cindex "external transports"
561 The only external transport mechanisms that are currently implemented are SMTP
562 and LMTP over a TCP/IP network (including support for IPv6). However, a pipe
563 transport is available, and there are facilities for writing messages to files
564 and pipes, optionally in &'batched SMTP'& format; these facilities can be used
565 to send messages to other transport mechanisms such as UUCP, provided they can
566 handle domain-style addresses. Batched SMTP input is also catered for.
567 .next
568 Exim is not designed for storing mail for dial-in hosts. When the volumes of
569 such mail are large, it is better to get the messages &"delivered"& into files
570 (that is, off Exim's queue) and subsequently passed on to the dial-in hosts by
571 other means.
572 .next
573 Although Exim does have basic facilities for scanning incoming messages, these
574 are not comprehensive enough to do full virus or spam scanning. Such operations
575 are best carried out using additional specialized software packages. If you
576 compile Exim with the content-scanning extension, straightforward interfaces to
577 a number of common scanners are provided.
578 .endlist
579
580
581 .section "Run time configuration"
582 Exim's run time configuration is held in a single text file that is divided
583 into a number of sections. The entries in this file consist of keywords and
584 values, in the style of Smail 3 configuration files. A default configuration
585 file which is suitable for simple online installations is provided in the
586 distribution, and is described in chapter &<<CHAPdefconfil>>& below.
587
588
589 .section "Calling interface"
590 .cindex "Sendmail compatibility" "command line interface"
591 Like many MTAs, Exim has adopted the Sendmail command line interface so that it
592 can be a straight replacement for &_/usr/lib/sendmail_& or
593 &_/usr/sbin/sendmail_& when sending mail, but you do not need to know anything
594 about Sendmail in order to run Exim. For actions other than sending messages,
595 Sendmail-compatible options also exist, but those that produce output (for
596 example, &%-bp%&, which lists the messages on the queue) do so in Exim's own
597 format. There are also some additional options that are compatible with Smail
598 3, and some further options that are new to Exim. Chapter &<<CHAPcommandline>>&
599 documents all Exim's command line options. This information is automatically
600 made into the man page that forms part of the Exim distribution.
601
602 Control of messages on the queue can be done via certain privileged command
603 line options. There is also an optional monitor program called &'eximon'&,
604 which displays current information in an X window, and which contains a menu
605 interface to Exim's command line administration options.
606
607
608
609 .section "Terminology"
610 .cindex "terminology definitions"
611 .cindex "body of message" "definition of"
612 The &'body'& of a message is the actual data that the sender wants to transmit.
613 It is the last part of a message, and is separated from the &'header'& (see
614 below) by a blank line.
615
616 .cindex "bounce message" "definition of"
617 When a message cannot be delivered, it is normally returned to the sender in a
618 delivery failure message or a &"non-delivery report"& (NDR). The term
619 &'bounce'& is commonly used for this action, and the error reports are often
620 called &'bounce messages'&. This is a convenient shorthand for &"delivery
621 failure error report"&. Such messages have an empty sender address in the
622 message's &'envelope'& (see below) to ensure that they cannot themselves give
623 rise to further bounce messages.
624
625 The term &'default'& appears frequently in this manual. It is used to qualify a
626 value which is used in the absence of any setting in the configuration. It may
627 also qualify an action which is taken unless a configuration setting specifies
628 otherwise.
629
630 The term &'defer'& is used when the delivery of a message to a specific
631 destination cannot immediately take place for some reason (a remote host may be
632 down, or a user's local mailbox may be full). Such deliveries are &'deferred'&
633 until a later time.
634
635 The word &'domain'& is sometimes used to mean all but the first component of a
636 host's name. It is &'not'& used in that sense here, where it normally refers to
637 the part of an email address following the @ sign.
638
639 .cindex "envelope" "definition of"
640 .cindex "sender" "definition of"
641 A message in transit has an associated &'envelope'&, as well as a header and a
642 body. The envelope contains a sender address (to which bounce messages should
643 be delivered), and any number of recipient addresses. References to the
644 sender or the recipients of a message usually mean the addresses in the
645 envelope. An MTA uses these addresses for delivery, and for returning bounce
646 messages, not the addresses that appear in the header lines.
647
648 .cindex "message header" "definition of"
649 .cindex "header section" "definition of"
650 The &'header'& of a message is the first part of a message's text, consisting
651 of a number of lines, each of which has a name such as &'From:'&, &'To:'&,
652 &'Subject:'&, etc. Long header lines can be split over several text lines by
653 indenting the continuations. The header is separated from the body by a blank
654 line.
655
656 .cindex "local part" "definition of"
657 .cindex "domain" "definition of"
658 The term &'local part'&, which is taken from RFC 2822, is used to refer to that
659 part of an email address that precedes the @ sign. The part that follows the
660 @ sign is called the &'domain'& or &'mail domain'&.
661
662 .cindex "local delivery" "definition of"
663 .cindex "remote delivery" "definition of"
664 The terms &'local delivery'& and &'remote delivery'& are used to distinguish
665 delivery to a file or a pipe on the local host from delivery by SMTP over
666 TCP/IP to another host. As far as Exim is concerned, all hosts other than the
667 host it is running on are &'remote'&.
668
669 .cindex "return path" "definition of"
670 &'Return path'& is another name that is used for the sender address in a
671 message's envelope.
672
673 .cindex "queue" "definition of"
674 The term &'queue'& is used to refer to the set of messages awaiting delivery,
675 because this term is in widespread use in the context of MTAs. However, in
676 Exim's case the reality is more like a pool than a queue, because there is
677 normally no ordering of waiting messages.
678
679 .cindex "queue runner" "definition of"
680 The term &'queue runner'& is used to describe a process that scans the queue
681 and attempts to deliver those messages whose retry times have come. This term
682 is used by other MTAs, and also relates to the command &%runq%&, but in Exim
683 the waiting messages are normally processed in an unpredictable order.
684
685 .cindex "spool directory" "definition of"
686 The term &'spool directory'& is used for a directory in which Exim keeps the
687 messages on its queue &-- that is, those that it is in the process of
688 delivering. This should not be confused with the directory in which local
689 mailboxes are stored, which is called a &"spool directory"& by some people. In
690 the Exim documentation, &"spool"& is always used in the first sense.
691
692
693
694
695
696
697 . ////////////////////////////////////////////////////////////////////////////
698 . ////////////////////////////////////////////////////////////////////////////
699
700 .chapter "Incorporated code"
701 .cindex "incorporated code"
702 .cindex "regular expressions" "library"
703 .cindex "PCRE"
704 A number of pieces of external code are included in the Exim distribution.
705
706 .ilist
707 Regular expressions are supported in the main Exim program and in the Exim
708 monitor using the freely-distributable PCRE library, copyright &copy;
709 University of Cambridge. The source is distributed in the directory
710 &_src/pcre_&. However, this is a cut-down version of PCRE. If you want to use
711 the PCRE library in other programs, you should obtain and install the full
712 version from &url(ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre).
713 .next
714 .cindex "cdb" "acknowledgement"
715 Support for the cdb (Constant DataBase) lookup method is provided by code
716 contributed by Nigel Metheringham of (at the time he contributed it) Planet
717 Online Ltd. The implementation is completely contained within the code of Exim.
718 It does not link against an external cdb library. The code contains the
719 following statements:
720
721 .blockquote
722 Copyright &copy; 1998 Nigel Metheringham, Planet Online Ltd
723
724 This program is free software; you can redistribute it and/or modify it under
725 the terms of the GNU General Public License as published by the Free Software
726 Foundation; either version 2 of the License, or (at your option) any later
727 version.
728
729 This code implements Dan Bernstein's Constant DataBase (cdb) spec. Information,
730 the spec and sample code for cdb can be obtained from
731 &url(http://www.pobox.com/~djb/cdb.html). This implementation borrows some
732 code from Dan Bernstein's implementation (which has no license restrictions
733 applied to it).
734 .endblockquote
735 .next
736 .cindex "SPA authentication"
737 .cindex "Samba project"
738 .cindex "Microsoft Secure Password Authentication"
739 Client support for Microsoft's &'Secure Password Authentication'& is provided
740 by code contributed by Marc Prud'hommeaux. Server support was contributed by
741 Tom Kistner. This includes code taken from the Samba project, which is released
742 under the Gnu GPL.
743 .next
744 .cindex "Cyrus"
745 .cindex "&'pwcheck'& daemon"
746 .cindex "&'pwauthd'& daemon"
747 Support for calling the Cyrus &'pwcheck'& and &'saslauthd'& daemons is provided
748 by code taken from the Cyrus-SASL library and adapted by Alexander S.
749 Sabourenkov. The permission notice appears below, in accordance with the
750 conditions expressed therein.
751
752 .blockquote
753 Copyright &copy; 2001 Carnegie Mellon University.  All rights reserved.
754
755 Redistribution and use in source and binary forms, with or without
756 modification, are permitted provided that the following conditions
757 are met:
758
759 .olist
760 Redistributions of source code must retain the above copyright
761 notice, this list of conditions and the following disclaimer.
762 .next
763 Redistributions in binary form must reproduce the above copyright
764 notice, this list of conditions and the following disclaimer in
765 the documentation and/or other materials provided with the
766 distribution.
767 .next
768 The name &"Carnegie Mellon University"& must not be used to
769 endorse or promote products derived from this software without
770 prior written permission. For permission or any other legal
771 details, please contact
772 .display
773               Office of Technology Transfer
774               Carnegie Mellon University
775               5000 Forbes Avenue
776               Pittsburgh, PA  15213-3890
777               (412) 268-4387, fax: (412) 268-7395
778               tech-transfer@andrew.cmu.edu
779 .endd
780 .next
781 Redistributions of any form whatsoever must retain the following
782 acknowledgment:
783
784 &"This product includes software developed by Computing Services
785 at Carnegie Mellon University (&url(http://www.cmu.edu/computing/)."&
786
787 CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
788 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
789 AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
790 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
791 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
792 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
793 OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
794 .endlist
795 .endblockquote
796
797 .next
798 .cindex "Exim monitor" "acknowledgement"
799 .cindex "X-windows"
800 .cindex "Athena"
801 The Exim Monitor program, which is an X-Window application, includes
802 modified versions of the Athena StripChart and TextPop widgets.
803 This code is copyright by DEC and MIT, and their permission notice appears
804 below, in accordance with the conditions expressed therein.
805
806 .blockquote
807 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
808 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
809
810 All Rights Reserved
811
812 Permission to use, copy, modify, and distribute this software and its
813 documentation for any purpose and without fee is hereby granted,
814 provided that the above copyright notice appear in all copies and that
815 both that copyright notice and this permission notice appear in
816 supporting documentation, and that the names of Digital or MIT not be
817 used in advertising or publicity pertaining to distribution of the
818 software without specific, written prior permission.
819
820 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
821 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
822 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
823 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
824 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
825 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
826 SOFTWARE.
827 .endblockquote
828
829 .next
830 Many people have contributed code fragments, some large, some small, that were
831 not covered by any specific licence requirements. It is assumed that the
832 contributors are happy to see their code incoporated into Exim under the GPL.
833 .endlist
834
835
836
837
838
839 . ////////////////////////////////////////////////////////////////////////////
840 . ////////////////////////////////////////////////////////////////////////////
841
842 .chapter "How Exim receives and delivers mail" "" &&&
843          "Receiving and delivering mail"
844
845
846 .section "Overall philosophy"
847 .cindex "design philosophy"
848 Exim is designed to work efficiently on systems that are permanently connected
849 to the Internet and are handling a general mix of mail. In such circumstances,
850 most messages can be delivered immediately. Consequently, Exim does not
851 maintain independent queues of messages for specific domains or hosts, though
852 it does try to send several messages in a single SMTP connection after a host
853 has been down, and it also maintains per-host retry information.
854
855
856 .section "Policy control"
857 .cindex "policy control" "overview"
858 Policy controls are now an important feature of MTAs that are connected to the
859 Internet. Perhaps their most important job is to stop MTAs being abused as
860 &"open relays"& by misguided individuals who send out vast amounts of
861 unsolicited junk, and want to disguise its source. Exim provides flexible
862 facilities for specifying policy controls on incoming mail:
863
864 .ilist
865 .cindex "&ACL;" "introduction"
866 Exim 4 (unlike previous versions of Exim) implements policy controls on
867 incoming mail by means of &'Access Control Lists'& (ACLs). Each list is a
868 series of statements that may either grant or deny access. ACLs can be used at
869 several places in the SMTP dialogue while receiving a message from a remote
870 host. However, the most common places are after each RCPT command, and at the
871 very end of the message. The sysadmin can specify conditions for accepting or
872 rejecting individual recipients or the entire message, respectively, at these
873 two points (see chapter &<<CHAPACL>>&). Denial of access results in an SMTP
874 error code.
875 .next
876 An ACL is also available for locally generated, non-SMTP messages. In this
877 case, the only available actions are to accept or deny the entire message.
878 .next
879 When Exim is compiled with the content-scanning extension, facilities are
880 provided in the ACL mechanism for passing the message to external virus and/or
881 spam scanning software. The result of such a scan is passed back to the ACL,
882 which can then use it to decide what to do with the message.
883 .next
884 When a message has been received, either from a remote host or from the local
885 host, but before the final acknowledgement has been sent, a locally supplied C
886 function called &[local_scan()]& can be run to inspect the message and decide
887 whether to accept it or not (see chapter &<<CHAPlocalscan>>&). If the message
888 is accepted, the list of recipients can be modified by the function.
889 .next
890 Using the &[local_scan()]& mechanism is another way of calling external scanner
891 software. The &%SA-Exim%& add-on package works this way. It does not require
892 Exim to be compiled with the content-scanning extension.
893 .next
894 After a message has been accepted, a further checking mechanism is available in
895 the form of the &'system filter'& (see chapter &<<CHAPsystemfilter>>&). This
896 runs at the start of every delivery process.
897 .endlist
898
899
900
901 .section "User filters"
902 .cindex "filter" "introduction"
903 .cindex "Sieve filter"
904 In a conventional Exim configuration, users are able to run private filters by
905 setting up appropriate &_.forward_& files in their home directories. See
906 chapter &<<CHAPredirect>>& (about the &(redirect)& router) for the
907 configuration needed to support this, and the separate document entitled
908 &'Exim's interfaces to mail filtering'& for user details. Two different kinds
909 of filtering are available:
910
911 .ilist
912 Sieve filters are written in the standard filtering language that is defined
913 by RFC 3028.
914 .next
915 Exim filters are written in a syntax that is unique to Exim, but which is more
916 powerful than Sieve, which it pre-dates.
917 .endlist
918
919 User filters are run as part of the routing process, described below.
920
921
922
923 .section "Message identification" "SECTmessiden"
924 .cindex "message ids" "details of format"
925 .cindex "format" "of message id"
926 .cindex "id of message"
927 .cindex "base62"
928 .cindex "base36"
929 .cindex "Darwin"
930 .cindex "Cygwin"
931 Every message handled by Exim is given a &'message id'& which is sixteen
932 characters long. It is divided into three parts, separated by hyphens, for
933 example &`16VDhn-0001bo-D3`&. Each part is a sequence of letters and digits,
934 normally encoding numbers in base 62. However, in the Darwin operating
935 system (Mac OS X) and when Exim is compiled to run under Cygwin, base 36
936 (avoiding the use of lower case letters) is used instead, because the message
937 id is used to construct file names, and the names of files in those systems are
938 not always case-sensitive.
939
940 .cindex "pid (process id)" "re-use of"
941 The detail of the contents of the message id have changed as Exim has evolved.
942 Earlier versions relied on the operating system not re-using a process id (pid)
943 within one second. On modern operating systems, this assumption can no longer
944 be made, so the algorithm had to be changed. To retain backward compatibility,
945 the format of the message id was retained, which is why the following rules are
946 somewhat eccentric:
947
948 .ilist
949 The first six characters of the message id are the time at which the message
950 started to be received, to a granularity of one second. That is, this field
951 contains the number of seconds since the start of the epoch (the normal Unix
952 way of representing the date and time of day).
953 .next
954 After the first hyphen, the next six characters are the id of the process that
955 received the message.
956 .next
957 There are two different possibilities for the final two characters:
958 .olist
959 .cindex "&%localhost_number%&"
960 If &%localhost_number%& is not set, this value is the fractional part of the
961 time of reception, normally in units of 1/2000 of a second, but for systems
962 that must use base 36 instead of base 62 (because of case-insensitive file
963 systems), the units are 1/1000 of a second.
964 .next
965 If &%localhost_number%& is set, it is multiplied by 200 (100) and added to
966 the fractional part of the time, which in this case is in units of 1/200
967 (1/100) of a second.
968 .endlist
969 .endlist
970
971 After a message has been received, Exim waits for the clock to tick at the
972 appropriate resolution before proceeding, so that if another message is
973 received by the same process, or by another process with the same (re-used)
974 pid, it is guaranteed that the time will be different. In most cases, the clock
975 will already have ticked while the message was being received.
976
977
978 .section "Receiving mail"
979 .cindex "receiving mail"
980 .cindex "message" "reception"
981 The only way Exim can receive mail from another host is using SMTP over
982 TCP/IP, in which case the sender and recipient addresses are transferred using
983 SMTP commands. However, from a locally running process (such as a user's MUA),
984 there are several possibilities:
985
986 .ilist
987 If the process runs Exim with the &%-bm%& option, the message is read
988 non-interactively (usually via a pipe), with the recipients taken from the
989 command line, or from the body of the message if &%-t%& is also used.
990 .next
991 If the process runs Exim with the &%-bS%& option, the message is also read
992 non-interactively, but in this case the recipients are listed at the start of
993 the message in a series of SMTP RCPT commands, terminated by a DATA
994 command. This is so-called &"batch SMTP"& format,
995 but it isn't really SMTP. The SMTP commands are just another way of passing
996 envelope addresses in a non-interactive submission.
997 .next
998 If the process runs Exim with the &%-bs%& option, the message is read
999 interactively, using the SMTP protocol. A two-way pipe is normally used for
1000 passing data between the local process and the Exim process.
1001 This is &"real"& SMTP and is handled in the same way as SMTP over TCP/IP. For
1002 example, the ACLs for SMTP commands are used for this form of submission.
1003 .next
1004 A local process may also make a TCP/IP call to the host's loopback address
1005 (127.0.0.1) or any other of its IP addresses. When receiving messages, Exim
1006 does not treat the loopback address specially. It treats all such connections
1007 in the same way as connections from other hosts.
1008 .endlist
1009
1010
1011 .cindex "message sender" "constructed by Exim"
1012 .cindex "sender" "constructed by Exim"
1013 In the three cases that do not involve TCP/IP, the sender address is
1014 constructed from the login name of the user that called Exim and a default
1015 qualification domain (which can be set by the &%qualify_domain%& configuration
1016 option). For local or batch SMTP, a sender address that is passed using the
1017 SMTP MAIL command is ignored. However, the system administrator may allow
1018 certain users (&"trusted users"&) to specify a different sender address
1019 unconditionally, or all users to specify certain forms of different sender
1020 address. The &%-f%& option or the SMTP MAIL command is used to specify these
1021 different addresses. See section &<<SECTtrustedadmin>>& for details of trusted
1022 users, and the &%untrusted_set_sender%& option for a way of allowing untrusted
1023 users to change sender addresses.
1024
1025 Messages received by either of the non-interactive mechanisms are subject to
1026 checking by the non-SMTP ACL, if one is defined. Messages received using SMTP
1027 (either over TCP/IP, or interacting with a local process) can be checked by a
1028 number of ACLs that operate at different times during the SMTP session. Either
1029 individual recipients, or the entire message, can be rejected if local policy
1030 requirements are not met. The &[local_scan()]& function (see chapter
1031 &<<CHAPlocalscan>>&) is run for all incoming messages.
1032
1033 Exim can be configured not to start a delivery process when a message is
1034 received; this can be unconditional, or depend on the number of incoming SMTP
1035 connections or the system load. In these situations, new messages wait on the
1036 queue until a queue runner process picks them up. However, in standard
1037 configurations under normal conditions, delivery is started as soon as a
1038 message is received.
1039
1040
1041
1042
1043
1044 .section "Handling an incoming message"
1045 .cindex "spool directory" "files that hold a message"
1046 .cindex "file" "how a message is held"
1047 When Exim accepts a message, it writes two files in its spool directory. The
1048 first contains the envelope information, the current status of the message, and
1049 the header lines, and the second contains the body of the message. The names of
1050 the two spool files consist of the message id, followed by &`-H`& for the
1051 file containing the envelope and header, and &`-D`& for the data file.
1052
1053 .cindex "spool directory" "&_input_& sub-directory"
1054 By default all these message files are held in a single directory called
1055 &_input_& inside the general Exim spool directory. Some operating systems do
1056 not perform very well if the number of files in a directory gets large; to
1057 improve performance in such cases, the &%split_spool_directory%& option can be
1058 used. This causes Exim to split up the input files into 62 sub-directories
1059 whose names are single letters or digits. When this is done, the queue is
1060 processed one sub-directory at a time instead of all at once, which can improve
1061 overall performance even when there are not enough files in each directory to
1062 affect file system performance.
1063
1064 The envelope information consists of the address of the message's sender and
1065 the addresses of the recipients. This information is entirely separate from
1066 any addresses contained in the header lines. The status of the message includes
1067 a list of recipients who have already received the message. The format of the
1068 first spool file is described in chapter &<<CHAPspool>>&.
1069
1070 .cindex "rewriting" "addresses"
1071 Address rewriting that is specified in the rewrite section of the configuration
1072 (see chapter &<<CHAPrewrite>>&) is done once and for all on incoming addresses,
1073 both in the header lines and the envelope, at the time the message is accepted.
1074 If during the course of delivery additional addresses are generated (for
1075 example, via aliasing), these new addresses are rewritten as soon as they are
1076 generated. At the time a message is actually delivered (transported) further
1077 rewriting can take place; because this is a transport option, it can be
1078 different for different forms of delivery. It is also possible to specify the
1079 addition or removal of certain header lines at the time the message is
1080 delivered (see chapters &<<CHAProutergeneric>>& and
1081 &<<CHAPtransportgeneric>>&).
1082
1083
1084
1085 .section "Life of a message"
1086 .cindex "message" "life of"
1087 .cindex "message" "frozen"
1088 A message remains in the spool directory until it is completely delivered to
1089 its recipients or to an error address, or until it is deleted by an
1090 administrator or by the user who originally created it. In cases when delivery
1091 cannot proceed &-- for example, when a message can neither be delivered to its
1092 recipients nor returned to its sender, the message is marked &"frozen"& on the
1093 spool, and no more deliveries are attempted.
1094
1095 .cindex "frozen messages" "thawing"
1096 .cindex "message" "thawing frozen"
1097 An administrator can &"thaw"& such messages when the problem has been
1098 corrected, and can also freeze individual messages by hand if necessary. In
1099 addition, an administrator can force a delivery error, causing a bounce message
1100 to be sent.
1101
1102 .cindex "&%timeout_frozen_after%&"
1103 .cindex "&%ignore_bounce_errors_after%&"
1104 There are options called &%ignore_bounce_errors_after%& and
1105 &%timeout_frozen_after%&, which discard frozen messages after a certain time.
1106 The first applies only to frozen bounces, the second to any frozen messages.
1107
1108 .cindex "message" "log file for"
1109 .cindex "log" "file for each message"
1110 While Exim is working on a message, it writes information about each delivery
1111 attempt to its main log file. This includes successful, unsuccessful, and
1112 delayed deliveries for each recipient (see chapter &<<CHAPlog>>&). The log
1113 lines are also written to a separate &'message log'& file for each message.
1114 These logs are solely for the benefit of the administrator, and are normally
1115 deleted along with the spool files when processing of a message is complete.
1116 The use of individual message logs can be disabled by setting
1117 &%no_message_logs%&; this might give an improvement in performance on very busy
1118 systems.
1119
1120 .cindex "journal file"
1121 .cindex "file" "journal"
1122 All the information Exim itself needs to set up a delivery is kept in the first
1123 spool file, along with the header lines. When a successful delivery occurs, the
1124 address is immediately written at the end of a journal file, whose name is the
1125 message id followed by &`-J`&. At the end of a delivery run, if there are some
1126 addresses left to be tried again later, the first spool file (the &`-H`& file)
1127 is updated to indicate which these are, and the journal file is then deleted.
1128 Updating the spool file is done by writing a new file and renaming it, to
1129 minimize the possibility of data loss.
1130
1131 Should the system or the program crash after a successful delivery but before
1132 the spool file has been updated, the journal is left lying around. The next
1133 time Exim attempts to deliver the message, it reads the journal file and
1134 updates the spool file before proceeding. This minimizes the chances of double
1135 deliveries caused by crashes.
1136
1137
1138
1139 .section "Processing an address for delivery" "SECTprocaddress"
1140 .cindex "drivers" "definition of"
1141 .cindex "router" "definition of"
1142 .cindex "transport" "definition of"
1143 The main delivery processing elements of Exim are called &'routers'& and
1144 &'transports'&, and collectively these are known as &'drivers'&. Code for a
1145 number of them is provided in the source distribution, and compile-time options
1146 specify which ones are included in the binary. Run time options specify which
1147 ones are actually used for delivering messages.
1148
1149 .cindex "drivers" "instance definition"
1150 Each driver that is specified in the run time configuration is an &'instance'&
1151 of that particular driver type. Multiple instances are allowed; for example,
1152 you can set up several different &(smtp)& transports, each with different
1153 option values that might specify different ports or different timeouts. Each
1154 instance has its own identifying name. In what follows we will normally use the
1155 instance name when discussing one particular instance (that is, one specific
1156 configuration of the driver), and the generic driver name when discussing
1157 the driver's features in general.
1158
1159 A &'router'& is a driver that operates on an address, either determining how
1160 its delivery should happen, by assigning it to a specific transport, or
1161 converting the address into one or more new addresses (for example, via an
1162 alias file). A router may also explicitly choose to fail an address, causing it
1163 to be bounced.
1164
1165 A &'transport'& is a driver that transmits a copy of the message from Exim's
1166 spool to some destination. There are two kinds of transport: for a &'local'&
1167 transport, the destination is a file or a pipe on the local host, whereas for a
1168 &'remote'& transport the destination is some other host. A message is passed
1169 to a specific transport as a result of successful routing. If a message has
1170 several recipients, it may be passed to a number of different transports.
1171
1172 .cindex "preconditions" "definition of"
1173 An address is processed by passing it to each configured router instance in
1174 turn, subject to certain preconditions, until a router accepts the address or
1175 specifies that it should be bounced. We will describe this process in more
1176 detail shortly. First, as a simple example, we consider how each recipient
1177 address in a message is processed in a small configuration of three routers.
1178
1179 To make this a more concrete example, it is described in terms of some actual
1180 routers, but remember, this is only an example. You can configure Exim's
1181 routers in many different ways, and there may be any number of routers in a
1182 configuration.
1183
1184 The first router that is specified in a configuration is often one that handles
1185 addresses in domains that are not recognized specially by the local host. These
1186 are typically addresses for arbitrary domains on the Internet. A precondition
1187 is set up which looks for the special domains known to the host (for example,
1188 its own domain name), and the router is run for addresses that do &'not'&
1189 match. Typically, this is a router that looks up domains in the DNS in order to
1190 find the hosts to which this address routes. If it succeeds, the address is
1191 assigned to a suitable SMTP transport; if it does not succeed, the router is
1192 configured to fail the address.
1193
1194 The second router is reached only when the domain is recognized as one that
1195 &"belongs"& to the local host. This router does redirection &-- also known as
1196 aliasing and forwarding. When it generates one or more new addresses from the
1197 original, each of them is routed independently from the start. Otherwise, the
1198 router may cause an address to fail, or it may simply decline to handle the
1199 address, in which case the address is passed to the next router.
1200
1201 The final router in many configurations is one that checks to see if the
1202 address belongs to a local mailbox. The precondition may involve a check to
1203 see if the local part is the name of a login account, or it may look up the
1204 local part in a file or a database. If its preconditions are not met, or if
1205 the router declines, we have reached the end of the routers. When this happens,
1206 the address is bounced.
1207
1208
1209
1210 .section "Processing an address for verification"
1211 .cindex "router" "for verification"
1212 .cindex "verifying address" "overview"
1213 As well as being used to decide how to deliver to an address, Exim's routers
1214 are also used for &'address verification'&. Verification can be requested as
1215 one of the checks to be performed in an ACL for incoming messages, on both
1216 sender and recipient addresses, and it can be tested using the &%-bv%& and
1217 &%-bvs%& command line options.
1218
1219 When an address is being verified, the routers are run in &"verify mode"&. This
1220 does not affect the way the routers work, but it is a state that can be
1221 detected. By this means, a router can be skipped or made to behave differently
1222 when verifying. A common example is a configuration in which the first router
1223 sends all messages to a message-scanning program, unless they have been
1224 previously scanned. Thus, the first router accepts all addresses without any
1225 checking, making it useless for verifying. Normally, the &%no_verify%& option
1226 would be set for such a router, causing it to be skipped in verify mode.
1227
1228
1229
1230
1231 .section "Running an individual router" "SECTrunindrou"
1232 .cindex "router" "running details"
1233 .cindex "preconditions" "checking"
1234 .cindex "router" "result of running"
1235 As explained in the example above, a number of preconditions are checked before
1236 running a router. If any are not met, the router is skipped, and the address is
1237 passed to the next router. When all the preconditions on a router &'are'& met,
1238 the router is run. What happens next depends on the outcome, which is one of
1239 the following:
1240
1241 .ilist
1242 &'accept'&: The router accepts the address, and either assigns it to a
1243 transport, or generates one or more &"child"& addresses. Processing the
1244 original address ceases,
1245 .cindex "&%unseen%& option"
1246 unless the &%unseen%& option is set on the router. This option
1247 can be used to set up multiple deliveries with different routing (for example,
1248 for keeping archive copies of messages). When &%unseen%& is set, the address is
1249 passed to the next router. Normally, however, an &'accept'& return marks the
1250 end of routing.
1251
1252 Any child addresses generated by the router are processed independently,
1253 starting with the first router by default. It is possible to change this by
1254 setting the &%redirect_router%& option to specify which router to start at for
1255 child addresses. Unlike &%pass_router%& (see below) the router specified by
1256 &%redirect_router%& may be anywhere in the router configuration.
1257 .next
1258 &'pass'&: The router recognizes the address, but cannot handle it itself. It
1259 requests that the address be passed to another router. By default the address
1260 is passed to the next router, but this can be changed by setting the
1261 &%pass_router%& option. However, (unlike &%redirect_router%&) the named router
1262 must be below the current router (to avoid loops).
1263 .next
1264 &'decline'&: The router declines to accept the address because it does not
1265 recognize it at all. By default, the address is passed to the next router, but
1266 this can be prevented by setting the &%no_more%& option. When &%no_more%& is
1267 set, all the remaining routers are skipped. In effect, &%no_more%& converts
1268 &'decline'& into &'fail'&.
1269 .next
1270 &'fail'&: The router determines that the address should fail, and queues it for
1271 the generation of a bounce message. There is no further processing of the
1272 original address unless &%unseen%& is set on the router.
1273 .next
1274 &'defer'&: The router cannot handle the address at the present time. (A
1275 database may be offline, or a DNS lookup may have timed out.) No further
1276 processing of the address happens in this delivery attempt. It is tried again
1277 next time the message is considered for delivery.
1278 .next
1279 &'error'&: There is some error in the router (for example, a syntax error in
1280 its configuration). The action is as for defer.
1281 .endlist
1282
1283 If an address reaches the end of the routers without having been accepted by
1284 any of them, it is bounced as unrouteable. The default error message in this
1285 situation is &"unrouteable address"&, but you can set your own message by
1286 making use of the &%cannot_route_message%& option. This can be set for any
1287 router; the value from the last router that &"saw"& the address is used.
1288
1289 Sometimes while routing you want to fail a delivery when some conditions are
1290 met but others are not, instead of passing the address on for further routing.
1291 You can do this by having a second router that explicitly fails the delivery
1292 when the relevant conditions are met. The &(redirect)& router has a &"fail"&
1293 facility for this purpose.
1294
1295
1296 .section "Duplicate addresses"
1297 .cindex "case of local parts"
1298 .cindex "address duplicate" "discarding"
1299 .cindex "duplicate addresses"
1300 Once routing is complete, Exim scans the addresses that are assigned to local
1301 and remote transports, and discards any duplicates that it finds. During this
1302 check, local parts are treated as case-sensitive. This happens only when
1303 actually delivering a message; when testing routers with &%-bt%&, all the
1304 routed addresses are shown.
1305
1306
1307
1308 .section "Router preconditions" "SECTrouprecon"
1309 .cindex "router preconditions" "order of processing"
1310 .cindex "preconditions" "order of processing"
1311 The preconditions that are tested for each router are listed below, in the
1312 order in which they are tested. The individual configuration options are
1313 described in more detail in chapter &<<CHAProutergeneric>>&.
1314
1315 .ilist
1316 The &%local_part_prefix%& and &%local_part_suffix%& options can specify that
1317 the local parts handled by the router may or must have certain prefixes and/or
1318 suffixes. If a mandatory affix (prefix or suffix) is not present, the router is
1319 skipped. These conditions are tested first. When an affix is present, it is
1320 removed from the local part before further processing, including the evaluation
1321 of any other conditions.
1322 .next
1323 Routers can be designated for use only when not verifying an address, that is,
1324 only when routing it for delivery (or testing its delivery routing). If the
1325 &%verify%& option is set false, the router is skipped when Exim is verifying an
1326 address.
1327 Setting the &%verify%& option actually sets two options, &%verify_sender%& and
1328 &%verify_recipient%&, which independently control the use of the router for
1329 sender and recipient verification. You can set these options directly if
1330 you want a router to be used for only one type of verification.
1331 .next
1332 If the &%address_test%& option is set false, the router is skipped when Exim is
1333 run with the &%-bt%& option to test an address routing. This can be helpful
1334 when the first router sends all new messages to a scanner of some sort; it
1335 makes it possible to use &%-bt%& to test subsequent delivery routing without
1336 having to simulate the effect of the scanner.
1337 .next
1338 Routers can be designated for use only when verifying an address, as
1339 opposed to routing it for delivery. The &%verify_only%& option controls this.
1340 .next
1341 Individual routers can be explicitly skipped when running the routers to
1342 check an address given in the SMTP EXPN command (see the &%expn%& option).
1343 .next
1344 If the &%domains%& option is set, the domain of the address must be in the set
1345 of domains that it defines.
1346 .next
1347 .cindex "&$local_part_prefix$&"
1348 .cindex "&$local_part$&"
1349 .cindex "&$local_part_suffix$&"
1350 If the &%local_parts%& option is set, the local part of the address must be in
1351 the set of local parts that it defines. If &%local_part_prefix%& or
1352 &%local_part_suffix%& is in use, the prefix or suffix is removed from the local
1353 part before this check. If you want to do precondition tests on local parts
1354 that include affixes, you can do so by using a &%condition%& option (see below)
1355 that uses the variables &$local_part$&, &$local_part_prefix$&, and
1356 &$local_part_suffix$& as necessary.
1357 .next
1358 .cindex "&$local_user_uid$&"
1359 .cindex "&$local_user_gid$&"
1360 .cindex "&$home$&"
1361 If the &%check_local_user%& option is set, the local part must be the name of
1362 an account on the local host. If this check succeeds, the uid and gid of the
1363 local user are placed in &$local_user_uid$& and &$local_user_gid$& and the
1364 user's home directory is placed in &$home$&; these values can be used in the
1365 remaining preconditions.
1366 .next
1367 If the &%router_home_directory%& option is set, it is expanded at this point,
1368 because it overrides the value of &$home$&. If this expansion were left till
1369 later, the value of &$home$& as set by &%check_local_user%& would be used in
1370 subsequent tests. Having two different values of &$home$& in the same router
1371 could lead to confusion.
1372 .next
1373 If the &%senders%& option is set, the envelope sender address must be in the
1374 set of addresses that it defines.
1375 .next
1376 If the &%require_files%& option is set, the existence or non-existence of
1377 specified files is tested.
1378 .next
1379 .cindex "customizing" "precondition"
1380 If the &%condition%& option is set, it is evaluated and tested. This option
1381 uses an expanded string to allow you to set up your own custom preconditions.
1382 Expanded strings are described in chapter &<<CHAPexpand>>&.
1383 .endlist
1384
1385
1386 Note that &%require_files%& comes near the end of the list, so you cannot use
1387 it to check for the existence of a file in which to lookup up a domain, local
1388 part, or sender. However, as these options are all expanded, you can use the
1389 &%exists%& expansion condition to make such tests within each condition. The
1390 &%require_files%& option is intended for checking files that the router may be
1391 going to use internally, or which are needed by a specific transport (for
1392 example, &_.procmailrc_&).
1393
1394
1395
1396 .section "Delivery in detail"
1397 .cindex "delivery" "in detail"
1398 When a message is to be delivered, the sequence of events is as follows:
1399
1400 .ilist
1401 If a system-wide filter file is specified, the message is passed to it. The
1402 filter may add recipients to the message, replace the recipients, discard the
1403 message, cause a new message to be generated, or cause the message delivery to
1404 fail. The format of the system filter file is the same as for Exim user filter
1405 files, described in the separate document entitled &'Exim's interfaces to mail
1406 filtering'&.
1407 .cindex "Sieve filter" "not available for system filter"
1408 (&*Note*&: Sieve cannot be used for system filter files.)
1409
1410 Some additional features are available in system filters &-- see chapter
1411 &<<CHAPsystemfilter>>& for details. Note that a message is passed to the system
1412 filter only once per delivery attempt, however many recipients it has. However,
1413 if there are several delivery attempts because one or more addresses could not
1414 be immediately delivered, the system filter is run each time. The filter
1415 condition &%first_delivery%& can be used to detect the first run of the system
1416 filter.
1417 .next
1418 Each recipient address is offered to each configured router in turn, subject to
1419 its preconditions, until one is able to handle it. If no router can handle the
1420 address, that is, if they all decline, the address is failed. Because routers
1421 can be targeted at particular domains, several locally handled domains can be
1422 processed entirely independently of each other.
1423 .next
1424 .cindex "routing" "loops in"
1425 .cindex "loop" "while routing"
1426 A router that accepts an address may assign it to a local or a remote
1427 transport. However, the transport is not run at this time. Instead, the address
1428 is placed on a list for the particular transport, which will be run later.
1429 Alternatively, the router may generate one or more new addresses (typically
1430 from alias, forward, or filter files). New addresses are fed back into this
1431 process from the top, but in order to avoid loops, a router ignores any address
1432 which has an identically-named ancestor that was processed by itself.
1433 .next
1434 When all the routing has been done, addresses that have been successfully
1435 handled are passed to their assigned transports. When local transports are
1436 doing real local deliveries, they handle only one address at a time, but if a
1437 local transport is being used as a pseudo-remote transport (for example, to
1438 collect batched SMTP messages for transmission by some other means) multiple
1439 addresses can be handled. Remote transports can always handle more than one
1440 address at a time, but can be configured not to do so, or to restrict multiple
1441 addresses to the same domain.
1442 .next
1443 Each local delivery to a file or a pipe runs in a separate process under a
1444 non-privileged uid, and these deliveries are run one at a time. Remote
1445 deliveries also run in separate processes, normally under a uid that is private
1446 to Exim (&"the Exim user"&), but in this case, several remote deliveries can be
1447 run in parallel. The maximum number of simultaneous remote deliveries for any
1448 one message is set by the &%remote_max_parallel%& option.
1449 The order in which deliveries are done is not defined, except that all local
1450 deliveries happen before any remote deliveries.
1451 .next
1452 .cindex "queue runner"
1453 When it encounters a local delivery during a queue run, Exim checks its retry
1454 database to see if there has been a previous temporary delivery failure for the
1455 address before running the local transport. If there was a previous failure,
1456 Exim does not attempt a new delivery until the retry time for the address is
1457 reached. However, this happens only for delivery attempts that are part of a
1458 queue run. Local deliveries are always attempted when delivery immediately
1459 follows message reception, even if retry times are set for them. This makes for
1460 better behaviour if one particular message is causing problems (for example,
1461 causing quota overflow, or provoking an error in a filter file).
1462 .next
1463 .cindex "delivery" "retry in remote transports"
1464 Remote transports do their own retry handling, since an address may be
1465 deliverable to one of a number of hosts, each of which may have a different
1466 retry time. If there have been previous temporary failures and no host has
1467 reached its retry time, no delivery is attempted, whether in a queue run or
1468 not. See chapter &<<CHAPretry>>& for details of retry strategies.
1469 .next
1470 If there were any permanent errors, a bounce message is returned to an
1471 appropriate address (the sender in the common case), with details of the error
1472 for each failing address. Exim can be configured to send copies of bounce
1473 messages to other addresses.
1474 .next
1475 .cindex "delivery" "deferral"
1476 If one or more addresses suffered a temporary failure, the message is left on
1477 the queue, to be tried again later. Delivery of these addresses is said to be
1478 &'deferred'&.
1479 .next
1480 When all the recipient addresses have either been delivered or bounced,
1481 handling of the message is complete. The spool files and message log are
1482 deleted, though the message log can optionally be preserved if required.
1483 .endlist
1484
1485
1486
1487
1488 .section "Retry mechanism"
1489 .cindex "delivery" "retry mechanism"
1490 .cindex "retry" "description of mechanism"
1491 .cindex "queue runner"
1492 Exim's mechanism for retrying messages that fail to get delivered at the first
1493 attempt is the queue runner process. You must either run an Exim daemon that
1494 uses the &%-q%& option with a time interval to start queue runners at regular
1495 intervals, or use some other means (such as &'cron'&) to start them. If you do
1496 not arrange for queue runners to be run, messages that fail temporarily at the
1497 first attempt will remain on your queue for ever. A queue runner process works
1498 its way through the queue, one message at a time, trying each delivery that has
1499 passed its retry time.
1500 You can run several queue runners at once.
1501
1502 Exim uses a set of configured rules to determine when next to retry the failing
1503 address (see chapter &<<CHAPretry>>&). These rules also specify when Exim
1504 should give up trying to deliver to the address, at which point it generates a
1505 bounce message. If no retry rules are set for a particular host, address, and
1506 error combination, no retries are attempted, and temporary errors are treated
1507 as permanent.
1508
1509
1510
1511 .section "Temporary delivery failure"
1512 .cindex "delivery" "temporary failure"
1513 There are many reasons why a message may not be immediately deliverable to a
1514 particular address. Failure to connect to a remote machine (because it, or the
1515 connection to it, is down) is one of the most common. Temporary failures may be
1516 detected during routing as well as during the transport stage of delivery.
1517 Local deliveries may be delayed if NFS files are unavailable, or if a mailbox
1518 is on a file system where the user is over quota. Exim can be configured to
1519 impose its own quotas on local mailboxes; where system quotas are set they will
1520 also apply.
1521
1522 If a host is unreachable for a period of time, a number of messages may be
1523 waiting for it by the time it recovers, and sending them in a single SMTP
1524 connection is clearly beneficial. Whenever a delivery to a remote host is
1525 deferred,
1526
1527 .cindex "hints database"
1528 Exim makes a note in its hints database, and whenever a successful
1529 SMTP delivery has happened, it looks to see if any other messages are waiting
1530 for the same host. If any are found, they are sent over the same SMTP
1531 connection, subject to a configuration limit as to the maximum number in any
1532 one connection.
1533
1534
1535
1536
1537 .section "Permanent delivery failure"
1538 .cindex "delivery" "permanent failure"
1539 .cindex "bounce message" "when generated"
1540 When a message cannot be delivered to some or all of its intended recipients, a
1541 bounce message is generated. Temporary delivery failures turn into permanent
1542 errors when their timeout expires. All the addresses that fail in a given
1543 delivery attempt are listed in a single message. If the original message has
1544 many recipients, it is possible for some addresses to fail in one delivery
1545 attempt and others to fail subsequently, giving rise to more than one bounce
1546 message. The wording of bounce messages can be customized by the administrator.
1547 See chapter &<<CHAPemsgcust>>& for details.
1548
1549 .cindex "&'X-Failed-Recipients:'& header line"
1550 Bounce messages contain an &'X-Failed-Recipients:'& header line that lists the
1551 failed addresses, for the benefit of programs that try to analyse such messages
1552 automatically.
1553
1554 .cindex "bounce message" "recipient of"
1555 A bounce message is normally sent to the sender of the original message, as
1556 obtained from the message's envelope. For incoming SMTP messages, this is the
1557 address given in the MAIL command. However, when an address is expanded via a
1558 forward or alias file, an alternative address can be specified for delivery
1559 failures of the generated addresses. For a mailing list expansion (see section
1560 &<<SECTmailinglists>>&) it is common to direct bounce messages to the manager
1561 of the list.
1562
1563
1564
1565 .section "Failures to deliver bounce messages"
1566 .cindex "bounce message" "failure to deliver"
1567 If a bounce message (either locally generated or received from a remote host)
1568 itself suffers a permanent delivery failure, the message is left on the queue,
1569 but it is frozen, awaiting the attention of an administrator. There are options
1570 that can be used to make Exim discard such failed messages, or to keep them
1571 for only a short time (see &%timeout_frozen_after%& and
1572 &%ignore_bounce_errors_after%&).
1573
1574
1575
1576
1577
1578 . ////////////////////////////////////////////////////////////////////////////
1579 . ////////////////////////////////////////////////////////////////////////////
1580
1581 .chapter "Building and installing Exim"
1582 .scindex IIDbuex "building Exim"
1583
1584 .section "Unpacking"
1585 Exim is distributed as a gzipped or bzipped tar file which, when upacked,
1586 creates a directory with the name of the current release (for example,
1587 &_exim-&version;_&) into which the following files are placed:
1588
1589 .table2 140pt
1590 .row &_ACKNOWLEDGMENTS_& "contains some acknowledgments"
1591 .row &_CHANGES_&         "contains a reference to where changes are documented"
1592 .row &_LICENCE_&         "the GNU General Public Licence"
1593 .row &_Makefile_&        "top-level make file"
1594 .row &_NOTICE_&          "conditions for the use of Exim"
1595 .row &_README_&          "list of files, directories and simple build &&&
1596                           instructions"
1597 .endtable
1598
1599 Other files whose names begin with &_README_& may also be present. The
1600 following subdirectories are created:
1601
1602 .table2 140pt
1603 .row &_Local_&           "an empty directory for local configuration files"
1604 .row &_OS_&              "OS-specific files"
1605 .row &_doc_&             "documentation files"
1606 .row &_exim_monitor_&    "source files for the Exim monitor"
1607 .row &_scripts_&         "scripts used in the build process"
1608 .row &_src_&             "remaining source files"
1609 .row &_util_&            "independent utilities"
1610 .endtable
1611
1612 The main utility programs are contained in the &_src_& directory, and are built
1613 with the Exim binary. The &_util_& directory contains a few optional scripts
1614 that may be useful to some sites.
1615
1616
1617 .section "Multiple machine architectures and operating systems"
1618 .cindex "building Exim" "multiple OS/architectures"
1619 The building process for Exim is arranged to make it easy to build binaries for
1620 a number of different architectures and operating systems from the same set of
1621 source files. Compilation does not take place in the &_src_& directory.
1622 Instead, a &'build directory'& is created for each architecture and operating
1623 system.
1624 .cindex "symbolic link" "to build directory"
1625 Symbolic links to the sources are installed in this directory, which is where
1626 the actual building takes place. In most cases, Exim can discover the machine
1627 architecture and operating system for itself, but the defaults can be
1628 overridden if necessary.
1629
1630
1631 .section "DBM libraries" "SECTdb"
1632 .cindex "DBM libraries" "discussion of"
1633 .cindex "hints database" "DBM files used for"
1634 Even if you do not use any DBM files in your configuration, Exim still needs a
1635 DBM library in order to operate, because it uses indexed files for its hints
1636 databases. Unfortunately, there are a number of DBM libraries in existence, and
1637 different operating systems often have different ones installed.
1638
1639 .cindex "Solaris" "DBM library for"
1640 .cindex "IRIX" "DBM library for"
1641 .cindex "BSD" "DBM library for"
1642 .cindex "Linux" "DBM library for"
1643 If you are using Solaris, IRIX, one of the modern BSD systems, or a modern
1644 Linux distribution, the DBM configuration should happen automatically, and you
1645 may be able to ignore this section. Otherwise, you may have to learn more than
1646 you would like about DBM libraries from what follows.
1647
1648 .cindex "&'ndbm'& DBM library"
1649 Licensed versions of Unix normally contain a library of DBM functions operating
1650 via the &'ndbm'& interface, and this is what Exim expects by default. Free
1651 versions of Unix seem to vary in what they contain as standard. In particular,
1652 some early versions of Linux have no default DBM library, and different
1653 distributors have chosen to bundle different libraries with their packaged
1654 versions. However, the more recent releases seem to have standardised on the
1655 Berkeley DB library.
1656
1657 Different DBM libraries have different conventions for naming the files they
1658 use. When a program opens a file called &_dbmfile_&, there are several
1659 possibilities:
1660
1661 .olist
1662 A traditional &'ndbm'& implementation, such as that supplied as part of
1663 Solaris, operates on two files called &_dbmfile.dir_& and &_dbmfile.pag_&.
1664 .next
1665 .cindex "&'gdbm'& DBM library"
1666 The GNU library, &'gdbm'&, operates on a single file. If used via its &'ndbm'&
1667 compatibility interface it makes two different hard links to it with names
1668 &_dbmfile.dir_& and &_dbmfile.pag_&, but if used via its native interface, the
1669 file name is used unmodified.
1670 .next
1671 .cindex "Berkeley DB library"
1672 The Berkeley DB package, if called via its &'ndbm'& compatibility interface,
1673 operates on a single file called &_dbmfile.db_&, but otherwise looks to the
1674 programmer exactly the same as the traditional &'ndbm'& implementation.
1675 .next
1676 If the Berkeley package is used in its native mode, it operates on a single
1677 file called &_dbmfile_&; the programmer's interface is somewhat different to
1678 the traditional &'ndbm'& interface.
1679 .next
1680 To complicate things further, there are several very different versions of the
1681 Berkeley DB package. Version 1.85 was stable for a very long time, releases
1682 2.&'x'& and 3.&'x'& were current for a while, but the latest versions are now
1683 numbered 4.&'x'&. Maintenance of some of the earlier releases has ceased. All
1684 versions of Berkeley DB can be obtained from
1685 &url(http://www.sleepycat.com/).
1686 .next
1687 .cindex "&'tdb'& DBM library"
1688 Yet another DBM library, called &'tdb'&, is available from
1689 &url(http://download.sourceforge.net/tdb). It has its own interface, and also
1690 operates on a single file.
1691 .endlist
1692
1693 .cindex "USE_DB"
1694 .cindex "DBM libraries" "configuration for building"
1695 Exim and its utilities can be compiled to use any of these interfaces. In order
1696 to use any version of the Berkeley DB package in native mode, you must set
1697 USE_DB in an appropriate configuration file (typically
1698 &_Local/Makefile_&). For example:
1699 .code
1700 USE_DB=yes
1701 .endd
1702 Similarly, for gdbm you set USE_GDBM, and for tdb you set USE_TDB. An
1703 error is diagnosed if you set more than one of these.
1704
1705 At the lowest level, the build-time configuration sets none of these options,
1706 thereby assuming an interface of type (1). However, some operating system
1707 configuration files (for example, those for the BSD operating systems and
1708 Linux) assume type (4) by setting USE_DB as their default, and the
1709 configuration files for Cygwin set USE_GDBM. Anything you set in
1710 &_Local/Makefile_&, however, overrides these system defaults.
1711
1712 As well as setting USE_DB, USE_GDBM, or USE_TDB, it may also be
1713 necessary to set DBMLIB, to cause inclusion of the appropriate library, as
1714 in one of these lines:
1715 .code
1716 DBMLIB = -ldb
1717 DBMLIB = -ltdb
1718 .endd
1719 Settings like that will work if the DBM library is installed in the standard
1720 place. Sometimes it is not, and the library's header file may also not be in
1721 the default path. You may need to set INCLUDE to specify where the header
1722 file is, and to specify the path to the library more fully in DBMLIB, as in
1723 this example:
1724 .code
1725 INCLUDE=-I/usr/local/include/db-4.1
1726 DBMLIB=/usr/local/lib/db-4.1/libdb.a
1727 .endd
1728 There is further detailed discussion about the various DBM libraries in the
1729 file &_doc/dbm.discuss.txt_& in the Exim distribution.
1730
1731
1732
1733 .section "Pre-building configuration"
1734 .cindex "building Exim" "pre-building configuration"
1735 .cindex "configuration for building Exim"
1736 .cindex "&_Local/Makefile_&"
1737 .cindex "&_src/EDITME_&"
1738 Before building Exim, a local configuration file that specifies options
1739 independent of any operating system has to be created with the name
1740 &_Local/Makefile_&. A template for this file is supplied as the file
1741 &_src/EDITME_&, and it contains full descriptions of all the option settings
1742 therein. These descriptions are therefore not repeated here. If you are
1743 building Exim for the first time, the simplest thing to do is to copy
1744 &_src/EDITME_& to &_Local/Makefile_&, then read it and edit it appropriately.
1745
1746 There are three settings that you must supply, because Exim will not build
1747 without them. They are the location of the run time configuration file
1748 (CONFIGURE_FILE), the directory in which Exim binaries will be installed
1749 (BIN_DIRECTORY), and the identity of the Exim user (EXIM_USER and
1750 maybe EXIM_GROUP as well). The value of CONFIGURE_FILE can in fact be
1751 a colon-separated list of file names; Exim uses the first of them that exists.
1752
1753 There are a few other parameters that can be specified either at build time or
1754 at run time, to enable the same binary to be used on a number of different
1755 machines. However, if the locations of Exim's spool directory and log file
1756 directory (if not within the spool directory) are fixed, it is recommended that
1757 you specify them in &_Local/Makefile_& instead of at run time, so that errors
1758 detected early in Exim's execution (such as a malformed configuration file) can
1759 be logged.
1760
1761 .cindex "content scanning" "specifying at build time"
1762 Exim's interfaces for calling virus and spam scanning software directly from
1763 access control lists are not compiled by default. If you want to include these
1764 facilities, you need to set
1765 .code
1766 WITH_CONTENT_SCAN=yes
1767 .endd
1768 in your &_Local/Makefile_&. For details of the facilities themselves, see
1769 chapter &<<CHAPexiscan>>&.
1770
1771
1772 .cindex "&_Local/eximon.conf_&"
1773 .cindex "&_exim_monitor/EDITME_&"
1774 If you are going to build the Exim monitor, a similar configuration process is
1775 required. The file &_exim_monitor/EDITME_& must be edited appropriately for
1776 your installation and saved under the name &_Local/eximon.conf_&. If you are
1777 happy with the default settings described in &_exim_monitor/EDITME_&,
1778 &_Local/eximon.conf_& can be empty, but it must exist.
1779
1780 This is all the configuration that is needed in straightforward cases for known
1781 operating systems. However, the building process is set up so that it is easy
1782 to override options that are set by default or by operating-system-specific
1783 configuration files, for example to change the name of the C compiler, which
1784 defaults to &%gcc%&. See section &<<SECToverride>>& below for details of how to
1785 do this.
1786
1787
1788
1789 .section "Support for iconv()"
1790 .cindex "&[iconv()]& support"
1791 .cindex "RFC 2047"
1792 The contents of header lines in messages may be encoded according to the rules
1793 described RFC 2047. This makes it possible to transmit characters that are not
1794 in the ASCII character set, and to label them as being in a particular
1795 character set. When Exim is inspecting header lines by means of the &%$h_%&
1796 mechanism, it decodes them, and translates them into a specified character set
1797 (default ISO-8859-1). The translation is possible only if the operating system
1798 supports the &[iconv()]& function.
1799
1800 However, some of the operating systems that supply &[iconv()]& do not support
1801 very many conversions. The GNU &%libiconv%& library (available from
1802 &url(http://www.gnu.org/software/libiconv/)) can be installed on such
1803 systems to remedy this deficiency, as well as on systems that do not supply
1804 &[iconv()]& at all. After installing &%libiconv%&, you should add
1805 .code
1806 HAVE_ICONV=yes
1807 .endd
1808 to your &_Local/Makefile_& and rebuild Exim.
1809
1810
1811
1812 .section "Including TLS/SSL encryption support" "SECTinctlsssl"
1813 .cindex "TLS" "including support for TLS"
1814 .cindex "encryption" "including support for"
1815 .cindex "SUPPORT_TLS"
1816 .cindex "OpenSSL" "building Exim with"
1817 .cindex "GnuTLS" "building Exim with"
1818 Exim can be built to support encrypted SMTP connections, using the STARTTLS
1819 command as per RFC 2487. It can also support legacy clients that expect to
1820 start a TLS session immediately on connection to a non-standard port (see the
1821 &%tls_on_connect_ports%& runtime option and the &%-tls-on-connect%& command
1822 line option).
1823
1824 If you want to build Exim with TLS support, you must first install either the
1825 OpenSSL or GnuTLS library. There is no cryptographic code in Exim itself for
1826 implementing SSL.
1827
1828 If OpenSSL is installed, you should set
1829 .code
1830 SUPPORT_TLS=yes
1831 TLS_LIBS=-lssl -lcrypto
1832 .endd
1833 in &_Local/Makefile_&. You may also need to specify the locations of the
1834 OpenSSL library and include files. For example:
1835 .code
1836 SUPPORT_TLS=yes
1837 TLS_LIBS=-L/usr/local/openssl/lib -lssl -lcrypto
1838 TLS_INCLUDE=-I/usr/local/openssl/include/
1839 .endd
1840 .cindex "USE_GNUTLS"
1841 If GnuTLS is installed, you should set
1842 .code
1843 SUPPORT_TLS=yes
1844 USE_GNUTLS=yes
1845 TLS_LIBS=-lgnutls -ltasn1 -lgcrypt
1846 .endd
1847 in &_Local/Makefile_&, and again you may need to specify the locations of the
1848 library and include files. For example:
1849 .code
1850 SUPPORT_TLS=yes
1851 USE_GNUTLS=yes
1852 TLS_LIBS=-L/usr/gnu/lib -lgnutls -ltasn1 -lgcrypt
1853 TLS_INCLUDE=-I/usr/gnu/include
1854 .endd
1855 You do not need to set TLS_INCLUDE if the relevant directory is already
1856 specified in INCLUDE. Details of how to configure Exim to make use of TLS are
1857 given in chapter &<<CHAPTLS>>&.
1858
1859
1860
1861
1862 .section "Use of tcpwrappers"
1863 .cindex "tcpwrappers" "building Exim to support"
1864 .cindex "USE_TCP_WRAPPERS"
1865 Exim can be linked with the &'tcpwrappers'& library in order to check incoming
1866 SMTP calls using the &'tcpwrappers'& control files. This may be a convenient
1867 alternative to Exim's own checking facilities for installations that are
1868 already making use of &'tcpwrappers'& for other purposes. To do this, you
1869 should set USE_TCP_WRAPPERS in &_Local/Makefile_&, arrange for the file
1870 &_tcpd.h_& to be available at compile time, and also ensure that the library
1871 &_libwrap.a_& is available at link time, typically by including &%-lwrap%& in
1872 EXTRALIBS_EXIM. For example, if &'tcpwrappers'& is installed in &_/usr/local_&,
1873 you might have
1874 .code
1875 USE_TCP_WRAPPERS=yes
1876 CFLAGS=-O -I/usr/local/include
1877 EXTRALIBS_EXIM=-L/usr/local/lib -lwrap
1878 .endd
1879 in &_Local/Makefile_&. The name to use in the &'tcpwrappers'& control files is
1880 &"exim"&. For example, the line
1881 .code
1882 exim : LOCAL  192.168.1.  .friendly.domain.example
1883 .endd
1884 in your &_/etc/hosts.allow_& file allows connections from the local host, from
1885 the subnet 192.168.1.0/24, and from all hosts in &'friendly.domain.example'&.
1886 All other connections are denied. Consult the &'tcpwrappers'& documentation for
1887 further details.
1888
1889
1890
1891 .section "Including support for IPv6"
1892 .cindex "IPv6" "including support for"
1893 Exim contains code for use on systems that have IPv6 support. Setting
1894 &`HAVE_IPV6=YES`& in &_Local/Makefile_& causes the IPv6 code to be included;
1895 it may also be necessary to set IPV6_INCLUDE and IPV6_LIBS on systems
1896 where the IPv6 support is not fully integrated into the normal include and
1897 library files.
1898
1899 Two different types of DNS record for handling IPv6 addresses have been
1900 defined. AAAA records (analagous to A records for IPv4) are in use, and are
1901 currently seen as the mainstream. Another record type called A6 was proposed
1902 as better than AAAA because it had more flexibility. However, it was felt to be
1903 over-complex, and its status was reduced to &"experimental"&. It is not known
1904 if anyone is actually using A6 records. Exim has support for A6 records, but
1905 this is included only if you set &`SUPPORT_A6=YES`& in &_Local/Makefile_&. The
1906 support has not been tested for some time.
1907
1908
1909
1910 .section "The building process"
1911 .cindex "build directory"
1912 Once &_Local/Makefile_& (and &_Local/eximon.conf_&, if required) have been
1913 created, run &'make'& at the top level. It determines the architecture and
1914 operating system types, and creates a build directory if one does not exist.
1915 For example, on a Sun system running Solaris 8, the directory
1916 &_build-SunOS5-5.8-sparc_& is created.
1917 .cindex "symbolic link" "to source files"
1918 Symbolic links to relevant source files are installed in the build directory.
1919
1920 &*Warning*&: The &%-j%& (parallel) flag must not be used with &'make'&; the
1921 building process fails if it is set.
1922
1923 If this is the first time &'make'& has been run, it calls a script that builds
1924 a make file inside the build directory, using the configuration files from the
1925 &_Local_& directory. The new make file is then passed to another instance of
1926 &'make'&. This does the real work, building a number of utility scripts, and
1927 then compiling and linking the binaries for the Exim monitor (if configured), a
1928 number of utility programs, and finally Exim itself. The command &`make
1929 makefile`& can be used to force a rebuild of the make file in the build
1930 directory, should this ever be necessary.
1931
1932 If you have problems building Exim, check for any comments there may be in the
1933 &_README_& file concerning your operating system, and also take a look at the
1934 FAQ, where some common problems are covered.
1935
1936
1937
1938 .section 'Output from &"make"&'
1939 The output produced by the &'make'& process for compile lines is often very
1940 unreadable, because these lines can be very long. For this reason, the normal
1941 output is suppressed by default, and instead output similar to that which
1942 appears when compiling the 2.6 Linux kernel is generated: just a short line for
1943 each module that is being compiled or linked. However, it is still possible to
1944 get the full output, by calling &'make'& like this:
1945 .code
1946 FULLECHO='' make -e
1947 .endd
1948 The value of FULLECHO defaults to &"@"&, the flag character that suppresses
1949 command reflection in &'make'&. When you ask for the full output, it is
1950 given in addition to the short output.
1951
1952
1953
1954 .section "Overriding build-time options for Exim" "SECToverride"
1955 .cindex "build-time options" "overriding"
1956 The main make file that is created at the beginning of the building process
1957 consists of the concatenation of a number of files which set configuration
1958 values, followed by a fixed set of &'make'& instructions. If a value is set
1959 more than once, the last setting overrides any previous ones. This provides a
1960 convenient way of overriding defaults. The files that are concatenated are, in
1961 order:
1962 .display
1963 &_OS/Makefile-Default_&
1964 &_OS/Makefile-_&<&'ostype'&>
1965 &_Local/Makefile_&
1966 &_Local/Makefile-_&<&'ostype'&>
1967 &_Local/Makefile-_&<&'archtype'&>
1968 &_Local/Makefile-_&<&'ostype'&>-<&'archtype'&>
1969 &_OS/Makefile-Base_&
1970 .endd
1971 .cindex "&_Local/Makefile_&"
1972 .cindex "building Exim" "operating system type"
1973 .cindex "building Exim" "architecture type"
1974 where <&'ostype'&> is the operating system type and <&'archtype'&> is the
1975 architecture type. &_Local/Makefile_& is required to exist, and the building
1976 process fails if it is absent. The other three &_Local_& files are optional,
1977 and are often not needed.
1978
1979 The values used for <&'ostype'&> and <&'archtype'&> are obtained from scripts
1980 called &_scripts/os-type_& and &_scripts/arch-type_& respectively. If either of
1981 the environment variables EXIM_OSTYPE or EXIM_ARCHTYPE is set, their
1982 values are used, thereby providing a means of forcing particular settings.
1983 Otherwise, the scripts try to get values from the &%uname%& command. If this
1984 fails, the shell variables OSTYPE and ARCHTYPE are inspected. A number
1985 of &'ad hoc'& transformations are then applied, to produce the standard names
1986 that Exim expects. You can run these scripts directly from the shell in order
1987 to find out what values are being used on your system.
1988
1989
1990 &_OS/Makefile-Default_& contains comments about the variables that are set
1991 therein. Some (but not all) are mentioned below. If there is something that
1992 needs changing, review the contents of this file and the contents of the make
1993 file for your operating system (&_OS/Makefile-<ostype>_&) to see what the
1994 default values are.
1995
1996
1997 .cindex "building Exim" "overriding default settings"
1998 If you need to change any of the values that are set in &_OS/Makefile-Default_&
1999 or in &_OS/Makefile-<ostype>_&, or to add any new definitions, you do not
2000 need to change the original files. Instead, you should make the changes by
2001 putting the new values in an appropriate &_Local_& file. For example,
2002 .cindex "Tru64-Unix build-time settings"
2003 when building Exim in many releases of the Tru64-Unix (formerly Digital UNIX,
2004 formerly DEC-OSF1) operating system, it is necessary to specify that the C
2005 compiler is called &'cc'& rather than &'gcc'&. Also, the compiler must be
2006 called with the option &%-std1%&, to make it recognize some of the features of
2007 Standard C that Exim uses. (Most other compilers recognize Standard C by
2008 default.) To do this, you should create a file called &_Local/Makefile-OSF1_&
2009 containing the lines
2010 .code
2011 CC=cc
2012 CFLAGS=-std1
2013 .endd
2014 If you are compiling for just one operating system, it may be easier to put
2015 these lines directly into &_Local/Makefile_&.
2016
2017 Keeping all your local configuration settings separate from the distributed
2018 files makes it easy to transfer them to new versions of Exim simply by copying
2019 the contents of the &_Local_& directory.
2020
2021
2022 .cindex "NIS lookup type" "including support for"
2023 .cindex "NIS+ lookup type" "including support for"
2024 .cindex "LDAP" "including support for"
2025 .cindex "lookup" "inclusion in binary"
2026 Exim contains support for doing LDAP, NIS, NIS+, and other kinds of file
2027 lookup, but not all systems have these components installed, so the default is
2028 not to include the relevant code in the binary. All the different kinds of file
2029 and database lookup that Exim supports are implemented as separate code modules
2030 which are included only if the relevant compile-time options are set. In the
2031 case of LDAP, NIS, and NIS+, the settings for &_Local/Makefile_& are:
2032 .code
2033 LOOKUP_LDAP=yes
2034 LOOKUP_NIS=yes
2035 LOOKUP_NISPLUS=yes
2036 .endd
2037 and similar settings apply to the other lookup types. They are all listed in
2038 &_src/EDITME_&. In many cases the relevant include files and interface
2039 libraries need to be installed before compiling Exim.
2040 .cindex "cdb" "including support for"
2041 However, there are some optional lookup types (such as cdb) for which
2042 the code is entirely contained within Exim, and no external include
2043 files or libraries are required. When a lookup type is not included in the
2044 binary, attempts to configure Exim to use it cause run time configuration
2045 errors.
2046
2047 .cindex "Perl" "including support for"
2048 Exim can be linked with an embedded Perl interpreter, allowing Perl
2049 subroutines to be called during string expansion. To enable this facility,
2050 .code
2051 EXIM_PERL=perl.o
2052 .endd
2053 must be defined in &_Local/Makefile_&. Details of this facility are given in
2054 chapter &<<CHAPperl>>&.
2055
2056 .cindex "X11 libraries" "location of"
2057 The location of the X11 libraries is something that varies a lot between
2058 operating systems, and there may be different versions of X11 to cope
2059 with. Exim itself makes no use of X11, but if you are compiling the Exim
2060 monitor, the X11 libraries must be available.
2061 The following three variables are set in &_OS/Makefile-Default_&:
2062 .code
2063 X11=/usr/X11R6
2064 XINCLUDE=-I$(X11)/include
2065 XLFLAGS=-L$(X11)/lib
2066 .endd
2067 These are overridden in some of the operating-system configuration files. For
2068 example, in &_OS/Makefile-SunOS5_& there is
2069 .code
2070 X11=/usr/openwin
2071 XINCLUDE=-I$(X11)/include
2072 XLFLAGS=-L$(X11)/lib -R$(X11)/lib
2073 .endd
2074 If you need to override the default setting for your operating system, place a
2075 definition of all three of these variables into your
2076 &_Local/Makefile-<ostype>_& file.
2077
2078 .cindex "EXTRALIBS"
2079 If you need to add any extra libraries to the link steps, these can be put in a
2080 variable called EXTRALIBS, which appears in all the link commands, but by
2081 default is not defined. In contrast, EXTRALIBS_EXIM is used only on the
2082 command for linking the main Exim binary, and not for any associated utilities.
2083
2084 .cindex "DBM libraries" "configuration for building"
2085 There is also DBMLIB, which appears in the link commands for binaries that
2086 use DBM functions (see also section &<<SECTdb>>&). Finally, there is
2087 EXTRALIBS_EXIMON, which appears only in the link step for the Exim monitor
2088 binary, and which can be used, for example, to include additional X11
2089 libraries.
2090
2091 .cindex "configuration file" "editing"
2092 The make file copes with rebuilding Exim correctly if any of the configuration
2093 files are edited. However, if an optional configuration file is deleted, it is
2094 necessary to touch the associated non-optional file (that is,
2095 &_Local/Makefile_& or &_Local/eximon.conf_&) before rebuilding.
2096
2097
2098 .section "OS-specific header files"
2099 .cindex "&_os.h_&"
2100 .cindex "building Exim" "OS-specific C header files"
2101 The &_OS_& directory contains a number of files with names of the form
2102 &_os.h-<ostype>_&. These are system-specific C header files that should not
2103 normally need to be changed. There is a list of macro settings that are
2104 recognized in the file &_OS/os.configuring_&, which should be consulted if you
2105 are porting Exim to a new operating system.
2106
2107
2108
2109 .section "Overriding build-time options for the monitor"
2110 .cindex "building Eximon" "overriding default options"
2111 A similar process is used for overriding things when building the Exim monitor,
2112 where the files that are involved are
2113 .display
2114 &_OS/eximon.conf-Default_&
2115 &_OS/eximon.conf-_&<&'ostype'&>
2116 &_Local/eximon.conf_&
2117 &_Local/eximon.conf-_&<&'ostype'&>
2118 &_Local/eximon.conf-_&<&'archtype'&>
2119 &_Local/eximon.conf-_&<&'ostype'&>-<&'archtype'&>
2120 .endd
2121 .cindex "&_Local/eximon.conf_&"
2122 As with Exim itself, the final three files need not exist, and in this case the
2123 &_OS/eximon.conf-<ostype>_& file is also optional. The default values in
2124 &_OS/eximon.conf-Default_& can be overridden dynamically by setting environment
2125 variables of the same name, preceded by EXIMON_. For example, setting
2126 EXIMON_LOG_DEPTH in the environment overrides the value of
2127 LOG_DEPTH at run time.
2128 .ecindex IIDbuex
2129
2130
2131 .section "Installing Exim binaries and scripts"
2132 .cindex "installing Exim"
2133 .cindex "BIN_DIRECTORY"
2134 The command &`make install`& runs the &(exim_install)& script with no
2135 arguments. The script copies binaries and utility scripts into the directory
2136 whose name is specified by the BIN_DIRECTORY setting in &_Local/Makefile_&.
2137 .cindex "setuid" "installing Exim with"
2138 The install script copies files only if they are newer than the files they are
2139 going to replace. The Exim binary is required to be owned by root and have the
2140 &'setuid'& bit set, for normal configurations. Therefore, you must run &`make
2141 install`& as root so that it can set up the Exim binary in this way. However, in
2142 some special situations (for example, if a host is doing no local deliveries)
2143 it may be possible to run Exim without making the binary setuid root (see
2144 chapter &<<CHAPsecurity>>& for details).
2145
2146 .cindex "CONFIGURE_FILE"
2147 Exim's run time configuration file is named by the CONFIGURE_FILE setting
2148 in &_Local/Makefile_&. If this names a single file, and the file does not
2149 exist, the default configuration file &_src/configure.default_& is copied there
2150 by the installation script. If a run time configuration file already exists, it
2151 is left alone. If CONFIGURE_FILE is a colon-separated list, naming several
2152 alternative files, no default is installed.
2153
2154 .cindex "system aliases file"
2155 .cindex "&_/etc/aliases_&"
2156 One change is made to the default configuration file when it is installed: the
2157 default configuration contains a router that references a system aliases file.
2158 The path to this file is set to the value specified by
2159 SYSTEM_ALIASES_FILE in &_Local/Makefile_& (&_/etc/aliases_& by default).
2160 If the system aliases file does not exist, the installation script creates it,
2161 and outputs a comment to the user.
2162
2163 The created file contains no aliases, but it does contain comments about the
2164 aliases a site should normally have. Mail aliases have traditionally been
2165 kept in &_/etc/aliases_&. However, some operating systems are now using
2166 &_/etc/mail/aliases_&. You should check if yours is one of these, and change
2167 Exim's configuration if necessary.
2168
2169 The default configuration uses the local host's name as the only local domain,
2170 and is set up to do local deliveries into the shared directory &_/var/mail_&,
2171 running as the local user. System aliases and &_.forward_& files in users' home
2172 directories are supported, but no NIS or NIS+ support is configured. Domains
2173 other than the name of the local host are routed using the DNS, with delivery
2174 over SMTP.
2175
2176 It is possible to install Exim for special purposes (such as building a binary
2177 distribution) in a private part of the file system. You can do this by a
2178 command such as
2179 .code
2180 make DESTDIR=/some/directory/ install
2181 .endd
2182 This has the effect of pre-pending the specified directory to all the file
2183 paths, except the name of the system aliases file that appears in the default
2184 configuration. (If a default alias file is created, its name &'is'& modified.)
2185 For backwards compatibility, ROOT is used if DESTDIR is not set,
2186 but this usage is deprecated.
2187
2188 .cindex "installing Exim" "what is not installed"
2189 Running &'make install'& does not copy the Exim 4 conversion script
2190 &'convert4r4'&, or the &'pcretest'& test program. You will probably run the
2191 first of these only once (if you are upgrading from Exim 3), and the second
2192 isn't really part of Exim. None of the documentation files in the &_doc_&
2193 directory are copied, except for the info files when you have set
2194 INFO_DIRECTORY, as described in section &<<SECTinsinfdoc>>& below.
2195
2196 For the utility programs, old versions are renamed by adding the suffix &_.O_&
2197 to their names. The Exim binary itself, however, is handled differently. It is
2198 installed under a name that includes the version number and the compile number,
2199 for example &_exim-&version;-1_&. The script then arranges for a symbolic link
2200 called &_exim_& to point to the binary. If you are updating a previous version
2201 of Exim, the script takes care to ensure that the name &_exim_& is never absent
2202 from the directory (as seen by other processes).
2203
2204 .cindex "installing Exim" "testing the script"
2205 If you want to see what the &'make install'& will do before running it for
2206 real, you can pass the &%-n%& option to the installation script by this
2207 command:
2208 .code
2209 make INSTALL_ARG=-n install
2210 .endd
2211 The contents of the variable INSTALL_ARG are passed to the installation
2212 script. You do not need to be root to run this test. Alternatively, you can run
2213 the installation script directly, but this must be from within the build
2214 directory. For example, from the top-level Exim directory you could use this
2215 command:
2216 .code
2217 (cd build-SunOS5-5.5.1-sparc; ../scripts/exim_install -n)
2218 .endd
2219 .cindex "installing Exim" "install script options"
2220 There are two other options that can be supplied to the installation script.
2221
2222 .ilist
2223 &%-no_chown%& bypasses the call to change the owner of the installed binary
2224 to root, and the call to make it a setuid binary.
2225 .next
2226 &%-no_symlink%& bypasses the setting up of the symbolic link &_exim_& to the
2227 installed binary.
2228 .endlist
2229
2230 INSTALL_ARG can be used to pass these options to the script. For example:
2231 .code
2232 make INSTALL_ARG=-no_symlink install
2233 .endd
2234 The installation script can also be given arguments specifying which files are
2235 to be copied. For example, to install just the Exim binary, and nothing else,
2236 without creating the symbolic link, you could use:
2237 .code
2238 make INSTALL_ARG='-no_symlink exim' install
2239 .endd
2240
2241
2242
2243 .section "Installing info documentation" "SECTinsinfdoc"
2244 .cindex "installing Exim" "&'info'& documentation"
2245 Not all systems use the GNU &'info'& system for documentation, and for this
2246 reason, the Texinfo source of Exim's documentation is not included in the main
2247 distribution. Instead it is available separately from the ftp site (see section
2248 &<<SECTavail>>&).
2249
2250 If you have defined INFO_DIRECTORY in &_Local/Makefile_& and the Texinfo
2251 source of the documentation is found in the source tree, running &`make
2252 install`& automatically builds the info files and installs them.
2253
2254
2255
2256 .section "Setting up the spool directory"
2257 .cindex "spool directory" "creating"
2258 When it starts up, Exim tries to create its spool directory if it does not
2259 exist. The Exim uid and gid are used for the owner and group of the spool
2260 directory. Sub-directories are automatically created in the spool directory as
2261 necessary.
2262
2263
2264
2265
2266 .section "Testing"
2267 .cindex "testing" "installation"
2268 Having installed Exim, you can check that the run time configuration file is
2269 syntactically valid by running the following command, which assumes that the
2270 Exim binary directory is within your PATH environment variable:
2271 .code
2272 exim -bV
2273 .endd
2274 If there are any errors in the configuration file, Exim outputs error messages.
2275 Otherwise it outputs the version number and build date,
2276 the DBM library that is being used, and information about which drivers and
2277 other optional code modules are included in the binary.
2278 Some simple routing tests can be done by using the address testing option. For
2279 example,
2280 .display
2281 &`exim -bt`& <&'local username'&>
2282 .endd
2283 should verify that it recognizes a local mailbox, and
2284 .display
2285 &`exim -bt`& <&'remote address'&>
2286 .endd
2287 a remote one. Then try getting it to deliver mail, both locally and remotely.
2288 This can be done by passing messages directly to Exim, without going through a
2289 user agent. For example:
2290 .code
2291 exim -v postmaster@your.domain.example
2292 From: user@your.domain.example
2293 To: postmaster@your.domain.example
2294 Subject: Testing Exim
2295
2296 This is a test message.
2297 ^D
2298 .endd
2299 The &%-v%& option causes Exim to output some verification of what it is doing.
2300 In this case you should see copies of three log lines, one for the message's
2301 arrival, one for its delivery, and one containing &"Completed"&.
2302
2303 .cindex "delivery" "problems with"
2304 If you encounter problems, look at Exim's log files (&'mainlog'& and
2305 &'paniclog'&) to see if there is any relevant information there. Another source
2306 of information is running Exim with debugging turned on, by specifying the
2307 &%-d%& option. If a message is stuck on Exim's spool, you can force a delivery
2308 with debugging turned on by a command of the form
2309 .display
2310 &`exim -d -M`& <&'exim-message-id'&>
2311 .endd
2312 You must be root or an &"admin user"& in order to do this. The &%-d%& option
2313 produces rather a lot of output, but you can cut this down to specific areas.
2314 For example, if you use &%-d-all+route%& only the debugging information
2315 relevant to routing is included. (See the &%-d%& option in chapter
2316 &<<CHAPcommandline>>& for more details.)
2317
2318 .cindex '&"sticky"& bit'
2319 .cindex "lock files"
2320 One specific problem that has shown up on some sites is the inability to do
2321 local deliveries into a shared mailbox directory, because it does not have the
2322 &"sticky bit"& set on it. By default, Exim tries to create a lock file before
2323 writing to a mailbox file, and if it cannot create the lock file, the delivery
2324 is deferred. You can get round this either by setting the &"sticky bit"& on the
2325 directory, or by setting a specific group for local deliveries and allowing
2326 that group to create files in the directory (see the comments above the
2327 &(local_delivery)& transport in the default configuration file). Another
2328 approach is to configure Exim not to use lock files, but just to rely on
2329 &[fcntl()]& locking instead. However, you should do this only if all user
2330 agents also use &[fcntl()]& locking. For further discussion of locking issues,
2331 see chapter &<<CHAPappendfile>>&.
2332
2333 One thing that cannot be tested on a system that is already running an MTA is
2334 the receipt of incoming SMTP mail on the standard SMTP port. However, the
2335 &%-oX%& option can be used to run an Exim daemon that listens on some other
2336 port, or &'inetd'& can be used to do this. The &%-bh%& option and the
2337 &'exim_checkaccess'& utility can be used to check out policy controls on
2338 incoming SMTP mail.
2339
2340 Testing a new version on a system that is already running Exim can most easily
2341 be done by building a binary with a different CONFIGURE_FILE setting. From
2342 within the run time configuration, all other file and directory names
2343 that Exim uses can be altered, in order to keep it entirely clear of the
2344 production version.
2345
2346
2347 .section "Replacing another MTA with Exim"
2348 .cindex "replacing another MTA"
2349 Building and installing Exim for the first time does not of itself put it in
2350 general use. The name by which the system's MTA is called by mail user agents
2351 is either &_/usr/sbin/sendmail_&, or &_/usr/lib/sendmail_& (depending on the
2352 operating system), and it is necessary to make this name point to the &'exim'&
2353 binary in order to get the user agents to pass messages to Exim. This is
2354 normally done by renaming any existing file and making &_/usr/sbin/sendmail_&
2355 or &_/usr/lib/sendmail_&
2356 .cindex "symbolic link" "to &'exim'& binary"
2357 a symbolic link to the &'exim'& binary. It is a good idea to remove any setuid
2358 privilege and executable status from the old MTA. It is then necessary to stop
2359 and restart the mailer daemon, if one is running.
2360
2361 .cindex "FreeBSD" "MTA indirection"
2362 .cindex "&_/etc/mail/mailer.conf_&"
2363 Some operating systems have introduced alternative ways of switching MTAs. For
2364 example, if you are running FreeBSD, you need to edit the file
2365 &_/etc/mail/mailer.conf_& instead of setting up a symbolic link as just
2366 described. A typical example of the contents of this file for running Exim is
2367 as follows:
2368 .code
2369 sendmail            /usr/exim/bin/exim
2370 send-mail           /usr/exim/bin/exim
2371 mailq               /usr/exim/bin/exim -bp
2372 newaliases          /usr/bin/true
2373 .endd
2374 Once you have set up the symbolic link, or edited &_/etc/mail/mailer.conf_&,
2375 your Exim installation is &"live"&. Check it by sending a message from your
2376 favourite user agent.
2377
2378 You should consider what to tell your users about the change of MTA. Exim may
2379 have different capabilities to what was previously running, and there are
2380 various operational differences such as the text of messages produced by
2381 command line options and in bounce messages. If you allow your users to make
2382 use of Exim's filtering capabilities, you should make the document entitled
2383 &'Exim's interface to mail filtering'& available to them.
2384
2385
2386
2387 .section "Upgrading Exim"
2388 .cindex "upgrading Exim"
2389 If you are already running Exim on your host, building and installing a new
2390 version automatically makes it available to MUAs, or any other programs that
2391 call the MTA directly. However, if you are running an Exim daemon, you do need
2392 to send it a HUP signal, to make it re-execute itself, and thereby pick up the
2393 new binary. You do not need to stop processing mail in order to install a new
2394 version of Exim. The install script does not modify an existing runtime
2395 configuration file.
2396
2397
2398
2399
2400 .section "Stopping the Exim daemon on Solaris"
2401 .cindex "Solaris" "stopping Exim on"
2402 The standard command for stopping the mailer daemon on Solaris is
2403 .code
2404 /etc/init.d/sendmail stop
2405 .endd
2406 If &_/usr/lib/sendmail_& has been turned into a symbolic link, this script
2407 fails to stop Exim because it uses the command &'ps -e'& and greps the output
2408 for the text &"sendmail"&; this is not present because the actual program name
2409 (that is, &"exim"&) is given by the &'ps'& command with these options. A
2410 solution is to replace the line that finds the process id with something like
2411 .code
2412 pid=`cat /var/spool/exim/exim-daemon.pid`
2413 .endd
2414 to obtain the daemon's pid directly from the file that Exim saves it in.
2415
2416 Note, however, that stopping the daemon does not &"stop Exim"&. Messages can
2417 still be received from local processes, and if automatic delivery is configured
2418 (the normal case), deliveries will still occur.
2419
2420
2421
2422
2423 . ////////////////////////////////////////////////////////////////////////////
2424 . ////////////////////////////////////////////////////////////////////////////
2425
2426 .chapter "The Exim command line" "CHAPcommandline"
2427 .scindex IIDclo1 "command line" "options"
2428 .scindex IIDclo2 "options" "command line"
2429 Exim's command line takes the standard Unix form of a sequence of options,
2430 each starting with a hyphen character, followed by a number of arguments. The
2431 options are compatible with the main options of Sendmail, and there are also
2432 some additional options, some of which are compatible with Smail 3. Certain
2433 combinations of options do not make sense, and provoke an error if used.
2434 The form of the arguments depends on which options are set.
2435
2436
2437 .section "Setting options by program name"
2438 .cindex "&'mailq'&"
2439 If Exim is called under the name &'mailq'&, it behaves as if the option &%-bp%&
2440 were present before any other options.
2441 The &%-bp%& option requests a listing of the contents of the mail queue on the
2442 standard output.
2443 This feature is for compatibility with some systems that contain a command of
2444 that name in one of the standard libraries, symbolically linked to
2445 &_/usr/sbin/sendmail_& or &_/usr/lib/sendmail_&.
2446
2447 .cindex "&'rsmtp'&"
2448 If Exim is called under the name &'rsmtp'& it behaves as if the option &%-bS%&
2449 were present before any other options, for compatibility with Smail. The
2450 &%-bS%& option is used for reading in a number of messages in batched SMTP
2451 format.
2452
2453 .cindex "&'rmail'&"
2454 If Exim is called under the name &'rmail'& it behaves as if the &%-i%& and
2455 &%-oee%& options were present before any other options, for compatibility with
2456 Smail. The name &'rmail'& is used as an interface by some UUCP systems.
2457
2458 .cindex "&'runq'&"
2459 .cindex "queue runner"
2460 If Exim is called under the name &'runq'& it behaves as if the option &%-q%&
2461 were present before any other options, for compatibility with Smail. The &%-q%&
2462 option causes a single queue runner process to be started.
2463
2464 .cindex "&'newaliases'&"
2465 .cindex "alias file" "building"
2466 .cindex "Sendmail compatibility" "calling Exim as &'newaliases'&"
2467 If Exim is called under the name &'newaliases'& it behaves as if the option
2468 &%-bi%& were present before any other options, for compatibility with Sendmail.
2469 This option is used for rebuilding Sendmail's alias file. Exim does not have
2470 the concept of a single alias file, but can be configured to run a given
2471 command if called with the &%-bi%& option.
2472
2473
2474 .section "Trusted and admin users" "SECTtrustedadmin"
2475 Some Exim options are available only to &'trusted users'& and others are
2476 available only to &'admin users'&. In the description below, the phrases &"Exim
2477 user"& and &"Exim group"& mean the user and group defined by EXIM_USER and
2478 EXIM_GROUP in &_Local/Makefile_& or set by the &%exim_user%& and
2479 &%exim_group%& options. These do not necessarily have to use the name &"exim"&.
2480
2481 .ilist
2482 .cindex "trusted user" "definition of"
2483 .cindex "user" "trusted definition of"
2484 The trusted users are root, the Exim user, any user listed in the
2485 &%trusted_users%& configuration option, and any user whose current group or any
2486 supplementary group is one of those listed in the &%trusted_groups%&
2487 configuration option. Note that the Exim group is not automatically trusted.
2488
2489 .cindex '&"From"& line'
2490 .cindex "envelope sender"
2491 Trusted users are always permitted to use the &%-f%& option or a leading
2492 &"From&~"& line to specify the envelope sender of a message that is passed to
2493 Exim through the local interface (see the &%-bm%& and &%-f%& options below).
2494 See the &%untrusted_set_sender%& option for a way of permitting non-trusted
2495 users to set envelope senders.
2496
2497 .cindex "&'From:'& header line"
2498 .cindex "&'Sender:'& header line"
2499 For a trusted user, there is never any check on the contents of the &'From:'&
2500 header line, and a &'Sender:'& line is never added. Furthermore, any existing
2501 &'Sender:'& line in incoming local (non-TCP/IP) messages is not removed.
2502
2503 Trusted users may also specify a host name, host address, interface address,
2504 protocol name, ident value, and authentication data when submitting a message
2505 locally. Thus, they are able to insert messages into Exim's queue locally that
2506 have the characteristics of messages received from a remote host. Untrusted
2507 users may in some circumstances use &%-f%&, but can never set the other values
2508 that are available to trusted users.
2509 .next
2510 .cindex "user" "admin definition of"
2511 .cindex "admin user" "definition of"
2512 The admin users are root, the Exim user, and any user that is a member of the
2513 Exim group or of any group listed in the &%admin_groups%& configuration option.
2514 The current group does not have to be one of these groups.
2515
2516 Admin users are permitted to list the queue, and to carry out certain
2517 operations on messages, for example, to force delivery failures. It is also
2518 necessary to be an admin user in order to see the full information provided by
2519 the Exim monitor, and full debugging output.
2520
2521 By default, the use of the &%-M%&, &%-q%&, &%-R%&, and &%-S%& options to cause
2522 Exim to attempt delivery of messages on its queue is restricted to admin users.
2523 However, this restriction can be relaxed by setting the &%prod_requires_admin%&
2524 option false (that is, specifying &%no_prod_requires_admin%&).
2525
2526 Similarly, the use of the &%-bp%& option to list all the messages in the queue
2527 is restricted to admin users unless &%queue_list_requires_admin%& is set
2528 false.
2529 .endlist
2530
2531
2532 &*Warning*&: If you configure your system so that admin users are able to
2533 edit Exim's configuration file, you are giving those users an easy way of
2534 getting root. There is further discussion of this issue at the start of chapter
2535 &<<CHAPconf>>&.
2536
2537
2538
2539
2540 .section "Command line options"
2541 Exim's command line options are described in alphabetical order below. If none
2542 of the options that specifies a specific action (such as starting the daemon or
2543 a queue runner, or testing an address, or receiving a message in a specific
2544 format, or listing the queue) are present, and there is at least one argument
2545 on the command line, &%-bm%& (accept a local message on the standard input,
2546 with the arguments specifying the recipients) is assumed. Otherwise, Exim
2547 outputs a brief message about itself and exits.
2548
2549 . ////////////////////////////////////////////////////////////////////////////
2550 . Insert a stylized XML comment here, to identify the start of the command line
2551 . options. This is for the benefit of the Perl script that automatically
2552 . creates a man page for the options.
2553 . ////////////////////////////////////////////////////////////////////////////
2554
2555 .literal xml
2556 <!-- === Start of command line options === -->
2557 .literal off
2558
2559
2560 .vlist
2561 .vitem &%--%&
2562 .oindex "--"
2563 .cindex "options" "command line; terminating"
2564 This is a pseudo-option whose only purpose is to terminate the options and
2565 therefore to cause subsequent command line items to be treated as arguments
2566 rather than options, even if they begin with hyphens.
2567
2568 .vitem &%--help%&
2569 .oindex "&%--help%&"
2570 This option causes Exim to output a few sentences stating what it is.
2571 The same output is generated if the Exim binary is called with no options and
2572 no arguments.
2573
2574 .vitem &%-B%&<&'type'&>
2575 .oindex "&%-B%&"
2576 .cindex "8-bit characters"
2577 .cindex "Sendmail compatibility" "8-bit characters"
2578 This is a Sendmail option for selecting 7 or 8 bit processing. Exim is 8-bit
2579 clean; it ignores this option.
2580
2581 .vitem &%-bd%&
2582 .oindex "&%-bd%&"
2583 .cindex "daemon"
2584 .cindex "SMTP listener"
2585 .cindex "queue runner"
2586 This option runs Exim as a daemon, awaiting incoming SMTP connections. Usually
2587 the &%-bd%& option is combined with the &%-q%&<&'time'&> option, to specify
2588 that the daemon should also initiate periodic queue runs.
2589
2590 The &%-bd%& option can be used only by an admin user. If either of the &%-d%&
2591 (debugging) or &%-v%& (verifying) options are set, the daemon does not
2592 disconnect from the controlling terminal. When running this way, it can be
2593 stopped by pressing ctrl-C.
2594
2595 By default, Exim listens for incoming connections to the standard SMTP port on
2596 all the host's running interfaces. However, it is possible to listen on other
2597 ports, on multiple ports, and only on specific interfaces. Chapter
2598 &<<CHAPinterfaces>>& contains a description of the options that control this.
2599
2600 When a listening daemon
2601 .cindex "daemon" "process id (pid)"
2602 .cindex "pid (process id)" "of daemon"
2603 is started without the use of &%-oX%& (that is, without overriding the normal
2604 configuration), it writes its process id to a file called &_exim-daemon.pid_&
2605 in Exim's spool directory. This location can be overridden by setting
2606 PID_FILE_PATH in &_Local/Makefile_&. The file is written while Exim is still
2607 running as root.
2608
2609 When &%-oX%& is used on the command line to start a listening daemon, the
2610 process id is not written to the normal pid file path. However, &%-oP%& can be
2611 used to specify a path on the command line if a pid file is required.
2612
2613 The SIGHUP signal
2614 .cindex "SIGHUP"
2615 .cindex "daemon" "restarting"
2616 can be used to cause the daemon to re-execute itself. This should be done
2617 whenever Exim's configuration file, or any file that is incorporated into it by
2618 means of the &%.include%& facility, is changed, and also whenever a new version
2619 of Exim is installed. It is not necessary to do this when other files that are
2620 referenced from the configuration (for example, alias files) are changed,
2621 because these are reread each time they are used.
2622
2623 .vitem &%-bdf%&
2624 .oindex "&%-bdf%&"
2625 This option has the same effect as &%-bd%& except that it never disconnects
2626 from the controlling terminal, even when no debugging is specified.
2627
2628 .vitem &%-be%&
2629 .oindex "&%-be%&"
2630 .cindex "testing" "string expansion"
2631 .cindex "expansion" "testing"
2632 Run Exim in expansion testing mode. Exim discards its root privilege, to
2633 prevent ordinary users from using this mode to read otherwise inaccessible
2634 files. If no arguments are given, Exim runs interactively, prompting for lines
2635 of data. Otherwise, it processes each argument in turn.
2636
2637 If Exim was built with USE_READLINE=yes in &_Local/Makefile_&, it tries
2638 to load the &%libreadline%& library dynamically whenever the &%-be%& option is
2639 used without command line arguments. If successful, it uses the &[readline()]&
2640 function, which provides extensive line-editing facilities, for reading the
2641 test data. A line history is supported.
2642
2643 Long expansion expressions can be split over several lines by using backslash
2644 continuations. As in Exim's run time configuration, white space at the start of
2645 continuation lines is ignored. Each argument or data line is passed through the
2646 string expansion mechanism, and the result is output. Variable values from the
2647 configuration file (for example, &$qualify_domain$&) are available, but no
2648 message-specific values (such as &$sender_domain$&) are set, because no message
2649 is being processed &new("(but see &%-bem%& and &%-Mset%&)").
2650
2651 &*Note*&: If you use this mechanism to test lookups, and you change the data
2652 files or databases you are using, you must exit and restart Exim before trying
2653 the same lookup again. Otherwise, because each Exim process caches the results
2654 of lookups, you will just get the same result as before.
2655
2656 .new
2657 .vitem &%-bem%&&~<&'filename'&>
2658 .oindex "&%-bem%&"
2659 .cindex "testing" "string expansion"
2660 .cindex "expansion" "testing"
2661 This option operates like &%-be%& except that it must be followed by the name
2662 of a file. For example:
2663 .code
2664 exim -bem /tmp/testmessage
2665 .endd
2666 The file is read as a message (as if receiving a locally-submitted non-SMTP
2667 message) before any of the test expansions are done. Thus, message-specific
2668 variables such as &$message_size$& and &$header_from:$& are available. However,
2669 no &'Received:'& header is added to the message. If the &%-t%& option is set,
2670 recipients are read from the headers in the normal way, and are shown in the
2671 &$recipients$& variable. Note that recipients cannot be given on the command
2672 line, because further arguments are taken as strings to expand (just like
2673 &%-be%&).
2674 .wen
2675
2676 .vitem &%-bF%&&~<&'filename'&>
2677 .oindex "&%-bF%&"
2678 .cindex "system filter" "testing"
2679 .cindex "testing" "system filter"
2680 This option is the same as &%-bf%& except that it assumes that the filter being
2681 tested is a system filter. The additional commands that are available only in
2682 system filters are recognized.
2683
2684 .vitem &%-bf%&&~<&'filename'&>
2685 .oindex "&%-bf%&"
2686 .cindex "filter" "testing"
2687 .cindex "testing" "filter file"
2688 .cindex "forward file" "testing"
2689 .cindex "testing" "forward file"
2690 .cindex "Sieve filter" "testing"
2691 This option runs Exim in user filter testing mode; the file is the filter file
2692 to be tested, and a test message must be supplied on the standard input. If
2693 there are no message-dependent tests in the filter, an empty file can be
2694 supplied.
2695
2696 If you want to test a system filter file, use &%-bF%& instead of &%-bf%&. You
2697 can use both &%-bF%& and &%-bf%& on the same command, in order to test a system
2698 filter and a user filter in the same run. For example:
2699 .code
2700 exim -bF /system/filter -bf /user/filter </test/message
2701 .endd
2702 This is helpful when the system filter adds header lines or sets filter
2703 variables that are used by the user filter.
2704
2705 If the test filter file does not begin with one of the special lines
2706 .code
2707 # Exim filter
2708 # Sieve filter
2709 .endd
2710 it is taken to be a normal &_.forward_& file, and is tested for validity under
2711 that interpretation. See sections &<<SECTitenonfilred>>& to
2712 &<<SECTspecitredli>>& for a description of the possible contents of non-filter
2713 redirection lists.
2714
2715 The result of an Exim command that uses &%-bf%&, provided no errors are
2716 detected, is a list of the actions that Exim would try to take if presented
2717 with the message for real. More details of filter testing are given in the
2718 separate document entitled &'Exim's interfaces to mail filtering'&.
2719
2720 When testing a filter file,
2721 .cindex "&""From""& line"
2722 .cindex "envelope sender"
2723 .cindex "&%-f%& option" "for filter testing"
2724 the envelope sender can be set by the &%-f%& option,
2725 or by a &"From&~"& line at the start of the test message. Various parameters
2726 that would normally be taken from the envelope recipient address of the message
2727 can be set by means of additional command line options (see the next four
2728 options).
2729
2730 .vitem &%-bfd%&&~<&'domain'&>
2731 .oindex "&%-bfd%&"
2732 .cindex "&$qualify_domain$&"
2733 This sets the domain of the recipient address when a filter file is being
2734 tested by means of the &%-bf%& option. The default is the value of
2735 &$qualify_domain$&.
2736
2737 .vitem &%-bfl%&&~<&'local&~part'&>
2738 .oindex "&%-bfl%&"
2739 This sets the local part of the recipient address when a filter file is being
2740 tested by means of the &%-bf%& option. The default is the username of the
2741 process that calls Exim. A local part should be specified with any prefix or
2742 suffix stripped, because that is how it appears to the filter when a message is
2743 actually being delivered.
2744
2745 .vitem &%-bfp%&&~<&'prefix'&>
2746 .oindex "&%-bfp%&"
2747 This sets the prefix of the local part of the recipient address when a filter
2748 file is being tested by means of the &%-bf%& option. The default is an empty
2749 prefix.
2750
2751 .vitem &%-bfs%&&~<&'suffix'&>
2752 .oindex "&%-bfs%&"
2753 This sets the suffix of the local part of the recipient address when a filter
2754 file is being tested by means of the &%-bf%& option. The default is an empty
2755 suffix.
2756
2757 .vitem &%-bh%&&~<&'IP&~address'&>
2758 .oindex "&%-bh%&"
2759 .cindex "testing" "incoming SMTP"
2760 .cindex "SMTP" "testing incoming"
2761 .cindex "testing" "relay control"
2762 .cindex "relaying" "testing configuration"
2763 .cindex "policy control" "testing"
2764 .cindex "debugging" "&%-bh%& option"
2765 This option runs a fake SMTP session as if from the given IP address, using the
2766 standard input and output. The IP address may include a port number at the end,
2767 after a full stop. For example:
2768 .code
2769 exim -bh 10.9.8.7.1234
2770 exim -bh fe80::a00:20ff:fe86:a061.5678
2771 .endd
2772 When an IPv6 address is given, it is converted into canonical form. In the case
2773 of the second example above, the value of &$sender_host_address$& after
2774 conversion to the canonical form is
2775 &`fe80:0000:0000:0a00:20ff:fe86:a061.5678`&.
2776
2777 Comments as to what is going on are written to the standard error file. These
2778 include lines beginning with &"LOG"& for anything that would have been logged.
2779 This facility is provided for testing configuration options for incoming
2780 messages, to make sure they implement the required policy. For example, you can
2781 test your relay controls using &%-bh%&.
2782
2783 &*Warning 1*&:
2784 .cindex "RFC 1413"
2785 You can test features of the configuration that rely on ident (RFC 1413)
2786 information by using the &%-oMt%& option. However, Exim cannot actually perform
2787 an ident callout when testing using &%-bh%& because there is no incoming SMTP
2788 connection.
2789
2790 &*Warning 2*&: Address verification callouts (see section &<<SECTcallver>>&)
2791 are also skipped when testing using &%-bh%&. If you want these callouts to
2792 occur, use &%-bhc%& instead.
2793
2794 Messages supplied during the testing session are discarded, and nothing is
2795 written to any of the real log files. There may be pauses when DNS (and other)
2796 lookups are taking place, and of course these may time out. The &%-oMi%& option
2797 can be used to specify a specific IP interface and port if this is important,
2798 and &%-oMaa%& and &%-oMai%& can be used to set parameters as if the SMTP
2799 session were authenticated.
2800
2801 The &'exim_checkaccess'& utility is a &"packaged"& version of &%-bh%& whose
2802 output just states whether a given recipient address from a given host is
2803 acceptable or not. See section &<<SECTcheckaccess>>&.
2804
2805 .new
2806 Features such as authentication and encryption, where the client input is not
2807 plain text, are most easily tested using specialized SMTP test programs such as
2808 &url(http://jetmore.org/john/code/#swaks,swaks).
2809 .wen
2810
2811 .vitem &%-bhc%&&~<&'IP&~address'&>
2812 .oindex "&%-bhc%&"
2813 This option operates in the same way as &%-bh%&, except that address
2814 verification callouts are performed if required. This includes consulting and
2815 updating the callout cache database.
2816
2817 .vitem &%-bi%&
2818 .oindex "&%-bi%&"
2819 .cindex "alias file" "building"
2820 .cindex "building alias file"
2821 .cindex "Sendmail compatibility" "&%-bi%& option"
2822 Sendmail interprets the &%-bi%& option as a request to rebuild its alias file.
2823 Exim does not have the concept of a single alias file, and so it cannot mimic
2824 this behaviour. However, calls to &_/usr/lib/sendmail_& with the &%-bi%& option
2825 tend to appear in various scripts such as NIS make files, so the option must be
2826 recognized.
2827
2828 If &%-bi%& is encountered, the command specified by the &%bi_command%&
2829 configuration option is run, under the uid and gid of the caller of Exim. If
2830 the &%-oA%& option is used, its value is passed to the command as an argument.
2831 The command set by &%bi_command%& may not contain arguments. The command can
2832 use the &'exim_dbmbuild'& utility, or some other means, to rebuild alias files
2833 if this is required. If the &%bi_command%& option is not set, calling Exim with
2834 &%-bi%& is a no-op.
2835
2836 .vitem &%-bm%&
2837 .oindex "&%-bm%&"
2838 .cindex "local message reception"
2839 This option runs an Exim receiving process that accepts an incoming,
2840 locally-generated message on the current input. The recipients are given as the
2841 command arguments (except when &%-t%& is also present &-- see below). Each
2842 argument can be a comma-separated list of RFC 2822 addresses. This is the
2843 default option for selecting the overall action of an Exim call; it is assumed
2844 if no other conflicting option is present.
2845
2846 If any addresses in the message are unqualified (have no domain), they are
2847 qualified by the values of the &%qualify_domain%& or &%qualify_recipient%&
2848 options, as appropriate. The &%-bnq%& option (see below) provides a way of
2849 suppressing this for special cases.
2850
2851 Policy checks on the contents of local messages can be enforced by means of
2852 the non-SMTP ACL. See chapter &<<CHAPACL>>& for details.
2853
2854 .cindex "return code" "for &%-bm%&"
2855 The return code is zero if the message is successfully accepted. Otherwise, the
2856 action is controlled by the &%-oe%&&'x'& option setting &-- see below.
2857
2858 The format
2859 .cindex "message" "format"
2860 .cindex "format" "message"
2861 .cindex "&""From""& line"
2862 .cindex "UUCP" "&""From""& line"
2863 .cindex "Sendmail compatibility" "&""From""& line"
2864 of the message must be as defined in RFC 2822, except that, for
2865 compatibility with Sendmail and Smail, a line in one of the forms
2866 .code
2867 From sender Fri Jan  5 12:55 GMT 1997
2868 From sender Fri, 5 Jan 97 12:55:01
2869 .endd
2870 (with the weekday optional, and possibly with additional text after the date)
2871 is permitted to appear at the start of the message. There appears to be no
2872 authoritative specification of the format of this line. Exim recognizes it by
2873 matching against the regular expression defined by the &%uucp_from_pattern%&
2874 option, which can be changed if necessary.
2875
2876 The
2877 .cindex "&%-f%& option" "overriding &""From""& line"
2878 specified sender is treated as if it were given as the argument to the
2879 &%-f%& option, but if a &%-f%& option is also present, its argument is used in
2880 preference to the address taken from the message. The caller of Exim must be a
2881 trusted user for the sender of a message to be set in this way.
2882
2883 .vitem &%-bnq%&
2884 .oindex "&%-bnq%&"
2885 .cindex "address qualification" "suppressing"
2886 By default, Exim automatically qualifies unqualified addresses (those
2887 without domains) that appear in messages that are submitted locally (that
2888 is, not over TCP/IP). This qualification applies both to addresses in
2889 envelopes, and addresses in header lines. Sender addresses are qualified using
2890 &%qualify_domain%&, and recipient addresses using &%qualify_recipient%& (which
2891 defaults to the value of &%qualify_domain%&).
2892
2893 Sometimes, qualification is not wanted. For example, if &%-bS%& (batch SMTP) is
2894 being used to re-submit messages that originally came from remote hosts after
2895 content scanning, you probably do not want to qualify unqualified addresses in
2896 header lines. (Such lines will be present only if you have not enabled a header
2897 syntax check in the appropriate ACL.)
2898
2899 The &%-bnq%& option suppresses all qualification of unqualified addresses in
2900 messages that originate on the local host. When this is used, unqualified
2901 addresses in the envelope provoke errors (causing message rejection) and
2902 unqualified addresses in header lines are left alone.
2903
2904
2905 .vitem &%-bP%&
2906 .oindex "&%-bP%&"
2907 .cindex "configuration options" "extracting"
2908 .cindex "options" "configuration &-- extracting"
2909 If this option is given with no arguments, it causes the values of all Exim's
2910 main configuration options to be written to the standard output. The values
2911 of one or more specific options can be requested by giving their names as
2912 arguments, for example:
2913 .code
2914 exim -bP qualify_domain hold_domains
2915 .endd
2916 However, any option setting that is preceded by the word &"hide"& in the
2917 configuration file is not shown in full, except to an admin user. For other
2918 users, the output is as in this example:
2919 .code
2920 mysql_servers = <value not displayable>
2921 .endd
2922 If &%configure_file%& is given as an argument, the name of the run time
2923 configuration file is output.
2924 If a list of configuration files was supplied, the value that is output here
2925 is the name of the file that was actually used.
2926
2927 .cindex "daemon" "process id (pid)"
2928 .cindex "pid (process id)" "of daemon"
2929 If &%log_file_path%& or &%pid_file_path%& are given, the names of the
2930 directories where log files and daemon pid files are written are output,
2931 respectively. If these values are unset, log files are written in a
2932 sub-directory of the spool directory called &%log%&, and the pid file is
2933 written directly into the spool directory.
2934
2935 If &%-bP%& is followed by a name preceded by &`+`&, for example,
2936 .code
2937 exim -bP +local_domains
2938 .endd
2939 it searches for a matching named list of any type (domain, host, address, or
2940 local part) and outputs what it finds.
2941
2942 .cindex "options" "router &-- extracting"
2943 .cindex "options" "transport &-- extracting"
2944 If one of the words &%router%&, &%transport%&, or &%authenticator%& is given,
2945 followed by the name of an appropriate driver instance, the option settings for
2946 that driver are output. For example:
2947 .code
2948 exim -bP transport local_delivery
2949 .endd
2950 The generic driver options are output first, followed by the driver's private
2951 options. A list of the names of drivers of a particular type can be obtained by
2952 using one of the words &%router_list%&, &%transport_list%&, or
2953 &%authenticator_list%&, and a complete list of all drivers with their option
2954 settings can be obtained by using &%routers%&, &%transports%&, or
2955 &%authenticators%&.
2956
2957
2958 .vitem &%-bp%&
2959 .oindex "&%-bp%&"
2960 .cindex "queue" "listing messages on"
2961 .cindex "listing" "messages on the queue"
2962 This option requests a listing of the contents of the mail queue on the
2963 standard output. If the &%-bp%& option is followed by a list of message ids,
2964 just those messages are listed. By default, this option can be used only by an
2965 admin user. However, the &%queue_list_requires_admin%& option can be set false
2966 to allow any user to see the queue.
2967
2968 Each message on the queue is displayed as in the following example:
2969 .code
2970 25m  2.9K 0t5C6f-0000c8-00 <alice@wonderland.fict.example>
2971           red.king@looking-glass.fict.example
2972           <other addresses>
2973 .endd
2974 .cindex "message" "size in queue listing"
2975 .cindex "size" "of message"
2976 The first line contains the length of time the message has been on the queue
2977 (in this case 25 minutes), the size of the message (2.9K), the unique local
2978 identifier for the message, and the message sender, as contained in the
2979 envelope. For bounce messages, the sender address is empty, and appears as
2980 &"<>"&. If the message was submitted locally by an untrusted user who overrode
2981 the default sender address, the user's login name is shown in parentheses
2982 before the sender address.
2983
2984 .cindex "frozen messages" "in queue listing"
2985 If the message is frozen (attempts to deliver it are suspended) then the text
2986 &"*** frozen ***"& is displayed at the end of this line.
2987
2988 The recipients of the message (taken from the envelope, not the headers) are
2989 displayed on subsequent lines. Those addresses to which the message has already
2990 been delivered are marked with the letter D. If an original address gets
2991 expanded into several addresses via an alias or forward file, the original is
2992 displayed with a D only when deliveries for all of its child addresses are
2993 complete.
2994
2995
2996 .vitem &%-bpa%&
2997 .oindex "&%-bpa%&"
2998 This option operates like &%-bp%&, but in addition it shows delivered addresses
2999 that were generated from the original top level address(es) in each message by
3000 alias or forwarding operations. These addresses are flagged with &"+D"& instead
3001 of just &"D"&.
3002
3003
3004 .vitem &%-bpc%&
3005 .oindex "&%-bpc%&"
3006 .cindex "queue" "count of messages on"
3007 This option counts the number of messages on the queue, and writes the total
3008 to the standard output. It is restricted to admin users, unless
3009 &%queue_list_requires_admin%& is set false.
3010
3011
3012 .vitem &%-bpr%&
3013 .oindex "&%-bpr%&"
3014 This option operates like &%-bp%&, but the output is not sorted into
3015 chronological order of message arrival. This can speed it up when there are
3016 lots of messages on the queue, and is particularly useful if the output is
3017 going to be post-processed in a way that doesn't need the sorting.
3018
3019 .vitem &%-bpra%&
3020 .oindex "&%-bpra%&"
3021 This option is a combination of &%-bpr%& and &%-bpa%&.
3022
3023 .vitem &%-bpru%&
3024 .oindex "&%-bpru%&"
3025 This option is a combination of &%-bpr%& and &%-bpu%&.
3026
3027
3028 .vitem &%-bpu%&
3029 .oindex "&%-bpu%&"
3030 This option operates like &%-bp%& but shows only undelivered top-level
3031 addresses for each message displayed. Addresses generated by aliasing or
3032 forwarding are not shown, unless the message was deferred after processing by a
3033 router with the &%one_time%& option set.
3034
3035
3036 .vitem &%-brt%&
3037 .oindex "&%-brt%&"
3038 .cindex "testing" "retry configuration"
3039 .cindex "retry" "configuration testing"
3040 This option is for testing retry rules, and it must be followed by up to three
3041 arguments. It causes Exim to look for a retry rule that matches the values
3042 and to write it to the standard output. For example:
3043 .code
3044 exim -brt bach.comp.mus.example
3045 Retry rule: *.comp.mus.example  F,2h,15m; F,4d,30m;
3046 .endd
3047 See chapter &<<CHAPretry>>& for a description of Exim's retry rules. The first
3048 argument, which is required, can be a complete address in the form
3049 &'local_part@domain'&, or it can be just a domain name. If the second argument
3050 contains a dot, it is interpreted as an optional second domain name; if no
3051 retry rule is found for the first argument, the second is tried. This ties in
3052 with Exim's behaviour when looking for retry rules for remote hosts &-- if no
3053 rule is found that matches the host, one that matches the mail domain is
3054 sought. Finally, an argument that is the name of a specific delivery error, as
3055 used in setting up retry rules, can be given. For example:
3056 .code
3057 exim -brt haydn.comp.mus.example quota_3d
3058 Retry rule: *@haydn.comp.mus.example quota_3d  F,1h,15m
3059 .endd
3060
3061 .vitem &%-brw%&
3062 .oindex "&%-brw%&"
3063 .cindex "testing" "rewriting"
3064 .cindex "rewriting" "testing"
3065 This option is for testing address rewriting rules, and it must be followed by
3066 a single argument, consisting of either a local part without a domain, or a
3067 complete address with a fully qualified domain. Exim outputs how this address
3068 would be rewritten for each possible place it might appear. See chapter
3069 &<<CHAPrewrite>>& for further details.
3070
3071 .vitem &%-bS%&
3072 .oindex "&%-bS%&"
3073 .cindex "SMTP" "batched incoming"
3074 .cindex "batched SMTP input"
3075 This option is used for batched SMTP input, which is an alternative interface
3076 for non-interactive local message submission. A number of messages can be
3077 submitted in a single run. However, despite its name, this is not really SMTP
3078 input. Exim reads each message's envelope from SMTP commands on the standard
3079 input, but generates no responses. If the caller is trusted, or
3080 &%untrusted_set_sender%& is set, the senders in the SMTP MAIL commands are
3081 believed; otherwise the sender is always the caller of Exim.
3082
3083 The message itself is read from the standard input, in SMTP format (leading
3084 dots doubled), terminated by a line containing just a single dot. An error is
3085 provoked if the terminating dot is missing. A further message may then follow.
3086
3087 As for other local message submissions, the contents of incoming batch SMTP
3088 messages can be checked using the non-SMTP ACL (see chapter &<<CHAPACL>>&).
3089 Unqualified addresses are automatically qualified using &%qualify_domain%& and
3090 &%qualify_recipient%&, as appropriate, unless the &%-bnq%& option is used.
3091
3092 Some other SMTP commands are recognized in the input. HELO and EHLO act
3093 as RSET; VRFY, EXPN, ETRN, and HELP act as NOOP;
3094 QUIT quits, ignoring the rest of the standard input.
3095
3096 .cindex "return code" "for &%-bS%&"
3097 If any error is encountered, reports are written to the standard output and
3098 error streams, and Exim gives up immediately. The return code is 0 if no error
3099 was detected; it is 1 if one or more messages were accepted before the error
3100 was detected; otherwise it is 2.
3101
3102 More details of input using batched SMTP are given in section
3103 &<<SECTincomingbatchedSMTP>>&.
3104
3105 .vitem &%-bs%&
3106 .oindex "&%-bs%&"
3107 .cindex "SMTP" "local input"
3108 .cindex "local SMTP input"
3109 This option causes Exim to accept one or more messages by reading SMTP commands
3110 on the standard input, and producing SMTP replies on the standard output. SMTP
3111 policy controls, as defined in ACLs (see chapter &<<CHAPACL>>&) are applied.
3112 Some user agents use this interface as a way of passing locally-generated
3113 messages to the MTA.
3114
3115 In
3116 .cindex "sender" "source of"
3117 this usage, if the caller of Exim is trusted, or &%untrusted_set_sender%& is
3118 set, the senders of messages are taken from the SMTP MAIL commands.
3119 Otherwise the content of these commands is ignored and the sender is set up as
3120 the calling user. Unqualified addresses are automatically qualified using
3121 &%qualify_domain%& and &%qualify_recipient%&, as appropriate, unless the
3122 &%-bnq%& option is used.
3123
3124 .cindex "inetd"
3125 The
3126 &%-bs%& option is also used to run Exim from &'inetd'&, as an alternative to
3127 using a listening daemon. Exim can distinguish the two cases by checking
3128 whether the standard input is a TCP/IP socket. When Exim is called from
3129 &'inetd'&, the source of the mail is assumed to be remote, and the comments
3130 above concerning senders and qualification do not apply. In this situation,
3131 Exim behaves in exactly the same way as it does when receiving a message via
3132 the listening daemon.
3133
3134 .vitem &%-bt%&
3135 .oindex "&%-bt%&"
3136 .cindex "testing" "addresses"
3137 .cindex "address" "testing"
3138 This option runs Exim in address testing mode, in which each argument is taken
3139 as an address to be tested for deliverability. The results are written to the
3140 standard output. If a test fails, and the caller is not an admin user, no
3141 details of the failure are output, because these might contain sensitive
3142 information such as usernames and passwords for database lookups.
3143
3144 If no arguments are given, Exim runs in an interactive manner, prompting with a
3145 right angle bracket for addresses to be tested.
3146
3147 Unlike the &%-be%& test option, you cannot arrange for Exim to use the
3148 &[readline()]& function, because it is running as &'root'& and there are
3149 security issues.
3150
3151 Each address is handled as if it were the recipient address of a message
3152 (compare the &%-bv%& option). It is passed to the routers and the result is
3153 written to the standard output. However, any router that has
3154 &%no_address_test%& set is bypassed. This can make &%-bt%& easier to use for
3155 genuine routing tests if your first router passes everything to a scanner
3156 program.
3157
3158 The
3159 .cindex "return code" "for &%-bt%&"
3160 return code is 2 if any address failed outright; it is 1 if no address
3161 failed outright but at least one could not be resolved for some reason. Return
3162 code 0 is given only when all addresses succeed.
3163
3164 .cindex "duplicate addresses"
3165 &*Note*&: When actually delivering a message, Exim removes duplicate recipient
3166 addresses after routing is complete, so that only one delivery takes place.
3167 This does not happen when testing with &%-bt%&; the full results of routing are
3168 always shown.
3169
3170 &*Warning*&: &%-bt%& can only do relatively simple testing. If any of the
3171 routers in the configuration makes any tests on the sender address of a
3172 message,
3173 .cindex "&%-f%& option" "for address testing"
3174 you can use the &%-f%& option to set an appropriate sender when running
3175 &%-bt%& tests. Without it, the sender is assumed to be the calling user at the
3176 default qualifying domain. However, if you have set up (for example) routers
3177 whose behaviour depends on the contents of an incoming message, you cannot test
3178 those conditions using &%-bt%&. The &%-N%& option provides a possible way of
3179 doing such tests.
3180
3181 .vitem &%-bV%&
3182 .oindex "&%-bV%&"
3183 .cindex "version number of Exim" "verifying"
3184 This option causes Exim to write the current version number, compilation
3185 number, and compilation date of the &'exim'& binary to the standard output.
3186 It also lists the DBM library this is being used, the optional modules (such as
3187 specific lookup types), the drivers that are included in the binary, and the
3188 name of the run time configuration file that is in use.
3189
3190 As part of its operation, &%-bV%& causes Exim to read and syntax check its
3191 configuration file. However, this is a static check only. It cannot check
3192 values that are to be expanded. For example, although a misspelt ACL verb is
3193 detected, an error in the verb's arguments is not. You cannot rely on &%-bV%&
3194 alone to discover (for example) all the typos in the configuration; some
3195 realistic testing is needed. The &%-bh%& and &%-N%& options provide more
3196 dynamic testing facilities.
3197
3198 .vitem &%-bv%&
3199 .oindex "&%-bv%&"
3200 .cindex "verifying address" "using &%-bv%&"
3201 .cindex "address" "verification"
3202 This option runs Exim in address verification mode, in which each argument is
3203 taken as an address to be verified by the routers. (This does not involve any
3204 verification callouts). During normal operation, verification happens mostly as
3205 a consequence processing a &%verify%& condition in an ACL (see chapter
3206 &<<CHAPACL>>&). If you want to test an entire ACL, possibly including callouts,
3207 see the &%-bh%& and &%-bhc%& options.
3208
3209 If verification fails, and the caller is not an admin user, no details of the
3210 failure are output, because these might contain sensitive information such as
3211 usernames and passwords for database lookups.
3212
3213 If no arguments are given, Exim runs in an interactive manner, prompting with a
3214 right angle bracket for addresses to be verified.
3215
3216 Unlike the &%-be%& test option, you cannot arrange for Exim to use the
3217 &[readline()]& function, because it is running as &'exim'& and there are
3218 security issues.
3219
3220 Verification differs from address testing (the &%-bt%& option) in that routers
3221 that have &%no_verify%& set are skipped, and if the address is accepted by a
3222 router that has &%fail_verify%& set, verification fails. The address is
3223 verified as a recipient if &%-bv%& is used; to test verification for a sender
3224 address, &%-bvs%& should be used.
3225
3226 .new
3227 If the &%-v%& option is not set, the output consists of a single line for each
3228 address, stating whether it was verified or not, and giving a reason in the
3229 latter case. Without &%-v%&, generating more than one address by redirection
3230 causes verification to end successfully, without considering the generated
3231 addresses. However, if just one address is generated, processing continues,
3232 and the generated address must verify successfully for the overall verification
3233 to succeed.
3234
3235 When &%-v%& is set, more details are given of how the address has been handled,
3236 and in the case of address redirection, all the generated addresses are also
3237 considered. Verification may succeed for some and fail for others.
3238 .wen
3239
3240 The
3241 .cindex "return code" "for &%-bv%&"
3242 return code is 2 if any address failed outright; it is 1 if no address
3243 failed outright but at least one could not be resolved for some reason. Return
3244 code 0 is given only when all addresses succeed.
3245
3246 If any of the routers in the configuration makes any tests on the sender
3247 address of a message, you should use the &%-f%& option to set an appropriate
3248 sender when running &%-bv%& tests. Without it, the sender is assumed to be the
3249 calling user at the default qualifying domain.
3250
3251 .vitem &%-bvs%&
3252 .oindex "&%-bvs%&"
3253 This option acts like &%-bv%&, but verifies the address as a sender rather
3254 than a recipient address. This affects any rewriting and qualification that
3255 might happen.
3256
3257 .vitem &%-C%&&~<&'filelist'&>
3258 .oindex "&%-C%&"
3259 .cindex "configuration file" "alternate"
3260 .cindex "CONFIGURE_FILE"
3261 .cindex "alternate configuration file"
3262 This option causes Exim to find the run time configuration file from the given
3263 list instead of from the list specified by the CONFIGURE_FILE
3264 compile-time setting. Usually, the list will consist of just a single file
3265 name, but it can be a colon-separated list of names. In this case, the first
3266 file that exists is used. Failure to open an existing file stops Exim from
3267 proceeding any further along the list, and an error is generated.
3268
3269 When this option is used by a caller other than root or the Exim user, and the
3270 list is different from the compiled-in list, Exim gives up its root privilege
3271 immediately, and runs with the real and effective uid and gid set to those of
3272 the caller. However, if ALT_CONFIG_ROOT_ONLY is defined in
3273 &_Local/Makefile_&, root privilege is retained for &%-C%& only if the caller of
3274 Exim is root.
3275
3276 That is, the Exim user is no longer privileged in this regard. This build-time
3277 option is not set by default in the Exim source distribution tarbundle.
3278 However, if you are using a &"packaged"& version of Exim (source or binary),
3279 the packagers might have enabled it.
3280
3281 Setting ALT_CONFIG_ROOT_ONLY locks out the possibility of testing a
3282 configuration using &%-C%& right through message reception and delivery, even
3283 if the caller is root. The reception works, but by that time, Exim is running
3284 as the Exim user, so when it re-executes to regain privilege for the delivery,
3285 the use of &%-C%& causes privilege to be lost. However, root can test reception
3286 and delivery using two separate commands (one to put a message on the queue,
3287 using &%-odq%&, and another to do the delivery, using &%-M%&).
3288
3289 If ALT_CONFIG_PREFIX is defined &_in Local/Makefile_&, it specifies a
3290 prefix string with which any file named in a &%-C%& command line option
3291 must start. In addition, the file name must not contain the sequence &`/../`&.
3292 However, if the value of the &%-C%& option is identical to the value of
3293 CONFIGURE_FILE in &_Local/Makefile_&, Exim ignores &%-C%& and proceeds as
3294 usual. There is no default setting for ALT_CONFIG_PREFIX; when it is
3295 unset, any file name can be used with &%-C%&.
3296
3297 ALT_CONFIG_PREFIX can be used to confine alternative configuration files
3298 to a directory to which only root has access. This prevents someone who has
3299 broken into the Exim account from running a privileged Exim with an arbitrary
3300 configuration file.
3301
3302 The &%-C%& facility is useful for ensuring that configuration files are
3303 syntactically correct, but cannot be used for test deliveries, unless the
3304 caller is privileged, or unless it is an exotic configuration that does not
3305 require privilege. No check is made on the owner or group of the files
3306 specified by this option.
3307
3308 .vitem &%-D%&<&'macro'&>=<&'value'&>
3309 .oindex "&%-D%&"
3310 .cindex "macro" "setting on command line"
3311 This option can be used to override macro definitions in the configuration file
3312 (see section &<<SECTmacrodefs>>&). However, like &%-C%&, if it is used by an
3313 unprivileged caller, it causes Exim to give up its root privilege.
3314 If DISABLE_D_OPTION is defined in &_Local/Makefile_&, the use of &%-D%& is
3315 completely disabled, and its use causes an immediate error exit.
3316
3317 The entire option (including equals sign if present) must all be within one
3318 command line item. &%-D%& can be used to set the value of a macro to the empty
3319 string, in which case the equals sign is optional. These two commands are
3320 synonymous:
3321 .code
3322 exim -DABC  ...
3323 exim -DABC= ...
3324 .endd
3325 To include spaces in a macro definition item, quotes must be used. If you use
3326 quotes, spaces are permitted around the macro name and the equals sign. For
3327 example:
3328 .code
3329 exim '-D ABC = something' ...
3330 .endd
3331 &%-D%& may be repeated up to 10 times on a command line.
3332
3333 .vitem &%-d%&<&'debug&~options'&>
3334 .oindex "&%-d%&"
3335 .cindex "debugging" "list of selectors"
3336 .cindex "debugging" "&%-d%& option"
3337 This option causes debugging information to be written to the standard
3338 error stream. It is restricted to admin users because debugging output may show
3339 database queries that contain password information. Also, the details of users'
3340 filter files should be protected. &new("If a non-admin user uses &%-d%&, Exim
3341 writes an error message to the standard error stream and exits with a non-zero
3342 return code.")
3343
3344 When &%-d%& is used, &%-v%& is assumed. If &%-d%& is given on its own, a lot of
3345 standard debugging data is output. This can be reduced, or increased to include
3346 some more rarely needed information, by directly following &%-d%& with a string
3347 made up of names preceded by plus or minus characters. These add or remove sets
3348 of debugging data, respectively. For example, &%-d+filter%& adds filter
3349 debugging, whereas &%-d-all+filter%& selects only filter debugging. Note that
3350 no spaces are allowed in the debug setting. The available debugging categories
3351 are:
3352 .display
3353 &`acl            `& ACL interpretation
3354 &`auth           `& authenticators
3355 &`deliver        `& general delivery logic
3356 &`dns            `& DNS lookups (see also resolver)
3357 &`dnsbl          `& DNS black list (aka RBL) code
3358 &`exec           `& arguments for &[execv()]& calls
3359 &`expand         `& detailed debugging for string expansions
3360 &`filter         `& filter handling
3361 &`hints_lookup   `& hints data lookups
3362 &`host_lookup    `& all types of name-to-IP address handling
3363 &`ident          `& ident lookup
3364 &`interface      `& lists of local interfaces
3365 &`lists          `& matching things in lists
3366 &`load           `& system load checks
3367 &`local_scan     `& can be used by &[local_scan()]& (see chapter &&&
3368                     &<<CHAPlocalscan>>&)
3369 &`lookup         `& general lookup code and all lookups
3370 &`memory         `& memory handling
3371 &`pid            `& add pid to debug output lines
3372 &`process_info   `& setting info for the process log
3373 &`queue_run      `& queue runs
3374 &`receive        `& general message reception logic
3375 &`resolver       `& turn on the DNS resolver's debugging output
3376 &`retry          `& retry handling
3377 &`rewrite        `& address rewriting
3378 &`route          `& address routing
3379 &`timestamp      `& add timestamp to debug output lines
3380 &`tls            `& TLS logic
3381 &`transport      `& transports
3382 &`uid            `& changes of uid/gid and looking up uid/gid
3383 &`verify         `& address verification logic
3384 &`all            `& almost all of the above (see below), and also &%-v%&
3385 .endd
3386 The &`all`& option excludes &`memory`& when used as &`+all`&, but includes it
3387 for &`-all`&. The reason for this is that &`+all`& is something that people
3388 tend to use when generating debug output for Exim maintainers. If &`+memory`&
3389 is included, an awful lot of output that is very rarely of interest is
3390 generated, so it now has to be explicitly requested. However, &`-all`& does
3391 turn everything off.
3392
3393 .cindex "resolver" "debugging output"
3394 .cindex "DNS resolver" "debugging output"
3395 The &`resolver`& option produces output only if the DNS resolver was compiled
3396 with DEBUG enabled. This is not the case in some operating systems. Also,
3397 unfortunately, debugging output from the DNS resolver is written to stdout
3398 rather than stderr.
3399
3400 The default (&%-d%& with no argument) omits &`expand`&, &`filter`&,
3401 &`interface`&, &`load`&, &`memory`&, &`pid`&, &`resolver`&, and &`timestamp`&.
3402 However, the &`pid`& selector is forced when debugging is turned on for a
3403 daemon, which then passes it on to any re-executed Exims. Exim also
3404 automatically adds the pid to debug lines when several remote deliveries are
3405 run in parallel.
3406
3407 The &`timestamp`& selector causes the current time to be inserted at the start
3408 of all debug output lines. This can be useful when trying to track down delays
3409 in processing.
3410
3411 If the &%debug_print%& option is set in any driver, it produces output whenever
3412 any debugging is selected, or if &%-v%& is used.
3413
3414 .vitem &%-dd%&<&'debug&~options'&>
3415 .oindex "&%-dd%&"
3416 This option behaves exactly like &%-d%& except when used on a command that
3417 starts a daemon process. In that case, debugging is turned off for the
3418 subprocesses that the daemon creates. Thus, it is useful for monitoring the
3419 behaviour of the daemon without creating as much output as full debugging does.
3420
3421 .vitem &%-dropcr%&
3422 .oindex "&%-dropcr%&"
3423 This is an obsolete option that is now a no-op. It used to affect the way Exim
3424 handled CR and LF characters in incoming messages. What happens now is
3425 described in section &<<SECTlineendings>>&.
3426
3427 .vitem &%-E%&
3428 .oindex "&%-E%&"
3429 .cindex "bounce message" "generating"
3430 This option specifies that an incoming message is a locally-generated delivery
3431 failure report. It is used internally by Exim when handling delivery failures
3432 and is not intended for external use. Its only effect is to stop Exim
3433 generating certain messages to the postmaster, as otherwise message cascades
3434 could occur in some situations. As part of the same option, a message id may
3435 follow the characters &%-E%&. If it does, the log entry for the receipt of the
3436 new message contains the id, following &"R="&, as a cross-reference.
3437
3438 .vitem &%-e%&&'x'&
3439 .oindex "&%-e%&&'x'&"
3440 There are a number of Sendmail options starting with &%-oe%& which seem to be
3441 called by various programs without the leading &%o%& in the option. For
3442 example, the &%vacation%& program uses &%-eq%&. Exim treats all options of the
3443 form &%-e%&&'x'& as synonymous with the corresponding &%-oe%&&'x'& options.
3444
3445 .vitem &%-F%&&~<&'string'&>
3446 .oindex "&%-F%&"
3447 .cindex "sender" "name"
3448 .cindex "name" "of sender"
3449 This option sets the sender's full name for use when a locally-generated
3450 message is being accepted. In the absence of this option, the user's &'gecos'&
3451 entry from the password data is used. As users are generally permitted to alter
3452 their &'gecos'& entries, no security considerations are involved. White space
3453 between &%-F%& and the <&'string'&> is optional.
3454
3455 .vitem &%-f%&&~<&'address'&>
3456 .oindex "&%-f%&"
3457 .cindex "sender" "address"
3458 .cindex "address" "sender"
3459 .cindex "trusted user"
3460 .cindex "envelope sender"
3461 .cindex "user" "trusted"
3462 This option sets the address of the envelope sender of a locally-generated
3463 message (also known as the return path). The option can normally be used only
3464 by a trusted user, but &%untrusted_set_sender%& can be set to allow untrusted
3465 users to use it.
3466
3467 Processes running as root or the Exim user are always trusted. Other
3468 trusted users are defined by the &%trusted_users%& or &%trusted_groups%&
3469 options. In the absence of &%-f%&, or if the caller is not trusted, the sender
3470 of a local message is set to the caller's login name at the default qualify
3471 domain.
3472
3473 There is one exception to the restriction on the use of &%-f%&: an empty sender
3474 can be specified by any user, trusted or not, to create a message that can
3475 never provoke a bounce. An empty sender can be specified either as an empty
3476 string, or as a pair of angle brackets with nothing between them, as in these
3477 examples of shell commands:
3478 .code
3479 exim -f '<>' user@domain
3480 exim -f "" user@domain
3481 .endd
3482 In addition, the use of &%-f%& is not restricted when testing a filter file
3483 with &%-bf%& or when testing or verifying addresses using the &%-bt%& or
3484 &%-bv%& options.
3485
3486 Allowing untrusted users to change the sender address does not of itself make
3487 it possible to send anonymous mail. Exim still checks that the &'From:'& header
3488 refers to the local user, and if it does not, it adds a &'Sender:'& header,
3489 though this can be overridden by setting &%no_local_from_check%&.
3490
3491 White
3492 .cindex "&""From""& line"
3493 space between &%-f%& and the <&'address'&> is optional (that is, they can be
3494 given as two arguments or one combined argument). The sender of a
3495 locally-generated message can also be set (when permitted) by an initial
3496 &"From&~"& line in the message &-- see the description of &%-bm%& above &-- but
3497 if &%-f%& is also present, it overrides &"From&~"&.
3498
3499 .vitem &%-G%&
3500 .oindex "&%-G%&"
3501 .cindex "Sendmail compatibility" "&%-G%& option ignored"
3502 This is a Sendmail option which is ignored by Exim.
3503
3504 .vitem &%-h%&&~<&'number'&>
3505 .oindex "&%-h%&"
3506 .cindex "Sendmail compatibility" "&%-h%& option ignored"
3507 This option is accepted for compatibility with Sendmail, but has no effect. (In
3508 Sendmail it overrides the &"hop count"& obtained by counting &'Received:'&
3509 headers.)
3510
3511 .vitem &%-i%&
3512 .oindex "&%-i%&"
3513 .cindex "Solaris" "&'mail'& command"
3514 .cindex "dot in incoming" "non-SMTP message"
3515 This option, which has the same effect as &%-oi%&, specifies that a dot on a
3516 line by itself should not terminate an incoming, non-SMTP message. I can find
3517 no documentation for this option in Solaris 2.4 Sendmail, but the &'mailx'&
3518 command in Solaris 2.4 uses it. See also &%-ti%&.
3519
3520 .vitem &%-M%&&~<&'message&~id'&>&~<&'message&~id'&>&~...
3521 .oindex "&%-M%&"
3522 .cindex "forcing delivery"
3523 .cindex "delivery" "forcing attempt"
3524 .cindex "frozen messages" "forcing delivery"
3525 This option requests Exim to run a delivery attempt on each message in turn. If
3526 any of the messages are frozen, they are automatically thawed before the
3527 delivery attempt. The settings of &%queue_domains%&, &%queue_smtp_domains%&,
3528 and &%hold_domains%& are ignored.
3529
3530 Retry
3531 .cindex "hints database" "overriding retry hints"
3532 hints for any of the addresses are overridden &-- Exim tries to deliver even if
3533 the normal retry time has not yet been reached. This option requires the caller
3534 to be an admin user. However, there is an option called &%prod_requires_admin%&
3535 which can be set false to relax this restriction (and also the same requirement
3536 for the &%-q%&, &%-R%&, and &%-S%& options).
3537
3538 The deliveries happen synchronously, that is, the original Exim process does
3539 not terminate until all the delivery attempts have finished. No output is
3540 produced unless there is a serious error. If you want to see what is happening,
3541 use the &%-v%& option as well, or inspect Exim's main log.
3542
3543 .vitem &%-Mar%&&~<&'message&~id'&>&~<&'address'&>&~<&'address'&>&~...
3544 .oindex "&%-Mar%&"
3545 .cindex "message" "adding recipients"
3546 .cindex "recipient" "adding"
3547 This option requests Exim to add the addresses to the list of recipients of the
3548 message (&"ar"& for &"add recipients"&). The first argument must be a message
3549 id, and the remaining ones must be email addresses. However, if the message is
3550 active (in the middle of a delivery attempt), it is not altered. This option
3551 can be used only by an admin user.
3552
3553 .vitem "&%-MC%&&~<&'transport'&>&~<&'hostname'&>&~<&'sequence&~number'&>&&&
3554         &~<&'message&~id'&>"
3555 .oindex "&%-MC%&"
3556 .cindex "SMTP" "passed connection"
3557 .cindex "SMTP" "multiple deliveries"
3558 .cindex "multiple SMTP deliveries"
3559 This option is not intended for use by external callers. It is used internally
3560 by Exim to invoke another instance of itself to deliver a waiting message using
3561 an existing SMTP connection, which is passed as the standard input. Details are
3562 given in chapter &<<CHAPSMTP>>&. This must be the final option, and the caller
3563 must be root or the Exim user in order to use it.
3564
3565 .vitem &%-MCA%&
3566 .oindex "&%-MCA%&"
3567 This option is not intended for use by external callers. It is used internally
3568 by Exim in conjunction with the &%-MC%& option. It signifies that the
3569 connection to the remote host has been authenticated.
3570
3571 .vitem &%-MCP%&
3572 .oindex "&%-MCP%&"
3573 This option is not intended for use by external callers. It is used internally
3574 by Exim in conjunction with the &%-MC%& option. It signifies that the server to
3575 which Exim is connected supports pipelining.
3576
3577 .vitem &%-MCQ%&&~<&'process&~id'&>&~<&'pipe&~fd'&>
3578 .oindex "&%-MCQ%&"
3579 This option is not intended for use by external callers. It is used internally
3580 by Exim in conjunction with the &%-MC%& option when the original delivery was
3581 started by a queue runner. It passes on the process id of the queue runner,
3582 together with the file descriptor number of an open pipe. Closure of the pipe
3583 signals the final completion of the sequence of processes that are passing
3584 messages through the same SMTP connection.
3585
3586 .vitem &%-MCS%&
3587 .oindex "&%-MCS%&"
3588 This option is not intended for use by external callers. It is used internally
3589 by Exim in conjunction with the &%-MC%& option, and passes on the fact that the
3590 SMTP SIZE option should be used on messages delivered down the existing
3591 connection.
3592
3593 .vitem &%-MCT%&
3594 .oindex "&%-MCT%&"
3595 This option is not intended for use by external callers. It is used internally
3596 by Exim in conjunction with the &%-MC%& option, and passes on the fact that the
3597 host to which Exim is connected supports TLS encryption.
3598
3599 .vitem &%-Mc%&&~<&'message&~id'&>&~<&'message&~id'&>&~...
3600 .oindex "&%-Mc%&"
3601 .cindex "hints database" "not overridden by &%-Mc%&"
3602 .cindex "delivery" "manually started &-- not forced"
3603 This option requests Exim to run a delivery attempt on each message in turn,
3604 but unlike the &%-M%& option, it does check for retry hints, and respects any
3605 that are found. This option is not very useful to external callers. It is
3606 provided mainly for internal use by Exim when it needs to re-invoke itself in
3607 order to regain root privilege for a delivery (see chapter &<<CHAPsecurity>>&).
3608 However, &%-Mc%& can be useful when testing, in order to run a delivery that
3609 respects retry times and other options such as &%hold_domains%& that are
3610 overridden when &%-M%& is used. Such a delivery does not count as a queue run.
3611 If you want to run a specific delivery as if in a queue run, you should use
3612 &%-q%& with a message id argument. A distinction between queue run deliveries
3613 and other deliveries is made in one or two places.
3614
3615 .vitem &%-Mes%&&~<&'message&~id'&>&~<&'address'&>
3616 .oindex "&%-Mes%&"
3617 .cindex "message" "changing sender"
3618 .cindex "sender" "changing"
3619 This option requests Exim to change the sender address in the message to the
3620 given address, which must be a fully qualified address or &"<>"& (&"es"& for
3621 &"edit sender"&). There must be exactly two arguments. The first argument must
3622 be a message id, and the second one an email address. However, if the message
3623 is active (in the middle of a delivery attempt), its status is not altered.
3624 This option can be used only by an admin user.
3625
3626 .vitem &%-Mf%&&~<&'message&~id'&>&~<&'message&~id'&>&~...
3627 .oindex "&%-Mf%&"
3628 .cindex "freezing messages"
3629 .cindex "message" "manually freezing"
3630 This option requests Exim to mark each listed message as &"frozen"&. This
3631 prevents any delivery attempts taking place until the message is &"thawed"&,
3632 either manually or as a result of the &%auto_thaw%& configuration option.
3633 However, if any of the messages are active (in the middle of a delivery
3634 attempt), their status is not altered. This option can be used only by an admin
3635 user.
3636
3637 .vitem &%-Mg%&&~<&'message&~id'&>&~<&'message&~id'&>&~...
3638 .oindex "&%-Mg%&"
3639 .cindex "giving up on messages"
3640 .cindex "message" "abandoning delivery attempts"
3641 .cindex "delivery" "abandoning further attempts"
3642 This option requests Exim to give up trying to deliver the listed messages,
3643 including any that are frozen. However, if any of the messages are active,
3644 their status is not altered. For non-bounce messages, a delivery error message
3645 is sent to the sender, containing the text &"cancelled by administrator"&.
3646 Bounce messages are just discarded. This option can be used only by an admin
3647 user.
3648
3649 .vitem &%-Mmad%&&~<&'message&~id'&>&~<&'message&~id'&>&~...
3650 .oindex "&%-Mmad%&"
3651 .cindex "delivery" "cancelling all"
3652 This option requests Exim to mark all the recipient addresses in the messages
3653 as already delivered (&"mad"& for &"mark all delivered"&). However, if any
3654 message is active (in the middle of a delivery attempt), its status is not
3655 altered. This option can be used only by an admin user.
3656
3657 .vitem &%-Mmd%&&~<&'message&~id'&>&~<&'address'&>&~<&'address'&>&~...
3658 .oindex "&%-Mmd%&"
3659 .cindex "delivery" "cancelling by address"
3660 .cindex "recipient" "removing"
3661 .cindex "removing recipients"
3662 This option requests Exim to mark the given addresses as already delivered
3663 (&"md"& for &"mark delivered"&). The first argument must be a message id, and
3664 the remaining ones must be email addresses. These are matched to recipient
3665 addresses in the message in a case-sensitive manner. If the message is active
3666 (in the middle of a delivery attempt), its status is not altered. This option
3667 can be used only by an admin user.
3668
3669 .vitem &%-Mrm%&&~<&'message&~id'&>&~<&'message&~id'&>&~...
3670 .oindex "&%-Mrm%&"
3671 .cindex "removing messages"
3672 .cindex "abandoning mail"
3673 .cindex "message" "manually discarding"
3674 This option requests Exim to remove the given messages from the queue. No
3675 bounce messages are sent; each message is simply forgotten. However, if any of
3676 the messages are active, their status is not altered. This option can be used
3677 only by an admin user or by the user who originally caused the message to be
3678 placed on the queue.
3679
3680 .new
3681 .vitem &%-Mset%&&~<&'message&~id'&>
3682 .oindex "&%-Mset%&
3683 .cindex "testing" "string expansion"
3684 .cindex "expansion" "testing"
3685 This option is useful only in conjunction with &%-be%& (that is, when testing
3686 string expansions). Exim loads the given message from its spool before doing
3687 the test expansions, thus setting message-specific variables such as
3688 &$message_size$& and the header variables. The &$recipients$& variable is made
3689 available. This feature is provided to make it easier to test expansions that
3690 make use of these variables. However, this option can be used only by an admin
3691 user. See also &%-bem%&.
3692 .wen
3693
3694 .vitem &%-Mt%&&~<&'message&~id'&>&~<&'message&~id'&>&~...
3695 .oindex "&%-Mt%&"
3696 .cindex "thawing messages"
3697 .cindex "unfreezing messages"
3698 .cindex "frozen messages" "thawing"
3699 .cindex "message" "thawing frozen"
3700 This option requests Exim to &"thaw"& any of the listed messages that are
3701 &"frozen"&, so that delivery attempts can resume. However, if any of the
3702 messages are active, their status is not altered. This option can be used only
3703 by an admin user.
3704
3705 .vitem &%-Mvb%&&~<&'message&~id'&>
3706 .oindex "&%-Mvb%&"
3707 .cindex "listing" "message body"
3708 .cindex "message" "listing body of"
3709 This option causes the contents of the message body (-D) spool file to be
3710 written to the standard output. This option can be used only by an admin user.
3711
3712 .vitem &%-Mvh%&&~<&'message&~id'&>
3713 .oindex "&%-Mvh%&"
3714 .cindex "listing" "message headers"
3715 .cindex "header lines" "listing"
3716 .cindex "message" "listing header lines"
3717 This option causes the contents of the message headers (-H) spool file to be
3718 written to the standard output. This option can be used only by an admin user.
3719
3720 .vitem &%-Mvl%&&~<&'message&~id'&>
3721 .oindex "&%-Mvl%&"
3722 .cindex "listing" "message log"
3723 .cindex "message" "listing message log"
3724 This option causes the contents of the message log spool file to be written to
3725 the standard output. This option can be used only by an admin user.
3726
3727 .vitem &%-m%&
3728 .oindex "&%-m%&"
3729 This is apparently a synonym for &%-om%& that is accepted by Sendmail, so Exim
3730 treats it that way too.
3731
3732 .vitem &%-N%&
3733 .oindex "&%-N%&"
3734 .cindex "debugging" "&%-N%& option"
3735 .cindex "debugging" "suppressing delivery"
3736 This is a debugging option that inhibits delivery of a message at the transport
3737 level. It implies &%-v%&. Exim goes through many of the motions of delivery &--
3738 it just doesn't actually transport the message, but instead behaves as if it
3739 had successfully done so. However, it does not make any updates to the retry
3740 database, and the log entries for deliveries are flagged with &"*>"& rather
3741 than &"=>"&.
3742
3743 Because &%-N%& discards any message to which it applies, only root or the Exim
3744 user are allowed to use it with &%-bd%&, &%-q%&, &%-R%& or &%-M%&. In other
3745 words, an ordinary user can use it only when supplying an incoming message to
3746 which it will apply. Although transportation never fails when &%-N%& is set, an
3747 address may be deferred because of a configuration problem on a transport, or a
3748 routing problem. Once &%-N%& has been used for a delivery attempt, it sticks to
3749 the message, and applies to any subsequent delivery attempts that may happen
3750 for that message.
3751
3752 .vitem &%-n%&
3753 .oindex "&%-n%&"
3754 .cindex "Sendmail compatibility" "&%-n%& option ignored"
3755 This option is interpreted by Sendmail to mean &"no aliasing"&. It is ignored
3756 by Exim.
3757
3758 .vitem &%-O%&&~<&'data'&>
3759 .oindex "&%-O%&"
3760 This option is interpreted by Sendmail to mean &`set option`&. It is ignored by
3761 Exim.
3762
3763 .vitem &%-oA%&&~<&'file&~name'&>
3764 .oindex "&%-oA%&"
3765 .cindex "Sendmail compatibility" "&%-oA%& option"
3766 This option is used by Sendmail in conjunction with &%-bi%& to specify an
3767 alternative alias file name. Exim handles &%-bi%& differently; see the
3768 description above.
3769
3770 .vitem &%-oB%&&~<&'n'&>
3771 .oindex "&%-oB%&"
3772 .cindex "SMTP" "passed connection"
3773 .cindex "SMTP" "multiple deliveries"
3774 .cindex "multiple SMTP deliveries"
3775 This is a debugging option which limits the maximum number of messages that can
3776 be delivered down one SMTP connection, overriding the value set in any &(smtp)&
3777 transport. If <&'n'&> is omitted, the limit is set to 1.
3778
3779 .vitem &%-odb%&
3780 .oindex "&%-odb%&"
3781 .cindex "background delivery"
3782 .cindex "delivery" "in the background"
3783 This option applies to all modes in which Exim accepts incoming messages,
3784 including the listening daemon. It requests &"background"& delivery of such
3785 messages, which means that the accepting process automatically starts a
3786 delivery process for each message received, but does not wait for the delivery
3787 processes to finish.
3788
3789 When all the messages have been received, the reception process exits,
3790 leaving the delivery processes to finish in their own time. The standard output
3791 and error streams are closed at the start of each delivery process.
3792 This is the default action if none of the &%-od%& options are present.
3793
3794 If one of the queueing options in the configuration file
3795 (&%queue_only%& or &%queue_only_file%&, for example) is in effect, &%-odb%&
3796 overrides it if &%queue_only_override%& is set true, which is the default
3797 setting. If &%queue_only_override%& is set false, &%-odb%& has no effect.
3798
3799 .vitem &%-odf%&
3800 .oindex "&%-odf%&"
3801 .cindex "foreground delivery"
3802 .cindex "delivery" "in the foreground"
3803 This option requests &"foreground"& (synchronous) delivery when Exim has
3804 accepted a locally-generated message. (For the daemon it is exactly the same as
3805 &%-odb%&.) A delivery process is automatically started to deliver the message,
3806 and Exim waits for it to complete before proceeding.
3807
3808 The original Exim reception process does not finish until the delivery
3809 process for the final message has ended. The standard error stream is left open
3810 during deliveries.
3811
3812 However, like &%-odb%&, this option has no effect if &%queue_only_override%& is
3813 false and one of the queueing options in the configuration file is in effect.
3814
3815 If there is a temporary delivery error during foreground delivery, the
3816 message is left on the queue for later delivery, and the original reception
3817 process exits. See chapter &<<CHAPnonqueueing>>& for a way of setting up a
3818 restricted configuration that never queues messages.
3819
3820
3821 .vitem &%-odi%&
3822 .oindex "&%-odi%&"
3823 This option is synonymous with &%-odf%&. It is provided for compatibility with
3824 Sendmail.
3825
3826 .vitem &%-odq%&
3827 .oindex "&%-odq%&"
3828 .cindex "non-immediate delivery"
3829 .cindex "delivery" "suppressing immediate"
3830 .cindex "queueing incoming messages"
3831 This option applies to all modes in which Exim accepts incoming messages,
3832 including the listening daemon. It specifies that the accepting process should
3833 not automatically start a delivery process for each message received. Messages
3834 are placed on the queue, and remain there until a subsequent queue runner
3835 process encounters them. There are several configuration options (such as
3836 &%queue_only%&) that can be used to queue incoming messages under certain
3837 conditions. This option overrides all of them and also &%-odqs%&. It always
3838 forces queueing.
3839
3840 .vitem &%-odqs%&
3841 .oindex "&%-odqs%&"
3842 .cindex "SMTP" "delaying delivery"
3843 This option is a hybrid between &%-odb%&/&%-odi%& and &%-odq%&.
3844 However, like &%-odb%& and &%-odi%&, this option has no effect if
3845 &%queue_only_override%& is false and one of the queueing options in the
3846 configuration file is in effect.
3847
3848 When &%-odqs%& does operate, a delivery process is started for each incoming
3849 message, in the background by default, but in the foreground if &%-odi%& is
3850 also present. The recipient addresses are routed, and local deliveries are done
3851 in the normal way. However, if any SMTP deliveries are required, they are not
3852 done at this time, so the message remains on the queue until a subsequent queue
3853 runner process encounters it. Because routing was done, Exim knows which
3854 messages are waiting for which hosts, and so a number of messages for the same
3855 host can be sent in a single SMTP connection. The &%queue_smtp_domains%&
3856 configuration option has the same effect for specific domains. See also the
3857 &%-qq%& option.
3858
3859 .vitem &%-oee%&
3860 .oindex "&%-oee%&"
3861 .cindex "error" "reporting"
3862 If an error is detected while a non-SMTP message is being received (for
3863 example, a malformed address), the error is reported to the sender in a mail
3864 message.
3865
3866 .cindex "return code" "for &%-oee%&"
3867 Provided
3868 this error message is successfully sent, the Exim receiving process
3869 exits with a return code of zero. If not, the return code is 2 if the problem
3870 is that the original message has no recipients, or 1 any other error. This is
3871 the default &%-oe%&&'x'& option if Exim is called as &'rmail'&.
3872
3873 .vitem &%-oem%&
3874 .oindex "&%-oem%&"
3875 .cindex "error" "reporting"
3876 .cindex "return code" "for &%-oem%&"
3877 This is the same as &%-oee%&, except that Exim always exits with a non-zero
3878 return code, whether or not the error message was successfully sent.
3879 This is the default &%-oe%&&'x'& option, unless Exim is called as &'rmail'&.
3880
3881 .vitem &%-oep%&
3882 .oindex "&%-oep%&"
3883 .cindex "error" "reporting"
3884 If an error is detected while a non-SMTP message is being received, the
3885 error is reported by writing a message to the standard error file (stderr).
3886 .cindex "return code" "for &%-oep%&"
3887 The return code is 1 for all errors.
3888
3889 .vitem &%-oeq%&
3890 .oindex "&%-oeq%&"
3891 .cindex "error" "reporting"
3892 This option is supported for compatibility with Sendmail, but has the same
3893 effect as &%-oep%&.
3894
3895 .vitem &%-oew%&
3896 .oindex "&%-oew%&"
3897 .cindex "error" "reporting"
3898 This option is supported for compatibility with Sendmail, but has the same
3899 effect as &%-oem%&.
3900
3901 .vitem &%-oi%&
3902 .oindex "&%-oi%&"
3903 .cindex "dot in incoming" "non-SMTP message"
3904 This option, which has the same effect as &%-i%&, specifies that a dot on a
3905 line by itself should not terminate an incoming, non-SMTP message. Otherwise, a
3906 single dot does terminate, though Exim does no special processing for other
3907 lines that start with a dot. This option is set by default if Exim is called as
3908 &'rmail'&. See also &%-ti%&.
3909
3910 .vitem &%-oitrue%&
3911 .oindex "&%-oitrue%&"
3912 This option is treated as synonymous with &%-oi%&.
3913
3914 .vitem &%-oMa%&&~<&'host&~address'&>
3915 .oindex "&%-oMa%&"
3916 .cindex "sender host address" "specifying for local message"
3917 A number of options starting with &%-oM%& can be used to set values associated
3918 with remote hosts on locally-submitted messages (that is, messages not received
3919 over TCP/IP). These options can be used by any caller in conjunction with the
3920 &%-bh%&, &%-be%&, &%-bf%&, &%-bF%&, &%-bt%&, or &%-bv%& testing options. In
3921 other circumstances, they are ignored unless the caller is trusted.
3922
3923 The &%-oMa%& option sets the sender host address. This may include a port
3924 number at the end, after a full stop (period). For example:
3925 .code
3926 exim -bs -oMa 10.9.8.7.1234
3927 .endd
3928 An alternative syntax is to enclose the IP address in square brackets,
3929 followed by a colon and the port number:
3930 .code
3931 exim -bs -oMa [10.9.8.7]:1234
3932 .endd
3933 The IP address is placed in the &$sender_host_address$& variable, and the
3934 port, if present, in &$sender_host_port$&. If both &%-oMa%& and &%-bh%&
3935 are present on the command line, the sender host IP address is taken from
3936 whichever one is last.
3937
3938 .vitem &%-oMaa%&&~<&'name'&>
3939 .oindex "&%-oMaa%&"
3940 .cindex "authentication name" "specifying for local message"
3941 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMaa%&
3942 option sets the value of &$sender_host_authenticated$& (the authenticator
3943 name). See chapter &<<CHAPSMTPAUTH>>& for a discussion of SMTP authentication.
3944 This option can be used with &%-bh%& and &%-bs%& to set up an
3945 authenticated SMTP session without actually using the SMTP AUTH command.
3946
3947 .vitem &%-oMai%&&~<&'string'&>
3948 .oindex "&%-oMai%&"
3949 .cindex "authentication id" "specifying for local message"
3950 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMai%&
3951 option sets the value of &$authenticated_id$& (the id that was authenticated).
3952 This overrides the default value (the caller's login id, except with &%-bh%&,
3953 where there is no default) for messages from local sources. See chapter
3954 &<<CHAPSMTPAUTH>>& for a discussion of authenticated ids.
3955
3956 .vitem &%-oMas%&&~<&'address'&>
3957 .oindex "&%-oMas%&"
3958 .cindex "authentication sender" "specifying for local message"
3959 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMas%&
3960 option sets the authenticated sender value in &$authenticated_sender$&. It
3961 overrides the sender address that is created from the caller's login id for
3962 messages from local sources, except when &%-bh%& is used, when there is no
3963 default. For both &%-bh%& and &%-bs%&, an authenticated sender that is
3964 specified on a MAIL command overrides this value. See chapter
3965 &<<CHAPSMTPAUTH>>& for a discussion of authenticated senders.
3966
3967 .vitem &%-oMi%&&~<&'interface&~address'&>
3968 .oindex "&%-oMi%&"
3969 .cindex "interface address" "specifying for local message"
3970 .new
3971 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMi%&
3972 option sets the IP interface address value. A port number may be included,
3973 using the same syntax as for &%-oMa%&. The interface address is placed in
3974 &$received_ip_address$& and the port number, if present, in &$received_port$&.
3975 .wen
3976
3977 .vitem &%-oMr%&&~<&'protocol&~name'&>
3978 .oindex "&%-oMr%&"
3979 .cindex "protocol" "incoming &-- specifying for local message"
3980 .cindex "&$received_protocol$&"
3981 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMr%&
3982 option sets the received protocol value that is stored in
3983 &$received_protocol$&. However, it does not apply (and is ignored) when &%-bh%&
3984 or &%-bs%& is used. For &%-bh%&, the protocol is forced to one of the standard
3985 SMTP protocol names (see the description of &$received_protocol$& in section
3986 &<<SECTexpvar>>&). For &%-bs%&, the protocol is always &"local-"& followed by
3987 one of those same names. For &%-bS%& (batched SMTP) however, the protocol can
3988 be set by &%-oMr%&.
3989
3990 .vitem &%-oMs%&&~<&'host&~name'&>
3991 .oindex "&%-oMs%&"
3992 .cindex "sender host name" "specifying for local message"
3993 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMs%&
3994 option sets the sender host name in &$sender_host_name$&. When this option is
3995 present, Exim does not attempt to look up a host name from an IP address; it
3996 uses the name it is given.
3997
3998 .vitem &%-oMt%&&~<&'ident&~string'&>
3999 .oindex "&%-oMt%&"
4000 .cindex "sender ident string" "specifying for local message"
4001 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMt%&
4002 option sets the sender ident value in &$sender_ident$&. The default setting for
4003 local callers is the login id of the calling process, except when &%-bh%& is
4004 used, when there is no default.
4005
4006 .vitem &%-om%&
4007 .oindex "&%-om%&"
4008 .cindex "Sendmail compatibility" "&%-om%& option ignored"
4009 In Sendmail, this option means &"me too"&, indicating that the sender of a
4010 message should receive a copy of the message if the sender appears in an alias
4011 expansion. Exim always does this, so the option does nothing.
4012
4013 .vitem &%-oo%&
4014 .oindex "&%-oo%&"
4015 .cindex "Sendmail compatibility" "&%-oo%& option ignored"
4016 This option is ignored. In Sendmail it specifies &"old style headers"&,
4017 whatever that means.
4018
4019 .vitem &%-oP%&&~<&'path'&>
4020 .oindex "&%-oP%&"
4021 .cindex "pid (process id)" "of daemon"
4022 .cindex "daemon" "process id (pid)"
4023 This option is useful only in conjunction with &%-bd%& or &%-q%& with a time
4024 value. The option specifies the file to which the process id of the daemon is
4025 written. When &%-oX%& is used with &%-bd%&, or when &%-q%& with a time is used
4026 without &%-bd%&, this is the only way of causing Exim to write a pid file,
4027 because in those cases, the normal pid file is not used.
4028
4029 .vitem &%-or%&&~<&'time'&>
4030 .oindex "&%-or%&"
4031 .cindex "timeout" "for non-SMTP input"
4032 This option sets a timeout value for incoming non-SMTP messages. If it is not
4033 set, Exim will wait forever for the standard input. The value can also be set
4034 by the &%receive_timeout%& option. The format used for specifying times is
4035 described in section &<<SECTtimeformat>>&.
4036
4037 .vitem &%-os%&&~<&'time'&>
4038 .oindex "&%-os%&"
4039 .cindex "timeout" "for SMTP input"
4040 .cindex "SMTP timeout" "input"
4041 This option sets a timeout value for incoming SMTP messages. The timeout
4042 applies to each SMTP command and block of data. The value can also be set by
4043 the &%smtp_receive_timeout%& option; it defaults to 5 minutes. The format used
4044 for specifying times is described in section &<<SECTtimeformat>>&.
4045
4046 .vitem &%-ov%&
4047 .oindex "&%-ov%&"
4048 This option has exactly the same effect as &%-v%&.
4049
4050 .vitem &%-oX%&&~<&'number&~or&~string'&>
4051 .oindex "&%-oX%&"
4052 .cindex "TCP/IP" "setting listening ports"
4053 .cindex "TCP/IP" "setting listening interfaces"
4054 .cindex "port" "receiving TCP/IP"
4055 This option is relevant only when the &%-bd%& (start listening daemon) option
4056 is also given. It controls which ports and interfaces the daemon uses. Details
4057 of the syntax, and how it interacts with configuration file options, are given
4058 in chapter &<<CHAPinterfaces>>&. When &%-oX%& is used to start a daemon, no pid
4059 file is written unless &%-oP%& is also present to specify a pid file name.
4060
4061 .vitem &%-pd%&
4062 .oindex "&%-pd%&"
4063 .cindex "Perl" "starting the interpreter"
4064 This option applies when an embedded Perl interpreter is linked with Exim (see
4065 chapter &<<CHAPperl>>&). It overrides the setting of the &%perl_at_start%&
4066 option, forcing the starting of the interpreter to be delayed until it is
4067 needed.
4068
4069 .vitem &%-ps%&
4070 .oindex "&%-ps%&"
4071 .cindex "Perl" "starting the interpreter"
4072 This option applies when an embedded Perl interpreter is linked with Exim (see
4073 chapter &<<CHAPperl>>&). It overrides the setting of the &%perl_at_start%&
4074 option, forcing the starting of the interpreter to occur as soon as Exim is
4075 started.
4076
4077 .vitem &%-p%&<&'rval'&>:<&'sval'&>
4078 .oindex "&%-p%&"
4079 For compatibility with Sendmail, this option is equivalent to
4080 .display
4081 &`-oMr`& <&'rval'&> &`-oMs`& <&'sval'&>
4082 .endd
4083 It sets the incoming protocol and host name (for trusted callers). The
4084 host name and its colon can be omitted when only the protocol is to be set.
4085 Note the Exim already has two private options, &%-pd%& and &%-ps%&, that refer
4086 to embedded Perl. It is therefore impossible to set a protocol value of &`p`&
4087 or &`s`& using this option (but that does not seem a real limitation).
4088
4089 .vitem &%-q%&
4090 .oindex "&%-q%&"
4091 .cindex "queue runner" "starting manually"
4092 This option is normally restricted to admin users. However, there is a
4093 configuration option called &%prod_requires_admin%& which can be set false to
4094 relax this restriction (and also the same requirement for the &%-M%&, &%-R%&,
4095 and &%-S%& options).
4096
4097 .cindex "queue runner" "description of operation"
4098 The &%-q%& option starts one queue runner process. This scans the queue of
4099 waiting messages, and runs a delivery process for each one in turn. It waits
4100 for each delivery process to finish before starting the next one. A delivery
4101 process may not actually do any deliveries if the retry times for the addresses
4102 have not been reached. Use &%-qf%& (see below) if you want to override this.
4103
4104 If
4105 .cindex "SMTP" "passed connection"
4106 .cindex "SMTP" "multiple deliveries"
4107 .cindex "multiple SMTP deliveries"
4108 the delivery process spawns other processes to deliver other messages down
4109 passed SMTP connections, the queue runner waits for these to finish before
4110 proceeding.
4111
4112 When all the queued messages have been considered, the original queue runner
4113 process terminates. In other words, a single pass is made over the waiting
4114 mail, one message at a time. Use &%-q%& with a time (see below) if you want
4115 this to be repeated periodically.
4116
4117 Exim processes the waiting messages in an unpredictable order. It isn't very
4118 random, but it is likely to be different each time, which is all that matters.
4119 If one particular message screws up a remote MTA, other messages to the same
4120 MTA have a chance of getting through if they get tried first.
4121
4122 It is possible to cause the messages to be processed in lexical message id
4123 order, which is essentially the order in which they arrived, by setting the
4124 &%queue_run_in_order%& option, but this is not recommended for normal use.
4125
4126 .vitem &%-q%&<&'qflags'&>
4127 The &%-q%& option may be followed by one or more flag letters that change its
4128 behaviour. They are all optional, but if more than one is present, they must
4129 appear in the correct order. Each flag is described in a separate item below.
4130
4131 .vitem &%-qq...%&
4132 .oindex "&%-qq%&"
4133 .cindex "queue" "double scanning"
4134 .cindex "queue" "routing"
4135 .cindex "routing" "whole queue before delivery"
4136 An option starting with &%-qq%& requests a two-stage queue run. In the first
4137 stage, the queue is scanned as if the &%queue_smtp_domains%& option matched
4138 every domain. Addresses are routed, local deliveries happen, but no remote
4139 transports are run.
4140
4141 .cindex "hints database" "remembering routing"
4142 The hints database that remembers which messages are waiting for specific hosts
4143 is updated, as if delivery to those hosts had been deferred. After this is
4144 complete, a second, normal queue scan happens, with routing and delivery taking
4145 place as normal. Messages that are routed to the same host should mostly be
4146 delivered down a single SMTP
4147 .cindex "SMTP" "passed connection"
4148 .cindex "SMTP" "multiple deliveries"
4149 .cindex "multiple SMTP deliveries"
4150 connection because of the hints that were set up during the first queue scan.
4151 This option may be useful for hosts that are connected to the Internet
4152 intermittently.
4153
4154 .vitem &%-q[q]i...%&
4155 .oindex "&%-qi%&"
4156 .cindex "queue" "initial delivery"
4157 If the &'i'& flag is present, the queue runner runs delivery processes only for
4158 those messages that haven't previously been tried. (&'i'& stands for &"initial
4159 delivery"&.) This can be helpful if you are putting messages on the queue using
4160 &%-odq%& and want a queue runner just to process the new messages.
4161
4162 .vitem &%-q[q][i]f...%&
4163 .oindex "&%-qf%&"
4164 .cindex "queue" "forcing delivery"
4165 .cindex "delivery" "forcing in queue run"
4166 If one &'f'& flag is present, a delivery attempt is forced for each non-frozen
4167 message, whereas without &'f'& only those non-frozen addresses that have passed
4168 their retry times are tried.
4169
4170 .vitem &%-q[q][i]ff...%&
4171 .oindex "&%-qff%&"
4172 .cindex "frozen messages" "forcing delivery"
4173 If &'ff'& is present, a delivery attempt is forced for every message, whether
4174 frozen or not.
4175
4176 .vitem &%-q[q][i][f[f]]l%&
4177 .oindex "&%-ql%&"
4178 .cindex "queue" "local deliveries only"
4179 The &'l'& (the letter &"ell"&) flag specifies that only local deliveries are to
4180 be done. If a message requires any remote deliveries, it remains on the queue
4181 for later delivery.
4182
4183 .vitem &%-q%&<&'qflags'&>&~<&'start&~id'&>&~<&'end&~id'&>
4184 .cindex "queue" "delivering specific messages"
4185 When scanning the queue, Exim can be made to skip over messages whose ids are
4186 lexically less than a given value by following the &%-q%& option with a
4187 starting message id. For example:
4188 .code
4189 exim -q 0t5C6f-0000c8-00
4190 .endd
4191 Messages that arrived earlier than &`0t5C6f-0000c8-00`& are not inspected. If a
4192 second message id is given, messages whose ids are lexically greater than it
4193 are also skipped. If the same id is given twice, for example,
4194 .code
4195 exim -q 0t5C6f-0000c8-00 0t5C6f-0000c8-00
4196 .endd
4197 just one delivery process is started, for that message. This differs from
4198 &%-M%& in that retry data is respected, and it also differs from &%-Mc%& in
4199 that it counts as a delivery from a queue run. Note that the selection
4200 mechanism does not affect the order in which the messages are scanned. There
4201 are also other ways of selecting specific sets of messages for delivery in a
4202 queue run &-- see &%-R%& and &%-S%&.
4203
4204 .vitem &%-q%&<&'qflags'&><&'time'&>
4205 .cindex "queue runner" "starting periodically"
4206 .cindex "periodic queue running"
4207 When a time value is present, the &%-q%& option causes Exim to run as a daemon,
4208 starting a queue runner process at intervals specified by the given time value
4209 (whose format is described in section &<<SECTtimeformat>>&). This form of the
4210 &%-q%& option is commonly combined with the &%-bd%& option, in which case a
4211 single daemon process handles both functions. A common way of starting up a
4212 combined daemon at system boot time is to use a command such as
4213 .code
4214 /usr/exim/bin/exim -bd -q30m
4215 .endd
4216 Such a daemon listens for incoming SMTP calls, and also starts a queue runner
4217 process every 30 minutes.
4218
4219 When a daemon is started by &%-q%& with a time value, but without &%-bd%&, no
4220 pid file is written unless one is explicitly requested by the &%-oP%& option.
4221
4222 .vitem &%-qR%&<&'rsflags'&>&~<&'string'&>
4223 .oindex "&%-qR%&"
4224 This option is synonymous with &%-R%&. It is provided for Sendmail
4225 compatibility.
4226
4227 .vitem &%-qS%&<&'rsflags'&>&~<&'string'&>
4228 .oindex "&%-qS%&"
4229 This option is synonymous with &%-S%&.
4230
4231 .vitem &%-R%&<&'rsflags'&>&~<&'string'&>
4232 .oindex "&%-R%&"
4233 .cindex "queue runner" "for specific recipients"
4234 .cindex "delivery" "to given domain"
4235 .cindex "domain" "delivery to"
4236 The <&'rsflags'&> may be empty, in which case the white space before the string
4237 is optional, unless the string is &'f'&, &'ff'&, &'r'&, &'rf'&, or &'rff'&,
4238 which are the possible values for <&'rsflags'&>. White space is required if
4239 <&'rsflags'&> is not empty.
4240
4241 This option is similar to &%-q%& with no time value, that is, it causes Exim to
4242 perform a single queue run, except that, when scanning the messages on the
4243 queue, Exim processes only those that have at least one undelivered recipient
4244 address containing the given string, which is checked in a case-independent
4245 way. If the <&'rsflags'&> start with &'r'&, <&'string'&> is interpreted as a
4246 regular expression; otherwise it is a literal string.
4247
4248 .new
4249 If you want to do periodic queue runs for messages with specific recipients,
4250 you can combine &%-R%& with &%-q%& and a time value. For example:
4251 .code
4252 exim -q25m -R @special.domain.example
4253 .endd
4254 This example does a queue run for messages with recipients in the given domain
4255 every 25 minutes. Any additional flags that are specified with &%-q%& are
4256 applied to each queue run.
4257 .wen
4258
4259 Once a message is selected for delivery by this mechanism, all its addresses
4260 are processed. For the first selected message, Exim overrides any retry
4261 information and forces a delivery attempt for each undelivered address. This
4262 means that if delivery of any address in the first message is successful, any
4263 existing retry information is deleted, and so delivery attempts for that
4264 address in subsequently selected messages (which are processed without forcing)
4265 will run. However, if delivery of any address does not succeed, the retry
4266 information is updated, and in subsequently selected messages, the failing
4267 address will be skipped.
4268
4269 .cindex "frozen messages" "forcing delivery"
4270 If the <&'rsflags'&> contain &'f'& or &'ff'&, the delivery forcing applies to
4271 all selected messages, not just the first; frozen messages are included when
4272 &'ff'& is present.
4273
4274 The &%-R%& option makes it straightforward to initiate delivery of all messages
4275 to a given domain after a host has been down for some time. When the SMTP
4276 command ETRN is accepted by its ACL (see chapter &<<CHAPACL>>&), its default
4277 effect is to run Exim with the &%-R%& option, but it can be configured to run
4278 an arbitrary command instead.
4279
4280 .vitem &%-r%&
4281 .oindex "&%-r%&"
4282 This is a documented (for Sendmail) obsolete alternative name for &%-f%&.
4283
4284 .vitem &%-S%&<&'rsflags'&>&~<&'string'&>
4285 .oindex "&%-S%&"
4286 .cindex "delivery" "from given sender"
4287 .cindex "queue runner" "for specific senders"
4288 This option acts like &%-R%& except that it checks the string against each
4289 message's sender instead of against the recipients. If &%-R%& is also set, both
4290 conditions must be met for a message to be selected. If either of the options
4291 has &'f'& or &'ff'& in its flags, the associated action is taken.
4292
4293 .vitem &%-Tqt%&&~<&'times'&>
4294 .oindex "&%-Tqt%&"
4295 This an option that is exclusively for use by the Exim testing suite. It is not
4296 recognized when Exim is run normally. It allows for the setting up of explicit
4297 &"queue times"& so that various warning/retry features can be tested.
4298
4299 .vitem &%-t%&
4300 .oindex "&%-t%&"
4301 .cindex "recipient" "extracting from header lines"
4302 .cindex "&'Bcc:'& header line"
4303 .cindex "&'Cc:'& header line"
4304 .cindex "&'To:'& header line"
4305 When Exim is receiving a locally-generated, non-SMTP message on its standard
4306 input, the &%-t%& option causes the recipients of the message to be obtained
4307 from the &'To:'&, &'Cc:'&, and &'Bcc:'& header lines in the message instead of
4308 from the command arguments. The addresses are extracted before any rewriting
4309 takes place and the &'Bcc:'& header line, if present, is then removed.
4310
4311 .cindex "Sendmail compatibility" "&%-t%& option"
4312 If the command has any arguments, they specify addresses to which the message
4313 is &'not'& to be delivered. That is, the argument addresses are removed from
4314 the recipients list obtained from the headers. This is compatible with Smail 3
4315 and in accordance with the documented behaviour of several versions of
4316 Sendmail, as described in man pages on a number of operating systems (e.g.
4317 Solaris 8, IRIX 6.5, HP-UX 11). However, some versions of Sendmail &'add'&
4318 argument addresses to those obtained from the headers, and the O'Reilly
4319 Sendmail book documents it that way. Exim can be made to add argument addresses
4320 instead of subtracting them by setting the option
4321 &%extract_addresses_remove_arguments%& false.
4322
4323 .cindex "&%Resent-%& header lines" "with &%-t%&"
4324 If there are any &%Resent-%& header lines in the message, Exim extracts
4325 recipients from all &'Resent-To:'&, &'Resent-Cc:'&, and &'Resent-Bcc:'& header
4326 lines instead of from &'To:'&, &'Cc:'&, and &'Bcc:'&. This is for compatibility
4327 with Sendmail and other MTAs. (Prior to release 4.20, Exim gave an error if
4328 &%-t%& was used in conjunction with &%Resent-%& header lines.)
4329
4330 RFC 2822 talks about different sets of &%Resent-%& header lines (for when a
4331 message is resent several times). The RFC also specifies that they should be
4332 added at the front of the message, and separated by &'Received:'& lines. It is
4333 not at all clear how &%-t%& should operate in the present of multiple sets,
4334 nor indeed exactly what constitutes a &"set"&.
4335 In practice, it seems that MUAs do not follow the RFC. The &%Resent-%& lines
4336 are often added at the end of the header, and if a message is resent more than
4337 once, it is common for the original set of &%Resent-%& headers to be renamed as
4338 &%X-Resent-%& when a new set is added. This removes any possible ambiguity.
4339
4340 .vitem &%-ti%&
4341 .oindex "&%-ti%&"
4342 This option is exactly equivalent to &%-t%& &%-i%&. It is provided for
4343 compatibility with Sendmail.
4344
4345 .vitem &%-tls-on-connect%&
4346 .oindex "&%-tls-on-connect%&"
4347 .cindex "TLS" "use without STARTTLS"
4348 .cindex "TLS" "automatic start"
4349 This option is available when Exim is compiled with TLS support. It forces all
4350 incoming SMTP connections to behave as if the incoming port is listed in the
4351 &%tls_on_connect_ports%& option. See section &<<SECTsupobssmt>>& and chapter
4352 &<<CHAPTLS>>& for further details.
4353
4354
4355 .vitem &%-U%&
4356 .oindex "&%-U%&"
4357 .cindex "Sendmail compatibility" "&%-U%& option ignored"
4358 Sendmail uses this option for &"initial message submission"&, and its
4359 documentation states that in future releases, it may complain about
4360 syntactically invalid messages rather than fixing them when this flag is not
4361 set. Exim ignores this option.
4362
4363 .vitem &%-v%&
4364 .oindex "&%-v%&"
4365 This option causes Exim to write information to the standard error stream,
4366 describing what it is doing. In particular, it shows the log lines for
4367 receiving and delivering a message, and if an SMTP connection is made, the SMTP
4368 dialogue is shown. Some of the log lines shown may not actually be written to
4369 the log if the setting of &%log_selector%& discards them. Any relevant
4370 selectors are shown with each log line. If none are shown, the logging is
4371 unconditional.
4372
4373 .vitem &%-x%&
4374 .oindex "&%-x%&"
4375 AIX uses &%-x%& for a private purpose (&"mail from a local mail program has
4376 National Language Support extended characters in the body of the mail item"&).
4377 It sets &%-x%& when calling the MTA from its &%mail%& command. Exim ignores
4378 this option.
4379 .endlist
4380
4381 .ecindex IIDclo1
4382 .ecindex IIDclo2
4383
4384
4385 . ////////////////////////////////////////////////////////////////////////////
4386 . Insert a stylized DocBook comment here, to identify the end of the command
4387 . line options. This is for the benefit of the Perl script that automatically
4388 . creates a man page for the options.
4389 . ////////////////////////////////////////////////////////////////////////////
4390
4391 .literal xml
4392 <!-- === End of command line options === -->
4393 .literal off
4394
4395
4396
4397
4398
4399 . ////////////////////////////////////////////////////////////////////////////
4400 . ////////////////////////////////////////////////////////////////////////////
4401
4402
4403 .chapter "The Exim run time configuration file" "CHAPconf" &&&
4404          "The runtime configuration file"
4405
4406 .cindex "run time configuration"
4407 .cindex "configuration file" "general description"
4408 .cindex "CONFIGURE_FILE"
4409 .cindex "configuration file" "errors in"
4410 .cindex "error" "in configuration file"
4411 .cindex "return code" "for bad configuration"
4412 Exim uses a single run time configuration file that is read whenever an Exim
4413 binary is executed. Note that in normal operation, this happens frequently,
4414 because Exim is designed to operate in a distributed manner, without central
4415 control.
4416
4417 If a syntax error is detected while reading the configuration file, Exim
4418 writes a message on the standard error, and exits with a non-zero return code.
4419 The message is also written to the panic log. &*Note*&: Only simple syntax
4420 errors can be detected at this time. The values of any expanded options are
4421 not checked until the expansion happens, even when the expansion does not
4422 actually alter the string.
4423
4424 The name of the configuration file is compiled into the binary for security
4425 reasons, and is specified by the CONFIGURE_FILE compilation option. In
4426 most configurations, this specifies a single file. However, it is permitted to
4427 give a colon-separated list of file names, in which case Exim uses the first
4428 existing file in the list.
4429
4430 .cindex "EXIM_USER"
4431 .cindex "EXIM_GROUP"
4432 .cindex "CONFIGURE_OWNER"
4433 .cindex "CONFIGURE_GROUP"
4434 .cindex "configuration file" "ownership"
4435 .cindex "ownership" "configuration file"
4436 The run time configuration file must be owned by root or by the user that is
4437 specified at compile time by the EXIM_USER option, or by the user that is
4438 specified at compile time by the CONFIGURE_OWNER option (if set). The
4439 configuration file must not be world-writeable or group-writeable, unless its
4440 group is the one specified at compile time by the EXIM_GROUP option or by the
4441 CONFIGURE_GROUP option.
4442
4443 &*Warning*&: In a conventional configuration, where the Exim binary is setuid
4444 to root, anybody who is able to edit the run time configuration file has an
4445 easy way to run commands as root. If you make your mail administrators members
4446 of the Exim group, but do not trust them with root, make sure that the run time
4447 configuration is not group writeable.
4448
4449 A default configuration file, which will work correctly in simple situations,
4450 is provided in the file &_src/configure.default_&. If CONFIGURE_FILE
4451 defines just one file name, the installation process copies the default
4452 configuration to a new file of that name if it did not previously exist. If
4453 CONFIGURE_FILE is a list, no default is automatically installed. Chapter
4454 &<<CHAPdefconfil>>& is a &"walk-through"& discussion of the default
4455 configuration.
4456
4457
4458
4459 .section "Using a different configuration file"
4460 .cindex "configuration file" "alternate"
4461 A one-off alternate configuration can be specified by the &%-C%& command line
4462 option, which may specify a single file or a list of files. However, when
4463 &%-C%& is used, Exim gives up its root privilege, unless called by root or the
4464 Exim user (or unless the argument for &%-C%& is identical to the built-in value
4465 from CONFIGURE_FILE). &%-C%& is useful mainly for checking the syntax of
4466 configuration files before installing them. No owner or group checks are done
4467 on a configuration file specified by &%-C%&.
4468
4469 The privileged use of &%-C%& by the Exim user can be locked out by setting
4470 ALT_CONFIG_ROOT_ONLY in &_Local/Makefile_& when building Exim. However,
4471 if you do this, you also lock out the possibility of testing a
4472 configuration using &%-C%& right through message reception and delivery, even
4473 if the caller is root. The reception works, but by that time, Exim is running
4474 as the Exim user, so when it re-execs to regain privilege for the delivery, the
4475 use of &%-C%& causes privilege to be lost. However, root can test reception and
4476 delivery using two separate commands (one to put a message on the queue, using
4477 &%-odq%&, and another to do the delivery, using &%-M%&).
4478
4479 If ALT_CONFIG_PREFIX is defined &_in Local/Makefile_&, it specifies a
4480 prefix string with which any file named in a &%-C%& command line option must
4481 start. In addition, the file name must not contain the sequence &"&`/../`&"&.
4482 There is no default setting for ALT_CONFIG_PREFIX; when it is unset, any file
4483 name can be used with &%-C%&.
4484
4485 One-off changes to a configuration can be specified by the &%-D%& command line
4486 option, which defines and overrides values for macros used inside the
4487 configuration file. However, like &%-C%&, the use of this option by a
4488 non-privileged user causes Exim to discard its root privilege.
4489 If DISABLE_D_OPTION is defined in &_Local/Makefile_&, the use of &%-D%& is
4490 completely disabled, and its use causes an immediate error exit.
4491
4492 Some sites may wish to use the same Exim binary on different machines that
4493 share a file system, but to use different configuration files on each machine.
4494 If CONFIGURE_FILE_USE_NODE is defined in &_Local/Makefile_&, Exim first
4495 looks for a file whose name is the configuration file name followed by a dot
4496 and the machine's node name, as obtained from the &[uname()]& function. If this
4497 file does not exist, the standard name is tried. This processing occurs for
4498 each file name in the list given by CONFIGURE_FILE or &%-C%&.
4499
4500 In some esoteric situations different versions of Exim may be run under
4501 different effective uids and the CONFIGURE_FILE_USE_EUID is defined to
4502 help with this. See the comments in &_src/EDITME_& for details.
4503
4504
4505
4506 .section "Configuration file format" "SECTconffilfor"
4507 .cindex "configuration file" "format of"
4508 .cindex "format" "configuration file"
4509 Exim's configuration file is divided into a number of different parts. General
4510 option settings must always appear at the start of the file. The other parts
4511 are all optional, and may appear in any order. Each part other than the first
4512 is introduced by the word &"begin"& followed by the name of the part. The
4513 optional parts are:
4514
4515 .ilist
4516 &'ACL'&: Access control lists for controlling incoming SMTP mail.
4517 .next
4518 .cindex "AUTH" "configuration"
4519 &'authenticators'&: Configuration settings for the authenticator drivers. These
4520 are concerned with the SMTP AUTH command (see chapter &<<CHAPSMTPAUTH>>&).
4521 .next
4522 &'routers'&: Configuration settings for the router drivers. Routers process
4523 addresses and determine how the message is to be delivered.
4524 .next
4525 &'transports'&: Configuration settings for the transport drivers. Transports
4526 define mechanisms for copying messages to destinations.
4527 .next
4528 &'retry'&: Retry rules, for use when a message cannot be immediately delivered.
4529 .next
4530 &'rewrite'&: Global address rewriting rules, for use when a message arrives and
4531 when new addresses are generated during delivery.
4532 .next
4533 &'local_scan'&: Private options for the &[local_scan()]& function. If you
4534 want to use this feature, you must set
4535 .code
4536 LOCAL_SCAN_HAS_OPTIONS=yes
4537 .endd
4538 in &_Local/Makefile_& before building Exim. Full details of the
4539 &[local_scan()]& facility are given in chapter &<<CHAPlocalscan>>&.
4540 .endlist
4541
4542 .cindex "configuration file" "leading white space in"
4543 .cindex "configuration file" "trailing white space in"
4544 .cindex "white space" "in configuration file"
4545 Leading and trailing white space in configuration lines is always ignored.
4546
4547 Blank lines in the file, and lines starting with a # character (ignoring
4548 leading white space) are treated as comments and are ignored. &*Note*&: A
4549 # character other than at the beginning of a line is not treated specially,
4550 and does not introduce a comment.
4551
4552 Any non-comment line can be continued by ending it with a backslash. Note that
4553 the general rule for white space means that trailing white space after the
4554 backslash and leading white space at the start of continuation
4555 lines is ignored. Comment lines beginning with # (but not empty lines) may
4556 appear in the middle of a sequence of continuation lines.
4557
4558 A convenient way to create a configuration file is to start from the
4559 default, which is supplied in &_src/configure.default_&, and add, delete, or
4560 change settings as required.
4561
4562 The ACLs, retry rules, and rewriting rules have their own syntax which is
4563 described in chapters &<<CHAPACL>>&, &<<CHAPretry>>&, and &<<CHAPrewrite>>&,
4564 respectively. The other parts of the configuration file have some syntactic
4565 items in common, and these are described below, from section &<<SECTcos>>&
4566 onwards. Before that, the inclusion, macro, and conditional facilities are
4567 described.
4568
4569
4570
4571 .section "File inclusions in the configuration file"
4572 .cindex "inclusions in configuration file"
4573 .cindex "configuration file" "including other files"
4574 .cindex ".include in configuration file"
4575 .cindex ".include_if_exists in configuration file"
4576 You can include other files inside Exim's run time configuration file by
4577 using this syntax:
4578 .display
4579 &`.include`& <&'file name'&>
4580 &`.include_if_exists`& <&'file name'&>
4581 .endd
4582 on a line by itself. Double quotes round the file name are optional. If you use
4583 the first form, a configuration error occurs if the file does not exist; the
4584 second form does nothing for non-existent files. In all cases, an absolute file
4585 name is required.
4586
4587 Includes may be nested to any depth, but remember that Exim reads its
4588 configuration file often, so it is a good idea to keep them to a minimum.
4589 If you change the contents of an included file, you must HUP the daemon,
4590 because an included file is read only when the configuration itself is read.
4591
4592 The processing of inclusions happens early, at a physical line level, so, like
4593 comment lines, an inclusion can be used in the middle of an option setting,
4594 for example:
4595 .code
4596 hosts_lookup = a.b.c \
4597                .include /some/file
4598 .endd
4599 Include processing happens after macro processing (see below). Its effect is to
4600 process the lines of the included file as if they occurred inline where the
4601 inclusion appears.
4602
4603
4604
4605 .section "Macros in the configuration file" "SECTmacrodefs"
4606 .cindex "macro" "description of"
4607 .cindex "configuration file" "macros"
4608 If a line in the main part of the configuration (that is, before the first
4609 &"begin"& line) begins with an upper case letter, it is taken as a macro
4610 definition, and must be of the form
4611 .display
4612 <&'name'&> = <&'rest of line'&>
4613 .endd
4614 The name must consist of letters, digits, and underscores, and need not all be
4615 in upper case, though that is recommended. The rest of the line, including any
4616 continuations, is the replacement text, and has leading and trailing white
4617 space removed. Quotes are not removed. The replacement text can never end with
4618 a backslash character, but this doesn't seem to be a serious limitation.
4619
4620 Macros may also be defined between router, transport, authenticator, or ACL
4621 definitions. They may not, however, be defined within an individual driver or
4622 ACL, or in the &%local_scan%&, retry, or rewrite sections of the configuration.
4623
4624 .section "Macro substitution"
4625 Once a macro is defined, all subsequent lines in the file (and any included
4626 files) are scanned for the macro name; if there are several macros, the line is
4627 scanned for each in turn, in the order in which the macros are defined. The
4628 replacement text is not re-scanned for the current macro, though it is scanned
4629 for subsequently defined macros. For this reason, a macro name may not contain
4630 the name of a previously defined macro as a substring. You could, for example,
4631 define
4632 .display
4633 &`ABCD_XYZ = `&<&'something'&>
4634 &`ABCD = `&<&'something else'&>
4635 .endd
4636 but putting the definitions in the opposite order would provoke a configuration
4637 error. Macro expansion is applied to individual physical lines from the file,
4638 before checking for line continuation or file inclusion (see above). If a line
4639 consists solely of a macro name, and the expansion of the macro is empty, the
4640 line is ignored. A macro at the start of a line may turn the line into a
4641 comment line or a &`.include`& line.
4642
4643
4644 .section "Redefining macros"
4645 Once defined, the value of a macro can be redefined later in the configuration
4646 (or in an included file). Redefinition is specified by using &'=='& instead of
4647 &'='&. For example:
4648 .code
4649 MAC =  initial value
4650 ...
4651 MAC == updated value
4652 .endd
4653 Redefinition does not alter the order in which the macros are applied to the
4654 subsequent lines of the configuration file. It is still the same order in which
4655 the macros were originally defined. All that changes is the macro's value.
4656 Redefinition makes it possible to accumulate values. For example:
4657 .code
4658 MAC =  initial value
4659 ...
4660 MAC == MAC and something added
4661 .endd
4662 This can be helpful in situations where the configuration file is built
4663 from a number of other files.
4664
4665 .section "Overriding macro values"
4666 The values set for macros in the configuration file can be overridden by the
4667 &%-D%& command line option, but Exim gives up its root privilege when &%-D%& is
4668 used, unless called by root or the Exim user. A definition on the command line
4669 using the &%-D%& option causes all definitions and redefinitions within the
4670 file to be ignored.
4671
4672
4673
4674 .section "Example of macro usage"
4675 As an example of macro usage, consider a configuration where aliases are looked
4676 up in a MySQL database. It helps to keep the file less cluttered if long
4677 strings such as SQL statements are defined separately as macros, for example:
4678 .code
4679 ALIAS_QUERY = select mailbox from user where \
4680               login=${quote_mysql:$local_part};
4681 .endd
4682 This can then be used in a &(redirect)& router setting like this:
4683 .code
4684 data = ${lookup mysql{ALIAS_QUERY}}
4685 .endd
4686 In earlier versions of Exim macros were sometimes used for domain, host, or
4687 address lists. In Exim 4 these are handled better by named lists &-- see
4688 section &<<SECTnamedlists>>&.
4689
4690
4691 .section "Conditional skips in the configuration file"
4692 .cindex "configuration file" "conditional skips"
4693 .cindex ".ifdef"
4694 You can use the directives &`.ifdef`&, &`.ifndef`&, &`.elifdef`&,
4695 &`.elifndef`&, &`.else`&, and &`.endif`& to dynamically include or exclude
4696 portions of the configuration file. The processing happens whenever the file is
4697 read (that is, when an Exim binary starts to run).
4698
4699 The implementation is very simple. Instances of the first four directives must
4700 be followed by text that includes the names of one or macros. The condition
4701 that is tested is whether or not any macro substitution has taken place in the
4702 line. Thus:
4703 .code
4704 .ifdef AAA
4705 message_size_limit = 50M
4706 .else
4707 message_size_limit = 100M
4708 .endif
4709 .endd
4710 sets a message size limit of 50M if the macro &`AAA`& is defined, and 100M
4711 otherwise. If there is more than one macro named on the line, the condition
4712 is true if any of them are defined. That is, it is an &"or"& condition. To
4713 obtain an &"and"& condition, you need to use nested &`.ifdef`&s.
4714
4715 Although you can use a macro expansion to generate one of these directives,
4716 it is not very useful, because the condition &"there was a macro substitution
4717 in this line"& will always be true.
4718
4719 Text following &`.else`& and &`.endif`& is ignored, and can be used as comment
4720 to clarify complicated nestings.
4721
4722
4723
4724 .section "Common option syntax" "SECTcos"
4725 .cindex "common option syntax"
4726 .cindex "syntax of common options"
4727 .cindex "configuration file" "common option syntax"
4728 For the main set of options, driver options, and &[local_scan()]& options,
4729 each setting is on a line by itself, and starts with a name consisting of
4730 lower-case letters and underscores. Many options require a data value, and in
4731 these cases the name must be followed by an equals sign (with optional white
4732 space) and then the value. For example:
4733 .code
4734 qualify_domain = mydomain.example.com
4735 .endd
4736 Some option settings may contain sensitive data, for example, passwords for
4737 accessing databases. To stop non-admin users from using the &%-bP%& command
4738 line option to read these values, you can precede the option settings with the
4739 word &"hide"&. For example:
4740 .code
4741 hide mysql_servers = localhost/users/admin/secret-password
4742 .endd
4743 For non-admin users, such options are displayed like this:
4744 .code
4745 mysql_servers = <value not displayable>
4746 .endd
4747 If &"hide"& is used on a driver option, it hides the value of that option on
4748 all instances of the same driver.
4749
4750 The following sections describe the syntax used for the different data types
4751 that are found in option settings.
4752
4753
4754 .section "Boolean options"
4755 .cindex "format" "boolean"
4756 .cindex "boolean configuration values"
4757 .oindex "&%no_%&&'xxx'&"
4758 .oindex "&%not_%&&'xxx'&"
4759 Options whose type is given as boolean are on/off switches. There are two
4760 different ways of specifying such options: with and without a data value. If
4761 the option name is specified on its own without data, the switch is turned on;
4762 if it is preceded by &"no_"& or &"not_"& the switch is turned off. However,
4763 boolean options may be followed by an equals sign and one of the words
4764 &"true"&, &"false"&, &"yes"&, or &"no"&, as an alternative syntax. For example,
4765 the following two settings have exactly the same effect:
4766 .code
4767 queue_only
4768 queue_only = true
4769 .endd
4770 The following two lines also have the same (opposite) effect:
4771 .code
4772 no_queue_only
4773 queue_only = false
4774 .endd
4775 You can use whichever syntax you prefer.
4776
4777
4778
4779
4780 .section "Integer values"
4781 .cindex "integer configuration values"
4782 .cindex "format" "integer"
4783 If an integer data item starts with the characters &"0x"&, the remainder of it
4784 is interpreted as a hexadecimal number. Otherwise, it is treated as octal if it
4785 starts with the digit 0, and decimal if not. If an integer value is followed by
4786 the letter K, it is multiplied by 1024; if it is followed by the letter M, it
4787 is multiplied by 1024x1024.
4788
4789 When the values of integer option settings are output, values which are an
4790 exact multiple of 1024 or 1024x1024 are
4791 sometimes, but not always,
4792 printed using the letters K and M. The printing style is independent of the
4793 actual input format that was used.
4794
4795
4796 .section "Octal integer values"
4797 .cindex "integer format"
4798 .cindex "format" "octal integer"
4799 The value of an option specified as an octal integer is always interpreted in
4800 octal, whether or not it starts with the digit zero. Such options are always
4801 output in octal.
4802
4803
4804
4805 .section "Fixed point number values"
4806 .cindex "fixed point configuration values"
4807 .cindex "format" "fixed point"
4808 A fixed point number consists of a decimal integer, optionally followed by a
4809 decimal point and up to three further digits.
4810
4811
4812
4813 .section "Time interval values" "SECTtimeformat"
4814 .cindex "time interval" "specifying in configuration"
4815 .cindex "format" "time interval"
4816 A time interval is specified as a sequence of numbers, each followed by one of
4817 the following letters, with no intervening white space:
4818
4819 .table2 50pt
4820 .row &~&%s%& seconds
4821 .row &~&%m%& minutes
4822 .row &~&%h%& hours
4823 .row &~&%d%& days
4824 .row &~&%w%& weeks
4825 .endtable
4826
4827 For example, &"3h50m"& specifies 3 hours and 50 minutes. The values of time
4828 intervals are output in the same format. Exim does not restrict the values; it
4829 is perfectly acceptable, for example, to specify &"90m"& instead of &"1h30m"&.
4830
4831
4832
4833 .section "String values" "SECTstrings"
4834 .cindex "string" "format of configuration values"
4835 .cindex "format" "string"
4836 If a string data item does not start with a double-quote character, it is taken
4837 as consisting of the remainder of the line plus any continuation lines,
4838 starting at the first character after any leading white space, with trailing
4839 white space removed, and with no interpretation of the characters in the
4840 string. Because Exim removes comment lines (those beginning with #) at an early
4841 stage, they can appear in the middle of a multi-line string. The following
4842 settings are therefore equivalent:
4843 .code
4844 trusted_users = uucp:mail
4845
4846 trusted_users = uucp:\
4847                 # This comment line is ignored
4848                 mail
4849 .endd
4850 .cindex "string" "quoted"
4851 .cindex "escape characters in quoted strings"
4852 If a string does start with a double-quote, it must end with a closing
4853 double-quote, and any backslash characters other than those used for line
4854 continuation are interpreted as escape characters, as follows:
4855
4856 .table2 100pt
4857 .row &~&`\\`&                     "single backslash"
4858 .row &~&`\n`&                     "newline"
4859 .row &~&`\r`&                     "carriage return"
4860 .row &~&`\t`&                     "tab"
4861 .row "&~&`\`&<&'octal digits'&>"  "up to 3 octal digits specify one character"
4862 .row "&~&`\x`&<&'hex digits'&>"   "up to 2 hexadecimal digits specify one &&&
4863                                    character"
4864 .endtable
4865
4866 If a backslash is followed by some other character, including a double-quote
4867 character, that character replaces the pair.
4868
4869 Quoting is necessary only if you want to make use of the backslash escapes to
4870 insert special characters, or if you need to specify a value with leading or
4871 trailing spaces. These cases are rare, so quoting is almost never needed in
4872 current versions of Exim. In versions of Exim before 3.14, quoting was required
4873 in order to continue lines, so you may come across older configuration files
4874 and examples that apparently quote unnecessarily.
4875
4876
4877 .section "Expanded strings"
4878 .cindex "string expansion" "definition of"
4879 .cindex "expansion" "definition of"
4880 Some strings in the configuration file are subjected to &'string expansion'&,
4881 by which means various parts of the string may be changed according to the
4882 circumstances (see chapter &<<CHAPexpand>>&). The input syntax for such strings
4883 is as just described; in particular, the handling of backslashes in quoted
4884 strings is done as part of the input process, before expansion takes place.
4885 However, backslash is also an escape character for the expander, so any
4886 backslashes that are required for that reason must be doubled if they are
4887 within a quoted configuration string.
4888
4889
4890 .section "User and group names"
4891 .cindex "user name" "format of"
4892 .cindex "format" "user name"
4893 .cindex "group" "name format"
4894 .cindex "format" "group name"
4895 User and group names are specified as strings, using the syntax described
4896 above, but the strings are interpreted specially. A user or group name must
4897 either consist entirely of digits, or be a name that can be looked up using the
4898 &[getpwnam()]& or &[getgrnam()]& function, as appropriate.
4899
4900
4901 .section "List construction" "SECTlistconstruct"
4902 .cindex "list" "syntax of in configuration"
4903 .cindex "format" "list item in configuration"
4904 .cindex "string list" "definition"
4905 The data for some configuration options is a list of items, with colon as the
4906 default separator. Many of these options are shown with type &"string list"& in
4907 the descriptions later in this document. Others are listed as &"domain list"&,
4908 &"host list"&, &"address list"&, or &"local part list"&. Syntactically, they
4909 are all the same; however, those other than &"string list"& are subject to
4910 particular kinds of interpretation, as described in chapter
4911 &<<CHAPdomhosaddlists>>&.
4912
4913 In all these cases, the entire list is treated as a single string as far as the
4914 input syntax is concerned. The &%trusted_users%& setting in section
4915 &<<SECTstrings>>& above is an example. If a colon is actually needed in an item
4916 in a list, it must be entered as two colons. Leading and trailing white space
4917 on each item in a list is ignored. This makes it possible to include items that
4918 start with a colon, and in particular, certain forms of IPv6 address. For
4919 example, the list
4920 .code
4921 local_interfaces = 127.0.0.1 : ::::1
4922 .endd
4923 contains two IP addresses, the IPv4 address 127.0.0.1 and the IPv6 address ::1.
4924
4925 &*Note*&: Although leading and trailing white space is ignored in individual
4926 list items, it is not ignored when parsing the list. The space after the first
4927 colon in the example above is necessary. If it were not there, the list would
4928 be interpreted as the two items 127.0.0.1:: and 1.
4929
4930 .cindex "list separator" "changing"
4931 .cindex "IPv6" "addresses in lists"
4932 Doubling colons in IPv6 addresses is an unwelcome chore, so a mechanism was
4933 introduced to allow the separator character to be changed. If a list begins
4934 with a left angle bracket, followed by any punctuation character, that
4935 character is used instead of colon as the list separator. For example, the list
4936 above can be rewritten to use a semicolon separator like this:
4937 .code
4938 local_interfaces = <; 127.0.0.1 ; ::1
4939 .endd
4940 This facility applies to all lists, with the exception of the list in
4941 &%log_file_path%&. It is recommended that the use of non-colon separators be
4942 confined to circumstances where they really are needed.
4943
4944
4945
4946 .section "Empty items in lists" "SECTempitelis"
4947 .cindex "list" "empty item in"
4948 An empty item at the end of a list is always ignored. In other words, trailing
4949 separator characters are ignored. Thus, the list in
4950 .code
4951 senders = user@domain :
4952 .endd
4953 contains only a single item. If you want to include an empty string as one item
4954 in a list, it must not be the last item. For example, this list contains three
4955 items, the second of which is empty:
4956 .code
4957 senders = user1@domain : : user2@domain
4958 .endd
4959 &*Note*&: There must be white space between the two colons, as otherwise they
4960 are interpreted as representing a single colon data character (and the list
4961 would then contain just one item). If you want to specify a list that contains
4962 just one, empty item, you can do it as in this example:
4963 .code
4964 senders = :
4965 .endd
4966 In this case, the first item is empty, and the second is discarded because it
4967 is at the end of the list.
4968
4969
4970
4971
4972 .section "Format of driver configurations" "SECTfordricon"
4973 .cindex "drivers" "configuration format"
4974 There are separate parts in the configuration for defining routers, transports,
4975 and authenticators. In each part, you are defining a number of driver
4976 instances, each with its own set of options. Each driver instance is defined by
4977 a sequence of lines like this:
4978 .display
4979 <&'instance name'&>:
4980   <&'option'&>
4981   ...
4982   <&'option'&>
4983 .endd
4984 In the following example, the instance name is &(localuser)&, and it is
4985 followed by three options settings:
4986 .code
4987 localuser:
4988   driver = accept
4989   check_local_user
4990   transport = local_delivery
4991 .endd
4992 For each driver instance, you specify which Exim code module it uses &-- by the
4993 setting of the &%driver%& option &-- and (optionally) some configuration
4994 settings. For example, in the case of transports, if you want a transport to
4995 deliver with SMTP you would use the &(smtp)& driver; if you want to deliver to
4996 a local file you would use the &(appendfile)& driver. Each of the drivers is
4997 described in detail in its own separate chapter later in this manual.
4998
4999 You can have several routers, transports, or authenticators that are based on
5000 the same underlying driver (each must have a different instance name).
5001
5002 The order in which routers are defined is important, because addresses are
5003 passed to individual routers one by one, in order. The order in which
5004 transports are defined does not matter at all. The order in which
5005 authenticators are defined is used only when Exim, as a client, is searching
5006 them to find one that matches an authentication mechanism offered by the
5007 server.
5008
5009 .cindex "generic options"
5010 .cindex "options" "generic &-- definition of"
5011 Within a driver instance definition, there are two kinds of option: &'generic'&
5012 and &'private'&. The generic options are those that apply to all drivers of the
5013 same type (that is, all routers, all transports or all authenticators). The
5014 &%driver%& option is a generic option that must appear in every definition.
5015 .cindex "private options"
5016 The private options are special for each driver, and none need appear, because
5017 they all have default values.
5018
5019 The options may appear in any order, except that the &%driver%& option must
5020 precede any private options, since these depend on the particular driver. For
5021 this reason, it is recommended that &%driver%& always be the first option.
5022
5023 Driver instance names, which are used for reference in log entries and
5024 elsewhere, can be any sequence of letters, digits, and underscores (starting
5025 with a letter) and must be unique among drivers of the same type. A router and
5026 a transport (for example) can each have the same name, but no two router
5027 instances can have the same name. The name of a driver instance should not be
5028 confused with the name of the underlying driver module. For example, the
5029 configuration lines:
5030 .code
5031 remote_smtp:
5032   driver = smtp
5033 .endd
5034 create an instance of the &(smtp)& transport driver whose name is
5035 &(remote_smtp)&. The same driver code can be used more than once, with
5036 different instance names and different option settings each time. A second
5037 instance of the &(smtp)& transport, with different options, might be defined
5038 thus:
5039 .code
5040 special_smtp:
5041   driver = smtp
5042   port = 1234
5043   command_timeout = 10s
5044 .endd
5045 The names &(remote_smtp)& and &(special_smtp)& would be used to reference
5046 these transport instances from routers, and these names would appear in log
5047 lines.
5048
5049 Comment lines may be present in the middle of driver specifications. The full
5050 list of option settings for any particular driver instance, including all the
5051 defaulted values, can be extracted by making use of the &%-bP%& command line
5052 option.
5053
5054
5055
5056
5057
5058
5059 . ////////////////////////////////////////////////////////////////////////////
5060 . ////////////////////////////////////////////////////////////////////////////
5061
5062 .chapter "The default configuration file" "CHAPdefconfil"
5063 .scindex IIDconfiwal "configuration file" "default &""walk through""&"
5064 .cindex "default" "configuration file &""walk through""&"
5065 The default configuration file supplied with Exim as &_src/configure.default_&
5066 is sufficient for a host with simple mail requirements. As an introduction to
5067 the way Exim is configured, this chapter &"walks through"& the default
5068 configuration, giving brief explanations of the settings. Detailed descriptions
5069 of the options are given in subsequent chapters. The default configuration file
5070 itself contains extensive comments about ways you might want to modify the
5071 initial settings. However, note that there are many options that are not
5072 mentioned at all in the default configuration.
5073
5074
5075
5076 .section "Main configuration settings" "SECTdefconfmain"
5077 The main (global) configuration option settings must always come first in the
5078 file. The first thing you'll see in the file, after some initial comments, is
5079 the line
5080 .code
5081 # primary_hostname =
5082 .endd
5083 This is a commented-out setting of the &%primary_hostname%& option. Exim needs
5084 to know the official, fully qualified name of your host, and this is where you
5085 can specify it. However, in most cases you do not need to set this option. When
5086 it is unset, Exim uses the &[uname()]& system function to obtain the host name.
5087
5088 The first three non-comment configuration lines are as follows:
5089 .code
5090 domainlist local_domains = @
5091 domainlist relay_to_domains =
5092 hostlist   relay_from_hosts = 127.0.0.1
5093 .endd
5094 These are not, in fact, option settings. They are definitions of two named
5095 domain lists and one named host list. Exim allows you to give names to lists of
5096 domains, hosts, and email addresses, in order to make it easier to manage the
5097 configuration file (see section &<<SECTnamedlists>>&).
5098
5099 The first line defines a domain list called &'local_domains'&; this is used
5100 later in the configuration to identify domains that are to be delivered
5101 on the local host.
5102
5103 .cindex "@ in a domain list"
5104 There is just one item in this list, the string &"@"&. This is a special form
5105 of entry which means &"the name of the local host"&. Thus, if the local host is
5106 called &'a.host.example'&, mail to &'any.user@a.host.example'& is expected to
5107 be delivered locally. Because the local host's name is referenced indirectly,
5108 the same configuration file can be used on different hosts.
5109
5110 The second line defines a domain list called &'relay_to_domains'&, but the
5111 list itself is empty. Later in the configuration we will come to the part that
5112 controls mail relaying through the local host; it allows relaying to any
5113 domains in this list. By default, therefore, no relaying on the basis of a mail
5114 domain is permitted.
5115
5116 The third line defines a host list called &'relay_from_hosts'&. This list is
5117 used later in the configuration to permit relaying from any host or IP address
5118 that matches the list. The default contains just the IP address of the IPv4
5119 loopback interface, which means that processes on the local host are able to
5120 submit mail for relaying by sending it over TCP/IP to that interface. No other
5121 hosts are permitted to submit messages for relaying.
5122
5123 Just to be sure there's no misunderstanding: at this point in the configuration
5124 we aren't actually setting up any controls. We are just defining some domains
5125 and hosts that will be used in the controls that are specified later.
5126
5127 The next two configuration lines are genuine option settings:
5128 .code
5129 acl_smtp_rcpt = acl_check_rcpt
5130 acl_smtp_data = acl_check_data
5131 .endd
5132 These options specify &'Access Control Lists'& (ACLs) that are to be used
5133 during an incoming SMTP session for every recipient of a message (every RCPT
5134 command), and after the contents of the message have been received,
5135 respectively. The names of the lists are &'acl_check_rcpt'& and
5136 &'acl_check_data'&, and we will come to their definitions below, in the ACL
5137 section of the configuration. The RCPT ACL controls which recipients are
5138 accepted for an incoming message &-- if a configuration does not provide an ACL
5139 to check recipients, no SMTP mail can be accepted. The DATA ACL allows the
5140 contents of a message to be checked.
5141
5142 Two commented-out option settings are next:
5143 .code
5144 # av_scanner = clamd:/tmp/clamd
5145 # spamd_address = 127.0.0.1 783
5146 .endd
5147 These are example settings that can be used when Exim is compiled with the
5148 content-scanning extension. The first specifies the interface to the virus
5149 scanner, and the second specifies the interface to SpamAssassin. Further
5150 details are given in chapter &<<CHAPexiscan>>&.
5151
5152 Three more commented-out option settings follow:
5153 .code
5154 # tls_advertise_hosts = *
5155 # tls_certificate = /etc/ssl/exim.crt
5156 # tls_privatekey = /etc/ssl/exim.pem
5157 .endd
5158 These are example settings that can be used when Exim is compiled with
5159 support for TLS (aka SSL) as described in section &<<SECTinctlsssl>>&. The
5160 first one specifies the list of clients that are allowed to use TLS when
5161 connecting to this server; in this case the wildcard means all clients. The
5162 other options specify where Exim should find its TLS certificate and private
5163 key, which together prove the server's identity to any clients that connect.
5164 More details are given in chapter &<<CHAPTLS>>&.
5165
5166 Another two commented-out option settings follow:
5167 .code
5168 # daemon_smtp_ports = 25 : 465 : 587
5169 # tls_on_connect_ports = 465
5170 .endd
5171 .cindex "port" "465 and 587"
5172 .cindex "port" "for message submission"
5173 .cindex "message" "submission, ports for"
5174 .cindex "ssmtp protocol"
5175 .cindex "smtps protocol"
5176 .cindex "SMTP" "ssmtp protocol"
5177 .cindex "SMTP" "smtps protocol"
5178 These options provide better support for roaming users who wish to use this
5179 server for message submission. They are not much use unless you have turned on
5180 TLS (as described in the previous paragraph) and authentication (about which
5181 more in section &<<SECTdefconfauth>>&). The usual SMTP port 25 is often blocked
5182 on end-user networks, so RFC 4409 specifies that message submission should use
5183 port 587 instead. However some software (notably Microsoft Outlook) cannot be
5184 configured to use port 587 correctly, so these settings also enable the
5185 non-standard &"smtps"& (aka &"ssmtp"&) port 465 (see section
5186 &<<SECTsupobssmt>>&).
5187
5188 Two more commented-out options settings follow:
5189 .code
5190 # qualify_domain =
5191 # qualify_recipient =
5192 .endd
5193 The first of these specifies a domain that Exim uses when it constructs a
5194 complete email address from a local login name. This is often needed when Exim
5195 receives a message from a local process. If you do not set &%qualify_domain%&,
5196 the value of &%primary_hostname%& is used. If you set both of these options,
5197 you can have different qualification domains for sender and recipient
5198 addresses. If you set only the first one, its value is used in both cases.
5199
5200 .cindex "domain literal" "recognizing format"
5201 The following line must be uncommented if you want Exim to recognize
5202 addresses of the form &'user@[10.11.12.13]'& that is, with a &"domain literal"&
5203 (an IP address within square brackets) instead of a named domain.
5204 .code
5205 # allow_domain_literals
5206 .endd
5207 The RFCs still require this form, but many people think that in the modern
5208 Internet it makes little sense to permit mail to be sent to specific hosts by
5209 quoting their IP addresses. This ancient format has been used by people who
5210 try to abuse hosts by using them for unwanted relaying. However, some
5211 people believe there are circumstances (for example, messages addressed to
5212 &'postmaster'&) where domain literals are still useful.
5213
5214 The next configuration line is a kind of trigger guard:
5215 .code
5216 never_users = root
5217 .endd
5218 It specifies that no delivery must ever be run as the root user. The normal
5219 convention is to set up &'root'& as an alias for the system administrator. This
5220 setting is a guard against slips in the configuration.
5221 The list of users specified by &%never_users%& is not, however, the complete
5222 list; the build-time configuration in &_Local/Makefile_& has an option called
5223 FIXED_NEVER_USERS specifying a list that cannot be overridden. The
5224 contents of &%never_users%& are added to this list. By default
5225 FIXED_NEVER_USERS also specifies root.
5226
5227 When a remote host connects to Exim in order to send mail, the only information
5228 Exim has about the host's identity is its IP address. The next configuration
5229 line,
5230 .code
5231 host_lookup = *
5232 .endd
5233 specifies that Exim should do a reverse DNS lookup on all incoming connections,
5234 in order to get a host name. This improves the quality of the logging
5235 information, but if you feel it is too expensive, you can remove it entirely,
5236 or restrict the lookup to hosts on &"nearby"& networks.
5237 Note that it is not always possible to find a host name from an IP address,
5238 because not all DNS reverse zones are maintained, and sometimes DNS servers are
5239 unreachable.
5240
5241 The next two lines are concerned with &'ident'& callbacks, as defined by RFC
5242 1413 (hence their names):
5243 .code
5244 rfc1413_hosts = *
5245 rfc1413_query_timeout = 5s
5246 .endd
5247 These settings cause Exim to make ident callbacks for all incoming SMTP calls.
5248 You can limit the hosts to which these calls are made, or change the timeout
5249 that is used. If you set the timeout to zero, all ident calls are disabled.
5250 Although they are cheap and can provide useful information for tracing problem
5251 messages, some hosts and firewalls have problems with ident calls. This can
5252 result in a timeout instead of an immediate refused connection, leading to
5253 delays on starting up an incoming SMTP session.
5254
5255 When Exim receives messages over SMTP connections, it expects all addresses to
5256 be fully qualified with a domain, as required by the SMTP definition. However,
5257 if you are running a server to which simple clients submit messages, you may
5258 find that they send unqualified addresses. The two commented-out options:
5259 .code
5260 # sender_unqualified_hosts =
5261 # recipient_unqualified_hosts =
5262 .endd
5263 show how you can specify hosts that are permitted to send unqualified sender
5264 and recipient addresses, respectively.
5265
5266 The &%percent_hack_domains%& option is also commented out:
5267 .code
5268 # percent_hack_domains =
5269 .endd
5270 It provides a list of domains for which the &"percent hack"& is to operate.
5271 This is an almost obsolete form of explicit email routing. If you do not know
5272 anything about it, you can safely ignore this topic.
5273
5274 The last two settings in the main part of the default configuration are
5275 concerned with messages that have been &"frozen"& on Exim's queue. When a
5276 message is frozen, Exim no longer continues to try to deliver it. Freezing
5277 occurs when a bounce message encounters a permanent failure because the sender
5278 address of the original message that caused the bounce is invalid, so the
5279 bounce cannot be delivered. This is probably the most common case, but there
5280 are also other conditions that cause freezing, and frozen messages are not
5281 always bounce messages.
5282 .code
5283 ignore_bounce_errors_after = 2d
5284 timeout_frozen_after = 7d
5285 .endd
5286 The first of these options specifies that failing bounce messages are to be
5287 discarded after 2 days on the queue. The second specifies that any frozen
5288 message (whether a bounce message or not) is to be timed out (and discarded)
5289 after a week. In this configuration, the first setting ensures that no failing
5290 bounce message ever lasts a week.
5291
5292
5293
5294 .section "ACL configuration"
5295 .cindex "default" "ACLs"
5296 .cindex "&ACL;" "default configuration"
5297 In the default configuration, the ACL section follows the main configuration.
5298 It starts with the line
5299 .code
5300 begin acl
5301 .endd
5302 and it contains the definitions of two ACLs, called &'acl_check_rcpt'& and
5303 &'acl_check_data'&, that were referenced in the settings of &%acl_smtp_rcpt%&
5304 and &%acl_smtp_data%& above.
5305
5306 .cindex "RCPT" "ACL for"
5307 The first ACL is used for every RCPT command in an incoming SMTP message. Each
5308 RCPT command specifies one of the message's recipients. The ACL statements
5309 are considered in order, until the recipient address is either accepted or
5310 rejected. The RCPT command is then accepted or rejected, according to the
5311 result of the ACL processing.
5312 .code
5313 acl_check_rcpt:
5314 .endd
5315 This line, consisting of a name terminated by a colon, marks the start of the
5316 ACL, and names it.
5317 .code
5318 accept  hosts = :
5319 .endd
5320 This ACL statement accepts the recipient if the sending host matches the list.
5321 But what does that strange list mean? It doesn't actually contain any host
5322 names or IP addresses. The presence of the colon puts an empty item in the
5323 list; Exim matches this only if the incoming message did not come from a remote
5324 host, because in that case, the remote hostname is empty. The colon is
5325 important. Without it, the list itself is empty, and can never match anything.
5326
5327 What this statement is doing is to accept unconditionally all recipients in
5328 messages that are submitted by SMTP from local processes using the standard
5329 input and output (that is, not using TCP/IP). A number of MUAs operate in this
5330 manner.
5331 .code
5332 deny    message       = Restricted characters in address
5333         domains       = +local_domains
5334         local_parts   = ^[.] : ^.*[@%!/|]
5335
5336 deny    message       = Restricted characters in address
5337         domains       = !+local_domains
5338         local_parts   = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
5339 .endd
5340 These statements are concerned with local parts that contain any of the
5341 characters &"@"&, &"%"&, &"!"&, &"/"&, &"|"&, or dots in unusual places.
5342 Although these characters are entirely legal in local parts (in the case of
5343 &"@"& and leading dots, only if correctly quoted), they do not commonly occur
5344 in Internet mail addresses.
5345
5346 The first three have in the past been associated with explicitly routed
5347 addresses (percent is still sometimes used &-- see the &%percent_hack_domains%&
5348 option). Addresses containing these characters are regularly tried by spammers
5349 in an attempt to bypass relaying restrictions, and also by open relay testing
5350 programs. Unless you really need them it is safest to reject these characters
5351 at this early stage. This configuration is heavy-handed in rejecting these
5352 characters for all messages it accepts from remote hosts. This is a deliberate
5353 policy of being as safe as possible.
5354
5355 The first rule above is stricter, and is applied to messages that are addressed
5356 to one of the local domains handled by this host. This is implemented by the
5357 first condition, which restricts it to domains that are listed in the
5358 &'local_domains'& domain list. The &"+"& character is used to indicate a
5359 reference to a named list. In this configuration, there is just one domain in
5360 &'local_domains'&, but in general there may be many.
5361
5362 The second condition on the first statement uses two regular expressions to
5363 block local parts that begin with a dot or contain &"@"&, &"%"&, &"!"&, &"/"&,
5364 or &"|"&. If you have local accounts that include these characters, you will
5365 have to modify this rule.
5366
5367 Empty components (two dots in a row) are not valid in RFC 2822, but Exim
5368 allows them because they have been encountered in practice. (Consider the
5369 common convention of local parts constructed as
5370 &"&'first-initial.second-initial.family-name'&"& when applied to someone like
5371 the author of Exim, who has no second initial.) However, a local part starting
5372 with a dot or containing &"/../"& can cause trouble if it is used as part of a
5373 file name (for example, for a mailing list). This is also true for local parts
5374 that contain slashes. A pipe symbol can also be troublesome if the local part
5375 is incorporated unthinkingly into a shell command line.
5376
5377 The second rule above applies to all other domains, and is less strict. This
5378 allows your own users to send outgoing messages to sites that use slashes
5379 and vertical bars in their local parts. It blocks local parts that begin
5380 with a dot, slash, or vertical bar, but allows these characters within the
5381 local part. However, the sequence &"/../"& is barred. The use of &"@"&, &"%"&,
5382 and &"!"& is blocked, as before. The motivation here is to prevent your users
5383 (or your users' viruses) from mounting certain kinds of attack on remote sites.
5384 .code
5385 accept  local_parts   = postmaster
5386         domains       = +local_domains
5387 .endd
5388 This statement, which has two conditions, accepts an incoming address if the
5389 local part is &'postmaster'& and the domain is one of those listed in the
5390 &'local_domains'& domain list. The &"+"& character is used to indicate a
5391 reference to a named list. In this configuration, there is just one domain in
5392 &'local_domains'&, but in general there may be many.
5393
5394 The presence of this statement means that mail to postmaster is never blocked
5395 by any of the subsequent tests. This can be helpful while sorting out problems
5396 in cases where the subsequent tests are incorrectly denying access.
5397 .code
5398 require verify        = sender
5399 .endd
5400 This statement requires the sender address to be verified before any subsequent
5401 ACL statement can be used. If verification fails, the incoming recipient
5402 address is refused. Verification consists of trying to route the address, to
5403 see if a bounce message could be delivered to it. In the case of remote
5404 addresses, basic verification checks only the domain, but &'callouts'& can be
5405 used for more verification if required. Section &<<SECTaddressverification>>&
5406 discusses the details of address verification.
5407 .code
5408 accept  hosts         = +relay_from_hosts
5409         control       = submission
5410 .endd
5411 This statement accepts the address if the message is coming from one of the
5412 hosts that are defined as being allowed to relay through this host. Recipient
5413 verification is omitted here, because in many cases the clients are dumb MUAs
5414 that do not cope well with SMTP error responses. For the same reason, the
5415 second line specifies &"submission mode"& for messages that are accepted. This
5416 is described in detail in section &<<SECTsubmodnon>>&; it causes Exim to fix
5417 messages that are deficient in some way, for example, because they lack a
5418 &'Date:'& header line. If you are actually relaying out from MTAs, you should
5419 probably add recipient verification here, and disable submission mode.
5420 .code
5421 accept  authenticated = *
5422         control       = submission
5423 .endd
5424 This statement accepts the address if the client host has authenticated itself.
5425 Submission mode is again specified, on the grounds that such messages are most
5426 likely to come from MUAs. The default configuration does not define any
5427 authenticators, though it does include some nearly complete commented-out
5428 examples described in &<<SECTdefconfauth>>&. This means that no client can in
5429 fact authenticate until you complete the authenticator definitions.
5430 .code
5431 require message = relay not permitted
5432         domains = +local_domains : +relay_domains
5433 .endd
5434 This statement rejects the address if its domain is neither a local domain nor
5435 one of the domains for which this host is a relay.
5436 .code
5437 require verify = recipient
5438 .endd
5439 This statement requires the recipient address to be verified; if verification
5440 fails, the address is rejected.
5441 .code
5442 # deny    message     = rejected because $sender_host_address \
5443 #                       is in a black list at $dnslist_domain\n\
5444 #                       $dnslist_text
5445 #         dnslists    = black.list.example
5446 #
5447 # warn    dnslists    = black.list.example
5448 #         add_header  = X-Warning: $sender_host_address is in \
5449 #                       a black list at $dnslist_domain
5450 #         log_message = found in $dnslist_domain
5451 .endd
5452 These commented-out lines are examples of how you could configure Exim to check
5453 sending hosts against a DNS black list. The first statement rejects messages
5454 from blacklisted hosts, whereas the second just inserts a warning header
5455 line.
5456 .code
5457 # require verify = csa
5458 .endd
5459 This commented-out line is an example of how you could turn on client SMTP
5460 authorization (CSA) checking. Such checks do DNS lookups for special SRV
5461 records.
5462 .code
5463 accept
5464 .endd
5465 The final statement in the first ACL unconditionally accepts any recipient
5466 address that has successfully passed all the previous tests.
5467 .code
5468 acl_check_data:
5469 .endd
5470 This line marks the start of the second ACL, and names it. Most of the contents
5471 of this ACL are commented out:
5472 .code
5473 # deny    malware   = *
5474 #         message   = This message contains a virus \
5475 #                     ($malware_name).
5476 .endd
5477 These lines are examples of how to arrange for messages to be scanned for
5478 viruses when Exim has been compiled with the content-scanning extension, and a
5479 suitable virus scanner is installed. If the message is found to contain a
5480 virus, it is rejected with the given custom error message.
5481 .code
5482 # warn    spam      = nobody
5483 #         message   = X-Spam_score: $spam_score\n\
5484 #                     X-Spam_score_int: $spam_score_int\n\
5485 #                     X-Spam_bar: $spam_bar\n\
5486 #                     X-Spam_report: $spam_report
5487 .endd
5488 These lines are an example of how to arrange for messages to be scanned by
5489 SpamAssassin when Exim has been compiled with the content-scanning extension,
5490 and SpamAssassin has been installed. The SpamAssassin check is run with
5491 &`nobody`& as its user parameter, and the results are added to the message as a
5492 series of extra header line. In this case, the message is not rejected,
5493 whatever the spam score.
5494 .code
5495 accept
5496 .endd
5497 This final line in the DATA ACL accepts the message unconditionally.
5498
5499
5500 .section "Router configuration"
5501 .cindex "default" "routers"
5502 .cindex "routers" "default"
5503 The router configuration comes next in the default configuration, introduced
5504 by the line
5505 .code
5506 begin routers
5507 .endd
5508 Routers are the modules in Exim that make decisions about where to send
5509 messages. An address is passed to each router in turn, until it is either
5510 accepted, or failed. This means that the order in which you define the routers
5511 matters. Each router is fully described in its own chapter later in this
5512 manual. Here we give only brief overviews.
5513 .code
5514 # domain_literal:
5515 #   driver = ipliteral
5516 #   domains = !+local_domains
5517 #   transport = remote_smtp
5518 .endd
5519 .cindex "domain literal" "default router"
5520 This router is commented out because the majority of sites do not want to
5521 support domain literal addresses (those of the form &'user@[10.9.8.7]'&). If
5522 you uncomment this router, you also need to uncomment the setting of
5523 &%allow_domain_literals%& in the main part of the configuration.
5524 .code
5525 dnslookup:
5526   driver = dnslookup
5527   domains = ! +local_domains
5528   transport = remote_smtp
5529   ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
5530   no_more
5531 .endd
5532 The first uncommented router handles addresses that do not involve any local
5533 domains. This is specified by the line
5534 .code
5535 domains = ! +local_domains
5536 .endd
5537 The &%domains%& option lists the domains to which this router applies, but the
5538 exclamation mark is a negation sign, so the router is used only for domains
5539 that are not in the domain list called &'local_domains'& (which was defined at
5540 the start of the configuration). The plus sign before &'local_domains'&
5541 indicates that it is referring to a named list. Addresses in other domains are
5542 passed on to the following routers.
5543
5544 The name of the router driver is &(dnslookup)&,
5545 and is specified by the &%driver%& option. Do not be confused by the fact that
5546 the name of this router instance is the same as the name of the driver. The
5547 instance name is arbitrary, but the name set in the &%driver%& option must be
5548 one of the driver modules that is in the Exim binary.
5549
5550 The &(dnslookup)& router routes addresses by looking up their domains in the
5551 DNS in order to obtain a list of hosts to which the address is routed. If the
5552 router succeeds, the address is queued for the &(remote_smtp)& transport, as
5553 specified by the &%transport%& option. If the router does not find the domain
5554 in the DNS, no further routers are tried because of the &%no_more%& setting, so
5555 the address fails and is bounced.
5556
5557 The &%ignore_target_hosts%& option specifies a list of IP addresses that are to
5558 be entirely ignored. This option is present because a number of cases have been
5559 encountered where MX records in the DNS point to host names
5560 whose IP addresses are 0.0.0.0 or are in the 127 subnet (typically 127.0.0.1).
5561 Completely ignoring these IP addresses causes Exim to fail to route the
5562 email address, so it bounces. Otherwise, Exim would log a routing problem, and
5563 continue to try to deliver the message periodically until the address timed
5564 out.
5565 .code
5566 system_aliases:
5567   driver = redirect
5568   allow_fail
5569   allow_defer
5570   data = ${lookup{$local_part}lsearch{/etc/aliases}}
5571 # user = exim
5572   file_transport = address_file
5573   pipe_transport = address_pipe
5574 .endd
5575 Control reaches this and subsequent routers only for addresses in the local
5576 domains. This router checks to see whether the local part is defined as an
5577 alias in the &_/etc/aliases_& file, and if so, redirects it according to the
5578 data that it looks up from that file. If no data is found for the local part,
5579 the value of the &%data%& option is empty, causing the address to be passed to
5580 the next router.
5581
5582 &_/etc/aliases_& is a conventional name for the system aliases file that is
5583 often used. That is why it is referenced by from the default configuration
5584 file. However, you can change this by setting SYSTEM_ALIASES_FILE in
5585 &_Local/Makefile_& before building Exim.
5586 .code
5587 userforward:
5588   driver = redirect
5589   check_local_user
5590 # local_part_suffix = +* : -*
5591 # local_part_suffix_optional
5592   file = $home/.forward
5593 # allow_filter
5594   no_verify
5595   no_expn
5596   check_ancestor
5597   file_transport = address_file
5598   pipe_transport = address_pipe
5599   reply_transport = address_reply
5600 .endd
5601 This is the most complicated router in the default configuration. It is another
5602 redirection router, but this time it is looking for forwarding data set up by
5603 individual users. The &%check_local_user%& setting specifies a check that the
5604 local part of the address is the login name of a local user. If it is not, the
5605 router is skipped. The two commented options that follow &%check_local_user%&,
5606 namely:
5607 .code
5608 # local_part_suffix = +* : -*
5609 # local_part_suffix_optional
5610 .endd
5611 .cindex "&$local_part_suffix$&"
5612 show how you can specify the recognition of local part suffixes. If the first
5613 is uncommented, a suffix beginning with either a plus or a minus sign, followed
5614 by any sequence of characters, is removed from the local part and placed in the
5615 variable &$local_part_suffix$&. The second suffix option specifies that the
5616 presence of a suffix in the local part is optional. When a suffix is present,
5617 the check for a local login uses the local part with the suffix removed.
5618
5619 When a local user account is found, the file called &_.forward_& in the user's
5620 home directory is consulted. If it does not exist, or is empty, the router
5621 declines. Otherwise, the contents of &_.forward_& are interpreted as
5622 redirection data (see chapter &<<CHAPredirect>>& for more details).
5623
5624 .cindex "Sieve filter" "enabling in default router"
5625 Traditional &_.forward_& files contain just a list of addresses, pipes, or
5626 files. Exim supports this by default. However, if &%allow_filter%& is set (it
5627 is commented out by default), the contents of the file are interpreted as a set
5628 of Exim or Sieve filtering instructions, provided the file begins with &"#Exim
5629 filter"& or &"#Sieve filter"&, respectively. User filtering is discussed in the
5630 separate document entitled &'Exim's interfaces to mail filtering'&.
5631
5632 The &%no_verify%& and &%no_expn%& options mean that this router is skipped when
5633 verifying addresses, or when running as a consequence of an SMTP EXPN command.
5634 There are two reasons for doing this:
5635
5636 .olist
5637 Whether or not a local user has a &_.forward_& file is not really relevant when
5638 checking an address for validity; it makes sense not to waste resources doing
5639 unnecessary work.
5640 .next
5641 More importantly, when Exim is verifying addresses or handling an EXPN
5642 command during an SMTP session, it is running as the Exim user, not as root.
5643 The group is the Exim group, and no additional groups are set up.
5644 It may therefore not be possible for Exim to read users' &_.forward_& files at
5645 this time.
5646 .endlist
5647
5648 The setting of &%check_ancestor%& prevents the router from generating a new
5649 address that is the same as any previous address that was redirected. (This
5650 works round a problem concerning a bad interaction between aliasing and
5651 forwarding &-- see section &<<SECTredlocmai>>&).
5652
5653 The final three option settings specify the transports that are to be used when
5654 forwarding generates a direct delivery to a file, or to a pipe, or sets up an
5655 auto-reply, respectively. For example, if a &_.forward_& file contains
5656 .code
5657 a.nother@elsewhere.example, /home/spqr/archive
5658 .endd
5659 the delivery to &_/home/spqr/archive_& is done by running the &%address_file%&
5660 transport.
5661 .code
5662 localuser:
5663   driver = accept
5664   check_local_user
5665 # local_part_suffix = +* : -*
5666 # local_part_suffix_optional
5667   transport = local_delivery
5668 .endd
5669 The final router sets up delivery into local mailboxes, provided that the local
5670 part is the name of a local login, by accepting the address and assigning it to
5671 the &(local_delivery)& transport. Otherwise, we have reached the end of the
5672 routers, so the address is bounced. The commented suffix settings fulfil the
5673 same purpose as they do for the &(userforward)& router.
5674
5675
5676 .section "Transport configuration"
5677 .cindex "default" "transports"
5678 .cindex "transports" "default"
5679 Transports define mechanisms for actually delivering messages. They operate
5680 only when referenced from routers, so the order in which they are defined does
5681 not matter. The transports section of the configuration starts with
5682 .code
5683 begin transports
5684 .endd
5685 One remote transport and four local transports are defined.
5686 .code
5687 remote_smtp:
5688   driver = smtp
5689 .endd
5690 This transport is used for delivering messages over SMTP connections. All its
5691 options are defaulted. The list of remote hosts comes from the router.
5692 .code
5693 local_delivery:
5694   driver = appendfile
5695   file = /var/mail/$local_part
5696   delivery_date_add
5697   envelope_to_add
5698   return_path_add
5699 # group = mail
5700 # mode = 0660
5701 .endd
5702 This &(appendfile)& transport is used for local delivery to user mailboxes in
5703 traditional BSD mailbox format. By default it runs under the uid and gid of the
5704 local user, which requires the sticky bit to be set on the &_/var/mail_&
5705 directory. Some systems use the alternative approach of running mail deliveries
5706 under a particular group instead of using the sticky bit. The commented options
5707 show how this can be done.
5708
5709 Exim adds three headers to the message as it delivers it: &'Delivery-date:'&,
5710 &'Envelope-to:'& and &'Return-path:'&. This action is requested by the three
5711 similarly-named options above.
5712 .code
5713 address_pipe:
5714   driver = pipe
5715   return_output
5716 .endd
5717 This transport is used for handling deliveries to pipes that are generated by
5718 redirection (aliasing or users' &_.forward_& files). The &%return_output%&
5719 option specifies that any output generated by the pipe is to be returned to the
5720 sender.
5721 .code
5722 address_file:
5723   driver = appendfile
5724   delivery_date_add
5725   envelope_to_add
5726   return_path_add
5727 .endd
5728 This transport is used for handling deliveries to files that are generated by
5729 redirection. The name of the file is not specified in this instance of
5730 &(appendfile)&, because it comes from the &(redirect)& router.
5731 .code
5732 address_reply:
5733   driver = autoreply
5734 .endd
5735 This transport is used for handling automatic replies generated by users'
5736 filter files.
5737
5738
5739
5740 .section "Default retry rule"
5741 .cindex "retry" "default rule"
5742 .cindex "default" "retry rule"
5743 The retry section of the configuration file contains rules which affect the way
5744 Exim retries deliveries that cannot be completed at the first attempt. It is
5745 introduced by the line
5746 .code
5747 begin retry
5748 .endd
5749 In the default configuration, there is just one rule, which applies to all
5750 errors:
5751 .code
5752 *   *   F,2h,15m; G,16h,1h,1.5; F,4d,6h
5753 .endd
5754 This causes any temporarily failing address to be retried every 15 minutes for
5755 2 hours, then at intervals starting at one hour and increasing by a factor of
5756 1.5 until 16 hours have passed, then every 6 hours up to 4 days. If an address
5757 is not delivered after 4 days of temporary failure, it is bounced.
5758
5759
5760
5761 .section "Rewriting configuration"
5762 The rewriting section of the configuration, introduced by
5763 .code
5764 begin rewrite
5765 .endd
5766 contains rules for rewriting addresses in messages as they arrive. There are no
5767 rewriting rules in the default configuration file.
5768
5769
5770
5771 .section "Authenticators configuration" "SECTdefconfauth"
5772 .cindex "AUTH" "configuration"
5773 The authenticators section of the configuration, introduced by
5774 .code
5775 begin authenticators
5776 .endd
5777 defines mechanisms for the use of the SMTP AUTH command. The default
5778 configuration file contains two commented-out example authenticators
5779 which support plaintext username/password authentication using the
5780 standard PLAIN mechanism and the traditional but non-standard LOGIN
5781 mechanism, with Exim acting as the server. PLAIN and LOGIN are enough
5782 to support most MUA software.
5783
5784 The example PLAIN authenticator looks like this:
5785 .code
5786 #PLAIN:
5787 #  driver                     = plaintext
5788 #  server_set_id              = $auth2
5789 #  server_prompts             = :
5790 #  server_condition           = Authentication is not yet configured
5791 #  server_advertise_condition = ${if def:tls_cipher }
5792 .endd
5793 And the example LOGIN authenticator looks like this:
5794 .code
5795 #LOGIN:
5796 #  driver                     = plaintext
5797 #  server_set_id              = $auth1
5798 #  server_prompts             = <| Username: | Password:
5799 #  server_condition           = Authentication is not yet configured
5800 #  server_advertise_condition = ${if def:tls_cipher }
5801 .endd
5802
5803 The &%server_set_id%& option makes Exim remember the authenticated username
5804 in &$authenticated_id$&, which can be used later in ACLs or routers. The
5805 &%server_prompts%& option configures the &(plaintext)& authenticator so
5806 that it implements the details of the specific authentication mechanism,
5807 i.e. PLAIN or LOGIN. The &%server_advertise_condition%& setting controls
5808 when Exim offers authentication to clients; in the examples, this is only
5809 when TLS or SSL has been started, so to enable the authenticators you also
5810 need to add support for TLS as described in &<<SECTdefconfmain>>&.
5811
5812 The &%server_condition%& setting defines how to verify that the username and
5813 password are correct. In the examples it just produces an error message.
5814 To make the authenticators work, you can use a string expansion
5815 expression like one of the examples in &<<CHAPplaintext>>&.
5816
5817 .ecindex IIDconfiwal
5818
5819
5820
5821 . ////////////////////////////////////////////////////////////////////////////
5822 . ////////////////////////////////////////////////////////////////////////////
5823
5824 .chapter "Regular expressions" "CHAPregexp"
5825
5826 .cindex "regular expressions" "library"
5827 .cindex "PCRE"
5828 Exim supports the use of regular expressions in many of its options. It
5829 uses the PCRE regular expression library; this provides regular expression
5830 matching that is compatible with Perl 5. The syntax and semantics of
5831 regular expressions is discussed in many Perl reference books, and also in
5832 Jeffrey Friedl's &'Mastering Regular Expressions'&, which is published by
5833 O'Reilly (see &url(http://www.oreilly.com/catalog/regex2/)).
5834
5835 The documentation for the syntax and semantics of the regular expressions that
5836 are supported by PCRE is included in plain text in the file
5837 &_doc/pcrepattern.txt_& in the Exim distribution, and also in the HTML
5838 tarbundle of Exim documentation. It describes in detail the features of the
5839 regular expressions that PCRE supports, so no further description is included
5840 here. The PCRE functions are called from Exim using the default option settings
5841 (that is, with no PCRE options set), except that the PCRE_CASELESS option is
5842 set when the matching is required to be case-insensitive.
5843
5844 In most cases, when a regular expression is required in an Exim configuration,
5845 it has to start with a circumflex, in order to distinguish it from plain text
5846 or an &"ends with"& wildcard. In this example of a configuration setting, the
5847 second item in the colon-separated list is a regular expression.
5848 .code
5849 domains = a.b.c : ^\\d{3} : *.y.z : ...
5850 .endd
5851 The doubling of the backslash is required because of string expansion that
5852 precedes interpretation &-- see section &<<SECTlittext>>& for more discussion
5853 of this issue, and a way of avoiding the need for doubling backslashes. The
5854 regular expression that is eventually used in this example contains just one
5855 backslash. The circumflex is included in the regular expression, and has the
5856 normal effect of &"anchoring"& it to the start of the string that is being
5857 matched.
5858
5859 There are, however, two cases where a circumflex is not required for the
5860 recognition of a regular expression: these are the &%match%& condition in a
5861 string expansion, and the &%matches%& condition in an Exim filter file. In
5862 these cases, the relevant string is always treated as a regular expression; if
5863 it does not start with a circumflex, the expression is not anchored, and can
5864 match anywhere in the subject string.
5865
5866 In all cases, if you want a regular expression to match at the end of a string,
5867 you must code the $ metacharacter to indicate this. For example:
5868 .code
5869 domains = ^\\d{3}\\.example
5870 .endd
5871 matches the domain &'123.example'&, but it also matches &'123.example.com'&.
5872 You need to use:
5873 .code
5874 domains = ^\\d{3}\\.example\$
5875 .endd
5876 if you want &'example'& to be the top-level domain. The backslash before the
5877 $ is needed because string expansion also interprets dollar characters.
5878
5879
5880
5881 .section "Testing regular expressions"
5882 .cindex "testing" "regular expressions"
5883 .cindex "regular expressions" "testing"
5884 .cindex "&'pcretest'&"
5885 A program called &'pcretest'& forms part of the PCRE distribution and is built
5886 with PCRE during the process of building Exim. It is primarily intended for
5887 testing PCRE itself, but it can also be used for experimenting with regular
5888 expressions. After building Exim, the binary can be found in the build
5889 directory (it is not installed anywhere automatically). There is documentation
5890 of various options in &_doc/pcretest.txt_&, but for simple testing, none are
5891 needed. This is the output of a sample run of &'pcretest'&:
5892 .display
5893 &`  re> `&&*&`/^([@]+)@.+\.(ac|edu)\.(?!kr)[a-z]{2}$/`&*&
5894 &`data> `&&*&`x@y.ac.uk`&*&
5895 &` 0: x@y.ac.uk`&
5896 &` 1: x`&
5897 &` 2: ac`&
5898 &`data> `&&*&`x@y.ac.kr`&*&
5899 &`No match`&
5900 &`data> `&&*&`x@y.edu.com`&*&
5901 &`No match`&
5902 &`data> `&&*&`x@y.edu.co`&*&
5903 &` 0: x@y.edu.co`&
5904 &` 1: x`&
5905 &` 2: edu`&
5906 .endd
5907 Input typed by the user is shown in bold face. After the &"re>"& prompt, a
5908 regular expression enclosed in delimiters is expected. If this compiles without
5909 error, &"data>"& prompts are given for strings against which the expression is
5910 matched. An empty data line causes a new regular expression to be read. If the
5911 match is successful, the captured substring values (that is, what would be in
5912 the variables &$0$&, &$1$&, &$2$&, etc.) are shown. The above example tests for
5913 an email address whose domain ends with either &"ac"& or &"edu"& followed by a
5914 two-character top-level domain that is not &"kr"&. The local part is captured
5915 in &$1$& and the &"ac"& or &"edu"& in &$2$&.
5916
5917
5918
5919
5920
5921
5922 . ////////////////////////////////////////////////////////////////////////////
5923 . ////////////////////////////////////////////////////////////////////////////
5924
5925 .chapter "File and database lookups" "CHAPfdlookup"
5926 .scindex IIDfidalo1 "file" "lookups"
5927 .scindex IIDfidalo2 "database lookups"
5928 .cindex "lookup" "description of"
5929 Exim can be configured to look up data in files or databases as it processes
5930 messages. Two different kinds of syntax are used:
5931
5932 .olist
5933 A string that is to be expanded may contain explicit lookup requests. These
5934 cause parts of the string to be replaced by data that is obtained from the
5935 lookup. Lookups of this type are conditional expansion items. Different results
5936 can be defined for the cases of lookup success and failure. See chapter
5937 &<<CHAPexpand>>&, where string expansions are described in detail.
5938 .next
5939 Lists of domains, hosts, and email addresses can contain lookup requests as a
5940 way of avoiding excessively long linear lists. In this case, the data that is
5941 returned by the lookup is often (but not always) discarded; whether the lookup
5942 succeeds or fails is what really counts. These kinds of list are described in
5943 chapter &<<CHAPdomhosaddlists>>&.
5944 .endlist
5945
5946 String expansions, lists, and lookups interact with each other in such a way
5947 that there is no order in which to describe any one of them that does not
5948 involve references to the others. Each of these three chapters makes more sense
5949 if you have read the other two first. If you are reading this for the first
5950 time, be aware that some of it will make a lot more sense after you have read
5951 chapters &<<CHAPdomhosaddlists>>& and &<<CHAPexpand>>&.
5952
5953 .section "Examples of different lookup syntax"
5954 It is easy to confuse the two different kinds of lookup, especially as the
5955 lists that may contain the second kind are always expanded before being
5956 processed as lists. Therefore, they may also contain lookups of the first kind.
5957 Be careful to distinguish between the following two examples:
5958 .code
5959 domains = ${lookup{$sender_host_address}lsearch{/some/file}}
5960 domains = lsearch;/some/file
5961 .endd
5962 The first uses a string expansion, the result of which must be a domain list.
5963 No strings have been specified for a successful or a failing lookup; the
5964 defaults in this case are the looked-up data and an empty string, respectively.
5965 The expansion takes place before the string is processed as a list, and the
5966 file that is searched could contain lines like this:
5967 .code
5968 192.168.3.4: domain1:domain2:...
5969 192.168.1.9: domain3:domain4:...
5970 .endd
5971 When the lookup succeeds, the result of the expansion is a list of domains (and
5972 possibly other types of item that are allowed in domain lists).
5973
5974 In the second example, the lookup is a single item in a domain list. It causes
5975 Exim to use a lookup to see if the domain that is being processed can be found
5976 in the file. The file could contains lines like this:
5977 .code
5978 domain1:
5979 domain2:
5980 .endd
5981 Any data that follows the keys is not relevant when checking that the domain
5982 matches the list item.
5983
5984 It is possible, though no doubt confusing, to use both kinds of lookup at once.
5985 Consider a file containing lines like this:
5986 .code
5987 192.168.5.6: lsearch;/another/file
5988 .endd
5989 If the value of &$sender_host_address$& is 192.168.5.6, expansion of the
5990 first &%domains%& setting above generates the second setting, which therefore
5991 causes a second lookup to occur.
5992
5993 The rest of this chapter describes the different lookup types that are
5994 available. Any of them can be used in any part of the configuration where a
5995 lookup is permitted.
5996
5997
5998 .section "Lookup types"
5999 .cindex "lookup" "types of"
6000 .cindex "single-key lookup" "definition of"
6001 Two different types of data lookup are implemented:
6002
6003 .ilist
6004 The &'single-key'& type requires the specification of a file in which to look,
6005 and a single key to search for. The key must be a non-empty string for the
6006 lookup to succeed. The lookup type determines how the file is searched.
6007 .next
6008 .cindex "query-style lookup" "definition of"
6009 The &'query-style'& type accepts a generalized database query. No particular
6010 key value is assumed by Exim for query-style lookups. You can use whichever
6011 Exim variables you need to construct the database query.
6012 .endlist
6013
6014 The code for each lookup type is in a separate source file that is included in
6015 the binary of Exim only if the corresponding compile-time option is set. The
6016 default settings in &_src/EDITME_& are:
6017 .code
6018 LOOKUP_DBM=yes
6019 LOOKUP_LSEARCH=yes
6020 .endd
6021 which means that only linear searching and DBM lookups are included by default.
6022 For some types of lookup (e.g. SQL databases), you need to install appropriate
6023 libraries and header files before building Exim.
6024
6025
6026
6027
6028 .section "Single-key lookup types" "SECTsinglekeylookups"
6029 .cindex "lookup" "single-key types"
6030 .cindex "single-key lookup" "list of types"
6031 The following single-key lookup types are implemented:
6032
6033 .ilist
6034 .cindex "cdb" "description of"
6035 .cindex "lookup" "cdb"
6036 .cindex "binary zero" "in lookup key"
6037 &(cdb)&: The given file is searched as a Constant DataBase file, using the key
6038 string without a terminating binary zero. The cdb format is designed for
6039 indexed files that are read frequently and never updated, except by total
6040 re-creation. As such, it is particulary suitable for large files containing
6041 aliases or other indexed data referenced by an MTA. Information about cdb can
6042 be found in several places:
6043 .display
6044 &url(http://www.pobox.com/~djb/cdb.html)
6045 &url(ftp://ftp.corpit.ru/pub/tinycdb/)
6046 &url(http://packages.debian.org/stable/utils/freecdb.html)
6047 .endd
6048 A cdb distribution is not needed in order to build Exim with cdb support,
6049 because the code for reading cdb files is included directly in Exim itself.
6050 However, no means of building or testing cdb files is provided with Exim, so
6051 you need to obtain a cdb distribution in order to do this.
6052 .next
6053 .cindex "DBM" "lookup type"
6054 .cindex "lookup" "dbm"
6055 .cindex "binary zero" "in lookup key"
6056 &(dbm)&: Calls to DBM library functions are used to extract data from the given
6057 DBM file by looking up the record with the given key. A terminating binary
6058 zero is included in the key that is passed to the DBM library. See section
6059 &<<SECTdb>>& for a discussion of DBM libraries.
6060
6061 .cindex "Berkeley DB library" "file format"
6062 For all versions of Berkeley DB, Exim uses the DB_HASH style of database
6063 when building DBM files using the &%exim_dbmbuild%& utility. However, when
6064 using Berkeley DB versions 3 or 4, it opens existing databases for reading with
6065 the DB_UNKNOWN option. This enables it to handle any of the types of database
6066 that the library supports, and can be useful for accessing DBM files created by
6067 other applications. (For earlier DB versions, DB_HASH is always used.)
6068 .next
6069 .cindex "lookup" "dbmnz"
6070 .cindex "lookup" "dbm &-- terminating zero"
6071 .cindex "binary zero" "in lookup key"
6072 .cindex "Courier"
6073 .cindex "&_/etc/userdbshadow.dat_&"
6074 .cindex "dmbnz lookup type"
6075 &(dbmnz)&: This is the same as &(dbm)&, except that a terminating binary zero
6076 is not included in the key that is passed to the DBM library. You may need this
6077 if you want to look up data in files that are created by or shared with some
6078 other application that does not use terminating zeros. For example, you need to
6079 use &(dbmnz)& rather than &(dbm)& if you want to authenticate incoming SMTP
6080 calls using the passwords from Courier's &_/etc/userdbshadow.dat_& file. Exim's
6081 utility program for creating DBM files (&'exim_dbmbuild'&) includes the zeros
6082 by default, but has an option to omit them (see section &<<SECTdbmbuild>>&).
6083 .next
6084 .cindex "lookup" "dsearch"
6085 .cindex "dsearch lookup type"
6086 &(dsearch)&: The given file must be a directory; this is searched for a file
6087 whose name is the key. The key may not contain any forward slash characters.
6088 The result of a successful lookup is the name of the file. An example of how
6089 this lookup can be used to support virtual domains is given in section
6090 &<<SECTvirtualdomains>>&.
6091 .next
6092 .cindex "lookup" "iplsearch"
6093 .cindex "iplsearch lookup type"
6094 &(iplsearch)&: The given file is a text file containing keys and data. A key is
6095 terminated by a colon or white space or the end of the line. The keys in the
6096 file must be IP addresses, or IP addresses with CIDR masks. Keys that involve
6097 IPv6 addresses must be enclosed in quotes to prevent the first internal colon
6098 being interpreted as a key terminator. For example:
6099 .code
6100 1.2.3.4:           data for 1.2.3.4
6101 192.168.0.0/16     data for 192.168.0.0/16
6102 "abcd::cdab":      data for abcd::cdab
6103 "abcd:abcd::/32"   data for abcd:abcd::/32
6104 .endd
6105 The key for an &(iplsearch)& lookup must be an IP address (without a mask). The
6106 file is searched linearly, using the CIDR masks where present, until a matching
6107 key is found. The first key that matches is used; there is no attempt to find a
6108 &"best"& match. Apart from the way the keys are matched, the processing for
6109 &(iplsearch)& is the same as for &(lsearch)&.
6110
6111 &*Warning 1*&: Unlike most other single-key lookup types, a file of data for
6112 &(iplsearch)& can &'not'& be turned into a DBM or cdb file, because those
6113 lookup types support only literal keys.
6114
6115 &*Warning 2*&: In a host list, you must always use &(net-iplsearch)& so that
6116 the implicit key is the host's IP address rather than its name (see section
6117 &<<SECThoslispatsikey>>&).
6118 .next
6119 .cindex "linear search"
6120 .cindex "lookup" "lsearch"
6121 .cindex "lsearch lookup type"
6122 .cindex "case sensitivity" "in lsearch lookup"
6123 &(lsearch)&: The given file is a text file that is searched linearly for a
6124 line beginning with the search key, terminated by a colon or white space or the
6125 end of the line. The search is case-insensitive; that is, upper and lower case
6126 letters are treated as the same. The first occurrence of the key that is found
6127 in the file is used.
6128
6129 White space between the key and the colon is permitted. The remainder of the
6130 line, with leading and trailing white space removed, is the data. This can be
6131 continued onto subsequent lines by starting them with any amount of white
6132 space, but only a single space character is included in the data at such a
6133 junction. If the data begins with a colon, the key must be terminated by a
6134 colon, for example:
6135 .code
6136 baduser:  :fail:
6137 .endd
6138 Empty lines and lines beginning with # are ignored, even if they occur in the
6139 middle of an item. This is the traditional textual format of alias files. Note
6140 that the keys in an &(lsearch)& file are literal strings. There is no
6141 wildcarding of any kind.
6142
6143 .cindex "lookup" "lsearch &-- colons in keys"
6144 .cindex "white space" "in lsearch key"
6145 In most &(lsearch)& files, keys are not required to contain colons or #
6146 characters, or white space. However, if you need this feature, it is available.
6147 If a key begins with a doublequote character, it is terminated only by a
6148 matching quote (or end of line), and the normal escaping rules apply to its
6149 contents (see section &<<SECTstrings>>&). An optional colon is permitted after
6150 quoted keys (exactly as for unquoted keys). There is no special handling of
6151 quotes for the data part of an &(lsearch)& line.
6152
6153 .next
6154 .cindex "NIS lookup type"
6155 .cindex "lookup" "NIS"
6156 .cindex "binary zero" "in lookup key"
6157 &(nis)&: The given file is the name of a NIS map, and a NIS lookup is done with
6158 the given key, without a terminating binary zero. There is a variant called
6159 &(nis0)& which does include the terminating binary zero in the key. This is
6160 reportedly needed for Sun-style alias files. Exim does not recognize NIS
6161 aliases; the full map names must be used.
6162
6163 .next
6164 .cindex "wildlsearch lookup type"
6165 .cindex "lookup" "wildlsearch"
6166 .cindex "nwildlsearch lookup type"
6167 .cindex "lookup" "nwildlsearch"
6168 &(wildlsearch)& or &(nwildlsearch)&: These search a file linearly, like
6169 &(lsearch)&, but instead of being interpreted as a literal string, each key in
6170 the file may be wildcarded. The difference between these two lookup types is
6171 that for &(wildlsearch)&, each key in the file is string-expanded before being
6172 used, whereas for &(nwildlsearch)&, no expansion takes place.
6173
6174 .cindex "case sensitivity" "in (n)wildlsearch lookup"
6175 Like &(lsearch)&, the testing is done case-insensitively. However, keys in the
6176 file that are regular expressions can be made case-sensitive by the use of
6177 &`(-i)`& within the pattern. The following forms of wildcard are recognized:
6178
6179 . ==== As this is a nested list, any displays it contains must be indented
6180 . ==== as otherwise they are too far to the left.
6181
6182 .olist
6183 The string may begin with an asterisk to mean &"ends with"&. For example:
6184 .code
6185     *.a.b.c       data for anything.a.b.c
6186     *fish         data for anythingfish
6187 .endd
6188 .next
6189 The string may begin with a circumflex to indicate a regular expression. For
6190 example, for &(wildlsearch)&:
6191 .code
6192     ^\N\d+\.a\.b\N    data for <digits>.a.b
6193 .endd
6194 Note the use of &`\N`& to disable expansion of the contents of the regular
6195 expression. If you are using &(nwildlsearch)&, where the keys are not
6196 string-expanded, the equivalent entry is:
6197 .code
6198     ^\d+\.a\.b        data for <digits>.a.b
6199 .endd
6200 The case-insensitive flag is set at the start of compiling the regular
6201 expression, but it can be turned off by using &`(-i)`& at an appropriate point.
6202 For example, to make the entire pattern case-sensitive:
6203 .code
6204     ^(?-i)\d+\.a\.b        data for <digits>.a.b
6205 .endd
6206
6207 If the regular expression contains white space or colon characters, you must
6208 either quote it (see &(lsearch)& above), or represent these characters in other
6209 ways. For example, &`\s`& can be used for white space and &`\x3A`& for a
6210 colon. This may be easier than quoting, because if you quote, you have to
6211 escape all the backslashes inside the quotes.
6212
6213 &*Note*&: It is not possible to capture substrings in a regular expression
6214 match for later use, because the results of all lookups are cached. If a lookup
6215 is repeated, the result is taken from the cache, and no actual pattern matching
6216 takes place. The values of all the numeric variables are unset after a
6217 &((n)wildlsearch)& match.
6218
6219 .next
6220 Although I cannot see it being of much use, the general matching function that
6221 is used to implement &((n)wildlsearch)& means that the string may begin with a
6222 lookup name terminated by a semicolon, and followed by lookup data. For
6223 example:
6224 .code
6225     cdb;/some/file  data for keys that match the file
6226 .endd
6227 The data that is obtained from the nested lookup is discarded.
6228 .endlist olist
6229
6230 Keys that do not match any of these patterns are interpreted literally. The
6231 continuation rules for the data are the same as for &(lsearch)&, and keys may
6232 be followed by optional colons.
6233
6234 &*Warning*&: Unlike most other single-key lookup types, a file of data for
6235 &((n)wildlsearch)& can &'not'& be turned into a DBM or cdb file, because those
6236 lookup types support only literal keys.
6237 .endlist ilist
6238
6239
6240 .section "Query-style lookup types"
6241 .cindex "lookup" "query-style types"
6242 .cindex "query-style lookup" "list of types"
6243 The supported query-style lookup types are listed below. Further details about
6244 many of them are given in later sections.
6245
6246 .ilist
6247 .cindex "DNS" "as a lookup type"
6248 .cindex "lookup" "DNS"
6249 &(dnsdb)&: This does a DNS search for one or more records whose domain names
6250 are given in the supplied query. The resulting data is the contents of the
6251 records. See section &<<SECTdnsdb>>&.
6252 .next
6253 .cindex "InterBase lookup type"
6254 .cindex "lookup" "InterBase"
6255 &(ibase)&: This does a lookup in an InterBase database.
6256 .next
6257 .cindex "LDAP" "lookup type"
6258 .cindex "lookup" "LDAP"
6259 &(ldap)&: This does an LDAP lookup using a query in the form of a URL, and
6260 returns attributes from a single entry. There is a variant called &(ldapm)&
6261 that permits values from multiple entries to be returned. A third variant
6262 called &(ldapdn)& returns the Distinguished Name of a single entry instead of
6263 any attribute values. See section &<<SECTldap>>&.
6264 .next
6265 .cindex "MySQL" "lookup type"
6266 .cindex "lookup" "MySQL"
6267 &(mysql)&: The format of the query is an SQL statement that is passed to a
6268 MySQL database. See section &<<SECTsql>>&.
6269 .next
6270 .cindex "NIS+ lookup type"
6271 .cindex "lookup" "NIS+"
6272 &(nisplus)&: This does a NIS+ lookup using a query that can specify the name of
6273 the field to be returned. See section &<<SECTnisplus>>&.
6274 .next
6275 .cindex "Oracle" "lookup type"
6276 .cindex "lookup" "Oracle"
6277 &(oracle)&: The format of the query is an SQL statement that is passed to an
6278 Oracle database. See section &<<SECTsql>>&.
6279 .next
6280 .cindex "lookup" "passwd"
6281 .cindex "passwd lookup type"
6282 .cindex "&_/etc/passwd_&"
6283 &(passwd)& is a query-style lookup with queries that are just user names. The
6284 lookup calls &[getpwnam()]& to interrogate the system password data, and on
6285 success, the result string is the same as you would get from an &(lsearch)&
6286 lookup on a traditional &_/etc/passwd file_&, though with &`*`& for the
6287 password value. For example:
6288 .code
6289 *:42:42:King Rat:/home/kr:/bin/bash
6290 .endd
6291 .next
6292 .cindex "PostgreSQL lookup type"
6293 .cindex "lookup" "PostgreSQL"
6294 &(pgsql)&: The format of the query is an SQL statement that is passed to a
6295 PostgreSQL database. See section &<<SECTsql>>&.
6296
6297 .next
6298 .cindex "sqlite lookup type"
6299 .cindex "lookup" "sqlite"
6300 &(sqlite)&: The format of the query is a file name followed by an SQL statement
6301 that is passed to an SQLite database. See section &<<SECTsqlite>>&.
6302
6303 .next
6304 &(testdb)&: This is a lookup type that is used for testing Exim. It is
6305 not likely to be useful in normal operation.
6306 .next
6307 .cindex "whoson lookup type"
6308 .cindex "lookup" "whoson"
6309 &(whoson)&: &'Whoson'& (&url(http://whoson.sourceforge.net)) is a proposed
6310 Internet protocol that allows Internet server programs to check whether a
6311 particular (dynamically allocated) IP address is currently allocated to a known
6312 (trusted) user and, optionally, to obtain the identity of the said user. In
6313 Exim, this can be used to implement &"POP before SMTP"& checking using ACL
6314 statements such as
6315 .code
6316 require condition = \
6317   ${lookup whoson {$sender_host_address}{yes}{no}}
6318 .endd
6319 The query consists of a single IP address. The value returned is the name of
6320 the authenticated user, which is stored in the variable &$value$&. However, in
6321 this example, the data in &$value$& is not used; the result of the lookup is
6322 one of the fixed strings &"yes"& or &"no"&.
6323 .endlist
6324
6325
6326
6327 .section "Temporary errors in lookups"
6328 .cindex "lookup" "temporary error in"
6329 Lookup functions can return temporary error codes if the lookup cannot be
6330 completed. For example, an SQL or LDAP database might be unavailable. For this
6331 reason, it is not advisable to use a lookup that might do this for critical
6332 options such as a list of local domains.
6333
6334 When a lookup cannot be completed in a router or transport, delivery
6335 of the message (to the relevant address) is deferred, as for any other
6336 temporary error. In other circumstances Exim may assume the lookup has failed,
6337 or may give up altogether.
6338
6339
6340
6341 .section "Default values in single-key lookups" "SECTdefaultvaluelookups"
6342 .cindex "wildcard lookups"
6343 .cindex "lookup" "default values"
6344 .cindex "lookup" "wildcard"
6345 .cindex "lookup" "* added to type"
6346 .cindex "default" "in single-key lookups"
6347 In this context, a &"default value"& is a value specified by the administrator
6348 that is to be used if a lookup fails.
6349
6350 .new
6351 &*Note:*& This section applies only to single-key lookups. For query-style
6352 lookups, the facilities of the query language must be used. An attempt to
6353 specify a default for a query-style lookup provokes an error.
6354 .wen
6355
6356 If &"*"& is added to a single-key lookup type (for example, &%lsearch*%&)
6357 and the initial lookup fails, the key &"*"& is looked up in the file to
6358 provide a default value. See also the section on partial matching below.
6359
6360 .cindex "*@ with single-key lookup"
6361 .cindex "lookup" "*@ added to type"
6362 .cindex "alias file" "per-domain default"
6363 Alternatively, if &"*@"& is added to a single-key lookup type (for example
6364 &%dbm*@%&) then, if the initial lookup fails and the key contains an @
6365 character, a second lookup is done with everything before the last @ replaced
6366 by *. This makes it possible to provide per-domain defaults in alias files
6367 that include the domains in the keys. If the second lookup fails (or doesn't
6368 take place because there is no @ in the key), &"*"& is looked up.
6369 For example, a &(redirect)& router might contain:
6370 .code
6371 data = ${lookup{$local_part@$domain}lsearch*@{/etc/mix-aliases}}
6372 .endd
6373 Suppose the address that is being processed is &'jane@eyre.example'&. Exim
6374 looks up these keys, in this order:
6375 .code
6376 jane@eyre.example
6377 *@eyre.example
6378 *
6379 .endd
6380 The data is taken from whichever key it finds first. &*Note*&: In an
6381 &(lsearch)& file, this does not mean the first of these keys in the file. A
6382 complete scan is done for each key, and only if it is not found at all does
6383 Exim move on to try the next key.
6384
6385
6386
6387 .section "Partial matching in single-key lookups" "SECTpartiallookup"
6388 .cindex "partial matching"
6389 .cindex "wildcard lookups"
6390 .cindex "lookup" "partial matching"
6391 .cindex "lookup" "wildcard"
6392 .cindex "asterisk" "in search type"
6393 The normal operation of a single-key lookup is to search the file for an exact
6394 match with the given key. However, in a number of situations where domains are
6395 being looked up, it is useful to be able to do partial matching. In this case,
6396 information in the file that has a key starting with &"*."& is matched by any
6397 domain that ends with the components that follow the full stop. For example, if
6398 a key in a DBM file is
6399 .code
6400 *.dates.fict.example
6401 .endd
6402 then when partial matching is enabled this is matched by (amongst others)
6403 &'2001.dates.fict.example'& and &'1984.dates.fict.example'&. It is also matched
6404 by &'dates.fict.example'&, if that does not appear as a separate key in the
6405 file.
6406
6407 &*Note*&: Partial matching is not available for query-style lookups. It is
6408 also not available for any lookup items in address lists (see section
6409 &<<SECTaddresslist>>&).
6410
6411 Partial matching is implemented by doing a series of separate lookups using
6412 keys constructed by modifying the original subject key. This means that it can
6413 be used with any of the single-key lookup types, provided that
6414 partial matching keys
6415 beginning with a special prefix (default &"*."&) are included in the data file.
6416 Keys in the file that do not begin with the prefix are matched only by
6417 unmodified subject keys when partial matching is in use.
6418
6419 Partial matching is requested by adding the string &"partial-"& to the front of
6420 the name of a single-key lookup type, for example, &%partial-dbm%&. When this
6421 is done, the subject key is first looked up unmodified; if that fails, &"*."&
6422 is added at the start of the subject key, and it is looked up again. If that
6423 fails, further lookups are tried with dot-separated components removed from the
6424 start of the subject key, one-by-one, and &"*."& added on the front of what
6425 remains.
6426
6427 A minimum number of two non-* components are required. This can be adjusted
6428 by including a number before the hyphen in the search type. For example,
6429 &%partial3-lsearch%& specifies a minimum of three non-* components in the
6430 modified keys. Omitting the number is equivalent to &"partial2-"&. If the
6431 subject key is &'2250.dates.fict.example'& then the following keys are looked
6432 up when the minimum number of non-* components is two:
6433 .code
6434 2250.dates.fict.example
6435 *.2250.dates.fict.example
6436 *.dates.fict.example
6437 *.fict.example
6438 .endd
6439 As soon as one key in the sequence is successfully looked up, the lookup
6440 finishes.
6441
6442 .cindex "lookup" "partial matching &-- changing prefix"
6443 .cindex "prefix" "for partial matching"
6444 The use of &"*."& as the partial matching prefix is a default that can be
6445 changed. The motivation for this feature is to allow Exim to operate with file
6446 formats that are used by other MTAs. A different prefix can be supplied in
6447 parentheses instead of the hyphen after &"partial"&. For example:
6448 .code
6449 domains = partial(.)lsearch;/some/file
6450 .endd
6451 In this example, if the domain is &'a.b.c'&, the sequence of lookups is
6452 &`a.b.c`&, &`.a.b.c`&, and &`.b.c`& (the default minimum of 2 non-wild
6453 components is unchanged). The prefix may consist of any punctuation characters
6454 other than a closing parenthesis. It may be empty, for example:
6455 .code
6456 domains = partial1()cdb;/some/file
6457 .endd
6458 For this example, if the domain is &'a.b.c'&, the sequence of lookups is
6459 &`a.b.c`&, &`b.c`&, and &`c`&.
6460
6461 If &"partial0"& is specified, what happens at the end (when the lookup with
6462 just one non-wild component has failed, and the original key is shortened right
6463 down to the null string) depends on the prefix:
6464
6465 .ilist
6466 If the prefix has zero length, the whole lookup fails.
6467 .next
6468 If the prefix has length 1, a lookup for just the prefix is done. For
6469 example, the final lookup for &"partial0(.)"& is for &`.`& alone.
6470 .next
6471 Otherwise, if the prefix ends in a dot, the dot is removed, and the
6472 remainder is looked up. With the default prefix, therefore, the final lookup is
6473 for &"*"& on its own.
6474 .next
6475 Otherwise, the whole prefix is looked up.
6476 .endlist
6477
6478
6479 If the search type ends in &"*"& or &"*@"& (see section
6480 &<<SECTdefaultvaluelookups>>& above), the search for an ultimate default that
6481 this implies happens after all partial lookups have failed. If &"partial0"& is
6482 specified, adding &"*"& to the search type has no effect with the default
6483 prefix, because the &"*"& key is already included in the sequence of partial
6484 lookups. However, there might be a use for lookup types such as
6485 &"partial0(.)lsearch*"&.
6486
6487 The use of &"*"& in lookup partial matching differs from its use as a wildcard
6488 in domain lists and the like. Partial matching works only in terms of
6489 dot-separated components; a key such as &`*fict.example`&
6490 in a database file is useless, because the asterisk in a partial matching
6491 subject key is always followed by a dot.
6492
6493
6494
6495
6496 .section "Lookup caching"
6497 .cindex "lookup" "caching"
6498 .cindex "caching" "lookup data"
6499 Exim caches all lookup results in order to avoid needless repetition of
6500 lookups. However, because (apart from the daemon) Exim operates as a collection
6501 of independent, short-lived processes, this caching applies only within a
6502 single Exim process. There is no inter-process lookup caching facility.
6503
6504 For single-key lookups, Exim keeps the relevant files open in case there is
6505 another lookup that needs them. In some types of configuration this can lead to
6506 many files being kept open for messages with many recipients. To avoid hitting
6507 the operating system limit on the number of simultaneously open files, Exim
6508 closes the least recently used file when it needs to open more files than its
6509 own internal limit, which can be changed via the &%lookup_open_max%& option.
6510
6511 The single-key lookup files are closed and the lookup caches are flushed at
6512 strategic points during delivery &-- for example, after all routing is
6513 complete.
6514
6515
6516
6517
6518 .section "Quoting lookup data"
6519 .cindex "lookup" "quoting"
6520 .cindex "quoting" "in lookups"
6521 When data from an incoming message is included in a query-style lookup, there
6522 is the possibility of special characters in the data messing up the syntax of
6523 the query. For example, a NIS+ query that contains
6524 .code
6525 [name=$local_part]
6526 .endd
6527 will be broken if the local part happens to contain a closing square bracket.
6528 For NIS+, data can be enclosed in double quotes like this:
6529 .code
6530 [name="$local_part"]
6531 .endd
6532 but this still leaves the problem of a double quote in the data. The rule for
6533 NIS+ is that double quotes must be doubled. Other lookup types have different
6534 rules, and to cope with the differing requirements, an expansion operator
6535 of the following form is provided:
6536 .code
6537 ${quote_<lookup-type>:<string>}
6538 .endd
6539 For example, the safest way to write the NIS+ query is
6540 .code
6541 [name="${quote_nisplus:$local_part}"]
6542 .endd
6543 See chapter &<<CHAPexpand>>& for full coverage of string expansions. The quote
6544 operator can be used for all lookup types, but has no effect for single-key
6545 lookups, since no quoting is ever needed in their key strings.
6546
6547
6548
6549
6550 .section "More about dnsdb" "SECTdnsdb"
6551 .cindex "dnsdb lookup"
6552 .cindex "lookup" "dnsdb"
6553 .cindex "DNS" "as a lookup type"
6554 The &(dnsdb)& lookup type uses the DNS as its database. A simple query consists
6555 of a record type and a domain name, separated by an equals sign. For example,
6556 an expansion string could contain:
6557 .code
6558 ${lookup dnsdb{mx=a.b.example}{$value}fail}
6559 .endd
6560 If the lookup succeeds, the result is placed in &$value$&, which in this case
6561 is used on its own as the result. If the lookup does not succeed, the
6562 &`fail`& keyword causes a &'forced expansion failure'& &-- see section
6563 &<<SECTforexpfai>>& for an explanation of what this means.
6564
6565 The supported DNS record types are A, CNAME, MX, NS, PTR, SRV, and TXT, and,
6566 when Exim is compiled with IPv6 support, AAAA (and A6 if that is also
6567 configured). If no type is given, TXT is assumed. When the type is PTR,
6568 the data can be an IP address, written as normal; inversion and the addition of
6569 &%in-addr.arpa%& or &%ip6.arpa%& happens automatically. For example:
6570 .code
6571 ${lookup dnsdb{ptr=192.168.4.5}{$value}fail}
6572 .endd
6573 If the data for a PTR record is not a syntactically valid IP address, it is not
6574 altered and nothing is added.
6575
6576 .cindex "MX record" "in &(dnsdb)& lookup"
6577 .cindex "SRV record" "in &(dnsdb)& lookup"
6578 For an MX lookup, both the preference value and the host name are returned for
6579 each record, separated by a space. For an SRV lookup, the priority, weight,
6580 port, and host name are returned for each record, separated by spaces.
6581
6582 For any record type, if multiple records are found (or, for A6 lookups, if a
6583 single record leads to multiple addresses), the data is returned as a
6584 concatenation, with newline as the default separator. The order, of course,
6585 depends on the DNS resolver. You can specify a different separator character
6586 between multiple records by putting a right angle-bracket followed immediately
6587 by the new separator at the start of the query. For example:
6588 .code
6589 ${lookup dnsdb{>: a=host1.example}}
6590 .endd
6591 It is permitted to specify a space as the separator character. Further
6592 white space is ignored.
6593
6594 .section "Pseudo dnsdb record types"
6595 .cindex "MX record" "in &(dnsdb)& lookup"
6596 By default, both the preference value and the host name are returned for
6597 each MX record, separated by a space. If you want only host names, you can use
6598 the pseudo-type MXH:
6599 .code
6600 ${lookup dnsdb{mxh=a.b.example}}
6601 .endd
6602 In this case, the preference values are omitted, and just the host names are
6603 returned.
6604
6605 .cindex "name server" "for enclosing domain"
6606 Another pseudo-type is ZNS (for &"zone NS"&). It performs a lookup for NS
6607 records on the given domain, but if none are found, it removes the first
6608 component of the domain name, and tries again. This process continues until NS
6609 records are found or there are no more components left (or there is a DNS
6610 error). In other words, it may return the name servers for a top-level domain,
6611 but it never returns the root name servers. If there are no NS records for the
6612 top-level domain, the lookup fails. Consider these examples:
6613 .code
6614 ${lookup dnsdb{zns=xxx.quercite.com}}
6615 ${lookup dnsdb{zns=xxx.edu}}
6616 .endd
6617 Assuming that in each case there are no NS records for the full domain name,
6618 the first returns the name servers for &%quercite.com%&, and the second returns
6619 the name servers for &%edu%&.
6620
6621 You should be careful about how you use this lookup because, unless the
6622 top-level domain does not exist, the lookup always returns some host names. The
6623 sort of use to which this might be put is for seeing if the name servers for a
6624 given domain are on a blacklist. You can probably assume that the name servers
6625 for the high-level domains such as &%com%& or &%co.uk%& are not going to be on
6626 such a list.
6627
6628 .cindex "CSA" "in &(dnsdb)& lookup"
6629 A third pseudo-type is CSA (Client SMTP Authorization). This looks up SRV
6630 records according to the CSA rules, which are described in section
6631 &<<SECTverifyCSA>>&. Although &(dnsdb)& supports SRV lookups directly, this is
6632 not sufficient because of the extra parent domain search behaviour of CSA. The
6633 result of a successful lookup such as:
6634 .code
6635 ${lookup dnsdb {csa=$sender_helo_name}}
6636 .endd
6637 has two space-separated fields: an authorization code and a target host name.
6638 The authorization code can be &"Y"& for yes, &"N"& for no, &"X"& for explicit
6639 authorization required but absent, or &"?"& for unknown.
6640
6641
6642 .section "Multiple dnsdb lookups"
6643 In the previous sections, &(dnsdb)& lookups for a single domain are described.
6644 However, you can specify a list of domains or IP addresses in a single
6645 &(dnsdb)& lookup. The list is specified in the normal Exim way, with colon as
6646 the default separator, but with the ability to change this. For example:
6647 .code
6648 ${lookup dnsdb{one.domain.com:two.domain.com}}
6649 ${lookup dnsdb{a=one.host.com:two.host.com}}
6650 ${lookup dnsdb{ptr = <; 1.2.3.4 ; 4.5.6.8}}
6651 .endd
6652 In order to retain backwards compatibility, there is one special case: if
6653 the lookup type is PTR and no change of separator is specified, Exim looks
6654 to see if the rest of the string is precisely one IPv6 address. In this
6655 case, it does not treat it as a list.
6656
6657 The data from each lookup is concatenated, with newline separators by default,
6658 in the same way that multiple DNS records for a single item are handled. A
6659 different separator can be specified, as described above.
6660
6661 The &(dnsdb)& lookup fails only if all the DNS lookups fail. If there is a
6662 temporary DNS error for any of them, the behaviour is controlled by
6663 an optional keyword followed by a comma that may appear before the record
6664 type. The possible keywords are &"defer_strict"&, &"defer_never"&, and
6665 &"defer_lax"&. With &"strict"& behaviour, any temporary DNS error causes the
6666 whole lookup to defer. With &"never"& behaviour, a temporary DNS error is
6667 ignored, and the behaviour is as if the DNS lookup failed to find anything.
6668 With &"lax"& behaviour, all the queries are attempted, but a temporary DNS
6669 error causes the whole lookup to defer only if none of the other lookups
6670 succeed. The default is &"lax"&, so the following lookups are equivalent:
6671 .code
6672 ${lookup dnsdb{defer_lax,a=one.host.com:two.host.com}}
6673 ${lookup dnsdb{a=one.host.com:two.host.com}}
6674 .endd
6675 Thus, in the default case, as long as at least one of the DNS lookups
6676 yields some data, the lookup succeeds.
6677
6678
6679
6680
6681 .section "More about LDAP" "SECTldap"
6682 .cindex "LDAP lookup"
6683 .cindex "lookup" "LDAP"
6684 .cindex "Solaris" "LDAP"
6685 The original LDAP implementation came from the University of Michigan; this has
6686 become &"Open LDAP"&, and there are now two different releases. Another
6687 implementation comes from Netscape, and Solaris 7 and subsequent releases
6688 contain inbuilt LDAP support. Unfortunately, though these are all compatible at
6689 the lookup function level, their error handling is different. For this reason
6690 it is necessary to set a compile-time variable when building Exim with LDAP, to
6691 indicate which LDAP library is in use. One of the following should appear in
6692 your &_Local/Makefile_&:
6693 .code
6694 LDAP_LIB_TYPE=UMICHIGAN
6695 LDAP_LIB_TYPE=OPENLDAP1
6696 LDAP_LIB_TYPE=OPENLDAP2
6697 LDAP_LIB_TYPE=NETSCAPE
6698 LDAP_LIB_TYPE=SOLARIS
6699 .endd
6700 If LDAP_LIB_TYPE is not set, Exim assumes &`OPENLDAP1`&, which has the
6701 same interface as the University of Michigan version.
6702
6703 There are three LDAP lookup types in Exim. These behave slightly differently in
6704 the way they handle the results of a query:
6705
6706 .ilist
6707 &(ldap)& requires the result to contain just one entry; if there are more, it
6708 gives an error.
6709 .next
6710 &(ldapdn)& also requires the result to contain just one entry, but it is the
6711 Distinguished Name that is returned rather than any attribute values.
6712 .next
6713 &(ldapm)& permits the result to contain more than one entry; the attributes
6714 from all of them are returned.
6715 .endlist
6716
6717
6718 For &(ldap)& and &(ldapm)&, if a query finds only entries with no attributes,
6719 Exim behaves as if the entry did not exist, and the lookup fails. The format of
6720 the data returned by a successful lookup is described in the next section.
6721 First we explain how LDAP queries are coded.
6722
6723
6724 .section "Format of LDAP queries" "SECTforldaque"
6725 .cindex "LDAP" "query format"
6726 An LDAP query takes the form of a URL as defined in RFC 2255. For example, in
6727 the configuration of a &(redirect)& router one might have this setting:
6728 .code
6729 data = ${lookup ldap \
6730   {ldap:///cn=$local_part,o=University%20of%20Cambridge,\
6731   c=UK?mailbox?base?}}
6732 .endd
6733 .cindex "LDAP" "with TLS"
6734 The URL may begin with &`ldap`& or &`ldaps`& if your LDAP library supports
6735 secure (encrypted) LDAP connections. The second of these ensures that an
6736 encrypted TLS connection is used.
6737
6738
6739 .section "LDAP quoting"
6740 .cindex "LDAP" "quoting"
6741 Two levels of quoting are required in LDAP queries, the first for LDAP itself
6742 and the second because the LDAP query is represented as a URL. Furthermore,
6743 within an LDAP query, two different kinds of quoting are required. For this
6744 reason, there are two different LDAP-specific quoting operators.
6745
6746 The &%quote_ldap%& operator is designed for use on strings that are part of
6747 filter specifications. Conceptually, it first does the following conversions on
6748 the string:
6749 .code
6750 *   =>   \2A
6751 (   =>   \28
6752 )   =>   \29
6753 \   =>   \5C
6754 .endd
6755 in accordance with RFC 2254. The resulting string is then quoted according
6756 to the rules for URLs, that is, all non-alphanumeric characters except
6757 .code
6758 ! $ ' - . _ ( ) * +
6759 .endd
6760 are converted to their hex values, preceded by a percent sign. For example:
6761 .code
6762 ${quote_ldap: a(bc)*, a<yz>; }
6763 .endd
6764 yields
6765 .code
6766 %20a%5C28bc%5C29%5C2A%2C%20a%3Cyz%3E%3B%20
6767 .endd
6768 Removing the URL quoting, this is (with a leading and a trailing space):
6769 .code
6770 a\28bc\29\2A, a<yz>;
6771 .endd
6772 The &%quote_ldap_dn%& operator is designed for use on strings that are part of
6773 base DN specifications in queries. Conceptually, it first converts the string
6774 by inserting a backslash in front of any of the following characters:
6775 .code
6776 , + " \ < > ;
6777 .endd
6778 It also inserts a backslash before any leading spaces or # characters, and
6779 before any trailing spaces. (These rules are in RFC 2253.) The resulting string
6780 is then quoted according to the rules for URLs. For example:
6781 .code
6782 ${quote_ldap_dn: a(bc)*, a<yz>; }
6783 .endd
6784 yields
6785 .code
6786 %5C%20a(bc)*%5C%2C%20a%5C%3Cyz%5C%3E%5C%3B%5C%20
6787 .endd
6788 Removing the URL quoting, this is (with a trailing space):
6789 .code
6790 \ a(bc)*\, a\<yz\>\;\
6791 .endd
6792 There are some further comments about quoting in the section on LDAP
6793 authentication below.
6794
6795
6796 .section "LDAP connections"
6797 .cindex "LDAP" "connections"
6798 The connection to an LDAP server may either be over TCP/IP, or, when OpenLDAP
6799 is in use, via a Unix domain socket. The example given above does not specify
6800 an LDAP server. A server that is reached by TCP/IP can be specified in a query
6801 by starting it with
6802 .code
6803 ldap://<hostname>:<port>/...
6804 .endd
6805 If the port (and preceding colon) are omitted, the standard LDAP port (389) is
6806 used. When no server is specified in a query, a list of default servers is
6807 taken from the &%ldap_default_servers%& configuration option. This supplies a
6808 colon-separated list of servers which are tried in turn until one successfully
6809 handles a query, or there is a serious error. Successful handling either
6810 returns the requested data, or indicates that it does not exist. Serious errors
6811 are syntactical, or multiple values when only a single value is expected.
6812 Errors which cause the next server to be tried are connection failures, bind
6813 failures, and timeouts.
6814
6815 For each server name in the list, a port number can be given. The standard way
6816 of specifing a host and port is to use a colon separator (RFC 1738). Because
6817 &%ldap_default_servers%& is a colon-separated list, such colons have to be
6818 doubled. For example
6819 .code
6820 ldap_default_servers = ldap1.example.com::145:ldap2.example.com
6821 .endd
6822 If &%ldap_default_servers%& is unset, a URL with no server name is passed
6823 to the LDAP library with no server name, and the library's default (normally
6824 the local host) is used.
6825
6826 If you are using the OpenLDAP library, you can connect to an LDAP server using
6827 a Unix domain socket instead of a TCP/IP connection. This is specified by using
6828 &`ldapi`& instead of &`ldap`& in LDAP queries. What follows here applies only
6829 to OpenLDAP. If Exim is compiled with a different LDAP library, this feature is
6830 not available.
6831
6832 For this type of connection, instead of a host name for the server, a pathname
6833 for the socket is required, and the port number is not relevant. The pathname
6834 can be specified either as an item in &%ldap_default_servers%&, or inline in
6835 the query. In the former case, you can have settings such as
6836 .code
6837 ldap_default_servers = /tmp/ldap.sock : backup.ldap.your.domain
6838 .endd
6839 When the pathname is given in the query, you have to escape the slashes as
6840 &`%2F`& to fit in with the LDAP URL syntax. For example:
6841 .code
6842 ${lookup ldap {ldapi://%2Ftmp%2Fldap.sock/o=...
6843 .endd
6844 When Exim processes an LDAP lookup and finds that the &"hostname"& is really
6845 a pathname, it uses the Unix domain socket code, even if the query actually
6846 specifies &`ldap`& or &`ldaps`&. In particular, no encryption is used for a
6847 socket connection. This behaviour means that you can use a setting of
6848 &%ldap_default_servers%& such as in the example above with traditional &`ldap`&
6849 or &`ldaps`& queries, and it will work. First, Exim tries a connection via
6850 the Unix domain socket; if that fails, it tries a TCP/IP connection to the
6851 backup host.
6852
6853 If an explicit &`ldapi`& type is given in a query when a host name is
6854 specified, an error is diagnosed. However, if there are more items in
6855 &%ldap_default_servers%&, they are tried. In other words:
6856
6857 .ilist
6858 Using a pathname with &`ldap`& or &`ldaps`& forces the use of the Unix domain
6859 interface.
6860 .next
6861 Using &`ldapi`& with a host name causes an error.
6862 .endlist
6863
6864
6865 Using &`ldapi`& with no host or path in the query, and no setting of
6866 &%ldap_default_servers%&, does whatever the library does by default.
6867
6868
6869
6870 .section "LDAP authentication and control information"
6871 .cindex "LDAP" "authentication"
6872 The LDAP URL syntax provides no way of passing authentication and other control
6873 information to the server. To make this possible, the URL in an LDAP query may
6874 be preceded by any number of <&'name'&>=<&'value'&> settings, separated by
6875 spaces. If a value contains spaces it must be enclosed in double quotes, and
6876 when double quotes are used, backslash is interpreted in the usual way inside
6877 them. The following names are recognized:
6878 .display
6879 &`DEREFERENCE`&  set the dereferencing parameter
6880 &`NETTIME    `&  set a timeout for a network operation
6881 &`USER       `&  set the DN, for authenticating the LDAP bind
6882 &`PASS       `&  set the password, likewise
6883 &`REFERRALS  `&  set the referrals parameter
6884 &`SIZE       `&  set the limit for the number of entries returned
6885 &`TIME       `&  set the maximum waiting time for a query
6886 .endd
6887 The value of the DEREFERENCE parameter must be one of the words &"never"&,
6888 &"searching"&, &"finding"&, or &"always"&. The value of the REFERRALS parameter
6889 must be &"follow"& (the default) or &"nofollow"&. The latter stops the LDAP
6890 library from trying to follow referrals issued by the LDAP server.
6891
6892 The name CONNECT is an obsolete name for NETTIME, retained for
6893 backwards compatibility. This timeout (specified as a number of seconds) is
6894 enforced from the client end for operations that can be carried out over a
6895 network. Specifically, it applies to network connections and calls to the
6896 &'ldap_result()'& function. If the value is greater than zero, it is used if
6897 LDAP_OPT_NETWORK_TIMEOUT is defined in the LDAP headers (OpenLDAP), or
6898 if LDAP_X_OPT_CONNECT_TIMEOUT is defined in the LDAP headers (Netscape
6899 SDK 4.1). A value of zero forces an explicit setting of &"no timeout"& for
6900 Netscape SDK; for OpenLDAP no action is taken.
6901
6902 The TIME parameter (also a number of seconds) is passed to the server to
6903 set a server-side limit on the time taken to complete a search.
6904
6905
6906 Here is an example of an LDAP query in an Exim lookup that uses some of these
6907 values. This is a single line, folded to fit on the page:
6908 .code
6909 ${lookup ldap
6910   {user="cn=manager,o=University of Cambridge,c=UK" pass=secret
6911   ldap:///o=University%20of%20Cambridge,c=UK?sn?sub?(cn=foo)}
6912   {$value}fail}
6913 .endd
6914 The encoding of spaces as &`%20`& is a URL thing which should not be done for
6915 any of the auxiliary data. Exim configuration settings that include lookups
6916 which contain password information should be preceded by &"hide"& to prevent
6917 non-admin users from using the &%-bP%& option to see their values.
6918
6919 The auxiliary data items may be given in any order. The default is no
6920 connection timeout (the system timeout is used), no user or password, no limit
6921 on the number of entries returned, and no time limit on queries.
6922
6923 When a DN is quoted in the USER= setting for LDAP authentication, Exim
6924 removes any URL quoting that it may contain before passing it LDAP. Apparently
6925 some libraries do this for themselves, but some do not. Removing the URL
6926 quoting has two advantages:
6927
6928 .ilist
6929 It makes it possible to use the same &%quote_ldap_dn%& expansion for USER=
6930 DNs as with DNs inside actual queries.
6931 .next
6932 It permits spaces inside USER= DNs.
6933 .endlist
6934
6935 For example, a setting such as
6936 .code
6937 USER=cn=${quote_ldap_dn:$1}
6938 .endd
6939 should work even if &$1$& contains spaces.
6940
6941 Expanded data for the PASS= value should be quoted using the &%quote%&
6942 expansion operator, rather than the LDAP quote operators. The only reason this
6943 field needs quoting is to ensure that it conforms to the Exim syntax, which
6944 does not allow unquoted spaces. For example:
6945 .code
6946 PASS=${quote:$3}
6947 .endd
6948 The LDAP authentication mechanism can be used to check passwords as part of
6949 SMTP authentication. See the &%ldapauth%& expansion string condition in chapter
6950 &<<CHAPexpand>>&.
6951
6952
6953
6954 .section "Format of data returned by LDAP"
6955 .cindex "LDAP" "returned data formats"
6956 The &(ldapdn)& lookup type returns the Distinguished Name from a single entry
6957 as a sequence of values, for example
6958 .code
6959 cn=manager, o=University of Cambridge, c=UK
6960 .endd
6961 The &(ldap)& lookup type generates an error if more than one entry matches the
6962 search filter, whereas &(ldapm)& permits this case, and inserts a newline in
6963 the result between the data from different entries. It is possible for multiple
6964 values to be returned for both &(ldap)& and &(ldapm)&, but in the former case
6965 you know that whatever values are returned all came from a single entry in the
6966 directory.
6967
6968 In the common case where you specify a single attribute in your LDAP query, the
6969 result is not quoted, and does not contain the attribute name. If the attribute
6970 has multiple values, they are separated by commas.
6971
6972 If you specify multiple attributes, the result contains space-separated, quoted
6973 strings, each preceded by the attribute name and an equals sign. Within the
6974 quotes, the quote character, backslash, and newline are escaped with
6975 backslashes, and commas are used to separate multiple values for the attribute.
6976 Apart from the escaping, the string within quotes takes the same form as the
6977 output when a single attribute is requested. Specifying no attributes is the
6978 same as specifying all of an entry's attributes.
6979
6980 Here are some examples of the output format. The first line of each pair is an
6981 LDAP query, and the second is the data that is returned. The attribute called
6982 &%attr1%& has two values, whereas &%attr2%& has only one value:
6983 .code
6984 ldap:///o=base?attr1?sub?(uid=fred)
6985 value1.1, value1.2
6986
6987 ldap:///o=base?attr2?sub?(uid=fred)
6988 value two
6989
6990 ldap:///o=base?attr1,attr2?sub?(uid=fred)
6991 attr1="value1.1, value1.2" attr2="value two"
6992
6993 ldap:///o=base??sub?(uid=fred)
6994 objectClass="top" attr1="value1.1, value1.2" attr2="value two"
6995 .endd
6996 The &%extract%& operator in string expansions can be used to pick out
6997 individual fields from data that consists of &'key'&=&'value'& pairs. You can
6998 make use of Exim's &%-be%& option to run expansion tests and thereby check the
6999 results of LDAP lookups.
7000
7001
7002
7003
7004 .section "More about NIS+" "SECTnisplus"
7005 .cindex "NIS+ lookup type"
7006 .cindex "lookup" "NIS+"
7007 NIS+ queries consist of a NIS+ &'indexed name'& followed by an optional colon
7008 and field name. If this is given, the result of a successful query is the
7009 contents of the named field; otherwise the result consists of a concatenation
7010 of &'field-name=field-value'& pairs, separated by spaces. Empty values and
7011 values containing spaces are quoted. For example, the query
7012 .code
7013 [name=mg1456],passwd.org_dir
7014 .endd
7015 might return the string
7016 .code
7017 name=mg1456 passwd="" uid=999 gid=999 gcos="Martin Guerre"
7018 home=/home/mg1456 shell=/bin/bash shadow=""
7019 .endd
7020 (split over two lines here to fit on the page), whereas
7021 .code
7022 [name=mg1456],passwd.org_dir:gcos
7023 .endd
7024 would just return
7025 .code
7026 Martin Guerre
7027 .endd
7028 with no quotes. A NIS+ lookup fails if NIS+ returns more than one table entry
7029 for the given indexed key. The effect of the &%quote_nisplus%& expansion
7030 operator is to double any quote characters within the text.
7031
7032
7033
7034 .section "SQL lookups" "SECTsql"
7035 .cindex "SQL lookup types"
7036 Exim can support lookups in InterBase, MySQL, Oracle, PostgreSQL, and SQLite
7037 databases. Queries for these databases contain SQL statements, so an example
7038 might be
7039 .code
7040 ${lookup mysql{select mailbox from users where id='userx'}\
7041   {$value}fail}
7042 .endd
7043 If the result of the query contains more than one field, the data for each
7044 field in the row is returned, preceded by its name, so the result of
7045 .code
7046 ${lookup pgsql{select home,name from users where id='userx'}\
7047   {$value}}
7048 .endd
7049 might be
7050 .code
7051 home=/home/userx name="Mister X"
7052 .endd
7053 Empty values and values containing spaces are double quoted, with embedded
7054 quotes escaped by a backslash. If the result of the query contains just one
7055 field, the value is passed back verbatim, without a field name, for example:
7056 .code
7057 Mister X
7058 .endd
7059 If the result of the query yields more than one row, it is all concatenated,
7060 with a newline between the data for each row.
7061
7062
7063 .section "More about MySQL, PostgreSQL, Oracle, and InterBase"
7064 .cindex "MySQL" "lookup type"
7065 .cindex "PostgreSQL lookup type"
7066 .cindex "lookup" "MySQL"
7067 .cindex "lookup" "PostgreSQL"
7068 .cindex "Oracle" "lookup type"
7069 .cindex "lookup" "Oracle"
7070 .cindex "InterBase lookup type"
7071 .cindex "lookup" "InterBase"
7072 If any MySQL, PostgreSQL, Oracle, or InterBase lookups are used, the
7073 &%mysql_servers%&, &%pgsql_servers%&, &%oracle_servers%&, or &%ibase_servers%&
7074 option (as appropriate) must be set to a colon-separated list of server
7075 information. Each item in the list is a slash-separated list of four items:
7076 host name, database name, user name, and password. In the case of Oracle, the
7077 host name field is used for the &"service name"&, and the database name field
7078 is not used and should be empty. For example:
7079 .code
7080 hide oracle_servers = oracle.plc.example//userx/abcdwxyz
7081 .endd
7082 Because password data is sensitive, you should always precede the setting with
7083 &"hide"&, to prevent non-admin users from obtaining the setting via the &%-bP%&
7084 option. Here is an example where two MySQL servers are listed:
7085 .code
7086 hide mysql_servers = localhost/users/root/secret:\
7087                      otherhost/users/root/othersecret
7088 .endd
7089 For MySQL and PostgreSQL, a host may be specified as <&'name'&>:<&'port'&> but
7090 because this is a colon-separated list, the colon has to be doubled. For each
7091 query, these parameter groups are tried in order until a connection and a query
7092 succeeds.
7093
7094 The &%quote_mysql%&, &%quote_pgsql%&, and &%quote_oracle%& expansion operators
7095 convert newline, tab, carriage return, and backspace to \n, \t, \r, and \b
7096 respectively, and the characters single-quote, double-quote, and backslash
7097 itself are escaped with backslashes. The &%quote_pgsql%& expansion operator, in
7098 addition, escapes the percent and underscore characters. This cannot be done
7099 for MySQL because these escapes are not recognized in contexts where these
7100 characters are not special.
7101
7102
7103 .section "Special MySQL features"
7104 For MySQL, an empty host name or the use of &"localhost"& in &%mysql_servers%&
7105 causes a connection to the server on the local host by means of a Unix domain
7106 socket. An alternate socket can be specified in parentheses. The full syntax of
7107 each item in &%mysql_servers%& is:
7108 .display
7109 <&'hostname'&>::<&'port'&>(<&'socket name'&>)/<&'database'&>/&&&
7110   <&'user'&>/<&'password'&>
7111 .endd
7112 Any of the three sub-parts of the first field can be omitted. For normal use on
7113 the local host it can be left blank or set to just &"localhost"&.
7114
7115 No database need be supplied &-- but if it is absent here, it must be given in
7116 the queries.
7117
7118 If a MySQL query is issued that does not request any data (an insert, update,
7119 or delete command), the result of the lookup is the number of rows affected.
7120
7121 &*Warning*&: This can be misleading. If an update does not actually change
7122 anything (for example, setting a field to the value it already has), the result
7123 is zero because no rows are affected.
7124
7125
7126 .section "Special PostgreSQL features"
7127 PostgreSQL lookups can also use Unix domain socket connections to the database.
7128 This is usually faster and costs less CPU time than a TCP/IP connection.
7129 However it can be used only if the mail server runs on the same machine as the
7130 database server. A configuration line for PostgreSQL via Unix domain sockets
7131 looks like this:
7132 .code
7133 hide pgsql_servers = (/tmp/.s.PGSQL.5432)/db/user/password : ...
7134 .endd
7135 In other words, instead of supplying a host name, a path to the socket is
7136 given. The path name is enclosed in parentheses so that its slashes aren't
7137 visually confused with the delimiters for the other server parameters.
7138
7139 If a PostgreSQL query is issued that does not request any data (an insert,
7140 update, or delete command), the result of the lookup is the number of rows
7141 affected.
7142
7143 .section "More about SQLite" "SECTsqlite"
7144 .cindex "lookup" "SQLite"
7145 .cindex "SQLite lookup type"
7146 SQLite is different to the other SQL lookups because a file name is required in
7147 addition to the SQL query. An SQLite database is a single file, and there is no
7148 daemon as in the other SQL databases. The interface to Exim requires the name
7149 of the file, as an absolute path, to be given at the start of the query. It is
7150 separated from the query by white space. This means that the path name cannot
7151 contain white space. Here is a lookup expansion example:
7152 .code
7153 ${lookup sqlite {/some/thing/sqlitedb \
7154   select name from aliases where id='userx';}}
7155 .endd
7156 In a list, the syntax is similar. For example:
7157 .code
7158 domainlist relay_domains = sqlite;/some/thing/sqlitedb \
7159    select * from relays where ip='$sender_host_address';
7160 .endd
7161 The only character affected by the &%quote_sqlite%& operator is a single
7162 quote, which it doubles.
7163
7164 The SQLite library handles multiple simultaneous accesses to the database
7165 internally. Multiple readers are permitted, but only one process can
7166 update at once. Attempts to access the database while it is being updated
7167 are rejected after a timeout period, during which the SQLite library
7168 waits for the lock to be released. In Exim, the default timeout is set
7169 to 5 seconds, but it can be changed by means of the &%sqlite_lock_timeout%&
7170 option.
7171 .ecindex IIDfidalo1
7172 .ecindex IIDfidalo2
7173
7174
7175 . ////////////////////////////////////////////////////////////////////////////
7176 . ////////////////////////////////////////////////////////////////////////////
7177
7178 .chapter "Domain, host, address, and local part lists" &&&
7179          "CHAPdomhosaddlists" &&&
7180          "Domain, host, and address lists"
7181 .scindex IIDdohoadli "lists of domains; hosts; etc."
7182 A number of Exim configuration options contain lists of domains, hosts,
7183 email addresses, or local parts. For example, the &%hold_domains%& option
7184 contains a list of domains whose delivery is currently suspended. These lists
7185 are also used as data in ACL statements (see chapter &<<CHAPACL>>&), and as
7186 arguments to expansion conditions such as &%match_domain%&.
7187
7188 Each item in one of these lists is a pattern to be matched against a domain,
7189 host, email address, or local part, respectively. In the sections below, the
7190 different types of pattern for each case are described, but first we cover some
7191 general facilities that apply to all four kinds of list.
7192
7193
7194
7195 .section "Expansion of lists"
7196 .cindex "expansion" "of lists"
7197 Each list is expanded as a single string before it is used. The result of
7198 expansion must be a list, possibly containing empty items, which is split up
7199 into separate items for matching. By default, colon is the separator character,
7200 but this can be varied if necessary. See sections &<<SECTlistconstruct>>& and
7201 &<<SECTempitelis>>& for details of the list syntax; the second of these
7202 discusses the way to specify empty list items.
7203
7204
7205 If the string expansion is forced to fail, Exim behaves as if the item it is
7206 testing (domain, host, address, or local part) is not in the list. Other
7207 expansion failures cause temporary errors.
7208
7209 If an item in a list is a regular expression, backslashes, dollars and possibly
7210 other special characters in the expression must be protected against
7211 misinterpretation by the string expander. The easiest way to do this is to use
7212 the &`\N`& expansion feature to indicate that the contents of the regular
7213 expression should not be expanded. For example, in an ACL you might have:
7214 .code
7215 deny senders = \N^\d{8}\w@.*\.baddomain\.example$\N : \
7216                ${lookup{$domain}lsearch{/badsenders/bydomain}}
7217 .endd
7218 The first item is a regular expression that is protected from expansion by
7219 &`\N`&, whereas the second uses the expansion to obtain a list of unwanted
7220 senders based on the receiving domain.
7221
7222
7223
7224
7225 .section "Negated items in lists"
7226 .cindex "list" "negation"
7227 .cindex "negation" "in lists"
7228 Items in a list may be positive or negative. Negative items are indicated by a
7229 leading exclamation mark, which may be followed by optional white space. A list
7230 defines a set of items (domains, etc). When Exim processes one of these lists,
7231 it is trying to find out whether a domain, host, address, or local part
7232 (respectively) is in the set that is defined by the list. It works like this:
7233
7234 The list is scanned from left to right. If a positive item is matched, the
7235 subject that is being checked is in the set; if a negative item is matched, the
7236 subject is not in the set. If the end of the list is reached without the
7237 subject having matched any of the patterns, it is in the set if the last item
7238 was a negative one, but not if it was a positive one. For example, the list in
7239 .code
7240 domainlist relay_domains = !a.b.c : *.b.c
7241 .endd
7242 matches any domain ending in &'.b.c'& except for &'a.b.c'&. Domains that match
7243 neither &'a.b.c'& nor &'*.b.c'& do not match, because the last item in the
7244 list is positive. However, if the setting were
7245 .code
7246 domainlist relay_domains = !a.b.c
7247 .endd
7248 then all domains other than &'a.b.c'& would match because the last item in the
7249 list is negative. In other words, a list that ends with a negative item behaves
7250 as if it had an extra item &`:*`& on the end.
7251
7252 Another way of thinking about positive and negative items in lists is to read
7253 the connector as &"or"& after a positive item and as &"and"& after a negative
7254 item.
7255
7256
7257
7258 .section "File names in lists" "SECTfilnamlis"
7259 .cindex "list" "file name in"
7260 If an item in a domain, host, address, or local part list is an absolute file
7261 name (beginning with a slash character), each line of the file is read and
7262 processed as if it were an independent item in the list, except that further
7263 file names are not allowed,
7264 and no expansion of the data from the file takes place.
7265 Empty lines in the file are ignored, and the file may also contain comment
7266 lines:
7267
7268 .ilist
7269 For domain and host lists, if a # character appears anywhere in a line of the
7270 file, it and all following characters are ignored.
7271 .next
7272 Because local parts may legitimately contain # characters, a comment in an
7273 address list or local part list file is recognized only if # is preceded by
7274 white space or the start of the line. For example:
7275 .code
7276 not#comment@x.y.z   # but this is a comment
7277 .endd
7278 .endlist
7279
7280 Putting a file name in a list has the same effect as inserting each line of the
7281 file as an item in the list (blank lines and comments excepted). However, there
7282 is one important difference: the file is read each time the list is processed,
7283 so if its contents vary over time, Exim's behaviour changes.
7284
7285 If a file name is preceded by an exclamation mark, the sense of any match
7286 within the file is inverted. For example, if
7287 .code
7288 hold_domains = !/etc/nohold-domains
7289 .endd
7290 and the file contains the lines
7291 .code
7292 !a.b.c
7293 *.b.c
7294 .endd
7295 then &'a.b.c'& is in the set of domains defined by &%hold_domains%&, whereas
7296 any domain matching &`*.b.c`& is not.
7297
7298
7299
7300 .section "An lsearch file is not an out-of-line list"
7301 As will be described in the sections that follow, lookups can be used in lists
7302 to provide indexed methods of checking list membership. There has been some
7303 confusion about the way &(lsearch)& lookups work in lists. Because
7304 an &(lsearch)& file contains plain text and is scanned sequentially, it is
7305 sometimes thought that it is allowed to contain wild cards and other kinds of
7306 non-constant pattern. This is not the case. The keys in an &(lsearch)& file are
7307 always fixed strings, just as for any other single-key lookup type.
7308
7309 If you want to use a file to contain wild-card patterns that form part of a
7310 list, just give the file name on its own, without a search type, as described
7311 in the previous section. You could also use the &(wildlsearch)& or
7312 &(nwildlsearch)&, but there is no advantage in doing this.
7313
7314
7315
7316
7317 .section "Named lists" "SECTnamedlists"
7318 .cindex "named lists"
7319 .cindex "list" "named"
7320 A list of domains, hosts, email addresses, or local parts can be given a name
7321 which is then used to refer to the list elsewhere in the configuration. This is
7322 particularly convenient if the same list is required in several different
7323 places. It also allows lists to be given meaningful names, which can improve
7324 the readability of the configuration. For example, it is conventional to define
7325 a domain list called &'local_domains'& for all the domains that are handled
7326 locally on a host, using a configuration line such as
7327 .code
7328 domainlist local_domains = localhost:my.dom.example
7329 .endd
7330 Named lists are referenced by giving their name preceded by a plus sign, so,
7331 for example, a router that is intended to handle local domains would be
7332 configured with the line
7333 .code
7334 domains = +local_domains
7335 .endd
7336 The first router in a configuration is often one that handles all domains
7337 except the local ones, using a configuration with a negated item like this:
7338 .code
7339 dnslookup:
7340   driver = dnslookup
7341   domains = ! +local_domains
7342   transport = remote_smtp
7343   no_more
7344 .endd
7345 The four kinds of named list are created by configuration lines starting with
7346 the words &%domainlist%&, &%hostlist%&, &%addresslist%&, or &%localpartlist%&,
7347 respectively. Then there follows the name that you are defining, followed by an
7348 equals sign and the list itself. For example:
7349 .code
7350 hostlist    relay_hosts = 192.168.23.0/24 : my.friend.example
7351 addresslist bad_senders = cdb;/etc/badsenders
7352 .endd
7353 A named list may refer to other named lists:
7354 .code
7355 domainlist  dom1 = first.example : second.example
7356 domainlist  dom2 = +dom1 : third.example
7357 domainlist  dom3 = fourth.example : +dom2 : fifth.example
7358 .endd
7359 &*Warning*&: If the last item in a referenced list is a negative one, the
7360 effect may not be what you intended, because the negation does not propagate
7361 out to the higher level. For example, consider:
7362 .code
7363 domainlist  dom1 = !a.b
7364 domainlist  dom2 = +dom1 : *.b
7365 .endd
7366 The second list specifies &"either in the &%dom1%& list or &'*.b'&"&. The first
7367 list specifies just &"not &'a.b'&"&, so the domain &'x.y'& matches it. That
7368 means it matches the second list as well. The effect is not the same as
7369 .code
7370 domainlist  dom2 = !a.b : *.b
7371 .endd
7372 where &'x.y'& does not match. It's best to avoid negation altogether in
7373 referenced lists if you can.
7374
7375 Named lists may have a performance advantage. When Exim is routing an
7376 address or checking an incoming message, it caches the result of tests on named
7377 lists. So, if you have a setting such as
7378 .code
7379 domains = +local_domains
7380 .endd
7381 on several of your routers
7382 or in several ACL statements,
7383 the actual test is done only for the first one. However, the caching works only
7384 if there are no expansions within the list itself or any sublists that it
7385 references. In other words, caching happens only for lists that are known to be
7386 the same each time they are referenced.
7387
7388 By default, there may be up to 16 named lists of each type. This limit can be
7389 extended by changing a compile-time variable. The use of domain and host lists
7390 is recommended for concepts such as local domains, relay domains, and relay
7391 hosts. The default configuration is set up like this.
7392
7393
7394
7395 .section "Named lists compared with macros"
7396 .cindex "list" "named compared with macro"
7397 .cindex "macro" "compared with named list"
7398 At first sight, named lists might seem to be no different from macros in the
7399 configuration file. However, macros are just textual substitutions. If you
7400 write
7401 .code
7402 ALIST = host1 : host2
7403 auth_advertise_hosts = !ALIST
7404 .endd
7405 it probably won't do what you want, because that is exactly the same as
7406 .code
7407 auth_advertise_hosts = !host1 : host2
7408 .endd
7409 Notice that the second host name is not negated. However, if you use a host
7410 list, and write
7411 .code
7412 hostlist alist = host1 : host2
7413 auth_advertise_hosts = ! +alist
7414 .endd
7415 the negation applies to the whole list, and so that is equivalent to
7416 .code
7417 auth_advertise_hosts = !host1 : !host2
7418 .endd
7419
7420
7421 .section "Named list caching"
7422 .cindex "list" "caching of named"
7423 .cindex "caching" "named lists"
7424 While processing a message, Exim caches the result of checking a named list if
7425 it is sure that the list is the same each time. In practice, this means that
7426 the cache operates only if the list contains no $ characters, which guarantees
7427 that it will not change when it is expanded. Sometimes, however, you may have
7428 an expanded list that you know will be the same each time within a given
7429 message. For example:
7430 .code
7431 domainlist special_domains = \
7432            ${lookup{$sender_host_address}cdb{/some/file}}
7433 .endd
7434 This provides a list of domains that depends only on the sending host's IP
7435 address. If this domain list is referenced a number of times (for example,
7436 in several ACL lines, or in several routers) the result of the check is not
7437 cached by default, because Exim does not know that it is going to be the
7438 same list each time.
7439
7440 By appending &`_cache`& to &`domainlist`& you can tell Exim to go ahead and
7441 cache the result anyway. For example:
7442 .code
7443 domainlist_cache special_domains = ${lookup{...
7444 .endd
7445 If you do this, you should be absolutely sure that caching is going to do
7446 the right thing in all cases. When in doubt, leave it out.
7447
7448
7449
7450 .section "Domain lists" "SECTdomainlist"
7451 .cindex "domain list" "patterns for"
7452 .cindex "list" "domain list"
7453 Domain lists contain patterns that are to be matched against a mail domain.
7454 The following types of item may appear in domain lists:
7455
7456 .ilist
7457 .cindex "primary host name"
7458 .cindex "host name" "matched in domain list"
7459 .cindex "&%primary_hostname%&"
7460 .cindex "domain list" "matching primary host name"
7461 .cindex "@ in a domain list"
7462 If a pattern consists of a single @ character, it matches the local host name,
7463 as set by the &%primary_hostname%& option (or defaulted). This makes it
7464 possible to use the same configuration file on several different hosts that
7465 differ only in their names.
7466 .next
7467 .cindex "@[] in a domain list"
7468 .cindex "domain list" "matching local IP interfaces"
7469 .cindex "domain literal"
7470 If a pattern consists of the string &`@[]`& it matches any local IP interface
7471 address, enclosed in square brackets, as in an email address that contains a
7472 domain literal.
7473 In today's Internet, the use of domain literals is controversial.
7474 .next
7475 .cindex "@mx_any"
7476 .cindex "@mx_primary"
7477 .cindex "@mx_secondary"
7478 .cindex "domain list" "matching MX pointers to local host"
7479 If a pattern consists of the string &`@mx_any`& it matches any domain that
7480 has an MX record pointing to the local host or to any host that is listed in
7481 .cindex "&%hosts_treat_as_local%&"
7482 &%hosts_treat_as_local%&. The items &`@mx_primary`& and &`@mx_secondary`&
7483 are similar, except that the first matches only when a primary MX target is the
7484 local host, and the second only when no primary MX target is the local host,
7485 but a secondary MX target is. &"Primary"& means an MX record with the lowest
7486 preference value &-- there may of course be more than one of them.
7487
7488 The MX lookup that takes place when matching a pattern of this type is
7489 performed with the resolver options for widening names turned off. Thus, for
7490 example, a single-component domain will &'not'& be expanded by adding the
7491 resolver's default domain. See the &%qualify_single%& and &%search_parents%&
7492 options of the &(dnslookup)& router for a discussion of domain widening.
7493
7494 Sometimes you may want to ignore certain IP addresses when using one of these
7495 patterns. You can specify this by following the pattern with &`/ignore=`&<&'ip
7496 list'&>, where <&'ip list'&> is a list of IP addresses. These addresses are
7497 ignored when processing the pattern (compare the &%ignore_target_hosts%& option
7498 on a router). For example:
7499 .code
7500 domains = @mx_any/ignore=127.0.0.1
7501 .endd
7502 This example matches any domain that has an MX record pointing to one of
7503 the local host's IP addresses other than 127.0.0.1.
7504
7505 The list of IP addresses is in fact processed by the same code that processes
7506 host lists, so it may contain CIDR-coded network specifications and it may also
7507 contain negative items.
7508
7509 Because the list of IP addresses is a sublist within a domain list, you have to
7510 be careful about delimiters if there is more than one address. Like any other
7511 list, the default delimiter can be changed. Thus, you might have:
7512 .code
7513 domains = @mx_any/ignore=<;127.0.0.1;0.0.0.0 : \
7514           an.other.domain : ...
7515 .endd
7516 so that the sublist uses semicolons for delimiters. When IPv6 addresses are
7517 involved, it is easiest to change the delimiter for the main list as well:
7518 .code
7519 domains = <? @mx_any/ignore=<;127.0.0.1;::1 ? \
7520           an.other.domain ? ...
7521 .endd
7522 .next
7523 .cindex "asterisk" "in domain list"
7524 .cindex "domain list" "asterisk in"
7525 .cindex "domain list" "matching &""ends with""&"
7526 If a pattern starts with an asterisk, the remaining characters of the pattern
7527 are compared with the terminating characters of the domain. The use of &"*"& in
7528 domain lists differs from its use in partial matching lookups. In a domain
7529 list, the character following the asterisk need not be a dot, whereas partial
7530 matching works only in terms of dot-separated components. For example, a domain
7531 list item such as &`*key.ex`& matches &'donkey.ex'& as well as
7532 &'cipher.key.ex'&.
7533
7534 .next
7535 .cindex "regular expressions" "in domain list"
7536 .cindex "domain list" "matching regular expression"
7537 If a pattern starts with a circumflex character, it is treated as a regular
7538 expression, and matched against the domain using a regular expression matching
7539 function. The circumflex is treated as part of the regular expression.
7540 References to descriptions of the syntax of regular expressions are given in
7541 chapter &<<CHAPregexp>>&.
7542
7543 &*Warning*&: Because domain lists are expanded before being processed, you
7544 must escape any backslash and dollar characters in the regular expression, or
7545 use the special &`\N`& sequence (see chapter &<<CHAPexpand>>&) to specify that
7546 it is not to be expanded (unless you really do want to build a regular
7547 expression by expansion, of course).
7548 .next
7549 .cindex "lookup" "in domain list"
7550 .cindex "domain list" "matching by lookup"
7551 If a pattern starts with the name of a single-key lookup type followed by a
7552 semicolon (for example, &"dbm;"& or &"lsearch;"&), the remainder of the pattern
7553 must be a file name in a suitable format for the lookup type. For example, for
7554 &"cdb;"& it must be an absolute path:
7555 .code
7556 domains = cdb;/etc/mail/local_domains.cdb
7557 .endd
7558 The appropriate type of lookup is done on the file using the domain name as the
7559 key. In most cases, the data that is looked up is not used; Exim is interested
7560 only in whether or not the key is present in the file. However, when a lookup
7561 is used for the &%domains%& option on a router
7562 or a &%domains%& condition in an ACL statement, the data is preserved in the
7563 &$domain_data$& variable and can be referred to in other router options or
7564 other statements in the same ACL.
7565
7566 .next
7567 Any of the single-key lookup type names may be preceded by
7568 &`partial`&<&'n'&>&`-`&, where the <&'n'&> is optional, for example,
7569 .code
7570 domains = partial-dbm;/partial/domains
7571 .endd
7572 This causes partial matching logic to be invoked; a description of how this
7573 works is given in section &<<SECTpartiallookup>>&.
7574
7575 .next
7576 .cindex "asterisk" "in lookup type"
7577 Any of the single-key lookup types may be followed by an asterisk. This causes
7578 a default lookup for a key consisting of a single asterisk to be done if the
7579 original lookup fails. This is not a useful feature when using a domain list to
7580 select particular domains (because any domain would match), but it might have
7581 value if the result of the lookup is being used via the &$domain_data$&
7582 expansion variable.
7583 .next
7584 If the pattern starts with the name of a query-style lookup type followed by a
7585 semicolon (for example, &"nisplus;"& or &"ldap;"&), the remainder of the
7586 pattern must be an appropriate query for the lookup type, as described in
7587 chapter &<<CHAPfdlookup>>&. For example:
7588 .code
7589 hold_domains = mysql;select domain from holdlist \
7590   where domain = '$domain';
7591 .endd
7592 In most cases, the data that is looked up is not used (so for an SQL query, for
7593 example, it doesn't matter what field you select). Exim is interested only in
7594 whether or not the query succeeds. However, when a lookup is used for the
7595 &%domains%& option on a router, the data is preserved in the &$domain_data$&
7596 variable and can be referred to in other options.
7597 .next
7598 .cindex "domain list" "matching literal domain name"
7599 If none of the above cases apply, a caseless textual comparison is made
7600 between the pattern and the domain.
7601 .endlist
7602
7603 Here is an example that uses several different kinds of pattern:
7604 .code
7605 domainlist funny_domains = \
7606   @ : \
7607   lib.unseen.edu : \
7608   *.foundation.fict.example : \
7609   \N^[1-2]\d{3}\.fict\.example$\N : \
7610   partial-dbm;/opt/data/penguin/book : \
7611   nis;domains.byname : \
7612   nisplus;[name=$domain,status=local],domains.org_dir
7613 .endd
7614 There are obvious processing trade-offs among the various matching modes. Using
7615 an asterisk is faster than a regular expression, and listing a few names
7616 explicitly probably is too. The use of a file or database lookup is expensive,
7617 but may be the only option if hundreds of names are required. Because the
7618 patterns are tested in order, it makes sense to put the most commonly matched
7619 patterns earlier.
7620
7621
7622
7623 .section "Host lists" "SECThostlist"
7624 .cindex "host list" "patterns in"
7625 .cindex "list" "host list"
7626 Host lists are used to control what remote hosts are allowed to do. For
7627 example, some hosts may be allowed to use the local host as a relay, and some
7628 may be permitted to use the SMTP ETRN command. Hosts can be identified in
7629 two different ways, by name or by IP address. In a host list, some types of
7630 pattern are matched to a host name, and some are matched to an IP address.
7631 You need to be particularly careful with this when single-key lookups are
7632 involved, to ensure that the right value is being used as the key.
7633
7634
7635 .section "Special host list patterns"
7636 .cindex "empty item in hosts list"
7637 .cindex "host list" "empty string in"
7638 If a host list item is the empty string, it matches only when no remote host is
7639 involved. This is the case when a message is being received from a local
7640 process using SMTP on the standard input, that is, when a TCP/IP connection is
7641 not used.
7642
7643 .cindex "asterisk" "in host list"
7644 The special pattern &"*"& in a host list matches any host or no host. Neither
7645 the IP address nor the name is actually inspected.
7646
7647
7648
7649 .section "Host list patterns that match by IP address" "SECThoslispatip"
7650 .cindex "host list" "matching IP addresses"
7651 If an IPv4 host calls an IPv6 host and the call is accepted on an IPv6 socket,
7652 the incoming address actually appears in the IPv6 host as
7653 &`::ffff:`&<&'v4address'&>. When such an address is tested against a host
7654 list, it is converted into a traditional IPv4 address first. (Not all operating
7655 systems accept IPv4 calls on IPv6 sockets, as there have been some security
7656 concerns.)
7657
7658 The following types of pattern in a host list check the remote host by
7659 inspecting its IP address:
7660
7661 .ilist
7662 If the pattern is a plain domain name (not a regular expression, not starting
7663 with *, not a lookup of any kind), Exim calls the operating system function
7664 to find the associated IP address(es). Exim uses the newer
7665 &[getipnodebyname()]& function when available, otherwise &[gethostbyname()]&.
7666 This typically causes a forward DNS lookup of the name. The result is compared
7667 with the IP address of the subject host.
7668
7669 If there is a temporary problem (such as a DNS timeout) with the host name
7670 lookup, a temporary error occurs. For example, if the list is being used in an
7671 ACL condition, the ACL gives a &"defer"& response, usually leading to a
7672 temporary SMTP error code. If no IP address can be found for the host name,
7673 what happens is described in section &<<SECTbehipnot>>& below.
7674
7675 .next
7676 .cindex "@ in a host list"
7677 If the pattern is &"@"&, the primary host name is substituted and used as a
7678 domain name, as just described.
7679
7680 .next
7681 If the pattern is an IP address, it is matched against the IP address of the
7682 subject host. IPv4 addresses are given in the normal &"dotted-quad"& notation.
7683 IPv6 addresses can be given in colon-separated format, but the colons have to
7684 be doubled so as not to be taken as item separators when the default list
7685 separator is used. IPv6 addresses are recognized even when Exim is compiled
7686 without IPv6 support. This means that if they appear in a host list on an
7687 IPv4-only host, Exim will not treat them as host names. They are just addresses
7688 that can never match a client host.
7689
7690 .next
7691 .cindex "@[] in a host list"
7692 If the pattern is &"@[]"&, it matches the IP address of any IP interface on
7693 the local host. For example, if the local host is an IPv4 host with one
7694 interface address 10.45.23.56, these two ACL statements have the same effect:
7695 .code
7696 accept hosts = 127.0.0.1 : 10.45.23.56
7697 accept hosts = @[]
7698 .endd
7699 .next
7700 .cindex "CIDR notation"
7701 If the pattern is an IP address followed by a slash and a mask length (for
7702 example 10.11.42.0/24), it is matched against the IP address of the subject
7703 host under the given mask. This allows, an entire network of hosts to be
7704 included (or excluded) by a single item. The mask uses CIDR notation; it
7705 specifies the number of address bits that must match, starting from the most
7706 significant end of the address.
7707
7708 &*Note*&: The mask is &'not'& a count of addresses, nor is it the high number
7709 of a range of addresses. It is the number of bits in the network portion of the
7710 address. The above example specifies a 24-bit netmask, so it matches all 256
7711 addresses in the 10.11.42.0 network. An item such as
7712 .code
7713 192.168.23.236/31
7714 .endd
7715 matches just two addresses, 192.168.23.236 and 192.168.23.237. A mask value of
7716 32 for an IPv4 address is the same as no mask at all; just a single address
7717 matches.
7718
7719 Here is another example which shows an IPv4 and an IPv6 network:
7720 .code
7721 recipient_unqualified_hosts = 192.168.0.0/16: \
7722                               3ffe::ffff::836f::::/48
7723 .endd
7724 The doubling of list separator characters applies only when these items
7725 appear inline in a host list. It is not required when indirecting via a file.
7726 For example:
7727 .code
7728 recipient_unqualified_hosts = /opt/exim/unqualnets
7729 .endd
7730 could make use of a file containing
7731 .code
7732 172.16.0.0/12
7733 3ffe:ffff:836f::/48
7734 .endd
7735 to have exactly the same effect as the previous example. When listing IPv6
7736 addresses inline, it is usually more convenient to use the facility for
7737 changing separator characters. This list contains the same two networks:
7738 .code
7739 recipient_unqualified_hosts = <; 172.16.0.0/12; \
7740                                  3ffe:ffff:836f::/48
7741 .endd
7742 The separator is changed to semicolon by the leading &"<;"& at the start of the
7743 list.
7744 .endlist
7745
7746
7747
7748 .section "Host list patterns for single-key lookups by host address" &&&
7749          "SECThoslispatsikey"
7750 .cindex "host list" "lookup of IP address"
7751 When a host is to be identified by a single-key lookup of its complete IP
7752 address, the pattern takes this form:
7753 .display
7754 &`net-<`&&'single-key-search-type'&&`>;<`&&'search-data'&&`>`&
7755 .endd
7756 For example:
7757 .code
7758 hosts_lookup = net-cdb;/hosts-by-ip.db
7759 .endd
7760 The text form of the IP address of the subject host is used as the lookup key.
7761 IPv6 addresses are converted to an unabbreviated form, using lower case
7762 letters, with dots as separators because colon is the key terminator in
7763 &(lsearch)& files. [Colons can in fact be used in keys in &(lsearch)& files by
7764 quoting the keys, but this is a facility that was added later.] The data
7765 returned by the lookup is not used.
7766
7767 .cindex "IP address" "masking"
7768 .cindex "host list" "masked IP address"
7769 Single-key lookups can also be performed using masked IP addresses, using
7770 patterns of this form:
7771 .display
7772 &`net<`&&'number'&&`>-<`&&'single-key-search-type'&&`>;<`&&'search-data'&&`>`&
7773 .endd
7774 For example:
7775 .code
7776 net24-dbm;/networks.db
7777 .endd
7778 The IP address of the subject host is masked using <&'number'&> as the mask
7779 length. A textual string is constructed from the masked value, followed by the
7780 mask, and this is used as the lookup key. For example, if the host's IP address
7781 is 192.168.34.6, the key that is looked up for the above example is
7782 &"192.168.34.0/24"&. IPv6 addresses are converted to a text value using lower
7783 case letters and dots as separators instead of the more usual colon, because
7784 colon is the key terminator in &(lsearch)& files. Full, unabbreviated IPv6
7785 addresses are always used.
7786
7787 &*Warning*&: Specifing &%net32-%& (for an IPv4 address) or &%net128-%& (for an
7788 IPv6 address) is not the same as specifing just &%net-%& without a number. In
7789 the former case the key strings include the mask value, whereas in the latter
7790 case the IP address is used on its own.
7791
7792
7793
7794 .section "Host list patterns that match by host name" "SECThoslispatnam"
7795 .cindex "host" "lookup failures"
7796 .cindex "unknown host name"
7797 .cindex "host list" "matching host name"
7798 There are several types of pattern that require Exim to know the name of the
7799 remote host. These are either wildcard patterns or lookups by name. (If a
7800 complete hostname is given without any wildcarding, it is used to find an IP
7801 address to match against, as described in the section &<<SECThoslispatip>>&
7802 above.)
7803
7804 If the remote host name is not already known when Exim encounters one of these
7805 patterns, it has to be found from the IP address.
7806 Although many sites on the Internet are conscientious about maintaining reverse
7807 DNS data for their hosts, there are also many that do not do this.
7808 Consequently, a name cannot always be found, and this may lead to unwanted
7809 effects. Take care when configuring host lists with wildcarded name patterns.
7810 Consider what will happen if a name cannot be found.
7811
7812 Because of the problems of determining host names from IP addresses, matching
7813 against host names is not as common as matching against IP addresses.
7814
7815 By default, in order to find a host name, Exim first does a reverse DNS lookup;
7816 if no name is found in the DNS, the system function (&[gethostbyaddr()]& or
7817 &[getipnodebyaddr()]& if available) is tried. The order in which these lookups
7818 are done can be changed by setting the &%host_lookup_order%& option.
7819
7820 There are some options that control what happens if a host name cannot be
7821 found. These are described in section &<<SECTbehipnot>>& below.
7822
7823 .cindex "host" "alias for"
7824 .cindex "alias for host"
7825 As a result of aliasing, hosts may have more than one name. When processing any
7826 of the following types of pattern, all the host's names are checked:
7827
7828 .ilist
7829 .cindex "asterisk" "in host list"
7830 If a pattern starts with &"*"& the remainder of the item must match the end of
7831 the host name. For example, &`*.b.c`& matches all hosts whose names end in
7832 &'.b.c'&. This special simple form is provided because this is a very common
7833 requirement. Other kinds of wildcarding require the use of a regular
7834 expression.
7835 .next
7836 .cindex "regular expressions" "in host list"
7837 .cindex "host list" "regular expression in"
7838 If the item starts with &"^"& it is taken to be a regular expression which is
7839 matched against the host name. For example,
7840 .code
7841 ^(a|b)\.c\.d$
7842 .endd
7843 is a regular expression that matches either of the two hosts &'a.c.d'& or
7844 &'b.c.d'&. When a regular expression is used in a host list, you must take care
7845 that backslash and dollar characters are not misinterpreted as part of the
7846 string expansion. The simplest way to do this is to use &`\N`& to mark that
7847 part of the string as non-expandable. For example:
7848 .code
7849 sender_unqualified_hosts = \N^(a|b)\.c\.d$\N : ....
7850 .endd
7851 &*Warning*&: If you want to match a complete host name, you must include the
7852 &`$`& terminating metacharacter in the regular expression, as in the above
7853 example. Without it, a match at the start of the host name is all that is
7854 required.
7855 .endlist
7856
7857
7858
7859
7860 .section "Behaviour when an IP address or name cannot be found" "SECTbehipnot"
7861 .cindex "host" "lookup failures"
7862 While processing a host list, Exim may need to look up an IP address from a
7863 name (see section &<<SECThoslispatip>>&), or it may need to look up a host name
7864 from an IP address (see section &<<SECThoslispatnam>>&). In either case, the
7865 behaviour when it fails to find the information it is seeking is the same.
7866
7867 .cindex "&`+include_unknown`&"
7868 .cindex "&`+ignore_unknown`&"
7869 By default, Exim behaves as if the host does not match the list. This may not
7870 always be what you want to happen. To change Exim's behaviour, the special
7871 items &`+include_unknown`& or &`+ignore_unknown`& may appear in the list (at
7872 top level &-- they are not recognized in an indirected file).
7873
7874 .ilist
7875 If any item that follows &`+include_unknown`& requires information that
7876 cannot found, Exim behaves as if the host does match the list. For example,
7877 .code
7878 host_reject_connection = +include_unknown:*.enemy.ex
7879 .endd
7880 rejects connections from any host whose name matches &`*.enemy.ex`&, and also
7881 any hosts whose name it cannot find.
7882
7883 .next
7884 If any item that follows &`+ignore_unknown`& requires information that cannot
7885 be found, Exim ignores that item and proceeds to the rest of the list. For
7886 example:
7887 .code
7888 accept hosts = +ignore_unknown : friend.example : \
7889                192.168.4.5
7890 .endd
7891 accepts from any host whose name is &'friend.example'& and from 192.168.4.5,
7892 whether or not its host name can be found. Without &`+ignore_unknown`&, if no
7893 name can be found for 192.168.4.5, it is rejected.
7894 .endlist
7895
7896 Both &`+include_unknown`& and &`+ignore_unknown`& may appear in the same
7897 list. The effect of each one lasts until the next, or until the end of the
7898 list.
7899
7900 &*Note*&: This section applies to permanent lookup failures. It does &'not'&
7901 apply to temporary DNS errors. They always cause a defer action (except when
7902 &%dns_again_means_nonexist%& converts them into permanent errors).
7903
7904
7905
7906 .section "Host list patterns for single-key lookups by host name" &&&
7907          "SECThoslispatnamsk"
7908 .cindex "host" "lookup failures"
7909 .cindex "unknown host name"
7910 .cindex "host list" "matching host name"
7911 If a pattern is of the form
7912 .display
7913 <&'single-key-search-type'&>;<&'search-data'&>
7914 .endd
7915 for example
7916 .code
7917 dbm;/host/accept/list
7918 .endd
7919 a single-key lookup is performend, using the host name as its key. If the
7920 lookup succeeds, the host matches the item. The actual data that is looked up
7921 is not used.
7922
7923 &*Reminder*&: With this kind of pattern, you must have host &'names'& as
7924 keys in the file, not IP addresses. If you want to do lookups based on IP
7925 addresses, you must precede the search type with &"net-"& (see section
7926 &<<SECThoslispatsikey>>&). There is, however, no reason why you could not use
7927 two items in the same list, one doing an address lookup and one doing a name
7928 lookup, both using the same file.
7929
7930
7931
7932 .section "Host list patterns for query-style lookups"
7933 If a pattern is of the form
7934 .display
7935 <&'query-style-search-type'&>;<&'query'&>
7936 .endd
7937 the query is obeyed, and if it succeeds, the host matches the item. The actual
7938 data that is looked up is not used. The variables &$sender_host_address$& and
7939 &$sender_host_name$& can be used in the query. For example:
7940 .code
7941 hosts_lookup = pgsql;\
7942   select ip from hostlist where ip='$sender_host_address'
7943 .endd
7944 The value of &$sender_host_address$& for an IPv6 address contains colons. You
7945 can use the &%sg%& expansion item to change this if you need to. If you want to
7946 use masked IP addresses in database queries, you can use the &%mask%& expansion
7947 operator.
7948
7949 If the query contains a reference to &$sender_host_name$&, Exim automatically
7950 looks up the host name if has not already done so. (See section
7951 &<<SECThoslispatnam>>& for comments on finding host names.)
7952
7953 Historical note: prior to release 4.30, Exim would always attempt to find a
7954 host name before running the query, unless the search type was preceded by
7955 &`net-`&. This is no longer the case. For backwards compatibility, &`net-`& is
7956 still recognized for query-style lookups, but its presence or absence has no
7957 effect. (Of course, for single-key lookups, &`net-`& &'is'& important.
7958 See section &<<SECThoslispatsikey>>&.)
7959
7960
7961
7962 .section "Mixing wildcarded host names and addresses in host lists" &&&
7963          "SECTmixwilhos"
7964 .cindex "host list" "mixing names and addresses in"
7965 If you have name lookups or wildcarded host names and IP addresses in the same
7966 host list, you should normally put the IP addresses first. For example, in an
7967 ACL you could have:
7968 .code
7969 accept hosts = 10.9.8.7 : *.friend.example
7970 .endd
7971 The reason for this lies in the left-to-right way that Exim processes lists.
7972 It can test IP addresses without doing any DNS lookups, but when it reaches an
7973 item that requires a host name, it fails if it cannot find a host name to
7974 compare with the pattern. If the above list is given in the opposite order, the
7975 &%accept%& statement fails for a host whose name cannot be found, even if its
7976 IP address is 10.9.8.7.
7977
7978 If you really do want to do the name check first, and still recognize the IP
7979 address, you can rewrite the ACL like this:
7980 .code
7981 accept hosts = *.friend.example
7982 accept hosts = 10.9.8.7
7983 .endd
7984 If the first &%accept%& fails, Exim goes on to try the second one. See chapter
7985 &<<CHAPACL>>& for details of ACLs.
7986
7987
7988
7989
7990
7991 .section "Address lists" "SECTaddresslist"
7992 .cindex "list" "address list"
7993 .cindex "address list" "empty item"
7994 .cindex "address list" "patterns"
7995 Address lists contain patterns that are matched against mail addresses. There
7996 is one special case to be considered: the sender address of a bounce message is
7997 always empty. You can test for this by providing an empty item in an address
7998 list. For example, you can set up a router to process bounce messages by
7999 using this option setting:
8000 .code
8001 senders = :
8002 .endd
8003 The presence of the colon creates an empty item. If you do not provide any
8004 data, the list is empty and matches nothing. The empty sender can also be
8005 detected by a regular expression that matches an empty string,
8006 and by a query-style lookup that succeeds when &$sender_address$& is empty.
8007
8008 Non-empty items in an address list can be straightforward email addresses. For
8009 example:
8010 .code
8011 senders = jbc@askone.example : hs@anacreon.example
8012 .endd
8013 A certain amount of wildcarding is permitted. If a pattern contains an @
8014 character, but is not a regular expression and does not begin with a
8015 semicolon-terminated lookup type (described below), the local part of the
8016 subject address is compared with the local part of the pattern, which may start
8017 with an asterisk. If the local parts match, the domain is checked in exactly
8018 the same way as for a pattern in a domain list. For example, the domain can be
8019 wildcarded, refer to a named list, or be a lookup:
8020 .code
8021 deny senders = *@*.spamming.site:\
8022                *@+hostile_domains:\
8023                bozo@partial-lsearch;/list/of/dodgy/sites:\
8024                *@dbm;/bad/domains.db
8025 .endd
8026 .cindex "local part" "starting with !"
8027 .cindex "address list" "local part starting with !"
8028 If a local part that begins with an exclamation mark is required, it has to be
8029 specified using a regular expression, because otherwise the exclamation mark is
8030 treated as a sign of negation, as is standard in lists.
8031
8032 If a non-empty pattern that is not a regular expression or a lookup does not
8033 contain an @ character, it is matched against the domain part of the subject
8034 address. The only two formats that are recognized this way are a literal
8035 domain, or a domain pattern that starts with *. In both these cases, the effect
8036 is the same as if &`*@`& preceded the pattern. For example:
8037 .code
8038 deny senders = enemy.domain : *.enemy.domain
8039 .endd
8040
8041 The following kinds of more complicated address list pattern can match any
8042 address, including the empty address that is characteristic of bounce message
8043 senders:
8044
8045 .ilist
8046 .cindex "regular expressions" "in address list"
8047 .cindex "address list" "regular expression in"
8048 If (after expansion) a pattern starts with &"^"&, a regular expression match is
8049 done against the complete address, with the pattern as the regular expression.
8050 You must take care that backslash and dollar characters are not misinterpreted
8051 as part of the string expansion. The simplest way to do this is to use &`\N`&
8052 to mark that part of the string as non-expandable. For example:
8053 .code
8054 deny senders = \N^.*this.*@example\.com$\N : \
8055                \N^\d{8}.+@spamhaus.example$\N : ...
8056 .endd
8057 The &`\N`& sequences are removed by the expansion, so these items do indeed
8058 start with &"^"& by the time they are being interpreted as address patterns.
8059
8060 .next
8061 .cindex "address list" "lookup for complete address"
8062 Complete addresses can be looked up by using a pattern that starts with a
8063 lookup type terminated by a semicolon, followed by the data for the lookup. For
8064 example:
8065 .code
8066 deny senders = cdb;/etc/blocked.senders : \
8067   mysql;select address from blocked where \
8068   address='${quote_mysql:$sender_address}'
8069 .endd
8070 Both query-style and single-key lookup types can be used. For a single-key
8071 lookup type, Exim uses the complete address as the key. However, empty keys are
8072 not supported for single-key lookups, so a match against the empty address
8073 always fails. This restriction does not apply to query-style lookups.
8074
8075 Partial matching for single-key lookups (section &<<SECTpartiallookup>>&)
8076 cannot be used, and is ignored if specified, with an entry being written to the
8077 panic log.
8078 .cindex "*@ with single-key lookup"
8079 However, you can configure lookup defaults, as described in section
8080 &<<SECTdefaultvaluelookups>>&, but this is useful only for the &"*@"& type of
8081 default. For example, with this lookup:
8082 .code
8083 accept senders = lsearch*@;/some/file
8084 .endd
8085 the file could contains lines like this:
8086 .code
8087 user1@domain1.example
8088 *@domain2.example
8089 .endd
8090 and for the sender address &'nimrod@jaeger.example'&, the sequence of keys
8091 that are tried is:
8092 .code
8093 nimrod@jaeger.example
8094 *@jaeger.example
8095 *
8096 .endd
8097 &*Warning 1*&: Do not include a line keyed by &"*"& in the file, because that
8098 would mean that every address matches, thus rendering the test useless.
8099
8100 &*Warning 2*&: Do not confuse these two kinds of item:
8101 .code
8102 deny recipients = dbm*@;/some/file
8103 deny recipients = *@dbm;/some/file
8104 .endd
8105 The first does a whole address lookup, with defaulting, as just described,
8106 because it starts with a lookup type. The second matches the local part and
8107 domain independently, as described in a bullet point below.
8108 .endlist
8109
8110
8111 The following kinds of address list pattern can match only non-empty addresses.
8112 If the subject address is empty, a match against any of these pattern types
8113 always fails.
8114
8115
8116 .ilist
8117 .cindex "@@ with single-key lookup"
8118 .cindex "address list" "@@ lookup type"
8119 .cindex "address list" "split local part and domain"
8120 If a pattern starts with &"@@"& followed by a single-key lookup item
8121 (for example, &`@@lsearch;/some/file`&), the address that is being checked is
8122 split into a local part and a domain. The domain is looked up in the file. If
8123 it is not found, there is no match. If it is found, the data that is looked up
8124 from the file is treated as a colon-separated list of local part patterns, each
8125 of which is matched against the subject local part in turn.
8126
8127 .cindex "asterisk" "in address list"
8128 The lookup may be a partial one, and/or one involving a search for a default
8129 keyed by &"*"& (see section &<<SECTdefaultvaluelookups>>&). The local part
8130 patterns that are looked up can be regular expressions or begin with &"*"&, or
8131 even be further lookups. They may also be independently negated. For example,
8132 with
8133 .code
8134 deny senders = @@dbm;/etc/reject-by-domain
8135 .endd
8136 the data from which the DBM file is built could contain lines like
8137 .code
8138 baddomain.com:  !postmaster : *
8139 .endd
8140 to reject all senders except &%postmaster%& from that domain.
8141
8142 .cindex "local part" "starting with !"
8143 If a local part that actually begins with an exclamation mark is required, it
8144 has to be specified using a regular expression. In &(lsearch)& files, an entry
8145 may be split over several lines by indenting the second and subsequent lines,
8146 but the separating colon must still be included at line breaks. White space
8147 surrounding the colons is ignored. For example:
8148 .code
8149 aol.com:  spammer1 : spammer2 : ^[0-9]+$ :
8150 spammer3 : spammer4
8151 .endd
8152 As in all colon-separated lists in Exim, a colon can be included in an item by
8153 doubling.
8154
8155 If the last item in the list starts with a right angle-bracket, the remainder
8156 of the item is taken as a new key to look up in order to obtain a continuation
8157 list of local parts. The new key can be any sequence of characters. Thus one
8158 might have entries like
8159 .code
8160 aol.com: spammer1 : spammer 2 : >*
8161 xyz.com: spammer3 : >*
8162 *:       ^\d{8}$
8163 .endd
8164 in a file that was searched with &%@@dbm*%&, to specify a match for 8-digit
8165 local parts for all domains, in addition to the specific local parts listed for
8166 each domain. Of course, using this feature costs another lookup each time a
8167 chain is followed, but the effort needed to maintain the data is reduced.
8168
8169 .cindex "loop" "in lookups"
8170 It is possible to construct loops using this facility, and in order to catch
8171 them, the chains may be no more than fifty items long.
8172
8173 .next
8174 The @@<&'lookup'&> style of item can also be used with a query-style
8175 lookup, but in this case, the chaining facility is not available. The lookup
8176 can only return a single list of local parts.
8177 .endlist
8178
8179 &*Warning*&: There is an important difference between the address list items
8180 in these two examples:
8181 .code
8182 senders = +my_list
8183 senders = *@+my_list
8184 .endd
8185 In the first one, &`my_list`& is a named address list, whereas in the second
8186 example it is a named domain list.
8187
8188
8189
8190
8191 .section "Case of letters in address lists" "SECTcasletadd"
8192 .cindex "case of local parts"
8193 .cindex "address list" "case forcing"
8194 .cindex "case forcing in address lists"
8195 Domains in email addresses are always handled caselessly, but for local parts
8196 case may be significant on some systems (see &%caseful_local_part%& for how
8197 Exim deals with this when routing addresses). However, RFC 2505 (&'Anti-Spam
8198 Recommendations for SMTP MTAs'&) suggests that matching of addresses to
8199 blocking lists should be done in a case-independent manner. Since most address
8200 lists in Exim are used for this kind of control, Exim attempts to do this by
8201 default.
8202
8203 The domain portion of an address is always lowercased before matching it to an
8204 address list. The local part is lowercased by default, and any string
8205 comparisons that take place are done caselessly. This means that the data in
8206 the address list itself, in files included as plain file names, and in any file
8207 that is looked up using the &"@@"& mechanism, can be in any case. However, the
8208 keys in files that are looked up by a search type other than &(lsearch)& (which
8209 works caselessly) must be in lower case, because these lookups are not
8210 case-independent.
8211
8212 .cindex "&`+caseful`&"
8213 To allow for the possibility of caseful address list matching, if an item in
8214 an address list is the string &"+caseful"&, the original case of the local
8215 part is restored for any comparisons that follow, and string comparisons are no
8216 longer case-independent. This does not affect the domain, which remains in
8217 lower case. However, although independent matches on the domain alone are still
8218 performed caselessly, regular expressions that match against an entire address
8219 become case-sensitive after &"+caseful"& has been seen.
8220
8221
8222
8223 .section "Local part lists" "SECTlocparlis"
8224 .cindex "list" "local part list"
8225 .cindex "local part" "list"
8226 Case-sensitivity in local part lists is handled in the same way as for address
8227 lists, as just described. The &"+caseful"& item can be used if required. In a
8228 setting of the &%local_parts%& option in a router with &%caseful_local_part%&
8229 set false, the subject is lowercased and the matching is initially
8230 case-insensitive. In this case, &"+caseful"& will restore case-sensitive
8231 matching in the local part list, but not elsewhere in the router. If
8232 &%caseful_local_part%& is set true in a router, matching in the &%local_parts%&
8233 option is case-sensitive from the start.
8234
8235 If a local part list is indirected to a file (see section &<<SECTfilnamlis>>&),
8236 comments are handled in the same way as address lists &-- they are recognized
8237 only if the # is preceded by white space or the start of the line.
8238 Otherwise, local part lists are matched in the same way as domain lists, except
8239 that the special items that refer to the local host (&`@`&, &`@[]`&,
8240 &`@mx_any`&, &`@mx_primary`&, and &`@mx_secondary`&) are not recognized.
8241 Refer to section &<<SECTdomainlist>>& for details of the other available item
8242 types.
8243 .ecindex IIDdohoadli
8244
8245
8246
8247
8248 . ////////////////////////////////////////////////////////////////////////////
8249 . ////////////////////////////////////////////////////////////////////////////
8250
8251 .chapter "String expansions" "CHAPexpand"
8252 .scindex IIDstrexp "expansion" "of strings"
8253 Many strings in Exim's run time configuration are expanded before use. Some of
8254 them are expanded every time they are used; others are expanded only once.
8255
8256 When a string is being expanded it is copied verbatim from left to right except
8257 when a dollar or backslash character is encountered. A dollar specifies the
8258 start of a portion of the string that is interpreted and replaced as described
8259 below in section &<<SECTexpansionitems>>& onwards. Backslash is used as an
8260 escape character, as described in the following section.
8261
8262
8263
8264 .section "Literal text in expanded strings" "SECTlittext"
8265 .cindex "expansion" "including literal text"
8266 An uninterpreted dollar can be included in an expanded string by putting a
8267 backslash in front of it. A backslash can be used to prevent any special
8268 character being treated specially in an expansion, including backslash itself.
8269 If the string appears in quotes in the configuration file, two backslashes are
8270 required because the quotes themselves cause interpretation of backslashes when
8271 the string is read in (see section &<<SECTstrings>>&).
8272
8273 .cindex "expansion" "non-expandable substrings"
8274 A portion of the string can specified as non-expandable by placing it between
8275 two occurrences of &`\N`&. This is particularly useful for protecting regular
8276 expressions, which often contain backslashes and dollar signs. For example:
8277 .code
8278 deny senders = \N^\d{8}[a-z]@some\.site\.example$\N
8279 .endd
8280 On encountering the first &`\N`&, the expander copies subsequent characters
8281 without interpretation until it reaches the next &`\N`& or the end of the
8282 string.
8283
8284
8285
8286 .section "Character escape sequences in expanded strings"
8287 .cindex "expansion" "escape sequences"
8288 A backslash followed by one of the letters &"n"&, &"r"&, or &"t"& in an
8289 expanded string is recognized as an escape sequence for the character newline,
8290 carriage return, or tab, respectively. A backslash followed by up to three
8291 octal digits is recognized as an octal encoding for a single character, and a
8292 backslash followed by &"x"& and up to two hexadecimal digits is a hexadecimal
8293 encoding.
8294
8295 These escape sequences are also recognized in quoted strings when they are read
8296 in. Their interpretation in expansions as well is useful for unquoted strings,
8297 and for other cases such as looked-up strings that are then expanded.
8298
8299
8300 .section "Testing string expansions"
8301 .cindex "expansion" "testing"
8302 .cindex "testing" "string expansion"
8303 .cindex "&%-be%& option"
8304 Many expansions can be tested by calling Exim with the &%-be%& option. This
8305 takes the command arguments, or lines from the standard input if there are no
8306 arguments, runs them through the string expansion code, and writes the results
8307 to the standard output. Variables based on configuration values are set up, but
8308 since no message is being processed, variables such as &$local_part$& have no
8309 value. Nevertheless the &%-be%& option can be useful for checking out file and
8310 database lookups, and the use of expansion operators such as &%sg%&, &%substr%&
8311 and &%nhash%&.
8312
8313 Exim gives up its root privilege when it is called with the &%-be%& option, and
8314 instead runs under the uid and gid it was called with, to prevent users from
8315 using &%-be%& for reading files to which they do not have access.
8316
8317 .new
8318 .cindex "&%-bem%& option"
8319 If you want to test expansions that include variables whose values are taken
8320 from a message, there are two other options that can be used. The &%-bem%&
8321 option is like &%-be%& except that it is followed by a file name. The file is
8322 read as a message before doing the test expansions. For example:
8323 .code
8324 exim -bem /tmp/test.message '$h_subject:'
8325 .endd
8326 The &%-Mset%& option is used in conjunction with &%-be%& and is followed by an
8327 Exim message identifier. For example:
8328 .code
8329 exim -be -Mset 1GrA8W-0004WS-LQ '$recipients'
8330 .endd
8331 This loads the message from Exim's spool before doing the test expansions, and
8332 is therefore restricted to admin users.
8333 .wen
8334
8335
8336 .section "Forced expansion failure" "SECTforexpfai"
8337 .cindex "expansion" "forced failure"
8338 A number of expansions that are described in the following section have
8339 alternative &"true"& and &"false"& substrings, enclosed in brace characters
8340 (which are sometimes called &"curly brackets"&). Which of the two strings is
8341 used depends on some condition that is evaluated as part of the expansion. If,
8342 instead of a &"false"& substring, the word &"fail"& is used (not in braces),
8343 the entire string expansion fails in a way that can be detected by the code
8344 that requested the expansion. This is called &"forced expansion failure"&, and
8345 its consequences depend on the circumstances. In some cases it is no different
8346 from any other expansion failure, but in others a different action may be
8347 taken. Such variations are mentioned in the documentation of the option that is
8348 being expanded.
8349
8350
8351
8352
8353 .section "Expansion items" "SECTexpansionitems"
8354 The following items are recognized in expanded strings. White space may be used
8355 between sub-items that are keywords or substrings enclosed in braces inside an
8356 outer set of braces, to improve readability. &*Warning*&: Within braces,
8357 white space is significant.
8358
8359 .vlist
8360 .vitem &*$*&<&'variable&~name'&>&~or&~&*${*&<&'variable&~name'&>&*}*&
8361 .cindex "expansion" "variables"
8362 Substitute the contents of the named variable, for example:
8363 .code
8364 $local_part
8365 ${domain}
8366 .endd
8367 The second form can be used to separate the name from subsequent alphanumeric
8368 characters. This form (using braces) is available only for variables; it does
8369 &'not'& apply to message headers. The names of the variables are given in
8370 section &<<SECTexpvar>>& below. If the name of a non-existent variable is
8371 given, the expansion fails.
8372
8373 .vitem &*${*&<&'op'&>&*:*&<&'string'&>&*}*&
8374 .cindex "expansion" "operators"
8375 The string is first itself expanded, and then the operation specified by
8376 <&'op'&> is applied to it. For example:
8377 .code
8378 ${lc:$local_part}
8379 .endd
8380 The string starts with the first character after the colon, which may be
8381 leading white space. A list of operators is given in section &<<SECTexpop>>&
8382 below. The operator notation is used for simple expansion items that have just
8383 one argument, because it reduces the number of braces and therefore makes the
8384 string easier to understand.
8385
8386 .vitem "&*${dlfunc{*&<&'file'&>&*}{*&<&'function'&>&*}{*&<&'arg'&>&*}&&&
8387        {*&<&'arg'&>&*}...}*&"
8388 .cindex &%dlfunc%&
8389 This expansion dynamically loads and then calls a locally-written C function.
8390 This functionality is available only if Exim is compiled with
8391 .code
8392 EXPAND_DLFUNC=yes
8393 .endd
8394 set in &_Local/Makefile_&. Once loaded, Exim remembers the dynamically loaded
8395 object so that it doesn't reload the same object file in the same Exim process
8396 (but of course Exim does start new processes frequently).
8397
8398 There may be from zero to eight arguments to the function. When compiling
8399 a local function that is to be called in this way, &_local_scan.h_& should be
8400 included. The Exim variables and functions that are defined by that API
8401 are also available for dynamically loaded functions. The function itself
8402 must have the following type:
8403 .code
8404 int dlfunction(uschar **yield, int argc, uschar *argv[])
8405 .endd
8406 Where &`uschar`& is a typedef for &`unsigned char`& in &_local_scan.h_&. The
8407 function should return one of the following values:
8408
8409 &`OK`&: Success. The string that is placed in the variable &'yield'& is put
8410 into the expanded string that is being built.
8411
8412 &`FAIL`&: A non-forced expansion failure occurs, with the error message taken
8413 from &'yield'&, if it is set.
8414
8415 &`FAIL_FORCED`&: A forced expansion failure occurs, with the error message
8416 taken from &'yield'& if it is set.
8417
8418 &`ERROR`&: Same as &`FAIL`&, except that a panic log entry is written.
8419
8420 When compiling a function that is to be used in this way with gcc,
8421 you need to add &%-shared%& to the gcc command. Also, in the Exim build-time
8422 configuration, you must add &%-export-dynamic%& to EXTRALIBS.
8423
8424 .vitem "&*${extract{*&<&'key'&>&*}{*&<&'string1'&>&*}{*&<&'string2'&>&*}&&&
8425        {*&<&'string3'&>&*}}*&"
8426 .cindex "expansion" "extracting substrings by key"
8427 .cindex "&%extract%&" "substrings by key"
8428 The key and <&'string1'&> are first expanded separately. Leading and trailing
8429 white space is removed from the key (but not from any of the strings). The key
8430 must not consist entirely of digits. The expanded <&'string1'&> must be of the
8431 form:
8432 .display
8433 <&'key1'&> = <&'value1'&>  <&'key2'&> = <&'value2'&> ...
8434 .endd
8435 .cindex "&$value$&"
8436 where the equals signs and spaces (but not both) are optional. If any of the
8437 values contain white space, they must be enclosed in double quotes, and any
8438 values that are enclosed in double quotes are subject to escape processing as
8439 described in section &<<SECTstrings>>&. The expanded <&'string1'&> is searched
8440 for the value that corresponds to the key. The search is case-insensitive. If
8441 the key is found, <&'string2'&> is expanded, and replaces the whole item;
8442 otherwise <&'string3'&> is used. During the expansion of <&'string2'&> the
8443 variable &$value$& contains the value that has been extracted. Afterwards, it
8444 is restored to any previous value it might have had.
8445
8446 If {<&'string3'&>} is omitted, the item is replaced by an empty string if the
8447 key is not found. If {<&'string2'&>} is also omitted, the value that was
8448 extracted is used. Thus, for example, these two expansions are identical, and
8449 yield &"2001"&:
8450 .code
8451 ${extract{gid}{uid=1984 gid=2001}}
8452 ${extract{gid}{uid=1984 gid=2001}{$value}}
8453 .endd
8454 Instead of {<&'string3'&>} the word &"fail"& (not in curly brackets) can
8455 appear, for example:
8456 .code
8457 ${extract{Z}{A=... B=...}{$value} fail }
8458 .endd
8459 This forces an expansion failure (see section &<<SECTforexpfai>>&);
8460 {<&'string2'&>} must be present for &"fail"& to be recognized.
8461
8462
8463 .vitem "&*${extract{*&<&'number'&>&*}{*&<&'separators'&>&*}&&&
8464         {*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&"
8465 .cindex "expansion" "extracting substrings by number"
8466 .cindex "&%extract%&" "substrings by number"
8467 The <&'number'&> argument must consist entirely of decimal digits,
8468 apart from leading and trailing white space, which is ignored.
8469 This is what distinguishes this form of &%extract%& from the previous kind. It
8470 behaves in the same way, except that, instead of extracting a named field, it
8471 extracts from <&'string1'&> the field whose number is given as the first
8472 argument. You can use &$value$& in <&'string2'&> or &`fail`& instead of
8473 <&'string3'&> as before.
8474
8475 The fields in the string are separated by any one of the characters in the
8476 separator string. These may include space or tab characters.
8477 The first field is numbered one. If the number is negative, the fields are
8478 counted from the end of the string, with the rightmost one numbered -1. If the
8479 number given is zero, the entire string is returned. If the modulus of the
8480 number is greater than the number of fields in the string, the result is the
8481 expansion of <&'string3'&>, or the empty string if <&'string3'&> is not
8482 provided. For example:
8483 .code
8484 ${extract{2}{:}{x:42:99:& Mailer::/bin/bash}}
8485 .endd
8486 yields &"42"&, and
8487 .code
8488 ${extract{-4}{:}{x:42:99:& Mailer::/bin/bash}}
8489 .endd
8490 yields &"99"&. Two successive separators mean that the field between them is
8491 empty (for example, the fifth field above).
8492
8493
8494 .vitem &*${hash{*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&
8495 .cindex "hash function" "textual"
8496 .cindex "expansion" "textual hash"
8497 This is a textual hashing function, and was the first to be implemented in
8498 early versions of Exim. In current releases, there are other hashing functions
8499 (numeric, MD5, and SHA-1), which are described below.
8500
8501 The first two strings, after expansion, must be numbers. Call them <&'m'&> and
8502 <&'n'&>. If you are using fixed values for these numbers, that is, if
8503 <&'string1'&> and <&'string2'&> do not change when they are expanded, you can
8504 use the simpler operator notation that avoids some of the braces:
8505 .code
8506 ${hash_<n>_<m>:<string>}
8507 .endd
8508 The second number is optional (in both notations). If <&'n'&> is greater than
8509 or equal to the length of the string, the expansion item returns the string.
8510 Otherwise it computes a new string of length <&'n'&> by applying a hashing
8511 function to the string. The new string consists of characters taken from the
8512 first <&'m'&> characters of the string
8513 .code
8514 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQWRSTUVWXYZ0123456789
8515 .endd
8516 If <&'m'&> is not present the value 26 is used, so that only lower case
8517 letters appear. For example:
8518 .display
8519 &`$hash{3}{monty}}           `&   yields  &`jmg`&
8520 &`$hash{5}{monty}}           `&   yields  &`monty`&
8521 &`$hash{4}{62}{monty python}}`&   yields  &`fbWx`&
8522 .endd
8523
8524 .vitem "&*$header_*&<&'header&~name'&>&*:*&&~or&~&&&
8525         &*$h_*&<&'header&~name'&>&*:*&"
8526 See &*$rheader*& below.
8527
8528 .vitem "&*$bheader_*&<&'header&~name'&>&*:*&&~or&~&&&
8529         &*$bh_*&<&'header&~name'&>&*:*&"
8530 See &*$rheader*& below.
8531
8532 .vitem "&*$rheader_*&<&'header&~name'&>&*:*&&~or&~&&&
8533         &*$rh_*&<&'header&~name'&>&*:*&"
8534 .cindex "expansion" "header insertion"
8535 .cindex "&$header_$&"
8536 .cindex "&$bheader_$&"
8537 .cindex "&$rheader_$&"
8538 .cindex "header lines" "in expansion strings"
8539 .cindex "header lines" "character sets"
8540 .cindex "header lines" "decoding"
8541 Substitute the contents of the named message header line, for example
8542 .code
8543 $header_reply-to:
8544 .endd
8545 The newline that terminates a header line is not included in the expansion, but
8546 internal newlines (caused by splitting the header line over several physical
8547 lines) may be present.
8548
8549 The difference between &%rheader%&, &%bheader%&, and &%header%& is in the way
8550 the data in the header line is interpreted.
8551
8552 .ilist
8553 .cindex "white space" "in header lines"
8554 &%rheader%& gives the original &"raw"& content of the header line, with no
8555 processing at all, and without the removal of leading and trailing white space.
8556
8557 .next
8558 .cindex "base64 encoding" "in header lines"
8559 &%bheader%& removes leading and trailing white space, and then decodes base64
8560 or quoted-printable MIME &"words"& within the header text, but does no
8561 character set translation. If decoding of what looks superficially like a MIME
8562 &"word"& fails, the raw string is returned. If decoding
8563 .cindex "binary zero" "in header line"
8564 produces a binary zero character, it is replaced by a question mark &-- this is
8565 what Exim does for binary zeros that are actually received in header lines.
8566
8567 .next
8568 &%header%& tries to translate the string as decoded by &%bheader%& to a
8569 standard character set. This is an attempt to produce the same string as would
8570 be displayed on a user's MUA. If translation fails, the &%bheader%& string is
8571 returned. Translation is attempted only on operating systems that support the
8572 &[iconv()]& function. This is indicated by the compile-time macro HAVE_ICONV in
8573 a system Makefile or in &_Local/Makefile_&.
8574 .endlist ilist
8575
8576 In a filter file, the target character set for &%header%& can be specified by a
8577 command of the following form:
8578 .code
8579 headers charset "UTF-8"
8580 .endd
8581 This command affects all references to &$h_$& (or &$header_$&) expansions in
8582 subsequently obeyed filter commands. In the absence of this command, the target
8583 character set in a filter is taken from the setting of the &%headers_charset%&
8584 option in the runtime configuration. The value of this option defaults to the
8585 value of HEADERS_CHARSET in &_Local/Makefile_&. The ultimate default is
8586 ISO-8859-1.
8587
8588 Header names follow the syntax of RFC 2822, which states that they may contain
8589 any printing characters except space and colon. Consequently, curly brackets
8590 &'do not'& terminate header names, and should not be used to enclose them as
8591 if they were variables. Attempting to do so causes a syntax error.
8592
8593 .new
8594 Only header lines that are common to all copies of a message are visible to
8595 this mechanism. These are the original header lines that are received with the
8596 message, and any that are added by an ACL statement or by a system
8597 filter. Header lines that are added to a particular copy of a message by a
8598 router or transport are not accessible.
8599
8600 For incoming SMTP messages, no header lines are visible in ACLs that are obeyed
8601 before the DATA ACL, because the header structure is not set up until the
8602 message is received. Header lines that are added in a RCPT ACL (for example)
8603 are saved until the message's incoming header lines are available, at which
8604 point they are added. When a DATA ACL is running, however, header lines added
8605 by earlier ACLs are visible.
8606 .wen
8607
8608 Upper case and lower case letters are synonymous in header names. If the
8609 following character is white space, the terminating colon may be omitted, but
8610 this is not recommended, because you may then forget it when it is needed. When
8611 white space terminates the header name, it is included in the expanded string.
8612 If the message does not contain the given header, the expansion item is
8613 replaced by an empty string. (See the &%def%& condition in section
8614 &<<SECTexpcond>>& for a means of testing for the existence of a header.)
8615
8616 .new
8617 If there is more than one header with the same name, they are all concatenated
8618 to form the substitution string, up to a maximum length of 64K. Unless
8619 &%rheader%& is being used, leading and trailing white space is removed from
8620 each header before concatenation, and a completely empty header is ignored. A
8621 newline character is then inserted between non-empty headers, but there is no
8622 newline at the very end. For the &%header%& and &%bheader%& expansion, for
8623 those headers that contain lists of addresses, a comma is also inserted at the
8624 junctions between headers. This does not happen for the &%rheader%& expansion.
8625 .wen
8626
8627
8628 .vitem &*${hmac{*&<&'hashname'&>&*}{*&<&'secret'&>&*}{*&<&'string'&>&*}}*&
8629 .cindex "expansion" "hmac hashing"
8630 .cindex &%hmac%&
8631 This function uses cryptographic hashing (either MD5 or SHA-1) to convert a
8632 shared secret and some text into a message authentication code, as specified in
8633 RFC 2104. This differs from &`${md5:secret_text...}`& or
8634 &`${sha1:secret_text...}`& in that the hmac step adds a signature to the
8635 cryptographic hash, allowing for authentication that is not possible with MD5
8636 or SHA-1 alone. The hash name must expand to either &`md5`& or &`sha1`& at
8637 present. For example:
8638 .code
8639 ${hmac{md5}{somesecret}{$primary_hostname $tod_log}}
8640 .endd
8641 For the hostname &'mail.example.com'& and time 2002-10-17 11:30:59, this
8642 produces:
8643 .code
8644 dd97e3ba5d1a61b5006108f8c8252953
8645 .endd
8646 As an example of how this might be used, you might put in the main part of
8647 an Exim configuration:
8648 .code
8649 SPAMSCAN_SECRET=cohgheeLei2thahw
8650 .endd
8651 In a router or a transport you could then have:
8652 .code
8653 headers_add = \
8654   X-Spam-Scanned: ${primary_hostname} ${message_exim_id} \
8655   ${hmac{md5}{SPAMSCAN_SECRET}\
8656   {${primary_hostname},${message_exim_id},$h_message-id:}}
8657 .endd
8658 Then given a message, you can check where it was scanned by looking at the
8659 &'X-Spam-Scanned:'& header line. If you know the secret, you can check that
8660 this header line is authentic by recomputing the authentication code from the
8661 host name, message ID and the &'Message-id:'& header line. This can be done
8662 using Exim's &%-be%& option, or by other means, for example by using the
8663 &'hmac_md5_hex()'& function in Perl.
8664
8665
8666 .vitem &*${if&~*&<&'condition'&>&*&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}}*&
8667 .cindex "expansion" "conditional"
8668 .cindex "&%if%&, expansion item"
8669 If <&'condition'&> is true, <&'string1'&> is expanded and replaces the whole
8670 item; otherwise <&'string2'&> is used. The available conditions are described
8671 in section &<<SECTexpcond>>& below. For example:
8672 .code
8673 ${if eq {$local_part}{postmaster} {yes}{no} }
8674 .endd
8675 The second string need not be present; if it is not and the condition is not
8676 true, the item is replaced with nothing. Alternatively, the word &"fail"& may
8677 be present instead of the second string (without any curly brackets). In this
8678 case, the expansion is forced to fail if the condition is not true (see section
8679 &<<SECTforexpfai>>&).
8680
8681 If both strings are omitted, the result is the string &`true`& if the condition
8682 is true, and the empty string if the condition is false. This makes it less
8683 cumbersome to write custom ACL and router conditions. For example, instead of
8684 .code
8685 condition = ${if >{$acl_m4}{3}{true}{false}}
8686 .endd
8687 you can use
8688 .code
8689 condition = ${if >{$acl_m4}{3}}
8690 .endd
8691
8692 .vitem &*${length{*&<&'string1'&>&*}{*&<&'string2'&>&*}}*&
8693 .cindex "expansion" "string truncation"
8694 .cindex "&%length%&" "expansion item"
8695 The &%length%& item is used to extract the initial portion of a string. Both
8696 strings are expanded, and the first one must yield a number, <&'n'&>, say. If
8697 you are using a fixed value for the number, that is, if <&'string1'&> does not
8698 change when expanded, you can use the simpler operator notation that avoids
8699 some of the braces:
8700 .code
8701 ${length_<n>:<string>}
8702 .endd
8703 The result of this item is either the first <&'n'&> characters or the whole
8704 of <&'string2'&>, whichever is the shorter. Do not confuse &%length%& with
8705 &%strlen%&, which gives the length of a string.
8706
8707
8708 .vitem "&*${lookup{*&<&'key'&>&*}&~*&<&'search&~type'&>&*&~&&&
8709         {*&<&'file'&>&*}&~{*&<&'string1'&>&*}&~{*&<&'string2'&>&*}}*&"
8710 This is the first of one of two different types of lookup item, which are both
8711 described in the next item.
8712
8713 .vitem "&*${lookup&~*&<&'search&~type'&>&*&~{*&<&'query'&>&*}&~&&&
8714         {*&<&'string1'&>&*}&~{*&<&'string2'&>&*}}*&"
8715 .cindex "expansion" "lookup in"
8716 .cindex "file" "lookups"
8717 .cindex "lookup" "in expanded string"
8718 The two forms of lookup item specify data lookups in files and databases, as
8719 discussed in chapter &<<CHAPfdlookup>>&. The first form is used for single-key
8720 lookups, and the second is used for query-style lookups. The <&'key'&>,
8721 <&'file'&>, and <&'query'&> strings are expanded before use.
8722
8723 If there is any white space in a lookup item which is part of a filter command,
8724 a retry or rewrite rule, a routing rule for the &(manualroute)& router, or any
8725 other place where white space is significant, the lookup item must be enclosed
8726 in double quotes. The use of data lookups in users' filter files may be locked
8727 out by the system administrator.
8728
8729 .cindex "&$value$&"
8730 If the lookup succeeds, <&'string1'&> is expanded and replaces the entire item.
8731 During its expansion, the variable &$value$& contains the data returned by the
8732 lookup. Afterwards it reverts to the value it had previously (at the outer
8733 level it is empty). If the lookup fails, <&'string2'&> is expanded and replaces
8734 the entire item. If {<&'string2'&>} is omitted, the replacement is the empty
8735 string on failure. If <&'string2'&> is provided, it can itself be a nested
8736 lookup, thus providing a mechanism for looking up a default value when the
8737 original lookup fails.
8738
8739 If a nested lookup is used as part of <&'string1'&>, &$value$& contains the
8740 data for the outer lookup while the parameters of the second lookup are
8741 expanded, and also while <&'string2'&> of the second lookup is expanded, should
8742 the second lookup fail. Instead of {<&'string2'&>} the word &"fail"& can
8743 appear, and in this case, if the lookup fails, the entire expansion is forced
8744 to fail (see section &<<SECTforexpfai>>&). If both {<&'string1'&>} and
8745 {<&'string2'&>} are omitted, the result is the looked up value in the case of a
8746 successful lookup, and nothing in the case of failure.
8747
8748 For single-key lookups, the string &"partial"& is permitted to precede the
8749 search type in order to do partial matching, and * or *@ may follow a search
8750 type to request default lookups if the key does not match (see sections
8751 &<<SECTdefaultvaluelookups>>& and &<<SECTpartiallookup>>& for details).
8752
8753 .cindex "numerical variables (&$1$& &$2$& etc)" "in lookup expansion"
8754 If a partial search is used, the variables &$1$& and &$2$& contain the wild
8755 and non-wild parts of the key during the expansion of the replacement text.
8756 They return to their previous values at the end of the lookup item.
8757
8758 This example looks up the postmaster alias in the conventional alias file:
8759 .code
8760 ${lookup {postmaster} lsearch {/etc/aliases} {$value}}
8761 .endd
8762 This example uses NIS+ to look up the full name of the user corresponding to
8763 the local part of an address, forcing the expansion to fail if it is not found:
8764 .code
8765 ${lookup nisplus {[name=$local_part],passwd.org_dir:gcos} \
8766   {$value}fail}
8767 .endd
8768
8769 .vitem &*${nhash{*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&
8770 .cindex "expansion" "numeric hash"
8771 .cindex "hash function" "numeric"
8772 The three strings are expanded; the first two must yield numbers. Call them
8773 <&'n'&> and <&'m'&>. If you are using fixed values for these numbers, that is,
8774 if <&'string1'&> and <&'string2'&> do not change when they are expanded, you
8775 can use the simpler operator notation that avoids some of the braces:
8776 .code
8777 ${nhash_<n>_<m>:<string>}
8778 .endd
8779 The second number is optional (in both notations). If there is only one number,
8780 the result is a number in the range 0&--<&'n'&>-1. Otherwise, the string is
8781 processed by a div/mod hash function that returns two numbers, separated by a
8782 slash, in the ranges 0 to <&'n'&>-1 and 0 to <&'m'&>-1, respectively. For
8783 example,
8784 .code
8785 ${nhash{8}{64}{supercalifragilisticexpialidocious}}
8786 .endd
8787 returns the string &"6/33"&.
8788
8789
8790
8791 .vitem &*${perl{*&<&'subroutine'&>&*}{*&<&'arg'&>&*}{*&<&'arg'&>&*}...}*&
8792 .cindex "Perl" "use in expanded string"
8793 .cindex "expansion" "calling Perl from"
8794 This item is available only if Exim has been built to include an embedded Perl
8795 interpreter. The subroutine name and the arguments are first separately
8796 expanded, and then the Perl subroutine is called with those arguments. No
8797 additional arguments need be given; the maximum number permitted, including the
8798 name of the subroutine, is nine.
8799
8800 The return value of the subroutine is inserted into the expanded string, unless
8801 the return value is &%undef%&. In that case, the expansion fails in the same
8802 way as an explicit &"fail"& on a lookup item. The return value is a scalar.
8803 Whatever you return is evaluated in a scalar context. For example, if you
8804 return the name of a Perl vector, the return value is the size of the vector,
8805 not its contents.
8806
8807 If the subroutine exits by calling Perl's &%die%& function, the expansion fails
8808 with the error message that was passed to &%die%&. More details of the embedded
8809 Perl facility are given in chapter &<<CHAPperl>>&.
8810
8811 The &(redirect)& router has an option called &%forbid_filter_perl%& which locks
8812 out the use of this expansion item in filter files.
8813
8814
8815 .vitem &*${prvs{*&<&'address'&>&*}{*&<&'secret'&>&*}{*&<&'keynumber'&>&*}}*&
8816 .cindex "prvs" "expansion item"
8817 The first argument is a complete email address and the second is secret
8818 keystring. The third argument, specifying a key number, is optional. If absent,
8819 it defaults to 0. The result of the expansion is a prvs-signed email address,
8820 to be typically used with the &%return_path%& option on an &(smtp)& transport
8821 as part of a bounce address tag validation (BATV) scheme. For more discussion
8822 and an example, see section &<<SECTverifyPRVS>>&.
8823
8824 .vitem "&*${prvscheck{*&<&'address'&>&*}{*&<&'secret'&>&*}&&&
8825         {*&<&'string'&>&*}}*&"
8826 .cindex "prvscheck" "expansion item"
8827 This expansion item is the complement of the &%prvs%& item. It is used for
8828 checking prvs-signed addresses. If the expansion of the first argument does not
8829 yield a syntactically valid prvs-signed address, the whole item expands to the
8830 empty string. When the first argument does expand to a syntactically valid
8831 prvs-signed address, the second argument is expanded, with the prvs-decoded
8832 version of the address and the key number extracted from the address in the
8833 variables &$prvscheck_address$& and &$prvscheck_keynum$&, respectively.
8834
8835 These two variables can be used in the expansion of the second argument to
8836 retrieve the secret. The validity of the prvs-signed address is then checked
8837 against the secret. The result is stored in the variable &$prvscheck_result$&,
8838 which is empty for failure or &"1"& for success.
8839
8840 The third argument is optional; if it is missing, it defaults to an empty
8841 string. This argument is now expanded. If the result is an empty string, the
8842 result of the expansion is the decoded version of the address. This is the case
8843 whether or not the signature was valid. Otherwise, the result of the expansion
8844 is the expansion of the third argument.
8845
8846 All three variables can be used in the expansion of the third argument.
8847 However, once the expansion is complete, only &$prvscheck_result$& remains set.
8848 For more discussion and an example, see section &<<SECTverifyPRVS>>&.
8849
8850 .vitem &*${readfile{*&<&'file&~name'&>&*}{*&<&'eol&~string'&>&*}}*&
8851 .cindex "expansion" "inserting an entire file"
8852 .cindex "file" "inserting into expansion"
8853 .cindex "&%readfile%& expansion item"
8854 The file name and end-of-line string are first expanded separately. The file is
8855 then read, and its contents replace the entire item. All newline characters in
8856 the file are replaced by the end-of-line string if it is present. Otherwise,
8857 newlines are left in the string.
8858 String expansion is not applied to the contents of the file. If you want this,
8859 you must wrap the item in an &%expand%& operator. If the file cannot be read,
8860 the string expansion fails.
8861
8862 The &(redirect)& router has an option called &%forbid_filter_readfile%& which
8863 locks out the use of this expansion item in filter files.
8864
8865
8866
8867 .vitem "&*${readsocket{*&<&'name'&>&*}{*&<&'request'&>&*}&&&
8868         {*&<&'timeout'&>&*}{*&<&'eol&~string'&>&*}{*&<&'fail&~string'&>&*}}*&"
8869 .cindex "expansion" "inserting from a socket"
8870 .cindex "socket" "use of in expansion"
8871 .cindex "&%readsocket%& expansion item"
8872 This item inserts data from a Unix domain or Internet socket into the expanded
8873 string. The minimal way of using it uses just two arguments, as in these
8874 examples:
8875 .code
8876 ${readsocket{/socket/name}{request string}}
8877 ${readsocket{inet:some.host:1234}{request string}}
8878 .endd
8879 For a Unix domain socket, the first substring must be the path to the socket.
8880 For an Internet socket, the first substring must contain &`inet:`& followed by
8881 a host name or IP address, followed by a colon and a port, which can be a
8882 number or the name of a TCP port in &_/etc/services_&. An IP address may
8883 optionally be enclosed in square brackets. This is best for IPv6 addresses. For
8884 example:
8885 .code
8886 ${readsocket{inet:[::1]:1234}{request string}}
8887 .endd
8888 Only a single host name may be given, but if looking it up yields more than
8889 one IP address, they are each tried in turn until a connection is made. For
8890 both kinds of socket, Exim makes a connection, writes the request string
8891 (unless it is an empty string) and reads from the socket until an end-of-file
8892 is read. A timeout of 5 seconds is applied. Additional, optional arguments
8893 extend what can be done. Firstly, you can vary the timeout. For example:
8894 .code
8895 ${readsocket{/socket/name}{request string}{3s}}
8896 .endd
8897 A fourth argument allows you to change any newlines that are in the data
8898 that is read, in the same way as for &%readfile%& (see above). This example
8899 turns them into spaces:
8900 .code
8901 ${readsocket{inet:127.0.0.1:3294}{request string}{3s}{ }}
8902 .endd
8903 As with all expansions, the substrings are expanded before the processing
8904 happens. Errors in these sub-expansions cause the expansion to fail. In
8905 addition, the following errors can occur:
8906
8907 .ilist
8908 Failure to create a socket file descriptor;
8909 .next
8910 Failure to connect the socket;
8911 .next
8912 Failure to write the request string;
8913 .next
8914 Timeout on reading from the socket.
8915 .endlist
8916
8917 By default, any of these errors causes the expansion to fail. However, if
8918 you supply a fifth substring, it is expanded and used when any of the above
8919 errors occurs. For example:
8920 .code
8921 ${readsocket{/socket/name}{request string}{3s}{\n}\
8922   {socket failure}}
8923 .endd
8924 You can test for the existence of a Unix domain socket by wrapping this
8925 expansion in &`${if exists`&, but there is a race condition between that test
8926 and the actual opening of the socket, so it is safer to use the fifth argument
8927 if you want to be absolutely sure of avoiding an expansion error for a
8928 non-existent Unix domain socket, or a failure to connect to an Internet socket.
8929
8930 The &(redirect)& router has an option called &%forbid_filter_readsocket%& which
8931 locks out the use of this expansion item in filter files.
8932
8933 .vitem &*$rheader_*&<&'header&~name'&>&*:&~or&~$rh_*&<&'header&~name'&>&*:*&
8934 This item inserts &"raw"& header lines. It is described with the &%header%&
8935 expansion item above.
8936
8937 .vitem "&*${run{*&<&'command'&>&*&~*&<&'args'&>&*}{*&<&'string1'&>&*}&&&
8938         {*&<&'string2'&>&*}}*&"
8939 .cindex "expansion" "running a command"
8940 .cindex "&%run%& expansion item"
8941 The command and its arguments are first expanded separately, and then the
8942 command is run in a separate process, but under the same uid and gid. As in
8943 other command executions from Exim, a shell is not used by default. If you want
8944 a shell, you must explicitly code it.
8945
8946 .new
8947 The standard input for the command exists, but is empty. The standard output
8948 and standard error are set to the same file descriptor.
8949 .cindex "return code" "from &%run%& expansion"
8950 .cindex "&$value$&"
8951 If the command succeeds (gives a zero return code) <&'string1'&> is expanded
8952 and replaces the entire item; during this expansion, the standard output/error
8953 from the command is in the variable &$value$&. If the command fails,
8954 <&'string2'&>, if present, is expanded and used. Once again, during the
8955 expansion, the standard output/error from the command is in the variable
8956 &$value$&.
8957
8958 If <&'string2'&> is absent, the result is empty. Alternatively, <&'string2'&>
8959 can be the word &"fail"& (not in braces) to force expansion failure if the
8960 command does not succeed. If both strings are omitted, the result is contents
8961 of the standard output/error on success, and nothing on failure.
8962 .wen
8963
8964 .cindex "&$runrc$&"
8965 The return code from the command is put in the variable &$runrc$&, and this
8966 remains set afterwards, so in a filter file you can do things like this:
8967 .code
8968 if "${run{x y z}{}}$runrc" is 1 then ...
8969   elif $runrc is 2 then ...
8970   ...
8971 endif
8972 .endd
8973 If execution of the command fails (for example, the command does not exist),
8974 the return code is 127 &-- the same code that shells use for non-existent
8975 commands.
8976
8977 &*Warning*&: In a router or transport, you cannot assume the order in which
8978 option values are expanded, except for those preconditions whose order of
8979 testing is documented. Therefore, you cannot reliably expect to set &$runrc$&
8980 by the expansion of one option, and use it in another.
8981
8982 The &(redirect)& router has an option called &%forbid_filter_run%& which locks
8983 out the use of this expansion item in filter files.
8984
8985
8986 .vitem &*${sg{*&<&'subject'&>&*}{*&<&'regex'&>&*}{*&<&'replacement'&>&*}}*&
8987 .cindex "expansion" "string substitution"
8988 .cindex "&%sg%& expansion item"
8989 This item works like Perl's substitution operator (s) with the global (/g)
8990 option; hence its name. However, unlike the Perl equivalent, Exim does not
8991 modify the subject string; instead it returns the modified string for insertion
8992 into the overall expansion. The item takes three arguments: the subject string,
8993 a regular expression, and a substitution string. For example:
8994 .code
8995 ${sg{abcdefabcdef}{abc}{xyz}}
8996 .endd
8997 yields &"xyzdefxyzdef"&. Because all three arguments are expanded before use,
8998 if any $ or \ characters are required in the regular expression or in the
8999 substitution string, they have to be escaped. For example:
9000 .code
9001 ${sg{abcdef}{^(...)(...)\$}{\$2\$1}}
9002 .endd
9003 yields &"defabc"&, and
9004 .code
9005 ${sg{1=A 4=D 3=C}{\N(\d+)=\N}{K\$1=}}
9006 .endd
9007 yields &"K1=A K4=D K3=C"&. Note the use of &`\N`& to protect the contents of
9008 the regular expression from string expansion.
9009
9010
9011
9012 .vitem &*${substr{*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&
9013 .cindex "&%substr%&"
9014 .cindex "substring extraction"
9015 .cindex "expansion" "substring extraction"
9016 The three strings are expanded; the first two must yield numbers. Call them
9017 <&'n'&> and <&'m'&>. If you are using fixed values for these numbers, that is,
9018 if <&'string1'&> and <&'string2'&> do not change when they are expanded, you
9019 can use the simpler operator notation that avoids some of the braces:
9020 .code
9021 ${substr_<n>_<m>:<string>}
9022 .endd
9023 The second number is optional (in both notations).
9024 If it is absent in the simpler format, the preceding underscore must also be
9025 omitted.
9026
9027 The &%substr%& item can be used to extract more general substrings than
9028 &%length%&. The first number, <&'n'&>, is a starting offset, and <&'m'&> is the
9029 length required. For example
9030 .code
9031 ${substr{3}{2}{$local_part}}
9032 .endd
9033 If the starting offset is greater than the string length the result is the
9034 null string; if the length plus starting offset is greater than the string
9035 length, the result is the right-hand part of the string, starting from the
9036 given offset. The first character in the string has offset zero.
9037
9038 The &%substr%& expansion item can take negative offset values to count
9039 from the right-hand end of its operand. The last character is offset -1, the
9040 second-last is offset -2, and so on. Thus, for example,
9041 .code
9042 ${substr{-5}{2}{1234567}}
9043 .endd
9044 yields &"34"&. If the absolute value of a negative offset is greater than the
9045 length of the string, the substring starts at the beginning of the string, and
9046 the length is reduced by the amount of overshoot. Thus, for example,
9047 .code
9048 ${substr{-5}{2}{12}}
9049 .endd
9050 yields an empty string, but
9051 .code
9052 ${substr{-3}{2}{12}}
9053 .endd
9054 yields &"1"&.
9055
9056 When the second number is omitted from &%substr%&, the remainder of the string
9057 is taken if the offset is positive. If it is negative, all characters in the
9058 string preceding the offset point are taken. For example, an offset of -1 and
9059 no length, as in these semantically identical examples:
9060 .code
9061 ${substr_-1:abcde}
9062 ${substr{-1}{abcde}}
9063 .endd
9064 yields all but the last character of the string, that is, &"abcd"&.
9065
9066
9067
9068 .vitem "&*${tr{*&<&'subject'&>&*}{*&<&'characters'&>&*}&&&
9069         {*&<&'replacements'&>&*}}*&"
9070 .cindex "expansion" "character translation"
9071 .cindex "&%tr%& expansion item"
9072 This item does single-character translation on its subject string. The second
9073 argument is a list of characters to be translated in the subject string. Each
9074 matching character is replaced by the corresponding character from the
9075 replacement list. For example
9076 .code
9077 ${tr{abcdea}{ac}{13}}
9078 .endd
9079 yields &`1b3de1`&. If there are duplicates in the second character string, the
9080 last occurrence is used. If the third string is shorter than the second, its
9081 last character is replicated. However, if it is empty, no translation takes
9082 place.
9083 .endlist
9084
9085
9086
9087 .section "Expansion operators" "SECTexpop"
9088 .cindex "expansion" "operators"
9089 For expansion items that perform transformations on a single argument string,
9090 the &"operator"& notation is used because it is simpler and uses fewer braces.
9091 The substring is first expanded before the operation is applied to it. The
9092 following operations can be performed:
9093
9094 .vlist
9095 .vitem &*${address:*&<&'string'&>&*}*&
9096 .cindex "expansion" "RFC 2822 address handling"
9097 .cindex "&%address%&" "expansion item"
9098 The string is interpreted as an RFC 2822 address, as it might appear in a
9099 header line, and the effective address is extracted from it. If the string does
9100 not parse successfully, the result is empty.
9101
9102
9103 .vitem &*${base62:*&<&'digits'&>&*}*&
9104 .cindex "&%base62%&"
9105 .cindex "expansion" "conversion to base 62"
9106 The string must consist entirely of decimal digits. The number is converted to
9107 base 62 and output as a string of six characters, including leading zeros. In
9108 the few operating environments where Exim uses base 36 instead of base 62 for
9109 its message identifiers (because those systems do not have case-sensitive file
9110 names), base 36 is used by this operator, despite its name. &*Note*&: Just to
9111 be absolutely clear: this is &'not'& base64 encoding.
9112
9113 .vitem &*${base62d:*&<&'base-62&~digits'&>&*}*&
9114 .cindex "&%base62d%&"
9115 .cindex "expansion" "conversion to base 62"
9116 The string must consist entirely of base-62 digits, or, in operating
9117 environments where Exim uses base 36 instead of base 62 for its message
9118 identifiers, base-36 digits. The number is converted to decimal and output as a
9119 string.
9120
9121 .vitem &*${domain:*&<&'string'&>&*}*&
9122 .cindex "domain" "extraction"
9123 .cindex "expansion" "domain extraction"
9124 The string is interpreted as an RFC 2822 address and the domain is extracted
9125 from it. If the string does not parse successfully, the result is empty.
9126
9127
9128 .vitem &*${escape:*&<&'string'&>&*}*&
9129 .cindex "expansion" "escaping non-printing characters"
9130 .cindex "&%escape%&, expansion item"
9131 If the string contains any non-printing characters, they are converted to
9132 escape sequences starting with a backslash. Whether characters with the most
9133 significant bit set (so-called &"8-bit characters"&) count as printing or not
9134 is controlled by the &%print_topbitchars%& option.
9135
9136
9137 .vitem &*${eval:*&<&'string'&>&*}*&&~and&~&*${eval10:*&<&'string'&>&*}*&
9138 .cindex "expansion" "expression evaluation"
9139 .cindex "expansion" "arithmetic expression"
9140 .cindex "&%eval%& expansion item"
9141 .new
9142 These items supports simple arithmetic and bitwise logical operations in
9143 expansion strings. The string (after expansion) must be a conventional
9144 arithmetic expression, but it is limited to basic arithmetic operators, bitwise
9145 logical operators, and parentheses. All operations are carried out using
9146 integer arithmetic. The operator priorities are as follows (the same as in the
9147 C programming language):
9148 .table2 90pt 300pt
9149 .row &~&~&~&~&~&~&~&~&'highest:'& "not (~), negate (-)"
9150 .row ""   "multiply (*), divide (/), remainder (%)"
9151 .row ""   "plus (+), minus (-)"
9152 .row ""   "shift-left (<<), shift-right (>>)"
9153 .row ""   "and (&&)"
9154 .row ""   "xor (^)"
9155 .row &~&~&~&~&~&~&~&~&'lowest:'&  "or (|)"
9156 .endtable
9157 Binary operators with the same priority are evaluated from left to right. White
9158 space is permitted before or after operators.
9159
9160 For &%eval%&, numbers may be decimal, octal (starting with &"0"&) or
9161 hexadecimal (starting with &"0x"&). For &%eval10%&, all numbers are taken as
9162 decimal, even if they start with a leading zero; hexadecimal numbers are not
9163 permitted. This can be useful when processing numbers extracted from dates or
9164 times, which often do have leading zeros.
9165
9166 A number may be followed by &"K"& or &"M"& to multiply it by 1024 or 1024*1024,
9167 respectively. Negative numbers are supported. The result of the computation is
9168 a decimal representation of the answer (without &"K"& or &"M"&). For example:
9169
9170 .display
9171 &`${eval:1+1}            `&  yields 2
9172 &`${eval:1+2*3}          `&  yields 7
9173 &`${eval:(1+2)*3}        `&  yields 9
9174 &`${eval:2+42%5}         `&  yields 4
9175 &`${eval:0xc&amp;5}          `&  yields 4
9176 &`${eval:0xc|5}          `&  yields 13
9177 &`${eval:0xc^5}          `&  yields 9
9178 &`${eval:0xc>>1}         `&  yields 6
9179 &`${eval:0xc<<1}         `&  yields 24
9180 &`${eval:~255&amp;0x1234}    `&  yields 4608
9181 &`${eval:-(~255&amp;0x1234)} `&  yields -4608
9182 .endd
9183 .wen
9184
9185 As a more realistic example, in an ACL you might have
9186 .code
9187 deny   message = Too many bad recipients
9188        condition =                    \
9189          ${if and {                   \
9190            {>{$rcpt_count}{10}}       \
9191            {                          \
9192            <                          \
9193              {$recipients_count}      \
9194              {${eval:$rcpt_count/2}}  \
9195            }                          \
9196          }{yes}{no}}
9197 .endd
9198 The condition is true if there have been more than 10 RCPT commands and
9199 fewer than half of them have resulted in a valid recipient.
9200
9201
9202 .vitem &*${expand:*&<&'string'&>&*}*&
9203 .cindex "expansion" "re-expansion of substring"
9204 The &%expand%& operator causes a string to be expanded for a second time. For
9205 example,
9206 .code
9207 ${expand:${lookup{$domain}dbm{/some/file}{$value}}}
9208 .endd
9209 first looks up a string in a file while expanding the operand for &%expand%&,
9210 and then re-expands what it has found.
9211
9212
9213 .vitem &*${from_utf8:*&<&'string'&>&*}*&
9214 .cindex "Unicode"
9215 .cindex "UTF-8" "conversion from"
9216 .cindex "expansion" "UTF-8 conversion"
9217 .cindex "&%from_utf8%&"
9218 The world is slowly moving towards Unicode, although there are no standards for
9219 email yet. However, other applications (including some databases) are starting
9220 to store data in Unicode, using UTF-8 encoding. This operator converts from a
9221 UTF-8 string to an ISO-8859-1 string. UTF-8 code values greater than 255 are
9222 converted to underscores. The input must be a valid UTF-8 string. If it is not,
9223 the result is an undefined sequence of bytes.
9224
9225 Unicode code points with values less than 256 are compatible with ASCII and
9226 ISO-8859-1 (also known as Latin-1).
9227 For example, character 169 is the copyright symbol in both cases, though the
9228 way it is encoded is different. In UTF-8, more than one byte is needed for
9229 characters with code values greater than 127, whereas ISO-8859-1 is a
9230 single-byte encoding (but thereby limited to 256 characters). This makes
9231 translation from UTF-8 to ISO-8859-1 straightforward.
9232
9233
9234 .vitem &*${hash_*&<&'n'&>&*_*&<&'m'&>&*:*&<&'string'&>&*}*&
9235 .cindex "hash function" "textual"
9236 .cindex "expansion" "textual hash"
9237 The &%hash%& operator is a simpler interface to the hashing function that can
9238 be used when the two parameters are fixed numbers (as opposed to strings that
9239 change when expanded). The effect is the same as
9240 .code
9241 ${hash{<n>}{<m>}{<string>}}
9242 .endd
9243 See the description of the general &%hash%& item above for details. The
9244 abbreviation &%h%& can be used when &%hash%& is used as an operator.
9245
9246
9247
9248 .vitem &*${hex2b64:*&<&'hexstring'&>&*}*&
9249 .cindex "base64 encoding" "conversion from hex"
9250 .cindex "expansion" "hex to base64"
9251 .cindex "&%hex2b64%&"
9252 This operator converts a hex string into one that is base64 encoded. This can
9253 be useful for processing the output of the MD5 and SHA-1 hashing functions.
9254
9255
9256 .vitem &*${lc:*&<&'string'&>&*}*&
9257 .cindex "case forcing in strings"
9258 .cindex "string" "case forcing"
9259 .cindex "lower casing"
9260 .cindex "expansion" "case forcing"
9261 .cindex "&%lc%& expansion item"
9262 This forces the letters in the string into lower-case, for example:
9263 .code
9264 ${lc:$local_part}
9265 .endd
9266
9267 .vitem &*${length_*&<&'number'&>&*:*&<&'string'&>&*}*&
9268 .cindex "expansion" "string truncation"
9269 .cindex "&%length%&" "expansion item"
9270 The &%length%& operator is a simpler interface to the &%length%& function that
9271 can be used when the parameter is a fixed number (as opposed to a string that
9272 changes when expanded). The effect is the same as
9273 .code
9274 ${length{<number>}{<string>}}
9275 .endd
9276 See the description of the general &%length%& item above for details. Note that
9277 &%length%& is not the same as &%strlen%&. The abbreviation &%l%& can be used
9278 when &%length%& is used as an operator.
9279
9280
9281 .vitem &*${local_part:*&<&'string'&>&*}*&
9282 .cindex "expansion" "local part extraction"
9283 .cindex "&%local_part%& expansion item"
9284 The string is interpreted as an RFC 2822 address and the local part is
9285 extracted from it. If the string does not parse successfully, the result is
9286 empty.
9287
9288
9289 .vitem &*${mask:*&<&'IP&~address'&>&*/*&<&'bit&~count'&>&*}*&
9290 .cindex "masked IP address"
9291 .cindex "IP address" "masking"
9292 .cindex "CIDR notation"
9293 .cindex "expansion" "IP address masking"
9294 .cindex "&%mask%&, expansion item"
9295 If the form of the string to be operated on is not an IP address followed by a
9296 slash and an integer (that is, a network address in CIDR notation), the
9297 expansion fails. Otherwise, this operator converts the IP address to binary,
9298 masks off the least significant bits according to the bit count, and converts
9299 the result back to text, with mask appended. For example,
9300 .code
9301 ${mask:10.111.131.206/28}
9302 .endd
9303 returns the string &"10.111.131.192/28"&. Since this operation is expected to
9304 be mostly used for looking up masked addresses in files, the result for an IPv6
9305 address uses dots to separate components instead of colons, because colon
9306 terminates a key string in lsearch files. So, for example,
9307 .code
9308 ${mask:3ffe:ffff:836f:0a00:000a:0800:200a:c031/99}
9309 .endd
9310 returns the string
9311 .code
9312 3ffe.ffff.836f.0a00.000a.0800.2000.0000/99
9313 .endd
9314 Letters in IPv6 addresses are always output in lower case.
9315
9316
9317 .vitem &*${md5:*&<&'string'&>&*}*&
9318 .cindex "MD5 hash"
9319 .cindex "expansion" "MD5 hash"
9320 .cindex "&%md5%& expansion item"
9321 The &%md5%& operator computes the MD5 hash value of the string, and returns it
9322 as a 32-digit hexadecimal number, in which any letters are in lower case.
9323
9324
9325 .vitem &*${nhash_*&<&'n'&>&*_*&<&'m'&>&*:*&<&'string'&>&*}*&
9326 .cindex "expansion" "numeric hash"
9327 .cindex "hash function" "numeric"
9328 The &%nhash%& operator is a simpler interface to the numeric hashing function
9329 that can be used when the two parameters are fixed numbers (as opposed to
9330 strings that change when expanded). The effect is the same as
9331 .code
9332 ${nhash{<n>}{<m>}{<string>}}
9333 .endd
9334 See the description of the general &%nhash%& item above for details.
9335
9336
9337 .vitem &*${quote:*&<&'string'&>&*}*&
9338 .cindex "quoting" "in string expansions"
9339 .cindex "expansion" "quoting"
9340 .cindex "&%quote%&, expansion item"
9341 The &%quote%& operator puts its argument into double quotes if it
9342 is an empty string or
9343 contains anything other than letters, digits, underscores, dots, and hyphens.
9344 Any occurrences of double quotes and backslashes are escaped with a backslash.
9345 Newlines and carriage returns are converted to &`\n`& and &`\r`&,
9346 respectively For example,
9347 .code
9348 ${quote:ab"*"cd}
9349 .endd
9350 becomes
9351 .code
9352 "ab\"*\"cd"
9353 .endd
9354 The place where this is useful is when the argument is a substitution from a
9355 variable or a message header.
9356
9357 .vitem &*${quote_local_part:*&<&'string'&>&*}*&
9358 .cindex "&%quote_local_part%& expansion item"
9359 This operator is like &%quote%&, except that it quotes the string only if
9360 required to do so by the rules of RFC 2822 for quoting local parts. For
9361 example, a plus sign would not cause quoting (but it would for &%quote%&).
9362 If you are creating a new email address from the contents of &$local_part$&
9363 (or any other unknown data), you should always use this operator.
9364
9365
9366 .vitem &*${quote_*&<&'lookup-type'&>&*:*&<&'string'&>&*}*&
9367 .cindex "quoting" "lookup-specific"
9368 This operator applies lookup-specific quoting rules to the string. Each
9369 query-style lookup type has its own quoting rules which are described with
9370 the lookups in chapter &<<CHAPfdlookup>>&. For example,
9371 .code
9372 ${quote_ldap:two * two}
9373 .endd
9374 returns
9375 .code
9376 two%20%5C2A%20two
9377 .endd
9378 For single-key lookup types, no quoting is ever necessary and this operator
9379 yields an unchanged string.
9380
9381
9382 .vitem &*${rfc2047:*&<&'string'&>&*}*&
9383 .cindex "expansion" "RFC 2047"
9384 .cindex "RFC 2047" "expansion operator"
9385 .cindex "&%rfc2047%& expansion item"
9386 This operator encodes text according to the rules of RFC 2047. This is an
9387 encoding that is used in header lines to encode non-ASCII characters. It is
9388 assumed that the input string is in the encoding specified by the
9389 &%headers_charset%& option, which defaults to ISO-8859-1. If the string
9390 contains only characters in the range 33&--126, and no instances of the
9391 characters
9392 .code
9393 ? = ( ) < > @ , ; : \ " . [ ] _
9394 .endd
9395 it is not modified. Otherwise, the result is the RFC 2047 encoding of the
9396 string, using as many &"encoded words"& as necessary to encode all the
9397 characters.
9398
9399
9400
9401 .vitem &*${rxquote:*&<&'string'&>&*}*&
9402 .cindex "quoting" "in regular expressions"
9403 .cindex "regular expressions" "quoting"
9404 .cindex "&%rxquote%& expansion item"
9405 The &%rxquote%& operator inserts a backslash before any non-alphanumeric
9406 characters in its argument. This is useful when substituting the values of
9407 variables or headers inside regular expressions.
9408
9409
9410 .vitem &*${sha1:*&<&'string'&>&*}*&
9411 .cindex "SHA-1 hash"
9412 .cindex "expansion" "SHA-1 hashing"
9413 .cindex "&%sha2%& expansion item"
9414 The &%sha1%& operator computes the SHA-1 hash value of the string, and returns
9415 it as a 40-digit hexadecimal number, in which any letters are in upper case.
9416
9417
9418 .vitem &*${stat:*&<&'string'&>&*}*&
9419 .cindex "expansion" "statting a file"
9420 .cindex "file" "extracting characteristics"
9421 .cindex "&%stat%& expansion item"
9422 The string, after expansion, must be a file path. A call to the &[stat()]&
9423 function is made for this path. If &[stat()]& fails, an error occurs and the
9424 expansion fails. If it succeeds, the data from the stat replaces the item, as a
9425 series of <&'name'&>=<&'value'&> pairs, where the values are all numerical,
9426 except for the value of &"smode"&. The names are: &"mode"& (giving the mode as
9427 a 4-digit octal number), &"smode"& (giving the mode in symbolic format as a
9428 10-character string, as for the &'ls'& command), &"inode"&, &"device"&,
9429 &"links"&, &"uid"&, &"gid"&, &"size"&, &"atime"&, &"mtime"&, and &"ctime"&. You
9430 can extract individual fields using the &%extract%& expansion item.
9431
9432 The use of the &%stat%& expansion in users' filter files can be locked out by
9433 the system administrator. &*Warning*&: The file size may be incorrect on 32-bit
9434 systems for files larger than 2GB.
9435
9436 .vitem &*${str2b64:*&<&'string'&>&*}*&
9437 .cindex "expansion" "base64 encoding"
9438 .cindex "base64 encoding" "in string expansion"
9439 .cindex "&%str2b64%& expansion item"
9440 This operator converts a string into one that is base64 encoded.
9441
9442
9443
9444 .vitem &*${strlen:*&<&'string'&>&*}*&
9445 .cindex "expansion" "string length"
9446 .cindex "string" "length in expansion"
9447 .cindex "&%strlen%& expansion item"
9448 The item is replace by the length of the expanded string, expressed as a
9449 decimal number. &*Note*&: Do not confuse &%strlen%& with &%length%&.
9450
9451
9452 .vitem &*${substr_*&<&'start'&>&*_*&<&'length'&>&*:*&<&'string'&>&*}*&
9453 .cindex "&%substr%& expansion item"
9454 .cindex "substring extraction"
9455 .cindex "expansion" "substring expansion"
9456 The &%substr%& operator is a simpler interface to the &%substr%& function that
9457 can be used when the two parameters are fixed numbers (as opposed to strings
9458 that change when expanded). The effect is the same as
9459 .code
9460 ${substr{<start>}{<length>}{<string>}}
9461 .endd
9462 See the description of the general &%substr%& item above for details. The
9463 abbreviation &%s%& can be used when &%substr%& is used as an operator.
9464
9465 .vitem &*${time_eval:*&<&'string'&>&*}*&
9466 .cindex "&%time_eval%& expansion item"
9467 .cindex "time interval" "decoding"
9468 This item converts an Exim time interval such as &`2d4h5m`& into a number of
9469 seconds.
9470
9471 .vitem &*${time_interval:*&<&'string'&>&*}*&
9472 .cindex "&%time_interval%& expansion item"
9473 .cindex "time interval" "formatting"
9474 The argument (after sub-expansion) must be a sequence of decimal digits that
9475 represents an interval of time as a number of seconds. It is converted into a
9476 number of larger units and output in Exim's normal time format, for example,
9477 &`1w3d4h2m6s`&.
9478
9479 .vitem &*${uc:*&<&'string'&>&*}*&
9480 .cindex "case forcing in strings"
9481 .cindex "string" "case forcing"
9482 .cindex "upper casing"
9483 .cindex "expansion" "case forcing"
9484 .cindex "&%uc%& expansion item"
9485 This forces the letters in the string into upper-case.
9486 .endlist
9487
9488
9489
9490
9491
9492
9493 .section "Expansion conditions" "SECTexpcond"
9494 .scindex IIDexpcond "expansion" "conditions"
9495 The following conditions are available for testing by the &%${if%& construct
9496 while expanding strings:
9497
9498 .vlist
9499 .vitem &*!*&<&'condition'&>
9500 .cindex "expansion" "negating a condition"
9501 .cindex "negation" "in expansion condition"
9502 Preceding any condition with an exclamation mark negates the result of the
9503 condition.
9504
9505 .vitem <&'symbolic&~operator'&>&~&*{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9506 .cindex "numeric comparison"
9507 .cindex "expansion" "numeric comparison"
9508 There are a number of symbolic operators for doing numeric comparisons. They
9509 are:
9510 .display
9511 &`=   `&   equal
9512 &`==  `&   equal
9513 &`>   `&   greater
9514 &`>=  `&   greater or equal
9515 &`<   `&   less
9516 &`<=  `&   less or equal
9517 .endd
9518 For example:
9519 .code
9520 ${if >{$message_size}{10M} ...
9521 .endd
9522 Note that the general negation operator provides for inequality testing. The
9523 two strings must take the form of optionally signed decimal integers,
9524 optionally followed by one of the letters &"K"& or &"M"& (in either upper or
9525 lower case), signifying multiplication by 1024 or 1024*1024, respectively.
9526
9527 .vitem &*crypteq&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9528 .cindex "expansion" "encrypted comparison"
9529 .cindex "encrypted strings" "comparing"
9530 .cindex "&%crypteq%& expansion condition"
9531 This condition is included in the Exim binary if it is built to support any
9532 authentication mechanisms (see chapter &<<CHAPSMTPAUTH>>&). Otherwise, it is
9533 necessary to define SUPPORT_CRYPTEQ in &_Local/Makefile_& to get &%crypteq%&
9534 included in the binary.
9535
9536 The &%crypteq%& condition has two arguments. The first is encrypted and
9537 compared against the second, which is already encrypted. The second string may
9538 be in the LDAP form for storing encrypted strings, which starts with the
9539 encryption type in curly brackets, followed by the data. If the second string
9540 does not begin with &"{"& it is assumed to be encrypted with &[crypt()]& or
9541 &[crypt16()]& (see below), since such strings cannot begin with &"{"&.
9542 Typically this will be a field from a password file. An example of an encrypted
9543 string in LDAP form is:
9544 .code
9545 {md5}CY9rzUYh03PK3k6DJie09g==
9546 .endd
9547 If such a string appears directly in an expansion, the curly brackets have to
9548 be quoted, because they are part of the expansion syntax. For example:
9549 .code
9550 ${if crypteq {test}{\{md5\}CY9rzUYh03PK3k6DJie09g==}{yes}{no}}
9551 .endd
9552 The following encryption types (whose names are matched case-independently) are
9553 supported:
9554
9555 .ilist
9556 .cindex "MD5 hash"
9557 .cindex "base64 encoding" "in encrypted password"
9558 &%{md5}%& computes the MD5 digest of the first string, and expresses this as
9559 printable characters to compare with the remainder of the second string. If the
9560 length of the comparison string is 24, Exim assumes that it is base64 encoded
9561 (as in the above example). If the length is 32, Exim assumes that it is a
9562 hexadecimal encoding of the MD5 digest. If the length not 24 or 32, the
9563 comparison fails.
9564
9565 .next
9566 .cindex "SHA-1 hash"
9567 &%{sha1}%& computes the SHA-1 digest of the first string, and expresses this as
9568 printable characters to compare with the remainder of the second string. If the
9569 length of the comparison string is 28, Exim assumes that it is base64 encoded.
9570 If the length is 40, Exim assumes that it is a hexadecimal encoding of the
9571 SHA-1 digest. If the length is not 28 or 40, the comparison fails.
9572
9573 .next
9574 .cindex "&[crypt()]&"
9575 &%{crypt}%& calls the &[crypt()]& function, which traditionally used to use
9576 only the first eight characters of the password. However, in modern operating
9577 systems this is no longer true, and in many cases the entire password is used,
9578 whatever its length.
9579
9580 .next
9581 .new
9582 .cindex "&[crypt16()]&"
9583 &%{crypt16}%& calls the &[crypt16()]& function, which was orginally created to
9584 use up to 16 characters of the password in some operating systems. Again, in
9585 modern operating systems, more characters may be used.
9586 .endlist
9587 Exim has its own version of &[crypt16()]&, which is just a double call to
9588 &[crypt()]&. For operating systems that have their own version, setting
9589 HAVE_CRYPT16 in &_Local/Makefile_& when building Exim causes it to use the
9590 operating system version instead of its own. This option is set by default in
9591 the OS-dependent &_Makefile_& for those operating systems that are known to
9592 support &[crypt16()]&.
9593
9594 Some years after Exim's &[crypt16()]& was implemented, a user discovered that
9595 it was not using the same algorithm as some operating systems' versions. It
9596 turns out that as well as &[crypt16()]& there is a function called
9597 &[bigcrypt()]& in some operating systems. This may or may not use the same
9598 algorithm, and both of them may be different to Exim's built-in &[crypt16()]&.
9599
9600 However, since there is now a move away from the traditional &[crypt()]&
9601 functions towards using SHA1 and other algorithms, tidying up this area of
9602 Exim is seen as very low priority.
9603
9604 If you do not put a encryption type (in curly brackets) in a &%crypteq%&
9605 comparison, the default is usually either &`{crypt}`& or &`{crypt16}`&, as
9606 determined by the setting of DEFAULT_CRYPT in &_Local/Makefile_&. The default
9607 default is &`{crypt}`&. Whatever the default, you can always use either
9608 function by specifying it explicitly in curly brackets.
9609 .wen
9610
9611 .vitem &*def:*&<&'variable&~name'&>
9612 .cindex "expansion" "checking for empty variable"
9613 .cindex "&%def%& expansion condition"
9614 The &%def%& condition must be followed by the name of one of the expansion
9615 variables defined in section &<<SECTexpvar>>&. The condition is true if the
9616 variable does not contain the empty string. For example:
9617 .code
9618 ${if def:sender_ident {from $sender_ident}}
9619 .endd
9620 Note that the variable name is given without a leading &%$%& character. If the
9621 variable does not exist, the expansion fails.
9622
9623 .vitem "&*def:header_*&<&'header&~name'&>&*:*&&~&~or&~&&&
9624         &~&*def:h_*&<&'header&~name'&>&*:*&"
9625 .cindex "expansion" "checking header line existence"
9626 This condition is true if a message is being processed and the named header
9627 exists in the message. For example,
9628 .code
9629 ${if def:header_reply-to:{$h_reply-to:}{$h_from:}}
9630 .endd
9631 &*Note*&: No &%$%& appears before &%header_%& or &%h_%& in the condition, and
9632 the header name must be terminated by a colon if white space does not follow.
9633
9634 .vitem &*eq&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9635 .cindex "string" "comparison"
9636 .cindex "expansion" "string comparison"
9637 .cindex "&%eq%& expansion condition"
9638 The two substrings are first expanded. The condition is true if the two
9639 resulting strings are identical, including the case of letters.
9640
9641 .vitem &*eqi&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9642 .cindex "string" "comparison"
9643 .cindex "expansion" "string comparison"
9644 .cindex "&%eqi%& expansion condition"
9645 The two substrings are first expanded. The condition is true if the two
9646 resulting strings are identical when compared in a case-independent way.
9647
9648 .vitem &*exists&~{*&<&'file&~name'&>&*}*&
9649 .cindex "expansion" "file existence test"
9650 .cindex "file" "existence test"
9651 .cindex "&%exists%&, expansion condition"
9652 The substring is first expanded and then interpreted as an absolute path. The
9653 condition is true if the named file (or directory) exists. The existence test
9654 is done by calling the &[stat()]& function. The use of the &%exists%& test in
9655 users' filter files may be locked out by the system administrator.
9656
9657 .vitem &*first_delivery*&
9658 .cindex "delivery" "first"
9659 .cindex "first delivery"
9660 .cindex "expansion" "first delivery test"
9661 .cindex "&%first_delivery%& expansion condition"
9662 This condition, which has no data, is true during a message's first delivery
9663 attempt. It is false during any subsequent delivery attempts.
9664
9665 .vitem &*ge&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9666 .cindex "&%ge%& expansion condition"
9667 See &*gei*&.
9668
9669 .vitem &*gei&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9670 .cindex "string" "comparison"
9671 .cindex "expansion" "string comparison"
9672 .cindex "&%gei%& expansion condition"
9673 The two substrings are first expanded. The condition is true if the first
9674 string is lexically greater than or equal to the second string: for &%ge%& the
9675 comparison includes the case of letters, whereas for &%gei%& the comparison is
9676 case-independent.
9677
9678 .vitem &*gt&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9679 .cindex "&%gt%& expansion condition"
9680 See &*gti*&.
9681
9682 .vitem &*gti&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9683 .cindex "string" "comparison"
9684 .cindex "expansion" "string comparison"
9685 .cindex "&%gti%& expansion condition"
9686 The two substrings are first expanded. The condition is true if the first
9687 string is lexically greater than the second string: for &%gt%& the comparison
9688 includes the case of letters, whereas for &%gti%& the comparison is
9689 case-independent.
9690
9691 .vitem &*isip&~{*&<&'string'&>&*}*&
9692 .cindex "&%isip%& expansion condition"
9693 See &*isip6*&.
9694
9695 .vitem &*isip4&~{*&<&'string'&>&*}*&
9696 .cindex "&%isip4%& expansion condition"
9697 See &*isip6*&.
9698
9699 .vitem &*isip6&~{*&<&'string'&>&*}*&
9700 .cindex "IP address" "testing string format"
9701 .cindex "string" "testing for IP address"
9702 .cindex "&%isip6%& expansion condition"
9703 The substring is first expanded, and then tested to see if it has the form of
9704 an IP address. Both IPv4 and IPv6 addresses are valid for &%isip%&, whereas
9705 &%isip4%& and &%isip6%& test just for IPv4 or IPv6 addresses, respectively. For
9706 example, you could use
9707 .code
9708 ${if isip4{$sender_host_address}...
9709 .endd
9710 to test which version of IP an incoming SMTP connection is using.
9711
9712
9713 .vitem &*ldapauth&~{*&<&'ldap&~query'&>&*}*&
9714 .cindex "LDAP" "use for authentication"
9715 .cindex "expansion" "LDAP authentication test"
9716 .cindex "&%ldapauth%& expansion condition"
9717 This condition supports user authentication using LDAP. See section
9718 &<<SECTldap>>& for details of how to use LDAP in lookups and the syntax of
9719 queries. For this use, the query must contain a user name and password. The
9720 query itself is not used, and can be empty. The condition is true if the
9721 password is not empty, and the user name and password are accepted by the LDAP
9722 server. An empty password is rejected without calling LDAP because LDAP binds
9723 with an empty password are considered anonymous regardless of the username, and
9724 will succeed in most configurations. See chapter &<<CHAPSMTPAUTH>>& for details
9725 of SMTP authentication, and chapter &<<CHAPplaintext>>& for an example of how
9726 this can be used.
9727
9728
9729 .vitem &*le&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9730 .cindex "&%le%& expansion condition"
9731 See &*lei*&.
9732
9733 .vitem &*lei&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9734 .cindex "string" "comparison"
9735 .cindex "expansion" "string comparison"
9736 .cindex "&%lei%& expansion condition"
9737 The two substrings are first expanded. The condition is true if the first
9738 string is lexically less than or equal to the second string: for &%le%& the
9739 comparison includes the case of letters, whereas for &%lei%& the comparison is
9740 case-independent.
9741
9742 .vitem &*lt&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9743 .cindex "&%lt%& expansion condition"
9744 See &*lti*&.
9745
9746 .vitem &*lti&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9747 .cindex "string" "comparison"
9748 .cindex "expansion" "string comparison"
9749 .cindex "&%lti%& expansion condition"
9750 The two substrings are first expanded. The condition is true if the first
9751 string is lexically less than the second string: for &%lt%& the comparison
9752 includes the case of letters, whereas for &%lti%& the comparison is
9753 case-independent.
9754
9755
9756 .vitem &*match&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9757 .cindex "expansion" "regular expression comparison"
9758 .cindex "regular expressions" "match in expanded string"
9759 .cindex "&%match%&, expansion condition"
9760 The two substrings are first expanded. The second is then treated as a regular
9761 expression and applied to the first. Because of the pre-expansion, if the
9762 regular expression contains dollar, or backslash characters, they must be
9763 escaped. Care must also be taken if the regular expression contains braces
9764 (curly brackets). A closing brace must be escaped so that it is not taken as a
9765 premature termination of <&'string2'&>. The easiest approach is to use the
9766 &`\N`& feature to disable expansion of the regular expression.
9767 For example,
9768 .code
9769 ${if match {$local_part}{\N^\d{3}\N} ...
9770 .endd
9771 If the whole expansion string is in double quotes, further escaping of
9772 backslashes is also required.
9773
9774 The condition is true if the regular expression match succeeds.
9775 The regular expression is not required to begin with a circumflex
9776 metacharacter, but if there is no circumflex, the expression is not anchored,
9777 and it may match anywhere in the subject, not just at the start. If you want
9778 the pattern to match at the end of the subject, you must include the &`$`&
9779 metacharacter at an appropriate point.
9780
9781 .cindex "numerical variables (&$1$& &$2$& etc)" "in &%if%& expansion"
9782 At the start of an &%if%& expansion the values of the numeric variable
9783 substitutions &$1$& etc. are remembered. Obeying a &%match%& condition that
9784 succeeds causes them to be reset to the substrings of that condition and they
9785 will have these values during the expansion of the success string. At the end
9786 of the &%if%& expansion, the previous values are restored. After testing a
9787 combination of conditions using &%or%&, the subsequent values of the numeric
9788 variables are those of the condition that succeeded.
9789
9790 .vitem &*match_address&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9791 .cindex "&%match_address%& expansion condition"
9792 See &*match_local_part*&.
9793
9794 .vitem &*match_domain&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9795 .cindex "&%match_domain%& expansion condition"
9796 See &*match_local_part*&.
9797
9798 .vitem &*match_ip&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9799 .cindex "&%match_ip%& expansion condition"
9800 This condition matches an IP address to a list of IP address patterns. It must
9801 be followed by two argument strings. The first (after expansion) must be an IP
9802 address or an empty string. The second (after expansion) is a restricted host
9803 list that can match only an IP address, not a host name. For example:
9804 .code
9805 ${if match_ip{$sender_host_address}{1.2.3.4:5.6.7.8}{...}{...}}
9806 .endd
9807 The specific types of host list item that are permitted in the list are:
9808
9809 .ilist
9810 An IP address, optionally with a CIDR mask.
9811 .next
9812 A single asterisk, which matches any IP address.
9813 .next
9814 An empty item, which matches only if the IP address is empty. This could be
9815 useful for testing for a locally submitted message or one from specific hosts
9816 in a single test such as
9817 . ==== As this is a nested list, any displays it contains must be indented
9818 . ==== as otherwise they are too far to the left.
9819 .code
9820   ${if match_ip{$sender_host_address}{:4.3.2.1:...}{...}{...}}
9821 .endd
9822 where the first item in the list is the empty string.
9823 .next
9824 The item @[] matches any of the local host's interface addresses.
9825 .next
9826 Lookups are assumed to be &"net-"& style lookups, even if &`net-`& is not
9827 specified. Thus, the following are equivalent:
9828 .code
9829   ${if match_ip{$sender_host_address}{lsearch;/some/file}...
9830   ${if match_ip{$sender_host_address}{net-lsearch;/some/file}...
9831 .endd
9832 You do need to specify the &`net-`& prefix if you want to specify a
9833 specific address mask, for example, by using &`net24-`&. However, unless you
9834 are combining a &%match_ip%& condition with others, it is usually neater to use
9835 an expansion lookup such as:
9836 .code
9837   ${lookup{${mask:$sender_host_address/24}}lsearch{/some/file}...
9838 .endd
9839 .endlist ilist
9840
9841 Consult section &<<SECThoslispatip>>& for further details of these patterns.
9842
9843 .vitem &*match_local_part&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
9844 .cindex "domain list" "in expansion condition"
9845 .cindex "address list" "in expansion condition"
9846 .cindex "local part list" "in expansion condition"
9847 .cindex "&%match_local_part%& expansion condition"
9848 This condition, together with &%match_address%& and &%match_domain%&, make it
9849 possible to test domain, address, and local part lists within expansions. Each
9850 condition requires two arguments: an item and a list to match. A trivial
9851 example is:
9852 .code
9853 ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
9854 .endd
9855 In each case, the second argument may contain any of the allowable items for a
9856 list of the appropriate type. Also, because the second argument (after
9857 expansion) is a standard form of list, it is possible to refer to a named list.
9858 Thus, you can use conditions like this:
9859 .code
9860 ${if match_domain{$domain}{+local_domains}{...
9861 .endd
9862 .cindex "&`+caseful`&"
9863 For address lists, the matching starts off caselessly, but the &`+caseful`&
9864 item can be used, as in all address lists, to cause subsequent items to
9865 have their local parts matched casefully. Domains are always matched
9866 caselessly.
9867
9868 &*Note*&: Host lists are &'not'& supported in this way. This is because
9869 hosts have two identities: a name and an IP address, and it is not clear
9870 how to specify cleanly how such a test would work. However, IP addresses can be
9871 matched using &%match_ip%&.
9872
9873 .vitem &*pam&~{*&<&'string1'&>&*:*&<&'string2'&>&*:...}*&
9874 .cindex "PAM authentication"
9875 .cindex "AUTH" "with PAM"
9876 .cindex "Solaris" "PAM support"
9877 .cindex "expansion" "PAM authentication test"
9878 .cindex "&%pam%& expansion condition"
9879 &'Pluggable Authentication Modules'&
9880 (&url(http://www.kernel.org/pub/linux/libs/pam/)) are a facility that is
9881 available in the latest releases of Solaris and in some GNU/Linux
9882 distributions. The Exim support, which is intended for use in conjunction with
9883 the SMTP AUTH command, is available only if Exim is compiled with
9884 .code
9885 SUPPORT_PAM=yes
9886 .endd
9887 in &_Local/Makefile_&. You probably need to add &%-lpam%& to EXTRALIBS, and
9888 in some releases of GNU/Linux &%-ldl%& is also needed.
9889
9890 The argument string is first expanded, and the result must be a
9891 colon-separated list of strings. Leading and trailing white space is ignored.
9892 The PAM module is initialized with the service name &"exim"& and the user name
9893 taken from the first item in the colon-separated data string (<&'string1'&>).
9894 The remaining items in the data string are passed over in response to requests
9895 from the authentication function. In the simple case there will only be one
9896 request, for a password, so the data consists of just two strings.
9897
9898 There can be problems if any of the strings are permitted to contain colon
9899 characters. In the usual way, these have to be doubled to avoid being taken as
9900 separators. If the data is being inserted from a variable, the &%sg%& expansion
9901 item can be used to double any existing colons. For example, the configuration
9902 of a LOGIN authenticator might contain this setting:
9903 .code
9904 server_condition = ${if pam{$auth1:${sg{$auth2}{:}{::}}}}
9905 .endd
9906 For a PLAIN authenticator you could use:
9907 .code
9908 server_condition = ${if pam{$auth2:${sg{$auth3}{:}{::}}}}
9909 .endd
9910 In some operating systems, PAM authentication can be done only from a process
9911 running as root. Since Exim is running as the Exim user when receiving
9912 messages, this means that PAM cannot be used directly in those systems.
9913 A patched version of the &'pam_unix'& module that comes with the
9914 Linux PAM package is available from &url(http://www.e-admin.de/pam_exim/).
9915 The patched module allows one special uid/gid combination, in addition to root,
9916 to authenticate. If you build the patched module to allow the Exim user and
9917 group, PAM can then be used from an Exim authenticator.
9918
9919
9920 .vitem &*pwcheck&~{*&<&'string1'&>&*:*&<&'string2'&>&*}*&
9921 .cindex "&'pwcheck'& daemon"
9922 .cindex "Cyrus"
9923 .cindex "expansion" "&'pwcheck'& authentication test"
9924 .cindex "&%pwcheck%& expansion condition"
9925 This condition supports user authentication using the Cyrus &'pwcheck'& daemon.
9926 This is one way of making it possible for passwords to be checked by a process
9927 that is not running as root. &*Note*&: The use of &'pwcheck'& is now
9928 deprecated. Its replacement is &'saslauthd'& (see below).
9929
9930 The pwcheck support is not included in Exim by default. You need to specify
9931 the location of the pwcheck daemon's socket in &_Local/Makefile_& before
9932 building Exim. For example:
9933 .code
9934 CYRUS_PWCHECK_SOCKET=/var/pwcheck/pwcheck
9935 .endd
9936 You do not need to install the full Cyrus software suite in order to use
9937 the pwcheck daemon. You can compile and install just the daemon alone
9938 from the Cyrus SASL library. Ensure that &'exim'& is the only user that has
9939 access to the &_/var/pwcheck_& directory.
9940
9941 The &%pwcheck%& condition takes one argument, which must be the user name and
9942 password, separated by a colon. For example, in a LOGIN authenticator
9943 configuration, you might have this:
9944 .code
9945 server_condition = ${if pwcheck{$auth1:$auth2}}
9946 .endd
9947 .vitem &*queue_running*&
9948 .cindex "queue runner" "detecting when delivering from"
9949 .cindex "expansion" "queue runner test"
9950 .cindex "&%queue_runnint%& expansion condition"
9951 This condition, which has no data, is true during delivery attempts that are
9952 initiated by queue runner processes, and false otherwise.
9953
9954
9955 .vitem &*radius&~{*&<&'authentication&~string'&>&*}*&
9956 .cindex "Radius"
9957 .cindex "expansion" "Radius authentication"
9958 .cindex "&%radius%& expansion condition"
9959 Radius authentication (RFC 2865) is supported in a similar way to PAM. You must
9960 set RADIUS_CONFIG_FILE in &_Local/Makefile_& to specify the location of
9961 the Radius client configuration file in order to build Exim with Radius
9962 support.
9963
9964 With just that one setting, Exim expects to be linked with the &%radiusclient%&
9965 library, using the original API. If you are using release 0.4.0 or later of
9966 this library, you need to set
9967 .code
9968 RADIUS_LIB_TYPE=RADIUSCLIENTNEW
9969 .endd
9970 in &_Local/Makefile_& when building Exim. You can also link Exim with the
9971 &%libradius%& library that comes with FreeBSD. To do this, set
9972 .code
9973 RADIUS_LIB_TYPE=RADLIB
9974 .endd
9975 in &_Local/Makefile_&, in addition to setting RADIUS_CONFIGURE_FILE.
9976 You may also have to supply a suitable setting in EXTRALIBS so that the
9977 Radius library can be found when Exim is linked.
9978
9979 The string specified by RADIUS_CONFIG_FILE is expanded and passed to the
9980 Radius client library, which calls the Radius server. The condition is true if
9981 the authentication is successful. For example:
9982 .code
9983 server_condition = ${if radius{<arguments>}}
9984 .endd
9985
9986
9987 .vitem "&*saslauthd&~{{*&<&'user'&>&*}{*&<&'password'&>&*}&&&
9988         {*&<&'service'&>&*}{*&<&'realm'&>&*}}*&"
9989 .cindex "&'saslauthd'& daemon"
9990 .cindex "Cyrus"
9991 .cindex "expansion" "&'saslauthd'& authentication test"
9992 .cindex "&%saslauthd%& expansion condition"
9993 This condition supports user authentication using the Cyrus &'saslauthd'&
9994 daemon. This replaces the older &'pwcheck'& daemon, which is now deprecated.
9995 Using this daemon is one way of making it possible for passwords to be checked
9996 by a process that is not running as root.
9997
9998 The saslauthd support is not included in Exim by default. You need to specify
9999 the location of the saslauthd daemon's socket in &_Local/Makefile_& before
10000 building Exim. For example:
10001 .code
10002 CYRUS_SASLAUTHD_SOCKET=/var/state/saslauthd/mux
10003 .endd
10004 You do not need to install the full Cyrus software suite in order to use
10005 the saslauthd daemon. You can compile and install just the daemon alone
10006 from the Cyrus SASL library.
10007
10008 Up to four arguments can be supplied to the &%saslauthd%& condition, but only
10009 two are mandatory. For example:
10010 .code
10011 server_condition = ${if saslauthd{{$auth1}{$auth2}}}
10012 .endd
10013 The service and the realm are optional (which is why the arguments are enclosed
10014 in their own set of braces). For details of the meaning of the service and
10015 realm, and how to run the daemon, consult the Cyrus documentation.
10016 .endlist vlist
10017
10018
10019
10020 .section "Combining expansion conditions"
10021 .cindex "expansion" "combining conditions"
10022 Several conditions can be tested at once by combining them using the &%and%&
10023 and &%or%& combination conditions. Note that &%and%& and &%or%& are complete
10024 conditions on their own, and precede their lists of sub-conditions. Each
10025 sub-condition must be enclosed in braces within the overall braces that contain
10026 the list. No repetition of &%if%& is used.
10027
10028
10029 .vlist
10030 .vitem &*or&~{{*&<&'cond1'&>&*}{*&<&'cond2'&>&*}...}*&
10031 .cindex "&""or""& expansion condition"
10032 .cindex "expansion" "&""or""& of conditions"
10033 The sub-conditions are evaluated from left to right. The condition is true if
10034 any one of the sub-conditions is true.
10035 For example,
10036 .code
10037 ${if or {{eq{$local_part}{spqr}}{eq{$domain}{testing.com}}}...
10038 .endd
10039 When a true sub-condition is found, the following ones are parsed but not
10040 evaluated. If there are several &"match"& sub-conditions the values of the
10041 numeric variables afterwards are taken from the first one that succeeds.
10042
10043 .vitem &*and&~{{*&<&'cond1'&>&*}{*&<&'cond2'&>&*}...}*&
10044 .cindex "&""and""& expansion condition"
10045 .cindex "expansion" "&""and""& of conditions"
10046 The sub-conditions are evaluated from left to right. The condition is true if
10047 all of the sub-conditions are true. If there are several &"match"&
10048 sub-conditions, the values of the numeric variables afterwards are taken from
10049 the last one. When a false sub-condition is found, the following ones are
10050 parsed but not evaluated.
10051 .endlist
10052 .ecindex IIDexpcond
10053
10054
10055
10056
10057 .section "Expansion variables" "SECTexpvar"
10058 .cindex "expansion variables" "list of"
10059 This section contains an alphabetical list of all the expansion variables. Some
10060 of them are available only when Exim is compiled with specific options such as
10061 support for TLS or the content scanning extension.
10062
10063 .vlist
10064 .vitem "&$0$&, &$1$&, etc"
10065 .cindex "numerical variables (&$1$& &$2$& etc)"
10066 When a &%match%& expansion condition succeeds, these variables contain the
10067 captured substrings identified by the regular expression during subsequent
10068 processing of the success string of the containing &%if%& expansion item. They
10069 may also be set externally by some other matching process which precedes the
10070 expansion of the string. For example, the commands available in Exim filter
10071 files include an &%if%& command with its own regular expression matching
10072 condition.
10073
10074 .vitem "&$acl_c0$& &-- &$acl_c19$&"
10075 Values can be placed in these variables by the &%set%& modifier in an ACL. The
10076 values persist throughout the lifetime of an SMTP connection. They can be used
10077 to pass information between ACLs and between different invocations of the same
10078 ACL. When a message is received, the values of these variables are saved with
10079 the message, and can be accessed by filters, routers, and transports during
10080 subsequent delivery.
10081
10082 .vitem "&$acl_m0$& &-- &$acl_m19$&"
10083 Values can be placed in these variables by the &%set%& modifier in an ACL. They
10084 retain their values while a message is being received, but are reset
10085 afterwards. They are also reset by MAIL, RSET, EHLO, HELO, and after starting a
10086 TLS session. When a message is received, the values of these variables are
10087 saved with the message, and can be accessed by filters, routers, and transports
10088 during subsequent delivery.
10089
10090 .vitem &$acl_verify_message$&
10091 .cindex "&$acl_verify_message$&"
10092 After an address verification has failed, this variable contains the failure
10093 message. It retains its value for use in subsequent modifiers. The message can
10094 be preserved by coding like this:
10095 .code
10096 warn !verify = sender
10097      set acl_m0 = $acl_verify_message
10098 .endd
10099 You can use &$acl_verify_message$& during the expansion of the &%message%& or
10100 &%log_message%& modifiers, to include information about the verification
10101 failure.
10102
10103 .vitem &$address_data$&
10104 .cindex "&$address_data$&"
10105 This variable is set by means of the &%address_data%& option in routers. The
10106 value then remains with the address while it is processed by subsequent routers
10107 and eventually a transport. If the transport is handling multiple addresses,
10108 the value from the first address is used. See chapter &<<CHAProutergeneric>>&
10109 for more details. &*Note*&: The contents of &$address_data$& are visible in
10110 user filter files.
10111
10112 If &$address_data$& is set when the routers are called from an ACL to verify
10113 a recipient address, the final value is still in the variable for subsequent
10114 conditions and modifiers of the ACL statement. If routing the address caused it
10115 to be redirected to just one address, the child address is also routed as part
10116 of the verification, and in this case the final value of &$address_data$& is
10117 from the child's routing.
10118
10119 If &$address_data$& is set when the routers are called from an ACL to verify a
10120 sender address, the final value is also preserved, but this time in
10121 &$sender_address_data$&, to distinguish it from data from a recipient
10122 address.
10123
10124 In both cases (recipient and sender verification), the value does not persist
10125 after the end of the current ACL statement. If you want to preserve
10126 these values for longer, you can save them in ACL variables.
10127
10128 .vitem &$address_file$&
10129 .cindex "&$address_file$&"
10130 When, as a result of aliasing, forwarding, or filtering, a message is directed
10131 to a specific file, this variable holds the name of the file when the transport
10132 is running. At other times, the variable is empty. For example, using the
10133 default configuration, if user &%r2d2%& has a &_.forward_& file containing
10134 .code
10135 /home/r2d2/savemail
10136 .endd
10137 then when the &(address_file)& transport is running, &$address_file$&
10138 contains &"/home/r2d2/savemail"&.
10139
10140 .cindex "Sieve filter" "value of &$address_file$&"
10141 For Sieve filters, the value may be &"inbox"& or a relative folder name. It is
10142 then up to the transport configuration to generate an appropriate absolute path
10143 to the relevant file.
10144
10145 .vitem &$address_pipe$&
10146 .cindex "&$address_pipe$&"
10147 When, as a result of aliasing or forwarding, a message is directed to a pipe,
10148 this variable holds the pipe command when the transport is running.
10149
10150 .vitem "&$auth1$& &-- &$auth3$&"
10151 .cindex "&$auth1$&, &$auth2$&, etc"
10152 These variables are used in SMTP authenticators (see chapters
10153 &<<CHAPplaintext>>&&--&<<CHAPspa>>&). Elsewhere, they are empty.
10154
10155 .vitem &$authenticated_id$&
10156 .cindex "authentication" "id"
10157 .cindex "&$authenticated_id$&"
10158 When a server successfully authenticates a client it may be configured to
10159 preserve some of the authentication information in the variable
10160 &$authenticated_id$& (see chapter &<<CHAPSMTPAUTH>>&). For example, a
10161 user/password authenticator configuration might preserve the user name for use
10162 in the routers. Note that this is not the same information that is saved in
10163 &$sender_host_authenticated$&.
10164 When a message is submitted locally (that is, not over a TCP connection)
10165 the value of &$authenticated_id$& is normally the login name of the calling
10166 process. However, a trusted user can override this by means of the &%-oMai%&
10167 command line option.
10168
10169
10170
10171
10172 .vitem &$authenticated_sender$&
10173 .cindex "sender" "authenticated"
10174 .cindex "authentication" "sender"
10175 .cindex "AUTH" "on MAIL command"
10176 .cindex "&$authenticated_sender$&"
10177 When acting as a server, Exim takes note of the AUTH= parameter on an incoming
10178 SMTP MAIL command if it believes the sender is sufficiently trusted, as
10179 described in section &<<SECTauthparamail>>&. Unless the data is the string
10180 &"<>"&, it is set as the authenticated sender of the message, and the value is
10181 available during delivery in the &$authenticated_sender$& variable. If the
10182 sender is not trusted, Exim accepts the syntax of AUTH=, but ignores the data.
10183
10184 .cindex "&$qualify_domain$&"
10185 When a message is submitted locally (that is, not over a TCP connection), the
10186 value of &$authenticated_sender$& is an address constructed from the login
10187 name of the calling process and &$qualify_domain$&, except that a trusted user
10188 can override this by means of the &%-oMas%& command line option.
10189
10190
10191 .vitem &$authentication_failed$&
10192 .cindex "authentication" "failure"
10193 .cindex "&$authentication_failed$&"
10194 This variable is set to &"1"& in an Exim server if a client issues an AUTH
10195 command that does not succeed. Otherwise it is set to &"0"&. This makes it
10196 possible to distinguish between &"did not try to authenticate"&
10197 (&$sender_host_authenticated$& is empty and &$authentication_failed$& is set to
10198 &"0"&) and &"tried to authenticate but failed"& (&$sender_host_authenticated$&
10199 is empty and &$authentication_failed$& is set to &"1"&). Failure includes any
10200 negative response to an AUTH command, including (for example) an attempt to use
10201 an undefined mechanism.
10202
10203 .vitem &$body_linecount$&
10204 .cindex "message body" "line count"
10205 .cindex "body of message" "line count"
10206 .cindex "&$body_linecount$&"
10207 When a message is being received or delivered, this variable contains the
10208 number of lines in the message's body. See also &$message_linecount$&.
10209
10210 .vitem &$body_zerocount$&
10211 .cindex "message body" "binary zero count"
10212 .cindex "body of message" "binary zero count"
10213 .cindex "binary zero" "in message body"
10214 .cindex "&$body_zerocount$&"
10215 When a message is being received or delivered, this variable contains the
10216 number of binary zero bytes in the message's body.
10217
10218 .vitem &$bounce_recipient$&
10219 .cindex "&$bounce_recipient$&"
10220 This is set to the recipient address of a bounce message while Exim is creating
10221 it. It is useful if a customized bounce message text file is in use (see
10222 chapter &<<CHAPemsgcust>>&).
10223
10224 .vitem &$bounce_return_size_limit$&
10225 .cindex "&$bounce_return_size_limit$&"
10226 This contains the value set in the &%bounce_return_size_limit%& option, rounded
10227 up to a multiple of 1000. It is useful when a customized error message text
10228 file is in use (see chapter &<<CHAPemsgcust>>&).
10229
10230 .vitem &$caller_gid$&
10231 .cindex "gid (group id)" "caller"
10232 .cindex "&$caller_gid$&"
10233 The real group id under which the process that called Exim was running. This is
10234 not the same as the group id of the originator of a message (see
10235 &$originator_gid$&). If Exim re-execs itself, this variable in the new
10236 incarnation normally contains the Exim gid.
10237
10238 .vitem &$caller_uid$&
10239 .cindex "uid (user id)" "caller"
10240 .cindex "&$caller_uid$&"
10241 The real user id under which the process that called Exim was running. This is
10242 not the same as the user id of the originator of a message (see
10243 &$originator_uid$&). If Exim re-execs itself, this variable in the new
10244 incarnation normally contains the Exim uid.
10245
10246 .vitem &$compile_date$&
10247 .cindex "&$compile_date$&"
10248 The date on which the Exim binary was compiled.
10249
10250 .vitem &$compile_number$&
10251 .cindex "&$compile_number$&"
10252 The building process for Exim keeps a count of the number
10253 of times it has been compiled. This serves to distinguish different
10254 compilations of the same version of the program.
10255
10256 .vitem &$demime_errorlevel$&
10257 .cindex "&$demime_errorlevel$&"
10258 This variable is available when Exim is compiled with
10259 the content-scanning extension and the obsolete &%demime%& condition. For
10260 details, see section &<<SECTdemimecond>>&.
10261
10262 .vitem &$demime_reason$&
10263 .cindex "&$demime_reason$&"
10264 This variable is available when Exim is compiled with the
10265 content-scanning extension and the obsolete &%demime%& condition. For details,
10266 see section &<<SECTdemimecond>>&.
10267
10268
10269 .vitem &$dnslist_domain$&
10270 .cindex "black list (DNS)"
10271 .cindex "&$dnslist_domain$&"
10272 When a client host is found to be on a DNS (black) list,
10273 the list's domain name is put into this variable so that it can be included in
10274 the rejection message.
10275
10276 .vitem &$dnslist_text$&
10277 .cindex "&$dnslist_text$&"
10278 When a client host is found to be on a DNS (black) list, the
10279 contents of any associated TXT record are placed in this variable.
10280
10281 .vitem &$dnslist_value$&
10282 .cindex "&$dnslist_value$&"
10283 When a client host is found to be on a DNS (black) list,
10284 the IP address from the resource record is placed in this variable.
10285 If there are multiple records, all the addresses are included, comma-space
10286 separated.
10287
10288 .vitem &$domain$&
10289 .new
10290 .cindex "&$domain$&"
10291 When an address is being routed, or delivered on its own, this variable
10292 contains the domain. Uppercase letters in the domain are converted into lower
10293 case for &$domain$&.
10294 .wen
10295
10296 Global address rewriting happens when a message is received, so the value of
10297 &$domain$& during routing and delivery is the value after rewriting. &$domain$&
10298 is set during user filtering, but not during system filtering, because a
10299 message may have many recipients and the system filter is called just once.
10300
10301 When more than one address is being delivered at once (for example, several
10302 RCPT commands in one SMTP delivery), &$domain$& is set only if they all
10303 have the same domain. Transports can be restricted to handling only one domain
10304 at a time if the value of &$domain$& is required at transport time &-- this is
10305 the default for local transports. For further details of the environment in
10306 which local transports are run, see chapter &<<CHAPenvironment>>&.
10307
10308 .cindex "&%delay_warning_condition%&"
10309 At the end of a delivery, if all deferred addresses have the same domain, it is
10310 set in &$domain$& during the expansion of &%delay_warning_condition%&.
10311
10312 The &$domain$& variable is also used in some other circumstances:
10313
10314 .ilist
10315 When an ACL is running for a RCPT command, &$domain$& contains the domain of
10316 the recipient address. The domain of the &'sender'& address is in
10317 &$sender_address_domain$& at both MAIL time and at RCPT time. &$domain$& is not
10318 normally set during the running of the MAIL ACL. However, if the sender address
10319 is verified with a callout during the MAIL ACL, the sender domain is placed in
10320 &$domain$& during the expansions of &%hosts%&, &%interface%&, and &%port%& in
10321 the &(smtp)& transport.
10322
10323 .next
10324 When a rewrite item is being processed (see chapter &<<CHAPrewrite>>&),
10325 &$domain$& contains the domain portion of the address that is being rewritten;
10326 it can be used in the expansion of the replacement address, for example, to
10327 rewrite domains by file lookup.
10328
10329 .next
10330 With one important exception, whenever a domain list is being scanned,
10331 &$domain$& contains the subject domain. &*Exception*&: When a domain list in
10332 a &%sender_domains%& condition in an ACL is being processed, the subject domain
10333 is in &$sender_address_domain$& and not in &$domain$&. It works this way so
10334 that, in a RCPT ACL, the sender domain list can be dependent on the
10335 recipient domain (which is what is in &$domain$& at this time).
10336
10337 .next
10338 .cindex "ETRN" "value of &$domain$&"
10339 .cindex "&%smtp_etrn_command%&"
10340 When the &%smtp_etrn_command%& option is being expanded, &$domain$& contains
10341 the complete argument of the ETRN command (see section &<<SECTETRN>>&).
10342 .endlist
10343
10344
10345 .vitem &$domain_data$&
10346 .cindex "&$domain_data$&"
10347 When the &%domains%& option on a router matches a domain by
10348 means of a lookup, the data read by the lookup is available during the running
10349 of the router as &$domain_data$&. In addition, if the driver routes the
10350 address to a transport, the value is available in that transport. If the
10351 transport is handling multiple addresses, the value from the first address is
10352 used.
10353
10354 &$domain_data$& is also set when the &%domains%& condition in an ACL matches a
10355 domain by means of a lookup. The data read by the lookup is available during
10356 the rest of the ACL statement. In all other situations, this variable expands
10357 to nothing.
10358
10359 .vitem &$exim_gid$&
10360 .cindex "&$exim_gid$&"
10361 This variable contains the numerical value of the Exim group id.
10362
10363 .vitem &$exim_path$&
10364 .cindex "&$exim_path$&"
10365 This variable contains the path to the Exim binary.
10366
10367 .vitem &$exim_uid$&
10368 .cindex "&$exim_uid$&"
10369 This variable contains the numerical value of the Exim user id.
10370
10371 .vitem &$found_extension$&
10372 .cindex "&$found_extension$&"
10373 This variable is available when Exim is compiled with the
10374 content-scanning extension and the obsolete &%demime%& condition. For details,
10375 see section &<<SECTdemimecond>>&.
10376
10377 .vitem &$header_$&<&'name'&>
10378 This is not strictly an expansion variable. It is expansion syntax for
10379 inserting the message header line with the given name. Note that the name must
10380 be terminated by colon or white space, because it may contain a wide variety of
10381 characters. Note also that braces must &'not'& be used.
10382
10383 .vitem &$home$&
10384 .cindex "&$home$&"
10385 When the &%check_local_user%& option is set for a router, the user's home
10386 directory is placed in &$home$& when the check succeeds. In particular, this
10387 means it is set during the running of users' filter files. A router may also
10388 explicitly set a home directory for use by a transport; this can be overridden
10389 by a setting on the transport itself.
10390
10391 When running a filter test via the &%-bf%& option, &$home$& is set to the value
10392 of the environment variable HOME.
10393
10394 .vitem &$host$&
10395 .cindex "&$host$&"
10396 If a router assigns an address to a transport (any transport), and passes a
10397 list of hosts with the address, the value of &$host$& when the transport starts
10398 to run is the name of the first host on the list. Note that this applies both
10399 to local and remote transports.
10400
10401 .cindex "transport" "filter"
10402 .cindex "filter" "transport filter"
10403 For the &(smtp)& transport, if there is more than one host, the value of
10404 &$host$& changes as the transport works its way through the list. In
10405 particular, when the &(smtp)& transport is expanding its options for encryption
10406 using TLS, or for specifying a transport filter (see chapter
10407 &<<CHAPtransportgeneric>>&), &$host$& contains the name of the host to which it
10408 is connected.
10409
10410 When used in the client part of an authenticator configuration (see chapter
10411 &<<CHAPSMTPAUTH>>&), &$host$& contains the name of the server to which the
10412 client is connected.
10413
10414
10415 .vitem &$host_address$&
10416 .cindex "&$host_address$&"
10417 This variable is set to the remote host's IP address whenever &$host$& is set
10418 for a remote connection. It is also set to the IP address that is being checked
10419 when the &%ignore_target_hosts%& option is being processed.
10420
10421 .vitem &$host_data$&
10422 .cindex "&$host_data$&"
10423 If a &%hosts%& condition in an ACL is satisfied by means of a lookup, the
10424 result of the lookup is made available in the &$host_data$& variable. This
10425 allows you, for example, to do things like this:
10426 .code
10427 deny  hosts = net-lsearch;/some/file
10428 message = $host_data
10429 .endd
10430 .vitem &$host_lookup_deferred$&
10431 .cindex "host name lookup" "failure of"
10432 .cindex "&$host_lookup_deferred$&"
10433 This variable normally contains &"0"&, as does &$host_lookup_failed$&. When a
10434 message comes from a remote host and there is an attempt to look up the host's
10435 name from its IP address, and the attempt is not successful, one of these
10436 variables is set to &"1"&.
10437
10438 .ilist
10439 If the lookup receives a definite negative response (for example, a DNS lookup
10440 succeeded, but no records were found), &$host_lookup_failed$& is set to &"1"&.
10441
10442 .next
10443 If there is any kind of problem during the lookup, such that Exim cannot
10444 tell whether or not the host name is defined (for example, a timeout for a DNS
10445 lookup), &$host_lookup_deferred$& is set to &"1"&.
10446 .endlist ilist
10447
10448 Looking up a host's name from its IP address consists of more than just a
10449 single reverse lookup. Exim checks that a forward lookup of at least one of the
10450 names it receives from a reverse lookup yields the original IP address. If this
10451 is not the case, Exim does not accept the looked up name(s), and
10452 &$host_lookup_failed$& is set to &"1"&. Thus, being able to find a name from an
10453 IP address (for example, the existence of a PTR record in the DNS) is not
10454 sufficient on its own for the success of a host name lookup. If the reverse
10455 lookup succeeds, but there is a lookup problem such as a timeout when checking
10456 the result, the name is not accepted, and &$host_lookup_deferred$& is set to
10457 &"1"&. See also &$sender_host_name$&.
10458
10459 .vitem &$host_lookup_failed$&
10460 .cindex "&$host_lookup_failed$&"
10461 See &$host_lookup_deferred$&.
10462
10463
10464 .vitem &$inode$&
10465 .cindex "&$inode$&"
10466 The only time this variable is set is while expanding the &%directory_file%&
10467 option in the &(appendfile)& transport. The variable contains the inode number
10468 of the temporary file which is about to be renamed. It can be used to construct
10469 a unique name for the file.
10470
10471 .new
10472 .vitem &$interface_address$&
10473 .cindex "&$interface_address$&"
10474 This is an obsolete name for &$received_ip_address$&.
10475
10476 .vitem &$interface_port$&
10477 .cindex "&$interface_port$&"
10478 This is an obsolete name for &$received_port$&.
10479 .wen
10480
10481 .vitem &$ldap_dn$&
10482 .cindex "&$ldap_dn$&"
10483 This variable, which is available only when Exim is compiled with LDAP support,
10484 contains the DN from the last entry in the most recently successful LDAP
10485 lookup.
10486
10487 .vitem &$load_average$&
10488 .cindex "&$load_average$&"
10489 This variable contains the system load average, multiplied by 1000 to that it
10490 is an integer. For example, if the load average is 0.21, the value of the
10491 variable is 210. The value is recomputed every time the variable is referenced.
10492
10493 .vitem &$local_part$&
10494 .cindex "&$local_part$&"
10495 When an address is being routed, or delivered on its own, this
10496 variable contains the local part. When a number of addresses are being
10497 delivered together (for example, multiple RCPT commands in an SMTP
10498 session), &$local_part$& is not set.
10499
10500 Global address rewriting happens when a message is received, so the value of
10501 &$local_part$& during routing and delivery is the value after rewriting.
10502 &$local_part$& is set during user filtering, but not during system filtering,
10503 because a message may have many recipients and the system filter is called just
10504 once.
10505
10506 .cindex "&$local_part_prefix$&"
10507 .cindex "&$local_part_suffix$&"
10508 If a local part prefix or suffix has been recognized, it is not included in the
10509 value of &$local_part$& during routing and subsequent delivery. The values of
10510 any prefix or suffix are in &$local_part_prefix$& and
10511 &$local_part_suffix$&, respectively.
10512
10513 When a message is being delivered to a file, pipe, or autoreply transport as a
10514 result of aliasing or forwarding, &$local_part$& is set to the local part of
10515 the parent address, not to the file name or command (see &$address_file$& and
10516 &$address_pipe$&).
10517
10518 When an ACL is running for a RCPT command, &$local_part$& contains the
10519 local part of the recipient address.
10520
10521 When a rewrite item is being processed (see chapter &<<CHAPrewrite>>&),
10522 &$local_part$& contains the local part of the address that is being rewritten;
10523 it can be used in the expansion of the replacement address, for example.
10524
10525 In all cases, all quoting is removed from the local part. For example, for both
10526 the addresses
10527 .code
10528 "abc:xyz"@test.example
10529 abc\:xyz@test.example
10530 .endd
10531 the value of &$local_part$& is
10532 .code
10533 abc:xyz
10534 .endd
10535 If you use &$local_part$& to create another address, you should always wrap it
10536 inside a quoting operator. For example, in a &(redirect)& router you could
10537 have:
10538 .code
10539 data = ${quote_local_part:$local_part}@new.domain.example
10540 .endd
10541 &*Note*&: The value of &$local_part$& is normally lower cased. If you want
10542 to process local parts in a case-dependent manner in a router, you can set the
10543 &%caseful_local_part%& option (see chapter &<<CHAProutergeneric>>&).
10544
10545 .vitem &$local_part_data$&
10546 .cindex "&$local_part_data$&"
10547 When the &%local_parts%& option on a router matches a local part by means of a
10548 lookup, the data read by the lookup is available during the running of the
10549 router as &$local_part_data$&. In addition, if the driver routes the address
10550 to a transport, the value is available in that transport. If the transport is
10551 handling multiple addresses, the value from the first address is used.
10552
10553 &$local_part_data$& is also set when the &%local_parts%& condition in an ACL
10554 matches a local part by means of a lookup. The data read by the lookup is
10555 available during the rest of the ACL statement. In all other situations, this
10556 variable expands to nothing.
10557
10558 .vitem &$local_part_prefix$&
10559 .cindex "&$local_part_prefix$&"
10560 When an address is being routed or delivered, and a
10561 specific prefix for the local part was recognized, it is available in this
10562 variable, having been removed from &$local_part$&.
10563
10564 .vitem &$local_part_suffix$&
10565 .cindex "&$local_part_suffix$&"
10566 When an address is being routed or delivered, and a
10567 specific suffix for the local part was recognized, it is available in this
10568 variable, having been removed from &$local_part$&.
10569
10570 .vitem &$local_scan_data$&
10571 .cindex "&$local_scan_data$&"
10572 This variable contains the text returned by the &[local_scan()]& function when
10573 a message is received. See chapter &<<CHAPlocalscan>>& for more details.
10574
10575 .vitem &$local_user_gid$&
10576 .cindex "&$local_user_gid$&"
10577 See &$local_user_uid$&.
10578
10579 .vitem &$local_user_uid$&
10580 .cindex "&$local_user_uid$&"
10581 This variable and &$local_user_gid$& are set to the uid and gid after the
10582 &%check_local_user%& router precondition succeeds. This means that their values
10583 are available for the remaining preconditions (&%senders%&, &%require_files%&,
10584 and &%condition%&), for the &%address_data%& expansion, and for any
10585 router-specific expansions. At all other times, the values in these variables
10586 are &`(uid_t)(-1)`& and &`(gid_t)(-1)`&, respectively.
10587
10588 .vitem &$localhost_number$&
10589 .cindex "&$localhost_number$&"
10590 This contains the expanded value of the
10591 &%localhost_number%& option. The expansion happens after the main options have
10592 been read.
10593
10594 .vitem &$log_inodes$&
10595 .cindex "&$log_inodes$&"
10596 The number of free inodes in the disk partition where Exim's
10597 log files are being written. The value is recalculated whenever the variable is
10598 referenced. If the relevant file system does not have the concept of inodes,
10599 the value of is -1. See also the &%check_log_inodes%& option.
10600
10601 .vitem &$log_space$&
10602 .cindex "&$log_space$&"
10603 The amount of free space (as a number of kilobytes) in the disk
10604 partition where Exim's log files are being written. The value is recalculated
10605 whenever the variable is referenced. If the operating system does not have the
10606 ability to find the amount of free space (only true for experimental systems),
10607 the space value is -1. See also the &%check_log_space%& option.
10608
10609
10610 .vitem &$mailstore_basename$&
10611 .cindex "&$mailstore_basename$&"
10612 This variable is set only when doing deliveries in &"mailstore"& format in the
10613 &(appendfile)& transport. During the expansion of the &%mailstore_prefix%&,
10614 &%mailstore_suffix%&, &%message_prefix%&, and &%message_suffix%& options, it
10615 contains the basename of the files that are being written, that is, the name
10616 without the &".tmp"&, &".env"&, or &".msg"& suffix. At all other times, this
10617 variable is empty.
10618
10619 .vitem &$malware_name$&
10620 .cindex "&$malware_name$&"
10621 This variable is available when Exim is compiled with the
10622 content-scanning extension. It is set to the name of the virus that was found
10623 when the ACL &%malware%& condition is true (see section &<<SECTscanvirus>>&).
10624
10625
10626 .vitem &$message_age$&
10627 .cindex "message" "age of"
10628 .cindex "&$message_age$&"
10629 This variable is set at the start of a delivery attempt to contain the number
10630 of seconds since the message was received. It does not change during a single
10631 delivery attempt.
10632
10633 .vitem &$message_body$&
10634 .cindex "body of message" "expansion variable"
10635 .cindex "message body" "in expansion"
10636 .cindex "binary zero" "in message body"
10637 .cindex "&$message_body$&"
10638 This variable contains the initial portion of a message's
10639 body while it is being delivered, and is intended mainly for use in filter
10640 files. The maximum number of characters of the body that are put into the
10641 variable is set by the &%message_body_visible%& configuration option; the
10642 default is 500. Newlines are converted into spaces to make it easier to search
10643 for phrases that might be split over a line break.
10644 Binary zeros are also converted into spaces.
10645
10646 .vitem &$message_body_end$&
10647 .cindex "body of message" "expansion variable"
10648 .cindex "message body" "in expansion"
10649 .cindex "&$message_body_end$&"
10650 This variable contains the final portion of a message's
10651 body while it is being delivered. The format and maximum size are as for
10652 &$message_body$&.
10653
10654 .vitem &$message_body_size$&
10655 .cindex "body of message" "size"
10656 .cindex "message body" "size"
10657 .cindex "&$message_body_size$&"
10658 When a message is being delivered, this variable contains the size of the body
10659 in bytes. The count starts from the character after the blank line that
10660 separates the body from the header. Newlines are included in the count. See
10661 also &$message_size$&, &$body_linecount$&, and &$body_zerocount$&.
10662
10663 .vitem &$message_exim_id$&
10664 .cindex "&$message_exim_id$&"
10665 When a message is being received or delivered, this variable contains the
10666 unique message id that is generated and used by Exim to identify the message.
10667 An id is not created for a message until after its header has been successfully
10668 received. &*Note*&: This is &'not'& the contents of the &'Message-ID:'& header
10669 line; it is the local id that Exim assigns to the message, for example:
10670 &`1BXTIK-0001yO-VA`&.
10671
10672 .vitem &$message_headers$&
10673 .new
10674 .cindex &$message_headers$&
10675 This variable contains a concatenation of all the header lines when a message
10676 is being processed, except for lines added by routers or transports. The header
10677 lines are separated by newline characters. Their contents are decoded in the
10678 same way as a header line that is inserted by &%bheader%&.
10679
10680 .vitem &$message_headers_raw$&
10681 .cindex &$message_headers_raw$&
10682 This variable is like &$message_headers$& except that no processing of the
10683 contents of header lines is done.
10684 .wen
10685
10686 .vitem &$message_id$&
10687 This is an old name for &$message_exim_id$&, which is now deprecated.
10688
10689 .vitem &$message_linecount$&
10690 .cindex "&$message_linecount$&"
10691 This variable contains the total number of lines in the header and body of the
10692 message. Compare &$body_linecount$&, which is the count for the body only.
10693 During the DATA and content-scanning ACLs, &$message_linecount$& contains the
10694 number of lines received. Before delivery happens (that is, before filters,
10695 routers, and transports run) the count is increased to include the
10696 &'Received:'& header line that Exim standardly adds, and also any other header
10697 lines that are added by ACLs. The blank line that separates the message header
10698 from the body is not counted. Here is an example of the use of this variable in
10699 a DATA ACL:
10700 .code
10701 deny message   = Too many lines in message header
10702      condition = \
10703        ${if <{250}{${eval:$message_linecount - $body_linecount}}}
10704 .endd
10705 In the MAIL and RCPT ACLs, the value is zero because at that stage the
10706 message has not yet been received.
10707
10708 .vitem &$message_size$&
10709 .cindex "size" "of message"
10710 .cindex "message" "size"
10711 .cindex "&$message_size$&"
10712 When a message is being processed, this variable contains its size in bytes. In
10713 most cases, the size includes those headers that were received with the
10714 message, but not those (such as &'Envelope-to:'&) that are added to individual
10715 deliveries as they are written. However, there is one special case: during the
10716 expansion of the &%maildir_tag%& option in the &(appendfile)& transport while
10717 doing a delivery in maildir format, the value of &$message_size$& is the
10718 precise size of the file that has been written. See also
10719 &$message_body_size$&, &$body_linecount$&, and &$body_zerocount$&.
10720
10721 .cindex "RCPT" "value of &$message_size$&"
10722 While running an ACL at the time of an SMTP RCPT command, &$message_size$&
10723 contains the size supplied on the MAIL command, or -1 if no size was given. The
10724 value may not, of course, be truthful.
10725
10726 .vitem &$mime_$&&'xxx'&
10727 A number of variables whose names start with &$mime$& are
10728 available when Exim is compiled with the content-scanning extension. For
10729 details, see section &<<SECTscanmimepart>>&.
10730
10731 .vitem "&$n0$& &-- &$n9$&"
10732 These variables are counters that can be incremented by means
10733 of the &%add%& command in filter files.
10734
10735 .vitem &$original_domain$&
10736 .cindex "&$domain$&"
10737 .cindex "&$original_domain$&"
10738 When a top-level address is being processed for delivery, this contains the
10739 same value as &$domain$&. However, if a &"child"& address (for example,
10740 generated by an alias, forward, or filter file) is being processed, this
10741 variable contains the domain of the original address (lower cased). This
10742 differs from &$parent_domain$& only when there is more than one level of
10743 aliasing or forwarding. When more than one address is being delivered in a
10744 single transport run, &$original_domain$& is not set.
10745
10746 If a new address is created by means of a &%deliver%& command in a system
10747 filter, it is set up with an artificial &"parent"& address. This has the local
10748 part &'system-filter'& and the default qualify domain.
10749
10750 .vitem &$original_local_part$&
10751 .cindex "&$local_part$&"
10752 .cindex "&$original_local_part$&"
10753 When a top-level address is being processed for delivery, this contains the
10754 same value as &$local_part$&, unless a prefix or suffix was removed from the
10755 local part, because &$original_local_part$& always contains the full local
10756 part. When a &"child"& address (for example, generated by an alias, forward, or
10757 filter file) is being processed, this variable contains the full local part of
10758 the original address.
10759
10760 If the router that did the redirection processed the local part
10761 case-insensitively, the value in &$original_local_part$& is in lower case.
10762 This variable differs from &$parent_local_part$& only when there is more than
10763 one level of aliasing or forwarding. When more than one address is being
10764 delivered in a single transport run, &$original_local_part$& is not set.
10765
10766 If a new address is created by means of a &%deliver%& command in a system
10767 filter, it is set up with an artificial &"parent"& address. This has the local
10768 part &'system-filter'& and the default qualify domain.
10769
10770 .vitem &$originator_gid$&
10771 .cindex "gid (group id)" "of originating user"
10772 .cindex "sender" "gid"
10773 .cindex "&$caller_gid$&"
10774 .cindex "&$originator_gid$&"
10775 This variable contains the value of &$caller_gid$& that was set when the
10776 message was received. For messages received via the command line, this is the
10777 gid of the sending user. For messages received by SMTP over TCP/IP, this is
10778 normally the gid of the Exim user.
10779
10780 .vitem &$originator_uid$&
10781 .cindex "uid (user id)" "of originating user"
10782 .cindex "sender" "uid"
10783 .cindex "&$caller_uid$&"
10784 .cindex "&$originaltor_uid$&"
10785 The value of &$caller_uid$& that was set when the message was received. For
10786 messages received via the command line, this is the uid of the sending user.
10787 For messages received by SMTP over TCP/IP, this is normally the uid of the Exim
10788 user.
10789
10790 .vitem &$parent_domain$&
10791 .cindex "&$parent_domain$&"
10792 This variable is similar to &$original_domain$& (see
10793 above), except that it refers to the immediately preceding parent address.
10794
10795 .vitem &$parent_local_part$&
10796 .cindex "&$parent_local_part$&"
10797 This variable is similar to &$original_local_part$&
10798 (see above), except that it refers to the immediately preceding parent address.
10799
10800 .vitem &$pid$&
10801 .cindex "pid (process id)" "of current process"
10802 .cindex "&$pid$&"
10803 This variable contains the current process id.
10804
10805 .vitem &$pipe_addresses$&
10806 .cindex "filter" "transport filter"
10807 .cindex "transport" "filter"
10808 .cindex "&$pipe_addresses$&"
10809 This is not an expansion variable, but is mentioned here because the string
10810 &`$pipe_addresses`& is handled specially in the command specification for the
10811 &(pipe)& transport (chapter &<<CHAPpipetransport>>&) and in transport filters
10812 (described under &%transport_filter%& in chapter &<<CHAPtransportgeneric>>&).
10813 It cannot be used in general expansion strings, and provokes an &"unknown
10814 variable"& error if encountered.
10815
10816 .vitem &$primary_hostname$&
10817 .cindex "&$primary_hostname$&"
10818 This variable contains the value set by &%primary_hostname%& in the
10819 configuration file, or read by the &[uname()]& function. If &[uname()]& returns
10820 a single-component name, Exim calls &[gethostbyname()]& (or
10821 &[getipnodebyname()]& where available) in an attempt to acquire a fully
10822 qualified host name. See also &$smtp_active_hostname$&.
10823
10824
10825 .vitem &$prvscheck_address$&
10826 This variable is used in conjunction with the &%prvscheck%& expansion item,
10827 which is described in sections &<<SECTexpansionitems>>& and
10828 &<<SECTverifyPRVS>>&.
10829
10830 .vitem &$prvscheck_keynum$&
10831 This variable is used in conjunction with the &%prvscheck%& expansion item,
10832 which is described in sections &<<SECTexpansionitems>>& and
10833 &<<SECTverifyPRVS>>&.
10834
10835 .vitem &$prvscheck_result$&
10836 This variable is used in conjunction with the &%prvscheck%& expansion item,
10837 which is described in sections &<<SECTexpansionitems>>& and
10838 &<<SECTverifyPRVS>>&.
10839
10840 .vitem &$qualify_domain$&
10841 .cindex "&$qualify_domain$&"
10842 The value set for the &%qualify_domain%& option in the configuration file.
10843
10844 .vitem &$qualify_recipient$&
10845 .cindex "&$qualify_recipient$&"
10846 The value set for the &%qualify_recipient%& option in the configuration file,
10847 or if not set, the value of &$qualify_domain$&.
10848
10849 .vitem &$rcpt_count$&
10850 .cindex "&$rcpt_count$&"
10851 When a message is being received by SMTP, this variable contains the number of
10852 RCPT commands received for the current message. If this variable is used in a
10853 RCPT ACL, its value includes the current command.
10854
10855 .vitem &$rcpt_defer_count$&
10856 .cindex "&$rcpt_defer_count$&"
10857 .cindex "4&'xx'& responses" "count of"
10858 When a message is being received by SMTP, this variable contains the number of
10859 RCPT commands in the current message that have previously been rejected with a
10860 temporary (4&'xx'&) response.
10861
10862 .vitem &$rcpt_fail_count$&
10863 .cindex "&$rcpt_fail_count$&"
10864 When a message is being received by SMTP, this variable contains the number of
10865 RCPT commands in the current message that have previously been rejected with a
10866 permanent (5&'xx'&) response.
10867
10868 .vitem &$received_count$&
10869 .cindex "&$received_count$&"
10870 This variable contains the number of &'Received:'& header lines in the message,
10871 including the one added by Exim (so its value is always greater than zero). It
10872 is available in the DATA ACL, the non-SMTP ACL, and while routing and
10873 delivering.
10874
10875 .vitem &$received_for$&
10876 .cindex "&$received_for$&"
10877 If there is only a single recipient address in an incoming message, this
10878 variable contains that address when the &'Received:'& header line is being
10879 built. The value is copied after recipient rewriting has happened, but before
10880 the &[local_scan()]& function is run.
10881
10882 .new
10883 .vitem &$received_ip_address$&
10884 .cindex "&$received_ip_address$&"
10885 As soon as an Exim server starts processing an incoming TCP/IP connection, this
10886 variable is set to the address of the local IP interface, and &$received_port$&
10887 is set to the local port number. (The remote IP address and port are in
10888 &$sender_host_address$& and &$sender_host_port$&.) When testing with &%-bh%&,
10889 the port value is -1 unless it has been set using the &%-oMi%& command line
10890 option.
10891
10892 As well as being useful in ACLs (including the &"connect"& ACL), these variable
10893 could be used, for example, to make the file name for a TLS certificate depend
10894 on which interface and/or port is being used for the incoming connection. The
10895 values of &$received_ip_address$& and &$received_port$& are saved with any
10896 messages that are received, thus making these variables available at delivery
10897 time.
10898
10899 &*Note:*& There are no equivalent variables for outgoing connections, because
10900 the values are unknown (unless they are explicitly set by options of the
10901 &(smtp)& transport).
10902
10903 .vitem &$received_port$&
10904 .cindex "&$received_port$&"
10905 See &$received_ip_address$&.
10906 .wen
10907
10908 .vitem &$received_protocol$&
10909 .cindex "&$received_protocol$&"
10910 When a message is being processed, this variable contains the name of the
10911 protocol by which it was received. Most of the names used by Exim are defined
10912 by RFCs 821, 2821, and 3848. They start with &"smtp"& (the client used HELO) or
10913 &"esmtp"& (the client used EHLO). This can be followed by &"s"& for secure
10914 (encrypted) and/or &"a"& for authenticated. Thus, for example, if the protocol
10915 is set to &"esmtpsa"&, the message was received over an encrypted SMTP
10916 connection and the client was successfully authenticated.
10917
10918 Exim uses the protocol name &"smtps"& for the case when encryption is
10919 automatically set up on connection without the use of STARTTLS (see
10920 &%tls_on_connect_ports%&), and the client uses HELO to initiate the
10921 encrypted SMTP session. The name &"smtps"& is also used for the rare situation
10922 where the client initially uses EHLO, sets up an encrypted connection using
10923 STARTTLS, and then uses HELO afterwards.
10924
10925 The &%-oMr%& option provides a way of specifying a custom protocol name for
10926 messages that are injected locally by trusted callers. This is commonly used to
10927 identify messages that are being re-injected after some kind of scanning.
10928
10929 .vitem &$received_time$&
10930 .cindex "&$received_time$&"
10931 This variable contains the date and time when the current message was received,
10932 as a number of seconds since the start of the Unix epoch.
10933
10934 .vitem &$recipient_data$&
10935 .cindex "&$recipient_data$&"
10936 This variable is set after an indexing lookup success in an ACL &%recipients%&
10937 condition. It contains the data from the lookup, and the value remains set
10938 until the next &%recipients%& test. Thus, you can do things like this:
10939 .display
10940 &`require recipients  = cdb*@;/some/file`&
10941 &`deny    `&&'some further test involving'& &`$recipient_data`&
10942 .endd
10943 &*Warning*&: This variable is set only when a lookup is used as an indexing
10944 method in the address list, using the semicolon syntax as in the example above.
10945 The variable is not set for a lookup that is used as part of the string
10946 expansion that all such lists undergo before being interpreted.
10947
10948 .vitem &$recipient_verify_failure$&
10949 .cindex "&$recipient_verify_failure$&"
10950 In an ACL, when a recipient verification fails, this variable contains
10951 information about the failure. It is set to one of the following words:
10952
10953 .ilist
10954 &"qualify"&: The address was unqualified (no domain), and the message
10955 was neither local nor came from an exempted host.
10956
10957 .next
10958 &"route"&: Routing failed.
10959
10960 .next
10961 &"mail"&: Routing succeeded, and a callout was attempted; rejection occurred at
10962 or before the MAIL command (that is, on initial connection, HELO, or
10963 MAIL).
10964
10965 .next
10966 &"recipient"&: The RCPT command in a callout was rejected.
10967 .next
10968
10969 &"postmaster"&: The postmaster check in a callout was rejected.
10970 .endlist
10971
10972 The main use of this variable is expected to be to distinguish between
10973 rejections of MAIL and rejections of RCPT.
10974
10975 .vitem &$recipients$&
10976 .cindex "&$recipients$&"
10977 This variable contains a list of envelope recipients for a
10978 message. A comma and a space separate the addresses in the replacement text.
10979 However, the variable is not generally available, to prevent exposure of Bcc
10980 recipients in unprivileged users' filter files. You can use &$recipients$& only
10981 in these two cases:
10982
10983 .olist
10984 In a system filter file.
10985 .next
10986 In the ACLs associated with the DATA command and with non-SMTP messages, that
10987 is, the ACLs defined by &%acl_smtp_predata%&, &%acl_smtp_data%&,
10988 &%acl_smtp_mime%&, &%acl_not_smtp_start%&, &%acl_not_smtp%&, and
10989 &%acl_not_smtp_mime%&.
10990 .endlist
10991
10992
10993 .vitem &$recipients_count$&
10994 .cindex "&$recipients_count$&"
10995 When a message is being processed, this variable contains the number of
10996 envelope recipients that came with the message. Duplicates are not excluded
10997 from the count. While a message is being received over SMTP, the number
10998 increases for each accepted recipient. It can be referenced in an ACL.
10999
11000
11001 .vitem &$regex_match_string$&
11002 .cindex "&$regex_match_string$&"
11003 This variable is set to contain the matching regular expression after a
11004 &%regex%& ACL condition has matched (see section &<<SECTscanregex>>&).
11005
11006
11007 .vitem &$reply_address$&
11008 .cindex "&$reply_address$&"
11009 When a message is being processed, this variable contains the contents of the
11010 &'Reply-To:'& header line if one exists and it is not empty, or otherwise the
11011 contents of the &'From:'& header line. Apart from the removal of leading
11012 white space, the value is not processed in any way. In particular, no RFC 2047
11013 decoding or character code translation takes place.
11014
11015 .vitem &$return_path$&
11016 .cindex "&$return_path$&"
11017 When a message is being delivered, this variable contains the return path &--
11018 the sender field that will be sent as part of the envelope. It is not enclosed
11019 in <> characters. At the start of routing an address, &$return_path$& has the
11020 same value as &$sender_address$&, but if, for example, an incoming message to a
11021 mailing list has been expanded by a router which specifies a different address
11022 for bounce messages, &$return_path$& subsequently contains the new bounce
11023 address, whereas &$sender_address$& always contains the original sender address
11024 that was received with the message. In other words, &$sender_address$& contains
11025 the incoming envelope sender, and &$return_path$& contains the outgoing
11026 envelope sender.
11027
11028 .vitem &$return_size_limit$&
11029 .cindex "&$return_size_limit$&"
11030 This is an obsolete name for &$bounce_return_size_limit$&.
11031
11032 .vitem &$runrc$&
11033 .cindex "return code" "from &%run%& expansion"
11034 .cindex "&$runrc$&"
11035 This variable contains the return code from a command that is run by the
11036 &%${run...}%& expansion item. &*Warning*&: In a router or transport, you cannot
11037 assume the order in which option values are expanded, except for those
11038 preconditions whose order of testing is documented. Therefore, you cannot
11039 reliably expect to set &$runrc$& by the expansion of one option, and use it in
11040 another.
11041
11042 .vitem &$self_hostname$&
11043 .cindex "&%self%& option" "value of host name"
11044 .cindex "&$self_hostname$&"
11045 When an address is routed to a supposedly remote host that turns out to be the
11046 local host, what happens is controlled by the &%self%& generic router option.
11047 One of its values causes the address to be passed to another router. When this
11048 happens, &$self_hostname$& is set to the name of the local host that the
11049 original router encountered. In other circumstances its contents are null.
11050
11051 .vitem &$sender_address$&
11052 .new
11053 .cindex "&$sender_address$&"
11054 When a message is being processed, this variable contains the sender's address
11055 that was received in the message's envelope. The case of letters in the address
11056 is retained, in both the local part and the domain. For bounce messages, the
11057 value of this variable is the empty string. See also &$return_path$&.
11058 .wen
11059
11060 .vitem &$sender_address_data$&
11061 .cindex "&$address_data$&"
11062 .cindex "&$sender_address_data$&"
11063 If &$address_data$& is set when the routers are called from an ACL to verify a
11064 sender address, the final value is preserved in &$sender_address_data$&, to
11065 distinguish it from data from a recipient address. The value does not persist
11066 after the end of the current ACL statement. If you want to preserve it for
11067 longer, you can save it in an ACL variable.
11068
11069 .vitem &$sender_address_domain$&
11070 .cindex "&$sender_address_domain$&"
11071 The domain portion of &$sender_address$&.
11072
11073 .vitem &$sender_address_local_part$&
11074 .cindex "&$sender_address_local_part$&"
11075 The local part portion of &$sender_address$&.
11076
11077 .vitem &$sender_data$&
11078 .cindex "&$sender_data$&"
11079 This variable is set after a lookup success in an ACL &%senders%& condition or
11080 in a router &%senders%& option. It contains the data from the lookup, and the
11081 value remains set until the next &%senders%& test. Thus, you can do things like
11082 this:
11083 .display
11084 &`require senders      = cdb*@;/some/file`&
11085 &`deny    `&&'some further test involving'& &`$sender_data`&
11086 .endd
11087 &*Warning*&: This variable is set only when a lookup is used as an indexing
11088 method in the address list, using the semicolon syntax as in the example above.
11089 The variable is not set for a lookup that is used as part of the string
11090 expansion that all such lists undergo before being interpreted.
11091
11092 .vitem &$sender_fullhost$&
11093 .cindex "&$sender_fullhost$&"
11094 When a message is received from a remote host, this variable contains the host
11095 name and IP address in a single string. It ends with the IP address in square
11096 brackets, followed by a colon and a port number if the logging of ports is
11097 enabled. The format of the rest of the string depends on whether the host
11098 issued a HELO or EHLO SMTP command, and whether the host name was verified by
11099 looking up its IP address. (Looking up the IP address can be forced by the
11100 &%host_lookup%& option, independent of verification.) A plain host name at the
11101 start of the string is a verified host name; if this is not present,
11102 verification either failed or was not requested. A host name in parentheses is
11103 the argument of a HELO or EHLO command. This is omitted if it is identical to
11104 the verified host name or to the host's IP address in square brackets.
11105
11106 .vitem &$sender_helo_name$&
11107 .cindex "&$sender_helo_name$&"
11108 When a message is received from a remote host that has issued a HELO or EHLO
11109 command, the argument of that command is placed in this variable. It is also
11110 set if HELO or EHLO is used when a message is received using SMTP locally via
11111 the &%-bs%& or &%-bS%& options.
11112
11113 .vitem &$sender_host_address$&
11114 .cindex "&$sender_host_address$&"
11115 When a message is received from a remote host, this variable contains that
11116 host's IP address. For locally submitted messages, it is empty.
11117
11118 .vitem &$sender_host_authenticated$&
11119 .cindex "&$sender_host_authenticated$&"
11120 This variable contains the name (not the public name) of the authenticator
11121 driver that successfully authenticated the client from which the message was
11122 received. It is empty if there was no successful authentication. See also
11123 &$authenticated_id$&.
11124
11125 .vitem &$sender_host_name$&
11126 .cindex "&$sender_host_name$&"
11127 When a message is received from a remote host, this variable contains the
11128 host's name as obtained by looking up its IP address. For messages received by
11129 other means, this variable is empty.
11130
11131 .cindex "&$host_lookup_failed$&"
11132 If the host name has not previously been looked up, a reference to
11133 &$sender_host_name$& triggers a lookup (for messages from remote hosts).
11134 A looked up name is accepted only if it leads back to the original IP address
11135 via a forward lookup. If either the reverse or the forward lookup fails to find
11136 any data, or if the forward lookup does not yield the original IP address,
11137 &$sender_host_name$& remains empty, and &$host_lookup_failed$& is set to &"1"&.
11138
11139 .cindex "&$host_lookup_deferred$&"
11140 However, if either of the lookups cannot be completed (for example, there is a
11141 DNS timeout), &$host_lookup_deferred$& is set to &"1"&, and
11142 &$host_lookup_failed$& remains set to &"0"&.
11143
11144 Once &$host_lookup_failed$& is set to &"1"&, Exim does not try to look up the
11145 host name again if there is a subsequent reference to &$sender_host_name$&
11146 in the same Exim process, but it does try again if &$host_lookup_deferred$&
11147 is set to &"1"&.
11148
11149 Exim does not automatically look up every calling host's name. If you want
11150 maximum efficiency, you should arrange your configuration so that it avoids
11151 these lookups altogether. The lookup happens only if one or more of the
11152 following are true:
11153
11154 .ilist
11155 A string containing &$sender_host_name$& is expanded.
11156 .next
11157 The calling host matches the list in &%host_lookup%&. In the default
11158 configuration, this option is set to *, so it must be changed if lookups are
11159 to be avoided. (In the code, the default for &%host_lookup%& is unset.)
11160 .next
11161 Exim needs the host name in order to test an item in a host list. The items
11162 that require this are described in sections &<<SECThoslispatnam>>& and
11163 &<<SECThoslispatnamsk>>&.
11164 .next
11165 The calling host matches &%helo_try_verify_hosts%& or &%helo_verify_hosts%&.
11166 In this case, the host name is required to compare with the name quoted in any
11167 EHLO or HELO commands that the client issues.
11168 .next
11169 The remote host issues a EHLO or HELO command that quotes one of the
11170 domains in &%helo_lookup_domains%&. The default value of this option is
11171 . ==== As this is a nested list, any displays it contains must be indented
11172 . ==== as otherwise they are too far to the left.
11173 .code
11174   helo_lookup_domains = @ : @[]
11175 .endd
11176 which causes a lookup if a remote host (incorrectly) gives the server's name or
11177 IP address in an EHLO or HELO command.
11178 .endlist
11179
11180
11181 .vitem &$sender_host_port$&
11182 .cindex "&$sender_host_port$&"
11183 When a message is received from a remote host, this variable contains the port
11184 number that was used on the remote host.
11185
11186 .vitem &$sender_ident$&
11187 .cindex "&$sender_ident$&"
11188 When a message is received from a remote host, this variable contains the
11189 identification received in response to an RFC 1413 request. When a message has
11190 been received locally, this variable contains the login name of the user that
11191 called Exim.
11192
11193 .vitem &$sender_rate_$&&'xxx'&
11194 A number of variables whose names begin &$sender_rate_$& are set as part of the
11195 &%ratelimit%& ACL condition. Details are given in section
11196 &<<SECTratelimiting>>&.
11197
11198 .vitem &$sender_rcvhost$&
11199 .cindex "DNS" "reverse lookup"
11200 .cindex "reverse DNS lookup"
11201 .cindex "&$sender_rcvhost$&"
11202 This is provided specifically for use in &'Received:'& headers. It starts with
11203 either the verified host name (as obtained from a reverse DNS lookup) or, if
11204 there is no verified host name, the IP address in square brackets. After that
11205 there may be text in parentheses. When the first item is a verified host name,
11206 the first thing in the parentheses is the IP address in square brackets,
11207 followed by a colon and a port number if port logging is enabled. When the
11208 first item is an IP address, the port is recorded as &"port=&'xxxx'&"& inside
11209 the parentheses.
11210
11211 There may also be items of the form &"helo=&'xxxx'&"& if HELO or EHLO
11212 was used and its argument was not identical to the real host name or IP
11213 address, and &"ident=&'xxxx'&"& if an RFC 1413 ident string is available. If
11214 all three items are present in the parentheses, a newline and tab are inserted
11215 into the string, to improve the formatting of the &'Received:'& header.
11216
11217 .vitem &$sender_verify_failure$&
11218 .cindex "&$sender_verify_failure$&"
11219 In an ACL, when a sender verification fails, this variable contains information
11220 about the failure. The details are the same as for
11221 &$recipient_verify_failure$&.
11222
11223 .vitem &$smtp_active_hostname$&
11224 .cindex "&$smtp_active_hostname$&"
11225 During an incoming SMTP session, this variable contains the value of the active
11226 host name, as specified by the &%smtp_active_hostname%& option. The value of
11227 &$smtp_active_hostname$& is saved with any message that is received, so its
11228 value can be consulted during routing and delivery.
11229
11230 .vitem &$smtp_command$&
11231 .cindex "&$smtp_command$&"
11232 During the processing of an incoming SMTP command, this variable contains the
11233 entire command. This makes it possible to distinguish between HELO and EHLO in
11234 the HELO ACL, and also to distinguish between commands such as these:
11235 .code
11236 MAIL FROM:<>
11237 MAIL FROM: <>
11238 .endd
11239 For a MAIL command, extra parameters such as SIZE can be inspected. For a RCPT
11240 command, the address in &$smtp_command$& is the original address before any
11241 rewriting, whereas the values in &$local_part$& and &$domain$& are taken from
11242 the address after SMTP-time rewriting.
11243
11244 .vitem &$smtp_command_argument$&
11245 .cindex "SMTP command" "argument for"
11246 .cindex "&$smtp_command_argument$&"
11247 While an ACL is running to check an SMTP command, this variable contains the
11248 argument, that is, the text that follows the command name, with leading white
11249 space removed. Following the introduction of &$smtp_command$&, this variable is
11250 somewhat redundant, but is retained for backwards compatibility.
11251
11252 .vitem "&$sn0$& &-- &$sn9$&"
11253 These variables are copies of the values of the &$n0$& &-- &$n9$& accumulators
11254 that were current at the end of the system filter file. This allows a system
11255 filter file to set values that can be tested in users' filter files. For
11256 example, a system filter could set a value indicating how likely it is that a
11257 message is junk mail.
11258
11259 .vitem &$spam_$&&'xxx'&
11260 A number of variables whose names start with &$spam$& are available when Exim
11261 is compiled with the content-scanning extension. For details, see section
11262 &<<SECTscanspamass>>&.
11263
11264
11265 .vitem &$spool_directory$&
11266 .cindex "&$spool_directory$&"
11267 The name of Exim's spool directory.
11268
11269 .vitem &$spool_inodes$&
11270 .cindex "&$spool_inodes$&"
11271 The number of free inodes in the disk partition where Exim's spool files are
11272 being written. The value is recalculated whenever the variable is referenced.
11273 If the relevant file system does not have the concept of inodes, the value of
11274 is -1. See also the &%check_spool_inodes%& option.
11275
11276 .vitem &$spool_space$&
11277 .cindex "&$spool_space$&"
11278 The amount of free space (as a number of kilobytes) in the disk partition where
11279 Exim's spool files are being written. The value is recalculated whenever the
11280 variable is referenced. If the operating system does not have the ability to
11281 find the amount of free space (only true for experimental systems), the space
11282 value is -1. For example, to check in an ACL that there is at least 50
11283 megabytes free on the spool, you could write:
11284 .code
11285 condition = ${if > {$spool_space}{50000}}
11286 .endd
11287 See also the &%check_spool_space%& option.
11288
11289
11290 .vitem &$thisaddress$&
11291 .cindex "&$thisaddress$&"
11292 This variable is set only during the processing of the &%foranyaddress%&
11293 command in a filter file. Its use is explained in the description of that
11294 command, which can be found in the separate document entitled &'Exim's
11295 interfaces to mail filtering'&.
11296
11297 .vitem &$tls_certificate_verified$&
11298 .cindex "&$tls_certificate_verified$&"
11299 This variable is set to &"1"& if a TLS certificate was verified when the
11300 message was received, and &"0"& otherwise.
11301
11302 .vitem &$tls_cipher$&
11303 .cindex "&$tls_cipher$&"
11304 When a message is received from a remote host over an encrypted SMTP
11305 connection, this variable is set to the cipher suite that was negotiated, for
11306 example DES-CBC3-SHA. In other circumstances, in particular, for message
11307 received over unencrypted connections, the variable is empty. See chapter
11308 &<<CHAPTLS>>& for details of TLS support.
11309
11310 .vitem &$tls_peerdn$&
11311 .cindex "&$tls_peerdn$&"
11312 When a message is received from a remote host over an encrypted SMTP
11313 connection, and Exim is configured to request a certificate from the client,
11314 the value of the Distinguished Name of the certificate is made available in the
11315 &$tls_peerdn$& during subsequent processing.
11316
11317 .vitem &$tod_bsdinbox$&
11318 .cindex "&$tod_bsdinbox$&"
11319 The time of day and the date, in the format required for BSD-style mailbox
11320 files, for example: Thu Oct 17 17:14:09 1995.
11321
11322 .vitem &$tod_epoch$&
11323 .cindex "&$tod_epoch$&"
11324 The time and date as a number of seconds since the start of the Unix epoch.
11325
11326 .vitem &$tod_full$&
11327 .cindex "&$tod_full$&"
11328 A full version of the time and date, for example: Wed, 16 Oct 1995 09:51:40
11329 +0100. The timezone is always given as a numerical offset from UTC, with
11330 positive values used for timezones that are ahead (east) of UTC, and negative
11331 values for those that are behind (west).
11332
11333 .vitem &$tod_log$&
11334 .cindex "&$tod_log$&"
11335 The time and date in the format used for writing Exim's log files, for example:
11336 1995-10-12 15:32:29, but without a timezone.
11337
11338 .vitem &$tod_logfile$&
11339 .cindex "&$tod_logfile$&"
11340 This variable contains the date in the format yyyymmdd. This is the format that
11341 is used for datestamping log files when &%log_file_path%& contains the &`%D`&
11342 flag.
11343
11344 .vitem &$tod_zone$&
11345 .cindex "&$tod_zone$&"
11346 This variable contains the numerical value of the local timezone, for example:
11347 -0500.
11348
11349 .vitem &$tod_zulu$&
11350 .cindex "&$tod_zulu$&"
11351 This variable contains the UTC date and time in &"Zulu"& format, as specified
11352 by ISO 8601, for example: 20030221154023Z.
11353
11354 .vitem &$value$&
11355 .cindex "&$value$&"
11356 This variable contains the result of an expansion lookup, extraction operation,
11357 or external command, as described above.
11358
11359 .vitem &$version_number$&
11360 .cindex "&$version_number$&"
11361 The version number of Exim.
11362
11363 .vitem &$warn_message_delay$&
11364 .cindex "&$warn_message_delay$&"
11365 This variable is set only during the creation of a message warning about a
11366 delivery delay. Details of its use are explained in section &<<SECTcustwarn>>&.
11367
11368 .vitem &$warn_message_recipients$&
11369 .cindex "&$warn_message_recipients$&"
11370 This variable is set only during the creation of a message warning about a
11371 delivery delay. Details of its use are explained in section &<<SECTcustwarn>>&.
11372 .endlist
11373 .ecindex IIDstrexp
11374
11375
11376
11377 . ////////////////////////////////////////////////////////////////////////////
11378 . ////////////////////////////////////////////////////////////////////////////
11379
11380 .chapter "Embedded Perl" "CHAPperl"
11381 .scindex IIDperl "Perl" "calling from Exim"
11382 Exim can be built to include an embedded Perl interpreter. When this is done,
11383 Perl subroutines can be called as part of the string expansion process. To make
11384 use of the Perl support, you need version 5.004 or later of Perl installed on
11385 your system. To include the embedded interpreter in the Exim binary, include
11386 the line
11387 .code
11388 EXIM_PERL = perl.o
11389 .endd
11390 in your &_Local/Makefile_& and then build Exim in the normal way.
11391
11392
11393 .section "Setting up so Perl can be used"
11394 .cindex "&%perl_startup%&"
11395 Access to Perl subroutines is via a global configuration option called
11396 &%perl_startup%& and an expansion string operator &%${perl ...}%&. If there is
11397 no &%perl_startup%& option in the Exim configuration file then no Perl
11398 interpreter is started and there is almost no overhead for Exim (since none of
11399 the Perl library will be paged in unless used). If there is a &%perl_startup%&
11400 option then the associated value is taken to be Perl code which is executed in
11401 a newly created Perl interpreter.
11402
11403 The value of &%perl_startup%& is not expanded in the Exim sense, so you do not
11404 need backslashes before any characters to escape special meanings. The option
11405 should usually be something like
11406 .code
11407 perl_startup = do '/etc/exim.pl'
11408 .endd
11409 where &_/etc/exim.pl_& is Perl code which defines any subroutines you want to
11410 use from Exim. Exim can be configured either to start up a Perl interpreter as
11411 soon as it is entered, or to wait until the first time it is needed. Starting
11412 the interpreter at the beginning ensures that it is done while Exim still has
11413 its setuid privilege, but can impose an unnecessary overhead if Perl is not in
11414 fact used in a particular run. Also, note that this does not mean that Exim is
11415 necessarily running as root when Perl is called at a later time. By default,
11416 the interpreter is started only when it is needed, but this can be changed in
11417 two ways:
11418
11419 .ilist
11420 .cindex "&%perl_at_start%&"
11421 Setting &%perl_at_start%& (a boolean option) in the configuration requests
11422 a startup when Exim is entered.
11423 .next
11424 The command line option &%-ps%& also requests a startup when Exim is entered,
11425 overriding the setting of &%perl_at_start%&.
11426 .endlist
11427
11428 There is also a command line option &%-pd%& (for delay) which suppresses the
11429 initial startup, even if &%perl_at_start%& is set.
11430
11431
11432 .section "Calling Perl subroutines"
11433 When the configuration file includes a &%perl_startup%& option you can make use
11434 of the string expansion item to call the Perl subroutines that are defined
11435 by the &%perl_startup%& code. The operator is used in any of the following
11436 forms:
11437 .code
11438 ${perl{foo}}
11439 ${perl{foo}{argument}}
11440 ${perl{foo}{argument1}{argument2} ... }
11441 .endd
11442 which calls the subroutine &%foo%& with the given arguments. A maximum of eight
11443 arguments may be passed. Passing more than this results in an expansion failure
11444 with an error message of the form
11445 .code
11446 Too many arguments passed to Perl subroutine "foo" (max is 8)
11447 .endd
11448 The return value of the Perl subroutine is evaluated in a scalar context before
11449 it is passed back to Exim to be inserted into the expanded string. If the
11450 return value is &'undef'&, the expansion is forced to fail in the same way as
11451 an explicit &"fail"& on an &%if%& or &%lookup%& item. If the subroutine aborts
11452 by obeying Perl's &%die%& function, the expansion fails with the error message
11453 that was passed to &%die%&.
11454
11455
11456 .section "Calling Exim functions from Perl"
11457 Within any Perl code called from Exim, the function &'Exim::expand_string()'&
11458 is available to call back into Exim's string expansion function. For example,
11459 the Perl code
11460 .code
11461 my $lp = Exim::expand_string('$local_part');
11462 .endd
11463 makes the current Exim &$local_part$& available in the Perl variable &$lp$&.
11464 Note those are single quotes and not double quotes to protect against
11465 &$local_part$& being interpolated as a Perl variable.
11466
11467 If the string expansion is forced to fail by a &"fail"& item, the result of
11468 &'Exim::expand_string()'& is &%undef%&. If there is a syntax error in the
11469 expansion string, the Perl call from the original expansion string fails with
11470 an appropriate error message, in the same way as if &%die%& were used.
11471
11472 .cindex "debugging" "from embedded Perl"
11473 .cindex "log" "writing from embedded Perl"
11474 Two other Exim functions are available for use from within Perl code.
11475 &'Exim::debug_write()'& writes a string to the standard error stream if Exim's
11476 debugging is enabled. If you want a newline at the end, you must supply it.
11477 &'Exim::log_write()'& writes a string to Exim's main log, adding a leading
11478 timestamp. In this case, you should not supply a terminating newline.
11479
11480
11481 .section "Use of standard output and error by Perl"
11482 .cindex "Perl" "standard output and error"
11483 You should not write to the standard error or output streams from within your
11484 Perl code, as it is not defined how these are set up. In versions of Exim
11485 before 4.50, it is possible for the standard output or error to refer to the
11486 SMTP connection during message reception via the daemon. Writing to this stream
11487 is certain to cause chaos. From Exim 4.50 onwards, the standard output and
11488 error streams are connected to &_/dev/null_& in the daemon. The chaos is
11489 avoided, but the output is lost.
11490
11491 .cindex "Perl" "use of &%warn%&"
11492 The Perl &%warn%& statement writes to the standard error stream by default.
11493 Calls to &%warn%& may be embedded in Perl modules that you use, but over which
11494 you have no control. When Exim starts up the Perl interpreter, it arranges for
11495 output from the &%warn%& statement to be written to the Exim main log. You can
11496 change this by including appropriate Perl magic somewhere in your Perl code.
11497 For example, to discard &%warn%& output completely, you need this:
11498 .code
11499 $SIG{__WARN__} = sub { };
11500 .endd
11501 Whenever a &%warn%& is obeyed, the anonymous subroutine is called. In this
11502 example, the code for the subroutine is empty, so it does nothing, but you can
11503 include any Perl code that you like. The text of the &%warn%& message is passed
11504 as the first subroutine argument.
11505 .ecindex IIDperl
11506
11507
11508 . ////////////////////////////////////////////////////////////////////////////
11509 . ////////////////////////////////////////////////////////////////////////////
11510
11511 .chapter "Starting the daemon and the use of network interfaces" &&&
11512          "CHAPinterfaces" &&&
11513          "Starting the daemon"
11514 .cindex "daemon" "starting"
11515 .cindex "interface" "listening"
11516 .cindex "network interface"
11517 .cindex "interface" "network"
11518 .cindex "IP address" "for listening"
11519 .cindex "daemon" "listening IP addresses"
11520 .cindex "TCP/IP" "setting listening interfaces"
11521 .cindex "TCP/IP" "setting listening ports"
11522 A host that is connected to a TCP/IP network may have one or more physical
11523 hardware network interfaces. Each of these interfaces may be configured as one
11524 or more &"logical"& interfaces, which are the entities that a program actually
11525 works with. Each of these logical interfaces is associated with an IP address.
11526 In addition, TCP/IP software supports &"loopback"& interfaces (127.0.0.1 in
11527 IPv4 and ::1 in IPv6), which do not use any physical hardware. Exim requires
11528 knowledge about the host's interfaces for use in three different circumstances:
11529
11530 .olist
11531 When a listening daemon is started, Exim needs to know which interfaces
11532 and ports to listen on.
11533 .next
11534 When Exim is routing an address, it needs to know which IP addresses
11535 are associated with local interfaces. This is required for the correct
11536 processing of MX lists by removing the local host and others with the
11537 same or higher priority values. Also, Exim needs to detect cases
11538 when an address is routed to an IP address that in fact belongs to the
11539 local host. Unless the &%self%& router option or the &%allow_localhost%&
11540 option of the smtp transport is set (as appropriate), this is treated
11541 as an error situation.
11542 .next
11543 When Exim connects to a remote host, it may need to know which interface to use
11544 for the outgoing connection.
11545 .endlist
11546
11547
11548 Exim's default behaviour is likely to be appropriate in the vast majority
11549 of cases. If your host has only one interface, and you want all its IP
11550 addresses to be treated in the same way, and you are using only the
11551 standard SMTP port, you should not need to take any special action. The
11552 rest of this chapter does not apply to you.
11553
11554 In a more complicated situation you may want to listen only on certain
11555 interfaces, or on different ports, and for this reason there are a number of
11556 options that can be used to influence Exim's behaviour. The rest of this
11557 chapter describes how they operate.
11558
11559 .new
11560 When a message is received over TCP/IP, the interface and port that were
11561 actually used are set in &$received_ip_address$& and &$received_port$&.
11562 .wen
11563
11564
11565
11566 .section "Starting a listening daemon"
11567 When a listening daemon is started (by means of the &%-bd%& command line
11568 option), the interfaces and ports on which it listens are controlled by the
11569 following options:
11570
11571 .ilist
11572 &%daemon_smtp_ports%& contains a list of default ports. (For backward
11573 compatibility, this option can also be specified in the singular.)
11574 .next
11575 &%local_interfaces%& contains list of interface IP addresses on which to
11576 listen. Each item may optionally also specify a port.
11577 .endlist
11578
11579 The default list separator in both cases is a colon, but this can be changed as
11580 described in section &<<SECTlistconstruct>>&. When IPv6 addresses are involved,
11581 it is usually best to change the separator to avoid having to double all the
11582 colons. For example:
11583 .code
11584 local_interfaces = <; 127.0.0.1 ; \
11585                       192.168.23.65 ; \
11586                       ::1 ; \
11587                       3ffe:ffff:836f::fe86:a061
11588 .endd
11589 There are two different formats for specifying a port along with an IP address
11590 in &%local_interfaces%&:
11591
11592 .olist
11593 The port is added onto the address with a dot separator. For example, to listen
11594 on port 1234 on two different IP addresses:
11595 .code
11596 local_interfaces = <; 192.168.23.65.1234 ; \
11597                       3ffe:ffff:836f::fe86:a061.1234
11598 .endd
11599 .next
11600 The IP address is enclosed in square brackets, and the port is added
11601 with a colon separator, for example:
11602 .code
11603 local_interfaces = <; [192.168.23.65]:1234 ; \
11604                       [3ffe:ffff:836f::fe86:a061]:1234
11605 .endd
11606 .endlist
11607
11608 When a port is not specified, the value of &%daemon_smtp_ports%& is used. The
11609 default setting contains just one port:
11610 .code
11611 daemon_smtp_ports = smtp
11612 .endd
11613 If more than one port is listed, each interface that does not have its own port
11614 specified listens on all of them. Ports that are listed in
11615 &%daemon_smtp_ports%& can be identified either by name (defined in
11616 &_/etc/services_&) or by number. However, when ports are given with individual
11617 IP addresses in &%local_interfaces%&, only numbers (not names) can be used.
11618
11619
11620
11621 .section "Special IP listening addresses"
11622 The addresses 0.0.0.0 and ::0 are treated specially. They are interpreted
11623 as &"all IPv4 interfaces"& and &"all IPv6 interfaces"&, respectively. In each
11624 case, Exim tells the TCP/IP stack to &"listen on all IPv&'x'& interfaces"&
11625 instead of setting up separate listening sockets for each interface. The
11626 default value of &%local_interfaces%& is
11627 .code
11628 local_interfaces = 0.0.0.0
11629 .endd
11630 when Exim is built without IPv6 support; otherwise it is:
11631 .code
11632 local_interfaces = <; ::0 ; 0.0.0.0
11633 .endd
11634 Thus, by default, Exim listens on all available interfaces, on the SMTP port.
11635
11636
11637
11638 .section "Overriding local_interfaces and daemon_smtp_ports"
11639 The &%-oX%& command line option can be used to override the values of
11640 &%daemon_smtp_ports%& and/or &%local_interfaces%& for a particular daemon
11641 instance. Another way of doing this would be to use macros and the &%-D%&
11642 option. However, &%-oX%& can be used by any admin user, whereas modification of
11643 the runtime configuration by &%-D%& is allowed only when the caller is root or
11644 exim.
11645
11646 The value of &%-oX%& is a list of items. The default colon separator can be
11647 changed in the usual way if required. If there are any items that do not
11648 contain dots or colons (that is, are not IP addresses), the value of
11649 &%daemon_smtp_ports%& is replaced by the list of those items. If there are any
11650 items that do contain dots or colons, the value of &%local_interfaces%& is
11651 replaced by those items. Thus, for example,
11652 .code
11653 -oX 1225
11654 .endd
11655 overrides &%daemon_smtp_ports%&, but leaves &%local_interfaces%& unchanged,
11656 whereas
11657 .code
11658 -oX 192.168.34.5.1125
11659 .endd
11660 overrides &%local_interfaces%&, leaving &%daemon_smtp_ports%& unchanged.
11661 (However, since &%local_interfaces%& now contains no items without ports, the
11662 value of &%daemon_smtp_ports%& is no longer relevant in this example.)
11663
11664
11665
11666 .section "Support for the obsolete SSMTP (or SMTPS) protocol" "SECTsupobssmt"
11667 .cindex "ssmtp protocol"
11668 .cindex "smtps protocol"
11669 .cindex "SMTP" "ssmtp protocol"
11670 .cindex "SMTP" "smtps protocol"
11671 Exim supports the obsolete SSMTP protocol (also known as SMTPS) that was used
11672 before the STARTTLS command was standardized for SMTP. Some legacy clients
11673 still use this protocol. If the &%tls_on_connect_ports%& option is set to a
11674 list of port numbers, connections to those ports must use SSMTP. The most
11675 common use of this option is expected to be
11676 .code
11677 tls_on_connect_ports = 465
11678 .endd
11679 because 465 is the usual port number used by the legacy clients. There is also
11680 a command line option &%-tls-on-connect%&, which forces all ports to behave in
11681 this way when a daemon is started.
11682
11683 &*Warning*&: Setting &%tls_on_connect_ports%& does not of itself cause the
11684 daemon to listen on those ports. You must still specify them in
11685 &%daemon_smtp_ports%&, &%local_interfaces%&, or the &%-oX%& option. (This is
11686 because &%tls_on_connect_ports%& applies to &%inetd%& connections as well as to
11687 connections via the daemon.)
11688
11689
11690
11691
11692 .section "IPv6 address scopes"
11693 .cindex "IPv6" "address scopes"
11694 IPv6 addresses have &"scopes"&, and a host with multiple hardware interfaces
11695 can, in principle, have the same link-local IPv6 address on different
11696 interfaces. Thus, additional information is needed, over and above the IP
11697 address, to distinguish individual interfaces. A convention of using a
11698 percent sign followed by something (often the interface name) has been
11699 adopted in some cases, leading to addresses like this:
11700 .code
11701 fe80::202:b3ff:fe03:45c1%eth0
11702 .endd
11703 To accommodate this usage, a percent sign followed by an arbitrary string is
11704 allowed at the end of an IPv6 address. By default, Exim calls &[getaddrinfo()]&
11705 to convert a textual IPv6 address for actual use. This function recognizes the
11706 percent convention in operating systems that support it, and it processes the
11707 address appropriately. Unfortunately, some older libraries have problems with
11708 &[getaddrinfo()]&. If
11709 .code
11710 IPV6_USE_INET_PTON=yes
11711 .endd
11712 is set in &_Local/Makefile_& (or an OS-dependent Makefile) when Exim is built,
11713 Exim uses &'inet_pton()'& to convert a textual IPv6 address for actual use,
11714 instead of &[getaddrinfo()]&. (Before version 4.14, it always used this
11715 function.) Of course, this means that the additional functionality of
11716 &[getaddrinfo()]& &-- recognizing scoped addresses &-- is lost.
11717
11718 .section "Disabling IPv6"
11719 .cindex "IPv6" "disabling"
11720 Sometimes it happens that an Exim binary that was compiled with IPv6 support is
11721 run on a host whose kernel does not support IPv6. The binary will fall back to
11722 using IPv4, but it may waste resources looking up AAAA records, and trying to
11723 connect to IPv6 addresses, causing delays to mail delivery. If you set the
11724 .oindex "&%disable_ipv6%&"
11725 &%disable_ipv6%& option true, even if the Exim binary has IPv6 support, no IPv6
11726 activities take place. AAAA records are never looked up, and any IPv6 addresses
11727 that are listed in &%local_interfaces%&, data for the &(manualroute)& router,
11728 etc. are ignored. If IP literals are enabled, the &(ipliteral)& router declines
11729 to handle IPv6 literal addresses.
11730
11731 On the other hand, when IPv6 is in use, there may be times when you want to
11732 disable it for certain hosts or domains. You can use the &%dns_ipv4_lookup%&
11733 option to globally suppress the lookup of AAAA records for specified domains,
11734 and you can use the &%ignore_target_hosts%& generic router option to ignore
11735 IPv6 addresses in an individual router.
11736
11737
11738
11739 .section "Examples of starting a listening daemon"
11740 The default case in an IPv6 environment is
11741 .code
11742 daemon_smtp_ports = smtp
11743 local_interfaces = <; ::0 ; 0.0.0.0
11744 .endd
11745 This specifies listening on the smtp port on all IPv6 and IPv4 interfaces.
11746 Either one or two sockets may be used, depending on the characteristics of
11747 the TCP/IP stack. (This is complicated and messy; for more information,
11748 read the comments in the &_daemon.c_& source file.)
11749
11750 To specify listening on ports 25 and 26 on all interfaces:
11751 .code
11752 daemon_smtp_ports = 25 : 26
11753 .endd
11754 (leaving &%local_interfaces%& at the default setting) or, more explicitly:
11755 .code
11756 local_interfaces = <; ::0.25     ; ::0.26 \
11757                       0.0.0.0.25 ; 0.0.0.0.26
11758 .endd
11759 To listen on the default port on all IPv4 interfaces, and on port 26 on the
11760 IPv4 loopback address only:
11761 .code
11762 local_interfaces = 0.0.0.0 : 127.0.0.1.26
11763 .endd
11764 To specify listening on the default port on specific interfaces only:
11765 .code
11766 local_interfaces = 192.168.34.67 : 192.168.34.67
11767 .endd
11768 &*Warning*&: Such a setting excludes listening on the loopback interfaces.
11769
11770
11771
11772 .section "Recognising the local host" "SECTreclocipadd"
11773 The &%local_interfaces%& option is also used when Exim needs to determine
11774 whether or not an IP address refers to the local host. That is, the IP
11775 addresses of all the interfaces on which a daemon is listening are always
11776 treated as local.
11777
11778 For this usage, port numbers in &%local_interfaces%& are ignored. If either of
11779 the items 0.0.0.0 or ::0 are encountered, Exim gets a complete list of
11780 available interfaces from the operating system, and extracts the relevant
11781 (that is, IPv4 or IPv6) addresses to use for checking.
11782
11783 Some systems set up large numbers of virtual interfaces in order to provide
11784 many virtual web servers. In this situation, you may want to listen for
11785 email on only a few of the available interfaces, but nevertheless treat all
11786 interfaces as local when routing. You can do this by setting
11787 &%extra_local_interfaces%& to a list of IP addresses, possibly including the
11788 &"all"& wildcard values. These addresses are recognized as local, but are not
11789 used for listening. Consider this example:
11790 .code
11791 local_interfaces = <; 127.0.0.1 ; ::1 ; \
11792                       192.168.53.235 ; \
11793                       3ffe:2101:12:1:a00:20ff:fe86:a061
11794
11795 extra_local_interfaces = <; ::0 ; 0.0.0.0
11796 .endd
11797 The daemon listens on the loopback interfaces and just one IPv4 and one IPv6
11798 address, but all available interface addresses are treated as local when
11799 Exim is routing.
11800
11801 In some environments the local host name may be in an MX list, but with an IP
11802 address that is not assigned to any local interface. In other cases it may be
11803 desirable to treat other host names as if they referred to the local host. Both
11804 these cases can be handled by setting the &%hosts_treat_as_local%& option.
11805 This contains host names rather than IP addresses. When a host is referenced
11806 during routing, either via an MX record or directly, it is treated as the local
11807 host if its name matches &%hosts_treat_as_local%&, or if any of its IP
11808 addresses match &%local_interfaces%& or &%extra_local_interfaces%&.
11809
11810
11811
11812 .section "Delivering to a remote host"
11813 Delivery to a remote host is handled by the smtp transport. By default, it
11814 allows the system's TCP/IP functions to choose which interface to use (if
11815 there is more than one) when connecting to a remote host. However, the
11816 &%interface%& option can be set to specify which interface is used. See the
11817 description of the smtp transport in chapter &<<CHAPsmtptrans>>& for more
11818 details.
11819
11820
11821
11822
11823 . ////////////////////////////////////////////////////////////////////////////
11824 . ////////////////////////////////////////////////////////////////////////////
11825
11826 .chapter "Main configuration" "CHAPmainconfig"
11827 .scindex IIDconfima "configuration file" "main section"
11828 .scindex IIDmaiconf "main configuration"
11829 The first part of the run time configuration file contains three types of item:
11830
11831 .ilist
11832 Macro definitions: These lines start with an upper case letter. See section
11833 &<<SECTmacrodefs>>& for details of macro processing.
11834 .next
11835 Named list definitions: These lines start with one of the words &"domainlist"&,
11836 &"hostlist"&, &"addresslist"&, or &"localpartlist"&. Their use is described in
11837 section &<<SECTnamedlists>>&.
11838 .next
11839 Main configuration settings: Each setting occupies one line of the file
11840 (with possible continuations). If any setting is preceded by the word
11841 &"hide"&, the &%-bP%& command line option displays its value to admin users
11842 only. See section &<<SECTcos>>& for a description of the syntax of these option
11843 settings.
11844 .endlist
11845
11846 This chapter specifies all the main configuration options, along with their
11847 types and default values. For ease of finding a particular option, they appear
11848 in alphabetical order in section &<<SECTalomo>>& below. However, because there
11849 are now so many options, they are first listed briefly in functional groups, as
11850 an aid to finding the name of the option you are looking for. Some options are
11851 listed in more than one group.
11852
11853 .section "Miscellaneous"
11854 .table2
11855 .row &%bi_command%&                  "to run for &%-bi%& command line option"
11856 .row &%disable_ipv6%&                "do no IPv6 processing"
11857 .row &%keep_malformed%&              "for broken files &-- should not happen"
11858 .row &%localhost_number%&            "for unique message ids in clusters"
11859 .row &%message_body_visible%&        "how much to show in &$message_body$&"
11860 .row &%mua_wrapper%&                 "run in &""MUA wrapper""& mode"
11861 .row &%print_topbitchars%&           "top-bit characters are printing"
11862 .row &%timezone%&                    "force time zone"
11863 .endtable
11864
11865
11866 .section "Exim parameters"
11867 .table2
11868 .row &%exim_group%&                  "override compiled-in value"
11869 .row &%exim_path%&                   "override compiled-in value"
11870 .row &%exim_user%&                   "override compiled-in value"
11871 .row &%primary_hostname%&            "default from &[uname()]&"
11872 .row &%split_spool_directory%&       "use multiple directories"
11873 .row &%spool_directory%&             "override compiled-in value"
11874 .endtable
11875
11876
11877
11878 .section "Privilege controls"
11879 .table2
11880 .row &%admin_groups%&                "groups that are Exim admin users"
11881 .row &%deliver_drop_privilege%&      "drop root for delivery processes"
11882 .row &%local_from_check%&            "insert &'Sender:'& if necessary"
11883 .row &%local_from_prefix%&           "for testing &'From:'& for local sender"
11884 .row &%local_from_suffix%&           "for testing &'From:'& for local sender"
11885 .row &%local_sender_retain%&         "keep &'Sender:'& from untrusted user"
11886 .row &%never_users%&                 "do not run deliveries as these"
11887 .row &%prod_requires_admin%&         "forced delivery requires admin user"
11888 .row &%queue_list_requires_admin%&   "queue listing requires admin user"
11889 .row &%trusted_groups%&              "groups that are trusted"
11890 .row &%trusted_users%&               "users that are trusted"
11891 .endtable
11892
11893
11894
11895 .section "Logging"
11896 .table2
11897 .row &%hosts_connection_nolog%&      "exemption from connect logging"
11898 .row &%log_file_path%&               "override compiled-in value"
11899 .row &%log_selector%&                "set/unset optional logging"
11900 .row &%log_timezone%&                "add timezone to log lines"
11901 .row &%message_logs%&                "create per-message logs"
11902 .row &%preserve_message_logs%&       "after message completion"
11903 .row &%process_log_path%&            "for SIGUSR1 and &'exiwhat'&"
11904 .row &%syslog_duplication%&          "controls duplicate log lines on syslog"
11905 .row &%syslog_facility%&             "set syslog &""facility""& field"
11906 .row &%syslog_processname%&          "set syslog &""ident""& field"
11907 .row &%syslog_timestamp%&            "timestamp syslog lines"
11908 .row &%write_rejectlog%&             "control use of message log"
11909 .endtable
11910
11911
11912
11913 .section "Frozen messages"
11914 .table2
11915 .row &%auto_thaw%&                   "sets time for retrying frozen messages"
11916 .row &%freeze_tell%&                 "send message when freezing"
11917 .row &%move_frozen_messages%&        "to another directory"
11918 .row &%timeout_frozen_after%&        "keep frozen messages only so long"
11919 .endtable
11920
11921
11922
11923 .section "Data lookups"
11924 .table2
11925 .row &%ldap_default_servers%&        "used if no server in query"
11926 .row &%ldap_version%&                "set protocol version"
11927 .row &%lookup_open_max%&             "lookup files held open"
11928 .row &%mysql_servers%&               "as it says"
11929 .row &%oracle_servers%&              "as it says"
11930 .row &%pgsql_servers%&               "as it says"
11931 .row &%sqlite_lock_timeout%&         "as it says"
11932 .endtable
11933
11934
11935
11936 .section "Message ids"
11937 .table2
11938 .row &%message_id_header_domain%&    "used to build &'Message-ID:'& header"
11939 .row &%message_id_header_text%&      "ditto"
11940 .endtable
11941
11942
11943
11944 .section "Embedded Perl Startup"
11945 .table2
11946 .row &%perl_at_start%&               "always start the interpreter"
11947 .row &%perl_startup%&                "code to obey when starting Perl"
11948 .endtable
11949
11950
11951
11952 .section "Daemon"
11953 .table2
11954 .row &%daemon_smtp_ports%&           "default ports"
11955 .row &%daemon_startup_retries%&      "number of times to retry"
11956 .row &%daemon_startup_sleep%&        "time to sleep between tries"
11957 .row &%extra_local_interfaces%&      "not necessarily listened on"
11958 .row &%local_interfaces%&            "on which to listen, with optional ports"
11959 .row &%pid_file_path%&               "override compiled-in value"
11960 .row &%queue_run_max%&               "maximum simultaneous queue runners"
11961 .endtable
11962
11963
11964
11965 .section "Resource control"
11966 .table2
11967 .row &%check_log_inodes%&            "before accepting a message"
11968 .row &%check_log_space%&             "before accepting a message"
11969 .row &%check_spool_inodes%&          "before accepting a message"
11970 .row &%check_spool_space%&           "before accepting a message"
11971 .row &%deliver_queue_load_max%&      "no queue deliveries if load high"
11972 .row &%queue_only_load%&             "queue incoming if load high"
11973 .row &%queue_run_max%&               "maximum simultaneous queue runners"
11974 .row &%remote_max_parallel%&         "parallel SMTP delivery per message"
11975 .row &%smtp_accept_max%&             "simultaneous incoming connections"
11976 .row &%smtp_accept_max_nonmail%&     "non-mail commands"
11977 .row &%smtp_accept_max_nonmail_hosts%& "hosts to which the limit applies"
11978 .row &%smtp_accept_max_per_connection%& "messages per connection"
11979 .row &%smtp_accept_max_per_host%&    "connections from one host"
11980 .row &%smtp_accept_queue%&           "queue mail if more connections"
11981 .row &%smtp_accept_queue_per_connection%& "queue if more messages per &&&
11982                                            connection"
11983 .row &%smtp_accept_reserve%&         "only reserve hosts if more connections"
11984 .row &%smtp_check_spool_space%&      "from SIZE on MAIL command"
11985 .row &%smtp_connect_backlog%&        "passed to TCP/IP stack"
11986 .row &%smtp_load_reserve%&           "SMTP from reserved hosts if load high"
11987 .row &%smtp_reserve_hosts%&          "these are the reserve hosts"
11988 .endtable
11989
11990
11991
11992 .section "Policy controls"
11993 .table2
11994 .row &%acl_not_smtp%&                "ACL for non-SMTP messages"
11995 .row &%acl_not_smtp_mime%&           "ACL for non-SMTP MIME parts"
11996 .row &%acl_not_smtp_start%&          "ACL for start of non-SMTP message"
11997 .row &%acl_smtp_auth%&               "ACL for AUTH"
11998 .row &%acl_smtp_connect%&            "ACL for connection"
11999 .row &%acl_smtp_data%&               "ACL for DATA"
12000 .row &%acl_smtp_etrn%&               "ACL for ETRN"
12001 .row &%acl_smtp_expn%&               "ACL for EXPN"
12002 .row &%acl_smtp_helo%&               "ACL for EHLO or HELO"
12003 .row &%acl_smtp_mail%&               "ACL for MAIL"
12004 .row &%acl_smtp_mailauth%&           "ACL for AUTH on MAIL command"
12005 .row &%acl_smtp_mime%&               "ACL for MIME parts"
12006 .row &%acl_smtp_predata%&            "ACL for start of data"
12007 .row &%acl_smtp_quit%&               "ACL for QUIT"
12008 .row &%acl_smtp_rcpt%&               "ACL for RCPT"
12009 .row &%acl_smtp_starttls%&           "ACL for STARTTLS"
12010 .row &%acl_smtp_vrfy%&               "ACL for VRFY"
12011 .row &%av_scanner%&                  "specify virus scanner"
12012 .row &%check_rfc2047_length%&        "check length of RFC 2047 &""encoded &&&
12013                                       words""&"
12014 .row &%dns_csa_search_limit%&        "control CSA parent search depth"
12015 .row &%dns_csa_use_reverse%&         "en/disable CSA IP reverse search"
12016 .row &%header_maxsize%&              "total size of message header"
12017 .row &%header_line_maxsize%&         "individual header line limit"
12018 .row &%helo_accept_junk_hosts%&      "allow syntactic junk from these hosts"
12019 .row &%helo_allow_chars%&            "allow illegal chars in HELO names"
12020 .row &%helo_lookup_domains%&         "lookup hostname for these HELO names"
12021 .row &%helo_try_verify_hosts%&       "HELO soft-checked for these hosts"
12022 .row &%helo_verify_hosts%&           "HELO hard-checked for these hosts"
12023 .row &%host_lookup%&                 "host name looked up for these hosts"
12024 .row &%host_lookup_order%&           "order of DNS and local name lookups"
12025 .row &%host_reject_connection%&      "reject connection from these hosts"
12026 .row &%hosts_treat_as_local%&        "useful in some cluster configurations"
12027 .row &%local_scan_timeout%&          "timeout for &[local_scan()]&"
12028 .row &%message_size_limit%&          "for all messages"
12029 .row &%percent_hack_domains%&        "recognize %-hack for these domains"
12030 .row &%spamd_address%&               "set interface to SpamAssassin"
12031 .row &%strict_acl_vars%&             "object to unset ACL variables"
12032 .endtable
12033
12034
12035
12036 .section "Callout cache"
12037 .table2
12038 .row &%callout_domain_negative_expire%& "timeout for negative domain cache &&&
12039                                          item"
12040 .row &%callout_domain_positive_expire%& "timeout for positive domain cache &&&
12041                                          item"
12042 .row &%callout_negative_expire%&     "timeout for negative address cache item"
12043 .row &%callout_positive_expire%&     "timeout for positive address cache item"
12044 .row &%callout_random_local_part%&   "string to use for &""random""& testing"
12045 .endtable
12046
12047
12048
12049 .section "TLS"
12050 .table2
12051 .row &%tls_advertise_hosts%&         "advertise TLS to these hosts"
12052 .row &%tls_certificate%&             "location of server certificate"
12053 .row &%tls_crl%&                     "certificate revocation list"
12054 .row &%tls_dhparam%&                 "DH parameters for server"
12055 .row &%tls_on_connect_ports%&        "specify SSMTP (SMTPS) ports"
12056 .row &%tls_privatekey%&              "location of server private key"
12057 .row &%tls_remember_esmtp%&          "don't reset after starting TLS"
12058 .row &%tls_require_ciphers%&         "specify acceptable cipers"
12059 .row &%tls_try_verify_hosts%&        "try to verify client certificate"
12060 .row &%tls_verify_certificates%&     "expected client certificates"
12061 .row &%tls_verify_hosts%&            "insist on client certificate verify"
12062 .endtable
12063
12064
12065
12066 .section "Local user handling"
12067 .table2
12068 .row &%finduser_retries%&            "useful in NIS environments"
12069 .row &%gecos_name%&                  "used when creating &'Sender:'&"
12070 .row &%gecos_pattern%&               "ditto"
12071 .row &%max_username_length%&         "for systems that truncate"
12072 .row &%unknown_login%&               "used when no login name found"
12073 .row &%unknown_username%&            "ditto"
12074 .row &%uucp_from_pattern%&           "for recognizing &""From ""& lines"
12075 .row &%uucp_from_sender%&            "ditto"
12076 .endtable
12077
12078
12079
12080 .section "All incoming messages (SMTP and non-SMTP)"
12081 .table2
12082 .row &%header_maxsize%&              "total size of message header"
12083 .row &%header_line_maxsize%&         "individual header line limit"
12084 .row &%message_size_limit%&          "applies to all messages"
12085 .row &%percent_hack_domains%&        "recognize %-hack for these domains"
12086 .row &%received_header_text%&        "expanded to make &'Received:'&"
12087 .row &%received_headers_max%&        "for mail loop detection"
12088 .row &%recipients_max%&              "limit per message"
12089 .row &%recipients_max_reject%&       "permanently reject excess"
12090 .endtable
12091
12092
12093
12094
12095 .section "Non-SMTP incoming messages"
12096 .table2
12097 .row &%receive_timeout%&             "for non-SMTP messages"
12098 .endtable
12099
12100
12101
12102
12103
12104 .section "Incoming SMTP messages"
12105 See also the &'Policy controls'& section above.
12106
12107 .table2
12108 .row &%host_lookup%&                 "host name looked up for these hosts"
12109 .row &%host_lookup_order%&           "order of DNS and local name lookups"
12110 .row &%recipient_unqualified_hosts%& "may send unqualified recipients"
12111 .row &%rfc1413_hosts%&               "make ident calls to these hosts"
12112 .row &%rfc1413_query_timeout%&       "zero disables ident calls"
12113 .row &%sender_unqualified_hosts%&    "may send unqualified senders"
12114 .row &%smtp_accept_keepalive%&       "some TCP/IP magic"
12115 .row &%smtp_accept_max%&             "simultaneous incoming connections"
12116 .row &%smtp_accept_max_nonmail%&     "non-mail commands"
12117 .row &%smtp_accept_max_nonmail_hosts%& "hosts to which the limit applies"
12118 .row &%smtp_accept_max_per_connection%& "messages per connection"
12119 .row &%smtp_accept_max_per_host%&    "connections from one host"
12120 .row &%smtp_accept_queue%&           "queue mail if more connections"
12121 .row &%smtp_accept_queue_per_connection%& "queue if more messages per &&&
12122                                            connection"
12123 .row &%smtp_accept_reserve%&         "only reserve hosts if more connections"
12124 .row &%smtp_active_hostname%&        "host name to use in messages"
12125 .row &%smtp_banner%&                 "text for welcome banner"
12126 .row &%smtp_check_spool_space%&      "from SIZE on MAIL command"
12127 .row &%smtp_connect_backlog%&        "passed to TCP/IP stack"
12128 .row &%smtp_enforce_sync%&           "of SMTP command/responses"
12129 .row &%smtp_etrn_command%&           "what to run for ETRN"
12130 .row &%smtp_etrn_serialize%&         "only one at once"
12131 .row &%smtp_load_reserve%&           "only reserve hosts if this load"
12132 .row &%smtp_max_unknown_commands%&   "before dropping connection"
12133 .row &%smtp_ratelimit_hosts%&        "apply ratelimiting to these hosts"
12134 .row &%smtp_ratelimit_mail%&         "ratelimit for MAIL commands"
12135 .row &%smtp_ratelimit_rcpt%&         "ratelimit for RCPT commands"
12136 .row &%smtp_receive_timeout%&        "per command or data line"
12137 .row &%smtp_reserve_hosts%&          "these are the reserve hosts"
12138 .row &%smtp_return_error_details%&   "give detail on rejections"
12139 .endtable
12140
12141
12142
12143 .section "SMTP extensions"
12144 .table2
12145 .row &%accept_8bitmime%&             "advertise 8BITMIME"
12146 .row &%auth_advertise_hosts%&        "advertise AUTH to these hosts"
12147 .row &%ignore_fromline_hosts%&       "allow &""From ""& from these hosts"
12148 .row &%ignore_fromline_local%&       "allow &""From ""& from local SMTP"
12149 .row &%pipelining_advertise_hosts%&  "advertise pipelining to these hosts"
12150 .row &%tls_advertise_hosts%&         "advertise TLS to these hosts"
12151 .endtable
12152
12153
12154
12155 .section "Processing messages"
12156 .table2
12157 .row &%allow_domain_literals%&       "recognize domain literal syntax"
12158 .row &%allow_mx_to_ip%&              "allow MX to point to IP address"
12159 .row &%allow_utf8_domains%&          "in addresses"
12160 .row &%check_rfc2047_length%&        "check length of RFC 2047 &""encoded &&&
12161                                       words""&"
12162 .row &%delivery_date_remove%&        "from incoming messages"
12163 .row &%envelope_to_remove%&          "from incoming messages"
12164 .row &%extract_addresses_remove_arguments%& "affects &%-t%& processing"
12165 .row &%headers_charset%&             "default for translations"
12166 .row &%qualify_domain%&              "default for senders"
12167 .row &%qualify_recipient%&           "default for recipients"
12168 .row &%return_path_remove%&          "from incoming messages"
12169 .row &%strip_excess_angle_brackets%& "in addresses"
12170 .row &%strip_trailing_dot%&          "at end of addresses"
12171 .row &%untrusted_set_sender%&        "untrusted can set envelope sender"
12172 .endtable
12173
12174
12175
12176 .section "System filter"
12177 .table2
12178 .row &%system_filter%&               "locate system filter"
12179 .row &%system_filter_directory_transport%& "transport for delivery to a &&&
12180                                             directory"
12181 .row &%system_filter_file_transport%& "transport for delivery to a file"
12182 .row &%system_filter_group%&         "group for filter running"
12183 .row &%system_filter_pipe_transport%& "transport for delivery to a pipe"
12184 .row &%system_filter_reply_transport%& "transport for autoreply delivery"
12185 .row &%system_filter_user%&          "user for filter running"
12186 .endtable
12187
12188
12189
12190 .section "Routing and delivery"
12191 .table2
12192 .row &%disable_ipv6%&                "do no IPv6 processing"
12193 .row &%dns_again_means_nonexist%&    "for broken domains"
12194 .row &%dns_check_names_pattern%&     "pre-DNS syntax check"
12195 .row &%dns_ipv4_lookup%&             "only v4 lookup for these domains"
12196 .row &%dns_retrans%&                 "parameter for resolver"
12197 .row &%dns_retry%&                   "parameter for resolver"
12198 .row &%hold_domains%&                "hold delivery for these domains"
12199 .row &%local_interfaces%&            "for routing checks"
12200 .row &%queue_domains%&               "no immediate delivery for these"
12201 .row &%queue_only%&                  "no immediate delivery at all"
12202 .row &%queue_only_file%&             "no immediate delivery if file exists"
12203 .row &%queue_only_load%&             "no immediate delivery if load is high"
12204 .row &%queue_only_override%&         "allow command line to override"
12205 .row &%queue_run_in_order%&          "order of arrival"
12206 .row &%queue_run_max%&               "of simultaneous queue runners"
12207 .row &%queue_smtp_domains%&          "no immediate SMTP delivery for these"
12208 .row &%remote_max_parallel%&         "parallel SMTP delivery per message"
12209 .row &%remote_sort_domains%&         "order of remote deliveries"
12210 .row &%retry_data_expire%&           "timeout for retry data"
12211 .row &%retry_interval_max%&          "safety net for retry rules"
12212 .endtable
12213
12214
12215
12216 .section "Bounce and warning messages"
12217 .table2
12218 .row &%bounce_message_file%&         "content of bounce"
12219 .row &%bounce_message_text%&         "content of bounce"
12220 .row &%bounce_return_body%&          "include body if returning message"
12221 .row &%bounce_return_message%&       "include original message in bounce"
12222 .row &%bounce_return_size_limit%&    "limit on returned message"
12223 .row &%bounce_sender_authentication%& "send authenticated sender with bounce"
12224 .row &%errors_copy%&                 "copy bounce messages"
12225 .row &%errors_reply_to%&             "&'Reply-to:'& in bounces"
12226 .row &%delay_warning%&               "time schedule"
12227 .row &%delay_warning_condition%&     "condition for warning messages"
12228 .row &%ignore_bounce_errors_after%&  "discard undeliverable bounces"
12229 .row &%smtp_return_error_details%&   "give detail on rejections"
12230 .row &%warn_message_file%&           "content of warning message"
12231 .endtable
12232
12233
12234
12235 .section "Alphabetical list of main options" "SECTalomo"
12236 Those options that undergo string expansion before use are marked with
12237 &dagger;.
12238
12239 .option accept_8bitmime main boolean false
12240 .cindex "8BITMIME"
12241 .cindex "8-bit characters"
12242 This option causes Exim to send 8BITMIME in its response to an SMTP
12243 EHLO command, and to accept the BODY= parameter on MAIL commands.
12244 However, though Exim is 8-bit clean, it is not a protocol converter, and it
12245 takes no steps to do anything special with messages received by this route.
12246 Consequently, this option is turned off by default.
12247
12248 .option acl_not_smtp main string&!! unset
12249 .cindex "&ACL;" "for non-SMTP messages"
12250 .cindex "non-SMTP messages" "ACLs for"
12251 This option defines the ACL that is run when a non-SMTP message has been
12252 read and is on the point of being accepted. See chapter &<<CHAPACL>>& for
12253 further details.
12254
12255 .option acl_not_smtp_mime main string&!! unset
12256 This option defines the ACL that is run for individual MIME parts of non-SMTP
12257 messages. It operates in exactly the same way as &%acl_smtp_mime%& operates for
12258 SMTP messages.
12259
12260 .option acl_not_smtp_start main string&!! unset
12261 .cindex "&ACL;" "at start of non-SMTP message"
12262 .cindex "non-SMTP messages" "ACLs for"
12263 This option defines the ACL that is run before Exim starts reading a
12264 non-SMTP message. See chapter &<<CHAPACL>>& for further details.
12265
12266 .option acl_smtp_auth main string&!! unset
12267 .cindex "&ACL;" "setting up for SMTP commands"
12268 .cindex "AUTH" "ACL for"
12269 This option defines the ACL that is run when an SMTP AUTH command is
12270 received. See chapter &<<CHAPACL>>& for further details.
12271
12272 .option acl_smtp_connect main string&!! unset
12273 .cindex "&ACL;" "on SMTP connection"
12274 This option defines the ACL that is run when an SMTP connection is received.
12275 See chapter &<<CHAPACL>>& for further details.
12276
12277 .option acl_smtp_data main string&!! unset
12278 .cindex "DATA" "ACL for"
12279 This option defines the ACL that is run after an SMTP DATA command has been
12280 processed and the message itself has been received, but before the final
12281 acknowledgement is sent. See chapter &<<CHAPACL>>& for further details.
12282
12283 .option acl_smtp_etrn main string&!! unset
12284 .cindex "ETRN" "ACL for"
12285 This option defines the ACL that is run when an SMTP ETRN command is
12286 received. See chapter &<<CHAPACL>>& for further details.
12287
12288 .option acl_smtp_expn main string&!! unset
12289 .cindex "EXPN" "ACL for"
12290 This option defines the ACL that is run when an SMTP EXPN command is
12291 received. See chapter &<<CHAPACL>>& for further details.
12292
12293 .option acl_smtp_helo main string&!! unset
12294 .cindex "EHLO" "ACL for"
12295 .cindex "HELO" "ACL for"
12296 This option defines the ACL that is run when an SMTP EHLO or HELO
12297 command is received. See chapter &<<CHAPACL>>& for further details.
12298
12299
12300 .option acl_smtp_mail main string&!! unset
12301 .cindex "MAIL" "ACL for"
12302 This option defines the ACL that is run when an SMTP MAIL command is
12303 received. See chapter &<<CHAPACL>>& for further details.
12304
12305 .option acl_smtp_mailauth main string&!! unset
12306 .cindex "AUTH" "on MAIL command"
12307 This option defines the ACL that is run when there is an AUTH parameter on
12308 a MAIL command. See chapter &<<CHAPACL>>& for details of ACLs, and chapter
12309 &<<CHAPSMTPAUTH>>& for details of authentication.
12310
12311 .option acl_smtp_mime main string&!! unset
12312 .cindex "MIME content scanning" "ACL for"
12313 This option is available when Exim is built with the content-scanning
12314 extension. It defines the ACL that is run for each MIME part in a message. See
12315 section &<<SECTscanmimepart>>& for details.
12316
12317 .option acl_smtp_predata main string&!! unset
12318 This option defines the ACL that is run when an SMTP DATA command is
12319 received, before the message itself is received. See chapter &<<CHAPACL>>& for
12320 further details.
12321
12322 .option acl_smtp_quit main string&!! unset
12323 .cindex "QUIT" "ACL for"
12324 This option defines the ACL that is run when an SMTP QUIT command is
12325 received. See chapter &<<CHAPACL>>& for further details.
12326
12327 .option acl_smtp_rcpt main string&!! unset
12328 .cindex "RCPT" "ACL for"
12329 This option defines the ACL that is run when an SMTP RCPT command is
12330 received. See chapter &<<CHAPACL>>& for further details.
12331
12332 .option acl_smtp_starttls main string&!! unset
12333 .cindex "STARTTLS" "ACL for"
12334 This option defines the ACL that is run when an SMTP STARTTLS command is
12335 received. See chapter &<<CHAPACL>>& for further details.
12336
12337 .option acl_smtp_vrfy main string&!! unset
12338 .cindex "VRFY" "ACL for"
12339 This option defines the ACL that is run when an SMTP VRFY command is
12340 received. See chapter &<<CHAPACL>>& for further details.
12341
12342 .option admin_groups main "string list&!!" unset
12343 .cindex "admin user"
12344 This option is expanded just once, at the start of Exim's processing. If the
12345 current group or any of the supplementary groups of an Exim caller is in this
12346 colon-separated list, the caller has admin privileges. If all your system
12347 programmers are in a specific group, for example, you can give them all Exim
12348 admin privileges by putting that group in &%admin_groups%&. However, this does
12349 not permit them to read Exim's spool files (whose group owner is the Exim gid).
12350 To permit this, you have to add individuals to the Exim group.
12351
12352 .option allow_domain_literals main boolean false
12353 .cindex "domain literal"
12354 If this option is set, the RFC 2822 domain literal format is permitted in
12355 email addresses. The option is not set by default, because the domain literal
12356 format is not normally required these days, and few people know about it. It
12357 has, however, been exploited by mail abusers.
12358
12359 Unfortunately, it seems that some DNS black list maintainers are using this
12360 format to report black listing to postmasters. If you want to accept messages
12361 addressed to your hosts by IP address, you need to set
12362 &%allow_domain_literals%& true, and also to add &`@[]`& to the list of local
12363 domains (defined in the named domain list &%local_domains%& in the default
12364 configuration). This &"magic string"& matches the domain literal form of all
12365 the local host's IP addresses.
12366
12367
12368 .option allow_mx_to_ip main boolean false
12369 .cindex "MX record" "pointing to IP address"
12370 It appears that more and more DNS zone administrators are breaking the rules
12371 and putting domain names that look like IP addresses on the right hand side of
12372 MX records. Exim follows the rules and rejects this, giving an error message
12373 that explains the mis-configuration. However, some other MTAs support this
12374 practice, so to avoid &"Why can't Exim do this?"& complaints,
12375 &%allow_mx_to_ip%& exists, in order to enable this heinous activity. It is not
12376 recommended, except when you have no other choice.
12377
12378 .option allow_utf8_domains main boolean false
12379 .cindex "domain" "UTF-8 characters in"
12380 .cindex "UTF-8" "in domain name"
12381 Lots of discussion is going on about internationalized domain names. One
12382 camp is strongly in favour of just using UTF-8 characters, and it seems
12383 that at least two other MTAs permit this. This option allows Exim users to
12384 experiment if they wish.
12385
12386 If it is set true, Exim's domain parsing function allows valid
12387 UTF-8 multicharacters to appear in domain name components, in addition to
12388 letters, digits, and hyphens. However, just setting this option is not
12389 enough; if you want to look up these domain names in the DNS, you must also
12390 adjust the value of &%dns_check_names_pattern%& to match the extended form. A
12391 suitable setting is:
12392 .code
12393 dns_check_names_pattern = (?i)^(?>(?(1)\.|())[a-z0-9\xc0-\xff]\
12394   (?>[-a-z0-9\x80-\xff]*[a-z0-9\x80-\xbf])?)+$
12395 .endd
12396 Alternatively, you can just disable this feature by setting
12397 .code
12398 dns_check_names_pattern =
12399 .endd
12400 That is, set the option to an empty string so that no check is done.
12401
12402
12403 .option auth_advertise_hosts main "host list&!!" *
12404 .cindex "authentication" "advertising"
12405 .cindex "AUTH" "advertising"
12406 If any server authentication mechanisms are configured, Exim advertises them in
12407 response to an EHLO command only if the calling host matches this list.
12408 Otherwise, Exim does not advertise AUTH.
12409 Exim does not accept AUTH commands from clients to which it has not
12410 advertised the availability of AUTH. The advertising of individual
12411 authentication mechanisms can be controlled by the use of the
12412 &%server_advertise_condition%& generic authenticator option on the individual
12413 authenticators. See chapter &<<CHAPSMTPAUTH>>& for further details.
12414
12415 Certain mail clients (for example, Netscape) require the user to provide a name
12416 and password for authentication if AUTH is advertised, even though it may
12417 not be needed (the host may accept messages from hosts on its local LAN without
12418 authentication, for example). The &%auth_advertise_hosts%& option can be used
12419 to make these clients more friendly by excluding them from the set of hosts to
12420 which Exim advertises AUTH.
12421
12422 .cindex "AUTH" "advertising when encrypted"
12423 If you want to advertise the availability of AUTH only when the connection
12424 is encrypted using TLS, you can make use of the fact that the value of this
12425 option is expanded, with a setting like this:
12426 .code
12427 auth_advertise_hosts = ${if eq{$tls_cipher}{}{}{*}}
12428 .endd
12429 .cindex "&$tls_cipher$&"
12430 If &$tls_cipher$& is empty, the session is not encrypted, and the result of
12431 the expansion is empty, thus matching no hosts. Otherwise, the result of the
12432 expansion is *, which matches all hosts.
12433
12434
12435 .option auto_thaw main time 0s
12436 .cindex "thawing messages"
12437 .cindex "unfreezing messages"
12438 If this option is set to a time greater than zero, a queue runner will try a
12439 new delivery attempt on any frozen message, other than a bounce message, if
12440 this much time has passed since it was frozen. This may result in the message
12441 being re-frozen if nothing has changed since the last attempt. It is a way of
12442 saying &"keep on trying, even though there are big problems"&.
12443
12444 &*Note*&: This is an old option, which predates &%timeout_frozen_after%& and
12445 &%ignore_bounce_errors_after%&. It is retained for compatibility, but it is not
12446 thought to be very useful any more, and its use should probably be avoided.
12447
12448 .option av_scanner main string "see below"
12449 This option is available if Exim is built with the content-scanning extension.
12450 It specifies which anti-virus scanner to use. The default value is:
12451 .code
12452 sophie:/var/run/sophie
12453 .endd
12454 If the value of &%av_scanner%& starts with dollar character, it is expanded
12455 before use. See section &<<SECTscanvirus>>& for further details.
12456
12457
12458
12459 .option bi_command main string unset
12460 .cindex "&%-bi%& option"
12461 This option supplies the name of a command that is run when Exim is called with
12462 the &%-bi%& option (see chapter &<<CHAPcommandline>>&). The string value is
12463 just the command name, it is not a complete command line. If an argument is
12464 required, it must come from the &%-oA%& command line option.
12465
12466
12467 .option bounce_message_file main string unset
12468 .cindex "bounce message" "customizing"
12469 .cindex "customizing" "bounce message"
12470 This option defines a template file containing paragraphs of text to be used
12471 for constructing bounce messages.  Details of the file's contents are given in
12472 chapter &<<CHAPemsgcust>>&. See also &%warn_message_file%&.
12473
12474
12475 .option bounce_message_text main string unset
12476 When this option is set, its contents are included in the default bounce
12477 message immediately after &"This message was created automatically by mail
12478 delivery software."& It is not used if &%bounce_message_file%& is set.
12479
12480 .option bounce_return_body main boolean true
12481 .cindex "bounce message" "including body"
12482 This option controls whether the body of an incoming message is included in a
12483 bounce message when &%bounce_return_message%& is true. The default setting
12484 causes the entire message, both header and body, to be returned (subject to the
12485 value of &%bounce_return_size_limit%&). If this option is false, only the
12486 message header is included. In the case of a non-SMTP message containing an
12487 error that is detected during reception, only those header lines preceding the
12488 point at which the error was detected are returned.
12489 .cindex "bounce message" "including original"
12490
12491 .option bounce_return_message main boolean true
12492 If this option is set false, none of the original message is included in
12493 bounce messages generated by Exim. See also &%bounce_return_size_limit%& and
12494 &%bounce_return_body%&.
12495
12496
12497 .option bounce_return_size_limit main integer 100K
12498 .cindex "size limit" "of bounce"
12499 .cindex "bounce message" "size limit"
12500 .cindex "limit" "bounce message size"
12501 This option sets a limit in bytes on the size of messages that are returned to
12502 senders as part of bounce messages when &%bounce_return_message%& is true. The
12503 limit should be less than the value of the global &%message_size_limit%& and of
12504 any &%message_size_limit%& settings on transports, to allow for the bounce text
12505 that Exim generates. If this option is set to zero there is no limit.
12506
12507 When the body of any message that is to be included in a bounce message is
12508 greater than the limit, it is truncated, and a comment pointing this out is
12509 added at the top. The actual cutoff may be greater than the value given, owing
12510 to the use of buffering for transferring the message in chunks (typically 8K in
12511 size). The idea is to save bandwidth on those undeliverable 15-megabyte
12512 messages.
12513
12514 .option bounce_sender_authentication main string unset
12515 .cindex "bounce message" "sender authentication"
12516 .cindex "authentication" "bounce message"
12517 .cindex "AUTH" "on bounce message"
12518 This option provides an authenticated sender address that is sent with any
12519 bounce messages generated by Exim that are sent over an authenticated SMTP
12520 connection. A typical setting might be:
12521 .code
12522 bounce_sender_authentication = mailer-daemon@my.domain.example
12523 .endd
12524 which would cause bounce messages to be sent using the SMTP command:
12525 .code
12526 MAIL FROM:<> AUTH=mailer-daemon@my.domain.example
12527 .endd
12528 The value of &%bounce_sender_authentication%& must always be a complete email
12529 address.
12530
12531 .option callout_domain_negative_expire main time 3h
12532 .cindex "caching" "callout timeouts"
12533 .cindex "callout" "caching timeouts"
12534 This option specifies the expiry time for negative callout cache data for a
12535 domain. See section &<<SECTcallver>>& for details of callout verification, and
12536 section &<<SECTcallvercache>>& for details of the caching.
12537
12538
12539 .option callout_domain_positive_expire main time 7d
12540 This option specifies the expiry time for positive callout cache data for a
12541 domain. See section &<<SECTcallver>>& for details of callout verification, and
12542 section &<<SECTcallvercache>>& for details of the caching.
12543
12544
12545 .option callout_negative_expire main time 2h
12546 This option specifies the expiry time for negative callout cache data for an
12547 address. See section &<<SECTcallver>>& for details of callout verification, and
12548 section &<<SECTcallvercache>>& for details of the caching.
12549
12550
12551 .option callout_positive_expire main time 24h
12552 This option specifies the expiry time for positive callout cache data for an
12553 address. See section &<<SECTcallver>>& for details of callout verification, and
12554 section &<<SECTcallvercache>>& for details of the caching.
12555
12556
12557 .option callout_random_local_part main string&!! "see below"
12558 This option defines the &"random"& local part that can be used as part of
12559 callout verification. The default value is
12560 .code
12561 $primary_host_name-$tod_epoch-testing
12562 .endd
12563 See section &<<CALLaddparcall>>& for details of how this value is used.
12564
12565
12566 .option check_log_inodes main integer 0
12567 See &%check_spool_space%& below.
12568
12569
12570 .option check_log_space main integer 0
12571 See &%check_spool_space%& below.
12572
12573 .oindex "&%check_rfc2047_length%&"
12574 .cindex "RFC 2047" "disabling length check"
12575 .option check_rfc2047_length " User: main" boolean true
12576 RFC 2047 defines a way of encoding non-ASCII characters in headers using a
12577 system of &"encoded words"&. The RFC specifies a maximum length for an encoded
12578 word; strings to be encoded that exceed this length are supposed to use
12579 multiple encoded words. By default, Exim does not recognize encoded words that
12580 exceed the maximum length. However, it seems that some software, in violation
12581 of the RFC, generates overlong encoded words. If &%check_rfc2047_length%& is
12582 set false, Exim recognizes encoded words of any length.
12583
12584
12585 .option check_spool_inodes main integer 0
12586 See &%check_spool_space%& below.
12587
12588
12589 .option check_spool_space main integer 0
12590 .cindex "checking disk space"
12591 .cindex "disk space" "checking"
12592 .cindex "spool directory" "checking space"
12593 The four &%check_...%& options allow for checking of disk resources before a
12594 message is accepted.
12595
12596 .cindex "&$log_inodes$&"
12597 .cindex "&$log_space$&"
12598 .cindex "&$spool_inodes$&"
12599 .cindex "&$spool_space$&"
12600 When any of these options are set, they apply to all incoming messages. If you
12601 want to apply different checks to different kinds of message, you can do so by
12602 testing the variables &$log_inodes$&, &$log_space$&, &$spool_inodes$&, and
12603 &$spool_space$& in an ACL with appropriate additional conditions.
12604
12605
12606 &%check_spool_space%& and &%check_spool_inodes%& check the spool partition if
12607 either value is greater than zero, for example:
12608 .code
12609 check_spool_space = 10M
12610 check_spool_inodes = 100
12611 .endd
12612 The spool partition is the one that contains the directory defined by
12613 SPOOL_DIRECTORY in &_Local/Makefile_&. It is used for holding messages in
12614 transit.
12615
12616 &%check_log_space%& and &%check_log_inodes%&  check the partition in which log
12617 files are written if either is greater than zero. These should be set only if
12618 &%log_file_path%& and &%spool_directory%& refer to different partitions.
12619
12620 If there is less space or fewer inodes than requested, Exim refuses to accept
12621 incoming mail. In the case of SMTP input this is done by giving a 452 temporary
12622 error response to the MAIL command. If ESMTP is in use and there was a
12623 SIZE parameter on the MAIL command, its value is added to the
12624 &%check_spool_space%& value, and the check is performed even if
12625 &%check_spool_space%& is zero, unless &%no_smtp_check_spool_space%& is set.
12626
12627 The values for &%check_spool_space%& and &%check_log_space%& are held as a
12628 number of kilobytes. If a non-multiple of 1024 is specified, it is rounded up.
12629
12630 For non-SMTP input and for batched SMTP input, the test is done at start-up; on
12631 failure a message is written to stderr and Exim exits with a non-zero code, as
12632 it obviously cannot send an error message of any kind.
12633
12634 .option daemon_smtp_ports main string &`smtp`&
12635 .cindex "port" "for daemon"
12636 .cindex "TCP/IP" "setting listening ports"
12637 This option specifies one or more default SMTP ports on which the Exim daemon
12638 listens. See chapter &<<CHAPinterfaces>>& for details of how it is used. For
12639 backward compatibility, &%daemon_smtp_port%& (singular) is a synonym.
12640
12641 .option daemon_startup_retries main integer 9
12642 .cindex "daemon startup" "retrying"
12643 This option, along with &%daemon_startup_sleep%&, controls the retrying done by
12644 the daemon at startup when it cannot immediately bind a listening socket
12645 (typically because the socket is already in use): &%daemon_startup_retries%&
12646 defines the number of retries after the first failure, and
12647 &%daemon_startup_sleep%& defines the length of time to wait between retries.
12648
12649 .option daemon_startup_sleep main time 30s
12650 See &%daemon_startup_retries%&.
12651
12652 .option delay_warning main "time list" 24h
12653 .cindex "warning of delay"
12654 .cindex "delay warning" "specifying"
12655 When a message is delayed, Exim sends a warning message to the sender at
12656 intervals specified by this option. The data is a colon-separated list of times
12657 after which to send warning messages. If the value of the option is an empty
12658 string or a zero time, no warnings are sent. Up to 10 times may be given. If a
12659 message has been on the queue for longer than the last time, the last interval
12660 between the times is used to compute subsequent warning times. For example,
12661 with
12662 .code
12663 delay_warning = 4h:8h:24h
12664 .endd
12665 the first message is sent after 4 hours, the second after 8 hours, and
12666 the third one after 24 hours. After that, messages are sent every 16 hours,
12667 because that is the interval between the last two times on the list. If you set
12668 just one time, it specifies the repeat interval. For example, with:
12669 .code
12670 delay_warning = 6h
12671 .endd
12672 messages are repeated every six hours. To stop warnings after a given time, set
12673 a very large time at the end of the list. For example:
12674 .code
12675 delay_warning = 2h:12h:99d
12676 .endd
12677
12678 .option delay_warning_condition main string&!! "see below"
12679 .cindex "&$domain$&"
12680 The string is expanded at the time a warning message might be sent. If all the
12681 deferred addresses have the same domain, it is set in &$domain$& during the
12682 expansion. Otherwise &$domain$& is empty. If the result of the expansion is a
12683 forced failure, an empty string, or a string matching any of &"0"&, &"no"& or
12684 &"false"& (the comparison being done caselessly) then the warning message is
12685 not sent. The default is:
12686 .code
12687 delay_warning_condition = ${if or {\
12688   { !eq{$h_list-id:$h_list-post:$h_list-subscribe:}{} }\
12689   { match{$h_precedence:}{(?i)bulk|list|junk} }\
12690   { match{$h_auto-submitted:}{(?i)auto-generated|auto-replied} }\
12691   } {no}{yes}}
12692 .endd
12693 This suppresses the sending of warnings for messages that contain &'List-ID:'&,
12694 &'List-Post:'&, or &'List-Subscribe:'& headers, or have &"bulk"&, &"list"& or
12695 &"junk"& in a &'Precedence:'& header, or have &"auto-generated"& or
12696 &"auto-replied"& in an &'Auto-Submitted:'& header.
12697
12698 .option deliver_drop_privilege main boolean false
12699 .cindex "unprivileged delivery"
12700 .cindex "delivery" "unprivileged"
12701 If this option is set true, Exim drops its root privilege at the start of a
12702 delivery process, and runs as the Exim user throughout. This severely restricts
12703 the kinds of local delivery that are possible, but is viable in certain types
12704 of configuration. There is a discussion about the use of root privilege in
12705 chapter &<<CHAPsecurity>>&.
12706
12707 .option deliver_queue_load_max main fixed-point unset
12708 .cindex "load average"
12709 .cindex "queue runner" "abandoning"
12710 When this option is set, a queue run is abandoned if the system load average
12711 becomes greater than the value of the option. The option has no effect on
12712 ancient operating systems on which Exim cannot determine the load average.
12713 See also &%queue_only_load%& and &%smtp_load_reserve%&.
12714
12715
12716 .option delivery_date_remove main boolean true
12717 .cindex "&'Delivery-date:'& header line"
12718 Exim's transports have an option for adding a &'Delivery-date:'& header to a
12719 message when it is delivered, in exactly the same way as &'Return-path:'& is
12720 handled. &'Delivery-date:'& records the actual time of delivery. Such headers
12721 should not be present in incoming messages, and this option causes them to be
12722 removed at the time the message is received, to avoid any problems that might
12723 occur when a delivered message is subsequently sent on to some other recipient.
12724
12725
12726 .option disable_ipv6 main boolean false
12727 .cindex "IPv6" "disabling"
12728 If this option is set true, even if the Exim binary has IPv6 support, no IPv6
12729 activities take place. AAAA records are never looked up, and any IPv6 addresses
12730 that are listed in &%local_interfaces%&, data for the &%manualroute%& router,
12731 etc. are ignored. If IP literals are enabled, the &(ipliteral)& router declines
12732 to handle IPv6 literal addresses.
12733
12734
12735 .option dns_again_means_nonexist main "domain list&!!" unset
12736 .cindex "DNS" "&""try again""& response; overriding"
12737 DNS lookups give a &"try again"& response for the DNS errors
12738 &"non-authoritative host not found"& and &"SERVERFAIL"&. This can cause Exim to
12739 keep trying to deliver a message, or to give repeated temporary errors to
12740 incoming mail. Sometimes the effect is caused by a badly set up name server and
12741 may persist for a long time. If a domain which exhibits this problem matches
12742 anything in &%dns_again_means_nonexist%&, it is treated as if it did not exist.
12743 This option should be used with care. You can make it apply to reverse lookups
12744 by a setting such as this:
12745 .code
12746 dns_again_means_nonexist = *.in-addr.arpa
12747 .endd
12748 This option applies to all DNS lookups that Exim does. It also applies when the
12749 &[gethostbyname()]& or &[getipnodebyname()]& functions give temporary errors,
12750 since these are most likely to be caused by DNS lookup problems. The
12751 &(dnslookup)& router has some options of its own for controlling what happens
12752 when lookups for MX or SRV records give temporary errors. These more specific
12753 options are applied after this global option.
12754
12755 .option dns_check_names_pattern main string "see below"
12756 .cindex "DNS" "pre-check of name syntax"
12757 When this option is set to a non-empty string, it causes Exim to check domain
12758 names for characters that are not allowed in host names before handing them to
12759 the DNS resolver, because some resolvers give temporary errors for names that
12760 contain unusual characters. If a domain name contains any unwanted characters,
12761 a &"not found"& result is forced, and the resolver is not called. The check is
12762 done by matching the domain name against a regular expression, which is the
12763 value of this option. The default pattern is
12764 .code
12765 dns_check_names_pattern = \
12766   (?i)^(?>(?(1)\.|())[^\W_](?>[a-z0-9/-]*[^\W_])?)+$
12767 .endd
12768 which permits only letters, digits, slashes, and hyphens in components, but
12769 they must start and end with a letter or digit. Hyphens are not, in fact,
12770 permitted in host names, but they are found in certain NS records (which can be
12771 accessed in Exim by using a &%dnsdb%& lookup). If you set
12772 &%allow_utf8_domains%&, you must modify this pattern, or set the option to an
12773 empty string.
12774
12775 .option dns_csa_search_limit main integer 5
12776 This option controls the depth of parental searching for CSA SRV records in the
12777 DNS, as described in more detail in section &<<SECTverifyCSA>>&.
12778
12779 .option dns_csa_use_reverse main boolean true
12780 This option controls whether or not an IP address, given as a CSA domain, is
12781 reversed and looked up in the reverse DNS, as described in more detail in
12782 section &<<SECTverifyCSA>>&.
12783
12784 .option dns_ipv4_lookup main "domain list&!!" unset
12785 .cindex "IPv6" "DNS lookup for AAAA records"
12786 .cindex "DNS" "IPv6 lookup for AAAA records"
12787 When Exim is compiled with IPv6 support and &%disable_ipv6%& is not set, it
12788 looks for IPv6 address records (AAAA records) as well as IPv4 address records
12789 (A records) when trying to find IP addresses for hosts, unless the host's
12790 domain matches this list.
12791
12792 This is a fudge to help with name servers that give big delays or otherwise do
12793 not work for the AAAA record type. In due course, when the world's name
12794 servers have all been upgraded, there should be no need for this option.
12795
12796
12797 .option dns_retrans main time 0s
12798 .cindex "DNS" "resolver options"
12799 The options &%dns_retrans%& and &%dns_retry%& can be used to set the
12800 retransmission and retry parameters for DNS lookups. Values of zero (the
12801 defaults) leave the system default settings unchanged. The first value is the
12802 time between retries, and the second is the number of retries. It isn't
12803 totally clear exactly how these settings affect the total time a DNS lookup may
12804 take. I haven't found any documentation about timeouts on DNS lookups; these
12805 parameter values are available in the external resolver interface structure,
12806 but nowhere does it seem to describe how they are used or what you might want
12807 to set in them.
12808
12809
12810 .option dns_retry main integer 0
12811 See &%dns_retrans%& above.
12812
12813
12814 .option drop_cr main boolean false
12815 This is an obsolete option that is now a no-op. It used to affect the way Exim
12816 handled CR and LF characters in incoming messages. What happens now is
12817 described in section &<<SECTlineendings>>&.
12818
12819
12820 .option envelope_to_remove main boolean true
12821 .cindex "&'Envelope-to:'& header line"
12822 Exim's transports have an option for adding an &'Envelope-to:'& header to a
12823 message when it is delivered, in exactly the same way as &'Return-path:'& is
12824 handled. &'Envelope-to:'& records the original recipient address from the
12825 messages's envelope that caused the delivery to happen. Such headers should not
12826 be present in incoming messages, and this option causes them to be removed at
12827 the time the message is received, to avoid any problems that might occur when a
12828 delivered message is subsequently sent on to some other recipient.
12829
12830
12831 .option errors_copy main "string list&!!" unset
12832 .cindex "bounce message" "copy to other address"
12833 .cindex "copy of bounce message"
12834 Setting this option causes Exim to send bcc copies of bounce messages that it
12835 generates to other addresses. &*Note*&: This does not apply to bounce messages
12836 coming from elsewhere. The value of the option is a colon-separated list of
12837 items. Each item consists of a pattern, terminated by white space, followed by
12838 a comma-separated list of email addresses. If a pattern contains spaces, it
12839 must be enclosed in double quotes.
12840
12841 Each pattern is processed in the same way as a single item in an address list
12842 (see section &<<SECTaddresslist>>&). When a pattern matches the recipient of
12843 the bounce message, the message is copied to the addresses on the list. The
12844 items are scanned in order, and once a matching one is found, no further items
12845 are examined. For example:
12846 .code
12847 errors_copy = spqr@mydomain   postmaster@mydomain.example :\
12848               rqps@mydomain   hostmaster@mydomain.example,\
12849                               postmaster@mydomain.example
12850 .endd
12851 .cindex "&$domain$&"
12852 .cindex "&$local_part$&"
12853 The address list is expanded before use. The expansion variables &$local_part$&
12854 and &$domain$& are set from the original recipient of the error message, and if
12855 there was any wildcard matching in the pattern, the expansion
12856 .cindex "numerical variables (&$1$& &$2$& etc)" "in &%errors_copy%&"
12857 variables &$0$&, &$1$&, etc. are set in the normal way.
12858
12859
12860 .option errors_reply_to main string unset
12861 .cindex "bounce message" "&'Reply-to:'& in"
12862 By default, Exim's bounce and delivery warning messages contain the header line
12863 .display
12864 &`From: Mail Delivery System <Mailer-Daemon@`&&'qualify-domain'&&`>`&
12865 .endd
12866 .oindex &%quota_warn_message%&
12867 where &'qualify-domain'& is the value of the &%qualify_domain%& option.
12868 A warning message that is generated by the &%quota_warn_message%& option in an
12869 &(appendfile)& transport may contain its own &'From:'& header line that
12870 overrides the default.
12871
12872 Experience shows that people reply to bounce messages. If the
12873 &%errors_reply_to%& option is set, a &'Reply-To:'& header is added to bounce
12874 and warning messages. For example:
12875 .code
12876 errors_reply_to = postmaster@my.domain.example
12877 .endd
12878 The value of the option is not expanded. It must specify a valid RFC 2822
12879 address. However, if a warning message that is generated by the
12880 &%quota_warn_message%& option in an &(appendfile)& transport contain its
12881 own &'Reply-To:'& header line, the value of the &%errors_reply_to%& option is
12882 not used.
12883
12884
12885 .option exim_group main string "compile-time configured"
12886 .cindex "gid (group id)" "Exim's own"
12887 .cindex "Exim group"
12888 This option changes the gid under which Exim runs when it gives up root
12889 privilege. The default value is compiled into the binary. The value of this
12890 option is used only when &%exim_user%& is also set. Unless it consists entirely
12891 of digits, the string is looked up using &[getgrnam()]&, and failure causes a
12892 configuration error. See chapter &<<CHAPsecurity>>& for a discussion of
12893 security issues.
12894
12895
12896 .option exim_path main string "see below"
12897 .cindex "Exim binary" "path name"
12898 This option specifies the path name of the Exim binary, which is used when Exim
12899 needs to re-exec itself. The default is set up to point to the file &'exim'& in
12900 the directory configured at compile time by the BIN_DIRECTORY setting. It
12901 is necessary to change &%exim_path%& if, exceptionally, Exim is run from some
12902 other place.
12903 &*Warning*&: Do not use a macro to define the value of this option, because
12904 you will break those Exim utilities that scan the configuration file to find
12905 where the binary is. (They then use the &%-bP%& option to extract option
12906 settings such as the value of &%spool_directory%&.)
12907
12908
12909 .option exim_user main string "compile-time configured"
12910 .cindex "uid (user id)" "Exim's own"
12911 .cindex "Exim user"
12912 This option changes the uid under which Exim runs when it gives up root
12913 privilege. The default value is compiled into the binary. Ownership of the run
12914 time configuration file and the use of the &%-C%& and &%-D%& command line
12915 options is checked against the values in the binary, not what is set here.
12916
12917 Unless it consists entirely of digits, the string is looked up using
12918 &[getpwnam()]&, and failure causes a configuration error. If &%exim_group%& is
12919 not also supplied, the gid is taken from the result of &[getpwnam()]& if it is
12920 used. See chapter &<<CHAPsecurity>>& for a discussion of security issues.
12921
12922
12923 .option extra_local_interfaces main "string list" unset
12924 This option defines network interfaces that are to be considered local when
12925 routing, but which are not used for listening by the daemon. See section
12926 &<<SECTreclocipadd>>& for details.
12927
12928
12929 .option "extract_addresses_remove_ &~arguments" main boolean true
12930 .cindex "&%-t%& option"
12931 .cindex "command line" "addresses with &%-t%&"
12932 .cindex "Sendmail compatibility" "&%-t%& option"
12933 According to some Sendmail documentation (Sun, IRIX, HP-UX), if any addresses
12934 are present on the command line when the &%-t%& option is used to build an
12935 envelope from a message's &'To:'&, &'Cc:'& and &'Bcc:'& headers, the command
12936 line addresses are removed from the recipients list. This is also how Smail
12937 behaves. However, other Sendmail documentation (the O'Reilly book) states that
12938 command line addresses are added to those obtained from the header lines. When
12939 &%extract_addresses_remove_arguments%& is true (the default), Exim subtracts
12940 argument headers. If it is set false, Exim adds rather than removes argument
12941 addresses.
12942
12943
12944 .option finduser_retries main integer 0
12945 .cindex "NIS" "looking up users; retrying"
12946 On systems running NIS or other schemes in which user and group information is
12947 distributed from a remote system, there can be times when &[getpwnam()]& and
12948 related functions fail, even when given valid data, because things time out.
12949 Unfortunately these failures cannot be distinguished from genuine &"not found"&
12950 errors. If &%finduser_retries%& is set greater than zero, Exim will try that
12951 many extra times to find a user or a group, waiting for one second between
12952 retries.
12953
12954 .cindex "&_/etc/passwd_&" "multiple reading of"
12955 You should not set this option greater than zero if your user information is in
12956 a traditional &_/etc/passwd_& file, because it will cause Exim needlessly to
12957 search the file multiple times for non-existent users, and also cause delay.
12958
12959
12960
12961 .option freeze_tell main "string list, comma separated" unset
12962 .cindex "freezing messages" "sending a message when freezing"
12963 On encountering certain errors, or when configured to do so in a system filter,
12964 ACL, or special router, Exim freezes a message. This means that no further
12965 delivery attempts take place until an administrator thaws the message, or the
12966 &%auto_thaw%&, &%ignore_bounce_errors_after%&, or &%timeout_frozen_after%&
12967 feature cause it to be processed. If &%freeze_tell%& is set, Exim generates a
12968 warning message whenever it freezes something, unless the message it is
12969 freezing is a locally-generated bounce message. (Without this exception there
12970 is the possibility of looping.) The warning message is sent to the addresses
12971 supplied as the comma-separated value of this option. If several of the
12972 message's addresses cause freezing, only a single message is sent. If the
12973 freezing was automatic, the reason(s) for freezing can be found in the message
12974 log. If you configure freezing in a filter or ACL, you must arrange for any
12975 logging that you require.
12976
12977
12978 .option gecos_name main string&!! unset
12979 .cindex "HP-UX"
12980 .cindex "&""gecos""& field" "parsing"
12981 Some operating systems, notably HP-UX, use the &"gecos"& field in the system
12982 password file to hold other information in addition to users' real names. Exim
12983 looks up this field for use when it is creating &'Sender:'& or &'From:'&
12984 headers. If either &%gecos_pattern%& or &%gecos_name%& are unset, the contents
12985 of the field are used unchanged, except that, if an ampersand is encountered,
12986 it is replaced by the user's login name with the first character forced to
12987 upper case, since this is a convention that is observed on many systems.
12988
12989 When these options are set, &%gecos_pattern%& is treated as a regular
12990 expression that is to be applied to the field (again with && replaced by the
12991 login name), and if it matches, &%gecos_name%& is expanded and used as the
12992 user's name.
12993
12994 .cindex "numerical variables (&$1$& &$2$& etc)" "in &%gecos_name%&"
12995 Numeric variables such as &$1$&, &$2$&, etc. can be used in the expansion to
12996 pick up sub-fields that were matched by the pattern. In HP-UX, where the user's
12997 name terminates at the first comma, the following can be used:
12998 .code
12999 gecos_pattern = ([^,]*)
13000 gecos_name = $1
13001 .endd
13002
13003 .option gecos_pattern main string unset
13004 See &%gecos_name%& above.
13005
13006
13007 .option headers_charset main string "see below"
13008 This option sets a default character set for translating from encoded MIME
13009 &"words"& in header lines, when referenced by an &$h_xxx$& expansion item. The
13010 default is the value of HEADERS_CHARSET in &_Local/Makefile_&. The
13011 ultimate default is ISO-8859-1. For more details see the description of header
13012 insertions in section &<<SECTexpansionitems>>&.
13013
13014
13015
13016 .option header_maxsize main integer "see below"
13017 .cindex "header section" "maximum size of"
13018 .cindex "limit" "size of message header section"
13019 This option controls the overall maximum size of a message's header
13020 section. The default is the value of HEADER_MAXSIZE in
13021 &_Local/Makefile_&; the default for that is 1M. Messages with larger header
13022 sections are rejected.
13023
13024
13025 .option header_line_maxsize main integer 0
13026 .cindex "header lines" "maximum size of"
13027 .cindex "limit" "size of one header line"
13028 This option limits the length of any individual header line in a message, after
13029 all the continuations have been joined together. Messages with individual
13030 header lines that are longer than the limit are rejected. The default value of
13031 zero means &"no limit"&.
13032
13033
13034
13035
13036 .option helo_accept_junk_hosts main "host list&!!" unset
13037 .cindex "HELO" "accepting junk data"
13038 .cindex "EHLO" "accepting junk data"
13039 Exim checks the syntax of HELO and EHLO commands for incoming SMTP
13040 mail, and gives an error response for invalid data. Unfortunately, there are
13041 some SMTP clients that send syntactic junk. They can be accommodated by setting
13042 this option. Note that this is a syntax check only. See &%helo_verify_hosts%&
13043 if you want to do semantic checking.
13044 See also &%helo_allow_chars%& for a way of extending the permitted character
13045 set.
13046
13047
13048 .option helo_allow_chars main string unset
13049 .cindex "HELO" "underscores in"
13050 .cindex "EHLO" "underscores in"
13051 .cindex "underscore in EHLO/HELO"
13052 This option can be set to a string of rogue characters that are permitted in
13053 all EHLO and HELO names in addition to the standard letters, digits,
13054 hyphens, and dots. If you really must allow underscores, you can set
13055 .code
13056 helo_allow_chars = _
13057 .endd
13058 Note that the value is one string, not a list.
13059
13060
13061 .option helo_lookup_domains main "domain list&!!" &`@:@[]`&
13062 .cindex "HELO" "forcing reverse lookup"
13063 .cindex "EHLO" "forcing reverse lookup"
13064 If the domain given by a client in a HELO or EHLO command matches this
13065 list, a reverse lookup is done in order to establish the host's true name. The
13066 default forces a lookup if the client host gives the server's name or any of
13067 its IP addresses (in brackets), something that broken clients have been seen to
13068 do.
13069
13070
13071 .option helo_try_verify_hosts main "host list&!!" unset
13072 .cindex "HELO verifying" "optional"
13073 .cindex "EHLO verifying" "optional"
13074 By default, Exim just checks the syntax of HELO and EHLO commands (see
13075 &%helo_accept_junk_hosts%& and &%helo_allow_chars%&). However, some sites like
13076 to do more extensive checking of the data supplied by these commands. The ACL
13077 condition &`verify`& &`=`& &`helo`& is provided to make this possible.
13078 Formerly, it was necessary also to set this option (&%helo_try_verify_hosts%&)
13079 to force the check to occur. From release 4.53 onwards, this is no longer
13080 necessary. If the check has not been done before &`verify`& &`=`& &`helo`& is
13081 encountered, it is done at that time. Consequently, this option is obsolete.
13082 Its specification is retained here for backwards compatibility.
13083
13084 When an EHLO or HELO command is received, if the calling host matches
13085 &%helo_try_verify_hosts%&, Exim checks that the host name given in the HELO or
13086 EHLO command either:
13087
13088 .ilist
13089 is an IP literal matching the calling address of the host, or
13090 .next
13091 .cindex "DNS" "reverse lookup"
13092 .cindex "reverse DNS lookup"
13093 matches the host name that Exim obtains by doing a reverse lookup of the
13094 calling host address, or
13095 .next
13096 when looked up using &[gethostbyname()]& (or &[getipnodebyname()]& when
13097 available) yields the calling host address.
13098 .endlist
13099
13100 However, the EHLO or HELO command is not rejected if any of the checks
13101 fail. Processing continues, but the result of the check is remembered, and can
13102 be detected later in an ACL by the &`verify`& &`=`& &`helo`& condition.
13103
13104 .option helo_verify_hosts main "host list&!!" unset
13105 .cindex "HELO verifying" "mandatory"
13106 .cindex "EHLO verifying" "mandatory"
13107 Like &%helo_try_verify_hosts%&, this option is obsolete, and retained only for
13108 backwards compatibility. For hosts that match this option, Exim checks the host
13109 name given in the HELO or EHLO in the same way as for
13110 &%helo_try_verify_hosts%&. If the check fails, the HELO or EHLO command is
13111 rejected with a 550 error, and entries are written to the main and reject logs.
13112 If a MAIL command is received before EHLO or HELO, it is rejected with a 503
13113 error.
13114
13115 .option hold_domains main "domain list&!!" unset
13116 .cindex "domain" "delaying delivery"
13117 .cindex "delivery" "delaying certain domains"
13118 This option allows mail for particular domains to be held on the queue
13119 manually. The option is overridden if a message delivery is forced with the
13120 &%-M%&, &%-qf%&, &%-Rf%& or &%-Sf%& options, and also while testing or
13121 verifying addresses using &%-bt%& or &%-bv%&. Otherwise, if a domain matches an
13122 item in &%hold_domains%&, no routing or delivery for that address is done, and
13123 it is deferred every time the message is looked at.
13124
13125 This option is intended as a temporary operational measure for delaying the
13126 delivery of mail while some problem is being sorted out, or some new
13127 configuration tested. If you just want to delay the processing of some
13128 domains until a queue run occurs, you should use &%queue_domains%& or
13129 &%queue_smtp_domains%&, not &%hold_domains%&.
13130
13131 A setting of &%hold_domains%& does not override Exim's code for removing
13132 messages from the queue if they have been there longer than the longest retry
13133 time in any retry rule. If you want to hold messages for longer than the normal
13134 retry times, insert a dummy retry rule with a long retry time.
13135
13136
13137 .option host_lookup main "host list&!!" unset
13138 .cindex "host name lookup" "forcing"
13139 Exim does not look up the name of a calling host from its IP address unless it
13140 is required to compare against some host list, or the host matches
13141 &%helo_try_verify_hosts%& or &%helo_verify_hosts%&, or the host matches this
13142 option (which normally contains IP addresses rather than host names). The
13143 default configuration file contains
13144 .code
13145 host_lookup = *
13146 .endd
13147 which causes a lookup to happen for all hosts. If the expense of these lookups
13148 is felt to be too great, the setting can be changed or removed.
13149
13150 After a successful reverse lookup, Exim does a forward lookup on the name it
13151 has obtained, to verify that it yields the IP address that it started with. If
13152 this check fails, Exim behaves as if the name lookup failed.
13153
13154 .cindex "&$host_lookup_failed$&"
13155 .cindex "&$sender_host_name$&"
13156 After any kind of failure, the host name (in &$sender_host_name$&) remains
13157 unset, and &$host_lookup_failed$& is set to the string &"1"&. See also
13158 &%dns_again_means_nonexist%&, &%helo_lookup_domains%&, and &`verify`& &`=`&
13159 &`reverse_host_lookup`& in ACLs.
13160
13161
13162 .option host_lookup_order main "string list" &`bydns:byaddr`&
13163 This option specifies the order of different lookup methods when Exim is trying
13164 to find a host name from an IP address. The default is to do a DNS lookup
13165 first, and then to try a local lookup (using &[gethostbyaddr()]& or equivalent)
13166 if that fails. You can change the order of these lookups, or omit one entirely,
13167 if you want.
13168
13169 &*Warning*&: The &"byaddr"& method does not always yield aliases when there are
13170 multiple PTR records in the DNS and the IP address is not listed in
13171 &_/etc/hosts_&. Different operating systems give different results in this
13172 case. That is why the default tries a DNS lookup first.
13173
13174
13175
13176 .option host_reject_connection main "host list&!!" unset
13177 .cindex "host" "rejecting connections from"
13178 If this option is set, incoming SMTP calls from the hosts listed are rejected
13179 as soon as the connection is made.
13180 This option is obsolete, and retained only for backward compatibility, because
13181 nowadays the ACL specified by &%acl_smtp_connect%& can also reject incoming
13182 connections immediately.
13183
13184 The ability to give an immediate rejection (either by this option or using an
13185 ACL) is provided for use in unusual cases. Many hosts will just try again,
13186 sometimes without much delay. Normally, it is better to use an ACL to reject
13187 incoming messages at a later stage, such as after RCPT commands. See
13188 chapter &<<CHAPACL>>&.
13189
13190
13191 .option hosts_connection_nolog main "host list&!!" unset
13192 .cindex "host" "not logging connections from"
13193 This option defines a list of hosts for which connection logging does not
13194 happen, even though the &%smtp_connection%& log selector is set. For example,
13195 you might want not to log SMTP connections from local processes, or from
13196 127.0.0.1, or from your local LAN. This option is consulted in the main loop of
13197 the daemon; you should therefore strive to restrict its value to a short inline
13198 list of IP addresses and networks. To disable logging SMTP connections from
13199 local processes, you must create a host list with an empty item. For example:
13200 .code
13201 hosts_connection_nolog = :
13202 .endd
13203 If the &%smtp_connection%& log selector is not set, this option has no effect.
13204
13205
13206
13207 .option hosts_treat_as_local main "domain list&!!" unset
13208 .cindex "local host" "domains treated as"
13209 .cindex "host" "treated as local"
13210 If this option is set, any host names that match the domain list are treated as
13211 if they were the local host when Exim is scanning host lists obtained from MX
13212 records
13213 or other sources. Note that the value of this option is a domain list, not a
13214 host list, because it is always used to check host names, not IP addresses.
13215
13216 This option also applies when Exim is matching the special items
13217 &`@mx_any`&, &`@mx_primary`&, and &`@mx_secondary`& in a domain list (see
13218 section &<<SECTdomainlist>>&), and when checking the &%hosts%& option in the
13219 &(smtp)& transport for the local host (see the &%allow_localhost%& option in
13220 that transport). See also &%local_interfaces%&, &%extra_local_interfaces%&, and
13221 chapter &<<CHAPinterfaces>>&, which contains a discussion about local network
13222 interfaces and recognising the local host.
13223
13224
13225 .option ignore_bounce_errors_after main time 10w
13226 .cindex "bounce message" "discarding"
13227 .cindex "discarding bounce message"
13228 This option affects the processing of bounce messages that cannot be delivered,
13229 that is, those that suffer a permanent delivery failure. (Bounce messages that
13230 suffer temporary delivery failures are of course retried in the usual way.)
13231
13232 After a permanent delivery failure, bounce messages are frozen,
13233 because there is no sender to whom they can be returned. When a frozen bounce
13234 message has been on the queue for more than the given time, it is unfrozen at
13235 the next queue run, and a further delivery is attempted. If delivery fails
13236 again, the bounce message is discarded. This makes it possible to keep failed
13237 bounce messages around for a shorter time than the normal maximum retry time
13238 for frozen messages. For example,
13239 .code
13240 ignore_bounce_errors_after = 12h
13241 .endd
13242 retries failed bounce message deliveries after 12 hours, discarding any further
13243 failures. If the value of this option is set to a zero time period, bounce
13244 failures are discarded immediately. Setting a very long time (as in the default
13245 value) has the effect of disabling this option. For ways of automatically
13246 dealing with other kinds of frozen message, see &%auto_thaw%& and
13247 &%timeout_frozen_after%&.
13248
13249
13250 .option ignore_fromline_hosts main "host list&!!" unset
13251 .cindex "&""From""& line"
13252 .cindex "UUCP" "&""From""& line"
13253 Some broken SMTP clients insist on sending a UUCP-like &"From&~"& line before
13254 the headers of a message. By default this is treated as the start of the
13255 message's body, which means that any following headers are not recognized as
13256 such. Exim can be made to ignore it by setting &%ignore_fromline_hosts%& to
13257 match those hosts that insist on sending it. If the sender is actually a local
13258 process rather than a remote host, and is using &%-bs%& to inject the messages,
13259 &%ignore_fromline_local%& must be set to achieve this effect.
13260
13261
13262 .option ignore_fromline_local main boolean false
13263 See &%ignore_fromline_hosts%& above.
13264
13265
13266 .option keep_malformed main time 4d
13267 This option specifies the length of time to keep messages whose spool files
13268 have been corrupted in some way. This should, of course, never happen. At the
13269 next attempt to deliver such a message, it gets removed. The incident is
13270 logged.
13271
13272
13273 .option ldap_default_servers main "string list" unset
13274 .cindex "LDAP" "default servers"
13275 This option provides a list of LDAP servers which are tried in turn when an
13276 LDAP query does not contain a server. See section &<<SECTforldaque>>& for
13277 details of LDAP queries. This option is available only when Exim has been built
13278 with LDAP support.
13279
13280
13281 .option ldap_version main integer unset
13282 .cindex "LDAP protocol version" "forcing"
13283 This option can be used to force Exim to set a specific protocol version for
13284 LDAP. If it option is unset, it is shown by the &%-bP%& command line option as
13285 -1. When this is the case, the default is 3 if LDAP_VERSION3 is defined in
13286 the LDAP headers; otherwise it is 2. This option is available only when Exim
13287 has been built with LDAP support.
13288
13289
13290
13291 .option local_from_check main boolean true
13292 .cindex "&'Sender:'& header line" "disabling addition of"
13293 .cindex "&'From:'& header line" "disabling checking of"
13294 When a message is submitted locally (that is, not over a TCP/IP connection) by
13295 an untrusted user, Exim removes any existing &'Sender:'& header line, and
13296 checks that the &'From:'& header line matches the login of the calling user and
13297 the domain specified by &%qualify_domain%&.
13298
13299 &*Note*&: An unqualified address (no domain) in the &'From:'& header in a
13300 locally submitted message is automatically qualified by Exim, unless the
13301 &%-bnq%& command line option is used.
13302
13303 You can use &%local_from_prefix%& and &%local_from_suffix%& to permit affixes
13304 on the local part. If the &'From:'& header line does not match, Exim adds a
13305 &'Sender:'& header with an address constructed from the calling user's login
13306 and the default qualify domain.
13307
13308 If &%local_from_check%& is set false, the &'From:'& header check is disabled,
13309 and no &'Sender:'& header is ever added. If, in addition, you want to retain
13310 &'Sender:'& header lines supplied by untrusted users, you must also set
13311 &%local_sender_retain%& to be true.
13312
13313 .cindex "envelope sender"
13314 These options affect only the header lines in the message. The envelope sender
13315 is still forced to be the login id at the qualify domain unless
13316 &%untrusted_set_sender%& permits the user to supply an envelope sender.
13317
13318 For messages received over TCP/IP, an ACL can specify &"submission mode"& to
13319 request similar header line checking. See section &<<SECTthesenhea>>&, which
13320 has more details about &'Sender:'& processing.
13321
13322
13323
13324
13325 .option local_from_prefix main string unset
13326 When Exim checks the &'From:'& header line of locally submitted messages for
13327 matching the login id (see &%local_from_check%& above), it can be configured to
13328 ignore certain prefixes and suffixes in the local part of the address. This is
13329 done by setting &%local_from_prefix%& and/or &%local_from_suffix%& to
13330 appropriate lists, in the same form as the &%local_part_prefix%& and
13331 &%local_part_suffix%& router options (see chapter &<<CHAProutergeneric>>&). For
13332 example, if
13333 .code
13334 local_from_prefix = *-
13335 .endd
13336 is set, a &'From:'& line containing
13337 .code
13338 From: anything-user@your.domain.example
13339 .endd
13340 will not cause a &'Sender:'& header to be added if &'user@your.domain.example'&
13341 matches the actual sender address that is constructed from the login name and
13342 qualify domain.
13343
13344
13345 .option local_from_suffix main string unset
13346 See &%local_from_prefix%& above.
13347
13348
13349 .option local_interfaces main "string list" "see below"
13350 This option controls which network interfaces are used by the daemon for
13351 listening; they are also used to identify the local host when routing. Chapter
13352 &<<CHAPinterfaces>>& contains a full description of this option and the related
13353 options &%daemon_smtp_ports%&, &%extra_local_interfaces%&,
13354 &%hosts_treat_as_local%&, and &%tls_on_connect_ports%&. The default value for
13355 &%local_interfaces%& is
13356 .code
13357 local_interfaces = 0.0.0.0
13358 .endd
13359 when Exim is built without IPv6 support; otherwise it is
13360 .code
13361 local_interfaces = <; ::0 ; 0.0.0.0
13362 .endd
13363
13364 .option local_scan_timeout main time 5m
13365 .cindex "timeout" "for &[local_scan()]& function"
13366 .cindex "&[local_scan()]& function" "timeout"
13367 This timeout applies to the &[local_scan()]& function (see chapter
13368 &<<CHAPlocalscan>>&). Zero means &"no timeout"&. If the timeout is exceeded,
13369 the incoming message is rejected with a temporary error if it is an SMTP
13370 message. For a non-SMTP message, the message is dropped and Exim ends with a
13371 non-zero code. The incident is logged on the main and reject logs.
13372
13373
13374
13375 .option local_sender_retain main boolean false
13376 .cindex "&'Sender:'& header line" "retaining from local submission"
13377 When a message is submitted locally (that is, not over a TCP/IP connection) by
13378 an untrusted user, Exim removes any existing &'Sender:'& header line. If you
13379 do not want this to happen, you must set &%local_sender_retain%&, and you must
13380 also set &%local_from_check%& to be false (Exim will complain if you do not).
13381 See also the ACL modifier &`control = suppress_local_fixups`&. Section
13382 &<<SECTthesenhea>>& has more details about &'Sender:'& processing.
13383
13384
13385
13386
13387 .option localhost_number main string&!! unset
13388 .cindex "host" "locally unique number for"
13389 .cindex "message ids" "with multiple hosts"
13390 .cindex "&$localhost_number$&"
13391 Exim's message ids are normally unique only within the local host. If
13392 uniqueness among a set of hosts is required, each host must set a different
13393 value for the &%localhost_number%& option. The string is expanded immediately
13394 after reading the configuration file (so that a number can be computed from the
13395 host name, for example) and the result of the expansion must be a number in the
13396 range 0&--16 (or 0&--10 on operating systems with case-insensitive file
13397 systems). This is available in subsequent string expansions via the variable
13398 &$localhost_number$&. When &%localhost_number is set%&, the final two
13399 characters of the message id, instead of just being a fractional part of the
13400 time, are computed from the time and the local host number as described in
13401 section &<<SECTmessiden>>&.
13402
13403
13404
13405 .option log_file_path main "string list&!!" "set at compile time"
13406 .cindex "log" "file path for"
13407 This option sets the path which is used to determine the names of Exim's log
13408 files, or indicates that logging is to be to syslog, or both. It is expanded
13409 when Exim is entered, so it can, for example, contain a reference to the host
13410 name. If no specific path is set for the log files at compile or run time, they
13411 are written in a sub-directory called &_log_& in Exim's spool directory.
13412 Chapter &<<CHAPlog>>& contains further details about Exim's logging, and
13413 section &<<SECTwhelogwri>>& describes how the contents of &%log_file_path%& are
13414 used. If this string is fixed at your installation (contains no expansion
13415 variables) it is recommended that you do not set this option in the
13416 configuration file, but instead supply the path using LOG_FILE_PATH in
13417 &_Local/Makefile_& so that it is available to Exim for logging errors detected
13418 early on &-- in particular, failure to read the configuration file.
13419
13420
13421 .option log_selector main string unset
13422 .cindex "log" "selectors"
13423 This option can be used to reduce or increase the number of things that Exim
13424 writes to its log files. Its argument is made up of names preceded by plus or
13425 minus characters. For example:
13426 .code
13427 log_selector = +arguments -retry_defer
13428 .endd
13429 A list of possible names and what they control is given in the chapter on
13430 logging, in section &<<SECTlogselector>>&.
13431
13432
13433 .option log_timezone main boolean false
13434 .cindex "log" "timezone for entries"
13435 .cindex "&$tod_log$&"
13436 .cindex "&$tod_zone$&"
13437 By default, the timestamps on log lines are in local time without the
13438 timezone. This means that if your timezone changes twice a year, the timestamps
13439 in log lines are ambiguous for an hour when the clocks go back. One way of
13440 avoiding this problem is to set the timezone to UTC. An alternative is to set
13441 &%log_timezone%& true. This turns on the addition of the timezone offset to
13442 timestamps in log lines. Turning on this option can add quite a lot to the size
13443 of log files because each line is extended by 6 characters. Note that the
13444 &$tod_log$& variable contains the log timestamp without the zone, but there is
13445 another variable called &$tod_zone$& that contains just the timezone offset.
13446
13447
13448 .option lookup_open_max main integer 25
13449 .cindex "too many open files"
13450 .cindex "open files" "too many"
13451 .cindex "file" "too many open"
13452 .cindex "lookup" "maximum open files"
13453 .cindex "limit" "open files for lookups"
13454 This option limits the number of simultaneously open files for single-key
13455 lookups that use regular files (that is, &(lsearch)&, &(dbm)&, and &(cdb)&).
13456 Exim normally keeps these files open during routing, because often the same
13457 file is required several times. If the limit is reached, Exim closes the least
13458 recently used file. Note that if you are using the &'ndbm'& library, it
13459 actually opens two files for each logical DBM database, though it still counts
13460 as one for the purposes of &%lookup_open_max%&. If you are getting &"too many
13461 open files"& errors with NDBM, you need to reduce the value of
13462 &%lookup_open_max%&.
13463
13464
13465 .option max_username_length main integer 0
13466 .cindex "length" "of login name"
13467 .cindex "user name" "maximum length"
13468 .cindex "limit" "user name length"
13469 Some operating systems are broken in that they truncate long arguments to
13470 &[getpwnam()]& to eight characters, instead of returning &"no such user"&. If
13471 this option is set greater than zero, any attempt to call &[getpwnam()]& with
13472 an argument that is longer behaves as if &[getpwnam()]& failed.
13473
13474
13475
13476 .option message_body_visible main integer 500
13477 .cindex "body of message" "visible size"
13478 .cindex "message body" "visible size"
13479 .cindex "&$message_body$&"
13480 .cindex "&$message_body_end$&"
13481 This option specifies how much of a message's body is to be included in the
13482 &$message_body$& and &$message_body_end$& expansion variables.
13483
13484
13485 .option message_id_header_domain main string&!! unset
13486 .cindex "&'Message-ID:'& header line"
13487 If this option is set, the string is expanded and used as the right hand side
13488 (domain) of the &'Message-ID:'& header that Exim creates if a
13489 locally-originated incoming message does not have one. &"Locally-originated"&
13490 means &"not received over TCP/IP."&
13491 Otherwise, the primary host name is used.
13492 Only letters, digits, dot and hyphen are accepted; any other characters are
13493 replaced by hyphens. If the expansion is forced to fail, or if the result is an
13494 empty string, the option is ignored.
13495
13496
13497 .option message_id_header_text main string&!! unset
13498 If this variable is set, the string is expanded and used to augment the text of
13499 the &'Message-id:'& header that Exim creates if a locally-originated incoming
13500 message does not have one. The text of this header is required by RFC 2822 to
13501 take the form of an address. By default, Exim uses its internal message id as
13502 the local part, and the primary host name as the domain. If this option is set,
13503 it is expanded, and provided the expansion is not forced to fail, and does not
13504 yield an empty string, the result is inserted into the header immediately
13505 before the @, separated from the internal message id by a dot. Any characters
13506 that are illegal in an address are automatically converted into hyphens. This
13507 means that variables such as &$tod_log$& can be used, because the spaces and
13508 colons will become hyphens.
13509
13510
13511 .option message_logs main boolean true
13512 .cindex "message log" "disabling"
13513 .cindex "log" "message log; disabling"
13514 If this option is turned off, per-message log files are not created in the
13515 &_msglog_& spool sub-directory. This reduces the amount of disk I/O required by
13516 Exim, by reducing the number of files involved in handling a message from a
13517 minimum of four (header spool file, body spool file, delivery journal, and
13518 per-message log) to three. The other major I/O activity is Exim's main log,
13519 which is not affected by this option.
13520
13521
13522 .option message_size_limit main string&!! 50M
13523 .cindex "message" "size limit"
13524 .cindex "limit" "message size"
13525 .cindex "size of message" "limit"
13526 This option limits the maximum size of message that Exim will process. The
13527 value is expanded for each incoming
13528 connection so, for example, it can be made to depend on the IP address of the
13529 remote host for messages arriving via TCP/IP. &*Note*&: This limit cannot be
13530 made to depend on a message's sender or any other properties of an individual
13531 message, because it has to be advertised in the server's response to EHLO.
13532 String expansion failure causes a temporary error. A value of zero means no
13533 limit, but its use is not recommended. See also &%bounce_return_size_limit%&.
13534
13535 Incoming SMTP messages are failed with a 552 error if the limit is
13536 exceeded; locally-generated messages either get a stderr message or a delivery
13537 failure message to the sender, depending on the &%-oe%& setting. Rejection of
13538 an oversized message is logged in both the main and the reject logs. See also
13539 the generic transport option &%message_size_limit%&, which limits the size of
13540 message that an individual transport can process.
13541
13542
13543 .option move_frozen_messages main boolean false
13544 .cindex "frozen messages" "moving"
13545 This option, which is available only if Exim has been built with the setting
13546 .code
13547 SUPPORT_MOVE_FROZEN_MESSAGES=yes
13548 .endd
13549 in &_Local/Makefile_&, causes frozen messages and their message logs to be
13550 moved from the &_input_& and &_msglog_& directories on the spool to &_Finput_&
13551 and &_Fmsglog_&, respectively. There is currently no support in Exim or the
13552 standard utilities for handling such moved messages, and they do not show up in
13553 lists generated by &%-bp%& or by the Exim monitor.
13554
13555
13556 .option mua_wrapper main boolean false
13557 Setting this option true causes Exim to run in a very restrictive mode in which
13558 it passes messages synchronously to a smart host. Chapter &<<CHAPnonqueueing>>&
13559 contains a full description of this facility.
13560
13561
13562
13563 .option mysql_servers main "string list" unset
13564 .cindex "MySQL" "server list"
13565 This option provides a list of MySQL servers and associated connection data, to
13566 be used in conjunction with &(mysql)& lookups (see section &<<SECTsql>>&). The
13567 option is available only if Exim has been built with MySQL support.
13568
13569
13570 .option never_users main "string list&!!" unset
13571 This option is expanded just once, at the start of Exim's processing. Local
13572 message deliveries are normally run in processes that are setuid to the
13573 recipient, and remote deliveries are normally run under Exim's own uid and gid.
13574 It is usually desirable to prevent any deliveries from running as root, as a
13575 safety precaution.
13576
13577 When Exim is built, an option called FIXED_NEVER_USERS can be set to a
13578 list of users that must not be used for local deliveries. This list is fixed in
13579 the binary and cannot be overridden by the configuration file. By default, it
13580 contains just the single user name &"root"&. The &%never_users%& runtime option
13581 can be used to add more users to the fixed list.
13582
13583 If a message is to be delivered as one of the users on the fixed list or the
13584 &%never_users%& list, an error occurs, and delivery is deferred. A common
13585 example is
13586 .code
13587 never_users = root:daemon:bin
13588 .endd
13589 Including root is redundant if it is also on the fixed list, but it does no
13590 harm. This option overrides the &%pipe_as_creator%& option of the &(pipe)&
13591 transport driver.
13592
13593
13594 .option oracle_servers main "string list" unset
13595 .cindex "Oracle" "server list"
13596 This option provides a list of Oracle servers and associated connection data,
13597 to be used in conjunction with &(oracle)& lookups (see section &<<SECTsql>>&).
13598 The option is available only if Exim has been built with Oracle support.
13599
13600
13601 .option percent_hack_domains main "domain list&!!" unset
13602 .cindex "&""percent hack""&"
13603 .cindex "source routing" "in email address"
13604 .cindex "address" "source-routed"
13605 The &"percent hack"& is the convention whereby a local part containing a
13606 percent sign is re-interpreted as a new email address, with the percent
13607 replaced by @. This is sometimes called &"source routing"&, though that term is
13608 also applied to RFC 2822 addresses that begin with an @ character. If this
13609 option is set, Exim implements the percent facility for those domains listed,
13610 but no others. This happens before an incoming SMTP address is tested against
13611 an ACL.
13612
13613 &*Warning*&: The &"percent hack"& has often been abused by people who are
13614 trying to get round relaying restrictions. For this reason, it is best avoided
13615 if at all possible. Unfortunately, a number of less security-conscious MTAs
13616 implement it unconditionally. If you are running Exim on a gateway host, and
13617 routing mail through to internal MTAs without processing the local parts, it is
13618 a good idea to reject recipient addresses with percent characters in their
13619 local parts. Exim's default configuration does this.
13620
13621
13622 .option perl_at_start main boolean false
13623 This option is available only when Exim is built with an embedded Perl
13624 interpreter. See chapter &<<CHAPperl>>& for details of its use.
13625
13626
13627 .option perl_startup main string unset
13628 This option is available only when Exim is built with an embedded Perl
13629 interpreter. See chapter &<<CHAPperl>>& for details of its use.
13630
13631
13632 .option pgsql_servers main "string list" unset
13633 .cindex "PostgreSQL lookup type" "server list"
13634 This option provides a list of PostgreSQL servers and associated connection
13635 data, to be used in conjunction with &(pgsql)& lookups (see section
13636 &<<SECTsql>>&). The option is available only if Exim has been built with
13637 PostgreSQL support.
13638
13639
13640 .option pid_file_path main string&!! "set at compile time"
13641 .cindex "daemon" "pid file path"
13642 .cindex "pid file" "path for"
13643 This option sets the name of the file to which the Exim daemon writes its
13644 process id. The string is expanded, so it can contain, for example, references
13645 to the host name:
13646 .code
13647 pid_file_path = /var/log/$primary_hostname/exim.pid
13648 .endd
13649 If no path is set, the pid is written to the file &_exim-daemon.pid_& in Exim's
13650 spool directory.
13651 The value set by the option can be overridden by the &%-oP%& command line
13652 option. A pid file is not written if a &"non-standard"& daemon is run by means
13653 of the &%-oX%& option, unless a path is explicitly supplied by &%-oP%&.
13654
13655
13656 .option pipelining_advertise_hosts main "host list&!!" *
13657 .cindex "PIPELINING advertising" "suppressing"
13658 This option can be used to suppress the advertisement of the SMTP
13659 PIPELINING extension to specific hosts. When PIPELINING is not
13660 advertised and &%smtp_enforce_sync%& is true, an Exim server enforces strict
13661 synchronization for each SMTP command and response.
13662 When PIPELINING is advertised, Exim assumes that clients will use it; &"out
13663 of order"& commands that are &"expected"& do not count as protocol errors (see
13664 &%smtp_max_synprot_errors%&).
13665
13666
13667 .option preserve_message_logs main boolean false
13668 .cindex "message logs" "preserving"
13669 If this option is set, message log files are not deleted when messages are
13670 completed. Instead, they are moved to a sub-directory of the spool directory
13671 called &_msglog.OLD_&, where they remain available for statistical or debugging
13672 purposes. This is a dangerous option to set on systems with any appreciable
13673 volume of mail. Use with care!
13674
13675
13676 .option primary_hostname main string "see below"
13677 .cindex "name" "of local host"
13678 .cindex "host" "name of local"
13679 .cindex "local host" "name of"
13680 .cindex "&$primary_hostname$&"
13681 This specifies the name of the current host. It is used in the default EHLO or
13682 HELO command for outgoing SMTP messages (changeable via the &%helo_data%&
13683 option in the &(smtp)& transport), and as the default for &%qualify_domain%&.
13684 The value is also used by default in some SMTP response messages from an Exim
13685 server. This can be changed dynamically by setting &%smtp_active_hostname%&.
13686
13687 If &%primary_hostname%& is not set, Exim calls &[uname()]& to find the host
13688 name. If this fails, Exim panics and dies. If the name returned by &[uname()]&
13689 contains only one component, Exim passes it to &[gethostbyname()]& (or
13690 &[getipnodebyname()]& when available) in order to obtain the fully qualified
13691 version. The variable &$primary_hostname$& contains the host name, whether set
13692 explicitly by this option, or defaulted.
13693
13694
13695 .option print_topbitchars main boolean false
13696 .cindex "printing characters"
13697 .cindex "8-bit characters"
13698 By default, Exim considers only those characters whose codes lie in the range
13699 32&--126 to be printing characters. In a number of circumstances (for example,
13700 when writing log entries) non-printing characters are converted into escape
13701 sequences, primarily to avoid messing up the layout. If &%print_topbitchars%&
13702 is set, code values of 128 and above are also considered to be printing
13703 characters.
13704
13705 This option also affects the header syntax checks performed by the
13706 &(autoreply)& transport, and whether Exim uses RFC 2047 encoding of
13707 the user's full name when constructing From: and Sender: addresses (as
13708 described in section &<<SECTconstr>>&). Setting this option can cause
13709 Exim to generate eight bit message headers that do not conform to the
13710 standards.
13711
13712
13713 .option process_log_path main string unset
13714 .cindex "process log path"
13715 .cindex "log" "process log"
13716 .cindex "&'exiwhat'&"
13717 This option sets the name of the file to which an Exim process writes its
13718 &"process log"& when sent a USR1 signal. This is used by the &'exiwhat'&
13719 utility script. If this option is unset, the file called &_exim-process.info_&
13720 in Exim's spool directory is used. The ability to specify the name explicitly
13721 can be useful in environments where two different Exims are running, using
13722 different spool directories.
13723
13724
13725 .option prod_requires_admin main boolean true
13726 .cindex "&%-M%& option"
13727 .cindex "&%-R%& option"
13728 .cindex "&%-q%& option"
13729 The &%-M%&, &%-R%&, and &%-q%& command-line options require the caller to be an
13730 admin user unless &%prod_requires_admin%& is set false. See also
13731 &%queue_list_requires_admin%&.
13732
13733
13734 .option qualify_domain main string "see below"
13735 .cindex "domain" "for qualifying addresses"
13736 .cindex "address" "qualification"
13737 This option specifies the domain name that is added to any envelope sender
13738 addresses that do not have a domain qualification. It also applies to
13739 recipient addresses if &%qualify_recipient%& is not set. Unqualified addresses
13740 are accepted by default only for locally-generated messages. Qualification is
13741 also applied to addresses in header lines such as &'From:'& and &'To:'& for
13742 locally-generated messages, unless the &%-bnq%& command line option is used.
13743
13744 Messages from external sources must always contain fully qualified addresses,
13745 unless the sending host matches &%sender_unqualified_hosts%& or
13746 &%recipient_unqualified_hosts%& (as appropriate), in which case incoming
13747 addresses are qualified with &%qualify_domain%& or &%qualify_recipient%& as
13748 necessary. Internally, Exim always works with fully qualified envelope
13749 addresses. If &%qualify_domain%& is not set, it defaults to the
13750 &%primary_hostname%& value.
13751
13752
13753 .option qualify_recipient main string "see below"
13754 This option allows you to specify a different domain for qualifying recipient
13755 addresses to the one that is used for senders. See &%qualify_domain%& above.
13756
13757
13758
13759 .option queue_domains main "domain list&!!" unset
13760 .cindex "domain" "specifying non-immediate delivery"
13761 .cindex "queueing incoming messages"
13762 .cindex "message" "queueing certain domains"
13763 This option lists domains for which immediate delivery is not required.
13764 A delivery process is started whenever a message is received, but only those
13765 domains that do not match are processed. All other deliveries wait until the
13766 next queue run. See also &%hold_domains%& and &%queue_smtp_domains%&.
13767
13768
13769 .option queue_list_requires_admin main boolean true
13770 .cindex "&%-bp%& option"
13771 The &%-bp%& command-line option, which lists the messages that are on the
13772 queue, requires the caller to be an admin user unless
13773 &%queue_list_requires_admin%& is set false. See also &%prod_requires_admin%&.
13774
13775
13776 .option queue_only main boolean false
13777 .cindex "queueing incoming messages"
13778 .cindex "message" "queueing unconditionally"
13779 If &%queue_only%& is set, a delivery process is not automatically started
13780 whenever a message is received. Instead, the message waits on the queue for the
13781 next queue run. Even if &%queue_only%& is false, incoming messages may not get
13782 delivered immediately when certain conditions (such as heavy load) occur.
13783
13784 The &%-odq%& command line has the same effect as &%queue_only%&. The &%-odb%&
13785 and &%-odi%& command line options override &%queue_only%& unless
13786 &%queue_only_override%& is set false. See also &%queue_only_file%&,
13787 &%queue_only_load%&, and &%smtp_accept_queue%&.
13788
13789
13790 .option queue_only_file main string unset
13791 .cindex "queueing incoming messages"
13792 .cindex "message" "queueing by file existence"
13793 This option can be set to a colon-separated list of absolute path names, each
13794 one optionally preceded by &"smtp"&. When Exim is receiving a message,
13795 it tests for the existence of each listed path using a call to &[stat()]&. For
13796 each path that exists, the corresponding queuing option is set.
13797 For paths with no prefix, &%queue_only%& is set; for paths prefixed by
13798 &"smtp"&, &%queue_smtp_domains%& is set to match all domains. So, for example,
13799 .code
13800 queue_only_file = smtp/some/file
13801 .endd
13802 causes Exim to behave as if &%queue_smtp_domains%& were set to &"*"& whenever
13803 &_/some/file_& exists.
13804
13805
13806 .option queue_only_load main fixed-point unset
13807 .cindex "load average"
13808 .cindex "queueing incoming messages"
13809 .cindex "message" "queueing by load"
13810 If the system load average is higher than this value, incoming messages from
13811 all sources are queued, and no automatic deliveries are started. If this
13812 happens during local or remote SMTP input, all subsequent messages on the same
13813 connection are queued. Deliveries will subsequently be performed by queue
13814 runner processes. This option has no effect on ancient operating systems on
13815 which Exim cannot determine the load average. See also
13816 &%deliver_queue_load_max%& and &%smtp_load_reserve%&.
13817
13818
13819 .option queue_only_override main boolean true
13820 .cindex "queueing incoming messages"
13821 When this option is true, the &%-od%&&'x'& command line options override the
13822 setting of &%queue_only%& or &%queue_only_file%& in the configuration file. If
13823 &%queue_only_override%& is set false, the &%-od%&&'x'& options cannot be used
13824 to override; they are accepted, but ignored.
13825
13826
13827 .option queue_run_in_order main boolean false
13828 .cindex "queue runner" "processing messages in order"
13829 If this option is set, queue runs happen in order of message arrival instead of
13830 in an arbitrary order. For this to happen, a complete list of the entire queue
13831 must be set up before the deliveries start. When the queue is all held in a
13832 single directory (the default), a single list is created for both the ordered
13833 and the non-ordered cases. However, if &%split_spool_directory%& is set, a
13834 single list is not created when &%queue_run_in_order%& is false. In this case,
13835 the sub-directories are processed one at a time (in a random order), and this
13836 avoids setting up one huge list for the whole queue. Thus, setting
13837 &%queue_run_in_order%& with &%split_spool_directory%& may degrade performance
13838 when the queue is large, because of the extra work in setting up the single,
13839 large list. In most situations, &%queue_run_in_order%& should not be set.
13840
13841
13842
13843 .option queue_run_max main integer 5
13844 .cindex "queue runner" "maximum number of"
13845 This controls the maximum number of queue runner processes that an Exim daemon
13846 can run simultaneously. This does not mean that it starts them all at once,
13847 but rather that if the maximum number are still running when the time comes to
13848 start another one, it refrains from starting another one. This can happen with
13849 very large queues and/or very sluggish deliveries. This option does not,
13850 however, interlock with other processes, so additional queue runners can be
13851 started by other means, or by killing and restarting the daemon.
13852
13853 Setting this option to zero does not suppress queue runs; rather, it disables
13854 the limit, allowing any number of simultaneous queue runner processes to be
13855 run. If you do not want queue runs to occur, omit the &%-q%&&'xx'& setting on
13856 the daemon's command line.
13857
13858 .option queue_smtp_domains main "domain list&!!" unset
13859 .cindex "queueing incoming messages"
13860 .cindex "message" "queueing remote deliveries"
13861 When this option is set, a delivery process is started whenever a message is
13862 received, routing is performed, and local deliveries take place.
13863 However, if any SMTP deliveries are required for domains that match
13864 &%queue_smtp_domains%&, they are not immediately delivered, but instead the
13865 message waits on the queue for the next queue run. Since routing of the message
13866 has taken place, Exim knows to which remote hosts it must be delivered, and so
13867 when the queue run happens, multiple messages for the same host are delivered
13868 over a single SMTP connection. The &%-odqs%& command line option causes all
13869 SMTP deliveries to be queued in this way, and is equivalent to setting
13870 &%queue_smtp_domains%& to &"*"&. See also &%hold_domains%& and
13871 &%queue_domains%&.
13872
13873
13874 .option receive_timeout main time 0s
13875 .cindex "timeout" "for non-SMTP input"
13876 This option sets the timeout for accepting a non-SMTP message, that is, the
13877 maximum time that Exim waits when reading a message on the standard input. If
13878 the value is zero, it will wait for ever. This setting is overridden by the
13879 &%-or%& command line option. The timeout for incoming SMTP messages is
13880 controlled by &%smtp_receive_timeout%&.
13881
13882 .option received_header_text main string&!! "see below"
13883 .cindex "customizing" "&'Received:'& header"
13884 .cindex "&'Received:'& header line" "customizing"
13885 This string defines the contents of the &'Received:'& message header that is
13886 added to each message, except for the timestamp, which is automatically added
13887 on at the end (preceded by a semicolon). The string is expanded each time it is
13888 used. If the expansion yields an empty string, no &'Received:'& header line is
13889 added to the message. Otherwise, the string should start with the text
13890 &"Received:"& and conform to the RFC 2822 specification for &'Received:'&
13891 header lines. The default setting is:
13892
13893 .code
13894 received_header_text = Received: \
13895   ${if def:sender_rcvhost {from $sender_rcvhost\n\t}\
13896   {${if def:sender_ident \
13897   {from ${quote_local_part:$sender_ident} }}\
13898   ${if def:sender_helo_name {(helo=$sender_helo_name)\n\t}}}}\
13899   by $primary_hostname \
13900   ${if def:received_protocol {with $received_protocol}} \
13901   ${if def:tls_cipher {($tls_cipher)\n\t}}\
13902   (Exim $version_number)\n\t\
13903   ${if def:sender_address \
13904   {(envelope-from <$sender_address>)\n\t}}\
13905   id $message_exim_id\
13906   ${if def:received_for {\n\tfor $received_for}}
13907 .endd
13908
13909 The reference to the TLS cipher is omitted when Exim is built without TLS
13910 support. The use of conditional expansions ensures that this works for both
13911 locally generated messages and messages received from remote hosts, giving
13912 header lines such as the following:
13913 .code
13914 Received: from scrooge.carol.example ([192.168.12.25] ident=root)
13915 by marley.carol.example with esmtp (Exim 4.00)
13916 (envelope-from <bob@carol.example>)
13917 id 16IOWa-00019l-00
13918 for chas@dickens.example; Tue, 25 Dec 2001 14:43:44 +0000
13919 Received: by scrooge.carol.example with local (Exim 4.00)
13920 id 16IOWW-000083-00; Tue, 25 Dec 2001 14:43:41 +0000
13921 .endd
13922 Until the body of the message has been received, the timestamp is the time when
13923 the message started to be received. Once the body has arrived, and all policy
13924 checks have taken place, the timestamp is updated to the time at which the
13925 message was accepted.
13926
13927
13928 .option received_headers_max main integer 30
13929 .cindex "loop" "prevention"
13930 .cindex "mail loop prevention"
13931 .cindex "&'Received:'& header line" "counting"
13932 When a message is to be delivered, the number of &'Received:'& headers is
13933 counted, and if it is greater than this parameter, a mail loop is assumed to
13934 have occurred, the delivery is abandoned, and an error message is generated.
13935 This applies to both local and remote deliveries.
13936
13937
13938 .option recipient_unqualified_hosts main "host list&!!" unset
13939 .cindex "unqualified addresses"
13940 .cindex "host" "unqualified addresses from"
13941 This option lists those hosts from which Exim is prepared to accept unqualified
13942 recipient addresses in message envelopes. The addresses are made fully
13943 qualified by the addition of the &%qualify_recipient%& value. This option also
13944 affects message header lines. Exim does not reject unqualified recipient
13945 addresses in headers, but it qualifies them only if the message came from a
13946 host that matches &%recipient_unqualified_hosts%&,
13947 or if the message was submitted locally (not using TCP/IP), and the &%-bnq%&
13948 option was not set.
13949
13950
13951 .option recipients_max main integer 0
13952 .cindex "limit" "number of recipients"
13953 .cindex "recipient" "maximum number"
13954 If this option is set greater than zero, it specifies the maximum number of
13955 original recipients for any message. Additional recipients that are generated
13956 by aliasing or forwarding do not count. SMTP messages get a 452 response for
13957 all recipients over the limit; earlier recipients are delivered as normal.
13958 Non-SMTP messages with too many recipients are failed, and no deliveries are
13959 done.
13960
13961 .cindex "RCPT" "maximum number of incoming"
13962 &*Note*&: The RFCs specify that an SMTP server should accept at least 100
13963 RCPT commands in a single message.
13964
13965
13966 .option recipients_max_reject main boolean false
13967 If this option is set true, Exim rejects SMTP messages containing too many
13968 recipients by giving 552 errors to the surplus RCPT commands, and a 554
13969 error to the eventual DATA command. Otherwise (the default) it gives a 452
13970 error to the surplus RCPT commands and accepts the message on behalf of the
13971 initial set of recipients. The remote server should then re-send the message
13972 for the remaining recipients at a later time.
13973
13974
13975 .option remote_max_parallel main integer 2
13976 .cindex "delivery" "parallelism for remote"
13977 This option controls parallel delivery of one message to a number of remote
13978 hosts. If the value is less than 2, parallel delivery is disabled, and Exim
13979 does all the remote deliveries for a message one by one. Otherwise, if a single
13980 message has to be delivered to more than one remote host, or if several copies
13981 have to be sent to the same remote host, up to &%remote_max_parallel%&
13982 deliveries are done simultaneously. If more than &%remote_max_parallel%&
13983 deliveries are required, the maximum number of processes are started, and as
13984 each one finishes, another is begun. The order of starting processes is the
13985 same as if sequential delivery were being done, and can be controlled by the
13986 &%remote_sort_domains%& option. If parallel delivery takes place while running
13987 with debugging turned on, the debugging output from each delivery process is
13988 tagged with its process id.
13989
13990 This option controls only the maximum number of parallel deliveries for one
13991 message in one Exim delivery process. Because Exim has no central queue
13992 manager, there is no way of controlling the total number of simultaneous
13993 deliveries if the configuration allows a delivery attempt as soon as a message
13994 is received.
13995
13996 .cindex "number of deliveries"
13997 .cindex "delivery" "maximum number of"
13998 If you want to control the total number of deliveries on the system, you
13999 need to set the &%queue_only%& option. This ensures that all incoming messages
14000 are added to the queue without starting a delivery process. Then set up an Exim
14001 daemon to start queue runner processes at appropriate intervals (probably
14002 fairly often, for example, every minute), and limit the total number of queue
14003 runners by setting the &%queue_run_max%& parameter. Because each queue runner
14004 delivers only one message at a time, the maximum number of deliveries that can
14005 then take place at once is &%queue_run_max%& multiplied by
14006 &%remote_max_parallel%&.
14007
14008 If it is purely remote deliveries you want to control, use
14009 &%queue_smtp_domains%& instead of &%queue_only%&. This has the added benefit of
14010 doing the SMTP routing before queuing, so that several messages for the same
14011 host will eventually get delivered down the same connection.
14012
14013
14014 .option remote_sort_domains main "domain list&!!" unset
14015 .cindex "sorting remote deliveries"
14016 .cindex "delivery" "sorting remote"
14017 When there are a number of remote deliveries for a message, they are sorted by
14018 domain into the order given by this list. For example,
14019 .code
14020 remote_sort_domains = *.cam.ac.uk:*.uk
14021 .endd
14022 would attempt to deliver to all addresses in the &'cam.ac.uk'& domain first,
14023 then to those in the &%uk%& domain, then to any others.
14024
14025
14026 .option retry_data_expire main time 7d
14027 .cindex "hints database" "data expiry"
14028 This option sets a &"use before"& time on retry information in Exim's hints
14029 database. Any older retry data is ignored. This means that, for example, once a
14030 host has not been tried for 7 days, Exim behaves as if it has no knowledge of
14031 past failures.
14032
14033
14034 .option retry_interval_max main time 24h
14035 .cindex "retry" "limit on interval"
14036 .cindex "limit" "on retry interval"
14037 Chapter &<<CHAPretry>>& describes Exim's mechanisms for controlling the
14038 intervals between delivery attempts for messages that cannot be delivered
14039 straight away. This option sets an overall limit to the length of time between
14040 retries. It cannot be set greater than 24 hours; any attempt to do so forces
14041 the default value.
14042
14043
14044 .option return_path_remove main boolean true
14045 .cindex "&'Return-path:'& header line" "removing"
14046 RFC 2821, section 4.4, states that an SMTP server must insert a
14047 &'Return-path:'& header line into a message when it makes a &"final delivery"&.
14048 The &'Return-path:'& header preserves the sender address as received in the
14049 MAIL command. This description implies that this header should not be present
14050 in an incoming message. If &%return_path_remove%& is true, any existing
14051 &'Return-path:'& headers are removed from messages at the time they are
14052 received. Exim's transports have options for adding &'Return-path:'& headers at
14053 the time of delivery. They are normally used only for final local deliveries.
14054
14055
14056 .option return_size_limit main integer 100K
14057 This option is an obsolete synonym for &%bounce_return_size_limit%&.
14058
14059
14060 .option rfc1413_hosts main "host list&!!" *
14061 .cindex "RFC 1413"
14062 .cindex "host" "for RFC 1413 calls"
14063 RFC 1413 identification calls are made to any client host which matches an item
14064 in the list.
14065
14066 .option rfc1413_query_timeout main time 5s
14067 .cindex "RFC 1413" "query timeout"
14068 .cindex "timeout" "for RFC 1413 call"
14069 This sets the timeout on RFC 1413 identification calls. If it is set to zero,
14070 no RFC 1413 calls are ever made.
14071
14072
14073 .option sender_unqualified_hosts main "host list&!!" unset
14074 .cindex "unqualified addresses"
14075 .cindex "host" "unqualified addresses from"
14076 This option lists those hosts from which Exim is prepared to accept unqualified
14077 sender addresses. The addresses are made fully qualified by the addition of
14078 &%qualify_domain%&. This option also affects message header lines. Exim does
14079 not reject unqualified addresses in headers that contain sender addresses, but
14080 it qualifies them only if the message came from a host that matches
14081 &%sender_unqualified_hosts%&, or if the message was submitted locally (not
14082 using TCP/IP), and the &%-bnq%& option was not set.
14083
14084
14085 .option smtp_accept_keepalive main boolean true
14086 .cindex "keepalive" "on incoming connection"
14087 This option controls the setting of the SO_KEEPALIVE option on incoming
14088 TCP/IP socket connections. When set, it causes the kernel to probe idle
14089 connections periodically, by sending packets with &"old"& sequence numbers. The
14090 other end of the connection should send an acknowledgement if the connection is
14091 still okay or a reset if the connection has been aborted. The reason for doing
14092 this is that it has the beneficial effect of freeing up certain types of
14093 connection that can get stuck when the remote host is disconnected without
14094 tidying up the TCP/IP call properly. The keepalive mechanism takes several
14095 hours to detect unreachable hosts.
14096
14097
14098
14099 .option smtp_accept_max main integer 20
14100 .cindex "limit" "incoming SMTP connections"
14101 .cindex "SMTP" "incoming connection count"
14102 .cindex "inetd"
14103 This option specifies the maximum number of simultaneous incoming SMTP calls
14104 that Exim will accept. It applies only to the listening daemon; there is no
14105 control (in Exim) when incoming SMTP is being handled by &'inetd'&. If the
14106 value is set to zero, no limit is applied. However, it is required to be
14107 non-zero if either &%smtp_accept_max_per_host%& or &%smtp_accept_queue%& is
14108 set. See also &%smtp_accept_reserve%&.
14109
14110
14111
14112 .option smtp_accept_max_nonmail main integer 10
14113 .cindex "limit" "non-mail SMTP commands"
14114 .cindex "SMTP" "limiting non-mail commands"
14115 Exim counts the number of &"non-mail"& commands in an SMTP session, and drops
14116 the connection if there are too many. This option defines &"too many"&. The
14117 check catches some denial-of-service attacks, repeated failing AUTHs, or a mad
14118 client looping sending EHLO, for example. The check is applied only if the
14119 client host matches &%smtp_accept_max_nonmail_hosts%&.
14120
14121 When a new message is expected, one occurrence of RSET is not counted. This
14122 allows a client to send one RSET between messages (this is not necessary,
14123 but some clients do it). Exim also allows one uncounted occurence of HELO
14124 or EHLO, and one occurrence of STARTTLS between messages. After
14125 starting up a TLS session, another EHLO is expected, and so it too is not
14126 counted. The first occurrence of AUTH in a connection, or immediately
14127 following STARTTLS is not counted. Otherwise, all commands other than
14128 MAIL, RCPT, DATA, and QUIT are counted.
14129
14130
14131 .option smtp_accept_max_nonmail_hosts main "host list&!!" *
14132 You can control which hosts are subject to the &%smtp_accept_max_nonmail%&
14133 check by setting this option. The default value makes it apply to all hosts. By
14134 changing the value, you can exclude any badly-behaved hosts that you have to
14135 live with.
14136
14137
14138
14139 .option smtp_accept_max_per_connection main integer 1000
14140 .cindex "SMTP incoming message count" "limiting"
14141 .cindex "limit" "messages per SMTP connection"
14142 The value of this option limits the number of MAIL commands that Exim is
14143 prepared to accept over a single SMTP connection, whether or not each command
14144 results in the transfer of a message. After the limit is reached, a 421
14145 response is given to subsequent MAIL commands. This limit is a safety
14146 precaution against a client that goes mad (incidents of this type have been
14147 seen).
14148
14149
14150 .option smtp_accept_max_per_host main string&!! unset
14151 .cindex "limit" "SMTP connections from one host"
14152 .cindex "host" "limiting SMTP connections from"
14153 This option restricts the number of simultaneous IP connections from a single
14154 host (strictly, from a single IP address) to the Exim daemon. The option is
14155 expanded, to enable different limits to be applied to different hosts by
14156 reference to &$sender_host_address$&. Once the limit is reached, additional
14157 connection attempts from the same host are rejected with error code 421. The
14158 default value of zero imposes no limit. If this option is set, it is required
14159 that &%smtp_accept_max%& be non-zero.
14160
14161 &*Warning*&: When setting this option you should not use any expansion
14162 constructions that take an appreciable amount of time. The expansion and test
14163 happen in the main daemon loop, in order to reject additional connections
14164 without forking additional processes (otherwise a denial-of-service attack
14165 could cause a vast number or processes to be created). While the daemon is
14166 doing this processing, it cannot accept any other incoming connections.
14167
14168
14169
14170 .option smtp_accept_queue main integer 0
14171 .cindex "SMTP" "incoming connection count"
14172 .cindex "queueing incoming messages"
14173 .cindex "message" "queueing by SMTP connection count"
14174 If the number of simultaneous incoming SMTP calls handled via the listening
14175 daemon exceeds this value, messages received by SMTP are just placed on the
14176 queue; no delivery processes are started automatically. A value of zero implies
14177 no limit, and clearly any non-zero value is useful only if it is less than the
14178 &%smtp_accept_max%& value (unless that is zero). See also &%queue_only%&,
14179 &%queue_only_load%&, &%queue_smtp_domains%&, and the various &%-od%&&'x'&
14180 command line options.
14181
14182
14183 .option smtp_accept_queue_per_connection main integer 10
14184 .cindex "queueing incoming messages"
14185 .cindex "message" "queueing by message count"
14186 This option limits the number of delivery processes that Exim starts
14187 automatically when receiving messages via SMTP, whether via the daemon or by
14188 the use of &%-bs%& or &%-bS%&. If the value of the option is greater than zero,
14189 and the number of messages received in a single SMTP session exceeds this
14190 number, subsequent messages are placed on the queue, but no delivery processes
14191 are started. This helps to limit the number of Exim processes when a server
14192 restarts after downtime and there is a lot of mail waiting for it on other
14193 systems. On large systems, the default should probably be increased, and on
14194 dial-in client systems it should probably be set to zero (that is, disabled).
14195
14196
14197 .option smtp_accept_reserve main integer 0
14198 .cindex "SMTP" "incoming call count"
14199 .cindex "host" "reserved"
14200 When &%smtp_accept_max%& is set greater than zero, this option specifies a
14201 number of SMTP connections that are reserved for connections from the hosts
14202 that are specified in &%smtp_reserve_hosts%&. The value set in
14203 &%smtp_accept_max%& includes this reserve pool. The specified hosts are not
14204 restricted to this number of connections; the option specifies a minimum number
14205 of connection slots for them, not a maximum. It is a guarantee that that group
14206 of hosts can always get at least &%smtp_accept_reserve%& connections.
14207
14208 For example, if &%smtp_accept_max%& is set to 50 and &%smtp_accept_reserve%& is
14209 set to 5, once there are 45 active connections (from any hosts), new
14210 connections are accepted only from hosts listed in &%smtp_reserve_hosts%&.
14211 See also &%smtp_accept_max_per_host%&.
14212
14213
14214 .option smtp_active_hostname main string&!! unset
14215 .new
14216 .cindex "host" "name in SMTP responses"
14217 .cindex "SMTP" "host name in responses"
14218 .cindex "&$primary_hostname$&"
14219 This option is provided for multi-homed servers that want to masquerade as
14220 several different hosts. At the start of an incoming SMTP connection, its value
14221 is expanded and used instead of the value of &$primary_hostname$& in SMTP
14222 responses. For example, it is used as domain name in the response to an
14223 incoming HELO or EHLO command.
14224
14225 .cindex "&$smtp_active_hostname$&"
14226 The active hostname is placed in the &$smtp_active_hostname$& variable, which
14227 is saved with any messages that are received. It is therefore available for use
14228 in routers and transports when the message is later delivered.
14229
14230 If this option is unset, or if its expansion is forced to fail, or if the
14231 expansion results in an empty string, the value of &$primary_hostname$& is
14232 used. Other expansion failures cause a message to be written to the main and
14233 panic logs, and the SMTP command receives a temporary error. Typically, the
14234 value of &%smtp_active_hostname%& depends on the incoming interface address.
14235 For example:
14236 .code
14237 smtp_active_hostname = ${if eq{$received_ip_address}{10.0.0.1}\
14238   {cox.mydomain}{box.mydomain}}
14239 .endd
14240
14241 Although &$smtp_active_hostname$& is primarily concerned with incoming
14242 messages, it is also used as the default for HELO commands in callout
14243 verification if there is no remote transport from which to obtain a
14244 &%helo_data%& value.
14245 .wen
14246
14247 .option smtp_banner main string&!! "see below"
14248 .cindex "SMTP" "welcome banner"
14249 .cindex "banner for SMTP"
14250 .cindex "welcome banner for SMTP"
14251 .cindex "customizing" "SMTP banner"
14252 This string, which is expanded every time it is used, is output as the initial
14253 positive response to an SMTP connection. The default setting is:
14254 .code
14255 smtp_banner = $smtp_active_hostname ESMTP Exim \
14256   $version_number $tod_full
14257 .endd
14258 Failure to expand the string causes a panic error. If you want to create a
14259 multiline response to the initial SMTP connection, use &"\n"& in the string at
14260 appropriate points, but not at the end. Note that the 220 code is not included
14261 in this string. Exim adds it automatically (several times in the case of a
14262 multiline response).
14263
14264
14265 .option smtp_check_spool_space main boolean true
14266 .cindex "checking disk space"
14267 .cindex "disk space" "checking"
14268 .cindex "spool directory" "checking space"
14269 When this option is set, if an incoming SMTP session encounters the SIZE
14270 option on a MAIL command, it checks that there is enough space in the
14271 spool directory's partition to accept a message of that size, while still
14272 leaving free the amount specified by &%check_spool_space%& (even if that value
14273 is zero). If there isn't enough space, a temporary error code is returned.
14274
14275
14276 .option smtp_connect_backlog main integer 20
14277 .cindex "connection backlog"
14278 .cindex "SMTP" "connection backlog"
14279 .cindex "backlog of connections"
14280 This option specifies a maximum number of waiting SMTP connections. Exim passes
14281 this value to the TCP/IP system when it sets up its listener. Once this number
14282 of connections are waiting for the daemon's attention, subsequent connection
14283 attempts are refused at the TCP/IP level. At least, that is what the manuals
14284 say; in some circumstances such connection attempts have been observed to time
14285 out instead. For large systems it is probably a good idea to increase the
14286 value (to 50, say). It also gives some protection against denial-of-service
14287 attacks by SYN flooding.
14288
14289
14290 .option smtp_enforce_sync main boolean true
14291 .cindex "SMTP" "synchronization checking"
14292 .cindex "synchronization checking in SMTP"
14293 The SMTP protocol specification requires the client to wait for a response from
14294 the server at certain points in the dialogue. Without PIPELINING these
14295 synchronization points are after every command; with PIPELINING they are
14296 fewer, but they still exist.
14297
14298 Some spamming sites send out a complete set of SMTP commands without waiting
14299 for any response. Exim protects against this by rejecting a message if the
14300 client has sent further input when it should not have. The error response &"554
14301 SMTP synchronization error"& is sent, and the connection is dropped. Testing
14302 for this error cannot be perfect because of transmission delays (unexpected
14303 input may be on its way but not yet received when Exim checks). However, it
14304 does detect many instances.
14305
14306 The check can be globally disabled by setting &%smtp_enforce_sync%& false.
14307 If you want to disable the check selectively (for example, only for certain
14308 hosts), you can do so by an appropriate use of a &%control%& modifier in an ACL
14309 (see section &<<SECTcontrols>>&). See also &%pipelining_advertise_hosts%&.
14310
14311
14312
14313 .option smtp_etrn_command main string&!! unset
14314 .cindex "ETRN" "command to be run"
14315 .cindex "&$domain$&"
14316 If this option is set, the given command is run whenever an SMTP ETRN
14317 command is received from a host that is permitted to issue such commands (see
14318 chapter &<<CHAPACL>>&). The string is split up into separate arguments which
14319 are independently expanded. The expansion variable &$domain$& is set to the
14320 argument of the ETRN command, and no syntax checking is done on it. For
14321 example:
14322 .code
14323 smtp_etrn_command = /etc/etrn_command $domain \
14324                     $sender_host_address
14325 .endd
14326 A new process is created to run the command, but Exim does not wait for it to
14327 complete. Consequently, its status cannot be checked. If the command cannot be
14328 run, a line is written to the panic log, but the ETRN caller still receives
14329 a 250 success response. Exim is normally running under its own uid when
14330 receiving SMTP, so it is not possible for it to change the uid before running
14331 the command.
14332
14333
14334 .option smtp_etrn_serialize main boolean true
14335 .cindex "ETRN" "serializing"
14336 When this option is set, it prevents the simultaneous execution of more than
14337 one identical command as a result of ETRN in an SMTP connection. See
14338 section &<<SECTETRN>>& for details.
14339
14340
14341 .option smtp_load_reserve main fixed-point unset
14342 .cindex "load average"
14343 If the system load average ever gets higher than this, incoming SMTP calls are
14344 accepted only from those hosts that match an entry in &%smtp_reserve_hosts%&.
14345 If &%smtp_reserve_hosts%& is not set, no incoming SMTP calls are accepted when
14346 the load is over the limit. The option has no effect on ancient operating
14347 systems on which Exim cannot determine the load average. See also
14348 &%deliver_queue_load_max%& and &%queue_only_load%&.
14349
14350
14351
14352 .option smtp_max_synprot_errors main integer 3
14353 .cindex "SMTP" "limiting syntax and protocol errors"
14354 .cindex "limit" "SMTP syntax and protocol errors"
14355 Exim rejects SMTP commands that contain syntax or protocol errors. In
14356 particular, a syntactically invalid email address, as in this command:
14357 .code
14358 RCPT TO:<abc xyz@a.b.c>
14359 .endd
14360 causes immediate rejection of the command, before any other tests are done.
14361 (The ACL cannot be run if there is no valid address to set up for it.) An
14362 example of a protocol error is receiving RCPT before MAIL. If there are
14363 too many syntax or protocol errors in one SMTP session, the connection is
14364 dropped. The limit is set by this option.
14365
14366 .cindex "PIPELINING" "expected errors"
14367 When the PIPELINING extension to SMTP is in use, some protocol errors are
14368 &"expected"&, for instance, a RCPT command after a rejected MAIL command.
14369 Exim assumes that PIPELINING will be used if it advertises it (see
14370 &%pipelining_advertise_hosts%&), and in this situation, &"expected"& errors do
14371 not count towards the limit.
14372
14373
14374
14375 .option smtp_max_unknown_commands main integer 3
14376 .cindex "SMTP" "limiting unknown commands"
14377 .cindex "limit" "unknown SMTP commands"
14378 If there are too many unrecognized commands in an incoming SMTP session, an
14379 Exim server drops the connection. This is a defence against some kinds of abuse
14380 that subvert web
14381 clients
14382 into making connections to SMTP ports; in these circumstances, a number of
14383 non-SMTP command lines are sent first.
14384
14385
14386
14387 .option smtp_ratelimit_hosts main "host list&!!" unset
14388 .cindex "SMTP" "rate limiting"
14389 .cindex "limit" "rate of message arrival"
14390 .cindex "RCPT" "rate limiting"
14391 Some sites find it helpful to be able to limit the rate at which certain hosts
14392 can send them messages, and the rate at which an individual message can specify
14393 recipients.
14394
14395 Exim has two rate-limiting facilities. This section describes the older
14396 facility, which can limit rates within a single connection. The newer
14397 &%ratelimit%& ACL condition can limit rates across all connections. See section
14398 &<<SECTratelimiting>>& for details of the newer facility.
14399
14400 When a host matches &%smtp_ratelimit_hosts%&, the values of
14401 &%smtp_ratelimit_mail%& and &%smtp_ratelimit_rcpt%& are used to control the
14402 rate of acceptance of MAIL and RCPT commands in a single SMTP session,
14403 respectively. Each option, if set, must contain a set of four comma-separated
14404 values:
14405
14406 .ilist
14407 A threshold, before which there is no rate limiting.
14408 .next
14409 An initial time delay. Unlike other times in Exim, numbers with decimal
14410 fractional parts are allowed here.
14411 .next
14412 A factor by which to increase the delay each time.
14413 .next
14414 A maximum value for the delay. This should normally be less than 5 minutes,
14415 because after that time, the client is liable to timeout the SMTP command.
14416 .endlist
14417
14418 For example, these settings have been used successfully at the site which
14419 first suggested this feature, for controlling mail from their customers:
14420 .code
14421 smtp_ratelimit_mail = 2,0.5s,1.05,4m
14422 smtp_ratelimit_rcpt = 4,0.25s,1.015,4m
14423 .endd
14424 The first setting specifies delays that are applied to MAIL commands after
14425 two have been received over a single connection. The initial delay is 0.5
14426 seconds, increasing by a factor of 1.05 each time. The second setting applies
14427 delays to RCPT commands when more than four occur in a single message.
14428
14429
14430 .option smtp_ratelimit_mail main string unset
14431 See &%smtp_ratelimit_hosts%& above.
14432
14433
14434 .option smtp_ratelimit_rcpt main string unset
14435 See &%smtp_ratelimit_hosts%& above.
14436
14437
14438 .option smtp_receive_timeout main time 5m
14439 .cindex "timeout" "for SMTP input"
14440 .cindex "SMTP timeout" "input"
14441 This sets a timeout value for SMTP reception. It applies to all forms of SMTP
14442 input, including batch SMTP. If a line of input (either an SMTP command or a
14443 data line) is not received within this time, the SMTP connection is dropped and
14444 the message is abandoned.
14445 A line is written to the log containing one of the following messages:
14446 .code
14447 SMTP command timeout on connection from...
14448 SMTP data timeout on connection from...
14449 .endd
14450 The former means that Exim was expecting to read an SMTP command; the latter
14451 means that it was in the DATA phase, reading the contents of a message.
14452
14453
14454 .cindex "&%-os%& option"
14455 The value set by this option can be overridden by the
14456 &%-os%& command-line option. A setting of zero time disables the timeout, but
14457 this should never be used for SMTP over TCP/IP. (It can be useful in some cases
14458 of local input using &%-bs%& or &%-bS%&.) For non-SMTP input, the reception
14459 timeout is controlled by &%receive_timeout%& and &%-or%&.
14460
14461
14462 .option smtp_reserve_hosts main "host list&!!" unset
14463 This option defines hosts for which SMTP connections are reserved; see
14464 &%smtp_accept_reserve%& and &%smtp_load_reserve%& above.
14465
14466
14467 .option smtp_return_error_details main boolean false
14468 .cindex "SMTP" "details policy failures"
14469 .cindex "policy control rejection" "returning details"
14470 In the default state, Exim uses bland messages such as
14471 &"Administrative prohibition"& when it rejects SMTP commands for policy
14472 reasons. Many sysadmins like this because it gives away little information
14473 to spammers. However, some other syadmins who are applying strict checking
14474 policies want to give out much fuller information about failures. Setting
14475 &%smtp_return_error_details%& true causes Exim to be more forthcoming. For
14476 example, instead of &"Administrative prohibition"&, it might give:
14477 .code
14478 550-Rejected after DATA: '>' missing at end of address:
14479 550 failing address in "From" header is: <user@dom.ain
14480 .endd
14481
14482 .option spamd_address main string "see below"
14483 This option is available when Exim is compiled with the content-scanning
14484 extension. It specifies how Exim connects to SpamAssassin's &%spamd%& daemon.
14485 The default value is
14486 .code
14487 127.0.0.1 783
14488 .endd
14489 See section &<<SECTscanspamass>>& for more details.
14490
14491
14492
14493 .option split_spool_directory main boolean false
14494 .cindex "multiple spool directories"
14495 .cindex "spool directory" "split"
14496 .cindex "directories" "multiple"
14497 If this option is set, it causes Exim to split its input directory into 62
14498 subdirectories, each with a single alphanumeric character as its name. The
14499 sixth character of the message id is used to allocate messages to
14500 subdirectories; this is the least significant base-62 digit of the time of
14501 arrival of the message.
14502
14503 Splitting up the spool in this way may provide better performance on systems
14504 where there are long mail queues, by reducing the number of files in any one
14505 directory. The msglog directory is also split up in a similar way to the input
14506 directory; however, if &%preserve_message_logs%& is set, all old msglog files
14507 are still placed in the single directory &_msglog.OLD_&.
14508
14509 It is not necessary to take any special action for existing messages when
14510 changing &%split_spool_directory%&. Exim notices messages that are in the
14511 &"wrong"& place, and continues to process them. If the option is turned off
14512 after a period of being on, the subdirectories will eventually empty and be
14513 automatically deleted.
14514
14515 When &%split_spool_directory%& is set, the behaviour of queue runner processes
14516 changes. Instead of creating a list of all messages in the queue, and then
14517 trying to deliver each one in turn, it constructs a list of those in one
14518 sub-directory and tries to deliver them, before moving on to the next
14519 sub-directory. The sub-directories are processed in a random order. This
14520 spreads out the scanning of the input directories, and uses less memory. It is
14521 particularly beneficial when there are lots of messages on the queue. However,
14522 if &%queue_run_in_order%& is set, none of this new processing happens. The
14523 entire queue has to be scanned and sorted before any deliveries can start.
14524
14525
14526 .option spool_directory main string&!! "set at compile time"
14527 .cindex "spool directory" "path to"
14528 This defines the directory in which Exim keeps its spool, that is, the messages
14529 it is waiting to deliver. The default value is taken from the compile-time
14530 configuration setting, if there is one. If not, this option must be set. The
14531 string is expanded, so it can contain, for example, a reference to
14532 &$primary_hostname$&.
14533
14534 If the spool directory name is fixed on your installation, it is recommended
14535 that you set it at build time rather than from this option, particularly if the
14536 log files are being written to the spool directory (see &%log_file_path%&).
14537 Otherwise log files cannot be used for errors that are detected early on, such
14538 as failures in the configuration file.
14539
14540 By using this option to override the compiled-in path, it is possible to run
14541 tests of Exim without using the standard spool.
14542
14543 .option sqlite_lock_timeout main time 5s
14544 .cindex "sqlite" "lock timeout"
14545 This option controls the timeout that the &(sqlite)& lookup uses when trying to
14546 access an SQLite database. See section &<<SECTsqlite>>& for more details.
14547
14548 .new
14549 .option strict_acl_vars main boolean false
14550 .cindex "ACL variables" "handling unset"
14551 This option controls what happens if a syntactically valid but undefined ACL
14552 variable is referenced. If it is false (the default), an empty string
14553 is substituted; if it is true, an error is generated. See section
14554 &<<SECTaclvariables>>& for details of ACL variables.
14555 .wen
14556
14557 .option strip_excess_angle_brackets main boolean false
14558 .cindex "angle brackets" "excess"
14559 If this option is set, redundant pairs of angle brackets round &"route-addr"&
14560 items in addresses are stripped. For example, &'<<xxx@a.b.c.d>>'& is
14561 treated as &'<xxx@a.b.c.d>'&. If this is in the envelope and the message is
14562 passed on to another MTA, the excess angle brackets are not passed on. If this
14563 option is not set, multiple pairs of angle brackets cause a syntax error.
14564
14565
14566 .option strip_trailing_dot main boolean false
14567 .cindex "trailing dot on domain"
14568 .cindex "dot" "trailing on domain"
14569 If this option is set, a trailing dot at the end of a domain in an address is
14570 ignored. If this is in the envelope and the message is passed on to another
14571 MTA, the dot is not passed on. If this option is not set, a dot at the end of a
14572 domain causes a syntax error.
14573 However, addresses in header lines are checked only when an ACL requests header
14574 syntax checking.
14575
14576
14577 .option syslog_duplication main boolean true
14578 .cindex "syslog" "duplicate log lines; suppressing"
14579 When Exim is logging to syslog, it writes the log lines for its three
14580 separate logs at different syslog priorities so that they can in principle
14581 be separated on the logging hosts. Some installations do not require this
14582 separation, and in those cases, the duplication of certain log lines is a
14583 nuisance. If &%syslog_duplication%& is set false, only one copy of any
14584 particular log line is written to syslog. For lines that normally go to
14585 both the main log and the reject log, the reject log version (possibly
14586 containing message header lines) is written, at LOG_NOTICE priority.
14587 Lines that normally go to both the main and the panic log are written at
14588 the LOG_ALERT priority.
14589
14590
14591 .option syslog_facility main string unset
14592 .cindex "syslog" "facility; setting"
14593 This option sets the syslog &"facility"& name, used when Exim is logging to
14594 syslog. The value must be one of the strings &"mail"&, &"user"&, &"news"&,
14595 &"uucp"&, &"daemon"&, or &"local&'x'&"& where &'x'& is a digit between 0 and 7.
14596 If this option is unset, &"mail"& is used. See chapter &<<CHAPlog>>& for
14597 details of Exim's logging.
14598
14599
14600
14601 .option syslog_processname main string &`exim`&
14602 .cindex "syslog" "process name; setting"
14603 This option sets the syslog &"ident"& name, used when Exim is logging to
14604 syslog. The value must be no longer than 32 characters. See chapter
14605 &<<CHAPlog>>& for details of Exim's logging.
14606
14607
14608
14609 .option syslog_timestamp main boolean true
14610 .cindex "syslog" "timestamps"
14611 If &%syslog_timestamp%& is set false, the timestamps on Exim's log lines are
14612 omitted when these lines are sent to syslog. See chapter &<<CHAPlog>>& for
14613 details of Exim's logging.
14614
14615
14616 .option system_filter main string&!! unset
14617 .cindex "filter" "system filter"
14618 .cindex "system filter" "specifying"
14619 .cindex "Sieve filter" "not available for system filter"
14620 This option specifies an Exim filter file that is applied to all messages at
14621 the start of each delivery attempt, before any routing is done. System filters
14622 must be Exim filters; they cannot be Sieve filters. If the system filter
14623 generates any deliveries to files or pipes, or any new mail messages, the
14624 appropriate &%system_filter_..._transport%& option(s) must be set, to define
14625 which transports are to be used. Details of this facility are given in chapter
14626 &<<CHAPsystemfilter>>&.
14627
14628
14629 .option system_filter_directory_transport main string&!! unset
14630 .cindex "&$address_file$&"
14631 This sets the name of the transport driver that is to be used when the
14632 &%save%& command in a system message filter specifies a path ending in &"/"&,
14633 implying delivery of each message into a separate file in some directory.
14634 During the delivery, the variable &$address_file$& contains the path name.
14635
14636
14637 .option system_filter_file_transport main string&!! unset
14638 .cindex "file" "transport for system filter"
14639 This sets the name of the transport driver that is to be used when the &%save%&
14640 command in a system message filter specifies a path not ending in &"/"&. During
14641 the delivery, the variable &$address_file$& contains the path name.
14642
14643 .option system_filter_group main string unset
14644 .cindex "gid (group id)" "system filter"
14645 This option is used only when &%system_filter_user%& is also set. It sets the
14646 gid under which the system filter is run, overriding any gid that is associated
14647 with the user. The value may be numerical or symbolic.
14648
14649 .option system_filter_pipe_transport main string&!! unset
14650 .cindex "&(pipe)& transport" "for system filter"
14651 .cindex "&$address_pipe$&"
14652 This specifies the transport driver that is to be used when a &%pipe%& command
14653 is used in a system filter. During the delivery, the variable &$address_pipe$&
14654 contains the pipe command.
14655
14656
14657 .option system_filter_reply_transport main string&!! unset
14658 .cindex "&(autoreply)& transport" "for system filter"
14659 This specifies the transport driver that is to be used when a &%mail%& command
14660 is used in a system filter.
14661
14662 .option system_filter_user main string unset
14663 .cindex "uid (user id)" "system filter"
14664 If this option is not set, the system filter is run in the main Exim delivery
14665 process, as root. When the option is set, the system filter runs in a separate
14666 process, as the given user. Unless the string consists entirely of digits, it
14667 is looked up in the password data. Failure to find the named user causes a
14668 configuration error. The gid is either taken from the password data, or
14669 specified by &%system_filter_group%&. When the uid is specified numerically,
14670 &%system_filter_group%& is required to be set.
14671
14672 If the system filter generates any pipe, file, or reply deliveries, the uid
14673 under which the filter is run is used when transporting them, unless a
14674 transport option overrides. Normally you should set &%system_filter_user%& if
14675 your system filter generates these kinds of delivery.
14676
14677
14678 .option tcp_nodelay main boolean true
14679 .cindex "daemon" "TCP_NODELAY on sockets"
14680 .cindex "Nagle algorithm"
14681 .cindex "TCP_NODELAY on listening sockets"
14682 If this option is set false, it stops the Exim daemon setting the
14683 TCP_NODELAY option on its listening sockets. Setting TCP_NODELAY
14684 turns off the &"Nagle algorithm"&, which is a way of improving network
14685 performance in interactive (character-by-character) situations. Turning it off
14686 should improve Exim's performance a bit, so that is what happens by default.
14687 However, it appears that some broken clients cannot cope, and time out. Hence
14688 this option. It affects only those sockets that are set up for listening by the
14689 daemon. Sockets created by the smtp transport for delivering mail always set
14690 TCP_NODELAY.
14691
14692
14693 .option timeout_frozen_after main time 0s
14694 .cindex "frozen messages" "timing out"
14695 .cindex "timeout" "frozen messages"
14696 If &%timeout_frozen_after%& is set to a time greater than zero, a frozen
14697 message of any kind that has been on the queue for longer than the given time
14698 is automatically cancelled at the next queue run. If the frozen message is a
14699 bounce message, it is just discarded; otherwise, a bounce is sent to the
14700 sender, in a similar manner to cancellation by the &%-Mg%& command line option.
14701 If you want to timeout frozen bounce messages earlier than other kinds of
14702 frozen message, see &%ignore_bounce_errors_after%&.
14703
14704 .new
14705 &*Note:*& the default value of zero means no timeouts; with this setting,
14706 frozen messages remain on the queue forever (except for any frozen bounce
14707 messages that are released by &%ignore_bounce_errors_after%&).
14708 .wen
14709
14710
14711 .option timezone main string unset
14712 .cindex "timezone" "setting"
14713 The value of &%timezone%& is used to set the environment variable TZ while
14714 running Exim (if it is different on entry). This ensures that all timestamps
14715 created by Exim are in the required timezone. If you want all your timestamps
14716 to be in UTC (aka GMT) you should set
14717 .code
14718 timezone = UTC
14719 .endd
14720 The default value is taken from TIMEZONE_DEFAULT in &_Local/Makefile_&,
14721 or, if that is not set, from the value of the TZ environment variable when Exim
14722 is built. If &%timezone%& is set to the empty string, either at build or run
14723 time, any existing TZ variable is removed from the environment when Exim
14724 runs. This is appropriate behaviour for obtaining wall-clock time on some, but
14725 unfortunately not all, operating systems.
14726
14727
14728 .option tls_advertise_hosts main "host list&!!" unset
14729 .cindex "TLS" "advertising"
14730 .cindex "encryption" "on SMTP connection"
14731 .cindex "SMTP" "encrypted connection"
14732 When Exim is built with support for TLS encrypted connections, the availability
14733 of the STARTTLS command to set up an encrypted session is advertised in
14734 response to EHLO only to those client hosts that match this option. See
14735 chapter &<<CHAPTLS>>& for details of Exim's support for TLS.
14736
14737
14738 .option tls_certificate main string&!! unset
14739 .cindex "TLS" "server certificate; location of"
14740 .cindex "certificate for server" "location of"
14741 The value of this option is expanded, and must then be the absolute path to a
14742 file which contains the server's certificates. The server's private key is also
14743 assumed to be in this file if &%tls_privatekey%& is unset. See chapter
14744 &<<CHAPTLS>>& for further details.
14745
14746 &*Note*&: The certificates defined by this option are used only when Exim is
14747 receiving incoming messages as a server. If you want to supply certificates for
14748 use when sending messages as a client, you must set the &%tls_certificate%&
14749 option in the relevant &(smtp)& transport.
14750
14751
14752 .option tls_crl main string&!! unset
14753 .cindex "TLS" "server certificate revocation list"
14754 .cindex "certificate" "revocation list for server"
14755 This option specifies a certificate revocation list. The expanded value must
14756 be the name of a file that contains a CRL in PEM format.
14757
14758
14759 .option tls_dhparam main string&!! unset
14760 .cindex "TLS" "D-H parameters for server"
14761 The value of this option is expanded, and must then be the absolute path to
14762 a file which contains the server's DH parameter values.
14763 This is used only for OpenSSL. When Exim is linked with GnuTLS, this option is
14764 ignored. See section &<<SECTopenvsgnu>>& for further details.
14765
14766
14767 .option tls_on_connect_ports main "string list" unset
14768 This option specifies a list of incoming SSMTP (aka SMTPS) ports that should
14769 operate the obsolete SSMTP (SMTPS) protocol, where a TLS session is immediately
14770 set up without waiting for the client to issue a STARTTLS command. For
14771 further details, see section &<<SECTsupobssmt>>&.
14772
14773
14774
14775 .option tls_privatekey main string&!! unset
14776 .cindex "TLS" "server private key; location of"
14777 The value of this option is expanded, and must then be the absolute path to a
14778 file which contains the server's private key. If this option is unset, or if
14779 the expansion is forced to fail, or the result is an empty string, the private
14780 key is assumed to be in the same file as the server's certificates. See chapter
14781 &<<CHAPTLS>>& for further details.
14782
14783
14784 .option tls_remember_esmtp main boolean false
14785 .cindex "TLS" "esmtp state; remembering"
14786 .cindex "TLS" "broken clients"
14787 If this option is set true, Exim violates the RFCs by remembering that it is in
14788 &"esmtp"& state after successfully negotiating a TLS session. This provides
14789 support for broken clients that fail to send a new EHLO after starting a
14790 TLS session.
14791
14792
14793 .option tls_require_ciphers main string&!! unset
14794 .cindex "TLS" "requiring specific ciphers"
14795 .cindex "cipher" "requiring specific"
14796 This option controls which ciphers can be used for incoming TLS connections.
14797 The &(smtp)& transport has an option of the same name for controlling outgoing
14798 connections. This option is expanded for each connection, so can be varied for
14799 different clients if required. The value of this option must be a list of
14800 permitted cipher suites. The OpenSSL and GnuTLS libraries handle cipher control
14801 in somewhat different ways. If GnuTLS is being used, the client controls the
14802 preference order of the available ciphers. Details are given in sections
14803 &<<SECTreqciphssl>>& and &<<SECTreqciphgnu>>&.
14804
14805
14806 .option tls_try_verify_hosts main "host list&!!" unset
14807 .cindex "TLS" "client certificate verification"
14808 .cindex "certificate" "verification of client"
14809 See &%tls_verify_hosts%& below.
14810
14811
14812 .option tls_verify_certificates main string&!! unset
14813 .cindex "TLS" "client certificate verification"
14814 .cindex "certificate" "verification of client"
14815 The value of this option is expanded, and must then be the absolute path to
14816 a file containing permitted certificates for clients that
14817 match &%tls_verify_hosts%& or &%tls_try_verify_hosts%&. Alternatively, if you
14818 are using OpenSSL, you can set &%tls_verify_certificates%& to the name of a
14819 directory containing certificate files. This does not work with GnuTLS; the
14820 option must be set to the name of a single file if you are using GnuTLS.
14821
14822
14823 .option tls_verify_hosts main "host list&!!" unset
14824 .cindex "TLS" "client certificate verification"
14825 .cindex "certificate" "verification of client"
14826 This option, along with &%tls_try_verify_hosts%&, controls the checking of
14827 certificates from clients.
14828 The expected certificates are defined by &%tls_verify_certificates%&, which
14829 must be set. A configuration error occurs if either &%tls_verify_hosts%& or
14830 &%tls_try_verify_hosts%& is set and &%tls_verify_certificates%& is not set.
14831
14832 Any client that matches &%tls_verify_hosts%& is constrained by
14833 &%tls_verify_certificates%&. The client must present one of the listed
14834 certificates. If it does not, the connection is aborted.
14835
14836 A weaker form of checking is provided by &%tls_try_verify_hosts%&. If a client
14837 matches this option (but not &%tls_verify_hosts%&), Exim requests a
14838 certificate and checks it against &%tls_verify_certificates%&, but does not
14839 abort the connection if there is no certificate or if it does not match. This
14840 state can be detected in an ACL, which makes it possible to implement policies
14841 such as &"accept for relay only if a verified certificate has been received,
14842 but accept for local delivery if encrypted, even without a verified
14843 certificate"&.
14844
14845 Client hosts that match neither of these lists are not asked to present
14846 certificates.
14847
14848
14849 .option trusted_groups main "string list&!!" unset
14850 .cindex "trusted group"
14851 .cindex "group" "trusted"
14852 This option is expanded just once, at the start of Exim's processing. If this
14853 option is set, any process that is running in one of the listed groups, or
14854 which has one of them as a supplementary group, is trusted. The groups can be
14855 specified numerically or by name. See section &<<SECTtrustedadmin>>& for
14856 details of what trusted callers are permitted to do. If neither
14857 &%trusted_groups%& nor &%trusted_users%& is set, only root and the Exim user
14858 are trusted.
14859
14860 .option trusted_users main "string list&!!" unset
14861 .cindex "trusted user"
14862 .cindex "user" "trusted"
14863 This option is expanded just once, at the start of Exim's processing. If this
14864 option is set, any process that is running as one of the listed users is
14865 trusted. The users can be specified numerically or by name. See section
14866 &<<SECTtrustedadmin>>& for details of what trusted callers are permitted to do.
14867 If neither &%trusted_groups%& nor &%trusted_users%& is set, only root and the
14868 Exim user are trusted.
14869
14870 .option unknown_login main string&!! unset
14871 .cindex "uid (user id)" "unknown caller"
14872 .cindex "&$caller_uid$&"
14873 This is a specialized feature for use in unusual configurations. By default, if
14874 the uid of the caller of Exim cannot be looked up using &[getpwuid()]&, Exim
14875 gives up. The &%unknown_login%& option can be used to set a login name to be
14876 used in this circumstance. It is expanded, so values like &%user$caller_uid%&
14877 can be set. When &%unknown_login%& is used, the value of &%unknown_username%&
14878 is used for the user's real name (gecos field), unless this has been set by the
14879 &%-F%& option.
14880
14881 .option unknown_username main string unset
14882 See &%unknown_login%&.
14883
14884 .option untrusted_set_sender main "address list&!!" unset
14885 .cindex "trusted user"
14886 .cindex "sender" "setting by untrusted user"
14887 .cindex "untrusted user" "setting sender"
14888 .cindex "user" "untrusted setting sender"
14889 .cindex "envelope sender"
14890 When an untrusted user submits a message to Exim using the standard input, Exim
14891 normally creates an envelope sender address from the user's login and the
14892 default qualification domain. Data from the &%-f%& option (for setting envelope
14893 senders on non-SMTP messages) or the SMTP MAIL command (if &%-bs%& or &%-bS%&
14894 is used) is ignored.
14895
14896 However, untrusted users are permitted to set an empty envelope sender address,
14897 to declare that a message should never generate any bounces. For example:
14898 .code
14899 exim -f '<>' user@domain.example
14900 .endd
14901 .cindex "&$sender_ident$&"
14902 The &%untrusted_set_sender%& option allows you to permit untrusted users to set
14903 other envelope sender addresses in a controlled way. When it is set, untrusted
14904 users are allowed to set envelope sender addresses that match any of the
14905 patterns in the list. Like all address lists, the string is expanded. The
14906 identity of the user is in &$sender_ident$&, so you can, for example, restrict
14907 users to setting senders that start with their login ids
14908 followed by a hyphen
14909 by a setting like this:
14910 .code
14911 untrusted_set_sender = ^$sender_ident-
14912 .endd
14913 If you want to allow untrusted users to set envelope sender addresses without
14914 restriction, you can use
14915 .code
14916 untrusted_set_sender = *
14917 .endd
14918 The &%untrusted_set_sender%& option applies to all forms of local input, but
14919 only to the setting of the envelope sender. It does not permit untrusted users
14920 to use the other options which trusted user can use to override message
14921 parameters. Furthermore, it does not stop Exim from removing an existing
14922 &'Sender:'& header in the message, or from adding a &'Sender:'& header if
14923 necessary. See &%local_sender_retain%& and &%local_from_check%& for ways of
14924 overriding these actions. The handling of the &'Sender:'& header is also
14925 described in section &<<SECTthesenhea>>&.
14926
14927 The log line for a message's arrival shows the envelope sender following
14928 &"<="&. For local messages, the user's login always follows, after &"U="&. In
14929 &%-bp%& displays, and in the Exim monitor, if an untrusted user sets an
14930 envelope sender address, the user's login is shown in parentheses after the
14931 sender address.
14932
14933
14934 .option uucp_from_pattern main string "see below"
14935 .cindex "&""From""& line"
14936 .cindex "UUCP" "&""From""& line"
14937 Some applications that pass messages to an MTA via a command line interface use
14938 an initial line starting with &"From&~"& to pass the envelope sender. In
14939 particular, this is used by UUCP software. Exim recognizes such a line by means
14940 of a regular expression that is set in &%uucp_from_pattern%&. When the pattern
14941 matches, the sender address is constructed by expanding the contents of
14942 &%uucp_from_sender%&, provided that the caller of Exim is a trusted user. The
14943 default pattern recognizes lines in the following two forms:
14944 .code
14945 From ph10 Fri Jan  5 12:35 GMT 1996
14946 From ph10 Fri, 7 Jan 97 14:00:00 GMT
14947 .endd
14948 The pattern can be seen by running
14949 .code
14950 exim -bP uucp_from_pattern
14951 .endd
14952 It checks only up to the hours and minutes, and allows for a 2-digit or 4-digit
14953 year in the second case. The first word after &"From&~"& is matched in the
14954 regular expression by a parenthesized subpattern. The default value for
14955 &%uucp_from_sender%& is &"$1"&, which therefore just uses this first word
14956 (&"ph10"& in the example above) as the message's sender. See also
14957 &%ignore_fromline_hosts%&.
14958
14959
14960 .option uucp_from_sender main string&!! &`$1`&
14961 See &%uucp_from_pattern%& above.
14962
14963
14964 .option warn_message_file main string unset
14965 .cindex "warning of delay" "customizing the message"
14966 .cindex "customizing" "warning message"
14967 This option defines a template file containing paragraphs of text to be used
14968 for constructing the warning message which is sent by Exim when a message has
14969 been on the queue for a specified amount of time, as specified by
14970 &%delay_warning%&. Details of the file's contents are given in chapter
14971 &<<CHAPemsgcust>>&. See also &%bounce_message_file%&.
14972
14973
14974 .option write_rejectlog main boolean true
14975 .cindex "reject log" "disabling"
14976 If this option is set false, Exim no longer writes anything to the reject log.
14977 See chapter &<<CHAPlog>>& for details of what Exim writes to its logs.
14978 .ecindex IIDconfima
14979 .ecindex IIDmaiconf
14980
14981
14982
14983
14984 . ////////////////////////////////////////////////////////////////////////////
14985 . ////////////////////////////////////////////////////////////////////////////
14986
14987 .chapter "Generic options for routers" "CHAProutergeneric"
14988 .scindex IIDgenoprou1 "options" "generic; for routers"
14989 .scindex IIDgenoprou2 "generic options" "router"
14990 This chapter describes the generic options that apply to all routers.
14991 Those that are preconditions are marked with &Dagger; in the &"use"& field.
14992
14993 For a general description of how a router operates, see sections
14994 &<<SECTrunindrou>>& and &<<SECTrouprecon>>&. The latter specifies the order in
14995 which the preconditions are tested. The order of expansion of the options that
14996 provide data for a transport is: &%errors_to%&, &%headers_add%&,
14997 &%headers_remove%&, &%transport%&.
14998
14999
15000
15001 .option address_data routers string&!! unset
15002 .cindex "router" "data attached to address"
15003 The string is expanded just before the router is run, that is, after all the
15004 precondition tests have succeeded. If the expansion is forced to fail, the
15005 router declines, the value of &%address_data%& remains unchanged, and the
15006 &%more%& option controls what happens next. Other expansion failures cause
15007 delivery of the address to be deferred.
15008
15009 .cindex "&$address_data$&"
15010 When the expansion succeeds, the value is retained with the address, and can be
15011 accessed using the variable &$address_data$& in the current router, subsequent
15012 routers, and the eventual transport.
15013
15014 &*Warning*&: If the current or any subsequent router is a &(redirect)& router
15015 that runs a user's filter file, the contents of &$address_data$& are accessible
15016 in the filter. This is not normally a problem, because such data is usually
15017 either not confidential or it &"belongs"& to the current user, but if you do
15018 put confidential data into &$address_data$& you need to remember this point.
15019
15020 Even if the router declines or passes, the value of &$address_data$& remains
15021 with the address, though it can be changed by another &%address_data%& setting
15022 on a subsequent router. If a router generates child addresses, the value of
15023 &$address_data$& propagates to them. This also applies to the special kind of
15024 &"child"& that is generated by a router with the &%unseen%& option.
15025
15026 The idea of &%address_data%& is that you can use it to look up a lot of data
15027 for the address once, and then pick out parts of the data later. For example,
15028 you could use a single LDAP lookup to return a string of the form
15029 .code
15030 uid=1234 gid=5678 mailbox=/mail/xyz forward=/home/xyz/.forward
15031 .endd
15032 In the transport you could pick out the mailbox by a setting such as
15033 .code
15034 file = ${extract{mailbox}{$address_data}}
15035 .endd
15036 This makes the configuration file less messy, and also reduces the number of
15037 lookups (though Exim does cache lookups).
15038
15039 The &%address_data%& facility is also useful as a means of passing information
15040 from one router to another, and from a router to a transport. In addition, if
15041
15042 .cindex "&$sender_address_data$&"
15043 .cindex "&$address_data$&"
15044 When &$address_data$& is set by a router when verifying a recipient address
15045 from an ACL, it remains available for use in the rest of the ACL statement.
15046 After verifying a sender, the value is transferred to &$sender_address_data$&.
15047
15048
15049
15050
15051 .option address_test routers&!? boolean true
15052 .cindex "&%-bt%& option"
15053 .cindex "router" "skipping when address testing"
15054 If this option is set false, the router is skipped when routing is being tested
15055 by means of the &%-bt%& command line option. This can be a convenience when
15056 your first router sends messages to an external scanner, because it saves you
15057 having to set the &"already scanned"& indicator when testing real address
15058 routing.
15059
15060
15061
15062 .option cannot_route_message routers string&!! unset
15063 .cindex "router" "customizing &""cannot route""& message"
15064 .cindex "customizing" "&""cannot route""& message"
15065 This option specifies a text message that is used when an address cannot be
15066 routed because Exim has run out of routers. The default message is
15067 &"Unrouteable address"&. This option is useful only on routers that have
15068 &%more%& set false, or on the very last router in a configuration, because the
15069 value that is used is taken from the last router that is considered. This
15070 includes a router that is skipped because its preconditions are not met, as
15071 well as a router that declines. For example, using the default configuration,
15072 you could put:
15073 .code
15074 cannot_route_message = Remote domain not found in DNS
15075 .endd
15076 on the first router, which is a &(dnslookup)& router with &%more%& set false,
15077 and
15078 .code
15079 cannot_route_message = Unknown local user
15080 .endd
15081 on the final router that checks for local users. If string expansion fails for
15082 this option, the default message is used. Unless the expansion failure was
15083 explicitly forced, a message about the failure is written to the main and panic
15084 logs, in addition to the normal message about the routing failure.
15085
15086
15087 .option caseful_local_part routers boolean false
15088 .cindex "case of local parts"
15089 .cindex "router" "case of local parts"
15090 By default, routers handle the local parts of addresses in a case-insensitive
15091 manner, though the actual case is preserved for transmission with the message.
15092 If you want the case of letters to be significant in a router, you must set
15093 this option true. For individual router options that contain address or local
15094 part lists (for example, &%local_parts%&), case-sensitive matching can be
15095 turned on by &"+caseful"& as a list item. See section &<<SECTcasletadd>>& for
15096 more details.
15097
15098 .cindex "&$local_part$&"
15099 .cindex "&$original_local_part$&"
15100 .cindex "&$parent_local_part$&"
15101 The value of the &$local_part$& variable is forced to lower case while a
15102 router is running unless &%caseful_local_part%& is set. When a router assigns
15103 an address to a transport, the value of &$local_part$& when the transport runs
15104 is the same as it was in the router. Similarly, when a router generates child
15105 addresses by aliasing or forwarding, the values of &$original_local_part$&
15106 and &$parent_local_part$& are those that were used by the redirecting router.
15107
15108 This option applies to the processing of an address by a router. When a
15109 recipient address is being processed in an ACL, there is a separate &%control%&
15110 modifier that can be used to specify case-sensitive processing within the ACL
15111 (see section &<<SECTcontrols>>&).
15112
15113
15114
15115 .option check_local_user routers&!? boolean false
15116 .cindex "local user" "checking in router"
15117 .cindex "router" "checking for local user"
15118 .cindex "&_/etc/passwd_&"
15119 .cindex "&$home$&"
15120 When this option is true, Exim checks that the local part of the recipient
15121 address (with affixes removed if relevant) is the name of an account on the
15122 local system. The check is done by calling the &[getpwnam()]& function rather
15123 than trying to read &_/etc/passwd_& directly. This means that other methods of
15124 holding password data (such as NIS) are supported. If the local part is a local
15125 user, &$home$& is set from the password data, and can be tested in other
15126 preconditions that are evaluated after this one (the order of evaluation is
15127 given in section &<<SECTrouprecon>>&). However, the value of &$home$& can be
15128 overridden by &%router_home_directory%&. If the local part is not a local user,
15129 the router is skipped.
15130
15131 If you want to check that the local part is either the name of a local user
15132 or matches something else, you cannot combine &%check_local_user%& with a
15133 setting of &%local_parts%&, because that specifies the logical &'and'& of the
15134 two conditions. However, you can use a &(passwd)& lookup in a &%local_parts%&
15135 setting to achieve this. For example:
15136 .code
15137 local_parts = passwd;$local_part : lsearch;/etc/other/users
15138 .endd
15139 Note, however, that the side effects of &%check_local_user%& (such as setting
15140 up a home directory) do not occur when a &(passwd)& lookup is used in a
15141 &%local_parts%& (or any other) precondition.
15142
15143
15144
15145 .option condition routers&!? string&!! unset
15146 .cindex "router" "customized precondition"
15147 This option specifies a general precondition test that has to succeed for the
15148 router to be called. The &%condition%& option is the last precondition to be
15149 evaluated (see section &<<SECTrouprecon>>&). The string is expanded, and if the
15150 result is a forced failure, or an empty string, or one of the strings &"0"& or
15151 &"no"& or &"false"& (checked without regard to the case of the letters), the
15152 router is skipped, and the address is offered to the next one.
15153
15154 If the result is any other value, the router is run (as this is the last
15155 precondition to be evaluated, all the other preconditions must be true).
15156
15157 The &%condition%& option provides a means of applying custom conditions to the
15158 running of routers. Note that in the case of a simple conditional expansion,
15159 the default expansion values are exactly what is wanted. For example:
15160 .code
15161 condition = ${if >{$message_age}{600}}
15162 .endd
15163 Because of the default behaviour of the string expansion, this is equivalent to
15164 .code
15165 condition = ${if >{$message_age}{600}{true}{}}
15166 .endd
15167 If the expansion fails (other than forced failure) delivery is deferred. Some
15168 of the other precondition options are common special cases that could in fact
15169 be specified using &%condition%&.
15170
15171
15172
15173 .option debug_print routers string&!! unset
15174 .cindex "testing" "variables in drivers"
15175 If this option is set and debugging is enabled (see the &%-d%& command line
15176 option), the string is expanded and included in the debugging output.
15177 If expansion of the string fails, the error message is written to the debugging
15178 output, and Exim carries on processing.
15179 This option is provided to help with checking out the values of variables and
15180 so on when debugging router configurations. For example, if a &%condition%&
15181 option appears not to be working, &%debug_print%& can be used to output the
15182 variables it references. The output happens after checks for &%domains%&,
15183 &%local_parts%&, and &%check_local_user%& but before any other preconditions
15184 are tested. A newline is added to the text if it does not end with one.
15185
15186
15187
15188 .option disable_logging routers boolean false
15189 If this option is set true, nothing is logged for any routing errors
15190 or for any deliveries caused by this router. You should not set this option
15191 unless you really, really know what you are doing. See also the generic
15192 transport option of the same name.
15193
15194
15195 .option domains routers&!? "domain list&!!" unset
15196 .cindex "router" "restricting to specific domains"
15197 .cindex "&$domain_data$&"
15198 If this option is set, the router is skipped unless the current domain matches
15199 the list. If the match is achieved by means of a file lookup, the data that the
15200 lookup returned for the domain is placed in &$domain_data$& for use in string
15201 expansions of the driver's private options. See section &<<SECTrouprecon>>& for
15202 a list of the order in which preconditions are evaluated.
15203
15204
15205
15206 .option driver routers string unset
15207 This option must always be set. It specifies which of the available routers is
15208 to be used.
15209
15210
15211
15212 .option errors_to routers string&!! unset
15213 .cindex "envelope sender"
15214 .cindex "router" "changing address for errors"
15215 If a router successfully handles an address, it may assign the address to a
15216 transport for delivery or it may generate child addresses. In both cases, if
15217 there is a delivery problem during later processing, the resulting bounce
15218 message is sent to the address that results from expanding this string,
15219 provided that the address verifies successfully. The &%errors_to%& option is
15220 expanded before &%headers_add%&, &%headers_remove%&, and &%transport%&.
15221
15222 The &%errors_to%& setting associated with an address can be overridden if it
15223 subsequently passes through other routers that have their own &%errors_to%&
15224 settings, or if the message is delivered by a transport with a &%return_path%&
15225 setting.
15226
15227 If &%errors_to%& is unset, or the expansion is forced to fail, or the result of
15228 the expansion fails to verify, the errors address associated with the incoming
15229 address is used. At top level, this is the envelope sender. A non-forced
15230 expansion failure causes delivery to be deferred.
15231
15232 If an address for which &%errors_to%& has been set ends up being delivered over
15233 SMTP, the envelope sender for that delivery is the &%errors_to%& value, so that
15234 any bounces that are generated by other MTAs on the delivery route are also
15235 sent there. You can set &%errors_to%& to the empty string by either of these
15236 settings:
15237 .code
15238 errors_to =
15239 errors_to = ""
15240 .endd
15241 An expansion item that yields an empty string has the same effect. If you do
15242 this, a locally detected delivery error for addresses processed by this router
15243 no longer gives rise to a bounce message; the error is discarded. If the
15244 address is delivered to a remote host, the return path is set to &`<>`&, unless
15245 overridden by the &%return_path%& option on the transport.
15246
15247 .cindex "&$address_data$&"
15248 If for some reason you want to discard local errors, but use a non-empty
15249 MAIL command for remote delivery, you can preserve the original return
15250 path in &$address_data$& in the router, and reinstate it in the transport by
15251 setting &%return_path%&.
15252
15253 The most common use of &%errors_to%& is to direct mailing list bounces to the
15254 manager of the list, as described in section &<<SECTmailinglists>>&, or to
15255 implement VERP (Variable Envelope Return Paths) (see section &<<SECTverp>>&).
15256
15257
15258
15259 .option expn routers&!? boolean true
15260 .cindex "address" "testing"
15261 .cindex "testing" "addresses"
15262 .cindex "EXPN" "router skipping"
15263 .cindex "router" "skipping for EXPN"
15264 If this option is turned off, the router is skipped when testing an address
15265 as a result of processing an SMTP EXPN command. You might, for example,
15266 want to turn it off on a router for users' &_.forward_& files, while leaving it
15267 on for the system alias file.
15268 See section &<<SECTrouprecon>>& for a list of the order in which preconditions
15269 are evaluated.
15270
15271 The use of the SMTP EXPN command is controlled by an ACL (see chapter
15272 &<<CHAPACL>>&). When Exim is running an EXPN command, it is similar to testing
15273 an address with &%-bt%&. Compare VRFY, whose counterpart is &%-bv%&.
15274
15275
15276
15277 .option fail_verify routers boolean false
15278 .cindex "router" "forcing verification failure"
15279 Setting this option has the effect of setting both &%fail_verify_sender%& and
15280 &%fail_verify_recipient%& to the same value.
15281
15282
15283
15284 .option fail_verify_recipient routers boolean false
15285 If this option is true and an address is accepted by this router when
15286 verifying a recipient, verification fails.
15287
15288
15289
15290 .option fail_verify_sender routers boolean false
15291 If this option is true and an address is accepted by this router when
15292 verifying a sender, verification fails.
15293
15294
15295
15296 .option fallback_hosts routers "string list" unset
15297 .cindex "router" "fallback hosts"
15298 .cindex "fallback" "hosts specified on router"
15299 String expansion is not applied to this option. The argument must be a
15300 colon-separated list of host names or IP addresses. The list separator can be
15301 changed (see section &<<SECTlistconstruct>>&), and a port can be specified with
15302 each name or address. In fact, the format of each item is exactly the same as
15303 defined for the list of hosts in a &(manualroute)& router (see section
15304 &<<SECTformatonehostitem>>&).
15305
15306 If a router queues an address for a remote transport, this host list is
15307 associated with the address, and used instead of the transport's fallback host
15308 list. If &%hosts_randomize%& is set on the transport, the order of the list is
15309 randomized for each use. See the &%fallback_hosts%& option of the &(smtp)&
15310 transport for further details.
15311
15312
15313 .option group routers string&!! "see below"
15314 .cindex "gid (group id)" "local delivery"
15315 .cindex "local transports" "uid and gid"
15316 .cindex "transport" "local"
15317 .cindex "router" "setting group"
15318 When a router queues an address for a transport, and the transport does not
15319 specify a group, the group given here is used when running the delivery
15320 process.
15321 The group may be specified numerically or by name. If expansion fails, the
15322 error is logged and delivery is deferred.
15323 The default is unset, unless &%check_local_user%& is set, when the default
15324 is taken from the password information. See also &%initgroups%& and &%user%&
15325 and the discussion in chapter &<<CHAPenvironment>>&.
15326
15327
15328
15329 .option headers_add routers string&!! unset
15330 .cindex "header lines" "adding"
15331 .cindex "router" "adding header lines"
15332 This option specifies a string of text that is expanded at routing time, and
15333 associated with any addresses that are accepted by the router. However, this
15334 option has no effect when an address is just being verified. The way in which
15335 the text is used to add header lines at transport time is described in section
15336 &<<SECTheadersaddrem>>&. New header lines are not actually added until the
15337 message is in the process of being transported. This means that references to
15338 header lines in string expansions in the transport's configuration do not
15339 &"see"& the added header lines.
15340
15341 The &%headers_add%& option is expanded after &%errors_to%&, but before
15342 &%headers_remove%& and &%transport%&. If the expanded string is empty, or if
15343 the expansion is forced to fail, the option has no effect. Other expansion
15344 failures are treated as configuration errors.
15345
15346 &*Warning 1*&: The &%headers_add%& option cannot be used for a &(redirect)&
15347 router that has the &%one_time%& option set.
15348
15349 &*Warning 2*&: If the &%unseen%& option is set on the router, all header
15350 additions are deleted when the address is passed on to subsequent routers.
15351
15352
15353
15354 .option headers_remove routers string&!! unset
15355 .cindex "header lines" "removing"
15356 .cindex "router" "removing header lines"
15357 This option specifies a string of text that is expanded at routing time, and
15358 associated with any addresses that are accepted by the router. However, this
15359 option has no effect when an address is just being verified. The way in which
15360 the text is used to remove header lines at transport time is described in
15361 section &<<SECTheadersaddrem>>&. Header lines are not actually removed until
15362 the message is in the process of being transported. This means that references
15363 to header lines in string expansions in the transport's configuration still
15364 &"see"& the original header lines.
15365
15366 The &%headers_remove%& option is expanded after &%errors_to%& and
15367 &%headers_add%&, but before &%transport%&. If the expansion is forced to fail,
15368 the option has no effect. Other expansion failures are treated as configuration
15369 errors.
15370
15371 &*Warning 1*&: The &%headers_remove%& option cannot be used for a &(redirect)&
15372 router that has the &%one_time%& option set.
15373
15374 &*Warning 2*&: If the &%unseen%& option is set on the router, all header
15375 removal requests are deleted when the address is passed on to subsequent
15376 routers.
15377
15378
15379 .option ignore_target_hosts routers "host list&!!" unset
15380 .cindex "IP address" "discarding"
15381 .cindex "router" "discarding IP addresses"
15382 Although this option is a host list, it should normally contain IP address
15383 entries rather than names. If any host that is looked up by the router has an
15384 IP address that matches an item in this list, Exim behaves as if that IP
15385 address did not exist. This option allows you to cope with rogue DNS entries
15386 like
15387 .code
15388 remote.domain.example.  A  127.0.0.1
15389 .endd
15390 by setting
15391 .code
15392 ignore_target_hosts = 127.0.0.1
15393 .endd
15394 on the relevant router. If all the hosts found by a &(dnslookup)& router are
15395 discarded in this way, the router declines. In a conventional configuration, an
15396 attempt to mail to such a domain would normally provoke the &"unrouteable
15397 domain"& error, and an attempt to verify an address in the domain would fail.
15398 Similarly, if &%ignore_target_hosts%& is set on an &(ipliteral)& router, the
15399 router declines if presented with one of the listed addresses.
15400
15401 You can use this option to disable the use of IPv4 or IPv6 for mail delivery by
15402 means of the first or the second of the following settings, respectively:
15403 .code
15404 ignore_target_hosts = 0.0.0.0/0
15405 ignore_target_hosts = <; 0::0/0
15406 .endd
15407 The pattern in the first line matches all IPv4 addresses, whereas the pattern
15408 in the second line matches all IPv6 addresses.
15409
15410 This option may also be useful for ignoring link-local and site-local IPv6
15411 addresses. Because, like all host lists, the value of &%ignore_target_hosts%&
15412 is expanded before use as a list, it is possible to make it dependent on the
15413 domain that is being routed.
15414
15415 .cindex "&$host_address$&"
15416 During its expansion, &$host_address$& is set to the IP address that is being
15417 checked.
15418
15419 .option initgroups routers boolean false
15420 .cindex "additional groups"
15421 .cindex "groups" "additional"
15422 .cindex "local transports" "uid and gid"
15423 .cindex "transport" "local"
15424 If the router queues an address for a transport, and this option is true, and
15425 the uid supplied by the router is not overridden by the transport, the
15426 &[initgroups()]& function is called when running the transport to ensure that
15427 any additional groups associated with the uid are set up. See also &%group%&
15428 and &%user%& and the discussion in chapter &<<CHAPenvironment>>&.
15429
15430
15431
15432 .option local_part_prefix routers&!? "string list" unset
15433 .cindex "router" "prefix for local part"
15434 .cindex "prefix" "for local part; used in router"
15435 If this option is set, the router is skipped unless the local part starts with
15436 one of the given strings, or &%local_part_prefix_optional%& is true. See
15437 section &<<SECTrouprecon>>& for a list of the order in which preconditions are
15438 evaluated.
15439
15440 The list is scanned from left to right, and the first prefix that matches is
15441 used. A limited form of wildcard is available; if the prefix begins with an
15442 asterisk, it matches the longest possible sequence of arbitrary characters at
15443 the start of the local part. An asterisk should therefore always be followed by
15444 some character that does not occur in normal local parts.
15445 .cindex "multiple mailboxes"
15446 .cindex "mailbox" "multiple"
15447 Wildcarding can be used to set up multiple user mailboxes, as described in
15448 section &<<SECTmulbox>>&.
15449
15450 .cindex "&$local_part$&"
15451 .cindex "&$local_part_prefix$&"
15452 During the testing of the &%local_parts%& option, and while the router is
15453 running, the prefix is removed from the local part, and is available in the
15454 expansion variable &$local_part_prefix$&. When a message is being delivered, if
15455 the router accepts the address, this remains true during subsequent delivery by
15456 a transport. In particular, the local part that is transmitted in the RCPT
15457 command for LMTP, SMTP, and BSMTP deliveries has the prefix removed by default.
15458 This behaviour can be overridden by setting &%rcpt_include_affixes%& true on
15459 the relevant transport.
15460
15461 When an address is being verified, &%local_part_prefix%& affects only the
15462 behaviour of the router. If the callout feature of verification is in use, this
15463 means that the full address, including the prefix, will be used during the
15464 callout.
15465
15466 The prefix facility is commonly used to handle local parts of the form
15467 &%owner-something%&. Another common use is to support local parts of the form
15468 &%real-username%& to bypass a user's &_.forward_& file &-- helpful when trying
15469 to tell a user their forwarding is broken &-- by placing a router like this one
15470 immediately before the router that handles &_.forward_& files:
15471 .code
15472 real_localuser:
15473   driver = accept
15474   local_part_prefix = real-
15475   check_local_user
15476   transport = local_delivery
15477 .endd
15478 If both &%local_part_prefix%& and &%local_part_suffix%& are set for a router,
15479 both conditions must be met if not optional. Care must be taken if wildcards
15480 are used in both a prefix and a suffix on the same router. Different
15481 separator characters must be used to avoid ambiguity.
15482
15483
15484 .option local_part_prefix_optional routers boolean false
15485 See &%local_part_prefix%& above.
15486
15487
15488
15489 .option local_part_suffix routers&!? "string list" unset
15490 .cindex "router" "suffix for local part"
15491 .cindex "suffix for local part" "used in router"
15492 This option operates in the same way as &%local_part_prefix%&, except that the
15493 local part must end (rather than start) with the given string, the
15494 &%local_part_suffix_optional%& option determines whether the suffix is
15495 mandatory, and the wildcard * character, if present, must be the last
15496 character of the suffix. This option facility is commonly used to handle local
15497 parts of the form &%something-request%& and multiple user mailboxes of the form
15498 &%username-foo%&.
15499
15500
15501 .option local_part_suffix_optional routers boolean false
15502 See &%local_part_suffix%& above.
15503
15504
15505
15506 .option local_parts routers&!? "local part list&!!" unset
15507 .cindex "router" "restricting to specific local parts"
15508 .cindex "local part" "checking in router"
15509 The router is run only if the local part of the address matches the list.
15510 See section &<<SECTrouprecon>>& for a list of the order in which preconditions
15511 are evaluated, and
15512 section &<<SECTlocparlis>>& for a discussion of local part lists. Because the
15513 string is expanded, it is possible to make it depend on the domain, for
15514 example:
15515 .code
15516 local_parts = dbm;/usr/local/specials/$domain
15517 .endd
15518 .cindex "&$local_part_data$&"
15519 If the match is achieved by a lookup, the data that the lookup returned
15520 for the local part is placed in the variable &$local_part_data$& for use in
15521 expansions of the router's private options. You might use this option, for
15522 example, if you have a large number of local virtual domains, and you want to
15523 send all postmaster mail to the same place without having to set up an alias in
15524 each virtual domain:
15525 .code
15526 postmaster:
15527   driver = redirect
15528   local_parts = postmaster
15529   data = postmaster@real.domain.example
15530 .endd
15531
15532
15533 .option log_as_local routers boolean "see below"
15534 .cindex "log" "delivery line"
15535 .cindex "delivery" "log line format"
15536 Exim has two logging styles for delivery, the idea being to make local
15537 deliveries stand out more visibly from remote ones. In the &"local"& style, the
15538 recipient address is given just as the local part, without a domain. The use of
15539 this style is controlled by this option. It defaults to true for the &(accept)&
15540 router, and false for all the others. This option applies only when a
15541 router assigns an address to a transport. It has no effect on routers that
15542 redirect addresses.
15543
15544
15545
15546 .option more routers boolean&!! true
15547 The result of string expansion for this option must be a valid boolean value,
15548 that is, one of the strings &"yes"&, &"no"&, &"true"&, or &"false"&. Any other
15549 result causes an error, and delivery is deferred. If the expansion is forced to
15550 fail, the default value for the option (true) is used. Other failures cause
15551 delivery to be deferred.
15552
15553 If this option is set false, and the router declines to handle the address, no
15554 further routers are tried, routing fails, and the address is bounced.
15555 .cindex "&%self%& option"
15556 However, if the router explicitly passes an address to the following router by
15557 means of the setting
15558 .code
15559 self = pass
15560 .endd
15561 or otherwise, the setting of &%more%& is ignored. Also, the setting of &%more%&
15562 does not affect the behaviour if one of the precondition tests fails. In that
15563 case, the address is always passed to the next router.
15564
15565 Note that &%address_data%& is not considered to be a precondition. If its
15566 expansion is forced to fail, the router declines, and the value of &%more%&
15567 controls what happens next.
15568
15569
15570 .option pass_on_timeout routers boolean false
15571 .cindex "timeout" "of router"
15572 .cindex "router" "timeout"
15573 If a router times out during a host lookup, it normally causes deferral of the
15574 address. If &%pass_on_timeout%& is set, the address is passed on to the next
15575 router, overriding &%no_more%&. This may be helpful for systems that are
15576 intermittently connected to the Internet, or those that want to pass to a smart
15577 host any messages that cannot immediately be delivered.
15578
15579 There are occasional other temporary errors that can occur while doing DNS
15580 lookups. They are treated in the same way as a timeout, and this option
15581 applies to all of them.
15582
15583
15584
15585 .option pass_router routers string unset
15586 .cindex "router" "go to after &""pass""&"
15587 When a router returns &"pass"&, the address is normally handed on to the next
15588 router in sequence. This can be changed by setting &%pass_router%& to the name
15589 of another router. However (unlike &%redirect_router%&) the named router must
15590 be below the current router, to avoid loops. Note that this option applies only
15591 to the special case of &"pass"&. It does not apply when a router returns
15592 &"decline"&.
15593
15594
15595
15596 .option redirect_router routers string unset
15597 .cindex "router" "start at after redirection"
15598 Sometimes an administrator knows that it is pointless to reprocess addresses
15599 generated from alias or forward files with the same router again. For
15600 example, if an alias file translates real names into login ids there is no
15601 point searching the alias file a second time, especially if it is a large file.
15602
15603 The &%redirect_router%& option can be set to the name of any router instance.
15604 It causes the routing of any generated addresses to start at the named router
15605 instead of at the first router. This option has no effect if the router in
15606 which it is set does not generate new addresses.
15607
15608
15609
15610 .option require_files routers&!? "string list&!!" unset
15611 .cindex "file" "requiring for router"
15612 .cindex "router" "requiring file existence"
15613 This option provides a general mechanism for predicating the running of a
15614 router on the existence or non-existence of certain files or directories.
15615 Before running a router, as one of its precondition tests, Exim works its way
15616 through the &%require_files%& list, expanding each item separately.
15617
15618 Because the list is split before expansion, any colons in expansion items must
15619 be doubled, or the facility for using a different list separator must be used.
15620 If any expansion is forced to fail, the item is ignored. Other expansion
15621 failures cause routing of the address to be deferred.
15622
15623 If any expanded string is empty, it is ignored. Otherwise, except as described
15624 below, each string must be a fully qualified file path, optionally preceded by
15625 &"!"&. The paths are passed to the &[stat()]& function to test for the
15626 existence of the files or directories. The router is skipped if any paths not
15627 preceded by &"!"& do not exist, or if any paths preceded by &"!"& do exist.
15628
15629 .cindex "NFS"
15630 If &[stat()]& cannot determine whether a file exists or not, delivery of
15631 the message is deferred. This can happen when NFS-mounted filesystems are
15632 unavailable.
15633
15634 This option is checked after the &%domains%&, &%local_parts%&, and &%senders%&
15635 options, so you cannot use it to check for the existence of a file in which to
15636 look up a domain, local part, or sender. (See section &<<SECTrouprecon>>& for a
15637 full list of the order in which preconditions are evaluated.) However, as
15638 these options are all expanded, you can use the &%exists%& expansion condition
15639 to make such tests. The &%require_files%& option is intended for checking files
15640 that the router may be going to use internally, or which are needed by a
15641 transport (for example &_.procmailrc_&).
15642
15643 During delivery, the &[stat()]& function is run as root, but there is a
15644 facility for some checking of the accessibility of a file by another user.
15645 This is not a proper permissions check, but just a &"rough"& check that
15646 operates as follows:
15647
15648 If an item in a &%require_files%& list does not contain any forward slash
15649 characters, it is taken to be the user (and optional group, separated by a
15650 comma) to be checked for subsequent files in the list. If no group is specified
15651 but the user is specified symbolically, the gid associated with the uid is
15652 used. For example:
15653 .code
15654 require_files = mail:/some/file
15655 require_files = $local_part:$home/.procmailrc
15656 .endd
15657 If a user or group name in a &%require_files%& list does not exist, the
15658 &%require_files%& condition fails.
15659
15660 Exim performs the check by scanning along the components of the file path, and
15661 checking the access for the given uid and gid. It checks for &"x"& access on
15662 directories, and &"r"& access on the final file. Note that this means that file
15663 access control lists, if the operating system has them, are ignored.
15664
15665 &*Warning 1*&: When the router is being run to verify addresses for an
15666 incoming SMTP message, Exim is not running as root, but under its own uid. This
15667 may affect the result of a &%require_files%& check. In particular, &[stat()]&
15668 may yield the error EACCES (&"Permission denied"&). This means that the Exim
15669 user is not permitted to read one of the directories on the file's path.
15670
15671 &*Warning 2*&: Even when Exim is running as root while delivering a message,
15672 &[stat()]& can yield EACCES for a file in an NFS directory that is mounted
15673 without root access. In this case, if a check for access by a particular user
15674 is requested, Exim creates a subprocess that runs as that user, and tries the
15675 check again in that process.
15676
15677 The default action for handling an unresolved EACCES is to consider it to
15678 be caused by a configuration error, and routing is deferred because the
15679 existence or non-existence of the file cannot be determined. However, in some
15680 circumstances it may be desirable to treat this condition as if the file did
15681 not exist. If the file name (or the exclamation mark that precedes the file
15682 name for non-existence) is preceded by a plus sign, the EACCES error is treated
15683 as if the file did not exist. For example:
15684 .code
15685 require_files = +/some/file
15686 .endd
15687 If the router is not an essential part of verification (for example, it
15688 handles users' &_.forward_& files), another solution is to set the &%verify%&
15689 option false so that the router is skipped when verifying.
15690
15691
15692
15693 .option retry_use_local_part routers boolean "see below"
15694 .cindex "hints database" "retry keys"
15695 .cindex "local part" "in retry keys"
15696 When a delivery suffers a temporary routing failure, a retry record is created
15697 in Exim's hints database. For addresses whose routing depends only on the
15698 domain, the key for the retry record should not involve the local part, but for
15699 other addresses, both the domain and the local part should be included.
15700 Usually, remote routing is of the former kind, and local routing is of the
15701 latter kind.
15702
15703 This option controls whether the local part is used to form the key for retry
15704 hints for addresses that suffer temporary errors while being handled by this
15705 router. The default value is true for any router that has &%check_local_user%&
15706 set, and false otherwise. Note that this option does not apply to hints keys
15707 for transport delays; they are controlled by a generic transport option of the
15708 same name.
15709
15710 The setting of &%retry_use_local_part%& applies only to the router on which it
15711 appears. If the router generates child addresses, they are routed
15712 independently; this setting does not become attached to them.
15713
15714
15715
15716 .option router_home_directory routers string&!! unset
15717 .cindex "router" "home directory for"
15718 .cindex "home directory" "for router"
15719 .cindex "&$home$&"
15720 This option sets a home directory for use while the router is running. (Compare
15721 &%transport_home_directory%&, which sets a home directory for later
15722 transporting.) In particular, if used on a &(redirect)& router, this option
15723 sets a value for &$home$& while a filter is running. The value is expanded;
15724 forced expansion failure causes the option to be ignored &-- other failures
15725 cause the router to defer.
15726
15727 Expansion of &%router_home_directory%& happens immediately after the
15728 &%check_local_user%& test (if configured), before any further expansions take
15729 place.
15730 (See section &<<SECTrouprecon>>& for a list of the order in which preconditions
15731 are evaluated.)
15732 While the router is running, &%router_home_directory%& overrides the value of
15733 &$home$& that came from &%check_local_user%&.
15734
15735 When a router accepts an address and assigns it to a local transport (including
15736 the cases when a &(redirect)& router generates a pipe, file, or autoreply
15737 delivery), the home directory setting for the transport is taken from the first
15738 of these values that is set:
15739
15740 .ilist
15741 The &%home_directory%& option on the transport;
15742 .next
15743 The &%transport_home_directory%& option on the router;
15744 .next
15745 The password data if &%check_local_user%& is set on the router;
15746 .next
15747 The &%router_home_directory%& option on the router.
15748 .endlist
15749
15750 In other words, &%router_home_directory%& overrides the password data for the
15751 router, but not for the transport.
15752
15753
15754
15755 .option self routers string freeze
15756 .cindex "MX record" "pointing to local host"
15757 .cindex "local host" "MX pointing to"
15758 This option applies to those routers that use a recipient address to find a
15759 list of remote hosts. Currently, these are the &(dnslookup)&, &(ipliteral)&,
15760 and &(manualroute)& routers.
15761 Certain configurations of the &(queryprogram)& router can also specify a list
15762 of remote hosts.
15763 Usually such routers are configured to send the message to a remote host via an
15764 &(smtp)& transport. The &%self%& option specifies what happens when the first
15765 host on the list turns out to be the local host.
15766 The way in which Exim checks for the local host is described in section
15767 &<<SECTreclocipadd>>&.
15768
15769 Normally this situation indicates either an error in Exim's configuration (for
15770 example, the router should be configured not to process this domain), or an
15771 error in the DNS (for example, the MX should not point to this host). For this
15772 reason, the default action is to log the incident, defer the address, and
15773 freeze the message. The following alternatives are provided for use in special
15774 cases:
15775
15776 .vlist
15777 .vitem &%defer%&
15778 Delivery of the message is tried again later, but the message is not frozen.
15779
15780 .vitem "&%reroute%&: <&'domain'&>"
15781 The domain is changed to the given domain, and the address is passed back to
15782 be reprocessed by the routers. No rewriting of headers takes place. This
15783 behaviour is essentially a redirection.
15784
15785 .vitem "&%reroute: rewrite:%& <&'domain'&>"
15786 The domain is changed to the given domain, and the address is passed back to be
15787 reprocessed by the routers. Any headers that contain the original domain are
15788 rewritten.
15789
15790 .vitem &%pass%&
15791 .cindex "&%more%& option"
15792 .cindex "&$self_hostname$&"
15793 The router passes the address to the next router, or to the router named in the
15794 &%pass_router%& option if it is set. This overrides &%no_more%&. During
15795 subsequent routing and delivery, the variable &$self_hostname$& contains the
15796 name of the local host that the router encountered. This can be used to
15797 distinguish between different cases for hosts with multiple names. The
15798 combination
15799 .code
15800 self = pass
15801 no_more
15802 .endd
15803 ensures that only those addresses that routed to the local host are passed on.
15804 Without &%no_more%&, addresses that were declined for other reasons would also
15805 be passed to the next router.
15806
15807 .vitem &%fail%&
15808 Delivery fails and an error report is generated.
15809
15810 .vitem &%send%&
15811 .cindex "local host" "sending to"
15812 The anomaly is ignored and the address is queued for the transport. This
15813 setting should be used with extreme caution. For an &(smtp)& transport, it
15814 makes sense only in cases where the program that is listening on the SMTP port
15815 is not this version of Exim. That is, it must be some other MTA, or Exim with a
15816 different configuration file that handles the domain in another way.
15817 .endlist
15818
15819
15820
15821 .option senders routers&!? "address list&!!" unset
15822 .cindex "router" "checking senders"
15823 If this option is set, the router is skipped unless the message's sender
15824 address matches something on the list.
15825 See section &<<SECTrouprecon>>& for a list of the order in which preconditions
15826 are evaluated.
15827
15828 There are issues concerning verification when the running of routers is
15829 dependent on the sender. When Exim is verifying the address in an &%errors_to%&
15830 setting, it sets the sender to the null string. When using the &%-bt%& option
15831 to check a configuration file, it is necessary also to use the &%-f%& option to
15832 set an appropriate sender. For incoming mail, the sender is unset when
15833 verifying the sender, but is available when verifying any recipients. If the
15834 SMTP VRFY command is enabled, it must be used after MAIL if the sender address
15835 matters.
15836
15837
15838 .option translate_ip_address routers string&!! unset
15839 .cindex "IP address" "translating"
15840 .cindex "packet radio"
15841 .cindex "router" "IP address translation"
15842 There exist some rare networking situations (for example, packet radio) where
15843 it is helpful to be able to translate IP addresses generated by normal routing
15844 mechanisms into other IP addresses, thus performing a kind of manual IP
15845 routing. This should be done only if the normal IP routing of the TCP/IP stack
15846 is inadequate or broken. Because this is an extremely uncommon requirement, the
15847 code to support this option is not included in the Exim binary unless
15848 SUPPORT_TRANSLATE_IP_ADDRESS=yes is set in &_Local/Makefile_&.
15849
15850 .cindex "&$host_address$&"
15851 The &%translate_ip_address%& string is expanded for every IP address generated
15852 by the router, with the generated address set in &$host_address$&. If the
15853 expansion is forced to fail, no action is taken.
15854 For any other expansion error, delivery of the message is deferred.
15855 If the result of the expansion is an IP address, that replaces the original
15856 address; otherwise the result is assumed to be a host name &-- this is looked
15857 up using &[gethostbyname()]& (or &[getipnodebyname()]& when available) to
15858 produce one or more replacement IP addresses. For example, to subvert all IP
15859 addresses in some specific networks, this could be added to a router:
15860 .code
15861 translate_ip_address = \
15862   ${lookup{${mask:$host_address/26}}lsearch{/some/file}\
15863     {$value}fail}}
15864 .endd
15865 The file would contain lines like
15866 .code
15867 10.2.3.128/26    some.host
15868 10.8.4.34/26     10.44.8.15
15869 .endd
15870 You should not make use of this facility unless you really understand what you
15871 are doing.
15872
15873
15874
15875 .option transport routers string&!! unset
15876 This option specifies the transport to be used when a router accepts an address
15877 and sets it up for delivery. A transport is never needed if a router is used
15878 only for verification. The value of the option is expanded at routing time,
15879 after the expansion of &%errors_to%&, &%headers_add%&, and &%headers_remove%&,
15880 and result must be the name of one of the configured transports. If it is not,
15881 delivery is deferred.
15882
15883 The &%transport%& option is not used by the &(redirect)& router, but it does
15884 have some private options that set up transports for pipe and file deliveries
15885 (see chapter &<<CHAPredirect>>&).
15886
15887
15888
15889 .option transport_current_directory routers string&!! unset
15890 .cindex "current directory for local transport"
15891 This option associates a current directory with any address that is routed
15892 to a local transport. This can happen either because a transport is
15893 explicitly configured for the router, or because it generates a delivery to a
15894 file or a pipe. During the delivery process (that is, at transport time), this
15895 option string is expanded and is set as the current directory, unless
15896 overridden by a setting on the transport.
15897 If the expansion fails for any reason, including forced failure, an error is
15898 logged, and delivery is deferred.
15899 See chapter &<<CHAPenvironment>>& for details of the local delivery
15900 environment.
15901
15902
15903
15904
15905 .option transport_home_directory routers string&!! "see below"
15906 .cindex "home directory" "for local transport"
15907 This option associates a home directory with any address that is routed to a
15908 local transport. This can happen either because a transport is explicitly
15909 configured for the router, or because it generates a delivery to a file or a
15910 pipe. During the delivery process (that is, at transport time), the option
15911 string is expanded and is set as the home directory, unless overridden by a
15912 setting of &%home_directory%& on the transport.
15913 If the expansion fails for any reason, including forced failure, an error is
15914 logged, and delivery is deferred.
15915
15916 If the transport does not specify a home directory, and
15917 &%transport_home_directory%& is not set for the router, the home directory for
15918 the tranport is taken from the password data if &%check_local_user%& is set for
15919 the router. Otherwise it is taken from &%router_home_directory%& if that option
15920 is set; if not, no home directory is set for the transport.
15921
15922 See chapter &<<CHAPenvironment>>& for further details of the local delivery
15923 environment.
15924
15925
15926
15927
15928 .option unseen routers boolean&!! false
15929 .cindex "router" "carrying on after success"
15930 The result of string expansion for this option must be a valid boolean value,
15931 that is, one of the strings &"yes"&, &"no"&, &"true"&, or &"false"&. Any other
15932 result causes an error, and delivery is deferred. If the expansion is forced to
15933 fail, the default value for the option (false) is used. Other failures cause
15934 delivery to be deferred.
15935
15936 When this option is set true, routing does not cease if the router accepts the
15937 address. Instead, a copy of the incoming address is passed to the next router,
15938 overriding a false setting of &%more%&. There is little point in setting
15939 &%more%& false if &%unseen%& is always true, but it may be useful in cases when
15940 the value of &%unseen%& contains expansion items (and therefore, presumably, is
15941 sometimes true and sometimes false).
15942
15943 .cindex "copy of message (&%unseen%& option)"
15944 The &%unseen%& option can be used to cause copies of messages to be delivered
15945 to some other destination, while also carrying out a normal delivery. In
15946 effect, the current address is made into a &"parent"& that has two children &--
15947 one that is delivered as specified by this router, and a clone that goes on to
15948 be routed further. For this reason, &%unseen%& may not be combined with the
15949 &%one_time%& option in a &(redirect)& router.
15950
15951 &*Warning*&: Header lines added to the address (or specified for removal) by
15952 this router or by previous routers affect the &"unseen"& copy of the message
15953 only. The clone that continues to be processed by further routers starts with
15954 no added headers and none specified for removal. However, any data that was set
15955 by the &%address_data%& option in the current or previous routers is passed on.
15956 Setting the &%unseen%& option has a similar effect to the &%unseen%& command
15957 qualifier in filter files.
15958
15959
15960
15961 .option user routers string&!! "see below"
15962 .cindex "uid (user id)" "local delivery"
15963 .cindex "local transports" "uid and gid"
15964 .cindex "transport" "local"
15965 .cindex "router" "user for filter processing"
15966 .cindex "filter" "user for processing"
15967 When a router queues an address for a transport, and the transport does not
15968 specify a user, the user given here is used when running the delivery process.
15969 The user may be specified numerically or by name. If expansion fails, the
15970 error is logged and delivery is deferred.
15971 This user is also used by the &(redirect)& router when running a filter file.
15972 The default is unset, except when &%check_local_user%& is set. In this case,
15973 the default is taken from the password information. If the user is specified as
15974 a name, and &%group%& is not set, the group associated with the user is used.
15975 See also &%initgroups%& and &%group%& and the discussion in chapter
15976 &<<CHAPenvironment>>&.
15977
15978
15979
15980 .option verify routers&!? boolean true
15981 Setting this option has the effect of setting &%verify_sender%& and
15982 &%verify_recipient%& to the same value.
15983
15984
15985 .option verify_only routers&!? boolean false
15986 .cindex "EXPN" "with &%verify_only%&"
15987 .cindex "&%-bv%& option"
15988 .cindex "router" "used only when verifying"
15989 If this option is set, the router is used only when verifying an address or
15990 testing with the &%-bv%& option, not when actually doing a delivery, testing
15991 with the &%-bt%& option, or running the SMTP EXPN command. It can be further
15992 restricted to verifying only senders or recipients by means of
15993 &%verify_sender%& and &%verify_recipient%&.
15994
15995 &*Warning*&: When the router is being run to verify addresses for an incoming
15996 SMTP message, Exim is not running as root, but under its own uid. If the router
15997 accesses any files, you need to make sure that they are accessible to the Exim
15998 user or group.
15999
16000
16001 .option verify_recipient routers&!? boolean true
16002 If this option is false, the router is skipped when verifying recipient
16003 addresses
16004 or testing recipient verification using &%-bv%&.
16005 See section &<<SECTrouprecon>>& for a list of the order in which preconditions
16006 are evaluated.
16007
16008
16009 .option verify_sender routers&!? boolean true
16010 If this option is false, the router is skipped when verifying sender addresses
16011 or testing sender verification using &%-bvs%&.
16012 See section &<<SECTrouprecon>>& for a list of the order in which preconditions
16013 are evaluated.
16014 .ecindex IIDgenoprou1
16015 .ecindex IIDgenoprou2
16016
16017
16018
16019
16020
16021
16022 . ////////////////////////////////////////////////////////////////////////////
16023 . ////////////////////////////////////////////////////////////////////////////
16024
16025 .chapter "The accept router"
16026 .cindex "&(accept)& router"
16027 .cindex "routers" "&(accept)&"
16028 The &(accept)& router has no private options of its own. Unless it is being
16029 used purely for verification (see &%verify_only%&) a transport is required to
16030 be defined by the generic &%transport%& option. If the preconditions that are
16031 specified by generic options are met, the router accepts the address and queues
16032 it for the given transport. The most common use of this router is for setting
16033 up deliveries to local mailboxes. For example:
16034 .code
16035 localusers:
16036   driver = accept
16037   domains = mydomain.example
16038   check_local_user
16039   transport = local_delivery
16040 .endd
16041 The &%domains%& condition in this example checks the domain of the address, and
16042 &%check_local_user%& checks that the local part is the login of a local user.
16043 When both preconditions are met, the &(accept)& router runs, and queues the
16044 address for the &(local_delivery)& transport.
16045
16046
16047
16048
16049
16050
16051 . ////////////////////////////////////////////////////////////////////////////
16052 . ////////////////////////////////////////////////////////////////////////////
16053
16054 .chapter "The dnslookup router" "CHAPdnslookup"
16055 .scindex IIDdnsrou1 "&(dnslookup)& router"
16056 .scindex IIDdnsrou2 "routers" "&(dnslookup)&"
16057 The &(dnslookup)& router looks up the hosts that handle mail for the
16058 recipient's domain in the DNS. A transport must always be set for this router,
16059 unless &%verify_only%& is set.
16060
16061 If SRV support is configured (see &%check_srv%& below), Exim first searches for
16062 SRV records. If none are found, or if SRV support is not configured,
16063 MX records are looked up. If no MX records exist, address records are sought.
16064 However, &%mx_domains%& can be set to disable the direct use of address
16065 records.
16066
16067 MX records of equal priority are sorted by Exim into a random order. Exim then
16068 looks for address records for the host names obtained from MX or SRV records.
16069 When a host has more than one IP address, they are sorted into a random order,
16070 except that IPv6 addresses are always sorted before IPv4 addresses. If all the
16071 IP addresses found are discarded by a setting of the &%ignore_target_hosts%&
16072 generic option, the router declines.
16073
16074 Unless they have the highest priority (lowest MX value), MX records that point
16075 to the local host, or to any host name that matches &%hosts_treat_as_local%&,
16076 are discarded, together with any other MX records of equal or lower priority.
16077
16078 .cindex "MX record" "pointing to local host"
16079 .cindex "local host" "MX pointing to"
16080 .cindex "&%self%& option" "in &(dnslookup)& router"
16081 If the host pointed to by the highest priority MX record, or looked up as an
16082 address record, is the local host, or matches &%hosts_treat_as_local%&, what
16083 happens is controlled by the generic &%self%& option.
16084
16085
16086 .section "Problems with DNS lookups" "SECTprowitdnsloo"
16087 There have been problems with DNS servers when SRV records are looked up.
16088 Some mis-behaving servers return a DNS error or timeout when a non-existent
16089 SRV record is sought. Similar problems have in the past been reported for
16090 MX records. The global &%dns_again_means_nonexist%& option can help with this
16091 problem, but it is heavy-handed because it is a global option.
16092
16093 For this reason, there are two options, &%srv_fail_domains%& and
16094 &%mx_fail_domains%&, that control what happens when a DNS lookup in a
16095 &(dnslookup)& router results in a DNS failure or a &"try again"& response. If
16096 an attempt to look up an SRV or MX record causes one of these results, and the
16097 domain matches the relevant list, Exim behaves as if the DNS had responded &"no
16098 such record"&. In the case of an SRV lookup, this means that the router
16099 proceeds to look for MX records; in the case of an MX lookup, it proceeds to
16100 look for A or AAAA records, unless the domain matches &%mx_domains%&, in which
16101 case routing fails.
16102
16103
16104
16105
16106 .section "Private options for dnslookup"
16107 .cindex "options" "&(dnslookup)& router"
16108 The private options for the &(dnslookup)& router are as follows:
16109
16110 .option check_secondary_mx dnslookup boolean false
16111 .cindex "MX record" "checking for secondary"
16112 If this option is set, the router declines unless the local host is found in
16113 (and removed from) the list of hosts obtained by MX lookup. This can be used to
16114 process domains for which the local host is a secondary mail exchanger
16115 differently to other domains. The way in which Exim decides whether a host is
16116 the local host is described in section &<<SECTreclocipadd>>&.
16117
16118
16119 .option check_srv dnslookup string&!! unset
16120 .cindex "SRV record" "enabling use of"
16121 The &(dnslookup)& router supports the use of SRV records (see RFC 2782) in
16122 addition to MX and address records. The support is disabled by default. To
16123 enable SRV support, set the &%check_srv%& option to the name of the service
16124 required. For example,
16125 .code
16126 check_srv = smtp
16127 .endd
16128 looks for SRV records that refer to the normal smtp service. The option is
16129 expanded, so the service name can vary from message to message or address
16130 to address. This might be helpful if SRV records are being used for a
16131 submission service. If the expansion is forced to fail, the &%check_srv%&
16132 option is ignored, and the router proceeds to look for MX records in the
16133 normal way.
16134
16135 When the expansion succeeds, the router searches first for SRV records for
16136 the given service (it assumes TCP protocol). A single SRV record with a
16137 host name that consists of just a single dot indicates &"no such service for
16138 this domain"&; if this is encountered, the router declines. If other kinds of
16139 SRV record are found, they are used to construct a host list for delivery
16140 according to the rules of RFC 2782. MX records are not sought in this case.
16141
16142 When no SRV records are found, MX records (and address records) are sought in
16143 the traditional way. In other words, SRV records take precedence over MX
16144 records, just as MX records take precedence over address records. Note that
16145 this behaviour is not sanctioned by RFC 2782, though a previous draft RFC
16146 defined it. It is apparently believed that MX records are sufficient for email
16147 and that SRV records should not be used for this purpose. However, SRV records
16148 have an additional &"weight"& feature which some people might find useful when
16149 trying to split an SMTP load between hosts of different power.
16150
16151 See section &<<SECTprowitdnsloo>>& above for a discussion of Exim's behaviour
16152 when there is a DNS lookup error.
16153
16154
16155
16156 .option mx_domains dnslookup "domain list&!!" unset
16157 .cindex "MX record" "required to exist"
16158 .cindex "SRV record" "required to exist"
16159 A domain that matches &%mx_domains%& is required to have either an MX or an SRV
16160 record in order to be recognised. (The name of this option could be improved.)
16161 For example, if all the mail hosts in &'fict.example'& are known to have MX
16162 records, except for those in &'discworld.fict.example'&, you could use this
16163 setting:
16164 .code
16165 mx_domains = ! *.discworld.fict.example : *.fict.example
16166 .endd
16167 This specifies that messages addressed to a domain that matches the list but
16168 has no MX record should be bounced immediately instead of being routed using
16169 the address record.
16170
16171
16172 .option mx_fail_domains dnslookup "domain list&!!" unset
16173 If the DNS lookup for MX records for one of the domains in this list causes a
16174 DNS lookup error, Exim behaves as if no MX records were found. See section
16175 &<<SECTprowitdnsloo>>& for more discussion.
16176
16177
16178
16179
16180 .option qualify_single dnslookup boolean true
16181 .cindex "DNS" "resolver options"
16182 .cindex "DNS" "qualifying single-component names"
16183 When this option is true, the resolver option RES_DEFNAMES is set for DNS
16184 lookups. Typically, but not standardly, this causes the resolver to qualify
16185 single-component names with the default domain. For example, on a machine
16186 called &'dictionary.ref.example'&, the domain &'thesaurus'& would be changed to
16187 &'thesaurus.ref.example'& inside the resolver. For details of what your
16188 resolver actually does, consult your man pages for &'resolver'& and
16189 &'resolv.conf'&.
16190
16191
16192
16193 .option rewrite_headers dnslookup boolean true
16194 .cindex "rewriting" "header lines"
16195 .cindex "header lines" "rewriting"
16196 If the domain name in the address that is being processed is not fully
16197 qualified, it may be expanded to its full form by a DNS lookup. For example, if
16198 an address is specified as &'dormouse@teaparty'&, the domain might be
16199 expanded to &'teaparty.wonderland.fict.example'&. Domain expansion can also
16200 occur as a result of setting the &%widen_domains%& option. If
16201 &%rewrite_headers%& is true, all occurrences of the abbreviated domain name in
16202 any &'Bcc:'&, &'Cc:'&, &'From:'&, &'Reply-to:'&, &'Sender:'&, and &'To:'&
16203 header lines of the message are rewritten with the full domain name.
16204
16205 This option should be turned off only when it is known that no message is
16206 ever going to be sent outside an environment where the abbreviation makes
16207 sense.
16208
16209 When an MX record is looked up in the DNS and matches a wildcard record, name
16210 servers normally return a record containing the name that has been looked up,
16211 making it impossible to detect whether a wildcard was present or not. However,
16212 some name servers have recently been seen to return the wildcard entry. If the
16213 name returned by a DNS lookup begins with an asterisk, it is not used for
16214 header rewriting.
16215
16216
16217 .option same_domain_copy_routing dnslookup boolean false
16218 .cindex "address" "copying routing"
16219 Addresses with the same domain are normally routed by the &(dnslookup)& router
16220 to the same list of hosts. However, this cannot be presumed, because the router
16221 options and preconditions may refer to the local part of the address. By
16222 default, therefore, Exim routes each address in a message independently. DNS
16223 servers run caches, so repeated DNS lookups are not normally expensive, and in
16224 any case, personal messages rarely have more than a few recipients.
16225
16226 If you are running mailing lists with large numbers of subscribers at the same
16227 domain, and you are using a &(dnslookup)& router which is independent of the
16228 local part, you can set &%same_domain_copy_routing%& to bypass repeated DNS
16229 lookups for identical domains in one message. In this case, when &(dnslookup)&
16230 routes an address to a remote transport, any other unrouted addresses in the
16231 message that have the same domain are automatically given the same routing
16232 without processing them independently,
16233 provided the following conditions are met:
16234
16235 .ilist
16236 No router that processed the address specified &%headers_add%& or
16237 &%headers_remove%&.
16238 .next
16239 The router did not change the address in any way, for example, by &"widening"&
16240 the domain.
16241 .endlist
16242
16243
16244
16245
16246 .option search_parents dnslookup boolean false
16247 .cindex "DNS" "resolver options"
16248 When this option is true, the resolver option RES_DNSRCH is set for DNS
16249 lookups. This is different from the &%qualify_single%& option in that it
16250 applies to domains containing dots. Typically, but not standardly, it causes
16251 the resolver to search for the name in the current domain and in parent
16252 domains. For example, on a machine in the &'fict.example'& domain, if looking
16253 up &'teaparty.wonderland'& failed, the resolver would try
16254 &'teaparty.wonderland.fict.example'&. For details of what your resolver
16255 actually does, consult your man pages for &'resolver'& and &'resolv.conf'&.
16256
16257 Setting this option true can cause problems in domains that have a wildcard MX
16258 record, because any domain that does not have its own MX record matches the
16259 local wildcard.
16260
16261
16262
16263 .option srv_fail_domains dnslookup "domain list&!!" unset
16264 If the DNS lookup for SRV records for one of the domains in this list causes a
16265 DNS lookup error, Exim behaves as if no SRV records were found. See section
16266 &<<SECTprowitdnsloo>>& for more discussion.
16267
16268
16269
16270
16271 .option widen_domains dnslookup "string list" unset
16272 .cindex "domain" "partial; widening"
16273 If a DNS lookup fails and this option is set, each of its strings in turn is
16274 added onto the end of the domain, and the lookup is tried again. For example,
16275 if
16276 .code
16277 widen_domains = fict.example:ref.example
16278 .endd
16279 is set and a lookup of &'klingon.dictionary'& fails,
16280 &'klingon.dictionary.fict.example'& is looked up, and if this fails,
16281 &'klingon.dictionary.ref.example'& is tried. Note that the &%qualify_single%&
16282 and &%search_parents%& options can cause some widening to be undertaken inside
16283 the DNS resolver. &%widen_domains%& is not applied to sender addresses
16284 when verifying, unless &%rewrite_headers%& is false (not the default).
16285
16286
16287 .section "Effect of qualify_single and search_parents"
16288 When a domain from an envelope recipient is changed by the resolver as a result
16289 of the &%qualify_single%& or &%search_parents%& options, Exim rewrites the
16290 corresponding address in the message's header lines unless &%rewrite_headers%&
16291 is set false. Exim then re-routes the address, using the full domain.
16292
16293 These two options affect only the DNS lookup that takes place inside the router
16294 for the domain of the address that is being routed. They do not affect lookups
16295 such as that implied by
16296 .code
16297 domains = @mx_any
16298 .endd
16299 that may happen while processing a router precondition before the router is
16300 entered. No widening ever takes place for these lookups.
16301 .ecindex IIDdnsrou1
16302 .ecindex IIDdnsrou2
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312 . ////////////////////////////////////////////////////////////////////////////
16313 . ////////////////////////////////////////////////////////////////////////////
16314
16315 .chapter "The ipliteral router"
16316 .cindex "&(ipliteral)& router"
16317 .cindex "domain literal" "routing"
16318 .cindex "routers" "&(ipliteral)&"
16319 This router has no private options. Unless it is being used purely for
16320 verification (see &%verify_only%&) a transport is required to be defined by the
16321 generic &%transport%& option. The router accepts the address if its domain part
16322 takes the form of an RFC 2822 domain literal. For example, the &(ipliteral)&
16323 router handles the address
16324 .code
16325 root@[192.168.1.1]
16326 .endd
16327 by setting up delivery to the host with that IP address. IPv4 domain literals
16328 consist of an IPv4 address enclosed in square brackets. IPv6 domain literals
16329 are similar, but the address is preceded by &`ipv6:`&. For example:
16330 .code
16331 postmaster@[ipv6:fe80::a00:20ff:fe86:a061.5678]
16332 .endd
16333 Exim allows &`ipv4:`& before IPv4 addresses, for consistency, and on the
16334 grounds that sooner or later somebody will try it.
16335
16336 .cindex "&%self%& option" "in &(ipliteral)& router"
16337 If the IP address matches something in &%ignore_target_hosts%&, the router
16338 declines. If an IP literal turns out to refer to the local host, the generic
16339 &%self%& option determines what happens.
16340
16341 The RFCs require support for domain literals; however, their use is
16342 controversial in today's Internet. If you want to use this router, you must
16343 also set the main configuration option &%allow_domain_literals%&. Otherwise,
16344 Exim will not recognize the domain literal syntax in addresses.
16345
16346
16347
16348 . ////////////////////////////////////////////////////////////////////////////
16349 . ////////////////////////////////////////////////////////////////////////////
16350
16351 .chapter "The iplookup router"
16352 .cindex "&(iplookup)& router"
16353 .cindex "routers" "&(iplookup)&"
16354 The &(iplookup)& router was written to fulfil a specific requirement in
16355 Cambridge University (which in fact no longer exists). For this reason, it is
16356 not included in the binary of Exim by default. If you want to include it, you
16357 must set
16358 .code
16359 ROUTER_IPLOOKUP=yes
16360 .endd
16361 in your &_Local/Makefile_& configuration file.
16362
16363 The &(iplookup)& router routes an address by sending it over a TCP or UDP
16364 connection to one or more specific hosts. The host can then return the same or
16365 a different address &-- in effect rewriting the recipient address in the
16366 message's envelope. The new address is then passed on to subsequent routers. If
16367 this process fails, the address can be passed on to other routers, or delivery
16368 can be deferred. Since &(iplookup)& is just a rewriting router, a transport
16369 must not be specified for it.
16370
16371 .cindex "options" "&(iplookup)& router"
16372 .option hosts iplookup string unset
16373 This option must be supplied. Its value is a colon-separated list of host
16374 names. The hosts are looked up using &[gethostbyname()]&
16375 (or &[getipnodebyname()]& when available)
16376 and are tried in order until one responds to the query. If none respond, what
16377 happens is controlled by &%optional%&.
16378
16379
16380 .option optional iplookup boolean false
16381 If &%optional%& is true, if no response is obtained from any host, the address
16382 is passed to the next router, overriding &%no_more%&. If &%optional%& is false,
16383 delivery to the address is deferred.
16384
16385
16386 .option port iplookup integer 0
16387 .cindex "port" "&(iplookup)& router"
16388 This option must be supplied. It specifies the port number for the TCP or UDP
16389 call.
16390
16391
16392 .option protocol iplookup string udp
16393 This option can be set to &"udp"& or &"tcp"& to specify which of the two
16394 protocols is to be used.
16395
16396
16397 .option query iplookup string&!! "&`$local_part@$domain $local_part@$domain`&"
16398 This defines the content of the query that is sent to the remote hosts. The
16399 repetition serves as a way of checking that a response is to the correct query
16400 in the default case (see &%response_pattern%& below).
16401
16402
16403 .option reroute iplookup string&!! unset
16404 If this option is not set, the rerouted address is precisely the byte string
16405 returned by the remote host, up to the first white space, if any. If set, the
16406 string is expanded to form the rerouted address. It can include parts matched
16407 in the response by &%response_pattern%& by means of numeric variables such as
16408 &$1$&, &$2$&, etc. The variable &$0$& refers to the entire input string,
16409 whether or not a pattern is in use. In all cases, the rerouted address must end
16410 up in the form &'local_part@domain'&.
16411
16412
16413 .option response_pattern iplookup string unset
16414 This option can be set to a regular expression that is applied to the string
16415 returned from the remote host. If the pattern does not match the response, the
16416 router declines. If &%response_pattern%& is not set, no checking of the
16417 response is done, unless the query was defaulted, in which case there is a
16418 check that the text returned after the first white space is the original
16419 address. This checks that the answer that has been received is in response to
16420 the correct question. For example, if the response is just a new domain, the
16421 following could be used:
16422 .code
16423 response_pattern = ^([^@]+)$
16424 reroute = $local_part@$1
16425 .endd
16426
16427 .option timeout iplookup time 5s
16428 This specifies the amount of time to wait for a response from the remote
16429 machine. The same timeout is used for the &[connect()]& function for a TCP
16430 call. It does not apply to UDP.
16431
16432
16433
16434
16435 . ////////////////////////////////////////////////////////////////////////////
16436 . ////////////////////////////////////////////////////////////////////////////
16437
16438 .chapter "The manualroute router"
16439 .scindex IIDmanrou1 "&(manualroute)& router"
16440 .scindex IIDmanrou2 "routers" "&(manualroute)&"
16441 .cindex "domain" "manually routing"
16442 The &(manualroute)& router is so-called because it provides a way of manually
16443 routing an address according to its domain. It is mainly used when you want to
16444 route addresses to remote hosts according to your own rules, bypassing the
16445 normal DNS routing that looks up MX records. However, &(manualroute)& can also
16446 route to local transports, a facility that may be useful if you want to save
16447 messages for dial-in hosts in local files.
16448
16449 The &(manualroute)& router compares a list of domain patterns with the domain
16450 it is trying to route. If there is no match, the router declines. Each pattern
16451 has associated with it a list of hosts and some other optional data, which may
16452 include a transport. The combination of a pattern and its data is called a
16453 &"routing rule"&. For patterns that do not have an associated transport, the
16454 generic &%transport%& option must specify a transport, unless the router is
16455 being used purely for verification (see &%verify_only%&).
16456
16457 .cindex "&$host$&"
16458 In the case of verification, matching the domain pattern is sufficient for the
16459 router to accept the address. When actually routing an address for delivery,
16460 an address that matches a domain pattern is queued for the associated
16461 transport. If the transport is not a local one, a host list must be associated
16462 with the pattern; IP addresses are looked up for the hosts, and these are
16463 passed to the transport along with the mail address. For local transports, a
16464 host list is optional. If it is present, it is passed in &$host$& as a single
16465 text string.
16466
16467 The list of routing rules can be provided as an inline string in
16468 &%route_list%&, or the data can be obtained by looking up the domain in a file
16469 or database by setting &%route_data%&. Only one of these settings may appear in
16470 any one instance of &(manualroute)&. The format of routing rules is described
16471 below, following the list of private options.
16472
16473
16474 .section "Private options for manualroute" "SECTprioptman"
16475
16476 .cindex "options" "&(manualroute)& router"
16477 The private options for the &(manualroute)& router are as follows:
16478
16479
16480 .option host_find_failed manualroute string freeze
16481 This option controls what happens when &(manualroute)& tries to find an IP
16482 address for a host, and the host does not exist. The option can be set to one
16483 of
16484 .code
16485 decline
16486 defer
16487 fail
16488 freeze
16489 pass
16490 .endd
16491 The default assumes that this state is a serious configuration error. The
16492 difference between &"pass"& and &"decline"& is that the former forces the
16493 address to be passed to the next router (or the router defined by
16494 &%pass_router%&),
16495 .cindex "&%more%& option"
16496 overriding &%no_more%&, whereas the latter passes the address to the next
16497 router only if &%more%& is true.
16498
16499 This option applies only to a definite &"does not exist"& state; if a host
16500 lookup gets a temporary error, delivery is deferred unless the generic
16501 &%pass_on_timeout%& option is set.
16502
16503
16504 .option hosts_randomize manualroute boolean false
16505 .cindex "randomized host list"
16506 .cindex "host" "list of; randomized"
16507 If this option is set, the order of the items in a host list in a routing rule
16508 is randomized each time the list is used, unless an option in the routing rule
16509 overrides (see below). Randomizing the order of a host list can be used to do
16510 crude load sharing. However, if more than one mail address is routed by the
16511 same router to the same host list, the host lists are considered to be the same
16512 (even though they may be randomized into different orders) for the purpose of
16513 deciding whether to batch the deliveries into a single SMTP transaction.
16514
16515 When &%hosts_randomize%& is true, a host list may be split
16516 into groups whose order is separately randomized. This makes it possible to
16517 set up MX-like behaviour. The boundaries between groups are indicated by an
16518 item that is just &`+`& in the host list. For example:
16519 .code
16520 route_list = * host1:host2:host3:+:host4:host5
16521 .endd
16522 The order of the first three hosts and the order of the last two hosts is
16523 randomized for each use, but the first three always end up before the last two.
16524 If &%hosts_randomize%& is not set, a &`+`& item in the list is ignored. If a
16525 randomized host list is passed to an &(smtp)& transport that also has
16526 &%hosts_randomize set%&, the list is not re-randomized.
16527
16528
16529 .option route_data manualroute string&!! unset
16530 If this option is set, it must expand to yield the data part of a routing rule.
16531 Typically, the expansion string includes a lookup based on the domain. For
16532 example:
16533 .code
16534 route_data = ${lookup{$domain}dbm{/etc/routes}}
16535 .endd
16536 If the expansion is forced to fail, or the result is an empty string, the
16537 router declines. Other kinds of expansion failure cause delivery to be
16538 deferred.
16539
16540
16541 .option route_list manualroute " "string list" " semicolon-separated""
16542 This string is a list of routing rules, in the form defined below. Note that,
16543 unlike most string lists, the items are separated by semicolons. This is so
16544 that they may contain colon-separated host lists.
16545
16546
16547 .option same_domain_copy_routing manualroute boolean false
16548 .cindex "address" "copying routing"
16549 Addresses with the same domain are normally routed by the &(manualroute)&
16550 router to the same list of hosts. However, this cannot be presumed, because the
16551 router options and preconditions may refer to the local part of the address. By
16552 default, therefore, Exim routes each address in a message independently. DNS
16553 servers run caches, so repeated DNS lookups are not normally expensive, and in
16554 any case, personal messages rarely have more than a few recipients.
16555
16556 If you are running mailing lists with large numbers of subscribers at the same
16557 domain, and you are using a &(manualroute)& router which is independent of the
16558 local part, you can set &%same_domain_copy_routing%& to bypass repeated DNS
16559 lookups for identical domains in one message. In this case, when
16560 &(manualroute)& routes an address to a remote transport, any other unrouted
16561 addresses in the message that have the same domain are automatically given the
16562 same routing without processing them independently. However, this is only done
16563 if &%headers_add%& and &%headers_remove%& are unset.
16564
16565
16566
16567
16568 .section "Routing rules in route_list"
16569 The value of &%route_list%& is a string consisting of a sequence of routing
16570 rules, separated by semicolons. If a semicolon is needed in a rule, it can be
16571 entered as two semicolons. Alternatively, the list separator can be changed as
16572 described (for colon-separated lists) in section &<<SECTlistconstruct>>&.
16573 Empty rules are ignored. The format of each rule is
16574 .display
16575 <&'domain pattern'&>  <&'list of hosts'&>  <&'options'&>
16576 .endd
16577 The following example contains two rules, each with a simple domain pattern and
16578 no options:
16579 .code
16580 route_list = \
16581   dict.ref.example  mail-1.ref.example:mail-2.ref.example ; \
16582   thes.ref.example  mail-3.ref.example:mail-4.ref.example
16583 .endd
16584 The three parts of a rule are separated by white space. The pattern and the
16585 list of hosts can be enclosed in quotes if necessary, and if they are, the
16586 usual quoting rules apply. Each rule in a &%route_list%& must start with a
16587 single domain pattern, which is the only mandatory item in the rule. The
16588 pattern is in the same format as one item in a domain list (see section
16589 &<<SECTdomainlist>>&),
16590 except that it may not be the name of an interpolated file.
16591 That is, it may be wildcarded, or a regular expression, or a file or database
16592 lookup (with semicolons doubled, because of the use of semicolon as a separator
16593 in a &%route_list%&).
16594
16595 The rules in &%route_list%& are searched in order until one of the patterns
16596 matches the domain that is being routed. The list of hosts and then options are
16597 then used as described below. If there is no match, the router declines. When
16598 &%route_list%& is set, &%route_data%& must not be set.
16599
16600
16601
16602 .section "Routing rules in route_data"
16603 The use of &%route_list%& is convenient when there are only a small number of
16604 routing rules. For larger numbers, it is easier to use a file or database to
16605 hold the routing information, and use the &%route_data%& option instead.
16606 The value of &%route_data%& is a list of hosts, followed by (optional) options.
16607 Most commonly, &%route_data%& is set as a string that contains an
16608 expansion lookup. For example, suppose we place two routing rules in a file
16609 like this:
16610 .code
16611 dict.ref.example:  mail-1.ref.example:mail-2.ref.example
16612 thes.ref.example:  mail-3.ref.example:mail-4.ref.example
16613 .endd
16614 This data can be accessed by setting
16615 .code
16616 route_data = ${lookup{$domain}lsearch{/the/file/name}}
16617 .endd
16618 Failure of the lookup results in an empty string, causing the router to
16619 decline. However, you do not have to use a lookup in &%route_data%&. The only
16620 requirement is that the result of expanding the string is a list of hosts,
16621 possibly followed by options, separated by white space. The list of hosts must
16622 be enclosed in quotes if it contains white space.
16623
16624
16625
16626
16627 .section "Format of the list of hosts"
16628 A list of hosts, whether obtained via &%route_data%& or &%route_list%&, is
16629 always separately expanded before use. If the expansion fails, the router
16630 declines. The result of the expansion must be a colon-separated list of names
16631 and/or IP addresses, optionally also including ports. The format of each item
16632 in the list is described in the next section. The list separator can be changed
16633 as described in section &<<SECTlistconstruct>>&.
16634
16635 If the list of hosts was obtained from a &%route_list%& item, the following
16636 variables are set during its expansion:
16637
16638 .ilist
16639 .cindex "numerical variables (&$1$& &$2$&  etc)" "in &(manualroute)& router"
16640 If the domain was matched against a regular expression, the numeric variables
16641 &$1$&, &$2$&, etc. may be set. For example:
16642 .code
16643 route_list = ^domain(\d+)   host-$1.text.example
16644 .endd
16645 .next
16646 &$0$& is always set to the entire domain.
16647 .next
16648 &$1$& is also set when partial matching is done in a file lookup.
16649
16650 .next
16651 .cindex "&$value$&"
16652 If the pattern that matched the domain was a lookup item, the data that was
16653 looked up is available in the expansion variable &$value$&. For example:
16654 .code
16655 route_list = lsearch;;/some/file.routes  $value
16656 .endd
16657 .endlist
16658
16659 Note the doubling of the semicolon in the pattern that is necessary because
16660 semicolon is the default route list separator.
16661
16662
16663
16664 .section "Format of one host item" "SECTformatonehostitem"
16665 Each item in the list of hosts is either a host name or an IP address,
16666 optionally with an attached port number. When no port is given, an IP address
16667 is not enclosed in brackets. When a port is specified, it overrides the port
16668 specification on the transport. The port is separated from the name or address
16669 by a colon. This leads to some complications:
16670
16671 .ilist
16672 Because colon is the default separator for the list of hosts, either
16673 the colon that specifies a port must be doubled, or the list separator must
16674 be changed. The following two examples have the same effect:
16675 .code
16676 route_list = * "host1.tld::1225 : host2.tld::1226"
16677 route_list = * "<+ host1.tld:1225 + host2.tld:1226"
16678 .endd
16679 .next
16680 When IPv6 addresses are involved, it gets worse, because they contain
16681 colons of their own. To make this case easier, it is permitted to
16682 enclose an IP address (either v4 or v6) in square brackets if a port
16683 number follows. For example:
16684 .code
16685 route_list = * "</ [10.1.1.1]:1225 / [::1]:1226"
16686 .endd
16687 .endlist
16688
16689 .section "How the list of hosts is used" "SECThostshowused"
16690 When an address is routed to an &(smtp)& transport by &(manualroute)&, each of
16691 the hosts is tried, in the order specified, when carrying out the SMTP
16692 delivery. However, the order can be changed by setting the &%hosts_randomize%&
16693 option, either on the router (see section &<<SECTprioptman>>& above), or on the
16694 transport.
16695
16696 Hosts may be listed by name or by IP address. An unadorned name in the list of
16697 hosts is interpreted as a host name. A name that is followed by &`/MX`& is
16698 interpreted as an indirection to a sublist of hosts obtained by looking up MX
16699 records in the DNS. For example:
16700 .code
16701 route_list = *  x.y.z:p.q.r/MX:e.f.g
16702 .endd
16703 If this feature is used with a port specifier, the port must come last. For
16704 example:
16705 .code
16706 route_list = *  dom1.tld/mx::1225
16707 .endd
16708 If the &%hosts_randomize%& option is set, the order of the items in the list is
16709 randomized before any lookups are done. Exim then scans the list; for any name
16710 that is not followed by &`/MX`& it looks up an IP address. If this turns out to
16711 be an interface on the local host and the item is not the first in the list,
16712 Exim discards it and any subsequent items. If it is the first item, what
16713 happens is controlled by the
16714 .cindex "&%self%& option" "in &(manualroute)& router"
16715 &%self%& option of the router.
16716
16717 A name on the list that is followed by &`/MX`& is replaced with the list of
16718 hosts obtained by looking up MX records for the name. This is always a DNS
16719 lookup; the &%bydns%& and &%byname%& options (see section &<<SECThowoptused>>&
16720 below) are not relevant here. The order of these hosts is determined by the
16721 preference values in the MX records, according to the usual rules. Because
16722 randomizing happens before the MX lookup, it does not affect the order that is
16723 defined by MX preferences.
16724
16725 If the local host is present in the sublist obtained from MX records, but is
16726 not the most preferred host in that list, it and any equally or less
16727 preferred hosts are removed before the sublist is inserted into the main list.
16728
16729 If the local host is the most preferred host in the MX list, what happens
16730 depends on where in the original list of hosts the &`/MX`& item appears. If it
16731 is not the first item (that is, there are previous hosts in the main list),
16732 Exim discards this name and any subsequent items in the main list.
16733
16734 If the MX item is first in the list of hosts, and the local host is the
16735 most preferred host, what happens is controlled by the &%self%& option of the
16736 router.
16737
16738 DNS failures when lookup up the MX records are treated in the same way as DNS
16739 failures when looking up IP addresses: &%pass_on_timeout%& and
16740 &%host_find_failed%& are used when relevant.
16741
16742 The generic &%ignore_target_hosts%& option applies to all hosts in the list,
16743 whether obtained from an MX lookup or not.
16744
16745
16746
16747 .section "How the options are used" "SECThowoptused"
16748 The options are a sequence of words; in practice no more than three are ever
16749 present. One of the words can be the name of a transport; this overrides the
16750 &%transport%& option on the router for this particular routing rule only. The
16751 other words (if present) control randomization of the list of hosts on a
16752 per-rule basis, and how the IP addresses of the hosts are to be found when
16753 routing to a remote transport. These options are as follows:
16754
16755 .ilist
16756 &%randomize%&: randomize the order of the hosts in this list, overriding the
16757 setting of &%hosts_randomize%& for this routing rule only.
16758 .next
16759 &%no_randomize%&: do not randomize the order of the hosts in this list,
16760 overriding the setting of &%hosts_randomize%& for this routing rule only.
16761 .next
16762 &%byname%&: use &[getipnodebyname()]& (&[gethostbyname()]& on older systems) to
16763 find IP addresses. This function may ultimately cause a DNS lookup, but it may
16764 also look in &_/etc/hosts_& or other sources of information.
16765 .next
16766 &%bydns%&: look up address records for the hosts directly in the DNS; fail if
16767 no address records are found. If there is a temporary DNS error (such as a
16768 timeout), delivery is deferred.
16769 .endlist
16770
16771 For example:
16772 .code
16773 route_list = domain1  host1:host2:host3  randomize bydns;\
16774              domain2  host4:host5
16775 .endd
16776 If neither &%byname%& nor &%bydns%& is given, Exim behaves as follows: First, a
16777 DNS lookup is done. If this yields anything other than HOST_NOT_FOUND, that
16778 result is used. Otherwise, Exim goes on to try a call to &[getipnodebyname()]&
16779 or &[gethostbyname()]&, and the result of the lookup is the result of that
16780 call.
16781
16782 &*Warning*&: It has been discovered that on some systems, if a DNS lookup
16783 called via &[getipnodebyname()]& times out, HOST_NOT_FOUND is returned
16784 instead of TRY_AGAIN. That is why the default action is to try a DNS
16785 lookup first. Only if that gives a definite &"no such host"& is the local
16786 function called.
16787
16788
16789
16790 If no IP address for a host can be found, what happens is controlled by the
16791 &%host_find_failed%& option.
16792
16793 .cindex "&$host$&"
16794 When an address is routed to a local transport, IP addresses are not looked up.
16795 The host list is passed to the transport in the &$host$& variable.
16796
16797
16798
16799 .section "Manualroute examples"
16800 In some of the examples that follow, the presence of the &%remote_smtp%&
16801 transport, as defined in the default configuration file, is assumed:
16802
16803 .ilist
16804 .cindex "smart host" "example router"
16805 The &(manualroute)& router can be used to forward all external mail to a
16806 &'smart host'&. If you have set up, in the main part of the configuration, a
16807 named domain list that contains your local domains, for example:
16808 .code
16809 domainlist local_domains = my.domain.example
16810 .endd
16811 You can arrange for all other domains to be routed to a smart host by making
16812 your first router something like this:
16813 .code
16814 smart_route:
16815   driver = manualroute
16816   domains = !+local_domains
16817   transport = remote_smtp
16818   route_list = * smarthost.ref.example
16819 .endd
16820 This causes all non-local addresses to be sent to the single host
16821 &'smarthost.ref.example'&. If a colon-separated list of smart hosts is given,
16822 they are tried in order
16823 (but you can use &%hosts_randomize%& to vary the order each time).
16824 Another way of configuring the same thing is this:
16825 .code
16826 smart_route:
16827   driver = manualroute
16828   transport = remote_smtp
16829   route_list = !+local_domains  smarthost.ref.example
16830 .endd
16831 There is no difference in behaviour between these two routers as they stand.
16832 However, they behave differently if &%no_more%& is added to them. In the first
16833 example, the router is skipped if the domain does not match the &%domains%&
16834 precondition; the following router is always tried. If the router runs, it
16835 always matches the domain and so can never decline. Therefore, &%no_more%&
16836 would have no effect. In the second case, the router is never skipped; it
16837 always runs. However, if it doesn't match the domain, it declines. In this case
16838 &%no_more%& would prevent subsequent routers from running.
16839
16840 .next
16841 .cindex "mail hub example"
16842 A &'mail hub'& is a host which receives mail for a number of domains via MX
16843 records in the DNS and delivers it via its own private routing mechanism. Often
16844 the final destinations are behind a firewall, with the mail hub being the one
16845 machine that can connect to machines both inside and outside the firewall. The
16846 &(manualroute)& router is usually used on a mail hub to route incoming messages
16847 to the correct hosts. For a small number of domains, the routing can be inline,
16848 using the &%route_list%& option, but for a larger number a file or database
16849 lookup is easier to manage.
16850
16851 If the domain names are in fact the names of the machines to which the mail is
16852 to be sent by the mail hub, the configuration can be quite simple. For
16853 example:
16854 .code
16855 hub_route:
16856   driver = manualroute
16857   transport = remote_smtp
16858   route_list = *.rhodes.tvs.example  $domain
16859 .endd
16860 This configuration routes domains that match &`*.rhodes.tvs.example`& to hosts
16861 whose names are the same as the mail domains. A similar approach can be taken
16862 if the host name can be obtained from the domain name by a string manipulation
16863 that the expansion facilities can handle. Otherwise, a lookup based on the
16864 domain can be used to find the host:
16865 .code
16866 through_firewall:
16867   driver = manualroute
16868   transport = remote_smtp
16869   route_data = ${lookup {$domain} cdb {/internal/host/routes}}
16870 .endd
16871 The result of the lookup must be the name or IP address of the host (or
16872 hosts) to which the address is to be routed. If the lookup fails, the route
16873 data is empty, causing the router to decline. The address then passes to the
16874 next router.
16875
16876 .next
16877 .cindex "batched SMTP output example"
16878 .cindex "SMTP" "batched outgoing; example"
16879 You can use &(manualroute)& to deliver messages to pipes or files in batched
16880 SMTP format for onward transportation by some other means. This is one way of
16881 storing mail for a dial-up host when it is not connected. The route list entry
16882 can be as simple as a single domain name in a configuration like this:
16883 .code
16884 save_in_file:
16885   driver = manualroute
16886   transport = batchsmtp_appendfile
16887   route_list = saved.domain.example
16888 .endd
16889 though often a pattern is used to pick up more than one domain. If there are
16890 several domains or groups of domains with different transport requirements,
16891 different transports can be listed in the routing information:
16892 .code
16893 save_in_file:
16894   driver = manualroute
16895   route_list = \
16896     *.saved.domain1.example  $domain  batch_appendfile; \
16897     *.saved.domain2.example  \
16898       ${lookup{$domain}dbm{/domain2/hosts}{$value}fail} \
16899       batch_pipe
16900 .endd
16901 .cindex "&$domain$&"
16902 .cindex "&$host$&"
16903 The first of these just passes the domain in the &$host$& variable, which
16904 doesn't achieve much (since it is also in &$domain$&), but the second does a
16905 file lookup to find a value to pass, causing the router to decline to handle
16906 the address if the lookup fails.
16907
16908 .next
16909 .cindex "UUCP" "example of router for"
16910 Routing mail directly to UUCP software is a specific case of the use of
16911 &(manualroute)& in a gateway to another mail environment. This is an example of
16912 one way it can be done:
16913 .code
16914 # Transport
16915 uucp:
16916   driver = pipe
16917   user = nobody
16918   command = /usr/local/bin/uux -r - \
16919     ${substr_-5:$host}!rmail ${local_part}
16920   return_fail_output = true
16921
16922 # Router
16923 uucphost:
16924   transport = uucp
16925   driver = manualroute
16926   route_data = \
16927     ${lookup{$domain}lsearch{/usr/local/exim/uucphosts}}
16928 .endd
16929 The file &_/usr/local/exim/uucphosts_& contains entries like
16930 .code
16931 darksite.ethereal.example:           darksite.UUCP
16932 .endd
16933 It can be set up more simply without adding and removing &".UUCP"& but this way
16934 makes clear the distinction between the domain name
16935 &'darksite.ethereal.example'& and the UUCP host name &'darksite'&.
16936 .endlist
16937 .ecindex IIDmanrou1
16938 .ecindex IIDmanrou2
16939
16940
16941
16942
16943
16944
16945
16946
16947 . ////////////////////////////////////////////////////////////////////////////
16948 . ////////////////////////////////////////////////////////////////////////////
16949
16950 .chapter "The queryprogram router" "CHAPdriverlast"
16951 .scindex IIDquerou1 "&(queryprogram)& router"
16952 .scindex IIDquerou2 "routers" "&(queryprogram)&"
16953 .cindex "routing" "by external program"
16954 The &(queryprogram)& router routes an address by running an external command
16955 and acting on its output. This is an expensive way to route, and is intended
16956 mainly for use in lightly-loaded systems, or for performing experiments.
16957 However, if it is possible to use the precondition options (&%domains%&,
16958 &%local_parts%&, etc) to skip this router for most addresses, it could sensibly
16959 be used in special cases, even on a busy host. There are the following private
16960 options:
16961 .cindex "options" "&(queryprogram)& router"
16962
16963 .option command queryprogram string&!! unset
16964 This option must be set. It specifies the command that is to be run. The
16965 command is split up into a command name and arguments, and then each is
16966 expanded separately (exactly as for a &(pipe)& transport, described in chapter
16967 &<<CHAPpipetransport>>&).
16968
16969
16970 .option command_group queryprogram string unset
16971 .cindex "gid (group id)" "in &(queryprogram)& router"
16972 This option specifies a gid to be set when running the command while routing an
16973 address for deliver. It must be set if &%command_user%& specifies a numerical
16974 uid. If it begins with a digit, it is interpreted as the numerical value of the
16975 gid. Otherwise it is looked up using &[getgrnam()]&.
16976
16977
16978 .option command_user queryprogram string unset
16979 .cindex "uid (user id)" "for &(queryprogram)&"
16980 This option must be set. It specifies the uid which is set when running the
16981 command while routing an address for delivery. If the value begins with a digit,
16982 it is interpreted as the numerical value of the uid. Otherwise, it is looked up
16983 using &[getpwnam()]& to obtain a value for the uid and, if &%command_group%& is
16984 not set, a value for the gid also.
16985
16986 &*Warning:*& Changing uid and gid is possible only when Exim is running as
16987 root, which it does during a normal delivery in a conventional configuration.
16988 However, when an address is being verified during message reception, Exim is
16989 usually running as the Exim user, not as root. If the &(queryprogram)& router
16990 is called from a non-root process, Exim cannot change uid or gid before running
16991 the command. In this circumstance the command runs under the current uid and
16992 gid.
16993
16994
16995 .option current_directory queryprogram string /
16996 This option specifies an absolute path which is made the current directory
16997 before running the command.
16998
16999
17000 .option timeout queryprogram time 1h
17001 If the command does not complete within the timeout period, its process group
17002 is killed and the message is frozen. A value of zero time specifies no
17003 timeout.
17004
17005
17006 The standard output of the command is connected to a pipe, which is read when
17007 the command terminates. It should consist of a single line of output,
17008 containing up to five fields, separated by white space. The maximum length of
17009 the line is 1023 characters. Longer lines are silently truncated. The first
17010 field is one of the following words (case-insensitive):
17011
17012 .ilist
17013 &'Accept'&: routing succeeded; the remaining fields specify what to do (see
17014 below).
17015 .next
17016 &'Decline'&: the router declines; pass the address to the next router, unless
17017 &%no_more%& is set.
17018 .next
17019 &'Fail'&: routing failed; do not pass the address to any more routers. Any
17020 subsequent text on the line is an error message. If the router is run as part
17021 of address verification during an incoming SMTP message, the message is
17022 included in the SMTP response.
17023 .next
17024 &'Defer'&: routing could not be completed at this time; try again later. Any
17025 subsequent text on the line is an error message which is logged. It is not
17026 included in any SMTP response.
17027 .next
17028 &'Freeze'&: the same as &'defer'&, except that the message is frozen.
17029 .next
17030 &'Pass'&: pass the address to the next router (or the router specified by
17031 &%pass_router%&), overriding &%no_more%&.
17032 .next
17033 &'Redirect'&: the message is redirected. The remainder of the line is a list of
17034 new addresses, which are routed independently, starting with the first router,
17035 or the router specified by &%redirect_router%&, if set.
17036 .endlist
17037
17038 When the first word is &'accept'&, the remainder of the line consists of a
17039 number of keyed data values, as follows (split into two lines here, to fit on
17040 the page):
17041 .code
17042 ACCEPT TRANSPORT=<transport> HOSTS=<list of hosts>
17043 LOOKUP=byname|bydns DATA=<text>
17044 .endd
17045 The data items can be given in any order, and all are optional. If no transport
17046 is included, the transport specified by the generic &%transport%& option is
17047 used. The list of hosts and the lookup type are needed only if the transport is
17048 an &(smtp)& transport that does not itself supply a list of hosts.
17049
17050 The format of the list of hosts is the same as for the &(manualroute)& router.
17051 As well as host names and IP addresses with optional port numbers, as described
17052 in section &<<SECTformatonehostitem>>&, it may contain names followed by
17053 &`/MX`& to specify sublists of hosts that are obtained by looking up MX records
17054 (see section &<<SECThostshowused>>&).
17055
17056 If the lookup type is not specified, Exim behaves as follows when trying to
17057 find an IP address for each host: First, a DNS lookup is done. If this yields
17058 anything other than HOST_NOT_FOUND, that result is used. Otherwise, Exim
17059 goes on to try a call to &[getipnodebyname()]& or &[gethostbyname()]&, and the
17060 result of the lookup is the result of that call.
17061
17062 .cindex "&$address_data$&"
17063 If the DATA field is set, its value is placed in the &$address_data$&
17064 variable. For example, this return line
17065 .code
17066 accept hosts=x1.y.example:x2.y.example data="rule1"
17067 .endd
17068 routes the address to the default transport, passing a list of two hosts. When
17069 the transport runs, the string &"rule1"& is in &$address_data$&.
17070 .ecindex IIDquerou1
17071 .ecindex IIDquerou2
17072
17073
17074
17075
17076 . ////////////////////////////////////////////////////////////////////////////
17077 . ////////////////////////////////////////////////////////////////////////////
17078
17079 .chapter "The redirect router" "CHAPredirect"
17080 .scindex IIDredrou1 "&(redirect)& router"
17081 .scindex IIDredrou2 "routers" "&(redirect)&"
17082 .cindex "alias file" "in a &(redirect)& router"
17083 .cindex "address redirection" "&(redirect)& router"
17084 The &(redirect)& router handles several kinds of address redirection. Its most
17085 common uses are for resolving local part aliases from a central alias file
17086 (usually called &_/etc/aliases_&) and for handling users' personal &_.forward_&
17087 files, but it has many other potential uses. The incoming address can be
17088 redirected in several different ways:
17089
17090 .ilist
17091 It can be replaced by one or more new addresses which are themselves routed
17092 independently.
17093 .next
17094 It can be routed to be delivered to a given file or directory.
17095 .next
17096 It can be routed to be delivered to a specified pipe command.
17097 .next
17098 It can cause an automatic reply to be generated.
17099 .next
17100 It can be forced to fail, with a custom error message.
17101 .next
17102 It can be temporarily deferred.
17103 .next
17104 It can be discarded.
17105 .endlist
17106
17107 The generic &%transport%& option must not be set for &(redirect)& routers.
17108 However, there are some private options which define transports for delivery to
17109 files and pipes, and for generating autoreplies. See the &%file_transport%&,
17110 &%pipe_transport%& and &%reply_transport%& descriptions below.
17111
17112
17113
17114 .section "Redirection data"
17115 The router operates by interpreting a text string which it obtains either by
17116 expanding the contents of the &%data%& option, or by reading the entire
17117 contents of a file whose name is given in the &%file%& option. These two
17118 options are mutually exclusive. The first is commonly used for handling system
17119 aliases, in a configuration like this:
17120 .code
17121 system_aliases:
17122   driver = redirect
17123   data = ${lookup{$local_part}lsearch{/etc/aliases}}
17124 .endd
17125 If the lookup fails, the expanded string in this example is empty. When the
17126 expansion of &%data%& results in an empty string, the router declines. A forced
17127 expansion failure also causes the router to decline; other expansion failures
17128 cause delivery to be deferred.
17129
17130 A configuration using &%file%& is commonly used for handling users'
17131 &_.forward_& files, like this:
17132 .code
17133 userforward:
17134   driver = redirect
17135   check_local_user
17136   file = $home/.forward
17137   no_verify
17138 .endd
17139 If the file does not exist, or causes no action to be taken (for example, it is
17140 empty or consists only of comments), the router declines. &*Warning*&: This
17141 is not the case when the file contains syntactically valid items that happen to
17142 yield empty addresses, for example, items containing only RFC 2822 address
17143 comments.
17144
17145
17146
17147 .section "Forward files and address verification"
17148 .cindex "address redirection" "while verifying"
17149 It is usual to set &%no_verify%& on &(redirect)& routers which handle users'
17150 &_.forward_& files, as in the example above. There are two reasons for this:
17151
17152 .ilist
17153 When Exim is receiving an incoming SMTP message from a remote host, it is
17154 running under the Exim uid, not as root. Exim is unable to change uid to read
17155 the file as the user, and it may not be able to read it as the Exim user. So in
17156 practice the router may not be able to operate.
17157 .next
17158 However, even when the router can operate, the existence of a &_.forward_& file
17159 is unimportant when verifying an address. What should be checked is whether the
17160 local part is a valid user name or not. Cutting out the redirection processing
17161 saves some resources.
17162 .endlist
17163
17164
17165
17166
17167
17168
17169 .section "Interpreting redirection data"
17170 .cindex "Sieve filter" "specifying in redirection data"
17171 .cindex "filter" "specifying in redirection data"
17172 The contents of the data string, whether obtained from &%data%& or &%file%&,
17173 can be interpreted in two different ways:
17174
17175 .ilist
17176 If the &%allow_filter%& option is set true, and the data begins with the text
17177 &"#Exim filter"& or &"#Sieve filter"&, it is interpreted as a list of
17178 &'filtering'& instructions in the form of an Exim or Sieve filter file,
17179 respectively. Details of the syntax and semantics of filter files are described
17180 in a separate document entitled &'Exim's interfaces to mail filtering'&; this
17181 document is intended for use by end users.
17182 .next
17183 Otherwise, the data must be a comma-separated list of redirection items, as
17184 described in the next section.
17185 .endlist
17186
17187 When a message is redirected to a file (a &"mail folder"&), the file name given
17188 in a non-filter redirection list must always be an absolute path. A filter may
17189 generate a relative path &-- how this is handled depends on the transport's
17190 configuration. See section &<<SECTfildiropt>>& for a discussion of this issue
17191 for the &(appendfile)& transport.
17192
17193
17194
17195 .section "Items in a non-filter redirection list" "SECTitenonfilred"
17196 .cindex "address redirection" "non-filter list items"
17197 When the redirection data is not an Exim or Sieve filter, for example, if it
17198 comes from a conventional alias or forward file, it consists of a list of
17199 addresses, file names, pipe commands, or certain special items (see section
17200 &<<SECTspecitredli>>& below). The special items can be individually enabled or
17201 disabled by means of options whose names begin with &%allow_%& or &%forbid_%&,
17202 depending on their default values. The items in the list are separated by
17203 commas or newlines.
17204 If a comma is required in an item, the entire item must be enclosed in double
17205 quotes.
17206
17207 Lines starting with a # character are comments, and are ignored, and # may
17208 also appear following a comma, in which case everything between the # and the
17209 next newline character is ignored.
17210
17211 If an item is entirely enclosed in double quotes, these are removed. Otherwise
17212 double quotes are retained because some forms of mail address require their use
17213 (but never to enclose the entire address). In the following description,
17214 &"item"& refers to what remains after any surrounding double quotes have been
17215 removed.
17216
17217 .cindex "&$local_part$&"
17218 &*Warning*&: If you use an Exim expansion to construct a redirection address,
17219 and the expansion contains a reference to &$local_part$&, you should make use
17220 of the &%quote_local_part%& expansion operator, in case the local part contains
17221 special characters. For example, to redirect all mail for the domain
17222 &'obsolete.example'&, retaining the existing local part, you could use this
17223 setting:
17224 .code
17225 data = ${quote_local_part:$local_part}@newdomain.example
17226 .endd
17227
17228
17229 .section "Redirecting to a local mailbox" "SECTredlocmai"
17230 .cindex "routing" "loops in"
17231 .cindex "loop while routing" "avoidance of"
17232 .cindex "address redirection" "to local mailbox"
17233 A redirection item may safely be the same as the address currently under
17234 consideration. This does not cause a routing loop, because a router is
17235 automatically skipped if any ancestor of the address that is being processed
17236 is the same as the current address and was processed by the current router.
17237 Such an address is therefore passed to the following routers, so it is handled
17238 as if there were no redirection. When making this loop-avoidance test, the
17239 complete local part, including any prefix or suffix, is used.
17240
17241 .cindex "address redirection" "local part without domain"
17242 Specifying the same local part without a domain is a common usage in personal
17243 filter files when the user wants to have messages delivered to the local
17244 mailbox and also forwarded elsewhere. For example, the user whose login is
17245 &'cleo'& might have a &_.forward_& file containing this:
17246 .code
17247 cleo, cleopatra@egypt.example
17248 .endd
17249 .cindex "backslash in alias file"
17250 .cindex "alias file" "backslash in"
17251 For compatibility with other MTAs, such unqualified local parts may be
17252 preceeded by &"\"&, but this is not a requirement for loop prevention. However,
17253 it does make a difference if more than one domain is being handled
17254 synonymously.
17255
17256 If an item begins with &"\"& and the rest of the item parses as a valid RFC
17257 2822 address that does not include a domain, the item is qualified using the
17258 domain of the incoming address. In the absence of a leading &"\"&, unqualified
17259 addresses are qualified using the value in &%qualify_recipient%&, but you can
17260 force the incoming domain to be used by setting &%qualify_preserve_domain%&.
17261
17262 Care must be taken if there are alias names for local users.
17263 Consider an MTA handling a single local domain where the system alias file
17264 contains:
17265 .code
17266 Sam.Reman: spqr
17267 .endd
17268 Now suppose that Sam (whose login id is &'spqr'&) wants to save copies of
17269 messages in the local mailbox, and also forward copies elsewhere. He creates
17270 this forward file:
17271 .code
17272 Sam.Reman, spqr@reme.elsewhere.example
17273 .endd
17274 With these settings, an incoming message addressed to &'Sam.Reman'& fails. The
17275 &(redirect)& router for system aliases does not process &'Sam.Reman'& the
17276 second time round, because it has previously routed it,
17277 and the following routers presumably cannot handle the alias. The forward file
17278 should really contain
17279 .code
17280 spqr, spqr@reme.elsewhere.example
17281 .endd
17282 but because this is such a common error, the &%check_ancestor%& option (see
17283 below) exists to provide a way to get round it. This is normally set on a
17284 &(redirect)& router that is handling users' &_.forward_& files.
17285
17286
17287
17288 .section "Special items in redirection lists" "SECTspecitredli"
17289 In addition to addresses, the following types of item may appear in redirection
17290 lists (that is, in non-filter redirection data):
17291
17292 .ilist
17293 .cindex "pipe" "in redirection list"
17294 .cindex "address redirection" "to pipe"
17295 An item is treated as a pipe command if it begins with &"|"& and does not parse
17296 as a valid RFC 2822 address that includes a domain. A transport for running the
17297 command must be specified by the &%pipe_transport%& option.
17298 Normally, either the router or the transport specifies a user and a group under
17299 which to run the delivery. The default is to use the Exim user and group.
17300
17301 Single or double quotes can be used for enclosing the individual arguments of
17302 the pipe command; no interpretation of escapes is done for single quotes. If
17303 the command contains a comma character, it is necessary to put the whole item
17304 in double quotes, for example:
17305 .code
17306 "|/some/command ready,steady,go"
17307 .endd
17308 since items in redirection lists are terminated by commas. Do not, however,
17309 quote just the command. An item such as
17310 .code
17311 |"/some/command ready,steady,go"
17312 .endd
17313 is interpreted as a pipe with a rather strange command name, and no arguments.
17314
17315 .next
17316 .cindex "file" "in redirection list"
17317 .cindex "address redirection" "to file"
17318 An item is interpreted as a path name if it begins with &"/"& and does not
17319 parse as a valid RFC 2822 address that includes a domain. For example,
17320 .code
17321 /home/world/minbari
17322 .endd
17323 is treated as a file name, but
17324 .code
17325 /s=molari/o=babylon/@x400gate.way
17326 .endd
17327 is treated as an address. For a file name, a transport must be specified using
17328 the &%file_transport%& option. However, if the generated path name ends with a
17329 forward slash character, it is interpreted as a directory name rather than a
17330 file name, and &%directory_transport%& is used instead.
17331
17332 Normally, either the router or the transport specifies a user and a group under
17333 which to run the delivery. The default is to use the Exim user and group.
17334
17335 .cindex "&_/dev/null_&"
17336 However, if a redirection item is the path &_/dev/null_&, delivery to it is
17337 bypassed at a high level, and the log entry shows &"**bypassed**"&
17338 instead of a transport name. In this case the user and group are not used.
17339
17340 .next
17341 .cindex "included address list"
17342 .cindex "address redirection" "included external list"
17343 If an item is of the form
17344 .code
17345 :include:<path name>
17346 .endd
17347 a list of further items is taken from the given file and included at that
17348 point. &*Note*&: Such a file can not be a filter file; it is just an
17349 out-of-line addition to the list. The items in the included list are separated
17350 by commas or newlines and are not subject to expansion. If this is the first
17351 item in an alias list in an &(lsearch)& file, a colon must be used to terminate
17352 the alias name. This example is incorrect:
17353 .code
17354 list1    :include:/opt/lists/list1
17355 .endd
17356 It must be given as
17357 .code
17358 list1:   :include:/opt/lists/list1
17359 .endd
17360 .next
17361 .cindex "address redirection" "to black hole"
17362 Sometimes you want to throw away mail to a particular local part. Making the
17363 &%data%& option expand to an empty string does not work, because that causes
17364 the router to decline. Instead, the alias item
17365 .cindex "black hole"
17366 .cindex "abandoning mail"
17367 .code
17368 :blackhole:
17369 .endd
17370 can be used. It does what its name implies. No delivery is done, and no error
17371 message is generated. This has the same effect as specifing &_/dev/null_&, but
17372 can be independently disabled.
17373
17374 &*Warning*&: If &`:blackhole:`& appears anywhere in a redirection list, no
17375 delivery is done for the original local part, even if other redirection items
17376 are present. If you are generating a multi-item list (for example, by reading a
17377 database) and need the ability to provide a no-op item, you must use
17378 &_/dev/null_&.
17379
17380 .next
17381 .cindex "delivery" "forcing failure"
17382 .cindex "delivery" "forcing deferral"
17383 .cindex "failing delivery" "forcing"
17384 .cindex "deferred delivery" "forcing"
17385 .cindex "customizing" "failure message"
17386 An attempt to deliver a particular address can be deferred or forced to fail by
17387 redirection items of the form
17388 .code
17389 :defer:
17390 :fail:
17391 .endd
17392 respectively. When a redirection list contains such an item, it applies to the
17393 entire redirection; any other items in the list are ignored (&':blackhole:'& is
17394 different). Any text following &':fail:'& or &':defer:'& is placed in the error
17395 text associated with the failure. For example, an alias file might contain:
17396 .code
17397 X.Employee:  :fail: Gone away, no forwarding address
17398 .endd
17399 In the case of an address that is being verified from an ACL or as the subject
17400 of a
17401 .cindex "VRFY error text" "display of"
17402 VRFY command, the text is included in the SMTP error response by
17403 default.
17404 .cindex "EXPN error text" "display of"
17405 The text is not included in the response to an EXPN command. In non-SMTP cases
17406 the text is included in the error message that Exim generates.
17407
17408 .cindex "SMTP" "error codes"
17409 By default, Exim sends a 451 SMTP code for a &':defer:'&, and 550 for
17410 &':fail:'&. However, if the message starts with three digits followed by a
17411 space, optionally followed by an extended code of the form &'n.n.n'&, also
17412 followed by a space, and the very first digit is the same as the default error
17413 code, the code from the message is used instead. If the very first digit is
17414 incorrect, a panic error is logged, and the default code is used. You can
17415 suppress the use of the supplied code in a redirect router by setting the
17416 &%forbid_smtp_code%& option true. In this case, any SMTP code is quietly
17417 ignored.
17418
17419 .cindex "&$acl_verify_message$&"
17420 In an ACL, an explicitly provided message overrides the default, but the
17421 default message is available in the variable &$acl_verify_message$& and can
17422 therefore be included in a custom message if this is desired.
17423
17424 Normally the error text is the rest of the redirection list &-- a comma does
17425 not terminate it &-- but a newline does act as a terminator. Newlines are not
17426 normally present in alias expansions. In &(lsearch)& lookups they are removed
17427 as part of the continuation process, but they may exist in other kinds of
17428 lookup and in &':include:'& files.
17429
17430 During routing for message delivery (as opposed to verification), a redirection
17431 containing &':fail:'& causes an immediate failure of the incoming address,
17432 whereas &':defer:'& causes the message to remain on the queue so that a
17433 subsequent delivery attempt can happen at a later time. If an address is
17434 deferred for too long, it will ultimately fail, because the normal retry
17435 rules still apply.
17436
17437 .next
17438 .cindex "alias file" "exception to default"
17439 Sometimes it is useful to use a single-key search type with a default (see
17440 chapter &<<CHAPfdlookup>>&) to look up aliases. However, there may be a need
17441 for exceptions to the default. These can be handled by aliasing them to
17442 .code
17443 :unknown:
17444 .endd
17445 This differs from &':fail:'& in that it causes the &(redirect)& router to
17446 decline, whereas &':fail:'& forces routing to fail. A lookup which results in
17447 an empty redirection list has the same effect.
17448 .endlist
17449
17450
17451 .section "Duplicate addresses"
17452 .cindex "duplicate addresses"
17453 .cindex "address duplicate" "discarding"
17454 .cindex "pipe" "duplicated"
17455 Exim removes duplicate addresses from the list to which it is delivering, so as
17456 to deliver just one copy to each address. This does not apply to deliveries
17457 routed to pipes by different immediate parent addresses, but an indirect
17458 aliasing scheme of the type
17459 .code
17460 pipe:       |/some/command $local_part
17461 localpart1: pipe
17462 localpart2: pipe
17463 .endd
17464 does not work with a message that is addressed to both local parts, because
17465 when the second is aliased to the intermediate local part &"pipe"& it gets
17466 discarded as being the same as a previously handled address. However, a scheme
17467 such as
17468 .code
17469 localpart1: |/some/command $local_part
17470 localpart2: |/some/command $local_part
17471 .endd
17472 does result in two different pipe deliveries, because the immediate parents of
17473 the pipes are distinct.
17474
17475
17476
17477 .section "Repeated redirection expansion"
17478 .cindex "repeated redirection expansion"
17479 .cindex "address redirection" "repeated for each delivery attempt"
17480 When a message cannot be delivered to all of its recipients immediately,
17481 leading to two or more delivery attempts, redirection expansion is carried out
17482 afresh each time for those addresses whose children were not all previously
17483 delivered. If redirection is being used as a mailing list, this can lead to new
17484 members of the list receiving copies of old messages. The &%one_time%& option
17485 can be used to avoid this.
17486
17487
17488 .section "Errors in redirection lists"
17489 .cindex "address redirection" "errors"
17490 If &%skip_syntax_errors%& is set, a malformed address that causes a parsing
17491 error is skipped, and an entry is written to the main log. This may be useful
17492 for mailing lists that are automatically managed. Otherwise, if an error is
17493 detected while generating the list of new addresses, the original address is
17494 deferred. See also &%syntax_errors_to%&.
17495
17496
17497
17498 .section "Private options for the redirect router"
17499
17500 .cindex "options" "&(redirect)& router"
17501 The private options for the &(redirect)& router are as follows:
17502
17503
17504 .option allow_defer redirect boolean false
17505 Setting this option allows the use of &':defer:'& in non-filter redirection
17506 data, or the &%defer%& command in an Exim filter file.
17507
17508
17509 .option allow_fail redirect boolean false
17510 .cindex "failing delivery" "from filter"
17511 If this option is true, the &':fail:'& item can be used in a redirection list,
17512 and the &%fail%& command may be used in an Exim filter file.
17513
17514
17515 .option allow_filter redirect boolean false
17516 .cindex "filter" "enabling use of"
17517 .cindex "Sieve filter" "enabling use of"
17518 Setting this option allows Exim to interpret redirection data that starts with
17519 &"#Exim filter"& or &"#Sieve filter"& as a set of filtering instructions. There
17520 are some features of Exim filter files that some administrators may wish to
17521 lock out; see the &%forbid_filter_%&&'xxx'& options below.
17522
17523 It is also possible to lock out Exim filters or Sieve filters while allowing
17524 the other type; see &%forbid_exim_filter%& and &%forbid_sieve_filter%&.
17525
17526
17527 The filter is run using the uid and gid set by the generic &%user%& and
17528 &%group%& options. These take their defaults from the password data if
17529 &%check_local_user%& is set, so in the normal case of users' personal filter
17530 files, the filter is run as the relevant user. When &%allow_filter%& is set
17531 true, Exim insists that either &%check_local_user%& or &%user%& is set.
17532
17533
17534
17535 .option allow_freeze redirect boolean false
17536 .cindex "freezing messages" "allowing in filter"
17537 Setting this option allows the use of the &%freeze%& command in an Exim filter.
17538 This command is more normally encountered in system filters, and is disabled by
17539 default for redirection filters because it isn't something you usually want to
17540 let ordinary users do.
17541
17542
17543
17544 .option check_ancestor redirect boolean false
17545 This option is concerned with handling generated addresses that are the same
17546 as some address in the list of redirection ancestors of the current address.
17547 Although it is turned off by default in the code, it is set in the default
17548 configuration file for handling users' &_.forward_& files. It is recommended
17549 for this use of the &(redirect)& router.
17550
17551 When &%check_ancestor%& is set, if a generated address (including the domain)
17552 is the same as any ancestor of the current address, it is replaced by a copy of
17553 the current address. This helps in the case where local part A is aliased to B,
17554 and B has a &_.forward_& file pointing back to A. For example, within a single
17555 domain, the local part &"Joe.Bloggs"& is aliased to &"jb"& and
17556 &_&~jb/.forward_& contains:
17557 .code
17558 \Joe.Bloggs, <other item(s)>
17559 .endd
17560 Without the &%check_ancestor%& setting, either local part (&"jb"& or
17561 &"joe.bloggs"&) gets processed once by each router and so ends up as it was
17562 originally. If &"jb"& is the real mailbox name, mail to &"jb"& gets delivered
17563 (having been turned into &"joe.bloggs"& by the &_.forward_& file and back to
17564 &"jb"& by the alias), but mail to &"joe.bloggs"& fails. Setting
17565 &%check_ancestor%& on the &(redirect)& router that handles the &_.forward_&
17566 file prevents it from turning &"jb"& back into &"joe.bloggs"& when that was the
17567 original address. See also the &%repeat_use%& option below.
17568
17569
17570 .option check_group redirect boolean "see below"
17571 When the &%file%& option is used, the group owner of the file is checked only
17572 when this option is set. The permitted groups are those listed in the
17573 &%owngroups%& option, together with the user's default group if
17574 &%check_local_user%& is set. If the file has the wrong group, routing is
17575 deferred. The default setting for this option is true if &%check_local_user%&
17576 is set and the &%modemask%& option permits the group write bit, or if the
17577 &%owngroups%& option is set. Otherwise it is false, and no group check occurs.
17578
17579
17580
17581 .option check_owner redirect boolean "see below"
17582 When the &%file%& option is used, the owner of the file is checked only when
17583 this option is set. If &%check_local_user%& is set, the local user is
17584 permitted; otherwise the owner must be one of those listed in the &%owners%&
17585 option. The default value for this option is true if &%check_local_user%& or
17586 &%owners%& is set. Otherwise the default is false, and no owner check occurs.
17587
17588
17589 .option data redirect string&!! unset
17590 This option is mutually exclusive with &%file%&. One or other of them must be
17591 set, but not both. The contents of &%data%& are expanded, and then used as the
17592 list of forwarding items, or as a set of filtering instructions. If the
17593 expansion is forced to fail, or the result is an empty string or a string that
17594 has no effect (consists entirely of comments), the router declines.
17595
17596 When filtering instructions are used, the string must begin with &"#Exim
17597 filter"&, and all comments in the string, including this initial one, must be
17598 terminated with newline characters. For example:
17599 .code
17600 data = #Exim filter\n\
17601        if $h_to: contains Exim then save $home/mail/exim endif
17602 .endd
17603 If you are reading the data from a database where newlines cannot be included,
17604 you can use the &${sg}$& expansion item to turn the escape string of your
17605 choice into a newline.
17606
17607
17608 .option directory_transport redirect string&!! unset
17609 A &(redirect)& router sets up a direct delivery to a directory when a path name
17610 ending with a slash is specified as a new &"address"&. The transport used is
17611 specified by this option, which, after expansion, must be the name of a
17612 configured transport. This should normally be an &(appendfile)& transport.
17613
17614
17615 .option file redirect string&!! unset
17616 This option specifies the name of a file that contains the redirection data. It
17617 is mutually exclusive with the &%data%& option. The string is expanded before
17618 use; if the expansion is forced to fail, the router declines. Other expansion
17619 failures cause delivery to be deferred. The result of a successful expansion
17620 must be an absolute path. The entire file is read and used as the redirection
17621 data. If the data is an empty string or a string that has no effect (consists
17622 entirely of comments), the router declines.
17623
17624 .cindex "NFS" "checking for file existence"
17625 If the attempt to open the file fails with a &"does not exist"& error, Exim
17626 runs a check on the containing directory,
17627 unless &%ignore_enotdir%& is true (see below).
17628 If the directory does not appear to exist, delivery is deferred. This can
17629 happen when users' &_.forward_& files are in NFS-mounted directories, and there
17630 is a mount problem. If the containing directory does exist, but the file does
17631 not, the router declines.
17632
17633
17634 .option file_transport redirect string&!! unset
17635 .cindex "&$address_file$&"
17636 A &(redirect)& router sets up a direct delivery to a file when a path name not
17637 ending in a slash is specified as a new &"address"&. The transport used is
17638 specified by this option, which, after expansion, must be the name of a
17639 configured transport. This should normally be an &(appendfile)& transport. When
17640 it is running, the file name is in &$address_file$&.
17641
17642
17643 .option filter_prepend_home redirect boolean true
17644 When this option is true, if a &(save)& command in an Exim filter specifies a
17645 relative path, and &$home$& is defined, it is automatically prepended to the
17646 relative path. If this option is set false, this action does not happen. The
17647 relative path is then passed to the transport unmodified.
17648
17649
17650 .option forbid_blackhole redirect boolean false
17651 If this option is true, the &':blackhole:'& item may not appear in a
17652 redirection list.
17653
17654
17655 .option forbid_exim_filter redirect boolean false
17656 If this option is set true, only Sieve filters are permitted when
17657 &%allow_filter%& is true.
17658
17659
17660
17661
17662 .option forbid_file redirect boolean false
17663 .cindex "delivery" "to file; forbidding"
17664 .cindex "Sieve filter" "forbidding delivery to a file"
17665 .cindex "Sieve filter" "&""keep""& facility; disabling"
17666 If this option is true, this router may not generate a new address that
17667 specifies delivery to a local file or directory, either from a filter or from a
17668 conventional forward file. This option is forced to be true if &%one_time%& is
17669 set. It applies to Sieve filters as well as to Exim filters, but if true, it
17670 locks out the Sieve's &"keep"& facility.
17671
17672
17673 .option forbid_filter_dlfunc redirect boolean false
17674 .cindex "filter" "locking out certain features"
17675 If this option is true, string expansions in Exim filters are not allowed to
17676 make use of the &%dlfunc%& expansion facility to run dynamically loaded
17677 functions.
17678
17679 .option forbid_filter_existstest redirect boolean false
17680 .cindex "expansion" "statting a file"
17681 If this option is true, string expansions in Exim filters are not allowed to
17682 make use of the &%exists%& condition or the &%stat%& expansion item.
17683
17684 .option forbid_filter_logwrite redirect boolean false
17685 If this option is true, use of the logging facility in Exim filters is not
17686 permitted. Logging is in any case available only if the filter is being run
17687 under some unprivileged uid (which is normally the case for ordinary users'
17688 &_.forward_& files).
17689
17690
17691 .option forbid_filter_lookup redirect boolean false
17692 If this option is true, string expansions in Exim filter files are not allowed
17693 to make use of &%lookup%& items.
17694
17695
17696 .option forbid_filter_perl redirect boolean false
17697 This option has an effect only if Exim is built with embedded Perl support. If
17698 it is true, string expansions in Exim filter files are not allowed to make use
17699 of the embedded Perl support.
17700
17701
17702 .option forbid_filter_readfile redirect boolean false
17703 If this option is true, string expansions in Exim filter files are not allowed
17704 to make use of &%readfile%& items.
17705
17706
17707 .option forbid_filter_readsocket redirect boolean false
17708 If this option is true, string expansions in Exim filter files are not allowed
17709 to make use of &%readsocket%& items.
17710
17711
17712 .option forbid_filter_reply redirect boolean false
17713 If this option is true, this router may not generate an automatic reply
17714 message. Automatic replies can be generated only from Exim or Sieve filter
17715 files, not from traditional forward files. This option is forced to be true if
17716 &%one_time%& is set.
17717
17718
17719 .option forbid_filter_run redirect boolean false
17720 If this option is true, string expansions in Exim filter files are not allowed
17721 to make use of &%run%& items.
17722
17723
17724 .option forbid_include redirect boolean false
17725 If this option is true, items of the form
17726 .code
17727 :include:<path name>
17728 .endd
17729 are not permitted in non-filter redirection lists.
17730
17731
17732 .option forbid_pipe redirect boolean false
17733 .cindex "delivery" "to pipe; forbidding"
17734 If this option is true, this router may not generate a new address which
17735 specifies delivery to a pipe, either from an Exim filter or from a conventional
17736 forward file. This option is forced to be true if &%one_time%& is set.
17737
17738
17739 .option forbid_sieve_filter redirect boolean false
17740 If this option is set true, only Exim filters are permitted when
17741 &%allow_filter%& is true.
17742
17743
17744 .cindex "SMTP" "error codes"
17745 .option forbid_smtp_code redirect boolean false
17746 If this option is set true, any SMTP error codes that are present at the start
17747 of messages specified for &`:defer:`& or &`:fail:`& are quietly ignored, and
17748 the default codes (451 and 550, respectively) are always used.
17749
17750
17751
17752
17753 .option hide_child_in_errmsg redirect boolean false
17754 .cindex "bounce message" "redirection details; suppressing"
17755 If this option is true, it prevents Exim from quoting a child address if it
17756 generates a bounce or delay message for it. Instead it says &"an address
17757 generated from <&'the top level address'&>"&. Of course, this applies only to
17758 bounces generated locally. If a message is forwarded to another host, &'its'&
17759 bounce may well quote the generated address.
17760
17761
17762 .option ignore_eacces redirect boolean false
17763 .cindex "EACCES"
17764 If this option is set and an attempt to open a redirection file yields the
17765 EACCES error (permission denied), the &(redirect)& router behaves as if the
17766 file did not exist.
17767
17768
17769 .option ignore_enotdir redirect boolean false
17770 .cindex "ENOTDIR"
17771 If this option is set and an attempt to open a redirection file yields the
17772 ENOTDIR error (something on the path is not a directory), the &(redirect)&
17773 router behaves as if the file did not exist.
17774
17775 Setting &%ignore_enotdir%& has another effect as well: When a &(redirect)&
17776 router that has the &%file%& option set discovers that the file does not exist
17777 (the ENOENT error), it tries to &[stat()]& the parent directory, as a check
17778 against unmounted NFS directories. If the parent can not be statted, delivery
17779 is deferred. However, it seems wrong to do this check when &%ignore_enotdir%&
17780 is set, because that option tells Exim to ignore &"something on the path is not
17781 a directory"& (the ENOTDIR error). This is a confusing area, because it seems
17782 that some operating systems give ENOENT where others give ENOTDIR.
17783
17784
17785
17786 .option include_directory redirect string unset
17787 If this option is set, the path names of any &':include:'& items in a
17788 redirection list must start with this directory.
17789
17790
17791 .option modemask redirect "octal integer" 022
17792 This specifies mode bits which must not be set for a file specified by the
17793 &%file%& option. If any of the forbidden bits are set, delivery is deferred.
17794
17795
17796 .option one_time redirect boolean false
17797 .cindex "one-time aliasing/forwarding expansion"
17798 .cindex "alias file" "one-time expansion"
17799 .cindex "forward file" "one-time expansion"
17800 .cindex "mailing lists" "one-time expansion"
17801 .cindex "address redirection" "one-time expansion"
17802 Sometimes the fact that Exim re-evaluates aliases and reprocesses redirection
17803 files each time it tries to deliver a message causes a problem when one or more
17804 of the generated addresses fails be delivered at the first attempt. The problem
17805 is not one of duplicate delivery &-- Exim is clever enough to handle that &--
17806 but of what happens when the redirection list changes during the time that the
17807 message is on Exim's queue. This is particularly true in the case of mailing
17808 lists, where new subscribers might receive copies of messages that were posted
17809 before they subscribed.
17810
17811 If &%one_time%& is set and any addresses generated by the router fail to
17812 deliver at the first attempt, the failing addresses are added to the message as
17813 &"top level"& addresses, and the parent address that generated them is marked
17814 &"delivered"&. Thus, redirection does not happen again at the next delivery
17815 attempt.
17816
17817 &*Warning 1*&: Any header line addition or removal that is specified by this
17818 router would be lost if delivery did not succeed at the first attempt. For this
17819 reason, the &%headers_add%& and &%headers_remove%& generic options are not
17820 permitted when &%one_time%& is set.
17821
17822 &*Warning 2*&: To ensure that the router generates only addresses (as opposed
17823 to pipe or file deliveries or auto-replies) &%forbid_file%&, &%forbid_pipe%&,
17824 and &%forbid_filter_reply%& are forced to be true when &%one_time%& is set.
17825
17826 &*Warning 3*&: The &%unseen%& generic router option may not be set with
17827 &%one_time%&.
17828
17829 The original top-level address is remembered with each of the generated
17830 addresses, and is output in any log messages. However, any intermediate parent
17831 addresses are not recorded. This makes a difference to the log only if
17832 &%all_parents%& log selector is set. It is expected that &%one_time%& will
17833 typically be used for mailing lists, where there is normally just one level of
17834 expansion.
17835
17836
17837 .option owners redirect "string list" unset
17838 .cindex "ownership" "alias file"
17839 .cindex "ownership" "forward file"
17840 .cindex "alias file" "ownership"
17841 .cindex "forward file" "ownership"
17842 This specifies a list of permitted owners for the file specified by &%file%&.
17843 This list is in addition to the local user when &%check_local_user%& is set.
17844 See &%check_owner%& above.
17845
17846
17847 .option owngroups redirect "string list" unset
17848 This specifies a list of permitted groups for the file specified by &%file%&.
17849 The list is in addition to the local user's primary group when
17850 &%check_local_user%& is set. See &%check_group%& above.
17851
17852
17853 .option pipe_transport redirect string&!! unset
17854 .cindex "&$address_pipe$&"
17855 A &(redirect)& router sets up a direct delivery to a pipe when a string
17856 starting with a vertical bar character is specified as a new &"address"&. The
17857 transport used is specified by this option, which, after expansion, must be the
17858 name of a configured transport. This should normally be a &(pipe)& transport.
17859 When the transport is run, the pipe command is in &$address_pipe$&.
17860
17861
17862 .option qualify_domain redirect string&!! unset
17863 .cindex "&$qualify_recipient$&"
17864 If this option is set, and an unqualified address (one without a domain) is
17865 generated, and that address would normally be qualified by the global setting
17866 in &%qualify_recipient%&, it is instead qualified with the domain specified by
17867 expanding this string. If the expansion fails, the router declines. If you want
17868 to revert to the default, you can have the expansion generate
17869 &$qualify_recipient$&.
17870
17871 This option applies to all unqualified addresses generated by Exim filters,
17872 but for traditional &_.forward_& files, it applies only to addresses that are
17873 not preceded by a backslash. Sieve filters cannot generate unqualified
17874 addresses.
17875
17876 .option qualify_preserve_domain redirect boolean false
17877 .cindex "domain" "in redirection; preserving"
17878 .cindex "preserving domain in redirection"
17879 .cindex "address redirection" "domain; preserving"
17880 If this option is set, the router's local &%qualify_domain%& option must not be
17881 set (a configuration error occurs if it is). If an unqualified address (one
17882 without a domain) is generated, it is qualified with the domain of the parent
17883 address (the immediately preceding ancestor) instead of the global
17884 &%qualify_recipient%& value. In the case of a traditional &_.forward_& file,
17885 this applies whether or not the address is preceded by a backslash.
17886
17887
17888 .option repeat_use redirect boolean true
17889 If this option is set false, the router is skipped for a child address that has
17890 any ancestor that was routed by this router. This test happens before any of
17891 the other preconditions are tested. Exim's default anti-looping rules skip
17892 only when the ancestor is the same as the current address. See also
17893 &%check_ancestor%& above and the generic &%redirect_router%& option.
17894
17895
17896 .option reply_transport redirect string&!! unset
17897 A &(redirect)& router sets up an automatic reply when a &%mail%& or
17898 &%vacation%& command is used in a filter file. The transport used is specified
17899 by this option, which, after expansion, must be the name of a configured
17900 transport. This should normally be an &(autoreply)& transport. Other transports
17901 are unlikely to do anything sensible or useful.
17902
17903
17904 .option rewrite redirect boolean true
17905 .cindex "address redirection" "disabling rewriting"
17906 If this option is set false, addresses generated by the router are not
17907 subject to address rewriting. Otherwise, they are treated like new addresses
17908 and are rewritten according to the global rewriting rules.
17909
17910
17911 .option sieve_subaddress redirect string&!! unset
17912 The value of this option is passed to a Sieve filter to specify the
17913 :subaddress part of an address.
17914
17915 .option sieve_useraddress redirect string&!! unset
17916 The value of this option is passed to a Sieve filter to specify the :user part
17917 of an address. However, if it is unset, the entire original local part
17918 (including any prefix or suffix) is used for :user.
17919
17920
17921 .option sieve_vacation_directory redirect string&!! unset
17922 .cindex "Sieve filter" "vacation directory"
17923 To enable the &"vacation"& extension for Sieve filters, you must set
17924 &%sieve_vacation_directory%& to the directory where vacation databases are held
17925 (do not put anything else in that directory), and ensure that the
17926 &%reply_transport%& option refers to an &(autoreply)& transport. Each user
17927 needs their own directory; Exim will create it if necessary.
17928
17929
17930
17931 .option skip_syntax_errors redirect boolean false
17932 .cindex "forward file" "broken"
17933 .cindex "address redirection" "broken files"
17934 .cindex "alias file" "broken"
17935 .cindex "broken alias or forward files"
17936 .cindex "ignoring faulty addresses"
17937 .cindex "skipping faulty addresses"
17938 .cindex "error" "skipping bad syntax"
17939 If &%skip_syntax_errors%& is set, syntactically malformed addresses in
17940 non-filter redirection data are skipped, and each failing address is logged. If
17941 &%syntax_errors_to%& is set, a message is sent to the address it defines,
17942 giving details of the failures. If &%syntax_errors_text%& is set, its contents
17943 are expanded and placed at the head of the error message generated by
17944 &%syntax_errors_to%&. Usually it is appropriate to set &%syntax_errors_to%& to
17945 be the same address as the generic &%errors_to%& option. The
17946 &%skip_syntax_errors%& option is often used when handling mailing lists.
17947
17948 If all the addresses in a redirection list are skipped because of syntax
17949 errors, the router declines to handle the original address, and it is passed to
17950 the following routers.
17951
17952 If &%skip_syntax_errors%& is set when an Exim filter is interpreted, any syntax
17953 error in the filter causes filtering to be abandoned without any action being
17954 taken. The incident is logged, and the router declines to handle the address,
17955 so it is passed to the following routers.
17956
17957 .cindex "Sieve filter" "syntax errors in"
17958 Syntax errors in a Sieve filter file cause the &"keep"& action to occur. This
17959 action is specified by RFC 3028. The values of &%skip_syntax_errors%&,
17960 &%syntax_errors_to%&, and &%syntax_errors_text%& are not used.
17961
17962 &%skip_syntax_errors%& can be used to specify that errors in users' forward
17963 lists or filter files should not prevent delivery. The &%syntax_errors_to%&
17964 option, used with an address that does not get redirected, can be used to
17965 notify users of these errors, by means of a router like this:
17966 .code
17967 userforward:
17968   driver = redirect
17969   allow_filter
17970   check_local_user
17971   file = $home/.forward
17972   file_transport = address_file
17973   pipe_transport = address_pipe
17974   reply_transport = address_reply
17975   no_verify
17976   skip_syntax_errors
17977   syntax_errors_to = real-$local_part@$domain
17978   syntax_errors_text = \
17979    This is an automatically generated message. An error has\n\
17980    been found in your .forward file. Details of the error are\n\
17981    reported below. While this error persists, you will receive\n\
17982    a copy of this message for every message that is addressed\n\
17983    to you. If your .forward file is a filter file, or if it is\n\
17984    a non-filter file containing no valid forwarding addresses,\n\
17985    a copy of each incoming message will be put in your normal\n\
17986    mailbox. If a non-filter file contains at least one valid\n\
17987    forwarding address, forwarding to the valid addresses will\n\
17988    happen, and those will be the only deliveries that occur.
17989 .endd
17990 You also need a router to ensure that local addresses that are prefixed by
17991 &`real-`& are recognized, but not forwarded or filtered. For example, you could
17992 put this immediately before the &(userforward)& router:
17993 .code
17994 real_localuser:
17995   driver = accept
17996   check_local_user
17997   local_part_prefix = real-
17998   transport = local_delivery
17999 .endd
18000
18001 .option syntax_errors_text redirect string&!! unset
18002 See &%skip_syntax_errors%& above.
18003
18004
18005 .option syntax_errors_to redirect string unset
18006 See &%skip_syntax_errors%& above.
18007 .ecindex IIDredrou1
18008 .ecindex IIDredrou2
18009
18010
18011
18012
18013
18014
18015 . ////////////////////////////////////////////////////////////////////////////
18016 . ////////////////////////////////////////////////////////////////////////////
18017
18018 .chapter "Environment for running local transports" "CHAPenvironment" &&&
18019          "Environment for local transports"
18020 .scindex IIDenvlotra1 "local transports" "environment for"
18021 .scindex IIDenvlotra2 "environment for local transports"
18022 .scindex IIDenvlotra3 "transport" "local; environment for"
18023 Local transports handle deliveries to files and pipes. (The &(autoreply)&
18024 transport can be thought of as similar to a pipe.) Exim always runs transports
18025 in subprocesses, under specified uids and gids. Typical deliveries to local
18026 mailboxes run under the uid and gid of the local user.
18027
18028 Exim also sets a specific current directory while running the transport; for
18029 some transports a home directory setting is also relevant. The &(pipe)&
18030 transport is the only one that sets up environment variables; see section
18031 &<<SECTpipeenv>>& for details.
18032
18033 The values used for the uid, gid, and the directories may come from several
18034 different places. In many cases, the router that handles the address associates
18035 settings with that address as a result of its &%check_local_user%&, &%group%&,
18036 or &%user%& options. However, values may also be given in the transport's own
18037 configuration, and these override anything that comes from the router.
18038
18039
18040
18041 .section "Concurrent deliveries"
18042 .cindex "concurrent deliveries"
18043 .cindex "simultaneous deliveries"
18044 If two different messages for the same local recpient arrive more or less
18045 simultaneously, the two delivery processes are likely to run concurrently. When
18046 the &(appendfile)& transport is used to write to a file, Exim applies locking
18047 rules to stop concurrent processes from writing to the same file at the same
18048 time.
18049
18050 However, when you use a &(pipe)& transport, it is up to you to arrange any
18051 locking that is needed. Here is a silly example:
18052 .code
18053 my_transport:
18054   driver = pipe
18055   command = /bin/sh -c 'cat >>/some/file'
18056 .endd
18057 This is supposed to write the message at the end of the file. However, if two
18058 messages arrive at the same time, the file will be scrambled. You can use the
18059 &%exim_lock%& utility program (see section &<<SECTmailboxmaint>>&) to lock a
18060 file using the same algorithm that Exim itself uses.
18061
18062
18063
18064
18065 .section "Uids and gids" "SECTenvuidgid"
18066 .cindex "local transports" "uid and gid"
18067 .cindex "transport" "local; uid and gid"
18068 All transports have the options &%group%& and &%user%&. If &%group%& is set, it
18069 overrides any group that the router set in the address, even if &%user%& is not
18070 set for the transport. This makes it possible, for example, to run local mail
18071 delivery under the uid of the recipient (set by the router), but in a special
18072 group (set by the transport). For example:
18073 .code
18074 # Routers ...
18075 # User/group are set by check_local_user in this router
18076 local_users:
18077   driver = accept
18078   check_local_user
18079   transport = group_delivery
18080
18081 # Transports ...
18082 # This transport overrides the group
18083 group_delivery:
18084   driver = appendfile
18085   file = /var/spool/mail/$local_part
18086   group = mail
18087 .endd
18088 If &%user%& is set for a transport, its value overrides what is set in the
18089 address by the router. If &%user%& is non-numeric and &%group%& is not set, the
18090 gid associated with the user is used. If &%user%& is numeric, &%group%& must be
18091 set.
18092
18093 .cindex "&%initgroups%& option"
18094 When the uid is taken from the transport's configuration, the &[initgroups()]&
18095 function is called for the groups associated with that uid if the
18096 &%initgroups%& option is set for the transport. When the uid is not specified
18097 by the transport, but is associated with the address by a router, the option
18098 for calling &[initgroups()]& is taken from the router configuration.
18099
18100 .cindex "&(pipe)& transport" "uid for"
18101 The &(pipe)& transport contains the special option &%pipe_as_creator%&. If this
18102 is set and &%user%& is not set, the uid of the process that called Exim to
18103 receive the message is used, and if &%group%& is not set, the corresponding
18104 original gid is also used.
18105
18106 This is the detailed preference order for obtaining a gid; the first of the
18107 following that is set is used:
18108
18109 .ilist
18110 A &%group%& setting of the transport;
18111 .next
18112 A &%group%& setting of the router;
18113 .next
18114 A gid associated with a user setting of the router, either as a result of
18115 &%check_local_user%& or an explicit non-numeric &%user%& setting;
18116 .next
18117 The group associated with a non-numeric &%user%& setting of the transport;
18118 .next
18119 In a &(pipe)& transport, the creator's gid if &%deliver_as_creator%& is set and
18120 the uid is the creator's uid;
18121 .next
18122 The Exim gid if the Exim uid is being used as a default.
18123 .endlist
18124
18125 If, for example, the user is specified numerically on the router and there are
18126 no group settings, no gid is available. In this situation, an error occurs.
18127 This is different for the uid, for which there always is an ultimate default.
18128 The first of the following that is set is used:
18129
18130 .ilist
18131 A &%user%& setting of the transport;
18132 .next
18133 In a &(pipe)& transport, the creator's uid if &%deliver_as_creator%& is set;
18134 .next
18135 A &%user%& setting of the router;
18136 .next
18137 A &%check_local_user%& setting of the router;
18138 .next
18139 The Exim uid.
18140 .endlist
18141
18142 Of course, an error will still occur if the uid that is chosen is on the
18143 &%never_users%& list.
18144
18145
18146
18147
18148
18149 .section "Current and home directories"
18150 .cindex "current directory for local transport"
18151 .cindex "home directory" "for local transport"
18152 .cindex "transport" "local; home directory for"
18153 .cindex "transport" "local; current directory for"
18154 Routers may set current and home directories for local transports by means of
18155 the &%transport_current_directory%& and &%transport_home_directory%& options.
18156 However, if the transport's &%current_directory%& or &%home_directory%& options
18157 are set, they override the router's values. In detail, the home directory
18158 for a local transport is taken from the first of these values that is set:
18159
18160 .ilist
18161 The &%home_directory%& option on the transport;
18162 .next
18163 The &%transport_home_directory%& option on the router;
18164 .next
18165 The password data if &%check_local_user%& is set on the router;
18166 .next
18167 The &%router_home_directory%& option on the router.
18168 .endlist
18169
18170 The current directory is taken from the first of these values that is set:
18171
18172 .ilist
18173 The &%current_directory%& option on the transport;
18174 .next
18175 The &%transport_current_directory%& option on the router.
18176 .endlist
18177
18178
18179 If neither the router nor the transport sets a current directory, Exim uses the
18180 value of the home directory, if it is set. Otherwise it sets the current
18181 directory to &_/_& before running a local transport.
18182
18183
18184
18185 .section "Expansion variables derived from the address"
18186 .cindex "&$domain$&"
18187 .cindex "&$local_part$&"
18188 .cindex "&$original_domain$&"
18189 Normally a local delivery is handling a single address, and in that case the
18190 variables such as &$domain$& and &$local_part$& are set during local
18191 deliveries. However, in some circumstances more than one address may be handled
18192 at once (for example, while writing batch SMTP for onward transmission by some
18193 other means). In this case, the variables associated with the local part are
18194 never set, &$domain$& is set only if all the addresses have the same domain,
18195 and &$original_domain$& is never set.
18196 .ecindex IIDenvlotra1
18197 .ecindex IIDenvlotra2
18198 .ecindex IIDenvlotra3
18199
18200
18201
18202
18203
18204
18205
18206 . ////////////////////////////////////////////////////////////////////////////
18207 . ////////////////////////////////////////////////////////////////////////////
18208
18209 .chapter "Generic options for transports" "CHAPtransportgeneric"
18210 .scindex IIDgenoptra1 "generic options" "transport"
18211 .scindex IIDgenoptra2 "options" "generic; for transports"
18212 .scindex IIDgenoptra3 "transport" "generic options for"
18213 The following generic options apply to all transports:
18214
18215
18216 .option body_only transports boolean false
18217 .cindex "transport" "body only"
18218 .cindex "message" "transporting body only"
18219 .cindex "body of message" "transporting"
18220 If this option is set, the message's headers are not transported. It is
18221 mutually exclusive with &%headers_only%&. If it is used with the &(appendfile)&
18222 or &(pipe)& transports, the settings of &%message_prefix%& and
18223 &%message_suffix%& should be checked, because this option does not
18224 automatically suppress them.
18225
18226
18227 .option current_directory transports string&!! unset
18228 .cindex "transport" "current directory for"
18229 This specifies the current directory that is to be set while running the
18230 transport, overriding any value that may have been set by the router.
18231 If the expansion fails for any reason, including forced failure, an error is
18232 logged, and delivery is deferred.
18233
18234
18235 .option disable_logging transports boolean false
18236 If this option is set true, nothing is logged for any
18237 deliveries by the transport or for any
18238 transport errors. You should not set this option unless you really, really know
18239 what you are doing.
18240
18241
18242 .option debug_print transports string&!! unset
18243 .cindex "testing" "variables in drivers"
18244 If this option is set and debugging is enabled (see the &%-d%& command line
18245 option), the string is expanded and included in the debugging output when the
18246 transport is run.
18247 If expansion of the string fails, the error message is written to the debugging
18248 output, and Exim carries on processing.
18249 This facility is provided to help with checking out the values of variables and
18250 so on when debugging driver configurations. For example, if a &%headers_add%&
18251 option is not working properly, &%debug_print%& could be used to output the
18252 variables it references. A newline is added to the text if it does not end with
18253 one.
18254
18255
18256 .option delivery_date_add transports boolean false
18257 .cindex "&'Delivery-date:'& header line"
18258 If this option is true, a &'Delivery-date:'& header is added to the message.
18259 This gives the actual time the delivery was made. As this is not a standard
18260 header, Exim has a configuration option (&%delivery_date_remove%&) which
18261 requests its removal from incoming messages, so that delivered messages can
18262 safely be resent to other recipients.
18263
18264
18265 .option driver transports string unset
18266 This specifies which of the available transport drivers is to be used.
18267 There is no default, and this option must be set for every transport.
18268
18269
18270 .option envelope_to_add transports boolean false
18271 .cindex "&'Envelope-to:'& header line"
18272 If this option is true, an &'Envelope-to:'& header is added to the message.
18273 This gives the original address(es) in the incoming envelope that caused this
18274 delivery to happen. More than one address may be present if the transport is
18275 configured to handle several addresses at once, or if more than one original
18276 address was redirected to the same final address. As this is not a standard
18277 header, Exim has a configuration option (&%envelope_to_remove%&) which requests
18278 its removal from incoming messages, so that delivered messages can safely be
18279 resent to other recipients.
18280
18281
18282 .option group transports string&!! "Exim group"
18283 .cindex "transport" "group; specifying"
18284 This option specifies a gid for running the transport process, overriding any
18285 value that the router supplies, and also overriding any value associated with
18286 &%user%& (see below).
18287
18288
18289 .option headers_add transports string&!! unset
18290 .cindex "header lines" "adding in transport"
18291 .cindex "transport" "header lines; adding"
18292 This option specifies a string of text that is expanded and added to the header
18293 portion of a message as it is transported, as described in section
18294 &<<SECTheadersaddrem>>&. Additional header lines can also be specified by
18295 routers. If the result of the expansion is an empty string, or if the expansion
18296 is forced to fail, no action is taken. Other expansion failures are treated as
18297 errors and cause the delivery to be deferred.
18298
18299
18300
18301 .option headers_only transports boolean false
18302 .cindex "transport" "header lines only"
18303 .cindex "message" "transporting headers only"
18304 .cindex "header lines" "transporting"
18305 If this option is set, the message's body is not transported. It is mutually
18306 exclusive with &%body_only%&. If it is used with the &(appendfile)& or &(pipe)&
18307 transports, the settings of &%message_prefix%& and &%message_suffix%& should be
18308 checked, since this option does not automatically suppress them.
18309
18310
18311 .option headers_remove transports string&!! unset
18312 .cindex "header lines" "removing"
18313 .cindex "transport" "header lines; removing"
18314 This option specifies a string that is expanded into a list of header names;
18315 these headers are omitted from the message as it is transported, as described
18316 in section &<<SECTheadersaddrem>>&. Header removal can also be specified by
18317 routers. If the result of the expansion is an empty string, or if the expansion
18318 is forced to fail, no action is taken. Other expansion failures are treated as
18319 errors and cause the delivery to be deferred.
18320
18321
18322
18323 .option headers_rewrite transports string unset
18324 .cindex "transport" "header lines; rewriting"
18325 .cindex "rewriting" "at transport time"
18326 This option allows addresses in header lines to be rewritten at transport time,
18327 that is, as the message is being copied to its destination. The contents of the
18328 option are a colon-separated list of rewriting rules. Each rule is in exactly
18329 the same form as one of the general rewriting rules that are applied when a
18330 message is received. These are described in chapter &<<CHAPrewrite>>&. For
18331 example,
18332 .code
18333 headers_rewrite = a@b c@d f : \
18334                   x@y w@z
18335 .endd
18336 changes &'a@b'& into &'c@d'& in &'From:'& header lines, and &'x@y'& into
18337 &'w@z'& in all address-bearing header lines. The rules are applied to the
18338 header lines just before they are written out at transport time, so they affect
18339 only those copies of the message that pass through the transport. However, only
18340 the message's original header lines, and any that were added by a system
18341 filter, are rewritten. If a router or transport adds header lines, they are not
18342 affected by this option. These rewriting rules are &'not'& applied to the
18343 envelope. You can change the return path using &%return_path%&, but you cannot
18344 change envelope recipients at this time.
18345
18346
18347 .option home_directory transports string&!! unset
18348 .cindex "transport" "home directory for"
18349 .cindex "&$home$&"
18350 This option specifies a home directory setting for a local transport,
18351 overriding any value that may be set by the router. The home directory is
18352 placed in &$home$& while expanding the transport's private options. It is also
18353 used as the current directory if no current directory is set by the
18354 &%current_directory%& option on the transport or the
18355 &%transport_current_directory%& option on the router. If the expansion fails
18356 for any reason, including forced failure, an error is logged, and delivery is
18357 deferred.
18358
18359
18360 .option initgroups transports boolean false
18361 .cindex "additional groups"
18362 .cindex "groups" "additional"
18363 .cindex "transport" "group; additional"
18364 If this option is true and the uid for the delivery process is provided by the
18365 transport, the &[initgroups()]& function is called when running the transport
18366 to ensure that any additional groups associated with the uid are set up.
18367
18368
18369 .option message_size_limit transports string&!! 0
18370 .cindex "limit" "message size per transport"
18371 .cindex "size of message" "limit"
18372 .cindex "transport" "message size; limiting"
18373 This option controls the size of messages passed through the transport. It is
18374 expanded before use; the result of the expansion must be a sequence of digits,
18375 optionally followed by K or M.
18376 If the expansion fails for any reason, including forced failure, or if the
18377 result is not of the required form, delivery is deferred.
18378 If the value is greater than zero and the size of a message exceeds this
18379 limit, the address is failed. If there is any chance that the resulting bounce
18380 message could be routed to the same transport, you should ensure that
18381 &%return_size_limit%& is less than the transport's &%message_size_limit%&, as
18382 otherwise the bounce message will fail to get delivered.
18383
18384
18385
18386 .option rcpt_include_affixes transports boolean false
18387 .cindex "prefix" "for local part; including in envelope"
18388 .cindex "suffix" "for local part; including in envelope"
18389 .cindex "local part" "prefix"
18390 .cindex "local part" "suffix"
18391 When this option is false (the default), and an address that has had any
18392 affixes (prefixes or suffixes) removed from the local part is delivered by any
18393 form of SMTP or LMTP, the affixes are not included. For example, if a router
18394 that contains
18395 .code
18396 local_part_prefix = *-
18397 .endd
18398 routes the address &'abc-xyz@some.domain'& to an SMTP transport, the envelope
18399 is delivered with
18400 .code
18401 RCPT TO:<xyz@some.domain>
18402 .endd
18403 This is also the case when an ACL-time callout is being used to verify a
18404 recipient address. However, if &%rcpt_include_affixes%& is set true, the
18405 whole local part is included in the RCPT command. This option applies to BSMTP
18406 deliveries by the &(appendfile)& and &(pipe)& transports as well as to the
18407 &(lmtp)& and &(smtp)& transports.
18408
18409
18410 .option retry_use_local_part transports boolean "see below"
18411 .cindex "hints database" "retry keys"
18412 When a delivery suffers a temporary failure, a retry record is created
18413 in Exim's hints database. For remote deliveries, the key for the retry record
18414 is based on the name and/or IP address of the failing remote host. For local
18415 deliveries, the key is normally the entire address, including both the local
18416 part and the domain. This is suitable for most common cases of local delivery
18417 temporary failure &-- for example, exceeding a mailbox quota should delay only
18418 deliveries to that mailbox, not to the whole domain.
18419
18420 However, in some special cases you may want to treat a temporary local delivery
18421 as a failure associated with the domain, and not with a particular local part.
18422 (For example, if you are storing all mail for some domain in files.) You can do
18423 this by setting &%retry_use_local_part%& false.
18424
18425 For all the local transports, its default value is true. For remote transports,
18426 the default value is false for tidiness, but changing the value has no effect
18427 on a remote transport in the current implementation.
18428
18429
18430 .option return_path transports string&!! unset
18431 .cindex "envelope sender"
18432 .cindex "transport" "return path; changing"
18433 .cindex "return path" "changing in transport"
18434 If this option is set, the string is expanded at transport time and replaces
18435 the existing return path (envelope sender) value in the copy of the message
18436 that is being delivered. An empty return path is permitted. This feature is
18437 designed for remote deliveries, where the value of this option is used in the
18438 SMTP MAIL command. If you set &%return_path%& for a local transport, the
18439 only effect is to change the address that is placed in the &'Return-path:'&
18440 header line, if one is added to the message (see the next option).
18441
18442 &*Note:*& A changed return path is not logged unless you add
18443 &%return_path_on_delivery%& to the log selector.
18444
18445 .cindex "&$return_path$&"
18446 The expansion can refer to the existing value via &$return_path$&. This is
18447 either the message's envelope sender, or an address set by the
18448 &%errors_to%& option on a router. If the expansion is forced to fail, no
18449 replacement occurs; if it fails for another reason, delivery is deferred. This
18450 option can be used to support VERP (Variable Envelope Return Paths) &-- see
18451 section &<<SECTverp>>&.
18452
18453 &*Note*&: If a delivery error is detected locally, including the case when a
18454 remote server rejects a message at SMTP time, the bounce message is not sent to
18455 the value of this option. It is sent to the previously set errors address.
18456 This defaults to the incoming sender address, but can be changed by setting
18457 &%errors_to%& in a router.
18458
18459
18460
18461 .option return_path_add transports boolean false
18462 .cindex "&'Return-path:'& header line"
18463 If this option is true, a &'Return-path:'& header is added to the message.
18464 Although the return path is normally available in the prefix line of BSD
18465 mailboxes, this is commonly not displayed by MUAs, and so the user does not
18466 have easy access to it.
18467
18468 RFC 2821 states that the &'Return-path:'& header is added to a message &"when
18469 the delivery SMTP server makes the final delivery"&. This implies that this
18470 header should not be present in incoming messages. Exim has a configuration
18471 option, &%return_path_remove%&, which requests removal of this header from
18472 incoming messages, so that delivered messages can safely be resent to other
18473 recipients.
18474
18475
18476 .option shadow_condition transports string&!! unset
18477 See &%shadow_transport%& below.
18478
18479
18480 .option shadow_transport transports string unset
18481 .cindex "shadow transport"
18482 .cindex "transport" "shadow"
18483 A local transport may set the &%shadow_transport%& option to the name of
18484 another local transport. Shadow remote transports are not supported.
18485
18486 Whenever a delivery to the main transport succeeds, and either
18487 &%shadow_condition%& is unset, or its expansion does not result in the empty
18488 string or one of the strings &"0"& or &"no"& or &"false"&, the message is also
18489 passed to the shadow transport, with the same delivery address or addresses. If
18490 expansion fails, no action is taken except that non-forced expansion failures
18491 cause a log line to be written.
18492
18493 The result of the shadow transport is discarded and does not affect the
18494 subsequent processing of the message. Only a single level of shadowing is
18495 provided; the &%shadow_transport%& option is ignored on any transport when it
18496 is running as a shadow. Options concerned with output from pipes are also
18497 ignored. The log line for the successful delivery has an item added on the end,
18498 of the form
18499 .code
18500 ST=<shadow transport name>
18501 .endd
18502 If the shadow transport did not succeed, the error message is put in
18503 parentheses afterwards. Shadow transports can be used for a number of different
18504 purposes, including keeping more detailed log information than Exim normally
18505 provides, and implementing automatic acknowledgement policies based on message
18506 headers that some sites insist on.
18507
18508
18509 .option transport_filter transports string&!! unset
18510 .cindex "transport" "filter"
18511 .cindex "filter" "transport filter"
18512 This option sets up a filtering (in the Unix shell sense) process for messages
18513 at transport time. It should not be confused with mail filtering as set up by
18514 individual users or via a system filter.
18515
18516 When the message is about to be written out, the command specified by
18517 &%transport_filter%& is started up in a separate, parallel process, and
18518 the entire message, including the header lines, is passed to it on its standard
18519 input (this in fact is done from a third process, to avoid deadlock). The
18520 command must be specified as an absolute path.
18521
18522 The lines of the message that are written to the transport filter are
18523 terminated by newline (&"\n"&). The message is passed to the filter before any
18524 SMTP-specific processing, such as turning &"\n"& into &"\r\n"& and escaping
18525 lines beginning with a dot, and also before any processing implied by the
18526 settings of &%check_string%& and &%escape_string%& in the &(appendfile)& or
18527 &(pipe)& transports.
18528
18529 The standard error for the filter process is set to the same destination as its
18530 standard output; this is read and written to the message's ultimate
18531 destination. The process that writes the message to the filter, the
18532 filter itself, and the original process that reads the result and delivers it
18533 are all run in parallel, like a shell pipeline.
18534
18535 The filter can perform any transformations it likes, but of course should take
18536 care not to break RFC 2822 syntax. A demonstration Perl script is provided in
18537 &_util/transport-filter.pl_&; this makes a few arbitrary modifications just to
18538 show the possibilities. Exim does not check the result, except to test for a
18539 final newline when SMTP is in use. All messages transmitted over SMTP must end
18540 with a newline, so Exim supplies one if it is missing.
18541
18542 .cindex "content scanning" "per user"
18543 A transport filter can be used to provide content-scanning on a per-user basis
18544 at delivery time if the only required effect of the scan is to modify the
18545 message. For example, a content scan could insert a new header line containing
18546 a spam score. This could be interpreted by a filter in the user's MUA. It is
18547 not possible to discard a message at this stage.
18548
18549 .cindex "SMTP" "SIZE"
18550 A problem might arise if the filter increases the size of a message that is
18551 being sent down an SMTP connection. If the receiving SMTP server has indicated
18552 support for the SIZE parameter, Exim will have sent the size of the message
18553 at the start of the SMTP session. If what is actually sent is substantially
18554 more, the server might reject the message. This can be worked round by setting
18555 the &%size_addition%& option on the &(smtp)& transport, either to allow for
18556 additions to the message, or to disable the use of SIZE altogether.
18557
18558 .cindex "&$pipe_addresses$&"
18559 The value of the &%transport_filter%& option is the command string for starting
18560 the filter, which is run directly from Exim, not under a shell. The string is
18561 parsed by Exim in the same way as a command string for the &(pipe)& transport:
18562 Exim breaks it up into arguments and then expands each argument separately (see
18563 section &<<SECThowcommandrun>>&). Any kind of expansion failure causes delivery
18564 to be deferred. The special argument &$pipe_addresses$& is replaced by a number
18565 of arguments, one for each address that applies to this delivery. (This isn't
18566 an ideal name for this feature here, but as it was already implemented for the
18567 &(pipe)& transport, it seemed sensible not to change it.)
18568
18569 .cindex "&$host$&"
18570 .cindex "&$host_address$&"
18571 The expansion variables &$host$& and &$host_address$& are available when the
18572 transport is a remote one. They contain the name and IP address of the host to
18573 which the message is being sent. For example:
18574 .code
18575 transport_filter = /some/directory/transport-filter.pl \
18576   $host $host_address $sender_address $pipe_addresses
18577 .endd
18578
18579 Two problems arise if you want to use more complicated expansion items to
18580 generate transport filter commands, both of which due to the fact that the
18581 command is split up &'before'& expansion.
18582 .ilist
18583 If an expansion item contains white space, you must quote it, so that it is all
18584 part of the same command item. If the entire option setting is one such
18585 expansion item, you have to take care what kind of quoting you use. For
18586 example:
18587 .code
18588 transport_filter = '/bin/cmd${if eq{$host}{a.b.c}{1}{2}}'
18589 .endd
18590 This runs the command &(/bin/cmd1)& if the host name is &'a.b.c'&, and
18591 &(/bin/cmd2)& otherwise. If double quotes had been used, they would have been
18592 stripped by Exim when it read the option's value. When the value is used, if
18593 the single quotes were missing, the line would be split into two items,
18594 &`/bin/cmd${if`& and &`eq{$host}{a.b.c}{1}{2}`&, and an error would occur when
18595 Exim tried to expand the first one.
18596 .next
18597 Except for the special case of &$pipe_addresses$& that is mentioned above, an
18598 expansion cannot generate multiple arguments, or a command name followed by
18599 arguments. Consider this example:
18600 .code
18601 transport_filter = ${lookup{$host}lsearch{/some/file}\
18602                     {$value}{/bin/cat}}
18603 .endd
18604 The result of the lookup is interpreted as the name of the command, even
18605 if it contains white space. The simplest way round this is to use a shell:
18606 .code
18607 transport_filter = /bin/sh -c ${lookup{$host}lsearch{/some/file}\
18608                                {$value}{/bin/cat}}
18609 .endd
18610 .endlist
18611
18612 The filter process is run under the same uid and gid as the normal delivery.
18613 For remote deliveries this is the Exim uid/gid by default. The command should
18614 normally yield a zero return code. Transport filters are not supposed to fail.
18615 A non-zero code is taken to mean that the transport filter encountered some
18616 serious problem. Delivery of the message is deferred; the message remains on
18617 the queue and is tried again later. It is not possible to cause a message to be
18618 bounced from a transport filter.
18619
18620 If a transport filter is set on an autoreply transport, the original message is
18621 passed through the filter as it is being copied into the newly generated
18622 message, which happens if the &%return_message%& option is set.
18623
18624
18625 .option transport_filter_timeout transports time 5m
18626 .cindex "transport filter" "timeout"
18627 When Exim is reading the output of a transport filter, it a applies a timeout
18628 that can be set by this option. Exceeding the timeout is normally treated as a
18629 temporary delivery failure. However, if a transport filter is used with a
18630 &(pipe)& transport, a timeout in the transport filter is treated in the same
18631 way as a timeout in the pipe command itself. By default, a timeout is a hard
18632 error, but if the &(pipe)& transport's &%timeout_defer%& option is set true, it
18633 becomes a temporary error.
18634
18635
18636 .option user transports string&!! "Exim user"
18637 .cindex "uid (user id)" "local delivery"
18638 .cindex "transport user" "specifying"
18639 This option specifies the user under whose uid the delivery process is to be
18640 run, overriding any uid that may have been set by the router. If the user is
18641 given as a name, the uid is looked up from the password data, and the
18642 associated group is taken as the value of the gid to be used if the &%group%&
18643 option is not set.
18644
18645 For deliveries that use local transports, a user and group are normally
18646 specified explicitly or implicitly (for example, as a result of
18647 &%check_local_user%&) by the router or transport.
18648
18649 .cindex "hints database" "access by remote transport"
18650 For remote transports, you should leave this option unset unless you really are
18651 sure you know what you are doing. When a remote transport is running, it needs
18652 to be able to access Exim's hints databases, because each host may have its own
18653 retry data.
18654 .ecindex IIDgenoptra1
18655 .ecindex IIDgenoptra2
18656 .ecindex IIDgenoptra3
18657
18658
18659
18660
18661
18662
18663 . ////////////////////////////////////////////////////////////////////////////
18664 . ////////////////////////////////////////////////////////////////////////////
18665
18666 .chapter "Address batching in local transports" "CHAPbatching" &&&
18667          "Address batching"
18668 .cindex "transport" "local; address batching in"
18669 The only remote transport (&(smtp)&) is normally configured to handle more than
18670 one address at a time, so that when several addresses are routed to the same
18671 remote host, just one copy of the message is sent. Local transports, however,
18672 normally handle one address at a time. That is, a separate instance of the
18673 transport is run for each address that is routed to the transport. A separate
18674 copy of the message is delivered each time.
18675
18676 .cindex "batched local delivery"
18677 .cindex "&%batch_max%&"
18678 .cindex "&%batch_id%&"
18679 In special cases, it may be desirable to handle several addresses at once in a
18680 local transport, for example:
18681
18682 .ilist
18683 In an &(appendfile)& transport, when storing messages in files for later
18684 delivery by some other means, a single copy of the message with multiple
18685 recipients saves space.
18686 .next
18687 In an &(lmtp)& transport, when delivering over &"local SMTP"& to some process,
18688 a single copy saves time, and is the normal way LMTP is expected to work.
18689 .next
18690 In a &(pipe)& transport, when passing the message
18691 to a scanner program or
18692 to some other delivery mechanism such as UUCP, multiple recipients may be
18693 acceptable.
18694 .endlist
18695
18696 These three local transports all have the same options for controlling multiple
18697 (&"batched"&) deliveries, namely &%batch_max%& and &%batch_id%&. To save
18698 repeating the information for each transport, these options are described here.
18699
18700 The &%batch_max%& option specifies the maximum number of addresses that can be
18701 delivered together in a single run of the transport. Its default value is one
18702 (no batching). When more than one address is routed to a transport that has a
18703 &%batch_max%& value greater than one, the addresses are delivered in a batch
18704 (that is, in a single run of the transport with multiple recipients), subject
18705 to certain conditions:
18706
18707 .ilist
18708 .cindex "&$local_part$&"
18709 If any of the transport's options contain a reference to &$local_part$&, no
18710 batching is possible.
18711 .next
18712 .cindex "&$domain$&"
18713 If any of the transport's options contain a reference to &$domain$&, only
18714 addresses with the same domain are batched.
18715 .next
18716 .cindex "customizing" "batching condition"
18717 If &%batch_id%& is set, it is expanded for each address, and only those
18718 addresses with the same expanded value are batched. This allows you to specify
18719 customized batching conditions. Failure of the expansion for any reason,
18720 including forced failure, disables batching, but it does not stop the delivery
18721 from taking place.
18722 .next
18723 Batched addresses must also have the same errors address (where to send
18724 delivery errors), the same header additions and removals, the same user and
18725 group for the transport, and if a host list is present, the first host must
18726 be the same.
18727 .endlist
18728
18729 In the case of the &(appendfile)& and &(pipe)& transports, batching applies
18730 both when the file or pipe command is specified in the transport, and when it
18731 is specified by a &(redirect)& router, but all the batched addresses must of
18732 course be routed to the same file or pipe command. These two transports have an
18733 option called &%use_bsmtp%&, which causes them to deliver the message in
18734 &"batched SMTP"& format, with the envelope represented as SMTP commands. The
18735 &%check_string%& and &%escape_string%& options are forced to the values
18736 .code
18737 check_string = "."
18738 escape_string = ".."
18739 .endd
18740 when batched SMTP is in use. A full description of the batch SMTP mechanism is
18741 given in section &<<SECTbatchSMTP>>&. The &(lmtp)& transport does not have a
18742 &%use_bsmtp%& option, because it always delivers using the SMTP protocol.
18743
18744 .cindex "&'Envelope-to:'& header line"
18745 If the generic &%envelope_to_add%& option is set for a batching transport, the
18746 &'Envelope-to:'& header that is added to the message contains all the addresses
18747 that are being processed together. If you are using a batching &(appendfile)&
18748 transport without &%use_bsmtp%&, the only way to preserve the recipient
18749 addresses is to set the &%envelope_to_add%& option.
18750
18751 .cindex "&(pipe)& transport" "with multiple addresses"
18752 .cindex "&$pipe_addresses$&"
18753 If you are using a &(pipe)& transport without BSMTP, and setting the
18754 transport's &%command%& option, you can include &$pipe_addresses$& as part of
18755 the command. This is not a true variable; it is a bit of magic that causes each
18756 of the recipient addresses to be inserted into the command as a separate
18757 argument. This provides a way of accessing all the addresses that are being
18758 delivered in the batch. &*Note:*& This is not possible for pipe commands that
18759 are specififed by a &(redirect)& router.
18760
18761
18762
18763
18764 . ////////////////////////////////////////////////////////////////////////////
18765 . ////////////////////////////////////////////////////////////////////////////
18766
18767 .chapter "The appendfile transport" "CHAPappendfile"
18768 .scindex IIDapptra1 "&(appendfile)& transport"
18769 .scindex IIDapptra2 "transports" "&(appendfile)&"
18770 .cindex "directory creation"
18771 .cindex "creating directories"
18772 The &(appendfile)& transport delivers a message by appending it to an existing
18773 file, or by creating an entirely new file in a specified directory. Single
18774 files to which messages are appended can be in the traditional Unix mailbox
18775 format, or optionally in the MBX format supported by the Pine MUA and
18776 University of Washington IMAP daemon, &'inter alia'&. When each message is
18777 being delivered as a separate file, &"maildir"& format can optionally be used
18778 to give added protection against failures that happen part-way through the
18779 delivery. A third form of separate-file delivery known as &"mailstore"& is also
18780 supported. For all file formats, Exim attempts to create as many levels of
18781 directory as necessary, provided that &%create_directory%& is set.
18782
18783 The code for the optional formats is not included in the Exim binary by
18784 default. It is necessary to set SUPPORT_MBX, SUPPORT_MAILDIR and/or
18785 SUPPORT_MAILSTORE in &_Local/Makefile_& to have the appropriate code
18786 included.
18787
18788 .cindex "quota" "system"
18789 Exim recognises system quota errors, and generates an appropriate message. Exim
18790 also supports its own quota control within the transport, for use when the
18791 system facility is unavailable or cannot be used for some reason.
18792
18793 If there is an error while appending to a file (for example, quota exceeded or
18794 partition filled), Exim attempts to reset the file's length and last
18795 modification time back to what they were before. If there is an error while
18796 creating an entirely new file, the new file is removed.
18797
18798 Before appending to a file, a number of security checks are made, and the
18799 file is locked. A detailed description is given below, after the list of
18800 private options.
18801
18802 The &(appendfile)& transport is most commonly used for local deliveries to
18803 users' mailboxes. However, it can also be used as a pseudo-remote transport for
18804 putting messages into files for remote delivery by some means other than Exim.
18805 &"Batch SMTP"& format is often used in this case (see the &%use_bsmtp%&
18806 option).
18807
18808
18809
18810 .section "The file and directory options" "SECTfildiropt"
18811 The &%file%& option specifies a single file, to which the message is appended;
18812 the &%directory%& option specifies a directory, in which a new file containing
18813 the message is created. Only one of these two options can be set, and for
18814 normal deliveries to mailboxes, one of them &'must'& be set.
18815
18816 .cindex "&$address_file$&"
18817 .cindex "&$local_part$&"
18818 However, &(appendfile)& is also used for delivering messages to files or
18819 directories whose names (or parts of names) are obtained from alias,
18820 forwarding, or filtering operations (for example, a &%save%& command in a
18821 user's Exim filter). When such a transport is running, &$local_part$& contains
18822 the local part that was aliased or forwarded, and &$address_file$& contains the
18823 name (or partial name) of the file or directory generated by the redirection
18824 operation. There are two cases:
18825
18826 .ilist
18827 If neither &%file%& nor &%directory%& is set, the redirection operation
18828 must specify an absolute path (one that begins with &`/`&). This is the most
18829 common case when users with local accounts use filtering to sort mail into
18830 different folders. See for example, the &(address_file)& transport in the
18831 default configuration. If the path ends with a slash, it is assumed to be the
18832 name of a directory. A delivery to a directory can also be forced by setting
18833 &%maildir_format%& or &%mailstore_format%&.
18834 .next
18835 If &%file%& or &%directory%& is set for a delivery from a redirection, it is
18836 used to determine the file or directory name for the delivery. Normally, the
18837 contents of &$address_file$& are used in some way in the string expansion.
18838 .endlist
18839
18840
18841 .cindex "Sieve filter" "configuring &(appendfile)&"
18842 .cindex "Sieve filter" "relative mailbox path handling"
18843 As an example of the second case, consider an environment where users do not
18844 have home directories. They may be permitted to use Exim filter commands of the
18845 form:
18846 .code
18847 save folder23
18848 .endd
18849 or Sieve filter commands of the form:
18850 .code
18851 require "fileinto";
18852 fileinto "folder23";
18853 .endd
18854 In this situation, the expansion of &%file%& or &%directory%& in the transport
18855 must transform the relative path into an appropriate absolute file name. In the
18856 case of Sieve filters, the name &'inbox'& must be handled. It is the name that
18857 is used as a result of a &"keep"& action in the filter. This example shows one
18858 way of handling this requirement:
18859 .code
18860 file = ${if eq{$address_file}{inbox} \
18861             {/var/mail/$local_part} \
18862             {${if eq{${substr_0_1:$address_file}}{/} \
18863                   {$address_file} \
18864                   {$home/mail/$address_file} \
18865             }} \
18866        }
18867 .endd
18868 With this setting of &%file%&, &'inbox'& refers to the standard mailbox
18869 location, absolute paths are used without change, and other folders are in the
18870 &_mail_& directory within the home directory.
18871
18872 &*Note 1*&: While processing an Exim filter, a relative path such as
18873 &_folder23_& is turned into an absolute path if a home directory is known to
18874 the router. In particular, this is the case if &%check_local_user%& is set. If
18875 you want to prevent this happening at routing time, you can set
18876 &%router_home_directory%& empty. This forces the router to pass the relative
18877 path to the transport.
18878
18879 &*Note 2*&: An absolute path in &$address_file$& is not treated specially;
18880 the &%file%& or &%directory%& option is still used if it is set.
18881
18882
18883
18884
18885 .section "Private options for appendfile"
18886 .cindex "options" "&(appendfile)& transport"
18887
18888
18889
18890 .option allow_fifo appendfile boolean false
18891 .cindex "fifo (named pipe)"
18892 .cindex "named pipe (fifo)"
18893 .cindex "pipe" "named (fifo)"
18894 Setting this option permits delivery to named pipes (FIFOs) as well as to
18895 regular files. If no process is reading the named pipe at delivery time, the
18896 delivery is deferred.
18897
18898
18899 .option allow_symlink appendfile boolean false
18900 .cindex "symbolic link" "to mailbox"
18901 .cindex "mailbox" "symbolic link"
18902 By default, &(appendfile)& will not deliver if the path name for the file is
18903 that of a symbolic link. Setting this option relaxes that constraint, but there
18904 are security issues involved in the use of symbolic links. Be sure you know
18905 what you are doing if you set this. Details of exactly what this option affects
18906 are included in the discussion which follows this list of options.
18907
18908
18909 .option batch_id appendfile string&!! unset
18910 See the description of local delivery batching in chapter &<<CHAPbatching>>&.
18911 However, batching is automatically disabled for &(appendfile)& deliveries that
18912 happen as a result of forwarding or aliasing or other redirection directly to a
18913 file.
18914
18915
18916 .option batch_max appendfile integer 1
18917 See the description of local delivery batching in chapter &<<CHAPbatching>>&.
18918
18919
18920 .option check_group appendfile boolean false
18921 When this option is set, the group owner of the file defined by the &%file%&
18922 option is checked to see that it is the same as the group under which the
18923 delivery process is running. The default setting is false because the default
18924 file mode is 0600, which means that the group is irrelevant.
18925
18926
18927 .option check_owner appendfile boolean true
18928 When this option is set, the owner of the file defined by the &%file%& option
18929 is checked to ensure that it is the same as the user under which the delivery
18930 process is running.
18931
18932
18933 .option check_string appendfile string "see below"
18934 .cindex "&""From""& line"
18935 As &(appendfile)& writes the message, the start of each line is tested for
18936 matching &%check_string%&, and if it does, the initial matching characters are
18937 replaced by the contents of &%escape_string%&. The value of &%check_string%& is
18938 a literal string, not a regular expression, and the case of any letters it
18939 contains is significant.
18940
18941 If &%use_bsmtp%& is set the values of &%check_string%& and &%escape_string%&
18942 are forced to &"."& and &".."& respectively, and any settings in the
18943 configuration are ignored. Otherwise, they default to &"From&~"& and
18944 &">From&~"& when the &%file%& option is set, and unset when any of the
18945 &%directory%&, &%maildir%&, or &%mailstore%& options are set.
18946
18947 The default settings, along with &%message_prefix%& and &%message_suffix%&, are
18948 suitable for traditional &"BSD"& mailboxes, where a line beginning with
18949 &"From&~"& indicates the start of a new message. All four options need changing
18950 if another format is used. For example, to deliver to mailboxes in MMDF format:
18951 .cindex "MMDF format mailbox"
18952 .cindex "mailbox" "MMDF format"
18953 .code
18954 check_string = "\1\1\1\1\n"
18955 escape_string = "\1\1\1\1 \n"
18956 message_prefix = "\1\1\1\1\n"
18957 message_suffix = "\1\1\1\1\n"
18958 .endd
18959 .option create_directory appendfile boolean true
18960 .cindex "directory creation"
18961 When this option is true, Exim attempts to create any missing superior
18962 directories for the file that it is about to write. A created directory's mode
18963 is given by the &%directory_mode%& option.
18964
18965 The group ownership of a newly created directory is highly dependent on the
18966 operating system (and possibly the file system) that is being used. For
18967 example, in Solaris, if the parent directory has the setgid bit set, its group
18968 is propagated to the child; if not, the currently set group is used. However,
18969 in FreeBSD, the parent's group is always used.
18970
18971
18972
18973 .option create_file appendfile string anywhere
18974 This option constrains the location of files and directories that are created
18975 by this transport. It applies to files defined by the &%file%& option and
18976 directories defined by the &%directory%& option. In the case of maildir
18977 delivery, it applies to the top level directory, not the maildir directories
18978 beneath.
18979
18980 The option must be set to one of the words &"anywhere"&, &"inhome"&, or
18981 &"belowhome"&. In the second and third cases, a home directory must have been
18982 set for the transport. This option is not useful when an explicit file name is
18983 given for normal mailbox deliveries. It is intended for the case when file
18984 names are generated from users' &_.forward_& files. These are usually handled
18985 by an &(appendfile)& transport called &%address_file%&. See also
18986 &%file_must_exist%&.
18987
18988
18989 .option directory appendfile string&!! unset
18990 This option is mutually exclusive with the &%file%& option, but one of &%file%&
18991 or &%directory%& must be set, unless the delivery is the direct result of a
18992 redirection (see section &<<SECTfildiropt>>&).
18993
18994 When &%directory%& is set, the string is expanded, and the message is delivered
18995 into a new file or files in or below the given directory, instead of being
18996 appended to a single mailbox file. A number of different formats are provided
18997 (see &%maildir_format%& and &%mailstore_format%&), and see section
18998 &<<SECTopdir>>& for further details of this form of delivery.
18999
19000
19001 .option directory_file appendfile string&!! &`q${base62:$tod_epoch}-$inode`&
19002 .cindex "base62"
19003 .cindex "&$inode$&"
19004 When &%directory%& is set, but neither &%maildir_format%& nor
19005 &%mailstore_format%& is set, &(appendfile)& delivers each message into a file
19006 whose name is obtained by expanding this string. The default value generates a
19007 unique name from the current time, in base 62 form, and the inode of the file.
19008 The variable &$inode$& is available only when expanding this option.
19009
19010
19011 .option directory_mode appendfile "octal integer" 0700
19012 If &(appendfile)& creates any directories as a result of the
19013 &%create_directory%& option, their mode is specified by this option.
19014
19015
19016 .option escape_string appendfile string "see description"
19017 See &%check_string%& above.
19018
19019
19020 .option file appendfile string&!! unset
19021 This option is mutually exclusive with the &%directory%& option, but one of
19022 &%file%& or &%directory%& must be set, unless the delivery is the direct result
19023 of a redirection (see section &<<SECTfildiropt>>&). The &%file%& option
19024 specifies a single file, to which the message is appended. One or more of
19025 &%use_fcntl_lock%&, &%use_flock_lock%&, or &%use_lockfile%& must be set with
19026 &%file%&.
19027
19028 .cindex "NFS" "lock file"
19029 .cindex "locking files"
19030 .cindex "lock files"
19031 If you are using more than one host to deliver over NFS into the same
19032 mailboxes, you should always use lock files.
19033
19034 The string value is expanded for each delivery, and must yield an absolute
19035 path. The most common settings of this option are variations on one of these
19036 examples:
19037 .code
19038 file = /var/spool/mail/$local_part
19039 file = /home/$local_part/inbox
19040 file = $home/inbox
19041 .endd
19042 .cindex "&""sticky""& bit"
19043 In the first example, all deliveries are done into the same directory. If Exim
19044 is configured to use lock files (see &%use_lockfile%& below) it must be able to
19045 create a file in the directory, so the &"sticky"& bit must be turned on for
19046 deliveries to be possible, or alternatively the &%group%& option can be used to
19047 run the delivery under a group id which has write access to the directory.
19048
19049
19050
19051 .option file_format appendfile string unset
19052 .cindex "file" "mailbox; checking existing format"
19053 This option requests the transport to check the format of an existing file
19054 before adding to it. The check consists of matching a specific string at the
19055 start of the file. The value of the option consists of an even number of
19056 colon-separated strings. The first of each pair is the test string, and the
19057 second is the name of a transport. If the transport associated with a matched
19058 string is not the current transport, control is passed over to the other
19059 transport. For example, suppose the standard &(local_delivery)& transport has
19060 this added to it:
19061 .code
19062 file_format = "From       : local_delivery :\
19063                \1\1\1\1\n : local_mmdf_delivery"
19064 .endd
19065 Mailboxes that begin with &"From"& are still handled by this transport, but if
19066 a mailbox begins with four binary ones followed by a newline, control is passed
19067 to a transport called &%local_mmdf_delivery%&, which presumably is configured
19068 to do the delivery in MMDF format. If a mailbox does not exist or is empty, it
19069 is assumed to match the current transport. If the start of a mailbox doesn't
19070 match any string, or if the transport named for a given string is not defined,
19071 delivery is deferred.
19072
19073
19074 .option file_must_exist appendfile boolean false
19075 If this option is true, the file specified by the &%file%& option must exist.
19076 A temporary error occurs if it does not, causing delivery to be deferred.
19077 If this option is false, the file is created if it does not exist.
19078
19079
19080 .option lock_fcntl_timeout appendfile time 0s
19081 .cindex "timeout" "mailbox locking"
19082 .cindex "mailbox locking" "blocking and non-blocking"
19083 .cindex "locking files"
19084 By default, the &(appendfile)& transport uses non-blocking calls to &[fcntl()]&
19085 when locking an open mailbox file. If the call fails, the delivery process
19086 sleeps for &%lock_interval%& and tries again, up to &%lock_retries%& times.
19087 Non-blocking calls are used so that the file is not kept open during the wait
19088 for the lock; the reason for this is to make it as safe as possible for
19089 deliveries over NFS in the case when processes might be accessing an NFS
19090 mailbox without using a lock file. This should not be done, but
19091 misunderstandings and hence misconfigurations are not unknown.
19092
19093 On a busy system, however, the performance of a non-blocking lock approach is
19094 not as good as using a blocking lock with a timeout. In this case, the waiting
19095 is done inside the system call, and Exim's delivery process acquires the lock
19096 and can proceed as soon as the previous lock holder releases it.
19097
19098 If &%lock_fcntl_timeout%& is set to a non-zero time, blocking locks, with that
19099 timeout, are used. There may still be some retrying: the maximum number of
19100 retries is
19101 .code
19102 (lock_retries * lock_interval) / lock_fcntl_timeout
19103 .endd
19104 rounded up to the next whole number. In other words, the total time during
19105 which &(appendfile)& is trying to get a lock is roughly the same, unless
19106 &%lock_fcntl_timeout%& is set very large.
19107
19108 You should consider setting this option if you are getting a lot of delayed
19109 local deliveries because of errors of the form
19110 .code
19111 failed to lock mailbox /some/file (fcntl)
19112 .endd
19113
19114 .option lock_flock_timeout appendfile time 0s
19115 This timeout applies to file locking when using &[flock()]& (see
19116 &%use_flock%&); the timeout operates in a similar manner to
19117 &%lock_fcntl_timeout%&.
19118
19119
19120 .option lock_interval appendfile time 3s
19121 This specifies the time to wait between attempts to lock the file. See below
19122 for details of locking.
19123
19124
19125 .option lock_retries appendfile integer 10
19126 This specifies the maximum number of attempts to lock the file. A value of zero
19127 is treated as 1. See below for details of locking.
19128
19129
19130 .option lockfile_mode appendfile "octal integer" 0600
19131 This specifies the mode of the created lock file, when a lock file is being
19132 used (see &%use_lockfile%& and &%use_mbx_lock%&).
19133
19134
19135 .option lockfile_timeout appendfile time 30m
19136 .cindex "timeout" "mailbox locking"
19137 When a lock file is being used (see &%use_lockfile%&), if a lock file already
19138 exists and is older than this value, it is assumed to have been left behind by
19139 accident, and Exim attempts to remove it.
19140
19141
19142 .option mailbox_filecount appendfile string&!! unset
19143 .cindex "mailbox" "specifying size of"
19144 .cindex "size" "of mailbox"
19145 If this option is set, it is expanded, and the result is taken as the current
19146 number of files in the mailbox. It must be a decimal number, optionally
19147 followed by K or M. This provides a way of obtaining this information from an
19148 external source that maintains the data.
19149
19150
19151 .option mailbox_size appendfile string&!! unset
19152 .cindex "mailbox" "specifying size of"
19153 .cindex "size" "of mailbox"
19154 If this option is set, it is expanded, and the result is taken as the current
19155 size the mailbox. It must be a decimal number, optionally followed by K or M.
19156 This provides a way of obtaining this information from an external source that
19157 maintains the data. This is likely to be helpful for maildir deliveries where
19158 it is computationally expensive to compute the size of a mailbox.
19159
19160
19161
19162 .option maildir_format appendfile boolean false
19163 .cindex "maildir format" "specifying"
19164 If this option is set with the &%directory%& option, the delivery is into a new
19165 file, in the &"maildir"& format that is used by other mail software. When the
19166 transport is activated directly from a &(redirect)& router (for example, the
19167 &(address_file)& transport in the default configuration), setting
19168 &%maildir_format%& causes the path received from the router to be treated as a
19169 directory, whether or not it ends with &`/`&. This option is available only if
19170 SUPPORT_MAILDIR is present in &_Local/Makefile_&. See section
19171 &<<SECTmaildirdelivery>>& below for further details.
19172
19173
19174 .option maildir_quota_directory_regex appendfile string "See below"
19175 .cindex "maildir format" "quota; directories included in"
19176 .cindex "quota" "maildir; directories included in"
19177 This option is relevant only when &%maildir_use_size_file%& is set. It defines
19178 a regular expression for specifying directories, relative to the quota
19179 directory (see &%quota_directory%&), that should be included in the quota
19180 calculation. The default value is:
19181 .code
19182 maildir_quota_directory_regex = ^(?:cur|new|\..*)$
19183 .endd
19184 This includes the &_cur_& and &_new_& directories, and any maildir++ folders
19185 (directories whose names begin with a dot). If you want to exclude the
19186 &_Trash_&
19187 folder from the count (as some sites do), you need to change this setting to
19188 .code
19189 maildir_quota_directory_regex = ^(?:cur|new|\.(?!Trash).*)$
19190 .endd
19191 This uses a negative lookahead in the regular expression to exclude the
19192 directory whose name is &_.Trash_&. When a directory is excluded from quota
19193 calculations, quota processing is bypassed for any messages that are delivered
19194 directly into that directory.
19195
19196
19197 .option maildir_retries appendfile integer 10
19198 This option specifies the number of times to retry when writing a file in
19199 &"maildir"& format. See section &<<SECTmaildirdelivery>>& below.
19200
19201
19202 .option maildir_tag appendfile string&!! unset
19203 This option applies only to deliveries in maildir format, and is described in
19204 section &<<SECTmaildirdelivery>>& below.
19205
19206
19207 .option maildir_use_size_file appendfile boolean false
19208 .cindex "maildir format" "&_maildirsize_& file"
19209 Setting this option true enables support for &_maildirsize_& files. Exim
19210 creates a &_maildirsize_& file in a maildir if one does not exist, taking the
19211 quota from the &%quota%& option of the transport. If &%quota%& is unset, the
19212 value is zero. See &%maildir_quota_directory_regex%& above and section
19213 &<<SECTmaildirdelivery>>& below for further details.
19214
19215 .option maildirfolder_create_regex appendfile string unset
19216 .cindex "maildir format" "&_maildirfolder_& file"
19217 .cindex "&_maildirfolder_&, creating"
19218 The value of this option is a regular expression. If it is unset, it has no
19219 effect. Otherwise, before a maildir delivery takes place, the pattern is
19220 matched against the name of the maildir directory, that is, the directory
19221 containing the &_new_& and &_tmp_& subdirectories that will be used for the
19222 delivery. If there is a match, Exim checks for the existence of a file called
19223 &_maildirfolder_& in the directory, and creates it if it does not exist.
19224 See section &<<SECTmaildirdelivery>>& for more details.
19225
19226
19227 .option mailstore_format appendfile boolean false
19228 .cindex "mailstore format" "specifying"
19229 If this option is set with the &%directory%& option, the delivery is into two
19230 new files in  &"mailstore"& format. The option is available only if
19231 SUPPORT_MAILSTORE is present in &_Local/Makefile_&. See section &<<SECTopdir>>&
19232 below for further details.
19233
19234
19235 .option mailstore_prefix appendfile string&!! unset
19236 This option applies only to deliveries in mailstore format, and is described in
19237 section &<<SECTopdir>>& below.
19238
19239
19240 .option mailstore_suffix appendfile string&!! unset
19241 This option applies only to deliveries in mailstore format, and is described in
19242 section &<<SECTopdir>>& below.
19243
19244
19245 .option mbx_format appendfile boolean false
19246 .cindex "locking files"
19247 .cindex "file" "locking"
19248 .cindex "file" "MBX format"
19249 .cindex "MBX format" "specifying"
19250 This option is available only if Exim has been compiled with SUPPORT_MBX
19251 set in &_Local/Makefile_&. If &%mbx_format%& is set with the &%file%& option,
19252 the message is appended to the mailbox file in MBX format instead of
19253 traditional Unix format. This format is supported by Pine4 and its associated
19254 IMAP and POP daemons, by means of the &'c-client'& library that they all use.
19255
19256 &*Note*&: The &%message_prefix%& and &%message_suffix%& options are not
19257 automatically changed by the use of &%mbx_format%&. They should normally be set
19258 empty when using MBX format, so this option almost always appears in this
19259 combination:
19260 .code
19261 mbx_format = true
19262 message_prefix =
19263 message_suffix =
19264 .endd
19265 If none of the locking options are mentioned in the configuration,
19266 &%use_mbx_lock%& is assumed and the other locking options default to false. It
19267 is possible to specify the other kinds of locking with &%mbx_format%&, but
19268 &%use_fcntl_lock%& and &%use_mbx_lock%& are mutually exclusive. MBX locking
19269 interworks with &'c-client'&, providing for shared access to the mailbox. It
19270 should not be used if any program that does not use this form of locking is
19271 going to access the mailbox, nor should it be used if the mailbox file is NFS
19272 mounted, because it works only when the mailbox is accessed from a single host.
19273
19274 If you set &%use_fcntl_lock%& with an MBX-format mailbox, you cannot use
19275 the standard version of &'c-client'&, because as long as it has a mailbox open
19276 (this means for the whole of a Pine or IMAP session), Exim will not be able to
19277 append messages to it.
19278
19279
19280 .option message_prefix appendfile string&!! "see below"
19281 .cindex "&""From""& line"
19282 The string specified here is expanded and output at the start of every message.
19283 The default is unset unless &%file%& is specified and &%use_bsmtp%& is not set,
19284 in which case it is:
19285 .code
19286 message_prefix = "From ${if def:return_path{$return_path}\
19287   {MAILER-DAEMON}} $tod_bsdinbox\n"
19288 .endd
19289
19290
19291 .option message_suffix appendfile string&!! "see below"
19292 The string specified here is expanded and output at the end of every message.
19293 The default is unset unless &%file%& is specified and &%use_bsmtp%& is not set,
19294 in which case it is a single newline character. The suffix can be suppressed by
19295 setting
19296 .code
19297 message_suffix =
19298 .endd
19299
19300 .option mode appendfile "octal integer" 0600
19301 If the output file is created, it is given this mode. If it already exists and
19302 has wider permissions, they are reduced to this mode. If it has narrower
19303 permissions, an error occurs unless &%mode_fail_narrower%& is false. However,
19304 if the delivery is the result of a &%save%& command in a filter file specifing
19305 a particular mode, the mode of the output file is always forced to take that
19306 value, and this option is ignored.
19307
19308
19309 .option mode_fail_narrower appendfile boolean true
19310 This option applies in the case when an existing mailbox file has a narrower
19311 mode than that specified by the &%mode%& option. If &%mode_fail_narrower%& is
19312 true, the delivery is deferred (&"mailbox has the wrong mode"&); otherwise Exim
19313 continues with the delivery attempt, using the existing mode of the file.
19314
19315
19316 .option notify_comsat appendfile boolean false
19317 If this option is true, the &'comsat'& daemon is notified after every
19318 successful delivery to a user mailbox. This is the daemon that notifies logged
19319 on users about incoming mail.
19320
19321
19322 .option quota appendfile string&!! unset
19323 .cindex "quota" "imposed by Exim"
19324 This option imposes a limit on the size of the file to which Exim is appending,
19325 or to the total space used in the directory tree when the &%directory%& option
19326 is set. In the latter case, computation of the space used is expensive, because
19327 all the files in the directory (and any sub-directories) have to be
19328 individually inspected and their sizes summed. (See &%quota_size_regex%& and
19329 &%maildir_use_size_file%& for ways to avoid this in environments where users
19330 have no shell access to their mailboxes).
19331
19332 As there is no interlock against two simultaneous deliveries into a
19333 multi-file mailbox, it is possible for the quota to be overrun in this case.
19334 For single-file mailboxes, of course, an interlock is a necessity.
19335
19336 A file's size is taken as its &'used'& value. Because of blocking effects, this
19337 may be a lot less than the actual amount of disk space allocated to the file.
19338 If the sizes of a number of files are being added up, the rounding effect can
19339 become quite noticeable, especially on systems that have large block sizes.
19340 Nevertheless, it seems best to stick to the &'used'& figure, because this is
19341 the obvious value which users understand most easily.
19342
19343 The value of the option is expanded, and must then be a numerical value
19344 (decimal point allowed), optionally followed by one of the letters K, M, or G,
19345 for kilobytes, megabytes, or gigabytes. If Exim is running on a system with
19346 large file support (Linux and FreeBSD have this), mailboxes larger than 2G can
19347 be handled.
19348
19349 &*Note*&: A value of zero is interpreted as &"no quota"&.
19350
19351 The expansion happens while Exim is running as root, before it changes uid for
19352 the delivery. This means that files that are inaccessible to the end user can
19353 be used to hold quota values that are looked up in the expansion. When delivery
19354 fails because this quota is exceeded, the handling of the error is as for
19355 system quota failures.
19356
19357 By default, Exim's quota checking mimics system quotas, and restricts the
19358 mailbox to the specified maximum size, though the value is not accurate to the
19359 last byte, owing to separator lines and additional headers that may get added
19360 during message delivery. When a mailbox is nearly full, large messages may get
19361 refused even though small ones are accepted, because the size of the current
19362 message is added to the quota when the check is made. This behaviour can be
19363 changed by setting &%quota_is_inclusive%& false. When this is done, the check
19364 for exceeding the quota does not include the current message. Thus, deliveries
19365 continue until the quota has been exceeded; thereafter, no further messages are
19366 delivered. See also &%quota_warn_threshold%&.
19367
19368
19369 .option quota_directory appendfile string&!! unset
19370 This option defines the directory to check for quota purposes when delivering
19371 into individual files. The default is the delivery directory, or, if a file
19372 called &_maildirfolder_& exists in a maildir directory, the parent of the
19373 delivery directory.
19374
19375
19376 .option quota_filecount appendfile string&!! 0
19377 This option applies when the &%directory%& option is set. It limits the total
19378 number of files in the directory (compare the inode limit in system quotas). It
19379 can only be used if &%quota%& is also set. The value is expanded; an expansion
19380 failure causes delivery to be deferred. A value of zero is interpreted as
19381 &"no quota"&.
19382
19383
19384 .option quota_is_inclusive appendfile boolean true
19385 See &%quota%& above.
19386
19387
19388 .option quota_size_regex appendfile string unset
19389 This option applies when one of the delivery modes that writes a separate file
19390 for each message is being used. When Exim wants to find the size of one of
19391 these files in order to test the quota, it first checks &%quota_size_regex%&.
19392 If this is set to a regular expression that matches the file name, and it
19393 captures one string, that string is interpreted as a representation of the
19394 file's size. The value of &%quota_size_regex%& is not expanded.
19395
19396 This feature is useful only when users have no shell access to their mailboxes
19397 &-- otherwise they could defeat the quota simply by renaming the files. This
19398 facility can be used with maildir deliveries, by setting &%maildir_tag%& to add
19399 the file length to the file name. For example:
19400 .code
19401 maildir_tag = ,S=$message_size
19402 quota_size_regex = ,S=(\d+)
19403 .endd
19404 An alternative to &$message_size$& is &$message_linecount$&, which contains the
19405 number of lines in the message.
19406
19407 The regular expression should not assume that the length is at the end of the
19408 file name (even though &%maildir_tag%& puts it there) because maildir MUAs
19409 sometimes add other information onto the ends of message file names.
19410
19411
19412
19413 .option quota_warn_message appendfile string&!! "see below"
19414 See below for the use of this option. If it is not set when
19415 &%quota_warn_threshold%& is set, it defaults to
19416 .code
19417 quota_warn_message = "\
19418   To: $local_part@$domain\n\
19419   Subject: Your mailbox\n\n\
19420   This message is automatically created \
19421   by mail delivery software.\n\n\
19422   The size of your mailbox has exceeded \
19423   a warning threshold that is\n\
19424   set by the system administrator.\n"
19425 .endd
19426
19427
19428 .option quota_warn_threshold appendfile string&!! 0
19429 .cindex "quota" "warning threshold"
19430 .cindex "mailbox" "size warning"
19431 .cindex "size" "of mailbox"
19432 This option is expanded in the same way as &%quota%& (see above). If the
19433 resulting value is greater than zero, and delivery of the message causes the
19434 size of the file or total space in the directory tree to cross the given
19435 threshold, a warning message is sent. If &%quota%& is also set, the threshold
19436 may be specified as a percentage of it by following the value with a percent
19437 sign. For example:
19438 .code
19439 quota = 10M
19440 quota_warn_threshold = 75%
19441 .endd
19442 If &%quota%& is not set, a setting of &%quota_warn_threshold%& that ends with a
19443 percent sign is ignored.
19444
19445 The warning message itself is specified by the &%quota_warn_message%& option,
19446 and it must start with a &'To:'& header line containing the recipient(s) of the
19447 warning message. These do not necessarily have to include the recipient(s) of
19448 the original message. A &'Subject:'& line should also normally be supplied. You
19449 can include any other header lines that you want. If you do not include a
19450 &'From:'& line, the default is:
19451 .code
19452 From: Mail Delivery System <mailer-daemon@$qualify_domain_sender>
19453 .endd
19454 .oindex &%errors_reply_to%&
19455 If you supply a &'Reply-To:'& line, it overrides the global &%errors_reply_to%&
19456 option.
19457
19458 The &%quota%& option does not have to be set in order to use this option; they
19459 are independent of one another except when the threshold is specified as a
19460 percentage.
19461
19462
19463 .option use_bsmtp appendfile boolean false
19464 .cindex "envelope sender"
19465 If this option is set true, &(appendfile)& writes messages in &"batch SMTP"&
19466 format, with the envelope sender and recipient(s) included as SMTP commands. If
19467 you want to include a leading HELO command with such messages, you can do
19468 so by setting the &%message_prefix%& option. See section &<<SECTbatchSMTP>>&
19469 for details of batch SMTP.
19470
19471
19472 .option use_crlf appendfile boolean false
19473 .cindex "carriage return"
19474 .cindex "linefeed"
19475 This option causes lines to be terminated with the two-character CRLF sequence
19476 (carriage return, linefeed) instead of just a linefeed character. In the case
19477 of batched SMTP, the byte sequence written to the file is then an exact image
19478 of what would be sent down a real SMTP connection.
19479
19480 The contents of the &%message_prefix%& and &%message_suffix%& options are
19481 written verbatim, so must contain their own carriage return characters if these
19482 are needed. In cases where these options have non-empty defaults, the values
19483 end with a single linefeed, so they must be changed to end with &`\r\n`& if
19484 &%use_crlf%& is set.
19485
19486
19487 .option use_fcntl_lock appendfile boolean "see below"
19488 This option controls the use of the &[fcntl()]& function to lock a file for
19489 exclusive use when a message is being appended. It is set by default unless
19490 &%use_flock_lock%& is set. Otherwise, it should be turned off only if you know
19491 that all your MUAs use lock file locking. When both &%use_fcntl_lock%& and
19492 &%use_flock_lock%& are unset, &%use_lockfile%& must be set.
19493
19494
19495 .option use_flock_lock appendfile boolean false
19496 This option is provided to support the use of &[flock()]& for file locking, for
19497 the few situations where it is needed. Most modern operating systems support
19498 &[fcntl()]& and &[lockf()]& locking, and these two functions interwork with
19499 each other. Exim uses &[fcntl()]& locking by default.
19500
19501 This option is required only if you are using an operating system where
19502 &[flock()]& is used by programs that access mailboxes (typically MUAs), and
19503 where &[flock()]& does not correctly interwork with &[fcntl()]&. You can use
19504 both &[fcntl()]& and &[flock()]& locking simultaneously if you want.
19505
19506 .cindex "Solaris" "&[flock()]& support"
19507 Not all operating systems provide &[flock()]&. Some versions of Solaris do not
19508 have it (and some, I think, provide a not quite right version built on top of
19509 &[lockf()]&). If the OS does not have &[flock()]&, Exim will be built without
19510 the ability to use it, and any attempt to do so will cause a configuration
19511 error.
19512
19513 &*Warning*&: &[flock()]& locks do not work on NFS files (unless &[flock()]&
19514 is just being mapped onto &[fcntl()]& by the OS).
19515
19516
19517 .option use_lockfile appendfile boolean "see below"
19518 If this option is turned off, Exim does not attempt to create a lock file when
19519 appending to a mailbox file. In this situation, the only locking is by
19520 &[fcntl()]&. You should only turn &%use_lockfile%& off if you are absolutely
19521 sure that every MUA that is ever going to look at your users' mailboxes uses
19522 &[fcntl()]& rather than a lock file, and even then only when you are not
19523 delivering over NFS from more than one host.
19524
19525 .cindex "NFS" "lock file"
19526 In order to append to an NFS file safely from more than one host, it is
19527 necessary to take out a lock &'before'& opening the file, and the lock file
19528 achieves this. Otherwise, even with &[fcntl()]& locking, there is a risk of
19529 file corruption.
19530
19531 The &%use_lockfile%& option is set by default unless &%use_mbx_lock%& is set.
19532 It is not possible to turn both &%use_lockfile%& and &%use_fcntl_lock%& off,
19533 except when &%mbx_format%& is set.
19534
19535
19536 .option use_mbx_lock appendfile boolean "see below"
19537 This option is available only if Exim has been compiled with SUPPORT_MBX
19538 set in &_Local/Makefile_&. Setting the option specifies that special MBX
19539 locking rules be used. It is set by default if &%mbx_format%& is set and none
19540 of the locking options are mentioned in the configuration. The locking rules
19541 are the same as are used by the &'c-client'& library that underlies Pine and
19542 the IMAP4 and POP daemons that come with it (see the discussion below). The
19543 rules allow for shared access to the mailbox. However, this kind of locking
19544 does not work when the mailbox is NFS mounted.
19545
19546 You can set &%use_mbx_lock%& with either (or both) of &%use_fcntl_lock%& and
19547 &%use_flock_lock%& to control what kind of locking is used in implementing the
19548 MBX locking rules. The default is to use &[fcntl()]& if &%use_mbx_lock%& is set
19549 without &%use_fcntl_lock%& or &%use_flock_lock%&.
19550
19551
19552
19553
19554 .section "Operational details for appending" "SECTopappend"
19555 .cindex "appending to a file"
19556 .cindex "file" "appending"
19557 Before appending to a file, the following preparations are made:
19558
19559 .ilist
19560 If the name of the file is &_/dev/null_&, no action is taken, and a success
19561 return is given.
19562
19563 .next
19564 .cindex "directory creation"
19565 If any directories on the file's path are missing, Exim creates them if the
19566 &%create_directory%& option is set. A created directory's mode is given by the
19567 &%directory_mode%& option.
19568
19569 .next
19570 If &%file_format%& is set, the format of an existing file is checked. If this
19571 indicates that a different transport should be used, control is passed to that
19572 transport.
19573
19574 .next
19575 .cindex "file" "locking"
19576 .cindex "locking files"
19577 .cindex "NFS" "lock file"
19578 If &%use_lockfile%& is set, a lock file is built in a way that will work
19579 reliably over NFS, as follows:
19580
19581 .olist
19582 Create a &"hitching post"& file whose name is that of the lock file with the
19583 current time, primary host name, and process id added, by opening for writing
19584 as a new file. If this fails with an access error, delivery is deferred.
19585 .next
19586 Close the hitching post file, and hard link it to the lock file name.
19587 .next
19588 If the call to &[link()]& succeeds, creation of the lock file has succeeded.
19589 Unlink the hitching post name.
19590 .next
19591 Otherwise, use &[stat()]& to get information about the hitching post file, and
19592 then unlink hitching post name. If the number of links is exactly two, creation
19593 of the lock file succeeded but something (for example, an NFS server crash and
19594 restart) caused this fact not to be communicated to the &[link()]& call.
19595 .next
19596 If creation of the lock file failed, wait for &%lock_interval%& and try again,
19597 up to &%lock_retries%& times. However, since any program that writes to a
19598 mailbox should complete its task very quickly, it is reasonable to time out old
19599 lock files that are normally the result of user agent and system crashes. If an
19600 existing lock file is older than &%lockfile_timeout%& Exim attempts to unlink
19601 it before trying again.
19602 .endlist olist
19603
19604 .next
19605 A call is made to &[lstat()]& to discover whether the main file exists, and if
19606 so, what its characteristics are. If &[lstat()]& fails for any reason other
19607 than non-existence, delivery is deferred.
19608
19609 .next
19610 .cindex "symbolic link" "to mailbox"
19611 .cindex "mailbox" "symbolic link"
19612 If the file does exist and is a symbolic link, delivery is deferred, unless the
19613 &%allow_symlink%& option is set, in which case the ownership of the link is
19614 checked, and then &[stat()]& is called to find out about the real file, which
19615 is then subjected to the checks below. The check on the top-level link
19616 ownership prevents one user creating a link for another's mailbox in a sticky
19617 directory, though allowing symbolic links in this case is definitely not a good
19618 idea. If there is a chain of symbolic links, the intermediate ones are not
19619 checked.
19620
19621 .next
19622 If the file already exists but is not a regular file, or if the file's owner
19623 and group (if the group is being checked &-- see &%check_group%& above) are
19624 different from the user and group under which the delivery is running,
19625 delivery is deferred.
19626
19627 .next
19628 If the file's permissions are more generous than specified, they are reduced.
19629 If they are insufficient, delivery is deferred, unless &%mode_fail_narrower%&
19630 is set false, in which case the delivery is tried using the existing
19631 permissions.
19632
19633 .next
19634 The file's inode number is saved, and the file is then opened for appending.
19635 If this fails because the file has vanished, &(appendfile)& behaves as if it
19636 hadn't existed (see below). For any other failures, delivery is deferred.
19637
19638 .next
19639 If the file is opened successfully, check that the inode number hasn't
19640 changed, that it is still a regular file, and that the owner and permissions
19641 have not changed. If anything is wrong, defer delivery and freeze the message.
19642
19643 .next
19644 If the file did not exist originally, defer delivery if the &%file_must_exist%&
19645 option is set. Otherwise, check that the file is being created in a permitted
19646 directory if the &%create_file%& option is set (deferring on failure), and then
19647 open for writing as a new file, with the O_EXCL and O_CREAT options,
19648 except when dealing with a symbolic link (the &%allow_symlink%& option must be
19649 set). In this case, which can happen if the link points to a non-existent file,
19650 the file is opened for writing using O_CREAT but not O_EXCL, because
19651 that prevents link following.
19652
19653 .next
19654 .cindex "loop" "while file testing"
19655 If opening fails because the file exists, obey the tests given above for
19656 existing files. However, to avoid looping in a situation where the file is
19657 being continuously created and destroyed, the exists/not-exists loop is broken
19658 after 10 repetitions, and the message is then frozen.
19659
19660 .next
19661 If opening fails with any other error, defer delivery.
19662
19663 .next
19664 .cindex "file" "locking"
19665 .cindex "locking files"
19666 Once the file is open, unless both &%use_fcntl_lock%& and &%use_flock_lock%&
19667 are false, it is locked using &[fcntl()]& or &[flock()]& or both. If
19668 &%use_mbx_lock%& is false, an exclusive lock is requested in each case.
19669 However, if &%use_mbx_lock%& is true, Exim takes out a shared lock on the open
19670 file, and an exclusive lock on the file whose name is
19671 .code
19672 /tmp/.<device-number>.<inode-number>
19673 .endd
19674 using the device and inode numbers of the open mailbox file, in accordance with
19675 the MBX locking rules. This file is created with a mode that is specified by
19676 the &%lockfile_mode%& option.
19677
19678 If Exim fails to lock the file, there are two possible courses of action,
19679 depending on the value of the locking timeout. This is obtained from
19680 &%lock_fcntl_timeout%& or &%lock_flock_timeout%&, as appropriate.
19681
19682 If the timeout value is zero, the file is closed, Exim waits for
19683 &%lock_interval%&, and then goes back and re-opens the file as above and tries
19684 to lock it again. This happens up to &%lock_retries%& times, after which the
19685 delivery is deferred.
19686
19687 If the timeout has a value greater than zero, blocking calls to &[fcntl()]& or
19688 &[flock()]& are used (with the given timeout), so there has already been some
19689 waiting involved by the time locking fails. Nevertheless, Exim does not give up
19690 immediately. It retries up to
19691 .code
19692 (lock_retries * lock_interval) / <timeout>
19693 .endd
19694 times (rounded up).
19695 .endlist
19696
19697 At the end of delivery, Exim closes the file (which releases the &[fcntl()]&
19698 and/or &[flock()]& locks) and then deletes the lock file if one was created.
19699
19700
19701 .section "Operational details for delivery to a new file" "SECTopdir"
19702 .cindex "delivery" "to single file"
19703 .cindex "&""From""& line"
19704 When the &%directory%& option is set instead of &%file%&, each message is
19705 delivered into a newly-created file or set of files. When &(appendfile)& is
19706 activated directly from a &(redirect)& router, neither &%file%& nor
19707 &%directory%& is normally set, because the path for delivery is supplied by the
19708 router. (See for example, the &(address_file)& transport in the default
19709 configuration.) In this case, delivery is to a new file if either the path name
19710 ends in &`/`&, or the &%maildir_format%& or &%mailstore_format%& option is set.
19711
19712 No locking is required while writing the message to a new file, so the various
19713 locking options of the transport are ignored. The &"From"& line that by default
19714 separates messages in a single file is not normally needed, nor is the escaping
19715 of message lines that start with &"From"&, and there is no need to ensure a
19716 newline at the end of each message. Consequently, the default values for
19717 &%check_string%&, &%message_prefix%&, and &%message_suffix%& are all unset when
19718 any of &%directory%&, &%maildir_format%&, or &%mailstore_format%& is set.
19719
19720 If Exim is required to check a &%quota%& setting, it adds up the sizes of all
19721 the files in the delivery directory by default. However, you can specify a
19722 different directory by setting &%quota_directory%&. Also, for maildir
19723 deliveries (see below) the &_maildirfolder_& convention is honoured.
19724
19725
19726 .cindex "maildir format"
19727 .cindex "mailstore format"
19728 There are three different ways in which delivery to individual files can be
19729 done, controlled by the settings of the &%maildir_format%& and
19730 &%mailstore_format%& options. Note that code to support maildir or mailstore
19731 formats is not included in the binary unless SUPPORT_MAILDIR or
19732 SUPPORT_MAILSTORE, respectively, is set in &_Local/Makefile_&.
19733
19734 .cindex "directory creation"
19735 In all three cases an attempt is made to create the directory and any necessary
19736 sub-directories if they do not exist, provided that the &%create_directory%&
19737 option is set (the default). The location of a created directory can be
19738 constrained by setting &%create_file%&. A created directory's mode is given by
19739 the &%directory_mode%& option. If creation fails, or if the
19740 &%create_directory%& option is not set when creation is required, delivery is
19741 deferred.
19742
19743
19744
19745 .section "Maildir delivery" "SECTmaildirdelivery"
19746 .cindex "maildir format" "description of"
19747 If the &%maildir_format%& option is true, Exim delivers each message by writing
19748 it to a file whose name is &_tmp/<stime>.H<mtime>P<pid>.<host>_& in the
19749 directory that is defined by the &%directory%& option (the &"delivery
19750 directory"&). If the delivery is successful, the file is renamed into the
19751 &_new_& subdirectory.
19752
19753 In the file name, <&'stime'&> is the current time of day in seconds, and
19754 <&'mtime'&> is the microsecond fraction of the time. After a maildir delivery,
19755 Exim checks that the time-of-day clock has moved on by at least one microsecond
19756 before terminating the delivery process. This guarantees uniqueness for the
19757 file name. However, as a precaution, Exim calls &[stat()]& for the file before
19758 opening it. If any response other than ENOENT (does not exist) is given,
19759 Exim waits 2 seconds and tries again, up to &%maildir_retries%& times.
19760
19761 Before Exim carries out a maildir delivery, it ensures that subdirectories
19762 called &_new_&, &_cur_&, and &_tmp_& exist in the delivery directory. If they
19763 do not exist, Exim tries to create them and any superior directories in their
19764 path, subject to the &%create_directory%& and &%create_file%& options. If the
19765 &%maildirfolder_create_regex%& option is set, and the regular expression it
19766 contains matches the delivery directory, Exim also ensures that a file called
19767 &_maildirfolder_& exists in the delivery directory. If a missing directory or
19768 &_maildirfolder_& file cannot be created, delivery is deferred.
19769
19770 These features make it possible to use Exim to create all the necessary files
19771 and directories in a maildir mailbox, including subdirectories for maildir++
19772 folders. Consider this example:
19773 .code
19774 maildir_format = true
19775 directory = /var/mail/$local_part\
19776            ${if eq{$local_part_suffix}{}{}\
19777            {/.${substr_1:$local_part_suffix}}}
19778 maildirfolder_create_regex = /\.[^/]+$
19779 .endd
19780 If &$local_part_suffix$& is empty (there was no suffix for the local part),
19781 delivery is into a toplevel maildir with a name like &_/var/mail/pimbo_& (for
19782 the user called &'pimbo'&). The pattern in &%maildirfolder_create_regex%& does
19783 not match this name, so Exim will not look for or create the file
19784 &_/var/mail/pimbo/maildirfolder_&, though it will create
19785 &_/var/mail/pimbo/{cur,new,tmp}_& if necessary.
19786
19787 However, if &$local_part_suffix$& contains &`-eximusers`& (for example),
19788 delivery is into the maildir++ folder &_/var/mail/pimbo/.eximusers_&, which
19789 does match &%maildirfolder_create_regex%&. In this case, Exim will create
19790 &_/var/mail/pimbo/.eximusers/maildirfolder_& as well as the three maildir
19791 directories &_/var/mail/pimbo/.eximusers/{cur,new,tmp}_&.
19792
19793 &*Warning:*& Take care when setting &%maildirfolder_create_regex%& that it does
19794 not inadvertently match the toplevel maildir directory, because a
19795 &_maildirfolder_& file at top level would completely break quota calculations.
19796
19797 .cindex "quota" "in maildir delivery"
19798 .cindex "maildir++"
19799 If Exim is required to check a &%quota%& setting before a maildir delivery, and
19800 &%quota_directory%& is not set, it looks for a file called &_maildirfolder_& in
19801 the maildir directory (alongside &_new_&, &_cur_&, &_tmp_&). If this exists,
19802 Exim assumes the directory is a maildir++ folder directory, which is one level
19803 down from the user's top level mailbox directory. This causes it to start at
19804 the parent directory instead of the current directory when calculating the
19805 amount of space used.
19806
19807 One problem with delivering into a multi-file mailbox is that it is
19808 computationally expensive to compute the size of the mailbox for quota
19809 checking. Various approaches have been taken to reduce the amount of work
19810 needed. The next two sections describe two of them. A third alternative is to
19811 use some external process for maintaining the size data, and use the expansion
19812 of the &%mailbox_size%& option as a way of importing it into Exim.
19813
19814
19815
19816
19817 .section "Using tags to record message sizes"
19818 If &%maildir_tag%& is set, the string is expanded for each delivery.
19819 When the maildir file is renamed into the &_new_& sub-directory, the
19820 tag is added to its name. However, if adding the tag takes the length of the
19821 name to the point where the test &[stat()]& call fails with ENAMETOOLONG,
19822 the tag is dropped and the maildir file is created with no tag.
19823
19824 .cindex "&$message_size$&"
19825 Tags can be used to encode the size of files in their names; see
19826 &%quota_size_regex%& above for an example. The expansion of &%maildir_tag%&
19827 happens after the message has been written. The value of the &$message_size$&
19828 variable is set to the number of bytes actually written. If the expansion is
19829 forced to fail, the tag is ignored, but a non-forced failure causes delivery to
19830 be deferred. The expanded tag may contain any printing characters except &"/"&.
19831 Non-printing characters in the string are ignored; if the resulting string is
19832 empty, it is ignored. If it starts with an alphanumeric character, a leading
19833 colon is inserted.
19834
19835
19836
19837 .section "Using a maildirsize file"
19838 .cindex "quota" "in maildir delivery"
19839 .cindex "maildir format" "&_maildirsize_& file"
19840 If &%maildir_use_size_file%& is true, Exim implements the maildir++ rules for
19841 storing quota and message size information in a file called &_maildirsize_&
19842 within the toplevel maildir directory. If this file does not exist, Exim
19843 creates it, setting the quota from the &%quota%& option of the transport. If
19844 the maildir directory itself does not exist, it is created before any attempt
19845 to write a &_maildirsize_& file.
19846
19847 The &_maildirsize_& file is used to hold information about the sizes of
19848 messages in the maildir, thus speeding up quota calculations. The quota value
19849 in the file is just a cache; if the quota is changed in the transport, the new
19850 value overrides the cached value when the next message is delivered. The cache
19851 is maintained for the benefit of other programs that access the maildir and
19852 need to know the quota.
19853
19854 If the &%quota%& option in the transport is unset or zero, the &_maildirsize_&
19855 file is maintained (with a zero quota setting), but no quota is imposed.
19856
19857 A regular expression is available for controlling which directories in the
19858 maildir participate in quota calculations when a &_maildirsizefile_& is in use.
19859 See the description of the &%maildir_quota_directory_regex%& option above for
19860 details.
19861
19862
19863 .section "Mailstore delivery"
19864 .cindex "mailstore format" "description of"
19865 If the &%mailstore_format%& option is true, each message is written as two
19866 files in the given directory. A unique base name is constructed from the
19867 message id and the current delivery process, and the files that are written use
19868 this base name plus the suffixes &_.env_& and &_.msg_&. The &_.env_& file
19869 contains the message's envelope, and the &_.msg_& file contains the message
19870 itself. The base name is placed in the variable &$mailstore_basename$&.
19871
19872 During delivery, the envelope is first written to a file with the suffix
19873 &_.tmp_&. The &_.msg_& file is then written, and when it is complete, the
19874 &_.tmp_& file is renamed as the &_.env_& file. Programs that access messages in
19875 mailstore format should wait for the presence of both a &_.msg_& and a &_.env_&
19876 file before accessing either of them. An alternative approach is to wait for
19877 the absence of a &_.tmp_& file.
19878
19879 The envelope file starts with any text defined by the &%mailstore_prefix%&
19880 option, expanded and terminated by a newline if there isn't one. Then follows
19881 the sender address on one line, then all the recipient addresses, one per line.
19882 There can be more than one recipient only if the &%batch_max%& option is set
19883 greater than one. Finally, &%mailstore_suffix%& is expanded and the result
19884 appended to the file, followed by a newline if it does not end with one.
19885
19886 If expansion of &%mailstore_prefix%& or &%mailstore_suffix%& ends with a forced
19887 failure, it is ignored. Other expansion errors are treated as serious
19888 configuration errors, and delivery is deferred. The variable
19889 &$mailstore_basename$& is available for use during these expansions.
19890
19891
19892 .section "Non-special new file delivery"
19893 If neither &%maildir_format%& nor &%mailstore_format%& is set, a single new
19894 file is created directly in the named directory. For example, when delivering
19895 messages into files in batched SMTP format for later delivery to some host (see
19896 section &<<SECTbatchSMTP>>&), a setting such as
19897 .code
19898 directory = /var/bsmtp/$host
19899 .endd
19900 might be used. A message is written to a file with a temporary name, which is
19901 then renamed when the delivery is complete. The final name is obtained by
19902 expanding the contents of the &%directory_file%& option.
19903 .ecindex IIDapptra1
19904 .ecindex IIDapptra2
19905
19906
19907
19908
19909
19910
19911 . ////////////////////////////////////////////////////////////////////////////
19912 . ////////////////////////////////////////////////////////////////////////////
19913
19914 .chapter "The autoreply transport"
19915 .scindex IIDauttra1 "transports" "&(autoreply)&"
19916 .scindex IIDauttra2 "&(autoreply)& transport"
19917 The &(autoreply)& transport is not a true transport in that it does not cause
19918 the message to be transmitted. Instead, it generates a new mail message as an
19919 automatic reply to the incoming message. &'References:'& and
19920 &'Auto-Submitted:'& header lines are included. These are constructed according
19921 to the rules in RFCs 2822 and 3834, respectively.
19922
19923 If the router that passes the message to this transport does not have the
19924 &%unseen%& option set, the original message (for the current recipient) is not
19925 delivered anywhere. However, when the &%unseen%& option is set on the router
19926 that passes the message to this transport, routing of the address continues, so
19927 another router can set up a normal message delivery.
19928
19929
19930 The &(autoreply)& transport is usually run as the result of mail filtering, a
19931 &"vacation"& message being the standard example. However, it can also be run
19932 directly from a router like any other transport. To reduce the possibility of
19933 message cascades, messages created by the &(autoreply)& transport always have
19934 empty envelope sender addresses, like bounce messages.
19935
19936 The parameters of the message to be sent can be specified in the configuration
19937 by options described below. However, these are used only when the address
19938 passed to the transport does not contain its own reply information. When the
19939 transport is run as a consequence of a
19940 &%mail%&
19941 or &%vacation%& command in a filter file, the parameters of the message are
19942 supplied by the filter, and passed with the address. The transport's options
19943 that define the message are then ignored (so they are not usually set in this
19944 case). The message is specified entirely by the filter or by the transport; it
19945 is never built from a mixture of options. However, the &%file_optional%&,
19946 &%mode%&, and &%return_message%& options apply in all cases.
19947
19948 &(Autoreply)& is implemented as a local transport. When used as a result of a
19949 command in a user's filter file, &(autoreply)& normally runs under the uid and
19950 gid of the user, and with appropriate current and home directories (see chapter
19951 &<<CHAPenvironment>>&).
19952
19953 There is a subtle difference between routing a message to a &(pipe)& transport
19954 that generates some text to be returned to the sender, and routing it to an
19955 &(autoreply)& transport. This difference is noticeable only if more than one
19956 address from the same message is so handled. In the case of a pipe, the
19957 separate outputs from the different addresses are gathered up and returned to
19958 the sender in a single message, whereas if &(autoreply)& is used, a separate
19959 message is generated for each address that is passed to it.
19960
19961 Non-printing characters are not permitted in the header lines generated for the
19962 message that &(autoreply)& creates, with the exception of newlines that are
19963 immediately followed by white space. If any non-printing characters are found,
19964 the transport defers.
19965 Whether characters with the top bit set count as printing characters or not is
19966 controlled by the &%print_topbitchars%& global option.
19967
19968 If any of the generic options for manipulating headers (for example,
19969 &%headers_add%&) are set on an &(autoreply)& transport, they apply to the copy
19970 of the original message that is included in the generated message when
19971 &%return_message%& is set. They do not apply to the generated message itself.
19972
19973 .cindex "&$sender_address$&"
19974 If the &(autoreply)& transport receives return code 2 from Exim when it submits
19975 the message, indicating that there were no recipients, it does not treat this
19976 as an error. This means that autoreplies sent to &$sender_address$& when this
19977 is empty (because the incoming message is a bounce message) do not cause
19978 problems. They are just discarded.
19979
19980
19981
19982 .section "Private options for autoreply"
19983 .cindex "options" "&(autoreply)& transport"
19984
19985 .option bcc autoreply string&!! unset
19986 This specifies the addresses that are to receive &"blind carbon copies"& of the
19987 message when the message is specified by the transport.
19988
19989
19990 .option cc autoreply string&!! unset
19991 This specifies recipients of the message and the contents of the &'Cc:'& header
19992 when the message is specified by the transport.
19993
19994
19995 .option file autoreply string&!! unset
19996 The contents of the file are sent as the body of the message when the message
19997 is specified by the transport. If both &%file%& and &%text%& are set, the text
19998 string comes first.
19999
20000
20001 .option file_expand autoreply boolean false
20002 If this is set, the contents of the file named by the &%file%& option are
20003 subjected to string expansion as they are added to the message.
20004
20005
20006 .option file_optional autoreply boolean false
20007 If this option is true, no error is generated if the file named by the &%file%&
20008 option or passed with the address does not exist or cannot be read.
20009
20010
20011 .option from autoreply string&!! unset
20012 This specifies the contents of the &'From:'& header when the message is
20013 specified by the transport.
20014
20015
20016 .option headers autoreply string&!! unset
20017 This specifies additional RFC 2822 headers that are to be added to the message
20018 when the message is specified by the transport. Several can be given by using
20019 &"\n"& to separate them. There is no check on the format.
20020
20021
20022 .option log autoreply string&!! unset
20023 This option names a file in which a record of every message sent is logged when
20024 the message is specified by the transport.
20025
20026
20027 .option mode autoreply "octal integer" 0600
20028 If either the log file or the &"once"& file has to be created, this mode is
20029 used.
20030
20031
20032 .option never_mail autoreply "address list&!!" unset
20033 If any run of the transport creates a message with a recipient that matches any
20034 item in the list, that recipient is quietly discarded. If all recipients are
20035 discarded, no message is created. This applies both when the recipients are
20036 generated by a filter and when they are specified in the transport.
20037
20038
20039
20040 .option once autoreply string&!! unset
20041 This option names a file or DBM database in which a record of each &'To:'&
20042 recipient is kept when the message is specified by the transport. &*Note*&:
20043 This does not apply to &'Cc:'& or &'Bcc:'& recipients.
20044
20045 If &%once%& is unset, or is set to an empty string, the message is always sent.
20046 By default, if &%once%& is set to a non-empty file name, the message
20047 is not sent if a potential recipient is already listed in the database.
20048 However, if the &%once_repeat%& option specifies a time greater than zero, the
20049 message is sent if that much time has elapsed since a message was last sent to
20050 this recipient. A setting of zero time for &%once_repeat%& (the default)
20051 prevents a message from being sent a second time &-- in this case, zero means
20052 infinity.
20053
20054 If &%once_file_size%& is zero, a DBM database is used to remember recipients,
20055 and it is allowed to grow as large as necessary. If &%once_file_size%& is set
20056 greater than zero, it changes the way Exim implements the &%once%& option.
20057 Instead of using a DBM file to record every recipient it sends to, it uses a
20058 regular file, whose size will never get larger than the given value.
20059
20060 In the file, Exim keeps a linear list of recipient addresses and the times at
20061 which they were sent messages. If the file is full when a new address needs to
20062 be added, the oldest address is dropped. If &%once_repeat%& is not set, this
20063 means that a given recipient may receive multiple messages, but at
20064 unpredictable intervals that depend on the rate of turnover of addresses in the
20065 file. If &%once_repeat%& is set, it specifies a maximum time between repeats.
20066
20067
20068 .option once_file_size autoreply integer 0
20069 See &%once%& above.
20070
20071
20072 .option once_repeat autoreply time&!! 0s
20073 See &%once%& above.
20074 After expansion, the value of this option must be a valid time value.
20075
20076
20077 .option reply_to autoreply string&!! unset
20078 This specifies the contents of the &'Reply-To:'& header when the message is
20079 specified by the transport.
20080
20081
20082 .option return_message autoreply boolean false
20083 If this is set, a copy of the original message is returned with the new
20084 message, subject to the maximum size set in the &%return_size_limit%& global
20085 configuration option.
20086
20087
20088 .option subject autoreply string&!! unset
20089 This specifies the contents of the &'Subject:'& header when the message is
20090 specified by the transport. It is tempting to quote the original subject in
20091 automatic responses. For example:
20092 .code
20093 subject = Re: $h_subject:
20094 .endd
20095 There is a danger in doing this, however. It may allow a third party to
20096 subscribe your users to an opt-in mailing list, provided that the list accepts
20097 bounce messages as subscription confirmations. Well-managed lists require a
20098 non-bounce message to confirm a subscription, so the danger is relatively
20099 small.
20100
20101
20102
20103 .option text autoreply string&!! unset
20104 This specifies a single string to be used as the body of the message when the
20105 message is specified by the transport. If both &%text%& and &%file%& are set,
20106 the text comes first.
20107
20108
20109 .option to autoreply string&!! unset
20110 This specifies recipients of the message and the contents of the &'To:'& header
20111 when the message is specified by the transport.
20112 .ecindex IIDauttra1
20113 .ecindex IIDauttra2
20114
20115
20116
20117
20118 . ////////////////////////////////////////////////////////////////////////////
20119 . ////////////////////////////////////////////////////////////////////////////
20120
20121 .chapter "The lmtp transport" "CHAPLMTP"
20122 .cindex "transports" "&(lmtp)&"
20123 .cindex "&(lmtp)& transport"
20124 .cindex "LMTP" "over a pipe"
20125 .cindex "LMTP" "over a socket"
20126 The &(lmtp)& transport runs the LMTP protocol (RFC 2033) over a pipe to a
20127 specified command
20128 or by interacting with a Unix domain socket.
20129 This transport is something of a cross between the &(pipe)& and &(smtp)&
20130 transports. Exim also has support for using LMTP over TCP/IP; this is
20131 implemented as an option for the &(smtp)& transport. Because LMTP is expected
20132 to be of minority interest, the default build-time configure in &_src/EDITME_&
20133 has it commented out. You need to ensure that
20134 .code
20135 TRANSPORT_LMTP=yes
20136 .endd
20137 .cindex "options" "&(lmtp)& transport"
20138 is present in your &_Local/Makefile_& in order to have the &(lmtp)& transport
20139 included in the Exim binary. The private options of the &(lmtp)& transport are
20140 as follows:
20141
20142 .option batch_id lmtp string&!! unset
20143 See the description of local delivery batching in chapter &<<CHAPbatching>>&.
20144
20145
20146 .option batch_max lmtp integer 1
20147 This limits the number of addresses that can be handled in a single delivery.
20148 Most LMTP servers can handle several addresses at once, so it is normally a
20149 good idea to increase this value. See the description of local delivery
20150 batching in chapter &<<CHAPbatching>>&.
20151
20152
20153 .option command lmtp string&!! unset
20154 This option must be set if &%socket%& is not set. The string is a command which
20155 is run in a separate process. It is split up into a command name and list of
20156 arguments, each of which is separately expanded (so expansion cannot change the
20157 number of arguments). The command is run directly, not via a shell. The message
20158 is passed to the new process using the standard input and output to operate the
20159 LMTP protocol.
20160
20161 .option ignore_quota lmtp boolean false
20162 .cindex "LMTP" "ignoring quota errors"
20163 If this option is set true, the string &`IGNOREQUOTA`& is added to RCPT
20164 commands, provided that the LMTP server has advertised support for IGNOREQUOTA
20165 in its response to the LHLO command.
20166
20167 .option socket lmtp string&!! unset
20168 This option must be set if &%command%& is not set. The result of expansion must
20169 be the name of a Unix domain socket. The transport connects to the socket and
20170 delivers the message to it using the LMTP protocol.
20171
20172
20173 .option timeout lmtp time 5m
20174 The transport is aborted if the created process
20175 or Unix domain socket
20176 does not respond to LMTP commands or message input within this timeout.
20177
20178
20179 Here is an example of a typical LMTP transport:
20180 .code
20181 lmtp:
20182   driver = lmtp
20183   command = /some/local/lmtp/delivery/program
20184   batch_max = 20
20185   user = exim
20186 .endd
20187 This delivers up to 20 addresses at a time, in a mixture of domains if
20188 necessary, running as the user &'exim'&.
20189
20190
20191
20192 . ////////////////////////////////////////////////////////////////////////////
20193 . ////////////////////////////////////////////////////////////////////////////
20194
20195 .chapter "The pipe transport" "CHAPpipetransport"
20196 .scindex IIDpiptra1 "transports" "&(pipe)&"
20197 .scindex IIDpiptra2 "&(pipe)& transport"
20198 The &(pipe)& transport is used to deliver messages via a pipe to a command
20199 running in another process. One example is the use of &(pipe)& as a
20200 pseudo-remote transport for passing messages to some other delivery mechanism
20201 (such as UUCP). Another is the use by individual users to automatically process
20202 their incoming messages. The &(pipe)& transport can be used in one of the
20203 following ways:
20204
20205 .ilist
20206 .cindex "&$local_part$&"
20207 A router routes one address to a transport in the normal way, and the
20208 transport is configured as a &(pipe)& transport. In this case, &$local_part$&
20209 contains the local part of the address (as usual), and the command that is run
20210 is specified by the &%command%& option on the transport.
20211 .next
20212 .cindex "&$pipe_addresses$&"
20213 If the &%batch_max%& option is set greater than 1 (the default is 1), the
20214 transport can handle more than one address in a single run. In this case, when
20215 more than one address is routed to the transport, &$local_part$& is not set
20216 (because it is not unique). However, the pseudo-variable &$pipe_addresses$&
20217 (described in section &<<SECThowcommandrun>>& below) contains all the addresses
20218 that are routed to the transport.
20219 .next
20220 .cindex "&$address_pipe$&"
20221 A router redirects an address directly to a pipe command (for example, from an
20222 alias or forward file). In this case, &$address_pipe$& contains the text of the
20223 pipe command, and the &%command%& option on the transport is ignored. If only
20224 one address is being transported (&%batch_max%& is not greater than one, or
20225 only one address was redirected to this pipe command), &$local_part$& contains
20226 the local part that was redirected.
20227 .endlist
20228
20229
20230 The &(pipe)& transport is a non-interactive delivery method. Exim can also
20231 deliver messages over pipes using the LMTP interactive protocol. This is
20232 implemented by the &(lmtp)& transport.
20233
20234 In the case when &(pipe)& is run as a consequence of an entry in a local user's
20235 &_.forward_& file, the command runs under the uid and gid of that user. In
20236 other cases, the uid and gid have to be specified explicitly, either on the
20237 transport or on the router that handles the address. Current and &"home"&
20238 directories are also controllable. See chapter &<<CHAPenvironment>>& for
20239 details of the local delivery environment and chapter &<<CHAPbatching>>&
20240 for a discussion of local delivery batching.
20241
20242
20243 .section "Concurrent delivery"
20244 If two messages arrive at almost the same time, and both are routed to a pipe
20245 delivery, the two pipe transports may be run concurrently. You must ensure that
20246 any pipe commands you set up are robust against this happening. If the commands
20247 write to a file, the &%exim_lock%& utility might be of use.
20248
20249
20250
20251
20252 .section "Returned status and data"
20253 .cindex "&(pipe)& transport" "returned data"
20254 If the command exits with a non-zero return code, the delivery is deemed to
20255 have failed, unless either the &%ignore_status%& option is set (in which case
20256 the return code is treated as zero), or the return code is one of those listed
20257 in the &%temp_errors%& option, which are interpreted as meaning &"try again
20258 later"&. In this case, delivery is deferred. Details of a permanent failure are
20259 logged, but are not included in the bounce message, which merely contains
20260 &"local delivery failed"&.
20261
20262 If the return code is greater than 128 and the command being run is a shell
20263 script, it normally means that the script was terminated by a signal whose
20264 value is the return code minus 128.
20265
20266 If Exim is unable to run the command (that is, if &[execve()]& fails), the
20267 return code is set to 127. This is the value that a shell returns if it is
20268 asked to run a non-existent command. The wording for the log line suggests that
20269 a non-existent command may be the problem.
20270
20271 The &%return_output%& option can affect the result of a pipe delivery. If it is
20272 set and the command produces any output on its standard output or standard
20273 error streams, the command is considered to have failed, even if it gave a zero
20274 return code or if &%ignore_status%& is set. The output from the command is
20275 included as part of the bounce message. The &%return_fail_output%& option is
20276 similar, except that output is returned only when the command exits with a
20277 failure return code, that is, a value other than zero or a code that matches
20278 &%temp_errors%&.
20279
20280
20281
20282 .section "How the command is run" "SECThowcommandrun"
20283 .cindex "&(pipe)& transport" "path for command"
20284 The command line is (by default) broken down into a command name and arguments
20285 by the &(pipe)& transport itself. The &%allow_commands%& and
20286 &%restrict_to_path%& options can be used to restrict the commands that may be
20287 run.
20288
20289 .cindex "quoting" "in pipe command"
20290 Unquoted arguments are delimited by white space. If an argument appears in
20291 double quotes, backslash is interpreted as an escape character in the usual
20292 way. If an argument appears in single quotes, no escaping is done.
20293
20294 String expansion is applied to the command line except when it comes from a
20295 traditional &_.forward_& file (commands from a filter file are expanded). The
20296 expansion is applied to each argument in turn rather than to the whole line.
20297 For this reason, any string expansion item that contains white space must be
20298 quoted so as to be contained within a single argument. A setting such as
20299 .code
20300 command = /some/path ${if eq{$local_part}{postmaster}{xx}{yy}}
20301 .endd
20302 will not work, because the expansion item gets split between several
20303 arguments. You have to write
20304 .code
20305 command = /some/path "${if eq{$local_part}{postmaster}{xx}{yy}}"
20306 .endd
20307 to ensure that it is all in one argument. The expansion is done in this way,
20308 argument by argument, so that the number of arguments cannot be changed as a
20309 result of expansion, and quotes or backslashes in inserted variables do not
20310 interact with external quoting. However, this leads to problems if you want to
20311 generate multiple arguments (or the command name plus arguments) from a single
20312 expansion. In this situation, the simplest solution is to use a shell. For
20313 example:
20314 .code
20315 command = /bin/sh -c ${lookup{$local_part}lsearch{/some/file}}
20316 .endd
20317
20318 .cindex "transport" "filter"
20319 .cindex "filter" "transport filter"
20320 .cindex "&$pipe_addresses$&"
20321 Special handling takes place when an argument consists of precisely the text
20322 &`$pipe_addresses`&. This is not a general expansion variable; the only
20323 place this string is recognized is when it appears as an argument for a pipe or
20324 transport filter command. It causes each address that is being handled to be
20325 inserted in the argument list at that point &'as a separate argument'&. This
20326 avoids any problems with spaces or shell metacharacters, and is of use when a
20327 &(pipe)& transport is handling groups of addresses in a batch.
20328
20329 After splitting up into arguments and expansion, the resulting command is run
20330 in a subprocess directly from the transport, &'not'& under a shell. The
20331 message that is being delivered is supplied on the standard input, and the
20332 standard output and standard error are both connected to a single pipe that is
20333 read by Exim. The &%max_output%& option controls how much output the command
20334 may produce, and the &%return_output%& and &%return_fail_output%& options
20335 control what is done with it.
20336
20337 Not running the command under a shell (by default) lessens the security risks
20338 in cases when a command from a user's filter file is built out of data that was
20339 taken from an incoming message. If a shell is required, it can of course be
20340 explicitly specified as the command to be run. However, there are circumstances
20341 where existing commands (for example, in &_.forward_& files) expect to be run
20342 under a shell and cannot easily be modified. To allow for these cases, there is
20343 an option called &%use_shell%&, which changes the way the &(pipe)& transport
20344 works. Instead of breaking up the command line as just described, it expands it
20345 as a single string and passes the result to &_/bin/sh_&. The
20346 &%restrict_to_path%& option and the &$pipe_addresses$& facility cannot be used
20347 with &%use_shell%&, and the whole mechanism is inherently less secure.
20348
20349
20350
20351 .section "Environment variables" "SECTpipeenv"
20352 .cindex "&(pipe)& transport" "environment for command"
20353 .cindex "environment for pipe transport"
20354 The environment variables listed below are set up when the command is invoked.
20355 This list is a compromise for maximum compatibility with other MTAs. Note that
20356 the &%environment%& option can be used to add additional variables to this
20357 environment.
20358 .display
20359 &`DOMAIN            `&   the domain of the address
20360 &`HOME              `&   the home directory, if set
20361 &`HOST              `&   the host name when called from a router (see below)
20362 &`LOCAL_PART        `&   see below
20363 &`LOCAL_PART_PREFIX `&   see below
20364 &`LOCAL_PART_SUFFIX `&   see below
20365 &`LOGNAME           `&   see below
20366 &`MESSAGE_ID        `&   Exim's local ID for the message
20367 &`PATH              `&   as specified by the &%path%& option below
20368 &`QUALIFY_DOMAIN    `&   the sender qualification domain
20369 &`RECIPIENT         `&   the complete recipient address
20370 &`SENDER            `&   the sender of the message (empty if a bounce)
20371 &`SHELL             `&   &`/bin/sh`&
20372 &`TZ                `&   the value of the &%timezone%& option, if set
20373 &`USER              `&   see below
20374 .endd
20375 When a &(pipe)& transport is called directly from (for example) an &(accept)&
20376 router, LOCAL_PART is set to the local part of the address. When it is
20377 called as a result of a forward or alias expansion, LOCAL_PART is set to
20378 the local part of the address that was expanded. In both cases, any affixes are
20379 removed from the local part, and made available in LOCAL_PART_PREFIX and
20380 LOCAL_PART_SUFFIX, respectively. LOGNAME and USER are set to the
20381 same value as LOCAL_PART for compatibility with other MTAs.
20382
20383 .cindex "HOST"
20384 HOST is set only when a &(pipe)& transport is called from a router that
20385 associates hosts with an address, typically when using &(pipe)& as a
20386 pseudo-remote transport. HOST is set to the first host name specified by
20387 the router.
20388
20389 .cindex "HOME"
20390 If the transport's generic &%home_directory%& option is set, its value is used
20391 for the HOME environment variable. Otherwise, a home directory may be set
20392 by the router's &%transport_home_directory%& option, which defaults to the
20393 user's home directory if &%check_local_user%& is set.
20394
20395
20396 .section "Private options for pipe"
20397 .cindex "options" "&(pipe)& transport"
20398
20399
20400
20401 .option allow_commands pipe "string list&!!" unset
20402 .cindex "&(pipe)& transport" "permitted commands"
20403 The string is expanded, and is then interpreted as a colon-separated list of
20404 permitted commands. If &%restrict_to_path%& is not set, the only commands
20405 permitted are those in the &%allow_commands%& list. They need not be absolute
20406 paths; the &%path%& option is still used for relative paths. If
20407 &%restrict_to_path%& is set with &%allow_commands%&, the command must either be
20408 in the &%allow_commands%& list, or a name without any slashes that is found on
20409 the path. In other words, if neither &%allow_commands%& nor
20410 &%restrict_to_path%& is set, there is no restriction on the command, but
20411 otherwise only commands that are permitted by one or the other are allowed. For
20412 example, if
20413 .code
20414 allow_commands = /usr/bin/vacation
20415 .endd
20416 and &%restrict_to_path%& is not set, the only permitted command is
20417 &_/usr/bin/vacation_&. The &%allow_commands%& option may not be set if
20418 &%use_shell%& is set.
20419
20420
20421 .option batch_id pipe string&!! unset
20422 See the description of local delivery batching in chapter &<<CHAPbatching>>&.
20423
20424
20425 .option batch_max pipe integer 1
20426 This limits the number of addresses that can be handled in a single delivery.
20427 See the description of local delivery batching in chapter &<<CHAPbatching>>&.
20428
20429
20430 .option check_string pipe string unset
20431 As &(pipe)& writes the message, the start of each line is tested for matching
20432 &%check_string%&, and if it does, the initial matching characters are replaced
20433 by the contents of &%escape_string%&, provided both are set. The value of
20434 &%check_string%& is a literal string, not a regular expression, and the case of
20435 any letters it contains is significant. When &%use_bsmtp%& is set, the contents
20436 of &%check_string%& and &%escape_string%& are forced to values that implement
20437 the SMTP escaping protocol. Any settings made in the configuration file are
20438 ignored.
20439
20440
20441 .option command pipe string&!! unset
20442 This option need not be set when &(pipe)& is being used to deliver to pipes
20443 obtained directly from address redirections. In other cases, the option must be
20444 set, to provide a command to be run. It need not yield an absolute path (see
20445 the &%path%& option below). The command is split up into separate arguments by
20446 Exim, and each argument is separately expanded, as described in section
20447 &<<SECThowcommandrun>>& above.
20448
20449
20450 .option environment pipe string&!! unset
20451 .cindex "&(pipe)& transport" "environment for command"
20452 .cindex "environment for &(pipe)& transport"
20453 This option is used to add additional variables to the environment in which the
20454 command runs (see section &<<SECTpipeenv>>& for the default list). Its value is
20455 a string which is expanded, and then interpreted as a colon-separated list of
20456 environment settings of the form <&'name'&>=<&'value'&>.
20457
20458
20459 .option escape_string pipe string unset
20460 See &%check_string%& above.
20461
20462
20463 .option freeze_exec_fail pipe boolean false
20464 .cindex "exec failure"
20465 .cindex "failure of exec"
20466 .cindex "&(pipe)& transport" "failure of exec"
20467 Failure to exec the command in a pipe transport is by default treated like
20468 any other failure while running the command. However, if &%freeze_exec_fail%&
20469 is set, failure to exec is treated specially, and causes the message to be
20470 frozen, whatever the setting of &%ignore_status%&.
20471
20472
20473 .option ignore_status pipe boolean false
20474 If this option is true, the status returned by the subprocess that is set up to
20475 run the command is ignored, and Exim behaves as if zero had been returned.
20476 Otherwise, a non-zero status or termination by signal causes an error return
20477 from the transport unless the status value is one of those listed in
20478 &%temp_errors%&; these cause the delivery to be deferred and tried again later.
20479
20480 &*Note*&: This option does not apply to timeouts, which do not return a status.
20481 See the &%timeout_defer%& option for how timeouts are handled.
20482
20483 .option log_defer_output pipe boolean false
20484 .cindex "&(pipe)& transport" "logging output"
20485 If this option is set, and the status returned by the command is
20486 one of the codes listed in &%temp_errors%& (that is, delivery was deferred),
20487 and any output was produced, the first line of it is written to the main log.
20488
20489
20490 .option log_fail_output pipe boolean false
20491 If this option is set, and the command returns any output, and also ends with a
20492 return code that is neither zero nor one of the return codes listed in
20493 &%temp_errors%& (that is, the delivery failed), the first line of output is
20494 written to the main log. This option and &%log_output%& are mutually exclusive.
20495 Only one of them may be set.
20496
20497
20498
20499 .option log_output pipe boolean false
20500 If this option is set and the command returns any output, the first line of
20501 output is written to the main log, whatever the return code. This option and
20502 &%log_fail_output%& are mutually exclusive. Only one of them may be set.
20503
20504
20505
20506 .option max_output pipe integer 20K
20507 This specifies the maximum amount of output that the command may produce on its
20508 standard output and standard error file combined. If the limit is exceeded, the
20509 process running the command is killed. This is intended as a safety measure to
20510 catch runaway processes. The limit is applied independently of the settings of
20511 the options that control what is done with such output (for example,
20512 &%return_output%&). Because of buffering effects, the amount of output may
20513 exceed the limit by a small amount before Exim notices.
20514
20515
20516 .option message_prefix pipe string&!! "see below"
20517 The string specified here is expanded and output at the start of every message.
20518 The default is unset if &%use_bsmtp%& is set. Otherwise it is
20519 .code
20520 message_prefix = \
20521   From ${if def:return_path{$return_path}{MAILER-DAEMON}}\
20522   ${tod_bsdinbox}\n
20523 .endd
20524 .cindex "Cyrus"
20525 .cindex "&%tmail%&"
20526 .cindex "&""From""& line"
20527 This is required by the commonly used &_/usr/bin/vacation_& program.
20528 However, it must &'not'& be present if delivery is to the Cyrus IMAP server,
20529 or to the &%tmail%& local delivery agent. The prefix can be suppressed by
20530 setting
20531 .code
20532 message_prefix =
20533 .endd
20534
20535 .option message_suffix pipe string&!! "see below"
20536 The string specified here is expanded and output at the end of every message.
20537 The default is unset if &%use_bsmtp%& is set. Otherwise it is a single newline.
20538 The suffix can be suppressed by setting
20539 .code
20540 message_suffix =
20541 .endd
20542
20543 .option path pipe string &`/bin:/usr/bin`&
20544 This option specifies the string that is set up in the PATH environment
20545 variable of the subprocess. If the &%command%& option does not yield an
20546 absolute path name, the command is sought in the PATH directories, in the usual
20547 way. &*Warning*&: This does not apply to a command specified as a transport
20548 filter.
20549
20550
20551 .option pipe_as_creator pipe boolean false
20552 .cindex "uid (user id)" "local delivery"
20553 If the generic &%user%& option is not set and this option is true, the delivery
20554 process is run under the uid that was in force when Exim was originally called
20555 to accept the message. If the group id is not otherwise set (via the generic
20556 &%group%& option), the gid that was in force when Exim was originally called to
20557 accept the message is used.
20558
20559
20560 .option restrict_to_path pipe boolean false
20561 When this option is set, any command name not listed in &%allow_commands%& must
20562 contain no slashes. The command is searched for only in the directories listed
20563 in the &%path%& option. This option is intended for use in the case when a pipe
20564 command has been generated from a user's &_.forward_& file. This is usually
20565 handled by a &(pipe)& transport called &%address_pipe%&.
20566
20567
20568 .option return_fail_output pipe boolean false
20569 If this option is true, and the command produced any output and ended with a
20570 return code other than zero or one of the codes listed in &%temp_errors%& (that
20571 is, the delivery failed), the output is returned in the bounce message.
20572 However, if the message has a null sender (that is, it is itself a bounce
20573 message), output from the command is discarded. This option and
20574 &%return_output%& are mutually exclusive. Only one of them may be set.
20575
20576
20577
20578 .option return_output pipe boolean false
20579 If this option is true, and the command produced any output, the delivery is
20580 deemed to have failed whatever the return code from the command, and the output
20581 is returned in the bounce message. Otherwise, the output is just discarded.
20582 However, if the message has a null sender (that is, it is a bounce message),
20583 output from the command is always discarded, whatever the setting of this
20584 option. This option and &%return_fail_output%& are mutually exclusive. Only one
20585 of them may be set.
20586
20587
20588
20589 .option temp_errors pipe "string list" "see below"
20590 .cindex "&(pipe)& transport" "temporary failure"
20591 This option contains either a colon-separated list of numbers, or a single
20592 asterisk. If &%ignore_status%& is false
20593 and &%return_output%& is not set,
20594 and the command exits with a non-zero return code, the failure is treated as
20595 temporary and the delivery is deferred if the return code matches one of the
20596 numbers, or if the setting is a single asterisk. Otherwise, non-zero return
20597 codes are treated as permanent errors. The default setting contains the codes
20598 defined by EX_TEMPFAIL and EX_CANTCREAT in &_sysexits.h_&. If Exim is
20599 compiled on a system that does not define these macros, it assumes values of 75
20600 and 73, respectively.
20601
20602
20603 .option timeout pipe time 1h
20604 If the command fails to complete within this time, it is killed. This normally
20605 causes the delivery to fail (but see &%timeout_defer%&). A zero time interval
20606 specifies no timeout. In order to ensure that any subprocesses created by the
20607 command are also killed, Exim makes the initial process a process group leader,
20608 and kills the whole process group on a timeout. However, this can be defeated
20609 if one of the processes starts a new process group.
20610
20611 .option timeout_defer pipe boolean false
20612 A timeout in a &(pipe)& transport, either in the command that the transport
20613 runs, or in a transport filter that is associated with it, is by default
20614 treated as a hard error, and the delivery fails. However, if &%timeout_defer%&
20615 is set true, both kinds of timeout become temporary errors, causing the
20616 delivery to be deferred.
20617
20618 .option umask pipe "octal integer" 022
20619 This specifies the umask setting for the subprocess that runs the command.
20620
20621
20622 .option use_bsmtp pipe boolean false
20623 .cindex "envelope sender"
20624 If this option is set true, the &(pipe)& transport writes messages in &"batch
20625 SMTP"& format, with the envelope sender and recipient(s) included as SMTP
20626 commands. If you want to include a leading HELO command with such messages,
20627 you can do so by setting the &%message_prefix%& option. See section
20628 &<<SECTbatchSMTP>>& for details of batch SMTP.
20629
20630 .option use_classresources pipe boolean false
20631 .cindex "class resources (BSD)"
20632 This option is available only when Exim is running on FreeBSD, NetBSD, or
20633 BSD/OS. If it is set true, the &[setclassresources()]& function is used to set
20634 resource limits when a &(pipe)& transport is run to perform a delivery. The
20635 limits for the uid under which the pipe is to run are obtained from the login
20636 class database.
20637
20638
20639 .option use_crlf pipe boolean false
20640 .cindex "carriage return"
20641 .cindex "linefeed"
20642 This option causes lines to be terminated with the two-character CRLF sequence
20643 (carriage return, linefeed) instead of just a linefeed character. In the case
20644 of batched SMTP, the byte sequence written to the pipe is then an exact image
20645 of what would be sent down a real SMTP connection.
20646
20647 The contents of the &%message_prefix%& and &%message_suffix%& options are
20648 written verbatim, so must contain their own carriage return characters if these
20649 are needed. Since the default values for both &%message_prefix%& and
20650 &%message_suffix%& end with a single linefeed, their values must be changed to
20651 end with &`\r\n`& if &%use_crlf%& is set.
20652
20653
20654 .option use_shell pipe boolean false
20655 .cindex "&$pipe_addresses$&"
20656 If this option is set, it causes the command to be passed to &_/bin/sh_&
20657 instead of being run directly from the transport, as described in section
20658 &<<SECThowcommandrun>>&. This is less secure, but is needed in some situations
20659 where the command is expected to be run under a shell and cannot easily be
20660 modified. The &%allow_commands%& and &%restrict_to_path%& options, and the
20661 &`$pipe_addresses`& facility are incompatible with &%use_shell%&. The
20662 command is expanded as a single string, and handed to &_/bin/sh_& as data for
20663 its &%-c%& option.
20664
20665
20666
20667 .section "Using an external local delivery agent"
20668 .cindex "local delivery" "using an external agent"
20669 .cindex "&'procmail'&"
20670 .cindex "external local delivery"
20671 .cindex "delivery" "&'procmail'&"
20672 .cindex "delivery" "by external agent"
20673 The &(pipe)& transport can be used to pass all messages that require local
20674 delivery to a separate local delivery agent such as &%procmail%&. When doing
20675 this, care must be taken to ensure that the pipe is run under an appropriate
20676 uid and gid. In some configurations one wants this to be a uid that is trusted
20677 by the delivery agent to supply the correct sender of the message. It may be
20678 necessary to recompile or reconfigure the delivery agent so that it trusts an
20679 appropriate user. The following is an example transport and router
20680 configuration for &%procmail%&:
20681 .code
20682 # transport
20683 procmail_pipe:
20684   driver = pipe
20685   command = /usr/local/bin/procmail -d $local_part
20686   return_path_add
20687   delivery_date_add
20688   envelope_to_add
20689   check_string = "From "
20690   escape_string = ">From "
20691   user = $local_part
20692   group = mail
20693
20694 # router
20695 procmail:
20696   driver = accept
20697   check_local_user
20698   transport = procmail_pipe
20699 .endd
20700 In this example, the pipe is run as the local user, but with the group set to
20701 &'mail'&. An alternative is to run the pipe as a specific user such as &'mail'&
20702 or &'exim'&, but in this case you must arrange for &%procmail%& to trust that
20703 user to supply a correct sender address. If you do not specify either a
20704 &%group%& or a &%user%& option, the pipe command is run as the local user. The
20705 home directory is the user's home directory by default.
20706
20707 &*Note*&: The command that the pipe transport runs does &'not'& begin with
20708 .code
20709 IFS=" "
20710 .endd
20711 as shown in some &%procmail%& documentation, because Exim does not by default
20712 use a shell to run pipe commands.
20713
20714 .cindex "Cyrus"
20715 The next example shows a transport and a router for a system where local
20716 deliveries are handled by the Cyrus IMAP server.
20717 .code
20718 # transport
20719 local_delivery_cyrus:
20720   driver = pipe
20721   command = /usr/cyrus/bin/deliver \
20722             -m ${substr_1:$local_part_suffix} -- $local_part
20723   user = cyrus
20724   group = mail
20725   return_output
20726   log_output
20727   message_prefix =
20728   message_suffix =
20729
20730 # router
20731 local_user_cyrus:
20732   driver = accept
20733   check_local_user
20734   local_part_suffix = .*
20735   transport = local_delivery_cyrus
20736 .endd
20737 Note the unsetting of &%message_prefix%& and &%message_suffix%&, and the use of
20738 &%return_output%& to cause any text written by Cyrus to be returned to the
20739 sender.
20740 .ecindex IIDpiptra1
20741 .ecindex IIDpiptra2
20742
20743
20744 . ////////////////////////////////////////////////////////////////////////////
20745 . ////////////////////////////////////////////////////////////////////////////
20746
20747 .chapter "The smtp transport" "CHAPsmtptrans"
20748 .scindex IIDsmttra1 "transports" "&(smtp)&"
20749 .scindex IIDsmttra2 "&(smtp)& transport"
20750 The &(smtp)& transport delivers messages over TCP/IP connections using the SMTP
20751 or LMTP protocol. The list of hosts to try can either be taken from the address
20752 that is being processed (having been set up by the router), or specified
20753 explicitly for the transport. Timeout and retry processing (see chapter
20754 &<<CHAPretry>>&) is applied to each IP address independently.
20755
20756
20757 .section "Multiple messages on a single connection"
20758 The sending of multiple messages over a single TCP/IP connection can arise in
20759 two ways:
20760
20761 .ilist
20762 If a message contains more than &%max_rcpt%& (see below) addresses that are
20763 routed to the same host, more than one copy of the message has to be sent to
20764 that host. In this situation, multiple copies may be sent in a single run of
20765 the &(smtp)& transport over a single TCP/IP connection. (What Exim actually
20766 does when it has too many addresses to send in one message also depends on the
20767 value of the global &%remote_max_parallel%& option. Details are given in
20768 section &<<SECToutSMTPTCP>>&.)
20769 .next
20770 .cindex "hints database" "remembering routing"
20771 When a message has been successfully delivered over a TCP/IP connection, Exim
20772 looks in its hints database to see if there are any other messages awaiting a
20773 connection to the same host. If there are, a new delivery process is started
20774 for one of them, and the current TCP/IP connection is passed on to it. The new
20775 process may in turn send multiple copies and possibly create yet another
20776 process.
20777 .endlist
20778
20779
20780 For each copy sent over the same TCP/IP connection, a sequence counter is
20781 incremented, and if it ever gets to the value of &%connection_max_messages%&,
20782 no further messages are sent over that connection.
20783
20784
20785
20786 .section "Use of the $host variable"
20787 .cindex "&$host$&"
20788 .cindex "&$host_address$&"
20789 At the start of a run of the &(smtp)& transport, the values of &$host$& and
20790 &$host_address$& are the name and IP address of the first host on the host list
20791 passed by the router. However, when the transport is about to connect to a
20792 specific host, and while it is connected to that host, &$host$& and
20793 &$host_address$& are set to the values for that host. These are the values
20794 that are in force when the &%helo_data%&, &%hosts_try_auth%&, &%interface%&,
20795 &%serialize_hosts%&, and the various TLS options are expanded.
20796
20797
20798
20799 .section "Private options for smtp"
20800 .cindex "options" "&(smtp)& transport"
20801 The private options of the &(smtp)& transport are as follows:
20802
20803
20804 .new
20805 .option address_retry_include_sender smtp boolean true
20806 .cindex "4&'xx'& responses" "retrying after"
20807 When an address is delayed because of a 4&'xx'& response to a RCPT command, it
20808 is the combination of sender and recipient that is delayed in subsequent queue
20809 runs until the retry time is reached. You can delay the recipient without
20810 reference to the sender (which is what earlier versions of Exim did), by
20811 setting &%address_retry_include_sender%& false. However, this can lead to
20812 problems with servers that regularly issue 4&'xx'& responses to RCPT commands.
20813 .wen
20814
20815 .option allow_localhost smtp boolean false
20816 .cindex "local host" "sending to"
20817 .cindex "fallback" "hosts specified on transport"
20818 When a host specified in &%hosts%& or &%fallback_hosts%& (see below) turns out
20819 to be the local host, or is listed in &%hosts_treat_as_local%&, delivery is
20820 deferred by default. However, if &%allow_localhost%& is set, Exim goes on to do
20821 the delivery anyway. This should be used only in special cases when the
20822 configuration ensures that no looping will result (for example, a differently
20823 configured Exim is listening on the port to which the message is sent).
20824
20825
20826 .option authenticated_sender smtp string&!! unset
20827 .cindex "Cyrus"
20828 When Exim has authenticated as a client, or if &%authenticated_sender_force%&
20829 is true, this option sets a value for the AUTH= item on outgoing MAIL commands,
20830 overriding any existing authenticated sender value. If the string expansion is
20831 forced to fail, the option is ignored. Other expansion failures cause delivery
20832 to be deferred. If the result of expansion is an empty string, that is also
20833 ignored.
20834
20835 If the SMTP session is not authenticated, the expansion of
20836 &%authenticated_sender%& still happens (and can cause the delivery to be
20837 deferred if it fails), but no AUTH= item is added to MAIL commands
20838 unless &%authenticated_sender_force%& is true.
20839
20840 This option allows you to use the &(smtp)& transport in LMTP mode to
20841 deliver mail to Cyrus IMAP and provide the proper local part as the
20842 &"authenticated sender"&, via a setting such as:
20843 .code
20844 authenticated_sender = $local_part
20845 .endd
20846 This removes the need for IMAP subfolders to be assigned special ACLs to
20847 allow direct delivery to those subfolders.
20848
20849 Because of expected uses such as that just described for Cyrus (when no
20850 domain is involved), there is no checking on the syntax of the provided
20851 value.
20852
20853
20854 .option authenticated_sender_force smtp boolean false
20855 If this option is set true, the &%authenticated_sender%& option's value
20856 is used for the AUTH= item on outgoing MAIL commands, even if Exim has not
20857 authenticated as a client.
20858
20859
20860 .option command_timeout smtp time 5m
20861 This sets a timeout for receiving a response to an SMTP command that has been
20862 sent out. It is also used when waiting for the initial banner line from the
20863 remote host. Its value must not be zero.
20864
20865
20866 .option connect_timeout smtp time 5m
20867 This sets a timeout for the &[connect()]& function, which sets up a TCP/IP call
20868 to a remote host. A setting of zero allows the system timeout (typically
20869 several minutes) to act. To have any effect, the value of this option must be
20870 less than the system timeout. However, it has been observed that on some
20871 systems there is no system timeout, which is why the default value for this
20872 option is 5 minutes, a value recommended by RFC 1123.
20873
20874
20875 .option connection_max_messages smtp integer 500
20876 .cindex "SMTP" "passed connection"
20877 .cindex "SMTP" "multiple deliveries"
20878 .cindex "multiple SMTP deliveries"
20879 This controls the maximum number of separate message deliveries that are sent
20880 over a single TCP/IP connection. If the value is zero, there is no limit.
20881 For testing purposes, this value can be overridden by the &%-oB%& command line
20882 option.
20883
20884
20885 .option data_timeout smtp time 5m
20886 This sets a timeout for the transmission of each block in the data portion of
20887 the message. As a result, the overall timeout for a message depends on the size
20888 of the message. Its value must not be zero. See also &%final_timeout%&.
20889
20890
20891 .option delay_after_cutoff smtp boolean true
20892 This option controls what happens when all remote IP addresses for a given
20893 domain have been inaccessible for so long that they have passed their retry
20894 cutoff times.
20895
20896 In the default state, if the next retry time has not been reached for any of
20897 them, the address is bounced without trying any deliveries. In other words,
20898 Exim delays retrying an IP address after the final cutoff time until a new
20899 retry time is reached, and can therefore bounce an address without ever trying
20900 a delivery, when machines have been down for a long time. Some people are
20901 unhappy at this prospect, so...
20902
20903 If &%delay_after_cutoff%& is set false, Exim behaves differently. If all IP
20904 addresses are past their final cutoff time, Exim tries to deliver to those
20905 IP addresses that have not been tried since the message arrived. If there are
20906 none, of if they all fail, the address is bounced. In other words, it does not
20907 delay when a new message arrives, but immediately tries those expired IP
20908 addresses that haven't been tried since the message arrived. If there is a
20909 continuous stream of messages for the dead hosts, unsetting
20910 &%delay_after_cutoff%& means that there will be many more attempts to deliver
20911 to them.
20912
20913
20914 .option dns_qualify_single smtp boolean true
20915 If the &%hosts%& or &%fallback_hosts%& option is being used,
20916 and the &%gethostbyname%& option is false,
20917 the RES_DEFNAMES resolver option is set. See the &%qualify_single%& option
20918 in chapter &<<CHAPdnslookup>>& for more details.
20919
20920
20921 .option dns_search_parents smtp boolean false
20922 .cindex "&%search_parents%&"
20923 If the &%hosts%& or &%fallback_hosts%& option is being used, and the
20924 &%gethostbyname%& option is false, the RES_DNSRCH resolver option is set.
20925 See the &%search_parents%& option in chapter &<<CHAPdnslookup>>& for more
20926 details.
20927
20928
20929
20930 .option fallback_hosts smtp "string list" unset
20931 .cindex "fallback" "hosts specified on transport"
20932 String expansion is not applied to this option. The argument must be a
20933 colon-separated list of host names or IP addresses, optionally also including
20934 port numbers, though the separator can be changed, as described in section
20935 &<<SECTlistconstruct>>&. Each individual item in the list is the same as an
20936 item in a &%route_list%& setting for the &(manualroute)& router, as described
20937 in section &<<SECTformatonehostitem>>&.
20938
20939 Fallback hosts can also be specified on routers, which associate them with the
20940 addresses they process. As for the &%hosts%& option without &%hosts_override%&,
20941 &%fallback_hosts%& specified on the transport is used only if the address does
20942 not have its own associated fallback host list. Unlike &%hosts%&, a setting of
20943 &%fallback_hosts%& on an address is not overridden by &%hosts_override%&.
20944 However, &%hosts_randomize%& does apply to fallback host lists.
20945
20946 If Exim is unable to deliver to any of the hosts for a particular address, and
20947 the errors are not permanent rejections, the address is put on a separate
20948 transport queue with its host list replaced by the fallback hosts, unless the
20949 address was routed via MX records and the current host was in the original MX
20950 list. In that situation, the fallback host list is not used.
20951
20952 Once normal deliveries are complete, the fallback queue is delivered by
20953 re-running the same transports with the new host lists. If several failing
20954 addresses have the same fallback hosts (and &%max_rcpt%& permits it), a single
20955 copy of the message is sent.
20956
20957 The resolution of the host names on the fallback list is controlled by the
20958 &%gethostbyname%& option, as for the &%hosts%& option. Fallback hosts apply
20959 both to cases when the host list comes with the address and when it is taken
20960 from &%hosts%&. This option provides a &"use a smart host only if delivery
20961 fails"& facility.
20962
20963
20964 .option final_timeout smtp time 10m
20965 This is the timeout that applies while waiting for the response to the final
20966 line containing just &"."& that terminates a message. Its value must not be
20967 zero.
20968
20969
20970 .option gethostbyname smtp boolean false
20971 If this option is true when the &%hosts%& and/or &%fallback_hosts%& options are
20972 being used, names are looked up using &[gethostbyname()]&
20973 (or &[getipnodebyname()]& when available)
20974 instead of using the DNS. Of course, that function may in fact use the DNS, but
20975 it may also consult other sources of information such as &_/etc/hosts_&.
20976
20977 .option helo_data smtp string&!! &`$primary_hostname`&
20978 .cindex "HELO argument" "setting"
20979 .cindex "EHLO argument" "setting"
20980 .cindex "LHLO argument" "setting"
20981 The value of this option is expanded, and used as the argument for the EHLO,
20982 HELO, or LHLO command that starts the outgoing SMTP or LMTP session. The
20983 variables &$host$& and &$host_address$& are set to the identity of the remote
20984 host, and can be used to generate different values for different servers.
20985
20986 .option hosts smtp "string list&!!" unset
20987 Hosts are associated with an address by a router such as &(dnslookup)&, which
20988 finds the hosts by looking up the address domain in the DNS, or by
20989 &(manualroute)&, which has lists of hosts in its configuration. However,
20990 email addresses can be passed to the &(smtp)& transport by any router, and not
20991 all of them can provide an associated list of hosts.
20992
20993 The &%hosts%& option specifies a list of hosts to be used if the address being
20994 processed does not have any hosts associated with it. The hosts specified by
20995 &%hosts%& are also used, whether or not the address has its own hosts, if
20996 &%hosts_override%& is set.
20997
20998 The string is first expanded, before being interpreted as a colon-separated
20999 list of host names or IP addresses, possibly including port numbers. The
21000 separator may be changed to something other than colon, as described in section
21001 &<<SECTlistconstruct>>&. Each individual item in the list is the same as an
21002 item in a &%route_list%& setting for the &(manualroute)& router, as described
21003 in section &<<SECTformatonehostitem>>&. However, note that the &`/MX`& facility
21004 of the &(manualroute)& router is not available here.
21005
21006 If the expansion fails, delivery is deferred. Unless the failure was caused by
21007 the inability to complete a lookup, the error is logged to the panic log as
21008 well as the main log. Host names are looked up either by searching directly for
21009 address records in the DNS or by calling &[gethostbyname()]& (or
21010 &[getipnodebyname()]& when available), depending on the setting of the
21011 &%gethostbyname%& option. When Exim is compiled with IPv6 support, if a host
21012 that is looked up in the DNS has both IPv4 and IPv6 addresses, both types of
21013 address are used.
21014
21015 During delivery, the hosts are tried in order, subject to their retry status,
21016 unless &%hosts_randomize%& is set.
21017
21018
21019 .option hosts_avoid_esmtp smtp "host list&!!" unset
21020 .cindex "ESMTP" "avoiding use of"
21021 .cindex "HELO" "forcing use of"
21022 .cindex "EHLO" "avoiding use of"
21023 .cindex "PIPELINING" "avoiding the use of"
21024 This option is for use with broken hosts that announce ESMTP facilities (for
21025 example, PIPELINING) and then fail to implement them properly. When a host
21026 matches &%hosts_avoid_esmtp%&, Exim sends HELO rather than EHLO at the
21027 start of the SMTP session. This means that it cannot use any of the ESMTP
21028 facilities such as AUTH, PIPELINING, SIZE, and STARTTLS.
21029
21030
21031 .option hosts_avoid_tls smtp "host list&!!" unset
21032 .cindex "TLS" "avoiding for certain hosts"
21033 Exim will not try to start a TLS session when delivering to any host that
21034 matches this list. See chapter &<<CHAPTLS>>& for details of TLS.
21035
21036
21037 .option hosts_max_try smtp integer 5
21038 .cindex "host" "maximum number to try"
21039 .cindex "limit" "number of hosts tried"
21040 .cindex "limit" "number of MX tried"
21041 .cindex "MX record" "maximum tried"
21042 This option limits the number of IP addresses that are tried for any one
21043 delivery in cases where there are temporary delivery errors. Section
21044 &<<SECTvalhosmax>>& describes in detail how the value of this option is used.
21045
21046
21047 .option hosts_max_try_hardlimit smtp integer 50
21048 This is an additional check on the maximum number of IP addresses that Exim
21049 tries for any one delivery. Section &<<SECTvalhosmax>>& describes its use and
21050 why it exists.
21051
21052
21053
21054 .option hosts_nopass_tls smtp "host list&!!" unset
21055 .cindex "TLS" "passing connection"
21056 .cindex "multiple SMTP deliveries"
21057 .cindex "TLS" "multiple message deliveries"
21058 For any host that matches this list, a connection on which a TLS session has
21059 been started will not be passed to a new delivery process for sending another
21060 message on the same connection. See section &<<SECTmulmessam>>& for an
21061 explanation of when this might be needed.
21062
21063
21064 .option hosts_override smtp boolean false
21065 If this option is set and the &%hosts%& option is also set, any hosts that are
21066 attached to the address are ignored, and instead the hosts specified by the
21067 &%hosts%& option are always used. This option does not apply to
21068 &%fallback_hosts%&.
21069
21070
21071 .option hosts_randomize smtp boolean false
21072 .cindex "randomized host list"
21073 .cindex "host" "list of; randomized"
21074 .cindex "fallback" "randomized hosts"
21075 If this option is set, and either the list of hosts is taken from the
21076 &%hosts%& or the &%fallback_hosts%& option, or the hosts supplied by the router
21077 were not obtained from MX records (this includes fallback hosts from the
21078 router), and were not randomizied by the router, the order of trying the hosts
21079 is randomized each time the transport runs. Randomizing the order of a host
21080 list can be used to do crude load sharing.
21081
21082 When &%hosts_randomize%& is true, a host list may be split into groups whose
21083 order is separately randomized. This makes it possible to set up MX-like
21084 behaviour. The boundaries between groups are indicated by an item that is just
21085 &`+`& in the host list. For example:
21086 .code
21087 hosts = host1:host2:host3:+:host4:host5
21088 .endd
21089 The order of the first three hosts and the order of the last two hosts is
21090 randomized for each use, but the first three always end up before the last two.
21091 If &%hosts_randomize%& is not set, a &`+`& item in the list is ignored.
21092
21093 .option hosts_require_auth smtp "host list&!!" unset
21094 .cindex "authentication" "required by client"
21095 This option provides a list of servers for which authentication must succeed
21096 before Exim will try to transfer a message. If authentication fails for
21097 servers which are not in this list, Exim tries to send unauthenticated. If
21098 authentication fails for one of these servers, delivery is deferred. This
21099 temporary error is detectable in the retry rules, so it can be turned into a
21100 hard failure if required. See also &%hosts_try_auth%&, and chapter
21101 &<<CHAPSMTPAUTH>>& for details of authentication.
21102
21103
21104 .option hosts_require_tls smtp "host list&!!" unset
21105 .cindex "TLS" "requiring for certain servers"
21106 Exim will insist on using a TLS session when delivering to any host that
21107 matches this list. See chapter &<<CHAPTLS>>& for details of TLS.
21108 &*Note*&: This option affects outgoing mail only. To insist on TLS for
21109 incoming messages, use an appropriate ACL.
21110
21111 .option hosts_try_auth smtp "host list&!!" unset
21112 .cindex "authentication" "optional in client"
21113 This option provides a list of servers to which, provided they announce
21114 authentication support, Exim will attempt to authenticate as a client when it
21115 connects. If authentication fails, Exim will try to transfer the message
21116 unauthenticated. See also &%hosts_require_auth%&, and chapter
21117 &<<CHAPSMTPAUTH>>& for details of authentication.
21118
21119 .option interface smtp "string list&!!" unset
21120 .new
21121 .cindex "bind IP address"
21122 .cindex "IP address" "binding"
21123 .cindex "&$host$&"
21124 .cindex "&$host_address$&"
21125 This option specifies which interface to bind to when making an outgoing SMTP
21126 call. &*Note:*& Do not confuse this with the interface address that was used
21127 when a message was received, which is in &$received_ip_address$&, formerly
21128 known as &$interface_address$&. The name was changed to minimize confusion with
21129 the outgoing interface address. There is no variable that contains an outgoing
21130 interface address because, unless it is set by this option, its value is
21131 unknown.
21132 .wen
21133
21134 During the expansion of the &%interface%& option the variables &$host$& and
21135 &$host_address$& refer to the host to which a connection is about to be made
21136 during the expansion of the string. Forced expansion failure, or an empty
21137 string result causes the option to be ignored. Otherwise, after expansion, the
21138 string must be a list of IP addresses, colon-separated by default, but the
21139 separator can be changed in the usual way. For example:
21140 .code
21141 interface = <; 192.168.123.123 ; 3ffe:ffff:836f::fe86:a061
21142 .endd
21143 The first interface of the correct type (IPv4 or IPv6) is used for the outgoing
21144 connection. If none of them are the correct type, the option is ignored. If
21145 &%interface%& is not set, or is ignored, the system's IP functions choose which
21146 interface to use if the host has more than one.
21147
21148
21149 .option keepalive smtp boolean true
21150 .cindex "keepalive" "on outgoing connection"
21151 This option controls the setting of SO_KEEPALIVE on outgoing TCP/IP socket
21152 connections. When set, it causes the kernel to probe idle connections
21153 periodically, by sending packets with &"old"& sequence numbers. The other end
21154 of the connection should send a acknowledgement if the connection is still okay
21155 or a reset if the connection has been aborted. The reason for doing this is
21156 that it has the beneficial effect of freeing up certain types of connection
21157 that can get stuck when the remote host is disconnected without tidying up the
21158 TCP/IP call properly. The keepalive mechanism takes several hours to detect
21159 unreachable hosts.
21160
21161
21162 .option lmtp_ignore_quota smtp boolean false
21163 .cindex "LMTP" "ignoring quota errors"
21164 If this option is set true when the &%protocol%& option is set to &"lmtp"&, the
21165 string &`IGNOREQUOTA`& is added to RCPT commands, provided that the LMTP server
21166 has advertised support for IGNOREQUOTA in its response to the LHLO command.
21167
21168 .option max_rcpt smtp integer 100
21169 .cindex "RCPT" "maximum number of outgoing"
21170 This option limits the number of RCPT commands that are sent in a single
21171 SMTP message transaction. Each set of addresses is treated independently, and
21172 so can cause parallel connections to the same host if &%remote_max_parallel%&
21173 permits this.
21174
21175
21176 .option multi_domain smtp boolean true
21177 .cindex "&$domain$&"
21178 When this option is set, the &(smtp)& transport can handle a number of
21179 addresses containing a mixture of different domains provided they all resolve
21180 to the same list of hosts. Turning the option off restricts the transport to
21181 handling only one domain at a time. This is useful if you want to use
21182 &$domain$& in an expansion for the transport, because it is set only when there
21183 is a single domain involved in a remote delivery.
21184
21185
21186 .option port smtp string&!! "see below"
21187 .new
21188 .cindex "port" "sending TCP/IP"
21189 .cindex "TCP/IP" "setting outgoing port"
21190 This option specifies the TCP/IP port on the server to which Exim connects.
21191 &*Note:*& Do not confuse this with the port that was used when a message was
21192 received, which is in &$received_port$&, formerly known as &$interface_port$&.
21193 The name was changed to minimize confusion with the outgoing port. There is no
21194 variable that contains an outgoing port.
21195 .wen
21196
21197 If the value of this option begins with a digit it is taken as a port number;
21198 otherwise it is looked up using &[getservbyname()]&. The default value is
21199 normally &"smtp"&, but if &%protocol%& is set to &"lmtp"&, the default is
21200 &"lmtp"&. If the expansion fails, or if a port number cannot be found, delivery
21201 is deferred.
21202
21203
21204
21205 .option protocol smtp string smtp
21206 .cindex "LMTP" "over TCP/IP"
21207 If this option is set to &"lmtp"& instead of &"smtp"&, the default value for
21208 the &%port%& option changes to &"lmtp"&, and the transport operates the LMTP
21209 protocol (RFC 2033) instead of SMTP. This protocol is sometimes used for local
21210 deliveries into closed message stores. Exim also has support for running LMTP
21211 over a pipe to a local process &-- see chapter &<<CHAPLMTP>>&.
21212
21213
21214 .option retry_include_ip_address smtp boolean true
21215 Exim normally includes both the host name and the IP address in the key it
21216 constructs for indexing retry data after a temporary delivery failure. This
21217 means that when one of several IP addresses for a host is failing, it gets
21218 tried periodically (controlled by the retry rules), but use of the other IP
21219 addresses is not affected.
21220
21221 However, in some dialup environments hosts are assigned a different IP address
21222 each time they connect. In this situation the use of the IP address as part of
21223 the retry key leads to undesirable behaviour. Setting this option false causes
21224 Exim to use only the host name. This should normally be done on a separate
21225 instance of the &(smtp)& transport, set up specially to handle the dialup
21226 hosts.
21227
21228
21229 .option serialize_hosts smtp "host list&!!" unset
21230 .cindex "serializing connections"
21231 .cindex "host" "serializing connections"
21232 Because Exim operates in a distributed manner, if several messages for the same
21233 host arrive at around the same time, more than one simultaneous connection to
21234 the remote host can occur. This is not usually a problem except when there is a
21235 slow link between the hosts. In that situation it may be helpful to restrict
21236 Exim to one connection at a time. This can be done by setting
21237 &%serialize_hosts%& to match the relevant hosts.
21238
21239 .cindex "hints database" "serializing deliveries to a host"
21240 Exim implements serialization by means of a hints database in which a record is
21241 written whenever a process connects to one of the restricted hosts. The record
21242 is deleted when the connection is completed. Obviously there is scope for
21243 records to get left lying around if there is a system or program crash. To
21244 guard against this, Exim ignores any records that are more than six hours old.
21245
21246 If you set up this kind of serialization, you should also arrange to delete the
21247 relevant hints database whenever your system reboots. The names of the files
21248 start with &_misc_& and they are kept in the &_spool/db_& directory. There
21249 may be one or two files, depending on the type of DBM in use. The same files
21250 are used for ETRN serialization.
21251
21252
21253 .option size_addition smtp integer 1024
21254 .cindex "SMTP" "SIZE"
21255 .cindex "message" "size issue for transport filter"
21256 .cindex "size" "of message"
21257 .cindex "transport" "filter"
21258 .cindex "filter" "transport filter"
21259 If a remote SMTP server indicates that it supports the SIZE option of the
21260 MAIL command, Exim uses this to pass over the message size at the start of
21261 an SMTP transaction. It adds the value of &%size_addition%& to the value it
21262 sends, to allow for headers and other text that may be added during delivery by
21263 configuration options or in a transport filter. It may be necessary to increase
21264 this if a lot of text is added to messages.
21265
21266 Alternatively, if the value of &%size_addition%& is set negative, it disables
21267 the use of the SIZE option altogether.
21268
21269
21270 .option tls_certificate smtp string&!! unset
21271 .cindex "TLS client certificate" "location of"
21272 .cindex "certificate for client" "location of"
21273 .cindex "&$host$&"
21274 .cindex "&$host_address$&"
21275 The value of this option must be the absolute path to a file which contains the
21276 client's certificate, for possible use when sending a message over an encrypted
21277 connection. The values of &$host$& and &$host_address$& are set to the name and
21278 address of the server during the expansion. See chapter &<<CHAPTLS>>& for
21279 details of TLS.
21280
21281 &*Note*&: This option must be set if you want Exim to be able to use a TLS
21282 certificate when sending messages as a client. The global option of the same
21283 name specifies the certificate for Exim as a server; it is not automatically
21284 assumed that the same certificate should be used when Exim is operating as a
21285 client.
21286
21287
21288 .option tls_crl smtp string&!! unset
21289 .cindex "TLS" "client certificate revocation list"
21290 .cindex "certificate" "revocation list for client"
21291 This option specifies a certificate revocation list. The expanded value must
21292 be the name of a file that contains a CRL in PEM format.
21293
21294
21295 .option tls_privatekey smtp string&!! unset
21296 .cindex "TLS client private key" "location of"
21297 .cindex "&$host$&"
21298 .cindex "&$host_address$&"
21299 The value of this option must be the absolute path to a file which contains the
21300 client's private key. This is used when sending a message over an encrypted
21301 connection using a client certificate. The values of &$host$& and
21302 &$host_address$& are set to the name and address of the server during the
21303 expansion. If this option is unset, or the expansion is forced to fail, or the
21304 result is an empty string, the private key is assumed to be in the same file as
21305 the certificate. See chapter &<<CHAPTLS>>& for details of TLS.
21306
21307
21308 .option tls_require_ciphers smtp string&!! unset
21309 .cindex "TLS" "requiring specific ciphers"
21310 .cindex "cipher" "requiring specific"
21311 .cindex "&$host$&"
21312 .cindex "&$host_address$&"
21313 The value of this option must be a list of permitted cipher suites, for use
21314 when setting up an outgoing encrypted connection. (There is a global option of
21315 the same name for controlling incoming connections.) The values of &$host$& and
21316 &$host_address$& are set to the name and address of the server during the
21317 expansion. See chapter &<<CHAPTLS>>& for details of TLS; note that this option
21318 is used in different ways by OpenSSL and GnuTLS (see sections
21319 &<<SECTreqciphssl>>& and &<<SECTreqciphgnu>>&). For GnuTLS, the order of the
21320 ciphers is a preference order.
21321
21322
21323
21324 .option tls_tempfail_tryclear smtp boolean true
21325 .cindex "4&'xx'& responses" "to STARTTLS"
21326 When the server host is not in &%hosts_require_tls%&, and there is a problem in
21327 setting up a TLS session, this option determines whether or not Exim should try
21328 to deliver the message unencrypted. If it is set false, delivery to the
21329 current host is deferred; if there are other hosts, they are tried. If this
21330 option is set true, Exim attempts to deliver unencrypted after a 4&'xx'&
21331 response to STARTTLS. Also, if STARTTLS is accepted, but the subsequent
21332 TLS negotiation fails, Exim closes the current connection (because it is in an
21333 unknown state), opens a new one to the same host, and then tries the delivery
21334 in clear.
21335
21336
21337 .option tls_verify_certificates smtp string&!! unset
21338 .cindex "TLS" "server certificate verification"
21339 .cindex "certificate" "verification of server"
21340 .cindex "&$host$&"
21341 .cindex "&$host_address$&"
21342 The value of this option must be the absolute path to a file containing
21343 permitted server certificates, for use when setting up an encrypted connection.
21344 Alternatively, if you are using OpenSSL, you can set
21345 &%tls_verify_certificates%& to the name of a directory containing certificate
21346 files. This does not work with GnuTLS; the option must be set to the name of a
21347 single file if you are using GnuTLS. The values of &$host$& and
21348 &$host_address$& are set to the name and address of the server during the
21349 expansion of this option. See chapter &<<CHAPTLS>>& for details of TLS.
21350
21351
21352
21353
21354 .section "How the limits for the number of hosts to try are used" &&&
21355          "SECTvalhosmax"
21356 .cindex "host" "maximum number to try"
21357 .cindex "limit" "hosts; maximum number tried"
21358 There are two options that are concerned with the number of hosts that are
21359 tried when an SMTP delivery takes place. They are &%hosts_max_try%& and
21360 &%hosts_max_try_hardlimit%&.
21361
21362
21363 The &%hosts_max_try%& option limits the number of hosts that are tried
21364 for a single delivery. However, despite the term &"host"& in its name, the
21365 option actually applies to each IP address independently. In other words, a
21366 multihomed host is treated as several independent hosts, just as it is for
21367 retrying.
21368
21369 Many of the larger ISPs have multiple MX records which often point to
21370 multihomed hosts. As a result, a list of a dozen or more IP addresses may be
21371 created as a result of routing one of these domains.
21372
21373 Trying every single IP address on such a long list does not seem sensible; if
21374 several at the top of the list fail, it is reasonable to assume there is some
21375 problem that is likely to affect all of them. Roughly speaking, the value of
21376 &%hosts_max_try%& is the maximum number that are tried before deferring the
21377 delivery. However, the logic cannot be quite that simple.
21378
21379 Firstly, IP addresses that are skipped because their retry times have not
21380 arrived do not count, and in addition, addresses that are past their retry
21381 limits are also not counted, even when they are tried. This means that when
21382 some IP addresses are past their retry limits, more than the value of
21383 &%hosts_max_retry%& may be tried. The reason for this behaviour is to ensure
21384 that all IP addresses are considered before timing out an email address (but
21385 see below for an exception).
21386
21387 Secondly, when the &%hosts_max_try%& limit is reached, Exim looks down the host
21388 list to see if there is a subsequent host with a different (higher valued) MX.
21389 If there is, that host is considered next, and the current IP address is used
21390 but not counted. This behaviour helps in the case of a domain with a retry rule
21391 that hardly ever delays any hosts, as is now explained:
21392
21393 Consider the case of a long list of hosts with one MX value, and a few with a
21394 higher MX value. If &%hosts_max_try%& is small (the default is 5) only a few
21395 hosts at the top of the list are tried at first. With the default retry rule,
21396 which specifies increasing retry times, the higher MX hosts are eventually
21397 tried when those at the top of the list are skipped because they have not
21398 reached their retry times.
21399
21400 However, it is common practice to put a fixed short retry time on domains for
21401 large ISPs, on the grounds that their servers are rarely down for very long.
21402 Unfortunately, these are exactly the domains that tend to resolve to long lists
21403 of hosts. The short retry time means that the lowest MX hosts are tried every
21404 time. The attempts may be in a different order because of random sorting, but
21405 without the special MX check, the higher MX hosts would never be tried until
21406 all the lower MX hosts had timed out (which might be several days), because
21407 there are always some lower MX hosts that have reached their retry times. With
21408 the special check, Exim considers at least one IP address from each MX value at
21409 every delivery attempt, even if the &%hosts_max_try%& limit has already been
21410 reached.
21411
21412 The above logic means that &%hosts_max_try%& is not a hard limit, and in
21413 particular, Exim normally eventually tries all the IP addresses before timing
21414 out an email address. When &%hosts_max_try%& was implemented, this seemed a
21415 reasonable thing to do. Recently, however, some lunatic DNS configurations have
21416 been set up with hundreds of IP addresses for some domains. It can
21417 take a very long time indeed for an address to time out in these cases.
21418
21419 The &%hosts_max_try_hardlimit%& option was added to help with this problem.
21420 Exim never tries more than this number of IP addresses; if it hits this limit
21421 and they are all timed out, the email address is bounced, even though not all
21422 possible IP addresses have been tried.
21423 .ecindex IIDsmttra1
21424 .ecindex IIDsmttra2
21425
21426
21427
21428
21429
21430 . ////////////////////////////////////////////////////////////////////////////
21431 . ////////////////////////////////////////////////////////////////////////////
21432
21433 .chapter "Address rewriting" "CHAPrewrite"
21434 .scindex IIDaddrew "rewriting" "addresses"
21435 There are some circumstances in which Exim automatically rewrites domains in
21436 addresses. The two most common are when an address is given without a domain
21437 (referred to as an &"unqualified address"&) or when an address contains an
21438 abbreviated domain that is expanded by DNS lookup.
21439
21440 Unqualified envelope addresses are accepted only for locally submitted
21441 messages, or for messages that are received from hosts matching
21442 &%sender_unqualified_hosts%& or &%recipient_unqualified_hosts%&, as
21443 appropriate. Unqualified addresses in header lines are qualified if they are in
21444 locally submitted messages, or messages from hosts that are permitted to send
21445 unqualified envelope addresses. Otherwise, unqualified addresses in header
21446 lines are neither qualified nor rewritten.
21447
21448 One situation in which Exim does &'not'& automatically rewrite a domain is
21449 when it is the name of a CNAME record in the DNS. The older RFCs suggest that
21450 such a domain should be rewritten using the &"canonical"& name, and some MTAs
21451 do this. The new RFCs do not contain this suggestion.
21452
21453
21454 .section "Explicitly configured address rewriting"
21455 This chapter describes the rewriting rules that can be used in the
21456 main rewrite section of the configuration file, and also in the generic
21457 &%headers_rewrite%& option that can be set on any transport.
21458
21459 Some people believe that configured address rewriting is a Mortal Sin.
21460 Others believe that life is not possible without it. Exim provides the
21461 facility; you do not have to use it.
21462
21463 The main rewriting rules that appear in the &"rewrite"& section of the
21464 configuration file are applied to addresses in incoming messages, both envelope
21465 addresses and addresses in header lines. Each rule specifies the types of
21466 address to which it applies.
21467
21468 Whether or not addresses in header lines are rewritten depends on the origin of
21469 the headers and the type of rewriting. Global rewriting, that is, rewriting
21470 rules from the rewrite section of the configuration file, is applied only to
21471 those headers that were received with the message. Header lines that are added
21472 by ACLs or by a system filter or by individual routers or transports (which
21473 are specific to individual recipient addresses) are not rewritten by the global
21474 rules.
21475
21476 Rewriting at transport time, by means of the &%headers_rewrite%& option,
21477 applies all headers except those added by routers and transports. That is, as
21478 well as the headers that were received with the message, it also applies to
21479 headers that were added by an ACL or a system filter.
21480
21481
21482 In general, rewriting addresses from your own system or domain has some
21483 legitimacy. Rewriting other addresses should be done only with great care and
21484 in special circumstances. The author of Exim believes that rewriting should be
21485 used sparingly, and mainly for &"regularizing"& addresses in your own domains.
21486 Although it can sometimes be used as a routing tool, this is very strongly
21487 discouraged.
21488
21489 There are two commonly encountered circumstances where rewriting is used, as
21490 illustrated by these examples:
21491
21492 .ilist
21493 The company whose domain is &'hitch.fict.example'& has a number of hosts that
21494 exchange mail with each other behind a firewall, but there is only a single
21495 gateway to the outer world. The gateway rewrites &'*.hitch.fict.example'& as
21496 &'hitch.fict.example'& when sending mail off-site.
21497 .next
21498 A host rewrites the local parts of its own users so that, for example,
21499 &'fp42@hitch.fict.example'& becomes &'Ford.Prefect@hitch.fict.example'&.
21500 .endlist
21501
21502
21503
21504 .section "When does rewriting happen?"
21505 .cindex "rewriting" "timing of"
21506 .cindex "&ACL;" "rewriting addresses in"
21507 Configured address rewriting can take place at several different stages of a
21508 message's processing.
21509
21510 .cindex "&$sender_address$&"
21511 At the start of an ACL for MAIL, the sender address may have been rewritten
21512 by a special SMTP-time rewrite rule (see section &<<SECTrewriteS>>&), but no
21513 ordinary rewrite rules have yet been applied. If, however, the sender address
21514 is verified in the ACL, it is rewritten before verification, and remains
21515 rewritten thereafter. The subsequent value of &$sender_address$& is the
21516 rewritten address. This also applies if sender verification happens in a
21517 RCPT ACL. Otherwise, when the sender address is not verified, it is
21518 rewritten as soon as a message's header lines have been received.
21519
21520 .cindex "&$domain$&"
21521 .cindex "&$local_part$&"
21522 Similarly, at the start of an ACL for RCPT, the current recipient's address
21523 may have been rewritten by a special SMTP-time rewrite rule, but no ordinary
21524 rewrite rules have yet been applied to it. However, the behaviour is different
21525 from the sender address when a recipient is verified. The address is rewritten
21526 for the verification, but the rewriting is not remembered at this stage. The
21527 value of &$local_part$& and &$domain$& after verification are always the same
21528 as they were before (that is, they contain the unrewritten &-- except for
21529 SMTP-time rewriting &-- address).
21530
21531 As soon as a message's header lines have been received, all the envelope
21532 recipient addresses are permanently rewritten, and rewriting is also applied to
21533 the addresses in the header lines (if configured). This happens before adding
21534 any header lines that were specified in MAIL or RCPT ACLs, and
21535 .cindex "&[local_scan()]& function" "address rewriting; timing of"
21536 before the DATA ACL and &[local_scan()]& functions are run.
21537
21538 When an address is being routed, either for delivery or for verification,
21539 rewriting is applied immediately to child addresses that are generated by
21540 redirection, unless &%no_rewrite%& is set on the router.
21541
21542 .cindex "envelope sender" "rewriting at transport time"
21543 .cindex "rewriting" "at transport time"
21544 .cindex "header lines" "rewriting at transport time"
21545 At transport time, additional rewriting of addresses in header lines can be
21546 specified by setting the generic &%headers_rewrite%& option on a transport.
21547 This option contains rules that are identical in form to those in the rewrite
21548 section of the configuration file. They are applied to the original message
21549 header lines and any that were added by ACLs or a system filter. They are not
21550 applied to header lines that are added by routers or the transport.
21551
21552 The outgoing envelope sender can be rewritten by means of the &%return_path%&
21553 transport option. However, it is not possible to rewrite envelope recipients at
21554 transport time.
21555
21556
21557
21558
21559 .section "Testing the rewriting rules that apply on input"
21560 .cindex "rewriting" "testing"
21561 .cindex "testing" "rewriting"
21562 Exim's input rewriting configuration appears in a part of the run time
21563 configuration file headed by &"begin rewrite"&. It can be tested by the
21564 &%-brw%& command line option. This takes an address (which can be a full RFC
21565 2822 address) as its argument. The output is a list of how the address would be
21566 transformed by the rewriting rules for each of the different places it might
21567 appear in an incoming message, that is, for each different header and for the
21568 envelope sender and recipient fields. For example,
21569 .code
21570 exim -brw ph10@exim.workshop.example
21571 .endd
21572 might produce the output
21573 .code
21574 sender: Philip.Hazel@exim.workshop.example
21575 from: Philip.Hazel@exim.workshop.example
21576 to: ph10@exim.workshop.example
21577 cc: ph10@exim.workshop.example
21578 bcc: ph10@exim.workshop.example
21579 reply-to: Philip.Hazel@exim.workshop.example
21580 env-from: Philip.Hazel@exim.workshop.example
21581 env-to: ph10@exim.workshop.example
21582 .endd
21583 which shows that rewriting has been set up for that address when used in any of
21584 the source fields, but not when it appears as a recipient address. At the
21585 present time, there is no equivalent way of testing rewriting rules that are
21586 set for a particular transport.
21587
21588
21589 .section "Rewriting rules"
21590 .cindex "rewriting" "rules"
21591 The rewrite section of the configuration file consists of lines of rewriting
21592 rules in the form
21593 .display
21594 <&'source pattern'&>  <&'replacement'&>  <&'flags'&>
21595 .endd
21596 Rewriting rules that are specified for the &%headers_rewrite%& generic
21597 transport option are given as a colon-separated list. Each item in the list
21598 takes the same form as a line in the main rewriting configuration (except that
21599 any colons must be doubled, of course).
21600
21601 The formats of source patterns and replacement strings are described below.
21602 Each is terminated by white space, unless enclosed in double quotes, in which
21603 case normal quoting conventions apply inside the quotes. The flags are single
21604 characters which may appear in any order. Spaces and tabs between them are
21605 ignored.
21606
21607 For each address that could potentially be rewritten, the rules are scanned in
21608 order, and replacements for the address from earlier rules can themselves be
21609 replaced by later rules (but see the &"q"& and &"R"& flags).
21610
21611 The order in which addresses are rewritten is undefined, may change between
21612 releases, and must not be relied on, with one exception: when a message is
21613 received, the envelope sender is always rewritten first, before any header
21614 lines are rewritten. For example, the replacement string for a rewrite of an
21615 address in &'To:'& must not assume that the message's address in &'From:'& has
21616 (or has not) already been rewritten. However, a rewrite of &'From:'& may assume
21617 that the envelope sender has already been rewritten.
21618
21619 .cindex "&$domain$&"
21620 .cindex "&$local_part$&"
21621 The variables &$local_part$& and &$domain$& can be used in the replacement
21622 string to refer to the address that is being rewritten. Note that lookup-driven
21623 rewriting can be done by a rule of the form
21624 .code
21625 *@*   ${lookup ...
21626 .endd
21627 where the lookup key uses &$1$& and &$2$& or &$local_part$& and &$domain$& to
21628 refer to the address that is being rewritten.
21629
21630
21631 .section "Rewriting patterns"
21632 .cindex "rewriting" "patterns"
21633 .cindex "address list" "in a rewriting pattern"
21634 The source pattern in a rewriting rule is any item which may appear in an
21635 address list (see section &<<SECTaddresslist>>&). It is in fact processed as a
21636 single-item address list, which means that it is expanded before being tested
21637 against the address. As always, if you use a regular expression as a pattern,
21638 you must take care to escape dollar and backslash characters, or use the &`\N`&
21639 facility to suppress string expansion within the regular expression.
21640
21641 Domains in patterns should be given in lower case. Local parts in patterns are
21642 case-sensitive. If you want to do case-insensitive matching of local parts, you
21643 can use a regular expression that starts with &`^(?i)`&.
21644
21645 .cindex "numerical variables (&$1$& &$2$& etc)" "in rewriting rules"
21646 After matching, the numerical variables &$1$&, &$2$&, etc. may be set,
21647 depending on the type of match which occurred. These can be used in the
21648 replacement string to insert portions of the incoming address. &$0$& always
21649 refers to the complete incoming address. When a regular expression is used, the
21650 numerical variables are set from its capturing subexpressions. For other types
21651 of pattern they are set as follows:
21652
21653 .ilist
21654 If a local part or domain starts with an asterisk, the numerical variables
21655 refer to the character strings matched by asterisks, with &$1$& associated with
21656 the first asterisk, and &$2$& with the second, if present. For example, if the
21657 pattern
21658 .code
21659 *queen@*.fict.example
21660 .endd
21661 is matched against the address &'hearts-queen@wonderland.fict.example'& then
21662 .code
21663 $0 = hearts-queen@wonderland.fict.example
21664 $1 = hearts-
21665 $2 = wonderland
21666 .endd
21667 Note that if the local part does not start with an asterisk, but the domain
21668 does, it is &$1$& that contains the wild part of the domain.
21669
21670 .next
21671 If the domain part of the pattern is a partial lookup, the wild and fixed parts
21672 of the domain are placed in the next available numerical variables. Suppose,
21673 for example, that the address &'foo@bar.baz.example'& is processed by a
21674 rewriting rule of the form
21675 .display
21676 &`*@partial-dbm;/some/dbm/file`&    <&'replacement string'&>
21677 .endd
21678 and the key in the file that matches the domain is &`*.baz.example`&. Then
21679 .code
21680 $1 = foo
21681 $2 = bar
21682 $3 = baz.example
21683 .endd
21684 If the address &'foo@baz.example'& is looked up, this matches the same
21685 wildcard file entry, and in this case &$2$& is set to the empty string, but
21686 &$3$& is still set to &'baz.example'&. If a non-wild key is matched in a
21687 partial lookup, &$2$& is again set to the empty string and &$3$& is set to the
21688 whole domain. For non-partial domain lookups, no numerical variables are set.
21689 .endlist
21690
21691
21692 .section "Rewriting replacements"
21693 .cindex "rewriting" "replacements"
21694 If the replacement string for a rule is a single asterisk, addresses that
21695 match the pattern and the flags are &'not'& rewritten, and no subsequent
21696 rewriting rules are scanned. For example,
21697 .code
21698 hatta@lookingglass.fict.example  *  f
21699 .endd
21700 specifies that &'hatta@lookingglass.fict.example'& is never to be rewritten in
21701 &'From:'& headers.
21702
21703 .cindex "&$domain$&"
21704 .cindex "&$local_part$&"
21705 If the replacement string is not a single asterisk, it is expanded, and must
21706 yield a fully qualified address. Within the expansion, the variables
21707 &$local_part$& and &$domain$& refer to the address that is being rewritten.
21708 Any letters they contain retain their original case &-- they are not lower
21709 cased. The numerical variables are set up according to the type of pattern that
21710 matched the address, as described above. If the expansion is forced to fail by
21711 the presence of &"fail"& in a conditional or lookup item, rewriting by the
21712 current rule is abandoned, but subsequent rules may take effect. Any other
21713 expansion failure causes the entire rewriting operation to be abandoned, and an
21714 entry written to the panic log.
21715
21716
21717
21718 .section "Rewriting flags"
21719 There are three different kinds of flag that may appear on rewriting rules:
21720
21721 .ilist
21722 Flags that specify which headers and envelope addresses to rewrite: E, F, T, b,
21723 c, f, h, r, s, t.
21724 .next
21725 A flag that specifies rewriting at SMTP time: S.
21726 .next
21727 Flags that control the rewriting process: Q, q, R, w.
21728 .endlist
21729
21730 For rules that are part of the &%headers_rewrite%& generic transport option,
21731 E, F, T, and S are not permitted.
21732
21733
21734
21735 .section "Flags specifying which headers and envelope addresses to rewrite"
21736 .cindex "rewriting" "flags"
21737 If none of the following flag letters, nor the &"S"& flag (see section
21738 &<<SECTrewriteS>>&) are present, a main rewriting rule applies to all headers
21739 and to both the sender and recipient fields of the envelope, whereas a
21740 transport-time rewriting rule just applies to all headers. Otherwise, the
21741 rewriting rule is skipped unless the relevant addresses are being processed.
21742 .display
21743 &`E`&       rewrite all envelope fields
21744 &`F`&       rewrite the envelope From field
21745 &`T`&       rewrite the envelope To field
21746 &`b`&       rewrite the &'Bcc:'& header
21747 &`c`&       rewrite the &'Cc:'& header
21748 &`f`&       rewrite the &'From:'& header
21749 &`h`&       rewrite all headers
21750 &`r`&       rewrite the &'Reply-To:'& header
21751 &`s`&       rewrite the &'Sender:'& header
21752 &`t`&       rewrite the &'To:'& header
21753 .endd
21754 You should be particularly careful about rewriting &'Sender:'& headers, and
21755 restrict this to special known cases in your own domains.
21756
21757
21758 .section "The SMTP-time rewriting flag" "SECTrewriteS"
21759 .cindex "SMTP" "rewriting malformed addresses"
21760 .cindex "RCPT" "rewriting argument of"
21761 .cindex "MAIL" "rewriting argument of"
21762 The rewrite flag &"S"& specifies a rewrite of incoming envelope addresses at
21763 SMTP time, as soon as an address is received in a MAIL or RCPT command, and
21764 before any other processing; even before syntax checking. The pattern is
21765 required to be a regular expression, and it is matched against the whole of the
21766 data for the command, including any surrounding angle brackets.
21767
21768 .cindex "&$domain$&"
21769 .cindex "&$local_part$&"
21770 This form of rewrite rule allows for the handling of addresses that are not
21771 compliant with RFCs 2821 and 2822 (for example, &"bang paths"& in batched SMTP
21772 input). Because the input is not required to be a syntactically valid address,
21773 the variables &$local_part$& and &$domain$& are not available during the
21774 expansion of the replacement string. The result of rewriting replaces the
21775 original address in the MAIL or RCPT command.
21776
21777
21778 .section "Flags controlling the rewriting process"
21779 There are four flags which control the way the rewriting process works. These
21780 take effect only when a rule is invoked, that is, when the address is of the
21781 correct type (matches the flags) and matches the pattern:
21782
21783 .ilist
21784 If the &"Q"& flag is set on a rule, the rewritten address is permitted to be an
21785 unqualified local part. It is qualified with &%qualify_recipient%&. In the
21786 absence of &"Q"& the rewritten address must always include a domain.
21787 .next
21788 If the &"q"& flag is set on a rule, no further rewriting rules are considered,
21789 even if no rewriting actually takes place because of a &"fail"& in the
21790 expansion. The &"q"& flag is not effective if the address is of the wrong type
21791 (does not match the flags) or does not match the pattern.
21792 .next
21793 The &"R"& flag causes a successful rewriting rule to be re-applied to the new
21794 address, up to ten times. It can be combined with the &"q"& flag, to stop
21795 rewriting once it fails to match (after at least one successful rewrite).
21796 .next
21797 .cindex "rewriting" "whole addresses"
21798 When an address in a header is rewritten, the rewriting normally applies only
21799 to the working part of the address, with any comments and RFC 2822 &"phrase"&
21800 left unchanged. For example, rewriting might change
21801 .code
21802 From: Ford Prefect <fp42@restaurant.hitch.fict.example>
21803 .endd
21804 into
21805 .code
21806 From: Ford Prefect <prefectf@hitch.fict.example>
21807 .endd
21808 .cindex "RFC 2047"
21809 Sometimes there is a need to replace the whole address item, and this can be
21810 done by adding the flag letter &"w"& to a rule. If this is set on a rule that
21811 causes an address in a header line to be rewritten, the entire address is
21812 replaced, not just the working part. The replacement must be a complete RFC
21813 2822 address, including the angle brackets if necessary. If text outside angle
21814 brackets contains a character whose value is greater than 126 or less than 32
21815 (except for tab), the text is encoded according to RFC 2047. The character set
21816 is taken from &%headers_charset%&, which defaults to ISO-8859-1.
21817
21818 When the &"w"& flag is set on a rule that causes an envelope address to be
21819 rewritten, all but the working part of the replacement address is discarded.
21820 .endlist
21821
21822
21823 .section "Rewriting examples"
21824 Here is an example of the two common rewriting paradigms:
21825 .code
21826 *@*.hitch.fict.example  $1@hitch.fict.example
21827 *@hitch.fict.example    ${lookup{$1}dbm{/etc/realnames}\
21828                      {$value}fail}@hitch.fict.example bctfrF
21829 .endd
21830 Note the use of &"fail"& in the lookup expansion in the second rule, forcing
21831 the string expansion to fail if the lookup does not succeed. In this context it
21832 has the effect of leaving the original address unchanged, but Exim goes on to
21833 consider subsequent rewriting rules, if any, because the &"q"& flag is not
21834 present in that rule. An alternative to &"fail"& would be to supply &$1$&
21835 explicitly, which would cause the rewritten address to be the same as before,
21836 at the cost of a small bit of processing. Not supplying either of these is an
21837 error, since the rewritten address would then contain no local part.
21838
21839 The first example above replaces the domain with a superior, more general
21840 domain. This may not be desirable for certain local parts. If the rule
21841 .code
21842 root@*.hitch.fict.example  *
21843 .endd
21844 were inserted before the first rule, rewriting would be suppressed for the
21845 local part &'root'& at any domain ending in &'hitch.fict.example'&.
21846
21847 Rewriting can be made conditional on a number of tests, by making use of
21848 &${if$& in the expansion item. For example, to apply a rewriting rule only to
21849 messages that originate outside the local host:
21850 .code
21851 *@*.hitch.fict.example  "${if !eq {$sender_host_address}{}\
21852                          {$1@hitch.fict.example}fail}"
21853 .endd
21854 The replacement string is quoted in this example because it contains white
21855 space.
21856
21857 .cindex "rewriting" "bang paths"
21858 .cindex "bang paths" "rewriting"
21859 Exim does not handle addresses in the form of &"bang paths"&. If it sees such
21860 an address it treats it as an unqualified local part which it qualifies with
21861 the local qualification domain (if the source of the message is local or if the
21862 remote host is permitted to send unqualified addresses). Rewriting can
21863 sometimes be used to handle simple bang paths with a fixed number of
21864 components. For example, the rule
21865 .code
21866 \N^([^!]+)!(.*)@your.domain.example$\N   $2@$1
21867 .endd
21868 rewrites a two-component bang path &'host.name!user'& as the domain address
21869 &'user@host.name'&. However, there is a security implication in using this as
21870 a global rewriting rule for envelope addresses. It can provide a backdoor
21871 method for using your system as a relay, because the incoming addresses appear
21872 to be local. If the bang path addresses are received via SMTP, it is safer to
21873 use the &"S"& flag to rewrite them as they are received, so that relay checking
21874 can be done on the rewritten addresses.
21875 .ecindex IIDaddrew
21876
21877
21878
21879
21880
21881 . ////////////////////////////////////////////////////////////////////////////
21882 . ////////////////////////////////////////////////////////////////////////////
21883
21884 .chapter "Retry configuration" "CHAPretry"
21885 .scindex IIDretconf1 "retry configuration" "description of"
21886 .scindex IIDregconf2 "configuration file" "retry section"
21887 The &"retry"& section of the run time configuration file contains a list of
21888 retry rules that control how often Exim tries to deliver messages that cannot
21889 be delivered at the first attempt. If there are no retry rules, temporary
21890 errors are treated as permanent. The &%-brt%& command line option can be used
21891 to test which retry rule will be used for a given address, domain and error.
21892
21893 The most common cause of retries is temporary failure to deliver to a remote
21894 host because the host is down, or inaccessible because of a network problem.
21895 Exim's retry processing in this case is applied on a per-host (strictly, per IP
21896 address) basis, not on a per-message basis. Thus, if one message has recently
21897 been delayed, delivery of a new message to the same host is not immediately
21898 tried, but waits for the host's retry time to arrive. If the &%retry_defer%&
21899 log selector is set, the message
21900 .cindex "retry" "time not reached"
21901 &"retry time not reached"& is written to the main log whenever a delivery is
21902 skipped for this reason. Section &<<SECToutSMTPerr>>& contains more details of
21903 the handling of errors during remote deliveries.
21904
21905 Retry processing applies to routing as well as to delivering, except as covered
21906 in the next paragraph. The retry rules do not distinguish between these
21907 actions. It is not possible, for example, to specify different behaviour for
21908 failures to route the domain &'snark.fict.example'& and failures to deliver to
21909 the host &'snark.fict.example'&. I didn't think anyone would ever need this
21910 added complication, so did not implement it. However, although they share the
21911 same retry rule, the actual retry times for routing and transporting a given
21912 domain are maintained independently.
21913
21914 When a delivery is not part of a queue run (typically an immediate delivery on
21915 receipt of a message), the routers are always run, and local deliveries are
21916 always attempted, even if retry times are set for them. This makes for better
21917 behaviour if one particular message is causing problems (for example, causing
21918 quota overflow, or provoking an error in a filter file). If such a delivery
21919 suffers a temporary failure, the retry data is updated as normal, and
21920 subsequent delivery attempts from queue runs occur only when the retry time for
21921 the local address is reached.
21922
21923 .section "Changing retry rules"
21924 If you change the retry rules in your configuration, you should consider
21925 whether or not to delete the retry data that is stored in Exim's spool area in
21926 files with names like &_db/retry_&. Deleting any of Exim's hints files is
21927 always safe; that is why they are called &"hints"&.
21928
21929 The hints retry data contains suggested retry times based on the previous
21930 rules. In the case of a long-running problem with a remote host, it might
21931 record the fact that the host has timed out. If your new rules increase the
21932 timeout time for such a host, you should definitely remove the old retry data
21933 and let Exim recreate it, based on the new rules. Otherwise Exim might bounce
21934 messages that it should now be retaining.
21935
21936
21937
21938 .section "Format of retry rules"
21939 .cindex "retry" "rules"
21940 Each retry rule occupies one line and consists of three or four parts,
21941 separated by white space: a pattern, an error name, an optional list of sender
21942 addresses, and a list of retry parameters. The pattern and sender lists must be
21943 enclosed in double quotes if they contain white space. The rules are searched
21944 in order until one is found where the pattern, error name, and sender list (if
21945 present) match the failing host or address, the error that occurred, and the
21946 message's sender, respectively.
21947
21948
21949 The pattern is any single item that may appear in an address list (see section
21950 &<<SECTaddresslist>>&). It is in fact processed as a one-item address list,
21951 which means that it is expanded before being tested against the address that
21952 has been delayed. A negated address list item is permitted. Address
21953 list processing treats a plain domain name as if it were preceded by &"*@"&,
21954 which makes it possible for many retry rules to start with just a domain. For
21955 example,
21956 .code
21957 lookingglass.fict.example        *  F,24h,30m;
21958 .endd
21959 provides a rule for any address in the &'lookingglass.fict.example'& domain,
21960 whereas
21961 .code
21962 alice@lookingglass.fict.example  *  F,24h,30m;
21963 .endd
21964 applies only to temporary failures involving the local part &%alice%&.
21965 In practice, almost all rules start with a domain name pattern without a local
21966 part.
21967
21968 .cindex "regular expressions" "in retry rules"
21969 &*Warning*&: If you use a regular expression in a routing rule pattern, it
21970 must match a complete address, not just a domain, because that is how regular
21971 expressions work in address lists.
21972 .display
21973 &`^\Nxyz\d+\.abc\.example$\N        *  G,1h,10m,2`&     &%Wrong%&
21974 &`^\N[^@]+@xyz\d+\.abc\.example$\N  *  G,1h,10m,2`&     &%Right%&
21975 .endd
21976
21977
21978 .section "Choosing which retry rule to use for address errors"
21979 When Exim is looking for a retry rule after a routing attempt has failed (for
21980 example, after a DNS timeout), each line in the retry configuration is tested
21981 against the complete address only if &%retry_use_local_part%& is set for the
21982 router. Otherwise, only the domain is used, except when matching against a
21983 regular expression, when the local part of the address is replaced with &"*"&.
21984 A domain on its own can match a domain pattern, or a pattern that starts with
21985 &"*@"&. By default, &%retry_use_local_part%& is true for routers where
21986 &%check_local_user%& is true, and false for other routers.
21987
21988 Similarly, when Exim is looking for a retry rule after a local delivery has
21989 failed (for example, after a mailbox full error), each line in the retry
21990 configuration is tested against the complete address only if
21991 &%retry_use_local_part%& is set for the transport (it defaults true for all
21992 local transports).
21993
21994 .new
21995 .cindex "4&'xx'& responses" "retry rules for"
21996 However, when Exim is looking for a retry rule after a remote delivery attempt
21997 suffers an address error (a 4&'xx'& SMTP response for a recipient address), the
21998 whole address is always used as the key when searching the retry rules. The
21999 rule that is found is used to create a retry time for the combination of the
22000 failing address and the message's sender. It is the combination of sender and
22001 recipient that is delayed in subsequent queue runs until its retry time is
22002 reached. You can delay the recipient without regard to the sender by setting
22003 &%address_retry_include_sender%& false in the &(smtp)& transport but this can
22004 lead to problems with servers that regularly issue 4&'xx'& responses to RCPT
22005 commands.
22006 .wen
22007
22008
22009
22010 .section "Choosing which retry rule to use for host and message errors"
22011 For a temporary error that is not related to an individual address (for
22012 example, a connection timeout), each line in the retry configuration is checked
22013 twice. First, the name of the remote host is used as a domain name (preceded by
22014 &"*@"& when matching a regular expression). If this does not match the line,
22015 the domain from the email address is tried in a similar fashion. For example,
22016 suppose the MX records for &'a.b.c.example'& are
22017 .code
22018 a.b.c.example  MX  5  x.y.z.example
22019                MX  6  p.q.r.example
22020                MX  7  m.n.o.example
22021 .endd
22022 and the retry rules are
22023 .code
22024 p.q.r.example    *      F,24h,30m;
22025 a.b.c.example    *      F,4d,45m;
22026 .endd
22027 and a delivery to the host &'x.y.z.example'& suffers a connection failure. The
22028 first rule matches neither the host nor the domain, so Exim looks at the second
22029 rule. This does not match the host, but it does match the domain, so it is used
22030 to calculate the retry time for the host &'x.y.z.example'&. Meanwhile, Exim
22031 tries to deliver to &'p.q.r.example'&. If this also suffers a host error, the
22032 first retry rule is used, because it matches the host.
22033
22034 In other words, temporary failures to deliver to host &'p.q.r.example'& use the
22035 first rule to determine retry times, but for all the other hosts for the domain
22036 &'a.b.c.example'&, the second rule is used. The second rule is also used if
22037 routing to &'a.b.c.example'& suffers a temporary failure.
22038
22039 &*Note*&: The host name is used when matching the patterns, not its IP address.
22040 However, if a message is routed directly to an IP address without the use of a
22041 host name, for example, if a &(manualroute)& router contains a setting such as:
22042 .code
22043 route_list = *.a.example  192.168.34.23
22044 .endd
22045 then the &"host name"& that is used when searching for a retry rule is the
22046 textual form of the IP address.
22047
22048 .section "Retry rules for specific errors"
22049 .cindex "retry" "specific errors; specifying"
22050 The second field in a retry rule is the name of a particular error, or an
22051 asterisk, which matches any error. The errors that can be tested for are:
22052
22053 .vlist
22054 .vitem &%auth_failed%&
22055 Authentication failed when trying to send to a host in the
22056 &%hosts_require_auth%& list in an &(smtp)& transport.
22057
22058 .vitem &%data_4xx%&
22059 A 4&'xx'& error was received for an outgoing DATA command, either immediately
22060 after the command, or after sending the message's data.
22061
22062 .vitem &%mail_4xx%&
22063 A 4&'xx'& error was received for an outgoing MAIL command.
22064
22065 .vitem &%rcpt_4xx%&
22066 A 4&'xx'& error was received for an outgoing RCPT command.
22067 .endlist
22068
22069 For the three 4&'xx'& errors, either the first or both of the x's can be given
22070 as specific digits, for example: &`mail_45x`& or &`rcpt_436`&. For example, to
22071 recognize 452 errors given to RCPT commands for addresses in a certain domain,
22072 and have retries every ten minutes with a one-hour timeout, you could set up a
22073 retry rule of this form:
22074 .code
22075 the.domain.name  rcpt_452   F,1h,10m
22076 .endd
22077 These errors apply to both outgoing SMTP (the &(smtp)& transport) and outgoing
22078 LMTP (either the &(lmtp)& transport, or the &(smtp)& transport in LMTP mode).
22079
22080 .vlist
22081 .vitem &%lost_connection%&
22082 A server unexpectedly closed the SMTP connection. There may, of course,
22083 legitimate reasons for this (host died, network died), but if it repeats a lot
22084 for the same host, it indicates something odd.
22085
22086 .vitem &%refused_MX%&
22087 A connection to a host obtained from an MX record was refused.
22088
22089 .vitem &%refused_A%&
22090 A connection to a host not obtained from an MX record was refused.
22091
22092 .vitem &%refused%&
22093 A connection was refused.
22094
22095 .vitem &%timeout_connect_MX%&
22096 A connection attempt to a host obtained from an MX record timed out.
22097
22098 .vitem &%timeout_connect_A%&
22099 A connection attempt to a host not obtained from an MX record timed out.
22100
22101 .vitem &%timeout_connect%&
22102 A connection attempt timed out.
22103
22104 .vitem &%timeout_MX%&
22105 There was a timeout while connecting or during an SMTP session with a host
22106 obtained from an MX record.
22107
22108 .vitem &%timeout_A%&
22109 There was a timeout while connecting or during an SMTP session with a host not
22110 obtained from an MX record.
22111
22112 .vitem &%timeout%&
22113 There was a timeout while connecting or during an SMTP session.
22114
22115 .vitem &%tls_required%&
22116 The server was required to use TLS (it matched &%hosts_require_tls%& in the
22117 &(smtp)& transport), but either did not offer TLS, or it responded with 4&'xx'&
22118 to STARTTLS, or there was a problem setting up the TLS connection.
22119
22120 .vitem &%quota%&
22121 A mailbox quota was exceeded in a local delivery by the &(appendfile)&
22122 transport.
22123
22124 .vitem &%quota_%&<&'time'&>
22125 .cindex "quota" "error testing in retry rule"
22126 .cindex "retry" "quota error testing"
22127 A mailbox quota was exceeded in a local delivery by the &(appendfile)&
22128 transport, and the mailbox has not been accessed for <&'time'&>. For example,
22129 &'quota_4d'& applies to a quota error when the mailbox has not been accessed
22130 for four days.
22131 .endlist
22132
22133 .cindex "mailbox" "time of last read"
22134 The idea of &%quota_%&<&'time'&> is to make it possible to have shorter
22135 timeouts when the mailbox is full and is not being read by its owner. Ideally,
22136 it should be based on the last time that the user accessed the mailbox.
22137 However, it is not always possible to determine this. Exim uses the following
22138 heuristic rules:
22139
22140 .ilist
22141 If the mailbox is a single file, the time of last access (the &"atime"&) is
22142 used. As no new messages are being delivered (because the mailbox is over
22143 quota), Exim does not access the file, so this is the time of last user access.
22144 .next
22145 .cindex "maildir format" "time of last read"
22146 For a maildir delivery, the time of last modification of the &_new_&
22147 subdirectory is used. As the mailbox is over quota, no new files are created in
22148 the &_new_& subdirectory, because no new messages are being delivered. Any
22149 change to the &_new_& subdirectory is therefore assumed to be the result of an
22150 MUA moving a new message to the &_cur_& directory when it is first read. The
22151 time that is used is therefore the last time that the user read a new message.
22152 .next
22153 For other kinds of multi-file mailbox, the time of last access cannot be
22154 obtained, so a retry rule that uses this type of error field is never matched.
22155 .endlist
22156
22157 The quota errors apply both to system-enforced quotas and to Exim's own quota
22158 mechanism in the &(appendfile)& transport. The &'quota'& error also applies
22159 when a local delivery is deferred because a partition is full (the ENOSPC
22160 error).
22161
22162
22163
22164 .section "Retry rules for specified senders"
22165 .cindex "retry" "rules; sender-specific"
22166 You can specify retry rules that apply only when the failing message has a
22167 specific sender. In particular, this can be used to define retry rules that
22168 apply only to bounce messages. The third item in a retry rule can be of this
22169 form:
22170 .display
22171 &`senders=`&<&'address list'&>
22172 .endd
22173 The retry timings themselves are then the fourth item. For example:
22174 .code
22175 *   rcpt_4xx   senders=:   F,1h,30m
22176 .endd
22177 matches recipient 4&'xx'& errors for bounce messages sent to any address at any
22178 host. If the address list contains white space, it must be enclosed in quotes.
22179 For example:
22180 .code
22181 a.domain  rcpt_452  senders="xb.dom : yc.dom"  G,8h,10m,1.5
22182 .endd
22183 &*Warning*&: This facility can be unhelpful if it is used for host errors
22184 (which do not depend on the recipient). The reason is that the sender is used
22185 only to match the retry rule. Once the rule has been found for a host error,
22186 its contents are used to set a retry time for the host, and this will apply to
22187 all messages, not just those with specific senders.
22188
22189 When testing retry rules using &%-brt%&, you can supply a sender using the
22190 &%-f%& command line option, like this:
22191 .code
22192 exim -f "" -brt user@dom.ain
22193 .endd
22194 If you do not set &%-f%& with &%-brt%&, a retry rule that contains a senders
22195 list is never matched.
22196
22197
22198
22199
22200
22201 .section "Retry parameters"
22202 .cindex "retry" "parameters in rules"
22203 The third (or fourth, if a senders list is present) field in a retry rule is a
22204 sequence of retry parameter sets, separated by semicolons. Each set consists of
22205 .display
22206 <&'letter'&>,<&'cutoff time'&>,<&'arguments'&>
22207 .endd
22208 The letter identifies the algorithm for computing a new retry time; the cutoff
22209 time is the time beyond which this algorithm no longer applies, and the
22210 arguments vary the algorithm's action. The cutoff time is measured from the
22211 time that the first failure for the domain (combined with the local part if
22212 relevant) was detected, not from the time the message was received.
22213
22214 .cindex "retry" "algorithms"
22215 .cindex "retry" "fixed intervals"
22216 .cindex "retry" "increasing intervals"
22217 .cindex "retry" "random intervals"
22218 The available algorithms are:
22219
22220 .ilist
22221 &'F'&: retry at fixed intervals. There is a single time parameter specifying
22222 the interval.
22223 .next
22224 &'G'&: retry at geometrically increasing intervals. The first argument
22225 specifies a starting value for the interval, and the second a multiplier, which
22226 is used to increase the size of the interval at each retry.
22227 .next
22228 &'H'&: retry at randomized intervals. The arguments are as for &'G'&. For each
22229 retry, the previous interval is multiplied by the factor in order to get a
22230 maximum for the next interval. The mininum interval is the first argument of
22231 the parameter, and an actual interval is chosen randomly between them. Such a
22232 rule has been found to be helpful in cluster configurations when all the
22233 members of the cluster restart at once, and may therefore synchronize their
22234 queue processing times.
22235 .endlist
22236
22237 When computing the next retry time, the algorithm definitions are scanned in
22238 order until one whose cutoff time has not yet passed is reached. This is then
22239 used to compute a new retry time that is later than the current time. In the
22240 case of fixed interval retries, this simply means adding the interval to the
22241 current time. For geometrically increasing intervals, retry intervals are
22242 computed from the rule's parameters until one that is greater than the previous
22243 interval is found. The main configuration variable
22244 .cindex "limit" "retry interval"
22245 .cindex "retry interval" "maximum"
22246 .cindex "&%retry_interval_max%&"
22247 &%retry_interval_max%& limits the maximum interval between retries. It
22248 cannot be set greater than &`24h`&, which is its default value.
22249
22250 A single remote domain may have a number of hosts associated with it, and each
22251 host may have more than one IP address. Retry algorithms are selected on the
22252 basis of the domain name, but are applied to each IP address independently. If,
22253 for example, a host has two IP addresses and one is unusable, Exim will
22254 generate retry times for it and will not try to use it until its next retry
22255 time comes. Thus the good IP address is likely to be tried first most of the
22256 time.
22257
22258 .cindex "hints database" "use for retrying"
22259 Retry times are hints rather than promises. Exim does not make any attempt to
22260 run deliveries exactly at the computed times. Instead, a queue runner process
22261 starts delivery processes for delayed messages periodically, and these attempt
22262 new deliveries only for those addresses that have passed their next retry time.
22263 If a new message arrives for a deferred address, an immediate delivery attempt
22264 occurs only if the address has passed its retry time. In the absence of new
22265 messages, the minimum time between retries is the interval between queue runner
22266 processes. There is not much point in setting retry times of five minutes if
22267 your queue runners happen only once an hour, unless there are a significant
22268 number of incoming messages (which might be the case on a system that is
22269 sending everything to a smart host, for example).
22270
22271 The data in the retry hints database can be inspected by using the
22272 &'exim_dumpdb'& or &'exim_fixdb'& utility programs (see chapter
22273 &<<CHAPutils>>&). The latter utility can also be used to change the data. The
22274 &'exinext'& utility script can be used to find out what the next retry times
22275 are for the hosts associated with a particular mail domain, and also for local
22276 deliveries that have been deferred.
22277
22278
22279 .section "Retry rule examples"
22280 Here are some example retry rules:
22281 .code
22282 alice@wonderland.fict.example quota_5d  F,7d,3h
22283 wonderland.fict.example       quota_5d
22284 wonderland.fict.example       *         F,1h,15m; G,2d,1h,2;
22285 lookingglass.fict.example     *         F,24h,30m;
22286 *                 refused_A   F,2h,20m;
22287 *                 *           F,2h,15m; G,16h,1h,1.5; F,5d,8h
22288 .endd
22289 The first rule sets up special handling for mail to
22290 &'alice@wonderland.fict.example'& when there is an over-quota error and the
22291 mailbox has not been read for at least 5 days. Retries continue every three
22292 hours for 7 days. The second rule handles over-quota errors for all other local
22293 parts at &'wonderland.fict.example'&; the absence of a local part has the same
22294 effect as supplying &"*@"&. As no retry algorithms are supplied, messages that
22295 fail are bounced immediately if the mailbox has not been read for at least 5
22296 days.
22297
22298 The third rule handles all other errors at &'wonderland.fict.example'&; retries
22299 happen every 15 minutes for an hour, then with geometrically increasing
22300 intervals until two days have passed since a delivery first failed. After the
22301 first hour there is a delay of one hour, then two hours, then four hours, and
22302 so on (this is a rather extreme example).
22303
22304 The fourth rule controls retries for the domain &'lookingglass.fict.example'&.
22305 They happen every 30 minutes for 24 hours only. The remaining two rules handle
22306 all other domains, with special action for connection refusal from hosts that
22307 were not obtained from an MX record.
22308
22309 The final rule in a retry configuration should always have asterisks in the
22310 first two fields so as to provide a general catch-all for any addresses that do
22311 not have their own special handling. This example tries every 15 minutes for 2
22312 hours, then with intervals starting at one hour and increasing by a factor of
22313 1.5 up to 16 hours, then every 8 hours up to 5 days.
22314
22315
22316
22317 .section "Timeout of retry data"
22318 .cindex "timeout" "of retry data"
22319 .cindex "&%retry_data_expire%&"
22320 .cindex "hints database" "data expiry"
22321 .cindex "retry" "timeout of data"
22322 Exim timestamps the data that it writes to its retry hints database. When it
22323 consults the data during a delivery it ignores any that is older than the value
22324 set in &%retry_data_expire%& (default 7 days). If, for example, a host hasn't
22325 been tried for 7 days, Exim will try to deliver to it immediately a message
22326 arrives, and if that fails, it will calculate a retry time as if it were
22327 failing for the first time.
22328
22329 This improves the behaviour for messages routed to rarely-used hosts such as MX
22330 backups. If such a host was down at one time, and happens to be down again when
22331 Exim tries a month later, using the old retry data would imply that it had been
22332 down all the time, which is not a justified assumption.
22333
22334 If a host really is permanently dead, this behaviour causes a burst of retries
22335 every now and again, but only if messages routed to it are rare. If there is a
22336 message at least once every 7 days the retry data never expires.
22337
22338
22339
22340
22341 .section "Long-term failures"
22342 .cindex "delivery failure" "long-term"
22343 .cindex "retry" "after long-term failure"
22344 Special processing happens when an email address has been failing for so long
22345 that the cutoff time for the last algorithm is reached. For example, using the
22346 default retry rule:
22347 .code
22348 * * F,2h,15m; G,16h,1h,1.5; F,4d,6h
22349 .endd
22350 the cutoff time is four days. Reaching the retry cutoff is independent of how
22351 long any specific message has been failing; it is the length of continuous
22352 failure for the recipient address that counts.
22353
22354 When the cutoff time is reached for a local delivery, or for all the IP
22355 addresses associated with a remote delivery, a subsequent delivery failure
22356 causes Exim to give up on the address, and a bounce message is generated.
22357 In order to cater for new messages that use the failing address, a next retry
22358 time is still computed from the final algorithm, and is used as follows:
22359
22360 For local deliveries, one delivery attempt is always made for any subsequent
22361 messages. If this delivery fails, the address fails immediately. The
22362 post-cutoff retry time is not used.
22363
22364 If the delivery is remote, there are two possibilities, controlled by the
22365 .cindex "&%delay_after_cutoff%&"
22366 &%delay_after_cutoff%& option of the &(smtp)& transport. The option is true by
22367 default. Until the post-cutoff retry time for one of the IP addresses is
22368 reached, the failing email address is bounced immediately, without a delivery
22369 attempt taking place. After that time, one new delivery attempt is made to
22370 those IP addresses that are past their retry times, and if that still fails,
22371 the address is bounced and new retry times are computed.
22372
22373 In other words, when all the hosts for a given email address have been failing
22374 for a long time, Exim bounces rather then defers until one of the hosts' retry
22375 times is reached. Then it tries once, and bounces if that attempt fails. This
22376 behaviour ensures that few resources are wasted in repeatedly trying to deliver
22377 to a broken destination, but if the host does recover, Exim will eventually
22378 notice.
22379
22380 If &%delay_after_cutoff%& is set false, Exim behaves differently. If all IP
22381 addresses are past their final cutoff time, Exim tries to deliver to those IP
22382 addresses that have not been tried since the message arrived. If there are
22383 no suitable IP addresses, or if they all fail, the address is bounced. In other
22384 words, it does not delay when a new message arrives, but tries the expired
22385 addresses immediately, unless they have been tried since the message arrived.
22386 If there is a continuous stream of messages for the failing domains, setting
22387 &%delay_after_cutoff%& false means that there will be many more attempts to
22388 deliver to permanently failing IP addresses than when &%delay_after_cutoff%& is
22389 true.
22390
22391 .section "Deliveries that work intermittently"
22392 .cindex "retry" "intermittently working deliveries"
22393 Some additional logic is needed to cope with cases where a host is
22394 intermittently available, or when a message has some attribute that prevents
22395 its delivery when others to the same address get through. In this situation,
22396 because some messages are successfully delivered, the &"retry clock"& for the
22397 host or address keeps getting reset by the successful deliveries, and so
22398 failing messages remain on the queue for ever because the cutoff time is never
22399 reached.
22400
22401 Two exceptional actions are applied to prevent this happening. The first
22402 applies to errors that are related to a message rather than a remote host.
22403 Section &<<SECToutSMTPerr>>& has a discussion of the different kinds of error;
22404 examples of message-related errors are 4&'xx'& responses to MAIL or DATA
22405 commands, and quota failures. For this type of error, if a message's arrival
22406 time is earlier than the &"first failed"& time for the error, the earlier time
22407 is used when scanning the retry rules to decide when to try next and when to
22408 time out the address.
22409
22410 The exceptional second action applies in all cases. If a message has been on
22411 the queue for longer than the cutoff time of any applicable retry rule for a
22412 given address, a delivery is attempted for that address, even if it is not yet
22413 time, and if this delivery fails, the address is timed out. A new retry time is
22414 not computed in this case, so that other messages for the same address are
22415 considered immediately.
22416 .ecindex IIDretconf1
22417 .ecindex IIDregconf2
22418
22419
22420
22421
22422
22423
22424 . ////////////////////////////////////////////////////////////////////////////
22425 . ////////////////////////////////////////////////////////////////////////////
22426
22427 .chapter "SMTP authentication" "CHAPSMTPAUTH"
22428 .scindex IIDauthconf1 "SMTP" "authentication configuration"
22429 .scindex IIDauthconf2 "authentication"
22430 The &"authenticators"& section of Exim's run time configuration is concerned
22431 with SMTP authentication. This facility is an extension to the SMTP protocol,
22432 described in RFC 2554, which allows a client SMTP host to authenticate itself
22433 to a server. This is a common way for a server to recognize clients that are
22434 permitted to use it as a relay. SMTP authentication is not of relevance to the
22435 transfer of mail between servers that have no managerial connection with each
22436 other.
22437
22438 .cindex "AUTH" "description of"
22439 Very briefly, the way SMTP authentication works is as follows:
22440
22441 .ilist
22442 The server advertises a number of authentication &'mechanisms'& in response to
22443 the client's EHLO command.
22444 .next
22445 The client issues an AUTH command, naming a specific mechanism. The command
22446 may, optionally, contain some authentication data.
22447 .next
22448 The server may issue one or more &'challenges'&, to which the client must send
22449 appropriate responses. In simple authentication mechanisms, the challenges are
22450 just prompts for user names and passwords. The server does not have to issue
22451 any challenges &-- in some mechanisms the relevant data may all be transmitted
22452 with the AUTH command.
22453 .next
22454 The server either accepts or denies authentication.
22455 .next
22456 If authentication succeeds, the client may optionally make use of the AUTH
22457 option on the MAIL command to pass an authenticated sender in subsequent
22458 mail transactions. Authentication lasts for the remainder of the SMTP
22459 connection.
22460 .next
22461 If authentication fails, the client may give up, or it may try a different
22462 authentication mechanism, or it may try transferring mail over the
22463 unauthenticated connection.
22464 .endlist
22465
22466 If you are setting up a client, and want to know which authentication
22467 mechanisms the server supports, you can use Telnet to connect to port 25 (the
22468 SMTP port) on the server, and issue an EHLO command. The response to this
22469 includes the list of supported mechanisms. For example:
22470 .display
22471 &`$ `&&*&`telnet server.example 25`&*&
22472 &`Trying 192.168.34.25...`&
22473 &`Connected to server.example.`&
22474 &`Escape character is '^]'.`&
22475 &`220 server.example ESMTP Exim 4.20 ...`&
22476 &*&`ehlo client.example`&*&
22477 &`250-server.example Hello client.example [10.8.4.5]`&
22478 &`250-SIZE 52428800`&
22479 &`250-PIPELINING`&
22480 &`250-AUTH PLAIN`&
22481 &`250 HELP`&
22482 .endd
22483 The second-last line of this example output shows that the server supports
22484 authentication using the PLAIN mechanism. In Exim, the different authentication
22485 mechanisms are configured by specifying &'authenticator'& drivers. Like the
22486 routers and transports, which authenticators are included in the binary is
22487 controlled by build-time definitions. The following are currently available,
22488 included by setting
22489 .code
22490 AUTH_CRAM_MD5=yes
22491 AUTH_CYRUS_SASL=yes
22492 AUTH_PLAINTEXT=yes
22493 AUTH_SPA=yes
22494 .endd
22495 in &_Local/Makefile_&, respectively. The first of these supports the CRAM-MD5
22496 authentication mechanism (RFC 2195), and the second provides an interface to
22497 the Cyrus SASL authentication library. The third can be configured to support
22498 the PLAIN authentication mechanism (RFC 2595) or the LOGIN mechanism, which is
22499 not formally documented, but used by several MUAs. The fourth authenticator
22500 supports Microsoft's &'Secure Password Authentication'& mechanism.
22501
22502 The authenticators are configured using the same syntax as other drivers (see
22503 section &<<SECTfordricon>>&). If no authenticators are required, no
22504 authentication section need be present in the configuration file. Each
22505 authenticator can in principle have both server and client functions. When Exim
22506 is receiving SMTP mail, it is acting as a server; when it is sending out
22507 messages over SMTP, it is acting as a client. Authenticator configuration
22508 options are provided for use in both these circumstances.
22509
22510 To make it clear which options apply to which situation, the prefixes
22511 &%server_%& and &%client_%& are used on option names that are specific to
22512 either the server or the client function, respectively. Server and client
22513 functions are disabled if none of their options are set. If an authenticator is
22514 to be used for both server and client functions, a single definition, using
22515 both sets of options, is required. For example:
22516 .code
22517 cram:
22518   driver = cram_md5
22519   public_name = CRAM-MD5
22520   server_secret = ${if eq{$auth1}{ph10}{secret1}fail}
22521   client_name = ph10
22522   client_secret = secret2
22523 .endd
22524 The &%server_%& option is used when Exim is acting as a server, and the
22525 &%client_%& options when it is acting as a client.
22526
22527 Descriptions of the individual authenticators are given in subsequent chapters.
22528 The remainder of this chapter covers the generic options for the
22529 authenticators, followed by general discussion of the way authentication works
22530 in Exim.
22531
22532
22533
22534 .section "Generic options for authenticators"
22535 .cindex "authentication" "generic options"
22536 .cindex "options" "generic; for authenticators"
22537
22538
22539 .option driver authenticators string unset
22540 This option must always be set. It specifies which of the available
22541 authenticators is to be used.
22542
22543
22544 .option public_name authenticators string unset
22545 This option specifies the name of the authentication mechanism that the driver
22546 implements, and by which it is known to the outside world. These names should
22547 contain only upper case letters, digits, underscores, and hyphens (RFC 2222),
22548 but Exim in fact matches them caselessly. If &%public_name%& is not set, it
22549 defaults to the driver's instance name.
22550
22551
22552 .option server_advertise_condition authenticators string&!! unset
22553 When a server is about to advertise an authentication mechanism, the condition
22554 is expanded. If it yields the empty string, &"0"&, &"no"&, or &"false"&, the
22555 mechanism is not advertised.
22556 If the expansion fails, the mechanism is not advertised. If the failure was not
22557 forced, and was not caused by a lookup defer, the incident is logged.
22558 See section &<<SECTauthexiser>>& below for further discussion.
22559
22560
22561 .new
22562 .option server_condition authenticators string&!! unset
22563 This option must be set for a &%plaintext%& server authenticator, where it
22564 is used directly to control authentication. See section &<<SECTplainserver>>&
22565 for details.
22566
22567 For the other authenticators, &%server_condition%& can be used as an additional
22568 authentication or authorization mechanism that is applied after the other
22569 authenticator conditions succeed. If it is set, it is expanded when the
22570 authenticator would otherwise return a success code. If the expansion is forced
22571 to fail, authentication fails. Any other expansion failure causes a temporary
22572 error code to be returned. If the result of a successful expansion is an empty
22573 string, &"0"&, &"no"&, or &"false"&, authentication fails. If the result of the
22574 expansion is &"1"&, &"yes"&, or &"true"&, authentication succeeds. For any
22575 other result, a temporary error code is returned, with the expanded string as
22576 the error text.
22577 .wen
22578
22579
22580 .option server_debug_print authenticators string&!! unset
22581 If this option is set and authentication debugging is enabled (see the &%-d%&
22582 command line option), the string is expanded and included in the debugging
22583 output when the authenticator is run as a server. This can help with checking
22584 out the values of variables.
22585 If expansion of the string fails, the error message is written to the debugging
22586 output, and Exim carries on processing.
22587
22588
22589 .option server_set_id authenticators string&!! unset
22590 .cindex "&$authenticated_id$&"
22591 When an Exim server successfully authenticates a client, this string is
22592 expanded using data from the authentication, and preserved for any incoming
22593 messages in the variable &$authenticated_id$&. It is also included in the log
22594 lines for incoming messages. For example, a user/password authenticator
22595 configuration might preserve the user name that was used to authenticate, and
22596 refer to it subsequently during delivery of the message.
22597 If expansion fails, the option is ignored.
22598
22599
22600 .option server_mail_auth_condition authenticators string&!! unset
22601 This option allows a server to discard authenticated sender addresses supplied
22602 as part of MAIL commands in SMTP connections that are authenticated by the
22603 driver on which &%server_mail_auth_condition%& is set. The option is not used
22604 as part of the authentication process; instead its (unexpanded) value is
22605 remembered for later use.
22606 How it is used is described in the following section.
22607
22608
22609
22610
22611
22612 .section "The AUTH parameter on MAIL commands" "SECTauthparamail"
22613 .cindex "authentication" "sender; authenticated"
22614 .cindex "AUTH" "on MAIL command"
22615 When a client supplied an AUTH= item on a MAIL command, Exim applies
22616 the following checks before accepting it as the authenticated sender of the
22617 message:
22618
22619 .ilist
22620 If the connection is not using extended SMTP (that is, HELO was used rather
22621 than EHLO), the use of AUTH= is a syntax error.
22622 .next
22623 If the value of the AUTH= parameter is &"<>"&, it is ignored.
22624 .next
22625 .cindex "&$authenticated_sender$&"
22626 If &%acl_smtp_mailauth%& is defined, the ACL it specifies is run. While it is
22627 running, the value of &$authenticated_sender$& is set to the value obtained
22628 from the AUTH= parameter. If the ACL does not yield &"accept"&, the value of
22629 &$authenticated_sender$& is deleted. The &%acl_smtp_mailauth%& ACL may not
22630 return &"drop"& or &"discard"&. If it defers, a temporary error code (451) is
22631 given for the MAIL command.
22632 .next
22633 If &%acl_smtp_mailauth%& is not defined, the value of the AUTH= parameter
22634 is accepted and placed in &$authenticated_sender$& only if the client has
22635 authenticated.
22636 .next
22637 If the AUTH= value was accepted by either of the two previous rules, and
22638 the client has authenticated, and the authenticator has a setting for the
22639 &%server_mail_auth_condition%&, the condition is checked at this point. The
22640 valued that was saved from the authenticator is expanded. If the expansion
22641 fails, or yields an empty string, &"0"&, &"no"&, or &"false"&, the value of
22642 &$authenticated_sender$& is deleted. If the expansion yields any other value,
22643 the value of &$authenticated_sender$& is retained and passed on with the
22644 message.
22645 .endlist
22646
22647
22648 When &$authenticated_sender$& is set for a message, it is passed on to other
22649 hosts to which Exim authenticates as a client. Do not confuse this value with
22650 &$authenticated_id$&, which is a string obtained from the authentication
22651 process, and which is not usually a complete email address.
22652
22653 .cindex "&$sender_address$&"
22654 Whenever an AUTH= value is ignored, the incident is logged. The ACL for
22655 MAIL, if defined, is run after AUTH= is accepted or ignored. It can
22656 therefore make use of &$authenticated_sender$&. The converse is not true: the
22657 value of &$sender_address$& is not yet set up when the &%acl_smtp_mailauth%&
22658 ACL is run.
22659
22660
22661
22662 .section "Authentication on an Exim server" "SECTauthexiser"
22663 .cindex "authentication" "on an Exim server"
22664 When Exim receives an EHLO command, it advertises the public names of those
22665 authenticators that are configured as servers, subject to the following
22666 conditions:
22667
22668 .ilist
22669 The client host must match &%auth_advertise_hosts%& (default *).
22670 .next
22671 It the &%server_advertise_condition%& option is set, its expansion must not
22672 yield the empty string, &"0"&, &"no"&, or &"false"&.
22673 .endlist
22674
22675 The order in which the authenticators are defined controls the order in which
22676 the mechanisms are advertised.
22677
22678 Some mail clients (for example, some versions of Netscape) require the user to
22679 provide a name and password for authentication whenever AUTH is advertised,
22680 even though authentication may not in fact be needed (for example, Exim may be
22681 set up to allow unconditional relaying from the client by an IP address check).
22682 You can make such clients more friendly by not advertising AUTH to them.
22683 For example, if clients on the 10.9.8.0/24 network are permitted (by the ACL
22684 that runs for RCPT) to relay without authentication, you should set
22685 .code
22686 auth_advertise_hosts = ! 10.9.8.0/24
22687 .endd
22688 so that no authentication mechanisms are advertised to them.
22689
22690 The &%server_advertise_condition%& controls the advertisement of individual
22691 authentication mechanisms. For example, it can be used to restrict the
22692 advertisement of a patricular mechanism to encrypted connections, by a setting
22693 such as:
22694 .code
22695 server_advertise_condition = ${if eq{$tls_cipher}{}{no}{yes}}
22696 .endd
22697 .cindex "&$tls_cipher$&"
22698 If the session is encrypted, &$tls_cipher$& is not empty, and so the expansion
22699 yields &"yes"&, which allows the advertisement to happen.
22700
22701 When an Exim server receives an AUTH command from a client, it rejects it
22702 immediately if AUTH was not advertised in response to an earlier EHLO
22703 command. This is the case if
22704
22705 .ilist
22706 The client host does not match &%auth_advertise_hosts%&; or
22707 .next
22708 No authenticators are configured with server options; or
22709 .next
22710 Expansion of &%server_advertise_condition%& blocked the advertising of all the
22711 server authenticators.
22712 .endlist
22713
22714
22715 Otherwise, Exim runs the ACL specified by &%acl_smtp_auth%& in order
22716 to decide whether to accept the command. If &%acl_smtp_auth%& is not set,
22717 AUTH is accepted from any client host.
22718
22719 If AUTH is not rejected by the ACL, Exim searches its configuration for a
22720 server authentication mechanism that was advertised in response to EHLO and
22721 that matches the one named in the AUTH command. If it finds one, it runs
22722 the appropriate authentication protocol, and authentication either succeeds or
22723 fails. If there is no matching advertised mechanism, the AUTH command is
22724 rejected with a 504 error.
22725
22726 .cindex "&$received_protocol$&"
22727 .cindex "&$sender_host_authenticated$&"
22728 When a message is received from an authenticated host, the value of
22729 &$received_protocol$& is set to &"esmtpa"& or &"esmtpsa"& instead of &"esmtp"&
22730 or &"esmtps"&, and &$sender_host_authenticated$& contains the name (not the
22731 public name) of the authenticator driver that successfully authenticated the
22732 client from which the message was received. This variable is empty if there was
22733 no successful authentication.
22734
22735
22736
22737
22738 .section "Testing server authentication"
22739 .cindex "authentication" "testing a server"
22740 .cindex "AUTH" "testing a server"
22741 .cindex "base64 encoding" "creating authentication test data"
22742 Exim's &%-bh%& option can be useful for testing server authentication
22743 configurations. The data for the AUTH command has to be sent using base64
22744 encoding. A quick way to produce such data for testing is the following Perl
22745 script:
22746 .code
22747 use MIME::Base64;
22748 printf ("%s", encode_base64(eval "\"$ARGV[0]\""));
22749 .endd
22750 .cindex "binary zero" "in authentication data"
22751 This interprets its argument as a Perl string, and then encodes it. The
22752 interpretation as a Perl string allows binary zeros, which are required for
22753 some kinds of authentication, to be included in the data. For example, a
22754 command line to run this script on such data might be
22755 .code
22756 encode '\0user\0password'
22757 .endd
22758 Note the use of single quotes to prevent the shell interpreting the
22759 backslashes, so that they can be interpreted by Perl to specify characters
22760 whose code value is zero.
22761
22762 &*Warning 1*&: If either of the user or password strings starts with an octal
22763 digit, you must use three zeros instead of one after the leading backslash. If
22764 you do not, the octal digit that starts your string will be incorrectly
22765 interpreted as part of the code for the first character.
22766
22767 &*Warning 2*&: If there are characters in the strings that Perl interprets
22768 specially, you must use a Perl escape to prevent them being misinterpreted. For
22769 example, a command such as
22770 .code
22771 encode '\0user@domain.com\0pas$$word'
22772 .endd
22773 gives an incorrect answer because of the unescaped &"@"& and &"$"& characters.
22774
22775 If you have the &%mimencode%& command installed, another way to do produce
22776 base64-encoded strings is to run the command
22777 .code
22778 echo -e -n `\0user\0password' | mimencode
22779 .endd
22780 The &%-e%& option of &%echo%& enables the interpretation of backslash escapes
22781 in the argument, and the &%-n%& option specifies no newline at the end of its
22782 output. However, not all versions of &%echo%& recognize these options, so you
22783 should check your version before relying on this suggestion.
22784
22785
22786
22787 .section "Authentication by an Exim client"
22788 .cindex "authentication" "on an Exim client"
22789 The &(smtp)& transport has two options called &%hosts_require_auth%& and
22790 &%hosts_try_auth%&. When the &(smtp)& transport connects to a server that
22791 announces support for authentication, and the host matches an entry in either
22792 of these options, Exim (as a client) tries to authenticate as follows:
22793
22794 .ilist
22795 For each authenticator that is configured as a client, it searches the
22796 authentication mechanisms announced by the server for one whose name
22797 matches the public name of the authenticator.
22798 .next
22799 .cindex "&$host$&"
22800 .cindex "&$host_address$&"
22801 When it finds one that matches, it runs the authenticator's client code.
22802 The variables &$host$& and &$host_address$& are available for any string
22803 expansions that the client might do. They are set to the server's name and
22804 IP address. If any expansion is forced to fail, the authentication attempt
22805 is abandoned,
22806 and Exim moves on to the next authenticator.
22807 Otherwise an expansion failure causes delivery to be
22808 deferred.
22809 .next
22810 If the result of the authentication attempt is a temporary error or a timeout,
22811 Exim abandons trying to send the message to the host for the moment. It will
22812 try again later. If there are any backup hosts available, they are tried in the
22813 usual way.
22814 .next
22815 If the response to authentication is a permanent error (5&'xx'& code), Exim
22816 carries on searching the list of authenticators and tries another one if
22817 possible. If all authentication attempts give permanent errors, or if there are
22818 no attempts because no mechanisms match (or option expansions force failure),
22819 what happens depends on whether the host matches &%hosts_require_auth%& or
22820 &%hosts_try_auth%&. In the first case, a temporary error is generated, and
22821 delivery is deferred. The error can be detected in the retry rules, and thereby
22822 turned into a permanent error if you wish. In the second case, Exim tries to
22823 deliver the message unauthenticated.
22824 .endlist
22825
22826 .cindex "AUTH" "on MAIL command"
22827 When Exim has authenticated itself to a remote server, it adds the AUTH
22828 parameter to the MAIL commands it sends, if it has an authenticated sender for
22829 the message. If the message came from a remote host, the authenticated sender
22830 is the one that was receiving on an incoming MAIL command, provided that the
22831 incoming connection was authenticated and the &%server_mail_auth%& condition
22832 allowed the authenticated sender to be retained. If a local process calls Exim
22833 to send a message, the sender address that is built from the login name and
22834 &%qualify_domain%& is treated as authenticated. However, if the
22835 &%authenticated_sender%& option is set on the &(smtp)& transport, it overrides
22836 the authenticated sender that was received with the message.
22837 .ecindex IIDauthconf1
22838 .ecindex IIDauthconf2
22839
22840
22841
22842
22843
22844
22845 . ////////////////////////////////////////////////////////////////////////////
22846 . ////////////////////////////////////////////////////////////////////////////
22847
22848 .chapter "The plaintext authenticator" "CHAPplaintext"
22849 .scindex IIDplaiauth1 "&(plaintext)& authenticator"
22850 .scindex IIDplaiauth2 "authenticators" "&(plaintext)&"
22851 The &(plaintext)& authenticator can be configured to support the PLAIN and
22852 LOGIN authentication mechanisms, both of which transfer authentication data as
22853 plain (unencrypted) text (though base64 encoded). The use of plain text is a
22854 security risk; you are strongly advised to insist on the use of SMTP encryption
22855 (see chapter &<<CHAPTLS>>&) if you use the PLAIN or LOGIN mechanisms. If you do
22856 use unencrypted plain text, you should not use the same passwords for SMTP
22857 connections as you do for login accounts.
22858
22859 .new
22860 .section "Plaintext options"
22861 .cindex "options" "&(plaintext)& authenticator (server)"
22862 When configured as a server, &(plaintext)& uses the following options:
22863
22864 .option server_condition authenticators string&!! unset
22865 This is actually a global authentication option, but it must be set in order to
22866 configure the &(plaintext)& driver as a server. Its use is described below.
22867 .wen
22868
22869 .option server_prompts plaintext string&!! unset
22870 The contents of this option, after expansion, must be a colon-separated list of
22871 prompt strings. If expansion fails, a temporary authentication rejection is
22872 given.
22873
22874 .section "Using plaintext in a server" "SECTplainserver"
22875 .cindex "AUTH" "in &(plaintext)& authenticator"
22876 .cindex "binary zero" "in &(plaintext)& authenticator"
22877 .cindex "numerical variables (&$1$& &$2$& etc)" &&&
22878         "in &(plaintext)& authenticator"
22879 .cindex "&$auth1$&, &$auth2$&, etc"
22880 .cindex "base64 encoding" "in &(plaintext)& authenticator"
22881
22882 When running as a server, &(plaintext)& performs the authentication test by
22883 expanding a string. The data sent by the client with the AUTH command, or in
22884 response to subsequent prompts, is base64 encoded, and so may contain any byte
22885 values when decoded. If any data is supplied with the command, it is treated as
22886 a list of strings, separated by NULs (binary zeros), the first three of which
22887 are placed in the expansion variables &$auth1$&, &$auth2$&, and &$auth3$&
22888 (neither LOGIN nor PLAIN uses more than three strings).
22889
22890 For compatibility with previous releases of Exim, the values are also placed in
22891 the expansion variables &$1$&, &$2$&, and &$3$&. However, the use of these
22892 variables for this purpose is now deprecated, as it can lead to confusion in
22893 string expansions that also use them for other things.
22894
22895 If there are more strings in &%server_prompts%& than the number of strings
22896 supplied with the AUTH command, the remaining prompts are used to obtain more
22897 data. Each response from the client may be a list of NUL-separated strings.
22898
22899 .cindex "&$authenticated_id$&"
22900 Once a sufficient number of data strings have been received,
22901 &%server_condition%& is expanded. If the expansion is forced to fail,
22902 authentication fails. Any other expansion failure causes a temporary error code
22903 to be returned. If the result of a successful expansion is an empty string,
22904 &"0"&, &"no"&, or &"false"&, authentication fails. If the result of the
22905 expansion is &"1"&, &"yes"&, or &"true"&, authentication succeeds and the
22906 generic &%server_set_id%& option is expanded and saved in &$authenticated_id$&.
22907 For any other result, a temporary error code is returned, with the expanded
22908 string as the error text.
22909
22910 &*Warning*&: If you use a lookup in the expansion to find the user's
22911 password, be sure to make the authentication fail if the user is unknown.
22912 There are good and bad examples at the end of the next section.
22913
22914
22915
22916 .section "The PLAIN authentication mechanism"
22917 .cindex "PLAIN authentication mechanism"
22918 .cindex "authentication" "PLAIN mechanism"
22919 .cindex "binary zero" "in &(plaintext)& authenticator"
22920 The PLAIN authentication mechanism (RFC 2595) specifies that three strings be
22921 sent as one item of data (that is, one combined string containing two NUL
22922 separators). The data is sent either as part of the AUTH command, or
22923 subsequently in response to an empty prompt from the server.
22924
22925 The second and third strings are a user name and a corresponding password.
22926 Using a single fixed user name and password as an example, this could be
22927 configured as follows:
22928 .code
22929 fixed_plain:
22930   driver = plaintext
22931   public_name = PLAIN
22932   server_prompts = :
22933   server_condition = \
22934     ${if and {{eq{$auth2}{username}}{eq{$auth3}{mysecret}}}}
22935   server_set_id = $auth2
22936 .endd
22937 Note that the default result strings from &%if%& (&"true"& or an empty string)
22938 are exactly what we want here, so they need not be specified. Obviously, if the
22939 password contains expansion-significant characters such as dollar, backslash,
22940 or closing brace, they have to be escaped.
22941
22942 The &%server_prompts%& setting specifies a single, empty prompt (empty items at
22943 the end of a string list are ignored). If all the data comes as part of the
22944 AUTH command, as is commonly the case, the prompt is not used. This
22945 authenticator is advertised in the response to EHLO as
22946 .code
22947 250-AUTH PLAIN
22948 .endd
22949 and a client host can authenticate itself by sending the command
22950 .code
22951 AUTH PLAIN AHVzZXJuYW1lAG15c2VjcmV0
22952 .endd
22953 As this contains three strings (more than the number of prompts), no further
22954 data is required from the client. Alternatively, the client may just send
22955 .code
22956 AUTH PLAIN
22957 .endd
22958 to initiate authentication, in which case the server replies with an empty
22959 prompt. The client must respond with the combined data string.
22960
22961 The data string is base64 encoded, as required by the RFC. This example,
22962 when decoded, is <&'NUL'&>&`username`&<&'NUL'&>&`mysecret`&, where <&'NUL'&>
22963 represents a zero byte. This is split up into three strings, the first of which
22964 is empty. The &%server_condition%& option in the authenticator checks that the
22965 second two are &`username`& and &`mysecret`& respectively.
22966
22967 Having just one fixed user name and password, as in this example, is not very
22968 realistic, though for a small organization with only a handful of
22969 authenticating clients it could make sense.
22970
22971 A more sophisticated instance of this authenticator could use the user name in
22972 &$auth2$& to look up a password in a file or database, and maybe do an encrypted
22973 comparison (see &%crypteq%& in chapter &<<CHAPexpand>>&). Here is a example of
22974 this approach, where the passwords are looked up in a DBM file. &*Warning*&:
22975 This is an incorrect example:
22976 .code
22977 server_condition = \
22978   ${if eq{$auth3}{${lookup{$auth2}dbm{/etc/authpwd}}}}
22979 .endd
22980 The expansion uses the user name (&$auth2$&) as the key to look up a password,
22981 which it then compares to the supplied password (&$auth3$&). Why is this example
22982 incorrect? It works fine for existing users, but consider what happens if a
22983 non-existent user name is given. The lookup fails, but as no success/failure
22984 strings are given for the lookup, it yields an empty string. Thus, to defeat
22985 the authentication, all a client has to do is to supply a non-existent user
22986 name and an empty password. The correct way of writing this test is:
22987 .code
22988 server_condition = ${lookup{$auth2}dbm{/etc/authpwd}\
22989   {${if eq{$value}{$auth3}}} {false}}
22990 .endd
22991 In this case, if the lookup succeeds, the result is checked; if the lookup
22992 fails, &"false"& is returned and authentication fails. If &%crypteq%& is being
22993 used instead of &%eq%&, the first example is in fact safe, because &%crypteq%&
22994 always fails if its second argument is empty. However, the second way of
22995 writing the test makes the logic clearer.
22996
22997
22998 .section "The LOGIN authentication mechanism"
22999 .cindex "LOGIN authentication mechanism"
23000 .cindex "authentication" "LOGIN mechanism"
23001 The LOGIN authentication mechanism is not documented in any RFC, but is in use
23002 in a number of programs. No data is sent with the AUTH command. Instead, a
23003 user name and password are supplied separately, in response to prompts. The
23004 plaintext authenticator can be configured to support this as in this example:
23005 .code
23006 fixed_login:
23007   driver = plaintext
23008   public_name = LOGIN
23009   server_prompts = User Name : Password
23010   server_condition = \
23011     ${if and {{eq{$auth1}{username}}{eq{$auth2}{mysecret}}}}
23012   server_set_id = $auth1
23013 .endd
23014 Because of the way plaintext operates, this authenticator accepts data supplied
23015 with the AUTH command (in contravention of the specification of LOGIN), but
23016 if the client does not supply it (as is the case for LOGIN clients), the prompt
23017 strings are used to obtain two data items.
23018
23019 Some clients are very particular about the precise text of the prompts. For
23020 example, Outlook Express is reported to recognize only &"Username:"& and
23021 &"Password:"&. Here is an example of a LOGIN authenticator that uses those
23022 strings. It uses the &%ldapauth%& expansion condition to check the user
23023 name and password by binding to an LDAP server:
23024 .code
23025 login:
23026   driver = plaintext
23027   public_name = LOGIN
23028   server_prompts = Username:: : Password::
23029   server_condition = ${if ldapauth \
23030     {user="cn=${quote_ldap_dn:$auth1},ou=people,o=example.org" \
23031     pass=${quote:$auth2} \
23032     ldap://ldap.example.org/}}
23033   server_set_id = uid=$auth1,ou=people,o=example.org
23034 .endd
23035 Note the use of the &%quote_ldap_dn%& operator to correctly quote the DN for
23036 authentication. However, the basic &%quote%& operator, rather than any of the
23037 LDAP quoting operators, is the correct one to use for the password, because
23038 quoting is needed only to make the password conform to the Exim syntax. At the
23039 LDAP level, the password is an uninterpreted string.
23040
23041
23042
23043 .section "Support for different kinds of authentication"
23044 A number of string expansion features are provided for the purpose of
23045 interfacing to different ways of user authentication. These include checking
23046 traditionally encrypted passwords from &_/etc/passwd_& (or equivalent), PAM,
23047 Radius, &%ldapauth%&, &'pwcheck'&, and &'saslauthd'&. For details see section
23048 &<<SECTexpcond>>&.
23049
23050
23051
23052
23053 .section "Using plaintext in a client"
23054 .cindex "options" "&(plaintext)& authenticator (client)"
23055 The &(plaintext)& authenticator has two client options:
23056
23057 .option client_ignore_invalid_base64 plaintext boolean false
23058 If the client receives a server prompt that is not a valid base64 string,
23059 authentication is abandoned by default. However, if this option is set true,
23060 the error in the challenge is ignored and the client sends the response as
23061 usual.
23062
23063 .option client_send plaintext string&!! unset
23064 The string is a colon-separated list of authentication data strings. Each
23065 string is independently expanded before being sent to the server. The first
23066 string is sent with the AUTH command; any more strings are sent in response
23067 to prompts from the server. Before each string is expanded, the value of the
23068 most recent prompt is placed in the next &$auth$&<&'n'&> variable, starting
23069 with &$auth1$& for the first prompt. Up to three prompts are stored in this
23070 way. Thus, the prompt that is received in response to sending the first string
23071 (with the AUTH command) can be used in the expansion of the second string, and
23072 so on. If an invalid base64 string is received when
23073 &%client_ignore_invalid_base64%& is set, an empty string is put in the
23074 &$auth$&<&'n'&> variable.
23075
23076 &*Note*&: You cannot use expansion to create multiple strings, because
23077 splitting takes priority and happens first.
23078
23079 Because the PLAIN authentication mechanism requires NUL (binary zero) bytes in
23080 the data, further processing is applied to each string before it is sent. If
23081 there are any single circumflex characters in the string, they are converted to
23082 NULs. Should an actual circumflex be required as data, it must be doubled in
23083 the string.
23084
23085 This is an example of a client configuration that implements the PLAIN
23086 authentication mechanism with a fixed user name and password:
23087 .code
23088 fixed_plain:
23089   driver = plaintext
23090   public_name = PLAIN
23091   client_send = ^username^mysecret
23092 .endd
23093 The lack of colons means that the entire text is sent with the AUTH
23094 command, with the circumflex characters converted to NULs. A similar example
23095 that uses the LOGIN mechanism is:
23096 .code
23097 fixed_login:
23098   driver = plaintext
23099   public_name = LOGIN
23100   client_send = : username : mysecret
23101 .endd
23102 The initial colon means that the first string is empty, so no data is sent with
23103 the AUTH command itself. The remaining strings are sent in response to
23104 prompts.
23105 .ecindex IIDplaiauth1
23106 .ecindex IIDplaiauth2
23107
23108
23109
23110
23111 . ////////////////////////////////////////////////////////////////////////////
23112 . ////////////////////////////////////////////////////////////////////////////
23113
23114 .chapter "The cram_md5 authenticator"
23115 .scindex IIDcramauth1 "&(cram_md5)& authenticator"
23116 .scindex IIDcramauth2 "authenticators" "&(cram_md5)&"
23117 .cindex "CRAM-MD5 authentication mechanism"
23118 .cindex "authentication" "CRAM-MD5 mechanism"
23119 The CRAM-MD5 authentication mechanism is described in RFC 2195. The server
23120 sends a challenge string to the client, and the response consists of a user
23121 name and the CRAM-MD5 digest of the challenge string combined with a secret
23122 string (password) which is known to both server and client. Thus, the secret
23123 is not sent over the network as plain text, which makes this authenticator more
23124 secure than &(plaintext)&. However, the downside is that the secret has to be
23125 available in plain text at either end.
23126
23127
23128 .section "Using cram_md5 as a server"
23129 .cindex "options" "&(cram_md5)& authenticator (server)"
23130 This authenticator has one server option, which must be set to configure the
23131 authenticator as a server:
23132
23133 .option server_secret cram_md5 string&!! unset
23134 .cindex "numerical variables (&$1$& &$2$& etc)" "in &(cram_md5)& authenticator"
23135 When the server receives the client's response, the user name is placed in
23136 the expansion variable &$auth1$&, and &%server_secret%& is expanded to
23137 obtain the password for that user. The server then computes the CRAM-MD5 digest
23138 that the client should have sent, and checks that it received the correct
23139 string. If the expansion of &%server_secret%& is forced to fail, authentication
23140 fails. If the expansion fails for some other reason, a temporary error code is
23141 returned to the client.
23142
23143 For compatibility with previous releases of Exim, the user name is also placed
23144 in &$1$&. However, the use of this variables for this purpose is now
23145 deprecated, as it can lead to confusion in string expansions that also use
23146 numeric variables for other things.
23147
23148 For example, the following authenticator checks that the user name given by the
23149 client is &"ph10"&, and if so, uses &"secret"& as the password. For any other
23150 user name, authentication fails.
23151 .code
23152 fixed_cram:
23153   driver = cram_md5
23154   public_name = CRAM-MD5
23155   server_secret = ${if eq{$auth1}{ph10}{secret}fail}
23156   server_set_id = $auth1
23157 .endd
23158 .cindex "&$authenticated_id$&"
23159 If authentication succeeds, the setting of &%server_set_id%& preserves the user
23160 name in &$authenticated_id$&. A more tyical configuration might look up the
23161 secret string in a file, using the user name as the key. For example:
23162 .code
23163 lookup_cram:
23164   driver = cram_md5
23165   public_name = CRAM-MD5
23166   server_secret = ${lookup{$auth1}lsearch{/etc/authpwd}{$value}fail}
23167   server_set_id = $auth1
23168 .endd
23169 Note that this expansion explicitly forces failure if the lookup fails
23170 because &$1$& contains an unknown user name.
23171
23172
23173 .section "Using cram_md5 as a client"
23174 .cindex "options" "&(cram_md5)& authenticator (client)"
23175 When used as a client, the &(cram_md5)& authenticator has two options:
23176
23177
23178
23179 .option client_name cram_md5 string&!! "the primary host name"
23180 This string is expanded, and the result used as the user name data when
23181 computing the response to the server's challenge.
23182
23183
23184 .option client_secret cram_md5 string&!! unset
23185 This option must be set for the authenticator to work as a client. Its value is
23186 expanded and the result used as the secret string when computing the response.
23187
23188
23189 .cindex "&$host$&"
23190 .cindex "&$host_address$&"
23191 Different user names and secrets can be used for different servers by referring
23192 to &$host$& or &$host_address$& in the options. Forced failure of either
23193 expansion string is treated as an indication that this authenticator is not
23194 prepared to handle this case. Exim moves on to the next configured client
23195 authenticator. Any other expansion failure causes Exim to give up trying to
23196 send the message to the current server.
23197
23198 A simple example configuration of a &(cram_md5)& authenticator, using fixed
23199 strings, is:
23200 .code
23201 fixed_cram:
23202   driver = cram_md5
23203   public_name = CRAM-MD5
23204   client_name = ph10
23205   client_secret = secret
23206 .endd
23207 .ecindex IIDcramauth1
23208 .ecindex IIDcramauth2
23209
23210
23211
23212 . ////////////////////////////////////////////////////////////////////////////
23213 . ////////////////////////////////////////////////////////////////////////////
23214
23215 .chapter "The cyrus_sasl authenticator"
23216 .scindex IIDcyrauth1 "&(cyrus_sasl)& authenticator"
23217 .scindex IIDcyrauth2 "authenticators" "&(cyrus_sasl)&"
23218 .cindex "Cyrus" "SASL library"
23219 .cindex "Kerberos"
23220 The code for this authenticator was provided by Matthew Byng-Maddick of A L
23221 Digital Ltd (&url(http://www.aldigital.co.uk)).
23222
23223 The &(cyrus_sasl)& authenticator provides server support for the Cyrus SASL
23224 library implementation of the RFC 2222 (&"Simple Authentication and Security
23225 Layer"&). This library supports a number of authentication mechanisms,
23226 including PLAIN and LOGIN, but also several others that Exim does not support
23227 directly. In particular, there is support for Kerberos authentication.
23228
23229 The &(cyrus_sasl)& authenticator provides a gatewaying mechanism directly to
23230 the Cyrus interface, so if your Cyrus library can do, for example, CRAM-MD5,
23231 then so can the &(cyrus_sasl)& authenticator. By default it uses the public
23232 name of the driver to determine which mechanism to support.
23233
23234 Where access to some kind of secret file is required, for example in GSSAPI
23235 or CRAM-MD5, it is worth noting that the authenticator runs as the Exim
23236 user, and that the Cyrus SASL library has no way of escalating privileges
23237 by default. You may also find you need to set environment variables,
23238 depending on the driver you are using.
23239
23240 .new
23241 The application name provided by Exim is &"exim"&, so various SASL options may
23242 be set in &_exim.conf_& in your SASL directory. If you are using GSSAPI for
23243 Kerberos, note that because of limitations in the GSSAPI interface,
23244 changing the server keytab might need to be communicated down to the Kerberos
23245 layer independently. The mechanism for doing so is dependent upon the Kerberos
23246 implementation. For example, for Heimdal, the environment variable KRB5_KTNAME
23247 may be set to point to an alternative keytab file. Exim will pass this
23248 variable through from its own inherited environment when started as root or the
23249 Exim user. The keytab file needs to be readable by the Exim user.
23250 .wen
23251
23252
23253 .section "Using cyrus_sasl as a server"
23254 The &(cyrus_sasl)& authenticator has four private options. It puts the username
23255 (on a successful authentication) into &$auth1$&. For compatibility with
23256 previous releases of Exim, the username is also placed in &$1$&. However, the
23257 use of this variable for this purpose is now deprecated, as it can lead to
23258 confusion in string expansions that also use numeric variables for other
23259 things.
23260
23261
23262 .option server_hostname cyrus_sasl string&!! &`$primary_hostname`&
23263 This option selects the hostname that is used when communicating with
23264 the library. It is up to the underlying SASL plug-in what it does with
23265 this data.
23266
23267
23268 .option server_mech cyrus_sasl string &`public_name`&
23269 This option selects the authentication mechanism this driver should
23270 use. It allows you to use a different underlying mechanism from the
23271 advertised name. For example:
23272 .code
23273 sasl:
23274   driver = cyrus_sasl
23275   public_name = X-ANYTHING
23276   server_mech = CRAM-MD5
23277   server_set_id = $auth1
23278 .endd
23279
23280 .option server_realm cyrus_sasl string unset
23281 This specifies the SASL realm that the server claims to be in.
23282
23283
23284 .option server_service cyrus_sasl string &`smtp`&
23285 This is the SASL service that the server claims to implement.
23286
23287
23288 For straightforward cases, you do not need to set any of the authenticator's
23289 private options. All you need to do is to specify an appropriate mechanism as
23290 the public name. Thus, if you have a SASL library that supports CRAM-MD5 and
23291 PLAIN, you could have two authenticators as follows:
23292 .code
23293 sasl_cram_md5:
23294   driver = cyrus_sasl
23295   public_name = CRAM-MD5
23296   server_set_id = $auth1
23297
23298 sasl_plain:
23299   driver = cyrus_sasl
23300   public_name = PLAIN
23301   server_set_id = $auth1
23302 .endd
23303 Cyrus SASL does implement the LOGIN authentication method, even though it is
23304 not a standard method. It is disabled by default in the source distribution,
23305 but it is present in many binary distributions.
23306 .ecindex IIDcyrauth1
23307 .ecindex IIDcyrauth2
23308
23309
23310
23311
23312 . ////////////////////////////////////////////////////////////////////////////
23313 . ////////////////////////////////////////////////////////////////////////////
23314 .new
23315 .chapter "The dovecot authenticator" "CHAPdovecot"
23316 .scindex IIDdcotauth1 "&(dovecot)& authenticator"
23317 .scindex IIDdcotauth2 "authenticators" "&(dovecot)&"
23318 This authenticator is an interface to the authentication facility of the
23319 Dovecot POP/IMAP server, which can support a number of authentication methods.
23320 If you are using Dovecot to authenticate POP/IMAP clients, it might be helpful
23321 to use the same mechanisms for SMTP authentication. This is a server
23322 authenticator only. There is only one option:
23323
23324 .option server_socket dovecot string unset
23325
23326 This option must specify the socket that is the interface to Dovecot
23327 authentication. The &%public_name%& option must specify an authentication
23328 mechanism that Dovecot is configured to support. You can have several
23329 authenticators for different mechanisms. For example:
23330 .code
23331 dovecot_plain:
23332   driver = dovecot
23333   public_name = PLAIN
23334   server_socket = /var/run/dovecot/auth-client
23335   server_setid = $auth1
23336
23337 dovecot_ntlm:
23338   driver = dovecot
23339   public_name = NTLM
23340   server_socket = /var/run/dovecot/auth-client
23341   server_setid = $auth1
23342 .endd
23343 If the SMTP connection is encrypted, or if &$sender_host_address$& is equal to
23344 &$received_ip_address$& (that is, the connection is local), the &"secured"&
23345 option is passed in the Dovecot authentication command. If, for a TLS
23346 connection, a client certificate has been verified, the &"valid-client-cert"&
23347 option is passed.
23348 .ecindex IIDdcotauth1
23349 .ecindex IIDdcotauth2
23350 .wen
23351
23352
23353 . ////////////////////////////////////////////////////////////////////////////
23354 . ////////////////////////////////////////////////////////////////////////////
23355
23356 .chapter "The spa authenticator" "CHAPspa"
23357 .scindex IIDspaauth1 "&(spa)& authenticator"
23358 .scindex IIDspaauth2 "authenticators" "&(spa)&"
23359 .cindex "authentication" "Microsoft Secure Password"
23360 .cindex "authentication" "NTLM"
23361 .cindex "Microsoft Secure Password Authentication"
23362 .cindex "NTLM authentication"
23363 The &(spa)& authenticator provides client support for Microsoft's &'Secure
23364 Password Authentication'& mechanism,
23365 which is also sometimes known as NTLM (NT LanMan). The code for client side of
23366 this authenticator was contributed by Marc Prud'hommeaux, and much of it is
23367 taken from the Samba project (&url(http://www.samba.org)). The code for the
23368 server side was subsequently contributed by Tom Kistner. The mechanism works as
23369 follows:
23370
23371 .ilist
23372 After the AUTH command has been accepted, the client sends an SPA
23373 authentication request based on the user name and optional domain.
23374 .next
23375 The server sends back a challenge.
23376 .next
23377 The client builds a challenge response which makes use of the user's password
23378 and sends it to the server, which then accepts or rejects it.
23379 .endlist
23380
23381 Encryption is used to protect the password in transit.
23382
23383
23384
23385 .section "Using spa as a server"
23386 .cindex "options" "&(spa)& authenticator (server)"
23387 The &(spa)& authenticator has just one server option:
23388
23389 .option server_password spa string&!! unset
23390 .cindex "numerical variables (&$1$& &$2$& etc)" "in &(spa)& authenticator"
23391 This option is expanded, and the result must be the cleartext password for the
23392 authenticating user, whose name is at this point in &$auth1$&. For
23393 compatibility with previous releases of Exim, the user name is also placed in
23394 &$1$&. However, the use of this variable for this purpose is now deprecated, as
23395 it can lead to confusion in string expansions that also use numeric variables
23396 for other things. For example:
23397 .code
23398 spa:
23399   driver = spa
23400   public_name = NTLM
23401   server_password = \
23402     ${lookup{$auth1}lsearch{/etc/exim/spa_clearpass}{$value}fail}
23403 .endd
23404 If the expansion is forced to fail, authentication fails. Any other expansion
23405 failure causes a temporary error code to be returned.
23406
23407
23408
23409
23410
23411 .section "Using spa as a client"
23412 .cindex "options" "&(spa)& authenticator (client)"
23413 The &(spa)& authenticator has the following client options:
23414
23415
23416
23417 .option client_domain spa string&!! unset
23418 This option specifies an optional domain for the authentication.
23419
23420
23421 .option client_password spa string&!! unset
23422 This option specifies the user's password, and must be set.
23423
23424
23425 .option client_username spa string&!! unset
23426 This option specifies the user name, and must be set. Here is an example of a
23427 configuration of this authenticator for use with the mail servers at
23428 &'msn.com'&:
23429 .code
23430 msn:
23431   driver = spa
23432   public_name = MSN
23433   client_username = msn/msn_username
23434   client_password = msn_plaintext_password
23435   client_domain = DOMAIN_OR_UNSET
23436 .endd
23437 .ecindex IIDspaauth1
23438 .ecindex IIDspaauth2
23439
23440
23441
23442
23443
23444 . ////////////////////////////////////////////////////////////////////////////
23445 . ////////////////////////////////////////////////////////////////////////////
23446
23447 .chapter "Encrypted SMTP connections using TLS/SSL" "CHAPTLS" &&&
23448          "Encrypted SMTP connections"
23449 .scindex IIDencsmtp1 "encryption" "on SMTP connection"
23450 .scindex IIDencsmtp2 "SMTP" "encryption"
23451 .cindex "TLS" "on SMTP connection"
23452 .cindex "OpenSSL"
23453 .cindex "GnuTLS"
23454 Support for TLS (Transport Layer Security), formerly known as SSL (Secure
23455 Sockets Layer), is implemented by making use of the OpenSSL library or the
23456 GnuTLS library (Exim requires GnuTLS release 1.0 or later). There is no
23457 cryptographic code in the Exim distribution itself for implementing TLS. In
23458 order to use this feature you must install OpenSSL or GnuTLS, and then build a
23459 version of Exim that includes TLS support (see section &<<SECTinctlsssl>>&).
23460 You also need to understand the basic concepts of encryption at a managerial
23461 level, and in particular, the way that public keys, private keys, and
23462 certificates are used.
23463
23464 RFC 3207 defines how SMTP connections can make use of encryption. Once a
23465 connection is established, the client issues a STARTTLS command. If the
23466 server accepts this, the client and the server negotiate an encryption
23467 mechanism. If the negotiation succeeds, the data that subsequently passes
23468 between them is encrypted.
23469
23470 Exim's ACLs can detect whether the current SMTP session is encrypted or not,
23471 and if so, what cipher suite is in use, whether the client supplied a
23472 certificate, and whether or not that certificate was verified. This makes it
23473 possible for an Exim server to deny or accept certain commands based on the
23474 encryption state.
23475
23476 &*Warning*&: Certain types of firewall and certain anti-virus products can
23477 disrupt TLS connections. You need to turn off SMTP scanning for these products
23478 in order to get TLS to work.
23479
23480
23481
23482 .section "Support for the legacy &""ssmtp""& (aka &""smtps""&) protocol"
23483 .cindex "ssmtp protocol"
23484 .cindex "smtps protocol"
23485 .cindex "SMTP" "ssmtp protocol"
23486 .cindex "SMTP" "smtps protocol"
23487 Early implementations of encrypted SMTP used a different TCP port from normal
23488 SMTP, and expected an encryption negotiation to start immediately, instead of
23489 waiting for a STARTTLS command from the client using the standard SMTP
23490 port. The protocol was called &"ssmtp"& or &"smtps"&, and port 465 was
23491 allocated for this purpose.
23492
23493 This approach was abandoned when encrypted SMTP was standardised, but there are
23494 still some legacy clients that use it. Exim supports these clients by means of
23495 the &%tls_on_connect_ports%& global option. Its value must be a list of port
23496 numbers; the most common use is expected to be:
23497 .code
23498 tls_on_connect_ports = 465
23499 .endd
23500 The port numbers specified by this option apply to all SMTP connections, both
23501 via the daemon and via &'inetd'&. You still need to specify all the ports that
23502 the daemon uses (by setting &%daemon_smtp_ports%& or &%local_interfaces%& or
23503 the &%-oX%& command line option) because &%tls_on_connect_ports%& does not add
23504 an extra port &-- rather, it specifies different behaviour on a port that is
23505 defined elsewhere.
23506
23507 There is also a &%-tls-on-connect%& command line option. This overrides
23508 &%tls_on_connect_ports%&; it forces the legacy behaviour for all ports.
23509
23510
23511
23512
23513
23514
23515 .section "OpenSSL vs GnuTLS" "SECTopenvsgnu"
23516 .cindex "TLS" "OpenSSL &'vs'& GnuTLS"
23517 The first TLS support in Exim was implemented using OpenSSL. Support for GnuTLS
23518 followed later, when the first versions of GnuTLS were released. To build Exim
23519 to use GnuTLS, you need to set
23520 .code
23521 USE_GNUTLS=yes
23522 .endd
23523 in Local/Makefile, in addition to
23524 .code
23525 SUPPORT_TLS=yes
23526 .endd
23527 You must also set TLS_LIBS and TLS_INCLUDE appropriately, so that the
23528 include files and libraries for GnuTLS can be found.
23529
23530 There are some differences in usage when using GnuTLS instead of OpenSSL:
23531
23532 .ilist
23533 The &%tls_verify_certificates%& option must contain the name of a file, not the
23534 name of a directory (for OpenSSL it can be either).
23535 .next
23536 The &%tls_dhparam%& option is ignored, because early versions of GnuTLS had no
23537 facility for varying its Diffie-Hellman parameters. I understand that this has
23538 changed, but Exim has not been updated to provide this facility.
23539 .next
23540 .cindex "&$tls_peerdn$&"
23541 Distinguished Name (DN) strings reported by the OpenSSL library use a slash for
23542 separating fields; GnuTLS uses commas, in accordance with RFC 2253. This
23543 affects the value of the &$tls_peerdn$& variable.
23544 .next
23545 OpenSSL identifies cipher suites using hyphens as separators, for example:
23546 DES-CBC3-SHA. GnuTLS uses underscores, for example: RSA_ARCFOUR_SHA. What is
23547 more, OpenSSL complains if underscores are present in a cipher list. To make
23548 life simpler, Exim changes underscores to hyhens for OpenSSL and hyphens to
23549 underscores for GnuTLS when processing lists of cipher suites in the
23550 &%tls_require_ciphers%& options (the global option and the &(smtp)& transport
23551 option).
23552 .next
23553 The &%tls_require_ciphers%& options operate differently, as described in the
23554 sections &<<SECTreqciphssl>>& and &<<SECTreqciphgnu>>&.
23555 .endlist
23556
23557
23558 .section "GnuTLS parameter computation"
23559 GnuTLS uses RSA and D-H parameters that may take a substantial amount of time
23560 to compute. It is unreasonable to re-compute them for every TLS session.
23561 Therefore, Exim keeps this data in a file in its spool directory, called
23562 &_gnutls-params_&. The file is owned by the Exim user and is readable only by
23563 its owner. Every Exim process that start up GnuTLS reads the RSA and D-H
23564 parameters from this file. If the file does not exist, the first Exim process
23565 that needs it computes the data and writes it to a temporary file which is
23566 renamed once it is complete. It does not matter if several Exim processes do
23567 this simultaneously (apart from wasting a few resources). Once a file is in
23568 place, new Exim processes immediately start using it.
23569
23570 For maximum security, the parameters that are stored in this file should be
23571 recalculated periodically, the frequency depending on your paranoia level.
23572 Arranging this is easy in principle; just delete the file when you want new
23573 values to be computed. However, there may be a problem. The calculation of new
23574 parameters needs random numbers, and these are obtained from &_/dev/random_&.
23575 If the system is not very active, &_/dev/random_& may delay returning data
23576 until enough randomness (entropy) is available. This may cause Exim to hang for
23577 a substantial amount of time, causing timeouts on incoming connections.
23578
23579 The solution is to generate the parameters externally to Exim. They are stored
23580 in &_gnutls-params_& in PEM format, which means that they can be generated
23581 externally using the &(certtool)& command that is part of GnuTLS.
23582
23583 To replace the parameters with new ones, instead of deleting the file
23584 and letting Exim re-create it, you can generate new parameters using
23585 &(certtool)& and, when this has been done, replace Exim's cache file by
23586 renaming. The relevant commands are something like this:
23587 .code
23588 # rm -f new-params
23589 # touch new-params
23590 # chown exim:exim new-params
23591 # chmod 0400 new-params
23592 # certtool --generate-privkey --bits 512 >new-params
23593 # echo "" >>new-params
23594 # certtool --generate-dh-params --bits 1024 >> new-params
23595 # mv new-params gnutls-params
23596 .endd
23597 If Exim never has to generate the parameters itself, the possibility of
23598 stalling is removed.
23599
23600
23601 .section "Requiring specific ciphers in OpenSSL" "SECTreqciphssl"
23602 .cindex "TLS" "requiring specific ciphers (OpenSSL)"
23603 .cindex "&%tls_require_ciphers%&" "OpenSSL"
23604 There is a function in the OpenSSL library that can be passed a list of cipher
23605 suites before the cipher negotiation takes place. This specifies which ciphers
23606 are acceptable. The list is colon separated and may contain names like
23607 DES-CBC3-SHA. Exim passes the expanded value of &%tls_require_ciphers%&
23608 directly to this function call. The following quotation from the OpenSSL
23609 documentation specifies what forms of item are allowed in the cipher string:
23610
23611 .ilist
23612 It can consist of a single cipher suite such as RC4-SHA.
23613 .next
23614 It can represent a list of cipher suites containing a certain algorithm,
23615 or cipher suites of a certain type. For example SHA1 represents all
23616 ciphers suites using the digest algorithm SHA1 and SSLv3 represents all
23617 SSL v3 algorithms.
23618 .next
23619 Lists of cipher suites can be combined in a single cipher string using
23620 the + character. This is used as a logical and operation. For example
23621 SHA1+DES represents all cipher suites containing the SHA1 and the DES
23622 algorithms.
23623 .endlist
23624
23625 Each cipher string can be optionally preceded by one of the characters &`!`&,
23626 &`-`& or &`+`&.
23627 .ilist
23628 If &`!`& is used, the ciphers are permanently deleted from the list. The
23629 ciphers deleted can never reappear in the list even if they are explicitly
23630 stated.
23631 .next
23632 If &`-`& is used, the ciphers are deleted from the list, but some or all
23633 of the ciphers can be added again by later options.
23634 .next
23635 If &`+`& is used, the ciphers are moved to the end of the list. This
23636 option does not add any new ciphers; it just moves matching existing ones.
23637 .endlist
23638
23639 If none of these characters is present, the string is interpreted as
23640 a list of ciphers to be appended to the current preference list. If the list
23641 includes any ciphers already present they will be ignored: that is, they will
23642 not be moved to the end of the list.
23643 .endlist
23644
23645
23646
23647
23648 .section "Requiring specific ciphers in GnuTLS" "SECTreqciphgnu"
23649 .cindex "TLS" "requiring specific ciphers (GnuTLS)"
23650 .cindex "&%tls_require_ciphers%&" "GnuTLS"
23651 The GnuTLS library does not have a combined function like OpenSSL. Instead,
23652 it allows the caller to specify separate lists of key-exchange methods,
23653 main cipher algorithms, and MAC algorithms. Unfortunately, these lists are
23654 numerical, and the library does not have a function for turning names into
23655 numbers. Consequently, the list of recognized names has to be built into
23656 the application.
23657
23658 At present, Exim permits only the list of main cipher algorithms to be
23659 changed. The &%tls_require_ciphers%& option is in the same format as for
23660 OpenSSL. Exim searches each item for the name of available algorithm. For
23661 example, if the list contains RSA_AES_SHA then AES is recognized.
23662
23663 The cipher algorithms list starts out with a default set of algorithms. If
23664 the first item in &%tls_require_ciphers%& does &'not'& start with an
23665 exclamation mark, all the default items are deleted. Thus, only those specified
23666 can be used. If the first item in &%tls_require_ciphers%& &'does'& start with
23667 an exclamation mark, the defaults are left on the list.
23668
23669 Then, any item that starts with an exclamation mark causes the relevant
23670 algorithms to be removed from the list, and any item that does not start
23671 with an exclamation mark causes the relevant algorithms to be added to the
23672 list. Thus,
23673 .code
23674 tls_require_ciphers = !RSA_ARCFOUR_SHA
23675 .endd
23676 allows all the defaults except those that use ARCFOUR, whereas
23677 .code
23678 tls_require_ciphers = AES : 3DES
23679 .endd
23680 allows only cipher suites that use AES and 3DES. The currently recognized
23681 algorithms are: AES_256, AES_128, AES (both of the preceding), 3DES, and
23682 ARCFOUR_128. Unrecognized algorithms are ignored. In a server, the order of the
23683 list is unimportant; the server will advertise the availability of all the
23684 relevant cipher suites. However, in a client, the order of the list specifies a
23685 preference order for the algorithms. The first one in the client's list that is
23686 also advertised by the server is tried first. The default order is as listed
23687 above.
23688
23689
23690
23691
23692 .section "Configuring an Exim server to use TLS"
23693 .cindex "TLS" "configuring an Exim server"
23694 When Exim has been built with TLS support, it advertises the availability of
23695 the STARTTLS command to client hosts that match &%tls_advertise_hosts%&,
23696 but not to any others. The default value of this option is unset, which means
23697 that STARTTLS is not advertised at all. This default is chosen because you
23698 need to set some other options in order to make TLS avaliable, and also it is
23699 sensible for systems that want to use TLS only as a client.
23700
23701 If a client issues a STARTTLS command and there is some configuration
23702 problem in the server, the command is rejected with a 454 error. If the client
23703 persists in trying to issue SMTP commands, all except QUIT are rejected
23704 with the error
23705 .code
23706 554 Security failure
23707 .endd
23708 If a STARTTLS command is issued within an existing TLS session, it is
23709 rejected with a 554 error code.
23710
23711 To enable TLS operations on a server, you must set &%tls_advertise_hosts%& to
23712 match some hosts. You can, of course, set it to * to match all hosts.
23713 However, this is not all you need to do. TLS sessions to a server won't work
23714 without some further configuration at the server end.
23715
23716 It is rumoured that all existing clients that support TLS/SSL use RSA
23717 encryption. To make this work you need to set, in the server,
23718 .code
23719 tls_certificate = /some/file/name
23720 tls_privatekey = /some/file/name
23721 .endd
23722 These options are, in fact, expanded strings, so you can make them depend on
23723 the identity of the client that is connected if you wish. The first file
23724 contains the server's X509 certificate, and the second contains the private key
23725 that goes with it. These files need to be readable by the Exim user, and must
23726 always be given as full path names. They can be the same file if both the
23727 certificate and the key are contained within it. If &%tls_privatekey%& is not
23728 set, or if its expansion is forced to fail or results in an empty string, this
23729 is assumed to be the case. The certificate file may also contain intermediate
23730 certificates that need to be sent to the client to enable it to authenticate
23731 the server's certificate.
23732
23733 If you do not understand about certificates and keys, please try to find a
23734 source of this background information, which is not Exim-specific. (There are a
23735 few comments below in section &<<SECTcerandall>>&.)
23736
23737 &*Note*&: These options do not apply when Exim is operating as a client &--
23738 they apply only in the case of a server. If you need to use a certificate in an
23739 Exim client, you must set the options of the same names in an &(smtp)&
23740 transport.
23741
23742 With just these options, an Exim server will be able to use TLS. It does not
23743 require the client to have a certificate (but see below for how to insist on
23744 this). There is one other option that may be needed in other situations. If
23745 .code
23746 tls_dhparam = /some/file/name
23747 .endd
23748 is set, the SSL library is initialized for the use of Diffie-Hellman ciphers
23749 with the parameters contained in the file. This increases the set of cipher
23750 suites that the server supports. See the command
23751 .code
23752 openssl dhparam
23753 .endd
23754 for a way of generating this data. At present, &%tls_dhparam%& is used only
23755 when Exim is linked with OpenSSL. It is ignored if GnuTLS is being used.
23756
23757 The strings supplied for these three options are expanded every time a client
23758 host connects. It is therefore possible to use different certificates and keys
23759 for different hosts, if you so wish, by making use of the client's IP address
23760 in &$sender_host_address$& to control the expansion. If a string expansion is
23761 forced to fail, Exim behaves as if the option is not set.
23762
23763 .cindex "cipher" "logging"
23764 .cindex "log" "TLS cipher"
23765 .cindex "&$tls_cipher$&"
23766 The variable &$tls_cipher$& is set to the cipher suite that was negotiated for
23767 an incoming TLS connection. It is included in the &'Received:'& header of an
23768 incoming message (by default &-- you can, of course, change this), and it is
23769 also included in the log line that records a message's arrival, keyed by
23770 &"X="&, unless the &%tls_cipher%& log selector is turned off. The &%encrypted%&
23771 condition can be used to test for specific cipher suites in ACLs.
23772
23773 The ACLs that run for subsequent SMTP commands can check the name of the cipher
23774 suite and vary their actions accordingly. The cipher suite names are those used
23775 by OpenSSL. These may differ from the names used elsewhere. For example,
23776 OpenSSL uses the name DES-CBC3-SHA for the cipher suite which in other contexts
23777 is known as TLS_RSA_WITH_3DES_EDE_CBC_SHA. Check the OpenSSL
23778 documentation for more details.
23779
23780
23781
23782 .section "Requesting and verifying client certificates"
23783 .cindex "certificate" "verification of client"
23784 .cindex "TLS" "client certificate verification"
23785 If you want an Exim server to request a certificate when negotiating a TLS
23786 session with a client, you must set either &%tls_verify_hosts%& or
23787 &%tls_try_verify_hosts%&. You can, of course, set either of them to * to
23788 apply to all TLS connections. For any host that matches one of these options,
23789 Exim requests a certificate as part of the setup of the TLS session. The
23790 contents of the certificate are verified by comparing it with a list of
23791 expected certificates. These must be available in a file or,
23792 for OpenSSL only (not GnuTLS), a directory, identified by
23793 &%tls_verify_certificates%&.
23794
23795 A file can contain multiple certificates, concatenated end to end. If a
23796 directory is used
23797 (OpenSSL only),
23798 each certificate must be in a separate file, with a name (or a symbolic link)
23799 of the form <&'hash'&>.0, where <&'hash'&> is a hash value constructed from the
23800 certificate. You can compute the relevant hash by running the command
23801 .code
23802 openssl x509 -hash -noout -in /cert/file
23803 .endd
23804 where &_/cert/file_& contains a single certificate.
23805
23806 The difference between &%tls_verify_hosts%& and &%tls_try_verify_hosts%& is
23807 what happens if the client does not supply a certificate, or if the certificate
23808 does not match any of the certificates in the collection named by
23809 &%tls_verify_certificates%&. If the client matches &%tls_verify_hosts%&, the
23810 attempt to set up a TLS session is aborted, and the incoming connection is
23811 dropped. If the client matches &%tls_try_verify_hosts%&, the (encrypted) SMTP
23812 session continues. ACLs that run for subsequent SMTP commands can detect the
23813 fact that no certificate was verified, and vary their actions accordingly. For
23814 example, you can insist on a certificate before accepting a message for
23815 relaying, but not when the message is destined for local delivery.
23816
23817 .cindex "&$tls_peerdn$&"
23818 When a client supplies a certificate (whether it verifies or not), the value of
23819 the Distinguished Name of the certificate is made available in the variable
23820 &$tls_peerdn$& during subsequent processing of the message.
23821
23822 .cindex "log" "distinguished name"
23823 Because it is often a long text string, it is not included in the log line or
23824 &'Received:'& header by default. You can arrange for it to be logged, keyed by
23825 &"DN="&, by setting the &%tls_peerdn%& log selector, and you can use
23826 &%received_header_text%& to change the &'Received:'& header. When no
23827 certificate is supplied, &$tls_peerdn$& is empty.
23828
23829
23830 .section "Revoked certificates"
23831 .cindex "TLS" "revoked certificates"
23832 .cindex "revocation list"
23833 .cindex "certificate" "revocation list"
23834 Certificate issuing authorities issue Certificate Revocation Lists (CRLs) when
23835 certificates are revoked. If you have such a list, you can pass it to an Exim
23836 server using the global option called &%tls_crl%& and to an Exim client using
23837 an identically named option for the &(smtp)& transport. In each case, the value
23838 of the option is expanded and must then be the name of a file that contains a
23839 CRL in PEM format.
23840
23841
23842 .section "Configuring an Exim client to use TLS"
23843 .cindex "cipher" "logging"
23844 .cindex "log" "TLS cipher"
23845 .cindex "log" "distinguished name"
23846 .cindex "TLS" "configuring an Exim client"
23847 The &%tls_cipher%& and &%tls_peerdn%& log selectors apply to outgoing SMTP
23848 deliveries as well as to incoming, the latter one causing logging of the
23849 server certificate's DN. The remaining client configuration for TLS is all
23850 within the &(smtp)& transport.
23851
23852 It is not necessary to set any options to have TLS work in the &(smtp)&
23853 transport. If Exim is built with TLS support, and TLS is advertised by a
23854 server, the &(smtp)& transport always tries to start a TLS session. However,
23855 this can be prevented by setting &%hosts_avoid_tls%& (an option of the
23856 transport) to a list of server hosts for which TLS should not be used.
23857
23858 If you do not want Exim to attempt to send messages unencrypted when an attempt
23859 to set up an encrypted connection fails in any way, you can set
23860 &%hosts_require_tls%& to a list of hosts for which encryption is mandatory. For
23861 those hosts, delivery is always deferred if an encrypted connection cannot be
23862 set up. If there are any other hosts for the address, they are tried in the
23863 usual way.
23864
23865 When the server host is not in &%hosts_require_tls%&, Exim may try to deliver
23866 the message unencrypted. It always does this if the response to STARTTLS is
23867 a 5&'xx'& code. For a temporary error code, or for a failure to negotiate a TLS
23868 session after a success response code, what happens is controlled by the
23869 &%tls_tempfail_tryclear%& option of the &(smtp)& transport. If it is false,
23870 delivery to this host is deferred, and other hosts (if available) are tried. If
23871 it is true, Exim attempts to deliver unencrypted after a 4&'xx'& response to
23872 STARTTLS, and if STARTTLS is accepted, but the subsequent TLS
23873 negotiation fails, Exim closes the current connection (because it is in an
23874 unknown state), opens a new one to the same host, and then tries the delivery
23875 unencrypted.
23876
23877
23878 The &%tls_certificate%& and &%tls_privatekey%& options of the &(smtp)&
23879 transport provide the client with a certificate, which is passed to the server
23880 if it requests it. If the server is Exim, it will request a certificate only if
23881 &%tls_verify_hosts%& or &%tls_try_verify_hosts%& matches the client. &*Note*&:
23882 These options must be set in the &(smtp)& transport for Exim to use TLS when it
23883 is operating as a client. Exim does not assume that a server certificate (set
23884 by the global options of the same name) should also be used when operating as a
23885 client.
23886
23887 If &%tls_verify_certificates%& is set, it must name a file or,
23888 for OpenSSL only (not GnuTLS), a directory, that contains a collection of
23889 expected server certificates. The client verifies the server's certificate
23890 against this collection, taking into account any revoked certificates that are
23891 in the list defined by &%tls_crl%&.
23892
23893 If
23894 &%tls_require_ciphers%& is set on the &(smtp)& transport, it must contain a
23895 list of permitted cipher suites. If either of these checks fails, delivery to
23896 the current host is abandoned, and the &(smtp)& transport tries to deliver to
23897 alternative hosts, if any.
23898
23899 .cindex "&$host$&"
23900 .cindex "&$host_address$&"
23901 All the TLS options in the &(smtp)& transport are expanded before use, with
23902 &$host$& and &$host_address$& containing the name and address of the server to
23903 which the client is connected. Forced failure of an expansion causes Exim to
23904 behave as if the relevant option were unset.
23905
23906
23907
23908 .section "Multiple messages on the same encrypted TCP/IP connection" &&&
23909          "SECTmulmessam"
23910 .cindex "multiple SMTP deliveries with TLS"
23911 .cindex "TLS" "multiple message deliveries"
23912 Exim sends multiple messages down the same TCP/IP connection by starting up
23913 an entirely new delivery process for each message, passing the socket from
23914 one process to the next. This implementation does not fit well with the use
23915 of TLS, because there is quite a lot of state information associated with a TLS
23916 connection, not just a socket identification. Passing all the state information
23917 to a new process is not feasible. Consequently, Exim shuts down an existing TLS
23918 session before passing the socket to a new process. The new process may then
23919 try to start a new TLS session, and if successful, may try to re-authenticate
23920 if AUTH is in use, before sending the next message.
23921
23922 The RFC is not clear as to whether or not an SMTP session continues in clear
23923 after TLS has been shut down, or whether TLS may be restarted again later, as
23924 just described. However, if the server is Exim, this shutdown and
23925 reinitialization works. It is not known which (if any) other servers operate
23926 successfully if the client closes a TLS session and continues with unencrypted
23927 SMTP, but there are certainly some that do not work. For such servers, Exim
23928 should not pass the socket to another process, because the failure of the
23929 subsequent attempt to use it would cause Exim to record a temporary host error,
23930 and delay other deliveries to that host.
23931
23932 To test for this case, Exim sends an EHLO command to the server after
23933 closing down the TLS session. If this fails in any way, the connection is
23934 closed instead of being passed to a new delivery process, but no retry
23935 information is recorded.
23936
23937 There is also a manual override; you can set &%hosts_nopass_tls%& on the
23938 &(smtp)& transport to match those hosts for which Exim should not pass
23939 connections to new processes if TLS has been used.
23940
23941
23942
23943
23944 .section "Certificates and all that" "SECTcerandall"
23945 .cindex "certificate" "references to discussion"
23946 In order to understand fully how TLS works, you need to know about
23947 certificates, certificate signing, and certificate authorities. This is not the
23948 place to give a tutorial, especially as I do not know very much about it
23949 myself. Some helpful introduction can be found in the FAQ for the SSL addition
23950 to Apache, currently at
23951 .display
23952 &url(http://www.modssl.org/docs/2.7/ssl_faq.html#ToC24)
23953 .endd
23954 Other parts of the &'modssl'& documentation are also helpful, and have
23955 links to further files.
23956 Eric Rescorla's book, &'SSL and TLS'&, published by Addison-Wesley (ISBN
23957 0-201-61598-3), contains both introductory and more in-depth descriptions.
23958 Some sample programs taken from the book are available from
23959 .display
23960 &url(http://www.rtfm.com/openssl-examples/)
23961 .endd
23962
23963
23964 .section "Certificate chains"
23965 The file named by &%tls_certificate%& may contain more than one
23966 certificate. This is useful in the case where the certificate that is being
23967 sent is validated by an intermediate certificate which the other end does
23968 not have. Multiple certificates must be in the correct order in the file.
23969 First the host's certificate itself, then the first intermediate
23970 certificate to validate the issuer of the host certificate, then the next
23971 intermediate certificate to validate the issuer of the first intermediate
23972 certificate, and so on, until finally (optionally) the root certificate.
23973 The root certificate must already be trusted by the recipient for
23974 validation to succeed, of course, but if it's not preinstalled, sending the
23975 root certificate along with the rest makes it available for the user to
23976 install if the receiving end is a client MUA that can interact with a user.
23977
23978
23979 .section "Self-signed certificates"
23980 .cindex "certificate" "self-signed"
23981 You can create a self-signed certificate using the &'req'& command provided
23982 with OpenSSL, like this:
23983 .code
23984 openssl req -x509 -newkey rsa:1024 -keyout file1 -out file2 \
23985             -days 9999 -nodes
23986 .endd
23987 &_file1_& and &_file2_& can be the same file; the key and the certificate are
23988 delimited and so can be identified independently. The &%-days%& option
23989 specifies a period for which the certificate is valid. The &%-nodes%& option is
23990 important: if you do not set it, the key is encrypted with a passphrase
23991 that you are prompted for, and any use that is made of the key causes more
23992 prompting for the passphrase. This is not helpful if you are going to use
23993 this certificate and key in an MTA, where prompting is not possible.
23994
23995 A self-signed certificate made in this way is sufficient for testing, and
23996 may be adequate for all your requirements if you are mainly interested in
23997 encrypting transfers, and not in secure identification.
23998
23999 However, many clients require that the certificate presented by the server be a
24000 user (also called &"leaf"& or &"site"&) certificate, and not a self-signed
24001 certificate. In this situation, the self-signed certificate described above
24002 must be installed on the client host as a trusted root &'certification
24003 authority'& (CA), and the certificate used by Exim must be a user certificate
24004 signed with that self-signed certificate.
24005
24006 For information on creating self-signed CA certificates and using them to sign
24007 user certificates, see the &'General implementation overview'& chapter of the
24008 Open-source PKI book, available online at
24009 &url(http://ospkibook.sourceforge.net/).
24010 .ecindex IIDencsmtp1
24011 .ecindex IIDencsmtp2
24012
24013
24014
24015 . ////////////////////////////////////////////////////////////////////////////
24016 . ////////////////////////////////////////////////////////////////////////////
24017
24018 .chapter "Access control lists" "CHAPACL"
24019 .scindex IIDacl "&ACL;" "description"
24020 .cindex "control of incoming mail"
24021 .cindex "message" "controlling incoming"
24022 .cindex "policy control" "access control lists"
24023 Access Control Lists (ACLs) are defined in a separate section of the run time
24024 configuration file, headed by &"begin acl"&. Each ACL definition starts with a
24025 name, terminated by a colon. Here is a complete ACL section that contains just
24026 one very small ACL:
24027 .code
24028 begin acl
24029
24030 small_acl:
24031   accept   hosts = one.host.only
24032 .endd
24033 You can have as many lists as you like in the ACL section, and the order in
24034 which they appear does not matter. The lists are self-terminating.
24035
24036 The majority of ACLs are used to control Exim's behaviour when it receives
24037 certain SMTP commands. This applies both to incoming TCP/IP connections, and
24038 when a local process submits a message using SMTP by specifying the &%-bs%&
24039 option. The most common use is for controlling which recipients are accepted
24040 in incoming messages. In addition, you can define an ACL that is used to check
24041 local non-SMTP messages. The default configuration file contains an example of
24042 a realistic ACL for checking RCPT commands. This is discussed in chapter
24043 &<<CHAPdefconfil>>&.
24044
24045
24046 .section "Testing ACLs"
24047 The &%-bh%& command line option provides a way of testing your ACL
24048 configuration locally by running a fake SMTP session with which you interact.
24049 The host &'relay-test.mail-abuse.org'& provides a service for checking your
24050 relaying configuration (see section &<<SECTcheralcon>>& for more details).
24051
24052
24053
24054 .section "Specifying when ACLs are used"
24055 .cindex "&ACL;" "options for specifying"
24056 In order to cause an ACL to be used, you have to name it in one of the relevant
24057 options in the main part of the configuration. These options are:
24058 .cindex "AUTH" "ACL for"
24059 .cindex "DATA" "ACLs for"
24060 .cindex "ETRN" "ACL for"
24061 .cindex "EXPN" "ACL for"
24062 .cindex "HELO" "ACL for"
24063 .cindex "EHLO" "ACL for"
24064 .cindex "MAIL" "ACL for"
24065 .cindex "QUIT" "ACL for"
24066 .cindex "RCPT" "ACL for"
24067 .cindex "STARTTLS" "ACL for"
24068 .cindex "VRFY" "ACL for"
24069 .cindex "SMTP connection" "ACL for"
24070 .cindex "non-smtp message" "ACLs for"
24071 .cindex "MIME parts" "ACL for"
24072
24073 .table2 140pt
24074 .row &~&%acl_not_smtp%&         "ACL for non-SMTP messages"
24075 .row &~&%acl_not_smtp_mime%&    "ACL for non-SMTP MIME parts"
24076 .row &~&%acl_not_smtp_start%&   "ACL at start of non-SMTP message"
24077 .row &~&%acl_smtp_auth%&        "ACL for AUTH"
24078 .row &~&%acl_smtp_connect%&     "ACL for start of SMTP connection"
24079 .row &~&%acl_smtp_data%&        "ACL after DATA is complete"
24080 .row &~&%acl_smtp_etrn%&        "ACL for ETRN"
24081 .row &~&%acl_smtp_expn%&        "ACL for EXPN"
24082 .row &~&%acl_smtp_helo%&        "ACL for HELO or EHLO"
24083 .row &~&%acl_smtp_mail%&        "ACL for MAIL"
24084 .row &~&%acl_smtp_mailauth%&    "ACL for the AUTH parameter of MAIL"
24085 .row &~&%acl_smtp_mime%&        "ACL for content-scanning MIME parts"
24086 .row &~&%acl_smtp_predata%&     "ACL at start of DATA command"
24087 .row &~&%acl_smtp_quit%&        "ACL for QUIT"
24088 .row &~&%acl_smtp_rcpt%&        "ACL for RCPT"
24089 .row &~&%acl_smtp_starttls%&    "ACL for STARTTLS"
24090 .row &~&%acl_smtp_vrfy%&        "ACL for VRFY"
24091 .endtable
24092
24093 For example, if you set
24094 .code
24095 acl_smtp_rcpt = small_acl
24096 .endd
24097 the little ACL defined above is used whenever Exim receives a RCPT command
24098 in an SMTP dialogue. The majority of policy tests on incoming messages can be
24099 done when RCPT commands arrive. A rejection of RCPT should cause the
24100 sending MTA to give up on the recipient address contained in the RCPT
24101 command, whereas rejection at other times may cause the client MTA to keep on
24102 trying to deliver the message. It is therefore recommended that you do as much
24103 testing as possible at RCPT time.
24104
24105
24106 .section "The non-SMTP ACLs"
24107 .cindex "non-smtp message" "ACLs for"
24108 The non-SMTP ACLs apply to all non-interactive incoming messages, that is, they
24109 apply to batched SMTP as well as to non-SMTP messages. (Batched SMTP is not
24110 really SMTP.) Many of the ACL conditions (for example, host tests, and tests on
24111 the state of the SMTP connection such as encryption and authentication) are not
24112 relevant and are forbidden in these ACLs. However, the sender and recipients
24113 are known, so the &%senders%& and &%sender_domains%& conditions and the
24114 &$sender_address$& and &$recipients$& variables can be used. Variables such as
24115 &$authenticated_sender$& are also available. You can specify added header lines
24116 in any of these ACLs.
24117
24118 The &%acl_not_smtp_start%& ACL is run right at the start of receiving a
24119 non-SMTP message, before any of the message has been read. (This is the
24120 analogue of the &%acl_smtp_predata%& ACL for SMTP input.) The result of this
24121 ACL is ignored; it cannot be used to reject a message. If you really need to,
24122 you could set a value in an ACL variable here and reject based on that in the
24123 &%acl_not_smtp%& ACL. However, this ACL can be used to set controls, and in
24124 particular, it can be used to set
24125 .code
24126 control = suppress_local_fixups
24127 .endd
24128 This cannot be used in the other non-SMTP ACLs because by the time they are
24129 run, it is too late.
24130
24131 The &%acl_not_smtp_mime%& ACL is available only when Exim is compiled with the
24132 content-scanning extension. For details, see chapter &<<CHAPexiscan>>&.
24133
24134 The &%acl_not_smtp%& ACL is run just before the &[local_scan()]& function. Any
24135 kind of rejection is treated as permanent, because there is no way of sending a
24136 temporary error for these kinds of message.
24137
24138
24139 .section "The SMTP connect ACL"
24140 .new
24141 .cindex "SMTP connection" "ACL for"
24142 .cindex &%smtp_banner%&
24143 The ACL test specified by &%acl_smtp_connect%& happens at the start of an SMTP
24144 session, after the test specified by &%host_reject_connection%& (which is now
24145 an anomaly) and any TCP Wrappers testing (if configured). If the connection is
24146 accepted by an &%accept%& verb that has a &%message%& modifier, the contents of
24147 the message override the banner message that is otherwise specified by the
24148 &%smtp_banner%& option.
24149
24150
24151 .section "The EHLO/HELO ACL"
24152 .cindex "EHLO" "ACL for"
24153 .cindex "HELO" "ACL for"
24154 The ACL test specified by &%acl_smtp_helo%& happens when the client issues an
24155 EHLO or HELO command, after the tests specified by &%helo_accept_junk_hosts%&,
24156 &%helo_allow_chars%&, &%helo_verify_hosts%&, and &%helo_try_verify_hosts%&.
24157 Note that a client may issue more than one EHLO or HELO command in an SMTP
24158 session, and indeed is required to issue a new EHLO or HELO after successfully
24159 setting up encryption following a STARTTLS command.
24160
24161 If the command is accepted by an &%accept%& verb that has a &%message%&
24162 modifier, the message may not contain more than one line (it will be truncated
24163 at the first newline and a panic logged if it does). Such a message cannot
24164 affect the EHLO options that are listed on the second and subsequent lines of
24165 an EHLO response.
24166 .wen
24167
24168
24169 .section "The DATA ACLs"
24170 .cindex "DATA" "ACLs for"
24171 Two ACLs are associated with the DATA command, because it is two-stage
24172 command, with two responses being sent to the client.
24173 When the DATA command is received, the ACL defined by &%acl_smtp_predata%&
24174 is obeyed. This gives you control after all the RCPT commands, but before
24175 the message itself is received. It offers the opportunity to give a negative
24176 response to the DATA command before the data is transmitted. Header lines
24177 added by MAIL or RCPT ACLs are not visible at this time, but any that
24178 are defined here are visible when the &%acl_smtp_data%& ACL is run.
24179
24180 You cannot test the contents of the message, for example, to verify addresses
24181 in the headers, at RCPT time or when the DATA command is received. Such
24182 tests have to appear in the ACL that is run after the message itself has been
24183 received, before the final response to the DATA command is sent. This is
24184 the ACL specified by &%acl_smtp_data%&, which is the second ACL that is
24185 associated with the DATA command.
24186
24187 For both of these ACLs, it is not possible to reject individual recipients. An
24188 error response rejects the entire message. Unfortunately, it is known that some
24189 MTAs do not treat hard (5&'xx'&) responses to the DATA command (either
24190 before or after the data) correctly &-- they keep the message on their queues
24191 and try again later, but that is their problem, though it does waste some of
24192 your resources.
24193
24194
24195 .section "The SMTP MIME ACL"
24196 The &%acl_smtp_mime%& option is available only when Exim is compiled with the
24197 content-scanning extension. For details, see chapter &<<CHAPexiscan>>&.
24198
24199
24200 .section "The QUIT ACL" "SECTQUITACL"
24201 .cindex "QUIT" "ACL for"
24202 The ACL for the SMTP QUIT command is anomalous, in that the outcome of the ACL
24203 does not affect the response code to QUIT, which is always 221. Thus, the ACL
24204 does not in fact control any access. For this reason, the only verbs that are
24205 permitted are &%accept%& and &%warn%&.
24206
24207 This ACL can be used for tasks such as custom logging at the end of an SMTP
24208 session. For example, you can use ACL variables in other ACLs to count
24209 messages, recipients, etc., and log the totals at QUIT time using one or
24210 more &%logwrite%& modifiers on a &%warn%& verb.
24211
24212 &*Warning*&: Only the &$acl_c$&&'x'& variables can be used for this, because
24213 the &$acl_m$&&'x'& variables are reset at the end of each incoming message.
24214
24215 You do not need to have a final &%accept%&, but if you do, you can use a
24216 &%message%& modifier to specify custom text that is sent as part of the 221
24217 response to QUIT.
24218
24219 This ACL is run only for a &"normal"& QUIT. For certain kinds of disastrous
24220 failure (for example, failure to open a log file, or when Exim is bombing out
24221 because it has detected an unrecoverable error), all SMTP commands from the
24222 client are given temporary error responses until QUIT is received or the
24223 connection is closed. In these special cases, the QUIT ACL does not run.
24224
24225
24226
24227 .section "Finding an ACL to use"
24228 .cindex "&ACL;" "finding which to use"
24229 The value of an &%acl_smtp_%&&'xxx'& option is expanded before use, so
24230 you can use different ACLs in different circumstances. For example,
24231 .code
24232 acl_smtp_rcpt = ${if ={25}{$interface_port} \
24233                      {acl_check_rcpt} {acl_check_rcpt_submit} }
24234 .endd
24235 In the default configuration file there are some example settings for
24236 providing an RFC 4409 message submission service on port 587 and a
24237 non-standard &"smtps"& service on port 465. You can use a string
24238 expansion like this to choose an ACL for MUAs on these ports which is
24239 more appropriate for this purpose than the default ACL on port 25.
24240
24241 The expanded string does not have to be the name of an ACL in the
24242 configuration file; there are other possibilities. Having expanded the
24243 string, Exim searches for an ACL as follows:
24244
24245 .ilist
24246 If the string begins with a slash, Exim uses it as a file name, and reads its
24247 contents as an ACL. The lines are processed in the same way as lines in the
24248 Exim configuration file. In particular, continuation lines are supported, blank
24249 lines are ignored, as are lines whose first non-whitespace character is &"#"&.
24250 If the file does not exist or cannot be read, an error occurs (typically
24251 causing a temporary failure of whatever caused the ACL to be run). For example:
24252 .code
24253 acl_smtp_data = /etc/acls/\
24254   ${lookup{$sender_host_address}lsearch\
24255   {/etc/acllist}{$value}{default}}
24256 .endd
24257 This looks up an ACL file to use on the basis of the host's IP address, falling
24258 back to a default if the lookup fails. If an ACL is successfully read from a
24259 file, it is retained in memory for the duration of the Exim process, so that it
24260 can be re-used without having to re-read the file.
24261 .next
24262 If the string does not start with a slash, and does not contain any spaces,
24263 Exim searches the ACL section of the configuration for an ACL whose name
24264 matches the string.
24265 .next
24266 If no named ACL is found, or if the string contains spaces, Exim parses
24267 the string as an inline ACL. This can save typing in cases where you just
24268 want to have something like
24269 .code
24270 acl_smtp_vrfy = accept
24271 .endd
24272 in order to allow free use of the VRFY command. Such a string may contain
24273 newlines; it is processed in the same way as an ACL that is read from a file.
24274 .endlist
24275
24276
24277
24278
24279 .section "ACL return codes"
24280 .cindex "&ACL;" "return codes"
24281 Except for the QUIT ACL, which does not affect the SMTP return code (see
24282 section &<<SECTQUITACL>>& above), the result of running an ACL is either
24283 &"accept"& or &"deny"&, or, if some test cannot be completed (for example, if a
24284 database is down), &"defer"&. These results cause 2&'xx'&, 5&'xx'&, and 4&'xx'&
24285 return codes, respectively, to be used in the SMTP dialogue. A fourth return,
24286 &"error"&, occurs when there is an error such as invalid syntax in the ACL.
24287 This also causes a 4&'xx'& return code.
24288
24289 For the non-SMTP ACL, &"defer"& and &"error"& are treated in the same way as
24290 &"deny"&, because there is no mechanism for passing temporary errors to the
24291 submitters of non-SMTP messages.
24292
24293
24294 ACLs that are relevant to message reception may also return &"discard"&. This
24295 has the effect of &"accept"&, but causes either the entire message or an
24296 individual recipient address to be discarded. In other words, it is a
24297 blackholing facility. Use it with care.
24298
24299 If the ACL for MAIL returns &"discard"&, all recipients are discarded, and no
24300 ACL is run for subsequent RCPT commands. The effect of &"discard"& in a
24301 RCPT ACL is to discard just the one recipient address. If there are no
24302 recipients left when the message's data is received, the DATA ACL is not
24303 run. A &"discard"& return from the DATA or the non-SMTP ACL discards all the
24304 remaining recipients. The &"discard"& return is not permitted for the
24305 &%acl_smtp_predata%& ACL.
24306
24307
24308 .cindex "&[local_scan()]& function" "when all recipients discarded"
24309 The &[local_scan()]& function is always run, even if there are no remaining
24310 recipients; it may create new recipients.
24311
24312
24313
24314 .section "Unset ACL options"
24315 .cindex "&ACL;" "unset options"
24316 The default actions when any of the &%acl_%&&'xxx'& options are unset are not
24317 all the same. &*Note*&: These defaults apply only when the relevant ACL is
24318 not defined at all. For any defined ACL, the default action when control
24319 reaches the end of the ACL statements is &"deny"&.
24320
24321 For &%acl_smtp_quit%& and &%acl_not_smtp_start%& there is no default because
24322 these two are ACLs that are used only for their side effects. They cannot be
24323 used to accept or reject anything.
24324
24325 For &%acl_not_smtp%&, &%acl_smtp_auth%&, &%acl_smtp_connect%&,
24326 &%acl_smtp_data%&, &%acl_smtp_helo%&, &%acl_smtp_mail%&, &%acl_smtp_mailauth%&,
24327 &%acl_smtp_mime%&, &%acl_smtp_predata%&, and &%acl_smtp_starttls%&, the action
24328 when the ACL is not defined is &"accept"&.
24329
24330 For the others (&%acl_smtp_etrn%&, &%acl_smtp_expn%&, &%acl_smtp_rcpt%&, and
24331 &%acl_smtp_vrfy%&), the action when the ACL is not defined is &"deny"&.
24332 This means that &%acl_smtp_rcpt%& must be defined in order to receive any
24333 messages over an SMTP connection. For an example, see the ACL in the default
24334 configuration file.
24335
24336
24337
24338
24339 .section "Data for message ACLs"
24340 .cindex "&ACL;" "data for message ACL"
24341 .cindex &$domain$&
24342 .cindex &$local_part$&
24343 .cindex &$sender_address$&
24344 .cindex &$sender_host_address$&
24345 .cindex &$smtp_command$&
24346 When a MAIL or RCPT ACL, or either of the DATA ACLs, is running, the variables
24347 that contain information about the host and the message's sender (for example,
24348 &$sender_host_address$& and &$sender_address$&) are set, and can be used in ACL
24349 statements. In the case of RCPT (but not MAIL or DATA), &$domain$& and
24350 &$local_part$& are set from the argument address. The entire SMTP command
24351 is available in &$smtp_command$&.
24352
24353 When an ACL for the AUTH parameter of MAIL is running, the variables that
24354 contain information about the host are set, but &$sender_address$& is not yet
24355 set. Section &<<SECTauthparamail>>& contains a discussion of this parameter and
24356 how it is used.
24357
24358 .cindex "&$message_size$&"
24359 The &$message_size$& variable is set to the value of the SIZE parameter on
24360 the MAIL command at MAIL, RCPT and pre-data time, or to -1 if
24361 that parameter is not given. The value is updated to the true message size by
24362 the time the final DATA ACL is run (after the message data has been
24363 received).
24364
24365 .cindex "&$rcpt_count$&"
24366 .cindex "&$recipients_count$&"
24367 The &$rcpt_count$& variable increases by one for each RCPT command received.
24368 The &$recipients_count$& variable increases by one each time a RCPT command is
24369 accepted, so while an ACL for RCPT is being processed, it contains the number
24370 of previously accepted recipients. At DATA time (for both the DATA ACLs),
24371 &$rcpt_count$& contains the total number of RCPT commands, and
24372 &$recipients_count$& contains the total number of accepted recipients.
24373
24374
24375
24376
24377
24378 .section "Data for non-message ACLs" "SECTdatfornon"
24379 .cindex "&ACL;" "data for non-message ACL"
24380 .cindex &$smtp_command_argument$&
24381 .cindex &$smtp_command$&
24382 When an ACL is being run for AUTH, EHLO, ETRN, EXPN, HELO, STARTTLS, or VRFY,
24383 the remainder of the SMTP command line is placed in &$smtp_command_argument$&,
24384 and the entire SMTP command is available in &$smtp_command$&.
24385 These variables can be tested using a &%condition%& condition. For example,
24386 here is an ACL for use with AUTH, which insists that either the session is
24387 encrypted, or the CRAM-MD5 authentication method is used. In other words, it
24388 does not permit authentication methods that use cleartext passwords on
24389 unencrypted connections.
24390 .code
24391 acl_check_auth:
24392   accept encrypted = *
24393   accept condition = ${if eq{${uc:$smtp_command_argument}}\
24394                      {CRAM-MD5}}
24395   deny   message   = TLS encryption or CRAM-MD5 required
24396 .endd
24397 (Another way of applying this restriction is to arrange for the authenticators
24398 that use cleartext passwords not to be advertised when the connection is not
24399 encrypted. You can use the generic &%server_advertise_condition%& authenticator
24400 option to do this.)
24401
24402
24403
24404 .section "Format of an ACL"
24405 .cindex "&ACL;" "format of"
24406 .cindex "&ACL;" "verbs; definition of"
24407 An individual ACL consists of a number of statements. Each statement starts
24408 with a verb, optionally followed by a number of conditions and &"modifiers"&.
24409 Modifiers can change the way the verb operates, define error and log messages,
24410 set variables, insert delays, and vary the processing of accepted messages.
24411
24412 If all the conditions are met, the verb is obeyed. The same condition may be
24413 used (with different arguments) more than once in the same statement. This
24414 provides a means of specifying an &"and"& conjunction between conditions. For
24415 example:
24416 .code
24417 deny  dnslists = list1.example
24418 dnslists = list2.example
24419 .endd
24420 If there are no conditions, the verb is always obeyed. Exim stops evaluating
24421 the conditions and modifiers when it reaches a condition that fails. What
24422 happens then depends on the verb (and in one case, on a special modifier). Not
24423 all the conditions make sense at every testing point. For example, you cannot
24424 test a sender address in the ACL that is run for a VRFY command.
24425
24426
24427 .section "ACL verbs"
24428 The ACL verbs are as follows:
24429
24430 .ilist
24431 .cindex "&%accept%&" "ACL verb"
24432 &%accept%&: If all the conditions are met, the ACL returns &"accept"&. If any
24433 of the conditions are not met, what happens depends on whether &%endpass%&
24434 appears among the conditions (for syntax see below). If the failing condition
24435 is before &%endpass%&, control is passed to the next ACL statement; if it is
24436 after &%endpass%&, the ACL returns &"deny"&. Consider this statement, used to
24437 check a RCPT command:
24438 .code
24439 accept domains = +local_domains
24440 endpass
24441 verify = recipient
24442 .endd
24443 If the recipient domain does not match the &%domains%& condition, control
24444 passes to the next statement. If it does match, the recipient is verified, and
24445 the command is accepted if verification succeeds. However, if verification
24446 fails, the ACL yields &"deny"&, because the failing condition is after
24447 &%endpass%&.
24448
24449 .new
24450 The &%endpass%& feature has turned out to be confusing to many people, so its
24451 use is not recommended nowadays. It is always possible to rewrite an ACL so
24452 that &%endpass%& is not needed, and it is no longer used in the default
24453 configuration.
24454
24455 .cindex "&%message%&" "ACL modifier, with &%accept%&"
24456 If a &%message%& modifier appears on an &%accept%& statement, its action
24457 depends on whether or not &%endpass%& is present. In the absence of &%endpass%&
24458 (when an &%accept%& verb either accepts or passes control to the next
24459 statement), &%message%& can be used to vary the message that is sent when an
24460 SMTP command is accepted. For example, in a RCPT ACL you could have:
24461 .display
24462 &`accept  `&<&'some conditions'&>
24463 &`        message = OK, I'll allow you through today`&
24464 .endd
24465 You can specify an SMTP response code, optionally followed by an &"extended
24466 response code"& at the start of the message, but the first digit must be the
24467 same as would be sent by default, which is 2 for an &%accept%& verb.
24468
24469 If &%endpass%& is present in an &%accept%& statement, &%message%& specifies
24470 an error message that is used when access is denied. This behaviour is retained
24471 for backward compatibility, but current &"best practice"& is to avoid the use
24472 of &%endpass%&.
24473 .wen
24474
24475
24476 .next
24477 .cindex "&%defer%&" "ACL verb"
24478 &%defer%&: If all the conditions are true, the ACL returns &"defer"& which, in
24479 an SMTP session, causes a 4&'xx'& response to be given. For a non-SMTP ACL,
24480 &%defer%& is the same as &%deny%&, because there is no way of sending a
24481 temporary error. For a RCPT command, &%defer%& is much the same as using a
24482 &(redirect)& router and &`:defer:`& while verifying, but the &%defer%& verb can
24483 be used in any ACL, and even for a recipient it might be a simpler approach.
24484
24485
24486 .next
24487 .cindex "&%deny%&" "ACL verb"
24488 &%deny%&: If all the conditions are met, the ACL returns &"deny"&. If any of
24489 the conditions are not met, control is passed to the next ACL statement. For
24490 example,
24491 .code
24492 deny dnslists = blackholes.mail-abuse.org
24493 .endd
24494 rejects commands from hosts that are on a DNS black list.
24495
24496
24497 .next
24498 .new
24499 .cindex "&%discard%&" "ACL verb"
24500 &%discard%&: This verb behaves like &%accept%&, except that it returns
24501 &"discard"& from the ACL instead of &"accept"&. It is permitted only on ACLs
24502 that are concerned with receiving messages. When all the conditions are true,
24503 the sending entity receives a &"success"& response. However, &%discard%& causes
24504 recipients to be discarded. If it is used in an ACL for RCPT, just the one
24505 recipient is discarded; if used for MAIL, DATA or in the non-SMTP ACL, all the
24506 message's recipients are discarded. Recipients that are discarded before DATA
24507 do not appear in the log line when the &%log_recipients%& log selector is set.
24508
24509 If the &%log_message%& modifier is set when &%discard%& operates,
24510 its contents are added to the line that is automatically written to the log.
24511 The &%message%& modifier operates exactly as it does for &%accept%&.
24512 .wen
24513
24514
24515 .next
24516 .cindex "&%drop%&" "ACL verb"
24517 &%drop%&: This verb behaves like &%deny%&, except that an SMTP connection is
24518 forcibly closed after the 5&'xx'& error message has been sent. For example:
24519 .code
24520 drop   message   = I don't take more than 20 RCPTs
24521        condition = ${if > {$rcpt_count}{20}}
24522 .endd
24523 There is no difference between &%deny%& and &%drop%& for the connect-time ACL.
24524 The connection is always dropped after sending a 550 response.
24525
24526 .next
24527 .cindex "&%require%&" "ACL verb"
24528 &%require%&: If all the conditions are met, control is passed to the next ACL
24529 statement. If any of the conditions are not met, the ACL returns &"deny"&. For
24530 example, when checking a RCPT command,
24531 .code
24532 require verify = sender
24533 .endd
24534 passes control to subsequent statements only if the message's sender can be
24535 verified. Otherwise, it rejects the command.
24536
24537 .next
24538 .cindex "&%warn%&" "ACL verb"
24539 &%warn%&: If all the conditions are true, a line specified by the
24540 &%log_message%& modifier is written to Exim's main log. Control always passes
24541 to the next ACL statement. If any condition is false, the log line is not
24542 written. If an identical log line is requested several times in the same
24543 message, only one copy is actually written to the log. If you want to force
24544 duplicates to be written, use the &%logwrite%& modifier instead.
24545
24546 If &%log_message%& is not present, a &%warn%& verb just checks its conditions
24547 and obeys any &"immediate"& modifiers (such as &%control%&, &%set%&,
24548 &%logwrite%&, and &%add_header%&) that appear before the first failing
24549 condition. There is more about adding header lines in section
24550 &<<SECTaddheadacl>>&.
24551
24552 If any condition on a &%warn%& statement cannot be completed (that is, there is
24553 some sort of defer), the log line specified by &%log_message%& is not written.
24554 &new("This does not include the case of a forced failure from a lookup, which
24555 is considered to be a successful completion. After a defer,") no further
24556 conditions or modifiers in the &%warn%& statement are processed. The incident
24557 is logged, and the ACL continues to be processed, from the next statement
24558 onwards.
24559
24560
24561 .cindex "&$acl_verify_message$&"
24562 When one of the &%warn%& conditions is an address verification that fails, the
24563 text of the verification failure message is in &$acl_verify_message$&. If you
24564 want this logged, you must set it up explicitly. For example:
24565 .code
24566 warn   !verify = sender
24567        log_message = sender verify failed: $acl_verify_message
24568 .endd
24569 .endlist
24570
24571 At the end of each ACL there is an implicit unconditional &%deny%&.
24572
24573 As you can see from the examples above, the conditions and modifiers are
24574 written one to a line, with the first one on the same line as the verb, and
24575 subsequent ones on following lines. If you have a very long condition, you can
24576 continue it onto several physical lines by the usual backslash continuation
24577 mechanism. It is conventional to align the conditions vertically.
24578
24579
24580
24581 .section "ACL variables" "SECTaclvariables"
24582 .new
24583 .cindex "&ACL;" "variables"
24584 There are some special variables that can be set during ACL processing. They
24585 can be used to pass information between different ACLs, different invocations
24586 of the same ACL in the same SMTP connection, and between ACLs and the routers,
24587 transports, and filters that are used to deliver a message. The names of these
24588 variables must begin with &$acl_c$& or &$acl_m$&, followed either by a digit or
24589 an underscore, but the remainder of the name can be any sequence of
24590 alphanumeric characters and underscores that you choose. There is no limit on
24591 the number of ACL variables. The two sets act as follows:
24592 .ilist
24593 The values of those variables whose names begin with &$acl_c$& persist
24594 throughout an SMTP connection. They are never reset. Thus, a value that is set
24595 while receiving one message is still available when receiving the next message
24596 on the same SMTP connection.
24597 .next
24598 The values of those variables whose names beging with &$acl_m$& persist only
24599 while a message is being received. They are reset afterwards. They are also
24600 reset by MAIL, RSET, EHLO, HELO, and after starting up a TLS session.
24601 .endlist
24602
24603 When a message is accepted, the current values of all the ACL variables are
24604 preserved with the message and are subsequently made available at delivery
24605 time. The ACL variables are set by a modifier called &%set%&. For example:
24606 .code
24607 accept hosts = whatever
24608        set acl_m4 = some value
24609 accept authenticated = *
24610        set acl_c_auth = yes
24611 .endd
24612 &*Note*&: A leading dollar sign is not used when naming a variable that is to
24613 be set. If you want to set a variable without taking any action, you can use a
24614 &%warn%& verb without any other modifiers or conditions.
24615
24616 .oindex &%strict_acl_vars%&
24617 What happens if a syntactically valid but undefined ACL variable is
24618 referenced depends on the setting of the &%strict_acl_vars%& option. If it is
24619 false (the default), an empty string is substituted; if it is true, an
24620 error is generated.
24621
24622 Versions of Exim before 4.64 have a limited set of numbered variables, but
24623 their names are compatible, so there is no problem with upgrading.
24624 .wen
24625
24626
24627 .section "Condition and modifier processing"
24628 .cindex "&ACL;" "conditions; processing"
24629 .cindex "&ACL;" "modifiers; processing"
24630 An exclamation mark preceding a condition negates its result. For example:
24631 .code
24632 deny   domains = *.dom.example
24633       !verify  = recipient
24634 .endd
24635 causes the ACL to return &"deny"& if the recipient domain ends in
24636 &'dom.example'& and the recipient address cannot be verified. Sometimes
24637 negation can be used on the right-hand side of a condition. For example, these
24638 two statements are equivalent:
24639 .code
24640 deny  hosts = !192.168.3.4
24641 deny !hosts =  192.168.3.4
24642 .endd
24643 However, for many conditions (&%verify%& being a good example), only left-hand
24644 side negation of the whole condition is possible.
24645
24646 The arguments of conditions and modifiers are expanded. A forced failure
24647 of an expansion causes a condition to be ignored, that is, it behaves as if the
24648 condition is true. Consider these two statements:
24649 .code
24650 accept  senders = ${lookup{$host_name}lsearch\
24651                   {/some/file}{$value}fail}
24652 accept  senders = ${lookup{$host_name}lsearch\
24653                   {/some/file}{$value}{}}
24654 .endd
24655 Each attempts to look up a list of acceptable senders. If the lookup succeeds,
24656 the returned list is searched, but if the lookup fails the behaviour is
24657 different in the two cases. The &%fail%& in the first statement causes the
24658 condition to be ignored, leaving no further conditions. The &%accept%& verb
24659 therefore succeeds. The second statement, however, generates an empty list when
24660 the lookup fails. No sender can match an empty list, so the condition fails,
24661 and therefore the &%accept%& also fails.
24662
24663 ACL modifiers appear mixed in with conditions in ACL statements. Some of them
24664 specify actions that are taken as the conditions for a statement are checked;
24665 others specify text for messages that are used when access is denied or a
24666 warning is generated. The &%control%& modifier affects the way an incoming
24667 message is handled.
24668
24669 The positioning of the modifiers in an ACL statement important, because the
24670 processing of a verb ceases as soon as its outcome is known. Only those
24671 modifiers that have already been encountered will take effect. For example,
24672 consider this use of the &%message%& modifier:
24673 .code
24674 require message = Can't verify sender
24675         verify  = sender
24676         message = Can't verify recipient
24677         verify  = recipient
24678         message = This message cannot be used
24679 .endd
24680 If sender verification fails, Exim knows that the result of the statement is
24681 &"deny"&, so it goes no further. The first &%message%& modifier has been seen,
24682 so its text is used as the error message. If sender verification succeeds, but
24683 recipient verification fails, the second message is used. If recipient
24684 verification succeeds, the third message becomes &"current"&, but is never used
24685 because there are no more conditions to cause failure.
24686
24687 For the &%deny%& verb, on the other hand, it is always the last &%message%&
24688 modifier that is used, because all the conditions must be true for rejection to
24689 happen. Specifying more than one &%message%& modifier does not make sense, and
24690 the message can even be specified after all the conditions. For example:
24691 .code
24692 deny   hosts = ...
24693       !senders = *@my.domain.example
24694        message = Invalid sender from client host
24695 .endd
24696 The &"deny"& result does not happen until the end of the statement is reached,
24697 by which time Exim has set up the message.
24698
24699
24700
24701 .section "ACL modifiers" "SECTACLmodi"
24702 .cindex "&ACL;" "modifiers; list of"
24703 The ACL modifiers are as follows:
24704
24705 .vlist
24706 .vitem &*add_header*&&~=&~<&'text'&>
24707 This modifier specifies one or more header lines that are to be added to an
24708 incoming message, assuming, of course, that the message is ultimately
24709 accepted. For details, see section &<<SECTaddheadacl>>&.
24710
24711 .vitem &*control*&&~=&~<&'text'&>
24712 .cindex "&%control%&" "ACL modifier"
24713 This modifier affects the subsequent processing of the SMTP connection or of an
24714 incoming message that is accepted. The effect of the first type of control
24715 lasts for the duration of the connection, whereas the effect of the second type
24716 lasts only until the current message has been received. The message-specific
24717 controls always apply to the whole message, not to individual recipients,
24718 even if the &%control%& modifier appears in a RCPT ACL.
24719
24720 As there are now quite a few controls that can be applied, they are described
24721 separately in section &<<SECTcontrols>>&. The &%control%& modifier can be used
24722 in several different ways. For example:
24723
24724 . ==== As this is a nested list, any displays it contains must be indented
24725 . ==== as otherwise they are too far to the left.
24726
24727 .ilist
24728 It can be at the end of an &%accept%& statement:
24729 .code
24730     accept  ...some conditions
24731             control = queue_only
24732 .endd
24733 In this case, the control is applied when this statement yields &"accept"&, in
24734 other words, when the conditions are all true.
24735
24736 .next
24737 It can be in the middle of an &%accept%& statement:
24738 .code
24739     accept  ...some conditions...
24740             control = queue_only
24741             ...some more conditions...
24742 .endd
24743 If the first set of conditions are true, the control is applied, even if the
24744 statement does not accept because one of the second set of conditions is false.
24745 In this case, some subsequent statement must yield &"accept"& for the control
24746 to be relevant.
24747
24748 .next
24749 It can be used with &%warn%& to apply the control, leaving the
24750 decision about accepting or denying to a subsequent verb. For
24751 example:
24752 .code
24753     warn    ...some conditions...
24754             control = freeze
24755     accept  ...
24756 .endd
24757 This example of &%warn%& does not contain &%message%&, &%log_message%&, or
24758 &%logwrite%&, so it does not add anything to the message and does not write a
24759 log entry.
24760
24761 .next
24762 If you want to apply a control unconditionally, you can use it with a
24763 &%require%& verb. For example:
24764 .code
24765     require  control = no_multiline_response
24766 .endd
24767 .endlist
24768
24769 .vitem &*delay*&&~=&~<&'time'&>
24770 .cindex "&%delay%&" "ACL modifier"
24771 .cindex "&%-bh%& option"
24772 This modifier causes Exim to wait for the time interval before proceeding. The
24773 time is given in the usual Exim notation. This modifier may appear in any ACL.
24774 The delay happens as soon as the modifier is processed. However, when testing
24775 Exim using the &%-bh%& option, the delay is not actually imposed (an
24776 appropriate message is output instead).
24777
24778 Like &%control%&, &%delay%& can be used with &%accept%& or &%deny%&, for
24779 example:
24780 .code
24781 deny    ...some conditions...
24782         delay = 30s
24783 .endd
24784 The delay happens if all the conditions are true, before the statement returns
24785 &"deny"&. Compare this with:
24786 .code
24787 deny    delay = 30s
24788         ...some conditions...
24789 .endd
24790 which waits for 30s before processing the conditions. The &%delay%& modifier
24791 can also be used with &%warn%& and together with &%control%&:
24792 .code
24793 warn    ...some conditions...
24794         delay = 2m
24795         control = freeze
24796 accept  ...
24797 .endd
24798
24799 .new
24800 .vitem &*endpass*&
24801 .cindex "&%endpass%&" "ACL modifier"
24802 This modifier, which has no argument, is recognized only in &%accept%& and
24803 &%discard%& statements. It marks the boundary between the conditions whose
24804 failure causes control to pass to the next statement, and the conditions whose
24805 failure causes the ACL to return &"deny"&. This concept has proved to be
24806 confusing to some people, so the use of &%endpass%& is no longer recommended as
24807 &"best practice"&. See the description of &%accept%& above for more details.
24808 .wen
24809
24810
24811 .vitem &*log_message*&&~=&~<&'text'&>
24812 .cindex "&%log_message%&" "ACL modifier"
24813 This modifier sets up a message that is used as part of the log message if the
24814 ACL denies access or a &%warn%& statement's conditions are true. For example:
24815 .code
24816 require log_message = wrong cipher suite $tls_cipher
24817         encrypted   = DES-CBC3-SHA
24818 .endd
24819 .new
24820 &%log_message%& is also used when recipients are discarded by &%discard%&. For
24821 example:
24822 .display
24823 &`discard `&<&'some conditions'&>
24824 &`        log_message = Discarded $local_part@$domain because...`&
24825 .endd
24826 When access is denied, &%log_message%& adds to any underlying error message
24827 that may exist because of a condition failure. For example, while verifying a
24828 recipient address, a &':fail:'& redirection might have already set up a
24829 message.
24830
24831 The message may be defined before the conditions to which it applies, because
24832 the string expansion does not happen until Exim decides that access is to be
24833 denied. This means that any variables that are set by the condition are
24834 available for inclusion in the message. For example, the &$dnslist_$&<&'xxx'&>
24835 variables are set after a DNS black list lookup succeeds. If the expansion of
24836 &%log_message%& fails, or if the result is an empty string, the modifier is
24837 ignored.
24838 .wen
24839
24840 .cindex "&$acl_verify_message$&"
24841 If you want to use a &%warn%& statement to log the result of an address
24842 verification, you can use &$acl_verify_message$& to include the verification
24843 error message.
24844
24845 If &%log_message%& is used with a &%warn%& statement, &"Warning:"& is added to
24846 the start of the logged message. If the same warning log message is requested
24847 more than once while receiving  a single email message, only one copy is
24848 actually logged. If you want to log multiple copies, use &%logwrite%& instead
24849 of &%log_message%&. In the absence of &%log_message%& and &%logwrite%&, nothing
24850 is logged for a succesful &%warn%& statement.
24851
24852 If &%log_message%& is not present and there is no underlying error message (for
24853 example, from the failure of address verification), but &%message%& is present,
24854 the &%message%& text is used for logging rejections. However, if any text for
24855 logging contains newlines, only the first line is logged. In the absence of
24856 both &%log_message%& and &%message%&, a default built-in message is used for
24857 logging rejections.
24858
24859
24860 .new
24861 .vitem "&*log_reject_target*&&~=&~<&'log name list'&>"
24862 .cindex "&%log_reject_target%&" "ACL modifier"
24863 .cindex "logging in ACL" "specifying which log"
24864 This modifier makes it possible to specify which logs are used for messages
24865 about ACL rejections. Its argument is a colon-separated list of words that can
24866 be &"main"&, &"reject"&, or &"panic"&. The default is &`main:reject`&. The list
24867 may be empty, in which case a rejection is not logged at all. For example, this
24868 ACL fragment writes no logging information when access is denied:
24869 .display
24870 &`deny `&<&'some conditions'&>
24871 &`     log_reject_target =`&
24872 .endd
24873 This modifier can be used in SMTP and non-SMTP ACLs. It applies to both
24874 permanent and temporary rejections.
24875 .wen
24876
24877
24878 .vitem &*logwrite*&&~=&~<&'text'&>
24879 .cindex "&%logwrite%&" "ACL modifier"
24880 .cindex "logging in ACL" "immediate"
24881 This modifier writes a message to a log file as soon as it is encountered when
24882 processing an ACL. (Compare &%log_message%&, which, except in the case of
24883 &%warn%& &new("and &%discard%&"), is used only if the ACL statement denies
24884 access.) The &%logwrite%& modifier can be used to log special incidents in
24885 ACLs. For example:
24886 .display
24887 &`accept `&<&'some special conditions'&>
24888 &`       control  = freeze`&
24889 &`       logwrite = froze message because ...`&
24890 .endd
24891 By default, the message is written to the main log. However, it may begin
24892 with a colon, followed by a comma-separated list of log names, and then
24893 another colon, to specify exactly which logs are to be written. For
24894 example:
24895 .code
24896 logwrite = :main,reject: text for main and reject logs
24897 logwrite = :panic: text for panic log only
24898 .endd
24899
24900
24901 .vitem &*message*&&~=&~<&'text'&>
24902 .new
24903 .cindex "&%message%&" "ACL modifier"
24904 This modifier sets up a text string that is expanded and used as a response
24905 message when an ACL statement terminates the ACL with an &"accept"&, &"deny"&,
24906 or &"defer"& response. (In the case of the &%accept%& and &%discard%& verbs,
24907 there is some complication if &%endpass%& is involved; see the description of
24908 &%accept%& for details.)
24909
24910 The expansion of the message happens at the time Exim decides that the ACL is
24911 to end, not at the time it processes &%message%&. If the expansion fails, or
24912 generates an empty string, the modifier is ignored. Here is an example where
24913 &%message%& must be specified first, because the ACL ends with a rejection if
24914 the &%hosts%& condition fails:
24915 .code
24916 require  message = Host not recognized
24917          hosts = 10.0.0.0/8
24918 .endd
24919 (Once a condition has failed, no further conditions or modifiers are
24920 processed.)
24921
24922 .cindex "SMTP" "error codes"
24923 .cindex "&%smtp_banner%&
24924 For ACLs that are triggered by SMTP commands, the message is returned as part
24925 of the SMTP response. The use of &%message%& with &%accept%& (or &%discard%&)
24926 is meaningful only for SMTP, as no message is returned when a non-SMTP message
24927 is accepted. In the case of the connect ACL, accepting with a message modifier
24928 overrides the value of &%smtp_banner%&. For the EHLO/HELO ACL, a customized
24929 accept message may not contain more than one line (otherwise it will be
24930 truncated at the first newline and a panic logged), and it cannot affect the
24931 EHLO options.
24932
24933 When SMTP is involved, the message may begin with an overriding response code,
24934 consisting of three digits optionally followed by an &"extended response code"&
24935 of the form &'n.n.n'&, each code being followed by a space. For example:
24936 .code
24937 deny  message = 599 1.2.3 Host not welcome
24938       hosts = 192.168.34.0/24
24939 .endd
24940 The first digit of the supplied response code must be the same as would be sent
24941 by default. A panic occurs if it is not. Exim uses a 550 code when it denies
24942 access, but for the predata ACL, note that the default success code is 354, not
24943 2&'xx'&.
24944
24945 Notwithstanding the previous paragraph, for the QUIT ACL, unlike the others,
24946 the message modifier cannot override the 221 response code.
24947
24948 The text in a &%message%& modifier is literal; any quotes are taken as
24949 literals, but because the string is expanded, backslash escapes are processed
24950 anyway. If the message contains newlines, this gives rise to a multi-line SMTP
24951 response.
24952 .wen
24953
24954 .cindex "&$acl_verify_message$&"
24955 If &%message%& is used on a statement that verifies an address, the message
24956 specified overrides any message that is generated by the verification process.
24957 However, the original message is available in the variable
24958 &$acl_verify_message$&, so you can incorporate it into your message if you
24959 wish. In particular, if you want the text from &%:fail:%& items in &(redirect)&
24960 routers to be passed back as part of the SMTP response, you should either not
24961 use a &%message%& modifier, or make use of &$acl_verify_message$&.
24962
24963 For compatibility with previous releases of Exim, a &%message%& modifier that
24964 is used with a &%warn%& verb behaves in a similar way to the &%add_header%&
24965 modifier, but this usage is now deprecated. However, &%message%& acts only when
24966 all the conditions are true, wherever it appears in an ACL command, whereas
24967 &%add_header%& acts as soon as it is encountered. If &%message%& is used with
24968 &%warn%& in an ACL that is not concerned with receiving a message, it has no
24969 effect.
24970
24971
24972 .vitem &*set*&&~<&'acl_name'&>&~=&~<&'value'&>
24973 .cindex "&%set%&" "ACL modifier"
24974 This modifier puts a value into one of the ACL variables (see section
24975 &<<SECTaclvariables>>&).
24976 .endlist
24977
24978
24979
24980
24981
24982 .section "Use of the control modifier" "SECTcontrols"
24983 .cindex "&%control%&" "ACL modifier"
24984 The &%control%& modifier supports the following settings:
24985
24986 .vlist
24987 .vitem &*control&~=&~allow_auth_unadvertised*&
24988 This modifier allows a client host to use the SMTP AUTH command even when it
24989 has not been advertised in response to EHLO. Furthermore, because there are
24990 apparently some really broken clients that do this, Exim will accept AUTH after
24991 HELO (rather than EHLO) when this control is set. It should be used only if you
24992 really need it, and you should limit its use to those broken clients that do
24993 not work without it. For example:
24994 .code
24995 warn hosts   = 192.168.34.25
24996      control = allow_auth_unadvertised
24997 .endd
24998 Normally, when an Exim server receives an AUTH command, it checks the name of
24999 the authentication mechanism that is given in the command to ensure that it
25000 matches an advertised mechanism. When this control is set, the check that a
25001 mechanism has been advertised is bypassed. Any configured mechanism can be used
25002 by the client. This control is permitted only in the connection and HELO ACLs.
25003
25004
25005 .vitem &*control&~=&~caseful_local_part*&
25006 See below.
25007
25008 .vitem &*control&~=&~caselower_local_part*&
25009 .cindex "&ACL;" "case of local part in"
25010 .cindex "case of local parts"
25011 .cindex "&$local_part$&"
25012 These two controls are permitted only in the ACL specified by &%acl_smtp_rcpt%&
25013 (that is, during RCPT processing). By default, the contents of &$local_part$&
25014 are lower cased before ACL processing. If &"caseful_local_part"& is specified,
25015 any uppercase letters in the original local part are restored in &$local_part$&
25016 for the rest of the ACL, or until a control that sets &"caselower_local_part"&
25017 is encountered.
25018
25019 These controls affect only the current recipient. Moreover, they apply only to
25020 local part handling that takes place directly in the ACL (for example, as a key
25021 in lookups). If a test to verify the recipient is obeyed, the case-related
25022 handling of the local part during the verification is controlled by the router
25023 configuration (see the &%caseful_local_part%& generic router option).
25024
25025 This facility could be used, for example, to add a spam score to local parts
25026 containing upper case letters. For example, using &$acl_m4$& to accumulate the
25027 spam score:
25028 .code
25029 warn  control = caseful_local_part
25030       set acl_m4 = ${eval:\
25031                      $acl_m4 + \
25032                      ${if match{$local_part}{[A-Z]}{1}{0}}\
25033                     }
25034       control = caselower_local_part
25035 .endd
25036 Notice that we put back the lower cased version afterwards, assuming that
25037 is what is wanted for subsequent tests.
25038
25039 .vitem &*control&~=&~enforce_sync*&
25040 See below.
25041
25042 .vitem &*control&~=&~no_enforce_sync*&
25043 .cindex "SMTP" "synchronization checking"
25044 .cindex "synchronization checking in SMTP"
25045 These controls make it possible to be selective about when SMTP synchronization
25046 is enforced. The global option &%smtp_enforce_sync%& specifies the initial
25047 state of the switch (it is true by default). See the description of this option
25048 in chapter &<<CHAPmainconfig>>& for details of SMTP synchronization checking.
25049
25050 The effect of these two controls lasts for the remainder of the SMTP
25051 connection. They can appear in any ACL except the one for the non-SMTP
25052 messages. The most straightforward place to put them is in the ACL defined by
25053 &%acl_smtp_connect%&, which is run at the start of an incoming SMTP connection,
25054 before the first synchronization check. The expected use is to turn off the
25055 synchronization checks for badly-behaved hosts that you nevertheless need to
25056 work with.
25057
25058
25059 .vitem &*control&~=&~fakedefer/*&<&'message'&>
25060 .cindex "fake defer"
25061 .cindex "defer" "fake"
25062 This control works in exactly the same way as &%fakereject%& (described below)
25063 except that it causes an SMTP 450 response after the message data instead of a
25064 550 response. You must take care when using &%fakedefer%& because it causes the
25065 messages to be duplicated when the sender retries. Therefore, you should not
25066 use &%fakedefer%& if the message is to be delivered normally.
25067
25068 .vitem &*control&~=&~fakereject/*&<&'message'&>
25069 .cindex "fake rejection"
25070 .cindex "rejection" "fake"
25071 This control is permitted only for the MAIL, RCPT, and DATA ACLs, in other
25072 words, only when an SMTP message is being received. If Exim accepts the
25073 message, instead the final 250 response, a 550 rejection message is sent.
25074 However, Exim proceeds to deliver the message as normal. The control applies
25075 only to the current message, not to any subsequent ones that may be received in
25076 the same SMTP connection.
25077
25078 The text for the 550 response is taken from the &%control%& modifier. If no
25079 message is supplied, the following is used:
25080 .code
25081 550-Your message has been rejected but is being
25082 550-kept for evaluation.
25083 550-If it was a legitimate message, it may still be
25084 550 delivered to the target recipient(s).
25085 .endd
25086 This facilty should be used with extreme caution.
25087
25088 .vitem &*control&~=&~freeze*&
25089 .cindex "frozen messages" "forcing in ACL"
25090 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs, in
25091 other words, only when a message is being received. If the message is accepted,
25092 it is placed on Exim's queue and frozen. The control applies only to the
25093 current message, not to any subsequent ones that may be received in the same
25094 SMTP connection.
25095
25096 This modifier can optionally be followed by &`/no_tell`&. If the global option
25097 &%freeze_tell%& is set, it is ignored for the current message (that is, nobody
25098 is told about the freezing), provided all the &*control=freeze*& modifiers that
25099 are obeyed for the current message have the &`/no_tell`& option.
25100
25101
25102 .vitem &*control&~=&~no_mbox_unspool*&
25103 This control is available when Exim is compiled with the content scanning
25104 extension. Content scanning may require a copy of the current message, or parts
25105 of it, to be written in &"mbox format"& to a spool file, for passing to a virus
25106 or spam scanner. Normally, such copies are deleted when they are no longer
25107 needed. If this control is set, the copies are not deleted. The control applies
25108 only to the current message, not to any subsequent ones that may be received in
25109 the same SMTP connection. It is provided for debugging purposes and is unlikely
25110 to be useful in production.
25111
25112 .vitem &*control&~=&~no_multiline_response*&
25113 .cindex "multiline responses" "suppressing"
25114 This control is permitted for any ACL except the one for non-SMTP messages.
25115 It seems that there are broken clients in use that cannot handle multiline
25116 SMTP responses, despite the fact that RFC 821 defined them over 20 years ago.
25117
25118 If this control is set, multiline SMTP responses from ACL rejections are
25119 suppressed. One way of doing this would have been to put out these responses as
25120 one long line. However, RFC 2821 specifies a maximum of 512 bytes per response
25121 (&"use multiline responses for more"& it says &-- ha!), and some of the
25122 responses might get close to that. So this facility, which is after all only a
25123 sop to broken clients, is implemented by doing two very easy things:
25124
25125 .ilist
25126 Extra information that is normally output as part of a rejection caused by
25127 sender verification failure is omitted. Only the final line (typically &"sender
25128 verification failed"&) is sent.
25129 .next
25130 If a &%message%& modifier supplies a multiline response, only the first
25131 line is output.
25132 .endlist
25133
25134 The setting of the switch can, of course, be made conditional on the
25135 calling host. Its effect lasts until the end of the SMTP connection.
25136
25137 .vitem &*control&~=&~queue_only*&
25138 .cindex "&%queue_only%&"
25139 .cindex "queueing incoming messages"
25140 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs, in
25141 other words, only when a message is being received. If the message is accepted,
25142 it is placed on Exim's queue and left there for delivery by a subsequent queue
25143 runner. No immediate delivery process is started. In other words, it has the
25144 effect as the &%queue_only%& global option. However, the control applies only
25145 to the current message, not to any subsequent ones that may be received in the
25146 same SMTP connection.
25147
25148 .vitem &*control&~=&~submission/*&<&'options'&>
25149 .cindex "message" "submission"
25150 .cindex "submission mode"
25151 This control is permitted only for the MAIL, RCPT, and start of data ACLs (the
25152 latter is the one defined by &%acl_smtp_predata%&). Setting it tells Exim that
25153 the current message is a submission from a local MUA. In this case, Exim
25154 operates in &"submission mode"&, and applies certain fixups to the message if
25155 necessary. For example, it add a &'Date:'& header line if one is not present.
25156 This control is not permitted in the &%acl_smtp_data%& ACL, because that is too
25157 late (the message has already been created).
25158
25159 Chapter &<<CHAPmsgproc>>& describes the processing that Exim applies to
25160 messages. Section &<<SECTsubmodnon>>& covers the processing that happens in
25161 submission mode; the available options for this control are described there.
25162 The control applies only to the current message, not to any subsequent ones
25163 that may be received in the same SMTP connection.
25164
25165 .vitem &*control&~=&~suppress_local_fixups*&
25166 .cindex "submission fixups" "suppressing"
25167 This control applies to locally submitted (non TCP/IP) messages, and is the
25168 complement of &`control`& &`=`& &`submission`&. It disables the fixups that are
25169 normally applied to locally-submitted messages. Specifically:
25170
25171 .ilist
25172 Any &'Sender:'& header line is left alone (in this respect, it is a
25173 dynamic version of &%local_sender_retain%&).
25174 .next
25175 No &'Message-ID:'&, &'From:'&, or &'Date:'& header lines are added.
25176 .next
25177 There is no check that &'From:'& corresponds to the actual sender.
25178 .endlist ilist
25179
25180 This control may be useful when a remotely-originated message is accepted,
25181 passed to some scanning program, and then re-submitted for delivery. It can be
25182 used only in the &%acl_smtp_mail%&, &%acl_smtp_rcpt%&, &%acl_smtp_predata%&,
25183 and &%acl_not_smtp_start%& ACLs, because it has to be set before the message's
25184 data is read.
25185 .endlist vlist
25186
25187 All four possibilities for message fixups can be specified:
25188
25189 .ilist
25190 Locally submitted, fixups applied: the default.
25191 .next
25192 Locally submitted, no fixups applied: use &`control`& &`=`&
25193 &`suppress_local_fixups`&.
25194 .next
25195 Remotely submitted, no fixups applied: the default.
25196 .next
25197 Remotely submitted, fixups applied: use &`control`& &`=`& &`submission`&.
25198 .endlist
25199
25200
25201
25202 .section "Adding header lines in ACLs" "SECTaddheadacl"
25203 .cindex "header lines" "adding in an ACL"
25204 .cindex "header lines" "position of added lines"
25205 .cindex "&%message%&" "ACL modifier"
25206 The &%add_header%& modifier can be used to add one or more extra header lines
25207 to an incoming message, as in this example:
25208 .code
25209 warn dnslists = sbl.spamhaus.org : \
25210                 dialup.mail-abuse.org
25211      add_header = X-blacklisted-at: $dnslist_domain
25212 .endd
25213 The &%add_header%& modifier is permitted in the MAIL, RCPT, PREDATA, DATA,
25214 MIME, and non-SMTP ACLs (in other words, those that are concerned with
25215 receiving a message). The message must ultimately be accepted for
25216 &%add_header%& to have any significant effect. You can use &%add_header%& with
25217 any ACL verb, including &%deny%& (though this is potentially useful only in a
25218 RCPT ACL).
25219
25220 If the data for the &%add_header%& modifier contains one or more newlines that
25221 are not followed by a space or a tab, it is assumed to contain multiple header
25222 lines. Each one is checked for valid syntax; &`X-ACL-Warn:`& is added to the
25223 front of any line that is not a valid header line.
25224
25225 Added header lines are accumulated during the MAIL, RCPT, and predata ACLs.
25226 They are added to the message before processing the DATA and MIME ACLs.
25227 However, if an identical header line is requested more than once, only one copy
25228 is actually added to the message. Further header lines may be accumulated
25229 during the DATA and MIME ACLs, after which they are added to the message, again
25230 with duplicates suppressed. Thus, it is possible to add two identical header
25231 lines to an SMTP message, but only if one is added before DATA and one after.
25232 In the case of non-SMTP messages, new headers are accumulated during the
25233 non-SMTP ACLs, and are added to the message after all the ACLs have run. If a
25234 message is rejected after DATA or by the non-SMTP ACL, all added header lines
25235 are included in the entry that is written to the reject log.
25236
25237 .cindex "header lines" "added; visibility of"
25238 Header lines are not visible in string expansions until they are added to the
25239 message. It follows that header lines defined in the MAIL, RCPT, and predata
25240 ACLs are not visible until the DATA ACL and MIME ACLs are run. Similarly,
25241 header lines that are added by the DATA or MIME ACLs are not visible in those
25242 ACLs. Because of this restriction, you cannot use header lines as a way of
25243 passing data between (for example) the MAIL and RCPT ACLs. If you want to do
25244 this, you can use ACL variables, as described in section
25245 &<<SECTaclvariables>>&.
25246
25247 The &%add_header%& modifier acts immediately it is encountered during the
25248 processing of an ACL. Notice the difference between these two cases:
25249 .display
25250 &`accept add_header = ADDED: some text`&
25251 &`       `&<&'some condition'&>
25252
25253 &`accept `&<&'some condition'&>
25254 &`       add_header = ADDED: some text`&
25255 .endd
25256 In the first case, the header line is always added, whether or not the
25257 condition is true. In the second case, the header line is added only if the
25258 condition is true. Multiple occurrences of &%add_header%& may occur in the same
25259 ACL statement. All those that are encountered before a condition fails are
25260 honoured.
25261
25262 .cindex "&%warn%&" "ACL verb"
25263 For compatibility with previous versions of Exim, a &%message%& modifier for a
25264 &%warn%& verb acts in the same way as &%add_header%&, except that it takes
25265 effect only if all the conditions are true, even if it appears before some of
25266 them. Furthermore, only the last occurrence of &%message%& is honoured. This
25267 usage of &%message%& is now deprecated. If both &%add_header%& and &%message%&
25268 are present on a &%warn%& verb, both are processed according to their
25269 specifications.
25270
25271 By default, new header lines are added to a message at the end of the existing
25272 header lines. However, you can specify that any particular header line should
25273 be added right at the start (before all the &'Received:'& lines), immediately
25274 after the first block of &'Received:'& lines, or immediately before any line
25275 that is not a &'Received:'& or &'Resent-something:'& header.
25276
25277 This is done by specifying &":at_start:"&, &":after_received:"&, or
25278 &":at_start_rfc:"& (or, for completeness, &":at_end:"&) before the text of the
25279 header line, respectively. (Header text cannot start with a colon, as there has
25280 to be a header name first.) For example:
25281 .code
25282 warn add_header = \
25283        :after_received:X-My-Header: something or other...
25284 .endd
25285 If more than one header line is supplied in a single &%add_header%& modifier,
25286 each one is treated independently and can therefore be placed differently. If
25287 you add more than one line at the start, or after the Received: block, they end
25288 up in reverse order.
25289
25290 &*Warning*&: This facility currently applies only to header lines that are
25291 added in an ACL. It does NOT work for header lines that are added in a
25292 system filter or in a router or transport.
25293
25294
25295
25296
25297 .section "ACL conditions" "SECTaclconditions"
25298 .cindex "&ACL;" "conditions; list of"
25299 Some of conditions listed in this section are available only when Exim is
25300 compiled with the content-scanning extension. They are included here briefly
25301 for completeness. More detailed descriptions can be found in the discussion on
25302 content scanning in chapter &<<CHAPexiscan>>&.
25303
25304 Not all conditions are relevant in all circumstances. For example, testing
25305 senders and recipients does not make sense in an ACL that is being run as the
25306 result of the arrival of an ETRN command, and checks on message headers can be
25307 done only in the ACLs specified by &%acl_smtp_data%& and &%acl_not_smtp%&. You
25308 can use the same condition (with different parameters) more than once in the
25309 same ACL statement. This provides a way of specifying an &"and"& conjunction.
25310 The conditions are as follows:
25311
25312
25313 .vlist
25314 .vitem &*acl&~=&~*&<&'name&~of&~acl&~or&~ACL&~string&~or&~file&~name&~'&>
25315 .cindex "&ACL;" "nested"
25316 .cindex "&ACL;" "indirect"
25317 .cindex "&%acl%&" "ACL condition"
25318 The possible values of the argument are the same as for the
25319 &%acl_smtp_%&&'xxx'& options. The named or inline ACL is run. If it returns
25320 &"accept"& the condition is true; if it returns &"deny"& the condition is
25321 false. If it returns &"defer"&, the current ACL returns &"defer"& unless the
25322 condition is on a &%warn%& verb. In that case, a &"defer"& return makes the
25323 condition false. This means that further processing of the &%warn%& verb
25324 ceases, but processing of the ACL continues.
25325
25326 If the nested &%acl%& returns &"drop"& and the outer condition denies access,
25327 the connection is dropped. If it returns &"discard"&, the verb must be
25328 &%accept%& or &%discard%&, and the action is taken immediately &-- no further
25329 conditions are tested.
25330
25331 ACLs may be nested up to 20 deep; the limit exists purely to catch runaway
25332 loops. This condition allows you to use different ACLs in different
25333 circumstances. For example, different ACLs can be used to handle RCPT commands
25334 for different local users or different local domains.
25335
25336 .vitem &*authenticated&~=&~*&<&'string&~list'&>
25337 .cindex "&%authenticated%&" "ACL condition"
25338 .cindex "authentication" "ACL checking"
25339 .cindex "&ACL;" "testing for authentication"
25340 If the SMTP connection is not authenticated, the condition is false. Otherwise,
25341 the name of the authenticator is tested against the list. To test for
25342 authentication by any authenticator, you can set
25343 .code
25344 authenticated = *
25345 .endd
25346
25347 .vitem &*condition&~=&~*&<&'string'&>
25348 .cindex "&%condition%&" "ACL condition"
25349 .cindex "customizing" "ACL condition"
25350 .cindex "&ACL;" "customized test"
25351 .cindex "&ACL;" "testing; customized"
25352 This feature allows you to make up custom conditions. If the result of
25353 expanding the string is an empty string, the number zero, or one of the strings
25354 &"no"& or &"false"&, the condition is false. If the result is any non-zero
25355 number, or one of the strings &"yes"& or &"true"&, the condition is true. For
25356 any other value, some error is assumed to have occurred, and the ACL returns
25357 &"defer"&. However, if the expansion is forced to fail, the condition is
25358 ignored. The effect is to treat it as true, whether it is positive or
25359 negative.
25360
25361 .vitem &*decode&~=&~*&<&'location'&>
25362 .cindex "&%decode%&" "ACL condition"
25363 This condition is available only when Exim is compiled with the
25364 content-scanning extension, and it is allowed only in the ACL defined by
25365 &%acl_smtp_mime%&. It causes the current MIME part to be decoded into a file.
25366 For details, see chapter &<<CHAPexiscan>>&.
25367
25368 .vitem &*demime&~=&~*&<&'extension&~list'&>
25369 .cindex "&%demime%&" "ACL condition"
25370 This condition is available only when Exim is compiled with the
25371 content-scanning extension. Its use is described in section
25372 &<<SECTdemimecond>>&.
25373
25374 .vitem &*dnslists&~=&~*&<&'list&~of&~domain&~names&~and&~other&~data'&>
25375 .cindex "&%dnslists%&" "ACL condition"
25376 .cindex "DNS list" "in ACL"
25377 .cindex "black list (DNS)"
25378 .cindex "&ACL;" "testing a DNS list"
25379 This condition checks for entries in DNS black lists. These are also known as
25380 &"RBL lists"&, after the original Realtime Blackhole List, but note that the
25381 use of the lists at &'mail-abuse.org'& now carries a charge. There are too many
25382 different variants of this condition to describe briefly here. See sections
25383 &<<SECTmorednslists>>&--&<<SECTmorednslistslast>>& for details.
25384
25385 .vitem &*domains&~=&~*&<&'domain&~list'&>
25386 .cindex "&%domains%&" "ACL condition"
25387 .cindex "domain" "ACL checking"
25388 .cindex "&ACL;" "testing a recipient domain"
25389 .cindex "&$domain_data$&"
25390 This condition is relevant only after a RCPT command. It checks that the domain
25391 of the recipient address is in the domain list. If percent-hack processing is
25392 enabled, it is done before this test is done. If the check succeeds with a
25393 lookup, the result of the lookup is placed in &$domain_data$& until the next
25394 &%domains%& test.
25395
25396 .new
25397 &*Note carefully*& (because many people seem to fall foul of this): you cannot
25398 use &%domains%& in a DATA ACL.
25399 .wen
25400
25401
25402 .vitem &*encrypted&~=&~*&<&'string&~list'&>
25403 .cindex "&%encrypted%&" "ACL condition"
25404 .cindex "encryption" "checking in an ACL"
25405 .cindex "&ACL;" "testing for encryption"
25406 If the SMTP connection is not encrypted, the condition is false. Otherwise, the
25407 name of the cipher suite in use is tested against the list. To test for
25408 encryption without testing for any specific cipher suite(s), set
25409 .code
25410 encrypted = *
25411 .endd
25412
25413
25414 .vitem &*hosts&~=&~*&<&'&~host&~list'&>
25415 .cindex "&%hosts%&" "ACL condition"
25416 .cindex "host" "ACL checking"
25417 .cindex "&ACL;" "testing the client host"
25418 This condition tests that the calling host matches the host list. If you have
25419 name lookups or wildcarded host names and IP addresses in the same host list,
25420 you should normally put the IP addresses first. For example, you could have:
25421 .code
25422 accept hosts = 10.9.8.7 : dbm;/etc/friendly/hosts
25423 .endd
25424 .new
25425 The lookup in this example uses the host name for its key. This is implied by
25426 the lookup type &"dbm"&. (For a host address lookup you would use &"net-dbm"&
25427 and it wouldn't matter which way round you had these two items.)
25428 .wen
25429
25430 The reason for the problem with host names lies in the left-to-right way that
25431 Exim processes lists. It can test IP addresses without doing any DNS lookups,
25432 but when it reaches an item that requires a host name, it fails if it cannot
25433 find a host name to compare with the pattern. If the above list is given in the
25434 opposite order, the &%accept%& statement fails for a host whose name cannot be
25435 found, even if its IP address is 10.9.8.7.
25436
25437 If you really do want to do the name check first, and still recognize the IP
25438 address even if the name lookup fails, you can rewrite the ACL like this:
25439 .code
25440 accept hosts = dbm;/etc/friendly/hosts
25441 accept hosts = 10.9.8.7
25442 .endd
25443 The default action on failing to find the host name is to assume that the host
25444 is not in the list, so the first &%accept%& statement fails. The second
25445 statement can then check the IP address.
25446
25447 .cindex "&$host_data$&"
25448 If a &%hosts%& condition is satisfied by means of a lookup, the result
25449 of the lookup is made available in the &$host_data$& variable. This
25450 allows you, for example, to set up a statement like this:
25451 .code
25452 deny  hosts = net-lsearch;/some/file
25453 message = $host_data
25454 .endd
25455 which gives a custom error message for each denied host.
25456
25457 .vitem &*local_parts&~=&~*&<&'local&~part&~list'&>
25458 .cindex "&%local_parts%&" "ACL condition"
25459 .cindex "local part" "ACL checking"
25460 .cindex "&ACL;" "testing a local part"
25461 .cindex "&$local_part_data$&"
25462 This condition is relevant only after a RCPT command. It checks that the local
25463 part of the recipient address is in the list. If percent-hack processing is
25464 enabled, it is done before this test. If the check succeeds with a lookup, the
25465 result of the lookup is placed in &$local_part_data$&, which remains set until
25466 the next &%local_parts%& test.
25467
25468 .vitem &*malware&~=&~*&<&'option'&>
25469 .cindex "&%malware%&" "ACL condition"
25470 .cindex "&ACL;" "virus scanning"
25471 .cindex "&ACL;" "scanning for viruses"
25472 This condition is available only when Exim is compiled with the
25473 content-scanning extension. It causes the incoming message to be scanned for
25474 viruses. For details, see chapter &<<CHAPexiscan>>&.
25475
25476 .vitem &*mime_regex&~=&~*&<&'list&~of&~regular&~expressions'&>
25477 .cindex "&%mime_regex%&" "ACL condition"
25478 .cindex "&ACL;" "testing by regex matching"
25479 This condition is available only when Exim is compiled with the
25480 content-scanning extension, and it is allowed only in the ACL defined by
25481 &%acl_smtp_mime%&. It causes the current MIME part to be scanned for a match
25482 with any of the regular expressions. For details, see chapter
25483 &<<CHAPexiscan>>&.
25484
25485 .vitem &*ratelimit&~=&~*&<&'parameters'&>
25486 .cindex "rate limiting"
25487 This condition can be used to limit the rate at which a user or host submits
25488 messages. Details are given in section &<<SECTratelimiting>>&.
25489
25490 .vitem &*recipients&~=&~*&<&'address&~list'&>
25491 .cindex "&%recipients%&" "ACL condition"
25492 .cindex "recipient" "ACL checking"
25493 .cindex "&ACL;" "testing a recipient"
25494 This condition is relevant only after a RCPT command. It checks the entire
25495 recipient address against a list of recipients.
25496
25497 .vitem &*regex&~=&~*&<&'list&~of&~regular&~expressions'&>
25498 .cindex "&%regex%&" "ACL condition"
25499 .cindex "&ACL;" "testing by regex matching"
25500 This condition is available only when Exim is compiled with the
25501 content-scanning extension, and is available only in the DATA, MIME, and
25502 non-SMTP ACLs. It causes the incoming message to be scanned for a match with
25503 any of the regular expressions. For details, see chapter &<<CHAPexiscan>>&.
25504
25505 .vitem &*sender_domains&~=&~*&<&'domain&~list'&>
25506 .cindex "&%sender_domains%&" "ACL condition"
25507 .cindex "sender" "ACL checking"
25508 .cindex "&ACL;" "testing a sender domain"
25509 .cindex "&$domain$&"
25510 .cindex "&$sender_address_domain$&"
25511 This condition tests the domain of the sender of the message against the given
25512 domain list. &*Note*&: The domain of the sender address is in
25513 &$sender_address_domain$&. It is &'not'& put in &$domain$& during the testing
25514 of this condition. This is an exception to the general rule for testing domain
25515 lists. It is done this way so that, if this condition is used in an ACL for a
25516 RCPT command, the recipient's domain (which is in &$domain$&) can be used to
25517 influence the sender checking.
25518
25519 &*Warning*&: It is a bad idea to use this condition on its own as a control on
25520 relaying, because sender addresses are easily, and commonly, forged.
25521
25522 .vitem &*senders&~=&~*&<&'address&~list'&>
25523 .cindex "&%senders%&" "ACL condition"
25524 .cindex "sender" "ACL checking"
25525 .cindex "&ACL;" "testing a sender"
25526 This condition tests the sender of the message against the given list. To test
25527 for a bounce message, which has an empty sender, set
25528 .code
25529 senders = :
25530 .endd
25531 &*Warning*&: It is a bad idea to use this condition on its own as a control on
25532 relaying, because sender addresses are easily, and commonly, forged.
25533
25534 .vitem &*spam&~=&~*&<&'username'&>
25535 .cindex "&%spam%&" "ACL condition"
25536 .cindex "&ACL;" "scanning for spam"
25537 This condition is available only when Exim is compiled with the
25538 content-scanning extension. It causes the incoming message to be scanned by
25539 SpamAssassin. For details, see chapter &<<CHAPexiscan>>&.
25540
25541 .vitem &*verify&~=&~certificate*&
25542 .cindex "&%verify%&" "ACL condition"
25543 .cindex "TLS" "client certificate verification"
25544 .cindex "certificate" "verification of client"
25545 .cindex "&ACL;" "certificate verification"
25546 .cindex "&ACL;" "testing a TLS certificate"
25547 This condition is true in an SMTP session if the session is encrypted, and a
25548 certificate was received from the client, and the certificate was verified. The
25549 server requests a certificate only if the client matches &%tls_verify_hosts%&
25550 or &%tls_try_verify_hosts%& (see chapter &<<CHAPTLS>>&).
25551
25552 .vitem &*verify&~=&~csa*&
25553 .cindex "CSA verification"
25554 This condition checks whether the sending host (the client) is authorized to
25555 send email. Details of how this works are given in section
25556 &<<SECTverifyCSA>>&.
25557
25558 .vitem &*verify&~=&~header_sender/*&<&'options'&>
25559 .cindex "&%verify%&" "ACL condition"
25560 .cindex "&ACL;" "verifying sender in the header"
25561 .cindex "header lines" "verifying the sender in"
25562 .cindex "sender" "verifying in header"
25563 .cindex "verifying" "sender in header"
25564 This condition is relevant only in an ACL that is run after a message has been
25565 received, that is, in an ACL specified by &%acl_smtp_data%& or
25566 &%acl_not_smtp%&. It checks that there is a verifiable address in at least one
25567 of the &'Sender:'&, &'Reply-To:'&, or &'From:'& header lines. Such an address
25568 is loosely thought of as a &"sender"& address (hence the name of the test).
25569 However, an address that appears in one of these headers need not be an address
25570 that accepts bounce messages; only sender addresses in envelopes are required
25571 to accept bounces. Therefore, if you use the callout option on this check, you
25572 might want to arrange for a non-empty address in the MAIL command.
25573
25574 Details of address verification and the options are given later, starting at
25575 section &<<SECTaddressverification>>& (callouts are described in section
25576 &<<SECTcallver>>&). You can combine this condition with the &%senders%&
25577 condition to restrict it to bounce messages only:
25578 .code
25579 deny    senders = :
25580         message = A valid sender header is required for bounces
25581        !verify  = header_sender
25582 .endd
25583
25584 .vitem &*verify&~=&~header_syntax*&
25585 .cindex "&%verify%&" "ACL condition"
25586 .cindex "&ACL;" "verifying header syntax"
25587 .cindex "header lines" "verifying syntax"
25588 .cindex "verifying" "header syntax"
25589 This condition is relevant only in an ACL that is run after a message has been
25590 received, that is, in an ACL specified by &%acl_smtp_data%& or
25591 &%acl_not_smtp%&. It checks the syntax of all header lines that can contain
25592 lists of addresses (&'Sender:'&, &'From:'&, &'Reply-To:'&, &'To:'&, &'Cc:'&,
25593 and &'Bcc:'&). Unqualified addresses (local parts without domains) are
25594 permitted only in locally generated messages and from hosts that match
25595 &%sender_unqualified_hosts%& or &%recipient_unqualified_hosts%&, as
25596 appropriate.
25597
25598 Note that this condition is a syntax check only. However, a common spamming
25599 ploy used to be to send syntactically invalid headers such as
25600 .code
25601 To: @
25602 .endd
25603 and this condition can be used to reject such messages, though they are not as
25604 common as they used to be.
25605
25606 .vitem &*verify&~=&~helo*&
25607 .cindex "&%verify%&" "ACL condition"
25608 .cindex "&ACL;" "verifying HELO/EHLO"
25609 .cindex "HELO" "verifying"
25610 .cindex "EHLO" "verifying"
25611 .cindex "verifying" "EHLO"
25612 .cindex "verifying" "HELO"
25613 This condition is true if a HELO or EHLO command has been received from the
25614 client host, and its contents have been verified. If there has been no previous
25615 attempt to verify the HELO/EHLO contents, it is carried out when this
25616 condition is encountered. See the description of the &%helo_verify_hosts%& and
25617 &%helo_try_verify_hosts%& options for details of how to request verification
25618 independently of this condition.
25619
25620 .new
25621 For SMTP input that does not come over TCP/IP (the &%-bs%& command line
25622 option), this condition is always true.
25623 .wen
25624
25625
25626 .vitem &*verify&~=&~not_blind*&
25627 .cindex "verifying" "not blind"
25628 .cindex "bcc recipients" "verifying none"
25629 This condition checks that there are no blind (bcc) recipients in the message.
25630 Every envelope recipient must appear either in a &'To:'& header line or in a
25631 &'Cc:'& header line for this condition to be true. Local parts are checked
25632 case-sensitively; domains are checked case-insensitively. If &'Resent-To:'& or
25633 &'Resent-Cc:'& header lines exist, they are also checked. This condition can be
25634 used only in a DATA or non-SMTP ACL.
25635
25636 There are, of course, many legitimate messages that make use of blind (bcc)
25637 recipients. This check should not be used on its own for blocking messages.
25638
25639
25640 .vitem &*verify&~=&~recipient/*&<&'options'&>
25641 .cindex "&%verify%&" "ACL condition"
25642 .cindex "&ACL;" "verifying recipient"
25643 .cindex "recipient" "verifying"
25644 .cindex "verifying" "recipient"
25645 .cindex "&$address_data$&"
25646 This condition is relevant only after a RCPT command. It verifies the current
25647 recipient. Details of address verification are given later, starting at section
25648 &<<SECTaddressverification>>&. After a recipient has been verified, the value
25649 of &$address_data$& is the last value that was set while routing the address.
25650 This applies even if the verification fails. When an address that is being
25651 verified is redirected to a single address, verification continues with the new
25652 address, and in that case, the subsequent value of &$address_data$& is the
25653 value for the child address.
25654
25655 .vitem &*verify&~=&~reverse_host_lookup*&
25656 .cindex "&%verify%&" "ACL condition"
25657 .cindex "&ACL;" "verifying host reverse lookup"
25658 .cindex "host" "verifying reverse lookup"
25659 This condition ensures that a verified host name has been looked up from the IP
25660 address of the client host. (This may have happened already if the host name
25661 was needed for checking a host list, or if the host matched &%host_lookup%&.)
25662 Verification ensures that the host name obtained from a reverse DNS lookup, or
25663 one of its aliases, does, when it is itself looked up in the DNS, yield the
25664 original IP address.
25665
25666 If this condition is used for a locally generated message (that is, when there
25667 is no client host involved), it always succeeds.
25668
25669 .vitem &*verify&~=&~sender/*&<&'options'&>
25670 .cindex "&%verify%&" "ACL condition"
25671 .cindex "&ACL;" "verifying sender"
25672 .cindex "sender" "verifying"
25673 .cindex "verifying" "sender"
25674 This condition is relevant only after a MAIL or RCPT command, or after a
25675 message has been received (the &%acl_smtp_data%& or &%acl_not_smtp%& ACLs). If
25676 the message's sender is empty (that is, this is a bounce message), the
25677 condition is true. Otherwise, the sender address is verified.
25678
25679 .cindex "&$address_data$&"
25680 .cindex "&$sender_address_data$&"
25681 If there is data in the &$address_data$& variable at the end of routing, its
25682 value is placed in &$sender_address_data$& at the end of verification. This
25683 value can be used in subsequent conditions and modifiers in the same ACL
25684 statement. It does not persist after the end of the current statement. If you
25685 want to preserve the value for longer, you can save it in an ACL variable.
25686
25687 Details of verification are given later, starting at section
25688 &<<SECTaddressverification>>&. Exim caches the result of sender verification,
25689 to avoid doing it more than once per message.
25690
25691 .vitem &*verify&~=&~sender=*&<&'address'&>&*/*&<&'options'&>
25692 .cindex "&%verify%&" "ACL condition"
25693 This is a variation of the previous option, in which a modified address is
25694 verified as a sender.
25695 .endlist
25696
25697
25698
25699 .section "Using DNS lists" "SECTmorednslists"
25700 .cindex "DNS list" "in ACL"
25701 .cindex "black list (DNS)"
25702 .cindex "&ACL;" "testing a DNS list"
25703 In its simplest form, the &%dnslists%& condition tests whether the calling host
25704 is on at least one of a number of DNS lists by looking up the inverted IP
25705 address in one or more DNS domains. For example, if the calling host's IP
25706 address is 192.168.62.43, and the ACL statement is
25707 .code
25708 deny dnslists = blackholes.mail-abuse.org : \
25709                 dialups.mail-abuse.org
25710 .endd
25711 the following records are looked up:
25712 .code
25713 43.62.168.192.blackholes.mail-abuse.org
25714 43.62.168.192.dialups.mail-abuse.org
25715 .endd
25716 As soon as Exim finds an existing DNS record, processing of the list stops.
25717 Thus, multiple entries on the list provide an &"or"& conjunction. If you want
25718 to test that a host is on more than one list (an &"and"& conjunction), you can
25719 use two separate conditions:
25720 .code
25721 deny dnslists = blackholes.mail-abuse.org
25722      dnslists = dialups.mail-abuse.org
25723 .endd
25724 If a DNS lookup times out or otherwise fails to give a decisive answer, Exim
25725 behaves as if the host does not match the list item, that is, as if the DNS
25726 record does not exist. If there are further items in the DNS list, they are
25727 processed.
25728
25729 This is usually the required action when &%dnslists%& is used with &%deny%&
25730 (which is the most common usage), because it prevents a DNS failure from
25731 blocking mail. However, you can change this behaviour by putting one of the
25732 following special items in the list:
25733 .display
25734 &`+include_unknown `&   behave as if the item is on the list
25735 &`+exclude_unknown `&   behave as if the item is not on the list (default)
25736 &`+defer_unknown   `&   give a temporary error
25737 .endd
25738 .cindex "&`+include_unknown`&"
25739 .cindex "&`+exclude_unknown`&"
25740 .cindex "&`+defer_unknown`&"
25741 Each of these applies to any subsequent items on the list. For example:
25742 .code
25743 deny dnslists = +defer_unknown : foo.bar.example
25744 .endd
25745 Testing the list of domains stops as soon as a match is found. If you want to
25746 warn for one list and block for another, you can use two different statements:
25747 .code
25748 deny  dnslists = blackholes.mail-abuse.org
25749 warn  message  = X-Warn: sending host is on dialups list
25750       dnslists = dialups.mail-abuse.org
25751 .endd
25752 DNS list lookups are cached by Exim for the duration of the SMTP session,
25753 so a lookup based on the IP address is done at most once for any incoming
25754 connection. Exim does not share information between multiple incoming
25755 connections (but your local name server cache should be active).
25756
25757
25758
25759 .section "Specifying the IP address for a DNS list lookup"
25760 .cindex "DNS list" "keyed by explicit IP address"
25761 By default, the IP address that is used in a DNS list lookup is the IP address
25762 of the calling host. However, you can specify another IP address by listing it
25763 after the domain name, introduced by a slash. For example:
25764 .code
25765 deny dnslists = black.list.tld/192.168.1.2
25766 .endd
25767 This feature is not very helpful with explicit IP addresses; it is intended for
25768 use with IP addresses that are looked up, for example, the IP addresses of the
25769 MX hosts or nameservers of an email sender address. For an example, see section
25770 &<<SECTmulkeyfor>>& below.
25771
25772
25773
25774
25775 .section "DNS lists keyed on domain names"
25776 .cindex "DNS list" "keyed by domain name"
25777 There are some lists that are keyed on domain names rather than inverted IP
25778 addresses (see for example the &'domain based zones'& link at
25779 &url(http://www.rfc-ignorant.org/)). No reversing of components is used
25780 with these lists. You can change the name that is looked up in a DNS list by
25781 listing it after the domain name, introduced by a slash. For example,
25782 .code
25783 deny  message  = Sender's domain is listed at $dnslist_domain
25784       dnslists = dsn.rfc-ignorant.org/$sender_address_domain
25785 .endd
25786 This particular example is useful only in ACLs that are obeyed after the
25787 RCPT or DATA commands, when a sender address is available. If (for
25788 example) the message's sender is &'user@tld.example'& the name that is looked
25789 up by this example is
25790 .code
25791 tld.example.dsn.rfc-ignorant.org
25792 .endd
25793 A single &%dnslists%& condition can contain entries for both names and IP
25794 addresses. For example:
25795 .code
25796 deny dnslists = sbl.spamhaus.org : \
25797                 dsn.rfc-ignorant.org/$sender_address_domain
25798 .endd
25799 The first item checks the sending host's IP address; the second checks a domain
25800 name. The whole condition is true if either of the DNS lookups succeeds.
25801
25802
25803
25804
25805 .section "Multiple explicit keys for a DNS list" "SECTmulkeyfor"
25806 .cindex "DNS list" "multiple keys for"
25807 The syntax described above for looking up explicitly-defined values (either
25808 names or IP addresses) in a DNS blacklist is a simplification. After the domain
25809 name for the DNS list, what follows the slash can in fact be a list of items.
25810 As with all lists in Exim, the default separator is a colon. However, because
25811 this is a sublist within the list of DNS blacklist domains, it is necessary
25812 either to double the separators like this:
25813 .code
25814 dnslists = black.list.tld/name.1::name.2
25815 .endd
25816 or to change the separator character, like this:
25817 .code
25818 dnslists = black.list.tld/<;name.1;name.2
25819 .endd
25820 If an item in the list is an IP address, it is inverted before the DNS
25821 blacklist domain is appended. If it is not an IP address, no inversion
25822 occurs. Consider this condition:
25823 .code
25824 dnslists = black.list.tld/<;192.168.1.2;a.domain
25825 .endd
25826 The DNS lookups that occur are:
25827 .code
25828 2.1.168.192.black.list.tld
25829 a.domain.black.list.tld
25830 .endd
25831 Once a DNS record has been found (that matches a specific IP return
25832 address, if specified &-- see section &<<SECTaddmatcon>>&), no further lookups
25833 are done. If there is a temporary DNS error, the rest of the sublist of domains
25834 or IP addresses is tried. A temporary error for the whole dnslists item occurs
25835 only if no other DNS lookup in this sublist succeeds. In other words, a
25836 successful lookup for any of the items in the sublist overrides a temporary
25837 error for a previous item.
25838
25839 The ability to supply a list of items after the slash is in some sense just a
25840 syntactic convenience. These two examples have the same effect:
25841 .code
25842 dnslists = black.list.tld/a.domain : black.list.tld/b.domain
25843 dnslists = black.list.tld/a.domain::b.domain
25844 .endd
25845 However, when the data for the list is obtained from a lookup, the second form
25846 is usually much more convenient. Consider this example:
25847 .code
25848 deny message  = The mail servers for the domain \
25849                 $sender_address_domain \
25850                 are listed at $dnslist_domain ($dnslist_value); \
25851                 see $dnslist_text.
25852      dnslists = sbl.spamhaus.org/<|${lookup dnsdb {>|a=<|\
25853                                    ${lookup dnsdb {>|mxh=\
25854                                    $sender_address_domain} }} }
25855 .endd
25856 Note the use of &`>|`& in the dnsdb lookup to specify the separator for
25857 multiple DNS records. The inner dnsdb lookup produces a list of MX hosts
25858 and the outer dnsdb lookup finds the IP addresses for these hosts. The result
25859 of expanding the condition might be something like this:
25860 .code
25861 dnslists = sbl.spahmaus.org/<|192.168.2.3|192.168.5.6|...
25862 .endd
25863 Thus, this example checks whether or not the IP addresses of the sender
25864 domain's mail servers are on the Spamhaus black list.
25865
25866
25867
25868
25869
25870 .section "Data returned by DNS lists"
25871 .cindex "DNS list" "data returned from"
25872 DNS lists are constructed using address records in the DNS. The original RBL
25873 just used the address 127.0.0.1 on the right hand side of each record, but the
25874 RBL+ list and some other lists use a number of values with different meanings.
25875 The values used on the RBL+ list are:
25876 .display
25877 127.1.0.1  RBL
25878 127.1.0.2  DUL
25879 127.1.0.3  DUL and RBL
25880 127.1.0.4  RSS
25881 127.1.0.5  RSS and RBL
25882 127.1.0.6  RSS and DUL
25883 127.1.0.7  RSS and DUL and RBL
25884 .endd
25885 .new
25886 Section &<<SECTaddmatcon>>& below describes how you can distinguish between
25887 different values. Some DNS lists may return more than one address record; they
25888 are all checked.
25889 .wen
25890
25891 .section "Variables set from DNS lists"
25892 .new
25893 .cindex "DNS list" "variables set from"
25894 .cindex "&$dnslist_domain$&"
25895 .cindex "&$dnslist_text$&"
25896 .cindex "&$dnslist_value$&"
25897 When an entry is found in a DNS list, the variable &$dnslist_domain$&
25898 contains the name of the domain that matched, and &$dnslist_value$& contains
25899 the data from the entry. If more than one address record is returned by the DNS
25900 lookup, all the IP addresses are included in &$dnslist_value$&, separated by
25901 commas and spaces. The variable &$dnslist_text$& contains the contents of any
25902 associated TXT record. For lists such as RBL+ the TXT record for a merged entry
25903 is often not very meaningful. See section &<<SECTmordetinf>>& for a way of
25904 obtaining more information.
25905 .wen
25906
25907 You can use the DNS list variables in &%message%& or &%log_message%& modifiers
25908 &-- although these appear before the condition in the ACL, they are not
25909 expanded until after it has failed. For example:
25910 .code
25911 deny    hosts = !+local_networks
25912         message = $sender_host_address is listed \
25913                   at $dnslist_domain
25914         dnslists = rbl-plus.mail-abuse.example
25915 .endd
25916
25917
25918
25919 .section "Additional matching conditions for DNS lists" "SECTaddmatcon"
25920 .cindex "DNS list" "matching specific returned data"
25921 You can add an equals sign and an IP address after a &%dnslists%& domain name
25922 in order to restrict its action to DNS records with a matching right hand side.
25923 For example,
25924 .code
25925 deny dnslists = rblplus.mail-abuse.org=127.0.0.2
25926 .endd
25927 rejects only those hosts that yield 127.0.0.2. Without this additional data,
25928 any address record is considered to be a match. If more than one address record
25929 is found on the list, they are all checked for a matching right-hand side.
25930
25931 More than one IP address may be given for checking, using a comma as a
25932 separator. These are alternatives &-- if any one of them matches, the
25933 &%dnslists%& condition is true. For example:
25934 .code
25935 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
25936 .endd
25937 If you want to specify a constraining address list and also specify names or IP
25938 addresses to be looked up, the constraining address list must be specified
25939 first. For example:
25940 .code
25941 deny dnslists = dsn.rfc-ignorant.org\
25942                 =127.0.0.2/$sender_address_domain
25943 .endd
25944
25945 If the character &`&&`& is used instead of &`=`&, the comparison for each
25946 listed IP address is done by a bitwise &"and"& instead of by an equality test.
25947 In other words, the listed addresses are used as bit masks. The comparison is
25948 true if all the bits in the mask are present in the address that is being
25949 tested. For example:
25950 .code
25951 dnslists = a.b.c&0.0.0.3
25952 .endd
25953 matches if the address is &'x.x.x.'&3, &'x.x.x.'&7, &'x.x.x.'&11, etc. If you
25954 want to test whether one bit or another bit is present (as opposed to both
25955 being present), you must use multiple values. For example:
25956 .code
25957 dnslists = a.b.c&0.0.0.1,0.0.0.2
25958 .endd
25959 matches if the final component of the address is an odd number or two times
25960 an odd number.
25961
25962
25963
25964 .section "Negated DNS matching conditions"
25965 You can supply a negative list of IP addresses as part of a &%dnslists%&
25966 condition. Whereas
25967 .code
25968 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
25969 .endd
25970 means &"deny if the host is in the black list at the domain &'a.b.c'& and the
25971 IP address yielded by the list is either 127.0.0.2 or 127.0.0.3"&,
25972 .code
25973 deny  dnslists = a.b.c!=127.0.0.2,127.0.0.3
25974 .endd
25975 means &"deny if the host is in the black list at the domain &'a.b.c'& and the
25976 IP address yielded by the list is not 127.0.0.2 and not 127.0.0.3"&. In other
25977 words, the result of the test is inverted if an exclamation mark appears before
25978 the &`=`& (or the &`&&`&) sign.
25979
25980 &*Note*&: This kind of negation is not the same as negation in a domain,
25981 host, or address list (which is why the syntax is different).
25982
25983 If you are using just one list, the negation syntax does not gain you much. The
25984 previous example is precisely equivalent to
25985 .code
25986 deny  dnslists = a.b.c
25987      !dnslists = a.b.c=127.0.0.2,127.0.0.3
25988 .endd
25989 However, if you are using multiple lists, the negation syntax is clearer.
25990 Consider this example:
25991 .code
25992 deny  dnslists = sbl.spamhaus.org : \
25993                  list.dsbl.org : \
25994                  dnsbl.njabl.org!=127.0.0.3 : \
25995                  relays.ordb.org
25996 .endd
25997 Using only positive lists, this would have to be:
25998 .code
25999 deny  dnslists = sbl.spamhaus.org : \
26000                  list.dsbl.org
26001 deny  dnslists = dnsbl.njabl.org
26002      !dnslists = dnsbl.njabl.org=127.0.0.3
26003 deny  dnslists = relays.ordb.org
26004 .endd
26005 which is less clear, and harder to maintain.
26006
26007
26008 .new
26009 .section "Detailed information from merged DNS lists" "SECTmordetinf"
26010 .cindex "DNS list" "information from merged"
26011 When the facility for restricting the matching IP values in a DNS list is used,
26012 the text from the TXT record that is set in &$dnslist_text$& may not reflect
26013 the true reason for rejection. This happens when lists are merged and the IP
26014 address in the A record is used to distinguish them; unfortunately there is
26015 only one TXT record. One way round this is not to use merged lists, but that
26016 can be inefficient because it requires multiple DNS lookups where one would do
26017 in the vast majority of cases when the host of interest is not on any of the
26018 lists.
26019
26020 A less inefficient way of solving this problem is available. If
26021 two domain names, comma-separated, are given, the second is used first to
26022 do an initial check, making use of any IP value restrictions that are set.
26023 If there is a match, the first domain is used, without any IP value
26024 restrictions, to get the TXT record. As a byproduct of this, there is also
26025 a check that the IP being tested is indeed on the first list. The first
26026 domain is the one that is put in &$dnslist_domain$&. For example:
26027 .code
26028 reject message  = \
26029          rejected because $sender_ip_address is blacklisted \
26030          at $dnslist_domain\n$dnslist_text
26031        dnslists = \
26032          sbl.spamhaus.org,sbl-xbl.spamhaus.org=127.0.0.2 : \
26033          dul.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.10
26034 .endd
26035 For the first blacklist item, this starts by doing a lookup in
26036 &'sbl-xbl.spamhaus.org'& and testing for a 127.0.0.2 return. If there is a
26037 match, it then looks in &'sbl.spamhaus.org'&, without checking the return
26038 value, and as long as something is found, it looks for the corresponding TXT
26039 record. If there is no match in &'sbl-xbl.spamhaus.org'&, nothing more is done.
26040 The second blacklist item is processed similarly.
26041
26042 If you are interested in more than one merged list, the same list must be
26043 given several times, but because the results of the DNS lookups are cached,
26044 the DNS calls themselves are not repeated. For example:
26045 .code
26046 reject dnslists = \
26047          http.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.2 : \
26048          socks.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.3 : \
26049          misc.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.4 : \
26050          dul.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.10
26051 .endd
26052 In this case there is one lookup in &'dnsbl.sorbs.net'&, and if none of the IP
26053 values matches (or if no record is found), this is the only lookup that is
26054 done. Only if there is a match is one of the more specific lists consulted.
26055 .wen
26056
26057
26058
26059 .section "DNS lists and IPv6" "SECTmorednslistslast"
26060 .cindex "IPv6" "DNS black lists"
26061 .cindex "DNS list" "IPv6 usage"
26062 If Exim is asked to do a dnslist lookup for an IPv6 address, it inverts it
26063 nibble by nibble. For example, if the calling host's IP address is
26064 3ffe:ffff:836f:0a00:000a:0800:200a:c031, Exim might look up
26065 .code
26066 1.3.0.c.a.0.0.2.0.0.8.0.a.0.0.0.0.0.a.0.f.6.3.8.
26067   f.f.f.f.e.f.f.3.blackholes.mail-abuse.org
26068 .endd
26069 (split over two lines here to fit on the page). Unfortunately, some of the DNS
26070 lists contain wildcard records, intended for IPv4, that interact badly with
26071 IPv6. For example, the DNS entry
26072 .code
26073 *.3.some.list.example.    A    127.0.0.1
26074 .endd
26075 is probably intended to put the entire 3.0.0.0/8 IPv4 network on the list.
26076 Unfortunately, it also matches the entire 3::/4 IPv6 network.
26077
26078 You can exclude IPv6 addresses from DNS lookups by making use of a suitable
26079 &%condition%& condition, as in this example:
26080 .code
26081 deny   condition = ${if isip4{$sender_host_address}}
26082        dnslists  = some.list.example
26083 .endd
26084
26085 .section "Rate limiting senders" "SECTratelimiting"
26086 .cindex "rate limiting" "client sending"
26087 .cindex "limiting client sending rates"
26088 .oindex "&%smtp_ratelimit_*%&"
26089 The &%ratelimit%& ACL condition can be used to measure and control the rate at
26090 which clients can send email. This is more powerful than the
26091 &%smtp_ratelimit_*%& options, because those options control the rate of
26092 commands in a single SMTP session only, whereas the &%ratelimit%& condition
26093 works across all connections (concurrent and sequential) from the same client
26094 host. The syntax of the &%ratelimit%& condition is:
26095 .display
26096 &`ratelimit =`& <&'m'&> &`/`& <&'p'&> &`/`& <&'options'&> &`/`& <&'key'&>
26097 .endd
26098 If the average client sending rate is less than &'m'& messages per time
26099 period &'p'& then the condition is false; otherwise it is true.
26100
26101 As a side-effect, the &%ratelimit%& condition sets the expansion variable
26102 &$sender_rate$& to the client's computed rate, &$sender_rate_limit$& to the
26103 configured value of &'m'&, and &$sender_rate_period$& to the configured value
26104 of &'p'&.
26105
26106 The parameter &'p'& is the smoothing time constant, in the form of an Exim
26107 time interval, for example, &`8h`& for eight hours. A larger time constant
26108 means that it takes Exim longer to forget a client's past behaviour. The
26109 parameter &'m'& is the maximum number of messages that a client is permitted to
26110 send in each time interval. It also specifies the number of messages permitted
26111 in a fast burst. By increasing both &'m'& and &'p'& but keeping &'m/p'&
26112 constant, you can allow a client to send more messages in a burst without
26113 changing its overall sending rate limit. Conversely, if &'m'& and &'p'& are
26114 both small, messages must be sent at an even rate.
26115
26116 There is a script in &_util/ratelimit.pl_& which extracts sending rates from
26117 log files, to assist with choosing appropriate settings for &'m'& and &'p'&
26118 when deploying the &%ratelimit%& ACL condition. The script prints usage
26119 instructions when it is run with no arguments.
26120
26121 The key is used to look up the data for calculating the client's average
26122 sending rate. This data is stored in a database maintained by Exim in its spool
26123 directory, alongside the retry and other hints databases. The default key is
26124 &$sender_host_address$&, which applies the limit to each client host IP address.
26125 By changing the key you can change how Exim identifies clients for the purpose
26126 of ratelimiting. For example, to limit the sending rate of each authenticated
26127 user, independent of the computer they are sending from, set the key to
26128 &$authenticated_id$&. You must ensure that the lookup key is meaningful; for
26129 example, &$authenticated_id$& is only meaningful if the client has
26130 authenticated, and you can check with the &%authenticated%& ACL condition.
26131
26132 Internally, Exim includes the smoothing constant &'p'& and the options in the
26133 lookup key because they alter the meaning of the stored data. This is not true
26134 for the limit &'m'&, so you can alter the configured maximum rate and Exim will
26135 still remember clients' past behaviour, but if you alter the other ratelimit
26136 parameters Exim forgets past behaviour.
26137
26138 Each &%ratelimit%& condition can have up to two options. The first option
26139 specifies what Exim measures the rate of, and the second specifies how Exim
26140 handles excessively fast clients. The options are separated by a slash, like
26141 the other parameters.
26142
26143 The &%per_conn%& option limits the client's connection rate.
26144
26145 The &%per_mail%& option limits the client's rate of sending messages. This is
26146 the default if none of the &%per_*%& options is specified.
26147
26148 The &%per_byte%& option limits the sender's email bandwidth. Note that it is
26149 best to use this option in the DATA ACL; if it is used in an earlier ACL it
26150 relies on the SIZE parameter on the MAIL command, which may be inaccurate or
26151 completely missing. You can follow the limit &'m'& in the configuration with K,
26152 M, or G to specify limits in kilobytes, megabytes, or gigabytes, respectively.
26153
26154 The &%per_cmd%& option causes Exim to recompute the rate every time the
26155 condition is processed. This can be used to limit the SMTP command rate. The
26156 alias &%per_rcpt%& is provided for use in the RCPT ACL instead of &%per_cmd%&
26157 to make it clear that the effect is to limit the rate at which recipients are
26158 accepted. Note that in this case the rate limiting engine will see a message
26159 with many recipients as a large high-speed burst.
26160
26161 If a client's average rate is greater than the maximum, the rate limiting
26162 engine can react in two possible ways, depending on the presence of the
26163 &%strict%& or &%leaky%& options. This is independent of the other
26164 counter-measures (such as rejecting the message) that may be specified by the
26165 rest of the ACL. The default mode is leaky, which avoids a sender's
26166 over-aggressive retry rate preventing it from getting any email through.
26167
26168 The &%strict%& option means that the client's recorded rate is always updated.
26169 The effect of this is that Exim measures the client's average rate of attempts
26170 to send email, which can be much higher than the maximum. If the client is over
26171 the limit it will be subjected to counter-measures until it slows down below
26172 the maximum rate. The smoothing period determines the time it takes for a high
26173 sending rate to decay exponentially to 37% of its peak value, which means that
26174 you can work out the time (the number of smoothing periods) that a client is
26175 subjected to counter-measures after an over-limit burst with this formula:
26176 .code
26177 ln(peakrate/maxrate)
26178 .endd
26179 The &%leaky%& option means that the client's recorded rate is not updated if it
26180 is above the limit. The effect of this is that Exim measures the client's
26181 average rate of successfully sent email, which cannot be greater than the
26182 maximum. If the client is over the limit it &new("may suffer some
26183 counter-measures (as specified in the ACL)"), but it will still be able to send
26184 email at the configured maximum rate, whatever the rate of its attempts. This
26185 is generally the better choice if you have clients that retry automatically.
26186
26187 Exim's other ACL facilities are used to define what counter-measures are taken
26188 when the rate limit is exceeded. This might be anything from logging a warning
26189 (for example, while measuring existing sending rates in order to define
26190 policy), through time delays to slow down fast senders, up to rejecting the
26191 message. For example:
26192 .code
26193 # Log all senders' rates
26194 warn ratelimit = 0 / 1h / strict
26195      log_message = Sender rate $sender_rate / $sender_rate_period
26196
26197 # Slow down fast senders; note the need to truncate $sender_rate
26198 # at the decimal point.
26199 warn ratelimit = 100 / 1h / per_rcpt / strict
26200      delay     = ${eval: ${sg{$sender_rate}{[.].*}{}} - \
26201                    $sender_rate_limit }s
26202
26203 # Keep authenticated users under control
26204 deny authenticated = *
26205      ratelimit = 100 / 1d / strict / $authenticated_id
26206
26207 # System-wide rate limit
26208 defer message = Sorry, too busy. Try again later.
26209      ratelimit = 10 / 1s / $primary_hostname
26210
26211 # Restrict incoming rate from each host, with a default
26212 # set using a macro and special cases looked up in a table.
26213 defer message = Sender rate exceeds $sender_rate_limit \
26214                messages per $sender_rate_period
26215      ratelimit = ${lookup {$sender_host_address} \
26216                    cdb {DB/ratelimits.cdb} \
26217                    {$value} {RATELIMIT} }
26218 .endd
26219 &*Warning*&: If you have a busy server with a lot of &%ratelimit%& tests,
26220 especially with the &%per_rcpt%& option, you may suffer from a performance
26221 bottleneck caused by locking on the ratelimit hints database. Apart from
26222 making your ACLs less complicated, you can reduce the problem by using a
26223 RAM disk for Exim's hints directory (usually &_/var/spool/exim/db/_&). However
26224 this means that Exim will lose its hints data after a reboot (including retry
26225 hints, the callout cache, and ratelimit data).
26226
26227
26228 .section "Address verification" "SECTaddressverification"
26229 .cindex "verifying address" "options for"
26230 .cindex "policy control" "address verification"
26231 Several of the &%verify%& conditions described in section
26232 &<<SECTaclconditions>>& cause addresses to be verified. Section
26233 &<<SECTsenaddver>>& discusses the reporting of sender verification failures.
26234 The verification conditions can be followed by options that modify the
26235 verification process. The options are separated from the keyword and from each
26236 other by slashes, and some of them contain parameters. For example:
26237 .code
26238 verify = sender/callout
26239 verify = recipient/defer_ok/callout=10s,defer_ok
26240 .endd
26241 The first stage of address verification, which always happens, is to run the
26242 address through the routers, in &"verify mode"&. Routers can detect the
26243 difference between verification and routing for delivery, and their actions can
26244 be varied by a number of generic options such as &%verify%& and &%verify_only%&
26245 (see chapter &<<CHAProutergeneric>>&). If routing fails, verification fails.
26246 The available options are as follows:
26247
26248 .ilist
26249 If the &%callout%& option is specified, successful routing to one or more
26250 remote hosts is followed by a &"callout"& to those hosts as an additional
26251 check. Callouts and their sub-options are discussed in the next section.
26252 .next
26253 If there is a defer error while doing verification routing, the ACL
26254 normally returns &"defer"&. However, if you include &%defer_ok%& in the
26255 options, the condition is forced to be true instead. Note that this is a main
26256 verification option as well as a suboption for callouts.
26257 .next
26258 The &%no_details%& option is covered in section &<<SECTsenaddver>>&, which
26259 discusses the reporting of sender address verification failures.
26260 .next
26261 The &%success_on_redirect%& option causes verification always to succeed
26262 immediately after a successful redirection. By default, if a redirection
26263 generates just one address, that address is also verified. See further
26264 discussion in section &<<SECTredirwhilveri>>&.
26265 .endlist
26266
26267 .cindex "verifying address" "differentiating failures"
26268 .cindex "&$recipient_verify_failure$&"
26269 .cindex "&$sender_verify_failure$&"
26270 .cindex "&$acl_verify_message$&"
26271 After an address verification failure, &$acl_verify_message$& contains the
26272 error message that is associated with the failure. It can be preserved by
26273 coding like this:
26274 .code
26275 warn  !verify = sender
26276        set acl_m0 = $acl_verify_message
26277 .endd
26278 If you are writing your own custom rejection message or log message when
26279 denying access, you can use this variable to include information about the
26280 verification failure.
26281
26282 In addition, &$sender_verify_failure$& or &$recipient_verify_failure$& (as
26283 appropriate) contains one of the following words:
26284
26285 .ilist
26286 &%qualify%&: The address was unqualified (no domain), and the message
26287 was neither local nor came from an exempted host.
26288 .next
26289 &%route%&: Routing failed.
26290 .next
26291 &%mail%&: Routing succeeded, and a callout was attempted; rejection
26292 occurred at or before the MAIL command (that is, on initial
26293 connection, HELO, or MAIL).
26294 .next
26295 &%recipient%&: The RCPT command in a callout was rejected.
26296 .next
26297 &%postmaster%&: The postmaster check in a callout was rejected.
26298 .endlist
26299
26300 The main use of these variables is expected to be to distinguish between
26301 rejections of MAIL and rejections of RCPT in callouts.
26302
26303
26304
26305
26306 .section "Callout verification" "SECTcallver"
26307 .cindex "verifying address" "by callout"
26308 .cindex "callout" "verification"
26309 .cindex "SMTP" "callout verification"
26310 For non-local addresses, routing verifies the domain, but is unable to do any
26311 checking of the local part. There are situations where some means of verifying
26312 the local part is desirable. One way this can be done is to make an SMTP
26313 &'callback'& to a delivery host for the sender address or a &'callforward'& to
26314 a subsequent host for a recipient address, to see if the host accepts the
26315 address. We use the term &'callout'& to cover both cases. Note that for a
26316 sender address, the callback is not to the client host that is trying to
26317 deliver the message, but to one of the hosts that accepts incoming mail for the
26318 sender's domain.
26319
26320 Exim does not do callouts by default. If you want them to happen, you must
26321 request them by setting appropriate options on the &%verify%& condition, as
26322 described below. This facility should be used with care, because it can add a
26323 lot of resource usage to the cost of verifying an address. However, Exim does
26324 cache the results of callouts, which helps to reduce the cost. Details of
26325 caching are in section &<<SECTcallvercache>>&.
26326
26327 Recipient callouts are usually used only between hosts that are controlled by
26328 the same administration. For example, a corporate gateway host could use
26329 callouts to check for valid recipients on an internal mailserver. A successful
26330 callout does not guarantee that a real delivery to the address would succeed;
26331 on the other hand, a failing callout does guarantee that a delivery would fail.
26332
26333 If the &%callout%& option is present on a condition that verifies an address, a
26334 second stage of verification occurs if the address is successfully routed to
26335 one or more remote hosts. The usual case is routing by a &(dnslookup)& or a
26336 &(manualroute)& router, where the router specifies the hosts. However, if a
26337 router that does not set up hosts routes to an &(smtp)& transport with a
26338 &%hosts%& setting, the transport's hosts are used. If an &(smtp)& transport has
26339 &%hosts_override%& set, its hosts are always used, whether or not the router
26340 supplies a host list.
26341
26342 .new
26343 The port that is used is taken from the transport, if it is specified and is a
26344 remote transport. (For routers that do verification only, no transport need be
26345 specified.) Otherwise, the default SMTP port is used. If a remote transport
26346 specifies an outgoing interface, this is used; otherwise the interface is not
26347 specified. Likewise, the text that is used for the HELO command is taken from
26348 the transport's &%helo_data%& option; if there is no transport, the value of
26349 &$smtp_active_hostname$& is used.
26350
26351 For a sender callout check, Exim makes SMTP connections to the remote hosts, to
26352 test whether a bounce message could be delivered to the sender address. The
26353 following SMTP commands are sent:
26354 .display
26355 &`HELO `&<&'local host name'&>
26356 &`MAIL FROM:<>`&
26357 &`RCPT TO:`&<&'the address to be tested'&>
26358 &`QUIT`&
26359 .endd
26360 .wen
26361 LHLO is used instead of HELO if the transport's &%protocol%& option is
26362 set to &"lmtp"&.
26363
26364 A recipient callout check is similar. By default, it also uses an empty address
26365 for the sender. This default is chosen because most hosts do not make use of
26366 the sender address when verifying a recipient. Using the same address means
26367 that a single cache entry can be used for each recipient. Some sites, however,
26368 do make use of the sender address when verifying. These are catered for by the
26369 &%use_sender%& and &%use_postmaster%& options, described in the next section.
26370
26371 If the response to the RCPT command is a 2&'xx'& code, the verification
26372 succeeds. If it is 5&'xx'&, the verification fails. For any other condition,
26373 Exim tries the next host, if any. If there is a problem with all the remote
26374 hosts, the ACL yields &"defer"&, unless the &%defer_ok%& parameter of the
26375 &%callout%& option is given, in which case the condition is forced to succeed.
26376
26377
26378
26379
26380
26381 .section "Additional parameters for callouts" "CALLaddparcall"
26382 .cindex "callout" "additional parameters for"
26383 The &%callout%& option can be followed by an equals sign and a number of
26384 optional parameters, separated by commas. For example:
26385 .code
26386 verify = recipient/callout=10s,defer_ok
26387 .endd
26388 The old syntax, which had &%callout_defer_ok%& and &%check_postmaster%& as
26389 separate verify options, is retained for backwards compatibility, but is now
26390 deprecated. The additional parameters for &%callout%& are as follows:
26391
26392
26393 .vlist
26394 .vitem <&'a&~time&~interval'&>
26395 .cindex "callout timeout" "specifying"
26396 This specifies the timeout that applies for the callout attempt to each host.
26397 For example:
26398 .code
26399 verify = sender/callout=5s
26400 .endd
26401 The default is 30 seconds. The timeout is used for each response from the
26402 remote host. It is also used for the intial connection, unless overridden by
26403 the &%connect%& parameter.
26404
26405
26406 .vitem &*connect&~=&~*&<&'time&~interval'&>
26407 .cindex "callout connection timeout" "specifying"
26408 This parameter makes it possible to set a different (usually smaller) timeout
26409 for making the SMTP connection. For example:
26410 .code
26411 verify = sender/callout=5s,connect=1s
26412 .endd
26413 If not specified, this timeout defaults to the general timeout value.
26414
26415 .vitem &*defer_ok*&
26416 .cindex "callout defer" "action on"
26417 When this parameter is present, failure to contact any host, or any other kind
26418 of temporary error, is treated as success by the ACL. However, the cache is not
26419 updated in this circumstance.
26420
26421 .vitem &*fullpostmaster*&
26422 .cindex "callout" "full postmaster check"
26423 This operates like the &%postmaster%& option (see below), but if the check for
26424 &'postmaster@domain'& fails, it tries just &'postmaster'&, without a domain, in
26425 accordance with the specification in RFC 2821. The RFC states that the
26426 unqualified address &'postmaster'& should be accepted.
26427
26428
26429 .vitem &*mailfrom&~=&~*&<&'email&~address'&>
26430 .cindex "callout" "sender when verifying header"
26431 When verifying addresses in header lines using the &%header_sender%&
26432 verification option, Exim behaves by default as if the addresses are envelope
26433 sender addresses from a message. Callout verification therefore tests to see
26434 whether a bounce message could be delivered, by using an empty address in the
26435 MAIL command. However, it is arguable that these addresses might never be used
26436 as envelope senders, and could therefore justifiably reject bounce messages
26437 (empty senders). The &%mailfrom%& callout parameter allows you to specify what
26438 address to use in the MAIL command. For example:
26439 .code
26440 require  verify = header_sender/callout=mailfrom=abcd@x.y.z
26441 .endd
26442 This parameter is available only for the &%header_sender%& verification option.
26443
26444
26445 .vitem &*maxwait&~=&~*&<&'time&~interval'&>
26446 .cindex "callout overall timeout" "specifying"
26447 This parameter sets an overall timeout for performing a callout verification.
26448 For example:
26449 .code
26450 verify = sender/callout=5s,maxwait=30s
26451 .endd
26452 This timeout defaults to four times the callout timeout for individual SMTP
26453 commands. The overall timeout applies when there is more than one host that can
26454 be tried. The timeout is checked before trying the next host. This prevents
26455 very long delays if there are a large number of hosts and all are timing out
26456 (for example, when network connections are timing out).
26457
26458
26459 .vitem &*no_cache*&
26460 .cindex "callout cache" "suppressing"
26461 .cindex "caching callout" "suppressing"
26462 When this parameter is given, the callout cache is neither read nor updated.
26463
26464 .vitem &*postmaster*&
26465 .cindex "callout" "postmaster; checking"
26466 When this parameter is set, a sucessful callout check is followed by a similar
26467 check for the local part &'postmaster'& at the same domain. If this address is
26468 rejected, the callout fails (but see &%fullpostmaster%& above). The result of
26469 the postmaster check is recorded in a cache record; if it is a failure, this is
26470 used to fail subsequent callouts for the domain without a connection being
26471 made, until the cache record expires.
26472
26473 .vitem &*postmaster_mailfrom&~=&~*&<&'email&~address'&>
26474 The postmaster check uses an empty sender in the MAIL command by default.
26475 You can use this parameter to do a postmaster check using a different address.
26476 For example:
26477 .code
26478 require  verify = sender/callout=postmaster_mailfrom=abc@x.y.z
26479 .endd
26480 If both &%postmaster%& and &%postmaster_mailfrom%& are present, the rightmost
26481 one overrides. The &%postmaster%& parameter is equivalent to this example:
26482 .code
26483 require  verify = sender/callout=postmaster_mailfrom=
26484 .endd
26485 &*Warning*&: The caching arrangements for postmaster checking do not take
26486 account of the sender address. It is assumed that either the empty address or
26487 a fixed non-empty address will be used. All that Exim remembers is that the
26488 postmaster check for the domain succeeded or failed.
26489
26490
26491 .vitem &*random*&
26492 .cindex "callout" "&""random""& check"
26493 When this parameter is set, before doing the normal callout check, Exim does a
26494 check for a &"random"& local part at the same domain. The local part is not
26495 really random &-- it is defined by the expansion of the option
26496 &%callout_random_local_part%&, which defaults to
26497 .code
26498 $primary_host_name-$tod_epoch-testing
26499 .endd
26500 The idea here is to try to determine whether the remote host accepts all local
26501 parts without checking. If it does, there is no point in doing callouts for
26502 specific local parts. If the &"random"& check succeeds, the result is saved in
26503 a cache record, and used to force the current and subsequent callout checks to
26504 succeed without a connection being made, until the cache record expires.
26505
26506 .vitem &*use_postmaster*&
26507 .cindex "callout" "sender for recipient check"
26508 This parameter applies to recipient callouts only. For example:
26509 .code
26510 deny  !verify = recipient/callout=use_postmaster
26511 .endd
26512 .cindex "&$qualify_domain$&"
26513 It causes a non-empty postmaster address to be used in the MAIL command when
26514 performing the callout for the recipient, and also for a &"random"& check if
26515 that is configured. The local part of the address is &`postmaster`& and the
26516 domain is the contents of &$qualify_domain$&.
26517
26518 .vitem &*use_sender*&
26519 This option applies to recipient callouts only. For example:
26520 .code
26521 require  verify = recipient/callout=use_sender
26522 .endd
26523 It causes the message's actual sender address to be used in the MAIL
26524 command when performing the callout, instead of an empty address. There is no
26525 need to use this option unless you know that the called hosts make use of the
26526 sender when checking recipients. If used indiscriminately, it reduces the
26527 usefulness of callout caching.
26528 .endlist
26529
26530 If you use any of the parameters that set a non-empty sender for the MAIL
26531 command (&%mailfrom%&, &%postmaster_mailfrom%&, &%use_postmaster%&, or
26532 &%use_sender%&), you should think about possible loops. Recipient checking is
26533 usually done between two hosts that are under the same management, and the host
26534 that receives the callouts is not normally configured to do callouts itself.
26535 Therefore, it is normally safe to use &%use_postmaster%& or &%use_sender%& in
26536 these circumstances.
26537
26538 However, if you use a non-empty sender address for a callout to an arbitrary
26539 host, there is the likelihood that the remote host will itself initiate a
26540 callout check back to your host. As it is checking what appears to be a message
26541 sender, it is likely to use an empty address in MAIL, thus avoiding a
26542 callout loop. However, to be on the safe side it would be best to set up your
26543 own ACLs so that they do not do sender verification checks when the recipient
26544 is the address you use for header sender or postmaster callout checking.
26545
26546 Another issue to think about when using non-empty senders for callouts is
26547 caching. When you set &%mailfrom%& or &%use_sender%&, the cache record is keyed
26548 by the sender/recipient combination; thus, for any given recipient, many more
26549 actual callouts are performed than when an empty sender or postmaster is used.
26550
26551
26552
26553
26554 .section "Callout caching" "SECTcallvercache"
26555 .cindex "hints database" "callout cache"
26556 .cindex "callout" "caching"
26557 .cindex "caching" "callout"
26558 Exim caches the results of callouts in order to reduce the amount of resources
26559 used, unless you specify the &%no_cache%& parameter with the &%callout%&
26560 option. A hints database called &"callout"& is used for the cache. Two
26561 different record types are used: one records the result of a callout check for
26562 a specific address, and the other records information that applies to the
26563 entire domain (for example, that it accepts the local part &'postmaster'&).
26564
26565 When an original callout fails, a detailed SMTP error message is given about
26566 the failure. However, for subsequent failures use the cache data, this message
26567 is not available.
26568
26569 The expiry times for negative and positive address cache records are
26570 independent, and can be set by the global options &%callout_negative_expire%&
26571 (default 2h) and &%callout_positive_expire%& (default 24h), respectively.
26572
26573 If a host gives a negative response to an SMTP connection, or rejects any
26574 commands up to and including
26575 .code
26576 MAIL FROM:<>
26577 .endd
26578 (but not including the MAIL command with a non-empty address),
26579 any callout attempt is bound to fail. Exim remembers such failures in a
26580 domain cache record, which it uses to fail callouts for the domain without
26581 making new connections, until the domain record times out. There are two
26582 separate expiry times for domain cache records:
26583 &%callout_domain_negative_expire%& (default 3h) and
26584 &%callout_domain_positive_expire%& (default 7d).
26585
26586 Domain records expire when the negative expiry time is reached if callouts
26587 cannot be made for the domain, or if the postmaster check failed.
26588 Otherwise, they expire when the positive expiry time is reached. This
26589 ensures that, for example, a host that stops accepting &"random"& local parts
26590 will eventually be noticed.
26591
26592 The callout caching mechanism is based on the domain of the address that is
26593 being tested. If the domain routes to several hosts, it is assumed that their
26594 behaviour will be the same.
26595
26596
26597
26598 .section "Sender address verification reporting" "SECTsenaddver"
26599 .cindex "verifying" "suppressing error details"
26600 See section &<<SECTaddressverification>>& for a general discussion of
26601 verification. When sender verification fails in an ACL, the details of the
26602 failure are given as additional output lines before the 550 response to the
26603 relevant SMTP command (RCPT or DATA). For example, if sender callout is in use,
26604 you might see:
26605 .code
26606 MAIL FROM:<xyz@abc.example>
26607 250 OK
26608 RCPT TO:<pqr@def.example>
26609 550-Verification failed for <xyz@abc.example>
26610 550-Called:   192.168.34.43
26611 550-Sent:     RCPT TO:<xyz@abc.example>
26612 550-Response: 550 Unknown local part xyz in <xyz@abc.example>
26613 550 Sender verification failed
26614 .endd
26615 If more than one RCPT command fails in the same way, the details are given
26616 only for the first of them. However, some administrators do not want to send
26617 out this much information. You can suppress the details by adding
26618 &`/no_details`& to the ACL statement that requests sender verification. For
26619 example:
26620 .code
26621 verify = sender/no_details
26622 .endd
26623
26624 .section "Redirection while verifying" "SECTredirwhilveri"
26625 .cindex "verifying" "redirection while"
26626 .cindex "address redirection" "while verifying"
26627 A dilemma arises when a local address is redirected by aliasing or forwarding
26628 during verification: should the generated addresses themselves be verified,
26629 or should the successful expansion of the original address be enough to verify
26630 it? By default, Exim takes the following pragmatic approach:
26631
26632 .ilist
26633 When an incoming address is redirected to just one child address, verification
26634 continues with the child address, and if that fails to verify, the original
26635 verification also fails.
26636 .next
26637 When an incoming address is redirected to more than one child address,
26638 verification does not continue. A success result is returned.
26639 .endlist
26640
26641 This seems the most reasonable behaviour for the common use of aliasing as a
26642 way of redirecting different local parts to the same mailbox. It means, for
26643 example, that a pair of alias entries of the form
26644 .code
26645 A.Wol:   aw123
26646 aw123:   :fail: Gone away, no forwarding address
26647 .endd
26648 work as expected, with both local parts causing verification failure. When a
26649 redirection generates more than one address, the behaviour is more like a
26650 mailing list, where the existence of the alias itself is sufficient for
26651 verification to succeed.
26652
26653 It is possible, however, to change the default behaviour so that all successful
26654 redirections count as successful verifications, however many new addresses are
26655 generated. This is specified by the &%success_on_redirect%& verification
26656 option. For example:
26657 .code
26658 require verify = recipient/success_on_redirect/callout=10s
26659 .endd
26660 In this example, verification succeeds if a router generates a new address, and
26661 the callout does not occur, because no address was routed to a remote host.
26662
26663 .new
26664 When verification is being tested via the &%-bv%& option, the treatment of
26665 redirections is as just described, unless the &%-v%& or any debugging option is
26666 also specified. In that case, full verification is done for every generated
26667 address and a report is output for each of them.
26668 .wen
26669
26670
26671
26672 .section "Client SMTP authorization (CSA)" "SECTverifyCSA"
26673 .cindex "CSA" "verifying"
26674 Client SMTP Authorization is a system that allows a site to advertise
26675 which machines are and are not permitted to send email. This is done by placing
26676 special SRV records in the DNS; these are looked up using the client's HELO
26677 domain. At the time of writing, CSA is still an Internet Draft. Client SMTP
26678 Authorization checks in Exim are performed by the ACL condition:
26679 .code
26680 verify = csa
26681 .endd
26682 This fails if the client is not authorized. If there is a DNS problem, or if no
26683 valid CSA SRV record is found, or if the client is authorized, the condition
26684 succeeds. These three cases can be distinguished using the expansion variable
26685 &$csa_status$&, which can take one of the values &"fail"&, &"defer"&,
26686 &"unknown"&, or &"ok"&. The condition does not itself defer because that would
26687 be likely to cause problems for legitimate email.
26688
26689 The error messages produced by the CSA code include slightly more
26690 detail. If &$csa_status$& is &"defer"&, this may be because of problems
26691 looking up the CSA SRV record, or problems looking up the CSA target
26692 address record. There are four reasons for &$csa_status$& being &"fail"&:
26693
26694 .ilist
26695 The client's host name is explicitly not authorized.
26696 .next
26697 The client's IP address does not match any of the CSA target IP addresses.
26698 .next
26699 The client's host name is authorized but it has no valid target IP addresses
26700 (for example, the target's addresses are IPv6 and the client is using IPv4).
26701 .next
26702 The client's host name has no CSA SRV record but a parent domain has asserted
26703 that all subdomains must be explicitly authorized.
26704 .endlist
26705
26706 The &%csa%& verification condition can take an argument which is the domain to
26707 use for the DNS query. The default is:
26708 .code
26709 verify = csa/$sender_helo_name
26710 .endd
26711 This implementation includes an extension to CSA. If the query domain
26712 is an address literal such as [192.0.2.95], or if it is a bare IP
26713 address, Exim searches for CSA SRV records in the reverse DNS as if
26714 the HELO domain was (for example) &'95.2.0.192.in-addr.arpa'&. Therefore it is
26715 meaningful to say:
26716 .code
26717 verify = csa/$sender_host_address
26718 .endd
26719 In fact, this is the check that Exim performs if the client does not say HELO.
26720 This extension can be turned off by setting the main configuration option
26721 &%dns_csa_use_reverse%& to be false.
26722
26723 If a CSA SRV record is not found for the domain itself, a search
26724 is performed through its parent domains for a record which might be
26725 making assertions about subdomains. The maximum depth of this search is limited
26726 using the main configuration option &%dns_csa_search_limit%&, which is 5 by
26727 default. Exim does not look for CSA SRV records in a top level domain, so the
26728 default settings handle HELO domains as long as seven
26729 (&'hostname.five.four.three.two.one.com'&). This encompasses the vast majority
26730 of legitimate HELO domains.
26731
26732 The &'dnsdb'& lookup also has support for CSA. Although &'dnsdb'& also supports
26733 direct SRV lookups, this is not sufficient because of the extra parent domain
26734 search behaviour of CSA, and (as with PTR lookups) &'dnsdb'& also turns IP
26735 addresses into lookups in the reverse DNS space. The result of a successful
26736 lookup such as:
26737 .code
26738 ${lookup dnsdb {csa=$sender_helo_name}}
26739 .endd
26740 has two space-separated fields: an authorization code and a target host name.
26741 The authorization code can be &"Y"& for yes, &"N"& for no, &"X"& for explicit
26742 authorization required but absent, or &"?"& for unknown.
26743
26744
26745
26746
26747 .section "Bounce address tag validation" "SECTverifyPRVS"
26748 .cindex "BATV" "verifying"
26749 Bounce address tag validation (BATV) is a scheme whereby the envelope senders
26750 of outgoing messages have a cryptographic, timestamped &"tag"& added to them.
26751 Genuine incoming bounce messages should therefore always be addressed to
26752 recipients that have a valid tag. This scheme is a way of detecting unwanted
26753 bounce messages caused by sender address forgeries (often called &"collateral
26754 spam"&), because the recipients of such messages do not include valid tags.
26755
26756 There are two expansion items to help with the implementation of the BATV
26757 &"prvs"& (private signature) scheme in an Exim configuration. This scheme signs
26758 the original envelope sender address by using a simple key to add a hash of the
26759 address and some time-based randomizing information. The &%prvs%& expansion
26760 item creates a signed address, and the &%prvscheck%& expansion item checks one.
26761 The syntax of these expansion items is described in section
26762 &<<SECTexpansionitems>>&.
26763
26764 As an example, suppose the secret per-address keys are stored in an MySQL
26765 database. A query to look up the key for an address could be defined as a macro
26766 like this:
26767 .code
26768 PRVSCHECK_SQL = ${lookup mysql{SELECT secret FROM batv_prvs \
26769                 WHERE sender='${quote_mysql:$prvscheck_address}'\
26770                 }{$value}}
26771 .endd
26772 Suppose also that the senders who make use of BATV are defined by an address
26773 list called &%batv_senders%&. Then, in the ACL for RCPT commands, you could
26774 use this:
26775 .code
26776 # Bounces: drop unsigned addresses for BATV senders
26777 deny message = This address does not send an unsigned reverse path.
26778      senders = :
26779      recipients = +batv_senders
26780
26781 # Bounces: In case of prvs-signed address, check signature.
26782 deny message = Invalid reverse path signature.
26783      senders = :
26784      condition  = ${prvscheck {$local_part@$domain}\
26785                   {PRVSCHECK_SQL}{1}}
26786      !condition = $prvscheck_result
26787 .endd
26788 The first statement rejects recipients for bounce messages that are addressed
26789 to plain BATV sender addresses, because it is known that BATV senders do not
26790 send out messages with plain sender addresses. The second statement rejects
26791 recipients that are prvs-signed, but with invalid signatures (either because
26792 the key is wrong, or the signature has timed out).
26793
26794 A non-prvs-signed address is not rejected by the second statement, because the
26795 &%prvscheck%& expansion yields an empty string if its first argument is not a
26796 prvs-signed address, thus causing the &%condition%& condition to be false. If
26797 the first argument is a syntactically valid prvs-signed address, the yield is
26798 the third string (in this case &"1"&), whether or not the cryptographic and
26799 timeout checks succeed. The &$prvscheck_result$& variable contains the result
26800 of the checks (empty for failure, &"1"& for success).
26801
26802 There are two more issues you must consider when implementing prvs-signing.
26803 Firstly, you need to ensure that prvs-signed addresses are not blocked by your
26804 ACLs. A prvs-signed address contains a slash character, but the default Exim
26805 configuration contains this statement in the RCPT ACL:
26806 .code
26807 deny    message       = Restricted characters in address
26808         domains       = +local_domains
26809         local_parts   = ^[.] : ^.*[@%!/|]
26810 .endd
26811 This is a conservative rule that blocks local parts that contain slashes. You
26812 should remove the slash in the last line.
26813
26814 Secondly, you have to ensure that the routers accept prvs-signed addresses and
26815 deliver them correctly. The easiest way to handle this is to use a &(redirect)&
26816 router to remove the signature with a configuration along these lines:
26817 .code
26818 batv_redirect:
26819   driver = redirect
26820   data = ${prvscheck {$local_part@$domain}{PRVSCHECK_SQL}}
26821 .endd
26822 This works because, if the third argument of &%prvscheck%& is empty, the result
26823 of the expansion of a prvs-signed address is the decoded value of the original
26824 address. This router should probably be the first of your routers that handles
26825 local addresses.
26826
26827 To create BATV-signed addresses in the first place, a transport of this form
26828 can be used:
26829 .code
26830 external_smtp_batv:
26831   driver = smtp
26832   return_path = ${prvs {$return_path} \
26833                        {${lookup mysql{SELECT \
26834                        secret FROM batv_prvs WHERE \
26835                        sender='${quote_mysql:$sender_address}'} \
26836                        {$value}fail}}}
26837 .endd
26838 If no key can be found for the existing return path, no signing takes place.
26839
26840
26841
26842 .section "Using an ACL to control relaying" "SECTrelaycontrol"
26843 .cindex "&ACL;" "relay control"
26844 .cindex "relaying" "control by ACL"
26845 .cindex "policy control" "relay control"
26846 An MTA is said to &'relay'& a message if it receives it from some host and
26847 delivers it directly to another host as a result of a remote address contained
26848 within it. Redirecting a local address via an alias or forward file and then
26849 passing the message on to another host is not relaying,
26850 .cindex "&""percent hack""&"
26851 but a redirection as a result of the &"percent hack"& is.
26852
26853 Two kinds of relaying exist, which are termed &"incoming"& and &"outgoing"&.
26854 A host which is acting as a gateway or an MX backup is concerned with incoming
26855 relaying from arbitrary hosts to a specific set of domains. On the other hand,
26856 a host which is acting as a smart host for a number of clients is concerned
26857 with outgoing relaying from those clients to the Internet at large. Often the
26858 same host is fulfilling both functions,
26859 . ///
26860 . as illustrated in the diagram below,
26861 . ///
26862 but in principle these two kinds of relaying are entirely independent. What is
26863 not wanted is the transmission of mail from arbitrary remote hosts through your
26864 system to arbitrary domains.
26865
26866
26867 You can implement relay control by means of suitable statements in the ACL that
26868 runs for each RCPT command. For convenience, it is often easiest to use
26869 Exim's named list facility to define the domains and hosts involved. For
26870 example, suppose you want to do the following:
26871
26872 .ilist
26873 Deliver a number of domains to mailboxes on the local host (or process them
26874 locally in some other way). Let's say these are &'my.dom1.example'& and
26875 &'my.dom2.example'&.
26876 .next
26877 Relay mail for a number of other domains for which you are the secondary MX.
26878 These might be &'friend1.example'& and &'friend2.example'&.
26879 .next
26880 Relay mail from the hosts on your local LAN, to whatever domains are involved.
26881 Suppose your LAN is 192.168.45.0/24.
26882 .endlist
26883
26884
26885 In the main part of the configuration, you put the following definitions:
26886 .code
26887 domainlist local_domains = my.dom1.example : my.dom2.example
26888 domainlist relay_domains = friend1.example : friend2.example
26889 hostlist   relay_hosts   = 192.168.45.0/24
26890 .endd
26891 Now you can use these definitions in the ACL that is run for every RCPT
26892 command:
26893 .code
26894 acl_check_rcpt:
26895   accept domains = +local_domains : +relay_domains
26896   accept hosts   = +relay_hosts
26897 .endd
26898 The first statement accepts any RCPT command that contains an address in
26899 the local or relay domains. For any other domain, control passes to the second
26900 statement, which accepts the command only if it comes from one of the relay
26901 hosts. In practice, you will probably want to make your ACL more sophisticated
26902 than this, for example, by including sender and recipient verification. The
26903 default configuration includes a more comprehensive example, which is described
26904 in chapter &<<CHAPdefconfil>>&.
26905
26906
26907
26908 .section "Checking a relay configuration" "SECTcheralcon"
26909 .cindex "relaying" "checking control of"
26910 You can check the relay characteristics of your configuration in the same way
26911 that you can test any ACL behaviour for an incoming SMTP connection, by using
26912 the &%-bh%& option to run a fake SMTP session with which you interact.
26913
26914 For specifically testing for unwanted relaying, the host
26915 &'relay-test.mail-abuse.org'& provides a useful service. If you telnet to this
26916 host from the host on which Exim is running, using the normal telnet port, you
26917 will see a normal telnet connection message and then quite a long delay. Be
26918 patient. The remote host is making an SMTP connection back to your host, and
26919 trying a number of common probes to test for open relay vulnerability. The
26920 results of the tests will eventually appear on your terminal.
26921 .ecindex IIDacl
26922
26923
26924
26925 . ////////////////////////////////////////////////////////////////////////////
26926 . ////////////////////////////////////////////////////////////////////////////
26927
26928 .chapter "Content scanning at ACL time" "CHAPexiscan"
26929 .scindex IIDcosca "content scanning" "at ACL time"
26930 The extension of Exim to include content scanning at ACL time, formerly known
26931 as &"exiscan"&, was originally implemented as a patch by Tom Kistner. The code
26932 was integrated into the main source for Exim release 4.50, and Tom continues to
26933 maintain it. Most of the wording of this chapter is taken from Tom's
26934 specification.
26935
26936 It is also possible to scan the content of messages at other times. The
26937 &[local_scan()]& function (see chapter &<<CHAPlocalscan>>&) allows for content
26938 scanning after all the ACLs have run. A transport filter can be used to scan
26939 messages at delivery time (see the &%transport_filter%& option, described in
26940 chapter &<<CHAPtransportgeneric>>&).
26941
26942 If you want to include the ACL-time content-scanning features when you compile
26943 Exim, you need to arrange for WITH_CONTENT_SCAN to be defined in your
26944 &_Local/Makefile_&. When you do that, the Exim binary is built with:
26945
26946 .ilist
26947 Two additional ACLs (&%acl_smtp_mime%& and &%acl_not_smtp_mime%&) that are run
26948 for all MIME parts for SMTP and non-SMTP messages, respectively.
26949 .next
26950 Additional ACL conditions and modifiers: &%decode%&, &%malware%&,
26951 &%mime_regex%&, &%regex%&, and &%spam%&. These can be used in the ACL that is
26952 run at the end of message reception (the &%acl_smtp_data%& ACL).
26953 .next
26954 An additional control feature (&"no_mbox_unspool"&) that saves spooled copies
26955 of messages, or parts of messages, for debugging purposes.
26956 .next
26957 Additional expansion variables that are set in the new ACL and by the new
26958 conditions.
26959 .next
26960 Two new main configuration options: &%av_scanner%& and &%spamd_address%&.
26961 .endlist
26962
26963 There is another content-scanning configuration option for &_Local/Makefile_&,
26964 called WITH_OLD_DEMIME. If this is set, the old, deprecated &%demime%& ACL
26965 condition is compiled, in addition to all the other content-scanning features.
26966
26967 Content-scanning is continually evolving, and new features are still being
26968 added. While such features are still unstable and liable to incompatible
26969 changes, they are made available in Exim by setting options whose names begin
26970 EXPERIMENTAL_ in &_Local/Makefile_&. Such features are not documented in
26971 this manual. You can find out about them by reading the file called
26972 &_doc/experimental.txt_&.
26973
26974 All the content-scanning facilites work on a MBOX copy of the message that is
26975 temporarily created in a file called:
26976 .display
26977 <&'spool_directory'&>&`/scan/`&<&'message_id'&>/<&'message_id'&>&`.eml`&
26978 .endd
26979 The &_.eml_& extension is a friendly hint to virus scanners that they can
26980 expect an MBOX-like structure inside that file. The file is created when the
26981 first content scanning facility is called. Subsequent calls to content
26982 scanning conditions open the same file again. The directory is recursively
26983 removed when the &%acl_smtp_data%& ACL has finished running, unless
26984 .code
26985 control = no_mbox_unspool
26986 .endd
26987 has been encountered. When the MIME ACL decodes files, they are put into the
26988 same directory by default.
26989
26990
26991
26992 .section "Scanning for viruses" "SECTscanvirus"
26993 .cindex "virus scanning"
26994 .cindex "content scanning" "for viruses"
26995 .cindex "content scanning" "the &%malware%& condition"
26996 The &%malware%& ACL condition lets you connect virus scanner software to Exim.
26997 It supports a &"generic"& interface to scanners called via the shell, and
26998 specialized interfaces for &"daemon"& type virus scanners, which are resident
26999 in memory and thus are much faster.
27000
27001 .cindex "&%av_scanner%&"
27002 You can set the &%av_scanner%& option in first part of the Exim configuration
27003 file to specify which scanner to use, together with any additional options that
27004 are needed. The basic syntax is as follows:
27005 .display
27006 &`av_scanner = <`&&'scanner-type'&&`>:<`&&'option1'&&`>:<`&&'option2'&&`>:[...]`&
27007 .endd
27008 If you do not set &%av_scanner%&, it defaults to
27009 .code
27010 av_scanner = sophie:/var/run/sophie
27011 .endd
27012 If the value of &%av_scanner%& starts with dollar character, it is expanded
27013 before use. The following scanner types are supported in this release:
27014
27015 .vlist
27016 .vitem &%aveserver%&
27017 .cindex "virus scanners" "Kaspersky"
27018 This is the scanner daemon of Kaspersky Version 5. You can get a trial version
27019 at &url(http://www.kaspersky.com). This scanner type takes one option,
27020 which is the path to the daemon's UNIX socket. The default is shown in this
27021 example:
27022 .code
27023 av_scanner = aveserver:/var/run/aveserver
27024 .endd
27025
27026 .vitem &%clamd%&
27027 .cindex "virus scanners" "clamd"
27028 This daemon-type scanner is GPL and free. You can get it at
27029 &url(http://www.clamav.net/). Some older versions of clamd do not seem to
27030 unpack MIME containers, so it used to be recommended to unpack MIME attachments
27031 in the MIME ACL. This no longer believed to be necessary. One option is
27032 required: either the path and name of a UNIX socket file, or a hostname or IP
27033 number, and a port, separated by space, as in the second of these examples:
27034 .code
27035 av_scanner = clamd:/opt/clamd/socket
27036 av_scanner = clamd:192.168.2.100 1234
27037 .endd
27038 If the option is unset, the default is &_/tmp/clamd_&. Thanks to David Saez for
27039 contributing the code for this scanner.
27040
27041 .vitem &%cmdline%&
27042 .cindex "virus scanners" "command line interface"
27043 This is the keyword for the generic command line scanner interface. It can be
27044 used to attach virus scanners that are invoked from the shell. This scanner
27045 type takes 3 mandatory options:
27046
27047 .olist
27048 The full path and name of the scanner binary, with all command line options,
27049 and a placeholder (&`%s`&) for the directory to scan.
27050
27051 .next
27052 A regular expression to match against the STDOUT and STDERR output of the
27053 virus scanner. If the expression matches, a virus was found. You must make
27054 absolutely sure that this expression matches on &"virus found"&. This is called
27055 the &"trigger"& expression.
27056
27057 .next
27058 Another regular expression, containing exactly one pair of parentheses, to
27059 match the name of the virus found in the scanners output. This is called the
27060 &"name"& expression.
27061 .endlist olist
27062
27063 For example, Sophos Sweep reports a virus on a line like this:
27064 .code
27065 Virus 'W32/Magistr-B' found in file ./those.bat
27066 .endd
27067 .new
27068 For the trigger expression, we can match the phrase &"found in file"&. For the
27069 name expression, we want to extract the W32/Magistr-B string, so we can match
27070 for the single quotes left and right of it. Altogether, this makes the
27071 configuration setting:
27072 .code
27073 av_scanner = cmdline:\
27074              /path/to/sweep -ss -all -rec -archive %s:\
27075              found in file:'(.+)'
27076 .endd
27077 .vitem &%drweb%&
27078 .cindex "virus scanners" "DrWeb"
27079 The DrWeb daemon scanner (&url(http://www.sald.com/)) interface takes one
27080 argument, either a full path to a UNIX socket, or an IP address and port
27081 separated by white space, as in these examples:
27082 .code
27083 av_scanner = drweb:/var/run/drwebd.sock
27084 av_scanner = drweb:192.168.2.20 31337
27085 .endd
27086 If you omit the argument, the default path &_/usr/local/drweb/run/drwebd.sock_&
27087 is used. Thanks to Alex Miller for contributing the code for this scanner.
27088
27089 .vitem &%fsecure%&
27090 .cindex "virus scanners" "F-Secure"
27091 The F-Secure daemon scanner (&url(http://www.f-secure.com)) takes one
27092 argument which is the path to a UNIX socket. For example:
27093 .code
27094 av_scanner = fsecure:/path/to/.fsav
27095 .endd
27096 If no argument is given, the default is &_/var/run/.fsav_&. Thanks to Johan
27097 Thelmen for contributing the code for this scanner.
27098
27099 .vitem &%kavdaemon%&
27100 .cindex "virus scanners" "Kaspersky"
27101 This is the scanner daemon of Kaspersky Version 4. This version of the
27102 Kaspersky scanner is outdated. Please upgrade (see &%aveserver%& above). This
27103 scanner type takes one option, which is the path to the daemon's UNIX socket.
27104 For example:
27105 .code
27106 av_scanner = kavdaemon:/opt/AVP/AvpCtl
27107 .endd
27108 The default path is &_/var/run/AvpCtl_&.
27109
27110 .vitem &%mksd%&
27111 .cindex "virus scanners" "mksd"
27112 This is a daemon type scanner that is aimed mainly at Polish users, though some
27113 parts of documentation are now available in English. You can get it at
27114 &url(http://linux.mks.com.pl/). The only option for this scanner type is
27115 the maximum number of processes used simultaneously to scan the attachments,
27116 provided that the demime facility is employed and also provided that mksd has
27117 been run with at least the same number of child processes. For example:
27118 .code
27119 av_scanner = mksd:2
27120 .endd
27121 You can safely omit this option (the default value is 1).
27122
27123 .vitem &%sophie%&
27124 .cindex "virus scanners" "Sophos and Sophie"
27125 Sophie is a daemon that uses Sophos' &%libsavi%& library to scan for viruses.
27126 You can get Sophie at &url(http://www.clanfield.info/sophie/). The only option
27127 for this scanner type is the path to the UNIX socket that Sophie uses for
27128 client communication. For example:
27129 .code
27130 av_scanner = sophie:/tmp/sophie
27131 .endd
27132 The default path is &_/var/run/sophie_&, so if you are using this, you can omit
27133 the option.
27134 .endlist
27135
27136 When &%av_scanner%& is correctly set, you can use the &%malware%& condition in
27137 the DATA ACL. &*Note*&: You cannot use the &%malware%& condition in the MIME
27138 ACL.
27139
27140 The &%av_scanner%& option is expanded each time &%malware%& is called. This
27141 makes it possible to use different scanners. See further below for an example.
27142 The &%malware%& condition caches its results, so when you use it multiple times
27143 for the same message, the actual scanning process is only carried out once.
27144 However, using expandable items in &%av_scanner%& disables this caching, in
27145 which case each use of the &%malware%& condition causes a new scan of the
27146 message.
27147
27148 The &%malware%& condition takes a right-hand argument that is expanded before
27149 use. It can then be one of
27150
27151 .ilist
27152 &"true"&, &"*"&, or &"1"&, in which case the message is scanned for viruses.
27153 The condition succeeds if a virus was found, and fail otherwise. This is the
27154 recommended usage.
27155 .next
27156 &"false"& or &"0"& or an empty string, in which case no scanning is done and
27157 the condition fails immediately.
27158 .next
27159 A regular expression, in which case the message is scanned for viruses. The
27160 condition succeeds if a virus is found and its name matches the regular
27161 expression. This allows you to take special actions on certain types of virus.
27162 .endlist
27163
27164 You can append &`/defer_ok`& to the &%malware%& condition to accept messages
27165 even if there is a problem with the virus scanner. Otherwise, such a problem
27166 causes the ACL to defer.
27167
27168 .cindex "&$malware_name$&"
27169 When a virus is found, the condition sets up an expansion variable called
27170 &$malware_name$& that contains the name of the virus. You can use it in a
27171 &%message%& modifier that specifies the error returned to the sender, and/or in
27172 logging data.
27173
27174 If your virus scanner cannot unpack MIME and TNEF containers itself, you should
27175 use the &%demime%& condition (see section &<<SECTdemimecond>>&) before the
27176 &%malware%& condition.
27177
27178 Here is a very simple scanning example:
27179 .code
27180 deny message = This message contains malware ($malware_name)
27181      demime = *
27182      malware = *
27183 .endd
27184 The next example accepts messages when there is a problem with the scanner:
27185 .code
27186 deny message = This message contains malware ($malware_name)
27187      demime = *
27188      malware = */defer_ok
27189 .endd
27190 The next example shows how to use an ACL variable to scan with both sophie and
27191 aveserver. It assumes you have set:
27192 .code
27193 av_scanner = $acl_m0
27194 .endd
27195 in the main Exim configuration.
27196 .code
27197 deny message = This message contains malware ($malware_name)
27198      set acl_m0 = sophie
27199      malware = *
27200
27201 deny message = This message contains malware ($malware_name)
27202      set acl_m0 = aveserver
27203      malware = *
27204 .endd
27205
27206
27207 .section "Scanning with SpamAssassin" "SECTscanspamass"
27208 .cindex "content scanning" "for spam"
27209 .cindex "spam scanning"
27210 .cindex "SpamAssassin" "scanning with"
27211 The &%spam%& ACL condition calls SpamAssassin's &%spamd%& daemon to get a spam
27212 score and a report for the message. You can get SpamAssassin at
27213 &url(http://www.spamassassin.org), or, if you have a working Perl
27214 installation, you can use CPAN by running:
27215 .code
27216 perl -MCPAN -e 'install Mail::SpamAssassin'
27217 .endd
27218 SpamAssassin has its own set of configuration files. Please review its
27219 documentation to see how you can tweak it. The default installation should work
27220 nicely, however.
27221
27222 .cindex "&%spamd_address%&"
27223 After having installed and configured SpamAssassin, start the &%spamd%& daemon.
27224 By default, it listens on 127.0.0.1, TCP port 783. If you use another host or
27225 port for &%spamd%&, you must set the &%spamd_address%& option in the global
27226 part of the Exim configuration as follows (example):
27227 .code
27228 spamd_address = 192.168.99.45 387
27229 .endd
27230 You do not need to set this option if you use the default. As of version 2.60,
27231 &%spamd%& also supports communication over UNIX sockets. If you want to use
27232 these, supply &%spamd_address%& with an absolute file name instead of a
27233 address/port pair:
27234 .code
27235 spamd_address = /var/run/spamd_socket
27236 .endd
27237 You can have multiple &%spamd%& servers to improve scalability. These can
27238 reside on other hardware reachable over the network. To specify multiple
27239 &%spamd%& servers, put multiple address/port pairs in the &%spamd_address%&
27240 option, separated with colons:
27241 .code
27242 spamd_address = 192.168.2.10 783 : \
27243                 192.168.2.11 783 : \
27244                 192.168.2.12 783
27245 .endd
27246 Up to 32 &%spamd%& servers are supported. The servers are queried in a random
27247 fashion. When a server fails to respond to the connection attempt, all other
27248 servers are tried until one succeeds. If no server responds, the &%spam%&
27249 condition defers.
27250
27251 &*Warning*&: It is not possible to use the UNIX socket connection method with
27252 multiple &%spamd%& servers.
27253
27254
27255 .section "Calling SpamAssassin from an Exim ACL"
27256 Here is a simple example of the use of the &%spam%& condition in a DATA ACL:
27257 .code
27258 deny message = This message was classified as SPAM
27259      spam = joe
27260 .endd
27261 .new
27262 The right-hand side of the &%spam%& condition specifies a name. This is
27263 relevant if you have set up multiple SpamAssassin profiles. If you do not want
27264 to scan using a specific profile, but rather use the SpamAssassin system-wide
27265 default profile, you can scan for an unknown name, or simply use &"nobody"&.
27266 However, you must put something on the right-hand side.
27267
27268 The name allows you to use per-domain or per-user antispam profiles in
27269 principle, but this is not straightforward in practice, because a message may
27270 have multiple recipients, not necessarily all in the same domain. Because the
27271 &%spam%& condition has to be called from a DATA ACL in order to be able to
27272 read the contents of the message, the variables &$local_part$& and &$domain$&
27273 are not set.
27274
27275 The right-hand side of the &%spam%& condition is expanded before being used, so
27276 you can put lookups or conditions there. When the right-hand side evaluates to
27277 &"0"& or &"false"&, no scanning is done and the condition fails immediately.
27278 .wen
27279
27280
27281 Scanning with SpamAssassin uses a lot of resources. If you scan every message,
27282 large ones may cause significant performance degredation. As most spam messages
27283 are quite small, it is recommended that you do not scan the big ones. For
27284 example:
27285 .code
27286 deny message = This message was classified as SPAM
27287      condition = ${if < {$message_size}{10K}}
27288      spam = nobody
27289 .endd
27290
27291 The &%spam%& condition returns true if the threshold specified in the user's
27292 SpamAssassin profile has been matched or exceeded. If you want to use the
27293 &%spam%& condition for its side effects (see the variables below), you can make
27294 it always return &"true"& by appending &`:true`& to the username.
27295
27296 .cindex "spam scanning" "returned variables"
27297 When the &%spam%& condition is run, it sets up a number of expansion
27298 variables. With the exception of &$spam_score_int$&, these are usable only
27299 within ACLs; their values are not retained with the message and so cannot be
27300 used at delivery time.
27301
27302 .vlist
27303 .vitem &$spam_score$&
27304 The spam score of the message, for example &"3.4"& or &"30.5"&. This is useful
27305 for inclusion in log or reject messages.
27306
27307 .vitem &$spam_score_int$&
27308 The spam score of the message, multiplied by ten, as an integer value. For
27309 example &"34"& or &"305"&. This is useful for numeric comparisons in
27310 conditions. This variable is special; its value is saved with the message, and
27311 written to Exim's spool file. This means that it can be used during the whole
27312 life of the message on your Exim system, in particular, in routers or
27313 transports during the later delivery phase.
27314
27315 .vitem &$spam_bar$&
27316 A string consisting of a number of &"+"& or &"-"& characters, representing the
27317 integer part of the spam score value. A spam score of 4.4 would have a
27318 &$spam_bar$& value of &"++++"&. This is useful for inclusion in warning
27319 headers, since MUAs can match on such strings.
27320
27321 .vitem &$spam_report$&
27322 A multiline text table, containing the full SpamAssassin report for the
27323 message. Useful for inclusion in headers or reject messages.
27324 .endlist
27325
27326 The &%spam%& condition caches its results. If you call it again with the same
27327 user name, it does not scan again, but rather returns the same values as
27328 before.
27329
27330 The &%spam%& condition returns DEFER if there is any error while running the
27331 message through SpamAssassin. If you want to treat DEFER as FAIL (to pass on to
27332 the next ACL statement block), append &`/defer_ok`& to the right-hand side of
27333 the spam condition, like this:
27334 .code
27335 deny message = This message was classified as SPAM
27336      spam    = joe/defer_ok
27337 .endd
27338 This causes messages to be accepted even if there is a problem with &%spamd%&.
27339
27340 Here is a longer, commented example of the use of the &%spam%&
27341 condition:
27342 .code
27343 # put headers in all messages (no matter if spam or not)
27344 warn  spam = nobody:true
27345       add_header = X-Spam-Score: $spam_score ($spam_bar)
27346       add_header = X-Spam-Report: $spam_report
27347
27348 # add second subject line with *SPAM* marker when message
27349 # is over threshold
27350 warn  spam = nobody
27351       add_header = Subject: *SPAM* $h_Subject:
27352
27353 # reject spam at high scores (> 12)
27354 deny  message = This message scored $spam_score spam points.
27355       spam = nobody:true
27356       condition = ${if >{$spam_score_int}{120}{1}{0}}
27357 .endd
27358
27359
27360
27361 .section "Scanning MIME parts" "SECTscanmimepart"
27362 .cindex "content scanning" "MIME parts"
27363 .cindex "MIME content scanning"
27364 .cindex "&%acl_smtp_mime%&"
27365 .cindex "&%acl_not_smtp_mime%&"
27366 The &%acl_smtp_mime%& global option specifies an ACL that is called once for
27367 each MIME part of an SMTP message, including multipart types, in the sequence
27368 of their position in the message. Similarly, the &%acl_not_smtp_mime%& option
27369 specifies an ACL that is used for the MIME parts of non-SMTP messages. These
27370 options may both refer to the same ACL if you want the same processing in both
27371 cases.
27372
27373 These ACLs are called (possibly many times) just before the
27374 &%acl_smtp_data%& ACL in the case of an SMTP message, or just before the
27375 &%acl_not_smtp%& ACL in the case of a non-SMTP message. However, a MIME ACL
27376 is called only if the message contains a &'MIME-Version:'& header line. When a
27377 call to a MIME ACL does not yield &"accept"&, ACL processing is aborted and the
27378 appropriate result code is sent to the client. In the case of an SMTP message,
27379 the &%acl_smtp_data%& ACL is not called when this happens.
27380
27381 You cannot use the &%malware%& or &%spam%& conditions in a MIME ACL; these can
27382 only be used in the DATA or non-SMTP ACLs. However, you can use the &%regex%&
27383 condition to match against the raw MIME part. You can also use the
27384 &%mime_regex%& condition to match against the decoded MIME part (see section
27385 &<<SECTscanregex>>&).
27386
27387 At the start of a MIME ACL, a number of variables are set from the header
27388 information for the relevant MIME part. These are described below. The contents
27389 of the MIME part are not by default decoded into a disk file except for MIME
27390 parts whose content-type is &"message/rfc822"&. If you want to decode a MIME
27391 part into a disk file, you can use the &%decode%& modifier. The general syntax
27392 is:
27393 .display
27394 &`decode = [/`&<&'path'&>&`/]`&<&'filename'&>
27395 .endd
27396 The right hand side is expanded before use. After expansion,
27397 the value can be:
27398
27399 .olist
27400 &"0"& or &"false"&, in which case no decoding is done.
27401 .next
27402 The string &"default"&. In that case, the file is put in the temporary
27403 &"default"& directory <&'spool_directory'&>&_/scan/_&<&'message_id'&>&_/_& with
27404 a sequential file name consisting of the message id and a sequence number. The
27405 full path and name is available in &$mime_decoded_filename$& after decoding.
27406 .next
27407 A full path name starting with a slash. If the full name is an existing
27408 directory, it is used as a replacement for the default directory. The filename
27409 is then sequentially assigned. If the path does not exist, it is used as
27410 the full path and file name.
27411 .next
27412 If the string does not start with a slash, it is used as the
27413 filename, and the default path is then used.
27414 .endlist
27415
27416 You can easily decode a file with its original, proposed filename using
27417 .code
27418 decode = $mime_filename
27419 .endd
27420 However, you should keep in mind that &$mime_filename$& might contain
27421 anything. If you place files outside of the default path, they are not
27422 automatically unlinked.
27423
27424 For RFC822 attachments (these are messages attached to messages, with a
27425 content-type of &"message/rfc822"&), the ACL is called again in the same manner
27426 as for the primary message, only that the &$mime_is_rfc822$& expansion
27427 variable is set (see below). Attached messages are always decoded to disk
27428 before being checked, and the files are unlinked once the check is done.
27429
27430 The MIME ACL supports the &%regex%& and &%mime_regex%& conditions. These can be
27431 used to match regular expressions against raw and decoded MIME parts,
27432 respectively. They are described in section &<<SECTscanregex>>&.
27433
27434 .cindex "MIME content scanning" "returned variables"
27435 The following list describes all expansion variables that are
27436 available in the MIME ACL:
27437
27438 .vlist
27439 .vitem &$mime_boundary$&
27440 If the current part is a multipart (see &$mime_is_multipart$&) below, it should
27441 have a boundary string, which is stored in this variable. If the current part
27442 has no boundary parameter in the &'Content-Type:'& header, this variable
27443 contains the empty string.
27444
27445 .vitem &$mime_charset$&
27446 This variable contains the character set identifier, if one was found in the
27447 &'Content-Type:'& header. Examples for charset identifiers are:
27448 .code
27449 us-ascii
27450 gb2312 (Chinese)
27451 iso-8859-1
27452 .endd
27453 Please note that this value is not normalized, so you should do matches
27454 case-insensitively.
27455
27456 .vitem &$mime_content_description$&
27457 This variable contains the normalized content of the &'Content-Description:'&
27458 header. It can contain a human-readable description of the parts content. Some
27459 implementations repeat the filename for attachments here, but they are usually
27460 only used for display purposes.
27461
27462 .vitem &$mime_content_disposition$&
27463 This variable contains the normalized content of the &'Content-Disposition:'&
27464 header. You can expect strings like &"attachment"& or &"inline"& here.
27465
27466 .vitem &$mime_content_id$&
27467 This variable contains the normalized content of the &'Content-ID:'& header.
27468 This is a unique ID that can be used to reference a part from another part.
27469
27470 .vitem &$mime_content_size$&
27471 This variable is set only after the &%decode%& modifier (see above) has been
27472 successfully run. It contains the size of the decoded part in kilobytes. The
27473 size is always rounded up to full kilobytes, so only a completely empty part
27474 has a &$mime_content_size$& of zero.
27475
27476 .vitem &$mime_content_transfer_encoding$&
27477 This variable contains the normalized content of the
27478 &'Content-transfer-encoding:'& header. This is a symbolic name for an encoding
27479 type. Typical values are &"base64"& and &"quoted-printable"&.
27480
27481 .vitem &$mime_content_type$&
27482 If the MIME part has a &'Content-Type:'& header, this variable contains its
27483 value, lowercased, and without any options (like &"name"& or &"charset"&). Here
27484 are some examples of popular MIME types, as they may appear in this variable:
27485 .code
27486 text/plain
27487 text/html
27488 application/octet-stream
27489 image/jpeg
27490 audio/midi
27491 .endd
27492 If the MIME part has no &'Content-Type:'& header, this variable contains the
27493 empty string.
27494
27495 .vitem &$mime_decoded_filename$&
27496 This variable is set only after the &%decode%& modifier (see above) has been
27497 successfully run. It contains the full path and file name of the file
27498 containing the decoded data.
27499 .endlist
27500
27501 .cindex "RFC 2047"
27502 .vlist
27503 .vitem &$mime_filename$&
27504 This is perhaps the most important of the MIME variables. It contains a
27505 proposed filename for an attachment, if one was found in either the
27506 &'Content-Type:'& or &'Content-Disposition:'& headers. The filename will be
27507 RFC2047 decoded, but no additional sanity checks are done. If no filename was
27508 found, this variable contains the empty string.
27509
27510 .vitem &$mime_is_coverletter$&
27511 This variable attempts to differentiate the &"cover letter"& of an e-mail from
27512 attached data. It can be used to clamp down on flashy or unneccessarily encoded
27513 content in the cover letter, while not restricting attachments at all.
27514
27515 The variable contains 1 (true) for a MIME part believed to be part of the
27516 cover letter, and 0 (false) for an attachment. At present, the algorithm is as
27517 follows:
27518
27519 .olist
27520 The outermost MIME part of a message is always a cover letter.
27521
27522 .next
27523 If a multipart/alternative or multipart/related MIME part is a cover letter,
27524 so are all MIME subparts within that multipart.
27525
27526 .next
27527 If any other multipart is a cover letter, the first subpart is a cover letter,
27528 and the rest are attachments.
27529
27530 .next
27531 All parts contained within an attachment multipart are attachments.
27532 .endlist olist
27533
27534 As an example, the following will ban &"HTML mail"& (including that sent with
27535 alternative plain text), while allowing HTML files to be attached. HTML
27536 coverletter mail attached to non-HMTL coverletter mail will also be allowed:
27537 .code
27538 deny message = HTML mail is not accepted here
27539 !condition = $mime_is_rfc822
27540 condition = $mime_is_coverletter
27541 condition = ${if eq{$mime_content_type}{text/html}{1}{0}}
27542 .endd
27543 .vitem &$mime_is_multipart$&
27544 This variable has the value 1 (true) when the current part has the main type
27545 &"multipart"&, for example &"multipart/alternative"& or &"multipart/mixed"&.
27546 Since multipart entities only serve as containers for other parts, you may not
27547 want to carry out specific actions on them.
27548
27549 .vitem &$mime_is_rfc822$&
27550 This variable has the value 1 (true) if the current part is not a part of the
27551 checked message itself, but part of an attached message. Attached message
27552 decoding is fully recursive.
27553
27554 .vitem &$mime_part_count$&
27555 This variable is a counter that is raised for each processed MIME part. It
27556 starts at zero for the very first part (which is usually a multipart). The
27557 counter is per-message, so it is reset when processing RFC822 attachments (see
27558 &$mime_is_rfc822$&). The counter stays set after &%acl_smtp_mime%& is
27559 complete, so you can use it in the DATA ACL to determine the number of MIME
27560 parts of a message. For non-MIME messages, this variable contains the value -1.
27561 .endlist
27562
27563
27564
27565 .section "Scanning with regular expressions" "SECTscanregex"
27566 .cindex "content scanning" "with regular expressions"
27567 .cindex "regular expressions" "content scanning with"
27568 You can specify your own custom regular expression matches on the full body of
27569 the message, or on individual MIME parts.
27570
27571 The &%regex%& condition takes one or more regular expressions as arguments and
27572 matches them against the full message (when called in the DATA ACL) or a raw
27573 MIME part (when called in the MIME ACL). The &%regex%& condition matches
27574 linewise, with a maximum line length of 32K characters. That means you cannot
27575 have multiline matches with the &%regex%& condition.
27576
27577 The &%mime_regex%& condition can be called only in the MIME ACL. It matches up
27578 to 32K of decoded content (the whole content at once, not linewise). If the
27579 part has not been decoded with the &%decode%& modifier earlier in the ACL, it
27580 is decoded automatically when &%mime_regex%& is executed (using default path
27581 and filename values). If the decoded data is larger than  32K, only the first
27582 32K characters are checked.
27583
27584 The regular expressions are passed as a colon-separated list. To include a
27585 literal colon, you must double it. Since the whole right-hand side string is
27586 expanded before being used, you must also escape dollar signs and backslashes
27587 with more backslashes, or use the &`\N`& facility to disable expansion.
27588 Here is a simple example that contains two regular expressions:
27589 .code
27590 deny message = contains blacklisted regex ($regex_match_string)
27591      regex = [Mm]ortgage : URGENT BUSINESS PROPOSAL
27592 .endd
27593 The conditions returns true if any one of the regular expressions matches. The
27594 &$regex_match_string$& expansion variable is then set up and contains the
27595 matching regular expression.
27596
27597 &*Warning*&: With large messages, these conditions can be fairly
27598 CPU-intensive.
27599
27600
27601
27602
27603 .section "The demime condition" "SECTdemimecond"
27604 .cindex "content scanning" "MIME checking"
27605 .cindex "MIME content scanning"
27606 The &%demime%& ACL condition provides MIME unpacking, sanity checking and file
27607 extension blocking. It is usable only in the DATA and non-SMTP ACLs. The
27608 &%demime%& condition uses a simpler interface to MIME decoding than the MIME
27609 ACL functionality, but provides no additional facilities. Please note that this
27610 condition is deprecated and kept only for backward compatibility. You must set
27611 the WITH_OLD_DEMIME option in &_Local/Makefile_& at build time to be able to
27612 use the &%demime%& condition.
27613
27614 The &%demime%& condition unpacks MIME containers in the message. It detects
27615 errors in MIME containers and can match file extensions found in the message
27616 against a list. Using this facility produces files containing the unpacked MIME
27617 parts of the message in the temporary scan directory. If you do antivirus
27618 scanning, it is recommened that you use the &%demime%& condition before the
27619 antivirus (&%malware%&) condition.
27620
27621 On the right-hand side of the &%demime%& condition you can pass a
27622 colon-separated list of file extensions that it should match against. For
27623 example:
27624 .code
27625 deny message = Found blacklisted file attachment
27626      demime  = vbs:com:bat:pif:prf:lnk
27627 .endd
27628 If one of the file extensions is found, the condition is true, otherwise it is
27629 false. If there is a temporary error while demimeing (for example, &"disk
27630 full"&), the condition defers, and the message is temporarily rejected (unless
27631 the condition is on a &%warn%& verb).
27632
27633 The right-hand side is expanded before being treated as a list, so you can have
27634 conditions and lookups there. If it expands to an empty string, &"false"&, or
27635 zero (&"0"&), no demimeing is done and the condition is false.
27636
27637 The &%demime%& condition set the following variables:
27638
27639 .vlist
27640 .vitem &$demime_errorlevel$&
27641 .cindex "&$demime_errorlevel$&"
27642 When an error is detected in a MIME container, this variable contains the
27643 severity of the error, as an integer number. The higher the value, the more
27644 severe the error (the current maximum value is 3). If this variable is unset or
27645 zero, no error occurred.
27646
27647 .vitem &$demime_reason$&
27648 .cindex "&$demime_reason$&"
27649 When &$demime_errorlevel$& is greater than zero, this variable contains a
27650 human-readable text string describing the MIME error that occurred.
27651 .endlist
27652
27653 .vlist
27654 .vitem &$found_extension$&
27655 .cindex "&$found_extension$&"
27656 When the &%demime%& condition is true, this variable contains the file
27657 extension it found.
27658 .endlist
27659
27660 Both &$demime_errorlevel$& and &$demime_reason$& are set by the first call of
27661 the &%demime%& condition, and are not changed on subsequent calls.
27662
27663 If you do not want to check for file extensions, but rather use the &%demime%&
27664 condition for unpacking or error checking purposes, pass &"*"& as the
27665 right-hand side value. Here is a more elaborate example of how to use this
27666 facility:
27667 .code
27668 # Reject messages with serious MIME container errors
27669 deny  message = Found MIME error ($demime_reason).
27670       demime = *
27671       condition = ${if >{$demime_errorlevel}{2}{1}{0}}
27672
27673 # Reject known virus spreading file extensions.
27674 # Accepting these is pretty much braindead.
27675 deny  message = contains $found_extension file (blacklisted).
27676       demime  = com:vbs:bat:pif:scr
27677
27678 # Freeze .exe and .doc files. Postmaster can
27679 # examine them and eventually thaw them.
27680 deny  log_message = Another $found_extension file.
27681       demime = exe:doc
27682       control = freeze
27683 .endd
27684 .ecindex IIDcosca
27685
27686
27687
27688
27689 . ////////////////////////////////////////////////////////////////////////////
27690 . ////////////////////////////////////////////////////////////////////////////
27691
27692 .chapter "Adding a local scan function to Exim" "CHAPlocalscan" &&&
27693          "Local scan function"
27694 .scindex IIDlosca "&[local_scan()]& function" "description of"
27695 .cindex "customizing" "input scan using C function"
27696 .cindex "policy control" "by local scan function"
27697 In these days of email worms, viruses, and ever-increasing spam, some sites
27698 want to apply a lot of checking to messages before accepting them.
27699
27700 The content scanning extension (chapter &<<CHAPexiscan>>&) has facilities for
27701 passing messages to external virus and spam scanning software. You can also do
27702 a certain amount in Exim itself through string expansions and the &%condition%&
27703 condition in the ACL that runs after the SMTP DATA command or the ACL for
27704 non-SMTP messages (see chapter &<<CHAPACL>>&), but this has its limitations.
27705
27706 To allow for further customization to a site's own requirements, there is the
27707 possibility of linking Exim with a private message scanning function, written
27708 in C. If you want to run code that is written in something other than C, you
27709 can of course use a little C stub to call it.
27710
27711 The local scan function is run once for every incoming message, at the point
27712 when Exim is just about to accept the message.
27713 It can therefore be used to control non-SMTP messages from local processes as
27714 well as messages arriving via SMTP.
27715
27716 Exim applies a timeout to calls of the local scan function, and there is an
27717 option called &%local_scan_timeout%& for setting it. The default is 5 minutes.
27718 Zero means &"no timeout"&.
27719 Exim also sets up signal handlers for SIGSEGV, SIGILL, SIGFPE, and SIGBUS
27720 before calling the local scan function, so that the most common types of crash
27721 are caught. If the timeout is exceeded or one of those signals is caught, the
27722 incoming message is rejected with a temporary error if it is an SMTP message.
27723 For a non-SMTP message, the message is dropped and Exim ends with a non-zero
27724 code. The incident is logged on the main and reject logs.
27725
27726
27727
27728 .section "Building Exim to use a local scan function"
27729 .cindex "&[local_scan()]& function" "building Exim to use"
27730 To make use of the local scan function feature, you must tell Exim where your
27731 function is before building Exim, by setting LOCAL_SCAN_SOURCE in your
27732 &_Local/Makefile_&. A recommended place to put it is in the &_Local_&
27733 directory, so you might set
27734 .code
27735 LOCAL_SCAN_SOURCE=Local/local_scan.c
27736 .endd
27737 for example. The function must be called &[local_scan()]&. It is called by
27738 Exim after it has received a message, when the success return code is about to
27739 be sent. This is after all the ACLs have been run. The return code from your
27740 function controls whether the message is actually accepted or not. There is a
27741 commented template function (that just accepts the message) in the file
27742 _src/local_scan.c_.
27743
27744 If you want to make use of Exim's run time configuration file to set options
27745 for your &[local_scan()]& function, you must also set
27746 .code
27747 LOCAL_SCAN_HAS_OPTIONS=yes
27748 .endd
27749 in &_Local/Makefile_& (see section &<<SECTconoptloc>>& below).
27750
27751
27752
27753
27754 .section "API for local_scan()" "SECTapiforloc"
27755 .cindex "&[local_scan()]& function" "API description"
27756 You must include this line near the start of your code:
27757 .code
27758 #include "local_scan.h"
27759 .endd
27760 This header file defines a number of variables and other values, and the
27761 prototype for the function itself. Exim is coded to use unsigned char values
27762 almost exclusively, and one of the things this header defines is a shorthand
27763 for &`unsigned char`& called &`uschar`&.
27764 It also contains the following macro definitions, to simplify casting character
27765 strings and pointers to character strings:
27766 .code
27767 #define CS   (char *)
27768 #define CCS  (const char *)
27769 #define CSS  (char **)
27770 #define US   (unsigned char *)
27771 #define CUS  (const unsigned char *)
27772 #define USS  (unsigned char **)
27773 .endd
27774 The function prototype for &[local_scan()]& is:
27775 .code
27776 extern int local_scan(int fd, uschar **return_text);
27777 .endd
27778 The arguments are as follows:
27779
27780 .ilist
27781 &%fd%& is a file descriptor for the file that contains the body of the message
27782 (the -D file). The file is open for reading and writing, but updating it is not
27783 recommended. &*Warning*&: You must &'not'& close this file descriptor.
27784
27785 The descriptor is positioned at character 19 of the file, which is the first
27786 character of the body itself, because the first 19 characters are the message
27787 id followed by &`-D`& and a newline. If you rewind the file, you should use the
27788 macro SPOOL_DATA_START_OFFSET to reset to the start of the data, just in
27789 case this changes in some future version.
27790 .next
27791 &%return_text%& is an address which you can use to return a pointer to a text
27792 string at the end of the function. The value it points to on entry is NULL.
27793 .endlist
27794
27795 The function must return an &%int%& value which is one of the following macros:
27796
27797 .vlist
27798 .vitem &`LOCAL_SCAN_ACCEPT`&
27799 .cindex "&$local_scan_data$&"
27800 The message is accepted. If you pass back a string of text, it is saved with
27801 the message, and made available in the variable &$local_scan_data$&. No
27802 newlines are permitted (if there are any, they are turned into spaces) and the
27803 maximum length of text is 1000 characters.
27804
27805 .vitem &`LOCAL_SCAN_ACCEPT_FREEZE`&
27806 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
27807 queued without immediate delivery, and is frozen.
27808
27809 .vitem &`LOCAL_SCAN_ACCEPT_QUEUE`&
27810 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
27811 queued without immediate delivery.
27812
27813 .vitem &`LOCAL_SCAN_REJECT`&
27814 The message is rejected; the returned text is used as an error message which is
27815 passed back to the sender and which is also logged. Newlines are permitted &--
27816 they cause a multiline response for SMTP rejections, but are converted to
27817 &`\n`& in log lines. If no message is given, &"Administrative prohibition"& is
27818 used.
27819
27820 .vitem &`LOCAL_SCAN_TEMPREJECT`&
27821 The message is temporarily rejected; the returned text is used as an error
27822 message as for LOCAL_SCAN_REJECT. If no message is given, &"Temporary local
27823 problem"& is used.
27824
27825 .vitem &`LOCAL_SCAN_REJECT_NOLOGHDR`&
27826 This behaves as LOCAL_SCAN_REJECT, except that the header of the rejected
27827 message is not written to the reject log. It has the effect of unsetting the
27828 &%rejected_header%& log selector for just this rejection. If
27829 &%rejected_header%& is already unset (see the discussion of the
27830 &%log_selection%& option in section &<<SECTlogselector>>&), this code is the
27831 same as LOCAL_SCAN_REJECT.
27832
27833 .vitem &`LOCAL_SCAN_TEMPREJECT_NOLOGHDR`&
27834 This code is a variation of LOCAL_SCAN_TEMPREJECT in the same way that
27835 LOCAL_SCAN_REJECT_NOLOGHDR is a variation of LOCAL_SCAN_REJECT.
27836 .endlist
27837
27838 If the message is not being received by interactive SMTP, rejections are
27839 reported by writing to &%stderr%& or by sending an email, as configured by the
27840 &%-oe%& command line options.
27841
27842
27843
27844 .section "Configuration options for local_scan()" "SECTconoptloc"
27845 .cindex "&[local_scan()]& function" "configuration options"
27846 It is possible to have option settings in the main configuration file
27847 that set values in static variables in the &[local_scan()]& module. If you
27848 want to do this, you must have the line
27849 .code
27850 LOCAL_SCAN_HAS_OPTIONS=yes
27851 .endd
27852 in your &_Local/Makefile_& when you build Exim. (This line is in
27853 &_OS/Makefile-Default_&, commented out). Then, in the &[local_scan()]& source
27854 file, you must define static variables to hold the option values, and a table
27855 to define them.
27856
27857 The table must be a vector called &%local_scan_options%&, of type
27858 &`optionlist`&. Each entry is a triplet, consisting of a name, an option type,
27859 and a pointer to the variable that holds the value. The entries must appear in
27860 alphabetical order. Following &%local_scan_options%& you must also define a
27861 variable called &%local_scan_options_count%& that contains the number of
27862 entries in the table. Here is a short example, showing two kinds of option:
27863 .code
27864 static int my_integer_option = 42;
27865 static uschar *my_string_option = US"a default string";
27866
27867 optionlist local_scan_options[] = {
27868   { "my_integer", opt_int,       &my_integer_option },
27869   { "my_string",  opt_stringptr, &my_string_option }
27870 };
27871
27872 int local_scan_options_count =
27873   sizeof(local_scan_options)/sizeof(optionlist);
27874 .endd
27875 The values of the variables can now be changed from Exim's runtime
27876 configuration file by including a local scan section as in this example:
27877 .code
27878 begin local_scan
27879 my_integer = 99
27880 my_string = some string of text...
27881 .endd
27882 The available types of option data are as follows:
27883
27884 .vlist
27885 .vitem &*opt_bool*&
27886 This specifies a boolean (true/false) option. The address should point to a
27887 variable of type &`BOOL`&, which will be set to TRUE or FALSE, which are macros
27888 that are defined as &"1"& and &"0"&, respectively. If you want to detect
27889 whether such a variable has been set at all, you can initialize it to
27890 TRUE_UNSET. (BOOL variables are integers underneath, so can hold more than two
27891 values.)
27892
27893 .vitem &*opt_fixed*&
27894 This specifies a fixed point number, such as is used for load averages.
27895 The address should point to a variable of type &`int`&. The value is stored
27896 multiplied by 1000, so, for example, 1.4142 is truncated and stored as 1414.
27897
27898 .vitem &*opt_int*&
27899 This specifies an integer; the address should point to a variable of type
27900 &`int`&. The value may be specified in any of the integer formats accepted by
27901 Exim.
27902
27903 .vitem &*opt_mkint*&
27904 This is the same as &%opt_int%&, except that when such a value is output in a
27905 &%-bP%& listing, if it is an exact number of kilobytes or megabytes, it is
27906 printed with the suffix K or M.
27907
27908 .vitem &*opt_octint*&
27909 This also specifies an integer, but the value is always interpeted as an
27910 octal integer, whether or not it starts with the digit zero, and it is
27911 always output in octal.
27912
27913 .vitem &*opt_stringptr*&
27914 This specifies a string value; the address must be a pointer to a
27915 variable that points to a string (for example, of type &`uschar *`&).
27916
27917 .vitem &*opt_time*&
27918 This specifies a time interval value. The address must point to a variable of
27919 type &`int`&. The value that is placed there is a number of seconds.
27920 .endlist
27921
27922 If the &%-bP%& command line option is followed by &`local_scan`&, Exim prints
27923 out the values of all the &[local_scan()]& options.
27924
27925
27926
27927 .section "Available Exim variables"
27928 .cindex "&[local_scan()]& function" "available Exim variables"
27929 The header &_local_scan.h_& gives you access to a number of C variables. These
27930 are the only ones that are guaranteed to be maintained from release to release.
27931 Note, however, that you can obtain the value of any Exim variable by calling
27932 &'expand_string()'&. The exported variables are as follows:
27933
27934 .vlist
27935 .vitem &*unsigned&~int&~debug_selector*&
27936 This variable is set to zero when no debugging is taking place. Otherwise, it
27937 is a bitmap of debugging selectors. Two bits are identified for use in
27938 &[local_scan()]&; they are defined as macros:
27939
27940 .ilist
27941 The &`D_v`& bit is set when &%-v%& was present on the command line. This is a
27942 testing option that is not privileged &-- any caller may set it. All the
27943 other selector bits can be set only by admin users.
27944
27945 .next
27946 The &`D_local_scan`& bit is provided for use by &[local_scan()]&; it is set
27947 by the &`+local_scan`& debug selector. It is not included in the default set
27948 of debugging bits.
27949 .endlist ilist
27950
27951 Thus, to write to the debugging output only when &`+local_scan`& has been
27952 selected, you should use code like this:
27953 .code
27954 if ((debug_selector & D_local_scan) != 0)
27955   debug_printf("xxx", ...);
27956 .endd
27957 .vitem &*uschar&~*expand_string_message*&
27958 After a failing call to &'expand_string()'& (returned value NULL), the
27959 variable &%expand_string_message%& contains the error message, zero-terminated.
27960
27961 .vitem &*header_line&~*header_list*&
27962 A pointer to a chain of header lines. The &%header_line%& structure is
27963 discussed below.
27964
27965 .vitem &*header_line&~*header_last*&
27966 A pointer to the last of the header lines.
27967
27968 .vitem &*uschar&~*headers_charset*&
27969 The value of the &%headers_charset%& configuration option.
27970
27971 .vitem &*BOOL&~host_checking*&
27972 This variable is TRUE during a host checking session that is initiated by the
27973 &%-bh%& command line option.
27974
27975 .vitem &*uschar&~*interface_address*&
27976 The IP address of the interface that received the message, as a string. This
27977 is NULL for locally submitted messages.
27978
27979 .vitem &*int&~interface_port*&
27980 .new
27981 The port on which this message was received. When testing with the &%-bh%&
27982 command line option, the value of this variable is -1 unless a port has been
27983 specified via the &%-oMi%& option.
27984 .wen
27985
27986 .vitem &*uschar&~*message_id*&
27987 This variable contains Exim's message id for the incoming message (the value of
27988 &$message_exim_id$&) as a zero-terminated string.
27989
27990 .vitem &*uschar&~*received_protocol*&
27991 The name of the protocol by which the message was received.
27992
27993 .vitem &*int&~recipients_count*&
27994 The number of accepted recipients.
27995
27996 .vitem &*recipient_item&~*recipients_list*&
27997 .cindex "recipient" "adding in local scan"
27998 .cindex "recipient" "removing in local scan"
27999 The list of accepted recipients, held in a vector of length
28000 &%recipients_count%&. The &%recipient_item%& structure is discussed below. You
28001 can add additional recipients by calling &'receive_add_recipient()'& (see
28002 below). You can delete recipients by removing them from the vector and adusting
28003 the value in &%recipients_count%&. In particular, by setting
28004 &%recipients_count%& to zero you remove all recipients. If you then return the
28005 value &`LOCAL_SCAN_ACCEPT`&, the message is accepted, but immediately
28006 blackholed. To replace the recipients, you can set &%recipients_count%& to zero
28007 and then call &'receive_add_recipient()'& as often as needed.
28008
28009 .vitem &*uschar&~*sender_address*&
28010 The envelope sender address. For bounce messages this is the empty string.
28011
28012 .vitem &*uschar&~*sender_host_address*&
28013 The IP address of the sending host, as a string. This is NULL for
28014 locally-submitted messages.
28015
28016 .vitem &*uschar&~*sender_host_authenticated*&
28017 The name of the authentication mechanism that was used, or NULL if the message
28018 was not received over an authenticated SMTP connection.
28019
28020 .vitem &*uschar&~*sender_host_name*&
28021 The name of the sending host, if known.
28022
28023 .vitem &*int&~sender_host_port*&
28024 The port on the sending host.
28025
28026 .vitem &*BOOL&~smtp_input*&
28027 This variable is TRUE for all SMTP input, including BSMTP.
28028
28029 .vitem &*BOOL&~smtp_batched_input*&
28030 This variable is TRUE for BSMTP input.
28031
28032 .vitem &*int&~store_pool*&
28033 The contents of this variable control which pool of memory is used for new
28034 requests. See section &<<SECTmemhanloc>>& for details.
28035 .endlist
28036
28037
28038 .section "Structure of header lines"
28039 The &%header_line%& structure contains the members listed below.
28040 You can add additional header lines by calling the &'header_add()'& function
28041 (see below). You can cause header lines to be ignored (deleted) by setting
28042 their type to *.
28043
28044
28045 .vlist
28046 .vitem &*struct&~header_line&~*next*&
28047 A pointer to the next header line, or NULL for the last line.
28048
28049 .vitem &*int&~type*&
28050 A code identifying certain headers that Exim recognizes. The codes are printing
28051 characters, and are documented in chapter &<<CHAPspool>>& of this manual.
28052 Notice in particular that any header line whose type is * is not transmitted
28053 with the message. This flagging is used for header lines that have been
28054 rewritten, or are to be removed (for example, &'Envelope-sender:'& header
28055 lines.) Effectively, * means &"deleted"&.
28056
28057 .vitem &*int&~slen*&
28058 The number of characters in the header line, including the terminating and any
28059 internal newlines.
28060
28061 .vitem &*uschar&~*text*&
28062 A pointer to the text of the header. It always ends with a newline, followed by
28063 a zero byte. Internal newlines are preserved.
28064 .endlist
28065
28066
28067
28068 .section "Structure of recipient items"
28069 The &%recipient_item%& structure contains these members:
28070
28071 .vlist
28072 .vitem &*uschar&~*address*&
28073 This is a pointer to the recipient address as it was received.
28074
28075 .vitem &*int&~pno*&
28076 This is used in later Exim processing when top level addresses are created by
28077 the &%one_time%& option. It is not relevant at the time &[local_scan()]& is run
28078 and must always contain -1 at this stage.
28079
28080 .vitem &*uschar&~*errors_to*&
28081 If this value is not NULL, bounce messages caused by failing to deliver to the
28082 recipient are sent to the address it contains. In other words, it overrides the
28083 envelope sender for this one recipient. (Compare the &%errors_to%& generic
28084 router option.) If a &[local_scan()]& function sets an &%errors_to%& field to
28085 an unqualified address, Exim qualifies it using the domain from
28086 &%qualify_recipient%&. When &[local_scan()]& is called, the &%errors_to%& field
28087 is NULL for all recipients.
28088 .endlist
28089
28090
28091
28092 .section "Available Exim functions"
28093 .cindex "&[local_scan()]& function" "available Exim functions"
28094 The header &_local_scan.h_& gives you access to a number of Exim functions.
28095 These are the only ones that are guaranteed to be maintained from release to
28096 release:
28097
28098 .vlist
28099 .vitem "&*pid_t&~child_open(uschar&~**argv,&~uschar&~**envp,&~int&~newumask,&&&
28100        &~int&~*infdptr,&~int&~*outfdptr, &~&~BOOL&~make_leader)*&"
28101
28102 This function creates a child process that runs the command specified by
28103 &%argv%&. The environment for the process is specified by &%envp%&, which can
28104 be NULL if no environment variables are to be passed. A new umask is supplied
28105 for the process in &%newumask%&.
28106
28107 Pipes to the standard input and output of the new process are set up
28108 and returned to the caller via the &%infdptr%& and &%outfdptr%& arguments. The
28109 standard error is cloned to the standard output. If there are any file
28110 descriptors &"in the way"& in the new process, they are closed. If the final
28111 argument is TRUE, the new process is made into a process group leader.
28112
28113 The function returns the pid of the new process, or -1 if things go wrong.
28114
28115 .vitem &*int&~child_close(pid_t&~pid,&~int&~timeout)*&
28116 This function waits for a child process to terminate, or for a timeout (in
28117 seconds) to expire. A timeout value of zero means wait as long as it takes. The
28118 return value is as follows:
28119
28120 .ilist
28121 >= 0
28122
28123 The process terminated by a normal exit and the value is the process
28124 ending status.
28125
28126 .next
28127 < 0 and > &--256
28128
28129 The process was terminated by a signal and the value is the negation of the
28130 signal number.
28131
28132 .next
28133 &--256
28134
28135 The process timed out.
28136 .next
28137 &--257
28138
28139 The was some other error in wait(); &%errno%& is still set.
28140 .endlist
28141
28142 .vitem &*pid_t&~child_open_exim(int&~*fd)*&
28143 This function provide you with a means of submitting a new message to
28144 Exim. (Of course, you can also call &_/usr/sbin/sendmail_& yourself if you
28145 want, but this packages it all up for you.) The function creates a pipe,
28146 forks a subprocess that is running
28147 .code
28148 exim -t -oem -oi -f <>
28149 .endd
28150 and returns to you (via the &`int *`& argument) a file descriptor for the pipe
28151 that is connected to the standard input. The yield of the function is the PID
28152 of the subprocess. You can then write a message to the file descriptor, with
28153 recipients in &'To:'&, &'Cc:'&, and/or &'Bcc:'& header lines.
28154
28155 When you have finished, call &'child_close()'& to wait for the process to
28156 finish and to collect its ending status. A timeout value of zero is usually
28157 fine in this circumstance. Unless you have made a mistake with the recipient
28158 addresses, you should get a return code of zero.
28159
28160
28161 .vitem &*pid_t&~child_open_exim2(int&~*fd,&~uschar&~*sender,&~uschar&~&&&
28162        *sender_authentication)*&
28163 This function is a more sophisticated version of &'child_open()'&. The command
28164 that it runs is:
28165 .display
28166 &`exim -t -oem -oi -f `&&'sender'&&` -oMas `&&'sender_authentication'&
28167 .endd
28168 The third argument may be NULL, in which case the &%-oMas%& option is omitted.
28169
28170
28171 .vitem &*void&~debug_printf(char&~*,&~...)*&
28172 This is Exim's debugging function, with arguments as for &'(printf()'&. The
28173 output is written to the standard error stream. If no debugging is selected,
28174 calls to &'debug_printf()'& have no effect. Normally, you should make calls
28175 conditional on the &`local_scan`& debug selector by coding like this:
28176 .code
28177 if ((debug_selector & D_local_scan) != 0)
28178   debug_printf("xxx", ...);
28179 .endd
28180
28181 .vitem &*uschar&~*expand_string(uschar&~*string)*&
28182 This is an interface to Exim's string expansion code. The return value is the
28183 expanded string, or NULL if there was an expansion failure.
28184 The C variable &%expand_string_message%& contains an error message after an
28185 expansion failure. If expansion does not change the string, the return value is
28186 the pointer to the input string. Otherwise, the return value points to a new
28187 block of memory that was obtained by a call to &'store_get()'&. See section
28188 &<<SECTmemhanloc>>& below for a discussion of memory handling.
28189
28190 .vitem &*void&~header_add(int&~type,&~char&~*format,&~...)*&
28191 This function allows you to an add additional header line at the end of the
28192 existing ones. The first argument is the type, and should normally be a space
28193 character. The second argument is a format string and any number of
28194 substitution arguments as for &[sprintf()]&. You may include internal newlines
28195 if you want, and you must ensure that the string ends with a newline.
28196
28197 .vitem "&*void&~header_add_at_position(BOOL&~after,&~uschar&~*name,&~&&&
28198         BOOL&~topnot,&~int&~type,&~char&~*format, &~&~...)*&"
28199 This function adds a new header line at a specified point in the header
28200 chain. The header itself is specified as for &'header_add()'&.
28201
28202 If &%name%& is NULL, the new header is added at the end of the chain if
28203 &%after%& is true, or at the start if &%after%& is false. If &%name%& is not
28204 NULL, the header lines are searched for the first non-deleted header that
28205 matches the name. If one is found, the new header is added before it if
28206 &%after%& is false. If &%after%& is true, the new header is added after the
28207 found header and any adjacent subsequent ones with the same name (even if
28208 marked &"deleted"&). If no matching non-deleted header is found, the &%topnot%&
28209 option controls where the header is added. If it is true, addition is at the
28210 top; otherwise at the bottom. Thus, to add a header after all the &'Received:'&
28211 headers, or at the top if there are no &'Received:'& headers, you could use
28212 .code
28213 header_add_at_position(TRUE, US"Received", TRUE,
28214   ' ', "X-xxx: ...");
28215 .endd
28216 Normally, there is always at least one non-deleted &'Received:'& header, but
28217 there may not be if &%received_header_text%& expands to an empty string.
28218
28219
28220 .vitem &*void&~header_remove(int&~occurrence,&~uschar&~*name)*&
28221 This function removes header lines. If &%occurrence%& is zero or negative, all
28222 occurrences of the header are removed. If occurrence is greater than zero, that
28223 particular instance of the header is removed. If no header(s) can be found that
28224 match the specification, the function does nothing.
28225
28226
28227 .vitem "&*BOOL&~header_testname(header_line&~*hdr,&~uschar&~*name,&~&&&
28228         int&~length,&~BOOL&~notdel)*&"
28229 This function tests whether the given header has the given name. It is not just
28230 a string comparison, because white space is permitted between the name and the
28231 colon. If the &%notdel%& argument is true, a false return is forced for all
28232 &"deleted"& headers; otherwise they are not treated specially. For example:
28233 .code
28234 if (header_testname(h, US"X-Spam", 6, TRUE)) ...
28235 .endd
28236 .vitem &*uschar&~*lss_b64encode(uschar&~*cleartext,&~int&~length)*&
28237 .cindex "base64 encoding" "functions for &[local_scan()]& use"
28238 This function base64-encodes a string, which is passed by address and length.
28239 The text may contain bytes of any value, including zero. The result is passed
28240 back in dynamic memory that is obtained by calling &'store_get()'&. It is
28241 zero-terminated.
28242
28243 .vitem &*int&~lss_b64decode(uschar&~*codetext,&~uschar&~**cleartext)*&
28244 This function decodes a base64-encoded string. Its arguments are a
28245 zero-terminated base64-encoded string and the address of a variable that is set
28246 to point to the result, which is in dynamic memory. The length of the decoded
28247 string is the yield of the function. If the input is invalid base64 data, the
28248 yield is -1. A zero byte is added to the end of the output string to make it
28249 easy to interpret as a C string (assuming it contains no zeros of its own). The
28250 added zero byte is not included in the returned count.
28251
28252 .vitem &*int&~lss_match_domain(uschar&~*domain,&~uschar&~*list)*&
28253 This function checks for a match in a domain list. Domains are always
28254 matched caselessly. The return value is one of the following:
28255 .display
28256 &`OK     `& match succeeded
28257 &`FAIL   `& match failed
28258 &`DEFER  `& match deferred
28259 .endd
28260 DEFER is usually caused by some kind of lookup defer, such as the
28261 inability to contact a database.
28262
28263 .vitem "&*int&~lss_match_local_part(uschar&~*localpart,&~uschar&~*list,&~&&&
28264         BOOL&~caseless)*&"
28265 This function checks for a match in a local part list. The third argument
28266 controls case-sensitivity. The return values are as for
28267 &'lss_match_domain()'&.
28268
28269 .vitem "&*int&~lss_match_address(uschar&~*address,&~uschar&~*list,&~&&&
28270         BOOL&~caseless)*&"
28271 This function checks for a match in an address list. The third argument
28272 controls the case-sensitivity of the local part match. The domain is always
28273 matched caselessly. The return values are as for &'lss_match_domain()'&.
28274
28275 .vitem "&*int&~lss_match_host(uschar&~*host_name,&~uschar&~*host_address,&~&&&
28276         uschar&~*list)*&"
28277 This function checks for a match in a host list. The most common usage is
28278 expected to be
28279 .code
28280 lss_match_host(sender_host_name, sender_host_address, ...)
28281 .endd
28282 .cindex "&$sender_host_address$&"
28283 An empty address field matches an empty item in the host list. If the host name
28284 is NULL, the name corresponding to &$sender_host_address$& is automatically
28285 looked up if a host name is required to match an item in the list. The return
28286 values are as for &'lss_match_domain()'&, but in addition, &'lss_match_host()'&
28287 returns ERROR in the case when it had to look up a host name, but the lookup
28288 failed.
28289
28290 .vitem "&*void&~log_write(unsigned&~int&~selector,&~int&~which,&~char&~&&&
28291         *format,&~...)*&"
28292 This function writes to Exim's log files. The first argument should be zero (it
28293 is concerned with &%log_selector%&). The second argument can be &`LOG_MAIN`& or
28294 &`LOG_REJECT`& or &`LOG_PANIC`& or the inclusive &"or"& of any combination of
28295 them. It specifies to which log or logs the message is written. The remaining
28296 arguments are a format and relevant insertion arguments. The string should not
28297 contain any newlines, not even at the end.
28298
28299
28300 .vitem &*void&~receive_add_recipient(uschar&~*address,&~int&~pno)*&
28301 This function adds an additional recipient to the message. The first argument
28302 is the recipient address. If it is unqualified (has no domain), it is qualified
28303 with the &%qualify_recipient%& domain. The second argument must always be -1.
28304
28305 This function does not allow you to specify a private &%errors_to%& address (as
28306 described with the structure of &%recipient_item%& above), because it pre-dates
28307 the addition of that field to the structure. However, it is easy to add such a
28308 value afterwards. For example:
28309 .code
28310  receive_add_recipient(US"monitor@mydom.example", -1);
28311  recipients_list[recipients_count-1].errors_to =
28312    US"postmaster@mydom.example";
28313 .endd
28314
28315 .vitem &*BOOL&~receive_remove_recipient(uschar&~*recipient)*&
28316 This is a convenience function to remove a named recipient from the list of
28317 recipients. It returns true if a recipient was removed, and false if no
28318 matching recipient could be found. The argument must be a complete email
28319 address.
28320 .endlist
28321
28322
28323 .cindex "RFC 2047"
28324 .vlist
28325 .vitem "&*uschar&~rfc2047_decode(uschar&~*string,&~BOOL&~lencheck,&&&
28326   &~uschar&~*target,&~int&~zeroval,&~int&~*lenptr, &~&~uschar&~**error)*&"
28327 This function decodes strings that are encoded according to RFC 2047. Typically
28328 these are the contents of header lines. First, each &"encoded word"& is decoded
28329 from the Q or B encoding into a byte-string. Then, if provided with the name of
28330 a charset encoding, and if the &[iconv()]& function is available, an attempt is
28331 made  to translate the result to the named character set. If this fails, the
28332 binary string is returned with an error message.
28333
28334 The first argument is the string to be decoded. If &%lencheck%& is TRUE, the
28335 maximum MIME word length is enforced. The third argument is the target
28336 encoding, or NULL if no translation is wanted.
28337
28338 .cindex "binary zero" "in RFC 2047 decoding"
28339 .cindex "RFC 2047" "binary zero in"
28340 If a binary zero is encountered in the decoded string, it is replaced by the
28341 contents of the &%zeroval%& argument. For use with Exim headers, the value must
28342 not be 0 because header lines are handled as zero-terminated strings.
28343
28344 The function returns the result of processing the string, zero-terminated; if
28345 &%lenptr%& is not NULL, the length of the result is set in the variable to
28346 which it points. When &%zeroval%& is 0, &%lenptr%& should not be NULL.
28347
28348 If an error is encountered, the function returns NULL and uses the &%error%&
28349 argument to return an error message. The variable pointed to by &%error%& is
28350 set to NULL if there is no error; it may be set non-NULL even when the function
28351 returns a non-NULL value if decoding was successful, but there was a problem
28352 with translation.
28353
28354
28355 .vitem &*int&~smtp_fflush(void)*&
28356 This function is used in conjunction with &'smtp_printf()'&, as described
28357 below.
28358
28359 .vitem &*void&~smtp_printf(char&~*,&~...)*&
28360 The arguments of this function are like &[printf()]&; it writes to the SMTP
28361 output stream. You should use this function only when there is an SMTP output
28362 stream, that is, when the incoming message is being received via interactive
28363 SMTP. This is the case when &%smtp_input%& is TRUE and &%smtp_batched_input%&
28364 is FALSE. If you want to test for an incoming message from another host (as
28365 opposed to a local process that used the &%-bs%& command line option), you can
28366 test the value of &%sender_host_address%&, which is non-NULL when a remote host
28367 is involved.
28368
28369 If an SMTP TLS connection is established, &'smtp_printf()'& uses the TLS
28370 output function, so it can be used for all forms of SMTP connection.
28371
28372 Strings that are written by &'smtp_printf()'& from within &[local_scan()]&
28373 must start with an appropriate response code: 550 if you are going to return
28374 LOCAL_SCAN_REJECT, 451 if you are going to return
28375 LOCAL_SCAN_TEMPREJECT, and 250 otherwise. Because you are writing the
28376 initial lines of a multi-line response, the code must be followed by a hyphen
28377 to indicate that the line is not the final response line. You must also ensure
28378 that the lines you write terminate with CRLF. For example:
28379 .code
28380 smtp_printf("550-this is some extra info\r\n");
28381 return LOCAL_SCAN_REJECT;
28382 .endd
28383 Note that you can also create multi-line responses by including newlines in
28384 the data returned via the &%return_text%& argument. The added value of using
28385 &'smtp_printf()'& is that, for instance, you could introduce delays between
28386 multiple output lines.
28387
28388 The &'smtp_printf()'& function does not return any error indication, because it
28389 does not automatically flush pending output, and therefore does not test
28390 the state of the stream. (In the main code of Exim, flushing and error
28391 detection is done when Exim is ready for the next SMTP input command.) If
28392 you want to flush the output and check for an error (for example, the
28393 dropping of a TCP/IP connection), you can call &'smtp_fflush()'&, which has no
28394 arguments. It flushes the output stream, and returns a non-zero value if there
28395 is an error.
28396
28397 .vitem &*void&~*store_get(int)*&
28398 This function accesses Exim's internal store (memory) manager. It gets a new
28399 chunk of memory whose size is given by the argument. Exim bombs out if it ever
28400 runs out of memory. See the next section for a discussion of memory handling.
28401
28402 .vitem &*void&~*store_get_perm(int)*&
28403 This function is like &'store_get()'&, but it always gets memory from the
28404 permanent pool. See the next section for a discussion of memory handling.
28405
28406 .vitem &*uschar&~*string_copy(uschar&~*string)*&
28407 See below.
28408
28409 .vitem &*uschar&~*string_copyn(uschar&~*string,&~int&~length)*&
28410 See below.
28411
28412 .vitem &*uschar&~*string_sprintf(char&~*format,&~...)*&
28413 These three functions create strings using Exim's dynamic memory facilities.
28414 The first makes a copy of an entire string. The second copies up to a maximum
28415 number of characters, indicated by the second argument. The third uses a format
28416 and insertion arguments to create a new string. In each case, the result is a
28417 pointer to a new string in the current memory pool. See the next section for
28418 more discussion.
28419 .endlist
28420
28421
28422
28423 .section "More about Exim's memory handling" "SECTmemhanloc"
28424 .cindex "&[local_scan()]& function" "memory handling"
28425 No function is provided for freeing memory, because that is never needed.
28426 The dynamic memory that Exim uses when receiving a message is automatically
28427 recycled if another message is received by the same process (this applies only
28428 to incoming SMTP connections &-- other input methods can supply only one
28429 message at a time). After receiving the last message, a reception process
28430 terminates.
28431
28432 Because it is recycled, the normal dynamic memory cannot be used for holding
28433 data that must be preserved over a number of incoming messages on the same SMTP
28434 connection. However, Exim in fact uses two pools of dynamic memory; the second
28435 one is not recycled, and can be used for this purpose.
28436
28437 If you want to allocate memory that remains available for subsequent messages
28438 in the same SMTP connection, you should set
28439 .code
28440 store_pool = POOL_PERM
28441 .endd
28442 before calling the function that does the allocation. There is no need to
28443 restore the value if you do not need to; however, if you do want to revert to
28444 the normal pool, you can either restore the previous value of &%store_pool%& or
28445 set it explicitly to POOL_MAIN.
28446
28447 The pool setting applies to all functions that get dynamic memory, including
28448 &'expand_string()'&, &'store_get()'&, and the &'string_xxx()'& functions.
28449 There is also a convenience function called &'store_get_perm()'& that gets a
28450 block of memory from the permanent pool while preserving the value of
28451 &%store_pool%&.
28452 .ecindex IIDlosca
28453
28454
28455
28456
28457 . ////////////////////////////////////////////////////////////////////////////
28458 . ////////////////////////////////////////////////////////////////////////////
28459
28460 .chapter "System-wide message filtering" "CHAPsystemfilter"
28461 .scindex IIDsysfil1 "filter" "system filter"
28462 .scindex IIDsysfil2 "filtering all mail"
28463 .scindex IIDsysfil3 "system filter"
28464 The previous chapters (on ACLs and the local scan function) describe checks
28465 that can be applied to messages before they are accepted by a host. There is
28466 also a mechanism for checking messages once they have been received, but before
28467 they are delivered. This is called the &'system filter'&.
28468
28469 The system filter operates in a similar manner to users' filter files, but it
28470 is run just once per message (however many recipients the message has).
28471 It should not normally be used as a substitute for routing, because &%deliver%&
28472 commands in a system router provide new envelope recipient addresses.
28473 The system filter must be an Exim filter. It cannot be a Sieve filter.
28474
28475 The system filter is run at the start of a delivery attempt, before any routing
28476 is done. If a message fails to be completely delivered at the first attempt,
28477 the system filter is run again at the start of every retry.
28478 If you want your filter to do something only once per message, you can make use
28479 of the &%first_delivery%& condition in an &%if%& command in the filter to
28480 prevent it happening on retries.
28481
28482 .cindex "&$domain$&"
28483 .cindex "&$local_part$&"
28484 &*Warning*&: Because the system filter runs just once, variables that are
28485 specific to individual recipient addresses, such as &$local_part$& and
28486 &$domain$&, are not set, and the &"personal"& condition is not meaningful. If
28487 you want to run a centrally-specified filter for each recipient address
28488 independently, you can do so by setting up a suitable &(redirect)& router, as
28489 described in section &<<SECTperaddfil>>& below.
28490
28491
28492 .section "Specifying a system filter"
28493 .cindex "uid (user id)" "system filter"
28494 .cindex "gid (group id)" "system filter"
28495 The name of the file that contains the system filter must be specified by
28496 setting &%system_filter%&. If you want the filter to run under a uid and gid
28497 other than root, you must also set &%system_filter_user%& and
28498 &%system_filter_group%& as appropriate. For example:
28499 .code
28500 system_filter = /etc/mail/exim.filter
28501 system_filter_user = exim
28502 .endd
28503 If a system filter generates any deliveries directly to files or pipes (via the
28504 &%save%& or &%pipe%& commands), transports to handle these deliveries must be
28505 specified by setting &%system_filter_file_transport%& and
28506 &%system_filter_pipe_transport%&, respectively. Similarly,
28507 &%system_filter_reply_transport%& must be set to handle any messages generated
28508 by the &%reply%& command.
28509
28510
28511 .section "Testing a system filter"
28512 You can run simple tests of a system filter in the same way as for a user
28513 filter, but you should use &%-bF%& rather than &%-bf%&, so that features that
28514 are permitted only in system filters are recognized.
28515
28516 If you want to test the combined effect of a system filter and a user filter,
28517 you can use both &%-bF%& and &%-bf%& on the same command line.
28518
28519
28520
28521 .section "Contents of a system filter"
28522 The language used to specify system filters is the same as for users' filter
28523 files. It is described in the separate end-user document &'Exim's interface to
28524 mail filtering'&. However, there are some additional features that are
28525 available only in system filters; these are described in subsequent sections.
28526 If they are encountered in a user's filter file or when testing with &%-bf%&,
28527 they cause errors.
28528
28529 .cindex "frozen messages" "manual thaw; testing in filter"
28530 There are two special conditions which, though available in users' filter
28531 files, are designed for use in system filters. The condition &%first_delivery%&
28532 is true only for the first attempt at delivering a message, and
28533 &%manually_thawed%& is true only if the message has been frozen, and
28534 subsequently thawed by an admin user. An explicit forced delivery counts as a
28535 manual thaw, but thawing as a result of the &%auto_thaw%& setting does not.
28536
28537 &*Warning*&: If a system filter uses the &%first_delivery%& condition to
28538 specify an &"unseen"& (non-significant) delivery, and that delivery does not
28539 succeed, it will not be tried again.
28540 If you want Exim to retry an unseen delivery until it succeeds, you should
28541 arrange to set it up every time the filter runs.
28542
28543 When a system filter finishes running, the values of the variables &$n0$& &--
28544 &$n9$& are copied into &$sn0$& &-- &$sn9$& and are thereby made available to
28545 users' filter files. Thus a system filter can, for example, set up &"scores"&
28546 to which users' filter files can refer.
28547
28548
28549
28550 .section "Additional variable for system filters"
28551 .cindex "&$recipients$&"
28552 The expansion variable &$recipients$&, containing a list of all the recipients
28553 of the message (separated by commas and white space), is available in system
28554 filters. It is not available in users' filters for privacy reasons.
28555
28556
28557
28558 .section "Defer, freeze, and fail commands for system filters"
28559 .cindex "freezing messages"
28560 .cindex "message" "freezing"
28561 .cindex "message" "forced failure"
28562 .cindex "&%fail%&" "in system filter"
28563 .cindex "&%freeze%& in system filter"
28564 .cindex "&%defer%& in system filter"
28565 There are three extra commands (&%defer%&, &%freeze%& and &%fail%&) which are
28566 always available in system filters, but are not normally enabled in users'
28567 filters. (See the &%allow_defer%&, &%allow_freeze%& and &%allow_fail%& options
28568 for the &(redirect)& router.) These commands can optionally be followed by the
28569 word &%text%& and a string containing an error message, for example:
28570 .code
28571 fail text "this message looks like spam to me"
28572 .endd
28573 The keyword &%text%& is optional if the next character is a double quote.
28574
28575 The &%defer%& command defers delivery of the original recipients of the
28576 message. The &%fail%& command causes all the original recipients to be failed,
28577 and a bounce message to be created. The &%freeze%& command suspends all
28578 delivery attempts for the original recipients. In all cases, any new deliveries
28579 that are specified by the filter are attempted as normal after the filter has
28580 run.
28581
28582 The &%freeze%& command is ignored if the message has been manually unfrozen and
28583 not manually frozen since. This means that automatic freezing by a system
28584 filter can be used as a way of checking out suspicious messages. If a message
28585 is found to be all right, manually unfreezing it allows it to be delivered.
28586
28587 .cindex "log" "&%fail%& command log line"
28588 .cindex "&%fail%&" "log line; reducing"
28589 The text given with a fail command is used as part of the bounce message as
28590 well as being written to the log. If the message is quite long, this can fill
28591 up a lot of log space when such failures are common. To reduce the size of the
28592 log message, Exim interprets the text in a special way if it starts with the
28593 two characters &`<<`& and contains &`>>`& later. The text between these two
28594 strings is written to the log, and the rest of the text is used in the bounce
28595 message. For example:
28596 .code
28597 fail "<<filter test 1>>Your message is rejected \
28598      because it contains attachments that we are \
28599      not prepared to receive."
28600 .endd
28601
28602 .cindex "loop" "caused by &%fail%&"
28603 Take great care with the &%fail%& command when basing the decision to fail on
28604 the contents of the message, because the bounce message will of course include
28605 the contents of the original message and will therefore trigger the &%fail%&
28606 command again (causing a mail loop) unless steps are taken to prevent this.
28607 Testing the &%error_message%& condition is one way to prevent this. You could
28608 use, for example
28609 .code
28610 if $message_body contains "this is spam" and not error_message
28611 then fail text "spam is not wanted here" endif
28612 .endd
28613 though of course that might let through unwanted bounce messages. The
28614 alternative is clever checking of the body and/or headers to detect bounces
28615 generated by the filter.
28616
28617 The interpretation of a system filter file ceases after a
28618 &%defer%&,
28619 &%freeze%&, or &%fail%& command is obeyed. However, any deliveries that were
28620 set up earlier in the filter file are honoured, so you can use a sequence such
28621 as
28622 .code
28623 mail ...
28624 freeze
28625 .endd
28626 to send a specified message when the system filter is freezing (or deferring or
28627 failing) a message. The normal deliveries for the message do not, of course,
28628 take place.
28629
28630
28631
28632 .section "Adding and removing headers in a system filter" "SECTaddremheasys"
28633 .cindex "header lines" "adding; in system filter"
28634 .cindex "header lines" "removing; in system filter"
28635 .cindex "filter" "header lines; adding/removing"
28636 Two filter commands that are available only in system filters are:
28637 .code
28638 headers add <string>
28639 headers remove <string>
28640 .endd
28641 The argument for the &%headers add%& is a string that is expanded and then
28642 added to the end of the message's headers. It is the responsibility of the
28643 filter maintainer to make sure it conforms to RFC 2822 syntax. Leading white
28644 space is ignored, and if the string is otherwise empty, or if the expansion is
28645 forced to fail, the command has no effect.
28646
28647 You can use &"\n"& within the string, followed by white space, to specify
28648 continued header lines. More than one header may be added in one command by
28649 including &"\n"& within the string without any following white space. For
28650 example:
28651 .code
28652 headers add "X-header-1: ....\n  \
28653              continuation of X-header-1 ...\n\
28654              X-header-2: ...."
28655 .endd
28656 Note that the header line continuation white space after the first newline must
28657 be placed before the backslash that continues the input string, because white
28658 space after input continuations is ignored.
28659
28660 The argument for &%headers remove%& is a colon-separated list of header names.
28661 This command applies only to those headers that are stored with the message;
28662 those that are added at delivery time (such as &'Envelope-To:'& and
28663 &'Return-Path:'&) cannot be removed by this means. If there is more than one
28664 header with the same name, they are all removed.
28665
28666 The &%headers%& command in a system filter makes an immediate change to the set
28667 of header lines that was received with the message (with possible additions
28668 from ACL processing). Subsequent commands in the system filter operate on the
28669 modified set, which also forms the basis for subsequent message delivery.
28670 Unless further modified during routing or transporting, this set of headers is
28671 used for all recipients of the message.
28672
28673 During routing and transporting, the variables that refer to the contents of
28674 header lines refer only to those lines that are in this set. Thus, header lines
28675 that are added by a system filter are visible to users' filter files and to all
28676 routers and transports. This contrasts with the manipulation of header lines by
28677 routers and transports, which is not immediate, but which instead is saved up
28678 until the message is actually being written (see section
28679 &<<SECTheadersaddrem>>&).
28680
28681 If the message is not delivered at the first attempt, header lines that were
28682 added by the system filter are stored with the message, and so are still
28683 present at the next delivery attempt. Header lines that were removed are still
28684 present, but marked &"deleted"& so that they are not transported with the
28685 message. For this reason, it is usual to make the &%headers%& command
28686 conditional on &%first_delivery%& so that the set of header lines is not
28687 modified more than once.
28688
28689 Because header modification in a system filter acts immediately, you have to
28690 use an indirect approach if you want to modify the contents of a header line.
28691 For example:
28692 .code
28693 headers add "Old-Subject: $h_subject:"
28694 headers remove "Subject"
28695 headers add "Subject: new subject (was: $h_old-subject:)"
28696 headers remove "Old-Subject"
28697 .endd
28698
28699
28700
28701 .section "Setting an errors address in a system filter"
28702 .cindex "envelope sender"
28703 In a system filter, if a &%deliver%& command is followed by
28704 .code
28705 errors_to <some address>
28706 .endd
28707 in order to change the envelope sender (and hence the error reporting) for that
28708 delivery, any address may be specified. (In a user filter, only the current
28709 user's address can be set.) For example, if some mail is being monitored, you
28710 might use
28711 .code
28712 unseen deliver monitor@spying.example errors_to root@local.example
28713 .endd
28714 to take a copy which would not be sent back to the normal error reporting
28715 address if its delivery failed.
28716
28717
28718
28719 .section "Per-address filtering" "SECTperaddfil"
28720 .cindex "&$domain$&"
28721 .cindex "&$local_part$&"
28722 In contrast to the system filter, which is run just once per message for each
28723 delivery attempt, it is also possible to set up a system-wide filtering
28724 operation that runs once for each recipient address. In this case, variables
28725 such as &$local_part$& and &$domain$& can be used, and indeed, the choice of
28726 filter file could be made dependent on them. This is an example of a router
28727 which implements such a filter:
28728 .code
28729 central_filter:
28730   check_local_user
28731   driver = redirect
28732   domains = +local_domains
28733   file = /central/filters/$local_part
28734   no_verify
28735   allow_filter
28736   allow_freeze
28737 .endd
28738 The filter is run in a separate process under its own uid. Therefore, either
28739 &%check_local_user%& must be set (as above), in which case the filter is run as
28740 the local user, or the &%user%& option must be used to specify which user to
28741 use. If both are set, &%user%& overrides.
28742
28743 Care should be taken to ensure that none of the commands in the filter file
28744 specify a significant delivery if the message is to go on to be delivered to
28745 its intended recipient. The router will not then claim to have dealt with the
28746 address, so it will be passed on to subsequent routers to be delivered in the
28747 normal way.
28748 .ecindex IIDsysfil1
28749 .ecindex IIDsysfil2
28750 .ecindex IIDsysfil3
28751
28752
28753
28754
28755
28756
28757 . ////////////////////////////////////////////////////////////////////////////
28758 . ////////////////////////////////////////////////////////////////////////////
28759
28760 .chapter "Message processing" "CHAPmsgproc"
28761 .scindex IIDmesproc "message" "general processing"
28762 Exim performs various transformations on the sender and recipient addresses of
28763 all messages that it handles, and also on the messages' header lines. Some of
28764 these are optional and configurable, while others always take place. All of
28765 this processing, except rewriting as a result of routing, and the addition or
28766 removal of header lines while delivering, happens when a message is received,
28767 before it is placed on Exim's queue.
28768
28769 Some of the automatic processing takes place by default only for
28770 &"locally-originated"& messages. This adjective is used to describe messages
28771 that are not received over TCP/IP, but instead are passed to an Exim process on
28772 its standard input. This includes the interactive &"local SMTP"& case that is
28773 set up by the &%-bs%& command line option.
28774
28775 &*Note*&: Messages received over TCP/IP on the loopback interface (127.0.0.1
28776 or ::1) are not considered to be locally-originated. Exim does not treat the
28777 loopback interface specially in any way.
28778
28779 If you want the loopback interface to be treated specially, you must ensure
28780 that there are appropriate entries in your ACLs.
28781
28782
28783
28784
28785 .section "Submission mode for non-local messages" "SECTsubmodnon"
28786 .cindex "message" "submission"
28787 .cindex "submission mode"
28788 Processing that happens automatically for locally-originated messages (unless
28789 &%suppress_local_fixups%& is set) can also be requested for messages that are
28790 received over TCP/IP. The term &"submission mode"& is used to describe this
28791 state. Submisssion mode is set by the modifier
28792 .code
28793 control = submission
28794 .endd
28795 in a MAIL, RCPT, or pre-data ACL for an incoming message (see sections
28796 &<<SECTACLmodi>>& and &<<SECTcontrols>>&). This makes Exim treat the message as
28797 a local submission, and is normally used when the source of the message is
28798 known to be an MUA running on a client host (as opposed to an MTA). For
28799 example, to set submission mode for messages originating on the IPv4 loopback
28800 interface, you could include the following in the MAIL ACL:
28801 .code
28802 warn  hosts = 127.0.0.1
28803       control = submission
28804 .endd
28805 .cindex "&%sender_retain%&"
28806 There are some options that can be used when setting submission mode. A slash
28807 is used to separate options. For example:
28808 .code
28809 control = submission/sender_retain
28810 .endd
28811 Specifying &%sender_retain%& has the effect of setting &%local_sender_retain%&
28812 true and &%local_from_check%& false for the current incoming message. The first
28813 of these allows an existing &'Sender:'& header in the message to remain, and
28814 the second suppresses the check to ensure that &'From:'& matches the
28815 authenticated sender. With this setting, Exim still fixes up messages by adding
28816 &'Date:'& and &'Message-ID:'& header lines if they are missing, but makes no
28817 attempt to check sender authenticity in header lines.
28818
28819 When &%sender_retain%& is not set, a submission mode setting may specify a
28820 domain to be used when generating a &'From:'& or &'Sender:'& header line. For
28821 example:
28822 .code
28823 control = submission/domain=some.domain
28824 .endd
28825 The domain may be empty. How this value is used is described in sections
28826 &<<SECTthefrohea>>& and &<<SECTthesenhea>>&. There is also a &%name%& option
28827 that allows you to specify the user's full name for inclusion in a created
28828 &'Sender:'& or &'From:'& header line. For example:
28829 .code
28830 accept authenticated = *
28831        control = submission/domain=wonderland.example/\
28832                             name=${lookup {$authenticated_id} \
28833                                    lsearch {/etc/exim/namelist}}
28834 .endd
28835 Because the name may contain any characters, including slashes, the &%name%&
28836 option must be given last. The remainder of the string is used as the name. For
28837 the example above, if &_/etc/exim/namelist_& contains:
28838 .code
28839 bigegg:  Humpty Dumpty
28840 .endd
28841 then when the sender has authenticated as &'bigegg'&, the generated &'Sender:'&
28842 line would be:
28843 .code
28844 Sender: Humpty Dumpty <bigegg@wonderland.example>
28845 .endd
28846 .cindex "return path" "in submission mode"
28847 By default, submission mode forces the return path to the same address as is
28848 used to create the &'Sender:'& header. However, if &%sender_retain%& is
28849 specified, the return path is also left unchanged.
28850
28851 &*Note*&: The changes caused by submission mode take effect after the predata
28852 ACL. This means that any sender checks performed before the fix-ups use the
28853 untrusted sender address specified by the user, not the trusted sender address
28854 specified by submission mode. Although this might be slightly unexpected, it
28855 does mean that you can configure ACL checks to spot that a user is trying to
28856 spoof another's address.
28857
28858 .section "Line endings" "SECTlineendings"
28859 .cindex "line endings"
28860 .cindex "carriage return"
28861 .cindex "linefeed"
28862 RFC 2821 specifies that CRLF (two characters: carriage-return, followed by
28863 linefeed) is the line ending for messages transmitted over the Internet using
28864 SMTP over TCP/IP. However, within individual operating systems, different
28865 conventions are used. For example, Unix-like systems use just LF, but others
28866 use CRLF or just CR.
28867
28868 Exim was designed for Unix-like systems, and internally, it stores messages
28869 using the system's convention of a single LF as a line terminator. When
28870 receiving a message, all line endings are translated to this standard format.
28871 Originally, it was thought that programs that passed messages directly to an
28872 MTA within an operating system would use that system's convention. Experience
28873 has shown that this is not the case; for example, there are Unix applications
28874 that use CRLF in this circumstance. For this reason, and for compatibility with
28875 other MTAs, the way Exim handles line endings for all messages is now as
28876 follows:
28877
28878 .ilist
28879 LF not preceded by CR is treated as a line ending.
28880 .next
28881 CR is treated as a line ending; if it is immediately followed by LF, the LF
28882 is ignored.
28883 .next
28884 The sequence &"CR, dot, CR"& does not terminate an incoming SMTP message,
28885 nor a local message in the state where a line containing only a dot is a
28886 terminator.
28887 .next
28888 If a bare CR is encountered within a header line, an extra space is added after
28889 the line terminator so as not to end the header line. The reasoning behind this
28890 is that bare CRs in header lines are most likely either to be mistakes, or
28891 people trying to play silly games.
28892 .next
28893 If the first header line received in a message ends with CRLF, a subsequent
28894 bare LF in a header line is treated in the same way as a bare CR in a header
28895 line.
28896 .endlist
28897
28898
28899
28900
28901
28902 .section "Unqualified addresses"
28903 .cindex "unqualified addresses"
28904 .cindex "address" "qualification"
28905 By default, Exim expects every envelope address it receives from an external
28906 host to be fully qualified. Unqualified addresses cause negative responses to
28907 SMTP commands. However, because SMTP is used as a means of transporting
28908 messages from MUAs running on personal workstations, there is sometimes a
28909 requirement to accept unqualified addresses from specific hosts or IP networks.
28910
28911 Exim has two options that separately control which hosts may send unqualified
28912 sender or receipient addresses in SMTP commands, namely
28913 &%sender_unqualified_hosts%& and &%recipient_unqualified_hosts%&. In both
28914 cases, if an unqualified address is accepted, it is qualified by adding the
28915 value of &%qualify_domain%& or &%qualify_recipient%&, as appropriate.
28916
28917 .cindex "&%qualify_domain%&"
28918 .cindex "&%qualify_recipient%&"
28919 Unqualified addresses in header lines are automatically qualified for messages
28920 that are locally originated, unless the &%-bnq%& option is given on the command
28921 line. For messages received over SMTP, unqualified addresses in header lines
28922 are qualified only if unqualified addresses are permitted in SMTP commands. In
28923 other words, such qualification is also controlled by
28924 &%sender_unqualified_hosts%& and &%recipient_unqualified_hosts%&,
28925
28926
28927
28928
28929 .section "The UUCP From line"
28930 .cindex "&""From""& line"
28931 .cindex "UUCP" "&""From""& line"
28932 .cindex "sender" "address"
28933 .cindex "&%uucp_from_pattern%&"
28934 .cindex "&%uucp_from_sender%&"
28935 .cindex "envelope sender"
28936 .cindex "Sendmail compatibility" "&""From""& line"
28937 Messages that have come from UUCP (and some other applications) often begin
28938 with a line containing the envelope sender and a timestamp, following the word
28939 &"From"&. Examples of two common formats are:
28940 .code
28941 From a.oakley@berlin.mus Fri Jan  5 12:35 GMT 1996
28942 From f.butler@berlin.mus Fri, 7 Jan 97 14:00:00 GMT
28943 .endd
28944 This line precedes the RFC 2822 header lines. For compatibility with Sendmail,
28945 Exim recognizes such lines at the start of messages that are submitted to it
28946 via the command line (that is, on the standard input). It does not recognize
28947 such lines in incoming SMTP messages, unless the sending host matches
28948 &%ignore_fromline_hosts%& or the &%-bs%& option was used for a local message
28949 and &%ignore_fromline_local%& is set. The recognition is controlled by a
28950 regular expression that is defined by the &%uucp_from_pattern%& option, whose
28951 default value matches the two common cases shown above and puts the address
28952 that follows &"From"& into &$1$&.
28953
28954 .cindex "numerical variables (&$1$& &$2$& etc)" "in &""From ""& line handling"
28955 When the caller of Exim for a non-SMTP message that contains a &"From"& line is
28956 a trusted user, the message's sender address is constructed by expanding the
28957 contents of &%uucp_sender_address%&, whose default value is &"$1"&. This is
28958 then parsed as an RFC 2822 address. If there is no domain, the local part is
28959 qualified with &%qualify_domain%& unless it is the empty string. However, if
28960 the command line &%-f%& option is used, it overrides the &"From"& line.
28961
28962 If the caller of Exim is not trusted, the &"From"& line is recognized, but the
28963 sender address is not changed. This is also the case for incoming SMTP messages
28964 that are permitted to contain &"From"& lines.
28965
28966 Only one &"From"& line is recognized. If there is more than one, the second is
28967 treated as a data line that starts the body of the message, as it is not valid
28968 as a header line. This also happens if a &"From"& line is present in an
28969 incoming SMTP message from a source that is not permitted to send them.
28970
28971
28972
28973 .section "Resent- header lines"
28974 .cindex "&%Resent-%& header lines"
28975 RFC 2822 makes provision for sets of header lines starting with the string
28976 &`Resent-`& to be added to a message when it is resent by the original
28977 recipient to somebody else. These headers are &'Resent-Date:'&,
28978 &'Resent-From:'&, &'Resent-Sender:'&, &'Resent-To:'&, &'Resent-Cc:'&,
28979 &'Resent-Bcc:'& and &'Resent-Message-ID:'&. The RFC says:
28980
28981 .blockquote
28982 &'Resent fields are strictly informational. They MUST NOT be used in the normal
28983 processing of replies or other such automatic actions on messages.'&
28984 .endblockquote
28985
28986 This leaves things a bit vague as far as other processing actions such as
28987 address rewriting are concerned. Exim treats &%Resent-%& header lines as
28988 follows:
28989
28990 .ilist
28991 A &'Resent-From:'& line that just contains the login id of the submitting user
28992 is automatically rewritten in the same way as &'From:'& (see below).
28993 .next
28994 If there's a rewriting rule for a particular header line, it is also applied to
28995 &%Resent-%& header lines of the same type. For example, a rule that rewrites
28996 &'From:'& also rewrites &'Resent-From:'&.
28997 .next
28998 For local messages, if &'Sender:'& is removed on input, &'Resent-Sender:'& is
28999 also removed.
29000 .next
29001 For a locally-submitted message,
29002 if there are any &%Resent-%& header lines but no &'Resent-Date:'&,
29003 &'Resent-From:'&, or &'Resent-Message-Id:'&, they are added as necessary. It is
29004 the contents of &'Resent-Message-Id:'& (rather than &'Message-Id:'&) which are
29005 included in log lines in this case.
29006 .next
29007 The logic for adding &'Sender:'& is duplicated for &'Resent-Sender:'& when any
29008 &%Resent-%& header lines are present.
29009 .endlist
29010
29011
29012
29013
29014 .section "The Auto-Submitted: header line"
29015 Whenever Exim generates an autoreply, a bounce, or a delay warning message, it
29016 includes the header line:
29017 .code
29018 Auto-Submitted: auto-replied
29019 .endd
29020
29021 .section "The Bcc: header line"
29022 .cindex "&'Bcc:'& header line"
29023 If Exim is called with the &%-t%& option, to take recipient addresses from a
29024 message's header, it removes any &'Bcc:'& header line that may exist (after
29025 extracting its addresses). If &%-t%& is not present on the command line, any
29026 existing &'Bcc:'& is not removed.
29027
29028
29029 .section "The Date: header line"
29030 .cindex "&'Date:'& header line"
29031 If a locally-generated or submission-mode message has no &'Date:'& header line,
29032 Exim adds one, using the current date and time, unless the
29033 &%suppress_local_fixups%& control has been specified.
29034
29035 .section "The Delivery-date: header line"
29036 .cindex "&'Delivery-date:'& header line"
29037 .cindex "&%delivery_date_remove%&"
29038 &'Delivery-date:'& header lines are not part of the standard RFC 2822 header
29039 set. Exim can be configured to add them to the final delivery of messages. (See
29040 the generic &%delivery_date_add%& transport option.) They should not be present
29041 in messages in transit. If the &%delivery_date_remove%& configuration option is
29042 set (the default), Exim removes &'Delivery-date:'& header lines from incoming
29043 messages.
29044
29045
29046 .section "The Envelope-to: header line"
29047 .cindex "&'Envelope-to:'& header line"
29048 .cindex "&%envelope_to_remove%&"
29049 &'Envelope-to:'& header lines are not part of the standard RFC 2822 header set.
29050 Exim can be configured to add them to the final delivery of messages. (See the
29051 generic &%envelope_to_add%& transport option.) They should not be present in
29052 messages in transit. If the &%envelope_to_remove%& configuration option is set
29053 (the default), Exim removes &'Envelope-to:'& header lines from incoming
29054 messages.
29055
29056
29057 .section "The From: header line" "SECTthefrohea"
29058 .cindex "&'From:'& header line"
29059 .cindex "Sendmail compatibility" "&""From""& line"
29060 .cindex "message" "submission"
29061 .cindex "submission mode"
29062 If a submission-mode message does not contain a &'From:'& header line, Exim
29063 adds one if either of the following conditions is true:
29064
29065 .ilist
29066 The envelope sender address is not empty (that is, this is not a bounce
29067 message). The added header line copies the envelope sender address.
29068 .next
29069 .cindex "&$authenticated_id$&"
29070 The SMTP session is authenticated and &$authenticated_id$& is not empty.
29071 .olist
29072 .cindex "&$qualify_domain$&"
29073 If no domain is specified by the submission control, the local part is
29074 &$authenticated_id$& and the domain is &$qualify_domain$&.
29075 .next
29076 If a non-empty domain is specified by the submission control, the local
29077 part is &$authenticated_id$&, and the domain is the specified domain.
29078 .next
29079 If an empty domain is specified by the submission control,
29080 &$authenticated_id$& is assumed to be the complete address.
29081 .endlist
29082 .endlist
29083
29084 A non-empty envelope sender takes precedence.
29085
29086 If a locally-generated incoming message does not contain a &'From:'& header
29087 line, and the &%suppress_local_fixups%& control is not set, Exim adds one
29088 containing the sender's address. The calling user's login name and full name
29089 are used to construct the address, as described in section &<<SECTconstr>>&.
29090 They are obtained from the password data by calling &[getpwuid()]& (but see the
29091 &%unknown_login%& configuration option). The address is qualified with
29092 &%qualify_domain%&.
29093
29094 For compatibility with Sendmail, if an incoming, non-SMTP message has a
29095 &'From:'& header line containing just the unqualified login name of the calling
29096 user, this is replaced by an address containing the user's login name and full
29097 name as described in section &<<SECTconstr>>&.
29098
29099
29100 .section "The Message-ID: header line"
29101 .cindex "&'Message-ID:'& header line"
29102 .cindex "message" "submission"
29103 .cindex "&%message_id_header_text%&"
29104 If a locally-generated or submission-mode incoming message does not contain a
29105 &'Message-ID:'& or &'Resent-Message-ID:'& header line, and the
29106 &%suppress_local_fixups%& control is not set, Exim adds a suitable header line
29107 to the message. If there are any &'Resent-:'& headers in the message, it
29108 creates &'Resent-Message-ID:'&. The id is constructed from Exim's internal
29109 message id, preceded by the letter E to ensure it starts with a letter, and
29110 followed by @ and the primary host name. Additional information can be included
29111 in this header line by setting the &%message_id_header_text%& and/or
29112 &%message_id_header_domain%& options.
29113
29114
29115 .section "The Received: header line"
29116 .cindex "&'Received:'& header line"
29117 A &'Received:'& header line is added at the start of every message. The
29118 contents are defined by the &%received_header_text%& configuration option, and
29119 Exim automatically adds a semicolon and a timestamp to the configured string.
29120
29121 The &'Received:'& header is generated as soon as the message's header lines
29122 have been received. At this stage, the timestamp in the &'Received:'& header
29123 line is the time that the message started to be received. This is the value
29124 that is seen by the DATA ACL and by the &[local_scan()]& function.
29125
29126 Once a message is accepted, the timestamp in the &'Received:'& header line is
29127 changed to the time of acceptance, which is (apart from a small delay while the
29128 -H spool file is written) the earliest time at which delivery could start.
29129
29130
29131 .section "The References: header line"
29132 .cindex "&'References:'& header line"
29133 Messages created by the &(autoreply)& transport include a &'References:'&
29134 header line. This is constructed according to the rules that are described in
29135 section 3.64 of RFC 2822 (which states that replies should contain such a
29136 header line), and section 3.14 of RFC 3834 (which states that automatic
29137 responses are not different in this respect). However, because some mail
29138 processing software does not cope well with very long header lines, no more
29139 than 12 message IDs are copied from the &'References:'& header line in the
29140 incoming message. If there are more than 12, the first one and then the final
29141 11 are copied, before adding the message ID of the incoming message.
29142
29143
29144
29145 .section "The Return-path: header line"
29146 .cindex "&'Return-path:'& header line"
29147 .cindex "&%return_path_remove%&"
29148 &'Return-path:'& header lines are defined as something an MTA may insert when
29149 it does the final delivery of messages. (See the generic &%return_path_add%&
29150 transport option.) Therefore, they should not be present in messages in
29151 transit. If the &%return_path_remove%& configuration option is set (the
29152 default), Exim removes &'Return-path:'& header lines from incoming messages.
29153
29154
29155
29156 .section "The Sender: header line" "SECTthesenhea"
29157 .cindex "&'Sender:'& header line"
29158 .cindex "message" "submission"
29159 For a locally-originated message from an untrusted user, Exim may remove an
29160 existing &'Sender:'& header line, and it may add a new one. You can modify
29161 these actions by setting the &%local_sender_retain%& option true, the
29162 &%local_from_check%& option false, or by using the &%suppress_local_fixups%&
29163 control setting.
29164
29165 When a local message is received from an untrusted user and
29166 &%local_from_check%& is true (the default), and the &%suppress_local_fixups%&
29167 control has not been set, a check is made to see if the address given in the
29168 &'From:'& header line is the correct (local) sender of the message. The address
29169 that is expected has the login name as the local part and the value of
29170 &%qualify_domain%& as the domain. Prefixes and suffixes for the local part can
29171 be permitted by setting &%local_from_prefix%& and &%local_from_suffix%&
29172 appropriately. If &'From:'& does not contain the correct sender, a &'Sender:'&
29173 line is added to the message.
29174
29175 If you set &%local_from_check%& false, this checking does not occur. However,
29176 the removal of an existing &'Sender:'& line still happens, unless you also set
29177 &%local_sender_retain%& to be true. It is not possible to set both of these
29178 options true at the same time.
29179
29180 .cindex "submission mode"
29181 By default, no processing of &'Sender:'& header lines is done for messages
29182 received over TCP/IP or for messages submitted by trusted users. However, when
29183 a message is received over TCP/IP in submission mode, and &%sender_retain%& is
29184 not specified on the submission control, the following processing takes place:
29185
29186 .cindex "&$authenticated_id$&"
29187 First, any existing &'Sender:'& lines are removed. Then, if the SMTP session is
29188 authenticated, and &$authenticated_id$& is not empty, a sender address is
29189 created as follows:
29190
29191 .ilist
29192 .cindex "&$qualify_domain$&"
29193 If no domain is specified by the submission control, the local part is
29194 &$authenticated_id$& and the domain is &$qualify_domain$&.
29195 .next
29196 If a non-empty domain is specified by the submission control, the local part
29197 is &$authenticated_id$&, and the domain is the specified domain.
29198 .next
29199 If an empty domain is specified by the submission control,
29200 &$authenticated_id$& is assumed to be the complete address.
29201 .endlist
29202
29203 This address is compared with the address in the &'From:'& header line. If they
29204 are different, a &'Sender:'& header line containing the created address is
29205 added. Prefixes and suffixes for the local part in &'From:'& can be permitted
29206 by setting &%local_from_prefix%& and &%local_from_suffix%& appropriately.
29207
29208 .cindex "return path" "created from &'Sender:'&"
29209 &*Note*&: Whenever a &'Sender:'& header line is created, the return path for
29210 the message (the envelope sender address) is changed to be the same address,
29211 except in the case of submission mode when &%sender_retain%& is specified.
29212
29213
29214
29215 .section "Adding and removing header lines in routers and transports" &&&
29216          "SECTheadersaddrem"
29217 .cindex "header lines" "adding; in router or transport"
29218 .cindex "header lines" "removing; in router or transport"
29219 When a message is delivered, the addition and removal of header lines can be
29220 specified in a system filter, or on any of the routers and transports that
29221 process the message. Section &<<SECTaddremheasys>>& contains details about
29222 modifying headers in a system filter. Header lines can also be added in an ACL
29223 as a message is received (see section &<<SECTaddheadacl>>&).
29224
29225 In contrast to what happens in a system filter, header modifications that are
29226 specified on routers and transports apply only to the particular recipient
29227 addresses that are being processed by those routers and transports. These
29228 changes do not actually take place until a copy of the message is being
29229 transported. Therefore, they do not affect the basic set of header lines, and
29230 they do not affect the values of the variables that refer to header lines.
29231
29232 &*Note*&: In particular, this means that any expansions in the configuration of
29233 the transport cannot refer to the modified header lines, because such
29234 expansions all occur before the message is actually transported.
29235
29236 For both routers and transports, the result of expanding a &%headers_add%&
29237 option must be in the form of one or more RFC 2822 header lines, separated by
29238 newlines (coded as &"\n"&). For example:
29239 .code
29240 headers_add = X-added-header: added by $primary_hostname\n\
29241               X-added-second: another added header line
29242 .endd
29243 Exim does not check the syntax of these added header lines.
29244
29245 The result of expanding &%headers_remove%& must consist of a colon-separated
29246 list of header names. This is confusing, because header names themselves are
29247 often terminated by colons. In this case, the colons are the list separators,
29248 not part of the names. For example:
29249 .code
29250 headers_remove = return-receipt-to:acknowledge-to
29251 .endd
29252 When &%headers_add%& or &%headers_remove%& is specified on a router, its value
29253 is expanded at routing time, and then associated with all addresses that are
29254 accepted by that router, and also with any new addresses that it generates. If
29255 an address passes through several routers as a result of aliasing or
29256 forwarding, the changes are cumulative.
29257
29258 .cindex "&%unseen%& option"
29259 However, this does not apply to multiple routers that result from the use of
29260 the &%unseen%& option. Any header modifications that were specified by the
29261 &"unseen"& router or its predecessors apply only to the &"unseen"& delivery.
29262
29263 Addresses that end up with different &%headers_add%& or &%headers_remove%&
29264 settings cannot be delivered together in a batch, so a transport is always
29265 dealing with a set of addresses that have the same header-processing
29266 requirements.
29267
29268 The transport starts by writing the original set of header lines that arrived
29269 with the message, possibly modified by the system filter. As it writes out
29270 these lines, it consults the list of header names that were attached to the
29271 recipient address(es) by &%headers_remove%& options in routers, and it also
29272 consults the transport's own &%headers_remove%& option. Header lines whose
29273 names are on either of these lists are not written out. If there are multiple
29274 instances of any listed header, they are all skipped.
29275
29276 After the remaining original header lines have been written, new header
29277 lines that were specified by routers' &%headers_add%& options are written, in
29278 the order in which they were attached to the address. These are followed by any
29279 header lines specified by the transport's &%headers_add%& option.
29280
29281 This way of handling header line modifications in routers and transports has
29282 the following consequences:
29283
29284 .ilist
29285 The original set of header lines, possibly modified by the system filter,
29286 remains &"visible"&, in the sense that the &$header_$&&'xxx'& variables refer
29287 to it, at all times.
29288 .next
29289 Header lines that are added by a router's
29290 &%headers_add%& option are not accessible by means of the &$header_$&&'xxx'&
29291 expansion syntax in subsequent routers or the transport.
29292 .next
29293 Conversely, header lines that are specified for removal by &%headers_remove%&
29294 in a router remain visible to subsequent routers and the transport.
29295 .next
29296 Headers added to an address by &%headers_add%& in a router cannot be removed by
29297 a later router or by a transport.
29298 .next
29299 An added header can refer to the contents of an original header that is to be
29300 removed, even it has the same name as the added header. For example:
29301 .code
29302 headers_remove = subject
29303 headers_add = Subject: new subject (was: $h_subject:)
29304 .endd
29305 .endlist
29306
29307 &*Warning*&: The &%headers_add%& and &%headers_remove%& options cannot be used
29308 for a &(redirect)& router that has the &%one_time%& option set.
29309
29310
29311
29312
29313
29314 .section "Constructed addresses" "SECTconstr"
29315 .cindex "address" "constructed"
29316 .cindex "constructed address"
29317 When Exim constructs a sender address for a locally-generated message, it uses
29318 the form
29319 .display
29320 <&'user name'&>&~&~<&'login'&&`@`&&'qualify_domain'&>
29321 .endd
29322 For example:
29323 .code
29324 Zaphod Beeblebrox <zaphod@end.univ.example>
29325 .endd
29326 The user name is obtained from the &%-F%& command line option if set, or
29327 otherwise by looking up the calling user by &[getpwuid()]& and extracting the
29328 &"gecos"& field from the password entry. If the &"gecos"& field contains an
29329 ampersand character, this is replaced by the login name with the first letter
29330 upper cased, as is conventional in a number of operating systems. See the
29331 &%gecos_name%& option for a way to tailor the handling of the &"gecos"& field.
29332 The &%unknown_username%& option can be used to specify user names in cases when
29333 there is no password file entry.
29334
29335 .cindex "RFC 2047"
29336 In all cases, the user name is made to conform to RFC 2822 by quoting all or
29337 parts of it if necessary. In addition, if it contains any non-printing
29338 characters, it is encoded as described in RFC 2047, which defines a way of
29339 including non-ASCII characters in header lines. The value of the
29340 &%headers_charset%& option specifies the name of the encoding that is used (the
29341 characters are assumed to be in this encoding). The setting of
29342 &%print_topbitchars%& controls whether characters with the top bit set (that
29343 is, with codes greater than 127) count as printing characters or not.
29344
29345
29346
29347 .section "Case of local parts"
29348 .cindex "case of local parts"
29349 .cindex "local part" "case of"
29350 RFC 2822 states that the case of letters in the local parts of addresses cannot
29351 be assumed to be non-significant. Exim preserves the case of local parts of
29352 addresses, but by default it uses a lower-cased form when it is routing,
29353 because on most Unix systems, usernames are in lower case and case-insensitive
29354 routing is required. However, any particular router can be made to use the
29355 original case for local parts by setting the &%caseful_local_part%& generic
29356 router option.
29357
29358 .cindex "mixed-case login names"
29359 If you must have mixed-case user names on your system, the best way to proceed,
29360 assuming you want case-independent handling of incoming email, is to set up
29361 your first router to convert incoming local parts in your domains to the
29362 correct case by means of a file lookup. For example:
29363 .code
29364 correct_case:
29365   driver = redirect
29366   domains = +local_domains
29367   data = ${lookup{$local_part}cdb\
29368               {/etc/usercased.cdb}{$value}fail}\
29369               @$domain
29370 .endd
29371 For this router, the local part is forced to lower case by the default action
29372 (&%caseful_local_part%& is not set). The lower-cased local part is used to look
29373 up a new local part in the correct case. If you then set &%caseful_local_part%&
29374 on any subsequent routers which process your domains, they will operate on
29375 local parts with the correct case in a case-sensitive manner.
29376
29377
29378
29379 .section "Dots in local parts"
29380 .cindex "dot" "in local part"
29381 .cindex "local part" "dots in"
29382 RFC 2822 forbids empty components in local parts. That is, an unquoted local
29383 part may not begin or end with a dot, nor have two consecutive dots in the
29384 middle. However, it seems that many MTAs do not enforce this, so Exim permits
29385 empty components for compatibility.
29386
29387
29388
29389 .section "Rewriting addresses"
29390 .cindex "rewriting" "addresses"
29391 Rewriting of sender and recipient addresses, and addresses in headers, can
29392 happen automatically, or as the result of configuration options, as described
29393 in chapter &<<CHAPrewrite>>&. The headers that may be affected by this are
29394 &'Bcc:'&, &'Cc:'&, &'From:'&, &'Reply-To:'&, &'Sender:'&, and &'To:'&.
29395
29396 Automatic rewriting includes qualification, as mentioned above. The other case
29397 in which it can happen is when an incomplete non-local domain is given. The
29398 routing process may cause this to be expanded into the full domain name. For
29399 example, a header such as
29400 .code
29401 To: hare@teaparty
29402 .endd
29403 might get rewritten as
29404 .code
29405 To: hare@teaparty.wonderland.fict.example
29406 .endd
29407 Rewriting as a result of routing is the one kind of message processing that
29408 does not happen at input time, as it cannot be done until the address has
29409 been routed.
29410
29411 Strictly, one should not do &'any'& deliveries of a message until all its
29412 addresses have been routed, in case any of the headers get changed as a
29413 result of routing. However, doing this in practice would hold up many
29414 deliveries for unreasonable amounts of time, just because one address could not
29415 immediately be routed. Exim therefore does not delay other deliveries when
29416 routing of one or more addresses is deferred.
29417 .ecindex IIDmesproc
29418
29419
29420
29421 . ////////////////////////////////////////////////////////////////////////////
29422 . ////////////////////////////////////////////////////////////////////////////
29423
29424 .chapter "SMTP processing" "CHAPSMTP"
29425 .scindex IIDsmtpproc1 "SMTP" "processing details"
29426 .scindex IIDsmtpproc2 "LMTP" "processing details"
29427 Exim supports a number of different ways of using the SMTP protocol, and its
29428 LMTP variant, which is an interactive protocol for transferring messages into a
29429 closed mail store application. This chapter contains details of how SMTP is
29430 processed. For incoming mail, the following are available:
29431
29432 .ilist
29433 SMTP over TCP/IP (Exim daemon or &'inetd'&);
29434 .next
29435 SMTP over the standard input and output (the &%-bs%& option);
29436 .next
29437 Batched SMTP on the standard input (the &%-bS%& option).
29438 .endlist
29439
29440 For mail delivery, the following are available:
29441
29442 .ilist
29443 SMTP over TCP/IP (the &(smtp)& transport);
29444 .next
29445 LMTP over TCP/IP (the &(smtp)& transport with the &%protocol%& option set to
29446 &"lmtp"&);
29447 .next
29448 LMTP over a pipe to a process running in the local host (the &(lmtp)&
29449 transport);
29450 .next
29451 Batched SMTP to a file or pipe (the &(appendfile)& and &(pipe)& transports with
29452 the &%use_bsmtp%& option set).
29453 .endlist
29454
29455 &'Batched SMTP'& is the name for a process in which batches of messages are
29456 stored in or read from files (or pipes), in a format in which SMTP commands are
29457 used to contain the envelope information.
29458
29459
29460
29461 .section "Outgoing SMTP and LMTP over TCP/IP" "SECToutSMTPTCP"
29462 .cindex "SMTP" "outgoing over TCP/IP"
29463 .cindex "outgoing SMTP over TCP/IP"
29464 .cindex "LMTP" "over TCP/IP"
29465 .cindex "outgoing LMTP over TCP/IP"
29466 .cindex "EHLO"
29467 .cindex "HELO"
29468 .cindex "SIZE option on MAIL command"
29469 Outgoing SMTP and LMTP over TCP/IP is implemented by the &(smtp)& transport.
29470 The &%protocol%& option selects which protocol is to be used, but the actual
29471 processing is the same in both cases.
29472
29473 If, in response to its EHLO command, Exim is told that the SIZE
29474 parameter is supported, it adds SIZE=<&'n'&> to each subsequent MAIL
29475 command. The value of <&'n'&> is the message size plus the value of the
29476 &%size_addition%& option (default 1024) to allow for additions to the message
29477 such as per-transport header lines, or changes made in a
29478 .cindex "transport" "filter"
29479 .cindex "filter" "transport filter"
29480 transport filter. If &%size_addition%& is set negative, the use of SIZE is
29481 suppressed.
29482
29483 If the remote server advertises support for PIPELINING, Exim uses the
29484 pipelining extension to SMTP (RFC 2197) to reduce the number of TCP/IP packets
29485 required for the transaction.
29486
29487 If the remote server advertises support for the STARTTLS command, and Exim
29488 was built to support TLS encryption, it tries to start a TLS session unless the
29489 server matches &%hosts_avoid_tls%&. See chapter &<<CHAPTLS>>& for more details.
29490
29491 If the remote server advertises support for the AUTH command, Exim scans
29492 the authenticators configuration for any suitable client settings, as described
29493 in chapter &<<CHAPSMTPAUTH>>&.
29494
29495 .cindex "carriage return"
29496 .cindex "linefeed"
29497 Responses from the remote host are supposed to be terminated by CR followed by
29498 LF. However, there are known to be hosts that do not send CR characters, so in
29499 order to be able to interwork with such hosts, Exim treats LF on its own as a
29500 line terminator.
29501
29502 If a message contains a number of different addresses, all those with the same
29503 characteristics (for example, the same envelope sender) that resolve to the
29504 same set of hosts, in the same order, are sent in a single SMTP transaction,
29505 even if they are for different domains, unless there are more than the setting
29506 of the &%max_rcpts%& option in the &(smtp)& transport allows, in which case
29507 they are split into groups containing no more than &%max_rcpts%& addresses
29508 each. If &%remote_max_parallel%& is greater than one, such groups may be sent
29509 in parallel sessions. The order of hosts with identical MX values is not
29510 significant when checking whether addresses can be batched in this way.
29511
29512 When the &(smtp)& transport suffers a temporary failure that is not
29513 message-related, Exim updates its transport-specific database, which contains
29514 records indexed by host name that remember which messages are waiting for each
29515 particular host. It also updates the retry database with new retry times.
29516
29517 .cindex "hints database" "retry keys"
29518 Exim's retry hints are based on host name plus IP address, so if one address of
29519 a multi-homed host is broken, it will soon be skipped most of the time.
29520 See the next section for more detail about error handling.
29521
29522 .cindex "SMTP" "passed connection"
29523 .cindex "SMTP" "batching over TCP/IP"
29524 When a message is successfully delivered over a TCP/IP SMTP connection, Exim
29525 looks in the hints database for the transport to see if there are any queued
29526 messages waiting for the host to which it is connected. If it finds one, it
29527 creates a new Exim process using the &%-MC%& option (which can only be used by
29528 a process running as root or the Exim user) and passes the TCP/IP socket to it
29529 so that it can deliver another message using the same socket. The new process
29530 does only those deliveries that are routed to the connected host, and may in
29531 turn pass the socket on to a third process, and so on.
29532
29533 The &%connection_max_messages%& option of the &(smtp)& transport can be used to
29534 limit the number of messages sent down a single TCP/IP connection.
29535
29536 .cindex "asterisk" "after IP address"
29537 The second and subsequent messages delivered down an existing connection are
29538 identified in the main log by the addition of an asterisk after the closing
29539 square bracket of the IP address.
29540
29541
29542
29543
29544 .section "Errors in outgoing SMTP" "SECToutSMTPerr"
29545 .cindex "error" "in outgoing SMTP"
29546 .cindex "SMTP" "errors in outgoing"
29547 .cindex "host" "error"
29548 Three different kinds of error are recognized for outgoing SMTP: host errors,
29549 message errors, and recipient errors.
29550
29551 .vlist
29552 .vitem "&*Host errors*&"
29553 A host error is not associated with a particular message or with a
29554 particular recipient of a message. The host errors are:
29555
29556 .ilist
29557 Connection refused or timed out,
29558 .next
29559 Any error response code on connection,
29560 .next
29561 Any error response code to EHLO or HELO,
29562 .next
29563 Loss of connection at any time, except after &"."&,
29564 .next
29565 I/O errors at any time,
29566 .next
29567 Timeouts during the session, other than in response to MAIL, RCPT or
29568 the &"."& at the end of the data.
29569 .endlist ilist
29570
29571 For a host error, a permanent error response on connection, or in response to
29572 EHLO, causes all addresses routed to the host to be failed. Any other host
29573 error causes all addresses to be deferred, and retry data to be created for the
29574 host. It is not tried again, for any message, until its retry time arrives. If
29575 the current set of addresses are not all delivered in this run (to some
29576 alternative host), the message is added to the list of those waiting for this
29577 host, so if it is still undelivered when a subsequent successful delivery is
29578 made to the host, it will be sent down the same SMTP connection.
29579
29580 .vitem "&*Message errors*&"
29581 .cindex "message" "error"
29582 A message error is associated with a particular message when sent to a
29583 particular host, but not with a particular recipient of the message. The
29584 message errors are:
29585
29586 .ilist
29587 Any error response code to MAIL, DATA, or the &"."& that terminates
29588 the data,
29589 .next
29590 Timeout after MAIL,
29591 .next
29592 Timeout or loss of connection after the &"."& that terminates the data. A
29593 timeout after the DATA command itself is treated as a host error, as is loss of
29594 connection at any other time.
29595 .endlist ilist
29596
29597 For a message error, a permanent error response (5&'xx'&) causes all addresses
29598 to be failed, and a delivery error report to be returned to the sender. A
29599 temporary error response (4&'xx'&), or one of the timeouts, causes all
29600 addresses to be deferred. Retry data is not created for the host, but instead,
29601 a retry record for the combination of host plus message id is created. The
29602 message is not added to the list of those waiting for this host. This ensures
29603 that the failing message will not be sent to this host again until the retry
29604 time arrives. However, other messages that are routed to the host are not
29605 affected, so if it is some property of the message that is causing the error,
29606 it will not stop the delivery of other mail.
29607
29608 If the remote host specified support for the SIZE parameter in its response
29609 to EHLO, Exim adds SIZE=&'nnn'& to the MAIL command, so an
29610 over-large message will cause a message error because the error arrives as a
29611 response to MAIL.
29612
29613 .vitem "&*Recipient errors*&"
29614 .cindex "recipient" "error"
29615 A recipient error is associated with a particular recipient of a message. The
29616 recipient errors are:
29617
29618 .ilist
29619 Any error response to RCPT,
29620 .next
29621 Timeout after RCPT.
29622 .endlist
29623
29624 For a recipient error, a permanent error response (5&'xx'&) causes the
29625 recipient address to be failed, and a bounce message to be returned to the
29626 sender. A temporary error response (4&'xx'&) or a timeout causes the failing
29627 address to be deferred, and routing retry data to be created for it. This is
29628 used to delay processing of the address in subsequent queue runs, until its
29629 routing retry time arrives. This applies to all messages, but because it
29630 operates only in queue runs, one attempt will be made to deliver a new message
29631 to the failing address before the delay starts to operate. This ensures that,
29632 if the failure is really related to the message rather than the recipient
29633 (&"message too big for this recipient"& is a possible example), other messages
29634 have a chance of getting delivered. If a delivery to the address does succeed,
29635 the retry information gets cleared, so all stuck messages get tried again, and
29636 the retry clock is reset.
29637
29638 The message is not added to the list of those waiting for this host. Use of the
29639 host for other messages is unaffected, and except in the case of a timeout,
29640 other recipients are processed independently, and may be successfully delivered
29641 in the current SMTP session. After a timeout it is of course impossible to
29642 proceed with the session, so all addresses get deferred. However, those other
29643 than the one that failed do not suffer any subsequent retry delays. Therefore,
29644 if one recipient is causing trouble, the others have a chance of getting
29645 through when a subsequent delivery attempt occurs before the failing
29646 recipient's retry time.
29647 .endlist
29648
29649 In all cases, if there are other hosts (or IP addresses) available for the
29650 current set of addresses (for example, from multiple MX records), they are
29651 tried in this run for any undelivered addresses, subject of course to their
29652 own retry data. In other words, recipient error retry data does not take effect
29653 until the next delivery attempt.
29654
29655 Some hosts have been observed to give temporary error responses to every
29656 MAIL command at certain times (&"insufficient space"& has been seen). It
29657 would be nice if such circumstances could be recognized, and defer data for the
29658 host itself created, but this is not possible within the current Exim design.
29659 What actually happens is that retry data for every (host, message) combination
29660 is created.
29661
29662 The reason that timeouts after MAIL and RCPT are treated specially is that
29663 these can sometimes arise as a result of the remote host's verification
29664 procedures. Exim makes this assumption, and treats them as if a temporary error
29665 response had been received. A timeout after &"."& is treated specially because
29666 it is known that some broken implementations fail to recognize the end of the
29667 message if the last character of the last line is a binary zero. Thus, it is
29668 helpful to treat this case as a message error.
29669
29670 Timeouts at other times are treated as host errors, assuming a problem with the
29671 host, or the connection to it. If a timeout after MAIL, RCPT,
29672 or &"."& is really a connection problem, the assumption is that at the next try
29673 the timeout is likely to occur at some other point in the dialogue, causing it
29674 then to be treated as a host error.
29675
29676 There is experimental evidence that some MTAs drop the connection after the
29677 terminating &"."& if they do not like the contents of the message for some
29678 reason, in contravention of the RFC, which indicates that a 5&'xx'& response
29679 should be given. That is why Exim treats this case as a message rather than a
29680 host error, in order not to delay other messages to the same host.
29681
29682
29683
29684
29685 .section "Incoming SMTP messages over TCP/IP"
29686 .cindex "SMTP" "incoming over TCP/IP"
29687 .cindex "incoming SMTP over TCP/IP"
29688 .cindex "inetd"
29689 .cindex "daemon"
29690 Incoming SMTP messages can be accepted in one of two ways: by running a
29691 listening daemon, or by using &'inetd'&. In the latter case, the entry in
29692 &_/etc/inetd.conf_& should be like this:
29693 .code
29694 smtp stream tcp nowait exim /opt/exim/bin/exim in.exim -bs
29695 .endd
29696 Exim distinguishes between this case and the case of a locally running user
29697 agent using the &%-bs%& option by checking whether or not the standard input is
29698 a socket. When it is, either the port must be privileged (less than 1024), or
29699 the caller must be root or the Exim user. If any other user passes a socket
29700 with an unprivileged port number, Exim prints a message on the standard error
29701 stream and exits with an error code.
29702
29703 By default, Exim does not make a log entry when a remote host connects or
29704 disconnects (either via the daemon or &'inetd'&), unless the disconnection is
29705 unexpected. It can be made to write such log entries by setting the
29706 &%smtp_connection%& log selector.
29707
29708 .cindex "carriage return"
29709 .cindex "linefeed"
29710 Commands from the remote host are supposed to be terminated by CR followed by
29711 LF. However, there are known to be hosts that do not send CR characters. In
29712 order to be able to interwork with such hosts, Exim treats LF on its own as a
29713 line terminator.
29714 Furthermore, because common code is used for receiving messages from all
29715 sources, a CR on its own is also interpreted as a line terminator. However, the
29716 sequence &"CR, dot, CR"& does not terminate incoming SMTP data.
29717
29718 .cindex "EHLO" "invalid data"
29719 .cindex "HELO" "invalid data"
29720 One area that sometimes gives rise to problems concerns the EHLO or
29721 HELO commands. Some clients send syntactically invalid versions of these
29722 commands, which Exim rejects by default. (This is nothing to do with verifying
29723 the data that is sent, so &%helo_verify_hosts%& is not relevant.) You can tell
29724 Exim not to apply a syntax check by setting &%helo_accept_junk_hosts%& to
29725 match the broken hosts that send invalid commands.
29726
29727 .cindex "SIZE option on MAIL command"
29728 .cindex "MAIL" "SIZE option"
29729 The amount of disk space available is checked whenever SIZE is received on
29730 a MAIL command, independently of whether &%message_size_limit%& or
29731 &%check_spool_space%& is configured, unless &%smtp_check_spool_space%& is set
29732 false. A temporary error is given if there is not enough space. If
29733 &%check_spool_space%& is set, the check is for that amount of space plus the
29734 value given with SIZE, that is, it checks that the addition of the incoming
29735 message will not reduce the space below the threshold.
29736
29737 When a message is successfully received, Exim includes the local message id in
29738 its response to the final &"."& that terminates the data. If the remote host
29739 logs this text it can help with tracing what has happened to a message.
29740
29741 The Exim daemon can limit the number of simultaneous incoming connections it is
29742 prepared to handle (see the &%smtp_accept_max%& option). It can also limit the
29743 number of simultaneous incoming connections from a single remote host (see the
29744 &%smtp_accept_max_per_host%& option). Additional connection attempts are
29745 rejected using the SMTP temporary error code 421.
29746
29747 The Exim daemon does not rely on the SIGCHLD signal to detect when a
29748 subprocess has finished, as this can get lost at busy times. Instead, it looks
29749 for completed subprocesses every time it wakes up. Provided there are other
29750 things happening (new incoming calls, starts of queue runs), completed
29751 processes will be noticed and tidied away. On very quiet systems you may
29752 sometimes see a &"defunct"& Exim process hanging about. This is not a problem;
29753 it will be noticed when the daemon next wakes up.
29754
29755 When running as a daemon, Exim can reserve some SMTP slots for specific hosts,
29756 and can also be set up to reject SMTP calls from non-reserved hosts at times of
29757 high system load &-- for details see the &%smtp_accept_reserve%&,
29758 &%smtp_load_reserve%&, and &%smtp_reserve_hosts%& options. The load check
29759 applies in both the daemon and &'inetd'& cases.
29760
29761 Exim normally starts a delivery process for each message received, though this
29762 can be varied by means of the &%-odq%& command line option and the
29763 &%queue_only%&, &%queue_only_file%&, and &%queue_only_load%& options. The
29764 number of simultaneously running delivery processes started in this way from
29765 SMTP input can be limited by the &%smtp_accept_queue%& and
29766 &%smtp_accept_queue_per_connection%& options. When either limit is reached,
29767 subsequently received messages are just put on the input queue without starting
29768 a delivery process.
29769
29770 The controls that involve counts of incoming SMTP calls (&%smtp_accept_max%&,
29771 &%smtp_accept_queue%&, &%smtp_accept_reserve%&) are not available when Exim is
29772 started up from the &'inetd'& daemon, because in that case each connection is
29773 handled by an entirely independent Exim process. Control by load average is,
29774 however, available with &'inetd'&.
29775
29776 Exim can be configured to verify addresses in incoming SMTP commands as they
29777 are received. See chapter &<<CHAPACL>>& for details. It can also be configured
29778 to rewrite addresses at this time &-- before any syntax checking is done. See
29779 section &<<SECTrewriteS>>&.
29780
29781 Exim can also be configured to limit the rate at which a client host submits
29782 MAIL and RCPT commands in a single SMTP session. See the
29783 &%smtp_ratelimit_hosts%& option.
29784
29785
29786
29787 .section "Unrecognized SMTP commands"
29788 .cindex "SMTP" "unrecognized commands"
29789 If Exim receives more than &%smtp_max_unknown_commands%& unrecognized SMTP
29790 commands during a single SMTP connection, it drops the connection after sending
29791 the error response to the last command. The default value for
29792 &%smtp_max_unknown_commands%& is 3. This is a defence against some kinds of
29793 abuse that subvert web servers into making connections to SMTP ports; in these
29794 circumstances, a number of non-SMTP lines are sent first.
29795
29796
29797 .section "Syntax and protocol errors in SMTP commands"
29798 .cindex "SMTP" "syntax errors"
29799 .cindex "SMTP" "protocol errors"
29800 A syntax error is detected if an SMTP command is recognized, but there is
29801 something syntactically wrong with its data, for example, a malformed email
29802 address in a RCPT command. Protocol errors include invalid command
29803 sequencing such as RCPT before MAIL. If Exim receives more than
29804 &%smtp_max_synprot_errors%& such commands during a single SMTP connection, it
29805 drops the connection after sending the error response to the last command. The
29806 default value for &%smtp_max_synprot_errors%& is 3. This is a defence against
29807 broken clients that loop sending bad commands (yes, it has been seen).
29808
29809
29810
29811 .section "Use of non-mail SMTP commands"
29812 .cindex "SMTP" "non-mail commands"
29813 The &"non-mail"& SMTP commands are those other than MAIL, RCPT, and
29814 DATA. Exim counts such commands, and drops the connection if there are too
29815 many of them in a single SMTP session. This action catches some
29816 denial-of-service attempts and things like repeated failing AUTHs, or a mad
29817 client looping sending EHLO. The global option &%smtp_accept_max_nonmail%&
29818 defines what &"too many"& means. Its default value is 10.
29819
29820 When a new message is expected, one occurrence of RSET is not counted. This
29821 allows a client to send one RSET between messages (this is not necessary,
29822 but some clients do it). Exim also allows one uncounted occurence of HELO
29823 or EHLO, and one occurrence of STARTTLS between messages. After
29824 starting up a TLS session, another EHLO is expected, and so it too is not
29825 counted.
29826
29827 The first occurrence of AUTH in a connection, or immediately following
29828 STARTTLS is also not counted. Otherwise, all commands other than MAIL,
29829 RCPT, DATA, and QUIT are counted.
29830
29831 You can control which hosts are subject to the limit set by
29832 &%smtp_accept_max_nonmail%& by setting
29833 &%smtp_accept_max_nonmail_hosts%&. The default value is &`*`&, which makes
29834 the limit apply to all hosts. This option means that you can exclude any
29835 specific badly-behaved hosts that you have to live with.
29836
29837
29838
29839
29840 .section "The VRFY and EXPN commands"
29841 When Exim receives a VRFY or EXPN command on a TCP/IP connection, it
29842 runs the ACL specified by &%acl_smtp_vrfy%& or &%acl_smtp_expn%& (as
29843 appropriate) in order to decide whether the command should be accepted or not.
29844 If no ACL is defined, the command is rejected.
29845
29846 .cindex "VRFY" "processing"
29847 When VRFY is accepted, it runs exactly the same code as when Exim is
29848 called with the &%-bv%& option.
29849
29850 .cindex "EXPN" "processing"
29851 When EXPN is accepted, a single-level expansion of the address is done.
29852 EXPN is treated as an &"address test"& (similar to the &%-bt%& option) rather
29853 than a verification (the &%-bv%& option). If an unqualified local part is given
29854 as the argument to EXPN, it is qualified with &%qualify_domain%&. Rejections
29855 of VRFY and EXPN commands are logged on the main and reject logs, and
29856 VRFY verification failures are logged on the main log for consistency with
29857 RCPT failures.
29858
29859
29860
29861 .section "The ETRN command" "SECTETRN"
29862 .cindex "ETRN" "processing"
29863 RFC 1985 describes an SMTP command called ETRN that is designed to
29864 overcome the security problems of the TURN command (which has fallen into
29865 disuse). When Exim receives an ETRN command on a TCP/IP connection, it runs
29866 the ACL specified by &%acl_smtp_etrn%& in order to decide whether the command
29867 should be accepted or not. If no ACL is defined, the command is rejected.
29868
29869 The ETRN command is concerned with &"releasing"& messages that are awaiting
29870 delivery to certain hosts. As Exim does not organize its message queue by host,
29871 the only form of ETRN that is supported by default is the one where the
29872 text starts with the &"#"& prefix, in which case the remainder of the text is
29873 specific to the SMTP server. A valid ETRN command causes a run of Exim with
29874 the &%-R%& option to happen, with the remainder of the ETRN text as its
29875 argument. For example,
29876 .code
29877 ETRN #brigadoon
29878 .endd
29879 runs the command
29880 .code
29881 exim -R brigadoon
29882 .endd
29883 which causes a delivery attempt on all messages with undelivered addresses
29884 containing the text &"brigadoon"&. When &%smtp_etrn_serialize%& is set (the
29885 default), Exim prevents the simultaneous execution of more than one queue run
29886 for the same argument string as a result of an ETRN command. This stops
29887 a misbehaving client from starting more than one queue runner at once.
29888
29889 .cindex "hints database" "ETRN serialization"
29890 Exim implements the serialization by means of a hints database in which a
29891 record is written whenever a process is started by ETRN, and deleted when
29892 the process completes. However, Exim does not keep the SMTP session waiting for
29893 the ETRN process to complete. Once ETRN is accepted, the client is sent
29894 a &"success"& return code. Obviously there is scope for hints records to get
29895 left lying around if there is a system or program crash. To guard against this,
29896 Exim ignores any records that are more than six hours old.
29897
29898 .cindex "&%smtp_etrn_command%&"
29899 For more control over what ETRN does, the &%smtp_etrn_command%& option can
29900 used. This specifies a command that is run whenever ETRN is received,
29901 whatever the form of its argument. For
29902 example:
29903 .code
29904 smtp_etrn_command = /etc/etrn_command $domain \
29905                     $sender_host_address
29906 .endd
29907 .cindex "&$domain$&"
29908 The string is split up into arguments which are independently expanded. The
29909 expansion variable &$domain$& is set to the argument of the ETRN command,
29910 and no syntax checking is done on the contents of this argument. Exim does not
29911 wait for the command to complete, so its status code is not checked. Exim runs
29912 under its own uid and gid when receiving incoming SMTP, so it is not possible
29913 for it to change them before running the command.
29914
29915
29916
29917 .section "Incoming local SMTP"
29918 .cindex "SMTP" "local incoming"
29919 Some user agents use SMTP to pass messages to their local MTA using the
29920 standard input and output, as opposed to passing the envelope on the command
29921 line and writing the message to the standard input. This is supported by the
29922 &%-bs%& option. This form of SMTP is handled in the same way as incoming
29923 messages over TCP/IP (including the use of ACLs), except that the envelope
29924 sender given in a MAIL command is ignored unless the caller is trusted. In
29925 an ACL you can detect this form of SMTP input by testing for an empty host
29926 identification. It is common to have this as the first line in the ACL that
29927 runs for RCPT commands:
29928 .code
29929 accept hosts = :
29930 .endd
29931 This accepts SMTP messages from local processes without doing any other tests.
29932
29933
29934
29935 .section "Outgoing batched SMTP" "SECTbatchSMTP"
29936 .cindex "SMTP" "batched outgoing"
29937 .cindex "batched SMTP output"
29938 Both the &(appendfile)& and &(pipe)& transports can be used for handling
29939 batched SMTP. Each has an option called &%use_bsmtp%& which causes messages to
29940 be output in BSMTP format. No SMTP responses are possible for this form of
29941 delivery. All it is doing is using SMTP commands as a way of transmitting the
29942 envelope along with the message.
29943
29944 The message is written to the file or pipe preceded by the SMTP commands
29945 MAIL and RCPT, and followed by a line containing a single dot. Lines in
29946 the message that start with a dot have an extra dot added. The SMTP command
29947 HELO is not normally used. If it is required, the &%message_prefix%& option
29948 can be used to specify it.
29949
29950 Because &(appendfile)& and &(pipe)& are both local transports, they accept only
29951 one recipient address at a time by default. However, you can arrange for them
29952 to handle several addresses at once by setting the &%batch_max%& option. When
29953 this is done for BSMTP, messages may contain multiple RCPT commands. See
29954 chapter &<<CHAPbatching>>& for more details.
29955
29956 .cindex "&$host$&"
29957 When one or more addresses are routed to a BSMTP transport by a router that
29958 sets up a host list, the name of the first host on the list is available to the
29959 transport in the variable &$host$&. Here is an example of such a transport and
29960 router:
29961 .code
29962 begin routers
29963 route_append:
29964   driver = manualroute
29965   transport = smtp_appendfile
29966   route_list = domain.example  batch.host.example
29967
29968 begin transports
29969 smtp_appendfile:
29970   driver = appendfile
29971   directory = /var/bsmtp/$host
29972   batch_max = 1000
29973   use_bsmtp
29974   user = exim
29975 .endd
29976 This causes messages addressed to &'domain.example'& to be written in BSMTP
29977 format to &_/var/bsmtp/batch.host.example_&, with only a single copy of each
29978 message (unless there are more than 1000 recipients).
29979
29980
29981
29982 .section "Incoming batched SMTP" "SECTincomingbatchedSMTP"
29983 .cindex "SMTP" "batched incoming"
29984 .cindex "batched SMTP input"
29985 The &%-bS%& command line option causes Exim to accept one or more messages by
29986 reading SMTP on the standard input, but to generate no responses. If the caller
29987 is trusted, the senders in the MAIL commands are believed; otherwise the
29988 sender is always the caller of Exim. Unqualified senders and receivers are not
29989 rejected (there seems little point) but instead just get qualified. HELO
29990 and EHLO act as RSET; VRFY, EXPN, ETRN and  HELP, act
29991 as NOOP; QUIT quits.
29992
29993 No policy checking is done for BSMTP input. That is, no ACL is run at anytime.
29994 In this respect it is like non-SMTP local input.
29995
29996 If an error is detected while reading a message, including a missing &"."& at
29997 the end, Exim gives up immediately. It writes details of the error to the
29998 standard output in a stylized way that the calling program should be able to
29999 make some use of automatically, for example:
30000 .code
30001 554 Unexpected end of file
30002 Transaction started in line 10
30003 Error detected in line 14
30004 .endd
30005 It writes a more verbose version, for human consumption, to the standard error
30006 file, for example:
30007 .code
30008 An error was detected while processing a file of BSMTP input.
30009 The error message was:
30010
30011 501 '>' missing at end of address
30012
30013 The SMTP transaction started in line 10.
30014 The error was detected in line 12.
30015 The SMTP command at fault was:
30016
30017 rcpt to:<malformed@in.com.plete
30018
30019 1 previous message was successfully processed.
30020 The rest of the batch was abandoned.
30021 .endd
30022 The return code from Exim is zero only if there were no errors. It is 1 if some
30023 messages were accepted before an error was detected, and 2 if no messages were
30024 accepted.
30025 .ecindex IIDsmtpproc1
30026 .ecindex IIDsmtpproc2
30027
30028
30029
30030 . ////////////////////////////////////////////////////////////////////////////
30031 . ////////////////////////////////////////////////////////////////////////////
30032
30033 .chapter "Customizing bounce and warning messages" "CHAPemsgcust" &&&
30034          "Customizing messages"
30035 When a message fails to be delivered, or remains on the queue for more than a
30036 configured amount of time, Exim sends a message to the original sender, or
30037 to an alternative configured address. The text of these messages is built into
30038 the code of Exim, but it is possible to change it, either by adding a single
30039 string, or by replacing each of the paragraphs by text supplied in a file.
30040
30041 The &'From:'& and &'To:'& header lines are automatically generated; you can
30042 cause a &'Reply-To:'& line to be added by setting the &%errors_reply_to%&
30043 option. Exim also adds the line
30044 .code
30045 Auto-Submitted: auto-generated
30046 .endd
30047 to all warning and bounce messages,
30048
30049
30050 .section "Customizing bounce messages"
30051 .cindex "customizing" "bounce message"
30052 .cindex "bounce message" "customizing"
30053 If &%bounce_message_text%& is set, its contents are included in the default
30054 message immediately after &"This message was created automatically by mail
30055 delivery software."& The string is not expanded. It is not used if
30056 &%bounce_message_file%& is set.
30057
30058 When &%bounce_message_file%& is set, it must point to a template file for
30059 constructing error messages. The file consists of a series of text items,
30060 separated by lines consisting of exactly four asterisks. If the file cannot be
30061 opened, default text is used and a message is written to the main and panic
30062 logs. If any text item in the file is empty, default text is used for that
30063 item.
30064
30065 .cindex "&$bounce_recipient$&"
30066 .cindex "&$bounce_return_size_limit$&"
30067 Each item of text that is read from the file is expanded, and there are two
30068 expansion variables which can be of use here: &$bounce_recipient$& is set to
30069 the recipient of an error message while it is being created, and
30070 &$bounce_return_size_limit$& contains the value of the &%return_size_limit%&
30071 option, rounded to a whole number.
30072
30073 The items must appear in the file in the following order:
30074
30075 .ilist
30076 The first item is included in the headers, and should include at least a
30077 &'Subject:'& header. Exim does not check the syntax of these headers.
30078 .next
30079 The second item forms the start of the error message. After it, Exim lists the
30080 failing addresses with their error messages.
30081 .next
30082 The third item is used to introduce any text from pipe transports that is to be
30083 returned to the sender. It is omitted if there is no such text.
30084 .next
30085 The fourth item is used to introduce the copy of the message that is returned
30086 as part of the error report.
30087 .next
30088 The fifth item is added after the fourth one if the returned message is
30089 truncated because it is bigger than &%return_size_limit%&.
30090 .next
30091 The sixth item is added after the copy of the original message.
30092 .endlist
30093
30094 The default state (&%bounce_message_file%& unset) is equivalent to the
30095 following file, in which the sixth item is empty. The &'Subject:'& and some
30096 other lines have been split in order to fit them on the page:
30097 .code
30098 Subject: Mail delivery failed
30099   ${if eq{$sender_address}{$bounce_recipient}
30100   {: returning message to sender}}
30101 ****
30102 This message was created automatically by mail delivery software.
30103
30104 A message ${if eq{$sender_address}{$bounce_recipient}
30105   {that you sent }{sent by
30106
30107 <$sender_address>
30108
30109 }}could not be delivered to all of its recipients.
30110 This is a permanent error. The following address(es) failed:
30111 ****
30112 The following text was generated during the delivery attempt(s):
30113 ****
30114 ------ This is a copy of the message, including all the headers.
30115   ------
30116 ****
30117 ------ The body of the message is $message_size characters long;
30118   only the first
30119 ------ $bounce_return_size_limit or so are included here.
30120 ****
30121 .endd
30122 .section "Customizing warning messages" "SECTcustwarn"
30123 .cindex "customizing" "warning message"
30124 .cindex "warning of delay" "customizing the message"
30125 The option &%warn_message_file%& can be pointed at a template file for use when
30126 warnings about message delays are created. In this case there are only three
30127 text sections:
30128
30129 .ilist
30130 The first item is included in the headers, and should include at least a
30131 &'Subject:'& header. Exim does not check the syntax of these headers.
30132 .next
30133 The second item forms the start of the warning message. After it, Exim lists
30134 the delayed addresses.
30135 .next
30136 The third item then ends the message.
30137 .endlist
30138
30139 The default state is equivalent to the following file, except that some lines
30140 have been split here, in order to fit them on the page:
30141 .code
30142 Subject: Warning: message $message_exim_id delayed
30143   $warn_message_delay
30144 ****
30145 This message was created automatically by mail delivery software.
30146
30147 A message ${if eq{$sender_address}{$warn_message_recipients}
30148 {that you sent }{sent by
30149
30150 <$sender_address>
30151
30152 }}has not been delivered to all of its recipients after
30153 more than $warn_message_delay on the queue on $primary_hostname.
30154
30155 The message identifier is:     $message_exim_id
30156 The subject of the message is: $h_subject
30157 The date of the message is:    $h_date
30158
30159 The following address(es) have not yet been delivered:
30160 ****
30161 No action is required on your part. Delivery attempts will
30162 continue for some time, and this warning may be repeated at
30163 intervals if the message remains undelivered. Eventually the
30164 mail delivery software will give up, and when that happens,
30165 the message will be returned to you.
30166 .endd
30167 .cindex "&$warn_message_delay$&"
30168 .cindex "&$warn_message_recipients$&"
30169 However, in the default state the subject and date lines are omitted if no
30170 appropriate headers exist. During the expansion of this file,
30171 &$warn_message_delay$& is set to the delay time in one of the forms &"<&'n'&>
30172 minutes"& or &"<&'n'&> hours"&, and &$warn_message_recipients$& contains a list
30173 of recipients for the warning message. There may be more than one if there are
30174 multiple addresses with different &%errors_to%& settings on the routers that
30175 handled them.
30176
30177
30178
30179
30180 . ////////////////////////////////////////////////////////////////////////////
30181 . ////////////////////////////////////////////////////////////////////////////
30182
30183 .chapter "Some common configuration settings" "CHAPcomconreq"
30184 This chapter discusses some configuration settings that seem to be fairly
30185 common. More examples and discussion can be found in the Exim book.
30186
30187
30188
30189 .section "Sending mail to a smart host"
30190 .cindex "smart host" "example router"
30191 If you want to send all mail for non-local domains to a &"smart host"&, you
30192 should replace the default &(dnslookup)& router with a router which does the
30193 routing explicitly:
30194 .code
30195 send_to_smart_host:
30196   driver = manualroute
30197   route_list = !+local_domains smart.host.name
30198   transport = remote_smtp
30199 .endd
30200 You can use the smart host's IP address instead of the name if you wish.
30201 If you are using Exim only to submit messages to a smart host, and not for
30202 receiving incoming messages, you can arrange for it to do the submission
30203 synchronously by setting the &%mua_wrapper%& option (see chapter
30204 &<<CHAPnonqueueing>>&).
30205
30206
30207
30208
30209 .section "Using Exim to handle mailing lists" "SECTmailinglists"
30210 .cindex "mailing lists"
30211 Exim can be used to run simple mailing lists, but for large and/or complicated
30212 requirements, the use of additional specialized mailing list software such as
30213 Majordomo or Mailman is recommended.
30214
30215 The &(redirect)& router can be used to handle mailing lists where each list
30216 is maintained in a separate file, which can therefore be managed by an
30217 independent manager. The &%domains%& router option can be used to run these
30218 lists in a separate domain from normal mail. For example:
30219 .code
30220 lists:
30221   driver = redirect
30222   domains = lists.example
30223   file = /usr/lists/$local_part
30224   forbid_pipe
30225   forbid_file
30226   errors_to = $local_part-request@lists.example
30227   no_more
30228 .endd
30229 This router is skipped for domains other than &'lists.example'&. For addresses
30230 in that domain, it looks for a file that matches the local part. If there is no
30231 such file, the router declines, but because &%no_more%& is set, no subsequent
30232 routers are tried, and so the whole delivery fails.
30233
30234 The &%forbid_pipe%& and &%forbid_file%& options prevent a local part from being
30235 expanded into a file name or a pipe delivery, which is usually inappropriate in
30236 a mailing list.
30237
30238 .cindex "&%errors_to%&"
30239 The &%errors_to%& option specifies that any delivery errors caused by addresses
30240 taken from a mailing list are to be sent to the given address rather than the
30241 original sender of the message. However, before acting on this, Exim verifies
30242 the error address, and ignores it if verification fails.
30243
30244 For example, using the configuration above, mail sent to
30245 &'dicts@lists.example'& is passed on to those addresses contained in
30246 &_/usr/lists/dicts_&, with error reports directed to
30247 &'dicts-request@lists.example'&, provided that this address can be verified.
30248 There could be a file called &_/usr/lists/dicts-request_& containing
30249 the address(es) of this particular list's manager(s), but other approaches,
30250 such as setting up an earlier router (possibly using the &%local_part_prefix%&
30251 or &%local_part_suffix%& options) to handle addresses of the form
30252 &%owner-%&&'xxx'& or &%xxx-%&&'request'&, are also possible.
30253
30254
30255
30256 .section "Syntax errors in mailing lists"
30257 .cindex "mailing lists" "syntax errors in"
30258 If an entry in redirection data contains a syntax error, Exim normally defers
30259 delivery of the original address. That means that a syntax error in a mailing
30260 list holds up all deliveries to the list. This may not be appropriate when a
30261 list is being maintained automatically from data supplied by users, and the
30262 addresses are not rigorously checked.
30263
30264 If the &%skip_syntax_errors%& option is set, the &(redirect)& router just skips
30265 entries that fail to parse, noting the incident in the log. If in addition
30266 &%syntax_errors_to%& is set to a verifiable address, a message is sent to it
30267 whenever a broken address is skipped. It is usually appropriate to set
30268 &%syntax_errors_to%& to the same address as &%errors_to%&.
30269
30270
30271
30272 .section "Re-expansion of mailing lists"
30273 .cindex "mailing lists" "re-expansion of"
30274 Exim remembers every individual address to which a message has been delivered,
30275 in order to avoid duplication, but it normally stores only the original
30276 recipient addresses with a message. If all the deliveries to a mailing list
30277 cannot be done at the first attempt, the mailing list is re-expanded when the
30278 delivery is next tried. This means that alterations to the list are taken into
30279 account at each delivery attempt, so addresses that have been added to
30280 the list since the message arrived will therefore receive a copy of the
30281 message, even though it pre-dates their subscription.
30282
30283 If this behaviour is felt to be undesirable, the &%one_time%& option can be set
30284 on the &(redirect)& router. If this is done, any addresses generated by the
30285 router that fail to deliver at the first attempt are added to the message as
30286 &"top level"& addresses, and the parent address that generated them is marked
30287 &"delivered"&. Thus, expansion of the mailing list does not happen again at the
30288 subsequent delivery attempts. The disadvantage of this is that if any of the
30289 failing addresses are incorrect, correcting them in the file has no effect on
30290 pre-existing messages.
30291
30292 The original top-level address is remembered with each of the generated
30293 addresses, and is output in any log messages. However, any intermediate parent
30294 addresses are not recorded. This makes a difference to the log only if the
30295 &%all_parents%& selector is set, but for mailing lists there is normally only
30296 one level of expansion anyway.
30297
30298
30299
30300 .section "Closed mailing lists"
30301 .cindex "mailing lists" "closed"
30302 The examples so far have assumed open mailing lists, to which anybody may
30303 send mail. It is also possible to set up closed lists, where mail is accepted
30304 from specified senders only. This is done by making use of the generic
30305 &%senders%& option to restrict the router that handles the list.
30306
30307 The following example uses the same file as a list of recipients and as a list
30308 of permitted senders. It requires three routers:
30309 .code
30310 lists_request:
30311   driver = redirect
30312   domains = lists.example
30313   local_part_suffix = -request
30314   file = /usr/lists/$local_part$local_part_suffix
30315   no_more
30316
30317 lists_post:
30318   driver = redirect
30319   domains = lists.example
30320   senders = ${if exists {/usr/lists/$local_part}\
30321              {lsearch;/usr/lists/$local_part}{*}}
30322   file = /usr/lists/$local_part
30323   forbid_pipe
30324   forbid_file
30325   errors_to = $local_part-request@lists.example
30326   no_more
30327
30328 lists_closed:
30329   driver = redirect
30330   domains = lists.example
30331   allow_fail
30332   data = :fail: $local_part@lists.example is a closed mailing list
30333 .endd
30334 All three routers have the same &%domains%& setting, so for any other domains,
30335 they are all skipped. The first router runs only if the local part ends in
30336 &%-request%&. It handles messages to the list manager(s) by means of an open
30337 mailing list.
30338
30339 The second router runs only if the &%senders%& precondition is satisfied. It
30340 checks for the existence of a list that corresponds to the local part, and then
30341 checks that the sender is on the list by means of a linear search. It is
30342 necessary to check for the existence of the file before trying to search it,
30343 because otherwise Exim thinks there is a configuration error. If the file does
30344 not exist, the expansion of &%senders%& is *, which matches all senders. This
30345 means that the router runs, but because there is no list, declines, and
30346 &%no_more%& ensures that no further routers are run. The address fails with an
30347 &"unrouteable address"& error.
30348
30349 The third router runs only if the second router is skipped, which happens when
30350 a mailing list exists, but the sender is not on it. This router forcibly fails
30351 the address, giving a suitable error message.
30352
30353
30354
30355
30356 .section "Variable Envelope Return Paths (VERP)" "SECTverp"
30357 .cindex "VERP"
30358 .cindex "Variable Envelope Return Paths"
30359 .cindex "envelope sender"
30360 Variable Envelope Return Paths &-- see &url(http://cr.yp.to/proto/verp.txt) &--
30361 are a way of helping mailing list administrators discover which subscription
30362 address is the cause of a particular delivery failure. The idea is to encode
30363 the original recipient address in the outgoing envelope sender address, so that
30364 if the message is forwarded by another host and then subsequently bounces, the
30365 original recipient can be extracted from the recipient address of the bounce.
30366
30367 .oindex &%errors_to%&
30368 .oindex &%return_path%&
30369 Envelope sender addresses can be modified by Exim using two different
30370 facilities: the &%errors_to%& option on a router (as shown in previous mailing
30371 list examples), or the &%return_path%& option on a transport. The second of
30372 these is effective only if the message is successfully delivered to another
30373 host; it is not used for errors detected on the local host (see the description
30374 of &%return_path%& in chapter &<<CHAPtransportgeneric>>&). Here is an example
30375 of the use of &%return_path%& to implement VERP on an &(smtp)& transport:
30376 .code
30377 verp_smtp:
30378   driver = smtp
30379   max_rcpt = 1
30380   return_path = \
30381     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
30382       {$1-request+$local_part=$domain@your.dom.example}fail}
30383 .endd
30384 This has the effect of rewriting the return path (envelope sender) on outgoing
30385 SMTP messages, if the local part of the original return path ends in
30386 &"-request"&, and the domain is &'your.dom.example'&. The rewriting inserts the
30387 local part and domain of the recipient into the return path. Suppose, for
30388 example, that a message whose return path has been set to
30389 &'somelist-request@your.dom.example'& is sent to
30390 &'subscriber@other.dom.example'&. In the transport, the return path is
30391 rewritten as
30392 .code
30393 somelist-request+subscriber=other.dom.example@your.dom.example
30394 .endd
30395 .cindex "&$local_part$&"
30396 For this to work, you must tell Exim to send multiple copies of messages that
30397 have more than one recipient, so that each copy has just one recipient. This is
30398 achieved by setting &%max_rcpt%& to 1. Without this, a single copy of a message
30399 might be sent to several different recipients in the same domain, in which case
30400 &$local_part$& is not available in the transport, because it is not unique.
30401
30402 Unless your host is doing nothing but mailing list deliveries, you should
30403 probably use a separate transport for the VERP deliveries, so as not to use
30404 extra resources in making one-per-recipient copies for other deliveries. This
30405 can easily be done by expanding the &%transport%& option in the router:
30406 .code
30407 dnslookup:
30408   driver = dnslookup
30409   domains = ! +local_domains
30410   transport = \
30411     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
30412       {verp_smtp}{remote_smtp}}
30413   no_more
30414 .endd
30415 If you want to change the return path using &%errors_to%& in a router instead
30416 of using &%return_path%& in the transport, you need to set &%errors_to%& on all
30417 routers that handle mailing list addresses. This will ensure that all delivery
30418 errors, including those detected on the local host, are sent to the VERP
30419 address.
30420
30421 On a host that does no local deliveries and has no manual routing, only the
30422 &(dnslookup)& router needs to be changed. A special transport is not needed for
30423 SMTP deliveries. Every mailing list recipient has its own return path value,
30424 and so Exim must hand them to the transport one at a time. Here is an example
30425 of a &(dnslookup)& router that implements VERP:
30426 .code
30427 verp_dnslookup:
30428   driver = dnslookup
30429   domains = ! +local_domains
30430   transport = remote_smtp
30431   errors_to = \
30432     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}}
30433      {$1-request+$local_part=$domain@your.dom.example}fail}
30434   no_more
30435 .endd
30436 Before you start sending out messages with VERPed return paths, you must also
30437 configure Exim to accept the bounce messages that come back to those paths.
30438 Typically this is done by setting a &%local_part_suffix%& option for a
30439 router, and using this to route the messages to wherever you want to handle
30440 them.
30441
30442 The overhead incurred in using VERP depends very much on the size of the
30443 message, the number of recipient addresses that resolve to the same remote
30444 host, and the speed of the connection over which the message is being sent. If
30445 a lot of addresses resolve to the same host and the connection is slow, sending
30446 a separate copy of the message for each address may take substantially longer
30447 than sending a single copy with many recipients (for which VERP cannot be
30448 used).
30449
30450
30451
30452
30453
30454
30455 .section "Virtual domains" "SECTvirtualdomains"
30456 .cindex "virtual domains"
30457 .cindex "domain" "virtual"
30458 The phrase &'virtual domain'& is unfortunately used with two rather different
30459 meanings:
30460
30461 .ilist
30462 A domain for which there are no real mailboxes; all valid local parts are
30463 aliases for other email addresses. Common examples are organizational
30464 top-level domains and &"vanity"& domains.
30465 .next
30466 One of a number of independent domains that are all handled by the same host,
30467 with mailboxes on that host, but where the mailbox owners do not necessarily
30468 have login accounts on that host.
30469 .endlist
30470
30471 The first usage is probably more common, and does seem more &"virtual"& than
30472 the second. This kind of domain can be handled in Exim with a straightforward
30473 aliasing router. One approach is to create a separate alias file for each
30474 virtual domain. Exim can test for the existence of the alias file to determine
30475 whether the domain exists. The &(dsearch)& lookup type is useful here, leading
30476 to a router of this form:
30477 .code
30478 virtual:
30479   driver = redirect
30480   domains = dsearch;/etc/mail/virtual
30481   data = ${lookup{$local_part}lsearch{/etc/mail/virtual/$domain}}
30482   no_more
30483 .endd
30484 The &%domains%& option specifies that the router is to be skipped, unless there
30485 is a file in the &_/etc/mail/virtual_& directory whose name is the same as the
30486 domain that is being processed. When the router runs, it looks up the local
30487 part in the file to find a new address (or list of addresses). The &%no_more%&
30488 setting ensures that if the lookup fails (leading to &%data%& being an empty
30489 string), Exim gives up on the address without trying any subsequent routers.
30490
30491 This one router can handle all the virtual domains because the alias file names
30492 follow a fixed pattern. Permissions can be arranged so that appropriate people
30493 can edit the different alias files. A successful aliasing operation results in
30494 a new envelope recipient address, which is then routed from scratch.
30495
30496 The other kind of &"virtual"& domain can also be handled in a straightforward
30497 way. One approach is to create a file for each domain containing a list of
30498 valid local parts, and use it in a router like this:
30499 .code
30500 my_domains:
30501   driver = accept
30502   domains = dsearch;/etc/mail/domains
30503   local_parts = lsearch;/etc/mail/domains/$domain
30504   transport = my_mailboxes
30505 .endd
30506 The address is accepted if there is a file for the domain, and the local part
30507 can be found in the file. The &%domains%& option is used to check for the
30508 file's existence because &%domains%& is tested before the &%local_parts%&
30509 option (see section &<<SECTrouprecon>>&). You cannot use &%require_files%&,
30510 because that option is tested after &%local_parts%&. The transport is as
30511 follows:
30512 .code
30513 my_mailboxes:
30514   driver = appendfile
30515   file = /var/mail/$domain/$local_part
30516   user = mail
30517 .endd
30518 This uses a directory of mailboxes for each domain. The &%user%& setting is
30519 required, to specify which uid is to be used for writing to the mailboxes.
30520
30521 The configuration shown here is just one example of how you might support this
30522 requirement. There are many other ways this kind of configuration can be set
30523 up, for example, by using a database instead of separate files to hold all the
30524 information about the domains.
30525
30526
30527
30528 .section "Multiple user mailboxes" "SECTmulbox"
30529 .cindex "multiple mailboxes"
30530 .cindex "mailbox" "multiple"
30531 .cindex "local part" "prefix"
30532 .cindex "local part" "suffix"
30533 Heavy email users often want to operate with multiple mailboxes, into which
30534 incoming mail is automatically sorted. A popular way of handling this is to
30535 allow users to use multiple sender addresses, so that replies can easily be
30536 identified. Users are permitted to add prefixes or suffixes to their local
30537 parts for this purpose. The wildcard facility of the generic router options
30538 &%local_part_prefix%& and &%local_part_suffix%& can be used for this. For
30539 example, consider this router:
30540 .code
30541 userforward:
30542   driver = redirect
30543   check_local_user
30544   file = $home/.forward
30545   local_part_suffix = -*
30546   local_part_suffix_optional
30547   allow_filter
30548 .endd
30549 .cindex "&$local_part_suffix$&"
30550 It runs a user's &_.forward_& file for all local parts of the form
30551 &'username-*'&. Within the filter file the user can distinguish different
30552 cases by testing the variable &$local_part_suffix$&. For example:
30553 .code
30554 if $local_part_suffix contains -special then
30555 save /home/$local_part/Mail/special
30556 endif
30557 .endd
30558 If the filter file does not exist, or does not deal with such addresses, they
30559 fall through to subsequent routers, and, assuming no subsequent use of the
30560 &%local_part_suffix%& option is made, they presumably fail. Thus, users have
30561 control over which suffixes are valid.
30562
30563 Alternatively, a suffix can be used to trigger the use of a different
30564 &_.forward_& file &-- which is the way a similar facility is implemented in
30565 another MTA:
30566 .code
30567 userforward:
30568   driver = redirect
30569   check_local_user
30570   file = $home/.forward$local_part_suffix
30571   local_part_suffix = -*
30572   local_part_suffix_optional
30573   allow_filter
30574 .endd
30575 If there is no suffix, &_.forward_& is used; if the suffix is &'-special'&, for
30576 example, &_.forward-special_& is used. Once again, if the appropriate file
30577 does not exist, or does not deal with the address, it is passed on to
30578 subsequent routers, which could, if required, look for an unqualified
30579 &_.forward_& file to use as a default.
30580
30581
30582
30583 .section "Simplified vacation processing"
30584 .cindex "vacation processing"
30585 The traditional way of running the &'vacation'& program is for a user to set up
30586 a pipe command in a &_.forward_& file
30587 (see section &<<SECTspecitredli>>& for syntax details).
30588 This is prone to error by inexperienced users. There are two features of Exim
30589 that can be used to make this process simpler for users:
30590
30591 .ilist
30592 A local part prefix such as &"vacation-"& can be specified on a router which
30593 can cause the message to be delivered directly to the &'vacation'& program, or
30594 alternatively can use Exim's &(autoreply)& transport. The contents of a user's
30595 &_.forward_& file are then much simpler. For example:
30596 .code
30597 spqr, vacation-spqr
30598 .endd
30599 .next
30600 The &%require_files%& generic router option can be used to trigger a
30601 vacation delivery by checking for the existence of a certain file in the
30602 user's home directory. The &%unseen%& generic option should also be used, to
30603 ensure that the original delivery also proceeds. In this case, all the user has
30604 to do is to create a file called, say, &_.vacation_&, containing a vacation
30605 message.
30606 .endlist
30607
30608 Another advantage of both these methods is that they both work even when the
30609 use of arbitrary pipes by users is locked out.
30610
30611
30612
30613 .section "Taking copies of mail"
30614 .cindex "message" "copying every"
30615 Some installations have policies that require archive copies of all messages to
30616 be made. A single copy of each message can easily be taken by an appropriate
30617 command in a system filter, which could, for example, use a different file for
30618 each day's messages.
30619
30620 There is also a shadow transport mechanism that can be used to take copies of
30621 messages that are successfully delivered by local transports, one copy per
30622 delivery. This could be used, &'inter alia'&, to implement automatic
30623 notification of delivery by sites that insist on doing such things.
30624
30625
30626
30627 .section "Intermittently connected hosts"
30628 .cindex "intermittently connected hosts"
30629 It has become quite common (because it is cheaper) for hosts to connect to the
30630 Internet periodically rather than remain connected all the time. The normal
30631 arrangement is that mail for such hosts accumulates on a system that is
30632 permanently connected.
30633
30634 Exim was designed for use on permanently connected hosts, and so it is not
30635 particularly well-suited to use in an intermittently connected environment.
30636 Nevertheless there are some features that can be used.
30637
30638
30639 .section "Exim on the upstream server host"
30640 It is tempting to arrange for incoming mail for the intermittently connected
30641 host to remain on Exim's queue until the client connects. However, this
30642 approach does not scale very well. Two different kinds of waiting message are
30643 being mixed up in the same queue &-- those that cannot be delivered because of
30644 some temporary problem, and those that are waiting for their destination host
30645 to connect. This makes it hard to manage the queue, as well as wasting
30646 resources, because each queue runner scans the entire queue.
30647
30648 A better approach is to separate off those messages that are waiting for an
30649 intermittently connected host. This can be done by delivering these messages
30650 into local files in batch SMTP, &"mailstore"&, or other envelope-preserving
30651 format, from where they are transmitted by other software when their
30652 destination connects. This makes it easy to collect all the mail for one host
30653 in a single directory, and to apply local timeout rules on a per-message basis
30654 if required.
30655
30656 On a very small scale, leaving the mail on Exim's queue can be made to work. If
30657 you are doing this, you should configure Exim with a long retry period for the
30658 intermittent host. For example:
30659 .code
30660 cheshire.wonderland.fict.example    *   F,5d,24h
30661 .endd
30662 This stops a lot of failed delivery attempts from occurring, but Exim remembers
30663 which messages it has queued up for that host. Once the intermittent host comes
30664 online, forcing delivery of one message (either by using the &%-M%& or &%-R%&
30665 options, or by using the ETRN SMTP command (see section &<<SECTETRN>>&)
30666 causes all the queued up messages to be delivered, often down a single SMTP
30667 connection. While the host remains connected, any new messages get delivered
30668 immediately.
30669
30670 If the connecting hosts do not have fixed IP addresses, that is, if a host is
30671 issued with a different IP address each time it connects, Exim's retry
30672 mechanisms on the holding host get confused, because the IP address is normally
30673 used as part of the key string for holding retry information. This can be
30674 avoided by unsetting &%retry_include_ip_address%& on the &(smtp)& transport.
30675 Since this has disadvantages for permanently connected hosts, it is best to
30676 arrange a separate transport for the intermittently connected ones.
30677
30678
30679
30680 .section "Exim on the intermittently connected client host"
30681 The value of &%smtp_accept_queue_per_connection%& should probably be
30682 increased, or even set to zero (that is, disabled) on the intermittently
30683 connected host, so that all incoming messages down a single connection get
30684 delivered immediately.
30685
30686 .cindex "SMTP" "passed connection"
30687 .cindex "SMTP" "multiple deliveries"
30688 .cindex "multiple SMTP deliveries"
30689 Mail waiting to be sent from an intermittently connected host will probably
30690 not have been routed, because without a connection DNS lookups are not
30691 possible. This means that if a normal queue run is done at connection time,
30692 each message is likely to be sent in a separate SMTP session. This can be
30693 avoided by starting the queue run with a command line option beginning with
30694 &%-qq%& instead of &%-q%&. In this case, the queue is scanned twice. In the
30695 first pass, routing is done but no deliveries take place. The second pass is a
30696 normal queue run; since all the messages have been previously routed, those
30697 destined for the same host are likely to get sent as multiple deliveries in a
30698 single SMTP connection.
30699
30700
30701
30702 . ////////////////////////////////////////////////////////////////////////////
30703 . ////////////////////////////////////////////////////////////////////////////
30704
30705 .chapter "Using Exim as a non-queueing client" "CHAPnonqueueing" &&&
30706          "Exim as a non-queueing client"
30707 .cindex "client" "non-queueing"
30708 .cindex "smart host" "queueing; suppressing"
30709 On a personal computer, it is a common requirement for all
30710 email to be sent to a &"smart host"&. There are plenty of MUAs that can be
30711 configured to operate that way, for all the popular operating systems.
30712 However, there are some MUAs for Unix-like systems that cannot be so
30713 configured: they submit messages using the command line interface of
30714 &_/usr/sbin/sendmail_&. Furthermore, utility programs such as &'cron'& submit
30715 messages this way.
30716
30717 If the personal computer runs continuously, there is no problem, because it can
30718 run a conventional MTA that handles delivery to the smart host, and deal with
30719 any delays via its queueing mechanism. However, if the computer does not run
30720 continuously or runs different operating systems at different times, queueing
30721 email is not desirable.
30722
30723 There is therefore a requirement for something that can provide the
30724 &_/usr/sbin/sendmail_& interface but deliver messages to a smart host without
30725 any queueing or retrying facilities. Furthermore, the delivery to the smart
30726 host should be synchronous, so that if it fails, the sending MUA is immediately
30727 informed. In other words, we want something that extends an MUA that submits
30728 to a local MTA via the command line so that it behaves like one that submits
30729 to a remote smart host using TCP/SMTP.
30730
30731 There are a number of applications (for example, there is one called &'ssmtp'&)
30732 that do this job. However, people have found them to be lacking in various
30733 ways. For instance, you might want to allow aliasing and forwarding to be done
30734 before sending a message to the smart host.
30735
30736 Exim already had the necessary infrastructure for doing this job. Just a few
30737 tweaks were needed to make it behave as required, though it is somewhat of an
30738 overkill to use a fully-featured MTA for this purpose.
30739
30740 .cindex "&%mua_wrapper%&"
30741 There is a Boolean global option called &%mua_wrapper%&, defaulting false.
30742 Setting &%mua_wrapper%& true causes Exim to run in a special mode where it
30743 assumes that it is being used to &"wrap"& a command-line MUA in the manner
30744 just described. As well as setting &%mua_wrapper%&, you also need to provide a
30745 compatible router and transport configuration. Typically there will be just one
30746 router and one transport, sending everything to a smart host.
30747
30748 When run in MUA wrapping mode, the behaviour of Exim changes in the
30749 following ways:
30750
30751 .ilist
30752 A daemon cannot be run, nor will Exim accept incoming messages from &'inetd'&.
30753 In other words, the only way to submit messages is via the command line.
30754 .next
30755 Each message is synchonously delivered as soon as it is received (&%-odi%& is
30756 assumed). All queueing options (&%queue_only%&, &%queue_smtp_domains%&,
30757 &%control%& in an ACL, etc.) are quietly ignored. The Exim reception process
30758 does not finish until the delivery attempt is complete. If the delivery is
30759 successful, a zero return code is given.
30760 .next
30761 Address redirection is permitted, but the final routing for all addresses must
30762 be to the same remote transport, and to the same list of hosts. Furthermore,
30763 the return address (envelope sender) must be the same for all recipients, as
30764 must any added or deleted header lines. In other words, it must be possible to
30765 deliver the message in a single SMTP transaction, however many recipients there
30766 are.
30767 .next
30768 If these conditions are not met, or if routing any address results in a
30769 failure or defer status, or if Exim is unable to deliver all the recipients
30770 successfully to one of the smart hosts, delivery of the entire message fails.
30771 .next
30772 Because no queueing is allowed, all failures are treated as permanent; there
30773 is no distinction between 4&'xx'& and 5&'xx'& SMTP response codes from the
30774 smart host. Furthermore, because only a single yes/no response can be given to
30775 the caller, it is not possible to deliver to some recipients and not others. If
30776 there is an error (temporary or permanent) for any recipient, all are failed.
30777 .next
30778 If more than one smart host is listed, Exim will try another host after a
30779 connection failure or a timeout, in the normal way. However, if this kind of
30780 failure happens for all the hosts, the delivery fails.
30781 .next
30782 When delivery fails, an error message is written to the standard error stream
30783 (as well as to Exim's log), and Exim exits to the caller with a return code
30784 value 1. The message is expunged from Exim's spool files. No bounce messages
30785 are ever generated.
30786 .next
30787 No retry data is maintained, and any retry rules are ignored.
30788 .next
30789 A number of Exim options are overridden: &%deliver_drop_privilege%& is forced
30790 true, &%max_rcpt%& in the smtp transport is forced to &"unlimited"&,
30791 &%remote_max_parallel%& is forced to one, and fallback hosts are ignored.
30792 .endlist
30793
30794 The overall effect is that Exim makes a single synchronous attempt to deliver
30795 the message, failing if there is any kind of problem. Because no local
30796 deliveries are done and no daemon can be run, Exim does not need root
30797 privilege. It should be possible to run it setuid to &'exim'& instead of setuid
30798 to &'root'&. See section &<<SECTrunexiwitpri>>& for a general discussion about
30799 the advantages and disadvantages of running without root privilege.
30800
30801
30802
30803
30804 . ////////////////////////////////////////////////////////////////////////////
30805 . ////////////////////////////////////////////////////////////////////////////
30806
30807 .chapter "Log files" "CHAPlog"
30808 .scindex IIDloggen "log" "general description"
30809 .cindex "log" "types of"
30810 Exim writes three different logs, referred to as the main log, the reject log,
30811 and the panic log:
30812
30813 .ilist
30814 .cindex "main log"
30815 The main log records the arrival of each message and each delivery in a single
30816 line in each case. The format is as compact as possible, in an attempt to keep
30817 down the size of log files. Two-character flag sequences make it easy to pick
30818 out these lines. A number of other events are recorded in the main log. Some of
30819 them are optional, in which case the &%log_selector%& option controls whether
30820 they are included or not. A Perl script called &'eximstats'&, which does simple
30821 analysis of main log files, is provided in the Exim distribution (see section
30822 &<<SECTmailstat>>&).
30823 .next
30824 .cindex "reject log"
30825 The reject log records information from messages that are rejected as a result
30826 of a configuration option (that is, for policy reasons).
30827 The first line of each rejection is a copy of the line that is also written to
30828 the main log. Then, if the message's header has been read at the time the log
30829 is written, its contents are written to this log. Only the original header
30830 lines are available; header lines added by ACLs are not logged. You can use the
30831 reject log to check that your policy controls are working correctly; on a busy
30832 host this may be easier than scanning the main log for rejection messages. You
30833 can suppress the writing of the reject log by setting &%write_rejectlog%&
30834 false.
30835 .next
30836 .cindex "panic log"
30837 .cindex "system log"
30838 When certain serious errors occur, Exim writes entries to its panic log. If the
30839 error is sufficiently disastrous, Exim bombs out afterwards. Panic log entries
30840 are usually written to the main log as well, but can get lost amid the mass of
30841 other entries. The panic log should be empty under normal circumstances. It is
30842 therefore a good idea to check it (or to have a &'cron'& script check it)
30843 regularly, in order to become aware of any problems. When Exim cannot open its
30844 panic log, it tries as a last resort to write to the system log (syslog). This
30845 is opened with LOG_PID+LOG_CONS and the facility code of LOG_MAIL. The
30846 message itself is written at priority LOG_CRIT.
30847 .endlist
30848
30849 Every log line starts with a timestamp, in the format shown in the following
30850 example. Note that many of the examples shown in this chapter are line-wrapped.
30851 In the log file, this would be all on one line:
30852 .code
30853 2001-09-16 16:09:47 SMTP connection from [127.0.0.1] closed
30854   by QUIT
30855 .endd
30856 By default, the timestamps are in the local timezone. There are two
30857 ways of changing this:
30858
30859 .ilist
30860 You can set the &%timezone%& option to a different time zone; in particular, if
30861 you set
30862 .code
30863 timezone = UTC
30864 .endd
30865 the timestamps will be in UTC (aka GMT).
30866 .next
30867 If you set &%log_timezone%& true, the time zone is added to the timestamp, for
30868 example:
30869 .code
30870 2003-04-25 11:17:07 +0100 Start queue run: pid=12762
30871 .endd
30872 .endlist
30873
30874
30875
30876
30877 .section "Where the logs are written" "SECTwhelogwri"
30878 .cindex "log" "destination"
30879 .cindex "log" "to file"
30880 .cindex "log" "to syslog"
30881 .cindex "syslog"
30882 The logs may be written to local files, or to syslog, or both. However, it
30883 should be noted that many syslog implementations use UDP as a transport, and
30884 are therefore unreliable in the sense that messages are not guaranteed to
30885 arrive at the loghost, nor is the ordering of messages necessarily maintained.
30886 It has also been reported that on large log files (tens of megabytes) you may
30887 need to tweak syslog to prevent it syncing the file with each write &-- on
30888 Linux this has been seen to make syslog take 90% plus of CPU time.
30889
30890 The destination for Exim's logs is configured by setting LOG_FILE_PATH in
30891 &_Local/Makefile_& or by setting &%log_file_path%& in the run time
30892 configuration. This latter string is expanded, so it can contain, for example,
30893 references to the host name:
30894 .code
30895 log_file_path = /var/log/$primary_hostname/exim_%slog
30896 .endd
30897 It is generally advisable, however, to set the string in &_Local/Makefile_&
30898 rather than at run time, because then the setting is available right from the
30899 start of Exim's execution. Otherwise, if there's something it wants to log
30900 before it has read the configuration file (for example, an error in the
30901 configuration file) it will not use the path you want, and may not be able to
30902 log at all.
30903
30904 The value of LOG_FILE_PATH or &%log_file_path%& is a colon-separated
30905 list, currently limited to at most two items. This is one option where the
30906 facility for changing a list separator may not be used. The list must always be
30907 colon-separated. If an item in the list is &"syslog"& then syslog is used;
30908 otherwise the item must either be an absolute path, containing &`%s`& at the
30909 point where &"main"&, &"reject"&, or &"panic"& is to be inserted, or be empty,
30910 implying the use of a default path.
30911
30912 When Exim encounters an empty item in the list, it searches the list defined by
30913 LOG_FILE_PATH, and uses the first item it finds that is neither empty nor
30914 &"syslog"&. This means that an empty item in &%log_file_path%& can be used to
30915 mean &"use the path specified at build time"&. It no such item exists, log
30916 files are written in the &_log_& subdirectory of the spool directory. This is
30917 equivalent to the setting:
30918 .code
30919 log_file_path = $spool_directory/log/%slog
30920 .endd
30921 If you do not specify anything at build time or run time, that is where the
30922 logs are written.
30923
30924 A log file path may also contain &`%D`& if datestamped log file names are in
30925 use &-- see section &<<SECTdatlogfil>>& below.
30926
30927 Here are some examples of possible settings:
30928 .display
30929 &`LOG_FILE_PATH=syslog                    `& syslog only
30930 &`LOG_FILE_PATH=:syslog                   `& syslog and default path
30931 &`LOG_FILE_PATH=syslog : /usr/log/exim_%s `& syslog and specified path
30932 &`LOG_FILE_PATH=/usr/log/exim_%s          `& specified path only
30933 .endd
30934 If there are more than two paths in the list, the first is used and a panic
30935 error is logged.
30936
30937
30938
30939 .section "Logging to local files that are periodically &""cycled""&"
30940 .cindex "log" "cycling local files"
30941 .cindex "cycling logs"
30942 .cindex "&'exicyclog'&"
30943 .cindex "log" "local files; writing to"
30944 Some operating systems provide centralized and standardised methods for cycling
30945 log files. For those that do not, a utility script called &'exicyclog'& is
30946 provided (see section &<<SECTcyclogfil>>&). This renames and compresses the
30947 main and reject logs each time it is called. The maximum number of old logs to
30948 keep can be set. It is suggested this script is run as a daily &'cron'& job.
30949
30950 An Exim delivery process opens the main log when it first needs to write to it,
30951 and it keeps the file open in case subsequent entries are required &-- for
30952 example, if a number of different deliveries are being done for the same
30953 message. However, remote SMTP deliveries can take a long time, and this means
30954 that the file may be kept open long after it is renamed if &'exicyclog'& or
30955 something similar is being used to rename log files on a regular basis. To
30956 ensure that a switch of log files is noticed as soon as possible, Exim calls
30957 &[stat()]& on the main log's name before reusing an open file, and if the file
30958 does not exist, or its inode has changed, the old file is closed and Exim
30959 tries to open the main log from scratch. Thus, an old log file may remain open
30960 for quite some time, but no Exim processes should write to it once it has been
30961 renamed.
30962
30963
30964
30965 .section "Datestamped log files" "SECTdatlogfil"
30966 .cindex "log" "datestamped files"
30967 Instead of cycling the main and reject log files by renaming them
30968 periodically, some sites like to use files whose names contain a datestamp,
30969 for example, &_mainlog-20031225_&. The datestamp is in the form &_yyyymmdd_&.
30970 Exim has support for this way of working. It is enabled by setting the
30971 &%log_file_path%& option to a path that includes &`%D`& at the point where the
30972 datestamp is required. For example:
30973 .code
30974 log_file_path = /var/spool/exim/log/%slog-%D
30975 log_file_path = /var/log/exim-%s-%D.log
30976 log_file_path = /var/spool/exim/log/%D-%slog
30977 .endd
30978 As before, &`%s`& is replaced by &"main"& or &"reject"&; the following are
30979 examples of names generated by the above examples:
30980 .code
30981 /var/spool/exim/log/mainlog-20021225
30982 /var/log/exim-reject-20021225.log
30983 /var/spool/exim/log/20021225-mainlog
30984 .endd
30985 When this form of log file is specified, Exim automatically switches to new
30986 files at midnight. It does not make any attempt to compress old logs; you
30987 will need to write your own script if you require this. You should not
30988 run &'exicyclog'& with this form of logging.
30989
30990 The location of the panic log is also determined by &%log_file_path%&, but it
30991 is not datestamped, because rotation of the panic log does not make sense.
30992 When generating the name of the panic log, &`%D`& is removed from the string.
30993 In addition, if it immediately follows a slash, a following non-alphanumeric
30994 character is removed; otherwise a preceding non-alphanumeric character is
30995 removed. Thus, the three examples above would give these panic log names:
30996 .code
30997 /var/spool/exim/log/paniclog
30998 /var/log/exim-panic.log
30999 /var/spool/exim/log/paniclog
31000 .endd
31001
31002
31003 .section "Logging to syslog"
31004 .cindex "log" "syslog; writing to"
31005 The use of syslog does not change what Exim logs or the format of its messages,
31006 except in one respect. If &%syslog_timestamp%& is set false, the timestamps on
31007 Exim's log lines are omitted when these lines are sent to syslog. Apart from
31008 that, the same strings are written to syslog as to log files. The syslog
31009 &"facility"& is set to LOG_MAIL, and the program name to &"exim"&
31010 by default, but you can change these by setting the &%syslog_facility%& and
31011 &%syslog_processname%& options, respectively. If Exim was compiled with
31012 SYSLOG_LOG_PID set in &_Local/Makefile_& (this is the default in
31013 &_src/EDITME_&), then, on systems that permit it (all except ULTRIX), the
31014 LOG_PID flag is set so that the &[syslog()]& call adds the pid as well as
31015 the time and host name to each line.
31016 The three log streams are mapped onto syslog priorities as follows:
31017
31018 .ilist
31019 &'mainlog'& is mapped to LOG_INFO
31020 .next
31021 &'rejectlog'& is mapped to LOG_NOTICE
31022 .next
31023 &'paniclog'& is mapped to LOG_ALERT
31024 .endlist
31025
31026 Many log lines are written to both &'mainlog'& and &'rejectlog'&, and some are
31027 written to both &'mainlog'& and &'paniclog'&, so there will be duplicates if
31028 these are routed by syslog to the same place. You can suppress this duplication
31029 by setting &%syslog_duplication%& false.
31030
31031 Exim's log lines can sometimes be very long, and some of its &'rejectlog'&
31032 entries contain multiple lines when headers are included. To cope with both
31033 these cases, entries written to syslog are split into separate &[syslog()]&
31034 calls at each internal newline, and also after a maximum of
31035 870 data characters. (This allows for a total syslog line length of 1024, when
31036 additions such as timestamps are added.) If you are running a syslog
31037 replacement that can handle lines longer than the 1024 characters allowed by
31038 RFC 3164, you should set
31039 .code
31040 SYSLOG_LONG_LINES=yes
31041 .endd
31042 in &_Local/Makefile_& before building Exim. That stops Exim from splitting long
31043 lines, but it still splits at internal newlines in &'reject'& log entries.
31044
31045 To make it easy to re-assemble split lines later, each component of a split
31046 entry starts with a string of the form [<&'n'&>/<&'m'&>] or [<&'n'&>\<&'m'&>]
31047 where <&'n'&> is the component number and <&'m'&> is the total number of
31048 components in the entry. The / delimiter is used when the line was split
31049 because it was too long; if it was split because of an internal newline, the \
31050 delimiter is used. For example, supposing the length limit to be 50 instead of
31051 870, the following would be the result of a typical rejection message to
31052 &'mainlog'& (LOG_INFO), each line in addition being preceded by the time, host
31053 name, and pid as added by syslog:
31054 .code
31055 [1/5] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from
31056 [2/5]  [127.0.0.1] (ph10): syntax error in 'From' header
31057 [3/5]  when scanning for sender: missing or malformed lo
31058 [4/5] cal part in "<>" (envelope sender is <ph10@cam.exa
31059 [5/5] mple>)
31060 .endd
31061 The same error might cause the following lines to be written to &"rejectlog"&
31062 (LOG_NOTICE):
31063 .code
31064 [1/18] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected fro
31065 [2/18] m [127.0.0.1] (ph10): syntax error in 'From' head
31066 [3/18] er when scanning for sender: missing or malformed
31067 [4/18]  local part in "<>" (envelope sender is <ph10@cam
31068 [5\18] .example>)
31069 [6\18] Recipients: ph10@some.domain.cam.example
31070 [7\18] P Received: from [127.0.0.1] (ident=ph10)
31071 [8\18]        by xxxxx.cam.example with smtp (Exim 4.00)
31072 [9\18]        id 16RdAL-0006pc-00
31073 [10/18]        for ph10@cam.example; Mon, 16 Sep 2002 16:
31074 [11\18] 09:43 +0100
31075 [12\18] F From: <>
31076 [13\18]   Subject: this is a test header
31077 [18\18]   X-something: this is another header
31078 [15/18] I Message-Id: <E16RdAL-0006pc-00@xxxxx.cam.examp
31079 [16\18] le>
31080 [17\18] B Bcc:
31081 [18/18]   Date: Mon, 16 Sep 2002 16:09:43 +0100
31082 .endd
31083 Log lines that are neither too long nor contain newlines are written to syslog
31084 without modification.
31085
31086 If only syslog is being used, the Exim monitor is unable to provide a log tail
31087 display, unless syslog is routing &'mainlog'& to a file on the local host and
31088 the environment variable EXIMON_LOG_FILE_PATH is set to tell the monitor
31089 where it is.
31090
31091
31092
31093 .section "Log line flags"
31094 One line is written to the main log for each message received, and for each
31095 successful, unsuccessful, and delayed delivery. These lines can readily be
31096 picked out by the distinctive two-character flags that immediately follow the
31097 timestamp. The flags are:
31098 .display
31099 &`<=`&     message arrival
31100 &`=>`&     normal message delivery
31101 &`->`&     additional address in same delivery
31102 &`*>`&     delivery suppressed by &%-N%&
31103 &`**`&     delivery failed; address bounced
31104 &`==`&     delivery deferred; temporary problem
31105 .endd
31106
31107
31108 .section "Logging message reception"
31109 .cindex "log" "reception line"
31110 The format of the single-line entry in the main log that is written for every
31111 message received is shown in the basic example below, which is split over
31112 several lines in order to fit it on the page:
31113 .code
31114 2002-10-31 08:57:53 16ZCW1-0005MB-00 <= kryten@dwarf.fict.example
31115   H=mailer.fict.example [192.168.123.123] U=exim
31116   P=smtp S=5678 id=<incoming message id>
31117 .endd
31118 The address immediately following &"<="& is the envelope sender address. A
31119 bounce message is shown with the sender address &"<>"&, and if it is locally
31120 generated, this is followed by an item of the form
31121 .code
31122 R=<message id>
31123 .endd
31124 which is a reference to the message that caused the bounce to be sent.
31125
31126 .cindex "HELO"
31127 .cindex "EHLO"
31128 For messages from other hosts, the H and U fields identify the remote host and
31129 record the RFC 1413 identity of the user that sent the message, if one was
31130 received. The number given in square brackets is the IP address of the sending
31131 host. If there is a single, unparenthesized  host name in the H field, as
31132 above, it has been verified to correspond to the IP address (see the
31133 &%host_lookup%& option). If the name is in parentheses, it was the name quoted
31134 by the remote host in the SMTP HELO or EHLO command, and has not been
31135 verified. If verification yields a different name to that given for HELO or
31136 EHLO, the verified name appears first, followed by the HELO or EHLO
31137 name in parentheses.
31138
31139 Misconfigured hosts (and mail forgers) sometimes put an IP address, with or
31140 without brackets, in the HELO or EHLO command, leading to entries in
31141 the log containing text like these examples:
31142 .code
31143 H=(10.21.32.43) [192.168.8.34]
31144 H=([10.21.32.43]) [192.168.8.34]
31145 .endd
31146 This can be confusing. Only the final address in square brackets can be relied
31147 on.
31148
31149 For locally generated messages (that is, messages not received over TCP/IP),
31150 the H field is omitted, and the U field contains the login name of the caller
31151 of Exim.
31152
31153 .cindex "authentication" "logging"
31154 .cindex "AUTH" "logging"
31155 For all messages, the P field specifies the protocol used to receive the
31156 message. This is the value that is stored in &$received_protocol$&. In the case
31157 of incoming SMTP messages, the value indicates whether or not any SMTP
31158 extensions (ESMTP), encryption, or authentication were used. If the SMTP
31159 session was encrypted, there is an additional X field that records the cipher
31160 suite that was used.
31161
31162 The protocol is set to &"esmtpsa"& or &"esmtpa"& for messages received from
31163 hosts that have authenticated themselves using the SMTP AUTH command. The first
31164 value is used when the SMTP connection was encrypted (&"secure"&). In this case
31165 there is an additional item A= followed by the name of the authenticator that
31166 was used. If an authenticated identification was set up by the authenticator's
31167 &%server_set_id%& option, this is logged too, separated by a colon from the
31168 authenticator name.
31169
31170 .cindex "size" "of message"
31171 The id field records the existing message id, if present. The size of the
31172 received message is given by the S field. When the message is delivered,
31173 headers may be removed or added, so that the size of delivered copies of the
31174 message may not correspond with this value (and indeed may be different to each
31175 other).
31176
31177 The &%log_selector%& option can be used to request the logging of additional
31178 data when a message is received. See section &<<SECTlogselector>>& below.
31179
31180
31181
31182 .section "Logging deliveries"
31183 .cindex "log" "delivery line"
31184 The format of the single-line entry in the main log that is written for every
31185 delivery is shown in one of the examples below, for local and remote
31186 deliveries, respectively. Each example has been split into two lines in order
31187 to fit it on the page:
31188 .code
31189 2002-10-31 08:59:13 16ZCW1-0005MB-00 => marv
31190   <marv@hitch.fict.example> R=localuser T=local_delivery
31191 2002-10-31 09:00:10 16ZCW1-0005MB-00 =>
31192   monk@holistic.fict.example R=dnslookup T=remote_smtp
31193   H=holistic.fict.example [192.168.234.234]
31194 .endd
31195 For ordinary local deliveries, the original address is given in angle brackets
31196 after the final delivery address, which might be a pipe or a file. If
31197 intermediate address(es) exist between the original and the final address, the
31198 last of these is given in parentheses after the final address. The R and T
31199 fields record the router and transport that were used to process the address.
31200
31201 If a shadow transport was run after a successful local delivery, the log line
31202 for the successful delivery has an item added on the end, of the form
31203 .display
31204 &`ST=<`&&'shadow transport name'&&`>`&
31205 .endd
31206 If the shadow transport did not succeed, the error message is put in
31207 parentheses afterwards.
31208
31209 .cindex "asterisk" "after IP address"
31210 When more than one address is included in a single delivery (for example, two
31211 SMTP RCPT commands in one transaction) the second and subsequent addresses are
31212 flagged with &`->`& instead of &`=>`&. When two or more messages are delivered
31213 down a single SMTP connection, an asterisk follows the IP address in the log
31214 lines for the second and subsequent messages.
31215
31216 The generation of a reply message by a filter file gets logged as a
31217 &"delivery"& to the addressee, preceded by &">"&.
31218
31219 The &%log_selector%& option can be used to request the logging of additional
31220 data when a message is delivered. See section &<<SECTlogselector>>& below.
31221
31222
31223 .section "Discarded deliveries"
31224 .cindex "discarded messages"
31225 .cindex "message" "discarded"
31226 .cindex "delivery" "discarded; logging"
31227 When a message is discarded as a result of the command &"seen finish"& being
31228 obeyed in a filter file which generates no deliveries, a log entry of the form
31229 .code
31230 2002-12-10 00:50:49 16auJc-0001UB-00 => discarded
31231   <low.club@bridge.example> R=userforward
31232 .endd
31233 is written, to record why no deliveries are logged. When a message is discarded
31234 because it is aliased to &":blackhole:"& the log line is like this:
31235 .code
31236 1999-03-02 09:44:33 10HmaX-0005vi-00 => :blackhole:
31237   <hole@nowhere.example> R=blackhole_router
31238 .endd
31239
31240
31241 .section "Deferred deliveries"
31242 When a delivery is deferred, a line of the following form is logged:
31243 .code
31244 2002-12-19 16:20:23 16aiQz-0002Q5-00 == marvin@endrest.example
31245   R=dnslookup T=smtp defer (146): Connection refused
31246 .endd
31247 In the case of remote deliveries, the error is the one that was given for the
31248 last IP address that was tried. Details of individual SMTP failures are also
31249 written to the log, so the above line would be preceded by something like
31250 .code
31251 2002-12-19 16:20:23 16aiQz-0002Q5-00 Failed to connect to
31252   mail1.endrest.example [192.168.239.239]: Connection refused
31253 .endd
31254 When a deferred address is skipped because its retry time has not been reached,
31255 a message is written to the log, but this can be suppressed by setting an
31256 appropriate value in &%log_selector%&.
31257
31258
31259
31260 .section "Delivery failures"
31261 .cindex "delivery" "failure; logging"
31262 If a delivery fails because an address cannot be routed, a line of the
31263 following form is logged:
31264 .code
31265 1995-12-19 16:20:23 0tRiQz-0002Q5-00 ** jim@trek99.example
31266   <jim@trek99.example>: unknown mail domain
31267 .endd
31268 If a delivery fails at transport time, the router and transport are shown, and
31269 the response from the remote host is included, as in this example:
31270 .code
31271 2002-07-11 07:14:17 17SXDU-000189-00 ** ace400@pb.example
31272   R=dnslookup T=remote_smtp: SMTP error from remote mailer
31273   after pipelined RCPT TO:<ace400@pb.example>: host
31274   pbmail3.py.example [192.168.63.111]: 553 5.3.0
31275   <ace400@pb.example>...Addressee unknown
31276 .endd
31277 The word &"pipelined"& indicates that the SMTP PIPELINING extension was being
31278 used. See &%hosts_avoid_esmtp%& in the &(smtp)& transport for a way of
31279 disabling PIPELINING. The log lines for all forms of delivery failure are
31280 flagged with &`**`&.
31281
31282
31283
31284 .section "Fake deliveries"
31285 .cindex "delivery" "fake; logging"
31286 If a delivery does not actually take place because the &%-N%& option has been
31287 used to suppress it, a normal delivery line is written to the log, except that
31288 &"=>"& is replaced by &"*>"&.
31289
31290
31291
31292 .section "Completion"
31293 A line of the form
31294 .code
31295 2002-10-31 09:00:11 16ZCW1-0005MB-00 Completed
31296 .endd
31297 is written to the main log when a message is about to be removed from the spool
31298 at the end of its processing.
31299
31300
31301
31302
31303 .section "Summary of Fields in Log Lines"
31304 .cindex "log" "summary of fields"
31305 A summary of the field identifiers that are used in log lines is shown in
31306 the following table:
31307 .display
31308 &`A   `&        authenticator name (and optional id)
31309 &`C   `&        SMTP confirmation on delivery
31310 &`CV  `&        certificate verification status
31311 &`DN  `&        distinguished name from peer certificate
31312 &`DT  `&        on &`=>`& lines: time taken for a delivery
31313 &`F   `&        sender address (on delivery lines)
31314 &`H   `&        host name and IP address
31315 &`I   `&        local interface used
31316 &`id  `&        message id for incoming message
31317 &`P   `&        on &`<=`& lines: protocol used
31318 &`    `&        on &`=>`& and &`**`& lines: return path
31319 &`QT  `&        on &`=>`& lines: time spent on queue so far
31320 &`    `&        on &"Completed"& lines: time spent on queue
31321 &`R   `&        on &`<=`& lines: reference for local bounce
31322 &`    `&        on &`=>`&  &`**`& and &`==`& lines: router name
31323 &`S   `&        size of message
31324 &`ST  `&        shadow transport name
31325 &`T   `&        on &`<=`& lines: message subject (topic)
31326 &`    `&        on &`=>`& &`**`& and &`==`& lines: transport name
31327 &`U   `&        local user or RFC 1413 identity
31328 &`X   `&        TLS cipher suite
31329 .endd
31330
31331
31332 .section "Other log entries"
31333 Various other types of log entry are written from time to time. Most should be
31334 self-explanatory. Among the more common are:
31335
31336 .ilist
31337 .cindex "retry" "time not reached"
31338 &'retry time not reached'&&~&~An address previously suffered a temporary error
31339 during routing or local delivery, and the time to retry has not yet arrived.
31340 This message is not written to an individual message log file unless it happens
31341 during the first delivery attempt.
31342 .next
31343 &'retry time not reached for any host'&&~&~An address previously suffered
31344 temporary errors during remote delivery, and the retry time has not yet arrived
31345 for any of the hosts to which it is routed.
31346 .next
31347 .cindex "spool directory" "file locked"
31348 &'spool file locked'&&~&~An attempt to deliver a message cannot proceed because
31349 some other Exim process is already working on the message. This can be quite
31350 common if queue running processes are started at frequent intervals. The
31351 &'exiwhat'& utility script can be used to find out what Exim processes are
31352 doing.
31353 .next
31354 .cindex "error" "ignored"
31355 &'error ignored'&&~&~There are several circumstances that give rise to this
31356 message:
31357 .olist
31358 Exim failed to deliver a bounce message whose age was greater than
31359 &%ignore_bounce_errors_after%&. The bounce was discarded.
31360 .next
31361 A filter file set up a delivery using the &"noerror"& option, and the delivery
31362 failed. The delivery was discarded.
31363 .next
31364 A delivery set up by a router configured with
31365 . ==== As this is a nested list, any displays it contains must be indented
31366 . ==== as otherwise they are too far to the left.
31367 .code
31368     errors_to = <>
31369 .endd
31370 failed. The delivery was discarded.
31371 .endlist olist
31372 .endlist ilist
31373
31374
31375
31376
31377
31378 .section "Reducing or increasing what is logged" "SECTlogselector"
31379 .cindex "log" "selectors"
31380 By setting the &%log_selector%& global option, you can disable some of Exim's
31381 default logging, or you can request additional logging. The value of
31382 &%log_selector%& is made up of names preceded by plus or minus characters. For
31383 example:
31384 .code
31385 log_selector = +arguments -retry_defer
31386 .endd
31387 The list of optional log items is in the following table, with the default
31388 selection marked by asterisks:
31389 .display
31390 &`*acl_warn_skipped           `&  skipped &%warn%& statement in ACL
31391 &` address_rewrite            `&  address rewriting
31392 &` all_parents                `&  all parents in => lines
31393 &` arguments                  `&  command line arguments
31394 &`*connection_reject          `&  connection rejections
31395 &`*delay_delivery             `&  immediate delivery delayed
31396 &` deliver_time               `&  time taken to perform delivery
31397 &` delivery_size              `&  add &`S=`&&'nnn'& to => lines
31398 &`*dnslist_defer              `&  defers of DNS list (aka RBL) lookups
31399 &`*etrn                       `&  ETRN commands
31400 &`*host_lookup_failed         `&  as it says
31401 &` ident_timeout              `&  timeout for ident connection
31402 &` incoming_interface         `&  incoming interface on <= lines
31403 &` incoming_port              `&  incoming port on <= lines
31404 &`*lost_incoming_connection   `&  as it says (includes timeouts)
31405 &` outgoing_port              `&  add remote port to => lines
31406 &`*queue_run                  `&  start and end queue runs
31407 &` queue_time                 `&  time on queue for one recipient
31408 &` queue_time_overall         `&  time on queue for whole message
31409 &` received_recipients        `&  recipients on <= lines
31410 &` received_sender            `&  sender on <= lines
31411 &`*rejected_header            `&  header contents on reject log
31412 &`*retry_defer                `&  &"retry time not reached"&
31413 &` return_path_on_delivery    `&  put return path on => and ** lines
31414 &` sender_on_delivery         `&  add sender to => lines
31415 &`*sender_verify_fail         `&  sender verification failures
31416 &`*size_reject                `&  rejection because too big
31417 &`*skip_delivery              `&  delivery skipped in a queue run
31418 &` smtp_confirmation          `&  SMTP confirmation on => lines
31419 &` smtp_connection            `&  SMTP connections
31420 &` smtp_incomplete_transaction`&  incomplete SMTP transactions
31421 &` smtp_protocol_error        `&  SMTP protocol errors
31422 &` smtp_syntax_error          `&  SMTP syntax errors
31423 &` subject                    `&  contents of &'Subject:'& on <= lines
31424 &` tls_certificate_verified   `&  certificate verification status
31425 &`*tls_cipher                 `&  TLS cipher suite on <= and => lines
31426 &` tls_peerdn                 `&  TLS peer DN on <= and => lines
31427 &` unknown_in_list            `&  DNS lookup failed in list match
31428
31429 &` all                        `&  all of the above
31430 .endd
31431 More details on each of these items follows:
31432
31433 .ilist
31434 .cindex "&%warn%& statement" "log when skipping"
31435 &%acl_warn_skipped%&: When an ACL &%warn%& statement is skipped because one of
31436 its conditions cannot be evaluated, a log line to this effect is written if
31437 this log selector is set.
31438 .next
31439 .cindex "log" "rewriting"
31440 .cindex "rewriting" "logging"
31441 &%address_rewrite%&: This applies both to global rewrites and per-transport
31442 rewrites, but not to rewrites in filters run as an unprivileged user (because
31443 such users cannot access the log).
31444 .next
31445 .cindex "log" "full parentage"
31446 &%all_parents%&: Normally only the original and final addresses are logged on
31447 delivery lines; with this selector, intermediate parents are given in
31448 parentheses between them.
31449 .next
31450 .cindex "log" "Exim arguments"
31451 .cindex "Exim arguments" "logging"
31452 &%arguments%&: This causes Exim to write the arguments with which it was called
31453 to the main log, preceded by the current working directory. This is a debugging
31454 feature, added to make it easier to find out how certain MUAs call
31455 &_/usr/sbin/sendmail_&. The logging does not happen if Exim has given up root
31456 privilege because it was called with the &%-C%& or &%-D%& options. Arguments
31457 that are empty or that contain white space are quoted. Non-printing characters
31458 are shown as escape sequences. This facility cannot log unrecognized arguments,
31459 because the arguments are checked before the configuration file is read. The
31460 only way to log such cases is to interpose a script such as &_util/logargs.sh_&
31461 between the caller and Exim.
31462 .next
31463 .cindex "log" "connection rejections"
31464 &%connection_reject%&: A log entry is written whenever an incoming SMTP
31465 connection is rejected, for whatever reason.
31466 .next
31467 .cindex "log" "delayed delivery"
31468 .cindex "delayed delivery" "logging"
31469 &%delay_delivery%&: A log entry is written whenever a delivery process is not
31470 started for an incoming message because the load is too high or too many
31471 messages were received on one connection. Logging does not occur if no delivery
31472 process is started because &%queue_only%& is set or &%-odq%& was used.
31473 .next
31474 .cindex "log" "delivery duration"
31475 &%deliver_time%&: For each delivery, the amount of real time it has taken to
31476 perform the actual delivery is logged as DT=<&'time'&>, for example, &`DT=1s`&.
31477 .next
31478 .cindex "log" "message size on delivery"
31479 .cindex "size" "of message"
31480 &%delivery_size%&: For each delivery, the size of message delivered is added to
31481 the &"=>"& line, tagged with S=.
31482 .next
31483 .cindex "log" "dnslist defer"
31484 .cindex "DNS list" "logging defer"
31485 .cindex "black list (DNS)"
31486 &%dnslist_defer%&: A log entry is written if an attempt to look up a host in a
31487 DNS black list suffers a temporary error.
31488 .next
31489 .cindex "log" "ETRN commands"
31490 .cindex "ETRN" "logging"
31491 &%etrn%&: Every valid ETRN command that is received is logged, before the ACL
31492 is run to determine whether or not it is actually accepted. An invalid ETRN
31493 command, or one received within a message transaction is not logged by this
31494 selector (see &%smtp_syntax_error%& and &%smtp_protocol_error%&).
31495 .next
31496 .cindex "log" "host lookup failure"
31497 &%host_lookup_failed%&: When a lookup of a host's IP addresses fails to find
31498 any addresses, or when a lookup of an IP address fails to find a host name, a
31499 log line is written. This logging does not apply to direct DNS lookups when
31500 routing email addresses, but it does apply to &"byname"& lookups.
31501 .next
31502 .cindex "log" "ident timeout"
31503 .cindex "RFC 1413" "logging timeout"
31504 &%ident_timeout%&: A log line is written whenever an attempt to connect to a
31505 client's ident port times out.
31506 .next
31507 .cindex "log" "incoming interface"
31508 .cindex "interface" "logging"
31509 &%incoming_interface%&: The interface on which a message was received is added
31510 to the &"<="& line as an IP address in square brackets, tagged by I= and
31511 followed by a colon and the port number. The local interface and port are also
31512 added to other SMTP log lines, for example &"SMTP connection from"&, and to
31513 rejection lines.
31514 .next
31515 .cindex "log" "incoming remote port"
31516 .cindex "port" "logging remote"
31517 .cindex "TCP/IP" "logging incoming remote port"
31518 .cindex "&$sender_fullhost$&"
31519 .cindex "&$sender_rcvhost$&"
31520 &%incoming_port%&: The remote port number from which a message was received is
31521 added to log entries and &'Received:'& header lines, following the IP address
31522 in square brackets, and separated from it by a colon. This is implemented by
31523 changing the value that is put in the &$sender_fullhost$& and
31524 &$sender_rcvhost$& variables. Recording the remote port number has become more
31525 important with the widening use of NAT (see RFC 2505).
31526 .next
31527 .cindex "log" "dropped connection"
31528 &%lost_incoming_connection%&: A log line is written when an incoming SMTP
31529 connection is unexpectedly dropped.
31530 .next
31531 .cindex "log" "outgoing remote port"
31532 .cindex "port" "logging outgoint remote"
31533 .cindex "TCP/IP" "logging ougtoing remote port"
31534 &%outgoing_port%&: The remote port number is added to delivery log lines (those
31535 containing => tags) following the IP address. This option is not included in
31536 the default setting, because for most ordinary configurations, the remote port
31537 number is always 25 (the SMTP port).
31538 .next
31539 .cindex "log" "queue run"
31540 .cindex "queue runner" "logging"
31541 &%queue_run%&: The start and end of every queue run are logged.
31542 .next
31543 .cindex "log" "queue time"
31544 &%queue_time%&: The amount of time the message has been in the queue on the
31545 local host is logged as QT=<&'time'&> on delivery (&`=>`&) lines, for example,
31546 &`QT=3m45s`&. The clock starts when Exim starts to receive the message, so it
31547 includes reception time as well as the delivery time for the current address.
31548 This means that it may be longer than the difference between the arrival and
31549 delivery log line times, because the arrival log line is not written until the
31550 message has been successfully received.
31551 .next
31552 &%queue_time_overall%&: The amount of time the message has been in the queue on
31553 the local host is logged as QT=<&'time'&> on &"Completed"& lines, for
31554 example, &`QT=3m45s`&. The clock starts when Exim starts to receive the
31555 message, so it includes reception time as well as the total delivery time.
31556 .next
31557 .cindex "log" "recipients"
31558 &%received_recipients%&: The recipients of a message are listed in the main log
31559 as soon as the message is received. The list appears at the end of the log line
31560 that is written when a message is received, preceded by the word &"for"&. The
31561 addresses are listed after they have been qualified, but before any rewriting
31562 has taken place.
31563 Recipients that were discarded by an ACL for MAIL or RCPT do not appear
31564 in the list.
31565 .next
31566 .cindex "log" "sender reception"
31567 &%received_sender%&: The unrewritten original sender of a message is added to
31568 the end of the log line that records the message's arrival, after the word
31569 &"from"& (before the recipients if &%received_recipients%& is also set).
31570 .next
31571 .cindex "log" "header lines for rejection"
31572 &%rejected_header%&: If a message's header has been received at the time a
31573 rejection is written to the reject log, the complete header is added to the
31574 log. Header logging can be turned off individually for messages that are
31575 rejected by the &[local_scan()]& function (see section &<<SECTapiforloc>>&).
31576 .next
31577 .cindex "log" "retry defer"
31578 &%retry_defer%&: A log line is written if a delivery is deferred because a
31579 retry time has not yet been reached. However, this &"retry time not reached"&
31580 message is always omitted from individual message logs after the first delivery
31581 attempt.
31582 .next
31583 .cindex "log" "return path"
31584 &%return_path_on_delivery%&: The return path that is being transmitted with
31585 the message is included in delivery and bounce lines, using the tag P=.
31586 This is omitted if no delivery actually happens, for example, if routing fails,
31587 or if delivery is to &_/dev/null_& or to &`:blackhole:`&.
31588 .next
31589 .cindex "log" "sender on delivery"
31590 &%sender_on_delivery%&: The message's sender address is added to every delivery
31591 and bounce line, tagged by F= (for &"from"&).
31592 This is the original sender that was received with the message; it is not
31593 necessarily the same as the outgoing return path.
31594 .next
31595 .cindex "log" "sender verify failure"
31596 &%sender_verify_fail%&: If this selector is unset, the separate log line that
31597 gives details of a sender verification failure is not written. Log lines for
31598 the rejection of SMTP commands contain just &"sender verify failed"&, so some
31599 detail is lost.
31600 .next
31601 .cindex "log" "size rejection"
31602 &%size_reject%&: A log line is written whenever a message is rejected because
31603 it is too big.
31604 .next
31605 .cindex "log" "frozen messages; skipped"
31606 .cindex "frozen messages" "logging skipping"
31607 &%skip_delivery%&: A log line is written whenever a message is skipped during a
31608 queue run because it is frozen or because another process is already delivering
31609 it.
31610 .cindex "&""spool file is locked""&"
31611 The message that is written is &"spool file is locked"&.
31612 .next
31613 .cindex "log" "smtp confirmation"
31614 .cindex "SMTP" "logging confirmation"
31615 &%smtp_confirmation%&: The response to the final &"."& in the SMTP dialogue for
31616 outgoing messages is added to delivery log lines in the form &`C=`&<&'text'&>.
31617 A number of MTAs (including Exim) return an identifying string in this
31618 response.
31619 .next
31620 .cindex "log" "SMTP connections"
31621 .cindex "SMTP" "logging connections"
31622 &%smtp_connection%&: A log line is written whenever an SMTP connection is
31623 established or closed, unless the connection is from a host that matches
31624 &%hosts_connection_nolog%&. (In contrast, &%lost_incoming_connection%& applies
31625 only when the closure is unexpected.) This applies to connections from local
31626 processes that use &%-bs%& as well as to TCP/IP connections. If a connection is
31627 dropped in the middle of a message, a log line is always written, whether or
31628 not this selector is set, but otherwise nothing is written at the start and end
31629 of connections unless this selector is enabled.
31630
31631 For TCP/IP connections to an Exim daemon, the current number of connections is
31632 included in the log message for each new connection, but note that the count is
31633 reset if the daemon is restarted.
31634 Also, because connections are closed (and the closure is logged) in
31635 subprocesses, the count may not include connections that have been closed but
31636 whose termination the daemon has not yet noticed. Thus, while it is possible to
31637 match up the opening and closing of connections in the log, the value of the
31638 logged counts may not be entirely accurate.
31639 .next
31640 .cindex "log" "SMTP transaction; incomplete"
31641 .cindex "SMTP" "logging incomplete transactions"
31642 &%smtp_incomplete_transaction%&: When a mail transaction is aborted by
31643 RSET, QUIT, loss of connection, or otherwise, the incident is logged,
31644 and the message sender plus any accepted recipients are included in the log
31645 line. This can provide evidence of dictionary attacks.
31646 .next
31647 .cindex "log" "SMTP protocol error"
31648 .cindex "SMTP" "logging protocol error"
31649 &%smtp_protocol_error%&: A log line is written for every SMTP protocol error
31650 encountered. Exim does not have perfect detection of all protocol errors
31651 because of transmission delays and the use of pipelining. If PIPELINING has
31652 been advertised to a client, an Exim server assumes that the client will use
31653 it, and therefore it does not count &"expected"& errors (for example, RCPT
31654 received after rejecting MAIL) as protocol errors.
31655 .next
31656 .cindex "SMTP" "logging syntax errors"
31657 .cindex "SMTP" "syntax errors; logging"
31658 .cindex "SMTP" "unknown command; logging"
31659 .cindex "log" "unknown SMTP command"
31660 .cindex "log" "SMTP syntax error"
31661 &%smtp_syntax_error%&: A log line is written for every SMTP syntax error
31662 encountered. An unrecognized command is treated as a syntax error. For an
31663 external connection, the host identity is given; for an internal connection
31664 using &%-bs%& the sender identification (normally the calling user) is given.
31665 .next
31666 .cindex "log" "subject"
31667 .cindex "subject" "logging"
31668 &%subject%&: The subject of the message is added to the arrival log line,
31669 preceded by &"T="& (T for &"topic"&, since S is already used for &"size"&).
31670 Any MIME &"words"& in the subject are decoded. The &%print_topbitchars%& option
31671 specifies whether characters with values greater than 127 should be logged
31672 unchanged, or whether they should be rendered as escape sequences.
31673 .next
31674 .cindex "log" "certificate verification"
31675 &%tls_certificate_verified%&: An extra item is added to <= and => log lines
31676 when TLS is in use. The item is &`CV=yes`& if the peer's certificate was
31677 verified, and &`CV=no`& if not.
31678 .next
31679 .cindex "log" "TLS cipher"
31680 .cindex "TLS" "logging cipher"
31681 &%tls_cipher%&: When a message is sent or received over an encrypted
31682 connection, the cipher suite used is added to the log line, preceded by X=.
31683 .next
31684 .cindex "log" "TLS peer DN"
31685 .cindex "TLS" "logging peer DN"
31686 &%tls_peerdn%&: When a message is sent or received over an encrypted
31687 connection, and a certificate is supplied by the remote host, the peer DN is
31688 added to the log line, preceded by DN=.
31689 .next
31690 .cindex "log" "DNS failure in list"
31691 &%unknown_in_list%&: This setting causes a log entry to be written when the
31692 result of a list match is failure because a DNS lookup failed.
31693 .endlist
31694
31695
31696 .section "Message log"
31697 .cindex "message" "log file for"
31698 .cindex "log" "message log; description of"
31699 .cindex "&_msglog_& directory"
31700 .cindex "&%preserve_message_logs%&"
31701 In addition to the general log files, Exim writes a log file for each message
31702 that it handles. The names of these per-message logs are the message ids, and
31703 they are kept in the &_msglog_& sub-directory of the spool directory. Each
31704 message log contains copies of the log lines that apply to the message. This
31705 makes it easier to inspect the status of an individual message without having
31706 to search the main log. A message log is deleted when processing of the message
31707 is complete, unless &%preserve_message_logs%& is set, but this should be used
31708 only with great care because they can fill up your disk very quickly.
31709
31710 On a heavily loaded system, it may be desirable to disable the use of
31711 per-message logs, in order to reduce disk I/O. This can be done by setting the
31712 &%message_logs%& option false.
31713 .ecindex IIDloggen
31714
31715
31716 . ////////////////////////////////////////////////////////////////////////////
31717 . ////////////////////////////////////////////////////////////////////////////
31718
31719 .chapter "Exim utilities" "CHAPutils"
31720 .scindex IIDutils "utilities"
31721 A number of utility scripts and programs are supplied with Exim and are
31722 described in this chapter. There is also the Exim Monitor, which is covered in
31723 the next chapter. The utilities described here are:
31724
31725 .itable none 0 0 4  2* left  8* left  30* left  40* left
31726 .row "" &<<SECTfinoutwha>>&     &'exiwhat'&       &&&
31727   "list what Exim processes are doing"
31728 .row "" &<<SECTgreptheque>>&    &'exiqgrep'&      "grep the queue"
31729 .row "" &<<SECTsumtheque>>&     &'exiqsumm'&      "summarize the queue"
31730 .row "" &<<SECTextspeinf>>&     &'exigrep'&       "search the main log"
31731 .row "" &<<SECTexipick>>&       &'exipick'&       "select messages on &&&
31732                                                    various criteria"
31733 .row "" &<<SECTcyclogfil>>&     &'exicyclog'&     "cycle (rotate) log files"
31734 .row "" &<<SECTmailstat>>&      &'eximstats'&     &&&
31735   "extract statistics from the log"
31736 .row "" &<<SECTcheckaccess>>&   &'exim_checkaccess'& &&&
31737   "check address acceptance from given IP"
31738 .row "" &<<SECTdbmbuild>>&      &'exim_dbmbuild'& "build a DBM file"
31739 .row "" &<<SECTfinindret>>&     &'exinext'&       "extract retry information"
31740 .row "" &<<SECThindatmai>>&     &'exim_dumpdb'&   "dump a hints database"
31741 .row "" &<<SECThindatmai>>&     &'exim_tidydb'&   "clean up a hints database"
31742 .row "" &<<SECThindatmai>>&     &'exim_fixdb'&    "patch a hints database"
31743 .row "" &<<SECTmailboxmaint>>&  &'exim_lock'&     "lock a mailbox file"
31744 .endtable
31745
31746 Another utility that might be of use to sites with many MTAs is Tom Kistner's
31747 &'exilog'&. It provides log visualizations across multiple Exim servers. See
31748 &url(http://duncanthrax.net/exilog/) for details.
31749
31750
31751
31752
31753 .section "Finding out what Exim processes are doing (exiwhat)" "SECTfinoutwha"
31754 .cindex "&'exiwhat'&"
31755 .cindex "process" "querying"
31756 .cindex "SIGUSR1"
31757 On operating systems that can restart a system call after receiving a signal
31758 (most modern OS), an Exim process responds to the SIGUSR1 signal by writing
31759 a line describing what it is doing to the file &_exim-process.info_& in the
31760 Exim spool directory. The &'exiwhat'& script sends the signal to all Exim
31761 processes it can find, having first emptied the file. It then waits for one
31762 second to allow the Exim processes to react before displaying the results. In
31763 order to run &'exiwhat'& successfully you have to have sufficient privilege to
31764 send the signal to the Exim processes, so it is normally run as root.
31765
31766 &*Warning*&: This is not an efficient process. It is intended for occasional
31767 use by system administrators. It is not sensible, for example, to set up a
31768 script that sends SIGUSR1 signals to Exim processes at short intervals.
31769
31770
31771 Unfortunately, the &'ps'& command that &'exiwhat'& uses to find Exim processes
31772 varies in different operating systems. Not only are different options used,
31773 but the format of the output is different. For this reason, there are some
31774 system configuration options that configure exactly how &'exiwhat'& works. If
31775 it doesn't seem to be working for you, check the following compile-time
31776 options:
31777 .display
31778 &`EXIWHAT_PS_CMD    `& the command for running &'ps'&
31779 &`EXIWHAT_PS_ARG    `& the argument for &'ps'&
31780 &`EXIWHAT_EGREP_ARG `& the argument for &'egrep'& to select from &'ps'& output
31781 &`EXIWHAT_KILL_ARG  `& the argument for the &'kill'& command
31782 .endd
31783 An example of typical output from &'exiwhat'& is
31784 .code
31785 164 daemon: -q1h, listening on port 25
31786 10483 running queue: waiting for 0tAycK-0002ij-00 (10492)
31787 10492 delivering 0tAycK-0002ij-00 to mail.ref.example
31788   [10.19.42.42] (editor@ref.example)
31789 10592 handling incoming call from [192.168.243.242]
31790 10628 accepting a local non-SMTP message
31791 .endd
31792 The first number in the output line is the process number. The third line has
31793 been split here, in order to fit it on the page.
31794
31795
31796
31797 .section "Selective queue listing (exiqgrep)" "SECTgreptheque"
31798 .cindex "&'exiqgrep'&"
31799 .cindex "queue" "grepping"
31800 This utility is a Perl script contributed by Matt Hubbard. It runs
31801 .code
31802 exim -bpu
31803 .endd
31804 to obtain a queue listing with undelivered recipients only, and then greps the
31805 output to select messages that match given criteria. The following selection
31806 options are available:
31807
31808 .vlist
31809 .vitem &*-f*&&~<&'regex'&>
31810 Match the sender address. The field that is tested is enclosed in angle
31811 brackets, so you can test for bounce messages with
31812 .code
31813 exiqgrep -f '^<>$'
31814 .endd
31815 .vitem &*-r*&&~<&'regex'&>
31816 Match a recipient address. The field that is tested is not enclosed in angle
31817 brackets.
31818
31819 .vitem &*-s*&&~<&'regex'&>
31820 Match against the size field.
31821
31822 .vitem &*-y*&&~<&'seconds'&>
31823 Match messages that are younger than the given time.
31824
31825 .vitem &*-o*&&~<&'seconds'&>
31826 Match messages that are older than the given time.
31827
31828 .vitem &*-z*&
31829 Match only frozen messages.
31830
31831 .vitem &*-x*&
31832 Match only non-frozen messages.
31833 .endlist
31834
31835 The following options control the format of the output:
31836
31837 .vlist
31838 .vitem &*-c*&
31839 Display only the count of matching messages.
31840
31841 .vitem &*-l*&
31842 Long format &-- display the full message information as output by Exim. This is
31843 the default.
31844
31845 .vitem &*-i*&
31846 Display message ids only.
31847
31848 .vitem &*-b*&
31849 Brief format &-- one line per message.
31850
31851 .vitem &*-R*&
31852 Display messages in reverse order.
31853 .endlist
31854
31855 There is one more option, &%-h%&, which outputs a list of options.
31856
31857
31858
31859 .section "Summarising the queue (exiqsumm)" "SECTsumtheque"
31860 .cindex "&'exiqsumm'&"
31861 .cindex "queue" "summary"
31862 The &'exiqsumm'& utility is a Perl script which reads the output of &`exim
31863 -bp`& and produces a summary of the messages on the queue. Thus, you use it by
31864 running a command such as
31865 .code
31866 exim -bp | exiqsumm
31867 .endd
31868 The output consists of one line for each domain that has messages waiting for
31869 it, as in the following example:
31870 .code
31871 3   2322   74m   66m  msn.com.example
31872 .endd
31873 Each line lists the number of pending deliveries for a domain, their total
31874 volume, and the length of time that the oldest and the newest messages have
31875 been waiting. Note that the number of pending deliveries is greater than the
31876 number of messages when messages have more than one recipient.
31877
31878 .new
31879 A summary line is output at the end. By default the output is sorted on the
31880 domain name, but &'exiqsumm'& has the options &%-a%& and &%-c%&, which cause
31881 the output to be sorted by oldest message and by count of messages,
31882 respectively. There are also three options that split the messages for each
31883 domain into two or more subcounts: &%-b%& separates bounce messages, &%-f%&
31884 separates frozen messages, and &%-s%& separates messages according to their
31885 sender.
31886 .wen
31887
31888 The output of &'exim -bp'& contains the original addresses in the message, so
31889 this also applies to the output from &'exiqsumm'&. No domains from addresses
31890 generated by aliasing or forwarding are included (unless the &%one_time%&
31891 option of the &(redirect)& router has been used to convert them into &"top
31892 level"& addresses).
31893
31894
31895
31896
31897 .section "Extracting specific information from the log (exigrep)" &&&
31898          "SECTextspeinf"
31899 .cindex "&'exigrep'&"
31900 .cindex "log" "extracts; grepping for"
31901 The &'exigrep'& utility is a Perl script that searches one or more main log
31902 files for entries that match a given pattern. When it finds a match, it
31903 extracts all the log entries for the relevant message, not just those that
31904 match the pattern. Thus, &'exigrep'& can extract complete log entries for a
31905 given message, or all mail for a given user, or for a given host, for example.
31906 The input files can be in Exim log format or syslog format.
31907
31908 If a matching log line is not associated with a specific message, it is always
31909 included in &'exigrep'&'s output. The usage is:
31910 .display
31911 &`exigrep [-l] [-t<`&&'n'&&`>] <`&&'pattern'&&`> [<`&&'log file'&&`>] ...`&
31912 .endd
31913 The &%-t%& argument specifies a number of seconds. It adds an additional
31914 condition for message selection. Messages that are complete are shown only if
31915 they spent more than <&'n'&> seconds on the queue.
31916
31917 The &%-l%& flag means &"literal"&, that is, treat all characters in the
31918 pattern as standing for themselves. Otherwise the pattern must be a Perl
31919 regular expression. The pattern match is case-insensitive. If no file names are
31920 given on the command line, the standard input is read.
31921
31922 If the location of a &'zcat'& command is known from the definition of
31923 ZCAT_COMMAND in &_Local/Makefile_&, &'exigrep'& automatically passes any file
31924 whose name ends in COMPRESS_SUFFIX through &'zcat'& as it searches it.
31925
31926
31927 .section "Selecting messages by various criteria (exipick)" "SECTexipick"
31928 .cindex "&'exipick'&"
31929 John Jetmore's &'exipick'& utility is included in the Exim distribution. It
31930 lists messages from the queue according to a variety of criteria. For details,
31931 visit &url(http://www.exim.org/eximwiki/ToolExipickManPage) or run:
31932 .code
31933 exipick --help
31934 .endd
31935
31936
31937 .section "Cycling log files (exicyclog)" "SECTcyclogfil"
31938 .cindex "log" "cycling local files"
31939 .cindex "cycling logs"
31940 .cindex "&'exicyclog'&"
31941 The &'exicyclog'& script can be used to cycle (rotate) &'mainlog'& and
31942 &'rejectlog'& files. This is not necessary if only syslog is being used, or if
31943 you are using log files with datestamps in their names (see section
31944 &<<SECTdatlogfil>>&). Some operating systems have their own standard mechanisms
31945 for log cycling, and these can be used instead of &'exicyclog'& if preferred.
31946 There are two command line options for &'exicyclog'&:
31947 .ilist
31948 &%-k%& <&'count'&> specifies the number of log files to keep, overriding the
31949 default that is set when Exim is built. The default default is 10.
31950 .next
31951 &%-l%& <&'path'&> specifies the log file path, in the same format as Exim's
31952 &%log_file_path%& option (for example, &`/var/log/exim_%slog`&), again
31953 overriding the script's default, which is to find the setting from Exim's
31954 configuration.
31955 .endlist
31956
31957 Each time &'exicyclog'& is run the file names get &"shuffled down"& by one. If
31958 the main log file name is &_mainlog_& (the default) then when &'exicyclog'& is
31959 run &_mainlog_& becomes &_mainlog.01_&, the previous &_mainlog.01_& becomes
31960 &_mainlog.02_& and so on, up to the limit that is set in the script or by the
31961 &%-k%& option. Log files whose numbers exceed the limit are discarded. Reject
31962 logs are handled similarly.
31963
31964 If the limit is greater than 99, the script uses 3-digit numbers such as
31965 &_mainlog.001_&, &_mainlog.002_&, etc. If you change from a number less than 99
31966 to one that is greater, or &'vice versa'&, you will have to fix the names of
31967 any existing log files.
31968
31969 If no &_mainlog_& file exists, the script does nothing. Files that &"drop off"&
31970 the end are deleted. All files with numbers greater than 01 are compressed,
31971 using a compression command which is configured by the COMPRESS_COMMAND
31972 setting in &_Local/Makefile_&. It is usual to run &'exicyclog'& daily from a
31973 root &%crontab%& entry of the form
31974 .code
31975 1 0 * * * su exim -c /usr/exim/bin/exicyclog
31976 .endd
31977 assuming you have used the name &"exim"& for the Exim user. You can run
31978 &'exicyclog'& as root if you wish, but there is no need.
31979
31980
31981
31982 .section "Mail statistics (eximstats)" "SECTmailstat"
31983 .cindex "statistics"
31984 .cindex "&'eximstats'&"
31985 A Perl script called &'eximstats'& is provided for extracting statistical
31986 information from log files. The output is either plain text, or HTML.
31987 Exim log files are also suported by the &'Lire'& system produced by the
31988 LogReport Foundation &url(http://www.logreport.org).
31989
31990 The &'eximstats'& script has been hacked about quite a bit over time. The
31991 latest version is the result of some extensive revision by Steve Campbell. A
31992 lot of information is given by default, but there are options for suppressing
31993 various parts of it. Following any options, the arguments to the script are a
31994 list of files, which should be main log files. For example:
31995 .code
31996 eximstats -nr /var/spool/exim/log/mainlog.01
31997 .endd
31998 By default, &'eximstats'& extracts information about the number and volume of
31999 messages received from or delivered to various hosts. The information is sorted
32000 both by message count and by volume, and the top fifty hosts in each category
32001 are listed on the standard output. Similar information, based on email
32002 addresses or domains instead of hosts can be requested by means of various
32003 options. For messages delivered and received locally, similar statistics are
32004 also produced per user.
32005
32006 The output also includes total counts and statistics about delivery errors, and
32007 histograms showing the number of messages received and deliveries made in each
32008 hour of the day. A delivery with more than one address in its envelope (for
32009 example, an SMTP transaction with more than one RCPT command) is counted
32010 as a single delivery by &'eximstats'&.
32011
32012 Though normally more deliveries than receipts are reported (as messages may
32013 have multiple recipients), it is possible for &'eximstats'& to report more
32014 messages received than delivered, even though the queue is empty at the start
32015 and end of the period in question. If an incoming message contains no valid
32016 recipients, no deliveries are recorded for it. A bounce message is handled as
32017 an entirely separate message.
32018
32019 &'eximstats'& always outputs a grand total summary giving the volume and number
32020 of messages received and deliveries made, and the number of hosts involved in
32021 each case. It also outputs the number of messages that were delayed (that is,
32022 not completely delivered at the first attempt), and the number that had at
32023 least one address that failed.
32024
32025 The remainder of the output is in sections that can be independently disabled
32026 or modified by various options. It consists of a summary of deliveries by
32027 transport, histograms of messages received and delivered per time interval
32028 (default per hour), information about the time messages spent on the queue,
32029 a list of relayed messages, lists of the top fifty sending hosts, local
32030 senders, destination hosts, and destination local users by count and by volume,
32031 and a list of delivery errors that occurred.
32032
32033 The relay information lists messages that were actually relayed, that is, they
32034 came from a remote host and were directly delivered to some other remote host,
32035 without being processed (for example, for aliasing or forwarding) locally.
32036
32037 There are quite a few options for &'eximstats'& to control exactly what it
32038 outputs. These are documented in the Perl script itself, and can be extracted
32039 by running the command &(perldoc)& on the script. For example:
32040 .code
32041 perldoc /usr/exim/bin/eximstats
32042 .endd
32043
32044 .section "Checking access policy (exim_checkaccess)" "SECTcheckaccess"
32045 .cindex "&'exim_checkaccess'&"
32046 .cindex "policy control" "checking access"
32047 .cindex "checking access"
32048 The &%-bh%& command line argument allows you to run a fake SMTP session with
32049 debugging output, in order to check what Exim is doing when it is applying
32050 policy controls to incoming SMTP mail. However, not everybody is sufficiently
32051 familiar with the SMTP protocol to be able to make full use of &%-bh%&, and
32052 sometimes you just want to answer the question &"Does this address have
32053 access?"& without bothering with any further details.
32054
32055 The &'exim_checkaccess'& utility is a &"packaged"& version of &%-bh%&. It takes
32056 two arguments, an IP address and an email address:
32057 .code
32058 exim_checkaccess 10.9.8.7 A.User@a.domain.example
32059 .endd
32060 The utility runs a call to Exim with the &%-bh%& option, to test whether the
32061 given email address would be accepted in a RCPT command in a TCP/IP
32062 connection from the host with the given IP address. The output of the utility
32063 is either the word &"accepted"&, or the SMTP error response, for example:
32064 .code
32065 Rejected:
32066 550 Relay not permitted
32067 .endd
32068 When running this test, the utility uses &`<>`& as the envelope sender address
32069 for the MAIL command, but you can change this by providing additional
32070 options. These are passed directly to the Exim command. For example, to specify
32071 that the test is to be run with the sender address &'himself@there.example'&
32072 you can use:
32073 .code
32074 exim_checkaccess 10.9.8.7 A.User@a.domain.example \
32075                  -f himself@there.example
32076 .endd
32077 Note that these additional Exim command line items must be given after the two
32078 mandatory arguments.
32079
32080 Because the &%exim_checkaccess%& uses &%-bh%&, it does not perform callouts
32081 while running its checks. You can run checks that include callouts by using
32082 &%-bhc%&, but this is not yet available in a &"packaged"& form.
32083
32084
32085
32086 .section "Making DBM files (exim_dbmbuild)" "SECTdbmbuild"
32087 .cindex "DBM" "building dbm files"
32088 .cindex "building DBM files"
32089 .cindex "&'exim_dbmbuild'&"
32090 .cindex "lower casing"
32091 .cindex "binary zero" "in lookup key"
32092 The &'exim_dbmbuild'& program reads an input file containing keys and data in
32093 the format used by the &(lsearch)& lookup (see section
32094 &<<SECTsinglekeylookups>>&). It writes a DBM file using the lower-cased alias
32095 names as keys and the remainder of the information as data. The lower-casing
32096 can be prevented by calling the program with the &%-nolc%& option.
32097
32098 A terminating zero is included as part of the key string. This is expected by
32099 the &(dbm)& lookup type. However, if the option &%-nozero%& is given,
32100 &'exim_dbmbuild'& creates files without terminating zeroes in either the key
32101 strings or the data strings. The &(dbmnz)& lookup type can be used with such
32102 files.
32103
32104 The program requires two arguments: the name of the input file (which can be a
32105 single hyphen to indicate the standard input), and the name of the output file.
32106 It creates the output under a temporary name, and then renames it if all went
32107 well.
32108
32109 .cindex "USE_DB"
32110 If the native DB interface is in use (USE_DB is set in a compile-time
32111 configuration file &-- this is common in free versions of Unix) the two file
32112 names must be different, because in this mode the Berkeley DB functions create
32113 a single output file using exactly the name given. For example,
32114 .code
32115 exim_dbmbuild /etc/aliases /etc/aliases.db
32116 .endd
32117 reads the system alias file and creates a DBM version of it in
32118 &_/etc/aliases.db_&.
32119
32120 In systems that use the &'ndbm'& routines (mostly proprietary versions of
32121 Unix), two files are used, with the suffixes &_.dir_& and &_.pag_&. In this
32122 environment, the suffixes are added to the second argument of
32123 &'exim_dbmbuild'&, so it can be the same as the first. This is also the case
32124 when the Berkeley functions are used in compatibility mode (though this is not
32125 recommended), because in that case it adds a &_.db_& suffix to the file name.
32126
32127 If a duplicate key is encountered, the program outputs a warning, and when it
32128 finishes, its return code is 1 rather than zero, unless the &%-noduperr%&
32129 option is used. By default, only the first of a set of duplicates is used &--
32130 this makes it compatible with &(lsearch)& lookups. There is an option
32131 &%-lastdup%& which causes it to use the data for the last duplicate instead.
32132 There is also an option &%-nowarn%&, which stops it listing duplicate keys to
32133 &%stderr%&. For other errors, where it doesn't actually make a new file, the
32134 return code is 2.
32135
32136
32137
32138
32139 .section "Finding individual retry times (exinext)" "SECTfinindret"
32140 .cindex "retry" "times"
32141 .cindex "&'exinext'&"
32142 A utility called &'exinext'& (mostly a Perl script) provides the ability to
32143 fish specific information out of the retry database. Given a mail domain (or a
32144 complete address), it looks up the hosts for that domain, and outputs any retry
32145 information for the hosts or for the domain. At present, the retry information
32146 is obtained by running &'exim_dumpdb'& (see below) and post-processing the
32147 output. For example:
32148 .code
32149 $ exinext piglet@milne.fict.example
32150 kanga.milne.example:192.168.8.1 error 146: Connection refused
32151   first failed: 21-Feb-1996 14:57:34
32152   last tried:   21-Feb-1996 14:57:34
32153   next try at:  21-Feb-1996 15:02:34
32154 roo.milne.example:192.168.8.3 error 146: Connection refused
32155   first failed: 20-Jan-1996 13:12:08
32156   last tried:   21-Feb-1996 11:42:03
32157   next try at:  21-Feb-1996 19:42:03
32158   past final cutoff time
32159 .endd
32160 You can also give &'exinext'& a local part, without a domain, and it
32161 will give any retry information for that local part in your default domain.
32162 A message id can be used to obtain retry information pertaining to a specific
32163 message. This exists only when an attempt to deliver a message to a remote host
32164 suffers a message-specific error (see section &<<SECToutSMTPerr>>&).
32165 &'exinext'& is not particularly efficient, but then it is not expected to be
32166 run very often.
32167
32168 The &'exinext'& utility calls Exim to find out information such as the location
32169 of the spool directory. The utility has &%-C%& and &%-D%& options, which are
32170 passed on to the &'exim'& commands. The first specifies an alternate Exim
32171 configuration file, and the second sets macros for use within the configuration
32172 file. These features are mainly to help in testing, but might also be useful in
32173 environments where more than one configuration file is in use.
32174
32175
32176
32177 .section "Hints database maintenance" "SECThindatmai"
32178 .cindex "hints database" "maintenance"
32179 .cindex "maintaining Exim's hints database"
32180 Three utility programs are provided for maintaining the DBM files that Exim
32181 uses to contain its delivery hint information. Each program requires two
32182 arguments. The first specifies the name of Exim's spool directory, and the
32183 second is the name of the database it is to operate on. These are as follows:
32184
32185 .ilist
32186 &'retry'&: the database of retry information
32187 .next
32188 &'wait-'&<&'transport name'&>: databases of information about messages waiting
32189 for remote hosts
32190 .next
32191 &'callout'&: the callout cache
32192 .next
32193 &'ratelimit'&: the data for implementing the ratelimit ACL condition
32194 .next
32195 &'misc'&: other hints data
32196 .endlist
32197
32198 The &'misc'& database is used for
32199
32200 .ilist
32201 Serializing ETRN runs (when &%smtp_etrn_serialize%& is set)
32202 .next
32203 Serializing delivery to a specific host (when &%serialize_hosts%& is set in an
32204 &(smtp)& transport)
32205 .endlist
32206
32207
32208
32209 .section "exim_dumpdb"
32210 .cindex "&'exim_dumpdb'&"
32211 The entire contents of a database are written to the standard output by the
32212 &'exim_dumpdb'& program, which has no options or arguments other than the
32213 spool and database names. For example, to dump the retry database:
32214 .code
32215 exim_dumpdb /var/spool/exim retry
32216 .endd
32217 Two lines of output are produced for each entry:
32218 .code
32219 T:mail.ref.example:192.168.242.242 146 77 Connection refused
32220 31-Oct-1995 12:00:12 02-Nov-1995 12:21:39 02-Nov-1995 20:21:39 *
32221 .endd
32222 The first item on the first line is the key of the record. It starts with one
32223 of the letters R, or T, depending on whether it refers to a routing or
32224 transport retry. For a local delivery, the next part is the local address; for
32225 a remote delivery it is the name of the remote host, followed by its failing IP
32226 address (unless &%no_retry_include_ip_address%& is set on the &(smtp)&
32227 transport). If the remote port is not the standard one (port 25), it is added
32228 to the IP address. Then there follows an error code, an additional error code,
32229 and a textual description of the error.
32230
32231 The three times on the second line are the time of first failure, the time of
32232 the last delivery attempt, and the computed time for the next attempt. The line
32233 ends with an asterisk if the cutoff time for the last retry rule has been
32234 exceeded.
32235
32236 Each output line from &'exim_dumpdb'& for the &'wait-xxx'& databases
32237 consists of a host name followed by a list of ids for messages that are or were
32238 waiting to be delivered to that host. If there are a very large number for any
32239 one host, continuation records, with a sequence number added to the host name,
32240 may be seen. The data in these records is often out of date, because a message
32241 may be routed to several alternative hosts, and Exim makes no effort to keep
32242 cross-references.
32243
32244
32245
32246 .section "exim_tidydb"
32247 .cindex "&'exim_tidydb'&"
32248 The &'exim_tidydb'& utility program is used to tidy up the contents of a hints
32249 database. If run with no options, it removes all records that are more than 30
32250 days old. The age is calculated from the date and time that the record was last
32251 updated. Note that, in the case of the retry database, it is &'not'& the time
32252 since the first delivery failure. Information about a host that has been down
32253 for more than 30 days will remain in the database, provided that the record is
32254 updated sufficiently often.
32255
32256 The cutoff date can be altered by means of the &%-t%& option, which must be
32257 followed by a time. For example, to remove all records older than a week from
32258 the retry database:
32259 .code
32260 exim_tidydb -t 7d /var/spool/exim retry
32261 .endd
32262 Both the &'wait-xxx'& and &'retry'& databases contain items that involve
32263 message ids. In the former these appear as data in records keyed by host &--
32264 they were messages that were waiting for that host &-- and in the latter they
32265 are the keys for retry information for messages that have suffered certain
32266 types of error. When &'exim_tidydb'& is run, a check is made to ensure that
32267 message ids in database records are those of messages that are still on the
32268 queue. Message ids for messages that no longer exist are removed from
32269 &'wait-xxx'& records, and if this leaves any records empty, they are deleted.
32270 For the &'retry'& database, records whose keys are non-existent message ids are
32271 removed. The &'exim_tidydb'& utility outputs comments on the standard output
32272 whenever it removes information from the database.
32273
32274 Certain records are automatically removed by Exim when they are no longer
32275 needed, but others are not. For example, if all the MX hosts for a domain are
32276 down, a retry record is created for each one. If the primary MX host comes back
32277 first, its record is removed when Exim successfully delivers to it, but the
32278 records for the others remain because Exim has not tried to use those hosts.
32279
32280 It is important, therefore, to run &'exim_tidydb'& periodically on all the
32281 hints databases. You should do this at a quiet time of day, because it requires
32282 a database to be locked (and therefore inaccessible to Exim) while it does its
32283 work. Removing records from a DBM file does not normally make the file smaller,
32284 but all the common DBM libraries are able to re-use the space that is released.
32285 After an initial phase of increasing in size, the databases normally reach a
32286 point at which they no longer get any bigger, as long as they are regularly
32287 tidied.
32288
32289 &*Warning*&: If you never run &'exim_tidydb'&, the space used by the hints
32290 databases is likely to keep on increasing.
32291
32292
32293
32294
32295 .section "exim_fixdb"
32296 .cindex "&'exim_fixdb'&"
32297 The &'exim_fixdb'& program is a utility for interactively modifying databases.
32298 Its main use is for testing Exim, but it might also be occasionally useful for
32299 getting round problems in a live system. It has no options, and its interface
32300 is somewhat crude. On entry, it prompts for input with a right angle-bracket. A
32301 key of a database record can then be entered, and the data for that record is
32302 displayed.
32303
32304 If &"d"& is typed at the next prompt, the entire record is deleted. For all
32305 except the &'retry'& database, that is the only operation that can be carried
32306 out. For the &'retry'& database, each field is output preceded by a number, and
32307 data for individual fields can be changed by typing the field number followed
32308 by new data, for example:
32309 .code
32310 > 4 951102:1000
32311 .endd
32312 resets the time of the next delivery attempt. Time values are given as a
32313 sequence of digit pairs for year, month, day, hour, and minute. Colons can be
32314 used as optional separators.
32315
32316
32317
32318
32319 .section "Mailbox maintenance (exim_lock)" "SECTmailboxmaint"
32320 .cindex "mailbox" "maintenance"
32321 .cindex "&'exim_lock'&"
32322 .cindex "locking mailboxes"
32323 The &'exim_lock'& utility locks a mailbox file using the same algorithm as
32324 Exim. For a discussion of locking issues, see section &<<SECTopappend>>&.
32325 &'Exim_lock'& can be used to prevent any modification of a mailbox by Exim or
32326 a user agent while investigating a problem. The utility requires the name of
32327 the file as its first argument. If the locking is successful, the second
32328 argument is run as a command (using C's &[system()]& function); if there is no
32329 second argument, the value of the SHELL environment variable is used; if this
32330 is unset or empty, &_/bin/sh_& is run. When the command finishes, the mailbox
32331 is unlocked and the utility ends. The following options are available:
32332
32333 .vlist
32334 .vitem &%-fcntl%&
32335 Use &[fcntl()]& locking on the open mailbox.
32336
32337 .vitem &%-flock%&
32338 Use &[flock()]& locking on the open mailbox, provided the operating system
32339 supports it.
32340
32341 .vitem &%-interval%&
32342 This must be followed by a number, which is a number of seconds; it sets the
32343 interval to sleep between retries (default 3).
32344
32345 .vitem &%-lockfile%&
32346 Create a lock file before opening the mailbox.
32347
32348 .vitem &%-mbx%&
32349 Lock the mailbox using MBX rules.
32350
32351 .vitem &%-q%&
32352 Suppress verification output.
32353
32354 .vitem &%-retries%&
32355 This must be followed by a number; it sets the number of times to try to get
32356 the lock (default 10).
32357
32358 .vitem &%-restore_time%&
32359 This option causes &%exim_lock%& to restore the modified and read times to the
32360 locked file before exiting. This allows you to access a locked mailbox (for
32361 example, to take a backup copy) without disturbing the times that the user
32362 subsequently sees.
32363
32364 .vitem &%-timeout%&
32365 This must be followed by a number, which is a number of seconds; it sets a
32366 timeout to be used with a blocking &[fcntl()]& lock. If it is not set (the
32367 default), a non-blocking call is used.
32368
32369 .vitem &%-v%&
32370 Generate verbose output.
32371 .endlist
32372
32373 If none of &%-fcntl%&, &%-flock%&, &%-lockfile%& or &%-mbx%& are given, the
32374 default is to create a lock file and also to use &[fcntl()]& locking on the
32375 mailbox, which is the same as Exim's default. The use of &%-flock%& or
32376 &%-fcntl%& requires that the file be writeable; the use of &%-lockfile%&
32377 requires that the directory containing the file be writeable. Locking by lock
32378 file does not last for ever; Exim assumes that a lock file is expired if it is
32379 more than 30 minutes old.
32380
32381 The &%-mbx%& option can be used with either or both of &%-fcntl%& or
32382 &%-flock%&. It assumes &%-fcntl%& by default. MBX locking causes a shared lock
32383 to be taken out on the open mailbox, and an exclusive lock on the file
32384 &_/tmp/.n.m_& where &'n'& and &'m'& are the device number and inode
32385 number of the mailbox file. When the locking is released, if an exclusive lock
32386 can be obtained for the mailbox, the file in &_/tmp_& is deleted.
32387
32388 The default output contains verification of the locking that takes place. The
32389 &%-v%& option causes some additional information to be given. The &%-q%& option
32390 suppresses all output except error messages.
32391
32392 A command such as
32393 .code
32394 exim_lock /var/spool/mail/spqr
32395 .endd
32396 runs an interactive shell while the file is locked, whereas
32397 .display
32398 &`exim_lock -q /var/spool/mail/spqr <<End`&
32399 <&'some commands'&>
32400 &`End`&
32401 .endd
32402 runs a specific non-interactive sequence of commands while the file is locked,
32403 suppressing all verification output. A single command can be run by a command
32404 such as
32405 .code
32406 exim_lock -q /var/spool/mail/spqr \
32407   "cp /var/spool/mail/spqr /some/where"
32408 .endd
32409 Note that if a command is supplied, it must be entirely contained within the
32410 second argument &-- hence the quotes.
32411 .ecindex IIDutils
32412
32413
32414 . ////////////////////////////////////////////////////////////////////////////
32415 . ////////////////////////////////////////////////////////////////////////////
32416
32417 .chapter "The Exim monitor" "CHAPeximon"
32418 .scindex IIDeximon "Exim monitor" "description"
32419 .cindex "X-windows"
32420 .cindex "&'eximon'&"
32421 .cindex "Local/eximon.conf"
32422 .cindex "&_exim_monitor/EDITME_&"
32423 The Exim monitor is an application which displays in an X window information
32424 about the state of Exim's queue and what Exim is doing. An admin user can
32425 perform certain operations on messages from this GUI interface; however all
32426 such facilities are also available from the command line, and indeed, the
32427 monitor itself makes use of the command line to perform any actions requested.
32428
32429
32430
32431 .section "Running the monitor"
32432 The monitor is started by running the script called &'eximon'&. This is a shell
32433 script that sets up a number of environment variables, and then runs the
32434 binary called &_eximon.bin_&. The default appearance of the monitor window can
32435 be changed by editing the &_Local/eximon.conf_& file created by editing
32436 &_exim_monitor/EDITME_&. Comments in that file describe what the various
32437 parameters are for.
32438
32439 The parameters that get built into the &'eximon'& script can be overridden for
32440 a particular invocation by setting up environment variables of the same names,
32441 preceded by &`EXIMON_`&. For example, a shell command such as
32442 .code
32443 EXIMON_LOG_DEPTH=400 eximon
32444 .endd
32445 (in a Bourne-compatible shell) runs &'eximon'& with an overriding setting of
32446 the LOG_DEPTH parameter. If EXIMON_LOG_FILE_PATH is set in the environment, it
32447 overrides the Exim log file configuration. This makes it possible to have
32448 &'eximon'& tailing log data that is written to syslog, provided that MAIL.INFO
32449 syslog messages are routed to a file on the local host.
32450
32451 X resources can be used to change the appearance of the window in the normal
32452 way. For example, a resource setting of the form
32453 .code
32454 Eximon*background: gray94
32455 .endd
32456 changes the colour of the background to light grey rather than white. The
32457 stripcharts are drawn with both the data lines and the reference lines in
32458 black. This means that the reference lines are not visible when on top of the
32459 data. However, their colour can be changed by setting a resource called
32460 &"highlight"& (an odd name, but that's what the Athena stripchart widget uses).
32461 For example, if your X server is running Unix, you could set up lighter
32462 reference lines in the stripcharts by obeying
32463 .code
32464 xrdb -merge <<End
32465 Eximon*highlight: gray
32466 End
32467 .endd
32468 .cindex "admin user"
32469 In order to see the contents of messages on the queue, and to operate on them,
32470 &'eximon'& must either be run as root or by an admin user.
32471
32472 The monitor's window is divided into three parts. The first contains one or
32473 more stripcharts and two action buttons, the second contains a &"tail"& of the
32474 main log file, and the third is a display of the queue of messages awaiting
32475 delivery, with two more action buttons. The following sections describe these
32476 different parts of the display.
32477
32478
32479
32480
32481 .section "The stripcharts"
32482 .cindex "stripchart"
32483 The first stripchart is always a count of messages on the queue. Its name can
32484 be configured by setting QUEUE_STRIPCHART_NAME in the
32485 &_Local/eximon.conf_& file. The remaining stripcharts are defined in the
32486 configuration script by regular expression matches on log file entries, making
32487 it possible to display, for example, counts of messages delivered to certain
32488 hosts or using certain transports. The supplied defaults display counts of
32489 received and delivered messages, and of local and SMTP deliveries. The default
32490 period between stripchart updates is one minute; this can be adjusted by a
32491 parameter in the &_Local/eximon.conf_& file.
32492
32493 The stripchart displays rescale themselves automatically as the value they are
32494 displaying changes. There are always 10 horizontal lines in each chart; the
32495 title string indicates the value of each division when it is greater than one.
32496 For example, &"x2"& means that each division represents a value of 2.
32497
32498 It is also possible to have a stripchart which shows the percentage fullness of
32499 a particular disk partition, which is useful when local deliveries are confined
32500 to a single partition.
32501
32502 .cindex "&%statvfs%& function"
32503 This relies on the availability of the &[statvfs()]& function or equivalent in
32504 the operating system. Most, but not all versions of Unix that support Exim have
32505 this. For this particular stripchart, the top of the chart always represents
32506 100%, and the scale is given as &"x10%"&. This chart is configured by setting
32507 SIZE_STRIPCHART and (optionally) SIZE_STRIPCHART_NAME in the
32508 &_Local/eximon.conf_& file.
32509
32510
32511
32512
32513 .section "Main action buttons"
32514 .cindex "size" "of monitor window"
32515 .cindex "Exim monitor" "window size"
32516 .cindex "window size"
32517 Below the stripcharts there is an action button for quitting the monitor. Next
32518 to this is another button marked &"Size"&. They are placed here so that
32519 shrinking the window to its default minimum size leaves just the queue count
32520 stripchart and these two buttons visible. Pressing the &"Size"& button causes
32521 the window to expand to its maximum size, unless it is already at the maximum,
32522 in which case it is reduced to its minimum.
32523
32524 When expanding to the maximum, if the window cannot be fully seen where it
32525 currently is, it is moved back to where it was the last time it was at full
32526 size. When it is expanding from its minimum size, the old position is
32527 remembered, and next time it is reduced to the minimum it is moved back there.
32528
32529 The idea is that you can keep a reduced window just showing one or two
32530 stripcharts at a convenient place on your screen, easily expand it to show
32531 the full window when required, and just as easily put it back to what it was.
32532 The idea is copied from what the &'twm'& window manager does for its
32533 &'f.fullzoom'& action. The minimum size of the window can be changed by setting
32534 the MIN_HEIGHT and MIN_WIDTH values in &_Local/eximon.conf_&.
32535
32536 Normally, the monitor starts up with the window at its full size, but it can be
32537 built so that it starts up with the window at its smallest size, by setting
32538 START_SMALL=yes in &_Local/eximon.conf_&.
32539
32540
32541
32542 .section "The log display"
32543 .cindex "log" "tail of; in monitor"
32544 The second section of the window is an area in which a display of the tail of
32545 the main log is maintained.
32546 To save space on the screen, the timestamp on each log line is shortened by
32547 removing the date and, if &%log_timezone%& is set, the timezone.
32548 The log tail is not available when the only destination for logging data is
32549 syslog, unless the syslog lines are routed to a local file whose name is passed
32550 to &'eximon'& via the EXIMON_LOG_FILE_PATH environment variable.
32551
32552 The log sub-window has a scroll bar at its lefthand side which can be used to
32553 move back to look at earlier text, and the up and down arrow keys also have a
32554 scrolling effect. The amount of log that is kept depends on the setting of
32555 LOG_BUFFER in &_Local/eximon.conf_&, which specifies the amount of memory
32556 to use. When this is full, the earlier 50% of data is discarded &-- this is
32557 much more efficient than throwing it away line by line. The sub-window also has
32558 a horizontal scroll bar for accessing the ends of long log lines. This is the
32559 only means of horizontal scrolling; the right and left arrow keys are not
32560 available. Text can be cut from this part of the window using the mouse in the
32561 normal way. The size of this subwindow is controlled by parameters in the
32562 configuration file &_Local/eximon.conf_&.
32563
32564 Searches of the text in the log window can be carried out by means of the ^R
32565 and ^S keystrokes, which default to a reverse and a forward search,
32566 respectively. The search covers only the text that is displayed in the window.
32567 It cannot go further back up the log.
32568
32569 The point from which the search starts is indicated by a caret marker. This is
32570 normally at the end of the text in the window, but can be positioned explicitly
32571 by pointing and clicking with the left mouse button, and is moved automatically
32572 by a successful search. If new text arrives in the window when it is scrolled
32573 back, the caret remains where it is, but if the window is not scrolled back,
32574 the caret is moved to the end of the new text.
32575
32576 Pressing ^R or ^S pops up a window into which the search text can be typed.
32577 There are buttons for selecting forward or reverse searching, for carrying out
32578 the search, and for cancelling. If the &"Search"& button is pressed, the search
32579 happens and the window remains so that further searches can be done. If the
32580 &"Return"& key is pressed, a single search is done and the window is closed. If
32581 ^C is typed the search is cancelled.
32582
32583 The searching facility is implemented using the facilities of the Athena text
32584 widget. By default this pops up a window containing both &"search"& and
32585 &"replace"& options. In order to suppress the unwanted &"replace"& portion for
32586 eximon, a modified version of the &%TextPop%& widget is distributed with Exim.
32587 However, the linkers in BSDI and HP-UX seem unable to handle an externally
32588 provided version of &%TextPop%& when the remaining parts of the text widget
32589 come from the standard libraries. The compile-time option EXIMON_TEXTPOP can be
32590 unset to cut out the modified &%TextPop%&, making it possible to build Eximon
32591 on these systems, at the expense of having unwanted items in the search popup
32592 window.
32593
32594
32595
32596 .section "The queue display"
32597 .cindex "queue" "display in monitor"
32598 The bottom section of the monitor window contains a list of all messages that
32599 are on the queue, which includes those currently being received or delivered,
32600 as well as those awaiting delivery. The size of this subwindow is controlled by
32601 parameters in the configuration file &_Local/eximon.conf_&, and the frequency
32602 at which it is updated is controlled by another parameter in the same file &--
32603 the default is 5 minutes, since queue scans can be quite expensive. However,
32604 there is an &"Update"& action button just above the display which can be used
32605 to force an update of the queue display at any time.
32606
32607 When a host is down for some time, a lot of pending mail can build up for it,
32608 and this can make it hard to deal with other messages on the queue. To help
32609 with this situation there is a button next to &"Update"& called &"Hide"&. If
32610 pressed, a dialogue box called &"Hide addresses ending with"& is put up. If you
32611 type anything in here and press &"Return"&, the text is added to a chain of
32612 such texts, and if every undelivered address in a message matches at least one
32613 of the texts, the message is not displayed.
32614
32615 If there is an address that does not match any of the texts, all the addresses
32616 are displayed as normal. The matching happens on the ends of addresses so, for
32617 example, &'cam.ac.uk'& specifies all addresses in Cambridge, while
32618 &'xxx@foo.com.example'& specifies just one specific address. When any hiding
32619 has been set up, a button called &"Unhide"& is displayed. If pressed, it
32620 cancels all hiding. Also, to ensure that hidden messages do not get forgotten,
32621 a hide request is automatically cancelled after one hour.
32622
32623 While the dialogue box is displayed, you can't press any buttons or do anything
32624 else to the monitor window. For this reason, if you want to cut text from the
32625 queue display to use in the dialogue box, you have to do the cutting before
32626 pressing the &"Hide"& button.
32627
32628 The queue display contains, for each unhidden queued message, the length of
32629 time it has been on the queue, the size of the message, the message id, the
32630 message sender, and the first undelivered recipient, all on one line. If it is
32631 a bounce message, the sender is shown as &"<>"&. If there is more than one
32632 recipient to which the message has not yet been delivered, subsequent ones are
32633 listed on additional lines, up to a maximum configured number, following which
32634 an ellipsis is displayed. Recipients that have already received the message are
32635 not shown.
32636
32637 .cindex "frozen messages" "display"
32638 If a message is frozen, an asterisk is displayed at the left-hand side.
32639
32640 The queue display has a vertical scroll bar, and can also be scrolled by means
32641 of the arrow keys. Text can be cut from it using the mouse in the normal way.
32642 The text searching facilities, as described above for the log window, are also
32643 available, but the caret is always moved to the end of the text when the queue
32644 display is updated.
32645
32646
32647
32648 .section "The queue menu"
32649 .cindex "queue" "menu in monitor"
32650 If the &%shift%& key is held down and the left button is clicked when the mouse
32651 pointer is over the text for any message, an action menu pops up, and the first
32652 line of the queue display for the message is highlighted. This does not affect
32653 any selected text.
32654
32655 If you want to use some other event for popping up the menu, you can set the
32656 MENU_EVENT parameter in &_Local/eximon.conf_& to change the default, or
32657 set EXIMON_MENU_EVENT in the environment before starting the monitor. The
32658 value set in this parameter is a standard X event description. For example, to
32659 run eximon using &%ctrl%& rather than &%shift%& you could use
32660 .code
32661 EXIMON_MENU_EVENT='Ctrl<Btn1Down>' eximon
32662 .endd
32663 The title of the menu is the message id, and it contains entries which act as
32664 follows:
32665
32666 .ilist
32667 &'message log'&: The contents of the message log for the message are displayed
32668 in a new text window.
32669 .next
32670 &'headers'&: Information from the spool file that contains the envelope
32671 information and headers is displayed in a new text window. See chapter
32672 &<<CHAPspool>>& for a description of the format of spool files.
32673 .next
32674 &'body'&: The contents of the spool file containing the body of the message are
32675 displayed in a new text window. There is a default limit of 20,000 bytes to the
32676 amount of data displayed. This can be changed by setting the BODY_MAX
32677 option at compile time, or the EXIMON_BODY_MAX option at run time.
32678 .next
32679 &'deliver message'&: A call to Exim is made using the &%-M%& option to request
32680 delivery of the message. This causes an automatic thaw if the message is
32681 frozen. The &%-v%& option is also set, and the output from Exim is displayed in
32682 a new text window. The delivery is run in a separate process, to avoid holding
32683 up the monitor while the delivery proceeds.
32684 .next
32685 &'freeze message'&: A call to Exim is made using the &%-Mf%& option to request
32686 that the message be frozen.
32687 .next
32688 .cindex "thawing messages"
32689 .cindex "unfreezing messages"
32690 .cindex "frozen messages" "thawing"
32691 &'thaw message'&: A call to Exim is made using the &%-Mt%& option to request
32692 that the message be thawed.
32693 .next
32694 .cindex "delivery" "forcing failure"
32695 &'give up on msg'&: A call to Exim is made using the &%-Mg%& option to request
32696 that Exim gives up trying to deliver the message. A bounce message is generated
32697 for any remaining undelivered addresses.
32698 .next
32699 &'remove message'&: A call to Exim is made using the &%-Mrm%& option to request
32700 that the message be deleted from the system without generating a bounce
32701 message.
32702 .next
32703 &'add recipient'&: A dialog box is displayed into which a recipient address can
32704 be typed. If the address is not qualified and the QUALIFY_DOMAIN parameter
32705 is set in &_Local/eximon.conf_&, the address is qualified with that domain.
32706 Otherwise it must be entered as a fully qualified address. Pressing RETURN
32707 causes a call to Exim to be made using the &%-Mar%& option to request that an
32708 additional recipient be added to the message, unless the entry box is empty, in
32709 which case no action is taken.
32710 .next
32711 &'mark delivered'&: A dialog box is displayed into which a recipient address
32712 can be typed. If the address is not qualified and the QUALIFY_DOMAIN parameter
32713 is set in &_Local/eximon.conf_&, the address is qualified with that domain.
32714 Otherwise it must be entered as a fully qualified address. Pressing RETURN
32715 causes a call to Exim to be made using the &%-Mmd%& option to mark the given
32716 recipient address as already delivered, unless the entry box is empty, in which
32717 case no action is taken.
32718 .next
32719 &'mark all delivered'&: A call to Exim is made using the &%-Mmad%& option to
32720 mark all recipient addresses as already delivered.
32721 .next
32722 &'edit sender'&: A dialog box is displayed initialized with the current
32723 sender's address. Pressing RETURN causes a call to Exim to be made using the
32724 &%-Mes%& option to replace the sender address, unless the entry box is empty,
32725 in which case no action is taken. If you want to set an empty sender (as in
32726 bounce messages), you must specify it as &"<>"&. Otherwise, if the address is
32727 not qualified and the QUALIFY_DOMAIN parameter is set in &_Local/eximon.conf_&,
32728 the address is qualified with that domain.
32729 .endlist
32730
32731 When a delivery is forced, a window showing the &%-v%& output is displayed. In
32732 other cases when a call to Exim is made, if there is any output from Exim (in
32733 particular, if the command fails) a window containing the command and the
32734 output is displayed. Otherwise, the results of the action are normally apparent
32735 from the log and queue displays. However, if you set ACTION_OUTPUT=yes in
32736 &_Local/eximon.conf_&, a window showing the Exim command is always opened, even
32737 if no output is generated.
32738
32739 The queue display is automatically updated for actions such as freezing and
32740 thawing, unless ACTION_QUEUE_UPDATE=no has been set in
32741 &_Local/eximon.conf_&. In this case the &"Update"& button has to be used to
32742 force an update of the display after one of these actions.
32743
32744 In any text window that is displayed as result of a menu action, the normal
32745 cut-and-paste facility is available, and searching can be carried out using ^R
32746 and ^S, as described above for the log tail window.
32747 .ecindex IIDeximon
32748
32749
32750
32751
32752
32753 . ////////////////////////////////////////////////////////////////////////////
32754 . ////////////////////////////////////////////////////////////////////////////
32755
32756 .chapter "Security considerations" "CHAPsecurity"
32757 .scindex IIDsecurcon "security" "discussion of"
32758 This chapter discusses a number of issues concerned with security, some of
32759 which are also covered in other parts of this manual.
32760
32761 For reasons that this author does not understand, some people have promoted
32762 Exim as a &"particularly secure"& mailer. Perhaps it is because of the
32763 existence of this chapter in the documentation. However, the intent of the
32764 chapter is simply to describe the way Exim works in relation to certain
32765 security concerns, not to make any specific claims about the effectiveness of
32766 its security as compared with other MTAs.
32767
32768 What follows is a description of the way Exim is supposed to be. Best efforts
32769 have been made to try to ensure that the code agrees with the theory, but an
32770 absence of bugs can never be guaranteed. Any that are reported will get fixed
32771 as soon as possible.
32772
32773
32774 .section "Building a more &""hardened""& Exim"
32775 .cindex "security" "build-time features"
32776 There are a number of build-time options that can be set in &_Local/Makefile_&
32777 to create Exim binaries that are &"harder"& to attack, in particular by a rogue
32778 Exim administrator who does not have the root password, or by someone who has
32779 penetrated the Exim (but not the root) account. These options are as follows:
32780
32781 .ilist
32782 ALT_CONFIG_PREFIX can be set to a string that is required to match the
32783 start of any file names used with the &%-C%& option. When it is set, these file
32784 names are also not allowed to contain the sequence &"/../"&. (However, if the
32785 value of the &%-C%& option is identical to the value of CONFIGURE_FILE in
32786 &_Local/Makefile_&, Exim ignores &%-C%& and proceeds as usual.) There is no
32787 default setting for &%ALT_CONFIG_PREFIX%&.
32788
32789 If the permitted configuration files are confined to a directory to
32790 which only root has access, this guards against someone who has broken
32791 into the Exim account from running a privileged Exim with an arbitrary
32792 configuration file, and using it to break into other accounts.
32793 .next
32794 If ALT_CONFIG_ROOT_ONLY is defined, root privilege is retained for &%-C%&
32795 and &%-D%& only if the caller of Exim is root. Without it, the Exim user may
32796 also use &%-C%& and &%-D%& and retain privilege. Setting this option locks out
32797 the possibility of testing a configuration using &%-C%& right through message
32798 reception and delivery, even if the caller is root. The reception works, but by
32799 that time, Exim is running as the Exim user, so when it re-execs to regain
32800 privilege for the delivery, the use of &%-C%& causes privilege to be lost.
32801 However, root can test reception and delivery using two separate commands.
32802 ALT_CONFIG_ROOT_ONLY is not set by default.
32803 .next
32804 If DISABLE_D_OPTION is defined, the use of the &%-D%& command line option
32805 is disabled.
32806 .next
32807 FIXED_NEVER_USERS can be set to a colon-separated list of users that are
32808 never to be used for any deliveries. This is like the &%never_users%& runtime
32809 option, but it cannot be overridden; the runtime option adds additional users
32810 to the list. The default setting is &"root"&; this prevents a non-root user who
32811 is permitted to modify the runtime file from using Exim as a way to get root.
32812 .endlist
32813
32814
32815
32816
32817 .section "Root privilege"
32818 .cindex "setuid"
32819 .cindex "root privilege"
32820 The Exim binary is normally setuid to root, which means that it gains root
32821 privilege (runs as root) when it starts execution. In some special cases (for
32822 example, when the daemon is not in use and there are no local deliveries), it
32823 may be possible to run Exim setuid to some user other than root. This is
32824 discussed in the next section. However, in most installations, root privilege
32825 is required for two things:
32826
32827 .ilist
32828 To set up a socket connected to the standard SMTP port (25) when initialising
32829 the listening daemon. If Exim is run from &'inetd'&, this privileged action is
32830 not required.
32831 .next
32832 To be able to change uid and gid in order to read users' &_.forward_& files and
32833 perform local deliveries as the receiving user or as specified in the
32834 configuration.
32835 .endlist
32836
32837 It is not necessary to be root to do any of the other things Exim does, such as
32838 receiving messages and delivering them externally over SMTP, and it is
32839 obviously more secure if Exim does not run as root except when necessary.
32840 For this reason, a user and group for Exim to use must be defined in
32841 &_Local/Makefile_&. These are known as &"the Exim user"& and &"the Exim
32842 group"&. Their values can be changed by the run time configuration, though this
32843 is not recommended. Often a user called &'exim'& is used, but some sites use
32844 &'mail'& or another user name altogether.
32845
32846 Exim uses &[setuid()]& whenever it gives up root privilege. This is a permanent
32847 abdication; the process cannot regain root afterwards. Prior to release 4.00,
32848 &[seteuid()]& was used in some circumstances, but this is no longer the case.
32849
32850 After a new Exim process has interpreted its command line options, it changes
32851 uid and gid in the following cases:
32852
32853 .ilist
32854 .cindex "&%-C%& option"
32855 .cindex "&%-D%& option"
32856 If the &%-C%& option is used to specify an alternate configuration file, or if
32857 the &%-D%& option is used to define macro values for the configuration, and the
32858 calling process is not running as root or the Exim user, the uid and gid are
32859 changed to those of the calling process.
32860 However, if ALT_CONFIG_ROOT_ONLY is defined in &_Local/Makefile_&, only
32861 root callers may use &%-C%& and &%-D%& without losing privilege, and if
32862 DISABLE_D_OPTION is set, the &%-D%& option may not be used at all.
32863 .next
32864 .cindex "&%-be%& option"
32865 .cindex "&%-bf%& option"
32866 .cindex "&%-bF%& option"
32867 If the expansion test option (&%-be%&) or one of the filter testing options
32868 (&%-bf%& or &%-bF%&) are used, the uid and gid are changed to those of the
32869 calling process.
32870 .next
32871 If the process is not a daemon process or a queue runner process or a delivery
32872 process or a process for testing address routing (started with &%-bt%&), the
32873 uid and gid are changed to the Exim user and group. This means that Exim always
32874 runs under its own uid and gid when receiving messages. This also applies when
32875 testing address verification
32876 .cindex "&%-bv%& option"
32877 .cindex "&%-bh%& option"
32878 (the &%-bv%& option) and testing incoming message policy controls (the &%-bh%&
32879 option).
32880 .next
32881 For a daemon, queue runner, delivery, or address testing process, the uid
32882 remains as root at this stage, but the gid is changed to the Exim group.
32883 .endlist
32884
32885 The processes that initially retain root privilege behave as follows:
32886
32887 .ilist
32888 A daemon process changes the gid to the Exim group and the uid to the Exim
32889 user after setting up one or more listening sockets. The &[initgroups()]&
32890 function is called, so that if the Exim user is in any additional groups, they
32891 will be used during message reception.
32892 .next
32893 A queue runner process retains root privilege throughout its execution. Its
32894 job is to fork a controlled sequence of delivery processes.
32895 .next
32896 A delivery process retains root privilege throughout most of its execution,
32897 but any actual deliveries (that is, the transports themselves) are run in
32898 subprocesses which always change to a non-root uid and gid. For local
32899 deliveries this is typically the uid and gid of the owner of the mailbox; for
32900 remote deliveries, the Exim uid and gid are used. Once all the delivery
32901 subprocesses have been run, a delivery process changes to the Exim uid and gid
32902 while doing post-delivery tidying up such as updating the retry database and
32903 generating bounce and warning messages.
32904
32905 While the recipient addresses in a message are being routed, the delivery
32906 process runs as root. However, if a user's filter file has to be processed,
32907 this is done in a subprocess that runs under the individual user's uid and
32908 gid. A system filter is run as root unless &%system_filter_user%& is set.
32909 .next
32910 A process that is testing addresses (the &%-bt%& option) runs as root so that
32911 the routing is done in the same environment as a message delivery.
32912 .endlist
32913
32914
32915
32916
32917 .section "Running Exim without privilege" "SECTrunexiwitpri"
32918 .cindex "privilege" "running without"
32919 .cindex "unprivileged running"
32920 .cindex "root privilege" "running without"
32921 Some installations like to run Exim in an unprivileged state for more of its
32922 operation, for added security. Support for this mode of operation is provided
32923 by the global option &%deliver_drop_privilege%&. When this is set, the uid and
32924 gid are changed to the Exim user and group at the start of a delivery process
32925 (and also queue runner and address testing processes). This means that address
32926 routing is no longer run as root, and the deliveries themselves cannot change
32927 to any other uid.
32928
32929 .cindex SIGHUP
32930 .cindex "daemon" "restarting"
32931 Leaving the binary setuid to root, but setting &%deliver_drop_privilege%& means
32932 that the daemon can still be started in the usual way, and it can respond
32933 correctly to SIGHUP because the re-invocation regains root privilege.
32934
32935 An alternative approach is to make Exim setuid to the Exim user and also setgid
32936 to the Exim group. If you do this, the daemon must be started from a root
32937 process. (Calling Exim from a root process makes it behave in the way it does
32938 when it is setuid root.) However, the daemon cannot restart itself after a
32939 SIGHUP signal because it cannot regain privilege.
32940
32941 It is still useful to set &%deliver_drop_privilege%& in this case, because it
32942 stops Exim from trying to re-invoke itself to do a delivery after a message has
32943 been received. Such a re-invocation is a waste of resources because it has no
32944 effect.
32945
32946 If restarting the daemon is not an issue (for example, if &%mua_wrapper%& is
32947 set, or &'inetd'& is being used instead of a daemon), having the binary setuid
32948 to the Exim user seems a clean approach, but there is one complication:
32949
32950 In this style of operation, Exim is running with the real uid and gid set to
32951 those of the calling process, and the effective uid/gid set to Exim's values.
32952 Ideally, any association with the calling process' uid/gid should be dropped,
32953 that is, the real uid/gid should be reset to the effective values so as to
32954 discard any privileges that the caller may have. While some operating systems
32955 have a function that permits this action for a non-root effective uid, quite a
32956 number of them do not. Because of this lack of standardization, Exim does not
32957 address this problem at this time.
32958
32959 For this reason, the recommended approach for &"mostly unprivileged"& running
32960 is to keep the Exim binary setuid to root, and to set
32961 &%deliver_drop_privilege%&. This also has the advantage of allowing a daemon to
32962 be used in the most straightforward way.
32963
32964 If you configure Exim not to run delivery processes as root, there are a
32965 number of restrictions on what you can do:
32966
32967 .ilist
32968 You can deliver only as the Exim user/group. You should  explicitly use the
32969 &%user%& and &%group%& options to override routers or local transports that
32970 normally deliver as the recipient. This makes sure that configurations that
32971 work in this mode function the same way in normal mode. Any implicit or
32972 explicit specification of another user causes an error.
32973 .next
32974 Use of &_.forward_& files is severely restricted, such that it is usually
32975 not worthwhile to include them in the configuration.
32976 .next
32977 Users who wish to use &_.forward_& would have to make their home directory and
32978 the file itself accessible to the Exim user. Pipe and append-to-file entries,
32979 and their equivalents in Exim filters, cannot be used. While they could be
32980 enabled in the Exim user's name, that would be insecure and not very useful.
32981 .next
32982 Unless the local user mailboxes are all owned by the Exim user (possible in
32983 some POP3 or IMAP-only environments):
32984
32985 .olist
32986 They must be owned by the Exim group and be writable by that group. This
32987 implies you must set &%mode%& in the appendfile configuration, as well as the
32988 mode of the mailbox files themselves.
32989 .next
32990 You must set &%no_check_owner%&, since most or all of the files will not be
32991 owned by the Exim user.
32992 .next
32993 You must set &%file_must_exist%&, because Exim cannot set the owner correctly
32994 on a newly created mailbox when unprivileged. This also implies that new
32995 mailboxes need to be created manually.
32996 .endlist olist
32997 .endlist ilist
32998
32999
33000 These restrictions severely restrict what can be done in local deliveries.
33001 However, there are no restrictions on remote deliveries. If you are running a
33002 gateway host that does no local deliveries, setting &%deliver_drop_privilege%&
33003 gives more security at essentially no cost.
33004
33005 If you are using the &%mua_wrapper%& facility (see chapter
33006 &<<CHAPnonqueueing>>&), &%deliver_drop_privilege%& is forced to be true.
33007
33008
33009
33010
33011 .section "Delivering to local files"
33012 Full details of the checks applied by &(appendfile)& before it writes to a file
33013 are given in chapter &<<CHAPappendfile>>&.
33014
33015
33016
33017 .section "IPv4 source routing"
33018 .cindex "source routing" "in IP packets"
33019 .cindex "IP source routing"
33020 Many operating systems suppress IP source-routed packets in the kernel, but
33021 some cannot be made to do this, so Exim does its own check. It logs incoming
33022 IPv4 source-routed TCP calls, and then drops them. Things are all different in
33023 IPv6. No special checking is currently done.
33024
33025
33026
33027 .section "The VRFY, EXPN, and ETRN commands in SMTP"
33028 Support for these SMTP commands is disabled by default. If required, they can
33029 be enabled by defining suitable ACLs.
33030
33031
33032
33033
33034 .section "Privileged users"
33035 .cindex "trusted user"
33036 .cindex "admin user"
33037 .cindex "privileged user"
33038 .cindex "user" "trusted"
33039 .cindex "user" "admin"
33040 Exim recognises two sets of users with special privileges. Trusted users are
33041 able to submit new messages to Exim locally, but supply their own sender
33042 addresses and information about a sending host. For other users submitting
33043 local messages, Exim sets up the sender address from the uid, and doesn't
33044 permit a remote host to be specified.
33045
33046 .cindex "&%-f%& option"
33047 However, an untrusted user is permitted to use the &%-f%& command line option
33048 in the special form &%-f <>%& to indicate that a delivery failure for the
33049 message should not cause an error report. This affects the message's envelope,
33050 but it does not affect the &'Sender:'& header. Untrusted users may also be
33051 permitted to use specific forms of address with the &%-f%& option by setting
33052 the &%untrusted_set_sender%& option.
33053
33054 Trusted users are used to run processes that receive mail messages from some
33055 other mail domain and pass them on to Exim for delivery either locally, or over
33056 the Internet. Exim trusts a caller that is running as root, as the Exim user,
33057 as any user listed in the &%trusted_users%& configuration option, or under any
33058 group listed in the &%trusted_groups%& option.
33059
33060 Admin users are permitted to do things to the messages on Exim's queue. They
33061 can freeze or thaw messages, cause them to be returned to their senders, remove
33062 them entirely, or modify them in various ways. In addition, admin users can run
33063 the Exim monitor and see all the information it is capable of providing, which
33064 includes the contents of files on the spool.
33065
33066 .cindex "&%-M%& option"
33067 .cindex "&%-q%& option"
33068 By default, the use of the &%-M%& and &%-q%& options to cause Exim to attempt
33069 delivery of messages on its queue is restricted to admin users. This
33070 restriction can be relaxed by setting the &%no_prod_requires_admin%& option.
33071 Similarly, the use of &%-bp%& (and its variants) to list the contents of the
33072 queue is also restricted to admin users. This restriction can be relaxed by
33073 setting &%no_queue_list_requires_admin%&.
33074
33075 Exim recognises an admin user if the calling process is running as root or as
33076 the Exim user or if any of the groups associated with the calling process is
33077 the Exim group. It is not necessary actually to be running under the Exim
33078 group. However, if admin users who are not root or the Exim user are to access
33079 the contents of files on the spool via the Exim monitor (which runs
33080 unprivileged), Exim must be built to allow group read access to its spool
33081 files.
33082
33083
33084
33085 .section "Spool files"
33086 .cindex "spool directory" "files"
33087 Exim's spool directory and everything it contains is owned by the Exim user and
33088 set to the Exim group. The mode for spool files is defined in the
33089 &_Local/Makefile_& configuration file, and defaults to 0640. This means that
33090 any user who is a member of the Exim group can access these files.
33091
33092
33093
33094 .section "Use of argv[0]"
33095 Exim examines the last component of &%argv[0]%&, and if it matches one of a set
33096 of specific strings, Exim assumes certain options. For example, calling Exim
33097 with the last component of &%argv[0]%& set to &"rsmtp"& is exactly equivalent
33098 to calling it with the option &%-bS%&. There are no security implications in
33099 this.
33100
33101
33102
33103 .section "Use of %f formatting"
33104 The only use made of &"%f"& by Exim is in formatting load average values. These
33105 are actually stored in integer variables as 1000 times the load average.
33106 Consequently, their range is limited and so therefore is the length of the
33107 converted output.
33108
33109
33110
33111 .section "Embedded Exim path"
33112 Exim uses its own path name, which is embedded in the code, only when it needs
33113 to re-exec in order to regain root privilege. Therefore, it is not root when it
33114 does so. If some bug allowed the path to get overwritten, it would lead to an
33115 arbitrary program's being run as exim, not as root.
33116
33117
33118
33119 .section "Use of sprintf()"
33120 .cindex "&[sprintf()]&"
33121 A large number of occurrences of &"sprintf"& in the code are actually calls to
33122 &'string_sprintf()'&, a function that returns the result in malloc'd store.
33123 The intermediate formatting is done into a large fixed buffer by a function
33124 that runs through the format string itself, and checks the length of each
33125 conversion before performing it, thus preventing buffer overruns.
33126
33127 The remaining uses of &[sprintf()]& happen in controlled circumstances where
33128 the output buffer is known to be sufficiently long to contain the converted
33129 string.
33130
33131
33132
33133 .section "Use of debug_printf() and log_write()"
33134 Arbitrary strings are passed to both these functions, but they do their
33135 formatting by calling the function &'string_vformat()'&, which runs through
33136 the format string itself, and checks the length of each conversion.
33137
33138
33139
33140 .section "Use of strcat() and strcpy()"
33141 These are used only in cases where the output buffer is known to be large
33142 enough to hold the result.
33143 .ecindex IIDsecurcon
33144
33145
33146
33147
33148 . ////////////////////////////////////////////////////////////////////////////
33149 . ////////////////////////////////////////////////////////////////////////////
33150
33151 .chapter "Format of spool files" "CHAPspool"
33152 .scindex IIDforspo1 "format" "spool files"
33153 .scindex IIDforspo2 "spool directory" "format of files"
33154 .scindex IIDforspo3 "spool files" "format of"
33155 .cindex "spool files" "editing"
33156 A message on Exim's queue consists of two files, whose names are the message id
33157 followed by -D and -H, respectively. The data portion of the message is kept in
33158 the -D file on its own. The message's envelope, status, and headers are all
33159 kept in the -H file, whose format is described in this chapter. Each of these
33160 two files contains the final component of its own name as its first line. This
33161 is insurance against disk crashes where the directory is lost but the files
33162 themselves are recoverable.
33163
33164 Some people are tempted into editing -D files in order to modify messages. You
33165 need to be extremely careful if you do this; it is not recommended and you are
33166 on your own if you do it. Here are some of the pitfalls:
33167
33168 .ilist
33169 You must ensure that Exim does not try to deliver the message while you are
33170 fiddling with it. The safest way is to take out a write lock on the -D file,
33171 which is what Exim itself does, using &[fcntl()]&. If you update the file in
33172 place, the lock will be retained. If you write a new file and rename it, the
33173 lock will be lost at the instant of rename.
33174 .next
33175 .cindex "&$body_linecount$&"
33176 If you change the number of lines in the file, the value of
33177 &$body_linecount$&, which is stored in the -H file, will be incorrect. At
33178 present, this value is not used by Exim, but there is no guarantee that this
33179 will always be the case.
33180 .next
33181 If the message is in MIME format, you must take care not to break it.
33182 .next
33183 If the message is cryptographically signed, any change will invalidate the
33184 signature.
33185 .endlist
33186
33187
33188 Files whose names end with -J may also be seen in the &_input_& directory (or
33189 its subdirectories when &%split_spool_directory%& is set). These are journal
33190 files, used to record addresses to which the message has been delivered during
33191 the course of a delivery run. At the end of the run, the -H file is updated,
33192 and the -J file is deleted.
33193
33194
33195 .section "Format of the -H file"
33196 .cindex "uid (user id)" "in spool file"
33197 .cindex "gid (group id)" "in spool file"
33198 The second line of the -H file contains the login name for the uid of the
33199 process that called Exim to read the message, followed by the numerical uid and
33200 gid. For a locally generated message, this is normally the user who sent the
33201 message. For a message received over TCP/IP, it is normally the Exim user.
33202
33203 The third line of the file contains the address of the message's sender as
33204 transmitted in the envelope, contained in angle brackets. The sender address is
33205 empty for bounce messages. For incoming SMTP mail, the sender address is given
33206 in the MAIL command. For locally generated mail, the sender address is
33207 created by Exim from the login name of the current user and the configured
33208 &%qualify_domain%&. However, this can be overridden by the &%-f%& option or a
33209 leading &"From&~"& line if the caller is trusted, or if the supplied address is
33210 &"<>"& or an address that matches &%untrusted_set_senders%&.
33211
33212 The fourth line contains two numbers. The first is the time that the message
33213 was received, in the conventional Unix form &-- the number of seconds since the
33214 start of the epoch. The second number is a count of the number of messages
33215 warning of delayed delivery that have been sent to the sender.
33216
33217 There follow a number of lines starting with a hyphen. These can appear in any
33218 order, and are omitted when not relevant:
33219
33220 .vlist
33221 .vitem "&%-acl%&&~<&'number'&>&~<&'length'&>"
33222 This item is obsolete, and is not generated from Exim release 4.61 onwards;
33223 &%-aclc%& and &%-aclm%& are used instead. However, &%-acl%& is still
33224 recognized, to provide backward compatibility. In the old format, a line of
33225 this form is present for every ACL variable that is not empty. The number
33226 identifies the variable; the &%acl_c%&&*x*& variables are numbered 0&--9 and
33227 the &%acl_m%&&*x*& variables are numbered 10&--19. The length is the length of
33228 the data string for the variable. The string itself starts at the beginning of
33229 the next line, and is followed by a newline character. It may contain internal
33230 newlines.
33231
33232 .new
33233 .vitem "&%-aclc%&&~<&'rest-of-name'&>&~<&'length'&>"
33234 A line of this form is present for every ACL connection variable that is
33235 defined. Note that there is a space between &%-aclc%& and the rest of the name.
33236 The length is the length of the data string for the variable. The string itself
33237 starts at the beginning of the next line, and is followed by a newline
33238 character. It may contain internal newlines.
33239
33240 .vitem "&%-aclm%&&~<&'rest-of-name'&>&~<&'length'&>"
33241 A line of this form is present for every ACL message variable that is defined.
33242 Note that there is a space between &%-aclm%& and the rest of the name. The
33243 length is the length of the data string for the variable. The string itself
33244 starts at the beginning of the next line, and is followed by a newline
33245 character. It may contain internal newlines.
33246 .wen
33247
33248 .vitem "&%-active_hostname%&&~<&'hostname'&>"
33249 This is present if, when the message was received over SMTP, the value of
33250 &$smtp_active_hostname$& was different to the value of &$primary_hostname$&.
33251
33252 .vitem &%-allow_unqualified_recipient%&
33253 This is present if unqualified recipient addresses are permitted in header
33254 lines (to stop such addresses from being qualified if rewriting occurs at
33255 transport time). Local messages that were input using &%-bnq%& and remote
33256 messages from hosts that match &%recipient_unqualified_hosts%& set this flag.
33257
33258 .vitem &%-allow_unqualified_sender%&
33259 This is present if unqualified sender addresses are permitted in header lines
33260 (to stop such addresses from being qualified if rewriting occurs at transport
33261 time). Local messages that were input using &%-bnq%& and remote messages from
33262 hosts that match &%sender_unqualified_hosts%& set this flag.
33263
33264 .vitem "&%-auth_id%&&~<&'text'&>"
33265 The id information for a message received on an authenticated SMTP connection
33266 &-- the value of the &$authenticated_id$& variable.
33267
33268 .vitem "&%-auth_sender%&&~<&'address'&>"
33269 The address of an authenticated sender &-- the value of the
33270 &$authenticated_sender$& variable.
33271
33272 .vitem "&%-body_linecount%&&~<&'number'&>"
33273 This records the number of lines in the body of the message, and is always
33274 present.
33275
33276 .vitem "&%-body_zerocount%&&~<&'number'&>"
33277 This records the number of binary zero bytes in the body of the message, and is
33278 present if the number is greater than zero.
33279
33280 .vitem &%-deliver_firsttime%&
33281 This is written when a new message is first added to the spool. When the spool
33282 file is updated after a deferral, it is omitted.
33283
33284 .vitem "&%-frozen%&&~<&'time'&>"
33285 .cindex "frozen messages" "spool data"
33286 The message is frozen, and the freezing happened at <&'time'&>.
33287
33288 .vitem "&%-helo_name%&&~<&'text'&>"
33289 This records the host name as specified by a remote host in a HELO or EHLO
33290 command.
33291
33292 .vitem "&%-host_address%&&~<&'address'&>.<&'port'&>"
33293 This records the IP address of the host from which the message was received and
33294 the remote port number that was used. It is omitted for locally generated
33295 messages.
33296
33297 .vitem "&%-host_auth%&&~<&'text'&>"
33298 If the message was received on an authenticated SMTP connection, this records
33299 the name of the authenticator &-- the value of the
33300 &$sender_host_authenticated$& variable.
33301
33302 .vitem &%-host_lookup_failed%&
33303 This is present if an attempt to look up the sending host's name from its IP
33304 address failed. It corresponds to the &$host_lookup_failed$& variable.
33305
33306 .vitem "&%-host_name%&&~<&'text'&>"
33307 .cindex "reverse DNS lookup"
33308 .cindex "DNS" "reverse lookup"
33309 This records the name of the remote host from which the message was received,
33310 if the host name was looked up from the IP address when the message was being
33311 received. It is not present if no reverse lookup was done.
33312
33313 .vitem "&%-ident%&&~<&'text'&>"
33314 For locally submitted messages, this records the login of the originating user,
33315 unless it was a trusted user and the &%-oMt%& option was used to specify an
33316 ident value. For messages received over TCP/IP, this records the ident string
33317 supplied by the remote host, if any.
33318
33319 .vitem "&%-interface_address%&&~<&'address'&>.<&'port'&>"
33320 This records the IP address of the local interface and the port number through
33321 which a message was received from a remote host. It is omitted for locally
33322 generated messages.
33323
33324 .vitem &%-local%&
33325 The message is from a local sender.
33326
33327 .vitem &%-localerror%&
33328 The message is a locally-generated bounce message.
33329
33330 .vitem "&%-local_scan%&&~<&'string'&>"
33331 This records the data string that was returned by the &[local_scan()]& function
33332 when the message was received &-- the value of the &$local_scan_data$&
33333 variable. It is omitted if no data was returned.
33334
33335 .vitem &%-manual_thaw%&
33336 The message was frozen but has been thawed manually, that is, by an explicit
33337 Exim command rather than via the auto-thaw process.
33338
33339 .vitem &%-N%&
33340 A testing delivery process was started using the &%-N%& option to suppress any
33341 actual deliveries, but delivery was deferred. At any further delivery attempts,
33342 &%-N%& is assumed.
33343
33344 .vitem &%-received_protocol%&
33345 This records the value of the &$received_protocol$& variable, which contains
33346 the name of the protocol by which the message was received.
33347
33348 .vitem &%-sender_set_untrusted%&
33349 The envelope sender of this message was set by an untrusted local caller (used
33350 to ensure that the caller is displayed in queue listings).
33351
33352 .vitem "&%-spam_score_int%&&~<&'number'&>"
33353 If a message was scanned by SpamAssassin, this is present. It records the value
33354 of &$spam_score_int$&.
33355
33356 .vitem &%-tls_certificate_verified%&
33357 A TLS certificate was received from the client that sent this message, and the
33358 certificate was verified by the server.
33359
33360 .vitem "&%-tls_cipher%&&~<&'cipher name'&>"
33361 When the message was received over an encrypted connection, this records the
33362 name of the cipher suite that was used.
33363
33364 .vitem "&%-tls_peerdn%&&~<&'peer DN'&>"
33365 When the message was received over an encrypted connection, and a certificate
33366 was received from the client, this records the Distinguished Name from that
33367 certificate.
33368 .endlist
33369
33370 Following the options there is a list of those addresses to which the message
33371 is not to be delivered. This set of addresses is initialized from the command
33372 line when the &%-t%& option is used and &%extract_addresses_remove_arguments%&
33373 is set; otherwise it starts out empty. Whenever a successful delivery is made,
33374 the address is added to this set. The addresses are kept internally as a
33375 balanced binary tree, and it is a representation of that tree which is written
33376 to the spool file. If an address is expanded via an alias or forward file, the
33377 original address is added to the tree when deliveries to all its child
33378 addresses are complete.
33379
33380 If the tree is empty, there is a single line in the spool file containing just
33381 the text &"XX"&. Otherwise, each line consists of two letters, which are either
33382 Y or N, followed by an address. The address is the value for the node of the
33383 tree, and the letters indicate whether the node has a left branch and/or a
33384 right branch attached to it, respectively. If branches exist, they immediately
33385 follow. Here is an example of a three-node tree:
33386 .code
33387 YY darcy@austen.fict.example
33388 NN alice@wonderland.fict.example
33389 NN editor@thesaurus.ref.example
33390 .endd
33391 After the non-recipients tree, there is a list of the message's recipients.
33392 This is a simple list, preceded by a count. It includes all the original
33393 recipients of the message, including those to whom the message has already been
33394 delivered. In the simplest case, the list contains one address per line. For
33395 example:
33396 .code
33397 4
33398 editor@thesaurus.ref.example
33399 darcy@austen.fict.example
33400 rdo@foundation
33401 alice@wonderland.fict.example
33402 .endd
33403 However, when a child address has been added to the top-level addresses as a
33404 result of the use of the &%one_time%& option on a &(redirect)& router, each
33405 line is of the following form:
33406 .display
33407 <&'top-level address'&> <&'errors_to address'&> &&&
33408   <&'length'&>,<&'parent number'&>#<&'flag bits'&>
33409 .endd
33410 The 01 flag bit indicates the presence of the three other fields that follow
33411 the top-level address. Other bits may be used in future to support additional
33412 fields. The <&'parent number'&> is the offset in the recipients list of the
33413 original parent of the &"one time"& address. The first two fields are the
33414 envelope sender that is associated with this address and its length. If the
33415 length is zero, there is no special envelope sender (there are then two space
33416 characters in the line). A non-empty field can arise from a &(redirect)& router
33417 that has an &%errors_to%& setting.
33418
33419
33420 A blank line separates the envelope and status information from the headers
33421 which follow. A header may occupy several lines of the file, and to save effort
33422 when reading it in, each header is preceded by a number and an identifying
33423 character. The number is the number of characters in the header, including any
33424 embedded newlines and the terminating newline. The character is one of the
33425 following:
33426
33427 .table2 50pt
33428 .row <&'blank'&>         "header in which Exim has no special interest"
33429 .row &`B`&               "&'Bcc:'& header"
33430 .row &`C`&               "&'Cc:'& header"
33431 .row &`F`&               "&'From:'& header"
33432 .row &`I`&               "&'Message-id:'& header"
33433 .row &`P`&               "&'Received:'& header &-- P for &""postmark""&"
33434 .row &`R`&               "&'Reply-To:'& header"
33435 .row &`S`&               "&'Sender:'& header"
33436 .row &`T`&               "&'To:'& header"
33437 .row &`*`&               "replaced or deleted header"
33438 .endtable
33439
33440 Deleted or replaced (rewritten) headers remain in the spool file for debugging
33441 purposes. They are not transmitted when the message is delivered. Here is a
33442 typical set of headers:
33443 .code
33444 111P Received: by hobbit.fict.example with local (Exim 4.00)
33445 id 14y9EI-00026G-00; Fri, 11 May 2001 10:28:59 +0100
33446 049  Message-Id: <E14y9EI-00026G-00@hobbit.fict.example>
33447 038* X-rewrote-sender: bb@hobbit.fict.example
33448 042* From: Bilbo Baggins <bb@hobbit.fict.example>
33449 049F From: Bilbo Baggins <B.Baggins@hobbit.fict.example>
33450 099* To: alice@wonderland.fict.example, rdo@foundation,
33451 darcy@austen.fict.example, editor@thesaurus.ref.example
33452 104T To: alice@wonderland.fict.example, rdo@foundation.example,
33453 darcy@austen.fict.example, editor@thesaurus.ref.example
33454 038  Date: Fri, 11 May 2001 10:28:59 +0100
33455 .endd
33456 The asterisked headers indicate that the envelope sender, &'From:'& header, and
33457 &'To:'& header have been rewritten, the last one because routing expanded the
33458 unqualified domain &'foundation'&.
33459 .ecindex IIDforspo1
33460 .ecindex IIDforspo2
33461 .ecindex IIDforspo3
33462
33463
33464
33465
33466 . ////////////////////////////////////////////////////////////////////////////
33467 . ////////////////////////////////////////////////////////////////////////////
33468
33469 .chapter "Adding new drivers or lookup types" "" &&&
33470          "Adding drivers or lookups"
33471 .cindex "adding drivers"
33472 .cindex "new drivers" "adding"
33473 .cindex "drivers" "adding new"
33474 The following actions have to be taken in order to add a new router, transport,
33475 authenticator, or lookup type to Exim:
33476
33477 .olist
33478 Choose a name for the driver or lookup type that does not conflict with any
33479 existing name; I will use &"newdriver"& in what follows.
33480 .next
33481 Add to &_src/EDITME_& the line:
33482 .display
33483 <&'type'&>&`_NEWDRIVER=yes`&
33484 .endd
33485 where <&'type'&> is ROUTER, TRANSPORT, AUTH, or LOOKUP. If the
33486 code is not to be included in the binary by default, comment this line out. You
33487 should also add any relevant comments about the driver or lookup type.
33488 .next
33489 Add to &_src/config.h.defaults_& the line:
33490 .code
33491 #define <type>_NEWDRIVER
33492 .endd
33493 .next
33494 Edit &_src/drtables.c_&, adding conditional code to pull in the private header
33495 and create a table entry as is done for all the other drivers and lookup types.
33496 .next
33497 Edit &_Makefile_& in the appropriate sub-directory (&_src/routers_&,
33498 &_src/transports_&, &_src/auths_&, or &_src/lookups_&); add a line for the new
33499 driver or lookup type and add it to the definition of OBJ.
33500 .next
33501 Create &_newdriver.h_& and &_newdriver.c_& in the appropriate sub-directory of
33502 &_src_&.
33503 .next
33504 Edit &_scripts/MakeLinks_& and add commands to link the &_.h_& and &_.c_& files
33505 as for other drivers and lookups.
33506 .endlist
33507
33508 Then all you need to do is write the code! A good way to start is to make a
33509 proforma by copying an existing module of the same type, globally changing all
33510 occurrences of the name, and cutting out most of the code. Note that any
33511 options you create must be listed in alphabetical order, because the tables are
33512 searched using a binary chop procedure.
33513
33514 There is a &_README_& file in each of the sub-directories of &_src_& describing
33515 the interface that is expected.
33516
33517
33518
33519
33520 . ////////////////////////////////////////////////////////////////////////////
33521 . ////////////////////////////////////////////////////////////////////////////
33522
33523 .makeindex "Option index" "option"
33524
33525 .makeindex "Concept index" "concept"
33526
33527
33528 . /////////////////////////////////////////////////////////////////////////////
33529 . /////////////////////////////////////////////////////////////////////////////