e0185865257a131d4b5b168bad99125e98cf13ab
[exim.git] / doc / doc-src / spec.src
1 . $Cambridge: exim/doc/doc-src/spec.src,v 1.7 2005/02/16 16:09:00 ph10 Exp $
2 .
3 .set version "4.50"
4 .set previousversion "4.40"
5 .set versionmonth "February"
6 .set versionyear "2005"
7 .set ACL "ACL"
8
9 . The last of those is to make ACL index entries easier to type. It is put
10 . up here so that it gets picked up by the HTML converter, which otherwise
11 . skips to the first chapter. A longer version is set below for use in the
12 . printed index.
13
14 .set sgcal true
15 .set html  false
16 .set texinfo false
17
18 .if !set style
19 .library "a4ps"
20 .linelength ~~sys.linelength + 0.2in
21 .set newlinelength ~~sys.linelength
22 .emphasis ~~sys.linelength + 0.1in
23 .pagedepth ~~sys.pagedepth - 0.2in
24 .bindfont 51 "atl/Times-Bold" 9
25 .bindfont 52 "atl/Times-Roman" 9
26 .bindfont 53 "atl/Times-Roman" 7
27 .bindfont 54 "atl/Courier" 9
28 .bindfont 55 "atl/Courier-Bold" ~~maintypesize
29 .bindfont 56 "atl/Times-Italic" 7
30 .bindfont 57 "atl/Times-Bold" 7
31 .bindfont 58 "atl/Symbol" 7
32 .set ssspaceb 1.50
33
34 .if ~~sgcal
35 . Used for the "small print" incorporated code stuff. Only rm, it, bf, sp are
36 . actually used at present.
37 .              rm  it  sl  bf  bi  ss  tt  sp  sc
38 .fontgroup 9 = 53  56   0  57   0   0   0  58   0
39 .fi
40 .fi
41
42 .if !~~sys.fancy
43 .fontgroup 9 = 0  0  0  0  0  0  0  0  0
44 .fi
45
46 .include "markup.sg"
47
48 .if ~~sys.fancy
49 .flag $smc{ "$push$g0$f54"
50 .flag $sm{  "$push$g0$f53"
51 .flag $smi{ "$push$g0$f56"
52 .flag $as{  "$push$g0$f52"
53 .flag $ab{  "$push$g0$f51"
54 .flag $cb{  "$push$g0$f55"
55 .
56 .else
57 .flag $smc{ "$push"
58 .flag $sm{  "$push"
59 .flag $smi{ "$push"
60 .flag $cb{  "$push"
61 .fi
62
63 .macro isunderscore "string"
64 .set string "~~1"
65 .set length length "~~1"
66 .undrec 1
67 .endm
68
69 .macro undrec "offset"
70 .if ~~1 > ~~length
71 .set underscore false
72 .else
73 .set sub "~~string"(1,~~1)
74 .if "~~sub" == "_"
75 .set underscore true
76 .else
77 .set next ~~1 + 1
78 .undrec ~~next
79 .fi
80 .fi
81 .endm
82
83 .macro testunderscore "string"
84 .isunderscore "~~1"
85 .newline
86 .endm
87
88 .macro tabs 6
89 .if ~~sys.fancy
90 .tabset ~~1em
91 .else
92 .set temp (~~1 * 5)/4
93 .tabset ~~temp em
94 .fi
95 .endm
96
97 .macro startoptions
98 .newline
99 .push
100 .if ~~sys.fancy
101 .indent 6em
102 .else
103 .indent 7em
104 .fi
105 .endm
106
107 .macro endoptions
108 .newline
109 .pop
110 .endm
111
112 .macro option "option" ""
113 .newpar
114 .index \-~~1-\ option
115 .tempindent 0
116 \-~~1-\~~2#$i
117 .nosep
118 .endm
119
120 .macro startitems
121 .newline
122 .push
123 .indent 3em
124 .endm
125
126 .macro enditems
127 .newline
128 .pop
129 .endm
130
131 .macro item "item" "6"
132 .newpar
133 .if ~~sys.leftonpage < ~~2ld
134 .newpage
135 .fi
136 .tempindent 0
137 \**~~1**\
138 .blank
139 .endm
140
141 .macro startconf ""
142 .set confsection "~~1"
143 .newline
144 .push
145 .if ~~sys.fancy
146 .indent 2em
147 .tabset 9em
148 .else
149 .indent 4em
150 .tabset 13em
151 .fi
152 .endm
153
154 .macro endconf
155 .newline
156 .pop
157 .endm
158
159 .macro conf "option" "type" "default" "6"
160 .newpar
161 .if ~~sys.leftonpage < ~~4ld
162 .newpage
163 .fi
164 .testunderscore "~~1"
165 .if ~~underscore
166 .index \~~1\
167 .else
168 .index \~~1\ option
169 .fi
170 .if "~~confsection" == ""
171 .set inssect ""
172 .else
173 .set inssect "$rm{Use:} $it{~~confsection}###"
174 .fi
175 .tempindent 0
176 \**~~1**\ $c ~~inssect$rm{Type:} $it{~~2} $e $rm{Default:} $it{~~3}
177 .blank
178 .endm
179
180 .set contents true
181 .set figurenumber -1
182 .set displayindent 2em
183
184 .index @$1, @$2, etc. $it{see numerical variables}
185 .index address||rewriting $it{see rewriting}
186 .index CR character $it{see carriage return}
187 .index CRL $it{see certificate revocation list}
188 .index delivery||failure report $it{see bounce message}
189 .index dialup $it{see intermittently connected hosts}
190 .index exiscan $it{see content scanning}
191 .index failover $it{see fallback}
192 .index fallover $it{see fallback}
193 .index filter||Sieve $it{see Sieve filter}
194 .index ident $it{see RFC 1413}
195 .index LF character $it{see linefeed}
196 .index maximum $it{see limit}
197 .index NUL $it{see binary zero}
198 .index passwd file $it{see \(/etc/passwd)\}
199 .index process id $it{see pid}
200 .index RBL $it{see DNS list}
201 .index redirection $it{see address redirection}
202 .index return path||$it{see also envelope sender}
203 .index scanning $it{see content scanning}
204 .index SSL $it{see TLS}
205 .index string||expansion $it{see expansion}
206 .index top bit $it{see 8-bit characters}
207 .index variables $it{see expansion, variables}
208 .index zero, binary $it{see binary zero}
209
210 . This is used for the printed index. See setting above for
211 . the HTML index value.
212
213 .set ACL "access control lists (ACLs)"
214
215 . ======================================================
216
217 .push
218 .disable filling
219 .justify centre
220 .nofoot
221 .space 8ld
222 $chead{University of Cambridge Computing Service}
223 .space 2ld
224 $chead{Specification of the Exim Mail Transfer Agent}
225 .space 3ld
226 by
227 .space 1ld
228 Philip Hazel
229 .space ~~sys.leftonpage - 15*~~sys.linedepth
230 .justify left
231 University Computing Service
232 New Museums Site
233 Pembroke Street
234 Cambridge CB2 3QH
235 United Kingdom
236 .blank
237 .tabs 6
238 $it{phone:} $t +44 1223 334600
239 $it{fax:}   $t +44 1223 334679
240 $it{email:} $t ph10 $it{at} cus.cam.ac.uk
241 .blank
242 Edition for Exim ~~version, ~~versionmonth ~~versionyear
243 .space 2ld
244 .if ~~sgcal
245 .fontgroup 1
246 .fi
247 $c$rm{Copyright (c) University of Cambridge ~~versionyear}
248
249
250 .if ~~sgcal
251 .fontgroup 0
252 .font 0
253 .fi
254
255 .pop
256 .newpage
257
258 . Blank verso for title page
259 .space 1ld
260 .newpage
261
262
263 . Set up for actual text pages
264 .page 1
265 . The first one to prevent a warning from sgfr
266 . set runningfoot "~~chapter"
267 .set runningfoot ""
268
269 .if ~~sys.fancy
270 .footdepth 2ld
271 .foot
272 .if "~~runningfoot" == ""
273 .set rhs ""
274 .else
275 .set rhs "~~runningfoot (~~chapter)"
276 .fi
277 .set lhs "Exim ~~version"
278 .linelength ~~newlinelength
279 $it{~~lhs}$c[~~sys.pagenumber]$e$it{~~rhs}
280 .endfoot
281 .fi
282
283
284
285
286 .
287 .
288 .
289 .
290 . ============================================================================
291 .chapter Introduction
292 .set runningfoot "introduction"
293
294 .if ~~sys.fancy
295 $c$bi{If I have seen further it is by standing on the shoulders of giants.}##(Isaac Newton)
296 .elif !~~html
297 $c"If I have seen further it is by standing on the shoulders of giants."
298 .newline
299 $e (Isaac Newton)
300 .else
301 \*If I have seen further it is by standing on the shoulders of giants.*\
302 (Isaac Newton).
303 .fi
304 .blank 4
305
306 Exim is a mail transfer agent (MTA) for hosts that are running Unix or
307 Unix-like operating systems. It was designed on the assumption that it would be
308 run on hosts that are permanently connected to the Internet. However, it can be
309 used on intermittently connected hosts with suitable configuration adjustments.
310
311 Configuration files currently exist for the following operating systems: AIX,
312 BSD/OS (aka BSDI), Darwin (Mac OS X), DGUX, FreeBSD, GNU/Hurd, GNU/Linux,
313 HI-OSF (Hitachi), HP-UX, IRIX, MIPS RISCOS, NetBSD, OpenBSD, QNX, SCO, SCO
314 SVR4.2 (aka UNIX-SV), Solaris (aka SunOS5), SunOS4, Tru64-Unix (formerly
315 Digital UNIX, formerly DEC-OSF1), Ultrix, and Unixware. Some of these operating
316 systems are no longer current and cannot easily be tested, so the configuration
317 files may no longer work in practice.
318
319 There are also configuration files for compiling Exim in the Cygwin environment
320 that can be installed on systems running Windows. However, this document does
321 not contain any information about running Exim in the Cygwin environment.
322
323 The terms and conditions for the use and distribution of Exim are contained in
324 the file \(NOTICE)\. Exim is distributed under the terms of the GNU General
325 Public Licence, a copy of which may be found in the file \(LICENCE)\.
326
327 The use, supply or promotion of Exim for the purpose of sending bulk,
328 unsolicited electronic mail is incompatible with the basic aims of the program,
329 which revolve around the free provision of a service that enhances the quality
330 of personal communications. The author of Exim regards indiscriminate
331 mass-mailing as an antisocial, irresponsible abuse of the Internet.
332
333 Exim owes a great deal to Smail 3 and its author, Ron Karr. Without the
334 experience of running and working on the Smail 3 code, I could never have
335 contemplated starting to write a new MTA. Many of the ideas and user interfaces
336 were originally taken from Smail 3, though the actual code of Exim is entirely
337 new, and has developed far beyond the initial concept.
338
339 Many people, both in Cambridge and around the world, have contributed to the
340 development and the testing of Exim, and to porting it to various operating
341 systems. I am grateful to them all. The distribution now contains a file called
342 \(ACKNOWLEDGMENTS)\, in which I have started recording the names of
343 contributors.
344
345
346 .section Exim documentation
347 .index documentation
348 .em
349 This edition of the Exim specification applies to version ~~version of Exim.
350 Substantive changes from the ~~previousversion edition are marked by bars in
351 the right-hand margin in the PostScript, PDF, and plain text versions of the
352 document, and by green text in the HTML version, as shown by this paragraph.
353 Changes are not marked in the Texinfo version, because Texinfo doesn't support
354 change bars. Minor corrections and rewordings are not marked.
355 .nem
356
357 This document is very much a reference manual; it is not a tutorial. The reader
358 is expected to have some familiarity with the SMTP mail transfer protocol and
359 with general Unix system administration. Although there are some discussions
360 and examples in places, the information is mostly organized in a way that makes
361 it easy to look up, rather than in a natural order for sequential reading.
362 Furthermore, the manual aims to cover every aspect of Exim in detail, including
363 a number of rarely-used, special-purpose features that are unlikely to be of
364 very wide interest.
365
366 .index books about Exim
367 An `easier' discussion of Exim which provides more in-depth explanatory,
368 introductory, and tutorial material can be found in a book entitled
369 .if ~~html
370 [(A HREF="http://www.uit.co.uk/exim-book/")]
371 $it{The Exim SMTP Mail Server},
372 [(/A)]
373 published by UIT Cambridge.
374 .else
375 $it{The Exim SMTP Mail Server}, published by UIT Cambridge
376 (\?http://www.uit.co.uk/exim-book/?\).
377 .fi
378
379 This book also contains a chapter that gives a general introduction to SMTP and
380 Internet mail. Inevitably, however, the book is unlikely to be fully up-to-date
381 with the latest release of Exim. (Note that the earlier book about Exim,
382 published by O'Reilly, covers Exim 3, and many things have changed in Exim 4.)
383
384 .index \(doc/NewStuff)\
385 .index \(doc/ChangeLog)\
386 .index change log
387 As the program develops, there may be features in newer versions that have not
388 yet made it into this document, which is updated only when the most significant
389 digit of the fractional part of the version number changes. Specifications of
390 new features that are not yet in this manual are placed in the file
391 \(doc/NewStuff)\ in the Exim distribution. 
392
393 .em
394 Some features may be classified as `experimental'. These may change
395 incompatibly while they are developing, or even be withdrawn. For this reason,
396 they are not documented in this manual. Information about experimental features 
397 can be found in the file \(doc/experimental.txt)\.
398 .nem
399
400 All changes to the program (whether new features, bug fixes, or other kinds of
401 change) are noted briefly in the file called \(doc/ChangeLog)\.
402
403 .index \(doc/spec.txt)\
404 This specification itself is available as an ASCII file in \(doc/spec.txt)\ so
405 that it can easily be searched with a text editor. Other files in the \(doc)\
406 directory are:
407 .display rm
408 .tabs 18
409 \(OptionLists.txt)\   $t $rm{list of all options in alphabetical order}
410 \(dbm.discuss.txt)\   $t $rm{discussion about DBM libraries}
411 \(exim.8)\            $t $rm{a man page of Exim's command line options}
412 .newline
413 .em
414 \(experimental.txt)\  $t $rm{documentation of experimental features}
415 .nem
416 .newline
417 \(filter.txt)\        $t $rm{specification of the filter language}
418 \(pcrepattern.txt)\   $t $rm{specification of PCRE regular expressions}
419 \(pcretest.txt)\      $t $rm{specification of the PCRE testing program}
420 \(Exim3.upgrade)\     $t $rm{upgrade notes from release 2 to release 3}
421 \(Exim4.upgrade)\     $t $rm{upgrade notes from release 3 to release 4}
422 .endd
423 The main specification and the specification of the filtering language are also
424 available in other formats (HTML, PostScript, PDF, and Texinfo). Section
425 ~~SECTavail below tells you how to get hold of these.
426
427
428 .section FTP and web sites
429 .index web site
430 .index FTP site
431 .em
432 The primary distribution site for Exim is currently the University of 
433 Cambridge's FTP site, whose contents are described in \*Where to find the Exim
434 distribution*\ below. In addition, there is a
435 .if ~~html
436 [(A HREF="http://www.exim.org/")]
437 .fi
438 web site 
439 .if ~~html
440 [(/A)]
441 .fi
442 and an 
443 .if ~~html
444 [(A HREF="ftp://ftp.exim.org/")]
445 .fi
446 FTP site 
447 .if ~~html
448 [(/A)]
449 .fi
450 at \exim.org\. These are now also hosted at the University of Cambridge. 
451 The \exim.org\ site was previously hosted for a number of years by Energis
452 Squared, formerly Planet Online Ltd, whose support I gratefully acknowledge.
453
454 As well as Exim distribution tar files, the Exim web site contains a number of 
455 differently formatted versions of the documentation, including the
456 .index FAQ
457 .if ~~html
458 [(A HREF="FAQ.html")]
459 .fi
460 FAQ
461 .if ~~html
462 [(/A)]
463 .fi
464 in both text and HTML formats. The HTML version comes with a keyword-in-context
465 index. A recent addition to the online information is the
466 .index wiki
467 .if ~~html
468 [(A HREF="http://www.exim.org/eximwiki/")]
469 Exim wiki.
470 [(/A)]
471 .else
472 Exim wiki (\?http://www.exim.org/eximwiki/?\).
473 .fi
474 We hope that this will make it easier for Exim users to contribute examples, 
475 tips, and know-how for the benefit of others.
476 .nem
477
478 .section Mailing lists
479 .index mailing lists||for Exim users
480 The following are the two main Exim mailing lists:
481 .display rm
482 .tabs 28
483 $it{exim-users@@exim.org}          $t general discussion list
484 $it{exim-announce@@exim.org}       $t moderated, low volume announcements list
485 .endd
486 You can subscribe to these lists, change your existing subscriptions, and view
487 or search the archives via the
488 .if ~~html
489 [(A HREF="http://www.exim.org/maillist.html")]
490 .fi
491 mailing lists
492 .if ~~html
493 [(/A)]
494 .fi
495 link on the Exim home page. The $it{exim-users} mailing list is also forwarded
496 to \?http://www.egroups.com/list/exim-users?\, an archiving system with
497 searching capabilities.
498
499 .section Exim training
500 .index training courses
501 From time to time (approximately annually at the time of writing),
502 lecture-based training courses are run by the author of Exim in Cambridge, UK.
503 Details can be found on the web site
504 .if ~~html
505 [(A HREF="http://www-tus.csx.cam.ac.uk/courses/exim/")]
506 .fi
507 \?http://www-tus@.csx@.cam@.ac.uk/courses/exim/?\.
508 .if ~~html
509 [(/A)]
510 .fi
511
512 .section Bug reports
513 .index bug reports
514 .index reporting bugs
515 Reports of obvious bugs should be emailed to \*bugs@@exim.org*\. However, if
516 you are unsure whether some behaviour is a bug or not, the best thing to do is
517 to post a message to the $it{exim-users} mailing list and have it discussed.
518
519
520 .em
521 .section Where to find the Exim distribution
522 .rset SECTavail "~~chapter.~~section"
523 .index FTP site
524 .index distribution||ftp site
525 The master ftp site for the Exim distribution is
526 .display rm
527 .if ! ~~sys.fancy
528 .indent 0
529 .fi
530 \?ftp://ftp.csx.cam.ac.uk/pub/software/email/exim?\
531 .endd
532 This is mirrored by
533 .display rm
534 .if ! ~~sys.fancy
535 .indent 0
536 .fi
537 \?ftp://ftp.exim.org/pub/exim?\
538 .endd
539 The file references that follow are relative to the \(exim)\ directories at
540 these sites.
541
542 There are now quite a number of independent mirror sites around the world.
543 Those that I know about are listed in the file called \(Mirrors)\.
544
545 Within the \(exim)\ directory there are subdirectories called \(exim3)\ (for
546 previous Exim 3 distributions), \(exim4)\ (for the latest Exim 4
547 distributions), and \(Testing)\ for testing versions. In the \(exim4)\
548 subdirectory, the current release can always be found in files called
549 .display rm
550 \(exim-$it{n.nn}.tar.gz)\
551 \(exim-$it{n.nn}.tar.bz2)\
552 .endd
553 where $it{n.nn} is the highest such version number in the directory. The two
554 files contain identical data; the only difference is the type of compression.
555 The \(.bz2)\ file is usually a lot smaller than the \(.gz)\ file.
556 .index distribution||signing details
557 .index distribution||public key
558 .index public key for signed distribution
559 The distributions are currently signed with Philip Hazel's GPG key. The
560 corresponding public key is available from a number of keyservers, and there is
561 also a copy in the file \(Public-Key)\. The signatures for the tar bundles are
562 in:
563 .display rm
564 \(exim-$it{n.nn}.tar.gz.sig)\
565 \(exim-$it{n.nn}.tar.bz2.sig)\
566 .endd
567 For each released version, the log of changes is made separately available in a
568 separate file in the directory \(ChangeLogs)\ so that it is possible to
569 find out what has changed without having to download the entire distribution.
570
571 .index documentation||available formats
572 The main distribution contains ASCII versions of this specification and other
573 documentation; other formats of the documents are available in separate files
574 inside the \(exim4)\ directory of the FTP site:
575 .display rm
576 \(exim-html-$it{n.nn}.tar.gz)\
577 \(exim-pdf-$it{n.nn}.tar.gz)\
578 \(exim-postscript-$it{n.nn}.tar.gz)\
579 \(exim-texinfo-$it{n.nn}.tar.gz)\
580 .endd
581 These tar files contain only the \(doc)\ directory, not the complete
582 distribution, and are also available in \(.bz2)\ as well as \(.gz)\ forms.
583
584 .index FAQ
585 The FAQ is available for downloading in two different formats in these files:
586 .display rm
587 \(exim4/FAQ.txt.gz)\
588 \(exim4/FAQ.html.tar.gz)\
589 .endd
590 The first of these is a single ASCII file that can be searched with a text
591 editor. The second is a directory of HTML files, normally accessed by starting
592 at \(index.html)\. The HTML version of the FAQ (which is also included in the
593 HTML documentation tarbundle) includes a keyword-in-context index, which is
594 often the most convenient way of finding your way around.
595
596 .section Wish list
597 .index wish list
598 A wish list is maintained, containing ideas for new features that have been
599 submitted. From time to time the file is exported to the ftp site into the file
600 \(exim4/WishList)\. Items are removed from the list if they get implemented.
601
602
603 .section Contributed material
604 .index contributed material
605 At the ftp site, there is a directory called \(Contrib)\ that contains
606 miscellaneous files contributed to the Exim community by Exim users. There is
607 also a collection of contributed configuration examples in
608 \(exim4/config.samples.tar.gz)\. These samples are referenced from the FAQ.
609 .nem
610
611 .section Limitations
612 .index limitations of Exim
613 .numberpars $.
614 Exim is designed for use as an Internet MTA, and therefore handles addresses
615 in RFC 2822 domain format only.
616 .index bang paths||not handled by Exim
617 It cannot handle UUCP `bang paths', though simple two-component bang paths can
618 be converted by a straightforward rewriting configuration. This restriction
619 does not prevent Exim from being interfaced to UUCP as a transport mechanism,
620 provided that domain addresses are used.
621 .nextp
622 .index domainless addresses
623 .index address||without domain
624 Exim insists that every address it handles has a domain attached. For incoming
625 local messages, domainless addresses are automatically qualified with a
626 configured domain value. Configuration options specify from which remote
627 systems unqualified addresses are acceptable. These are then qualified on
628 arrival.
629 .nextp
630 .index transport||external
631 .index external transports
632 The only external transport currently implemented is an SMTP transport over a
633 TCP/IP network (using sockets, including support for IPv6). However, a pipe
634 transport is available, and there are facilities for writing messages to files
635 and pipes, optionally in \*batched SMTP*\ format; these facilities can be used
636 to send messages to some other transport mechanism such as UUCP, provided it
637 can handle domain-style addresses. Batched SMTP input is also catered for.
638 .nextp
639 Exim is not designed for storing mail for dial-in hosts. When the volumes of
640 such mail are large, it is better to get the messages `delivered' into files
641 (that is, off Exim's queue) and subsequently passed on to the dial-in hosts by
642 other means.
643 .nextp
644 .em
645 Although Exim does have basic facilities for scanning incoming messages, these
646 are not comprehensive enough to do full virus or spam scanning. Such operations
647 are best carried out using additional specialized software packages. If you 
648 compile Exim with the content-scanning extension, straightforward interfaces to 
649 a number of common scanners are provided.
650 .nem
651 .endp
652
653
654
655 .section Run time configuration
656 Exim's run time configuration is held in a single text file that is divided
657 into a number of sections. The entries in this file consist of keywords and
658 values, in the style of Smail 3 configuration files. A default configuration
659 file which is suitable for simple online installations is provided in the
660 distribution, and is described in chapter ~~CHAPdefconfil below.
661
662
663 .section Calling interface
664 .index Sendmail compatibility||command line interface
665 Like many MTAs, Exim has adopted the Sendmail command line interface so that it
666 can be a straight replacement for \(/usr/lib/sendmail)\ or
667 \(/usr/sbin/sendmail)\ when sending mail, but you do not need to know anything
668 about Sendmail in order to run Exim. For actions other than sending messages,
669 Sendmail-compatible options also exist, but those that produce output (for
670 example, \-bp-\, which lists the messages on the queue) do so in Exim's own
671 format. There are also some additional options that are compatible with Smail
672 3, and some further options that are new to Exim. Chapter ~~CHAPcommandline
673 documents all Exim's command line options. This information is automatically
674 made into the man page that forms part of the Exim distribution.
675
676 Control of messages on the queue can be done via certain privileged command
677 line options. There is also an optional monitor program called \*eximon*\, which
678 displays current information in an X window, and which contains a menu
679 interface to Exim's command line administration options.
680
681
682 .section Terminology
683 .index terminology definitions
684 .index body of message||definition of
685 The \*body*\ of a message is the actual data that the sender wants to transmit.
686 It is the last part of a message, and is separated from the \*header*\ (see
687 below) by a blank line.
688
689 .index bounce message||definition of
690 When a message cannot be delivered, it is normally returned to the sender in a
691 delivery failure message or a `non-delivery report' (NDR). The term \*bounce*\
692 is commonly used for this action, and the error reports are often called
693 \*bounce messages*\. This is a convenient shorthand for `delivery failure error
694 report'. Such messages have an empty sender address in the message's
695 \*envelope*\ (see below) to ensure that they cannot themselves give rise to
696 further bounce messages.
697
698 The term \*default*\ appears frequently in this manual. It is used to qualify a
699 value which is used in the absence of any setting in the configuration. It may
700 also qualify an action which is taken unless a configuration setting specifies
701 otherwise.
702
703 The term \*defer*\ is used when the delivery of a message to a specific
704 destination cannot immediately take place for some reason (a remote host may be
705 down, or a user's local mailbox may be full). Such deliveries are \*deferred*\
706 until a later time.
707
708 The word \*domain*\ is sometimes used to mean all but the first component of a
709 host's name. It is $it{not} used in that sense here, where it normally
710 refers to the part of an email address following the @@ sign.
711
712 .index envelope, definition of
713 .index sender||definition of
714 A message in transit has an associated \*envelope*\, as well as a header and a
715 body. The envelope contains a sender address (to which bounce messages should
716 be delivered), and any number of recipient addresses. References to the
717 sender or the recipients of a message usually mean the addresses in the
718 envelope. An MTA uses these addresses for delivery, and for returning bounce
719 messages, not the addresses that appear in the header lines.
720
721 .index message||header, definition of
722 .index header section||definition of
723 The \*header*\ of a message is the first part of a message's text, consisting
724 of a number of lines, each of which has a name such as ::From::, ::To::,
725 ::Subject::, etc. Long header lines can be split over several text lines by
726 indenting the continuations. The header is separated from the body by a blank
727 line.
728
729 .index local part||definition of
730 .index domain||definition of
731 The term \*local part*\, which is taken from RFC 2822, is used to refer to that
732 part of an email address that precedes the @@ sign. The part that follows the
733 @@ sign is called the \*domain*\ or \*mail domain*\.
734
735 .index local delivery||definition of
736 .index remote delivery, definition of
737 The terms \*local delivery*\ and \*remote delivery*\ are used to distinguish
738 delivery to a file or a pipe on the local host from delivery by SMTP over
739 TCP/IP to a remote host.
740
741 .index return path||definition of
742 \*Return path*\ is another name that is used for the sender address in a
743 message's envelope.
744
745 .index queue||definition of
746 The term \*queue*\ is used to refer to the set of messages awaiting delivery,
747 because this term is in widespread use in the context of MTAs. However, in
748 Exim's case the reality is more like a pool than a queue, because there is
749 normally no ordering of waiting messages.
750
751 .index queue runner||definition of
752 The term \*queue runner*\ is used to describe a process that scans the queue
753 and attempts to deliver those messages whose retry times have come. This term
754 is used by other MTAs, and also relates to the command \runq\, but in Exim
755 the waiting messages are normally processed in an unpredictable order.
756
757 .index spool directory||definition of
758 The term \*spool directory*\ is used for a directory in which Exim keeps the
759 messages on its queue -- that is, those that it is in the process of
760 delivering. This should not be confused with the directory in which local
761 mailboxes are stored, which is called a `spool directory' by some people. In
762 the Exim documentation, `spool' is always used in the first sense.
763
764
765
766 .
767 .
768 .
769 .
770 . ============================================================================
771 .chapter Incorporated code
772 .set runningfoot "incorporated code"
773 .index incorporated code
774 .index regular expressions||library
775 .index PCRE
776 A number of pieces of external code are included in the Exim distribution.
777 .numberpars $.
778 Regular expressions are supported in the main Exim program and in the Exim
779 monitor using the freely-distributable PCRE library, copyright (c) University
780 of Cambridge. The source is distributed in the directory \(src/pcre)\. However,
781 this is a cut-down version of PCRE. If you want to use the PCRE library in
782 other programs, you should obtain and install the full version from
783 \?ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre?\.
784
785 .space 1ld
786 .nextp
787 .index cdb||acknowledgement
788 Support for the cdb (Constant DataBase) lookup method is provided by code
789 contributed by Nigel Metheringham of (at the time he contributed it) Planet
790 Online Ltd. which contains the following statements:
791 .rule
792 .push
793 .if ~~sgcal
794 .fontgroup 9
795 .font 0
796 .fi
797 Copyright (c) 1998 Nigel Metheringham, Planet Online Ltd
798
799 This program is free software; you can redistribute it and/or modify it under
800 the terms of the GNU General Public License as published by the Free Software
801 Foundation; either version 2 of the License, or (at your option) any later
802 version.
803
804 This code implements Dan Bernstein's Constant DataBase (cdb) spec. Information,
805 the spec and sample code for cdb can be obtained from
806 \?http://www.pobox.com/@~djb/cdb.html?\. This implementation borrows some code
807 from Dan Bernstein's implementation (which has no license restrictions applied
808 to it).
809 .newline
810 .pop
811 .rule
812 The implementation is completely contained within the code of Exim.
813 It does not link against an external cdb library.
814 .space 1ld
815 .nextp
816 .index SPA authentication
817 .index Samba project
818 .index Microsoft Secure Password Authentication
819 Client support for Microsoft's \*Secure Password Authentication*\ is provided
820 by code contributed by Marc Prud'hommeaux. Server support was contributed by
821 Tom Kistner. This includes code taken from the Samba project, which is released
822 under the Gnu GPL.
823
824 .space 1ld
825 .nextp
826 .index Cyrus
827 .index \*pwcheck*\ daemon
828 .index \*pwauthd*\ daemon
829 Support for calling the Cyrus \*pwcheck*\ and \*saslauthd*\ daemons is provided
830 by code taken from the Cyrus-SASL library and adapted by Alexander S.
831 Sabourenkov. The permission notice appears below, in accordance with the
832 conditions expressed therein.
833
834 .rule
835 .push
836 .if ~~sgcal
837 .fontgroup 9
838 .font 0
839 .fi
840 Copyright (c) 2001 Carnegie Mellon University.  All rights reserved.
841
842 Redistribution and use in source and binary forms, with or without
843 modification, are permitted provided that the following conditions
844 are met:
845
846 .if ~~sgcal
847 .cancelflag $npbracket
848 .flag $npbracket "" "."
849 .fi
850 .numberpars
851 Redistributions of source code must retain the above copyright
852 notice, this list of conditions and the following disclaimer.
853 .nextp
854 Redistributions in binary form must reproduce the above copyright
855 notice, this list of conditions and the following disclaimer in
856 the documentation and/or other materials provided with the
857 distribution.
858 .nextp
859 The name `Carnegie Mellon University' must not be used to
860 endorse or promote products derived from this software without
861 prior written permission. For permission or any other legal
862 details, please contact
863 .display rm
864 Office of Technology Transfer
865 Carnegie Mellon University
866 5000 Forbes Avenue
867 Pittsburgh, PA  15213-3890
868 (412) 268-4387, fax: (412) 268-7395
869 tech-transfer@@andrew.cmu.edu
870 .endd
871 .nextp
872 Redistributions of any form whatsoever must retain the following
873 acknowledgment:
874 .newline
875 .push
876 .indent ~~sys.indent + 3em
877 .justify left
878 $it{This product includes software developed by Computing Services
879 at Carnegie Mellon University (\?http://www.cmu.edu/computing/?\).}
880 .newline
881 .pop
882 .endp
883 .if ~~sgcal
884 .cancelflag $npbracket
885 .flag $npbracket "(" ")"
886 .fi
887
888 CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
889 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
890 AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
891 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
892 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
893 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
894 OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
895 .newline
896 .pop
897 .rule
898
899 .space 1ld
900 .nextp
901 .index monitor
902 .index X-windows
903 .index Athena
904 The Exim Monitor program, which is an X-Window application, includes
905 modified versions of the Athena StripChart and TextPop widgets.
906 This code is copyright by DEC and MIT, and their permission notice appears
907 below, in accordance with the conditions expressed therein.
908
909 .rule
910 .push
911 .if ~~sgcal
912 .fontgroup 9
913 .font 0
914 .fi
915 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
916 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
917 .blank
918 $c All Rights Reserved
919 .blank
920 Permission to use, copy, modify, and distribute this software and its
921 documentation for any purpose and without fee is hereby granted,
922 provided that the above copyright notice appear in all copies and that
923 both that copyright notice and this permission notice appear in
924 supporting documentation, and that the names of Digital or MIT not be
925 used in advertising or publicity pertaining to distribution of the
926 software without specific, written prior permission.
927
928 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
929 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
930 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
931 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
932 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
933 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
934 SOFTWARE.
935 .newline
936 .pop
937 .rule
938 .space 1ld
939 .nextp
940 .em
941 Many people have contributed code fragments, some large, some small, that were
942 not covered by any specific licence requirements. It is assumed that the
943 contributors are happy to see their code incoporated into Exim under the GPL.
944 .nem
945 .endp
946
947
948
949 .
950 .
951 .
952 .
953 . ============================================================================
954 .chapter How Exim receives and delivers mail
955 .set runningfoot "receiving & delivering mail"
956
957 .section Overall philosophy
958 .index design philosophy
959 Exim is designed to work efficiently on systems that are permanently connected
960 to the Internet and are handling a general mix of mail. In such circumstances,
961 most messages can be delivered immediately. Consequently, Exim does not
962 maintain independent queues of messages for specific domains or hosts, though
963 it does try to send several messages in a single SMTP connection after a host
964 has been down, and it also maintains per-host retry information.
965
966
967 .section Policy control
968 .index policy control||overview
969 Policy controls are now an important feature of MTAs that are connected to the
970 Internet. Perhaps their most important job is to stop MTAs being abused as
971 `open relays' by misguided individuals who send out vast amounts of unsolicited
972 junk, and want to disguise its source. Exim provides flexible facilities for
973 specifying policy controls on incoming mail:
974 .numberpars $.
975 .index ~~ACL||introduction
976 Exim 4 (unlike previous versions of Exim) implements policy controls on
977 incoming mail by means of \*Access Control Lists*\ (ACLs). Each list is a
978 series of statements that may either grant or deny access. ACLs can be used at
979 several places in the SMTP dialogue while receiving a message from a remote 
980 host. However, the most common places are after each \\RCPT\\ command, and at
981 the very end of the message. The sysadmin can specify conditions for accepting
982 or rejecting individual recipients or the entire message, respectively, at
983 these two points (see chapter ~~CHAPACL). Denial of access results in an SMTP
984 error code.
985 .nextp
986 An ACL is also available for locally generated, non-SMTP messages. In this
987 case, the only available actions are to accept or deny the entire message.
988 .nextp
989 .em
990 When Exim is compiled with the content-scanning extension, facilities are 
991 provided in the ACL mechanism for passing the message to external virus and/or 
992 spam scanning software. The result of such a scan is passed back to the ACL,
993 which can then use it to decide what to do with the message.
994 .nem
995 .nextp
996 When a message has been received, either from a remote host or from the local
997 host, but before the final acknowledgement has been sent, a locally supplied C
998 function called \*local@_scan()*\ can be run to inspect the message and decide
999 whether to accept it or not (see chapter ~~CHAPlocalscan). If the message is
1000 accepted, the list of recipients can be modified by the function.
1001 .nextp
1002 .em
1003 Using the \*local@_scan()*\ mechanism is another way of calling external
1004 scanner software. The \SA-Exim\ add-on package works this way. It does not 
1005 require Exim to be compiled with the content-scanning extension.
1006 .nem
1007 .nextp
1008 After a message has been accepted, a further checking mechanism is available in
1009 the form of the $it{system filter} (see chapter ~~CHAPsystemfilter). This runs
1010 at the start of every delivery process.
1011 .endp
1012
1013 .section User filters
1014 .index filter||introduction
1015 .index Sieve filter
1016 In a conventional Exim configuration, users are able to run private filters by
1017 setting up appropriate \(.forward)\ files in their home directories. See
1018 chapter ~~CHAPredirect (about the \%redirect%\ router) for the configuration
1019 needed to support this, and the separate document entitled
1020 .if ~~html
1021 [(A HREF="filter_toc.html")]
1022 .fi
1023 \*Exim's interfaces to mail filtering*\
1024 .if ~~html
1025 [(/A)]
1026 .fi
1027 for user details. Two different kinds of filtering are available:
1028 .numberpars $.
1029 Sieve filters are written in the standard filtering language that is defined by
1030 RFC 3028.
1031 .nextp
1032 Exim filters are written in a syntax that is unique to Exim, but which is more
1033 powerful than Sieve, which it pre-dates.
1034 .endp
1035 User filters are run as part of the routing process, described below.
1036
1037
1038 .section Message identification
1039 .rset SECTmessiden "~~chapter.~~section"
1040 .index message||ids, details of format
1041 .index format||of message id
1042 .index id of message
1043 .index base62
1044 .index base36
1045 .index Darwin
1046 .index Cygwin
1047 Every message handled by Exim is given a \*message id*\ which is sixteen
1048 characters long. It is divided into three parts, separated by hyphens, for
1049 example \"16VDhn-0001bo-D3"\. Each part is a sequence of letters and digits,
1050 normally encoding numbers in base 62. However, in the Darwin operating
1051 system (Mac OS X) and when Exim is compiled to run under Cygwin, base 36
1052 (avoiding the use of lower case letters) is used instead, because the message
1053 id is used to construct file names, and the names of files in those systems are
1054 not case-sensitive.
1055
1056 .index pid (process id)||re-use of
1057 The detail of the contents of the message id have changed as Exim has evolved.
1058 Earlier versions relied on the operating system not re-using a process id (pid)
1059 within one second. On modern operating systems, this assumption can no longer
1060 be made, so the algorithm had to be changed. To retain backward compatibility,
1061 the format of the message id was retained, which is why the following rules are
1062 somewhat eccentric:
1063 .numberpars $.
1064 The first six characters of the message id are the time at which the message
1065 started to be received, to a granularity of one second. That is, this field
1066 contains the number of seconds since the start of the epoch (the normal Unix
1067 way of representing the date and time of day).
1068 .nextp
1069 After the first hyphen, the next six characters are the id of the process that
1070 received the message.
1071 .nextp
1072 There are two different possibilities for the final two characters:
1073 .numberpars alpha
1074 .index \localhost@_number\
1075 If \localhost@_number\ is not set, this value is the fractional part of the
1076 time of reception, normally in units of 1/2000 of a second, but for systems
1077 that must use base 36 instead of base 62 (because of case-insensitive file
1078 systems), the units are 1/1000 of a second.
1079 .nextp
1080 If \localhost@_number\ is set, it is multiplied by 200 (100) and added to
1081 the fractional part of the time, which in this case is in units of 1/200
1082 (1/100) of a second.
1083 .endp
1084 .endp
1085 After a message has been received, Exim waits for the clock to tick at the
1086 appropriate resolution before proceeding, so that if another message is
1087 received by the same process, or by another process with the same (re-used)
1088 pid, it is guaranteed that the time will be different. In most cases, the clock
1089 will already have ticked while the message was being received.
1090
1091 .section Receiving mail
1092 .index receiving mail
1093 .index message||reception
1094 The only way Exim can receive mail from a remote host is using SMTP over
1095 TCP/IP, in which case the sender and recipient addresses are tranferred using
1096 SMTP commands. However, from a locally running process (such as a user's MUA),
1097 there are several possibilities:
1098 .numberpars $.
1099 If the process runs Exim with the \-bm-\ option, the message is read
1100 non-interactively (usually via a pipe), with the recipients taken from the
1101 command line, or from the body of the message if \-t-\ is also used.
1102 .nextp
1103 If the process runs Exim with the \-bS-\ option, the message is also read
1104 non-interactively, but in this case the recipients are listed at the start of
1105 the message in a series of SMTP \\RCPT\\ commands, terminated by a \\DATA\\
1106 command. This is so-called `batch SMTP' format,
1107 but it isn't really SMTP. The SMTP commands are just another way of passing
1108 envelope addresses in a non-interactive submission.
1109 .nextp
1110 If the process runs Exim with the \-bs-\ option, the message is read
1111 interactively, using the SMTP protocol. A two-way pipe is normally used for
1112 passing data between the local process and the Exim process.
1113 This is `real' SMTP and is handled in the same way as SMTP over TCP/IP. For
1114 example, the ACLs for SMTP commands are used for this form of submission.
1115 .nextp
1116 A local process may also make a TCP/IP call to the host's loopback address
1117 (127.0.0.1) or any other of its IP addresses. When receiving messages, Exim
1118 does not treat the loopback address specially. It treats all such connections
1119 in the same way as connections from other hosts.
1120 .endp
1121
1122 .index message||sender, constructed by Exim
1123 .index sender||constructed by Exim
1124 In the three cases that do not involve TCP/IP, the sender address is
1125 constructed from the login name of the user that called Exim and a default
1126 qualification domain (which can be set by the \qualify@_domain\ configuration
1127 option). For local or batch SMTP, a sender address that is passed using the
1128 SMTP \\MAIL\\ command is ignored. However, the system administrator may allow
1129 certain users (`trusted users') to specify a different sender address
1130 unconditionally, or all users to specify certain forms of different sender
1131 address. The \-f-\ option or the SMTP \\MAIL\\ command is used to specify these
1132 different addresses. See section ~~SECTtrustedadmin for details of trusted
1133 users, and the \untrusted@_set@_sender\ option for a way of allowing untrusted
1134 users to change sender addresses.
1135
1136 Messages received by either of the non-interactive mechanisms are subject to
1137 checking by the non-SMTP ACL, if one is defined. Messages received using SMTP
1138 (either over TCP/IP, or interacting with a local process) can be checked by a
1139 number of ACLs that operate at different times during the SMTP session. Either
1140 individual recipients, or the entire message, can be rejected if local policy
1141 requirements are not met. The \*local@_scan()*\ function (see chapter
1142 ~~CHAPlocalscan) is run for all incoming messages.
1143
1144 Exim can be configured not to start a delivery process when a message is
1145 received; this can be unconditional, or depend on the number of incoming SMTP
1146 connections or the system load. In these situations, new messages wait on the
1147 queue until a queue runner process picks them up. However, in standard
1148 configurations under normal conditions, delivery is started as soon as a
1149 message is received.
1150
1151
1152
1153
1154 .section Handling an incoming message
1155 .index spool directory||files that hold a message
1156 .index file||how a message is held
1157 When Exim accepts a message, it writes two files in its spool directory. The
1158 first contains the envelope information, the current status of the message,
1159 and the header lines, and the second contains the body of the message. The
1160 names of the two spool files consist of the message id, followed by $tt{-H} for
1161 the file containing the envelope and header, and $tt{-D} for the data file.
1162
1163 .index spool directory||\(input)\ sub-directory
1164 By default all these message files are held in a single directory called
1165 \(input)\ inside the general Exim spool directory. Some operating systems do
1166 not perform very well if the number of files in a directory gets very large; to
1167 improve performance in such cases, the \split@_spool@_directory\ option can be
1168 used. This causes Exim to split up the input files into 62 sub-directories
1169 whose names are single letters or digits.
1170
1171 The envelope information consists of the address of the message's sender and
1172 the addresses of the recipients. This information is entirely separate from
1173 any addresses contained in the header lines. The status of the message includes
1174 a list of recipients who have already received the message. The format of the
1175 first spool file is described in chapter ~~CHAPspool.
1176
1177 .index rewriting||addresses
1178 Address rewriting that is specified in the rewrite section of the configuration
1179 (see chapter ~~CHAPrewrite) is done once and for all on incoming addresses,
1180 both in the header lines and the envelope, at the time the message is accepted.
1181 If during the course of delivery additional addresses are generated (for
1182 example, via aliasing), these new addresses are rewritten as soon as they are
1183 generated. At the time a message is actually delivered (transported) further
1184 rewriting can take place; because this is a transport option, it can be
1185 different for different forms of delivery. It is also possible to specify the
1186 addition or removal of certain header lines at the time the message is
1187 delivered (see chapters ~~CHAProutergeneric and ~~CHAPtransportgeneric).
1188
1189
1190 .section Life of a message
1191 .index message||life of
1192 .index message||frozen
1193 A message remains in the spool directory until it is completely delivered to
1194 its recipients or to an error address, or until it is deleted by an
1195 administrator or by the user who originally created it. In cases when delivery
1196 cannot proceed -- for example, when a message can neither be delivered to its
1197 recipients nor returned to its sender, the message is marked `frozen' on the
1198 spool, and no more deliveries are attempted.
1199
1200 .index frozen messages||thawing
1201 .index message||thawing frozen
1202 An administrator can `thaw' such messages when the problem has been corrected,
1203 and can also freeze individual messages by hand if necessary. In addition, an
1204 administrator can force a delivery error, causing a bounce message to be sent.
1205
1206 .index \auto@_thaw\
1207 There is an option called \auto@_thaw\, which can be used to cause Exim to
1208 retry frozen messages after a certain time. When this is set, no message will
1209 remain on the queue for ever, because the delivery timeout will eventually be
1210 reached. Delivery failure reports (bounce messages) that reach this timeout are
1211 discarded.
1212 .index \timeout@_frozen@_after\
1213 There is also an option called \timeout@_frozen@_after\, which discards frozen
1214 messages after a certain time.
1215
1216 .index message||log file for
1217 .index log||file for each message
1218 While Exim is working on a message, it writes information about each delivery
1219 attempt to the main log file. This includes successful, unsuccessful, and
1220 delayed deliveries for each recipient (see chapter ~~CHAPlog). The log lines
1221 are also written to a separate $it{message log} file for each message. These
1222 logs are solely for the benefit of the administrator, and are normally deleted
1223 along with the spool files when processing of a message is complete.
1224 The use of individual message logs can be disabled by setting
1225 \no@_message@_logs\; this might give an improvement in performance on very
1226 busy systems.
1227
1228 .index journal file
1229 .index file||journal
1230 All the information Exim itself needs to set up a delivery is kept in the first
1231 spool file, along with the header lines. When a successful delivery occurs, the
1232 address is immediately written at the end of a journal file, whose name is the
1233 message id followed by $tt{-J}. At the end of a delivery run, if there are some
1234 addresses left to be tried again later, the first spool file (the $tt{-H} file)
1235 is updated to indicate which these are, and the journal file is then deleted.
1236 Updating the spool file is done by writing a new file and renaming it, to
1237 minimize the possibility of data loss.
1238
1239 Should the system or the program crash after a successful delivery but before
1240 the spool file has been updated, the journal is left lying around. The next
1241 time Exim attempts to deliver the message, it reads the journal file and
1242 updates the spool file before proceeding. This minimizes the chances of double
1243 deliveries caused by crashes.
1244
1245
1246 .section Processing an address for delivery
1247 .rset SECTprocaddress "~~chapter.~~section"
1248 .index drivers||definition of
1249 .index router||definition of
1250 .index transport||definition of
1251 The main delivery processing elements of Exim are called $it{routers} and
1252 $it{transports}, and collectively these are known as $it{drivers}. Code for a
1253 number of them is provided in the source distribution, and compile-time options
1254 specify which ones are included in the binary. Run time options specify which
1255 ones are actually used for delivering messages.
1256
1257 .index drivers||instance definition
1258 Each driver that is specified in the run time configuration is an \*instance*\
1259 of that particular driver type. Multiple instances are allowed; for example,
1260 you can set up several different \%smtp%\ transports, each with different
1261 option values that might specify different ports or different timeouts. Each
1262 instance has its own identifying name. In what follows we will normally use the
1263 instance name when discussing one particular instance (that is, one specific
1264 configuration of the driver), and the generic driver name when discussing
1265 the driver's features in general.
1266
1267 A $it{router} is a driver that operates on an address, either determining how
1268 its delivery should happen, by routing it to a specific transport, or
1269 converting the address into one or more new addresses (for example, via an
1270 alias file). A router may also explicitly choose to fail an address, causing it
1271 to be bounced.
1272
1273 A $it{transport} is a driver that transmits a copy of the message from Exim's
1274 spool to some destination. There are two kinds of transport: for a $it{local}
1275 transport, the destination is a file or a pipe on the local host, whereas for a
1276 $it{remote} transport the destination is some other host. A message is passed
1277 to a specific transport as a result of successful routing. If a message has
1278 several recipients, it may be passed to a number of different transports.
1279
1280 .index preconditions||definition of
1281 An address is processed by passing it to each configured router instance in
1282 turn, subject to certain preconditions, until a router accepts the address or
1283 specifies that it should be bounced. We will describe this process in more
1284 detail shortly. As a simple example, the diagram below illustrates how each
1285 recipient address in a message is processed in a small configuration of three
1286 routers that are configured in various ways.
1287
1288 .if ~~sys.fancy
1289 .figure "Routing an address" rm
1290 .indent 0
1291 .call aspic -sgcal -nv
1292 centre ~~sys.linelength;
1293 magnify 0.8;
1294 boundingbox 30;
1295     ibox depth 14 "address";
1296 B:  arrow down 44;
1297     textdepth 14;
1298 A:  box width 100 "first router" "conditions ok?";
1299     arrow right "yes";
1300 C:  box width 100 "run" "first router";
1301     arrow down "fail";
1302 D:  ibox depth 20 "address bounces";
1303
1304     arc clockwise from right of C "accept";
1305     arrow down 10;
1306     ibox "queue for" "transport";
1307
1308     arrow down from A align bottom of D plus (0,-20) "no"(-6,20)/r;
1309 E:  box width 100 "second router" "conditions ok?";
1310     arrow right "yes";
1311 F:  box width 100 "run" "second router";
1312     line right 100 "redirect";
1313     line up align middle of B;
1314     arrow left to middle of B "new addresses";
1315
1316     line down 20 from bottom left of F plus (30,0);
1317     arrow left align centre of E "decline";
1318
1319     line down 20 from bottom right of F plus (-30,0);
1320     arrow right "fail";
1321     ibox width 64 "address" "bounces";
1322
1323     arrow down 64 from E "no"(-6,20)/r;
1324 G:  box width 100 "third router" "conditions ok?";
1325     arrow right "yes";
1326 H:  box width 100 "run" "third router";
1327     arc clockwise from right of H "accept";
1328     arrow down 10;
1329     ibox "queue for" "transport";
1330
1331     line down 20 from bottom of H;
1332     arrow left align centre of G "decline";
1333     arrow down 64 from G "no"(-6,20)/r;
1334
1335     ibox "no more routers" "address bounces";
1336 .endcall
1337 .endfigure
1338 .elif !~~html
1339 .display asis
1340
1341        address
1342           |
1343           |<------------- new addresses -----------------------------
1344           V                                                         |
1345   -----------------                -----------------                |
1346   | first router  |----- yes ----->|     run       |--- accept      |
1347   | conditions ok?|                | first router  |      |         |
1348   -----------------                -----------------      |         |
1349           |                                |              V         |
1350        no |                           fail |          queue for     |
1351           |                                V          transport     |
1352           |                         address bounces                 |
1353           |                                                         |
1354           V                                                         |
1355   -----------------                -----------------                |
1356   | second router |----- yes ----->|     run       |----redirect ----
1357   | conditions ok?|                | second router |
1358   -----------------                -----------------
1359           |                            |       |
1360        no |                            |       |
1361           |<-------- decline -----------       --- fail ---> address
1362           |                                                  bounces
1363           V
1364   -----------------                -----------------
1365   | third router  |----- yes ----->|     run       |--- accept
1366   | conditions ok?|                | third router  |      |
1367   -----------------                -----------------      |
1368           |                                |              V
1369        no |                                |          queue for
1370           |<-------- decline ---------------          transport
1371           |
1372           V
1373    no more routers
1374    address bounces
1375 .endd
1376 .else
1377 [(img src="routing.gif" alt="Routing an address")][(br)]
1378 .fi
1379 To make this a more concrete example, we'll describe it in terms of some actual
1380 routers, but remember, this is only an example. You can configure Exim's
1381 routers in many different ways, and there may be any number of routers in a
1382 configuration.
1383
1384 The first router that is specified in a configuration is often one that handles
1385 addresses in domains that are not recognized specially by the local host. These
1386 are typically addresses for arbitrary domains on the Internet. A precondition
1387 is set up which looks for the special domains known to the host (for example,
1388 its own domain name), and the router is run for addresses that do $it{not}
1389 match. Typically, this is a router that looks up domains in the DNS in order to
1390 find the hosts to which this address routes. If it succeeds, the address is
1391 queued for a suitable SMTP transport; if it does not succeed, the router is
1392 configured to fail the address.
1393
1394 The example pictured could be a configuration of this type. The second and
1395 third routers can only be run for addresses for which the preconditions for
1396 the first router are not met. If one of these preconditions checks the
1397 domain, the second and third routers are run only for domains that are somehow
1398 special to the local host.
1399
1400 The second router does redirection -- also known as aliasing and forwarding.
1401 When it generates one or more new addresses from the original, each of them is
1402 routed independently from the start. Otherwise, the router may cause an address
1403 to fail, or it may simply decline to handle the address, in which case the
1404 address is passed to the next router.
1405
1406 The final router in many configurations is one that checks to see if the
1407 address belongs to a local mailbox. The precondition may involve a check to
1408 see if the local part is the name of a login account, or it may look up the
1409 local part in a file or a database. If its preconditions are not met, or if
1410 the router declines, we have reached the end of the routers. When this happens,
1411 the address is bounced.
1412
1413
1414 .section Processing an address for verification
1415 .index router||for verification
1416 .index verifying||address, overview
1417 As well as being used to decide how to deliver to an address, Exim's routers
1418 are also used for \*address verification*\. Verification can be requested as
1419 one of the checks to be performed in an ACL for incoming messages, on both
1420 sender and recipient addresses, and it can be tested using the \-bv-\ and
1421 \-bvs-\ command line options.
1422
1423 When an address is being verified, the routers are run in `verify mode'. This
1424 does not affect the way the routers work, but it is a state that can be
1425 detected. By this means, a router can be skipped or made to behave differently
1426 when verifying. A common example is a configuration in which the first router
1427 sends all messages to a message-scanning program, unless they have been
1428 previously scanned. Thus, the first router accepts all addresses without any
1429 checking, making it useless for verifying. Normally, the \no@_verify\ option
1430 would be set for such a router, causing it to be skipped in verify mode.
1431
1432
1433
1434 .section Running an individual router
1435 .rset SECTrunindrou "~~chapter.~~section"
1436 .index router||running details
1437 .index preconditions||checking
1438 .index router||result of running
1439 As explained in the example above, a number of preconditions are checked before
1440 running a router. If any are not met, the router is skipped, and the address is
1441 passed to the next router. When all the preconditions on a router $it{are} met,
1442 the router is run. What happens next depends on the outcome, which is one of
1443 the following:
1444 .numberpars $.
1445 \*accept*\: The router accepts the address, and either queues it for a
1446 transport, or generates one or more `child' addresses. Processing the original
1447 address ceases,
1448 .index \unseen\ option
1449 unless the \unseen\ option is set on the router. This option
1450 can be used to set up multiple deliveries with different routing (for example,
1451 for keeping archive copies of messages). When \unseen\ is set, the address is
1452 passed to the next router. Normally, however, an \*accept*\ return marks the
1453 end of routing.
1454
1455 .index case of local parts
1456 .index address||duplicate, discarding
1457 If child addresses are generated, Exim checks to see whether they are
1458 duplicates of any existing recipient addresses. During this check, local parts
1459 are treated as case-sensitive. Duplicate addresses are discarded. Each of the
1460 remaining child addresses is then processed independently, starting with the
1461 first router by default. It is possible to change this by setting the
1462 \redirect@_router\ option to specify which router to start at for child
1463 addresses. Unlike \pass@_router\ (see below) the router specified by
1464 \redirect@_router\ may be anywhere in the router configuration.
1465 .nextp
1466 \*pass*\: The router recognizes the address, but cannot handle it itself. It
1467 requests that the address be passed to another router. By default the address
1468 is passed to the next router, but this can be changed by setting the
1469 \pass@_router\ option. However, (unlike \redirect@_router\) the named router
1470 must be below the current router (to avoid loops).
1471 .nextp
1472 \*decline*\: The router declines to accept the address because it does not
1473 recognize it at all. By default, the address is passed to the next router, but
1474 this can be prevented by setting the \no@_more\ option. When \no@_more\ is set,
1475 all the remaining routers are skipped.
1476 .nextp
1477 \*fail*\: The router determines that the address should fail, and queues it for
1478 the generation of a bounce message. There is no further processing of the
1479 original address unless \unseen\ is set on the router.
1480 .nextp
1481 \*defer*\: The router cannot handle the address at the present time. (A database
1482 may be offline, or a DNS lookup may have timed out.) No further processing of
1483 the address happens in this delivery attempt. It is tried again next time the
1484 message is considered for delivery.
1485 .nextp
1486 \*error*\: There is some error in the router (for example, a syntax error in
1487 its configuration). The action is as for defer.
1488 .endp
1489 If an address reaches the end of the routers without having been accepted by
1490 any of them, it is bounced as unrouteable.
1491 The default error message in this situation is `unrouteable address', but you
1492 can set your own message by making use of the \cannot@_route@_message\ option.
1493 This can be set for any router; the value from the last router that `saw'
1494 the address is used.
1495
1496 Sometimes while routing you want to fail a delivery when some conditions are
1497 met but others are not, instead of passing the address on for further routing.
1498 You can do this by having a second router that explicitly fails the delivery
1499 when the relevant conditions are met. The \%redirect%\ router has a `fail'
1500 facility for this purpose.
1501
1502
1503
1504 .section Router preconditions
1505 .rset SECTrouprecon "~~chapter.~~section"
1506 .index router||preconditions, order of processing
1507 .index preconditions||order of processing
1508 The preconditions that are tested for each router are listed below, in the
1509 order in which they are tested. The individual configuration options are
1510 described in more detail in chapter ~~CHAProutergeneric.
1511 .numberpars $.
1512 The \local@_part@_prefix\ and \local@_part@_suffix\ options can specify that
1513 the local parts handled by the router may or must have certain prefixes and/or
1514 suffixes. If a mandatory affix (prefix or suffix) is not present, the router is
1515 skipped. These conditions are tested first. When an affix is present, it is
1516 removed from the local part before further processing, including the evaluation
1517 of any other conditions.
1518 .nextp
1519 Routers can be designated for use only when not verifying an address, that is,
1520 only when routing it for delivery (or testing its delivery routing). If the
1521 \verify\ option is set false, the router is skipped when Exim is verifying an
1522 address.
1523 Setting the \verify\ option actually sets two options, \verify@_sender\ and
1524 \verify@_recipient\, which independently control the use of the router for
1525 sender and recipient verification. You can set these options directly if
1526 you want a router to be used for only one type of verification.
1527 .nextp
1528 If the \address@_test\ option is set false, the router is skipped when Exim is
1529 run with the \-bt-\ option to test an address routing. This can be helpful when
1530 the first router sends all new messages to a scanner of some sort; it makes it
1531 possible to use \-bt-\ to test subsequent delivery routing without having to
1532 simulate the effect of the scanner.
1533 .nextp
1534 Routers can be designated for use only when verifying an address, as
1535 opposed to routing it for delivery. The \verify@_only\ option controls this.
1536 .nextp
1537 Certain routers can be explicitly skipped when running the routers to check an
1538 address given in the SMTP \\EXPN\\ command (see the \expn\ option).
1539 .nextp
1540 If the \domains\ option is set, the domain of the address must be in the set of
1541 domains that it defines.
1542 .nextp
1543 If the \local@_parts\ option is set, the local part of the address must be in
1544 the set of local parts that it defines. If \local@_part@_prefix\ or
1545 \local@_part@_suffix\ is in use, the prefix or suffix is removed from the local
1546 part before this check. If you want to do precondition tests on local parts
1547 that include affixes, you can do so by using a \condition\ option (see below)
1548 that uses the variables \$local@_part$\, \$local@_part@_prefix$\, and
1549 \$local@_part@_suffix$\ as necessary.
1550 .nextp
1551 If the \check@_local@_user\ option is set, the local part must be the name of
1552 an account on the local host.
1553 If this check succeeds, the uid and gid of the local user are placed in
1554 \$local@_user@_uid$\ and \$local@_user@_gid$\; these values can be used in the
1555 remaining preconditions.
1556 .nextp
1557 If the \router@_home@_directory\ option is set, it is expanded at this point,
1558 because it overrides the value of \$home$\. If this expansion were left till
1559 later, the value of \$home$\ as set by \check@_local@_user\ would be used in
1560 subsequent tests. Having two different values of \$home$\ in the same router
1561 could lead to confusion.
1562 .nextp
1563 If the \senders\ option is set, the envelope sender address must be in the set
1564 of addresses that it defines.
1565 .nextp
1566 If the \require@_files\ option is set, the existence or non-existence of
1567 specified files is tested.
1568 .nextp
1569 .index customizing||precondition
1570 If the \condition\ option is set, it is evaluated and tested. This option uses
1571 an expanded string to allow you to set up your own custom preconditions.
1572 Expanded strings are described in chapter ~~CHAPexpand.
1573 .endp
1574
1575 Note that \require@_files\ comes near the end of the list, so you cannot use it
1576 to check for the existence of a file in which to lookup up a domain, local
1577 part, or sender. However, as these options are all expanded, you can use the
1578 \exists\ expansion condition to make such tests within each condition. The
1579 \require@_files\ option is intended for checking files that the router may be
1580 going to use internally, or which are needed by a specific transport (for
1581 example, \(.procmailrc)\).
1582
1583
1584 .section Delivery in detail
1585 .index delivery||in detail
1586 When a message is to be delivered, the sequence of events is as follows:
1587 .numberpars $.
1588 If a system-wide filter file is specified, the message is passed to it. The
1589 filter may add recipients to the message, replace the recipients, discard the
1590 message, cause a new message to be generated, or cause the message delivery to
1591 fail. The format of the system filter file is the same as for Exim user filter
1592 files, described in the separate document entitled
1593 .if ~~html
1594 [(A HREF="filter.html")]
1595 .fi
1596 \*Exim's interfaces to mail filtering*\.
1597 .if ~~html
1598 [(/A)]
1599 .fi
1600 .index Sieve filter||not available for system filter
1601 (\**Note**\: Sieve cannot be used for system filter files.)
1602 Some additional features are available in system filters -- see chapter
1603 ~~CHAPsystemfilter for details. Note that a message is passed to the system
1604 filter only once per delivery attempt, however many recipients it has. However,
1605 if there are several delivery attempts because one or more addresses could not
1606 be immediately delivered, the system filter is run each time. The filter
1607 condition \first@_delivery\ can be used to detect the first run of the system
1608 filter.
1609 .nextp
1610 Each recipient address is offered to each configured router in turn, subject to
1611 its preconditions, until one is able to handle it. If no router can handle
1612 the address, that is, if they all decline, the address is failed. Because
1613 routers can be targeted at particular domains, several locally handled domains
1614 can be processed entirely independently of each other.
1615 .nextp
1616 .index routing||loops in
1617 .index loop||while routing
1618 A router that accepts an address may set up a local or a remote transport for
1619 it. However, the transport is not run at this time. Instead, the address is
1620 placed on a list for the particular transport, to be run later. Alternatively,
1621 the router may generate one or more new addresses (typically from alias,
1622 forward, or filter files). New addresses are fed back into this process from
1623 the top, but in order to avoid loops, a router ignores any address which has an
1624 identically-named ancestor that was processed by itself.
1625 .nextp
1626 When all the routing has been done, addresses that have been successfully
1627 handled are passed to their assigned transports. When local transports are
1628 doing real local deliveries, they handle only one address at a time, but if a
1629 local transport is being used as a pseudo-remote transport (for example, to
1630 collect batched SMTP messages for transmission by some other means) multiple
1631 addresses can be handled. Remote transports can always handle more than one
1632 address at a time, but can be configured not to do so, or to restrict multiple
1633 addresses to the same domain.
1634 .nextp
1635 Each local delivery to a file or a pipe runs in a separate process under a
1636 non-privileged uid, and these deliveries are run one at a time. Remote
1637 deliveries also run in separate processes, normally under a uid that is private
1638 to Exim (`the Exim user'), but in this case, several remote deliveries can be
1639 run in parallel. The maximum number of simultaneous remote deliveries for any
1640 one message is set by the \remote@_max@_parallel\ option.
1641 The order in which deliveries are done is not defined, except that all local
1642 deliveries happen before any remote deliveries.
1643 .nextp
1644 .index queue runner
1645 When it encounters a local delivery during a queue run, Exim checks its retry
1646 database to see if there has been a previous temporary delivery failure for the
1647 address before running the local transport. If there was a previous failure,
1648 Exim does not attempt a new delivery until the retry time for the address is
1649 reached. However, this happens only for delivery attempts that are part of a
1650 queue run. Local deliveries are always attempted when delivery immediately
1651 follows message reception, even if retry times are set for them. This makes for
1652 better behaviour if one particular message is causing problems (for example,
1653 causing quota overflow, or provoking an error in a filter file).
1654 .nextp
1655 .index delivery||retry in remote transports
1656 Remote transports do their own retry handling, since an address may be
1657 deliverable to one of a number of hosts, each of which may have a different
1658 retry time. If there have been previous temporary failures and no host has
1659 reached its retry time, no delivery is attempted, whether in a queue run or
1660 not. See chapter ~~CHAPretry for details of retry strategies.
1661 .nextp
1662 If there were any permanent errors, a bounce message is returned to an
1663 appropriate address (the sender in the common case), with details of the error
1664 for each failing address. Exim can be configured to send copies of bounce
1665 messages to other addresses.
1666 .nextp
1667 .index delivery||deferral
1668 If one or more addresses suffered a temporary failure, the message is left on
1669 the queue, to be tried again later. Delivery of these addresses is said to be
1670 \*deferred*\.
1671 .nextp
1672 When all the recipient addresses have either been delivered or bounced,
1673 handling of the message is complete. The spool files and message log are
1674 deleted, though the message log can optionally be preserved if required.
1675 .endp
1676
1677
1678 .section Retry mechanism
1679 .index delivery||retry mechanism
1680 .index retry||description of mechanism
1681 .index queue runner
1682 Exim's mechanism for retrying messages that fail to get delivered at the first
1683 attempt is the queue runner process. You must either run an Exim daemon that
1684 uses the \-q-\ option with a time interval to start queue runners at regular
1685 intervals, or use some other means (such as \*cron*\) to start them. If you do
1686 not arrange for queue runners to be run, messages that fail temporarily at the
1687 first attempt will remain on your queue for ever. A queue runner process works
1688 it way through the queue, one message at a time, trying each delivery that has
1689 passed its retry time.
1690 You can run several queue runners at once.
1691
1692 Exim uses a set of configured rules to determine when next to retry the failing
1693 address (see chapter ~~CHAPretry). These rules also specify when Exim should
1694 give up trying to deliver to the address, at which point it generates a bounce
1695 message. If no retry rules are set for a particular host, address, and error
1696 combination, no retries are attempted, and temporary errors are treated as
1697 permanent.
1698
1699
1700 .section Temporary delivery failure
1701 .index delivery||temporary failure
1702 There are many reasons why a message may not be immediately deliverable to a
1703 particular address. Failure to connect to a remote machine (because it, or the
1704 connection to it, is down) is one of the most common. Temporary failures may be
1705 detected during routing as well as during the transport stage of delivery.
1706 Local deliveries may be delayed if NFS files are unavailable, or if a mailbox
1707 is on a file system where the user is over quota. Exim can be configured to
1708 impose its own quotas on local mailboxes; where system quotas are set they will
1709 also apply.
1710
1711 If a host is unreachable for a period of time, a number of messages may be
1712 waiting for it by the time it recovers, and sending them in a single SMTP
1713 connection is clearly beneficial. Whenever a delivery to a remote host is
1714 deferred,
1715 .index hints database
1716 Exim makes a note in its hints database, and whenever a successful
1717 SMTP delivery has happened, it looks to see if any other messages are waiting
1718 for the same host. If any are found, they are sent over the same SMTP
1719 connection, subject to a configuration limit as to the maximum number in any
1720 one connection.
1721
1722
1723
1724 .section Permanent delivery failure
1725 .index delivery||permanent failure
1726 .index bounce message||when generated
1727 When a message cannot be delivered to some or all of its intended recipients, a
1728 bounce message is generated. Temporary delivery failures turn into permanent
1729 errors when their timeout expires. All the addresses that fail in a given
1730 delivery attempt are listed in a single message. If the original message has
1731 many recipients, it is possible for some addresses to fail in one delivery
1732 attempt and others to fail subsequently, giving rise to more than one bounce
1733 message. The wording of bounce messages can be customized by the administrator.
1734 See chapter ~~CHAPemsgcust for details.
1735
1736 .index ::X-Failed-Recipients:: header line
1737 Bounce messages contain an ::X-Failed-Recipients:: header line that lists the
1738 failed addresses, for the benefit of programs that try to analyse such messages
1739 automatically.
1740
1741 .index bounce message||recipient of
1742 A bounce message is normally sent to the sender of the original message, as
1743 obtained from the message's envelope. For incoming SMTP messages, this is the
1744 address given in the \\MAIL\\ command. However, when an address is
1745 expanded via a forward or alias file, an alternative address can be specified
1746 for delivery failures of the generated addresses. For a mailing list expansion
1747 (see section ~~SECTmailinglists) it is common to direct bounce messages to the
1748 manager of the list.
1749
1750
1751
1752 .section Failures to deliver bounce messages
1753 .index bounce message||failure to deliver
1754 If a bounce message (either locally generated or received from a remote host)
1755 itself suffers a permanent delivery failure, the message is left on the queue,
1756 but it is frozen, awaiting the attention of an administrator. There are options
1757 which can be used to make Exim discard such failed messages, or to keep them
1758 for only a short time (see \timeout@_frozen@_after\ and
1759 \ignore@_bounce@_errors@_after\).
1760
1761
1762
1763 .
1764 .
1765 .
1766 .
1767 . ============================================================================
1768 .chapter Building and installing Exim
1769 .set runningfoot "building/installing"
1770
1771 .index building Exim
1772 .section Unpacking
1773 Exim is distributed as a gzipped or bzipped tar file which, when upacked,
1774 creates a directory with the name of the current release (for example,
1775 \(exim-~~version)\) into which the following files are placed:
1776 .display rm
1777 .if !~~sys.fancy && ~~sgcal
1778 .tabs 16
1779 .else
1780 .tabs 22
1781 .fi
1782 \(ACKNOWLEDGMENTS)\ $t contains some acknowledgments
1783 .newline
1784 \(CHANGES)\      $t contains a reference to where changes are documented
1785 \(LICENCE)\      $t the GNU General Public Licence
1786 \(Makefile)\     $t top-level make file
1787 \(NOTICE)\       $t conditions for the use of Exim
1788 \(README)\       $t list of files, directories and simple build instructions
1789 .endd
1790 Other files whose names begin with \(README)\ may also be present. The
1791 following subdirectories are created:
1792 .display rm
1793 .if !~~sys.fancy && ~~sgcal
1794 .tabs 16
1795 .else
1796 .tabs 22
1797 .fi
1798 \(Local)\        $t an empty directory for local configuration files
1799 \(OS)\           $t OS-specific files
1800 \(doc)\          $t documentation files
1801 \(exim@_monitor)\$t source files for the Exim monitor
1802 \(scripts)\      $t scripts used in the build process
1803 \(src)\          $t remaining source files
1804 \(util)\         $t independent utilities
1805 .endd
1806 The main utility programs are contained in the \(src)\ directory, and are built
1807 with the Exim binary. The \(util)\ directory contains a few optional scripts
1808 that may be useful to some sites.
1809
1810 .section Multiple machine architectures and operating systems
1811 .index building Exim||multiple OS/architectures
1812 The building process for Exim is arranged to make it easy to build binaries for
1813 a number of different architectures and operating systems from the same set of
1814 source files. Compilation does not take place in the \(src)\ directory. Instead,
1815 a \*build directory*\ is created for each architecture and operating system.
1816 .index symbolic link||to build directory
1817 Symbolic links to the sources are installed in this directory, which is where
1818 the actual building takes place.
1819
1820 In most cases, Exim can discover the machine architecture and operating system
1821 for itself, but the defaults can be overridden if necessary.
1822
1823 .section DBM libraries
1824 .rset SECTdb "~~chapter.~~section"
1825 .index DBM||libraries, discussion of
1826 .index hints database||DBM files used for
1827 Even if you do not use any DBM files in your configuration, Exim still needs a
1828 DBM library in order to operate, because it uses indexed files for its hints
1829 databases. Unfortunately, there are a number of DBM libraries in existence, and
1830 different operating systems often have different ones installed.
1831
1832 .index Solaris||DBM library for
1833 .index IRIX, DBM library for
1834 .index BSD, DBM library for
1835 .index Linux, DBM library for
1836 If you are using Solaris, IRIX, one of the modern BSD systems, or a modern
1837 Linux distribution, the DBM configuration should happen automatically, and you
1838 may be able to ignore this section. Otherwise, you may have to learn more than
1839 you would like about DBM libraries from what follows.
1840
1841 .index \*ndbm*\ DBM library
1842 Licensed versions of Unix normally contain a library of DBM functions operating
1843 via the \*ndbm*\ interface, and this is what Exim expects by default. Free
1844 versions of Unix seem to vary in what they contain as standard. In particular,
1845 some early versions of Linux have no default DBM library, and different
1846 distributors have chosen to bundle different libraries with their packaged
1847 versions. However, the more recent releases seem to have standardised on the
1848 Berkeley DB library.
1849
1850 Different DBM libraries have different conventions for naming the files they
1851 use. When a program opens a file called \(dbmfile)\, there are four
1852 possibilities:
1853 .numberpars
1854 A traditional \*ndbm*\ implementation, such as that supplied as part of
1855 Solaris, operates on two files called \(dbmfile.dir)\ and \(dbmfile.pag)\.
1856 .nextp
1857 .index \*gdbm*\ DBM library
1858 The GNU library, \*gdbm*\, operates on a single file. If used via its \*ndbm*\
1859 compatibility interface it makes two different hard links to it with names
1860 \(dbmfile.dir)\ and \(dbmfile.pag)\, but if used via its native interface, the
1861 file name is used unmodified.
1862 .nextp
1863 .index Berkeley DB library
1864 The Berkeley DB package, if called via its \*ndbm*\ compatibility interface,
1865 operates on a single file called \(dbmfile.db)\, but otherwise looks to the
1866 programmer exactly the same as the traditional \*ndbm*\ implementation.
1867 .nextp
1868 If the Berkeley package is used in its native mode, it operates on a single
1869 file called \(dbmfile)\; the programmer's interface is somewhat different to
1870 the traditional \*ndbm*\ interface.
1871 .nextp
1872 To complicate things further, there are several very different versions of the
1873 Berkeley DB package. Version 1.85 was stable for a very long time, releases
1874 2.$it{x} and 3.$it{x} were current for a while, but the latest versions are now
1875 numbered 4.$it{x}. Maintenance of some of the earlier releases has ceased. All
1876 versions of Berkeley DB can be obtained from
1877 .display rm
1878 \?http://www.sleepycat.com/?\
1879 .endd
1880 .nextp
1881 .index \*tdb*\ DBM library
1882 Yet another DBM library, called \*tdb*\, has become available from
1883 .display rm
1884 \?http://download.sourceforge.net/tdb?\
1885 .endd
1886 It has its own interface, and also operates on a single file.
1887 .endp
1888 .index \\USE@_DB\\
1889 .index DBM||libraries, configuration for building
1890 Exim and its utilities can be compiled to use any of these interfaces. In order
1891 to use any version of the Berkeley DB package in native mode, you must set
1892 \\USE@_DB\\ in an appropriate configuration file (typically
1893 \(Local/Makefile)\). For example:
1894 .display asis
1895 USE_DB=yes
1896 .endd
1897 Similarly, for gdbm you set \\USE@_GDBM\\, and for tdb you set \\USE@_TDB\\. An
1898 error is diagnosed if you set more than one of these.
1899
1900 At the lowest level, the build-time configuration sets none of these options,
1901 thereby assuming an interface of type (1). However, some operating system
1902 configuration files (for example, those for the BSD operating systems and
1903 Linux) assume type (4) by setting \\USE@_DB\\ as their default, and the
1904 configuration files for Cygwin set \\USE@_GDBM\\. Anything you set in
1905 \(Local/Makefile)\, however, overrides these system defaults.
1906
1907 As well as setting \\USE@_DB\\, \\USE@_GDBM\\, or \\USE@_TDB\\, it may also be
1908 necessary to set \\DBMLIB\\, to cause inclusion of the appropriate library, as
1909 in one of these lines:
1910 .display asis
1911 DBMLIB = -ldb
1912 DBMLIB = -ltdb
1913 .endd
1914 Settings like that will work if the DBM library is installed in the standard
1915 place. Sometimes it is not, and the library's header file may also not be in
1916 the default path. You may need to set \\INCLUDE\\ to specify where the header
1917 file is, and to specify the path to the library more fully in \\DBMLIB\\, as in
1918 this example:
1919 .display asis
1920 INCLUDE=-I/usr/local/include/db-4.1
1921 DBMLIB=/usr/local/lib/db-4.1/libdb.a
1922 .endd
1923
1924 There is further detailed discussion about the various DBM libraries in the
1925 file \(doc/dbm.discuss.txt)\ in the Exim distribution.
1926
1927
1928 .section Pre-building configuration
1929 .index building Exim||pre-building configuration
1930 .index configuration for building Exim
1931 .index \(Local/Makefile)\
1932 .index \(src/EDITME)\
1933 Before building Exim, a local configuration file that specifies options
1934 independent of any operating system has to be created with the name
1935 \(Local/Makefile)\. A template for this file is supplied as the file
1936 \(src/EDITME)\, and it contains full descriptions of all the option settings
1937 therein. These descriptions are therefore not repeated here. If you are
1938 building Exim for the first time, the simplest thing to do is to copy
1939 \(src/EDITME)\ to \(Local/Makefile)\, then read it and edit it appropriately.
1940
1941 There are three settings that you must supply, because Exim will not build
1942 without them. They are the location of the run time configuration file
1943 (\\CONFIGURE@_FILE\\), the directory in which Exim binaries will be installed
1944 (\\BIN@_DIRECTORY\\), and the identity of the Exim user (\\EXIM@_USER\\ and
1945 maybe \\EXIM@_GROUP\\ as well). The value of \\CONFIGURE@_FILE\\ can in fact be
1946 a colon-separated list of file names; Exim uses the first of them that exists.
1947
1948 There are a few other parameters that can be specified either at build time or
1949 at run time, to enable the same binary to be used on a number of different
1950 machines. However, if the locations of Exim's spool directory and log file
1951 directory (if not within the spool directory) are fixed, it is recommended that
1952 you specify them in \(Local/Makefile)\ instead of at run time, so that errors
1953 detected early in Exim's execution (such as a malformed configuration file) can
1954 be logged.
1955
1956 .index content scanning||specifying at build time
1957 .em
1958 Exim's interfaces for calling virus and spam scanning sofware directly from 
1959 access control lists are not compiled by default. If you want to include these 
1960 facilities, you need to set
1961 .display asis
1962 WITH_CONTENT_SCAN=yes
1963 .endd
1964 in your \(Local/Makefile)\. For details of the facilities themselves, see 
1965 chapter ~~CHAPexiscan.
1966 .nem
1967
1968 .index \(Local/eximon.conf)\
1969 .index \(exim@_monitor/EDITME)\
1970 If you are going to build the Exim monitor, a similar configuration process is
1971 required. The file \(exim@_monitor/EDITME)\ must be edited appropriately for
1972 your installation and saved under the name \(Local/eximon.conf)\. If you are
1973 happy with the default settings described in \(exim@_monitor/EDITME)\,
1974 \(Local/eximon.conf)\ can be empty, but it must exist.
1975
1976 This is all the configuration that is needed in straightforward cases for known
1977 operating systems. However, the building process is set up so that it is easy
1978 to override options that are set by default or by operating-system-specific
1979 configuration files, for example to change the name of the C compiler, which
1980 defaults to \gcc\. See section ~~SECToverride below for details of how to do
1981 this.
1982
1983
1984 .section Support for iconv()
1985 .index \*iconv()*\ support
1986 The contents of header lines in messages may be encoded according to the rules
1987 described RFC 2047. This makes it possible to transmit characters that are not
1988 in the ASCII character set, and to label them as being in a particular
1989 character set. When Exim is inspecting header lines by means of the \@$h@_\
1990 mechanism, it decodes them, and translates them into a specified character set
1991 (default ISO-8859-1). The translation is possible only if the operating system
1992 supports the \*iconv()*\ function.
1993
1994 However, some of the operating systems that supply \*iconv()*\ do not support
1995 very many conversions. The GNU \libiconv\ library (available from
1996 \?http:/@/www.gnu.org/software/libiconv/?\) can be installed on such systems to
1997 remedy this deficiency, as well as on systems that do not supply \*iconv()*\ at
1998 all. After installing \libiconv\, you should add
1999 .display asis
2000 HAVE_ICONV=yes
2001 .endd
2002 to your \(Local/Makefile)\ and rebuild Exim.
2003
2004
2005 .section Including TLS/SSL encryption support
2006 .rset SECTinctlsssl "~~chapter.~~section"
2007 .index TLS||including support for TLS
2008 .index encryption||including support for
2009 .index \\SUPPORT@_TLS\\
2010 .index OpenSSL||building Exim with
2011 .index GnuTLS||building Exim with
2012 Exim can be built to support encrypted SMTP connections, using the \\STARTTLS\\
2013 command as per RFC 2487. It can also support legacy clients that expect to
2014 start a TLS session immediately on connection to a non-standard port (see the
2015 \tls@_on@_connect@_ports\ runtime option and the \-tls-on-connect-\ command
2016 line option).
2017
2018 If you want to build Exim with TLS support, you must first install either the
2019 OpenSSL or GnuTLS library. There is no cryptographic code in Exim itself for
2020 implementing SSL.
2021
2022 If OpenSSL is installed, you should set
2023 .display asis
2024 SUPPORT_TLS=yes
2025 TLS_LIBS=-lssl -lcrypto
2026 .endd
2027 in \(Local/Makefile)\. You may also need to specify the locations of the
2028 OpenSSL library and include files. For example:
2029 .display asis
2030 SUPPORT_TLS=yes
2031 TLS_LIBS=-L/usr/local/openssl/lib -lssl -lcrypto
2032 TLS_INCLUDE=-I/usr/local/openssl/include/
2033 .endd
2034
2035 If GnuTLS is installed, you should set
2036 .index \\USE@_GNUTLS\\
2037 .display asis
2038 SUPPORT_TLS=yes
2039 USE_GNUTLS=yes
2040 TLS_LIBS=-lgnutls -ltasn1 -lgcrypt
2041 .endd
2042 in \(Local/Makefile)\, and again you may need to specify the locations of the
2043 library and include files. For example:
2044 .display asis
2045 SUPPORT_TLS=yes
2046 USE_GNUTLS=yes
2047 TLS_LIBS=-L/usr/gnu/lib -lgnutls -ltasn1 -lgcrypt
2048 TLS_INCLUDE=-I/usr/gnu/include
2049 .endd
2050 You do not need to set \\TLS@_INCLUDE\\ if the relevant directory is already
2051 specified in \\INCLUDE\\. Details of how to configure Exim to make use of TLS
2052 are given in chapter ~~CHAPTLS.
2053
2054
2055
2056 .section Use of tcpwrappers
2057 .index tcpwrappers, building Exim to support
2058 .index \\USE@_TCP@_WRAPPERS\\
2059 Exim can be linked with the \*tcpwrappers*\ library in order to check incoming
2060 SMTP calls using the \*tcpwrappers*\ control files. This may be a convenient
2061 alternative to Exim's own checking facilities for installations that are
2062 already making use of \*tcpwrappers*\ for other purposes. To do this, you should
2063 set \\USE@_TCP@_WRAPPERS\\ in \(Local/Makefile)\, arrange for the file
2064 \(tcpd.h)\ to be available at compile time, and also ensure that the library
2065 \(libwrap.a)\ is available at link time, typically by including \-lwrap-\ in
2066 \\EXTRALIBS@_EXIM\\. For example, if \*tcpwrappers*\ is installed in
2067 \(/usr/local)\, you might have
2068 .display
2069 USE@_TCP@_WRAPPERS=yes
2070 CFLAGS=-O -I/usr/local/include
2071 .newline
2072 EXTRALIBS@_EXIM=-L/usr/local/lib -lwrap
2073 .endd
2074 in \(Local/Makefile)\. The name to use in the \*tcpwrappers*\ control files is
2075 `exim'. For example, the line
2076 .display
2077 exim : LOCAL  192.168.1.  .friendly.domain.example
2078 .endd
2079 in your \(/etc/hosts.allow)\ file allows connections from the local host, from
2080 the subnet 192.168.1.0/24, and from all hosts in \*friendly.domain.example*\.
2081 All other connections are denied. Consult the \*tcpwrappers*\ documentation for
2082 further details.
2083
2084
2085 .section Including support for IPv6
2086 .index IPv6||including support for
2087 Exim contains code for use on systems that have IPv6 support. Setting
2088 \\HAVE@_IPV6=YES\\ in \(Local/Makefile)\ causes the IPv6 code to be included;
2089 it may also be necessary to set \\IPV6@_INCLUDE\\ and \\IPV6@_LIBS\\ on systems
2090 where the IPv6 support is not fully integrated into the normal include and
2091 library files.
2092
2093 .em
2094 Two different types of DNS record for handling IPv6 addresses have been
2095 defined. AAAA records (analagous to A records for IPv4) are in use, and are
2096 currently seen as the mainstream. Another record type called A6 was proposed
2097 as better than AAAA because it had more flexibility. However, it was felt to
2098 be over-complex, and its status was reduced to `experimental'. It is not known
2099 if anyone is actually using A6 records. Exim has support for A6 records, but
2100 this is included only if you set \\SUPPORT@_A6=YES\\ in \(Local/Makefile)\. The
2101 support has not been tested for some time.
2102 .nem
2103
2104 .section The building process
2105 .index build directory
2106 Once \(Local/Makefile)\ (and \(Local/eximon.conf)\, if required) have been
2107 created, run \*make*\ at the top level. It determines the architecture and
2108 operating system types, and creates a build directory if one does not exist.
2109 For example, on a Sun system running Solaris 8, the directory
2110 \(build-SunOS5-5.8-sparc)\ is created.
2111 .index symbolic link||to source files
2112 Symbolic links to relevant source files are installed in the build directory.
2113
2114 \**Warning**\: The \-j-\ (parallel) flag must not be used with \*make*\; the
2115 building process fails if it is set.
2116
2117 If this is the first time \*make*\ has been run, it calls a script that builds
2118 a make file inside the build directory, using the configuration files from the
2119 \(Local)\ directory. The new make file is then passed to another instance of
2120 \*make*\. This does the real work, building a number of utility scripts, and
2121 then compiling and linking the binaries for the Exim monitor (if configured), a
2122 number of utility programs, and finally Exim itself. The command \*make
2123 makefile*\ can be used to force a rebuild of the make file in the build
2124 directory, should this ever be necessary.
2125
2126 If you have problems building Exim, check for any comments there may be in the
2127 \(README)\ file concerning your operating system, and also take a look at the
2128 .if ~~html
2129 [(A HREF="FAQ.html")]
2130 .fi
2131 FAQ,
2132 .if ~~html
2133 [(/A)]
2134 .fi
2135 where some common problems are covered.
2136
2137
2138
2139 .section Overriding build-time options for Exim
2140 .index build-time options, overriding
2141 .rset SECToverride "~~chapter.~~section"
2142 The main make file that is created at the beginning of the building process
2143 consists of the concatenation of a number of files which set configuration
2144 values, followed by a fixed set of \*make*\ instructions. If a value is set
2145 more than once, the last setting overrides any previous ones. This provides a
2146 convenient way of overriding defaults. The files that are concatenated are, in
2147 order:
2148 .display rm
2149 \(OS/Makefile-Default)\
2150 \(OS/Makefile-)\<<ostype>>
2151 \(Local/Makefile)\
2152 \(Local/Makefile-)\<<ostype>>
2153 \(Local/Makefile-)\<<archtype>>
2154 \(Local/Makefile-)\<<ostype>>-<<archtype>>
2155 \(OS/Makefile-Base)\
2156 .endd
2157 .index \(Local/Makefile)\
2158 where <<ostype>> is the operating system type and <<archtype>> is the
2159 .index building Exim||operating system type
2160 .index building Exim||architecture type
2161 architecture type. \(Local/Makefile)\ is required to exist, and the building
2162 process fails if it is absent. The other three \(Local)\ files are optional,
2163 and are often not needed.
2164
2165 The values used for <<ostype>> and <<archtype>> are obtained from scripts
2166 called \(scripts/os-type)\ and \(scripts/arch-type)\ respectively. If either of
2167 the environment variables \\EXIM@_OSTYPE\\ or \\EXIM@_ARCHTYPE\\ is set, their
2168 values are used, thereby providing a means of forcing particular settings.
2169 Otherwise, the scripts try to get values from the \uname\ command. If this
2170 fails, the shell variables \\OSTYPE\\ and \\ARCHTYPE\\ are inspected. A number
2171 of $it{ad hoc} transformations are then applied, to produce the standard names
2172 that Exim expects. You can run these scripts directly from the shell in order
2173 to find out what values are being used on your system.
2174
2175
2176 \(OS/Makefile-Default)\ contains comments about the variables that are set
2177 therein. Some (but not all) are mentioned below. If there is something that
2178 needs changing, review the contents of this file and the contents of the make
2179 file for your operating system (\(OS/Makefile-<<ostype>>)\) to see what the
2180 default values are.
2181
2182
2183 .index building Exim||overriding default settings
2184 If you need to change any of the values that are set in \(OS/Makefile-Default)\
2185 or in \(OS/Makefile-<<ostype>>)\, or to add any new definitions, you do not
2186 need to change the original files. Instead, you should make the changes by
2187 putting the new values in an appropriate \(Local)\ file. For example,
2188 .index Tru64-Unix build-time settings
2189 when building Exim in many releases of the Tru64-Unix (formerly Digital UNIX,
2190 formerly DEC-OSF1) operating system, it is necessary to specify that the C
2191 compiler is called \*cc*\ rather than \*gcc*\. Also, the compiler must be
2192 called with the option \-std1-\, to make it recognize some of the features of
2193 Standard C that Exim uses. (Most other compilers recognize Standard C by
2194 default.) To do this, you should create a file called \(Local/Makefile-OSF1)\
2195 containing the lines
2196 .display
2197 CC=cc
2198 CFLAGS=-std1
2199 .endd
2200 If you are compiling for just one operating system, it may be easier to put
2201 these lines directly into \(Local/Makefile)\.
2202
2203 Keeping all your local configuration settings separate from the distributed
2204 files makes it easy to transfer them to new versions of Exim simply by copying
2205 the contents of the \(Local)\ directory.
2206
2207
2208 .index NIS lookup type||including support for
2209 .index NIS@+ lookup type||including support for
2210 .index LDAP||including support for
2211 .index lookup||inclusion in binary
2212 Exim contains support for doing LDAP, NIS, NIS+, and other kinds of file
2213 lookup, but not all systems have these components installed, so the default is
2214 not to include the relevant code in the binary. All the different kinds of file
2215 and database lookup that Exim supports are implemented as separate code modules
2216 which are included only if the relevant compile-time options are set. In the
2217 case of LDAP, NIS, and NIS+, the settings for \(Local/Makefile)\ are:
2218 .display asis
2219 LOOKUP_LDAP=yes
2220 LOOKUP_NIS=yes
2221 LOOKUP_NISPLUS=yes
2222 .endd
2223 and similar settings apply to the other lookup types. They are all listed in
2224 \(src/EDITME)\. In most cases the relevant include files and interface
2225 libraries need to be installed before compiling Exim.
2226 .index cdb||including support for
2227 However, in the case of cdb, which is included in the binary only if
2228 .display asis
2229 LOOKUP_CDB=yes
2230 .endd
2231 is set, the code is entirely contained within Exim, and no external include
2232 files or libraries are required. When a lookup type is not included in the
2233 binary, attempts to configure Exim to use it cause run time configuration
2234 errors.
2235
2236 .index Perl||including support for
2237 Exim can be linked with an embedded Perl interpreter, allowing Perl
2238 subroutines to be called during string expansion. To enable this facility,
2239 .display asis
2240 EXIM_PERL=perl.o
2241 .endd
2242 must be defined in \(Local/Makefile)\. Details of this facility are given in
2243 chapter ~~CHAPperl.
2244
2245 .index X11 libraries, location of
2246 The location of the X11 libraries is something that varies a lot between
2247 operating systems, and of course there are different versions of X11 to cope
2248 with. Exim itself makes no use of X11, but if you are compiling the Exim
2249 monitor, the X11 libraries must be available.
2250 The following three variables are set in \(OS/Makefile-Default)\:
2251 .display asis
2252 X11=/usr/X11R6
2253 XINCLUDE=-I$(X11)/include
2254 XLFLAGS=-L$(X11)/lib
2255 .endd
2256 These are overridden in some of the operating-system configuration files. For
2257 example, in \(OS/Makefile-SunOS5)\ there is
2258 .display asis
2259 X11=/usr/openwin
2260 XINCLUDE=-I$(X11)/include
2261 XLFLAGS=-L$(X11)/lib -R$(X11)/lib
2262 .endd
2263 If you need to override the default setting for your operating system, place a
2264 definition of all three of these variables into your
2265 \(Local/Makefile-<<ostype>>)\ file.
2266
2267 .index \\EXTRALIBS\\
2268 If you need to add any extra libraries to the link steps, these can be put in a
2269 variable called \\EXTRALIBS\\, which appears in all the link commands, but by
2270 default is not defined. In contrast, \\EXTRALIBS@_EXIM\\ is used only on the
2271 command for linking the main Exim binary, and not for any associated utilities.
2272 .index DBM||libraries, configuration for building
2273 There is also \\DBMLIB\\, which appears in the link commands for binaries that
2274 use DBM functions (see also section ~~SECTdb). Finally, there is
2275 \\EXTRALIBS@_EXIMON\\, which appears only in the link step for the Exim monitor
2276 binary, and which can be used, for example, to include additional X11
2277 libraries.
2278
2279 .index configuration file||editing
2280 The make file copes with rebuilding Exim correctly if any of the configuration
2281 files are edited. However, if an optional configuration file is deleted, it is
2282 necessary to touch the associated non-optional file (that is, \(Local/Makefile)\
2283 or \(Local/eximon.conf)\) before rebuilding.
2284
2285 .section OS-specific header files
2286 .index \(os.h)\
2287 .index building Exim||OS-specific C header files
2288 The \(OS)\ directory contains a number of files with names of the form
2289 \(os.h-<<ostype>>)\. These are system-specific C header files that should not
2290 normally need to be changed. There is a list of macro settings that are
2291 recognized in the file \(OS/os.configuring)\, which should be consulted if you
2292 are porting Exim to a new operating system.
2293
2294
2295 .section Overriding build-time options for the monitor
2296 .index building Eximon||overriding default options
2297 A similar process is used for overriding things when building the Exim monitor,
2298 where the files that are involved are
2299 .display rm
2300 \(OS/eximon.conf-Default)\
2301 \(OS/eximon.conf-)\<<ostype>>
2302 \(Local/eximon.conf)\
2303 \(Local/eximon.conf-)\<<ostype>>
2304 \(Local/eximon.conf-)\<<archtype>>
2305 \(Local/eximon.conf-)\<<ostype>>-<<archtype>>
2306 .endd
2307 .index \(Local/eximon.conf)\
2308 As with Exim itself, the final three files need not exist, and in this case the
2309 \(OS/eximon.conf-<<ostype>>)\ file is also optional. The default values in
2310 \(OS/eximon.conf-Default)\ can be overridden dynamically by setting environment
2311 variables of the same name, preceded by \\EXIMON@_\\. For example, setting
2312 \\EXIMON@_LOG@_DEPTH\\ in the environment overrides the value of
2313 \\LOG@_DEPTH\\ at run time.
2314
2315
2316
2317 .section Installing Exim binaries and scripts
2318 .index installing Exim
2319 .index \\BIN@_DIRECTORY\\
2320 The command \*make install*\ runs the \*exim@_install*\ script with no
2321 arguments. The script copies binaries and utility scripts into the directory
2322 whose name is specified by the \\BIN@_DIRECTORY\\ setting in
2323 \(Local/Makefile)\.
2324
2325 Exim's run time configuration file is named by the \\CONFIGURE@_FILE\\ setting
2326 .index \\CONFIGURE@_FILE\\
2327 in \(Local/Makefile)\. If this names a single file, and the file does not
2328 exist, the default configuration file \(src/configure.default)\ is copied there
2329 by the installation script. If a run time configuration file already exists, it
2330 is left alone. If \\CONFIGURE@_FILE\\ is a colon-separated list, naming several
2331 alternative files, no default is installed.
2332
2333 .index system aliases file
2334 .index \(/etc/aliases)\
2335 One change is made to the default configuration file when it is installed: the
2336 default configuration contains a router that references a system aliases file.
2337 The path to this file is set to the value specified by
2338 \\SYSTEM@_ALIASES@_FILE\\ in \(Local/Makefile)\ (\(/etc/aliases)\ by default).
2339 If the system aliases file does not exist, the installation script creates it,
2340 and outputs a comment to the user.
2341
2342 The created file contains no aliases, but it does contain comments about the
2343 aliases a site should normally have. Mail aliases have traditionally been
2344 kept in \(/etc/aliases)\. However, some operating systems are now using
2345 \(/etc/mail/aliases)\. You should check if yours is one of these, and change
2346 Exim's configuration if necessary.
2347
2348 The default configuration uses the local host's name as the only local domain,
2349 and is set up to do local deliveries into the shared directory \(/var/mail)\,
2350 running as the local user. System aliases and \(.forward)\ files in users' home
2351 directories are supported, but no NIS or NIS+ support is configured. Domains
2352 other than the name of the local host are routed using the DNS, with delivery
2353 over SMTP.
2354
2355 The install script copies files only if they are newer than the files they are
2356 going to replace. The Exim binary is required to be owned by root and have the
2357 \*setuid*\ bit set,
2358 .index setuid||installing Exim with
2359 for normal configurations. Therefore, you must run \*make install*\ as root so
2360 that it can set up the Exim binary in this way. However, in some special
2361 situations (for example, if a host is doing no local deliveries) it may be
2362 possible to run Exim without making the binary setuid root (see chapter
2363 ~~CHAPsecurity for details).
2364
2365 It is possible to install Exim for special purposes (such as building a binary
2366 distribution) in a private part of the file system. You can do this by a
2367 command such as
2368 .display asis
2369 make DESTDIR=/some/directory/ install
2370 .endd
2371 This has the effect of pre-pending the specified directory to all the file
2372 paths, except the name of the system aliases file that appears in the default
2373 configuration. (If a default alias file is created, its name \*is*\ modified.)
2374 For backwards compatibility, \\ROOT\\ is used if \\DESTDIR\\ is not set,
2375 but this usage is deprecated.
2376
2377 .index installing Exim||what is not installed
2378 Running \*make install*\ does not copy the Exim 4 conversion script
2379 \*convert4r4*\, or the \*pcretest*\ test program. You will probably run the
2380 first of these only once (if you are upgrading from Exim 3), and the second
2381 isn't really part of Exim. None of the documentation files in the \(doc)\
2382 directory are copied, except for the info files when you have set
2383 \\INFO@_DIRECTORY\\, as described in section ~~SECTinsinfdoc below.
2384
2385 For the utility programs, old versions are renamed by adding the suffix \(.O)\
2386 to their names. The Exim binary itself, however, is handled differently. It is
2387 installed under a name that includes the version number and the compile number,
2388 for example \(exim-~~version-1)\. The script then arranges for a symbolic link
2389 called \(exim)\ to point to the binary. If you are updating a previous version
2390 of Exim, the script takes care to ensure that the name \(exim)\ is never absent
2391 from the directory (as seen by other processes).
2392
2393 .index installing Exim||testing the script
2394 If you want to see what the \*make install*\ will do before running it for
2395 real, you can pass the \-n-\ option to the installation script by this command:
2396 .display asis
2397 make INSTALL_ARG=-n install
2398 .endd
2399 The contents of the variable \\INSTALL@_ARG\\ are passed to the installation
2400 script. You do not need to be root to run this test. Alternatively, you can run
2401 the installation script directly, but this must be from within the build
2402 directory. For example, from the top-level Exim directory you could use this
2403 command:
2404 .display
2405 (cd build-SunOS5-5.5.1-sparc; ../scripts/exim@_install -n)
2406 .endd
2407
2408 .index installing Exim||install script options
2409 There are two other options that can be supplied to the installation script.
2410 .numberpars $.
2411 \-no@_chown-\ bypasses the call to change the owner of the installed binary
2412 to root, and the call to make it a setuid binary.
2413 .nextp
2414 \-no@_symlink-\ bypasses the setting up of the symbolic link \(exim)\ to the
2415 installed binary.
2416 .endp
2417 \\INSTALL@_ARG\\ can be used to pass these options to the script. For example:
2418 .display asis
2419 make INSTALL_ARG=-no_symlink install
2420 .endd
2421
2422 The installation script can also be given arguments specifying which files are
2423 to be copied. For example, to install just the Exim binary, and nothing else,
2424 without creating the symbolic link, you could use:
2425 .display asis
2426 make INSTALL_ARG='-no_symlink exim' install
2427 .endd
2428
2429
2430 .section Installing info documentation
2431 .rset SECTinsinfdoc "~~chapter.~~section"
2432 .index installing Exim||\*info*\ documentation
2433 Not all systems use the GNU \*info*\ system for documentation, and for this
2434 reason, the Texinfo source of Exim's documentation is not included in the main
2435 distribution. Instead it is available separately from the ftp site (see section
2436 ~~SECTavail).
2437
2438 If you have defined \\INFO@_DIRECTORY\\ in \(Local/Makefile)\ and the Texinfo
2439 source of the documentation is found in the source tree, running \*make
2440 install*\ automatically builds the info files and installs them.
2441
2442
2443 .section Setting up the spool directory
2444 .index spool directory||creating
2445 When it starts up, Exim tries to create its spool directory if it does not
2446 exist. The Exim uid and gid are used for the owner and group of the spool
2447 directory. Sub-directories are automatically created in the spool directory as
2448 necessary.
2449
2450
2451
2452 .section Testing
2453 .index testing||installation
2454 Having installed Exim, you can check that the run time configuration file is
2455 syntactically valid by running the following command, which assumes that the
2456 Exim binary directory is within your \\PATH\\ environment variable:
2457 .display
2458 exim -bV
2459 .endd
2460 If there are any errors in the configuration file, Exim outputs error messages.
2461 Otherwise it outputs the version number and build date,
2462 the DBM library that is being used, and information about which drivers and
2463 other optional code modules are included in the binary.
2464 Some simple routing tests can be done by using the address testing option. For
2465 example,
2466 .display
2467 exim -bt <<local username>>
2468 .endd
2469 should verify that it recognizes a local mailbox, and
2470 .display
2471 exim -bt <<remote address>>
2472 .endd
2473 a remote one. Then try getting it to deliver mail, both locally and remotely.
2474 This can be done by passing messages directly to Exim, without going through a
2475 user agent. For example:
2476 .display
2477 exim -v postmaster@@your.domain.example
2478 From: user@@your.domain.example
2479 To: postmaster@@your.domain.example
2480 Subject: Testing Exim
2481
2482 This is a test message.
2483 ^D
2484 .endd
2485 The \-v-\ option causes Exim to output some verification of what it is doing.
2486 In this case you should see copies of three log lines, one for the message's
2487 arrival, one for its delivery, and one containing `Completed'.
2488
2489 .index delivery||problems with
2490 If you encounter problems, look at Exim's log files (\*mainlog*\ and
2491 \*paniclog*\) to see if there is any relevant information there. Another source
2492 of information is running Exim with debugging turned on, by specifying the
2493 \-d-\ option. If a message is stuck on Exim's spool, you can force a delivery
2494 with debugging turned on by a command of the form
2495 .display
2496 exim -d -M <<message-id>>
2497 .endd
2498 You must be root or an `admin user' in order to do this. The \-d-\ option
2499 produces rather a lot of output, but you can cut this down to specific areas.
2500 For example, if you use \-d-all+route-\ only the debugging information relevant
2501 to routing is included. (See the \-d-\ option in chapter ~~CHAPcommandline for
2502 more details.)
2503
2504 .index `sticky' bit
2505 .index lock files
2506 One specific problem that has shown up on some sites is the inability to do
2507 local deliveries into a shared mailbox directory, because it does not have the
2508 `sticky bit' set on it. By default, Exim tries to create a lock file before
2509 writing to a mailbox file, and if it cannot create the lock file, the delivery
2510 is deferred. You can get round this either by setting the `sticky bit' on the
2511 directory, or by setting a specific group for local deliveries and allowing
2512 that group to create files in the directory (see the comments above the
2513 \%local@_delivery%\ transport in the default configuration file). Another
2514 approach is to configure Exim not to use lock files, but just to rely on
2515 \*fcntl()*\ locking instead. However, you should do this only if all user
2516 agents also use \*fcntl()*\ locking. For further discussion of locking issues,
2517 see chapter ~~CHAPappendfile.
2518
2519 One thing that cannot be tested on a system that is already running an MTA is
2520 the receipt of incoming SMTP mail on the standard SMTP port. However, the
2521 \-oX-\ option can be used to run an Exim daemon that listens on some other
2522 port, or \*inetd*\ can be used to do this. The \-bh-\ option and the
2523 \*exim@_checkaccess*\ utility can be used to check out policy controls on
2524 incoming SMTP mail.
2525
2526 Testing a new version on a system that is already running Exim can most easily
2527 be done by building a binary with a different \\CONFIGURE@_FILE\\ setting. From
2528 within the run time configuration, all other file and directory names
2529 that Exim uses can be altered, in order to keep it entirely clear of the
2530 production version.
2531
2532 .section Replacing another MTA with Exim
2533 .index replacing another MTA
2534 Building and installing Exim for the first time does not of itself put it in
2535 general use. The name by which the system's MTA is called by mail user agents
2536 is either \(/usr/sbin/sendmail)\, or \(/usr/lib/sendmail)\ (depending on the
2537 operating system), and it is necessary to make this name point to the \*exim*\
2538 binary in order to get the user agents to pass messages to Exim. This is
2539 normally done by renaming any existing file and making \(/usr/sbin/sendmail)\
2540 or \(/usr/lib/sendmail)\
2541 .index symbolic link||to \*exim*\ binary
2542 a symbolic link to the \*exim*\ binary. It is a good idea to remove any setuid
2543 privilege and executable status from the old MTA. It is then necessary to stop
2544 and restart the mailer daemon, if one is running.
2545
2546 .index FreeBSD, MTA indirection
2547 .index \(/etc/mail/mailer.conf)\
2548 Some operating systems have introduced alternative ways of switching MTAs. For
2549 example, if you are running FreeBSD, you need to edit the file
2550 \(/etc/mail/mailer.conf)\ instead of setting up a symbolic link as just
2551 described. A typical example of the contents of this file for running Exim is
2552 as follows:
2553 .display asis
2554 sendmail            /usr/exim/bin/exim
2555 send-mail           /usr/exim/bin/exim
2556 mailq               /usr/exim/bin/exim -bp
2557 newaliases          /usr/bin/true
2558 .endd
2559
2560 Once you have set up the symbolic link, or edited \(/etc/mail/mailer.conf)\,
2561 your Exim installation is `live'. Check it by sending a message from your
2562 favourite user agent.
2563
2564 You should consider what to tell your users about the change of MTA. Exim may
2565 have different capabilities to what was previously running, and there are
2566 various operational differences such as the text of messages produced by
2567 command line options and in bounce messages. If you allow your users to make
2568 use of Exim's filtering capabilities, you should make the document entitled
2569 .if ~~html
2570 [(A HREF="filter.html")]
2571 .fi
2572 \*Exim's interface to mail filtering*\
2573 .if ~~html
2574 [(/A)]
2575 .fi
2576 available to them.
2577
2578
2579 .section Upgrading Exim
2580 .index upgrading Exim
2581 If you are already running Exim on your host, building and installing a new
2582 version automatically makes it available to MUAs, or any other programs that
2583 call the MTA directly. However, if you are running an Exim daemon, you do need
2584 to send it a HUP signal, to make it re-exec itself, and thereby pick up the new
2585 binary. You do not need to stop processing mail in order to install a new
2586 version of Exim.
2587
2588
2589 .section Stopping the Exim daemon on Solaris
2590 .index Solaris||stopping Exim on
2591 The standard command for stopping the mailer daemon on Solaris is
2592 .display
2593 /etc/init.d/sendmail stop
2594 .endd
2595 If \(/usr/lib/sendmail)\ has been turned into a symbolic link, this script
2596 fails to stop Exim because it uses the command \*ps -e*\ and greps the output
2597 for the text `sendmail'; this is not present because the actual program name
2598 (that is, `exim') is given by the \*ps*\ command with these options. A solution
2599 is to replace the line that finds the process id with something like
2600 .display asis
2601 pid=`cat /var/spool/exim/exim-daemon.pid`
2602 .endd
2603 to obtain the daemon's pid directly from the file that Exim saves it in.
2604
2605 Note, however, that stopping the daemon does not `stop Exim'. Messages can
2606 still be received from local processes, and if automatic delivery is configured
2607 (the normal case), deliveries will still occur.
2608
2609
2610 .
2611 .
2612 .
2613 .
2614 . ============================================================================
2615 .chapter The Exim command line
2616 .set runningfoot "command line"
2617 .rset CHAPcommandline ~~chapter
2618 .index command line||options
2619 .index options||command line
2620
2621 Exim's command line takes the standard Unix form of a sequence of options,
2622 each starting with a hyphen character, followed by a number of arguments. The
2623 options are compatible with the main options of Sendmail, and there are also
2624 some additional options, some of which are compatible with Smail 3. Certain
2625 combinations of options do not make sense, and provoke an error if used.
2626 The form of the arguments depends on which options are set.
2627
2628 .section Setting options by program name
2629 .index \*mailq*\
2630 If Exim is called under the name \*mailq*\, it behaves as if the option \-bp-\
2631 were present before any other options.
2632 The \-bp-\ option requests a listing of the contents of the mail queue on the
2633 standard output.
2634 This feature is for compatibility with some systems that contain a command of
2635 that name in one of the standard libraries, symbolically linked to
2636 \(/usr/sbin/sendmail)\ or \(/usr/lib/sendmail)\.
2637
2638 .index \*rsmtp*\
2639 If Exim is called under the name \*rsmtp*\ it behaves as if the option \-bS-\
2640 were present before any other options, for compatibility with Smail. The \-bS-\
2641 option is used for reading in a number of messages in batched SMTP format.
2642
2643 .index \*rmail*\
2644 If Exim is called under the name \*rmail*\ it behaves as if the \-i-\ and
2645 \-oee-\ options were present before any other options, for compatibility with
2646 Smail. The name \*rmail*\ is used as an interface by some UUCP systems.
2647
2648 .index \*runq*\
2649 .index queue runner
2650 If Exim is called under the name \*runq*\ it behaves as if the option \-q-\ were
2651 present before any other options, for compatibility with Smail. The \-q-\
2652 option causes a single queue runner process to be started.
2653
2654 .index \*newaliases*\
2655 .index alias file||building
2656 .index Sendmail compatibility||calling Exim as \*newaliases*\
2657 If Exim is called under the name \*newaliases*\ it behaves as if the option
2658 \-bi-\ were present before any other options, for compatibility with Sendmail.
2659 This option is used for rebuilding Sendmail's alias file. Exim does not have
2660 the concept of a single alias file, but can be configured to run a given
2661 command if called with the \-bi-\ option.
2662
2663 .section Trusted and admin users
2664 .rset SECTtrustedadmin "~~chapter.~~section"
2665 Some Exim options are available only to \*trusted users*\ and others are
2666 available only to \*admin users*\. In the description below, the phrases `Exim
2667 user' and `Exim group' mean the user and group defined by \\EXIM@_USER\\ and
2668 \\EXIM@_GROUP\\ in \(Local/Makefile)\ or set by the \exim@_user\ and
2669 \exim@_group\ options. These do not necessarily have to use the name `exim'.
2670
2671 .numberpars $.
2672 .index trusted user||definition of
2673 .index user||trusted, definition of
2674 The trusted users are root, the Exim user, any user listed in the
2675 \trusted@_users\ configuration option, and any user whose current group or any
2676 supplementary group is one of those listed in the \trusted@_groups\
2677 configuration option. Note that the Exim group is not automatically trusted.
2678
2679 .index `From' line
2680 .index envelope sender
2681 Trusted users are always permitted to use the \-f-\ option or a leading `From '
2682 line to specify the envelope sender of a message that is passed to Exim through
2683 the local interface (see the \-bm-\ and \-f-\ options below). See the
2684 \untrusted@_set@_sender\ option for a way of permitting non-trusted users to
2685 set envelope senders.
2686 .index ::From:: header line
2687 .index ::Sender:: header line
2688 For a trusted user, there is never any check on the contents of the ::From::
2689 header line, and a ::Sender:: line is never added. Furthermore, any existing
2690 ::Sender:: line in incoming local (non-TCP/IP) messages is not removed.
2691
2692 Trusted users may also specify a host name, host address, interface address,
2693 protocol name, ident value, and authentication data when submitting a message
2694 locally. Thus, they are able to insert messages into Exim's queue locally that
2695 have the characteristics of messages received from a remote host. Untrusted
2696 users may in some circumstances use \-f-\, but can never set the other values
2697 that are available to trusted users.
2698 .nextp
2699 .index user||admin, definition of
2700 .index admin user||definition of
2701 The admin users are root, the Exim user, and any user that is a member of the
2702 Exim group or of any group listed in the \admin@_groups\ configuration option.
2703 The current group does not have to be one of these groups.
2704
2705 Admin users are permitted to list the queue, and to carry out certain
2706 operations on messages, for example, to force delivery failures. It is also
2707 necessary to be an admin user in order to see the full information provided by
2708 the Exim monitor, and full debugging output.
2709
2710 By default, the use of the \-M-\, \-q-\, \-R-\, and \-S-\ options to cause Exim
2711 to attempt delivery of messages on its queue is restricted to admin users.
2712 However, this restriction can be relaxed by setting the \prod@_requires@_admin\
2713 option false (that is, specifying \no@_prod@_requires@_admin\).
2714
2715 Similarly, the use of the \-bp-\ option to list all the messages in the queue
2716 is restricted to admin users unless \queue@_list@_requires@_admin\ is set
2717 false.
2718 .endp
2719
2720 \**Warning**\: If you configure your system so that admin users are able to
2721 edit Exim's configuration file, you are giving those users an easy way of
2722 getting root. There is further discussion of this issue at the start of chapter
2723 ~~CHAPconf.
2724
2725
2726
2727 .section Command line options
2728 The command options are described in alphabetical order below.
2729
2730 .startoptions
2731
2732 .option @-
2733 .index options||command line, terminating
2734 This is a pseudo-option whose only purpose is to terminate the options and
2735 therefore to cause subsequent command line items to be treated as arguments
2736 rather than options, even if they begin with hyphens.
2737
2738 .option -help
2739 This option causes Exim to output a few sentences stating what it is.
2740 The same output is generated if the Exim binary is called with no options and
2741 no arguments.
2742
2743 .option B <<type>>
2744 .index 8-bit characters
2745 .index Sendmail compatibility||8-bit characters
2746 This is a Sendmail option for selecting 7 or 8 bit processing. Exim is 8-bit
2747 clean; it ignores this option.
2748
2749 .option bd
2750 .index daemon
2751 .index SMTP listener
2752 .index queue runner
2753 This option runs Exim as a daemon, awaiting incoming SMTP connections. Usually
2754 the \-bd-\ option is combined with the \-q-\<<time>> option, to specify that
2755 the daemon should also initiate periodic queue runs.
2756
2757 The \-bd-\ option can be used only by an admin user. If either of the \-d-\
2758 (debugging) or \-v-\ (verifying) options are set, the daemon does not
2759 disconnect from the controlling terminal. When running this way, it can be
2760 stopped by pressing ctrl-C.
2761
2762 By default, Exim listens for incoming connections to the standard SMTP port on
2763 all the host's running interfaces. However, it is possible to listen on other
2764 ports, on multiple ports, and only on specific interfaces. Chapter
2765 ~~CHAPinterfaces contains a description of the options that control this.
2766
2767 .index daemon||process id (pid)
2768 .index pid (process id)||of daemon
2769 When a listening daemon is started without the use of \-oX-\ (that is, without
2770 overriding the normal configuration), it writes its process id to a file called
2771 \(exim-daemon.pid)\ in Exim's spool directory. This location can be overridden
2772 by setting \\PID@_FILE@_PATH\\ in \(Local/Makefile)\. The file is written while
2773 Exim is still running as root.
2774
2775 When \-oX-\ is used on the command line to start a listening daemon, the
2776 process id is not written to the normal pid file path. However, \-oP-\ can be
2777 used to specify a path on the command line if a pid file is required.
2778
2779 .index \\SIGHUP\\
2780 The \\SIGHUP\\ signal can be used to cause the daemon to re-exec itself. This
2781 should be done whenever Exim's configuration file, or any file that is
2782 incorporated into it by means of the \.include\ facility, is changed, and also
2783 whenever a new version of Exim is installed. It is not necessary to do this
2784 when other files that are referenced from the configuration (for example, alias
2785 files) are changed, because these are reread each time they are used.
2786
2787 .option bdf
2788 This option has the same effect as \-bd-\ except that it never disconnects from
2789 the controlling terminal, even when no debugging is specified.
2790
2791 .option be
2792 .index testing||string expansion
2793 .index expansion||testing
2794 Run Exim in expansion testing mode. Exim discards its root privilege, to
2795 prevent ordinary users from using this mode to read otherwise inaccessible
2796 files. If no arguments are given, Exim runs interactively, prompting for lines
2797 of data. 
2798 .em
2799 If Exim was built with \\USE@_READLINE\\=yes in \(Local/Makefile)\, it tries
2800 to load the \libreadline\ library dynamically whenever the \-be-\ option is
2801 used without command line arguments. If successful, it uses the \*readline()*\
2802 function, which provides extensive line-editing facilities, for reading the
2803 test data. A line history is supported.
2804 .nem
2805
2806 Long expansion expressions can be split over several lines by using backslash
2807 continuations. As in Exim's run time configuration, whitespace at the start of
2808 continuation lines is ignored. Each argument or data line is passed through the
2809 string expansion mechanism, and the result is output. Variable values from the
2810 configuration file (for example, \$qualify@_domain$\) are available, but no
2811 message-specific values (such as \$domain$\) are set, because no message is
2812 being processed.
2813
2814 .option bF #<<filename>>
2815 .index system filter||testing
2816 .index testing||system filter
2817 This option is the same as \-bf-\ except that it assumes that the filter being
2818 tested is a system filter. The additional commands that are available only in
2819 system filters are recognized.
2820
2821 .option bf #<<filename>>
2822 .index filter||testing
2823 .index testing||filter file
2824 .index forward file||testing
2825 .index testing||forward file
2826 .index Sieve filter||testing
2827 This option runs Exim in user filter testing mode; the file is the filter file
2828 to be tested, and a test message must be supplied on the standard input. If
2829 there are no message-dependent tests in the filter, an empty file can be
2830 supplied.
2831 .em
2832 If you want to test a system filter file, use \-bF-\ instead of \-bf-\. You can 
2833 use both \-bF-\ and \-bf-\ on the same command, in order to
2834 test a system filter and a user filter in the same run. For example:
2835 .display asis
2836 exim -bF /system/filter -bf /user/filter </test/message
2837 .endd
2838 This is helpful when the system filter adds header lines or sets filter
2839 variables that are used by the user filter.
2840 .nem
2841
2842 If the test filter file does not begin with one of the special lines
2843 .display asis
2844 # Exim filter
2845 # Sieve filter
2846 .endd
2847 it is taken to be a normal \(.forward)\ file, and is tested for validity under
2848 that interpretation. See sections ~~SECTitenonfilred to ~~SECTspecitredli for a
2849 description of the possible contents of non-filter redirection lists.
2850
2851 The result of an Exim command that uses \-bf-\, provided no errors are
2852 detected, is a list of the actions that Exim would try to take if presented
2853 with the message for real. More details of filter testing are given in the
2854 separate document entitled \*Exim's interfaces to mail filtering*\.
2855
2856 .index `From' line
2857 .index envelope sender
2858 .index \-f-\ option||for filter testing
2859 When testing a filter file, the envelope sender can be set by the \-f-\ option,
2860 or by a `From ' line at the start of the test message. Various parameters that
2861 would normally be taken from the envelope recipient address of the message can
2862 be set by means of additional command line options (see the next four options).
2863
2864 .em
2865 .option bfd #<<domain>>
2866 This sets the domain of the recipient address when a filter file is being 
2867 tested by means of the \-bf-\ option. The default is the value of 
2868 \$qualify@_domain$\.
2869
2870 .option bfl #<<local part>>
2871 This sets the local part of the recipient address when a filter file is being
2872 tested by means of the \-bf-\ option. The default is the username of the
2873 process that calls Exim. A local part should be specified with any prefix or
2874 suffix stripped, because that is how it appears to the filter when a message is
2875 actually being delivered.
2876
2877 .option bfp #<<prefix>>
2878 This sets the prefix of the local part of the recipient address when a filter
2879 file is being tested by means of the \-bf-\ option. The default is an empty 
2880 prefix.
2881
2882 .option bfp #<<suffix>>
2883 This sets the suffix of the local part of the recipient address when a filter
2884 file is being tested by means of the \-bf-\ option. The default is an empty 
2885 suffix.
2886 .em
2887
2888
2889 .option bh #<<IP address>>
2890 .index testing||incoming SMTP
2891 .index SMTP||testing incoming
2892 .index testing||relay control
2893 .index relaying||testing configuration
2894 .index policy control||testing
2895 .index debugging||\-bh-\ option
2896 This option runs a fake SMTP session as if from the given IP address, using the
2897 standard input and output. The IP address may include a port number at the end,
2898 after a full stop. For example:
2899 .display asis
2900 exim -bh 10.9.8.7.1234
2901 exim -bh fe80::a00:20ff:fe86:a061.5678
2902 .endd
2903 .em
2904 When an IPv6 address is given, it is converted into canonical form. In the case 
2905 of the second example above, the value of \$sender@_host@_address$\ after 
2906 conversion to the canonical form is \"fe80:0000:0000:0a00:20ff:fe86:a061.5678"\.
2907 .nem
2908
2909 Comments as to what is going on are written to the standard error file. These
2910 include lines beginning with `LOG' for anything that would have been logged.
2911 This facility is provided for testing configuration options for incoming
2912 messages, to make sure they implement the required policy. For example, you can
2913 test your relay controls using \-bh-\.
2914
2915 .index RFC 1413
2916 \**Warning 1**\: You cannot test features of the configuration that rely on
2917 ident (RFC 1413) callouts. These cannot be done when testing using
2918 \-bh-\ because there is no incoming SMTP connection.
2919
2920 \**Warning 2**\: Address verification callouts (see section ~~SECTcallver) are
2921 also skipped when testing using \-bh-\. If you want these callouts to occur,
2922 use \-bhc-\ instead.
2923
2924 Messages supplied during the testing session are discarded, and nothing is
2925 written to any of the real log files. There may be pauses when DNS (and other)
2926 lookups are taking place, and of course these may time out. The \-oMi-\ option
2927 can be used to specify a specific IP interface and port if this is important.
2928
2929 The \*exim@_checkaccess*\ utility is a `packaged' version of \-bh-\ whose
2930 output just states whether a given recipient address from a given host is
2931 acceptable or not. See section ~~SECTcheckaccess.
2932
2933 .option bhc #<<IP address>>
2934 This option operates in the same way as \-bh-\, except that address
2935 verification callouts are performed if required. This includes consulting and
2936 updating the callout cache database.
2937
2938 .option bi
2939 .index alias file||building
2940 .index building alias file
2941 .index Sendmail compatibility||\-bi-\ option
2942 Sendmail interprets the \-bi-\ option as a request to rebuild its alias file.
2943 Exim does not have the concept of a single alias file, and so it cannot mimic
2944 this behaviour. However, calls to \(/usr/lib/sendmail)\ with the \-bi-\ option
2945 tend to appear in various scripts such as NIS make files, so the option must be
2946 recognized.
2947
2948 If \-bi-\ is encountered, the command specified by the \bi@_command\
2949 configuration option is run, under the uid and gid of the caller of Exim. If
2950 the \-oA-\ option is used, its value is passed to the command as an argument.
2951 The command set by \bi@_command\ may not contain arguments. The command can use
2952 the \*exim@_dbmbuild*\ utility, or some other means, to rebuild alias files if
2953 this is required. If the \bi@_command\ option is not set, calling Exim with
2954 \-bi-\ is a no-op.
2955
2956 .option bm
2957 .index local message reception
2958 This option runs an Exim receiving process that accepts an incoming,
2959 locally-generated message on the current input. The recipients are given as the
2960 command arguments (except when \-t-\ is also present -- see below). Each
2961 argument can be a comma-separated list of RFC 2822 addresses. This is the
2962 default option for selecting the overall action of an Exim call; it is assumed
2963 if no other conflicting option is present.
2964
2965 If any addresses in the message are unqualified (have no domain), they are
2966 qualified by the values of the \qualify@_domain\ or \qualify@_recipient\
2967 options, as appropriate. The \-bnq-\ option (see below) provides a way of
2968 suppressing this for special cases.
2969
2970 Policy checks on the contents of local messages can be enforced by means of the
2971 non-SMTP ACL. See chapter ~~CHAPACL for details.
2972 .index return code||for \-bm-\
2973 The return code is zero if the message is successfully accepted. Otherwise, the
2974 action is controlled by the \-oe$it{x}-\ option setting -- see below.
2975
2976 .index message||format
2977 .index format||message
2978 .index `From' line
2979 .index UUCP||`From' line
2980 .index Sendmail compatibility||`From' line
2981 The format of the message must be as defined in RFC 2822, except that, for
2982 compatibility with Sendmail and Smail, a line in one of the forms
2983 .display
2984 From sender Fri Jan  5 12:55 GMT 1997
2985 From sender Fri, 5 Jan 97 12:55:01
2986 .endd
2987 (with the weekday optional, and possibly with additional text after the date)
2988 is permitted to appear at the start of the message. There appears to be no
2989 authoritative specification of the format of this line. Exim recognizes it by
2990 matching against the regular expression defined by the \uucp@_from@_pattern\
2991 option, which can be changed if necessary.
2992 .index \-f-\ option||overriding `From' line
2993 The specified sender is treated as if it were given as the argument to the
2994 \-f-\ option, but if a \-f-\ option is also present, its argument is used in
2995 preference to the address taken from the message. The caller of Exim must be a
2996 trusted user for the sender of a message to be set in this way.
2997
2998 .option bnq
2999 .index address||qualification, suppressing
3000 By default, Exim automatically qualifies unqualified addresses (those
3001 without domains) that appear in messages that are submitted locally (that
3002 is, not over TCP/IP). This qualification applies both to addresses in
3003 envelopes, and addresses in header lines. Sender addresses are qualified using
3004 \qualify@_domain\, and recipient addresses using \qualify@_recipient\ (which
3005 defaults to the value of \qualify@_domain\).
3006
3007 Sometimes, qualification is not wanted. For example, if \-bS-\ (batch SMTP) is
3008 being used to re-submit messages that originally came from remote hosts after
3009 content scanning, you probably do not want to qualify unqualified addresses in
3010 header lines. (Such lines will be present only if you have not enabled a header
3011 syntax check in the appropriate ACL.)
3012
3013 The \-bnq-\ option suppresses all qualification of unqualified addresses in
3014 messages that originate on the local host. When this is used, unqualified
3015 addresses in the envelope provoke errors (causing message rejection) and
3016 unqualified addresses in header lines are left alone.
3017
3018
3019 .option bP
3020 .index configuration options, extracting
3021 .index options||configuration, extracting
3022 If this option is given with no arguments, it causes the values of all Exim's
3023 main configuration options to be written to the standard output. The values
3024 of one or more specific options can be requested by giving their names as
3025 arguments, for example:
3026 .display
3027 exim -bP qualify@_domain hold@_domains
3028 .endd
3029 However, any option setting that is preceded by the word `hide' in the
3030 configuration file is not shown in full, except to an admin user. For other
3031 users, the output is as in this example:
3032 .display asis
3033 mysql_servers = <value not displayable>
3034 .endd
3035 If \configure@_file\ is given as an argument, the name of the run time
3036 configuration file is output.
3037 If a list of configuration files was supplied, the value that is output here
3038 is the name of the file that was actually used.
3039
3040 .index daemon||process id (pid)
3041 .index pid (process id)||of daemon
3042 If \log__file__path\ or \pid@_file@_path\ are given, the names of the
3043 directories where log files and daemon pid files are written are output,
3044 respectively. If these values are unset, log files are written in a
3045 sub-directory of the spool directory called \log\, and the pid file is written
3046 directly into the spool directory.
3047
3048 If \-bP-\ is followed by a name preceded by \"+"\, for example,
3049 .display asis
3050 exim -bP +local_domains
3051 .endd
3052 it searches for a matching named list of any type (domain, host, address, or
3053 local part) and outputs what it finds.
3054
3055 .index options||router, extracting
3056 .index options||transport, extracting
3057 If one of the words \router\, \transport\, or \authenticator\ is given,
3058 followed by the name of an appropriate driver instance, the option settings for
3059 that driver are output. For example:
3060 .display
3061 exim -bP transport local@_delivery
3062 .endd
3063 The generic driver options are output first, followed by the driver's private
3064 options. A list of the names of drivers of a particular type can be obtained by
3065 using one of the words \router@_list\, \transport@_list\, or
3066 \authenticator@_list\, and a complete list of all drivers with their option
3067 settings can be obtained by using \routers\, \transports\, or \authenticators\.
3068
3069
3070 .option bp
3071 .index queue||listing messages on
3072 .index listing||messages on the queue
3073 This option requests a listing of the contents of the mail queue on the
3074 standard output. If the \-bp-\ option is followed by a list of message ids,
3075 just those messages are listed. By default, this option can be used only by an
3076 admin user. However, the \queue__list__requires__admin\ option can be set false
3077 to allow any user to see the queue.
3078
3079 Each message on the queue is displayed as in the following example:
3080 .display
3081 25m  2.9K 0t5C6f-0000c8-00 <alice@@wonderland.fict.example>
3082           red.king@@looking-glass.fict.example
3083           <<other addresses>>
3084 .endd
3085 .index message||size in queue listing
3086 .index size||of message
3087 The first line contains the length of time the message has been on the queue
3088 (in this case 25 minutes), the size of the message (2.9K), the unique local
3089 identifier for the message, and the message sender, as contained in the
3090 envelope. For bounce messages, the sender address is empty, and appears as
3091 `<>'. If the message was submitted locally by an untrusted user who overrode
3092 the default sender address, the user's login name is shown in parentheses
3093 before the sender address.
3094 .index frozen messages||in queue listing
3095 If the message is frozen (attempts to deliver it are suspended) then the text
3096 `$*$$*$$*$ frozen $*$$*$$*$' is displayed at the end of this line.
3097
3098 The recipients of the message (taken from the envelope, not the headers) are
3099 displayed on subsequent lines. Those addresses to which the message has already
3100 been delivered are marked with the letter D. If an original address gets
3101 expanded into several addresses via an alias or forward file, the original is
3102 displayed with a D only when deliveries for all of its child addresses are
3103 complete.
3104
3105
3106 .option bpa
3107 This option operates like \-bp-\, but in addition it shows delivered addresses
3108 that were generated from the original top level address(es) in each message by
3109 alias or forwarding operations. These addresses are flagged with `+D' instead
3110 of just `D'.
3111
3112
3113 .option bpc
3114 .index queue||count of messages on
3115 This option counts the number of messages on the queue, and writes the total
3116 to the standard output. It is restricted to admin users, unless
3117 \queue__list__requires__admin\ is set false.
3118
3119
3120 .option bpr
3121 This option operates like \-bp-\, but the output is not sorted into
3122 chronological order of message arrival. This can speed it up when there are
3123 lots of messages on the queue, and is particularly useful if the output is
3124 going to be post-processed in a way that doesn't need the sorting.
3125
3126 .option bpra
3127 This option is a combination of \-bpr-\ and \-bpa-\.
3128
3129 .option bpru
3130 This option is a combination of \-bpr-\ and \-bpu-\.
3131
3132
3133 .option bpu
3134 This option operates like \-bp-\ but shows only undelivered top-level addresses
3135 for each message displayed. Addresses generated by aliasing or forwarding are
3136 not shown, unless the message was deferred after processing by a router with
3137 the \one@_time\ option set.
3138
3139
3140 .option brt
3141 .index testing||retry configuration
3142 .index retry||configuration testing
3143 This option is for testing retry rules, and it must be followed by up to three
3144 arguments. It causes Exim to look for a retry rule that matches the values
3145 and to write it to the standard output. For example:
3146 .display asis
3147 exim -brt bach.comp.mus.example
3148 Retry rule: *.comp.mus.example  F,2h,15m; F,4d,30m;
3149 .endd
3150 See chapter ~~CHAPretry for a description of Exim's retry rules. The first
3151 argument, which is required, can be a complete address in the form
3152 \*local@_part@@domain*\, or it can be just a domain name. The second argument is
3153 an optional second domain name; if no retry rule is found for the first
3154 argument, the second is tried. This ties in with Exim's behaviour when looking
3155 for retry rules for remote hosts -- if no rule is found that matches the host,
3156 one that matches the mail domain is sought. The final argument is the name of a
3157 specific delivery error, as used in setting up retry rules, for example
3158 `quota@_3d'.
3159
3160 .option brw
3161 .index testing||rewriting
3162 .index rewriting||testing
3163 This option is for testing address rewriting rules, and it must be followed by
3164 a single argument, consisting of either a local part without a domain, or a
3165 complete address with a fully qualified domain. Exim outputs how this address
3166 would be rewritten for each possible place it might appear. See chapter
3167 ~~CHAPrewrite for further details.
3168
3169 .option bS
3170 .index SMTP||batched incoming
3171 .index batched SMTP input
3172 This option is used for batched SMTP input, which is an alternative interface
3173 for non-interactive local message submission. A number of messages can be
3174 submitted in a single run. However, despite its name, this is not really SMTP
3175 input. Exim reads each message's envelope from SMTP commands on the standard
3176 input, but generates no responses. If the caller is trusted, or
3177 \untrusted@_set@_sender\ is set, the senders in the SMTP \\MAIL\\ commands are
3178 believed; otherwise the sender is always the caller of Exim.
3179
3180 The message itself is read from the standard input, in SMTP format (leading
3181 dots doubled), terminated by a line containing just a single dot. An error is
3182 provoked if the terminating dot is missing. A further message may then follow.
3183
3184 As for other local message submissions, the contents of incoming batch SMTP
3185 messages can be checked using the non-SMTP ACL (see chapter ~~CHAPACL).
3186 Unqualified addresses are automatically qualified using \qualify@_domain\ and
3187 \qualify@_recipient\, as appropriate, unless the \-bnq-\ option is used.
3188
3189 Some other SMTP commands are recognized in the input. \\HELO\\ and \\EHLO\\ act
3190 as \\RSET\\; \\VRFY\\, \\EXPN\\, \\ETRN\\, and \\HELP\\ act as \\NOOP\\;
3191 \\QUIT\\ quits, ignoring the rest of the standard input.
3192
3193 If any error is encountered, reports are written to the standard output and
3194 error streams, and Exim gives up immediately.
3195 .index return code||for \-bS-\
3196 The return code is 0 if no error was detected; it is 1 if one or more messages
3197 were accepted before the error was detected; otherwise it is 2.
3198
3199 More details of input using batched SMTP are given in section
3200 ~~SECTincomingbatchedSMTP.
3201
3202 .option bs
3203 .index SMTP||local input
3204 .index local SMTP input
3205 This option causes Exim to accept one or more messages by reading SMTP commands
3206 on the standard input, and producing SMTP replies on the standard output. SMTP
3207 policy controls, as defined in ACLs (see chapter ~~CHAPACL) are applied.
3208
3209 Some user agents use this interface as a way of passing locally-generated
3210 messages to the MTA.
3211 .index sender||source of
3212 In this usage, if the caller of Exim is trusted, or \untrusted@_set@_sender\ is
3213 set, the senders of messages are taken from the SMTP \\MAIL\\ commands.
3214 Otherwise the content of these commands is ignored and the sender is set up as
3215 the calling user. Unqualified addresses are automatically qualified using
3216 \qualify@_domain\ and \qualify@_recipient\, as appropriate, unless the \-bnq-\
3217 option is used.
3218
3219 .index inetd
3220 The \-bs-\ option is also used to run Exim from \*inetd*\, as an alternative to
3221 using a listening daemon. Exim can distinguish the two cases by checking
3222 whether the standard input is a TCP/IP socket. When Exim is called from
3223 \*inetd*\, the source of the mail is assumed to be remote, and the comments
3224 above concerning senders and qualification do not apply. In this situation,
3225 Exim behaves in exactly the same way as it does when receiving a message via
3226 the listening daemon.
3227
3228 .option bt
3229 .index testing||addresses
3230 .index address||testing
3231 This option runs Exim in address testing mode, in which each argument is taken
3232 as an address to be tested for deliverability. The results are written to the
3233 standard output. If a test fails, and the caller is not an admin user, no
3234 details of the failure are output, because these might contain sensitive
3235 information such as usernames and passwords for database lookups.
3236
3237 If no arguments are given, Exim runs in an interactive manner, prompting with a
3238 right angle bracket for addresses to be tested. 
3239 .em
3240 Unlike the \-be-\ test option, you cannot arrange for Exim to use the 
3241 \*readline()*\ function, because it is running as \*root*\ and there are
3242 security issues.
3243 .nem
3244
3245 Each address is handled as if it were the recipient address of a message
3246 (compare the \-bv-\ option). It is passed to the routers and the result is
3247 written to the standard output. However, any router that has
3248 \no@_address@_test\ set is bypassed. This can make \-bt-\ easier to use for
3249 genuine routing tests if your first router passes everything to a scanner
3250 program.
3251
3252 .index return code||for \-bt-\
3253 The return code is 2 if any address failed outright; it is 1 if no address
3254 failed outright but at least one could not be resolved for some reason. Return
3255 code 0 is given only when all addresses succeed.
3256
3257 \**Warning**\: \-bt-\ can only do relatively simple testing. If any of the
3258 routers in the configuration makes any tests on the sender address of a
3259 message,
3260 .index \-f-\ option||for address testing
3261 you can use the \-f-\ option to set an appropriate sender when running
3262 \-bt-\ tests. Without it, the sender is assumed to be the calling user at the
3263 default qualifying domain. However, if you have set up (for example) routers
3264 whose behaviour depends on the contents of an incoming message, you cannot test
3265 those conditions using \-bt-\. The \-N-\ option provides a possible way of
3266 doing such tests.
3267
3268 .option bV
3269 .index version number of Exim, verifying
3270 This option causes Exim to write the current version number, compilation
3271 number, and compilation date of the \*exim*\ binary to the standard output.
3272 It also lists the DBM library this is being used, the optional modules (such as
3273 specific lookup types), the drivers that are included in the binary, and the
3274 name of the run time configuration file that is in use.
3275
3276 .em
3277 As part of its operation, \-bV-\ causes Exim to read and syntax check its 
3278 configuration file. However, this is a static check only. It cannot check
3279 values that are to be expanded. For example, although a misspelt ACL verb is
3280 detected, an error in the verb's arguments is not. You cannot rely on \-bV-\
3281 alone to discover (for example) all the typos in the configuration; some
3282 realistic testing is needed. The \-bh-\ and \-N-\ options provide more dynamic
3283 testing facilities.
3284 .nem
3285
3286
3287 .option bv
3288 .index verifying||address, using \-bv-\
3289 .index address||verification
3290 This option runs Exim in address verification mode, in which each argument is
3291 taken as an address to be verified. During normal operation, verification
3292 happens mostly as a consequence processing a \verify\ condition in an ACL (see
3293 chapter ~~CHAPACL). If you want to test an entire ACL, see the \-bh-\ option.
3294
3295 If verification fails, and the caller is not an admin user, no details of the
3296 failure are output, because these might contain sensitive information such as
3297 usernames and passwords for database lookups.
3298
3299 If no arguments are given, Exim runs in an interactive manner, prompting with a
3300 right angle bracket for addresses to be verified. 
3301 .em
3302 Unlike the \-be-\ test option, you cannot arrange for Exim to use the 
3303 \*readline()*\ function, because it is running as \*exim*\ and there are
3304 security issues.
3305 .nem
3306
3307 Verification differs from address testing (the \-bt-\ option) in that routers
3308 that have \no@_verify\ set are skipped, and if the address is accepted by a
3309 router that has \fail@_verify\ set, verification fails. The address is verified
3310 as a recipient if \-bv-\ is used; to test verification for a sender address,
3311 \-bvs-\ should be used.
3312
3313 If the \-v-\ option is not set, the output consists of a single line for each
3314 address, stating whether it was verified or not, and giving a reason in the
3315 latter case. Otherwise, more details are given of how the address has been
3316 handled, and in the case of address redirection, all the generated addresses
3317 are also considered. Without \-v-\, generating more than one address by
3318 redirection causes verification to end sucessfully.
3319
3320 .index return code||for \-bv-\
3321 The return code is 2 if any address failed outright; it is 1 if no address
3322 failed outright but at least one could not be resolved for some reason. Return
3323 code 0 is given only when all addresses succeed.
3324
3325 If any of the routers in the configuration makes any tests on the sender
3326 address of a message, you should use the \-f-\ option to set an appropriate
3327 sender when running \-bv-\ tests. Without it, the sender is assumed to be the
3328 calling user at the default qualifying domain.
3329
3330 .option bvs
3331 This option acts like \-bv-\, but verifies the address as a sender rather
3332 than a recipient address. This affects any rewriting and qualification that
3333 might happen.
3334
3335 .option C #<<filelist>>
3336 .index configuration file||alternate
3337 .index \\CONFIGURE@_FILE\\
3338 .index alternate configuration file
3339 This option causes Exim to find the run time configuration file from the given
3340 list instead of from the list specified by the \\CONFIGURE@_FILE\\
3341 compile-time setting. Usually, the list will consist of just a single file
3342 name, but it can be a colon-separated list of names. In this case, the first
3343 file that exists is used. Failure to open an existing file stops Exim from
3344 proceeding any further along the list, and an error is generated.
3345
3346 When this option is used by a caller other than root or the Exim user, and the
3347 list is different from the compiled-in list, Exim gives up its root privilege
3348 immediately, and runs with the real and effective uid and gid set to those of
3349 the caller. However, if \\ALT@_CONFIG@_ROOT@_ONLY\\ is defined in
3350 \(Local/Makefile)\, root privilege is retained for \-C-\ only if the caller of
3351 Exim is root.
3352 .em
3353 That is, the Exim user is no longer privileged in this regard. This build-time
3354 option is not set by default in the Exim source distribution tarbundle. 
3355 However, if you are using a `packaged' version of Exim (source or binary), the 
3356 packagers might have enabled it.
3357 .nem
3358
3359 Setting \\ALT@_CONFIG@_ROOT@_ONLY\\ locks out the possibility of testing a
3360 configuration using \-C-\ right through message reception and delivery, even if
3361 the caller is root. The reception works, but by that time, Exim is running as
3362 the Exim user, so when it re-execs to regain privilege for the delivery, the
3363 use of \-C-\ causes privilege to be lost. However, root can test reception and
3364 delivery using two separate commands (one to put a message on the queue, using
3365 \-odq-\, and another to do the delivery, using \-M-\).
3366
3367 If \\ALT@_CONFIG@_PREFIX\\ is defined \(in Local/Makefile)\, it specifies a
3368 prefix string with which any file named in a \-C-\ command line option
3369 must start. In addition, the file name must not contain the sequence \"/../"\.
3370 However, if the value of the \-C-\ option is identical to the value of
3371 \\CONFIGURE@_FILE\\ in \(Local/Makefile)\, Exim ignores \-C-\ and proceeds as
3372 usual. There is no default setting for \\ALT@_CONFIG@_PREFIX\\; when it is
3373 unset, any file name can be used with \-C-\.
3374
3375 \\ALT@_CONFIG@_PREFIX\\ can be used to confine alternative configuration files
3376 to a directory to which only root has access. This prevents someone who has
3377 broken into the Exim account from running a privileged Exim with an arbitrary
3378 configuration file.
3379
3380 The \-C-\ facility is useful for ensuring that configuration files are
3381 syntactically correct, but cannot be used for test deliveries, unless the
3382 caller is privileged, or unless it is an exotic configuration that does not
3383 require privilege. No check is made on the owner or group of the files
3384 specified by this option.
3385
3386 .option D <<macro>>=<<value>>
3387 .index macro||setting on command line
3388 This option can be used to override macro definitions in the configuration file
3389 (see section ~~SECTmacrodefs). However, like \-C-\, if it is used by an
3390 unprivileged caller, it causes Exim to give up its root privilege.
3391 If \\DISABLE@_D@_OPTION\\ is defined in \(Local/Makefile)\, the use of \-D-\ is
3392 completely disabled, and its use causes an immediate error exit.
3393
3394 The entire option (including equals sign if present) must all be within one
3395 command line item. \-D-\ can be used to set the value of a macro to the empty
3396 string, in which case the equals sign is optional. These two commands are
3397 synonymous:
3398 .display asis
3399 exim -DABC  ...
3400 exim -DABC= ...
3401 .endd
3402 To include spaces in a macro definition item, quotes must be used. If you use
3403 quotes, spaces are permitted around the macro name and the equals sign. For
3404 example:
3405 .display asis
3406 exim '-D ABC = something' ...
3407 .endd
3408 \-D-\ may be repeated up to 10 times on a command line.
3409
3410 .option d <<debug options>>
3411 .index debugging||list of selectors
3412 .index debugging||\-d-\ option
3413 This option causes debugging information to be written to the standard
3414 error stream. It is restricted to admin users because debugging output may show
3415 database queries that contain password information. Also, the details of users'
3416 filter files should be protected. When \-d-\ is used, \-v-\ is assumed. If
3417 \-d-\ is given on its own, a lot of standard debugging data is output. This can
3418 be reduced, or increased to include some more rarely needed information, by
3419 following \-d-\ with a string made up of names preceded by plus or minus
3420 characters. These add or remove sets of debugging data, respectively. For
3421 example, \-d+filter-\ adds filter debugging, whereas \-d-all+filter-\ selects
3422 only filter debugging. The available debugging categories are:
3423 .display flow
3424 .tabs 21
3425 .
3426 . The odd formatting of the lines below is deliberate. It does not affect the
3427 . SGCAL output, but by putting in the space it keeps things aligned in the man
3428 . page that is automatically generated from this text.
3429 .
3430 acl           $t $rm{ACL interpretation}
3431 auth          $t $rm{authenticators}
3432 deliver       $t $rm{general delivery logic}
3433 dns           $t $rm{DNS lookups (see also resolver)}
3434 dnsbl         $t $rm{DNS black list (aka RBL) code}
3435 exec          $t $rm{arguments for \execv@(@)\ calls}
3436 expand        $t $rm{detailed debugging for string expansions}
3437 filter        $t $rm{filter handling}
3438 hints@_lookup  $t $rm{hints data lookups}
3439 host@_lookup   $t $rm{all types of name-to-IP address handling}
3440 ident         $t $rm{ident lookup}
3441 interface     $t $rm{lists of local interfaces}
3442 lists         $t $rm{matching things in lists}
3443 load          $t $rm{system load checks}
3444 local@_scan    $t $rm{can be used by \*local@_scan()*\ (see chapter ~~CHAPlocalscan)}
3445 lookup        $t $rm{general lookup code and all lookups}
3446 memory        $t $rm{memory handling}
3447 pid           $t $rm{add pid to debug output lines}
3448 process@_info  $t $rm{setting info for the process log}
3449 queue@_run     $t $rm{queue runs}
3450 receive       $t $rm{general message reception logic}
3451 resolver      $t $rm{turn on the DNS resolver's debugging output}
3452 retry         $t $rm{retry handling}
3453 rewrite       $t $rm{address rewriting}
3454 route         $t $rm{address routing}
3455 timestamp     $t $rm{add timestamp to debug output lines}
3456 tls           $t $rm{TLS logic}
3457 transport     $t $rm{transports}
3458 uid           $t $rm{changes of uid/gid and looking up uid/gid}
3459 verify        $t $rm{address verification logic}
3460
3461 all           $t $rm{all of the above, and also \-v-\}
3462 .endd
3463 .index resolver, debugging output
3464 .index DNS||resolver, debugging output
3465 The \"resolver"\ option produces output only if the DNS resolver was compiled
3466 with \\DEBUG\\ enabled. This is not the case in some operating systems. Also,
3467 unfortunately, debugging output from the DNS resolver is written to stdout
3468 rather than stderr.
3469
3470 The default (\-d-\ with no argument) omits \"expand"\, \"filter"\,
3471 \"interface"\, \"load"\, \"memory"\, \"pid"\, \"resolver"\, and \"timestamp"\.
3472 However, the \"pid"\ selector is forced when debugging is turned on for a
3473 daemon, which then passes it on to any re-executed Exims. Exim also
3474 automatically adds the pid to debug lines when several remote deliveries are
3475 run in parallel.
3476
3477 The \"timestamp"\ selector causes the current time to be inserted at the start
3478 of all debug output lines. This can be useful when trying to track down delays
3479 in processing.
3480
3481 If the \debug@_print\ option is set in any driver, it produces output whenever
3482 any debugging is selected, or if \-v-\ is used.
3483
3484 .em
3485 .option dd <<debug options>>
3486 This option behaves exactly like \-d-\ except when used on a command that
3487 starts a daemon process. In that case, debugging is turned off for the
3488 subprocesses that the daemon creates. Thus, it is useful for monitoring the
3489 behaviour of the daemon without creating as much output as full debugging does.
3490 .nem
3491
3492 .option dropcr
3493 This is an obsolete option that is now a no-op. It used to affect the way Exim
3494 handled CR and LF characters in incoming messages. What happens now is
3495 described in section ~~SECTlineendings.
3496
3497
3498 .option E
3499 .index bounce message||generating
3500 This option specifies that an incoming message is a locally-generated delivery
3501 failure report. It is used internally by Exim when handling delivery failures
3502 and is not intended for external use. Its only effect is to stop Exim
3503 generating certain messages to the postmaster, as otherwise message cascades
3504 could occur in some situations. As part of the same option, a message id may
3505 follow the characters \-E-\. If it does, the log entry for the receipt of the
3506 new message contains the id, following `R=', as a cross-reference.
3507
3508 .option e$it{x}
3509 There are a number of Sendmail options starting with \-oe-\ which seem to be
3510 called by various programs without the leading \o\ in the option. For example,
3511 the \vacation\ program uses \-eq-\. Exim treats all options of the form
3512 \-e$it{x}-\ as synonymous with the corresponding \-oe$it{x}-\ options.
3513
3514 .option F #<<string>>
3515 .index sender||name
3516 .index name||of sender
3517 This option sets the sender's full name for use when a locally-generated
3518 message is being accepted. In the absence of this option, the user's \*gecos*\
3519 entry from the password data is used. As users are generally permitted to alter
3520 their \*gecos*\ entries, no security considerations are involved. White space
3521 between \-F-\ and the <<string>> is optional.
3522
3523 .option f #<<address>>
3524 .index sender||address
3525 .index address||sender
3526 .index trusted user
3527 .index envelope sender
3528 .index user||trusted
3529 This option sets the address of the envelope sender of a locally-generated
3530 message (also known as the return path). The option can normally be used only
3531 by a trusted user, but \untrusted@_set@_sender\ can be set to allow untrusted
3532 users to use it. 
3533 .em
3534 Processes running as root or the Exim user are always trusted. Other
3535 trusted users are defined by the \trusted@_users\ or \trusted@_groups\ options.
3536
3537 In the absence of \-f-\, or if the caller is not trusted, the sender of a local
3538 message is set to the caller's login name at the default qualify domain.
3539
3540 There is one exception to the restriction on the use of \-f-\: an empty sender
3541 can be specified by any user, trusted or not,
3542 .nem
3543 to create a message that can never provoke a bounce. An empty sender can be
3544 specified either as an empty string, or as a pair of angle brackets with
3545 nothing between them, as in these examples of shell commands:
3546 .display asis
3547 exim -f '<>' user@domain
3548 exim -f "" user@domain
3549 .endd
3550 In addition, the use of \-f-\ is not restricted when testing a filter file with
3551 \-bf-\ or when testing or verifying addresses using the \-bt-\ or \-bv-\
3552 options.
3553
3554 Allowing untrusted users to change the sender address does not of itself make
3555 it possible to send anonymous mail. Exim still checks that the ::From:: header
3556 refers to the local user, and if it does not, it adds a ::Sender:: header,
3557 though this can be overridden by setting \no@_local@_from@_check\.
3558
3559 .index `From' line
3560 White space between \-f-\ and the <<address>> is optional
3561 (that is, they can be given as two arguments or one combined argument).
3562 The sender of a locally-generated message can also be set (when permitted) by
3563 an initial `From ' line in the message -- see the description of \-bm-\ above
3564 -- but if \-f-\ is also present, it overrides `From'.
3565
3566 .option G
3567 .index Sendmail compatibility||\-G-\ option ignored
3568 This is a Sendmail option which is ignored by Exim.
3569
3570 .option h #<<number>>
3571 .index Sendmail compatibility||\-h-\ option ignored
3572 This option is accepted for compatibility with Sendmail, but has no effect. (In
3573 Sendmail it overrides the `hop count' obtained by counting ::Received::
3574 headers.)
3575
3576 .option i
3577 .index Solaris||\*mail*\ command
3578 .index dot||in incoming, non-SMTP message
3579 This option, which has the same effect as \-oi-\, specifies that a dot on a
3580 line by itself should not terminate an incoming, non-SMTP message. I can find
3581 no documentation for this option in Solaris 2.4 Sendmail, but the \*mailx*\
3582 command in Solaris 2.4 uses it. See also \-ti-\.
3583
3584 .option M #<<message id>>#<<message id>> ...
3585 .index forcing delivery
3586 .index delivery||forcing attempt
3587 .index frozen messages||forcing delivery
3588 This option requests Exim to run a delivery attempt on each message in turn. If
3589 any of the messages are frozen, they are automatically thawed before the
3590 delivery attempt. The settings of \queue@_domains\, \queue@_smtp@_domains\, and
3591 \hold@_domains\ are ignored.
3592 .index hints database||overriding retry hints
3593 Retry hints for any of the addresses are
3594 overridden -- Exim tries to deliver even if the normal retry time has not yet
3595 been reached. This option requires the caller to be an admin user. However,
3596 there is an option called \prod@_requires@_admin\ which can be set false to
3597 relax this restriction (and also the same requirement for the \-q-\, \-R-\, and
3598 \-S-\ options).
3599
3600
3601 .option Mar #<<message id>>#<<address>>#<<address>> ...
3602 .index message||adding recipients
3603 .index recipient||adding
3604 This option requests Exim to add the addresses to the list of recipients of the
3605 message (`ar' for `add recipients'). The first argument must be a message id,
3606 and the remaining ones must be email addresses. However, if the message is
3607 active (in the middle of a delivery attempt), it is not altered. This option
3608 can be used only by an admin user.
3609
3610 .index SMTP||passed connection
3611 .index SMTP||multiple deliveries
3612 .index multiple SMTP deliveries
3613 .option MC #<<transport>>#<<hostname>>#<<sequence number>>#<<message id>>
3614 This option is not intended for use by external callers. It is used internally
3615 by Exim to invoke another instance of itself to deliver a waiting message using
3616 an existing SMTP connection, which is passed as the standard input. Details are
3617 given in chapter ~~CHAPSMTP. This must be the final option, and the caller must
3618 be root or the Exim user in order to use it.
3619
3620 .option MCA
3621 This option is not intended for use by external callers. It is used internally
3622 by Exim in conjunction with the \-MC-\ option. It signifies that the connection
3623 to the remote host has been authenticated.
3624
3625 .option MCP
3626 This option is not intended for use by external callers. It is used internally
3627 by Exim in conjunction with the \-MC-\ option. It signifies that the server to
3628 which Exim is connected supports pipelining.
3629
3630 .option MCQ #<<process id>> <<pipe fd>>
3631 This option is not intended for use by external callers. It is used internally
3632 by Exim in conjunction with the \-MC-\ option when the original delivery was
3633 started by a queue runner. It passes on the process id of the queue runner,
3634 together with the file descriptor number of an open pipe. Closure of the pipe
3635 signals the final completion of the sequence of processes that are passing
3636 messages through the same SMTP connection.
3637
3638 .option MCS
3639 This option is not intended for use by external callers. It is used internally
3640 by Exim in conjunction with the \-MC-\ option, and passes on the fact that the
3641 SMTP \\SIZE\\ option should be used on messages delivered down the existing
3642 connection.
3643
3644 .option MCT
3645 This option is not intended for use by external callers. It is used internally
3646 by Exim in conjunction with the \-MC-\ option, and passes on the fact that the
3647 host to which Exim is connected supports TLS encryption.
3648
3649 .option Mc #<<message id>>#<<message id>> ...
3650 .index hints database||not overridden by \-Mc-\
3651 .index delivery||manually started, not forced
3652 This option requests Exim to run a delivery attempt on each message in turn,
3653 but unlike the \-M-\ option, it does check for retry hints, and respects any
3654 that are found. This option is not very useful to external callers. It is
3655 provided mainly for internal use by Exim when it needs to re-invoke itself in
3656 order to regain root privilege for a delivery (see chapter ~~CHAPsecurity).
3657 However, \-Mc-\ can be useful when testing, in order to run a delivery that
3658 respects retry times and other options such as \hold@_domains\ that are
3659 overridden when \-M-\ is used. Such a delivery does not count as a queue run.
3660 If you want to run a specific delivery as if in a queue run, you should use
3661 \-q-\ with a message id argument. A distinction between queue run deliveries
3662 and other deliveries is made in one or two places.
3663
3664 .option Mes #<<message id>>#<<address>>
3665 .index message||changing sender
3666 .index sender||changing
3667 This option requests Exim to change the sender address in the message to the
3668 given address, which must be a fully qualified address or `<>' (`es' for `edit
3669 sender'). There must be exactly two arguments. The first argument must be a
3670 message id, and the second one an email address. However, if the message is
3671 active (in the middle of a delivery attempt), its status is not altered. This
3672 option can be used only by an admin user.
3673
3674 .option Mf #<<message id>>#<<message id>> ...
3675 .index freezing messages
3676 .index message||manually freezing
3677 This option requests Exim to mark each listed message as `frozen'. This
3678 prevents any delivery attempts taking place until the message is `thawed',
3679 either manually or as a result of the \auto@_thaw\ configuration option.
3680 However, if any of the messages are active (in the middle of a delivery
3681 attempt), their status is not altered. This option can be used only by an admin
3682 user.
3683
3684 .option Mg #<<message id>>#<<message id>> ...
3685 .index giving up on messages
3686 .index message||abandoning delivery attempts
3687 .index delivery||abandoning further attempts
3688 This option requests Exim to give up trying to deliver the listed messages,
3689 including any that are frozen. However, if any of the messages are active,
3690 their status is not altered.
3691 For non-bounce messages, a delivery error message is sent to the sender,
3692 containing the text `cancelled by administrator'. Bounce messages are just
3693 discarded.
3694 This option can be used only by an admin user.
3695
3696 .option Mmad #<<message id>>#<<message id>> ...
3697 .index delivery||cancelling all
3698 This option requests Exim to mark all the recipient addresses in the messages
3699 as already delivered (`mad' for `mark all delivered'). However, if any message
3700 is active (in the middle of a delivery attempt), its status is not altered.
3701 This option can be used only by an admin user.
3702
3703 .option Mmd #<<message id>>#<<address>>#<<address>> ...
3704 .index delivery||cancelling by address
3705 .index recipient||removing
3706 .index removing recipients
3707 This option requests Exim to mark the given addresses as already delivered
3708 (`md' for `mark delivered'). The first argument must be a message id, and the
3709 remaining ones must be email addresses. These are matched to recipient
3710 addresses in the message in a case-sensitive manner. If the message is active
3711 (in the middle of a delivery attempt), its status is not altered. This option
3712 can be used only by an admin user.
3713
3714 .option Mrm #<<message id>>#<<message id>> ...
3715 .index removing messages
3716 .index abandoning mail
3717 .index message||manually discarding
3718 This option requests Exim to remove the given messages from the queue. No
3719 bounce messages are sent; each message is simply forgotten. However, if any of
3720 the messages are active, their status is not altered. This option can be used
3721 only by an admin user or by the user who originally caused the message to be
3722 placed on the queue.
3723
3724 .option Mt #<<message id>>#<<message id>> ...
3725 .index thawing messages
3726 .index unfreezing messages
3727 .index frozen messages||thawing
3728 .index message||thawing frozen
3729 This option requests Exim to `thaw' any of the listed messages that are
3730 `frozen', so that delivery attempts can resume. However, if any of the messages
3731 are active, their status is not altered. This option can be used only by an
3732 admin user.
3733
3734 .option Mvb #<<message id>>
3735 .index listing||message body
3736 .index message||listing body of
3737 This option causes the contents of the message body (-D) spool file to be
3738 written to the standard output. This option can be used only by an admin user.
3739
3740 .option Mvh #<<message id>>
3741 .index listing||message headers
3742 .index header lines||listing
3743 .index message||listing header lines
3744 This option causes the contents of the message headers (-H) spool file to be
3745 written to the standard output. This option can be used only by an admin user.
3746
3747 .option Mvl #<<message id>>
3748 .index listing||message log
3749 .index message||listing message log
3750 This option causes the contents of the message log spool file to be written to
3751 the standard output. This option can be used only by an admin user.
3752
3753 .option m
3754 This is apparently a synonym for \-om-\ that is accepted by Sendmail, so Exim
3755 treats it that way too.
3756
3757 .option N
3758 .index debugging||\-N-\ option
3759 .index debugging||suppressing delivery
3760 This is a debugging option that inhibits delivery of a message at the transport
3761 level. It implies \-v-\. Exim goes through many of the motions of delivery --
3762 it just doesn't actually transport the message, but instead behaves as if it
3763 had successfully done so. However, it does not make any updates to the retry
3764 database, and the log entries for deliveries are flagged with `$*$>' rather
3765 than `=>'.
3766
3767 Because \-N-\ discards any message to which it applies, only root or the Exim
3768 user are allowed to use it with \-bd-\, \-q-\, \-R-\ or \-M-\. In other words,
3769 an ordinary user can use it only when supplying an incoming message to which it
3770 will apply. Although transportation never fails when \-N-\ is set, an address
3771 may be deferred because of a configuration problem on a transport, or a routing
3772 problem. Once \-N-\ has been used for a delivery attempt, it sticks to the
3773 message, and applies to any subsequent delivery attempts that may happen for
3774 that message.
3775
3776 .option n
3777 .index Sendmail compatibility||\-n-\ option ignored
3778 This option is interpreted by Sendmail to mean `no aliasing'. It is ignored by
3779 Exim.
3780
3781 .option O #<<data>>
3782 This option is interpreted by Sendmail to mean `set option`. It is ignored by
3783 Exim.
3784
3785 .option oA #<<file name>>
3786 .index Sendmail compatibility||\-oA-\ option
3787 This option is used by Sendmail in conjunction with \-bi-\ to specify an
3788 alternative alias file name. Exim handles \-bi-\ differently; see the
3789 description above.
3790
3791 .index SMTP||passed connection
3792 .option oB #<<n>>
3793 .index SMTP||multiple deliveries
3794 .index multiple SMTP deliveries
3795 This is a debugging option which limits the maximum number of messages that can
3796 be delivered down one SMTP connection, overriding the value set in any \%smtp%\
3797 transport. If <<n>> is omitted, the limit is set to 1.
3798
3799 .option odb
3800 .index background delivery
3801 .index delivery||in the background
3802 This option applies to all modes in which Exim accepts incoming messages,
3803 including the listening daemon. It requests `background' delivery of such
3804 messages, which means that the accepting process automatically starts a
3805 delivery process for each message received, but does not wait for the delivery
3806 processes to finish.
3807 .em
3808 When all the messages have been received, the reception process exits, leaving 
3809 the delivery processes to finish in their own time. The standard output and
3810 error streams are closed at the start of each delivery process.
3811 .nem
3812 This is the default action if none of the \-od-\ options are present.
3813
3814 If one of the queueing options in the configuration file
3815 (\queue@_only\ or \queue@_only@_file\, for example) is in effect, \-odb-\
3816 overrides it if \queue@_only@_override\ is set true, which is the default
3817 setting. If \queue@_only@_override\ is set false, \-odb-\ has no effect.
3818
3819 .option odf
3820 .index foreground delivery
3821 .index delivery||in the foreground
3822 This option requests `foreground' (synchronous) delivery when Exim has accepted
3823 a locally-generated message. (For the daemon it is exactly the same as
3824 \-odb-\.) A delivery process is automatically started to deliver the
3825 message, and Exim waits for it to complete before proceeding.
3826 .em
3827 The original Exim reception process does not finish until the delivery 
3828 process for the final message has ended. The standard error stream is left open
3829 during deliveries.
3830 .nem
3831 However, like \-odb-\, this option has no effect if \queue@_only@_override\ is
3832 false and one of the queueing options in the configuration file is in effect.
3833
3834 .em
3835 If there is a temporary delivery error during foreground delivery, the message 
3836 is left on the queue for later delivery, and the original reception process 
3837 exists. See chapter ~~CHAPnonqueueing for a way of setting up a restricted 
3838 configuration that never queues messages.
3839 .nem
3840
3841 .option odi
3842 This option is synonymous with \-odf-\. It is provided for compatibility with
3843 Sendmail.
3844
3845 .option odq
3846 .index non-immediate delivery
3847 .index delivery||suppressing immediate
3848 .index queueing incoming messages
3849 This option applies to all modes in which Exim accepts incoming messages,
3850 including the listening daemon. It specifies that the accepting process should
3851 not automatically start a delivery process for each message received. Messages
3852 are placed on the queue, and remain there until a subsequent queue runner
3853 process encounters them.
3854 There are several configuration options (such as \queue@_only\) that can be
3855 used to queue incoming messages under certain conditions. This option overrides
3856 all of them and also \-odqs-\. It always forces queueing.
3857
3858 .option odqs
3859 .index SMTP||delaying delivery
3860 This option is a hybrid between \-odb-\/\-odi-\ and \-odq-\.
3861 However, like \-odb-\ and \-odi-\, this option has no effect if
3862 \queue@_only@_override\ is false and one of the queueing options in the
3863 configuration file is in effect.
3864
3865 When \-odqs-\ does operate, a delivery process is started for each incoming
3866 message, in the background by default, but in the foreground if \-odi-\ is also
3867 present.
3868 The recipient addresses are routed, and local deliveries are done in the normal
3869 way. However, if any SMTP deliveries are required, they are not done at this
3870 time, so the message remains on the queue until a subsequent queue runner
3871 process encounters it. Because routing was done, Exim knows which messages are
3872 waiting for which hosts, and so a number of messages for the same host can be
3873 sent in a single SMTP connection. The \queue@_smtp@_domains\ configuration
3874 option has the same effect for specific domains. See also the \-qq-\ option.
3875
3876 .option oee
3877 .index error||reporting
3878 If an error is detected while a non-SMTP message is being received (for
3879 example, a malformed address), the error is reported to the sender in a mail
3880 message.
3881 .index return code||for \-oee-\
3882 Provided this error message is successfully sent, the Exim receiving process
3883 exits with a return code of zero. If not, the return code is 2 if the problem
3884 is that the original message has no recipients, or 1 any other error. This is
3885 the default \-oe$it{x}-\ option if Exim is called as \*rmail*\.
3886
3887 .option oem
3888 .index error||reporting
3889 .index return code||for \-oem-\
3890 This is the same as \-oee-\, except that Exim always exits with a non-zero
3891 return code, whether or not the error message was successfully sent.
3892 This is the default \-oe$it{x}-\ option, unless Exim is called as \*rmail*\.
3893
3894 .option oep
3895 .index error||reporting
3896 If an error is detected while a non-SMTP message is being received, the
3897 error is reported by writing a message to the standard error file (stderr).
3898 .index return code||for \-oep-\
3899 The return code is 1 for all errors.
3900
3901 .option oeq
3902 .index error||reporting
3903 This option is supported for compatibility with Sendmail, but has the same
3904 effect as \-oep-\.
3905
3906 .option oew
3907 .index error||reporting
3908 This option is supported for compatibility with Sendmail, but has the same
3909 effect as \-oem-\.
3910
3911 .option oi
3912 .index dot||in incoming, non-SMTP message
3913 This option, which has the same effect as \-i-\, specifies that a dot on a line
3914 by itself should not terminate an incoming, non-SMTP message.
3915 Otherwise, a single dot does terminate, though Exim does no special processing
3916 for other lines that start with a dot.
3917 This option is set by default if Exim is called as \*rmail*\. See also \-ti-\.
3918
3919 .option oitrue
3920 This option is treated as synonymous with \-oi-\.
3921
3922 .option oMa #<<host address>>
3923 .index sender||host address, specifying for local message
3924 A number of options starting with \-oM-\ can be used to set values associated
3925 with remote hosts on locally-submitted messages (that is, messages not received
3926 over TCP/IP). These options can be used by any caller in conjunction with the
3927 \-bh-\,
3928 \-be-\,
3929 \-bf-\, \-bF-\, \-bt-\, or \-bv-\ testing options. In other circumstances, they
3930 are ignored unless the caller is trusted.
3931
3932 The \-oMa-\ option sets the sender host address. This may include a port number
3933 at the end, after a full stop (period). For example:
3934 .display asis
3935 exim -bs -oMa 10.9.8.7.1234
3936 .endd
3937 An alternative syntax is to enclose the IP address in square brackets, followed
3938 by a colon and the port number:
3939 .display asis
3940 exim -bs -oMa [10.9.8.7]:1234
3941 .endd
3942 The IP address is placed in the \$sender@_host@_address$\ variable, and the
3943 port, if present, in \$sender@_host@_port$\.
3944
3945 .option oMaa #<<name>>
3946 .index authentication||name, specifying for local message
3947 See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMaa-\
3948 option sets the value of \$sender@_host@_authenticated$\ (the authenticator
3949 name). See chapter ~~CHAPSMTPAUTH for a discussion of SMTP authentication.
3950
3951 .option oMai #<<string>>
3952 .index authentication||id, specifying for local message
3953 See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMai-\
3954 option sets the
3955 value of \$authenticated@_id$\ (the id that was authenticated).
3956 This overrides the default value (the caller's login id) for messages from
3957 local sources. See chapter ~~CHAPSMTPAUTH for a discussion of authenticated
3958 ids.
3959
3960 .option oMas #<<address>>
3961 .index authentication||sender, specifying for local message
3962 See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMas-\
3963 option sets the authenticated sender value
3964 in \$authenticated@_sender$\.
3965 It overrides the sender address that is created from the caller's login id for
3966 messages from local sources. See chapter ~~CHAPSMTPAUTH for a discussion of
3967 authenticated senders.
3968
3969 .option oMi #<<interface address>>
3970 .index interface||address, specifying for local message
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-\.
3974 The interface address is placed in \$interface@_address$\ and the port number,
3975 if present, in \$interface@_port$\.
3976
3977 .option oMr #<<protocol name>>
3978 .index protocol||incoming, specifying for local message
3979 See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMr-\
3980 option sets the received protocol value that is stored in
3981 \$received@_protocol$\. However, this applies only when \-bs-\ is not used. For
3982 interactive SMTP input (\-bs-\), the protocol is always
3983 .em
3984 `local-' followed by one of the standard SMTP protocol names (see the 
3985 description of \$received@_protocol$\ in section ~~SECTexpvar).
3986 .nem
3987 For \-bS-\ (batch SMTP) however, the protocol can be set by \-oMr-\.
3988
3989 .option oMs #<<host name>>
3990 .index sender||host name, specifying for local message
3991 See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMs-\
3992 option sets the sender host name
3993 in \$sender@_host@_name$\. When this option is present, Exim does not attempt
3994 to look up a host name from an IP address; it uses the name it is given.
3995
3996 .option oMt #<<ident string>>
3997 .index sender||ident string, specifying for local message
3998 See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMt-\
3999 option sets the sender ident value
4000 in \$sender@_ident$\.
4001 The default setting for local callers is the login id of the calling process.
4002
4003 .option om
4004 .index Sendmail compatibility||\-om-\ option ignored
4005 In Sendmail, this option means `me too', indicating that the sender of a
4006 message should receive a copy of the message if the sender appears in an alias
4007 expansion. Exim always does this, so the option does nothing.
4008
4009 .option oo
4010 .index Sendmail compatibility||\-oo-\ option ignored
4011 This option is ignored. In Sendmail it specifies `old style headers', whatever
4012 that means.
4013
4014 .option oP #<<path>>
4015 .index pid (process id)||of daemon
4016 .index daemon||process id (pid)
4017 This option is useful only in conjunction with \-bd-\ or \-q-\ with a time
4018 value. The option specifies the file to which the process id of the daemon is
4019 written. When \-oX-\ is used with \-bd-\, or when \-q-\ with a time is used
4020 without \-bd-\, this is the only way of causing Exim to write a pid file,
4021 because in those cases, the normal pid file is not used.
4022
4023 .option or #<<time>>
4024 .index timeout||for non-SMTP input
4025 This option sets a timeout value for incoming non-SMTP messages. If it is not
4026 set, Exim will wait forever for the standard input. The value can also be set
4027 by the \receive@_timeout\ option. The format used for specifying times is
4028 described in section ~~SECTtimeformat.
4029
4030 .option os #<<time>>
4031 .index timeout||for SMTP input
4032 .index SMTP||timeout, input
4033 This option sets a timeout value for incoming SMTP messages. The timeout
4034 applies to each SMTP command and block of data. The value can also be set by
4035 the \smtp@_receive@_timeout\ option; it defaults to 5 minutes. The format used
4036 for specifying times is described in section ~~SECTtimeformat.
4037
4038 .option ov
4039 This option has exactly the same effect as \-v-\.
4040
4041 .option oX #<<number or string>>
4042 .index TCP/IP||setting listening ports
4043 .index TCP/IP||setting listening interfaces
4044 .index port||receiving TCP/IP
4045 This option is relevant only when the \-bd-\ (start listening daemon) option is
4046 also given. It controls which ports and interfaces the daemon uses. Details of
4047 the syntax, and how it interacts with configuration file options, are given in
4048 chapter ~~CHAPinterfaces. When \-oX-\ is used to start a daemon, no pid file is
4049 written unless \-oP-\ is also present to specify a pid file name.
4050
4051 .option pd
4052 .index Perl||starting the interpreter
4053 This option applies when an embedded Perl interpreter is linked with Exim (see
4054 chapter ~~CHAPperl). It overrides the setting of the \perl@_at@_start\ option,
4055 forcing the starting of the interpreter to be delayed until it is needed.
4056
4057 .option ps
4058 .index Perl||starting the interpreter
4059 This option applies when an embedded Perl interpreter is linked with Exim (see
4060 chapter ~~CHAPperl). It overrides the setting of the \perl@_at@_start\ option,
4061 forcing the starting of the interpreter to occur as soon as Exim is started.
4062
4063 .option p<<rval>>:<<sval>>
4064 For compatibility with Sendmail, this option
4065 is equivalent to
4066 .display
4067 -oMr <<rval>> -oMs <<sval>>
4068 .endd
4069 It sets the incoming protocol and host name (for trusted callers). The
4070 host name and its colon can be omitted when only the protocol is to be set.
4071 Note the Exim already has two private options, \-pd-\ and \-ps-\, that refer to
4072 embedded Perl. It is therefore impossible to set a protocol value of \"p"\ or
4073 \"s"\ using this option (but that does not seem a real limitation).
4074
4075 .option q
4076 .index queue runner||starting manually
4077 This option is normally restricted to admin users. However, there is a
4078 configuration option called \prod@_requires@_admin\ which can be set false to
4079 relax this restriction (and also the same requirement for the \-M-\, \-R-\, and
4080 \-S-\ options).
4081
4082 .index queue runner||description of operation
4083 The \-q-\ option starts one queue runner process. This scans the queue of
4084 waiting messages, and runs a delivery process for each one in turn. It waits
4085 for each delivery process to finish before starting the next one. A delivery
4086 process may not actually do any deliveries if the retry times for the addresses
4087 have not been reached. Use \-qf-\ (see below) if you want to override this.
4088 .index SMTP||passed connection
4089 .index SMTP||multiple deliveries
4090 .index multiple SMTP deliveries
4091 If the delivery process spawns other processes to deliver other messages down
4092 passed SMTP connections, the queue runner waits for these to finish before
4093 proceeding.
4094
4095 When all the queued messages have been considered, the original queue runner
4096 process terminates. In other words, a single pass is made over the waiting
4097 mail, one message at a time. Use \-q-\ with a time (see below) if you want this
4098 to be repeated periodically.
4099
4100 Exim processes the waiting messages in an unpredictable order. It isn't very
4101 random, but it is likely to be different each time, which is all that matters.
4102 If one particular message screws up a remote MTA, other messages to the same
4103 MTA have a chance of getting through if they get tried first.
4104
4105 It is possible to cause the messages to be processed in lexical message id
4106 order, which is essentially the order in which they arrived, by setting the
4107 \queue@_run@_in@_order\ option, but this is not recommended for normal use.
4108
4109 .option q <<qflags>>
4110 The \-q-\ option may be followed by one or more flag letters that change its
4111 behaviour. They are all optional, but if more than one is present, they must
4112 appear in the correct order. Each flag is described in a separate item below.
4113
4114 .option qq...
4115 .index queue||double scanning
4116 .index queue||routing
4117 .index routing||whole queue before delivery
4118 An option starting with \-qq-\ requests a two-stage queue run. In the first
4119 stage, the queue is scanned as if the \queue@_smtp@_domains\ option matched
4120 every domain. Addresses are routed, local deliveries happen, but no remote
4121 transports are run.
4122 .index hints database||remembering routing
4123 The hints database that remembers which messages are
4124 waiting for specific hosts is updated, as if delivery to those hosts had been
4125 deferred. After this is complete, a second, normal queue scan happens, with
4126 routing and delivery taking place as normal. Messages that are routed to the
4127 same host should mostly be delivered down a single SMTP
4128 .index SMTP||passed connection
4129 .index SMTP||multiple deliveries
4130 .index multiple SMTP deliveries
4131 connection because of the hints that were set up during the first queue scan.
4132 This option may be useful for hosts that are connected to the Internet
4133 intermittently.
4134
4135 .option q[q]i...
4136 .index queue||initial delivery
4137 If the \*i*\ flag is present, the queue runner runs delivery processes only for
4138 those messages that haven't previously been tried. (\*i*\ stands for `initial
4139 delivery'.) This can be helpful if you are putting messages on the queue using
4140 \-odq-\ and want a queue runner just to process the new messages.
4141
4142 .option q[q][i]f...
4143 .index queue||forcing delivery
4144 .index delivery||forcing in queue run
4145 If one \*f*\ flag is present, a delivery attempt is forced for each non-frozen
4146 message, whereas without \f\ only those non-frozen addresses that have passed
4147 their retry times are tried.
4148
4149 .option q[q][i]ff...
4150 .index frozen messages||forcing delivery
4151 If \*ff*\ is present, a delivery attempt is forced for every message, whether
4152 frozen or not.
4153
4154 .option q[q][i][f[f]]l
4155 .index queue||local deliveries only
4156 The \*l*\ (the letter `ell') flag specifies that only local deliveries are to be
4157 done. If a message requires any remote deliveries, it remains on the queue for
4158 later delivery.
4159
4160 .option q <<qflags>>#<<start id>>#<<end id>>
4161 .index queue||delivering specific messages
4162 When scanning the queue, Exim can be made to skip over messages whose ids are
4163 lexically less than a given value by following the \-q-\ option with a starting
4164 message id. For example:
4165 .display
4166 exim -q 0t5C6f-0000c8-00
4167 .endd
4168 Messages that arrived earlier than \"0t5C6f-0000c8-00"\ are not inspected. If a
4169 second message id is given, messages whose ids are lexically greater than it
4170 are also skipped. If the same id is given twice, for example,
4171 .display
4172 exim -q 0t5C6f-0000c8-00 0t5C6f-0000c8-00
4173 .endd
4174 just one delivery process is started, for that message. This differs from \-M-\
4175 in that retry data is respected, and it also differs from \-Mc-\ in that it
4176 counts as a delivery from a queue run. Note that the selection mechanism does
4177 not affect the order in which the messages are scanned. There are also other
4178 ways of selecting specific sets of messages for delivery in a queue run -- see
4179 \-R-\ and \-S-\.
4180
4181 .option q <<qflags>><<time>>
4182 .index queue runner||starting periodically
4183 .index periodic queue running
4184 When a time value is present, the \-q-\ option causes Exim to run as a daemon,
4185 starting a queue runner process at intervals specified by the given time value
4186 (whose format is described in section ~~SECTtimeformat). This form of the \-q-\
4187 option is commonly combined with the \-bd-\ option, in which case a single
4188 daemon process handles both functions. A common way of starting up a combined
4189 daemon at system boot time is to use a command such as
4190 .display
4191 /usr/exim/bin/exim -bd -q30m
4192 .endd
4193 Such a daemon listens for incoming SMTP calls, and also starts a queue runner
4194 process every 30 minutes.
4195
4196 When a daemon is started by \-q-\ with a time value, but without \-bd-\, no pid
4197 file is written unless one is explicitly requested by the \-oP-\ option.
4198
4199 .option qR <<rsflags>>#<<string>>
4200 This option is synonymous with \-R-\. It is provided for Sendmail
4201 compatibility.
4202
4203 .option qS <<rsflags>>#<<string>>
4204 This option is synonymous with \-S-\.
4205
4206 .option R <<rsflags>>#<<string>>
4207 .index queue runner||for specific recipients
4208 .index delivery||to given domain
4209 .index domain||delivery to
4210 The <<rsflags>> may be empty, in which case the white space before the string
4211 is optional, unless the string is \*f*\, \*ff*\, \*r*\, \*rf*\, or \*rff*\,
4212 which are the possible values for <<rsflags>>. White space is required if
4213 <<rsflags>> is not empty.
4214
4215 This option is similar to \-q-\ with no time value, that is, it causes Exim to
4216 perform a single queue run, except that, when scanning the messages on the
4217 queue, Exim processes only those that have at least one undelivered recipient
4218 address containing the given string, which is checked in a case-independent
4219 way. If the <<rsflags>> start with \*r*\, <<string>> is interpreted as a regular
4220 expression; otherwise it is a literal string.
4221
4222 Once a message is selected, all its addresses are processed. For the first
4223 selected message, Exim overrides any retry information and forces a delivery
4224 attempt for each undelivered address. This means that if delivery of any
4225 address in the first message is successful, any existing retry information is
4226 deleted, and so delivery attempts for that address in subsequently selected
4227 messages (which are processed without forcing) will run. However, if delivery
4228 of any address does not succeed, the retry information is updated, and in
4229 subsequently selected messages, the failing address will be skipped.
4230
4231 If the <<rsflags>> contain \*f*\ or \*ff*\, the delivery forcing applies to all
4232 selected messages, not just the first;
4233 .index frozen messages||forcing delivery
4234 frozen messages are included when \*ff*\ is present.
4235
4236 The \-R-\ option makes it straightforward to initiate delivery of all messages
4237 to a given domain after a host has been down for some time. When the SMTP
4238 command \\ETRN\\ is accepted by its ACL (see chapter ~~CHAPACL), its default
4239 effect is to run Exim with the \-R-\ option, but it can be configured to run an
4240 arbitrary command instead.
4241
4242 .option r
4243 This is a documented (for Sendmail) obsolete alternative name for \-f-\.
4244
4245 .index delivery||from given sender
4246 .option S <<rsflags>>#<<string>>
4247 .index queue runner||for specific senders
4248 This option acts like \-R-\ except that it checks the string against each
4249 message's sender instead of against the recipients. If \-R-\ is also set, both
4250 conditions must be met for a message to be selected. If either of the options
4251 has \*f*\ or \*ff*\ in its flags, the associated action is taken.
4252
4253 .option Tqt#<<times>>
4254 This an option that is exclusively for use by the Exim testing suite.
4255 It is not recognized when Exim is run normally. It allows for the setting up
4256 of explicit `queue times' so that various warning/retry features can be
4257 tested.
4258
4259 .option t
4260 .index recipient||extracting from header lines
4261 .index ::Bcc:: header line
4262 .index ::Cc:: header line
4263 .index ::To:: header line
4264 When Exim is receiving a locally-generated, non-SMTP message on its standard
4265 input, the \-t-\ option causes the recipients of the message to be obtained
4266 from the ::To::, ::Cc::, and ::Bcc:: header lines in the message instead of from
4267 the command arguments. The addresses are extracted before any rewriting takes
4268 place.
4269
4270 .index Sendmail compatibility||\-t-\ option
4271 If the command has any arguments, they specify addresses to which the message
4272 is $it{not} to be delivered. That is, the argument addresses are removed from
4273 the recipients list obtained from the headers. This is compatible with Smail 3
4274 and in accordance with the documented behaviour of several versions of
4275 Sendmail, as described in man pages on a number of operating systems (e.g.
4276 Solaris 8, IRIX 6.5, HP-UX 11). However, some versions of Sendmail $it{add}
4277 argument addresses to those obtained from the headers, and the O'Reilly
4278 Sendmail book documents it that way. Exim can be made to add argument addresses
4279 instead of subtracting them by setting the option
4280 \extract__addresses__remove__arguments\ false.
4281
4282 If a ::Bcc:: header line is present, it is removed from the message unless
4283 there is no ::To:: or ::Cc::, in which case a ::Bcc:: line with no data is
4284 created. This is necessary for conformity with the original RFC 822 standard;
4285 the requirement has been removed in RFC 2822, but that is still very new.
4286
4287 .index \Resent@-\ header lines||with \-t-\
4288 If there are any \Resent@-\ header lines in the message, Exim extracts
4289 recipients from all ::Resent-To::, ::Resent-Cc::, and ::Resent-Bcc:: header
4290 lines instead of from ::To::, ::Cc::, and ::Bcc::. This is for compatibility
4291 with Sendmail and other MTAs. (Prior to release 4.20, Exim gave an error if
4292 \-t-\ was used in conjunction with \Resent@-\ header lines.)
4293
4294 RFC 2822 talks about different sets of \Resent@-\ header lines (for when a
4295 message is resent several times). The RFC also specifies that they should be
4296 added at the front of the message, and separated by ::Received:: lines. It is
4297 not at all clear how \-t-\ should operate in the present of multiple sets,
4298 nor indeed exactly what constitutes a `set'.
4299 In practice, it seems that MUAs do not follow the RFC. The \Resent@-\ lines are
4300 often added at the end of the header, and if a message is resent more than
4301 once, it is common for the original set of \Resent@-\ headers to be renamed as
4302 \X-Resent@-\ when a new set is added. This removes any possible ambiguity.
4303
4304 .option ti
4305 This option is exactly equivalent to \-t-\ \-i-\. It is provided for
4306 compatibility with Sendmail.
4307
4308 .option tls-on-connect
4309 .index TLS||use without STARTTLS
4310 .index TLS||automatic start
4311 This option is available when Exim is compiled with TLS support. 
4312 .em
4313 It forces all incoming SMTP connections to behave as if the incoming port is
4314 listed in the \tls@_on@_connect@_ports\ option. See section ~~SECTsupobssmt and 
4315 chapter ~~CHAPTLS for further details.
4316 .nem
4317
4318 .option U
4319 .index Sendmail compatibility||\-U-\ option ignored
4320 Sendmail uses this option for `initial message submission', and its
4321 documentation states that in future releases, it may complain about
4322 syntactically invalid messages rather than fixing them when this flag is not
4323 set. Exim ignores this option.
4324
4325 .option v
4326 This option causes Exim to write information to the standard error stream,
4327 describing what it is doing. In particular, it shows the log lines for
4328 receiving and delivering a message, and if an SMTP connection is made, the SMTP
4329 dialogue is shown. Some of the log lines shown may not actually be written to
4330 the log if the setting of \log@_selector\ discards them. Any relevant selectors
4331 are shown with each log line. If none are shown, the logging is unconditional.
4332
4333 .option x
4334 AIX uses \-x-\ for a private purpose (`mail from a local mail program has
4335 National Language Support extended characters in the body of the mail item').
4336 It sets \-x-\ when calling the MTA from its \mail\ command. Exim ignores this
4337 option.
4338
4339 .endoptions
4340
4341
4342
4343 .
4344 .
4345 .
4346 .
4347 . ============================================================================
4348 .chapter The Exim run time configuration file
4349 .set runningfoot "configuration file"
4350 .rset CHAPconf ~~chapter
4351
4352 .index run time configuration
4353 .index configuration file||general description
4354 .index \\CONFIGURE@_FILE\\
4355 .index configuration file||errors in
4356 .index error||in configuration file
4357 .index return code||for bad configuration
4358 Exim uses a single run time configuration file that is read whenever an Exim
4359 binary is executed. Note that in normal operation, this happens frequently,
4360 because Exim is designed to operate in a distributed manner, without central
4361 control.
4362
4363 .em
4364 If a syntax error is detected while reading the configuration file, Exim
4365 writes a message on the standard error, and exits with a non-zero return code.
4366 The message is also written to the panic log. \**Note**\: only simple syntax 
4367 errors can be detected at this time. The values of any expanded options are
4368 not checked until the expansion happens, even when the expansion does not
4369 actually alter the string.
4370 .nem
4371
4372
4373 The name of the configuration file is compiled into the binary for security
4374 reasons, and is specified by the \\CONFIGURE@_FILE\\ compilation option. In
4375 most configurations, this specifies a single file. However, it is permitted to
4376 give a colon-separated list of file names, in which case Exim uses the first
4377 existing file in the list.
4378
4379 .index \\EXIM@_USER\\
4380 .index \\EXIM@_GROUP\\
4381 .index \\CONFIGURE@_OWNER\\
4382 .index \\CONFIGURE@_GROUP\\
4383 .index configuration file||ownership
4384 .index ownership||configuration file
4385 The run time configuration file must be owned by root or by the user that is
4386 specified at compile time by the \\EXIM@_USER\\ option, or by the user that is
4387 specified at compile time by the \\CONFIGURE@_OWNER\\ option (if set). The
4388 configuration file must not be world-writeable or group-writeable, unless its
4389 group is the one specified at compile time by the \\EXIM@_GROUP\\ option
4390 .em
4391 or by the \\CONFIGURE@_GROUP\\ option.
4392 .nem
4393
4394 \**Warning**\: In a conventional configuration, where the Exim binary is setuid
4395 to root, anybody who is able to edit the run time configuration file has an
4396 easy way to run commands as root. If you make your mail administrators members
4397 of the Exim group, but do not trust them with root, make sure that the run time
4398 configuration is not group writeable.
4399
4400 A default configuration file, which will work correctly in simple situations,
4401 is provided in the file \(src/configure.default)\. If \\CONFIGURE@_FILE\\
4402 defines just one file name, the installation process copies the default
4403 configuration to a new file of that name if it did not previously exist. If
4404 \\CONFIGURE@_FILE\\ is a list, no default is automatically installed. Chapter
4405 ~~CHAPdefconfil is a `walk-through' discussion of the default configuration.
4406
4407
4408 .section Using a different configuration file
4409 .index configuration file||alternate
4410 A one-off alternate configuration can be specified by the \-C-\ command line
4411 option, which may specify a single file or a list of files. However, when \-C-\
4412 is used, Exim gives up its root privilege, unless called by root or the Exim
4413 user (or unless the argument for \-C-\ is identical to the built-in value from
4414 \\CONFIGURE@_FILE\\). \-C-\ is useful mainly for checking the syntax of
4415 configuration files before installing them. No owner or group checks are done
4416 on a configuration file specified by \-C-\.
4417
4418 The privileged use of \-C-\ by the Exim user can be locked out by setting
4419 \\ALT@_CONFIG@_ROOT@_ONLY\\ in \(Local/Makefile)\ when building Exim. However,
4420 if you do this, you also lock out the possibility of testing a
4421 configuration using \-C-\ right through message reception and delivery, even if
4422 the caller is root. The reception works, but by that time, Exim is running as
4423 the Exim user, so when it re-execs to regain privilege for the delivery, the
4424 use of \-C-\ causes privilege to be lost. However, root can test reception and
4425 delivery using two separate commands (one to put a message on the queue, using
4426 \-odq-\, and another to do the delivery, using \-M-\).
4427
4428 If \\ALT@_CONFIG@_PREFIX\\ is defined \(in Local/Makefile)\, it specifies a
4429 prefix string with which any file named in a \-C-\ command line option must
4430 start. In addition, the file name must not contain the sequence \"/../"\. There
4431 is no default setting for \\ALT@_CONFIG@_PREFIX\\; when it is unset, any file
4432 name can be used with \-C-\.
4433
4434 One-off changes to a configuration can be specified by the \-D-\ command line
4435 option, which defines and overrides values for macros used inside the
4436 configuration file. However, like \-C-\, the use of this option by a
4437 non-privileged user causes Exim to discard its root privilege.
4438 If \\DISABLE@_D@_OPTION\\ is defined in \(Local/Makefile)\, the use of \-D-\ is
4439 completely disabled, and its use causes an immediate error exit.
4440
4441 Some sites may wish to use the same Exim binary on different machines that
4442 share a file system, but to use different configuration files on each machine.
4443 If \\CONFIGURE@_FILE@_USE@_NODE\\ is defined in \(Local/Makefile)\, Exim first
4444 looks for a file whose name is the configuration file name followed by a dot
4445 and the machine's node name, as obtained from the \*uname()*\ function. If this
4446 file does not exist, the standard name is tried. This processing occurs for
4447 each file name in the list given by \\CONFIGURE@_FILE\\ or \-C-\.
4448
4449 In some esoteric situations different versions of Exim may be run under
4450 different effective uids and the \\CONFIGURE@_FILE@_USE@_EUID\\ is defined to
4451 help with this. See the comments in \(src/EDITME)\ for details.
4452
4453
4454 .section Configuration file format
4455 .rset SECTconffilfor "~~chapter.~~section"
4456 .index configuration file||format of
4457 .index format||configuration file
4458 Exim's configuration file is divided into a number of different parts. General
4459 option settings must always appear at the start of the file. The other parts
4460 are all optional, and may appear in any order. Each part other than the first
4461 is introduced by the word `begin' followed by the name of the part. The
4462 optional parts are:
4463
4464 .numberpars $.
4465 \*ACL*\: Access control lists for controlling incoming SMTP mail.
4466 .nextp
4467 .index \\AUTH\\||configuration
4468 \*authenticators*\: Configuration settings for the authenticator drivers. These
4469 are concerned with the SMTP \\AUTH\\ command (see chapter ~~CHAPSMTPAUTH).
4470 .nextp
4471 \*routers*\: Configuration settings for the router drivers. Routers process
4472 addresses and determine how the message is to be delivered.
4473 .nextp
4474 \*transports*\: Configuration settings for the transport drivers. Transports
4475 define mechanisms for copying messages to destinations.
4476 .nextp
4477 \*retry*\: Retry rules, for use when a message cannot be immediately delivered.
4478 .nextp
4479 \*rewrite*\: Global address rewriting rules, for use when a message arrives and
4480 when new addresses are generated during delivery.
4481 .nextp
4482 \*local@_scan*\: Private options for the \*local@_scan()*\ function. If you
4483 want to use this feature, you must set
4484 .display asis
4485 LOCAL_SCAN_HAS_OPTIONS=yes
4486 .endd
4487 in \(Local/Makefile)\ before building Exim. Full details of the
4488 \*local@_scan()*\ facility are given in chapter ~~CHAPlocalscan.
4489 .endp
4490 .index configuration file||leading whitespace in
4491 .index configuration file||trailing whitespace in
4492 .index whitespace||in configuration file
4493 .em
4494 Leading and trailing whitespace in configuration lines is always ignored.
4495 .nem
4496 Blank lines in the file, and lines starting with a @# character (ignoring
4497 leading white space) are treated as comments and are ignored. \**Note**\: a
4498 @# character other than at the beginning of a line is not treated specially,
4499 and does not introduce a comment.
4500
4501 Any non-comment line can be continued by ending it with a backslash. 
4502 .em
4503 Note that the general rule for whitespace means that trailing white space after
4504 the backslash is ignored, and leading white space at the start of continuation
4505 lines is also ignored.
4506 .nem
4507 Comment lines beginning with @# (but not empty lines) may appear in the middle
4508 of a sequence of continuation lines.
4509
4510 A convenient way to create a configuration file is to start from the
4511 default, which is supplied in \(src/configure.default)\, and add, delete, or
4512 change settings as required.
4513
4514 The ACLs, retry rules, and rewriting rules have their own syntax which is
4515 described in chapters ~~CHAPACL, ~~CHAPretry, and ~~CHAPrewrite, respectively.
4516 The other parts of the configuration file have some syntactic items in common,
4517 and these are described below, from section ~~SECTcos onwards. Before that, the
4518 inclusion, macro, and conditional facilities are described.
4519
4520
4521 .section File inclusions in the configuration file
4522 .index inclusions in configuration file
4523 .index configuration file||including other files
4524 .index .include in configuration file
4525 .index .include@_if@_exists in configuration file
4526 You can include other files inside Exim's run time configuration file by
4527 using this syntax:
4528 .display
4529 @.include <<file name>>
4530 .endd
4531 or
4532 .display
4533 @.include@_if@_exists <<file name>>
4534 .endd
4535 on a line by itself. Double quotes round the file name are optional. If you use
4536 the first form, a configuration error occurs if the file does not exist; the
4537 second form does nothing for non-existent files.
4538
4539 Includes may be nested to any depth, but remember that Exim reads its
4540 configuration file often, so it is a good idea to keep them to a minimum.
4541 If you change the contents of an included file, you must HUP the daemon,
4542 because an included file is read only when the configuration itself is read.
4543
4544 The processing of inclusions happens early, at a physical line level, so, like
4545 comment lines, an inclusion can be used in the middle of an option setting,
4546 for example:
4547 .display asis
4548 hosts_lookup = a.b.c \
4549                .include /some/file
4550 .endd
4551 Include processing happens
4552 after
4553 macro processing (see below). Its effect is to process the lines of the file as
4554 if they occurred inline where the inclusion appears.
4555
4556
4557 .section Macros in the configuration file
4558 .rset SECTmacrodefs "~~chapter.~~section"
4559 .index macro||description of
4560 .index configuration file||macros
4561 If a line in the main part of the configuration (that is, before the first
4562 `begin' line) begins with an upper case letter, it is taken as a macro
4563 definition, and must be of the form
4564 .display
4565 <<name>> = <<rest of line>>
4566 .endd
4567 The name must consist of letters, digits, and underscores, and need not all be
4568 in upper case, though that is recommended. The rest of the line, including any
4569 continuations, is the replacement text, and has leading and trailing white
4570 space removed. Quotes are not removed. The replacement text can never end with
4571 a backslash character, but this doesn't seem to be a serious limitation.
4572
4573 Once a macro is defined, all subsequent lines in the file (and any included
4574 files) are scanned for the macro name; if there are several macros, the line is
4575 scanned for each in turn, in the order in which they are defined. The
4576 replacement text is not re-scanned for the current macro, though it is scanned
4577 for subsequently defined macros. For this reason, a macro name may not contain
4578 the name of a previously defined macro as a substring. You could, for example,
4579 define
4580 .display asis
4581 ABCD_XYZ = <<something>>
4582 ABCD = <<something else>>
4583 .endd
4584 but putting the definitions in the opposite order would provoke a configuration
4585 error.
4586
4587 Macro expansion is applied to individual lines from the file, before checking
4588 for line continuation or file inclusion (see below). If a line consists solely
4589 of a macro name, and the expansion of the macro is empty, the line is ignored.
4590 A macro at the start of a line may turn the line into a comment line or a
4591 \".include"\ line.
4592
4593 As an example of macro usage, consider a configuration where aliases are looked
4594 up in a MySQL database. It helps to keep the file less cluttered if long
4595 strings such as SQL statements are defined separately as macros, for example:
4596 .display asis
4597 ALIAS_QUERY = select mailbox from user where \
4598               login=${quote_mysql:$local_part};
4599 .endd
4600 This can then be used in a \%redirect%\ router setting like this:
4601 .display asis
4602 data = ${lookup mysql{ALIAS_QUERY}}
4603 .endd
4604 In earlier versions of Exim macros were sometimes used for domain, host, or
4605 address lists. In Exim 4 these are handled better by named lists -- see section
4606 ~~SECTnamedlists.
4607
4608 Macros in the configuration file can be overridden by the \-D-\ command line
4609 option, but Exim gives up its root privilege when \-D-\ is used, unless called
4610 by root or the Exim user.
4611
4612
4613 .section Conditional skips in the configuration file
4614 .index configuration file||conditional skips
4615 .index .ifdef
4616 You can use the directives \".ifdef"\, \".ifndef"\, \".elifdef"\,
4617 \".elifndef"\, \".else"\, and \".endif"\ to dynamically include or exclude
4618 portions of the configuration file. The processing happens whenever the file is
4619 read (that is, when an Exim binary starts to run).
4620
4621 The implementation is very simple. Instances of the first four directives must
4622 be followed by text that includes the names of one or macros. The condition
4623 that is tested is whether or not any macro substitution has taken place in the
4624 line. Thus:
4625 .display
4626 @.ifdef AAA
4627 message@_size@_limit = 50M
4628 @.else
4629 message@_size@_limit = 100M
4630 @.endif
4631 .endd
4632 sets a message size limit of 50M if the macro \"AAA"\ is defined, and 100M
4633 otherwise. If there is more than one macro named on the line, the condition
4634 is true if any of them are defined. That is, it is an `or' condition. To
4635 obtain an `and' condition, you need to use nested \".ifdef"\s.
4636
4637 Although you can use a macro expansion to generate one of these directives,
4638 it is not very useful, because the condition `there was a macro substitution
4639 in this line' will always be true.
4640
4641 Text following \".else"\ and \".endif"\ is ignored, and can be used as comment
4642 to clarify complicated nestings.
4643
4644
4645 .section Common option syntax
4646 .rset SECTcos "~~chapter.~~section"
4647 .index common option syntax
4648 .index syntax of common options
4649 .index configuration file||common option syntax
4650 For the main set of options, driver options, and \*local@_scan()*\ options,
4651 each setting is on a line by itself, and starts with a name consisting of
4652 lower-case letters and underscores. Many options require a data value, and in
4653 these cases the name must be followed by an equals sign (with optional white
4654 space) and then the value. For example:
4655 .display asis
4656 qualify_domain = mydomain.example.com
4657 .endd
4658 Some option settings may contain sensitive data, for example, passwords for
4659 accessing databases. To stop non-admin users from using the \-bP-\ command line
4660 option to read these values, you can precede the option settings with the word
4661 `hide'. For example:
4662 .display asis
4663 hide mysql_servers = localhost/users/admin/secret-password
4664 .endd
4665 For non-admin users, such options are displayed like this:
4666 .display asis
4667 mysql_servers = <value not displayable>
4668 .endd
4669 If `hide' is used on a driver option, it hides the value of that option on all
4670 instances of the same driver.
4671
4672 The following sections describe the syntax used for the different data types
4673 that are found in option settings.
4674
4675 .section Boolean options
4676 .index format||boolean
4677 .index boolean configuration values
4678 Options whose type is given as boolean are on/off switches. There are two
4679 different ways of specifying such options: with and without a data value. If
4680 the option name is specified on its own without data, the switch is turned on;
4681 if it is preceded by `no@_' or `not@_' the switch is turned off. However,
4682 boolean options may optionally be followed by an equals sign and one of the
4683 words `true', `false', `yes', or `no', as an alternative syntax. For example,
4684 the following two settings have exactly the same effect:
4685 .display asis
4686 queue_only
4687 queue_only = true
4688 .endd
4689 The following two lines also have the same (opposite) effect:
4690 .display asis
4691 no_queue_only
4692 queue_only = false
4693 .endd
4694 You can use whichever syntax you prefer.
4695
4696
4697
4698 .section Integer values
4699 .index integer configuration values
4700 .index format||integer
4701 If an integer data item starts with the characters `0x', the remainder of it
4702 is interpreted as a hexadecimal number. Otherwise, it is treated as octal if it
4703 starts with the digit 0, and decimal if not. If an integer value is followed by
4704 the letter K, it is multiplied by 1024; if it is followed by the letter M, it
4705 is multiplied by 1024x1024.
4706
4707 When the values of integer option settings are output, values which are an
4708 exact multiple of 1024 or 1024x1024 are
4709 sometimes, but not always,
4710 printed using the letters K and M. The printing style is independent of the
4711 actual input format that was used.
4712
4713 .section Octal integer values
4714 .index integer format
4715 .index format||octal integer
4716 The value of an option specified as an octal integer is always interpreted in
4717 octal, whether or not it starts with the digit zero. Such options are always
4718 output in octal.
4719
4720
4721 .section Fixed point number values
4722 .index fixed point configuration values
4723 .index format||fixed point
4724 A fixed point number consists of a decimal integer, optionally followed by a
4725 decimal point and up to three further digits.
4726
4727
4728 .section Time interval values
4729 .index time interval||specifying in configuration
4730 .index format||time interval
4731 .rset SECTtimeformat "~~chapter.~~section"
4732 A time interval is specified as a sequence of numbers, each followed by one of
4733 the following letters, with no intervening white space:
4734 .display rm
4735 .tabs 5
4736 \s\  $t seconds
4737 \m\  $t minutes
4738 \h\  $t hours
4739 \d\  $t days
4740 \w\  $t weeks
4741 .endd
4742 For example, `3h50m' specifies 3 hours and 50 minutes. The values of time
4743 intervals are output in the same format.
4744 Exim does not restrict the values; it is perfectly acceptable, for example, to
4745 specify `90m' instead of `1h30m'.
4746
4747
4748 .section String values
4749 .index string||format of configuration values
4750 .index format||string
4751 .rset SECTstrings "~~chapter.~~section"
4752 If a string data item does not start with a double-quote character, it is taken
4753 as consisting of the remainder of the line plus any continuation lines,
4754 starting at the first character after any leading white space, with trailing
4755 white space characters removed, and with no interpretation of the characters in
4756 the string. Because Exim removes comment lines (those beginning with @#) at an
4757 early stage, they can appear in the middle of a multi-line string. The
4758 following settings are therefore equivalent:
4759 .display asis
4760 trusted_users = uucp:mail
4761
4762 trusted_users = uucp:\
4763                 # This comment line is ignored
4764                 mail
4765 .endd
4766 .index string||quoted
4767 .index escape characters in quoted strings
4768 If a string does start with a double-quote, it must end with a closing
4769 double-quote, and any backslash characters other than those used for line
4770 continuation are interpreted as escape characters, as follows:
4771 .display
4772 .tabs 15
4773 @\@\   $t $rm{single backslash}
4774 @\n    $t $rm{newline}
4775 @\r    $t $rm{carriage return}
4776 @\t    $t $rm{tab}
4777 @\<<octal digits>> $t $rm{up to 3 octal digits specify one character}
4778 @\x<<hex digits>>  $t $rm{up to 2 hexadecimal digits specify one character}
4779 .endd
4780 If a backslash is followed by some other character, including a double-quote
4781 character, that character replaces the pair.
4782
4783 Quoting is necessary only if you want to make use of the backslash escapes to
4784 insert special characters, or if you need to specify a value with leading or
4785 trailing spaces. These cases are rare, so quoting is almost never needed in
4786 current versions of Exim. In versions of Exim before 3.14, quoting was required
4787 in order to continue lines, so you may come across older configuration files
4788 and examples that apparently quote unnecessarily.
4789
4790 .section Expanded strings
4791 .index string||expansion, definition of
4792 .index expansion||definition of
4793 Some strings in the configuration file are subjected to \*string expansion*\,
4794 by which means various parts of the string may be changed according to the
4795 circumstances (see chapter ~~CHAPexpand). The input syntax for such strings is
4796 as just described; in particular, the handling of backslashes in quoted strings
4797 is done as part of the input process, before expansion takes place. However,
4798 backslash is also an escape character for the expander, so any backslashes that
4799 are required for that reason must be doubled if they are within a quoted
4800 configuration string.
4801
4802 .section User and group names
4803 .index user name||format of
4804 .index format||user name
4805 .index group||name format
4806 .index format||group name
4807 User and group names are specified as strings, using the syntax described
4808 above, but the strings are interpreted specially. A user or group name must
4809 either consist entirely of digits, or be a name that can be looked up using the
4810 \*getpwnam()*\ or \*getgrnam()*\ function, as appropriate.
4811
4812 .section List construction
4813 .index list||syntax of in configuration
4814 .index format||list item in configuration
4815 .index string list, definition
4816 .rset SECTlistconstruct "~~chapter.~~section"
4817 The data for some configuration options is a list of items, with colon as the
4818 default separator. Many of these options are shown with type `string list' in
4819 the descriptions later in this document. Others are listed as `domain list',
4820 `host list', `address list', or `local part list'. Syntactically, they are all
4821 the same; however, those other than `string list' are subject to particular
4822 kinds of interpretation, as described in chapter ~~CHAPdomhosaddlists.
4823
4824 In all these cases, the entire list is treated as a single string as far as the
4825 input syntax is concerned. The \trusted@_users\ setting in section
4826 ~~SECTstrings above is an example. If a colon is actually needed in an item in
4827 a list, it must be entered as two colons. Leading and trailing white space on
4828 each item in a list is ignored. This makes it possible to include items that
4829 start with a colon, and in particular, certain forms of IPv6 address. For
4830 example, the list
4831 .display asis
4832 local_interfaces = 127.0.0.1 : ::::1
4833 .endd
4834 contains two IP addresses, the IPv4 address 127.0.0.1 and the IPv6 address
4835 @:@:1.
4836 .index list||separator, changing
4837 .index IPv6||addresses in lists
4838 Doubling colons in IPv6 addresses is an unwelcome chore, so a mechanism was
4839 introduced to allow the separator character to be changed. If a list begins
4840 with a left angle bracket, followed by any punctuation character, that
4841 character is used instead of colon as the list separator. For example, the list
4842 above can be rewritten to use a semicolon separator like this:
4843 .display asis
4844 local_interfaces = <; 127.0.0.1 ; ::1
4845 .endd
4846 This facility applies to all lists, with the exception of the list in
4847 \log@_file@_path\. It is recommended that the use of non-colon separators be
4848 confined to circumstances where they really are needed.
4849
4850
4851 .em
4852 .section Empty items in lists
4853 .rset SECTempitelis "~~chapter.~~section"
4854 .index list||empty item in
4855 An empty item at the end of a list is always ignored. In other words, trailing 
4856 separator characters are ignored. Thus, the list in
4857 .display asis
4858 senders = user@domain :
4859 .endd
4860 contains only a single item. If you want to include an empty string as one item 
4861 in a list, it must not be the last item. For example, this list contains three 
4862 items, the second of which is empty:
4863 .display asis
4864 senders = user1@domain : : user2@domain
4865 .endd
4866 \**Note**\: there must be whitespace between the two colons, as otherwise they
4867 are interpreted as representing a single colon data character (and the list 
4868 would then contain just one item). If you want to specify a list that contains 
4869 just one, empty item, you can do it as in this example:
4870 .display asis
4871 senders = :
4872 .endd
4873 In this case, the first item is empty, and the second is discarded because it 
4874 is at the end of the list.
4875 .nem
4876  
4877
4878 .section Format of driver configurations
4879 .rset SECTfordricon "~~chapter.~~section"
4880 .index drivers||configuration format
4881 There are separate parts in the configuration for defining routers, transports,
4882 and authenticators. In each part, you are defining a number of driver
4883 instances, each with its own set of options. Each driver instance is defined by
4884 a sequence of lines like this:
4885 .display
4886 <<instance name>>:
4887   <<option>>
4888   ...
4889   <<option>>
4890 .endd
4891 In the following example, the instance name is \%localuser%\, and it is
4892 followed by three options settings:
4893 .display asis
4894 localuser:
4895   driver = accept
4896   check_local_user
4897   transport = local_delivery
4898 .endd
4899 For each driver instance, you specify which Exim code module it uses -- by the
4900 setting of the \driver\ option -- and (optionally) some configuration settings.
4901 For example, in the case of transports, if you want a transport to deliver with
4902 SMTP you would use the \%smtp%\ driver; if you want to deliver to a local file
4903 you would use the \%appendfile%\ driver. Each of the drivers is described in
4904 detail in its own separate chapter later in this manual.
4905
4906 You can have several routers, transports, or authenticators that are based on
4907 the same underlying driver (each must have a different name).
4908
4909 The order in which routers are defined is important, because addresses are
4910 passed to individual routers one by one, in order. The order in which
4911 transports are defined does not matter at all. The order in which
4912 authenticators are defined is used only when Exim, as a client, is searching
4913 them to find one that matches an authentication mechanism offered by the
4914 server.
4915
4916 .index generic options
4917 .index options||generic, definition of
4918 Within a driver instance definition, there are two kinds of option:
4919 $it{generic} and $it{private}. The generic options are those that apply to all
4920 drivers of the same type (that is, all routers, all transports or all
4921 authenticators).
4922 The \driver\ option is a generic option that must appear in every definition.
4923 .index private options
4924 The private options are special for each driver, and none need appear, because
4925 they all have default values.
4926
4927 The options may appear in any order, except that the \driver\ option must
4928 precede any private options, since these depend on the particular driver. For
4929 this reason, it is recommended that \driver\ always be the first option.
4930
4931 Driver instance names, which are used for reference in log entries and
4932 elsewhere, can be any sequence of letters, digits, and underscores (starting
4933 with a letter) and must be unique among drivers of the same type. A router and
4934 a transport (for example) can each have the same name, but no two router
4935 instances can have the same name. The name of a driver instance should not be
4936 confused with the name of the underlying driver module. For example, the
4937 configuration lines:
4938 .display asis
4939 remote_smtp:
4940   driver = smtp
4941 .endd
4942 create an instance of the \%smtp%\ transport driver whose name is
4943 \%remote@_smtp%\. The same driver code can be used more than once, with
4944 different instance names and different option settings each time. A second
4945 instance of the \%smtp%\ transport, with different options, might be defined
4946 thus:
4947 .display asis
4948 special_smtp:
4949   driver = smtp
4950   port = 1234
4951   command_timeout = 10s
4952 .endd
4953 The names \%remote@_smtp%\ and \%special@_smtp%\ would be used to reference
4954 these transport instances from routers, and these names would appear in log
4955 lines.
4956
4957 Comment lines may be present in the middle of driver specifications. The full
4958 list of option settings for any particular driver instance, including all the
4959 defaulted values, can be extracted by making use of the \-bP-\ command line
4960 option.
4961
4962
4963
4964
4965
4966
4967 .
4968 .
4969 .
4970 .
4971 . ============================================================================
4972 .chapter The default configuration file
4973 .set runningfoot "default configuration"
4974 .rset CHAPdefconfil "~~chapter"
4975 .index configuration file||default, `walk through'
4976 .index default||configuration file `walk through'
4977 The default configuration file supplied with Exim as \(src/configure.default)\
4978 is sufficient for a host with simple mail requirements. As an introduction to
4979 the way Exim is configured, this chapter `walks through' the default
4980 configuration, giving brief explanations of the settings. Detailed descriptions
4981 of the options are given in subsequent chapters. The default configuration file
4982 itself contains extensive comments about ways you might want to modify the
4983 initial settings. However, note that there are many options that are not
4984 mentioned at all in the default configuration.
4985
4986
4987 .section Main configuration settings
4988 The main (global) configuration option settings must always come first in the
4989 file. The first thing you'll see in the file, after some initial comments, is
4990 the line
4991 .display asis
4992 # primary_hostname =
4993 .endd
4994 This is a commented-out setting of the \primary@_hostname\ option. Exim needs
4995 to know the official, fully qualified name of your host, and this is where you
4996 can specify it. However, in most cases you do not need to set this option. When
4997 it is unset, Exim uses the \*uname()*\ system function to obtain the host name.
4998
4999 The first three non-comment configuration lines are as follows:
5000 .display asis
5001 domainlist local_domains = @
5002 domainlist relay_to_domains =
5003 hostlist   relay_from_hosts = 127.0.0.1
5004 .endd
5005 These are not, in fact, option settings. They are definitions of two named
5006 domain lists and one named host list. Exim allows you to give names to lists of
5007 domains, hosts, and email addresses, in order to make it easier to manage the
5008 configuration file (see section ~~SECTnamedlists).
5009
5010 The first line defines a domain list called \*local@_domains*\; this is used
5011 later in the configuration to identify domains that are to be delivered
5012 on the local host.
5013 .index @@ in a domain list
5014 There is just one item in this list, the string `@@'. This is a special form of
5015 entry which means `the name of the local host'. Thus, if the local host is
5016 called \*a.host.example*\, mail to \*any.user@@a.host.example*\ is expected to
5017 be delivered locally. Because the local host's name is referenced indirectly,
5018 the same configuration file can be used on different hosts.
5019
5020 The second line defines a domain list called \*relay@_to@_domains*\, but the
5021 list itself is empty. Later in the configuration we will come to the part that
5022 controls mail relaying through the local host; it allows relaying to any
5023 domains in this list. By default, therefore, no relaying on the basis of a mail
5024 domain is permitted.
5025
5026 The third line defines a host list called \*relay@_from@_hosts*\. This list is
5027 used later in the configuration to permit relaying from any host or IP address
5028 that matches the list. The default contains just the IP address of the IPv4
5029 loopback interface, which means that processes on the local host are able to
5030 submit mail for relaying by sending it over TCP/IP to that interface. No other
5031 hosts are permitted to submit messages for relaying.
5032
5033 Just to be sure there's no misunderstanding: at this point in the configuration
5034 we aren't actually setting up any controls. We are just defining some domains
5035 and hosts that will be used in the controls that are specified later.
5036
5037 The next configuration line is a genuine option setting:
5038 .display asis
5039 acl_smtp_rcpt = acl_check_rcpt
5040 .endd
5041 This option specifies an \*Access Control List*\ (ACL) which is to be used
5042 during an incoming SMTP session for every recipient of a message (every
5043 \\RCPT\\ command). The name of the list is \*acl@_check@_rcpt*\, and we will
5044 come to its definition below, in the ACL section of the configuration. ACLs
5045 control which recipients are accepted for an incoming message -- if a
5046 configuration does not provide an ACL to check recipients, no SMTP mail can be
5047 accepted.
5048
5049 Two commented-out options settings are next:
5050 .display asis
5051 # qualify_domain =
5052 # qualify_recipient =
5053 .endd
5054 The first of these specifies a domain that Exim uses when it constructs a
5055 complete email address from a local login name. This is often needed when Exim
5056 receives a message from a local process. If you do not set \qualify@_domain\,
5057 the value of \primary@_hostname\ is used. If you set both of these options, you
5058 can have different qualification domains for sender and recipient addresses. If
5059 you set only the first one, its value is used in both cases.
5060
5061 .index domain literal||recognizing format
5062 The following line must be uncommented if you want Exim to recognize
5063 addresses of the form \*user@@[10.11.12.13]*\ that is, with a `domain literal'
5064 (an IP address) instead of a named domain.
5065 .display asis
5066 # allow_domain_literals
5067 .endd
5068 The RFCs still require this form, but many people think that in the modern
5069 Internet it makes little sense to permit mail to be sent to specific hosts by
5070 quoting their IP addresses. This ancient format has been used by people who
5071 try to abuse hosts by using them for unwanted relaying. However, some
5072 people believe there are circumstances (for example, messages addressed to
5073 \*postmaster*\) where domain literals are still useful.
5074
5075 The next configuration line is a kind of trigger guard:
5076 .display asis
5077 never_users = root
5078 .endd
5079 It specifies that no delivery must ever be run as the root user. The normal
5080 convention is to set up \*root*\ as an alias for the system administrator. This
5081 setting is a guard against slips in the configuration.
5082 The list of users specified by \never@_users\ is not, however, the complete
5083 list; the build-time configuration in \(Local/Makefile)\ has an option called
5084 \\FIXED@_NEVER@_USERS\\ specifying a list that cannot be overridden. The
5085 contents of \never@_users\ are added to this list. By default
5086 \\FIXED@_NEVER@_USERS\\ also specifies root.
5087
5088 When a remote host connects to Exim in order to send mail, the only information
5089 Exim has about the host's identity is its IP address. The next configuration
5090 line,
5091 .display asis
5092 host_lookup = *
5093 .endd
5094 specifies that Exim should do a reverse DNS lookup on all incoming connections,
5095 in order to get a host name. This improves the quality of the logging
5096 information, but if you feel it is too expensive, you can remove it entirely,
5097 or restrict the lookup to hosts on `nearby' networks.
5098 Note that it is not always possible to find a host name from an IP address,
5099 because not all DNS reverse zones are maintained, and sometimes DNS servers are
5100 unreachable.
5101
5102 The next two lines are concerned with \*ident*\ callbacks, as defined by RFC
5103 1413 (hence their names):
5104 .display asis
5105 rfc1413_hosts = *
5106 rfc1413_query_timeout = 30s
5107 .endd
5108 These settings cause Exim to make ident callbacks for all incoming SMTP calls.
5109 You can limit the hosts to which these calls are made, or change the timeout
5110 that is used. If you set the timeout to zero, all ident calls are disabled.
5111 Although they are cheap and can provide useful information for tracing problem
5112 messages, some hosts and firewalls have problems with ident calls. This can
5113 result in a timeout instead of an immediate refused connection, leading to
5114 delays on starting up an incoming SMTP session.
5115
5116 When Exim receives messages over SMTP connections, it expects all addresses to
5117 be fully qualified with a domain, as required by the SMTP definition. However,
5118 if you are running a server to which simple clients submit messages, you may
5119 find that they send unqualified addresses. The two commented-out options:
5120 .display asis
5121 # sender_unqualified_hosts =
5122 # recipient_unqualified_hosts =
5123 .endd
5124 show how you can specify hosts that are permitted to send unqualified sender
5125 and recipient addresses, respectively.
5126
5127 The \percent@_hack@_domains\ option is also commented out:
5128 .display asis
5129 # percent_hack_domains =
5130 .endd
5131 It provides a list of domains for which the `percent hack' is to operate. This
5132 is an almost obsolete form of explicit email routing. If you do not know
5133 anything about it, you can safely ignore this topic.
5134
5135 The last two settings in the main part of the default configuration are
5136 concerned with messages that have been `frozen' on Exim's queue. When a message
5137 is frozen, Exim no longer continues to try to deliver it. Freezing occurs when
5138 a bounce message encounters a permanent failure because the sender address of
5139 the original message that caused the bounce is invalid, so the bounce cannot be
5140 delivered. This is probably the most common case, but there are also other
5141 conditions that cause freezing, and frozen messages are not always bounce
5142 messages.
5143 .display asis
5144 ignore_bounce_errors_after = 2d
5145 timeout_frozen_after = 7d
5146 .endd
5147 The first of these options specifies that failing bounce messages are to be
5148 discarded after 2 days on the queue. The second specifies that any frozen
5149 message (whether a bounce message or not) is to be timed out (and discarded)
5150 after a week. In this configuration, the first setting ensures that no failing
5151 bounce message ever lasts a week.
5152
5153
5154 .section ACL configuration
5155 .index default||ACLs
5156 .index ~~ACL||default configuration
5157 In the default configuration, the ACL section follows the main configuration.
5158 It starts with the line
5159 .display asis
5160 begin acl
5161 .endd
5162 and it contains the definition of one ACL called \*acl@_check@_rcpt*\ that was
5163 referenced in the setting of \acl@_smtp@_rcpt\ above.
5164 .index \\RCPT\\||ACL for
5165 This ACL is used for every \\RCPT\\ command in an incoming SMTP message. Each
5166 \\RCPT\\ command specifies one of the message's recipients. The ACL statements
5167 are considered in order, until the recipient address is either accepted or
5168 rejected. The \\RCPT\\ command is then accepted or rejected, according to the
5169 result of the ACL processing.
5170 .display asis
5171 acl_check_rcpt:
5172 .endd
5173 This line, consisting of a name terminated by a colon, marks the start of the
5174 ACL, and names it.
5175 .display asis
5176 accept  hosts = :
5177 .endd
5178 This ACL statement accepts the recipient if the sending host matches the list.
5179 But what does that strange list mean? It doesn't actually contain any host
5180 names or IP addresses. The presence of the colon puts an empty item in the
5181 list; Exim matches this only if the incoming message didn't come from a remote
5182 host. The colon is important. Without it, the list itself is empty, and can
5183 never match anything.
5184
5185 What this statement is doing is to accept unconditionally all recipients in
5186 messages that are submitted by SMTP from local processes using the standard
5187 input and output (that is, not using TCP/IP). A number of MUAs operate in this
5188 manner.
5189 .display asis
5190 deny    domains       = +local_domains
5191         local_parts   = ^[.] : ^.*[@%!/|]
5192
5193 deny    domains       = !+local_domains
5194         local_parts   = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
5195 .endd
5196 These statements are concerned with local parts that contain any of the
5197 characters `@@', `%', `!', `/', `|', or dots in unusual places. Although these
5198 characters are entirely legal in local parts (in the case of `@@' and leading
5199 dots, only if correctly quoted), they do not commonly occur in Internet mail
5200 addresses.
5201
5202 The first three have in the past been associated with explicitly routed
5203 addresses (percent is still sometimes used -- see the \percent@_hack@_domains\
5204 option). Addresses containing these characters are regularly tried by spammers
5205 in an attempt to bypass relaying restrictions, and also by open relay testing
5206 programs. Unless you really need them it is safest to reject these characters
5207 at this early stage. This configuration is heavy-handed in rejecting these
5208 characters for all messages it accepts from remote hosts. This is a deliberate
5209 policy of being as safe as possible.
5210
5211 The first rule above is stricter, and is applied to messages that are addressed
5212 to one of the local domains handled by this host. This is implemented by the
5213 first condition, which restricts it to domains that are listed in the
5214 \*local@_domains*\ domain list. The `+' character is used to indicate a
5215 reference to a named list. In this configuration, there is just one domain in
5216 \*local@_domains*\, but in general there may be many.
5217
5218 The second condition on the first statement uses two regular expressions to
5219 block local parts that begin with a dot or contain `@@', `%', `!', `/', or `|'.
5220 If you have local accounts that include these characters, you will have to
5221 modify this rule.
5222
5223 Empty components (two dots in a row) are not valid in RFC 2822, but Exim
5224 allows them because they have been encountered in practice. (Consider local
5225 parts constructed as `first-initial.second-initial.family-name' when applied to
5226 someone like the author of Exim, who has no second initial.) However, a local
5227 part starting with a dot or containing `/../' can cause trouble if it is used
5228 as part of a file name (for example, for a mailing list). This is also true for
5229 local parts that contain slashes. A pipe symbol can also be troublesome if the
5230 local part is incorporated unthinkingly into a shell command line.
5231
5232 The second rule above applies to all other domains, and is less strict. This
5233 allows your own users to send outgoing messages to sites that use slashes
5234 and vertical bars in their local parts. It blocks local parts that begin
5235 with a dot, slash, or vertical bar, but allows these characters within the
5236 local part. However, the sequence `/../' is barred. The use of `@@', `%', and
5237 `!' is blocked, as before. The motivation here is to prevent your users (or
5238 your users' viruses) from mounting certain kinds of attack on remote sites.
5239
5240 .display asis
5241 accept  local_parts   = postmaster
5242         domains       = +local_domains
5243 .endd
5244 This statement, which has two conditions, accepts an incoming address if the
5245 local part is \*postmaster*\ and the domain is one of those listed in the
5246 \*local@_domains*\ domain list. The `+' character is used to indicate a
5247 reference to a named list. In this configuration, there is just one domain in
5248 \*local@_domains*\, but in general there may be many.
5249
5250 The presence of this statement means that mail to postmaster is never blocked
5251 by any of the subsequent tests. This can be helpful while sorting out problems
5252 in cases where the subsequent tests are incorrectly denying access.
5253 .display asis
5254 require verify        = sender
5255 .endd
5256 This statement requires the sender address to be verified before any subsequent
5257 ACL statement can be used. If verification fails, the incoming recipient
5258 address is refused. Verification consists of trying to route the address, to
5259 see if a
5260 bounce
5261 message could be delivered to it. In the case of remote addresses, basic
5262 verification checks only the domain, but \*callouts*\ can be used for more
5263 verification if required. Section ~~SECTaddressverification discusses the
5264 details of address verification.
5265
5266 .display asis
5267 # deny    message       = rejected because $sender_host_address is \
5268 #                         in a black list at $dnslist_domain\n\
5269 #                         $dnslist_text
5270 #         dnslists      = black.list.example
5271 #
5272 # warn    message       = X-Warning: $sender_host_address is \
5273 #                         in a black list at $dnslist_domain
5274 #         log_message   = found in $dnslist_domain
5275 #         dnslists      = black.list.example
5276 .endd
5277 These commented-out lines are examples of how you could configure Exim to check
5278 sending hosts against a DNS black list. The first statement rejects messages
5279 from blacklisted hosts, whereas the second merely inserts a warning header
5280 line.
5281
5282 .display asis
5283 accept  domains       = +local_domains
5284         endpass
5285         message       = unknown user
5286         verify        = recipient
5287 .endd
5288 This statement accepts the incoming recipient address if its domain is one of
5289 the local domains, but only if the address can be verified. Verification of
5290 local addresses normally checks both the local part and the domain. The
5291 \endpass\ line needs some explanation: if the condition above \endpass\ fails,
5292 that is, if the address is not in a local domain, control is passed to the next
5293 ACL statement. However, if the condition below \endpass\ fails, that is, if a
5294 recipient in a local domain cannot be verified, access is denied and the
5295 recipient is rejected.
5296 .index customizing||ACL failure message
5297 The \message\ modifier provides a customized error message for the failure.
5298 .display asis
5299 accept  domains       = +relay_to_domains
5300         endpass
5301         message       = unrouteable address
5302         verify        = recipient
5303 .endd
5304 This statement accepts the incoming recipient address if its domain is one of
5305 the domains for which this host is a relay, but again, only if the address can
5306 be verified.
5307 .display asis
5308 accept  hosts         = +relay_from_hosts
5309 .endd
5310 Control reaches this statement only if the recipient's domain is neither a
5311 local domain, nor a relay domain. The statement accepts the address if the
5312 message is coming from one of the hosts that are defined as being allowed to
5313 relay through this host. Recipient verification is omitted here, because in
5314 many cases the clients are dumb MUAs that do not cope well with SMTP error
5315 responses. If you are actually relaying out from MTAs, you should probably add
5316 recipient verification here.
5317 .display asis
5318 accept  authenticated = *
5319 .endd
5320 Control reaches here for attempts to relay to arbitrary domains from arbitrary
5321 hosts. The statement accepts the address only if the client host has
5322 authenticated itself. The default configuration does not define any
5323 authenticators, which means that no client can in fact authenticate. You will
5324 need to add authenticator definitions if you want to make use of this ACL
5325 statement.
5326 .display asis
5327 deny    message       = relay not permitted
5328 .endd
5329 The final statement denies access, giving a specific error message. Reaching
5330 the end of the ACL also causes access to be denied, but with the generic
5331 message `administrative prohibition'.
5332
5333
5334 .section Router configuration
5335 .index default||routers
5336 .index routers||default
5337 The router configuration comes next in the default configuration, introduced
5338 by the line
5339 .display asis
5340 begin routers
5341 .endd
5342 Routers are the modules in Exim that make decisions about where to send
5343 messages. An address is passed to each router in turn, until it is either
5344 accepted, or failed. This means that the order in which you define the routers
5345 matters. Each router is fully described in its own chapter later in this
5346 manual. Here we give only brief overviews.
5347
5348 .index domain literal||default router
5349 .display asis
5350 # domain_literal:
5351 #   driver = ipliteral
5352 #   domains = !+local_domains
5353 #   transport = remote_smtp
5354 .endd
5355 This router is commented out because the majority of sites do not want to
5356 support domain literal addresses (those of the form \*user@@[10.9.8.7]*\). If
5357 you uncomment this router, you also need to uncomment the setting of
5358 \allow@_domain@_literals\ in the main part of the configuration.
5359
5360 .display asis
5361 dnslookup:
5362   driver = dnslookup
5363   domains = ! +local_domains
5364   transport = remote_smtp
5365 .newline
5366   ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
5367 .newline
5368   no_more
5369 .endd
5370 The first uncommented router handles addresses that do not involve any local
5371 domains. This is specified by the line
5372 .display asis
5373 domains = ! +local_domains
5374 .endd
5375 The \domains\ option lists the domains to which this router applies, but the
5376 exclamation mark is a negation sign, so the router is used only for domains
5377 that are not in the domain list called \*local@_domains*\ (which was defined at
5378 the start of the configuration). The plus sign before \*local@_domains*\
5379 indicates that it is referring to a named list. Addresses in other domains are
5380 passed on to the following routers.
5381
5382 The name of the router driver is \%dnslookup%\,
5383 and is specified by the \driver\ option. Do not be confused by the fact that
5384 the name of this router instance is the same as the name of the driver. The
5385 instance name is arbitrary, but the name set in the \driver\ option must be one
5386 of the driver modules that is in the Exim binary.
5387
5388 The \%dnslookup%\ router routes addresses by looking up their domains in the
5389 DNS in order to obtain a list of hosts to which the address is routed. If the
5390 router succeeds, the address is queued for the \%remote@_smtp%\ transport, as
5391 specified by the \transport\ option. If the router does not find the domain in
5392 the DNS, no further routers are tried because of the \no@_more\ setting, so the
5393 address fails and is bounced.
5394
5395 The \ignore@_target@_hosts\ option specifies a list of IP addresses that are to
5396 be entirely ignored. This option is present because a number of cases have been
5397 encountered where MX records in the DNS point to host names
5398 whose IP addresses are 0.0.0.0 or are in the 127 subnet (typically 127.0.0.1).
5399 Completely ignoring these IP addresses causes Exim to fail to route the
5400 email address, so it bounces. Otherwise, Exim would log a routing problem, and
5401 continue to try to deliver the message periodically until the address timed
5402 out.
5403 .display asis
5404 system_aliases:
5405   driver = redirect
5406   allow_fail
5407   allow_defer
5408   data = ${lookup{$local_part}lsearch{/etc/aliases}}
5409 # user = exim
5410   file_transport = address_file
5411   pipe_transport = address_pipe
5412 .endd
5413 Control reaches this and subsequent routers only for addresses in the local
5414 domains. This router checks to see whether the local part is defined as an
5415 alias in the \(/etc/aliases)\ file, and if so, redirects it according to the
5416 data that it looks up from that file. If no data is found for the local part,
5417 the value of the \data\ option is empty, causing the address to be passed to
5418 the next router.
5419
5420 \(/etc/aliases)\ is a conventional name for the system aliases file that is
5421 often used. That is why it is referenced by from the default configuration
5422 file. However, you can change this by setting \\SYSTEM@_ALIASES@_FILE\\ in
5423 \(Local/Makefile)\ before building Exim.
5424
5425 .display asis
5426 userforward:
5427   driver = redirect
5428   check_local_user
5429   file = $home/.forward
5430   no_verify
5431   no_expn
5432   check_ancestor
5433 # allow_filter
5434   file_transport = address_file
5435   pipe_transport = address_pipe
5436   reply_transport = address_reply
5437 .endd
5438 This is the most complicated router in the default configuration. It is another
5439 redirection router, but this time it is looking for forwarding data set up by
5440 individual users. The \check@_local@_user\ setting means that the first thing it
5441 does is to check that the local part of the address is the login name of a
5442 local user. If it is not, the router is skipped. When a local user is found,
5443 the file called \(.forward)\ in the user's home directory is consulted. If it
5444 does not exist, or is empty, the router declines. Otherwise, the contents of
5445 \(.forward)\ are interpreted as redirection data (see chapter ~~CHAPredirect
5446 for more details).
5447
5448 .index Sieve filter||enabling in default router
5449 Traditional \(.forward)\ files contain just a list of addresses, pipes, or
5450 files. Exim supports this by default. However, if \allow@_filter\ is set (it is
5451 commented out by default), the contents of the file are interpreted as a set of
5452 Exim or Sieve filtering instructions, provided the file begins with `@#Exim
5453 filter' or `@#Sieve filter', respectively. User filtering is discussed in the
5454 separate document entitled \*Exim's interfaces to mail filtering*\.
5455
5456 The \no@_verify\ and \no@_expn\ options mean that this router is skipped when
5457 verifying addresses, or when running as a consequence of an SMTP \\EXPN\\
5458 command.
5459 There are two reasons for doing this:
5460 .numberpars
5461 Whether or not a local user has a \(.forward)\ file is not really relevant when
5462 checking an address for validity; it makes sense not to waste resources doing
5463 unnecessary work.
5464 .nextp
5465 More importantly, when Exim is verifying addresses or handling an \\EXPN\\
5466 command during an SMTP session, it is running as the Exim user, not as root.
5467 The group is the Exim group, and no additional groups are set up.
5468 It may therefore not be possible for Exim to read users' \(.forward)\ files at
5469 this time.
5470 .endp
5471
5472 The setting of \check@_ancestor\ prevents the router from generating a new
5473 address that is the same as any previous address that was redirected. (This
5474 works round a problem concerning a bad interaction between aliasing and
5475 forwarding -- see section ~~SECTredlocmai).
5476
5477 The final three option settings specify the transports that are to be used when
5478 forwarding generates a direct delivery to a file, or to a pipe, or sets up an
5479 auto-reply, respectively. For example, if a \(.forward)\ file contains
5480 .display asis
5481 a.nother@elsewhere.example, /home/spqr/archive
5482 .endd
5483 the delivery to \(/home/spqr/archive)\ is done by running the \address@_file\
5484 transport.
5485 .display asis
5486 localuser:
5487   driver = accept
5488   check_local_user
5489   transport = local_delivery
5490 .endd
5491 The final router sets up delivery into local mailboxes, provided that the local
5492 part is the name of a local login, by accepting the address and queuing it for
5493 the \%local@_delivery%\ transport. Otherwise, we have reached the end of the
5494 routers, so the address is bounced.
5495
5496
5497 .section Transport configuration
5498 .index default||transports
5499 .index transports||default
5500 Transports define mechanisms for actually delivering messages. They operate
5501 only when referenced from routers, so the order in which they are defined does
5502 not matter. The transports section of the configuration starts with
5503 .display asis
5504 begin transports
5505 .endd
5506 One remote transport and four local transports are defined.
5507 .display asis
5508 remote_smtp:
5509   driver = smtp
5510 .endd
5511 This transport is used for delivering messages over SMTP connections. All its
5512 options are defaulted. The list of remote hosts comes from the router.
5513 .display asis
5514 local_delivery:
5515   driver = appendfile
5516   file = /var/mail/$local_part
5517   delivery_date_add
5518   envelope_to_add
5519   return_path_add
5520 # group = mail
5521 # mode = 0660
5522 .endd
5523 This \%appendfile%\ transport is used for local delivery to user mailboxes in
5524 traditional BSD mailbox format. By default it runs under the uid and gid of the
5525 local user, which requires the sticky bit to be set on the \(/var/mail)\
5526 directory. Some systems use the alternative approach of running mail deliveries
5527 under a particular group instead of using the sticky bit. The commented options
5528 show how this can be done.
5529
5530 Exim adds three headers to the message as it delivers it: ::Delivery-date::,
5531 ::Envelope-to:: and ::Return-path::. This action is requested by the three
5532 similarly-named options above.
5533 .display asis
5534 address_pipe:
5535   driver = pipe
5536   return_output
5537 .endd
5538 This transport is used for handling deliveries to pipes that are generated by
5539 redirection (aliasing or users' \(.forward)\ files). The \return@_output\
5540 option specifies that any output generated by the pipe is to be returned to the
5541 sender.
5542 .display asis
5543 address_file:
5544   driver = appendfile
5545   delivery_date_add
5546   envelope_to_add
5547   return_path_add
5548 .endd
5549 This transport is used for handling deliveries to files that are generated by
5550 redirection. The name of the file is not specified in this instance of
5551 \%appendfile%\, because it comes from the \%redirect%\ router.
5552 .display asis
5553 address_reply:
5554   driver = autoreply
5555 .endd
5556 This transport is used for handling automatic replies generated by users'
5557 filter files.
5558
5559
5560 .section Default retry rule
5561 .index retry||default rule
5562 .index default||retry rule
5563 The retry section of the configuration file contains rules which affect the way
5564 Exim retries deliveries that cannot be completed at the first attempt. It is
5565 introduced by the line
5566 .display asis
5567 begin retry
5568 .endd
5569 In the default configuration, there is just one rule, which applies to all
5570 errors:
5571 .display asis
5572 *   *   F,2h,15m; G,16h,1h,1.5; F,4d,6h
5573 .endd
5574 This causes any temporarily failing address to be retried every 15 minutes for
5575 2 hours, then at intervals starting at one hour and increasing by a factor of
5576 1.5 until 16 hours have passed, then every 6 hours up to 4 days. If an address
5577 is not delivered after 4 days of failure, it is bounced.
5578
5579
5580 .section Rewriting configuration
5581 The rewriting section of the configuration, introduced by
5582 .display asis
5583 begin rewrite
5584 .endd
5585 contains rules for rewriting addresses in messages as they arrive. There are no
5586 rewriting rules in the default configuration file.
5587
5588
5589 .section Authenticators configuration
5590 .index \\AUTH\\||configuration
5591 The authenticators section of the configuration, introduced by
5592 .display asis
5593 begin authenticators
5594 .endd
5595 defines mechanisms for the use of the SMTP \\AUTH\\ command. No authenticators
5596 are specified in the default configuration file.
5597
5598
5599
5600 .
5601 .
5602 .
5603 .
5604 . ============================================================================
5605 .chapter Regular expressions
5606 .set runningfoot "regular expressions"
5607 .rset CHAPregexp ~~chapter
5608
5609 .index regular expressions||library
5610 .index PCRE
5611 Exim supports the use of regular expressions in many of its options. It
5612 uses the PCRE regular expression library; this provides regular expression
5613 matching that is compatible with Perl 5. The syntax and semantics of
5614 regular expressions is discussed in many Perl reference books, and also in
5615 Jeffrey Friedl's
5616 .if ~~html
5617 [(A HREF="http://www.oreilly.com/catalog/regex/")]
5618 .fi
5619 $it{Mastering Regular Expressions}
5620 .if ~~html
5621 [(/A)]
5622 .fi
5623 (O'Reilly, ISBN 0-596-00289-0).
5624
5625 The documentation for the syntax and semantics of the regular expressions that
5626 are supported by PCRE is included in plain text in the file
5627 \(doc/pcrepattern.txt)\ in the Exim distribution, and also in the HTML
5628 tarbundle of Exim documentation, and as an appendix to the
5629 .if ~~html
5630 [(A HREF="http://www.uit.co.uk/exim-book/")]
5631 .fi
5632 Exim book.
5633 .if ~~html
5634 [(/A)]
5635 .fi
5636 It describes in detail the features of the regular expressions that PCRE
5637 supports, so no further description is included here. The PCRE functions are
5638 called from Exim using the default option settings (that is, with no PCRE
5639 options set), except that the \\PCRE@_CASELESS\\ option is set when the
5640 matching is required to be case-insensitive.
5641
5642 In most cases, when a regular expression is required in an Exim configuration,
5643 it has to start with a circumflex, in order to distinguish it from plain text
5644 or an `ends with' wildcard. In this example of a configuration setting, the
5645 second item in the colon-separated list is a regular expression.
5646 .display asis
5647 domains = a.b.c : ^\\d{3} : *.y.z : ...
5648 .endd
5649 The doubling of the backslash is required because of string expansion that
5650 precedes interpretation -- see section ~~SECTlittext for more discussion of
5651 this issue, and a way of avoiding the need for doubling backslashes. The
5652 regular expression that is eventually used in this example contains just one
5653 backslash. The circumflex is included in the regular expression, and has the
5654 normal effect of `anchoring' it to the start of the string that is being
5655 matched.
5656
5657 There are, however, two cases where a circumflex is not required for the
5658 recognition of a regular expression: these are the \match\ condition in a
5659 string expansion, and the \matches\ condition in an Exim filter file. In these
5660 cases, the relevant string is always treated as a regular expression; if it
5661 does not start with a circumflex, the expression is not anchored, and can match
5662 anywhere in the subject string.
5663
5664 In all cases, if you want a regular expression to match at the end of a string,
5665 you must code the @$ metacharacter to indicate this. For example:
5666 .display asis
5667 domains = ^\\d{3}\\.example
5668 .endd
5669 matches the domain \*123.example*\, but it also matches \*123.example.com*\.
5670 You need to use:
5671 .display asis
5672 domains = ^\\d{3}\\.example\$
5673 .endd
5674 if you want \*example*\ to be the top-level domain. (The backslash before the
5675 @$ is another artefact of string expansion.)
5676
5677
5678 .section Testing regular expressions
5679 .index testing||regular expressions
5680 .index regular expressions||testing
5681 .index \*pcretest*\
5682 A program called \*pcretest*\ forms part of the PCRE distribution and is built
5683 with PCRE during the process of building Exim. It is primarily intended for
5684 testing PCRE itself, but it can also be used for experimenting with regular
5685 expressions. After building Exim, the binary can be found in the build
5686 directory (it is not installed anywhere automatically). There is documentation
5687 of various options in \(doc/pcretest.txt)\, but for simple testing, none are
5688 needed. This is the output of a sample run of \*pcretest*\:
5689 .display
5690   re> $cb{/^([^@@]+)@@.+@\.(ac|edu)@\.(?!kr)[a-z]@{2@}@$/}
5691 data> $cb{x@@y.ac.uk}
5692  0: x@@y.ac.uk
5693  1: x
5694  2: ac
5695 data> $cb{x@@y.ac.kr}
5696 No match
5697 data> $cb{x@@y.edu.com}
5698 No match
5699 data> $cb{x@@y.edu.co}
5700  0: x@@y.edu.co
5701  1: x
5702  2: edu
5703 .endd
5704 .if ~~sys.fancy
5705 Input typed by the user is shown in bold face.
5706 .fi
5707 After the `re>' prompt, a regular expression enclosed in delimiters is
5708 expected. If this compiles without error, `data>' prompts are given for strings
5709 against which the expression is matched. An empty data line causes a new
5710 regular expression to be read. If the match is successful, the captured
5711 substring values (that is, what would be in the variables \$0$\, \$1$\, \$2$\,
5712 etc.) are shown. The above example tests for an email address whose domain ends
5713 with either `ac' or `edu' followed by a two-character top-level domain that is
5714 not `kr'. The local part is captured in \$1$\ and the `ac' or `edu' in \$2$\.
5715
5716
5717
5718
5719
5720
5721 .
5722 .
5723 .
5724 .
5725 . ============================================================================
5726 .chapter File and database lookups
5727 .set runningfoot "file/database lookups"
5728 .rset CHAPfdlookup "~~chapter"
5729 .index file||lookup
5730 .index database lookups
5731 .index lookup||description of
5732 Exim can be configured to look up data in files or databases as it processes
5733 messages. Two different kinds of syntax are used:
5734 .numberpars
5735 A string that is to be expanded may contain explicit lookup requests. These
5736 cause parts of the string to be replaced by data that is obtained from the
5737 lookup.
5738 .nextp
5739 Lists of domains, hosts, and email addresses can contain lookup requests as a
5740 way of avoiding excessively long linear lists. In this case, the data that is
5741 returned by the lookup is often (but not always) discarded; whether the lookup
5742 succeeds or fails is what really counts. These kinds of list are described in
5743 chapter ~~CHAPdomhosaddlists.
5744 .endp
5745 It is easy to confuse the two different kinds of lookup, especially as the
5746 lists that may contain the second kind are always expanded before being
5747 processed as lists. Therefore, they may also contain lookups of the first kind.
5748 Be careful to distinguish between the following two examples:
5749 .display asis
5750 domains = ${lookup{$sender_host_address}lsearch{/some/file}}
5751 domains = lsearch;/some/file
5752 .endd
5753 The first uses a string expansion, the result of which must be a domain list.
5754 String expansions are described in detail in chapter ~~CHAPexpand. The
5755 expansion takes place first, and the file that is searched could contain lines
5756 like this:
5757 .display asis
5758 192.168.3.4: domain1 : domain2 : ...
5759 192.168.1.9: domain3 : domain4 : ...
5760 .endd
5761 Thus, the result of the expansion is a list of domains (and possibly other
5762 types of item that are allowed in domain lists).
5763
5764 In the second case, the lookup is a single item in a domain list. It causes
5765 Exim to use a lookup to see if the domain that is being processed can be found
5766 in the file. The file could contains lines like this:
5767 .display asis
5768 domain1:
5769 domain2:
5770 .endd
5771 Any data that follows the keys is not relevant when checking that the domain
5772 matches the list item.
5773
5774 It is possible to use both kinds of lookup at once. Consider a file containing
5775 lines like this:
5776 .display asis
5777 192.168.5.6: lsearch;/another/file
5778 .endd
5779 If the value of \$sender@_host@_address$\ is 192.168.5.6, expansion of the
5780 first \domains\ setting above generates the second setting, which therefore
5781 causes a second lookup to occur.
5782
5783 The rest of this chapter describes the different lookup types that are
5784 available. Any of them can be used in either of the circumstances described
5785 above. The syntax requirements for the two cases are described in chapters
5786 ~~CHAPexpand and ~~CHAPdomhosaddlists, respectively.
5787
5788 .section Lookup types
5789 .index lookup||types of
5790 .index single-key lookup||definition of
5791 Two different styles of data lookup are implemented:
5792 .numberpars $.
5793 The \*single-key*\ style requires the specification of a file in which to look,
5794 and a single key to search for. 
5795 .em
5796 The key must be a non-empty string for the lookup to succeed.
5797 .nem
5798 The lookup type determines how the file is searched.
5799 .nextp
5800 .index query-style lookup||definition of
5801 The \*query*\ style accepts a generalized database query.
5802 No particular key value is assumed by Exim for query-style lookups. You can
5803 use whichever Exim variable(s) you need to construct the database query.
5804 .endp
5805 The code for each lookup type is in a separate source file that is included in
5806 the binary of Exim only if the corresponding compile-time option is set. The
5807 default settings in \(src/EDITME)\ are:
5808 .display asis
5809 LOOKUP_DBM=yes
5810 LOOKUP_LSEARCH=yes
5811 .endd
5812 which means that only linear searching and DBM lookups are included by default.
5813 For some types of lookup (e.g. SQL databases), you need to install appropriate
5814 libraries and header files before building Exim.
5815
5816
5817
5818 .section Single-key lookup types
5819 .rset SECTsinglekeylookups "~~chapter.~~section"
5820 .index lookup||single-key types
5821 .index single-key lookup||list of types
5822 The following single-key lookup types are implemented:
5823 .numberpars $.
5824 .index cdb||description of
5825 .index lookup||cdb
5826 .index binary zero||in lookup key
5827 \%cdb%\: The given file is searched as a Constant DataBase file, using the key
5828 string without a terminating binary zero. The cdb format is designed for
5829 indexed files that are read frequently and never updated, except by total
5830 re-creation. As such, it is particulary suitable for large files containing
5831 aliases or other indexed data referenced by an MTA. Information about cdb can
5832 be found in several places:
5833 .display rm
5834 \?http://www.pobox.com/@~djb/cdb.html?\
5835 \?ftp://ftp.corpit.ru/pub/tinycdb/?\
5836 \?http://packages.debian.org/stable/utils/freecdb.html?\
5837 .endd
5838 A cdb distribution is not needed in order to build Exim with cdb support,
5839 because the code for reading cdb files is included directly in Exim itself.
5840 However, no means of building or testing cdb files is provided with Exim, so
5841 you need to obtain a cdb distribution in order to do this.
5842 .nextp
5843 .index DBM||lookup type
5844 .index lookup||dbm
5845 .index binary zero||in lookup key
5846 \%dbm%\: Calls to DBM library functions are used to extract data from the given
5847 DBM file by looking up the record with the given key. A terminating binary
5848 zero is included in the key that is passed to the DBM library. See section
5849 ~~SECTdb for a discussion of DBM libraries.
5850 .index Berkeley DB library||file format
5851 For all versions of Berkeley DB, Exim uses the \\DB@_HASH\\ style of database
5852 when building DBM files using the \exim@_dbmbuild\ utility. However, when using
5853 Berkeley DB versions 3 or 4, it opens existing databases for reading with the
5854 \\DB@_UNKNOWN\\ option. This enables it to handle any of the types of database
5855 that the library supports, and can be useful for accessing DBM files created by
5856 other applications. (For earlier DB versions, \\DB@_HASH\\ is always used.)
5857
5858 .nextp
5859 .index lookup||dbmnz
5860 .index lookup||dbm, terminating zero
5861 .index binary zero||in lookup key
5862 .index Courier
5863 .index \(/etc/userdbshadow.dat)\
5864 .index dmbnz lookup type
5865 \%dbmnz%\: This is the same as \%dbm%\, except that a terminating binary zero
5866 is not included in the key that is passed to the DBM library. You may need this
5867 if you want to look up data in files that are created by or shared with some
5868 other application that does not use terminating zeros. For example, you need to
5869 use \%dbmnz%\ rather than \%dbm%\ if you want to authenticate incoming SMTP
5870 calls using the passwords from Courier's \(/etc/userdbshadow.dat)\ file. Exim's
5871 utility program for creating DBM files (\*exim@_dbmbuild*\) includes the zeros
5872 by default, but has an option to omit them (see section ~~SECTdbmbuild).
5873 .nextp
5874 .index lookup||dsearch
5875 .index dsearch lookup type
5876 \%dsearch%\: The given file must be a directory; this is searched for a file
5877 whose name is the key. The key may not contain any forward slash characters.
5878 The result of a successful lookup is the name of the file. An example of how
5879 this lookup can be used to support virtual domains is given in section
5880 ~~SECTvirtualdomains.
5881 .nextp
5882 .index lookup||iplsearch
5883 .index iplsearch lookup type
5884 \%iplsearch%\: The given file is a text file containing keys and data. A key is
5885 terminated by a colon or white space or the end of the line. The keys in the
5886 file must be IP addresses, or IP addresses with CIDR masks. Keys that involve
5887 IPv6 addresses must be enclosed in quotes to prevent the first internal colon
5888 being interpreted as a key terminator. For example:
5889 .display asis
5890 1.2.3.4:           data for 1.2.3.4
5891 192.168.0.0/16     data for 192.168.0.0/16
5892 "abcd::cdab":      data for abcd::cdab
5893 "abcd:abcd::/32"   data for abcd:abcd::/32
5894 .endd
5895 The key for an \%iplsearch%\ lookup must be an IP address (without a mask). The
5896 file is searched linearly, using the CIDR masks where present, until a matching
5897 key is found. The first key that matches is used; there is no attempt to find a
5898 `best' match. Apart from the way the keys are matched, the processing for
5899 \%iplsearch%\ is the same as for \%lsearch%\.
5900
5901 \**Warning 1**\: Unlike most other single-key lookup types, a file of data for
5902 \%iplsearch%\ can \*not*\ be turned into a DBM or cdb file, because those
5903 lookup types support only literal keys.
5904
5905 \**Warning 2**\: In a host list, you must always use \%net-iplsearch%\ so that
5906 the implicit key is the host's IP address rather than its name (see section
5907 ~~SECThoslispatsikey).
5908
5909 .nextp
5910 .index linear search
5911 .index lookup||lsearch
5912 .index lsearch lookup type
5913 \%lsearch%\: The given file is a text file that is searched linearly for a
5914 line beginning with the search key, terminated by a colon or white space or the
5915 end of the line. The first occurrence that is found in the file is used. White
5916 space between the key and the colon is permitted. The remainder of the line,
5917 with leading and trailing white space removed, is the data. This can be
5918 continued onto subsequent lines by starting them with any amount of white
5919 space, but only a single space character is included in the data at such a
5920 junction. If the data begins with a colon, the key must be terminated by a
5921 colon, for example:
5922 .display
5923 baduser:  :fail:
5924 .endd
5925 Empty lines and lines beginning with @# are ignored, even if they occur in the
5926 middle of an item. This is the traditional textual format of alias files. Note
5927 that the keys in an \%lsearch%\ file are literal strings. There is no
5928 wildcarding of any kind.
5929
5930 .index lookup||lsearch, colons in keys
5931 .index whitespace||in lsearch key
5932 In most \%lsearch%\ files, keys are not required to contain colons or @#
5933 characters, or whitespace. However, if you need this feature, it is available.
5934 If a key begins with a doublequote character, it is terminated only by a
5935 matching quote (or end of line), and the normal escaping rules apply to its
5936 contents (see section ~~SECTstrings). An optional colon is permitted after
5937 quoted keys (exactly as for unquoted keys). There is no special handling of
5938 quotes for the data part of an \%lsearch%\ line.
5939 .nextp
5940 .index NIS lookup type
5941 .index lookup||NIS
5942 .index binary zero||in lookup key
5943 \%nis%\: The given file is the name of a NIS map, and a NIS lookup is done with
5944 the given key, without a terminating binary zero. There is a variant called
5945 \%nis0%\ which does include the terminating binary zero in the key. This is
5946 reportedly needed for Sun-style alias files. Exim does not recognize NIS
5947 aliases; the full map names must be used.
5948 .nextp
5949 .index wildlsearch lookup type
5950 .index lookup||wildlsearch
5951 .index nwildlsearch lookup type
5952 .index lookup||nwildlsearch
5953 \%wildlsearch%\ or \%nwildlsearch%\: These search a file linearly, like
5954 \%lsearch%\, but instead of being interpreted as a literal string, each key may
5955 be wildcarded. The difference between these two lookup types is that for
5956 \%wildlsearch%\, each key in the file is string-expanded before being used,
5957 whereas for \%nwildlsearch%\, no expansion takes place.
5958
5959 Like \%lsearch%\, the testing is done case-insensitively. The following forms
5960 of wildcard are recognized:
5961 .numberpars "$*$"
5962 The string may begin with an asterisk to mean `ends with'. For example:
5963 .display asis
5964 *.a.b.c       data for anything.a.b.c
5965 *fish         data for anythingfish
5966 .endd
5967 .nextp
5968 The string may begin with a circumflex to indicate a regular expression. For
5969 example, for \%wildlsearch%\:
5970 .display asis
5971 ^\N\d+\.a\.b\N    data for <digits>.a.b
5972 .endd
5973 Note the use of \"@\N"\ to disable expansion of the contents of the regular
5974 expression. If you are using \%nwildlsearch%\, where the keys are not
5975 string-expanded, the equivalent entry is:
5976 .display asis
5977 ^\d+\.a\.b        data for <digits>.a.b
5978 .endd
5979
5980 If the regular expression contains white space or colon characters, you must
5981 either quote it (see \%lsearch%\ above), or represent these characters in other
5982 ways. For example, \"@\s"\ can be used for white space and \"@\x3A"\ for a
5983 colon. This may be easier than quoting, because if you quote, you have to
5984 escape all the backslashes inside the quotes.
5985 .nextp
5986 Although I cannot see it being of much use, the general matching function
5987 that is used to implement
5988 \%(n)wildlsearch%\
5989 means that the string may begin with a lookup name terminated by a semicolon,
5990 and followed by lookup data. For example:
5991 .display asis
5992 cdb;/some/file  data for keys that match the file
5993 .endd
5994 The data that is obtained from the nested lookup is discarded.
5995 .endp
5996 Keys that do not match any of these patterns are interpreted literally. The
5997 continuation rules for the data are the same as for \%lsearch%\, and keys may
5998 be followed by optional colons.
5999
6000 \**Warning**\: Unlike most other single-key lookup types, a file of data for
6001 \%(n)wildlsearch%\ can \*not*\ be turned into a DBM or cdb file, because those
6002 lookup types support only literal keys.
6003 .endp
6004
6005 .section Query-style lookup types
6006 .index lookup||query-style types
6007 .index query-style lookup||list of types
6008 The supported query-style lookup types are listed below. Further details about
6009 many of them are given in later sections.
6010 .numberpars $.
6011 .index DNS||as a lookup type
6012 .index lookup||DNS
6013 \%dnsdb%\: This does a DNS search for 
6014 .em
6015 one or more records whose domain names are given in the supplied query. The
6016 resulting data is the contents of the records.
6017 .nem
6018 See section ~~SECTdnsdb.
6019 .nextp
6020 .index Interbase lookup type
6021 .index lookup||Interbase
6022 \%ibase%\: This does a lookup in an Interbase database.
6023 .nextp
6024 .index LDAP||lookup type
6025 .index lookup||LDAP
6026 \%ldap%\: This does an LDAP lookup using a query in the form of a URL, and
6027 returns attributes from a single entry. There is a variant called \%ldapm%\
6028 that permits values from multiple entries to be returned. A third variant
6029 called \%ldapdn%\ returns the Distinguished Name of a single entry instead of
6030 any attribute values. See section ~~SECTldap.
6031 .nextp
6032 .index MySQL||lookup type
6033 .index lookup||MySQL
6034 \%mysql%\: The format of the query is an SQL statement that is passed to a MySQL
6035 database. See section ~~SECTsql.
6036 .nextp
6037 .index NIS@+ lookup type
6038 .index lookup||NIS+
6039 \%nisplus%\: This does a NIS+ lookup using a query that can specify the name of
6040 the field to be returned. See section ~~SECTnisplus.
6041 .nextp
6042 .index Oracle||lookup type
6043 .index lookup||Oracle
6044 \%oracle%\: The format of the query is an SQL statement that is passed to an
6045 Oracle database. See section ~~SECTsql.
6046 .nextp
6047 .index lookup||passwd
6048 .index passwd lookup type
6049 .index \(/etc/passwd)\
6050 \%passwd%\ is a query-style lookup with queries that are just user names. The
6051 lookup calls \*getpwnam()*\ to interrogate the system password data, and on
6052 success, the result string is the same as you would get from an \%lsearch%\
6053 lookup on a traditional \(/etc/passwd file)\, though with \"*"\ for the
6054 password value. For example:
6055 .display asis
6056 *:42:42:King Rat:/home/kr:/bin/bash
6057 .endd
6058 .nextp
6059 .index PostgreSQL lookup type
6060 .index lookup||PostgreSQL
6061 \%pgsql%\: The format of the query is an SQL statement that is passed to a
6062 PostgreSQL database. See section ~~SECTsql.
6063 .nextp
6064 \%testdb%\: This is a lookup type that is used for testing Exim. It is
6065 not likely to be useful in normal operation.
6066 .nextp
6067 .index whoson lookup type
6068 .index lookup||whoson
6069 \%whoson%\: \*Whoson*\ (\?http://whoson.sourceforge.net?\) is a proposed
6070 Internet protocol that allows Internet server programs to check whether a
6071 particular (dynamically allocated) IP address is currently allocated to a known
6072 (trusted) user and, optionally, to obtain the identity of the said user. In
6073 Exim, this can be used to implement `POP before SMTP' checking using ACL
6074 statements such as
6075 .display asis
6076 require condition = \
6077   ${lookup whoson {$sender_host_address}{yes}{no}}
6078 .endd
6079 The query consists of a single IP address. The value returned is the name of
6080 the authenticated user.
6081 .endp
6082
6083 .section Temporary errors in lookups
6084 .index lookup||temporary error in
6085 Lookup functions can return temporary error codes if the lookup cannot be
6086 completed. For example, a NIS or LDAP database might be unavailable. For this
6087 reason, it is not advisable to use a lookup that might do this for critical
6088 options such as a list of local domains.
6089
6090 When a lookup cannot be completed in a router or transport, delivery
6091 of the message (to the relevant address) is deferred, as for any other
6092 temporary error. In other circumstances Exim may assume the lookup has failed,
6093 or may give up altogether.
6094
6095
6096 .section Default values in single-key lookups
6097 .rset SECTdefaultvaluelookups "~~chapter.~~section"
6098 .index wildcard lookups
6099 .index lookup||default values
6100 .index lookup||wildcard
6101 .index lookup||$*$ added to type
6102 .index default||in single-key lookups
6103 In this context, a `default value' is a value specified by the administrator
6104 that is to be used if a lookup fails.
6105
6106 If `$*$' is added to a single-key lookup type (for example, \lsearch$*$\) and
6107 the initial lookup fails, the key `$*$' is looked up in the file to provide
6108 a default value. See also the section on partial matching below.
6109
6110 .index @*@@ with single-key lookup
6111 .index lookup||$*$@@ added to type
6112 .index alias file||per-domain default
6113 Alternatively, if `$*$@@' is added to a single-key lookup type (for example
6114 \dbm$*$@@\) then, if the initial lookup fails and the key contains an @@
6115 character, a second lookup is done with everything before the last @@ replaced
6116 by $*$. This makes it possible to provide per-domain defaults in alias files
6117 that include the domains in the keys. If the second lookup fails (or doesn't
6118 take place because there is no @@ in the key), `$*$' is looked up.
6119 For example, a \%redirect%\ router might contain:
6120 .display asis
6121 data = ${lookup{$local_part@$domain}lsearch*@{/etc/mixed-aliases}}
6122 .endd
6123 Suppose the address that is being processed is \*jane@@eyre.example*\. Exim
6124 looks up these keys, in this order:
6125 .display asis
6126 jane@eyre.example
6127 *@eyre.example
6128 *
6129 .endd
6130 The data is taken from whichever key it finds first. \**Note**\: in an
6131 \%lsearch%\ file, this does not mean the first of these keys in the file. A
6132 complete scan is done for each key, and only if it is not found at all does
6133 Exim move on to try the next key.
6134
6135
6136 .section Partial matching in single-key lookups
6137 .rset SECTpartiallookup "~~chapter.~~section"
6138 .index partial matching
6139 .index wildcard lookups
6140 .index lookup||partial matching
6141 .index lookup||wildcard
6142 .index asterisk||in search type
6143 The normal operation of a single-key lookup is to search the file for an exact
6144 match with the given key. However, in a number of situations where domains are
6145 being looked up, it is useful to be able to do partial matching. In this case,
6146 information in the file that has a key starting with `$*$.' is matched by any
6147 domain that ends with the components that follow the full stop. For example, if
6148 a key in a DBM file is
6149 .display
6150 *.dates.fict.example
6151 .endd
6152 then when partial matching is enabled this is matched by (amongst others)
6153 \*2001.dates.fict.example*\ and \*1984.dates.fict.example*\. It is also matched
6154 by \*dates.fict.example*\, if that does not appear as a separate key in the
6155 file.
6156
6157 \**Note**\: Partial matching is not available for query-style lookups. It is
6158 also not available for any lookup items in address lists (see section
6159 ~~SECTaddresslist).
6160
6161 Partial matching is implemented by doing a series of separate lookups using
6162 keys constructed by modifying the original subject key. This means that it can
6163 be used with any of the single-key lookup types, provided that
6164 partial matching keys
6165 beginning with a special prefix (default `$*$.') are included in the data file.
6166 Keys in the file that do not begin with the prefix are matched only by
6167 unmodified subject keys when partial matching is in use.
6168
6169 Partial matching is requested by adding the string `partial-' to the front of
6170 the name of a single-key lookup type, for example, \partial-dbm\. When this is
6171 done, the subject key is first looked up unmodified; if that fails, `$*$.'
6172 is added at the start of the subject key, and it is looked up again. If that
6173 fails, further lookups are tried with dot-separated components removed
6174 from the start of the subject key, one-by-one, and `$*$.' added on the front of
6175 what remains.
6176
6177 A minimum number of two non-$*$ components are required. This can be adjusted
6178 by including a number before the hyphen in the search type. For example,
6179 \partial3-lsearch\ specifies a minimum of three non-$*$ components in the
6180 modified keys. Omitting the number is equivalent to `partial2-'. If the subject
6181 key is \*2250.dates.fict.example*\ then the following keys are looked up when
6182 the minimum number of non-$*$ components is two:
6183 .display asis
6184 2250.dates.fict.example
6185 *.2250.dates.fict.example
6186 *.dates.fict.example
6187 *.fict.example
6188 .endd
6189 As soon as one key in the sequence is successfully looked up, the lookup
6190 finishes.
6191
6192 .index lookup||partial matching, changing prefix
6193 .index prefix||for partial matching
6194 The use of `$*$.' as the partial matching prefix is a default that can be
6195 changed. The motivation for this feature is to allow Exim to operate with file
6196 formats that are used by other MTAs. A different prefix can be supplied in
6197 parentheses instead of the hyphen after `partial'. For example:
6198 .display asis
6199 domains = partial(.)lsearch;/some/file
6200 .endd
6201 In this example, if the domain is \*a.b.c*\, the sequence of lookups is
6202 \"a.b.c"\, \".a.b.c"\, and \".b.c"\ (the default minimum of 2 non-wild
6203 components is unchanged). The prefix may consist of any punctuation characters
6204 other than a closing parenthesis. It may be empty, for example:
6205 .display asis
6206 domains = partial1()cdb;/some/file
6207 .endd
6208 For this example, if the domain is \*a.b.c*\, the sequence of lookups is
6209 \"a.b.c"\, \"b.c"\, and \"c"\.
6210
6211 If `partial0' is specified, what happens at the end (when the lookup with just
6212 one non-wild component has failed, and the original key is shortened right down
6213 to the null string) depends on the prefix:
6214 .numberpars $.
6215 If the prefix has zero length, the whole lookup fails.
6216 .nextp
6217 If the prefix has length 1, a lookup for just the prefix is done. For
6218 example, the final lookup for `partial0(.)' is for \"."\ alone.
6219 .nextp
6220 Otherwise, if the prefix ends in a dot, the dot is removed, and the
6221 remainder is looked up. With the default prefix, therefore, the final lookup is
6222 for `$*$' on its own.
6223 .nextp
6224 Otherwise, the whole prefix is looked up.
6225 .endp
6226
6227 If the search type ends in `$*$' or `$*$@@' (see section
6228 ~~SECTdefaultvaluelookups above), the search for an ultimate default that this
6229 implies happens after all partial lookups have failed. If `partial0' is
6230 specified, adding `$*$' to the search type has no effect with the default
6231 prefix, because the `$*$' key is already included in the sequence of partial
6232 lookups. However, there might be a use for lookup types such as
6233 `partial0(.)lsearch$*$'.
6234
6235 The use of `$*$' in lookup partial matching differs from its use as a wildcard
6236 in domain lists and the like. Partial matching works only in terms of
6237 dot-separated components; a key such as \"*fict.example"\
6238 in a database file is useless, because the asterisk in a partial matching
6239 subject key is always followed by a dot.
6240
6241
6242
6243 .section Lookup caching
6244 .index lookup||caching
6245 .index caching||lookup data
6246 .em
6247 Exim caches all lookup results in order to avoid needless repetition of 
6248 lookups. However, because (apart from the daemon) Exim operates as a collection
6249 of independent, short-lived processes, this caching applies only within a
6250 single Exim process. There is no inter-process caching facility.
6251
6252 For single-key lookups, Exim keeps the relevant files open in case there is
6253 another lookup that needs them. In some types of configuration this can lead to
6254 many files being kept open for messages with many recipients. To avoid hitting
6255 the operating system limit on the number of simultaneously open files, Exim
6256 closes the least recently used file when it needs to open more files than its
6257 own internal limit, which can be changed via the \lookup@_open@_max\ option.
6258
6259 The single-key lookup files are closed and the lookup caches are flushed at
6260 strategic points during delivery -- for example, after all routing is complete.
6261 .nem
6262
6263
6264 .section Quoting lookup data
6265 .index lookup||quoting
6266 .index quoting||in lookups
6267 When data from an incoming message is included in a query-style lookup, there
6268 is the possibility of special characters in the data messing up the syntax of
6269 the query. For example, a NIS+ query that contains
6270 .display asis
6271 [name=$local_part]
6272 .endd
6273 will be broken if the local part happens to contain a closing square bracket.
6274 For NIS+, data can be enclosed in double quotes like this:
6275 .display asis
6276 [name="$local_part"]
6277 .endd
6278 but this still leaves the problem of a double quote in the data. The rule for
6279 NIS+ is that double quotes must be doubled. Other lookup types have different
6280 rules, and to cope with the differing requirements, an expansion operator
6281 of the following form is provided:
6282 .display
6283 @$@{quote@_<<lookup-type>>:<<string>>@}
6284 .endd
6285 For example, the safest way to write the NIS+ query is
6286 .display asis
6287 [name="${quote_nisplus:$local_part}"]
6288 .endd
6289 See chapter ~~CHAPexpand for full coverage of string expansions. The quote
6290 operator can be used for all lookup types, but has no effect for single-key
6291 lookups, since no quoting is ever needed in their key strings.
6292
6293
6294
6295 .section More about dnsdb
6296 .rset SECTdnsdb "~~chapter.~~section"
6297 .index dnsdb lookup
6298 .index lookup||dnsdb
6299 .index DNS||as a lookup type
6300 The \%dnsdb%\ lookup type uses the DNS as its database. A simple query consists
6301 of a record type and a domain name, separated by an equals sign. For example,
6302 an expansion string could contain:
6303 .display asis
6304 ${lookup dnsdb{mx=a.b.example}{$value}fail}
6305 .endd
6306 The supported DNS record types are A, CNAME, MX, NS, PTR, SRV, and TXT, and,
6307 when Exim is compiled with IPv6 support, AAAA (and A6 if that is also
6308 configured). If no type is given, TXT is assumed. When the type is PTR,
6309 .em
6310 the data can be an IP address, written as normal; inversion and the addition of
6311 \in-addr.arpa\ or \ip6.arpa\ happens automatically. For example:
6312 .display asis
6313 ${lookup dnsdb{ptr=192.168.4.5}{$value}fail}
6314 .endd
6315 If the data for a PTR record is not a syntactically valid IP address, it is not
6316 altered and nothing is added.
6317
6318 For any record type, if multiple records are found (or, for A6 lookups, if a
6319 single record leads to multiple addresses), the data is returned as a
6320 concatenation, with newline as the default separator. The order, of course,
6321 depends on the DNS resolver. You can specify a different separator character
6322 between multiple records by putting a right angle-bracket followed immediately
6323 by the new separator at the start of the query. For example:
6324 .display asis
6325 ${lookup dnsdb{>: a=host1.example}}
6326 .endd
6327 It is permitted to specify a space as the separator character. Further 
6328 whitespace is ignored.
6329
6330 .index SRV record||in \%dnsdb%\ lookup
6331 For SRV records, the priority, weight, port, and host name are returned for 
6332 each record, separated by spaces.
6333
6334 .index MX record||in \%dnsdb%\ lookup
6335 For MX records, both the preference value and the host name are returned for 
6336 each record, separated by a space. However, if you want only host names, you
6337 can use the pseudo-type MXH:
6338 .display asis
6339 ${lookup dnsdb{mxh=a.b.example}}
6340 .endd
6341 In this case, the preference values are omitted.
6342
6343 .index name server||for enclosing domain
6344 Another pseudo-type is ZNS (for `zone NS'). It performs a lookup for NS
6345 records on the given domain, but if none are found, it removes the first
6346 component of the domain name, and tries again. This process continues until NS
6347 records are found or there are no more components left (or there is a DNS
6348 error). In other words, it may return the name servers for a top-level domain,
6349 but it never returns the root name servers. If there are no NS records for the
6350 top-level domain, the lookup fails. Consider these examples:
6351 .display asis
6352 ${lookup dnsdb{zns=xxx.quercite.com}} 
6353 ${lookup dnsdb{zns=xxx.edu}}
6354 .endd
6355 Assuming that in each case there are no NS records for the full domain name,
6356 the first returns the name servers for \quercite.com\, and the second returns
6357 the name servers for \edu\.
6358
6359 You should be careful about how you use this lookup because, unless the
6360 top-level domain does not exist, the lookup always returns some host names. The
6361 sort of use to which this might be put is for seeing if the name servers for a
6362 given domain are on a blacklist. You can probably assume that the name servers
6363 for the high-level domains such as \com\ or \co.uk\ are not going to be on such
6364 a list.
6365
6366 .nem
6367
6368 .em
6369 .section Multiple dnsdb lookups
6370 In the previous section, \%dnsdb%\ lookups for a single domain are described.
6371 However, you can specify a list of domains or IP addresses in a single
6372 \%dnsdb%\ lookup. The list is specified in the normal Exim way, with colon as
6373 the default separator, but with the ability to change this. For example:
6374 .display asis
6375 ${lookup dnsdb{one.domain.com:two.domain.com}}
6376 ${lookup dnsdb{a=one.host.com:two.host.com}}
6377 ${lookup dnsdb{ptr = <; 1.2.3.4 ; 4.5.6.8}}
6378 .endd
6379 In order to retain backwards compatibility, there is one special case: if
6380 the lookup type is PTR and no change of separator is specified, Exim looks
6381 to see if the rest of the string is precisely one IPv6 address. In this
6382 case, it does not treat it as a list.
6383
6384 The data from each lookup is concatenated, with newline separators by default,
6385 in the same way that multiple DNS records for a single item are handled. A 
6386 different separator can be specified, as described above.
6387
6388 The \%dnsdb%\ lookup fails only if all the DNS lookups fail. If there is a
6389 temporary DNS error for any of them, the behaviour is controlled by
6390 an optional keyword followed by a comma that may appear before the record
6391 type. The possible keywords are `defer@_strict', `defer@_never', and
6392 `defer@_lax'. With `strict' behaviour, any temporary DNS error causes the
6393 whole lookup to defer. With `never' behaviour, a temporary DNS error is
6394 ignored, and the behaviour is as if the DNS lookup failed to find anything.
6395 With `lax' behaviour, all the queries are attempted, but a temporary DNS
6396 error causes the whole lookup to defer only if none of the other lookups
6397 succeed. The default is `lax', so the following lookups are equivalent:
6398 .display asis
6399 ${lookup dnsdb{defer_lax,a=one.host.com:two.host.com}}
6400 ${lookup dnsdb{a=one.host.com:two.host.com}}
6401 .endd
6402 Thus, in the default case, as long as at least one of the DNS lookups
6403 yields some data, the lookup succeeds.
6404 .nem
6405
6406
6407 .section More about LDAP
6408 .rset SECTldap "~~chapter.~~section"
6409 .index LDAP lookup
6410 .index lookup||LDAP
6411 .index Solaris||LDAP
6412 The original LDAP implementation came from the University of Michigan; this has
6413 become `Open LDAP', and there are now two different releases. Another
6414 implementation comes from Netscape, and Solaris 7 and subsequent releases
6415 contain inbuilt LDAP support. Unfortunately, though these are all compatible at
6416 the lookup function level, their error handling is different. For this reason
6417 it is necessary to set a compile-time variable when building Exim with LDAP, to
6418 indicate which LDAP library is in use. One of the following should appear in
6419 your \(Local/Makefile)\:
6420 .display asis
6421 LDAP_LIB_TYPE=UMICHIGAN
6422 LDAP_LIB_TYPE=OPENLDAP1
6423 LDAP_LIB_TYPE=OPENLDAP2
6424 LDAP_LIB_TYPE=NETSCAPE
6425 LDAP_LIB_TYPE=SOLARIS
6426 .endd
6427 If \\LDAP@_LIB@_TYPE\\ is not set, Exim assumes \"OPENLDAP1"\, which has the
6428 same interface as the University of Michigan version.
6429
6430 There are three LDAP lookup types in Exim. These behave slightly differently in
6431 the way they handle the results of a query:
6432 .numberpars $.
6433 \%ldap%\ requires the result to contain just one entry; if there are more, it
6434 gives an error.
6435 .nextp
6436 \%ldapdn%\ also requires the result to contain just one entry, but it is the
6437 Distinguished Name that is returned rather than any attribute values.
6438 .nextp
6439 \%ldapm%\ permits the result to contain more than one entry; the attributes from
6440 all of them are returned.
6441 .endp
6442
6443 For \%ldap%\ and \%ldapm%\, if a query finds only entries with no attributes,
6444 Exim behaves as if the entry did not exist, and the lookup fails. The format of
6445 the data returned by a successful lookup is described in the next section.
6446 First we explain how LDAP queries are coded.
6447
6448 .section Format of LDAP queries
6449 .rset SECTforldaque "~~chapter.~~section"
6450 .index LDAP||query format
6451 An LDAP query takes the form of a URL as defined in RFC 2255. For example, in
6452 the configuration of a \%redirect%\ router one might have this setting:
6453 .display asis
6454 data = ${lookup ldap \
6455   {ldap:///cn=$local_part,o=University%20of%20Cambridge,\
6456   c=UK?mailbox?base?}}
6457 .endd
6458 .index LDAP||with TLS
6459 The URL may begin with \"ldap"\ or \"ldaps"\ if your LDAP library supports
6460 secure (encrypted) LDAP connections. The second of these ensures that an
6461 encrypted TLS connection is used.
6462
6463 .section LDAP quoting
6464 .index LDAP||quoting
6465 Two levels of quoting are required in LDAP queries, the first for LDAP itself
6466 and the second because the LDAP query is represented as a URL. Furthermore,
6467 within an LDAP query, two different kinds of quoting are required. For this
6468 reason, there are two different LDAP-specific quoting operators.
6469
6470 The \quote@_ldap\ operator is designed for use on strings that are part of
6471 filter specifications. Conceptually, it first does the following conversions on
6472 the string:
6473 .display asis
6474 *   =>   \2A
6475 (   =>   \28
6476 )   =>   \29
6477 \   =>   \5C
6478 .endd
6479 in accordance with RFC 2254. The resulting string is then quoted according
6480 to the rules for URLs, that is, all characters except
6481 .display asis
6482 ! $ ' - . _ ( ) * +
6483 .endd
6484 are converted to their hex values, preceded by a percent sign. For example:
6485 .display asis
6486 ${quote_ldap: a(bc)*, a<yz>; }
6487 .endd
6488 yields
6489 .display asis
6490 %20a%5C28bc%5C29%5C2A%2C%20a%3Cyz%3E%3B%20
6491 .endd
6492 Removing the URL quoting, this is (with a leading and a trailing space):
6493 .display asis
6494 a\28bc\29\2A, a<yz>;
6495 .endd
6496
6497 The \quote@_ldap@_dn\ operator is designed for use on strings that are part of
6498 base DN specifications in queries. Conceptually, it first converts the string
6499 by inserting a backslash in front of any of the following characters:
6500 .display asis
6501 , + " \ < > ;
6502 .endd
6503 It also inserts a backslash before any leading spaces or @# characters, and
6504 before any trailing spaces. (These rules are in RFC 2253.) The resulting string
6505 is then quoted according to the rules for URLs. For example:
6506 .display asis
6507 ${quote_ldap_dn: a(bc)*, a<yz>; }
6508 .endd
6509 yields
6510 .display asis
6511 %5C%20a(bc)*%5C%2C%20a%5C%3Cyz%5C%3E%5C%3B%5C%20
6512 .endd
6513 Removing the URL quoting, this is (with a trailing space):
6514 .display asis
6515 \ a(bc)*\, a\<yz\>\;\
6516 .endd
6517 There are some further comments about quoting in the section on LDAP
6518 authentication below.
6519
6520 .section LDAP connections
6521 .index LDAP||connections
6522 The connection to an LDAP server may either be over TCP/IP, or, when OpenLDAP
6523 is in use, via a Unix domain socket. The example given above does not specify
6524 an LDAP server. A server that is reached by TCP/IP can be specified in a query
6525 by starting it with
6526 .display
6527 ldap://<<hostname>>:<<port>>/...
6528 .endd
6529 If the port (and preceding colon) are omitted, the standard LDAP port (389) is
6530 used. When no server is specified in a query, a list of default servers is
6531 taken from the \ldap@_default@_servers\ configuration option. This supplies a
6532 colon-separated list of servers which are tried in turn until one successfully
6533 handles a query, or there is a serious error. Successful handling either
6534 returns the requested data, or indicates that it does not exist. Serious errors
6535 are syntactical, or multiple values when only a single value is expected.
6536 Errors which cause the next server to be tried are connection failures, bind
6537 failures, and timeouts.
6538
6539 For each server name in the list, a port number can be given. The standard way
6540 of specifing a host and port is to use a colon separator (RFC 1738). Because
6541 \ldap@_default@_servers\ is a colon-separated list, such colons have to be
6542 doubled. For example
6543 .display asis
6544 ldap_default_servers = ldap1.example.com::145:ldap2.example.com
6545 .endd
6546 If \ldap@_default@_servers\ is unset, a URL with no server name is passed
6547 to the LDAP library with no server name, and the library's default (normally
6548 the local host) is used.
6549
6550 If you are using the OpenLDAP library, you can connect to an LDAP server using
6551 a Unix domain socket instead of a TCP/IP connection. This is specified by using
6552 \"ldapi"\ instead of \"ldap"\ in LDAP queries. What follows here applies only
6553 to OpenLDAP. If Exim is compiled with a different LDAP library, this feature is
6554 not available.
6555
6556 For this type of connection, instead of a host name for the server, a pathname
6557 for the socket is required, and the port number is not relevant. The pathname
6558 can be specified either as an item in \ldap@_default@_servers\, or inline in
6559 the query. In the former case, you can have settings such as
6560 .display asis
6561 ldap_default_servers = /tmp/ldap.sock : backup.ldap.your.domain
6562 .endd
6563 When the pathname is given in the query, you have to escape the slashes as
6564 \"%2F"\ to fit in with the LDAP URL syntax. For example:
6565 .display asis
6566 ${lookup ldap {ldapi://%2Ftmp%2Fldap.sock/o=...
6567 .endd
6568 When Exim processes an LDAP lookup and finds that the `hostname' is really
6569 a pathname, it uses the Unix domain socket code, even if the query actually
6570 specifies \"ldap"\ or \"ldaps"\. In particular, no encryption is used for a
6571 socket connection. This behaviour means that you can use a setting of
6572 \ldap@_default@_servers\ such as in the example above with traditional \"ldap"\
6573 or \"ldaps"\ queries, and it will work. First, Exim tries a connection via
6574 the Unix domain socket; if that fails, it tries a TCP/IP connection to the
6575 backup host.
6576
6577 If an explicit \"ldapi"\ type is given in a query when a host name is
6578 specified, an error is diagnosed. However, if there are more items in
6579 \ldap@_default@_servers\, they are tried. In other words:
6580 .numberpars $.
6581 Using a pathname with \"ldap"\ or \"ldaps"\ forces the use of the Unix domain
6582 interface.
6583 .nextp
6584 Using \"ldapi"\ with a host name causes an error.
6585 .endp
6586
6587 Using \"ldapi"\ with no host or path in the query, and no setting of
6588 \ldap@_default@_servers\, does whatever the library does by default.
6589
6590
6591 .section LDAP authentication and control information
6592 .index LDAP||authentication
6593 The LDAP URL syntax provides no way of passing authentication and other control
6594 information to the server. To make this possible, the URL in an LDAP query may
6595 be preceded by any number of `<<name>>=<<value>>' settings, separated by
6596 spaces. If a value contains spaces it must be enclosed in double quotes, and
6597 when double quotes are used, backslash is interpreted in the usual way inside
6598 them. The following names are recognized:
6599 .display
6600 DEREFERENCE $rm{set the dereferencing parameter}
6601 .newline
6602 .em
6603 NETTIME     $rm{set a timeout for a network operation}
6604 .nem
6605 .newline
6606 USER        $rm{set the DN, for authenticating the LDAP bind}
6607 PASS        $rm{set the password, likewise}
6608 SIZE        $rm{set the limit for the number of entries returned}
6609 TIME        $rm{set the maximum waiting time for a query}
6610 .endd
6611 The value of the \\DEREFERENCE\\ parameter must be one of the words `never',
6612 `searching', `finding', or `always'.
6613
6614 .em
6615 The name \\CONNECT\\ is an obsolete name for \\NETTIME\\, retained for
6616 backwards compatibility. This timeout (specified as a number of seconds) is
6617 enforced from the client end for operations that can be carried out over a
6618 network. Specifically, it applies to network connections and calls to the
6619 \*ldap@_result()*\ function. If the value is greater than zero, it is used if
6620 \\LDAP@_OPT@_NETWORK@_TIMEOUT\\ is defined in the LDAP headers (OpenLDAP), or 
6621 if \\LDAP@_X@_OPT@_CONNECT@_TIMEOUT\\ is defined in the LDAP headers (Netscape 
6622 SDK 4.1). A value of zero forces an explicit setting of `no timeout' for 
6623 Netscape SDK; for OpenLDAP no action is taken.
6624
6625 The \\TIME\\ parameter (also a number of seconds) is passed to the server to
6626 set a server-side limit on the time taken to complete a search.
6627 .nem
6628
6629 Here is an example of an LDAP query in an Exim lookup that uses some of these
6630 values. This is a single line, folded for ease of reading:
6631 .display asis
6632 .indent 0
6633 ${lookup ldap
6634   {user="cn=manager,o=University of Cambridge,c=UK" pass=secret
6635   ldap:///o=University%20of%20Cambridge,c=UK?sn?sub?(cn=foo)}
6636   {$value}fail}
6637 .endd
6638 The encoding of spaces as %20 is a URL thing which should not be done for any
6639 of the auxiliary data. Exim configuration settings that include lookups which
6640 contain password information should be preceded by `hide' to prevent non-admin
6641 users from using the \-bP-\ option to see their values.
6642
6643 The auxiliary data items may be given in any order. The default is no
6644 connection timeout (the system timeout is used), no user or password, no limit
6645 on the number of entries returned, and no time limit on queries.
6646
6647 When a DN is quoted in the \\USER=\\ setting for LDAP authentication, Exim
6648 removes any URL quoting that it may contain before passing it LDAP. Apparently
6649 some libraries do this for themselves, but some do not. Removing the URL
6650 quoting has two advantages:
6651 .numberpars $.
6652 It makes it possible to use the same \quote@_ldap@_dn\ expansion for \\USER=\\
6653 DNs as with DNs inside actual queries.
6654 .nextp
6655 It permits spaces inside \\USER=\\ DNs.
6656 .endp
6657 For example, a setting such as
6658 .display asis
6659 USER=cn=${quote_ldap_dn:$1}
6660 .endd
6661 should work even if \$1$\ contains spaces.
6662
6663 Expanded data for the \\PASS=\\ value should be quoted using the \quote\
6664 expansion operator, rather than the LDAP quote operators. The only reason this
6665 field needs quoting is to ensure that it conforms to the Exim syntax, which
6666 does not allow unquoted spaces. For example:
6667 .display asis
6668 PASS=${quote:$3}
6669 .endd
6670
6671 The LDAP authentication mechanism can be used to check passwords as part of
6672 SMTP authentication. See the \ldapauth\ expansion string condition in chapter
6673 ~~CHAPexpand.
6674
6675
6676 .section Format of data returned by LDAP
6677 .index LDAP||returned data formats
6678 The \%ldapdn%\ lookup type returns the Distinguished Name from a single entry as
6679 a sequence of values, for example
6680 .display asis
6681 cn=manager, o=University of Cambridge, c=UK
6682 .endd
6683
6684 The \%ldap%\ lookup type generates an error if more than one entry matches the
6685 search filter, whereas \%ldapm%\ permits this case, and inserts a newline in
6686 the result between the data from different entries. It is possible for multiple
6687 values to be returned for both \%ldap%\ and \%ldapm%\, but in the former case
6688 you know that whatever values are returned all came from a single entry in the
6689 directory.
6690
6691 In the common case where you specify a single attribute in your LDAP query, the
6692 result is not quoted, and does not contain the attribute name. If the attribute
6693 has multiple values, they are separated by commas.
6694
6695 If you specify multiple attributes, the result contains space-separated, quoted
6696 strings, each preceded by the attribute name and an equals sign. Within the
6697 quotes, the quote character, backslash, and newline are escaped with
6698 backslashes, and commas are used to separate multiple values for the attribute.
6699 Apart from the escaping, the string within quotes takes the same form as the
6700 output when a single attribute is requested. Specifying no attributes is the
6701 same as specifying all of an entry's attributes.
6702
6703 Here are some examples of the output format. The first line of each pair is an
6704 LDAP query, and the second is the data that is returned. The attribute called
6705 \attr1\ has two values, whereas \attr2\ has only one value:
6706 .display asis
6707 ldap:///o=base?attr1?sub?(uid=fred)
6708 value1.1, value1.2
6709
6710 ldap:///o=base?attr2?sub?(uid=fred)
6711 value two
6712
6713 ldap:///o=base?attr1,attr2?sub?(uid=fred)
6714 attr1="value1.1, value1.2" attr2="value two"
6715
6716 ldap:///o=base??sub?(uid=fred)
6717 objectClass="top" attr1="value1.1, value1.2" attr2="value two"
6718 .endd
6719 The \extract\ operator in string expansions can be used to pick out individual
6720 fields from data that consists of $it{key}=$it{value} pairs. You can make use
6721 of Exim's \-be-\ option to run expansion tests and thereby check the results of
6722 LDAP lookups.
6723
6724
6725
6726 .section More about NIS+
6727 .rset SECTnisplus "~~chapter.~~section"
6728 .index NIS@+ lookup type
6729 .index lookup||NIS+
6730 NIS+ queries consist of a NIS+ \*indexed name*\ followed by an optional colon
6731 and field name. If this is given, the result of a successful query is the
6732 contents of the named field; otherwise the result consists of a concatenation
6733 of \*field-name=field-value*\ pairs, separated by spaces. Empty values and
6734 values containing spaces are quoted. For example, the query
6735 .display asis
6736 [name=mg1456],passwd.org_dir
6737 .endd
6738 might return the string
6739 .display asis
6740 name=mg1456 passwd="" uid=999 gid=999 gcos="Martin Guerre"
6741 home=/home/mg1456 shell=/bin/bash shadow=""
6742 .endd
6743 (split over two lines here to fit on the page), whereas
6744 .display asis
6745 [name=mg1456],passwd.org_dir:gcos
6746 .endd
6747 would just return
6748 .display asis
6749 Martin Guerre
6750 .endd
6751 with no quotes. A NIS+ lookup fails if NIS+ returns more than one table entry
6752 for the given indexed key. The effect of the \quote@_nisplus\ expansion
6753 operator is to double any quote characters within the text.
6754
6755
6756 .section More about MySQL, PostgreSQL, Oracle, and Interbase
6757 .rset SECTsql "~~chapter.~~section"
6758 .index MySQL||lookup type
6759 .index PostgreSQL lookup type
6760 .index lookup||MySQL
6761 .index lookup||PostgreSQL
6762 .index Oracle||lookup type
6763 .index lookup||Oracle
6764 .index Interbase lookup type
6765 .index lookup||Interbase
6766 If any MySQL, PostgreSQL, Oracle, or Interbase lookups are used, the
6767 \mysql@_servers\, \pgsql@_servers\, \oracle@_servers\, or \ibase@_servers\
6768 option (as appropriate) must be set to a colon-separated list of server
6769 information. Each item in the list is a slash-separated list of four items:
6770 host name, database name, user name, and password. In the case of Oracle, the
6771 host name field is used for the `service name', and the database name field is
6772 not used and should be empty. For example:
6773 .display asis
6774 hide oracle_servers = oracle.plc.example//ph10/abcdwxyz
6775 .endd
6776 Because password data is sensitive, you should always precede the setting with
6777 `hide', to prevent non-admin users from obtaining the setting via the \-bP-\
6778 option. Here is an example where two MySQL servers are listed:
6779 .display asis
6780 hide mysql_servers = localhost/users/root/secret:\
6781                      otherhost/users/root/othersecret
6782 .endd
6783 For MySQL and PostgreSQL, a host may be specified as <<name>>:<<port>> but
6784 because this is a colon-separated list, the colon has to be doubled.
6785
6786 For each query, these parameter groups are tried in order until a connection
6787 and a query succeeds. Queries for these databases are SQL statements, so an
6788 example might be
6789 .display asis
6790 .indent 0
6791 ${lookup mysql{select mailbox from users where id='ph10'}{$value}fail}
6792 .endd
6793 If the result of the query contains more than one field, the data for
6794 each field in the row is returned, preceded by its name, so the result
6795 of
6796 .display asis
6797 .indent 0
6798 ${lookup pgsql{select home,name from users where id='ph10'}{$value}}
6799 .endd
6800 might be
6801 .display asis
6802 home=/home/ph10 name="Philip Hazel"
6803 .endd
6804 Values containing spaces and empty values are double quoted, with embedded
6805 quotes escaped by a backslash.
6806
6807 If the result of the query contains just one field, the value is passed back
6808 verbatim, without a field name, for example:
6809 .display asis
6810 Philip Hazel
6811 .endd
6812 If the result of the query yields more than one row, it is all concatenated,
6813 with a newline between the data for each row.
6814
6815 The \quote@_mysql\, \quote@_pgsql\, and \quote@_oracle\ expansion operators
6816 convert newline, tab, carriage return, and backspace to @\n, @\t, @\r, and @\b
6817 respectively, and the characters single-quote, double-quote, and backslash
6818 itself are escaped with backslashes. The \quote@_pgsql\ expansion operator, in
6819 addition, escapes the percent and underscore characters. This cannot be done
6820 for MySQL because these escapes are not recognized in contexts where these
6821 characters are not special.
6822
6823
6824 .section Special MySQL features
6825 For MySQL, an empty host name or the use of `localhost' in \mysql@_servers\
6826 causes a connection to the server on the local host by means of a Unix domain
6827 socket. An alternate socket can be specified in parentheses. The full syntax of
6828 each item in \mysql@_servers\ is:
6829 .display
6830 <<hostname>>@:@:<<port>>(<<socket name>>)/<<database>>/<<user>>/<<password>>
6831 .endd
6832 Any of the three sub-parts of the first field can be omitted. For normal use on
6833 the local host it can be left blank or set to just `localhost'.
6834
6835 No database need be supplied -- but if it is absent here, it must be given in
6836 the queries.
6837
6838 If a MySQL query is issued that does not request any data (an insert, update,
6839 or delete command), the result of the lookup is the number of rows affected.
6840 .em
6841 \**Warning**\: this can be misleading. If an update does not actually change 
6842 anything (for example, setting a field to the value it already has), the result 
6843 is zero because no rows are affected.
6844 .nem
6845
6846
6847 .section Special PostgreSQL features
6848 PostgreSQL lookups can also use Unix domain socket connections to the database.
6849 This is usually faster and costs less CPU time than a TCP/IP connection.
6850 However it can be used only if the mail server runs on the same machine as the
6851 database server. A configuration line for PostgreSQL via Unix domain sockets
6852 looks like this:
6853 .display asis
6854 hide pgsql_servers = (/tmp/.s.PGSQL.5432)/db/user/password : ...
6855 .endd
6856 In other words, instead of supplying a host name, a path to the socket is
6857 given. The path name is enclosed in parentheses so that its slashes aren't
6858 visually confused with the delimiters for the other server parameters.
6859
6860 If a PostgreSQL query is issued that does not request any data (an insert,
6861 update, or delete command), the result of the lookup is the number of rows
6862 affected.
6863
6864
6865
6866
6867 .
6868 .
6869 .
6870 .
6871 . ============================================================================
6872 .chapter Domain, host, address, and local part lists
6873 .set runningfoot "domain, host, and address lists"
6874 .rset CHAPdomhosaddlists "~~chapter"
6875 .index list||of domains, hosts, etc.
6876 A number of Exim configuration options contain lists of domains, hosts,
6877 email addresses, or local parts. For example, the \hold@_domains\ option
6878 contains a list of domains whose delivery is currently suspended. These lists
6879 are also used as data in ACL statements (see chapter ~~CHAPACL).
6880
6881 Each item in one of these lists is a pattern to be matched against a domain,
6882 host, email address, or local part, respectively. In the sections below, the
6883 different types of pattern for each case are described, but first we cover some
6884 general facilities that apply to all four kinds of list.
6885
6886
6887 .section Expansion of lists
6888 .index expansion||of lists
6889 .em
6890 Each list is expanded as a single string before it is used. The result of
6891 expansion must be a list, possibly containing empty items, which is split up 
6892 into separate items for matching. By default, colon is the separator character,
6893 but this can be varied if necessary. See sections ~~SECTlistconstruct and
6894 ~~SECTempitelis for details of the list syntax; the second of these discusses  
6895 the way you specify empty list items.
6896 .nem
6897
6898 If the string expansion is forced to fail, Exim behaves as if the item it is
6899 testing (domain, host, address, or local part) is not in the list. Other
6900 expansion failures cause temporary errors.
6901
6902 If an item in a list is a regular expression, backslashes, dollars and possibly
6903 other special characters in the expression must be protected against
6904 misinterpretation by the string expander. The easiest way to do this is to use
6905 the \"@\N"\ expansion feature to indicate that the contents of the regular
6906 expression should not be expanded. For example, in an ACL you might have:
6907 .display asis
6908 deny senders = \N^\d{8}\w@.*\.baddomain\.example$\N :
6909                ${lookup{$domain}lsearch{/badsenders/bydomain}}
6910 .endd
6911 The first item is a regular expression that is protected from expansion by
6912 \"@\N"\, whereas the second uses the expansion to obtain a list of unwanted
6913 senders based on the receiving domain.
6914
6915
6916
6917 .section Negated items in lists
6918 .index list||negation
6919 .index negation in lists
6920 Items in a list may be positive or negative. Negative items are indicated by a
6921 leading exclamation mark, which may be followed by optional white space. A list
6922 defines a set of items (domains, etc). When Exim processes one of these lists,
6923 it is trying to find out whether a domain, host, address, or local part
6924 (respectively) is in the set that is defined by the list. It works like this:
6925
6926 The list is scanned from left to right. If a positive item is matched, the
6927 subject that is being checked is in the set; if a negative item is matched, the
6928 subject is not in the set. If the end of the list is reached without the
6929 subject having matched any of the patterns, it is in the set if the last item
6930 was a negative one, but not if it was a positive one. For example, the list in
6931 .display asis
6932 domainlist relay_domains = !a.b.c : *.b.c
6933 .endd
6934 matches any domain ending in \*.b.c*\ except for \*a.b.c*\. Domains that match
6935 neither \*a.b.c*\ nor \*@*.b.c*\ do not match, because the last item in the
6936 list is positive. However, if the setting were
6937 .display asis
6938 domainlist relay_domains = !a.b.c
6939 .endd
6940 then all domains other than \*a.b.c*\ would match because the last item in the
6941 list is negative. In other words, a list that ends with a negative item behaves
6942 as if it had an extra item \":*"\ on the end.
6943
6944 Another way of thinking about positive and negative items in lists is to read
6945 the connector as `or' after a positive item and as `and' after a negative
6946 item.
6947
6948
6949 .section File names in lists
6950 .rset SECTfilnamlis "~~chapter.~~section"
6951 .index list||file name in
6952 If an item in a domain, host, address, or local part list is an absolute file
6953 name (beginning with a slash character), each line of the file is read and
6954 processed as if it were an independent item in the list, except that further
6955 file names are not allowed,
6956 and no expansion of the data from the file takes place.
6957 Empty lines in the file are ignored, and the file may also contain comment
6958 lines:
6959 .numberpars $.
6960 For domain and host lists, if a @# character appears anywhere in a line of the
6961 file, it and all following characters are ignored.
6962 .nextp
6963 Because local parts may legitimately contain @# characters, a comment in an
6964 address list or local part list file is recognized only if @# is preceded by
6965 white space or the start of the line. For example:
6966 .display asis
6967 not#comment@x.y.z   # but this is a comment
6968 .endd
6969 .endp
6970 Putting a file name in a list has the same effect as inserting each line of the
6971 file as an item in the list (blank lines and comments excepted). However, there
6972 is one important difference: the file is read each time the list is processed,
6973 so if its contents vary over time, Exim's behaviour changes.
6974
6975 If a file name is preceded by an exclamation mark, the sense of any match
6976 within the file is inverted. For example, if
6977 .display asis
6978 hold_domains = !/etc/nohold-domains
6979 .endd
6980 and the file contains the lines
6981 .display asis
6982 !a.b.c
6983 *.b.c
6984 .endd
6985 then \*a.b.c*\ is in the set of domains defined by \hold@_domains\, whereas any
6986 domain matching \"*.b.c"\ is not.
6987
6988
6989 .section An lsearch file is not an out-of-line list
6990 As will be described in the sections that follow, lookups can be used in lists
6991 to provide indexed methods of checking list membership. There has been some
6992 confusion about the way \%lsearch%\ lookups work in lists. Because
6993 an \%lsearch%\ file contains plain text and is scanned sequentially, it is
6994 sometimes thought that it is allowed to contain wild cards and other kinds of
6995 non-constant pattern. This is not the case. The keys in an \%lsearch%\ file are
6996 always fixed strings, just as for any other single-key lookup type.
6997
6998 If you want to use a file to contain wild-card patterns that form part of a
6999 list, just give the file name on its own, without a search type, as described
7000 in the previous section.
7001
7002
7003
7004 .section Named lists
7005 .rset SECTnamedlists "~~chapter.~~section"
7006 .index named lists
7007 .index list||named
7008 A list of domains, hosts, email addresses, or local parts can be given a name
7009 which is then used to refer to the list elsewhere in the configuration. This is
7010 particularly convenient if the same list is required in several different
7011 places. It also allows lists to be given meaningful names, which can improve
7012 the readability of the configuration. For example, it is conventional to define
7013 a domain list called \*local@_domains*\ for all the domains that are handled
7014 locally on a host, using a configuration line such as
7015 .display asis
7016 domainlist local_domains = localhost:my.dom.example
7017 .endd
7018 Named lists are referenced by giving their name preceded by a plus sign, so,
7019 for example, a router that is intended to handle local domains would be
7020 configured with the line
7021 .display asis
7022 domains = +local_domains
7023 .endd
7024 The first router in a configuration is often one that handles all domains
7025 except the local ones, using a configuration with a negated item like this:
7026 .display asis
7027 dnslookup:
7028   driver = dnslookup
7029   domains = ! +local_domains
7030   transport = remote_smtp
7031   no_more
7032 .endd
7033 The four kinds of named list are created by configuration lines starting with
7034 the words \domainlist\, \hostlist\, \addresslist\, or \localpartlist\,
7035 respectively. Then there follows the name that you are defining, followed by an
7036 equals sign and the list itself. For example:
7037 .display asis
7038 hostlist    relay_hosts = 192.168.23.0/24 : my.friend.example
7039 addresslist bad_senders = cdb;/etc/badsenders
7040 .endd
7041 A named list may refer to other named lists:
7042 .display asis
7043 domainlist  dom1 = first.example : second.example
7044 domainlist  dom2 = +dom1 : third.example
7045 domainlist  dom3 = fourth.example : +dom2 : fifth.example
7046 .endd
7047
7048 \**Warning**\: If the last item in a referenced list is a negative one, the
7049 effect may not be what you intended, because the negation does not propagate
7050 out to the higher level. For example, consider:
7051 .display asis
7052 domainlist  dom1 = !a.b
7053 domainlist  dom2 = +dom1 : *.b
7054 .endd
7055 The second list specifies `either in the \dom1\ list or \*@*.b*\'. The first
7056 list specifies just `not \*a.b*\', so the domain \*x.y*\ matches it. That means
7057 it matches the second list as well. The effect is not the same as
7058 .display asis
7059 domainlist  dom2 = !a.b : *.b
7060 .endd
7061 where \*x.y*\ does not match. It's best to avoid negation altogether in
7062 referenced lists if you can.
7063
7064 Named lists may have a performance advantage. When Exim is routing an
7065 address or checking an incoming message, it caches the result of tests on named
7066 lists. So, if you have a setting such as
7067 .display asis
7068 domains = +local_domains
7069 .endd
7070 on several of your routers
7071 or in several ACL statements,
7072 the actual test is done only for the first one. However, the caching works only
7073 if there are no expansions within the list itself or any sublists that it
7074 references. In other words, caching happens only for lists that are known to be
7075 the same each time they are referenced.
7076
7077 By default, there may be up to 16 named lists of each type. This limit can be
7078 extended by changing a compile-time variable. The use of domain and host lists
7079 is recommended for concepts such as local domains, relay domains, and relay
7080 hosts. The default configuration is set up like this.
7081
7082
7083 .section Named lists compared with macros
7084 .index list||named compared with macro
7085 .index macro||compared with named list
7086 At first sight, named lists might seem to be no different from macros in the
7087 configuration file. However, macros are just textual substitutions. If you
7088 write
7089 .display asis
7090 ALIST = host1 : host2
7091 auth_advertise_hosts = !ALIST
7092 .endd
7093 it probably won't do what you want, because that is exactly the same as
7094 .display asis
7095 auth_advertise_hosts = !host1 : host2
7096 .endd
7097 Notice that the second host name is not negated. However, if you use a host
7098 list, and write
7099 .display asis
7100 hostlist alist = host1 : host2
7101 auth_advertise_hosts = ! +alist
7102 .endd
7103 the negation applies to the whole list, and so that is equivalent to
7104 .display asis
7105 auth_advertise_hosts = !host1 : !host2
7106 .endd
7107
7108
7109 .section Named list caching
7110 .index list||caching of named
7111 .index caching||named lists
7112 While processing a message, Exim caches the result of checking a named list if
7113 it is sure that the list is the same each time. In practice, this means that
7114 the cache operates only if the list contains no @$ characters, which guarantees
7115 that it will not change when it is expanded. Sometimes, however, you may have
7116 an expanded list that you know will be the same each time within a given
7117 message. For example:
7118 .display asis
7119 domainlist special_domains = \
7120            ${lookup{$sender_host_address}cdb{/some/file}}
7121 .endd
7122 This provides a list of domains that depends only on the sending host's IP
7123 address. If this domain list is referenced a number of times (for example,
7124 in several ACL lines, or in several routers) the result of the check is not
7125 cached by default, because Exim does not know that it is going to be the
7126 same list each time.
7127
7128 By appending \"@_cache"\ to \"domainlist"\ you can tell Exim to go ahead and
7129 cache the result anyway. For example:
7130 .display asis
7131 domainlist_cache special_domains = ${lookup{...
7132 .endd
7133 If you do this, you should be absolutely sure that caching is going to do
7134 the right thing in all cases. When in doubt, leave it out.
7135
7136
7137 .section Domain lists
7138 .rset SECTdomainlist "~~chapter.~~section"
7139 .index domain list||patterns for
7140 .index list||domain list
7141 Domain lists contain patterns that are to be matched against a mail domain.
7142 The following types of item may appear in domain lists:
7143 .numberpars $.
7144 .index primary host name
7145 .index host||name, matched in domain list
7146 .index \primary@_hostname\
7147 .index domain list||matching primary host name
7148 .index @@ in a domain list
7149 If a pattern consists of a single @@ character, it matches the local host name,
7150 as set by the \primary@_hostname\ option (or defaulted). This makes it possible
7151 to use the same configuration file on several different hosts that differ only
7152 in their names.
7153 .nextp
7154 .index @@[] in a domain list
7155 .index domain list||matching local IP interfaces
7156 .index domain literal
7157 If a pattern consists of the string \"@@[]"\ it matches any local IP interface
7158 address, enclosed in square brackets, as in an email address that contains a
7159 domain literal.
7160 In today's Internet, the use of domain literals is controversial.
7161 .nextp
7162 .index @@mx@_any
7163 .index @@mx@_primary
7164 .index @@mx@_secondary
7165 .index domain list||matching MX pointers to local host
7166 If a pattern consists of the string \"@@mx@_any"\ it matches any domain that
7167 has an MX record pointing to the local host or to any host that is listed in
7168 .index \hosts@_treat@_as@_local\
7169 \hosts@_treat@_as@_local\. The items \"@@mx@_primary"\ and \"@@mx@_secondary"\
7170 are similar, except that the first matches only when a primary MX target is the
7171 local host, and the second only when no primary MX target is the local host,
7172 but a secondary MX target is. `Primary' means an MX record with the lowest
7173 preference value -- there may of course be more than one of them.
7174
7175 The MX lookup that takes place when matching a pattern of this type is
7176 performed with the resolver options for widening names turned off. Thus, for
7177 example, a single-component domain will \*not*\ be expanded by adding the
7178 resolver's default domain. See the \qualify@_single\ and \search@_parents\
7179 options of the \%dnslookup%\ router for a discussion of domain widening.
7180
7181 Sometimes you may want to ignore certain IP addresses when using one of these
7182 patterns. You can specify this by following the pattern with \"/ignore=<<ip
7183 list>>"\, where <<ip list>> is a list of IP addresses. These addresses are
7184 ignored when processing the pattern (compare the \ignore@_target@_hosts\ option
7185 on a router). For example:
7186 .display asis
7187 domains = @mx_any/ignore=127.0.0.1
7188 .endd
7189 This example matches any domain that has an MX record pointing to one of
7190 the local host's IP addresses other than 127.0.0.1.
7191
7192 The list of IP addresses is in fact processed by the same code that processes
7193 host lists, so it may contain CIDR-coded network specifications and it may also
7194 contain negative items.
7195
7196 Because the list of IP addresses is a sublist within a domain list, you have to
7197 be careful about delimiters if there is more than one address. Like any other
7198 list, the default delimiter can be changed. Thus, you might have:
7199 .display asis
7200 domains = @mx_any/ignore=<;127.0.0.1;0.0.0.0 : \
7201           an.other.domain : ...
7202 .endd
7203 so that the sublist uses semicolons for delimiters. When IPv6 addresses are
7204 involved, it is easiest to change the delimiter for the main list as well:
7205 .display asis
7206 domains = <? @mx_any/ignore=<;127.0.0.1;::1 ? \
7207           an.other.domain ? ...
7208 .endd
7209
7210 .nextp
7211 .index asterisk||in domain list
7212 .index domain list||asterisk in
7213 .index domain list||matching `ends with'
7214 If a pattern starts with an asterisk, the remaining characters of the pattern
7215 are compared with the terminating characters of the domain. The use of `$*$' in
7216 domain lists differs from its use in partial matching lookups. In a domain
7217 list, the character following the asterisk need not be a dot, whereas partial
7218 matching works only in terms of dot-separated components. For example, a domain
7219 list item such as \"*key.ex"\ matches \*donkey.ex*\ as well as
7220 \*cipher.key.ex*\.
7221 .nextp
7222 .index regular expressions||in domain list
7223 .index domain list||matching regular expression
7224 If a pattern starts with a circumflex character, it is treated as a regular
7225 expression, and matched against the domain using a regular expression matching
7226 function. The circumflex is treated as part of the regular expression.
7227 References to descriptions of the syntax of regular expressions are given in
7228 chapter ~~CHAPregexp.
7229
7230 \**Warning**\: Because domain lists are expanded before being processed, you
7231 must escape any backslash and dollar characters in the regular expression, or
7232 use the special \"@\N"\ sequence (see chapter ~~CHAPexpand) to specify that it
7233 is not to be expanded (unless you really do want to build a regular expression
7234 by expansion, of course).
7235 .nextp
7236 .index lookup||in domain list
7237 .index domain list||matching by lookup
7238 If a pattern starts with the name of a single-key lookup type followed by a
7239 semicolon (for example, `dbm;' or `lsearch;'), the remainder of the pattern
7240 must be a file name in a suitable format for the lookup type. For example, for
7241 `cdb;' it must be an absolute path:
7242 .display asis
7243 domains = cdb;/etc/mail/local_domains.cdb
7244 .endd
7245 The appropriate type of lookup is done on the file using the domain name as the
7246 key. In most cases, the data that is looked up is not used; Exim is interested
7247 only in whether or not the key is present in the file. However, when a lookup
7248 is used for the \domains\ option on a router
7249 or a \domains\ condition in an ACL statement, the data is preserved in the
7250 \$domain@_data$\ variable and can be referred to in other router options or
7251 other statements in the same ACL.
7252 .nextp
7253 Any of the single-key lookup type names may be preceded by `partial<<n>>-',
7254 where the <<n>> is optional, for example,
7255 .display asis
7256 domains = partial-dbm;/partial/domains
7257 .endd
7258 This causes partial matching logic to be invoked; a description of how this
7259 works is given in section ~~SECTpartiallookup.
7260 .nextp
7261 .index asterisk||in lookup type
7262 Any of the single-key lookup types may be followed by an asterisk. This causes
7263 a default lookup for a key consisting of a single asterisk to be done if the
7264 original lookup fails. This is not a useful feature when using a domain list to
7265 select particular domains (because any domain would match), but it might have
7266 value if the result of the lookup is being used via the \$domain@_data$\
7267 expansion variable.
7268 .nextp
7269 If the pattern starts with the name of a query-style lookup type followed by a
7270 semicolon (for example, `nisplus;' or `ldap;'), the remainder of the pattern
7271 must be an appropriate query for the lookup type, as described in chapter
7272 ~~CHAPfdlookup. For example:
7273 .display asis
7274 hold_domains = mysql;select domain from holdlist \
7275   where domain = '$domain';
7276 .endd
7277 In most cases, the data that is looked up is not used (so for an SQL query, for
7278 example, it doesn't matter what field you select). Exim is interested only in
7279 whether or not the query succeeds. However, when a lookup is used for the
7280 \domains\ option on a router, the data is preserved in the \$domain@_data$\
7281 variable and can be referred to in other options.
7282 .nextp
7283 .index domain list||matching literal domain name
7284 If none of the above cases apply, a caseless textual comparison is made between
7285 the pattern and the domain.
7286 .endp
7287
7288 Here is an example that uses several different kinds of pattern:
7289 .display asis
7290 domainlist funny_domains = \
7291   @ : \
7292   lib.unseen.edu : \
7293   *.foundation.fict.example : \
7294   \N^[1-2]\d{3}\.fict\.example$\N : \
7295   partial-dbm;/opt/data/penguin/book : \
7296   nis;domains.byname : \
7297   nisplus;[name=$domain,status=local],domains.org_dir
7298 .endd
7299 There are obvious processing trade-offs among the various matching modes. Using
7300 an asterisk is faster than a regular expression, and listing a few names
7301 explicitly probably is too. The use of a file or database lookup is expensive,
7302 but may be the only option if hundreds of names are required. Because the
7303 patterns are tested in order, it makes sense to put the most commonly matched
7304 patterns earlier.
7305
7306
7307 .section Host lists
7308 .rset SECThostlist "~~chapter.~~section"
7309 .index host list||patterns in
7310 .index list||host list
7311 Host lists are used to control what remote hosts are allowed to do. For
7312 example, some hosts may be allowed to use the local host as a relay, and some
7313 may be permitted to use the SMTP \\ETRN\\ command. Hosts can be identified in
7314 two different ways, by name or by IP address. In a host list, some types of
7315 pattern are matched to a host name, and some are matched to an IP address.
7316 You need to be particularly careful with this when single-key lookups are
7317 involved, to ensure that the right value is being used as the key.
7318
7319 .section Special host list patterns
7320 .index empty item in hosts list
7321 .index host list||empty string in
7322 If a host list item is the empty string, it matches only when no remote host is
7323 involved. This is the case when a message is being received from a local
7324 process using SMTP on the standard input, that is, when a TCP/IP connection is
7325 not used.
7326
7327 .index asterisk||in host list
7328 The special pattern `$*$' in a host list matches any host or no host. Neither
7329 the IP address nor the name is actually inspected.
7330
7331
7332 .section Host list patterns that match by IP address
7333 .rset SECThoslispatip "~~chapter.~~section"
7334 .index host list||matching IP addresses
7335 If an IPv4 host calls an IPv6 host and the call is accepted on an IPv6 socket,
7336 the incoming address actually appears in the IPv6 host as
7337 `@:@:$tt{ffff}:<<v4address>>'. When such an address is tested against a host
7338 list, it is converted into a traditional IPv4 address first. (Not all operating
7339 systems accept IPv4 calls on IPv6 sockets, as there have been some security
7340 concerns.)
7341
7342 The following types of pattern in a host list check the remote host by
7343 inspecting its IP address:
7344 .numberpars $.
7345 If the pattern is a plain domain name (not a regular expression, not starting
7346 with $*$, not a lookup of any kind), Exim calls the operating system function
7347 to find the associated IP address(es). Exim uses the newer
7348 \*getipnodebyname()*\ function when available, otherwise \*gethostbyname()*\.
7349 This typically causes a forward DNS lookup of the name. The result is compared
7350 with the IP address of the subject host.
7351
7352 If there is a temporary problem (such as a DNS timeout) with the host name
7353 lookup, a temporary error occurs. For example, if the list is being used in an
7354 ACL condition, the ACL gives a `defer' response, usually leading to a temporary
7355 SMTP error code. If no IP address can be found for the host name, what happens
7356 is described in section ~~SECTbehipnot below.
7357
7358 .nextp
7359 .index @@ in a host list
7360 If the pattern is `@@', the primary host name is substituted and used as a
7361 domain name, as just described.
7362 .nextp
7363 If the pattern is an IP address, it is matched against the IP address of the
7364 subject host. IPv4 addresses are given in the normal `dotted-quad' notation.
7365 IPv6 addresses can be given in colon-separated format, but the colons have to
7366 be doubled so as not to be taken as item separators when the default list
7367 separator is used. IPv6 addresses are recognized even when Exim is compiled
7368 without IPv6 support. This means that if they appear in a host list on an
7369 IPv4-only host, Exim will not treat them as host names. They are just addresses
7370 that can never match a client host.
7371 .nextp
7372 .index @@[] in a host list
7373 If the pattern is `@@[]', it matches the IP address of any IP interface on
7374 the local host. For example, if the local host is an IPv4 host with one
7375 interface address 10.45.23.56, these two ACL statements have the same effect:
7376 .display asis
7377 accept hosts = 127.0.0.1 : 10.45.23.56
7378 accept hosts = @[]
7379 .endd
7380 .nextp
7381 If the pattern is an IP address followed by a slash and a mask length (for
7382 example 10.11.42.0/24), it is matched against the IP address of the subject
7383 host under the given mask.
7384 This allows, an entire network of hosts to be included (or excluded) by a
7385 single item.
7386 .index CIDR notation
7387 The mask uses CIDR notation; it specifies the number of address bits that must
7388 match, starting from the most significant end of the address.
7389
7390 \**Note**\: the mask is \*not*\ a count of addresses, nor is it the high number
7391 of a range of addresses. It is the number of bits in the network portion of the
7392 address. The above example specifies a 24-bit netmask, so it matches all 256
7393 addresses in the 10.11.42.0 network. An item such as
7394 .display asis
7395 192.168.23.236/31
7396 .endd
7397 matches just two addresses, 192.168.23.236 and 192.168.23.237. A mask value of
7398 32 for an IPv4 address is the same as no mask at all; just a single address
7399 matches.
7400
7401 Here is another example which shows an IPv4 and an IPv6 network:
7402 .display asis
7403 recipient_unqualified_hosts = 192.168.0.0/16: \
7404                               3ffe::ffff::836f::::/48
7405 .endd
7406 The doubling of list separator characters applies only when these items
7407 appear inline in a host list. It is not required when indirecting via a file.
7408 For example,
7409 .display asis
7410 recipient_unqualified_hosts = /opt/exim/unqualnets
7411 .endd
7412 could make use of a file containing
7413 .display asis
7414 172.16.0.0/12
7415 3ffe:ffff:836f::/48
7416 .endd
7417 to have exactly the same effect as the previous example. When listing IPv6
7418 addresses inline, it is usually more convenient to use the facility for
7419 changing separator characters. This list contains the same two networks:
7420 .display asis
7421 recipient_unqualified_hosts = <; 172.16.0.0/12; \
7422                                  3ffe:ffff:836f::/48
7423 .endd
7424 The separator is changed to semicolon by the leading `<;' at the start of the
7425 list.
7426 .endp
7427
7428
7429 .section Host list patterns for single-key lookups by host address
7430 .rset SECThoslispatsikey "~~chapter.~~section"
7431 .index host list||lookup of IP address
7432 When a host is to be identified by a single-key lookup of its complete IP
7433 address, the pattern takes this form:
7434 .display
7435 net-<<single-key-search-type>>;<<search-data>>
7436 .endd
7437 For example:
7438 .display asis
7439 hosts_lookup = net-cdb;/hosts-by-ip.db
7440 .endd
7441 The text form of the IP address of the subject host is used as the lookup key.
7442 IPv6 addresses are converted to an unabbreviated form, using lower case
7443 letters, with dots as separators because colon is the key terminator in
7444 \%lsearch%\ files. [Colons can in fact be used in keys in \%lsearch%\ files by
7445 quoting the keys, but this is a facility that was added later.] The data
7446 returned by the lookup is not used.
7447
7448 .index IP address||masking
7449 .index host list||masked IP address
7450 Single-key lookups can also be performed using masked IP addresses, using
7451 patterns of this form:
7452 .display
7453 net<<number>>-<<single-key-search-type>>;<<search-data>>
7454 .endd
7455 For example:
7456 .display asis
7457 net24-dbm;/networks.db
7458 .endd
7459 The IP address of the subject host is masked using <<number>> as the mask
7460 length. A textual string is constructed from the masked value, followed by the
7461 mask, and this is used as the lookup key. For example, if the host's IP address
7462 is 192.168.34.6, the key that is looked up for the above example is
7463 `192.168.34.0/24'. IPv6 addresses are converted to a text value using lower
7464 case letters and dots as separators instead of the more usual colon, because
7465 colon is the key terminator in \%lsearch%\ files. Full, unabbreviated IPv6
7466 addresses are always used.
7467
7468 \**Warning**\: Specifing \net32@-\ (for an IPv4 address) or \net128@-\ (for an
7469 IPv6 address) is not the same as specifing just \net@-\ without a number. In
7470 the former case the key strings include the mask value, whereas in the latter
7471 case the IP address is used on its own.
7472
7473
7474 .section Host list patterns that match by host name
7475 .rset SECThoslispatnam "~~chapter.~~section"
7476 .index host||lookup failures
7477 .index unknown host name
7478 .index host list||matching host name
7479 There are several types of pattern that require Exim to know the name of the
7480 remote host. These are either wildcard patterns or lookups by name. (If a
7481 complete hostname is given without any wildcarding, it is used to find an IP
7482 address to match against, as described in the section ~~SECThoslispatip above.)
7483
7484 If the remote host name is not already known when Exim encounters one of these
7485 patterns, it has to be found from the IP address.
7486 Although many sites on the Internet are conscientious about maintaining reverse
7487 DNS data for their hosts, there are also many that do not do this.
7488 Consequently, a name cannot always be found, and this may lead to unwanted
7489 effects. Take care when configuring host lists with wildcarded name patterns.
7490 Consider what will happen if a name cannot be found.
7491
7492 Because of the problems of determining host names from IP addresses, matching
7493 against host names is not as common as matching against IP addresses.
7494
7495 By default, in order to find a host name, Exim first does a reverse DNS lookup;
7496 if no name is found in the DNS, the system function (\*gethostbyaddr()*\ or
7497 \*getipnodebyaddr()*\ if available) is tried. The order in which these lookups
7498 are done can be changed by setting the \host@_lookup@_order\ option.
7499
7500 There are some options that control what happens if a host name cannot be
7501 found. These are described in section ~~SECTbehipnot below.
7502
7503
7504 .index host||alias for
7505 .index alias for host
7506 As a result of aliasing, hosts may have more than one name. When processing any
7507 of the following types of pattern, all the host's names are checked:
7508 .numberpars $.
7509 .index asterisk||in host list
7510 If a pattern starts with `$*$' the remainder of the item must match the end of
7511 the host name. For example, \"*.b.c"\ matches all hosts whose names end in
7512 \*.b.c*\. This special simple form is provided because this is a very common
7513 requirement. Other kinds of wildcarding require the use of a regular
7514 expression.
7515 .nextp
7516 .index regular expressions||in host list
7517 .index host list||regular expression in
7518 If the item starts with `@^' it is taken to be a regular expression which is
7519 matched against the host name. For example,
7520 .display asis
7521 ^(a|b)\.c\.d$
7522 .endd
7523 is a regular expression that matches either of the two hosts \*a.c.d*\ or
7524 \*b.c.d*\. When a regular expression is used in a host list, you must take care
7525 that backslash and dollar characters are not misinterpreted as part of the
7526 string expansion. The simplest way to do this is to use \"@\N"\ to mark that
7527 part of the string as non-expandable. For example:
7528 .display asis
7529 sender_unqualified_hosts = \N^(a|b)\.c\.d$\N : ....
7530 .endd
7531 \**Warning**\: If you want to match a complete host name, you must include the
7532 \"@$"\ terminating metacharacter in the regular expression, as in the above
7533 example. Without it, a match at the start of the host name is all that is
7534 required.
7535 .endp
7536
7537
7538 .section Behaviour when an IP address or name cannot be found
7539 .rset SECTbehipnot "~~chapter.~~section"
7540 .index host||lookup failures
7541 While processing a host list, Exim may need to look up an IP address from a
7542 name (see section ~~SECThoslispatip), or it may need to look up a host name
7543 from an IP address (see section ~~SECThoslispatnam). In either case, the
7544 behaviour when it fails to find the information it is seeking is the same.
7545
7546 .index \"+include@_unknown"\
7547 .index \"+ignore@_unknown"\
7548 By default, Exim behaves as if the host does not match the list. This may not
7549 always be what you want to happen. To change Exim's behaviour, the special
7550 items \"+include@_unknown"\ or \"+ignore@_unknown"\ may appear in the list (at
7551 top level -- they are not recognized in an indirected file).
7552 .numberpars $.
7553 If any item that follows \"+include@_unknown"\ requires information that
7554 cannot found, Exim behaves as if the host does match the list. For example,
7555 .display asis
7556 host_reject_connection = +include_unknown:*.enemy.ex
7557 .endd
7558 rejects connections from any host whose name matches \"*.enemy.ex"\, and also
7559 any hosts whose name it cannot find.
7560 .nextp
7561 If any item that follows \"+ignore@_unknown"\ requires information that cannot
7562 be found, Exim ignores that item and proceeds to the rest of the list. For
7563 example:
7564 .display asis
7565 accept hosts = +ignore_unknown : friend.example : \
7566                192.168.4.5
7567 .endd
7568 accepts from any host whose name is \*friend.example*\ and from 192.168.4.5,
7569 whether or not its host name can be found. Without \"+ignore@_unknown"\, if no
7570 name can be found for 192.168.4.5, it is rejected.
7571 .endp
7572 Both \"+include@_unknown"\ and \"+ignore@_unknown"\ may appear in the same
7573 list. The effect of each one lasts until the next, or until the end of the
7574 list.
7575
7576 \**Note**\: This section applies to permanent lookup failures. It does \*not*\
7577 apply to temporary DNS errors. They always cause a defer action.
7578
7579
7580 .section Host list patterns for single-key lookups by host name
7581 .rset SECThoslispatnamsk "~~chapter.~~section"
7582 .index host||lookup failures
7583 .index unknown host name
7584 .index host list||matching host name
7585 If a pattern is of the form
7586 .display
7587 <<single-key-search-type>>;<<search-data>>
7588 .endd
7589 for example
7590 .display asis
7591 dbm;/host/accept/list
7592 .endd
7593 a single-key lookup is performend, using the host name as its key. If the
7594 lookup succeeds, the host matches the item. The actual data that is looked up
7595 is not used.
7596
7597 \**Reminder**\: With this kind of pattern, you must have host $it{names} as
7598 keys in the file, not IP addresses. If you want to do lookups based on IP
7599 addresses, you must precede the search type with `net-' (see section
7600 ~~SECThoslispatsikey). There is, however, no reason why you could not use two
7601 items in the same list, one doing an address lookup and one doing a name
7602 lookup, both using the same file.
7603
7604
7605 .section Host list patterns for query-style lookups
7606 If a pattern is of the form
7607 .display
7608 <<query-style-search-type>>;<<query>>
7609 .endd
7610 the query is obeyed, and if it succeeds, the host matches the item. The actual
7611 data that is looked up is not used. The variables \$sender@_host@_address$\ and
7612 \$sender@_host@_name$\ can be used in the query. For example:
7613 .display asis
7614 hosts_lookup = pgsql;\
7615   select ip from hostlist where ip='$sender_host_address'
7616 .endd
7617 The value of \$sender@_host@_address$\ for an IPv6 address contains colons. You
7618 can use the \sg\ expansion item to change this if you need to. If you want to
7619 use masked IP addresses in database queries, you can use the \mask\ expansion
7620 operator.
7621
7622 If the query contains a reference to \$sender@_host@_name$\, Exim automatically
7623 looks up the host name if has not already done so. (See section
7624 ~~SECThoslispatnam for comments on finding host names.)
7625
7626 Historical note: prior to release 4.30, Exim would always attempt to find a
7627 host name before running the query, unless the search type was preceded by
7628 \"net-"\. This is no longer the case. For backwards compatibility, \"net-"\ is
7629 still recognized for query-style lookups, but its presence or absence has no
7630 effect. (Of course, for single-key lookups, \"net-"\ $it{is} important.
7631 See section ~~SECThoslispatsikey.)
7632
7633
7634 .section Mixing wildcarded host names and addresses in host lists
7635 .rset SECTmixwilhos "~~chapter.~~section"
7636 .index host list||mixing names and addresses in
7637 If you have name lookups or wildcarded host names and IP addresses in the same
7638 host list, you should normally put the IP addresses first. For example, in an
7639 ACL you could have:
7640 .display asis
7641 accept hosts = 10.9.8.7 : *.friend.example
7642 .endd
7643 The reason for this lies in the left-to-right way that Exim processes lists.
7644 It can test IP addresses without doing any DNS lookups, but when it reaches an
7645 item that requires a host name, it fails if it cannot find a host name to
7646 compare with the pattern. If the above list is given in the opposite order, the
7647 \accept\ statement fails for a host whose name cannot be found, even if its
7648 IP address is 10.9.8.7.
7649
7650 If you really do want to do the name check first, and still recognize the IP
7651 address, you can rewrite the ACL like this:
7652 .display asis
7653 accept hosts = *.friend.example
7654 accept hosts = 10.9.8.7
7655 .endd
7656 If the first \accept\ fails, Exim goes on to try the second one. See chapter
7657 ~~CHAPACL for details of ACLs.
7658
7659
7660
7661
7662 .section Address lists
7663 .index list||address list
7664 .index address list||empty item
7665 .index address list||patterns
7666 .rset SECTaddresslist "~~chapter.~~section"
7667 Address lists contain patterns that are matched against mail addresses. There
7668 is one special case to be considered: the sender address of a bounce message is
7669 always empty. You can test for this by providing an empty item in an address
7670 list. For example, you can set up a router to process bounce messages by
7671 using this option setting:
7672 .display asis
7673 senders = :
7674 .endd
7675 The presence of the colon creates an empty item. If you do not provide any
7676 data, the list is empty and matches nothing. The empty sender can also be
7677 detected by a regular expression that matches an empty string,
7678 .em
7679 and by a query-style lookup that succeeds when \$sender@_address$\ is empty.
7680
7681 The following kinds of address list pattern can match any address, including 
7682 the empty address that is characteristic of bounce message senders:
7683 .nem
7684 .numberpars $.
7685 .em
7686 As explained above, if a pattern item is empty, it matches the empty address
7687 (and no others).
7688 .nem
7689 .nextp
7690 .index regular expressions||in address list
7691 .index address list||regular expression in
7692 If (after expansion) a pattern starts with `@^', a regular expression match is
7693 done against the complete address, with the pattern as the regular expression.
7694 You must take care that backslash and dollar characters are not misinterpreted
7695 as part of the string expansion. The simplest way to do this is to use \"@\N"\
7696 to mark that part of the string as non-expandable. For example:
7697 .display asis
7698 deny senders = \N^\d{8}.+@spamhaus.example$\N : ...
7699 .endd
7700 The \"@\N"\ sequences are removed by the expansion, so the item does start
7701 with `@^' by the time it is being interpreted as an address pattern.
7702 .nextp
7703 .index address list||lookup for complete address
7704 Complete addresses can be looked up by using a pattern that starts with a
7705 lookup type terminated by a semicolon, followed by the data for the lookup. For
7706 example:
7707 .display asis
7708 deny senders = cdb;/etc/blocked.senders : \
7709   mysql;select address from blocked where \
7710   address='${quote_mysql:$sender_address}'
7711 .endd
7712 .em
7713 Both query-style and single-key lookup types can be used. For a single-key
7714 lookup type, Exim uses the complete address as the key. However, empty keys are
7715 not supported for single-key lookups, so a match against the empty address
7716 always fails. This restriction does not apply to query-style lookups.
7717
7718 .nem
7719 Partial matching for single-key lookups (section ~~SECTpartiallookup) cannot be
7720 used, and is ignored if specified, with an entry being written to the panic
7721 log.
7722 .index @*@@ with single-key lookup
7723 However, you can configure lookup defaults, as described in section
7724 ~~SECTdefaultvaluelookups, but this is useful only for the `$*$@@' type of
7725 default. For example, with this lookup:
7726 .display asis
7727 accept senders = lsearch*@;/some/file
7728 .endd
7729 the file could contains lines like this:
7730 .display asis
7731 user1@domain1.example
7732 *@domain2.example
7733 .endd
7734 and for the sender address \*nimrod@@jaeger.example*\, the sequence of keys
7735 that are tried is:
7736 .display asis
7737 nimrod@jaeger.example
7738 *@jaeger.example
7739 *
7740 .endd
7741 \**Warning 1**\: Do not include a line keyed by `$*$' in the file, because that
7742 would mean that every address matches, thus rendering the test useless.
7743
7744 \**Warning 2**\: Do not confuse these two kinds of item:
7745 .display asis
7746 deny recipients = dbm*@;/some/file
7747 deny recipients = *@dbm;/some/file
7748 .endd
7749 The first does a whole address lookup, with defaulting, as just described,
7750 because it starts with a lookup type. The second matches the local part and
7751 domain independently, as described in a bullet point below.
7752 .endp
7753
7754
7755 .em
7756 The following kinds of address list pattern can match only non-empty addresses. 
7757 If the subject address is empty, a match against any of these pattern types 
7758 always fails.
7759 .nem
7760
7761 .numberpars $.
7762 .index @@@@ with single-key lookup
7763 .index address list||@@@@ lookup type
7764 .index address list||split local part and domain
7765 If a pattern starts with `@@@@' followed by a single-key lookup item
7766 (for example, \"@@@@lsearch;/some/file"\), the address that is being checked is
7767 split into a local part and a domain. The domain is looked up in the file. If
7768 it is not found, there is no match. If it is found, the data that is looked up
7769 from the file is treated as a colon-separated list of local part patterns, each
7770 of which is matched against the subject local part in turn.
7771
7772 .index asterisk||in address list
7773 The lookup may be a partial one, and/or one involving a search for a default
7774 keyed by `$*$' (see section ~~SECTdefaultvaluelookups). The local part patterns
7775 that are looked up can be regular expressions or begin with `$*$', or even be
7776 further lookups. They may also be independently negated. For example, with
7777 .display asis
7778 deny senders = @@dbm;/etc/reject-by-domain
7779 .endd
7780 the data from which the DBM file is built could contain lines like
7781 .display asis
7782 baddomain.com:  !postmaster : *
7783 .endd
7784 to reject all senders except \postmaster\ from that domain.
7785 .index local part||starting with !
7786 If a local part that actually begins with an exclamation mark is required, it
7787 has to be specified using a regular expression. In \%lsearch%\ files, an entry
7788 may be split over several lines by indenting the second and subsequent lines,
7789 but the separating colon must still be included at line breaks. White space
7790 surrounding the colons is ignored. For example:
7791 .display asis
7792 aol.com:  spammer1 : spammer2 : ^[0-9]+$ :
7793           spammer3 : spammer4
7794 .endd
7795 As in all colon-separated lists in Exim, a colon can be included in an item by
7796 doubling.
7797
7798 If the last item in the list starts with a right angle-bracket, the remainder
7799 of the item is taken as a new key to look up in order to obtain a continuation
7800 list of local parts. The new key can be any sequence of characters. Thus one
7801 might have entries like
7802 .display asis
7803 aol.com: spammer1 : spammer 2 : >*
7804 xyz.com: spammer3 : >*
7805 *:       ^\d{8}$
7806 .endd
7807 in a file that was searched with \@@@@dbm$*$\, to specify a match for 8-digit
7808 local parts for all domains, in addition to the specific local parts listed for
7809 each domain. Of course, using this feature costs another lookup each time a
7810 chain is followed, but the effort needed to maintain the data is reduced.
7811 .index loop||in lookups
7812 It is possible to construct loops using this facility, and in order to catch
7813 them, the chains may be no more than fifty items long.
7814 .nextp
7815 The @@@@<<lookup>> style of item can also be used with a query-style
7816 lookup, but in this case, the chaining facility is not available. The lookup
7817 can only return a single list of local parts.
7818 .nextp
7819 If a pattern contains an @@ character, but is not a regular expression and does
7820 not begin with a lookup type as described above, the local part of the subject
7821 address is compared with the local part of the pattern, which may start with an
7822 asterisk. If the local parts match, the domain is checked in exactly the same
7823 way as for a pattern in a domain list. For example, the domain can be
7824 wildcarded, refer to a named list, or be a lookup:
7825 .display asis
7826 deny senders = *@*.spamming.site:\
7827                *@+hostile_domains:\
7828                bozo@partial-lsearch;/list/of/dodgy/sites:\
7829 .newline
7830                *@dbm;/bad/domains.db
7831 .endd
7832 .index local part||starting with !
7833 .index address list||local part starting with !
7834 If a local part that begins with an exclamation mark is required, it has to be
7835 specified using a regular expression, because otherwise the exclamation mark is
7836 treated as a sign of negation.
7837 .nextp
7838 If a pattern is not one of the above syntax forms, that is, if a
7839 .em
7840 non-empty
7841 .nem
7842 pattern that is not a regular expression or a lookup does not contain an @@
7843 character, it is matched against the domain part of the subject address. The
7844 only two formats that are recognized this way are a literal domain, or a domain
7845 pattern that starts with $*$. In both these cases, the effect is the same as if
7846 \"*@@"\ preceded the pattern.
7847 .endp
7848
7849 \**Warning**\: there is an important difference between the address list items
7850 in these two examples:
7851 .display asis
7852 senders = +my_list
7853 senders = *@+my_list
7854 .endd
7855 In the first one, \"my@_list"\ is a named address list, whereas in the second
7856 example it is a named domain list.
7857
7858
7859
7860 .section Case of letters in address lists
7861 .rset SECTcasletadd "~~chapter.~~section"
7862 .index case of local parts
7863 .index address list||case forcing
7864 .index case forcing in address lists
7865 Domains in email addresses are always handled caselessly, but for local parts
7866 case may be significant on some systems (see \caseful@_local@_part\ for how
7867 Exim deals with this when routing addresses). However, RFC 2505 ($it{Anti-Spam
7868 Recommendations for SMTP MTAs}) suggests that matching of addresses to blocking
7869 lists should be done in a case-independent manner. Since most address lists in
7870 Exim are used for this kind of control, Exim attempts to do this by default.
7871
7872 The domain portion of an address is always lowercased before matching it to an
7873 address list. The local part is lowercased by default, and any string
7874 comparisons that take place are done caselessly. This means that the data in
7875 the address list itself, in files included as plain file names, and in any file
7876 that is looked up using the `@@@@' mechanism, can be in any case. However, the
7877 keys in files that are looked up by a search type other than \%lsearch%\ (which
7878 works caselessly) must be in lower case, because these lookups are not
7879 case-independent.
7880
7881 .index \"+caseful"\
7882 To allow for the possibility of caseful address list matching, if an item in
7883 an address list is the string `+caseful', the original case of the local
7884 part is restored for any comparisons that follow, and string comparisons are no
7885 longer case-independent. This does not affect the domain, which remains in
7886 lower case. However, although independent matches on the domain alone are still
7887 performed caselessly, regular expressions that match against an entire address
7888 become case-sensitive after `+caseful' has been seen.
7889
7890
7891 .section Local part lists
7892 .rset SECTlocparlis "~~chapter.~~section"
7893 .index list||local part list
7894 .index local part||list
7895 Case-sensitivity in local part lists is handled in the same way as for address
7896 lists, as just described. The `+caseful' item can be used if required. In a
7897 setting of the \local@_parts\ option in a router with \caseful@_local@_part\
7898 set false, the subject is lowercased and the matching is initially
7899 case-insensitive. In this case, `+caseful' will restore case-sensitive matching
7900 in the local part list, but not elsewhere in the router. If
7901 \caseful@_local@_part\ is set true in a router, matching in the \local@_parts\
7902 option is case-sensitive from the start.
7903
7904 If a local part list is indirected to a file (see section ~~SECTfilnamlis),
7905 comments are handled in the same way as address lists -- they are recognized
7906 only if the @# is preceded by white space or the start of the line.
7907 Otherwise, local part lists are matched in the same way as domain lists, except
7908 that the special items that refer to the local host (\"@@"\, \"@@[]"\,
7909 \"@@mx@_any"\, \"@@mx@_primary"\, and \"@@mx@_secondary"\) are not recognized.
7910 Refer to section ~~SECTdomainlist for details of the other available item
7911 types.
7912
7913
7914
7915 .
7916 .
7917 .
7918 .
7919 . ============================================================================
7920 .chapter String expansions
7921 .set runningfoot "string expansions"
7922 .rset CHAPexpand ~~chapter
7923 .index expansion||of strings
7924 Many strings in Exim's run time configuration are expanded before use. Some of
7925 them are expanded every time they are used; others are expanded only once.
7926
7927 When a string is being expanded it is copied verbatim from left to right except
7928 when a dollar or backslash character is encountered. A dollar specifies the
7929 start of a portion of the string which is interpreted and replaced as described
7930 below in section ~~SECTexpansionitems onwards. Backslash is used as an escape
7931 character, as described in the following section.
7932
7933
7934 .section Literal text in expanded strings
7935 .rset SECTlittext "~~chapter.~~section"
7936 .index expansion||including literal text
7937 An uninterpreted dollar can be included in an expanded string by putting a
7938 backslash in front of it. A backslash can be used to prevent any special
7939 character being treated specially in an expansion, including itself. If the
7940 string appears in quotes in the configuration file, two backslashes are
7941 required because the quotes themselves cause interpretation of backslashes when
7942 the string is read in (see section ~~SECTstrings).
7943
7944 .index expansion||non-expandable substrings
7945 A portion of the string can specified as non-expandable by placing it between
7946 two occurrences of \"@\N"\. This is particularly useful for protecting regular
7947 expressions, which often contain backslashes and dollar signs. For example:
7948 .display asis
7949 deny senders = \N^\d{8}[a-z]@some\.site\.example$\N
7950 .endd
7951 On encountering the first \"@\N"\, the expander copies subsequent characters
7952 without interpretation until it reaches the next \"@\N"\ or the end of the
7953 string.
7954
7955
7956 .section Character escape sequences in expanded strings
7957 .index expansion||escape sequences
7958 A backslash followed by one of the letters `n', `r', or `t' in an expanded
7959 string is recognized as an escape sequence for the character newline, carriage
7960 return, or tab, respectively. A backslash followed by up to three octal digits
7961 is recognized as an octal encoding for a single character, and a backslash
7962 followed by `x' and up to two hexadecimal digits is a hexadecimal encoding.
7963
7964 These escape sequences are also recognized in quoted strings when they are read
7965 in. Their interpretation in expansions as well is useful for unquoted strings,
7966 and for other cases such as looked-up strings that are then expanded.
7967
7968 .section Testing string expansions
7969 .index expansion||testing
7970 .index testing||string expansion
7971 .index \-be-\ option
7972 Many expansions can be tested by calling Exim with the \-be-\ option. This takes
7973 the command arguments, or lines from the standard input if there are no
7974 arguments, runs them through the string expansion code, and writes the results
7975 to the standard output. Variables based on configuration values are set up, but
7976 since no message is being processed, variables such as \$local@_part$\ have no
7977 value. Nevertheless the \-be-\ option can be useful for checking out file and
7978 database lookups, and the use of expansion operators such as \sg\, \substr\ and
7979 \nhash\.
7980
7981 Exim gives up its root privilege when it is called with the \-be-\ option, and
7982 instead runs under the uid and gid it was called with, to prevent users from
7983 using \-be-\ for reading files to which they do not have access.
7984
7985
7986 .em
7987 .section Forced expansion failure
7988 .rset SECTforexpfai "~~chapter.~~section"
7989 .index expansion||forced failure
7990 A number of expansions that are described in the following section have
7991 alternative `true' and `false' substrings, enclosed in curly brackets. Which 
7992 one is used depends on some condition that is evaluated as part of the 
7993 expansion. If, instead of a `false' substring, the word `fail' is used (not in 
7994 curly brackets), the entire string expansion fails in a way that can be
7995 detected by the code that requested the expansion. This is called `forced
7996 expansion failure', and its consequences depend on the circumstances. In some
7997 cases it is no different from any other expansion failure, but in others a
7998 different action may be taken. Such variations are mentioned in the
7999 documentation of the option that is being expanded.
8000 .nem
8001
8002
8003 .section Expansion items
8004 .rset SECTexpansionitems "~~chapter.~~section"
8005 The following items are recognized in expanded strings. White space may be used
8006 between sub-items that are keywords or substrings enclosed in braces inside an
8007 outer set of braces, to improve readability. \**Warning**\: Within braces,
8008 white space is significant.
8009
8010 .startitems
8011
8012 .item "@$<<variable name>>#$rm{or}#@$@{<<variable name>>@}"
8013 .index expansion||variables
8014 Substitute the contents of the named variable, for example
8015 .display asis
8016 $local_part
8017 ${domain}
8018 .endd
8019 The second form can be used to separate the name from subsequent alphanumeric
8020 characters. This form (using curly brackets) is available only for variables;
8021 it does $it{not} apply to message headers. The names of the variables are given
8022 in section ~~SECTexpvar below. If the name of a non-existent variable is given,
8023 the expansion fails.
8024
8025 .item "@$@{<<op>>:<<string>>@}"
8026 .index expansion||operators
8027 The string is first itself expanded, and then the operation specified by <<op>>
8028 is applied to it. For example,
8029 .display asis
8030 ${lc:$local_part}
8031 .endd
8032 The string starts with the first character after the colon, which may be
8033 leading white space. A list of operators is given in section ~~SECTexpop below.
8034 The operator notation is used for simple expansion items that have just one
8035 argument, because it reduces the number of braces and therefore makes the
8036 string easier to understand.
8037
8038 .item "@$@{extract@{<<key>>@}@{<<string1>>@}@{<<string2>>@}@{<<string3>>@}@}"
8039 .index expansion||extracting substrings by key
8040 The key and <<string1>> are first expanded separately.
8041 Leading and trailing whitespace is removed from the key (but not from any of
8042 the strings).
8043 The key must not consist entirely of digits. The expanded <<string1>> must be
8044 of the form:
8045 .display
8046 <<key1>> = <<value1>>  <<key2>> = <<value2>> ...
8047 .endd
8048 where the equals signs and spaces (but not both) are optional. If any of the
8049 values contain white space, they must be enclosed in double quotes, and any
8050 values that are enclosed in double quotes are subject to escape processing as
8051 described in section ~~SECTstrings. The expanded <<string1>> is searched for
8052 the value that corresponds to the key. The search is case-insensitive. If the
8053 key is found, <<string2>> is expanded, and replaces the whole item; otherwise
8054 <<string3>> is used. During the expansion of <<string2>> the variable \$value$\
8055 contains the value that has been extracted. Afterwards, it is restored to any
8056 previous value it might have had.
8057
8058 If @{<<string3>>@} is omitted, the item is replaced by an empty string if the
8059 key is not found. If @{<<string2>>@} is also omitted, the value that was
8060 extracted is used. Thus, for example, these two expansions are identical, and
8061 yield `2001':
8062 .display
8063 @$@{extract@{gid@}{uid=1984 gid=2001@}@}
8064 @$@{extract@{gid@}{uid=1984 gid=2001@}@{@$value@}@}
8065 .endd
8066 Instead of @{<<string3>>@} the word `fail' (not in curly brackets) can appear,
8067 for example:
8068 .display
8069 @$@{extract@{Z@}@{A=... B=...@}@{@$value@} fail @}
8070 .endd
8071 This forces an expansion failure (see section ~~SECTforexpfai); @{<<string2>>@}
8072 must be present for `fail' to be recognized.
8073
8074
8075 .item "@$@{extract@{<<number>>@}@{<<separators>>@}@{<<string1>>@}@{<<string2>>@}@{<<string3>>@}@}"
8076 .index expansion||extracting substrings by number
8077 The <<number>> argument must consist entirely of decimal digits,
8078 apart from leading and trailing whitespace, which is ignored.
8079 This is what distinguishes this form of \extract\ from the previous kind. It
8080 behaves in the same way, except that, instead of extracting a named field, it
8081 extracts from <<string1>> the field whose number is given as the first
8082 argument. You can use \$value$\ in <<string2>> or \"fail"\ instead of
8083 <<string3>> as before.
8084
8085 The fields in the string are separated by any one of the characters in the
8086 separator string. These may include space or tab characters.
8087 The first field is numbered one. If the number is negative, the fields are
8088 counted from the end of the string, with the rightmost one numbered -1. If the
8089 number given is zero, the entire string is returned. If the modulus of the
8090 number is greater than the number of fields in the string, the result is the
8091 expansion of <<string3>>, or the empty string if <<string3>> is not provided.
8092 For example:
8093 .display asis
8094 ${extract{2}{:}{x:42:99:& Mailer::/bin/bash}}
8095 .endd
8096 yields `42', and
8097 .display asis
8098 ${extract{-4}{:}{x:42:99:& Mailer::/bin/bash}}
8099 .endd
8100 yields `99'. Two successive separators mean that the field between them is
8101 empty (for example, the fifth field above).
8102
8103
8104 .item "@$@{hash@{<<string1>>@}@{<<string2>>@}@{<<string3>>@}@}"
8105 .index hash function||textual
8106 .index expansion||textual hash
8107 This is a textual hashing function, and was the first to be implemented in
8108 early versions of Exim. In current releases, there are other hashing functions
8109 (numeric, MD5, and SHA-1), which are described below.
8110
8111 The first two strings, after expansion, must be numbers. Call them <<m>> and
8112 <<n>>. If you are using fixed values for these numbers, that is, if <<string1>>
8113 and <<string2>> do not change when they are expanded, you can use the
8114 simpler operator notation that avoids some of the braces:
8115 .display
8116 @$@{hash@_<<n>>@_<<m>>:<<string>>@}
8117 .endd
8118 The second number is optional (in both notations).
8119
8120 If <<n>> is greater than or equal to the length of the string, the expansion
8121 item returns the string. Otherwise it computes a new string of length <<n>> by
8122 applying a hashing function to the string. The new string consists of
8123 characters taken from the first <<m>> characters of the string
8124 .display asis
8125 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQWRSTUVWXYZ0123456789
8126 .endd
8127 If <<m>> is not present the value 26 is used, so that only lower case
8128 letters appear. For example:
8129 .display
8130 @$@{hash@{3@}@{monty@}@}              $rm{yields}  \"jmg"\
8131 @$@{hash@{5@}@{monty@}@}              $rm{yields}  \"monty"\
8132 @$@{hash@{4@}@{62@}@{monty python@}@}   $rm{yields}  \"fbWx"\
8133 .endd
8134
8135
8136 .item "@$header@_<<header name>>:#$rm{or}#@$h@_<<header name>>:"
8137 .item "@$bheader@_<<header name>>:#$rm{or}#@$bh@_<<header name>>:"
8138 .item "@$rheader@_<<header name>>:#$rm{or}#@$rh@_<<header name>>:"
8139 .index expansion||header insertion
8140 .index \$header@_$\
8141 .index \$bheader@_$\
8142 .index \$rheader@_$\
8143 .index header lines||in expansion strings
8144 .index header lines||character sets
8145 .index header lines||decoding
8146 Substitute the contents of the named message header line, for example
8147 .display asis
8148 $header_reply-to:
8149 .endd
8150 The newline that terminates a header line is not included in the expansion, but
8151 internal newlines (caused by splitting the header line over several physical
8152 lines) may be present.
8153
8154 The difference between \rheader\, \bheader\, and \header\ is in the way the
8155 data in the header line is interpreted.
8156 .numberpars $.
8157 .index whitespace||in header lines
8158 \rheader\ gives the original `raw' content of the header line, with no
8159 processing at all, and without the removal of leading and trailing whitespace.
8160 .nextp
8161 .index base64 encoding||in header lines
8162 \bheader\ removes leading and trailing whitespace, and then decodes base64 or
8163 quoted-printable MIME `words' within the header text, but does no character
8164 set translation. If decoding of what looks superficially like a MIME `word'
8165 fails, the raw string is returned.
8166 .index binary zero||in header line
8167 If decoding produces a binary zero character, it is replaced by a question mark
8168 -- this is what Exim does for binary zeros that are actually received in header
8169 lines.
8170 .nextp
8171 \header\ tries to translate the string as decoded by \bheader\ to a standard
8172 character set. This is an attempt to produce the same string as would be
8173 displayed on a user's MUA. If translation fails, the \bheader\ string is
8174 returned. Translation is attempted only on operating systems that support the
8175 \*iconv()*\ function. This is indicated by the compile-time macro
8176 \\HAVE@_ICONV\\ in a system Makefile or in \(Local/Makefile)\.
8177 .endp
8178
8179 In a filter file, the target character set for \header\ can be specified by a
8180 command of the following form:
8181 .display asis
8182 headers charset "UTF-8"
8183 .endd
8184 This command affects all references to \$h@_$\ (or \$header@_$\) expansions in
8185 subsequently obeyed filter commands. In the absence of this command, the target
8186 character set in a filter is taken from the setting of the \headers@_charset\
8187 option in the runtime configuration. The value of this option defaults to the
8188 value of \\HEADERS@_CHARSET\\ in \(Local/Makefile)\. The ultimate default is
8189 ISO-8859-1.
8190
8191 Header names follow the syntax of RFC 2822, which states that they may contain
8192 any printing characters except space and colon. Consequently, curly brackets
8193 $it{do not} terminate header names, and should not be used to enclose them as
8194 if they were variables. Attempting to do so causes a syntax error.
8195
8196 Only header lines that are common to all copies of a message are visible to
8197 this mechanism. These are the original header lines that are received with the
8198 message, and any that are added by
8199 an ACL \warn\ statement or by
8200 a system filter. Header lines that are added to a particular copy of a message
8201 by a router or transport are not accessible.
8202
8203 For incoming SMTP messages, no header lines are visible in ACLs that are obeyed
8204 before the \\DATA\\ ACL, because the header structure is not set up until the
8205 message is received. Header lines that are added by \warn\ statements in a
8206 \\RCPT\\ ACL (for example) are saved until the message's incoming header lines
8207 are available, at which point they are added. When a \\DATA\\ ACL is running,
8208 however, header lines added by earlier ACLs are visible.
8209
8210 Upper case and lower case letters are synonymous in header names. If the
8211 following character is white space, the terminating colon may be omitted, but
8212 this is not recommended, because you may then forget it when it is needed. When
8213 white space terminates the header name, it is included in the expanded string.
8214 If the message does not contain the given header, the expansion item is
8215 replaced by an empty string. (See the \def\ condition in section ~~SECTexpcond
8216 for a means of testing for the existence of a header.)
8217
8218 If there is more than one header with the same name, they are all concatenated
8219 to form the substitution string, up to a maximum length of 64K. A newline
8220 character is inserted between each line.
8221 For the \header\ expansion, for those headers that contain lists of addresses,
8222 a comma is also inserted at the junctions between lines. This does not happen
8223 for the \rheader\ expansion.
8224
8225
8226
8227 .item "@$@{hmac@{<<hashname>>@}@{<<secret>>@}@{<<string>>@}@}"
8228 .index expansion||hmac hashing
8229 This function uses cryptographic hashing (either MD5 or SHA-1) to convert a
8230 shared secret and some text into a message authentication code, as specified in
8231 RFC 2104.
8232 This differs from \"@$@{md5:secret@_text...@}"\ or
8233 \"@$@{sha1:secret@_text...@}"\ in that the hmac step adds a signature to the
8234 cryptographic hash, allowing for authentication that is not possible with MD5
8235 or SHA-1 alone.
8236 The hash name must expand to either \"md5"\ or \"sha1"\ at present. For
8237 example:
8238 .display asis
8239 ${hmac{md5}{somesecret}{$primary_hostname $tod_log}}
8240 .endd
8241 For the hostname \*mail.example.com*\ and time 2002-10-17 11:30:59, this
8242 produces:
8243 .display asis
8244 dd97e3ba5d1a61b5006108f8c8252953
8245 .endd
8246 As an example of how this might be used, you might put in the main part of
8247 an Exim configuration:
8248 .display asis
8249 SPAMSCAN_SECRET=cohgheeLei2thahw
8250 .endd
8251 In a router or a transport you could then have:
8252 .display asis
8253 headers_add = \
8254   X-Spam-Scanned: ${primary_hostname} ${message_id} \
8255   ${hmac{md5}{SPAMSCAN_SECRET}\
8256   {${primary_hostname},${message_id},$h_message-id:}}
8257 .endd
8258 Then given a message, you can check where it was scanned by looking at the
8259 ::X-Spam-Scanned:: header line. If you know the secret, you can check that this
8260 header line is authentic by recomputing the authentication code from the host
8261 name, message ID and the ::Message-id:: header line. This can be done using
8262 Exim's \-be-\ option, or by other means, for example by using the
8263 \*hmac@_md5@_hex()*\ function in Perl.
8264
8265
8266 .item "@${if <<condition>> @{<<string1>>@}@{<<string2>>@}@}"
8267 .index expansion||conditional
8268 If <<condition>> is true, <<string1>> is expanded and replaces the whole item;
8269 otherwise <<string2>> is used. The available conditions are described in
8270 section ~~SECTexpcond below. For example:
8271 .display asis
8272 ${if eq {$local_part}{postmaster} {yes}{no} }
8273 .endd
8274 The second string need not be present; if it is not and the condition is not
8275 true, the item is replaced with nothing. Alternatively, the word `fail' may be
8276 present instead of the second string (without any curly brackets). In this
8277 case, the expansion is forced to fail if the condition is not true (see section 
8278 ~~SECTforexpfai). 
8279
8280 .em
8281 If both strings are omitted, the result is the string \"true"\ if the condition
8282 is true, and the empty string if the condition is false. This makes it less
8283 cumbersome to write custom ACL and router conditions. For example, instead of
8284 .display asis
8285 condition = ${if >{$acl_m4}{3}{true}{false}}
8286 .endd
8287 you can use
8288 .display asis
8289 condition = ${if >{$acl_m4}{3}}
8290 .endd
8291 .nem
8292
8293
8294 .item "@$@{length@{<<string1>>@}@{<<string2>>@}@}"
8295 .index expansion||string truncation
8296 The \length\ item is used to extract the initial portion of a string. Both
8297 strings are expanded, and the first one must yield a number, <<n>>, say. If you
8298 are using a fixed value for the number, that is, if <<string1>> does not change
8299 when expanded, you can use the simpler operator notation that avoids some of
8300 the braces:
8301 .display
8302 @$@{length@_<<n>>:<<string>>@}
8303 .endd
8304 The result of this item is either the first <<n>> characters or the whole
8305 of <<string2>>, whichever is the shorter. Do not confuse \length\ with
8306 \strlen\, which gives the length of a string.
8307
8308
8309 .item "@${lookup@{<<key>>@} <<search type>> @{<<file>>@} @{<<string1>>@} @{<<string2>>@}@}"
8310 .item "@${lookup <<search type>> @{<<query>>@} @{<<string1>>@} @{<<string2>>@}@}"
8311 .index expansion||lookup in
8312 .index file||lookup
8313 .index lookup||in expanded string
8314 These items specify data lookups in files and databases, as discussed in
8315 chapter ~~CHAPfdlookup. The first form is used for single-key lookups, and the
8316 second is used for query-style lookups. The <<key>>, <<file>>, and <<query>>
8317 strings are expanded before use.
8318
8319 If there is any white space in a lookup item which is part of a filter command,
8320 a retry or rewrite rule, a routing rule for the \%manualroute%\ router, or any
8321 other place where white space is significant, the lookup item must be enclosed
8322 in double quotes. The use of data lookups in users' filter files may be locked
8323 out by the system administrator.
8324
8325 .index \$value$\
8326 If the lookup succeeds, <<string1>> is expanded and replaces the entire item.
8327 During its expansion, the variable \$value$\ contains the data returned by the
8328 lookup. Afterwards it reverts to the value it had previously (at the outer
8329 level it is empty). If the lookup fails, <<string2>> is expanded and replaces
8330 the entire item. If @{<<string2>>@} is omitted, the replacement is the empty 
8331 string on failure. If <<string2>> is provided, it can itself be a nested
8332 lookup, thus providing a mechanism for looking up a default value when the
8333 original lookup fails.
8334
8335 If a nested lookup is used as part of <<string1>>, \$value$\ contains the data
8336 for the outer lookup while the parameters of the second lookup are expanded,
8337 and also while <<string2>> of the second lookup is expanded, should the second
8338 lookup fail.
8339
8340 Instead of @{<<string2>>@} the word `fail' can appear, and in this case, if the
8341 lookup fails, the entire expansion is forced to fail (see section
8342 ~~SECTforexpfai). If both @{<<string1>>@} and @{<<string2>>@} are omitted, the
8343 result is the looked up value in the case of a successful lookup, and nothing
8344 in the case of failure.
8345
8346 For single-key lookups, the string `partial' is permitted to precede the
8347 search type in order to do partial matching, and $*$ or $*$@@ may follow a
8348 search type to request default lookups if the key does not match (see sections
8349 ~~SECTdefaultvaluelookups and ~~SECTpartiallookup for details).
8350
8351 .index numerical variables (\$1$\, \$2$\, etc)||in lookup expansion
8352 If a partial search is used, the variables \$1$\ and \$2$\ contain the wild
8353 and non-wild parts of the key during the expansion of the replacement text.
8354 They return to their previous values at the end of the lookup item.
8355
8356 This example looks up the postmaster alias in the conventional alias file:
8357 .display asis
8358 ${lookup {postmaster} lsearch {/etc/aliases} {$value}}
8359 .endd
8360 This example uses NIS+ to look up the full name of the user corresponding to
8361 the local part of an address, forcing the expansion to fail if it is not found:
8362 .display asis
8363 ${lookup nisplus {[name=$local_part],passwd.org_dir:gcos} \
8364   {$value}fail}
8365 .endd
8366
8367
8368 .item "@$@{nhash@{<<string1>>@}@{<<string2>>@}@{<<string3>>@}@}"
8369 .index expansion||numeric hash
8370 .index hash function||numeric
8371 The three strings are expanded; the first two must yield numbers. Call them
8372 <<n>> and <<m>>. If you are using fixed values for these numbers, that is, if
8373 <<string1>> and <<string2>> do not change when they are expanded, you can use
8374 the simpler operator notation that avoids some of the braces:
8375 .display
8376 @$@{nhash@_<<n>>@_<<m>>:<<string>>@}
8377 .endd
8378 The second number is optional (in both notations). If there is only one number,
8379 the result is a number in the range 0--<<n>>-1. Otherwise, the string is
8380 processed by a div/mod hash function that returns two numbers, separated by a
8381 slash, in the ranges 0 to <<n>>-1 and 0 to <<m>>-1, respectively. For example,
8382 .display asis
8383 ${nhash{8}{64}{supercalifragilisticexpialidocious}}
8384 .endd
8385 returns the string `6/33'.
8386
8387
8388
8389 .item "@$@{perl@{<<subroutine>>@}@{<<arg>>@}@{<<arg>>@}...@}"
8390 .index Perl||use in expanded string
8391 .index expansion||calling Perl from
8392 This item is available only if Exim has been built to include an embedded Perl
8393 interpreter. The subroutine name and the arguments are first separately
8394 expanded, and then the Perl subroutine is called with those arguments. No
8395 additional arguments need be given; the maximum number permitted, including the
8396 name of the subroutine, is nine.
8397
8398 The return value of the subroutine is inserted into the expanded string, unless
8399 the return value is \undef\. In that case, the expansion fails in the same way
8400 as an explicit `fail' on a lookup item.
8401 The return value is a scalar. Whatever you return is evaluated in a scalar
8402 context. For example, if you return the name of a Perl vector, the
8403 return value is the size of the vector, not its contents.
8404
8405 If the subroutine exits by calling Perl's \die\ function, the expansion fails
8406 with the error message that was passed to \die\. More details of the embedded
8407 Perl facility are given in chapter ~~CHAPperl.
8408
8409 The \%redirect%\ router has an option called \forbid@_filter@_perl\ which locks
8410 out the use of this expansion item in filter files.
8411
8412
8413 .item "@$@{readfile@{<<file name>>@}@{<<eol string>>@}@}"
8414 .index expansion||inserting an entire file
8415 .index file||inserting into expansion
8416 The file name and end-of-line string are first expanded separately. The file is
8417 then read, and its contents replace the entire item. All newline characters in
8418 the file are replaced by the end-of-line string if it is present. Otherwise,
8419 newlines are left in the string.
8420 String expansion is not applied to the contents of the file. If you want this,
8421 you must wrap the item in an \expand\ operator. If the file cannot be read, the
8422 string expansion fails.
8423
8424 The \%redirect%\ router has an option called \forbid@_filter@_readfile\ which
8425 locks out the use of this expansion item in filter files.
8426
8427
8428
8429 .item "@$@{readsocket@{<<name>>@}@{<<request>>@}@{<<timeout>>@}@{<<eol string>>@}@{<<fail string>>@}@}"
8430 .index expansion||inserting from a socket
8431 .index socket, use of in expansion
8432 This item inserts data that is read from a Unix domain socket into the expanded
8433 string. The minimal way of using it uses just two arguments:
8434 .display asis
8435 ${readsocket{/socket/name}{request string}}
8436 .endd
8437 Exim connects to the socket, writes the request string (unless it is an
8438 empty string) and reads from the socket until an end-of-file is read. A timeout
8439 of 5 seconds is applied. Additional, optional arguments extend what can be
8440 done. Firstly, you can vary the timeout. For example:
8441 .display asis
8442 ${readsocket{/socket/name}{request-string}{3s}}
8443 .endd
8444 A fourth argument allows you to change any newlines that are in the data
8445 that is read, in the same way as for \readfile\ (see above). This example turns
8446 them into spaces:
8447 .display asis
8448 ${readsocket{/socket/name}{request-string}{3s}{ }}
8449 .endd
8450 As with all expansions, the substrings are expanded before the processing
8451 happens. Errors in these sub-expansions cause the expansion to fail. In
8452 addition, the following errors can occur:
8453 .numberpars $.
8454 Failure to create a socket file descriptor;
8455 .nextp
8456 Failure to connect the socket;
8457 .nextp
8458 Failure to write the request-string;
8459 .nextp
8460 Timeout on reading from the socket.
8461 .endp
8462 By default, any of these errors causes the expansion to fail. However, if
8463 you supply a fifth substring, it is expanded and used when any of the above
8464 errors occurs. For example:
8465 .display asis
8466 ${readsocket{/socket/name}{request-string}{3s}{\n}\
8467   {socket failure}}
8468 .endd
8469 You can test for the existence of the socket by wrapping this expansion in
8470 \"@$@{if exists"\, but there is a race condition between that test and the
8471 actual opening of the socket, so it is safer to use the fifth argument if you
8472 want to be absolutely sure of avoiding an expansion error for a non-existent
8473 socket.
8474
8475 The \%redirect%\ router has an option called \forbid@_filter@_readsocket\ which
8476 locks out the use of this expansion item in filter files.
8477
8478 .item "@$rheader@_<<header name>>:#$rm{or}#@$rh@_<<header name>>:"
8479 This item inserts `raw' header lines. It is described with the \header\
8480 expansion item above.
8481
8482
8483
8484 .item "@$@{run@{<<command>> <<args>>@}@{<<string1>>@}@{<<string2>>@}@}"
8485 .index expansion||running a command
8486 The command and its arguments are first expanded separately, and then the
8487 command is run in a separate process, but under the same uid and gid. As in
8488 other command executions from Exim, a shell is not used by default. If you want
8489 a shell, you must explicitly code it.
8490 .index return code||from \run\ expansion
8491 If the command succeeds (gives a zero return code) <<string1>> is expanded and
8492 replaces the entire item; during this expansion, the standard output from the
8493 command is in the variable \$value$\. If the command fails, <<string2>>, if
8494 present, is expanded. If it is absent, the result is empty. Alternatively,
8495 <<string2>> can be the word `fail' (not in braces) to force expansion failure
8496 if the command does not succeed. If both strings are omitted, the result is the
8497 standard output on success, and nothing on failure.
8498
8499 The return code from the command is put in the variable \$runrc$\, and this
8500 remains set afterwards, so in a filter file you can do things like this:
8501 .display asis
8502 if "${run{x y z}{}}$runrc" is 1 then ...
8503   elif $runrc is 2 then ...
8504   ...
8505 endif
8506 .endd
8507 If execution of the command fails (for example, the command does not exist),
8508 the return code is 127 -- the same code that shells use for non-existent
8509 commands.
8510
8511 \**Warning**\: In a router or transport, you cannot assume the order in which
8512 option values are expanded, except for those pre-conditions whose order of
8513 testing is documented. Therefore, you cannot reliably expect to set \$runrc$\
8514 by the expansion of one option, and use it in another.
8515
8516 The \%redirect%\ router has an option called \forbid@_filter@_run\ which locks
8517 out the use of this expansion item in filter files.
8518
8519
8520 .item "@$@{sg@{<<subject>>@}@{<<regex>>@}@{<<replacement>>@}@}"
8521 .index expansion||string substitution
8522 This item works like Perl's substitution operator (s) with the global (/g)
8523 option; hence its name. However, unlike the Perl equivalent, Exim does not
8524 modify the subject string; instead it returns the modified string for insertion
8525 into the overall expansion. The item takes three arguments: the subject string,
8526 a regular expression, and a substitution string. For example
8527 .display asis
8528 ${sg{abcdefabcdef}{abc}{xyz}}
8529 .endd
8530 yields `xyzdefxyzdef'. Because all three arguments are expanded before use, if
8531 any @$ or @\ characters are required in the regular expression or in the
8532 substitution string, they have to be escaped. For example
8533 .display asis
8534 ${sg{abcdef}{^(...)(...)\$}{\$2\$1}}
8535 .endd
8536 yields `defabc', and
8537 .display asis
8538 ${sg{1=A 4=D 3=C}{\N(\d+)=\N}{K\$1=}}
8539 .endd
8540 yields `K1=A K4=D K3=C'.
8541 Note the use of \"@\N"\ to protect the contents of the regular expression from
8542 string expansion.
8543
8544
8545
8546 .item "@$@{substr@{<<string1>>@}@{<<string2>>@}@{<<string3>>@}@}"
8547 .index \substr\
8548 .index substring extraction
8549 .index expansion||substring extraction
8550 The three strings are expanded; the first two must yield numbers. Call them
8551 <<n>> and <<m>>. If you are using fixed values for these numbers, that is, if
8552 <<string1>> and <<string2>> do not change when they are expanded, you can use
8553 the simpler operator notation that avoids some of the braces:
8554 .display
8555 @$@{substr@_<<n>>@_<<m>>:<<string>>@}
8556 .endd
8557 The second number is optional (in both notations).
8558 .em
8559 If it is absent in the simpler format, the preceding underscore must also be 
8560 omitted.
8561 .nem
8562
8563 The \substr\ item can be used to extract more general substrings than \length\.
8564 The first number, <<n>>, is a starting offset, and <<m>> is the length
8565 required. For example
8566 .display asis
8567 ${substr{3}{2}{$local_part}}
8568 .endd
8569 If the starting offset is greater than the string length the result is the null
8570 string; if the length plus starting offset is greater than the string length,
8571 the result is the right-hand part of the string, starting from the given
8572 offset. The first character in the string has offset zero.
8573
8574 The \substr\ expansion item can take negative offset values to count
8575 from the right-hand end of its operand. The last character is offset -1, the
8576 second-last is offset -2, and so on. Thus, for example,
8577 .display asis
8578 ${substr{-5}{2}{1234567}}
8579 .endd
8580 yields `34'. If the absolute value of a negative offset is greater than the
8581 length of the string, the substring starts at the beginning of the string, and
8582 the length is reduced by the amount of overshoot. Thus, for example,
8583 .display asis
8584 ${substr{-5}{2}{12}}
8585 .endd
8586 yields an empty string, but
8587 .display asis
8588 ${substr{-3}{2}{12}}
8589 .endd
8590 yields `1'.
8591
8592 When the second number is omitted from \substr\, the remainder of the string is
8593 taken if the offset is positive. If it is negative, all characters in the
8594 string preceding the offset point are taken. For example, an offset of -1 and
8595 no length, as in these semantically identical examples:
8596 .display asis
8597 ${substr_-1:abcde}
8598 ${substr{-1}{abcde}}
8599 .endd
8600 yields all but the last character of the string, that is, `abcd'.
8601
8602
8603
8604 .item "@$@{tr@{<<subject>>@}@{<<characters>>@}@{<<replacements>>@}@}"
8605 .index expansion||character translation
8606 This item does single-character translation on its subject string. The second
8607 argument is a list of characters to be translated in the subject string. Each
8608 matching character is replaced by the corresponding character from the
8609 replacement list. For example
8610 .display asis
8611 ${tr{abcdea}{ac}{13}}
8612 .endd
8613 yields `1b3de1'. If there are duplicates in the second character string, the
8614 last occurrence is used. If the third string is shorter than the second, its
8615 last character is replicated. However, if it is empty, no translation takes
8616 place.
8617
8618 .enditems
8619
8620
8621 .section Expansion operators
8622 .rset SECTexpop "~~chapter.~~section"
8623 .index expansion||operators
8624 For expansion items that perform transformations on a single argument string,
8625 the `operator' notation is used because it is simpler and uses fewer braces.
8626 The substring is first expanded before the operation is applied to it. The
8627 following operations can be performed:
8628
8629 .startitems
8630
8631 .item "@$@{address:<<string>>@}"
8632 .index expansion||RFC 2822 address handling
8633 The string is interpreted as an RFC 2822 address, as it might appear in a
8634 header line, and the effective address is extracted from it. If the string does
8635 not parse successfully, the result is empty.
8636
8637
8638 .item "@$@{base62:<<digits>>@}"
8639 .index base62
8640 .index expansion||conversion to base 62
8641 The string must consist entirely of decimal digits. The number is converted to
8642 base 62 (sic) and output as a string of six characters, including leading
8643 zeros. \**Note**\: Just to be absolutely clear: this is \*not*\ base64
8644 encoding.
8645
8646 .item "@$@{base62d:<<base-62 digits>>@}"
8647 .index base62
8648 .index expansion||conversion to base 62
8649 The string must consist entirely of base-62 digits. The number is converted to
8650 decimal and output as a string.
8651
8652
8653 .item "@$@{domain:<<string>>@}"
8654 .index domain||extraction
8655 .index expansion||domain extraction
8656 The string is interpreted as an RFC 2822 address and the domain is extracted
8657 from it. If the string does not parse successfully, the result is empty.
8658
8659
8660 .item "@$@{escape:<<string>>@}"
8661 .index expansion||escaping non-printing characters
8662 If the string contains any non-printing characters, they are converted to
8663 escape sequences starting with a backslash. Whether characters with the most
8664 significant bit set (so-called `8-bit characters') count as printing or not is
8665 controlled by the \print@_topbitchars\ option.
8666
8667
8668 .item "@$@{eval:<<string>>@}"
8669 .item "@$@{eval10:<<string>>@}"
8670 .index expansion||expression evaluation
8671 .index expansion||arithmetic expression
8672 These items supports simple arithmetic in expansion strings. The string (after
8673 expansion) must be a conventional arithmetic expression, but it is limited to
8674 the four basic operators (plus, minus, times, divide) and parentheses. All
8675 operations are carried out using integer arithmetic. Plus and minus have a
8676 lower priority than times and divide; operators with the same priority are
8677 evaluated from left to right.
8678
8679 For \eval\, numbers may be decimal, octal (starting with `0') or hexadecimal
8680 (starting with `0x'). For \eval10\, all numbers are taken as decimal, even if
8681 they start with a leading zero. This can be useful when processing numbers
8682 extracted from dates or times, which often do have leading zeros.
8683
8684 A number may be followed by `K' or `M' to multiply it by 1024 or 1024$*$1024,
8685 respectively. Negative numbers are supported. The result of the computation is
8686 a decimal representation of the answer (without `K' or `M'). For example:
8687 .display
8688   @$@{eval:1+1@}       $rm{yields} 2
8689   @$@{eval:1+2*3@}     $rm{yields} 7
8690   @$@{eval:(1+2)*3@}   $rm{yields} 9
8691 .endd
8692 As a more realistic example, in an ACL you might have
8693 .display asis
8694 deny   message = Too many bad recipients
8695        condition =                    \
8696          ${if and {                   \
8697            {>{$rcpt_count}{10}}       \
8698            {                          \
8699            <                          \
8700              {$recipients_count}      \
8701              {${eval:$rcpt_count/2}}  \
8702            }                          \
8703          }{yes}{no}}
8704 .endd
8705 The condition is true if there have been more than 10 \\RCPT\\ commands and
8706 fewer than half of them have resulted in a valid recipient.
8707
8708
8709 .item "@$@{expand:<<string>>@}"
8710 .index expansion||re-expansion of substring
8711 The \expand\ operator causes a string to be expanded for a second time. For
8712 example,
8713 .display asis
8714 ${expand:${lookup{$domain}dbm{/some/file}{$value}}}
8715 .endd
8716 first looks up a string in a file while expanding the operand for \expand\, and
8717 then re-expands what it has found.
8718
8719
8720 .item "@$@{from@_utf8:<<string>>@}"
8721 .index Unicode
8722 .index UTF-8||conversion from
8723 .index expansion||UTF-8 conversion
8724 The world is slowly moving towards Unicode, although there are no standards for
8725 email yet. However, other applications (including some databases) are starting
8726 to store data in Unicode, using UTF-8 encoding. This operator converts from a
8727 UTF-8 string to an ISO-8859-1 string. UTF-8 code values greater than 255 are
8728 converted to underscores. The input must be a valid UTF-8 string. If it is not,
8729 the result is an undefined sequence of bytes.
8730
8731 Unicode code points with values less than 256 are compatible with ASCII and
8732 ISO-8859-1 (also known as Latin-1).
8733 For example, character 169 is the copyright symbol in both cases, though the
8734 way it is encoded is different. In UTF-8, more than one byte is needed for
8735 characters with code values greater than 127, whereas ISO-8859-1 is a
8736 single-byte encoding (but thereby limited to 256 characters). This makes
8737 translation from UTF-8 to ISO-8859-1 straightforward.
8738
8739
8740 .item "@$@{hash@_<<n>>@_<<m>>:<<string>>@}"
8741 .index hash function||textual
8742 .index expansion||textual hash
8743 The \hash\ operator is a simpler interface to the hashing function that can be
8744 used when the two parameters are fixed numbers (as opposed to strings that
8745 change when expanded). The effect is the same as
8746 .display
8747 @$@{hash@{<<n>>@}@{<<m>>@}@{<<string>>@}@}
8748 .endd
8749 See the description of the general \hash\ item above for details. The
8750 abbreviation \h\ can be used when \hash\ is used as an operator.
8751
8752
8753
8754 .item "@$@{hex2b64:<<hexstring>>@}"
8755 .index base64 encoding||conversion from hex
8756 .index expansion||hex to base64
8757 This operator converts a hex string into one that is base64 encoded. This can
8758 be useful for processing the output of the MD5 and SHA-1 hashing functions.
8759
8760
8761 .item "@$@{lc:<<string>>@}"
8762 .index case forcing in strings
8763 .index string||case forcing
8764 .index lower casing
8765 .index expansion||case forcing
8766 This forces the letters in the string into lower-case, for example:
8767 .display asis
8768 ${lc:$local_part}
8769 .endd
8770
8771
8772 .item "@$@{length@_<<number>>:<<string>>@}"
8773 .index expansion||string truncation
8774 The \length\ operator is a simpler interface to the \length\ function that can
8775 be used when the parameter is a fixed number (as opposed to a string that
8776 changes when expanded). The effect is the same as
8777 .display
8778 @$@{length@{<<number>>@}@{<<string>>@}@}
8779 .endd
8780 See the description of the general \length\ item above for details. Note that
8781 \length\ is not the same as \strlen\. The abbreviation \l\ can be used when
8782 \length\ is used as an operator.
8783
8784
8785 .item "@$@{local@_part:<<string>>@}"
8786 .index expansion||local part extraction
8787 The string is interpreted as an RFC 2822 address and the local part is
8788 extracted from it. If the string does not parse successfully, the result is
8789 empty.
8790
8791
8792 .item "@$@{mask:<<IP address>>/<<bit count>>@}"
8793 .index masked IP address
8794 .index IP address||masking
8795 .index CIDR notation
8796 .index expansion||IP address masking
8797 If the form of the string to be operated on is not an IP address followed by a
8798 slash and an integer (that is, a network address in CIDR notation), the
8799 expansion fails. Otherwise, this operator converts the IP address to binary,
8800 masks off the least significant bits according to the bit count, and converts
8801 the result back to text, with mask appended. For example,
8802 .display asis
8803 ${mask:10.111.131.206/28}
8804 .endd
8805 returns the string `10.111.131.192/28'. Since this operation is expected to be
8806 mostly used for looking up masked addresses in files, the result for an IPv6
8807 address uses dots to separate components instead of colons, because colon
8808 terminates a key string in lsearch files. So, for example,
8809 .display asis
8810 ${mask:3ffe:ffff:836f:0a00:000a:0800:200a:c031/99}
8811 .endd
8812 returns the string
8813 .display asis
8814 3ffe.ffff.836f.0a00.000a.0800.2000.0000/99
8815 .endd
8816 Letters in IPv6 addresses are always output in lower case.
8817
8818
8819 .item "@$@{md5:<<string>>@}"
8820 .index MD5 hash
8821 .index expansion||MD5 hash
8822 The \md5\ operator computes the MD5 hash value of the string, and returns it as
8823 a 32-digit hexadecimal number,
8824 in which any letters are in lower case.
8825
8826
8827 .item "@$@{nhash@_<<n>>@_<<m>>:<<string>>@}"
8828 .index expansion||numeric hash
8829 .index hash function||numeric
8830 The \nhash\ operator is a simpler interface to the numeric hashing function
8831 that can be used when the two parameters are fixed numbers (as opposed to
8832 strings that change when expanded). The effect is the same as
8833 .display
8834 @$@{nhash@{<<n>>@}@{<<m>>@}@{<<string>>@}@}
8835 .endd
8836 See the description of the general \nhash\ item above for details.
8837
8838
8839 .item "@$@{quote:<<string>>@}"
8840 .index quoting||in string expansions
8841 .index expansion||quoting
8842 The \quote\ operator puts its argument into double quotes if it
8843 is an empty string or
8844 contains anything other than letters, digits, underscores, dots, and hyphens.
8845 Any occurrences of double quotes and backslashes are escaped with a backslash.
8846 Newlines and carriage returns are converted to \"@\n"\ and \"@\r"\,
8847 respectively For example,
8848 .display asis
8849 ${quote:ab"*"cd}
8850 .endd
8851 becomes
8852 .display asis
8853 "ab\"*\"cd"
8854 .endd
8855 The place where this is useful is when the argument is a substitution from a
8856 variable or a message header.
8857
8858 .item "@$@{quote@_local@_part:<<string>>@}"
8859 This operator is like \quote\, except that it quotes the string only if
8860 required to do so by the rules of RFC 2822 for quoting local parts. For
8861 example, a plus sign would not cause quoting (but it would for \quote\).
8862 If you are creating a new email address from the contents of \$local@_part$\
8863 (or any other unknown data), you should always use this operator.
8864
8865
8866 .item "@$@{quote@_<<lookup-type>>:<<string>>@}"
8867 .index quoting||lookup-specific
8868 This operator applies lookup-specific quoting rules to the string. Each
8869 query-style lookup type has its own quoting rules which are described with
8870 the lookups in chapter ~~CHAPfdlookup. For example,
8871 .display asis
8872 ${quote_ldap:two * two}
8873 .endd
8874 returns
8875 .display asis
8876 two%20%5C2A%20two
8877 .endd
8878 For single-key lookup types, no quoting is ever necessary and this operator
8879 yields an unchanged string.
8880
8881
8882 .item "@$@{rxquote:<<string>>@}"
8883 .index quoting||in regular expressions
8884 .index regular expressions||quoting
8885 The \rxquote\ operator inserts a backslash before any non-alphanumeric
8886 characters in its argument. This is useful when substituting the values of
8887 variables or headers inside regular expressions.
8888
8889
8890 .item "@$@{rfc2047:<<string>>@}"
8891 .index expansion||RFC 2047
8892 This operator encodes text according to the rules of RFC 2047. This is an
8893 encoding that is used in header lines to encode non-ASCII characters. It is
8894 assumed that the input string is in the encoding specified by the
8895 \headers@_charset\ option, which defaults to ISO-8859-1. If the string contains
8896 only characters in the range 33--126, and no instances of the characters
8897 .display asis
8898 ? = ( ) < > @ , ; : \ " . [ ] _
8899 .endd
8900 it is not modified. Otherwise, the result is the RFC 2047 encoding of the 
8901 string,
8902 .em
8903 using as many `coded words' as necessary to encode all the characters.
8904 .nem
8905
8906
8907 .item "@$@{sha1:<<string>>@}"
8908 .index SHA-1 hash
8909 .index expansion||SHA-1 hashing
8910 The \sha1\ operator computes the SHA-1 hash value of the string, and returns it
8911 as a 40-digit hexadecimal number, in which any letters are in upper case.
8912
8913
8914 .item "@$@{stat:<<string>>@}"
8915 .index expansion||statting a file
8916 .index file||extracting characteristics
8917 The string, after expansion, must be a file path. A call to the \*stat()*\
8918 function is made for this path. If \*stat()*\ fails, an error occurs and the
8919 expansion fails. If it succeeds, the data from the stat replaces the item, as a
8920 series of <<name>>=<<value>> pairs, where the values are all numerical,
8921 except for the value of `smode'. The names are: `mode' (giving the mode as a
8922 4-digit octal number), `smode' (giving the mode in symbolic format as a
8923 10-character string, as for the \*ls*\ command), `inode', `device', `links',
8924 `uid', `gid', `size', `atime', `mtime', and `ctime'. You can extract individual
8925 fields using the \extract\ expansion item. \**Warning**\: The file size may be
8926 incorrect on 32-bit systems for files larger than 2GB.
8927
8928
8929 .em
8930 .item "@$@{str2b64:<<string>>@}"
8931 .index expansion||base64 encoding
8932 .index base64 encoding||in string expansion
8933 This operator converts a string into one that is base64 encoded.
8934 .nem
8935
8936
8937 .item "@$@{strlen:<<string>>@}"
8938 .index expansion||string length
8939 .index string||length in expansion
8940 The item is replace by the length of the expanded string, expressed as a
8941 decimal number. \**Note**\: Do not confuse \strlen\ with \length\.
8942
8943
8944 .item "@$@{substr@_<<start>>@_<<length>>:<<string>>@}"
8945 .index \substr\
8946 .index substring extraction
8947 .index expansion||substring expansion
8948 The \substr\ operator is a simpler interface to the \substr\ function that can
8949 be used when the two parameters are fixed numbers (as opposed to strings that
8950 change when expanded). The effect is the same as
8951 .display
8952 @$@{substr@{<<start>>@}@{<<length>>@}@{<<string>>@}@}
8953 .endd
8954 See the description of the general \substr\ item above for details. The
8955 abbreviation \s\ can be used when \substr\ is used as an operator.
8956
8957 .item "@$@{time@_interval:<<string>>@}"
8958 .index \time@_interval\
8959 .index time interval||formatting
8960 The argument (after sub-expansion) must be a sequence of decimal digits that
8961 represents an interval of time as a number of seconds. It is converted into a
8962 number of larger units and output in Exim's normal time format, for example,
8963 \"1w3d4h2m6s"\.
8964
8965 .item "@$@{uc:<<string>>@}"
8966 .index case forcing in strings
8967 .index string||case forcing
8968 .index upper casing
8969 .index expansion||case forcing
8970 This forces the letters in the string into upper-case.
8971
8972 .enditems
8973
8974
8975
8976 .section Expansion conditions
8977 .rset SECTexpcond "~~chapter.~~section"
8978 .index expansion||conditions
8979 The following conditions are available for testing by the \@$@{if\ construct
8980 while expanding strings:
8981
8982 .startitems
8983
8984 .item "!<<condition>>"
8985 .index expansion||negating a condition
8986 Preceding any condition with an exclamation mark negates the result of the
8987 condition.
8988
8989 .item "<<symbolic operator>> @{<<string1>>@}@{<<string2>>@}"
8990 .index numeric comparison
8991 .index expansion||numeric comparison
8992 There are a number of symbolic operators for doing numeric comparisons. They
8993 are:
8994 .display
8995 .tabs 8
8996 =    $t  $rm{equal}
8997 ==   $t  $rm{equal}
8998 >    $t  $rm{greater}
8999 >=   $t  $rm{greater or equal}
9000 <    $t  $rm{less}
9001 <=   $t  $rm{less or equal}
9002 .endd
9003 For example,
9004 .display asis
9005 ${if >{$message_size}{10M} ...
9006 .endd
9007 Note that the general negation operator provides for inequality testing. The
9008 two strings must take the form of optionally signed decimal integers,
9009 optionally followed by one of the letters `K' or `M' (in either upper or lower
9010 case), signifying multiplication by 1024 or 1024$*$1024, respectively.
9011
9012 .item "crypteq @{<<string1>>@}@{<<string2>>@}"
9013 .index expansion||encrypted comparison
9014 .index encrypted strings, comparing
9015 This condition is included in the Exim binary if it is built to support any
9016 authentication mechanisms (see chapter ~~CHAPSMTPAUTH). Otherwise, it is
9017 necessary to define \\SUPPORT@_CRYPTEQ\\ in \(Local/Makefile)\ to get \crypteq\
9018 included in the binary.
9019
9020 The \crypteq\ condition has two arguments. The first is encrypted and compared
9021 against the second, which is already encrypted. The second string may be in the
9022 LDAP form for storing encrypted strings, which starts with the encryption type
9023 in curly brackets, followed by the data. If the second string does not begin
9024 with `{' it is assumed to be encrypted with \*crypt()*\
9025 or \*crypt16()*\ (see below),
9026 since such strings cannot begin with `{'. Typically this will be a field from a
9027 password file.
9028
9029 An example of an encrypted string in LDAP form is:
9030 .display asis
9031 {md5}CY9rzUYh03PK3k6DJie09g==
9032 .endd
9033 If such a string appears directly in an expansion, the curly brackets have to
9034 be quoted, because they are part of the expansion syntax. For example:
9035 .display asis
9036 ${if crypteq {test}{\{md5\}CY9rzUYh03PK3k6DJie09g==}{yes}{no}}
9037 .endd
9038 The following encryption types
9039 (whose names are matched case-independently)
9040 are supported:
9041 .numberpars $.
9042 .index MD5 hash
9043 .index base64 encoding||in encrypted password
9044 \@{md5@}\ computes the MD5 digest of the first string, and expresses this as
9045 printable characters to compare with the remainder of the second string. If the
9046 length of the comparison string is 24, Exim assumes that it is base64 encoded
9047 (as in the above example). If the length is 32, Exim assumes that it is a
9048 hexadecimal encoding of the MD5 digest. If the length not 24 or 32, the
9049 comparison fails.
9050 .nextp
9051 .index SHA-1 hash
9052 \@{sha1@}\ computes the SHA-1 digest of the first string, and expresses this as
9053 printable characters to compare with the remainder of the second string. If the
9054 length of the comparison string is 28, Exim assumes that it is base64 encoded.
9055 If the length is 40, Exim assumes that it is a hexadecimal encoding of the
9056 SHA-1 digest. If the length is not 28 or 40, the comparison fails.
9057 .nextp
9058 .index \*crypt()*\
9059 \@{crypt@}\ calls the \*crypt()*\ function, 
9060 .em
9061 which traditionally used to use only the first eight characters of the
9062 password. However, in modern operating systems this is no longer true, and in
9063 many cases the entire password is used, whatever its length.
9064 .nem
9065 .nextp
9066 .index \*crypt16()*\
9067 \@{crypt16@}\ calls the \*crypt16()*\ function (also known as \*bigcrypt()*\),
9068 which 
9069 .em
9070 was orginally created to use up to 16 characters of the password. Again, in 
9071 modern operating systems, more characters may be used.
9072 .nem
9073 .endp
9074 Exim has its own version of \*crypt16()*\ (which is just a double call to
9075 \*crypt()*\). For operating systems that have their own version, setting
9076 \\HAVE@_CRYPT16\\ in \(Local/Makefile)\ when building Exim causes it to use the
9077 operating system version instead of its own. This option is set by default in
9078 the OS-dependent \(Makefile)\ for those operating systems that are known to
9079 support \*crypt16()*\.
9080
9081 If you do not put any curly bracket encryption type in a \crypteq\ comparison,
9082 the default is either \"@{crypt@}"\ or \"@{crypt16@}"\, as determined by the
9083 setting of \\DEFAULT@_CRYPT\\ in \(Local/Makefile)\. The default default is
9084 \"@{crypt@}"\. Whatever the default, you can always use either function by
9085 specifying it explicitly in curly brackets.
9086
9087 Note that if a password is no longer than 8 characters, the results of
9088 encrypting it with \*crypt()*\ and \*crypt16()*\ are identical. That means that
9089 \*crypt16()*\ is backwards compatible, as long as nobody feeds it a password
9090 longer than 8 characters.
9091
9092
9093 .item "def:<<variable name>>"
9094 .index expansion||checking for empty variable
9095 The \def\ condition must be followed by the name of one of the expansion
9096 variables defined in section ~~SECTexpvar. The condition is true if the named
9097 expansion variable does not contain the empty string, for example
9098 .display asis
9099 ${if def:sender_ident {from $sender_ident}}
9100 .endd
9101 Note that the variable name is given without a leading \@$\ character. If the
9102 variable does not exist, the expansion fails.
9103
9104 .item "def:header@_<<header name>>:##or##def:h@_<<header name>>:"
9105 .index expansion||checking header line existence
9106 This condition is true if a message is being processed and the named header
9107 exists in the message. For example,
9108 .display asis
9109 ${if def:header_reply-to:{$h_reply-to:}{$h_from:}}
9110 .endd
9111 Note that no \@$\ appears before \header@_\ or \h@_\ in the condition,
9112 and that header names must be terminated by colons if white space does not
9113 follow.
9114
9115 .item "eq @{<<string1>>@}@{<<string2>>@}"
9116 .item "eqi @{<<string1>>@}@{<<string2>>@}"
9117 .index string||comparison
9118 .index expansion||string comparison
9119 The two substrings are first expanded. The condition is true if the two
9120 resulting strings are identical: for \eq\ the comparison includes the case of
9121 letters, whereas for \eqi\ the comparison is case-independent.
9122
9123 .item "exists @{<<file name>>@}"
9124 .index expansion||file existence test
9125 .index file||existence test
9126 The substring is first expanded and then interpreted as an absolute path. The
9127 condition is true if the named file (or directory) exists. The existence test
9128 is done by calling the \*stat()*\ function. The use of the \exists\ test in
9129 users' filter files may be locked out by the system administrator.
9130
9131 .item "first@_delivery"
9132 .index delivery||first
9133 .index first delivery
9134 .index expansion||first delivery test
9135 This condition, which has no data, is true during a message's first delivery
9136 attempt. It is false during any subsequent delivery attempts.
9137
9138 .item "ge @{<<string1>>@}@{<<string2>>@}"
9139 .item "gei @{<<string1>>@}@{<<string2>>@}"
9140 .index string||comparison
9141 .index expansion||string comparison
9142 The two substrings are first expanded. The condition is true if the first
9143 string is lexically greater than or equal to the second string: for \ge\ the
9144 comparison includes the case of letters, whereas for \gei\ the comparison is
9145 case-independent.
9146
9147 .item "gt @{<<string1>>@}@{<<string2>>@}"
9148 .item "gti @{<<string1>>@}@{<<string2>>@}"
9149 .index string||comparison
9150 .index expansion||string comparison
9151 The two substrings are first expanded. The condition is true if the first
9152 string is lexically greater than the second string: for \gt\ the comparison
9153 includes the case of letters, whereas for \gti\ the comparison is
9154 case-independent.
9155
9156 .item "isip @{<<string>>@}" 8
9157 .item "isip4 @{<<string>>@}"
9158 .item "isip6 @{<<string>>@}"
9159 .index IP address||testing string format
9160 .index string||testing for IP address
9161 The substring is first expanded, and then tested to see if it has the form of
9162 an IP address. Both IPv4 and IPv6 addresses are valid for \isip\, whereas
9163 \isip4\ and \isip6\ test just for IPv4 or IPv6 addresses, respectively. For
9164 example, you could use
9165 .display asis
9166 ${if isip4{$sender_host_address}...
9167 .endd
9168 to test which version of IP an incoming SMTP connection is using.
9169
9170
9171 .item "ldapauth @{<<ldap query>>@}"
9172 .index LDAP||use for authentication
9173 .index expansion||LDAP authentication test
9174 This condition supports user authentication using LDAP. See section ~~SECTldap
9175 for details of how to use LDAP in lookups and the syntax of queries. For this
9176 use, the query must contain a user name and password. The query itself is not
9177 used, and can be empty. The condition is true if
9178 the password is not empty, and the user name and password are accepted by the
9179 LDAP server. An empty password is rejected without calling LDAP because LDAP
9180 binds with an empty password are considered anonymous regardless of
9181 the username, and will succeed in most configurations.
9182 See chapter ~~CHAPSMTPAUTH for details of SMTP authentication, and chapter
9183 ~~CHAPplaintext for an example of how this can be used.
9184
9185
9186 .item "le @{<<string1>>@}@{<<string2>>@}"
9187 .item "lei @{<<string1>>@}@{<<string2>>@}"
9188 .index string||comparison
9189 .index expansion||string comparison
9190 The two substrings are first expanded. The condition is true if the first
9191 string is lexically less than or equal to the second string: for \le\ the
9192 comparison includes the case of letters, whereas for \lei\ the comparison is
9193 case-independent.
9194
9195 .item "lt @{<<string1>>@}@{<<string2>>@}"
9196 .item "lti @{<<string1>>@}@{<<string2>>@}"
9197 .index string||comparison
9198 .index expansion||string comparison
9199 The two substrings are first expanded. The condition is true if the first
9200 string is lexically less than the second string: for \lt\ the comparison
9201 includes the case of letters, whereas for \lti\ the comparison is
9202 case-independent.
9203
9204
9205 .item "match @{<<string1>>@}@{<<string2>>@}"
9206 .index expansion||regular expression comparison
9207 .index regular expressions||match in expanded string
9208 The two substrings are first expanded. The second is then treated as a regular
9209 expression and applied to the first. Because of the pre-expansion, if the
9210 regular expression contains dollar, or backslash characters, they must be
9211 escaped. Care must also be taken if the regular expression contains braces
9212 (curly brackets). A closing brace must be escaped so that it is not taken as a
9213 premature termination of <<string2>>. The easiest approach is to use the
9214 \"@\N"\ feature to disable expansion of the regular expression.
9215 For example,
9216 .display asis
9217 ${if match {$local_part}{\N^\d{3}\N} ...
9218 .endd
9219 If the whole expansion string is in double quotes, further escaping of
9220 backslashes is also required.
9221
9222 The condition is true if the regular expression match succeeds.
9223 The regular expression is not required to begin with a circumflex
9224 metacharacter, but if there is no circumflex, the expression is not anchored,
9225 and it may match anywhere in the subject, not just at the start. If you want
9226 the pattern to match at the end of the subject, you must include the \"@$"\
9227 metacharacter at an appropriate point.
9228
9229 .index numerical variables (\$1$\, \$2$\, etc)||in \if\ expansion
9230 At the start of an \if\ expansion the values of the numeric variable
9231 substitutions \$1$\ etc. are remembered. Obeying a \match\ condition that
9232 succeeds causes them to be reset to the substrings of that condition and they
9233 will have these values during the expansion of the success string. At the end
9234 of the \if\ expansion, the previous values are restored. After testing a
9235 combination of conditions using \or\, the subsequent values of the numeric
9236 variables are those of the condition that succeeded.
9237
9238 .item "match@_domain @{<<string1>>@}@{<<string2>>@}"
9239 .item "match@_address @{<<string1>>@}@{<<string2>>@}"
9240 .item "match@_local@_part @{<<string1>>@}@{<<string2>>@}"
9241 .index domain list||in expansion condition
9242 .index address list||in expansion condition
9243 .index local part list||in expansion condition
9244 These conditions make it possible to test domain, address, and local
9245 part lists within expansions. Each condition requires two arguments: an item
9246 and a list to match. A trivial example is:
9247 .display asis
9248 ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
9249 .endd
9250 In each case, the second argument may contain any of the allowable items for a
9251 list of the appropriate type. Also, because the second argument (after
9252 expansion) is a standard form of list, it is possible to refer to a named list.
9253 Thus, you can use conditions like this:
9254 .display asis
9255 ${if match_domain{$domain}{+local_domains}{...
9256 .endd
9257 .index \"+caseful"\
9258 For address lists, the matching starts off caselessly, but the \"+caseful"\
9259 item can be used, as in all address lists, to cause subsequent items to
9260 have their local parts matched casefully. Domains are always matched
9261 caselessly.
9262
9263 \**Note**\: Host lists are \*not*\ supported in this way. This is because
9264 hosts have two identities: a name and an IP address, and it is not clear
9265 how to specify cleanly how such a test would work. At least, I haven't come
9266 up with anything yet.
9267
9268 .item "pam {<<string1>>:<<string2>>:...@}"
9269 .index PAM authentication
9270 .index \\AUTH\\||with PAM
9271 .index Solaris||PAM support
9272 .index expansion||PAM authentication test
9273 \*Pluggable Authentication Modules*\
9274 (\?http://www.kernel.org/pub/linux/libs/pam/?\)
9275 are a facility which is available in the latest releases of Solaris and in some
9276 GNU/Linux distributions. The Exim support, which is intended for use in
9277 conjunction with the SMTP \\AUTH\\ command, is available only if Exim is
9278 compiled with
9279 .display asis
9280 SUPPORT_PAM=yes
9281 .endd
9282 in \(Local/Makefile)\. You probably need to add \-lpam-\ to \\EXTRALIBS\\, and
9283 in some releases of GNU/Linux \-ldl-\ is also needed.
9284
9285 The argument string is first expanded, and the result must be a colon-separated
9286 list of strings.
9287 Leading and trailing whitespace is ignored.
9288 The PAM module is initialized with the service name `exim' and the user name
9289 taken from the first item in the colon-separated data string (<<string1>>). The
9290 remaining items in the data string are passed over in response to requests from
9291 the authentication function. In the simple case there will only be one request,
9292 for a password, so the data consists of just two strings.
9293
9294 There can be problems if any of the strings are permitted to contain colon
9295 characters. In the usual way, these have to be doubled to avoid being taken as
9296 separators. If the data is being inserted from a variable, the \sg\ expansion
9297 item can be used to double any existing colons. For example, the configuration
9298 of a LOGIN authenticator might contain this setting:
9299 .display asis
9300 server_condition = ${if pam{$1:${sg{$2}{:}{::}}}{yes}{no}}
9301 .endd
9302 For a PLAIN authenticator you could use:
9303 .display asis
9304 server_condition = ${if pam{$2:${sg{$3}{:}{::}}}{yes}{no}}
9305 .endd
9306 In some operating systems, PAM authentication can be done only from a process
9307 running as root. Since Exim is running as the Exim user when receiving
9308 messages, this means that PAM cannot be used directly in those systems.
9309 A patched version of the \*pam@_unix*\ module that comes with the
9310 Linux PAM package is available from \?http:@/@/www.e-admin.de/pam@_exim/?\.
9311 The patched module allows one special uid/gid combination, in addition to root,
9312 to authenticate. If you build the patched module to allow the Exim user and
9313 group, PAM can then be used from an Exim authenticator.
9314
9315
9316 .item "pwcheck {<<string1>>:<<string2>>@}"
9317 .index \*pwcheck*\ daemon
9318 .index Cyrus
9319 .index expansion||\*pwcheck*\ authentication test
9320 This condition supports user authentication using the Cyrus \*pwcheck*\ daemon.
9321 This is one way of making it possible for passwords to be checked by a process
9322 that is not running as root.
9323 \**Note:**\ The use of \*pwcheck*\ is now deprecated. Its replacement is
9324 \*saslauthd*\ (see below).
9325
9326 The pwcheck support is not included in Exim by default. You need to specify
9327 the location of the pwcheck daemon's socket in \(Local/Makefile)\ before
9328 building Exim. For example:
9329 .display asis
9330 CYRUS_PWCHECK_SOCKET=/var/pwcheck/pwcheck
9331 .endd
9332 You do not need to install the full Cyrus software suite in order to use
9333 the pwcheck daemon. You can compile and install just the daemon alone
9334 from the Cyrus SASL library. Ensure that \*exim*\ is the only user that has
9335 access to the \(/var/pwcheck)\ directory.
9336
9337 The \pwcheck\ condition takes one argument, which must be the user name and
9338 password, separated by a colon. For example, in a LOGIN authenticator
9339 configuration, you might have this:
9340 .display asis
9341 server_condition = ${if pwcheck{$1:$2}{1}{0}}
9342 .endd
9343
9344 .item "queue@_running"
9345 .index queue runner||detecting when delivering from
9346 .index expansion||queue runner test
9347 This condition, which has no data, is true during delivery attempts that are
9348 initiated by queue runner processes, and false otherwise.
9349
9350
9351 .item "radius {<<authentication string>>@}"
9352 .index Radius
9353 .index expansion||Radius authentication
9354 Radius authentication (RFC 2865) is supported in a similar way to PAM. You must
9355 set \\RADIUS@_CONFIG@_FILE\\ in \(Local/Makefile)\ to specify the location of
9356 the Radius client configuration file in order to build Exim with Radius
9357 support.
9358 .em
9359 With just that one setting, Exim expects to be linked with the \radiusclient\ 
9360 library. You can also link Exim with the \libradius\ library that comes with 
9361 FreeBSD. To do this, set
9362 .display asis
9363 RADIUS_LIB_TYPE=RADLIB
9364 .endd
9365 in \(Local/Makefile)\, in addition to setting \\RADIUS@_CONFIGURE@_FILE\\.
9366 .nem
9367 You may also have to supply a suitable setting in \\EXTRALIBS\\ so that the
9368 Radius library can be found when Exim is linked.
9369
9370 The string specified by \\RADIUS@_CONFIG@_FILE\\ is expanded and passed to the
9371 Radius client library, which calls the Radius server. The condition is true if
9372 the authentication is successful. For example
9373 .display
9374 server@_condition = @$@{if radius@{<<arguments>>@}@{yes@}@{no@}@}
9375 .endd
9376
9377
9378
9379 .item "saslauthd @{@{<<user>>@}@{<<password>>@}@{<<service>>@}@{<<realm>>@}@}"
9380 .index \*saslauthd*\ daemon
9381 .index Cyrus
9382 .index expansion||\*saslauthd*\ authentication test
9383 This condition supports user authentication using the Cyrus \*saslauthd*\
9384 daemon. This replaces the older \*pwcheck*\ daemon, which is now deprecated.
9385 Using this daemon is one way of making it possible for passwords to be checked
9386 by a process that is not running as root.
9387
9388 The saslauthd support is not included in Exim by default. You need to specify
9389 the location of the saslauthd daemon's socket in \(Local/Makefile)\ before
9390 building Exim. For example:
9391 .display asis
9392 CYRUS_SASLAUTHD_SOCKET=/var/state/saslauthd/mux
9393 .endd
9394 You do not need to install the full Cyrus software suite in order to use
9395 the saslauthd daemon. You can compile and install just the daemon alone
9396 from the Cyrus SASL library.
9397
9398 Up to four arguments can be supplied to the \saslauthd\ condition, but only two
9399 are mandatory. For example:
9400 .display asis
9401 server_condition = ${if saslauthd{{$1}{$2}}{1}{0}}
9402 .endd
9403 The service and the realm are optional (which is why the arguments are enclosed
9404 in their own set of braces). For details of the meaning of the service and
9405 realm, and how to run the daemon, consult the Cyrus documentation.
9406
9407 .enditems
9408
9409
9410
9411 .section Combining expansion conditions
9412 .index expansion||combining conditions
9413 Several conditions can be tested at once by combining them using the \and\ and
9414 \or\ combination conditions. Note that \and\ and \or\ are complete conditions
9415 on their own, and precede their lists of sub-conditions. Each sub-condition
9416 must be enclosed in braces within the overall braces that contain the list. No
9417 repetition of \if\ is used.
9418
9419 .startitems
9420
9421 .item "or @{@{<<cond1>>@}@{<<cond2>>@}...@}"
9422 .index `or' expansion condition
9423 .index expansion||`or' of conditions
9424 The sub-conditions are evaluated from left to right. The condition is true if
9425 any one of the sub-conditions is true.
9426 For example,
9427 .display asis
9428 ${if or {{eq{$local_part}{spqr}}{eq{$domain}{testing.com}}}...
9429 .endd
9430 When a true sub-condition is found, the following ones are parsed but not
9431 evaluated. If there are several `match' sub-conditions the values of the
9432 numeric variables afterwards are taken from the first one that succeeds.
9433
9434 .item "and @{@{<<cond1>>@}@{<<cond2>>@}...@}"
9435 .index `and' expansion condition
9436 .index expansion||`and' of conditions
9437 The sub-conditions are evaluated from left to right. The condition is true if
9438 all of the sub-conditions are true. If there are several `match'
9439 sub-conditions, the values of the numeric variables afterwards are taken from
9440 the last one. When a false sub-condition is found, the following ones are
9441 parsed but not evaluated.
9442
9443 .enditems
9444
9445
9446
9447 .section Expansion variables
9448 .rset SECTexpvar "~~chapter.~~section"
9449 .index expansion||variables, list of
9450
9451 .em
9452 This section contains an alphabetical list of all the expansion variables. Some
9453 of them are available only when Exim is compiled with specific options such as
9454 support for TLS or the content scanning extension.
9455 .nem
9456
9457 .push
9458 .indent 2em
9459 .index numerical variables (\$1$\, \$2$\, etc)
9460 .tempindent 0
9461 \$0$\, \$1$\, etc: When a \match\ expansion condition succeeds, these
9462 variables contain the captured substrings identified by the regular expression
9463 during subsequent processing of the success string of the containing \if\
9464 expansion item. They may also be set externally by some other matching process
9465 which precedes the expansion of the string. For example, the commands available
9466 in Exim filter files include an \if\ command with its own regular expression
9467 matching condition.
9468
9469 .tempindent 0
9470 \$acl@_c0$\ -- \$acl@_c9$\: Values can be placed in these variables by the
9471 \set\ modifier in an ACL. The values persist throughout the lifetime of an SMTP
9472 connection. They can be used to pass information between ACLs and different
9473 invocations of the same ACL.
9474 When a message is received, the values of these variables are saved with the
9475 message, and can be accessed by filters, routers, and transports during
9476 subsequent delivery.
9477
9478 .tempindent 0
9479 \$acl@_m0$\ -- \$acl@_m9$\: Values can be placed in these variables by the
9480 \set\ modifier in an ACL. They retain their values while a message is being
9481 received, but are reset afterwards. They are also reset by \\MAIL\\, \\RSET\\,
9482 \\EHLO\\, \\HELO\\, and after starting a TLS session.
9483 When a message is received, the values of these variables are saved with the
9484 message, and can be accessed by filters, routers, and transports during
9485 subsequent delivery.
9486
9487
9488 .tempindent 0
9489 \$acl@_verify@_message$\: During the expansion of the \message\ and
9490 \log@_message\ modifiers in an ACL statement after an address verification has
9491 failed, this variable contains the original failure message that will be
9492 overridden by the expanded string.
9493
9494 .tempindent 0
9495 \$address@_data$\: This variable is set by means of the \address@_data\
9496 option in routers. The value then remains with the address while it is
9497 processed by subsequent routers and eventually a transport. If the transport is
9498 handling multiple addresses, the value from the first address is used. See
9499 chapter ~~CHAProutergeneric for more details. \**Note**\: the contents of
9500 \$address@_data$\ are visible in user filter files.
9501
9502 .em
9503 If \$address@_data$\ is set when the routers are called from an ACL to verify 
9504 a recipient address, the final value is still in the variable for subsequent
9505 conditions and modifiers of the ACL statement. If routing the address caused it
9506 to be redirected to just one address, the child address is also routed as part
9507 of the verification, and in this case the final value of \$address@_data$\ is
9508 from the child's routing.
9509
9510 If \$address@_data$\ is set when the routers are called from an ACL to verify a
9511 sender address, the final value is also preserved, but this time in
9512 \$sender@_address@_data$\, to distinguish it from data from a recipient 
9513 address.
9514
9515 In both cases (recipient and sender verification), the value does not persist 
9516 after the end of the current ACL statement. If you want to preserve
9517 these values for longer, you can save them in ACL variables.
9518 .nem
9519
9520 .tempindent 0
9521 \$address@_file$\: When, as a result of aliasing, forwarding, or filtering, a
9522 message is directed to a specific file, this variable holds the name of the
9523 file when the transport is running. At other times, the variable is empty. For
9524 example, using the default configuration, if user \r2d2\ has a \(.forward)\
9525 file containing
9526 .display asis
9527 /home/r2d2/savemail
9528 .endd
9529 then when the \%address@_file%\ transport is running, \$address@_file$\
9530 contains `/home/r2d2/savemail'.
9531 .index Sieve filter||value of \$address@_file$\
9532 For Sieve filters, the value may be `inbox' or a relative folder name. It is
9533 then up to the transport configuration to generate an appropriate absolute path
9534 to the relevant file.
9535
9536
9537 .tempindent 0
9538 \$address@_pipe$\: When, as a result of aliasing or forwarding, a message is
9539 directed to a pipe, this variable holds the pipe command when the transport is
9540 running.
9541
9542 .index authentication||id
9543 .tempindent 0
9544 \$authenticated@_id$\: When a server successfully authenticates a client it may
9545 be configured to preserve some of the authentication information in the
9546 variable \$authenticated@_id$\ (see chapter ~~CHAPSMTPAUTH). For example, a
9547 user/password authenticator configuration might preserve the user name for use
9548 in the routers. When a message is submitted locally (that is, not over a TCP
9549 connection), the value of \$authenticated@_id$\ is the login name of the
9550 calling process.
9551
9552 .index sender||authenticated
9553 .index authentication||sender
9554 .index \\AUTH\\||on \\MAIL\\ command
9555 .tempindent 0
9556 \$authenticated@_sender$\:
9557 When acting as a server, Exim takes note of the \\AUTH=\\ parameter on an
9558 incoming SMTP \\MAIL\\ command
9559 if it believes the sender is sufficiently trusted, as described in section
9560 ~~SECTauthparamail. Unless the data is the string `@<@>', it is set as the
9561 authenticated sender of the message, and the value is available during delivery
9562 in the \$authenticated@_sender$\ variable. If the sender is not trusted, Exim
9563 accepts the syntax of \\AUTH=\\, but ignores the data.
9564
9565 When a message is submitted locally (that is, not over a TCP connection), the
9566 value of \$authenticated@_sender$\ is an address constructed from the login
9567 name of the calling process and \$qualify@_domain$\.
9568
9569
9570 .index authentication||failure
9571 .tempindent 0
9572 \$authentication@_failed$\:
9573 This variable is set to `1' in an Exim server if a client issues an \\AUTH\\
9574 command that does not succeed. Otherwise it is set to `0'. This makes it
9575 possible to distinguish between `did not try to authenticate'
9576 (\$sender@_host@_authenticated$\ is empty and \$authentication__failed$\ is set
9577 to `0') and `tried to authenticate but failed' (\$sender@_host@_authenticated$\
9578 is empty and \$authentication@_failed$\ is set to `1'). Failure includes any
9579 negative response to an \\AUTH\\ command, including (for example) an attempt to
9580 use an undefined mechanism.
9581
9582
9583 .index message||body, line count
9584 .index body of message||line count
9585 .tempindent 0
9586 \$body@_linecount$\:
9587 When a message is being received or delivered, this variable contains the
9588 number of lines in the message's body.
9589
9590 .index message||body, binary zero count
9591 .index body of message||binary zero count
9592 .index binary zero||in message body
9593 .tempindent 0
9594 \$body@_zerocount$\:
9595 When a message is being received or delivered, this variable contains the
9596 number of binary zero bytes in the message's body.
9597
9598 .tempindent 0
9599 \$bounce@_recipient$\:
9600 This is set to the recipient address of a bounce message while Exim is creating
9601 it. It is useful if a customized bounce message text file is in use (see
9602 chapter ~~CHAPemsgcust).
9603
9604 .tempindent 0
9605 \$bounce@_return@_size@_limit$\: This contains the value set in the
9606 \bounce@_return@_size@_limit\ option, rounded up to a multiple of 1000. It is
9607 useful when a customized error message text file is in use (see chapter
9608 ~~CHAPemsgcust).
9609
9610 .index gid (group id)||caller
9611 .tempindent 0
9612 \$caller@_gid$\: The
9613 real
9614 group id under which the process that called Exim was
9615 running. This is not the same as the group id of the originator of a message
9616 (see \$originator@_gid$\). If Exim re-execs itself, this variable in the new
9617 incarnation normally contains the Exim gid.
9618
9619 .index uid (user id)||caller
9620 .tempindent 0
9621 \$caller@_uid$\: The
9622 real
9623 user id under which the process that called Exim was
9624 running. This is not the same as the user id of the originator of a message
9625 (see \$originator@_uid$\). If Exim re-execs itself, this variable in the new
9626 incarnation normally contains the Exim uid.
9627
9628 .tempindent 0
9629 \$compile@_date$\: The date on which the Exim binary was compiled.
9630
9631 .tempindent 0
9632 \$compile@_number$\: The building process for Exim keeps a count of the number
9633 of times it has been compiled. This serves to distinguish different
9634 compilations of the same version of the program.
9635
9636 .em
9637 .tempindent 0
9638 \$demime@_errorlevel$\: This variable is available when Exim is compiled with
9639 the content-scanning extension and the obsolete \demime\ condition. For
9640 details, see section ~~SECTdemimecond.
9641
9642 .tempindent 0
9643 \$demime@_reason$\: This variable is available when Exim is compiled with the
9644 content-scanning extension and the obsolete \demime\ condition. For details,
9645 see section ~~SECTdemimecond.
9646 .nem
9647
9648 .index black list (DNS)
9649 .tempindent 0
9650 \$dnslist@_domain$\: When a client host is found to be on a DNS (black) list,
9651 the list's domain name is put into this variable so that it can be included in
9652 the rejection message.
9653
9654 .tempindent 0
9655 \$dnslist@_text$\: When a client host is found to be on a DNS (black) list, the
9656 contents of any associated TXT record are placed in this variable.
9657
9658 .tempindent 0
9659 \$dnslist@_value$\: When a client host is found to be on a DNS (black) list,
9660 the IP address from the resource record is placed in this variable.
9661 If there are multiple records, all the addresses are included, comma-space
9662 separated.
9663
9664 .tempindent 0
9665 \$domain$\: When an address is being routed, or delivered on its own, this
9666 variable contains the domain. Global address rewriting happens when a message
9667 is received, so the value of \$domain$\ during routing and delivery is the
9668 value after rewriting. \$domain$\ is set during user filtering, but not during
9669 system filtering, because a message may have many recipients and the system
9670 filter is called just once.
9671
9672 When more than one address is being delivered at once (for example, several
9673 \\RCPT\\ commands in one SMTP delivery), \$domain$\ is set only if they all
9674 have the same domain. Transports can be restricted to handling only one domain
9675 at a time if the value of \$domain$\ is required at transport time -- this is
9676 the default for local transports. For further details of the environment in
9677 which local transports are run, see chapter ~~CHAPenvironment.
9678
9679 .index \delay@_warning@_condition\
9680 At the end of a delivery, if all deferred addresses have the same domain, it is
9681 set in \$domain$\ during the expansion of \delay@_warning@_condition\.
9682
9683 The \$domain$\ variable is also used in some other circumstances:
9684 .numberpars $.
9685 When an ACL is running for a \\RCPT\\ command, \$domain$\ contains the domain
9686 of the recipient address.
9687 \**Note:**\ the domain of the sender address is in \$sender@_address@_domain$\
9688 at \\MAIL\\ time and at \\RCPT\\ time. \$domain$\ is not set for the \\MAIL\\
9689 ACL.
9690 .nextp
9691 When a rewrite item is being processed (see chapter ~~CHAPrewrite), \$domain$\
9692 contains the domain portion of the address that is being rewritten; it can be
9693 used in the expansion of the replacement address, for example, to rewrite
9694 domains by file lookup.
9695 .nextp
9696 With one important exception, whenever a domain list is being scanned,
9697 \$domain$\ contains the subject domain. \**Exception**\: When a domain list in
9698 a \sender@_domains\ condition in an ACL is being processed, the subject domain
9699 is in \$sender@_address@_domain$\ and not in \$domain$\. It works this way so
9700 that, in a \\RCPT\\ ACL, the sender domain list can be dependent on the
9701 recipient domain (which is what is in \$domain$\ at this time).
9702 .nextp
9703 .index \\ETRN\\||value of \$domain$\
9704 .index \smtp@_etrn@_command\
9705 When the \smtp@_etrn@_command\ option is being expanded, \$domain$\ contains
9706 the complete argument of the \\ETRN\\ command (see section ~~SECTETRN).
9707 .endp
9708
9709 .tempindent 0
9710 \$domain@_data$\: When the \domains\ option on a router matches a domain by
9711 means of a lookup, the data read by the lookup is available during the running
9712 of the router as \$domain@_data$\. In addition, if the driver routes the
9713 address to a transport, the value is available in that transport. If the
9714 transport is handling multiple addresses, the value from the first address is
9715 used.
9716
9717 \$domain@_data$\ is also set when the \domains\ condition in an ACL matches a
9718 domain by means of a lookup. The data read by the lookup is available during
9719 the rest of the ACL statement. In all other situations, this variable expands
9720 to nothing.
9721
9722 .tempindent 0
9723 \$exim@_gid$\: This variable contains the numerical value of the Exim group id.
9724
9725 .tempindent 0
9726 \$exim@_path$\: This variable contains the path to the Exim binary.
9727
9728 .tempindent 0
9729 \$exim@_uid$\: This variable contains the numerical value of the Exim user id.
9730
9731 .em
9732 .tempindent 0
9733 \$found@_extension$\: This variable is available when Exim is compiled with the
9734 content-scanning extension and the obsolete \demime\ condition. For details,
9735 see section ~~SECTdemimecond.
9736 .nem
9737
9738 .tempindent 0
9739 \$header@_<<name>>$\: This is not strictly an expansion variable. It is
9740 expansion syntax for inserting the message header line with the given name.
9741 Note that the name must be terminated by colon or white space, because it may
9742 contain a wide variety of characters.
9743 Note also that braces must \*not*\ be used.
9744
9745 .tempindent 0
9746 \$home$\:
9747 When the \check@_local@_user\ option is set for a router, the user's home
9748 directory is placed in \$home$\ when the check succeeds. In particular, this
9749 means it is set during the running of users' filter files. A router may also
9750 explicitly set a home directory for use by a transport; this can be overridden
9751 by a setting on the transport itself.
9752
9753 When running a filter test via the \-bf-\ option, \$home$\ is set to the value
9754 of the environment variable \\HOME\\.
9755
9756 .tempindent 0
9757 \$host$\:
9758 When the \%smtp%\ transport is expanding its options for encryption using TLS,
9759 \$host$\ contains the name of the host to which it is connected. Likewise, when
9760 used in the client part of an authenticator configuration (see chapter
9761 ~~CHAPSMTPAUTH), \$host$\ contains the name of the server to which the client
9762 is connected.
9763 .index transport||filter
9764 .index filter||transport filter
9765 When used in a transport filter (see chapter ~~CHAPtransportgeneric) \$host$\
9766 refers to the host involved in the current connection. When a local transport
9767 is run as a result of a router that sets up a host list, \$host$\ contains the
9768 name of the first host.
9769
9770 .tempindent 0
9771 \$host@_address$\:
9772 This variable is set to the remote host's IP address whenever \$host$\ is set
9773 for a remote connection.
9774 .em
9775 It is also set to the IP address that is being checked when the 
9776 \ignore@_target@_hosts\ option is being processed.
9777 .nem
9778
9779 .tempindent 0
9780 \$host@_data$\:
9781 If a \hosts\ condition in an ACL is satisfied by means of a lookup, the result
9782 of the lookup is made available in the \$host@_data$\ variable. This
9783 allows you, for example, to do things like this:
9784 .display asis
9785 deny  hosts = net-lsearch;/some/file
9786       message = $host_data
9787 .endd
9788
9789 .em
9790 .index host||name lookup, failure of
9791 .tempindent 0
9792 \$host@_lookup@_deferred$\:
9793 This variable normally contains `0', as does \$host@_lookup@_failed$\. When a
9794 message comes from a remote host and there is an attempt to look up the host's
9795 name from its IP address, and the attempt is not successful, one of these
9796 variables is set to `1'.
9797 .numberpars $.
9798 If the lookup receives a definite negative response (for example, a DNS lookup 
9799 succeeded, but no records were found), \$host@_lookup@_failed$\ is set to `1'.
9800 .nextp
9801 If there is any kind of problem during the lookup, such that Exim cannot 
9802 tell whether or not the host name is defined (for example, a timeout for a DNS 
9803 lookup), \$host@_lookup@_deferred$\ is set to `1'.
9804 .endp
9805 Looking up a host's name from its IP address consists of more than just a
9806 single reverse lookup. Exim checks that a forward lookup of at least one of the
9807 names it receives from a reverse lookup yields the original IP address. If this
9808 is not the case, Exim does not accept the looked up name(s), and
9809 \$host@_lookup@_failed$\ is set to `1'. Thus, being able to find a name from an
9810 IP address (for example, the existence of a PTR record in the DNS) is not
9811 sufficient on its own for the success of a host name lookup. If the reverse
9812 lookup succeeds, but there is a lookup problem such as a timeout when checking
9813 the result, the name is not accepted, and \$host@_lookup@_deferred$\ is set to
9814 `1'. See also \$sender@_host@_name$\.
9815
9816 .tempindent 0
9817 \$host@_lookup@_failed$\: See \$host@_lookup@_deferred$\.
9818 .nem
9819
9820 .tempindent 0
9821 \$inode$\:
9822 The only time this variable is set is while expanding the \directory@_file\
9823 option in the \%appendfile%\ transport. The variable contains the inode number
9824 of the temporary file which is about to be renamed. It can be used to construct
9825 a unique name for the file.
9826
9827 .tempindent 0
9828 \$interface@_address$\:
9829 When a message is received over a TCP/IP connection, this variable contains the
9830 address of the local IP interface. See also the \-oMi-\ command line option.
9831 This variable can be used in ACLs and also, for example, to make the file name
9832 for a TLS certificate depend on which interface is being used.
9833
9834 .tempindent 0
9835 \$interface@_port$\:
9836 When a message is received over a TCP/IP connection, this variable contains the
9837 local port number. See also the \-oMi-\ command line option.
9838 This variable can be used in ACLs and also, for example, to make the file name
9839 for a TLS certificate depend on which port is being used.
9840
9841 .tempindent 0
9842 \$ldap@_dn$\:
9843 This variable, which is available only when Exim is compiled with LDAP support,
9844 contains the DN from the last entry in the most recently successful LDAP
9845 lookup.
9846
9847 .tempindent 0
9848 \$load@_average$\:
9849 This variable contains the system load average, multiplied by 1000 to that it
9850 is an integer. For example, if the load average is 0.21, the value of the
9851 variable is 210. The value is recomputed every time the variable is referenced.
9852
9853 .tempindent 0
9854 \$local@_part$\: When an address is being routed, or delivered on its own, this
9855 variable contains the local part. When a number of addresses are being
9856 delivered together (for example, multiple \\RCPT\\ commands in an SMTP
9857 session), \$local@_part$\ is not set.
9858
9859 Global address rewriting happens when a message is received, so the value of
9860 \$local@_part$\ during routing and delivery is the value after rewriting.
9861 \$local@_part$\ is set during user filtering, but not during system filtering,
9862 because a message may have many recipients and the system filter is called just
9863 once.
9864
9865 If a local part prefix or suffix has been recognized, it is not included in the
9866 value of \$local@_part$\ during routing and subsequent delivery. The values of
9867 any prefix or suffix are in \$local@_part@_prefix$\ and
9868 \$local@_part@_suffix$\, respectively.
9869
9870 When a message is being delivered to a file, pipe, or autoreply transport as a
9871 result of aliasing or forwarding, \$local@_part$\ is set to the local part of
9872 the parent address, not to the file name or command (see \$address@_file$\ and
9873 \$address@_pipe$\).
9874
9875 When an ACL is running for a \\RCPT\\ command, \$local@_part$\ contains the
9876 local part of the recipient address.
9877
9878 When a rewrite item is being processed (see chapter ~~CHAPrewrite),
9879 \$local@_part$\ contains the local part of the address that is being rewritten;
9880 it can be used in the expansion of the replacement address, for example.
9881
9882 In all cases, all quoting is removed from the local part. For example, for both
9883 the addresses
9884 .display asis
9885 "abc:xyz"@test.example
9886 abc\:xyz@test.example
9887 .endd
9888 the value of \$local@_part$\ is
9889 .display asis
9890 abc:xyz
9891 .endd
9892 If you use \$local@_part$\ to create another address, you should always wrap it
9893 inside a quoting operator. For example, in a \%redirect%\ router you could have:
9894 .display asis
9895 data = ${quote_local_part:$local_part}@new.domain.example
9896 .endd
9897 \**Note**\: The value of \$local@_part$\ is normally lower cased. If you want
9898 to process local parts in a case-dependent manner in a router, you can set the
9899 \caseful@_local@_part\ option (see chapter ~~CHAProutergeneric).
9900
9901 .tempindent 0
9902 \$local@_part@_data$\:
9903 When the \local@_parts\ option on a router matches a local part by means of a
9904 lookup, the data read by the lookup is available during the running of the
9905 router as \$local@_part@_data$\. In addition, if the driver routes the address
9906 to a transport, the value is available in that transport. If the transport is
9907 handling multiple addresses, the value from the first address is used.
9908
9909 \$local@_part@_data$\ is also set when the \local@_parts\ condition in an ACL
9910 matches a local part by means of a lookup. The data read by the lookup is
9911 available during the rest of the ACL statement. In all other situations, this
9912 variable expands to nothing.
9913
9914 .tempindent 0
9915 \$local@_part@_prefix$\: When an address is being routed or delivered, and a
9916 specific prefix for the local part was recognized, it is available in this
9917 variable, having been removed from \$local@_part$\.
9918
9919 .tempindent 0
9920 \$local@_part@_suffix$\: When an address is being routed or delivered, and a
9921 specific suffix for the local part was recognized, it is available in this
9922 variable, having been removed from \$local@_part$\.
9923
9924 .tempindent 0
9925 \$local@_scan@_data$\: This variable contains the text returned by the
9926 \*local@_scan()*\ function when a message is received. See chapter
9927 ~~CHAPlocalscan for more details.
9928
9929 .tempindent 0
9930 \$local@_user@_gid$\: See \$local@_user@_uid$\.
9931
9932 .tempindent 0
9933 \$local@_user@_uid$\: This variable and \$local@_user@_gid$\ are set to
9934 the uid and gid after the \check__local__user\ router precondition succeeds.
9935 This means that their values are available for the remaining preconditions
9936 (\senders\, \require@_files\, and \condition\), for the \address@_data\
9937 expansion, and for any router-specific expansions. At all other times, the
9938 values in these variables are \"(uid@_t)(-1)"\ and \"(gid@_t)(-1)"\,
9939 respectively.
9940
9941 .tempindent 0
9942 \$localhost@_number$\: This contains the expanded value of the
9943 \localhost@_number\ option. The expansion happens after the main options have
9944 been read.
9945
9946 .em
9947 .tempindent 0
9948 \$log@_inodes$\: The number of free inodes in the disk partition where Exim's 
9949 log files are being written. The value is recalculated whenever the variable is
9950 referenced. If the relevant file system does not have the concept of inodes,
9951 the value of is -1. See also the \check@_log@_inodes\ option.
9952  
9953 .tempindent 0
9954 \$log@_space$\: The amount of free space (as a number of kilobytes) in the disk
9955 partition where Exim's log files are being written. The value is recalculated
9956 whenever the variable is referenced. If the operating system does not have the
9957 ability to find the amount of free space (only true for experimental systems),
9958 the space value is -1. See also the \check@_log@_space\ option.
9959 .nem
9960
9961 .tempindent 0
9962 \$mailstore@_basename$\: This variable is set only when doing deliveries in
9963 `mailstore' format in the \%appendfile%\ transport. During the expansion of the
9964 \mailstore@_prefix\, \mailstore@_suffix\, \message__prefix\, and
9965 \message@_suffix\ options, it contains the basename of the files that are being
9966 written, that is, the name without the `.tmp', `.env', or `.msg' suffix. At all
9967 other times, this variable is empty.
9968
9969 .em
9970 .tempindent 0
9971 \$malware@_name$\: This variable is available when Exim is compiled with the 
9972 content-scanning extension. It is set to the name of the virus that was found 
9973 when the ACL \malware\ condition is true (see section ~~SECTscanvirus).
9974 .nem
9975
9976 .index message||age of
9977 .tempindent 0
9978 \$message@_age$\: This variable is set at the start of a delivery attempt to
9979 contain the number of seconds since the message was received. It does not
9980 change during a single delivery attempt.
9981
9982 .index body of message||expansion variable
9983 .index message||body, in expansion
9984 .index binary zero||in message body
9985 .tempindent 0
9986 \$message@_body$\: This variable contains the initial portion of a message's
9987 body while it is being delivered, and is intended mainly for use in filter
9988 files. The maximum number of characters of the body that are put into the
9989 variable is set by the \message@_body@_visible\ configuration option; the
9990 default is 500. Newlines are converted into spaces to make it easier to search
9991 for phrases that might be split over a line break.
9992 Binary zeros are also converted into spaces.
9993
9994 .index body of message||expansion variable
9995 .index message||body, in expansion
9996 .tempindent 0
9997 \$message@_body@_end$\: This variable contains the final portion of a message's
9998 body while it is being delivered. The format and maximum size are as for
9999 \$message@_body$\.
10000
10001 .index body of message||size
10002 .index message||body, size
10003 .tempindent 0
10004 \$message@_body@_size$\: When a message is being delivered, this variable
10005 contains the size of the body in bytes. The count starts from the character
10006 after the blank line that separates the body from the header. Newlines are
10007 included in the count. See also \$message@_size$\, \$body@_linecount$\, and 
10008 \$body@_zerocount$\.
10009
10010 .tempindent 0
10011 \$message@_headers$\:
10012 This variable contains a concatenation of all the header lines when a message
10013 is being processed, except for lines added by routers or transports. The header
10014 lines are separated by newline characters.
10015
10016 .tempindent 0
10017 \$message@_id$\:
10018 When a message is being received or delivered, this variable contains the
10019 unique message id that is used by Exim to identify the message.
10020 An id is not created for a message until after its header has been
10021 successfully received.
10022 \**Note**\: This is \*not*\ the contents of the ::Message-ID:: header line; it
10023 is the local id that Exim assigns to the message, for example:
10024 \"1BXTIK-0001yO-VA"\.
10025
10026 .index size||of message
10027 .index message||size
10028 .tempindent 0
10029 \$message@_size$\:
10030 When a message is being processed, this variable contains its size in bytes. In
10031 most cases, the size includes those headers that were received with the
10032 message, but not those (such as ::Envelope-to::) that are added to individual
10033 deliveries as they are written. However, there is one special case: during the
10034 expansion of the \maildir@_tag\ option in the \%appendfile%\ transport while
10035 doing a delivery in maildir format, the value of \$message@_size$\ is the
10036 precise size of the file that has been written. See also
10037 \$message@_body@_size$\, \$body@_linecount$\, and \$body@_zerocount$\.
10038
10039 .index \\RCPT\\||value of \$message@_size$\
10040 While running an ACL at the time of an SMTP \\RCPT\\ command, \$message@_size$\
10041 contains the size supplied on the \\MAIL\\ command, or
10042 -1
10043 if no size was given. The value may not, of course, be truthful.
10044
10045 .em
10046 .tempindent 0
10047 \$mime@_$\\*xxx*\: A number of variables whose names start with \$mime$\ are
10048 available when Exim is compiled with the content-scanning extension. For
10049 details, see section ~~SECTscanmimepart.
10050 .nem
10051
10052 .tempindent 0
10053 \$n0$\ -- \$n9$\: These variables are counters that can be incremented by means
10054 of the \add\ command in filter files.
10055
10056 .tempindent 0
10057 \$original@_domain$\: When a top-level address is being processed for delivery,
10058 this contains the same value as \$domain$\. However, if a `child' address (for
10059 example, generated by an alias, forward, or filter file) is being processed,
10060 this variable contains the domain of the original address. This differs from
10061 \$parent@_domain$\ only when there is more than one level of aliasing or
10062 forwarding. When more than one address is being delivered in a single transport
10063 run, \$original@_domain$\ is not set.
10064
10065 If new an address is created by means of a \deliver\ command in a system
10066 filter, it is set up with an artificial `parent' address. This has the local
10067 part \*system-filter*\ and the default qualify domain.
10068
10069 .tempindent 0
10070 \$original@_local@_part$\: When a top-level address is being processed for
10071 delivery, this contains the same value as \$local@_part$\, unless a prefix or
10072 suffix was removed from the local part, because \$original@_local@_part$\
10073 always contains the full local part. When a `child' address (for example,
10074 generated by an alias, forward, or filter file) is being processed, this
10075 variable contains the full local part of the original address.
10076
10077 If the router that did the redirection processed the local part
10078 case-insensitively, the value in \$original@_local@_part$\ is in lower case.
10079 This variable differs from \$parent@_local@_part$\ only when there is more than
10080 one level of aliasing or forwarding. When more than one address is being
10081 delivered in a single transport run, \$original@_local@_part$\ is not set.
10082
10083 If new an address is created by means of a \deliver\ command in a system
10084 filter, it is set up with an artificial `parent' address. This has the local
10085 part \*system-filter*\ and the default qualify domain.
10086
10087
10088 .index gid (group id)||of originating user
10089 .index sender||gid
10090 .tempindent 0
10091 \$originator@_gid$\: The value of \$caller@_gid$\ that was set when the message
10092 was received. For messages received via the command line, this is the gid of
10093 the sending user. For messages received by SMTP over TCP/IP, this is normally
10094 the gid of the Exim user.
10095
10096 .index uid (user id)||of originating user
10097 .index sender||uid
10098 .tempindent 0
10099 \$originator@_uid$\: The value of \$caller@_uid$\ that was set when the message
10100 was received. For messages received via the command line, this is the uid of
10101 the sending user. For messages received by SMTP over TCP/IP, this is normally
10102 the uid of the Exim user.
10103
10104 .tempindent 0
10105 \$parent@_domain$\: This variable is similar to \$original@_domain$\ (see
10106 above), except that it refers to the immediately preceding parent address.
10107
10108 .tempindent 0
10109 \$parent@_local@_part$\: This variable is similar to \$original@_local@_part$\
10110 (see above), except that it refers to the immediately preceding parent address.
10111
10112 .index pid (process id)||of current process
10113 .tempindent 0
10114 \$pid$\: This variable contains the current process id.
10115
10116 .index filter||transport filter
10117 .index transport||filter
10118 .tempindent 0
10119 \$pipe@_addresses$\: This is not an expansion variable, but is mentioned here
10120 because the string `@$pipe@_addresses' is handled specially in the command
10121 specification for the \%pipe%\ transport (chapter ~~CHAPpipetransport) and in
10122 transport filters (described under \transport@_filter\ in chapter
10123 ~~CHAPtransportgeneric). It cannot be used in general expansion strings, and
10124 provokes an `unknown variable' error if encountered.
10125
10126 .tempindent 0
10127 \$primary@_hostname$\: The value set in the configuration file, or read by the
10128 \*uname()*\ function. If \*uname()*\ returns a single-component name, Exim
10129 calls \*gethostbyname()*\ (or \*getipnodebyname()*\ where available) in an
10130 attempt to acquire a fully qualified host name.
10131 See also \$smtp@_active@_hostname$\.
10132
10133 .tempindent 0
10134 \$qualify@_domain$\: The value set for this option in the configuration file.
10135
10136 .tempindent 0
10137 \$qualify@_recipient$\: The value set for this option in the configuration file,
10138 or if not set, the value of \$qualify@_domain$\.
10139
10140 .tempindent 0
10141 \$rcpt@_count$\: When a message is being received by SMTP, this variable
10142 contains the number of \\RCPT\\ commands received for the current message. If
10143 this variable is used in a \\RCPT\\ ACL, its value includes the current
10144 command.
10145
10146 .tempindent 0
10147 \$rcpt@_defer@_count$\: When a message is being received by SMTP, this variable
10148 contains the number of \\RCPT\\ commands in the current message that have
10149 previously been rejected with a temporary (4\*xx*\) response.
10150
10151 .tempindent 0
10152 \$rcpt@_fail@_count$\: When a message is being received by SMTP, this variable
10153 contains the number of \\RCPT\\ commands in the current message that have
10154 previously been rejected with a permanent (5\*xx*\) response.
10155
10156 .tempindent 0
10157 \$received@_count$\: This variable contains the number of ::Received:: header
10158 lines in the message, including the one added by Exim (so its value is always
10159 greater than zero). It is available in the \\DATA\\ ACL, the non-SMTP ACL, and
10160 while routing and delivering.
10161
10162 .tempindent 0
10163 \$received@_for$\: If there is only a single recipient address in an incoming
10164 message, this variable contains that address when the ::Received:: header line
10165 is being built.
10166 The value is copied after recipient rewriting has happened, but before the
10167 \*local@_scan()*\ function is run.
10168
10169 .tempindent 0
10170 \$received@_protocol$\: When a message is being processed, this variable
10171 contains the name of the protocol by which it was received. 
10172 .em
10173 Most of the names used by Exim are defined by RFCs 821, 2821, and 3848. They
10174 start with `smtp' (the client used \\HELO\\) or `esmtp' (the client used
10175 \\EHLO\\). This can be followed by `s' for secure (encrypted) and/or `a' for
10176 authenticated. Thus, for example, if the protocol is set to `esmtpsa', the
10177 message was received over an encrypted SMTP connection and the client was
10178 successfully authenticated.
10179
10180 Exim uses the protocol name `smtps' for the case when encryption is
10181 automatically set up on connection without the use of \\STARTTLS\\ (see
10182 \tls@_on@_connect@_ports\), and the client uses \\HELO\\ to initiate the
10183 encrypted SMTP session. The name `smtps' is also used for the rare situation
10184 where the client initially uses \\EHLO\\, sets up an encrypted connection using
10185 \\STARTTLS\\, and then uses \\HELO\\ afterwards.
10186
10187 The \-oMr-\ option provides a way of specifying a custom protocol name for 
10188 messages that are injected locally by trusted callers. This is commonly used to 
10189 identify messages that are being re-injected after some kind of scanning.
10190 .nem
10191
10192 .tempindent 0
10193 \$recipient@_data$\: This variable is set after an indexing lookup success in
10194 an ACL \recipients\ condition. It contains the data from the lookup, and the
10195 value remains set until the next \recipients\ test. Thus, you can do things
10196 like this:
10197 .display
10198 require recipients      = cdb*@@;/some/file
10199 deny    \*some further test involving*\ @$recipient@_data
10200 .endd
10201 \**Warning**\: This variable is set only when a lookup is used as an indexing
10202 method in the address list, using the semicolon syntax as in the example above.
10203 The variable is not set for a lookup that is used as part of the string
10204 expansion that all such lists undergo before being interpreted.
10205
10206 .em
10207 .tempindent 0
10208 \$recipient@_verify@_failure$\: In an ACL, when a recipient verification fails,
10209 this variable contains information about the failure. It is set to one of the
10210 following words:
10211 .numberpars " "
10212 `qualify': The address was unqualified (no domain), and the message
10213 was neither local nor came from an exempted host.
10214 .nextp
10215 `route': Routing failed.
10216 .nextp
10217 `mail': Routing succeeded, and a callout was attempted; rejection occurred at
10218 or before the \\MAIL\\ command (that is, on initial connection, \\HELO\\, or
10219 \\MAIL\\).
10220 .nextp
10221 `recipient': The \\RCPT\\ command in a callout was rejected.
10222 .nextp
10223 `postmaster': The postmaster check in a callout was rejected.
10224 .endp
10225 The main use of this variable is expected to be to distinguish between
10226 rejections of \\MAIL\\ and rejections of \\RCPT\\.
10227 .nem
10228
10229 .tempindent 0
10230 \$recipients$\: This variable contains a list of envelope recipients for a
10231 message. A comma and a space separate the addresses in the replacement text.
10232 However, the variable is not generally available, to prevent exposure of Bcc
10233 recipients in unprivileged users' filter files. You can use \$recipients$\ only
10234 in these two cases:
10235 .numberpars
10236 In a system filter file.
10237 .nextp
10238 .em
10239 In the ACLs associated with the \\DATA\\ command, that is, the ACLs defined by 
10240 \acl@_smtp@_predata\ and \acl@_smtp@_data\.
10241 .nem
10242 .endp
10243
10244 .tempindent 0
10245 \$recipients@_count$\: When a message is being processed, this variable
10246 contains the number of envelope recipients that came with the message.
10247 Duplicates are not excluded from the count. While a message is being received
10248 over SMTP, the number increases for each accepted recipient. It can be
10249 referenced in an ACL.
10250
10251 .tempindent 0
10252 \$reply@_address$\: When a message is being processed, this variable contains
10253 the contents of the ::Reply-To:: header line if one exists
10254 and it is not empty,
10255 or otherwise the contents of the ::From:: header line.
10256
10257 .tempindent 0
10258 \$return@_path$\: When a message is being delivered, this variable contains the
10259 return path -- the sender field that will be sent as part of the envelope. It
10260 is not enclosed in @<@> characters.
10261 At the start of routing an address,
10262 \$return@_path$\ has the same value as \$sender@_address$\, but if, for
10263 example, an incoming message to a mailing list has been expanded by a router
10264 which specifies a different address for bounce messages, \$return@_path$\
10265 subsequently contains the new bounce address, whereas \$sender@_address$\
10266 always contains the original sender address that was received with the message.
10267 In other words, \$sender@_address$\ contains the incoming envelope sender, and
10268 \$return@_path$\ contains the outgoing envelope sender.
10269
10270 .tempindent 0
10271 \$return@_size@_limit$\: This is an obsolete name for
10272 \$bounce@_return@_size@_limit$\.
10273
10274 .index return code||from \run\ expansion
10275 .tempindent 0
10276 \$runrc$\: This variable contains the return code from a command that is run by
10277 the \@$@{run...@}\ expansion item.
10278 \**Warning**\: In a router or transport, you cannot assume the order in which
10279 option values are expanded, except for those pre-conditions whose order of
10280 testing is documented. Therefore, you cannot reliably expect to set \$runrc$\
10281 by the expansion of one option, and use it in another.
10282
10283 .tempindent 0
10284 \$self@_hostname$\: When an address is routed to a supposedly remote host that
10285 turns out to be the local host, what happens is controlled by the
10286 .index \self\ option||value of host name
10287 \self\ generic router option. One of its values causes the address to be passed
10288 to another router. When this happens, \$self@_hostname$\ is set to the name of
10289 the local host that the original router encountered. In other circumstances its
10290 contents are null.
10291
10292 .tempindent 0
10293 \$sender@_address$\: When a message is being processed, this variable contains
10294 the sender's address that was received in the message's envelope. For bounce
10295 messages, the value of this variable is the empty string.
10296 See also \$return@_path$\.
10297
10298 .em
10299 .tempindent 0
10300 \$sender@_address@_data$\: If \$address@_data$\ is set when the routers are
10301 called from an ACL to verify a sender address, the final value is preserved in
10302 \$sender@_address@_data$\, to distinguish it from data from a recipient
10303 address. The value does not persist after the end of the current ACL statement.
10304 If you want to preserve it for longer, you can save it in an ACL variable.
10305 .nem
10306
10307 .tempindent 0
10308 \$sender@_address@_domain$\: The domain portion of \$sender@_address$\.
10309
10310 .tempindent 0
10311 \$sender@_address@_local@_part$\: The local part portion of \$sender@_address$\.
10312
10313 .tempindent 0
10314 \$sender@_data$\: This variable is set after a lookup success in an ACL
10315 \senders\ condition or in a router \senders\ option. It contains the data from
10316 the lookup, and the value remains set until the next \senders\ test. Thus, you
10317 can do things like this:
10318 .display
10319 require senders      = cdb*@@;/some/file
10320 deny    \*some further test involving*\ @$sender@_data
10321 .endd
10322 \**Warning**\: This variable is set only when a lookup is used as an indexing
10323 method in the address list, using the semicolon syntax as in the example above.
10324 The variable is not set for a lookup that is used as part of the string
10325 expansion that all such lists undergo before being interpreted.
10326
10327 .tempindent 0
10328 \$sender@_fullhost$\: When a message is received from a remote host, this
10329 variable contains the host name and IP address in a single string. It ends
10330 with the IP address in square brackets, followed by a colon and a port number
10331 if the logging of ports is enabled. The format of the rest of the string
10332 depends on whether the host issued a \\HELO\\ or \\EHLO\\ SMTP command, and
10333 whether the host name was verified by looking up its IP address. (Looking up
10334 the IP address can be forced by the \host@_lookup\ option, independent of
10335 verification.) A plain host name at the start of the string is a verified host
10336 name; if this is not present, verification either failed or was not requested.
10337 A host name in parentheses is the argument of a \\HELO\\ or \\EHLO\\ command.
10338 This is omitted if it is identical to the verified host name or to the host's
10339 IP address in square brackets.
10340
10341 .tempindent 0
10342 \$sender@_helo@_name$\: When a message is received from a remote host that has
10343 issued a \\HELO\\ or \\EHLO\\ command, the argument of that command is placed
10344 in this variable. It is also set if \\HELO\\ or \\EHLO\\ is used when a message
10345 is received using SMTP locally via the \-bs-\ or \-bS-\ options.
10346
10347 .tempindent 0
10348 \$sender@_host@_address$\: When a message is received from a remote host, this
10349 variable contains that host's IP address. For locally submitted messages, it is
10350 empty.
10351
10352 .tempindent 0
10353 \$sender@_host@_authenticated$\: This variable contains the name (not the
10354 public name) of the authenticator driver which successfully authenticated the
10355 client from which the message was received. It is empty if there was no
10356 successful authentication.
10357
10358 .tempindent 0
10359 \$sender@_host@_name$\: When a message is received from a remote host, this
10360 variable contains the host's name as obtained by looking up its IP address.
10361 For messages received by other means, this variable is empty.
10362
10363 If the host name has not previously been looked up, a reference to
10364 \$sender@_host@_name$\ triggers a lookup (for messages from remote hosts).
10365 A looked up name is accepted only if it leads back to the original IP address
10366 via a forward lookup. If either the reverse or the forward lookup fails
10367 .em
10368 to find any data,
10369 .nem
10370 or if the forward lookup does not yield the original IP address,
10371 \$sender@_host@_name$\ remains empty, and \$host@_lookup@_failed$\ is set to
10372 `1'.
10373 .em
10374 However, if either of the lookups cannot be completed (for example, there is a 
10375 DNS timeout), \$host@_lookup@_deferred$\ is set to `1', and 
10376 \$host@_lookup@_failed$\ remains set to `0'.
10377
10378 Once \$host@_lookup@_failed$\ is set to `1', Exim does not try to look up the 
10379 host name again if there is a subsequent reference to \$sender@_host@_name$\ 
10380 in the same Exim process, but it does try again if \$sender@_host@_deferred$\
10381 is set to `1'.
10382 .nem
10383
10384 Exim does not automatically look up every calling host's name. If you want
10385 maximum efficiency, you should arrange your configuration so that it avoids
10386 these lookups altogether. The lookup happens only if one or more of the
10387 following are true:
10388 .numberpars
10389 A string containing \$sender@_host@_name$\ is expanded.
10390 .nextp
10391 The calling host matches the list in \host@_lookup\. In the default
10392 configuration, this option is set to $*$, so it must be changed if lookups are
10393 to be avoided. (In the code, the default for \host@_lookup\ is unset.)
10394 .nextp
10395 Exim needs the host name in order to test an item in a host list. The items
10396 that require this are described in sections ~~SECThoslispatnam and
10397 ~~SECThoslispatnamsk.
10398 .nextp
10399 The calling host matches \helo@_try@_verify@_hosts\ or \helo@_verify@_hosts\.
10400 In this case, the host name is required to compare with the name quoted in any
10401 \\EHLO\\ or \\HELO\\ commands that the client issues.
10402 .nextp
10403 The remote host issues a \\EHLO\\ or \\HELO\\ command that quotes one of the
10404 domains in \helo@_lookup@_domains\. The default value of this option is
10405 .display asis
10406 helo_lookup_domains = @ : @[]
10407 .endd
10408 which causes a lookup if a remote host (incorrectly) gives the server's name or
10409 IP address in an \\EHLO\\ or \\HELO\\ command.
10410 .endp
10411
10412 .tempindent 0
10413 \$sender@_host@_port$\: When a message is received from a remote host, this
10414 variable contains the port number that was used on the remote host.
10415
10416 .tempindent 0
10417 \$sender@_ident$\: When a message is received from a remote host, this variable
10418 contains the identification received in response to an RFC 1413 request. When a
10419 message has been received locally, this variable contains the login name of the
10420 user that called Exim.
10421
10422 .tempindent 0
10423 \$sender@_rcvhost$\: This is provided specifically for use in ::Received::
10424 headers. It starts with either the verified host name (as obtained from a
10425 .index DNS||reverse lookup
10426 .index reverse DNS lookup
10427 reverse DNS lookup) or, if there is no verified host name, the IP address in
10428 square brackets. After that there may be text in parentheses. When the first
10429 item is a verified host name, the first thing in the parentheses is the IP
10430 address in square brackets, followed by a colon and a port number if port
10431 logging is enabled. When the first item is an IP address, the port is recorded
10432 as `port=$it{xxxx}' inside the parentheses.
10433
10434 There may also be items of the form `helo=$it{xxxx}' if \\HELO\\ or \\EHLO\\
10435 was used and its argument was not identical to the real host name or IP
10436 address, and `ident=$it{xxxx}' if an RFC 1413 ident string is available. If all
10437 three items are present in the parentheses, a newline and tab are inserted into
10438 the string, to improve the formatting of the ::Received:: header.
10439
10440 .em
10441 .tempindent 0
10442 \$sender@_verify@_failure$\: In an ACL, when a sender verification fails, this
10443 variable contains information about the failure. The details are the same as 
10444 for \$recipient@_verify@_failure$\.
10445
10446 .tempindent 0
10447 \$smtp@_active@_hostname$\: During an SMTP session, this variable contains the 
10448 value of the active host name, as specified by the \smtp@_active@_hostname\
10449 option. The value of \$smtp@_active@_hostname$\ is saved with any message that
10450 is received, so its value can be consulted during routing and delivery.
10451 .nem
10452
10453 .index \\AUTH\\||argument
10454 .index \\EXPN\\||argument
10455 .index \\ETRN\\||argument
10456 .index \\VRFY\\||argument
10457 .tempindent 0
10458 \$smtp@_command@_argument$\: While an ACL is running to check an \\AUTH\\,
10459 \\EHLO\\, \\EXPN\\, \\ETRN\\, \\HELO\\, or \\VRFY\\ command, this variable
10460 contains the argument for the SMTP command.
10461
10462 .tempindent 0
10463 \$sn0$\ -- \$sn9$\: These variables are copies of the values of the \$n0$\
10464 -- \$n9$\ accumulators that were current at the end of the system filter file.
10465 This allows a system filter file to set values that can be tested in users'
10466 filter files. For example, a system filter could set a value indicating how
10467 likely it is that a message is junk mail.
10468
10469 .em
10470 .tempindent 0
10471 \$spam@_$\\*xxx*\: A number of variables whose names start with \$spam$\ are
10472 available when Exim is compiled with the content-scanning extension. For
10473 details, see section ~~SECTscanspamass.
10474 .nem
10475
10476 .tempindent 0
10477 \$spool@_directory$\: The name of Exim's spool directory.
10478
10479 .em
10480 .tempindent 0
10481 \$spool@_inodes$\: The number of free inodes in the disk partition where Exim's
10482 spool files are being written. The value is recalculated whenever the variable
10483 is referenced. If the relevant file system does not have the concept of inodes,
10484 the value of is -1.
10485 See also the \check@_spool@_inodes\ option.
10486  
10487 .tempindent 0
10488 \$spool@_space$\: The amount of free space (as a number of kilobytes) in the
10489 disk partition where Exim's spool files are being written. The value is
10490 recalculated whenever the variable is referenced. If the operating system does
10491 not have the ability to find the amount of free space (only true for
10492 experimental systems), the space value is -1. For example, to check in an ACL
10493 that there is at least 50 megabytes free on the spool, you could write:
10494 .display asis
10495 condition = ${if > {$spool_space}{50000}}
10496 .endd
10497 See also the \check@_spool@_space\ option.
10498 .nem
10499
10500 .tempindent 0
10501 \$thisaddress$\: This variable is set only during the processing of the
10502 \foranyaddress\ command in a filter file. Its use is explained in the
10503 description of that command.
10504
10505 .tempindent 0
10506 \$tls@_certificate@_verified$\:
10507 This variable is set to `1' if a TLS certificate was verified when the message
10508 was received, and `0' otherwise.
10509
10510 .tempindent 0
10511 \$tls@_cipher$\: When a message is received from a remote host over an
10512 encrypted SMTP connection, this variable is set to the cipher suite that was
10513 negotiated, for example DES-CBC3-SHA.
10514 In other circumstances, in particular, for message received over unencrypted
10515 connections, the variable is empty.
10516 See chapter ~~CHAPTLS for details of TLS support.
10517
10518 .tempindent 0
10519 \$tls@_peerdn$\:  When a message is received from a remote host over an
10520 encrypted SMTP connection,
10521 and Exim is configured to request a certificate from the client,
10522 the value of the Distinguished Name of the certificate is made available in the
10523 \$tls@_peerdn$\ during subsequent processing.
10524
10525 .tempindent 0
10526 \$tod@_bsdinbox$\: The time of day and date, in the format required for
10527 BSD-style mailbox files, for example: Thu Oct 17 17:14:09 1995.
10528
10529 .tempindent 0
10530 \$tod@_epoch$\: The time and date as a number of seconds since the start of the
10531 Unix epoch.
10532
10533 .tempindent 0
10534 \$tod@_full$\: A full version of the time and date, for example: Wed, 16 Oct
10535 1995 09:51:40 +0100. The timezone is always given as a numerical offset from
10536 UTC, with positive values used for timezones that are ahead (east) of UTC, and
10537 negative values for those that are behind (west).
10538
10539 .tempindent 0
10540 \$tod@_log$\: The time and date in the format used for writing Exim's log
10541 files, for example: 1995-10-12 15:32:29,
10542 but without a timezone.
10543
10544 .tempindent 0
10545 \$tod@_logfile$\:
10546 This variable contains the date in the format yyyymmdd. This is the format that
10547 is used for datestamping log files when \log@_file@_path\ contains the \"%D"\
10548 flag.
10549
10550 .tempindent 0
10551 \$tod@_zone$\: This variable contains the numerical value of the local
10552 timezone, for example: -0500.
10553
10554 .tempindent 0
10555 \$tod@_zulu$\:
10556 This variable contains the UTC date and time in `Zulu' format, as specified by
10557 ISO 8601, for example: 20030221154023Z.
10558
10559 .index \$value$\
10560 .tempindent 0
10561 \$value$\: This variable contains the result of an expansion lookup, extraction
10562 operation, or external command, as described above.
10563
10564 .tempindent 0
10565 \$version@_number$\: The version number of Exim.
10566
10567 .tempindent 0
10568 \$warn@_message@_delay$\: This variable is set only during the creation of a
10569 message warning about a delivery delay. Details of its use are explained in
10570 section ~~SECTcustwarn.
10571
10572 .tempindent 0
10573 \$warn@_message@_recipients$\: This variable is set only during the creation of
10574 a message warning about a delivery delay. Details of its use are explained in
10575 section ~~SECTcustwarn.
10576 .pop
10577
10578
10579
10580 .
10581 .
10582 . ============================================================================
10583 .chapter Embedded Perl
10584 .set runningfoot "embedded Perl"
10585 .rset CHAPperl "~~chapter"
10586 .index Perl||calling from Exim
10587
10588 Exim can be built to include an embedded Perl interpreter. When this is done,
10589 Perl subroutines can be called as part of the string expansion process. To make
10590 use of the Perl support, you need version 5.004 or later of Perl installed on
10591 your system. To include the embedded interpreter in the Exim binary, include
10592 the line
10593 .display asis
10594 EXIM_PERL = perl.o
10595 .endd
10596 in your \(Local/Makefile)\ and then build Exim in the normal way.
10597
10598 .section Setting up so Perl can be used
10599 Access to Perl subroutines is via a global configuration option called
10600 .index \perl@_startup\
10601 \perl@_startup\ and an expansion string operator \@$@{perl ...@}\. If there is
10602 no \perl@_startup\ option in the Exim configuration file then no Perl
10603 interpreter is started and there is almost no overhead for Exim (since none of
10604 the Perl library will be paged in unless used). If there is a \perl@_startup\
10605 option then the associated value is taken to be Perl code which is executed in
10606 a newly created Perl interpreter.
10607
10608 The value of \perl@_startup\ is not expanded in the Exim sense, so you do not
10609 need backslashes before any characters to escape special meanings. The option
10610 should usually be something like
10611 .display asis
10612 perl_startup = do '/etc/exim.pl'
10613 .endd
10614 where \(/etc/exim.pl)\ is Perl code which defines any subroutines you want to
10615 use from Exim. Exim can be configured either to start up a Perl interpreter as
10616 soon as it is entered, or to wait until the first time it is needed. Starting
10617 the interpreter at the beginning ensures that it is done while Exim still has
10618 its setuid privilege, but can impose an unnecessary overhead if Perl is not in
10619 fact used in a particular run. Also, note that this does not mean that Exim is
10620 necessarily running as root when Perl is called at a later time. By default,
10621 the interpreter is started only when it is needed, but this can be changed in
10622 two ways:
10623 .numberpars $.
10624 .index \perl@_at@_start\
10625 Setting \perl@_at@_start\ (a boolean option) in the configuration requests
10626 a startup when Exim is entered.
10627 .nextp
10628 The command line option \-ps-\ also requests a startup when Exim is entered,
10629 overriding the setting of \perl@_at@_start\.
10630 .endp
10631 There is also a command line option \-pd-\ (for delay) which suppresses the
10632 initial startup, even if \perl@_at@_start\ is set.
10633
10634 .section Calling Perl subroutines
10635 When the configuration file includes a \perl@_startup\ option you can make use
10636 of the string expansion item to call the Perl subroutines that are defined
10637 by the \perl@_startup\ code. The operator is used in any of the following
10638 forms:
10639 .display asis
10640 ${perl{foo}}
10641 ${perl{foo}{argument}}
10642 ${perl{foo}{argument1}{argument2} ... }
10643 .endd
10644 which calls the subroutine \foo\ with the given arguments. A maximum of eight
10645 arguments may be passed. Passing more than this results in an expansion failure
10646 with an error message of the form
10647 .display asis
10648 Too many arguments passed to Perl subroutine "foo" (max is 8)
10649 .endd
10650 The return value of the Perl subroutine is evaluated in a scalar context before
10651 it is passed back to Exim to be inserted into the expanded string. If the
10652 return value is \*undef*\, the expansion is forced to fail in the same way as
10653 an explicit `fail' on an \@$@{if ...@}\ or \@$@{lookup...@}\ item. If the
10654 subroutine aborts by obeying Perl's \die\ function, the expansion fails with
10655 the error message that was passed to \die\.
10656
10657 .section Calling Exim functions from Perl
10658 Within any Perl code called from Exim, the function \*Exim@:@:expand@_string*\
10659 is available to call back into Exim's string expansion function. For example,
10660 the Perl code
10661 .display asis
10662 my $lp = Exim::expand_string('$local_part');
10663 .endd
10664 makes the current Exim \$local@_part$\ available in the Perl variable \$lp$\.
10665 Note those are single quotes and not double quotes to protect against
10666 \$local@_part$\ being interpolated as a Perl variable.
10667
10668 If the string expansion is forced to fail by a `fail' item, the result of
10669 \*Exim@:@:expand@_string*\ is \undef\. If there is a syntax error in the
10670 expansion string, the Perl call from the original expansion string fails with
10671 an appropriate error message, in the same way as if \die\ were used.
10672
10673 .index debugging||from embedded Perl
10674 .index log||writing from embedded Perl
10675 Two other Exim functions are available for use from within Perl code.
10676 \*Exim@:@:debug@_write(<<string>>)*\ writes the string to the standard error
10677 stream if Exim's debugging is enabled. If you want a newline at the end, you
10678 must supply it. \*Exim@:@:log@_write(<<string>>)*\ writes the string to Exim's
10679 main log, adding a leading timestamp. In this case, you should not supply a
10680 terminating newline.
10681
10682 .em
10683 .section Use of standard output and error by Perl
10684 .index Perl||standard output and error
10685 You should not write to the standard error or output streams from within your 
10686 Perl code, as it is not defined how these are set up. In versions of Exim  
10687 before 4.50, it is possible for the standard output or error to refer to the 
10688 SMTP connection during message reception via the daemon. Writing to this stream
10689 is certain to cause chaos. From Exim 4.50 onwards, the standard output and
10690 error streams are connected to \(/dev/null)\ in the daemon. The chaos is 
10691 avoided, but the output is lost.
10692
10693 .index Perl||\warn\, use of
10694 The Perl \warn\ statement writes to the standard error stream by default. Calls 
10695 to \warn\ may be embedded in Perl modules that you use, but over which you have
10696 no control. When Exim starts up the Perl interpreter, it arranges for output
10697 from the \warn\ statement to be written to the Exim main log. You can change 
10698 this by including appropriate Perl magic somewhere in your Perl code. For 
10699 example, to discard \warn\ output completely, you need this:
10700 .display asis
10701 $SIG{__WARN__} = sub { };
10702 .endd
10703 Whenever a \warn\ is obeyed, the anonymous subroutine is called. In this 
10704 example, the code for the subroutine is empty, so it does nothing, but you can
10705 include any Perl code that you like. The text of the \warn\ message is passed
10706 as the first subroutine argument.
10707 .nem
10708
10709
10710 .
10711 .
10712 .
10713 .
10714 . ============================================================================
10715 .chapter Starting the daemon and the use of network interfaces
10716 .set runningfoot "starting the daemon"
10717 .rset CHAPinterfaces "~~chapter"
10718 .index daemon||starting
10719 .index interface||listening
10720 .index network interface
10721 .index interface||network
10722 .index IP address||for listening
10723 .index daemon||listening IP addresses
10724 .index TCP/IP||setting listening interfaces
10725 .index TCP/IP||setting listening ports
10726
10727 A host that is connected to a TCP/IP network may have one or more physical
10728 hardware network interfaces. Each of these interfaces may be configured as one
10729 or more `logical' interfaces, which are the entities that a program actually
10730 works with. Each of these logical interfaces is associated with an IP address.
10731 In addition, TCP/IP software supports `loopback' interfaces (127.0.0.1 in IPv4
10732 and @:@:1 in IPv6), which do not use any physical hardware. Exim requires
10733 knowledge about the host's interfaces for use in three different circumstances:
10734 .numberpars
10735 When a listening daemon is started, Exim needs to know which interfaces
10736 and ports to listen on.
10737 .nextp
10738 When Exim is routing an address, it needs to know which IP addresses
10739 are associated with local interfaces. This is required for the correct
10740 processing of MX lists by removing the local host and others with the
10741 same or higher priority values. Also, Exim needs to detect cases
10742 when an address is routed to an IP address that in fact belongs to the
10743 local host. Unless the \self\ router option or the \allow@_localhost\
10744 option of the smtp transport is set (as appropriate), this is treated
10745 as an error situation.
10746 .nextp
10747 When Exim connects to a remote host, it may need to know which interface to use
10748 for the outgoing connection.
10749 .endp
10750
10751 Exim's default behaviour is likely to be appropriate in the vast majority
10752 of cases. If your host has only one interface, and you want all its IP
10753 addresses to be treated in the same way, and you are using only the
10754 standard SMTP port, you should not need to take any special action. The
10755 rest of this chapter does not apply to you.
10756
10757 In a more complicated situation you may want to listen only on certain
10758 interfaces, or on different ports, and for this reason there are a number of
10759 options that can be used to influence Exim's behaviour. The rest of this
10760 chapter describes how they operate.
10761
10762 When a message is received over TCP/IP, the interface and port that were
10763 actually used are set in \$interface@_address$\ and \$interface@_port$\.
10764
10765
10766 .section Starting a listening daemon
10767 When a listening daemon is started (by means of the \-bd-\ command line
10768 option), the interfaces and ports on which it listens are controlled by the
10769 following options:
10770 .numberpars $.
10771 \daemon@_smtp@_ports\ contains a list of default ports. (For backward
10772 compatibility, this option can also be specified in the singular.)
10773 .nextp
10774 \local@_interfaces\ contains list of interface IP addresses on which to
10775 listen. Each item may optionally also specify a port.
10776 .endp
10777 The default list separator in both cases is a colon, but this can be changed as
10778 described in section ~~SECTlistconstruct. When IPv6 addresses are involved, it
10779 is usually best to change the separator to avoid having to double all the
10780 colons. For example:
10781 .display asis
10782 local_interfaces = <; 127.0.0.1 ; \
10783                       192.168.23.65 ; \
10784                       ::1 ; \
10785                       3ffe:ffff:836f::fe86:a061
10786 .endd
10787 There are two different formats for specifying a port along with an IP address
10788 in \local@_interfaces\:
10789 .numberpars
10790 The port is added onto the address with a dot separator. For example, to listen
10791 on port 1234 on two different IP addresses:
10792 .display asis
10793 local_interfaces = <; 192.168.23.65.1234 ; \
10794                       3ffe:ffff:836f::fe86:a061.1234
10795 .endd
10796 .nextp
10797 The IP address is enclosed in square brackets, and the port is added
10798 with a colon separator, for example:
10799 .display asis
10800 local_interfaces = <; [192.168.23.65]:1234 ; \
10801                       [3ffe:ffff:836f::fe86:a061]:1234
10802 .endd
10803 .endp
10804 When a port is not specified, the value of \daemon@_smtp@_ports\ is used. The
10805 default setting contains just one port:
10806 .display asis
10807 daemon_smtp_ports = smtp
10808 .endd
10809 If more than one port is listed, each interface that does not have its own port
10810 specified listens on all of them. Ports that are listed in
10811 \daemon@_smtp@_ports\ can be identified either by name (defined in
10812 \(/etc/services)\) or by number. However, when ports are given with individual
10813 IP addresses in \local@_interfaces\, only numbers (not names) can be used.
10814
10815
10816 .section Special IP listening addresses
10817 The addresses 0.0.0.0 and @:@:0 are treated specially. They are interpreted
10818 as `all IPv4 interfaces' and `all IPv6 interfaces', respectively. In each
10819 case, Exim tells the TCP/IP stack to `listen on all IPv\*x*\ interfaces'
10820 instead of setting up separate listening sockets for each interface. The
10821 default value of \local@_interfaces\ is
10822 .display asis
10823 local_interfaces = 0.0.0.0
10824 .endd
10825 when Exim is built without IPv6 support; otherwise it is:
10826 .display asis
10827 local_interfaces = <; ::0 ; 0.0.0.0
10828 .endd
10829 Thus, by default, Exim listens on all available interfaces, on the SMTP port.
10830
10831
10832 .section Overriding local@_interfaces and daemon@_smtp@_ports
10833 The \-oX-\ command line option can be used to override the values of
10834 \daemon@_smtp@_ports\ and/or \local@_interfaces\ for a particular daemon
10835 instance. Another way of doing this would be to use macros and the \-D-\
10836 option. However, \-oX-\ can be used by any admin user, whereas modification of
10837 the runtime configuration by \-D-\ is allowed only when the caller is root or
10838 exim.
10839
10840 The value of \-oX-\ is a list of items. The default colon separator can be
10841 changed in the usual way if required. If there are any items that do not
10842 contain dots or colons (that is, are not IP addresses), the value of
10843 \daemon@_smtp@_ports\ is replaced by the list of those items. If there are any
10844 items that do contain dots or colons, the value of \local@_interfaces\ is
10845 replaced by those items. Thus, for example,
10846 .display asis
10847 -oX 1225
10848 .endd
10849 overrides \daemon@_smtp@_ports\, but leaves \local@_interfaces\ unchanged,
10850 whereas
10851 .display asis
10852 -oX 192.168.34.5.1125
10853 .endd
10854 overrides \local@_interfaces\, leaving \daemon@_smtp@_ports\ unchanged.
10855 (However, since \local@_interfaces\ now contains no items without ports, the
10856 value of \daemon@_smtp@_ports\ is no longer relevant in this example.)
10857
10858
10859 .em
10860 .section Support for the obsolete SSMTP (or SMTPS) protocol
10861 .rset SECTsupobssmt "~~chapter.~~section"
10862 .index ssmtp protocol
10863 .index smtps protocol
10864 .index SMTP||ssmtp protocol
10865 .index SMTP||smtps protocol
10866 Exim supports the obsolete SSMTP protocol (also known as SMTPS) that was used
10867 before the \\STARTTLS\\ command was standardized for SMTP. Some legacy clients
10868 still use this protocol. If the \tls@_on@_connect@_ports\ option is set to a
10869 list of port numbers, connections to those ports must use SSMTP. The most
10870 common use of this option is expected to be
10871 .display asis
10872 tls_on_connect_ports = 465
10873 .endd
10874 because 465 is the usual port number used by the legacy clients. There is also
10875 a command line option \-tls-on-connect-\, which forces all ports to behave in
10876 this way when a daemon is started.
10877
10878 \**Warning**\: Setting \tls@_on@_connect@_ports\ does not of itself cause the 
10879 daemon to listen on those ports. You must still specify them in 
10880 \daemon@_smtp@_ports\, \local@_interfaces\, or the \-oX-\ option. (This is
10881 because \tls@_on@_connect@_ports\ applies to \inetd\ connections as well as to
10882 connections via the daemon.)
10883 .nem
10884
10885
10886 .section IPv6 address scopes
10887 IPv6 addresses have `scopes', and a host with multiple hardware interfaces
10888 can, in principle, have the same link-local IPv6 address on different
10889 interfaces. Thus, additional information is needed, over and above the IP
10890 address, to distinguish individual interfaces. A convention of using a
10891 percent sign followed by something (often the interface name) has been
10892 adopted in some cases, leading to addresses like this:
10893 .display asis
10894 fe80::202:b3ff:fe03:45c1%eth0
10895 .endd
10896 To accommodate this usage, a percent sign followed by an arbitrary string is
10897 allowed at the end of an IPv6 address. By default, Exim calls \*getaddrinfo()*\
10898 to convert a textual IPv6 address for actual use. This function recognizes the
10899 percent convention in operating systems that support it, and it processes the
10900 address appropriately. Unfortunately, some older libraries have problems with
10901 \*getaddrinfo()*\. If
10902 .display asis
10903 IPV6_USE_INET_PTON=yes
10904 .endd
10905 is set in \(Local/Makefile)\ (or an OS-dependent Makefile) when Exim is built,
10906 Exim uses \*inet@_pton()*\ to convert a textual IPv6 address for actual use,
10907 instead of \*getaddrinfo()*\. (Before version 4.14, it always used this
10908 function.) Of course, this means that the additional functionality of
10909 \*getaddrinfo()*\ -- recognizing scoped addresses -- is lost.
10910
10911
10912 .section Examples of starting a listening daemon
10913 The default case in an IPv6 environment is
10914 .display asis
10915 daemon_smtp_ports = smtp
10916 local_interfaces = <; ::0 ; 0.0.0.0
10917 .endd
10918 This specifies listening on the smtp port on all IPv6 and IPv4 interfaces.
10919 Either one or two sockets may be used, depending on the characteristics of
10920 the TCP/IP stack. (This is complicated and messy; for more information,
10921 read the comments in the \(daemon.c)\ source file.)
10922
10923 To specify listening on ports 25 and 26 on all interfaces:
10924 .display asis
10925 daemon_smtp_ports = 25 : 26
10926 .endd
10927 (leaving \local@_interfaces\ at the default setting) or, more explicitly:
10928 .display asis
10929 local_interfaces = <; ::0.25     ; ::0.26 \
10930                       0.0.0.0.25 ; 0.0.0.0.26
10931 .endd
10932 To listen on the default port on all IPv4 interfaces, and on port 26 on the
10933 IPv4 loopback address only:
10934 .display asis
10935 local_interfaces = 0.0.0.0 : 127.0.0.1.26
10936 .endd
10937 To specify listening on the default port on specific interfaces only:
10938 .display asis
10939 local_interfaces = 192.168.34.67 : 192.168.34.67
10940 .endd
10941 \**Warning**\: such a setting excludes listening on the loopback interfaces.
10942
10943
10944 .section Recognising the local host
10945 .rset SECTreclocipadd "~~chapter.~~section"
10946 The \local@_interfaces\ option is also used when Exim needs to determine
10947 whether or not an IP address refers to the local host. That is, the IP
10948 addresses of all the interfaces on which a daemon is listening are always
10949 treated as local.
10950
10951 For this usage, port numbers in \local@_interfaces\ are ignored. If either of
10952 the items 0.0.0.0 or @:@:0 are encountered, Exim gets a complete list of
10953 available interfaces from the operating system, and extracts the relevant
10954 (that is, IPv4 or IPv6) addresses to use for checking.
10955
10956 Some systems set up large numbers of virtual interfaces in order to provide
10957 many virtual web servers. In this situation, you may want to listen for
10958 email on only a few of the available interfaces, but nevertheless treat all
10959 interfaces as local when routing. You can do this by setting
10960 \extra@_local@_interfaces\ to a list of IP addresses, possibly including the
10961 `all' wildcard values. These addresses are recognized as local, but are not
10962 used for listening. Consider this example:
10963 .display asis
10964 local_interfaces = <; 127.0.0.1 ; ::1 ; \
10965                       192.168.53.235 ; \
10966                       3ffe:2101:12:1:a00:20ff:fe86:a061
10967
10968 extra_local_interfaces = <; ::0 ; 0.0.0.0
10969 .endd
10970 The daemon listens on the loopback interfaces and just one IPv4 and one IPv6
10971 address, but all available interface addresses are treated as local when
10972 Exim is routing.
10973
10974 In some environments the local host name may be in an MX list, but with an IP
10975 address that is not assigned to any local interface. In other cases it may be
10976 desirable to treat other host names as if they referred to the local host. Both
10977 these cases can be handled by setting the \hosts@_treat@_as@_local\ option.
10978 This contains host names rather than IP addresses. When a host is referenced
10979 during routing, either via an MX record or directly, it is treated as the local
10980 host if its name matches \hosts@_treat@_as@_local\, or if any of its IP
10981 addresses match \local@_interfaces\ or \extra@_local@_interfaces\.
10982
10983
10984 .section Delivering to a remote host
10985 Delivery to a remote host is handled by the smtp transport. By default, it
10986 allows the system's TCP/IP functions to choose which interface to use (if
10987 there is more than one) when connecting to a remote host. However, the
10988 \interface\ option can be set to specify which interface is used. See the
10989 description of the smtp transport in chapter ~~CHAPsmtptrans for more details.
10990
10991
10992
10993
10994 .
10995 .
10996 .
10997 .
10998 . ============================================================================
10999 .chapter Main configuration
11000 .set runningfoot "main configuration"
11001 .rset CHAPmainconfig "~~chapter"
11002 .index configuration file||main section
11003 .index main configuration
11004 The first part of the run time configuration file contains three types of item:
11005 .numberpars $.
11006 Macro definitions: These lines start with an upper case letter. See section
11007 ~~SECTmacrodefs for details of macro processing.
11008 .nextp
11009 Named list definitions: These lines start with one of the words `domainlist',
11010 `hostlist', `addresslist', or `localpartlist'. Their use is described in
11011 section ~~SECTnamedlists.
11012 .nextp
11013 Main configuration settings: Each setting occupies one line of the file
11014 (with possible continuations). If any setting is preceded by the word
11015 `hide', the \-bP-\ command line option displays its value to admin users only.
11016 See section ~~SECTcos for a description of the syntax of these option settings.
11017 .endp
11018 This chapter specifies all the main configuration options, along with their
11019 types and default values. For ease of finding a particular option, they appear
11020 in alphabetical order in section ~~SECTalomo below. However, because there are
11021 now so many options, they are first listed briefly in functional groups, as an
11022 aid to finding the name of the option you are looking for. Some options are
11023 listed in more than one group.
11024
11025 .set savedisplayflowcheck ~~displayflowcheck
11026 .set displayflowcheck 0
11027
11028 .section Miscellaneous
11029 .display flow rm
11030 .tabs 31
11031 \bi@_command\                           $t$rm{to run for \-bi-\ command line option}
11032 \keep@_malformed\                       $t$rm{for broken files -- should not happen}
11033 \localhost@_number\                     $t$rm{for unique message ids in clusters}
11034 \message@_body@_visible\                $t$rm{how much to show in \$message@_body$\}
11035 .newline
11036 .em
11037 \mua@_wrapper\                          $t$rm{run in `MUA wrapper' mode}
11038 .nem
11039 .newline
11040 \print@_topbitchars\                    $t$rm{top-bit characters are printing}
11041 \timezone\                              $t$rm{force time zone}
11042 .endd
11043
11044 .section Exim parameters
11045 .display flow rm
11046 .tabs 31
11047 \exim@_group\                           $t$rm{override compiled-in value}
11048 \exim@_path\                            $t$rm{override compiled-in value}
11049 \exim@_user\                            $t$rm{override compiled-in value}
11050 \primary@_hostname\                     $t$rm{default from \*uname()*\}
11051 \split@_spool@_directory\               $t$rm{use multiple directories}
11052 \spool@_directory\                      $t$rm{override compiled-in value}
11053 .endd
11054
11055 .section Privilege controls
11056 .display flow rm
11057 .tabs 31
11058 \admin@_groups\                         $t$rm{groups that are Exim admin users}
11059 \deliver@_drop@_privilege\              $t$rm{drop root for delivery processes}
11060 \local@_from@_check\                    $t$rm{insert ::Sender:: if necessary}
11061 \local@_from@_prefix\                   $t$rm{for testing ::From:: for local sender}
11062 \local@_from@_suffix\                   $t$rm{for testing ::From:: for local sender}
11063 \local@_sender@_retain\                 $t$rm{keep ::Sender:: from untrusted user}
11064 \never@_users\                          $t$rm{do not run deliveries as these}
11065 \prod@_requires@_admin\                 $t$rm{forced delivery requires admin user}
11066 \queue@_list@_requires@_admin\          $t$rm{queue listing requires admin user}
11067 \trusted@_groups\                       $t$rm{groups that are trusted}
11068 \trusted@_users\                        $t$rm{users that are trusted}
11069 .endd
11070
11071 .section Logging
11072 .display flow rm
11073 .tabs 31
11074 .em
11075 \hosts@_connection@_nolog\              $t$rm{exemption from connect logging}
11076 .nem
11077 .newline
11078 \log@_file@_path\                       $t$rm{override compiled-in value}
11079 \log@_selector\                         $t$rm{set/unset optional logging}
11080 \log@_timezone\                         $t$rm{add timezone to log lines}
11081 \message@_logs\                         $t$rm{create per-message logs}
11082 \preserve@_message@_logs\               $t$rm{after message completion}
11083 \process@_log@_path\                    $t$rm{for SIGUSR1 and \*exiwhat*\}
11084 \syslog@_duplication\                   $t$rm{controls duplicate log lines on syslog }
11085 \syslog@_facility\                      $t$rm{set syslog `facility' field}
11086 \syslog@_processname\                   $t$rm{set syslog `ident' field}
11087 \syslog@_timestamp\                     $t$rm{timestamp syslog lines}
11088 .newline
11089 \write@_rejectlog\                      $t$rm{control use of message log}
11090 .newline
11091 .endd
11092
11093 .section Frozen messages
11094 .display flow rm
11095 .tabs 31
11096 \auto@_thaw\                            $t$rm{sets time for retrying frozen messages}
11097 \freeze@_tell\                          $t$rm{send message when freezing}
11098 \move@_frozen@_messages\                $t$rm{to another directory}
11099 \timeout@_frozen@_after\                $t$rm{keep frozen messages only so long}
11100 .endd
11101
11102 .section Data lookups
11103 .display flow rm
11104 .tabs 31
11105 \ldap@_default@_servers\                $t$rm{used if no server in query}
11106 \ldap@_version\                         $t$rm{set protocol version}
11107 \lookup@_open@_max\                     $t$rm{lookup files held open}
11108 \mysql@_servers\                        $t$rm{as it says}
11109 \oracle@_servers\                       $t$rm{as it says}
11110 \pgsql@_servers\                        $t$rm{as it says}
11111 .endd
11112
11113 .section Message ids
11114 .display flow rm
11115 .tabs 31
11116 \message@_id@_header@_domain\           $t$rm{used to build ::Message-ID:: header}
11117 \message@_id@_header@_text\             $t$rm{ditto}
11118 .endd
11119
11120 .section Embedded Perl Startup
11121 .display flow rm
11122 .tabs 31
11123 \perl@_at@_start\                       $t$rm{always start the interpreter}
11124 \perl@_startup\                         $t$rm{code to obey when starting Perl}
11125 .endd
11126
11127 .section Daemon
11128 .display flow rm
11129 .tabs 31
11130 \daemon@_smtp@_ports\                   $t$rm{default ports}
11131 \extra@_local@_interfaces\              $t$rm{not necessarily listened on}
11132 \local@_interfaces\                     $t$rm{on which to listen, with optional ports}
11133 \pid@_file@_path\                       $t$rm{override compiled-in value}
11134 \queue@_run@_max\                       $t$rm{maximum simultaneous queue runners}
11135 .endd
11136
11137 .section Resource control
11138 .display flow rm
11139 .tabs 31
11140 \check@_log@_inodes\                    $t$rm{before accepting a message}
11141 \check@_log@_space\                     $t$rm{before accepting a message}
11142 \check@_spool@_inodes\                  $t$rm{before accepting a message}
11143 \check@_spool@_space\                   $t$rm{before accepting a message}
11144 \deliver@_queue@_load@_max\             $t$rm{no queue deliveries if load high}
11145 \queue@_only@_load\                     $t$rm{queue incoming if load high}
11146 \queue@_run@_max\                       $t$rm{maximum simultaneous queue runners}
11147 \remote@_max@_parallel\                 $t$rm{parallel SMTP delivery per message}
11148 \smtp@_accept@_max\                     $t$rm{simultaneous incoming connections}
11149 \smtp@_accept@_max@_nommail\            $t$rm{non-mail commands}
11150 \smtp@_accept@_max@_nonmail@_hosts\     $t$rm{hosts to which the limit applies}
11151 \smtp@_accept@_max@_per@_connection\    $t$rm{messages per connection}
11152 \smtp@_accept@_max@_per@_host\          $t$rm{connections from one host}
11153 \smtp@_accept@_queue\                   $t$rm{queue mail if more connections}
11154 \smtp@_accept@_queue@_per@_connection\  $t$rm{queue if more messages per connection}
11155 \smtp@_accept@_reserve\                 $t$rm{only reserve hosts if more connections}
11156 \smtp@_check@_spool@_space\             $t$rm{from \\SIZE\\ on \\MAIL\\ command}
11157 \smtp@_connect@_backlog\                $t$rm{passed to TCP/IP stack}
11158 \smtp@_load@_reserve\                   $t$rm{SMTP from reserved hosts if load high}
11159 \smtp@_reserve@_hosts\                  $t$rm{these are the reserve hosts}
11160 .endd
11161
11162 .section Policy controls
11163 .display flow rm
11164 .tabs 31
11165 \acl@_not@_smtp\                        $t$rm{set ACL for non-SMTP messages}
11166 \acl@_smtp@_auth\                       $t$rm{set ACL for \\AUTH\\}
11167 \acl@_smtp@_connect\                    $t$rm{set ACL for connection}
11168 \acl@_smtp@_data\                       $t$rm{set ACL for \\DATA\\}
11169 \acl@_smtp@_etrn\                       $t$rm{set ACL for \\ETRN\\}
11170 \acl@_smtp@_expn\                       $t$rm{set ACL for \\EXPN\\}
11171 \acl@_smtp@_helo\                       $t$rm{set ACL for \\EHLO\\ or \\HELO\\}
11172 \acl@_smtp@_mail\                       $t$rm{set ACL for \\MAIL\\}
11173 \acl@_smtp@_mailauth\                   $t$rm{set ACL for \\AUTH\\ on \\MAIL\\ command}
11174 .newline
11175 .em
11176 \acl@_smtp@_mime\                       $t$rm{set ACL for MIME parts}
11177 \acl@_smtp@_predata\                    $t$rm{set ACL for start of data}
11178 \acl@_smtp@_quit\                       $t$rm{set ACL for \\QUIT\\}
11179 .nem
11180 .newline
11181 \acl@_smtp@_rcpt\                       $t$rm{set ACL for \\RCPT\\}
11182 \acl@_smtp@_starttls\                   $t$rm{set ACL for \\STARTTLS\\}
11183 \acl@_smtp@_vrfy\                       $t$rm{set ACL for \\VRFY\\}
11184 .newline
11185 .em
11186 \av@_scanner\                           $t$rm{specify virus scanner}
11187 .nem
11188 .newline
11189 \header@_maxsize\                       $t$rm{total size of message header}
11190 \header@_line@_maxsize\                 $t$rm{individual header line limit}
11191 \helo@_accept@_junk@_hosts\             $t$rm{allow syntactic junk from these hosts}
11192 \helo@_allow@_chars\                    $t$rm{allow illegal chars in \\HELO\\ names}
11193 \helo@_lookup@_domains\                 $t$rm{lookup hostname for these \\HELO\\ names}
11194 \helo@_try@_verify@_hosts\              $t$rm{\\HELO\\ soft-checked for these hosts}
11195 \helo@_verify@_hosts\                   $t$rm{\\HELO\\ hard-checked for these hosts}
11196 \host@_lookup\                          $t$rm{host name looked up for these hosts}
11197 \host@_lookup@_order\                   $t$rm{order of DNS and local name lookups}
11198 \host@_reject@_connection\              $t$rm{reject connection from these hosts}
11199 \hosts@_treat@_as@_local\               $t$rm{useful in some cluster configurations}
11200 \local@_scan@_timeout\                  $t$rm{timeout for \*local@_scan()*\}
11201 \message@_size@_limit\                  $t$rm{for all messages}
11202 \percent@_hack@_domains\                $t$rm{recognize %-hack for these domains}
11203 .newline
11204 .em
11205 \spamd@_address\                        $t$rm{set interface to SpamAssassin}
11206 .nem
11207 .newline
11208 .endd
11209
11210 .section Callout cache
11211 .display flow rm
11212 .tabs 31
11213 \callout@_domain@_negative@_expire\     $t$rm{timeout for negative domain cache item}
11214 \callout@_domain@_positive@_expire\     $t$rm{timeout for positive domain cache item}
11215 \callout@_negative@_expire\             $t$rm{timeout for negative address cache item}
11216 \callout@_positive@_expire\             $t$rm{timeout for positive address cache item}
11217 \callout@_random@_local@_part\          $t$rm{string to use for `random' testing}
11218 .endd
11219
11220 .section TLS
11221 .display flow rm
11222 .tabs 31
11223 \tls@_advertise@_hosts\                 $t$rm{advertise TLS to these hosts}
11224 \tls@_certificate\                      $t$rm{location of server certificate}
11225 \tls@_crl\                              $t$rm{certificate revocation list}
11226 \tls@_dhparam\                          $t$rm{DH parameters for server}
11227 .newline
11228 .em
11229 \tls@_on@_connect@_ports\               $t$rm{specify SSMTP (SMTPS) ports}
11230 .nem
11231 .newline
11232 \tls@_privatekey\                       $t$rm{location of server private key}
11233 \tls@_remember@_esmtp\                  $t$rm{don't reset after starting TLS}
11234 \tls@_require@_ciphers\                 $t$rm{specify acceptable cipers}
11235 \tls@_try@_verify@_hosts\               $t$rm{try to verify client certificate}
11236 \tls@_verify@_certificates\             $t$rm{expected client certificates}
11237 \tls@_verify@_hosts\                    $t$rm{insist on client certificate verify}
11238 .endd
11239
11240 .section Local user handling
11241 .display flow rm
11242 .tabs 31
11243 \finduser@_retries\                     $t$rm{useful in NIS environments}
11244 \gecos@_name\                           $t$rm{used when creating ::Sender::}
11245 \gecos@_pattern\                        $t$rm{ditto}
11246 \max@_username@_length\                 $t$rm{for systems that truncate}
11247 \unknown@_login\                        $t$rm{used when no login name found}
11248 \unknown@_username\                     $t$rm{ditto}
11249 \uucp@_from@_pattern\                   $t$rm{for recognizing `From ' lines}
11250 \uucp@_from@_sender\                    $t$rm{ditto}
11251 .endd
11252
11253 .section All incoming messages (SMTP and non-SMTP)
11254 .display flow rm
11255 .tabs 31
11256 \header@_maxsize\                       $t$rm{total size of message header}
11257 \header@_line@_maxsize\                 $t$rm{individual header line limit}
11258 \message@_size@_limit\                  $t$rm{applies to all messages}
11259 \percent@_hack@_domains\                $t$rm{recognize %-hack for these domains}
11260 \received@_header@_text\                $t$rm{expanded to make ::Received::}
11261 \received@_headers@_max\                $t$rm{for mail loop detection}
11262 \recipients@_max\                       $t$rm{limit per message}
11263 \recipients@_max@_reject\               $t$rm{permanently reject excess}
11264 .endd
11265
11266
11267 .section Non-SMTP incoming messages
11268 .display rm
11269 .tabs 31
11270 \receive@_timeout\                      $t$rm{for non-SMTP messages}
11271 .endd
11272
11273
11274
11275 .section Incoming SMTP messages
11276 See also the \*Policy controls*\ section above.
11277 .display flow rm
11278 .tabs 31
11279 \host@_lookup\                          $t$rm{host name looked up for these hosts}
11280 \host@_lookup@_order\                   $t$rm{order of DNS and local name lookups}
11281 \recipient@_unqualified@_hosts\         $t$rm{may send unqualified recipients}
11282 \rfc1413@_hosts\                        $t$rm{make ident calls to these hosts}
11283 \rfc1413@_query@_timeout\               $t$rm{zero disables ident calls}
11284 \sender@_unqualified@_hosts\            $t$rm{may send unqualified senders}
11285 \smtp@_accept@_keepalive\               $t$rm{some TCP/IP magic}
11286 \smtp@_accept@_max\                     $t$rm{simultaneous incoming connections}
11287 \smtp@_accept@_max@_nommail\            $t$rm{non-mail commands}
11288 \smtp@_accept@_max@_nonmail@_hosts\     $t$rm{hosts to which the limit applies}
11289 \smtp@_accept@_max@_per@_connection\    $t$rm{messages per connection}
11290 \smtp@_accept@_max@_per@_host\          $t$rm{connections from one host}
11291 \smtp@_accept@_queue\                   $t$rm{queue mail if more connections}
11292 \smtp@_accept@_queue@_per@_connection\  $t$rm{queue if more messages per connection}
11293 \smtp@_accept@_reserve\                 $t$rm{only reserve hosts if more connections}
11294 .newline
11295 \smtp@_active@_hostname\                $t$rm{host name to use in messages}
11296 .newline
11297 \smtp@_banner\                          $t$rm{text for welcome banner}
11298 \smtp@_check@_spool@_space\             $t$rm{from \\SIZE\\ on \\MAIL\\ command}
11299 \smtp@_connect@_backlog\                $t$rm{passed to TCP/IP stack}
11300 \smtp@_enforce@_sync\                   $t$rm{of SMTP command/responses}
11301 \smtp@_etrn@_command\                   $t$rm{what to run for \\ETRN\\}
11302 \smtp@_etrn@_serialize\                 $t$rm{only one at once}
11303 \smtp@_load@_reserve\                   $t$rm{only reserve hosts if this load}
11304 \smtp@_max@_unknown@_commands\          $t$rm{before dropping connection}
11305 \smtp@_ratelimit@_hosts\                $t$rm{apply ratelimiting to these hosts}
11306 \smtp@_ratelimit@_mail\                 $t$rm{ratelimit for \\MAIL\\ commands}
11307 \smtp@_ratelimit@_rcpt\                 $t$rm{ratelimit for \\RCPT\\ commands}
11308 \smtp@_receive@_timeout\                $t$rm{per command or data line}
11309 \smtp@_reserve@_hosts\                  $t$rm{these are the reserve hosts}
11310 \smtp@_return@_error@_details\          $t$rm{give detail on rejections}
11311 .endd
11312
11313 .section SMTP extensions
11314 .display flow rm
11315 .tabs 31
11316 \accept@_8bitmime\                      $t$rm{advertise \\8BITMIME\\}
11317 \auth@_advertise@_hosts\                $t$rm{advertise \\AUTH\\ to these hosts}
11318 \ignore@_fromline@_hosts\               $t$rm{allow `From ' from these hosts}
11319 \ignore@_fromline@_local\               $t$rm{allow `From ' from local SMTP}
11320 \pipelining@_advertise@_hosts\          $t$rm{advertise pipelining to these hosts}
11321 \tls@_advertise@_hosts\                 $t$rm{advertise TLS to these hosts}
11322 .endd
11323
11324 .section Processing messages
11325 .display flow rm
11326 .tabs 31
11327 \allow@_domain@_literals\               $t$rm{recognize domain literal syntax}
11328 \allow@_mx@_to@_ip\                     $t$rm{allow MX to point to IP address}
11329 \allow@_utf8@_domains\                  $t$rm{in addresses}
11330 \delivery@_date@_remove\                $t$rm{from incoming messages}
11331 \envelope@_to@_remote\                  $t$rm{from incoming messages}
11332 \extract@_addresses@_remove@_arguments\ $t$rm{affects \-t-\ processing}
11333 \headers@_charset\                      $t$rm{default for translations}
11334 \qualify@_domain\                       $t$rm{default for senders}
11335 \qualify@_recipient\                    $t$rm{default for recipients}
11336 \return@_path@_remove\                  $t$rm{from incoming messages}
11337 \strip@_excess@_angle@_brackets\        $t$rm{in addresses}
11338 \strip@_trailing@_dot\                  $t$rm{at end of addresses}
11339 \untrusted@_set@_sender\                $t$rm{untrusted can set envelope sender}
11340 .endd
11341
11342 .section System filter
11343 .display flow rm
11344 .tabs 31
11345 \system@_filter\                        $t$rm{locate system filter}
11346 \system@_filter@_directory@_transport\  $t$rm{transport for delivery to a directory}
11347 \system@_filter@_file@_transport\       $t$rm{transport for delivery to a file}
11348 \system@_filter@_group\                 $t$rm{group for filter running}
11349 \system@_filter@_pipe@_transport\       $t$rm{transport for delivery to a pipe}
11350 \system@_filter@_reply@_transport\      $t$rm{transport for autoreply delivery}
11351 \system@_filter@_user\                  $t$rm{user for filter running}
11352 .endd
11353
11354 .section Routing and delivery
11355 .display flow rm
11356 .tabs 31
11357 \dns@_again@_means@_nonexist\           $t$rm{for broken domains}
11358 \dns@_check@_names@_pattern\            $t$rm{pre-DNS syntax check}
11359 \dns@_ipv4@_lookup\                     $t$rm{only v4 lookup for these domains}
11360 \dns@_retrans\                          $t$rm{parameter for resolver}
11361 \dns@_retry\                            $t$rm{parameter for resolver}
11362 \hold@_domains\                         $t$rm{hold delivery for these domains}
11363 \local@_interfaces\                     $t$rm{for routing checks}
11364 \queue@_domains\                        $t$rm{no immediate delivery for these}
11365 \queue@_only\                           $t$rm{no immediate delivery at all}
11366 \queue@_only@_file\                     $t$rm{no immediate deliveryif file exists}
11367 \queue@_only@_load\                     $t$rm{no immediate delivery if load is high}
11368 \queue@_only@_override\                 $t$rm{allow command line to override}
11369 \queue@_run@_in@_order\                 $t$rm{order of arrival}
11370 \queue@_run@_max\                       $t$rm{of simultaneous queue runners}
11371 \queue@_smtp@_domains\                  $t$rm{no immediate SMTP delivery for these}
11372 \remote@_max@_parallel\                 $t$rm{parallel SMTP delivery per message}
11373 \remote@_sort@_domains\                 $t$rm{order of remote deliveries}
11374 \retry@_data@_expire\                   $t$rm{timeout for retry data}
11375 \retry@_interval@_max\                  $t$rm{safety net for retry rules}
11376 .endd
11377
11378 .section Bounce and warning messages
11379 .display flow rm
11380 .tabs 31
11381 \bounce@_message@_file\                 $t$rm{content of bounce}
11382 \bounce@_message@_text\                 $t$rm{content of bounce}
11383 \bounce@_return@_body\                  $t$rm{include body if returning message}
11384 \bounce@_return@_message\               $t$rm{include original message in bounce}
11385 \bounce@_return@_size@_limit\           $t$rm{limit on returned message}
11386 \bounce@_sender@_authentication\        $t$rm{send authenticated sender with bounce}
11387 \errors@_copy\                          $t$rm{copy bounce messages}
11388 \errors@_reply@_to\                     $t$rm{::Reply-to:: in bounces}
11389 \delay@_warning\                        $t$rm{time schedule}
11390 \delay@_warning@_condition\             $t$rm{condition for warning messages}
11391 \ignore@_bounce@_errors@_after\         $t$rm{discard undeliverable bounces}
11392 \warn@_message@_file\                   $t$rm{content of warning message}
11393 .endd
11394
11395 .set displayflowcheck ~~savedisplayflowcheck
11396
11397 .section Alphabetical list of main options
11398 .rset SECTalomo "~~chapter.~~section"
11399 .if ~~sgcal
11400 Those options that undergo string expansion before use are marked with $**$.
11401 .fi
11402
11403 .startconf main
11404
11405 .index \\8BITMIME\\
11406 .index 8-bit characters
11407 .conf accept@_8bitmime boolean false
11408 This option causes Exim to send \\8BITMIME\\ in its response to an SMTP
11409 \\EHLO\\ command, and to accept the \\BODY=\\ parameter on \\MAIL\\ commands.
11410 However, though Exim is 8-bit clean, it is not a protocol converter, and it
11411 takes no steps to do anything special with messages received by this route.
11412 Consequently, this option is turned off by default.
11413
11414 .index ~~ACL||for non-SMTP messages
11415 .index non-SMTP messages, ACL for
11416 .conf acl@_not@_smtp string$**$ unset
11417 This option defines the ACL that is run when a non-SMTP message is on the point
11418 of being accepted. See chapter ~~CHAPACL for further details.
11419
11420 .index ~~ACL||setting up for SMTP commands
11421 .index \\AUTH\\||ACL for
11422 .conf acl@_smtp@_auth string$**$ unset
11423 This option defines the ACL that is run when an SMTP \\AUTH\\ command is
11424 received. See chapter ~~CHAPACL for further details.
11425
11426 .index ~~ACL||on SMTP connection
11427 .conf acl@_smtp@_connect string$**$ unset
11428 This option defines the ACL that is run when an SMTP connection is received.
11429 See chapter ~~CHAPACL for further details.
11430
11431 .index \\DATA\\, ACL for
11432 .conf acl@_smtp@_data string$**$ unset
11433 This option defines the ACL that is run after an SMTP \\DATA\\ command has been
11434 processed and the message itself has been received, but before the final
11435 acknowledgement is sent. See chapter ~~CHAPACL for further details.
11436
11437 .index \\ETRN\\||ACL for
11438 .conf acl@_smtp@_etrn string$**$ unset
11439 This option defines the ACL that is run when an SMTP \\ETRN\\ command is
11440 received. See chapter ~~CHAPACL for further details.
11441
11442 .index \\EXPN\\||ACL for
11443 .conf acl@_smtp@_expn string$**$ unset
11444 This option defines the ACL that is run when an SMTP \\EXPN\\ command is
11445 received. See chapter ~~CHAPACL for further details.
11446
11447 .index \\EHLO\\||ACL for
11448 .index \\HELO\\||ACL for
11449 .conf acl@_smtp@_helo string$**$ unset
11450 This option defines the ACL that is run when an SMTP \\EHLO\\ or \\HELO\\
11451 command is received. See chapter ~~CHAPACL for further details.
11452
11453 .index \\MAIL\\||ACL for
11454 .conf acl@_smtp@_mail string$**$ unset
11455 This option defines the ACL that is run when an SMTP \\MAIL\\ command is
11456 received. See chapter ~~CHAPACL for further details.
11457
11458 .index \\AUTH\\||on \\MAIL\\ command
11459 .conf acl@_smtp@_mailauth string$**$ unset
11460 This option defines the ACL that is run when there is an \\AUTH\\ parameter on
11461 a \\MAIL\\ command. See chapter ~~CHAPACL for details of ACLs, and chapter
11462 ~~CHAPSMTPAUTH for details of authentication.
11463
11464 .em
11465 .index MIME content scanning||ACL for
11466 .conf acl@_smtp@_mime string$**$ unset
11467 This option is available when Exim is built with the content-scanning 
11468 extension. It defines the ACL that is run for each MIME part in a message. See 
11469 section ~~SECTscanmimepart for details.
11470
11471 .conf acl@_smtp@_predata string$**$ unset
11472 This option defines the ACL that is run when an SMTP \\DATA\\ command is
11473 received, before the message itself is received. See chapter ~~CHAPACL for
11474 further details.
11475
11476 .index \\QUIT\\||ACL for
11477 .conf acl@_smtp@_quit string$**$ unset
11478 This option defines the ACL that is run when an SMTP \\QUIT\\ command is
11479 received. See chapter ~~CHAPACL for further details.
11480 .nem
11481
11482 .index \\RCPT\\||ACL for
11483 .conf acl@_smtp@_rcpt string$**$ unset
11484 This option defines the ACL that is run when an SMTP \\RCPT\\ command is
11485 received. See chapter ~~CHAPACL for further details.
11486
11487 .index \\STARTTLS\\, ACL for
11488 .conf acl@_smtp@_starttls string$**$ unset
11489 This option defines the ACL that is run when an SMTP \\STARTTLS\\ command is
11490 received. See chapter ~~CHAPACL for further details.
11491
11492 .index \\VRFY\\||ACL for
11493 .conf acl@_smtp@_vrfy string$**$ unset
11494 This option defines the ACL that is run when an SMTP \\VRFY\\ command is
11495 received. See chapter ~~CHAPACL for further details.
11496
11497 .conf admin@_groups "string list" unset
11498 .index admin user
11499 If the current group or any of the supplementary groups of the caller is in
11500 this colon-separated list, the caller has admin privileges. If all your system
11501 programmers are in a specific group, for example, you can give them all Exim
11502 admin privileges by putting that group in \admin@_groups\. However, this does
11503 not permit them to read Exim's spool files (whose group owner is the Exim gid).
11504 To permit this, you have to add individuals to the Exim group.
11505
11506 .conf allow@_domain@_literals boolean false
11507 .index domain literal
11508 If this option is set, the RFC 2822 domain literal format is permitted in
11509 email addresses. The option is not set by default, because the domain literal
11510 format is not normally required these days, and few people know about it. It
11511 has, however, been exploited by mail abusers.
11512
11513 Unfortunately, it seems that some DNS black list maintainers are using this
11514 format to report black listing to postmasters. If you want to accept messages
11515 addressed to your hosts by IP address, you need to set
11516 \allow@_domain@_literals\ true, and also to add \"@@[]"\ to the list of local
11517 domains (defined in the named domain list \local@_domains\ in the default
11518 configuration). This `magic string' matches the domain literal form of all the
11519 local host's IP addresses.
11520
11521 .conf allow@_mx@_to@_ip boolean false
11522 .index MX record||pointing to IP address
11523 It appears that more and more DNS zone administrators are breaking the rules
11524 and putting domain names that look like IP addresses on the right hand side of
11525 MX records. Exim follows the rules and rejects this, giving an error message
11526 that explains the mis-configuration. However, some other MTAs support this
11527 practice, so to avoid `Why can't Exim do this?' complaints, \allow@_mx@_to@_ip\
11528 exists, in order to enable this heinous activity. It is not recommended, except
11529 when you have no other choice.
11530
11531 .index domain||UTF-8 characters in
11532 .index UTF-8||in domain name
11533 .conf allow@_utf8@_domains boolean false
11534 Lots of discussion is going on about internationalized domain names. One
11535 camp is strongly in favour of just using UTF-8 characters, and it seems
11536 that at least two other MTAs permit this. This option allows Exim users to
11537 experiment if they wish.
11538
11539 If it is set true, Exim's domain parsing function allows valid
11540 UTF-8 multicharacters to appear in domain name components, in addition to
11541 letters, digits, and hyphens. However, just setting this option is not
11542 enough; if you want to look up these domain names in the DNS, you must also
11543 adjust the value of \dns@_check@_names@_pattern\ to match the extended form. A
11544 suitable setting is:
11545 .display asis
11546 dns_check_names_pattern = (?i)^(?>(?(1)\.|())[a-z0-9\xc0-\xff]\
11547   (?>[-a-z0-9\x80-\xff]*[a-z0-9\x80-\xbf])?)+$
11548 .endd
11549 Alternatively, you can just disable this feature by setting
11550 .display asis
11551 dns_check_names_pattern =
11552 .endd
11553 That is, set the option to an empty string so that no check is done.
11554
11555 .conf auth@_advertise@_hosts "host list$**$" $*$
11556 .index authentication||advertising
11557 .index \\AUTH\\||advertising
11558 If any server authentication mechanisms are configured, Exim advertises them in
11559 response to an \\EHLO\\ command only if the calling host matches this list.
11560 Otherwise, Exim does not advertise \\AUTH\\.
11561 Exim does not accept \\AUTH\\ commands from clients to which it has not
11562 advertised the availability of \\AUTH\\. The advertising of individual
11563 authentication mechanisms can be controlled by the use of the
11564 \server@_advertise@_condition\ generic authenticator option on the individual
11565 authenticators. See chapter ~~CHAPSMTPAUTH for further details.
11566
11567 Certain mail clients (for example, Netscape) require the user to provide a name
11568 and password for authentication if \\AUTH\\ is advertised, even though it may
11569 not be needed (the host may accept messages from hosts on its local LAN without
11570 authentication, for example). The \auth@_advertise@_hosts\ option can be used
11571 to make these clients more friendly by excluding them from the set of hosts to
11572 which Exim advertises \\AUTH\\.
11573
11574 .index \\AUTH\\||advertising when encrypted
11575 If you want to advertise the availability of \\AUTH\\ only when the connection
11576 is encrypted using TLS, you can make use of the fact that the value of this
11577 option is expanded, with a setting like this:
11578 .display asis
11579 auth_advertise_hosts = ${if eq{$tls_cipher}{}{}{*}}
11580 .endd
11581 If \$tls@_cipher$\ is empty, the session is not encrypted, and the result of
11582 the expansion is empty, thus matching no hosts. Otherwise, the result of the
11583 expansion is $*$, which matches all hosts.
11584
11585 .conf auto@_thaw time 0s
11586 .index thawing messages
11587 .index unfreezing messages
11588 If this option is set to a time greater than zero, a queue runner will try a
11589 new delivery attempt on any frozen message if this much time has passed since
11590 it was frozen. This may result in the message being re-frozen if nothing has
11591 changed since the last attempt. It is a way of saying `keep on trying, even
11592 though there are big problems'. See also \timeout@_frozen@_after\ and
11593 \ignore@_bounce@_errors@_after\.
11594
11595 .em
11596 .conf av@_scanner string "see below"
11597 This option is available if Exim is built with the content-scanning extension.
11598 It specifies which anti-virus scanner to use. The default value is:
11599 .display asis
11600 sophie:/var/run/sophie
11601 .endd
11602 If the value of \av@_scanner\ starts with dollar character, it is expanded
11603 before use. See section ~~SECTscanvirus for further details.
11604 .nem
11605
11606 .conf bi@_command string unset
11607 .index \-bi-\ option
11608 This option supplies the name of a command that is run when Exim is called with
11609 the \-bi-\ option (see chapter ~~CHAPcommandline). The string value is just the
11610 command name, it is not a complete command line. If an argument is required, it
11611 must come from the \-oA-\ command line option.
11612
11613 .conf bounce@_message@_file string unset
11614 .index bounce message||customizing
11615 .index customizing||bounce message
11616 This option defines a template file containing paragraphs of text to be used
11617 for constructing bounce messages.  Details of the file's contents are given in
11618 chapter ~~CHAPemsgcust. See also \warn@_message@_file\.
11619
11620 .conf bounce@_message@_text string unset
11621 When this option is set, its contents are included in the default bounce
11622 message immediately after `This message was created automatically by mail
11623 delivery software.' It is not used if \bounce@_message@_file\ is set.
11624
11625 .index bounce message||including body
11626 .conf bounce@_return@_body boolean true
11627 This option controls whether the body of an incoming message is included in a
11628 bounce message when \bounce@_return@_message\ is true. If it is not set, only
11629 the message header is included.
11630
11631 .index bounce message||including original
11632 .conf bounce@_return@_message boolean true
11633 If this option is set false, the original message is not included in bounce
11634 messages generated by Exim. See also \bounce@_return@_size@_limit\.
11635
11636 .conf bounce@_return@_size@_limit integer 100K
11637 .index size||of bounce, limit
11638 .index bounce message||size limit
11639 .index limit||bounce message size
11640 This option sets a limit in bytes on the size of messages that are returned to
11641 senders as part of bounce messages when \bounce@_return@_message\ is true. The
11642 limit should be less than the value of the global \message@_size@_limit\ and of
11643 any \message@_size@_limit\ settings on transports, to allow for the bounce text
11644 that Exim generates. If this option is set to zero there is no limit.
11645
11646 When the body of any message that is to be included in a bounce message is
11647 greater than the limit, it is truncated, and a comment pointing this out is
11648 added at the top. The actual cutoff may be greater than the value given, owing
11649 to the use of buffering for transferring the message in chunks (typically 8K in
11650 size). The idea is to save bandwidth on those undeliverable 15-megabyte
11651 messages.
11652
11653 .index bounce message||sender authentication
11654 .index authentication||bounce message
11655 .index \\AUTH\\||on bounce message
11656 .conf bounce@_sender@_authentication string unset
11657 This option provides an authenticated sender address that is sent with any
11658 bounce messages generated by Exim that are sent over an authenticated SMTP
11659 connection. A typical setting might be:
11660 .display asis
11661 bounce_sender_authentication = mailer-daemon@my.domain.example
11662 .endd
11663 which would cause bounce messages to be sent using the SMTP command:
11664 .display asis
11665 MAIL FROM:<> AUTH=mailer-daemon@my.domain.example
11666 .endd
11667 The value of \bounce@_sender@_authentication\ must always be a complete email
11668 address.
11669
11670 .index caching||callout, timeouts
11671 .index callout||caching timeouts
11672 .conf callout@_domain@_negative@_expire time 3h
11673 This option specifies the expiry time for negative callout cache data for a
11674 domain. See section ~~SECTcallver for details of callout verification, and
11675 section ~~SECTcallvercache for details of the caching.
11676
11677 .conf callout@_domain@_positive@_expire time 7d
11678 This option specifies the expiry time for positive callout cache data for a
11679 domain. See section ~~SECTcallver for details of callout verification, and
11680 section ~~SECTcallvercache for details of the caching.
11681
11682 .conf callout@_negative@_expire time 2h
11683 This option specifies the expiry time for negative callout cache data for an
11684 address. See section ~~SECTcallver for details of callout verification, and
11685 section ~~SECTcallvercache for details of the caching.
11686
11687 .conf callout@_positive@_expire time 24h
11688 This option specifies the expiry time for positive callout cache data for an
11689 address. See section ~~SECTcallver for details of callout verification, and
11690 section ~~SECTcallvercache for details of the caching.
11691
11692 .conf callout@_random@_local@_part string$**$ "see below"
11693 This option defines the `random' local part that can be used as part of callout
11694 verification. The default value is
11695 .display asis
11696 $primary_host_name-$tod_epoch-testing
11697 .endd
11698 See section ~~CALLaddparcall for details of how this value is used.
11699
11700 .conf check@_log@_inodes integer 0
11701 See \check@_spool@_space\ below.
11702
11703 .conf check@_log@_space integer 0
11704 See \check@_spool@_space\ below.
11705
11706 .conf check@_spool@_inodes integer 0
11707 See \check@_spool@_space\ below.
11708
11709 .conf check@_spool@_space integer 0
11710 .index checking disk space
11711 .index disk space, checking
11712 .index spool directory||checking space
11713 The four \check@_...\ options allow for checking of disk resources before a
11714 message is accepted. 
11715 .em
11716 When any of these options are set, they apply to all incoming messages. If you 
11717 want to apply different checks to different kinds of message, you can do so 
11718 by testing the the variables \$log@_inodes$\, \$log@_space$\, 
11719 \$spool@_inodes$\, and \$spool@_space$\ in an ACL with appropriate additional
11720 conditions.
11721 .nem
11722
11723 \check@_spool@_space\ and \check@_spool@_inodes\ check the spool partition if
11724 either value is greater than zero, for example:
11725 .display asis
11726 check_spool_space = 10M
11727 check_spool_inodes = 100
11728 .endd
11729 The spool partition is the one that contains the directory defined by
11730 \\SPOOL@_DIRECTORY\\ in \(Local/Makefile)\. It is used for holding messages in
11731 transit.
11732
11733 \check@_log@_space\ and \check@_log@_inodes\  check the partition in which log
11734 files are written if either is greater than zero. These should be set only if
11735 \log@_file@_path\ and \spool@_directory\ refer to different partitions.
11736
11737 If there is less space or fewer inodes than requested, Exim refuses to accept
11738 incoming mail. In the case of SMTP input this is done by giving a 452 temporary
11739 error response to the \\MAIL\\ command. If ESMTP is in use and there was a
11740 \\SIZE\\ parameter on the \\MAIL\\ command, its value is added to the
11741 \check@_spool@_space\ value, and the check is performed even if
11742 \check@_spool@_space\ is zero, unless \no@_smtp@_check@_spool@_space\ is set.
11743
11744 The values for \check@_spool@_space\ and \check@_log@_space\ are held as a
11745 number of kilobytes. If a non-multiple of 1024 is specified, it is rounded up.
11746
11747 For non-SMTP input and for batched SMTP input, the test is done at start-up; on
11748 failure a message is written to stderr and Exim exits with a non-zero code, as
11749 it obviously cannot send an error message of any kind.
11750
11751 .index port||for daemon
11752 .index TCP/IP||setting listening ports
11753 .conf daemon@_smtp@_ports string "$tt{smtp}"
11754 This option specifies one or more default SMTP ports on which the Exim daemon
11755 listens. See chapter ~~CHAPinterfaces for details of how it is used. For
11756 backward compatibility, \daemon@_smtp@_port\ (singular) is a synonym.
11757
11758 .conf delay@_warning "time list" 24h
11759 .index warning of delay
11760 .index delay warning, specifying
11761 When a message is delayed, Exim sends a warning message to the sender at
11762 intervals specified by this option. The data is a colon-separated list of times
11763 after which to send warning messages.
11764 .em
11765 If the value of the option is an empty string or a zero time, no warnings are
11766 sent. 
11767 .nem
11768 Up to 10 times may be given. If a message has been on the queue for longer than
11769 the last time, the last interval between the times is used to compute
11770 subsequent warning times. For example, with
11771 .display asis
11772 delay_warning = 4h:8h:24h
11773 .endd
11774 the first message is sent after 4 hours, the second after 8 hours, and
11775 the third one after 24 hours. After that, messages are sent every 16 hours,
11776 because that is the interval between the last two times on the list. If you set
11777 just one time, it specifies the repeat interval. For example, with:
11778 .display asis
11779 delay_warning = 6h
11780 .endd
11781 messages are repeated every six hours. To stop warnings after a given time, set
11782 a very large time at the end of the list. For example:
11783 .display asis
11784 delay_warning = 2h:12h:99d
11785 .endd
11786
11787 .conf delay@_warning@_condition string$**$ "see below"
11788 The string is expanded at the time a warning message might be sent. If all the
11789 deferred addresses have the same domain, it is set in \$domain$\ during the
11790 expansion. Otherwise \$domain$\ is empty. If the result of the expansion is a
11791 forced failure, an empty string, or a string matching any of `0', `no' or
11792 `false' (the comparison being done caselessly) then the warning message is not
11793 sent. The default is
11794 .display asis
11795 delay_warning_condition = \
11796   ${if match{$h_precedence:}{(?i)bulk|list|junk}{no}{yes}}
11797 .endd
11798 which suppresses the sending of warnings about messages that have `bulk',
11799 `list' or `junk' in a ::Precedence:: header.
11800
11801 .index unprivileged delivery
11802 .index delivery||unprivileged
11803 .conf deliver@_drop@_privilege boolean false
11804 If this option is set true, Exim drops its root privilege at the start of a
11805 delivery process, and runs as the Exim user throughout. This severely restricts
11806 the kinds of local delivery that are possible, but is viable in certain types
11807 of configuration. There is a discussion about the use of root privilege in
11808 chapter ~~CHAPsecurity.
11809
11810 .index load average
11811 .index queue runner||abandoning
11812 .conf deliver@_queue@_load@_max fixed-point unset
11813 When this option is set, a queue run is abandoned if the system load average
11814 becomes greater than the value of the option. The option has no effect on
11815 ancient operating systems on which Exim cannot determine the load average.
11816 See also \queue@_only@_load\ and \smtp@_load@_reserve\.
11817
11818 .conf delivery@_date@_remove boolean true
11819 .index ::Delivery-date:: header line
11820 Exim's transports have an option for adding a ::Delivery-date:: header to a
11821 message when it is delivered -- in exactly the same way as ::Return-path:: is
11822 handled. ::Delivery-date:: records the actual time of delivery. Such headers
11823 should not be present in incoming messages, and this option causes them to be
11824 removed at the time the message is received, to avoid any problems that might
11825 occur when a delivered message is subsequently sent on to some other recipient.
11826
11827 .index DNS||`try again' response, overriding
11828 .conf dns@_again@_means@_nonexist "domain list$**$" unset
11829 DNS lookups give a `try again' response for the DNS errors `non-authoritative
11830 host not found' and `\\SERVERFAIL\\'. This can cause Exim to keep trying to
11831 deliver a message, or to give repeated temporary errors to incoming mail.
11832 Sometimes the effect is caused by a badly set up name server and may persist
11833 for a long time. If a domain which exhibits this problem matches anything in
11834 \dns__again__means__nonexist\, it is treated as if it did not exist. This
11835 option should be used with care.
11836 You can make it apply to reverse lookups by a setting such as this:
11837 .display asis
11838 dns_again_means_nonexist = *.in-addr.arpa
11839 .endd
11840 .em
11841 This option applies to all DNS lookups that Exim does. The \%dnslookup%\ router 
11842 has some options of its own for controlling what happens when lookups for MX or 
11843 SRV records give temporary errors. These more specific options are applied
11844 after the global option.
11845 .nem
11846
11847 .index DNS||pre-check of name syntax
11848 .conf dns@_check@_names@_pattern string "see below"
11849 When this option is set to a non-empty string, it causes Exim to check domain
11850 names for illegal characters before handing them to the DNS resolver, because
11851 some resolvers give temporary errors for malformed names. If a domain name
11852 contains any illegal characters, a `not found' result is forced, and the
11853 resolver is not called. The check is done by matching the domain name against a
11854 regular expression, which is the value of this option. The default pattern is
11855 .display asis
11856 dns_check_names_pattern = \
11857   (?i)^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$
11858 .endd
11859 which permits only letters, digits, and hyphens in components, but they may not
11860 start or end with a hyphen.
11861 If you set \allow@_utf8@_domains\, you must modify this pattern, or set the
11862 option to an empty string.
11863
11864 .conf dns@_ipv4@_lookup "domain list$**$" unset
11865 .index IPv6||DNS lookup for AAAA records
11866 .index DNS||IPv6 lookup for AAAA records
11867 When Exim is compiled with IPv6 support, it looks for IPv6 address records
11868 (AAAA and, if configured, A6) as well as IPv4 address records when trying to
11869 find IP addresses for hosts, unless the host's domain matches this list.
11870
11871 This is a fudge to help with name servers that give big delays or otherwise do
11872 not work for the new IPv6 record types. If Exim is handed an IPv6 address
11873 record as a result of an MX lookup, it always recognizes it, and may as a
11874 result make an outgoing IPv6 connection. All this option does is to make Exim
11875 look only for IPv4-style A records when it needs to find an IP address for a
11876 host name. In due course, when the world's name servers have all been upgraded,
11877 there should be no need for this option.
11878
11879 .conf dns@_retrans time 0s
11880 .index DNS||resolver options
11881 The options \dns@_retrans\ and \dns@_retry\ can be used to set the
11882 retransmission and retry parameters for DNS lookups. Values of zero (the
11883 defaults) leave the system default settings unchanged. The first value is the
11884 time between retries, and the second is the number of retries. It isn't
11885 totally clear exactly how these settings affect the total time a DNS lookup may
11886 take. I haven't found any documentation about timeouts on DNS lookups; these
11887 parameter values are available in the external resolver interface structure,
11888 but nowhere does it seem to describe how they are used or what you might want
11889 to set in them.
11890
11891 .conf dns@_retry integer 0
11892 See \dns@_retrans\ above.
11893
11894 .conf drop@_cr boolean false
11895 This is an obsolete option that is now a no-op. It used to affect the way Exim
11896 handled CR and LF characters in incoming messages. What happens now is
11897 described in section ~~SECTlineendings.
11898
11899 .conf envelope@_to@_remove boolean true
11900 .index ::Envelope-to:: header line
11901 Exim's transports have an option for adding an ::Envelope-to:: header to a
11902 message when it is delivered -- in exactly the same way as ::Return-path:: is
11903 handled. ::Envelope-to:: records the original recipient address from the
11904 messages's envelope that caused the delivery to happen. Such headers should not
11905 be present in incoming messages, and this option causes them to be removed at
11906 the time the message is received, to avoid any problems that might occur when a
11907 delivered message is subsequently sent on to some other recipient.
11908
11909 .conf errors@_copy "string list$**$" unset
11910 .index bounce message||copy to other address
11911 .index copy of bounce message
11912 Setting this option causes Exim to send bcc copies of bounce messages that it
11913 generates to other addresses. \**Note**\: this does not apply to bounce messages
11914 coming from elsewhere. The value of the option is a colon-separated list of
11915 items. Each item consists of a pattern, terminated by white space, followed by
11916 a comma-separated list of email addresses. If a pattern contains spaces, it
11917 must be enclosed in double quotes.
11918
11919 Each pattern is processed in the same way as a single item in an address list
11920 (see section ~~SECTaddresslist). When a pattern matches the recipient of the
11921 bounce message, the message is copied to the addresses on the list. The items
11922 are scanned in order, and once a matching one is found, no further items are
11923 examined. For example:
11924 .display asis
11925 errors_copy = spqr@mydomain   postmaster@mydomain.example :\
11926               rqps@mydomain   hostmaster@mydomain.example,\
11927                               postmaster@mydomain.example
11928 .endd
11929 The address list is expanded before use. The expansion variables
11930 \$local@_part$\ and \$domain$\ are set from the original recipient of the error
11931 message, and if there was any wildcard matching in the pattern, the expansion
11932 .index numerical variables (\$1$\, \$2$\, etc)||in \errors@_copy\
11933 variables \$0$\, \$1$\, etc. are set in the normal way.
11934
11935 .conf errors@_reply@_to string unset
11936 .index bounce message||::Reply-to:: in
11937 Exim's bounce and delivery warning messages contain the header line
11938 .display
11939 From: Mail Delivery System @<Mailer-Daemon@@<<qualify-domain>>@>
11940 .endd
11941 where <<qualify-domain>> is the value of the \qualify@_domain\ option.
11942 Experience shows that people reply to bounce messages. If the
11943 \errors@_reply@_to\ option is set, a ::Reply-To:: header is added to bounce and
11944 warning messages. For example:
11945 .display asis
11946 errors_reply_to = postmaster@my.domain.example
11947 .endd
11948 The value of the option is not expanded. It must specify a valid RFC 2822
11949 address.
11950
11951 .conf exim@_group string "compile-time configured"
11952 .index gid (group id)||Exim's own
11953 .index Exim group
11954 This option changes the gid under which Exim runs when it gives up root
11955 privilege. The default value is compiled into the binary. The value of this
11956 option is used only when \exim@_user\ is also set. Unless it consists entirely
11957 of digits, the string is looked up using \*getgrnam()*\, and failure causes a
11958 configuration error. See chapter ~~CHAPsecurity for a discussion of security
11959 issues.
11960
11961 .conf exim@_path string "see below"
11962 .index Exim binary, path name
11963 This option specifies the path name of the Exim binary, which is used when Exim
11964 needs to re-exec itself. The default is set up to point to the file \*exim*\ in
11965 the directory configured at compile time by the \\BIN@_DIRECTORY\\ setting. It
11966 is necessary to change \exim@_path\ if, exceptionally, Exim is run from some
11967 other place.
11968 \**Warning**\: Do not use a macro to define the value of this option, because
11969 you will break those Exim utilities that scan the configuration file to find
11970 where the binary is. (They then use the \-bP-\ option to extract option
11971 settings such as the value of \spool@_directory\.)
11972
11973 .conf exim@_user string "compile-time configured"
11974 .index uid (user id)||Exim's own
11975 .index Exim user
11976 This option changes the uid under which Exim runs when it gives up root
11977 privilege. The default value is compiled into the binary. Ownership of the run
11978 time configuration file and the use of the \-C-\ and \-D-\ command line options
11979 is checked against the values in the binary, not what is set here.
11980
11981 Unless it consists entirely of digits, the string is looked up using
11982 \*getpwnam()*\, and failure causes a configuration error. If \exim@_group\ is
11983 not also supplied, the gid is taken from the result of \*getpwnam()*\ if it is
11984 used. See chapter ~~CHAPsecurity for a discussion of security issues.
11985
11986 .conf extra@_local@_interfaces "string list" unset
11987 .index
11988 This option defines network interfaces that are to be considered local when
11989 routing, but which are not used for listening by the daemon. See section
11990 ~~SECTreclocipadd for details.
11991
11992 .conf extract@_addresses@_remove@_arguments boolean true
11993 .index \-t-\ option
11994 .index command line||addresses with \-t-\
11995 .index Sendmail compatibility||\-t-\ option
11996 According to some Sendmail documentation (Sun, IRIX, HP-UX), if any addresses
11997 are present on the command line when the \-t-\ option is used to build an
11998 envelope from a message's ::To::, ::Cc:: and ::Bcc:: headers, the command line
11999 addresses are removed from the recipients list. This is also how Smail behaves.
12000 However, other Sendmail documentation (the O'Reilly book) states that command
12001 line addresses are added to those obtained from the header lines. When
12002 \extract__addresses__remove__arguments\ is true (the default), Exim subtracts
12003 argument headers. If it is set false, Exim adds rather than removes argument
12004 addresses.
12005
12006 .conf finduser@_retries integer 0
12007 .index NIS, looking up users, retrying
12008 On systems running NIS or other schemes in which user and group information is
12009 distributed from a remote system, there can be times when \*getpwnam()*\ and
12010 related functions fail, even when given valid data, because things time out.
12011 Unfortunately these failures cannot be distinguished from genuine `not found'
12012 errors. If \finduser@_retries\ is set greater than zero, Exim will try that
12013 many extra times to find a user or a group, waiting for one second between
12014 retries.
12015
12016 .index \(/etc/passwd)\, multiple reading of
12017 .em
12018 You should not set this option greater than zero if your user information is in 
12019 a traditional \(/etc/passwd)\ file, because it will cause Exim needlessly to
12020 search the file multiple times for non-existent users, and also cause delay.
12021 .nem
12022
12023 .conf freeze@_tell "string list, comma separated" unset
12024 .index freezing messages||sending a message when freezing
12025 On encountering certain errors, or when configured to do so in a system filter,
12026 or in an ACL,
12027 Exim freezes a message. This means that no further delivery attempts take place
12028 until an administrator (or the \auto@_thaw\ feature) thaws the message. If
12029 \freeze@_tell\ is set, Exim generates a warning message whenever it freezes
12030 something, unless the message it is freezing is a
12031 locally-generated
12032 bounce message. (Without this exception there is the possibility of looping.)
12033 The warning message is sent to the addresses supplied as the comma-separated
12034 value of this option. If several of the message's addresses cause freezing,
12035 only a single message is sent.
12036 If the freezing was automatic, the reason(s) for freezing can be found in the
12037 message log. If you configure freezing in a filter or ACL, you must arrange for
12038 any logging that you require.
12039
12040 .conf gecos@_name string$**$ unset
12041 .index HP-UX
12042 .index `gecos' field, parsing
12043 Some operating systems, notably HP-UX, use the `gecos' field in the system
12044 password file to hold other information in addition to users' real names. Exim
12045 looks up this field for use when it is creating ::Sender:: or ::From:: headers.
12046 If either \gecos@_pattern\ or \gecos@_name\ are unset, the contents of the
12047 field are used unchanged, except that, if an ampersand is encountered, it is
12048 replaced by the user's login name with the first character forced to
12049 upper case, since this is a convention that is observed on many systems.
12050
12051 When these options are set, \gecos@_pattern\ is treated as a regular expression
12052 that is to be applied to the field (again with & replaced by the login name),
12053 and if it matches, \gecos@_name\ is expanded and used as the user's name.
12054 .index numerical variables (\$1$\, \$2$\, etc)||in \gecos@_name\
12055 Numeric variables such as \$1$\, \$2$\, etc. can be used in the expansion to
12056 pick up sub-fields that were matched by the pattern. In HP-UX, where the user's
12057 name terminates at the first comma, the following can be used:
12058 .display asis
12059 gecos_pattern = ([^,]*)
12060 gecos_name = $1
12061 .endd
12062
12063 .conf gecos@_pattern string unset
12064 See \gecos@_name\ above.
12065
12066 .conf headers@_charset string "see below"
12067 This option sets a default character set for translating from encoded MIME
12068 `words' in header lines, when referenced by an \$h@_xxx$\ expansion item. The
12069 default is the value of \\HEADERS@_CHARSET\\ in \(Local/Makefile)\. The
12070 ultimate default is ISO-8859-1. For more details see the description of header
12071 insertions in section ~~SECTexpansionitems.
12072
12073
12074 .conf header@_maxsize integer "see below"
12075 .index header section||maximum size of
12076 .index limit||size of message header section
12077 This option controls the overall maximum size of a message's header
12078 section. The default is the value of \\HEADER@_MAXSIZE\\ in
12079 \(Local/Makefile)\; the default for that is 1M. Messages with larger header
12080 sections are rejected.
12081
12082 .conf header@_line@_maxsize integer 0
12083 .index header lines||maximum size of
12084 .index limit||size of one header line
12085 This option limits the length of any individual header line in a message, after
12086 all the continuations have been joined together. Messages with individual
12087 header lines that are longer than the limit are rejected. The default value of
12088 zero means `no limit'.
12089
12090
12091
12092 .conf helo@_accept@_junk@_hosts "host list$**$" unset
12093 .index \\HELO\\||accepting junk data
12094 .index \\EHLO\\||accepting junk data
12095 Exim checks the syntax of \\HELO\\ and \\EHLO\\ commands for incoming SMTP
12096 mail, and gives an error response for invalid data. Unfortunately, there are
12097 some SMTP clients that send syntactic junk. They can be accommodated by setting
12098 this option. Note that this is a syntax check only. See \helo@_verify@_hosts\
12099 if you want to do semantic checking.
12100 See also \helo@_allow@_chars\ for a way of extending the permitted character
12101 set.
12102
12103 .conf helo@_allow@_chars string unset
12104 .index \\HELO\\||underscores in
12105 .index \\EHLO\\||underscores in
12106 .index underscore in \\EHLO\\/\\HELO\\
12107 This option can be set to a string of rogue characters that are permitted in
12108 all \\EHLO\\ and \\HELO\\ names in addition to the standard letters, digits,
12109 hyphens, and dots. If you really must allow underscores, you can set
12110 .display asis
12111 helo_allow_chars = _
12112 .endd
12113 Note that the value is one string, not a list.
12114
12115 .conf helo@_lookup@_domains "domain list$**$" "$tt{@@:@@[]}"
12116 .index \\HELO\\||forcing reverse lookup
12117 .index \\EHLO\\||forcing reverse lookup
12118 If the domain given by a client in a \\HELO\\ or \\EHLO\\ command matches this
12119 list, a reverse lookup is done in order to establish the host's true name. The
12120 default forces a lookup if the client host gives the server's name or any of
12121 its IP addresses (in brackets), something that broken clients have been seen to
12122 do.
12123
12124 .conf helo@_try@_verify@_hosts "host list$**$" unset
12125 .index \\HELO\\||verifying, optional
12126 .index \\EHLO\\||verifying, optional
12127 The RFCs mandate that a server must not reject a message because it doesn't
12128 like the \\HELO\\ or \\EHLO\\ command. By default, Exim just checks the syntax
12129 of these commands (see \helo__accept__junk__hosts\ and \helo@_allow@_chars\
12130 above). However, some sites like to be stricter. If the calling host matches
12131 \helo@_try@_verify@_hosts\, Exim checks that the host name given in the \\HELO\\
12132 or \\EHLO\\ command either:
12133 .numberpars $.
12134 is an IP literal matching the calling address of the host (the RFCs
12135 specifically allow this), or
12136 .nextp
12137 .index DNS||reverse lookup
12138 .index reverse DNS lookup
12139 matches the host name that Exim obtains by doing a reverse lookup of the
12140 calling host address, or
12141 .nextp
12142 when looked up using \*gethostbyname()*\ (or \*getipnodebyname()*\ when
12143 available) yields the calling host address.
12144 .endp
12145 However, the \\EHLO\\ or \\HELO\\ command is not rejected if any of the checks
12146 fail. Processing continues, but the result of the check is remembered, and can
12147 be detected later in an ACL by the \"verify = helo"\ condition. If you want
12148 verification failure to cause rejection of \\EHLO\\ or \\HELO\\, use
12149 \helo@_verify@_hosts\ instead.
12150
12151
12152 .conf helo@_verify@_hosts "host list$**$" unset
12153 .index \\HELO\\||verifying, mandatory
12154 .index \\EHLO\\||verifying, mandatory
12155 For hosts that match this option, Exim checks the host name given in the
12156 \\HELO\\ or \\EHLO\\ in the same way as for \helo@_try@_verify@_hosts\. If the
12157 check fails, the \\HELO\\ or \\EHLO\\ command is rejected with a 550 error, and
12158 entries are written to the main and reject logs. If a \\MAIL\\ command is
12159 received before \\EHLO\\ or \\HELO\\, it is rejected with a
12160 503
12161 error.
12162
12163 .conf hold@_domains "domain list$**$" unset
12164 .index domain||delaying delivery
12165 .index delivery||delaying certain domains
12166 This option allows mail for particular domains to be held on the queue
12167 manually. The option is overridden if a message delivery is forced with the
12168 \-M-\, \-qf-\, \-Rf-\ or \-Sf-\ options, and also while testing or verifying
12169 addresses using \-bt-\ or \-bv-\. Otherwise, if a domain matches an item in
12170 \hold@_domains\, no routing or delivery for that address is done, and it is
12171 deferred every time the message is looked at.
12172
12173 This option is intended as a temporary operational measure for delaying the
12174 delivery of mail while some problem is being sorted out, or some new
12175 configuration tested. If you just want to delay the processing of some
12176 domains until a queue run occurs, you should use \queue@_domains\ or
12177 \queue@_smtp@_domains\, not \hold@_domains\.
12178
12179 A setting of \hold@_domains\ does not override Exim's code for removing
12180 messages from the queue if they have been there longer than the longest retry
12181 time in any retry rule. If you want to hold messages for longer than the normal
12182 retry times, insert a dummy retry rule with a long retry time.
12183
12184 .conf host@_lookup "host list$**$" unset
12185 .index host||name lookup, forcing
12186 Exim does not look up the name of a calling host from its IP address unless it
12187 is required to compare against some host list, or the host matches
12188 \helo@_try@_verify@_hosts\ or \helo@_verify@_hosts\, or the host matches this
12189 option (which normally contains IP addresses rather than host names). The
12190 default configuration file contains
12191 .display asis
12192 host_lookup = *
12193 .endd
12194 which causes a lookup to happen for all hosts. If the expense of these lookups
12195 is felt to be too great, the setting can be changed or removed.
12196
12197 After a successful reverse lookup, Exim does a forward lookup on the name it
12198 has obtained, to verify that it yields the IP address that it started with. If
12199 this check fails, Exim behaves as if the name lookup failed.
12200
12201 After any kind of failure, the host name (in \$sender@_host@_name$\) remains
12202 unset, and \$host@_lookup@_failed$\ is set to the string `1'. See also
12203 \dns@_again@_means@_nonexist\, \helo__lookup__domains\, and \"verify =
12204 reverse@_host@_lookup"\ in ACLs.
12205
12206 .conf host@_lookup@_order "string list" $tt{bydns:byaddr}
12207 This option specifies the order of different lookup methods when Exim is trying
12208 to find a host name from an IP address. The default is to do a DNS lookup
12209 first, and then to try a local lookup (using \*gethostbyaddr()*\ or equivalent)
12210 if that fails. You can change the order of these lookups, or omit one entirely,
12211 if you want.
12212
12213 \**Warning**\: the `byaddr' method does not always yield aliases when there are
12214 multiple PTR records in the DNS and the IP address is not listed in
12215 \(/etc/hosts)\. Different operating systems give different results in this
12216 case. That is why the default tries a DNS lookup first.
12217
12218
12219 .conf host@_reject@_connection "host list$**$" unset
12220 .index host||rejecting connections from
12221 If this option is set, incoming SMTP calls from the hosts listed are rejected
12222 as soon as the connection is made.
12223 This option is obsolete, and retained only for backward compatibility, because
12224 nowadays the ACL specified by \acl@_smtp@_connect\ can also reject incoming
12225 connections immediately.
12226
12227 The ability to give an immediate rejection (either by this option or using an
12228 ACL) is provided for use in unusual cases. Many hosts will just try again,
12229 sometimes without much delay. Normally, it is better to use an ACL to reject
12230 incoming messages at a later stage, such as after \\RCPT\\ commands. See
12231 chapter ~~CHAPACL.
12232
12233 .em
12234 .conf hosts@_connection@_nolog "host list$**$" unset
12235 .index host||not logging connections from
12236 This option defines a list of hosts for which connection logging does not
12237 happen, even though the \smtp@_connection\ log selector is set. For example,
12238 you might want not to log SMTP connections from local processes, or from
12239 127.0.0.1, or from your local LAN. This option is consulted in the main loop of
12240 the daemon; you should therefore strive to restrict its value to a short inline
12241 list of IP addresses and networks. To disable logging SMTP connections from
12242 local processes, you must create a host list with an empty item. For example:
12243 .display asis
12244 hosts_connection_nolog = :
12245 .endd
12246 If the \smtp@_connection\ log selector is not set, this option has no effect.
12247 .nem
12248
12249 .conf hosts@_treat@_as@_local "domain list$**$" unset
12250 .index local host||domains treated as
12251 .index host||treated as local
12252 If this option is set, any host names that match the domain list are treated as
12253 if they were the local host when Exim is scanning host lists obtained from MX
12254 records
12255 or other sources. Note that the value of this option is a domain list, not a
12256 host list, because it is always used to check host names, not IP addresses.
12257
12258 This option also applies when Exim is matching the special items
12259 \"@@mx@_any"\, \"@@mx@_primary"\, and \"@@mx@_secondary"\ in a domain list (see
12260 section ~~SECTdomainlist), and when checking the \hosts\ option in the \%smtp%\
12261 transport for the local host (see the \allow@_localhost\ option in that
12262 transport).
12263 See also \local@_interfaces\, \extra@_local@_interfaces\, and chapter
12264 ~~CHAPinterfaces, which contains a discussion about local network interfaces
12265 and recognising the local host.
12266
12267 .conf ignore@_bounce@_errors@_after time 10w
12268 .index bounce message||discarding
12269 .index discarding bounce message
12270 This option affects the processing of bounce messages that cannot be delivered,
12271 that is, those that suffer a permanent delivery failure. (Bounce messages that
12272 suffer temporary delivery failures are of course retried in the usual way.)
12273
12274 After a permanent delivery failure, bounce messages are frozen,
12275 because there is no sender to whom they can be returned. When a frozen bounce
12276 message has been on the queue for more than the given time, it is unfrozen at
12277 the next queue run, and a further delivery is attempted. If delivery fails
12278 again, the bounce message is discarded. This makes it possible to keep failed
12279 bounce messages around for a shorter time than the normal maximum retry time
12280 for frozen messages. For example,
12281 .display asis
12282 ignore_bounce_errors_after = 12h
12283 .endd
12284 retries failed bounce message deliveries after 12 hours, discarding any further
12285 failures. If the value of this option is set to a zero time period, bounce
12286 failures are discarded immediately. Setting a very long time (as in the default
12287 value) has the effect of disabling this option. For ways of automatically
12288 dealing with other kinds of frozen message, see \auto@_thaw\ and
12289 \timeout@_frozen@_after\.
12290
12291 .conf ignore@_fromline@_hosts "host list$**$" unset
12292 .index `From' line
12293 .index UUCP||`From' line
12294 Some broken SMTP clients insist on sending a UUCP-like `From' line before the
12295 headers of a message. By default this is treated as the start of the message's
12296 body, which means that any following headers are not recognized as such. Exim
12297 can be made to ignore it by setting \ignore@_fromline@_hosts\ to match those
12298 hosts that insist on sending it. If the sender is actually a local process
12299 rather than a remote host, and is using \-bs-\ to inject the messages,
12300 \ignore__fromline__local\ must be set to achieve this effect.
12301
12302 .conf ignore@_fromline@_local boolean false
12303 See \ignore@_fromline@_hosts\ above.
12304
12305 .conf keep@_malformed time 4d
12306 This option specifies the length of time to keep messages whose spool files
12307 have been corrupted in some way. This should, of course, never happen. At the
12308 next attempt to deliver such a message, it gets removed. The incident is
12309 logged.
12310
12311 .conf ldap@_default@_servers "string list" unset
12312 .index LDAP||default servers
12313 This option provides a list of LDAP servers which are tried in turn when an
12314 LDAP query does not contain a server. See section ~~SECTforldaque for details
12315 of LDAP queries. This option is available only when Exim has been built with
12316 LDAP support.
12317
12318 .conf ldap@_version integer unset
12319 .index LDAP||protocol version, forcing
12320 This option can be used to force Exim to set a specific protocol version for
12321 LDAP. If it option is unset, it is shown by the \-bP-\ command line option as
12322 -1. When this is the case, the default is 3 if \\LDAP@_VERSION3\\ is defined in
12323 the LDAP headers; otherwise it is 2. This option is available only when Exim
12324 has been built with LDAP support.
12325
12326
12327 .conf local@_from@_check boolean true
12328 .index ::Sender:: header line||disabling addition of
12329 .index ::From:: header line||disabling checking of
12330 When a message is submitted locally (that is, not over a TCP/IP connection) by
12331 an untrusted user, Exim removes any existing ::Sender:: header line, and checks
12332 that the ::From:: header line matches 
12333 .em
12334 the login of the calling user and the domain specified by \qualify@_domain\.
12335
12336 \**Note**\: An unqualified address (no domain) in the ::From:: header in a 
12337 locally submitted message is automatically qualified by Exim, unless the 
12338 \-bnq-\ command line option is used.
12339 .nem
12340
12341 You can use \local@_from@_prefix\ and \local@_from@_suffix\ to permit affixes
12342 on the local part. If the ::From:: header line does not match, Exim adds a
12343 ::Sender:: header with an address constructed from the calling user's login and
12344 the default qualify domain.
12345
12346 If \local@_from@_check\ is set false, the ::From:: header check is disabled,
12347 and no ::Sender:: header is ever added. If, in addition, you want to retain
12348 ::Sender:: header lines supplied by untrusted users, you must also set
12349 \local@_sender@_retain\ to be true.
12350
12351 .index envelope sender
12352 These options affect only the header lines in the message. The envelope sender
12353 is still forced to be the login id at the qualify domain unless
12354 \untrusted@_set@_sender\ permits the user to supply an envelope sender.
12355
12356 .em
12357 For messages received over TCP/IP, an ACL can specify `submission mode' to
12358 request similar header line checking. See section ~~SECTthesenhea, which has
12359 more details about ::Sender:: processing.
12360 .nem
12361
12362
12363 .conf local@_from@_prefix string unset
12364 When Exim checks the ::From:: header line of locally submitted messages for
12365 matching the login id (see \local@_from@_check\ above), it can be configured to
12366 ignore certain prefixes and suffixes in the local part of the address. This is
12367 done by setting \local@_from@_prefix\ and/or \local@_from@_suffix\ to
12368 appropriate lists, in the same form as the \local@_part@_prefix\ and
12369 \local@_part@_suffix\ router options (see chapter ~~CHAProutergeneric). For
12370 example, if
12371 .display asis
12372 local_from_prefix = *-
12373 .endd
12374 is set, a ::From:: line containing
12375 .display asis
12376 From: anything-user@your.domain.example
12377 .endd
12378 will not cause a ::Sender:: header to be added if \*user@@your.domain.example*\
12379 matches the actual sender address that is constructed from the login name and
12380 qualify domain.
12381
12382 .conf local@_from@_suffix string unset
12383 See \local@_from@_prefix\ above.
12384
12385 .conf local@_interfaces "string list" "see below"
12386 This option controls which network interfaces are used by the daemon for
12387 listening; they are also used to identify the local host when routing. Chapter
12388 ~~CHAPinterfaces contains a full description of this option and the related
12389 options 
12390 .em
12391 \daemon@_smtp@_ports\, \extra@_local@_interfaces\, \hosts@_treat@_as@_local\,
12392 and \tls@_on@_connect@_ports\. 
12393 .nem
12394 The default value for \local@_interfaces\ is
12395 .display asis
12396 local_interfaces = 0.0.0.0
12397 .endd
12398 when Exim is built without IPv6 support; otherwise it is
12399 .display asis
12400 local_interfaces = <; ::0 ; 0.0.0.0
12401 .endd
12402
12403 .conf local@_scan@_timeout time 5m
12404 .index timeout||for \*local@_scan()*\ function
12405 .index \*local@_scan()*\ function||timeout
12406 This timeout applies to the \*local@_scan()*\ function (see chapter
12407 ~~CHAPlocalscan). Zero means `no timeout'. If the timeout is exceeded, the
12408 incoming message is rejected with a temporary error if it is an SMTP message.
12409 For a non-SMTP message, the message is dropped and Exim ends with a non-zero
12410 code. The incident is logged on the main and reject logs.
12411
12412
12413 .conf local@_sender@_retain boolean false
12414 .index ::Sender:: header line||retaining from local submission
12415 When a message is submitted locally (that is, not over a TCP/IP connection) by
12416 an untrusted user, Exim removes any existing ::Sender:: header line. If you
12417 do not want this to happen, you must set \local@_sender@_retain\, and you must
12418 also set \local@_from@_check\ to be false (Exim will complain if you do not).
12419 Section ~~SECTthesenhea has more details about ::Sender:: processing.
12420
12421
12422
12423 .conf localhost@_number string$**$ unset
12424 .index host||locally unique number for
12425 .index message||ids, with multiple hosts
12426 Exim's message ids are normally unique only within the local host. If
12427 uniqueness among a set of hosts is required, each host must set a different
12428 value for the \localhost@_number\ option. The string is expanded immediately
12429 after reading the configuration file (so that a number can be computed from the
12430 host name, for example) and the result of the expansion must be a number in the
12431 range 0--16 (or 0--10 on operating systems with case-insensitive file systems).
12432 This is available in subsequent string expansions via the variable
12433 \$localhost@_number$\. When \localhost@_number is set\, the final two
12434 characters of the message id, instead of just being a fractional part of the
12435 time, are computed from the time and the local host number as described in
12436 section ~~SECTmessiden.
12437
12438
12439 .conf log@_file@_path "string list$**$" "set at compile time"
12440 .index log||file path for
12441 This option sets the path which is used to determine the names of Exim's log
12442 files, or indicates that logging is to be to syslog, or both. It is expanded
12443 when Exim is entered, so it can, for example, contain a reference to the host
12444 name. If no specific path is set for the log files at compile or run time, they
12445 are written in a sub-directory called \(log)\ in Exim's spool directory.
12446 Chapter ~~CHAPlog contains further details about Exim's logging, and section
12447 ~~SECTwhelogwri describes how the contents of \log@_file@_path\ are used. If
12448 this string is fixed at your installation (contains no expansion variables) it
12449 is recommended that you do not set this option in the configuration file, but
12450 instead supply the path using \\LOG@_FILE@_PATH\\ in \(Local/Makefile)\ so that
12451 it is available to Exim for logging errors detected early on -- in particular,
12452 failure to read the configuration file.
12453
12454 .conf log@_selector string unset
12455 .index log||selectors
12456 This option can be used to reduce or increase the number of things that Exim
12457 writes to its log files. Its argument is made up of names preceded by plus or
12458 minus characters. For example:
12459 .display asis
12460 log_selector = +arguments -retry_defer
12461 .endd
12462 A list of possible names and what they control is given in the chapter on
12463 logging, in section ~~SECTlogselector.
12464
12465 .conf log@_timezone boolean false
12466 .index log||timezone for entries
12467 By default, the timestamps on log lines are in local time without the
12468 timezone. This means that if your timezone changes twice a year, the timestamps
12469 in log lines are ambiguous for an hour when the clocks go back. One way of
12470 avoiding this problem is to set the timezone to UTC. An alternative is to set
12471 \log@_timezone\ true. This turns on the addition of the timezone offset to
12472 timestamps in log lines. Turning on this option can add quite a lot to the size
12473 of log files because each line is extended by 6 characters. Note that the
12474 \$tod@_log$\ variable contains the log timestamp without the zone, but there is
12475 another variable called \$tod@_zone$\ that contains just the timezone offset.
12476
12477 .conf lookup@_open@_max integer 25
12478 .index too many open files
12479 .index open files, too many
12480 .index file||too many open
12481 .index lookup||maximum open files
12482 .index limit||open files for lookups
12483 This option limits the number of simultaneously open files for single-key
12484 lookups that use regular files (that is, \%lsearch%\, \%dbm%\, and \%cdb%\). Exim
12485 normally keeps these files open during routing, because often the same file is
12486 required several times. If the limit is reached, Exim closes the least recently
12487 used file. Note that if you are using the \*ndbm*\ library, it actually opens
12488 two files for each logical DBM database, though it still counts as one for the
12489 purposes of \lookup@_open@_max\. If you are getting `too many open files'
12490 errors with NDBM, you need to reduce the value of \lookup@_open@_max\.
12491
12492 .conf max@_username@_length integer 0
12493 .index length of login name
12494 .index user name||maximum length
12495 .index limit||user name length
12496 Some operating systems are broken in that they truncate long arguments to
12497 \*getpwnam()*\ to eight characters, instead of returning `no such user'. If
12498 this option is set greater than zero, any attempt to call \*getpwnam()*\ with
12499 an argument that is longer behaves as if \*getpwnam()*\ failed.
12500
12501
12502 .conf message@_body@_visible integer 500
12503 .index body of message||visible size
12504 .index message||body, visible size
12505 This option specifies how much of a message's body is to be included in the
12506 \$message@_body$\ and \$message@_body@_end$\ expansion variables.
12507
12508 .conf message@_id@_header@_domain string$**$ unset
12509 .index ::Message-ID:: header line
12510 If this option is set, the string is expanded and used as the right hand side
12511 (domain) of the ::Message-ID:: header that Exim creates if a
12512 locally-originated incoming message does not have one. `Locally-originated'
12513 means `not received over TCP/IP.'
12514 Otherwise, the primary host name is used.
12515 Only letters, digits, dot and hyphen are accepted; any other characters are
12516 replaced by hyphens. If the expansion is forced to fail, or if the result is an
12517 empty string, the option is ignored.
12518
12519 .conf message@_id@_header@_text string$**$ unset
12520 If this variable is set, the string is expanded and used to augment the text of
12521 the ::Message-id:: header that Exim creates if a
12522 locally-originated
12523 incoming message does not have one. The text of this header is required by RFC
12524 2822 to take the form of an address. By default, Exim uses its internal message
12525 id as the local part, and the primary host name as the domain. If this option
12526 is set, it is expanded, and provided the expansion is not forced to fail, and
12527 does not yield an empty string, the result is inserted into the header
12528 immediately before the @@, separated from the internal message id by a dot. Any
12529 characters that are illegal in an address are automatically converted into
12530 hyphens. This means that variables such as \$tod@_log$\ can be used, because
12531 the spaces and colons will become hyphens.
12532
12533 .conf message@_logs boolean true
12534 .index message||log, disabling
12535 .index log||message log, disabling
12536 If this option is turned off, per-message log files are not created in the
12537 \(msglog)\ spool sub-directory. This reduces the amount of disk I/O required by
12538 Exim, by reducing the number of files involved in handling a message from a
12539 minimum of four (header spool file, body spool file, delivery journal, and
12540 per-message log) to three. The other major I/O activity is Exim's main log,
12541 which is not affected by this option.
12542
12543 .conf message@_size@_limit string$**$ 50M
12544 .index message||size limit
12545 .index limit||message size
12546 .index size||of message, limit
12547 This option limits the maximum size of message that Exim will process. The
12548 value is expanded for each incoming
12549 connection so, for example, it can be made to depend on the IP address of the
12550 remote host for messages arriving via TCP/IP. \**Note**\: This limit cannot be
12551 made to depend on a message's sender or any other properties of an individual
12552 message, because it has to be advertised in the server's response to \\EHLO\\.
12553 String expansion failure causes a temporary error. A value of zero means no
12554 limit, but its use is not recommended. See also \bounce@_return@_size@_limit\.
12555
12556 Incoming SMTP messages are failed with a 552 error if the limit is
12557 exceeded; locally-generated messages either get a stderr message or a delivery
12558 failure message to the sender, depending on the \-oe-\ setting. Rejection of an
12559 oversized message is logged in both the main and the reject logs. See also the
12560 generic transport option \message@_size@_limit\, which limits the size of
12561 message that an individual transport can process.
12562
12563 .conf move@_frozen@_messages boolean false
12564 .index frozen messages||moving
12565 This option, which is available only if Exim has been built with the setting
12566 .display asis
12567 SUPPORT_MOVE_FROZEN_MESSAGES=yes
12568 .endd
12569 in \(Local/Makefile)\, causes frozen messages and their message logs to be
12570 moved from the \(input)\ and \(msglog)\ directories on the spool to \(Finput)\
12571 and \(Fmsglog)\, respectively. There is currently no support in Exim or the
12572 standard utilities for handling such moved messages, and they do not show up in
12573 lists generated by \-bp-\ or by the Exim monitor.
12574
12575 .em
12576 .conf mua@_wrapper boolean false
12577 Setting this option true causes Exim to run in a very restrictive mode in which
12578 it passes messages synchronously to a smart host. Chapter ~~CHAPnonqueueing
12579 contains a full description of this facility.
12580 .nem
12581
12582 .conf mysql@_servers "string list" unset
12583 .index MySQL||server list
12584 This option provides a list of MySQL servers and associated connection data, to
12585 be used in conjunction with \%mysql%\ lookups (see section ~~SECTsql). The
12586 option is available only if Exim has been built with MySQL support.
12587
12588 .conf never@_users "string list" unset
12589 Local message deliveries are normally run in processes that are setuid to the
12590 recipient, and remote deliveries are normally run under Exim's own uid and gid.
12591 It is usually desirable to prevent any deliveries from running as root, as a
12592 safety precaution.
12593
12594 When Exim is built, an option called \\FIXED@_NEVER@_USERS\\ can be set to a
12595 list of users that must not be used for local deliveries. This list is fixed in
12596 the binary and cannot be overridden by the configuration file. By default, it
12597 contains just the single user name `root'. The \never@_users\ runtime option
12598 can be used to add more users to the fixed list.
12599
12600 If a message is to be delivered as one of the users on the fixed list or the
12601 \never@_users\ list, an error occurs, and delivery is deferred. A common
12602 example is
12603 .display
12604 never@_users = root:daemon:bin
12605 .endd
12606 Including root is redundant if it is also on the fixed list, but it does no
12607 harm.
12608 This option overrides the \pipe@_as@_creator\ option of the \%pipe%\ transport
12609 driver.
12610
12611 .conf oracle@_servers "string list" unset
12612 .index Oracle||server list
12613 This option provides a list of Oracle servers and associated connection data,
12614 to be used in conjunction with \%oracle%\ lookups (see section ~~SECTsql). The
12615 option is available only if Exim has been built with Oracle support.
12616
12617 .conf percent@_hack@_domains "domain list$**$" unset
12618 .index `percent hack'
12619 .index source routing||in email address
12620 .index address||source-routed
12621 The `percent hack' is the convention whereby a local part containing a percent
12622 sign is re-interpreted as a new email address, with the percent replaced by @@.
12623 This is sometimes called `source routing', though that term is also applied to
12624 RFC 2822 addresses that begin with an @@ character. If this option is set, Exim
12625 implements the percent facility for those domains listed, but no others. This
12626 happens before an incoming SMTP address is tested against an ACL.
12627
12628 \**Warning**\: The `percent hack' has often been abused by people who are
12629 trying to get round relaying restrictions. For this reason, it is best avoided
12630 if at all possible. Unfortunately, a number of less security-conscious MTAs
12631 implement it unconditionally. If you are running Exim on a gateway host, and
12632 routing mail through to internal MTAs without processing the local parts, it is
12633 a good idea to reject recipient addresses with percent characters in their
12634 local parts. Exim's default configuration does this.
12635
12636 .conf perl@_at@_start boolean false
12637 This option is available only when Exim is built with an embedded Perl
12638 interpreter. See chapter ~~CHAPperl for details of its use.
12639
12640 .conf perl@_startup string unset
12641 This option is available only when Exim is built with an embedded Perl
12642 interpreter. See chapter ~~CHAPperl for details of its use.
12643
12644 .conf pgsql@_servers "string list" unset
12645 .index PostgreSQL lookup type||server list
12646 This option provides a list of PostgreSQL servers and associated connection
12647 data, to be used in conjunction with \%pgsql%\ lookups (see section ~~SECTsql).
12648 The option is available only if Exim has been built with PostgreSQL support.
12649
12650 .conf pid@_file@_path string$**$ "set at compile time"
12651 .index daemon||pid file path
12652 .index pid file, path for
12653 This option sets the name of the file to which the Exim daemon writes its
12654 process id. The string is expanded, so it can contain, for example, references
12655 to the host name:
12656 .display asis
12657 pid_file_path = /var/log/$primary_hostname/exim.pid
12658 .endd
12659 If no path is set, the pid is written to the file \(exim-daemon.pid)\ in Exim's
12660 spool directory.
12661 The value set by the option can be overridden by the \-oP-\ command line
12662 option. A pid file is not written if a `non-standard' daemon is run by means of
12663 the \-oX-\ option, unless a path is explicitly supplied by \-oP-\.
12664
12665 .conf pipelining@_advertise@_hosts "host list$**$" $*$
12666 .index \\PIPELINING\\||advertising, suppressing
12667 This option can be used to suppress the advertisement of the SMTP
12668 \\PIPELINING\\ extension to specific hosts. When \\PIPELINING\\ is not
12669 advertised and \smtp@_enforce@_sync\ is true, an Exim server enforces strict
12670 synchronization for each SMTP command and response.
12671 When \\PIPELINING\\ is advertised, Exim assumes that clients will use it; `out
12672 of order' commands that are `expected' do not count as protocol errors (see
12673 \smtp@_max@_synprot@_errors\).
12674
12675 .conf preserve@_message@_logs boolean false
12676 .index message logs, preserving
12677 If this option is set, message log files are not deleted when messages are
12678 completed. Instead, they are moved to a sub-directory of the spool directory
12679 called \(msglog.OLD)\, where they remain available for statistical or debugging
12680 purposes. This is a dangerous option to set on systems with any appreciable
12681 volume of mail. Use with care!
12682
12683 .conf primary@_hostname string "see below"
12684 .index name||of local host
12685 .index host||name of local
12686 .index local host||name of
12687 This specifies the name of the current host. It is used in the default \\EHLO\\
12688 or \\HELO\\ command for outgoing SMTP messages (changeable via the \helo@_data\
12689 option in the \%smtp%\ transport),
12690 and as the default for \qualify@_domain\. If it is not set, Exim calls
12691 \*uname()*\ to find it. If this fails, Exim panics and dies. If the name
12692 returned by \*uname()*\ contains only one component, Exim passes it to
12693 \*gethostbyname()*\ (or \*getipnodebyname()*\ when available) in order to
12694 obtain the fully qualified version.
12695
12696 The value of \$primary@_hostname$\ is also used by default in some SMTP
12697 response messages from an Exim server. This can be changed dynamically by
12698 setting \smtp@_active@_hostname\.
12699
12700 .conf print@_topbitchars boolean false
12701 .index printing characters
12702 .index 8-bit characters
12703 By default, Exim considers only those characters whose codes lie in the range
12704 32--126 to be printing characters. In a number of circumstances (for example,
12705 when writing log entries) non-printing characters are converted into escape
12706 sequences, primarily to avoid messing up the layout. If \print@_topbitchars\ is
12707 set, code values of 128 and above are also considered to be printing
12708 characters.
12709
12710 .conf process@_log@_path string unset
12711 .index process log path
12712 .index log||process log
12713 .index \*exiwhat*\
12714 This option sets the name of the file to which an Exim process writes its
12715 `process log' when sent a USR1 signal. This is used by the \*exiwhat*\ utility
12716 script. If this option is unset, the file called \(exim-process.info)\ in
12717 Exim's spool directory is used. The ability to specify the name explicitly can
12718 be useful in environments where two different Exims are running, using
12719 different spool directories.
12720
12721 .conf prod@_requires@_admin boolean true
12722 .index \-M-\ option
12723 .index \-R-\ option
12724 .index \-q-\ option
12725 The \-M-\, \-R-\, and \-q-\ command-line options require the caller to be an
12726 admin user unless \prod@_requires@_admin\ is set false. See also
12727 \queue@_list@_requires@_admin\.
12728
12729 .conf qualify@_domain string "see below"
12730 .index domain||for qualifying addresses
12731 .index address||qualification
12732 This option specifies the domain name that is added to any envelope sender
12733 addresses that do not have a domain qualification. It also applies to
12734 recipient addresses if \qualify@_recipient\ is not set. 
12735 .em
12736 Unqualified addresses are accepted by default only for locally-generated
12737 messages.
12738
12739 Qualification is also applied to addresses in header lines such as ::From:: and 
12740 ::To:: for locally-generated messages, unless the \-bnq-\ command line option 
12741 is used.
12742 .nem
12743
12744 Messages from external sources must always contain fully qualified addresses,
12745 unless the sending host matches \sender@_unqualified@_hosts\ or
12746 \recipient@_unqualified@_hosts\ (as appropriate), in which case incoming
12747 addresses are qualified with \qualify@_domain\ or \qualify@_recipient\ as
12748 necessary. Internally, Exim always works with fully qualified envelope
12749 addresses. If \qualify@_domain\ is not set, it defaults to the
12750 \primary@_hostname\ value.
12751
12752 .conf qualify@_recipient string "see below"
12753 .em
12754 This option allows you to specify a different domain for qualifying recipient
12755 addresses to the one that is used for senders. See \qualify@_domain\ above.
12756 .nem
12757
12758 .conf queue@_domains "domain list$**$" unset
12759 .index domain||specifying non-immediate delivery
12760 .index queueing incoming messages
12761 .index message||queueing certain domains
12762 This option lists domains for which immediate delivery is not required.
12763 A delivery process is started whenever a message is received, but only those
12764 domains that do not match are processed. All other deliveries wait until the
12765 next queue run. See also \hold@_domains\ and \queue@_smtp@_domains\.
12766
12767 .conf queue@_list@_requires@_admin boolean true
12768 .index \-bp-\ option
12769 The \-bp-\ command-line option, which lists the messages that are on the queue,
12770 requires the caller to be an admin user unless \queue__list__requires__admin\
12771 is set false. See also \prod@_requires@_admin\.
12772
12773 .conf queue@_only boolean false
12774 .index queueing incoming messages
12775 .index message||queueing unconditionally
12776 If \queue@_only\ is set, a delivery process is not automatically started
12777 whenever a message is received. Instead, the message waits on the queue for the
12778 next queue run. Even if \queue@_only\ is false, incoming messages may not get
12779 delivered immediately when certain conditions (such as heavy load) occur.
12780
12781 The \-odq-\ command line has the same effect as \queue@_only\. The \-odb-\ and
12782 \-odi-\ command line options override \queue@_only\ unless
12783 \queue@_only@_override\ is set false. See also \queue@_only@_file\,
12784 \queue@_only@_load\, and \smtp@_accept@_queue\.
12785
12786 .conf queue@_only@_file string unset
12787 .index queueing incoming messages
12788 .index message||queueing by file existence
12789 This option can be set to a colon-separated list of absolute path names, each
12790 one optionally preceded by `smtp'. When Exim is receiving a message,
12791 it tests for the existence of each listed path using a call to \*stat()*\. For
12792 each path that exists, the corresponding queuing option is set.
12793 For paths with no prefix, \queue@_only\ is set; for paths prefixed by `smtp',
12794 \queue@_smtp@_domains\ is set to match all domains. So, for example,
12795 .display asis
12796 queue_only_file = smtp/some/file
12797 .endd
12798 causes Exim to behave as if \queue@_smtp@_domains\ were set to `$*$' whenever
12799 \(/some/file)\ exists.
12800
12801 .conf queue@_only@_load fixed-point unset
12802 .index load average
12803 .index queueing incoming messages
12804 .index message||queueing by load
12805 If the system load average is higher than this value, incoming messages from
12806 all sources are queued, and no automatic deliveries are started. If this
12807 happens during local or remote SMTP input, all subsequent messages on the same
12808 connection are queued. Deliveries will subsequently be performed by queue
12809 runner processes. This option has no effect on ancient operating systems on
12810 which Exim cannot determine the load average. See also
12811 \deliver@_queue@_load@_max\ and \smtp@_load@_reserve\.
12812
12813 .conf queue@_only@_override boolean true
12814 .index queueing incoming messages
12815 When this option is true, the \-od\*x*\-\ command line options override the
12816 setting of \queue@_only\ or \queue@_only@_file\ in the configuration file. If
12817 \queue@_only@_override\ is set false, the \-od\*x*\-\ options cannot be used to
12818 override; they are accepted, but ignored.
12819
12820 .conf queue@_run@_in@_order boolean false
12821 .index queue runner||processing messages in order
12822 If this option is set, queue runs happen in order of message arrival instead of
12823 in an arbitrary order. For this to happen, a complete list of the entire queue
12824 must be set up before the deliveries start. When the queue is all held in a
12825 single directory (the default),
12826 .em
12827 a single list is created for both the ordered and the non-ordered cases.
12828 However, if \split@_spool@_directory\ is set, a single list is not created when
12829 \queue@_run@_in@_order\ is false. In this case, the sub-directories are
12830 processed one at a time (in a random order), and this avoids setting up one
12831 huge list for the whole queue. Thus, setting \queue@_run@_in@_order\ with
12832 \split@_spool@_directory\ may degrade performance when the queue is large,
12833 because of the extra work in setting up the single, large list. In most
12834 situations, \queue@_run@_in@_order\ should not be set.
12835 .nem
12836
12837 .conf queue@_run@_max integer 5
12838 .index queue runner||maximum number of
12839 This controls the maximum number of queue runner processes that an Exim daemon
12840 can run simultaneously. This does not mean that it starts them all at once,
12841 but rather that if the maximum number are still running when the time comes to
12842 start another one, it refrains from starting another one. This can happen with
12843 very large queues and/or very sluggish deliveries. This option does not,
12844 however, interlock with other processes, so additional queue runners can be
12845 started by other means, or by killing and restarting the daemon.
12846
12847 .conf queue@_smtp@_domains "domain list$**$" unset
12848 .index queueing incoming messages
12849 .index message||queueing remote deliveries
12850 When this option is set, a delivery process is started whenever a message is
12851 received, routing is performed, and local deliveries take place.
12852 However, if any SMTP deliveries are required for domains that match
12853 \queue@_smtp@_domains\, they are not immediately delivered, but instead the
12854 message waits on the queue for the next queue run. Since routing of the message
12855 has taken place, Exim knows to which remote hosts it must be delivered, and so
12856 when the queue run happens, multiple messages for the same host are delivered
12857 over a single SMTP connection. The \-odqs-\ command line option causes all SMTP
12858 deliveries to be queued in this way, and is equivalent to setting
12859 \queue@_smtp@_domains\ to `$*$'. See also \hold@_domains\ and \queue@_domains\.
12860
12861 .conf receive@_timeout time 0s
12862 .index timeout||for non-SMTP input
12863 This option sets the timeout for accepting a non-SMTP message, that is, the
12864 maximum time that Exim waits when reading a message on the standard input. If
12865 the value is zero, it will wait for ever. This setting is overridden by the
12866 \-or-\ command line option. The timeout for incoming SMTP messages is
12867 controlled by \smtp@_receive@_timeout\.
12868
12869 .index customizing|| ::Received:: header
12870 .index ::Received:: header line||customizing
12871 .conf received@_header@_text string$**$ "see below"
12872 This string defines the contents of the ::Received:: message header that is
12873 added to each message, except for the timestamp, which is automatically added
12874 on at the end (preceded by a semicolon). The string is expanded each time it is
12875 used. If the expansion yields an empty string, no ::Received:: header line is
12876 added to the message. Otherwise, the string should start with the text
12877 `Received:' and conform to the RFC 2822 specification for ::Received:: header
12878 lines. The default setting is:
12879 .display asis
12880 received_header_text = Received: \
12881     ${if def:sender_rcvhost {from $sender_rcvhost\n\t}\
12882     {${if def:sender_ident {from $sender_ident }}\
12883     ${if def:sender_helo_name {(helo=$sender_helo_name)\n\t}}}}\
12884     by $primary_hostname \
12885     ${if def:received_protocol {with $received_protocol}} \
12886     ${if def:tls_cipher {($tls_cipher)\n\t}}\
12887     (Exim $version_number)\n\t\
12888     id $message_id\
12889     ${if def:received_for {\n\tfor $received_for}}
12890 .endd
12891 Note the use of quotes, to allow the sequences \"@\n"\ and \"@\t"\ to be used
12892 for newlines and tabs, respectively. The reference to the TLS cipher is omitted
12893 when Exim is built without TLS support. The use of conditional expansions
12894 ensures that this works for both locally generated messages and messages
12895 received from remote hosts, giving header lines such as the following:
12896 .display asis
12897 Received: from scrooge.carol.example ([192.168.12.25] ident=root)
12898         by marley.carol.example with esmtp (Exim 4.00)
12899         id 16IOWa-00019l-00
12900         for chas@dickens.example; Tue, 25 Dec 2001 14:43:44 +0000
12901 Received: by scrooge.carol.example with local (Exim 4.00)
12902         id 16IOWW-000083-00; Tue, 25 Dec 2001 14:43:41 +0000
12903 .endd
12904 Until the body of the message has been received, the timestamp is the time when
12905 the message started to be received. Once the body has arrived, and all policy
12906 checks have taken place, the timestamp is updated to the time at which the
12907 message was accepted.
12908
12909 .conf received@_headers@_max integer 30
12910 .index loop||prevention
12911 .index mail loop prevention
12912 .index ::Received:: header line||counting
12913 When a message is to be delivered, the number of ::Received:: headers is
12914 counted, and if it is greater than this parameter, a mail loop is assumed to
12915 have occurred, the delivery is abandoned, and an error message is generated.
12916 This applies to both local and remote deliveries.
12917
12918 .conf recipient@_unqualified@_hosts "host list$**$" unset
12919 .index unqualified addresses
12920 .index host||unqualified addresses from
12921 This option lists those hosts from which Exim is prepared to accept unqualified
12922 recipient addresses in message envelopes. The addresses are made fully
12923 qualified by the addition of the \qualify@_recipient\ value. This option also
12924 affects message header lines. Exim does not reject unqualified recipient
12925 addresses in headers, but it qualifies them only if the message came from a
12926 host that matches \recipient@_unqualified@_hosts\,
12927 or if the message was submitted locally (not using TCP/IP), and the \-bnq-\
12928 option was not set.
12929
12930 .conf recipients@_max integer 0
12931 .index limit||number of recipients
12932 .index recipient||maximum number
12933 If this option is set greater than zero, it specifies the maximum number of
12934 original recipients for any message. Additional recipients that are generated
12935 by aliasing or forwarding do not count. SMTP messages get a 452 response for
12936 all recipients over the limit; earlier recipients are delivered as normal.
12937 Non-SMTP messages with too many recipients are failed, and no deliveries are
12938 done.
12939 .index \\RCPT\\||maximum number of incoming
12940 Note that the RFCs specify that an SMTP server should accept at least 100
12941 \\RCPT\\ commands in a single message.
12942
12943 .conf recipients@_max@_reject boolean false
12944 If this option is set true, Exim rejects SMTP messages containing too many
12945 recipients by giving 552 errors to the surplus \\RCPT\\ commands, and a 554
12946 error to the eventual \\DATA\\ command. Otherwise (the default) it gives a 452
12947 error to the surplus \\RCPT\\ commands and accepts the message on behalf of the
12948 initial set of recipients. The remote server should then re-send the message
12949 for the remaining recipients at a later time.
12950
12951 .conf remote@_max@_parallel integer 2
12952 .index delivery||parallelism for remote
12953 This option controls parallel delivery of one message to a number of remote
12954 hosts. If the value is less than 2, parallel delivery is disabled, and Exim
12955 does all the remote deliveries for a message one by one. Otherwise, if a single
12956 message has to be delivered to more than one remote host, or if several copies
12957 have to be sent to the same remote host, up to \remote@_max@_parallel\
12958 deliveries are done simultaneously. If more than \remote@_max@_parallel\
12959 deliveries are required, the maximum number of processes are started, and as
12960 each one finishes, another is begun. The order of starting processes is the
12961 same as if sequential delivery were being done, and can be controlled by the
12962 \remote@_sort@_domains\ option. If parallel delivery takes place while running
12963 with debugging turned on, the debugging output from each delivery process is
12964 tagged with its process id.
12965
12966 This option controls only the maximum number of parallel deliveries for one
12967 message in one Exim delivery process. Because Exim has no central queue
12968 manager, there is no way of controlling the total number of simultaneous
12969 deliveries if the configuration allows a delivery attempt as soon as a message
12970 is received.
12971 .index number of deliveries
12972 .index delivery||maximum number of
12973 If you want to control the total number of deliveries on the system, you
12974 need to set the \queue@_only\ option. This ensures that all incoming messages
12975 are added to the queue without starting a delivery process. Then set up an Exim
12976 daemon to start queue runner processes at appropriate intervals (probably
12977 fairly often, for example, every minute), and limit the total number of queue
12978 runners by setting the \queue__run__max\ parameter. Because each queue runner
12979 delivers only one message at a time, the maximum number of deliveries that can
12980 then take place at once is \queue@_run@_max\ multiplied by
12981 \remote@_max@_parallel\.
12982
12983 If it is purely remote deliveries you want to control, use
12984 \queue@_smtp@_domains\ instead of \queue@_only\. This has the added benefit of
12985 doing the SMTP routing before queuing, so that several messages for the same
12986 host will eventually get delivered down the same connection.
12987
12988 .conf remote@_sort@_domains "domain list$**$" unset
12989 .index sorting remote deliveries
12990 .index delivery||sorting remote
12991 When there are a number of remote deliveries for a message, they are sorted by
12992 domain into the order given by this list. For example,
12993 .display asis
12994 remote_sort_domains = *.cam.ac.uk:*.uk
12995 .endd
12996 would attempt to deliver to all addresses in the \*cam.ac.uk*\ domain first, then
12997 to those in the \uk\ domain, then to any others.
12998
12999 .conf retry@_data@_expire time 7d
13000 .index hints database||data expiry
13001 This option sets a `use before' time on retry information in Exim's hints
13002 database. Any older retry data is ignored. This means that, for example, once a
13003 host has not been tried for 7 days, Exim behaves as if it has no knowledge of
13004 past failures.
13005
13006 .conf retry@_interval@_max time 24h
13007 .index retry||limit on interval
13008 .index limit||on retry interval
13009 Chapter ~~CHAPretry describes Exim's mechanisms for controlling the intervals
13010 between delivery attempts for messages that cannot be delivered straight away.
13011 This option sets an overall limit to the length of time between retries.
13012
13013 .conf return@_path@_remove boolean true
13014 .index ::Return-path:: header line||removing
13015 RFC 2821, section 4.4, states that an SMTP server must insert a ::Return-path::
13016 header line into a message when it makes a `final delivery'. The ::Return-path::
13017 header preserves the sender address as received in the \\MAIL\\ command. This
13018 description implies that this header should not be present in an incoming
13019 message. If \return@_path@_remove\ is true, any existing ::Return-path::
13020 headers are removed from messages at the time they are received. Exim's
13021 transports have options for adding ::Return-path:: headers at the time of
13022 delivery. They are normally used only for final local deliveries.
13023
13024 .conf return@_size@_limit integer 100K
13025 This option is an obsolete synonym for \bounce@_return@_size@_limit\.
13026
13027 .conf rfc1413@_hosts "host list$**$" $*$
13028 .index RFC 1413
13029 .index host||for RFC 1413 calls
13030 RFC 1413 identification calls are made to any client host which matches an item
13031 in the list.
13032
13033 .conf rfc1413@_query@_timeout time 30s
13034 .index RFC 1413||query timeout
13035 .index timeout||for RFC 1413 call
13036 This sets the timeout on RFC 1413 identification calls. If it is set to zero,
13037 no RFC 1413 calls are ever made.
13038
13039 .conf sender@_unqualified@_hosts "host list$**$" unset
13040 .index unqualified addresses
13041 .index host||unqualified addresses from
13042 This option lists those hosts from which Exim is prepared to accept unqualified
13043 sender addresses. The addresses are made fully qualified by the addition of
13044 \qualify@_domain\. This option also affects message header lines. Exim does not
13045 reject unqualified addresses in headers that contain sender addresses, but it
13046 qualifies them only if the message came from a host that matches
13047 \sender@_unqualified@_hosts\,
13048 or if the message was submitted locally (not using TCP/IP), and the \-bnq-\
13049 option was not set.
13050
13051 .conf smtp@_accept@_keepalive boolean true
13052 .index keepalive||on incoming connection
13053 This option controls the setting of the \\SO@_KEEPALIVE\\ option on incoming
13054 TCP/IP socket connections. When set, it causes the kernel to probe idle
13055 connections periodically, by sending packets with `old' sequence numbers. The
13056 other end of the connection should send an acknowledgement if the connection is
13057 still okay or a reset if the connection has been aborted. The reason for doing
13058 this is that it has the beneficial effect of freeing up certain types of
13059 connection that can get stuck when the remote host is disconnected without
13060 tidying up the TCP/IP call properly. The keepalive mechanism takes several
13061 hours to detect unreachable hosts.
13062
13063
13064 .conf smtp@_accept@_max integer 20
13065 .index limit||incoming SMTP connections
13066 .index SMTP||incoming connection count
13067 .index inetd
13068 This option specifies the maximum number of simultaneous incoming SMTP calls
13069 that Exim will accept. It applies only to the listening daemon; there is no
13070 control (in Exim) when incoming SMTP is being handled by \*inetd*\. If the value
13071 is set to zero, no limit is applied. However, it is required to be non-zero if
13072 either \smtp@_accept@_max@_per@_host\ or \smtp@_accept@_queue\ is set. See also
13073 \smtp@_accept@_reserve\.
13074
13075
13076 .conf smtp@_accept@_max@_nonmail integer 10
13077 .index limit||non-mail SMTP commands
13078 .index SMTP||limiting non-mail commands
13079 Exim counts the number of `non-mail' commands in an SMTP session, and drops the
13080 connection if there are too many. This option defines `too many'. The check
13081 catches some denial-of-service attacks, repeated failing \\AUTH\\s, or a mad
13082 client looping sending \\EHLO\\, for example. The check is applied only if the
13083 client host matches \smtp@_accept@_max@_nonmail@_hosts\.
13084
13085 When a new message is expected, one occurrence of \\RSET\\ is not counted. This
13086 allows a client to send one \\RSET\\ between messages (this is not necessary,
13087 but some clients do it). Exim also allows one uncounted occurence of \\HELO\\
13088 or \\EHLO\\, and one occurrence of \\STARTTLS\\ between messages. After
13089 starting up a TLS session, another \\EHLO\\ is expected, and so it too is not
13090 counted. The first occurrence of \\AUTH\\ in a connection, or immediately
13091 following \\STARTTLS\\ is not counted. Otherwise, all commands other than
13092 \\MAIL\\, \\RCPT\\, \\DATA\\, and \\QUIT\\ are counted.
13093
13094 .conf smtp@_accept@_max@_nonmail@_hosts "host list$**$" $*$
13095 You can control which hosts are subject to the \smtp@_accept@_max@_nonmail\
13096 check by setting this option. The default value makes it apply to all hosts. By
13097 changing the value, you can exclude any badly-behaved hosts that you have to
13098 live with.
13099
13100
13101 .conf smtp@_accept@_max@_per@_connection integer 1000
13102 .index SMTP||incoming message count, limiting
13103 .index limit||messages per SMTP connection
13104 The value of this option limits the number of \\MAIL\\ commands that Exim is
13105 prepared to accept over a single SMTP connection, whether or not each command
13106 results in the transfer of a message. After the limit is reached, a 421
13107 response is given to subsequent \\MAIL\\ commands. This limit is a safety
13108 precaution against a client that goes mad (incidents of this type have been
13109 seen).
13110
13111 .conf smtp@_accept@_max@_per@_host string$**$ unset
13112 .index limit||SMTP connections from one host
13113 .index host||limiting SMTP connections from
13114 This option restricts the number of simultaneous IP connections from a single
13115 host (strictly, from a single IP address) to the Exim daemon. The option is
13116 expanded, to enable different limits to be applied to different hosts by
13117 reference to \$sender@_host@_address$\. Once the limit is reached, additional
13118 connection attempts from the same host are rejected with error code 421. The
13119 default value of zero imposes no limit. If this option is set, it is required
13120 that \smtp@_accept@_max\ be non-zero.
13121
13122 \**Warning**\: When setting this option you should not use any expansion
13123 constructions that take an appreciable amount of time. The expansion and test
13124 happen in the main daemon loop, in order to reject additional connections
13125 without forking additional processes (otherwise a denial-of-service attack
13126 could cause a vast number or processes to be created). While the daemon is
13127 doing this processing, it cannot accept any other incoming connections.
13128
13129
13130 .conf smtp@_accept@_queue integer 0
13131 .index SMTP||incoming connection count
13132 .index queueing incoming messages
13133 .index message||queueing by SMTP connection count
13134 If the number of simultaneous incoming SMTP calls handled via the listening
13135 daemon exceeds this value, messages received by SMTP are just placed on the
13136 queue; no delivery processes are started automatically. A value of zero implies
13137 no limit, and clearly any non-zero value is useful only if it is less than the
13138 \smtp@_accept@_max\ value (unless that is zero). See also \queue@_only\,
13139 \queue@_only@_load\, \queue@_smtp@_domains\, and the various \-od-\ command
13140 line options.
13141
13142 .conf smtp@_accept@_queue@_per@_connection integer 10
13143 .index queueing incoming messages
13144 .index message||queueing by message count
13145 This option limits the number of delivery processes that Exim starts
13146 automatically when receiving messages via SMTP, whether via the daemon or by
13147 the use of \-bs-\ or \-bS-\. If the value of the option is greater than zero,
13148 and the number of messages received in a single SMTP session exceeds this
13149 number, subsequent messages are placed on the queue, but no delivery processes
13150 are started. This helps to limit the number of Exim processes when a server
13151 restarts after downtime and there is a lot of mail waiting for it on other
13152 systems. On large systems, the default should probably be increased, and on
13153 dial-in client systems it should probably be set to zero (that is, disabled).
13154
13155 .conf smtp@_accept@_reserve integer 0
13156 .index SMTP||incoming call count
13157 .index host||reserved
13158 When \smtp@_accept@_max\ is set greater than zero, this option specifies a
13159 number of SMTP connections that are reserved for connections from the hosts
13160 that are specified in \smtp@_reserve@_hosts\. The value set in
13161 \smtp@_accept@_max\ includes this reserve pool. The specified hosts are not
13162 restricted to this number of connections; the option specifies a minimum number
13163 of connection slots for them, not a maximum. It is a guarantee that that group
13164 of hosts can always get at least \smtp@_accept@_reserve\ connections.
13165
13166 For example, if \smtp@_accept@_max\ is set to 50 and \smtp@_accept@_reserve\ is
13167 set to 5, once there are 45 active connections (from any hosts), new
13168 connections are accepted only from hosts listed in \smtp@_reserve@_hosts\.
13169 See also \smtp@_accept@_max@_per@_host\.
13170
13171 .conf smtp@_active@_hostname string$**$ unset
13172 .index host||name in SMTP responses
13173 .index SMTP||host name in responses
13174 This option is provided for multi-homed servers that want to masquerade as
13175 several different hosts. At the start of an SMTP connection, its value is
13176 expanded and used instead of the value of \$primary@_hostname$\ in SMTP
13177 responses. For example, it is used as domain name in the response to an
13178 incoming \\HELO\\ or \\EHLO\\ command. 
13179 .em
13180 It is also used in \\HELO\\ commands for callout verification.
13181 The active hostname is placed in the \$smtp__active__hostname$\ variable, which 
13182 is saved with any messages that are received. It is therefore available for use 
13183 in routers and transports when the message is later delivered.
13184 .nem
13185
13186 If this option is unset, or if its expansion is forced to fail, or if the
13187 expansion results in an empty string, the value of \$primary@_hostname$\ is
13188 used. Other expansion failures cause a message to be written to the main and
13189 panic logs, and the SMTP command receives a temporary error. Typically, the
13190 value of \smtp@_active@_hostname\ depends on the incoming interface address.
13191 For example:
13192 .display asis
13193 smtp_active_hostname = ${if eq{$interface_address}{10.0.0.1}\
13194   {cox.mydomain}{box.mydomain}}
13195 .endd
13196
13197 .conf smtp@_banner string$**$ "see below"
13198 .index SMTP||welcome banner
13199 .index banner for SMTP
13200 .index welcome banner for SMTP
13201 .index customizing||SMTP banner
13202 This string, which is expanded every time it is used, is output as the initial
13203 positive response to an SMTP connection. The default setting is:
13204 .display asis
13205 .em
13206 smtp_banner = $smtp_active_hostname ESMTP Exim \
13207   $version_number $tod_full
13208 .nem   
13209 .endd
13210 Failure to expand the string causes a panic error. If you want to create a
13211 multiline response to the initial SMTP connection, use `@\n' in the string at
13212 appropriate points, but not at the end. Note that the 220 code is not included
13213 in this string. Exim adds it automatically (several times in the case of a
13214 multiline response).
13215
13216 .conf smtp@_check@_spool@_space boolean true
13217 .index checking disk space
13218 .index disk space, checking
13219 .index spool directory||checking space
13220 When this option is set, if an incoming SMTP session encounters the \\SIZE\\
13221 option on a \\MAIL\\ command, it checks that there is enough space in the
13222 spool directory's partition to accept a message of that size, while still
13223 leaving free the amount specified by \check@_spool@_space\ (even if that value
13224 is zero). If there isn't enough space, a temporary error code is returned.
13225
13226 .conf smtp@_connect@_backlog integer 20
13227 .index connection backlog
13228 .index SMTP||connection backlog
13229 .index backlog of connections
13230 This option specifies a maximum number of waiting SMTP connections. Exim passes
13231 this value to the TCP/IP system when it sets up its listener. Once this number
13232 of connections are waiting for the daemon's attention, subsequent connection
13233 attempts are refused at the TCP/IP level. At least, that is what the manuals
13234 say; in some circumstances such connection attempts have been observed to time
13235 out instead. For large systems it is probably a good idea to increase the
13236 value (to 50, say). It also gives some protection against denial-of-service
13237 attacks by SYN flooding.
13238
13239 .conf smtp@_enforce@_sync boolean true
13240 .index SMTP||synchronization checking
13241 .index synchronization checking in SMTP
13242 The SMTP protocol specification requires the client to wait for a response from
13243 the server at certain points in the dialogue. Without \\PIPELINING\\ these
13244 synchronization points are after every command; with \\PIPELINING\\ they are
13245 fewer, but they still exist. 
13246
13247 Some spamming sites send out a complete set of SMTP commands without waiting
13248 for any response. Exim protects against this by rejecting a message if the
13249 client has sent further input when it should not have. The error response `554
13250 SMTP synchronization error' is sent, and the connection is dropped. Testing for
13251 this error cannot be perfect because of transmission delays (unexpected input
13252 may be on its way but not yet received when Exim checks). However, it does
13253 detect many instances.
13254
13255 .em
13256 The check can be globally disabled by setting \smtp@_enforce@_sync\ false.
13257 If you want to disable the check selectively (for example, only for certain 
13258 hosts), you can do so by an appropriate use of a \control\ modifier in an ACL
13259 (see section ~~SECTcontrols). See also \pipelining@_advertise@_hosts\.
13260 .nem
13261
13262 .conf smtp@_etrn@_command string$**$ unset
13263 .index \\ETRN\\||command to be run
13264 If this option is set, the given command is run whenever an SMTP \\ETRN\\
13265 command is received from a host that is permitted to issue such commands (see
13266 chapter ~~CHAPACL). The string is split up into separate arguments which are
13267 independently expanded. The expansion variable \$domain$\ is set to the
13268 argument of the \\ETRN\\ command, and no syntax checking is done on it. For
13269 example:
13270 .display asis
13271 smtp_etrn_command = /etc/etrn_command $domain $sender_host_address
13272 .endd
13273 A new process is created to run the command, but Exim does not wait for it to
13274 complete. Consequently, its status cannot be checked. If the command cannot be
13275 run, a line is written to the panic log, but the \\ETRN\\ caller still receives
13276 a 250 success response. Exim is normally running under its own uid when
13277 receiving SMTP, so it is not possible for it to change the uid before running
13278 the command.
13279
13280 .conf smtp@_etrn@_serialize boolean true
13281 .index \\ETRN\\||serializing
13282 When this option is set, it prevents the simultaneous execution of more than
13283 one identical command as a result of \\ETRN\\ in an SMTP connection. See
13284 section ~~SECTETRN for details.
13285
13286 .conf smtp@_load@_reserve fixed-point unset
13287 .index load average
13288 If the system load average ever gets higher than this, incoming SMTP calls are
13289 accepted only from those hosts that match an entry in \smtp@_reserve@_hosts\.
13290 If \smtp@_reserve@_hosts\ is not set, no incoming SMTP calls are accepted when
13291 the load is over the limit. The option has no effect on ancient operating
13292 systems on which Exim cannot determine the load average. See also
13293 \deliver@_queue@_load@_max\ and \queue@_only@_load\.
13294
13295
13296 .conf smtp@_max@_synprot@_errors integer 3
13297 .index SMTP||limiting syntax and protocol errors
13298 .index limit||SMTP syntax and protocol errors
13299 Exim rejects SMTP commands that contain syntax or protocol errors. In
13300 particular, a syntactically invalid email address, as in this command:
13301 .display asis
13302 RCPT TO:<abc xyz@a.b.c>
13303 .endd
13304 causes immediate rejection of the command, before any other tests are done.
13305 (The ACL cannot be run if there is no valid address to set up for it.) An
13306 example of a protocol error is receiving \\RCPT\\ before \\MAIL\\. If there are
13307 too many syntax or protocol errors in one SMTP session, the connection is
13308 dropped. The limit is set by this option.
13309
13310 .index \\PIPELINING\\||expected errors
13311 When the \\PIPELINING\\ extension to SMTP is in use, some protocol errors are
13312 `expected', for instance, a \\RCPT\\ command after a rejected \\MAIL\\ command.
13313 Exim assumes that \\PIPELINING\\ will be used if it advertises it (see
13314 \pipelining@_advertise@_hosts\), and in this situation, `expected' errors do
13315 not count towards the limit.
13316
13317
13318 .conf smtp@_max@_unknown@_commands integer 3
13319 .index SMTP||limiting unknown commands
13320 .index limit||unknown SMTP commands
13321 If there are too many unrecognized commands in an incoming SMTP session, an
13322 Exim server drops the connection. This is a defence against some kinds of abuse
13323 that subvert web
13324 clients
13325 into making connections to SMTP ports; in these circumstances, a number of
13326 non-SMTP command lines are sent first.
13327
13328
13329 .conf smtp@_ratelimit@_hosts "host list$**$" unset
13330 .index SMTP||rate limiting
13331 .index limit||rate of message arrival
13332 .index \\RCPT\\||rate limiting
13333 Some sites find it helpful to be able to limit the rate at which certain hosts
13334 can send them messages, and the rate at which an individual message can specify
13335 recipients. When a host matches \smtp@_ratelimit@_hosts\, the values of
13336 \smtp@_ratelimit@_mail\ and \smtp@_ratelimit@_rcpt\ are used to control the
13337 rate of acceptance of \\MAIL\\ and \\RCPT\\ commands in a single SMTP session,
13338 respectively. Each option, if set, must contain a set of four comma-separated
13339 values:
13340 .numberpars $.
13341 A threshold, before which there is no rate limiting.
13342 .nextp
13343 An initial time delay. Unlike other times in Exim, numbers with decimal
13344 fractional parts are allowed here.
13345 .nextp
13346 A factor by which to increase the delay each time.
13347 .nextp
13348 A maximum value for the delay. This should normally be less than 5 minutes,
13349 because after that time, the client is liable to timeout the SMTP command.
13350 .endp
13351 For example, these settings have been used successfully at the site which
13352 first suggested this feature, for controlling mail from their customers:
13353 .display asis
13354 smtp_ratelimit_mail = 2,0.5s,1.05,4m
13355 smtp_ratelimit_rcpt = 4,0.25s,1.015,4m
13356 .endd
13357 The first setting specifies delays that are applied to \\MAIL\\ commands after
13358 two have been received over a single connection. The initial delay is 0.5
13359 seconds, increasing by a factor of 1.05 each time. The second setting applies
13360 delays to \\RCPT\\ commands when more than four occur in a single message.
13361
13362 It is also possible to configure delays explicitly in ACLs. See section
13363 ~~SECTACLmodi for details.
13364
13365
13366 .conf smtp@_ratelimit@_mail string unset
13367 See \smtp@_ratelimit@_hosts\ above.
13368
13369 .conf smtp@_ratelimit@_rcpt string unset
13370 See \smtp@_ratelimit@_hosts\ above.
13371
13372 .conf smtp@_receive@_timeout time 5m
13373 .index timeout||for SMTP input
13374 .index SMTP||timeout, input
13375 This sets a timeout value for SMTP reception. It applies to all forms of SMTP
13376 input, including batch SMTP. If a line of input (either an SMTP command or a
13377 data line) is not received within this time, the SMTP connection is dropped and
13378 the message is abandoned.
13379 A line is written to the log containing one of the following messages:
13380 .display asis
13381 SMTP command timeout on connection from...
13382 SMTP data timeout on connection from...
13383 .endd
13384 The former means that Exim was expecting to read an SMTP command; the latter
13385 means that it was in the \\DATA\\ phase, reading the contents of a message.
13386
13387
13388 .index \-os-\ option
13389 The value set by this option can be overridden by the
13390 \-os-\ command-line option. A setting of zero time disables the timeout, but
13391 this should never be used for SMTP over TCP/IP. (It can be useful in some cases
13392 of local input using \-bs-\ or \-bS-\.) For non-SMTP input, the reception
13393 timeout is controlled by \receive@_timeout\ and \-or-\.
13394
13395 .conf smtp@_reserve@_hosts "host list$**$" unset
13396 This option defines hosts for which SMTP connections are reserved; see
13397 \smtp@_accept@_reserve\ and \smtp@_load@_reserve\ above.
13398
13399 .conf smtp@_return@_error@_details boolean false
13400 .index SMTP||details policy failures
13401 .index policy control||rejection, returning details
13402 In the default state, Exim uses bland messages such as
13403 `Administrative prohibition' when it rejects SMTP commands for policy
13404 reasons. Many sysadmins like this because it gives away little information
13405 to spammers. However, some other syadmins who are applying strict checking
13406 policies want to give out much fuller information about failures. Setting
13407 \smtp@_return@_error@_details\ true causes Exim to be more forthcoming. For
13408 example, instead of `Administrative prohibition', it might give:
13409 .display asis
13410 550-Rejected after DATA: '>' missing at end of address:
13411 550 failing address in "From" header is: <user@dom.ain
13412 .endd
13413
13414 .em
13415 .conf spamd@_address string "$tt{127.0.0.1 783}"
13416 This option is available when Exim is compiled with the content-scanning
13417 extension. It specifies how Exim connects to SpamAssassin's \spamd\ daemon. See
13418 section ~~SECTscanspamass for more details.
13419 .nem
13420
13421 .conf split@_spool@_directory boolean false
13422 .index multiple spool directories
13423 .index spool directory||split
13424 .index directories, multiple
13425 If this option is set, it causes Exim to split its input directory into 62
13426 subdirectories, each with a single alphanumeric character as its name. The
13427 sixth character of the message id is used to allocate messages to
13428 subdirectories; this is the least significant base-62 digit of the time of
13429 arrival of the message.
13430
13431 Splitting up the spool in this way may provide better performance on systems
13432 where there are long mail queues, by reducing the number of files in any one
13433 directory. The msglog directory is also split up in a similar way to the input
13434 directory; however, if \preserve@_message@_logs\ is set, all old msglog files
13435 are still placed in the single directory \(msglog.OLD)\.
13436
13437 It is not necessary to take any special action for existing messages when
13438 changing \split@_spool@_directory\. Exim notices messages that are in the
13439 `wrong' place, and continues to process them. If the option is turned off after
13440 a period of being on, the subdirectories will eventually empty and be
13441 automatically deleted.
13442
13443 When \split@_spool@_directory\ is set, the behaviour of queue runner processes
13444 changes. Instead of creating a list of all messages in the queue, and then
13445 trying to deliver each one in turn, it constructs a list of those in one
13446 sub-directory and tries to deliver them, before moving on to the next
13447 sub-directory. The sub-directories are processed in a random order. This
13448 spreads out the scanning of the input directories, and uses less memory. It is
13449 particularly beneficial when there are lots of messages on the queue. However,
13450 if \queue@_run@_in@_order\ is set, none of this new processing happens. The
13451 entire queue has to be scanned and sorted before any deliveries can start.
13452
13453 .conf spool@_directory string$**$ "set at compile time"
13454 .index spool directory||path to
13455 This defines the directory in which Exim keeps its spool, that is, the messages
13456 it is waiting to deliver. The default value is taken from the compile-time
13457 configuration setting, if there is one. If not, this option must be set. The
13458 string is expanded, so it can contain, for example, a reference to
13459 \$primary@_hostname$\.
13460
13461 If the spool directory name is fixed on your installation, it is recommended
13462 that you set it at build time rather than from this option, particularly if the
13463 log files are being written to the spool directory (see \log@_file@_path\).
13464 Otherwise log files cannot be used for errors that are detected early on, such
13465 as failures in the configuration file.
13466
13467 By using this option to override the compiled-in path, it is possible to run
13468 tests of Exim without using the standard spool.
13469
13470 .conf strip@_excess@_angle@_brackets boolean false
13471 .index angle brackets, excess
13472 If this option is set, redundant pairs of angle brackets round `route-addr'
13473 items in addresses are stripped. For example, \*@<@<xxx@@a.b.c.d@>@>*\ is treated
13474 as \*@<xxx@@a.b.c.d@>*\. If this is in the envelope and the message is passed on
13475 to another MTA, the excess angle brackets are not passed on. If this option is
13476 not set, multiple pairs of angle brackets cause a syntax error.
13477
13478 .conf strip@_trailing@_dot boolean false
13479 .index trailing dot on domain
13480 .index dot||trailing on domain
13481 If this option is set, a trailing dot at the end of a domain in an address is
13482 ignored. If this is in the envelope and the message is passed on to another
13483 MTA, the dot is not passed on. If this option is not set, a dot at the end of a
13484 domain causes a syntax error.
13485 However, addresses in header lines are checked only when an ACL requests header
13486 syntax checking.
13487
13488 .conf syslog@_duplication boolean true
13489 .index syslog||duplicate log lines, suppressing
13490 When Exim is logging to syslog, it writes the log lines for its three
13491 separate logs at different syslog priorities so that they can in principle
13492 be separated on the logging hosts. Some installations do not require this
13493 separation, and in those cases, the duplication of certain log lines is a
13494 nuisance. If \syslog@_duplication\ is set false, only one copy of any
13495 particular log line is written to syslog. For lines that normally go to
13496 both the main log and the reject log, the reject log version (possibly
13497 containing message header lines) is written, at \\LOG@_NOTICE\\ priority.
13498 Lines that normally go to both the main and the panic log are written at
13499 the \\LOG@_ALERT\\ priority.
13500
13501 .conf syslog@_facility string unset
13502 .index syslog||facility, setting
13503 This option sets the syslog `facility' name, used when Exim is logging to
13504 syslog. The value must be one of the strings `mail', `user', `news', `uucp',
13505 `daemon', or `local\*x*\' where \*x*\ is a digit between 0 and 7. If this
13506 option is unset, `mail' is used. See chapter ~~CHAPlog for details of Exim's
13507 logging.
13508
13509
13510 .conf syslog@_processname string "$tt{exim}"
13511 .index syslog||process name, setting
13512 This option sets the syslog `ident' name, used when Exim is logging to syslog.
13513 The value must be no longer than 32 characters. See chapter ~~CHAPlog for
13514 details of Exim's logging.
13515
13516
13517 .conf syslog@_timestamp boolean true
13518 .index syslog||timestamps
13519 If \syslog@_timestamp\ is set false, the timestamps on Exim's log lines are
13520 omitted when these lines are sent to syslog. See chapter ~~CHAPlog for
13521 details of Exim's logging.
13522
13523 .conf system@_filter string$**$ unset
13524 .index filter||system filter
13525 .index system filter||specifying
13526 .index Sieve filter||not available for system filter
13527 This option specifies an Exim filter file that is applied to all messages at
13528 the start of each delivery attempt, before any routing is done. System filters
13529 must be Exim filters; they cannot be Sieve filters. If the system filter
13530 generates any deliveries to files or pipes, or any new mail messages, the
13531 appropriate \system@_filter@_...@_transport\ option(s) must be set, to define
13532 which transports are to be used. Details of this facility are given in chapter
13533 ~~CHAPsystemfilter.
13534
13535 .conf system@_filter@_directory@_transport string$**$ unset
13536 This sets the name of the transport driver that is to be used when the
13537 \save\ command in a system message filter specifies a path ending in `/',
13538 implying delivery of each message into a separate file in some directory.
13539 During the delivery, the variable \$address@_file$\ contains the path name.
13540
13541 .conf system@_filter@_file@_transport string$**$ unset
13542 .index file||transport for system filter
13543 This sets the name of the transport driver that is to be used when the \save\
13544 command in a system message filter specifies a path not ending in `/'. During
13545 the delivery, the variable \$address@_file$\ contains the path name.
13546
13547 .index gid (group id)||system filter
13548 .conf system@_filter@_group string unset
13549 This option is used only when \system@_filter@_user\ is also set. It sets the
13550 gid under which the system filter is run, overriding any gid that is associated
13551 with the user. The value may be numerical or symbolic.
13552
13553 .conf system@_filter@_pipe@_transport string$**$ unset 7
13554 .index \%pipe%\ transport||for system filter
13555 This specifies the transport driver that is to be used when a \pipe\ command is
13556 used in a system filter. During the delivery, the variable \$address@_pipe$\
13557 contains the pipe command.
13558
13559 .conf system@_filter@_reply@_transport string$**$ unset
13560 .index \%autoreply%\ transport||for system filter
13561 This specifies the transport driver that is to be used when a \mail\ command is
13562 used in a system filter.
13563
13564 .index uid (user id)||system filter
13565 .conf system@_filter@_user string unset
13566 If this option is not set, the system filter is run in the main Exim delivery
13567 process, as root. When the option is set, the system filter runs in a separate
13568 process, as the given user. Unless the string consists entirely of digits, it
13569 is looked up in the password data. Failure to find the named user causes a
13570 configuration error. The gid is either taken from the password data, or
13571 specified by \system@_filter@_group\. When the uid is specified numerically,
13572 \system@_filter@_group\ is required to be set.
13573
13574 If the system filter generates any pipe, file, or reply deliveries, the uid
13575 under which the filter is run is used when transporting them, unless a
13576 transport option overrides.
13577 Normally you should set \system@_filter@_user\ if your system filter generates
13578 these kinds of delivery.
13579
13580 .conf tcp@_nodelay boolean true
13581 .index daemon||\\TCP@_NODELAY\\ on sockets
13582 .index Nagle algorithm
13583 .index \\TCP@_NODELAY\\ on listening sockets
13584 If this option is set false, it stops the Exim daemon setting the
13585 \\TCP@_NODELAY\\ option on its listening sockets. Setting \\TCP@_NODELAY\\
13586 turns off the `Nagle algorithm', which is a way of improving network
13587 performance in interactive (character-by-character) situations. Turning it off
13588 should improve Exim's performance a bit, so that is what happens by default.
13589 However, it appears that some broken clients cannot cope, and time out. Hence
13590 this option. It affects only those sockets that are set up for listening by the
13591 daemon. Sockets created by the smtp transport for delivering mail always set
13592 \\TCP@_NODELAY\\.
13593
13594 .conf timeout@_frozen@_after time 0s
13595 .index frozen messages||timing out
13596 .index timeout||frozen messages
13597 If \timeout@_frozen@_after\ is set to a time greater than zero, a frozen
13598 message of any kind that has been on the queue for longer than the given
13599 time is automatically cancelled at the next queue run. If it is a bounce
13600 message, it is just discarded; otherwise, a bounce is sent to the sender, in a
13601 similar manner to cancellation by the \-Mg-\ command line option. If you want
13602 to timeout frozen bounce messages earlier than other kinds of frozen message,
13603 see \ignore@_bounce@_errors@_after\.
13604
13605 .conf timezone string unset
13606 .index timezone, setting
13607 The value of \timezone\ is used to set the environment variable \\TZ\\ while
13608 running Exim (if it is different on entry). This ensures that all timestamps
13609 created by Exim are in the required timezone. If you want all your timestamps
13610 to be in UTC (aka GMT) you should set
13611 .display asis
13612 timezone = UTC
13613 .endd
13614 The default value is taken from \\TIMEZONE@_DEFAULT\\ in \(Local/Makefile)\,
13615 or, if that is not set, from the value of the TZ environment variable when Exim
13616 is built. If \timezone\ is set to the empty string, either at build or run
13617 time, any existing \\TZ\\ variable is removed from the environment when Exim
13618 runs. This is appropriate behaviour for obtaining wall-clock time on some, but
13619 unfortunately not all, operating systems.
13620
13621 .conf tls@_advertise@_hosts "host list$**$" unset
13622 .index TLS||advertising
13623 .index encryption||on SMTP connection
13624 .index SMTP||encrypted connection
13625 When Exim is built with support for TLS encrypted connections, the availability
13626 of the \\STARTTLS\\ command to set up an encrypted session is advertised in
13627 response to \\EHLO\\ only to those client hosts that match this option. See
13628 chapter ~~CHAPTLS for details of Exim's support for TLS.
13629
13630 .conf tls@_certificate string$**$ unset
13631 .index TLS||server certificate, location of
13632 .index certificate||for server, location of
13633 The value of this option is expanded, and must then be the absolute path to a
13634 file which contains the server's certificates. The server's private key is also
13635 assumed to be in this file if \tls@_privatekey\ is unset. See chapter ~~CHAPTLS
13636 for further details.
13637
13638 \**Note**\: The certificates defined by this option are used only when Exim is
13639 receiving incoming messages as a server. If you want to supply certificates for
13640 use when sending messages as a client, you must set the \tls@_certificate\
13641 option in the relevant \%smtp%\ transport.
13642
13643 .conf tls@_crl string$**$ unset
13644 .index TLS||server certificate revocation list
13645 .index certificate||revocation list for server
13646 This option specifies a certificate revocation list. The expanded value must
13647 be the name of a file that contains a CRL in PEM format.
13648
13649 .conf tls@_dhparam string$**$ unset
13650 .index TLS||D-H parameters for server
13651 The value of this option is expanded, and must then be the absolute path to
13652 a file which contains the server's DH parameter values.
13653 This is used only for OpenSSL. When Exim is linked with GnuTLS, this option is
13654 ignored. See section ~~SECTopenvsgnu for further details.
13655
13656 .em
13657 .conf tls@_on@_connect@_ports "string list" unset
13658 This option specifies a list of incoming SSMTP (aka SMTPS) ports that should
13659 operate the obsolete SSMTP (SMTPS) protocol, where a TLS session is immediately
13660 set up without waiting for the client to issue a \\STARTTLS\\ command. For
13661 further details, see section ~~SECTsupobssmt.
13662 .nem
13663
13664 .conf tls@_privatekey string$**$ unset
13665 .index TLS||server private key, location of
13666 The value of this option is expanded, and must then be the absolute path to a
13667 file which contains the server's private key. If this option is unset, the
13668 private key is assumed to be in the same file as the server's certificates. See
13669 chapter ~~CHAPTLS for further details.
13670
13671 .conf tls@_remember@_esmtp boolean false
13672 .index TLS||esmtp state, remembering
13673 .index TLS||broken clients
13674 If this option is set true, Exim violates the RFCs by remembering that it is in
13675 `esmtp' state after successfully negotiating a TLS session. This provides
13676 support for broken clients that fail to send a new \\EHLO\\ after starting a
13677 TLS session.
13678
13679 .conf tls@_require@_ciphers string$**$ unset
13680 .index TLS||requiring specific ciphers
13681 .index cipher||requiring specific
13682 This option controls which ciphers can be used for incoming TLS connections.
13683 The \%smtp%\ transport has an option of the same name for controlling outgoing
13684 connections. This option is expanded for each connection, so can be varied for
13685 different clients if required. The value of this option must be a list of
13686 permitted cipher suites. The OpenSSL and GnuTLS libraries handle cipher control
13687 in somewhat different ways.
13688 .em
13689 If GnuTLS is being used, the client controls the preference order of the
13690 available ciphers.
13691 .nem
13692 Details are given in sections ~~SECTreqciphssl and ~~SECTreqciphgnu.
13693
13694 .conf tls@_try@_verify@_hosts "host list$**$" unset
13695 .index TLS||client certificate verification
13696 .index certificate||verification of client
13697 See \tls@_verify@_hosts\ below.
13698
13699 .conf tls@_verify@_certificates string$**$ unset
13700 .index TLS||client certificate verification
13701 .index certificate||verification of client
13702 The value of this option is expanded, and must then be the absolute path to
13703 a file containing permitted certificates for clients that
13704 match \tls@_verify@_hosts\ or \tls@_try@_verify@_hosts\. Alternatively, if you
13705 are using OpenSSL, you can set \tls@_verify@_certificates\ to the name of a
13706 directory containing certificate files. This does not work with GnuTLS; the
13707 option must be set to the name of a single file if you are using GnuTLS.
13708
13709 .conf tls@_verify@_hosts "host list$**$" unset
13710 .index TLS||client certificate verification
13711 .index certificate||verification of client
13712 This option, along with \tls@_try@_verify@_hosts\, controls the checking of
13713 certificates from clients.
13714 The expected certificates are defined by \tls@_verify@_certificates\, which
13715 must be set. A configuration error occurs if either \tls@_verify@_hosts\ or
13716 \tls@_try@_verify@_hosts\ is set and \tls@_verify@_certificates\ is not set.
13717
13718 Any client that matches \tls@_verify@_hosts\ is constrained by
13719 \tls@_verify@_certificates\. The client must present one of the listed
13720 certificates. If it does not, the connection is aborted.
13721
13722 A weaker form of checking is provided by \tls@_try@_verify@_hosts\. If a client
13723 matches this option (but not \tls@_verify@_hosts\), Exim requests a
13724 certificate and checks it against \tls@_verify@_certificates\, but does not
13725 abort the connection if there is no certificate or if it does not match. This
13726 state can be detected in an ACL, which makes it possible to implement policies
13727 such as `accept for relay only if a verified certificate has been received, but
13728 accept for local delivery if encrypted, even without a verified certificate'.
13729
13730 Client hosts that match neither of these lists are not asked to present
13731 certificates.
13732
13733 .conf trusted@_groups "string list" unset
13734 .index trusted group
13735 .index group||trusted
13736 If this option is set, any process that is running in one of the listed groups,
13737 or which has one of them as a supplementary group, is trusted.
13738 The groups can be specified numerically or by name.
13739 See section ~~SECTtrustedadmin for details of what trusted callers are
13740 permitted to do. If neither \trusted@_groups\ nor \trusted@_users\ is set, only
13741 root and the Exim user are trusted.
13742
13743 .conf trusted@_users "string list" unset
13744 .index trusted user
13745 .index user||trusted
13746 If this option is set, any process that is running as one of the listed users
13747 is trusted.
13748 The users can be specified numerically or by name.
13749 See section ~~SECTtrustedadmin for details of what trusted callers are
13750 permitted to do. If neither \trusted@_groups\ nor \trusted@_users\ is set, only
13751 root and the Exim user are trusted.
13752
13753 .index uid (user id)||unknown caller
13754 .conf unknown@_login string$**$ unset
13755 This is a specialized feature for use in unusual configurations. By default, if
13756 the uid of the caller of Exim cannot be looked up using \*getpwuid()*\, Exim
13757 gives up. The \unknown@_login\ option can be used to set a login name to be
13758 used in this circumstance. It is expanded, so values like \user@$caller@_uid\
13759 can be set. When \unknown@_login\ is used, the value of \unknown@_username\ is
13760 used for the user's real name (gecos field), unless this has been set by the
13761 \-F-\ option.
13762
13763 .conf unknown@_username string unset
13764 See \unknown@_login\.
13765
13766 .conf untrusted@_set@_sender "address list$**$" unset
13767 .index trusted user
13768 .index sender||setting by untrusted user
13769 .index untrusted user, setting sender
13770 .index user||untrusted setting sender
13771 .index envelope sender
13772 When an untrusted user submits a message to Exim using the standard input, Exim
13773 normally creates an envelope sender address from the user's login and the
13774 default qualification domain. Data from the \-f-\ option (for setting envelope
13775 senders on non-SMTP messages) or the SMTP \\MAIL\\ command (if \-bs-\ or \-bS-\
13776 is used) is ignored.
13777
13778 However, untrusted users are permitted to set an empty envelope sender address,
13779 to declare that a message should never generate any bounces. For example:
13780 .display asis
13781 exim -f '<>' user@domain.example
13782 .endd
13783 The \untrusted@_set@_sender\ option allows you to permit untrusted users to set
13784 other envelope sender addresses in a controlled way. When it is set, untrusted
13785 users are allowed to set envelope sender addresses that match any of the
13786 patterns in the list. Like all address lists, the string is expanded. The
13787 identity of the user is in \$sender@_ident$\, so you can, for example, restrict
13788 users to setting senders that start with their login ids
13789 followed by a hyphen
13790 by a setting like this:
13791 .display asis
13792 untrusted_set_sender = ^$sender_ident-
13793 .endd
13794 If you want to allow untrusted users to set envelope sender addresses without
13795 restriction, you can use
13796 .display asis
13797 untrusted_set_sender = *
13798 .endd
13799 The \untrusted@_set@_sender\ option applies to all forms of local input, but
13800 only to the setting of the envelope sender. It does not permit untrusted users
13801 to use the other options which trusted user can use to override message
13802 parameters. Furthermore, it does not stop Exim from removing an existing
13803 ::Sender:: header in the message, or from adding a ::Sender:: header if
13804 necessary. See \local__sender__retain\ and \local@_from@_check\ for ways of
13805 overriding these actions. The handling of the ::Sender:: header is also
13806 described in section ~~SECTthesenhea.
13807
13808 The log line for a message's arrival shows the envelope sender following `<='.
13809 For local messages, the user's login always follows, after `U='. In \-bp-\
13810 displays, and in the Exim monitor, if an untrusted user sets an envelope sender
13811 address, the user's login is shown in parentheses after the sender address.
13812
13813 .conf uucp@_from@_pattern string "see below"
13814 .index `From' line
13815 .index UUCP||`From' line
13816 Some applications that pass messages to an MTA via a command line interface use
13817 an initial line starting with `From' to pass the envelope sender. In
13818 particular, this is used by UUCP software. Exim recognizes such a line by means
13819 of a regular expression that is set in \uucp@_from@_pattern\. When the pattern
13820 matches, the sender address is constructed by expanding the contents of
13821 \uucp@_from@_sender\, provided that the caller of Exim is a trusted user. The
13822 default pattern recognizes lines in the following two forms:
13823 .display asis
13824    From ph10 Fri Jan  5 12:35 GMT 1996
13825    From ph10 Fri, 7 Jan 97 14:00:00 GMT
13826 .endd
13827 The pattern can be seen by running
13828 .display asis
13829 exim -bP uucp_from_pattern
13830 .endd
13831 It checks only up to the hours and minutes, and allows for a 2-digit or 4-digit
13832 year in the second case. The first word after `From' is matched in the regular
13833 expression by a parenthesized subpattern. The default value for
13834 \uucp@_from@_sender\ is `$1', which therefore just uses this first word (`ph10'
13835 in the example above) as the message's sender. See also
13836 \ignore@_fromline@_hosts\.
13837
13838 .conf uucp@_from@_sender string$**$ "$tt{@$1}"
13839 See \uucp@_from@_pattern\ above.
13840
13841 .conf warn@_message@_file string unset
13842 .index warning of delay||customizing the message
13843 .index customizing||warning message
13844 This option defines a template file containing paragraphs of text to be used
13845 for constructing the warning message which is sent by Exim when a message has
13846 been on the queue for a specified amount of time, as specified by
13847 \delay@_warning\. Details of the file's contents are given in chapter
13848 ~~CHAPemsgcust. See also \bounce@_message@_file\.
13849
13850 .conf write@_rejectlog boolean true
13851 .index reject log||disabling
13852 If this option is set false, Exim no longer writes anything to the reject log.
13853 See chapter ~~CHAPlog for details of what Exim writes to its logs.
13854
13855 .endconf
13856
13857
13858
13859 .
13860 .
13861 .
13862 .
13863 . ============================================================================
13864 .chapter Generic options for routers
13865 .rset CHAProutergeneric "~~chapter"
13866 .set runningfoot "generic router options"
13867 .index options||generic, for routers
13868 .index generic options||router
13869
13870 This chapter describes the generic options that apply to all routers,
13871 identifying those that are preconditions. For a general description of how a
13872 router operates, see sections ~~SECTrunindrou and ~~SECTrouprecon. The latter
13873 specifies the order in which the preconditions are tested. The order of
13874 expansion of the options that provide data for a transport is: \errors@_to\,
13875 \headers@_add\, \headers@_remove\, \transport\.
13876
13877 .startconf routers
13878
13879 .conf address@_data string$**$ unset
13880 .index router||data attached to address
13881 The string is expanded just before the router is run, that is, after all the
13882 precondition tests have succeeded. If the expansion is forced to fail, the
13883 router declines. Other expansion failures cause delivery of the address to be
13884 deferred.
13885
13886 When the expansion succeeds, the value is retained with the address, and can be
13887 accessed using the variable \$address@_data$\ in the current router, subsequent
13888 routers, and the eventual transport.
13889
13890 \**Warning**\: if the current or any subsequent router is a \%redirect%\ router
13891 that runs a user's filter file, the contents of \$address@_data$\ are
13892 accessible in the filter. This is not normally a problem, because such data is
13893 usually either not confidential or it `belongs' to the current user, but if you
13894 do put confidential data into \$address@_data$\ you need to remember this
13895 point.
13896
13897 Even if the router declines or passes, the value of \$address@_data$\ remains
13898 with the address, though it can be changed by another \address@_data\ setting
13899 on a subsequent router. If a router generates child addresses, the value of
13900 \$address@_data$\ propagates to them. This also applies to the special kind of
13901 `child' that is generated by a router with the \unseen\ option.
13902
13903 The idea of \address@_data\ is that you can use it to look up a lot of data for
13904 the address once, and then pick out parts of the data later. For example, you
13905 could use a single LDAP lookup to return a string of the form
13906 .display asis
13907 uid=1234 gid=5678 mailbox=/mail/xyz forward=/home/xyz/.forward
13908 .endd
13909 In the transport you could pick out the mailbox by a setting such as
13910 .display asis
13911 file = ${extract{mailbox}{$address_data}}
13912 .endd
13913 This makes the configuration file less messy, and also reduces the number of
13914 lookups (though Exim does cache lookups).
13915
13916 The \address@_data\ facility is also useful as a means of passing information
13917 from one router to another, and from a router to a transport. In addition, if
13918 .em
13919 \$address@_data$\ is set by a router when verifying a recipient address from an
13920 ACL, it remains available for use in the rest of the ACL statement. After
13921 verifying a sender, the value is transferred to \$sender@_address@_data$\.
13922 .nem
13923
13924
13925 .conf address@_test "boolean (precondition)" true
13926 .index \-bt-\ option
13927 .index router||skipping when address testing
13928 If this option is set false, the router is skipped when routing is being tested
13929 by means of the \-bt-\ command line option. This can be a convenience when your
13930 first router sends messages to an external scanner, because it saves you
13931 having to set the `already scanned' indicator when testing real address
13932 routing.
13933
13934
13935 .conf cannot@_route@_message string$**$ unset
13936 .index router||customizing `cannot route' message
13937 .index customizing||`cannot route' message
13938 This option specifies a text message that is used when an address cannot be
13939 routed because Exim has run out of routers. The default message is `Unrouteable
13940 address'. This option is useful only on routers that have \more\ set false, or
13941 on the very last router in a configuration, because the value that is used is
13942 taken from the last router that inspects an address. For example, using the
13943 default configuration, you could put:
13944 .display asis
13945 cannot_route_message = Remote domain not found in DNS
13946 .endd
13947 on the first (\%dnslookup%\) router, and
13948 .display asis
13949 cannot_route_message = Unknown local user
13950 .endd
13951 on the final router that checks for local users. If string expansion fails, the
13952 default message is used.
13953 Unless the expansion failure was explicitly forced, a message about the failure
13954 is written to the main and panic logs, in addition to the normal message about
13955 the routing failure.
13956
13957 .conf caseful@_local@_part boolean false
13958 .index case of local parts
13959 .index router||case of local parts
13960 By default, routers handle the local parts of addresses in a case-insensitive
13961 manner, though the actual case is preserved for transmission with the message.
13962 If you want the case of letters to be significant in a router, you must set
13963 this option true. For individual router options that contain address or local
13964 part lists (for example, \local@_parts\), case-sensitive matching can be turned
13965 on by `+caseful' as a list item. See section ~~SECTcasletadd for more details.
13966
13967 .em
13968 The value of the \$local@_part$\ variable is forced to lower case while a
13969 router is running unless \caseful@_local@_part\ is set. When a router assigns
13970 an address to a transport, the value of \$local@_part$\ when the transport runs
13971 is the same as it was in the router. Similarly, when a router generates child 
13972 addresses by aliasing or forwarding, the values of \$original@_local@_part$\
13973 and \$parent@_local@_part$\ are those that were used by the redirecting router.
13974
13975 This option applies to the processing of an address by a router. When a 
13976 recipient address is being processed in an ACL, there is a separate \control\ 
13977 modifier that can be used to specify case-sensitive processing within the ACL
13978 (see section ~~SECTcontrols).
13979 .nem
13980
13981 .conf check@_local@_user "boolean (precondition)" false
13982 .index local user, checking in router
13983 .index router||checking for local user
13984 .index \(/etc/passwd)\
13985 When this option is true, Exim checks that the local part of the recipient
13986 address (with affixes removed if relevant) is the name of an account on the
13987 local system. The check is done by calling the \*getpwnam()*\ function rather
13988 than trying to read \(/etc/passwd)\ directly. This means that other methods of
13989 holding password data (such as NIS) are supported. If the local part is a local
13990 user, \$home$\ is set from the password data, and can be tested in other
13991 preconditions that are evaluated after this one (the order of evaluation is
13992 given in section ~~SECTrouprecon). However, the value of \$home$\ can be
13993 overridden by \router@_home@_directory\. If the local part is not a local user,
13994 the router is skipped.
13995
13996 If you want to check that the local part is either the name of a local user
13997 or matches something else, you cannot combine \check@_local@_user\ with a
13998 setting of \local@_parts\, because that specifies the logical \*and*\ of the
13999 two conditions. However, you can use a \%passwd%\ lookup in a \local@_parts\
14000 setting to achieve this. For example:
14001 .display asis
14002 local_parts = passwd;$local_part : lsearch;/etc/other/users
14003 .endd
14004 Note, however, that the side effects of \check@_local@_user\ (such as setting
14005 up a home directory) do not occur when a \%passwd%\ lookup is used in a
14006 \local@_parts\ (or any other) precondition.
14007
14008
14009 .conf condition "string$**$ (precondition)"  unset
14010 .index router||customized precondition
14011 This option specifies a general precondition test that has to succeed for the
14012 router to be called. The \condition\ option is the last precondition to be
14013 evaluated (see section ~~SECTrouprecon). The string is expanded, and if the
14014 result is a forced failure, or an empty string, or one of the strings `0' or
14015 `no' or `false' (checked without regard to the case of the letters), the router
14016 is skipped, and the address is offered to the next one.
14017 .em
14018 If the result is any other value, the router is run (as this is the last
14019 precondition to be evaluated, all the other preconditions must be true).
14020
14021 The \condition\ option provides a means of applying custom conditions to the
14022 running of routers. Note that in the case of a simple conditional expansion,
14023 the default expansion values are exactly what is wanted. For example:
14024 .display asis
14025 condition = ${if >{$message_age}{600}}
14026 .endd
14027 Because of the default behaviour of the string expansion, this is equivalent to
14028 .display asis
14029 condition = ${if >{$message_age}{600}{true}{}}
14030 .endd
14031 .nem
14032
14033 If the expansion fails (other than forced failure) delivery is deferred. Some
14034 of the other precondition options are common special cases that could in fact
14035 be specified using \condition\. 
14036
14037
14038 .conf debug@_print string$**$ unset
14039 .index testing||variables in drivers
14040 If this option is set and debugging is enabled (see the \-d-\ command line
14041 option), the string is expanded and included in the debugging output.
14042 If expansion of the string fails, the error message is written to the debugging
14043 output, and Exim carries on processing.
14044 This option is provided to help with checking out the values of variables and
14045 so on when debugging router configurations. For example, if a \condition\
14046 option appears not to be working, \debug@_print\ can be used to output the
14047 variables it references. The output happens after checks for \domains\,
14048 \local@_parts\, and \check@_local@_user\ but before any other preconditions are
14049 tested. A newline is added to the text if it does not end with one.
14050
14051
14052 .conf disable@_logging boolean false
14053 If this option is set true, nothing is logged for any routing errors
14054 or for any deliveries caused by this router. You should not set this option
14055 unless you really, really know what you are doing. See also the generic
14056 transport option of the same name.
14057
14058 .conf domains "domain list$**$ (precondition)" unset
14059 .index router||restricting to specific domains
14060 If this option is set, the router is skipped unless the current domain matches
14061 the list. If the match is achieved by means of a file lookup, the data that the
14062 lookup returned for the domain is placed in \$domain@_data$\ for use in string
14063 expansions of the driver's private options.
14064 See section ~~SECTrouprecon for a list of the order in which preconditions
14065 are evaluated.
14066
14067
14068 .conf driver string unset
14069 This option must always be set. It specifies which of the available routers is
14070 to be used.
14071
14072
14073 .conf errors@_to string$**$ unset
14074 .index envelope sender
14075 .index router||changing address for errors
14076 If a router successfully handles an address, it may queue the address for
14077 delivery or it may generate child addresses. In both cases, if there is a
14078 delivery problem during later processing, the resulting bounce message is sent
14079 to the address that results from expanding this string, provided that the
14080 address verifies successfully.
14081 \errors@_to\ is expanded before \headers@_add\, \headers@_remove\, and
14082 \transport\.
14083
14084 If the option is unset, or the expansion is forced to fail, or the result of
14085 the expansion fails to verify, the errors address associated with the incoming
14086 address is used. At top level, this is the envelope sender. A non-forced
14087 expansion failure causes delivery to be deferred.
14088
14089 If an address for which \errors@_to\ has been set ends up being delivered over
14090 SMTP, the envelope sender for that delivery is the \errors@_to\ value, so that
14091 any bounces that are generated by other MTAs on the delivery route are also
14092 sent there. The most common use of \errors@_to\ is probably to direct mailing
14093 list bounces to the manager of the list, as described in section
14094 ~~SECTmailinglists.
14095
14096 The \errors@_to\ setting associated with an address can be overridden if it
14097 subsequently passes through other routers that have their own \errors@_to\
14098 settings,
14099 or if it is delivered by a transport with a \return@_path\ setting.
14100
14101 You can set \errors@_to\ to the empty string by either of these settings:
14102 .display asis
14103 errors_to =
14104 errors_to = ""
14105 .endd
14106 An expansion item that yields an empty string has the same effect. If you do
14107 this, a locally detected delivery error for addresses processed by this router
14108 no longer gives rise to a bounce message; the error is discarded. If the
14109 address is delivered to a remote host, the return path is set to \"<>"\, unless
14110 overridden by the \return@_path\ option on the transport.
14111
14112 If for some reason you want to discard local errors, but use a non-empty
14113 \\MAIL\\ command for remote delivery, you can preserve the original return
14114 path in \$address@_data$\ in the router, and reinstate it in the transport by
14115 setting \return@_path\.
14116
14117
14118 .conf expn "boolean (precondition)" true
14119 .index address||testing
14120 .index testing||addresses
14121 .index \\EXPN\\||router skipping
14122 .index router||skipping for \\EXPN\\
14123 If this option is turned off, the router is skipped when testing an address
14124 as a result of processing an SMTP \\EXPN\\ command. You might, for example,
14125 want to turn it off on a router for users' \(.forward)\ files, while leaving it
14126 on for the system alias file.
14127 See section ~~SECTrouprecon for a list of the order in which preconditions
14128 are evaluated.
14129
14130 The use of the SMTP \\EXPN\\ command is controlled by an ACL (see chapter
14131 ~~CHAPACL). When Exim is running an \\EXPN\\ command, it is similar to testing
14132 an address with \-bt-\. Compare \\VRFY\\, whose counterpart is \-bv-\.
14133
14134
14135 .conf fail@_verify boolean false
14136 .index router||forcing verification failure
14137 Setting this option has the effect of setting both \fail@_verify@_sender\ and
14138 \fail@_verify@_recipient\ to the same value.
14139
14140
14141 .conf fail@_verify@_recipient boolean false
14142 If this option is true and an address is accepted by this router when
14143 verifying a recipient, verification fails.
14144
14145
14146 .conf fail@_verify@_sender boolean false
14147 If this option is true and an address is accepted by this router when
14148 verifying a sender, verification fails.
14149
14150
14151 .conf fallback@_hosts "string list" unset
14152 .index router||fallback hosts
14153 .index fallback||hosts specified on router
14154 String expansion is not applied to this option. The argument must be a
14155 colon-separated list of host names or IP addresses. If a router queues an
14156 address for a remote transport, this host list is associated with the address,
14157 and used instead of the transport's fallback host list. If \hosts@_randomize\
14158 is set on the transport, the order of the list is randomized for each use. See
14159 the \fallback@_hosts\ option of the \%smtp%\ transport for further details.
14160
14161 .conf group string$**$ "see below"
14162 .index gid (group id)||local delivery
14163 .index local transports||uid and gid
14164 .index transport||local
14165 .index router||setting group
14166 When a router queues an address for a transport, and the transport does not
14167 specify a group, the group given here is used when running the delivery
14168 process.
14169 The group may be specified numerically or by name. If expansion fails, the
14170 error is logged and delivery is deferred.
14171 The default is unset, unless \check@_local@_user\ is set, when the default
14172 is taken from the password information. See also \initgroups\ and \user\ and
14173 the discussion in chapter ~~CHAPenvironment.
14174
14175
14176 .conf headers@_add string$**$ unset
14177 .index header lines||adding
14178 .index router||adding header lines
14179 .em
14180 This option specifies a string of text that is expanded at routing time, and
14181 associated with any addresses that are accepted by the router. However, this
14182 option has no effect when an address is just being verified. The way in which
14183 the text is used to add header lines at transport time is described in section
14184 ~~SECTheadersaddrem.
14185
14186 The \headers@_add\ option is expanded after \errors@_to\, but before
14187 \headers@_remove\ and \transport\. If the expanded string is empty, or if the
14188 expansion is forced to fail, the option has no effect. Other expansion failures
14189 are treated as configuration errors.
14190
14191 \**Warning**\: The \headers@_add\ option cannot be used for a \%redirect%\
14192 router that has the \one@_time\ option set.
14193 .nem
14194
14195
14196 .conf headers@_remove string$**$ unset
14197 .index header lines||removing
14198 .index router||removing header lines
14199 .em
14200 This option specifies a string of text that is expanded at routing time, and
14201 associated with any addresses that are accepted by the router. However, this
14202 option has no effect when an address is just being verified. The way in which
14203 the text is used to remove header lines at transport time is described in
14204 section ~~SECTheadersaddrem.
14205
14206 The \headers@_remove\ option is expanded after \errors@_to\ and \headers@_add\,
14207 but before \transport\. If the expansion is forced to fail, the option has no
14208 effect. Other expansion failures are treated as configuration errors.
14209
14210 \**Warning**\: The \headers@_remove\ option cannot be used for a \%redirect%\
14211 router that has the \one@_time\ option set.
14212 .nem
14213
14214
14215 .conf ignore@_target@_hosts "host list$**$" unset
14216 .index IP address||discarding
14217 .index router||discarding IP addresses
14218 Although this option is a host list, it should normally contain IP address
14219 entries rather than names. If any host that is looked up by the router has an
14220 IP address that matches an item in this list, Exim behaves as if that IP
14221 address did not exist. This option allows you to cope with rogue DNS entries
14222 like
14223 .display asis
14224 remote.domain.example.  A  127.0.0.1
14225 .endd
14226 by setting
14227 .display asis
14228 ignore_target_hosts = 127.0.0.1
14229 .endd
14230 on the relevant router. If all the hosts found by a \%dnslookup%\ router are
14231 discarded in this way, the router declines. In a conventional configuration, an
14232 attempt to mail to such a domain would normally provoke the `unrouteable
14233 domain' error, and an attempt to verify an address in the domain would fail.
14234
14235 Similarly, if \ignore@_target@_hosts\ is set on an \%ipliteral%\ router, the
14236 router declines if presented with one of the listed addresses.
14237
14238 This option may also be useful for ignoring link-local and site-local IPv6
14239 addresses. Because, like all host lists, the value of \ignore@_target@_hosts\
14240 is expanded before use as a list, it is possible to make it dependent on the
14241 domain that is being routed.
14242 .em
14243 During its expansion, \$host@_address$\ is set to the IP address that is being 
14244 checked.
14245 .nem
14246
14247
14248
14249 .index additional groups
14250 .index groups, additional
14251 .index local transports||uid and gid
14252 .index transport||local
14253 .conf initgroups boolean false
14254 If the router queues an address for a transport, and this option is true, and
14255 the uid supplied by the router is not overridden by the transport, the
14256 \*initgroups()*\ function is called when running the transport to ensure that
14257 any additional groups associated with the uid are set up. See also \group\ and
14258 \user\ and the discussion in chapter ~~CHAPenvironment.
14259
14260
14261 .conf local@_part@_prefix "string list (precondition)" unset
14262 .index router||prefix for local part
14263 .index prefix||for local part, used in router
14264 If this option is set, the router is skipped unless the local part
14265 starts with one of the given strings, or \local@_part@_prefix@_optional\ is
14266 true.
14267 See section ~~SECTrouprecon for a list of the order in which preconditions
14268 are evaluated.
14269
14270 The list is scanned from left to right, and the first prefix that matches is
14271 used. A limited form of wildcard is available; if the prefix begins with an
14272 asterisk, it matches the longest possible sequence of arbitrary characters at
14273 the start of the local part. An asterisk should therefore always be followed by
14274 some character that does not occur in normal local parts.
14275 .index multiple mailboxes
14276 .index mailbox||multiple
14277 Wildcarding can be used to set up multiple user mailboxes, as described in
14278 section ~~SECTmulbox.
14279
14280 During the testing of the \local@_parts\ option, and while the router is
14281 running, the prefix is removed from the local part, and is available in the
14282 expansion variable \$local@_part@_prefix$\. If the router accepts the address,
14283 this remains true during subsequent delivery.
14284 In particular, the local part that is transmitted in the \\RCPT\\ command
14285 for LMTP, SMTP, and BSMTP deliveries has the prefix removed by default. This
14286 behaviour can be overridden by setting \rcpt@_include@_affixes\ true on the
14287 relevant transport.
14288
14289 The prefix facility is commonly used to handle local parts of the form
14290 \owner-something\. Another common use is to support local parts of the form
14291 \real-username\ to bypass a user's \(.forward)\ file -- helpful when trying to
14292 tell a user their forwarding is broken -- by placing a router like this one
14293 immediately before the router that handles \(.forward)\ files:
14294 .display asis
14295 real_localuser:
14296   driver = accept
14297   local_part_prefix = real-
14298   check_local_user
14299   transport = local_delivery
14300 .endd
14301 If both \local@_part@_prefix\ and \local@_part@_suffix\ are set for a router,
14302 both conditions must be met if not optional. Care must be taken if wildcards
14303 are used in both a prefix and a suffix on the same router. Different
14304 separator characters must be used to avoid ambiguity.
14305
14306 .conf local@_part@_prefix@_optional boolean false
14307 See \local@_part@_prefix\ above.
14308
14309
14310 .conf local@_part@_suffix "string list (precondition)" unset
14311 .index router||suffix for local part
14312 .index suffix for local part, used in router
14313 This option operates in the same way as \local@_part@_prefix\, except that the
14314 local part must end (rather than start) with the given string, the
14315 \local@_part@_suffix@_optional\ option determines whether the suffix is
14316 mandatory, and the wildcard $*$ character, if present, must be the last
14317 character of the suffix. This option facility is commonly used to handle local
14318 parts of the form \something-request\ and multiple user mailboxes of the form
14319 \username-foo\.
14320
14321 .conf local@_part@_suffix@_optional boolean false
14322 See \local@_part@_suffix\ above.
14323
14324
14325 .conf local@_parts "local part list$**$ (precondition)" unset
14326 .index router||restricting to specific local parts
14327 .index local part||checking in router
14328 The router is run only if the local part of the address matches the list.
14329 See section ~~SECTrouprecon for a list of the order in which preconditions
14330 are evaluated, and
14331 section ~~SECTlocparlis for a discussion of local part lists. Because the
14332 string is expanded, it is possible to make it depend on the domain, for
14333 example:
14334 .display asis
14335 local_parts = dbm;/usr/local/specials/$domain
14336 .endd
14337 If the match is achieved by a lookup, the data that the lookup returned
14338 for the local part is placed in the variable \$local@_part@_data$\ for use in
14339 expansions of the router's private options. You might use this option, for
14340 example, if you have a large number of local virtual domains, and you want to
14341 send all postmaster mail to the same place without having to set up an alias in
14342 each virtual domain:
14343 .display asis
14344 postmaster:
14345   driver = redirect
14346   local_parts = postmaster
14347   data = postmaster@real.domain.example
14348 .endd
14349
14350
14351 .conf log@_as@_local boolean "see below"
14352 .index log||delivery line
14353 .index delivery||log line format
14354 Exim has two logging styles for delivery, the idea being to make local
14355 deliveries stand out more visibly from remote ones. In the `local' style, the
14356 recipient address is given just as the local part, without a domain. The use of
14357 this style is controlled by this option. It defaults to true for the \%accept%\
14358 router, and false for all the others.
14359
14360
14361 .conf more boolean$**$ true
14362 The result of string expansion for this option must be a valid boolean value,
14363 that is, one of the strings `yes', `no', `true', or `false'. Any other result
14364 causes an error, and delivery is deferred. If the expansion is forced to fail,
14365 the default value for the option (true) is used. Other failures cause delivery
14366 to be deferred.
14367
14368 If this option is set false, and the router is run, but declines to handle the
14369 address, no further routers are tried, routing fails, and the address is
14370 bounced.
14371 .index \self\ option
14372 However, if the router explicitly passes an address to the following router by
14373 means of the setting
14374 .display asis
14375 self = pass
14376 .endd
14377 or otherwise, the setting of \more\ is ignored. Also, the setting of \more\
14378 does not affect the behaviour if one of the precondition tests fails. In that
14379 case, the address is always passed to the next router.
14380
14381
14382 .conf pass@_on@_timeout boolean false
14383 .index timeout||of router
14384 .index router||timeout
14385 If a router times out during a host lookup, it normally causes deferral of the
14386 address. If \pass@_on@_timeout\ is set, the address is passed on to the next
14387 router, overriding \no@_more\. This may be helpful for systems that are
14388 intermittently connected to the Internet, or those that want to pass to a smart
14389 host any messages that cannot immediately be delivered.
14390
14391 There are occasional other temporary errors that can occur while doing DNS
14392 lookups. They are treated in the same way as a timeout, and this option
14393 applies to all of them.
14394
14395
14396 .conf pass@_router string unset
14397 .index router||go to after `pass'
14398 When a router returns `pass', the address is normally handed on to the next
14399 router in sequence. This can be changed by setting \pass@_router\ to the name
14400 of another router. However (unlike \redirect@_router\) the named router must be
14401 below the current router, to avoid loops. Note that this option applies only to
14402 the special case of `pass'. It does not apply when a router returns `decline'.
14403
14404
14405 .conf redirect@_router string unset
14406 .index router||start at after redirection
14407 Sometimes an administrator knows that it is pointless to reprocess addresses
14408 generated from alias or forward files with the same router again. For
14409 example, if an alias file translates real names into login ids there is no
14410 point searching the alias file a second time, especially if it is a large file.
14411
14412 The \redirect@_router\ option can be set to the name of any router instance. It
14413 causes the routing of any generated addresses to start at the named router
14414 instead of at the first router. This option has no effect if the router in
14415 which it is set does not generate new addresses.
14416
14417
14418 .conf require@_files "string list$**$ (precondition)" unset
14419 .index file||requiring for router
14420 .index router||requiring file existence
14421 This option provides a general mechanism for predicating the running of a
14422 router on the existence or non-existence of certain files or directories.
14423 Before running a router, as one of its precondition tests, Exim works its way
14424 through the \require@_files\ list, expanding each item separately.
14425
14426 Because the list is split before expansion, any colons in expansion items must
14427 be doubled, or the facility for using a different list separator must be used.
14428 If any expansion is forced to fail, the item is ignored. Other expansion
14429 failures cause routing of the address to be deferred.
14430
14431 If any expanded string is empty, it is ignored. Otherwise, except as described
14432 below, each string must be a fully qualified file path, optionally preceded by
14433 `!'. The paths are passed to the \*stat()*\ function to test for the existence
14434 of the files or directories. The router is skipped if any paths not preceded by
14435 `!' do not exist, or if any paths preceded by `!' do exist.
14436
14437 .index NFS
14438 If \*stat()*\ cannot determine whether a file exists or not, delivery of
14439 the message is deferred. This can happen when NFS-mounted filesystems are
14440 unavailable.
14441
14442 This option is checked after the \domains\, \local@_parts\, and \senders\
14443 options, so you cannot use it to check for the existence of a file in which to
14444 look up a domain, local part, or sender. (See section ~~SECTrouprecon for a
14445 full list of the order in which preconditions are evaluated.) However, as
14446 these options are all expanded, you can use the \exists\ expansion condition to
14447 make such tests. The \require@_files\ option is intended for checking files
14448 that the router may be going to use internally, or which are needed by a
14449 transport (for example \(.procmailrc)\).
14450
14451 During delivery, the \*stat()*\ function is run as root, but there is a
14452 facility for some checking of the accessibility of a file by another user.
14453 This is not a proper permissions check, but just a `rough' check that
14454 operates as follows:
14455
14456 If an item in a \require@_files\ list does not contain any forward slash
14457 characters, it is taken to be the user (and optional group, separated by a
14458 comma) to be checked for subsequent files in the list. If no group is specified
14459 but the user is specified symbolically, the gid associated with the uid is
14460 used. For example:
14461 .display asis
14462 require_files = mail:/some/file
14463 require_files = $local_part:$home/.procmailrc
14464 .endd
14465 If a user or group name in a \require@_files\ list does not exist, the
14466 \require@_files\ condition fails.
14467
14468 Exim performs the check by scanning along the components of the file path, and
14469 checking the access for the given uid and gid. It checks for `x' access on
14470 directories, and `r' access on the final file. Note that this means that file
14471 access control lists, if the operating system has them, are ignored.
14472
14473 \**Warning 1**\: When the router is being run to verify addresses for an
14474 incoming SMTP message, Exim is not running as root, but under its own uid. This
14475 may affect the result of a \require@_files\ check. In particular, \*stat()*\
14476 may yield the error \\EACCES\\ (`Permission denied'). This means that the Exim
14477 user is not permitted to read one of the directories on the file's path.
14478
14479 \**Warning 2**\: Even when Exim is running as root while delivering a message,
14480 \*stat()*\ can yield \\EACCES\\ for a file in an NFS directory that is mounted
14481 without root access.
14482 .em
14483 In this case, if a check for access by a particular user is requested, Exim 
14484 creates a subprocess that runs as that user, and tries the check again in that
14485 process.
14486
14487 The default action for handling an unresolved \\EACCES\\ is to consider it to
14488 be caused by a configuration error,
14489 .nem
14490 and routing is deferred because the existence or non-existence of the file
14491 cannot be determined. However, in some circumstances it may be desirable to
14492 treat this condition as if the file did not exist. If the file name (or the
14493 exclamation mark that precedes the file name for non-existence) is preceded by
14494 a plus sign, the \\EACCES\\ error is treated as if the file did not exist. For
14495 example:
14496 .display asis
14497 require_files = +/some/file
14498 .endd
14499 If the router is not an essential part of verification (for example, it
14500 handles users' \(.forward)\ files), another solution is to set the \verify\
14501 option false so that the router is skipped when verifying.
14502
14503
14504 .conf retry@_use@_local@_part boolean "see below"
14505 .index hints database||retry keys
14506 .index local part||in retry keys
14507 When a delivery suffers a temporary routing failure, a retry record is created
14508 in Exim's hints database. For addresses whose routing depends only on the
14509 domain, the key for the retry record should not involve the local part, but for
14510 other addresses, both the domain and the local part should be included.
14511 Usually, remote routing is of the former kind, and local routing is of the
14512 latter kind.
14513
14514 This option controls whether the local part is used to form the key for retry
14515 hints for addresses that suffer temporary errors while being handled by this
14516 router. The default value is true for any router that has \check@_local@_user\
14517 set, and false otherwise. Note that this option does not apply to hints keys
14518 for transport delays; they are controlled by a generic transport option of the
14519 same name.
14520
14521 The setting of \retry@_use@_local@_part\ applies only to the router on which it
14522 appears. If the router generates child addresses, they are routed
14523 independently; this setting does not become attached to them.
14524
14525
14526 .conf router@_home@_directory string$**$ unset
14527 .index router||home directory for
14528 .index home directory||for router
14529 This option sets a home directory for use while the router is running. (Compare
14530 \transport__home@_directory\, which sets a home directory for later
14531 transporting.) In particular, if used on a \%redirect%\ router, this option
14532 sets a value for \$home$\ while a filter is running. The value is expanded;
14533 forced expansion failure causes the option to be ignored -- other failures
14534 cause the router to defer.
14535
14536 Expansion of \router@_home@_directory\ happens immediately after the
14537 \check@_local@_user\ test (if configured), before any further expansions take
14538 place.
14539 (See section ~~SECTrouprecon for a list of the order in which preconditions
14540 are evaluated.)
14541 While the router is running, \router__home@_directory\ overrides the value of
14542 \$home$\ that came from \check@_local@_user\.
14543
14544 When a router accepts an address and routes it to a transport (including the
14545 cases when a redirect router generates a pipe, file, or autoreply delivery),
14546 the home directory setting for the transport is taken from the first of these
14547 values that is set:
14548 .numberpars $.
14549 The \home@_directory\ option on the transport;
14550 .nextp
14551 The \transport@_home@_directory\ option on the router;
14552 .nextp
14553 The password data if \check@_local@_user\ is set on the router;
14554 .nextp
14555 The \router@_home@_directory\ option on the router.
14556 .endp
14557 In other words, \router@_home@_directory\ overrides the password data for the
14558 router, but not for the transport.
14559
14560
14561 .conf self string "freeze"
14562 .index MX record||pointing to local host
14563 .index local host||MX pointing to
14564 This option applies to those routers that use a recipient address to find a
14565 list of remote hosts. Currently, these are the \%dnslookup%\, \%ipliteral%\,
14566 and \%manualroute%\ routers.
14567 Certain configurations of the \%queryprogram%\ router can also specify a list
14568 of remote hosts.
14569 Usually such routers are configured to send the message to a remote host via an
14570 \%smtp%\ transport. The \self\ option specifies what happens when the first
14571 host on the list turns out to be the local host.
14572 The way in which Exim checks for the local host is described in section
14573 ~~SECTreclocipadd.
14574
14575 Normally this situation indicates either an error in Exim's configuration (for
14576 example, the router should be configured not to process this domain), or an
14577 error in the DNS (for example, the MX should not point to this host). For this
14578 reason, the default action is to log the incident, defer the address, and
14579 freeze the message. The following alternatives are provided for use in special
14580 cases:
14581 .numberpars $.
14582 \defer\
14583 .newline
14584 Delivery of the message is tried again later, but the message is not frozen.
14585 .nextp
14586 \reroute: <<domain>>\
14587 .newline
14588 The domain is changed to the given domain, and the address is passed back to
14589 be reprocessed by the routers. No rewriting of headers takes place. This
14590 behaviour is essentially a redirection.
14591 .nextp
14592 \reroute: rewrite: <<domain>>\
14593 .newline
14594 The domain is changed to the given domain, and the address is passed back to be
14595 reprocessed by the routers. Any headers that contain the original domain are
14596 rewritten.
14597 .nextp
14598 \pass\
14599 .newline
14600 The router passes the address to the next router, or to the router named in the
14601 \pass@_router\ option if it is set.
14602 .index \more\ option
14603 This overrides \no@_more\.
14604
14605 During subsequent routing and delivery, the variable
14606 \$self@_hostname$\ contains the name of the local host that the router
14607 encountered. This can be used to distinguish between different cases for hosts
14608 with multiple names. The combination
14609 .display asis
14610 self = pass
14611 no_more
14612 .endd
14613 ensures that only those addresses that routed to the local host are passed on.
14614 Without \no@_more\, addresses that were declined for other reasons would also
14615 be passed to the next router.
14616 .nextp
14617 \fail\
14618 .newline
14619 Delivery fails and an error report is generated.
14620 .nextp
14621 \send\
14622 .newline
14623 .index local host||sending to
14624 The anomaly is ignored and the address is queued for the transport. This
14625 setting should be used with extreme caution. For an \%smtp%\ transport, it makes
14626 sense only in cases where the program that is listening on the SMTP port is not
14627 this version of Exim. That is, it must be some other MTA, or Exim with a
14628 different configuration file that handles the domain in another way.
14629 .endp
14630
14631 .conf senders "address list$**$ (precondition)" unset
14632 .index router||checking senders
14633 If this option is set, the router is skipped unless the message's sender
14634 address matches something on the list.
14635 See section ~~SECTrouprecon for a list of the order in which preconditions
14636 are evaluated.
14637
14638 There are issues concerning verification when the running of routers is
14639 dependent on the sender. When Exim is verifying the address in an \errors@_to\
14640 setting, it sets the sender to the null string. When using the \-bt-\ option to
14641 check a configuration file, it is necessary also to use the \-f-\ option to set
14642 an appropriate sender. For incoming mail, the sender is unset when verifying
14643 the sender, but is available when verifying any recipients. If the SMTP
14644 \\VRFY\\ command is enabled, it must be used after \\MAIL\\ if the sender
14645 address matters.
14646
14647 .conf translate@_ip@_address string$**$ unset
14648 .index IP address||translating
14649 .index packet radio
14650 .index router||IP address translation
14651 There exist some rare networking situations (for example, packet radio) where
14652 it is helpful to be able to translate IP addresses generated by normal routing
14653 mechanisms into other IP addresses, thus performing a kind of manual IP
14654 routing. This should be done only if the normal IP routing of the TCP/IP stack
14655 is inadequate or broken. Because this is an extremely uncommon requirement, the
14656 code to support this option is not included in the Exim binary unless
14657 \\SUPPORT__TRANSLATE__IP__ADDRESS\\=yes is set in \(Local/Makefile)\.
14658
14659 The \translate@_ip@_address\ string is expanded for every IP address generated
14660 by the router, with the generated address set in \$host@_address$\. If the
14661 expansion is forced to fail, no action is taken.
14662 For any other expansion error, delivery of the message is deferred.
14663 If the result of the expansion is an IP address, that replaces the original
14664 address; otherwise the result is assumed to be a host name -- this is looked up
14665 using \*gethostbyname()*\ (or \*getipnodebyname()*\ when available) to produce
14666 one or more replacement IP addresses. For example, to subvert all IP addresses
14667 in some specific networks, this could be added to a router:
14668 .display
14669 $smc{translate@_ip@_address = @\
14670   @$@{lookup@{@$@{mask:@$host@_address/26@}@}lsearch@{/some/file@}@{@$value@}fail@}}
14671 .endd
14672 The file would contain lines like
14673 .display asis
14674 10.2.3.128/26    some.host
14675 10.8.4.34/26     10.44.8.15
14676 .endd
14677 You should not make use of this facility unless you really understand what you
14678 are doing.
14679
14680
14681 .conf transport string$**$ unset
14682 This option specifies the transport to be used when a router accepts an address
14683 and sets it up for delivery. A transport is never needed if a router is used
14684 only for verification. The value of the option is expanded at routing time,
14685 after the expansion of \errors@_to\, \headers@_add\, and \headers@_remove\, and
14686 result must be the name of one of the configured transports. If it is not,
14687 delivery is deferred.
14688
14689 The \transport\ option is not used by the \%redirect%\ router, but it does have
14690 some private options that set up transports for pipe and file deliveries (see
14691 chapter ~~CHAPredirect).
14692
14693
14694 .conf transport@_current@_directory string$**$ unset
14695 .index current directory for local transport
14696 This option associates a current directory with any address that is routed
14697 to a local transport. This can happen either because a transport is
14698 explicitly configured for the router, or because it generates a delivery to a
14699 file or a pipe. During the delivery process (that is, at transport time), this
14700 option string is expanded and is set as the current directory, unless
14701 overridden by a setting on the transport.
14702 If the expansion fails for any reason, including forced failure, an error is
14703 logged, and delivery is deferred.
14704 See chapter ~~CHAPenvironment for details of the local delivery environment.
14705
14706
14707
14708 .conf transport@_home@_directory string$**$ "see below"
14709 .index home directory||for local transport
14710 This option associates a home directory with any address that is routed to a
14711 local transport. This can happen either because a transport is explicitly
14712 configured for the router, or because it generates a delivery to a file or a
14713 pipe. During the delivery process (that is, at transport time), the option
14714 string is expanded and is set as the home directory, unless overridden by a
14715 setting of \home@_directory\ on the transport.
14716 If the expansion fails for any reason, including forced failure, an error is
14717 logged, and delivery is deferred.
14718
14719 If the transport does not specify a home directory, and
14720 \transport@_home@_directory\ is not set for the router, the home directory for
14721 the tranport is taken from the password data if \check@_local@_user\ is set for
14722 the router. Otherwise it is taken from \router@_home@_directory\ if that option
14723 is set; if not, no home directory is set for the transport.
14724
14725 See chapter ~~CHAPenvironment for further details of the local delivery
14726 environment.
14727
14728
14729
14730 .conf unseen boolean$**$ false
14731 .index router||carrying on after success
14732 The result of string expansion for this option must be a valid boolean value,
14733 that is, one of the strings `yes', `no', `true', or `false'. Any other result
14734 causes an error, and delivery is deferred. If the expansion is forced to fail,
14735 the default value for the option (false) is used. Other failures cause delivery
14736 to be deferred.
14737
14738 When this option is set true, routing does not cease if the router accepts the
14739 address. Instead, a copy of the incoming address is passed to the next router,
14740 overriding a false setting of \more\. There is little point in setting \more\
14741 false if \unseen\ is always true, but it may be useful in cases when the value
14742 of \unseen\ contains expansion items (and therefore, presumably, is sometimes
14743 true and sometimes false).
14744
14745 The \unseen\ option can be used to cause
14746 .index copy of message (\unseen\ option)
14747 copies of messages to be delivered to some other destination, while also
14748 carrying out a normal delivery. In effect, the current address is made into a
14749 `parent' that has two children -- one that is delivered as specified by this
14750 router, and a clone that goes on to be routed further.
14751
14752 Header lines added to the address (or specified for removal) by this router or
14753 by previous routers affect the `unseen' copy of the message only. The clone
14754 that continues to be processed by further routers starts with no added headers
14755 and none specified for removal.
14756
14757 However, any data that was set by the \address@_data\ option in the current or
14758 previous routers is passed on. Setting this option has a similar effect to the
14759 \unseen\ command qualifier in filter files.
14760
14761
14762 .conf user string$**$ "see below"
14763 .index uid (user id)||local delivery
14764 .index local transports||uid and gid
14765 .index transport||local
14766 .index router||user for filter processing
14767 .index filter||user for processing
14768 When a router queues an address for a transport, and the transport does not
14769 specify a user, the user given here is used when running the delivery process.
14770 The user may be specified numerically or by name. If expansion fails, the
14771 error is logged and delivery is deferred.
14772 This user is also used by the \%redirect%\ router when running a filter file.
14773 The default is unset, except when \check@_local@_user\ is set. In this case,
14774 the default is taken from the password information. If the user is specified as
14775 a name, and \group\ is not set, the group associated with the user is used. See
14776 also \initgroups\ and \group\ and the discussion in chapter ~~CHAPenvironment.
14777
14778
14779 .conf verify "boolean (precondition)" true
14780 Setting this option has the effect of setting \verify@_sender\ and
14781 \verify@_recipient\ to the same value.
14782
14783 .conf verify@_only "boolean (precondition)" false
14784 .index \\EXPN\\||with \verify@_only\
14785 .index \-bv-\ option
14786 .index router||used only when verifying
14787 If this option is set, the router is used only when verifying an address or
14788 testing with the \-bv-\ option, not when actually doing a delivery, testing
14789 with the \-bt-\ option, or running the SMTP \\EXPN\\ command. It can be further
14790 restricted to verifying only senders or recipients by means of \verify@_sender\
14791 and \verify@_recipient\.
14792
14793 \**Warning**\: When the router is being run to verify addresses for an incoming
14794 SMTP message, Exim is not running as root, but under its own uid. If the router
14795 accesses any files, you need to make sure that they are accessible to the Exim
14796 user or group.
14797
14798 .conf verify@_recipient "boolean (precondition)" true
14799 If this option is false, the router is skipped when verifying recipient
14800 addresses
14801 or testing recipient verification using \-bv-\.
14802 See section ~~SECTrouprecon for a list of the order in which preconditions
14803 are evaluated.
14804
14805 .conf verify@_sender "boolean (precondition)" true
14806 If this option is false, the router is skipped when verifying sender addresses
14807 or testing sender verification using \-bvs-\.
14808 See section ~~SECTrouprecon for a list of the order in which preconditions
14809 are evaluated.
14810
14811 .endconf
14812
14813
14814
14815
14816
14817 .
14818 .
14819 .
14820 .
14821 . ============================================================================
14822 .chapter The accept router
14823 .set runningfoot "accept router"
14824 .index \%accept%\ router
14825 .index routers||\%accept%\
14826 The \%accept%\ router has no private options of its own. Unless it is being used
14827 purely for verification (see \verify@_only\) a transport is required to be
14828 defined by the generic \transport\ option. If the preconditions that are
14829 specified by generic options are met, the router accepts the address and queues
14830 it for the given transport. The most common use of this router is for setting
14831 up deliveries to local mailboxes. For example:
14832 .display asis
14833 localusers:
14834   driver = accept
14835   domains = mydomain.example
14836   check_local_user
14837   transport = local_delivery
14838 .endd
14839 The \domains\ condition in this example checks the domain of the address, and
14840 \check@_local@_user\ checks that the local part is the login of a local user.
14841 When both preconditions are met, the \%accept%\ router runs, and queues the
14842 address for the \%local@_delivery%\ transport.
14843
14844
14845
14846
14847
14848
14849 .
14850 .
14851 .
14852 .
14853 . ============================================================================
14854 .chapter The dnslookup router
14855 .rset CHAPdnslookup "~~chapter"
14856 .set runningfoot "dnslookup router"
14857 .index \%dnslookup%\ router
14858 .index routers||\%dnslookup%\
14859 The \%dnslookup%\ router looks up the hosts that handle mail for the 
14860 recipient's domain in the DNS. A transport must always be set for this router,
14861 unless \verify@_only\ is set.
14862
14863 If SRV support is configured (see \check@_srv\ below), Exim first searches for
14864 SRV records. If none are found, or if SRV support is not configured,
14865 MX records are looked up. If no MX records exist, address records are sought.
14866 However, \mx@_domains\ can be set to disable the direct use of address records.
14867
14868 MX records of equal priority are sorted by Exim into a random order. Exim then
14869 looks for address records for the host names obtained from MX or SRV records.
14870 When a host has more than one IP address, they are sorted into a random order,
14871 except that IPv6 addresses are always sorted before IPv4 addresses. If all the
14872 IP addresses found are discarded by a setting of the \ignore@_target@_hosts\
14873 generic option, the router declines.
14874
14875 Unless they have the highest priority (lowest MX value), MX records that point
14876 to the local host, or to any host name that matches \hosts__treat__as__local\,
14877 are discarded, together with any other MX records of equal or lower priority.
14878
14879 .index MX record||pointing to local host
14880 .index local host||MX pointing to
14881 .index \self\ option||in \%dnslookup%\ router
14882 If the host pointed to by the highest priority MX record, or looked up as an
14883 address record, is the local host, or matches \hosts__treat__as__local\, what
14884 happens is controlled by the generic \self\ option.
14885
14886 .em
14887 .section Problems with DNS lookups
14888 .rset SECTprowitdnsloo "~~chapter.~~section"
14889 There have been problems with DNS servers when SRV records are looked up.
14890 Some mis-behaving servers return a DNS error or timeout when a non-existent
14891 SRV record is sought. Similar problems have in the past been reported for
14892 MX records. The global \dns@_again@_means@_nonexist\ option can help with this
14893 problem, but it is heavy-handed because it is a global option.
14894
14895 For this reason, there are two options, \srv@_fail@_domains\ and
14896 \mx@_fail@_domains\, that control what happens when a DNS lookup in a
14897 \%dnslookup%\ router results in a DNS failure or a `try again' response. If an
14898 attempt to look up an SRV or MX record causes one of these results, and the
14899 domain matches the relevant list, Exim behaves as if the DNS had responded `no
14900 such record'. In the case of an SRV lookup, this means that the router proceeds
14901 to look for MX records; in the case of an MX lookup, it proceeds to look for A
14902 or AAAA records, unless the domain matches \mx@_domains\, in which case routing
14903 fails.
14904 .nem
14905
14906
14907 .section Private options for dnslookup
14908 The private options for the \%dnslookup%\ router are as follows:
14909
14910
14911 .startconf dnslookup
14912
14913 .index options||\%dnslookup%\ router
14914 .conf check@_secondary@_mx boolean false
14915 .index MX record||checking for secondary
14916 If this option is set, the router declines unless the local host is found in
14917 (and removed from) the list of hosts obtained by MX lookup. This can be used to
14918 process domains for which the local host is a secondary mail exchanger
14919 differently to other domains. The way in which Exim decides whether a host is
14920 the local host is described in section ~~SECTreclocipadd.
14921
14922 .conf check@_srv string$**$ unset
14923 .index SRV record||enabling use of
14924 The \%dnslookup%\ router supports the use of SRV records (see RFC 2782) in
14925 addition to MX and address records. The support is disabled by default. To
14926 enable SRV support, set the \check@_srv\ option to the name of the service
14927 required. For example,
14928 .display asis
14929 check_srv = smtp
14930 .endd
14931 looks for SRV records that refer to the normal smtp service. The option is
14932 expanded, so the service name can vary from message to message or address
14933 to address. This might be helpful if SRV records are being used for a
14934 submission service. If the expansion is forced to fail, the \check@_srv\
14935 option is ignored, and the router proceeds to look for MX records in the
14936 normal way.
14937
14938 When the expansion succeeds, the router searches first for SRV records for
14939 the given service (it assumes TCP protocol). A single SRV record with a
14940 host name that consists of just a single dot indicates `no such service for
14941 this domain'; if this is encountered, the router declines. If other kinds of
14942 SRV record are found, they are used to construct a host list for delivery
14943 according to the rules of RFC 2782. MX records are not sought in this case.
14944
14945 When no SRV records are found, MX records (and address records) are sought in
14946 the traditional way. In other words, SRV records take precedence over MX
14947 records, just as MX records take precedence over address records. Note that
14948 this behaviour is not sanctioned by RFC 2782, though a previous draft RFC
14949 defined it. It is apparently believed that MX records are sufficient for email
14950 and that SRV records should not be used for this purpose. However, SRV records
14951 have an additional `weight' feature which some people might find useful when
14952 trying to split an SMTP load between hosts of different power.
14953
14954 .em
14955 See section ~~SECTprowitdnsloo above for a discussion of Exim's behaviour when 
14956 there is a DNS lookup error.
14957 .nem
14958
14959 .conf mx@_domains "domain list$**$" unset
14960 .index MX record||required to exist
14961 .index SRV record||required to exist
14962 A domain that matches \mx@_domains\ is required to have either an MX or an SRV
14963 record in order to be recognised. (The name of this option could be improved.)
14964 For example, if all the mail hosts in \*fict.example*\ are known to have MX
14965 records, except for those in \*discworld.fict.example*\, you could use this
14966 setting:
14967 .display asis
14968 mx_domains = ! *.discworld.fict.example : *.fict.example
14969 .endd
14970 This specifies that messages addressed to a domain that matches the list but
14971 has no MX record should be bounced immediately instead of being routed using
14972 the address record.
14973
14974 .em
14975 .conf mx@_fail@_domains "domain list$**$" unset
14976 If the DNS lookup for MX records for one of the domains in this list causes a
14977 DNS lookup error, Exim behaves as if no MX records were found. See section
14978 ~~SECTprowitdnsloo for more discussion.
14979 .nem
14980
14981
14982 .conf qualify@_single boolean true
14983 .index DNS||resolver options
14984 .index DNS||qualifying single-component names
14985 When this option is true, the resolver option \\RES@_DEFNAMES\\ is set for DNS
14986 lookups. Typically, but not standardly, this causes the resolver to qualify
14987 single-component names with the default domain. For example, on a machine
14988 called \*dictionary.ref.example*\, the domain \*thesaurus*\ would be changed to
14989 \*thesaurus.ref.example*\ inside the resolver. For details of what your resolver
14990 actually does, consult your man pages for \*resolver*\ and \*resolv.conf*\.
14991
14992
14993 .conf rewrite@_headers boolean true
14994 .index rewriting||header lines
14995 .index header lines||rewriting
14996 If the domain name in the address that is being processed is not fully
14997 qualified, it may be expanded to its full form by a DNS lookup. For example, if
14998 an address is specified as \*dormouse@@teaparty*\, the domain might be
14999 expanded to \*teaparty.wonderland.fict.example*\. Domain expansion can also
15000 occur as a result of setting the \widen@_domains\ option. If \rewrite@_headers\
15001 is true, all occurrences of the abbreviated domain name in any ::Bcc::, ::Cc::,
15002 ::From::, ::Reply-to::, ::Sender::, and ::To:: header lines of the message are
15003 rewritten with the full domain name.
15004
15005 This option should be turned off only when it is known that no message is
15006 ever going to be sent outside an environment where the abbreviation makes
15007 sense.
15008
15009 When an MX record is looked up in the DNS and matches a wildcard record, name
15010 servers normally return a record containing the name that has been looked up,
15011 making it impossible to detect whether a wildcard was present or not. However,
15012 some name servers have recently been seen to return the wildcard entry. If the
15013 name returned by a DNS lookup begins with an asterisk, it is not used for
15014 header rewriting.
15015
15016 .conf same@_domain@_copy@_routing boolean false
15017 .index address||copying routing
15018 Addresses with the same domain are normally routed by the \%dnslookup%\ router
15019 to the same list of hosts. However, this cannot be presumed, because the router
15020 options and preconditions may refer to the local part of the address. By
15021 default, therefore, Exim routes each address in a message independently. DNS
15022 servers run caches, so repeated DNS lookups are not normally expensive, and in
15023 any case, personal messages rarely have more than a few recipients.
15024
15025 If you are running mailing lists with large numbers of subscribers at the same
15026 domain, and you are using a \%dnslookup%\ router which is independent of the
15027 local part, you can set \same__domain__copy@_routing\ to bypass repeated DNS
15028 lookups for identical domains in one message. In this case, when \%dnslookup%\
15029 routes an address to a remote transport, any other unrouted addresses in the
15030 message that have the same domain are automatically given the same routing
15031 without processing them independently,
15032 provided the following conditions are met:
15033 .numberpars $.
15034 No router that processed the address specified \headers@_add\ or
15035 \headers@_remove\.
15036 .nextp
15037 The router did not change the address in any way, for example, by `widening'
15038 the domain.
15039 .endp
15040
15041
15042 .conf search@_parents boolean false
15043 .index DNS||resolver options
15044 When this option is true, the resolver option \\RES@_DNSRCH\\ is set for DNS
15045 lookups. This is different from the \qualify@_single\ option in that it applies
15046 to domains containing dots. Typically, but not standardly, it causes the
15047 resolver to search for the name in the current domain and in parent domains.
15048 For example, on a machine in the \*fict.example*\ domain, if looking up
15049 \*teaparty.wonderland*\ failed, the resolver would try
15050 \*teaparty.wonderland.fict.example*\. For details of what your resolver
15051 actually does, consult your man pages for \*resolver*\ and \*resolv.conf*\.
15052
15053 Setting this option true can cause problems in domains that have a wildcard MX
15054 record, because any domain that does not have its own MX record matches the
15055 local wildcard.
15056
15057
15058 .em
15059 .conf srv@_fail@_domains "domain list$**$" unset
15060 If the DNS lookup for SRV records for one of the domains in this list causes a
15061 DNS lookup error, Exim behaves as if no SRV records were found. See section
15062 ~~SECTprowitdnsloo for more discussion.
15063 .nem
15064
15065
15066 .conf widen@_domains "string list" unset
15067 .index domain||partial, widening
15068 If a DNS lookup fails and this option is set, each of its strings in turn is
15069 added onto the end of the domain, and the lookup is tried again. For example,
15070 if
15071 .display asis
15072 widen_domains = fict.example:ref.example
15073 .endd
15074 is set and a lookup of \*klingon.dictionary*\ fails,
15075 \*klingon.dictionary.fict.example*\ is looked up, and if this fails,
15076 \*klingon.dictionary.ref.example*\ is tried. Note that the \qualify@_single\
15077 and \search@_parents\ options can cause some widening to be undertaken inside
15078 the DNS resolver.
15079
15080 .endconf
15081
15082 .section Effect of qualify@_single and search@_parents
15083 When a domain from an envelope recipient is changed by the resolver as a result
15084 of the \qualify@_single\ or \search@_parents\ options, Exim rewrites the
15085 corresponding address in the message's header lines unless \rewrite@_headers\
15086 is set false. Exim then re-routes the address, using the full domain.
15087
15088 These two options affect only the DNS lookup that takes place inside the router
15089 for the domain of the address that is being routed. They do not affect lookups
15090 such as that implied by
15091 .display asis
15092 domains = @mx_any
15093 .endd
15094 that may happen while processing a router precondition before the router is
15095 entered. No widening ever takes place for these lookups.
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105 .
15106 .
15107 .
15108 .
15109 . ============================================================================
15110 .chapter The ipliteral router
15111 .set runningfoot "ipliteral router"
15112 .index \%ipliteral%\ router
15113 .index domain literal||routing
15114 .index routers||\%ipliteral%\
15115 This router has no private options. Unless it is being used purely for
15116 verification (see \verify@_only\) a transport is required to be defined by the
15117 generic \transport\ option. The router accepts the address if its domain part
15118 takes the form of an RFC 2822 domain literal, that is, an IP address enclosed
15119 in square brackets. For example, this router handles the address
15120 .display asis
15121 root@[192.168.1.1]
15122 .endd
15123 by setting up delivery to the host with that IP address.
15124
15125 If the IP address matches something in \ignore@_target@_hosts\, the router
15126 declines.
15127 .index \self\ option||in \%ipliteral%\ router
15128 If an IP literal turns out to refer to the local host, the generic \self\
15129 option determines what happens.
15130
15131 The RFCs require support for domain literals; however, their use is
15132 controversial in today's Internet. If you want to use this router, you must
15133 also set the main configuration option \allow@_domain@_literals\. Otherwise,
15134 Exim will not recognize the domain literal syntax in addresses.
15135
15136
15137
15138 .
15139 .
15140 .
15141 .
15142 . ============================================================================
15143 .chapter The iplookup router
15144 .set runningfoot "iplookup router"
15145 .index \%iplookup%\ router
15146 .index routers||\%iplookup%\
15147 The \%iplookup%\ router was written to fulfil a specific requirement in
15148 Cambridge University (which in fact no longer exists). For this reason, it is
15149 not included in the binary of Exim by default. If you want to include it, you
15150 must set
15151 .display asis
15152 ROUTER_IPLOOKUP=yes
15153 .endd
15154 in your \(Local/Makefile)\ configuration file.
15155
15156 The \%iplookup%\ router routes an address by sending it over a TCP or UDP
15157 connection to one or more specific hosts. The host can then return the same or
15158 a different address -- in effect rewriting the recipient address in the
15159 message's envelope. The new address is then passed on to subsequent routers.
15160
15161
15162 If this process fails, the address can be passed on to
15163 other routers, or delivery can be deferred.
15164
15165 Background, for those that are interested: We have an Oracle database of all
15166 Cambridge users, and one of the items of data it maintains for each user is
15167 where to send mail addressed to \*user@@cam.ac.uk*\. The MX records for
15168 \*cam.ac.uk*\ point to a central machine that has a large alias list that is
15169 abstracted from the database. Mail from outside is switched by this system, and
15170 originally internal mail was also done this way. However, this resulted in a
15171 fair number of messages travelling from some of our larger systems to the
15172 switch and back again. The Oracle machine now runs a UDP service that can be
15173 called by the \%iplookup%\ router in Exim to find out where \*user@@cam.ac.uk*\
15174 addresses really have to go; this saves passing through the central switch, and
15175 in many cases saves doing any remote delivery at all.
15176
15177 Since \%iplookup%\ is just a rewriting router, a transport must not be
15178 specified for it.
15179
15180 .startconf iplookup
15181 .index options||\%iplookup%\ router
15182
15183 .conf hosts string unset
15184 This option must be supplied. Its value is a colon-separated list of host
15185 names. The hosts are looked up using \*gethostbyname()*\
15186 (or \*getipnodebyname()*\ when available)
15187 and are tried in order until one responds to the query. If none respond, what
15188 happens is controlled by \optional\.
15189
15190 .conf optional boolean false
15191 If \optional\ is true, if no response is obtained from any host, the address is
15192 passed to the next router, overriding \no@_more\. If \optional\ is false,
15193 delivery to the address is deferred.
15194
15195 .conf port integer 0
15196 .index port||\%iplookup%\ router
15197 This option must be supplied. It specifies the port number for the TCP or UDP
15198 call.
15199
15200 .conf protocol string "udp"
15201 This option can be set to `udp' or `tcp' to specify which of the two protocols
15202 is to be used.
15203
15204 .conf query string$**$ "$tt{@$local@_part@@@$domain @$local@_part@@@$domain}"
15205 This defines the content of the query that is sent to the remote hosts. The
15206 repetition serves as a way of checking that a response is to the correct query
15207 in the default case (see \response@_pattern\ below).
15208
15209 .conf reroute string$**$ unset
15210 If this option is not set, the rerouted address is precisely the byte string
15211 returned by the remote host, up to the first white space, if any. If set, the
15212 string is expanded to form the rerouted address. It can include parts matched
15213 in the response by \response@_pattern\ by means of numeric variables such as
15214 \$1$\, \$2$\, etc. The variable \$0$\ refers to the entire input string,
15215 whether or not a pattern is in use. In all cases, the rerouted address must end
15216 up in the form \*local@_part@@domain*\.
15217
15218 .conf response@_pattern string unset
15219 This option can be set to a regular expression that is applied to the string
15220 returned from the remote host. If the pattern does not match the response, the
15221 router declines. If \response@_pattern\ is not set, no checking of the response
15222 is done, unless the query was defaulted, in which case there is a check that
15223 the text returned after the first white space is the original address. This
15224 checks that the answer that has been received is in response to the correct
15225 question. For example, if the response is just a new domain, the following
15226 could be used:
15227 .display asis
15228 response_pattern = ^([^@]+)$
15229 reroute = $local_part@$1
15230 .endd
15231
15232 .conf timeout time 5s
15233 This specifies the amount of time to wait for a response from the remote
15234 machine. The same timeout is used for the \*connect()*\ function for a TCP
15235 call. It does not apply to UDP.
15236
15237 .endconf
15238
15239
15240
15241
15242 .
15243 .
15244 .
15245 .
15246 . ============================================================================
15247 .chapter The manualroute router
15248 .set runningfoot "manualroute router"
15249 .index \%manualroute%\ router
15250 .index routers||\%manualroute%\
15251 .index domain||manually routing
15252 The \%manualroute%\ router is so-called because it provides a way of manually
15253 routing an address according to its domain. It is mainly used when you want to
15254 route addresses to remote hosts according to your own rules, bypassing the
15255 normal DNS routing that looks up MX records. However, \%manualroute%\ can also
15256 route to local transports, a facility that may be useful if you want to save
15257 messages for dial-in hosts in local files.
15258
15259 The \%manualroute%\ router compares a list of domain patterns with the domain it
15260 is trying to route. If there is no match, the router declines. Each pattern has
15261 associated with it a list of hosts and some other optional data, which may
15262 include a transport. The combination of a pattern and its data is called a
15263 `routing rule'. For patterns that do not have an associated transport, the
15264 generic \transport\ option must specify a transport, unless the router is being
15265 used purely for verification (see \verify@_only\).
15266
15267 In the case of verification, matching the domain pattern is sufficient for the
15268 router to accept the address. When actually routing an address for delivery,
15269 an address that matches a domain pattern is queued for the associated
15270 transport. If the transport is not a local one, a host list must be associated
15271 with the pattern; IP addresses are looked up for the hosts, and these are
15272 passed to the transport along with the mail address. For local transports, a
15273 host list is optional. If it is present, it is passed in \$host$\ as a single
15274 text string.
15275
15276 The list of routing rules can be provided as an inline string in \route@_list\,
15277 or the data can be obtained by looking up the domain in a file or database by
15278 setting \route@_data\. Only one of these settings may appear in any one
15279 instance of \%manualroute%\. The format of routing rules is described below,
15280 following the list of private options.
15281
15282 .section Private options for manualroute
15283 .rset SECTprioptman "~~chapter.~~section"
15284
15285 The private options for the \%manualroute%\ router are as follows:
15286
15287 .startconf manualroute
15288 .index options||\%manualroute%\ router
15289
15290 .conf host@_find@_failed string "freeze"
15291 This option controls what happens when \%manualroute%\ tries to find an IP
15292 address for a host, and the host does not exist. The option can be set to one
15293 of
15294 .display asis
15295 decline
15296 defer
15297 fail
15298 freeze
15299 pass
15300 .endd
15301 The default assumes that this state is a serious configuration error. The
15302 difference between `pass' and `decline' is that the former forces the address
15303 to be passed to the next router (or the router defined by \pass@_router\),
15304 .index \more\ option
15305 overriding \no@_more\, whereas the latter passes the address to the next router
15306 only if \more\ is true.
15307
15308 This option applies only to a definite `does not exist' state; if a host lookup
15309 gets a temporary error, delivery is deferred unless the generic
15310 \pass@_on@_timeout\ option is set.
15311
15312 .conf hosts@_randomize boolean false
15313 .index randomized host list
15314 .index host||list of, randomized
15315 If this option is set, the order of the items in a host list in a routing rule
15316 is randomized each time the list is used, unless an option in the routing rule
15317 overrides (see below). Randomizing the order of a host list can be used to do
15318 crude load sharing. However, if more than one mail address is routed by the
15319 same router to the same host list, the host lists are considered to be the same
15320 (even though they may be randomized into different orders) for the purpose of
15321 deciding whether to batch the deliveries into a single SMTP transaction.
15322
15323 When \hosts@_randomize\ is true, a host list may be split
15324 into groups whose order is separately randomized. This makes it possible to
15325 set up MX-like behaviour. The boundaries between groups are indicated by an
15326 item that is just \"+"\ in the host list. For example:
15327 .display asis
15328 route_list = * host1:host2:host3:+:host4:host5
15329 .endd
15330 The order of the first three hosts and the order of the last two hosts is
15331 randomized for each use, but the first three always end up before the last two.
15332 If \hosts@_randomize\ is not set, a \"+"\ item in the list is ignored. If a
15333 randomized host list is passed to an \%smtp%\ transport that also has
15334 \hosts@_randomize set\, the list is not re-randomized.
15335
15336 .conf route@_data string$**$ unset
15337 If this option is set, it must expand to yield the data part of a routing rule.
15338 Typically, the expansion string includes a lookup based on the domain. For
15339 example:
15340 .display asis
15341 route_data = ${lookup{$domain}dbm{/etc/routes}}
15342 .endd
15343 If the expansion is forced to fail, or the result is an empty string, the
15344 router declines. Other kinds of expansion failure cause delivery to be
15345 deferred.
15346
15347 .conf route@_list "string list, semicolon-separated" unset
15348 This string is a list of routing rules, in the form defined below. Note that,
15349 unlike most string lists, the items are separated by semicolons. This is so
15350 that they may contain colon-separated host lists.
15351
15352 .conf same@_domain@_copy@_routing boolean false
15353 .index address||copying routing
15354 Addresses with the same domain are normally routed by the \%manualroute%\ router
15355 to the same list of hosts. However, this cannot be presumed, because the router
15356 options and preconditions may refer to the local part of the address. By
15357 default, therefore, Exim routes each address in a message independently. DNS
15358 servers run caches, so repeated DNS lookups are not normally expensive, and in
15359 any case, personal messages rarely have more than a few recipients.
15360
15361 If you are running mailing lists with large numbers of subscribers at the same
15362 domain, and you are using a \%manualroute%\ router which is independent of the
15363 local part, you can set \same@_domain@_copy@_routing\ to bypass repeated DNS
15364 lookups for identical domains in one message. In this case, when \%manualroute%\
15365 routes an address to a remote transport, any other unrouted addresses in the
15366 message that have the same domain are automatically given the same routing
15367 without processing them independently. However, this is only done if
15368 \headers@_add\ and \headers@_remove\ are unset.
15369
15370 .endconf
15371
15372
15373 .section Routing rules in route@_list
15374 The value of \route@_list\ is a string consisting of a sequence of routing
15375 rules, separated by semicolons. If a semicolon is needed in a rule, it can be
15376 entered as two semicolons. Empty rules are ignored. The format of each rule is
15377 .display
15378 <<domain pattern>>  <<list of hosts>>  <<options>>
15379 .endd
15380 The following example contains two rules, each with a simple domain pattern and
15381 no options:
15382 .display asis
15383 route_list = \
15384   dict.ref.example  mail-1.ref.example:mail-2.ref.example ; \
15385   thes.ref.example  mail-3.ref.example:mail-4.ref.example
15386 .endd
15387 The three parts of a rule are separated by white space. The pattern and the
15388 list of hosts can be enclosed in quotes if necessary, and if they are, the
15389 usual quoting rules apply. Each rule in a \route@_list\ must start with a
15390 single domain pattern, which is the only mandatory item in the rule. The
15391 pattern is in the same format as one item in a domain list (see section
15392 ~~SECTdomainlist),
15393 except that it may not be the name of an interpolated file.
15394 That is, it may be wildcarded, or a regular expression, or a file or database
15395 lookup (with semicolons doubled, because of the use of semicolon as a separator
15396 in a \route@_list\).
15397
15398 The rules in \route@_list\ are searched in order until one of the patterns
15399 matches the domain that is being routed. The list of hosts and then options are
15400 then used as described below. If there is no match, the router declines. When
15401 \route@_list\ is set, \route@_data\ must not be set.
15402
15403
15404 .section Routing rules in route@_data
15405 The use of \route@_list\ is convenient when there are only a small number of
15406 routing rules. For larger numbers, it is easier to use a file or database to
15407 hold the routing information, and use the \route@_data\ option instead.
15408 The value of \route@_data\ is a list of hosts, followed by (optional) options.
15409 Most commonly, \route@_data\ is set as a string that contains an
15410 expansion lookup. For example, suppose we place two routing rules in a file
15411 like this:
15412 .display asis
15413 dict.ref.example:  mail-1.ref.example:mail-2.ref.example
15414 thes.ref.example:  mail-3.ref.example:mail-4.ref.example
15415 .endd
15416 This data can be accessed by setting
15417 .display asis
15418 route_data = ${lookup{$domain}lsearch{/the/file/name}}
15419 .endd
15420 Failure of the lookup results in an empty string, causing the router to
15421 decline. However, you do not have to use a lookup in \route@_data\. The only
15422 requirement is that the result of expanding the string is a list of hosts,
15423 possibly followed by options, separated by white space. The list of hosts must
15424 be enclosed in quotes if it contains white space.
15425
15426
15427
15428 .section Format of the list of hosts
15429 A list of hosts, whether obtained via \route@_data\ or \route@_list\, is always
15430 separately expanded before use. If the expansion fails, the router declines.
15431 The result of the expansion must be a colon-separated list of names and/or
15432 IP addresses. IP addresses are not enclosed in brackets.
15433
15434 If the list of hosts was obtained from a \route@_list\ item, the following
15435 variables are set during its expansion:
15436 .index numerical variables (\$1$\, \$2$\, etc)||in \%manualroute%\ router
15437 .numberpars $.
15438 If the domain was matched against a regular expression, the numeric variables
15439 \$1$\, \$2$\, etc. may be set.
15440 .nextp
15441 \$0$\ is always set to the entire domain.
15442 .nextp
15443 \$1$\ is also set when partial matching is done in a file lookup.
15444 .nextp
15445 .index \$value$\
15446 If the pattern that matched the domain was a lookup item, the data that was
15447 looked up is available in the expansion variable \$value$\.
15448 .endp
15449
15450
15451 .section How the list of hosts is used
15452 When an address is routed to an \%smtp%\ transport by \%manualroute%\, each of
15453 the hosts is tried, in the order specified, when carrying out the SMTP
15454 delivery. However, the order can be changed by setting the \hosts@_randomize\
15455 option, either on the router (see section ~~SECTprioptman above), or on the
15456 transport.
15457
15458 Hosts may be listed by name or by IP address. An unadorned name in the list of
15459 hosts is interpreted as a host name. A name that is followed by \"/MX"\ is
15460 interpreted as an indirection to a sublist of hosts obtained by looking up MX
15461 records in the DNS. For example:
15462 .display asis
15463 route_list = *  x.y.z:p.q.r/MX:e.f.g
15464 .endd
15465 If the \hosts@_randomize\ option is set, the order of the items in the list is
15466 randomized before any lookups are done. Exim then scans the list; for any name
15467 that is not followed by \"/MX"\ it looks up an IP address. If this turns out to
15468 be an interface on the local host and the item is not the first in the list,
15469 Exim discards it and any subsequent items. If it is the first item, what
15470 happens is controlled by the
15471 .index \self\ option||in \%manualroute%\ router
15472 \self\ option of the router.
15473
15474 A name on the list that is followed by \"/MX"\ is replaced with the list of
15475 hosts obtained by looking up MX records for the name. This is always a DNS
15476 lookup; the \bydns\ and \byname\ options (see section ~~SECThowoptused below)
15477 are not relevant here. The order of these hosts is determined by the preference
15478 values in the MX records, according to the usual rules. Because randomizing
15479 happens before the MX lookup, it does not affect the order that is defined by
15480 MX preferences.
15481
15482 If the local host is present in the sublist obtained from MX records, but is
15483 not the most preferred host in that list, it and any equally or less
15484 preferred hosts are removed before the sublist is inserted into the main list.
15485
15486 If the local host is the most preferred host in the MX list, what happens
15487 depends on where in the original list of hosts the \"/MX"\ item appears. If it
15488 is not the first item (that is, there are previous hosts in the main list),
15489 Exim discards this name and any subsequent items in the main list.
15490
15491 If the MX item is first in the list of hosts, and the local host is the
15492 most preferred host, what happens is controlled by the \self\ option of the
15493 router.
15494
15495 DNS failures when lookup up the MX records are treated in the same way as DNS
15496 failures when looking up IP addresses: \pass@_on@_timeout\ and
15497 \host@_find@_failed\ are used when relevant.
15498
15499 The generic \ignore@_target@_hosts\ option applies to all hosts in the list,
15500 whether obtained from an MX lookup or not.
15501
15502
15503 .section How the options are used
15504 .rset SECThowoptused "~~chapter.~~section"
15505 The options are a sequence of words; in practice no more than three are ever
15506 present. One of the words can be the name of a transport; this overrides the
15507 \transport\ option on the router for this particular routing rule only. The
15508 other words (if present) control randomization of the list of hosts on a
15509 per-rule basis, and how the IP addresses of the hosts are to be found when
15510 routing to a remote transport. These options are as follows:
15511 .numberpars $.
15512 \randomize\: randomize the order of the hosts in this list, overriding the
15513 setting of \hosts@_randomize\ for this routing rule only.
15514 .nextp
15515 \no@_randomize\: do not randomize the order of the hosts in this list,
15516 overriding the setting of \hosts@_randomize\ for this routing rule only.
15517 .nextp
15518 \byname\: use \*getipnodebyname()*\ (\*gethostbyname()*\ on older systems) to
15519 find IP addresses. This function may ultimately cause a DNS lookup, but it may
15520 also look in \(/etc/hosts)\ or other sources of information.
15521 .nextp
15522 \bydns\: look up address records for the hosts directly in the DNS; fail if
15523 no address records are found. If there is a temporary DNS error (such as a
15524 timeout), delivery is deferred.
15525 .endp
15526 For example:
15527 .display asis
15528 route_list = domain1  host1:host2:host3  randomize bydns;\
15529              domain2  host4:host5
15530 .endd
15531 If neither \byname\ nor \bydns\ is given, Exim behaves as follows: First, a DNS
15532 lookup is done. If this yields anything other than \\HOST@_NOT@_FOUND\\, that
15533 result is used. Otherwise, Exim goes on to try a call to \*getipnodebyname()*\
15534 or \*gethostbyname()*\, and the result of the lookup is the result of that
15535 call.
15536
15537 \**Warning**\: It has been discovered that on some systems, if a DNS lookup
15538 called via \*getipnodebyname()*\ times out, \\HOST@_NOT@_FOUND\\ is returned
15539 instead of \\TRY@_AGAIN\\. That is why the default action is to try a DNS
15540 lookup first. Only if that gives a definite `no such host' is the local
15541 function called.
15542
15543
15544
15545 If no IP address for a host can be found, what happens is controlled by the
15546 \host@_find@_failed\ option.
15547
15548 When an address is routed to a local transport, IP addresses are not looked up.
15549 The host list is passed to the transport in the \$host$\ variable.
15550
15551
15552 .section Manualroute examples
15553 In some of the examples that follow, the presence of the \remote@_smtp\
15554 transport, as defined in the default configuration file, is assumed:
15555
15556 .numberpars $.
15557 .index smart host||example router
15558 The \%manualroute%\ router can be used to forward all external mail to a
15559 \*smart host*\. If you have set up, in the main part of the configuration, a
15560 named domain list that contains your local domains, for example,
15561 .display asis
15562 domainlist local_domains = my.domain.example
15563 .endd
15564 you can arrange for all other domains to be routed to a smart host by making
15565 your first router something like this:
15566 .display asis
15567 smart_route:
15568   driver = manualroute
15569   domains = !+local_domains
15570   transport = remote_smtp
15571   route_list = * smarthost.ref.example
15572 .endd
15573 This causes all non-local addresses to be sent to the single host
15574 \*smarthost.ref.example*\. If a colon-separated list of smart hosts is given,
15575 they are tried in order
15576 (but you can use \hosts@_randomize\ to vary the order each time).
15577 Another way of configuring the same thing is this:
15578 .display asis
15579 smart_route:
15580   driver = manualroute
15581   transport = remote_smtp
15582   route_list = !+local_domains  smarthost.ref.example
15583 .endd
15584 There is no difference in behaviour between these two routers as they stand.
15585 However, they behave differently if \no@_more\ is added to them. In the first
15586 example, the router is skipped if the domain does not match the \domains\
15587 precondition; the following router is always tried. If the router runs, it
15588 always matches the domain and so can never decline. Therefore, \no@_more\ would
15589 have no effect. In the second case, the router is never skipped; it always
15590 runs. However, if it doesn't match the domain, it declines. In this case
15591 \no@_more\ would prevent subsequent routers from running.
15592
15593 .nextp
15594 .index mail hub example
15595 A \*mail hub*\ is a host which receives mail for a number of domains via MX
15596 records in the DNS and delivers it via its own private routing mechanism. Often
15597 the final destinations are behind a firewall, with the mail hub being the one
15598 machine that can connect to machines both inside and outside the firewall. The
15599 \%manualroute%\ router is usually used on a mail hub to route incoming messages
15600 to the correct hosts. For a small number of domains, the routing can be inline,
15601 using the \route@_list\ option, but for a larger number a file or database
15602 lookup is easier to manage.
15603
15604 If the domain names are in fact the names of the machines to which the mail is
15605 to be sent by the mail hub, the configuration can be quite simple. For
15606 example,
15607 .display asis
15608 hub_route:
15609   driver = manualroute
15610   transport = remote_smtp
15611   route_list = *.rhodes.tvs.example  $domain
15612 .endd
15613 This configuration routes domains that match \"*.rhodes.tvs.example"\ to hosts
15614 whose names are the same as the mail domains. A similar approach can be taken
15615 if the host name can be obtained from the domain name by a string manipulation
15616 that the expansion facilities can handle. Otherwise, a lookup based on the
15617 domain can be used to find the host:
15618 .display asis
15619 through_firewall:
15620   driver = manualroute
15621   transport = remote_smtp
15622   route_data = ${lookup {$domain} cdb {/internal/host/routes}}
15623 .endd
15624 The result of the lookup must be the name or IP address of the host (or
15625 hosts) to which the address is to be routed. If the lookup fails, the route
15626 data is empty, causing the router to decline. The address then passes to the
15627 next router.
15628
15629 .nextp
15630 .index batched SMTP output example
15631 .index SMTP||batched outgoing, example
15632 You can use \%manualroute%\ to deliver messages to pipes or files in batched
15633 SMTP format for onward transportation by some other means. This is one way of
15634 storing mail for a dial-up host when it is not connected. The route list entry
15635 can be as simple as a single domain name in a configuration like this:
15636 .display asis
15637 save_in_file:
15638   driver = manualroute
15639   transport = batchsmtp_appendfile
15640   route_list = saved.domain.example
15641 .endd
15642 though often a pattern is used to pick up more than one domain. If there are
15643 several domains or groups of domains with different transport requirements,
15644 different transports can be listed in the routing information:
15645 .display asis
15646 save_in_file:
15647   driver = manualroute
15648   route_list = \
15649     *.saved.domain1.example  $domain  batch_appendfile; \
15650     *.saved.domain2.example  \
15651       ${lookup{$domain}dbm{/domain2/hosts}{$value}fail} \
15652       batch_pipe
15653 .endd
15654 The first of these just passes the domain in the \$host$\ variable, which
15655 doesn't achieve much (since it is also in \$domain$\), but the second does a
15656 file lookup to find a value to pass, causing the router to decline to handle
15657 the address if the lookup fails.
15658 .nextp
15659 .index UUCP||example of router for
15660 Routing mail directly to UUCP software is a specific case of the use of
15661 \%manualroute%\ in a gateway to another mail environment. This is an example of
15662 one way it can be done:
15663 .display asis
15664 # Transport
15665 uucp:
15666   driver = pipe
15667   user = nobody
15668   command = /usr/local/bin/uux -r - \
15669     ${substr_-5:$host}!rmail ${local_part}
15670   return_fail_output = true
15671 .endd
15672 .display asis
15673 # Router
15674 uucphost:
15675   transport = uucp
15676   driver = manualroute
15677   route_data = \
15678     ${lookup{$domain}lsearch{/usr/local/exim/uucphosts}}
15679 .endd
15680 The file \(/usr/local/exim/uucphosts)\ contains entries like
15681 .display asis
15682 darksite.ethereal.example:           darksite.UUCP
15683 .endd
15684 It can be set up more simply without adding and removing `.UUCP' but this way
15685 makes clear the distinction between the domain name
15686 \*darksite.ethereal.example*\ and the UUCP host name \*darksite*\.
15687 .endp
15688
15689
15690
15691
15692
15693
15694 .
15695 .
15696 .
15697 .
15698 . ============================================================================
15699 .chapter The queryprogram router
15700 .set runningfoot "queryprogram router"
15701 .rset CHAPdriverlast "~~chapter"
15702 .index \%queryprogram%\ router
15703 .index routers||\%queryprogram%\
15704 .index routing||by external program
15705 The \%queryprogram%\ router routes an address by running an external command and
15706 acting on its output. This is an expensive way to route, and is intended mainly
15707 for use in lightly-loaded systems, or for performing experiments. However, if
15708 it is possible to use the precondition options (\domains\, \local@_parts\,
15709 etc) to skip this router for most addresses, it could sensibly be used in
15710 special cases, even on a busy host. There are the following private options:
15711
15712 .startconf queryprogram
15713 .index options||\%queryprogram%\ router
15714 .conf command string$**$ unset
15715 This option must be set. It specifies the command that is to be run. The
15716 command is split up into a command name and arguments, and then each is
15717 expanded separately (exactly as for a \%pipe%\ transport, described in chapter
15718 ~~CHAPpipetransport).
15719
15720 .conf command@_group string unset
15721 .index gid (group id)||in \%queryprogram%\ router
15722 This option specifies a gid to be set when running the command. It must be set
15723 if \command@_user\ specifies a numerical uid. If it begins with a digit, it is
15724 interpreted as the numerical value of the gid. Otherwise it is looked up using
15725 \*getgrnam()*\.
15726
15727 .conf command@_user string unset
15728 .index uid (user id)||for \%queryprogram%\
15729 This option must be set. It specifies the uid which is set when running the
15730 command. If it begins with a digit it is interpreted as the numerical value of
15731 the uid. Otherwise, it is looked up using \*getpwnam()*\ to obtain a value for
15732 the uid and, if \command@_group\ is not set, a value for the gid also.
15733
15734 .conf current@_directory string /
15735 This option specifies an absolute path which is made the current directory
15736 before running the command.
15737
15738 .conf timeout time 1h
15739 If the command does not complete within the timeout period, its process group
15740 is killed and the message is frozen. A value of zero time specifies no
15741 timeout.
15742
15743 .endconf
15744
15745 The standard output of the command is connected to a pipe, which is read when
15746 the command terminates. It should consist of a single line of output,
15747 containing up to five fields, separated by white space. 
15748 .em
15749 The maximum length of the line is 1023 characters. Longer lines are silently 
15750 truncated.
15751 .nem
15752 The first field is one of the following words (case-insensitive):
15753 .numberpars $.
15754 \*Accept*\: routing succeeded; the remaining fields specify what to do (see
15755 below).
15756 .nextp
15757 \*Decline*\: the router declines; pass the address to the next router, unless
15758 \no@_more\ is set.
15759 .nextp
15760 \*Fail*\: routing failed; do not pass the address to any more routers. Any
15761 subsequent text on the line is an error message. If the router is run as part
15762 of address verification during an incoming SMTP message, the message is
15763 included in the SMTP response.
15764 .nextp
15765 \*Defer*\: routing could not be completed at this time; try again later. Any
15766 subsequent text on the line is an error message which is logged. It is not
15767 included in any SMTP response.
15768 .nextp
15769 \*Freeze*\: the same as \*defer*\, except that the message is frozen.
15770 .nextp
15771 \*Pass*\: pass the address to the next router (or the router specified by
15772 \pass@_router\), overriding \no@_more\.
15773 .nextp
15774 \*Redirect*\: the message is redirected. The remainder of the line is a list of
15775 new addresses, which are routed independently, starting with the first router,
15776 or the router specified by \redirect@_router\, if set.
15777 .endp
15778 When the first word is \*accept*\, the remainder of the line consists of a
15779 number of keyed data values, as follows (split into two lines here, to fit on
15780 the page):
15781 .display
15782 ACCEPT TRANSPORT=<<transport>> HOSTS=<<list of hosts>>
15783        LOOKUP=byname|bydns DATA=<<text>>
15784 .endd
15785 The data items can be given in any order, and all are optional. If no transport
15786 is included, the transport specified by the generic \transport\ option is used.
15787 The list of hosts and the lookup type are needed only if the transport is an
15788 \%smtp%\ transport that does not itself supply a list of hosts.
15789
15790 The format of the list of hosts is the same as for the \%manualroute%\ router.
15791 As well as host names and IP addresses, it may contain names followed by
15792 \"/MX"\ to specify sublists of hosts that are obtained by looking up MX
15793 records.
15794
15795 If the lookup type is not specified, Exim behaves as follows when trying to
15796 find an IP address for each host: First, a DNS lookup is done. If this yields
15797 anything other than \\HOST@_NOT@_FOUND\\, that result is used. Otherwise, Exim
15798 goes on to try a call to \*getipnodebyname()*\ or \*gethostbyname()*\, and the
15799 result of the lookup is the result of that call.
15800
15801 If the DATA field is set, its value is placed in the \$address@_data$\
15802 variable. For example, this return line
15803 .display asis
15804 accept hosts=x1.y.example:x2.y.example data="rule1"
15805 .endd
15806 routes the address to the default transport, passing a list of two hosts. When
15807 the transport runs, the string `rule1' is in \$address@_data$\.
15808
15809
15810
15811 .
15812 .
15813 .
15814 .
15815 . ============================================================================
15816 .chapter The redirect router
15817 .set runningfoot "redirect router"
15818 .rset CHAPredirect "~~chapter"
15819 .index \%redirect%\ router
15820 .index routers||\%redirect%\
15821 .index alias file||in a \%redirect%\ router
15822 .index address redirection||\%redirect%\ router
15823 The \%redirect%\ router handles several kinds of address redirection. Its most
15824 common uses are for resolving local part aliases from a central alias file
15825 (usually called \(/etc/aliases)\) and for handling users' personal \(.forward)\
15826 files, but it has many other potential uses. The incoming address can be
15827 redirected in several different ways:
15828 .numberpars $.
15829 It can be replaced by one or more new addresses which are themselves routed
15830 independently.
15831 .nextp
15832 It can be routed to be delivered to a given file or directory.
15833 .nextp
15834 It can be routed to be delivered to a specified pipe command.
15835 .nextp
15836 It can cause an automatic reply to be generated.
15837 .nextp
15838 It can be forced to fail, with a custom error message.
15839 .nextp
15840 It can be temporarily deferred.
15841 .nextp
15842 It can be discarded.
15843 .endp
15844 The generic \transport\ option must not be set for \%redirect%\ routers.
15845 However, there are some private options which define transports for delivery to
15846 files and pipes, and for generating autoreplies. See the \file@_transport\,
15847 \pipe@_transport\ and \reply@_transport\ descriptions below.
15848
15849
15850 .section Redirection data
15851 The router operates by interpreting a text string which it obtains either by
15852 expanding the contents of the \data\ option, or by reading the entire contents
15853 of a file whose name is given in the \file\ option. These two options are
15854 mutually exclusive. The first is commonly used for handling system aliases, in
15855 a configuration like this:
15856 .display asis
15857 system_aliases:
15858   driver = redirect
15859   data = ${lookup{$local_part}lsearch{/etc/aliases}}
15860 .endd
15861 If the lookup fails, the expanded string in this example is empty. When the
15862 expansion of \data\ results in an empty string, the router declines. A forced
15863 expansion failure also causes the router to decline; other expansion failures
15864 cause delivery to be deferred.
15865
15866 A configuration using \file\ is commonly used for handling users' \(.forward)\
15867 files, like this:
15868 .display asis
15869 userforward:
15870   driver = redirect
15871   check_local_user
15872   file = $home/.forward
15873   no_verify
15874 .endd
15875 If the file does not exist, or causes no action to be taken (for example, it is
15876 empty or consists only of comments), the router declines. \**Warning**\: This
15877 is not the case when the file contains syntactically valid items that happen to
15878 yield empty addresses, for example, items containing only RFC 2822 address
15879 comments.
15880
15881
15882 .section Forward files and address verification
15883 .index address redirection||while verifying
15884 It is usual to set \no@_verify\ on \%redirect%\ routers which handle users'
15885 \(.forward)\ files, as in the example above. There are two reasons for this:
15886 .numberpars $.
15887 When Exim is receiving an incoming SMTP message from a remote host, it is
15888 running under the Exim uid, not as root.
15889 No additional groups are set up, even if the Exim uid is a member of other
15890 groups (that is, the \*initgroups()*\ function is not run).
15891 Exim is unable to change uid to read the file as the user, and it may not be
15892 able to read it as the Exim user. So in practice the router may not be able to
15893 operate.
15894 .nextp
15895 However, even when the router can operate, the existence of a \(.forward)\ file
15896 is unimportant when verifying an address. What should be checked is whether the
15897 local part is a valid user name or not. Cutting out the redirection processing
15898 saves some resources.
15899 .endp
15900
15901
15902
15903
15904 .section Interpreting redirection data
15905 .index Sieve filter||specifying in redirection data
15906 .index filter||specifying in redirection data
15907 The contents of the data string, whether obtained from \data\ or \file\, can be
15908 interpreted in two different ways:
15909 .numberpars $.
15910 If the \allow@_filter\ option is set true, and the data begins with the text
15911 `@#Exim filter' or `@#Sieve filter', it is interpreted as a list of
15912 \*filtering*\ instructions in the form of an Exim or Sieve filter file,
15913 respectively. Details of the syntax and semantics of filter files are described
15914 in a separate document entitled \*Exim's interfaces to mail filtering*\; this
15915 document is intended for use by end users.
15916 .nextp
15917 Otherwise, the data must be a comma-separated list of redirection items, as
15918 described in the next section.
15919 .endp
15920 When a message is redirected to a file (a `mail folder'), the file name given
15921 in a non-filter redirection list must always be an absolute path. A filter may
15922 generate a relative path -- how this is handled depends on the transport's
15923 configuration. See section ~~SECTfildiropt for a discussion of this issue for
15924 the \%appendfile%\ transport.
15925
15926
15927 .section Items in a non-filter redirection list
15928 .rset SECTitenonfilred "~~chapter.~~section"
15929 .index address redirection||non-filter list items
15930 When the redirection data is not an Exim or Sieve filter, for example, if it
15931 comes from a conventional alias or forward file, it consists of a list of
15932 addresses, file names, pipe commands, or certain special items (see section
15933 ~~SECTspecitredli below). The special items can be individually enabled or
15934 disabled by means of options whose names begin with \allow@_\ or \forbid@_\,
15935 depending on their default values. The items in the list are separated by
15936 commas or newlines.
15937 If a comma is required in an item, the entire item must be enclosed in double
15938 quotes.
15939
15940 Lines starting with a @# character are comments, and are ignored, and @# may
15941 also appear following a comma, in which case everything between the @# and the
15942 next newline character is ignored.
15943
15944 If an item is entirely enclosed in double quotes, these are removed. Otherwise
15945 double quotes are retained because some forms of mail address require their use
15946 (but never to enclose the entire address). In the following description, `item'
15947 refers to what remains after any surrounding double quotes have been removed.
15948
15949 \**Warning**\: If you use an Exim expansion to construct a redirection address,
15950 and the expansion contains a reference to \$local@_part$\, you should make use
15951 of the \quote\ expansion operator, in case the local part contains special
15952 characters. For example, to redirect all mail for the domain
15953 \*obsolete.example*\, retaining the existing local part, you could use this
15954 setting:
15955 .display asis
15956 data = ${quote:$local_part}@newdomain.example
15957 .endd
15958
15959
15960 .section Redirecting to a local mailbox
15961 .rset SECTredlocmai "~~chapter.~~section"
15962 .index routing||loops in
15963 .index loop||while routing, avoidance of
15964 .index address redirection||to local mailbox
15965 A redirection item may safely be the same as the address currently under
15966 consideration. This does not cause a routing loop, because a router is
15967 automatically skipped if any ancestor of the address that is being processed
15968 is the same as the current address and was processed by the current router.
15969 Such an address is therefore passed to the following routers, so it is handled
15970 as if there were no redirection. When making this loop-avoidance test, the
15971 complete local part, including any prefix or suffix, is used.
15972
15973 .index address redirection||local part without domain
15974 Specifying the same local part without a domain is a common usage in personal
15975 filter files when the user wants to have messages delivered to the local
15976 mailbox and also forwarded elsewhere. For example, the user whose login is
15977 \*cleo*\ might have a \(.forward)\ file containing this:
15978 .display asis
15979 cleo, cleopatra@egypt.example
15980 .endd
15981 .index backslash in alias file
15982 .index alias file||backslash in
15983 For compatibility with other MTAs, such unqualified local parts may be
15984 preceeded by `@\', but this is not a requirement for loop prevention. However,
15985 it does make a difference if more than one domain is being handled
15986 synonymously.
15987
15988 If an item begins with `@\' and the rest of the item parses as a valid RFC 2822
15989 address that does not include a domain, the item is qualified using the domain
15990 of the incoming address. In the absence of a leading `@\', unqualified
15991 addresses are qualified using the value in \qualify@_recipient\, but you can
15992 force the incoming domain to be used by setting \qualify__preserve@_domain\.
15993
15994 Care must be taken if there are alias names for local users.
15995 Consider an MTA handling a single local domain where the system alias file
15996 contains:
15997 .display asis
15998 Sam.Reman: spqr
15999 .endd
16000 Now suppose that Sam (whose login id is \*spqr*\) wants to save copies of
16001 messages in the local mailbox, and also forward copies elsewhere. He creates
16002 this forward file:
16003 .display asis
16004 Sam.Reman, spqr@reme.elsewhere.example
16005 .endd
16006 With these settings, an incoming message addressed to \*Sam.Reman*\ fails. The
16007 \%redirect%\ router for system aliases does not process \*Sam.Reman*\ the
16008 second time round, because it has previously routed it,
16009 and the following routers presumably cannot handle the alias. The forward file
16010 should really contain
16011 .display asis
16012 spqr, spqr@reme.elsewhere.example
16013 .endd
16014 but because this is such a common error, the \check@_ancestor\ option (see
16015 below) exists to provide a way to get round it. This is normally set on a
16016 \%redirect%\ router that is handling users' \(.forward)\ files.
16017
16018
16019 .section Special items in redirection lists
16020 .rset SECTspecitredli "~~chapter.~~section"
16021 In addition to addresses, the following types of item may appear in redirection
16022 lists (that is, in non-filter redirection data):
16023
16024 .numberpars $.
16025 .index pipe||in redirection list
16026 .index address redirection||to pipe
16027 An item is treated as a pipe command if it begins with `|' and does not parse
16028 as a valid RFC 2822 address that includes a domain. A transport for running the
16029 command must be specified by the \pipe@_transport\ option.
16030 Normally, either the router or the transport specifies a user and a group under
16031 which to run the delivery. The default is to use the Exim user and group.
16032
16033 Single or double quotes can be used for enclosing the individual arguments of
16034 the pipe command; no interpretation of escapes is done for single quotes. If
16035 the command contains a comma character, it is necessary to put the whole item
16036 in double quotes, for example:
16037 .display asis
16038 "|/some/command ready,steady,go"
16039 .endd
16040 since items in redirection lists are terminated by commas. Do not, however,
16041 quote just the command. An item such as
16042 .display asis
16043 |"/some/command ready,steady,go"
16044 .endd
16045 is interpreted as a pipe with a rather strange command name, and no arguments.
16046 .nextp
16047 .index file||in redirection list
16048 .index address redirection||to file
16049 An item is interpreted as a path name if it begins with `/' and does not parse
16050 as a valid RFC 2822 address that includes a domain. For example,
16051 .display asis
16052 /home/world/minbari
16053 .endd
16054 is treated as a file name, but
16055 .display asis
16056 /s=molari/o=babylon/@x400gate.way
16057 .endd
16058 is treated as an address. For a file name, a transport must be specified using
16059 the \file@_transport\ option. However, if the generated path name ends with a
16060 forward slash character, it is interpreted as a directory name rather than a
16061 file name, and \directory@_transport\ is used instead.
16062
16063 Normally, either the router or the transport specifies a user and a group under
16064 which to run the delivery. The default is to use the Exim user and group.
16065 .index \(/dev/null)\
16066 However, if a redirection item is the path \(/dev/null)\, delivery to it is
16067 bypassed at a high level, and the log entry shows `$*$$*$bypassed$*$$*$'
16068 instead of a transport name. In this case the user and group are not used.
16069 .nextp
16070 .index included address list
16071 .index address redirection||included external list
16072 If an item is of the form
16073 .display
16074 :include:<<path name>>
16075 .endd
16076 a list of further items is taken from the given file and included at that
16077 point.
16078 \**Note**\: such a file can not be a filter file; it is just an out-of-line
16079 addition to the list.
16080 The items in the included list are separated by commas or newlines and are not
16081 subject to expansion. If this is the first item in an alias list in an
16082 \%lsearch%\ file, a colon must be used to terminate the alias name. This
16083 example is incorrect:
16084 .display asis
16085 list1    :include:/opt/lists/list1
16086 .endd
16087 It must be given as
16088 .display asis
16089 list1:   :include:/opt/lists/list1
16090 .endd
16091 .nextp
16092 .index address redirection||to black hole
16093 Sometimes you want to throw away mail to a particular local part. Making the
16094 \data\ option expand to an empty string does not work, because that causes the
16095 router to decline. Instead, the alias item
16096 .index black hole
16097 .index abandoning mail
16098 .display
16099 :blackhole:
16100 .endd
16101 can be used. It does what its name implies. No delivery is done, and no error
16102 message is generated. This has the same effect as specifing \(/dev/null)\, but
16103 can be independently disabled.
16104
16105 \**Warning**\: If \":blackhole:"\ appears anywhere in a redirection list, no
16106 delivery is done for the original local part, even if other redirection items
16107 are present. If you are generating a multi-item list (for example, by reading a
16108 database) and need the ability to provide a no-op item, you must use
16109 \(/dev/null)\.
16110
16111 .nextp
16112 .index delivery||forcing failure
16113 .index delivery||forcing deferral
16114 .index failing delivery||forcing
16115 .index deferred delivery, forcing
16116 .index customizing||failure message
16117 An attempt to deliver a particular address can be deferred or forced to fail by
16118 redirection items of the form
16119 .display
16120 :defer:
16121 $rm{or}
16122 :fail:
16123 .endd
16124 respectively. When a redirection list contains such an item, it applies to the
16125 entire redirection; any other items in the list are ignored (:::blackhole:: is
16126 different). Any text following :::fail:: or :::defer:: is placed in the error
16127 text associated with the failure. For example, an alias file might contain:
16128 .display asis
16129 X.Employee:  :fail: Gone away, no forwarding address
16130 .endd
16131 In the case of an address that is being verified from an ACL or as the subject
16132 of a 
16133 .index \\VRFY\\||error text, display of
16134 \\VRFY\\ command, the text is included in the SMTP error response by
16135 default. 
16136 .em
16137 .index \\EXPN\\||error text, display of
16138 The text is not included in the response to an \\EXPN\\ command.
16139 .nem
16140
16141 In an ACL, an explicitly provided message overrides the default, but the
16142 default message is available in the variable \$acl@_verify@_message$\ and can
16143 therefore be included in a custom message if this is desired. Exim sends a 451
16144 SMTP code for a :::defer::, and 550 for :::fail::. In non-SMTP cases the text
16145 is included in the error message that Exim generates.
16146
16147
16148
16149 Normally the error text is the rest of the redirection list -- a comma does not
16150 terminate it -- but a newline does act as a terminator. Newlines are not
16151 normally present in alias expansions. In \%lsearch%\ lookups they are removed as
16152 part of the continuation process, but they may exist in other kinds of lookup
16153 and in :::include:: files.
16154
16155 During routing for message delivery (as opposed to verification), a redirection
16156 containing :::fail:: causes an immediate failure of the incoming address,
16157 whereas :::defer:: causes the message to remain on the queue so that a
16158 subsequent delivery attempt can happen at a later time. If an address is
16159 deferred for too long, it will ultimately fail, because the normal retry
16160 rules still apply.
16161 .nextp
16162 .index alias file||exception to default
16163 Sometimes it is useful to use a single-key search type with a default (see
16164 chapter ~~CHAPfdlookup) to look up aliases. However, there may be a need for
16165 exceptions to the default. These can be handled by aliasing them to
16166 .display asis
16167 :unknown:
16168 .endd
16169 This differs from :::fail:: in that it causes the \%redirect%\ router to decline,
16170 whereas :::fail:: forces routing to fail. A lookup which results in an empty
16171 redirection list has the same effect.
16172 .endp
16173
16174 .section Duplicate addresses
16175 .index duplicate addresses
16176 .index address||duplicate, discarding
16177 .index pipe||duplicated
16178 Exim removes duplicate addresses from the list to which it is delivering, so as
16179 to deliver just one copy to each address. This does not apply to deliveries
16180 routed to pipes by different immediate parent addresses, but an indirect
16181 aliasing scheme of the type
16182 .display asis
16183 pipe:       |/some/command $local_part
16184 localpart1: pipe
16185 localpart2: pipe
16186 .endd
16187 does not work with a message that is addressed to both local parts, because
16188 when the second is aliased to the intermediate local part `pipe' it gets
16189 discarded as being the same as a previously handled address. However, a scheme
16190 such as
16191 .display asis
16192 localpart1: |/some/command $local_part
16193 localpart2: |/some/command $local_part
16194 .endd
16195 does result in two different pipe deliveries, because the immediate parents of
16196 the pipes are distinct.
16197
16198
16199 .section Repeated redirection expansion
16200 .index repeated redirection expansion
16201 .index address redirection||repeated for each delivery attempt
16202 When a message cannot be delivered to all of its recipients immediately,
16203 leading to two or more delivery attempts, redirection expansion is carried out
16204 afresh each time for those addresses whose children were not all previously
16205 delivered. If redirection is being used as a mailing list, this can lead to new
16206 members of the list receiving copies of old messages. The \one@_time\ option
16207 can be used to avoid this.
16208
16209 .section Errors in redirection lists
16210 .index address redirection||errors
16211 If \skip@_syntax@_errors\ is set, a malformed address that causes a parsing
16212 error is skipped, and an entry is written to the main log. This may be useful
16213 for mailing lists that are automatically managed. Otherwise, if an error is
16214 detected while generating the list of new addresses, the original address is
16215 deferred. See also \syntax@_errors@_to\.
16216
16217
16218 .section Private options for the redirect router
16219
16220 The private options for the \%redirect%\ router are as follows:
16221
16222 .startconf redirect
16223 .index options||\%redirect%\ router
16224
16225 .conf allow@_defer boolean false
16226 Setting this option allows the use of :::defer:: in non-filter redirection
16227 data,
16228 or the \defer\ command in an Exim filter file.
16229
16230 .conf allow@_fail boolean false
16231 .index failing delivery||from filter
16232 If this option is true, the :::fail:: item can be used in a redirection list,
16233 and the \fail\ command may be used in a filter file.
16234
16235 .conf allow@_filter boolean false
16236 .index filter||enabling use of
16237 .index Sieve filter||enabling use of
16238 Setting this option allows Exim to interpret redirection data that starts with
16239 `@#Exim filter' or `@#Sieve filter' as a set of filtering instructions. There
16240 are some features of Exim filter files that some administrators may wish to
16241 lock out; see the \forbid@_filter@_xxx\ options below. 
16242 .em
16243 It is also possible to lock out Exim filters or Sieve filters while allowing 
16244 the other type; see \forbid@_exim@_filter\ and \forbid@_sieve@_filter\.
16245 .nem
16246
16247 The filter is run using the uid and gid set by the generic \user\ and \group\
16248 options. These take their defaults from the password data if
16249 \check@_local@_user\ is set, so in the normal case of users' personal filter
16250 files, the filter is run as the relevant user. When \allow@_filter\ is set
16251 true, Exim insists that either \check@_local@_user\ or \user\ is set.
16252
16253
16254 .conf allow@_freeze boolean false
16255 .index freezing messages||allowing in filter
16256 Setting this option allows the use of the \freeze\ command in an Exim filter.
16257 This command is more normally encountered in system filters, and is disabled by
16258 default for redirection filters because it isn't something you usually want to
16259 let ordinary users do.
16260
16261
16262 .conf check@_ancestor boolean false
16263 This option is concerned with handling generated addresses that are the same
16264 as some address in the list of redirection ancestors of the current address.
16265 Although it is turned off by default in the code, it is set in the default
16266 configuration file for handling users' \(.forward)\ files. It is recommended
16267 for this use of the \%redirect%\ router.
16268
16269 When \check@_ancestor\ is set, if a generated address (including the domain) is
16270 the same as any ancestor of the current address, it is replaced by a copy of
16271 the current address. This helps in the case where local part A is aliased to B,
16272 and B has a \(.forward)\ file pointing back to A. For example, within a single
16273 domain, the local part `Joe.Bloggs' is aliased to `jb' and \(@~jb/.forward)\
16274 contains:
16275 .display
16276 @\Joe.Bloggs, <<other item(s)>>
16277 .endd
16278 Without the \check@_ancestor\ setting, either local part (`jb' or `joe.bloggs')
16279 gets processed once by each router and so ends up as it was originally. If `jb'
16280 is the real mailbox name, mail to `jb' gets delivered (having been turned into
16281 `joe.bloggs' by the \(.forward)\ file and back to `jb' by the alias), but mail
16282 to `joe.bloggs' fails. Setting \check@_ancestor\ on the \%redirect%\ router that
16283 handles the \(.forward)\ file prevents it from turning `jb' back into
16284 `joe.bloggs' when that was the original address. See also the \repeat@_use\
16285 option below.
16286
16287 .conf check@_group boolean "see below"
16288 When the \file\ option is used, the group owner of the file is checked only
16289 when this option is set. The permitted groups are those listed in the
16290 \owngroups\ option, together with the user's default group if
16291 \check@_local@_user\ is set. If the file has the wrong group, routing is
16292 deferred. The default setting for this option is true if \check@_local@_user\
16293 is set and the \modemask\ option permits the group write bit, or if the
16294 \owngroups\ option is set. Otherwise it is false, and no group check occurs.
16295
16296
16297 .conf check@_owner boolean "see below"
16298 When the \file\ option is used, the owner of the file is checked only when this
16299 option is set. If \check@_local@_user\ is set, the local user is permitted;
16300 otherwise the owner must be one of those listed in the \owners\ option. The
16301 default value for this option is true if \check@_local@_user\ or \owners\ is
16302 set. Otherwise the default is false, and no owner check occurs.
16303
16304 .conf data string$**$ unset
16305 This option is mutually exclusive with \file\. One or other of them must be
16306 set, but not both. The contents of \data\ are expanded, and then used as the
16307 list of forwarding items, or as a set of filtering instructions. If the
16308 expansion is forced to fail, or the result is an empty string or a string that
16309 has no effect (consists entirely of comments), the router declines.
16310
16311 When filtering instructions are used, the string must begin with `@#Exim
16312 filter', and all comments in the string, including this initial one, must be
16313 terminated with newline characters. For example:
16314 .display asis
16315 data = #Exim filter\n\
16316        if $h_to: contains Exim then save $home/mail/exim endif
16317 .endd
16318 If you are reading the data from a database where newlines cannot be included,
16319 you can use the \$@{sg@}$\ expansion item to turn the escape string of your
16320 choice into a newline.
16321
16322 .conf directory@_transport string$**$ unset
16323 A \%redirect%\ router sets up a direct delivery to a directory when a path name
16324 ending with a slash is specified as a new `address'. The transport used is
16325 specified by this option, which, after expansion, must be the name of a
16326 configured transport. This should normally be an \%appendfile%\ transport.
16327
16328 .conf file string$**$ unset
16329 This option specifies the name of a file that contains the redirection data. It
16330 is mutually exclusive with the \data\ option. The string is expanded before
16331 use; if the expansion is forced to fail, the router declines. Other expansion
16332 failures cause delivery to be deferred. The result of a successful expansion
16333 must be an absolute path. The entire file is read and used as the redirection
16334 data. If the data is an empty string or a string that has no effect (consists
16335 entirely of comments), the router declines.
16336
16337 .index NFS||checking for file existence
16338 If the attempt to open the file fails with a `does not exist' error, Exim
16339 runs a check on the containing directory,
16340 unless \ignore@_enotdir\ is true (see below).
16341 If the directory does not appear to exist, delivery is deferred. This can
16342 happen when users' \(.forward)\ files are in NFS-mounted directories, and there
16343 is a mount problem. If the containing directory does exist, but the file does
16344 not, the router declines.
16345
16346 .conf file@_transport string$**$ unset
16347 A \%redirect%\ router sets up a direct delivery to a file when a path name not
16348 ending in a slash is specified as a new `address'. The transport used is
16349 specified by this option, which, after expansion, must be the name of a
16350 configured transport.
16351 This should normally be an \%appendfile%\ transport.
16352 When it is running, the file name is in \$address@_file$\.
16353
16354 .conf forbid@_blackhole boolean false
16355 If this option is true, the :::blackhole:: item may not appear in a redirection
16356 list.
16357
16358 .em
16359 .conf forbid@_exim@_filter boolean false
16360 If this option is set true, only Sieve filters are permitted when 
16361 \allow@_filter\ is true.
16362 .nem
16363
16364
16365 .conf forbid@_file boolean false
16366 .index delivery||to file, forbidding
16367 .index Sieve filter||forbidding delivery to a file
16368 .index Sieve filter||`keep' facility, disabling
16369 If this option is true, this router may not generate a new address that
16370 specifies delivery to a local file or directory, either from a filter or from a
16371 conventional forward file. This option is forced to be true if \one@_time\ is
16372 set. It applies to Sieve filters as well as to Exim filters, but if true, it
16373 locks out the Sieve's `keep' facility.
16374
16375 .conf forbid@_filter@_existstest boolean false
16376 .index filter||locking out certain features
16377 If this option is true, string expansions in Exim filters are not allowed to
16378 make use of the \exists\ condition.
16379
16380 .conf forbid@_filter@_logwrite boolean false
16381 If this option is true, use of the logging facility in Exim filters is not
16382 permitted. Logging is in any case available only if the filter is being run
16383 under some unprivileged uid (which is normally the case for ordinary users'
16384 \(.forward)\ files).
16385
16386 .conf forbid@_filter@_lookup boolean false
16387 If this option is true, string expansions in Exim filter files are not allowed
16388 to make use of \lookup\ items.
16389
16390 .conf forbid@_filter@_perl boolean false
16391 This option is available only if Exim is built with embedded Perl support. If
16392 it is true, string expansions in Exim filter files are not allowed to make use
16393 of the embedded Perl support.
16394
16395 .conf forbid@_filter@_readfile boolean false
16396 If this option is true, string expansions in Exim filter files are not allowed
16397 to make use of \readfile\ items.
16398
16399 .conf forbid@_filter@_readsocket boolean false
16400 If this option is true, string expansions in Exim filter files are not allowed
16401 to make use of \readsocket\ items.
16402
16403 .conf forbid@_filter@_reply boolean false
16404 If this option is true, this router may not generate an automatic reply
16405 message. Automatic replies can be generated only from Exim 
16406 .em
16407 or Sieve filter files, not from traditional forward files.
16408 .nem
16409 This option is forced to be true if \one@_time\ is set.
16410
16411 .conf forbid@_filter@_run boolean false
16412 If this option is true, string expansions in Exim filter files are not allowed
16413 to make use of \run\ items.
16414
16415 .conf forbid@_include boolean false
16416 If this option is true, items of the form
16417 .display
16418 :include:<<path name>>
16419 .endd
16420 are not permitted in non-filter redirection lists.
16421
16422 .conf forbid@_pipe boolean false
16423 .index delivery||to pipe, forbidding
16424 If this option is true, this router may not generate a new address which
16425 specifies delivery to a pipe, either from an Exim filter or from a conventional
16426 forward file. This option is forced to be true if \one@_time\ is set.
16427
16428 .em
16429 .conf forbid@_sieve@_filter boolean false
16430 If this option is set true, only Exim filters are permitted when 
16431 \allow@_filter\ is true.
16432 .nem
16433
16434
16435 .conf hide@_child@_in@_errmsg boolean false
16436 .index bounce message||redirection details, suppressing
16437 If this option is true, it prevents Exim from quoting a child address if it
16438 generates a bounce or delay message for it. Instead it says `an address
16439 generated from <<the top level address>>'. Of course, this applies only to
16440 bounces generated locally. If a message is forwarded to another host, $it{its}
16441 bounce may well quote the generated address.
16442
16443 .conf ignore@_eacces boolean false
16444 .index \\EACCES\\
16445 If this option is set and an attempt to open a redirection file yields the
16446 \\EACCES\\ error (permission denied), the \%redirect%\ router behaves as if the
16447 file did not exist.
16448
16449 .conf ignore@_enotdir boolean false
16450 .index \\ENOTDIR\\
16451 If this option is set and an attempt to open a redirection file yields the
16452 \\ENOTDIR\\ error (something on the path is not a directory), the \%redirect%\
16453 router behaves as if the file did not exist.
16454
16455 Setting \ignore@_enotdir\ has another effect as well: When a \%redirect%\
16456 router that has the \file\ option set discovers that the file does not exist
16457 (the \\ENOENT\\ error), it tries to \*stat()*\ the parent directory, as a check
16458 against unmounted NFS directories. If the parent can not be statted, delivery
16459 is deferred. However, it seems wrong to do this check when \ignore@_enotdir\ is
16460 set, because that option tells Exim to ignore `something on the path is not a
16461 directory' (the \\ENOTDIR\\ error). This is a confusing area, because it seems
16462 that some operating systems give \\ENOENT\\ where others give \\ENOTDIR\\.
16463
16464
16465 .conf include@_directory string unset
16466 If this option is set, the path names of any :::include:: items in a redirection
16467 list must start with this directory.
16468
16469 .conf modemask "octal integer" 022
16470 This specifies mode bits which must not be set for a file specified by the
16471 \file\ option. If any of the forbidden bits are set, delivery is deferred.
16472
16473 .conf one@_time boolean false
16474 .index one-time aliasing/forwarding expansion
16475 .index alias file||one-time expansion
16476 .index forward file||one-time expansion
16477 .index mailing lists||one-time expansion
16478 .index address redirection||one-time expansion
16479 Sometimes the fact that Exim re-evaluates aliases and reprocesses redirection
16480 files each time it tries to deliver a message causes a problem
16481 when one or more of the generated addresses fails be delivered at the first
16482 attempt. The problem is not one of duplicate delivery -- Exim is clever enough
16483 to handle that -- but of what happens when the redirection list changes during
16484 the time that the message is on Exim's queue. This is particularly true in the
16485 case of mailing lists, where new subscribers might receive copies of messages
16486 that were posted before they subscribed.
16487
16488 If \one@_time\ is set and any addresses generated by the router fail to
16489 deliver at the first attempt, the failing addresses are added to the message as
16490 `top level' addresses, and the parent address that generated them is marked
16491 `delivered'. Thus, redirection does not happen again at the next
16492 delivery attempt.
16493
16494 \**Warning 1**\: This means that any header line addition or removal that is
16495 specified by this router would be lost if delivery did not succeed at the
16496 first attempt. For this reason, the \headers@_add\ and \headers@_remove\
16497 generic options are not permitted when \one@_time\ is set.
16498
16499 \**Warning 2**\: To ensure that the router generates only addresses (as opposed
16500 to pipe or file deliveries or auto-replies) \forbid@_file\, \forbid@_pipe\,
16501 and \forbid@_filter@_reply\ are forced to be true when \one@_time\ is set.
16502
16503 The original top-level address is remembered with each of the generated
16504 addresses, and is output in any log messages. However, any intermediate parent
16505 addresses are not recorded. This makes a difference to the log only if
16506 \all__parents\ log selector is set. It is expected that \one@_time\ will
16507 typically be used for mailing lists, where there is normally just one level of
16508 expansion.
16509
16510 .conf owners "string list" unset
16511 .index ownership||alias file
16512 .index ownership||forward file
16513 .index alias file||ownership
16514 .index forward file||ownership
16515 This specifies a list of permitted owners for the file specified by \file\.
16516 This list is in addition to the local user when \check@_local@_user\ is set.
16517 See \check@_owner\ above.
16518
16519 .conf owngroups "string list" unset
16520 This specifies a list of permitted groups for the file specified by \file\. The
16521 list is in addition to the local user's primary group when \check@_local@_user\
16522 is set. See \check@_group\ above.
16523
16524 .conf pipe@_transport string$**$ unset
16525 A \%redirect%\ router sets up a direct delivery to a pipe when a string starting
16526 with a vertical bar character is specified as a new `address'. The transport
16527 used is specified by this option, which, after expansion, must be the name of a
16528 configured transport.
16529 This should normally be a \%pipe%\ transport.
16530 When the transport is run, the pipe command is in \$address@_pipe$\.
16531
16532 .conf qualify@_domain string$**$ unset
16533 If this option is set and an unqualified address (one without a domain) is
16534 generated, it is qualified with the domain specified by expanding this string,
16535 instead of the global setting in \qualify@_recipient\. If the expansion fails,
16536 the router declines. If you want to revert to the default, you can have the
16537 expansion generate \$qualify@_recipient$\.
16538
16539 .conf qualify@_preserve@_domain boolean false
16540 .index domain||in redirection, preserving
16541 .index preserving domain in redirection
16542 .index address redirection||domain, preserving
16543 If this is set and an unqualified address (one without a domain) is generated,
16544 it is qualified with the domain of the
16545 parent address (the immediately preceding ancestor) instead of the local
16546 \qualify@_domain\ or global \qualify@_recipient\ value.
16547
16548 .conf repeat@_use boolean true
16549 If this option is set false, the router is skipped for a child address that has
16550 any ancestor that was routed by this router. This test happens before any of
16551 the other preconditions are tested. Exim's default anti-looping rules skip
16552 only when the ancestor is the same as the current address. See also
16553 \check@_ancestor\ above and the generic \redirect@_router\ option.
16554
16555 .conf reply@_transport string$**$ unset
16556 A \%redirect%\ router sets up an automatic reply when a \mail\ or \vacation\
16557 command is used in a filter file. The transport used is specified by this
16558 option, which, after expansion, must be the name of a configured transport.
16559 This should normally be an \%autoreply%\ transport. Other transports are
16560 unlikely to do anything sensible or useful.
16561
16562 .conf rewrite boolean true
16563 .index address redirection||disabling rewriting
16564 If this option is set false, addresses generated by the router are not
16565 subject to address rewriting. Otherwise, they are treated like new addresses
16566 and are rewritten according to the global rewriting rules.
16567
16568
16569 .em
16570 .conf sieve@_vacation@_directory string$**$ unset
16571 .index Sieve filter||vacation directory
16572 To enable the `vacation' extension for Sieve filters, you must set
16573 \sieve@_vacation@_directory\ to the directory where vacation databases are held
16574 (do not put anything else in that directory), and ensure that the
16575 \reply@_transport\ option refers to an \%autoreply%\ transport.
16576 .nem
16577
16578
16579 .conf skip@_syntax@_errors boolean false
16580 .index forward file||broken
16581 .index address redirection||broken files
16582 .index alias file||broken
16583 .index broken alias or forward files
16584 .index ignoring faulty addresses
16585 .index skipping faulty addresses
16586 .index error||skipping bad syntax
16587 If \skip@_syntax@_errors\ is set, syntactically malformed addresses in
16588 non-filter redirection data are skipped, and each failing address is logged. If
16589 \syntax@_errors@_to\ is set, a message is sent to the address it defines,
16590 giving details of the failures. If \syntax@_errors@_text\ is set, its contents
16591 are expanded and placed at the head of the error message generated by
16592 \syntax@_errors@_to\. Usually it is appropriate to set \syntax@_errors@_to\ to
16593 be the same address as the generic \errors@_to\ option. The
16594 \skip@_syntax@_errors\ option is often used when handling mailing lists.
16595
16596 If all the addresses in a redirection list are skipped because of syntax
16597 errors, the router declines to handle the original address, and it is passed to
16598 the following routers.
16599
16600 If \skip@_syntax@_errors\ is set when an Exim filter is interpreted, any syntax
16601 error in the filter causes filtering to be abandoned without any action being
16602 taken. The incident is logged, and the router declines to handle the address,
16603 so it is passed to the following routers.
16604
16605 .index Sieve filter||syntax errors in
16606 .em
16607 Syntax errors in a Sieve filter file cause the `keep' action to
16608 occur. This action is specified by RFC 3028.
16609 .nem
16610 The values of \skip@_syntax@_errors\, \syntax@_errors@_to\, and
16611 \syntax@_errors@_text\ are not used.
16612
16613 \skip@_syntax@_errors\ can be used to specify that errors in users' forward
16614 lists or filter files should not prevent delivery. The \syntax@_errors@_to\
16615 option, used with an address that does not get redirected, can be used to
16616 notify users of these errors, by means of a router like this:
16617 .display flow asis
16618 userforward:
16619   driver = redirect
16620   allow_filter
16621   check_local_user
16622   file = $home/.forward
16623   file_transport = address_file
16624   pipe_transport = address_pipe
16625   reply_transport = address_reply
16626   no_verify
16627   skip_syntax_errors
16628   syntax_errors_to = real-$local_part@$domain
16629   syntax_errors_text = \
16630     This is an automatically generated message. An error has\n\
16631     been found in your .forward file. Details of the error are\n\
16632     reported below. While this error persists, you will receive\n\
16633     a copy of this message for every message that is addressed\n\
16634     to you. If your .forward file is a filter file, or if it is\n\
16635     a non-filter file containing no valid forwarding addresses,\n\
16636     a copy of each incoming message will be put in your normal\n\
16637     mailbox. If a non-filter file contains at least one valid\n\
16638     forwarding address, forwarding to the valid addresses will\n\
16639     happen, and those will be the only deliveries that occur.
16640 .endd
16641 You also need a router to ensure that local addresses that are prefixed by
16642 \"real-"\ are recognized, but not forwarded or filtered. For example, you could
16643 put this immediately before the \%userforward%\ router:
16644 .display asis
16645 real_localuser:
16646   driver = accept
16647   check_local_user
16648   local_part_prefix = real-
16649   transport = local_delivery
16650 .endd
16651
16652 .conf syntax@_errors@_text string$**$ unset
16653 See \skip@_syntax@_errors\ above.
16654
16655 .conf syntax@_errors@_to string unset
16656 See \skip@_syntax@_errors\ above.
16657
16658 .endconf
16659
16660
16661
16662
16663
16664 .
16665 .
16666 .
16667 . ============================================================================
16668 .chapter Environment for running local transports
16669 .rset CHAPenvironment "~~chapter"
16670 .set runningfoot "local transport environment"
16671 .index local transports||environment for
16672 .index environment for local transports
16673 .index transport||local, environment for
16674 Local transports handle deliveries to files and pipes. (The \%autoreply%\
16675 transport can be thought of as similar to a pipe.) Exim always runs transports
16676 in subprocesses, under specified uids and gids. Typical deliveries to local
16677 mailboxes run under the uid and gid of the local user.
16678
16679 Exim also sets a specific current directory while running the transport; for
16680 some transports a home directory setting is also relevant. The \%pipe%\
16681 transport is the only one that sets up environment variables; see section
16682 ~~SECTpipeenv for details.
16683
16684 The values used for the uid, gid, and the directories may come from several
16685 different places. In many cases, the router that handles the address associates
16686 settings with that address as a result of its \check@_local@_user\, \group\, or
16687 \user\ options. However, values may also be given in the transport's own
16688 configuration, and these override anything that comes from the router.
16689
16690
16691 .em
16692 .section Concurrent deliveries
16693 .index concurrent deliveries
16694 .index simultaneous deliveries
16695 If two different messages for the same local recpient arrive more or less 
16696 simultaneously, the two delivery processes are likely to run concurrently. When 
16697 the \%appendfile%\ transport is used to write to a file, Exim applies locking 
16698 rules to stop concurrent processes from writing to the same file at the same 
16699 time.
16700
16701 However, when you use a \%pipe%\ transport, it is up to you to arrange any 
16702 locking that is needed. Here is a silly example:
16703 .display asis
16704 my_transport:
16705   driver = pipe
16706   command = /bin/sh -c 'cat >>/some/file'
16707 .endd    
16708 This is supposed to write the message at the end of the file. However, if two
16709 messages arrive at the same time, the file will be scrambled. You can use the
16710 \exim@_lock\ utility program (see section ~~SECTmailboxmaint) to lock a file
16711 using the same algorithm that Exim itself uses.
16712 .nem
16713
16714
16715 .section Uids and gids
16716 .rset SECTenvuidgid "~~chapter.~~section"
16717 .index local transports||uid and gid
16718 .index transport||local, uid and gid
16719 All transports have the options \group\ and \user\. If \group\ is set, it
16720 overrides any group that the router set in the address, even if \user\ is not
16721 set for the transport. This makes it possible, for example, to run local mail
16722 delivery under the uid of the recipient (set by the router), but in a special
16723 group (set by the transport). For example:
16724 .display asis
16725 # Routers ...
16726 # User/group are set by check_local_user in this router
16727 local_users:
16728   driver = accept
16729   check_local_user
16730   transport = group_delivery
16731
16732 # Transports ...
16733 # This transport overrides the group
16734 group_delivery:
16735   driver = appendfile
16736   file = /var/spool/mail/$local_part
16737   group = mail
16738 .endd
16739 If \user\ is set for a transport, its value overrides what is set in the
16740 address. If \user\ is non-numeric and \group\ is not set, the gid associated
16741 with the user is used. If \user\ is numeric, \group\ must be set.
16742
16743 .index \initgroups\ option
16744 When the uid is taken from the transport's configuration, the \*initgroups()*\
16745 function is called for the groups associated with that uid if the \initgroups\
16746 option is set for the transport. When the uid is not specified by the
16747 transport, but is associated with the address by a router, the option for
16748 calling \*initgroups()*\ is taken from the router configuration.
16749
16750 .index \%pipe%\ transport||uid for
16751 The \%pipe%\ transport contains the special option \pipe@_as@_creator\. If this
16752 is set and \user\ is not set, the uid of the process that called Exim to
16753 receive the message is used, and if \group\ is not set, the corresponding
16754 original gid is also used.
16755
16756
16757 .section Current and home directories
16758 .index current directory for local transport
16759 .index home directory||for local transport
16760 .index transport||local, home directory for
16761 .index transport||local, current directory for
16762 Routers may set current and home directories for local transports by means of
16763 the \transport__current@_directory\ and \transport@_home@_directory\ options.
16764 However, if the transport's \current__directory\ or \home@_directory\ options
16765 are set, they override the router's values. In detail, the home directory
16766 for a local transport is taken from the first of these values that is set:
16767 .numberpars $.
16768 The \home@_directory\ option on the transport;
16769 .nextp
16770 The \transport@_home@_directory\ option on the router;
16771 .nextp
16772 The password data if \check@_local@_user\ is set on the router;
16773 .nextp
16774 The \router@_home@_directory\ option on the router.
16775 .endp
16776 The current directory is taken from the first of these values that is set:
16777 .numberpars $.
16778 The \current@_directory\ option on the transport;
16779 .nextp
16780 The \transport@_current@_directory\ option on the router.
16781 .endp
16782
16783 If neither the router nor the transport sets a current directory, Exim uses the
16784 value of the home directory, if it is set. Otherwise it sets the current
16785 directory to \(/)\ before running a local transport.
16786
16787
16788 .section Expansion variables derived from the address
16789 Normally a local delivery is handling a single address, and in that case the
16790 variables such as \$domain$\ and \$local@_part$\ are set during local
16791 deliveries. However, in some circumstances more than one address may be handled
16792 at once (for example, while writing batch SMTP for onward transmission by some
16793 other means). In this case, the variables associated with the local part are
16794 never set, \$domain$\ is set only if all the addresses have the same
16795 domain, and \$original@_domain$\ is never set.
16796
16797
16798
16799
16800
16801
16802
16803 .
16804 .
16805 .
16806 . ============================================================================
16807 .chapter Generic options for transports
16808 .rset CHAPtransportgeneric "~~chapter"
16809 .set runningfoot "generic transport options"
16810
16811 .index generic options||transport
16812 .index options||generic, for transports
16813 .index transport||generic options for
16814 The following generic options apply to all transports:
16815
16816 .startconf transports
16817 .conf body@_only boolean false
16818 .index transport||body only
16819 .index message||transporting body only
16820 .index body of message||transporting
16821 If this option is set, the message's headers are not transported. It is
16822 mutually exclusive with \headers@_only\. If it is used with the \%appendfile%\ or
16823 \%pipe%\ transports, the settings of \message@_prefix\ and \message@_suffix\
16824 should be checked, because this option does not automatically suppress them.
16825
16826 .conf current@_directory string$**$ unset
16827 .index transport||current directory for
16828 This specifies the current directory that is to be set while running the
16829 transport, overriding any value that may have been set by the router.
16830 If the expansion fails for any reason, including forced failure, an error is
16831 logged, and delivery is deferred.
16832
16833 .conf disable@_logging boolean false
16834 If this option is set true, nothing is logged for any
16835 deliveries by the transport or for any
16836 transport errors. You should not set this option unless you really, really know
16837 what you are doing.
16838
16839 .conf debug@_print string$**$ unset
16840 .index testing||variables in drivers
16841 If this option is set and debugging is enabled (see the \-d-\ command line
16842 option), the string is expanded and included in the debugging output when the
16843 transport is run.
16844 If expansion of the string fails, the error message is written to the debugging
16845 output, and Exim carries on processing.
16846 This facility is provided to help with checking out the values of variables and
16847 so on when debugging driver configurations. For example, if a \headers@_add\
16848 option is not working properly, \debug@_print\ could be used to output the
16849 variables it references. A newline is added to the text if it does not end with
16850 one.
16851
16852 .conf delivery@_date@_add boolean false
16853 .index ::Delivery-date:: header line
16854 If this option is true, a ::Delivery-date:: header is added to the message. This
16855 gives the actual time the delivery was made. As this is not a standard header,
16856 Exim has a configuration option (\delivery@_date@_remove\) which requests its
16857 removal from incoming messages, so that delivered messages can safely be resent
16858 to other recipients.
16859
16860 .conf driver string unset
16861 This specifies which of the available transport drivers is to be used.
16862 There is no default, and this option must be set for every transport.
16863
16864 .conf envelope@_to@_add boolean false
16865 .index ::Envelope-to:: header line
16866 If this option is true, an ::Envelope-to:: header is added to the message. This
16867 gives the original address(es) in the incoming envelope that caused this
16868 delivery to happen. More than one address may be present if the transport is
16869 configured to handle several addresses at once, or if more than one original
16870 address was redirected to the same final address. As this is not a standard
16871 header, Exim has a configuration option (\envelope@_to@_remove\) which requests
16872 its removal from incoming messages, so that delivered messages can safely be
16873 resent to other recipients.
16874
16875 .conf group string$**$ "Exim group"
16876 .index transport||group, specifying
16877 This option specifies a gid for running the transport process, overriding any
16878 value that the router supplies, and also overriding any value associated with
16879 \user\ (see below).
16880
16881 .conf headers@_add string$**$ unset
16882 .index header lines||adding in transport
16883 .index transport||header lines, adding
16884 .em
16885 This option specifies a string of text that is expanded and added to the header
16886 portion of a message as it is transported, as described in section
16887 ~~SECTheadersaddrem. Additional header lines can also be specified by routers.
16888 If the result of the expansion is an empty string, or if the expansion is
16889 forced to fail, no action is taken. Other expansion failures are treated as
16890 errors and cause the delivery to be deferred.
16891 .nem
16892
16893 .conf headers@_only boolean false
16894 .index transport||header lines only
16895 .index message||transporting headers only
16896 .index header lines||transporting
16897 If this option is set, the message's body is not transported. It is mutually
16898 exclusive with \body@_only\. If it is used with the \%appendfile%\ or \%pipe%\
16899 transports, the settings of \message@_prefix\ and \message__suffix\ should be
16900 checked, since this option does not automatically suppress them.
16901
16902 .conf headers@_remove string$**$ unset
16903 .index header lines||removing
16904 .index transport||header lines, removing
16905 .em
16906 This option specifies a string that is expanded into a list of header names;
16907 these headers are omitted from the message as it is transported, as described 
16908 in section ~~SECTheadersaddrem. Header removal can also be specified by
16909 routers. If the result of the expansion is an empty string, or if the expansion
16910 is forced to fail, no action is taken. Other expansion failures are treated as
16911 errors and cause the delivery to be deferred.
16912 .nem
16913
16914 .conf headers@_rewrite string unset
16915 .index transport||header lines, rewriting
16916 .index rewriting||at transport time
16917 This option allows addresses in header lines to be rewritten at transport time,
16918 that is, as the message is being copied to its destination. The contents of the
16919 option are a colon-separated list of rewriting rules. Each rule is in exactly
16920 the same form as one of the general rewriting rules that are applied when a
16921 message is received. These are described in chapter ~~CHAPrewrite. For example,
16922 .display asis
16923 headers_rewrite = a@b c@d f : \
16924                   x@y w@z
16925 .endd
16926 changes \a@@b\ into \c@@d\ in ::From:: header lines, and \x@@y\ into \w@@z\ in
16927 all address-bearing header lines. The rules are applied to the header lines
16928 just before they are written out at transport time, so they affect only those
16929 copies of the message that pass through the transport. However, only the
16930 message's original header lines, and any that were added by a system filter,
16931 are rewritten. If a router or transport adds header lines, they are
16932 not affected by this option. These rewriting rules are $it{not} applied to the
16933 envelope. You can change the return path using \return@_path\, but you cannot
16934 change envelope recipients at this time.
16935
16936 .conf home@_directory string$**$ unset
16937 .index transport||home directory for
16938 This option specifies a home directory setting for the transport, overriding
16939 any value that may be set by the router. The home directory is placed in
16940 \$home$\ while expanding the transport's private options. It is also used as
16941 the current directory if no current directory is set by the
16942 \current__directory\ option on the transport or the
16943 \transport__current__directory\ option on the router.
16944 If the expansion fails for any reason, including forced failure, an error is
16945 logged, and delivery is deferred.
16946
16947
16948 .index additional groups
16949 .index groups, additional
16950 .index transport||group, additional
16951 .conf initgroups boolean false
16952 If this option is true and the uid for the delivery process is provided by the
16953 transport, the \*initgroups()*\ function is called when running the transport
16954 to ensure that any additional groups associated with the uid are set up.
16955
16956 .conf message@_size@_limit string$**$ 0
16957 .index limit||message size per transport
16958 .index size||of message, limit
16959 .index transport||message size, limiting
16960 This option controls the size of messages passed through the transport. It is
16961 expanded before use; the result of the expansion must be a sequence of digits,
16962 optionally followed by K or M.
16963 If the expansion fails for any reason, including forced failure, or if the
16964 result is not of the required form, delivery is deferred.
16965 If the value is greater than zero and the size of a message exceeds this
16966 limit, the address is failed. If there is any chance that the resulting bounce
16967 message could be routed to the same transport, you should ensure that
16968 \return@_size@_limit\ is less than the transport's \message@_size@_limit\, as
16969 otherwise the bounce message will fail to get delivered.
16970
16971
16972 .conf rcpt@_include@_affixes boolean false
16973 .index prefix||for local part, including in envelope
16974 .index suffix||for local part, including in envelope
16975 .index local part||prefix
16976 .index local part||suffix
16977 When this option is false (the default), and an address that has had any
16978 affixes (prefixes or suffixes) removed from the local part is delivered by any
16979 form of SMTP or LMTP, the affixes are not included. For example, if a router
16980 that contains
16981 .display asis
16982 local_part_prefix = *-
16983 .endd
16984 routes the address \*abc-xyz@@some.domain*\ to an SMTP transport, the envelope
16985 is delivered with
16986 .display asis
16987 RCPT TO:<xyz@some.domain>
16988 .endd
16989 If \rcpt@_include@_affixes\ is set true, the whole local part is included in
16990 the \\RCPT\\ command. This option applies to BSMTP deliveries by the
16991 \%appendfile%\ and \%pipe%\ transports as well as to the \%lmtp%\ and \%smtp%\
16992 transports.
16993
16994 .conf retry@_use@_local@_part boolean "see below"
16995 .index hints database||retry keys
16996 When a delivery suffers a temporary failure, a retry record is created
16997 in Exim's hints database. For remote deliveries, the key for the retry record
16998 is based on the name and/or IP address of the failing remote host. For local
16999 deliveries, the key is normally the entire address, including both the local
17000 part and the domain. This is suitable for most common cases of local delivery
17001 temporary failure -- for example, exceeding a mailbox quota should delay only
17002 deliveries to that mailbox, not to the whole domain.
17003
17004 However, in some special cases you may want to treat a temporary local delivery
17005 as a failure associated with the domain, and not with a particular local part.
17006 (For example, if you are storing all mail for some domain in files.) You can do
17007 this by setting \retry@_use@_local@_part\ false.
17008
17009 For all the local transports, its default value is true. For remote transports,
17010 the default value is false for tidiness, but changing the value has no effect
17011 on a remote transport in the current implementation.
17012
17013 .conf return@_path string$**$ unset
17014 .index envelope sender
17015 .index transport||return path, changing
17016 .index return path||changing in transport
17017 If this option is set, the string is expanded at transport time and replaces
17018 the existing return path (envelope sender) value in the copy of the message
17019 that is being delivered. An empty return path is permitted. This feature is
17020 designed for remote deliveries, where the value of this option is used in the
17021 SMTP \\MAIL\\ command. If you set \return@_path\ for a local transport, the
17022 only effect is to change the address that is placed in the ::Return-path::
17023 header line, if one is added to the message (see the next option).
17024
17025 The expansion can refer to the existing value via \$return@_path$\. This is
17026 either the message's envelope sender, or an address set by the
17027 \errors@_to\ option on a router. If the expansion is forced to fail, no
17028 replacement occurs; if it fails for another reason, delivery is deferred. This
17029 option can be used to support VERP (Variable Envelope Return Paths) -- see
17030 chapter ~~CHAPSMTP.
17031
17032 \**Note**\: If a delivery error is detected locally,
17033 including the case when a remote server rejects a message at SMTP time,
17034 the bounce message is not sent to the value of this option, but to the
17035 previously set errors address (which defaults to the incoming sender address).
17036
17037
17038 .conf return@_path@_add boolean false
17039 .index ::Return-path:: header line
17040 If this option is true, a ::Return-path:: header is added to the message.
17041 Although the return path is normally available in the prefix line of BSD
17042 mailboxes, this is commonly not displayed by MUAs, and so the user does not
17043 have easy access to it.
17044
17045 RFC 2821 states that the ::Return-path:: header is added to a message `when the
17046 delivery SMTP server makes the final delivery'. This implies that this header
17047 should not be present in incoming messages. Exim has a configuration option,
17048 \return@_path@_remove\, which requests removal of this header from incoming
17049 messages, so that delivered messages can safely be resent to other recipients.
17050
17051 .conf shadow@_condition string$**$ unset
17052 See \shadow@_transport\ below.
17053
17054 .conf shadow@_transport string unset
17055 .index shadow transport
17056 .index transport||shadow
17057 A local transport may set the \shadow@_transport\ option to the name of another
17058 local transport. Shadow remote transports are not supported.
17059
17060 Whenever a delivery to the main transport succeeds, and either
17061 \shadow@_condition\ is unset, or its expansion does not result in the empty
17062 string or one of the strings `0' or `no' or `false', the message is also passed
17063 to the shadow transport, with the same delivery address or addresses.
17064 If expansion fails, no action is taken except that non-forced expansion
17065 failures cause a log line to be written.
17066
17067 The result of the shadow transport is discarded and does not affect the
17068 subsequent processing of the message. Only a single level of shadowing is
17069 provided; the \shadow@_transport\ option is ignored on any transport when it is
17070 running as a shadow. Options concerned with output from pipes are also ignored.
17071
17072 The log line for the successful delivery has an item added on the end, of the
17073 form
17074 .display
17075 ST=<<shadow transport name>>
17076 .endd
17077 If the shadow transport did not succeed, the error message is put in
17078 parentheses afterwards.
17079
17080 Shadow transports can be used for a number of different purposes, including
17081 keeping more detailed log information than Exim normally provides, and
17082 implementing automatic acknowledgement policies based on message headers that
17083 some sites insist on.
17084
17085 .conf transport@_filter string$**$ unset
17086 .index transport||filter
17087 .index filter||transport filter
17088 This option sets up a filtering (in the Unix shell sense) process for messages
17089 at transport time. It should not be confused with mail filtering as set up by
17090 individual users or via a system filter.
17091
17092 When the message is about to be written out, the command specified by
17093 \transport@_filter\ is started up in a separate process, and the entire
17094 message, including the header lines, is passed to it on its standard input
17095 (this in fact is done from a third process, to avoid deadlock).
17096 The command must be specified as an absolute path.
17097
17098 .em
17099 The lines of the message that are written to the transport filter are
17100 terminated by newline (`@\n').
17101 .nem
17102 The message is passed to the filter before any SMTP-specific processing, such
17103 as turning `@\n' into `@\r@\n' and escaping lines beginning with a dot, and
17104 also before any processing implied by the settings of \check@_string\ and
17105 \escape@_string\ in the \%appendfile%\ or \%pipe%\ transports.
17106
17107 .em
17108 The standard error for the filter process is set to the same destination as its 
17109 standard output; this is read and written to the message's ultimate
17110 destination.
17111 .nem
17112 The filter can perform any transformations it likes, but of course should take
17113 care not to break RFC 2822 syntax. A demonstration Perl script is provided in
17114 \(util/transport-filter.pl)\; this makes a few arbitrary modifications just to
17115 show the possibilities. Exim does not check the result, except to test for a
17116 final newline when SMTP is in use. All messages transmitted over SMTP must end
17117 with a newline, so Exim supplies one if it is missing.
17118
17119 .index SMTP||\\SIZE\\
17120 A problem might arise if the filter increases the size of a message that is
17121 being sent down an SMTP connection. If the receiving SMTP server has indicated
17122 support for the \\SIZE\\ parameter, Exim will have sent the size of the message
17123 at the start of the SMTP session. If what is actually sent is substantially
17124 more, the server might reject the message. This can be worked round by setting
17125 the \size@_addition\ option on the \%smtp%\ transport, either to allow for
17126 additions to the message, or to disable the use of \\SIZE\\ altogether.
17127
17128 The value of the \transport@_filter\ option is the command string for starting
17129 the filter, which is run directly from Exim, not under a shell. The string is
17130 parsed by Exim in the same way as a command string for the \%pipe%\ transport:
17131 Exim breaks it up into arguments and then expands each argument separately. The
17132 special argument \$pipe@_addresses$\ is replaced by a number of arguments, one
17133 for each address that applies to this delivery. (This isn't an ideal name for
17134 this feature here, but as it was already implemented for the \%pipe%\
17135 transport, it seemed sensible not to change it.)
17136
17137 .index \$host$\
17138 .index \$host@_address$\
17139 The expansion variables \$host$\ and \$host@_address$\ are available when the
17140 transport is a remote one. They contain the name and IP address of the host to
17141 which the message is being sent. For example:
17142 .display asis
17143 transport_filter = /some/directory/transport-filter.pl \
17144   $host $host_address $sender_address $pipe_addresses
17145 .endd
17146 The filter process is run under the same uid and gid as the normal delivery.
17147 For remote deliveries this is the Exim uid/gid by default.
17148 .em
17149 The command should normally yield a zero return code. A non-zero code is taken
17150 to mean that the transport filter failed in some way. Delivery of the message
17151 is deferred. It is not possible to cause a message to be bounced from a 
17152 transport filter.
17153 .nem
17154
17155 If a transport filter is set on an autoreply transport, the original message is
17156 passed through the filter as it is being copied into the newly generated
17157 message, which happens if the \return@_message\ option is set.
17158
17159 .conf transport@_filter@_timeout time 5m
17160 .index transport||filter, timeout
17161 When Exim is reading the output of a transport filter, it a applies a timeout
17162 that can be set by this option. Exceeding the timeout is treated as a
17163 temporary delivery failure.
17164
17165
17166 .conf user string$**$ "Exim user"
17167 .index uid (user id)||local delivery
17168 .index transport||user, specifying
17169 This option specifies the user under whose uid the delivery process is to be
17170 run, overriding any uid that may have been set by the router. If the user is
17171 given as a name, the uid is looked up from the password data, and the
17172 associated group is taken as the value of the gid to be used if the \group\
17173 option is not set.
17174
17175 For deliveries that use local transports, a user and group are normally
17176 specified explicitly or implicitly (for example, as a result of
17177 \check@_local@_user\) by the router or transport.
17178
17179 .index hints database||access by remote transport
17180 For remote transports, you should leave this option unset unless you really are
17181 sure you know what you are doing. When a remote transport is running, it needs
17182 to be able to access Exim's hints databases, because each host may have its own
17183 retry data.
17184
17185 .endconf
17186
17187
17188
17189
17190
17191 .
17192 .
17193 .
17194 . ============================================================================
17195 .chapter Address batching in local transports
17196 .set runningfoot "address batching"
17197 .rset CHAPbatching ~~chapter
17198 .index transport||local, address batching in
17199 The only remote transport (\%smtp%\) is normally configured to handle more than
17200 one address at a time, so that when several addresses are routed to the same
17201 remote host, just one copy of the message is sent. Local transports, however,
17202 normally handle one address at a time. That is, a separate instance of the
17203 transport is run for each address that is routed to the transport. A separate
17204 copy of the message is delivered each time.
17205
17206 .index batched local delivery
17207 .index \batch@_max\
17208 .index \batch@_id\
17209 In special cases, it may be desirable to handle several addresses at once in a
17210 local transport, for example:
17211 .numberpars $.
17212 In an \%appendfile%\ transport, when storing messages in files for later
17213 delivery by some other means, a single copy of the message with multiple
17214 recipients saves space.
17215 .nextp
17216 In an \%lmtp%\ transport, when delivering over `local SMTP' to some process,
17217 a single copy saves time, and is the normal way LMTP is expected to work.
17218 .nextp
17219 In a \%pipe%\ transport, when passing the message
17220 to a scanner program or
17221 to some other delivery mechanism such as UUCP, multiple recipients may be
17222 acceptable.
17223 .endp
17224 The three local transports (\%appendfile%\, \%lmtp%\, and \%pipe%\) all have
17225 the same options for controlling multiple (`batched') deliveries, namely
17226 \batch@_max\ and \batch@_id\. To save repeating the information for each
17227 transport, these options are described here.
17228
17229 The \batch@_max\ option specifies the maximum number of addresses that can be
17230 delivered together in a single run of the transport. Its default value is one.
17231 When more than one address is routed to a transport that has a \batch@_max\
17232 value greater than one, the addresses are delivered in a batch (that is, in a
17233 single run of the transport), subject to certain conditions:
17234 .numberpars $.
17235 If any of the transport's options contain a reference to \$local@_part$\, no
17236 batching is possible.
17237 .nextp
17238 If any of the transport's options contain a reference to \$domain$\, only
17239 addresses with the same domain are batched.
17240 .nextp
17241 .index customizing||batching condition
17242 If \batch@_id\ is set, it is expanded for each address, and only those
17243 addresses with the same expanded value are batched. This allows you to specify
17244 customized batching conditions.
17245 Failure of the expansion for any reason, including forced failure, disables
17246 batching, but it does not stop the delivery from taking place.
17247 .nextp
17248 Batched addresses must also have the same errors address (where to send
17249 delivery errors), the same header additions and removals, the same user and
17250 group for the transport, and if a host list is present, the first host must
17251 be the same.
17252 .endp
17253 .index ::Envelope-to:: header line
17254 If the generic \envelope@_to@_add\ option is set for the transport, the
17255 ::Envelope-to:: header that is added to the message contains all the addresses
17256 that are batched together.
17257
17258 The \%appendfile%\ and \%pipe%\ transports have an option called \use@_bsmtp\,
17259 which causes them to deliver the message in `batched SMTP' format, with the
17260 envelope represented as SMTP commands. The \check@_string\ and \escape@_string\
17261 options are forced to the values
17262 .display asis
17263 check_string = "."
17264 escape_string = ".."
17265 .endd
17266 when batched SMTP is in use. A full description of the batch SMTP mechanism is
17267 given in section ~~SECTbatchSMTP. The \%lmtp%\ transport does not have a
17268 \use@_bsmtp\ option, because it always delivers using the SMTP protocol.
17269
17270 .index \%pipe%\ transport||with multiple addresses
17271 If you are not using BSMTP, but are using a \%pipe%\ transport, you can include
17272 \$pipe@_addresses$\ as part of the command. This is not a true variable; it is
17273 a bit of magic that causes each of the recipient addresses to be inserted into
17274 the command as a separate argument. This provides a way of accessing all the
17275 addresses that are being delivered in the batch.
17276
17277 If you are using a batching \%appendfile%\ transport without \use@_bsmtp\, the
17278 only way to preserve the recipient addresses is to set the \envelope@_to@_add\
17279 option. This causes an ::Envelope-to:: header line to be added to the message,
17280 containing all the recipients.
17281
17282
17283
17284 .
17285 .
17286 .
17287 . ============================================================================
17288 .chapter The appendfile transport
17289 .set runningfoot "appendfile transport"
17290 .rset CHAPappendfile ~~chapter
17291 .index \%appendfile%\ transport
17292 .index transports||\%appendfile%\
17293 .index directory creation
17294 .index creating directories
17295 The \%appendfile%\ transport delivers a message by appending it to an existing
17296 file, or by creating an entirely new file in a specified directory. Single
17297 files to which messages are appended can be in the traditional Unix mailbox
17298 format, or optionally in the MBX format supported by the Pine MUA and
17299 University of Washington IMAP daemon, $it{inter alia}. When each message is
17300 being delivered as a separate file, `maildir' format can optionally be used to
17301 give added protection against failures that happen part-way through the
17302 delivery. A third form of separate-file delivery known as `mailstore' is also
17303 supported. For all file formats, Exim attempts to create as many levels of
17304 directory as necessary, provided that \create@_directory\ is set.
17305
17306 The code for the optional formats is not included in the Exim binary by
17307 default. It is necessary to set \\SUPPORT@_MBX\\, \\SUPPORT@_MAILDIR\\ and/or
17308 \\SUPPORT@_MAILSTORE\\ in \(Local/Makefile)\ to have the appropriate code
17309 included.
17310
17311 .index quota||system
17312 Exim recognises system quota errors, and generates an appropriate message. Exim
17313 also supports its own quota control within the transport, for use when the
17314 system facility is unavailable or cannot be used for some reason.
17315
17316 If there is an error while appending to a file (for example, quota exceeded or
17317 partition filled), Exim attempts to reset the file's length and last
17318 modification time back to what they were before. If there is an error while
17319 creating an entirely new file, the new file is removed.
17320
17321 Before appending to a file, a number of security checks are made, and the
17322 file is locked. A detailed description is given below, after the list of
17323 private options.
17324
17325 \%appendfile%\ is most commonly used for local deliveries to users' mailboxes.
17326 However, it can also be used as a pseudo-remote transport for putting messages
17327 into files for remote delivery by some means other than Exim. `Batch SMTP'
17328 format is often used in this case (see the \use@_bsmtp\ option).
17329
17330
17331 .section The file and directory options
17332 .rset SECTfildiropt "~~chapter.~~section"
17333 The \file\ option specifies a single file, to which the message is appended;
17334 the \directory\ option specifies a directory, in which a new file containing
17335 the message is created. Only one of these two options can be set, and for
17336 normal deliveries to mailboxes, one of them \*must*\ be set.
17337
17338 However, \%appendfile%\ is also used for delivering messages to files or
17339 directories whose names (or parts of names) are obtained from alias,
17340 forwarding, or filtering operations (for example, a \save\ command in a user's
17341 Exim filter). When such a transport is running, \$local@_part$\ contains the
17342 local part that was aliased or forwarded, and \$address@_file$\ contains the
17343 name (or partial name) of the file or directory generated by the redirection
17344 operation. There are two cases:
17345 .numberpars $.
17346 If neither \file\ nor \directory\ is set, the redirection operation
17347 must specify an absolute path (one that begins with \"/"\). This is the most
17348 common case when users with local accounts use filtering to sort mail into
17349 different folders. See for example, the \%address@_file%\ transport in the
17350 default configuration. If the path ends with a slash, it is assumed to be the
17351 name of a directory. A delivery to a directory can also be forced by setting
17352 \maildir@_format\ or \mailstore@_format\.
17353 .nextp
17354 If \file\ or \directory\ is set for a delivery from a redirection, it is used
17355 to determine the file or directory name for the delivery. Normally, the
17356 contents of \$address@_file$\ are used in some way in the string expansion.
17357 .endp
17358
17359 .index Sieve filter||configuring \%appendfile%\
17360 .index Sieve filter||relative mailbox path handling
17361 As an example of the second case, consider an environment where users do not
17362 have home directories. They may be permitted to use Exim filter commands of the
17363 form:
17364 .display asis
17365 save folder23
17366 .endd
17367 or Sieve filter commands of the form:
17368 .display asis
17369 require "fileinto";
17370 fileinto "folder23";
17371 .endd
17372 In this situation, the expansion of \file\ or \directory\ in the transport must
17373 transform the relative path into an appropriate absolute file name. In the case
17374 of Sieve filters, the name \*inbox*\ must be handled. It is the name that is
17375 used as a result of a `keep' action in the filter. This example shows one way
17376 of handling this requirement:
17377 .display asis
17378 file = ${if eq{$address_file}{inbox} \
17379             {/var/mail/$local_part} \
17380             {${if eq{${substr_0_1:$address_file}}{/} \
17381                   {$address_file} \
17382                   {$home/mail/$address_file} \
17383             }} \
17384        }
17385 .endd
17386 With this setting of \file\, \*inbox*\ refers to the standard mailbox location,
17387 absolute paths are used without change, and other folders are in the \(mail)\
17388 directory within the home directory.
17389
17390 \**Note 1**\: While processing an Exim filter, a relative path such as
17391 \(folder23)\ is turned into an absolute path if a home directory is known to
17392 the router. In particular, this is the case if \check@_local@_user\ is set. If
17393 you want to prevent this happening at routing time, you can set
17394 \router@_home@_directory\ empty. This forces the router to pass the relative
17395 path to the transport.
17396
17397 \**Note 2**\: An absolute path in \$address@_file$\ is not treated specially;
17398 the \file\ or \directory\ option is still used if it is set.
17399
17400
17401
17402 .section Private options for appendfile
17403 .index options||\%appendfile%\ transport
17404
17405 .startconf appendfile
17406
17407 .conf allow@_fifo boolean false
17408 .index fifo (named pipe)
17409 .index named pipe (fifo)
17410 .index pipe||named (fifo)
17411 Setting this option permits delivery to named pipes (FIFOs) as well as to
17412 regular files. If no process is reading the named pipe at delivery time, the
17413 delivery is deferred.
17414
17415 .conf allow@_symlink boolean false
17416 .index symbolic link||to mailbox
17417 .index mailbox||symbolic link
17418 By default, \%appendfile%\ will not deliver if the path name for the file is
17419 that of a symbolic link. Setting this option relaxes that constraint, but there
17420 are security issues involved in the use of symbolic links. Be sure you know
17421 what you are doing if you set this. Details of exactly what this option affects
17422 are included in the discussion which follows this list of options.
17423
17424 .conf batch@_id string$**$ unset
17425 See the description of local delivery batching in chapter ~~CHAPbatching.
17426 However, batching is automatically disabled for \%appendfile%\ deliveries that
17427 happen as a result of forwarding or aliasing or other redirection directly to a
17428 file.
17429
17430 .conf batch@_max integer 1
17431 See the description of local delivery batching in chapter ~~CHAPbatching.
17432
17433 .conf check@_group boolean false
17434 When this option is set, the group owner of the file defined by the \file\
17435 option is checked to see that it is the same as the group under which the
17436 delivery process is running. The default setting is false because the default
17437 file mode is 0600, which means that the group is irrelevant.
17438
17439 .conf check@_owner boolean true
17440 When this option is set, the owner of the file defined by the \file\ option is
17441 checked to ensure that it is the same as the user under which the delivery
17442 process is running.
17443
17444 .conf check@_string string "see below"
17445 .index `From' line
17446 As \%appendfile%\ writes the message, the start of each line is tested for
17447 matching \check@_string\, and if it does, the initial matching characters are
17448 replaced by the contents of \escape@_string\. The value of \check@_string\ is a
17449 literal string, not a regular expression, and the case of any letters it
17450 contains is significant.
17451
17452 If \use@_bsmtp\ is set the values of \check@_string\ and \escape@_string\ are
17453 forced to `.' and `..' respectively, and any settings in the configuration are
17454 ignored. Otherwise, they default to `From ' and `>From ' when the \file\ option
17455 is set, and unset when
17456 any of the \directory\, \maildir\, or \mailstore\ options are set.
17457
17458 The default settings, along with \message@_prefix\ and \message@_suffix\, are
17459 suitable for traditional `BSD' mailboxes, where a line beginning with `From '
17460 indicates the start of a new message. All four options need changing if another
17461 format is used. For example, to deliver to mailboxes in MMDF format:
17462 .index MMDF format mailbox
17463 .index mailbox||MMDF format
17464 .display asis
17465 check_string = "\1\1\1\1\n"
17466 escape_string = "\1\1\1\1 \n"
17467 message_prefix = "\1\1\1\1\n"
17468 message_suffix = "\1\1\1\1\n"
17469 .endd
17470
17471 .index directory creation
17472 .conf create@_directory boolean true
17473 When this option is true, Exim attempts to create any missing superior
17474 directories for the file that it is about to write. A created directory's mode
17475 is given by the \directory@_mode\ option.
17476 .em
17477 The group ownership of a newly created directory is highly dependent on the 
17478 operating system (and possibly the file system) that is being used. For
17479 example, in Solaris, if the parent directory has the setgid bit set, its group
17480 is propagated to the child; if not, the currently set group is used. However,
17481 in FreeBSD, the parent's group is always used.
17482 .nem
17483
17484 .conf create@_file string "anywhere"
17485 This option constrains the location of files and directories that are created
17486 by this transport. It applies to files defined by the \file\ option and
17487 directories defined by the \directory\ option. In the case of maildir delivery,
17488 it applies to the top level directory, not the maildir directories beneath.
17489
17490 The option must be set to one of the words `anywhere', `inhome', or
17491 `belowhome'. In the second and third cases, a home directory must have been set
17492 for the transport. This option is not useful when an explicit file name is
17493 given for normal mailbox deliveries. It is intended for the case when file
17494 names are generated from users' \(.forward)\ files. These are usually handled
17495 by an \%appendfile%\ transport called \address@_file\. See also
17496 \file@_must@_exist\.
17497
17498 .conf directory string$**$ unset
17499 This option is mutually exclusive with the \file\ option, but one of \file\ or
17500 \directory\ must be set, unless the delivery is the direct result of a
17501 redirection (see section ~~SECTfildiropt).
17502
17503 When \directory\ is set, the string is expanded, and the message is delivered
17504 into a new file or files in or below the given directory, instead of being
17505 appended to a single mailbox file. A number of different formats are provided
17506 (see \maildir@_format\ and \mailstore@_format\), and see section ~~SECTopdir
17507 for further details of this form of delivery.
17508
17509 .conf directory@_file string$**$ "$tt{q@$@{base62:@$tod@_epoch@}-@$inode}"
17510 .index base62
17511 When \directory\ is set, but neither \maildir@_format\ nor \mailstore@_format\
17512 is set, \%appendfile%\ delivers each message into a file whose name is obtained
17513 by expanding this string. The default value generates a unique name from the
17514 current time, in base 62 form, and the inode of the file. The variable
17515 \$inode$\ is available only when expanding this option.
17516
17517 .conf directory@_mode "octal integer" 0700
17518 If \%appendfile%\ creates any directories as a result of the \create@_directory\
17519 option, their mode is specified by this option.
17520
17521 .conf escape@_string string "see description"
17522 See \check@_string\ above.
17523
17524 .conf file string$**$ unset
17525 This option is mutually exclusive with the \directory\ option, but one of
17526 \file\ or \directory\ must be set, unless the delivery is the direct result of
17527 a redirection (see section ~~SECTfildiropt). The \file\ option specifies a
17528 single file, to which the message is appended. One or more of
17529 \use@_fcntl@_lock\, \use@_flock@_lock\, or \use@_lockfile\ must be set with
17530 \file\.
17531 .index NFS||lock file
17532 .index locking files
17533 .index lock files
17534 If you are using more than one host to deliver over NFS into the same
17535 mailboxes, you should always use lock files.
17536
17537 The string value is expanded for each delivery, and must yield an absolute
17538 path. The most common settings of this option are variations on one of these
17539 examples:
17540 .display asis
17541 file = /var/spool/mail/$local_part
17542 file = /home/$local_part/inbox
17543 file = $home/inbox
17544 .endd
17545 .index `sticky' bit
17546 In the first example, all deliveries are done into the same directory. If Exim
17547 is configured to use lock files (see \use@_lockfile\ below) it must be able to
17548 create a file in the directory, so the `sticky' bit must be turned on for
17549 deliveries to be possible, or alternatively the \group\ option can be used to
17550 run the delivery under a group id which has write access to the directory.
17551
17552
17553 .conf file@_format string unset
17554 .index file||mailbox, checking existing format
17555 This option requests the transport to check the format of an existing file
17556 before adding to it. The check consists of matching a specific string at the
17557 start of the file. The value of the option consists of an even number of
17558 colon-separated strings. The first of each pair is the test string, and the
17559 second is the name of a transport. If the transport associated with a matched
17560 string is not the current transport, control is passed over to the other
17561 transport. For example, suppose the standard \%local@_delivery%\ transport has
17562 this added to it:
17563 .display asis
17564 file_format = "From       : local_delivery :\
17565                \1\1\1\1\n : local_mmdf_delivery"
17566 .endd
17567 Mailboxes that begin with `From' are still handled by this transport, but if a
17568 mailbox begins with four binary ones followed by a newline, control is passed
17569 to a transport called \local__mmdf__delivery\, which presumably is configured
17570 to do the delivery in MMDF format. If a mailbox does not exist or is empty, it
17571 is assumed to match the current transport. If the start of a mailbox doesn't
17572 match any string, or if the transport named for a given string is not defined,
17573 delivery is deferred.
17574
17575 .conf file@_must@_exist boolean false
17576 If this option is true, the file specified by the \file\ option must exist, and
17577 an error occurs if it does not. Otherwise, it is created if it does not exist.
17578
17579 .conf lock@_fcntl@_timeout time 0s
17580 .index timeout||mailbox locking
17581 .index mailbox locking||blocking and non-blocking
17582 .index locking files
17583 By default, the \%appendfile%\ transport uses non-blocking calls to \*fcntl()*\
17584 when locking an open mailbox file. If the call fails, the delivery process
17585 sleeps for \lock@_interval\ and tries again, up to \lock@_retries\ times.
17586 Non-blocking calls are used so that the file is not kept open during the wait
17587 for the lock; the reason for this is to make it as safe as possible for
17588 deliveries over NFS in the case when processes might be accessing an NFS
17589 mailbox without using a lock file. This should not be done, but
17590 misunderstandings and hence misconfigurations are not unknown.
17591
17592 On a busy system, however, the performance of a non-blocking lock approach is
17593 not as good as using a blocking lock with a timeout. In this case, the waiting
17594 is done inside the system call, and Exim's delivery process acquires the lock
17595 and can proceed as soon as the previous lock holder releases it.
17596
17597 If \lock@_fcntl@_timeout\ is set to a non-zero time, blocking locks, with that
17598 timeout, are used. There may still be some retrying: the maximum number of
17599 retries is
17600 .display asis
17601 (lock_retries * lock_interval) / lock_fcntl_timeout
17602 .endd
17603 rounded up to the next whole number. In other words, the total time during
17604 which \%appendfile%\ is trying to get a lock is roughly the same, unless
17605 \lock@_fcntl@_timeout\ is set very large.
17606
17607 You should consider setting this option if you are getting a lot of delayed
17608 local deliveries because of errors of the form
17609 .display asis
17610 failed to lock mailbox /some/file (fcntl)
17611 .endd
17612
17613 .conf lock@_flock@_timeout time 0s
17614 This timeout applies to file locking when using \*flock()*\ (see \use@_flock\);
17615 the timeout operates in a similar manner to \lock@_fcntl@_timeout\.
17616
17617 .conf lock@_interval time 3s
17618 This specifies the time to wait between attempts to lock the file. See below
17619 for details of locking.
17620
17621 .conf lock@_retries integer 10
17622 This specifies the maximum number of attempts to lock the file. A value of zero
17623 is treated as 1. See below for details of locking.
17624
17625 .conf lockfile@_mode "octal integer" 0600
17626 This specifies the mode of the created lock file, when a lock file is being
17627 used (see \use@_lockfile\).
17628
17629 .conf lockfile@_timeout time 30m
17630 .index timeout||mailbox locking
17631 When a lock file is being used (see \use@_lockfile\), if a lock file already
17632 exists and is older than this value, it is assumed to have been left behind by
17633 accident, and Exim attempts to remove it.
17634
17635 .em
17636 .conf mailbox@_filecount string$**$ unset
17637 .index mailbox||specifying size of
17638 .index size||of mailbox
17639 If this option is set, it is expanded, and the result is taken as the current 
17640 number of files in the mailbox. It must be a decimal number, optionally 
17641 followed by K or M. This provides a way of obtaining this information from an 
17642 external source that maintains the data.
17643
17644 .conf mailbox@_size string$**$ unset
17645 .index mailbox||specifying size of
17646 .index size||of mailbox
17647 If this option is set, it is expanded, and the result is taken as the current
17648 size the mailbox. It must be a decimal number, optionally followed by K or M.
17649 This provides a way of obtaining this information from an external source that 
17650 maintains the data. This is likely to be helpful for maildir deliveries where 
17651 it is computationally expensive to compute the size of a mailbox.
17652 .nem
17653
17654 .conf maildir@_format boolean false
17655 .index maildir format||specifying
17656 If this option is set with the \directory\ option, the delivery is into a new
17657 file, in the `maildir' format that is used by other mail software. When the
17658 transport is activated directly from a \%redirect%\ router (for example, the
17659 \%address@_file%\ transport in the default configuration), setting
17660 \maildir@_format\ causes the path received from the router to be treated as a
17661 directory, whether or not it ends with \"/"\. This option is available only if
17662 \\SUPPORT@_MAILDIR\\ is present in \(Local/Makefile)\. See section
17663 ~~SECTmaildirdelivery below for further details.
17664
17665 .conf maildir@_quota@_directory@_regex string "See below"
17666 .index maildir format||quota, directories included in
17667 .index quota||maildir, directories included in
17668 This option is relevant only when \maildir@_use@_size@_file\ is set. It defines
17669 a regular expression for specifying directories that should be included in the
17670 quota calculation. The default value is
17671 .display asis
17672 maildir_quota_directory_regex = ^(?:cur|new|\..*)$
17673 .endd
17674 which includes the \(cur)\ and \(new)\ directories, and any maildir++ folders
17675 (directories whose names begin with a dot). If you want to exclude the
17676 \(Trash)\
17677 folder from the count (as some sites do), you need to change this setting to
17678 .display asis
17679 maildir_quota_directory_regex = ^(?:cur|new|\.(?!Trash).*)$
17680 .endd
17681 This uses a negative lookahead in the regular expression to exclude the
17682 directory whose name is \(.Trash)\.
17683
17684 .conf maildir@_retries integer 10
17685 This option specifies the number of times to retry when writing a file in
17686 `maildir' format. See section ~~SECTmaildirdelivery below.
17687
17688 .conf maildir@_tag string$**$ unset
17689 This option applies only to deliveries in maildir format, and is described in
17690 section ~~SECTmaildirdelivery below.
17691
17692 .conf maildir@_use@_size@_file boolean false
17693 .index maildir format||\(maildirsize)\ file
17694 Setting this option true enables support for \(maildirsize)\ files. Exim
17695 creates a \(maildirsize)\ file in a maildir if one does not exist, taking the
17696 quota from the \quota\ option of the transport. If \quota\ is unset, the value
17697 is zero. See section ~~SECTmaildirdelivery below for further details.
17698
17699 .conf mailstore@_format boolean false
17700 .index mailstore format||specifying
17701 If this option is set with the \directory\ option, the delivery is into two new
17702 files in  `mailstore' format. The option is available only if
17703 \\SUPPORT@_MAILSTORE\\ is present in \(Local/Makefile)\. See section
17704 ~~SECTopdir below for further details.
17705
17706 .conf mailstore@_prefix string$**$ unset
17707 This option applies only to deliveries in mailstore format, and is described in
17708 section ~~SECTopdir below.
17709
17710 .conf mailstore@_suffix string$**$ unset
17711 This option applies only to deliveries in mailstore format, and is described in
17712 section ~~SECTopdir below.
17713
17714 .conf mbx@_format boolean false
17715 .index locking files
17716 .index file||locking
17717 .index file||MBX format
17718 .index MBX format, specifying
17719 This option is available only if Exim has been compiled with \\SUPPORT@_MBX\\
17720 set in \(Local/Makefile)\. If \mbx@_format\ is set with the \file\ option,
17721 the message is appended to the mailbox file in MBX format instead of
17722 traditional Unix format. This format is supported by Pine4 and its associated
17723 IMAP and POP daemons, by means of the \*c-client*\ library that they all use.
17724
17725 \**Note**\: The \message@_prefix\ and \message@_suffix\ options are not
17726 automatically changed by the use of \mbx@_format\. They should normally be set
17727 empty when using MBX format, so this option almost always appears in this
17728 combination:
17729 .display asis
17730 mbx_format = true
17731 message_prefix =
17732 message_suffix =
17733 .endd
17734
17735 If none of the locking options are mentioned in the configuration,
17736 \use@_mbx@_lock\ is assumed and the other locking options default to false. It
17737 is possible to specify the other kinds of locking with \mbx@_format\, but
17738 \use@_fcntl@_lock\ and \use@_mbx@_lock\ are mutually exclusive. MBX locking
17739 interworks with \*c-client*\, providing for shared access to the mailbox. It
17740 should not be used if any program that does not use this form of locking is
17741 going to access the mailbox, nor should it be used if the mailbox file is NFS
17742 mounted, because it works only when the mailbox is accessed from a single host.
17743
17744 If you set \use@_fcntl@_lock\ with an MBX-format mailbox, you cannot use
17745 the standard version of \*c-client*\, because as long as it has a mailbox open
17746 (this means for the whole of a Pine or IMAP session), Exim will not be able to
17747 append messages to it.
17748
17749 .conf message@_prefix string$**$ "see below"
17750 .index `From' line
17751 The string specified here is expanded and output at the start of every message.
17752 The default is unset unless \file\ is specified and \use@_bsmtp\ is not set, in
17753 which case it is:
17754 .display asis
17755 message_prefix = "From ${if def:return_path{$return_path}\
17756   {MAILER-DAEMON}} $tod_bsdinbox\n"
17757 .endd
17758
17759 .conf message@_suffix string$**$ "see below"
17760 The string specified here is expanded and output at the end of every message.
17761 The default is unset unless \file\ is specified and \use@_bsmtp\ is not set, in
17762 which case it is a single newline character. The suffix can be suppressed by
17763 setting
17764 .display asis
17765 message_suffix =
17766 .endd
17767
17768 .conf mode "octal integer" 0600
17769 If the output file is created, it is given this mode. If it already exists and
17770 has wider permissions, they are reduced to this mode. If it has narrower
17771 permissions, an error occurs unless \mode__fail__narrower\ is false. However,
17772 if the delivery is the result of a \save\ command in a filter file specifing a
17773 particular mode, the mode of the output file is always forced to take that
17774 value, and this option is ignored.
17775
17776 .conf mode@_fail@_narrower boolean true
17777 This option applies in the case when an existing mailbox file has a narrower
17778 mode than that specified by the \mode\ option. If \mode@_fail@_narrower\ is
17779 true, the delivery is deferred (`mailbox has the wrong mode'); otherwise Exim
17780 continues with the delivery attempt, using the existing mode of the file.
17781
17782 .conf notify@_comsat boolean false
17783 If this option is true, the \*comsat*\ daemon is notified after every successful
17784 delivery to a user mailbox. This is the daemon that notifies logged on users
17785 about incoming mail.
17786
17787 .conf quota string$**$ unset
17788 .index quota||imposed by Exim
17789 This option imposes a limit on the size of the file to which Exim is appending,
17790 or to the total space used in the directory tree when the \directory\ option is
17791 set. In the latter case, computation of the space used is expensive, because
17792 all the files in the directory (and any sub-directories) have to be
17793 individually inspected and their sizes summed.
17794 (See \quota@_size@_regex\ and \maildir@_use@_size@_file\ for ways to avoid this
17795 in environments where users have no shell access to their mailboxes).
17796
17797 As there is no interlock against two simultaneous deliveries into a
17798 multi-file mailbox, it is possible for the quota to be overrun in this case.
17799 For single-file mailboxes, of course, an interlock is a necessity.
17800
17801 A file's size is taken as its \*used*\ value. Because of blocking effects, this
17802 may be a lot less than the actual amount of disk space allocated to the file.
17803 If the sizes of a number of files are being added up, the rounding effect can
17804 become quite noticeable, especially on systems that have large block sizes.
17805 Nevertheless, it seems best to stick to the \*used*\ figure, because this is
17806 the obvious value which users understand most easily.
17807
17808 The value of the option is expanded, and must then be a numerical value
17809 (decimal point allowed), optionally followed by one of the letters K or M. The
17810 expansion happens while Exim is running as root, before it changes uid for the
17811 delivery. This means that files which are inaccessible to the end user can be
17812 used to hold quota values that are looked up in the expansion. When delivery
17813 fails because this quota is exceeded, the handling of the error is as for
17814 system quota failures.
17815
17816 \**Note**\: A value of zero is interpreted as `no quota'.
17817
17818 By default, Exim's quota checking mimics system quotas, and restricts the
17819 mailbox to the specified maximum size, though the value is not accurate to the
17820 last byte, owing to separator lines and additional headers that may get added
17821 during message delivery. When a mailbox is nearly full, large messages may get
17822 refused even though small ones are accepted, because the size of the current
17823 message is added to the quota when the check is made. This behaviour can be
17824 changed by setting \quota@_is@_inclusive\ false. When this is done, the check
17825 for exceeding the quota does not include the current message. Thus, deliveries
17826 continue until the quota has been exceeded; thereafter, no further messages are
17827 delivered. See also \quota@_warn@_threshold\.
17828
17829 .conf quota@_directory string$**$ unset
17830 This option defines the directory to check for quota purposes when delivering
17831 into individual files. The default is the delivery directory, or, if a file
17832 called \(maildirfolder)\ exists in a maildir directory, the parent of the
17833 delivery directory.
17834
17835 .conf quota@_filecount string$**$ 0
17836 This option applies when the \directory\ option is set. It limits the total
17837 number of files in the directory (compare the inode limit in system quotas). It
17838 can only be used if \quota\ is also set. The value is expanded; an expansion
17839 failure causes delivery to be deferred.
17840
17841 .conf quota@_is@_inclusive boolean true
17842 See \quota\ above.
17843
17844 .conf quota@_size@_regex string unset
17845 This option applies when one of the delivery modes that writes a separate file
17846 for each message is being used. When Exim wants to find the size of one of
17847 these files in order to test the quota, it first checks \quota@_size@_regex\.
17848 If this is set to a regular expression that matches the file name, and it
17849 captures one string, that string is interpreted as a representation of the
17850 file's size. The value of \quota@_size@_regex\ is not expanded.
17851
17852 This feature is useful only when users have no shell access to their mailboxes
17853 -- otherwise they could defeat the quota simply by renaming the files. This
17854 facility can be used with maildir deliveries, by setting \maildir@_tag\ to add
17855 the file length to the file name. For example:
17856 .display asis
17857 maildir_tag = ,S=$message_size
17858 quota_size_regex = ,S=(\d+)
17859 .endd
17860 The regular expression should not assume that the length is at the end of the
17861 file name (even though \maildir@_tag\ puts it there) because maildir MUAs
17862 sometimes add other information onto the ends of message file names.
17863
17864 .conf quota@_warn@_message string$**$ "see below"
17865 See below for the use of this option. If it is not set when
17866 \quota@_warn@_threshold\ is set, it defaults to
17867 .display asis
17868 quota_warn_message = "\
17869   To: $local_part@$domain\n\
17870   Subject: Your mailbox\n\n\
17871   This message is automatically created \
17872   by mail delivery software.\n\n\
17873   The size of your mailbox has exceeded \
17874   a warning threshold that is\n\
17875   set by the system administrator.\n"
17876 .endd
17877
17878 .conf quota@_warn@_threshold string$**$ 0
17879 .index quota||warning threshold
17880 .index mailbox||size warning
17881 .index size||of mailbox
17882 This option is expanded in the same way as \quota\ (see above). If the
17883 resulting value is greater than zero, and delivery of the message causes the
17884 size of the file or total space in the directory tree to cross the given
17885 threshold, a warning message is sent. If \quota\ is also set, the threshold may
17886 be specified as a percentage of it by following the value with a percent sign.
17887 For example:
17888 .display asis
17889 quota = 10M
17890 quota_warn_threshold = 75%
17891 .endd
17892 If \quota\ is not set, a setting of \quota@_warn@_threshold\ that ends with a
17893 percent sign is ignored.
17894
17895 The warning message itself is specified by the \quota@_warn@_message\ option,
17896 and it must start with a ::To:: header line containing the recipient(s). A
17897 ::Subject:: line should also normally be supplied. The \quota\ option does not
17898 have to be set in order to use this option; they are independent of one
17899 another except when the threshold is specified as a percentage.
17900
17901 .conf use@_bsmtp boolean false
17902 .index envelope sender
17903 If this option is set true, \%appendfile%\ writes messages in `batch SMTP'
17904 format, with the envelope sender and recipient(s) included as SMTP commands. If
17905 you want to include a leading \\HELO\\ command with such messages, you can do
17906 so by setting the \message@_prefix\ option. See section ~~SECTbatchSMTP for
17907 details of batch SMTP.
17908
17909 .conf use@_crlf boolean false
17910 .index carriage return
17911 .index linefeed
17912 This option causes lines to be terminated with the two-character CRLF sequence
17913 (carriage return, linefeed) instead of just a linefeed character. In the case
17914 of batched SMTP, the byte sequence written to the file is then an exact image
17915 of what would be sent down a real SMTP connection.
17916
17917 The contents of the \message@_prefix\ and \message@_suffix\ options are written
17918 verbatim, so must contain their own carriage return characters if these are
17919 needed. In cases where these options have non-empty defaults, the values end
17920 with a single linefeed, so they
17921 must
17922 be changed to end with \"@\r@\n"\ if \use@_crlf\ is set.
17923
17924 .conf use@_fcntl@_lock boolean "see below"
17925 This option controls the use of the \*fcntl()*\ function to lock a file for
17926 exclusive use when a message is being appended. It is set by default unless
17927 \use@_flock@_lock\ is set. Otherwise, it should be turned off only if you know
17928 that all your MUAs use lock file locking. When both \use@_fcntl@_lock\ and
17929 \use@_flock@_lock\ are unset, \use@_lockfile\ must be set.
17930
17931 .conf use@_flock@_lock boolean false
17932 This option is provided to support the use of \*flock()*\ for file locking, for
17933 the few situations where it is needed. Most modern operating systems support
17934 \*fcntl()*\ and \*lockf()*\ locking, and these two functions interwork with
17935 each other. Exim uses \*fcntl()*\ locking by default.
17936
17937 This option is required only if you are using an operating system where
17938 \*flock()*\ is used by programs that access mailboxes (typically MUAs), and
17939 where \*flock()*\ does not correctly interwork with \*fcntl()*\. You can use
17940 both \*fcntl()*\ and \*flock()*\ locking simultaneously if you want.
17941
17942 .index Solaris||\*flock()*\ support
17943 Not all operating systems provide \*flock()*\. Some versions of Solaris do not
17944 have it (and some, I think, provide a not quite right version built on top of
17945 \*lockf()*\). If the OS does not have \*flock()*\, Exim will be built without
17946 the ability to use it, and any attempt to do so will cause a configuration
17947 error.
17948
17949 \**Warning**\: \*flock()*\ locks do not work on NFS files (unless \*flock()*\
17950 is just being mapped onto \*fcntl()*\ by the OS).
17951
17952 .conf use@_lockfile boolean "see below"
17953 If this option is turned off, Exim does not attempt to create a lock file when
17954 appending to a mailbox file. In this situation, the only locking is by
17955 \*fcntl()*\. You should only turn \use@_lockfile\ off if you are absolutely
17956 sure that every MUA that is ever going to look at your users' mailboxes uses
17957 \*fcntl()*\ rather than a lock file, and even then only when you are not
17958 delivering over NFS from more than one host.
17959
17960 .index NFS||lock file
17961 In order to append to an NFS file safely from more than one host, it is
17962 necessary to take out a lock $it{before} opening the file, and the lock file
17963 achieves this. Otherwise, even with \*fcntl()*\ locking, there is a risk of
17964 file corruption.
17965
17966 The \use@_lockfile\ option is set by default unless \use@_mbx@_lock\ is set. It
17967 is not possible to turn both \use@_lockfile\ and \use@_fcntl@_lock\ off, except
17968 when \mbx@_format\ is set.
17969
17970 .conf use@_mbx@_lock boolean "see below"
17971 This option is available only if Exim has been compiled with \\SUPPORT@_MBX\\
17972 set in \(Local/Makefile)\. Setting the option specifies that special MBX
17973 locking rules be used. It is set by default if \mbx@_format\ is set and none of
17974 the locking options are mentioned in the configuration. The locking rules are
17975 the same as are used by the \*c-client*\ library that underlies Pine and the
17976 IMAP4 and POP daemons that come with it (see the discussion below). The rules
17977 allow for shared access to the mailbox. However, this kind of locking does not
17978 work when the mailbox is NFS mounted.
17979
17980 You can set \use@_mbx@_lock\ with either (or both) of \use@_fcntl@_lock\ and
17981 \use@_flock@_lock\ to control what kind of locking is used in implementing the
17982 MBX locking rules. The default is to use \*fcntl()*\ if \use@_mbx@_lock\ is set
17983 without \use@_fcntl@_lock\ or \use@_flock@_lock\.
17984 .endconf
17985
17986
17987 .section Operational details for appending
17988 .rset SECTopappend "~~chapter.~~section"
17989 .index appending to a file
17990 .index file||appending
17991 Before appending to a file, the following preparations are made:
17992 .numberpars $.
17993 If the name of the file is \(/dev/null)\, no action is taken, and a success
17994 return is given.
17995 .nextp
17996 .index directory creation
17997 If any directories on the file's path are missing, Exim creates them if the
17998 \create@_directory\ option is set. A created directory's mode is given by the
17999 \directory@_mode\ option.
18000 .nextp
18001 If \file@_format\ is set, the format of an existing file is checked. If this
18002 indicates that a different transport should be used, control is passed to that
18003 transport.
18004 .nextp
18005 .index file||locking
18006 .index locking files
18007 .index NFS||lock file
18008 If \use@_lockfile\ is set, a lock file is built in a way that will work
18009 reliably over NFS, as follows:
18010 .numberpars $.
18011 Create a `hitching post' file whose name is that of the lock file with the
18012 current time, primary host name, and process id added, by opening for writing
18013 as a new file. If this fails with an access error, delivery is deferred.
18014 .nextp
18015 Close the hitching post file, and hard link it to the lock file name.
18016 .nextp
18017 If the call to \*link()*\ succeeds, creation of the lock file has succeeded.
18018 Unlink the hitching post name.
18019 .nextp
18020 Otherwise, use \*stat()*\ to get information about the hitching post file, and
18021 then unlink hitching post name. If the number of links is exactly two, creation
18022 of the lock file succeeded but something (for example, an NFS server crash and
18023 restart) caused this fact not to be communicated to the \*link()*\ call.
18024 .nextp
18025 If creation of the lock file failed, wait for \lock@_interval\ and try again,
18026 up to \lock@_retries\ times. However, since any program that writes to a
18027 mailbox should complete its task very quickly, it is reasonable to time out old
18028 lock files that are normally the result of user agent and system crashes. If an
18029 existing lock file is older than \lockfile@_timeout\ Exim attempts to unlink it
18030 before trying again.
18031 .endp
18032 .nextp
18033 A call is made to \*lstat()*\ to discover whether the main file exists, and if
18034 so, what its characteristics are. If \*lstat()*\ fails for any reason other
18035 than non-existence, delivery is deferred.
18036 .nextp
18037 .index symbolic link||to mailbox
18038 .index mailbox||symbolic link
18039 If the file does exist and is a symbolic link, delivery is deferred, unless the
18040 \allow@_symlink\ option is set, in which case the ownership of the link is
18041 checked, and then \*stat()*\ is called to find out about the real file, which
18042 is then subjected to the checks below. The check on the top-level link
18043 ownership prevents one user creating a link for another's mailbox in a sticky
18044 directory, though allowing symbolic links in this case is definitely not a good
18045 idea. If there is a chain of symbolic links, the intermediate ones are not
18046 checked.
18047 .nextp
18048 If the file already exists but is not a regular file, or if the file's owner
18049 and group (if the group is being checked -- see \check@_group\ above) are
18050 different from the user and group under which the delivery is running,
18051 delivery is deferred.
18052 .nextp
18053 If the file's permissions are more generous than specified, they are reduced.
18054 If they are insufficient, delivery is deferred, unless \mode@_fail@_narrower\
18055 is set false, in which case the delivery is tried using the existing
18056 permissions.
18057 .nextp
18058 The file's inode number is saved, and the file is then opened for appending. If
18059 this fails because the file has vanished, \%appendfile%\ behaves as if it hadn't
18060 existed (see below). For any other failures, delivery is deferred.
18061 .nextp
18062 If the file is opened successfully, check that the inode number hasn't
18063 changed, that it is still a regular file, and that the owner and permissions
18064 have not changed. If anything is wrong, defer delivery and freeze the message.
18065 .nextp
18066 If the file did not exist originally, defer delivery if the \file@_must@_exist\
18067 option is set. Otherwise, check that the file is being created in a permitted
18068 directory if the \create@_file\ option is set (deferring on failure), and then
18069 open for writing as a new file, with the \\O@_EXCL\\ and \\O@_CREAT\\ options,
18070 except when dealing with a symbolic link (the \allow@_symlink\ option must be
18071 set). In this case, which can happen if the link points to a non-existent file,
18072 the file is opened for writing using \\O@_CREAT\\ but not \\O@_EXCL\\, because
18073 that prevents link following.
18074 .nextp
18075 .index loop||while file testing
18076 If opening fails because the file exists, obey the tests given above for
18077 existing files. However, to avoid looping in a situation where the file is
18078 being continuously created and destroyed, the exists/not-exists loop is broken
18079 after 10 repetitions, and the message is then frozen.
18080 .nextp
18081 If opening fails with any other error, defer delivery.
18082 .nextp
18083 .index file||locking
18084 .index locking files
18085 Once the file is open, unless both \use@_fcntl@_lock\ and \use@_flock@_lock\
18086 are false, it is locked using \*fcntl()*\ or \*flock()*\ or both. If
18087 \use@_mbx@_lock\ is false, an exclusive lock is requested in each case.
18088 However, if \use@_mbx@_lock\ is true,
18089 Exim takes out a shared lock on the open file,
18090 and an exclusive lock on the file whose name is
18091 .display
18092 /tmp/.<<device-number>>.<<inode-number>>
18093 .endd
18094 using the device and inode numbers of the open mailbox file, in accordance with
18095 the MBX locking rules.
18096
18097 If Exim fails to lock the file, there are two possible courses of action,
18098 depending on the value of the locking timeout. This is obtained from
18099 \lock@_fcntl@_timeout\ or \lock@_flock@_timeout\, as appropriate.
18100
18101 If the timeout value is zero, the file is closed, Exim waits for
18102 \lock@_interval\, and then goes back and re-opens the file as above and tries
18103 to lock it again. This happens up to \lock@_retries\ times, after which the
18104 delivery is deferred.
18105
18106 If the timeout has a value greater than zero, blocking calls to \*fcntl()*\ or
18107 \*flock()*\ are used (with the given timeout), so there has already been some
18108 waiting involved by the time locking fails. Nevertheless, Exim does not give up
18109 immediately. It retries up to
18110 .display
18111 (lock@_retries * lock@_interval) / <<timeout>>
18112 .endd
18113 times (rounded up).
18114 .endp
18115
18116 At the end of delivery, Exim closes the file (which releases the \*fcntl()*\
18117 and/or \*flock()*\ locks) and then deletes the lock file if one was created.
18118
18119 .section Operational details for delivery to a new file
18120 .rset SECTopdir "~~chapter.~~section"
18121 .index delivery||to single file
18122 .index `From' line
18123 When the \directory\ option is set instead of \file\, each message is delivered
18124 into a newly-created file or set of files. When \%appendfile%\ is activated
18125 directly from a \%redirect%\ router, neither \file\ nor \directory\ is normally
18126 set, because the path for delivery is supplied by the router. (See for example,
18127 the \%address@_file%\ transport in the default configuration.) In this case,
18128 delivery is to a new file if either the path name ends in \"/"\, or the
18129 \maildir@_format\ or \mailstore@_format\ option is set.
18130
18131 No locking is required while writing the message to a new file, so the various
18132 locking options of the transport are ignored. The `From' line that by default
18133 separates messages in a single file is not normally needed, nor is the escaping
18134 of message lines that start with `From', and there is no need to ensure a
18135 newline at the end of each message. Consequently, the default values for
18136 \check@_string\, \message@_prefix\, and \message@_suffix\ are all unset when
18137 any of \directory\, \maildir@_format\, or \mailstore@_format\ is set.
18138
18139 If Exim is required to check a \quota\ setting, it adds up the sizes of all the
18140 files in the delivery directory by default. However, you can specify a
18141 different directory by setting \quota@_directory\. Also, for maildir deliveries
18142 (see below) the \(maildirfolder)\ convention is honoured.
18143
18144
18145 .index maildir format
18146 .index mailstore format
18147 There are three different ways in which delivery to individual files can be
18148 done, controlled by the settings of the \maildir@_format\ and
18149 \mailstore@_format\ options. Note that code to support maildir or mailstore
18150 formats is not included in the binary unless \\SUPPORT@_MAILDIR\\ or
18151 \\SUPPORT@_MAILSTORE\\, respectively, is set in \(Local/Makefile)\.
18152
18153 .index directory creation
18154 In all three cases an attempt is made to create the directory and any necessary
18155 sub-directories if they do not exist, provided that the \create@_directory\
18156 option is set (the default). The location of a created directory can be
18157 constrained by setting \create@_file\. A created directory's mode is given by
18158 the \directory@_mode\ option. If creation fails, or if the \create@_directory\
18159 option is not set when creation is required, delivery is deferred.
18160
18161
18162 .section Maildir delivery
18163 .rset SECTmaildirdelivery "~~chapter.~~section"
18164 .index maildir format||description of
18165 If the \maildir@_format\ option is true, Exim delivers each message by writing
18166 it to a file whose name is \(tmp/<<stime>>.H<<mtime>>P<<pid>>.<<host>>)\ in the
18167 given directory. If the delivery is successful, the file is renamed into the
18168 \(new)\ subdirectory.
18169
18170 In the file name, <<stime>> is the current time of day in seconds, and
18171 <<mtime>> is the microsecond fraction of the time. After a maildir delivery,
18172 Exim checks that the time-of-day clock has moved on by at least one microsecond
18173 before terminating the delivery process. This guarantees uniqueness for the
18174 file name. However, as a precaution, Exim calls \*stat()*\ for the file before
18175 opening it. If any response other than \\ENOENT\\ (does not exist) is given,
18176 Exim waits 2 seconds and tries again, up to \maildir@_retries\ times.
18177
18178 .index quota||in maildir delivery
18179 .index maildir++
18180 If Exim is required to check a \quota\ setting before a maildir delivery, and
18181 \quota@_directory\ is not set, it looks for a file called \(maildirfolder)\ in
18182 the maildir directory (alongside \(new)\, \(cur)\, \(tmp)\). If this exists,
18183 Exim assumes the directory is a maildir++ folder directory, which is one level
18184 down from the user's top level mailbox directory. This causes it to start at
18185 the parent directory instead of the current directory when calculating the
18186 amount of space used.
18187
18188 .em
18189 One problem with delivering into a multi-file mailbox is that it is 
18190 computationally expensive to compute the size of the mailbox for quota 
18191 checking. Various approaches have been taken to reduce the amount of work 
18192 needed. The next two sections describe two of them. A third alternative is to 
18193 use some external process for maintaining the size data, and use the expansion 
18194 of the \mailbox@_size\ option as a way of importing it into Exim.
18195 .nem
18196
18197
18198 .section Using tags to record message sizes
18199 If \maildir@_tag\ is set, the string is expanded for each delivery.
18200 When the maildir file is renamed into the \(new)\ sub-directory, the
18201 tag is added to its name. However, if adding the tag takes the length of the
18202 name to the point where the test \*stat()*\ call fails with \\ENAMETOOLONG\\,
18203 the tag is dropped and the maildir file is created with no tag.
18204
18205 Tags can be used to encode the size of files in their names; see
18206 \quota@_size@_regex\ above for an example. The expansion of \maildir@_tag\
18207 happens after the message has been written. The value of the \$message@_size$\
18208 variable is set to the number of bytes actually written. If the expansion is
18209 forced to fail, the tag is ignored, but a non-forced failure causes delivery to
18210 be deferred. The expanded tag may contain any printing characters except `/'.
18211 Non-printing characters in the string are ignored; if the resulting string is
18212 empty, it is ignored. If it starts with an alphanumeric character, a leading
18213 colon is inserted.
18214
18215
18216 .section Using a maildirsize file
18217 .index quota||in maildir delivery
18218 .index maildir format||\(maildirsize)\ file
18219 If \maildir@_use@_size@_file\ is true, Exim implements the maildir++ rules for
18220 storing quota and message size information in a file called \(maildirsize)\
18221 within the maildir directory. If this file does not exist, Exim creates it,
18222 setting the quota from the \quota\ option of the transport. If the maildir
18223 directory itself does not exist, it is created before any attempt to write a
18224 \(maildirsize)\ file.
18225
18226 The \(maildirsize)\ file is used to hold information about the sizes of
18227 messages in the maildir, thus speeding up quota calculations. The quota value
18228 in the file is just a cache; if the quota is changed in the transport, the new
18229 value overrides the cached value when the next message is delivered. The cache
18230 is maintained for the benefit of other programs that access the maildir and
18231 need to know the quota.
18232
18233 If the \quota\ option in the transport is unset or zero, the \(maildirsize)\
18234 file is maintained (with a zero quota setting), but no quota is imposed.
18235
18236 A regular expression is available for controlling which directories in the
18237 maildir participate in quota calculations. See the description of the
18238 \maildir@_quota@_directory@_regex\ option above for details.
18239
18240
18241 .section Mailstore delivery
18242 .index mailstore format||description of
18243 If the \mailstore@_format\ option is true, each message is written as two files
18244 in the given directory. A unique base name is constructed from the message id
18245 and the current delivery process, and the files that are written use this base
18246 name plus the suffixes \(.env)\ and \(.msg)\. The \(.env)\ file contains the
18247 message's envelope, and the \(.msg)\ file contains the message itself.
18248
18249 During delivery, the envelope is first written to a file with the suffix
18250 \(.tmp)\. The \(.msg)\ file is then written, and when it is complete, the
18251 \(.tmp)\ file is renamed as the \(.env)\ file. Programs that access messages in
18252 mailstore format should wait for the presence of both a \(.msg)\ and a \(.env)\
18253 file before accessing either of them. An alternative approach is to wait for
18254 the absence of a \(.tmp)\ file.
18255
18256 The envelope file starts with any text defined by the \mailstore@_prefix\
18257 option, expanded and terminated by a newline if there isn't one. Then follows
18258 the sender address on one line, then all the recipient addresses, one per line.
18259 There can be more than one recipient only if the \batch@_max\ option is set
18260 greater than one. Finally, \mailstore@_suffix\ is expanded and the result
18261 appended to the file, followed by a newline if it does not end with one.
18262
18263 If expansion of \mailstore@_prefix\ or \mailstore@_suffix\ ends with a forced
18264 failure, it is ignored. Other expansion errors are treated as serious
18265 configuration errors, and delivery is deferred.
18266
18267
18268 .section Non-special new file delivery
18269 If neither \maildir@_format\ nor \mailstore@_format\ is set, a single new file
18270 is created directly in the named directory. For example, when delivering
18271 messages into files in batched SMTP format for later delivery to some host (see
18272 section ~~SECTbatchSMTP), a setting such as
18273 .display asis
18274 directory = /var/bsmtp/$host
18275 .endd
18276 might be used. A message is written to a file with a temporary name, which is
18277 then renamed when the delivery is complete. The final name is obtained by
18278 expanding the contents of the \directory@_file\ option.
18279
18280
18281
18282
18283
18284 .
18285 .
18286 .
18287 .
18288 . ============================================================================
18289 .chapter The autoreply transport
18290 .set runningfoot "autoreply transport"
18291 .index transports||\%autoreply%\
18292 .index \%autoreply%\ transport
18293 The \%autoreply%\ transport is not a true transport in that it does not cause
18294 the message to be transmitted. Instead, it generates a new mail message.
18295 .em
18296 If the router that passes the message to this transport does not have the 
18297 \unseen\ option set, the original message (for the current recipient) is not
18298 delivered anywhere. However, when the \unseen\ option is set on the router that
18299 passes the message to this transport, routing of the address continues, so
18300 another router can set up a normal message delivery.
18301 .nem
18302
18303 The \%autoreply%\ transport is usually run as the result of mail filtering, a
18304 `vacation' message being the standard example. However, it can also be run
18305 directly from a router like any other transport. To reduce the possibility of
18306 message cascades, messages created by the \%autoreply%\ transport always have
18307 empty envelope sender addresses, like bounce messages.
18308
18309 The parameters of the message to be sent can be specified in the configuration
18310 by options described below. However, these are used only when the address
18311 passed to the transport does not contain its own reply information. When the
18312 transport is run as a consequence of a
18313 \mail\
18314 or \vacation\ command in a filter file, the parameters of the message are
18315 supplied by the filter, and passed with the address. The transport's options
18316 that define the message are then ignored (so they are not usually set in this
18317 case). The message is specified entirely by the filter or by the transport; it
18318 is never built from a mixture of options. However, the \file@_optional\,
18319 \mode\, and \return@_message\ options apply in all cases.
18320
18321 \%Autoreply%\ is implemented as a local transport. When used as a result of a
18322 command in a user's filter file, \%autoreply%\ normally runs under the uid and
18323 gid of the user, and with appropriate current and home directories (see chapter
18324 ~~CHAPenvironment).
18325
18326 There is a subtle difference between routing a message to a \%pipe%\ transport
18327 that generates some text to be returned to the sender, and routing it to an
18328 \%autoreply%\ transport. This difference is noticeable only if more than one
18329 address from the same message is so handled. In the case of a pipe, the
18330 separate outputs from the different addresses are gathered up and returned to
18331 the sender in a single message, whereas if \%autoreply%\ is used, a separate
18332 message is generated for each address that is passed to it.
18333
18334 Non-printing characters are not permitted in the header lines generated for the
18335 message that \%autoreply%\ creates, with the exception of newlines that are
18336 immediately followed by whitespace. If any non-printing characters are found,
18337 the transport defers.
18338 Whether characters with the top bit set count as printing characters or not is
18339 controlled by the \print@_topbitchars\ global option.
18340
18341 If any of the generic options for manipulating headers (for example,
18342 \headers@_add\) are set on an \%autoreply%\ transport, they apply to the copy of
18343 the original message that is included in the generated message when
18344 \return@_message\ is set. They do not apply to the generated message itself.
18345
18346 If the \%autoreply%\ transport receives return code 2 from Exim when it submits
18347 the message, indicating that there were no recipients, it does not treat this
18348 as an error. This means that autoreplies sent to \$sender@_address$\ when this
18349 is empty (because the incoming message is a bounce message) do not cause
18350 problems. They are just discarded.
18351
18352
18353 .section Private options for autoreply
18354
18355 .startconf autoreply
18356 .index options||\%autoreply%\ transport
18357 .conf bcc string$**$ unset
18358 This specifies the addresses that are to receive `blind carbon copies' of the
18359 message when the message is specified by the transport.
18360
18361 .conf cc string$**$ unset
18362 This specifies recipients of the message and the contents of the ::Cc:: header
18363 when the message is specified by the transport.
18364
18365 .conf file string$**$ unset
18366 The contents of the file are sent as the body of the message when the message
18367 is specified by the transport. If both \file\ and \text\ are set, the text
18368 string comes first.
18369
18370 .conf file@_expand boolean false
18371 If this is set, the contents of the file named by the \file\ option are
18372 subjected to string expansion as they are added to the message.
18373
18374 .conf file@_optional boolean false
18375 If this option is true, no error is generated if the file named by the \file\
18376 option or passed with the address does not exist or cannot be read.
18377
18378 .conf from string$**$ unset
18379 This specifies the contents of the ::From:: header when the message is specified
18380 by the transport.
18381
18382 .conf headers string$**$ unset
18383 This specifies additional RFC 2822 headers that are to be added to the message when
18384 the message is specified by the transport. Several can be given by using `@\n'
18385 to separate them. There is no check on the format.
18386
18387 .conf log string$**$ unset
18388 This option names a file in which a record of every message sent is logged when
18389 the message is specified by the transport.
18390
18391 .conf mode "octal integer" 0600
18392 If either the log file or the `once' file has to be created, this mode is used.
18393
18394 .em
18395 .conf never@_mail "address list$**$" unset
18396 If any run of the transport creates a message with a recipient that matches any
18397 item in the list, that recipient is quietly discarded. If all recipients are
18398 discarded, no message is created.
18399 .nem
18400
18401 .conf once string$**$ unset
18402 This option names a file or DBM database in which a record of each
18403 ::To:: recipient is kept when the message is specified by the transport.
18404 \**Note**\: This does not apply to ::Cc:: or ::Bcc:: recipients.
18405 If \once@_file@_size\ is not set, a DBM database is used, and it is allowed to
18406 grow as large as necessary. If a potential recipient is already in the
18407 database, no message is sent by default. However, if \once@_repeat\ specifies a
18408 time greater than zero, the message is sent if that much time has elapsed since
18409 a message was last sent to this recipient. If \once\ is unset, the message is
18410 always sent.
18411
18412 If \once@_file@_size\ is set greater than zero, it changes the way Exim
18413 implements the \once\ option. Instead of using a DBM file to record every
18414 recipient it sends to, it uses a regular file, whose size will never get larger
18415 than the given value. In the file, it keeps a linear list of recipient
18416 addresses and times at which they were sent messages. If the file is full when
18417 a new address needs to be added, the oldest address is dropped. If
18418 \once@_repeat\ is not set, this means that a given recipient may receive
18419 multiple messages, but at unpredictable intervals that depend on the rate of
18420 turnover of addresses in the file. If \once@_repeat\ is set, it specifies a
18421 maximum time between repeats.
18422
18423 .conf once@_file@_size integer 0
18424 See \once\ above.
18425
18426 .conf once@_repeat time$**$ 0s
18427 See \once\ above.
18428 After expansion, the value of this option must be a valid time value.
18429
18430 .conf reply@_to string$**$ unset
18431 This specifies the contents of the ::Reply-To:: header when the message is
18432 specified by the transport.
18433
18434 .conf return@_message boolean false
18435 If this is set, a copy of the original message is returned with the new
18436 message, subject to the maximum size set in the \return@_size@_limit\ global
18437 configuration option.
18438
18439 .conf subject string$**$ unset
18440 This specifies the contents of the ::Subject:: header when the message is
18441 specified by the transport.
18442 .em
18443 It is tempting to quote the original subject in automatic responses. For
18444 example:
18445 .display asis
18446 subject = Re: $h_subject:
18447 .endd
18448 There is a danger in doing this, however. It may allow a third party to 
18449 subscribe your users to an opt-in mailing list, provided that the list accepts
18450 bounce messages as subscription confirmations. Well-managed lists require a
18451 non-bounce message to confirm a subscription, so the danger is relatively
18452 small.
18453 .nem
18454
18455 .conf text string$**$ unset
18456 This specifies a single string to be used as the body of the message when the
18457 message is specified by the transport. If both \text\ and \file\ are set, the
18458 text comes first.
18459
18460 .conf to string$**$ unset
18461 This specifies recipients of the message and the contents of the ::To:: header
18462 when the message is specified by the transport.
18463
18464 .endconf
18465
18466
18467
18468 .
18469 .
18470 .
18471 .
18472 . ============================================================================
18473 .chapter The lmtp transport
18474 .set runningfoot "lmtp transport"
18475 .index transports||\%lmtp%\
18476 .index \%lmtp%\ transport
18477 .index LMTP||over a pipe
18478 .index LMTP||over a socket
18479 .rset CHAPLMTP "~~chapter"
18480 The \%lmtp%\ transport runs the LMTP protocol (RFC 2033) over a pipe to a
18481 specified command
18482 or by interacting with a Unix domain socket.
18483 This transport is something of a cross between the \%pipe%\ and \%smtp%\
18484 transports. Exim also has support for using LMTP over TCP/IP; this is
18485 implemented as an option for the \%smtp%\ transport. Because LMTP is expected
18486 to be of minority interest, the default build-time configure in \(src/EDITME)\
18487 has it commented out. You need to ensure that
18488 .display asis
18489 TRANSPORT_LMTP=yes
18490 .endd
18491 is present in your \(Local/Makefile)\ in order to have the \%lmtp%\ transport
18492 included in the Exim binary.
18493
18494 The private options of the \%lmtp%\ transport are as follows:
18495
18496 .startconf lmtp
18497 .index options||\%lmtp%\ transport
18498
18499 .conf batch@_id string$**$ unset
18500 See the description of local delivery batching in chapter ~~CHAPbatching.
18501
18502 .conf batch@_max integer 1
18503 This limits the number of addresses that can be handled in a single delivery.
18504 Most LMTP servers can handle several addresses at once, so it is normally a
18505 good idea to increase this value. See the description of local delivery
18506 batching in chapter ~~CHAPbatching.
18507
18508 .conf command string$**$ unset
18509 This option must be set if \socket\ is not set.
18510 The string is a command which is run in a separate process. It is split up into
18511 a command name and list of arguments, each of which is separately expanded (so
18512 expansion cannot change the number of arguments). The command is run directly,
18513 not via a shell. The message is passed to the new process using the standard
18514 input and output to operate the LMTP protocol.
18515
18516 .conf socket string$**$ unset
18517 This option must be set if \command\ is not set. The result of expansion must
18518 be the name of a Unix domain socket. The transport connects to the socket and
18519 delivers the message to it using the LMTP protocol.
18520
18521 .conf timeout time 5m
18522 The transport is aborted if the created process
18523 or Unix domain socket
18524 does not respond to LMTP commands or message input within this timeout.
18525
18526 .endconf
18527
18528 Here is an example of a typical LMTP transport:
18529 .display asis
18530 lmtp:
18531   driver = lmtp
18532   command = /some/local/lmtp/delivery/program
18533   batch_max = 20
18534   user = exim
18535 .endd
18536 This delivers up to 20 addresses at a time, in a mixture of domains if
18537 necessary, running as the user \*exim*\.
18538
18539
18540
18541 .
18542 .
18543 .
18544 .
18545 . ============================================================================
18546 .chapter The pipe transport
18547 .rset CHAPpipetransport "~~chapter"
18548 .set runningfoot "pipe transport"
18549 .index transports||\%pipe%\
18550 .index \%pipe%\ transport
18551 The \%pipe%\ transport is used to deliver messages via a pipe to a command
18552 running in another process. 
18553 .em
18554 One example is the
18555 use of \%pipe%\ as a pseudo-remote transport for passing messages to some other
18556 delivery mechanism (such as UUCP). Another is the use by individual users to
18557 automatically process their incoming messages. The \%pipe%\ transport can be
18558 used in one of the following ways:
18559 .nem
18560 .numberpars $.
18561 A router routes one address to a transport in the normal way, and the transport
18562 is configured as a \%pipe%\ transport. In this case, \$local@_part$\ contains
18563 the local part of the address (as usual), and the command that is run is
18564 specified by the \command\ option on the transport.
18565 .nextp
18566 .em
18567 If the \batch@_max\ option is set greater than 1 (the default), the transport 
18568 can be called upon to handle more than one address in a single run. In this
18569 case, \$local@_part$\ is not set (because it is not unique). However, the
18570 pseudo-variable \$pipe@_addresses$\ (described in section ~~SECThowcommandrun
18571 below) contains all the addresses that are being handled.
18572 .nem
18573 .nextp
18574 A router redirects an address directly to a pipe command (for example, from an
18575 alias or forward file). In this case, \$local@_part$\ contains the local part
18576 that was redirected, and \$address@_pipe$\ contains the text of the pipe
18577 command itself. The \command\ option on the transport is ignored.
18578 .endp
18579
18580 The \%pipe%\ transport is a non-interactive delivery method. Exim can also
18581 deliver messages over pipes using the LMTP interactive protocol. This is
18582 implemented by the \%lmtp%\ transport.
18583
18584 In the case when \%pipe%\ is run as a consequence of an entry in a local user's
18585 \(.forward)\ file, the command runs under the uid and gid of that user. In
18586 other cases, the uid and gid have to be specified explicitly, either on the
18587 transport or on the router that handles the address. Current and `home'
18588 directories are also controllable. See chapter ~~CHAPenvironment for details of
18589 the local delivery environment.
18590
18591
18592 .em
18593 .section Concurrent delivery
18594 If two messages arrive at almost the same time, and both are routed to a pipe 
18595 delivery, the two pipe transports may be run concurrently. You must ensure that 
18596 any pipe commands you set up are robust against this happening. If the commands 
18597 write to a file, the \exim@_lock\ utility might be of use.
18598 .nem
18599
18600
18601 .section Returned status and data
18602 .index \%pipe%\ transport||returned data
18603 If the command exits with a non-zero return code, the delivery is deemed to
18604 have failed, unless either the \ignore@_status\ option is set (in which case
18605 the return code is treated as zero), or the return code is one of those listed
18606 in the \temp@_errors\ option, which are interpreted as meaning `try again
18607 later'. In this case, delivery is deferred. Details of a permanent failure are
18608 logged, but are not included in the bounce message, which merely contains
18609 `local delivery failed'.
18610
18611 If the return code is greater than 128 and the command being run is a shell
18612 script, it normally means that the script was terminated by a signal whose
18613 value is the return code minus 128.
18614
18615 If Exim is unable to run the command (that is, if \*execve()*\ fails), the
18616 return code is set to 127. This is the value that a shell returns if it is
18617 asked to run a non-existent command. The wording for the log line suggests that
18618 a non-existent command may be the problem.
18619
18620 The \return@_output\ option can affect the result of a pipe delivery. If it is
18621 set and the command produces any output on its standard output or standard
18622 error streams, the command is considered to have failed, even if it gave a zero
18623 return code or if \ignore@_status\ is set. The output from the command is
18624 included as part of the bounce message. The \return@_fail@_output\ option is
18625 similar, except that output is returned only when the command exits with a
18626 failure return code, that is, a value other than zero or a code that matches
18627 \temp@_errors\.
18628
18629
18630 .section How the command is run
18631 .rset SECThowcommandrun "~~chapter.~~section"
18632 .index \%pipe%\ transport||path for command
18633 The command line is (by default) broken down into a command name and arguments
18634 by the \%pipe%\ transport itself. The \allow@_commands\ and \restrict@_to@_path\
18635 options can be used to restrict the commands that may be run.
18636 .index quoting||in pipe command
18637 Unquoted arguments are delimited by white space. If an argument appears in
18638 double quotes, backslash is interpreted as an escape character in the usual
18639 way. If an argument appears in single quotes, no escaping is done.
18640
18641 String expansion is applied to the command line except when it comes from a
18642 traditional \(.forward)\ file (commands from a filter file are expanded). The
18643 expansion is applied to each argument in turn rather than to the whole line.
18644 For this reason, any string expansion item that contains white space must be
18645 quoted so as to be contained within a single argument. A setting such as
18646 .display asis
18647 command = /some/path ${if eq{$local_part}{postmaster}{xxx}{yyy}}
18648 .endd
18649 will not work, because the expansion item gets split between several
18650 arguments. You have to write
18651 .display asis
18652 command = /some/path "${if eq{$local_part}{postmaster}{xxx}{yyy}}"
18653 .endd
18654 to ensure that it is all in one argument. The expansion is done in this way,
18655 argument by argument, so that the number of arguments cannot be changed as a
18656 result of expansion, and quotes or backslashes in inserted variables do not
18657 interact with external quoting.
18658
18659 .index transport||filter
18660 .index filter||transport filter
18661 Special handling takes place when an argument consists of precisely the text
18662 `$tt{@$pipe@_addresses}'. This is not a general expansion variable; the only
18663 place this string is recognized is when it appears as an argument for a pipe or
18664 transport filter command. It causes each address that is being handled to be
18665 inserted in the argument list at that point $it{as a separate argument}. This
18666 avoids any problems with spaces or shell metacharacters, and is of use when a
18667 \%pipe%\ transport is handling groups of addresses in a batch.
18668
18669 After splitting up into arguments and expansion, the resulting command is run
18670 in a subprocess directly from the transport, $it{not} under a shell. The
18671 message that is being delivered is supplied on the standard input, and the
18672 standard output and standard error are both connected to a single pipe that is
18673 read by Exim. The \max@_output\ option controls how much output the command may
18674 produce, and the \return@_output\ and \return@_fail@_output\ options control
18675 what is done with it.
18676
18677 Not running the command under a shell (by default) lessens the security risks
18678 in cases when a command from a user's filter file is built out of data that was
18679 taken from an incoming message. If a shell is required, it can of course be
18680 explicitly specified as the command to be run. However, there are circumstances
18681 where existing commands (for example, in \(.forward)\ files) expect to be run
18682 under a shell and cannot easily be modified. To allow for these cases, there is
18683 an option called \use@_shell\, which changes the way the \%pipe%\ transport
18684 works. Instead of breaking up the command line as just described, it expands it
18685 as a single string and passes the result to \(/bin/sh)\. The
18686 \restrict@_to@_path\ option and the \$pipe@_addresses$\ facility cannot be used
18687 with \use@_shell\, and the whole mechanism is inherently less secure.
18688
18689
18690 .section Environment variables
18691 .rset SECTpipeenv "~~chapter.~~section"
18692 .index \%pipe%\ transport||environment for command
18693 .index environment for pipe transport
18694 The environment variables listed below are set up when the command is invoked.
18695 This list is a compromise for maximum compatibility with other MTAs. Note that
18696 the \environment\ option can be used to add additional variables to this
18697 environment.
18698 .display flow
18699 .tabs 20
18700 DOMAIN              $t $rm{the domain of the address}
18701 HOME                $t $rm{the home directory, if set}
18702 HOST                $t $rm{the host name when called from a router (see below)}
18703 LOCAL@_PART         $t $rm{see below}
18704 LOCAL@_PART@_PREFIX $t $rm{see below}
18705 LOCAL@_PART@_SUFFIX $t $rm{see below}
18706 LOGNAME             $t $rm{see below}
18707 MESSAGE@_ID         $t $rm{the message's id}
18708 PATH                $t $rm{as specified by the \path\ option below}
18709 QUALIFY@_DOMAIN     $t $rm{the sender qualification domain}
18710 RECIPIENT           $t $rm{the complete recipient address}
18711 SENDER              $t $rm{the sender of the message (empty if a bounce)}
18712 SHELL               $t `$tt{/bin/sh}'
18713 TZ                  $t $rm{the value of the \timezone\ option, if set}
18714 USER                $t $rm{see below}
18715 .endd
18716
18717 When a \%pipe%\ transport is called directly from (for example) an \%accept%\
18718 router, \\LOCAL@_PART\\ is set to the local part of the address. When it is
18719 called as a result of a forward or alias expansion, \\LOCAL@_PART\\ is set to
18720 the local part of the address that was expanded. In both cases, any affixes are
18721 removed from the local part, and made available in \\LOCAL@_PART@_PREFIX\\ and
18722 \\LOCAL@_PART@_SUFFIX\\, respectively. \\LOGNAME\\ and \\USER\\ are set to the
18723 same value as \\LOCAL@_PART\\ for compatibility with other MTAs.
18724
18725 .index \\HOST\\
18726 \\HOST\\ is set only when a \%pipe%\ transport is called from a router that
18727 associates hosts with an address, typically when using \%pipe%\ as a
18728 pseudo-remote transport. \\HOST\\ is set to the first host name specified by
18729 the router.
18730
18731 .index \\HOME\\
18732 If the transport's generic \home@_directory\ option is set, its value is used
18733 for the \\HOME\\ environment variable. Otherwise, a home directory may be set
18734 by the router's \transport@_home@_directory\ option, which defaults to the
18735 user's home directory if \check@_local@_user\ is set.
18736
18737 .section Private options for pipe
18738 .index options||\%pipe%\ transport
18739
18740 .startconf pipe
18741
18742 .conf allow@_commands "string list$**$" unset
18743 .index \%pipe%\ transport||permitted commands
18744 The string is expanded, and is then interpreted as a colon-separated list of
18745 permitted commands. If \restrict@_to@_path\ is not set, the only commands
18746 permitted are those in the \allow@_commands\ list. They need not be absolute
18747 paths; the \path\ option is still used for relative paths. If
18748 \restrict@_to@_path\ is set with \allow@_commands\, the command must either be
18749 in the \allow@_commands\ list, or a name without any slashes that is found on
18750 the path. In other words, if neither \allow@_commands\ nor \restrict@_to@_path\
18751 is set, there is no restriction on the command, but otherwise only commands
18752 that are permitted by one or the other are allowed. For example, if
18753 .display asis
18754 allow_commands = /usr/bin/vacation
18755 .endd
18756 and \restrict@_to@_path\ is not set, the only permitted command is
18757 \(/usr/bin/vacation)\. The \allow@_commands\ option may not be set if
18758 \use@_shell\ is set.
18759
18760 .conf batch@_id string$**$ unset
18761 See the description of local delivery batching in chapter ~~CHAPbatching.
18762
18763 .conf batch@_max integer 1
18764 This limits the number of addresses that can be handled in a single delivery.
18765 See the description of local delivery batching in chapter ~~CHAPbatching.
18766
18767 .conf check@_string string unset
18768 As \%pipe%\ writes the message, the start of each line is tested for matching
18769 \check@_string\, and if it does, the initial matching characters are replaced
18770 by the contents of \escape@_string\, provided both are set. The value of
18771 \check@_string\ is a literal string, not a regular expression, and the case of
18772 any letters it contains is significant. When \use@_bsmtp\ is set, the contents
18773 of \check@_string\ and \escape@_string\ are forced to values that implement the
18774 SMTP escaping protocol. Any settings made in the configuration file are
18775 ignored.
18776
18777 .conf command string$**$ unset
18778 This option need not be set when \%pipe%\ is being used to deliver to pipes
18779 obtained directly from address redirections. In other cases, the option must be
18780 set, to provide a command to be run. It need not yield an absolute path (see
18781 the \path\ option below). The command is split up into separate arguments by
18782 Exim, and each argument is separately expanded, as described in section
18783 ~~SECThowcommandrun above.
18784
18785 .conf environment string$**$ unset
18786 .index \%pipe%\ transport||environment for command
18787 .index environment for \%pipe%\ transport
18788 This option is used to add additional variables to the environment in which the
18789 command runs (see section ~~SECTpipeenv for the default list). Its value is a
18790 string which is expanded, and then interpreted as a colon-separated list of
18791 environment settings of the form `<<name>>=<<value>>'.
18792
18793 .conf escape@_string string unset
18794 See \check@_string\ above.
18795
18796 .conf freeze@_exec@_fail boolean false
18797 .index exec failure
18798 .index failure of exec
18799 .index \%pipe%\ transport||failure of exec
18800 Failure to exec the command in a pipe transport is by default treated like
18801 any other failure while running the command. However, if \freeze@_exec@_fail\
18802 is set, failure to exec is treated specially, and causes the message to be
18803 frozen, whatever the setting of \ignore@_status\.
18804
18805 .conf ignore@_status boolean false
18806 If this option is true, the status returned by the subprocess that is set up to
18807 run the command is ignored, and Exim behaves as if zero had been returned.
18808 Otherwise, a non-zero status
18809 or termination by signal
18810 causes an error return from the transport unless the status value is one of
18811 those listed in \temp@_errors\; these cause the delivery to be deferred and
18812 tried again later.
18813
18814 .conf log@_defer@_output boolean false
18815 .index \%pipe%\ transport||logging output
18816 If this option is set, and the status returned by the command is
18817 one of the codes listed in \temp@_errors\ (that is, delivery was deferred),
18818 and any output was produced, the first line of it is written to the main log.
18819
18820 .conf log@_fail@_output boolean false
18821 If this option is set, and the command returns any output, and also ends with a
18822 return code that is neither zero nor one of the return codes listed in
18823 \temp@_errors\ (that is, the delivery failed), the first line of output is
18824 written to the main log.
18825 .em
18826 This option and \log@_output\ are mutually exclusive. Only one of them may be 
18827 set.
18828 .nem
18829
18830 .conf log@_output boolean false
18831 If this option is set and the command returns any output, the first line of
18832 output is written to the main log, whatever the return code.
18833 .em
18834 This option and \log@_fail@_output\ are mutually exclusive. Only one of them
18835 may be set.
18836 .nem
18837
18838 .conf max@_output integer 20K
18839 This specifies the maximum amount of output that the command may produce on its
18840 standard output and standard error file combined. If the limit is exceeded, the
18841 process running the command is killed. This is intended as a safety measure to
18842 catch runaway processes. The limit is applied independently of the settings of
18843 the options that control what is done with such output (for example,
18844 \return@_output\). Because of buffering effects, the amount of output may
18845 exceed the limit by a small amount before Exim notices.
18846
18847 .conf message@_prefix string$**$ "see below"
18848 The string specified here is expanded and output at the start of every message.
18849 The default is unset if \use@_bsmtp\ is set. Otherwise it is
18850 .display asis
18851 message_prefix = \
18852   From ${if def:return_path{$return_path}{MAILER-DAEMON}}\
18853   ${tod_bsdinbox}\n
18854 .endd
18855 .index Cyrus
18856 .index \tmail\
18857 .index `From' line
18858 This is required by the commonly used \(/usr/bin/vacation)\ program.
18859 However, it must $it{not} be present if delivery is to the Cyrus IMAP server,
18860 or to the \tmail\ local delivery agent. The prefix can be suppressed by setting
18861 .display asis
18862 message_prefix =
18863 .endd
18864
18865 .conf message@_suffix string$**$ "see below"
18866 The string specified here is expanded and output at the end of every message.
18867 The default is unset if \use@_bsmtp\ is set. Otherwise it is a single newline.
18868 The suffix can be suppressed by setting
18869 .display asis
18870 message_suffix =
18871 .endd
18872
18873 .conf path string $tt{/usr/bin}
18874 This option specifies the string that is set up in the \\PATH\\ environment
18875 variable of the subprocess. If the \command\ option does not yield an absolute
18876 path name, the command is sought in the \\PATH\\ directories, in the usual way.
18877 \**Warning**\: This does not apply to a command specified as a transport
18878 filter.
18879
18880 .conf pipe@_as@_creator boolean false
18881 .index uid (user id)||local delivery
18882 If the generic \user\ option is not set and this option is true, the delivery
18883 process is run under the uid that was in force when Exim was originally called
18884 to accept the message. If the group id is not otherwise set (via the generic
18885 \group\ option), the gid that was in force when Exim was originally called to
18886 accept the message is used.
18887
18888 .conf restrict@_to@_path boolean false
18889 When this option is set, any command name not listed in \allow@_commands\ must
18890 contain no slashes. The command is searched for only in the directories listed
18891 in the \path\ option. This option is intended for use in the case when a pipe
18892 command has been generated from a user's \(.forward)\ file. This is usually
18893 handled by a \%pipe%\ transport called \address@_pipe\.
18894
18895 .conf return@_fail@_output boolean false
18896 If this option is true, and the command produced any output and ended with a
18897 return code other than zero or one of the codes listed in \temp@_errors\ (that
18898 is, the delivery failed), the output is returned in the bounce message.
18899 However, if the message has a null sender (that is, it is itself a bounce
18900 message), output from the command is discarded.
18901 .em
18902 This option and \return@_output\ are mutually exclusive. Only one of them may
18903 be set.
18904 .nem
18905
18906 .conf return@_output boolean false
18907 If this option is true, and the command produced any output, the delivery is
18908 deemed to have failed whatever the return code from the command, and the output
18909 is returned in the bounce message. Otherwise, the output is just discarded.
18910 However, if the message has a null sender (that is, it is a bounce message),
18911 output from the command is always discarded, whatever the setting of this
18912 option.
18913 .em
18914 This option and \return@_fail@_output\ are mutually exclusive. Only one of them
18915 may be set.
18916 .nem
18917
18918 .conf temp@_errors "string list" "see below"
18919 .index \%pipe%\ transport||temporary failure
18920 This option contains either a colon-separated list of numbers, or a single
18921 asterisk. If \ignore@_status\ is false
18922 and \return@_output\ is not set,
18923 and the command exits with a non-zero return code, the failure is treated as
18924 temporary and the delivery is deferred if the return code matches one of the
18925 numbers, or if the setting is a single asterisk. Otherwise, non-zero return
18926 codes are treated as permanent errors. The default setting contains the codes
18927 defined by \\EX@_TEMPFAIL\\ and \\EX@_CANTCREAT\\ in \(sysexits.h)\. If Exim is
18928 compiled on a system that does not define these macros, it assumes values of 75
18929 and 73, respectively.
18930
18931 .conf timeout time 1h
18932 If the command fails to complete within this time, it is killed. This normally
18933 causes the delivery to fail. A zero time interval specifies no timeout. In
18934 order to ensure that any subprocesses created by the command are also killed,
18935 Exim makes the initial process a process group leader, and kills the whole
18936 process group on a timeout. However, this can be defeated if one of the
18937 processes starts a new process group.
18938
18939 .conf umask "octal integer" 022
18940 This specifies the umask setting for the subprocess that runs the command.
18941
18942 .conf use@_bsmtp boolean false
18943 .index envelope sender
18944 If this option is set true, the \%pipe%\ transport writes messages in `batch
18945 SMTP' format, with the envelope sender and recipient(s) included as SMTP
18946 commands. If you want to include a leading \\HELO\\ command with such messages,
18947 you can do so by setting the \message@_prefix\ option. See section
18948 ~~SECTbatchSMTP for details of batch SMTP.
18949
18950 .conf use@_crlf boolean false
18951 .index carriage return
18952 .index linefeed
18953 This option causes lines to be terminated with the two-character CRLF sequence
18954 (carriage return, linefeed) instead of just a linefeed character. In the case
18955 of batched SMTP, the byte sequence written to the pipe is then an exact image
18956 of what would be sent down a real SMTP connection.
18957
18958 The contents of the \message@_prefix\ and \message@_suffix\ options are written
18959 verbatim, so must contain their own carriage return characters if these are
18960 needed. Since the default values for both \message@_prefix\ and
18961 \message@_suffix\ end with a single linefeed, their values
18962 must
18963 be changed to end with \"@\r@\n"\ if \use@_crlf\ is set.
18964
18965 .conf use@_shell boolean false
18966 If this option is set, it causes the command to be passed to \(/bin/sh)\
18967 instead of being run directly from the transport, as described in section
18968 ~~SECThowcommandrun. This is less secure, but is needed in some situations
18969 where the command is expected to be run under a shell and cannot easily be
18970 modified. The \allow@_commands\ and \restrict@_to@_path\ options, and the
18971 `$tt{@$pipe@_addresses}' facility are incompatible with \use@_shell\. The
18972 command is expanded as a single string, and handed to \(/bin/sh)\ as data for
18973 its \-c-\ option.
18974
18975 .endconf
18976
18977 .section Using an external local delivery agent
18978 .index local delivery||using an external agent
18979 .index \*procmail*\
18980 .index external local delivery
18981 .index delivery||\*procmail*\
18982 .index delivery||by external agent
18983 The \%pipe%\ transport can be used to pass all messages that require local
18984 delivery to a separate local delivery agent such as \procmail\. When doing
18985 this, care must be taken to ensure that the pipe is run under an appropriate
18986 uid and gid. In some configurations one wants this to be a uid that is trusted
18987 by the delivery agent to supply the correct sender of the message. It may be
18988 necessary to recompile or reconfigure the delivery agent so that it trusts an
18989 appropriate user. The following is an example transport and router
18990 configuration for \procmail\:
18991 .display asis
18992 # transport
18993 procmail_pipe:
18994   driver = pipe
18995   command = /usr/local/bin/procmail -d $local_part
18996   return_path_add
18997   delivery_date_add
18998   envelope_to_add
18999   check_string = "From "
19000   escape_string = ">From "
19001   user = $local_part
19002   group = mail
19003 .endd
19004 .display asis
19005 # router
19006 procmail:
19007   driver = accept
19008   check_local_user
19009   transport = procmail_pipe
19010 .endd
19011
19012 In this example, the pipe is run as the local user, but with the group set to
19013 \*mail*\. An alternative is to run the pipe as a specific user such as \*mail*\
19014 or \*exim*\, but in this case you must arrange for \procmail\ to trust that
19015 user to supply a correct sender address. If you do not specify either a \group\
19016 or a \user\ option, the pipe command is run as the local user. The home
19017 directory is the user's home directory by default.
19018
19019 Note that the command that the pipe transport runs does $it{not} begin with
19020 .display asis
19021 IFS=" "
19022 .endd
19023 as shown in the \procmail\ documentation, because Exim does not by default use
19024 a shell to run pipe commands.
19025
19026 .index Cyrus
19027 The next example shows a transport and a router for a system where local
19028 deliveries are handled by the Cyrus IMAP server.
19029 .display asis
19030 # transport
19031 local_delivery_cyrus:
19032   driver = pipe
19033   command = /usr/cyrus/bin/deliver \
19034             -m ${substr_1:$local_part_suffix} -- $local_part
19035   user = cyrus
19036   group = mail
19037   return_output
19038   log_output
19039   message_prefix =
19040   message_suffix =
19041 .endd
19042 .display asis
19043 # router
19044 local_user_cyrus:
19045   driver = accept
19046   check_local_user
19047   local_part_suffix = .*
19048   transport = local_delivery_cyrus
19049 .endd
19050 Note the unsetting of \message@_prefix\ and \message@_suffix\, and the use of
19051 \return@_output\ to cause any text written by Cyrus to be returned to the
19052 sender.
19053
19054
19055 .
19056 .
19057 .
19058 .
19059 . ============================================================================
19060 .chapter The smtp transport
19061 .rset CHAPsmtptrans "~~chapter"
19062 .set runningfoot "smtp transport"
19063 .index transports||\%smtp%\
19064 .index \%smtp%\ transport
19065 The \%smtp%\ transport delivers messages over TCP/IP connections using the SMTP
19066 or LMTP protocol. The list of hosts to try can either be taken from the address
19067 that is being processed (having been set up by the router), or specified
19068 explicitly for the transport. Timeout and retry processing (see chapter
19069 ~~CHAPretry) is applied to each IP address independently.
19070
19071 .section Multiple messages on a single connection
19072 The sending of multiple messages over a single TCP/IP connection can arise in
19073 two ways:
19074 .numberpars $.
19075 If a message contains more than \max@_rcpt\ (see below) addresses that are
19076 routed to the same host, more than one copy of the message has to be sent to
19077 that host. In this situation, multiple copies may be sent in a single run of
19078 the \%smtp%\ transport over a single TCP/IP connection. (What Exim actually does
19079 when it has too many addresses to send in one message also depends on the value
19080 of the global \remote@_max@_parallel\ option. Details are given in section
19081 ~~SECToutSMTPTCP.)
19082 .nextp
19083 .index hints database||remembering routing
19084 When a message has been successfully delivered over a TCP/IP connection, Exim
19085 looks in its hints database to see if there are any other messages awaiting a
19086 connection to the same host. If there are, a new delivery process is started
19087 for one of them, and the current TCP/IP connection is passed on to it. The new
19088 process may in turn send multiple copies and possibly create yet another
19089 process.
19090 .endp
19091
19092 For each copy sent over the same TCP/IP connection, a sequence counter is
19093 incremented, and if it ever gets to the value of \connection@_max@_messages\,
19094 no further messages are sent over that connection.
19095
19096
19097 .section Use of the @$host variable
19098 .index \$host$\
19099 .index \$host@_address$\
19100 At the start of a run of the \%smtp%\ transport, the values of \$host$\ and
19101 \$host@_address$\ are the name and IP address of the first host on the host list
19102 passed by the router. However, when the transport is about to connect to a
19103 specific host, and while it is connected to that host, \$host$\ and
19104 \$host@_address$\ are set to the values for that host. These are the values
19105 that are in force when the \helo@_data\, \hosts@_try@_auth\, \interface\,
19106 \serialize@_hosts\, and the various TLS options are expanded.
19107
19108
19109 .section Private options for smtp
19110 The private options of the \%smtp%\ transport are as follows:
19111
19112 .index options||\%smtp%\ transport
19113 .startconf smtp
19114 .conf allow@_localhost boolean false
19115 .index local host||sending to
19116 .index fallback||hosts specified on transport
19117 When a host specified in \hosts\ or \fallback@_hosts\ (see below) turns out to
19118 be the local host, or is listed in \hosts@_treat@_as@_local\, delivery is
19119 deferred by default. However, if \allow@_localhost\ is set, Exim goes on to do
19120 the delivery anyway. This should be used only in special cases when the
19121 configuration ensures that no looping will result (for example, a differently
19122 configured Exim is listening on the port to which the message is sent).
19123
19124 .conf authenticated@_sender string$**$ unset
19125 .index Cyrus
19126 When Exim has authenticated as a client, this option sets a value for the
19127 \\AUTH=\\ item on outgoing \\MAIL\\ commands, overriding any existing
19128 authenticated sender value. If the string expansion is forced to fail, the
19129 option is ignored. Other expansion failures cause delivery to be deferred. If
19130 the result of expansion is an empty string, that is also ignored.
19131
19132 If the SMTP session is not authenticated, the expansion of
19133 \authenticated@_sender\ still happens (and can cause the delivery to be
19134 deferred if it fails), but no \\AUTH=\\ item is added to \\MAIL\\ commands.
19135
19136 This option allows you to use the \%smtp%\ transport in LMTP mode to
19137 deliver mail to Cyrus IMAP and provide the proper local part as the
19138 `authenticated sender', via a setting such as:
19139 .display asis
19140 authenticated_sender = $local_part
19141 .endd
19142 This removes the need for IMAP subfolders to be assigned special ACLs to
19143 allow direct delivery to those subfolders.
19144
19145 Because of expected uses such as that just described for Cyrus (when no
19146 domain is involved), there is no checking on the syntax of the provided
19147 value.
19148
19149 .conf command@_timeout time 5m
19150 This sets a timeout for receiving a response to an SMTP command that has been
19151 sent out. It is also used when waiting for the initial banner line from the
19152 remote host. Its value must not be zero.
19153
19154 .conf connect@_timeout time 5m
19155 This sets a timeout for the \*connect()*\ function, which sets up a TCP/IP call
19156 to a remote host. A setting of zero allows the system timeout (typically
19157 several minutes) to act. To have any effect, the value of this option must be
19158 less than the system timeout. However, it has been observed that on some
19159 systems there is no system timeout, which is why the default value for this
19160 option is 5 minutes, a value recommended by RFC 1123.
19161
19162 .index SMTP||passed connection
19163 .index SMTP||multiple deliveries
19164 .index multiple SMTP deliveries
19165 .conf connection@_max@_messages integer 500
19166 This controls the maximum number of separate message deliveries that are sent
19167 over a single TCP/IP connection. If the value is zero, there is no limit.
19168 For testing purposes, this value can be overridden by the \-oB-\ command line
19169 option.
19170
19171 .conf data@_timeout time 5m
19172 This sets a timeout for the transmission of each block in the data portion of
19173 the message. As a result, the overall timeout for a message depends on the size
19174 of the message. Its value must not be zero. See also \final@_timeout\.
19175
19176 .conf delay@_after@_cutoff boolean true
19177 This option controls what happens when all remote IP addresses for a given
19178 domain have been inaccessible for so long that they have passed their retry
19179 cutoff times.
19180
19181 In the default state, if the next retry time has not been reached for any of
19182 them, the address is bounced without trying any deliveries. In other words,
19183 Exim delays retrying an IP address after the final cutoff time until a new
19184 retry time is reached, and can therefore bounce an address without ever trying
19185 a delivery, when machines have been down for a long time. Some people are
19186 unhappy at this prospect, so...
19187
19188 If \delay@_after@_cutoff\ is set false, Exim behaves differently. If all IP
19189 addresses are past their final cutoff time, Exim tries to deliver to those
19190 IP addresses that have not been tried since the message arrived. If there are
19191 none, of if they all fail, the address is bounced. In other words, it does not
19192 delay when a new message arrives, but immediately tries those expired IP
19193 addresses that haven't been tried since the message arrived. If there is a
19194 continuous stream of messages for the dead hosts, unsetting
19195 \delay@_after@_cutoff\ means that there will be many more attempts to deliver
19196 to them.
19197
19198 .conf dns@_qualify@_single boolean true
19199 If the \hosts\ or \fallback@_hosts\ option is being used,
19200 and the \gethostbyname\ option is false,
19201 the \\RES@_DEFNAMES\\ resolver option is set. See the \qualify@_single\ option
19202 in chapter ~~CHAPdnslookup for more details.
19203
19204 .conf dns@_search@_parents boolean false
19205 .index \search@_parents\
19206 If the \hosts\ or \fallback@_hosts\ option is being used, and the
19207 \gethostbyname\ option is false, the \\RES@_DNSRCH\\ resolver option is set.
19208 See the \search@_parents\ option in chapter ~~CHAPdnslookup for more details.
19209
19210
19211 .conf fallback@_hosts "string list" unset
19212 .index fallback||hosts specified on transport
19213 String expansion is not applied to this option. The argument must be a
19214 colon-separated list of host names or IP addresses. Fallback hosts can also be
19215 specified on routers, which associate them with the addresses they process. As
19216 for the \hosts\ option without \hosts@_override\, \fallback@_hosts\ specified
19217 on the transport is used only if the address does not have its own associated
19218 fallback host list. Unlike \hosts\, a setting of \fallback@_hosts\ on an
19219 address is not overridden by \hosts@_override\. However, \hosts@_randomize\
19220 does apply to fallback host lists.
19221
19222 If Exim is unable to deliver to any of the hosts for a particular address, and
19223 the errors are not permanent rejections, the address is put on a separate
19224 transport queue with its host list replaced by the fallback hosts, unless the
19225 address was routed via MX records and the current host was in the original MX
19226 list. In that situation, the fallback host list is not used.
19227
19228 Once normal deliveries are complete, the fallback queue is delivered by
19229 re-running the same transports with the new host lists. If several failing
19230 addresses have the same fallback hosts (and \max@_rcpt\ permits it), a single
19231 copy of the message is sent.
19232
19233 The resolution of the host names on the fallback list is controlled by the
19234 \gethostbyname\ option, as for the \hosts\ option. Fallback hosts apply
19235 both to cases when the host list comes with the address and when it is taken
19236 from \hosts\. This option provides a `use a smart host only if delivery fails'
19237 facility.
19238
19239 .conf final@_timeout time 10m
19240 This is the timeout that applies while waiting for the response to the final
19241 line containing just `.' that terminates a message. Its value must not be zero.
19242
19243 .conf gethostbyname boolean false
19244 If this option is true when the \hosts\ and/or \fallback@_hosts\ options are
19245 being used, names are looked up using \*gethostbyname()*\
19246 (or \*getipnodebyname()*\ when available)
19247 instead of using the DNS. Of course, that function may in fact use the DNS, but
19248 it may also consult other sources of information such as \(/etc/hosts)\.
19249
19250 .index \\HELO\\||argument, setting
19251 .index \\EHLO\\||argument, setting
19252 .conf helo@_data string$**$ $tt{@$primary@_hostname}
19253 The value of this option is expanded, and used as the argument for the \\EHLO\\
19254 or \\HELO\\ command that starts the outgoing SMTP session.
19255
19256 .conf hosts "string list$**$" unset
19257 Hosts are associated with an address by a router such as \%dnslookup%\, which
19258 finds the hosts by looking up the address domain in the DNS. However, addresses
19259 can be passed to the \%smtp%\ transport by any router, and not all of them can
19260 provide an associated host list. The \hosts\ option specifies a list of hosts
19261 which are used if the address being processed does not have any hosts
19262 associated with it. The hosts specified by \hosts\ are also used, whether or
19263 not the address has its own hosts, if \hosts@_override\ is set.
19264
19265 The string is first expanded, before being interpreted as a colon-separated
19266 list of host names or IP addresses. If the expansion fails, delivery is
19267 deferred. Unless the failure was caused by the inability to complete a lookup,
19268 the error is logged to the panic log as well as the main log. Host names are
19269 looked up either by searching directly for address records in the DNS or by
19270 calling \*gethostbyname()*\
19271 (or \*getipnodebyname()*\ when available),
19272 depending on the setting of the \gethostbyname\ option. When Exim is compiled
19273 with IPv6 support, if a host that is looked up in the DNS has both IPv4 and
19274 IPv6 addresses, both types of address are used.
19275
19276 During delivery, the hosts are tried in order, subject to their retry status,
19277 unless \hosts@_randomize\ is set.
19278
19279 .conf hosts@_avoid@_esmtp "host list$**$" unset
19280 .index ESMTP, avoiding use of
19281 .index \\HELO\\||forcing use of
19282 .index \\EHLO\\||avoiding use of
19283 .index \\PIPELINING\\||avoiding the use of
19284 This option is for use with broken hosts that announce ESMTP facilities (for
19285 example, \\PIPELINING\\) and then fail to implement them properly. When a host
19286 matches \hosts@_avoid@_esmtp\, Exim sends \\HELO\\ rather than \\EHLO\\ at the
19287 start of the SMTP session. This means that it cannot use any of the ESMTP
19288 facilities such as \\AUTH\\, \\PIPELINING\\, \\SIZE\\, and \\STARTTLS\\.
19289
19290 .conf hosts@_avoid@_tls "host list$**$" unset
19291 .index TLS||avoiding for certain hosts
19292 Exim will not try to start a TLS session when delivering to any host that
19293 matches this list. See chapter ~~CHAPTLS for details of TLS.
19294
19295 .conf hosts@_max@_try integer 5
19296 .index host||maximum number to try
19297 .index limit||number of hosts tried
19298 .index limit||number of MX tried
19299 .index MX record||maximum tried
19300 This option limits the number of IP addresses that are tried for any one
19301 delivery in cases where there are temporary delivery errors. Section
19302 ~~SECTvalhosmax describes in detail how the value of this option is used.
19303
19304 .em
19305 .conf hosts@_max@_try@_hardlimit integer 50
19306 This is an additional check on the maximum number of IP addresses that Exim 
19307 tries for any one delivery. Section ~~SECTvalhosmax describes its use and why 
19308 it exists.
19309 .nem
19310
19311 .conf hosts@_nopass@_tls "host list$**$" unset
19312 .index TLS||passing connection
19313 .index multiple SMTP deliveries
19314 .index TLS||multiple message deliveries
19315 For any host that matches this list, a connection on which a TLS session has
19316 been started will not be passed to a new delivery process for sending another
19317 message on the same connection. See section ~~SECTmulmessam for an explanation
19318 of when this might be needed.
19319
19320 .conf hosts@_override boolean false
19321 If this option is set and the \hosts\ option is also set, any hosts that are
19322 attached to the address are ignored, and instead the hosts specified by the
19323 \hosts\ option are always used. This option does not apply to
19324 \fallback@_hosts\.
19325
19326 .conf hosts@_randomize boolean false
19327 .index randomized host list
19328 .index host||list of, randomized
19329 .index fallback||randomized hosts
19330 If this option is set, and either the list of hosts is taken from the
19331 \hosts\ or the \fallback@_hosts\ option, or the hosts supplied by the router
19332 were not obtained from MX records (this includes fallback hosts from the
19333 router), and were not randomizied by the router, the order of trying the hosts
19334 is randomized each time the transport runs. Randomizing the order of a host
19335 list can be used to do crude load sharing.
19336
19337 When \hosts@_randomize\ is true, a host list may be split into groups whose
19338 order is separately randomized. This makes it possible to set up MX-like
19339 behaviour. The boundaries between groups are indicated by an item that is just
19340 \"+"\ in the host list. For example:
19341 .display asis
19342 hosts = host1:host2:host3:+:host4:host5
19343 .endd
19344 The order of the first three hosts and the order of the last two hosts is
19345 randomized for each use, but the first three always end up before the last two.
19346 If \hosts@_randomize\ is not set, a \"+"\ item in the list is ignored.
19347
19348 .index authentication||required by client
19349 .conf hosts@_require@_auth "host list$**$" unset
19350 This option provides a list of servers for which authentication must succeed
19351 before Exim will try to transfer a message. If authentication fails for
19352 servers which are not in this list, Exim tries to send unauthenticated. If
19353 authentication fails for one of these servers, delivery is deferred. This
19354 temporary error is detectable in the retry rules, so it can be turned into a
19355 hard failure if required. See also \hosts@_try@_auth\, and chapter
19356 ~~CHAPSMTPAUTH for details of authentication.
19357
19358 .conf hosts@_require@_tls "host list$**$" unset
19359 .index TLS||requiring for certain servers
19360 Exim will insist on using a TLS session when delivering to any host that
19361 matches this list. See chapter ~~CHAPTLS for details of TLS.
19362 \**Note**\: This option affects outgoing mail only. To insist on TLS for
19363 incoming messages, use an appropriate ACL.
19364
19365 .index authentication||optional in client
19366 .conf hosts@_try@_auth "host list$**$" unset
19367 This option provides a list of servers to which, provided they announce
19368 authentication support, Exim will attempt to authenticate as a client when it
19369 connects. If authentication fails, Exim will try to transfer the message
19370 unauthenticated. See also \hosts@_require@_auth\, and chapter ~~CHAPSMTPAUTH
19371 for details of authentication.
19372
19373 .index bind IP address
19374 .index IP address||binding
19375 .conf interface "string list$**$" unset
19376 This option specifies which interface to bind to when making an outgoing SMTP
19377 call. The variables \$host$\ and \$host@_address$\ refer to the host to which a
19378 connection is about to be made during the expansion of the string. Forced
19379 expansion failure, or an empty string result causes the option to be ignored.
19380 Otherwise, after expansion,
19381 the string must be a list of IP addresses, colon-separated by default, but the
19382 separator can be changed in the usual way.
19383 For example:
19384 .display asis
19385 interface = <; 192.168.123.123 ; 3ffe:ffff:836f::fe86:a061
19386 .endd
19387 The first interface of the correct type (IPv4 or IPv6) is used for the outgoing
19388 connection. If none of them are the correct type, the option is ignored. If
19389 \interface\ is not set, or is ignored, the system's IP functions choose which
19390 interface to use if the host has more than one.
19391
19392 .conf keepalive boolean true
19393 .index keepalive||on outgoing connection
19394 This option controls the setting of \\SO@_KEEPALIVE\\ on outgoing TCP/IP socket
19395 connections. When set, it causes the kernel to probe idle connections
19396 periodically, by sending packets with `old' sequence numbers. The other end of
19397 the connection should send a acknowledgement if the connection is still okay or
19398 a reset if the connection has been aborted. The reason for doing this is that
19399 it has the beneficial effect of freeing up certain types of connection that can
19400 get stuck when the remote host is disconnected without tidying up the TCP/IP
19401 call properly. The keepalive mechanism takes several hours to detect
19402 unreachable hosts.
19403
19404 .conf max@_rcpt integer 100
19405 .index \\RCPT\\||maximum number of outgoing
19406 This option limits the number of \\RCPT\\ commands that are sent in a single
19407 SMTP message transaction. Each set of addresses is treated independently, and
19408 so can cause parallel connections to the same host if \remote@_max@_parallel\
19409 permits this.
19410
19411 .conf multi@_domain boolean true
19412 When this option is set, the \%smtp%\ transport can handle a number of addresses
19413 containing a mixture of different domains provided they all resolve to the same
19414 list of hosts. Turning the option off restricts the transport to handling only
19415 one domain at a time. This is useful if you want to use \$domain$\ in an
19416 expansion for the transport, because it is set only when there is a single
19417 domain involved in a remote delivery.
19418
19419 .conf port string$**$ "see below"
19420 .index port||sending TCP/IP
19421 .index TCP/IP||setting outgoing port
19422 This option specifies the TCP/IP port on the server to which Exim connects. If
19423 it begins with a digit it is taken as a port number; otherwise it is looked up
19424 using \*getservbyname()*\. The default value is normally `smtp', but if
19425 \protocol\ is set to `lmtp', the default is `lmtp'.
19426 If the expansion fails, or if a port number cannot be found, delivery is
19427 deferred.
19428
19429
19430 .conf protocol string "smtp"
19431 .index LMTP||over TCP/IP
19432 If this option is set to `lmtp' instead of `smtp', the default value for the
19433 \port\ option changes to `lmtp', and the transport operates the LMTP protocol
19434 (RFC 2033) instead of SMTP. This protocol is sometimes used for local
19435 deliveries into closed message stores. Exim also has support for running LMTP
19436 over a pipe to a local process -- see chapter ~~CHAPLMTP.
19437
19438 .conf retry@_include@_ip@_address boolean true
19439 Exim normally includes both the host name and the IP address in the key it
19440 constructs for indexing retry data after a temporary delivery failure. This
19441 means that when one of several IP addresses for a host is failing, it gets
19442 tried periodically (controlled by the retry rules), but use of the other IP
19443 addresses is not affected.
19444
19445 However, in some dialup environments hosts are assigned a different IP address
19446 each time they connect. In this situation the use of the IP address as part of
19447 the retry key leads to undesirable behaviour. Setting this option false causes
19448 Exim to use only the host name. This should normally be done on a separate
19449 instance of the \%smtp%\ transport, set up specially to handle the dialup hosts.
19450
19451 .conf serialize@_hosts "host list$**$" unset
19452 .index serializing connections
19453 .index host||serializing connections
19454 Because Exim operates in a distributed manner, if several messages for the same
19455 host arrive at around the same time, more than one simultaneous connection to
19456 the remote host can occur. This is not usually a problem except when there is a
19457 slow link between the hosts. In that situation it may be helpful to restrict
19458 Exim to one connection at a time. This can be done by setting
19459 \serialize@_hosts\ to match the relevant hosts.
19460
19461 .index hints database||serializing deliveries to a host
19462 Exim implements serialization by means of a hints database in which a record is
19463 written whenever a process connects to one of the restricted hosts. The record
19464 is deleted when the connection is completed. Obviously there is scope for
19465 records to get left lying around if there is a system or program crash. To
19466 guard against this, Exim ignores any records that are more than six hours old.
19467
19468 If you set up this kind of serialization, you should also arrange to delete the
19469 relevant hints database whenever your system reboots. The names of the files
19470 start with \(misc)\ and they are kept in the \(spool/db)\ directory. There
19471 may be one or two files, depending on the type of DBM in use. The same files
19472 are used for ETRN serialization.
19473
19474 .conf size@_addition integer 1024
19475 .index SMTP||\\SIZE\\
19476 .index message||size issue for transport filter
19477 .index size||of message
19478 .index transport||filter
19479 .index filter||transport filter
19480 If a remote SMTP server indicates that it supports the \\SIZE\\ option of the
19481 \\MAIL\\ command, Exim uses this to pass over the message size at the start of
19482 an SMTP transaction. It adds the value of \size@_addition\ to the value it
19483 sends, to allow for headers and other text that may be added during delivery by
19484 configuration options or in a transport filter. It may be necessary to increase
19485 this if a lot of text is added to messages.
19486
19487 Alternatively, if the value of \size@_addition\ is set negative, it disables
19488 the use of the \\SIZE\\ option altogether.
19489
19490 .conf tls@_certificate string$**$ unset
19491 .index TLS||client certificate, location of
19492 .index certificate||for client, location of
19493 The value of this option must be the absolute path to a file which contains the
19494 client's certificate, for use when sending a message over an encrypted
19495 connection. The values of \$host$\ and \$host@_address$\ are set to the name
19496 and address of the server during the expansion. See chapter ~~CHAPTLS for
19497 details of TLS.
19498
19499 \**Note**\: This option must be set if you want Exim to use TLS when sending
19500 messages as a client. The global option of the same name specifies the
19501 certificate for Exim as a server; it is not automatically assumed that the same
19502 certificate should be used when Exim is operating as a client.
19503
19504 .conf tls@_crl string$**$ unset
19505 .index TLS||client certificate revocation list
19506 .index certificate||revocation list for client
19507 This option specifies a certificate revocation list. The expanded value must
19508 be the name of a file that contains a CRL in PEM format.
19509
19510 .conf tls@_privatekey string$**$ unset
19511 .index TLS||client private key, location of
19512 The value of this option must be the absolute path to a file which contains the
19513 client's private key, for use when sending a message over an encrypted
19514 connection. The values of \$host$\ and \$host@_address$\ are set to the name
19515 and address of the server during the expansion.
19516 If this option is unset, the private key is assumed to be in the same file as
19517 the certificate.
19518 See chapter ~~CHAPTLS for details of TLS.
19519
19520 .conf tls@_require@_ciphers string$**$ unset
19521 .index TLS||requiring specific ciphers
19522 .index cipher||requiring specific
19523 The value of this option must be a list of permitted cipher suites, for use
19524 when setting up an outgoing encrypted connection. (There is a global option of
19525 the same name for controlling incoming connections.) The values of \$host$\ and
19526 \$host@_address$\ are set to the name and address of the server during the
19527 expansion. See chapter ~~CHAPTLS for details of TLS; note that this option is
19528 used in different ways by OpenSSL and GnuTLS (see sections ~~SECTreqciphssl and 
19529 ~~SECTreqciphgnu).
19530 .em
19531 For GnuTLS, the order of the ciphers is a preference order.
19532 .nem
19533
19534 .conf tls@_tempfail@_tryclear boolean true
19535 When the server host is not in \hosts@_require@_tls\, and there is a problem in
19536 setting up a TLS session, this option determines whether or not Exim should try
19537 to deliver the message unencrypted. If it is set false, delivery to the
19538 current host is deferred; if there are other hosts, they are tried. If this
19539 option is set true, Exim attempts to deliver unencrypted after a 4\*xx*\
19540 response to \\STARTTLS\\. Also, if \\STARTTLS\\ is accepted, but the subsequent
19541 TLS negotiation fails, Exim closes the current connection (because it is in an
19542 unknown state), opens a new one to the same host, and then tries the delivery
19543 in clear.
19544
19545 .conf tls@_verify@_certificates string$**$ unset
19546 .index TLS||server certificate verification
19547 .index certificate||verification of server
19548 The value of this option must be the absolute path to a file containing
19549 permitted server certificates, for use when setting up an encrypted connection.
19550 Alternatively, if you are using OpenSSL, you can set
19551 \tls@_verify@_certificates\ to the name of a directory containing certificate
19552 files. This does not work with GnuTLS; the option must be set to the name of a
19553 single file if you are using GnuTLS. The values of \$host$\ and
19554 \$host@_address$\ are set to the name and address of the server during the
19555 expansion of this option. See chapter ~~CHAPTLS for details of TLS.
19556
19557 .endconf
19558
19559
19560 .section How the limits for the number of hosts to try are used
19561 .rset SECTvalhosmax "~~chapter.~~section"
19562 .index host||maximum number to try
19563 .index limit||hosts, maximum number tried
19564 .em
19565 There are two options that are concerned with the number of hosts that are 
19566 tried when an SMTP delivery takes place. They are \hosts@_max@_try\ and 
19567 \hosts@_max@_try@_hardlimit\.
19568 .nem
19569
19570 The \hosts@_max@_try\ option limits the number of hosts that are tried
19571 for a single delivery. However, despite the term `host' in its name, the option
19572 actually applies to each IP address independently. In other words, a multihomed
19573 host is treated as several independent hosts, just as it is for retrying.
19574
19575 Many of the larger ISPs have multiple MX records which often point to
19576 multihomed hosts. As a result, a list of a dozen or more IP addresses may be
19577 created as a result of routing one of these domains.
19578
19579 Trying every single IP address on such a long list does not seem sensible; if
19580 several at the top of the list fail, it is reasonable to assume there is some
19581 problem that is likely to affect all of them. Roughly speaking, the value of
19582 \hosts@_max@_try\ is the maximum number that are tried before deferring the
19583 delivery. However, the logic cannot be quite that simple.
19584
19585 Firstly, IP addresses that are skipped because their retry times have not
19586 arrived do not count, and in addition, addresses that are past their retry
19587 limits are also not counted, even when they are tried. This means that when
19588 some IP addresses are past their retry limits, more than the value of
19589 \hosts@_max@_retry\ may be tried. The reason for this behaviour is to ensure
19590 that all IP addresses are considered before timing out an email address (but 
19591 see below for an exception).
19592
19593 Secondly, when the \hosts@_max@_try\ limit is reached, Exim looks down the host
19594 list to see if there is a subsequent host with a different (higher valued) MX.
19595 If there is, that host is considered next, and the current IP address is used
19596 but not counted. This behaviour helps in the case of a domain with a retry rule
19597 that hardly ever delays any hosts, as is now explained:
19598
19599 Consider the case of a long list of hosts with one MX value, and a few with a
19600 higher MX value. If \hosts@_max@_try\ is small (the default is 5) only a few
19601 hosts at the top of the list are tried at first. With the default retry rule,
19602 which specifies increasing retry times, the higher MX hosts are eventually
19603 tried when those at the top of the list are skipped because they have not
19604 reached their retry times.
19605
19606 However, it is common practice to put a fixed short retry time on domains for
19607 large ISPs, on the grounds that their servers are rarely down for very long.
19608 Unfortunately, these are exactly the domains that tend to resolve to long lists
19609 of hosts. The short retry time means that the lowest MX hosts are tried every
19610 time. The attempts may be in a different order because of random sorting, but
19611 without the special MX check, the higher MX hosts would never be tried
19612 .em
19613 until all the lower MX hosts had timed out (which might be several days),
19614 because there are always some lower MX hosts that have reached their retry
19615 times. With the special check, Exim considers at least one IP address from each
19616 MX value at every delivery attempt, even if the \hosts@_max@_try\ limit has
19617 already been reached.
19618
19619 The above logic means that \hosts@_max@_try\ is not a hard limit, and in
19620 particular, Exim normally eventually tries all the IP addresses before timing
19621 out an email address. When \hosts@_max@_try\ was implemented, this seemed a 
19622 reasonable thing to do. Recently, however, some lunatic DNS configurations have 
19623 been set up with hundreds of IP addresses for some domains. It can 
19624 take a very long time indeed for an address to time out in these cases.
19625
19626 The \hosts@_max@_try@_hardlimit\ option was added to help with this problem.
19627 Exim never tries more than this number of IP addresses; if it hits this limit
19628 and they are all timed out, the email address is bounced, even though not all
19629 possible IP addresses have been tried.
19630 .nem
19631
19632
19633
19634
19635 .
19636 .
19637 .
19638 .
19639 . ============================================================================
19640 .chapter Address rewriting
19641 .set runningfoot "address rewriting"
19642 .rset CHAPrewrite ~~chapter
19643 .index rewriting||addresses
19644 There are some circumstances in which Exim automatically rewrites domains in
19645 addresses. The two most common are when an address is given without a domain
19646 (referred to as an `unqualified address') or when an address contains an
19647 abbreviated domain that is expanded by DNS lookup.
19648
19649 Unqualified envelope addresses are accepted only for locally submitted
19650 messages, or messages from hosts that match \sender@_unqualified@_hosts\ or
19651 \recipient@_unqualified@_hosts\, respectively. Unqualified addresses in header
19652 lines are qualified if they are in locally submitted messages, or messages from
19653 hosts that are permitted to send unqualified envelope addresses. Otherwise,
19654 unqualified addresses in header lines are neither qualified nor rewritten.
19655
19656 One situation in which Exim does $it{not} automatically rewrite a domain is
19657 when it is the name of a CNAME record in the DNS. The older RFCs suggest that
19658 such a domain should be rewritten using the `canonical' name, and some MTAs do
19659 this. The new RFCs do not contain this suggestion.
19660  
19661 .section Explicitly configured address rewriting
19662 This chapter describes the rewriting rules that can be used in the
19663 main rewrite section of the configuration file, and also in the generic
19664 \headers@_rewrite\ option that can be set on any transport.
19665
19666 Some people believe that configured address rewriting is a Mortal Sin.
19667 Others believe that life is not possible without it. Exim provides the
19668 facility; you do not have to use it.
19669
19670 The main rewriting rules that appear in the `rewrite' section of the
19671 configuration file are applied to addresses in incoming messages, both envelope
19672 addresses and addresses in header lines. Each rule specifies the types of
19673 address to which it applies.
19674
19675 Rewriting of addresses in header lines applies only to those headers that
19676 were received with the message, and, in the case of transport rewriting, those
19677 that were added by a system filter. That is, it applies only to those headers
19678 that are common to all copies of the message. Header lines that are added by
19679 individual routers or transports (and which are therefore specific to
19680 individual recipient addresses) are not rewritten.
19681
19682 In general, rewriting addresses from your own system or domain has some
19683 legitimacy. Rewriting other addresses should be done only with great care and
19684 in special circumstances. The author of Exim believes that rewriting should be
19685 used sparingly, and mainly for `regularizing' addresses in your own domains.
19686 Although it can sometimes be used as a routing tool, this is very strongly
19687 discouraged.
19688
19689 There are two commonly encountered circumstances where rewriting is used, as
19690 illustrated by these examples:
19691 .numberpars $.
19692 The company whose domain is \*hitch.fict.example*\ has a number of hosts that
19693 exchange mail with each other behind a firewall, but there is only a single
19694 gateway to the outer world. The gateway rewrites \*@*.hitch.fict.example*\ as
19695 \*hitch.fict.example*\ when sending mail off-site.
19696 .nextp
19697 A host rewrites the local parts of its own users so that, for example,
19698 \*fp42@@hitch.fict.example*\ becomes \*Ford.Prefect@@hitch.fict.example*\.
19699 .endp
19700
19701 .section When does rewriting happen?
19702 .index rewriting||timing of
19703 .index ~~ACL||rewriting addresses in
19704 Configured address rewriting can take place at several different stages of a
19705 message's processing.
19706
19707 At the start of an ACL for \\MAIL\\, the sender address may have been rewritten
19708 by a special SMTP-time rewrite rule (see section ~~SECTrewriteS), but no
19709 ordinary rewrite rules have yet been applied. If, however, the sender address
19710 is verified in the ACL, it is rewritten before verification, and remains
19711 rewritten thereafter. The subsequent value of \$sender@_address$\ is the
19712 rewritten address. This also applies if sender verification happens in a
19713 \\RCPT\\ ACL. Otherwise, when the sender address is not verified, it is
19714 rewritten as soon as a message's header lines have been received.
19715
19716 Similarly, at the start of an ACL for \\RCPT\\, the current recipient's address
19717 may have been rewritten by a special SMTP-time rewrite rule, but no ordinary
19718 rewrite rules have yet been applied to it. However, the behaviour is different
19719 from the sender address when a recipient is verified. The address is rewritten
19720 for the verification, but the rewriting is not remembered at this stage. The
19721 value of \$local@_part$\ and \$domain$\ after verification are always the same
19722 as they were before (that is, they contain the unrewritten -- except for
19723 SMTP-time rewriting -- address).
19724
19725 Once a message's header lines have been received, all the envelope recipient
19726 addresses are permanently rewritten, and rewriting is also applied to the
19727 addresses in the header lines (if configured).
19728 .index \*local@_scan()*\ function||address rewriting, timing of
19729 Thus, all the rewriting is completed before the \\DATA\\ ACL and
19730 \*local@_scan()*\ functions are run.
19731
19732 When an address is being routed, either for delivery or for verification,
19733 rewriting is applied immediately to child addresses that are generated by
19734 redirection, unless \no@_rewrite\ is set on the router.
19735
19736 .index envelope sender, rewriting
19737 .index rewriting||at transport time
19738 At transport time, additional rewriting of addresses in header lines can be
19739 specified by setting the generic \headers@_rewrite\ option on a transport. This
19740 option contains rules that are identical in form to those in the rewrite
19741 section of the configuration file. In addition, the outgoing envelope sender
19742 can be rewritten by means of the \return@_path\ transport option. However, it
19743 is not possible to rewrite envelope recipients at transport time.
19744
19745
19746
19747 .section Testing the rewriting rules that apply on input
19748 .index rewriting||testing
19749 .index testing||rewriting
19750 Exim's input rewriting configuration appears in a part of the run time
19751 configuration file headed by `begin rewrite'. It can be tested by the \-brw-\
19752 command line option. This takes an address (which can be a full RFC 2822
19753 address) as its argument. The output is a list of how the address would be
19754 transformed by the rewriting rules for each of the different places it might
19755 appear in an incoming message, that is, for each different header and for the
19756 envelope sender and recipient fields. For example,
19757 .display asis
19758 exim -brw ph10@exim.workshop.example
19759 .endd
19760 might produce the output
19761 .display asis
19762   sender: Philip.Hazel@exim.workshop.example
19763     from: Philip.Hazel@exim.workshop.example
19764       to: ph10@exim.workshop.example
19765       cc: ph10@exim.workshop.example
19766      bcc: ph10@exim.workshop.example
19767 reply-to: Philip.Hazel@exim.workshop.example
19768 env-from: Philip.Hazel@exim.workshop.example
19769   env-to: ph10@exim.workshop.example
19770 .endd
19771 which shows that rewriting has been set up for that address when used in any of
19772 the source fields, but not when it appears as a recipient address. At the
19773 present time, there is no equivalent way of testing rewriting rules that are
19774 set for a particular transport.
19775
19776 .section Rewriting rules
19777 .index rewriting||rules
19778 The rewrite section of the configuration file consists of lines of rewriting
19779 rules in the form
19780 .display
19781 <<source pattern>>  <<replacement>>  <<flags>>
19782 .endd
19783 Rewriting rules that are specified for the \headers@_rewrite\ generic transport
19784 option are given as a colon-separated list. Each item in the list takes the
19785 same form as a line in the main rewriting configuration
19786 (except that any colons must be doubled, of course).
19787
19788 The formats of source patterns and replacement strings are described below.
19789 Each is terminated by white space, unless enclosed in double quotes, in which
19790 case normal quoting conventions apply inside the quotes. The flags are single
19791 characters which may appear in any order. Spaces and tabs between them are
19792 ignored.
19793
19794 For each address that could potentially be rewritten, the rules are scanned in
19795 order, and replacements for the address from earlier rules can themselves be
19796 replaced by later rules (but see the `q' and `R' flags).
19797
19798 The order in which addresses are rewritten is undefined, may change between
19799 releases, and must not be relied on, with one exception: when a message is
19800 received, the envelope sender is always rewritten first, before any header
19801 lines are rewritten. For example, the replacement string for a rewrite of an
19802 address in ::To:: must not assume that the message's address in ::From:: has (or
19803 has not) already been rewritten. However, a rewrite of ::From:: may assume that
19804 the envelope sender has already been rewritten.
19805
19806 The variables \$local@_part$\ and \$domain$\ can be used in the replacement
19807 string to refer to the address that is being rewritten. Note that lookup-driven
19808 rewriting can be done by a rule of the form
19809 .display asis
19810 *@*   ${lookup ...
19811 .endd
19812 where the lookup key uses \$1$\ and \$2$\ or \$local@_part$\ and \$domain$\ to
19813 refer to the address that is being rewritten.
19814
19815 .section Rewriting patterns
19816 .index rewriting||patterns
19817 .index address list||in a rewriting pattern
19818 The source pattern in a rewriting rule is any item which may appear in an
19819 address list (see section ~~SECTaddresslist). It is in fact processed as a
19820 single-item address list, which means that it is expanded before being tested
19821 against the address.
19822
19823 Domains in patterns should be given in lower case. Local parts in patterns are
19824 case-sensitive. If you want to do case-insensitive matching of local parts, you
19825 can use a regular expression that starts with \"^(?i)"\.
19826
19827 .index numerical variables (\$1$\, \$2$\, etc)||in rewriting rules
19828 After matching, the numerical variables \$1$\, \$2$\, etc. may be set,
19829 depending on the type of match which occurred. These can be used in the
19830 replacement string to insert portions of the incoming address. \$0$\ always
19831 refers to the complete incoming address. When a regular expression is used, the
19832 numerical variables are set from its capturing subexpressions. For other types
19833 of pattern they are set as follows:
19834
19835 .numberpars $.
19836 If a local part or domain starts with an asterisk, the numerical variables
19837 refer to the character strings matched by asterisks, with \$1$\ associated with
19838 the first asterisk, and \$2$\ with the second, if present. For example, if the
19839 pattern
19840 .display
19841 *queen@@*.fict.example
19842 .endd
19843 is matched against the address \*hearts-queen@@wonderland.fict.example*\ then
19844 .display asis
19845 $0 = hearts-queen@wonderland.fict.example
19846 $1 = hearts-
19847 $2 = wonderland
19848 .endd
19849 Note that if the local part does not start with an asterisk, but the domain
19850 does, it is \$1$\ that contains the wild part of the domain.
19851 .nextp
19852 If the domain part of the pattern is a partial lookup, the wild and fixed parts
19853 of the domain are placed in the next available numerical variables. Suppose,
19854 for example, that the address \*foo@@bar.baz.example*\ is processed by a
19855 rewriting rule of the form
19856 .display
19857 *@@partial-dbm;/some/dbm/file    <<replacement string>>
19858 .endd
19859 and the key in the file that matches the domain is \"*.baz.example"\. Then
19860 .display asis
19861 $1 = foo
19862 $2 = bar
19863 $3 = baz.example
19864 .endd
19865 If the address \*foo@@baz.example*\ is looked up, this matches the same
19866 wildcard file entry, and in this case \$2$\ is set to the empty string, but
19867 \$3$\ is still set to \*baz.example*\. If a non-wild key is matched in a
19868 partial lookup, \$2$\ is again set to the empty string and \$3$\ is set to the
19869 whole domain. For non-partial domain lookups, no numerical variables are set.
19870 .endp
19871
19872 .section Rewriting replacements
19873 .index rewriting||replacements
19874 If the replacement string for a rule is a single asterisk, addresses that
19875 match the pattern and the flags are $it{not} rewritten, and no subsequent
19876 rewriting rules are scanned. For example,
19877 .display asis
19878 hatta@lookingglass.fict.example  *  f
19879 .endd
19880 specifies that \*hatta@@lookingglass.fict.example*\ is never to be rewritten in
19881 ::From:: headers.
19882
19883 If the replacement string is not a single asterisk, it is expanded, and must
19884 yield a fully qualified address. Within the expansion, the variables
19885 \$local@_part$\ and \$domain$\ refer to the address that is being rewritten.
19886 Any letters they contain retain their original case -- they are not lower
19887 cased. The numerical variables are set up according to the type of pattern that
19888 matched the address, as described above. If the expansion is forced to fail by
19889 the presence of `fail' in a conditional or lookup item, rewriting by the
19890 current rule is abandoned, but subsequent rules may take effect. Any other
19891 expansion failure causes the entire rewriting operation to be abandoned, and an
19892 entry written to the panic log.
19893
19894
19895 .section Rewriting flags
19896 There are three different kinds of flag that may appear on rewriting rules:
19897 .numberpars $.
19898 Flags that specify which headers and envelope addresses to rewrite: E, F, T, b,
19899 c, f, h, r, s, t.
19900 .nextp
19901 A flag that specifies rewriting at SMTP time: S.
19902 .nextp
19903 Flags that control the rewriting process: Q, q, R, w.
19904 .endp
19905 For rules that are part of the \headers@_rewrite\ generic transport option,
19906 E, F, T, and S are not permitted.
19907
19908
19909 .section Flags specifying which headers and envelope addresses to rewrite
19910 .index rewriting||flags
19911 If none of the following flag letters, nor the `S' flag (see section
19912 ~~SECTrewriteS) are present, a main rewriting rule applies to all headers and
19913 to both the sender and recipient fields of the envelope, whereas a
19914 transport-time rewriting rule just applies to all headers. Otherwise, the
19915 rewriting rule is skipped unless the relevant addresses are being processed.
19916 .display
19917 E       $rm{rewrite all envelope fields}
19918 F       $rm{rewrite the envelope From field}
19919 T       $rm{rewrite the envelope To field}
19920 b       $rm{rewrite the ::Bcc:: header}
19921 c       $rm{rewrite the ::Cc:: header}
19922 f       $rm{rewrite the ::From:: header}
19923 h       $rm{rewrite all headers}
19924 r       $rm{rewrite the ::Reply-To:: header}
19925 s       $rm{rewrite the ::Sender:: header}
19926 t       $rm{rewrite the ::To:: header}
19927 .endd
19928 You should be particularly careful about rewriting ::Sender:: headers, and
19929 restrict this to special known cases in your own domains.
19930
19931 .section The SMTP-time rewriting flag
19932 .rset SECTrewriteS "~~chapter.~~section"
19933 .index SMTP||rewriting malformed addresses
19934 .index \\RCPT\\||rewriting argument of
19935 .index \\MAIL\\||rewriting argument of
19936 The rewrite flag `S' specifies a rewrite of incoming envelope addresses at SMTP
19937 time, as soon as an address is received in a \\MAIL\\ or \\RCPT\\ command, and
19938 before any other processing; even before syntax checking. The pattern is
19939 required to be a regular expression, and it is matched against the whole of the
19940 data for the command, including any surrounding angle brackets.
19941
19942 This form of rewrite rule allows for the handling of addresses that are not
19943 compliant with RFCs 2821 and 2822 (for example, `bang paths' in batched SMTP
19944 input). Because the input is not required to be a syntactically valid address,
19945 the variables \$local@_part$\ and \$domain$\ are not available during the
19946 expansion of the replacement string. The result of rewriting replaces the
19947 original address in the \\MAIL\\ or \\RCPT\\ command.
19948
19949 .section Flags controlling the rewriting process
19950 There are four flags which control the way the rewriting process works. These
19951 take effect only when a rule is invoked, that is, when the address is of the
19952 correct type (matches the flags) and matches the pattern:
19953 .numberpars $.
19954 If the `Q' flag is set on a rule, the rewritten address is permitted to be an
19955 unqualified local part. It is qualified with \qualify@_recipient\. In the
19956 absence of `Q' the rewritten address must always include a domain.
19957 .nextp
19958 If the `q' flag is set on a rule, no further rewriting rules are considered,
19959 even if no rewriting actually takes place because of a `fail' in the expansion.
19960 The `q' flag is not effective if the address is of the wrong type (does not
19961 match the flags) or does not match the pattern.
19962 .nextp
19963 The `R' flag causes a successful rewriting rule to be re-applied to the new
19964 address, up to ten times. It can be combined with the `q' flag, to stop
19965 rewriting once it fails to match (after at least one successful rewrite).
19966 .nextp
19967 .index rewriting||whole addresses
19968 When an address in a header is rewritten, the rewriting normally applies only
19969 to the working part of the address, with any comments and RFC 2822 `phrase'
19970 left unchanged. For example, rewriting might change
19971 .display asis
19972 From: Ford Prefect <fp42@restaurant.hitch.fict.example>
19973 .endd
19974 into
19975 .display asis
19976 From: Ford Prefect <prefectf@hitch.fict.example>
19977 .endd
19978 Sometimes there is a need to replace the whole address item, and this can be
19979 done by adding the flag letter `w' to a rule. If this is set on a rule that
19980 causes an address in a header line to be rewritten, the entire address is
19981 replaced, not just the working part. The replacement must be a complete RFC
19982 2822 address, including the angle brackets if necessary. If text outside angle
19983 brackets contains a character whose value is greater than 126 or less than 32
19984 (except for tab), the text is encoded according to RFC 2047.
19985 The character set is taken from \headers@_charset\, which defaults to
19986 ISO-8859-1.
19987
19988 When the `w' flag is set on a rule that causes an envelope address to be
19989 rewritten, all but the working part of the replacement address is discarded.
19990 .endp
19991
19992 .section Rewriting examples
19993 Here is an example of the two common rewriting paradigms:
19994 .display asis
19995 *@*.hitch.fict.example  $1@hitch.fict.example
19996 *@hitch.fict.example    ${lookup{$1}dbm{/etc/realnames}\
19997                      {$value}fail}@hitch.fict.example bctfrF
19998 .endd
19999 Note the use of `fail' in the lookup expansion in the second rule, forcing
20000 the string expansion to fail if the lookup does not succeed. In this context it
20001 has the effect of leaving the original address unchanged, but Exim goes on to
20002 consider subsequent rewriting rules, if any, because the `q' flag is not
20003 present in that rule. An alternative to `fail' would be to supply \$1$\
20004 explicitly, which would cause the rewritten address to be the same as before,
20005 at the cost of a small bit of processing. Not supplying either of these is an
20006 error, since the rewritten address would then contain no local part.
20007
20008 The first example above replaces the domain with a superior, more general
20009 domain. This may not be desirable for certain local parts. If the rule
20010 .display asis
20011 root@*.hitch.fict.example  *
20012 .endd
20013 were inserted before the first rule, rewriting would be suppressed for the
20014 local part \*root*\ at any domain ending in \*hitch.fict.example*\.
20015
20016 Rewriting can be made conditional on a number of tests, by making use of
20017 \${if$\ in the expansion item. For example, to apply a rewriting rule only to
20018 messages that originate outside the local host:
20019 .display asis
20020 *@*.hitch.fict.example  "${if !eq {$sender_host_address}{}\
20021                          {$1@hitch.fict.example}fail}"
20022 .endd
20023 The replacement string is quoted in this example because it contains white
20024 space.
20025
20026 .index rewriting||bang paths
20027 .index bang paths||rewriting
20028 Exim does not handle addresses in the form of `bang paths'. If it sees such an
20029 address it treats it as an unqualified local part which it qualifies with the
20030 local qualification domain (if the source of the message is local or if the
20031 remote host is permitted to send unqualified addresses). Rewriting can
20032 sometimes be used to handle simple bang paths with a fixed number of
20033 components. For example, the rule
20034 .display asis
20035 \N^([^!]+)!(.*)@your.domain.example$\N   $2@$1
20036 .endd
20037 rewrites a two-component bang path \*host.name!user*\ as the domain address
20038 \*user@@host.name*\. However, there is a security implication in using this as
20039 a global rewriting rule for envelope addresses. It can provide a backdoor
20040 method for using your system as a relay, because the incoming addresses appear
20041 to be local. If the bang path addresses are received via SMTP, it is safer to
20042 use the `S' flag to rewrite them as they are received, so that relay checking
20043 can be done on the rewritten addresses.
20044
20045
20046
20047
20048
20049 .
20050 .
20051 .
20052 .
20053 . ============================================================================
20054 .chapter Retry configuration
20055 .set runningfoot "retry configuration"
20056 .rset CHAPretry ~~chapter
20057 .index retry||configuration, description of
20058 .index configuration file||retry section
20059 The `retry' section of the run time configuration file contains a list of retry
20060 rules which control how often Exim tries to deliver messages that cannot be
20061 delivered at the first attempt. If there are no retry rules, temporary errors
20062 are treated as permanent. The \-brt-\ command line option can be used to test
20063 which retry rule will be used for a given address or domain.
20064
20065 The most common cause of retries is temporary failure to deliver to a remote
20066 host because the host is down, or inaccessible because of a network problem.
20067 Exim's retry processing in this case is applied on a per-host (strictly, per IP
20068 address) basis, not on a per-message basis. Thus, if one message has recently
20069 been delayed, delivery of a new message to the same host is not immediately
20070 tried, but waits for the host's retry time to arrive. If the \retry@_defer\ log
20071 selector is set, the message
20072 .index retry||time not reached
20073 `retry time not reached' is written to the main log whenever a delivery is
20074 skipped for this reason. Section ~~SECToutSMTPerr contains more details of the
20075 handling of errors during remote deliveries.
20076
20077 Retry processing applies to routing as well as to delivering, except as covered
20078 in the next paragraph. The retry rules do not distinguish between these
20079 actions. It is not possible, for example, to specify different behaviour for
20080 failures to route the domain \*snark.fict.example*\ and failures to deliver to
20081 the host \*snark.fict.example*\. I didn't think anyone would ever need this
20082 added complication, so did not implement it. However, although they share the
20083 same retry rule, the actual retry times for routing and transporting a given
20084 domain are maintained independently.
20085
20086 When a delivery is not part of a queue run (typically an immediate delivery on
20087 receipt of a message), the routers are always run, and local deliveries are
20088 always attempted, even if retry times are set for them. This makes for better
20089 behaviour if one particular message is causing problems (for example, causing
20090 quota overflow, or provoking an error in a filter file). If such a delivery
20091 suffers a temporary failure, the retry data is updated as normal, and
20092 subsequent delivery attempts from queue runs occur only when the retry time for
20093 the local address is reached.
20094
20095
20096 .section Retry rules
20097 .index retry||rules
20098 .em
20099 Each retry rule occupies one line and consists of three or four parts,
20100 separated by white space: a pattern, an error name, an optional list of sender
20101 addresses, and a list of retry parameters. The pattern and sender lists must be
20102 enclosed in double quotes if they contain white space. The rules are searched in
20103 order until one is found where the pattern, error name, and sender list (if
20104 present) match the failing host or address, the error that occurred, and the
20105 message's sender, respectively.
20106 .nem
20107
20108 The pattern is any single item that may appear in an address list (see section
20109 ~~SECTaddresslist). It is in fact processed as a one-item address list, which
20110 means that it is expanded before being tested against the address that has
20111 been delayed. Address list processing treats a plain domain name as if it were
20112 preceded by `*@@', which makes it possible for many retry rules to start with
20113 just a domain. For example,
20114 .display asis
20115 lookingglass.fict.example        *  F,24h,30m;
20116 .endd
20117 provides a rule for any address in the \*lookingglass.fict.example*\ domain,
20118 whereas
20119 .display asis
20120 alice@lookingglass.fict.example  *  F,24h,30m;
20121 .endd
20122 applies only to temporary failures involving the local part \alice\.
20123 In practice, almost all rules start with a domain name pattern without a local
20124 part.
20125
20126 .index regular expressions||in retry rules
20127 \**Warning**\: If you use a regular expression in a routing rule pattern, it
20128 must match a complete address, not just a domain, because that is how regular
20129 expressions work in address lists.
20130 .display
20131 ^@\Nxyz@\d+@\.abc@\.example@$@\N        *  G,1h,10m,2     \Wrong\
20132 ^@\N[^@@]+@@xyz@\d+@\.abc@\.example@$@\N  *  G,1h,10m,2     \Right\
20133 .endd
20134
20135
20136 .section Choosing which retry rule to use
20137 When Exim is looking for a retry rule after a routing attempt has failed (for
20138 example, after a DNS timeout), each line in the retry configuration is tested
20139 against the complete address only if \retry__use@_local@_part\ is set for the
20140 router. Otherwise, only the domain is used, except when matching against a
20141 regular expression, when the local part of the address is replaced with `*'. A
20142 domain on its own can match a domain pattern, or a pattern that starts with
20143 `*@@'. By default, \retry@_use@_local@_part\ is true for routers where
20144 \check@_local@_user\ is true, and false for other routers.
20145
20146 Similarly, when Exim is looking for a retry rule after a local delivery has
20147 failed (for example, after a mailbox full error), each line in the retry
20148 configuration is tested against the complete address only if
20149 \retry@_use@_local@_part\ is set for the transport (it defaults true for all
20150 local transports).
20151
20152 When Exim is looking for a retry rule after a remote delivery attempt has
20153 failed, what happens depends on the type of failure. After a 4\*xx*\ SMTP
20154 response for a recipient address, the whole address is used when searching the
20155 retry rules. The rule that is found is used to create a retry time for the
20156 failing address.
20157
20158 For a temporary error that is not related to an individual address,
20159 (for example, a connection timeout), each line in the retry configuration is
20160 checked twice. First, the name of the remote host is used as a domain name
20161 (preceded by `*@@' when matching a regular expression). If this does not match
20162 the line, the domain from the email address is tried in a similar fashion. For
20163 example, suppose the MX records for \*a.b.c.example*\ are
20164 .display asis
20165 a.b.c.example  MX  5  x.y.z.example
20166                MX  6  p.q.r.example
20167                MX  7  m.n.o.example
20168 .endd
20169 and the retry rules are
20170 .display asis
20171 p.q.r.example    *      F,24h,30m;
20172 a.b.c.example    *      F,4d,45m;
20173 .endd
20174 and a delivery to the host \*x.y.z.example*\ fails. The first rule matches
20175 neither the host nor the domain, so Exim looks at the second rule. This does
20176 not match the host, but it does match the domain, so it is used to calculate
20177 the retry time for the host \*x.y.z.example*\. Meanwhile, Exim tries to deliver
20178 to \*p.q.r.example*\. If this fails, the first retry rule is used, because it
20179 matches the host.
20180
20181 In other words, failures to deliver to host \*p.q.r.example*\ use the first
20182 rule to determine retry times, but for all the other hosts for the domain
20183 \*a.b.c.example*\, the second rule is used. The second rule is also used if
20184 routing to \*a.b.c.example*\ suffers a temporary failure.
20185
20186 .section Retry rules for specific errors
20187 .index retry||specific errors, specifying
20188 The second field in a retry rule is the name of a particular error, or an
20189 asterisk, which matches any error. The errors that can be tested for are:
20190 .em
20191
20192 .push
20193 .indent 2em
20194 .tempindent 0
20195 \auth@_failed\: Authentication failed when trying to send to a host in the
20196 \hosts@_require@_auth\ list in an \%smtp%\ transport.
20197
20198 .tempindent 0
20199 \rcpt@_4xx\: A 4\*xx*\ error was received for an outgoing \\RCPT\\ command.
20200 Either the first or both of the x's can be given as specific digits, for
20201 example: \"rcpt@_45x"\ or \"rcpt@_436"\. For example, to recognize 452 errors
20202 given to \\RCPT\\ commands by a particular host, and have retries every ten 
20203 minutes and a one-hour timeout, you could set up a retry rule of this form:
20204 .display asis
20205 the.host.name  rcpt_452   F,1h,10m
20206 .endd
20207 These errors apply to both outgoing SMTP (the \%smtp%\ transport) and outgoing
20208 LMTP (either the \%lmtp%\ transport, or the \%smtp%\ transport in LMTP mode).
20209 Note, however, that they apply only to responses to \\RCPT\\ commands.
20210
20211 .tempindent 0
20212 \refused@_MX\: A connection to a host obtained from an MX record was refused.
20213
20214 .tempindent 0
20215 \refused@_A\: A connection to a host not obtained from an MX record was
20216 refused.
20217
20218 .tempindent 0
20219 \refused\: A connection was refused.
20220
20221 .tempindent 0
20222 \timeout@_connect@_MX\: A connection attempt to a host obtained from an MX
20223 record timed out.
20224
20225 .tempindent 0
20226 \timeout@_connect@_A\: A connection attempt to a host not obtained from an MX
20227 record timed out.
20228
20229 .tempindent 0
20230 \timeout@_connect\: A connection attempt timed out.
20231
20232 .tempindent 0
20233 \timeout@_MX\: There was a timeout while connecting or during an SMTP session 
20234 with a host obtained from an MX record.
20235
20236 .tempindent 0
20237 \timeout@_A\: There was a timeout while connecting or during an SMTP session 
20238 with a host not obtained from an MX record.
20239
20240 .tempindent 0
20241 \timeout\: There was a timeout while connecting or during an SMTP session.
20242
20243 .tempindent 0
20244 \quota\: A mailbox quota was exceeded in a local delivery by the
20245 \%appendfile%\ transport.
20246
20247 .index quota||error testing in retry rule
20248 .index retry||quota error testing
20249 .tempindent 0
20250 \quota@_\<<time>>: A mailbox quota was exceeded in a local delivery by 
20251 the \%appendfile%\ transport, and the mailbox has not been accessed for
20252 <<time>>. For example, \*quota@_4d*\ applies to a quota error when the mailbox
20253 has not been accessed for four days.
20254
20255 .pop
20256
20257
20258 .index mailbox||time of last read
20259 The idea of \quota@_\<<time>> is to make it possible to have shorter timeouts
20260 when the mailbox is full and is not being read by its owner. Ideally, it should
20261 be based on the last time that the user accessed the mailbox. However, it is
20262 not always possible to determine this. Exim uses the following heuristic rules:
20263 .numberpars $.
20264 If the mailbox is a single file, the time of last access (the `atime') is used.
20265 As no new messages are being delivered (because the mailbox is over quota), 
20266 Exim does not access the file, so this is the time of last user access.
20267 .nextp
20268 .index maildir format||time of last read
20269 For a maildir delivery, the time of last modification of the \(new)\
20270 subdirectory is used. As the mailbox is over quota, no new files are created in
20271 the \(new)\ subdirectory, because no new messages are being delivered. Any
20272 change to the \(new)\ subdirectory is therefore assumed to be the result of an
20273 MUA moving a new message to the \(cur)\ directory when it is first read. The
20274 time that is used is therefore the last time that the user read a new message.
20275 .nextp
20276 For other kinds of multi-file mailbox, the time of last access cannot be
20277 obtained, so a retry rule that uses this type of error field is never matched.
20278 .endp
20279 .nem
20280 The quota errors apply both to system-enforced quotas and to Exim's own quota
20281 mechanism in the \%appendfile%\ transport. The \*quota*\ error also applies
20282 when a local delivery is deferred because a partition is full (the \\ENOSPC\\
20283 error).
20284
20285
20286 .em
20287 .section Retry rules for specified senders
20288 .index retry||rules, sender-specific
20289 You can specify retry rules that apply only when the failing message has a
20290 specific sender. In particular, this can be used to define retry rules that
20291 apply only to bounce messages. The third item in a retry rule can be of this
20292 form:
20293 .display 
20294 senders=<<address list>>
20295 .endd
20296 The retry timings themselves are then the fourth item. For example:
20297 .display asis
20298 *   *   senders=:   F,1h,30m
20299 .endd
20300 matches all temporary errors for bounce messages sent to any host. If the
20301 address list contains white space, it must be enclosed in quotes. For example:
20302 .display
20303 a.domain  timeout  senders="x@b.dom : y@c.dom"  G,8h,10m,1.5
20304 .endd
20305 When testing retry rules using \-brt-\, you can supply a sender using the \-f-\
20306 command line option, like this:
20307 .display asis
20308 exim -f "" -brt user@dom.ain
20309 .endd
20310 If you do not set \-f-\ with \-brt-\, a retry rule that contains a senders list
20311 is never matched.
20312 .nem
20313
20314
20315
20316 .section Retry parameters
20317 .index retry||parameters in rules
20318 The third 
20319 .em
20320 (or fourth, if a senders list is present)
20321 .nem
20322 field in a retry rule is a sequence of retry parameter sets, separated by
20323 semicolons. Each set consists of
20324 .display
20325 <<letter>>,<<cutoff time>>,<<arguments>>
20326 .endd
20327 The letter identifies the algorithm for computing a new retry time; the cutoff
20328 time is the time beyond which this algorithm no longer applies, and the
20329 arguments vary the algorithm's action. The cutoff time is measured from the
20330 time that the first failure for the domain (combined with the local part if
20331 relevant) was detected, not from the time the message was received.
20332 .index retry||algorithms
20333 The available algorithms are:
20334 .numberpars $.
20335 \*F*\: retry at fixed intervals. There is a single time parameter specifying
20336 the interval.
20337 .nextp
20338 \*G*\: retry at geometrically increasing intervals. The first argument
20339 specifies a starting value for the interval, and the second a multiplier, which
20340 is used to increase the size of the interval at each retry.
20341 .endp
20342 When computing the next retry time, the algorithm definitions are scanned in
20343 order until one whose cutoff time has not yet passed is reached. This is then
20344 used to compute a new retry time that is later than the current time. In the
20345 case of fixed interval retries, this simply means adding the interval to the
20346 current time. For geometrically increasing intervals, retry intervals are
20347 computed from the rule's parameters until one that is greater than the previous
20348 interval is found. The main configuration variable
20349 .index limit||retry interval
20350 .index retry||interval, maximum
20351 .index \retry@_interval@_max\
20352 \retry@_interval@_max\ limits the maximum interval between retries.
20353
20354 A single remote domain may have a number of hosts associated with it, and each
20355 host may have more than one IP address. Retry algorithms are selected on the
20356 basis of the domain name, but are applied to each IP address independently. If,
20357 for example, a host has two IP addresses and one is unusable, Exim will
20358 generate retry times for it and will not try to use it until its next retry
20359 time comes. Thus the good IP address is likely to be tried first most of the
20360 time.
20361
20362 .index hints database||use for retrying
20363 Retry times are hints rather than promises. Exim does not make any attempt to
20364 run deliveries exactly at the computed times. Instead, a queue runner process
20365 starts delivery processes for delayed messages periodically, and these attempt
20366 new deliveries only for those addresses that have passed their next retry time.
20367 If a new message arrives for a deferred address, an immediate delivery attempt
20368 occurs only if the address has passed its retry time. In the absence of new
20369 messages, the minimum time between retries is the interval between queue runner
20370 processes. There is not much point in setting retry times of five minutes if
20371 your queue runners happen only once an hour, unless there are a significant
20372 number of incoming messages (which might be the case on a system that is
20373 sending everything to a smart host, for example).
20374
20375 The data in the retry hints database can be inspected by using the
20376 \*exim@_dumpdb*\ or \*exim@_fixdb*\ utility programs (see chapter ~~CHAPutils). The
20377 latter utility can also be used to change the data. The \*exinext*\ utility
20378 script can be used to find out what the next retry times are for the hosts
20379 associated with a particular mail domain, and also for local deliveries that
20380 have been deferred.
20381
20382 .section Retry rule examples
20383 Here are some example retry rules:
20384 .display asis
20385 alice@wonderland.fict.example quota_5d  F,7d,3h
20386 wonderland.fict.example       quota_5d
20387 wonderland.fict.example       *         F,1h,15m; G,2d,1h,2;
20388 lookingglass.fict.example     *         F,24h,30m;
20389 *                          refused_A F,2h,20m;
20390 *                          *         F,2h,15m; G,16h,1h,1.5; F,5d,8h
20391 .endd
20392 The first rule sets up special handling for mail to
20393 \*alice@@wonderland.fict.example*\ when there is an over-quota error and the
20394 mailbox has not been read for at least 5 days. Retries continue every three
20395 hours for 7 days. The second rule handles over-quota errors for all other local
20396 parts at \*wonderland.fict.example*\; the absence of a local part has the same
20397 effect as supplying `$*$@@'. As no retry algorithms are supplied, messages that
20398 fail are bounced immediately if the mailbox has not been read for at least 5
20399 days.
20400
20401 The third rule handles all other errors at \*wonderland.fict.example*\; retries
20402 happen every 15 minutes for an hour, then with geometrically increasing
20403 intervals until two days have passed since a delivery first failed. After the
20404 first hour there is a delay of one hour, then two hours, then four hours, and
20405 so on (this is a rather extreme example).
20406
20407 The fourth rule controls retries for the domain \*lookingglass.fict.example*\.
20408 They happen every 30 minutes for 24 hours only. The remaining two rules handle
20409 all other domains, with special action for connection refusal from hosts that
20410 were not obtained from an MX record.
20411
20412 The final rule in a retry configuration should always have asterisks in the
20413 first two fields so as to provide a general catch-all for any addresses that do
20414 not have their own special handling. This example tries every 15 minutes for 2
20415 hours, then with intervals starting at one hour and increasing by a factor of
20416 1.5 up to 16 hours, then every 8 hours up to 5 days.
20417
20418
20419 .section Timeout of retry data
20420 .index timeout||of retry data
20421 .index \retry@_data@_expire\
20422 .index hints database||data expiry
20423 .index retry||timeout of data
20424 Exim timestamps the data that it writes to its retry hints database. When it
20425 consults the data during a delivery it ignores any that is older than the value
20426 set in \retry@_data@_expire\ (default 7 days). If, for example, a host hasn't
20427 been tried for 7 days, Exim will try to deliver to it immediately a message
20428 arrives, and if that fails, it will calculate a retry time as if it were
20429 failing for the first time.
20430
20431 This improves the behaviour for messages routed to rarely-used hosts such as MX
20432 backups. If such a host was down at one time, and happens to be down again when
20433 Exim tries a month later, using the old retry data would imply that it had been
20434 down all the time, which is not a justified assumption.
20435
20436 If a host really is permanently dead, this behaviour causes a burst of retries
20437 every now and again, but only if messages routed to it are rare. It there is a
20438 message at least once every 7 days the retry data never expires.
20439
20440
20441
20442 .section Long-term failures
20443 .index delivery||failure, long-term
20444 .index retry||after long-term failure
20445 Special processing happens when an email address has been failing for so long
20446 that the cutoff time for the last algorithm is reached. For example, using the
20447 default retry rule:
20448 .display asis
20449 * * F,2h,15m; G,16h,1h,1.5; F,4d,6h
20450 .endd
20451 the cutoff time is four days. Reaching the retry cutoff is independent of how
20452 long any specific message has been failing; it is the length of continuous
20453 failure for the recipient address that counts.
20454
20455 When the cutoff time is reached for a local delivery, or for all the IP
20456 addresses associated with a remote delivery, a subsequent delivery failure
20457 causes Exim to give up on the address, and a bounce message is generated.
20458 In order to cater for new messages that use the failing address, a next retry
20459 time is still computed from the final algorithm, and is used as follows:
20460
20461 For local deliveries, one delivery attempt is always made for any subsequent
20462 messages. If this delivery fails, the address fails immediately. The
20463 post-cutoff retry time is not used.
20464
20465 If the delivery is remote, there are two possibilities, controlled by the
20466 .index \delay@_after@_cutoff\
20467 \delay@_after@_cutoff\ option of the \%smtp%\ transport. The option is true by
20468 default and in that case:
20469 .numberpars " "
20470 Until the post-cutoff retry time for one of the IP addresses is reached,
20471 the failing email address is bounced immediately, without a delivery attempt
20472 taking place. After that time, one new delivery attempt is made to those IP
20473 addresses that are past their retry times, and if that still fails, the address
20474 is bounced and new retry times are computed.
20475 .endp
20476
20477 In other words, when all the hosts for a given email address have been failing
20478 for a long time, Exim bounces rather then defers until one of the hosts' retry
20479 times is reached. Then it tries once, and bounces if that attempt fails. This
20480 behaviour ensures that few resources are wasted in repeatedly trying to deliver
20481 to a broken destination, but if the host does recover, Exim will eventually
20482 notice.
20483
20484 If \delay@_after@_cutoff\ is set false, Exim behaves differently. If all IP
20485 addresses are past their final cutoff time, Exim tries to deliver to those IP
20486 addresses that have not been tried since the message arrived. If there are
20487 no suitable IP addresses, or if they all fail, the address is bounced. In other
20488 words, it does not delay when a new message arrives, but tries the expired
20489 addresses immediately, unless they have been tried since the message arrived.
20490 If there is a continuous stream of messages for the failing domains, setting
20491 \delay@_after@_cutoff\ false means that there will be many more attempts to
20492 deliver to permanently failing IP addresses than when \delay@_after@_cutoff\ is
20493 true.
20494
20495 .section Ultimate address timeout
20496 .index retry||ultimate address timeout
20497 An additional rule is needed to cope with cases where a host is intermittently
20498 available, or when a message has some attribute that prevents its delivery when
20499 others to the same address get through. In this situation, because some
20500 messages are successfully delivered, the `retry clock' for the address keeps
20501 getting restarted, and so a message could remain on the queue for ever. To
20502 prevent this, if a message has been on the queue for longer than the cutoff
20503 time of any applicable retry rule for a given address, a delivery is attempted
20504 for that address, even if it is not yet time, and if this delivery fails, the
20505 address is timed out. A new retry time is not computed in this case, so that
20506 other messages for the same address are considered immediately.
20507
20508
20509
20510
20511
20512 .
20513 .
20514 .
20515 .
20516 . ============================================================================
20517 .chapter SMTP authentication
20518 .set runningfoot "SMTP authentication"
20519 .rset CHAPSMTPAUTH "~~chapter"
20520 .index SMTP||authentication configuration
20521 .index authentication
20522 The `authenticators' section of Exim's run time configuration is concerned with
20523 SMTP authentication. This facility is an extension to the SMTP protocol,
20524 described in RFC 2554, which allows a client SMTP host to authenticate itself
20525 to a server. This is a common way for a server to recognize clients that
20526 are permitted to use it as a relay. SMTP authentication is not of relevance to
20527 the transfer of mail between servers that have no managerial connection with
20528 each other.
20529
20530 .index \\AUTH\\||description of
20531 Very briefly, the way SMTP authentication works is as follows:
20532 .numberpars $.
20533 The server advertises a number of authentication \*mechanisms*\ in response to
20534 the client's \\EHLO\\ command.
20535 .nextp
20536 The client issues an \\AUTH\\ command, naming a specific mechanism. The command
20537 may, optionally, contain some authentication data.
20538 .nextp
20539 The server may issue one or more \*challenges*\, to which the client must send
20540 appropriate responses. In simple authentication mechanisms, the challenges are
20541 just prompts for user names and passwords. The server does not have to issue
20542 any challenges -- in some mechanisms the relevant data may all be transmitted
20543 with the \\AUTH\\ command.
20544 .nextp
20545 The server either accepts or denies authentication.
20546 .nextp
20547 If authentication succeeds, the client may optionally make use of the \\AUTH\\
20548 option on the \\MAIL\\ command to pass an authenticated sender in subsequent
20549 mail transactions. Authentication lasts for the remainder of the SMTP
20550 connection.
20551 .nextp
20552 If authentication fails, the client may give up, or it may try a different
20553 authentication mechanism, or it may try transferring mail over the
20554 unauthenticated connection.
20555 .endp
20556 If you are setting up a client, and want to know which authentication
20557 mechanisms the server supports, you can use Telnet to connect to port 25 (the
20558 SMTP port) on the server, and issue an \\EHLO\\ command. The response to this
20559 includes the list of supported mechanisms. For example:
20560 .display
20561 @$ $cb{telnet server.example 25}
20562 Trying 192.168.34.25...
20563 Connected to server.example.
20564 Escape character is '@^]'.
20565 220 server.example ESMTP Exim 4.20 ...
20566 $cb{ehlo client.example}
20567 250-server.example Hello client.example [10.8.4.5]
20568 250-SIZE 52428800
20569 250-PIPELINING
20570 250-AUTH PLAIN
20571 250 HELP
20572 .endd
20573 The second-last line of this example output shows that the server supports
20574 authentication using the PLAIN mechanism. In Exim, the different authentication
20575 mechanisms are configured by specifying \*authenticator*\ drivers. Like the
20576 routers and transports, which authenticators are included in the binary is
20577 controlled by build-time definitions. The following are currently available,
20578 included by setting
20579 .display asis
20580 AUTH_CRAM_MD5=yes
20581 AUTH_PLAINTEXT=yes
20582 AUTH_SPA=yes
20583 .endd
20584 in \(Local/Makefile)\, respectively. The first of these supports the CRAM-MD5
20585 authentication mechanism (RFC 2195), and the second can be configured to
20586 support the PLAIN authentication mechanism (RFC 2595) or the LOGIN mechanism,
20587 which is not formally documented, but used by several MUAs. The third
20588 authenticator supports Microsoft's \*Secure Password Authentication*\
20589 mechanism.
20590
20591 The authenticators are configured using the same syntax as other drivers (see
20592 section ~~SECTfordricon). If no authenticators are required, no authentication
20593 section need be present in the configuration file. Each authenticator can in
20594 principle have both server and client functions. When Exim is receiving SMTP
20595 mail, it is acting as a server; when it is sending out messages over SMTP, it
20596 is acting as a client. Authenticator configuration options are provided for use
20597 in both these circumstances.
20598
20599 To make it clear which options apply to which situation, the prefixes
20600 \server@_\ and \client@_\ are used on option names that are specific to either
20601 the server or the client function, respectively. Server and client functions
20602 are disabled if none of their options are set. If an authenticator is to be
20603 used for both server and client functions, a single definition, using both sets
20604 of options, is required. For example:
20605 .display asis
20606 cram:
20607   driver = cram_md5
20608   public_name = CRAM-MD5
20609   server_secret = ${if eq{$1}{ph10}{secret1}fail}
20610   client_name = ph10
20611   client_secret = secret2
20612 .endd
20613 The \server@_\ option is used when Exim is acting as a server, and the
20614 \client@_\ options when it is acting as a client.
20615
20616 Descriptions of the individual authenticators are given in subsequent chapters.
20617 The remainder of this chapter covers the generic options for the
20618 authenticators, followed by general discussion of the way authentication works
20619 in Exim.
20620
20621
20622 .section Generic options for authenticators
20623 .index authentication||generic options
20624
20625 .startconf authenticators
20626 .index options||generic, for authenticators
20627
20628 .conf driver string unset
20629 This option must always be set. It specifies which of the available
20630 authenticators is to be used.
20631
20632 .conf public@_name string unset
20633 This option specifies the name of the authentication mechanism that the driver
20634 implements, and by which it is known to the outside world. These names should
20635 contain only upper case letters, digits, underscores, and hyphens (RFC 2222),
20636 but Exim in fact matches them caselessly. If \public@_name\ is not set, it
20637 defaults to the driver's instance name.
20638
20639 .conf server@_advertise@_condition string$**$ unset
20640 When a server is about to advertise an authentication mechanism, the condition
20641 is expanded. If it yields the empty string, `0', `no', or `false', the
20642 mechanism is not advertised.
20643 If the expansion fails, the mechanism is not advertised. If the failure was not
20644 forced, and was not caused by a lookup defer, the incident is logged.
20645 See section ~~SECTauthexiser below for further discussion.
20646
20647 .conf server@_debug@_print string$**$ unset
20648 If this option is set and authentication debugging is enabled (see the \-d-\
20649 command line option), the string is expanded and included in the debugging
20650 output when the authenticator is run as a server. This can help with checking
20651 out the values of variables.
20652 If expansion of the string fails, the error message is written to the debugging
20653 output, and Exim carries on processing.
20654
20655 .conf server@_set@_id string$**$ unset
20656 When an Exim server successfully authenticates a client, this string is
20657 expanded using data from the authentication, and preserved for any incoming
20658 messages in the variable \$authenticated@_id$\. It is also included in the log
20659 lines for incoming messages. For example, a user/password authenticator
20660 configuration might preserve the user name that was used to authenticate, and
20661 refer to it subsequently during delivery of the message.
20662 If expansion fails, the option is ignored.
20663
20664 .conf server@_mail@_auth@_condition string$**$ unset
20665 This option allows a server to discard authenticated sender addresses supplied
20666 as part of \\MAIL\\ commands in SMTP connections that are authenticated by the
20667 driver on which \server__mail__auth@_condition\ is set. The option is not used
20668 as part of the authentication process; instead its (unexpanded) value is
20669 remembered for later use.
20670 How it is used is described in the following section.
20671 .endconf
20672
20673
20674
20675 .section The AUTH parameter on MAIL commands
20676 .rset SECTauthparamail "~~chapter.~~section"
20677 .index authentication||sender, authenticated
20678 .index \\AUTH\\||on \\MAIL\\ command
20679 When a client supplied an \\AUTH=\\ item on a \\MAIL\\ command, Exim applies
20680 the following checks before accepting it as the authenticated sender of the
20681 message:
20682 .numberpars $.
20683 If the connection is not using extended SMTP (that is, \\HELO\\ was used rather
20684 than \\EHLO\\), the use of \\AUTH=\\ is a syntax error.
20685 .nextp
20686 If the value of the \\AUTH=\\ parameter is `@<@>', it is ignored.
20687 .nextp
20688 If \acl@_smtp@_mailauth\ is defined, the ACL it specifies is run. While it is
20689 running, the value of \$authenticated@_sender$\ is set to the value obtained
20690 from the \\AUTH=\\ parameter. If the ACL does not yield `accept', the value of
20691 \$authenticated@_sender$\ is deleted. The \acl@_smtp@_mailauth\ ACL may not
20692 return `drop' or `discard'. If it defers, a temporary error code (451) is given
20693 for the \\MAIL\\ command.
20694 .nextp
20695 If \acl@_smtp@_mailauth\ is not defined, the value of the \\AUTH=\\ parameter
20696 is accepted and placed in \$authenticated@_sender$\ only if the client has
20697 authenticated.
20698 .nextp
20699 If the \\AUTH=\\ value was accepted by either of the two previous rules, and
20700 the client has authenticated, and the authenticator has a setting for the
20701 \server@_mail@_auth@_condition\, the condition is checked at this point. The
20702 valued that was saved from the authenticator is expanded. If the expansion
20703 fails, or yields an empty string, `0', `no', or `false', the value of
20704 \$authenticated__sender$\ is deleted. If the expansion yields any other value,
20705 the value of \$authenticated@_sender$\ is retained and passed on with the
20706 message.
20707 .endp
20708
20709 When \$authenticated@_sender$\ is set for a message, it is passed on to other
20710 hosts to which Exim authenticates as a client. Do not confuse this value with
20711 \$authenticated@_id$\, which is a string obtained from the authentication
20712 process, and which is not usually a complete email address.
20713
20714 Whenever an \\AUTH=\\ value is ignored, the incident is logged. The ACL for
20715 \\MAIL\\, if defined, is run after \\AUTH=\\ is accepted or ignored. It can
20716 therefore make use of \$authenticated@_sender$\. The converse is not true: the
20717 value of \$sender@_address$\ is not yet set up when the \acl@_smtp@_mailauth\
20718 ACL is run.
20719
20720
20721 .section Authentication on an Exim server
20722 .rset SECTauthexiser "~~chapter.~~section"
20723 .index authentication||on an Exim server
20724 When Exim receives an \\EHLO\\ command, it advertises the public names of those
20725 authenticators that are configured as servers, subject to the following
20726 conditions:
20727 .numberpars $.
20728 The client host must match \auth@_advertise@_hosts\ (default $*$).
20729 .nextp
20730 It the \server@_advertise@_condition\ option is set, its expansion must not
20731 yield the empty string, `0', `no', or `false'.
20732 .endp
20733 The order in which the authenticators are defined controls the order in which
20734 the mechanisms are advertised.
20735
20736 Some mail clients (for example, some versions of Netscape) require the user to
20737 provide a name and password for authentication whenever \\AUTH\\ is advertised,
20738 even though authentication may not in fact be needed (for example, Exim may be
20739 set up to allow unconditional relaying from the client by an IP address check).
20740 You can make such clients more friendly by not advertising \\AUTH\\ to them.
20741 For example, if clients on the 10.9.8.0/24 network are permitted (by the ACL
20742 that runs for \\RCPT\\) to relay without authentication, you should set
20743 .display asis
20744 auth_advertise_hosts = ! 10.9.8.0/24
20745 .endd
20746 so that no authentication mechanisms are advertised to them.
20747
20748 The \server@_advertise@_condition\ controls the advertisement of individual
20749 authentication mechanisms. For example, it can be used to restrict the
20750 advertisement of a patricular mechanism to encrypted connections, by a setting
20751 such as:
20752 .display asis
20753 server_advertise_condition = ${if eq{$tls_cipher}{}{no}{yes}}
20754 .endd
20755 If the session is encrypted, \$tls@_cipher$\ is not empty, and so the expansion
20756 yields `yes', which allows the advertisement to happen.
20757
20758 When an Exim server receives an \\AUTH\\ command from a client, it rejects it
20759 immediately if \\AUTH\\ was not advertised in response to an earlier \\EHLO\\
20760 command. This is the case if
20761 .numberpars $.
20762 The client host does not match \auth@_advertise@_hosts\; or
20763 .nextp
20764 No authenticators are configured with server options; or
20765 .nextp
20766 Expansion of \server@_advertise@_condition\ blocked the advertising of all the
20767 server authenticators.
20768 .endp
20769
20770 Otherwise, Exim runs the ACL specified by \acl@_smtp@_auth\ in order
20771 to decide whether to accept the command. If \acl@_smtp@_auth\ is not set,
20772 \\AUTH\\ is accepted from any client host.
20773
20774 If \\AUTH\\ is not rejected by the ACL, Exim searches its configuration for a
20775 server authentication mechanism that was advertised in response to \\EHLO\\ and
20776 that matches the one named in the \\AUTH\\ command. If it finds one, it runs
20777 the appropriate authentication protocol, and authentication either succeeds or
20778 fails. If there is no matching advertised mechanism, the \\AUTH\\ command is
20779 rejected with a 504 error.
20780
20781 When a message is received from an authenticated host, the value of
20782 \$received@_protocol$\ is set to 
20783 .em
20784 `esmtpa' 
20785 .nem
20786 instead of `esmtp', and \$sender@_host@_authenticated$\ contains the name (not
20787 the public name) of the authenticator driver that successfully authenticated
20788 the client from which the message was received. This variable is empty if there
20789 was no successful authentication.
20790
20791
20792
20793 .section Testing server authentication
20794 .index authentication||testing a server
20795 .index \\AUTH\\||testing a server
20796 .index base64 encoding||creating authentication test data
20797 Exim's \-bh-\ option can be useful for testing server authentication
20798 configurations. The data for the \\AUTH\\ command has to be sent using base64
20799 encoding. A quick way to produce such data for testing is the following Perl
20800 script:
20801 .display asis
20802 use MIME::Base64;
20803 printf ("%s", encode_base64(eval "\"$ARGV[0]\""));
20804 .endd
20805 .index binary zero||in authentication data
20806 This interprets its argument as a Perl string, and then encodes it. The
20807 interpretation as a Perl string allows binary zeros, which are required for
20808 some kinds of authentication, to be included in the data. For example, a
20809 command line to run this script on such data might be
20810 .display asis
20811 encode '\0user\0password'
20812 .endd
20813 Note the use of single quotes to prevent the shell interpreting the
20814 backslashes, so that they can be interpreted by Perl to specify characters
20815 whose code value is zero.
20816
20817 \**Warning 1**\: If either of the user or password strings starts with an octal
20818 digit, you must use three zeros instead of one after the leading backslash. If
20819 you do not, the octal digit that starts your string will be incorrectly
20820 interpreted as part of the code for the first character.
20821
20822 \**Warning 2**\: If there are characters in the strings that Perl interprets
20823 specially, you must use a Perl escape to prevent them being misinterpreted. For
20824 example, a command such as
20825 .display asis
20826 encode '\0user@domain.com\0pas$$word'
20827 .endd
20828 gives an incorrect answer because of the unescaped `@@' and `@$' characters.
20829
20830 If you have the \mimencode\ command installed, another way to do produce
20831 base64-encoded strings is to run the command
20832 .display asis
20833 echo -e -n `\0user\0password' | mimencode
20834 .endd
20835 The \-e-\ option of \echo\ enables the interpretation of backslash escapes in
20836 the argument, and the \-n-\ option specifies no newline at the end of its
20837 output. However, not all versions of \echo\ recognize these options, so you
20838 should check your version before relying on this suggestion.
20839
20840
20841 .section Authentication by an Exim client
20842 .index authentication||on an Exim client
20843 The \%smtp%\ transport has two options called \hosts@_require@_auth\ and
20844 \hosts@_try@_auth\. When the \%smtp%\ transport connects to a server that
20845 announces support for authentication, and the host matches an entry in either
20846 of these options, Exim (as a client) tries to authenticate as follows:
20847 .numberpars $.
20848 For each authenticator that is configured as a client, it searches the
20849 authentication mechanisms announced by the server for one whose name
20850 matches the public name of the authenticator.
20851 .nextp
20852 When it finds one that matches, it runs the authenticator's client code.
20853 The variables \$host$\ and \$host@_address$\ are available for any string
20854 expansions that the client might do. They are set to the server's name and
20855 IP address. If any expansion is forced to fail, the authentication attempt
20856 is abandoned,
20857 and Exim moves on to the next authenticator.
20858 Otherwise an expansion failure causes delivery to be
20859 deferred.
20860 .nextp
20861 If the result of the authentication attempt is a temporary error or a timeout,
20862 Exim abandons trying to send the message to the host for the moment. It will
20863 try again later. If there are any backup hosts available, they are tried in the
20864 usual way.
20865 .nextp
20866 If the response to authentication is a permanent error (5xx code), Exim carries
20867 on searching the list of authenticators and tries another one if possible. If
20868 all authentication attempts give permanent errors, or if there are no attempts
20869 because no mechanisms match
20870 (or option expansions force failure),
20871 what happens depends on whether the host matches \hosts@_require@_auth\ or
20872 \hosts@_try@_auth\. In the first case, a temporary error is generated, and
20873 delivery is deferred. The error can be detected in the retry rules, and thereby
20874 turned into a permanent error if you wish. In the second case, Exim tries to
20875 deliver the message unauthenticated.
20876 .endp
20877 .index \\AUTH\\||on \\MAIL\\ command
20878 When Exim has authenticated itself to a remote server, it adds the \\AUTH\\
20879 parameter to the \\MAIL\\ commands it sends, if it has an authenticated sender
20880 for the message.
20881 If the message came from a remote host, the authenticated sender is the one
20882 that was receiving on an incoming \\MAIL\\ command, provided that the incoming
20883 connection was authenticated and the \server@_mail@_auth\ condition allowed the
20884 authenticated sender to be retained. If a local process calls Exim to send a
20885 message, the sender address that is built from the login name and
20886 \qualify@_domain\ is treated as authenticated. However, if the
20887 \authenticated@_sender\ option is set on the \%smtp%\ transport, it overrides
20888 the authenticated sender that was received with the message.
20889
20890
20891
20892
20893
20894
20895 .
20896 .
20897 .
20898 .
20899 . ============================================================================
20900 .chapter The plaintext authenticator
20901 .rset CHAPplaintext "~~chapter"
20902 .set runningfoot "plaintext authenticator"
20903 .index \%plaintext%\ authenticator
20904 .index authenticators||\%plaintext%\
20905 The \%plaintext%\ authenticator can be configured to support the PLAIN and
20906 LOGIN authentication mechanisms, both of which transfer authentication data as
20907 plain (unencrypted) text (though base64 encoded). The use of plain text is a
20908 security risk. If you use one of these mechanisms without also making use of
20909 SMTP encryption (see chapter ~~CHAPTLS) you should not use the same passwords
20910 for SMTP connections as you do for login accounts.
20911
20912 .section Using plaintext in a server
20913 When running as a server, \%plaintext%\ performs the authentication test by
20914 expanding a string. It has the following options:
20915
20916 .startconf plaintext
20917 .index options||\%plaintext%\ authenticator (server)
20918
20919 .conf server@_prompts string$**$ unset
20920 The contents of this option, after expansion, must be a colon-separated list of
20921 prompt strings. If expansion fails, a temporary authentication rejection is
20922 given.
20923
20924 .conf server@_condition string$**$ unset
20925 This option must be set in order to configure the driver as a server. Its use
20926 is described below.
20927
20928 .endconf
20929
20930 .index \\AUTH\\||in \%plaintext%\ authenticator
20931 .index binary zero||in \%plaintext%\ authenticator
20932 .index numerical variables (\$1$\, \$2$\, etc)||in \%plaintext%\ authenticator
20933 .index base64 encoding||in \%plaintext%\ authenticator
20934 The data sent by the client with the \\AUTH\\ command, or in response to
20935 subsequent prompts, is base64 encoded, and so may contain any byte values
20936 when decoded. If any data is supplied with the command, it is treated as a
20937 list of strings, separated by NULs (binary zeros), which are placed in the
20938 expansion variables \$1$\, \$2$\, etc. If there are more strings in
20939 \server@_prompts\ than the number of strings supplied with the \\AUTH\\
20940 command, the remaining prompts are used to obtain more data. Each response from
20941 the client may be a list of NUL-separated strings.
20942
20943 Once a sufficient number of data strings have been received,
20944 \server@_condition\ is expanded.
20945 If the expansion is forced to fail, authentication fails. Any other expansion
20946 failure causes a temporary error code to be returned.
20947 If the result of a successful expansion is an empty string, `0', `no', or
20948 `false', authentication fails. If the result of the expansion is `1', `yes', or
20949 `true', authentication succeeds and the generic \server@_set@_id\ option is
20950 expanded and saved in \$authenticated@_id$\. For any other result, a temporary
20951 error code is returned, with the expanded string as the error text.
20952
20953 \**Warning**\: If you use a lookup in the expansion to find the user's
20954 password, be sure to make the authentication fail if the user is unknown.
20955 There are good and bad examples at the end of the next section.
20956
20957
20958 .section The PLAIN authentication mechanism
20959 .index PLAIN authentication mechanism
20960 .index authentication||PLAIN mechanism
20961 .index binary zero||in \%plaintext%\ authenticator
20962 The PLAIN authentication mechanism (RFC 2595) specifies that three strings be
20963 sent as one item of data (that is, one combined string containing two NUL
20964 separators). The data is sent either as part of the \\AUTH\\ command, or
20965 subsequently in response to an empty prompt from the server.
20966
20967 The second and third strings are a user name and a corresponding password.
20968 Using a single fixed user name and password as an example, this could be
20969 configured as follows:
20970 .display asis
20971 fixed_plain:
20972   driver = plaintext
20973   public_name = PLAIN
20974   server_prompts = :
20975   server_condition = \
20976     ${if and {{eq{$2}{username}}{eq{$3}{mysecret}}}{yes}{no}}
20977   server_set_id = $2
20978 .endd
20979 The \server@_prompts\ setting specifies a single, empty prompt (empty items at
20980 the end of a string list are ignored). If all the data comes as part of the
20981 \\AUTH\\ command, as is commonly the case, the prompt is not used. This
20982 authenticator is advertised in the response to \\EHLO\\ as
20983 .display asis
20984 250-AUTH PLAIN
20985 .endd
20986 and a client host can authenticate itself by sending the command
20987 .display asis
20988 AUTH PLAIN AHVzZXJuYW1lAG15c2VjcmV0
20989 .endd
20990 As this contains three strings (more than the number of prompts), no further
20991 data is required from the client. Alternatively, the client may just send
20992 .display asis
20993 AUTH PLAIN
20994 .endd
20995 to initiate authentication, in which case the server replies with an empty
20996 prompt. The client must respond with the combined data string.
20997
20998 The data string is base64 encoded, as required by the RFC. This example,
20999 when decoded, is \"<<NUL>>username<<NUL>>mysecret"\, where <<NUL>> represents a
21000 zero byte. This is split up into three strings, the first of which is empty.
21001 The \server@_condition\ option in the authenticator checks that the second two
21002 are \"username"\ and \"mysecret"\ respectively.
21003
21004 Having just one fixed user name and password, as in this example, is not very
21005 realistic, though for a small organization with only a handful of
21006 authenticating clients it could make sense.
21007
21008 A more sophisticated instance of this authenticator could use the user name in
21009 \$2$\ to look up a password in a file or database, and maybe do an encrypted
21010 comparison (see \crypteq\ in chapter ~~CHAPexpand). Here is a example of this
21011 approach, where the passwords are looked up in a DBM file. \**Warning**\: This
21012 is an incorrect example:
21013 .display asis
21014 server_condition = \
21015   ${if eq{$3}{${lookup{$2}dbm{/etc/authpwd}}}{yes}{no}}
21016 .endd
21017 The expansion uses the user name (\$2$\) as the key to look up a password,
21018 which it then compares to the supplied password (\$3$\). Why is this example
21019 incorrect? It works fine for existing users, but consider what happens if a
21020 non-existent user name is given. The lookup fails, but as no success/failure
21021 strings are given for the lookup, it yields an empty string. Thus, to defeat
21022 the authentication, all a client has to do is to supply a non-existent user
21023 name and an empty password. The correct way of writing this test is:
21024 .display asis
21025 server_condition = ${lookup{$2}dbm{/etc/authpwd}\
21026   {${if eq{$value}{$3}{yes}{no}}}{no}}
21027 .endd
21028 In this case, if the lookup succeeds, the result is checked; if the lookup
21029 fails, authentication fails. If \crypteq\ is being used instead of \eq\, the
21030 first example is in fact safe, because \crypteq\ always fails if its second
21031 argument is empty. However, the second way of writing the test makes the logic
21032 clearer.
21033
21034
21035 .section The LOGIN authentication mechanism
21036 .index LOGIN authentication mechanism
21037 .index authentication||LOGIN mechanism
21038 The LOGIN authentication mechanism is not documented in any RFC, but is in use
21039 in a number of programs. No data is sent with the \\AUTH\\ command. Instead, a
21040 user name and password are supplied separately, in response to prompts. The
21041 plaintext authenticator can be configured to support this as in this example:
21042 .display asis
21043 fixed_login:
21044   driver = plaintext
21045   public_name = LOGIN
21046   server_prompts = User Name : Password
21047   server_condition = \
21048     ${if and {{eq{$1}{username}}{eq{$2}{mysecret}}}{yes}{no}}
21049   server_set_id = $1
21050 .endd
21051 Because of the way plaintext operates, this authenticator accepts data supplied
21052 with the \\AUTH\\ command (in contravention of the specification of LOGIN), but
21053 if the client does not supply it (as is the case for LOGIN clients), the prompt
21054 strings are used to obtain two data items.
21055
21056 Some clients are very particular about the precise text of the prompts. For
21057 example, Outlook Express is reported to recognize only `Username:' and
21058 `Password:'. Here is an example of a LOGIN authenticator which uses those
21059 strings, and which uses the \ldapauth\ expansion condition to check the user
21060 name and password by binding to an LDAP server:
21061 .display asis
21062 login:
21063   driver = plaintext
21064   public_name = LOGIN
21065   server_prompts = Username:: : Password::
21066   server_condition = ${if ldapauth \
21067 .newline
21068     {user="cn=${quote_ldap_dn:$1},ou=people,o=example.org" \
21069     pass=${quote:$2} \
21070 .newline
21071     ldap://ldap.example.org/}{yes}{no}}
21072   server_set_id = uid=$1,ou=people,o=example.org
21073 .endd
21074 Note the use of the \quote@_ldap@_dn\ operator to correctly quote the DN for
21075 authentication. However, the basic \quote\ operator, rather than any of the
21076 LDAP quoting operators, is the correct one to use for the password, because
21077 quoting is needed only to make the password conform to the Exim syntax. At the
21078 LDAP level, the password is an uninterpreted string.
21079
21080
21081 .section Support for different kinds of authentication
21082 A number of string expansion features are provided for the purpose of
21083 interfacing to different ways of user authentication. These include checking
21084 traditionally encrypted passwords from \(/etc/passwd)\ (or equivalent), PAM,
21085 Radius, \ldapauth\, and \*pwcheck*\. For details see section ~~SECTexpcond.
21086
21087
21088
21089 .section Using plaintext in a client
21090 The \%plaintext%\ authenticator has just one client option:
21091
21092 .startconf plaintext
21093 .index options||\%plaintext%\ authenticator (client)
21094
21095 .conf client@_send string$**$ unset
21096 The string is a colon-separated list of authentication data strings. Each
21097 string is independently expanded before being sent to the server. The first
21098 string is sent with the \\AUTH\\ command; any more strings are sent in response
21099 to prompts from the server.
21100
21101 \**Note**\: you cannot use expansion to create multiple strings, because
21102 splitting takes priority and happens first.
21103
21104 Because the PLAIN authentication mechanism requires NUL (binary zero) bytes in
21105 the data, further processing is applied to each string before it is sent. If
21106 there are any single circumflex characters in the string, they are converted to
21107 NULs. Should an actual circumflex be required as data, it must be doubled in
21108 the string.
21109
21110 .endconf
21111
21112 This is an example of a client configuration that implements the PLAIN
21113 authentication mechanism with a fixed user name and password:
21114 .display asis
21115 fixed_plain:
21116   driver = plaintext
21117   public_name = PLAIN
21118   client_send = ^username^mysecret
21119 .endd
21120 The lack of colons means that the entire text is sent with the \\AUTH\\
21121 command, with the circumflex characters converted to NULs. A similar example
21122 that uses the LOGIN mechanism is:
21123 .display asis
21124 fixed_login:
21125   driver = plaintext
21126   public_name = LOGIN
21127   client_send = : username : mysecret
21128 .endd
21129 The initial colon means that the first string is empty, so no data is sent with
21130 the \\AUTH\\ command itself. The remaining strings are sent in response to
21131 prompts.
21132
21133
21134
21135
21136 .
21137 .
21138 .
21139 .
21140 . ============================================================================
21141 .chapter The cram@_md5 authenticator
21142 .set runningfoot "cram@_md5 authenticator"
21143 .index \%cram@_md5%\ authenticator
21144 .index authenticators||\%cram@_md5%\
21145 .index CRAM-MD5 authentication mechanism
21146 .index authentication||CRAM-MD5 mechanism
21147 The CRAM-MD5 authentication mechanism is described in RFC 2195. The server
21148 sends a challenge string to the client, and the response consists of a user
21149 name and the CRAM-MD5 digest of the challenge string combined with a secret
21150 string (password) which is known to both server and client. Thus, the secret
21151 is not sent over the network as plain text, which makes this authenticator more
21152 secure than \%plaintext%\. However, the downside is that the secret has to be
21153 available in plain text at either end.
21154
21155 .section Using cram@_md5 as a server
21156 This authenticator has one server option, which must be set to configure the
21157 authenticator as a server:
21158
21159 .startconf cram@_md5
21160 .index options||\%cram@_md5%\ authenticator (server)
21161
21162 .conf server@_secret string$**$ unset
21163 .index numerical variables (\$1$\, \$2$\, etc)||in \%cram@_md5%\ authenticator
21164 When the server receives the client's response, the user name is placed in
21165 the expansion variable \$1$\, and \server@_secret\ is expanded to obtain the
21166 password for that user. The server then computes the CRAM-MD5 digest that the
21167 client should have sent, and checks that it received the correct string. If the
21168 expansion of \server@_secret\ is forced to fail, authentication fails. If the
21169 expansion fails for some other reason, a temporary error code is returned to
21170 the client.
21171
21172 .endconf
21173
21174 For example, the following authenticator checks that the user name given by the
21175 client is `ph10', and if so, uses `secret' as the password. For any other user
21176 name, authentication fails.
21177 .display asis
21178 fixed_cram:
21179   driver = cram_md5
21180   public_name = CRAM-MD5
21181   server_secret = ${if eq{$1}{ph10}{secret}fail}
21182   server_set_id = $1
21183 .endd
21184 If authentication succeeds, the setting of \server@_set@_id\ preserves the user
21185 name in \$authenticated@_id$\.
21186 A more tyical configuration might look up the secret string in a file, using
21187 the user name as the key. For example:
21188 .display asis
21189 lookup_cram:
21190   driver = cram_md5
21191   public_name = CRAM-MD5
21192   server_secret = ${lookup{$1}lsearch{/etc/authpwd}{$value}fail}
21193   server_set_id = $1
21194 .endd
21195 Note that this expansion explicitly forces failure if the lookup fails
21196 because \$1$\ contains an unknown user name.
21197
21198 .section Using cram@_md5 as a client
21199 When used as a client, the \%cram@_md5%\ authenticator has two options:
21200
21201 .startconf cram@_md5
21202 .index options||\%cram@_md5%\ authenticator (client)
21203
21204 .conf client@_name string$**$ "the primary host name"
21205 This string is expanded, and the result used as the user name data when
21206 computing the response to the server's challenge.
21207
21208 .conf client@_secret string$**$ unset
21209 This option must be set for the authenticator to work as a client. Its value is
21210 expanded and the result used as the secret string when computing the response.
21211
21212 .endconf
21213
21214 Different user names and secrets can be used for different servers by referring
21215 to \$host$\ or \$host@_address$\ in the options.
21216
21217 Forced failure of either expansion string is treated as an indication that this
21218 authenticator is not prepared to handle this case. Exim moves on to the next
21219 configured client authenticator. Any other expansion failure causes Exim to
21220 give up trying to send the message to the current server.
21221
21222 A simple example configuration of a \%cram@_md5%\ authenticator, using fixed
21223 strings, is:
21224 .display asis
21225 fixed_cram:
21226   driver = cram_md5
21227   public_name = CRAM-MD5
21228   client_name = ph10
21229   client_secret = secret
21230 .endd
21231
21232
21233
21234
21235 .
21236 .
21237 .
21238 .
21239 . ============================================================================
21240 .chapter The cyrus@_sasl authenticator
21241 .set runningfoot "cyrus@_sasl authenticator"
21242 .index \%cyrus@_sasl%\ authenticator
21243 .index authenticators||\%cyrus@_sasl%\
21244 .index Cyrus, SASL library
21245 .em
21246 The code for this authenticator was provided by Matthew Byng-Maddick of A L
21247 Digital Ltd (\?http://www.aldigital.co.uk?\).
21248
21249 The \%cyrus@_sasl%\ authenticator provides server support for the Cyrus SASL
21250 library implementation of the RFC 2222 (`Simple Authentication and Security
21251 Layer'). This library supports a number of authentication mechanisms, including
21252 PLAIN and LOGIN, but also several others that Exim does not support directly.
21253 In particular, there is support for Kerberos authentication.
21254
21255 The \%cyrus@_sasl%\ authenticator provides a gatewaying mechanism directly to
21256 the Cyrus interface, so if your Cyrus library can do, for example, CRAM-MD5,
21257 then so can the \%cyrus@_sasl%\ authenticator. By default it uses the public
21258 name of the driver to determine which mechanism to support.
21259
21260 Where access to some kind of secret file is required, for example in GSSAPI
21261 or CRAM-MD5, it is worth noting that the authenticator runs as the \*exim*\
21262 user, and that the Cyrus SASL library has no way of escalating privileges
21263 by default. You may also find you need to set environment variables,
21264 depending on the driver you are using.
21265
21266 .section Using cyrus@_sasl as a server
21267 The \%cyrus@_sasl%\ authenticator has four private options. It puts the
21268 username (on a successful authentication) into \$1$\.
21269
21270 .startconf cyrus@_sasl
21271 .conf server@_hostname string$**$ $tt{$primary@_hostname}
21272 This option selects the hostname that is used when communicating with
21273 the library. It is up to the underlying SASL plug-in what it does with
21274 this data.
21275
21276 .conf server@_mech string $tt{public@_name}
21277 This option selects the authentication mechanism this driver should
21278 use. It allows you to use a different underlying mechanism from the
21279 advertised name. For example:
21280 .display asis
21281 sasl:
21282   driver = cyrus_sasl
21283   public_name = X-ANYTHING
21284   server_mech = CRAM-MD5
21285   server_set_id = $1
21286 .endd
21287
21288 .conf server@_realm  string  unset
21289 This specifies the SASL realm that the server claims to be in.
21290
21291 .conf server@_service string $tt{smtp}
21292 This is the SASL service that the server claims to implement.
21293
21294 .endconf
21295
21296 For straightforward cases, you do not need to set any of the authenticator's
21297 private options. All you need to do is to specify an appropriate mechanism as
21298 the public name. Thus, if you have a SASL library that supports CRAM-MD5 and
21299 PLAIN, you could have two authenticators as follows:
21300 .display asis
21301 sasl_cram_md5:
21302   driver = cyrus_sasl
21303   public_name = CRAM-MD5
21304   server_set_id = $1
21305
21306 sasl_plain:
21307   driver = cyrus_sasl
21308   public_name = PLAIN
21309   server_set_id = $1
21310 .endd
21311
21312 Cyrus SASL does implement the LOGIN authentication method, even though it is 
21313 not a standard method. It is disabled by default in the source distribution,
21314 but it is present in many binary distributions.
21315
21316 .nem
21317
21318
21319
21320 .
21321 .
21322 .
21323 .
21324 . ============================================================================
21325 .chapter The spa authenticator
21326 .set runningfoot "spa authenticator"
21327 .index \%spa%\ authenticator
21328 .index authenticators||\%spa%\
21329 .index authentication||Microsoft Secure Password
21330 .index authentication||NTLM
21331 .index Microsoft Secure Password Authentication
21332 .index NTLM authentication
21333 The \%spa%\ authenticator provides client support for Microsoft's \*Secure
21334 Password Authentication*\ mechanism,
21335 which is also sometimes known as NTLM (NT LanMan). The code for client side of
21336 this authenticator was contributed by Marc Prud'hommeaux, and much of it is
21337 taken from the Samba project (\?http://www.samba.org?\). The code for the
21338 server side was subsequently contributed by Tom Kistner.
21339
21340 The mechanism works as follows:
21341 .numberpars $.
21342 After the \\AUTH\\ command has been accepted, the client sends an SPA
21343 authentication request based on the user name and optional domain.
21344 .nextp
21345 The server sends back a challenge.
21346 .nextp
21347 The client builds a challenge response which makes use of the user's password
21348 and sends it to the server, which then accepts or rejects it.
21349 .endp
21350 Encryption is used to protect the password in transit.
21351
21352
21353 .section Using spa as a server
21354 The \%spa%\ authenticator has just one server option:
21355
21356 .startconf spa
21357 .index options||\%spa%\ authenticator (server)
21358
21359 .conf server@_password string$**$ unset
21360 .index numerical variables (\$1$\, \$2$\, etc)||in \%spa%\ authenticator
21361 This option is expanded, and the result must be the cleartext password for the
21362 authenticating user, whose name is at this point in \$1$\. For example:
21363 .display asis
21364 spa:
21365   driver = spa
21366   public_name = NTLM
21367   server_password = ${lookup{$1}lsearch{/etc/exim/spa_clearpass}}
21368 .endd
21369 If the expansion is forced to fail, authentication fails. Any other expansion
21370 failure causes a temporary error code to be returned.
21371
21372 .endconf
21373
21374
21375
21376 .section Using spa as a client
21377 The \%spa%\ authenticator has the following client options:
21378
21379 .startconf spa
21380 .index options||\%spa%\ authenticator (client)
21381
21382 .conf client@_domain string$**$ unset
21383 This option specifies an optional domain for the authentication.
21384
21385 .conf client@_password string$**$ unset
21386 This option specifies the user's password, and must be set.
21387
21388 .conf client@_username string$**$ unset
21389 This option specifies the user name, and must be set.
21390
21391 .endconf
21392
21393 Here is an example of a configuration of this authenticator for use with the
21394 mail servers at \*msn.com*\:
21395 .display asis
21396 msn:
21397   driver = spa
21398   public_name = MSN
21399   client_username = msn/msn_username
21400   client_password = msn_plaintext_password
21401   client_domain = DOMAIN_OR_UNSET
21402 .endd
21403
21404
21405
21406
21407
21408
21409 .
21410 .
21411 .
21412 .
21413 . ============================================================================
21414 .chapter Encrypted SMTP connections using TLS/SSL
21415 .set runningfoot "TLS encryption"
21416 .rset CHAPTLS "~~chapter"
21417 .index encryption||on SMTP connection
21418 .index SMTP||encryption
21419 .index TLS||on SMTP connection
21420 .index OpenSSL
21421 .index GnuTLS
21422 Support for TLS (Transport Layer Security), formerly known as SSL (Secure
21423 Sockets Layer), is implemented by making use of the OpenSSL library or the
21424 GnuTLS library (Exim requires GnuTLS release 1.0 or later). There is no
21425 cryptographic code in the Exim distribution itself for implementing TLS. In
21426 order to use this feature you must install OpenSSL or GnuTLS, and then build a
21427 version of Exim that includes TLS support (see section ~~SECTinctlsssl). You
21428 also need to understand the basic concepts of encryption at a managerial level,
21429 and in particular, the way that public keys, private keys, and certificates are
21430 used.
21431
21432 RFC 2487 defines how SMTP connections can make use of encryption. Once a
21433 connection is established, the client issues a \\STARTTLS\\ command. If the
21434 server accepts this, the client and the server negotiate an encryption
21435 mechanism. If the negotiation succeeds, the data that subsequently passes
21436 between them is encrypted.
21437
21438 Exim's ACLs can detect whether the current SMTP session is encrypted or not,
21439 and if so, what cipher suite is in use, whether the client supplied a
21440 certificate, and whether or not that certificate was verified. This makes it
21441 possible for an Exim server to deny or accept certain commands based on the
21442 encryption state.
21443
21444 \**Warning**\: certain types of firewall and certain anti-virus products can
21445 disrupt TLS connections. You need to turn off SMTP scanning for these products
21446 in order to get TLS to work.
21447
21448
21449 .em
21450 .section Support for the legacy `ssmtp' (aka `smtps') protocol
21451 .index ssmtp protocol
21452 .index smtps protocol
21453 .index SMTP||ssmtp protocol
21454 .index SMTP||smtps protocol
21455 Early implementations of encrypted SMTP used a different TCP port from normal
21456 SMTP, and expected an encryption negotiation to start immediately, instead of 
21457 waiting for a \\STARTTLS\\ command from the client using the standard SMTP 
21458 port. The protocol was called `ssmtp' or `smtps', and port 465 was allocated
21459 for this purpose.
21460
21461 This approach was abandoned when encrypted SMTP was standardised, but there are
21462 still some legacy clients that use it. Exim supports these clients by means of
21463 the \tls@_on@_connect@_ports\ global option. Its value must be a list of port
21464 numbers; the most common use is expected to be:
21465 .display asis
21466 tls_on_connect_ports = 465
21467 .endd
21468 The port numbers specified by this option apply to all SMTP connections, both
21469 via the daemon and via \*inetd*\. You still need to specify all the ports that
21470 the daemon uses (by setting \daemon@_smtp@_ports\ or \local@_interfaces\ or the
21471 \-oX-\ command line option) because \tls@_on@_connect@_ports\ does not add an
21472 extra port -- rather, it specifies different behaviour on a port that is
21473 defined elsewhere.
21474
21475 There is also a \-tls-on-connect-\ command line option. This overrides
21476 \tls@_on@_connect@_ports\; it forces the legacy behaviour for all ports.
21477 .nem
21478
21479
21480
21481
21482 .section OpenSSL vs GnuTLS
21483 .index TLS||OpenSSL \*vs*\ GnuTLS
21484 .rset SECTopenvsgnu "~~chapter.~~section"
21485 The first TLS support in Exim was implemented using OpenSSL. Support for GnuTLS
21486 followed later, when the first versions of GnuTLS were released. To build Exim
21487 to use GnuTLS, you need to set
21488 .display asis
21489 USE_GNUTLS=yes
21490 .endd
21491 in Local/Makefile, in addition to
21492 .display asis
21493 SUPPORT_TLS=yes
21494 .endd
21495 You must also set \\TLS@_LIBS\\ and \\TLS@_INCLUDE\\ appropriately, so that the
21496 include files and libraries for GnuTLS can be found.
21497
21498 There are some differences in usage when using GnuTLS instead of OpenSSL:
21499 .numberpars $.
21500 The \tls@_verify@_certificates\ option must contain the name of a file, not the
21501 name of a directory (for OpenSSL it can be either).
21502 .nextp
21503 The \tls@_dhparam\ option is ignored, because early versions of GnuTLS had no
21504 facility for varying its Diffie-Hellman parameters. I understand that this has
21505 changed, but Exim has not been updated to provide this facility.
21506 .nextp
21507 GnuTLS uses RSA and D-H parameters that take a substantial amount of
21508 time to compute. It is unreasonable to re-compute them for every TLS
21509 session. Therefore, Exim keeps this data in a file in its spool
21510 directory, called \(gnutls-params)\. The file is owned by the Exim user and is
21511 readable only by its owner. Every Exim process that start up GnuTLS reads the
21512 RSA and D-H parameters from this file. If the file does not exist, the first
21513 Exim process that needs it computes the data and writes it to a temporary file
21514 which is renamed once it is complete. It does not matter if several Exim
21515 processes do this simultaneously (apart from wasting a few resources). Once a
21516 file is in place, new Exim processes immediately start using it.
21517
21518 For maximum security, the parameters that are stored in this file should be
21519 recalculated periodically, the frequency depending on your paranoia level.
21520 Arranging this is easy; just delete the file when you want new values to be
21521 computed.
21522 .nextp
21523 Distinguished Name (DN) strings reported by the OpenSSL library use a slash for
21524 separating fields; GnuTLS uses commas, in accordance with RFC 2253. This
21525 affects the value of the \$tls@_peerdn$\ variable.
21526 .nextp
21527 OpenSSL identifies cipher suites using hyphens as separators, for example:
21528 DES-CBC3-SHA. GnuTLS uses underscores, for example: RSA@_ARCFOUR@_SHA. What is
21529 more, OpenSSL complains if underscores are present in a cipher list. To make
21530 life simpler, Exim changes underscores to hyhens for OpenSSL and hyphens to
21531 underscores for GnuTLS when processing lists of cipher suites in the
21532 \tls@_require@_ciphers\ options (the global option and the \%smtp%\ transport
21533 option).
21534 .nextp
21535 The \tls@_require@_ciphers\ options operate differently, as described in the
21536 following sections.
21537 .endp
21538
21539 .section Requiring specific ciphers in OpenSSL
21540 .rset SECTreqciphssl "~~chapter.~~section"
21541 .index TLS||requiring specific ciphers (OpenSSL)
21542 .index \tls@_require@_ciphers\||OpenSSL
21543 There is a function in the OpenSSL library that can be passed a list of cipher
21544 suites before the cipher negotiation takes place. This specifies which ciphers
21545 are acceptable. The list is colon separated and may contain names like
21546 DES-CBC3-SHA. Exim passes the expanded value of \tls@_require@_ciphers\
21547 directly to this function call. The following quotation from the OpenSSL
21548 documentation specifies what forms of item are allowed in the cipher string:
21549 .numberpars $.
21550 It can consist of a single cipher suite such as RC4-SHA.
21551 .nextp
21552 It can represent a list of cipher suites containing a certain algorithm,
21553 or cipher suites of a certain type. For example SHA1 represents all
21554 ciphers suites using the digest algorithm SHA1 and SSLv3 represents all
21555 SSL v3 algorithms.
21556 .nextp
21557 Lists of cipher suites can be combined in a single cipher string using
21558 the + character. This is used as a logical and operation. For example
21559 SHA1+DES represents all cipher suites containing the SHA1 and the DES
21560 algorithms.
21561 .nextp
21562 Each cipher string can be optionally preceded by the characters \"!"\, \"-"\ or
21563 \"+"\.
21564 .numberpars " "
21565 If \"!"\ is used then the ciphers are permanently deleted from the list. The
21566 ciphers deleted can never reappear in the list even if they are explicitly
21567 stated.
21568 .nextp
21569 If \"-"\ is used then the ciphers are deleted from the list, but some or all
21570 of the ciphers can be added again by later options.
21571 .nextp
21572 If \"+"\ is used then the ciphers are moved to the end of the list. This
21573 option doesn't add any new ciphers it just moves matching existing ones.
21574 .nextp
21575 If none of these characters is present then the string is just interpreted as a
21576 list of ciphers to be appended to the current preference list. If the list
21577 includes any ciphers already present they will be ignored: that is, they will
21578 not moved to the end of the list.
21579 .endp
21580 .endp
21581
21582
21583 .section Requiring specific ciphers in GnuTLS
21584 .rset SECTreqciphgnu "~~chapter.~~section"
21585 .index TLS||requiring specific ciphers (GnuTLS)
21586 .index \tls@_require@_ciphers\||GnuTLS
21587 The GnuTLS library does not have a combined function like OpenSSL. Instead,
21588 it allows the caller to specify separate lists of key-exchange methods,
21589 main cipher algorithms, and MAC algorithms. Unfortunately, these lists are
21590 numerical, and the library does not have a function for turning names into
21591 numbers. Consequently, the list of recognized names has to be built into
21592 the application.
21593
21594 At present, Exim permits only the list of main cipher algorithms to be
21595 changed. The \tls@_require@_ciphers\ option is in the same format as for
21596 OpenSSL. Exim searches each item for the name of available algorithm. For
21597 example, if the list contains RSA@_AES@_SHA then AES is recognized.
21598
21599 The cipher algorithms list starts out with a default set of algorithms. If
21600 the first item in \tls@_require@_ciphers\ does \*not*\ start with an
21601 exclamation mark, all the default items are deleted. Thus, only those specified
21602 can be used. If the first item in \tls@_require@_ciphers\ \*does*\ start with
21603 an exclamation mark, the defaults are left on the list.
21604
21605 Then, any item that starts with an exclamation mark causes the relevent
21606 algorithms to be removed from the list, and any item that does not start
21607 with an exclamation mark causes the relevant algorithms to be added to the
21608 list. Thus,
21609 .display asis
21610 tls_require_ciphers = !RSA_ARCFOUR_SHA
21611 .endd
21612 allows all the defaults except those that use ARCFOUR, whereas
21613 .display asis
21614 tls_require_ciphers = AES : 3DES
21615 .endd
21616 allows only cipher suites that use AES and 3DES. The currently recognized
21617 algorithms are: 
21618 .em
21619 AES@_256, AES@_128, AES (both of the preceding), 3DES, and ARCFOUR@_128.
21620 Unrecognized algorithms are ignored. In a server, the order of the list is 
21621 unimportant; the server will advertise the availability of all the relevant 
21622 cipher suites. However, in a client, the order of the list specifies a
21623 preference order for the algorithms. The first one in the client's list that is
21624 also advertised by the server is tried first. The default order is as listed
21625 above.
21626 .nem
21627
21628
21629 .section Configuring an Exim server to use TLS
21630 .index TLS||configuring an Exim server
21631 When Exim has been built with TLS support, it advertises the availability of
21632 the \\STARTTLS\\ command to client hosts that match \tls@_advertise@_hosts\,
21633 but not to any others. The default value of this option is unset, which means
21634 that \\STARTTLS\\ is not advertised at all. This default is chosen because you
21635 need to set some other options in order to make TLS avaliable, and also it is
21636 sensible for systems that want to use TLS only as a client.
21637
21638 If a client issues a \\STARTTLS\\ command and there is some configuration
21639 problem in the server, the command is rejected with a 454 error. If the client
21640 persists in trying to issue SMTP commands, all except \\QUIT\\ are rejected
21641 with the error
21642 .display asis
21643 554 Security failure
21644 .endd
21645 If a \\STARTTLS\\ command is issued within an existing TLS session, it is
21646 rejected with a 554 error code.
21647
21648 To enable TLS operations on a server, you must set \tls@_advertise@_hosts\ to
21649 match some hosts. You can, of course, set it to $*$ to match all hosts.
21650 However, this is not all you need to do. TLS sessions to a server won't work
21651 without some further configuration at the server end.
21652
21653 It is rumoured that all existing clients that support TLS/SSL use RSA
21654 encryption. To make this work you need to set, in the server,
21655 .display asis
21656 tls_certificate = /some/file/name
21657 tls_privatekey = /some/file/name
21658 .endd
21659 The first file contains the server's X509 certificate, and the second contains
21660 the private key that goes with it. These files need to be readable by the Exim
21661 user, and must always be given as full path names. They can be the same file if
21662 both the certificate and the key are contained within it. If \tls@_privatekey\
21663 is not set, this is assumed to be the case. The certificate file may also
21664 contain intermediate certificates that need to be sent to the client to enable
21665 it to authenticate the server's certificate.
21666
21667 If you do not understand about certificates and keys, please try to find a
21668 source of this background information, which is not Exim-specific. (There are a
21669 few comments below in section ~~SECTcerandall.)
21670
21671 \**Note**\: These options do not apply when Exim is operating as a client --
21672 they apply only in the case of a server. For a client, you must set the options
21673 of the same name in an \%smtp%\ transport.
21674
21675 With just these options, Exim will work as a server with clients such as
21676 Netscape. It does not require the client to have a certificate (but see below
21677 for how to insist on this). There is one other option that may be needed in
21678 other situations. If
21679 .display asis
21680 tls_dhparam = /some/file/name
21681 .endd
21682 is set, the SSL library is initialized for the use of Diffie-Hellman ciphers
21683 with the parameters contained in the file. This increases the set of cipher
21684 suites that the server supports. See the command
21685 .display asis
21686 openssl dhparam
21687 .endd
21688 for a way of generating this data.
21689 At present, \tls@_dhparam\ is used only when Exim is linked with OpenSSL. It is
21690 ignored if GnuTLS is being used.
21691
21692 The strings supplied for these three options are expanded every time a client
21693 host connects. It is therefore possible to use different certificates and keys
21694 for different hosts, if you so wish, by making use of the client's IP address
21695 in \$sender@_host@_address$\ to control the expansion. If a string expansion is
21696 forced to fail, Exim behaves as if the option is not set.
21697
21698 .index cipher||logging
21699 .index log||TLS cipher
21700 The variable \$tls@_cipher$\ is set to the cipher suite that was negotiated for
21701 an incoming TLS connection. It is included in the ::Received:: header of an
21702 incoming message (by default -- you can, of course, change this), and it is
21703 also included in the log line that records a message's arrival, keyed by `X=',
21704 unless the \tls@_cipher\ log selector is turned off.
21705 The \encrypted\ condition can be used to test for specific cipher suites in
21706 ACLs.
21707
21708 The ACLs that run for subsequent SMTP commands can check the name of the cipher
21709 suite and vary their actions accordingly. The cipher suite names are those used
21710 by OpenSSL. These may differ from the names used elsewhere. For example,
21711 OpenSSL uses the name DES-CBC3-SHA for the cipher suite which in other contexts
21712 is known as TLS@_RSA@_WITH@_3DES@_EDE@_CBC@_SHA. Check the OpenSSL
21713 documentation for more details.
21714
21715
21716 .section Requesting and verifying client certificates
21717 .index certificate||verification of client
21718 .index TLS||client certificate verification
21719 If you want an Exim server to request a certificate when negotiating a TLS
21720 session with a client, you must set either \tls@_verify@_hosts\ or
21721 \tls@_try@_verify@_hosts\. You can, of course, set either of them to $*$ to
21722 apply to all TLS connections. For any host that matches one of these options,
21723 Exim requests a certificate as part of the setup of the TLS session. The
21724 contents of the certificate are verified by comparing it with a list of
21725 expected certificates. These must be available in a file or,
21726 for OpenSSL only (not GnuTLS), a directory, identified by
21727 \tls@_verify@_certificates\.
21728
21729 A file can contain multiple certificates, concatenated end to end. If a
21730 directory is used
21731 (OpenSSL only),
21732 each certificate must be in a separate file, with a name (or a symbolic link)
21733 of the form <<hash>>.0, where <<hash>> is a hash value constructed from the
21734 certificate. You can compute the relevant hash by running the command
21735 .display asis
21736 openssl x509 -hash -noout -in /cert/file
21737 .endd
21738 where \(/cert/file)\ contains a single certificate.
21739
21740 The difference between \tls@_verify@_hosts\ and \tls@_try@_verify@_hosts\ is
21741 what happens if the client does not supply a certificate, or if the certificate
21742 does not match any of the certificates in the collection named by
21743 \tls@_verify@_certificates\. If the client matches \tls@_verify@_hosts\, the
21744 attempt to set up a TLS session is aborted, and the incoming connection is
21745 dropped. If the client matches \tls@_try@_verify@_hosts\, the (encrypted) SMTP
21746 session continues. ACLs that run for subsequent SMTP commands can detect the
21747 fact that no certificate was verified, and vary their actions accordingly. For
21748 example, you can insist on a certificate before accepting a message for
21749 relaying, but not when the message is destined for local delivery.
21750
21751 When a client supplies a certificate (whether it verifies or not), the value of
21752 the Distinguished Name of the certificate is made available in the variable
21753 \$tls@_peerdn$\ during subsequent processing of the message.
21754 .index log||distinguished name
21755 Because it is often a long text string, it is not included in the log line or
21756 ::Received:: header by default. You can arrange for it to be logged, keyed by
21757 `DN=', by setting the \tls@_peerdn\ log selector, and you can use
21758 \received@_header@_text\ to change the ::Received:: header. When no certificate
21759 is supplied, \$tls@_peerdn$\ is empty.
21760
21761 .section Revoked certificates
21762 .index TLS||revoked certificates
21763 .index revocation list
21764 .index certificate||revocation list
21765 Certificate issuing authorities issue Certificate Revocation Lists (CRLs) when
21766 certificates are revoked. If you have such a list, you can pass it to an Exim
21767 server using the global option called \tls@_crl\ and to an Exim client using an
21768 identically named option for the \%smtp%\ transport. In each case, the value of
21769 the option is expanded and must then be the name of a file that contains a CRL
21770 in PEM format.
21771
21772 .section Configuring an Exim client to use TLS
21773 .index cipher||logging
21774 .index log||TLS cipher
21775 .index log||distinguished name
21776 .index TLS||configuring an Exim client
21777 The \tls@_cipher\ and \tls@_peerdn\ log selectors apply to outgoing SMTP
21778 deliveries as well as to incoming, the latter one causing logging of the
21779 server certificate's DN. The remaining client configuration for TLS is all
21780 within the \%smtp%\ transport.
21781
21782 It is not necessary to set any options to have TLS work in the \%smtp%\
21783 transport. If Exim is built with TLS support, and TLS is advertised by a
21784 server, the \%smtp%\ transport always tries to start a TLS session. However,
21785 this can be prevented by setting \hosts@_avoid@_tls\ (an option of the
21786 transport) to a list of server hosts for which TLS should not be used.
21787
21788 If you do not want Exim to attempt to send messages unencrypted when an attempt
21789 to set up an encrypted connection fails in any way, you can set
21790 \hosts@_require@_tls\ to a list of hosts for which encryption is mandatory. For
21791 those hosts, delivery is always deferred if an encrypted connection cannot be
21792 set up. If there are any other hosts for the address, they are tried in the
21793 usual way.
21794
21795 When the server host is not in \hosts@_require@_tls\, Exim may try to deliver
21796 the message unencrypted. It always does this if the response to \\STARTTLS\\ is
21797 a 5\*xx*\ code. For a temporary error code, or for a failure to negotiate a TLS
21798 session after a success response code, what happens is controlled by the
21799 \tls@_tempfail@_tryclear\ option of the \%smtp%\ transport. If it is false,
21800 delivery to this host is deferred, and other hosts (if available) are tried. If
21801 it is true, Exim attempts to deliver unencrypted after a 4\*xx*\ response to
21802 \\STARTTLS\\, and if \\STARTTLS\\ is accepted, but the subsequent TLS
21803 negotiation fails, Exim closes the current connection (because it is in an
21804 unknown state), opens a new one to the same host, and then tries the delivery
21805 unencrypted.
21806
21807
21808 The \tls@_certificate\ and \tls@_privatekey\ options of the \%smtp%\ transport
21809 provide the client with a certificate, which is passed to the server if it
21810 requests it. If the server is Exim, it will request a certificate only if
21811 \tls@_verify@_hosts\ or \tls@_try@_verify@_hosts\ matches the client.
21812 \**Note**\: these options must be set in the \%smtp%\ transport for Exim to use
21813 TLS when it is operating as a client. Exim does not assume that a server
21814 certificate (set by the global options of the same name) should also be used
21815 when operating as a client.
21816
21817 If \tls@_verify@_certificates\ is set, it must name a file or,
21818 for OpenSSL only (not GnuTLS), a directory, that contains a collection of
21819 expected server certificates. The client verifies the server's certificate
21820 against this collection, taking into account any revoked certificates that are
21821 in the list defined by \tls@_crl\.
21822
21823 If
21824 \tls@_require@_ciphers\ is set on the \%smtp%\ transport, it must contain a
21825 list of permitted cipher suites. If either of these checks fails, delivery to
21826 the current host is abandoned, and the \%smtp%\ transport tries to deliver to
21827 alternative hosts, if any.
21828
21829 All the TLS options in the \%smtp%\ transport are expanded before use, with
21830 \$host$\ and \$host@_address$\ containing the name and address of the server to
21831 which the client is connected. Forced failure of an expansion causes Exim to
21832 behave as if the relevant option were unset.
21833
21834
21835 .section Multiple messages on the same encrypted TCP/IP connection
21836 .rset SECTmulmessam "~~chapter.~~section"
21837 .index multiple SMTP deliveries with TLS
21838 .index TLS||multiple message deliveries
21839 Exim sends multiple messages down the same TCP/IP connection by starting up
21840 an entirely new delivery process for each message, passing the socket from
21841 one process to the next. This implementation does not fit well with the use
21842 of TLS, because there is quite a lot of state information associated with a TLS
21843 connection, not just a socket identification. Passing all the state information
21844 to a new process is not feasible. Consequently, Exim shuts down an existing TLS
21845 session before passing the socket to a new process. The new process may then
21846 try to start a new TLS session, and if successful, may try to re-authenticate
21847 if \\AUTH\\ is in use, before sending the next message.
21848
21849 The RFC is not clear as to whether or not an SMTP session continues in clear
21850 after TLS has been shut down, or whether TLS may be restarted again later, as
21851 just described. However, if the server is Exim, this shutdown and
21852 reinitialization works. It is not known which (if any) other servers operate
21853 successfully if the client closes a TLS session and continues with unencrypted
21854 SMTP, but there are certainly some that do not work. For such servers, Exim
21855 should not pass the socket to another process, because the failure of the
21856 subsequent attempt to use it would cause Exim to record a temporary host error,
21857 and delay other deliveries to that host.
21858
21859 To test for this case, Exim sends an \\EHLO\\ command to the server after
21860 closing down the TLS session. If this fails in any way, the connection is
21861 closed instead of being passed to a new delivery process, but no retry
21862 information is recorded.
21863
21864 There is also a manual override; you can set \hosts@_nopass@_tls\ on the
21865 \%smtp%\ transport to match those hosts for which Exim should not pass
21866 connections to new processes if TLS has been used.
21867
21868
21869
21870 .section Certificates and all that
21871 .rset SECTcerandall "~~chapter.~~section"
21872 .index certificate||references to discussion
21873 In order to understand fully how TLS works, you need to know about
21874 certificates, certificate signing, and certificate authorities. This is not the
21875 place to give a tutorial, especially as I do not know very much about it
21876 myself. Some helpful introduction can be found in the FAQ for the SSL addition
21877 to Apache, currently at
21878 .display rm
21879 \?http://www.modssl.org/docs/2.7/ssl@_faq.html@#ToC24?\
21880 .endd
21881 Other parts of the \*modssl*\ documentation are also helpful, and have
21882 links to further files.
21883 Eric Rescorla's book, \*SSL and TLS*\, published by Addison-Wesley (ISBN
21884 0-201-61598-3), contains both introductory and more in-depth descriptions.
21885 Some sample programs taken from the book are available from
21886 .display rm
21887 \?http://www.rtfm.com/openssl-examples/?\
21888 .endd
21889
21890 .section Certificate chains
21891 The file named by \tls@_certificate\ may contain more than one
21892 certificate. This is useful in the case where the certificate that is being
21893 sent is validated by an intermediate certificate which the other end does
21894 not have. Multiple certificates must be in the correct order in the file.
21895 First the host's certificate itself, then the first intermediate
21896 certificate to validate the issuer of the host certificate, then the next
21897 intermediate certificate to validate the issuer of the first intermediate
21898 certificate, and so on, until finally (optionally) the root certificate.
21899 The root certificate must already be trusted by the recipient for
21900 validation to succeed, of course, but if it's not preinstalled, sending the
21901 root certificate along with the rest makes it available for the user to
21902 install if the receiving end is a client MUA that can interact with a user.
21903
21904 .section Self-signed certificates
21905 .index certificate||self-signed
21906 You can create a self-signed certificate using the \*req*\ command provided
21907 with OpenSSL, like this:
21908 .display asis
21909 openssl req -x509 -newkey rsa:1024 -keyout file1 -out file2 \
21910             -days 9999 -nodes
21911 .endd
21912 \(file1)\ and \(file2)\ can be the same file; the key and the certificate are
21913 delimited and so can be identified independently. The \-days-\ option
21914 specifies a period for which the certificate is valid. The \-nodes-\ option is
21915 important: if you do not set it, the key is encrypted with a passphrase
21916 that you are prompted for, and any use that is made of the key causes more
21917 prompting for the passphrase. This is not helpful if you are going to use
21918 this certificate and key in an MTA, where prompting is not possible.
21919
21920 A self-signed certificate made in this way is sufficient for testing, and
21921 may be adequate for all your requirements if you are mainly interested in
21922 encrypting transfers, and not in secure identification.
21923
21924 However, many clients require that the certificate presented by the server be a
21925 user (also called `leaf' or `site') certificate, and not a self-signed
21926 certificate. In this situation, the self-signed certificate described above
21927 must be installed on the client host as a trusted root \*certification
21928 authority*\ (CA), and the certificate used by Exim must be a user certificate
21929 signed with that self-signed certificate.
21930
21931 For information on creating self-signed CA certificates and using them to sign
21932 user certificates, see the \*General implementation overview*\ chapter of the
21933 Open-source PKI book, available online at \?http://ospkibook.sourceforge.net/?\.
21934
21935
21936
21937 .
21938 .
21939 .
21940 .
21941 . ============================================================================
21942 .chapter Access control lists
21943 .set runningfoot "ACL"
21944 .rset CHAPACL "~~chapter"
21945 .index ~~ACL||description
21946 .index control of incoming mail
21947 .index message||controlling incoming
21948 .index policy control||access control lists
21949 Access Control Lists (ACLs) are defined in a separate section of the run time
21950 configuration file, headed by `begin acl'. Each ACL definition starts with a
21951 name, terminated by a colon. Here is a complete ACL section that contains just
21952 one very small ACL:
21953 .display asis
21954 begin acl
21955
21956 small_acl:
21957   accept   hosts = one.host.only
21958 .endd
21959 You can have as many lists as you like in the ACL section, and the order in
21960 which they appear does not matter. The lists are self-terminating.
21961
21962 The majority of ACLs are used to control Exim's behaviour when it receives
21963 certain SMTP commands. This applies both to incoming TCP/IP connections, and
21964 when a local process submits a message using SMTP by specifying the \-bs-\
21965 option. The most common use is for controlling which recipients are accepted
21966 in incoming messages. In addition, you can define an ACL that is used to check
21967 local non-SMTP messages. The default configuration file contains an example of
21968 a realistic ACL for checking \\RCPT\\ commands. This is discussed in chapter
21969 ~~CHAPdefconfil.
21970
21971 .section Testing ACLs
21972 The \-bh-\ command line option provides a way of testing your ACL configuration
21973 locally by running a fake SMTP session with which you interact. The host
21974 \*relay-test.mail-abuse.org*\ provides a service for checking your relaying
21975 configuration (see section ~~SECTcheralcon for more details).
21976
21977
21978 .section Specifying when ACLs are used
21979 .index ~~ACL||options for specifying
21980 In order to cause an ACL to be used, you have to name it in one of the relevant
21981 options in the main part of the configuration. These options are:
21982 .index \\AUTH\\||ACL for
21983 .index \\DATA\\, ACLs for
21984 .index \\ETRN\\||ACL for
21985 .index \\EXPN\\||ACL for
21986 .index \\HELO\\||ACL for
21987 .index \\EHLO\\||ACL for
21988 .index \\MAIL\\||ACL for
21989 .index \\QUIT\\, ACL for
21990 .index \\RCPT\\||ACL for
21991 .index \\STARTTLS\\, ACL for
21992 .index \\VRFY\\||ACL for
21993 .index SMTP||connection, ACL for
21994 .index non-smtp message, ACL for
21995 .display
21996 .tabs 20
21997 .if !~~sys.fancy
21998 .tabs 24
21999 .fi
22000 \acl@_not@_smtp\      $t $rm{ACL for non-SMTP messages}
22001 \acl@_smtp@_auth\     $t $rm{ACL for \\AUTH\\}
22002 \acl@_smtp@_connect\  $t $rm{ACL for start of SMTP connection}
22003 \acl@_smtp@_data\     $t $rm{ACL after \\DATA\\ is complete}
22004 \acl@_smtp@_etrn\     $t $rm{ACL for \\ETRN\\}
22005 \acl@_smtp@_expn\     $t $rm{ACL for \\EXPN\\}
22006 \acl@_smtp@_helo\     $t $rm{ACL for \\HELO\\ or \\EHLO\\}
22007 \acl@_smtp@_mail\     $t $rm{ACL for \\MAIL\\}
22008 \acl@_smtp@_mailauth\ $t $rm{ACL for the \\AUTH\\ parameter of \\MAIL\\}
22009 .newline
22010 .em
22011 \acl@_smtp@_mime\     $t $rm{ACL for content-scanning MIME parts}
22012 \acl@_smtp@_predata\  $t $rm{ACL at start of \\DATA\\ command}
22013 \acl@_smtp@_quit\     $t $rm{ACL for \\QUIT\\}
22014 .nem
22015 .newline
22016 \acl@_smtp@_rcpt\     $t $rm{ACL for \\RCPT\\}
22017 \acl@_smtp@_starttls\ $t $rm{ACL for \\STARTTLS\\}
22018 \acl@_smtp@_vrfy\     $t $rm{ACL for \\VRFY\\}
22019 .endd
22020 For example, if you set
22021 .display asis
22022 acl_smtp_rcpt = small_acl
22023 .endd
22024 the little ACL defined above is used whenever Exim receives a \\RCPT\\ command
22025 in an SMTP dialogue. The majority of policy tests on incoming messages can be
22026 done when \\RCPT\\ commands arrive. A rejection of \\RCPT\\ should cause the
22027 sending MTA to give up on the recipient address contained in the \\RCPT\\
22028 command, whereas rejection at other times may cause the client MTA to keep on
22029 trying to deliver the message. It is therefore recommended that you do as much
22030 testing as possible at \\RCPT\\ time.
22031
22032 .section The non-SMTP ACL
22033 .index non-smtp message, ACL for
22034 The non-SMTP ACL applies to all non-interactive incoming messages, that is, it
22035 applies to batch SMTP as well as to non-SMTP messages. (Batch SMTP is not
22036 really SMTP.) This ACL is run just before the \*local@_scan()*\ function. Any
22037 kind of rejection is treated as permanent, because there is no way of sending a
22038 temporary error for these kinds of message. Many of the ACL conditions (for
22039 example, host tests, and tests on the state of the SMTP connection such as
22040 encryption and authentication) are not relevant and are forbidden in this ACL.
22041
22042 .section The connect ACL
22043 .index SMTP||connection, ACL for
22044 The ACL test specified by \acl@_smtp@_connect\ happens after the test specified
22045 by \host__reject__connection\ (which is now an anomaly) and any TCP Wrappers
22046 testing (if configured).
22047
22048 .em
22049 .section The DATA ACLs
22050 .index \\DATA\\, ACLs for
22051 Two ACLs are associated with the \\DATA\\ command, because it is two-stage 
22052 command, with two responses being sent to the client.
22053 When the \\DATA\\ command is received, the ACL defined by \acl@_smtp@_predata\
22054 is obeyed. This gives you control after all the \\RCPT\\ commands, but before
22055 the message itself is received. It offers the opportunity to give a negative
22056 response to the \\DATA\\ command before the data is transmitted. Header lines
22057 added by \\MAIL\\ or \\RCPT\\ ACLs are not visible at this time, but any that
22058 are defined here are visible when the \acl@_smtp@_data\ ACL is run.
22059
22060 You cannot test the contents of the message, for example, to verify addresses
22061 in the headers, at \\RCPT\\ time or when the \\DATA\\ command is received. Such
22062 tests have to appear in the ACL that is run after the message itself has been
22063 received, before the final response to the \\DATA\\ command is sent. This is
22064 the ACL specified by \acl@_smtp@_data\, which is the second ACL that is
22065 associated with the \\DATA\\ command.
22066
22067 For both of these ACLs, it is not possible to reject individual recipients. An
22068 error response rejects the entire message. Unfortunately, it is known that some
22069 MTAs do not treat hard (5$it{xx}) responses to the \\DATA\\ command (either 
22070 before or after the data) correctly -- they keep the message on their queues
22071 and try again later, but that is their problem, though it does waste some of
22072 your resources.
22073
22074 .section The MIME ACL
22075 The \acl@_smtp@_mime\ option is available only when Exim is compiled with the
22076 content-scanning extension. For details, see chapter ~~CHAPexiscan.
22077
22078 .section The QUIT ACL
22079 .rset SECTQUITACL "~~chapter.~~section"
22080 .index \\QUIT\\, ACL for
22081 The ACL for the SMTP \\QUIT\\ command is anomalous, in that the
22082 outcome of the ACL does not affect the response code to \\QUIT\\,
22083 which is always 221. Thus, the ACL does not in fact control any access.
22084 For this reason, the only verbs that are permitted are \accept\ and \warn\.
22085
22086 This ACL can be used for tasks such as custom logging at the end of an SMTP
22087 session. For example, you can use ACL variables in other ACLs to count
22088 messages, recipients, etc., and log the totals at \\QUIT\\ time using one or
22089 more \logwrite\ modifiers on a \warn\ verb.
22090
22091 You do not need to have a final \accept\, but if you do, you can use a
22092 \message\ modifier to specify custom text that is sent as part of the 221
22093 response to \\QUIT\\.
22094
22095 This ACL is run only for a `normal' \\QUIT\\. For certain kinds of disastrous
22096 failure (for example, failure to open a log file, or when Exim is bombing out
22097 because it has detected an unrecoverable error), all SMTP commands from the
22098 client are given temporary error responses until \\QUIT\\ is received or the
22099 connection is closed. In these special cases, the \\QUIT\\ ACL does not run.
22100 .nem
22101
22102 .section Finding an ACL to use
22103 .index ~~ACL||finding which to use
22104 The value of an \acl@_smtp@_$it{xxx}\ option is expanded before use, so you can
22105 use different ACLs in different circumstances. The resulting string does not
22106 have to be the name of an ACL in the configuration file; there are other
22107 possibilities. Having expanded the string, Exim searches for an ACL as follows:
22108 .numberpars $.
22109 If the string begins with a slash, Exim uses it as a file name, and reads its
22110 contents as an ACL. The lines are processed in the same way as lines in the
22111 Exim configuration file. In particular, continuation lines are supported, blank
22112 lines are ignored, as are lines whose first non-whitespace character is `@#'.
22113 If the file does not exist or cannot be read, an error occurs (typically
22114 causing a temporary failure of whatever caused the ACL to be run). For example:
22115 .display asis
22116 acl_smtp_data = /etc/acls/\
22117   ${lookup{$sender_host_address}lsearch\
22118   {/etc/acllist}{$value}{default}}
22119 .endd
22120 This looks up an ACL file to use on the basis of the host's IP address, falling
22121 back to a default if the lookup fails. If an ACL is successfully read from a
22122 file, it is retained in memory for the duration of the Exim process, so that it
22123 can be re-used without having to re-read the file.
22124 .nextp
22125 If the string does not start with a slash, and does not contain any spaces,
22126 Exim searches the ACL section of the configuration for an ACL whose name
22127 matches the string.
22128 .nextp
22129 If no named ACL is found, or if the string contains spaces, Exim parses
22130 the string as an inline ACL. This can save typing in cases where you just
22131 want to have something like
22132 .display asis
22133 acl_smtp_vrfy = accept
22134 .endd
22135 in order to allow free use of the \\VRFY\\ command. Such a string may contain
22136 newlines; it is processed in the same way as an ACL that is read from a file.
22137 .endp
22138
22139
22140 .section ACL return codes
22141 .index ~~ACL||return codes
22142 .em
22143 Except for the \\QUIT\\ ACL, which does not affect the SMTP return code (see
22144 section ~~SECTQUITACL above), the
22145 .nem
22146 result of running an ACL is either `accept' or `deny', or, if some test
22147 cannot be completed (for example, if a database is down), `defer'. These
22148 results cause 2$it{xx}, 5$it{xx}, and 4$it{xx} return codes, respectively, to
22149 be used in the SMTP dialogue. A fourth return, `error', occurs when there is an
22150 error such as invalid syntax in the ACL. This also causes a 4$it{xx} return
22151 code.
22152
22153 .em
22154 For the non-SMTP ACL, `defer' and `error' are treated in the same way as
22155 `deny', because there is no mechanism for passing temporary errors to the
22156 submitters of non-SMTP messages.
22157 .nem
22158
22159 ACLs that are relevant to message reception may also return `discard'. This
22160 has the effect of `accept', but causes either the entire message or an
22161 individual recipient address to be discarded. In other words, it is a
22162 blackholing facility. Use it with care.
22163
22164 If the ACL for \\MAIL\\ returns `discard', all recipients are discarded, and no
22165 ACL is run for subsequent \\RCPT\\ commands. The effect of `discard' in a
22166 \\RCPT\\ ACL is to discard just the one recipient address. If there are no
22167 recipients left when the message's data is received, the \\DATA\\ ACL is not
22168 run. A `discard' return from the \\DATA\\ or the non-SMTP ACL discards all the
22169 remaining recipients.
22170 .em
22171 The `discard' return is not permitted for the \acl@_smtp@_predata\ ACL.
22172 .nem
22173
22174 .index \*local@_scan()*\ function||when all recipients discarded
22175 The \*local@_scan()*\ function is always run, even if there are no remaining
22176 recipients; it may create new recipients.
22177
22178
22179 .section Unset ACL options
22180 .index ~~ACL||unset options
22181 The default actions when any of the \acl@_$it{xxx}\ options are unset are not
22182 all the same. \**Note**\: These defaults apply only when the relevant ACL is
22183 not defined at all. For any defined ACL, the default action when control reaches
22184 the end of the ACL statements is `deny'.
22185
22186 For \acl@_not@_smtp\, \acl@_smtp@_auth\, \acl@_smtp@_connect\,
22187 \acl@_smtp@_data\, \acl@_smtp@_helo\, \acl__smtp__mail\, \acl@_smtp@_mailauth\,
22188 .em
22189 \acl@_smtp@_mime\, \acl@_smtp@_predata\, \acl@_smtp@_quit\,
22190 .nem
22191 and \acl__smtp__starttls\, the action when the ACL is not defined is `accept'.
22192
22193 For the others (\acl@_smtp@_etrn\, \acl@_smtp@_expn\, \acl@_smtp@_rcpt\, and
22194 \acl@_smtp@_vrfy\), the action when the ACL is not defined is `deny'.
22195 This means that \acl@_smtp@_rcpt\ must be defined in order to receive any
22196 messages over an SMTP connection. For an example, see the ACL in the default
22197 configuration file.
22198
22199
22200
22201 .section Data for message ACLs
22202 .index ~~ACL||data for message ACL
22203 .em
22204 When a \\MAIL\\ or \\RCPT\\ ACL, or either of the \\DATA\\ ACLs, is running,
22205 the variables that contain information about the host and the message's sender
22206 (for example, \$sender@_host@_address$\ and \$sender@_address$\) are set, and
22207 can be used in ACL statements. In the case of \\RCPT\\ (but not \\MAIL\\ or
22208 \\DATA\\), \$domain$\ and \$local@_part$\ are set from the argument address.
22209
22210 When an ACL for the \\AUTH\\ parameter of \\MAIL\\ is running, the variables
22211 that contain information about the host are set, but \$sender@_address$\ is not
22212 yet set. Section ~~SECTauthparamail contains a discussion of this parameter and
22213 how it is used.
22214
22215 The \$message@_size$\ variable is set to the value of the \\SIZE\\ parameter on
22216 the \\MAIL\\ command at \\MAIL\\, \\RCPT\\ and pre-data time, or to -1 if
22217 that parameter is not given. The value is updated to the true message size by
22218 the time the final \\DATA\\ ACL is run (after the message data has been
22219 received).
22220
22221 The \$rcpt@_count$\ variable increases by one for each \\RCPT\\ command
22222 received. The \$recipients@_count$\ variable increases by one each time a
22223 \\RCPT\\ command is accepted, so while an ACL for \\RCPT\\ is being processed,
22224 it contains the number of previously accepted recipients. At \\DATA\\ time (for
22225 both the \\DATA\\ ACLs), \$rcpt@_count$\ contains the total number of \\RCPT\\
22226 commands, and \$recipients@_count$\ contains the total number of accepted
22227 recipients.
22228 .nem
22229
22230
22231
22232 .section Data for non-message ACLs
22233 .rset SECTdatfornon "~~chapter.~~section"
22234 .index ~~ACL||data for non-message ACL
22235 .em
22236 When an ACL is being run for \\AUTH\\, \\EHLO\\, \\ETRN\\, \\EXPN\\, \\HELO\\,
22237 .nem
22238 \\STARTTLS\\, or \\VRFY\\, the remainder of the SMTP command line is placed in
22239 \$smtp@_command@_argument$\. This can be tested using a \condition\ condition.
22240 For example, here is an ACL for use with \\AUTH\\, which insists that either
22241 the session is encrypted, or the CRAM-MD5 authentication method is used. In
22242 other words, it does not permit authentication methods that use cleartext
22243 passwords on unencrypted connections.
22244 .display asis
22245 acl_check_auth:
22246   accept encrypted = *
22247 .newline
22248 .em
22249   accept condition = ${if eq{${uc:$smtp_command_argument}}\
22250                      {CRAM-MD5}}
22251 .nem
22252 .newline
22253   deny   message   = TLS encryption or CRAM-MD5 required
22254 .endd
22255 (Another way of applying this restriction is to arrange for the authenticators
22256 that use cleartext passwords not to be advertised when the connection is not
22257 encrypted. You can use the generic \server@_advertise@_condition\ authenticator
22258 option to do this.)
22259
22260
22261 .section Format of an ACL
22262 .index ~~ACL||format of
22263 .index ~~ACL||verbs, definition of
22264 An individual ACL consists of a number of statements. Each statement starts
22265 with a verb, optionally followed by a number of conditions and `modifiers'.
22266 .em
22267 Modifiers can change the way the verb operates, define error and log messages,
22268 set variables, insert delays, and vary the processing of accepted messages.
22269 .nem
22270
22271 If all the conditions are met, the verb is obeyed. The same condition may be
22272 used (with different arguments) more than once in the same statement. This
22273 provides a means of specifying an `and' conjunction between conditions. For
22274 example:
22275 .display asis
22276 deny  dnslists = list1.example
22277       dnslists = list2.example
22278 .endd
22279 If there are no conditions, the verb is always obeyed.
22280 .em
22281 Exim stops evaluating the conditions and modifiers when it reaches a condition
22282 that fails. What happens then
22283 .nem
22284 depends on the verb (and in one case, on a special modifier). Not all the
22285 conditions make sense at every testing point. For example, you cannot test a
22286 sender address in the ACL that is run for a \\VRFY\\ command.
22287
22288 .section ACL verbs
22289 The ACL verbs are as follows:
22290 .numberpars $.
22291 .index \accept\, ACL verb
22292 \accept\: If all the conditions are met, the ACL returns `accept'. If any of
22293 the conditions are not met, what happens depends on whether \endpass\ appears
22294 among the conditions (for syntax see below). If the failing condition is before
22295 \endpass\, control is passed to the next ACL statement; if it is after
22296 \endpass\, the ACL returns `deny'. Consider this statement, used to check a
22297 \\RCPT\\ command:
22298 .display asis
22299 accept domains = +local_domains
22300        endpass
22301        verify = recipient
22302 .endd
22303 If the recipient domain does not match the \domains\ condition, control passes
22304 to the next statement. If it does match, the recipient is verified, and the
22305 command is accepted if verification succeeds. However, if verification fails,
22306 the ACL yields `deny', because the failing condition is after \endpass\.
22307 .nextp
22308 .index \defer\, ACL verb
22309 \defer\: If all the conditions are met, the ACL returns `defer' which, in an
22310 SMTP session, causes a 4\*xx*\ response to be given. For a non-SMTP ACL,
22311 \defer\ is the same as \deny\, because there is no way of sending a temporary
22312 error. For a \\RCPT\\ command, \defer\ is much the same as using a
22313 \%redirect%\ router and \":defer:"\ while verifying, but the \defer\ verb can
22314 be used in any ACL, and even for a recipient it might be a simpler approach.
22315 .nextp
22316 .index \deny\, ACL verb
22317 \deny\: If all the conditions are met, the ACL returns `deny'. If any of the
22318 conditions are not met, control is passed to the next ACL statement. For
22319 example,
22320 .display asis
22321 deny dnslists = blackholes.mail-abuse.org
22322 .endd
22323 rejects commands from hosts that are on a DNS black list.
22324 .nextp
22325 .index \discard\, ACL verb
22326 \discard\: This verb behaves like \accept\, except that it returns `discard'
22327 from the ACL instead of `accept'. It is permitted only on ACLs that are
22328 concerned with receiving messages, and it causes recipients to be discarded.
22329 If the \log@_message\ modifier is set when \discard\ operates, its contents are
22330 added to the line that is automatically written to the log.
22331
22332 If \discard\ is used in an ACL for \\RCPT\\, just the one recipient is
22333 discarded; if used for \\MAIL\\, \\DATA\\ or in the non-SMTP ACL, all the
22334 message's recipients are discarded. Recipients that are discarded before
22335 \\DATA\\ do not appear in the log line when the \log@_recipients\ log selector
22336 is set.
22337 .nextp
22338 .index \drop\, ACL verb
22339 \drop\: This verb behaves like \deny\, except that an SMTP connection is
22340 forcibly closed after the 5\*xx*\ error message has been sent. For example:
22341 .display asis
22342 drop   message   = I don't take more than 20 RCPTs
22343 .newline
22344 .em
22345        condition = ${if > {$rcpt_count}{20}}
22346 .nem
22347 .endd
22348 There is no difference between \deny\ and \drop\ for the connect-time ACL. The
22349 connection is always dropped after sending a 550 response.
22350 .nextp
22351 .index \require\, ACL verb
22352 \require\: If all the conditions are met, control is passed to the next ACL
22353 statement. If any of the conditions are not met, the ACL returns `deny'. For
22354 example, when checking a \\RCPT\\ command,
22355 .display asis
22356 require verify = sender
22357 .endd
22358 passes control to subsequent statements only if the message's sender can be
22359 verified. Otherwise, it rejects the command.
22360 .nextp
22361 .index \warn\, ACL verb
22362 \warn\: If all the conditions are met, a header line is added to an incoming
22363 message and/or a line is written to Exim's main log. In all cases, control
22364 passes to the next ACL statement. The text of the added header line and the log
22365 line are specified by modifiers; if they are not present, a \warn\ verb just
22366 checks its conditions and obeys any `immediate' modifiers such as \set\ and
22367 \logwrite\.
22368 .em
22369 There is more about adding header lines in section ~~SECTaddheadwarn.
22370 .nem
22371
22372 If any condition on a \warn\ statement cannot be completed (that is, there is
22373 some sort of defer), no header lines are added and the configured log line is
22374 not written. No further conditions or modifiers in the \warn\ statement are
22375 processed. The incident is logged, but the ACL continues to be processed, from
22376 the next statement onwards.
22377
22378 If a \message\ modifier is present on a \warn\ verb in an ACL that is not
22379 testing an incoming message, it is ignored, and the incident is logged.
22380
22381 A \warn\ statement may use the \log@_message\ modifier to cause a line to be
22382 written to the main log when the statement's conditions are true.
22383 If an identical log line is requested several times in the same message, only
22384 one copy is actually written to the log. If you want to force duplicates to be
22385 written, use the \logwrite\ modifier instead.
22386
22387 When one of the \warn\ conditions is an address verification that fails, the
22388 text of the verification failure message is in \$acl@_verify@_message$\. If you
22389 want this logged, you must set it up explicitly. For example:
22390 .display asis
22391 warn   !verify = sender
22392         log_message = sender verify failed: $acl_verify_message
22393 .endd
22394 .endp
22395
22396 At the end of each ACL there is an implicit unconditional \deny\.
22397
22398 As you can see from the examples above, the conditions and modifiers are
22399 written one to a line, with the first one on the same line as the verb, and
22400 subsequent ones on following lines. If you have a very long condition, you can
22401 continue it onto several physical lines by the usual backslash continuation
22402 mechanism. It is conventional to align the conditions vertically.
22403
22404
22405 .section ACL variables
22406 .rset SECTaclvariables "~~chapter.~~section"
22407 .index ~~ACL||variables
22408 There are some special variables that can be set during ACL processing. They
22409 can be used to pass information between different ACLs, different invocations
22410 of the same ACL in the same SMTP connection, and between ACLs and the routers,
22411 transports, and filters that are used to deliver a message. There are two sets
22412 of these variables:
22413 .numberpars $.
22414 The values of \$acl@_c0$\ to \$acl@_c9$\ persist throughout an SMTP connection.
22415 They are never reset. Thus, a value that is set while receiving one message is
22416 still available when receiving the next message on the same SMTP connection.
22417 .nextp
22418 The values of \$acl@_m0$\ to \$acl@_m9$\ persist only while a message is being
22419 received. They are reset afterwards. They are also reset by \\MAIL\\, \\RSET\\,
22420 \\EHLO\\, \\HELO\\, and after starting up a TLS session.
22421 .endp
22422 When a message is accepted, the current values of all the ACL variables are
22423 preserved with the message and are subsequently made available at delivery
22424 time. The ACL variables are set by modifier called \set\. For example:
22425 .display asis
22426 accept hosts = whatever
22427        set acl_m4 = some value
22428 .endd
22429 \**Note**\: a leading dollar sign is not used when naming a variable that is to
22430 be set. If you want to set a variable without taking any action, you can use a
22431 \warn\ verb without any other modifiers or conditions.
22432
22433
22434 .section Condition and modifier processing
22435 .index ~~ACL||conditions, processing
22436 .index ~~ACL||modifiers, processing
22437 An exclamation mark preceding a condition negates its result. For example,
22438 .display asis
22439 deny   domains = *.dom.example
22440       !verify = recipient
22441 .endd
22442 causes the ACL to return `deny' if the recipient domain ends in
22443 \*dom.example*\ and the recipient address cannot be verified.
22444
22445 The arguments of conditions and modifiers are expanded. A forced failure
22446 of an expansion causes a condition to be ignored, that is, it behaves as if the
22447 condition is true. Consider these two statements:
22448 .display asis
22449 accept  senders = ${lookup{$host_name}lsearch\
22450                   {/some/file}{$value}fail}
22451 accept  senders = ${lookup{$host_name}lsearch\
22452                   {/some/file}{$value}{}}
22453 .endd
22454 Each attempts to look up a list of acceptable senders. If the lookup succeeds,
22455 the returned list is searched, but if the lookup fails the behaviour is
22456 different in the two cases. The \fail\ in the first statement causes the
22457 condition to be ignored, leaving no further conditions. The \accept\ verb
22458 therefore succeeds. The second statement, however, generates an empty list when
22459 the lookup fails. No sender can match an empty list, so the condition fails,
22460 and therefore the \accept\ also fails.
22461
22462 ACL modifiers appear mixed in with conditions in ACL statements. Some of them
22463 specify actions that are taken as the conditions for a statement are checked;
22464 others specify text for messages that are used when access is denied or a
22465 warning is generated.
22466 .em
22467 The \control\ modifier affects the way an incoming message is handled.
22468 .nem
22469
22470 The positioning of the modifiers in an ACL statement important, because the
22471 processing of a verb ceases as soon as its outcome is known. Only those
22472 modifiers that have already been encountered will take effect. For example,
22473 consider this use of the \message\ modifier:
22474 .display asis
22475 require message = Can't verify sender
22476         verify = sender
22477         message = Can't verify recipient
22478         verify = recipient
22479         message = This message cannot be used
22480 .endd
22481 If sender verification fails, Exim knows that the result of the statement is
22482 `deny', so it goes no further. The first \message\ modifier has been seen, so
22483 its text is used as the error message. If sender verification succeeds, but
22484 recipient verification fails, the second message is used. If recipient
22485 verification succeeds, the third message becomes `current', but is never used
22486 because there are no more conditions to cause failure.
22487
22488 For the \deny\ verb, on the other hand, it is always the last \message\
22489 modifier that is used, because all the conditions must be true for rejection to
22490 happen. Specifying more than one \message\ modifier does not make sense, and
22491 the message can even be specified after all the conditions. For example:
22492 .display asis
22493 deny   hosts = ...
22494       !senders = *@my.domain.example
22495        message = Invalid sender from client host
22496 .endd
22497 The `deny' result does not happen until the end of the statement is reached, by
22498 which time Exim has set up the message.
22499
22500
22501 .section ACL modifiers
22502 .rset SECTACLmodi "~~chapter.~~section"
22503 .index ~~ACL||modifiers, list of
22504 The ACL modifiers are as follows:
22505
22506 .startitems
22507
22508 .item "control = <<text>>"
22509 .index \control\, ACL modifier
22510 .em
22511 This modifier affects the subsequent processing of the SMTP connection or of an
22512 incoming message that is accepted. The effect of the first type of control
22513 lasts for the duration of the connection, whereas the effect of the second type
22514 lasts only until the current message has been received. The message-specific
22515 controls always apply to the whole message, not to individual recipients,
22516 even if the \control\ modifier appears in a \\RCPT\\ ACL.
22517
22518 As there are now quite a few controls that can be applied, they are described
22519 separately in section ~~SECTcontrols.
22520 .nem
22521 The \control\ modifier can be used in several different ways. For example:
22522 .numberpars $.
22523 It can be at the end of an \accept\ statement:
22524 .display asis
22525 accept  ...some conditions
22526         control = queue_only
22527 .endd
22528 In this case, the control is applied when this statement yields `accept', in
22529 other words, when the conditions are all true.
22530 .nextp
22531 It can be in the middle of an \accept\ statement:
22532 .display asis
22533 accept  ...some conditions...
22534         control = queue_only
22535         ...some more conditions...
22536 .endd
22537 If the first set of conditions are true, the control is applied, even if the
22538 statement does not accept because one of the second set of conditions is false.
22539 In this case, some subsequent statement must yield `accept' for the control to
22540 be relevant.
22541 .nextp
22542 It can be used with \warn\ to apply the control, leaving the
22543 decision about accepting or denying to a subsequent verb. For
22544 example:
22545 .display asis
22546 warn    ...some conditions...
22547         control = freeze
22548 accept  ...
22549 .endd
22550 This example of \warn\ does not contain \message\, \log@_message\, or
22551 \logwrite\, so it does not add anything to the message and does not write a log
22552 entry.
22553 .nextp
22554 .em
22555 If you want to apply a control unconditionally, you can use it with a \require\ 
22556 verb. For example:
22557 .display asis
22558 require  control = no_multiline_response
22559 .nem
22560 .endd
22561 .endp
22562
22563 .item "delay = <<time>>"
22564 .index \delay\, ACL modifier
22565 .index \-bh-\ option
22566 This modifier causes Exim to wait for the time interval before proceeding. The
22567 time is given in the usual Exim notation. This modifier may appear in any ACL.
22568 The delay happens as soon as the modifier is processed. However, when testing
22569 Exim using the \-bh-\ option, the delay is not actually imposed (an appropriate
22570 message is output instead).
22571
22572 Like \control\, \delay\ can be used with \accept\ or
22573 \deny\, for example:
22574 .display asis
22575 deny    ...some conditions...
22576         delay = 30s
22577 .endd
22578 The delay happens if all the conditions are true, before the statement returns
22579 `deny'. Compare this with:
22580 .display asis
22581 deny    delay = 30s
22582         ...some conditions...
22583 .endd
22584 which waits for 30s before processing the conditions. The \delay\ modifier can
22585 also be used with \warn\ and together with \control\:
22586 .display
22587 warn    ...some conditions...
22588         delay = 2m
22589         control = freeze
22590 accept  ...
22591 .endd
22592
22593 .item endpass
22594 .index \endpass\, ACL modifier
22595 This modifier, which has no argument, is recognized only in \accept\
22596 statements. It marks the boundary between the conditions whose failure causes
22597 control to pass to the next statement, and the conditions whose failure causes
22598 the ACL to return `deny'. See the description of \accept\ above.
22599
22600 .item "log@_message = <<text>>"
22601 .index \log@_message\, ACL modifier
22602 This modifier sets up a message that is used as part of the log message if the
22603 ACL denies access or a \warn\ statement's conditions are true. For example:
22604 .display asis
22605 require log_message = wrong cipher suite $tls_cipher
22606         encrypted   = DES-CBC3-SHA
22607 .endd
22608 \log@_message\ adds to any underlying error message that may exist because of
22609 the condition failure. For example, while verifying a recipient address, a
22610 :::fail:: redirection might have already set up a message. Although the message
22611 is usually defined before the conditions to which it applies, the expansion
22612 does not happen until Exim decides that access is to be denied. This means that
22613 any variables that are set by the condition are available for inclusion in the
22614 message. For example, the \$dnslist@_<<xxx>>$\ variables are set after a DNS
22615 black list lookup succeeds. If the expansion of \log@_message\ fails, or if the
22616 result is an empty string, the modifier is ignored.
22617
22618 If you want to use a \warn\ statement to log the result of an address
22619 verification, you can use \$acl__verify__message$\ to include the verification
22620 error message.
22621
22622 If \log@_message\ is used with a \warn\ statement, `Warning:' is added to the
22623 start of the logged message. If the same warning log message is requested more
22624 than once while receiving  a single email message, only one copy is actually
22625 logged. If you want to log multiple copies, use \logwrite\ instead of
22626 \log@_message\. In the absence of \log@_message\ and \logwrite\, nothing is
22627 logged for a succesful \warn\ statement.
22628
22629 If \log@_message\ is not present and there is no underlying error message (for
22630 example, from the failure of address verification), but \message\ is present,
22631 the \message\ text is used for logging rejections. However, if any text for
22632 logging contains newlines, only the first line is logged. In the absence of
22633 both \log@_message\ and \message\, a default built-in message is used for
22634 logging rejections.
22635
22636 .item "logwrite = <<text>>"
22637 .index \logwrite\, ACL modifier
22638 .index log||in ACL, immediate
22639 This modifier writes a message to a log file as soon as it is encountered when
22640 processing an ACL. (Compare \log@_message\, which, except in the case of
22641 \warn\, is used only if the ACL statement denies access.) The \logwrite\
22642 modifier can be used to log special incidents in ACLs. For example:
22643 .display
22644 accept <<some special conditions>>
22645        control  = freeze
22646        logwrite = froze message because ...
22647 .endd
22648 By default, the message is written to the main log. However, it may begin
22649 with a colon, followed by a comma-separated list of log names, and then
22650 another colon, to specify exactly which logs are to be written. For
22651 example:
22652 .display asis
22653 logwrite = :main,reject: text for main and reject logs
22654 logwrite = :panic: text for panic log only
22655 .endd
22656
22657 .item "message = <<text>>"
22658 .index \message\, ACL modifier
22659 This modifier sets up a text string that is expanded and used as an error
22660 message if the current statement causes the ACL to deny access. The expansion
22661 happens at the time Exim decides that access is to be denied, not at the time
22662 it processes \message\. If the expansion fails, or generates an empty string,
22663 the modifier is ignored. For ACLs that are triggered by SMTP commands, the
22664 message is returned as part of the SMTP error response.
22665
22666 The \message\ modifier is also used with the \warn\ verb to specify one or more
22667 header lines to be added to an incoming message when all the conditions are
22668 true. See section ~~SECTaddheadwarn for more details. If \message\ is used with
22669 \warn\ in an ACL that is not concerned with receiving a message, it has no
22670 effect.
22671
22672 The text is literal; any quotes are taken as literals, but because the string
22673 is expanded, backslash escapes are processed anyway. If the message contains
22674 newlines, this gives rise to a multi-line SMTP response. Like \log@_message\,
22675 the contents of \message\ are not expanded until after a condition has failed.
22676
22677 If \message\ is used on a statement that verifies an address, the message
22678 specified overrides any message that is generated by the verification process.
22679 However, the original message is available in the variable
22680 \$acl@_verify@_message$\, so you can incorporate it into your message if you
22681 wish. In particular, if you want the text from \:fail:\ items in \%redirect%\
22682 routers to be passed back as part of the SMTP response, you should either not
22683 use a \message\ modifier, or make use of \$acl@_verify@_message$\.
22684
22685 .item "set <<acl@_name>> = <<value>>"
22686 .index \set\, ACL modifier
22687 This modifier puts a value into one of the ACL variables (see section
22688 ~~SECTaclvariables).
22689
22690 .enditems
22691
22692
22693 .em
22694 .section Use of the control modifier
22695 .rset SECTcontrols "~~chapter.~~section"
22696 .index \control\, ACL modifier
22697 The \control\ modifier supports the following settings:
22698
22699 .startitems
22700
22701 .item "control = caseful@_local@_part"
22702 .item "control = caselower@_local@_part"
22703 .index ~~ACL||case of local part in
22704 .index case of local parts
22705 These two controls are permitted only in the ACL specified by \acl@_smtp@_rcpt\
22706 (that is, during \\RCPT\\ processing). By default, the contents of
22707 \$local@_part$\ are lower cased before ACL processing. If
22708 `caseful@_local@_part' is specified, any uppercase letters in the original
22709 local part are restored in \$local@_part$\ for the rest of the ACL, or until a
22710 control that sets `caselower@_local@_part' is encountered. 
22711
22712 This control affects only the current recipient. Moreover, it applies only to
22713 local part handling that takes place directly in the ACL (for example, as a key
22714 in lookups). If a test to verify the recipient is obeyed, the case-related
22715 handling of the local part during the verification is controlled by the router
22716 configuration (see the \caseful@_local@_part\ generic router option).
22717
22718 This facility could be used, for example, to add a spam score to local parts
22719 containing upper case letters. For example, using \$acl@_m4$\ to accumulate the
22720 spam score:
22721 .display asis
22722 warn  control = caseful_local_part
22723       set acl_m4 = ${eval:\
22724                      $acl_m4 + \
22725                      ${if match{$local_part}{[A-Z]}{1}{0}}\
22726                     }
22727       control = caselower_local_part
22728 .endd
22729 Notice that we put back the lower cased version afterwards, assuming that
22730 is what is wanted for subsequent tests.
22731
22732 .item "control = enforce@_sync"
22733 .item "control = no@_enforce@_sync"
22734 .index SMTP||synchronization checking
22735 .index synchronization checking in SMTP
22736 These controls make it possible to be selective about when SMTP synchronization
22737 is enforced. The global option \smtp@_enforce@_sync\ specifies the initial
22738 state of the switch (it is true by default). See the description of this option
22739 in chapter ~~CHAPmainconfig for details of SMTP synchronization checking.
22740
22741 The effect of these two controls lasts for the remainder of the SMTP
22742 connection. They can appear in any ACL except the one for the non-SMTP
22743 messages. The most straightforward place to put them is in the ACL defined by
22744 \acl@_smtp@_connect\, which is run at the start of an incoming SMTP connection,
22745 before the first synchronization check. The expected use is to turn off the
22746 synchronization checks for badly-behaved hosts that you nevertheless need to
22747 work with.
22748
22749 .item "control = fakereject/<<message>>"
22750 .index fake rejection
22751 .index rejection, fake
22752 This control is permitted only for the \\MAIL\\, \\RCPT\\, and \\DATA\\ ACLs,
22753 in other words, only when an SMTP message is being received. If Exim accepts
22754 the message, instead the final 250 response, a 550 rejection message is sent.
22755 However, Exim proceeds to deliver the message as normal. The control applies 
22756 only to the current message, not to any subsequent ones that may be received in 
22757 the same SMTP connection.
22758
22759 The text for the 550 response is taken from the \control\ modifier. If no
22760 message is supplied, the following is used:
22761 .display asis
22762 550-Your message has been rejected but is being 
22763 550-kept for evaluation.
22764 550-If it was a legitimate message, it may still be 
22765 550 delivered to the target recipient(s).
22766 .endd
22767 This facilty should be used with extreme caution.
22768
22769
22770 .item "control = freeze"
22771 .index frozen messages||forcing in ACL
22772 This control is permitted only for the \\MAIL\\, \\RCPT\\, \\DATA\\, and
22773 non-SMTP ACLs, in other words, only when a message is being received. If the
22774 message is accepted, it is placed on Exim's queue and frozen. The control
22775 applies only to the current message, not to any subsequent ones that may be
22776 received in the same SMTP connection.
22777
22778
22779 .item "control = no@_mbox@_unspool"
22780 This control is available when Exim is compiled with the content scanning 
22781 extension. Content scanning may require a copy of the current message, or parts 
22782 of it, to be written in `mbox format' to a spool file, for passing to a virus
22783 or spam scanner. Normally, such copies are deleted when they are no longer 
22784 needed. If this control is set, the copies are not deleted. The control
22785 applies only to the current message, not to any subsequent ones that may be
22786 received in the same SMTP connection. It is provided for debugging purposes and 
22787 is unlikely to be useful in production.
22788
22789
22790 .item "control = no@_multiline@_response"
22791 .index multiline responses, suppressing
22792 This control is permitted for any ACL except the one for non-SMTP messages.
22793 It seems that there are broken clients in use that cannot handle multiline
22794 SMTP responses, despite the fact that RFC 821 defined them over 20 years ago.
22795
22796 If this control is set, multiline SMTP responses from ACL rejections are
22797 suppressed. One way of doing this would have been to put out these responses as
22798 one long line. However, RFC 2821 specifies a maximum of 512 bytes per response
22799 (`use multiline responses for more' it says -- ha!), and some of the responses
22800 might get close to that. So this facility, which is after all only a sop to
22801 broken clients, is implemented by doing two very easy things:
22802 .numberpars
22803 Extra information that is normally output as part of a rejection caused by
22804 sender verification failure is omitted. Only the final line (typically `sender
22805 verification failed') is sent.
22806 .nextp
22807 If a \message\ modifier supplies a multiline response, only the first
22808 line is output.
22809 .endp
22810 The setting of the switch can, of course, be made conditional on the
22811 calling host. Its effect lasts until the end of the SMTP connection.
22812
22813
22814 .item "control = queue@_only"
22815 .index \queue@_only\
22816 .index queueing incoming messages
22817 This control is permitted only for the \\MAIL\\, \\RCPT\\, \\DATA\\, and
22818 non-SMTP ACLs, in other words, only when a message is being received. If the
22819 message is accepted, it is placed on Exim's queue and left there for delivery
22820 by a subsequent queue runner. No immediate delivery process is started. In
22821 other words, it has the effect as the \queue@_only\ global option. However, the
22822 control applies only to the current message, not to any subsequent ones that
22823 may be received in the same SMTP connection.
22824
22825
22826 .item "control = submission/<<options>>"
22827 .index message||submission
22828 .index submission mode
22829 This control is permitted only for the \\MAIL\\, \\RCPT\\, and start of data
22830 ACLs (the latter is the one defined by \acl@_smtp@_predata\). Setting it tells
22831 Exim that the current message is a submission from a local MUA. In this case,
22832 Exim operates in `submission mode', and applies certain fixups to the message
22833 if necessary. For example, it add a ::Date:: header line if one is not present.
22834 This control is not permitted in the \acl@_smtp@_data\ ACL, because that is too
22835 late (the message has already been created). 
22836
22837 Chapter ~~CHAPmsgproc describes the processing that Exim applies to messages.
22838 Section ~~SECTsubmodnon covers the processing that happens in submission mode;
22839 the available options for this control are described there. The control applies
22840 only to the current message, not to any subsequent ones that may be received in
22841 the same SMTP connection.
22842
22843 .enditems
22844 .nem
22845
22846
22847 .em
22848 .section Adding header lines with the warn verb
22849 .rset SECTaddheadwarn "~~chapter.~~section"
22850 .index header lines||adding in an ACL
22851 .index header lines||position of added lines
22852 .index \warn\, ACL verb
22853 .index \message\, ACL modifier
22854 The \message\ modifier can be used on a \warn\ statement to add an extra header
22855 line to an incoming message, as in this example:
22856 .display asis
22857 warn message = X-blacklisted-at: $dnslist_domain
22858      dnslists = sbl.spamhaus.org : \
22859                 dialup.mail-abuse.org
22860 .endd
22861 If an identical header line is requested several times (provoked, for example,
22862 by multiple \\RCPT\\ commands), only one copy is actually added to the message.
22863 If the text of the \message\ modifier contains one or more newlines that are
22864 not followed by a space or a tab, it is assumed to contain multiple header
22865 lines. Each one is checked for valid syntax; \"X-ACL-Warn:"\ is added to the
22866 front of any line that is not a valid header line.
22867
22868 By default, new lines are added at the end of the existing header lines.
22869 However, you can specify that any particular header line should be added right
22870 at the start (before all the ::Received:: lines), immediately after the first
22871 block of ::Received:: lines, or immediately before any line that is not a
22872 ::Received:: or ::Resent-something:: header.
22873
22874 This is done by specifying `:at@_start:', `:after@_received:', or
22875 `:at@_start@_rfc:' (or, for completeness, `:at@_end:') before the text of the
22876 header line, respectively. (Header text cannot start with a colon, as there has
22877 to be a header name first.) For example:
22878 .display asis
22879 warn message = :after_received:X-My-Header: something or other...
22880 .endd
22881
22882 If more than one header is supplied in a single warn statement, each one is
22883 treated independently and can therefore be placed differently. If you add
22884 more than one line at the start, or after the Received: block, they will
22885 end up in reverse order.
22886
22887 \**Warning**\: This facility currently applies only to header lines that are
22888 added in an ACL. It does NOT work for header lines that are added in a
22889 system filter or in a router or transport.
22890
22891 .index header lines||added, visibility of
22892 Header lines that are added by an ACL at \\MAIL\\ or \\RCPT\\ time are not
22893 visible in string expansions in ACLs for subsequent \\RCPT\\ commands or in the
22894 \acl@_smtp@_predata\ ACL. However, they are visible in string expansions in the
22895 ACL that is run after \\DATA\\ is complete (the \acl@_smtp@_data\ ACL). This is
22896 also true for header lines that are added in the \acl@_smtp@_predata\ ACL.
22897 If a message is rejected after \\DATA\\, all added header lines are included in
22898 the entry that is written to the reject log.
22899
22900 If you want to preserve data between \\MAIL\\, \\RCPT\\, and the
22901 \acl@_smtp@_predata\ ACLs, you can use ACL variables, as described in section
22902 ~~SECTaclvariables.
22903 .nem
22904
22905
22906
22907 .section ACL conditions
22908 .rset SECTaclconditions "~~chapter.~~section"
22909 .index ~~ACL||conditions, list of
22910 .em
22911 Some of conditions listed in this section are available only when Exim is
22912 compiled with the content-scanning extension. They are included here briefly
22913 for completeness. More detailed descriptions can be found in the discussion on
22914 content scanning in chapter ~~CHAPexiscan.
22915 .nem
22916
22917 Not all conditions are relevant in all circumstances. For example, testing
22918 senders and recipients does not make sense in an ACL that is being run as the
22919 result of the arrival of an \\ETRN\\ command, and checks on message headers can
22920 be done only in the ACLs specified by \acl@_smtp@_data\ and \acl__not__smtp\.
22921 You can use the same condition (with different parameters) more than once in
22922 the same ACL statement. This provides a way of specifying an `and' conjunction.
22923 The conditions are as follows:
22924
22925 .startitems
22926
22927 .item "acl = <<name of acl or ACL string or file name >>"
22928 .index ~~ACL||nested
22929 .index ~~ACL||indirect
22930 .index \acl\, ACL condition
22931 The possible values of the argument are the same as for the
22932 \acl@_smtp@_$it{xxx}\ options. The named or inline ACL is run. If it returns
22933 `accept' the condition is true; if it returns `deny' the condition is false. If
22934 it returns `defer', the current ACL returns `defer'
22935 .em
22936 unless the condition is on a \warn\ verb. In that case, a `defer' return makes
22937 the condition false. This means that further processing of the \warn\ verb
22938 ceases, but processing of the ACL continues.
22939 .nem
22940
22941 If the nested \acl\ returns `drop' and the outer condition denies access,
22942 the connection is dropped. If it returns `discard', the verb must be \accept\
22943 or \discard\, and the action is taken immediately -- no further conditions are
22944 tested.
22945
22946 ACLs may be nested up to 20 deep; the limit exists purely to catch runaway
22947 loops. This condition allows you to use different ACLs in different
22948 circumstances. For example, different ACLs can be used to handle \\RCPT\\
22949 commands for different local users or different local domains.
22950
22951 .item "authenticated = <<string list>>"
22952 .index \authenticated\, ACL condition
22953 .index authentication||ACL checking
22954 .index ~~ACL||testing for authentication
22955 If the SMTP connection is not authenticated, the condition is false. Otherwise,
22956 the name of the authenticator is tested against the list. To test for
22957 authentication by any authenticator, you can set
22958 .display asis
22959 authenticated = *
22960 .endd
22961
22962 .item "condition = <<string>>"
22963 .index \condition\, ACL condition
22964 .index customizing||ACL condition
22965 .index ~~ACL||customized test
22966 .index ~~ACL||testing, customized
22967 This feature allows you to make up custom conditions. If the result of
22968 expanding the string is an empty string, the number zero, or one of the strings
22969 `no' or `false', the condition is false. If the result is any non-zero number,
22970 or one of the strings `yes' or `true', the condition is true. For any other
22971 values, some error is assumed to have occured, and the ACL returns `defer'.
22972
22973
22974 .em
22975 .item "decode = <<location>>"
22976 .index \decode\, ACL condition
22977 This condition is available only when Exim is compiled with the
22978 content-scanning extension, and it is allowed only the the ACL defined by
22979 \acl@_smtp@_mime\. It causes the current MIME part to be decoded into a file.
22980 For details, see chapter ~~CHAPexiscan.
22981 .nem
22982
22983
22984 .item "dnslists = <<list of domain names and other data>>"
22985 .index \dnslists\, ACL condition
22986 .index DNS list||in ACL
22987 .index black list (DNS)
22988 .index ~~ACL||testing a DNS list
22989 This condition checks for entries in DNS black lists. These are also known as
22990 `RBL lists', after the original Realtime Blackhole List, but note that the use
22991 of the lists at \*mail-abuse.org*\ now carries a charge.
22992 There are too many different variants of this condition to describe briefly
22993 here. See sections ~~SECTmorednslists--~~SECTmorednslistslast for details.
22994
22995 .item "domains = <<domain list>>"
22996 .index \domains\, ACL condition
22997 .index domain||ACL checking
22998 .index ~~ACL||testing a recipient domain
22999 This condition is relevant only after a \\RCPT\\ command. It checks that the
23000 domain of the recipient address is in the domain list. If percent-hack
23001 processing is enabled, it is done before this test is done. If the check
23002 succeeds with a lookup, the result of the lookup is placed in \$domain@_data$\
23003 until the next \domains\ test.
23004
23005 .item "encrypted = <<string list>>"
23006 .index \encrypted\, ACL condition
23007 .index encryption||checking in an ACL
23008 .index ~~ACL||testing for encryption
23009 If the SMTP connection is not encrypted, the condition is false. Otherwise, the
23010 name of the cipher suite in use is tested against the list. To test for
23011 encryption without testing for any specific cipher suite(s), set
23012 .display asis
23013 encrypted = *
23014 .endd
23015
23016 .item "hosts = << host list>>"
23017 .index \hosts\, ACL condition
23018 .index host||ACL checking
23019 .index ~~ACL||testing the client host
23020 This condition tests that the calling host matches the host list. If you have
23021 name lookups or wildcarded host names and IP addresses in the same host list,
23022 you should normally put the IP addresses first. For example, you could have:
23023 .display asis
23024 accept hosts = 10.9.8.7 : dbm;/etc/friendly/hosts
23025 .endd
23026 The reason for this lies in the left-to-right way that Exim processes lists.
23027 It can test IP addresses without doing any DNS lookups, but when it reaches an
23028 item that requires a host name, it fails if it cannot find a host name to
23029 compare with the pattern. If the above list is given in the opposite order, the
23030 \accept\ statement fails for a host whose name cannot be found, even if its
23031 IP address is 10.9.8.7.
23032
23033 If you really do want to do the name check first, and still recognize the IP
23034 address even if the name lookup fails, you can rewrite the ACL like this:
23035 .display asis
23036 accept hosts = dbm;/etc/friendly/hosts
23037 accept hosts = 10.9.8.7
23038 .endd
23039 The default action on failing to find the host name is to assume that the host
23040 is not in the list, so the first \accept\ statement fails. The second statement
23041 can then check the IP address.
23042
23043 If a \hosts\ condition is satisfied by means of a lookup, the result
23044 of the lookup is made available in the \$host@_data$\ variable. This
23045 allows you, for example, to set up a statement like this:
23046 .display asis
23047 deny  hosts = net-lsearch;/some/file
23048       message = $host_data
23049 .endd
23050 which gives a custom error message for each denied host.
23051
23052 .item "local@_parts = <<local part list>>"
23053 .index \local@_parts\, ACL condition
23054 .index local part||ACL checking
23055 .index ~~ACL||testing a local part
23056 This condition is relevant only after a \\RCPT\\ command. It checks that the
23057 local part of the recipient address is in the list. If percent-hack processing
23058 is enabled, it is done before this test. If the check succeeds with a lookup,
23059 the result of the lookup is placed in \$local@_part@_data$\ until the next
23060 \local@_parts\ test.
23061
23062
23063 .em
23064 .item "malware = <<option>>"
23065 .index \malware\, ACL condition
23066 .index ~~ACL||virus scanning
23067 .index ~~ACL||scanning for viruses
23068 This condition is available only when Exim is compiled with the
23069 content-scanning extension. It causes the incoming message to be scanned for
23070 viruses. For details, see chapter ~~CHAPexiscan.
23071 .nem
23072
23073
23074 .em
23075 .item "mime@_regex = <<list of regular expressions>>"
23076 .index \mime@_regex\, ACL condition
23077 .index ~~ACL||testing by regex matching
23078 This condition is available only when Exim is compiled with the
23079 content-scanning extension, and it is allowed only the the ACL defined by
23080 \acl@_smtp@_mime\. It causes the current MIME part to be scanned for a match
23081 with any of the regular expressions. For details, see chapter ~~CHAPexiscan.
23082 .nem
23083
23084
23085 .item "recipients = <<address list>>"
23086 .index \recipients\, ACL condition
23087 .index recipient||ACL checking
23088 .index ~~ACL||testing a recipient
23089 This condition is relevant only after a \\RCPT\\ command. It checks the entire
23090 recipient address against a list of recipients.
23091
23092
23093 .em
23094 .item "regex = <<list of regular expressions>>"
23095 .index \regex\, ACL condition
23096 .index ~~ACL||testing by regex matching
23097 This condition is available only when Exim is compiled with the
23098 content-scanning extension. It causes the incoming message to be scanned
23099 for a match with any of the regular expressions. For details, see chapter
23100 ~~CHAPexiscan.
23101 .nem
23102
23103
23104 .item "sender@_domains = <<domain list>>"
23105 .index \sender@_domains\, ACL condition
23106 .index sender||ACL checking
23107 .index ~~ACL||testing a sender domain
23108 This condition tests the domain of the sender of the message against the given
23109 domain list.
23110 \**Note**\: the domain of the sender address is in
23111 \$sender@_address@_domain$\. It is \*not*\ put in \$domain$\ during the testing
23112 of this condition. This is an exception to the general rule for testing
23113 domain lists. It is done this way so that, if this condition is used in an
23114 ACL for a \\RCPT\\ command, the recipient's domain (which is in \$domain$\) can
23115 be used to influence the sender checking.
23116
23117 .item "senders = <<address list>>"
23118 .index \senders\, ACL condition
23119 .index sender||ACL checking
23120 .index ~~ACL||testing a sender
23121 This condition tests the sender of the message against the given list. To test
23122 for a bounce message, which has an empty sender, set
23123 .display asis
23124 senders = :
23125 .endd
23126
23127
23128 .em
23129 .item "spam = <<username>>"
23130 .index \spam\, ACL condition
23131 .index ~~ACL||scanning for spam
23132 This condition is available only when Exim is compiled with the
23133 content-scanning extension. It causes the incoming message to be scanned by
23134 SpamAssassin. For details, see chapter ~~CHAPexiscan.
23135 .nem
23136
23137
23138 .item "verify = certificate"
23139 .index \verify\, ACL condition
23140 .index TLS||client certificate verification
23141 .index certificate||verification of client
23142 .index ~~ACL||certificate verification
23143 .index ~~ACL||testing a TLS certificate
23144 This condition is true in an SMTP session if the session is encrypted, and a
23145 certificate was received from the client, and the certificate was verified. The
23146 server requests a certificate only if the client matches \tls@_verify@_hosts\
23147 or \tls@_try@_verify@_hosts\ (see chapter ~~CHAPTLS).
23148
23149 .item "verify = header@_sender/<<options>>"
23150 .index \verify\, ACL condition
23151 .index ~~ACL||verifying sender in the header
23152 .index header lines||verifying the sender in
23153 .index sender||verifying in header
23154 .index verifying||sender in header
23155 This condition is relevant only in an ACL that is run after a message has been
23156 received, that is, in an ACL specified by \acl@_smtp@_data\
23157 .em
23158 or \acl@_not@_smtp\. It checks that there is a verifiable address in at least
23159 one of the ::Sender::, ::Reply-To::, or ::From:: header lines. Such an address
23160 is loosely thought of as a `sender' address (hence the name of the test).
23161 However, an address that appears in one of these headers need not be an address
23162 that accepts bounce messages; only sender addresses in envelopes are required
23163 to accept bounces. Therefore, if you use the callout option on this check, you
23164 might want to arrange for a non-empty address in the \\MAIL\\ command.
23165 .nem
23166
23167 Details of address verification and the options are given later, starting at
23168 section ~~SECTaddressverification (callouts are described in section
23169 ~~SECTcallver). You can combine this condition with the \senders\ condition to
23170 restrict it to bounce messages only:
23171 .display asis
23172 deny    senders = :
23173         message = A valid sender header is required for bounces
23174        !verify  = header_sender
23175 .endd
23176
23177 .item "verify = header@_syntax"
23178 .index \verify\, ACL condition
23179 .index ~~ACL||verifying header syntax
23180 .index header lines||verifying syntax
23181 .index verifying||header syntax
23182 This condition is relevant only in an ACL that is run after a message has been
23183 received, that is, in an ACL specified by \acl@_smtp@_data\
23184 or \acl@_not@_smtp\.
23185 It checks the syntax of all header lines that can contain lists of addresses
23186 (::Sender::, ::From::, ::Reply-To::, ::To::, ::Cc::, and ::Bcc::).
23187 Unqualified addresses (local parts without domains) are permitted only in
23188 locally generated messages and from hosts that match
23189 \sender@_unqualified@_hosts\ or \recipient@_unqualified@_hosts\, as
23190 appropriate.
23191
23192 Note that this condition is a syntax check only. However, a common spamming
23193 ploy is to send syntactically invalid headers such as
23194 .display asis
23195 To: @
23196 .endd
23197 and this condition can be used to reject such messages.
23198
23199 .item "verify = helo"
23200 .index \verify\, ACL condition
23201 .index ~~ACL||verifying HELO/EHLO
23202 .index \\HELO\\||verifying
23203 .index \\EHLO\\||verifying
23204 .index verifying||\\EHLO\\
23205 .index verifying||\\HELO\\
23206 This condition is true if a \\HELO\\ or \\EHLO\\ command has been received from
23207 the client host, and its contents have been verified. Verification of these
23208 commands does not happen by default. See the description of the
23209 \helo@_verify@_hosts\ and \helo@_try@_verify@_hosts\ options for details of how
23210 to request it.
23211
23212 .item "verify = recipient/<<options>>"
23213 .index \verify\, ACL condition
23214 .index ~~ACL||verifying recipient
23215 .index recipient||verifying
23216 .index verifying||recipient
23217 This condition is relevant only after a \\RCPT\\ command. It verifies the
23218 current recipient. Details of address verification are given later, starting at
23219 section ~~SECTaddressverification. After a recipient has been verified, the
23220 value of \$address@_data$\ is the last value that was set while routing the
23221 address. This applies even if the verification fails. When an address that is
23222 being verified is redirected to a single address, verification continues with
23223 the new address, and in that case, the subsequent value of \$address@_data$\ is
23224 the value for the child address.
23225
23226
23227 .item "verify = reverse@_host@_lookup"
23228 .index \verify\, ACL condition
23229 .index ~~ACL||verifying host reverse lookup
23230 .index host||verifying reverse lookup
23231 This condition ensures that a verified host name has been looked up from the IP
23232 address of the client host. (This may have happened already if the host name
23233 was needed for checking a host list, or if the host matched \host@_lookup\.)
23234 Verification ensures that the host name obtained from a reverse DNS lookup, or
23235 one of its aliases, does, when it is itself looked up in the DNS, yield the
23236 original IP address.
23237
23238 If this condition is used for a locally generated message (that is, when there
23239 is no client host involved), it always succeeds.
23240
23241
23242 .item "verify = sender/<<options>>"
23243 .index \verify\, ACL condition
23244 .index ~~ACL||verifying sender
23245 .index sender||verifying
23246 .index verifying||sender
23247 This condition is relevant only after a \\MAIL\\ or \\RCPT\\ command, or after
23248 a message has been received (the \acl@_smtp@_data\ or \acl@_not@_smtp\ ACLs).
23249 If the message's sender is empty (that is, this is a bounce message), the
23250 condition is true. Otherwise, the sender address is verified.
23251 .em
23252 If there is data in the \$address@_data$\ variable at the end of routing, its 
23253 value is placed in \$sender__address__data$\ at the end of verification. This
23254 value can be used in subsequent conditions and modifiers in the same ACL
23255 statement. It does not persist after the end of the current statement. If you
23256 want to preserve the value for longer, you can save it in an ACL variable.
23257
23258 Details of verification are given later, starting at section
23259 ~~SECTaddressverification. Exim caches the result of sender verification, to
23260 avoid doing it more than once per message.
23261
23262 .item "verify = sender=<<address>>/<<options>>"
23263 .index \verify\, ACL condition
23264 This is a variation of the previous option, in which a modified address is
23265 verified as a sender.
23266
23267 .enditems
23268
23269
23270
23271 .section Using DNS lists
23272 .rset SECTmorednslists "~~chapter.~~section"
23273 .index DNS list||in ACL
23274 .index black list (DNS)
23275 .index ~~ACL||testing a DNS list
23276 In its simplest form, the \dnslists\ condition tests whether the calling host
23277 is on at least one of a number of DNS lists by looking up the inverted IP
23278 address in one or more DNS domains. For example, if the calling host's IP
23279 address is 192.168.62.43, and the ACL statement is
23280 .display asis
23281 deny dnslists = blackholes.mail-abuse.org : \
23282                 dialups.mail-abuse.org
23283 .endd
23284 the following records are looked up:
23285 .display asis
23286 43.62.168.192.blackholes.mail-abuse.org
23287 43.62.168.192.dialups.mail-abuse.org
23288 .endd
23289 .em
23290 As soon as Exim finds an existing DNS record, processing of the list stops.
23291 Thus, multiple entries on the list provide an `or' conjunction. If you want to
23292 test that a host is on more than one list (an `and' conjunction), you can use
23293 two separate conditions:
23294 .display asis
23295 deny dnslists = blackholes.mail-abuse.org
23296      dnslists = dialups.mail-abuse.org
23297 .endd
23298 .nem
23299 If a DNS lookup times out or otherwise fails to give a decisive answer, Exim
23300 behaves as if the host
23301 .em
23302 does not match the list item, that is, as if the DNS record does not exist. If
23303 there are further items in the DNS list, they are processed.
23304 .nem
23305 This is usually the required action when \dnslists\ is used with \deny\ (which
23306 is the most common usage), because it prevents a DNS failure from blocking
23307 mail. However, you can change this behaviour by putting one of the following
23308 special items in the list:
23309 .index \"+include@_unknown"\
23310 .index \"+exclude@_unknown"\
23311 .index \"+defer@_unknown"\
23312 .display
23313 +include@_unknown    $rm{behave as if the item is on the list}
23314 +exclude@_unknown    $rm{behave as if the item is not on the list (default)}
23315 +defer@_unknown      $rm{give a temporary error}
23316 .endd
23317 Each of these applies to any subsequent items on the list. For example:
23318 .display asis
23319 deny dnslists = +defer_unknown : foo.bar.example
23320 .endd
23321
23322 Testing the list of domains stops as soon as a match is found. If you want to
23323 warn for one list and block for another, you can use two different statements:
23324 .display asis
23325 deny  dnslists = blackholes.mail-abuse.org
23326 warn  message  = X-Warn: sending host is on dialups list
23327       dnslists = dialups.mail-abuse.org
23328 .endd
23329
23330 DNS list lookups are cached by Exim for the duration of the SMTP session,
23331 so a lookup based on the IP address is done at most once for any incoming
23332 connection. Exim does not share information between multiple incoming
23333 connections (but your local name server cache should be active).
23334
23335
23336 .em
23337 .section Specifying the IP address for a DNS list lookup
23338 .index DNS list||keyed by explicit IP address
23339 By default, the IP address that is used in a DNS list lookup is the IP address
23340 of the calling host. However, you can specify another IP address by listing it
23341 after the domain name, introduced by a slash. For example:
23342 .display asis
23343 deny dnslists = black.list.tls/192.168.1.2
23344 .endd
23345 This feature is not very helpful with explicit IP addresses; it is intended for
23346 use with IP addresses that are looked up, for example, the IP addresses of the
23347 MX hosts or nameservers of an email sender address. For an example, see section
23348 ~~SECTmulkeyfor below.
23349 .nem
23350
23351
23352 .section DNS lists keyed on domain names
23353 .index DNS list||keyed by domain name
23354 There are some lists that are keyed on domain names rather than inverted IP
23355 addresses (see for example the \*domain based zones*\ link at
23356 \?http://www.rfc-ignorant.org/?\). No reversing of components is used with
23357 these lists. You can change the name that is looked up in a DNS list by listing
23358 it after the domain name, introduced by a slash. For example,
23359 .display asis
23360 deny  message  = Sender's domain is listed at $dnslist_domain
23361       dnslists = dsn.rfc-ignorant.org/$sender_address_domain
23362 .endd
23363 This particular example is useful only in ACLs that are obeyed after the
23364 \\RCPT\\ or \\DATA\\ commands, when a sender address is available. If (for
23365 example) the message's sender is \*user@@tld.example*\ the name that is looked
23366 up by this example is
23367 .display asis
23368 tld.example.dsn.rfc-ignorant.org
23369 .endd
23370 .em
23371 A single \dnslists\ condition can contain entries for both names and IP
23372 addresses. For example:
23373 .display asis
23374 deny dnslists = sbl.spamhaus.org : \
23375                 dsn.rfc-ignorant.org/$sender_address_domain
23376 .endd
23377 The first item checks the sending host's IP address; the second checks a domain
23378 name. The whole condition is true if either of the DNS lookups succeeds.
23379 .nem
23380
23381
23382 .em
23383 .section Multiple explicit keys for a DNS list
23384 .rset SECTmulkeyfor "~~chapter.~~section"
23385 .index DNS list||multiple keys for
23386 The syntax described above for looking up explicitly-defined values (either
23387 names or IP addresses) in a DNS blacklist is a simplification. After the domain
23388 name for the DNS list, what follows the slash can in fact be a list of items.
23389 As with all lists in Exim, the default separator is a colon. However, because
23390 this is a sublist within the list of DNS blacklist domains, it is necessary
23391 either to double the separators like this:
23392 .display asis
23393 dnslists = black.list.tld/name.1::name.2
23394 .endd
23395 or to change the separator character, like this:
23396 .display asis
23397 dnslists = black.list.tld/<;name.1;name.2
23398 .endd
23399 If an item in the list is an IP address, it is inverted before the DNS
23400 blacklist domain is appended. If it is not an IP address, no inversion
23401 occurs. Consider this condition:
23402 .display asis
23403 dnslists = black.list.tld/<;192.168.1.2;a.domain
23404 .endd
23405 The DNS lookups that occur are:
23406 .display asis
23407 2.1.168.192.black.list.tld
23408 a.domain.black.list.tld
23409 .endd
23410 Once a DNS record has been found (that matches a specific IP return
23411 address, if specified -- see section ~~SECTaddmatcon), no further lookups are
23412 done. If there is a temporary DNS error, the rest of the sublist of domains or
23413 IP addresses is tried. A temporary error for the whole dnslists item occurs
23414 only if no other DNS lookup in this sublist succeeds. In other words, a
23415 successful lookup for any of the items in the sublist overrides a temporary
23416 error for a previous item.
23417
23418 The ability to supply a list of items after the slash is in some sense just a
23419 syntactic convenience. These two examples have the same effect:
23420 .display asis
23421 dnslists = black.list.tld/a.domain : black.list.tld/b.domain
23422 dnslists = black.list.tld/a.domain::b.domain
23423 .endd
23424 However, when the data for the list is obtained from a lookup, the second form
23425 is usually much more convenient. Consider this example:
23426 .display asis
23427 deny message  =  The mail servers for the domain \
23428                  $sender_address_domain \
23429                  are listed at $dnslist_domain ($dnslist_value); \
23430                  see $dnslist_text.
23431      dnslists =  sbl.spamhaus.org/<|${lookup dnsdb {>|a=<|\
23432                                     ${lookup dnsdb {>|mxh=\
23433                                     $sender_address_domain} }} }
23434 .endd
23435 Note the use of \">|"\ in the dnsdb lookup to specify the separator for
23436 multiple DNS records. The inner dnsdb lookup produces a list of MX hosts
23437 and the outer dnsdb lookup finds the IP addresses for these hosts. The result
23438 of expanding the condition might be something like this:
23439 .display asis
23440 dnslists = sbl.spahmaus.org/<|192.168.2.3|192.168.5.6|...
23441 .endd
23442 Thus, this example checks whether or not the IP addresses of the sender
23443 domain's mail servers are on the Spamhaus black list.
23444 .nem
23445
23446
23447
23448 .section Data returned by DNS lists
23449 .index DNS list||data returned from
23450 DNS lists are constructed using address records in the DNS. The original RBL
23451 just used the address 127.0.0.1 on the right hand side of each record, but the
23452 RBL+ list and some other lists use a number of values with different meanings.
23453 The values used on the RBL+ list are:
23454 .display rm
23455 .tabs 12
23456 127.1.0.1 $t RBL
23457 127.1.0.2 $t DUL
23458 127.1.0.3 $t DUL and RBL
23459 127.1.0.4 $t RSS
23460 127.1.0.5 $t RSS and RBL
23461 127.1.0.6 $t RSS and DUL
23462 127.1.0.7 $t RSS and DUL and RBL
23463 .endd
23464 Some DNS lists may return more than one address record.
23465
23466 .section Variables set from DNS lists
23467 .index DNS list||variables set from
23468 When an entry is found in a DNS list, the variable \$dnslist@_domain$\
23469 contains the name of the domain that matched, \$dnslist@_value$\ contains the
23470 data from the entry, and \$dnslist@_text$\ contains the contents of any
23471 associated TXT record. If more than one address record is returned by the DNS
23472 lookup, all the IP addresses are included in \$dnslist@_value$\, separated by
23473 commas and spaces.
23474
23475 You can use these variables in \message\ or \log@_message\ modifiers --
23476 although these appear before the condition in the ACL, they are not expanded
23477 until after it has failed. For example:
23478 .display asis
23479 deny    hosts = !+local_networks
23480         message = $sender_host_address is listed \
23481                   at $dnslist_domain
23482         dnslists = rbl-plus.mail-abuse.example
23483 .endd
23484
23485
23486 .section Additional matching conditions for DNS lists
23487 .rset SECTaddmatcon "~~chapter.~~section"
23488 .index DNS list||matching specific returned data
23489 You can add an equals sign and an IP address after a \dnslists\ domain name in
23490 order to restrict its action to DNS records with a matching right hand side.
23491 For example,
23492 .display asis
23493 deny dnslists = rblplus.mail-abuse.org=127.0.0.2
23494 .endd
23495 rejects only those hosts that yield 127.0.0.2. Without this additional data,
23496 any address record is considered to be a match. If more than one address record
23497 is found on the list, they are all checked for a matching right-hand side.
23498
23499 More than one IP address may be given for checking, using a comma as a
23500 separator. These are alternatives -- if any one of them matches, the \dnslists\
23501 condition is true. For example:
23502 .display asis
23503 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
23504 .endd
23505
23506 If you want to specify a constraining address list and also specify names or IP
23507 addresses to be looked up, the constraining address list must be specified
23508 first. For example:
23509 .display asis
23510 deny dnslists = dsn.rfc-ignorant.org\
23511                 =127.0.0.2/$sender_address_domain
23512 .endd
23513
23514 If the character `&' is used instead of `=', the comparison for each listed
23515 IP address is done by a bitwise `and' instead of by an equality test. In
23516 other words, the listed addresses are used as bit masks. The comparison is
23517 true if all the bits in the mask are present in the address that is being
23518 tested. For example:
23519 .display asis
23520 dnslists = a.b.c&0.0.0.3
23521 .endd
23522 matches if the address is \*x.x.x.*\3, \*x.x.x.*\7, \*x.x.x.*\11, etc. If you
23523 want to test whether one bit or another bit is present (as opposed to both
23524 being present), you must use multiple values. For example:
23525 .display asis
23526 dnslists = a.b.c&0.0.0.1,0.0.0.2
23527 .endd
23528 matches if the final component of the address is an odd number or two times
23529 an odd number.
23530
23531
23532 .section Negated DNS matching conditions
23533 You can supply a negative list of IP addresses as part of a \dnslists\
23534 condition. Whereas
23535 .display asis
23536 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
23537 .endd
23538 means `deny if the host is in the black list at the domain \*a.b.c*\ and the IP
23539 address yielded by the list is either 127.0.0.2 or 127.0.0.3',
23540 .display asis
23541 deny  dnslists = a.b.c!=127.0.0.2,127.0.0.3
23542 .endd
23543 means `deny if the host is in the black list at the domain \*a.b.c*\ and the IP
23544 address yielded by the list is not 127.0.0.2 and not 127.0.0.3'. In other
23545 words, the result of the test is inverted if an exclamation mark appears before
23546 the `=' (or the `&') sign.
23547
23548 \**Note**\: this kind of negation is not the same as negation in a domain,
23549 host, or address list (which is why the syntax is different).
23550
23551 If you are using just one list, the negation syntax does not gain you much. The
23552 previous example is precisely equivalent to
23553 .display asis
23554 deny  dnslists = a.b.c
23555      !dnslists = a.b.c=127.0.0.2,127.0.0.3
23556 .endd
23557 However, if you are using multiple lists, the negation syntax is clearer.
23558 Consider this example:
23559 .display asis
23560 deny  dnslists = sbl.spamhaus.org : \
23561                  list.dsbl.org : \
23562                  dnsbl.njabl.org!=127.0.0.3 : \
23563                  relays.ordb.org
23564 .endd
23565 Using only positive lists, this would have to be:
23566 .display asis
23567 deny  dnslists = sbl.spamhaus.org : \
23568                  list.dsbl.org
23569 deny  dnslists = dnsbl.njabl.org
23570      !dnslists = dnsbl.njabl.org=127.0.0.3
23571 deny  dnslists = relays.ordb.org
23572 .endd
23573 which is less clear, and harder to maintain.
23574
23575
23576
23577 .section DNS lists and IPv6
23578 .rset SECTmorednslistslast "~~chapter.~~section"
23579 .index IPv6||DNS black lists
23580 .index DNS list||IPv6 usage
23581 If Exim is asked to do a dnslist lookup for an IPv6 address, it inverts it
23582 nibble by nibble. For example, if the calling host's IP address is
23583 3ffe:ffff:836f:0a00:000a:0800:200a:c031, Exim might look up
23584 .display asis
23585 1.3.0.c.a.0.0.2.0.0.8.0.a.0.0.0.0.0.a.0.f.6.3.8.
23586   f.f.f.f.e.f.f.3.blackholes.mail-abuse.org
23587 .endd
23588 (split over two lines here to fit on the page). Unfortunately, some of the DNS
23589 lists contain wildcard records, intended for IPv4, that interact badly with
23590 IPv6. For example, the DNS entry
23591 .display asis
23592 *.3.some.list.example.    A    127.0.0.1
23593 .endd
23594 is probably intended to put the entire 3.0.0.0/8 IPv4 network on the list.
23595 Unfortunately, it also matches the entire 3@:@:/4 IPv6 network.
23596
23597 You can exclude IPv6 addresses from DNS lookups by making use of a suitable
23598 \condition\ condition, as in this example:
23599 .display asis
23600 .newline
23601 .em
23602 deny   condition = ${if isip4{$sender_host_address}}
23603 .nem
23604 .newline
23605        dnslists  = some.list.example
23606 .endd
23607
23608
23609 .section Address verification
23610 .rset SECTaddressverification "~~chapter.~~section"
23611 .index verifying||address, options for
23612 .index policy control||address verification
23613 Several of the \verify\ conditions described in section ~~SECTaclconditions
23614 cause addresses to be verified. These conditions can be followed by options
23615 that modify the verification process. The options are separated from the
23616 keyword and from each other by slashes, and some of them contain parameters.
23617 For example:
23618 .display asis
23619 verify = sender/callout
23620 verify = recipient/defer_ok/callout=10s,defer_ok
23621 .endd
23622 .em
23623 The first stage of address verification, which always happens, is to run the
23624 address through the routers, in `verify mode'. Routers can detect the
23625 difference between verification and routing for delivery, and their actions can
23626 be varied by a number of generic options such as \verify\ and \verify@_only\
23627 (see chapter ~~CHAProutergeneric). If routing fails, verification fails.
23628 The available options are as follows:
23629 .numberpars $.
23630 If the \callout\ option is specified, successful routing to one or more remote
23631 hosts is followed by a `callout' to those hosts as an additional check.
23632 Callouts and their sub-options are discussed in the next section.
23633 .nextp
23634 If there is a defer error while doing verification routing, the ACL
23635 normally returns `defer'. However, if you include \defer@_ok\ in the options,
23636 the condition is forced to be true instead. Note that this is a main
23637 verification option as well as a suboption for callouts.
23638 .nextp
23639 The \no@_details\ option is covered in section ~~SECTsenaddver, which discusses
23640 the reporting of sender address verification failures.
23641 .endp
23642
23643 .index verifying||address, differentiating failures
23644 After an address verification failure, \$sender@_verify@_failure$\ or
23645 \$recipient@_verify@_failure$\ (as appropriate) contains one of the following
23646 words:
23647 .numberpars $.
23648 \qualify\: The address was unqualified (no domain), and the message
23649 was neither local nor came from an exempted host.
23650 .nextp
23651 \route\: Routing failed.
23652 .nextp
23653 \mail\: Routing succeeded, and a callout was attempted; rejection
23654 occurred at or before the \\MAIL\\ command (that is, on initial
23655 connection, \\HELO\\, or \\MAIL\\).
23656 .nextp
23657 \recipient\: The \\RCPT\\ command in a callout was rejected.
23658 .nextp
23659 \postmaster\: The postmaster check in a callout was rejected.
23660 .endp
23661
23662 The main use of these variables is expected to be to distinguish between
23663 rejections of \\MAIL\\ and rejections of \\RCPT\\ in callouts.
23664
23665 .nem
23666
23667
23668 .section Callout verification
23669 .rset SECTcallver "~~chapter.~~section"
23670 .index verifying||address, by callout
23671 .index callout||verification
23672 .index SMTP||callout verification
23673 For non-local addresses, routing verifies the domain, but is unable to do any
23674 checking of the local part. There are situations where some means of verifying
23675 the local part is desirable. One way this can be done is to make an SMTP
23676 \*callback*\ to the sending host (for a sender address) or a \*callforward*\ to
23677 a subsequent host (for a recipient address), to see if the host accepts the
23678 address. We use the term \*callout*\ to cover both cases. This facility should
23679 be used with care, because it can add a lot of resource usage to the cost of
23680 verifying an address. However, Exim does cache the results of callouts, which
23681 helps to reduce the cost. Details of caching are in the next section.
23682
23683 Recipient callouts are usually used only between hosts that are controlled by
23684 the same administration. For example, a corporate gateway host could use
23685 callouts to check for valid recipients on an internal mailserver.
23686 A successful callout does not guarantee that a real delivery to the address
23687 would succeed; on the other hand, a failing callout does guarantee that
23688 a delivery would fail.
23689
23690 If the \callout\ option is present on a condition that verifies an address, a
23691 second stage of verification occurs if the address is successfully routed to
23692 one or more remote hosts. The usual case is routing by a \%dnslookup%\ or a
23693 \%manualroute%\ router, where the router specifies the hosts. However, if a
23694 router that does not set up hosts routes to an \%smtp%\ transport with a
23695 \hosts\ setting, the transport's hosts are used. If an \%smtp%\ transport has
23696 \hosts@_override\ set, its hosts are always used, whether or not the router
23697 supplies a host list.
23698
23699 The port that is used is taken from the transport, if it is specified and is a
23700 remote transport. (For routers that do verification only, no transport need be
23701 specified.) Otherwise, the default SMTP port is used. If a remote transport
23702 specifies an outgoing interface, this is used; otherwise the interface is not
23703 specified.
23704
23705 For a sender callout check, Exim makes SMTP connections to the remote hosts, to
23706 test whether a bounce message could be delivered to the sender address. The
23707 following SMTP commands are sent:
23708 .display
23709 .newline
23710 .em
23711 HELO <<smtp active host name>>
23712 .nem
23713 .newline
23714 MAIL FROM:@<@>
23715 RCPT TO:<<the address to be tested>>
23716 QUIT
23717 .endd
23718 \\LHLO\\ is used instead of \\HELO\\ if the transport's \protocol\ option is
23719 set to `lmtp'.
23720
23721 A recipient callout check is similar. By default, it also uses an empty address
23722 for the sender. This default is chosen because most hosts do not make use of
23723 the sender address when verifying a recipient. Using the same address means
23724 that a single cache entry can be used for each recipient. Some sites, however,
23725 do make use of the sender address when verifying. These are catered for by the
23726 \use@_sender\ and \use@_postmaster\ options, described in the next section.
23727
23728 If the response to the \\RCPT\\ command is a 2$it{xx} code, the verification
23729 succeeds. If it is 5$it{xx}, the verification fails. For any other condition,
23730 Exim tries the next host, if any. If there is a problem with all the remote
23731 hosts, the ACL yields `defer', unless the \defer@_ok\ parameter of the
23732 \callout\ option is given, in which case the condition is forced to succeed.
23733
23734
23735
23736
23737 .section Additional parameters for callouts
23738 .rset CALLaddparcall "~~chapter.~~section"
23739 .index callout||additional parameters for
23740 The \callout\ option can be followed by an equals sign and a number of optional
23741 parameters, separated by commas. For example:
23742 .display asis
23743 verify = recipient/callout=10s,defer_ok
23744 .endd
23745 The old syntax, which had \callout@_defer@_ok\ and \check@_postmaster\ as
23746 separate verify options, is retained for backwards compatibility, but is now
23747 deprecated. The additional parameters for \callout\ are as follows:
23748
23749 .startitems
23750
23751 .item "<<a time interval>>"
23752 .index callout||timeout, specifying
23753 This specifies the timeout that applies for the callout attempt to each host.
23754 For example:
23755 .display asis
23756 verify = sender/callout=5s
23757 .endd
23758 The default is 30 seconds. The timeout is used for each response from the
23759 remote host.
23760 .em
23761 It is also used for the intial connection, unless overridden by the \connect\
23762 parameter.
23763 .nem
23764
23765 .em
23766 .item "connect = <<time interval>>"
23767 .index callout||connection timeout, specifying
23768 This parameter makes it possible to set a different (usually
23769 smaller) timeout for making the SMTP connection.
23770 For example:
23771 .display asis
23772 verify = sender/callout=5s,connect=1s
23773 .endd
23774 If not specified, this timeout defaults to the general timeout value.
23775 .nem
23776
23777 .item "defer@_ok"
23778 .index callout||defer, action on
23779 When this parameter is present, failure to contact any host, or any other kind
23780 of temporary error, is treated as success by the ACL. However, the cache is not
23781 updated in this circumstance.
23782
23783 .em
23784 .item "mailfrom = <<email address>>"
23785 .index callout||sender when verifying header
23786 When verifying addresses in header lines using the \header@_sender\
23787 verification option, Exim behaves by default as if the addresses are envelope
23788 sender addresses from a message. Callout verification therefore tests to see
23789 whether a bounce message could be delivered, by using an empty address in the
23790 \\MAIL\\ command. However, it is arguable that these addresses might never be
23791 used as envelope senders, and could therefore justifiably reject bounce
23792 messages (empty senders). The \mailfrom\ callout parameter allows you to
23793 specify what address to use in the \\MAIL\\ command. For example:
23794 .display asis
23795 require  verify = header_sender/callout=mailfrom=abcd@x.y.z
23796 .endd
23797 This parameter is available only for the \header@_sender\ verification option.
23798 .nem
23799
23800 .em
23801 .item "maxwait = <<time interval>>"
23802 .index callout||overall timeout, specifying
23803 This parameter sets an overall timeout for performing a callout verification.
23804 For example:
23805 .display asis
23806 verify = sender/callout=5s,maxwait=30s
23807 .endd
23808 This timeout defaults to four times the callout timeout for individual SMTP
23809 commands. The overall timeout applies when there is more than one host that can
23810 be tried. The timeout is checked before trying the next host. This prevents
23811 very long delays if there are a large number of hosts and all are timing out
23812 (for example, when network connections are timing out).
23813 .nem
23814
23815 .item "no@_cache"
23816 .index callout||cache, suppressing
23817 .index caching||callout, suppressing
23818 When this parameter is given, the callout cache is neither read nor updated.
23819
23820 .item "postmaster"
23821 .index callout||postmaster, checking
23822 When this parameter is set, a sucessful callout check is followed by a similar
23823 check for the local part \*postmaster*\ at the same domain. If this address is
23824 rejected, the callout fails. The result of the postmaster check is recorded in
23825 a cache record; if it is a failure, this is used to fail subsequent callouts
23826 for the domain without a connection being made, until the cache record expires.
23827
23828 .em
23829 .item "postmaster@_mailfrom = <<email address>>"
23830 The postmaster check uses an empty sender in the \\MAIL\\ command by default.
23831 You can use this parameter to do a postmaster check using a different address.
23832 For example:
23833 .display asis
23834 require  verify = sender/callout=postmaster_mailfrom=abc@x.y.z
23835 .endd
23836 If both \postmaster\ and \postmaster@_mailfrom\ are present, the rightmost one
23837 overrides. The \postmaster\ parameter is equivalent to this example:
23838 .display asis
23839 require  verify = sender/callout=postmaster_mailfrom=
23840 .endd
23841 \**Warning**\: The caching arrangements for postmaster checking do not take
23842 account of the sender address. It is assumed that either the empty address or
23843 a fixed non-empty address will be used. All that Exim remembers is that the
23844 postmaster check for the domain succeeded or failed.
23845 .nem
23846
23847 .item "random"
23848 .index callout||`random' check
23849 When this parameter is set, before doing the normal callout check, Exim does a
23850 check for a `random' local part at the same domain. The local part is not
23851 really random -- it is defined by the expansion of the option
23852 \callout@_random@_local@_part\, which defaults to
23853 .display asis
23854 $primary_host_name-$tod_epoch-testing
23855 .endd
23856 The idea here is to try to determine whether the remote host accepts all local
23857 parts without checking. If it does, there is no point in doing callouts for
23858 specific local parts. If the `random' check succeeds, the result is saved in
23859 a cache record, and used to force the current and subsequent callout checks to
23860 succeed without a connection being made, until the cache record expires.
23861
23862 .item "use@_postmaster"
23863 .index callout||sender for recipient check
23864 This parameter applies to recipient callouts only. For example:
23865 .display asis
23866 deny  !verify = recipient/callout=use_postmaster
23867 .endd
23868 It causes a non-empty postmaster address to be used in the \\MAIL\\ command
23869 when performing the callout. The local part of the address is \"postmaster"\
23870 and the domain is the contents of \$qualify@_domain$\.
23871
23872 .item "use@_sender"
23873 This option applies to recipient callouts only. For example:
23874 .display asis
23875 require  verify = recipient/callout=use_sender
23876 .endd
23877 It causes the message's actual sender address to be used in the \\MAIL\\
23878 command when performing the callout, instead of an empty address. There is no
23879 need to use this option unless you know that the called hosts make use of the
23880 sender when checking recipients. If used indiscriminately, it reduces the
23881 usefulness of callout caching.
23882
23883 .enditems
23884
23885 .em
23886 If you use any of the parameters that set a non-empty sender for the \\MAIL\\
23887 command (\mailfrom\, \postmaster@_mailfrom\, \use@_postmaster\, or
23888 \use@_sender\), you should think about possible loops. Recipient checking is
23889 usually done between two hosts that are under the same management, and the host
23890 that receives the callouts is not normally configured to do callouts itself.
23891 Therefore, it is normally safe to use \use@_postmaster\ or \use@_sender\ in
23892 these circumstances.
23893
23894 However, if you use a non-empty sender address for a callout to an arbitrary
23895 host, there is the likelihood that the remote host will itself initiate a
23896 callout check back to your host. As it is checking what appears to be a message
23897 sender, it is likely to use an empty address in \\MAIL\\, thus avoiding a
23898 callout loop. However, to be on the safe side it would be best to set up your
23899 own ACLs so that they do not do sender verification checks when the recipient
23900 is the address you use for header sender or postmaster callout checking.
23901
23902 Another issue to think about when using non-empty senders for callouts is
23903 caching. When you set \mailfrom\ or \use@_sender\, the cache record is keyed by
23904 the sender/recipient combination; thus, for any given recipient, many more
23905 actual callouts are performed than when an empty sender or postmaster is used.
23906
23907 .nem
23908
23909
23910 .section Callout caching
23911 .rset SECTcallvercache "~~chapter.~~section"
23912 .index hints database||callout cache
23913 .index callout||caching
23914 .index caching||callout
23915 Exim caches the results of callouts in order to reduce the amount of resources
23916 used, unless you specify the \no@_cache\ parameter with the \callout\ option.
23917 A hints database called `callout' is used for the cache. Two different record
23918 types are used: one records the result of a callout check for a specific
23919 address, and the other records information that applies to the entire domain
23920 (for example, that it accepts the local part \*postmaster*\).
23921
23922 When an original callout fails, a detailed SMTP error message is given about
23923 the failure. However, for subsequent failures use the cache data, this message
23924 is not available.
23925
23926 The expiry times for negative and positive address cache records are
23927 independent, and can be set by the global options \callout@_negative@_expire\
23928 (default 2h) and \callout@_positive@_expire\ (default 24h), respectively.
23929
23930 If a host gives a negative response to an SMTP connection, or rejects any
23931 commands up to and including
23932 .display asis
23933 MAIL FROM:<>
23934 .endd
23935 (but not including the \\MAIL\\ command with a non-empty address),
23936 any callout attempt is bound to fail. Exim remembers such failures in a
23937 domain cache record, which it uses to fail callouts for the domain without
23938 making new connections, until the domain record times out. There are two
23939 separate expiry times for domain cache records:
23940 \callout@_domain@_negative@_expire\ (default 3h) and
23941 \callout__domain__positive@_expire\ (default 7d).
23942
23943 Domain records expire when the negative expiry time is reached if callouts
23944 cannot be made for the domain, or if the postmaster check failed.
23945 Otherwise, they expire when the positive expiry time is reached. This
23946 ensures that, for example, a host that stops accepting `random' local parts
23947 will eventually be noticed.
23948
23949 The callout caching mechanism is based on the domain of the address that is
23950 being tested. If the domain routes to several hosts, it is assumed that their
23951 behaviour will be the same.
23952
23953
23954 .section Sender address verification reporting
23955 .rset SECTsenaddver "~~chapter.~~section"
23956 .index verifying||suppressing error details
23957 When sender verification fails in an ACL, the details of the failure are
23958 given as additional output lines before the 550 response to the relevant
23959 SMTP command (\\RCPT\\ or \\DATA\\). For example, if sender callout is in use,
23960 you might see:
23961 .display asis
23962 MAIL FROM:<xyz@abc.example>
23963 250 OK
23964 RCPT TO:<pqr@def.example>
23965 550-Verification failed for <xyz@abc.example>
23966 550-Called:   192.168.34.43
23967 550-Sent:     RCPT TO:<xyz@abc.example>
23968 550-Response: 550 Unknown local part xyz in <xyz@abc.example>
23969 550 Sender verification failed
23970 .endd
23971 If more than one \\RCPT\\ command fails in the same way, the details are given
23972 only for the first of them. However, some administrators do not want to send
23973 out this much information. You can suppress the details by adding
23974 `/no@_details' to the ACL statement that requests sender verification. For
23975 example:
23976 .display asis
23977 verify = sender/no_details
23978 .endd
23979
23980
23981 .section Redirection while verifying
23982 .index verifying||redirection while
23983 .index address redirection||while verifying
23984 A dilemma arises when a local address is redirected by aliasing or forwarding
23985 during verification: should the generated addresses themselves be verified,
23986 or should the successful expansion of the original address be enough to verify
23987 it? Exim takes the following pragmatic approach:
23988 .numberpars $.
23989 When an incoming address is redirected to just one child address, verification
23990 continues with the child address, and if that fails to verify, the original
23991 verification also fails.
23992 .nextp
23993 When an incoming address is redirected to more than one child address,
23994 verification does not continue. A success result is returned.
23995 .endp
23996 This seems the most reasonable behaviour for the common use of aliasing as a
23997 way of redirecting different local parts to the same mailbox. It means, for
23998 example, that a pair of alias entries of the form
23999 .display asis
24000 A.Wol:   aw123
24001 aw123:   :fail: Gone away, no forwarding address
24002 .endd
24003 work as expected, with both local parts causing verification failure. When a
24004 redirection generates more than one address, the behaviour is more like a
24005 mailing list, where the existence of the alias itself is sufficient for
24006 verification to succeed.
24007
24008
24009 .section Using an ACL to control relaying
24010 .rset SECTrelaycontrol "~~chapter.~~section"
24011 .index ~~ACL||relay control
24012 .index relaying||control by ACL
24013 .index policy control||relay control
24014 An MTA is said to \*relay*\ a message if it receives it from some host and
24015 delivers it directly to another host as a result of a remote address contained
24016 within it. Redirecting a local address via an alias or forward file and then
24017 passing the message on to another host is not relaying,
24018 .index `percent hack'
24019 but a redirection as a result of the `percent hack' is.
24020
24021 Two kinds of relaying exist, which are termed `incoming' and `outgoing'. A host
24022 which is acting as a gateway or an MX backup is concerned with incoming
24023 relaying from arbitrary hosts to a specific set of domains. On the other hand,
24024 a host which is acting as a smart host for a number of clients is concerned
24025 with outgoing relaying from those clients to the Internet at large. Often the
24026 same host is fulfilling both functions, as illustrated in the diagram below,
24027 but in principle these two kinds of relaying are entirely independent. What is
24028 not wanted is the transmission of mail from arbitrary remote hosts through your
24029 system to arbitrary domains.
24030 .if ~~sys.fancy
24031 .figure "Controlled relaying" rm
24032 .indent 0
24033 .call aspic -sgcal -nv
24034 centre ~~sys.linelength;
24035 magnify 0.8;
24036 boundingbox 30;
24037 textdepth 16;
24038     boxwidth 120;
24039     boxdepth 44;
24040 A:  box "Arbitrary" "remote hosts";
24041 C:  ibox;
24042 D:  box "Arbitrary" "domains";
24043     iline down 50 from bottom of C;
24044 H:  box width 180 "Local host";
24045     iline down 50;
24046 E:  ibox;
24047 SH: box "Specific" "hosts";
24048 SD: box join right to E "Specific" "domains";
24049     arcarrow clockwise from top of SH to bottom of D plus (-10,-4)
24050       via right of H plus (-20,0);
24051     arcarrow clockwise from bottom of A to top of SD plus (10,4)
24052       via left of H plus (20,0);
24053
24054     ibox join left to right of H "$it{Outgoing}";
24055     goto H;
24056     ibox join right to left of H "$it{Incoming}";
24057
24058 L:  line dashed from right of A to top of H plus (-15,0);
24059     arc dashed to top of H plus (15,0);
24060     arrow dashed to left of D plus (-2,0);
24061
24062     arrow dashed back up 72 right 32 from middle of L plus (8,0);
24063     text at end plus (0, 4) "$it{Not wanted}";
24064 .endcall
24065 .endfigure
24066 .elif !~~html
24067 .display asis
24068    --------------    -----------
24069    | Arbitrary  |    |Arbitrary|
24070    |remote hosts|    | domains |
24071    --------------    -----------
24072  I       v                ^       O
24073  n       v                ^       u
24074  c    ---v----------------^---    t
24075  o    |  v     Local      ^  |    g
24076  m    |  v      host      ^  |    o
24077  i    ---v----------------^---    i
24078  n       v                ^       n
24079  g       v                ^       g
24080       Specific         Specific
24081       domains           hosts
24082 .endd
24083 .else
24084 [(IMG SRC="relaying.gif" alt="Controlled relaying")][(br)]
24085 .fi
24086
24087 You can implement relay control by means of suitable statements in the ACL that
24088 runs for each \\RCPT\\ command. For convenience, it is often easiest to use
24089 Exim's named list facility to define the domains and hosts involved. For
24090 example, suppose you want to do the following:
24091 .numberpars $.
24092 Deliver a number of domains to mailboxes on the local host (or process them
24093 locally in some other way). Let's say these are \*my.dom1.example*\ and
24094 \*my.dom2.example*\.
24095 .nextp
24096 Relay mail for a number of other domains for which you are the secondary MX.
24097 These might be \*friend1.example*\ and \*friend2.example*\.
24098 .nextp
24099 Relay mail from the hosts on your local LAN, to whatever domains are involved.
24100 Suppose your LAN is 192.168.45.0/24.
24101 .endp
24102 In the main part of the configuration, you put the following definitions:
24103 .display asis
24104 domainlist local_domains = my.dom1.example : my.dom2.example
24105 domainlist relay_domains = friend1.example : friend2.example
24106 hostlist   relay_hosts   = 192.168.45.0/24
24107 .endd
24108 Now you can use these definitions in the ACL that is run for every \\RCPT\\
24109 command:
24110 .display asis
24111 acl_check_rcpt:
24112   accept domains = +local_domains : +relay_domains
24113   accept hosts   = +relay_hosts
24114 .endd
24115 The first statement accepts any \\RCPT\\ command that contains an address in
24116 the local or relay domains. For any other domain, control passes to the second
24117 statement, which accepts the command only if it comes from one of the relay
24118 hosts. In practice, you will probably want to make your ACL more sophisticated
24119 than this, for example, by including sender and recipient verification. The
24120 default configuration includes a more comprehensive example, which is described
24121 in chapter ~~CHAPdefconfil.
24122
24123
24124 .section Checking a relay configuration
24125 .rset SECTcheralcon "~~chapter.~~section"
24126 .index relaying||checking control of
24127 You can check the relay characteristics of your configuration in the same way
24128 that you can test any ACL behaviour for an incoming SMTP connection, by using
24129 the \-bh-\ option to run a fake SMTP session with which you interact.
24130
24131 For specifically testing for unwanted relaying, the host
24132 \*relay-test.mail-abuse.org*\ provides a useful service. If you telnet to this
24133 host from the host on which Exim is running, using the normal telnet port, you
24134 will see a normal telnet connection message and then quite a long delay. Be
24135 patient. The remote host is making an SMTP connection back to your host, and
24136 trying a number of common probes to test for open relay vulnerability. The
24137 results of the tests will eventually appear on your terminal.
24138
24139
24140
24141
24142 .
24143 .
24144 .
24145 .
24146 . ============================================================================
24147 .chapter Content scanning
24148 .set runningfoot "content scanning"
24149 .rset CHAPexiscan "~~chapter"
24150 .index content scanning
24151 .em
24152 The content-scanning extension of Exim, formerly known as `exiscan', was
24153 originally implemented as a patch by Tom Kistner. The code was integrated into
24154 the main source for Exim release 4.50, and Tom continues to maintain it. Most
24155 of the wording of this chapter is taken from Tom's specification.
24156
24157 If you want to include the content-scanning features when you compile Exim, you
24158 need to arrange for \\WITH@_CONTENT@_SCAN\\ to be defined in your
24159 \(Local/Makefile)\. When you do that, the Exim binary is built with:
24160 .numberpars $.
24161 An additional ACL (\acl@_smtp@_mime\) that is run for all MIME parts.
24162 .nextp
24163 Additional ACL conditions and modifiers: \decode\, \malware\, \mime@_regex\,
24164 \regex\, and \spam\. These can be used in the ACL that is run at the end of
24165 message reception (the \acl@_smtp@_data\ ACL).
24166 .nextp
24167 An additional control feature (`no@_mbox@_unspool') that saves spooled copies 
24168 of messages, or parts of messages, for debugging purposes. 
24169 .nextp
24170 Additional expansion variables that are set in the new ACL and by the new
24171 conditions.
24172 .nextp
24173 Two new main configuration options: \av@_scanner\ and \spamd@_address\.
24174 .endp
24175 There is another content-scanning configuration option for \(Local/Makefile)\,
24176 called \\WITH@_OLD@_DEMIME\\. If this is set, the old, deprecated \demime\ ACL
24177 condition is compiled, in addition to all the other content-scanning features.
24178
24179 Content-scanning is continually evolving, and new features are still being
24180 added. While such features are still unstable and liable to incompatible
24181 changes, they are made available in Exim by setting options whose names begin
24182 \\EXPERIMENTAL@_\\ in \(Local/Makefile)\. Such features are not documented in
24183 this manual. You can find out about them by reading the file called
24184 \(doc/experimental.txt)\.
24185
24186 All the content-scanning facilites work on a MBOX copy of the message that is
24187 temporarily created in a file called:
24188 .display
24189 <<spool@_directory>>/scan/<<message@_id>>/<<message@_id>>.eml
24190 .endd
24191 The \(.eml)\ extension is a friendly hint to virus scanners that they can
24192 expect an MBOX-like structure inside that file. The file is created when the
24193 first content scanning facility is called. Subsequent calls to content
24194 scanning conditions open the same file again. The directory is recursively
24195 removed when the \acl@_smtp@_data\ ACL has finished running, unless 
24196 .display asis
24197 control = no_mbox_unspool
24198 .endd
24199 has been encountered. When the MIME ACL decodes files, they are put into the
24200 same directory by default.
24201
24202
24203 .section Scanning for viruses
24204 .rset SECTscanvirus "~~chapter.~~section"
24205 .index virus scanning
24206 .index content scanning||for viruses
24207 .index content scanning||the \malware\ condition
24208 The \malware\ ACL condition lets you connect virus scanner software to Exim. It
24209 supports a `generic' interface to scanners called via the shell, and
24210 specialized interfaces for `daemon' type virus scanners, which are resident in
24211 memory and thus are much faster.
24212
24213 .index \av@_scanner\
24214 You can set the \av@_scanner\ option in first part of the Exim configuration
24215 file to specify which scanner to use, together with any additional options that
24216 are needed. The basic syntax is as follows:
24217 .display
24218 av@_scanner = <<scanner-type>>:<<option1>>:<<option2>>:[...]
24219 .endd
24220 If you do not set \av@_scanner\, it defaults to
24221 .display asis
24222 av_scanner = sophie:/var/run/sophie
24223 .endd
24224 If the value of \av@_scanner\ starts with dollar character, it is expanded
24225 before use.
24226
24227 The following scanner types are supported in this release:
24228 .numberpars $.
24229 .index virus scanners||Kaspersky
24230 \aveserver\: This is the scanner daemon of Kaspersky Version 5. You can get a
24231 trial version at \?http://www.kaspersky.com?\. This scanner type takes one
24232 option, which is the path to the daemon's UNIX socket. The default is shown in
24233 this example:
24234 .display asis
24235 av_scanner = aveserver:/var/run/aveserver
24236 .endd
24237
24238 .nextp
24239 .index virus scanners||clamd
24240 \clamd\: This daemon-type scanner is GPL and free. You can get it at
24241 \?http://www.clamav.net/?\. Clamd does not seem to unpack MIME containers, so
24242 it is recommended to unpack MIME attachments in the MIME ACL. It takes one
24243 option: either the path and name of a UNIX socket file, or a hostname or IP
24244 number, and a port, separated by space, as in the second of these examples:
24245 .display asis
24246 av_scanner = clamd:/opt/clamd/socket
24247 av_scanner = clamd:192.168.2.100 1234
24248 .endd
24249 If the option is unset, the default is \(/tmp/clamd)\. Thanks to David Saez for 
24250 contributing the code for this scanner.
24251
24252 .nextp
24253 .index virus scanners||command line interface
24254 \cmdline\: This is the keyword for the generic command line scanner interface.
24255 It can be used to attach virus scanners that are invoked from the shell. This
24256 scanner type takes 3 mantadory options:
24257 .numberpars
24258 The full path and name of the scanner binary, with all command line options,
24259 and a placeholder (%s) for the directory to scan.
24260 .nextp
24261 A regular expression to match against the STDOUT and STDERR output of the virus
24262 scanner. If the expression matches, a virus was found. You must make absolutely
24263 sure that this expression matches on `virus found'. This is called the
24264 `trigger' expression.
24265 .nextp
24266 Another regular expression, containing exactly one pair of parentheses, to
24267 match the name of the virus found in the scanners output. This is called the
24268 `name' expression.
24269 .endp
24270 For example, Sophos Sweep reports a virus on a line like this:
24271 .display asis
24272 Virus 'W32/Magistr-B' found in file ./those.bat
24273 .endd
24274 For the trigger expression, we can just match the word `found'. For the name
24275 expression, we want to extract the W32/Magistr-B string, so we can match for
24276 the single quotes left and right of it. Altogether, this makes the
24277 configuration setting:
24278 .display asis
24279 av_scanner = cmdline:\
24280              /path/to/sweep -all -rec -archive %s:\
24281              found:'(.+)'
24282 .endd
24283
24284 .nextp
24285 .index virus scanners||DrWeb
24286 \drweb\: The DrWeb daemon scanner (\?http://www.sald.com/?\) interface
24287 takes one argument, either a full path to a UNIX socket, or an IP address and
24288 port separated by whitespace, as in these examples:
24289 .display asis
24290 av_scanner = drweb:/var/run/drwebd.sock
24291 av_scanner = drweb:192.168.2.20 31337
24292 .endd
24293 If you omit the argument, the default path \(/usr/local/drweb/run/drwebd.sock)\
24294 is used. Thanks to Alex Miller for contributing the code for this scanner.
24295
24296 .nextp
24297 .index virus scanners||F-Secure
24298 \fsecure\: The F-Secure daemon scanner (\?http://www.f-secure.com?\) takes one
24299 argument which is the path to a UNIX socket. For example:
24300 .display asis
24301 av_scanner = fsecure:/path/to/.fsav
24302 .endd
24303 If no argument is given, the default is \(/var/run/.fsav)\. Thanks to Johan
24304 Thelmen for contributing the code for this scanner.
24305
24306 .nextp
24307 .index virus scanners||Kaspersky
24308 \kavdaemon\: This is the scanner daemon of Kaspersky Version 4. This version of
24309 the Kaspersky scanner is outdated. Please upgrade (see \aveserver\ above). This
24310 scanner type takes one option, which is the path to the daemon's UNIX socket.
24311 For example:
24312 .display asis
24313 av_scanner = kavdaemon:/opt/AVP/AvpCtl
24314 .endd
24315 The default path is \(/var/run/AvpCtl)\.
24316
24317 .nextp
24318 .index virus scanners||mksd
24319 \mksd\: This is a daemon type scanner that is aimed mainly at Polish users,
24320 though some parts of documentation are now available in English. You can get it
24321 at \?http://linux.mks.com.pl/?\. The only option for this scanner type is the
24322 maximum number of processes used simultaneously to scan the attachments,
24323 provided that the demime facility is employed and also provided that mksd has
24324 been run with at least the same number of child processes. For example:
24325 .display asis
24326 av_scanner = mksd:2
24327 .endd
24328 You can safely omit this option (the default value is 1).
24329
24330 .nextp
24331 .index virus scanners||Sophos and Sophie
24332 \sophie\:  Sophie is a daemon that uses Sophos' \libsavi\ library to scan for
24333 viruses. You can get Sophie at \?http://www.vanja.com/tools/sophie/?\. The only
24334 option for this scanner type is the path to the UNIX socket that Sophie uses
24335 for client communication. For example:
24336 .display asis
24337 av_scanner = sophie:/tmp/sophie
24338 .endd
24339 The default path is \(/var/run/sophie)\, so if you are using this, you can omit
24340 the option.
24341 .endp
24342
24343 When \av@_scanner\ is correctly set, you can use the \malware\ condition in the
24344 \\DATA\\ ACL. The \av@_scanner\ option is expanded each time \malware\ is
24345 called. This makes it possible to use different scanners. See further below for
24346 an example. The \malware\ condition caches its results, so when you use it
24347 multiple times for the same message, the actual scanning process is only
24348 carried out once. However, using expandable items in \av@_scanner\ disables
24349 this caching, in which case each use of the \malware\ condition causes a new 
24350 scan of the message.
24351
24352 The \malware\ condition takes a right-hand argument that is expanded before
24353 use. It can then be one of
24354 .numberpars $.
24355 `true', `*', or `1', in which case the message is scanned for viruses. The
24356 condition succeeds if a virus was found, and fail otherwise. This is the
24357 recommended usage.
24358 .nextp
24359 `false' or `0', in which case no scanning is done and the condition fails
24360 immediately.
24361 .nextp
24362 A regular expression, in which case the message is scanned for viruses. The
24363 condition succeeds if a virus is found and its name matches the regular
24364 expression. This allows you to take special actions on certain types of virus.
24365 .endp
24366 You can append \"/defer@_ok"\ to the \malware\ condition to accept messages even
24367 if there is a problem with the virus scanner.
24368
24369 .index \$malware@_name$\
24370 When a virus is found, the condition sets up an expansion variable called
24371 \$malware@_name$\ that contains the name of the virus. You can use it in a
24372 \message\ modifier that specifies the error returned to the sender, and/or in
24373 logging data.
24374
24375 If your virus scanner cannot unpack MIME and TNEF containers itself, you should
24376 use the \demime\ condition (see section ~~SECTdemimecond) before the \malware\
24377 condition.
24378
24379 Here is a very simple scanning example:
24380 .display asis
24381 deny message = This message contains malware ($malware_name)
24382    demime = *
24383    malware = *
24384 .endd
24385 The next example accepts messages when there is a problem with the scanner:
24386 .display asis
24387 deny message = This message contains malware ($malware_name)
24388    demime = *
24389    malware = */defer_ok
24390 .endd
24391 The next example shows how to use an ACL variable to scan with both sophie and
24392 aveserver. It assumes you have set:
24393 .display asis
24394 av_scanner = $acl_m0
24395 .endd
24396 in the main Exim configuration.
24397 .display asis
24398 deny message = This message contains malware ($malware_name)
24399    set acl_m0 = sophie
24400    malware = *
24401
24402 deny message = This message contains malware ($malware_name)
24403    set acl_m0 = aveserver
24404    malware = *
24405 .endd
24406
24407
24408 .section Scanning with SpamAssassin
24409 .rset SECTscanspamass "~~chapter.~~section"
24410 .index content scanning||for spam
24411 .index spam scanning
24412 .index SpamAssassin, scanning with
24413 The \spam\ ACL condition calls SpamAssassin's \spamd\ daemon to get a spam
24414 score and a report for the message. You can get SpamAssassin at
24415 \?http://www.spamassassin.org?\, or, if you have a working Perl installation,
24416 you can use CPAN by running:
24417 .display asis
24418 perl -MCPAN -e 'install Mail::SpamAssassin'
24419 .endd
24420 SpamAssassin has its own set of configuration files. Please review its
24421 documentation to see how you can tweak it. The default installation should work
24422 nicely, however.
24423
24424 .index \spamd@_address\
24425 After having installed and configured SpamAssassin, start the \spamd\ daemon.
24426 By default, it listens on 127.0.0.1, TCP port 783. If you use another host or
24427 port for \spamd\, you must set the \spamd@_address\ option in the global part
24428 of the Exim configuration as follows (example):
24429 .display asis
24430 spamd_address = 192.168.99.45 387
24431 .endd
24432 You do not need to set this option if you use the default. As of version 2.60,
24433 \spamd\ also supports communication over UNIX sockets. If you want to use
24434 these, supply \spamd@_address\ with an absolute file name instead of a
24435 address/port pair:
24436 .display asis
24437 spamd_address = /var/run/spamd_socket
24438 .endd
24439
24440 You can have multiple \spamd\ servers to improve scalability. These can reside
24441 on other hardware reachable over the network. To specify multiple \spamd\
24442 servers, put multiple address/port pairs in the \spamd@_address\ option,
24443 separated with colons:
24444 .display asis
24445 spamd_address = 192.168.2.10 783 : \
24446                 192.168.2.11 783 : \
24447                 192.168.2.12 783
24448 .endd
24449 Up to 32 \spamd\ servers are supported. The servers are
24450 queried in a random fashion. When a server fails to respond
24451 to the connection attempt, all other servers are tried
24452 until one succeeds. If no server responds, the \spam\
24453 condition defers. 
24454
24455 \**Warning**\: It is not possible to use the UNIX socket connection method with
24456 multiple \spamd\ servers.
24457
24458 Here is a simple example of the use of the \spam\ condition in a DATA ACL:
24459 .display asis
24460 deny message = This message was classified as SPAM
24461         spam = joe
24462 .endd
24463 The right-hand side of the \spam\ condition specifies the username that
24464 SpamAssassin should scan for. If you do not want to scan for a particular user,
24465 but rather use the SpamAssassin system-wide default profile, you can scan for
24466 an unknown user, or simply use `nobody'. However, you must put something on the
24467 right-hand side.
24468
24469 The username allows you to use per-domain or per-user antispam profiles. The
24470 right-hand side is expanded before being used, so you can put lookups or
24471 conditions there. When the right-hand side evaluates to `0' or `false', no
24472 scanning is done and the condition fails immediately.
24473
24474 The \spam\ condition returns true if the threshold specified in the user's
24475 SpamAssassin profile has been matched or exceeded. If you want to use the
24476 \spam\ condition for its side effects (see the variables below), you can make
24477 it always return `true' by appending \":true"\ to the username.
24478
24479 .index spam scanning||returned variables
24480 When the \spam\ condition is run, it sets up the following expansion
24481 variables:
24482
24483 .push
24484 .indent 2em
24485
24486 .tempindent 0
24487 \$spam@_score$\: The spam score of the message, for example `3.4' or `30.5'.
24488 This is useful for inclusion in log or reject messages.
24489
24490 .tempindent 0
24491 \$spam@_score@_int$\: The spam score of the message, multiplied by ten, as an
24492 integer value. For example `34' or `305'. This is useful for numeric
24493 comparisons in conditions. This variable is special; it is saved with the
24494 message, and written to Exim's spool file. This means that it can be used
24495 during the whole life of the message on your Exim system, in particular, in
24496 routers or transports during the later delivery phase.
24497
24498 .tempindent 0
24499 \$spam@_bar$\: A string consisting of a number of `+' or `@-' characters,
24500 representing the integer part of the spam score value. A spam score of 4.4
24501 would have a \$spam@_bar$\ value of `++++'. This is useful for inclusion in
24502 warning headers, since MUAs can match on such strings.
24503
24504 .tempindent 0
24505 \$spam@_report$\: A multiline text table, containing the full SpamAssassin
24506 report for the message. Useful for inclusion in headers or reject messages.
24507
24508 .pop
24509
24510 The \spam\ condition caches its results. If you call it again with the same user
24511 name, it does not scan again, but rather returns the same values as before.
24512
24513 The \spam\ condition returns DEFER if there is any error while running the
24514 message through SpamAssassin. If you want to treat DEFER as FAIL (to pass on to
24515 the next ACL statement block), append \"/defer@_ok"\ to the right-hand side of
24516 the spam condition, like this:
24517 .display asis
24518 deny message = This message was classified as SPAM
24519      spam    = joe/defer_ok
24520 .endd
24521 This causes messages to be accepted even if there is a
24522 problem with \spamd\.
24523
24524 Here is a longer, commented example of the use of the \spam\
24525 condition:
24526 .display asis
24527 # put headers in all messages (no matter if spam or not)
24528 warn  message = X-Spam-Score: $spam_score ($spam_bar)
24529       spam = nobody:true
24530 warn  message = X-Spam-Report: $spam_report
24531       spam = nobody:true
24532
24533 # add second subject line with *SPAM* marker when message
24534 # is over threshold
24535 warn  message = Subject: *SPAM* $h_Subject:
24536       spam = nobody
24537
24538 # reject spam at high scores (> 12)
24539 deny   message = This message scored $spam_score spam points.
24540        spam = nobody:true
24541        condition = ${if >{$spam_score_int}{120}{1}{0}}
24542 .endd
24543
24544
24545
24546 .section Scanning MIME parts
24547 .rset SECTscanmimepart "~~chapter.~~section"
24548 .index content scanning||MIME parts
24549 .index MIME content scanning
24550 .index \acl@_smtp@_mime\
24551 The \acl@_smtp@_mime\ global option defines an ACL that is called once for each
24552 MIME part of a message, including multipart types, in the sequence of their
24553 position in the message.
24554  
24555 This ACL is called (possibly many times) just before the \acl@_smtp@_data\ ACL,
24556 but only if the message has a ::MIME-Version:: header. When a call to the MIME
24557 ACL does not yield `accept', ACL processing is aborted and the appropriate
24558 result code is sent to the remote client. The \acl@_smtp@_data\ ACL is not
24559 called in this circumstance.
24560
24561 At the start of the MIME ACL, a number of variables are set from the header 
24562 information for the relevant MIME part. These are described below. The contents 
24563 of the MIME part are not by default decoded into a disk file except for MIME 
24564 parts whose content-type is `message/rfc822'. If you want to decode a MIME part 
24565 into a disk file, you can use the \decode\ modifier. The general syntax is:
24566 .display
24567 decode = [/<<path>>/]<<filename>>
24568 .endd
24569 The right hand side is expanded before use. After expansion,
24570 the value can be:
24571 .numberpars
24572 `0' or `false', in which case no decoding is done.
24573 .nextp
24574 The string `default'. In that case, the file is put in the temporary `default'
24575 directory \(<<spool@_directory>>/scan/<<message@_id>>/)\ with a sequential file
24576 name consisting of the message id and a sequence number. The full path and name
24577 is available in \$mime@_decoded@_filename$\ after decoding.
24578 .nextp
24579 A full path name starting with a slash. If the full name is an existing
24580 directory, it is used as a replacement for the default directory. The filename
24581 is then sequentially assigned. If the path does not exist, it is used as
24582 the full path and file name.
24583 .nextp
24584 If the string does not start with a slash, it is used as the
24585 filename, and the default path is then used.
24586 .endp
24587 You can easily decode a file with its original, proposed
24588 filename using
24589 .display asis
24590 decode = $mime_filename
24591 .endd
24592 However, you should keep in mind that \$mime@_filename$\ might contain
24593 anything. If you place files outside of the default path, they are not
24594 automatically unlinked.
24595
24596 For RFC822 attachments (these are messages attached to messages, with a
24597 content-type of `message/rfc822'), the ACL is called again in the same manner
24598 as for the primary message, only that the \$mime@_is@_rfc822$\ expansion
24599 variable is set (see below). Attached messages are always decoded to disk
24600 before being checked, and the files are unlinked once the check is done.
24601
24602 The MIME ACL supports the \regex\ and \mime@_regex\ conditions. These can be
24603 used to match regular expressions against raw and decoded MIME parts,
24604 respectively. They are described in section ~~SECTscanregex.
24605
24606 .index MIME content scanning||returned variables
24607 The following list describes all expansion variables that are
24608 available in the MIME ACL:
24609
24610 .push
24611 .indent 2em
24612
24613 .tempindent 0
24614 \$mime@_boundary$\:
24615 If the current part is a multipart (see \$mime@_is@_multipart$\) below, it
24616 should have a boundary string, which is stored in this variable. If the current
24617 part has no boundary parameter in the ::Content-Type:: header, this variable
24618 contains the empty string.
24619
24620 .tempindent 0
24621 \$mime@_charset$\:
24622 This variable contains the character set identifier, if one was found in the
24623 ::Content-Type:: header. Examples for charset identifiers are:
24624 .display asis
24625 us-ascii
24626 gb2312 (Chinese)
24627 iso-8859-1
24628 .endd
24629 Please note that this value is not normalized, so you should do matches
24630 case-insensitively.
24631
24632 .tempindent 0
24633 \$mime@_content@_description$\:
24634 This variable contains the normalized content of the ::Content-Description::
24635 header. It can contain a human-readable description of the parts content. Some
24636 implementations repeat the filename for attachments here, but they are
24637 usually only used for display purposes.
24638
24639 .tempindent 0
24640 \$mime@_content@_disposition$\:
24641 This variable contains the normalized content of the ::Content-Disposition::
24642 header. You can expect strings like `attachment' or `inline' here.
24643
24644 .tempindent 0
24645 \$mime@_content@_id$\:
24646 This variable contains the normalized content of the ::Content-ID:: header.
24647 This is a unique ID that can be used to reference a part from another part.
24648
24649 .tempindent 0
24650 \$mime@_content@_size$\:
24651 This variable is set only after the \decode\ modifier (see above) has been
24652 successfully run. It contains the size of the decoded part in kilobytes. The
24653 size is always rounded up to full kilobytes, so only a completely empty part
24654 has a \$mime@_content@_size$\ of zero.
24655
24656 .tempindent 0
24657 \$mime@_content@_transfer@_encoding$\:
24658 This variable contains the normalized content of the
24659 ::Content-transfer-encoding:: header. This is a symbolic name for an encoding
24660 type. Typical values are `base64' and `quoted-printable'.
24661
24662 .tempindent 0
24663 \$mime@_content@_type$\: If the MIME part has a ::Content-Type:: header, this
24664 variable contains its value, lowercased, and without any options (like `name'
24665 or `charset'). Here are some examples of popular MIME types, as they may appear
24666 in this variable:
24667 .display asis
24668 text/plain
24669 text/html
24670 application/octet-stream
24671 image/jpeg
24672 audio/midi
24673 .endd
24674 If the MIME part has no ::Content-Type:: header, this variable contains the
24675 empty string.
24676
24677 .tempindent 0
24678 \$mime@_decoded@_filename$\:
24679 This variable is set only after the \decode\ modifier (see above) has been
24680 successfully run. It contains the full path and file name of the file
24681 containing the decoded data.
24682
24683 .tempindent 0
24684 \$mime@_filename$\: This is perhaps the most important of the MIME variables.
24685 It contains a proposed filename for an attachment, if one was found in either
24686 the ::Content-Type:: or ::Content-Disposition:: headers. The filename will be
24687 RFC2047 decoded, but no additional sanity checks are done. If no filename was
24688 found, this variable contains the empty string.
24689
24690 .tempindent 0
24691 \$mime@_is@_coverletter$\:
24692 This variable attempts to differentiate the `cover letter' of an e-mail from
24693 attached data. It can be used to clamp down on flashy or unneccessarily encoded
24694 content in the cover letter, while not restricting attachments at all.
24695
24696 The variable contains 1 (true) for a MIME part believed to be part of the
24697 cover letter, and 0 (false) for an attachment. At present, the algorithm is as
24698 follows:
24699 .numberpars
24700 The outermost MIME part of a message is always a cover letter.
24701 .nextp
24702 If a multipart/alternative or multipart/related MIME part is a cover letter, so
24703 are all MIME subparts within that multipart.
24704 .nextp
24705 If any other multipart is a cover letter, the first subpart is a cover letter,
24706 and the rest are attachments.
24707 .nextp
24708 All parts contained within an attachment multipart are attachments.
24709 .endp
24710
24711 As an example, the following will ban `HTML mail' (including that sent with
24712 alternative plain text), while allowing HTML files to be attached. HTML 
24713 coverletter mail attached to non-HMTL coverletter mail will also be allowed:
24714 .display asis
24715 deny message = HTML mail is not accepted here
24716    !condition = $mime_is_rfc822
24717    condition = $mime_is_coverletter
24718    condition = ${if eq{$mime_content_type}{text/html}{1}{0}}
24719 .endd
24720
24721
24722 .tempindent 0
24723 \$mime@_is@_multipart$\:
24724 This variable has the value 1 (true) when the current part has the main type
24725 `multipart', for example `multipart/alternative' or `multipart/mixed'. Since
24726 multipart entities only serve as containers for other parts, you may not want
24727 to carry out specific actions on them.
24728
24729 .tempindent 0
24730 \$mime@_is@_rfc822$\:
24731 This variable has the value 1 (true) if the current part is not a part of the
24732 checked message itself, but part of an attached message. Attached message
24733 decoding is fully recursive.
24734
24735 .tempindent 0
24736 \$mime@_part@_count$\:
24737 This variable is a counter that is raised for each processed MIME part. It
24738 starts at zero for the very first part (which is usually a multipart). The
24739 counter is per-message, so it is reset when processing RFC822 attachments (see
24740 \$mime@_is@_rfc822$\). The counter stays set after \acl@_smtp@_mime\ is
24741 complete, so you can use it in the DATA ACL to determine the number of MIME
24742 parts of a message. For non-MIME messages, this variable contains the value -1.
24743
24744 .pop
24745
24746
24747 .section Scanning with regular expressions
24748 .rset SECTscanregex "~~chapter.~~section"
24749 .index content scanning||with regular expressions
24750 .index regular expressions||content scanning with
24751 You can specify your own custom regular expression matches on the full body of 
24752 the message, or on individual MIME parts.
24753
24754 The \regex\ condition takes one or more regular expressions as arguments and
24755 matches them against the full message (when called in the DATA ACL) or a raw
24756 MIME part (when called in the MIME ACL). The \regex\ condition matches
24757 linewise, with a maximum line length of 32K characters. That means you cannot
24758 have multiline matches with the \regex\ condition.
24759
24760 The \mime@_regex\ condition can be called only in the MIME ACL. It matches up
24761 to 32K of decoded content (the whole content at once, not linewise). If the
24762 part has not been decoded with the \decode\ modifier earlier in the ACL, it is
24763 decoded automatically when \mime@_regex\ is executed (using default path and
24764 filename values). If the decoded data is larger than  32K, only the first 32K
24765 characters are checked.
24766
24767 The regular expressions are passed as a colon-separated list. To include a
24768 literal colon, you must double it. Since the whole right-hand side string is
24769 expanded before being used, you must also escape dollar signs and backslashes
24770 with more backslashes, or use the \"@\N"\ facility to disable expansion.
24771 Here is a simple example that contains two regular expressions:
24772 .display asis
24773 deny message = contains blacklisted regex ($regex_match_string)
24774        regex = [Mm]ortgage : URGENT BUSINESS PROPOSAL
24775 .endd
24776 The conditions returns true if any one of the regular expressions matches. The
24777 \$regex@_match@_string$\ expansion variable is then set up and contains the
24778 matching regular expression.
24779
24780 \**Warning**\: With large messages, these conditions can be fairly
24781 CPU-intensive.
24782
24783
24784
24785 .section The demime condition
24786 .rset SECTdemimecond "~~chapter.~~section"
24787 .index content scanning||MIME checking
24788 .index MIME content scanning
24789 The \demime\ ACL condition provides MIME unpacking, sanity checking and file
24790 extension blocking. It uses a simpler interface to MIME decoding than the MIME
24791 ACL functionality, but provides no additional facilities. Please note that this
24792 condition is deprecated and kept only for for backward compatibility. You must
24793 set the \\WITH@_OLD@_DEMIME\\ option in \(Local/Makefile)\ at build time to be
24794 able to use the \demime\ condition.
24795
24796 The \demime\ condition unpacks MIME containers in the message. It detects
24797 errors in MIME containers and can match file extensions found in the message
24798 against a list. Using this facility produces files containing the unpacked MIME
24799 parts of the message in the temporary scan directory. If you do antivirus
24800 scanning, it is recommened that you use the \demime\ condition before the
24801 antivirus (\malware\) condition.
24802
24803 On the right-hand side of the \demime\ condition you can pass a colon-separated
24804 list of file extensions that it should match against. For example:
24805 .display asis
24806 deny message = Found blacklisted file attachment
24807      demime  = vbs:com:bat:pif:prf:lnk
24808 .endd
24809 If one of the file extensions is found, the condition is true, otherwise it is
24810 false. If there is a temporary error while demimeing (for example, `disk
24811 full'), the condition defers, and the message is temporarily rejected (unless
24812 the condition is on a \warn\ verb).
24813
24814 The right-hand side is expanded before being treated as a list, so you can have
24815 conditions and lookups there. If it expands to an empty string, `false', or
24816 zero (`0'), no demimeing is done and the condition is false.
24817
24818 The \demime\ condition set the following variables:
24819
24820 .push
24821 .indent 2em
24822
24823 .tempindent 0
24824 \$demime@_errorlevel$\: When an error is detected in a MIME container, this
24825 variable contains the severity of the error, as an integer number. The higher
24826 the value, the more severe the error. If this variable is unset or zero, no
24827 error occurred.
24828
24829 .tempindent 0
24830 \$demime@_reason$\: When \$demime@_errorlevel$\ is greater than zero, this
24831 variable contains a human-readable text string describing the MIME error that
24832 occurred.
24833
24834 .tempindent 0
24835 \$found@_extension$\: When the \demime\ condition is true, this variable
24836 contains the file extension it found.
24837  
24838 .pop 
24839  
24840 Both \$demime@_errorlevel$\ and \$demime@_reason$\ are set by the first call of
24841 the \demime\ condition, and are not changed on subsequent calls.
24842
24843 If you do not want to check for file extensions, but rather use the \demime\
24844 condition for unpacking or error checking purposes, pass `*' as the
24845 right-hand side value. Here is a more elaborate example of how to use this
24846 facility:
24847 .display asis
24848 # Reject messages with serious MIME container errors
24849 deny  message = Found MIME error ($demime_reason).
24850       demime = *
24851       condition = ${if >{$demime_errorlevel}{2}{1}{0}}
24852
24853 # Reject known virus spreading file extensions.
24854 # Accepting these is pretty much braindead.
24855 deny  message = contains $found_extension file (blacklisted).
24856       demime  = com:vbs:bat:pif:scr
24857
24858 # Freeze .exe and .doc files. Postmaster can
24859 # examine them and eventually thaw them.
24860 deny  log_message = Another $found_extension file.
24861       demime = exe:doc
24862       control = freeze
24863 .endd
24864
24865
24866 .nem
24867
24868
24869
24870 .
24871 .
24872 .
24873 .
24874 . ============================================================================
24875 .chapter Adding a local scan function to Exim
24876 .set runningfoot "local scan function"
24877 .rset CHAPlocalscan "~~chapter"
24878 .index \*local@_scan()*\ function||description of
24879 .index customizing||input scan using C function
24880 .index policy control||by local scan function
24881
24882 In these days of email worms, viruses, and ever-increasing spam, some sites
24883 want to apply a lot of checking to messages before accepting them. 
24884 .em
24885 The content scanning extension (chapter ~~CHAPexiscan) has facilities for 
24886 passing messages to external virus and spam scanning software. You can also do
24887 .nem
24888 a certain amount in Exim itself through string expansions and the \condition\
24889 condition in the ACL that runs after the SMTP \\DATA\\ command or the ACL for
24890 non-SMTP messages (see chapter ~~CHAPACL), but this has its limitations.
24891
24892 To allow for further customization to a site's own requirements, there is the
24893 possibility of linking Exim with a private message scanning function, written
24894 in C. If you want to run code that is written in something other than C, you
24895 can of course use a little C stub to call it.
24896
24897 The local scan function is run once for every incoming message, at the point
24898 when Exim is just about to accept the message.
24899 It can therefore be used to control non-SMTP messages from local processes as
24900 well as messages arriving via SMTP.
24901
24902 Exim applies a timeout to calls of the local scan function, and there is an
24903 option called \local@_scan@_timeout\ for setting it. The default is 5 minutes.
24904 Zero means `no timeout'.
24905 Exim also sets up signal handlers for SIGSEGV, SIGILL, SIGFPE, and SIGBUS
24906 before calling the local scan function, so that the most common types of crash
24907 are caught. If the timeout is exceeded or one of those signals is caught, the
24908 incoming message is rejected with a temporary error if it is an SMTP message.
24909 For a non-SMTP message, the message is dropped and Exim ends with a non-zero
24910 code. The incident is logged on the main and reject logs.
24911
24912
24913 .section Building Exim to use a local scan function
24914 .index \*local@_scan()*\ function||building Exim to use
24915 To make use of the local scan function feature, you must tell Exim where your
24916 function is before building Exim, by setting \\LOCAL@_SCAN@_SOURCE\\ in your
24917 \(Local/Makefile)\. A recommended place to put it is in the \(Local)\
24918 directory, so you might set
24919 .display asis
24920 LOCAL_SCAN_SOURCE=Local/local_scan.c
24921 .endd
24922 for example. The function must be called \*local@_scan()*\. It is called by
24923 Exim after it has received a message, when the success return code is about to
24924 be sent. This is after all the ACLs have been run. The return code from your
24925 function controls whether the message is actually accepted or not. There is a
24926 commented template function (that just accepts the message) in the file
24927 \(src/local@_scan.c)\.
24928
24929 If you want to make use of Exim's run time configuration file to set options
24930 for your \*local@_scan()*\ function, you must also set
24931 .display asis
24932 LOCAL_SCAN_HAS_OPTIONS=yes
24933 .endd
24934 in \(Local/Makefile)\ (see section ~~SECTconoptloc below).
24935
24936
24937
24938 .section API for local@_scan()
24939 .rset SECTapiforloc "~~chapter.~~section"
24940 .index \*local@_scan()*\ function||API description
24941 You must include this line near the start of your code:
24942 .display asis
24943 #include "local_scan.h"
24944 .endd
24945 This header file defines a number of variables and other values, and the
24946 prototype for the function itself. Exim is coded to use unsigned char values
24947 almost exclusively, and one of the things this header defines is a shorthand
24948 for \"unsigned char"\ called \"uschar"\.
24949 It also contains the following macro definitions, to simplify casting character
24950 strings and pointers to character strings:
24951 .display asis
24952 #define CS   (char *)
24953 #define CCS  (const char *)
24954 #define CSS  (char **)
24955 #define US   (unsigned char *)
24956 #define CUS  (const unsigned char *)
24957 #define USS  (unsigned char **)
24958 .endd
24959
24960 The function prototype for \*local@_scan()*\ is:
24961 .display asis
24962 extern int local_scan(int fd, uschar **return_text);
24963 .endd
24964 The arguments are as follows:
24965 .numberpars $.
24966 \fd\ is a file descriptor for the file that contains the body of the message
24967 (the -D file).
24968 The file is open for reading and writing, but updating it is not recommended.
24969 \**Warning**\: You must \*not*\ close this file descriptor.
24970
24971 The descriptor is positioned at character 19 of the file, which is the first
24972 character of the body itself, because the first 19 characters are the message
24973 id followed by \"-D"\ and a newline. If you rewind the file, you should use the
24974 macro \\SPOOL@_DATA@_START@_OFFSET\\ to reset to the start of the data, just in
24975 case this changes in some future version.
24976
24977 .nextp
24978 \return@_text\ is an address which you can use to return a pointer to a text
24979 string at the end of the function. The value it points to on entry is NULL.
24980 .endp
24981 The function must return an \int\ value which is one of the following macros:
24982 .numberpars $.
24983 \"LOCAL@_SCAN@_ACCEPT"\
24984
24985 The message is accepted. If you pass back a string of text, it is saved with
24986 the message, and made available in the variable \$local@_scan@_data$\. No
24987 newlines are permitted (if there are any, they are turned into spaces) and the
24988 maximum length of text is 1000 characters.
24989 .nextp
24990 \"LOCAL@_SCAN@_ACCEPT@_FREEZE"\
24991
24992 This behaves as \\LOCAL@_SCAN@_ACCEPT\\, except that the accepted message is
24993 queued without immediate delivery, and is frozen.
24994 .nextp
24995 \"LOCAL@_SCAN@_ACCEPT@_QUEUE"\
24996
24997 This behaves as \\LOCAL@_SCAN@_ACCEPT\\, except that the accepted message is
24998 queued without immediate delivery.
24999 .nextp
25000 \"LOCAL@_SCAN@_REJECT"\
25001
25002 The message is rejected; the returned text is used as an error message which is
25003 passed back to the sender and which is also logged. Newlines are permitted --
25004 they cause a multiline response for SMTP rejections, but are converted to
25005 \"@\n"\ in log lines.
25006 If no message is given, `Administrative prohibition' is used.
25007 .nextp
25008 \"LOCAL@_SCAN@_TEMPREJECT"\
25009
25010 The message is temporarily rejected; the returned text is used as an error
25011 message as for \\LOCAL@_SCAN@_REJECT\\. If no message is given, `Temporary
25012 local problem' is used.
25013 .nextp
25014 \"LOCAL@_SCAN@_REJECT@_NOLOGHDR"\
25015
25016 This behaves as \\LOCAL@_SCAN@_REJECT\\, except that the header of the rejected
25017 message is not written to the reject log. It has the effect of unsetting the
25018 \rejected@_header\ log selector for just this rejection. If \rejected@_header\
25019 is already unset (see the discussion of the \log@_selection\ option in section
25020 ~~SECTlogselector), this code is the same as \\LOCAL@_SCAN@_REJECT\\.
25021
25022 .nextp
25023 \"LOCAL@_SCAN@_TEMPREJECT@_NOLOGHDR"\
25024
25025 This code is a variation of \\LOCAL@_SCAN@_TEMPREJECT\\ in the same way that
25026 \\LOCAL__SCAN__REJECT__NOLOGHDR\\ is a variation of \\LOCAL@_SCAN@_REJECT\\.
25027 .endp
25028
25029 If the message is not being received by interactive SMTP, rejections are
25030 reported by writing to \stderr\ or by sending an email, as configured by the
25031 \-oe-\ command line options.
25032
25033
25034 .section Configuration options for local@_scan()
25035 .rset SECTconoptloc "~~chapter.~~section"
25036 .index \*local@_scan()*\ function||configuration options
25037 It is possible to have option settings in the main configuration file
25038 that set values in static variables in the \*local@_scan()*\ module. If you
25039 want to do this, you must have the line
25040 .display asis
25041 LOCAL_SCAN_HAS_OPTIONS=yes
25042 .endd
25043 in your \(Local/Makefile)\ when you build Exim. (This line is in
25044 \(OS/Makefile-Default)\, commented out). Then, in the \*local@_scan()*\ source
25045 file, you must define static variables to hold the option values, and a table to
25046 define them.
25047
25048 The table must be a vector called \local@_scan@_options\, of type
25049 \"optionlist"\. Each entry is a triplet, consisting of a name, an option type,
25050 and a pointer to the variable that holds the value. The entries must appear in
25051 alphabetical order. Following \local@_scan@_options\ you must also define a
25052 variable called \local@_scan@_options@_count\ that contains the number of
25053 entries in the table. Here is a short example, showing two kinds of option:
25054 .display asis
25055 static int my_integer_option = 42;
25056 static uschar *my_string_option = US"a default string";
25057
25058 optionlist local_scan_options[] = {
25059   { "my_integer", opt_int,       &my_integer_option },
25060   { "my_string",  opt_stringptr, &my_string_option }
25061 };
25062 int local_scan_options_count =
25063   sizeof(local_scan_options)/sizeof(optionlist);
25064 .endd
25065 The values of the variables can now be changed from Exim's runtime
25066 configuration file by including a local scan section as in this example:
25067 .display asis
25068 begin local_scan
25069 my_integer = 99
25070 my_string = some string of text...
25071 .endd
25072 The available types of option data are as follows:
25073
25074 .startitems
25075
25076 .item opt@_bool
25077 This specifies a boolean (true/false) option. The address should point to
25078 a variable of type \"BOOL"\, which will be set to \\TRUE\\ or \\FALSE\\, which
25079 are macros that are defined as `1' and `0', respectively. If you want to detect
25080 whether such a variable has been set at all, you can initialize it to
25081 \\TRUE@_UNSET\\. (BOOL variables are integers underneath, so can hold more than
25082 two values.)
25083
25084 .item "opt@_fixed"
25085 This specifies a fixed point number, such as is used for load averages.
25086 The address should point to a variable of type \"int"\. The value is stored
25087 multiplied by 1000, so, for example, 1.4142 is truncated and stored as 1414.
25088
25089 .item "opt@_int"
25090 This specifies an integer; the address should point to a variable of type
25091 \"int"\. The value may be specified in any of the integer formats accepted by
25092 Exim.
25093
25094 .item "opt@_mkint"
25095 This is the same as \opt@_int\, except that when such a value is output in a
25096 \-bP-\ listing, if it is an exact number of kilobytes or megabytes, it is
25097 printed with the suffix K or M.
25098
25099 .item "opt@_octint"
25100 This also specifies an integer, but the value is always interpeted as an
25101 octal integer, whether or not it starts with the digit zero, and it is
25102 always output in octal.
25103
25104 .item "opt@_stringptr"
25105 This specifies a string value; the address must be a pointer to a
25106 variable that points to a string (for example, of type \"uschar $*$"\).
25107
25108 .item "opt@_time"
25109 This specifies a time interval value. The address must point to a variable of
25110 type \"int"\. The value that is placed there is a number of seconds.
25111
25112 .enditems
25113
25114 If the \-bP-\ command line option is followed by \"local@_scan"\, Exim prints
25115 out the values of all the \*local@_scan()*\ options.
25116
25117
25118 .section Available Exim variables
25119 .index \*local@_scan()*\ function||available Exim variables
25120 The header \(local@_scan.h)\ gives you access to a number of C variables.
25121 These are the only ones that are guaranteed to be maintained from release to
25122 release. Note, however, that you can obtain the value of any Exim variable by
25123 calling \*expand@_string()*\. The exported variables are as follows:
25124
25125 .startitems
25126
25127 .item "unsigned int debug@_selector"
25128 This variable is set to zero when no debugging is taking place. Otherwise, it
25129 is a bitmap of debugging selectors. Two bits are identified for use in
25130 \*local@_scan()*\; they are defined as macros:
25131 .numberpars $.
25132 The \"D@_v"\ bit is set when \-v-\ was present on the command line. This is a
25133 testing option that is not privileged -- any caller may set it. All the
25134 other selector bits can be set only by admin users.
25135 .nextp
25136 The \"D@_local@_scan"\ bit is provided for use by \*local@_scan()*\; it is set
25137 by the \"+local@_scan"\ debug selector. It is not included in the default set
25138 of debugging bits.
25139 .endp
25140 Thus, to write to the debugging output only when \"+local@_scan"\ has been
25141 selected, you should use code like this:
25142 .display asis
25143 if ((debug_selector & D_local_scan) != 0)
25144   debug_printf("xxx", ...);
25145 .endd
25146
25147 .item "uschar *expand@_string@_message"
25148 After a failing call to \*expand@_string()*\ (returned value NULL), the
25149 variable \expand__string__message\ contains the error message, zero-terminated.
25150
25151 .item "header@_line *header@_list"
25152 A pointer to a chain of header lines. The \header@_line\ structure is discussed
25153 below.
25154
25155 .item "header@_line *header@_last"
25156 A pointer to the last of the header lines.
25157
25158 .item "uschar *headers@_charset"
25159 The value of the \headers@_charset\ configuration option.
25160
25161 .item "BOOL host@_checking"
25162 This variable is TRUE during a host checking session that is initiated by the
25163 \-bh-\ command line option.
25164
25165 .item "uschar *interface@_address"
25166 The IP address of the interface that received the message, as a string. This
25167 is NULL for locally submitted messages.
25168
25169 .item "int interface@_port"
25170 The port on which this message was received.
25171
25172 .item "uschar *message@_id"
25173 This variable contains the message id for the incoming message as a
25174 zero-terminated string.
25175
25176
25177 .item "uschar *received@_protocol"
25178 The name of the protocol by which the message was received.
25179
25180 .item "int recipients@_count"
25181 The number of accepted recipients.
25182
25183 .item "recipient@_item *recipients@_list"
25184 .index recipient||adding in local scan
25185 .index recipient||removing in local scan
25186 The list of accepted recipients, held in a vector of length
25187 \recipients@_count\. The \recipient@_item\ structure is discussed below. You
25188 can add additional recipients by calling \*receive@_add@_recipient()*\ (see
25189 below). You can delete recipients by removing them from the vector and adusting
25190 the value in \recipients@_count\. In particular, by setting \recipients@_count\
25191 to zero you remove all recipients. If you then return the value
25192 \"LOCAL@_SCAN@_ACCEPT"\, the message is accepted, but immediately blackholed.
25193 To replace the recipients, set \recipients@_count\ to zero and then call
25194 \*receive@_add@_recipient()*\ as often as needed.
25195
25196 .item "uschar *sender@_address"
25197 The envelope sender address. For bounce messages this is the empty string.
25198
25199 .item "uschar *sender@_host@_address"
25200 The IP address of the sending host, as a string. This is NULL for
25201 locally-submitted messages.
25202
25203 .item "uschar *sender@_host@_authenticated"
25204 The name of the authentication mechanism that was used, or NULL if the message
25205 was not received over an authenticated SMTP connection.
25206
25207 .item "uschar *sender@_host@_name"
25208 The name of the sending host, if known.
25209
25210 .item "int sender@_host@_port"
25211 The port on the sending host.
25212
25213 .item "BOOL smtp@_input"
25214 This variable is TRUE for all SMTP input, including BSMTP.
25215
25216 .item "BOOL smtp@_batched@_input"
25217 This variable is TRUE for BSMTP input.
25218
25219 .item "int store@_pool"
25220 The contents of this variable control which pool of memory is used for new
25221 requests. See section ~~SECTmemhanloc for details.
25222
25223 .enditems
25224
25225
25226 .section Structure of header lines
25227 The \header@_line\ structure contains the members listed below.
25228 You can add additional header lines by calling the \*header@_add()*\ function
25229 (see below). You can cause header lines to be ignored (deleted) by setting
25230 their type to $*$.
25231
25232 .startitems
25233
25234 .item "struct header@_line *next"
25235 A pointer to the next header line, or NULL for the last line.
25236
25237 .item "int type"
25238 A code identifying certain headers that Exim recognizes. The codes are printing
25239 characters, and are documented in chapter ~~CHAPspool of this manual. Notice in
25240 particular that any header line whose type is $*$ is not transmitted with the
25241 message. This flagging is used for header lines that have been rewritten, or
25242 are to be removed (for example, ::Envelope-sender:: header lines.) Effectively,
25243 $*$ means `deleted'.
25244
25245 .item "int slen"
25246 The number of characters in the header line, including the terminating and any
25247 internal newlines.
25248
25249 .item "uschar *text"
25250 A pointer to the text of the header. It always ends with a newline, followed by
25251 a zero byte. Internal newlines are preserved.
25252
25253 .enditems
25254
25255
25256
25257 .section Structure of recipient items
25258 The \recipient@_item\ structure contains these members:
25259
25260 .startitems
25261
25262 .item "uschar *address"
25263 This is a pointer to the recipient address as it was received.
25264
25265 .item "int pno"
25266 This is used in later Exim processing when top level addresses are created
25267 by the \one@_time\ option. It is not relevant at the time \*local@_scan()*\ is
25268 run and
25269 must always contain -1 at this stage.
25270
25271 .item "uschar *errors@_to"
25272 If this value is not NULL, bounce messages caused by failing to deliver to the
25273 recipient are sent to the address it contains. In other words, it overrides the
25274 envelope sender for this one recipient. (Compare the \errors@_to\ generic
25275 router option.)
25276 If a \*local@_scan()*\ function sets an \errors@_to\ field to an unqualified
25277 address, Exim qualifies it using the domain from \qualify@_recipient\.
25278 When \*local@_scan()*\ is called, the \errors@_to\ field is NULL for all
25279 recipients.
25280 .enditems
25281
25282
25283 .section Available Exim functions
25284 .index \*local@_scan()*\ function||available Exim functions
25285 The header \(local@_scan.h)\ gives you access to a number of Exim functions.
25286 These are the only ones that are guaranteed to be maintained from release to
25287 release:
25288
25289 .startitems
25290
25291 .item "pid@_t child@_open(uschar **argv, uschar **envp, int newumask, int *infdptr, int *outfdptr, BOOL make@_leader)"
25292 This function creates a child process that runs the command specified by
25293 \argv\. The environment for the process is specified by \envp\, which can be
25294 NULL if no environment variables are to be passed. A new umask is supplied for
25295 the process in \newumask\.
25296
25297 Pipes to the standard input and output of the new process are set up
25298 and returned to the caller via the \infdptr\ and \outfdptr\ arguments. The
25299 standard error is cloned to the standard output. If there are any file
25300 descriptors `in the way' in the new process, they are closed. If the final
25301 argument is TRUE, the new process is made into a process group leader.
25302
25303 The function returns the pid of the new process, or -1 if things go wrong.
25304
25305
25306 .item "int child@_close(pid@_t pid, int timeout)"
25307 This function waits for a child process to terminate, or for a timeout (in
25308 seconds) to expire. A timeout value of zero means wait as long as it takes. The
25309 return value is as follows:
25310 .numberpars $.
25311 >= 0
25312
25313 The process terminated by a normal exit and the value is the process ending
25314 status.
25315 .nextp
25316 < 0 and > --256
25317
25318 The process was terminated by a signal and the value is the negation of the
25319 signal number.
25320 .nextp
25321 --256
25322
25323 The process timed out.
25324 .nextp
25325 --257
25326
25327 The was some other error in wait(); \errno\ is still set.
25328 .endp
25329
25330
25331 .item "pid@_t child@_open@_exim(int *fd)"
25332 This function provide you with a means of submitting a new message to
25333 Exim. (Of course, you can also call \(/usr/sbin/sendmail)\ yourself if you
25334 want, but this packages it all up for you.) The function creates a pipe,
25335 forks a subprocess that is running
25336 .display asis
25337 exim -t -oem -oi -f <>
25338 .endd
25339 and returns to you (via the \"int *"\ argument) a file descriptor for the pipe
25340 that is connected to the standard input. The yield of the function is the PID
25341 of the subprocess. You can then write a message to the file descriptor, with
25342 recipients in ::To::, ::Cc::, and/or ::Bcc:: header lines.
25343
25344 When you have finished, call \*child@_close()*\ to wait for the process to
25345 finish and to collect its ending status. A timeout value of zero is usually
25346 fine in this circumstance. Unless you have made a mistake with the recipient
25347 addresses, you should get a return code of zero.
25348
25349 .item "void debug@_printf(char *, ...)"
25350 This is Exim's debugging function, with arguments as for \*(printf()*\. The
25351 output is written to the standard error stream. If no debugging is selected,
25352 calls to \*debug@_printf()*\ have no effect. Normally, you should make calls
25353 conditional on the \"local@_scan"\ debug selector by coding like this:
25354 .display asis
25355 if ((debug_selector & D_local_scan) != 0)
25356   debug_printf("xxx", ...);
25357 .endd
25358
25359 .item "uschar *expand@_string(uschar *string)"
25360 This is an interface to Exim's string expansion code. The return value is the
25361 expanded string, or NULL if there was an expansion failure.
25362 The C variable \expand@_string@_message\ contains an error message after an
25363 expansion failure. If expansion does not change the string, the return value is
25364 the pointer to the input string. Otherwise, the return value points to a new
25365 block of memory that was obtained by a call to \*store@_get()*\. See section
25366 ~~SECTmemhanloc below for a discussion of memory handling.
25367
25368 .item "void header@_add(int type, char *format, ...)"
25369 .em
25370 This function allows you to an add additional header line at the end of the 
25371 existing ones.
25372 .nem
25373 The first argument is the type, and should normally be a space character. The
25374 second argument is a format string and any number of substitution arguments as
25375 for \*sprintf()*\. You may include internal newlines if you want, and you must
25376 ensure that the string ends with a newline.
25377
25378 .em
25379 .item "void header@_add@_at@_position(BOOL after, uschar *name, BOOL topnot, int type, char *$nh{format}, ...)"
25380 This function adds a new header line at a specified point in the header
25381 chain. The header itself is specified as for \*header@_add()*\.
25382
25383 If \name\ is NULL, the new header is added at the end of the chain if \after\
25384 is true, or at the start if \after\ is false. If \name\ is not NULL, the header
25385 lines are searched for the first non-deleted header that matches the name. If
25386 one is found, the new header is added before it if \after\ is false. If \after\
25387 is true, the new header is added after the found header and any adjacent
25388 subsequent ones with the same name (even if marked `deleted'). If no matching
25389 non-deleted header is found, the \topnot\ option controls where the header is
25390 added. If it is true, addition is at the top; otherwise at the bottom. Thus, to
25391 add a header after all the ::Received:: headers, or at the top if there are no
25392 ::Received:: headers, you could use
25393 .display asis
25394 header_add_at_position(TRUE, US"Received", TRUE, 
25395   ' ', "X-xxx: ...");
25396 .endd
25397 Normally, there is always at least one non-deleted ::Received:: header, but
25398 there may not be if \received@_header@_text\ expands to an empty string.
25399
25400
25401 .item "void header@_remove(int occurrence, uschar *name)"
25402 This function removes header lines. If \occurrence\ is zero or negative, all
25403 occurrences of the header are removed. If occurrence is greater than zero, that
25404 particular instance of the header is removed. If no header(s) can be found that
25405 match the specification, the function does nothing.
25406
25407
25408 .item "BOOL header@_testname(header@_line *hdr, uschar *name, int length, BOOL notdel)"
25409 This function tests whether the given header has the given name. It is not just
25410 a string comparison, because whitespace is permitted between the name and the
25411 colon. If the \notdel\ argument is true, a false return is forced for all
25412 `deleted' headers; otherwise they are not treated specially. For example:
25413 .display asis
25414 if (header_testname(h, US"X-Spam", 6, TRUE)) ...
25415 .endd
25416 .nem
25417
25418
25419 .item "uschar *lss@_b64encode(uschar *cleartext, int length)"
25420 .index base64 encoding||functions for \*local@_scan()*\ use
25421 This function base64-encodes a string, which is passed by address and length.
25422 The text may contain bytes of any value, including zero. The result is passed
25423 back in dynamic memory that is obtained by calling \*store@_get()*\. It is
25424 zero-terminated.
25425
25426 .item "int lss@_b64decode(uschar *codetext, uschar **cleartext)"
25427 This function decodes a base64-encoded string. Its arguments are a
25428 zero-terminated base64-encoded string and the address of a variable that is set
25429 to point to the result, which is in dynamic memory. The length of the
25430 decoded string is the yield of the function. If the input is invalid base64
25431 data, the yield is -1. A zero byte is added to the end of the output string to
25432 make it easy to interpret as a C string (assuming it contains no zeros of its
25433 own). The added zero byte is not included in the returned count.
25434
25435 .item "int lss@_match@_domain(uschar *domain, uschar *list)"
25436 This function checks for a match in a domain list. Domains are always
25437 matched caselessly. The return value is one of the following:
25438 .display
25439 OK     $rm{match succeeded}
25440 FAIL   $rm{match failed}
25441 DEFER  $rm{match deferred}
25442 .endd
25443 DEFER is usually caused by some kind of lookup defer, such as the
25444 inability to contact a database.
25445
25446 .item "int lss@_match@_local@_part(uschar *localpart, uschar *list, BOOL caseless)"
25447 This function checks for a match in a local part list. The third argument
25448 controls case-sensitivity. The return values are as for
25449 \*lss@_match@_domain()*\.
25450
25451 .item "int lss@_match@_address(uschar *address, uschar *list, BOOL caseless)"
25452 This function checks for a match in an address list. The third argument
25453 controls the case-sensitivity of the local part match. The domain is always
25454 matched caselessly. The return values are as for \*lss@_match@_domain()*\.
25455
25456 .item "int lss@_match@_host(uschar *host@_name, uschar *host@_address, uschar *list)"
25457 This function checks for a match in a host list. The most common usage is
25458 expected to be
25459 .display asis
25460 lss_match_host(sender_host_name, sender_host_address, ...)
25461 .endd
25462 An empty address field matches an empty item in the host list. If the
25463 host name is NULL, the name corresponding to \$sender@_host@_address$\ is
25464 automatically looked up if a host name is required to match an item in the
25465 list. The return values are as for \*lss@_match@_domain()*\, but in addition,
25466 \*lss@_match@_host()*\ returns ERROR in the case when it had to look up a host
25467 name, but the lookup failed.
25468
25469 .item "void log@_write(unsigned int selector, int which, char *format, ...)"
25470 This function writes to Exim's log files. The first argument should be zero (it
25471 is concerned with \log@_selector\). The second argument can be \"LOG@_MAIN"\ or
25472 \"LOG@_REJECT"\ or
25473 \"LOG@_PANIC"\ or the inclusive `or' of any combination of them. It specifies
25474 to which log or logs the message is written.
25475 The remaining arguments are a format and relevant insertion arguments. The
25476 string should not contain any newlines, not even at the end.
25477
25478
25479 .item "void receive@_add@_recipient(uschar *address, int pno)"
25480 This function adds an additional recipient to the message. The first argument
25481 is the recipient address. If it is unqualified (has no domain), it is qualified
25482 with the \qualify@_recipient\ domain. The second argument must always be -1.
25483
25484 This function does not allow you to specify a private \errors@_to\ address (as
25485 described with the structure of \recipient@_item\ above), because it pre-dates
25486 the addition of that field to the structure. However, it is easy to add such a
25487 value afterwards. For example:
25488 .display asis
25489 receive_add_recipient(US"monitor@mydom.example", -1);
25490 recipients_list[recipients_count-1].errors_to =
25491   US"postmaster@mydom.example";
25492 .endd
25493
25494 .em
25495 .item "BOOL receive@_remove@_recipient(uschar *recipient)"
25496 This is a convenience function to remove a named recipient from the
25497 list of recipients. It returns true if a recipient was removed, and
25498 false if no matching recipient could be found. The argument must be a
25499 complete email address.
25500 .nem
25501
25502
25503 .item "uschar *rfc2047@_decode(uschar *string, BOOL lencheck, uschar *target, int zeroval, int *lenptr, uschar **error)"
25504 This function decodes strings that are encoded according to RFC 2047. Typically
25505 these are the contents of header lines. First, each encoded `word' is decoded
25506 from the Q or B encoding into a byte-string. Then, if provided with the name of
25507 a charset encoding, and if the \*iconv()*\ function is available, an attempt is
25508 made  to translate the result to the named character set. If this fails, the
25509 binary string is returned with an error message.
25510
25511 The first argument is the string to be decoded. If \lencheck\ is TRUE, the
25512 maximum MIME word length is enforced. The third argument is the target
25513 encoding, or NULL if no translation is wanted.
25514
25515 .index binary zero||in RFC 2047 decoding
25516 If a binary zero is encountered in the decoded string, it is replaced by the
25517 contents of the \zeroval\ argument. For use with Exim headers, the value must
25518 not be 0 because header lines are handled as zero-terminated strings.
25519
25520 The function returns the result of processing the string, zero-terminated; if
25521 \lenptr\ is not NULL, the length of the result is set in the variable to which
25522 it points. When \zeroval\ is 0, \lenptr\ should not be NULL.
25523
25524 If an error is encountered, the function returns NULL and uses the \error\
25525 argument to return an error message. The variable pointed to by \error\ is set
25526 to NULL if there is no error; it may be set non-NULL even when the function
25527 returns a non-NULL value if decoding was successful, but there was a problem
25528 with translation.
25529
25530
25531 .item "int smtp@_fflush(void)"
25532 This function is used in conjunction with \*smtp@_printf()*\, as described
25533 below.
25534
25535 .item "void smtp@_printf(char *, ...)"
25536 The arguments of this function are like \*printf()*\; it writes to the SMTP
25537 output stream. You should use this function only when there is an SMTP output
25538 stream, that is, when the incoming message is being received via interactive
25539 SMTP. This is the case when \smtp@_input\ is TRUE and \smtp@_batched@_input\ is
25540 FALSE. If you want to test for an incoming message from another host (as
25541 opposed to a local process that used the \-bs-\ command line option), you can
25542 test the value of \sender@_host@_address\, which is non-NULL when a remote host
25543 is involved.
25544
25545 If an SMTP TLS connection is established, \*smtp@_printf()*\ uses the TLS
25546 output function, so it can be used for all forms of SMTP connection.
25547
25548 Strings that are written by \*smtp@_printf()*\ from within \*local@_scan()*\
25549 must start with an appropriate response code: 550 if you are going to return
25550 \\LOCAL@_SCAN@_REJECT\\, 451 if you are going to return
25551 \\LOCAL@_SCAN@_TEMPREJECT\\, and 250 otherwise. Because you are writing the
25552 initial lines of a multi-line response, the code must be followed by a hyphen
25553 to indicate that the line is not the final response line. You must also ensure
25554 that the lines you write terminate with CRLF. For example:
25555 .display asis
25556 smtp_printf("550-this is some extra info\r\n");
25557 return LOCAL_SCAN_REJECT;
25558 .endd
25559 Note that you can also create multi-line responses by including newlines in
25560 the data returned via the \return@_text\ argument. The added value of using
25561 \*smtp@_printf()*\ is that, for instance, you could introduce delays between
25562 multiple output lines.
25563
25564 The \*smtp@_printf()*\ function does not return any error indication, because it
25565 does not automatically flush pending output, and therefore does not test
25566 the state of the stream. (In the main code of Exim, flushing and error
25567 detection is done when Exim is ready for the next SMTP input command.) If
25568 you want to flush the output and check for an error (for example, the
25569 dropping of a TCP/IP connection), you can call \*smtp@_fflush()*\, which has no
25570 arguments. It flushes the output stream, and returns a non-zero value if there
25571 is an error.
25572
25573 .item "void *store@_get(int)"
25574 This function accesses Exim's internal store (memory) manager. It gets a new
25575 chunk of memory whose size is given by the argument. Exim bombs out if it ever
25576 runs out of memory. See the next section for a discussion of memory handling.
25577
25578 .item "void *store@_get@_perm(int)"
25579 This function is like \*store@_get()*\, but it always gets memory from the
25580 permanent pool. See the next section for a discussion of memory handling.
25581
25582 .item "uschar *string@_copy(uschar *string)"
25583 .item "uschar *string@_copyn(uschar *string, int length)" 0
25584 .item "uschar *string@_sprintf(char *format, ...)" 0
25585 These three functions create strings using Exim's dynamic memory facilities.
25586 The first makes a copy of an entire string. The second copies up to a maximum
25587 number of characters, indicated by the second argument. The third uses a format
25588 and insertion arguments to create a new string. In each case, the result is a
25589 pointer to a new string
25590 in the current memory pool. See the next section for more discussion.
25591
25592 .enditems
25593
25594
25595
25596 .section More about Exim's memory handling
25597 .rset SECTmemhanloc "~~chapter.~~section"
25598 .index \*local@_scan()*\ function||memory handling
25599 No function is provided for freeing memory, because that is never needed.
25600 The dynamic memory that Exim uses when receiving a message is automatically
25601 recycled if another message is received by the same process (this applies only
25602 to incoming SMTP connections -- other input methods can supply only one message
25603 at a time). After receiving the last message, a reception process terminates.
25604
25605 Because it is recycled, the normal dynamic memory cannot be used for holding
25606 data that must be preserved over a number of incoming messages on the same SMTP
25607 connection. However, Exim in fact uses two pools of dynamic memory; the second
25608 one is not recycled, and can be used for this purpose.
25609
25610 If you want to allocate memory that remains available for subsequent messages
25611 in the same SMTP connection, you should set
25612 .display asis
25613 store_pool = POOL_PERM
25614 .endd
25615 before calling the function that does the allocation. There is no need to
25616 restore the value if you do not need to; however, if you do want to revert to
25617 the normal pool, you can either restore the previous value of \store@_pool\ or
25618 set it explicitly to \\POOL@_MAIN\\.
25619
25620 The pool setting applies to all functions that get dynamic memory, including
25621 \*expand@_string()*\, \*store@_get()*\, and the \*string@_xxx()*\ functions.
25622 There is also a convenience function called \*store__get__perm()*\ that gets a
25623 block of memory from the permanent pool while preserving the value of
25624 \store@_pool\.
25625
25626
25627
25628
25629
25630 .
25631 .
25632 .
25633 .
25634 . ============================================================================
25635 .chapter System-wide message filtering
25636 .set runningfoot "system filtering"
25637 .rset CHAPsystemfilter "~~chapter"
25638 .index filter||system filter
25639 .index filtering all mail
25640 .index system filter
25641 The previous chapters (on ACLs and the local scan function) describe checks
25642 that can be applied to messages before they are accepted by a host. There is
25643 also a mechanism for checking messages once they have been received, but before
25644 they are delivered. This is called the $it{system filter}.
25645
25646 The system filter operates in a similar manner to users' filter files, but it
25647 is run just once per message (however many recipients the message has).
25648 It should not normally be used as a substitute for routing, because \deliver\
25649 commands in a system router provide new envelope recipient addresses.
25650 The system filter must be an Exim filter. It cannot be a Sieve filter.
25651
25652 The system filter is run at the start of a delivery attempt, before any routing
25653 is done. If a message fails to be completely delivered at the first attempt,
25654 the system filter is run again at the start of every retry.
25655 If you want your filter to do something only once per message, you can make use
25656 of the \first@_delivery\ condition in an \if\ command in the filter to prevent
25657 it happening on retries.
25658
25659 \**Warning**\: Because the system filter runs just once, variables that are
25660 specific to individual recipient addresses, such as \$local@_part$\ and
25661 \$domain$\, are not set, and the `personal' condition is not meaningful. If you
25662 want to run a centrally-specified filter for each recipient address
25663 independently, you can do so by setting up a suitable \%redirect%\ router, as
25664 described in section ~~SECTperaddfil below.
25665
25666 .section Specifying a system filter
25667 .index uid (user id)||system filter
25668 .index gid (group id)||system filter
25669 The name of the file that contains the system filter must be specified by
25670 setting \system@_filter\. If you want the filter to run under a uid and gid
25671 other than root, you must also set \system@_filter@_user\ and
25672 \system@_filter@_group\ as appropriate. For example:
25673 .display asis
25674 system_filter = /etc/mail/exim.filter
25675 system_filter_user = exim
25676 .endd
25677 If a system filter generates any deliveries directly to files or pipes (via the
25678 \save\ or \pipe\ commands), transports to handle these deliveries must be
25679 specified by setting \system@_filter@_file@_transport\ and
25680 \system@_filter@_pipe@_transport\, respectively. Similarly,
25681 \system@_filter@_reply@_transport\ must be set to handle any messages generated
25682 by the \reply\ command.
25683
25684 .section Testing a system filter
25685 You can run simple tests of a system filter in the same way as for a user
25686 filter, but you should use \-bF-\ rather than \-bf-\, so that features that
25687 are permitted only in system filters are recognized.
25688 .em
25689 If you want to test the combined effect of a system filter and a user filter, 
25690 you can use both \-bF-\ and \-bf-\ on the same command line.
25691 .nem
25692
25693 .section Contents of a system filter
25694 The language used to specify system filters is the same as for users' filter
25695 files. It is described in the separate end-user document \*Exim's interface to
25696 mail filtering*\. However, there are some additional features that are
25697 available only in system filters; these are described in subsequent sections.
25698 If they are encountered in a user's filter file or when testing with \-bf-\,
25699 they cause errors.
25700
25701 .index frozen messages||manual thaw, testing in filter
25702 There are two special conditions which, though available in users' filter
25703 files, are designed for use in system filters. The condition \first@_delivery\
25704 is true only for the first attempt at delivering a message, and
25705 \manually@_thawed\ is true only if the message has been frozen, and
25706 subsequently thawed by an admin user. An explicit forced delivery counts as a
25707 manual thaw, but thawing as a result of the \auto__thaw\ setting does not.
25708
25709 \**Warning**\: If a system filter uses the \first@_delivery\ condition to
25710 specify an `unseen' (non-significant) delivery, and that delivery does not
25711 succeed, it will not be tried again.
25712 If you want Exim to retry an unseen delivery until it succeeds, you should
25713 arrange to set it up every time the filter runs.
25714
25715 When a system filter finishes running, the values of the variables \$n0$\ --
25716 \$n9$\ are copied into \$sn0$\ -- \$sn9$\ and are thereby made available to
25717 users' filter files. Thus a system filter can, for example, set up `scores' to
25718 which users' filter files can refer.
25719
25720
25721 .section Additional variable for system filters
25722 The expansion variable \$recipients$\, containing a list of all the recipients
25723 of the message (separated by commas and white space), is available in system
25724 filters. It is not available in users' filters for privacy reasons.
25725
25726
25727 .section Defer, freeze, and fail commands for system filters
25728 .index freezing messages
25729 .index message||freezing
25730 .index message||forced failure
25731 .index \fail\||in system filter
25732 .index \freeze\ in system filter
25733 .index \defer\ in system filter
25734 There are three extra commands (\defer\, \freeze\ and \fail\) which are always
25735 available in system filters, but are not normally enabled in users' filters.
25736 (See the \allow@_defer\,
25737 \allow@_freeze\ and \allow@_fail\ options for the \%redirect%\ router.) These
25738 commands can optionally be followed by the word \text\ and a string containing
25739 an error message, for example:
25740 .display asis
25741 fail text "this message looks like spam to me"
25742 .endd
25743 The keyword \text\ is optional if the next character is a double quote.
25744
25745 The \defer\ command defers delivery of the original recipients of the message.
25746 The \fail\ command causes all the original recipients to be failed, and a
25747 bounce message to be created. The \freeze\ command suspends all delivery
25748 attempts for the original recipients. In all cases, any new deliveries that are
25749 specified by the filter are attempted as normal after the filter has run.
25750
25751 The \freeze\ command is ignored if the message has been manually unfrozen and
25752 not manually frozen since. This means that automatic freezing by a system
25753 filter can be used as a way of checking out suspicious messages. If a message
25754 is found to be all right, manually unfreezing it allows it to be delivered.
25755
25756 .index log||\fail\ command log line
25757 .index \fail\||log line, reducing
25758 The text given with a fail command is used as part of the bounce message as
25759 well as being written to the log. If the message is quite long, this can fill
25760 up a lot of log space when such failures are common. To reduce the size of the
25761 log message, Exim interprets the text in a special way if it starts with the
25762 two characters \"@<@<"\ and contains \"@>@>"\ later. The text between these two
25763 strings is written to the log, and the rest of the text is used in the bounce
25764 message. For example:
25765 .display asis
25766 fail "<<filter test 1>>Your message is rejected \
25767      because it contains attachments that we are \
25768      not prepared to receive."
25769 .endd
25770
25771 .index loop||caused by \fail\
25772 Take great care with the \fail\ command when basing the decision to fail on the
25773 contents of the message, because the bounce message will of course include the
25774 contents of the original message and will therefore trigger the \fail\ command
25775 again (causing a mail loop) unless steps are taken to prevent this. Testing the
25776 \error@_message\ condition is one way to prevent this. You could use, for
25777 example
25778 .display asis
25779 if $message_body contains "this is spam" and not error_message
25780   then fail text "spam is not wanted here" endif
25781 .endd
25782 though of course that might let through unwanted bounce messages. The
25783 alternative is clever checking of the body and/or headers to detect bounces
25784 generated by the filter.
25785
25786 The interpretation of a system filter file ceases after a
25787 \defer\,
25788 \freeze\, or \fail\ command is obeyed. However, any deliveries that were set up
25789 earlier in the filter file are honoured, so you can use a sequence such as
25790 .display asis
25791 mail ...
25792 freeze
25793 .endd
25794 to send a specified message when the system filter is freezing (or deferring or
25795 failing) a message. The normal deliveries for the message do not, of course,
25796 take place.
25797
25798
25799 .section Adding and removing headers in a system filter
25800 .rset SECTaddremheasys "~~chapter.~~section"
25801 .index header lines||adding, in system filter
25802 .index header lines||removing, in system filter
25803 .index filter||header lines, adding/removing
25804 Two filter commands that are available only in system filters are:
25805 .display
25806 headers add <<string>>
25807 headers remove <<string>>
25808 .endd
25809 The argument for the \headers add\ is a string that is expanded and then added
25810 to the end of the message's headers. It is the responsibility of the filter
25811 maintainer to make sure it conforms to RFC 2822 syntax. Leading white space is
25812 ignored, and if the string is otherwise empty, or if the expansion is forced to
25813 fail, the command has no effect.
25814
25815 You can use `@\n' within the string, followed by white space, to specify
25816 continued header lines. More than one header may be added in one command by
25817 including `@\n' within the string without any following white space. For
25818 example:
25819 .display asis
25820 headers add "X-header-1: ....\n  \
25821              continuation of X-header-1 ...\n\
25822              X-header-2: ...."
25823 .endd
25824 Note that the header line continuation white space after the first newline must
25825 be placed before the backslash that continues the input string, because white
25826 space after input continuations is ignored.
25827
25828 The argument for \headers remove\ is a colon-separated list of header names.
25829 This command applies only to those headers that are stored with the message;
25830 those that are added at delivery time (such as ::Envelope-To:: and
25831 ::Return-Path::) cannot be removed by this means. If there is more than one
25832 header with the same name, they are all removed.
25833
25834 .em
25835 The \headers\ command in a system filter makes an immediate change to the set
25836 of header lines that was received with the message (with possible additions 
25837 from ACL processing). Subsequent commands in the system filter operate on the
25838 modified set, which also forms the basis for subsequent message delivery. 
25839 Unless further modified during routing or transporting, this set of headers is 
25840 used for all recipients of the message.
25841
25842 During routing and transporting, the variables that refer to the contents of
25843 header lines refer only to those lines that are in this set. Thus, header lines
25844 that are added by a system filter are visible to users' filter files and to all
25845 routers and transports. This contrasts with the manipulation of header lines by
25846 routers and transports, which is not immediate, but which instead is saved up 
25847 until the message is actually being written (see section ~~SECTheadersaddrem).
25848
25849 If the message is not delivered at the first attempt, header lines that were
25850 added by the system filter are stored with the message, and so are still
25851 present at the next delivery attempt. Header lines that were removed are still
25852 present, but marked `deleted' so that they are not transported with the
25853 message. For this reason, it is usual to make the \headers\ command conditional
25854 on \first@_delivery\ so that the set of header lines is not modified more than 
25855 once.
25856
25857 Because header modification in a system filter acts immediately, you have to 
25858 use an indirect approach if you want to modify the contents of a header line. 
25859 For example:
25860 .display asis
25861 headers add "Old-Subject: $h_subject:"
25862 headers remove "Subject"
25863 headers add "Subject: new subject (was: $h_old-subject:)"
25864 headers remove "Old-Subject"
25865 .endd
25866 .nem
25867
25868
25869
25870 .section Setting an errors address in a system filter
25871 .index envelope sender
25872 In a system filter, if a \deliver\ command is followed by
25873 .display
25874 errors@_to <<some address>>
25875 .endd
25876 in order to change the envelope sender (and hence the error reporting) for that
25877 delivery, any address may be specified. (In a user filter, only the current
25878 user's address can be set.) For example, if some mail is being monitored, you
25879 might use
25880 .display asis
25881 unseen deliver monitor@spying.example errors_to root@local.example
25882 .endd
25883 to take a copy which would not be sent back to the normal error reporting
25884 address if its delivery failed.
25885
25886
25887 .section Per-address filtering
25888 .rset SECTperaddfil "~~chapter.~~section"
25889 In contrast to the system filter, which is run just once per message for each
25890 delivery attempt, it is also possible to set up a system-wide filtering
25891 operation that runs once for each recipient address. In this case, variables
25892 such as \$local@_part$\ and \$domain$\ can be used, and indeed, the choice of
25893 filter file could be made dependent on them. This is an example of a router
25894 which implements such a filter:
25895 .display asis
25896 central_filter:
25897 .newline
25898   check_local_user
25899 .newline
25900   driver = redirect
25901   domains = +local_domains
25902   file = /central/filters/$local_part
25903   no_verify
25904   allow_filter
25905   allow_freeze
25906 .endd
25907 The filter is run in a separate process under its own uid. Therefore, either
25908 \check@_local@_user\ must be set (as above), in which case the filter is run as
25909 the local user, or the \user\ option must be used to specify which user to use.
25910 If both are set, \user\ overrides.
25911
25912 Care should be taken to ensure that none of the commands in the filter file
25913 specify a significant delivery if the message is to go on to be delivered to
25914 its intended recipient. The router will not then claim to have dealt with the
25915 address, so it will be passed on to subsequent routers to be delivered in the
25916 normal way.
25917
25918
25919
25920
25921
25922
25923 .
25924 .
25925 .
25926 .
25927 . ============================================================================
25928 .chapter Message processing
25929 .set runningfoot "message processing"
25930 .rset CHAPmsgproc "~~chapter"
25931 .index message||general processing
25932 Exim performs various transformations on the sender and recipient addresses of
25933 all messages that it handles, and also on the messages' header lines. Some of
25934 these are optional and configurable, while others always take place. All of
25935 this processing, except rewriting as a result of routing, and the addition or
25936 removal of header lines while delivering, happens when a message is received,
25937 before it is placed on Exim's queue.
25938
25939 Some of the automatic processing takes place by default only for
25940 `locally-originated' messages. This adjective is used to describe messages that
25941 are not received over TCP/IP, but instead are passed to an Exim process on its
25942 standard input. This includes the interactive `local SMTP' case that is set up
25943 by the \-bs-\ command line option. 
25944
25945 \**Note**\: messages received over TCP/IP on the loopback interface (127.0.0.1
25946 or @:@:1) are not considered to be locally-originated. Exim does not treat the
25947 loopback interface specially in any way.
25948 .em
25949 If you want the loopback interface to be treated specially, you must ensure 
25950 that there are appropriate entries in your ACLs.
25951 .nem
25952
25953
25954 .section Submission mode for non-local messages
25955 .rset SECTsubmodnon "~~chapter.~~section"
25956 .index message||submission
25957 .index submission mode
25958 .em
25959 Processing that happens automatically for locally-originated messages can also
25960 be requested for other messages. The term `submission mode' is used to describe
25961 this state. Submisssion mode is set by the modifier
25962 .display asis
25963 control = submission
25964 .endd
25965 in a \\MAIL\\, \\RCPT\\, or pre-data ACL for an incoming SMTP message (see
25966 sections ~~SECTACLmodi and ~~SECTcontrols). This makes Exim treat the message
25967 as a local submission, and is normally used when the source of the message is
25968 known to be an MUA running on a client host (as opposed to an MTA). For
25969 example, to set submission mode for messages originating on the IPv4 loopback
25970 interface, you could include the following in the \\MAIL\\ ACL:
25971 .display asis
25972 warn  hosts = 127.0.0.1
25973       control = submission
25974 .endd
25975 There are some options that can be used when setting submission mode. A slash 
25976 is used to separate options. For example:
25977 .display asis
25978 control = submission/sender_retain
25979 .endd
25980 Specifying \sender@_retain\ has the effect of setting \local@_sender@_retain\
25981 true and \local@_from@_check\ false for the current incoming message. The first
25982 of these allows an existing ::Sender:: header in the message to remain, and the
25983 second suppresses the check to ensure that ::From:: matches the authenticated
25984 sender. With this setting, Exim still fixes up messages by adding ::Date:: and
25985 ::Message-ID:: header lines if they are missing, but makes no attempt to check
25986 sender authenticity in header lines.
25987
25988 A submission mode setting may also specify a domain to be used when generating 
25989 a ::From:: or ::Sender:: header. For example:
25990 .display asis
25991 control = submission/domain=some.domain
25992 .endd
25993 The domain may be empty. How this value is used is described in sections
25994 ~~SECTthefrohea and ~~SECTthesenhea.
25995 .nem
25996
25997
25998
25999 .section Line endings
26000 .rset SECTlineendings "~~chapter.~~section"
26001 .index line endings
26002 .index carriage return
26003 .index linefeed
26004 RFC 2821 specifies that CRLF (two characters: carriage-return, followed by
26005 linefeed) is the line ending for messages transmitted over the Internet using
26006 SMTP over TCP/IP. However, within individual operating systems, different
26007 conventions are used. For example, Unix-like systems use just LF, but others
26008 use CRLF or just CR.
26009
26010 Exim was designed for Unix-like systems, and internally, it stores messages
26011 using the system's convention of a single LF as a line terminator. When
26012 receiving a message, all line endings are translated to this standard format.
26013 Originally, it was thought that programs that passed messages directly to an
26014 MTA within an operating system would use that system's convention. Experience
26015 has shown that this is not the case; for example, there are Unix applications
26016 that use CRLF in this circumstance. For this reason, and for compatibility with
26017 other MTAs, the way Exim handles line endings for all messages is now as
26018 follows:
26019 .numberpars $.
26020 LF not preceded by CR is treated as a line ending.
26021 .nextp
26022 CR is treated as a line ending; if it is immediately followed by LF, the LF
26023 is ignored.
26024 .nextp
26025 The sequence `CR, dot, CR' does not terminate an incoming SMTP message,
26026 nor a local message in the state where a line containing only a dot is a
26027 terminator.
26028 .nextp
26029 If a bare CR is encountered within a header line, an extra space is added after
26030 the line terminator so as not to end the header line. The reasoning behind this
26031 is that bare CRs in header lines are most likely either to be mistakes, or
26032 people trying to play silly games.
26033 .nextp
26034 If the first header line received in a message ends with CRLF, a subsequent
26035 bare LF in a header line is treated in the same way as a bare CR in a header
26036 line.
26037 .endp
26038
26039
26040
26041 .section Unqualified addresses
26042 .index unqualified addresses
26043 .index address||qualification
26044 By default, Exim expects every envelope address it receives from an external
26045 host to be fully qualified. Unqualified addresses cause negative responses to
26046 SMTP commands. However, because SMTP is used as a means of transporting
26047 messages from MUAs running on personal workstations, there is sometimes a
26048 requirement to accept unqualified addresses from specific hosts or IP networks.
26049
26050 Exim has two options that separately control which hosts may send unqualified
26051 sender or receipient addresses in SMTP commands, namely
26052 \sender__unqualified__hosts\ and \recipient__unqualified__hosts\. In both
26053 cases, if an unqualified address is accepted, it is qualified by adding the
26054 value of \qualify__domain\ or \qualify__recipient\, as appropriate.
26055 .index \qualify@_domain\
26056 .index \qualify@_recipient\
26057
26058 .em
26059 Unqualified addresses in header lines are automatically qualified for messages 
26060 that are locally originated, unless the \-bnq-\ option is given on the command 
26061 line. For messages received over SMTP, unqualified addresses in header lines 
26062 are qualified only if unqualified addresses are permitted in SMTP commands. In 
26063 other words, such qualification is also controlled by 
26064 \sender__unqualified__hosts\ and \recipient__unqualified__hosts\,
26065 .nem
26066
26067
26068 .section The UUCP From line
26069 .index `From' line
26070 .index UUCP||`From' line
26071 .index sender||address
26072 .index \uucp@_from@_pattern\
26073 .index \uucp@_from@_sender\
26074 .index envelope sender
26075 .index Sendmail compatibility||`From' line
26076 Messages that have come from UUCP (and some other applications) often begin
26077 with a line containing the envelope sender and a timestamp, following the word
26078 `From'. Examples of two common formats are:
26079 .display asis
26080 From a.oakley@berlin.mus Fri Jan  5 12:35 GMT 1996
26081 From f.butler@berlin.mus Fri, 7 Jan 97 14:00:00 GMT
26082 .endd
26083 This line precedes the RFC 2822 header lines. For compatibility with Sendmail,
26084 Exim recognizes such lines at the start of messages that are submitted to it
26085 via the command line (that is, on the standard input). It does not recognize
26086 such lines in incoming SMTP messages, unless the sending host matches
26087 \ignore@_fromline@_hosts\ or the \-bs-\ option was used for a local message and
26088 \ignore@_fromline@_local\ is set. The recognition is controlled by a regular
26089 expression that is defined by the \uucp@_from@_pattern\ option, whose default
26090 value matches the two common cases shown above and puts the address that
26091 follows `From' into \$1$\.
26092
26093 .index numerical variables (\$1$\, \$2$\, etc)||in `From ' line handling
26094 When the caller of Exim for a non-SMTP message that contains a `From' line is a
26095 trusted user, the message's sender address is constructed by expanding the
26096 contents of \uucp@_sender@_address\, whose default value is `@$1'. This is then
26097 parsed as an RFC 2822 address. If there is no domain, the local part is
26098 qualified with \qualify@_domain\ unless it is the empty string. However, if the
26099 command line \-f-\ option is used, it overrides the `From' line.
26100
26101 If the caller of Exim is not trusted, the `From' line is recognized, but the
26102 sender address is not changed. This is also the case for incoming SMTP messages
26103 that are permitted to contain `From' lines.
26104
26105 Only one `From' line is recognized. If there is more than one, the second is
26106 treated as a data line that starts the body of the message, as it is not valid
26107 as a header line. This also happens if a `From' line is present in an incoming
26108 SMTP message from a source that is not permitted to send them.
26109
26110
26111 .section Resent- header lines
26112 .index \Resent@-\ header lines
26113 RFC 2822 makes provision for sets of header lines starting with the string
26114 \"Resent-"\ to be added to a message when it is resent by the original
26115 recipient to somebody else. These headers are ::Resent-Date::, ::Resent-From::,
26116 ::Resent-Sender::, ::Resent-To::, ::Resent-Cc::, ::Resent-Bcc:: and
26117 ::Resent-Message-ID::. The RFC says:
26118
26119 \*Resent fields are strictly informational. They MUST NOT be used in the normal
26120 processing of replies or other such automatic actions on messages.*\
26121
26122 This leaves things a bit vague as far as other processing actions such as
26123 address rewriting are concerned. Exim treats \Resent@-\ header lines as
26124 follows:
26125 .numberpars $.
26126 A ::Resent-From:: line that just contains the login id of the submitting user
26127 is automatically rewritten in the same way as ::From:: (see below).
26128 .nextp
26129 If there's a rewriting rule for a particular header line, it is also applied to
26130 \Resent@-\ header lines of the same type. For example, a rule that rewrites
26131 ::From:: also rewrites ::Resent-From::.
26132 .nextp
26133 For local messages, if ::Sender:: is removed on input, ::Resent-Sender:: is also
26134 removed.
26135 .nextp
26136 For a locally-submitted message,
26137 if there are any \Resent@-\ header lines but no ::Resent-Date::,
26138 ::Resent-From::, or ::Resent-Message-Id::, they are added as necessary. It is
26139 the contents of ::Resent-Message-Id:: (rather than ::Message-Id::) which are
26140 included in log lines in this case.
26141 .nextp
26142 The logic for adding ::Sender:: is duplicated for ::Resent-Sender:: when any
26143 \Resent@-\ header lines are present.
26144 .endp
26145
26146
26147 .section The Auto-Submitted: header line
26148 Whenever Exim generates a bounce or a delay warning message, it includes the
26149 header line
26150 .display asis
26151 Auto-Submitted: auto-generated
26152 .endd
26153
26154
26155 .section The Bcc: header line
26156 .index ::Bcc:: header line
26157 If Exim is called with the \-t-\ option, to take recipient addresses from a
26158 message's header, it removes any ::Bcc:: header line that may exist (after
26159 extracting its addresses). If \-t-\ is not present on the command line, any
26160 existing ::Bcc:: is not removed.
26161
26162 .section The Date: header line
26163 .index ::Date:: header line
26164 If a locally-generated
26165 or submission-mode
26166 message has no ::Date:: header line, Exim adds one, using the current date and
26167 time.
26168
26169 .section The Delivery-date: header line
26170 .index ::Delivery-date:: header line
26171 .index \delivery@_date@_remove\
26172 ::Delivery-date:: header lines are not part of the standard RFC 2822 header
26173 set. Exim can be configured to add them to the final delivery of messages. (See
26174 the generic \delivery@_date@_add\ transport option.) They should not be present
26175 in messages in transit. If the \delivery@_date@_remove\ configuration option is
26176 set (the default), Exim removes ::Delivery-date:: header lines from incoming
26177 messages.
26178
26179 .section The Envelope-to: header line
26180 .index ::Envelope-to:: header line
26181 .index \envelope@_to@_remove\
26182 ::Envelope-to:: header lines are not part of the standard RFC 2822 header set.
26183 Exim can be configured to add them to the final delivery of messages. (See the
26184 generic \envelope@_to@_add\ transport option.) They should not be present in
26185 messages in transit. If the \envelope@_to@_remove\ configuration option is set
26186 (the default), Exim removes ::Envelope-to:: header lines from incoming
26187 messages.
26188
26189 .section The From: header line
26190 .rset SECTthefrohea "~~chapter.~~section"
26191 .index ::From:: header line
26192 .index Sendmail compatibility||`From' line
26193 .index message||submission
26194 .index submission mode
26195 If a submission-mode message does not contain a ::From:: header line, Exim adds
26196 one if either of the following conditions is true:
26197 .numberpars $.
26198 The envelope sender address is not empty (that is, this is not a bounce
26199 message). The added header line copies the envelope sender address.
26200 .nextp
26201 The SMTP session is authenticated and \$authenticated@_id$\ is not empty. 
26202 .em
26203 .numberpars alpha
26204 If no domain is specified by the submission control, the local part is 
26205 \$authenticated@_id$\ and the domain is \$qualify@_domain$\.
26206 .nextp
26207 If a non-empty domain is specified by the submission control, the local part is 
26208 \$authenticated@_id$\, and the the domain is the specified domain.
26209 .nextp
26210 If an empty domain is specified by the submission control, 
26211 \$authenticated@_id$\ is assumed to be the complete address.
26212 .endp
26213 .nem
26214 .endp
26215 A non-empty envelope sender takes precedence.
26216
26217 If a locally-generated incoming message does not contain a ::From:: header
26218 line, Exim adds one containing the sender's address. The calling user's login
26219 name and full name are used to construct the address, as described in section
26220 ~~SECTconstr. They are obtained from the password data by calling
26221 \*getpwuid()*\ (but see the \unknown@_login\ configuration option). The address
26222 is qualified with \qualify@_domain\.
26223
26224 For compatibility with Sendmail, if an incoming, non-SMTP message has a
26225 ::From:: header line containing just the unqualified login name of the calling
26226 user, this is replaced by an address containing the user's login name and full
26227 name as described in section ~~SECTconstr.
26228
26229 .section The Message-ID: header line
26230 .index ::Message-ID:: header line
26231 .index message||submission
26232 If a locally-generated or submission-mode incoming message does not contain a
26233 ::Message-ID:: or ::Resent-Message-ID:: header line, Exim adds one to the
26234 message. If there are any ::Resent-:: headers in the message, it creates
26235 ::Resent-Message-ID::. The id is constructed from Exim's internal message id,
26236 preceded by the letter E to ensure it starts with a letter, and followed by @@
26237 and the primary host name. Additional information can be included in this
26238 header line by setting the
26239 .index \message@_id@_header@_text\
26240 \message@_id@_header@_text\ and/or \message__id__header__domain\ options.
26241
26242
26243 .section The Received: header line
26244 .index ::Received:: header line
26245 A ::Received:: header line is added at the start of every message. The contents
26246 are defined by the \received@_header@_text\ configuration option, and Exim
26247 automatically adds a semicolon and a timestamp to the configured string.
26248
26249 The ::Received:: header is generated as soon as the message's header lines have
26250 been received. At this stage, the timestamp in the ::Received:: header line is
26251 the time that the message started to be received. This is the value that is
26252 seen by the \\DATA\\ ACL and by the \*local@_scan()*\ function.
26253
26254 Once a message is accepted, the timestamp in the ::Received:: header line is
26255 changed to the time of acceptance, which is (apart from a small delay while the
26256 -H spool file is written) the earliest time at which delivery could start.
26257
26258
26259 .section The Return-path: header line
26260 .index ::Return-path:: header line
26261 .index \return@_path@_remove\
26262 ::Return-path:: header lines are defined as something an MTA may insert when
26263 it does the final delivery of messages. (See the generic \return@_path@_add\
26264 transport option.) Therefore, they should not be present in messages in
26265 transit. If the \return@_path@_remove\ configuration option is set (the
26266 default), Exim removes ::Return-path:: header lines from incoming messages.
26267
26268
26269 .section The Sender: header line
26270 .rset SECTthesenhea "~~chapter.~~section"
26271 .index ::Sender:: header line
26272 .index message||submission
26273 For a locally-originated message from an untrusted user, Exim may remove an
26274 existing ::Sender:: header line, and it may add a new one. You can modify these
26275 actions by setting \local@_sender@_retain\ true or \local@_from@_check\ false.
26276
26277 When a local message is received from an untrusted user and
26278 \local@_from@_check\ is true (the default), a check is made to see if the
26279 address given in the ::From:: header line is the correct (local) sender of the
26280 message. The address that is expected has the login name as the local part and
26281 the value of \qualify@_domain\ as the domain. Prefixes and suffixes for the
26282 local part can be permitted by setting \local@_from@_prefix\ and
26283 \local@_from@_suffix\ appropriately. If ::From:: does not contain the correct
26284 sender, a ::Sender:: line is added to the message.
26285
26286 If you set \local@_from@_check\ false, this checking does not occur. However,
26287 the removal of an existing ::Sender:: line still happens, unless you also set
26288 \local@_sender@_retain\ to be true. It is not possible to set both of these
26289 options true at the same time.
26290
26291 .em
26292 .index submission mode
26293 By default, no processing of ::Sender:: header lines is done for messages
26294 received over TCP/IP or for messages submitted by trusted users. However, when
26295 a message is received over TCP/IP in submission mode, and \sender@_retain\ is
26296 not specified on the submission control, the following processing takes place:
26297
26298 First, any existing ::Sender:: lines are removed. Then, if the SMTP session is
26299 authenticated, and \$authenticated@_id$\ is not empty, a sender address is
26300 created as follows:
26301 .numberpars $.
26302 If no domain is specified by the submission control, the local part is 
26303 \$authenticated@_id$\ and the domain is \$qualify@_domain$\.
26304 .nextp
26305 If a non-empty domain is specified by the submission control, the local part is 
26306 \$authenticated@_id$\, and the the domain is the specified domain.
26307 .nextp
26308 If an empty domain is specified by the submission control, 
26309 \$authenticated@_id$\ is assumed to be the complete address.
26310 .endp
26311 This address is compared with the address in the ::From:: header line. If they
26312 are different, a ::Sender:: header line containing the created address is
26313 added. Prefixes and suffixes for the local part in ::From:: can be permitted by
26314 setting \local@_from@_prefix\ and \local@_from@_suffix\ appropriately.
26315 .nem
26316
26317
26318 .section Adding and removing header lines in routers and transports
26319 .index header lines||adding, in router or transport
26320 .index header lines||removing, in router or transport
26321 .rset SECTheadersaddrem "~~chapter.~~section"
26322 .em
26323 When a message is delivered, the addition and removal of header lines can be
26324 specified in a system filter, or on any of the routers and transports that 
26325 process the message. Section ~~SECTaddremheasys contains details about 
26326 modifying headers in a system filter. 
26327
26328 In contrast to what happens in a system filter, header modifications that are
26329 specified on routers and transports apply only to the particular recipient
26330 addresses that are being processed by those routers and transports. These
26331 changes do not actually take place until a copy of the message is being
26332 transported. Therefore, they do not affect the basic set of header lines, and
26333 they do not affect the values of the variables that refer to header lines.
26334
26335 For both routers and transports, the result of expanding a \headers@_add\
26336 option must be in the form of one or more RFC 2822 header lines, separated by
26337 newlines (coded as `@\n'). For example:
26338 .display asis
26339 headers_add = X-added-header: added by $primary_hostname\n\
26340               X-added-second: another added header line
26341 .endd
26342 Exim does not check the syntax of these added header lines. 
26343
26344 The result of expanding \headers@_remove\ must consist of a colon-separated
26345 list of header names. This is confusing, because header names themselves are
26346 often terminated by colons. In this case, the colons are the list separators,
26347 not part of the names. For example:
26348 .display asis
26349 headers_remove = return-receipt-to:acknowledge-to
26350 .endd
26351
26352 When \headers@_add\ or \headers@_remove\ is specified on a router, its value is 
26353 expanded at routing time, and then associated with all addresses that are
26354 accepted by that router, and also with any new addresses that it generates. If
26355 an address passes through several routers as a result of aliasing or
26356 forwarding, the changes are cumulative.
26357 .index \unseen\ option
26358 However, this does not apply to multiple routers that result from the use of
26359 the \unseen\ option. Any header modifications that were specified by the
26360 `unseen' router or its predecessors apply only to the `unseen' delivery.
26361
26362 Addresses that end up with different \headers@_add\ or \headers@_remove\
26363 settings cannot be delivered together in a batch, so a transport is always 
26364 dealing with a set of addresses that have the same header-processing 
26365 requirements. 
26366
26367 The transport starts by writing the original set of header lines that arrived 
26368 with the message, possibly modified by the system filter. As it writes out
26369 these lines, it consults the list of header names that were attached to the
26370 recipient address(es) by \headers@_remove\ options in routers, and it also
26371 consults the transport's own \headers@_remove\ option. Header lines whose names
26372 are on either of these lists are not written out. If there are multiple
26373 instances of any listed header, they are all skipped.
26374
26375 After the remaining original header lines have been written, new header
26376 lines that were specified by routers' \headers@_add\ options are written, in
26377 the order in which they were attached to the address. These are followed by any
26378 header lines specified by the transport's \headers@_add\ option.
26379
26380 This way of handling header line modifications in routers and transports has
26381 the following consequences:
26382 .numberpars $.
26383 The original set of header lines, possibly modified by the system filter, 
26384 remains `visible', in the sense that the \$header@_$\\*xxx*\ variables refer to
26385 it, at all times. 
26386 .nextp
26387 Header lines that are added by a router's
26388 \headers@_add\ option are not accessible by means of the \$header@_$\\*xxx*\
26389 expansion syntax in subsequent routers or the transport.
26390 .nextp
26391 Conversely, header lines that are specified for removal by \headers@_remove\ in
26392 a router remain visible to subsequent routers and the transport.
26393 .nextp
26394 Headers added to an address by \headers@_add\ in a router cannot be removed by 
26395 a later router or by a transport.
26396 .nextp
26397 An added header can refer to the contents of an original header that is to be 
26398 removed, even it has the same name as the added header. For example:
26399 .display asis
26400 headers_remove = subject
26401 headers_add = Subject: new subject (was: $h_subject:)
26402 .endd
26403 .endp
26404
26405 \**Warning**\: The \headers@_add\ and \headers@_remove\ options cannot be used
26406 for a \%redirect%\ router that has the \one@_time\ option set.
26407 .nem
26408
26409
26410
26411 .section Constructed addresses
26412 .rset SECTconstr "~~chapter.~~section"
26413 .index address||constructed
26414 .index constructed address
26415 When Exim constructs a sender address for a locally-generated message, it uses
26416 the form
26417 .display
26418 <<user name>> <$$<<login>>@@<<qualify@_domain>>$$>
26419 .endd
26420 For example:
26421 .display asis
26422 Zaphod Beeblebrox <zaphod@end.univ.example>
26423 .endd
26424 The user name is obtained from the \-F-\ command line option if set, or
26425 otherwise by looking up the calling user by \*getpwuid()*\ and extracting the
26426 `gecos' field from the password entry. If the `gecos' field contains an
26427 ampersand character, this is replaced by the login name with the first letter
26428 upper cased, as is conventional in a number of operating systems. See the
26429 \gecos@_name\ option for a way to tailor the handling of the `gecos' field. The
26430 \unknown@_username\ option can be used to specify user names in cases when
26431 there is no password file entry.
26432
26433 In all cases, the user name is made to conform to RFC 2822 by quoting all or
26434 parts of it if necessary. In addition, if it contains any non-printing
26435 characters, it is encoded as described in RFC 2047, which defines a way of
26436 including non-ASCII characters in header lines.
26437 The value of the \headers@_charset\ option specifies the name of the encoding
26438 that is used (the characters are assumed to be in this encoding).
26439 The setting of \print@_topbitchars\ controls whether characters with the top
26440 bit set (that is, with codes greater than 127) count as printing characters or
26441 not.
26442
26443
26444 .section Case of local parts
26445 .index case of local parts
26446 .index local part||case of
26447 RFC 2822 states that the case of letters in the local parts of addresses cannot
26448 be assumed to be non-significant. Exim preserves the case of local parts of
26449 addresses, but by default it uses a lower-cased form when it is routing,
26450 because on most Unix systems, usernames are in lower case and case-insensitive
26451 routing is required. However, any particular router can be made to use the
26452 original case for local parts by setting the \caseful@_local@_part\ generic
26453 router option.
26454
26455 .index mixed-case login names
26456 If you must have mixed-case user names on your system, the best way to proceed,
26457 assuming you want case-independent handling of incoming email, is to set up
26458 your first router to convert incoming local parts in your domains to the
26459 correct case by means of a file lookup. For example:
26460 .display asis
26461 correct_case:
26462   driver = redirect
26463   domains = +local_domains
26464   data = ${lookup{$local_part}cdb\
26465               {/etc/usercased.cdb}{$value}fail}\
26466               @$domain
26467 .endd
26468 For this router, the local part is forced to lower case by the default action
26469 (\caseful@_local@_part\ is not set). The lower-cased local part is used to look
26470 up a new local part in the correct case. If you then set \caseful@_local@_part\
26471 on any subsequent routers which process your domains, they will operate on
26472 local parts with the correct case in a case-sensitive manner.
26473
26474
26475 .section Dots in local parts
26476 .index dot||in local part
26477 .index local part||dots in
26478 RFC 2822 forbids empty components in local parts. That is, an unquoted local
26479 part may not begin or end with a dot, nor have two consecutive dots in the
26480 middle. However, it seems that many MTAs do not enforce this, so Exim permits
26481 empty components for compatibility.
26482
26483
26484 .section Rewriting addresses
26485 .index rewriting||addresses
26486 Rewriting of sender and recipient addresses, and addresses in headers, can
26487 happen automatically, or as the result of configuration options, as described
26488 in chapter ~~CHAPrewrite. The headers that may be affected by this are ::Bcc::,
26489 ::Cc::, ::From::, ::Reply-To::, ::Sender::, and ::To::.
26490
26491 Automatic rewriting includes qualification, as mentioned above. The other case
26492 in which it can happen is when an incomplete non-local domain is given. The
26493 routing process may cause this to be expanded into the full domain name. For
26494 example, a header such as
26495 .display asis
26496 To: hare@teaparty
26497 .endd
26498 might get rewritten as
26499 .display asis
26500 To: hare@teaparty.wonderland.fict.example
26501 .endd
26502 Rewriting as a result of routing is the one kind of message processing that
26503 does not happen at input time, as it cannot be done until the address has
26504 been routed.
26505
26506 Strictly, one should not do $it{any} deliveries of a message until all its
26507 addresses have been routed, in case any of the headers get changed as a
26508 result of routing. However, doing this in practice would hold up many
26509 deliveries for unreasonable amounts of time, just because one address could not
26510 immediately be routed. Exim therefore does not delay other deliveries when
26511 routing of one or more addresses is deferred.
26512
26513
26514 .
26515 .
26516 .
26517 .
26518 . ============================================================================
26519 .chapter SMTP processing
26520 .set runningfoot "smtp processing"
26521 .rset CHAPSMTP ~~chapter
26522 .index SMTP||processing details
26523 .index LMTP||processing details
26524 Exim supports a number of different ways of using the SMTP protocol, and its
26525 LMTP variant, which is an interactive protocol for transferring messages into a
26526 closed mail store application. This chapter contains details of how SMTP is
26527 processed. For incoming mail, the following are available:
26528 .numberpars $.
26529 SMTP over TCP/IP (Exim daemon or \*inetd*\);
26530 .nextp
26531 SMTP over the standard input and output (the \-bs-\ option);
26532 .nextp
26533 Batched SMTP on the standard input (the \-bS-\ option).
26534 .endp
26535 For mail delivery, the following are available:
26536 .numberpars $.
26537 SMTP over TCP/IP (the \%smtp%\ transport);
26538 .nextp
26539 LMTP over TCP/IP (the \%smtp%\ transport with the \protocol\ option set to
26540 `lmtp');
26541 .nextp
26542 LMTP over a pipe to a process running in the local host (the \%lmtp%\
26543 transport);
26544 .nextp
26545 Batched SMTP to a file or pipe (the \%appendfile%\ and \%pipe%\ transports with
26546 the \use@_bsmtp\ option set).
26547 .endp
26548 \*Batched SMTP*\ is the name for a process in which batches of messages are
26549 stored in or read from files (or pipes), in a format in which SMTP commands are
26550 used to contain the envelope information.
26551
26552
26553 .section Outgoing SMTP and LMTP over TCP/IP
26554 .rset SECToutSMTPTCP "~~chapter.~~section"
26555 .index SMTP||outgoing over TCP/IP
26556 .index outgoing SMTP over TCP/IP
26557 .index LMTP||over TCP/IP
26558 .index outgoing LMTP over TCP/IP
26559 .index \\EHLO\\
26560 .index \\HELO\\
26561 .index \\SIZE\\ option on \\MAIL\\ command
26562 Outgoing SMTP and LMTP over TCP/IP is implemented by the \%smtp%\ transport.
26563 The \protocol\ option selects which protocol is to be used, but the actual
26564 processing is the same in both cases.
26565
26566 If, in response to its \\EHLO\\ command, Exim is told that the \\SIZE\\
26567 parameter is supported, it adds \\SIZE\\=<<n>> to each subsequent \\MAIL\\
26568 command. The value of <<n>> is the message size plus the value of the
26569 \size@_addition\ option (default 1024) to allow for additions to the message
26570 such as per-transport header lines, or changes made in a
26571 .index transport||filter
26572 .index filter||transport filter
26573 transport filter. If \size@_addition\ is set negative, the use of \\SIZE\\ is
26574 suppressed.
26575
26576 If the remote server advertises support for \\PIPELINING\\, Exim uses the
26577 pipelining extension to SMTP (RFC 2197) to reduce the number of TCP/IP packets
26578 required for the transaction.
26579
26580 If the remote server advertises support for the \\STARTTLS\\ command, and Exim
26581 was built to support TLS encryption, it tries to start a TLS session unless the
26582 server matches \hosts@_avoid@_tls\. See chapter ~~CHAPTLS for more details.
26583
26584 If the remote server advertises support for the \\AUTH\\ command, Exim scans
26585 the authenticators configuration for any suitable client settings, as described
26586 in chapter ~~CHAPSMTPAUTH.
26587
26588 .index carriage return
26589 .index linefeed
26590 Responses from the remote host are supposed to be terminated by CR followed by
26591 LF. However, there are known to be hosts that do not send CR characters, so in
26592 order to be able to interwork with such hosts, Exim treats LF on its own as a
26593 line terminator.
26594
26595 If a message contains a number of different addresses, all those with the same
26596 characteristics (for example, the same envelope sender) that resolve to the
26597 same set of hosts, in the same order, are sent in a single SMTP transaction,
26598 even if they are for different domains, unless there are more than the setting
26599 of the \max@_rcpts\ option in the \%smtp%\ transport allows, in which case they
26600 are split into groups containing no more than \max@_rcpts\ addresses each. If
26601 \remote@_max@_parallel\ is greater than one, such groups may be sent in
26602 parallel sessions. The order of hosts with identical MX values is not
26603 significant when checking whether addresses can be batched in this way.
26604
26605 When the \%smtp%\ transport suffers a temporary failure that is not
26606 message-related, Exim updates its transport-specific database, which contains
26607 records indexed by host name that remember which messages are waiting for each
26608 particular host. It also updates the retry database with new retry times.
26609 .index hints database||retry keys
26610 Exim's retry hints are based on host name plus IP address, so if one address of
26611 a multi-homed host is broken, it will soon be skipped most of the time.
26612 See the next section for more detail about error handling.
26613
26614 .index SMTP||passed connection
26615 .index SMTP||batching over TCP/IP
26616 When a message is successfully delivered over a TCP/IP SMTP connection, Exim
26617 looks in the hints database for the transport to see if there are any queued
26618 messages waiting for the host to which it is connected. If it finds one, it
26619 creates a new Exim process using the \-MC-\ option (which can only be used by a
26620 process running as root or the Exim user) and passes the TCP/IP socket to it so
26621 that it can deliver another message using the same socket. The new process does
26622 only those deliveries that are routed to the connected host, and may in turn
26623 pass the socket on to a third process, and so on.
26624
26625 The \connection@_max@_messages\ option of the \%smtp%\ transport can be used to
26626 limit the number of messages sent down a single TCP/IP connection.
26627 .index asterisk||after IP address
26628 The second and subsequent messages delivered down an existing connection are
26629 identified in the main log by the addition of an asterisk after the closing
26630 square bracket of the IP address.
26631
26632
26633
26634 .section Errors in outgoing SMTP
26635 .rset SECToutSMTPerr "~~chapter.~~section"
26636 .index error||in outgoing SMTP
26637 .index SMTP||errors in outgoing
26638 .index host||error
26639 Three different kinds of error are recognized for outgoing SMTP: host errors,
26640 message errors, and recipient errors.
26641 .numberpars
26642 A host error is not associated with a particular message or with a
26643 particular recipient of a message. The host errors are:
26644 .numberpars $.
26645 Connection refused or timed out,
26646 .nextp
26647 Any error response code on connection,
26648 .nextp
26649 Any error response code to \\EHLO\\ or \\HELO\\,
26650 .nextp
26651 Loss of connection at any time, except after `.',
26652 .nextp
26653 I/O errors at any time,
26654 .nextp
26655 Timeouts during the session, other than in response to \\MAIL\\, \\RCPT\\ or
26656 the `.' at the end of the data.
26657 .endp
26658 For a host error, a permanent error response on connection, or in response to
26659 \\EHLO\\, causes all addresses routed to the host to be failed. Any other host
26660 error causes all addresses to be deferred, and retry data to be created for the
26661 host. It is not tried again, for any message, until its retry time arrives. If
26662 the current set of addresses are not all delivered in this run (to some
26663 alternative host), the message is added to the list of those waiting for this
26664 host, so if it is still undelivered when a subsequent successful delivery is
26665 made to the host, it will be sent down the same SMTP connection.
26666 .nextp
26667 .index message||error
26668 A message error is associated with a particular message when sent to a
26669 particular host, but not with a particular recipient of the message. The
26670 message errors are:
26671 .numberpars $.
26672 Any error response code to \\MAIL\\, \\DATA\\, or the `.' that terminates
26673 the data,
26674 .nextp
26675 Timeout after \\MAIL\\,
26676 .nextp
26677 Timeout
26678 or loss of connection after the `.' that terminates the data. A timeout after
26679 the \\DATA\\ command itself is treated as a host error, as is loss of
26680 connection at any other time.
26681 .endp
26682 For a message error, a permanent error response (5$it{xx}) causes all addresses
26683 to be failed, and a delivery error report to be returned to the sender. A
26684 temporary error response (4$it{xx}), or one of the timeouts, causes all
26685 addresses to be deferred. Retry data is not created for the host, but instead,
26686 a retry record for the combination of host plus message id is created. The
26687 message is not added to the list of those waiting for this host. This ensures
26688 that the failing message will not be sent to this host again until the retry
26689 time arrives. However, other messages that are routed to the host are not
26690 affected, so if it is some property of the message that is causing the error,
26691 it will not stop the delivery of other mail.
26692
26693 If the remote host specified support for the \\SIZE\\ parameter in its response
26694 to \\EHLO\\, Exim adds SIZE=$it{nnn} to the \\MAIL\\ command, so an
26695 over-large message will cause a message error because the error arrives as a
26696 response to \\MAIL\\.
26697 .nextp
26698 .index recipient||error
26699 A recipient error is associated with a particular recipient of a message. The
26700 recipient errors are:
26701 .numberpars $.
26702 Any error response to \\RCPT\\,
26703 .nextp
26704 Timeout after \\RCPT\\.
26705 .endp
26706 For a recipient error, a permanent error response (5$it{xx}) causes the
26707 recipient address to be failed, and a bounce message to be returned to the
26708 sender. A temporary error response (4$it{xx}) or a timeout causes the failing
26709 address to be deferred, and routing retry data to be created for it. This is
26710 used to delay processing of the address in subsequent queue runs, until its
26711 routing retry time arrives. This applies to all messages, but because it
26712 operates only in queue runs, one attempt will be made to deliver a new message
26713 to the failing address before the delay starts to operate. This ensures that,
26714 if the failure is really related to the message rather than the recipient
26715 (`message too big for this recipient' is a possible example), other messages
26716 have a chance of getting delivered. If a delivery to the address does succeed,
26717 the retry information gets cleared, so all stuck messages get tried again, and
26718 the retry clock is reset.
26719
26720 The message is not added to the list of those waiting for this host. Use of the
26721 host for other messages is unaffected, and except in the case of a timeout,
26722 other recipients are processed independently, and may be successfully delivered
26723 in the current SMTP session. After a timeout it is of course impossible to
26724 proceed with the session, so all addresses get deferred. However, those other
26725 than the one that failed do not suffer any subsequent retry delays. Therefore,
26726 if one recipient is causing trouble, the others have a chance of getting
26727 through when a subsequent delivery attempt occurs before the failing
26728 recipient's retry time.
26729 .endp
26730
26731 In all cases, if there are other hosts (or IP addresses) available for the
26732 current set of addresses (for example, from multiple MX records), they are
26733 tried in this run for any undelivered addresses, subject of course to their
26734 own retry data. In other words, recipient error retry data does not take effect
26735 until the next delivery attempt.
26736
26737 Some hosts have been observed to give temporary error responses to every
26738 \\MAIL\\ command at certain times (`insufficient space' has been seen). It
26739 would be nice if such circumstances could be recognized, and defer data for the
26740 host itself created, but this is not possible within the current Exim design.
26741 What actually happens is that retry data for every (host, message) combination
26742 is created.
26743
26744 The reason that timeouts after \\MAIL\\ and \\RCPT\\ are treated specially is
26745 that these can sometimes arise as a result of the remote host's verification
26746 procedures. Exim makes this assumption, and treats them as if a temporary error
26747 response had been received. A timeout after `.' is treated specially because it
26748 is known that some broken implementations fail to recognize the end of the
26749 message if the last character of the last line is a binary zero. Thus, it is
26750 helpful to treat this case as a message error.
26751
26752 Timeouts at other times are treated as host errors, assuming a problem with the
26753 host, or the connection to it. If a timeout after \\MAIL\\, \\RCPT\\,
26754 or `.' is really a connection problem, the assumption is that at the next try
26755 the timeout is likely to occur at some other point in the dialogue, causing it
26756 then to be treated as a host error.
26757
26758 There is experimental evidence that some MTAs drop the connection after the
26759 terminating `.' if they do not like the contents of the message for some
26760 reason, in contravention of the RFC, which indicates that a 5$it{xx} response
26761 should be given. That is why Exim treats this case as a message rather than a
26762 host error, in order not to delay other messages to the same host.
26763
26764
26765
26766
26767 .section Variable Envelope Return Paths (VERP)
26768 .index VERP
26769 .index Variable Envelope Return Paths
26770 .index envelope sender
26771 Variable Envelope Return Paths -- see
26772 \?ftp://koobera.math.uic.edu/www/proto/verp.txt?\ -- can be supported in Exim
26773 by using the \return@_path\ generic transport option to rewrite the return path
26774 at transport time. For example, the following could be used on an \%smtp%\
26775 transport:
26776 .display asis
26777 return_path = \
26778   ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
26779   {$1-request=$local_part%$domain@your.dom.example}fail}
26780 .endd
26781 This has the effect of rewriting the return path (envelope sender) on all
26782 outgoing SMTP messages, if the local part of the original return path ends in
26783 `-request', and the domain is \*your.dom.example*\. The rewriting inserts the
26784 local part and domain of the recipient into the return path. Suppose, for
26785 example, that a message whose return path has been set to
26786 \*somelist-request@@your.dom.example*\ is sent to
26787 \*subscriber@@other.dom.example*\. In the transport, the return path is
26788 rewritten as
26789 .display asis
26790 somelist-request=subscriber%other.dom.example@your.dom.example
26791 .endd
26792 For this to work, you must arrange for outgoing messages that have `-request'
26793 in their return paths to have just a single recipient. This can be done by
26794 setting
26795 .display asis
26796 max_rcpt = 1
26797 .endd
26798 in the \%smtp%\ transport. Otherwise a single copy of a message might be
26799 addressed to several different recipients in the same domain, in which case
26800 \$local@_part$\ is not available (because it is not unique). Of course, if you
26801 do start sending out messages with this kind of return path, you must also
26802 configure Exim to accept the bounce messages that come back to those paths.
26803 Typically this would be done by setting an \local@_part@_suffix\ option for a
26804 suitable router.
26805
26806 The overhead incurred in using VERP depends very much on the size of the
26807 message, the number of recipient addresses that resolve to the same remote
26808 host, and the speed of the connection over which the message is being sent. If
26809 a lot of addresses resolve to the same host and the connection is slow, sending
26810 a separate copy of the message for each address may take substantially longer
26811 than sending a single copy with many recipients (for which VERP cannot be
26812 used).
26813
26814
26815 .section Incoming SMTP messages over TCP/IP
26816 .index SMTP||incoming over TCP/IP
26817 .index incoming SMTP over TCP/IP
26818 .index inetd
26819 .index daemon
26820 Incoming SMTP messages can be accepted in one of two ways: by running a
26821 listening daemon, or by using \*inetd*\. In the latter case, the entry in
26822 \(/etc/inetd.conf)\ should be like this:
26823 .display asis
26824 smtp  stream  tcp  nowait  exim  /opt/exim/bin/exim  in.exim  -bs
26825 .endd
26826 Exim distinguishes between this case and the case of a locally running user
26827 agent using the \-bs-\ option by checking whether or not the standard input is
26828 a socket. When it is, either the port must be privileged (less than 1024), or
26829 the caller must be root or the Exim user. If any other user passes a socket
26830 with an unprivileged port number, Exim prints a message on the standard error
26831 stream and exits with an error code.
26832
26833 By default, Exim does not make a log entry when a remote host connects or
26834 disconnects (either via the daemon or \*inetd*\), unless the disconnection is
26835 unexpected. It can be made to write such log entries by setting the
26836 \smtp@_connection\ log selector.
26837
26838 .index carriage return
26839 .index linefeed
26840 Commands from the remote host are supposed to be terminated by CR followed by
26841 LF. However, there are known to be hosts that do not send CR characters. In
26842 order to be able to interwork with such hosts, Exim treats LF on its own as a
26843 line terminator.
26844 Furthermore, because common code is used for receiving messages from all
26845 sources, a CR on its own is also interpreted as a line terminator. However, the
26846 sequence `CR, dot, CR' does not terminate incoming SMTP data.
26847
26848 .index \\EHLO\\||invalid data
26849 .index \\HELO\\||invalid data
26850 One area that sometimes gives rise to problems concerns the \\EHLO\\ or
26851 \\HELO\\ commands. Some clients send syntactically invalid versions of these
26852 commands, which Exim rejects by default. (This is nothing to do with verifying
26853 the data that is sent, so \helo@_verify@_hosts\ is not relevant.) You can tell
26854 Exim not to apply a syntax check by setting \helo@_accept@_junk@_hosts\ to
26855 match the broken hosts that send invalid commands.
26856
26857 .index \\SIZE\\ option on \\MAIL\\ command
26858 .index \\MAIL\\||\\SIZE\\ option
26859 The amount of disk space available is checked whenever \\SIZE\\ is received on
26860 a \\MAIL\\ command, independently of whether \message@_size@_limit\ or
26861 \check@_spool@_space\ is configured, unless \smtp__check__spool__space\ is set
26862 false. A temporary error is given if there is not enough space. If
26863 \check@_spool@_space\ is set, the check is for that amount of space plus the
26864 value given with \\SIZE\\, that is, it checks that the addition of the incoming
26865 message will not reduce the space below the threshold.
26866
26867 When a message is successfully received, Exim includes the local message id in
26868 its response to the final `.' that terminates the data. If the remote host logs
26869 this text it can help with tracing what has happened to a message.
26870
26871 The Exim daemon can limit the number of simultaneous incoming connections it is
26872 prepared to handle (see the \smtp@_accept@_max\ option). It can also limit the
26873 number of simultaneous incoming connections from a single remote host (see the
26874 \smtp@_accept@_max@_per@_host\ option). Additional connection attempts are
26875 rejected using the SMTP temporary error code 421.
26876
26877 The Exim daemon does not rely on the \\SIGCHLD\\ signal to detect when a
26878 subprocess has finished, as this can get lost at busy times. Instead, it looks
26879 for completed subprocesses every time it wakes up. Provided there are other
26880 things happening (new incoming calls, starts of queue runs), completed
26881 processes will be noticed and tidied away. On very quiet systems you may
26882 sometimes see a `defunct' Exim process hanging about. This is not a problem; it
26883 will be noticed when the daemon next wakes up.
26884
26885 When running as a daemon, Exim can reserve some SMTP slots for specific hosts,
26886 and can also be set up to reject SMTP calls from non-reserved hosts at times of
26887 high system load -- for details see the \smtp@_accept@_reserve\,
26888 \smtp@_load@_reserve\, and \smtp@_reserve@_hosts\ options. The load check
26889 applies in both the daemon and \*inetd*\ cases.
26890
26891 Exim normally starts a delivery process for each message received, though this
26892 can be varied by means of the \-odq-\ command line option and the
26893 \queue@_only\, \queue@_only@_file\, and \queue@_only@_load\ options. The number
26894 of simultaneously running delivery processes started in this way from SMTP
26895 input can be limited by the \smtp__accept__queue\ and
26896 \smtp__accept__queue__per__connection\ options. When either limit is reached,
26897 subsequently received messages are just put on the input queue without starting
26898 a delivery process.
26899
26900 The controls that involve counts of incoming SMTP calls (\smtp@_accept@_max\,
26901 \smtp@_accept@_queue\, \smtp__accept__reserve\) are not available when Exim is
26902 started up from the \*inetd*\ daemon, because in that case each connection is
26903 handled by an entirely independent Exim process. Control by load average is,
26904 however, available with \*inetd*\.
26905
26906 Exim can be configured to verify addresses in incoming SMTP commands as they
26907 are received. See chapter ~~CHAPACL for details. It can also be configured to
26908 rewrite addresses at this time -- before any syntax checking is done. See
26909 section ~~SECTrewriteS.
26910
26911 Exim can also be configured to limit the rate at which a client host submits
26912 \\MAIL\\ and \\RCPT\\ commands in a single SMTP session. See the
26913 \smtp@_ratelimit@_hosts\ option.
26914
26915
26916 .section Unrecognized SMTP commands
26917 .index SMTP||unrecognized commands
26918 If Exim receives more than \smtp@_max@_unknown@_commands\ unrecognized SMTP
26919 commands during a single SMTP connection, it drops the connection after sending
26920 the error response to the last command. The default value for
26921 \smtp@_max@_unknown@_commands\ is 3. This is a defence against some kinds of
26922 abuse that subvert web servers into making connections to SMTP ports; in these
26923 circumstances, a number of non-SMTP lines are sent first.
26924
26925 .section Syntax and protocol errors in SMTP commands
26926 .index SMTP||syntax errors
26927 .index SMTP||protocol errors
26928 A syntax error is detected if an SMTP command is recognized, but there is
26929 something syntactically wrong with its data, for example, a malformed email
26930 address in a \\RCPT\\ command. Protocol errors include invalid command
26931 sequencing such as \\RCPT\\ before \\MAIL\\. If Exim receives more than
26932 \smtp@_max@_synprot@_errors\ such commands during a single SMTP connection, it
26933 drops the connection after sending the error response to the last command. The
26934 default value for \smtp__max__synprot__errors\ is 3. This is a defence against
26935 broken clients that loop sending bad commands (yes, it has been seen).
26936
26937
26938 .section Use of non-mail SMTP commands
26939 .index SMTP||non-mail commands
26940 The `non-mail' SMTP commands are those other than \\MAIL\\, \\RCPT\\, and
26941 \\DATA\\. Exim counts such commands, and drops the connection if there are too
26942 many of them in a single SMTP session. This action catches some
26943 denial-of-service attempts and things like repeated failing \\AUTH\\s, or a mad
26944 client looping sending \\EHLO\\. The global option \smtp@_accept@_max@_nonmail\
26945 defines what `too many' means. Its default value is 10.
26946
26947 When a new message is expected, one occurrence of \\RSET\\ is not counted. This
26948 allows a client to send one \\RSET\\ between messages (this is not necessary,
26949 but some clients do it). Exim also allows one uncounted occurence of \\HELO\\
26950 or \\EHLO\\, and one occurrence of \\STARTTLS\\ between messages. After
26951 starting up a TLS session, another \\EHLO\\ is expected, and so it too is not
26952 counted.
26953
26954 The first occurrence of \\AUTH\\ in a connection, or immediately following
26955 \\STARTTLS\\ is also not counted. Otherwise, all commands other than \\MAIL\\,
26956 \\RCPT\\, \\DATA\\, and \\QUIT\\ are counted.
26957
26958 You can control which hosts are subject to the limit set by
26959 \smtp@_accept@_max@_nonmail\ by setting
26960 \smtp@_accept@_max@_nonmail@_hosts\. The default value is \"$*$"\, which makes
26961 the limit apply to all hosts. This option means that you can exclude any
26962 specific badly-behaved hosts that you have to live with.
26963
26964
26965
26966 .section The \\VRFY\\ and \\EXPN\\ commands
26967 When Exim receives a \\VRFY\\ or \\EXPN\\ command on a TCP/IP connection, it
26968 runs the ACL specified by \acl@_smtp@_vrfy\ or \acl@_smtp@_expn\ (as
26969 appropriate) in order to decide whether the command should be accepted or not.
26970 If no ACL is defined, the command is rejected.
26971
26972 .index \\VRFY\\||processing
26973 When \\VRFY\\ is accepted, it runs exactly the same code as when Exim is
26974 called with the \-bv-\ option.
26975 .index \\EXPN\\||processing
26976 When \\EXPN\\ is accepted, a single-level expansion of the address is done.
26977 \\EXPN\\ is treated as an `address test' (similar to the \-bt-\ option) rather
26978 than a verification (the \-bv-\ option). If an unqualified local part is given
26979 as the argument to \\EXPN\\, it is qualified with \qualify@_domain\. Rejections
26980 of \\VRFY\\ and \\EXPN\\ commands are logged on the main and reject logs, and
26981 \\VRFY\\ verification failures are logged on the main log for consistency with
26982 \\RCPT\\ failures.
26983
26984
26985 .section The \\ETRN\\ command
26986 .rset SECTETRN "~~chapter.~~section"
26987 .index \\ETRN\\||processing
26988 RFC 1985 describes an SMTP command called \\ETRN\\ that is designed to
26989 overcome the security problems of the \\TURN\\ command (which has fallen into
26990 disuse). When Exim receives an \\ETRN\\ command on a TCP/IP connection, it runs
26991 the ACL specified by \acl@_smtp@_etrn\ in order to decide whether the command
26992 should be accepted or not. If no ACL is defined, the command is rejected.
26993
26994 The \\ETRN\\ command is concerned with `releasing' messages that are awaiting
26995 delivery to certain hosts. As Exim does not organize its message queue by host,
26996 the only form of \\ETRN\\ that is supported by default is the one where the
26997 text starts with the `@#' prefix, in which case the remainder of the text is
26998 specific to the SMTP server. A valid \\ETRN\\ command causes a run of Exim with
26999 the \-R-\ option to happen, with the remainder of the \\ETRN\\ text as its
27000 argument. For example,
27001 .display asis
27002 ETRN #brigadoon
27003 .endd
27004 runs the command
27005 .display asis
27006 exim -R brigadoon
27007 .endd
27008 which causes a delivery attempt on all messages with undelivered addresses
27009 containing the text `brigadoon'. When \smtp@_etrn@_serialize\ is set (the
27010 default), Exim prevents the simultaneous execution of more than one queue run
27011 for the same argument string as a result of an \\ETRN\\ command. This stops
27012 a misbehaving client from starting more than one queue runner at once.
27013
27014 .index hints database||\\ETRN\\ serialization
27015 Exim implements the serialization by means of a hints database in which a
27016 record is written whenever a process is started by \\ETRN\\, and deleted when
27017 the process completes. However, Exim does not keep the SMTP session waiting for
27018 the \\ETRN\\ process to complete. Once \\ETRN\\ is accepted, the client is sent
27019 a `success' return code. Obviously there is scope for hints records to get left
27020 lying around if there is a system or program crash. To guard against this, Exim
27021 ignores any records that are more than six hours old.
27022
27023 .index \smtp@_etrn@_command\
27024 For more control over what \\ETRN\\ does, the \smtp@_etrn@_command\ option can
27025 used. This specifies a command that is run whenever \\ETRN\\ is received,
27026 whatever the form of its argument. For
27027 example:
27028 .display asis
27029 smtp_etrn_command = /etc/etrn_command $domain $sender_host_address
27030 .endd
27031 The string is split up into arguments which are independently expanded. The
27032 expansion variable \$domain$\ is set to the argument of the \\ETRN\\ command,
27033 and no syntax checking is done on the contents of this argument. Exim does not
27034 wait for the command to complete, so its status code is not checked. Exim runs
27035 under its own uid and gid when receiving incoming SMTP, so it is not possible
27036 for it to change them before running the command.
27037
27038
27039 .section Incoming local SMTP
27040 .index SMTP||local incoming
27041 Some user agents use SMTP to pass messages to their local MTA using the
27042 standard input and output, as opposed to passing the envelope on the command
27043 line and writing the message to the standard input. This is supported by the
27044 \-bs-\ option. This form of SMTP is handled in the same way as incoming
27045 messages over TCP/IP (including the use of ACLs), except that the envelope
27046 sender given in a \\MAIL\\ command is ignored unless the caller is trusted. In
27047 an ACL you can detect this form of SMTP input by testing for an empty host
27048 identification. It is common to have this as the first line in the ACL that
27049 runs for \\RCPT\\ commands:
27050 .display asis
27051 accept hosts = :
27052 .endd
27053 This accepts SMTP messages from local processes without doing any other tests.
27054
27055
27056 .section Outgoing batched SMTP
27057 .rset SECTbatchSMTP "~~chapter.~~section"
27058 .index SMTP||batched outgoing
27059 .index batched SMTP output
27060 Both the \%appendfile%\ and \%pipe%\ transports can be used for handling batched
27061 SMTP. Each has an option called \use@_bsmtp\ which causes messages to be output
27062 in BSMTP format. No SMTP responses are possible for this form of delivery. All
27063 it is doing is using SMTP commands as a way of transmitting the envelope along
27064 with the message.
27065
27066 The message is written to the file or pipe preceded by the SMTP commands
27067 \\MAIL\\ and \\RCPT\\, and followed by a line containing a single dot. Lines in
27068 the message that start with a dot have an extra dot added. The SMTP command
27069 \\HELO\\ is not normally used. If it is required, the \message@_prefix\ option
27070 can be used to specify it.
27071
27072 Because \%appendfile%\ and \%pipe%\ are both local transports, they accept only
27073 one recipient address at a time by default. However, you can arrange for them
27074 to handle several addresses at once by setting the \batch@_max\ option. When
27075 this is done for BSMTP, messages may contain multiple \\RCPT\\ commands. See
27076 chapter ~~CHAPbatching for more details.
27077
27078 When one or more addresses are routed to a BSMTP transport by a router that
27079 sets up a host list, the name of the first host on the list is available to the
27080 transport in the variable \$host$\. Here is an example of such a transport and
27081 router:
27082 .display asis
27083 begin routers
27084 route_append:
27085   driver = manualroute
27086   transport = smtp_appendfile
27087   route_list = domain.example  batch.host.example
27088
27089 begin transports
27090 smtp_appendfile:
27091   driver = appendfile
27092   directory = /var/bsmtp/$host
27093   batch_max = 1000
27094   use_bsmtp
27095   user = exim
27096 .endd
27097 This causes messages addressed to \*domain.example*\ to be written in BSMTP
27098 format to \(/var/bsmtp/batch.host.example)\, with only a single copy of each
27099 message (unless there are more than 1000 recipients).
27100
27101
27102 .section Incoming batched SMTP
27103 .rset SECTincomingbatchedSMTP "~~chapter.~~section"
27104 .index SMTP||batched incoming
27105 .index batched SMTP input
27106 The \-bS-\ command line option causes Exim to accept one or more messages by
27107 reading SMTP on the standard input, but to generate no responses. If the caller
27108 is trusted, the senders in the \\MAIL\\ commands are believed; otherwise the
27109 sender is always the caller of Exim. Unqualified senders and receivers are not
27110 rejected (there seems little point) but instead just get qualified. \\HELO\\
27111 and \\EHLO\\ act as \\RSET\\; \\VRFY\\, \\EXPN\\, \\ETRN\\ and  \\HELP\\, act
27112 as \\NOOP\\; \\QUIT\\ quits.
27113
27114 No policy checking is done for BSMTP input. That is, no ACL is run at anytime.
27115 In this respect it is like non-SMTP local input.
27116
27117 If an error is detected while reading a message, including a missing `.' at
27118 the end, Exim gives up immediately. It writes details of the error to the
27119 standard output in a stylized way that the calling program should be able to
27120 make some use of automatically, for example:
27121 .display asis
27122 554 Unexpected end of file
27123 Transaction started in line 10
27124 Error detected in line 14
27125 .endd
27126 It writes a more verbose version, for human consumption, to the standard error
27127 file, for example:
27128 .display asis
27129 An error was detected while processing a file of BSMTP input.
27130 The error message was:
27131
27132   501 '>' missing at end of address
27133
27134 The SMTP transaction started in line 10.
27135 The error was detected in line 12.
27136 The SMTP command at fault was:
27137
27138    rcpt to:<malformed@in.com.plete
27139
27140 1 previous message was successfully processed.
27141 The rest of the batch was abandoned.
27142 .endd
27143 The return code from Exim is zero only if there were no errors. It is 1 if some
27144 messages were accepted before an error was detected, and 2 if no messages were
27145 accepted.
27146
27147
27148
27149 .
27150 .
27151 .
27152 .
27153 . ============================================================================
27154 .chapter Customizing bounce and warning messages
27155 .set runningfoot "customizing messages"
27156 .rset CHAPemsgcust "~~chapter"
27157 When a message fails to be delivered, or remains on the queue for more than a
27158 configured amount of time, Exim sends a message to the original sender, or
27159 to an alternative configured address. The text of these messages is built into
27160 the code of Exim, but it is possible to change it, either by adding a single
27161 string, or by replacing each of the paragraphs by text supplied in a file.
27162
27163 The ::From:: and ::To:: header lines are automatically generated; you can cause
27164 a ::Reply-To:: line to be added by setting the \errors@_reply@_to\ option. Exim
27165 also adds the line
27166 .display asis
27167 Auto-Submitted: auto-generated
27168 .endd
27169 to all warning and bounce messages,
27170
27171 .section Customizing bounce messages
27172 .index customizing||bounce message
27173 .index bounce message||customizing
27174 If \bounce@_message@_text\ is set, its contents are included in the default
27175 message immediately after `This message was created automatically by mail
27176 delivery software.' The string is not expanded. It is not used if
27177 \bounce@_message@_file\ is set.
27178
27179 When \bounce@_message@_file\ is set, it must point to a template file for
27180 constructing error messages. The file consists of a series of text items,
27181 separated by lines consisting of exactly four asterisks. If the file cannot be
27182 opened, default text is used and a message is written to the main and panic
27183 logs. If any text item in the file is empty, default text is used for that
27184 item.
27185
27186 Each item of text that is read from the file is expanded, and there are two
27187 expansion variables which can be of use here: \$bounce@_recipient$\ is set to
27188 the recipient of an error message while it is being created, and
27189 \$return@_size@_limit$\ contains the value of the \return@_size@_limit\ option,
27190 rounded to a whole number.
27191
27192 The items must appear in the file in the following order:
27193 .numberpars $.
27194 The first item is included in the headers, and should include at least a
27195 ::Subject:: header. Exim does not check the syntax of these headers.
27196 .nextp
27197 The second item forms the start of the error message. After it, Exim lists the
27198 failing addresses with their error messages.
27199 .nextp
27200 The third item is used to introduce any text from pipe transports that is to be
27201 returned to the sender. It is omitted if there is no such text.
27202 .nextp
27203 The fourth item is used to introduce the copy of the message that is returned
27204 as part of the error report.
27205 .nextp
27206 The fifth item is added after the fourth one if the returned message is
27207 truncated because it is bigger than \return@_size@_limit\.
27208 .nextp
27209 The sixth item is added after the copy of the original message.
27210 .endp
27211 The default state (\bounce@_message@_file\ unset) is equivalent to the
27212 following file, in which the sixth item is empty. The ::Subject:: line has been
27213 split into two here in order to fit it on the page:
27214 .if ~~sys.fancy
27215 .display flow asis
27216 .fontgroup 0
27217 .font 54
27218 .else
27219 .rule
27220 .display flow asis
27221 .linelength 80em
27222 .indent 0
27223 .fi
27224 Subject: Mail delivery failed
27225   ${if eq{$sender_address}{$bounce_recipient}{: returning message to sender}}
27226 ****
27227 This message was created automatically by mail delivery software.
27228
27229 A message ${if eq{$sender_address}{$bounce_recipient}{that you sent }{sent by
27230
27231   <$sender_address>
27232
27233 }}could not be delivered to all of its recipients.
27234 The following address(es) failed:
27235 ****
27236 The following text was generated during the delivery attempt(s):
27237 ****
27238 ------ This is a copy of the message, including all the headers. ------
27239 ****
27240 ------ The body of the message is $message_size characters long; only the first
27241 ------ $return_size_limit or so are included here.
27242 ****
27243 .endd
27244 .if !~~sys.fancy
27245 .rule
27246 .fi
27247
27248 .section Customizing warning messages
27249 .rset SECTcustwarn "~~chapter.~~section"
27250 .index customizing||warning message
27251 .index warning of delay||customizing the message
27252 The option
27253 \warn@_message@_file\
27254 can be pointed at a template file for use when
27255 warnings about message delays are created. In this case there are only three
27256 text sections:
27257 .numberpars $.
27258 The first item is included in the headers, and should include at least a
27259 ::Subject:: header. Exim does not check the syntax of these headers.
27260 .nextp
27261 The second item forms the start of the warning message. After it, Exim lists
27262 the delayed addresses.
27263 .nextp
27264 The third item then ends the message.
27265 .endp
27266 The default state is equivalent to the following file, except that the line
27267 starting `A message' has been split here, in order to fit it on the page:
27268 .if ~~sys.fancy
27269 .display asis
27270 .fontgroup 0
27271 .font 54
27272 .else
27273 .rule
27274 .display asis
27275 .linelength 80em
27276 .indent 0
27277 .fi
27278 .newline
27279 Subject: Warning: message $message_id delayed $warn_message_delay
27280 ****
27281 This message was created automatically by mail delivery software.
27282
27283 A message ${if eq{$sender_address}{$warn_message_recipients}
27284   {that you sent }{sent by
27285
27286   <$sender_address>
27287
27288 }}has not been delivered to all of its recipients after
27289 more than $warn_message_delay on the queue on $primary_hostname.
27290 .newline
27291
27292 The message identifier is:     $message_id
27293 The subject of the message is: $h_subject
27294 The date of the message is:    $h_date
27295
27296 The following address(es) have not yet been delivered:
27297 ****
27298 No action is required on your part. Delivery attempts will continue for
27299 some time, and this warning may be repeated at intervals if the message
27300 remains undelivered. Eventually the mail delivery software will give up,
27301 and when that happens, the message will be returned to you.
27302 .endd
27303 .if !~~sys.fancy
27304 .rule
27305 .fi
27306 except that in the default state the subject and date lines are omitted if no
27307 appropriate headers exist. During the expansion of this file,
27308 \$warn@_message@_delay$\
27309 is set to the delay time in one of the forms `<<n>> minutes'
27310 or `<<n>> hours', and
27311 \$warn@_message@_recipients$\
27312 contains a list of recipients for the warning message. There may be more than
27313 one if there are multiple addresses with different \errors@_to\ settings on the
27314 routers that handled them.
27315
27316
27317
27318
27319 .
27320 .
27321 .
27322 . ============================================================================
27323 .chapter Some common configuration requirements
27324 .set runningfoot "common configuration requirements"
27325 .rset CHAPcomconreq "~~chapter"
27326 This chapter discusses some configuration requirements that seem to be fairly
27327 common. More examples and discussion can be found in the Exim book.
27328
27329
27330 .section Sending mail to a smart host
27331 .index smart host||example router
27332 If you want to send all mail for non-local domains to a `smart host', you
27333 should replace the default \%dnslookup%\ router with a router which does the
27334 routing explicitly:
27335 .display asis
27336 send_to_smart_host:
27337   driver = manualroute
27338   route_list = !+local_domains smart.host.name
27339   transport = remote_smtp
27340 .endd
27341 You can use the smart host's IP address instead of the name if you wish.
27342 .em
27343 If you are using Exim only to submit messages to a smart host, and not for
27344 receiving incoming messages, you can arrange for it to do the submission
27345 synchronously by setting the \mua@_wrapper\ option (see chapter
27346 ~~CHAPnonqueueing).
27347 .nem
27348
27349
27350 .section Using Exim to handle mailing lists
27351 .rset SECTmailinglists "~~chapter.~~section"
27352 .index mailing lists
27353 Exim can be used to run simple mailing lists, but for large and/or complicated
27354 requirements, the use of additional specialized mailing list software such as
27355 Majordomo or Mailman is recommended.
27356
27357 The \%redirect%\ router can be used to handle mailing lists where each list
27358 is maintained in a separate file, which can therefore be managed by an
27359 independent manager. The \domains\ router option can be used to run these
27360 lists in a separate domain from normal mail. For example:
27361 .display asis
27362 lists:
27363   driver = redirect
27364   domains = lists.example
27365   file = /usr/lists/$local_part
27366   forbid_pipe
27367   forbid_file
27368   errors_to = $local_part-request@lists.example
27369   no_more
27370 .endd
27371 This router is skipped for domains other than \*lists.example*\. For addresses
27372 in that domain, it looks for a file that matches the local part. If there is no
27373 such file, the router declines, but because \no@_more\ is set, no subsequent
27374 routers are tried, and so the whole delivery fails.
27375
27376 The \forbid@_pipe\ and \forbid@_file\ options prevent a local part from being
27377 expanded into a file name or a pipe delivery, which is usually inappropriate in
27378 a mailing list.
27379
27380 .index \errors@_to\
27381 The \errors@_to\ option specifies that any delivery errors caused by addresses
27382 taken from a mailing list are to be sent to the given address rather than the
27383 original sender of the message. However, before acting on this, Exim verifies
27384 the error address, and ignores it if verification fails.
27385
27386 For example, using the configuration above, mail sent to
27387 \*dicts@@lists.example*\ is passed on to those addresses contained in
27388 \(/usr/lists/dicts)\, with error reports directed to
27389 \*dicts-request@@lists.example*\, provided that this address can be verified.
27390 There could be a file called \(/usr/lists/dicts-request)\ containing
27391 the address(es) of this particular list's manager(s), but other approaches,
27392 such as setting up an earlier router (possibly using the \local@_part@_prefix\
27393 or \local@_part@_suffix\ options) to handle addresses of the form \owner-xxx\
27394 or \xxx-request\, are also possible.
27395
27396
27397 .section Syntax errors in mailing lists
27398 .index mailing lists||syntax errors in
27399 If an entry in redirection data contains a syntax error, Exim normally defers
27400 delivery of the original address. That means that a syntax error in a mailing
27401 list holds up all deliveries to the list. This may not be appropriate when a
27402 list is being maintained automatically from data supplied by users, and the
27403 addresses are not rigorously checked.
27404
27405 If the \skip@_syntax@_errors\ option is set, the \%redirect%\ router just skips
27406 entries that fail to parse, noting the incident in the log. If in addition
27407 \syntax@_errors@_to\ is set to a verifiable address, a message is sent to it
27408 whenever a broken address is skipped. It is usually appropriate to set
27409 \syntax@_errors@_to\ to the same address as \errors@_to\.
27410
27411
27412 .section Re-expansion of mailing lists
27413 .index mailing lists||re-expansion of
27414 Exim remembers every individual address to which a message has been delivered,
27415 in order to avoid duplication, but it normally stores only the original
27416 recipient addresses with a message. If all the deliveries to a mailing list
27417 cannot be done at the first attempt, the mailing list is re-expanded when the
27418 delivery is next tried. This means that alterations to the list are taken into
27419 account at each delivery attempt, so addresses that have been added to
27420 the list since the message arrived will therefore receive a copy of the
27421 message, even though it pre-dates their subscription.
27422
27423 If this behaviour is felt to be undesirable, the \one@_time\ option can be set
27424 on the \%redirect%\ router. If this is done, any addresses generated by the
27425 router that fail to deliver at the first attempt are added to the message as
27426 `top level' addresses, and the parent address that generated them is marked
27427 `delivered'. Thus, expansion of the mailing list does not happen again at the
27428 subsequent delivery attempts. The disadvantage of this is that if any of the
27429 failing addresses are incorrect, correcting them in the file has no effect on
27430 pre-existing messages.
27431
27432 The original top-level address is remembered with each of the generated
27433 addresses, and is output in any log messages. However, any intermediate parent
27434 addresses are not recorded. This makes a difference to the log only if the
27435 \all@_parents\ selector is set, but for mailing lists there is normally only
27436 one level of expansion anyway.
27437
27438
27439 .section Closed mailing lists
27440 .index mailing lists||closed
27441 The examples so far have assumed open mailing lists, to which anybody may
27442 send mail. It is also possible to set up closed lists, where mail is accepted
27443 from specified senders only. This is done by making use of the generic
27444 \senders\ option to restrict the router that handles the list.
27445
27446 The following example uses the same file as a list of recipients and as a list
27447 of permitted senders. It requires three routers:
27448 .display asis
27449 lists_request:
27450   driver = redirect
27451   domains = lists.example
27452   local_part_suffix = -request
27453   file = /usr/lists/$local_part$local_part_suffix
27454   no_more
27455
27456 lists_post:
27457   driver = redirect
27458   domains = lists.example
27459   senders = ${if exists {/usr/lists/$local_part}\
27460              {lsearch;/usr/lists/$local_part}{*}}
27461   file = /usr/lists/$local_part
27462   forbid_pipe
27463   forbid_file
27464   errors_to = $local_part-request@lists.example
27465   no_more
27466
27467 lists_closed:
27468   driver = redirect
27469   domains = lists.example
27470   allow_fail
27471   data = :fail: $local_part@lists.example is a closed mailing list
27472 .endd
27473 All three routers have the same \domains\ setting, so for any other domains,
27474 they are all skipped. The first router runs only if the local part ends in
27475 \@-request\. It handles messages to the list manager(s) by means of an open
27476 mailing list.
27477
27478 The second router runs only if the \senders\ precondition is satisfied. It
27479 checks for the existence of a list that corresponds to the local part, and then
27480 checks that the sender is on the list by means of a linear search. It is
27481 necessary to check for the existence of the file before trying to search it,
27482 because otherwise Exim thinks there is a configuration error. If the file does
27483 not exist, the expansion of \senders\ is $*$, which matches all senders. This
27484 means that the router runs, but because there is no list, declines, and
27485 \no@_more\ ensures that no further routers are run. The address fails with an
27486 `unrouteable address' error.
27487
27488 The third router runs only if the second router is skipped, which happens when
27489 a mailing list exists, but the sender is not on it. This router forcibly fails
27490 the address, giving a suitable error message.
27491
27492
27493
27494 .section Virtual domains
27495 .rset SECTvirtualdomains "~~chapter.~~section"
27496 .index virtual domains
27497 .index domain||virtual
27498 The phrase \*virtual domain*\ is unfortunately used with two rather different
27499 meanings:
27500 .numberpars $.
27501 A domain for which there are no real mailboxes; all valid local parts are
27502 aliases for other email addresses. Common examples are organizational
27503 top-level domains and `vanity' domains.
27504 .nextp
27505 One of a number of independent domains that are all handled by the same host,
27506 with mailboxes on that host, but where the mailbox owners do not necessarily
27507 have login accounts on that host.
27508 .endp
27509 The first usage is probably more common, and does seem more `virtual' than the
27510 second. This kind of domain can be handled in Exim with a straightforward
27511 aliasing router. One approach is to create a separate alias file for each
27512 virtual domain. Exim can test for the existence of the alias file to determine
27513 whether the domain exists. The \%dsearch%\ lookup type is useful here, leading
27514 to a router of this form:
27515 .display asis
27516 virtual:
27517   driver = redirect
27518   domains = dsearch;/etc/mail/virtual
27519   data = ${lookup{$local_part}lsearch{/etc/mail/virtual/$domain}}
27520   no_more
27521 .endd
27522 The \domains\ option specifies that the router is to be skipped, unless there
27523 is a file in the \(/etc/mail/virtual)\ directory whose name is the same as the
27524 domain that is being processed. When the router runs, it looks up the local
27525 part in the file to find a new address (or list of addresses). The \no@_more\
27526 setting ensures that if the lookup fails (leading to \data\ being an empty
27527 string), Exim gives up on the address without trying any subsequent routers.
27528
27529 This one router can handle all the virtual domains because the alias file names
27530 follow a fixed pattern. Permissions can be arranged so that appropriate people
27531 can edit the different alias files. A successful aliasing operation results in
27532 a new envelope recipient address, which is then routed from scratch.
27533
27534 The other kind of `virtual' domain can also be handled in a straightforward
27535 way. One approach is to create a file for each domain containing a list of
27536 valid local parts, and use it in a router like this:
27537 .display asis
27538 my_domains:
27539   driver = accept
27540   domains = dsearch;/etc/mail/domains
27541   local_parts = lsearch;/etc/mail/domains/$domain
27542   transport = my_mailboxes
27543 .endd
27544 The address is accepted if there is a file for the domain, and the local part
27545 can be found in the file. The \domains\ option is used to check for the file's
27546 existence because \domains\ is tested before the \local@_parts\ option (see
27547 section ~~SECTrouprecon). You can't use \require@_files\, because that option
27548 is tested after \local@_parts\. The transport is as follows:
27549 .display asis
27550 my_mailboxes:
27551   driver = appendfile
27552   file = /var/mail/$domain/$local_part
27553   user = mail
27554 .endd
27555 This uses a directory of mailboxes for each domain. The \user\ setting is
27556 required, to specify which uid is to be used for writing to the mailboxes.
27557
27558 The configuration shown here is just one example of how you might support this
27559 requirement. There are many other ways this kind of configuration can be set
27560 up, for example, by using a database instead of separate files to hold all the
27561 information about the domains.
27562
27563
27564 .section Multiple user mailboxes
27565 .rset SECTmulbox "~~chapter.~~section"
27566 .index multiple mailboxes
27567 .index mailbox||multiple
27568 .index local part||prefix
27569 .index local part||suffix
27570 Heavy email users often want to operate with multiple mailboxes, into which
27571 incoming mail is automatically sorted. A popular way of handling this is to
27572 allow users to use multiple sender addresses, so that replies can easily be
27573 identified. Users are permitted to add prefixes or suffixes to their local
27574 parts for this purpose. The wildcard facility of the generic router options
27575 \local@_part@_prefix\ and \local@_part@_suffix\ can be used for this. For
27576 example, consider this router:
27577 .display asis
27578 userforward:
27579   driver = redirect
27580   check_local_user
27581   file = $home/.forward
27582   local_part_suffix = -*
27583   local_part_suffix_optional
27584   allow_filter
27585 .endd
27586 It runs a user's \(.forward)\ file for all local parts of the form
27587 \*username-$*$*\. Within the filter file the user can distinguish different
27588 cases by testing the variable \$local@_part@_suffix$\. For example:
27589 .display asis
27590 if $local_part_suffix contains -special then
27591   save /home/$local_part/Mail/special
27592 endif
27593 .endd
27594 If the filter file does not exist, or does not deal with such addresses, they
27595 fall through to subsequent routers, and, assuming no subsequent use of the
27596 \local@_part@_suffix\ option is made, they presumably fail. Thus, users have
27597 control over which suffixes are valid.
27598
27599 Alternatively, a suffix can be used to trigger the use of a different
27600 \(.forward)\ file -- which is the way a similar facility is implemented in
27601 another MTA:
27602 .display asis
27603 userforward:
27604   driver = redirect
27605   check_local_user
27606   file = $home/.forward$local_part_suffix
27607   local_part_suffix = -*
27608   local_part_suffix_optional
27609   allow_filter
27610 .endd
27611 If there is no suffix, \(.forward)\ is used; if the suffix is \*-special*\, for
27612 example, \(.forward-special)\ is used. Once again, if the appropriate file
27613 does not exist, or does not deal with the address, it is passed on to
27614 subsequent routers, which could, if required, look for an unqualified
27615 \(.forward)\ file to use as a default.
27616
27617
27618 .section Simplified vacation processing
27619 .index vacation processing
27620 The traditional way of running the \*vacation*\ program is for a user to set up
27621 a pipe command in a \(.forward)\ file
27622 (see section ~~SECTspecitredli for syntax details).
27623 This is prone to error by inexperienced users. There are two features of Exim
27624 that can be used to make this process simpler for users:
27625 .numberpars $.
27626 A local part prefix such as `vacation-' can be specified on a router which
27627 can cause the message to be delivered directly to the \*vacation*\ program, or
27628 alternatively can use Exim's \%autoreply%\ transport. The contents of a user's
27629 \(.forward)\ file are then much simpler. For example:
27630 .display asis
27631 spqr, vacation-spqr
27632 .endd
27633 .nextp
27634 The \require@_files\ generic router option can be used to trigger a
27635 vacation delivery by checking for the existence of a certain file in the
27636 user's home directory. The \unseen\ generic option should also be used, to
27637 ensure that the original delivery also proceeds. In this case, all the user has
27638 to do is to create a file called, say, \(.vacation)\, containing a vacation
27639 message.
27640 .endp
27641 Another advantage of both these methods is that they both work even when the
27642 use of arbitrary pipes by users is locked out.
27643
27644
27645 .section Taking copies of mail
27646 .index message||copying every
27647 Some installations have policies that require archive copies of all messages to
27648 be made. A single copy of each message can easily be taken by an appropriate
27649 command in a system filter, which could, for example, use a different file for
27650 each day's messages.
27651
27652 There is also a shadow transport mechanism that can be used to take copies of
27653 messages that are successfully delivered by local transports, one copy per
27654 delivery. This could be used, $it{inter alia}, to implement automatic
27655 notification of delivery by sites that insist on doing such things.
27656
27657
27658 .section Intermittently connected hosts
27659 .index intermittently connected hosts
27660 It has become quite common (because it is cheaper) for hosts to connect to the
27661 Internet periodically rather than remain connected all the time. The normal
27662 arrangement is that mail for such hosts accumulates on a system that is
27663 permanently connected.
27664
27665 Exim was designed for use on permanently connected hosts, and so it is not
27666 particularly well-suited to use in an intermittently connected environment.
27667 Nevertheless there are some features that can be used.
27668
27669 .section Exim on the upstream server host
27670 It is tempting to arrange for incoming mail for the intermittently connected
27671 host to remain on Exim's queue until the client connects. However, this
27672 approach does not scale very well. Two different kinds of waiting message are
27673 being mixed up in the same queue -- those that cannot be delivered because of
27674 some temporary problem, and those that are waiting for their destination host
27675 to connect. This makes it hard to manage the queue, as well as wasting
27676 resources, because each queue runner scans the entire queue.
27677
27678 A better approach is to separate off those messages that are waiting for an
27679 intermittently connected host. This can be done by delivering these messages
27680 into local files in batch SMTP, `mailstore', or other envelope-preserving
27681 format, from where they are transmitted by other software when their
27682 destination connects. This makes it easy to collect all the mail for one host
27683 in a single directory, and to apply local timeout rules on a per-message basis
27684 if required.
27685
27686 On a very small scale, leaving the mail on Exim's queue can be made to work. If
27687 you are doing this, you should configure Exim with a long retry period for the
27688 intermittent host. For example:
27689 .display
27690 cheshire.wonderland.fict.example    *   F,5d,24h
27691 .endd
27692 This stops a lot of failed delivery attempts from occurring, but Exim remembers
27693 which messages it has queued up for that host. Once the intermittent host comes
27694 online, forcing delivery of one message (either by using the \-M-\ or \-R-\
27695 options, or by using the \\ETRN\\ SMTP command (see section ~~SECTETRN)
27696 causes all the queued up messages to be delivered, often down a single SMTP
27697 connection. While the host remains connected, any new messages get delivered
27698 immediately.
27699
27700 If the connecting hosts do not have fixed IP addresses, that is, if a host is
27701 issued with a different IP address each time it connects, Exim's retry
27702 mechanisms on the holding host get confused, because the IP address is normally
27703 used as part of the key string for holding retry information. This can be
27704 avoided by unsetting \retry__include__ip__address\ on the \%smtp%\ transport.
27705 Since this has disadvantages for permanently connected hosts, it is best to
27706 arrange a separate transport for the intermittently connected ones.
27707
27708
27709 .section Exim on the intermittently connected client host
27710 The value of \smtp@_accept@_queue@_per@_connection\ should probably be
27711 increased, or even set to zero (that is, disabled) on the intermittently
27712 connected host, so that all incoming messages down a single connection get
27713 delivered immediately.
27714
27715 .index SMTP||passed connection
27716 .index SMTP||multiple deliveries
27717 .index multiple SMTP deliveries
27718 Mail waiting to be sent from an intermittently connected host will probably
27719 not have been routed, because without a connection DNS lookups are not
27720 possible. This means that if a normal queue run is done at connection time,
27721 each message is likely to be sent in a separate SMTP session. This can be
27722 avoided by starting the queue run with a command line option beginning with
27723 \-qq-\ instead of \-q-\. In this case, the queue is scanned twice. In the first
27724 pass, routing is done but no deliveries take place. The second pass is a normal
27725 queue run; since all the messages have been previously routed, those destined
27726 for the same host are likely to get sent as multiple deliveries in a single
27727 SMTP connection.
27728
27729
27730
27731 .
27732 .
27733 .
27734 .
27735 . ============================================================================
27736 .chapter Using Exim as a non-queueing client
27737 .set runningfoot "non-queueing client"
27738 .rset CHAPnonqueueing "~~chapter"
27739 .index client, non-queueing
27740 .index smart host||queueing, suppressing
27741 .em
27742 On a personal computer, it is a common requirement for all
27743 email to be sent to a `smart host'. There are plenty of MUAs that can be
27744 configured to operate that way, for all the popular operating systems.
27745 However, there are some MUAs for Unix-like systems that cannot be so
27746 configured: they submit messages using the command line interface of
27747 \(/usr/sbin/sendmail)\. Furthermore, utility programs such as \*cron*\ submit
27748 messages this way.
27749
27750 If the personal computer runs continuously, there is no problem, because it can 
27751 run a conventional MTA that handles delivery to the smart host, and deal with
27752 any delays via its queueing mechanism. However, if the computer does not run 
27753 continuously or runs different operating systems at different times, queueing 
27754 email is not desirable.
27755
27756 There is therefore a requirement for something that can provide the
27757 \(/usr/sbin/sendmail)\ interface but deliver messages to a smart host without
27758 any queueing or retrying facilities. Furthermore, the delivery to the smart
27759 host should be synchronous, so that if it fails, the sending MUA is immediately
27760 informed. In other words, we want something that extends an MUA that submits
27761 to a local MTA via the command line so that it behaves like one that submits
27762 to a remote smart host using TCP/SMTP.
27763
27764 There are a number of applications (for example, there is one called \*ssmtp*\)
27765 that do this job. However, people have found them to be lacking in various
27766 ways. For instance, you might want to allow aliasing and forwarding to be done
27767 before sending a message to the smart host.
27768
27769 Exim already had the necessary infrastructure for doing this job. Just a few
27770 tweaks were needed to make it behave as required, though it is somewhat of an
27771 overkill to use a fully-featured MTA for this purpose.
27772
27773 .index \mua@_wrapper\
27774 There is a Boolean global option called \mua@_wrapper\, defaulting false.
27775 Setting \mua@_wrapper\ true causes Exim to run in a special mode where it
27776 assumes that it is being used to `wrap' a command-line MUA in the manner
27777 just described. As well as setting \mua@_wrapper\, you also need to provide a
27778 compatible router and transport configuration. Typically there will be just one
27779 router and one transport, sending everything to a smart host.
27780
27781 When run in MUA wrapping mode, the behaviour of Exim changes in the
27782 following ways:
27783 .numberpars alpha
27784 A daemon cannot be run, nor will Exim accept incoming messages from \*inetd*\.
27785 In other words, the only way to submit messages is via the command line.
27786 .nextp
27787 Each message is synchonously delivered as soon as it is received (\-odi-\ is
27788 assumed). All queueing options (\queue@_only\, \queue@_smtp@_domains\,
27789 \control\ in an ACL, etc.) are quietly ignored. The Exim reception process does
27790 not finish until the delivery attempt is complete. If the delivery is
27791 successful, a zero return code is given.
27792 .nextp
27793 Address redirection is permitted, but the final routing for all addresses must
27794 be to the same remote transport, and to the same list of hosts. Furthermore,
27795 the return address (envelope sender) must be the same for all recipients, as
27796 must any added or deleted header lines. In other words, it must be possible to
27797 deliver the message in a single SMTP transaction, however many recipients there
27798 are.
27799 .nextp
27800 If these conditions are not met, or if routing any address results in a failure
27801 or defer status, or if Exim is unable to deliver all the recipients
27802 successfully to one of the smart hosts, delivery of the entire message fails.
27803 .nextp
27804 Because no queueing is allowed, all failures are treated as permanent; there is
27805 no distinction between 4\*xx*\ and 5\*xx*\ SMTP response codes from the smart
27806 host. Furthermore, because only a single yes/no response can be given to the
27807 caller, it is not possible to deliver to some recipients and not others. If
27808 there is an error (temporary or permanent) for any recipient, all are failed.
27809 .nextp
27810 If more than one smart host is listed, Exim will try another host after a
27811 connection failure or a timeout, in the normal way. However, if this kind of
27812 failure happens for all the hosts, the delivery fails.
27813 .nextp
27814 When delivery fails, an error message is written to the standard error stream
27815 (as well as to Exim's log), and Exim exits to the caller with a return code
27816 value 1. The message is expunged from Exim's spool files. No bounce messages
27817 are ever generated.
27818 .nextp
27819 No retry data is maintained, and any retry rules are ignored.
27820 .nextp
27821 A number of Exim options are overridden: \deliver@_drop@_privilege\ is forced
27822 true, \max@_rcpt\ in the smtp transport is forced to `unlimited',
27823 \remote@_max@_parallel\ is forced to one, and fallback hosts are ignored.
27824 .endp
27825 The overall effect is that Exim makes a single synchronous attempt to deliver
27826 the message, failing if there is any kind of problem. Because no local
27827 deliveries are done and no daemon can be run, Exim does not need root
27828 privilege. It should be possible to run it setuid to \*exim*\ instead of setuid
27829 to \*root*\. See section ~~SECTrunexiwitpri for a general discussion about the
27830 advantages and disadvantages of running without root privilege.
27831 .nem
27832
27833
27834
27835 .
27836 .
27837 .
27838 .
27839 . ============================================================================
27840 .chapter Log files
27841 .set runningfoot "log files"
27842 .rset CHAPlog "~~chapter"
27843 .index log||types of
27844 .index log||general description
27845 Exim writes three different logs, referred to as the main log, the reject log,
27846 and the panic log:
27847 .numberpars $.
27848 .index main log
27849 The main log records the arrival of each message and each delivery in a single
27850 line in each case. The format is as compact as possible, in an attempt to keep
27851 down the size of log files. Two-character flag sequences make it easy to pick
27852 out these lines. A number of other events are recorded in the main log. Some of
27853 them are optional, in which case the \log@_selector\ option controls whether
27854 they are included or not. A Perl script called \*eximstats*\, which does simple
27855 analysis of main log files, is provided in the Exim distribution (see section
27856 ~~SECTmailstat).
27857 .nextp
27858 .index reject log
27859 The reject log records information from messages that are rejected as a result
27860 of a configuration option (that is, for policy reasons).
27861 The first line of each rejection is a copy of the line that is also written to
27862 the main log. Then, if the message's header has been read at the time the log
27863 is written, its contents are written to this log. Only the original header
27864 lines are available; header lines added by ACLs are not logged. You can use the
27865 reject log to check that your policy controls are working correctly; on a busy
27866 host this may be easier than scanning the main log for rejection messages. You
27867 can suppress the writing of the reject log by setting \write@_rejectlog\ false.
27868 .nextp
27869 .index panic log
27870 .index system log
27871 When certain serious errors occur, Exim writes entries to its panic log. If the
27872 error is sufficiently disastrous, Exim bombs out afterwards. Panic log entries
27873 are usually written to the main log as well, but can get lost amid the mass of
27874 other entries. The panic log should be empty under normal circumstances. It is
27875 therefore a good idea to check it (or to have a \*cron*\ script check it)
27876 regularly, in order to become aware of any problems. When Exim cannot open its
27877 panic log, it tries as a last resort to write to the system log (syslog). This
27878 is opened with LOG@_PID+LOG@_CONS and the facility code of LOG@_MAIL. The
27879 message itself is written at priority LOG@_CRIT.
27880 .endp
27881 Every log line starts with a timestamp, in the format shown in this example:
27882 .display asis
27883 2001-09-16 16:09:47 SMTP connection from [127.0.0.1] closed by QUIT
27884 .endd
27885 By default, the timestamps are in the local timezone. There are two
27886 ways of changing this:
27887 .numberpars $.
27888 You can set the \timezone\ option to a different time zone; in particular, if
27889 you set
27890 .display asis
27891 timezone = UTC
27892 .endd
27893 the timestamps will be in UTC (aka GMT).
27894 .nextp
27895 If you set \log@_timezone\ true, the time zone is added to the timestamp, for
27896 example:
27897 .display asis
27898 2003-04-25 11:17:07 +0100 Start queue run: pid=12762
27899 .endd
27900 .endp
27901
27902
27903
27904 .section Where the logs are written
27905 .rset SECTwhelogwri "~~chapter.~~section"
27906 .index log||destination
27907 .index log||to file
27908 .index log||to syslog
27909 .index syslog
27910 The logs may be written to local files, or to syslog, or both. However, it
27911 should be noted that many syslog implementations use UDP as a transport, and
27912 are therefore unreliable in the sense that messages are not guaranteed to
27913 arrive at the loghost, nor is the ordering of messages necessarily maintained.
27914 It has also been reported that on large log files (tens of megabytes) you may
27915 need to tweak syslog to prevent it syncing the file with each write -- on Linux
27916 this has been seen to make syslog take 90% plus of CPU time.
27917
27918 The destination for Exim's logs is configured by setting \\LOG@_FILE@_PATH\\ in
27919 \(Local/Makefile)\ or by setting \log@_file@_path\ in the run time
27920 configuration. This latter string is expanded, so it can contain, for example,
27921 references to the host name:
27922 .display asis
27923 log_file_path = /var/log/$primary_hostname/exim_%slog
27924 .endd
27925 It is generally advisable, however, to set the string in \(Local/Makefile)\
27926 rather than at run time, because then the setting is available right from the
27927 start of Exim's execution. Otherwise, if there's something it wants to log
27928 before it has read the configuration file (for example, an error in the
27929 configuration file) it will not use the path you want, and may not be able to
27930 log at all.
27931
27932 The value of \\LOG@_FILE@_PATH\\ or \log@_file@_path\ is a colon-separated
27933 list, currently limited to at most two items. This is one option where the
27934 facility for changing a list separator may not be used. The list must always be
27935 colon-separated. If an item in the list is `syslog' then syslog is used;
27936 otherwise the item must either be an absolute path, containing \"%s"\ at the
27937 point where `main', `reject', or `panic' is to be inserted, or be empty,
27938 implying the use of a default path.
27939
27940 When Exim encounters an empty item in the list, it searches the list defined by
27941 \\LOG@_FILE@_PATH\\, and uses the first item it finds that is neither empty nor
27942 `syslog'. This means that an empty item in \log@_file@_path\ can be used to
27943 mean `use the path specified at build time'. It no such item exists, log files
27944 are written in the \(log)\ subdirectory of the spool directory. This is
27945 equivalent to the setting:
27946 .display asis
27947 log_file_path = $spool_directory/log/%slog
27948 .endd
27949 If you do not specify anything at build time or run time, that is where the
27950 logs are written.
27951
27952 A log file path may also contain \"%D"\ if datestamped log file names are in
27953 use -- see section ~~SECTdatlogfil below.
27954
27955 Here are some examples of possible settings:
27956 .display
27957 .tabs 42
27958 LOG@_FILE@_PATH=syslog                      $t $rm{syslog only}
27959 LOG@_FILE@_PATH=:syslog                     $t $rm{syslog and default path}
27960 LOG@_FILE@_PATH=syslog : /usr/log/exim@_%s  $t $rm{syslog and specified path}
27961 LOG@_FILE@_PATH=/usr/log/exim@_%s           $t $rm{specified path only}
27962 .endd
27963 If there are more than two paths in the list, the first is used and a panic
27964 error is logged.
27965
27966
27967 .section Logging to local files that are periodically `cycled'
27968 .index log||cycling local files
27969 .index cycling logs
27970 .index \*exicyclog*\
27971 .index log||local files, writing to
27972 Some operating systems provide centralized and standardised methods for cycling
27973 log files. For those that do not, a utility script called \*exicyclog*\ is
27974 provided (see section ~~SECTcyclogfil). This renames and compresses the main
27975 and reject logs each time it is called. The maximum number of old logs to keep
27976 can be set. It is suggested this script is run as a daily \*cron*\ job.
27977
27978 An Exim delivery process opens the main log when it first needs to write to it,
27979 and it keeps the file open in case subsequent entries are required -- for
27980 example, if a number of different deliveries are being done for the same
27981 message. However, remote SMTP deliveries can take a long time, and this means
27982 that the file may be kept open long after it is renamed if \*exicyclog*\ or
27983 something similar is being used to rename log files on a regular basis. To
27984 ensure that a switch of log files is noticed as soon as possible, Exim calls
27985 \*stat()*\ on the main log's name before reusing an open file, and if the file
27986 does not exist, or its inode has changed, the old file is closed and Exim
27987 tries to open the main log from scratch. Thus, an old log file may remain open
27988 for quite some time, but no Exim processes should write to it once it has been
27989 renamed.
27990
27991
27992 .section Datestamped log files
27993 .rset SECTdatlogfil "~~chapter.~~section"
27994 .index log||datestamped files
27995 Instead of cycling the main and reject log files by renaming them
27996 periodically, some sites like to use files whose names contain a datestamp,
27997 for example, \(mainlog-20031225)\. The datestamp is in the form \(yyyymmdd)\.
27998 Exim has support for this way of working. It is enabled by setting the
27999 \log@_file@_path\ option to a path that includes \"%D"\ at the point where the
28000 datestamp is required. For example:
28001 .display asis
28002 log_file_path = /var/spool/exim/log/%slog-%D
28003 log_file_path = /var/log/exim-%s-%D.log
28004 log_file_path = /var/spool/exim/log/%D-%slog
28005 .endd
28006 As before, \"%s"\ is replaced by `main' or `reject'; the following are examples
28007 of names generated by the above examples:
28008 .display asis
28009 /var/spool/exim/log/mainlog-20021225
28010 /var/log/exim-reject-20021225.log
28011 /var/spool/exim/log/20021225-mainlog
28012 .endd
28013 When this form of log file is specified, Exim automatically switches to new
28014 files at midnight. It does not make any attempt to compress old logs; you
28015 will need to write your own script if you require this. You should not
28016 run \*exicyclog*\ with this form of logging.
28017
28018 The location of the panic log is also determined by \log@_file@_path\, but it
28019 is not datestamped, because rotation of the panic log does not make sense.
28020 When generating the name of the panic log, \"%D"\ is removed from the string.
28021 In addition, if it immediately follows a slash, a following non-alphanumeric
28022 character is removed; otherwise a preceding non-alphanumeric character is
28023 removed. Thus, the three examples above would give these panic log names:
28024 .display asis
28025 /var/spool/exim/log/paniclog
28026 /var/log/exim-panic.log
28027 /var/spool/exim/log/paniclog
28028 .endd
28029
28030
28031 .section Logging to syslog
28032 .index log||syslog, writing to
28033 The use of syslog does not change what Exim logs or the format of its messages,
28034 except in one respect. If \syslog@_timestamp\ is set false, the timestamps on
28035 Exim's log lines are omitted when these lines are sent to syslog. Apart from
28036 that, the same strings are written to syslog as to log files. The syslog
28037 `facility' is set to \\LOG@_MAIL\\, and the program name to `exim'
28038 by default, but you can change these by setting the \syslog@_facility\ and
28039 \syslog@_processname\ options, respectively. If Exim was compiled with
28040 \\SYSLOG@_LOG@_PID\\ set in \(Local/Makefile)\ (this is the default in
28041 \(src/EDITME)\), then, on systems that permit it (all except ULTRIX), the
28042 \\LOG@_PID\\ flag is set so that the \*syslog()*\ call adds the pid as well as
28043 the time and host name to each line.
28044 The three log streams are mapped onto syslog priorities as follows:
28045 .numberpars " "
28046 \*mainlog*\ is mapped to \\LOG@_INFO\\
28047 .nextp
28048 \*rejectlog*\ is mapped to \\LOG@_NOTICE\\
28049 .nextp
28050 \*paniclog*\ is mapped to \\LOG@_ALERT\\
28051 .endp
28052 Many log lines are written to both \*mainlog*\ and \*rejectlog*\, and some are
28053 written to both \*mainlog*\ and \*paniclog*\, so there will be duplicates if
28054 these are routed by syslog to the same place. You can suppress this duplication
28055 by setting \syslog@_duplication\ false.
28056
28057 Exim's log lines can sometimes be very long, and some of its \*rejectlog*\
28058 entries contain multiple lines when headers are included. To cope with both
28059 these cases, entries written to syslog are split into separate \*syslog()*\
28060 calls at each internal newline, and also after a maximum of
28061 870 data characters. (This allows for a total syslog line length of 1024, when
28062 additions such as timestamps are added.) If you are running a syslog
28063 replacement that can handle lines longer than the 1024 characters allowed by
28064 RFC 3164, you should set
28065 .display asis
28066 SYSLOG_LONG_LINES=yes
28067 .endd
28068 in \(Local/Makefile)\ before building Exim. That stops Exim from splitting long
28069 lines, but it still splits at internal newlines in \*reject*\ log entries.
28070
28071 To make it easy to re-assemble split lines later, each component of a split
28072 entry starts with a string of the form `[<<n>>/<<m>>]' or `[<<n>>@\<<m>>]'
28073 where <<n>> is the component number and <<m>> is the total number of components
28074 in the entry. The / delimiter is used when the line was split because it was
28075 too long; if it was split because of an internal newline, the @\ delimiter is
28076 used. For example, supposing the length limit to be 70 instead of 1000, the
28077 following would be the result of a typical rejection message to \*mainlog*\
28078 (LOG@_INFO), each line in addition being preceded by the time, host name, and
28079 pid as added by syslog:
28080 .display
28081 .indent 0
28082 $smc{[1/3] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from [127.0.0.1] (ph10):
28083 [2/3]  syntax error in 'From' header when scanning for sender: missing or ma
28084 [3/3] lformed local part in "<>" (envelope sender is <ph10@@cam.example>)}
28085 .endd
28086 The same error might cause the following lines to be written to `rejectlog'
28087 (LOG@_NOTICE):
28088 .display flow
28089 .indent 0
28090 $smc{[1/14] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from [127.0.0.1] (ph10):
28091 [2/14]  syntax error in 'From' header when scanning for sender: missing or ma
28092 [3@\14] lformed local part in "@<@>" (envelope sender is <ph10@@cam.example>)
28093 [4@\14] Recipients: ph10@@some.domain.cam.example
28094 [5@\14] P Received: from [127.0.0.1] (ident=ph10)
28095 [6@\14]        by xxxxx.cam.example with smtp (Exim 4.00)
28096 [7@\14]        id 16RdAL-0006pc-00
28097 [8@\14]        for ph10@@cam.example; Mon, 16 Sep 2002 16:09:43 +0100
28098 [9@\14] F From: @<@>
28099 [10@\14]   Subject: this is a test header
28100 [11@\14]   X-something: this is another header
28101 [12@\14] I Message-Id: <E16RdAL-0006pc-00@@xxxxx.cam.example>
28102 [13@\14] B Bcc:
28103 [14/14]   Date: Mon, 16 Sep 2002 16:09:43 +0100}
28104 .endd
28105 Log lines that are neither too long nor contain newlines are written to syslog
28106 without modification.
28107
28108 If only syslog is being used, the Exim monitor is unable to provide a log tail
28109 display, unless syslog is routing \*mainlog*\ to a file on the local host and
28110 the environment variable \\EXIMON@_LOG@_FILE@_PATH\\ is set to tell the monitor
28111 where it is.
28112
28113
28114 .section Log line flags
28115 One line is written to the main log for each message received, and for each
28116 successful, unsuccessful, and delayed delivery. These lines can readily be
28117 picked out by the distinctive two-character flags that immediately follow the
28118 timestamp. The flags are:
28119 .display
28120 .tabs 6
28121 <=    $t $rm{message arrival}
28122 =>    $t $rm{normal message delivery}
28123 ->    $t $rm{additional address in same delivery}
28124 *>    $t $rm{delivery suppressed by \-N-\}
28125 **    $t $rm{delivery failed; address bounced}
28126 ==    $t $rm{delivery deferred; temporary problem}
28127 .endd
28128
28129
28130 .section Logging message reception
28131 .index log||reception line
28132 The format of the single-line entry in the main log that is written for every
28133 message received is shown in the basic example below, which is split over
28134 several lines in order to fit it on the page:
28135 .display
28136 .indent 0
28137 2002-10-31 08:57:53 16ZCW1-0005MB-00 <= kryten@@dwarf.fict.example
28138   H=mailer.fict.example [192.168.123.123] U=exim
28139   P=smtp S=5678 id=<<incoming message id>>
28140 .endd
28141 The address immediately following `<=' is the envelope sender address. A bounce
28142 message is shown with the sender address `<>', and if it is locally generated,
28143 this is followed by an item of the form
28144 .display
28145 R=<<message id>>
28146 .endd
28147 which is a reference to the message that caused the bounce to be sent.
28148
28149 .index \\HELO\\
28150 .index \\EHLO\\
28151 For messages from other hosts, the H and U fields identify the remote host and
28152 record the RFC 1413 identity of the user that sent the message, if one was
28153 received. The number given in square brackets is the IP address of the sending
28154 host. If there is a single, unparenthesized  host name in the H field, as
28155 above, it has been verified to correspond to the IP address (see the
28156 \host@_lookup\ option). If the name is in parentheses, it was the name quoted
28157 by the remote host in the SMTP \\HELO\\ or \\EHLO\\ command, and has not been
28158 verified. If verification yields a different name to that given for \\HELO\\ or
28159 \\EHLO\\, the verified name appears first, followed by the \\HELO\\ or \\EHLO\\
28160 name in parentheses.
28161
28162 Misconfigured hosts (and mail forgers) sometimes put an IP address, with or
28163 without brackets, in the \\HELO\\ or \\EHLO\\ command, leading to entries in
28164 the log containing text like these examples:
28165 .display
28166 H=(10.21.32.43) [192.168.8.34]
28167 H=([10.21.32.43]) [192.168.8.34]
28168 .endd
28169 This can be confusing. Only the final address in square brackets can be relied
28170 on.
28171
28172 For locally generated messages (that is, messages not received over TCP/IP),
28173 the H field is omitted, and the U field contains the login name of the caller
28174 of Exim.
28175
28176 .index authentication||logging
28177 .index \\AUTH\\||logging
28178 For all messages, the P field specifies the protocol used to receive the
28179 message. This is set to 
28180 .em
28181 `esmtpa' 
28182 .nem
28183 for messages received from hosts that have authenticated themselves using the
28184 SMTP \\AUTH\\ command. In this case there is an additional item A= followed by
28185 the name of the authenticator that was used. If an authenticated identification
28186 was set up by the authenticator's \server@_set@_id\ option, this is logged too,
28187 separated by a colon from the authenticator name.
28188
28189 The id field records the existing message id, if present.
28190 .index size||of message
28191 The size of the received message is given by the S field. When the message is
28192 delivered, headers may get removed or added, so that the size of delivered
28193 copies of the message may not correspond with this value (and indeed may be
28194 different to each other).
28195
28196 The \log@_selector\ option can be used to request the logging of additional
28197 data when a message is received. See section ~~SECTlogselector below.
28198
28199
28200 .section Logging deliveries
28201 .index log||delivery line
28202 The format of the single-line entry in the main log that is written for every
28203 delivery is shown in one of the examples below, for local and remote deliveries,
28204 respectively. Each example has been split into two lines in order to fit
28205 it on the page:
28206 .display
28207 .indent 0
28208 2002-10-31 08:59:13 16ZCW1-0005MB-00 => marv <marv@@hitch.fict.example>
28209   R=localuser T=local@_delivery
28210 2002-10-31 09:00:10 16ZCW1-0005MB-00 => monk@@holistic.fict.example
28211   R=dnslookup T=remote@_smtp H=holistic.fict.example [192.168.234.234]
28212 .endd
28213 For ordinary local deliveries, the original address is given in angle brackets
28214 after the final delivery address, which might be a pipe or a file. If
28215 intermediate address(es) exist between the original and the final address, the
28216 last of these is given in parentheses after the final address. The R and T
28217 fields record the router and transport that were used to process the address.
28218
28219 If a shadow transport was run after a successful local delivery, the log line
28220 for the successful delivery has an item added on the end, of the form
28221 .display
28222 ST=<<shadow transport name>>
28223 .endd
28224 If the shadow transport did not succeed, the error message is put in
28225 parentheses afterwards.
28226
28227 When more than one address is included in a single delivery (for example, two
28228 SMTP \\RCPT\\ commands in one transaction) the second and subsequent
28229 addresses are flagged with `$tt{@-@>}' instead of `$tt{@=@>}'. When two or more
28230 messages are delivered down a single SMTP connection, an asterisk follows the
28231 IP address in the log lines for the second and subsequent messages.
28232
28233 The generation of a reply message by a filter file gets logged as a `delivery'
28234 to the addressee, preceded by `>'.
28235
28236 The \log@_selector\ option can be used to request the logging of additional
28237 data when a message is delivered. See section ~~SECTlogselector below.
28238
28239
28240 .section Discarded deliveries
28241 .index discarded messages
28242 .index message||discarded
28243 .index delivery||discarded, logging
28244 When a message is discarded as a result of the command `seen finish' being
28245 obeyed in a filter file which generates no deliveries, a log entry of the form
28246 .display
28247 2002-12-10 00:50:49 16auJc-0001UB-00 => discarded
28248   <low.club@@bridge.example> R=userforward
28249 .endd
28250 is written, to record why no deliveries are logged. When a message is discarded
28251 because it is aliased to `:blackhole:' the log line is like this:
28252 .display asis
28253 1999-03-02 09:44:33 10HmaX-0005vi-00 => :blackhole:
28254   <hole@nowhere.example> R=blackhole_router
28255 .endd
28256
28257
28258 .section Deferred deliveries
28259 When a delivery is deferred, a line of the following form is logged:
28260 .display
28261 .indent 0
28262 2002-12-19 16:20:23 16aiQz-0002Q5-00 == marvin@@endrest.example
28263   R=dnslookup T=smtp defer (146): Connection refused
28264 .endd
28265 In the case of remote deliveries, the error is the one that was given for the
28266 last IP address that was tried. Details of individual SMTP failures are also
28267 written to the log, so the above line would be preceded by something like
28268 .display
28269 .indent 0
28270 2002-12-19 16:20:23 16aiQz-0002Q5-00 Failed to connect to
28271   mail1.endrest.example [192.168.239.239]: Connection refused
28272 .endd
28273 When a deferred address is skipped because its retry time has not been reached,
28274 a message is written to the log, but this can be suppressed by setting an
28275 appropriate value in \log@_selector\.
28276
28277
28278 .section Delivery failures
28279 .index delivery||failure, logging
28280 If a delivery fails because an address cannot be routed, a line of the
28281 following form is logged:
28282 .display asis
28283 .indent 0
28284 1995-12-19 16:20:23 0tRiQz-0002Q5-00 ** jim@trek99.example
28285   <jim@trek99.example>: unknown mail domain
28286 .endd
28287 If a delivery fails at transport time, the router and transport are shown, and
28288 the response from the remote host is included, as in this example:
28289 .display asis
28290 .indent 0
28291 2002-07-11 07:14:17 17SXDU-000189-00 ** ace400@pb.example R=dnslookup
28292 .newline
28293   T=remote_smtp: SMTP error from remote mailer after pipelined
28294 .newline
28295   RCPT TO:<ace400@pb.example>: host pbmail3.py.example
28296   [192.168.63.111]: 553 5.3.0 <ace400@pb.example>...
28297   Addressee unknown
28298 .endd
28299 The word `pipelined' indicates that the SMTP \\PIPELINING\\ extension was being
28300 used. See \hosts@_avoid@_esmtp\ in the \%smtp%\ transport for a way of
28301 disabling \\PIPELINING\\.
28302
28303 The log lines for all forms of delivery failure are flagged with \"**"\.
28304
28305
28306 .section Fake deliveries
28307 .index delivery||fake, logging
28308 If a delivery does not actually take place because the \-N-\ option has been
28309 used to suppress it, a normal delivery line is written to the log, except that
28310 `=>' is replaced by `$*$>'.
28311
28312
28313 .section Completion
28314 A line of the form
28315 .display
28316 2002-10-31 09:00:11 16ZCW1-0005MB-00 Completed
28317 .endd
28318 is written to the main log when a message is about to be removed from the spool
28319 at the end of its processing.
28320
28321
28322
28323 .section Summary of Fields in Log Lines
28324 .index log||summary of fields
28325 A summary of the field identifiers that are used in log lines is shown in
28326 the following table:
28327 .display flow
28328 .tabs 8
28329 A          $t $rm{authenticator name (and optional id)}
28330 C          $t $rm{SMTP confirmation on delivery}
28331 CV         $t $rm{certificate verification status}
28332 DN         $t $rm{distinguished name from peer certificate}
28333 .newline
28334 .em
28335 DT         $t $rm{on \"=>"\ lines: time taken for a delivery}
28336 .nem
28337 .newline
28338 F          $t $rm{sender address (on delivery lines)}
28339 H          $t $rm{host name and IP address}
28340 I          $t $rm{local interface used}
28341 id         $t $rm{message id for incoming message}
28342 P          $t $rm{on \"<="\ lines: protocol used}
28343 .newline
28344 .em
28345            $t $rm{on \"=>"\ and \"**"\ lines: return path}
28346 QT         $t $rm{on \"=>"\ lines: time spent on queue so far}
28347            $t $rm{on `Completed' lines: time spent on queue}
28348 .nem
28349 .newline            
28350 R          $t $rm{on \"<="\ lines: reference for local bounce}
28351 .newline
28352 .em
28353            $t $rm{on \"=>"\  \"**"\ and \"=="\ lines: router name}
28354 .nem
28355 .newline            
28356 S          $t $rm{size of message}
28357 ST         $t $rm{shadow transport name}
28358 T          $t $rm{on \"<="\ lines: message subject (topic)}
28359 .newline
28360 .em
28361            $t $rm{on \"=>"\ \"**"\ and \"=="\ lines: transport name}
28362 .nem
28363 .newline            
28364 U          $t $rm{local user or RFC 1413 identity}
28365 X          $t $rm{TLS cipher suite}
28366 .endd
28367
28368
28369 .section Other log entries
28370 Various other types of log entry are written from time to time. Most should be
28371 self-explanatory. Among the more common are:
28372 .numberpars $.
28373 .index retry||time not reached
28374 \*retry time not reached*\##An address previously suffered a temporary error
28375 during routing or local delivery, and the time to retry has not yet arrived.
28376 This message is not written to an individual message log file unless it happens
28377 during the first delivery attempt.
28378 .nextp
28379 \*retry time not reached for any host*\##An address previously suffered
28380 temporary errors during remote delivery, and the retry time has not yet arrived
28381 for any of the hosts to which it is routed.
28382 .nextp
28383 .index spool directory||file locked
28384 \*spool file locked*\##An attempt to deliver a message cannot proceed because
28385 some other Exim process is already working on the message. This can be quite
28386 common if queue running processes are started at frequent intervals. The
28387 \*exiwhat*\ utility script can be used to find out what Exim processes are
28388 doing.
28389 .nextp
28390 .index error||ignored
28391 \*error ignored*\##There are several circumstances that give rise to this
28392 message:
28393 .numberpars " "
28394 Exim failed to deliver a bounce message whose age was greater than
28395 \ignore__bounce__errors__after\. The bounce was discarded.
28396 .nextp
28397 A filter file set up a delivery using the `noerror' option, and the delivery
28398 failed. The delivery was discarded.
28399 .nextp
28400 A delivery set up by a router configured with
28401 .display asis
28402 errors_to = <>
28403 .endd
28404 failed. The delivery was discarded.
28405 .endp
28406 .endp
28407
28408
28409
28410 .section Reducing or increasing what is logged
28411 .rset SECTlogselector "~~chapter.~~section"
28412 .index log||selectors
28413 By setting the \log@_selector\ global option, you can disable some of Exim's
28414 default logging, or you can request additional logging. The value of
28415 \log@_selector\ is made up of names preceded by plus or minus characters. For
28416 example:
28417 .display asis
28418 log_selector = +arguments -retry_defer
28419 .endd
28420 The list of optional log items is in the following table, with the default
28421 selection marked by asterisks:
28422 .display flow
28423 .tabs 32
28424  address@_rewrite           $t $rm{address rewriting}
28425  all@_parents               $t $rm{all parents in => lines}
28426  arguments                  $t $rm{command line arguments}
28427 *connection@_reject         $t $rm{connection rejections}
28428 *delay@_delivery            $t $rm{immediate delivery delayed}
28429  deliver@_time              $t $rm{time taken to perform delivery}
28430  delivery@_size             $t $rm{add S=nnn to => lines}
28431 *dnslist@_defer             $t $rm{defers of DNS list (aka RBL) lookups}
28432 *etrn                       $t $rm{ETRN commands}
28433 *host@_lookup@_failed       $t $rm{as it says}
28434  ident@_timeout             $t $rm{timeout for ident connection}
28435  incoming@_interface        $t $rm{incoming interface on <= lines}
28436  incoming@_port             $t $rm{incoming port on <= lines}
28437 *lost@_incoming@_connection $t $rm{as it says (includes timeouts)}
28438  outgoing@_port             $t $rm{add remote port to => lines}
28439 *queue@_run                 $t $rm{start and end queue runs}
28440 .newline
28441 .em 
28442  queue@_time                $t $rm{time on queue for one recipient}
28443  queue@_time@_overall       $t $rm{time on queue for whole message} 
28444 .nem
28445 .newline
28446  received@_recipients       $t $rm{recipients on <= lines}
28447  received@_sender           $t $rm{sender on <= lines}
28448 *rejected@_header           $t $rm{header contents on reject log}
28449 *retry@_defer               $t $rm{`retry time not reached'}
28450  return@_path@_on@_delivery $t $rm{put return path on => and ** lines}
28451  sender@_on@_delivery       $t $rm{add sender to => lines}
28452 *size@_reject               $t $rm{rejection because too big}
28453 *skip@_delivery             $t $rm{delivery skipped in a queue run}
28454  smtp@_confirmation         $t $rm{SMTP confirmation on => lines}
28455  smtp@_connection           $t $rm{SMTP connections}
28456  smtp@_incomplete@_transaction $t $rm{incomplete SMTP transactions}
28457  smtp@_protocol@_error      $t $rm{SMTP protocol errors}
28458  smtp@_syntax@_error        $t $rm{SMTP syntax errors}
28459  subject                    $t $rm{contents of ::Subject:: on <= lines}
28460  tls@_certificate@_verified $t $rm{certificate verification status}
28461 *tls@_cipher                $t $rm{TLS cipher suite on <= and => lines}
28462  tls@_peerdn                $t $rm{TLS peer DN on <= and => lines}
28463
28464  all                        $t $rm{all of the above}
28465 .endd
28466 More details on each of these items follows:
28467 .numberpars $.
28468 .index log||rewriting
28469 .index rewriting||logging
28470 \address@_rewrite\: This applies both to global rewrites and per-transport
28471 rewrites,
28472 but not to rewrites in filters run as an unprivileged user (because such users
28473 cannot access the log).
28474 .nextp
28475 .index log||full parentage
28476 \all@_parents\: Normally only the original and final addresses are logged on
28477 delivery lines; with this selector, intermediate parents are given in
28478 parentheses between them.
28479 .nextp
28480 .index log||Exim arguments
28481 .index Exim arguments, logging
28482 \arguments\: This causes Exim to write the arguments with which it was called
28483 to the main log,
28484 preceded by the current working directory.
28485 This is a debugging feature, added to make it easier to find out how certain
28486 MUAs call \(/usr/sbin/sendmail)\. The logging does not happen if Exim has given
28487 up root privilege because it was called with the \-C-\ or \-D-\ options.
28488 Arguments that are empty or that contain whitespace are quoted. Non-printing
28489 characters are shown as escape sequences.
28490 This facility cannot log unrecognized arguments, because the arguments are
28491 checked before the configuration file is read. The only way to log such cases
28492 is to interpose a script such as \(util/logargs.sh)\ between the caller and
28493 Exim.
28494 .nextp
28495 .index log||connection rejections
28496 \connection@_reject\: A log entry is written whenever an incoming SMTP
28497 connection is rejected, for whatever reason.
28498 .nextp
28499 .index log||delayed delivery
28500 .index delayed delivery, logging
28501 \delay@_delivery\: A log entry is written whenever a delivery process is not
28502 started for an incoming message because the load is too high or too many
28503 messages were received on one connection. Logging does not occur if no delivery
28504 process is started because \queue@_only\ is set or \-odq-\ was used.
28505 .nextp
28506 .index log||delivery duration
28507 \deliver@_time\: For each delivery, the amount of real time it has taken to
28508 perform the actual delivery is logged as DT=<<time>>, for example, \"DT=1s"\.
28509 .nextp
28510 .index log||message size on delivery
28511 .index size||of message
28512 \delivery@_size\: For each delivery, the size of message delivered is added to
28513 the `=>' line, tagged with S=.
28514 .nextp
28515 .index log||dnslist defer
28516 .index DNS list||logging defer
28517 .index black list (DNS)
28518 \dnslist@_defer\: A log entry is written if an attempt to look up a host in a
28519 DNS black list suffers a temporary error.
28520 .nextp
28521 .index log||ETRN commands
28522 .index \\ETRN\\||logging
28523 \etrn\: Every legal ETRN command that is received is logged, before the ACL is
28524 run to determine whether or not it is actually accepted. An invalid ETRN
28525 command, or one received within a message transaction is not logged by this
28526 selector (see \smtp@_syntax@_error\ and \smtp@_protocol@_error\).
28527 .nextp
28528 .index log||host lookup failure
28529 \host@_lookup@_failed\: When a lookup of a host's IP addresses fails to find
28530 any addresses, or when a lookup of an IP address fails to find a host name, a
28531 log line is written. This logging does not apply to direct DNS lookups when
28532 routing email addresses, but it does apply to `byname' lookups.
28533 .nextp
28534 .index log||ident timeout
28535 .index RFC 1413||logging timeout
28536 \ident@_timeout\: A log line is written whenever an attempt to connect to a
28537 client's ident port times out.
28538 .nextp
28539 .index log||incoming interface
28540 .index interface||logging
28541 \incoming@_interface\: The interface on which a message was received is added
28542 to the `<=' line as an IP address in square brackets, tagged by I= and followed
28543 by a colon and the port number.
28544 The local interface and port are also added to other SMTP log
28545 lines, for example `SMTP connection from', and to rejection lines.
28546 .nextp
28547 .index log||incoming remote port
28548 .index port||logging remote
28549 .index TCP/IP||logging incoming remote port
28550 \incoming@_port\: The remote port number from which a message was received is
28551 added to log entries and ::Received:: header lines, following the IP address in
28552 square brackets, and separated from it by a colon. This is implemented by
28553 changing the value that is put in the \$sender@_fullhost$\ and
28554 \$sender@_rcvhost$\ variables. Recording the remote port number has become more
28555 important with the widening use of NAT (see RFC 2505).
28556 .nextp
28557 .index log||dropped connection
28558 \lost@_incoming@_connection\: A log line is written when an incoming SMTP
28559 connection is unexpectedly dropped.
28560 .nextp
28561 .index log||outgoing remote port
28562 .index port||logging outgoint remote
28563 .index TCP/IP||logging ougtoing remote port
28564 \outgoing@_port\: The remote port number is added to delivery log lines (those
28565 containing => tags) following the IP address. This option is not included in
28566 the default setting, because for most ordinary configurations, the remote port
28567 number is always 25 (the SMTP port).
28568 .nextp
28569 .index log||queue run
28570 .index queue runner||logging
28571 \queue@_run\: The start and end of every queue run are logged.
28572 .nextp
28573 .index log||queue time
28574 \queue@_time\: The amount of time the message has been in the queue on the
28575 local host is logged as QT=<<time>>
28576 .em
28577 on delivery (\"=>"\) lines, for example, \"QT=3m45s"\. The clock starts when
28578 Exim starts to receive the message, so it includes reception time as well as
28579 the delivery time for the current address. This means that it may be longer
28580 than the difference between the arrival and delivery log line times, because
28581 the arrival log line is not written until the message has been successfully
28582 received.
28583 .nem
28584
28585 .nextp
28586 .em
28587 \queue@_time@_overall\: The amount of time the message has been in the queue on
28588 the local host is logged as QT=<<time>> on `Completed' lines, for
28589 example, \"QT=3m45s"\. The clock starts when Exim starts to receive the
28590 message, so it includes reception time as well as the total delivery time.
28591 .nem
28592 .nextp
28593 .index log||recipients
28594 \received@_recipients\: The recipients of a message are listed in the main log
28595 as soon as the message is received. The list appears at the end of the log line
28596 that is written when a message is received, preceded by the word `for'. The
28597 addresses are listed after they have been qualified, but before any rewriting
28598 has taken place.
28599 Recipients that were discarded by an ACL for \\MAIL\\ or \\RCPT\\ do not appear
28600 in the list.
28601 .nextp
28602 .index log||sender reception
28603 \received@_sender\: The unrewritten original sender of a message is added to
28604 the end of the log line that records the message's arrival, after the word
28605 `from' (before the recipients if \received@_recipients\ is also set).
28606 .nextp
28607 .index log||header lines for rejection
28608 \rejected@_header\: If a message's header has been received at the time a
28609 rejection is written to the reject log, the complete header is added to the
28610 log. Header logging can be turned off individually for messages that are
28611 rejected by the \*local@_scan()*\ function (see section ~~SECTapiforloc).
28612 .nextp
28613 .index log||retry defer
28614 \retry@_defer\: A log line is written if a delivery is deferred because a retry
28615 time has not yet been reached. However, this `retry time not reached' message
28616 is always omitted from individual message logs after the first delivery
28617 attempt.
28618 .nextp
28619 .index log||return path
28620 \return@_path@_on@_delivery\: The return path that is being transmitted with
28621 the message is included in delivery and bounce lines, using the tag P=.
28622 .em
28623 This is omitted if no delivery actually happens, for example, if routing fails, 
28624 or if delivery is to \(/dev/null)\ or to \":blackhole:"\.
28625 .nem
28626 .nextp
28627 .index log||sender on delivery
28628 \sender@_on@_delivery\: The message's sender address is added to every delivery
28629 and bounce line, tagged by F= (for `from').
28630 This is the original sender that was received with the message; it is not
28631 necessarily the same as the outgoing return path.
28632 .nextp
28633 .index log||size rejection
28634 \size@_reject\: A log line is written whenever a message is rejected because it
28635 is too big.
28636 .nextp
28637 .index log||frozen messages, skipped
28638 .index frozen messages||logging skipping
28639 \skip@_delivery\: A log line is written whenever a message is skipped during a
28640 queue run because it is frozen or because another process is already delivering
28641 it.
28642 .em
28643 .index `spool file is locked'
28644 The message that is written is `spool file is locked'.
28645 .nem
28646 .nextp
28647 .index log||smtp confirmation
28648 .index SMTP||logging confirmation
28649 \smtp@_confirmation\: The response to the final `.' in the SMTP dialogue for
28650 outgoing messages is added to delivery log lines in the form `C="<<text>>"'. A
28651 number of MTAs (including Exim) return an identifying string in this response.
28652 .nextp
28653 .index log||SMTP connections
28654 .index SMTP||logging connections
28655 \smtp@_connection\: A log line is written whenever an SMTP connection is
28656 established or closed,
28657 .em
28658 unless the connection is from a host that matches \hosts@_connection@_nolog\.
28659 .nem
28660 (In contrast, \lost__incoming__connection\ applies only when the closure is
28661 unexpected.) This applies to connections from local processes that use \-bs-\
28662 as well as to TCP/IP connections. If a connection is dropped in the middle of a
28663 message, a log line is always written, whether or not this selector is set, but
28664 otherwise nothing is written at the start and end of connections unless this
28665 selector is enabled.
28666
28667 For TCP/IP connections to an Exim daemon, the current number of connections is
28668 included in the log message for each new connection, but note that the count is
28669 reset if the daemon is restarted.
28670 Also, because connections are closed (and the closure is logged) in
28671 subprocesses, the count may not include connections that have been closed but
28672 whose termination the daemon has not yet noticed. Thus, while it is possible to
28673 match up the opening and closing of connections in the log, the value of the
28674 logged counts may not be entirely accurate.
28675 .nextp
28676 .index log||SMTP transaction, incomplete
28677 .index SMTP||logging incomplete transactions
28678 \smtp@_incomplete@_transaction\: When a mail transaction is aborted by
28679 \\RSET\\, \\QUIT\\, loss of connection, or otherwise, the incident is logged,
28680 and the message sender plus any accepted recipients are included in the log
28681 line. This can provide evidence of dictionary attacks.
28682 .nextp
28683 .index log||SMTP protocol error
28684 .index SMTP||logging protocol error
28685 \smtp@_protocol@_error\: A log line is written for every SMTP protocol error
28686 encountered.
28687 Exim does not have perfect detection of all protocol errors because of
28688 transmission delays and the use of pipelining. If \\PIPELINING\\ has been
28689 advertised to a client, an Exim server assumes that the client will use it, and
28690 therefore it does not count `expected' errors (for example, \\RCPT\\ received
28691 after rejecting \\MAIL\\) as protocol errors.
28692 .nextp
28693 .index SMTP||logging syntax errors
28694 .index SMTP||syntax errors, logging
28695 .index SMTP||unknown command, logging
28696 .index log||unknown SMTP command
28697 .index log||SMTP syntax error
28698 \smtp@_syntax@_error\: A log line is written for every SMTP syntax error
28699 encountered. An unrecognized command is treated as a syntax error. For an
28700 external connection, the host identity is given; for an internal connection
28701 using \-bs-\ the sender identification (normally the calling user) is given.
28702 .nextp
28703 .index log||subject
28704 .index subject, logging
28705 \subject\: The subject of the message is added to the arrival log line,
28706 preceded by `T=' (T for `topic', since S is already used for `size').
28707 Any MIME `words' in the subject are decoded. The \print@_topbitchars\ option
28708 specifies whether characters with values greater than 127 should be logged
28709 unchanged, or whether they should be rendered as escape sequences.
28710 .nextp
28711 .index log||certificate verification
28712 \tls@_certificate@_verified\: An extra item is added to <= and => log lines
28713 when TLS is in use. The item is \"CV=yes"\ if the peer's certificate was
28714 verified, and \"CV=no"\ if not.
28715 .nextp
28716 .index log||TLS cipher
28717 .index TLS||logging cipher
28718 \tls@_cipher\: When a message is sent or received over an encrypted connection,
28719 the cipher suite used is added to the log line, preceded by X=.
28720 .nextp
28721 .index log||TLS peer DN
28722 .index TLS||logging peer DN
28723 \tls@_peerdn\: When a message is sent or received over an encrypted connection,
28724 and a certificate is supplied by the remote host, the peer DN is added to the
28725 log line, preceded by DN=.
28726 .endp
28727
28728 .section Message log
28729 .index message||log file for
28730 .index log||message log, description of
28731 In addition to the general log files, Exim writes a log file for each message
28732 that it handles. The names of these per-message logs are the message ids, and
28733 .index \(msglog)\ directory
28734 they are kept in the \(msglog)\ sub-directory of the spool directory. Each
28735 message log contains copies of the log lines that apply to the message. This
28736 makes it easier to inspect the status of an individual message without having
28737 to search the main log. A message log is deleted when processing of the message
28738 is complete,
28739 .index \preserve@_message@_logs\
28740 unless \preserve__message__logs\ is set, but this should be used only with
28741 great care because they can fill up your disk very quickly.
28742
28743 On a heavily loaded system, it may be desirable to disable the use of
28744 per-message logs, in order to reduce disk I/O. This can be done by setting the
28745 \message@_logs\ option false.
28746
28747
28748
28749 .
28750 .
28751 .
28752 . ============================================================================
28753 .chapter Exim utilities
28754 .set runningfoot "utilities"
28755 .rset CHAPutils ~~chapter
28756 .index utilities
28757 A number of utility scripts and programs are supplied with Exim and are
28758 described in this chapter. There is also the Exim Monitor, which is covered in
28759 the next chapter. The utilities described here are:
28760
28761 . This duplication seems to be the only way to arrange that the cross-
28762 . references are omitted in the Texinfo version. They look horribly ugly.
28763
28764 .if ~~texinfo
28765 .display rm
28766 .tabs 22
28767 \*exiwhat*\           $t $rm{list what Exim processes are doing}
28768 .newline
28769 \*exiqgrep*\          $t $rm{grep the queue}
28770 .newline
28771 \*exiqsumm*\          $t $rm{summarize the queue}
28772 \*exigrep*\           $t $rm{search the main log}
28773 \*exipick*\           $t $rm{select messages on various criteria}
28774 \*exicyclog*\         $t $rm{cycle (rotate) log files}
28775 \*eximstats*\         $t $rm{extract statistics from the log}
28776 \*exim@_checkaccess*\ $t $rm{check address acceptance from given IP}
28777 \*exim@_dbmbuild*\    $t $rm{build a DBM file}
28778 \*exinext*\           $t $rm{extract retry information}
28779 \*exim@_dumpdb*\      $t $rm{dump a hints database}
28780 \*exim@_tidydb*\      $t $rm{clean up a hints database}
28781 \*exim@_fixdb*\       $t $rm{patch a hints database}
28782 \*exim@_lock*\        $t $rm{lock a mailbox file}
28783 .endd
28784 .
28785 .else
28786 .
28787 .display rm
28788 .tabs 22
28789 ~~SECTfinoutwha  \*exiwhat*\           $t $rm{list what Exim processes are doing}
28790 ~~SECTgreptheque  \*exiqgrep*\         $t $rm{grep the queue}
28791 ~~SECTsumtheque  \*exiqsumm*\          $t $rm{summarize the queue}
28792 ~~SECTextspeinf  \*exigrep*\           $t $rm{search the main log}
28793 ~~SECTexipick  \*exipick*\           $t $rm{select messages on various criteria}
28794 ~~SECTcyclogfil  \*exicyclog*\         $t $rm{cycle (rotate) log files}
28795 ~~SECTmailstat  \*eximstats*\         $t $rm{extract statistics from the log}
28796 ~~SECTcheckaccess  \*exim@_checkaccess*\ $t $rm{check address acceptance from given IP}
28797 ~~SECTdbmbuild  \*exim@_dbmbuild*\    $t $rm{build a DBM file}
28798 ~~SECTfinindret  \*exinext*\           $t $rm{extract retry information}
28799 ~~SECThindatmai  \*exim@_dumpdb*\      $t $rm{dump a hints database}
28800 ~~SECThindatmai  \*exim@_tidydb*\      $t $rm{clean up a hints database}
28801 ~~SECThindatmai  \*exim@_fixdb*\       $t $rm{patch a hints database}
28802 ~~SECTmailboxmaint  \*exim@_lock*\     $t $rm{lock a mailbox file}
28803 .endd
28804 .fi
28805
28806 .section Finding out what Exim processes are doing (exiwhat)
28807 .rset SECTfinoutwha "~~chapter.~~section"
28808 .index \*exiwhat*\
28809 .index process, querying
28810 .index \\SIGUSR1\\
28811 On operating systems that can restart a system call after receiving a signal
28812 (most modern OS), an Exim process responds to the \\SIGUSR1\\ signal by writing
28813 a line describing what it is doing to the file \(exim-process.info)\ in the
28814 Exim spool directory. The \*exiwhat*\ script sends the signal to all Exim
28815 processes it can find, having first emptied the file. It then waits for one
28816 second to allow the Exim processes to react before displaying the results. In
28817 order to run \*exiwhat*\ successfully you have to have sufficient privilege to
28818 send the signal to the Exim processes, so it is normally run as root.
28819
28820 .em
28821 \**Warning**\: This is not an efficient process. It is intended for occasional 
28822 use by system administrators. It is not sensible, for example, to set up a 
28823 script that sends \\SIGUSR1\\ signals to Exim processes at short intervals.
28824 .nem
28825
28826 Unfortunately, the \*ps*\ command that \*exiwhat*\ uses to find Exim processes
28827 varies in different operating systems. Not only are different options used,
28828 but the format of the output is different. For this reason, there are some
28829 system configuration options that configure exactly how \*exiwhat*\ works. If it
28830 doesn't seem to be working for you, check the following compile-time options:
28831 .display
28832 EXIWHAT@_PS@_CMD     $rm{the command for running \*ps*\}
28833 EXIWHAT@_PS@_ARG     $rm{the argument for \*ps*\}
28834 EXIWHAT@_EGREP@_ARG  $rm{the argument for \*egrep*\ to select from \*ps*\ output}
28835 EXIWHAT@_KILL@_ARG   $rm{the argument for the \*kill*\ command}
28836 .endd
28837 An example of typical output from \*exiwhat*\ is
28838 .display
28839 .indent 0
28840   164 daemon: -q1h, listening on port 25
28841 10483 running queue: waiting for 0tAycK-0002ij-00 (10492)
28842 10492 delivering 0tAycK-0002ij-00 to mail.ref.example [10.19.42.42]
28843   (editor@@ref.example)
28844 10592 handling incoming call from [192.168.243.242]
28845 10628 accepting a local non-SMTP message
28846 .endd
28847 The first number in the output line is the process number. The third line has
28848 been split here, in order to fit it on the page.
28849
28850
28851 .section Selective queue listing (exiqgrep)
28852 .rset SECTgreptheque "~~chapter.~~section"
28853 .index \*exiqgrep*\
28854 .index queue||grepping
28855 This utility is a Perl script contributed by Matt Hubbard. It runs
28856 .display asis
28857 exim -bpu
28858 .endd
28859 to obtain a queue listing with undelivered recipients only, and then greps the
28860 output to select messages that match given criteria. The following selection
28861 options are available:
28862
28863 .startoptions
28864
28865 .option f <<regex>>
28866 Match the sender address. The field that is tested is enclosed in angle
28867 brackets, so you can test for bounce messages with
28868 .display asis
28869 exiqgrep -f '^<>$'
28870 .endd
28871
28872 .option r <<regex>>
28873 Match a recipient address. The field that is tested is not enclosed in angle
28874 brackets.
28875
28876 .option s <<regex>>
28877 Match against the size field.
28878
28879 .option y <<seconds>>
28880 Match messages that are younger than the given time.
28881
28882 .option o <<seconds>>
28883 Match messages that are older than the given time.
28884
28885 .option z
28886 Match only frozen messages.
28887
28888 .option x
28889 Match only non-frozen messages.
28890
28891 .endoptions
28892
28893 The following options control the format of the output:
28894
28895 .startoptions
28896
28897 .option c
28898 Display only the count of matching messages.
28899
28900 .option l
28901 Long format -- display the full message information as output by Exim. This is
28902 the default.
28903
28904 .option i
28905 Display message ids only.
28906
28907 .option b
28908 Brief format -- one line per message.
28909
28910 .option R
28911 Display messages in reverse order.
28912
28913 .endoptions
28914
28915 There is one more option, \-h-\, which outputs a list of options.
28916
28917
28918 .section Summarising the queue (exiqsumm)
28919 .rset SECTsumtheque "~~chapter.~~section"
28920 .index \*exiqsumm*\
28921 .index queue||summary
28922 The \*exiqsumm*\ utility is a Perl script which reads the output of \*exim
28923 -bp*\ and produces a summary of the messages on the queue. Thus, you use it by
28924 running a command such as
28925 .display asis
28926 exim -bp | exiqsumm
28927 .endd
28928 The output consists of one line for each domain that has messages waiting for
28929 it, as in the following example:
28930 .display asis
28931   3   2322   74m   66m  msn.com.example
28932 .endd
28933 Each line lists the number of
28934 pending deliveries for a domain, their total volume, and the length of time
28935 that the oldest and the newest messages have been waiting. Note that the number
28936 of pending deliveries is greater than the number of messages when messages
28937 have more than one recipient.
28938
28939 A summary line is output at the end. By default the output is sorted on the
28940 domain name, but \*exiqsumm*\ has the options \-a-\ and \-c-\, which cause the
28941 output to be sorted by oldest message and by count of messages, respectively.
28942
28943 The output of \*exim -bp*\ contains the original addresses in the message, so
28944 this also applies to the output from \*exiqsumm*\. No domains from addresses
28945 generated by aliasing or forwarding are included (unless the \one@_time\ option
28946 of the \%redirect%\ router has been used to convert them into `top level'
28947 addresses).
28948
28949
28950
28951 .section Extracting specific information from the log (exigrep)
28952 .rset SECTextspeinf "~~chapter.~~section"
28953 .index \*exigrep*\
28954 .index log||extracts, grepping for
28955 The \*exigrep*\ utility is a Perl script that searches one or more main log
28956 files for entries that match a given pattern. When it finds a match, it
28957 extracts all the log entries for the relevant message, not just those that
28958 match the pattern. Thus, \*exigrep*\ can extract complete log entries for a
28959 given message, or all mail for a given user, or for a given host, for example.
28960
28961 If a matching log line is not associated with a specific message, it is always
28962 included in \*exigrep*\'s output.
28963 The usage is:
28964 .display asis
28965 exigrep [-l] [-t<n>] <pattern> [<log file>] ...
28966 .endd
28967 The \-t-\ argument specifies a number of seconds. It adds an additional
28968 condition for message selection. Messages that are complete are shown only if
28969 they spent more than <<n>> seconds on the queue.
28970
28971 The \-l-\ flag means `literal', that is, treat all characters in the
28972 pattern as standing for themselves. Otherwise the pattern must be a Perl
28973 regular expression. The pattern match is case-insensitive. If no file names are
28974 given on the command line, the standard input is read.
28975
28976 If the location of a \*zcat*\ command is known from the definition of
28977 \\ZCAT@_COMMAND\\ in \(Local/Makefile)\, \*exigrep*\ automatically passes any
28978 file whose name ends in \\COMPRESS@_SUFFIX\\ through \*zcat*\ as it searches
28979 it.
28980
28981 .section Selecting messages by various criteria (exipick)
28982 .rset SECTexipick "~~chapter.~~section"
28983 .index \*exipick*\
28984 John Jetmore's \*exipick*\ utility is included in the Exim distribution. It
28985 lists messages from the queue according to a variety of criteria. For details,
28986 run:
28987 .display asis
28988 exipick --help
28989 .endd
28990
28991
28992 .section Cycling log files (exicyclog)
28993 .rset SECTcyclogfil "~~chapter.~~section"
28994 .index log||cycling local files
28995 .index cycling logs
28996 .index \*exicyclog*\
28997 The \*exicyclog*\ script can be used to cycle (rotate) \*mainlog*\ and
28998 \*rejectlog*\ files. This is not necessary if only syslog is being used, or if
28999 you are using log files with datestamps in their names (see section
29000 ~~SECTdatlogfil). Some operating systems have their own standard mechanisms for
29001 log cycling, and these can be used instead of \*exicyclog*\ if preferred.
29002
29003 Each time \*exicyclog*\ is run the file names get `shuffled down' by one. If
29004 the main log file name is \(mainlog)\ (the default) then when \*exicyclog*\ is
29005 run \(mainlog)\ becomes \(mainlog.01)\, the previous \(mainlog.01)\ becomes
29006 \(mainlog.02)\ and so on, up to a limit which is set in the script, and which
29007 defaults to 10. 
29008 .em
29009 Log files whose numbers exceed the limit are discarded.
29010 .nem
29011 Reject logs are handled similarly.
29012
29013 .em
29014 If the limit is greater than 99, the script uses 3-digit numbers such as
29015 \(mainlog.001)\, \(mainlog.002)\, etc. If you change from a number less than 99
29016 to one that is greater, or \*vice versa*\, you will have to fix the names of
29017 any existing log files.
29018 .nem
29019
29020 If no \(mainlog)\ file exists, the script does nothing. Files that `drop off'
29021 the end are deleted. All files with numbers greater than 01 are compressed,
29022 using a compression command which is configured by the \\COMPRESS@_COMMAND\\
29023 setting in \(Local/Makefile)\. It is usual to run \*exicyclog*\ daily from a
29024 root \crontab\ entry of the form
29025 .display
29026 1 0 * * * su exim -c /usr/exim/bin/exicyclog
29027 .endd
29028 assuming you have used the name `exim' for the Exim user. You can run
29029 \*exicyclog*\ as root if you wish, but there is no need.
29030
29031
29032 .section Mail statistics (eximstats)
29033 .rset SECTmailstat "~~chapter.~~section"
29034 .index statistics
29035 .index \*eximstats*\
29036 A Perl script called \*eximstats*\ is provided for extracting statistical
29037 information from log files. The output is either plain text, or HTML.
29038 Exim log files are also suported by the \*Lire*\ system produced by the
29039 LogReport Foundation (\?http://www.logreport.org?\).
29040
29041 The \*eximstats*\ script has been hacked about quite a bit over time. The
29042 latest version is the result of some extensive revision by Steve Campbell. A
29043 lot of information is given by default, but there are options for suppressing
29044 various parts of it. Following any options, the arguments to the script are a
29045 list of files, which should be main log files. For example:
29046 .display asis
29047 eximstats -nr /var/spool/exim/log/mainlog.01
29048 .endd
29049 By default, \*eximstats*\ extracts information about the number and volume of
29050 messages received from or delivered to various hosts. The information is sorted
29051 both by message count and by volume, and the top fifty hosts in each category
29052 are listed on the standard output. Similar information, based on email
29053 addresses or domains instead of hosts can be requested by means of various
29054 options. For messages delivered and received locally, similar statistics are
29055 also produced per user.
29056
29057 The output also includes total counts and statistics about delivery errors, and
29058 histograms showing the number of messages received and deliveries made in each
29059 hour of the day. A delivery with more than one address in its envelope (for
29060 example, an SMTP transaction with more than one \\RCPT\\ command) is counted
29061 as a single delivery by \*eximstats*\.
29062
29063 Though normally more deliveries than receipts are reported (as messages may
29064 have multiple recipients), it is possible for \*eximstats*\ to report more
29065 messages received than delivered, even though the queue is empty at the start
29066 and end of the period in question. If an incoming message contains no valid
29067 recipients, no deliveries are recorded for it. A bounce message is handled as
29068 an entirely separate message.
29069
29070 \*eximstats*\ always outputs a grand total summary giving the volume and number
29071 of messages received and deliveries made, and the number of hosts involved in
29072 each case. It also outputs the number of messages that were delayed (that is,
29073 not completely delivered at the first attempt), and the number that had at
29074 least one address that failed.
29075
29076 The remainder of the output is in sections that can be independently disabled
29077 or modified by various options. It consists of a summary of deliveries by
29078 transport, histograms of messages received and delivered per time interval
29079 (default per hour), information about the time messages spent on the queue,
29080 a list of relayed messages, lists of the top fifty sending hosts, local
29081 senders, destination hosts, and destination local users by count and by volume,
29082 and a list of delivery errors that occurred.
29083
29084 The relay information lists messages that were actually relayed, that is, they
29085 came from a remote host and were directly delivered to some other remote host,
29086 without being processed (for example, for aliasing or forwarding) locally.
29087
29088 The options for \*eximstats*\ are as follows:
29089
29090 .startoptions
29091 .index \*eximstats*\||options
29092 .option bydomain
29093 The `league tables' are computed on the basis of the superior domains of the
29094 sending hosts instead of the sending and receiving hosts. This option may be
29095 combined with \-byhost-\ and/or \-byemail-\.
29096
29097 .option byedomain
29098 This is a synonym for \-byemaildomain-\.
29099
29100 .option byemail
29101 The `league tables' are computed on the basis of complete email addresses,
29102 instead of sending and receiving hosts. This option may be combined with
29103 \-byhost-\ and/or \-bydomain-\.
29104
29105 .option byemaildomain
29106 The `league tables' are computed on the basis of the sender's email domain
29107 instead of the sending and receiving hosts. This option may be combined with
29108 \-byhost-\, \-bydomain-\, or \-byemail-\.
29109
29110 .option byhost
29111 The `league tables' are computed on the basis of sending and receiving hosts.
29112 This is the default option. It may be combined with \-bydomain-\ and/or
29113 \-byemail-\.
29114
29115 .option cache
29116 Cache results of \*timegm()*\ lookups. This results in a significant speedup
29117 when processing hundreds of thousands of messages, at a cost of increasing the
29118 memory utilisation.
29119
29120 .option chartdir <<dir>>
29121 When \-charts-\ is specified, create the charts in the directory <<dir>>.
29122
29123 .option chartrel <<dir>>
29124 When \-charts-\ is specified, this option specifies the relative directory for
29125 the \"img src="\ tags from where to include the charts.
29126
29127 .option charts
29128 Create graphical charts to be displayed in HTML output. This requires the
29129 \"GD"\, \"GDTextUtil"\, and \"GDGraph"\ Perl modules, which can be obtained
29130 from \?http://www.cpan.org/modules/01modules.index.html?\.
29131
29132 To install these, download and unpack them, then use the normal Perl
29133 installation procedure:
29134 .display asis
29135 perl Makefile.PL
29136 make
29137 make test
29138 make install
29139 .endd
29140
29141 .option d
29142 This is a debug flag. It causes \*eximstats*\ to output the \*eval()*\'d parser
29143 to the standard output, which makes it easier to trap errors in the eval
29144 section. Remember to add one to the line numbers to allow for the title.
29145
29146
29147 .option help
29148 Show help information about \*eximstats*\' options.
29149
29150 .option h <<n>>
29151 This option controls the histograms of messages received and deliveries per
29152 time interval. By default the time interval is one hour. If \-h0-\ is given,
29153 the histograms are suppressed; otherwise the value of <<n>> gives the number of
29154 divisions per hour. Valid values are 0, 1, 2, 3, 5, 10, 15, 20, 30 or 60, so
29155 \-h2-\ sets an interval of 30 minutes, and the default is equivalent to \-h1-\.
29156
29157 .option html
29158 Output the results in HTML instead of plain text.
29159
29160 .option merge
29161 This option causes \*eximstats*\ to merge old reports into a combined report.
29162 When this option is used, the input files must be outputs from previous calls
29163 to \*eximstats*\, not raw log files. For example, you could produce a set of
29164 daily reports and a weekly report by commands such as
29165 .display asis
29166 eximstats mainlog.sun > report.sun.txt
29167 eximstats mainlog.mon > report.mon.txt
29168 eximstats mainlog.tue > report.tue.txt
29169 eximstats mainlog.wed > report.wed.txt
29170 eximstats mainlog.thu > report.thu.txt
29171 eximstats mainlog.fri > report.fri.txt
29172 eximstats mainlog.sat > report.sat.txt
29173 eximstats -merge -html report.*.txt > weekly_report.html
29174 .endd
29175 You can merge text or html reports and output the results as text or html. You
29176 can use all the normal \*eximstats*\ output options, but only data included in
29177 the original reports can be shown. When merging reports, some loss of accuracy
29178 may occur in the `league tables', towards the ends of the lists. The order of
29179 items in the `league tables' may vary when the data volumes round to the same
29180 value.
29181
29182 .option ne
29183 Suppress the display of information about failed deliveries (errors).
29184
29185 .option nr
29186 Suppress information about messages relayed through this host.
29187
29188 .option nr /pattern/
29189 Suppress information about relayed messages that match the pattern, which is
29190 matched against a string of the following form (split over two lines here in
29191 order to fit it on the page):
29192 .display asis
29193 H=<host> [<ip address>] A=<sender address> =>
29194   H=<host> A=<recipient address>
29195 .endd
29196 for example
29197 .display asis
29198 H=in.host [1.2.3.4] A=from@some.where.example =>
29199   H=out.host A=to@else.where.example
29200 .endd
29201 The sending host name appears in parentheses if it has not been verified as
29202 matching the IP address. The mail addresses are taken from the envelope, not
29203 the headers. This option allows you to screen out hosts whom you are happy to
29204 have using your host as a relay.
29205
29206 .option nt
29207 Suppress the statistics about delivery by transport.
29208
29209 .option nt/<<pattern>>/
29210 Suppress the statistics about delivery by any transport whose name matches the
29211 pattern. If you are using one transport to send all messages to a scanning
29212 mechanism before doing the real delivery, this feature can be used to omit that
29213 transport from your normal statistics (on the grounds that it is of no
29214 interest).
29215
29216
29217 .option "pattern" "#<<description>>#/<<pattern>>/"
29218 Count lines matching specified patterns and show them in
29219 the results. For example:
29220 .display asis
29221 -pattern 'Refused connections' '/refused connection/'
29222 .endd
29223 This option can be specified multiple times.
29224
29225 .option q0
29226 Suppress information about times messages spend on the queue.
29227
29228 .option q <<n1>>...
29229 This option sets an alternative list of time intervals for the queueing
29230 information. The values are separated by commas and are in seconds, but can
29231 involve arithmetic multipliers, so for example you can set 3$*$60 to specify 3
29232 minutes. A setting such as
29233 .display asis
29234 -q60,5*60,10*60
29235 .endd
29236 causes \*eximstats*\ to give counts of messages that stayed on the queue for less
29237 than one minute, less than five minutes, less than ten minutes, and over ten
29238 minutes.
29239
29240 .option t <<n>>
29241 Sets the `top' count to <<n>>. This controls the listings of the `top <<n>>'
29242 hosts and users by count and volume. The default is 50, and setting 0
29243 suppresses the output altogether.
29244
29245 .option tnl
29246 Omit local information from the `top' listings.
29247
29248 .option t@_remote@_users
29249 Include remote users in the `top' listings.
29250
29251 .endoptions
29252
29253
29254 .section Checking access policy (exim@_checkaccess)
29255 .rset SECTcheckaccess "~~chapter.~~section"
29256 .index \*exim@_checkaccess*\
29257 .index policy control||checking access
29258 .index checking access
29259 The \-bh-\ command line argument allows you to run a fake SMTP session with
29260 debugging output, in order to check what Exim is doing when it is applying
29261 policy controls to incoming SMTP mail. However, not everybody is sufficiently
29262 familiar with the SMTP protocol to be able to make full use of \-bh-\, and
29263 sometimes you just want to answer the question \*Does this address have
29264 access?*\ without bothering with any further details.
29265
29266 The \*exim@_checkaccess*\ utility is a `packaged' version of \-bh-\. It takes
29267 two arguments, an IP address and an email address:
29268 .display asis
29269 exim_checkaccess 10.9.8.7 A.User@a.domain.example
29270 .endd
29271 The utility runs a call to Exim with the \-bh-\ option, to test whether the
29272 given email address would be accepted in a \\RCPT\\ command in a TCP/IP
29273 connection from the host with the given IP address. The output of the utility
29274 is either the word `accepted', or the SMTP error response, for example:
29275 .display asis
29276 Rejected:
29277   550 Relay not permitted
29278 .endd
29279 When running this test, the utility uses \"<>"\ as the envelope sender address
29280 for the \\MAIL\\ command, but you can change this by providing additional
29281 options. These are passed directly to the Exim command. For example, to specify
29282 that the test is to be run with the sender address \*himself@@there.example*\
29283 you can use:
29284 .display asis
29285 exim_checkaccess 10.9.8.7 A.User@a.domain.example \
29286                  -f himself@there.example
29287 .endd
29288 Note that these additional Exim command line items must be given after the two
29289 mandatory arguments.
29290
29291 Because the \exim@_checkaccess\ uses \-bh-\, it does not perform callouts while
29292 running its checks. You can run checks that include callouts by using \-bhc-\,
29293 but this is not yet available in a `packaged' form.
29294
29295
29296 .section Making DBM files (exim@_dbmbuild)
29297 .rset SECTdbmbuild "~~chapter.~~section"
29298 .index DBM||building dbm files
29299 .index building DBM files
29300 .index \*exim@_dbmbuild*\
29301 .index lower casing
29302 .index binary zero||in lookup key
29303 The \*exim@_dbmbuild*\ program reads an input file containing keys and data in
29304 the format used by the \%lsearch%\ lookup (see section ~~SECTsinglekeylookups).
29305 It writes a DBM file using the lower-cased alias names as keys and the
29306 remainder of the information as data. The lower-casing can be prevented by
29307 calling the program with the \-nolc-\ option.
29308
29309 A terminating zero is included as part of the key string. This is expected by
29310 the \%dbm%\ lookup type. However, if the option \-nozero-\ is given,
29311 \*exim@_dbmbuild*\ creates files without terminating zeroes in either the key
29312 strings or the data strings. The \%dbmnz%\ lookup type can be used with such
29313 files.
29314
29315 The program requires two arguments: the name of the input file (which can be a
29316 single hyphen to indicate the standard input), and the name of the output file.
29317 It creates the output under a temporary name, and then renames it if all went
29318 well.
29319 .index \\USE@_DB\\
29320 If the native DB interface is in use (\\USE@_DB\\ is set in a compile-time
29321 configuration file -- this is common in free versions of Unix) the two file
29322 names must be different, because in this mode the Berkeley DB functions create
29323 a single output file using exactly the name given. For example,
29324 .display asis
29325 exim_dbmbuild /etc/aliases /etc/aliases.db
29326 .endd
29327 reads the system alias file and creates a DBM version of it in
29328 \(/etc/aliases.db)\.
29329
29330 In systems that use the \*ndbm*\ routines (mostly proprietary versions of Unix),
29331 two files are used, with the suffixes \(.dir)\ and \(.pag)\. In this
29332 environment, the suffixes are added to the second argument of
29333 \*exim@_dbmbuild*\, so it can be the same as the first. This is also the case
29334 when the Berkeley functions are used in compatibility mode (though this is not
29335 recommended), because in that case it adds a \(.db)\ suffix to the file name.
29336
29337 If a duplicate key is encountered, the program outputs a warning, and when it
29338 finishes, its return code is 1 rather than zero, unless the \-noduperr-\ option
29339 is used. By default, only the first of a set of duplicates is used -- this
29340 makes it compatible with \%lsearch%\ lookups. There is an option \-lastdup-\
29341 which causes it to use the data for the last duplicate instead. There is also
29342 an option \-nowarn-\, which stops it listing duplicate keys to \stderr\. For
29343 other errors, where it doesn't actually make a new file, the return code is 2.
29344
29345
29346
29347 .section Finding individual retry times (exinext)
29348 .rset SECTfinindret "~~chapter.~~section"
29349 .index retry||times
29350 .index \*exinext*\
29351 A utility called \*exinext*\ (mostly a Perl script) provides the ability to fish
29352 specific information out of the retry database. Given a mail domain (or a
29353 complete address), it looks up the hosts for that domain, and outputs any retry
29354 information for the hosts or for the domain. At present, the retry information
29355 is obtained by running \*exim@_dumpdb*\ (see below) and post-processing the
29356 output. For example:
29357 .display asis
29358 $ exinext piglet@milne.fict.example
29359 kanga.milne.fict.example:192.168.8.1 error 146: Connection refused
29360   first failed: 21-Feb-1996 14:57:34
29361   last tried:   21-Feb-1996 14:57:34
29362   next try at:  21-Feb-1996 15:02:34
29363 roo.milne.fict.example:192.168.8.3 error 146: Connection refused
29364   first failed: 20-Jan-1996 13:12:08
29365   last tried:   21-Feb-1996 11:42:03
29366   next try at:  21-Feb-1996 19:42:03
29367   past final cutoff time
29368 .endd
29369 You can also give \*exinext*\ a local part, without a domain, and it
29370 will give any retry information for that local part in your default domain.
29371 A message id can be used to obtain retry information pertaining to a specific
29372 message. This exists only when an attempt to deliver a message to a remote host
29373 suffers a message-specific error (see section ~~SECToutSMTPerr). \*exinext*\ is
29374 not particularly efficient, but then it isn't expected to be run very often.
29375
29376 The \*exinext*\ utility calls Exim to find out information such as the location
29377 of the spool directory. The utility has \-C-\ and \-D-\ options, which are
29378 passed on to the \*exim*\ commands. The first specifies an alternate Exim
29379 configuration file, and the second sets macros for use within the configuration
29380 file. These features are mainly to help in testing, but might also be useful in
29381 environments where more than one configuration file is in use.
29382
29383
29384
29385 .section Hints database maintenance (exim@_dumpdb, exim@_fixdb, exim@_tidydb)
29386 .rset SECThindatmai "~~chapter.~~section"
29387 .index hints database||maintenance
29388 .index maintaining Exim's hints database
29389 Three utility programs are provided for maintaining the DBM files that Exim
29390 uses to contain its delivery hint information. Each program requires two
29391 arguments. The first specifies the name of Exim's spool directory, and the
29392 second is the name of the database it is to operate on. These are as
29393 follows:
29394 .numberpars $.
29395 \*retry*\: the database of retry information
29396 .nextp
29397 \*wait-*\<<transport name>>: databases of information about messages waiting
29398 for remote hosts
29399 .nextp
29400 \*callout*\: the callout cache
29401 .nextp
29402 \*misc*\: other hints data
29403 .endp
29404 The \*misc*\ database is used for
29405 .numberpars alpha
29406 Serializing \\ETRN\\ runs (when \smtp@_etrn@_serialize\ is set)
29407 .nextp
29408 Serializing delivery to a specific host (when \serialize@_hosts\ is set in an
29409 \%smtp%\ transport)
29410 .endp
29411
29412 .section exim@_dumpdb
29413 .index \*exim@_dumpdb*\
29414 The entire contents of a database are written to the standard output by the
29415 \*exim@_dumpdb*\ program, which has no options or arguments other than the
29416 spool and database names. For example, to dump the retry database:
29417 .display asis
29418 exim_dumpdb /var/spool/exim retry
29419 .endd
29420 Two lines of output are produced for each entry:
29421 .display
29422   T:mail.ref.example:192.168.242.242 146 77 Connection refused
29423 31-Oct-1995 12:00:12  02-Nov-1995 12:21:39  02-Nov-1995 20:21:39 *
29424 .endd
29425 The first item on the first line is the key of the record. It starts with one
29426 of the letters R, or T, depending on whether it refers to a routing or
29427 transport retry. For a local delivery, the next part is the local address; for
29428 a remote delivery it is the name of the remote host, followed by its failing IP
29429 address (unless \no@_retry@_include@_ip@_address\ is set on the \%smtp%\
29430 transport). If the remote port is not the standard one (port 25), it is added
29431 to the IP address. Then there follows an error code, an additional error code,
29432 and a textual description of the error.
29433
29434 The three times on the second line are the time of first failure, the time of
29435 the last delivery attempt, and the computed time for the next attempt. The line
29436 ends with an asterisk if the cutoff time for the last retry rule has been
29437 exceeded.
29438
29439 Each output line from \*exim@_dumpdb*\ for the \*wait-*\$it{xxx} databases
29440 consists of a host name followed by a list of ids for messages that are or were
29441 waiting to be delivered to that host. If there are a very large number for any
29442 one host, continuation records, with a sequence number added to the host name,
29443 may be seen. The data in these records is often out of date, because a message
29444 may be routed to several alternative hosts, and Exim makes no effort to keep
29445 cross-references.
29446
29447
29448 .section exim@_tidydb
29449 .index \*exim@_tidydb*\
29450 The \*exim@_tidydb*\ utility program is used to tidy up the contents of the
29451 hints databases. If run with no options, it removes all records from a database
29452 that are more than 30 days old. The cutoff date can be altered by means of the
29453 \-t-\ option, which must be followed by a time. For example, to remove all
29454 records older than a week from the retry database:
29455 .display asis
29456 exim_tidydb -t 7d /var/spool/exim retry
29457 .endd
29458 Both the \*wait-*\$it{xxx} and \*retry*\ databases contain items that involve
29459 message ids. In the former these appear as data in records keyed by host --
29460 they were messages that were waiting for that host -- and in the latter they
29461 are the keys for retry information for messages that have suffered certain
29462 types of error. When \*exim@_tidydb*\ is run, a check is made to ensure that
29463 message ids in database records are those of messages that are still on the
29464 queue. Message ids for messages that no longer exist are removed from
29465 \*wait-*\$it{xxx} records, and if this leaves any records empty, they are
29466 deleted. For the \*retry*\ database, records whose keys are non-existent
29467 message ids are removed. The \*exim@_tidydb*\ utility outputs comments on the
29468 standard output whenever it removes information from the database.
29469
29470 .em
29471 Certain records are automatically removed by Exim when they are no longer 
29472 needed, but others are not. For example, if all the MX hosts for a domain are 
29473 down, a retry record is created for each one. If the primary MX host comes back
29474 first, its record is removed when Exim successfully delivers to it, but the 
29475 records for the others remain because Exim has not tried to use those hosts.
29476
29477 It is important, therefore, to run \*exim@_tidydb*\ periodically on all the
29478 hints databases. You should do this at a quiet time of day, because it requires
29479 a database to be locked (and therefore inaccessible to Exim) while it does its
29480 work. Removing records from a DBM file does not normally make the file smaller,
29481 but all the common DBM libraries are able to re-use the space that is released.
29482 After an initial phase of increasing in size, the databases normally reach a 
29483 point at which they no longer get any bigger, as long as they are regularly 
29484 tidied.
29485
29486 \**Warning**\: If you never run \*exim@_tidydb*\, the space used by the hints 
29487 databases is likely to keep on increasing.
29488 .nem
29489
29490
29491 .section exim@_fixdb
29492 .index \*exim@_fixdb*\
29493 The \*exim@_fixdb*\ program is a utility for interactively modifying databases.
29494 Its main use is for testing Exim, but it might also be occasionally useful for
29495 getting round problems in a live system. It has no options, and its interface
29496 is somewhat crude. On entry, it prompts for input with a right angle-bracket. A
29497 key of a database record can then be entered, and the data for that record is
29498 displayed.
29499
29500 If `d' is typed at the next prompt, the entire record is deleted. For all
29501 except the \*retry*\ database, that is the only operation that can be carried
29502 out. For the \*retry*\ database, each field is output preceded by a number, and
29503 data for individual fields can be changed by typing the field number followed
29504 by new data, for example:
29505 .display asis
29506 > 4 951102:1000
29507 .endd
29508 resets the time of the next delivery attempt. Time values are given as a
29509 sequence of digit pairs for year, month, day, hour, and minute. Colons can be
29510 used as optional separators.
29511
29512
29513
29514 .section Mailbox maintenance (exim@_lock)
29515 .rset SECTmailboxmaint "~~chapter.~~section"
29516 .index mailbox||maintenance
29517 .index \*exim@_lock*\
29518 .index locking mailboxes
29519 The \*exim@_lock*\ utility locks a mailbox file using the same algorithm as
29520 Exim. For a discussion of locking issues, see section ~~SECTopappend.
29521 \*Exim@_lock*\ can be used to prevent any modification of a mailbox by Exim or
29522 a user agent while investigating a problem. The utility requires the name of
29523 the file as its first argument. If the locking is successful, the second
29524 argument is run as a command (using C's \*system()*\ function); if there is no
29525 second argument, the value of the SHELL environment variable is used; if this
29526 is unset or empty, \(/bin/sh)\ is run. When the command finishes, the mailbox
29527 is unlocked and the utility ends. The following options are available:
29528
29529 .startoptions
29530
29531 .option fcntl
29532 Use \*fcntl()*\ locking on the open mailbox.
29533
29534 .option flock
29535 Use \*flock()*\ locking on the open mailbox, provided the operating system
29536 supports it.
29537
29538 .option interval
29539 This must be followed by a number, which is a number of seconds; it sets the
29540 interval to sleep between retries (default 3).
29541
29542 .option lockfile
29543 Create a lock file before opening the mailbox.
29544
29545 .option mbx
29546 Lock the mailbox using MBX rules.
29547
29548 .option q
29549 Suppress verification output.
29550
29551 .option retries
29552 This must be followed by a number; it sets the number of times to try to get
29553 the lock (default 10).
29554
29555 .option restore@_time
29556 This option causes \exim@_lock\ to restore the modified and read times to the
29557 locked file before exiting. This allows you to access a locked mailbox (for
29558 example, to take a backup copy) without disturbing the times that the user
29559 subsequently sees.
29560
29561 .option timeout
29562 This must be followed by a number, which is a number of seconds; it sets a
29563 timeout to be used with a blocking \*fcntl()*\ lock. If it is not set (the
29564 default), a non-blocking call is used.
29565
29566 .option v
29567 Generate verbose output.
29568
29569 .endoptions
29570
29571 If none of \-fcntl-\,
29572 \-flock-\,
29573 \-lockfile-\ or \-mbx-\ are given, the default is to create a lock file and
29574 also to use \*fcntl()*\ locking on the mailbox, which is the same as Exim's
29575 default. The use of
29576 \-flock-\
29577 or \-fcntl-\ requires that the file be writeable; the use of
29578 \-lockfile-\ requires that the directory containing the file be writeable.
29579 Locking by lock file does not last for ever; Exim assumes that a lock file is
29580 expired if it is more than 30 minutes old.
29581
29582 The \-mbx-\ option can be used with either or both of \-fcntl-\ or \-flock-\.
29583 It assumes \-fcntl-\ by default.
29584 MBX locking causes a shared lock to be taken out on the open mailbox, and an
29585 exclusive lock on the file \(/tmp/.$it{n}.$it{m})\ where $it{n} and $it{m} are
29586 the device number and inode number of the mailbox file. When the locking is
29587 released, if an exclusive lock can be obtained for the mailbox, the file in
29588 \(/tmp)\ is deleted.
29589
29590 The default output contains verification of the locking that takes place. The
29591 \-v-\ option causes some additional information to be given. The \-q-\ option
29592 suppresses all output except error messages.
29593
29594 A command such as
29595 .display asis
29596 exim_lock /var/spool/mail/spqr
29597 .endd
29598 runs an interactive shell while the file is locked, whereas
29599 .display
29600 exim@_lock -q /var/spool/mail/spqr @<@<End
29601 <<some commands>>
29602 End
29603 .endd
29604 runs a specific non-interactive sequence of commands while the file is locked,
29605 suppressing all verification output. A single command can be run by a command
29606 such as
29607 .display asis
29608 exim_lock -q /var/spool/mail/spqr \
29609   "cp /var/spool/mail/spqr /some/where"
29610 .endd
29611 Note that if a command is supplied, it must be entirely contained within the
29612 second argument -- hence the quotes.
29613
29614
29615
29616 .
29617 .
29618 .
29619 .
29620 . ============================================================================
29621 .chapter The Exim monitor
29622 .set runningfoot "monitor"
29623 .rset CHAPeximon ~~chapter
29624 .index monitor
29625 .index Exim monitor
29626 .index X-windows
29627 .index \*eximon*\
29628 .index Local/eximon.conf
29629 .index \(exim@_monitor/EDITME)\
29630 The Exim monitor is an application which displays in an X window information
29631 about the state of Exim's queue and what Exim is doing. An admin user can
29632 perform certain operations on messages from this GUI interface; however all
29633 such facilities are also available from the command line, and indeed, the
29634 monitor itself makes use of the command line to perform any actions requested.
29635
29636
29637 .section Running the monitor
29638 The monitor is started by running the script called \*eximon*\. This is a shell
29639 script that sets up a number of environment variables, and then runs the
29640 binary called \(eximon.bin)\. The default appearance of the monitor window can
29641 be changed by editing the \(Local/eximon.conf)\ file created by editing
29642 \(exim@_monitor/EDITME)\. Comments in that file describe what the various
29643 parameters are for.
29644
29645 The parameters that get built into the \*eximon*\ script can be overridden for a
29646 particular invocation by setting up environment variables of the same names,
29647 preceded by `$tt{EXIMON@_}'. For example, a shell command such as
29648 .display asis
29649 EXIMON_LOG_DEPTH=400 eximon
29650 .endd
29651 (in a Bourne-compatible shell) runs \*eximon*\ with an overriding setting of the
29652 \\LOG@_DEPTH\\ parameter. If \\EXIMON@_LOG@_FILE@_PATH\\ is set in the
29653 environment, it overrides the Exim log file configuration. This makes it
29654 possible to have \*eximon*\ tailing log data that is written to syslog, provided
29655 that MAIL.INFO syslog messages are routed to a file on the local host.
29656
29657 X resources can be used to change the appearance of the window in the normal
29658 way. For example, a resource setting of the form
29659 .display asis
29660 Eximon*background: gray94
29661 .endd
29662 changes the colour of the background to light grey rather than white. The
29663 stripcharts are drawn with both the data lines and the reference lines in
29664 black. This means that the reference lines are not visible when on top of the
29665 data. However, their colour can be changed by setting a resource called
29666 `highlight' (an odd name, but that's what the Athena stripchart widget uses).
29667 For example, if your X server is running Unix, you could set up lighter
29668 reference lines in the stripcharts by obeying
29669 .display asis
29670 xrdb -merge <<End
29671 Eximon*highlight: gray
29672 End
29673 .endd
29674
29675 .index admin user
29676 In order to see the contents of messages on the queue, and to operate on them,
29677 \*eximon*\ must either be run as root or by an admin user.
29678
29679 The monitor's window is divided into three parts. The first contains one or
29680 more stripcharts and two action buttons, the second contains a `tail' of the
29681 main log file, and the third is a display of the queue of messages awaiting
29682 delivery, with two more action buttons. The following sections describe these
29683 different parts of the display.
29684
29685
29686
29687 .section The stripcharts
29688 .index stripchart
29689 The first stripchart is always a count of messages on the queue. Its name can
29690 be configured by setting \\QUEUE@_STRIPCHART@_NAME\\ in the
29691 \(Local/eximon.conf)\ file. The remaining stripcharts are defined in the
29692 configuration script by regular expression matches on log file entries, making
29693 it possible to display, for example, counts of messages delivered to certain
29694 hosts or using certain transports. The supplied defaults display counts of
29695 received and delivered messages, and of local and SMTP deliveries. The default
29696 period between stripchart updates is one minute; this can be adjusted by a
29697 parameter in the \(Local/eximon.conf)\ file.
29698
29699 The stripchart displays rescale themselves automatically as the value they are
29700 displaying changes. There are always 10 horizontal lines in each chart; the
29701 title string indicates the value of each division when it is greater than one.
29702 For example, `x2' means that each division represents a value of 2.
29703
29704 It is also possible to have a stripchart which shows the percentage fullness of
29705 a particular disk partition, which is useful when local deliveries are confined
29706 to a single partition.
29707 .index \statvfs\ function
29708 This relies on the availability of the \*statvfs()*\ function or equivalent in
29709 the operating system. Most, but not all versions of Unix that support Exim have
29710 this. For this particular stripchart, the top of the chart always represents
29711 100%, and the scale is given as `x10%'. This chart is configured by setting
29712 \\SIZE@_STRIPCHART\\ and (optionally) \\SIZE@_STRIPCHART@_NAME\\ in the
29713 \(Local/eximon.conf)\ file.
29714
29715
29716
29717 .section Main action buttons
29718 .index size||of monitor window
29719 .index monitor window size
29720 .index window size
29721 Below the stripcharts there is an action button for quitting the monitor. Next
29722 to this is another button marked `Size'. They are placed here so that shrinking
29723 the window to its default minimum size leaves just the queue count stripchart
29724 and these two buttons visible. Pressing the `Size' button causes the window to
29725 expand to its maximum size, unless it is already at the maximum, in which case
29726 it is reduced to its minimum.
29727
29728 When expanding to the maximum, if the window cannot be fully seen where it
29729 currently is, it is moved back to where it was the last time it was at full
29730 size. When it is expanding from its minimum size, the old position is
29731 remembered, and next time it is reduced to the minimum it is moved back there.
29732
29733 The idea is that you can keep a reduced window just showing one or two
29734 stripcharts at a convenient place on your screen, easily expand it to show
29735 the full window when required, and just as easily put it back to what it was.
29736 The idea is copied from what the \*twm*\ window manager does for its
29737 \*f.fullzoom*\ action. The minimum size of the window can be changed by setting
29738 the \\MIN@_HEIGHT\\ and \\MIN@_WIDTH\\ values in \(Local/eximon.conf)\.
29739
29740 Normally, the monitor starts up with the window at its full size, but it can be
29741 built so that it starts up with the window at its smallest size, by setting
29742 \\START@_SMALL\\=yes in \(Local/eximon.conf)\.
29743
29744
29745 .section The log display
29746 .index log||tail of, in monitor
29747 The second section of the window is an area in which a display of the tail of
29748 the main log is maintained.
29749 To save space on the screen, the timestamp on each log line is shortened by
29750 removing the date and, if \log@_timezone\ is set, the timezone.
29751 The log tail is not available when the only destination for logging data is
29752 syslog, unless the syslog lines are routed to a local file whose name is passed
29753 to \*eximon*\ via the \\EXIMON@_LOG@_FILE@_PATH\\ environment variable.
29754
29755 The log sub-window has a scroll bar at its lefthand side which can be used to
29756 move back to look at earlier text, and the up and down arrow keys also have a
29757 scrolling effect. The amount of log that is kept depends on the setting of
29758 \\LOG@_BUFFER\\ in \(Local/eximon.conf)\, which specifies the amount of memory
29759 to use. When this is full, the earlier 50% of data is discarded -- this is much
29760 more efficient than throwing it away line by line. The sub-window also has a
29761 horizontal scroll bar for accessing the ends of long log lines. This is the
29762 only means of horizontal scrolling; the right and left arrow keys are not
29763 available. Text can be cut from this part of the window using the mouse in the
29764 normal way. The size of this subwindow is controlled by parameters in the
29765 configuration file \(Local/eximon.conf)\.
29766
29767 Searches of the text in the log window can be carried out by means of the ^R
29768 and ^S keystrokes, which default to a reverse and a forward search,
29769 respectively. The search covers only the text that is displayed in the window.
29770 It cannot go further back up the log.
29771
29772 The point from which the search starts is indicated by a caret marker. This is
29773 normally at the end of the text in the window, but can be positioned explicitly
29774 by pointing and clicking with the left mouse button, and is moved automatically
29775 by a successful search. If new text arrives in the window when it is scrolled
29776 back, the caret remains where it is, but if the window is not scrolled back,
29777 the caret is moved to the end of the new text.
29778
29779 Pressing ^R or ^S pops up a window into which the search text can be typed.
29780 There are buttons for selecting forward or reverse searching, for carrying out
29781 the search, and for cancelling. If the `Search' button is pressed, the search
29782 happens and the window remains so that further searches can be done. If the
29783 `Return' key is pressed, a single search is done and the window is closed. If
29784 ^C is typed the search is cancelled.
29785
29786 The searching facility is implemented using the facilities of the Athena text
29787 widget. By default this pops up a window containing both `search' and `replace'
29788 options. In order to suppress the unwanted `replace' portion for eximon, a
29789 modified version of the \TextPop\ widget is distributed with Exim. However, the
29790 linkers in BSDI and HP-UX seem unable to handle an externally provided version
29791 of \TextPop\ when the remaining parts of the text widget come from the standard
29792 libraries. The compile-time option \\EXIMON@_TEXTPOP\\ can be unset to cut out
29793 the modified \TextPop\, making it possible to build Eximon on these systems, at
29794 the expense of having unwanted items in the search popup window.
29795
29796
29797 .section The queue display
29798 .index queue||display in monitor
29799 The bottom section of the monitor window contains a list of all messages that
29800 are on the queue, which includes those currently being received or delivered,
29801 as well as those awaiting delivery. The size of this subwindow is controlled by
29802 parameters in the configuration file \(Local/eximon.conf)\, and the frequency
29803 at which it is updated is controlled by another parameter in the same file --
29804 the default is 5 minutes, since queue scans can be quite expensive. However,
29805 there is an `Update' action button just above the display which can be used to
29806 force an update of the queue display at any time.
29807
29808 When a host is down for some time, a lot of pending mail can build up for it,
29809 and this can make it hard to deal with other messages on the queue. To help
29810 with this situation there is a button next to `Update' called `Hide'. If
29811 pressed, a dialogue box called `Hide addresses ending with' is put up. If you
29812 type anything in here and press `Return', the text is added to a chain of such
29813 texts, and if every undelivered address in a message matches at least one
29814 of the texts, the message is not displayed.
29815
29816 If there is an address that does not match any of the texts, all the addresses
29817 are displayed as normal. The matching happens on the ends of addresses so, for
29818 example, \*cam.ac.uk*\ specifies all addresses in Cambridge, while
29819 \*xxx@@foo.com.example*\ specifies just one specific address. When any hiding
29820 has been set up, a button called `Unhide' is displayed. If pressed, it cancels
29821 all hiding. Also, to ensure that hidden messages do not get forgotten, a hide
29822 request is automatically cancelled after one hour.
29823
29824 While the dialogue box is displayed, you can't press any buttons or do anything
29825 else to the monitor window. For this reason, if you want to cut text from the
29826 queue display to use in the dialogue box, you have to do the cutting before
29827 pressing the `Hide' button.
29828
29829 The queue display contains, for each unhidden queued message, the length of
29830 time it has been on the queue, the size of the message, the message id, the
29831 message sender, and the first undelivered recipient, all on one line. If it is
29832 a bounce message, the sender is shown as `<>'. If there is more than one
29833 recipient to which the message has not yet been delivered, subsequent ones are
29834 listed on additional lines, up to a maximum configured number, following which
29835 an ellipsis is displayed. Recipients that have already received the message are
29836 not shown.
29837 .index frozen messages||display
29838 If a message is frozen, an asterisk is displayed at the left-hand side.
29839
29840 The queue display has a vertical scroll bar, and can also be scrolled by means
29841 of the arrow keys. Text can be cut from it using the mouse in the normal way.
29842 The text searching facilities, as described above for the log window, are also
29843 available, but the caret is always moved to the end of the text when the queue
29844 display is updated.
29845
29846
29847 .section The queue menu
29848 .index queue||menu in monitor
29849 If the \shift\ key is held down and the left button is clicked when the mouse
29850 pointer is over the text for any message, an action menu pops up, and the first
29851 line of the queue display for the message is highlighted. This does not affect
29852 any selected text.
29853
29854 If you want to use some other event for popping up the menu, you can set the
29855 \\MENU@_EVENT\\ parameter in \(Local/eximon.conf)\ to change the default, or
29856 set \\EXIMON@_MENU@_EVENT\\ in the environment before starting the monitor. The
29857 value set in this parameter is a standard X event description. For example, to
29858 run eximon using \ctrl\ rather than \shift\ you could use
29859 .display asis
29860 EXIMON_MENU_EVENT='Ctrl<Btn1Down>' eximon
29861 .endd
29862 The title of the menu is the message id, and it contains entries which act as
29863 follows:
29864 .numberpars $.
29865 \*message log*\: The contents of the message log for the message are displayed in
29866 a new text window.
29867 .nextp
29868 \*headers*\: Information from the spool file that contains the envelope
29869 information and headers is displayed in a new text window. See chapter
29870 ~~CHAPspool for a description of the format of spool files.
29871 .nextp
29872 \*body*\: The contents of the spool file containing the body of the message are
29873 displayed in a new text window. There is a default limit of 20,000 bytes to the
29874 amount of data displayed. This can be changed by setting the \\BODY@_MAX\\
29875 option at compile time, or the \\EXIMON@_BODY@_MAX\\ option at run time.
29876 .nextp
29877 \*deliver message*\: A call to Exim is made using the \-M-\ option to request
29878 delivery of the message. This causes an automatic thaw if the message is
29879 frozen. The \-v-\ option is also set, and the output from Exim is displayed in
29880 a new text window. The delivery is run in a separate process, to avoid holding
29881 up the monitor while the delivery proceeds.
29882 .nextp
29883 \*freeze message*\: A call to Exim is made using the \-Mf-\ option to request
29884 that the message be frozen.
29885 .nextp
29886 .index thawing messages
29887 .index unfreezing messages
29888 .index frozen messages||thawing
29889 \*thaw message*\: A call to Exim is made using the \-Mt-\ option to request that
29890 the message be thawed.
29891 .nextp
29892 .index delivery||forcing failure
29893 \*give up on msg*\: A call to Exim is made using the \-Mg-\ option to request
29894 that Exim gives up trying to deliver the message. A bounce message is generated
29895 for any remaining undelivered addresses.
29896 .nextp
29897 \*remove message*\: A call to Exim is made using the \-Mrm-\ option to request
29898 that the message be deleted from the system without generating a bounce
29899 message.
29900 .nextp
29901 \*add recipient*\: A dialog box is displayed into which a recipient address can
29902 be typed. If the address is not qualified and the \\QUALIFY@_DOMAIN\\ parameter
29903 is set in \(Local/eximon.conf)\, the address is qualified with that domain.
29904 Otherwise it must be entered as a fully qualified address. Pressing \\RETURN\\
29905 causes a call to Exim to be made using the \-Mar-\ option to request that an
29906 additional recipient be added to the message, unless the entry box is empty, in
29907 which case no action is taken.
29908 .nextp
29909 \*mark delivered*\: A dialog box is displayed into which a recipient address can
29910 be typed. If the address is not qualified and the \\QUALIFY@_DOMAIN\\ parameter
29911 is set in \(Local/eximon.conf)\, the address is qualified with that domain.
29912 Otherwise it must be entered as a fully qualified address. Pressing \\RETURN\\
29913 causes a call to Exim to be made using the \-Mmd-\ option to mark the given
29914 recipient address as already delivered, unless the entry box is empty, in which
29915 case no action is taken.
29916 .nextp
29917 \*mark all delivered*\: A call to Exim is made using the \-Mmad-\ option to mark
29918 all recipient addresses as already delivered.
29919 .nextp
29920 \*edit sender*\: A dialog box is displayed initialized with the current sender's
29921 address. Pressing \\RETURN\\ causes a call to Exim to be made using the \-Mes-\
29922 option to replace the sender address, unless the entry box is empty, in which
29923 case no action is taken. If you want to set an empty sender (as in bounce
29924 messages), you must specify it as `<>'. Otherwise, if the address is not
29925 qualified and the \\QUALIFY@_DOMAIN\\ parameter is set in
29926 \(Local/eximon.conf)\, the address is qualified with that domain.
29927 .endp
29928 When a delivery is forced, a window showing the \-v-\ output is displayed. In
29929 other cases when a call to Exim is made, if there is any output from Exim (in
29930 particular, if the command fails) a window containing the command and the
29931 output is displayed. Otherwise, the results of the action are normally apparent
29932 from the log and queue displays. However, if you set \\ACTION@_OUTPUT\\=yes in
29933 \(Local/eximon.conf)\, a window showing the Exim command is always opened, even
29934 if no output is generated.
29935
29936 The queue display is automatically updated for actions such as freezing and
29937 thawing, unless \\ACTION@_QUEUE@_UPDATE\\=no has been set in
29938 \(Local/eximon.conf)\. In this case the `Update' button has to be used to force
29939 an update of the display after one of these actions.
29940
29941 In any text window that is displayed as result of a menu action, the normal
29942 cut-and-paste facility is available, and searching can be carried out using ^R
29943 and ^S, as described above for the log tail window.
29944
29945
29946
29947
29948
29949
29950 .
29951 .
29952 .
29953 .
29954 . ============================================================================
29955 .chapter Security considerations
29956 .set runningfoot "security"
29957 .rset CHAPsecurity ~~chapter
29958 .index security
29959 This chapter discusses a number of issues concerned with security, some of
29960 which are also covered in other parts of this manual.
29961
29962 For reasons that this author does not understand, some people have promoted
29963 Exim as a `particularly secure' mailer. Perhaps it is because of the existence
29964 of this chapter in the documentation. However, the intent of the chapter is
29965 simply to describe the way Exim works in relation to certain security concerns,
29966 not to make any specific claims about the effectiveness of its security as
29967 compared with other MTAs.
29968
29969 What follows is a description of the way Exim is supposed to be. Best efforts
29970 have been made to try to ensure that the code agrees with the theory, but an
29971 absence of bugs can never be guaranteed. Any that are reported will get fixed
29972 as soon as possible.
29973
29974 .section Building a more `hardened' Exim
29975 .index security||build-time features
29976 There are a number of build-time options that can be set in \(Local/Makefile)\
29977 to create Exim binaries that are `harder' to attack, in particular by a rogue
29978 Exim administrator who does not have the root password, or by someone who has
29979 penetrated the Exim (but not the root) account. These options are as follows:
29980 .numberpars $.
29981 \\ALT@_CONFIG@_PREFIX\\ can be set to a string that is required to match the
29982 start of any file names used with the \-C-\ option. When it is set, these file
29983 names are also not allowed to contain the sequence `/../'. (However, if the
29984 value of the \-C-\ option is identical to the value of \\CONFIGURE@_FILE\\ in
29985 \(Local/Makefile)\, Exim ignores \-C-\ and proceeds as usual.) There is no
29986 default setting for \ALT@_CONFIG@_PREFIX\.
29987
29988 If the permitted configuration files are confined to a directory to
29989 which only root has access, this guards against someone who has broken
29990 into the Exim account from running a privileged Exim with an arbitrary
29991 configuration file, and using it to break into other accounts.
29992 .nextp
29993 If \\ALT@_CONFIG@_ROOT@_ONLY\\ is defined, root privilege is retained for \-C-\
29994 and \-D-\ only if the caller of Exim is root. Without it, the Exim user may
29995 also use \-C-\ and \-D-\ and retain privilege. Setting this option locks out
29996 the possibility of testing a configuration using \-C-\ right through message
29997 reception and delivery, even if the caller is root. The reception works, but by
29998 that time, Exim is running as the Exim user, so when it re-execs to regain
29999 privilege for the delivery, the use of \-C-\ causes privilege to be lost.
30000 However, root can test reception and delivery using two separate commands.
30001 \\ALT@_CONFIG@_ROOT@_ONLY\\ is not set by default.
30002 .nextp
30003 If \\DISABLE@_D@_OPTION\\ is defined, the use of the \-D-\ command line option
30004 is disabled.
30005 .nextp
30006 \\FIXED@_NEVER@_USERS\\ can be set to a colon-separated list of users that are
30007 never to be used for any deliveries. This is like the \never@_users\ runtime
30008 option, but it cannot be overridden; the runtime option adds additional users
30009 to the list. The default setting is `root'; this prevents a non-root user who
30010 is permitted to modify the runtime file from using Exim as a way to get root.
30011 .endp
30012
30013
30014 .section Root privilege
30015 .index setuid
30016 .index root privilege
30017 The Exim binary is normally setuid to root, which means that it gains root
30018 privilege (runs as root) when it starts execution. In some special cases (for
30019 example, when the daemon is not in use and there are no local deliveries), it
30020 may be possible to run Exim setuid to some user other than root. This is
30021 discussed in the next section. However, in most installations, root privilege
30022 is required for two things:
30023 .numberpars $.
30024 To set up a socket connected to the standard SMTP port (25) when initialising
30025 the listening daemon. If Exim is run from \*inetd*\, this privileged action is
30026 not required.
30027 .nextp
30028 To be able to change uid and gid in order to read users' \(.forward)\ files and
30029 perform local deliveries as the receiving user or as specified in the
30030 configuration.
30031 .endp
30032 It is not necessary to be root to do any of the other things Exim does, such as
30033 receiving messages and delivering them externally over SMTP, and it is
30034 obviously more secure if Exim does not run as root except when necessary.
30035 For this reason, a user and group for Exim to use must be defined in
30036 \(Local/Makefile)\. These are known as `the Exim user' and `the Exim group'.
30037 Their values can be changed by the run time configuration, though this is not
30038 recommended. Often a user called \*exim*\ is used, but some sites use \*mail*\
30039 or another user name altogether.
30040
30041 Exim uses \*setuid()*\ whenever it gives up root privilege. This is a permanent
30042 abdication; the process cannot regain root afterwards. Prior to release 4.00,
30043 \*seteuid()*\ was used in some circumstances, but this is no longer the case.
30044
30045 After a new Exim process has interpreted its command line options, it changes
30046 uid and gid in the following cases:
30047 .numberpars $.
30048 .index \-C-\ option
30049 .index \-D-\ option
30050 If the \-C-\ option is used to specify an alternate configuration file, or if
30051 the \-D-\ option is used to define macro values for the configuration, and the
30052 calling process is not running as root or the Exim user, the uid and gid are
30053 changed to those of the calling process.
30054 However, if \\ALT@_CONFIG@_ROOT@_ONLY\\ is defined in \(Local/Makefile)\, only
30055 root callers may use \-C-\ and \-D-\ without losing privilege, and if
30056 \\DISABLE@_D@_OPTION\\ is set, the \-D-\ option may not be used at all.
30057 .nextp
30058 .index \-be-\ option
30059 .index \-bf-\ option
30060 .index \-bF-\ option
30061 If the expansion test option (\-be-\) or one of the filter testing options
30062 (\-bf-\ or \-bF-\) are used, the uid and gid are changed to those of the
30063 calling process.
30064 .nextp
30065 If the process is not a daemon process or a queue runner process or a delivery
30066 process or a process for testing address routing (started with \-bt-\), the uid
30067 and gid are changed to the Exim user and group. This means that Exim always
30068 runs under its own uid and gid when receiving messages. This also applies when
30069 testing address verification
30070 .index \-bv-\ option
30071 .index \-bh-\ option
30072 (the \-bv-\ option) and testing incoming message policy controls (the \-bh-\
30073 option).
30074 .nextp
30075 For a daemon, queue runner, delivery, or address testing process, the uid
30076 remains as root at this stage, but the gid is changed to the Exim group.
30077 .endp
30078 The processes that initially retain root privilege behave as follows:
30079 .numberpars $.
30080 A daemon process changes the gid to the Exim group and the uid to the Exim user
30081 after setting up one or more listening sockets. The \*initgroups()*\ function
30082 is called, so that if the Exim user is in any additional groups, they will be
30083 used during message reception.
30084 .nextp
30085 A queue runner process retains root privilege throughout its execution. Its job
30086 is to fork a controlled sequence of delivery processes.
30087 .nextp
30088 A delivery process retains root privilege throughout most of its execution,
30089 but any actual deliveries (that is, the transports themselves) are run in
30090 subprocesses which always change to a non-root uid and gid. For local
30091 deliveries this is typically the uid and gid of the owner of the mailbox; for
30092 remote deliveries, the Exim uid and gid are used. Once all the delivery
30093 subprocesses have been run, a delivery process changes to the Exim uid and gid
30094 while doing post-delivery tidying up such as updating the retry database and
30095 generating bounce and warning messages.
30096
30097 While the recipient addresses in a message are being routed, the delivery
30098 process runs as root. However, if a user's filter file has to be processed,
30099 this is done in a subprocess that runs under the individual user's uid and
30100 gid. A system filter is run as root unless \system@_filter@_user\ is set.
30101 .nextp
30102 A process that is testing addresses (the \-bt-\ option) runs as root so that
30103 the routing is done in the same environment as a message delivery.
30104 .endp
30105
30106
30107 .section Running Exim without privilege
30108 .rset SECTrunexiwitpri "~~chapter.~~section"
30109 .index privilege, running without
30110 .index unprivileged running
30111 .index root privilege||running without
30112 Some installations like to run Exim in an unprivileged state for more of its
30113 operation, for added security. Support for this mode of operation is provided
30114 by the global option \deliver@_drop@_privilege\. When this is set, the uid and
30115 gid are changed to the Exim user and group at the start of a delivery process
30116 (and also queue runner and address testing processes). This means that address
30117 routing is no longer run as root, and the deliveries themselves cannot change
30118 to any other uid.
30119
30120 Leaving the binary setuid to root, but setting \deliver@_drop@_privilege\ means
30121 that the daemon can still be started in the usual way, and it can respond
30122 correctly to SIGHUP because the re-invocation regains root privilege.
30123
30124 An alternative approach is to make Exim setuid to the Exim user and also setgid
30125 to the Exim group.
30126 If you do this, the daemon must be started from a root process. (Calling
30127 Exim from a root process makes it behave in the way it does when it is setuid
30128 root.) However, the daemon cannot restart itself after a SIGHUP signal because
30129 it cannot regain privilege.
30130
30131 It is still useful to set \deliver@_drop@_privilege\ in this case, because it
30132 stops Exim from trying to re-invoke itself to do a delivery after a message has
30133 been received. Such a re-invocation is a waste of resources because it has no
30134 effect.
30135
30136 If restarting the daemon is not an issue (for example, if 
30137 .em
30138 \mua@_wrapper\ is set, or 
30139 .nem
30140 \*inetd*\ is being used instead of a daemon), having the binary setuid to the
30141 Exim user seems a clean approach, but there is one complication:
30142
30143 In this style of operation, Exim is running with the real uid and gid set to
30144 those of the calling process, and the effective uid/gid set to Exim's values.
30145 Ideally, any association with the calling process' uid/gid should be dropped,
30146 that is, the real uid/gid should be reset to the effective values so as to
30147 discard any privileges that the caller may have. While some operating systems
30148 have a function that permits this action for a non-root effective uid, quite a
30149 number of them do not. Because of this lack of standardization, Exim does not
30150 address this problem at this time.
30151
30152 For this reason, the recommended approach for `mostly unprivileged' running is
30153 to keep the Exim binary setuid to root, and to set \deliver@_drop@_privilege\.
30154 This also has the advantage of allowing a daemon to be used in the most
30155 straightforward way.
30156
30157 If you configure Exim not to run delivery processes as root, there are a
30158 number of restrictions on what you can do:
30159 .numberpars $.
30160 You can deliver only as the Exim user/group. You should  explicitly use the
30161 \user\ and \group\ options to override routers or local transports that
30162 normally deliver as the recipient. This makes sure that configurations that
30163 work in this mode function the same way in normal mode. Any implicit or
30164 explicit specification of another user causes an error.
30165 .nextp
30166 Use of \(.forward)\ files is severely restricted, such that it is usually
30167 not worthwhile to include them in the configuration.
30168 .nextp
30169 Users who wish to use \(.forward)\ would have to make their home directory and
30170 the file itself accessible to the Exim user. Pipe and append-to-file entries,
30171 and their equivalents in Exim filters, cannot be used. While they could be
30172 enabled in the Exim user's name, that would be insecure and not very useful.
30173 .nextp
30174 Unless the local user mailboxes are all owned by the Exim user (possible in
30175 some POP3 or IMAP-only environments):
30176 .numberpars $*$
30177 They must be owned by the Exim group and be writable by that group. This
30178 implies you must set \mode\ in the appendfile configuration, as well as the
30179 mode of the mailbox files themselves.
30180 .nextp
30181 You must set \no@_check@_owner\, since most or all of the files will not be
30182 owned by the Exim user.
30183 .nextp
30184 You must set \file@_must@_exist\, because Exim cannot set the owner correctly
30185 on a newly created mailbox when unprivileged. This also implies that new
30186 mailboxes need to be created manually.
30187 .endp
30188 .endp
30189 These restrictions severely restrict what can be done in local deliveries.
30190 However, there are no restrictions on remote deliveries. If you are running a
30191 gateway host that does no local deliveries, setting \deliver@_drop@_privilege\
30192 gives more security at essentially no cost.
30193 .em
30194 If you are using the \mua@_wrapper\ facility (see chapter ~~CHAPnonqueueing), 
30195 \deliver@_drop@_privilege\ is forced to be true.
30196 .nem
30197
30198
30199 .section Delivering to local files
30200 Full details of the checks applied by \%appendfile%\ before it writes to a file
30201 are given in chapter ~~CHAPappendfile.
30202
30203
30204 .section IPv4 source routing
30205 .index source routing||in IP packets
30206 .index IP source routing
30207 Many operating systems suppress IP source-routed packets in the kernel, but
30208 some cannot be made to do this, so Exim does its own check. It logs incoming
30209 IPv4 source-routed TCP calls, and then drops them. Things are all different in
30210 IPv6. No special checking is currently done.
30211
30212
30213 .section The VRFY, EXPN, and ETRN commands in SMTP
30214 Support for these SMTP commands is disabled by default. If required, they can
30215 be enabled by defining suitable ACLs.
30216
30217
30218
30219 .section Privileged users
30220 .index trusted user
30221 .index admin user
30222 .index privileged user
30223 .index user||trusted
30224 .index user||admin
30225 Exim recognises two sets of users with special privileges. Trusted users are
30226 able to submit new messages to Exim locally, but supply their own sender
30227 addresses and information about a sending host. For other users submitting
30228 local messages, Exim sets up the sender address from the uid, and doesn't
30229 permit a remote host to be specified.
30230
30231 .index \-f-\ option
30232 However, an untrusted user is permitted to use the \-f-\ command line option in
30233 the special form \-f @<@>-\ to indicate that a delivery failure for the message
30234 should not cause an error report. This affects the message's envelope, but it
30235 does not affect the ::Sender:: header. Untrusted users may also be permitted to
30236 use specific forms of address with the \-f-\ option by setting the
30237 \untrusted@_set@_sender\ option.
30238
30239 Trusted users are used to run processes that receive mail messages from some
30240 other mail domain and pass them on to Exim for delivery either locally, or over
30241 the Internet. Exim trusts a caller that is running as root, as the Exim user,
30242 as any user listed in the \trusted@_users\ configuration option, or under any
30243 group listed in the \trusted@_groups\ option.
30244
30245 Admin users are permitted to do things to the messages on Exim's queue. They
30246 can freeze or thaw messages, cause them to be returned to their senders, remove
30247 them entirely, or modify them in various ways. In addition, admin users can run
30248 the Exim monitor and see all the information it is capable of providing, which
30249 includes the contents of files on the spool.
30250
30251 .index \-M-\ option
30252 .index \-q-\ option
30253 By default, the use of the \-M-\ and \-q-\ options to cause Exim to attempt
30254 delivery of messages on its queue is restricted to admin users. This
30255 restriction can be relaxed by setting the \no@_prod@_requires@_admin\ option.
30256 Similarly, the use of \-bp-\ (and its variants) to list the contents of the
30257 queue is also restricted to admin users. This restriction can be relaxed by
30258 setting \no@_queue@_list@_requires@_admin\.
30259
30260 Exim recognises an admin user if the calling process is running as root or as
30261 the Exim user or if any of the groups associated with the calling process is
30262 the Exim group. It is not necessary actually to be running under the Exim
30263 group. However, if admin users who are not root or the Exim user are to access
30264 the contents of files on the spool via the Exim monitor (which runs
30265 unprivileged), Exim must be built to allow group read access to its spool
30266 files.
30267
30268
30269 .section Spool files
30270 .index spool directory||files
30271 Exim's spool directory and everything it contains is owned by the Exim user and
30272 set to the Exim group. The mode for spool files is defined in the
30273 \(Local/Makefile)\ configuration file, and defaults to 0640. This means that
30274 any user who is a member of the Exim group can access these files.
30275
30276
30277 .section Use of argv[0]
30278 Exim examines the last component of \argv[0]\, and if it matches one of a set
30279 of specific strings, Exim assumes certain options. For example, calling Exim
30280 with the last component of \argv[0]\ set to `rsmtp' is exactly equivalent to
30281 calling it with the option \-bS-\. There are no security implications in this.
30282
30283
30284 .section Use of %f formatting
30285 The only use made of `%f' by Exim is in formatting load average values. These
30286 are actually stored in integer variables as 1000 times the load average.
30287 Consequently, their range is limited and so therefore is the length of the
30288 converted output.
30289
30290
30291 .section Embedded Exim path
30292 Exim uses its own path name, which is embedded in the code, only when it needs
30293 to re-exec in order to regain root privilege. Therefore, it is not root when it
30294 does so. If some bug allowed the path to get overwritten, it would lead to an
30295 arbitrary program's being run as exim, not as root.
30296
30297
30298 .section Use of sprintf()
30299 .index \*sprintf()*\
30300 A large number of occurrences of `sprintf' in the code are actually calls to
30301 \*string@_sprintf()*\, a function that returns the result in malloc'd store.
30302 The intermediate formatting is done into a large fixed buffer by a function
30303 that runs through the format string itself, and checks the length of each
30304 conversion before performing it, thus preventing buffer overruns.
30305
30306 The remaining uses of \*sprintf()*\ happen in controlled circumstances where
30307 the output buffer is known to be sufficiently long to contain the converted
30308 string.
30309
30310
30311 .section Use of debug@_printf() and log@_write()
30312 Arbitrary strings are passed to both these functions, but they do their
30313 formatting by calling the function \*string@_vformat()*\, which runs through
30314 the format string itself, and checks the length of each conversion.
30315
30316
30317 .section Use of strcat() and strcpy()
30318 These are used only in cases where the output buffer is known to be large
30319 enough to hold the result.
30320
30321
30322
30323
30324 .
30325 .
30326 .
30327 .
30328 . ============================================================================
30329 .chapter Format of spool files
30330 .set runningfoot "spool file format"
30331 .rset CHAPspool ~~chapter
30332 .index format||spool files
30333 .index spool directory||format of files
30334 .index spool||files, format of
30335 .index spool||files, editing
30336 A message on Exim's queue consists of two files, whose names are the message id
30337 followed by -D and -H, respectively. The data portion of the message is kept in
30338 the -D file on its own. The message's envelope, status, and headers are all
30339 kept in the -H file, whose format is described in this chapter. Each of these
30340 two files contains the final component of its own name as its first line. This
30341 is insurance against disk crashes where the directory is lost but the files
30342 themselves are recoverable.
30343
30344 Some people are tempted into editing -D files in order to modify messages. You
30345 need to be extremely careful if you do this; it is not recommended and you are
30346 on your own if you do it. Here are some of the pitfalls:
30347 .numberpars $.
30348 You must use the \*exim@_lock*\ utility to ensure that Exim does not try to
30349 deliver the message while you are fiddling with it. The lock is implemented
30350 by opening the -D file and taking out a write lock on it. If you update the
30351 file in place, the lock will be retained. If you write a new file and rename
30352 it, the lock will be lost at the instant of rename.
30353 .nextp
30354 If you change the number of lines in the file, the value of
30355 \$body@_linecount$\, which is stored in the -H file, will be incorrect.
30356 .nextp
30357 If the message is in MIME format, you must take care not to break it.
30358 .nextp
30359 If the message is cryptographically signed, any change will invalidate the
30360 signature.
30361 .endp
30362
30363 Files whose names end with -J may also be seen in the \(input)\ directory (or
30364 its subdirectories when \split@_spool@_directory\ is set). These are journal
30365 files, used to record addresses to which the message has been delivered during
30366 the course of a delivery run. At the end of the run, the -H file is updated,
30367 and the -J file is deleted.
30368
30369 .section Format of the -H file
30370 .index uid (user id)||in spool file
30371 .index gid (group id)||in spool file
30372 The second line of the -H file contains the login name for the uid of the
30373 process that called Exim to read the message, followed by the numerical uid and
30374 gid. For a locally generated message, this is normally the user who sent the
30375 message. For a message received over TCP/IP, it is normally the Exim user.
30376
30377 The third line of the file contains the address of the message's sender as
30378 transmitted in the envelope, contained in angle brackets. The sender address is
30379 empty for bounce messages. For incoming SMTP mail, the sender address is given
30380 in the \\MAIL\\ command. For locally generated mail, the sender address is
30381 created by Exim from the login name of the current user and the configured
30382 \qualify@_domain\. However, this can be overridden by the \-f-\ option or a
30383 leading `From' line if the caller is trusted, or if the supplied address is
30384 `@<@>' or an address that matches \untrusted@_set@_senders\.
30385
30386 The fourth line contains two numbers. The first is the time that the message
30387 was received, in the conventional Unix form -- the number of seconds since the
30388 start of the epoch. The second number is a count of the number of messages
30389 warning of delayed delivery that have been sent to the sender.
30390
30391 There follow a number of lines starting with a hyphen. These can appear in any
30392 order, and are omitted when not relevant:
30393 .numberpars $.
30394 \-acl <<number>> <<length>>-\: A line of this form is present for every ACL
30395 variable that is not empty. The number identifies the variable; the
30396 \acl@_c\*x*\$$\ variables are numbered 0--9 and the \acl@_m\*x*\$$\ variables
30397 are numbered 10--19. The length is the length of the data string for the
30398 variable. The string itself starts at the beginning of the next line, and is
30399 followed by a newline character. It may contain internal newlines.
30400 .nextp
30401 .em
30402 \-active@_hostname <<hostname>>-\: This is present if, when the message was 
30403 received over SMTP, the value of \$smtp@_active@_hostname$\ was different to 
30404 the value of \$primary@_hostname$\.
30405 .nem
30406 .nextp
30407 \-allow@_unqualified@_recipient-\: This is present if unqualified recipient
30408 addresses are permitted in header lines (to stop such addresses from being
30409 qualified if rewriting occurs at transport time). Local messages that were
30410 input using \-bnq-\ and remote messages from hosts that match
30411 \recipient@_unqualified@_hosts\ set this flag.
30412 .nextp
30413 \-allow@_unqualified@_sender-\: This is present if unqualified sender
30414 addresses are permitted in header lines (to stop such addresses from being
30415 qualified if rewriting occurs at transport time). Local messages that were
30416 input using \-bnq-\ and remote messages from hosts that match
30417 \sender@_unqualified@_hosts\ set this flag.
30418 .nextp
30419 \-auth@_id <<text>>-\: The id information for a message received on an
30420 authenticated SMTP connection -- the value of the \$authenticated@_id$\
30421 variable.
30422 .nextp
30423 \-auth@_sender <<address>>-\: The address of an authenticated sender -- the
30424 value of the \$authenticated@_sender$\ variable.
30425 .nextp
30426 \-body@_linecount <<number>>-\: This records the number of lines in the body of
30427 the message, and is always present.
30428 .nextp
30429 .em
30430 \-body@_zerocount <<number>>-\: This records the number of binary zero bytes in 
30431 the body of the message, and is present if the number is greater than zero.
30432 .nem
30433 .nextp
30434 \-deliver@_firsttime-\: This is written when a new message is first added to
30435 the spool. When the spool file is updated after a deferral, it is omitted.
30436 .nextp
30437 .index frozen messages||spool data
30438 \-frozen <<time>>-\: The message is frozen, and the freezing happened at
30439 <<time>>.
30440 .nextp
30441 \-helo@_name <<text>>-\: This records the host name as specified by a remote
30442 host in a \\HELO\\ or \\EHLO\\ command.
30443 .nextp
30444 \-host@_address <<address>>.<<port>>-\: This records the IP address of the host
30445 from which the message was received and the remote port number that was used.
30446 It is omitted for locally generated messages.
30447 .nextp
30448 \-host@_auth <<text>>-\: If the message was received on an authenticated SMTP
30449 connection, this records the name of the authenticator -- the value of the
30450 \$sender@_host@_authenticated$\ variable.
30451 .nextp
30452 \-host@_lookup@_failed-\: This is present if an attempt to look up the sending
30453 host's name from its IP address failed. It corresponds to the
30454 \$host@_lookup@_failed$\ variable.
30455 .nextp
30456 .index DNS||reverse lookup
30457 .index reverse DNS lookup
30458 \-host@_name <<text>>-\: This records the name of the remote host from which
30459 the message was received, if the host name was looked up from the IP address
30460 when the message was being received. It is not present if no reverse lookup was
30461 done.
30462 .nextp
30463 \-ident <<text>>-\: For locally submitted messages, this records the login of
30464 the originating user, unless it was a trusted user and the \-oMt-\ option was
30465 used to specify an ident value. For messages received over TCP/IP, this records
30466 the ident string supplied by the remote host, if any.
30467 .nextp
30468 \-interface@_address <<address>>.<<port>>-\: This records the IP address of the
30469 local interface and the port number through which a message was received from a
30470 remote host. It is omitted for locally generated messages.
30471 .nextp
30472 \-local-\: The message is from a local sender.
30473 .nextp
30474 \-localerror-\: The message is a locally-generated bounce message.
30475 .nextp
30476 \-local@_scan <<string>>-\: This records the data string that was
30477 returned by the \*local@_scan()*\ function when the message was received -- the
30478 value of the \$local@_scan@_data$\ variable. It is omitted if no data was
30479 returned.
30480 .nextp
30481 \-manual@_thaw-\: The message was frozen but has been thawed manually, that is,
30482 by an explicit Exim command rather than via the auto-thaw process.
30483 .nextp
30484 \-N-\: A testing delivery process was started using the \-N-\ option to
30485 suppress any actual deliveries, but delivery was deferred. At any further
30486 delivery attempts, \-N-\ is assumed.
30487 .nextp
30488 \-received@_protocol-\: This records the value of the \$received@_protocol$\
30489 variable, which contains the name of the protocol by which the message was
30490 received.
30491 .nextp
30492 \-sender@_set@_untrusted-\: The envelope sender of this message was set by an
30493 untrusted local caller (used to ensure that the caller is displayed in queue
30494 listings).
30495 .nextp
30496 .em
30497 \-spam@_score@_int-\: If a message was scanned by SpamAssassin, this is 
30498 present. It records the value of \$spam@_score@_int$\.
30499 .nem
30500 .nextp
30501 \-tls@_certificate@_verified-\: A TLS certificate was received from the client
30502 that sent this message, and the certificate was verified by the server.
30503 .nextp
30504 \-tls@_cipher <<cipher name>>-\: When the message was received over an
30505 encrypted connection, this records the name of the cipher suite that was used.
30506 .nextp
30507 \-tls@_peerdn <<peer DN>>-\: When the message was received over an encrypted
30508 connection, and a certificate was received from the client, this records the
30509 Distinguished Name from that certificate.
30510 .endp
30511
30512 Following the options there is a list of those addresses to which the message
30513 is not to be delivered. This set of addresses is initialized from the command
30514 line when the \-t-\ option is used and \extract__addresses__remove__arguments\
30515 is set; otherwise it starts out empty. Whenever a successful delivery is made,
30516 the address is added to this set. The addresses are kept internally as a
30517 balanced binary tree, and it is a representation of that tree which is written
30518 to the spool file. If an address is expanded via an alias or forward file, the
30519 original address is added to the tree when deliveries to all its child
30520 addresses are complete.
30521
30522 If the tree is empty, there is a single line in the spool file containing just
30523 the text `XX'. Otherwise, each line consists of two letters, which are either Y
30524 or N, followed by an address. The address is the value for the node of the
30525 tree, and the letters indicate whether the node has a left branch and/or a
30526 right branch attached to it, respectively. If branches exist, they immediately
30527 follow. Here is an example of a three-node tree:
30528 .display asis
30529 YY darcy@austen.fict.example
30530 NN alice@wonderland.fict.example
30531 NN editor@thesaurus.ref.example
30532 .endd
30533 After the non-recipients tree, there is a list of the message's recipients.
30534 This is a simple list, preceded by a count. It includes all the original
30535 recipients of the message, including those to whom the message has already been
30536 delivered. In the simplest case, the list contains one address per line. For
30537 example:
30538 .display asis
30539 4
30540 editor@thesaurus.ref.example
30541 darcy@austen.fict.example
30542 rdo@foundation
30543 alice@wonderland.fict.example
30544 .endd
30545 However, when a child address has been added to the top-level addresses as a
30546 result of the use of the \one@_time\ option on a \%redirect%\ router, each line
30547 is of the following form:
30548 .display
30549 <<top-level address>> <<errors@_to address>> <<length>>,<<parent number>>@#<<flag bits>>
30550 .endd
30551 The 01 flag bit indicates the presence of the three other fields that follow
30552 the top-level address. Other bits may be used in future to support additional
30553 fields. The <<parent number>> is the offset in the recipients list of the
30554 original parent of the `one time' address. The first two fields are the
30555 envelope sender that is associated with this address and its length. If the
30556 length is zero, there is no special envelope sender (there are then two space
30557 characters in the line). A non-empty field can arise from a \%redirect%\ router
30558 that has an \errors@_to\ setting.
30559
30560
30561 A blank line separates the envelope and status information from the headers
30562 which follow. A header may occupy several lines of the file, and to save effort
30563 when reading it in, each header is preceded by a number and an identifying
30564 character. The number is the number of characters in the header, including any
30565 embedded newlines and the terminating newline. The character is one of the
30566 following:
30567 .display
30568 .tabs 9
30569 <<blank>>  $t $rm{header in which Exim has no special interest}
30570 #B      $t $rm{::Bcc:: header}
30571 #C      $t $rm{::Cc:: header}
30572 #F      $t $rm{::From:: header}
30573 #I      $t $rm{::Message-id:: header}
30574 #P      $t $rm{::Received:: header -- P for `postmark'}
30575 #R      $t $rm{::Reply-To:: header}
30576 #S      $t $rm{::Sender:: header}
30577 #T      $t $rm{::To:: header}
30578 #*      $t $rm{replaced or deleted header}
30579 .endd
30580 Deleted or replaced (rewritten) headers remain in the spool file for debugging
30581 purposes. They are not transmitted when the message is delivered. Here is a
30582 typical set of headers:
30583 .display asis
30584 111P Received: by hobbit.fict.example with local (Exim 4.00)
30585         id 14y9EI-00026G-00; Fri, 11 May 2001 10:28:59 +0100
30586 049  Message-Id: <E14y9EI-00026G-00@hobbit.fict.example>
30587 038* X-rewrote-sender: bb@hobbit.fict.example
30588 042* From: Bilbo Baggins <bb@hobbit.fict.example>
30589 049F From: Bilbo Baggins <B.Baggins@hobbit.fict.example>
30590 099* To: alice@wonderland.fict.example, rdo@foundation,
30591  darcy@austen.fict.example, editor@thesaurus.ref.example
30592 109T To: alice@wonderland.fict.example, rdo@foundation.fict.example,
30593  darcy@austen.fict.example, editor@thesaurus.ref.example
30594 038  Date: Fri, 11 May 2001 10:28:59 +0100
30595 .endd
30596 The asterisked headers indicate that the envelope sender, ::From:: header, and
30597 ::To:: header have been rewritten, the last one because routing expanded the
30598 unqualified domain \*foundation*\.
30599
30600 .
30601 .
30602 .
30603 .
30604 . ============================================================================
30605 .chapter Adding new drivers or lookup types
30606 .set runningfoot "adding drivers"
30607 .index adding drivers
30608 .index new drivers, adding
30609 .index drivers||adding new
30610 The following actions have to be taken in order to add a new router, transport,
30611 authenticator, or lookup type to Exim:
30612 .numberpars
30613 Choose a name for the driver or lookup type that does not conflict with any
30614 existing name; I will use `newdriver' in what follows.
30615 .nextp
30616 Add to \(src/EDITME)\ the line
30617 .display
30618 <<type>>@_NEWDRIVER=yes
30619 .endd
30620 where <<type>> is \\ROUTER\\, \\TRANSPORT\\, \\AUTH\\, or \\LOOKUP\\. If the
30621 code is not to be included in the binary by default, comment this line out. You
30622 should also add any relevant comments about the driver or lookup type.
30623 .nextp
30624 Add to \(src/config.h.defaults)\ the line
30625 .display
30626 @#define <<type>>@_NEWDRIVER
30627 .endd
30628 .nextp
30629 Edit \(src/drtables.c)\, adding conditional code to pull in the private header
30630 and create a table entry as is done for all the other drivers and lookup types.
30631 .nextp
30632 Edit \(Makefile)\ in the appropriate sub-directory (\(src/routers)\,
30633 \(src/transports)\, \(src/auths)\, or \(src/lookups)\); add a line for the new
30634 driver or lookup type and add it to the definition of OBJ.
30635 .nextp
30636 Create \(newdriver.h)\ and \(newdriver.c)\ in the appropriate sub-directory of
30637 \(src)\.
30638 .nextp
30639 Edit \(scripts/MakeLinks)\ and add commands to link the \(.h)\ and \(.c)\ files
30640 as for other drivers and lookups.
30641 .endp
30642 Then all you need to do is write the code! A good way to start is to make a
30643 proforma by copying an existing module of the same type, globally changing all
30644 occurrences of the name, and cutting out most of the code. Note that any
30645 options you create must be listed in alphabetical order, because the tables are
30646 searched using a binary chop procedure.
30647
30648 There is a \(README)\ file in each of the sub-directories of \(src)\ describing
30649 the interface that is expected.
30650
30651 .
30652 .
30653 .
30654 .
30655 . ============================================================================
30656 . Fudge for the index page number. We want it to be on a right-hand page.
30657 .
30658 .set indexpage ~~sys.pagenumber + 1
30659 .if even ~~indexpage
30660 .set indexpage ~~indexpage + 1
30661 .fi
30662 .if ~~sgcal
30663 .%index Index$e~~indexpage--
30664 .fi
30665 .
30666 .
30667 . End of Exim specification