Tidies for HTML and Texinfo versions of the new spec.
[exim.git] / doc / doc-src / spec.src
1 . $Cambridge: exim/doc/doc-src/spec.src,v 1.5 2005/01/27 10:25:35 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 to be expanded. You cannot rely on \-bV-\ alone to discover (for 
3280 example) all the typos in the configuration; some realistic testing is needed.
3281 The \-bh-\ and \-N-\ options provide more dynamic testing facilities.
3282 .nem
3283
3284
3285 .option bv
3286 .index verifying||address, using \-bv-\
3287 .index address||verification
3288 This option runs Exim in address verification mode, in which each argument is
3289 taken as an address to be verified. During normal operation, verification
3290 happens mostly as a consequence processing a \verify\ condition in an ACL (see
3291 chapter ~~CHAPACL). If you want to test an entire ACL, see the \-bh-\ option.
3292
3293 If verification fails, and the caller is not an admin user, no details of the
3294 failure are output, because these might contain sensitive information such as
3295 usernames and passwords for database lookups.
3296
3297 If no arguments are given, Exim runs in an interactive manner, prompting with a
3298 right angle bracket for addresses to be verified. 
3299 .em
3300 Unlike the \-be-\ test option, you cannot arrange for Exim to use the 
3301 \*readline()*\ function, because it is running as \*exim*\ and there are
3302 security issues.
3303 .nem
3304
3305 Verification differs from address testing (the \-bt-\ option) in that routers
3306 that have \no@_verify\ set are skipped, and if the address is accepted by a
3307 router that has \fail@_verify\ set, verification fails. The address is verified
3308 as a recipient if \-bv-\ is used; to test verification for a sender address,
3309 \-bvs-\ should be used.
3310
3311 If the \-v-\ option is not set, the output consists of a single line for each
3312 address, stating whether it was verified or not, and giving a reason in the
3313 latter case. Otherwise, more details are given of how the address has been
3314 handled, and in the case of address redirection, all the generated addresses
3315 are also considered. Without \-v-\, generating more than one address by
3316 redirection causes verification to end sucessfully.
3317
3318 .index return code||for \-bv-\
3319 The return code is 2 if any address failed outright; it is 1 if no address
3320 failed outright but at least one could not be resolved for some reason. Return
3321 code 0 is given only when all addresses succeed.
3322
3323 If any of the routers in the configuration makes any tests on the sender
3324 address of a message, you should use the \-f-\ option to set an appropriate
3325 sender when running \-bv-\ tests. Without it, the sender is assumed to be the
3326 calling user at the default qualifying domain.
3327
3328 .option bvs
3329 This option acts like \-bv-\, but verifies the address as a sender rather
3330 than a recipient address. This affects any rewriting and qualification that
3331 might happen.
3332
3333 .option C #<<filelist>>
3334 .index configuration file||alternate
3335 .index \\CONFIGURE@_FILE\\
3336 .index alternate configuration file
3337 This option causes Exim to find the run time configuration file from the given
3338 list instead of from the list specified by the \\CONFIGURE@_FILE\\
3339 compile-time setting. Usually, the list will consist of just a single file
3340 name, but it can be a colon-separated list of names. In this case, the first
3341 file that exists is used. Failure to open an existing file stops Exim from
3342 proceeding any further along the list, and an error is generated.
3343
3344 When this option is used by a caller other than root or the Exim user, and the
3345 list is different from the compiled-in list, Exim gives up its root privilege
3346 immediately, and runs with the real and effective uid and gid set to those of
3347 the caller. However, if \\ALT@_CONFIG@_ROOT@_ONLY\\ is defined in
3348 \(Local/Makefile)\, root privilege is retained for \-C-\ only if the caller of
3349 Exim is root.
3350 .em
3351 That is, the Exim user is no longer privileged in this regard. This build-time
3352 option is not set by default in the Exim source distribution tarbundle. 
3353 However, if you are using a `packaged' version of Exim (source or binary), the 
3354 packagers might have enabled it.
3355 .nem
3356
3357 Setting \\ALT@_CONFIG@_ROOT@_ONLY\\ locks out the possibility of testing a
3358 configuration using \-C-\ right through message reception and delivery, even if
3359 the caller is root. The reception works, but by that time, Exim is running as
3360 the Exim user, so when it re-execs to regain privilege for the delivery, the
3361 use of \-C-\ causes privilege to be lost. However, root can test reception and
3362 delivery using two separate commands (one to put a message on the queue, using
3363 \-odq-\, and another to do the delivery, using \-M-\).
3364
3365 If \\ALT@_CONFIG@_PREFIX\\ is defined \(in Local/Makefile)\, it specifies a
3366 prefix string with which any file named in a \-C-\ command line option
3367 must start. In addition, the file name must not contain the sequence \"/../"\.
3368 However, if the value of the \-C-\ option is identical to the value of
3369 \\CONFIGURE@_FILE\\ in \(Local/Makefile)\, Exim ignores \-C-\ and proceeds as
3370 usual. There is no default setting for \\ALT@_CONFIG@_PREFIX\\; when it is
3371 unset, any file name can be used with \-C-\.
3372
3373 \\ALT@_CONFIG@_PREFIX\\ can be used to confine alternative configuration files
3374 to a directory to which only root has access. This prevents someone who has
3375 broken into the Exim account from running a privileged Exim with an arbitrary
3376 configuration file.
3377
3378 The \-C-\ facility is useful for ensuring that configuration files are
3379 syntactically correct, but cannot be used for test deliveries, unless the
3380 caller is privileged, or unless it is an exotic configuration that does not
3381 require privilege. No check is made on the owner or group of the files
3382 specified by this option.
3383
3384 .option D <<macro>>=<<value>>
3385 .index macro||setting on command line
3386 This option can be used to override macro definitions in the configuration file
3387 (see section ~~SECTmacrodefs). However, like \-C-\, if it is used by an
3388 unprivileged caller, it causes Exim to give up its root privilege.
3389 If \\DISABLE@_D@_OPTION\\ is defined in \(Local/Makefile)\, the use of \-D-\ is
3390 completely disabled, and its use causes an immediate error exit.
3391
3392 The entire option (including equals sign if present) must all be within one
3393 command line item. \-D-\ can be used to set the value of a macro to the empty
3394 string, in which case the equals sign is optional. These two commands are
3395 synonymous:
3396 .display asis
3397 exim -DABC  ...
3398 exim -DABC= ...
3399 .endd
3400 To include spaces in a macro definition item, quotes must be used. If you use
3401 quotes, spaces are permitted around the macro name and the equals sign. For
3402 example:
3403 .display asis
3404 exim '-D ABC = something' ...
3405 .endd
3406 \-D-\ may be repeated up to 10 times on a command line.
3407
3408 .option d <<debug options>>
3409 .index debugging||list of selectors
3410 .index debugging||\-d-\ option
3411 This option causes debugging information to be written to the standard
3412 error stream. It is restricted to admin users because debugging output may show
3413 database queries that contain password information. Also, the details of users'
3414 filter files should be protected. When \-d-\ is used, \-v-\ is assumed. If
3415 \-d-\ is given on its own, a lot of standard debugging data is output. This can
3416 be reduced, or increased to include some more rarely needed information, by
3417 following \-d-\ with a string made up of names preceded by plus or minus
3418 characters. These add or remove sets of debugging data, respectively. For
3419 example, \-d+filter-\ adds filter debugging, whereas \-d-all+filter-\ selects
3420 only filter debugging. The available debugging categories are:
3421 .display flow
3422 .tabs 21
3423 .
3424 . The odd formatting of the lines below is deliberate. It does not affect the
3425 . SGCAL output, but by putting in the space it keeps things aligned in the man
3426 . page that is automatically generated from this text.
3427 .
3428 acl           $t $rm{ACL interpretation}
3429 auth          $t $rm{authenticators}
3430 deliver       $t $rm{general delivery logic}
3431 dns           $t $rm{DNS lookups (see also resolver)}
3432 dnsbl         $t $rm{DNS black list (aka RBL) code}
3433 exec          $t $rm{arguments for \execv@(@)\ calls}
3434 expand        $t $rm{detailed debugging for string expansions}
3435 filter        $t $rm{filter handling}
3436 hints@_lookup  $t $rm{hints data lookups}
3437 host@_lookup   $t $rm{all types of name-to-IP address handling}
3438 ident         $t $rm{ident lookup}
3439 interface     $t $rm{lists of local interfaces}
3440 lists         $t $rm{matching things in lists}
3441 load          $t $rm{system load checks}
3442 local@_scan    $t $rm{can be used by \*local@_scan()*\ (see chapter ~~CHAPlocalscan)}
3443 lookup        $t $rm{general lookup code and all lookups}
3444 memory        $t $rm{memory handling}
3445 pid           $t $rm{add pid to debug output lines}
3446 process@_info  $t $rm{setting info for the process log}
3447 queue@_run     $t $rm{queue runs}
3448 receive       $t $rm{general message reception logic}
3449 resolver      $t $rm{turn on the DNS resolver's debugging output}
3450 retry         $t $rm{retry handling}
3451 rewrite       $t $rm{address rewriting}
3452 route         $t $rm{address routing}
3453 timestamp     $t $rm{add timestamp to debug output lines}
3454 tls           $t $rm{TLS logic}
3455 transport     $t $rm{transports}
3456 uid           $t $rm{changes of uid/gid and looking up uid/gid}
3457 verify        $t $rm{address verification logic}
3458
3459 all           $t $rm{all of the above, and also \-v-\}
3460 .endd
3461 .index resolver, debugging output
3462 .index DNS||resolver, debugging output
3463 The \"resolver"\ option produces output only if the DNS resolver was compiled
3464 with \\DEBUG\\ enabled. This is not the case in some operating systems. Also,
3465 unfortunately, debugging output from the DNS resolver is written to stdout
3466 rather than stderr.
3467
3468 The default (\-d-\ with no argument) omits \"expand"\, \"filter"\,
3469 \"interface"\, \"load"\, \"memory"\, \"pid"\, \"resolver"\, and \"timestamp"\.
3470 However, the \"pid"\ selector is forced when debugging is turned on for a
3471 daemon, which then passes it on to any re-executed Exims. Exim also
3472 automatically adds the pid to debug lines when several remote deliveries are
3473 run in parallel.
3474
3475 The \"timestamp"\ selector causes the current time to be inserted at the start
3476 of all debug output lines. This can be useful when trying to track down delays
3477 in processing.
3478
3479 If the \debug@_print\ option is set in any driver, it produces output whenever
3480 any debugging is selected, or if \-v-\ is used.
3481
3482 .em
3483 .option dd <<debug options>>
3484 This option behaves exactly like \-d-\ except when used on a command that
3485 starts a daemon process. In that case, debugging is turned off for the
3486 subprocesses that the daemon creates. Thus, it is useful for monitoring the
3487 behaviour of the daemon without creating as much output as full debugging does.
3488 .nem
3489
3490 .option dropcr
3491 This is an obsolete option that is now a no-op. It used to affect the way Exim
3492 handled CR and LF characters in incoming messages. What happens now is
3493 described in section ~~SECTlineendings.
3494
3495
3496 .option E
3497 .index bounce message||generating
3498 This option specifies that an incoming message is a locally-generated delivery
3499 failure report. It is used internally by Exim when handling delivery failures
3500 and is not intended for external use. Its only effect is to stop Exim
3501 generating certain messages to the postmaster, as otherwise message cascades
3502 could occur in some situations. As part of the same option, a message id may
3503 follow the characters \-E-\. If it does, the log entry for the receipt of the
3504 new message contains the id, following `R=', as a cross-reference.
3505
3506 .option e$it{x}
3507 There are a number of Sendmail options starting with \-oe-\ which seem to be
3508 called by various programs without the leading \o\ in the option. For example,
3509 the \vacation\ program uses \-eq-\. Exim treats all options of the form
3510 \-e$it{x}-\ as synonymous with the corresponding \-oe$it{x}-\ options.
3511
3512 .option F #<<string>>
3513 .index sender||name
3514 .index name||of sender
3515 This option sets the sender's full name for use when a locally-generated
3516 message is being accepted. In the absence of this option, the user's \*gecos*\
3517 entry from the password data is used. As users are generally permitted to alter
3518 their \*gecos*\ entries, no security considerations are involved. White space
3519 between \-F-\ and the <<string>> is optional.
3520
3521 .option f #<<address>>
3522 .index sender||address
3523 .index address||sender
3524 .index trusted user
3525 .index envelope sender
3526 .index user||trusted
3527 This option sets the address of the envelope sender of a locally-generated
3528 message (also known as the return path). The option can normally be used only
3529 by a trusted user, but \untrusted@_set@_sender\ can be set to allow untrusted
3530 users to use it. 
3531 .em
3532 Processes running as root or the Exim user are always trusted. Other
3533 trusted users are defined by the \trusted@_users\ or \trusted@_groups\ options.
3534
3535 In the absence of \-f-\, or if the caller is not trusted, the sender of a local
3536 message is set to the caller's login name at the default qualify domain.
3537
3538 There is one exception to the restriction on the use of \-f-\: an empty sender
3539 can be specified by any user, trusted or not,
3540 .nem
3541 to create a message that can never provoke a bounce. An empty sender can be
3542 specified either as an empty string, or as a pair of angle brackets with
3543 nothing between them, as in these examples of shell commands:
3544 .display asis
3545 exim -f '<>' user@domain
3546 exim -f "" user@domain
3547 .endd
3548 In addition, the use of \-f-\ is not restricted when testing a filter file with
3549 \-bf-\ or when testing or verifying addresses using the \-bt-\ or \-bv-\
3550 options.
3551
3552 Allowing untrusted users to change the sender address does not of itself make
3553 it possible to send anonymous mail. Exim still checks that the ::From:: header
3554 refers to the local user, and if it does not, it adds a ::Sender:: header,
3555 though this can be overridden by setting \no@_local@_from@_check\.
3556
3557 .index `From' line
3558 White space between \-f-\ and the <<address>> is optional
3559 (that is, they can be given as two arguments or one combined argument).
3560 The sender of a locally-generated message can also be set (when permitted) by
3561 an initial `From ' line in the message -- see the description of \-bm-\ above
3562 -- but if \-f-\ is also present, it overrides `From'.
3563
3564 .option G
3565 .index Sendmail compatibility||\-G-\ option ignored
3566 This is a Sendmail option which is ignored by Exim.
3567
3568 .option h #<<number>>
3569 .index Sendmail compatibility||\-h-\ option ignored
3570 This option is accepted for compatibility with Sendmail, but has no effect. (In
3571 Sendmail it overrides the `hop count' obtained by counting ::Received::
3572 headers.)
3573
3574 .option i
3575 .index Solaris||\*mail*\ command
3576 .index dot||in incoming, non-SMTP message
3577 This option, which has the same effect as \-oi-\, specifies that a dot on a
3578 line by itself should not terminate an incoming, non-SMTP message. I can find
3579 no documentation for this option in Solaris 2.4 Sendmail, but the \*mailx*\
3580 command in Solaris 2.4 uses it. See also \-ti-\.
3581
3582 .option M #<<message id>>#<<message id>> ...
3583 .index forcing delivery
3584 .index delivery||forcing attempt
3585 .index frozen messages||forcing delivery
3586 This option requests Exim to run a delivery attempt on each message in turn. If
3587 any of the messages are frozen, they are automatically thawed before the
3588 delivery attempt. The settings of \queue@_domains\, \queue@_smtp@_domains\, and
3589 \hold@_domains\ are ignored.
3590 .index hints database||overriding retry hints
3591 Retry hints for any of the addresses are
3592 overridden -- Exim tries to deliver even if the normal retry time has not yet
3593 been reached. This option requires the caller to be an admin user. However,
3594 there is an option called \prod@_requires@_admin\ which can be set false to
3595 relax this restriction (and also the same requirement for the \-q-\, \-R-\, and
3596 \-S-\ options).
3597
3598
3599 .option Mar #<<message id>>#<<address>>#<<address>> ...
3600 .index message||adding recipients
3601 .index recipient||adding
3602 This option requests Exim to add the addresses to the list of recipients of the
3603 message (`ar' for `add recipients'). The first argument must be a message id,
3604 and the remaining ones must be email addresses. However, if the message is
3605 active (in the middle of a delivery attempt), it is not altered. This option
3606 can be used only by an admin user.
3607
3608 .index SMTP||passed connection
3609 .index SMTP||multiple deliveries
3610 .index multiple SMTP deliveries
3611 .option MC #<<transport>>#<<hostname>>#<<sequence number>>#<<message id>>
3612 This option is not intended for use by external callers. It is used internally
3613 by Exim to invoke another instance of itself to deliver a waiting message using
3614 an existing SMTP connection, which is passed as the standard input. Details are
3615 given in chapter ~~CHAPSMTP. This must be the final option, and the caller must
3616 be root or the Exim user in order to use it.
3617
3618 .option MCA
3619 This option is not intended for use by external callers. It is used internally
3620 by Exim in conjunction with the \-MC-\ option. It signifies that the connection
3621 to the remote host has been authenticated.
3622
3623 .option MCP
3624 This option is not intended for use by external callers. It is used internally
3625 by Exim in conjunction with the \-MC-\ option. It signifies that the server to
3626 which Exim is connected supports pipelining.
3627
3628 .option MCQ #<<process id>> <<pipe fd>>
3629 This option is not intended for use by external callers. It is used internally
3630 by Exim in conjunction with the \-MC-\ option when the original delivery was
3631 started by a queue runner. It passes on the process id of the queue runner,
3632 together with the file descriptor number of an open pipe. Closure of the pipe
3633 signals the final completion of the sequence of processes that are passing
3634 messages through the same SMTP connection.
3635
3636 .option MCS
3637 This option is not intended for use by external callers. It is used internally
3638 by Exim in conjunction with the \-MC-\ option, and passes on the fact that the
3639 SMTP \\SIZE\\ option should be used on messages delivered down the existing
3640 connection.
3641
3642 .option MCT
3643 This option is not intended for use by external callers. It is used internally
3644 by Exim in conjunction with the \-MC-\ option, and passes on the fact that the
3645 host to which Exim is connected supports TLS encryption.
3646
3647 .option Mc #<<message id>>#<<message id>> ...
3648 .index hints database||not overridden by \-Mc-\
3649 .index delivery||manually started, not forced
3650 This option requests Exim to run a delivery attempt on each message in turn,
3651 but unlike the \-M-\ option, it does check for retry hints, and respects any
3652 that are found. This option is not very useful to external callers. It is
3653 provided mainly for internal use by Exim when it needs to re-invoke itself in
3654 order to regain root privilege for a delivery (see chapter ~~CHAPsecurity).
3655 However, \-Mc-\ can be useful when testing, in order to run a delivery that
3656 respects retry times and other options such as \hold@_domains\ that are
3657 overridden when \-M-\ is used. Such a delivery does not count as a queue run.
3658 If you want to run a specific delivery as if in a queue run, you should use
3659 \-q-\ with a message id argument. A distinction between queue run deliveries
3660 and other deliveries is made in one or two places.
3661
3662 .option Mes #<<message id>>#<<address>>
3663 .index message||changing sender
3664 .index sender||changing
3665 This option requests Exim to change the sender address in the message to the
3666 given address, which must be a fully qualified address or `<>' (`es' for `edit
3667 sender'). There must be exactly two arguments. The first argument must be a
3668 message id, and the second one an email address. However, if the message is
3669 active (in the middle of a delivery attempt), its status is not altered. This
3670 option can be used only by an admin user.
3671
3672 .option Mf #<<message id>>#<<message id>> ...
3673 .index freezing messages
3674 .index message||manually freezing
3675 This option requests Exim to mark each listed message as `frozen'. This
3676 prevents any delivery attempts taking place until the message is `thawed',
3677 either manually or as a result of the \auto@_thaw\ configuration option.
3678 However, if any of the messages are active (in the middle of a delivery
3679 attempt), their status is not altered. This option can be used only by an admin
3680 user.
3681
3682 .option Mg #<<message id>>#<<message id>> ...
3683 .index giving up on messages
3684 .index message||abandoning delivery attempts
3685 .index delivery||abandoning further attempts
3686 This option requests Exim to give up trying to deliver the listed messages,
3687 including any that are frozen. However, if any of the messages are active,
3688 their status is not altered.
3689 For non-bounce messages, a delivery error message is sent to the sender,
3690 containing the text `cancelled by administrator'. Bounce messages are just
3691 discarded.
3692 This option can be used only by an admin user.
3693
3694 .option Mmad #<<message id>>#<<message id>> ...
3695 .index delivery||cancelling all
3696 This option requests Exim to mark all the recipient addresses in the messages
3697 as already delivered (`mad' for `mark all delivered'). However, if any message
3698 is active (in the middle of a delivery attempt), its status is not altered.
3699 This option can be used only by an admin user.
3700
3701 .option Mmd #<<message id>>#<<address>>#<<address>> ...
3702 .index delivery||cancelling by address
3703 .index recipient||removing
3704 .index removing recipients
3705 This option requests Exim to mark the given addresses as already delivered
3706 (`md' for `mark delivered'). The first argument must be a message id, and the
3707 remaining ones must be email addresses. These are matched to recipient
3708 addresses in the message in a case-sensitive manner. If the message is active
3709 (in the middle of a delivery attempt), its status is not altered. This option
3710 can be used only by an admin user.
3711
3712 .option Mrm #<<message id>>#<<message id>> ...
3713 .index removing messages
3714 .index abandoning mail
3715 .index message||manually discarding
3716 This option requests Exim to remove the given messages from the queue. No
3717 bounce messages are sent; each message is simply forgotten. However, if any of
3718 the messages are active, their status is not altered. This option can be used
3719 only by an admin user or by the user who originally caused the message to be
3720 placed on the queue.
3721
3722 .option Mt #<<message id>>#<<message id>> ...
3723 .index thawing messages
3724 .index unfreezing messages
3725 .index frozen messages||thawing
3726 .index message||thawing frozen
3727 This option requests Exim to `thaw' any of the listed messages that are
3728 `frozen', so that delivery attempts can resume. However, if any of the messages
3729 are active, their status is not altered. This option can be used only by an
3730 admin user.
3731
3732 .option Mvb #<<message id>>
3733 .index listing||message body
3734 .index message||listing body of
3735 This option causes the contents of the message body (-D) spool file to be
3736 written to the standard output. This option can be used only by an admin user.
3737
3738 .option Mvh #<<message id>>
3739 .index listing||message headers
3740 .index header lines||listing
3741 .index message||listing header lines
3742 This option causes the contents of the message headers (-H) spool file to be
3743 written to the standard output. This option can be used only by an admin user.
3744
3745 .option Mvl #<<message id>>
3746 .index listing||message log
3747 .index message||listing message log
3748 This option causes the contents of the message log spool file to be written to
3749 the standard output. This option can be used only by an admin user.
3750
3751 .option m
3752 This is apparently a synonym for \-om-\ that is accepted by Sendmail, so Exim
3753 treats it that way too.
3754
3755 .option N
3756 .index debugging||\-N-\ option
3757 .index debugging||suppressing delivery
3758 This is a debugging option that inhibits delivery of a message at the transport
3759 level. It implies \-v-\. Exim goes through many of the motions of delivery --
3760 it just doesn't actually transport the message, but instead behaves as if it
3761 had successfully done so. However, it does not make any updates to the retry
3762 database, and the log entries for deliveries are flagged with `$*$>' rather
3763 than `=>'.
3764
3765 Because \-N-\ discards any message to which it applies, only root or the Exim
3766 user are allowed to use it with \-bd-\, \-q-\, \-R-\ or \-M-\. In other words,
3767 an ordinary user can use it only when supplying an incoming message to which it
3768 will apply. Although transportation never fails when \-N-\ is set, an address
3769 may be deferred because of a configuration problem on a transport, or a routing
3770 problem. Once \-N-\ has been used for a delivery attempt, it sticks to the
3771 message, and applies to any subsequent delivery attempts that may happen for
3772 that message.
3773
3774 .option n
3775 .index Sendmail compatibility||\-n-\ option ignored
3776 This option is interpreted by Sendmail to mean `no aliasing'. It is ignored by
3777 Exim.
3778
3779 .option O #<<data>>
3780 This option is interpreted by Sendmail to mean `set option`. It is ignored by
3781 Exim.
3782
3783 .option oA #<<file name>>
3784 .index Sendmail compatibility||\-oA-\ option
3785 This option is used by Sendmail in conjunction with \-bi-\ to specify an
3786 alternative alias file name. Exim handles \-bi-\ differently; see the
3787 description above.
3788
3789 .index SMTP||passed connection
3790 .option oB #<<n>>
3791 .index SMTP||multiple deliveries
3792 .index multiple SMTP deliveries
3793 This is a debugging option which limits the maximum number of messages that can
3794 be delivered down one SMTP connection, overriding the value set in any \%smtp%\
3795 transport. If <<n>> is omitted, the limit is set to 1.
3796
3797 .option odb
3798 .index background delivery
3799 .index delivery||in the background
3800 This option applies to all modes in which Exim accepts incoming messages,
3801 including the listening daemon. It requests `background' delivery of such
3802 messages, which means that the accepting process automatically starts a
3803 delivery process for each message received, but does not wait for the delivery
3804 processes to finish.
3805 .em
3806 When all the messages have been received, the reception process exits, leaving 
3807 the delivery processes to finish in their own time. The standard output and
3808 error streams are closed at the start of each delivery process.
3809 .nem
3810 This is the default action if none of the \-od-\ options are present.
3811
3812 If one of the queueing options in the configuration file
3813 (\queue@_only\ or \queue@_only@_file\, for example) is in effect, \-odb-\
3814 overrides it if \queue@_only@_override\ is set true, which is the default
3815 setting. If \queue@_only@_override\ is set false, \-odb-\ has no effect.
3816
3817 .option odf
3818 .index foreground delivery
3819 .index delivery||in the foreground
3820 This option requests `foreground' (synchronous) delivery when Exim has accepted
3821 a locally-generated message. (For the daemon it is exactly the same as
3822 \-odb-\.) A delivery process is automatically started to deliver the
3823 message, and Exim waits for it to complete before proceeding.
3824 .em
3825 The original Exim reception process does not finish until the delivery 
3826 process for the final message has ended. The standard error stream is left open
3827 during deliveries.
3828 .nem
3829 However, like \-odb-\, this option has no effect if \queue@_only@_override\ is
3830 false and one of the queueing options in the configuration file is in effect.
3831
3832 .em
3833 If there is a temporary delivery error during foreground delivery, the message 
3834 is left on the queue for later delivery, and the original reception process 
3835 exists. See chapter ~~CHAPnonqueueing for a way of setting up a restricted 
3836 configuration that never queues messages.
3837 .nem
3838
3839 .option odi
3840 This option is synonymous with \-odf-\. It is provided for compatibility with
3841 Sendmail.
3842
3843 .option odq
3844 .index non-immediate delivery
3845 .index delivery||suppressing immediate
3846 .index queueing incoming messages
3847 This option applies to all modes in which Exim accepts incoming messages,
3848 including the listening daemon. It specifies that the accepting process should
3849 not automatically start a delivery process for each message received. Messages
3850 are placed on the queue, and remain there until a subsequent queue runner
3851 process encounters them.
3852 There are several configuration options (such as \queue@_only\) that can be
3853 used to queue incoming messages under certain conditions. This option overrides
3854 all of them and also \-odqs-\. It always forces queueing.
3855
3856 .option odqs
3857 .index SMTP||delaying delivery
3858 This option is a hybrid between \-odb-\/\-odi-\ and \-odq-\.
3859 However, like \-odb-\ and \-odi-\, this option has no effect if
3860 \queue@_only@_override\ is false and one of the queueing options in the
3861 configuration file is in effect.
3862
3863 When \-odqs-\ does operate, a delivery process is started for each incoming
3864 message, in the background by default, but in the foreground if \-odi-\ is also
3865 present.
3866 The recipient addresses are routed, and local deliveries are done in the normal
3867 way. However, if any SMTP deliveries are required, they are not done at this
3868 time, so the message remains on the queue until a subsequent queue runner
3869 process encounters it. Because routing was done, Exim knows which messages are
3870 waiting for which hosts, and so a number of messages for the same host can be
3871 sent in a single SMTP connection. The \queue@_smtp@_domains\ configuration
3872 option has the same effect for specific domains. See also the \-qq-\ option.
3873
3874 .option oee
3875 .index error||reporting
3876 If an error is detected while a non-SMTP message is being received (for
3877 example, a malformed address), the error is reported to the sender in a mail
3878 message.
3879 .index return code||for \-oee-\
3880 Provided this error message is successfully sent, the Exim receiving process
3881 exits with a return code of zero. If not, the return code is 2 if the problem
3882 is that the original message has no recipients, or 1 any other error. This is
3883 the default \-oe$it{x}-\ option if Exim is called as \*rmail*\.
3884
3885 .option oem
3886 .index error||reporting
3887 .index return code||for \-oem-\
3888 This is the same as \-oee-\, except that Exim always exits with a non-zero
3889 return code, whether or not the error message was successfully sent.
3890 This is the default \-oe$it{x}-\ option, unless Exim is called as \*rmail*\.
3891
3892 .option oep
3893 .index error||reporting
3894 If an error is detected while a non-SMTP message is being received, the
3895 error is reported by writing a message to the standard error file (stderr).
3896 .index return code||for \-oep-\
3897 The return code is 1 for all errors.
3898
3899 .option oeq
3900 .index error||reporting
3901 This option is supported for compatibility with Sendmail, but has the same
3902 effect as \-oep-\.
3903
3904 .option oew
3905 .index error||reporting
3906 This option is supported for compatibility with Sendmail, but has the same
3907 effect as \-oem-\.
3908
3909 .option oi
3910 .index dot||in incoming, non-SMTP message
3911 This option, which has the same effect as \-i-\, specifies that a dot on a line
3912 by itself should not terminate an incoming, non-SMTP message.
3913 Otherwise, a single dot does terminate, though Exim does no special processing
3914 for other lines that start with a dot.
3915 This option is set by default if Exim is called as \*rmail*\. See also \-ti-\.
3916
3917 .option oitrue
3918 This option is treated as synonymous with \-oi-\.
3919
3920 .option oMa #<<host address>>
3921 .index sender||host address, specifying for local message
3922 A number of options starting with \-oM-\ can be used to set values associated
3923 with remote hosts on locally-submitted messages (that is, messages not received
3924 over TCP/IP). These options can be used by any caller in conjunction with the
3925 \-bh-\,
3926 \-be-\,
3927 \-bf-\, \-bF-\, \-bt-\, or \-bv-\ testing options. In other circumstances, they
3928 are ignored unless the caller is trusted.
3929
3930 The \-oMa-\ option sets the sender host address. This may include a port number
3931 at the end, after a full stop (period). For example:
3932 .display asis
3933 exim -bs -oMa 10.9.8.7.1234
3934 .endd
3935 An alternative syntax is to enclose the IP address in square brackets, followed
3936 by a colon and the port number:
3937 .display asis
3938 exim -bs -oMa [10.9.8.7]:1234
3939 .endd
3940 The IP address is placed in the \$sender@_host@_address$\ variable, and the
3941 port, if present, in \$sender@_host@_port$\.
3942
3943 .option oMaa #<<name>>
3944 .index authentication||name, specifying for local message
3945 See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMaa-\
3946 option sets the value of \$sender@_host@_authenticated$\ (the authenticator
3947 name). See chapter ~~CHAPSMTPAUTH for a discussion of SMTP authentication.
3948
3949 .option oMai #<<string>>
3950 .index authentication||id, specifying for local message
3951 See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMai-\
3952 option sets the
3953 value of \$authenticated@_id$\ (the id that was authenticated).
3954 This overrides the default value (the caller's login id) for messages from
3955 local sources. See chapter ~~CHAPSMTPAUTH for a discussion of authenticated
3956 ids.
3957
3958 .option oMas #<<address>>
3959 .index authentication||sender, specifying for local message
3960 See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMas-\
3961 option sets the authenticated sender value
3962 in \$authenticated@_sender$\.
3963 It overrides the sender address that is created from the caller's login id for
3964 messages from local sources. See chapter ~~CHAPSMTPAUTH for a discussion of
3965 authenticated senders.
3966
3967 .option oMi #<<interface address>>
3968 .index interface||address, specifying for local message
3969 See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMi-\
3970 option sets the IP interface address value. A port number may be included,
3971 using the same syntax as for \-oMa-\.
3972 The interface address is placed in \$interface@_address$\ and the port number,
3973 if present, in \$interface@_port$\.
3974
3975 .option oMr #<<protocol name>>
3976 .index protocol||incoming, specifying for local message
3977 See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMr-\
3978 option sets the received protocol value that is stored in
3979 \$received@_protocol$\. However, this applies only when \-bs-\ is not used. For
3980 interactive SMTP input (\-bs-\), the protocol is always
3981 .em
3982 `local-' followed by one of the standard SMTP protocol names (see the 
3983 description of \$received@_protocol$\ in section ~~SECTexpvar).
3984 .nem
3985 For \-bS-\ (batch SMTP) however, the protocol can be set by \-oMr-\.
3986
3987 .option oMs #<<host name>>
3988 .index sender||host name, specifying for local message
3989 See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMs-\
3990 option sets the sender host name
3991 in \$sender@_host@_name$\. When this option is present, Exim does not attempt
3992 to look up a host name from an IP address; it uses the name it is given.
3993
3994 .option oMt #<<ident string>>
3995 .index sender||ident string, specifying for local message
3996 See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMt-\
3997 option sets the sender ident value
3998 in \$sender@_ident$\.
3999 The default setting for local callers is the login id of the calling process.
4000
4001 .option om
4002 .index Sendmail compatibility||\-om-\ option ignored
4003 In Sendmail, this option means `me too', indicating that the sender of a
4004 message should receive a copy of the message if the sender appears in an alias
4005 expansion. Exim always does this, so the option does nothing.
4006
4007 .option oo
4008 .index Sendmail compatibility||\-oo-\ option ignored
4009 This option is ignored. In Sendmail it specifies `old style headers', whatever
4010 that means.
4011
4012 .option oP #<<path>>
4013 .index pid (process id)||of daemon
4014 .index daemon||process id (pid)
4015 This option is useful only in conjunction with \-bd-\ or \-q-\ with a time
4016 value. The option specifies the file to which the process id of the daemon is
4017 written. When \-oX-\ is used with \-bd-\, or when \-q-\ with a time is used
4018 without \-bd-\, this is the only way of causing Exim to write a pid file,
4019 because in those cases, the normal pid file is not used.
4020
4021 .option or #<<time>>
4022 .index timeout||for non-SMTP input
4023 This option sets a timeout value for incoming non-SMTP messages. If it is not
4024 set, Exim will wait forever for the standard input. The value can also be set
4025 by the \receive@_timeout\ option. The format used for specifying times is
4026 described in section ~~SECTtimeformat.
4027
4028 .option os #<<time>>
4029 .index timeout||for SMTP input
4030 .index SMTP||timeout, input
4031 This option sets a timeout value for incoming SMTP messages. The timeout
4032 applies to each SMTP command and block of data. The value can also be set by
4033 the \smtp@_receive@_timeout\ option; it defaults to 5 minutes. The format used
4034 for specifying times is described in section ~~SECTtimeformat.
4035
4036 .option ov
4037 This option has exactly the same effect as \-v-\.
4038
4039 .option oX #<<number or string>>
4040 .index TCP/IP||setting listening ports
4041 .index TCP/IP||setting listening interfaces
4042 .index port||receiving TCP/IP
4043 This option is relevant only when the \-bd-\ (start listening daemon) option is
4044 also given. It controls which ports and interfaces the daemon uses. Details of
4045 the syntax, and how it interacts with configuration file options, are given in
4046 chapter ~~CHAPinterfaces. When \-oX-\ is used to start a daemon, no pid file is
4047 written unless \-oP-\ is also present to specify a pid file name.
4048
4049 .option pd
4050 .index Perl||starting the interpreter
4051 This option applies when an embedded Perl interpreter is linked with Exim (see
4052 chapter ~~CHAPperl). It overrides the setting of the \perl@_at@_start\ option,
4053 forcing the starting of the interpreter to be delayed until it is needed.
4054
4055 .option ps
4056 .index Perl||starting the interpreter
4057 This option applies when an embedded Perl interpreter is linked with Exim (see
4058 chapter ~~CHAPperl). It overrides the setting of the \perl@_at@_start\ option,
4059 forcing the starting of the interpreter to occur as soon as Exim is started.
4060
4061 .option p<<rval>>:<<sval>>
4062 For compatibility with Sendmail, this option
4063 is equivalent to
4064 .display
4065 -oMr <<rval>> -oMs <<sval>>
4066 .endd
4067 It sets the incoming protocol and host name (for trusted callers). The
4068 host name and its colon can be omitted when only the protocol is to be set.
4069 Note the Exim already has two private options, \-pd-\ and \-ps-\, that refer to
4070 embedded Perl. It is therefore impossible to set a protocol value of \"p"\ or
4071 \"s"\ using this option (but that does not seem a real limitation).
4072
4073 .option q
4074 .index queue runner||starting manually
4075 This option is normally restricted to admin users. However, there is a
4076 configuration option called \prod@_requires@_admin\ which can be set false to
4077 relax this restriction (and also the same requirement for the \-M-\, \-R-\, and
4078 \-S-\ options).
4079
4080 .index queue runner||description of operation
4081 The \-q-\ option starts one queue runner process. This scans the queue of
4082 waiting messages, and runs a delivery process for each one in turn. It waits
4083 for each delivery process to finish before starting the next one. A delivery
4084 process may not actually do any deliveries if the retry times for the addresses
4085 have not been reached. Use \-qf-\ (see below) if you want to override this.
4086 .index SMTP||passed connection
4087 .index SMTP||multiple deliveries
4088 .index multiple SMTP deliveries
4089 If the delivery process spawns other processes to deliver other messages down
4090 passed SMTP connections, the queue runner waits for these to finish before
4091 proceeding.
4092
4093 When all the queued messages have been considered, the original queue runner
4094 process terminates. In other words, a single pass is made over the waiting
4095 mail, one message at a time. Use \-q-\ with a time (see below) if you want this
4096 to be repeated periodically.
4097
4098 Exim processes the waiting messages in an unpredictable order. It isn't very
4099 random, but it is likely to be different each time, which is all that matters.
4100 If one particular message screws up a remote MTA, other messages to the same
4101 MTA have a chance of getting through if they get tried first.
4102
4103 It is possible to cause the messages to be processed in lexical message id
4104 order, which is essentially the order in which they arrived, by setting the
4105 \queue@_run@_in@_order\ option, but this is not recommended for normal use.
4106
4107 .option q <<qflags>>
4108 The \-q-\ option may be followed by one or more flag letters that change its
4109 behaviour. They are all optional, but if more than one is present, they must
4110 appear in the correct order. Each flag is described in a separate item below.
4111
4112 .option qq...
4113 .index queue||double scanning
4114 .index queue||routing
4115 .index routing||whole queue before delivery
4116 An option starting with \-qq-\ requests a two-stage queue run. In the first
4117 stage, the queue is scanned as if the \queue@_smtp@_domains\ option matched
4118 every domain. Addresses are routed, local deliveries happen, but no remote
4119 transports are run.
4120 .index hints database||remembering routing
4121 The hints database that remembers which messages are
4122 waiting for specific hosts is updated, as if delivery to those hosts had been
4123 deferred. After this is complete, a second, normal queue scan happens, with
4124 routing and delivery taking place as normal. Messages that are routed to the
4125 same host should mostly be delivered down a single SMTP
4126 .index SMTP||passed connection
4127 .index SMTP||multiple deliveries
4128 .index multiple SMTP deliveries
4129 connection because of the hints that were set up during the first queue scan.
4130 This option may be useful for hosts that are connected to the Internet
4131 intermittently.
4132
4133 .option q[q]i...
4134 .index queue||initial delivery
4135 If the \*i*\ flag is present, the queue runner runs delivery processes only for
4136 those messages that haven't previously been tried. (\*i*\ stands for `initial
4137 delivery'.) This can be helpful if you are putting messages on the queue using
4138 \-odq-\ and want a queue runner just to process the new messages.
4139
4140 .option q[q][i]f...
4141 .index queue||forcing delivery
4142 .index delivery||forcing in queue run
4143 If one \*f*\ flag is present, a delivery attempt is forced for each non-frozen
4144 message, whereas without \f\ only those non-frozen addresses that have passed
4145 their retry times are tried.
4146
4147 .option q[q][i]ff...
4148 .index frozen messages||forcing delivery
4149 If \*ff*\ is present, a delivery attempt is forced for every message, whether
4150 frozen or not.
4151
4152 .option q[q][i][f[f]]l
4153 .index queue||local deliveries only
4154 The \*l*\ (the letter `ell') flag specifies that only local deliveries are to be
4155 done. If a message requires any remote deliveries, it remains on the queue for
4156 later delivery.
4157
4158 .option q <<qflags>>#<<start id>>#<<end id>>
4159 .index queue||delivering specific messages
4160 When scanning the queue, Exim can be made to skip over messages whose ids are
4161 lexically less than a given value by following the \-q-\ option with a starting
4162 message id. For example:
4163 .display
4164 exim -q 0t5C6f-0000c8-00
4165 .endd
4166 Messages that arrived earlier than \"0t5C6f-0000c8-00"\ are not inspected. If a
4167 second message id is given, messages whose ids are lexically greater than it
4168 are also skipped. If the same id is given twice, for example,
4169 .display
4170 exim -q 0t5C6f-0000c8-00 0t5C6f-0000c8-00
4171 .endd
4172 just one delivery process is started, for that message. This differs from \-M-\
4173 in that retry data is respected, and it also differs from \-Mc-\ in that it
4174 counts as a delivery from a queue run. Note that the selection mechanism does
4175 not affect the order in which the messages are scanned. There are also other
4176 ways of selecting specific sets of messages for delivery in a queue run -- see
4177 \-R-\ and \-S-\.
4178
4179 .option q <<qflags>><<time>>
4180 .index queue runner||starting periodically
4181 .index periodic queue running
4182 When a time value is present, the \-q-\ option causes Exim to run as a daemon,
4183 starting a queue runner process at intervals specified by the given time value
4184 (whose format is described in section ~~SECTtimeformat). This form of the \-q-\
4185 option is commonly combined with the \-bd-\ option, in which case a single
4186 daemon process handles both functions. A common way of starting up a combined
4187 daemon at system boot time is to use a command such as
4188 .display
4189 /usr/exim/bin/exim -bd -q30m
4190 .endd
4191 Such a daemon listens for incoming SMTP calls, and also starts a queue runner
4192 process every 30 minutes.
4193
4194 When a daemon is started by \-q-\ with a time value, but without \-bd-\, no pid
4195 file is written unless one is explicitly requested by the \-oP-\ option.
4196
4197 .option qR <<rsflags>>#<<string>>
4198 This option is synonymous with \-R-\. It is provided for Sendmail
4199 compatibility.
4200
4201 .option qS <<rsflags>>#<<string>>
4202 This option is synonymous with \-S-\.
4203
4204 .option R <<rsflags>>#<<string>>
4205 .index queue runner||for specific recipients
4206 .index delivery||to given domain
4207 .index domain||delivery to
4208 The <<rsflags>> may be empty, in which case the white space before the string
4209 is optional, unless the string is \*f*\, \*ff*\, \*r*\, \*rf*\, or \*rff*\,
4210 which are the possible values for <<rsflags>>. White space is required if
4211 <<rsflags>> is not empty.
4212
4213 This option is similar to \-q-\ with no time value, that is, it causes Exim to
4214 perform a single queue run, except that, when scanning the messages on the
4215 queue, Exim processes only those that have at least one undelivered recipient
4216 address containing the given string, which is checked in a case-independent
4217 way. If the <<rsflags>> start with \*r*\, <<string>> is interpreted as a regular
4218 expression; otherwise it is a literal string.
4219
4220 Once a message is selected, all its addresses are processed. For the first
4221 selected message, Exim overrides any retry information and forces a delivery
4222 attempt for each undelivered address. This means that if delivery of any
4223 address in the first message is successful, any existing retry information is
4224 deleted, and so delivery attempts for that address in subsequently selected
4225 messages (which are processed without forcing) will run. However, if delivery
4226 of any address does not succeed, the retry information is updated, and in
4227 subsequently selected messages, the failing address will be skipped.
4228
4229 If the <<rsflags>> contain \*f*\ or \*ff*\, the delivery forcing applies to all
4230 selected messages, not just the first;
4231 .index frozen messages||forcing delivery
4232 frozen messages are included when \*ff*\ is present.
4233
4234 The \-R-\ option makes it straightforward to initiate delivery of all messages
4235 to a given domain after a host has been down for some time. When the SMTP
4236 command \\ETRN\\ is accepted by its ACL (see chapter ~~CHAPACL), its default
4237 effect is to run Exim with the \-R-\ option, but it can be configured to run an
4238 arbitrary command instead.
4239
4240 .option r
4241 This is a documented (for Sendmail) obsolete alternative name for \-f-\.
4242
4243 .index delivery||from given sender
4244 .option S <<rsflags>>#<<string>>
4245 .index queue runner||for specific senders
4246 This option acts like \-R-\ except that it checks the string against each
4247 message's sender instead of against the recipients. If \-R-\ is also set, both
4248 conditions must be met for a message to be selected. If either of the options
4249 has \*f*\ or \*ff*\ in its flags, the associated action is taken.
4250
4251 .option Tqt#<<times>>
4252 This an option that is exclusively for use by the Exim testing suite.
4253 It is not recognized when Exim is run normally. It allows for the setting up
4254 of explicit `queue times' so that various warning/retry features can be
4255 tested.
4256
4257 .option t
4258 .index recipient||extracting from header lines
4259 .index ::Bcc:: header line
4260 .index ::Cc:: header line
4261 .index ::To:: header line
4262 When Exim is receiving a locally-generated, non-SMTP message on its standard
4263 input, the \-t-\ option causes the recipients of the message to be obtained
4264 from the ::To::, ::Cc::, and ::Bcc:: header lines in the message instead of from
4265 the command arguments. The addresses are extracted before any rewriting takes
4266 place.
4267
4268 .index Sendmail compatibility||\-t-\ option
4269 If the command has any arguments, they specify addresses to which the message
4270 is $it{not} to be delivered. That is, the argument addresses are removed from
4271 the recipients list obtained from the headers. This is compatible with Smail 3
4272 and in accordance with the documented behaviour of several versions of
4273 Sendmail, as described in man pages on a number of operating systems (e.g.
4274 Solaris 8, IRIX 6.5, HP-UX 11). However, some versions of Sendmail $it{add}
4275 argument addresses to those obtained from the headers, and the O'Reilly
4276 Sendmail book documents it that way. Exim can be made to add argument addresses
4277 instead of subtracting them by setting the option
4278 \extract__addresses__remove__arguments\ false.
4279
4280 If a ::Bcc:: header line is present, it is removed from the message unless
4281 there is no ::To:: or ::Cc::, in which case a ::Bcc:: line with no data is
4282 created. This is necessary for conformity with the original RFC 822 standard;
4283 the requirement has been removed in RFC 2822, but that is still very new.
4284
4285 .index \Resent@-\ header lines||with \-t-\
4286 If there are any \Resent@-\ header lines in the message, Exim extracts
4287 recipients from all ::Resent-To::, ::Resent-Cc::, and ::Resent-Bcc:: header
4288 lines instead of from ::To::, ::Cc::, and ::Bcc::. This is for compatibility
4289 with Sendmail and other MTAs. (Prior to release 4.20, Exim gave an error if
4290 \-t-\ was used in conjunction with \Resent@-\ header lines.)
4291
4292 RFC 2822 talks about different sets of \Resent@-\ header lines (for when a
4293 message is resent several times). The RFC also specifies that they should be
4294 added at the front of the message, and separated by ::Received:: lines. It is
4295 not at all clear how \-t-\ should operate in the present of multiple sets,
4296 nor indeed exactly what constitutes a `set'.
4297 In practice, it seems that MUAs do not follow the RFC. The \Resent@-\ lines are
4298 often added at the end of the header, and if a message is resent more than
4299 once, it is common for the original set of \Resent@-\ headers to be renamed as
4300 \X-Resent@-\ when a new set is added. This removes any possible ambiguity.
4301
4302 .option ti
4303 This option is exactly equivalent to \-t-\ \-i-\. It is provided for
4304 compatibility with Sendmail.
4305
4306 .option tls-on-connect
4307 .index TLS||use without STARTTLS
4308 .index TLS||automatic start
4309 This option is available when Exim is compiled with TLS support. 
4310 .em
4311 It forces all incoming SMTP connections to behave as if the incoming port is
4312 listed in the \tls@_on@_connect@_ports\ option. See section ~~SECTsupobssmt and 
4313 chapter ~~CHAPTLS for further details.
4314 .nem
4315
4316 .option U
4317 .index Sendmail compatibility||\-U-\ option ignored
4318 Sendmail uses this option for `initial message submission', and its
4319 documentation states that in future releases, it may complain about
4320 syntactically invalid messages rather than fixing them when this flag is not
4321 set. Exim ignores this option.
4322
4323 .option v
4324 This option causes Exim to write information to the standard error stream,
4325 describing what it is doing. In particular, it shows the log lines for
4326 receiving and delivering a message, and if an SMTP connection is made, the SMTP
4327 dialogue is shown. Some of the log lines shown may not actually be written to
4328 the log if the setting of \log@_selector\ discards them. Any relevant selectors
4329 are shown with each log line. If none are shown, the logging is unconditional.
4330
4331 .option x
4332 AIX uses \-x-\ for a private purpose (`mail from a local mail program has
4333 National Language Support extended characters in the body of the mail item').
4334 It sets \-x-\ when calling the MTA from its \mail\ command. Exim ignores this
4335 option.
4336
4337 .endoptions
4338
4339
4340
4341 .
4342 .
4343 .
4344 .
4345 . ============================================================================
4346 .chapter The Exim run time configuration file
4347 .set runningfoot "configuration file"
4348 .rset CHAPconf ~~chapter
4349
4350 .index run time configuration
4351 .index configuration file||general description
4352 .index \\CONFIGURE@_FILE\\
4353 .index configuration file||errors in
4354 .index error||in configuration file
4355 .index return code||for bad configuration
4356 Exim uses a single run time configuration file that is read whenever an Exim
4357 binary is executed. Note that in normal operation, this happens frequently,
4358 because Exim is designed to operate in a distributed manner, without central
4359 control.
4360
4361 .em
4362 If a syntax error is detected while reading the configuration file, Exim
4363 writes a message on the standard error, and exits with a non-zero return code.
4364 The message is also written to the panic log. \**Note**\: only simple syntax 
4365 errors can be detected at this time. The values of any expanded options are
4366 not checked until the expansion happens, even when the expansion does not
4367 actually alter the string.
4368 .nem
4369
4370
4371 The name of the configuration file is compiled into the binary for security
4372 reasons, and is specified by the \\CONFIGURE@_FILE\\ compilation option. In
4373 most configurations, this specifies a single file. However, it is permitted to
4374 give a colon-separated list of file names, in which case Exim uses the first
4375 existing file in the list.
4376
4377 .index \\EXIM@_USER\\
4378 .index \\EXIM@_GROUP\\
4379 .index \\CONFIGURE@_OWNER\\
4380 .index \\CONFIGURE@_GROUP\\
4381 .index configuration file||ownership
4382 .index ownership||configuration file
4383 The run time configuration file must be owned by root or by the user that is
4384 specified at compile time by the \\EXIM@_USER\\ option, or by the user that is
4385 specified at compile time by the \\CONFIGURE@_OWNER\\ option (if set). The
4386 configuration file must not be world-writeable or group-writeable, unless its
4387 group is the one specified at compile time by the \\EXIM@_GROUP\\ option
4388 .em
4389 or by the \\CONFIGURE@_GROUP\\ option.
4390 .nem
4391
4392 \**Warning**\: In a conventional configuration, where the Exim binary is setuid
4393 to root, anybody who is able to edit the run time configuration file has an
4394 easy way to run commands as root. If you make your mail administrators members
4395 of the Exim group, but do not trust them with root, make sure that the run time
4396 configuration is not group writeable.
4397
4398 A default configuration file, which will work correctly in simple situations,
4399 is provided in the file \(src/configure.default)\. If \\CONFIGURE@_FILE\\
4400 defines just one file name, the installation process copies the default
4401 configuration to a new file of that name if it did not previously exist. If
4402 \\CONFIGURE@_FILE\\ is a list, no default is automatically installed. Chapter
4403 ~~CHAPdefconfil is a `walk-through' discussion of the default configuration.
4404
4405
4406 .section Using a different configuration file
4407 .index configuration file||alternate
4408 A one-off alternate configuration can be specified by the \-C-\ command line
4409 option, which may specify a single file or a list of files. However, when \-C-\
4410 is used, Exim gives up its root privilege, unless called by root or the Exim
4411 user (or unless the argument for \-C-\ is identical to the built-in value from
4412 \\CONFIGURE@_FILE\\). \-C-\ is useful mainly for checking the syntax of
4413 configuration files before installing them. No owner or group checks are done
4414 on a configuration file specified by \-C-\.
4415
4416 The privileged use of \-C-\ by the Exim user can be locked out by setting
4417 \\ALT@_CONFIG@_ROOT@_ONLY\\ in \(Local/Makefile)\ when building Exim. However,
4418 if you do this, you also lock out the possibility of testing a
4419 configuration using \-C-\ right through message reception and delivery, even if
4420 the caller is root. The reception works, but by that time, Exim is running as
4421 the Exim user, so when it re-execs to regain privilege for the delivery, the
4422 use of \-C-\ causes privilege to be lost. However, root can test reception and
4423 delivery using two separate commands (one to put a message on the queue, using
4424 \-odq-\, and another to do the delivery, using \-M-\).
4425
4426 If \\ALT@_CONFIG@_PREFIX\\ is defined \(in Local/Makefile)\, it specifies a
4427 prefix string with which any file named in a \-C-\ command line option must
4428 start. In addition, the file name must not contain the sequence \"/../"\. There
4429 is no default setting for \\ALT@_CONFIG@_PREFIX\\; when it is unset, any file
4430 name can be used with \-C-\.
4431
4432 One-off changes to a configuration can be specified by the \-D-\ command line
4433 option, which defines and overrides values for macros used inside the
4434 configuration file. However, like \-C-\, the use of this option by a
4435 non-privileged user causes Exim to discard its root privilege.
4436 If \\DISABLE@_D@_OPTION\\ is defined in \(Local/Makefile)\, the use of \-D-\ is
4437 completely disabled, and its use causes an immediate error exit.
4438
4439 Some sites may wish to use the same Exim binary on different machines that
4440 share a file system, but to use different configuration files on each machine.
4441 If \\CONFIGURE@_FILE@_USE@_NODE\\ is defined in \(Local/Makefile)\, Exim first
4442 looks for a file whose name is the configuration file name followed by a dot
4443 and the machine's node name, as obtained from the \*uname()*\ function. If this
4444 file does not exist, the standard name is tried. This processing occurs for
4445 each file name in the list given by \\CONFIGURE@_FILE\\ or \-C-\.
4446
4447 In some esoteric situations different versions of Exim may be run under
4448 different effective uids and the \\CONFIGURE@_FILE@_USE@_EUID\\ is defined to
4449 help with this. See the comments in \(src/EDITME)\ for details.
4450
4451
4452 .section Configuration file format
4453 .rset SECTconffilfor "~~chapter.~~section"
4454 .index configuration file||format of
4455 .index format||configuration file
4456 Exim's configuration file is divided into a number of different parts. General
4457 option settings must always appear at the start of the file. The other parts
4458 are all optional, and may appear in any order. Each part other than the first
4459 is introduced by the word `begin' followed by the name of the part. The
4460 optional parts are:
4461
4462 .numberpars $.
4463 \*ACL*\: Access control lists for controlling incoming SMTP mail.
4464 .nextp
4465 .index \\AUTH\\||configuration
4466 \*authenticators*\: Configuration settings for the authenticator drivers. These
4467 are concerned with the SMTP \\AUTH\\ command (see chapter ~~CHAPSMTPAUTH).
4468 .nextp
4469 \*routers*\: Configuration settings for the router drivers. Routers process
4470 addresses and determine how the message is to be delivered.
4471 .nextp
4472 \*transports*\: Configuration settings for the transport drivers. Transports
4473 define mechanisms for copying messages to destinations.
4474 .nextp
4475 \*retry*\: Retry rules, for use when a message cannot be immediately delivered.
4476 .nextp
4477 \*rewrite*\: Global address rewriting rules, for use when a message arrives and
4478 when new addresses are generated during delivery.
4479 .nextp
4480 \*local@_scan*\: Private options for the \*local@_scan()*\ function. If you
4481 want to use this feature, you must set
4482 .display asis
4483 LOCAL_SCAN_HAS_OPTIONS=yes
4484 .endd
4485 in \(Local/Makefile)\ before building Exim. Full details of the
4486 \*local@_scan()*\ facility are given in chapter ~~CHAPlocalscan.
4487 .endp
4488 .index configuration file||leading whitespace in
4489 .index configuration file||trailing whitespace in
4490 .index whitespace||in configuration file
4491 .em
4492 Leading and trailing whitespace in configuration lines is always ignored.
4493 .nem
4494 Blank lines in the file, and lines starting with a @# character (ignoring
4495 leading white space) are treated as comments and are ignored. \**Note**\: a
4496 @# character other than at the beginning of a line is not treated specially,
4497 and does not introduce a comment.
4498
4499 Any non-comment line can be continued by ending it with a backslash. 
4500 .em
4501 Note that the general rule for whitespace means that trailing white space after
4502 the backslash is ignored, and leading white space at the start of continuation
4503 lines is also ignored.
4504 .nem
4505 Comment lines beginning with @# (but not empty lines) may appear in the middle
4506 of a sequence of continuation lines.
4507
4508 A convenient way to create a configuration file is to start from the
4509 default, which is supplied in \(src/configure.default)\, and add, delete, or
4510 change settings as required.
4511
4512 The ACLs, retry rules, and rewriting rules have their own syntax which is
4513 described in chapters ~~CHAPACL, ~~CHAPretry, and ~~CHAPrewrite, respectively.
4514 The other parts of the configuration file have some syntactic items in common,
4515 and these are described below, from section ~~SECTcos onwards. Before that, the
4516 inclusion, macro, and conditional facilities are described.
4517
4518
4519 .section File inclusions in the configuration file
4520 .index inclusions in configuration file
4521 .index configuration file||including other files
4522 .index .include in configuration file
4523 .index .include@_if@_exists in configuration file
4524 You can include other files inside Exim's run time configuration file by
4525 using this syntax:
4526 .display
4527 @.include <<file name>>
4528 .endd
4529 or
4530 .display
4531 @.include@_if@_exists <<file name>>
4532 .endd
4533 on a line by itself. Double quotes round the file name are optional. If you use
4534 the first form, a configuration error occurs if the file does not exist; the
4535 second form does nothing for non-existent files.
4536
4537 Includes may be nested to any depth, but remember that Exim reads its
4538 configuration file often, so it is a good idea to keep them to a minimum.
4539 If you change the contents of an included file, you must HUP the daemon,
4540 because an included file is read only when the configuration itself is read.
4541
4542 The processing of inclusions happens early, at a physical line level, so, like
4543 comment lines, an inclusion can be used in the middle of an option setting,
4544 for example:
4545 .display asis
4546 hosts_lookup = a.b.c \
4547                .include /some/file
4548 .endd
4549 Include processing happens
4550 after
4551 macro processing (see below). Its effect is to process the lines of the file as
4552 if they occurred inline where the inclusion appears.
4553
4554
4555 .section Macros in the configuration file
4556 .rset SECTmacrodefs "~~chapter.~~section"
4557 .index macro||description of
4558 .index configuration file||macros
4559 If a line in the main part of the configuration (that is, before the first
4560 `begin' line) begins with an upper case letter, it is taken as a macro
4561 definition, and must be of the form
4562 .display
4563 <<name>> = <<rest of line>>
4564 .endd
4565 The name must consist of letters, digits, and underscores, and need not all be
4566 in upper case, though that is recommended. The rest of the line, including any
4567 continuations, is the replacement text, and has leading and trailing white
4568 space removed. Quotes are not removed. The replacement text can never end with
4569 a backslash character, but this doesn't seem to be a serious limitation.
4570
4571 Once a macro is defined, all subsequent lines in the file (and any included
4572 files) are scanned for the macro name; if there are several macros, the line is
4573 scanned for each in turn, in the order in which they are defined. The
4574 replacement text is not re-scanned for the current macro, though it is scanned
4575 for subsequently defined macros. For this reason, a macro name may not contain
4576 the name of a previously defined macro as a substring. You could, for example,
4577 define
4578 .display asis
4579 ABCD_XYZ = <<something>>
4580 ABCD = <<something else>>
4581 .endd
4582 but putting the definitions in the opposite order would provoke a configuration
4583 error.
4584
4585 Macro expansion is applied to individual lines from the file, before checking
4586 for line continuation or file inclusion (see below). If a line consists solely
4587 of a macro name, and the expansion of the macro is empty, the line is ignored.
4588 A macro at the start of a line may turn the line into a comment line or a
4589 \".include"\ line.
4590
4591 As an example of macro usage, consider a configuration where aliases are looked
4592 up in a MySQL database. It helps to keep the file less cluttered if long
4593 strings such as SQL statements are defined separately as macros, for example:
4594 .display asis
4595 ALIAS_QUERY = select mailbox from user where \
4596               login=${quote_mysql:$local_part};
4597 .endd
4598 This can then be used in a \%redirect%\ router setting like this:
4599 .display asis
4600 data = ${lookup mysql{ALIAS_QUERY}}
4601 .endd
4602 In earlier versions of Exim macros were sometimes used for domain, host, or
4603 address lists. In Exim 4 these are handled better by named lists -- see section
4604 ~~SECTnamedlists.
4605
4606 Macros in the configuration file can be overridden by the \-D-\ command line
4607 option, but Exim gives up its root privilege when \-D-\ is used, unless called
4608 by root or the Exim user.
4609
4610
4611 .section Conditional skips in the configuration file
4612 .index configuration file||conditional skips
4613 .index .ifdef
4614 You can use the directives \".ifdef"\, \".ifndef"\, \".elifdef"\,
4615 \".elifndef"\, \".else"\, and \".endif"\ to dynamically include or exclude
4616 portions of the configuration file. The processing happens whenever the file is
4617 read (that is, when an Exim binary starts to run).
4618
4619 The implementation is very simple. Instances of the first four directives must
4620 be followed by text that includes the names of one or macros. The condition
4621 that is tested is whether or not any macro substitution has taken place in the
4622 line. Thus:
4623 .display
4624 @.ifdef AAA
4625 message@_size@_limit = 50M
4626 @.else
4627 message@_size@_limit = 100M
4628 @.endif
4629 .endd
4630 sets a message size limit of 50M if the macro \"AAA"\ is defined, and 100M
4631 otherwise. If there is more than one macro named on the line, the condition
4632 is true if any of them are defined. That is, it is an `or' condition. To
4633 obtain an `and' condition, you need to use nested \".ifdef"\s.
4634
4635 Although you can use a macro expansion to generate one of these directives,
4636 it is not very useful, because the condition `there was a macro substitution
4637 in this line' will always be true.
4638
4639 Text following \".else"\ and \".endif"\ is ignored, and can be used as comment
4640 to clarify complicated nestings.
4641
4642
4643 .section Common option syntax
4644 .rset SECTcos "~~chapter.~~section"
4645 .index common option syntax
4646 .index syntax of common options
4647 .index configuration file||common option syntax
4648 For the main set of options, driver options, and \*local@_scan()*\ options,
4649 each setting is on a line by itself, and starts with a name consisting of
4650 lower-case letters and underscores. Many options require a data value, and in
4651 these cases the name must be followed by an equals sign (with optional white
4652 space) and then the value. For example:
4653 .display asis
4654 qualify_domain = mydomain.example.com
4655 .endd
4656 Some option settings may contain sensitive data, for example, passwords for
4657 accessing databases. To stop non-admin users from using the \-bP-\ command line
4658 option to read these values, you can precede the option settings with the word
4659 `hide'. For example:
4660 .display asis
4661 hide mysql_servers = localhost/users/admin/secret-password
4662 .endd
4663 For non-admin users, such options are displayed like this:
4664 .display asis
4665 mysql_servers = <value not displayable>
4666 .endd
4667 If `hide' is used on a driver option, it hides the value of that option on all
4668 instances of the same driver.
4669
4670 The following sections describe the syntax used for the different data types
4671 that are found in option settings.
4672
4673 .section Boolean options
4674 .index format||boolean
4675 .index boolean configuration values
4676 Options whose type is given as boolean are on/off switches. There are two
4677 different ways of specifying such options: with and without a data value. If
4678 the option name is specified on its own without data, the switch is turned on;
4679 if it is preceded by `no@_' or `not@_' the switch is turned off. However,
4680 boolean options may optionally be followed by an equals sign and one of the
4681 words `true', `false', `yes', or `no', as an alternative syntax. For example,
4682 the following two settings have exactly the same effect:
4683 .display asis
4684 queue_only
4685 queue_only = true
4686 .endd
4687 The following two lines also have the same (opposite) effect:
4688 .display asis
4689 no_queue_only
4690 queue_only = false
4691 .endd
4692 You can use whichever syntax you prefer.
4693
4694
4695
4696 .section Integer values
4697 .index integer configuration values
4698 .index format||integer
4699 If an integer data item starts with the characters `0x', the remainder of it
4700 is interpreted as a hexadecimal number. Otherwise, it is treated as octal if it
4701 starts with the digit 0, and decimal if not. If an integer value is followed by
4702 the letter K, it is multiplied by 1024; if it is followed by the letter M, it
4703 is multiplied by 1024x1024.
4704
4705 When the values of integer option settings are output, values which are an
4706 exact multiple of 1024 or 1024x1024 are
4707 sometimes, but not always,
4708 printed using the letters K and M. The printing style is independent of the
4709 actual input format that was used.
4710
4711 .section Octal integer values
4712 .index integer format
4713 .index format||octal integer
4714 The value of an option specified as an octal integer is always interpreted in
4715 octal, whether or not it starts with the digit zero. Such options are always
4716 output in octal.
4717
4718
4719 .section Fixed point number values
4720 .index fixed point configuration values
4721 .index format||fixed point
4722 A fixed point number consists of a decimal integer, optionally followed by a
4723 decimal point and up to three further digits.
4724
4725
4726 .section Time interval values
4727 .index time interval||specifying in configuration
4728 .index format||time interval
4729 .rset SECTtimeformat "~~chapter.~~section"
4730 A time interval is specified as a sequence of numbers, each followed by one of
4731 the following letters, with no intervening white space:
4732 .display rm
4733 .tabs 5
4734 \s\  $t seconds
4735 \m\  $t minutes
4736 \h\  $t hours
4737 \d\  $t days
4738 \w\  $t weeks
4739 .endd
4740 For example, `3h50m' specifies 3 hours and 50 minutes. The values of time
4741 intervals are output in the same format.
4742 Exim does not restrict the values; it is perfectly acceptable, for example, to
4743 specify `90m' instead of `1h30m'.
4744
4745
4746 .section String values
4747 .index string||format of configuration values
4748 .index format||string
4749 .rset SECTstrings "~~chapter.~~section"
4750 If a string data item does not start with a double-quote character, it is taken
4751 as consisting of the remainder of the line plus any continuation lines,
4752 starting at the first character after any leading white space, with trailing
4753 white space characters removed, and with no interpretation of the characters in
4754 the string. Because Exim removes comment lines (those beginning with @#) at an
4755 early stage, they can appear in the middle of a multi-line string. The
4756 following settings are therefore equivalent:
4757 .display asis
4758 trusted_users = uucp:mail
4759
4760 trusted_users = uucp:\
4761                 # This comment line is ignored
4762                 mail
4763 .endd
4764 .index string||quoted
4765 .index escape characters in quoted strings
4766 If a string does start with a double-quote, it must end with a closing
4767 double-quote, and any backslash characters other than those used for line
4768 continuation are interpreted as escape characters, as follows:
4769 .display
4770 .tabs 15
4771 @\@\   $t $rm{single backslash}
4772 @\n    $t $rm{newline}
4773 @\r    $t $rm{carriage return}
4774 @\t    $t $rm{tab}
4775 @\<<octal digits>> $t $rm{up to 3 octal digits specify one character}
4776 @\x<<hex digits>>  $t $rm{up to 2 hexadecimal digits specify one character}
4777 .endd
4778 If a backslash is followed by some other character, including a double-quote
4779 character, that character replaces the pair.
4780
4781 Quoting is necessary only if you want to make use of the backslash escapes to
4782 insert special characters, or if you need to specify a value with leading or
4783 trailing spaces. These cases are rare, so quoting is almost never needed in
4784 current versions of Exim. In versions of Exim before 3.14, quoting was required
4785 in order to continue lines, so you may come across older configuration files
4786 and examples that apparently quote unnecessarily.
4787
4788 .section Expanded strings
4789 .index string||expansion, definition of
4790 .index expansion||definition of
4791 Some strings in the configuration file are subjected to \*string expansion*\,
4792 by which means various parts of the string may be changed according to the
4793 circumstances (see chapter ~~CHAPexpand). The input syntax for such strings is
4794 as just described; in particular, the handling of backslashes in quoted strings
4795 is done as part of the input process, before expansion takes place. However,
4796 backslash is also an escape character for the expander, so any backslashes that
4797 are required for that reason must be doubled if they are within a quoted
4798 configuration string.
4799
4800 .section User and group names
4801 .index user name||format of
4802 .index format||user name
4803 .index group||name format
4804 .index format||group name
4805 User and group names are specified as strings, using the syntax described
4806 above, but the strings are interpreted specially. A user or group name must
4807 either consist entirely of digits, or be a name that can be looked up using the
4808 \*getpwnam()*\ or \*getgrnam()*\ function, as appropriate.
4809
4810 .section List construction
4811 .index list||syntax of in configuration
4812 .index format||list item in configuration
4813 .index string list, definition
4814 .rset SECTlistconstruct "~~chapter.~~section"
4815 The data for some configuration options is a list of items, with colon as the
4816 default separator. Many of these options are shown with type `string list' in
4817 the descriptions later in this document. Others are listed as `domain list',
4818 `host list', `address list', or `local part list'. Syntactically, they are all
4819 the same; however, those other than `string list' are subject to particular
4820 kinds of interpretation, as described in chapter ~~CHAPdomhosaddlists.
4821
4822 In all these cases, the entire list is treated as a single string as far as the
4823 input syntax is concerned. The \trusted@_users\ setting in section
4824 ~~SECTstrings above is an example. If a colon is actually needed in an item in
4825 a list, it must be entered as two colons. Leading and trailing white space on
4826 each item in a list is ignored. This makes it possible to include items that
4827 start with a colon, and in particular, certain forms of IPv6 address. For
4828 example, the list
4829 .display asis
4830 local_interfaces = 127.0.0.1 : ::::1
4831 .endd
4832 contains two IP addresses, the IPv4 address 127.0.0.1 and the IPv6 address
4833 @:@:1.
4834 .index list||separator, changing
4835 .index IPv6||addresses in lists
4836 Doubling colons in IPv6 addresses is an unwelcome chore, so a mechanism was
4837 introduced to allow the separator character to be changed. If a list begins
4838 with a left angle bracket, followed by any punctuation character, that
4839 character is used instead of colon as the list separator. For example, the list
4840 above can be rewritten to use a semicolon separator like this:
4841 .display asis
4842 local_interfaces = <; 127.0.0.1 ; ::1
4843 .endd
4844 This facility applies to all lists, with the exception of the list in
4845 \log@_file@_path\. It is recommended that the use of non-colon separators be
4846 confined to circumstances where they really are needed.
4847
4848
4849 .em
4850 .section Empty items in lists
4851 .rset SECTempitelis "~~chapter.~~section"
4852 .index list||empty item in
4853 An empty item at the end of a list is always ignored. In other words, trailing 
4854 separator characters are ignored. Thus, the list in
4855 .display asis
4856 senders = user@domain :
4857 .endd
4858 contains only a single item. If you want to include an empty string as one item 
4859 in a list, it must not be the last item. For example, this list contains three 
4860 items, the second of which is empty:
4861 .display asis
4862 senders = user1@domain : : user2@domain
4863 .endd
4864 \**Note**\: there must be whitespace between the two colons, as otherwise they
4865 are interpreted as representing a single colon data character (and the list 
4866 would then contain just one item). If you want to specify a list that contains 
4867 just one, empty item, you can do it as in this example:
4868 .display asis
4869 senders = :
4870 .endd
4871 In this case, the first item is empty, and the second is discarded because it 
4872 is at the end of the list.
4873 .nem
4874  
4875
4876 .section Format of driver configurations
4877 .rset SECTfordricon "~~chapter.~~section"
4878 .index drivers||configuration format
4879 There are separate parts in the configuration for defining routers, transports,
4880 and authenticators. In each part, you are defining a number of driver
4881 instances, each with its own set of options. Each driver instance is defined by
4882 a sequence of lines like this:
4883 .display
4884 <<instance name>>:
4885   <<option>>
4886   ...
4887   <<option>>
4888 .endd
4889 In the following example, the instance name is \%localuser%\, and it is
4890 followed by three options settings:
4891 .display asis
4892 localuser:
4893   driver = accept
4894   check_local_user
4895   transport = local_delivery
4896 .endd
4897 For each driver instance, you specify which Exim code module it uses -- by the
4898 setting of the \driver\ option -- and (optionally) some configuration settings.
4899 For example, in the case of transports, if you want a transport to deliver with
4900 SMTP you would use the \%smtp%\ driver; if you want to deliver to a local file
4901 you would use the \%appendfile%\ driver. Each of the drivers is described in
4902 detail in its own separate chapter later in this manual.
4903
4904 You can have several routers, transports, or authenticators that are based on
4905 the same underlying driver (each must have a different name).
4906
4907 The order in which routers are defined is important, because addresses are
4908 passed to individual routers one by one, in order. The order in which
4909 transports are defined does not matter at all. The order in which
4910 authenticators are defined is used only when Exim, as a client, is searching
4911 them to find one that matches an authentication mechanism offered by the
4912 server.
4913
4914 .index generic options
4915 .index options||generic, definition of
4916 Within a driver instance definition, there are two kinds of option:
4917 $it{generic} and $it{private}. The generic options are those that apply to all
4918 drivers of the same type (that is, all routers, all transports or all
4919 authenticators).
4920 The \driver\ option is a generic option that must appear in every definition.
4921 .index private options
4922 The private options are special for each driver, and none need appear, because
4923 they all have default values.
4924
4925 The options may appear in any order, except that the \driver\ option must
4926 precede any private options, since these depend on the particular driver. For
4927 this reason, it is recommended that \driver\ always be the first option.
4928
4929 Driver instance names, which are used for reference in log entries and
4930 elsewhere, can be any sequence of letters, digits, and underscores (starting
4931 with a letter) and must be unique among drivers of the same type. A router and
4932 a transport (for example) can each have the same name, but no two router
4933 instances can have the same name. The name of a driver instance should not be
4934 confused with the name of the underlying driver module. For example, the
4935 configuration lines:
4936 .display asis
4937 remote_smtp:
4938   driver = smtp
4939 .endd
4940 create an instance of the \%smtp%\ transport driver whose name is
4941 \%remote@_smtp%\. The same driver code can be used more than once, with
4942 different instance names and different option settings each time. A second
4943 instance of the \%smtp%\ transport, with different options, might be defined
4944 thus:
4945 .display asis
4946 special_smtp:
4947   driver = smtp
4948   port = 1234
4949   command_timeout = 10s
4950 .endd
4951 The names \%remote@_smtp%\ and \%special@_smtp%\ would be used to reference
4952 these transport instances from routers, and these names would appear in log
4953 lines.
4954
4955 Comment lines may be present in the middle of driver specifications. The full
4956 list of option settings for any particular driver instance, including all the
4957 defaulted values, can be extracted by making use of the \-bP-\ command line
4958 option.
4959
4960
4961
4962
4963
4964
4965 .
4966 .
4967 .
4968 .
4969 . ============================================================================
4970 .chapter The default configuration file
4971 .set runningfoot "default configuration"
4972 .rset CHAPdefconfil "~~chapter"
4973 .index configuration file||default, `walk through'
4974 .index default||configuration file `walk through'
4975 The default configuration file supplied with Exim as \(src/configure.default)\
4976 is sufficient for a host with simple mail requirements. As an introduction to
4977 the way Exim is configured, this chapter `walks through' the default
4978 configuration, giving brief explanations of the settings. Detailed descriptions
4979 of the options are given in subsequent chapters. The default configuration file
4980 itself contains extensive comments about ways you might want to modify the
4981 initial settings. However, note that there are many options that are not
4982 mentioned at all in the default configuration.
4983
4984
4985 .section Main configuration settings
4986 The main (global) configuration option settings must always come first in the
4987 file. The first thing you'll see in the file, after some initial comments, is
4988 the line
4989 .display asis
4990 # primary_hostname =
4991 .endd
4992 This is a commented-out setting of the \primary@_hostname\ option. Exim needs
4993 to know the official, fully qualified name of your host, and this is where you
4994 can specify it. However, in most cases you do not need to set this option. When
4995 it is unset, Exim uses the \*uname()*\ system function to obtain the host name.
4996
4997 The first three non-comment configuration lines are as follows:
4998 .display asis
4999 domainlist local_domains = @
5000 domainlist relay_to_domains =
5001 hostlist   relay_from_hosts = 127.0.0.1
5002 .endd
5003 These are not, in fact, option settings. They are definitions of two named
5004 domain lists and one named host list. Exim allows you to give names to lists of
5005 domains, hosts, and email addresses, in order to make it easier to manage the
5006 configuration file (see section ~~SECTnamedlists).
5007
5008 The first line defines a domain list called \*local@_domains*\; this is used
5009 later in the configuration to identify domains that are to be delivered
5010 on the local host.
5011 .index @@ in a domain list
5012 There is just one item in this list, the string `@@'. This is a special form of
5013 entry which means `the name of the local host'. Thus, if the local host is
5014 called \*a.host.example*\, mail to \*any.user@@a.host.example*\ is expected to
5015 be delivered locally. Because the local host's name is referenced indirectly,
5016 the same configuration file can be used on different hosts.
5017
5018 The second line defines a domain list called \*relay@_to@_domains*\, but the
5019 list itself is empty. Later in the configuration we will come to the part that
5020 controls mail relaying through the local host; it allows relaying to any
5021 domains in this list. By default, therefore, no relaying on the basis of a mail
5022 domain is permitted.
5023
5024 The third line defines a host list called \*relay@_from@_hosts*\. This list is
5025 used later in the configuration to permit relaying from any host or IP address
5026 that matches the list. The default contains just the IP address of the IPv4
5027 loopback interface, which means that processes on the local host are able to
5028 submit mail for relaying by sending it over TCP/IP to that interface. No other
5029 hosts are permitted to submit messages for relaying.
5030
5031 Just to be sure there's no misunderstanding: at this point in the configuration
5032 we aren't actually setting up any controls. We are just defining some domains
5033 and hosts that will be used in the controls that are specified later.
5034
5035 The next configuration line is a genuine option setting:
5036 .display asis
5037 acl_smtp_rcpt = acl_check_rcpt
5038 .endd
5039 This option specifies an \*Access Control List*\ (ACL) which is to be used
5040 during an incoming SMTP session for every recipient of a message (every
5041 \\RCPT\\ command). The name of the list is \*acl@_check@_rcpt*\, and we will
5042 come to its definition below, in the ACL section of the configuration. ACLs
5043 control which recipients are accepted for an incoming message -- if a
5044 configuration does not provide an ACL to check recipients, no SMTP mail can be
5045 accepted.
5046
5047 Two commented-out options settings are next:
5048 .display asis
5049 # qualify_domain =
5050 # qualify_recipient =
5051 .endd
5052 The first of these specifies a domain that Exim uses when it constructs a
5053 complete email address from a local login name. This is often needed when Exim
5054 receives a message from a local process. If you do not set \qualify@_domain\,
5055 the value of \primary@_hostname\ is used. If you set both of these options, you
5056 can have different qualification domains for sender and recipient addresses. If
5057 you set only the first one, its value is used in both cases.
5058
5059 .index domain literal||recognizing format
5060 The following line must be uncommented if you want Exim to recognize
5061 addresses of the form \*user@@[10.11.12.13]*\ that is, with a `domain literal'
5062 (an IP address) instead of a named domain.
5063 .display asis
5064 # allow_domain_literals
5065 .endd
5066 The RFCs still require this form, but many people think that in the modern
5067 Internet it makes little sense to permit mail to be sent to specific hosts by
5068 quoting their IP addresses. This ancient format has been used by people who
5069 try to abuse hosts by using them for unwanted relaying. However, some
5070 people believe there are circumstances (for example, messages addressed to
5071 \*postmaster*\) where domain literals are still useful.
5072
5073 The next configuration line is a kind of trigger guard:
5074 .display asis
5075 never_users = root
5076 .endd
5077 It specifies that no delivery must ever be run as the root user. The normal
5078 convention is to set up \*root*\ as an alias for the system administrator. This
5079 setting is a guard against slips in the configuration.
5080 The list of users specified by \never@_users\ is not, however, the complete
5081 list; the build-time configuration in \(Local/Makefile)\ has an option called
5082 \\FIXED@_NEVER@_USERS\\ specifying a list that cannot be overridden. The
5083 contents of \never@_users\ are added to this list. By default
5084 \\FIXED@_NEVER@_USERS\\ also specifies root.
5085
5086 When a remote host connects to Exim in order to send mail, the only information
5087 Exim has about the host's identity is its IP address. The next configuration
5088 line,
5089 .display asis
5090 host_lookup = *
5091 .endd
5092 specifies that Exim should do a reverse DNS lookup on all incoming connections,
5093 in order to get a host name. This improves the quality of the logging
5094 information, but if you feel it is too expensive, you can remove it entirely,
5095 or restrict the lookup to hosts on `nearby' networks.
5096 Note that it is not always possible to find a host name from an IP address,
5097 because not all DNS reverse zones are maintained, and sometimes DNS servers are
5098 unreachable.
5099
5100 The next two lines are concerned with \*ident*\ callbacks, as defined by RFC
5101 1413 (hence their names):
5102 .display asis
5103 rfc1413_hosts = *
5104 rfc1413_query_timeout = 30s
5105 .endd
5106 These settings cause Exim to make ident callbacks for all incoming SMTP calls.
5107 You can limit the hosts to which these calls are made, or change the timeout
5108 that is used. If you set the timeout to zero, all ident calls are disabled.
5109 Although they are cheap and can provide useful information for tracing problem
5110 messages, some hosts and firewalls have problems with ident calls. This can
5111 result in a timeout instead of an immediate refused connection, leading to
5112 delays on starting up an incoming SMTP session.
5113
5114 When Exim receives messages over SMTP connections, it expects all addresses to
5115 be fully qualified with a domain, as required by the SMTP definition. However,
5116 if you are running a server to which simple clients submit messages, you may
5117 find that they send unqualified addresses. The two commented-out options:
5118 .display asis
5119 # sender_unqualified_hosts =
5120 # recipient_unqualified_hosts =
5121 .endd
5122 show how you can specify hosts that are permitted to send unqualified sender
5123 and recipient addresses, respectively.
5124
5125 The \percent@_hack@_domains\ option is also commented out:
5126 .display asis
5127 # percent_hack_domains =
5128 .endd
5129 It provides a list of domains for which the `percent hack' is to operate. This
5130 is an almost obsolete form of explicit email routing. If you do not know
5131 anything about it, you can safely ignore this topic.
5132
5133 The last two settings in the main part of the default configuration are
5134 concerned with messages that have been `frozen' on Exim's queue. When a message
5135 is frozen, Exim no longer continues to try to deliver it. Freezing occurs when
5136 a bounce message encounters a permanent failure because the sender address of
5137 the original message that caused the bounce is invalid, so the bounce cannot be
5138 delivered. This is probably the most common case, but there are also other
5139 conditions that cause freezing, and frozen messages are not always bounce
5140 messages.
5141 .display asis
5142 ignore_bounce_errors_after = 2d
5143 timeout_frozen_after = 7d
5144 .endd
5145 The first of these options specifies that failing bounce messages are to be
5146 discarded after 2 days on the queue. The second specifies that any frozen
5147 message (whether a bounce message or not) is to be timed out (and discarded)
5148 after a week. In this configuration, the first setting ensures that no failing
5149 bounce message ever lasts a week.
5150
5151
5152 .section ACL configuration
5153 .index default||ACLs
5154 .index ~~ACL||default configuration
5155 In the default configuration, the ACL section follows the main configuration.
5156 It starts with the line
5157 .display asis
5158 begin acl
5159 .endd
5160 and it contains the definition of one ACL called \*acl@_check@_rcpt*\ that was
5161 referenced in the setting of \acl@_smtp@_rcpt\ above.
5162 .index \\RCPT\\||ACL for
5163 This ACL is used for every \\RCPT\\ command in an incoming SMTP message. Each
5164 \\RCPT\\ command specifies one of the message's recipients. The ACL statements
5165 are considered in order, until the recipient address is either accepted or
5166 rejected. The \\RCPT\\ command is then accepted or rejected, according to the
5167 result of the ACL processing.
5168 .display asis
5169 acl_check_rcpt:
5170 .endd
5171 This line, consisting of a name terminated by a colon, marks the start of the
5172 ACL, and names it.
5173 .display asis
5174 accept  hosts = :
5175 .endd
5176 This ACL statement accepts the recipient if the sending host matches the list.
5177 But what does that strange list mean? It doesn't actually contain any host
5178 names or IP addresses. The presence of the colon puts an empty item in the
5179 list; Exim matches this only if the incoming message didn't come from a remote
5180 host. The colon is important. Without it, the list itself is empty, and can
5181 never match anything.
5182
5183 What this statement is doing is to accept unconditionally all recipients in
5184 messages that are submitted by SMTP from local processes using the standard
5185 input and output (that is, not using TCP/IP). A number of MUAs operate in this
5186 manner.
5187 .display asis
5188 deny    domains       = +local_domains
5189         local_parts   = ^[.] : ^.*[@%!/|]
5190
5191 deny    domains       = !+local_domains
5192         local_parts   = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
5193 .endd
5194 These statements are concerned with local parts that contain any of the
5195 characters `@@', `%', `!', `/', `|', or dots in unusual places. Although these
5196 characters are entirely legal in local parts (in the case of `@@' and leading
5197 dots, only if correctly quoted), they do not commonly occur in Internet mail
5198 addresses.
5199
5200 The first three have in the past been associated with explicitly routed
5201 addresses (percent is still sometimes used -- see the \percent@_hack@_domains\
5202 option). Addresses containing these characters are regularly tried by spammers
5203 in an attempt to bypass relaying restrictions, and also by open relay testing
5204 programs. Unless you really need them it is safest to reject these characters
5205 at this early stage. This configuration is heavy-handed in rejecting these
5206 characters for all messages it accepts from remote hosts. This is a deliberate
5207 policy of being as safe as possible.
5208
5209 The first rule above is stricter, and is applied to messages that are addressed
5210 to one of the local domains handled by this host. This is implemented by the
5211 first condition, which restricts it to domains that are listed in the
5212 \*local@_domains*\ domain list. The `+' character is used to indicate a
5213 reference to a named list. In this configuration, there is just one domain in
5214 \*local@_domains*\, but in general there may be many.
5215
5216 The second condition on the first statement uses two regular expressions to
5217 block local parts that begin with a dot or contain `@@', `%', `!', `/', or `|'.
5218 If you have local accounts that include these characters, you will have to
5219 modify this rule.
5220
5221 Empty components (two dots in a row) are not valid in RFC 2822, but Exim
5222 allows them because they have been encountered in practice. (Consider local
5223 parts constructed as `first-initial.second-initial.family-name' when applied to
5224 someone like the author of Exim, who has no second initial.) However, a local
5225 part starting with a dot or containing `/../' can cause trouble if it is used
5226 as part of a file name (for example, for a mailing list). This is also true for
5227 local parts that contain slashes. A pipe symbol can also be troublesome if the
5228 local part is incorporated unthinkingly into a shell command line.
5229
5230 The second rule above applies to all other domains, and is less strict. This
5231 allows your own users to send outgoing messages to sites that use slashes
5232 and vertical bars in their local parts. It blocks local parts that begin
5233 with a dot, slash, or vertical bar, but allows these characters within the
5234 local part. However, the sequence `/../' is barred. The use of `@@', `%', and
5235 `!' is blocked, as before. The motivation here is to prevent your users (or
5236 your users' viruses) from mounting certain kinds of attack on remote sites.
5237
5238 .display asis
5239 accept  local_parts   = postmaster
5240         domains       = +local_domains
5241 .endd
5242 This statement, which has two conditions, accepts an incoming address if the
5243 local part is \*postmaster*\ and the domain is one of those listed in the
5244 \*local@_domains*\ domain list. The `+' character is used to indicate a
5245 reference to a named list. In this configuration, there is just one domain in
5246 \*local@_domains*\, but in general there may be many.
5247
5248 The presence of this statement means that mail to postmaster is never blocked
5249 by any of the subsequent tests. This can be helpful while sorting out problems
5250 in cases where the subsequent tests are incorrectly denying access.
5251 .display asis
5252 require verify        = sender
5253 .endd
5254 This statement requires the sender address to be verified before any subsequent
5255 ACL statement can be used. If verification fails, the incoming recipient
5256 address is refused. Verification consists of trying to route the address, to
5257 see if a
5258 bounce
5259 message could be delivered to it. In the case of remote addresses, basic
5260 verification checks only the domain, but \*callouts*\ can be used for more
5261 verification if required. Section ~~SECTaddressverification discusses the
5262 details of address verification.
5263
5264 .display asis
5265 # deny    message       = rejected because $sender_host_address is \
5266 #                         in a black list at $dnslist_domain\n\
5267 #                         $dnslist_text
5268 #         dnslists      = black.list.example
5269 #
5270 # warn    message       = X-Warning: $sender_host_address is \
5271 #                         in a black list at $dnslist_domain
5272 #         log_message   = found in $dnslist_domain
5273 #         dnslists      = black.list.example
5274 .endd
5275 These commented-out lines are examples of how you could configure Exim to check
5276 sending hosts against a DNS black list. The first statement rejects messages
5277 from blacklisted hosts, whereas the second merely inserts a warning header
5278 line.
5279
5280 .display asis
5281 accept  domains       = +local_domains
5282         endpass
5283         message       = unknown user
5284         verify        = recipient
5285 .endd
5286 This statement accepts the incoming recipient address if its domain is one of
5287 the local domains, but only if the address can be verified. Verification of
5288 local addresses normally checks both the local part and the domain. The
5289 \endpass\ line needs some explanation: if the condition above \endpass\ fails,
5290 that is, if the address is not in a local domain, control is passed to the next
5291 ACL statement. However, if the condition below \endpass\ fails, that is, if a
5292 recipient in a local domain cannot be verified, access is denied and the
5293 recipient is rejected.
5294 .index customizing||ACL failure message
5295 The \message\ modifier provides a customized error message for the failure.
5296 .display asis
5297 accept  domains       = +relay_to_domains
5298         endpass
5299         message       = unrouteable address
5300         verify        = recipient
5301 .endd
5302 This statement accepts the incoming recipient address if its domain is one of
5303 the domains for which this host is a relay, but again, only if the address can
5304 be verified.
5305 .display asis
5306 accept  hosts         = +relay_from_hosts
5307 .endd
5308 Control reaches this statement only if the recipient's domain is neither a
5309 local domain, nor a relay domain. The statement accepts the address if the
5310 message is coming from one of the hosts that are defined as being allowed to
5311 relay through this host. Recipient verification is omitted here, because in
5312 many cases the clients are dumb MUAs that do not cope well with SMTP error
5313 responses. If you are actually relaying out from MTAs, you should probably add
5314 recipient verification here.
5315 .display asis
5316 accept  authenticated = *
5317 .endd
5318 Control reaches here for attempts to relay to arbitrary domains from arbitrary
5319 hosts. The statement accepts the address only if the client host has
5320 authenticated itself. The default configuration does not define any
5321 authenticators, which means that no client can in fact authenticate. You will
5322 need to add authenticator definitions if you want to make use of this ACL
5323 statement.
5324 .display asis
5325 deny    message       = relay not permitted
5326 .endd
5327 The final statement denies access, giving a specific error message. Reaching
5328 the end of the ACL also causes access to be denied, but with the generic
5329 message `administrative prohibition'.
5330
5331
5332 .section Router configuration
5333 .index default||routers
5334 .index routers||default
5335 The router configuration comes next in the default configuration, introduced
5336 by the line
5337 .display asis
5338 begin routers
5339 .endd
5340 Routers are the modules in Exim that make decisions about where to send
5341 messages. An address is passed to each router in turn, until it is either
5342 accepted, or failed. This means that the order in which you define the routers
5343 matters. Each router is fully described in its own chapter later in this
5344 manual. Here we give only brief overviews.
5345
5346 .index domain literal||default router
5347 .display asis
5348 # domain_literal:
5349 #   driver = ipliteral
5350 #   domains = !+local_domains
5351 #   transport = remote_smtp
5352 .endd
5353 This router is commented out because the majority of sites do not want to
5354 support domain literal addresses (those of the form \*user@@[10.9.8.7]*\). If
5355 you uncomment this router, you also need to uncomment the setting of
5356 \allow@_domain@_literals\ in the main part of the configuration.
5357
5358 .display asis
5359 dnslookup:
5360   driver = dnslookup
5361   domains = ! +local_domains
5362   transport = remote_smtp
5363 .newline
5364   ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
5365 .newline
5366   no_more
5367 .endd
5368 The first uncommented router handles addresses that do not involve any local
5369 domains. This is specified by the line
5370 .display asis
5371 domains = ! +local_domains
5372 .endd
5373 The \domains\ option lists the domains to which this router applies, but the
5374 exclamation mark is a negation sign, so the router is used only for domains
5375 that are not in the domain list called \*local@_domains*\ (which was defined at
5376 the start of the configuration). The plus sign before \*local@_domains*\
5377 indicates that it is referring to a named list. Addresses in other domains are
5378 passed on to the following routers.
5379
5380 The name of the router driver is \%dnslookup%\,
5381 and is specified by the \driver\ option. Do not be confused by the fact that
5382 the name of this router instance is the same as the name of the driver. The
5383 instance name is arbitrary, but the name set in the \driver\ option must be one
5384 of the driver modules that is in the Exim binary.
5385
5386 The \%dnslookup%\ router routes addresses by looking up their domains in the
5387 DNS in order to obtain a list of hosts to which the address is routed. If the
5388 router succeeds, the address is queued for the \%remote@_smtp%\ transport, as
5389 specified by the \transport\ option. If the router does not find the domain in
5390 the DNS, no further routers are tried because of the \no@_more\ setting, so the
5391 address fails and is bounced.
5392
5393 The \ignore@_target@_hosts\ option specifies a list of IP addresses that are to
5394 be entirely ignored. This option is present because a number of cases have been
5395 encountered where MX records in the DNS point to host names
5396 whose IP addresses are 0.0.0.0 or are in the 127 subnet (typically 127.0.0.1).
5397 Completely ignoring these IP addresses causes Exim to fail to route the
5398 email address, so it bounces. Otherwise, Exim would log a routing problem, and
5399 continue to try to deliver the message periodically until the address timed
5400 out.
5401 .display asis
5402 system_aliases:
5403   driver = redirect
5404   allow_fail
5405   allow_defer
5406   data = ${lookup{$local_part}lsearch{/etc/aliases}}
5407 # user = exim
5408   file_transport = address_file
5409   pipe_transport = address_pipe
5410 .endd
5411 Control reaches this and subsequent routers only for addresses in the local
5412 domains. This router checks to see whether the local part is defined as an
5413 alias in the \(/etc/aliases)\ file, and if so, redirects it according to the
5414 data that it looks up from that file. If no data is found for the local part,
5415 the value of the \data\ option is empty, causing the address to be passed to
5416 the next router.
5417
5418 \(/etc/aliases)\ is a conventional name for the system aliases file that is
5419 often used. That is why it is referenced by from the default configuration
5420 file. However, you can change this by setting \\SYSTEM@_ALIASES@_FILE\\ in
5421 \(Local/Makefile)\ before building Exim.
5422
5423 .display asis
5424 userforward:
5425   driver = redirect
5426   check_local_user
5427   file = $home/.forward
5428   no_verify
5429   no_expn
5430   check_ancestor
5431 # allow_filter
5432   file_transport = address_file
5433   pipe_transport = address_pipe
5434   reply_transport = address_reply
5435 .endd
5436 This is the most complicated router in the default configuration. It is another
5437 redirection router, but this time it is looking for forwarding data set up by
5438 individual users. The \check@_local@_user\ setting means that the first thing it
5439 does is to check that the local part of the address is the login name of a
5440 local user. If it is not, the router is skipped. When a local user is found,
5441 the file called \(.forward)\ in the user's home directory is consulted. If it
5442 does not exist, or is empty, the router declines. Otherwise, the contents of
5443 \(.forward)\ are interpreted as redirection data (see chapter ~~CHAPredirect
5444 for more details).
5445
5446 .index Sieve filter||enabling in default router
5447 Traditional \(.forward)\ files contain just a list of addresses, pipes, or
5448 files. Exim supports this by default. However, if \allow@_filter\ is set (it is
5449 commented out by default), the contents of the file are interpreted as a set of
5450 Exim or Sieve filtering instructions, provided the file begins with `@#Exim
5451 filter' or `@#Sieve filter', respectively. User filtering is discussed in the
5452 separate document entitled \*Exim's interfaces to mail filtering*\.
5453
5454 The \no@_verify\ and \no@_expn\ options mean that this router is skipped when
5455 verifying addresses, or when running as a consequence of an SMTP \\EXPN\\
5456 command.
5457 There are two reasons for doing this:
5458 .numberpars
5459 Whether or not a local user has a \(.forward)\ file is not really relevant when
5460 checking an address for validity; it makes sense not to waste resources doing
5461 unnecessary work.
5462 .nextp
5463 More importantly, when Exim is verifying addresses or handling an \\EXPN\\
5464 command during an SMTP session, it is running as the Exim user, not as root.
5465 The group is the Exim group, and no additional groups are set up.
5466 It may therefore not be possible for Exim to read users' \(.forward)\ files at
5467 this time.
5468 .endp
5469
5470 The setting of \check@_ancestor\ prevents the router from generating a new
5471 address that is the same as any previous address that was redirected. (This
5472 works round a problem concerning a bad interaction between aliasing and
5473 forwarding -- see section ~~SECTredlocmai).
5474
5475 The final three option settings specify the transports that are to be used when
5476 forwarding generates a direct delivery to a file, or to a pipe, or sets up an
5477 auto-reply, respectively. For example, if a \(.forward)\ file contains
5478 .display asis
5479 a.nother@elsewhere.example, /home/spqr/archive
5480 .endd
5481 the delivery to \(/home/spqr/archive)\ is done by running the \address@_file\
5482 transport.
5483 .display asis
5484 localuser:
5485   driver = accept
5486   check_local_user
5487   transport = local_delivery
5488 .endd
5489 The final router sets up delivery into local mailboxes, provided that the local
5490 part is the name of a local login, by accepting the address and queuing it for
5491 the \%local@_delivery%\ transport. Otherwise, we have reached the end of the
5492 routers, so the address is bounced.
5493
5494
5495 .section Transport configuration
5496 .index default||transports
5497 .index transports||default
5498 Transports define mechanisms for actually delivering messages. They operate
5499 only when referenced from routers, so the order in which they are defined does
5500 not matter. The transports section of the configuration starts with
5501 .display asis
5502 begin transports
5503 .endd
5504 One remote transport and four local transports are defined.
5505 .display asis
5506 remote_smtp:
5507   driver = smtp
5508 .endd
5509 This transport is used for delivering messages over SMTP connections. All its
5510 options are defaulted. The list of remote hosts comes from the router.
5511 .display asis
5512 local_delivery:
5513   driver = appendfile
5514   file = /var/mail/$local_part
5515   delivery_date_add
5516   envelope_to_add
5517   return_path_add
5518 # group = mail
5519 # mode = 0660
5520 .endd
5521 This \%appendfile%\ transport is used for local delivery to user mailboxes in
5522 traditional BSD mailbox format. By default it runs under the uid and gid of the
5523 local user, which requires the sticky bit to be set on the \(/var/mail)\
5524 directory. Some systems use the alternative approach of running mail deliveries
5525 under a particular group instead of using the sticky bit. The commented options
5526 show how this can be done.
5527
5528 Exim adds three headers to the message as it delivers it: ::Delivery-date::,
5529 ::Envelope-to:: and ::Return-path::. This action is requested by the three
5530 similarly-named options above.
5531 .display asis
5532 address_pipe:
5533   driver = pipe
5534   return_output
5535 .endd
5536 This transport is used for handling deliveries to pipes that are generated by
5537 redirection (aliasing or users' \(.forward)\ files). The \return@_output\
5538 option specifies that any output generated by the pipe is to be returned to the
5539 sender.
5540 .display asis
5541 address_file:
5542   driver = appendfile
5543   delivery_date_add
5544   envelope_to_add
5545   return_path_add
5546 .endd
5547 This transport is used for handling deliveries to files that are generated by
5548 redirection. The name of the file is not specified in this instance of
5549 \%appendfile%\, because it comes from the \%redirect%\ router.
5550 .display asis
5551 address_reply:
5552   driver = autoreply
5553 .endd
5554 This transport is used for handling automatic replies generated by users'
5555 filter files.
5556
5557
5558 .section Default retry rule
5559 .index retry||default rule
5560 .index default||retry rule
5561 The retry section of the configuration file contains rules which affect the way
5562 Exim retries deliveries that cannot be completed at the first attempt. It is
5563 introduced by the line
5564 .display asis
5565 begin retry
5566 .endd
5567 In the default configuration, there is just one rule, which applies to all
5568 errors:
5569 .display asis
5570 *   *   F,2h,15m; G,16h,1h,1.5; F,4d,6h
5571 .endd
5572 This causes any temporarily failing address to be retried every 15 minutes for
5573 2 hours, then at intervals starting at one hour and increasing by a factor of
5574 1.5 until 16 hours have passed, then every 6 hours up to 4 days. If an address
5575 is not delivered after 4 days of failure, it is bounced.
5576
5577
5578 .section Rewriting configuration
5579 The rewriting section of the configuration, introduced by
5580 .display asis
5581 begin rewrite
5582 .endd
5583 contains rules for rewriting addresses in messages as they arrive. There are no
5584 rewriting rules in the default configuration file.
5585
5586
5587 .section Authenticators configuration
5588 .index \\AUTH\\||configuration
5589 The authenticators section of the configuration, introduced by
5590 .display asis
5591 begin authenticators
5592 .endd
5593 defines mechanisms for the use of the SMTP \\AUTH\\ command. No authenticators
5594 are specified in the default configuration file.
5595
5596
5597
5598 .
5599 .
5600 .
5601 .
5602 . ============================================================================
5603 .chapter Regular expressions
5604 .set runningfoot "regular expressions"
5605 .rset CHAPregexp ~~chapter
5606
5607 .index regular expressions||library
5608 .index PCRE
5609 Exim supports the use of regular expressions in many of its options. It
5610 uses the PCRE regular expression library; this provides regular expression
5611 matching that is compatible with Perl 5. The syntax and semantics of
5612 regular expressions is discussed in many Perl reference books, and also in
5613 Jeffrey Friedl's
5614 .if ~~html
5615 [(A HREF="http://www.oreilly.com/catalog/regex/")]
5616 .fi
5617 $it{Mastering Regular Expressions}
5618 .if ~~html
5619 [(/A)]
5620 .fi
5621 (O'Reilly, ISBN 0-596-00289-0).
5622
5623 The documentation for the syntax and semantics of the regular expressions that
5624 are supported by PCRE is included in plain text in the file
5625 \(doc/pcrepattern.txt)\ in the Exim distribution, and also in the HTML
5626 tarbundle of Exim documentation, and as an appendix to the
5627 .if ~~html
5628 [(A HREF="http://www.uit.co.uk/exim-book/")]
5629 .fi
5630 Exim book.
5631 .if ~~html
5632 [(/A)]
5633 .fi
5634 It describes in detail the features of the regular expressions that PCRE
5635 supports, so no further description is included here. The PCRE functions are
5636 called from Exim using the default option settings (that is, with no PCRE
5637 options set), except that the \\PCRE@_CASELESS\\ option is set when the
5638 matching is required to be case-insensitive.
5639
5640 In most cases, when a regular expression is required in an Exim configuration,
5641 it has to start with a circumflex, in order to distinguish it from plain text
5642 or an `ends with' wildcard. In this example of a configuration setting, the
5643 second item in the colon-separated list is a regular expression.
5644 .display asis
5645 domains = a.b.c : ^\\d{3} : *.y.z : ...
5646 .endd
5647 The doubling of the backslash is required because of string expansion that
5648 precedes interpretation -- see section ~~SECTlittext for more discussion of
5649 this issue, and a way of avoiding the need for doubling backslashes. The
5650 regular expression that is eventually used in this example contains just one
5651 backslash. The circumflex is included in the regular expression, and has the
5652 normal effect of `anchoring' it to the start of the string that is being
5653 matched.
5654
5655 There are, however, two cases where a circumflex is not required for the
5656 recognition of a regular expression: these are the \match\ condition in a
5657 string expansion, and the \matches\ condition in an Exim filter file. In these
5658 cases, the relevant string is always treated as a regular expression; if it
5659 does not start with a circumflex, the expression is not anchored, and can match
5660 anywhere in the subject string.
5661
5662 In all cases, if you want a regular expression to match at the end of a string,
5663 you must code the @$ metacharacter to indicate this. For example:
5664 .display asis
5665 domains = ^\\d{3}\\.example
5666 .endd
5667 matches the domain \*123.example*\, but it also matches \*123.example.com*\.
5668 You need to use:
5669 .display asis
5670 domains = ^\\d{3}\\.example\$
5671 .endd
5672 if you want \*example*\ to be the top-level domain. (The backslash before the
5673 @$ is another artefact of string expansion.)
5674
5675
5676 .section Testing regular expressions
5677 .index testing||regular expressions
5678 .index regular expressions||testing
5679 .index \*pcretest*\
5680 A program called \*pcretest*\ forms part of the PCRE distribution and is built
5681 with PCRE during the process of building Exim. It is primarily intended for
5682 testing PCRE itself, but it can also be used for experimenting with regular
5683 expressions. After building Exim, the binary can be found in the build
5684 directory (it is not installed anywhere automatically). There is documentation
5685 of various options in \(doc/pcretest.txt)\, but for simple testing, none are
5686 needed. This is the output of a sample run of \*pcretest*\:
5687 .display
5688   re> $cb{/^([^@@]+)@@.+@\.(ac|edu)@\.(?!kr)[a-z]@{2@}@$/}
5689 data> $cb{x@@y.ac.uk}
5690  0: x@@y.ac.uk
5691  1: x
5692  2: ac
5693 data> $cb{x@@y.ac.kr}
5694 No match
5695 data> $cb{x@@y.edu.com}
5696 No match
5697 data> $cb{x@@y.edu.co}
5698  0: x@@y.edu.co
5699  1: x
5700  2: edu
5701 .endd
5702 .if ~~sys.fancy
5703 Input typed by the user is shown in bold face.
5704 .fi
5705 After the `re>' prompt, a regular expression enclosed in delimiters is
5706 expected. If this compiles without error, `data>' prompts are given for strings
5707 against which the expression is matched. An empty data line causes a new
5708 regular expression to be read. If the match is successful, the captured
5709 substring values (that is, what would be in the variables \$0$\, \$1$\, \$2$\,
5710 etc.) are shown. The above example tests for an email address whose domain ends
5711 with either `ac' or `edu' followed by a two-character top-level domain that is
5712 not `kr'. The local part is captured in \$1$\ and the `ac' or `edu' in \$2$\.
5713
5714
5715
5716
5717
5718
5719 .
5720 .
5721 .
5722 .
5723 . ============================================================================
5724 .chapter File and database lookups
5725 .set runningfoot "file/database lookups"
5726 .rset CHAPfdlookup "~~chapter"
5727 .index file||lookup
5728 .index database lookups
5729 .index lookup||description of
5730 Exim can be configured to look up data in files or databases as it processes
5731 messages. Two different kinds of syntax are used:
5732 .numberpars
5733 A string that is to be expanded may contain explicit lookup requests. These
5734 cause parts of the string to be replaced by data that is obtained from the
5735 lookup.
5736 .nextp
5737 Lists of domains, hosts, and email addresses can contain lookup requests as a
5738 way of avoiding excessively long linear lists. In this case, the data that is
5739 returned by the lookup is often (but not always) discarded; whether the lookup
5740 succeeds or fails is what really counts. These kinds of list are described in
5741 chapter ~~CHAPdomhosaddlists.
5742 .endp
5743 It is easy to confuse the two different kinds of lookup, especially as the
5744 lists that may contain the second kind are always expanded before being
5745 processed as lists. Therefore, they may also contain lookups of the first kind.
5746 Be careful to distinguish between the following two examples:
5747 .display asis
5748 domains = ${lookup{$sender_host_address}lsearch{/some/file}}
5749 domains = lsearch;/some/file
5750 .endd
5751 The first uses a string expansion, the result of which must be a domain list.
5752 String expansions are described in detail in chapter ~~CHAPexpand. The
5753 expansion takes place first, and the file that is searched could contain lines
5754 like this:
5755 .display asis
5756 192.168.3.4: domain1 : domain2 : ...
5757 192.168.1.9: domain3 : domain4 : ...
5758 .endd
5759 Thus, the result of the expansion is a list of domains (and possibly other
5760 types of item that are allowed in domain lists).
5761
5762 In the second case, the lookup is a single item in a domain list. It causes
5763 Exim to use a lookup to see if the domain that is being processed can be found
5764 in the file. The file could contains lines like this:
5765 .display asis
5766 domain1:
5767 domain2:
5768 .endd
5769 Any data that follows the keys is not relevant when checking that the domain
5770 matches the list item.
5771
5772 It is possible to use both kinds of lookup at once. Consider a file containing
5773 lines like this:
5774 .display asis
5775 192.168.5.6: lsearch;/another/file
5776 .endd
5777 If the value of \$sender@_host@_address$\ is 192.168.5.6, expansion of the
5778 first \domains\ setting above generates the second setting, which therefore
5779 causes a second lookup to occur.
5780
5781 The rest of this chapter describes the different lookup types that are
5782 available. Any of them can be used in either of the circumstances described
5783 above. The syntax requirements for the two cases are described in chapters
5784 ~~CHAPexpand and ~~CHAPdomhosaddlists, respectively.
5785
5786 .section Lookup types
5787 .index lookup||types of
5788 .index single-key lookup||definition of
5789 Two different styles of data lookup are implemented:
5790 .numberpars $.
5791 The \*single-key*\ style requires the specification of a file in which to look,
5792 and a single key to search for. 
5793 .em
5794 The key must be a non-empty string for the lookup to succeed.
5795 .nem
5796 The lookup type determines how the file is searched.
5797 .nextp
5798 .index query-style lookup||definition of
5799 The \*query*\ style accepts a generalized database query.
5800 No particular key value is assumed by Exim for query-style lookups. You can
5801 use whichever Exim variable(s) you need to construct the database query.
5802 .endp
5803 The code for each lookup type is in a separate source file that is included in
5804 the binary of Exim only if the corresponding compile-time option is set. The
5805 default settings in \(src/EDITME)\ are:
5806 .display asis
5807 LOOKUP_DBM=yes
5808 LOOKUP_LSEARCH=yes
5809 .endd
5810 which means that only linear searching and DBM lookups are included by default.
5811 For some types of lookup (e.g. SQL databases), you need to install appropriate
5812 libraries and header files before building Exim.
5813
5814
5815
5816 .section Single-key lookup types
5817 .rset SECTsinglekeylookups "~~chapter.~~section"
5818 .index lookup||single-key types
5819 .index single-key lookup||list of types
5820 The following single-key lookup types are implemented:
5821 .numberpars $.
5822 .index cdb||description of
5823 .index lookup||cdb
5824 .index binary zero||in lookup key
5825 \%cdb%\: The given file is searched as a Constant DataBase file, using the key
5826 string without a terminating binary zero. The cdb format is designed for
5827 indexed files that are read frequently and never updated, except by total
5828 re-creation. As such, it is particulary suitable for large files containing
5829 aliases or other indexed data referenced by an MTA. Information about cdb can
5830 be found in several places:
5831 .display rm
5832 \?http://www.pobox.com/@~djb/cdb.html?\
5833 \?ftp://ftp.corpit.ru/pub/tinycdb/?\
5834 \?http://packages.debian.org/stable/utils/freecdb.html?\
5835 .endd
5836 A cdb distribution is not needed in order to build Exim with cdb support,
5837 because the code for reading cdb files is included directly in Exim itself.
5838 However, no means of building or testing cdb files is provided with Exim, so
5839 you need to obtain a cdb distribution in order to do this.
5840 .nextp
5841 .index DBM||lookup type
5842 .index lookup||dbm
5843 .index binary zero||in lookup key
5844 \%dbm%\: Calls to DBM library functions are used to extract data from the given
5845 DBM file by looking up the record with the given key. A terminating binary
5846 zero is included in the key that is passed to the DBM library. See section
5847 ~~SECTdb for a discussion of DBM libraries.
5848 .index Berkeley DB library||file format
5849 For all versions of Berkeley DB, Exim uses the \\DB@_HASH\\ style of database
5850 when building DBM files using the \exim@_dbmbuild\ utility. However, when using
5851 Berkeley DB versions 3 or 4, it opens existing databases for reading with the
5852 \\DB@_UNKNOWN\\ option. This enables it to handle any of the types of database
5853 that the library supports, and can be useful for accessing DBM files created by
5854 other applications. (For earlier DB versions, \\DB@_HASH\\ is always used.)
5855
5856 .nextp
5857 .index lookup||dbmnz
5858 .index lookup||dbm, terminating zero
5859 .index binary zero||in lookup key
5860 .index Courier
5861 .index \(/etc/userdbshadow.dat)\
5862 .index dmbnz lookup type
5863 \%dbmnz%\: This is the same as \%dbm%\, except that a terminating binary zero
5864 is not included in the key that is passed to the DBM library. You may need this
5865 if you want to look up data in files that are created by or shared with some
5866 other application that does not use terminating zeros. For example, you need to
5867 use \%dbmnz%\ rather than \%dbm%\ if you want to authenticate incoming SMTP
5868 calls using the passwords from Courier's \(/etc/userdbshadow.dat)\ file. Exim's
5869 utility program for creating DBM files (\*exim@_dbmbuild*\) includes the zeros
5870 by default, but has an option to omit them (see section ~~SECTdbmbuild).
5871 .nextp
5872 .index lookup||dsearch
5873 .index dsearch lookup type
5874 \%dsearch%\: The given file must be a directory; this is searched for a file
5875 whose name is the key. The key may not contain any forward slash characters.
5876 The result of a successful lookup is the name of the file. An example of how
5877 this lookup can be used to support virtual domains is given in section
5878 ~~SECTvirtualdomains.
5879 .nextp
5880 .index lookup||iplsearch
5881 .index iplsearch lookup type
5882 \%iplsearch%\: The given file is a text file containing keys and data. A key is
5883 terminated by a colon or white space or the end of the line. The keys in the
5884 file must be IP addresses, or IP addresses with CIDR masks. Keys that involve
5885 IPv6 addresses must be enclosed in quotes to prevent the first internal colon
5886 being interpreted as a key terminator. For example:
5887 .display asis
5888 1.2.3.4:           data for 1.2.3.4
5889 192.168.0.0/16     data for 192.168.0.0/16
5890 "abcd::cdab":      data for abcd::cdab
5891 "abcd:abcd::/32"   data for abcd:abcd::/32
5892 .endd
5893 The key for an \%iplsearch%\ lookup must be an IP address (without a mask). The
5894 file is searched linearly, using the CIDR masks where present, until a matching
5895 key is found. The first key that matches is used; there is no attempt to find a
5896 `best' match. Apart from the way the keys are matched, the processing for
5897 \%iplsearch%\ is the same as for \%lsearch%\.
5898
5899 \**Warning 1**\: Unlike most other single-key lookup types, a file of data for
5900 \%iplsearch%\ can \*not*\ be turned into a DBM or cdb file, because those
5901 lookup types support only literal keys.
5902
5903 \**Warning 2**\: In a host list, you must always use \%net-iplsearch%\ so that
5904 the implicit key is the host's IP address rather than its name (see section
5905 ~~SECThoslispatsikey).
5906
5907 .nextp
5908 .index linear search
5909 .index lookup||lsearch
5910 .index lsearch lookup type
5911 \%lsearch%\: The given file is a text file that is searched linearly for a
5912 line beginning with the search key, terminated by a colon or white space or the
5913 end of the line. The first occurrence that is found in the file is used. White
5914 space between the key and the colon is permitted. The remainder of the line,
5915 with leading and trailing white space removed, is the data. This can be
5916 continued onto subsequent lines by starting them with any amount of white
5917 space, but only a single space character is included in the data at such a
5918 junction. If the data begins with a colon, the key must be terminated by a
5919 colon, for example:
5920 .display
5921 baduser:  :fail:
5922 .endd
5923 Empty lines and lines beginning with @# are ignored, even if they occur in the
5924 middle of an item. This is the traditional textual format of alias files. Note
5925 that the keys in an \%lsearch%\ file are literal strings. There is no
5926 wildcarding of any kind.
5927
5928 .index lookup||lsearch, colons in keys
5929 .index whitespace||in lsearch key
5930 In most \%lsearch%\ files, keys are not required to contain colons or @#
5931 characters, or whitespace. However, if you need this feature, it is available.
5932 If a key begins with a doublequote character, it is terminated only by a
5933 matching quote (or end of line), and the normal escaping rules apply to its
5934 contents (see section ~~SECTstrings). An optional colon is permitted after
5935 quoted keys (exactly as for unquoted keys). There is no special handling of
5936 quotes for the data part of an \%lsearch%\ line.
5937 .nextp
5938 .index NIS lookup type
5939 .index lookup||NIS
5940 .index binary zero||in lookup key
5941 \%nis%\: The given file is the name of a NIS map, and a NIS lookup is done with
5942 the given key, without a terminating binary zero. There is a variant called
5943 \%nis0%\ which does include the terminating binary zero in the key. This is
5944 reportedly needed for Sun-style alias files. Exim does not recognize NIS
5945 aliases; the full map names must be used.
5946 .nextp
5947 .index wildlsearch lookup type
5948 .index lookup||wildlsearch
5949 .index nwildlsearch lookup type
5950 .index lookup||nwildlsearch
5951 \%wildlsearch%\ or \%nwildlsearch%\: These search a file linearly, like
5952 \%lsearch%\, but instead of being interpreted as a literal string, each key may
5953 be wildcarded. The difference between these two lookup types is that for
5954 \%wildlsearch%\, each key in the file is string-expanded before being used,
5955 whereas for \%nwildlsearch%\, no expansion takes place.
5956
5957 Like \%lsearch%\, the testing is done case-insensitively. The following forms
5958 of wildcard are recognized:
5959 .numberpars "$*$"
5960 The string may begin with an asterisk to mean `begins with'. For example:
5961 .display asis
5962 *.a.b.c       data for anything.a.b.c
5963 *fish         data for anythingfish
5964 .endd
5965 .nextp
5966 The string may begin with a circumflex to indicate a regular expression. For
5967 example, for \%wildlsearch%\:
5968 .display asis
5969 ^\N\d+\.a\.b\N    data for <digits>.a.b
5970 .endd
5971 Note the use of \"@\N"\ to disable expansion of the contents of the regular
5972 expression. If you are using \%nwildlsearch%\, where the keys are not
5973 string-expanded, the equivalent entry is:
5974 .display asis
5975 ^\d+\.a\.b        data for <digits>.a.b
5976 .endd
5977
5978 If the regular expression contains white space or colon characters, you must
5979 either quote it (see \%lsearch%\ above), or represent these characters in other
5980 ways. For example, \"@\s"\ can be used for white space and \"@\x3A"\ for a
5981 colon. This may be easier than quoting, because if you quote, you have to
5982 escape all the backslashes inside the quotes.
5983 .nextp
5984 Although I cannot see it being of much use, the general matching function
5985 that is used to implement
5986 \%(n)wildlsearch%\
5987 means that the string may begin with a lookup name terminated by a semicolon,
5988 and followed by lookup data. For example:
5989 .display asis
5990 cdb;/some/file  data for keys that match the file
5991 .endd
5992 The data that is obtained from the nested lookup is discarded.
5993 .endp
5994 Keys that do not match any of these patterns are interpreted literally. The
5995 continuation rules for the data are the same as for \%lsearch%\, and keys may
5996 be followed by optional colons.
5997
5998 \**Warning**\: Unlike most other single-key lookup types, a file of data for
5999 \%(n)wildlsearch%\ can \*not*\ be turned into a DBM or cdb file, because those
6000 lookup types support only literal keys.
6001 .endp
6002
6003 .section Query-style lookup types
6004 .index lookup||query-style types
6005 .index query-style lookup||list of types
6006 The supported query-style lookup types are listed below. Further details about
6007 many of them are given in later sections.
6008 .numberpars $.
6009 .index DNS||as a lookup type
6010 .index lookup||DNS
6011 \%dnsdb%\: This does a DNS search for 
6012 .em
6013 one or more records whose domain names are given in the supplied query. The
6014 resulting data is the contents of the records.
6015 .nem
6016 See section ~~SECTdnsdb.
6017 .nextp
6018 .index Interbase lookup type
6019 .index lookup||Interbase
6020 \%ibase%\: This does a lookup in an Interbase database.
6021 .nextp
6022 .index LDAP||lookup type
6023 .index lookup||LDAP
6024 \%ldap%\: This does an LDAP lookup using a query in the form of a URL, and
6025 returns attributes from a single entry. There is a variant called \%ldapm%\
6026 that permits values from multiple entries to be returned. A third variant
6027 called \%ldapdn%\ returns the Distinguished Name of a single entry instead of
6028 any attribute values. See section ~~SECTldap.
6029 .nextp
6030 .index MySQL||lookup type
6031 .index lookup||MySQL
6032 \%mysql%\: The format of the query is an SQL statement that is passed to a MySQL
6033 database. See section ~~SECTsql.
6034 .nextp
6035 .index NIS@+ lookup type
6036 .index lookup||NIS+
6037 \%nisplus%\: This does a NIS+ lookup using a query that can specify the name of
6038 the field to be returned. See section ~~SECTnisplus.
6039 .nextp
6040 .index Oracle||lookup type
6041 .index lookup||Oracle
6042 \%oracle%\: The format of the query is an SQL statement that is passed to an
6043 Oracle database. See section ~~SECTsql.
6044 .nextp
6045 .index lookup||passwd
6046 .index passwd lookup type
6047 .index \(/etc/passwd)\
6048 \%passwd%\ is a query-style lookup with queries that are just user names. The
6049 lookup calls \*getpwnam()*\ to interrogate the system password data, and on
6050 success, the result string is the same as you would get from an \%lsearch%\
6051 lookup on a traditional \(/etc/passwd file)\, though with \"*"\ for the
6052 password value. For example:
6053 .display asis
6054 *:42:42:King Rat:/home/kr:/bin/bash
6055 .endd
6056 .nextp
6057 .index PostgreSQL lookup type
6058 .index lookup||PostgreSQL
6059 \%pgsql%\: The format of the query is an SQL statement that is passed to a
6060 PostgreSQL database. See section ~~SECTsql.
6061 .nextp
6062 \%testdb%\: This is a lookup type that is used for testing Exim. It is
6063 not likely to be useful in normal operation.
6064 .nextp
6065 .index whoson lookup type
6066 .index lookup||whoson
6067 \%whoson%\: \*Whoson*\ (\?http://whoson.sourceforge.net?\) is a proposed
6068 Internet protocol that allows Internet server programs to check whether a
6069 particular (dynamically allocated) IP address is currently allocated to a known
6070 (trusted) user and, optionally, to obtain the identity of the said user. In
6071 Exim, this can be used to implement `POP before SMTP' checking using ACL
6072 statements such as
6073 .display asis
6074 require condition = \
6075   ${lookup whoson {$sender_host_address}{yes}{no}}
6076 .endd
6077 The query consists of a single IP address. The value returned is the name of
6078 the authenticated user.
6079 .endp
6080
6081 .section Temporary errors in lookups
6082 .index lookup||temporary error in
6083 Lookup functions can return temporary error codes if the lookup cannot be
6084 completed. For example, a NIS or LDAP database might be unavailable. For this
6085 reason, it is not advisable to use a lookup that might do this for critical
6086 options such as a list of local domains.
6087
6088 When a lookup cannot be completed in a router or transport, delivery
6089 of the message (to the relevant address) is deferred, as for any other
6090 temporary error. In other circumstances Exim may assume the lookup has failed,
6091 or may give up altogether.
6092
6093
6094 .section Default values in single-key lookups
6095 .rset SECTdefaultvaluelookups "~~chapter.~~section"
6096 .index wildcard lookups
6097 .index lookup||default values
6098 .index lookup||wildcard
6099 .index lookup||$*$ added to type
6100 .index default||in single-key lookups
6101 In this context, a `default value' is a value specified by the administrator
6102 that is to be used if a lookup fails.
6103
6104 If `$*$' is added to a single-key lookup type (for example, \lsearch$*$\) and
6105 the initial lookup fails, the key `$*$' is looked up in the file to provide
6106 a default value. See also the section on partial matching below.
6107
6108 .index @*@@ with single-key lookup
6109 .index lookup||$*$@@ added to type
6110 .index alias file||per-domain default
6111 Alternatively, if `$*$@@' is added to a single-key lookup type (for example
6112 \dbm$*$@@\) then, if the initial lookup fails and the key contains an @@
6113 character, a second lookup is done with everything before the last @@ replaced
6114 by $*$. This makes it possible to provide per-domain defaults in alias files
6115 that include the domains in the keys. If the second lookup fails (or doesn't
6116 take place because there is no @@ in the key), `$*$' is looked up.
6117 For example, a \%redirect%\ router might contain:
6118 .display asis
6119 data = ${lookup{$local_part@$domain}lsearch*@{/etc/mixed-aliases}}
6120 .endd
6121 Suppose the address that is being processed is \*jane@@eyre.example*\. Exim
6122 looks up these keys, in this order:
6123 .display asis
6124 jane@eyre.example
6125 *@eyre.example
6126 *
6127 .endd
6128 The data is taken from whichever key it finds first. \**Note**\: in an
6129 \%lsearch%\ file, this does not mean the first of these keys in the file. A
6130 complete scan is done for each key, and only if it is not found at all does
6131 Exim move on to try the next key.
6132
6133
6134 .section Partial matching in single-key lookups
6135 .rset SECTpartiallookup "~~chapter.~~section"
6136 .index partial matching
6137 .index wildcard lookups
6138 .index lookup||partial matching
6139 .index lookup||wildcard
6140 .index asterisk||in search type
6141 The normal operation of a single-key lookup is to search the file for an exact
6142 match with the given key. However, in a number of situations where domains are
6143 being looked up, it is useful to be able to do partial matching. In this case,
6144 information in the file that has a key starting with `$*$.' is matched by any
6145 domain that ends with the components that follow the full stop. For example, if
6146 a key in a DBM file is
6147 .display
6148 *.dates.fict.example
6149 .endd
6150 then when partial matching is enabled this is matched by (amongst others)
6151 \*2001.dates.fict.example*\ and \*1984.dates.fict.example*\. It is also matched
6152 by \*dates.fict.example*\, if that does not appear as a separate key in the
6153 file.
6154
6155 \**Note**\: Partial matching is not available for query-style lookups. It is
6156 also not available for any lookup items in address lists (see section
6157 ~~SECTaddresslist).
6158
6159 Partial matching is implemented by doing a series of separate lookups using
6160 keys constructed by modifying the original subject key. This means that it can
6161 be used with any of the single-key lookup types, provided that
6162 partial matching keys
6163 beginning with a special prefix (default `$*$.') are included in the data file.
6164 Keys in the file that do not begin with the prefix are matched only by
6165 unmodified subject keys when partial matching is in use.
6166
6167 Partial matching is requested by adding the string `partial-' to the front of
6168 the name of a single-key lookup type, for example, \partial-dbm\. When this is
6169 done, the subject key is first looked up unmodified; if that fails, `$*$.'
6170 is added at the start of the subject key, and it is looked up again. If that
6171 fails, further lookups are tried with dot-separated components removed
6172 from the start of the subject key, one-by-one, and `$*$.' added on the front of
6173 what remains.
6174
6175 A minimum number of two non-$*$ components are required. This can be adjusted
6176 by including a number before the hyphen in the search type. For example,
6177 \partial3-lsearch\ specifies a minimum of three non-$*$ components in the
6178 modified keys. Omitting the number is equivalent to `partial2-'. If the subject
6179 key is \*2250.dates.fict.example*\ then the following keys are looked up when
6180 the minimum number of non-$*$ components is two:
6181 .display asis
6182 2250.dates.fict.example
6183 *.2250.dates.fict.example
6184 *.dates.fict.example
6185 *.fict.example
6186 .endd
6187 As soon as one key in the sequence is successfully looked up, the lookup
6188 finishes.
6189
6190 .index lookup||partial matching, changing prefix
6191 .index prefix||for partial matching
6192 The use of `$*$.' as the partial matching prefix is a default that can be
6193 changed. The motivation for this feature is to allow Exim to operate with file
6194 formats that are used by other MTAs. A different prefix can be supplied in
6195 parentheses instead of the hyphen after `partial'. For example:
6196 .display asis
6197 domains = partial(.)lsearch;/some/file
6198 .endd
6199 In this example, if the domain is \*a.b.c*\, the sequence of lookups is
6200 \"a.b.c"\, \".a.b.c"\, and \".b.c"\ (the default minimum of 2 non-wild
6201 components is unchanged). The prefix may consist of any punctuation characters
6202 other than a closing parenthesis. It may be empty, for example:
6203 .display asis
6204 domains = partial1()cdb;/some/file
6205 .endd
6206 For this example, if the domain is \*a.b.c*\, the sequence of lookups is
6207 \"a.b.c"\, \"b.c"\, and \"c"\.
6208
6209 If `partial0' is specified, what happens at the end (when the lookup with just
6210 one non-wild component has failed, and the original key is shortened right down
6211 to the null string) depends on the prefix:
6212 .numberpars $.
6213 If the prefix has zero length, the whole lookup fails.
6214 .nextp
6215 If the prefix has length 1, a lookup for just the prefix is done. For
6216 example, the final lookup for `partial0(.)' is for \"."\ alone.
6217 .nextp
6218 Otherwise, if the prefix ends in a dot, the dot is removed, and the
6219 remainder is looked up. With the default prefix, therefore, the final lookup is
6220 for `$*$' on its own.
6221 .nextp
6222 Otherwise, the whole prefix is looked up.
6223 .endp
6224
6225 If the search type ends in `$*$' or `$*$@@' (see section
6226 ~~SECTdefaultvaluelookups above), the search for an ultimate default that this
6227 implies happens after all partial lookups have failed. If `partial0' is
6228 specified, adding `$*$' to the search type has no effect with the default
6229 prefix, because the `$*$' key is already included in the sequence of partial
6230 lookups. However, there might be a use for lookup types such as
6231 `partial0(.)lsearch$*$'.
6232
6233 The use of `$*$' in lookup partial matching differs from its use as a wildcard
6234 in domain lists and the like. Partial matching works only in terms of
6235 dot-separated components; a key such as \"*fict.example"\
6236 in a database file is useless, because the asterisk in a partial matching
6237 subject key is always followed by a dot.
6238
6239
6240
6241 .section Lookup caching
6242 .index lookup||caching
6243 .index caching||lookup data
6244 .em
6245 Exim caches all lookup results in order to avoid needless repetition of 
6246 lookups. However, because (apart from the daemon) Exim operates as a collection
6247 of independent, short-lived processes, this caching applies only within a
6248 single Exim process. There is no inter-process caching facility.
6249
6250 For single-key lookups, Exim keeps the relevant files open in case there is
6251 another lookup that needs them. In some types of configuration this can lead to
6252 many files being kept open for messages with many recipients. To avoid hitting
6253 the operating system limit on the number of simultaneously open files, Exim
6254 closes the least recently used file when it needs to open more files than its
6255 own internal limit, which can be changed via the \lookup@_open@_max\ option.
6256
6257 The single-key lookup files are closed and the lookup caches are flushed at
6258 strategic points during delivery -- for example, after all routing is complete.
6259 .nem
6260
6261
6262 .section Quoting lookup data
6263 .index lookup||quoting
6264 .index quoting||in lookups
6265 When data from an incoming message is included in a query-style lookup, there
6266 is the possibility of special characters in the data messing up the syntax of
6267 the query. For example, a NIS+ query that contains
6268 .display asis
6269 [name=$local_part]
6270 .endd
6271 will be broken if the local part happens to contain a closing square bracket.
6272 For NIS+, data can be enclosed in double quotes like this:
6273 .display asis
6274 [name="$local_part"]
6275 .endd
6276 but this still leaves the problem of a double quote in the data. The rule for
6277 NIS+ is that double quotes must be doubled. Other lookup types have different
6278 rules, and to cope with the differing requirements, an expansion operator
6279 of the following form is provided:
6280 .display
6281 @$@{quote@_<<lookup-type>>:<<string>>@}
6282 .endd
6283 For example, the safest way to write the NIS+ query is
6284 .display asis
6285 [name="${quote_nisplus:$local_part}"]
6286 .endd
6287 See chapter ~~CHAPexpand for full coverage of string expansions. The quote
6288 operator can be used for all lookup types, but has no effect for single-key
6289 lookups, since no quoting is ever needed in their key strings.
6290
6291
6292
6293 .section More about dnsdb
6294 .rset SECTdnsdb "~~chapter.~~section"
6295 .index dnsdb lookup
6296 .index lookup||dnsdb
6297 .index DNS||as a lookup type
6298 The \%dnsdb%\ lookup type uses the DNS as its database. A simple query consists
6299 of a record type and a domain name, separated by an equals sign. For example,
6300 an expansion string could contain:
6301 .display asis
6302 ${lookup dnsdb{mx=a.b.example}{$value}fail}
6303 .endd
6304 The supported DNS record types are A, CNAME, MX, NS, PTR, SRV, and TXT, and,
6305 when Exim is compiled with IPv6 support, AAAA (and A6 if that is also
6306 configured). If no type is given, TXT is assumed. When the type is PTR,
6307 .em
6308 the data can be an IP address, written as normal; inversion and the addition of
6309 \in-addr.arpa\ or \ip6.arpa\ happens automatically. For example:
6310 .display asis
6311 ${lookup dnsdb{ptr=192.168.4.5}{$value}fail}
6312 .endd
6313 If the data for a PTR record is not a syntactically valid IP address, it is not
6314 altered and nothing is added.
6315
6316 For any record type, if multiple records are found (or, for A6 lookups, if a
6317 single record leads to multiple addresses), the data is returned as a
6318 concatenation, with newline as the default separator. The order, of course,
6319 depends on the DNS resolver. You can specify a different separator character
6320 between multiple records by putting a right angle-bracket followed immediately
6321 by the new separator at the start of the query. For example:
6322 .display asis
6323 ${lookup dnsdb{>: a=host1.example}}
6324 .endd
6325 It is permitted to specify a space as the separator character. Further 
6326 whitespace is ignored.
6327
6328 .index SRV record||in \%dnsdb%\ lookup
6329 For SRV records, the priority, weight, port, and host name are returned for 
6330 each record, separated by spaces.
6331
6332 .index MX record||in \%dnsdb%\ lookup
6333 For MX records, both the preference value and the host name are returned for 
6334 each record, separated by a space. However, if you want only host names, you
6335 can use the pseudo-type MXH:
6336 .display asis
6337 ${lookup dnsdb{mxh=a.b.example}}
6338 .endd
6339 In this case, the preference values are omitted.
6340
6341 .index name server||for enclosing domain
6342 Another pseudo-type is ZNS (for `zone NS'). It performs a lookup for NS
6343 records on the given domain, but if none are found, it removes the first
6344 component of the domain name, and tries again. This process continues until NS
6345 records are found or there are no more components left (or there is a DNS
6346 error). In other words, it may return the name servers for a top-level domain,
6347 but it never returns the root name servers. If there are no NS records for the
6348 top-level domain, the lookup fails. Consider these examples:
6349 .display asis
6350 ${lookup dnsdb{zns=xxx.quercite.com}} 
6351 ${lookup dnsdb{zns=xxx.edu}}
6352 .endd
6353 Assuming that in each case there are no NS records for the full domain name,
6354 the first returns the name servers for \quercite.com\, and the second returns
6355 the name servers for \edu\.
6356
6357 You should be careful about how you use this lookup because, unless the
6358 top-level domain does not exist, the lookup always returns some host names. The
6359 sort of use to which this might be put is for seeing if the name servers for a
6360 given domain are on a blacklist. You can probably assume that the name servers
6361 for the high-level domains such as \com\ or \co.uk\ are not going to be on such
6362 a list.
6363
6364 .nem
6365
6366 .em
6367 .section Multiple dnsdb lookups
6368 In the previous section, \%dnsdb%\ lookups for a single domain are described.
6369 However, you can specify a list of domains or IP addresses in a single
6370 \%dnsdb%\ lookup. The list is specified in the normal Exim way, with colon as
6371 the default separator, but with the ability to change this. For example:
6372 .display asis
6373 ${lookup dnsdb{one.domain.com:two.domain.com}}
6374 ${lookup dnsdb{a=one.host.com:two.host.com}}
6375 ${lookup dnsdb{ptr = <; 1.2.3.4 ; 4.5.6.8}}
6376 .endd
6377 In order to retain backwards compatibility, there is one special case: if
6378 the lookup type is PTR and no change of separator is specified, Exim looks
6379 to see if the rest of the string is precisely one IPv6 address. In this
6380 case, it does not treat it as a list.
6381
6382 The data from each lookup is concatenated, with newline separators by default,
6383 in the same way that multiple DNS records for a single item are handled. A 
6384 different separator can be specified, as described above.
6385
6386 The \%dnsdb%\ lookup fails only if all the DNS lookups fail. If there is a
6387 temporary DNS error for any of them, the behaviour is controlled by
6388 an optional keyword followed by a comma that may appear before the record
6389 type. The possible keywords are `defer@_strict', `defer@_never', and
6390 `defer@_lax'. With `strict' behaviour, any temporary DNS error causes the
6391 whole lookup to defer. With `never' behaviour, a temporary DNS error is
6392 ignored, and the behaviour is as if the DNS lookup failed to find anything.
6393 With `lax' behaviour, all the queries are attempted, but a temporary DNS
6394 error causes the whole lookup to defer only if none of the other lookups
6395 succeed. The default is `lax', so the following lookups are equivalent:
6396 .display asis
6397 ${lookup dnsdb{defer_lax,a=one.host.com:two.host.com}}
6398 ${lookup dnsdb{a=one.host.com:two.host.com}}
6399 .endd
6400 Thus, in the default case, as long as at least one of the DNS lookups
6401 yields some data, the lookup succeeds.
6402 .nem
6403
6404
6405 .section More about LDAP
6406 .rset SECTldap "~~chapter.~~section"
6407 .index LDAP lookup
6408 .index lookup||LDAP
6409 .index Solaris||LDAP
6410 The original LDAP implementation came from the University of Michigan; this has
6411 become `Open LDAP', and there are now two different releases. Another
6412 implementation comes from Netscape, and Solaris 7 and subsequent releases
6413 contain inbuilt LDAP support. Unfortunately, though these are all compatible at
6414 the lookup function level, their error handling is different. For this reason
6415 it is necessary to set a compile-time variable when building Exim with LDAP, to
6416 indicate which LDAP library is in use. One of the following should appear in
6417 your \(Local/Makefile)\:
6418 .display asis
6419 LDAP_LIB_TYPE=UMICHIGAN
6420 LDAP_LIB_TYPE=OPENLDAP1
6421 LDAP_LIB_TYPE=OPENLDAP2
6422 LDAP_LIB_TYPE=NETSCAPE
6423 LDAP_LIB_TYPE=SOLARIS
6424 .endd
6425 If \\LDAP@_LIB@_TYPE\\ is not set, Exim assumes \"OPENLDAP1"\, which has the
6426 same interface as the University of Michigan version.
6427
6428 There are three LDAP lookup types in Exim. These behave slightly differently in
6429 the way they handle the results of a query:
6430 .numberpars $.
6431 \%ldap%\ requires the result to contain just one entry; if there are more, it
6432 gives an error.
6433 .nextp
6434 \%ldapdn%\ also requires the result to contain just one entry, but it is the
6435 Distinguished Name that is returned rather than any attribute values.
6436 .nextp
6437 \%ldapm%\ permits the result to contain more than one entry; the attributes from
6438 all of them are returned.
6439 .endp
6440
6441 For \%ldap%\ and \%ldapm%\, if a query finds only entries with no attributes,
6442 Exim behaves as if the entry did not exist, and the lookup fails. The format of
6443 the data returned by a successful lookup is described in the next section.
6444 First we explain how LDAP queries are coded.
6445
6446 .section Format of LDAP queries
6447 .rset SECTforldaque "~~chapter.~~section"
6448 .index LDAP||query format
6449 An LDAP query takes the form of a URL as defined in RFC 2255. For example, in
6450 the configuration of a \%redirect%\ router one might have this setting:
6451 .display asis
6452 data = ${lookup ldap \
6453   {ldap:///cn=$local_part,o=University%20of%20Cambridge,\
6454   c=UK?mailbox?base?}}
6455 .endd
6456 .index LDAP||with TLS
6457 The URL may begin with \"ldap"\ or \"ldaps"\ if your LDAP library supports
6458 secure (encrypted) LDAP connections. The second of these ensures that an
6459 encrypted TLS connection is used.
6460
6461 .section LDAP quoting
6462 .index LDAP||quoting
6463 Two levels of quoting are required in LDAP queries, the first for LDAP itself
6464 and the second because the LDAP query is represented as a URL. Furthermore,
6465 within an LDAP query, two different kinds of quoting are required. For this
6466 reason, there are two different LDAP-specific quoting operators.
6467
6468 The \quote@_ldap\ operator is designed for use on strings that are part of
6469 filter specifications. Conceptually, it first does the following conversions on
6470 the string:
6471 .display asis
6472 *   =>   \2A
6473 (   =>   \28
6474 )   =>   \29
6475 \   =>   \5C
6476 .endd
6477 in accordance with RFC 2254. The resulting string is then quoted according
6478 to the rules for URLs, that is, all characters except
6479 .display asis
6480 ! $ ' - . _ ( ) * +
6481 .endd
6482 are converted to their hex values, preceded by a percent sign. For example:
6483 .display asis
6484 ${quote_ldap: a(bc)*, a<yz>; }
6485 .endd
6486 yields
6487 .display asis
6488 %20a%5C28bc%5C29%5C2A%2C%20a%3Cyz%3E%3B%20
6489 .endd
6490 Removing the URL quoting, this is (with a leading and a trailing space):
6491 .display asis
6492 a\28bc\29\2A, a<yz>;
6493 .endd
6494
6495 The \quote@_ldap@_dn\ operator is designed for use on strings that are part of
6496 base DN specifications in queries. Conceptually, it first converts the string
6497 by inserting a backslash in front of any of the following characters:
6498 .display asis
6499 , + " \ < > ;
6500 .endd
6501 It also inserts a backslash before any leading spaces or @# characters, and
6502 before any trailing spaces. (These rules are in RFC 2253.) The resulting string
6503 is then quoted according to the rules for URLs. For example:
6504 .display asis
6505 ${quote_ldap_dn: a(bc)*, a<yz>; }
6506 .endd
6507 yields
6508 .display asis
6509 %5C%20a(bc)*%5C%2C%20a%5C%3Cyz%5C%3E%5C%3B%5C%20
6510 .endd
6511 Removing the URL quoting, this is (with a trailing space):
6512 .display asis
6513 \ a(bc)*\, a\<yz\>\;\
6514 .endd
6515 There are some further comments about quoting in the section on LDAP
6516 authentication below.
6517
6518 .section LDAP connections
6519 .index LDAP||connections
6520 The connection to an LDAP server may either be over TCP/IP, or, when OpenLDAP
6521 is in use, via a Unix domain socket. The example given above does not specify
6522 an LDAP server. A server that is reached by TCP/IP can be specified in a query
6523 by starting it with
6524 .display
6525 ldap://<<hostname>>:<<port>>/...
6526 .endd
6527 If the port (and preceding colon) are omitted, the standard LDAP port (389) is
6528 used. When no server is specified in a query, a list of default servers is
6529 taken from the \ldap@_default@_servers\ configuration option. This supplies a
6530 colon-separated list of servers which are tried in turn until one successfully
6531 handles a query, or there is a serious error. Successful handling either
6532 returns the requested data, or indicates that it does not exist. Serious errors
6533 are syntactical, or multiple values when only a single value is expected.
6534 Errors which cause the next server to be tried are connection failures, bind
6535 failures, and timeouts.
6536
6537 For each server name in the list, a port number can be given. The standard way
6538 of specifing a host and port is to use a colon separator (RFC 1738). Because
6539 \ldap@_default@_servers\ is a colon-separated list, such colons have to be
6540 doubled. For example
6541 .display asis
6542 ldap_default_servers = ldap1.example.com::145:ldap2.example.com
6543 .endd
6544 If \ldap@_default@_servers\ is unset, a URL with no server name is passed
6545 to the LDAP library with no server name, and the library's default (normally
6546 the local host) is used.
6547
6548 If you are using the OpenLDAP library, you can connect to an LDAP server using
6549 a Unix domain socket instead of a TCP/IP connection. This is specified by using
6550 \"ldapi"\ instead of \"ldap"\ in LDAP queries. What follows here applies only
6551 to OpenLDAP. If Exim is compiled with a different LDAP library, this feature is
6552 not available.
6553
6554 For this type of connection, instead of a host name for the server, a pathname
6555 for the socket is required, and the port number is not relevant. The pathname
6556 can be specified either as an item in \ldap@_default@_servers\, or inline in
6557 the query. In the former case, you can have settings such as
6558 .display asis
6559 ldap_default_servers = /tmp/ldap.sock : backup.ldap.your.domain
6560 .endd
6561 When the pathname is given in the query, you have to escape the slashes as
6562 \"%2F"\ to fit in with the LDAP URL syntax. For example:
6563 .display asis
6564 ${lookup ldap {ldapi://%2Ftmp%2Fldap.sock/o=...
6565 .endd
6566 When Exim processes an LDAP lookup and finds that the `hostname' is really
6567 a pathname, it uses the Unix domain socket code, even if the query actually
6568 specifies \"ldap"\ or \"ldaps"\. In particular, no encryption is used for a
6569 socket connection. This behaviour means that you can use a setting of
6570 \ldap@_default@_servers\ such as in the example above with traditional \"ldap"\
6571 or \"ldaps"\ queries, and it will work. First, Exim tries a connection via
6572 the Unix domain socket; if that fails, it tries a TCP/IP connection to the
6573 backup host.
6574
6575 If an explicit \"ldapi"\ type is given in a query when a host name is
6576 specified, an error is diagnosed. However, if there are more items in
6577 \ldap@_default@_servers\, they are tried. In other words:
6578 .numberpars $.
6579 Using a pathname with \"ldap"\ or \"ldaps"\ forces the use of the Unix domain
6580 interface.
6581 .nextp
6582 Using \"ldapi"\ with a host name causes an error.
6583 .endp
6584
6585 Using \"ldapi"\ with no host or path in the query, and no setting of
6586 \ldap@_default@_servers\, does whatever the library does by default.
6587
6588
6589 .section LDAP authentication and control information
6590 .index LDAP||authentication
6591 The LDAP URL syntax provides no way of passing authentication and other control
6592 information to the server. To make this possible, the URL in an LDAP query may
6593 be preceded by any number of `<<name>>=<<value>>' settings, separated by
6594 spaces. If a value contains spaces it must be enclosed in double quotes, and
6595 when double quotes are used, backslash is interpreted in the usual way inside
6596 them. The following names are recognized:
6597 .display
6598 DEREFERENCE $rm{set the dereferencing parameter}
6599 .newline
6600 .em
6601 NETTIME     $rm{set a timeout for a network operation}
6602 .nem
6603 .newline
6604 USER        $rm{set the DN, for authenticating the LDAP bind}
6605 PASS        $rm{set the password, likewise}
6606 SIZE        $rm{set the limit for the number of entries returned}
6607 TIME        $rm{set the maximum waiting time for a query}
6608 .endd
6609 The value of the \\DEREFERENCE\\ parameter must be one of the words `never',
6610 `searching', `finding', or `always'.
6611
6612 .em
6613 The name \\CONNECT\\ is an obsolete name for \\NETTIME\\, retained for
6614 backwards compatibility. This timeout (specified as a number of seconds) is
6615 enforced from the client end for operations that can be carried out over a
6616 network. Specifically, it applies to network connections and calls to the
6617 \*ldap@_result()*\ function. If the value is greater than zero, it is used if
6618 \\LDAP@_OPT@_NETWORK@_TIMEOUT\\ is defined in the LDAP headers (OpenLDAP), or 
6619 if \\LDAP@_X@_OPT@_CONNECT@_TIMEOUT\\ is defined in the LDAP headers (Netscape 
6620 SDK 4.1). A value of zero forces an explicit setting of `no timeout' for 
6621 Netscape SDK; for OpenLDAP no action is taken.
6622
6623 The \\TIME\\ parameter (also a number of seconds) is passed to the server to
6624 set a server-side limit on the time taken to complete a search.
6625 .nem
6626
6627 Here is an example of an LDAP query in an Exim lookup that uses some of these
6628 values. This is a single line, folded for ease of reading:
6629 .display asis
6630 .indent 0
6631 ${lookup ldap
6632   {user="cn=manager,o=University of Cambridge,c=UK" pass=secret
6633   ldap:///o=University%20of%20Cambridge,c=UK?sn?sub?(cn=foo)}
6634   {$value}fail}
6635 .endd
6636 The encoding of spaces as %20 is a URL thing which should not be done for any
6637 of the auxiliary data. Exim configuration settings that include lookups which
6638 contain password information should be preceded by `hide' to prevent non-admin
6639 users from using the \-bP-\ option to see their values.
6640
6641 The auxiliary data items may be given in any order. The default is no
6642 connection timeout (the system timeout is used), no user or password, no limit
6643 on the number of entries returned, and no time limit on queries.
6644
6645 When a DN is quoted in the \\USER=\\ setting for LDAP authentication, Exim
6646 removes any URL quoting that it may contain before passing it LDAP. Apparently
6647 some libraries do this for themselves, but some do not. Removing the URL
6648 quoting has two advantages:
6649 .numberpars $.
6650 It makes it possible to use the same \quote@_ldap@_dn\ expansion for \\USER=\\
6651 DNs as with DNs inside actual queries.
6652 .nextp
6653 It permits spaces inside \\USER=\\ DNs.
6654 .endp
6655 For example, a setting such as
6656 .display asis
6657 USER=cn=${quote_ldap_dn:$1}
6658 .endd
6659 should work even if \$1$\ contains spaces.
6660
6661 Expanded data for the \\PASS=\\ value should be quoted using the \quote\
6662 expansion operator, rather than the LDAP quote operators. The only reason this
6663 field needs quoting is to ensure that it conforms to the Exim syntax, which
6664 does not allow unquoted spaces. For example:
6665 .display asis
6666 PASS=${quote:$3}
6667 .endd
6668
6669 The LDAP authentication mechanism can be used to check passwords as part of
6670 SMTP authentication. See the \ldapauth\ expansion string condition in chapter
6671 ~~CHAPexpand.
6672
6673
6674 .section Format of data returned by LDAP
6675 .index LDAP||returned data formats
6676 The \%ldapdn%\ lookup type returns the Distinguished Name from a single entry as
6677 a sequence of values, for example
6678 .display asis
6679 cn=manager, o=University of Cambridge, c=UK
6680 .endd
6681
6682 The \%ldap%\ lookup type generates an error if more than one entry matches the
6683 search filter, whereas \%ldapm%\ permits this case, and inserts a newline in
6684 the result between the data from different entries. It is possible for multiple
6685 values to be returned for both \%ldap%\ and \%ldapm%\, but in the former case
6686 you know that whatever values are returned all came from a single entry in the
6687 directory.
6688
6689 In the common case where you specify a single attribute in your LDAP query, the
6690 result is not quoted, and does not contain the attribute name. If the attribute
6691 has multiple values, they are separated by commas.
6692
6693 If you specify multiple attributes, the result contains space-separated, quoted
6694 strings, each preceded by the attribute name and an equals sign. Within the
6695 quotes, the quote character, backslash, and newline are escaped with
6696 backslashes, and commas are used to separate multiple values for the attribute.
6697 Apart from the escaping, the string within quotes takes the same form as the
6698 output when a single attribute is requested. Specifying no attributes is the
6699 same as specifying all of an entry's attributes.
6700
6701 Here are some examples of the output format. The first line of each pair is an
6702 LDAP query, and the second is the data that is returned. The attribute called
6703 \attr1\ has two values, whereas \attr2\ has only one value:
6704 .display asis
6705 ldap:///o=base?attr1?sub?(uid=fred)
6706 value1.1, value1.2
6707
6708 ldap:///o=base?attr2?sub?(uid=fred)
6709 value two
6710
6711 ldap:///o=base?attr1,attr2?sub?(uid=fred)
6712 attr1="value1.1, value1.2" attr2="value two"
6713
6714 ldap:///o=base??sub?(uid=fred)
6715 objectClass="top" attr1="value1.1, value1.2" attr2="value two"
6716 .endd
6717 The \extract\ operator in string expansions can be used to pick out individual
6718 fields from data that consists of $it{key}=$it{value} pairs. You can make use
6719 of Exim's \-be-\ option to run expansion tests and thereby check the results of
6720 LDAP lookups.
6721
6722
6723
6724 .section More about NIS+
6725 .rset SECTnisplus "~~chapter.~~section"
6726 .index NIS@+ lookup type
6727 .index lookup||NIS+
6728 NIS+ queries consist of a NIS+ \*indexed name*\ followed by an optional colon
6729 and field name. If this is given, the result of a successful query is the
6730 contents of the named field; otherwise the result consists of a concatenation
6731 of \*field-name=field-value*\ pairs, separated by spaces. Empty values and
6732 values containing spaces are quoted. For example, the query
6733 .display asis
6734 [name=mg1456],passwd.org_dir
6735 .endd
6736 might return the string
6737 .display asis
6738 name=mg1456 passwd="" uid=999 gid=999 gcos="Martin Guerre"
6739 home=/home/mg1456 shell=/bin/bash shadow=""
6740 .endd
6741 (split over two lines here to fit on the page), whereas
6742 .display asis
6743 [name=mg1456],passwd.org_dir:gcos
6744 .endd
6745 would just return
6746 .display asis
6747 Martin Guerre
6748 .endd
6749 with no quotes. A NIS+ lookup fails if NIS+ returns more than one table entry
6750 for the given indexed key. The effect of the \quote@_nisplus\ expansion
6751 operator is to double any quote characters within the text.
6752
6753
6754 .section More about MySQL, PostgreSQL, Oracle, and Interbase
6755 .rset SECTsql "~~chapter.~~section"
6756 .index MySQL||lookup type
6757 .index PostgreSQL lookup type
6758 .index lookup||MySQL
6759 .index lookup||PostgreSQL
6760 .index Oracle||lookup type
6761 .index lookup||Oracle
6762 .index Interbase lookup type
6763 .index lookup||Interbase
6764 If any MySQL, PostgreSQL, Oracle, or Interbase lookups are used, the
6765 \mysql@_servers\, \pgsql@_servers\, \oracle@_servers\, or \ibase@_servers\
6766 option (as appropriate) must be set to a colon-separated list of server
6767 information. Each item in the list is a slash-separated list of four items:
6768 host name, database name, user name, and password. In the case of Oracle, the
6769 host name field is used for the `service name', and the database name field is
6770 not used and should be empty. For example:
6771 .display asis
6772 hide oracle_servers = oracle.plc.example//ph10/abcdwxyz
6773 .endd
6774 Because password data is sensitive, you should always precede the setting with
6775 `hide', to prevent non-admin users from obtaining the setting via the \-bP-\
6776 option. Here is an example where two MySQL servers are listed:
6777 .display asis
6778 hide mysql_servers = localhost/users/root/secret:\
6779                      otherhost/users/root/othersecret
6780 .endd
6781 For MySQL and PostgreSQL, a host may be specified as <<name>>:<<port>> but
6782 because this is a colon-separated list, the colon has to be doubled.
6783
6784 For each query, these parameter groups are tried in order until a connection
6785 and a query succeeds. Queries for these databases are SQL statements, so an
6786 example might be
6787 .display asis
6788 .indent 0
6789 ${lookup mysql{select mailbox from users where id='ph10'}{$value}fail}
6790 .endd
6791 If the result of the query contains more than one field, the data for
6792 each field in the row is returned, preceded by its name, so the result
6793 of
6794 .display asis
6795 .indent 0
6796 ${lookup pgsql{select home,name from users where id='ph10'}{$value}}
6797 .endd
6798 might be
6799 .display asis
6800 home=/home/ph10 name="Philip Hazel"
6801 .endd
6802 Values containing spaces and empty values are double quoted, with embedded
6803 quotes escaped by a backslash.
6804
6805 If the result of the query contains just one field, the value is passed back
6806 verbatim, without a field name, for example:
6807 .display asis
6808 Philip Hazel
6809 .endd
6810 If the result of the query yields more than one row, it is all concatenated,
6811 with a newline between the data for each row.
6812
6813 The \quote@_mysql\, \quote@_pgsql\, and \quote@_oracle\ expansion operators
6814 convert newline, tab, carriage return, and backspace to @\n, @\t, @\r, and @\b
6815 respectively, and the characters single-quote, double-quote, and backslash
6816 itself are escaped with backslashes. The \quote@_pgsql\ expansion operator, in
6817 addition, escapes the percent and underscore characters. This cannot be done
6818 for MySQL because these escapes are not recognized in contexts where these
6819 characters are not special.
6820
6821
6822 .section Special MySQL features
6823 For MySQL, an empty host name or the use of `localhost' in \mysql@_servers\
6824 causes a connection to the server on the local host by means of a Unix domain
6825 socket. An alternate socket can be specified in parentheses. The full syntax of
6826 each item in \mysql@_servers\ is:
6827 .display
6828 <<hostname>>@:@:<<port>>(<<socket name>>)/<<database>>/<<user>>/<<password>>
6829 .endd
6830 Any of the three sub-parts of the first field can be omitted. For normal use on
6831 the local host it can be left blank or set to just `localhost'.
6832
6833 No database need be supplied -- but if it is absent here, it must be given in
6834 the queries.
6835
6836 If a MySQL query is issued that does not request any data (an insert, update,
6837 or delete command), the result of the lookup is the number of rows affected.
6838 .em
6839 \**Warning**\: this can be misleading. If an update does not actually change 
6840 anything (for example, setting a field to the value it already has), the result 
6841 is zero because no rows are affected.
6842 .nem
6843
6844
6845 .section Special PostgreSQL features
6846 PostgreSQL lookups can also use Unix domain socket connections to the database.
6847 This is usually faster and costs less CPU time than a TCP/IP connection.
6848 However it can be used only if the mail server runs on the same machine as the
6849 database server. A configuration line for PostgreSQL via Unix domain sockets
6850 looks like this:
6851 .display asis
6852 hide pgsql_servers = (/tmp/.s.PGSQL.5432)/db/user/password : ...
6853 .endd
6854 In other words, instead of supplying a host name, a path to the socket is
6855 given. The path name is enclosed in parentheses so that its slashes aren't
6856 visually confused with the delimiters for the other server parameters.
6857
6858 If a PostgreSQL query is issued that does not request any data (an insert,
6859 update, or delete command), the result of the lookup is the number of rows
6860 affected.
6861
6862
6863
6864
6865 .
6866 .
6867 .
6868 .
6869 . ============================================================================
6870 .chapter Domain, host, address, and local part lists
6871 .set runningfoot "domain, host, and address lists"
6872 .rset CHAPdomhosaddlists "~~chapter"
6873 .index list||of domains, hosts, etc.
6874 A number of Exim configuration options contain lists of domains, hosts,
6875 email addresses, or local parts. For example, the \hold@_domains\ option
6876 contains a list of domains whose delivery is currently suspended. These lists
6877 are also used as data in ACL statements (see chapter ~~CHAPACL).
6878
6879 Each item in one of these lists is a pattern to be matched against a domain,
6880 host, email address, or local part, respectively. In the sections below, the
6881 different types of pattern for each case are described, but first we cover some
6882 general facilities that apply to all four kinds of list.
6883
6884
6885 .section Expansion of lists
6886 .index expansion||of lists
6887 .em
6888 Each list is expanded as a single string before it is used. The result of
6889 expansion must be a list, possibly containing empty items, which is split up 
6890 into separate items for matching. By default, colon is the separator character,
6891 but this can be varied if necessary. See sections ~~SECTlistconstruct and
6892 ~~SECTempitelis for details of the list syntax; the second of these discusses  
6893 the way you specify empty list items.
6894 .nem
6895
6896 If the string expansion is forced to fail, Exim behaves as if the item it is
6897 testing (domain, host, address, or local part) is not in the list. Other
6898 expansion failures cause temporary errors.
6899
6900 If an item in a list is a regular expression, backslashes, dollars and possibly
6901 other special characters in the expression must be protected against
6902 misinterpretation by the string expander. The easiest way to do this is to use
6903 the \"@\N"\ expansion feature to indicate that the contents of the regular
6904 expression should not be expanded. For example, in an ACL you might have:
6905 .display asis
6906 deny senders = \N^\d{8}\w@.*\.baddomain\.example$\N :
6907                ${lookup{$domain}lsearch{/badsenders/bydomain}}
6908 .endd
6909 The first item is a regular expression that is protected from expansion by
6910 \"@\N"\, whereas the second uses the expansion to obtain a list of unwanted
6911 senders based on the receiving domain.
6912
6913
6914
6915 .section Negated items in lists
6916 .index list||negation
6917 .index negation in lists
6918 Items in a list may be positive or negative. Negative items are indicated by a
6919 leading exclamation mark, which may be followed by optional white space. A list
6920 defines a set of items (domains, etc). When Exim processes one of these lists,
6921 it is trying to find out whether a domain, host, address, or local part
6922 (respectively) is in the set that is defined by the list. It works like this:
6923
6924 The list is scanned from left to right. If a positive item is matched, the
6925 subject that is being checked is in the set; if a negative item is matched, the
6926 subject is not in the set. If the end of the list is reached without the
6927 subject having matched any of the patterns, it is in the set if the last item
6928 was a negative one, but not if it was a positive one. For example, the list in
6929 .display asis
6930 domainlist relay_domains = !a.b.c : *.b.c
6931 .endd
6932 matches any domain ending in \*.b.c*\ except for \*a.b.c*\. Domains that match
6933 neither \*a.b.c*\ nor \*@*.b.c*\ do not match, because the last item in the
6934 list is positive. However, if the setting were
6935 .display asis
6936 domainlist relay_domains = !a.b.c
6937 .endd
6938 then all domains other than \*a.b.c*\ would match because the last item in the
6939 list is negative. In other words, a list that ends with a negative item behaves
6940 as if it had an extra item \":*"\ on the end.
6941
6942 Another way of thinking about positive and negative items in lists is to read
6943 the connector as `or' after a positive item and as `and' after a negative
6944 item.
6945
6946
6947 .section File names in lists
6948 .rset SECTfilnamlis "~~chapter.~~section"
6949 .index list||file name in
6950 If an item in a domain, host, address, or local part list is an absolute file
6951 name (beginning with a slash character), each line of the file is read and
6952 processed as if it were an independent item in the list, except that further
6953 file names are not allowed,
6954 and no expansion of the data from the file takes place.
6955 Empty lines in the file are ignored, and the file may also contain comment
6956 lines:
6957 .numberpars $.
6958 For domain and host lists, if a @# character appears anywhere in a line of the
6959 file, it and all following characters are ignored.
6960 .nextp
6961 Because local parts may legitimately contain @# characters, a comment in an
6962 address list or local part list file is recognized only if @# is preceded by
6963 white space or the start of the line. For example:
6964 .display asis
6965 not#comment@x.y.z   # but this is a comment
6966 .endd
6967 .endp
6968 Putting a file name in a list has the same effect as inserting each line of the
6969 file as an item in the list (blank lines and comments excepted). However, there
6970 is one important difference: the file is read each time the list is processed,
6971 so if its contents vary over time, Exim's behaviour changes.
6972
6973 If a file name is preceded by an exclamation mark, the sense of any match
6974 within the file is inverted. For example, if
6975 .display asis
6976 hold_domains = !/etc/nohold-domains
6977 .endd
6978 and the file contains the lines
6979 .display asis
6980 !a.b.c
6981 *.b.c
6982 .endd
6983 then \*a.b.c*\ is in the set of domains defined by \hold@_domains\, whereas any
6984 domain matching \"*.b.c"\ is not.
6985
6986
6987 .section An lsearch file is not an out-of-line list
6988 As will be described in the sections that follow, lookups can be used in lists
6989 to provide indexed methods of checking list membership. There has been some
6990 confusion about the way \%lsearch%\ lookups work in lists. Because
6991 an \%lsearch%\ file contains plain text and is scanned sequentially, it is
6992 sometimes thought that it is allowed to contain wild cards and other kinds of
6993 non-constant pattern. This is not the case. The keys in an \%lsearch%\ file are
6994 always fixed strings, just as for any other single-key lookup type.
6995
6996 If you want to use a file to contain wild-card patterns that form part of a
6997 list, just give the file name on its own, without a search type, as described
6998 in the previous section.
6999
7000
7001
7002 .section Named lists
7003 .rset SECTnamedlists "~~chapter.~~section"
7004 .index named lists
7005 .index list||named
7006 A list of domains, hosts, email addresses, or local parts can be given a name
7007 which is then used to refer to the list elsewhere in the configuration. This is
7008 particularly convenient if the same list is required in several different
7009 places. It also allows lists to be given meaningful names, which can improve
7010 the readability of the configuration. For example, it is conventional to define
7011 a domain list called \*local@_domains*\ for all the domains that are handled
7012 locally on a host, using a configuration line such as
7013 .display asis
7014 domainlist local_domains = localhost:my.dom.example
7015 .endd
7016 Named lists are referenced by giving their name preceded by a plus sign, so,
7017 for example, a router that is intended to handle local domains would be
7018 configured with the line
7019 .display asis
7020 domains = +local_domains
7021 .endd
7022 The first router in a configuration is often one that handles all domains
7023 except the local ones, using a configuration with a negated item like this:
7024 .display asis
7025 dnslookup:
7026   driver = dnslookup
7027   domains = ! +local_domains
7028   transport = remote_smtp
7029   no_more
7030 .endd
7031 The four kinds of named list are created by configuration lines starting with
7032 the words \domainlist\, \hostlist\, \addresslist\, or \localpartlist\,
7033 respectively. Then there follows the name that you are defining, followed by an
7034 equals sign and the list itself. For example:
7035 .display asis
7036 hostlist    relay_hosts = 192.168.23.0/24 : my.friend.example
7037 addresslist bad_senders = cdb;/etc/badsenders
7038 .endd
7039 A named list may refer to other named lists:
7040 .display asis
7041 domainlist  dom1 = first.example : second.example
7042 domainlist  dom2 = +dom1 : third.example
7043 domainlist  dom3 = fourth.example : +dom2 : fifth.example
7044 .endd
7045
7046 \**Warning**\: If the last item in a referenced list is a negative one, the
7047 effect may not be what you intended, because the negation does not propagate
7048 out to the higher level. For example, consider:
7049 .display asis
7050 domainlist  dom1 = !a.b
7051 domainlist  dom2 = +dom1 : *.b
7052 .endd
7053 The second list specifies `either in the \dom1\ list or \*@*.b*\'. The first
7054 list specifies just `not \*a.b*\', so the domain \*x.y*\ matches it. That means
7055 it matches the second list as well. The effect is not the same as
7056 .display asis
7057 domainlist  dom2 = !a.b : *.b
7058 .endd
7059 where \*x.y*\ does not match. It's best to avoid negation altogether in
7060 referenced lists if you can.
7061
7062 Named lists may have a performance advantage. When Exim is routing an
7063 address or checking an incoming message, it caches the result of tests on named
7064 lists. So, if you have a setting such as
7065 .display asis
7066 domains = +local_domains
7067 .endd
7068 on several of your routers
7069 or in several ACL statements,
7070 the actual test is done only for the first one. However, the caching works only
7071 if there are no expansions within the list itself or any sublists that it
7072 references. In other words, caching happens only for lists that are known to be
7073 the same each time they are referenced.
7074
7075 By default, there may be up to 16 named lists of each type. This limit can be
7076 extended by changing a compile-time variable. The use of domain and host lists
7077 is recommended for concepts such as local domains, relay domains, and relay
7078 hosts. The default configuration is set up like this.
7079
7080
7081 .section Named lists compared with macros
7082 .index list||named compared with macro
7083 .index macro||compared with named list
7084 At first sight, named lists might seem to be no different from macros in the
7085 configuration file. However, macros are just textual substitutions. If you
7086 write
7087 .display asis
7088 ALIST = host1 : host2
7089 auth_advertise_hosts = !ALIST
7090 .endd
7091 it probably won't do what you want, because that is exactly the same as
7092 .display asis
7093 auth_advertise_hosts = !host1 : host2
7094 .endd
7095 Notice that the second host name is not negated. However, if you use a host
7096 list, and write
7097 .display asis
7098 hostlist alist = host1 : host2
7099 auth_advertise_hosts = ! +alist
7100 .endd
7101 the negation applies to the whole list, and so that is equivalent to
7102 .display asis
7103 auth_advertise_hosts = !host1 : !host2
7104 .endd
7105
7106
7107 .section Named list caching
7108 .index list||caching of named
7109 .index caching||named lists
7110 While processing a message, Exim caches the result of checking a named list if
7111 it is sure that the list is the same each time. In practice, this means that
7112 the cache operates only if the list contains no @$ characters, which guarantees
7113 that it will not change when it is expanded. Sometimes, however, you may have
7114 an expanded list that you know will be the same each time within a given
7115 message. For example:
7116 .display asis
7117 domainlist special_domains = \
7118            ${lookup{$sender_host_address}cdb{/some/file}}
7119 .endd
7120 This provides a list of domains that depends only on the sending host's IP
7121 address. If this domain list is referenced a number of times (for example,
7122 in several ACL lines, or in several routers) the result of the check is not
7123 cached by default, because Exim does not know that it is going to be the
7124 same list each time.
7125
7126 By appending \"@_cache"\ to \"domainlist"\ you can tell Exim to go ahead and
7127 cache the result anyway. For example:
7128 .display asis
7129 domainlist_cache special_domains = ${lookup{...
7130 .endd
7131 If you do this, you should be absolutely sure that caching is going to do
7132 the right thing in all cases. When in doubt, leave it out.
7133
7134
7135 .section Domain lists
7136 .rset SECTdomainlist "~~chapter.~~section"
7137 .index domain list||patterns for
7138 .index list||domain list
7139 Domain lists contain patterns that are to be matched against a mail domain.
7140 The following types of item may appear in domain lists:
7141 .numberpars $.
7142 .index primary host name
7143 .index host||name, matched in domain list
7144 .index \primary@_hostname\
7145 .index domain list||matching primary host name
7146 .index @@ in a domain list
7147 If a pattern consists of a single @@ character, it matches the local host name,
7148 as set by the \primary@_hostname\ option (or defaulted). This makes it possible
7149 to use the same configuration file on several different hosts that differ only
7150 in their names.
7151 .nextp
7152 .index @@[] in a domain list
7153 .index domain list||matching local IP interfaces
7154 .index domain literal
7155 If a pattern consists of the string \"@@[]"\ it matches any local IP interface
7156 address, enclosed in square brackets, as in an email address that contains a
7157 domain literal.
7158 In today's Internet, the use of domain literals is controversial.
7159 .nextp
7160 .index @@mx@_any
7161 .index @@mx@_primary
7162 .index @@mx@_secondary
7163 .index domain list||matching MX pointers to local host
7164 If a pattern consists of the string \"@@mx@_any"\ it matches any domain that
7165 has an MX record pointing to the local host or to any host that is listed in
7166 .index \hosts@_treat@_as@_local\
7167 \hosts@_treat@_as@_local\. The items \"@@mx@_primary"\ and \"@@mx@_secondary"\
7168 are similar, except that the first matches only when a primary MX target is the
7169 local host, and the second only when no primary MX target is the local host,
7170 but a secondary MX target is. `Primary' means an MX record with the lowest
7171 preference value -- there may of course be more than one of them.
7172
7173 The MX lookup that takes place when matching a pattern of this type is
7174 performed with the resolver options for widening names turned off. Thus, for
7175 example, a single-component domain will \*not*\ be expanded by adding the
7176 resolver's default domain. See the \qualify@_single\ and \search@_parents\
7177 options of the \%dnslookup%\ router for a discussion of domain widening.
7178
7179 Sometimes you may want to ignore certain IP addresses when using one of these
7180 patterns. You can specify this by following the pattern with \"/ignore=<<ip
7181 list>>"\, where <<ip list>> is a list of IP addresses. These addresses are
7182 ignored when processing the pattern (compare the \ignore@_target@_hosts\ option
7183 on a router). For example:
7184 .display asis
7185 domains = @mx_any/ignore=127.0.0.1
7186 .endd
7187 This example matches any domain that has an MX record pointing to one of
7188 the local host's IP addresses other than 127.0.0.1.
7189
7190 The list of IP addresses is in fact processed by the same code that processes
7191 host lists, so it may contain CIDR-coded network specifications and it may also
7192 contain negative items.
7193
7194 Because the list of IP addresses is a sublist within a domain list, you have to
7195 be careful about delimiters if there is more than one address. Like any other
7196 list, the default delimiter can be changed. Thus, you might have:
7197 .display asis
7198 domains = @mx_any/ignore=<;127.0.0.1;0.0.0.0 : \
7199           an.other.domain : ...
7200 .endd
7201 so that the sublist uses semicolons for delimiters. When IPv6 addresses are
7202 involved, it is easiest to change the delimiter for the main list as well:
7203 .display asis
7204 domains = <? @mx_any/ignore=<;127.0.0.1;::1 ? \
7205           an.other.domain ? ...
7206 .endd
7207
7208 .nextp
7209 .index asterisk||in domain list
7210 .index domain list||asterisk in
7211 .index domain list||matching `ends with'
7212 If a pattern starts with an asterisk, the remaining characters of the pattern
7213 are compared with the terminating characters of the domain. The use of `$*$' in
7214 domain lists differs from its use in partial matching lookups. In a domain
7215 list, the character following the asterisk need not be a dot, whereas partial
7216 matching works only in terms of dot-separated components. For example, a domain
7217 list item such as \"*key.ex"\ matches \*donkey.ex*\ as well as
7218 \*cipher.key.ex*\.
7219 .nextp
7220 .index regular expressions||in domain list
7221 .index domain list||matching regular expression
7222 If a pattern starts with a circumflex character, it is treated as a regular
7223 expression, and matched against the domain using a regular expression matching
7224 function. The circumflex is treated as part of the regular expression.
7225 References to descriptions of the syntax of regular expressions are given in
7226 chapter ~~CHAPregexp.
7227
7228 \**Warning**\: Because domain lists are expanded before being processed, you
7229 must escape any backslash and dollar characters in the regular expression, or
7230 use the special \"@\N"\ sequence (see chapter ~~CHAPexpand) to specify that it
7231 is not to be expanded (unless you really do want to build a regular expression
7232 by expansion, of course).
7233 .nextp
7234 .index lookup||in domain list
7235 .index domain list||matching by lookup
7236 If a pattern starts with the name of a single-key lookup type followed by a
7237 semicolon (for example, `dbm;' or `lsearch;'), the remainder of the pattern
7238 must be a file name in a suitable format for the lookup type. For example, for
7239 `cdb;' it must be an absolute path:
7240 .display asis
7241 domains = cdb;/etc/mail/local_domains.cdb
7242 .endd
7243 The appropriate type of lookup is done on the file using the domain name as the
7244 key. In most cases, the data that is looked up is not used; Exim is interested
7245 only in whether or not the key is present in the file. However, when a lookup
7246 is used for the \domains\ option on a router
7247 or a \domains\ condition in an ACL statement, the data is preserved in the
7248 \$domain@_data$\ variable and can be referred to in other router options or
7249 other statements in the same ACL.
7250 .nextp
7251 Any of the single-key lookup type names may be preceded by `partial<<n>>-',
7252 where the <<n>> is optional, for example,
7253 .display asis
7254 domains = partial-dbm;/partial/domains
7255 .endd
7256 This causes partial matching logic to be invoked; a description of how this
7257 works is given in section ~~SECTpartiallookup.
7258 .nextp
7259 .index asterisk||in lookup type
7260 Any of the single-key lookup types may be followed by an asterisk. This causes
7261 a default lookup for a key consisting of a single asterisk to be done if the
7262 original lookup fails. This is not a useful feature when using a domain list to
7263 select particular domains (because any domain would match), but it might have
7264 value if the result of the lookup is being used via the \$domain@_data$\
7265 expansion variable.
7266 .nextp
7267 If the pattern starts with the name of a query-style lookup type followed by a
7268 semicolon (for example, `nisplus;' or `ldap;'), the remainder of the pattern
7269 must be an appropriate query for the lookup type, as described in chapter
7270 ~~CHAPfdlookup. For example:
7271 .display asis
7272 hold_domains = mysql;select domain from holdlist \
7273   where domain = '$domain';
7274 .endd
7275 In most cases, the data that is looked up is not used (so for an SQL query, for
7276 example, it doesn't matter what field you select). Exim is interested only in
7277 whether or not the query succeeds. However, when a lookup is used for the
7278 \domains\ option on a router, the data is preserved in the \$domain@_data$\
7279 variable and can be referred to in other options.
7280 .nextp
7281 .index domain list||matching literal domain name
7282 If none of the above cases apply, a caseless textual comparison is made between
7283 the pattern and the domain.
7284 .endp
7285
7286 Here is an example that uses several different kinds of pattern:
7287 .display asis
7288 domainlist funny_domains = \
7289   @ : \
7290   lib.unseen.edu : \
7291   *.foundation.fict.example : \
7292   \N^[1-2]\d{3}\.fict\.example$\N : \
7293   partial-dbm;/opt/data/penguin/book : \
7294   nis;domains.byname : \
7295   nisplus;[name=$domain,status=local],domains.org_dir
7296 .endd
7297 There are obvious processing trade-offs among the various matching modes. Using
7298 an asterisk is faster than a regular expression, and listing a few names
7299 explicitly probably is too. The use of a file or database lookup is expensive,
7300 but may be the only option if hundreds of names are required. Because the
7301 patterns are tested in order, it makes sense to put the most commonly matched
7302 patterns earlier.
7303
7304
7305 .section Host lists
7306 .rset SECThostlist "~~chapter.~~section"
7307 .index host list||patterns in
7308 .index list||host list
7309 Host lists are used to control what remote hosts are allowed to do. For
7310 example, some hosts may be allowed to use the local host as a relay, and some
7311 may be permitted to use the SMTP \\ETRN\\ command. Hosts can be identified in
7312 two different ways, by name or by IP address. In a host list, some types of
7313 pattern are matched to a host name, and some are matched to an IP address.
7314 You need to be particularly careful with this when single-key lookups are
7315 involved, to ensure that the right value is being used as the key.
7316
7317 .section Special host list patterns
7318 .index empty item in hosts list
7319 .index host list||empty string in
7320 If a host list item is the empty string, it matches only when no remote host is
7321 involved. This is the case when a message is being received from a local
7322 process using SMTP on the standard input, that is, when a TCP/IP connection is
7323 not used.
7324
7325 .index asterisk||in host list
7326 The special pattern `$*$' in a host list matches any host or no host. Neither
7327 the IP address nor the name is actually inspected.
7328
7329
7330 .section Host list patterns that match by IP address
7331 .rset SECThoslispatip "~~chapter.~~section"
7332 .index host list||matching IP addresses
7333 If an IPv4 host calls an IPv6 host and the call is accepted on an IPv6 socket,
7334 the incoming address actually appears in the IPv6 host as
7335 `@:@:$tt{ffff}:<<v4address>>'. When such an address is tested against a host
7336 list, it is converted into a traditional IPv4 address first. (Not all operating
7337 systems accept IPv4 calls on IPv6 sockets, as there have been some security
7338 concerns.)
7339
7340 The following types of pattern in a host list check the remote host by
7341 inspecting its IP address:
7342 .numberpars $.
7343 If the pattern is a plain domain name (not a regular expression, not starting
7344 with $*$, not a lookup of any kind), Exim calls the operating system function
7345 to find the associated IP address(es). Exim uses the newer
7346 \*getipnodebyname()*\ function when available, otherwise \*gethostbyname()*\.
7347 This typically causes a forward DNS lookup of the name. The result is compared
7348 with the IP address of the subject host.
7349
7350 If there is a temporary problem (such as a DNS timeout) with the host name
7351 lookup, a temporary error occurs. For example, if the list is being used in an
7352 ACL condition, the ACL gives a `defer' response, usually leading to a temporary
7353 SMTP error code. If no IP address can be found for the host name, what happens
7354 is described in section ~~SECTbehipnot below.
7355
7356 .nextp
7357 .index @@ in a host list
7358 If the pattern is `@@', the primary host name is substituted and used as a
7359 domain name, as just described.
7360 .nextp
7361 If the pattern is an IP address, it is matched against the IP address of the
7362 subject host. IPv4 addresses are given in the normal `dotted-quad' notation.
7363 IPv6 addresses can be given in colon-separated format, but the colons have to
7364 be doubled so as not to be taken as item separators when the default list
7365 separator is used. IPv6 addresses are recognized even when Exim is compiled
7366 without IPv6 support. This means that if they appear in a host list on an
7367 IPv4-only host, Exim will not treat them as host names. They are just addresses
7368 that can never match a client host.
7369 .nextp
7370 .index @@[] in a host list
7371 If the pattern is `@@[]', it matches the IP address of any IP interface on
7372 the local host. For example, if the local host is an IPv4 host with one
7373 interface address 10.45.23.56, these two ACL statements have the same effect:
7374 .display asis
7375 accept hosts = 127.0.0.1 : 10.45.23.56
7376 accept hosts = @[]
7377 .endd
7378 .nextp
7379 If the pattern is an IP address followed by a slash and a mask length (for
7380 example 10.11.42.0/24), it is matched against the IP address of the subject
7381 host under the given mask.
7382 This allows, an entire network of hosts to be included (or excluded) by a
7383 single item.
7384 .index CIDR notation
7385 The mask uses CIDR notation; it specifies the number of address bits that must
7386 match, starting from the most significant end of the address.
7387
7388 \**Note**\: the mask is \*not*\ a count of addresses, nor is it the high number
7389 of a range of addresses. It is the number of bits in the network portion of the
7390 address. The above example specifies a 24-bit netmask, so it matches all 256
7391 addresses in the 10.11.42.0 network. An item such as
7392 .display asis
7393 192.168.23.236/31
7394 .endd
7395 matches just two addresses, 192.168.23.236 and 192.168.23.237. A mask value of
7396 32 for an IPv4 address is the same as no mask at all; just a single address
7397 matches.
7398
7399 Here is another example which shows an IPv4 and an IPv6 network:
7400 .display asis
7401 recipient_unqualified_hosts = 192.168.0.0/16: \
7402                               3ffe::ffff::836f::::/48
7403 .endd
7404 The doubling of list separator characters applies only when these items
7405 appear inline in a host list. It is not required when indirecting via a file.
7406 For example,
7407 .display asis
7408 recipient_unqualified_hosts = /opt/exim/unqualnets
7409 .endd
7410 could make use of a file containing
7411 .display asis
7412 172.16.0.0/12
7413 3ffe:ffff:836f::/48
7414 .endd
7415 to have exactly the same effect as the previous example. When listing IPv6
7416 addresses inline, it is usually more convenient to use the facility for
7417 changing separator characters. This list contains the same two networks:
7418 .display asis
7419 recipient_unqualified_hosts = <; 172.16.0.0/12; \
7420                                  3ffe:ffff:836f::/48
7421 .endd
7422 The separator is changed to semicolon by the leading `<;' at the start of the
7423 list.
7424 .endp
7425
7426
7427 .section Host list patterns for single-key lookups by host address
7428 .rset SECThoslispatsikey "~~chapter.~~section"
7429 .index host list||lookup of IP address
7430 When a host is to be identified by a single-key lookup of its complete IP
7431 address, the pattern takes this form:
7432 .display
7433 net-<<single-key-search-type>>;<<search-data>>
7434 .endd
7435 For example:
7436 .display asis
7437 hosts_lookup = net-cdb;/hosts-by-ip.db
7438 .endd
7439 The text form of the IP address of the subject host is used as the lookup key.
7440 IPv6 addresses are converted to an unabbreviated form, using lower case
7441 letters, with dots as separators because colon is the key terminator in
7442 \%lsearch%\ files. [Colons can in fact be used in keys in \%lsearch%\ files by
7443 quoting the keys, but this is a facility that was added later.] The data
7444 returned by the lookup is not used.
7445
7446 .index IP address||masking
7447 .index host list||masked IP address
7448 Single-key lookups can also be performed using masked IP addresses, using
7449 patterns of this form:
7450 .display
7451 net<<number>>-<<single-key-search-type>>;<<search-data>>
7452 .endd
7453 For example:
7454 .display asis
7455 net24-dbm;/networks.db
7456 .endd
7457 The IP address of the subject host is masked using <<number>> as the mask
7458 length. A textual string is constructed from the masked value, followed by the
7459 mask, and this is used as the lookup key. For example, if the host's IP address
7460 is 192.168.34.6, the key that is looked up for the above example is
7461 `192.168.34.0/24'. IPv6 addresses are converted to a text value using lower
7462 case letters and dots as separators instead of the more usual colon, because
7463 colon is the key terminator in \%lsearch%\ files. Full, unabbreviated IPv6
7464 addresses are always used.
7465
7466 \**Warning**\: Specifing \net32@-\ (for an IPv4 address) or \net128@-\ (for an
7467 IPv6 address) is not the same as specifing just \net@-\ without a number. In
7468 the former case the key strings include the mask value, whereas in the latter
7469 case the IP address is used on its own.
7470
7471
7472 .section Host list patterns that match by host name
7473 .rset SECThoslispatnam "~~chapter.~~section"
7474 .index host||lookup failures
7475 .index unknown host name
7476 .index host list||matching host name
7477 There are several types of pattern that require Exim to know the name of the
7478 remote host. These are either wildcard patterns or lookups by name. (If a
7479 complete hostname is given without any wildcarding, it is used to find an IP
7480 address to match against, as described in the section ~~SECThoslispatip above.)
7481
7482 If the remote host name is not already known when Exim encounters one of these
7483 patterns, it has to be found from the IP address.
7484 Although many sites on the Internet are conscientious about maintaining reverse
7485 DNS data for their hosts, there are also many that do not do this.
7486 Consequently, a name cannot always be found, and this may lead to unwanted
7487 effects. Take care when configuring host lists with wildcarded name patterns.
7488 Consider what will happen if a name cannot be found.
7489
7490 Because of the problems of determining host names from IP addresses, matching
7491 against host names is not as common as matching against IP addresses.
7492
7493 By default, in order to find a host name, Exim first does a reverse DNS lookup;
7494 if no name is found in the DNS, the system function (\*gethostbyaddr()*\ or
7495 \*getipnodebyaddr()*\ if available) is tried. The order in which these lookups
7496 are done can be changed by setting the \host@_lookup@_order\ option.
7497
7498 There are some options that control what happens if a host name cannot be
7499 found. These are described in section ~~SECTbehipnot below.
7500
7501
7502 .index host||alias for
7503 .index alias for host
7504 As a result of aliasing, hosts may have more than one name. When processing any
7505 of the following types of pattern, all the host's names are checked:
7506 .numberpars $.
7507 .index asterisk||in host list
7508 If a pattern starts with `$*$' the remainder of the item must match the end of
7509 the host name. For example, \"*.b.c"\ matches all hosts whose names end in
7510 \*.b.c*\. This special simple form is provided because this is a very common
7511 requirement. Other kinds of wildcarding require the use of a regular
7512 expression.
7513 .nextp
7514 .index regular expressions||in host list
7515 .index host list||regular expression in
7516 If the item starts with `@^' it is taken to be a regular expression which is
7517 matched against the host name. For example,
7518 .display asis
7519 ^(a|b)\.c\.d$
7520 .endd
7521 is a regular expression that matches either of the two hosts \*a.c.d*\ or
7522 \*b.c.d*\. When a regular expression is used in a host list, you must take care
7523 that backslash and dollar characters are not misinterpreted as part of the
7524 string expansion. The simplest way to do this is to use \"@\N"\ to mark that
7525 part of the string as non-expandable. For example:
7526 .display asis
7527 sender_unqualified_hosts = \N^(a|b)\.c\.d$\N : ....
7528 .endd
7529 \**Warning**\: If you want to match a complete host name, you must include the
7530 \"@$"\ terminating metacharacter in the regular expression, as in the above
7531 example. Without it, a match at the start of the host name is all that is
7532 required.
7533 .endp
7534
7535
7536 .section Behaviour when an IP address or name cannot be found
7537 .rset SECTbehipnot "~~chapter.~~section"
7538 .index host||lookup failures
7539 While processing a host list, Exim may need to look up an IP address from a
7540 name (see section ~~SECThoslispatip), or it may need to look up a host name
7541 from an IP address (see section ~~SECThoslispatnam). In either case, the
7542 behaviour when it fails to find the information it is seeking is the same.
7543
7544 .index \"+include@_unknown"\
7545 .index \"+ignore@_unknown"\
7546 By default, Exim behaves as if the host does not match the list. This may not
7547 always be what you want to happen. To change Exim's behaviour, the special
7548 items \"+include@_unknown"\ or \"+ignore@_unknown"\ may appear in the list (at
7549 top level -- they are not recognized in an indirected file).
7550 .numberpars $.
7551 If any item that follows \"+include@_unknown"\ requires information that
7552 cannot found, Exim behaves as if the host does match the list. For example,
7553 .display asis
7554 host_reject_connection = +include_unknown:*.enemy.ex
7555 .endd
7556 rejects connections from any host whose name matches \"*.enemy.ex"\, and also
7557 any hosts whose name it cannot find.
7558 .nextp
7559 If any item that follows \"+ignore@_unknown"\ requires information that cannot
7560 be found, Exim ignores that item and proceeds to the rest of the list. For
7561 example:
7562 .display asis
7563 accept hosts = +ignore_unknown : friend.example : \
7564                192.168.4.5
7565 .endd
7566 accepts from any host whose name is \*friend.example*\ and from 192.168.4.5,
7567 whether or not its host name can be found. Without \"+ignore@_unknown"\, if no
7568 name can be found for 192.168.4.5, it is rejected.
7569 .endp
7570 Both \"+include@_unknown"\ and \"+ignore@_unknown"\ may appear in the same
7571 list. The effect of each one lasts until the next, or until the end of the
7572 list.
7573
7574 \**Note**\: This section applies to permanent lookup failures. It does \*not*\
7575 apply to temporary DNS errors. They always cause a defer action.
7576
7577
7578 .section Host list patterns for single-key lookups by host name
7579 .rset SECThoslispatnamsk "~~chapter.~~section"
7580 .index host||lookup failures
7581 .index unknown host name
7582 .index host list||matching host name
7583 If a pattern is of the form
7584 .display
7585 <<single-key-search-type>>;<<search-data>>
7586 .endd
7587 for example
7588 .display asis
7589 dbm;/host/accept/list
7590 .endd
7591 a single-key lookup is performend, using the host name as its key. If the
7592 lookup succeeds, the host matches the item. The actual data that is looked up
7593 is not used.
7594
7595 \**Reminder**\: With this kind of pattern, you must have host $it{names} as
7596 keys in the file, not IP addresses. If you want to do lookups based on IP
7597 addresses, you must precede the search type with `net-' (see section
7598 ~~SECThoslispatsikey). There is, however, no reason why you could not use two
7599 items in the same list, one doing an address lookup and one doing a name
7600 lookup, both using the same file.
7601
7602
7603 .section Host list patterns for query-style lookups
7604 If a pattern is of the form
7605 .display
7606 <<query-style-search-type>>;<<query>>
7607 .endd
7608 the query is obeyed, and if it succeeds, the host matches the item. The actual
7609 data that is looked up is not used. The variables \$sender@_host@_address$\ and
7610 \$sender@_host@_name$\ can be used in the query. For example:
7611 .display asis
7612 hosts_lookup = pgsql;\
7613   select ip from hostlist where ip='$sender_host_address'
7614 .endd
7615 The value of \$sender@_host@_address$\ for an IPv6 address contains colons. You
7616 can use the \sg\ expansion item to change this if you need to. If you want to
7617 use masked IP addresses in database queries, you can use the \mask\ expansion
7618 operator.
7619
7620 If the query contains a reference to \$sender@_host@_name$\, Exim automatically
7621 looks up the host name if has not already done so. (See section
7622 ~~SECThoslispatnam for comments on finding host names.)
7623
7624 Historical note: prior to release 4.30, Exim would always attempt to find a
7625 host name before running the query, unless the search type was preceded by
7626 \"net-"\. This is no longer the case. For backwards compatibility, \"net-"\ is
7627 still recognized for query-style lookups, but its presence or absence has no
7628 effect. (Of course, for single-key lookups, \"net-"\ $it{is} important.
7629 See section ~~SECThoslispatsikey.)
7630
7631
7632 .section Mixing wildcarded host names and addresses in host lists
7633 .rset SECTmixwilhos "~~chapter.~~section"
7634 .index host list||mixing names and addresses in
7635 If you have name lookups or wildcarded host names and IP addresses in the same
7636 host list, you should normally put the IP addresses first. For example, in an
7637 ACL you could have:
7638 .display asis
7639 accept hosts = 10.9.8.7 : *.friend.example
7640 .endd
7641 The reason for this lies in the left-to-right way that Exim processes lists.
7642 It can test IP addresses without doing any DNS lookups, but when it reaches an
7643 item that requires a host name, it fails if it cannot find a host name to
7644 compare with the pattern. If the above list is given in the opposite order, the
7645 \accept\ statement fails for a host whose name cannot be found, even if its
7646 IP address is 10.9.8.7.
7647
7648 If you really do want to do the name check first, and still recognize the IP
7649 address, you can rewrite the ACL like this:
7650 .display asis
7651 accept hosts = *.friend.example
7652 accept hosts = 10.9.8.7
7653 .endd
7654 If the first \accept\ fails, Exim goes on to try the second one. See chapter
7655 ~~CHAPACL for details of ACLs.
7656
7657
7658
7659
7660 .section Address lists
7661 .index list||address list
7662 .index address list||empty item
7663 .index address list||patterns
7664 .rset SECTaddresslist "~~chapter.~~section"
7665 Address lists contain patterns that are matched against mail addresses. There
7666 is one special case to be considered: the sender address of a bounce message is
7667 always empty. You can test for this by providing an empty item in an address
7668 list. For example, you can set up a router to process bounce messages by
7669 using this option setting:
7670 .display asis
7671 senders = :
7672 .endd
7673 The presence of the colon creates an empty item. If you do not provide any
7674 data, the list is empty and matches nothing. The empty sender can also be
7675 detected by a regular expression that matches an empty string,
7676 .em
7677 and by a query-style lookup that succeeds when \$sender@_address$\ is empty.
7678
7679 The following kinds of address list pattern can match any address, including 
7680 the empty address that is characteristic of bounce message senders:
7681 .nem
7682 .numberpars $.
7683 .em
7684 As explained above, if a pattern item is empty, it matches the empty address
7685 (and no others).
7686 .nem
7687 .nextp
7688 .index regular expressions||in address list
7689 .index address list||regular expression in
7690 If (after expansion) a pattern starts with `@^', a regular expression match is
7691 done against the complete address, with the pattern as the regular expression.
7692 You must take care that backslash and dollar characters are not misinterpreted
7693 as part of the string expansion. The simplest way to do this is to use \"@\N"\
7694 to mark that part of the string as non-expandable. For example:
7695 .display asis
7696 deny senders = \N^\d{8}.+@spamhaus.example$\N : ...
7697 .endd
7698 The \"@\N"\ sequences are removed by the expansion, so the item does start
7699 with `@^' by the time it is being interpreted as an address pattern.
7700 .nextp
7701 .index address list||lookup for complete address
7702 Complete addresses can be looked up by using a pattern that starts with a
7703 lookup type terminated by a semicolon, followed by the data for the lookup. For
7704 example:
7705 .display asis
7706 deny senders = cdb;/etc/blocked.senders : \
7707   mysql;select address from blocked where \
7708   address='${quote_mysql:$sender_address}'
7709 .endd
7710 .em
7711 Both query-style and single-key lookup types can be used. For a single-key
7712 lookup type, Exim uses the complete address as the key. However, empty keys are
7713 not supported for single-key lookups, so a match against the empty address
7714 always fails. This restriction does not apply to query-style lookups.
7715
7716 .nem
7717 Partial matching for single-key lookups (section ~~SECTpartiallookup) cannot be
7718 used, and is ignored if specified, with an entry being written to the panic
7719 log.
7720 .index @*@@ with single-key lookup
7721 However, you can configure lookup defaults, as described in section
7722 ~~SECTdefaultvaluelookups, but this is useful only for the `$*$@@' type of
7723 default. For example, with this lookup:
7724 .display asis
7725 accept senders = lsearch*@;/some/file
7726 .endd
7727 the file could contains lines like this:
7728 .display asis
7729 user1@domain1.example
7730 *@domain2.example
7731 .endd
7732 and for the sender address \*nimrod@@jaeger.example*\, the sequence of keys
7733 that are tried is:
7734 .display asis
7735 nimrod@jaeger.example
7736 *@jaeger.example
7737 *
7738 .endd
7739 \**Warning 1**\: Do not include a line keyed by `$*$' in the file, because that
7740 would mean that every address matches, thus rendering the test useless.
7741
7742 \**Warning 2**\: Do not confuse these two kinds of item:
7743 .display asis
7744 deny recipients = dbm*@;/some/file
7745 deny recipients = *@dbm;/some/file
7746 .endd
7747 The first does a whole address lookup, with defaulting, as just described,
7748 because it starts with a lookup type. The second matches the local part and
7749 domain independently, as described in a bullet point below.
7750 .endp
7751
7752
7753 .em
7754 The following kinds of address list pattern can match only non-empty addresses. 
7755 If the subject address is empty, a match against any of these pattern types 
7756 always fails.
7757 .nem
7758
7759 .numberpars $.
7760 .index @@@@ with single-key lookup
7761 .index address list||@@@@ lookup type
7762 .index address list||split local part and domain
7763 If a pattern starts with `@@@@' followed by a single-key lookup item
7764 (for example, \"@@@@lsearch;/some/file"\), the address that is being checked is
7765 split into a local part and a domain. The domain is looked up in the file. If
7766 it is not found, there is no match. If it is found, the data that is looked up
7767 from the file is treated as a colon-separated list of local part patterns, each
7768 of which is matched against the subject local part in turn.
7769
7770 .index asterisk||in address list
7771 The lookup may be a partial one, and/or one involving a search for a default
7772 keyed by `$*$' (see section ~~SECTdefaultvaluelookups). The local part patterns
7773 that are looked up can be regular expressions or begin with `$*$', or even be
7774 further lookups. They may also be independently negated. For example, with
7775 .display asis
7776 deny senders = @@dbm;/etc/reject-by-domain
7777 .endd
7778 the data from which the DBM file is built could contain lines like
7779 .display asis
7780 baddomain.com:  !postmaster : *
7781 .endd
7782 to reject all senders except \postmaster\ from that domain.
7783 .index local part||starting with !
7784 If a local part that actually begins with an exclamation mark is required, it
7785 has to be specified using a regular expression. In \%lsearch%\ files, an entry
7786 may be split over several lines by indenting the second and subsequent lines,
7787 but the separating colon must still be included at line breaks. White space
7788 surrounding the colons is ignored. For example:
7789 .display asis
7790 aol.com:  spammer1 : spammer2 : ^[0-9]+$ :
7791           spammer3 : spammer4
7792 .endd
7793 As in all colon-separated lists in Exim, a colon can be included in an item by
7794 doubling.
7795
7796 If the last item in the list starts with a right angle-bracket, the remainder
7797 of the item is taken as a new key to look up in order to obtain a continuation
7798 list of local parts. The new key can be any sequence of characters. Thus one
7799 might have entries like
7800 .display asis
7801 aol.com: spammer1 : spammer 2 : >*
7802 xyz.com: spammer3 : >*
7803 *:       ^\d{8}$
7804 .endd
7805 in a file that was searched with \@@@@dbm$*$\, to specify a match for 8-digit
7806 local parts for all domains, in addition to the specific local parts listed for
7807 each domain. Of course, using this feature costs another lookup each time a
7808 chain is followed, but the effort needed to maintain the data is reduced.
7809 .index loop||in lookups
7810 It is possible to construct loops using this facility, and in order to catch
7811 them, the chains may be no more than fifty items long.
7812 .nextp
7813 The @@@@<<lookup>> style of item can also be used with a query-style
7814 lookup, but in this case, the chaining facility is not available. The lookup
7815 can only return a single list of local parts.
7816 .nextp
7817 If a pattern contains an @@ character, but is not a regular expression and does
7818 not begin with a lookup type as described above, the local part of the subject
7819 address is compared with the local part of the pattern, which may start with an
7820 asterisk. If the local parts match, the domain is checked in exactly the same
7821 way as for a pattern in a domain list. For example, the domain can be
7822 wildcarded, refer to a named list, or be a lookup:
7823 .display asis
7824 deny senders = *@*.spamming.site:\
7825                *@+hostile_domains:\
7826                bozo@partial-lsearch;/list/of/dodgy/sites:\
7827 .newline
7828                *@dbm;/bad/domains.db
7829 .endd
7830 .index local part||starting with !
7831 .index address list||local part starting with !
7832 If a local part that begins with an exclamation mark is required, it has to be
7833 specified using a regular expression, because otherwise the exclamation mark is
7834 treated as a sign of negation.
7835 .nextp
7836 If a pattern is not one of the above syntax forms, that is, if a
7837 .em
7838 non-empty
7839 .nem
7840 pattern that is not a regular expression or a lookup does not contain an @@
7841 character, it is matched against the domain part of the subject address. The
7842 only two formats that are recognized this way are a literal domain, or a domain
7843 pattern that starts with $*$. In both these cases, the effect is the same as if
7844 \"*@@"\ preceded the pattern.
7845 .endp
7846
7847 \**Warning**\: there is an important difference between the address list items
7848 in these two examples:
7849 .display asis
7850 senders = +my_list
7851 senders = *@+my_list
7852 .endd
7853 In the first one, \"my@_list"\ is a named address list, whereas in the second
7854 example it is a named domain list.
7855
7856
7857
7858 .section Case of letters in address lists
7859 .rset SECTcasletadd "~~chapter.~~section"
7860 .index case of local parts
7861 .index address list||case forcing
7862 .index case forcing in address lists
7863 Domains in email addresses are always handled caselessly, but for local parts
7864 case may be significant on some systems (see \caseful@_local@_part\ for how
7865 Exim deals with this when routing addresses). However, RFC 2505 ($it{Anti-Spam
7866 Recommendations for SMTP MTAs}) suggests that matching of addresses to blocking
7867 lists should be done in a case-independent manner. Since most address lists in
7868 Exim are used for this kind of control, Exim attempts to do this by default.
7869
7870 The domain portion of an address is always lowercased before matching it to an
7871 address list. The local part is lowercased by default, and any string
7872 comparisons that take place are done caselessly. This means that the data in
7873 the address list itself, in files included as plain file names, and in any file
7874 that is looked up using the `@@@@' mechanism, can be in any case. However, the
7875 keys in files that are looked up by a search type other than \%lsearch%\ (which
7876 works caselessly) must be in lower case, because these lookups are not
7877 case-independent.
7878
7879 .index \"+caseful"\
7880 To allow for the possibility of caseful address list matching, if an item in
7881 an address list is the string `+caseful', the original case of the local
7882 part is restored for any comparisons that follow, and string comparisons are no
7883 longer case-independent. This does not affect the domain, which remains in
7884 lower case. However, although independent matches on the domain alone are still
7885 performed caselessly, regular expressions that match against an entire address
7886 become case-sensitive after `+caseful' has been seen.
7887
7888
7889 .section Local part lists
7890 .rset SECTlocparlis "~~chapter.~~section"
7891 .index list||local part list
7892 .index local part||list
7893 Case-sensitivity in local part lists is handled in the same way as for address
7894 lists, as just described. The `+caseful' item can be used if required. In a
7895 setting of the \local@_parts\ option in a router with \caseful@_local@_part\
7896 set false, the subject is lowercased and the matching is initially
7897 case-insensitive. In this case, `+caseful' will restore case-sensitive matching
7898 in the local part list, but not elsewhere in the router. If
7899 \caseful@_local@_part\ is set true in a router, matching in the \local@_parts\
7900 option is case-sensitive from the start.
7901
7902 If a local part list is indirected to a file (see section ~~SECTfilnamlis),
7903 comments are handled in the same way as address lists -- they are recognized
7904 only if the @# is preceded by white space or the start of the line.
7905 Otherwise, local part lists are matched in the same way as domain lists, except
7906 that the special items that refer to the local host (\"@@"\, \"@@[]"\,
7907 \"@@mx@_any"\, \"@@mx@_primary"\, and \"@@mx@_secondary"\) are not recognized.
7908 Refer to section ~~SECTdomainlist for details of the other available item
7909 types.
7910
7911
7912
7913 .
7914 .
7915 .
7916 .
7917 . ============================================================================
7918 .chapter String expansions
7919 .set runningfoot "string expansions"
7920 .rset CHAPexpand ~~chapter
7921 .index expansion||of strings
7922 Many strings in Exim's run time configuration are expanded before use. Some of
7923 them are expanded every time they are used; others are expanded only once.
7924
7925 When a string is being expanded it is copied verbatim from left to right except
7926 when a dollar or backslash character is encountered. A dollar specifies the
7927 start of a portion of the string which is interpreted and replaced as described
7928 below in section ~~SECTexpansionitems onwards. Backslash is used as an escape
7929 character, as described in the following section.
7930
7931
7932 .section Literal text in expanded strings
7933 .rset SECTlittext "~~chapter.~~section"
7934 .index expansion||including literal text
7935 An uninterpreted dollar can be included in an expanded string by putting a
7936 backslash in front of it. A backslash can be used to prevent any special
7937 character being treated specially in an expansion, including itself. If the
7938 string appears in quotes in the configuration file, two backslashes are
7939 required because the quotes themselves cause interpretation of backslashes when
7940 the string is read in (see section ~~SECTstrings).
7941
7942 .index expansion||non-expandable substrings
7943 A portion of the string can specified as non-expandable by placing it between
7944 two occurrences of \"@\N"\. This is particularly useful for protecting regular
7945 expressions, which often contain backslashes and dollar signs. For example:
7946 .display asis
7947 deny senders = \N^\d{8}[a-z]@some\.site\.example$\N
7948 .endd
7949 On encountering the first \"@\N"\, the expander copies subsequent characters
7950 without interpretation until it reaches the next \"@\N"\ or the end of the
7951 string.
7952
7953
7954 .section Character escape sequences in expanded strings
7955 .index expansion||escape sequences
7956 A backslash followed by one of the letters `n', `r', or `t' in an expanded
7957 string is recognized as an escape sequence for the character newline, carriage
7958 return, or tab, respectively. A backslash followed by up to three octal digits
7959 is recognized as an octal encoding for a single character, and a backslash
7960 followed by `x' and up to two hexadecimal digits is a hexadecimal encoding.
7961
7962 These escape sequences are also recognized in quoted strings when they are read
7963 in. Their interpretation in expansions as well is useful for unquoted strings,
7964 and for other cases such as looked-up strings that are then expanded.
7965
7966 .section Testing string expansions
7967 .index expansion||testing
7968 .index testing||string expansion
7969 .index \-be-\ option
7970 Many expansions can be tested by calling Exim with the \-be-\ option. This takes
7971 the command arguments, or lines from the standard input if there are no
7972 arguments, runs them through the string expansion code, and writes the results
7973 to the standard output. Variables based on configuration values are set up, but
7974 since no message is being processed, variables such as \$local@_part$\ have no
7975 value. Nevertheless the \-be-\ option can be useful for checking out file and
7976 database lookups, and the use of expansion operators such as \sg\, \substr\ and
7977 \nhash\.
7978
7979 Exim gives up its root privilege when it is called with the \-be-\ option, and
7980 instead runs under the uid and gid it was called with, to prevent users from
7981 using \-be-\ for reading files to which they do not have access.
7982
7983
7984 .em
7985 .section Forced expansion failure
7986 .rset SECTforexpfai "~~chapter.~~section"
7987 .index expansion||forced failure
7988 A number of expansions that are described in the following section have
7989 alternative `true' and `false' substrings, enclosed in curly brackets. Which 
7990 one is used depends on some condition that is evaluated as part of the 
7991 expansion. If, instead of a `false' substring, the word `fail' is used (not in 
7992 curly brackets), the entire string expansion fails in a way that can be
7993 detected by the code that requested the expansion. This is called `forced
7994 expansion failure', and its consequences depend on the circumstances. In some
7995 cases it is no different from any other expansion failure, but in others a
7996 different action may be taken. Such variations are mentioned in the
7997 documentation of the option that is being expanded.
7998 .nem
7999
8000
8001 .section Expansion items
8002 .rset SECTexpansionitems "~~chapter.~~section"
8003 The following items are recognized in expanded strings. White space may be used
8004 between sub-items that are keywords or substrings enclosed in braces inside an
8005 outer set of braces, to improve readability. \**Warning**\: Within braces,
8006 white space is significant.
8007
8008 .startitems
8009
8010 .item "@$<<variable name>>#$rm{or}#@$@{<<variable name>>@}"
8011 .index expansion||variables
8012 Substitute the contents of the named variable, for example
8013 .display asis
8014 $local_part
8015 ${domain}
8016 .endd
8017 The second form can be used to separate the name from subsequent alphanumeric
8018 characters. This form (using curly brackets) is available only for variables;
8019 it does $it{not} apply to message headers. The names of the variables are given
8020 in section ~~SECTexpvar below. If the name of a non-existent variable is given,
8021 the expansion fails.
8022
8023 .item "@$@{<<op>>:<<string>>@}"
8024 .index expansion||operators
8025 The string is first itself expanded, and then the operation specified by <<op>>
8026 is applied to it. For example,
8027 .display asis
8028 ${lc:$local_part}
8029 .endd
8030 The string starts with the first character after the colon, which may be
8031 leading white space. A list of operators is given in section ~~SECTexpop below.
8032 The operator notation is used for simple expansion items that have just one
8033 argument, because it reduces the number of braces and therefore makes the
8034 string easier to understand.
8035
8036 .item "@$@{extract@{<<key>>@}@{<<string1>>@}@{<<string2>>@}@{<<string3>>@}@}"
8037 .index expansion||extracting substrings by key
8038 The key and <<string1>> are first expanded separately.
8039 Leading and trailing whitespace is removed from the key (but not from any of
8040 the strings).
8041 The key must not consist entirely of digits. The expanded <<string1>> must be
8042 of the form:
8043 .display
8044 <<key1>> = <<value1>>  <<key2>> = <<value2>> ...
8045 .endd
8046 where the equals signs and spaces (but not both) are optional. If any of the
8047 values contain white space, they must be enclosed in double quotes, and any
8048 values that are enclosed in double quotes are subject to escape processing as
8049 described in section ~~SECTstrings. The expanded <<string1>> is searched for
8050 the value that corresponds to the key. The search is case-insensitive. If the
8051 key is found, <<string2>> is expanded, and replaces the whole item; otherwise
8052 <<string3>> is used. During the expansion of <<string2>> the variable \$value$\
8053 contains the value that has been extracted. Afterwards, it is restored to any
8054 previous value it might have had.
8055
8056 If @{<<string3>>@} is omitted, the item is replaced by an empty string if the
8057 key is not found. If @{<<string2>>@} is also omitted, the value that was
8058 extracted is used. Thus, for example, these two expansions are identical, and
8059 yield `2001':
8060 .display
8061 @$@{extract@{gid@}{uid=1984 gid=2001@}@}
8062 @$@{extract@{gid@}{uid=1984 gid=2001@}@{@$value@}@}
8063 .endd
8064 Instead of @{<<string3>>@} the word `fail' (not in curly brackets) can appear,
8065 for example:
8066 .display
8067 @$@{extract@{Z@}@{A=... B=...@}@{@$value@} fail @}
8068 .endd
8069 This forces an expansion failure (see section ~~SECTforexpfai); @{<<string2>>@}
8070 must be present for `fail' to be recognized.
8071
8072
8073 .item "@$@{extract@{<<number>>@}@{<<separators>>@}@{<<string1>>@}@{<<string2>>@}@{<<string3>>@}@}"
8074 .index expansion||extracting substrings by number
8075 The <<number>> argument must consist entirely of decimal digits,
8076 apart from leading and trailing whitespace, which is ignored.
8077 This is what distinguishes this form of \extract\ from the previous kind. It
8078 behaves in the same way, except that, instead of extracting a named field, it
8079 extracts from <<string1>> the field whose number is given as the first
8080 argument. You can use \$value$\ in <<string2>> or \"fail"\ instead of
8081 <<string3>> as before.
8082
8083 The fields in the string are separated by any one of the characters in the
8084 separator string. These may include space or tab characters.
8085 The first field is numbered one. If the number is negative, the fields are
8086 counted from the end of the string, with the rightmost one numbered -1. If the
8087 number given is zero, the entire string is returned. If the modulus of the
8088 number is greater than the number of fields in the string, the result is the
8089 expansion of <<string3>>, or the empty string if <<string3>> is not provided.
8090 For example:
8091 .display asis
8092 ${extract{2}{:}{x:42:99:& Mailer::/bin/bash}}
8093 .endd
8094 yields `42', and
8095 .display asis
8096 ${extract{-4}{:}{x:42:99:& Mailer::/bin/bash}}
8097 .endd
8098 yields `99'. Two successive separators mean that the field between them is
8099 empty (for example, the fifth field above).
8100
8101
8102 .item "@$@{hash@{<<string1>>@}@{<<string2>>@}@{<<string3>>@}@}"
8103 .index hash function||textual
8104 .index expansion||textual hash
8105 This is a textual hashing function, and was the first to be implemented in
8106 early versions of Exim. In current releases, there are other hashing functions
8107 (numeric, MD5, and SHA-1), which are described below.
8108
8109 The first two strings, after expansion, must be numbers. Call them <<m>> and
8110 <<n>>. If you are using fixed values for these numbers, that is, if <<string1>>
8111 and <<string2>> do not change when they are expanded, you can use the
8112 simpler operator notation that avoids some of the braces:
8113 .display
8114 @$@{hash@_<<n>>@_<<m>>:<<string>>@}
8115 .endd
8116 The second number is optional (in both notations).
8117
8118 If <<n>> is greater than or equal to the length of the string, the expansion
8119 item returns the string. Otherwise it computes a new string of length <<n>> by
8120 applying a hashing function to the string. The new string consists of
8121 characters taken from the first <<m>> characters of the string
8122 .display asis
8123 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQWRSTUVWXYZ0123456789
8124 .endd
8125 If <<m>> is not present the value 26 is used, so that only lower case
8126 letters appear. For example:
8127 .display
8128 @$@{hash@{3@}@{monty@}@}              $rm{yields}  \"jmg"\
8129 @$@{hash@{5@}@{monty@}@}              $rm{yields}  \"monty"\
8130 @$@{hash@{4@}@{62@}@{monty python@}@}   $rm{yields}  \"fbWx"\
8131 .endd
8132
8133
8134 .item "@$header@_<<header name>>:#$rm{or}#@$h@_<<header name>>:"
8135 .item "@$bheader@_<<header name>>:#$rm{or}#@$bh@_<<header name>>:"
8136 .item "@$rheader@_<<header name>>:#$rm{or}#@$rh@_<<header name>>:"
8137 .index expansion||header insertion
8138 .index \$header@_$\
8139 .index \$bheader@_$\
8140 .index \$rheader@_$\
8141 .index header lines||in expansion strings
8142 .index header lines||character sets
8143 .index header lines||decoding
8144 Substitute the contents of the named message header line, for example
8145 .display asis
8146 $header_reply-to:
8147 .endd
8148 The newline that terminates a header line is not included in the expansion, but
8149 internal newlines (caused by splitting the header line over several physical
8150 lines) may be present.
8151
8152 The difference between \rheader\, \bheader\, and \header\ is in the way the
8153 data in the header line is interpreted.
8154 .numberpars $.
8155 .index whitespace||in header lines
8156 \rheader\ gives the original `raw' content of the header line, with no
8157 processing at all, and without the removal of leading and trailing whitespace.
8158 .nextp
8159 .index base64 encoding||in header lines
8160 \bheader\ removes leading and trailing whitespace, and then decodes base64 or
8161 quoted-printable MIME `words' within the header text, but does no character
8162 set translation. If decoding of what looks superficially like a MIME `word'
8163 fails, the raw string is returned.
8164 .index binary zero||in header line
8165 If decoding produces a binary zero character, it is replaced by a question mark
8166 -- this is what Exim does for binary zeros that are actually received in header
8167 lines.
8168 .nextp
8169 \header\ tries to translate the string as decoded by \bheader\ to a standard
8170 character set. This is an attempt to produce the same string as would be
8171 displayed on a user's MUA. If translation fails, the \bheader\ string is
8172 returned. Translation is attempted only on operating systems that support the
8173 \*iconv()*\ function. This is indicated by the compile-time macro
8174 \\HAVE@_ICONV\\ in a system Makefile or in \(Local/Makefile)\.
8175 .endp
8176
8177 In a filter file, the target character set for \header\ can be specified by a
8178 command of the following form:
8179 .display asis
8180 headers charset "UTF-8"
8181 .endd
8182 This command affects all references to \$h@_$\ (or \$header@_$\) expansions in
8183 subsequently obeyed filter commands. In the absence of this command, the target
8184 character set in a filter is taken from the setting of the \headers@_charset\
8185 option in the runtime configuration. The value of this option defaults to the
8186 value of \\HEADERS@_CHARSET\\ in \(Local/Makefile)\. The ultimate default is
8187 ISO-8859-1.
8188
8189 Header names follow the syntax of RFC 2822, which states that they may contain
8190 any printing characters except space and colon. Consequently, curly brackets
8191 $it{do not} terminate header names, and should not be used to enclose them as
8192 if they were variables. Attempting to do so causes a syntax error.
8193
8194 Only header lines that are common to all copies of a message are visible to
8195 this mechanism. These are the original header lines that are received with the
8196 message, and any that are added by
8197 an ACL \warn\ statement or by
8198 a system filter. Header lines that are added to a particular copy of a message
8199 by a router or transport are not accessible.
8200
8201 For incoming SMTP messages, no header lines are visible in ACLs that are obeyed
8202 before the \\DATA\\ ACL, because the header structure is not set up until the
8203 message is received. Header lines that are added by \warn\ statements in a
8204 \\RCPT\\ ACL (for example) are saved until the message's incoming header lines
8205 are available, at which point they are added. When a \\DATA\\ ACL is running,
8206 however, header lines added by earlier ACLs are visible.
8207
8208 Upper case and lower case letters are synonymous in header names. If the
8209 following character is white space, the terminating colon may be omitted, but
8210 this is not recommended, because you may then forget it when it is needed. When
8211 white space terminates the header name, it is included in the expanded string.
8212 If the message does not contain the given header, the expansion item is
8213 replaced by an empty string. (See the \def\ condition in section ~~SECTexpcond
8214 for a means of testing for the existence of a header.)
8215
8216 If there is more than one header with the same name, they are all concatenated
8217 to form the substitution string, up to a maximum length of 64K. A newline
8218 character is inserted between each line.
8219 For the \header\ expansion, for those headers that contain lists of addresses,
8220 a comma is also inserted at the junctions between lines. This does not happen
8221 for the \rheader\ expansion.
8222
8223
8224
8225 .item "@$@{hmac@{<<hashname>>@}@{<<secret>>@}@{<<string>>@}@}"
8226 .index expansion||hmac hashing
8227 This function uses cryptographic hashing (either MD5 or SHA-1) to convert a
8228 shared secret and some text into a message authentication code, as specified in
8229 RFC 2104.
8230 This differs from \"@$@{md5:secret@_text...@}"\ or
8231 \"@$@{sha1:secret@_text...@}"\ in that the hmac step adds a signature to the
8232 cryptographic hash, allowing for authentication that is not possible with MD5
8233 or SHA-1 alone.
8234 The hash name must expand to either \"md5"\ or \"sha1"\ at present. For
8235 example:
8236 .display asis
8237 ${hmac{md5}{somesecret}{$primary_hostname $tod_log}}
8238 .endd
8239 For the hostname \*mail.example.com*\ and time 2002-10-17 11:30:59, this
8240 produces:
8241 .display asis
8242 dd97e3ba5d1a61b5006108f8c8252953
8243 .endd
8244 As an example of how this might be used, you might put in the main part of
8245 an Exim configuration:
8246 .display asis
8247 SPAMSCAN_SECRET=cohgheeLei2thahw
8248 .endd
8249 In a router or a transport you could then have:
8250 .display asis
8251 headers_add = \
8252   X-Spam-Scanned: ${primary_hostname} ${message_id} \
8253   ${hmac{md5}{SPAMSCAN_SECRET}\
8254   {${primary_hostname},${message_id},$h_message-id:}}
8255 .endd
8256 Then given a message, you can check where it was scanned by looking at the
8257 ::X-Spam-Scanned:: header line. If you know the secret, you can check that this
8258 header line is authentic by recomputing the authentication code from the host
8259 name, message ID and the ::Message-id:: header line. This can be done using
8260 Exim's \-be-\ option, or by other means, for example by using the
8261 \*hmac@_md5@_hex()*\ function in Perl.
8262
8263
8264 .item "@${if <<condition>> @{<<string1>>@}@{<<string2>>@}@}"
8265 .index expansion||conditional
8266 If <<condition>> is true, <<string1>> is expanded and replaces the whole item;
8267 otherwise <<string2>> is used. The available conditions are described in
8268 section ~~SECTexpcond below. For example:
8269 .display asis
8270 ${if eq {$local_part}{postmaster} {yes}{no} }
8271 .endd
8272 The second string need not be present; if it is not and the condition is not
8273 true, the item is replaced with nothing. Alternatively, the word `fail' may be
8274 present instead of the second string (without any curly brackets). In this
8275 case, the expansion is forced to fail if the condition is not true (see section 
8276 ~~SECTforexpfai). 
8277
8278 .em
8279 If both strings are omitted, the result is the string \"true"\ if the condition
8280 is true, and the empty string if the condition is false. This makes it less
8281 cumbersome to write custom ACL and router conditions. For example, instead of
8282 .display asis
8283 condition = ${if >{$acl_m4}{3}{true}{false}}
8284 .endd
8285 you can use
8286 .display asis
8287 condition = ${if >{$acl_m4}{3}}
8288 .endd
8289 .nem
8290
8291
8292 .item "@$@{length@{<<string1>>@}@{<<string2>>@}@}"
8293 .index expansion||string truncation
8294 The \length\ item is used to extract the initial portion of a string. Both
8295 strings are expanded, and the first one must yield a number, <<n>>, say. If you
8296 are using a fixed value for the number, that is, if <<string1>> does not change
8297 when expanded, you can use the simpler operator notation that avoids some of
8298 the braces:
8299 .display
8300 @$@{length@_<<n>>:<<string>>@}
8301 .endd
8302 The result of this item is either the first <<n>> characters or the whole
8303 of <<string2>>, whichever is the shorter. Do not confuse \length\ with
8304 \strlen\, which gives the length of a string.
8305
8306
8307 .item "@${lookup@{<<key>>@} <<search type>> @{<<file>>@} @{<<string1>>@} @{<<string2>>@}@}"
8308 .item "@${lookup <<search type>> @{<<query>>@} @{<<string1>>@} @{<<string2>>@}@}"
8309 .index expansion||lookup in
8310 .index file||lookup
8311 .index lookup||in expanded string
8312 These items specify data lookups in files and databases, as discussed in
8313 chapter ~~CHAPfdlookup. The first form is used for single-key lookups, and the
8314 second is used for query-style lookups. The <<key>>, <<file>>, and <<query>>
8315 strings are expanded before use.
8316
8317 If there is any white space in a lookup item which is part of a filter command,
8318 a retry or rewrite rule, a routing rule for the \%manualroute%\ router, or any
8319 other place where white space is significant, the lookup item must be enclosed
8320 in double quotes. The use of data lookups in users' filter files may be locked
8321 out by the system administrator.
8322
8323 .index \$value$\
8324 If the lookup succeeds, <<string1>> is expanded and replaces the entire item.
8325 During its expansion, the variable \$value$\ contains the data returned by the
8326 lookup. Afterwards it reverts to the value it had previously (at the outer
8327 level it is empty). If the lookup fails, <<string2>> is expanded and replaces
8328 the entire item. If @{<<string2>>@} is omitted, the replacement is the empty 
8329 string on failure. If <<string2>> is provided, it can itself be a nested
8330 lookup, thus providing a mechanism for looking up a default value when the
8331 original lookup fails.
8332
8333 If a nested lookup is used as part of <<string1>>, \$value$\ contains the data
8334 for the outer lookup while the parameters of the second lookup are expanded,
8335 and also while <<string2>> of the second lookup is expanded, should the second
8336 lookup fail.
8337
8338 Instead of @{<<string2>>@} the word `fail' can appear, and in this case, if the
8339 lookup fails, the entire expansion is forced to fail (see section
8340 ~~SECTforexpfai). If both @{<<string1>>@} and @{<<string2>>@} are omitted, the
8341 result is the looked up value in the case of a successful lookup, and nothing
8342 in the case of failure.
8343
8344 For single-key lookups, the string `partial' is permitted to precede the
8345 search type in order to do partial matching, and $*$ or $*$@@ may follow a
8346 search type to request default lookups if the key does not match (see sections
8347 ~~SECTdefaultvaluelookups and ~~SECTpartiallookup for details).
8348
8349 .index numerical variables (\$1$\, \$2$\, etc)||in lookup expansion
8350 If a partial search is used, the variables \$1$\ and \$2$\ contain the wild
8351 and non-wild parts of the key during the expansion of the replacement text.
8352 They return to their previous values at the end of the lookup item.
8353
8354 This example looks up the postmaster alias in the conventional alias file:
8355 .display asis
8356 ${lookup {postmaster} lsearch {/etc/aliases} {$value}}
8357 .endd
8358 This example uses NIS+ to look up the full name of the user corresponding to
8359 the local part of an address, forcing the expansion to fail if it is not found:
8360 .display asis
8361 ${lookup nisplus {[name=$local_part],passwd.org_dir:gcos} \
8362   {$value}fail}
8363 .endd
8364
8365
8366 .item "@$@{nhash@{<<string1>>@}@{<<string2>>@}@{<<string3>>@}@}"
8367 .index expansion||numeric hash
8368 .index hash function||numeric
8369 The three strings are expanded; the first two must yield numbers. Call them
8370 <<n>> and <<m>>. If you are using fixed values for these numbers, that is, if
8371 <<string1>> and <<string2>> do not change when they are expanded, you can use
8372 the simpler operator notation that avoids some of the braces:
8373 .display
8374 @$@{nhash@_<<n>>@_<<m>>:<<string>>@}
8375 .endd
8376 The second number is optional (in both notations). If there is only one number,
8377 the result is a number in the range 0--<<n>>-1. Otherwise, the string is
8378 processed by a div/mod hash function that returns two numbers, separated by a
8379 slash, in the ranges 0 to <<n>>-1 and 0 to <<m>>-1, respectively. For example,
8380 .display asis
8381 ${nhash{8}{64}{supercalifragilisticexpialidocious}}
8382 .endd
8383 returns the string `6/33'.
8384
8385
8386
8387 .item "@$@{perl@{<<subroutine>>@}@{<<arg>>@}@{<<arg>>@}...@}"
8388 .index Perl||use in expanded string
8389 .index expansion||calling Perl from
8390 This item is available only if Exim has been built to include an embedded Perl
8391 interpreter. The subroutine name and the arguments are first separately
8392 expanded, and then the Perl subroutine is called with those arguments. No
8393 additional arguments need be given; the maximum number permitted, including the
8394 name of the subroutine, is nine.
8395
8396 The return value of the subroutine is inserted into the expanded string, unless
8397 the return value is \undef\. In that case, the expansion fails in the same way
8398 as an explicit `fail' on a lookup item.
8399 The return value is a scalar. Whatever you return is evaluated in a scalar
8400 context. For example, if you return the name of a Perl vector, the
8401 return value is the size of the vector, not its contents.
8402
8403 If the subroutine exits by calling Perl's \die\ function, the expansion fails
8404 with the error message that was passed to \die\. More details of the embedded
8405 Perl facility are given in chapter ~~CHAPperl.
8406
8407 The \%redirect%\ router has an option called \forbid@_filter@_perl\ which locks
8408 out the use of this expansion item in filter files.
8409
8410
8411 .item "@$@{readfile@{<<file name>>@}@{<<eol string>>@}@}"
8412 .index expansion||inserting an entire file
8413 .index file||inserting into expansion
8414 The file name and end-of-line string are first expanded separately. The file is
8415 then read, and its contents replace the entire item. All newline characters in
8416 the file are replaced by the end-of-line string if it is present. Otherwise,
8417 newlines are left in the string.
8418 String expansion is not applied to the contents of the file. If you want this,
8419 you must wrap the item in an \expand\ operator. If the file cannot be read, the
8420 string expansion fails.
8421
8422 The \%redirect%\ router has an option called \forbid@_filter@_readfile\ which
8423 locks out the use of this expansion item in filter files.
8424
8425
8426
8427 .item "@$@{readsocket@{<<name>>@}@{<<request>>@}@{<<timeout>>@}@{<<eol string>>@}@{<<fail string>>@}@}"
8428 .index expansion||inserting from a socket
8429 .index socket, use of in expansion
8430 This item inserts data that is read from a Unix domain socket into the expanded
8431 string. The minimal way of using it uses just two arguments:
8432 .display asis
8433 ${readsocket{/socket/name}{request string}}
8434 .endd
8435 Exim connects to the socket, writes the request string (unless it is an
8436 empty string) and reads from the socket until an end-of-file is read. A timeout
8437 of 5 seconds is applied. Additional, optional arguments extend what can be
8438 done. Firstly, you can vary the timeout. For example:
8439 .display asis
8440 ${readsocket{/socket/name}{request-string}{3s}}
8441 .endd
8442 A fourth argument allows you to change any newlines that are in the data
8443 that is read, in the same way as for \readfile\ (see above). This example turns
8444 them into spaces:
8445 .display asis
8446 ${readsocket{/socket/name}{request-string}{3s}{ }}
8447 .endd
8448 As with all expansions, the substrings are expanded before the processing
8449 happens. Errors in these sub-expansions cause the expansion to fail. In
8450 addition, the following errors can occur:
8451 .numberpars $.
8452 Failure to create a socket file descriptor;
8453 .nextp
8454 Failure to connect the socket;
8455 .nextp
8456 Failure to write the request-string;
8457 .nextp
8458 Timeout on reading from the socket.
8459 .endp
8460 By default, any of these errors causes the expansion to fail. However, if
8461 you supply a fifth substring, it is expanded and used when any of the above
8462 errors occurs. For example:
8463 .display asis
8464 ${readsocket{/socket/name}{request-string}{3s}{\n}\
8465   {socket failure}}
8466 .endd
8467 You can test for the existence of the socket by wrapping this expansion in
8468 \"@$@{if exists"\, but there is a race condition between that test and the
8469 actual opening of the socket, so it is safer to use the fifth argument if you
8470 want to be absolutely sure of avoiding an expansion error for a non-existent
8471 socket.
8472
8473 The \%redirect%\ router has an option called \forbid@_filter@_readsocket\ which
8474 locks out the use of this expansion item in filter files.
8475
8476 .item "@$rheader@_<<header name>>:#$rm{or}#@$rh@_<<header name>>:"
8477 This item inserts `raw' header lines. It is described with the \header\
8478 expansion item above.
8479
8480
8481
8482 .item "@$@{run@{<<command>> <<args>>@}@{<<string1>>@}@{<<string2>>@}@}"
8483 .index expansion||running a command
8484 The command and its arguments are first expanded separately, and then the
8485 command is run in a separate process, but under the same uid and gid. As in
8486 other command executions from Exim, a shell is not used by default. If you want
8487 a shell, you must explicitly code it.
8488 .index return code||from \run\ expansion
8489 If the command succeeds (gives a zero return code) <<string1>> is expanded and
8490 replaces the entire item; during this expansion, the standard output from the
8491 command is in the variable \$value$\. If the command fails, <<string2>>, if
8492 present, is expanded. If it is absent, the result is empty. Alternatively,
8493 <<string2>> can be the word `fail' (not in braces) to force expansion failure
8494 if the command does not succeed. If both strings are omitted, the result is the
8495 standard output on success, and nothing on failure.
8496
8497 The return code from the command is put in the variable \$runrc$\, and this
8498 remains set afterwards, so in a filter file you can do things like this:
8499 .display asis
8500 if "${run{x y z}{}}$runrc" is 1 then ...
8501   elif $runrc is 2 then ...
8502   ...
8503 endif
8504 .endd
8505 If execution of the command fails (for example, the command does not exist),
8506 the return code is 127 -- the same code that shells use for non-existent
8507 commands.
8508
8509 \**Warning**\: In a router or transport, you cannot assume the order in which
8510 option values are expanded, except for those pre-conditions whose order of
8511 testing is documented. Therefore, you cannot reliably expect to set \$runrc$\
8512 by the expansion of one option, and use it in another.
8513
8514 The \%redirect%\ router has an option called \forbid@_filter@_run\ which locks
8515 out the use of this expansion item in filter files.
8516
8517
8518 .item "@$@{sg@{<<subject>>@}@{<<regex>>@}@{<<replacement>>@}@}"
8519 .index expansion||string substitution
8520 This item works like Perl's substitution operator (s) with the global (/g)
8521 option; hence its name. However, unlike the Perl equivalent, Exim does not
8522 modify the subject string; instead it returns the modified string for insertion
8523 into the overall expansion. The item takes three arguments: the subject string,
8524 a regular expression, and a substitution string. For example
8525 .display asis
8526 ${sg{abcdefabcdef}{abc}{xyz}}
8527 .endd
8528 yields `xyzdefxyzdef'. Because all three arguments are expanded before use, if
8529 any @$ or @\ characters are required in the regular expression or in the
8530 substitution string, they have to be escaped. For example
8531 .display asis
8532 ${sg{abcdef}{^(...)(...)\$}{\$2\$1}}
8533 .endd
8534 yields `defabc', and
8535 .display asis
8536 ${sg{1=A 4=D 3=C}{\N(\d+)=\N}{K\$1=}}
8537 .endd
8538 yields `K1=A K4=D K3=C'.
8539 Note the use of \"@\N"\ to protect the contents of the regular expression from
8540 string expansion.
8541
8542
8543
8544 .item "@$@{substr@{<<string1>>@}@{<<string2>>@}@{<<string3>>@}@}"
8545 .index \substr\
8546 .index substring extraction
8547 .index expansion||substring extraction
8548 The three strings are expanded; the first two must yield numbers. Call them
8549 <<n>> and <<m>>. If you are using fixed values for these numbers, that is, if
8550 <<string1>> and <<string2>> do not change when they are expanded, you can use
8551 the simpler operator notation that avoids some of the braces:
8552 .display
8553 @$@{substr@_<<n>>@_<<m>>:<<string>>@}
8554 .endd
8555 The second number is optional (in both notations).
8556 .em
8557 If it is absent in the simpler format, the preceding underscore must also be 
8558 omitted.
8559 .nem
8560
8561 The \substr\ item can be used to extract more general substrings than \length\.
8562 The first number, <<n>>, is a starting offset, and <<m>> is the length
8563 required. For example
8564 .display asis
8565 ${substr{3}{2}{$local_part}}
8566 .endd
8567 If the starting offset is greater than the string length the result is the null
8568 string; if the length plus starting offset is greater than the string length,
8569 the result is the right-hand part of the string, starting from the given
8570 offset. The first character in the string has offset zero.
8571
8572 The \substr\ expansion item can take negative offset values to count
8573 from the right-hand end of its operand. The last character is offset -1, the
8574 second-last is offset -2, and so on. Thus, for example,
8575 .display asis
8576 ${substr{-5}{2}{1234567}}
8577 .endd
8578 yields `34'. If the absolute value of a negative offset is greater than the
8579 length of the string, the substring starts at the beginning of the string, and
8580 the length is reduced by the amount of overshoot. Thus, for example,
8581 .display asis
8582 ${substr{-5}{2}{12}}
8583 .endd
8584 yields an empty string, but
8585 .display asis
8586 ${substr{-3}{2}{12}}
8587 .endd
8588 yields `1'.
8589
8590 When the second number is omitted from \substr\, the remainder of the string is
8591 taken if the offset is positive. If it is negative, all characters in the
8592 string preceding the offset point are taken. For example, an offset of -1 and
8593 no length, as in these semantically identical examples:
8594 .display asis
8595 ${substr_-1:abcde}
8596 ${substr{-1}{abcde}}
8597 .endd
8598 yields all but the last character of the string, that is, `abcd'.
8599
8600
8601
8602 .item "@$@{tr@{<<subject>>@}@{<<characters>>@}@{<<replacements>>@}@}"
8603 .index expansion||character translation
8604 This item does single-character translation on its subject string. The second
8605 argument is a list of characters to be translated in the subject string. Each
8606 matching character is replaced by the corresponding character from the
8607 replacement list. For example
8608 .display asis
8609 ${tr{abcdea}{ac}{13}}
8610 .endd
8611 yields `1b3de1'. If there are duplicates in the second character string, the
8612 last occurrence is used. If the third string is shorter than the second, its
8613 last character is replicated. However, if it is empty, no translation takes
8614 place.
8615
8616 .enditems
8617
8618
8619 .section Expansion operators
8620 .rset SECTexpop "~~chapter.~~section"
8621 .index expansion||operators
8622 For expansion items that perform transformations on a single argument string,
8623 the `operator' notation is used because it is simpler and uses fewer braces.
8624 The substring is first expanded before the operation is applied to it. The
8625 following operations can be performed:
8626
8627 .startitems
8628
8629 .item "@$@{address:<<string>>@}"
8630 .index expansion||RFC 2822 address handling
8631 The string is interpreted as an RFC 2822 address, as it might appear in a
8632 header line, and the effective address is extracted from it. If the string does
8633 not parse successfully, the result is empty.
8634
8635
8636 .item "@$@{base62:<<digits>>@}"
8637 .index base62
8638 .index expansion||conversion to base 62
8639 The string must consist entirely of decimal digits. The number is converted to
8640 base 62 (sic) and output as a string of six characters, including leading
8641 zeros. \**Note**\: Just to be absolutely clear: this is \*not*\ base64
8642 encoding.
8643
8644 .item "@$@{base62d:<<base-62 digits>>@}"
8645 .index base62
8646 .index expansion||conversion to base 62
8647 The string must consist entirely of base-62 digits. The number is converted to
8648 decimal and output as a string.
8649
8650
8651 .item "@$@{domain:<<string>>@}"
8652 .index domain||extraction
8653 .index expansion||domain extraction
8654 The string is interpreted as an RFC 2822 address and the domain is extracted
8655 from it. If the string does not parse successfully, the result is empty.
8656
8657
8658 .item "@$@{escape:<<string>>@}"
8659 .index expansion||escaping non-printing characters
8660 If the string contains any non-printing characters, they are converted to
8661 escape sequences starting with a backslash. Whether characters with the most
8662 significant bit set (so-called `8-bit characters') count as printing or not is
8663 controlled by the \print@_topbitchars\ option.
8664
8665
8666 .item "@$@{eval:<<string>>@}"
8667 .item "@$@{eval10:<<string>>@}"
8668 .index expansion||expression evaluation
8669 .index expansion||arithmetic expression
8670 These items supports simple arithmetic in expansion strings. The string (after
8671 expansion) must be a conventional arithmetic expression, but it is limited to
8672 the four basic operators (plus, minus, times, divide) and parentheses. All
8673 operations are carried out using integer arithmetic. Plus and minus have a
8674 lower priority than times and divide; operators with the same priority are
8675 evaluated from left to right.
8676
8677 For \eval\, numbers may be decimal, octal (starting with `0') or hexadecimal
8678 (starting with `0x'). For \eval10\, all numbers are taken as decimal, even if
8679 they start with a leading zero. This can be useful when processing numbers
8680 extracted from dates or times, which often do have leading zeros.
8681
8682 A number may be followed by `K' or `M' to multiply it by 1024 or 1024$*$1024,
8683 respectively. Negative numbers are supported. The result of the computation is
8684 a decimal representation of the answer (without `K' or `M'). For example:
8685 .display
8686   @$@{eval:1+1@}       $rm{yields} 2
8687   @$@{eval:1+2*3@}     $rm{yields} 7
8688   @$@{eval:(1+2)*3@}   $rm{yields} 9
8689 .endd
8690 As a more realistic example, in an ACL you might have
8691 .display asis
8692 deny   message = Too many bad recipients
8693        condition =                    \
8694          ${if and {                   \
8695            {>{$rcpt_count}{10}}       \
8696            {                          \
8697            <                          \
8698              {$recipients_count}      \
8699              {${eval:$rcpt_count/2}}  \
8700            }                          \
8701          }{yes}{no}}
8702 .endd
8703 The condition is true if there have been more than 10 \\RCPT\\ commands and
8704 fewer than half of them have resulted in a valid recipient.
8705
8706
8707 .item "@$@{expand:<<string>>@}"
8708 .index expansion||re-expansion of substring
8709 The \expand\ operator causes a string to be expanded for a second time. For
8710 example,
8711 .display asis
8712 ${expand:${lookup{$domain}dbm{/some/file}{$value}}}
8713 .endd
8714 first looks up a string in a file while expanding the operand for \expand\, and
8715 then re-expands what it has found.
8716
8717
8718 .item "@$@{from@_utf8:<<string>>@}"
8719 .index Unicode
8720 .index UTF-8||conversion from
8721 .index expansion||UTF-8 conversion
8722 The world is slowly moving towards Unicode, although there are no standards for
8723 email yet. However, other applications (including some databases) are starting
8724 to store data in Unicode, using UTF-8 encoding. This operator converts from a
8725 UTF-8 string to an ISO-8859-1 string. UTF-8 code values greater than 255 are
8726 converted to underscores. The input must be a valid UTF-8 string. If it is not,
8727 the result is an undefined sequence of bytes.
8728
8729 Unicode code points with values less than 256 are compatible with ASCII and
8730 ISO-8859-1 (also known as Latin-1).
8731 For example, character 169 is the copyright symbol in both cases, though the
8732 way it is encoded is different. In UTF-8, more than one byte is needed for
8733 characters with code values greater than 127, whereas ISO-8859-1 is a
8734 single-byte encoding (but thereby limited to 256 characters). This makes
8735 translation from UTF-8 to ISO-8859-1 straightforward.
8736
8737
8738 .item "@$@{hash@_<<n>>@_<<m>>:<<string>>@}"
8739 .index hash function||textual
8740 .index expansion||textual hash
8741 The \hash\ operator is a simpler interface to the hashing function that can be
8742 used when the two parameters are fixed numbers (as opposed to strings that
8743 change when expanded). The effect is the same as
8744 .display
8745 @$@{hash@{<<n>>@}@{<<m>>@}@{<<string>>@}@}
8746 .endd
8747 See the description of the general \hash\ item above for details. The
8748 abbreviation \h\ can be used when \hash\ is used as an operator.
8749
8750
8751
8752 .item "@$@{hex2b64:<<hexstring>>@}"
8753 .index base64 encoding||conversion from hex
8754 .index expansion||hex to base64
8755 This operator converts a hex string into one that is base64 encoded. This can
8756 be useful for processing the output of the MD5 and SHA-1 hashing functions.
8757
8758
8759 .item "@$@{lc:<<string>>@}"
8760 .index case forcing in strings
8761 .index string||case forcing
8762 .index lower casing
8763 .index expansion||case forcing
8764 This forces the letters in the string into lower-case, for example:
8765 .display asis
8766 ${lc:$local_part}
8767 .endd
8768
8769
8770 .item "@$@{length@_<<number>>:<<string>>@}"
8771 .index expansion||string truncation
8772 The \length\ operator is a simpler interface to the \length\ function that can
8773 be used when the parameter is a fixed number (as opposed to a string that
8774 changes when expanded). The effect is the same as
8775 .display
8776 @$@{length@{<<number>>@}@{<<string>>@}@}
8777 .endd
8778 See the description of the general \length\ item above for details. Note that
8779 \length\ is not the same as \strlen\. The abbreviation \l\ can be used when
8780 \length\ is used as an operator.
8781
8782
8783 .item "@$@{local@_part:<<string>>@}"
8784 .index expansion||local part extraction
8785 The string is interpreted as an RFC 2822 address and the local part is
8786 extracted from it. If the string does not parse successfully, the result is
8787 empty.
8788
8789
8790 .item "@$@{mask:<<IP address>>/<<bit count>>@}"
8791 .index masked IP address
8792 .index IP address||masking
8793 .index CIDR notation
8794 .index expansion||IP address masking
8795 If the form of the string to be operated on is not an IP address followed by a
8796 slash and an integer (that is, a network address in CIDR notation), the
8797 expansion fails. Otherwise, this operator converts the IP address to binary,
8798 masks off the least significant bits according to the bit count, and converts
8799 the result back to text, with mask appended. For example,
8800 .display asis
8801 ${mask:10.111.131.206/28}
8802 .endd
8803 returns the string `10.111.131.192/28'. Since this operation is expected to be
8804 mostly used for looking up masked addresses in files, the result for an IPv6
8805 address uses dots to separate components instead of colons, because colon
8806 terminates a key string in lsearch files. So, for example,
8807 .display asis
8808 ${mask:3ffe:ffff:836f:0a00:000a:0800:200a:c031/99}
8809 .endd
8810 returns the string
8811 .display asis
8812 3ffe.ffff.836f.0a00.000a.0800.2000.0000/99
8813 .endd
8814 Letters in IPv6 addresses are always output in lower case.
8815
8816
8817 .item "@$@{md5:<<string>>@}"
8818 .index MD5 hash
8819 .index expansion||MD5 hash
8820 The \md5\ operator computes the MD5 hash value of the string, and returns it as
8821 a 32-digit hexadecimal number,
8822 in which any letters are in lower case.
8823
8824
8825 .item "@$@{nhash@_<<n>>@_<<m>>:<<string>>@}"
8826 .index expansion||numeric hash
8827 .index hash function||numeric
8828 The \nhash\ operator is a simpler interface to the numeric hashing function
8829 that can be used when the two parameters are fixed numbers (as opposed to
8830 strings that change when expanded). The effect is the same as
8831 .display
8832 @$@{nhash@{<<n>>@}@{<<m>>@}@{<<string>>@}@}
8833 .endd
8834 See the description of the general \nhash\ item above for details.
8835
8836
8837 .item "@$@{quote:<<string>>@}"
8838 .index quoting||in string expansions
8839 .index expansion||quoting
8840 The \quote\ operator puts its argument into double quotes if it
8841 is an empty string or
8842 contains anything other than letters, digits, underscores, dots, and hyphens.
8843 Any occurrences of double quotes and backslashes are escaped with a backslash.
8844 Newlines and carriage returns are converted to \"@\n"\ and \"@\r"\,
8845 respectively For example,
8846 .display asis
8847 ${quote:ab"*"cd}
8848 .endd
8849 becomes
8850 .display asis
8851 "ab\"*\"cd"
8852 .endd
8853 The place where this is useful is when the argument is a substitution from a
8854 variable or a message header.
8855
8856 .item "@$@{quote@_local@_part:<<string>>@}"
8857 This operator is like \quote\, except that it quotes the string only if
8858 required to do so by the rules of RFC 2822 for quoting local parts. For
8859 example, a plus sign would not cause quoting (but it would for \quote\).
8860 If you are creating a new email address from the contents of \$local@_part$\
8861 (or any other unknown data), you should always use this operator.
8862
8863
8864 .item "@$@{quote@_<<lookup-type>>:<<string>>@}"
8865 .index quoting||lookup-specific
8866 This operator applies lookup-specific quoting rules to the string. Each
8867 query-style lookup type has its own quoting rules which are described with
8868 the lookups in chapter ~~CHAPfdlookup. For example,
8869 .display asis
8870 ${quote_ldap:two * two}
8871 .endd
8872 returns
8873 .display asis
8874 two%20%5C2A%20two
8875 .endd
8876 For single-key lookup types, no quoting is ever necessary and this operator
8877 yields an unchanged string.
8878
8879
8880 .item "@$@{rxquote:<<string>>@}"
8881 .index quoting||in regular expressions
8882 .index regular expressions||quoting
8883 The \rxquote\ operator inserts a backslash before any non-alphanumeric
8884 characters in its argument. This is useful when substituting the values of
8885 variables or headers inside regular expressions.
8886
8887
8888 .item "@$@{rfc2047:<<string>>@}"
8889 .index expansion||RFC 2047
8890 This operator encodes text according to the rules of RFC 2047. This is an
8891 encoding that is used in header lines to encode non-ASCII characters. It is
8892 assumed that the input string is in the encoding specified by the
8893 \headers@_charset\ option, which defaults to ISO-8859-1. If the string contains
8894 only characters in the range 33--126, and no instances of the characters
8895 .display asis
8896 ? = ( ) < > @ , ; : \ " . [ ] _
8897 .endd
8898 it is not modified. Otherwise, the result is the RFC 2047 encoding of the 
8899 string,
8900 .em
8901 using as many `coded words' as necessary to encode all the characters.
8902 .nem
8903
8904
8905 .item "@$@{sha1:<<string>>@}"
8906 .index SHA-1 hash
8907 .index expansion||SHA-1 hashing
8908 The \sha1\ operator computes the SHA-1 hash value of the string, and returns it
8909 as a 40-digit hexadecimal number, in which any letters are in upper case.
8910
8911
8912 .item "@$@{stat:<<string>>@}"
8913 .index expansion||statting a file
8914 .index file||extracting characteristics
8915 The string, after expansion, must be a file path. A call to the \*stat()*\
8916 function is made for this path. If \*stat()*\ fails, an error occurs and the
8917 expansion fails. If it succeeds, the data from the stat replaces the item, as a
8918 series of <<name>>=<<value>> pairs, where the values are all numerical,
8919 except for the value of `smode'. The names are: `mode' (giving the mode as a
8920 4-digit octal number), `smode' (giving the mode in symbolic format as a
8921 10-character string, as for the \*ls*\ command), `inode', `device', `links',
8922 `uid', `gid', `size', `atime', `mtime', and `ctime'. You can extract individual
8923 fields using the \extract\ expansion item. \**Warning**\: The file size may be
8924 incorrect on 32-bit systems for files larger than 2GB.
8925
8926
8927 .em
8928 .item "@$@{str2b64:<<string>>@}"
8929 .index expansion||base64 encoding
8930 .index base64 encoding||in string expansion
8931 This operator converts a string into one that is base64 encoded.
8932 .nem
8933
8934
8935 .item "@$@{strlen:<<string>>@}"
8936 .index expansion||string length
8937 .index string||length in expansion
8938 The item is replace by the length of the expanded string, expressed as a
8939 decimal number. \**Note**\: Do not confuse \strlen\ with \length\.
8940
8941
8942 .item "@$@{substr@_<<start>>@_<<length>>:<<string>>@}"
8943 .index \substr\
8944 .index substring extraction
8945 .index expansion||substring expansion
8946 The \substr\ operator is a simpler interface to the \substr\ function that can
8947 be used when the two parameters are fixed numbers (as opposed to strings that
8948 change when expanded). The effect is the same as
8949 .display
8950 @$@{substr@{<<start>>@}@{<<length>>@}@{<<string>>@}@}
8951 .endd
8952 See the description of the general \substr\ item above for details. The
8953 abbreviation \s\ can be used when \substr\ is used as an operator.
8954
8955 .item "@$@{time@_interval:<<string>>@}"
8956 .index \time@_interval\
8957 .index time interval||formatting
8958 The argument (after sub-expansion) must be a sequence of decimal digits that
8959 represents an interval of time as a number of seconds. It is converted into a
8960 number of larger units and output in Exim's normal time format, for example,
8961 \"1w3d4h2m6s"\.
8962
8963 .item "@$@{uc:<<string>>@}"
8964 .index case forcing in strings
8965 .index string||case forcing
8966 .index upper casing
8967 .index expansion||case forcing
8968 This forces the letters in the string into upper-case.
8969
8970 .enditems
8971
8972
8973
8974 .section Expansion conditions
8975 .rset SECTexpcond "~~chapter.~~section"
8976 .index expansion||conditions
8977 The following conditions are available for testing by the \@$@{if\ construct
8978 while expanding strings:
8979
8980 .startitems
8981
8982 .item "!<<condition>>"
8983 .index expansion||negating a condition
8984 Preceding any condition with an exclamation mark negates the result of the
8985 condition.
8986
8987 .item "<<symbolic operator>> @{<<string1>>@}@{<<string2>>@}"
8988 .index numeric comparison
8989 .index expansion||numeric comparison
8990 There are a number of symbolic operators for doing numeric comparisons. They
8991 are:
8992 .display
8993 .tabs 8
8994 =    $t  $rm{equal}
8995 ==   $t  $rm{equal}
8996 >    $t  $rm{greater}
8997 >=   $t  $rm{greater or equal}
8998 <    $t  $rm{less}
8999 <=   $t  $rm{less or equal}
9000 .endd
9001 For example,
9002 .display asis
9003 ${if >{$message_size}{10M} ...
9004 .endd
9005 Note that the general negation operator provides for inequality testing. The
9006 two strings must take the form of optionally signed decimal integers,
9007 optionally followed by one of the letters `K' or `M' (in either upper or lower
9008 case), signifying multiplication by 1024 or 1024$*$1024, respectively.
9009
9010 .item "crypteq @{<<string1>>@}@{<<string2>>@}"
9011 .index expansion||encrypted comparison
9012 .index encrypted strings, comparing
9013 This condition is included in the Exim binary if it is built to support any
9014 authentication mechanisms (see chapter ~~CHAPSMTPAUTH). Otherwise, it is
9015 necessary to define \\SUPPORT@_CRYPTEQ\\ in \(Local/Makefile)\ to get \crypteq\
9016 included in the binary.
9017
9018 The \crypteq\ condition has two arguments. The first is encrypted and compared
9019 against the second, which is already encrypted. The second string may be in the
9020 LDAP form for storing encrypted strings, which starts with the encryption type
9021 in curly brackets, followed by the data. If the second string does not begin
9022 with `{' it is assumed to be encrypted with \*crypt()*\
9023 or \*crypt16()*\ (see below),
9024 since such strings cannot begin with `{'. Typically this will be a field from a
9025 password file.
9026
9027 An example of an encrypted string in LDAP form is:
9028 .display asis
9029 {md5}CY9rzUYh03PK3k6DJie09g==
9030 .endd
9031 If such a string appears directly in an expansion, the curly brackets have to
9032 be quoted, because they are part of the expansion syntax. For example:
9033 .display asis
9034 ${if crypteq {test}{\{md5\}CY9rzUYh03PK3k6DJie09g==}{yes}{no}}
9035 .endd
9036 The following encryption types
9037 (whose names are matched case-independently)
9038 are supported:
9039 .numberpars $.
9040 .index MD5 hash
9041 .index base64 encoding||in encrypted password
9042 \@{md5@}\ computes the MD5 digest of the first string, and expresses this as
9043 printable characters to compare with the remainder of the second string. If the
9044 length of the comparison string is 24, Exim assumes that it is base64 encoded
9045 (as in the above example). If the length is 32, Exim assumes that it is a
9046 hexadecimal encoding of the MD5 digest. If the length not 24 or 32, the
9047 comparison fails.
9048 .nextp
9049 .index SHA-1 hash
9050 \@{sha1@}\ computes the SHA-1 digest of the first string, and expresses this as
9051 printable characters to compare with the remainder of the second string. If the
9052 length of the comparison string is 28, Exim assumes that it is base64 encoded.
9053 If the length is 40, Exim assumes that it is a hexadecimal encoding of the
9054 SHA-1 digest. If the length is not 28 or 40, the comparison fails.
9055 .nextp
9056 .index \*crypt()*\
9057 \@{crypt@}\ calls the \*crypt()*\ function, 
9058 .em
9059 which traditionally used to use only the first eight characters of the
9060 password. However, in modern operating systems this is no longer true, and in
9061 many cases the entire password is used, whatever its length.
9062 .nem
9063 .nextp
9064 .index \*crypt16()*\
9065 \@{crypt16@}\ calls the \*crypt16()*\ function (also known as \*bigcrypt()*\),
9066 which 
9067 .em
9068 was orginally created to use up to 16 characters of the password. Again, in 
9069 modern operating systems, more characters may be used.
9070 .nem
9071 .endp
9072 Exim has its own version of \*crypt16()*\ (which is just a double call to
9073 \*crypt()*\). For operating systems that have their own version, setting
9074 \\HAVE@_CRYPT16\\ in \(Local/Makefile)\ when building Exim causes it to use the
9075 operating system version instead of its own. This option is set by default in
9076 the OS-dependent \(Makefile)\ for those operating systems that are known to
9077 support \*crypt16()*\.
9078
9079 If you do not put any curly bracket encryption type in a \crypteq\ comparison,
9080 the default is either \"@{crypt@}"\ or \"@{crypt16@}"\, as determined by the
9081 setting of \\DEFAULT@_CRYPT\\ in \(Local/Makefile)\. The default default is
9082 \"@{crypt@}"\. Whatever the default, you can always use either function by
9083 specifying it explicitly in curly brackets.
9084
9085 Note that if a password is no longer than 8 characters, the results of
9086 encrypting it with \*crypt()*\ and \*crypt16()*\ are identical. That means that
9087 \*crypt16()*\ is backwards compatible, as long as nobody feeds it a password
9088 longer than 8 characters.
9089
9090
9091 .item "def:<<variable name>>"
9092 .index expansion||checking for empty variable
9093 The \def\ condition must be followed by the name of one of the expansion
9094 variables defined in section ~~SECTexpvar. The condition is true if the named
9095 expansion variable does not contain the empty string, for example
9096 .display asis
9097 ${if def:sender_ident {from $sender_ident}}
9098 .endd
9099 Note that the variable name is given without a leading \@$\ character. If the
9100 variable does not exist, the expansion fails.
9101
9102 .item "def:header@_<<header name>>:##or##def:h@_<<header name>>:"
9103 .index expansion||checking header line existence
9104 This condition is true if a message is being processed and the named header
9105 exists in the message. For example,
9106 .display asis
9107 ${if def:header_reply-to:{$h_reply-to:}{$h_from:}}
9108 .endd
9109 Note that no \@$\ appears before \header@_\ or \h@_\ in the condition,
9110 and that header names must be terminated by colons if white space does not
9111 follow.
9112
9113 .item "eq @{<<string1>>@}@{<<string2>>@}"
9114 .item "eqi @{<<string1>>@}@{<<string2>>@}"
9115 .index string||comparison
9116 .index expansion||string comparison
9117 The two substrings are first expanded. The condition is true if the two
9118 resulting strings are identical: for \eq\ the comparison includes the case of
9119 letters, whereas for \eqi\ the comparison is case-independent.
9120
9121 .item "exists @{<<file name>>@}"
9122 .index expansion||file existence test
9123 .index file||existence test
9124 The substring is first expanded and then interpreted as an absolute path. The
9125 condition is true if the named file (or directory) exists. The existence test
9126 is done by calling the \*stat()*\ function. The use of the \exists\ test in
9127 users' filter files may be locked out by the system administrator.
9128
9129 .item "first@_delivery"
9130 .index delivery||first
9131 .index first delivery
9132 .index expansion||first delivery test
9133 This condition, which has no data, is true during a message's first delivery
9134 attempt. It is false during any subsequent delivery attempts.
9135
9136 .item "ge @{<<string1>>@}@{<<string2>>@}"
9137 .item "gei @{<<string1>>@}@{<<string2>>@}"
9138 .index string||comparison
9139 .index expansion||string comparison
9140 The two substrings are first expanded. The condition is true if the first
9141 string is lexically greater than or equal to the second string: for \ge\ the
9142 comparison includes the case of letters, whereas for \gei\ the comparison is
9143 case-independent.
9144
9145 .item "gt @{<<string1>>@}@{<<string2>>@}"
9146 .item "gti @{<<string1>>@}@{<<string2>>@}"
9147 .index string||comparison
9148 .index expansion||string comparison
9149 The two substrings are first expanded. The condition is true if the first
9150 string is lexically greater than the second string: for \gt\ the comparison
9151 includes the case of letters, whereas for \gti\ the comparison is
9152 case-independent.
9153
9154 .item "isip @{<<string>>@}" 8
9155 .item "isip4 @{<<string>>@}"
9156 .item "isip6 @{<<string>>@}"
9157 .index IP address||testing string format
9158 .index string||testing for IP address
9159 The substring is first expanded, and then tested to see if it has the form of
9160 an IP address. Both IPv4 and IPv6 addresses are valid for \isip\, whereas
9161 \isip4\ and \isip6\ test just for IPv4 or IPv6 addresses, respectively. For
9162 example, you could use
9163 .display asis
9164 ${if isip4{$sender_host_address}...
9165 .endd
9166 to test which version of IP an incoming SMTP connection is using.
9167
9168
9169 .item "ldapauth @{<<ldap query>>@}"
9170 .index LDAP||use for authentication
9171 .index expansion||LDAP authentication test
9172 This condition supports user authentication using LDAP. See section ~~SECTldap
9173 for details of how to use LDAP in lookups and the syntax of queries. For this
9174 use, the query must contain a user name and password. The query itself is not
9175 used, and can be empty. The condition is true if
9176 the password is not empty, and the user name and password are accepted by the
9177 LDAP server. An empty password is rejected without calling LDAP because LDAP
9178 binds with an empty password are considered anonymous regardless of
9179 the username, and will succeed in most configurations.
9180 See chapter ~~CHAPSMTPAUTH for details of SMTP authentication, and chapter
9181 ~~CHAPplaintext for an example of how this can be used.
9182
9183
9184 .item "le @{<<string1>>@}@{<<string2>>@}"
9185 .item "lei @{<<string1>>@}@{<<string2>>@}"
9186 .index string||comparison
9187 .index expansion||string comparison
9188 The two substrings are first expanded. The condition is true if the first
9189 string is lexically less than or equal to the second string: for \le\ the
9190 comparison includes the case of letters, whereas for \lei\ the comparison is
9191 case-independent.
9192
9193 .item "lt @{<<string1>>@}@{<<string2>>@}"
9194 .item "lti @{<<string1>>@}@{<<string2>>@}"
9195 .index string||comparison
9196 .index expansion||string comparison
9197 The two substrings are first expanded. The condition is true if the first
9198 string is lexically less than the second string: for \lt\ the comparison
9199 includes the case of letters, whereas for \lti\ the comparison is
9200 case-independent.
9201
9202
9203 .item "match @{<<string1>>@}@{<<string2>>@}"
9204 .index expansion||regular expression comparison
9205 .index regular expressions||match in expanded string
9206 The two substrings are first expanded. The second is then treated as a regular
9207 expression and applied to the first. Because of the pre-expansion, if the
9208 regular expression contains dollar, or backslash characters, they must be
9209 escaped. Care must also be taken if the regular expression contains braces
9210 (curly brackets). A closing brace must be escaped so that it is not taken as a
9211 premature termination of <<string2>>. The easiest approach is to use the
9212 \"@\N"\ feature to disable expansion of the regular expression.
9213 For example,
9214 .display asis
9215 ${if match {$local_part}{\N^\d{3}\N} ...
9216 .endd
9217 If the whole expansion string is in double quotes, further escaping of
9218 backslashes is also required.
9219
9220 The condition is true if the regular expression match succeeds.
9221 The regular expression is not required to begin with a circumflex
9222 metacharacter, but if there is no circumflex, the expression is not anchored,
9223 and it may match anywhere in the subject, not just at the start. If you want
9224 the pattern to match at the end of the subject, you must include the \"@$"\
9225 metacharacter at an appropriate point.
9226
9227 .index numerical variables (\$1$\, \$2$\, etc)||in \if\ expansion
9228 At the start of an \if\ expansion the values of the numeric variable
9229 substitutions \$1$\ etc. are remembered. Obeying a \match\ condition that
9230 succeeds causes them to be reset to the substrings of that condition and they
9231 will have these values during the expansion of the success string. At the end
9232 of the \if\ expansion, the previous values are restored. After testing a
9233 combination of conditions using \or\, the subsequent values of the numeric
9234 variables are those of the condition that succeeded.
9235
9236 .item "match@_domain @{<<string1>>@}@{<<string2>>@}"
9237 .item "match@_address @{<<string1>>@}@{<<string2>>@}"
9238 .item "match@_local@_part @{<<string1>>@}@{<<string2>>@}"
9239 .index domain list||in expansion condition
9240 .index address list||in expansion condition
9241 .index local part list||in expansion condition
9242 These conditions make it possible to test domain, address, and local
9243 part lists within expansions. Each condition requires two arguments: an item
9244 and a list to match. A trivial example is:
9245 .display asis
9246 ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
9247 .endd
9248 In each case, the second argument may contain any of the allowable items for a
9249 list of the appropriate type. Also, because the second argument (after
9250 expansion) is a standard form of list, it is possible to refer to a named list.
9251 Thus, you can use conditions like this:
9252 .display asis
9253 ${if match_domain{$domain}{+local_domains}{...
9254 .endd
9255 .index \"+caseful"\
9256 For address lists, the matching starts off caselessly, but the \"+caseful"\
9257 item can be used, as in all address lists, to cause subsequent items to
9258 have their local parts matched casefully. Domains are always matched
9259 caselessly.
9260
9261 \**Note**\: Host lists are \*not*\ supported in this way. This is because
9262 hosts have two identities: a name and an IP address, and it is not clear
9263 how to specify cleanly how such a test would work. At least, I haven't come
9264 up with anything yet.
9265
9266 .item "pam {<<string1>>:<<string2>>:...@}"
9267 .index PAM authentication
9268 .index \\AUTH\\||with PAM
9269 .index Solaris||PAM support
9270 .index expansion||PAM authentication test
9271 \*Pluggable Authentication Modules*\
9272 (\?http://www.kernel.org/pub/linux/libs/pam/?\)
9273 are a facility which is available in the latest releases of Solaris and in some
9274 GNU/Linux distributions. The Exim support, which is intended for use in
9275 conjunction with the SMTP \\AUTH\\ command, is available only if Exim is
9276 compiled with
9277 .display asis
9278 SUPPORT_PAM=yes
9279 .endd
9280 in \(Local/Makefile)\. You probably need to add \-lpam-\ to \\EXTRALIBS\\, and
9281 in some releases of GNU/Linux \-ldl-\ is also needed.
9282
9283 The argument string is first expanded, and the result must be a colon-separated
9284 list of strings.
9285 Leading and trailing whitespace is ignored.
9286 The PAM module is initialized with the service name `exim' and the user name
9287 taken from the first item in the colon-separated data string (<<string1>>). The
9288 remaining items in the data string are passed over in response to requests from
9289 the authentication function. In the simple case there will only be one request,
9290 for a password, so the data consists of just two strings.
9291
9292 There can be problems if any of the strings are permitted to contain colon
9293 characters. In the usual way, these have to be doubled to avoid being taken as
9294 separators. If the data is being inserted from a variable, the \sg\ expansion
9295 item can be used to double any existing colons. For example, the configuration
9296 of a LOGIN authenticator might contain this setting:
9297 .display asis
9298 server_condition = ${if pam{$1:${sg{$2}{:}{::}}}{yes}{no}}
9299 .endd
9300 For a PLAIN authenticator you could use:
9301 .display asis
9302 server_condition = ${if pam{$2:${sg{$3}{:}{::}}}{yes}{no}}
9303 .endd
9304 In some operating systems, PAM authentication can be done only from a process
9305 running as root. Since Exim is running as the Exim user when receiving
9306 messages, this means that PAM cannot be used directly in those systems.
9307 A patched version of the \*pam@_unix*\ module that comes with the
9308 Linux PAM package is available from \?http:@/@/www.e-admin.de/pam@_exim/?\.
9309 The patched module allows one special uid/gid combination, in addition to root,
9310 to authenticate. If you build the patched module to allow the Exim user and
9311 group, PAM can then be used from an Exim authenticator.
9312
9313
9314 .item "pwcheck {<<string1>>:<<string2>>@}"
9315 .index \*pwcheck*\ daemon
9316 .index Cyrus
9317 .index expansion||\*pwcheck*\ authentication test
9318 This condition supports user authentication using the Cyrus \*pwcheck*\ daemon.
9319 This is one way of making it possible for passwords to be checked by a process
9320 that is not running as root.
9321 \**Note:**\ The use of \*pwcheck*\ is now deprecated. Its replacement is
9322 \*saslauthd*\ (see below).
9323
9324 The pwcheck support is not included in Exim by default. You need to specify
9325 the location of the pwcheck daemon's socket in \(Local/Makefile)\ before
9326 building Exim. For example:
9327 .display asis
9328 CYRUS_PWCHECK_SOCKET=/var/pwcheck/pwcheck
9329 .endd
9330 You do not need to install the full Cyrus software suite in order to use
9331 the pwcheck daemon. You can compile and install just the daemon alone
9332 from the Cyrus SASL library. Ensure that \*exim*\ is the only user that has
9333 access to the \(/var/pwcheck)\ directory.
9334
9335 The \pwcheck\ condition takes one argument, which must be the user name and
9336 password, separated by a colon. For example, in a LOGIN authenticator
9337 configuration, you might have this:
9338 .display asis
9339 server_condition = ${if pwcheck{$1:$2}{1}{0}}
9340 .endd
9341
9342 .item "queue@_running"
9343 .index queue runner||detecting when delivering from
9344 .index expansion||queue runner test
9345 This condition, which has no data, is true during delivery attempts that are
9346 initiated by queue runner processes, and false otherwise.
9347
9348
9349 .item "radius {<<authentication string>>@}"
9350 .index Radius
9351 .index expansion||Radius authentication
9352 Radius authentication (RFC 2865) is supported in a similar way to PAM. You must
9353 set \\RADIUS@_CONFIG@_FILE\\ in \(Local/Makefile)\ to specify the location of
9354 the Radius client configuration file in order to build Exim with Radius
9355 support.
9356 .em
9357 With just that one setting, Exim expects to be linked with the \radiusclient\ 
9358 library. You can also link Exim with the \libradius\ library that comes with 
9359 FreeBSD. To do this, set
9360 .display asis
9361 RADIUS_LIB_TYPE=RADLIB
9362 .endd
9363 in \(Local/Makefile)\, in addition to setting \\RADIUS@_CONFIGURE@_FILE\\.
9364 .nem
9365 You may also have to supply a suitable setting in \\EXTRALIBS\\ so that the
9366 Radius library can be found when Exim is linked.
9367
9368 The string specified by \\RADIUS@_CONFIG@_FILE\\ is expanded and passed to the
9369 Radius client library, which calls the Radius server. The condition is true if
9370 the authentication is successful. For example
9371 .display
9372 server@_condition = @$@{if radius@{<<arguments>>@}@{yes@}@{no@}@}
9373 .endd
9374
9375
9376
9377 .item "saslauthd @{@{<<user>>@}@{<<password>>@}@{<<service>>@}@{<<realm>>@}@}"
9378 .index \*saslauthd*\ daemon
9379 .index Cyrus
9380 .index expansion||\*saslauthd*\ authentication test
9381 This condition supports user authentication using the Cyrus \*saslauthd*\
9382 daemon. This replaces the older \*pwcheck*\ daemon, which is now deprecated.
9383 Using this daemon is one way of making it possible for passwords to be checked
9384 by a process that is not running as root.
9385
9386 The saslauthd support is not included in Exim by default. You need to specify
9387 the location of the saslauthd daemon's socket in \(Local/Makefile)\ before
9388 building Exim. For example:
9389 .display asis
9390 CYRUS_SASLAUTHD_SOCKET=/var/state/saslauthd/mux
9391 .endd
9392 You do not need to install the full Cyrus software suite in order to use
9393 the saslauthd daemon. You can compile and install just the daemon alone
9394 from the Cyrus SASL library.
9395
9396 Up to four arguments can be supplied to the \saslauthd\ condition, but only two
9397 are mandatory. For example:
9398 .display asis
9399 server_condition = ${if saslauthd{{$1}{$2}}{1}{0}}
9400 .endd
9401 The service and the realm are optional (which is why the arguments are enclosed
9402 in their own set of braces). For details of the meaning of the service and
9403 realm, and how to run the daemon, consult the Cyrus documentation.
9404
9405 .enditems
9406
9407
9408
9409 .section Combining expansion conditions
9410 .index expansion||combining conditions
9411 Several conditions can be tested at once by combining them using the \and\ and
9412 \or\ combination conditions. Note that \and\ and \or\ are complete conditions
9413 on their own, and precede their lists of sub-conditions. Each sub-condition
9414 must be enclosed in braces within the overall braces that contain the list. No
9415 repetition of \if\ is used.
9416
9417 .startitems
9418
9419 .item "or @{@{<<cond1>>@}@{<<cond2>>@}...@}"
9420 .index `or' expansion condition
9421 .index expansion||`or' of conditions
9422 The sub-conditions are evaluated from left to right. The condition is true if
9423 any one of the sub-conditions is true.
9424 For example,
9425 .display asis
9426 ${if or {{eq{$local_part}{spqr}}{eq{$domain}{testing.com}}}...
9427 .endd
9428 When a true sub-condition is found, the following ones are parsed but not
9429 evaluated. If there are several `match' sub-conditions the values of the
9430 numeric variables afterwards are taken from the first one that succeeds.
9431
9432 .item "and @{@{<<cond1>>@}@{<<cond2>>@}...@}"
9433 .index `and' expansion condition
9434 .index expansion||`and' of conditions
9435 The sub-conditions are evaluated from left to right. The condition is true if
9436 all of the sub-conditions are true. If there are several `match'
9437 sub-conditions, the values of the numeric variables afterwards are taken from
9438 the last one. When a false sub-condition is found, the following ones are
9439 parsed but not evaluated.
9440
9441 .enditems
9442
9443
9444
9445 .section Expansion variables
9446 .rset SECTexpvar "~~chapter.~~section"
9447 .index expansion||variables, list of
9448
9449 .em
9450 This section contains an alphabetical list of all the expansion variables. Some
9451 of them are available only when Exim is compiled with specific options such as
9452 support for TLS or the content scanning extension.
9453 .nem
9454
9455 .push
9456 .indent 2em
9457 .index numerical variables (\$1$\, \$2$\, etc)
9458 .tempindent 0
9459 \$0$\, \$1$\, etc: When a \match\ expansion condition succeeds, these
9460 variables contain the captured substrings identified by the regular expression
9461 during subsequent processing of the success string of the containing \if\
9462 expansion item. They may also be set externally by some other matching process
9463 which precedes the expansion of the string. For example, the commands available
9464 in Exim filter files include an \if\ command with its own regular expression
9465 matching condition.
9466
9467 .tempindent 0
9468 \$acl@_c0$\ -- \$acl@_c9$\: Values can be placed in these variables by the
9469 \set\ modifier in an ACL. The values persist throughout the lifetime of an SMTP
9470 connection. They can be used to pass information between ACLs and different
9471 invocations of the same ACL.
9472 When a message is received, the values of these variables are saved with the
9473 message, and can be accessed by filters, routers, and transports during
9474 subsequent delivery.
9475
9476 .tempindent 0
9477 \$acl@_m0$\ -- \$acl@_m9$\: Values can be placed in these variables by the
9478 \set\ modifier in an ACL. They retain their values while a message is being
9479 received, but are reset afterwards. They are also reset by \\MAIL\\, \\RSET\\,
9480 \\EHLO\\, \\HELO\\, and after starting a TLS session.
9481 When a message is received, the values of these variables are saved with the
9482 message, and can be accessed by filters, routers, and transports during
9483 subsequent delivery.
9484
9485
9486 .tempindent 0
9487 \$acl@_verify@_message$\: During the expansion of the \message\ and
9488 \log@_message\ modifiers in an ACL statement after an address verification has
9489 failed, this variable contains the original failure message that will be
9490 overridden by the expanded string.
9491
9492 .tempindent 0
9493 \$address@_data$\: This variable is set by means of the \address@_data\
9494 option in routers. The value then remains with the address while it is
9495 processed by subsequent routers and eventually a transport. If the transport is
9496 handling multiple addresses, the value from the first address is used. See
9497 chapter ~~CHAProutergeneric for more details. \**Note**\: the contents of
9498 \$address@_data$\ are visible in user filter files.
9499
9500 .em
9501 If \$address@_data$\ is set when the routers are called from an ACL to verify 
9502 a recipient address, the final value is still in the variable for subsequent
9503 conditions and modifiers of the ACL statement. If routing the address caused it
9504 to be redirected to just one address, the child address is also routed as part
9505 of the verification, and in this case the final value of \$address@_data$\ is
9506 from the child's routing.
9507
9508 If \$address@_data$\ is set when the routers are called from an ACL to verify a
9509 sender address, the final value is also preserved, but this time in
9510 \$sender@_address@_data$\, to distinguish it from data from a recipient 
9511 address.
9512
9513 In both cases (recipient and sender verification), the value does not persist 
9514 after the end of the current ACL statement. If you want to preserve
9515 these values for longer, you can save them in ACL variables.
9516 .nem
9517
9518 .tempindent 0
9519 \$address@_file$\: When, as a result of aliasing, forwarding, or filtering, a
9520 message is directed to a specific file, this variable holds the name of the
9521 file when the transport is running. At other times, the variable is empty. For
9522 example, using the default configuration, if user \r2d2\ has a \(.forward)\
9523 file containing
9524 .display asis
9525 /home/r2d2/savemail
9526 .endd
9527 then when the \%address@_file%\ transport is running, \$address@_file$\
9528 contains `/home/r2d2/savemail'.
9529 .index Sieve filter||value of \$address@_file$\
9530 For Sieve filters, the value may be `inbox' or a relative folder name. It is
9531 then up to the transport configuration to generate an appropriate absolute path
9532 to the relevant file.
9533
9534
9535 .tempindent 0
9536 \$address@_pipe$\: When, as a result of aliasing or forwarding, a message is
9537 directed to a pipe, this variable holds the pipe command when the transport is
9538 running.
9539
9540 .index authentication||id
9541 .tempindent 0
9542 \$authenticated@_id$\: When a server successfully authenticates a client it may
9543 be configured to preserve some of the authentication information in the
9544 variable \$authenticated@_id$\ (see chapter ~~CHAPSMTPAUTH). For example, a
9545 user/password authenticator configuration might preserve the user name for use
9546 in the routers. When a message is submitted locally (that is, not over a TCP
9547 connection), the value of \$authenticated@_id$\ is the login name of the
9548 calling process.
9549
9550 .index sender||authenticated
9551 .index authentication||sender
9552 .index \\AUTH\\||on \\MAIL\\ command
9553 .tempindent 0
9554 \$authenticated@_sender$\:
9555 When acting as a server, Exim takes note of the \\AUTH=\\ parameter on an
9556 incoming SMTP \\MAIL\\ command
9557 if it believes the sender is sufficiently trusted, as described in section
9558 ~~SECTauthparamail. Unless the data is the string `@<@>', it is set as the
9559 authenticated sender of the message, and the value is available during delivery
9560 in the \$authenticated@_sender$\ variable. If the sender is not trusted, Exim
9561 accepts the syntax of \\AUTH=\\, but ignores the data.
9562
9563 When a message is submitted locally (that is, not over a TCP connection), the
9564 value of \$authenticated@_sender$\ is an address constructed from the login
9565 name of the calling process and \$qualify@_domain$\.
9566
9567
9568 .index authentication||failure
9569 .tempindent 0
9570 \$authentication@_failed$\:
9571 This variable is set to `1' in an Exim server if a client issues an \\AUTH\\
9572 command that does not succeed. Otherwise it is set to `0'. This makes it
9573 possible to distinguish between `did not try to authenticate'
9574 (\$sender@_host@_authenticated$\ is empty and \$authentication__failed$\ is set
9575 to `0') and `tried to authenticate but failed' (\$sender@_host@_authenticated$\
9576 is empty and \$authentication@_failed$\ is set to `1'). Failure includes any
9577 negative response to an \\AUTH\\ command, including (for example) an attempt to
9578 use an undefined mechanism.
9579
9580
9581 .index message||body, line count
9582 .index body of message||line count
9583 .tempindent 0
9584 \$body@_linecount$\:
9585 When a message is being received or delivered, this variable contains the
9586 number of lines in the message's body.
9587
9588 .index message||body, binary zero count
9589 .index body of message||binary zero count
9590 .index binary zero||in message body
9591 .tempindent 0
9592 \$body@_zerocount$\:
9593 When a message is being received or delivered, this variable contains the
9594 number of binary zero bytes in the message's body.
9595
9596 .tempindent 0
9597 \$bounce@_recipient$\:
9598 This is set to the recipient address of a bounce message while Exim is creating
9599 it. It is useful if a customized bounce message text file is in use (see
9600 chapter ~~CHAPemsgcust).
9601
9602 .tempindent 0
9603 \$bounce@_return@_size@_limit$\: This contains the value set in the
9604 \bounce@_return@_size@_limit\ option, rounded up to a multiple of 1000. It is
9605 useful when a customized error message text file is in use (see chapter
9606 ~~CHAPemsgcust).
9607
9608 .index gid (group id)||caller
9609 .tempindent 0
9610 \$caller@_gid$\: The
9611 real
9612 group id under which the process that called Exim was
9613 running. This is not the same as the group id of the originator of a message
9614 (see \$originator@_gid$\). If Exim re-execs itself, this variable in the new
9615 incarnation normally contains the Exim gid.
9616
9617 .index uid (user id)||caller
9618 .tempindent 0
9619 \$caller@_uid$\: The
9620 real
9621 user id under which the process that called Exim was
9622 running. This is not the same as the user id of the originator of a message
9623 (see \$originator@_uid$\). If Exim re-execs itself, this variable in the new
9624 incarnation normally contains the Exim uid.
9625
9626 .tempindent 0
9627 \$compile@_date$\: The date on which the Exim binary was compiled.
9628
9629 .tempindent 0
9630 \$compile@_number$\: The building process for Exim keeps a count of the number
9631 of times it has been compiled. This serves to distinguish different
9632 compilations of the same version of the program.
9633
9634 .em
9635 .tempindent 0
9636 \$demime@_$\\*xxx*\: Two variables whose names start with \$demime$\ are
9637 available when Exim is compiled with the content-scanning extension and the
9638 obsolete \demime\ condition. For details, see section ~~SECTdemimecond.
9639 .nem
9640
9641 .index black list (DNS)
9642 .tempindent 0
9643 \$dnslist@_domain$\: When a client host is found to be on a DNS (black) list,
9644 the list's domain name is put into this variable so that it can be included in
9645 the rejection message.
9646
9647 .tempindent 0
9648 \$dnslist@_text$\: When a client host is found to be on a DNS (black) list, the
9649 contents of any associated TXT record are placed in this variable.
9650
9651 .tempindent 0
9652 \$dnslist@_value$\: When a client host is found to be on a DNS (black) list,
9653 the IP address from the resource record is placed in this variable.
9654 If there are multiple records, all the addresses are included, comma-space
9655 separated.
9656
9657 .tempindent 0
9658 \$domain$\: When an address is being routed, or delivered on its own, this
9659 variable contains the domain. Global address rewriting happens when a message
9660 is received, so the value of \$domain$\ during routing and delivery is the
9661 value after rewriting. \$domain$\ is set during user filtering, but not during
9662 system filtering, because a message may have many recipients and the system
9663 filter is called just once.
9664
9665 When more than one address is being delivered at once (for example, several
9666 \\RCPT\\ commands in one SMTP delivery), \$domain$\ is set only if they all
9667 have the same domain. Transports can be restricted to handling only one domain
9668 at a time if the value of \$domain$\ is required at transport time -- this is
9669 the default for local transports. For further details of the environment in
9670 which local transports are run, see chapter ~~CHAPenvironment.
9671
9672 .index \delay@_warning@_condition\
9673 At the end of a delivery, if all deferred addresses have the same domain, it is
9674 set in \$domain$\ during the expansion of \delay@_warning@_condition\.
9675
9676 The \$domain$\ variable is also used in some other circumstances:
9677 .numberpars $.
9678 When an ACL is running for a \\RCPT\\ command, \$domain$\ contains the domain
9679 of the recipient address.
9680 \**Note:**\ the domain of the sender address is in \$sender@_address@_domain$\
9681 at \\MAIL\\ time and at \\RCPT\\ time. \$domain$\ is not set for the \\MAIL\\
9682 ACL.
9683 .nextp
9684 When a rewrite item is being processed (see chapter ~~CHAPrewrite), \$domain$\
9685 contains the domain portion of the address that is being rewritten; it can be
9686 used in the expansion of the replacement address, for example, to rewrite
9687 domains by file lookup.
9688 .nextp
9689 With one important exception, whenever a domain list is being scanned,
9690 \$domain$\ contains the subject domain. \**Exception**\: When a domain list in
9691 a \sender@_domains\ condition in an ACL is being processed, the subject domain
9692 is in \$sender@_address@_domain$\ and not in \$domain$\. It works this way so
9693 that, in a \\RCPT\\ ACL, the sender domain list can be dependent on the
9694 recipient domain (which is what is in \$domain$\ at this time).
9695 .nextp
9696 .index \\ETRN\\||value of \$domain$\
9697 .index \smtp@_etrn@_command\
9698 When the \smtp@_etrn@_command\ option is being expanded, \$domain$\ contains
9699 the complete argument of the \\ETRN\\ command (see section ~~SECTETRN).
9700 .endp
9701
9702 .tempindent 0
9703 \$domain@_data$\: When the \domains\ option on a router matches a domain by
9704 means of a lookup, the data read by the lookup is available during the running
9705 of the router as \$domain@_data$\. In addition, if the driver routes the
9706 address to a transport, the value is available in that transport. If the
9707 transport is handling multiple addresses, the value from the first address is
9708 used.
9709
9710 \$domain@_data$\ is also set when the \domains\ condition in an ACL matches a
9711 domain by means of a lookup. The data read by the lookup is available during
9712 the rest of the ACL statement. In all other situations, this variable expands
9713 to nothing.
9714
9715 .tempindent 0
9716 \$exim@_gid$\: This variable contains the numerical value of the Exim group id.
9717
9718 .tempindent 0
9719 \$exim@_path$\: This variable contains the path to the Exim binary.
9720
9721 .tempindent 0
9722 \$exim@_uid$\: This variable contains the numerical value of the Exim user id.
9723
9724 .em
9725 .tempindent 0
9726 \$found@_extension$\: This variable is available when Exim is compiled with the
9727 content-scanning extension and the obsolete \demime\ condition. For details,
9728 see section ~~SECTdemimecond.
9729 .nem
9730
9731 .tempindent 0
9732 \$header@_<<name>>$\: This is not strictly an expansion variable. It is
9733 expansion syntax for inserting the message header line with the given name.
9734 Note that the name must be terminated by colon or white space, because it may
9735 contain a wide variety of characters.
9736 Note also that braces must \*not*\ be used.
9737
9738 .tempindent 0
9739 \$home$\:
9740 When the \check@_local@_user\ option is set for a router, the user's home
9741 directory is placed in \$home$\ when the check succeeds. In particular, this
9742 means it is set during the running of users' filter files. A router may also
9743 explicitly set a home directory for use by a transport; this can be overridden
9744 by a setting on the transport itself.
9745
9746 When running a filter test via the \-bf-\ option, \$home$\ is set to the value
9747 of the environment variable \\HOME\\.
9748
9749 .tempindent 0
9750 \$host$\:
9751 When the \%smtp%\ transport is expanding its options for encryption using TLS,
9752 \$host$\ contains the name of the host to which it is connected. Likewise, when
9753 used in the client part of an authenticator configuration (see chapter
9754 ~~CHAPSMTPAUTH), \$host$\ contains the name of the server to which the client
9755 is connected.
9756 .index transport||filter
9757 .index filter||transport filter
9758 When used in a transport filter (see chapter ~~CHAPtransportgeneric) \$host$\
9759 refers to the host involved in the current connection. When a local transport
9760 is run as a result of a router that sets up a host list, \$host$\ contains the
9761 name of the first host.
9762
9763 .tempindent 0
9764 \$host@_address$\:
9765 This variable is set to the remote host's IP address whenever \$host$\ is set
9766 for a remote connection.
9767 .em
9768 It is also set to the IP address that is being checked when the 
9769 \ignore@_target@_hosts\ option is being processed.
9770 .nem
9771
9772 .tempindent 0
9773 \$host@_data$\:
9774 If a \hosts\ condition in an ACL is satisfied by means of a lookup, the result
9775 of the lookup is made available in the \$host@_data$\ variable. This
9776 allows you, for example, to do things like this:
9777 .display asis
9778 deny  hosts = net-lsearch;/some/file
9779       message = $host_data
9780 .endd
9781
9782 .em
9783 .index host||name lookup, failure of
9784 .tempindent 0
9785 \$host@_lookup@_deferred$\:
9786 This variable normally contains `0', as does \$host@_lookup@_failed$\. When a
9787 message comes from a remote host and there is an attempt to look up the host's
9788 name from its IP address, and the attempt is not successful, one of these
9789 variables is set to `1'.
9790 .numberpars $.
9791 If the lookup receives a definite negative response (for example, a DNS lookup 
9792 succeeded, but no records were found), \$host@_lookup@_failed$\ is set to `1'.
9793 .nextp
9794 If there is any kind of problem during the lookup, such that Exim cannot 
9795 tell whether or not the host name is defined (for example, a timeout for a DNS 
9796 lookup), \$host@_lookup@_deferred$\ is set to `1'.
9797 .endp
9798 Looking up a host's name from its IP address consists of more than just a
9799 single reverse lookup. Exim checks that a forward lookup of at least one of the
9800 names it receives from a reverse lookup yields the original IP address. If this
9801 is not the case, Exim does not accept the looked up name(s), and
9802 \$host@_lookup@_failed$\ is set to `1'. Thus, being able to find a name from an
9803 IP address (for example, the existence of a PTR record in the DNS) is not
9804 sufficient on its own for the success of a host name lookup. If the reverse
9805 lookup succeeds, but there is a lookup problem such as a timeout when checking
9806 the result, the name is not accepted, and \$host@_lookup@_deferred$\ is set to
9807 `1'. See also \$sender@_host@_name$\.
9808
9809 .tempindent 0
9810 \$host@_lookup@_failed$\: See \$host@_lookup@_deferred$\.
9811 .nem
9812
9813 .tempindent 0
9814 \$inode$\:
9815 The only time this variable is set is while expanding the \directory@_file\
9816 option in the \%appendfile%\ transport. The variable contains the inode number
9817 of the temporary file which is about to be renamed. It can be used to construct
9818 a unique name for the file.
9819
9820 .tempindent 0
9821 \$interface@_address$\:
9822 When a message is received over a TCP/IP connection, this variable contains the
9823 address of the local IP interface. See also the \-oMi-\ command line option.
9824 This variable can be used in ACLs and also, for example, to make the file name
9825 for a TLS certificate depend on which interface is being used.
9826
9827 .tempindent 0
9828 \$interface@_port$\:
9829 When a message is received over a TCP/IP connection, this variable contains the
9830 local port number. 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 port is being used.
9833
9834 .tempindent 0
9835 \$ldap@_dn$\:
9836 This variable, which is available only when Exim is compiled with LDAP support,
9837 contains the DN from the last entry in the most recently successful LDAP
9838 lookup.
9839
9840 .tempindent 0
9841 \$load@_average$\:
9842 This variable contains the system load average, multiplied by 1000 to that it
9843 is an integer. For example, if the load average is 0.21, the value of the
9844 variable is 210. The value is recomputed every time the variable is referenced.
9845
9846 .tempindent 0
9847 \$local@_part$\: When an address is being routed, or delivered on its own, this
9848 variable contains the local part. When a number of addresses are being
9849 delivered together (for example, multiple \\RCPT\\ commands in an SMTP
9850 session), \$local@_part$\ is not set.
9851
9852 Global address rewriting happens when a message is received, so the value of
9853 \$local@_part$\ during routing and delivery is the value after rewriting.
9854 \$local@_part$\ is set during user filtering, but not during system filtering,
9855 because a message may have many recipients and the system filter is called just
9856 once.
9857
9858 If a local part prefix or suffix has been recognized, it is not included in the
9859 value of \$local@_part$\ during routing and subsequent delivery. The values of
9860 any prefix or suffix are in \$local@_part@_prefix$\ and
9861 \$local@_part@_suffix$\, respectively.
9862
9863 When a message is being delivered to a file, pipe, or autoreply transport as a
9864 result of aliasing or forwarding, \$local@_part$\ is set to the local part of
9865 the parent address, not to the file name or command (see \$address@_file$\ and
9866 \$address@_pipe$\).
9867
9868 When an ACL is running for a \\RCPT\\ command, \$local@_part$\ contains the
9869 local part of the recipient address.
9870
9871 When a rewrite item is being processed (see chapter ~~CHAPrewrite),
9872 \$local@_part$\ contains the local part of the address that is being rewritten;
9873 it can be used in the expansion of the replacement address, for example.
9874
9875 In all cases, all quoting is removed from the local part. For example, for both
9876 the addresses
9877 .display asis
9878 "abc:xyz"@test.example
9879 abc\:xyz@test.example
9880 .endd
9881 the value of \$local@_part$\ is
9882 .display asis
9883 abc:xyz
9884 .endd
9885 If you use \$local@_part$\ to create another address, you should always wrap it
9886 inside a quoting operator. For example, in a \%redirect%\ router you could have:
9887 .display asis
9888 data = ${quote_local_part:$local_part}@new.domain.example
9889 .endd
9890 \**Note**\: The value of \$local@_part$\ is normally lower cased. If you want
9891 to process local parts in a case-dependent manner in a router, you can set the
9892 \caseful@_local@_part\ option (see chapter ~~CHAProutergeneric).
9893
9894 .tempindent 0
9895 \$local@_part@_data$\:
9896 When the \local@_parts\ option on a router matches a local part by means of a
9897 lookup, the data read by the lookup is available during the running of the
9898 router as \$local@_part@_data$\. In addition, if the driver routes the address
9899 to a transport, the value is available in that transport. If the transport is
9900 handling multiple addresses, the value from the first address is used.
9901
9902 \$local@_part@_data$\ is also set when the \local@_parts\ condition in an ACL
9903 matches a local part by means of a lookup. The data read by the lookup is
9904 available during the rest of the ACL statement. In all other situations, this
9905 variable expands to nothing.
9906
9907 .tempindent 0
9908 \$local@_part@_prefix$\: When an address is being routed or delivered, and a
9909 specific prefix for the local part was recognized, it is available in this
9910 variable, having been removed from \$local@_part$\.
9911
9912 .tempindent 0
9913 \$local@_part@_suffix$\: When an address is being routed or delivered, and a
9914 specific suffix for the local part was recognized, it is available in this
9915 variable, having been removed from \$local@_part$\.
9916
9917 .tempindent 0
9918 \$local@_scan@_data$\: This variable contains the text returned by the
9919 \*local@_scan()*\ function when a message is received. See chapter
9920 ~~CHAPlocalscan for more details.
9921
9922 .tempindent 0
9923 \$local@_user@_gid$\: See \$local@_user@_uid$\.
9924
9925 .tempindent 0
9926 \$local@_user@_uid$\: This variable and \$local@_user@_gid$\ are set to
9927 the uid and gid after the \check__local__user\ router precondition succeeds.
9928 This means that their values are available for the remaining preconditions
9929 (\senders\, \require@_files\, and \condition\), for the \address@_data\
9930 expansion, and for any router-specific expansions. At all other times, the
9931 values in these variables are \"(uid@_t)(-1)"\ and \"(gid@_t)(-1)"\,
9932 respectively.
9933
9934 .tempindent 0
9935 \$localhost@_number$\: This contains the expanded value of the
9936 \localhost@_number\ option. The expansion happens after the main options have
9937 been read.
9938
9939 .em
9940 .tempindent 0
9941 \$log@_inodes$\: The number of free inodes in the disk partition where Exim's 
9942 log files are being written. The value is recalculated whenever the variable is
9943 referenced. If the relevant file system does not have the concept of inodes,
9944 the value of is -1. See also the \check@_log@_inodes\ option.
9945  
9946 .tempindent 0
9947 \$log@_space$\: The amount of free space (as a number of kilobytes) in the disk
9948 partition where Exim's log files are being written. The value is recalculated
9949 whenever the variable is referenced. If the operating system does not have the
9950 ability to find the amount of free space (only true for experimental systems),
9951 the space value is -1. See also the \check@_log@_space\ option.
9952 .nem
9953
9954 .tempindent 0
9955 \$mailstore@_basename$\: This variable is set only when doing deliveries in
9956 `mailstore' format in the \%appendfile%\ transport. During the expansion of the
9957 \mailstore@_prefix\, \mailstore@_suffix\, \message__prefix\, and
9958 \message@_suffix\ options, it contains the basename of the files that are being
9959 written, that is, the name without the `.tmp', `.env', or `.msg' suffix. At all
9960 other times, this variable is empty.
9961
9962 .em
9963 .tempindent 0
9964 \$malware@_name$\: This variable is available when Exim is compiled with the 
9965 content-scanning extension. It is set to the name of the virus that was found 
9966 when the ACL \malware\ condition is true (see section ~~SECTscanvirus).
9967 .nem
9968
9969 .index message||age of
9970 .tempindent 0
9971 \$message@_age$\: This variable is set at the start of a delivery attempt to
9972 contain the number of seconds since the message was received. It does not
9973 change during a single delivery attempt.
9974
9975 .index body of message||expansion variable
9976 .index message||body, in expansion
9977 .index binary zero||in message body
9978 .tempindent 0
9979 \$message@_body$\: This variable contains the initial portion of a message's
9980 body while it is being delivered, and is intended mainly for use in filter
9981 files. The maximum number of characters of the body that are put into the
9982 variable is set by the \message@_body@_visible\ configuration option; the
9983 default is 500. Newlines are converted into spaces to make it easier to search
9984 for phrases that might be split over a line break.
9985 Binary zeros are also converted into spaces.
9986
9987 .index body of message||expansion variable
9988 .index message||body, in expansion
9989 .tempindent 0
9990 \$message@_body@_end$\: This variable contains the final portion of a message's
9991 body while it is being delivered. The format and maximum size are as for
9992 \$message@_body$\.
9993
9994 .index body of message||size
9995 .index message||body, size
9996 .tempindent 0
9997 \$message@_body@_size$\: When a message is being delivered, this variable
9998 contains the size of the body in bytes. The count starts from the character
9999 after the blank line that separates the body from the header. Newlines are
10000 included in the count. See also \$message@_size$\, \$body@_linecount$\, and 
10001 \$body@_zerocount$\.
10002
10003 .tempindent 0
10004 \$message@_headers$\:
10005 This variable contains a concatenation of all the header lines when a message
10006 is being processed, except for lines added by routers or transports. The header
10007 lines are separated by newline characters.
10008
10009 .tempindent 0
10010 \$message@_id$\:
10011 When a message is being received or delivered, this variable contains the
10012 unique message id that is used by Exim to identify the message.
10013 An id is not created for a message until after its header has been
10014 successfully received.
10015 \**Note**\: This is \*not*\ the contents of the ::Message-ID:: header line; it
10016 is the local id that Exim assigns to the message, for example:
10017 \"1BXTIK-0001yO-VA"\.
10018
10019 .index size||of message
10020 .index message||size
10021 .tempindent 0
10022 \$message@_size$\:
10023 When a message is being processed, this variable contains its size in bytes. In
10024 most cases, the size includes those headers that were received with the
10025 message, but not those (such as ::Envelope-to::) that are added to individual
10026 deliveries as they are written. However, there is one special case: during the
10027 expansion of the \maildir@_tag\ option in the \%appendfile%\ transport while
10028 doing a delivery in maildir format, the value of \$message@_size$\ is the
10029 precise size of the file that has been written. See also
10030 \$message@_body@_size$\, \$body@_linecount$\, and \$body@_zerocount$\.
10031
10032 .index \\RCPT\\||value of \$message@_size$\
10033 While running an ACL at the time of an SMTP \\RCPT\\ command, \$message@_size$\
10034 contains the size supplied on the \\MAIL\\ command, or
10035 -1
10036 if no size was given. The value may not, of course, be truthful.
10037
10038 .em
10039 .tempindent 0
10040 \$mime@_$\\*xxx*\:
10041 A number of variables whose names start with \$mime$\ are available when Exim
10042 is compiled with the content-scanning extension. For details, see section
10043 ~~SECTscanmimepart.
10044 .nem
10045
10046 .tempindent 0
10047 \$n0$\ -- \$n9$\: These variables are counters that can be incremented by means
10048 of the \add\ command in filter files.
10049
10050 .tempindent 0
10051 \$original@_domain$\: When a top-level address is being processed for delivery,
10052 this contains the same value as \$domain$\. However, if a `child' address (for
10053 example, generated by an alias, forward, or filter file) is being processed,
10054 this variable contains the domain of the original address. This differs from
10055 \$parent@_domain$\ only when there is more than one level of aliasing or
10056 forwarding. When more than one address is being delivered in a single transport
10057 run, \$original@_domain$\ is not set.
10058
10059 If new an address is created by means of a \deliver\ command in a system
10060 filter, it is set up with an artificial `parent' address. This has the local
10061 part \*system-filter*\ and the default qualify domain.
10062
10063 .tempindent 0
10064 \$original@_local@_part$\: When a top-level address is being processed for
10065 delivery, this contains the same value as \$local@_part$\, unless a prefix or
10066 suffix was removed from the local part, because \$original@_local@_part$\
10067 always contains the full local part. When a `child' address (for example,
10068 generated by an alias, forward, or filter file) is being processed, this
10069 variable contains the full local part of the original address.
10070
10071 If the router that did the redirection processed the local part
10072 case-insensitively, the value in \$original@_local@_part$\ is in lower case.
10073 This variable differs from \$parent@_local@_part$\ only when there is more than
10074 one level of aliasing or forwarding. When more than one address is being
10075 delivered in a single transport run, \$original@_local@_part$\ is not set.
10076
10077 If new an address is created by means of a \deliver\ command in a system
10078 filter, it is set up with an artificial `parent' address. This has the local
10079 part \*system-filter*\ and the default qualify domain.
10080
10081
10082 .index gid (group id)||of originating user
10083 .index sender||gid
10084 .tempindent 0
10085 \$originator@_gid$\: The value of \$caller@_gid$\ that was set when the message
10086 was received. For messages received via the command line, this is the gid of
10087 the sending user. For messages received by SMTP over TCP/IP, this is normally
10088 the gid of the Exim user.
10089
10090 .index uid (user id)||of originating user
10091 .index sender||uid
10092 .tempindent 0
10093 \$originator@_uid$\: The value of \$caller@_uid$\ that was set when the message
10094 was received. For messages received via the command line, this is the uid of
10095 the sending user. For messages received by SMTP over TCP/IP, this is normally
10096 the uid of the Exim user.
10097
10098 .tempindent 0
10099 \$parent@_domain$\: This variable is similar to \$original@_domain$\ (see
10100 above), except that it refers to the immediately preceding parent address.
10101
10102 .tempindent 0
10103 \$parent@_local@_part$\: This variable is similar to \$original@_local@_part$\
10104 (see above), except that it refers to the immediately preceding parent address.
10105
10106 .index pid (process id)||of current process
10107 .tempindent 0
10108 \$pid$\: This variable contains the current process id.
10109
10110 .index filter||transport filter
10111 .index transport||filter
10112 .tempindent 0
10113 \$pipe@_addresses$\: This is not an expansion variable, but is mentioned here
10114 because the string `@$pipe@_addresses' is handled specially in the command
10115 specification for the \%pipe%\ transport (chapter ~~CHAPpipetransport) and in
10116 transport filters (described under \transport@_filter\ in chapter
10117 ~~CHAPtransportgeneric). It cannot be used in general expansion strings, and
10118 provokes an `unknown variable' error if encountered.
10119
10120 .tempindent 0
10121 \$primary@_hostname$\: The value set in the configuration file, or read by the
10122 \*uname()*\ function. If \*uname()*\ returns a single-component name, Exim
10123 calls \*gethostbyname()*\ (or \*getipnodebyname()*\ where available) in an
10124 attempt to acquire a fully qualified host name.
10125 See also \$smtp@_active@_hostname$\.
10126
10127 .tempindent 0
10128 \$qualify@_domain$\: The value set for this option in the configuration file.
10129
10130 .tempindent 0
10131 \$qualify@_recipient$\: The value set for this option in the configuration file,
10132 or if not set, the value of \$qualify@_domain$\.
10133
10134 .tempindent 0
10135 \$rcpt@_count$\: When a message is being received by SMTP, this variable
10136 contains the number of \\RCPT\\ commands received for the current message. If
10137 this variable is used in a \\RCPT\\ ACL, its value includes the current
10138 command.
10139
10140 .tempindent 0
10141 \$rcpt@_defer@_count$\: When a message is being received by SMTP, this variable
10142 contains the number of \\RCPT\\ commands in the current message that have
10143 previously been rejected with a temporary (4\*xx*\) response.
10144
10145 .tempindent 0
10146 \$rcpt@_fail@_count$\: When a message is being received by SMTP, this variable
10147 contains the number of \\RCPT\\ commands in the current message that have
10148 previously been rejected with a permanent (5\*xx*\) response.
10149
10150 .tempindent 0
10151 \$received@_count$\: This variable contains the number of ::Received:: header
10152 lines in the message, including the one added by Exim (so its value is always
10153 greater than zero). It is available in the \\DATA\\ ACL, the non-SMTP ACL, and
10154 while routing and delivering.
10155
10156 .tempindent 0
10157 \$received@_for$\: If there is only a single recipient address in an incoming
10158 message, this variable contains that address when the ::Received:: header line
10159 is being built.
10160 The value is copied after recipient rewriting has happened, but before the
10161 \*local@_scan()*\ function is run.
10162
10163 .tempindent 0
10164 \$received@_protocol$\: When a message is being processed, this variable
10165 contains the name of the protocol by which it was received. 
10166 .em
10167 Most of the names used by Exim are defined by RFCs 821, 2821, and 3848. They
10168 start with `smtp' (the client used \\HELO\\) or `esmtp' (the client used
10169 \\EHLO\\). This can be followed by `s' for secure (encrypted) and/or `a' for
10170 authenticated. Thus, for example, if the protocol is set to `esmtpsa', the
10171 message was received over an encrypted SMTP connection and the client was
10172 successfully authenticated.
10173
10174 Exim also uses the protocol name `smtps' for the rare situation where the 
10175 client initially used \\EHLO\\, set up an encrypted connection using
10176 \\STARTTLS\\, and then used \\HELO\\ afterwards to initiate the encrypted 
10177 session.
10178
10179 The \-oMr-\ option provides a way of specifying a custom protocol name for 
10180 messages that are injected locally by trusted callers. This is commonly used to 
10181 identify messages that are being re-injected after some kind of scanning.
10182 .nem
10183
10184 .tempindent 0
10185 \$recipient@_data$\: This variable is set after an indexing lookup success in
10186 an ACL \recipients\ condition. It contains the data from the lookup, and the
10187 value remains set until the next \recipients\ test. Thus, you can do things
10188 like this:
10189 .display
10190 require recipients      = cdb*@@;/some/file
10191 deny    \*some further test involving*\ @$recipient@_data
10192 .endd
10193 \**Warning**\: This variable is set only when a lookup is used as an indexing
10194 method in the address list, using the semicolon syntax as in the example above.
10195 The variable is not set for a lookup that is used as part of the string
10196 expansion that all such lists undergo before being interpreted.
10197
10198 .em
10199 .tempindent 0
10200 \$recipient@_verify@_failure$\: In an ACL, when a recipient verification fails,
10201 this variable contains information about the failure. It is set to one of the
10202 following words:
10203 .numberpars " "
10204 `qualify': The address was unqualified (no domain), and the message
10205 was neither local nor came from an exempted host.
10206 .nextp
10207 `route': Routing failed.
10208 .nextp
10209 `mail': Routing succeeded, and a callout was attempted; rejection occurred at
10210 or before the \\MAIL\\ command (that is, on initial connection, \\HELO\\, or
10211 \\MAIL\\).
10212 .nextp
10213 `recipient': The \\RCPT\\ command in a callout was rejected.
10214 .nextp
10215 `postmaster': The postmaster check in a callout was rejected.
10216 .endp
10217 The main use of this variable is expected to be to distinguish between
10218 rejections of \\MAIL\\ and rejections of \\RCPT\\.
10219 .nem
10220
10221 .tempindent 0
10222 \$recipients$\: This variable contains a list of envelope recipients for a
10223 message. A comma and a space separate the addresses in the replacement text.
10224 However, the variable is not generally available, to prevent exposure of Bcc
10225 recipients in unprivileged users' filter files. You can use \$recipients$\ only
10226 in these two cases:
10227 .numberpars
10228 In a system filter file.
10229 .nextp
10230 .em
10231 In the ACLs associated with the \\DATA\\ command, that is, the ACLs defined by 
10232 \acl@_smtp@_predata\ and \acl@_smtp@_data\.
10233 .nem
10234 .endp
10235
10236 .tempindent 0
10237 \$recipients@_count$\: When a message is being processed, this variable
10238 contains the number of envelope recipients that came with the message.
10239 Duplicates are not excluded from the count. While a message is being received
10240 over SMTP, the number increases for each accepted recipient. It can be
10241 referenced in an ACL.
10242
10243 .tempindent 0
10244 \$reply@_address$\: When a message is being processed, this variable contains
10245 the contents of the ::Reply-To:: header line if one exists
10246 and it is not empty,
10247 or otherwise the contents of the ::From:: header line.
10248
10249 .tempindent 0
10250 \$return@_path$\: When a message is being delivered, this variable contains the
10251 return path -- the sender field that will be sent as part of the envelope. It
10252 is not enclosed in @<@> characters.
10253 At the start of routing an address,
10254 \$return@_path$\ has the same value as \$sender@_address$\, but if, for
10255 example, an incoming message to a mailing list has been expanded by a router
10256 which specifies a different address for bounce messages, \$return@_path$\
10257 subsequently contains the new bounce address, whereas \$sender@_address$\
10258 always contains the original sender address that was received with the message.
10259 In other words, \$sender@_address$\ contains the incoming envelope sender, and
10260 \$return@_path$\ contains the outgoing envelope sender.
10261
10262 .tempindent 0
10263 \$return@_size@_limit$\: This is an obsolete name for
10264 \$bounce@_return@_size@_limit$\.
10265
10266 .index return code||from \run\ expansion
10267 .tempindent 0
10268 \$runrc$\: This variable contains the return code from a command that is run by
10269 the \@$@{run...@}\ expansion item.
10270 \**Warning**\: In a router or transport, you cannot assume the order in which
10271 option values are expanded, except for those pre-conditions whose order of
10272 testing is documented. Therefore, you cannot reliably expect to set \$runrc$\
10273 by the expansion of one option, and use it in another.
10274
10275 .tempindent 0
10276 \$self@_hostname$\: When an address is routed to a supposedly remote host that
10277 turns out to be the local host, what happens is controlled by the
10278 .index \self\ option||value of host name
10279 \self\ generic router option. One of its values causes the address to be passed
10280 to another router. When this happens, \$self@_hostname$\ is set to the name of
10281 the local host that the original router encountered. In other circumstances its
10282 contents are null.
10283
10284 .tempindent 0
10285 \$sender@_address$\: When a message is being processed, this variable contains
10286 the sender's address that was received in the message's envelope. For bounce
10287 messages, the value of this variable is the empty string.
10288 See also \$return@_path$\.
10289
10290 .em
10291 .tempindent 0
10292 \$sender@_address@_data$\: If \$address@_data$\ is set when the routers are
10293 called from an ACL to verify a sender address, the final value is preserved in
10294 \$sender@_address@_data$\, to distinguish it from data from a recipient
10295 address. The value does not persist after the end of the current ACL statement.
10296 If you want to preserve it for longer, you can save it in an ACL variable.
10297 .nem
10298
10299 .tempindent 0
10300 \$sender@_address@_domain$\: The domain portion of \$sender@_address$\.
10301
10302 .tempindent 0
10303 \$sender@_address@_local@_part$\: The local part portion of \$sender@_address$\.
10304
10305 .tempindent 0
10306 \$sender@_data$\: This variable is set after a lookup success in an ACL
10307 \senders\ condition or in a router \senders\ option. It contains the data from
10308 the lookup, and the value remains set until the next \senders\ test. Thus, you
10309 can do things like this:
10310 .display
10311 require senders      = cdb*@@;/some/file
10312 deny    \*some further test involving*\ @$sender@_data
10313 .endd
10314 \**Warning**\: This variable is set only when a lookup is used as an indexing
10315 method in the address list, using the semicolon syntax as in the example above.
10316 The variable is not set for a lookup that is used as part of the string
10317 expansion that all such lists undergo before being interpreted.
10318
10319 .tempindent 0
10320 \$sender@_fullhost$\: When a message is received from a remote host, this
10321 variable contains the host name and IP address in a single string. It ends
10322 with the IP address in square brackets, followed by a colon and a port number
10323 if the logging of ports is enabled. The format of the rest of the string
10324 depends on whether the host issued a \\HELO\\ or \\EHLO\\ SMTP command, and
10325 whether the host name was verified by looking up its IP address. (Looking up
10326 the IP address can be forced by the \host@_lookup\ option, independent of
10327 verification.) A plain host name at the start of the string is a verified host
10328 name; if this is not present, verification either failed or was not requested.
10329 A host name in parentheses is the argument of a \\HELO\\ or \\EHLO\\ command.
10330 This is omitted if it is identical to the verified host name or to the host's
10331 IP address in square brackets.
10332
10333 .tempindent 0
10334 \$sender@_helo@_name$\: When a message is received from a remote host that has
10335 issued a \\HELO\\ or \\EHLO\\ command, the argument of that command is placed
10336 in this variable. It is also set if \\HELO\\ or \\EHLO\\ is used when a message
10337 is received using SMTP locally via the \-bs-\ or \-bS-\ options.
10338
10339 .tempindent 0
10340 \$sender@_host@_address$\: When a message is received from a remote host, this
10341 variable contains that host's IP address. For locally submitted messages, it is
10342 empty.
10343
10344 .tempindent 0
10345 \$sender@_host@_authenticated$\: This variable contains the name (not the
10346 public name) of the authenticator driver which successfully authenticated the
10347 client from which the message was received. It is empty if there was no
10348 successful authentication.
10349
10350 .tempindent 0
10351 \$sender@_host@_name$\: When a message is received from a remote host, this
10352 variable contains the host's name as obtained by looking up its IP address.
10353 For messages received by other means, this variable is empty.
10354
10355 If the host name has not previously been looked up, a reference to
10356 \$sender@_host@_name$\ triggers a lookup (for messages from remote hosts).
10357 A looked up name is accepted only if it leads back to the original IP address
10358 via a forward lookup. If either the reverse or the forward lookup fails
10359 .em
10360 to find any data,
10361 .nem
10362 or if the forward lookup does not yield the original IP address,
10363 \$sender@_host@_name$\ remains empty, and \$host@_lookup@_failed$\ is set to
10364 `1'.
10365 .em
10366 However, if either of the lookups cannot be completed (for example, there is a 
10367 DNS timeout), \$host@_lookup@_deferred$\ is set to `1', and 
10368 \$host@_lookup@_failed$\ remains set to `0'.
10369
10370 Once \$host@_lookup@_failed$\ is set to `1', Exim does not try to look up the 
10371 host name again if there is a subsequent reference to \$sender@_host@_name$\ 
10372 in the same Exim process, but it does try again if \$sender@_host@_deferred$\
10373 is set to `1'.
10374 .nem
10375
10376 Exim does not automatically look up every calling host's name. If you want
10377 maximum efficiency, you should arrange your configuration so that it avoids
10378 these lookups altogether. The lookup happens only if one or more of the
10379 following are true:
10380 .numberpars
10381 A string containing \$sender@_host@_name$\ is expanded.
10382 .nextp
10383 The calling host matches the list in \host@_lookup\. In the default
10384 configuration, this option is set to $*$, so it must be changed if lookups are
10385 to be avoided. (In the code, the default for \host@_lookup\ is unset.)
10386 .nextp
10387 Exim needs the host name in order to test an item in a host list. The items
10388 that require this are described in sections ~~SECThoslispatnam and
10389 ~~SECThoslispatnamsk.
10390 .nextp
10391 The calling host matches \helo@_try@_verify@_hosts\ or \helo@_verify@_hosts\.
10392 In this case, the host name is required to compare with the name quoted in any
10393 \\EHLO\\ or \\HELO\\ commands that the client issues.
10394 .nextp
10395 The remote host issues a \\EHLO\\ or \\HELO\\ command that quotes one of the
10396 domains in \helo@_lookup@_domains\. The default value of this option is
10397 .display asis
10398 helo_lookup_domains = @ : @[]
10399 .endd
10400 which causes a lookup if a remote host (incorrectly) gives the server's name or
10401 IP address in an \\EHLO\\ or \\HELO\\ command.
10402 .endp
10403
10404 .tempindent 0
10405 \$sender@_host@_port$\: When a message is received from a remote host, this
10406 variable contains the port number that was used on the remote host.
10407
10408 .tempindent 0
10409 \$sender@_ident$\: When a message is received from a remote host, this variable
10410 contains the identification received in response to an RFC 1413 request. When a
10411 message has been received locally, this variable contains the login name of the
10412 user that called Exim.
10413
10414 .tempindent 0
10415 \$sender@_rcvhost$\: This is provided specifically for use in ::Received::
10416 headers. It starts with either the verified host name (as obtained from a
10417 .index DNS||reverse lookup
10418 .index reverse DNS lookup
10419 reverse DNS lookup) or, if there is no verified host name, the IP address in
10420 square brackets. After that there may be text in parentheses. When the first
10421 item is a verified host name, the first thing in the parentheses is the IP
10422 address in square brackets, followed by a colon and a port number if port
10423 logging is enabled. When the first item is an IP address, the port is recorded
10424 as `port=$it{xxxx}' inside the parentheses.
10425
10426 There may also be items of the form `helo=$it{xxxx}' if \\HELO\\ or \\EHLO\\
10427 was used and its argument was not identical to the real host name or IP
10428 address, and `ident=$it{xxxx}' if an RFC 1413 ident string is available. If all
10429 three items are present in the parentheses, a newline and tab are inserted into
10430 the string, to improve the formatting of the ::Received:: header.
10431
10432 .em
10433 .tempindent 0
10434 \$sender@_verify@_failure$\: In an ACL, when a sender verification fails, this
10435 variable contains information about the failure. The details are the same as 
10436 for \$recipient@_verify@_failure$\.
10437
10438 .tempindent 0
10439 \$smtp@_active@_hostname$\: During an SMTP session, this variable contains the 
10440 value of the active host name, as specified by the \smtp@_active@_hostname\
10441 option. The value of \$smtp@_active@_hostname$\ is saved with any message that
10442 is received, so its value can be consulted during routing and delivery.
10443 .nem
10444
10445 .index \\AUTH\\||argument
10446 .index \\EXPN\\||argument
10447 .index \\ETRN\\||argument
10448 .index \\VRFY\\||argument
10449 .tempindent 0
10450 \$smtp@_command@_argument$\: While an ACL is running to check an \\AUTH\\,
10451 \\EHLO\\, \\EXPN\\, \\ETRN\\, \\HELO\\, or \\VRFY\\ command, this variable
10452 contains the argument for the SMTP command.
10453
10454 .tempindent 0
10455 \$sn0$\ -- \$sn9$\: These variables are copies of the values of the \$n0$\
10456 -- \$n9$\ accumulators that were current at the end of the system filter file.
10457 This allows a system filter file to set values that can be tested in users'
10458 filter files. For example, a system filter could set a value indicating how
10459 likely it is that a message is junk mail.
10460
10461 .em
10462 .tempindent 0
10463 \$spam@_$\\*xxx*\: A number of variables whose names start with \$spam$\ are
10464 available when Exim is compiled with the content-scanning extension. For
10465 details, see section ~~SECTscanspamass.
10466 .nem
10467
10468 .tempindent 0
10469 \$spool@_directory$\: The name of Exim's spool directory.
10470
10471 .em
10472 .tempindent 0
10473 \$spool@_inodes$\: The number of free inodes in the disk partition where Exim's
10474 spool files are being written. The value is recalculated whenever the variable
10475 is referenced. If the relevant file system does not have the concept of inodes,
10476 the value of is -1.
10477 See also the \check@_spool@_inodes\ option.
10478  
10479 .tempindent 0
10480 \$spool@_space$\: The amount of free space (as a number of kilobytes) in the
10481 disk partition where Exim's spool files are being written. The value is
10482 recalculated whenever the variable is referenced. If the operating system does
10483 not have the ability to find the amount of free space (only true for
10484 experimental systems), the space value is -1. For example, to check in an ACL
10485 that there is at least 50 megabytes free on the spool, you could write:
10486 .display asis
10487 condition = ${if > {$spool_space}{50000}}
10488 .endd
10489 See also the \check@_spool@_space\ option.
10490 .nem
10491
10492 .tempindent 0
10493 \$thisaddress$\: This variable is set only during the processing of the
10494 \foranyaddress\ command in a filter file. Its use is explained in the
10495 description of that command.
10496
10497 .tempindent 0
10498 \$tls@_certificate@_verified$\:
10499 This variable is set to `1' if a TLS certificate was verified when the message
10500 was received, and `0' otherwise.
10501
10502 .tempindent 0
10503 \$tls@_cipher$\: When a message is received from a remote host over an
10504 encrypted SMTP connection, this variable is set to the cipher suite that was
10505 negotiated, for example DES-CBC3-SHA.
10506 In other circumstances, in particular, for message received over unencrypted
10507 connections, the variable is empty.
10508 See chapter ~~CHAPTLS for details of TLS support.
10509
10510 .tempindent 0
10511 \$tls@_peerdn$\:  When a message is received from a remote host over an
10512 encrypted SMTP connection,
10513 and Exim is configured to request a certificate from the client,
10514 the value of the Distinguished Name of the certificate is made available in the
10515 \$tls@_peerdn$\ during subsequent processing.
10516
10517 .tempindent 0
10518 \$tod@_bsdinbox$\: The time of day and date, in the format required for
10519 BSD-style mailbox files, for example: Thu Oct 17 17:14:09 1995.
10520
10521 .tempindent 0
10522 \$tod@_epoch$\: The time and date as a number of seconds since the start of the
10523 Unix epoch.
10524
10525 .tempindent 0
10526 \$tod@_full$\: A full version of the time and date, for example: Wed, 16 Oct
10527 1995 09:51:40 +0100. The timezone is always given as a numerical offset from
10528 UTC, with positive values used for timezones that are ahead (east) of UTC, and
10529 negative values for those that are behind (west).
10530
10531 .tempindent 0
10532 \$tod@_log$\: The time and date in the format used for writing Exim's log
10533 files, for example: 1995-10-12 15:32:29,
10534 but without a timezone.
10535
10536 .tempindent 0
10537 \$tod@_logfile$\:
10538 This variable contains the date in the format yyyymmdd. This is the format that
10539 is used for datestamping log files when \log@_file@_path\ contains the \"%D"\
10540 flag.
10541
10542 .tempindent 0
10543 \$tod@_zone$\: This variable contains the numerical value of the local
10544 timezone, for example: -0500.
10545
10546 .tempindent 0
10547 \$tod@_zulu$\:
10548 This variable contains the UTC date and time in `Zulu' format, as specified by
10549 ISO 8601, for example: 20030221154023Z.
10550
10551 .index \$value$\
10552 .tempindent 0
10553 \$value$\: This variable contains the result of an expansion lookup, extraction
10554 operation, or external command, as described above.
10555
10556 .tempindent 0
10557 \$version@_number$\: The version number of Exim.
10558
10559 .tempindent 0
10560 \$warn@_message@_delay$\: This variable is set only during the creation of a
10561 message warning about a delivery delay. Details of its use are explained in
10562 section ~~SECTcustwarn.
10563
10564 .tempindent 0
10565 \$warn@_message@_recipients$\: This variable is set only during the creation of
10566 a message warning about a delivery delay. Details of its use are explained in
10567 section ~~SECTcustwarn.
10568 .pop
10569
10570
10571
10572 .
10573 .
10574 . ============================================================================
10575 .chapter Embedded Perl
10576 .set runningfoot "embedded Perl"
10577 .rset CHAPperl "~~chapter"
10578 .index Perl||calling from Exim
10579
10580 Exim can be built to include an embedded Perl interpreter. When this is done,
10581 Perl subroutines can be called as part of the string expansion process. To make
10582 use of the Perl support, you need version 5.004 or later of Perl installed on
10583 your system. To include the embedded interpreter in the Exim binary, include
10584 the line
10585 .display asis
10586 EXIM_PERL = perl.o
10587 .endd
10588 in your \(Local/Makefile)\ and then build Exim in the normal way.
10589
10590 .section Setting up so Perl can be used
10591 Access to Perl subroutines is via a global configuration option called
10592 .index \perl@_startup\
10593 \perl@_startup\ and an expansion string operator \@$@{perl ...@}\. If there is
10594 no \perl@_startup\ option in the Exim configuration file then no Perl
10595 interpreter is started and there is almost no overhead for Exim (since none of
10596 the Perl library will be paged in unless used). If there is a \perl@_startup\
10597 option then the associated value is taken to be Perl code which is executed in
10598 a newly created Perl interpreter.
10599
10600 The value of \perl@_startup\ is not expanded in the Exim sense, so you do not
10601 need backslashes before any characters to escape special meanings. The option
10602 should usually be something like
10603 .display asis
10604 perl_startup = do '/etc/exim.pl'
10605 .endd
10606 where \(/etc/exim.pl)\ is Perl code which defines any subroutines you want to
10607 use from Exim. Exim can be configured either to start up a Perl interpreter as
10608 soon as it is entered, or to wait until the first time it is needed. Starting
10609 the interpreter at the beginning ensures that it is done while Exim still has
10610 its setuid privilege, but can impose an unnecessary overhead if Perl is not in
10611 fact used in a particular run. Also, note that this does not mean that Exim is
10612 necessarily running as root when Perl is called at a later time. By default,
10613 the interpreter is started only when it is needed, but this can be changed in
10614 two ways:
10615 .numberpars $.
10616 .index \perl@_at@_start\
10617 Setting \perl@_at@_start\ (a boolean option) in the configuration requests
10618 a startup when Exim is entered.
10619 .nextp
10620 The command line option \-ps-\ also requests a startup when Exim is entered,
10621 overriding the setting of \perl@_at@_start\.
10622 .endp
10623 There is also a command line option \-pd-\ (for delay) which suppresses the
10624 initial startup, even if \perl@_at@_start\ is set.
10625
10626 .section Calling Perl subroutines
10627 When the configuration file includes a \perl@_startup\ option you can make use
10628 of the string expansion item to call the Perl subroutines that are defined
10629 by the \perl@_startup\ code. The operator is used in any of the following
10630 forms:
10631 .display asis
10632 ${perl{foo}}
10633 ${perl{foo}{argument}}
10634 ${perl{foo}{argument1}{argument2} ... }
10635 .endd
10636 which calls the subroutine \foo\ with the given arguments. A maximum of eight
10637 arguments may be passed. Passing more than this results in an expansion failure
10638 with an error message of the form
10639 .display asis
10640 Too many arguments passed to Perl subroutine "foo" (max is 8)
10641 .endd
10642 The return value of the Perl subroutine is evaluated in a scalar context before
10643 it is passed back to Exim to be inserted into the expanded string. If the
10644 return value is \*undef*\, the expansion is forced to fail in the same way as
10645 an explicit `fail' on an \@$@{if ...@}\ or \@$@{lookup...@}\ item. If the
10646 subroutine aborts by obeying Perl's \die\ function, the expansion fails with
10647 the error message that was passed to \die\.
10648
10649 .section Calling Exim functions from Perl
10650 Within any Perl code called from Exim, the function \*Exim@:@:expand@_string*\
10651 is available to call back into Exim's string expansion function. For example,
10652 the Perl code
10653 .display asis
10654 my $lp = Exim::expand_string('$local_part');
10655 .endd
10656 makes the current Exim \$local@_part$\ available in the Perl variable \$lp$\.
10657 Note those are single quotes and not double quotes to protect against
10658 \$local@_part$\ being interpolated as a Perl variable.
10659
10660 If the string expansion is forced to fail by a `fail' item, the result of
10661 \*Exim@:@:expand@_string*\ is \undef\. If there is a syntax error in the
10662 expansion string, the Perl call from the original expansion string fails with
10663 an appropriate error message, in the same way as if \die\ were used.
10664
10665 .index debugging||from embedded Perl
10666 .index log||writing from embedded Perl
10667 Two other Exim functions are available for use from within Perl code.
10668 \*Exim@:@:debug@_write(<<string>>)*\ writes the string to the standard error
10669 stream if Exim's debugging is enabled. If you want a newline at the end, you
10670 must supply it. \*Exim@:@:log@_write(<<string>>)*\ writes the string to Exim's
10671 main log, adding a leading timestamp. In this case, you should not supply a
10672 terminating newline.
10673
10674 .em
10675 .section Use of standard output and error by Perl
10676 You should not write to the standard error or output streams from within your 
10677 Perl code, as it is not defined how these are set up. In versions of Exim up to 
10678 at least 4.50, it is possible for the standard output or error to refer to the 
10679 SMTP connection during message reception. Writing to this stream is likely to 
10680 cause chaos. Something may be done about this in later releases.
10681
10682 Unfortunately, the Perl \warn\ statment writes to the standard error stream, 
10683 and this may be embedded in Perl modules that you use, but over which you have 
10684 no control. One way round this is to ensure that the following Perl magic is 
10685 obeyed before \warn\ is used:
10686 .display asis
10687 $SIG{__WARN__} = sub { Exim::log_write($_[0]) };
10688 .endd
10689 This causes the output of the \warn\ statement to be written to Exim's log 
10690 file.
10691 .nem
10692
10693
10694 .
10695 .
10696 .
10697 .
10698 . ============================================================================
10699 .chapter Starting the daemon and the use of network interfaces
10700 .set runningfoot "starting the daemon"
10701 .rset CHAPinterfaces "~~chapter"
10702 .index daemon||starting
10703 .index interface||listening
10704 .index network interface
10705 .index interface||network
10706 .index IP address||for listening
10707 .index daemon||listening IP addresses
10708 .index TCP/IP||setting listening interfaces
10709 .index TCP/IP||setting listening ports
10710
10711 A host that is connected to a TCP/IP network may have one or more physical
10712 hardware network interfaces. Each of these interfaces may be configured as one
10713 or more `logical' interfaces, which are the entities that a program actually
10714 works with. Each of these logical interfaces is associated with an IP address.
10715 In addition, TCP/IP software supports `loopback' interfaces (127.0.0.1 in IPv4
10716 and @:@:1 in IPv6), which do not use any physical hardware. Exim requires
10717 knowledge about the host's interfaces for use in three different circumstances:
10718 .numberpars
10719 When a listening daemon is started, Exim needs to know which interfaces
10720 and ports to listen on.
10721 .nextp
10722 When Exim is routing an address, it needs to know which IP addresses
10723 are associated with local interfaces. This is required for the correct
10724 processing of MX lists by removing the local host and others with the
10725 same or higher priority values. Also, Exim needs to detect cases
10726 when an address is routed to an IP address that in fact belongs to the
10727 local host. Unless the \self\ router option or the \allow@_localhost\
10728 option of the smtp transport is set (as appropriate), this is treated
10729 as an error situation.
10730 .nextp
10731 When Exim connects to a remote host, it may need to know which interface to use
10732 for the outgoing connection.
10733 .endp
10734
10735 Exim's default behaviour is likely to be appropriate in the vast majority
10736 of cases. If your host has only one interface, and you want all its IP
10737 addresses to be treated in the same way, and you are using only the
10738 standard SMTP port, you should not need to take any special action. The
10739 rest of this chapter does not apply to you.
10740
10741 In a more complicated situation you may want to listen only on certain
10742 interfaces, or on different ports, and for this reason there are a number of
10743 options that can be used to influence Exim's behaviour. The rest of this
10744 chapter describes how they operate.
10745
10746 When a message is received over TCP/IP, the interface and port that were
10747 actually used are set in \$interface@_address$\ and \$interface@_port$\.
10748
10749
10750 .section Starting a listening daemon
10751 When a listening daemon is started (by means of the \-bd-\ command line
10752 option), the interfaces and ports on which it listens are controlled by the
10753 following options:
10754 .numberpars $.
10755 \daemon@_smtp@_ports\ contains a list of default ports. (For backward
10756 compatibility, this option can also be specified in the singular.)
10757 .nextp
10758 \local@_interfaces\ contains list of interface IP addresses on which to
10759 listen. Each item may optionally also specify a port.
10760 .endp
10761 The default list separator in both cases is a colon, but this can be changed as
10762 described in section ~~SECTlistconstruct. When IPv6 addresses are involved, it
10763 is usually best to change the separator to avoid having to double all the
10764 colons. For example:
10765 .display asis
10766 local_interfaces = <; 127.0.0.1 ; \
10767                       192.168.23.65 ; \
10768                       ::1 ; \
10769                       3ffe:ffff:836f::fe86:a061
10770 .endd
10771 There are two different formats for specifying a port along with an IP address
10772 in \local@_interfaces\:
10773 .numberpars
10774 The port is added onto the address with a dot separator. For example, to listen
10775 on port 1234 on two different IP addresses:
10776 .display asis
10777 local_interfaces = <; 192.168.23.65.1234 ; \
10778                       3ffe:ffff:836f::fe86:a061.1234
10779 .endd
10780 .nextp
10781 The IP address is enclosed in square brackets, and the port is added
10782 with a colon separator, for example:
10783 .display asis
10784 local_interfaces = <; [192.168.23.65]:1234 ; \
10785                       [3ffe:ffff:836f::fe86:a061]:1234
10786 .endd
10787 .endp
10788 When a port is not specified, the value of \daemon@_smtp@_ports\ is used. The
10789 default setting contains just one port:
10790 .display asis
10791 daemon_smtp_ports = smtp
10792 .endd
10793 If more than one port is listed, each interface that does not have its own port
10794 specified listens on all of them. Ports that are listed in
10795 \daemon@_smtp@_ports\ can be identified either by name (defined in
10796 \(/etc/services)\) or by number. However, when ports are given with individual
10797 IP addresses in \local@_interfaces\, only numbers (not names) can be used.
10798
10799
10800 .section Special IP listening addresses
10801 The addresses 0.0.0.0 and @:@:0 are treated specially. They are interpreted
10802 as `all IPv4 interfaces' and `all IPv6 interfaces', respectively. In each
10803 case, Exim tells the TCP/IP stack to `listen on all IPv\*x*\ interfaces'
10804 instead of setting up separate listening sockets for each interface. The
10805 default value of \local@_interfaces\ is
10806 .display asis
10807 local_interfaces = 0.0.0.0
10808 .endd
10809 when Exim is built without IPv6 support; otherwise it is:
10810 .display asis
10811 local_interfaces = <; ::0 ; 0.0.0.0
10812 .endd
10813 Thus, by default, Exim listens on all available interfaces, on the SMTP port.
10814
10815
10816 .section Overriding local@_interfaces and daemon@_smtp@_ports
10817 The \-oX-\ command line option can be used to override the values of
10818 \daemon@_smtp@_ports\ and/or \local@_interfaces\ for a particular daemon
10819 instance. Another way of doing this would be to use macros and the \-D-\
10820 option. However, \-oX-\ can be used by any admin user, whereas modification of
10821 the runtime configuration by \-D-\ is allowed only when the caller is root or
10822 exim.
10823
10824 The value of \-oX-\ is a list of items. The default colon separator can be
10825 changed in the usual way if required. If there are any items that do not
10826 contain dots or colons (that is, are not IP addresses), the value of
10827 \daemon@_smtp@_ports\ is replaced by the list of those items. If there are any
10828 items that do contain dots or colons, the value of \local@_interfaces\ is
10829 replaced by those items. Thus, for example,
10830 .display asis
10831 -oX 1225
10832 .endd
10833 overrides \daemon@_smtp@_ports\, but leaves \local@_interfaces\ unchanged,
10834 whereas
10835 .display asis
10836 -oX 192.168.34.5.1125
10837 .endd
10838 overrides \local@_interfaces\, leaving \daemon@_smtp@_ports\ unchanged.
10839 (However, since \local@_interfaces\ now contains no items without ports, the
10840 value of \daemon@_smtp@_ports\ is no longer relevant in this example.)
10841
10842
10843 .em
10844 .section Support for the obsolete SSMTP protocol
10845 .rset SECTsupobssmt "~~chapter.~~section"
10846 .index ssmtp protocol
10847 .index SMTP||ssmtp protocol
10848 Exim supports the obsolete SSMTP protocol that was used before the \\STARTTLS\\ 
10849 command was standardized for SMTP. Some legacy clients still use this protocol.
10850 If the \tls@_on@_connect@_ports\ option is set to a list of port numbers, 
10851 connections to those ports must use SSMTP. The most common use of this option
10852 is expected to be
10853 .display asis
10854 tls_on_connect_ports = 465
10855 .endd
10856 because 465 is the usual port number used by the legacy clients. There is also
10857 a command line option \-tls-on-connect-\, which forces all ports to behave in
10858 this way when a daemon is started.
10859
10860 \**Warning**\: Setting \tls@_on@_connect@_ports\ does not of itself cause the 
10861 daemon to listen on those ports. You must still specify them in 
10862 \daemon@_smtp@_ports\, \local@_interfaces\, or the \-oX-\ option. (This is
10863 because \tls@_on@_connect@_ports\ applies to \inetd\ connections as well as to
10864 connections via the daemon.)
10865 .nem
10866
10867
10868 .section IPv6 address scopes
10869 IPv6 addresses have `scopes', and a host with multiple hardware interfaces
10870 can, in principle, have the same link-local IPv6 address on different
10871 interfaces. Thus, additional information is needed, over and above the IP
10872 address, to distinguish individual interfaces. A convention of using a
10873 percent sign followed by something (often the interface name) has been
10874 adopted in some cases, leading to addresses like this:
10875 .display asis
10876 fe80::202:b3ff:fe03:45c1%eth0
10877 .endd
10878 To accommodate this usage, a percent sign followed by an arbitrary string is
10879 allowed at the end of an IPv6 address. By default, Exim calls \*getaddrinfo()*\
10880 to convert a textual IPv6 address for actual use. This function recognizes the
10881 percent convention in operating systems that support it, and it processes the
10882 address appropriately. Unfortunately, some older libraries have problems with
10883 \*getaddrinfo()*\. If
10884 .display asis
10885 IPV6_USE_INET_PTON=yes
10886 .endd
10887 is set in \(Local/Makefile)\ (or an OS-dependent Makefile) when Exim is built,
10888 Exim uses \*inet@_pton()*\ to convert a textual IPv6 address for actual use,
10889 instead of \*getaddrinfo()*\. (Before version 4.14, it always used this
10890 function.) Of course, this means that the additional functionality of
10891 \*getaddrinfo()*\ -- recognizing scoped addresses -- is lost.
10892
10893
10894 .section Examples of starting a listening daemon
10895 The default case in an IPv6 environment is
10896 .display asis
10897 daemon_smtp_ports = smtp
10898 local_interfaces = <; ::0 ; 0.0.0.0
10899 .endd
10900 This specifies listening on the smtp port on all IPv6 and IPv4 interfaces.
10901 Either one or two sockets may be used, depending on the characteristics of
10902 the TCP/IP stack. (This is complicated and messy; for more information,
10903 read the comments in the \(daemon.c)\ source file.)
10904
10905 To specify listening on ports 25 and 26 on all interfaces:
10906 .display asis
10907 daemon_smtp_ports = 25 : 26
10908 .endd
10909 (leaving \local@_interfaces\ at the default setting) or, more explicitly:
10910 .display asis
10911 local_interfaces = <; ::0.25     ; ::0.26 \
10912                       0.0.0.0.25 ; 0.0.0.0.26
10913 .endd
10914 To listen on the default port on all IPv4 interfaces, and on port 26 on the
10915 IPv4 loopback address only:
10916 .display asis
10917 local_interfaces = 0.0.0.0 : 127.0.0.1.26
10918 .endd
10919 To specify listening on the default port on specific interfaces only:
10920 .display asis
10921 local_interfaces = 192.168.34.67 : 192.168.34.67
10922 .endd
10923 \**Warning**\: such a setting excludes listening on the loopback interfaces.
10924
10925
10926 .section Recognising the local host
10927 .rset SECTreclocipadd "~~chapter.~~section"
10928 The \local@_interfaces\ option is also used when Exim needs to determine
10929 whether or not an IP address refers to the local host. That is, the IP
10930 addresses of all the interfaces on which a daemon is listening are always
10931 treated as local.
10932
10933 For this usage, port numbers in \local@_interfaces\ are ignored. If either of
10934 the items 0.0.0.0 or @:@:0 are encountered, Exim gets a complete list of
10935 available interfaces from the operating system, and extracts the relevant
10936 (that is, IPv4 or IPv6) addresses to use for checking.
10937
10938 Some systems set up large numbers of virtual interfaces in order to provide
10939 many virtual web servers. In this situation, you may want to listen for
10940 email on only a few of the available interfaces, but nevertheless treat all
10941 interfaces as local when routing. You can do this by setting
10942 \extra@_local@_interfaces\ to a list of IP addresses, possibly including the
10943 `all' wildcard values. These addresses are recognized as local, but are not
10944 used for listening. Consider this example:
10945 .display asis
10946 local_interfaces = <; 127.0.0.1 ; ::1 ; \
10947                       192.168.53.235 ; \
10948                       3ffe:2101:12:1:a00:20ff:fe86:a061
10949
10950 extra_local_interfaces = <; ::0 ; 0.0.0.0
10951 .endd
10952 The daemon listens on the loopback interfaces and just one IPv4 and one IPv6
10953 address, but all available interface addresses are treated as local when
10954 Exim is routing.
10955
10956 In some environments the local host name may be in an MX list, but with an IP
10957 address that is not assigned to any local interface. In other cases it may be
10958 desirable to treat other host names as if they referred to the local host. Both
10959 these cases can be handled by setting the \hosts@_treat@_as@_local\ option.
10960 This contains host names rather than IP addresses. When a host is referenced
10961 during routing, either via an MX record or directly, it is treated as the local
10962 host if its name matches \hosts@_treat@_as@_local\, or if any of its IP
10963 addresses match \local@_interfaces\ or \extra@_local@_interfaces\.
10964
10965
10966 .section Delivering to a remote host
10967 Delivery to a remote host is handled by the smtp transport. By default, it
10968 allows the system's TCP/IP functions to choose which interface to use (if
10969 there is more than one) when connecting to a remote host. However, the
10970 \interface\ option can be set to specify which interface is used. See the
10971 description of the smtp transport in chapter ~~CHAPsmtptrans for more details.
10972
10973
10974
10975
10976 .
10977 .
10978 .
10979 .
10980 . ============================================================================
10981 .chapter Main configuration
10982 .set runningfoot "main configuration"
10983 .rset CHAPmainconfig "~~chapter"
10984 .index configuration file||main section
10985 .index main configuration
10986 The first part of the run time configuration file contains three types of item:
10987 .numberpars $.
10988 Macro definitions: These lines start with an upper case letter. See section
10989 ~~SECTmacrodefs for details of macro processing.
10990 .nextp
10991 Named list definitions: These lines start with one of the words `domainlist',
10992 `hostlist', `addresslist', or `localpartlist'. Their use is described in
10993 section ~~SECTnamedlists.
10994 .nextp
10995 Main configuration settings: Each setting occupies one line of the file
10996 (with possible continuations). If any setting is preceded by the word
10997 `hide', the \-bP-\ command line option displays its value to admin users only.
10998 See section ~~SECTcos for a description of the syntax of these option settings.
10999 .endp
11000 This chapter specifies all the main configuration options, along with their
11001 types and default values. For ease of finding a particular option, they appear
11002 in alphabetical order in section ~~SECTalomo below. However, because there are
11003 now so many options, they are first listed briefly in functional groups, as an
11004 aid to finding the name of the option you are looking for. Some options are
11005 listed in more than one group.
11006
11007 .set savedisplayflowcheck ~~displayflowcheck
11008 .set displayflowcheck 0
11009
11010 .section Miscellaneous
11011 .display flow rm
11012 .tabs 31
11013 \bi@_command\                           $t$rm{to run for \-bi-\ command line option}
11014 \keep@_malformed\                       $t$rm{for broken files -- should not happen}
11015 \localhost@_number\                     $t$rm{for unique message ids in clusters}
11016 \message@_body@_visible\                $t$rm{how much to show in \$message@_body$\}
11017 .newline
11018 .em
11019 \mua@_wrapper\                          $t$rm{run in `MUA wrapper' mode}
11020 .nem
11021 .newline
11022 \print@_topbitchars\                    $t$rm{top-bit characters are printing}
11023 \timezone\                              $t$rm{force time zone}
11024 .endd
11025
11026 .section Exim parameters
11027 .display flow rm
11028 .tabs 31
11029 \exim@_group\                           $t$rm{override compiled-in value}
11030 \exim@_path\                            $t$rm{override compiled-in value}
11031 \exim@_user\                            $t$rm{override compiled-in value}
11032 \primary@_hostname\                     $t$rm{default from \*uname()*\}
11033 \split@_spool@_directory\               $t$rm{use multiple directories}
11034 \spool@_directory\                      $t$rm{override compiled-in value}
11035 .endd
11036
11037 .section Privilege controls
11038 .display flow rm
11039 .tabs 31
11040 \admin@_groups\                         $t$rm{groups that are Exim admin users}
11041 \deliver@_drop@_privilege\              $t$rm{drop root for delivery processes}
11042 \local@_from@_check\                    $t$rm{insert ::Sender:: if necessary}
11043 \local@_from@_prefix\                   $t$rm{for testing ::From:: for local sender}
11044 \local@_from@_suffix\                   $t$rm{for testing ::From:: for local sender}
11045 \local@_sender@_retain\                 $t$rm{keep ::Sender:: from untrusted user}
11046 \never@_users\                          $t$rm{do not run deliveries as these}
11047 \prod@_requires@_admin\                 $t$rm{forced delivery requires admin user}
11048 \queue@_list@_requires@_admin\          $t$rm{queue listing requires admin user}
11049 \trusted@_groups\                       $t$rm{groups that are trusted}
11050 \trusted@_users\                        $t$rm{users that are trusted}
11051 .endd
11052
11053 .section Logging
11054 .display flow rm
11055 .tabs 31
11056 .em
11057 \hosts@_connection@_nolog\              $t$rm{exemption from connect logging}
11058 .nem
11059 .newline
11060 \log@_file@_path\                       $t$rm{override compiled-in value}
11061 \log@_selector\                         $t$rm{set/unset optional logging}
11062 \log@_timezone\                         $t$rm{add timezone to log lines}
11063 \message@_logs\                         $t$rm{create per-message logs}
11064 \preserve@_message@_logs\               $t$rm{after message completion}
11065 \process@_log@_path\                    $t$rm{for SIGUSR1 and \*exiwhat*\}
11066 \syslog@_duplication\                   $t$rm{controls duplicate log lines on syslog }
11067 \syslog@_facility\                      $t$rm{set syslog `facility' field}
11068 \syslog@_processname\                   $t$rm{set syslog `ident' field}
11069 \syslog@_timestamp\                     $t$rm{timestamp syslog lines}
11070 .newline
11071 \write@_rejectlog\                      $t$rm{control use of message log}
11072 .newline
11073 .endd
11074
11075 .section Frozen messages
11076 .display flow rm
11077 .tabs 31
11078 \auto@_thaw\                            $t$rm{sets time for retrying frozen messages}
11079 \freeze@_tell\                          $t$rm{send message when freezing}
11080 \move@_frozen@_messages\                $t$rm{to another directory}
11081 \timeout@_frozen@_after\                $t$rm{keep frozen messages only so long}
11082 .endd
11083
11084 .section Data lookups
11085 .display flow rm
11086 .tabs 31
11087 \ldap@_default@_servers\                $t$rm{used if no server in query}
11088 \ldap@_version\                         $t$rm{set protocol version}
11089 \lookup@_open@_max\                     $t$rm{lookup files held open}
11090 \mysql@_servers\                        $t$rm{as it says}
11091 \oracle@_servers\                       $t$rm{as it says}
11092 \pgsql@_servers\                        $t$rm{as it says}
11093 .endd
11094
11095 .section Message ids
11096 .display flow rm
11097 .tabs 31
11098 \message@_id@_header@_domain\           $t$rm{used to build ::Message-ID:: header}
11099 \message@_id@_header@_text\             $t$rm{ditto}
11100 .endd
11101
11102 .section Embedded Perl Startup
11103 .display flow rm
11104 .tabs 31
11105 \perl@_at@_start\                       $t$rm{always start the interpreter}
11106 \perl@_startup\                         $t$rm{code to obey when starting Perl}
11107 .endd
11108
11109 .section Daemon
11110 .display flow rm
11111 .tabs 31
11112 \daemon@_smtp@_ports\                   $t$rm{default ports}
11113 \extra@_local@_interfaces\              $t$rm{not necessarily listened on}
11114 \local@_interfaces\                     $t$rm{on which to listen, with optional ports}
11115 \pid@_file@_path\                       $t$rm{override compiled-in value}
11116 \queue@_run@_max\                       $t$rm{maximum simultaneous queue runners}
11117 .endd
11118
11119 .section Resource control
11120 .display flow rm
11121 .tabs 31
11122 \check@_log@_inodes\                    $t$rm{before accepting a message}
11123 \check@_log@_space\                     $t$rm{before accepting a message}
11124 \check@_spool@_inodes\                  $t$rm{before accepting a message}
11125 \check@_spool@_space\                   $t$rm{before accepting a message}
11126 \deliver@_queue@_load@_max\             $t$rm{no queue deliveries if load high}
11127 \queue@_only@_load\                     $t$rm{queue incoming if load high}
11128 \queue@_run@_max\                       $t$rm{maximum simultaneous queue runners}
11129 \remote@_max@_parallel\                 $t$rm{parallel SMTP delivery per message}
11130 \smtp@_accept@_max\                     $t$rm{simultaneous incoming connections}
11131 \smtp@_accept@_max@_nommail\            $t$rm{non-mail commands}
11132 \smtp@_accept@_max@_nonmail@_hosts\     $t$rm{hosts to which the limit applies}
11133 \smtp@_accept@_max@_per@_connection\    $t$rm{messages per connection}
11134 \smtp@_accept@_max@_per@_host\          $t$rm{connections from one host}
11135 \smtp@_accept@_queue\                   $t$rm{queue mail if more connections}
11136 \smtp@_accept@_queue@_per@_connection\  $t$rm{queue if more messages per connection}
11137 \smtp@_accept@_reserve\                 $t$rm{only reserve hosts if more connections}
11138 \smtp@_check@_spool@_space\             $t$rm{from \\SIZE\\ on \\MAIL\\ command}
11139 \smtp@_connect@_backlog\                $t$rm{passed to TCP/IP stack}
11140 \smtp@_load@_reserve\                   $t$rm{SMTP from reserved hosts if load high}
11141 \smtp@_reserve@_hosts\                  $t$rm{these are the reserve hosts}
11142 .endd
11143
11144 .section Policy controls
11145 .display flow rm
11146 .tabs 31
11147 \acl@_not@_smtp\                        $t$rm{set ACL for non-SMTP messages}
11148 \acl@_smtp@_auth\                       $t$rm{set ACL for \\AUTH\\}
11149 \acl@_smtp@_connect\                    $t$rm{set ACL for connection}
11150 \acl@_smtp@_data\                       $t$rm{set ACL for \\DATA\\}
11151 \acl@_smtp@_etrn\                       $t$rm{set ACL for \\ETRN\\}
11152 \acl@_smtp@_expn\                       $t$rm{set ACL for \\EXPN\\}
11153 \acl@_smtp@_helo\                       $t$rm{set ACL for \\EHLO\\ or \\HELO\\}
11154 \acl@_smtp@_mail\                       $t$rm{set ACL for \\MAIL\\}
11155 \acl@_smtp@_mailauth\                   $t$rm{set ACL for \\AUTH\\ on \\MAIL\\ command}
11156 .newline
11157 .em
11158 \acl@_smtp@_mime\                       $t$rm{set ACL for MIME parts}
11159 \acl@_smtp@_predata\                    $t$rm{set ACL for start of data}
11160 \acl@_smtp@_quit\                       $t$rm{set ACL for \\QUIT\\}
11161 .nem
11162 .newline
11163 \acl@_smtp@_rcpt\                       $t$rm{set ACL for \\RCPT\\}
11164 \acl@_smtp@_starttls\                   $t$rm{set ACL for \\STARTTLS\\}
11165 \acl@_smtp@_vrfy\                       $t$rm{set ACL for \\VRFY\\}
11166 .newline
11167 .em
11168 \av@_scanner\                           $t$rm{specify virus scanner}
11169 .nem
11170 .newline
11171 \header@_maxsize\                       $t$rm{total size of message header}
11172 \header@_line@_maxsize\                 $t$rm{individual header line limit}
11173 \helo@_accept@_junk@_hosts\             $t$rm{allow syntactic junk from these hosts}
11174 \helo@_allow@_chars\                    $t$rm{allow illegal chars in \\HELO\\ names}
11175 \helo@_lookup@_domains\                 $t$rm{lookup hostname for these \\HELO\\ names}
11176 \helo@_try@_verify@_hosts\              $t$rm{\\HELO\\ soft-checked for these hosts}
11177 \helo@_verify@_hosts\                   $t$rm{\\HELO\\ hard-checked for these hosts}
11178 \host@_lookup\                          $t$rm{host name looked up for these hosts}
11179 \host@_lookup@_order\                   $t$rm{order of DNS and local name lookups}
11180 \host@_reject@_connection\              $t$rm{reject connection from these hosts}
11181 \hosts@_treat@_as@_local\               $t$rm{useful in some cluster configurations}
11182 \local@_scan@_timeout\                  $t$rm{timeout for \*local@_scan()*\}
11183 \message@_size@_limit\                  $t$rm{for all messages}
11184 \percent@_hack@_domains\                $t$rm{recognize %-hack for these domains}
11185 .newline
11186 .em
11187 \spamd@_address\                        $t$rm{set interface to SpamAssassin}
11188 .nem
11189 .newline
11190 .endd
11191
11192 .section Callout cache
11193 .display flow rm
11194 .tabs 31
11195 \callout@_domain@_negative@_expire\     $t$rm{timeout for negative domain cache item}
11196 \callout@_domain@_positive@_expire\     $t$rm{timeout for positive domain cache item}
11197 \callout@_negative@_expire\             $t$rm{timeout for negative address cache item}
11198 \callout@_positive@_expire\             $t$rm{timeout for positive address cache item}
11199 \callout@_random@_local@_part\          $t$rm{string to use for `random' testing}
11200 .endd
11201
11202 .section TLS
11203 .display flow rm
11204 .tabs 31
11205 \tls@_advertise@_hosts\                 $t$rm{advertise TLS to these hosts}
11206 \tls@_certificate\                      $t$rm{location of server certificate}
11207 \tls@_crl\                              $t$rm{certificate revocation list}
11208 \tls@_dhparam\                          $t$rm{DH parameters for server}
11209 .newline
11210 .em
11211 \tls@_on@_connect@_ports\               $t$rm{specify SSMTP ports}
11212 .nem
11213 .newline
11214 \tls@_privatekey\                       $t$rm{location of server private key}
11215 \tls@_remember@_esmtp\                  $t$rm{don't reset after starting TLS}
11216 \tls@_require@_ciphers\                 $t$rm{specify acceptable cipers}
11217 \tls@_try@_verify@_hosts\               $t$rm{try to verify client certificate}
11218 \tls@_verify@_certificates\             $t$rm{expected client certificates}
11219 \tls@_verify@_hosts\                    $t$rm{insist on client certificate verify}
11220 .endd
11221
11222 .section Local user handling
11223 .display flow rm
11224 .tabs 31
11225 \finduser@_retries\                     $t$rm{useful in NIS environments}
11226 \gecos@_name\                           $t$rm{used when creating ::Sender::}
11227 \gecos@_pattern\                        $t$rm{ditto}
11228 \max@_username@_length\                 $t$rm{for systems that truncate}
11229 \unknown@_login\                        $t$rm{used when no login name found}
11230 \unknown@_username\                     $t$rm{ditto}
11231 \uucp@_from@_pattern\                   $t$rm{for recognizing `From ' lines}
11232 \uucp@_from@_sender\                    $t$rm{ditto}
11233 .endd
11234
11235 .section All incoming messages (SMTP and non-SMTP)
11236 .display flow rm
11237 .tabs 31
11238 \header@_maxsize\                       $t$rm{total size of message header}
11239 \header@_line@_maxsize\                 $t$rm{individual header line limit}
11240 \message@_size@_limit\                  $t$rm{applies to all messages}
11241 \percent@_hack@_domains\                $t$rm{recognize %-hack for these domains}
11242 \received@_header@_text\                $t$rm{expanded to make ::Received::}
11243 \received@_headers@_max\                $t$rm{for mail loop detection}
11244 \recipients@_max\                       $t$rm{limit per message}
11245 \recipients@_max@_reject\               $t$rm{permanently reject excess}
11246 .endd
11247
11248
11249 .section Non-SMTP incoming messages
11250 .display rm
11251 .tabs 31
11252 \receive@_timeout\                      $t$rm{for non-SMTP messages}
11253 .endd
11254
11255
11256
11257 .section Incoming SMTP messages
11258 See also the \*Policy controls*\ section above.
11259 .display flow rm
11260 .tabs 31
11261 \host@_lookup\                          $t$rm{host name looked up for these hosts}
11262 \host@_lookup@_order\                   $t$rm{order of DNS and local name lookups}
11263 \recipient@_unqualified@_hosts\         $t$rm{may send unqualified recipients}
11264 \rfc1413@_hosts\                        $t$rm{make ident calls to these hosts}
11265 \rfc1413@_query@_timeout\               $t$rm{zero disables ident calls}
11266 \sender@_unqualified@_hosts\            $t$rm{may send unqualified senders}
11267 \smtp@_accept@_keepalive\               $t$rm{some TCP/IP magic}
11268 \smtp@_accept@_max\                     $t$rm{simultaneous incoming connections}
11269 \smtp@_accept@_max@_nommail\            $t$rm{non-mail commands}
11270 \smtp@_accept@_max@_nonmail@_hosts\     $t$rm{hosts to which the limit applies}
11271 \smtp@_accept@_max@_per@_connection\    $t$rm{messages per connection}
11272 \smtp@_accept@_max@_per@_host\          $t$rm{connections from one host}
11273 \smtp@_accept@_queue\                   $t$rm{queue mail if more connections}
11274 \smtp@_accept@_queue@_per@_connection\  $t$rm{queue if more messages per connection}
11275 \smtp@_accept@_reserve\                 $t$rm{only reserve hosts if more connections}
11276 .newline
11277 \smtp@_active@_hostname\                $t$rm{host name to use in messages}
11278 .newline
11279 \smtp@_banner\                          $t$rm{text for welcome banner}
11280 \smtp@_check@_spool@_space\             $t$rm{from \\SIZE\\ on \\MAIL\\ command}
11281 \smtp@_connect@_backlog\                $t$rm{passed to TCP/IP stack}
11282 \smtp@_enforce@_sync\                   $t$rm{of SMTP command/responses}
11283 \smtp@_etrn@_command\                   $t$rm{what to run for \\ETRN\\}
11284 \smtp@_etrn@_serialize\                 $t$rm{only one at once}
11285 \smtp@_load@_reserve\                   $t$rm{only reserve hosts if this load}
11286 \smtp@_max@_unknown@_commands\          $t$rm{before dropping connection}
11287 \smtp@_ratelimit@_hosts\                $t$rm{apply ratelimiting to these hosts}
11288 \smtp@_ratelimit@_mail\                 $t$rm{ratelimit for \\MAIL\\ commands}
11289 \smtp@_ratelimit@_rcpt\                 $t$rm{ratelimit for \\RCPT\\ commands}
11290 \smtp@_receive@_timeout\                $t$rm{per command or data line}
11291 \smtp@_reserve@_hosts\                  $t$rm{these are the reserve hosts}
11292 \smtp@_return@_error@_details\          $t$rm{give detail on rejections}
11293 .endd
11294
11295 .section SMTP extensions
11296 .display flow rm
11297 .tabs 31
11298 \accept@_8bitmime\                      $t$rm{advertise \\8BITMIME\\}
11299 \auth@_advertise@_hosts\                $t$rm{advertise \\AUTH\\ to these hosts}
11300 \ignore@_fromline@_hosts\               $t$rm{allow `From ' from these hosts}
11301 \ignore@_fromline@_local\               $t$rm{allow `From ' from local SMTP}
11302 \pipelining@_advertise@_hosts\          $t$rm{advertise pipelining to these hosts}
11303 \tls@_advertise@_hosts\                 $t$rm{advertise TLS to these hosts}
11304 .endd
11305
11306 .section Processing messages
11307 .display flow rm
11308 .tabs 31
11309 \allow@_domain@_literals\               $t$rm{recognize domain literal syntax}
11310 \allow@_mx@_to@_ip\                     $t$rm{allow MX to point to IP address}
11311 \allow@_utf8@_domains\                  $t$rm{in addresses}
11312 \delivery@_date@_remove\                $t$rm{from incoming messages}
11313 \envelope@_to@_remote\                  $t$rm{from incoming messages}
11314 \extract@_addresses@_remove@_arguments\ $t$rm{affects \-t-\ processing}
11315 \headers@_charset\                      $t$rm{default for translations}
11316 \qualify@_domain\                       $t$rm{default for senders}
11317 \qualify@_recipient\                    $t$rm{default for recipients}
11318 \return@_path@_remove\                  $t$rm{from incoming messages}
11319 \strip@_excess@_angle@_brackets\        $t$rm{in addresses}
11320 \strip@_trailing@_dot\                  $t$rm{at end of addresses}
11321 \untrusted@_set@_sender\                $t$rm{untrusted can set envelope sender}
11322 .endd
11323
11324 .section System filter
11325 .display flow rm
11326 .tabs 31
11327 \system@_filter\                        $t$rm{locate system filter}
11328 \system@_filter@_directory@_transport\  $t$rm{transport for delivery to a directory}
11329 \system@_filter@_file@_transport\       $t$rm{transport for delivery to a file}
11330 \system@_filter@_group\                 $t$rm{group for filter running}
11331 \system@_filter@_pipe@_transport\       $t$rm{transport for delivery to a pipe}
11332 \system@_filter@_reply@_transport\      $t$rm{transport for autoreply delivery}
11333 \system@_filter@_user\                  $t$rm{user for filter running}
11334 .endd
11335
11336 .section Routing and delivery
11337 .display flow rm
11338 .tabs 31
11339 \dns@_again@_means@_nonexist\           $t$rm{for broken domains}
11340 \dns@_check@_names@_pattern\            $t$rm{pre-DNS syntax check}
11341 \dns@_ipv4@_lookup\                     $t$rm{only v4 lookup for these domains}
11342 \dns@_retrans\                          $t$rm{parameter for resolver}
11343 \dns@_retry\                            $t$rm{parameter for resolver}
11344 \hold@_domains\                         $t$rm{hold delivery for these domains}
11345 \local@_interfaces\                     $t$rm{for routing checks}
11346 \queue@_domains\                        $t$rm{no immediate delivery for these}
11347 \queue@_only\                           $t$rm{no immediate delivery at all}
11348 \queue@_only@_file\                     $t$rm{no immediate deliveryif file exists}
11349 \queue@_only@_load\                     $t$rm{no immediate delivery if load is high}
11350 \queue@_only@_override\                 $t$rm{allow command line to override}
11351 \queue@_run@_in@_order\                 $t$rm{order of arrival}
11352 \queue@_run@_max\                       $t$rm{of simultaneous queue runners}
11353 \queue@_smtp@_domains\                  $t$rm{no immediate SMTP delivery for these}
11354 \remote@_max@_parallel\                 $t$rm{parallel SMTP delivery per message}
11355 \remote@_sort@_domains\                 $t$rm{order of remote deliveries}
11356 \retry@_data@_expire\                   $t$rm{timeout for retry data}
11357 \retry@_interval@_max\                  $t$rm{safety net for retry rules}
11358 .endd
11359
11360 .section Bounce and warning messages
11361 .display flow rm
11362 .tabs 31
11363 \bounce@_message@_file\                 $t$rm{content of bounce}
11364 \bounce@_message@_text\                 $t$rm{content of bounce}
11365 \bounce@_return@_body\                  $t$rm{include body if returning message}
11366 \bounce@_return@_message\               $t$rm{include original message in bounce}
11367 \bounce@_return@_size@_limit\           $t$rm{limit on returned message}
11368 \bounce@_sender@_authentication\        $t$rm{send authenticated sender with bounce}
11369 \errors@_copy\                          $t$rm{copy bounce messages}
11370 \errors@_reply@_to\                     $t$rm{::Reply-to:: in bounces}
11371 \delay@_warning\                        $t$rm{time schedule}
11372 \delay@_warning@_condition\             $t$rm{condition for warning messages}
11373 \ignore@_bounce@_errors@_after\         $t$rm{discard undeliverable bounces}
11374 \warn@_message@_file\                   $t$rm{content of warning message}
11375 .endd
11376
11377 .set displayflowcheck ~~savedisplayflowcheck
11378
11379 .section Alphabetical list of main options
11380 .rset SECTalomo "~~chapter.~~section"
11381 .if ~~sgcal
11382 Those options that undergo string expansion before use are marked with $**$.
11383 .fi
11384
11385 .startconf main
11386
11387 .index \\8BITMIME\\
11388 .index 8-bit characters
11389 .conf accept@_8bitmime boolean false
11390 This option causes Exim to send \\8BITMIME\\ in its response to an SMTP
11391 \\EHLO\\ command, and to accept the \\BODY=\\ parameter on \\MAIL\\ commands.
11392 However, though Exim is 8-bit clean, it is not a protocol converter, and it
11393 takes no steps to do anything special with messages received by this route.
11394 Consequently, this option is turned off by default.
11395
11396 .index ~~ACL||for non-SMTP messages
11397 .index non-SMTP messages, ACL for
11398 .conf acl@_not@_smtp string$**$ unset
11399 This option defines the ACL that is run when a non-SMTP message is on the point
11400 of being accepted. See chapter ~~CHAPACL for further details.
11401
11402 .index ~~ACL||on SMTP connection
11403 .conf acl@_smtp@_connect string$**$ unset
11404 This option defines the ACL that is run when an SMTP connection is received.
11405 See chapter ~~CHAPACL for further details.
11406
11407 .index ~~ACL||setting up for SMTP commands
11408 .index \\AUTH\\||ACL for
11409 .conf acl@_smtp@_auth string$**$ unset
11410 This option defines the ACL that is run when an SMTP \\AUTH\\ command is
11411 received. See chapter ~~CHAPACL for further details.
11412
11413 .index \\DATA\\, ACL for
11414 .conf acl@_smtp@_data string$**$ unset
11415 This option defines the ACL that is run after an SMTP \\DATA\\ command has been
11416 processed and the message itself has been received, but before the final
11417 acknowledgement is sent. See chapter ~~CHAPACL for further details.
11418
11419 .index \\ETRN\\||ACL for
11420 .conf acl@_smtp@_etrn string$**$ unset
11421 This option defines the ACL that is run when an SMTP \\ETRN\\ command is
11422 received. See chapter ~~CHAPACL for further details.
11423
11424 .index \\EXPN\\||ACL for
11425 .conf acl@_smtp@_expn string$**$ unset
11426 This option defines the ACL that is run when an SMTP \\EXPN\\ command is
11427 received. See chapter ~~CHAPACL for further details.
11428
11429 .index \\EHLO\\||ACL for
11430 .index \\HELO\\||ACL for
11431 .conf acl@_smtp@_helo string$**$ unset
11432 This option defines the ACL that is run when an SMTP \\EHLO\\ or \\HELO\\
11433 command is received. See chapter ~~CHAPACL for further details.
11434
11435 .index \\MAIL\\||ACL for
11436 .conf acl@_smtp@_mail string$**$ unset
11437 This option defines the ACL that is run when an SMTP \\MAIL\\ command is
11438 received. See chapter ~~CHAPACL for further details.
11439
11440 .index \\AUTH\\||on \\MAIL\\ command
11441 .conf acl@_smtp@_mailauth string$**$ unset
11442 This option defines the ACL that is run when there is an \\AUTH\\ parameter on
11443 a \\MAIL\\ command. See chapter ~~CHAPACL for details of ACLs, and chapter
11444 ~~CHAPSMTPAUTH for details of authentication.
11445
11446 .em
11447 .index MIME content scanning||ACL for
11448 .conf acl@_smtp@_mime string$**$ unset
11449 This option is available when Exim is built with the content-scanning 
11450 extension. It defines the ACL that is run for each MIME part in a message. See 
11451 section ~~SECTscanmimepart for details.
11452
11453 .conf acl@_smtp@_predata string$**$ unset
11454 This option defines the ACL that is run when an SMTP \\DATA\\ command is
11455 received, before the message itself is received. See chapter ~~CHAPACL for
11456 further details.
11457
11458 .index \\QUIT\\||ACL for
11459 .conf acl@_smtp@_quit string$**$ unset
11460 This option defines the ACL that is run when an SMTP \\QUIT\\ command is
11461 received. See chapter ~~CHAPACL for further details.
11462 .nem
11463
11464 .index \\RCPT\\||ACL for
11465 .conf acl@_smtp@_rcpt string$**$ unset
11466 This option defines the ACL that is run when an SMTP \\RCPT\\ command is
11467 received. See chapter ~~CHAPACL for further details.
11468
11469 .index \\STARTTLS\\, ACL for
11470 .conf acl@_smtp@_starttls string$**$ unset
11471 This option defines the ACL that is run when an SMTP \\STARTTLS\\ command is
11472 received. See chapter ~~CHAPACL for further details.
11473
11474 .index \\VRFY\\||ACL for
11475 .conf acl@_smtp@_vrfy string$**$ unset
11476 This option defines the ACL that is run when an SMTP \\VRFY\\ command is
11477 received. See chapter ~~CHAPACL for further details.
11478
11479 .conf admin@_groups "string list" unset
11480 .index admin user
11481 If the current group or any of the supplementary groups of the caller is in
11482 this colon-separated list, the caller has admin privileges. If all your system
11483 programmers are in a specific group, for example, you can give them all Exim
11484 admin privileges by putting that group in \admin@_groups\. However, this does
11485 not permit them to read Exim's spool files (whose group owner is the Exim gid).
11486 To permit this, you have to add individuals to the Exim group.
11487
11488 .conf allow@_domain@_literals boolean false
11489 .index domain literal
11490 If this option is set, the RFC 2822 domain literal format is permitted in
11491 email addresses. The option is not set by default, because the domain literal
11492 format is not normally required these days, and few people know about it. It
11493 has, however, been exploited by mail abusers.
11494
11495 Unfortunately, it seems that some DNS black list maintainers are using this
11496 format to report black listing to postmasters. If you want to accept messages
11497 addressed to your hosts by IP address, you need to set
11498 \allow@_domain@_literals\ true, and also to add \"@@[]"\ to the list of local
11499 domains (defined in the named domain list \local@_domains\ in the default
11500 configuration). This `magic string' matches the domain literal form of all the
11501 local host's IP addresses.
11502
11503 .conf allow@_mx@_to@_ip boolean false
11504 .index MX record||pointing to IP address
11505 It appears that more and more DNS zone administrators are breaking the rules
11506 and putting domain names that look like IP addresses on the right hand side of
11507 MX records. Exim follows the rules and rejects this, giving an error message
11508 that explains the mis-configuration. However, some other MTAs support this
11509 practice, so to avoid `Why can't Exim do this?' complaints, \allow@_mx@_to@_ip\
11510 exists, in order to enable this heinous activity. It is not recommended, except
11511 when you have no other choice.
11512
11513 .index domain||UTF-8 characters in
11514 .index UTF-8||in domain name
11515 .conf allow@_utf8@_domains boolean false
11516 Lots of discussion is going on about internationalized domain names. One
11517 camp is strongly in favour of just using UTF-8 characters, and it seems
11518 that at least two other MTAs permit this. This option allows Exim users to
11519 experiment if they wish.
11520
11521 If it is set true, Exim's domain parsing function allows valid
11522 UTF-8 multicharacters to appear in domain name components, in addition to
11523 letters, digits, and hyphens. However, just setting this option is not
11524 enough; if you want to look up these domain names in the DNS, you must also
11525 adjust the value of \dns@_check@_names@_pattern\ to match the extended form. A
11526 suitable setting is:
11527 .display asis
11528 dns_check_names_pattern = (?i)^(?>(?(1)\.|())[a-z0-9\xc0-\xff]\
11529   (?>[-a-z0-9\x80-\xff]*[a-z0-9\x80-\xbf])?)+$
11530 .endd
11531 Alternatively, you can just disable this feature by setting
11532 .display asis
11533 dns_check_names_pattern =
11534 .endd
11535 That is, set the option to an empty string so that no check is done.
11536
11537 .conf auth@_advertise@_hosts "host list$**$" $*$
11538 .index authentication||advertising
11539 .index \\AUTH\\||advertising
11540 If any server authentication mechanisms are configured, Exim advertises them in
11541 response to an \\EHLO\\ command only if the calling host matches this list.
11542 Otherwise, Exim does not advertise \\AUTH\\.
11543 Exim does not accept \\AUTH\\ commands from clients to which it has not
11544 advertised the availability of \\AUTH\\. The advertising of individual
11545 authentication mechanisms can be controlled by the use of the
11546 \server@_advertise@_condition\ generic authenticator option on the individual
11547 authenticators. See chapter ~~CHAPSMTPAUTH for further details.
11548
11549 Certain mail clients (for example, Netscape) require the user to provide a name
11550 and password for authentication if \\AUTH\\ is advertised, even though it may
11551 not be needed (the host may accept messages from hosts on its local LAN without
11552 authentication, for example). The \auth@_advertise@_hosts\ option can be used
11553 to make these clients more friendly by excluding them from the set of hosts to
11554 which Exim advertises \\AUTH\\.
11555
11556 .index \\AUTH\\||advertising when encrypted
11557 If you want to advertise the availability of \\AUTH\\ only when the connection
11558 is encrypted using TLS, you can make use of the fact that the value of this
11559 option is expanded, with a setting like this:
11560 .display asis
11561 auth_advertise_hosts = ${if eq{$tls_cipher}{}{}{*}}
11562 .endd
11563 If \$tls@_cipher$\ is empty, the session is not encrypted, and the result of
11564 the expansion is empty, thus matching no hosts. Otherwise, the result of the
11565 expansion is $*$, which matches all hosts.
11566
11567 .conf auto@_thaw time 0s
11568 .index thawing messages
11569 .index unfreezing messages
11570 If this option is set to a time greater than zero, a queue runner will try a
11571 new delivery attempt on any frozen message if this much time has passed since
11572 it was frozen. This may result in the message being re-frozen if nothing has
11573 changed since the last attempt. It is a way of saying `keep on trying, even
11574 though there are big problems'. See also \timeout@_frozen@_after\ and
11575 \ignore@_bounce@_errors@_after\.
11576
11577 .em
11578 .conf av@_scanner string "see below"
11579 This option is available if Exim is built with the content-scanning extension.
11580 It specifies which anti-virus scanner to use. The default value is:
11581 .display asis
11582 sophie:/var/run/sophie
11583 .endd
11584 If the value of \av@_scanner\ starts with dollar character, it is expanded
11585 before use. See section ~~SECTscanvirus for further details.
11586 .nem
11587
11588 .conf bi@_command string unset
11589 .index \-bi-\ option
11590 This option supplies the name of a command that is run when Exim is called with
11591 the \-bi-\ option (see chapter ~~CHAPcommandline). The string value is just the
11592 command name, it is not a complete command line. If an argument is required, it
11593 must come from the \-oA-\ command line option.
11594
11595 .conf bounce@_message@_file string unset
11596 .index bounce message||customizing
11597 .index customizing||bounce message
11598 This option defines a template file containing paragraphs of text to be used
11599 for constructing bounce messages.  Details of the file's contents are given in
11600 chapter ~~CHAPemsgcust. See also \warn@_message@_file\.
11601
11602 .conf bounce@_message@_text string unset
11603 When this option is set, its contents are included in the default bounce
11604 message immediately after `This message was created automatically by mail
11605 delivery software.' It is not used if \bounce@_message@_file\ is set.
11606
11607 .index bounce message||including body
11608 .conf bounce@_return@_body boolean true
11609 This option controls whether the body of an incoming message is included in a
11610 bounce message when \bounce@_return@_message\ is true. If it is not set, only
11611 the message header is included.
11612
11613 .index bounce message||including original
11614 .conf bounce@_return@_message boolean true
11615 If this option is set false, the original message is not included in bounce
11616 messages generated by Exim. See also \bounce@_return@_size@_limit\.
11617
11618 .conf bounce@_return@_size@_limit integer 100K
11619 .index size||of bounce, limit
11620 .index bounce message||size limit
11621 .index limit||bounce message size
11622 This option sets a limit in bytes on the size of messages that are returned to
11623 senders as part of bounce messages when \bounce@_return@_message\ is true. The
11624 limit should be less than the value of the global \message@_size@_limit\ and of
11625 any \message@_size@_limit\ settings on transports, to allow for the bounce text
11626 that Exim generates. If this option is set to zero there is no limit.
11627
11628 When the body of any message that is to be included in a bounce message is
11629 greater than the limit, it is truncated, and a comment pointing this out is
11630 added at the top. The actual cutoff may be greater than the value given, owing
11631 to the use of buffering for transferring the message in chunks (typically 8K in
11632 size). The idea is to save bandwidth on those undeliverable 15-megabyte
11633 messages.
11634
11635 .index bounce message||sender authentication
11636 .index authentication||bounce message
11637 .index \\AUTH\\||on bounce message
11638 .conf bounce@_sender@_authentication string unset
11639 This option provides an authenticated sender address that is sent with any
11640 bounce messages generated by Exim that are sent over an authenticated SMTP
11641 connection. A typical setting might be:
11642 .display asis
11643 bounce_sender_authentication = mailer-daemon@my.domain.example
11644 .endd
11645 which would cause bounce messages to be sent using the SMTP command:
11646 .display asis
11647 MAIL FROM:<> AUTH=mailer-daemon@my.domain.example
11648 .endd
11649 The value of \bounce@_sender@_authentication\ must always be a complete email
11650 address.
11651
11652 .index caching||callout, timeouts
11653 .index callout||caching timeouts
11654 .conf callout@_domain@_negative@_expire time 3h
11655 This option specifies the expiry time for negative callout cache data for a
11656 domain. See section ~~SECTcallver for details of callout verification, and
11657 section ~~SECTcallvercache for details of the caching.
11658
11659 .conf callout@_domain@_positive@_expire time 7d
11660 This option specifies the expiry time for positive callout cache data for a
11661 domain. See section ~~SECTcallver for details of callout verification, and
11662 section ~~SECTcallvercache for details of the caching.
11663
11664 .conf callout@_negative@_expire time 2h
11665 This option specifies the expiry time for negative callout cache data for an
11666 address. See section ~~SECTcallver for details of callout verification, and
11667 section ~~SECTcallvercache for details of the caching.
11668
11669 .conf callout@_positive@_expire time 24h
11670 This option specifies the expiry time for positive callout cache data for an
11671 address. See section ~~SECTcallver for details of callout verification, and
11672 section ~~SECTcallvercache for details of the caching.
11673
11674 .conf callout@_random@_local@_part string$**$ "see below"
11675 This option defines the `random' local part that can be used as part of callout
11676 verification. The default value is
11677 .display asis
11678 $primary_host_name-$tod_epoch-testing
11679 .endd
11680 See section ~~CALLaddparcall for details of how this value is used.
11681
11682 .conf check@_log@_inodes integer 0
11683 See \check@_spool@_space\ below.
11684
11685 .conf check@_log@_space integer 0
11686 See \check@_spool@_space\ below.
11687
11688 .conf check@_spool@_inodes integer 0
11689 See \check@_spool@_space\ below.
11690
11691 .conf check@_spool@_space integer 0
11692 .index checking disk space
11693 .index disk space, checking
11694 .index spool directory||checking space
11695 The four \check@_...\ options allow for checking of disk resources before a
11696 message is accepted. 
11697 .em
11698 When any of these options are set, they apply to all incoming messages. If you 
11699 want to apply different checks to different kinds of message, you can do so 
11700 by testing the the variables \$log@_inodes$\, \$log@_space$\, 
11701 \$spool@_inodes$\, and \$spool@_space$\ in an ACL with appropriate additional
11702 conditions.
11703 .nem
11704
11705 \check@_spool@_space\ and \check@_spool@_inodes\ check the spool partition if
11706 either value is greater than zero, for example:
11707 .display asis
11708 check_spool_space = 10M
11709 check_spool_inodes = 100
11710 .endd
11711 The spool partition is the one that contains the directory defined by
11712 \\SPOOL@_DIRECTORY\\ in \(Local/Makefile)\. It is used for holding messages in
11713 transit.
11714
11715 \check@_log@_space\ and \check@_log@_inodes\  check the partition in which log
11716 files are written if either is greater than zero. These should be set only if
11717 \log@_file@_path\ and \spool@_directory\ refer to different partitions.
11718
11719 If there is less space or fewer inodes than requested, Exim refuses to accept
11720 incoming mail. In the case of SMTP input this is done by giving a 452 temporary
11721 error response to the \\MAIL\\ command. If ESMTP is in use and there was a
11722 \\SIZE\\ parameter on the \\MAIL\\ command, its value is added to the
11723 \check@_spool@_space\ value, and the check is performed even if
11724 \check@_spool@_space\ is zero, unless \no@_smtp@_check@_spool@_space\ is set.
11725
11726 The values for \check@_spool@_space\ and \check@_log@_space\ are held as a
11727 number of kilobytes. If a non-multiple of 1024 is specified, it is rounded up.
11728
11729 For non-SMTP input and for batched SMTP input, the test is done at start-up; on
11730 failure a message is written to stderr and Exim exits with a non-zero code, as
11731 it obviously cannot send an error message of any kind.
11732
11733 .index port||for daemon
11734 .index TCP/IP||setting listening ports
11735 .conf daemon@_smtp@_ports string "$tt{smtp}"
11736 This option specifies one or more default SMTP ports on which the Exim daemon
11737 listens. See chapter ~~CHAPinterfaces for details of how it is used. For
11738 backward compatibility, \daemon@_smtp@_port\ (singular) is a synonym.
11739
11740 .conf delay@_warning "time list" 24h
11741 .index warning of delay
11742 .index delay warning, specifying
11743 When a message is delayed, Exim sends a warning message to the sender at
11744 intervals specified by this option. The data is a colon-separated list of times
11745 after which to send warning messages.
11746 .em
11747 If the value of the option is an empty string or a zero time, no warnings are
11748 sent. 
11749 .nem
11750 Up to 10 times may be given. If a message has been on the queue for longer than
11751 the last time, the last interval between the times is used to compute
11752 subsequent warning times. For example, with
11753 .display asis
11754 delay_warning = 4h:8h:24h
11755 .endd
11756 the first message is sent after 4 hours, the second after 8 hours, and
11757 the third one after 24 hours. After that, messages are sent every 16 hours,
11758 because that is the interval between the last two times on the list. If you set
11759 just one time, it specifies the repeat interval. For example, with:
11760 .display asis
11761 delay_warning = 6h
11762 .endd
11763 messages are repeated every six hours. To stop warnings after a given time, set
11764 a very large time at the end of the list. For example:
11765 .display asis
11766 delay_warning = 2h:12h:99d
11767 .endd
11768
11769 .conf delay@_warning@_condition string$**$ "see below"
11770 The string is expanded at the time a warning message might be sent. If all the
11771 deferred addresses have the same domain, it is set in \$domain$\ during the
11772 expansion. Otherwise \$domain$\ is empty. If the result of the expansion is a
11773 forced failure, an empty string, or a string matching any of `0', `no' or
11774 `false' (the comparison being done caselessly) then the warning message is not
11775 sent. The default is
11776 .display asis
11777 delay_warning_condition = \
11778   ${if match{$h_precedence:}{(?i)bulk|list|junk}{no}{yes}}
11779 .endd
11780 which suppresses the sending of warnings about messages that have `bulk',
11781 `list' or `junk' in a ::Precedence:: header.
11782
11783 .index unprivileged delivery
11784 .index delivery||unprivileged
11785 .conf deliver@_drop@_privilege boolean false
11786 If this option is set true, Exim drops its root privilege at the start of a
11787 delivery process, and runs as the Exim user throughout. This severely restricts
11788 the kinds of local delivery that are possible, but is viable in certain types
11789 of configuration. There is a discussion about the use of root privilege in
11790 chapter ~~CHAPsecurity.
11791
11792 .index load average
11793 .index queue runner||abandoning
11794 .conf deliver@_queue@_load@_max fixed-point unset
11795 When this option is set, a queue run is abandoned if the system load average
11796 becomes greater than the value of the option. The option has no effect on
11797 ancient operating systems on which Exim cannot determine the load average.
11798 See also \queue@_only@_load\ and \smtp@_load@_reserve\.
11799
11800 .conf delivery@_date@_remove boolean true
11801 .index ::Delivery-date:: header line
11802 Exim's transports have an option for adding a ::Delivery-date:: header to a
11803 message when it is delivered -- in exactly the same way as ::Return-path:: is
11804 handled. ::Delivery-date:: records the actual time of delivery. Such headers
11805 should not be present in incoming messages, and this option causes them to be
11806 removed at the time the message is received, to avoid any problems that might
11807 occur when a delivered message is subsequently sent on to some other recipient.
11808
11809 .index DNS||`try again' response, overriding
11810 .conf dns@_again@_means@_nonexist "domain list$**$" unset
11811 DNS lookups give a `try again' response for the DNS errors `non-authoritative
11812 host not found' and `\\SERVERFAIL\\'. This can cause Exim to keep trying to
11813 deliver a message, or to give repeated temporary errors to incoming mail.
11814 Sometimes the effect is caused by a badly set up name server and may persist
11815 for a long time. If a domain which exhibits this problem matches anything in
11816 \dns__again__means__nonexist\, it is treated as if it did not exist. This
11817 option should be used with care.
11818 You can make it apply to reverse lookups by a setting such as this:
11819 .display asis
11820 dns_again_means_nonexist = *.in-addr.arpa
11821 .endd
11822 .em
11823 This option applies to all DNS lookups that Exim does. The \%dnslookup%\ router 
11824 has some options of its own for controlling what happens when lookups for MX or 
11825 SRV records give temporary errors. These more specific options are applied
11826 after the global option.
11827 .nem
11828
11829 .index DNS||pre-check of name syntax
11830 .conf dns@_check@_names@_pattern string "see below"
11831 When this option is set to a non-empty string, it causes Exim to check domain
11832 names for illegal characters before handing them to the DNS resolver, because
11833 some resolvers give temporary errors for malformed names. If a domain name
11834 contains any illegal characters, a `not found' result is forced, and the
11835 resolver is not called. The check is done by matching the domain name against a
11836 regular expression, which is the value of this option. The default pattern is
11837 .display asis
11838 dns_check_names_pattern = \
11839   (?i)^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$
11840 .endd
11841 which permits only letters, digits, and hyphens in components, but they may not
11842 start or end with a hyphen.
11843 If you set \allow@_utf8@_domains\, you must modify this pattern, or set the
11844 option to an empty string.
11845
11846 .conf dns@_ipv4@_lookup "domain list$**$" unset
11847 .index IPv6||DNS lookup for AAAA records
11848 .index DNS||IPv6 lookup for AAAA records
11849 When Exim is compiled with IPv6 support, it looks for IPv6 address records
11850 (AAAA and, if configured, A6) as well as IPv4 address records when trying to
11851 find IP addresses for hosts, unless the host's domain matches this list.
11852
11853 This is a fudge to help with name servers that give big delays or otherwise do
11854 not work for the new IPv6 record types. If Exim is handed an IPv6 address
11855 record as a result of an MX lookup, it always recognizes it, and may as a
11856 result make an outgoing IPv6 connection. All this option does is to make Exim
11857 look only for IPv4-style A records when it needs to find an IP address for a
11858 host name. In due course, when the world's name servers have all been upgraded,
11859 there should be no need for this option.
11860
11861 .conf dns@_retrans time 0s
11862 .index DNS||resolver options
11863 The options \dns@_retrans\ and \dns@_retry\ can be used to set the
11864 retransmission and retry parameters for DNS lookups. Values of zero (the
11865 defaults) leave the system default settings unchanged. The first value is the
11866 time between retries, and the second is the number of retries. It isn't
11867 totally clear exactly how these settings affect the total time a DNS lookup may
11868 take. I haven't found any documentation about timeouts on DNS lookups; these
11869 parameter values are available in the external resolver interface structure,
11870 but nowhere does it seem to describe how they are used or what you might want
11871 to set in them.
11872
11873 .conf dns@_retry integer 0
11874 See \dns@_retrans\ above.
11875
11876 .conf drop@_cr boolean false
11877 This is an obsolete option that is now a no-op. It used to affect the way Exim
11878 handled CR and LF characters in incoming messages. What happens now is
11879 described in section ~~SECTlineendings.
11880
11881 .conf envelope@_to@_remove boolean true
11882 .index ::Envelope-to:: header line
11883 Exim's transports have an option for adding an ::Envelope-to:: header to a
11884 message when it is delivered -- in exactly the same way as ::Return-path:: is
11885 handled. ::Envelope-to:: records the original recipient address from the
11886 messages's envelope that caused the delivery to happen. Such headers should not
11887 be present in incoming messages, and this option causes them to be removed at
11888 the time the message is received, to avoid any problems that might occur when a
11889 delivered message is subsequently sent on to some other recipient.
11890
11891 .conf errors@_copy "string list$**$" unset
11892 .index bounce message||copy to other address
11893 .index copy of bounce message
11894 Setting this option causes Exim to send bcc copies of bounce messages that it
11895 generates to other addresses. \**Note**\: this does not apply to bounce messages
11896 coming from elsewhere. The value of the option is a colon-separated list of
11897 items. Each item consists of a pattern, terminated by white space, followed by
11898 a comma-separated list of email addresses. If a pattern contains spaces, it
11899 must be enclosed in double quotes.
11900
11901 Each pattern is processed in the same way as a single item in an address list
11902 (see section ~~SECTaddresslist). When a pattern matches the recipient of the
11903 bounce message, the message is copied to the addresses on the list. The items
11904 are scanned in order, and once a matching one is found, no further items are
11905 examined. For example:
11906 .display asis
11907 errors_copy = spqr@mydomain   postmaster@mydomain.example :\
11908               rqps@mydomain   hostmaster@mydomain.example,\
11909                               postmaster@mydomain.example
11910 .endd
11911 The address list is expanded before use. The expansion variables
11912 \$local@_part$\ and \$domain$\ are set from the original recipient of the error
11913 message, and if there was any wildcard matching in the pattern, the expansion
11914 .index numerical variables (\$1$\, \$2$\, etc)||in \errors@_copy\
11915 variables \$0$\, \$1$\, etc. are set in the normal way.
11916
11917 .conf errors@_reply@_to string unset
11918 .index bounce message||::Reply-to:: in
11919 Exim's bounce and delivery warning messages contain the header line
11920 .display
11921 From: Mail Delivery System @<Mailer-Daemon@@<<qualify-domain>>@>
11922 .endd
11923 where <<qualify-domain>> is the value of the \qualify@_domain\ option.
11924 Experience shows that people reply to bounce messages. If the
11925 \errors@_reply@_to\ option is set, a ::Reply-To:: header is added to bounce and
11926 warning messages. For example:
11927 .display asis
11928 errors_reply_to = postmaster@my.domain.example
11929 .endd
11930 The value of the option is not expanded. It must specify a valid RFC 2822
11931 address.
11932
11933 .conf exim@_group string "compile-time configured"
11934 .index gid (group id)||Exim's own
11935 .index Exim group
11936 This option changes the gid under which Exim runs when it gives up root
11937 privilege. The default value is compiled into the binary. The value of this
11938 option is used only when \exim@_user\ is also set. Unless it consists entirely
11939 of digits, the string is looked up using \*getgrnam()*\, and failure causes a
11940 configuration error. See chapter ~~CHAPsecurity for a discussion of security
11941 issues.
11942
11943 .conf exim@_path string "see below"
11944 .index Exim binary, path name
11945 This option specifies the path name of the Exim binary, which is used when Exim
11946 needs to re-exec itself. The default is set up to point to the file \*exim*\ in
11947 the directory configured at compile time by the \\BIN@_DIRECTORY\\ setting. It
11948 is necessary to change \exim@_path\ if, exceptionally, Exim is run from some
11949 other place.
11950 \**Warning**\: Do not use a macro to define the value of this option, because
11951 you will break those Exim utilities that scan the configuration file to find
11952 where the binary is. (They then use the \-bP-\ option to extract option
11953 settings such as the value of \spool@_directory\.)
11954
11955 .conf exim@_user string "compile-time configured"
11956 .index uid (user id)||Exim's own
11957 .index Exim user
11958 This option changes the uid under which Exim runs when it gives up root
11959 privilege. The default value is compiled into the binary. Ownership of the run
11960 time configuration file and the use of the \-C-\ and \-D-\ command line options
11961 is checked against the values in the binary, not what is set here.
11962
11963 Unless it consists entirely of digits, the string is looked up using
11964 \*getpwnam()*\, and failure causes a configuration error. If \exim@_group\ is
11965 not also supplied, the gid is taken from the result of \*getpwnam()*\ if it is
11966 used. See chapter ~~CHAPsecurity for a discussion of security issues.
11967
11968 .conf extra@_local@_interfaces "string list" unset
11969 .index
11970 This option defines network interfaces that are to be considered local when
11971 routing, but which are not used for listening by the daemon. See section
11972 ~~SECTreclocipadd for details.
11973
11974 .conf extract@_addresses@_remove@_arguments boolean true
11975 .index \-t-\ option
11976 .index command line||addresses with \-t-\
11977 .index Sendmail compatibility||\-t-\ option
11978 According to some Sendmail documentation (Sun, IRIX, HP-UX), if any addresses
11979 are present on the command line when the \-t-\ option is used to build an
11980 envelope from a message's ::To::, ::Cc:: and ::Bcc:: headers, the command line
11981 addresses are removed from the recipients list. This is also how Smail behaves.
11982 However, other Sendmail documentation (the O'Reilly book) states that command
11983 line addresses are added to those obtained from the header lines. When
11984 \extract__addresses__remove__arguments\ is true (the default), Exim subtracts
11985 argument headers. If it is set false, Exim adds rather than removes argument
11986 addresses.
11987
11988 .conf finduser@_retries integer 0
11989 .index NIS, looking up users, retrying
11990 On systems running NIS or other schemes in which user and group information is
11991 distributed from a remote system, there can be times when \*getpwnam()*\ and
11992 related functions fail, even when given valid data, because things time out.
11993 Unfortunately these failures cannot be distinguished from genuine `not found'
11994 errors. If \finduser@_retries\ is set greater than zero, Exim will try that
11995 many extra times to find a user or a group, waiting for one second between
11996 retries.
11997
11998 .index \(/etc/passwd)\, multiple reading of
11999 .em
12000 You should not set this option greater than zero if your user information is in 
12001 a traditional \(/etc/passwd)\ file, because it will cause Exim needlessly to
12002 search the file multiple times for non-existent users, and also cause delay.
12003 .nem
12004
12005 .conf freeze@_tell "string list, comma separated" unset
12006 .index freezing messages||sending a message when freezing
12007 On encountering certain errors, or when configured to do so in a system filter,
12008 or in an ACL,
12009 Exim freezes a message. This means that no further delivery attempts take place
12010 until an administrator (or the \auto@_thaw\ feature) thaws the message. If
12011 \freeze@_tell\ is set, Exim generates a warning message whenever it freezes
12012 something, unless the message it is freezing is a
12013 locally-generated
12014 bounce message. (Without this exception there is the possibility of looping.)
12015 The warning message is sent to the addresses supplied as the comma-separated
12016 value of this option. If several of the message's addresses cause freezing,
12017 only a single message is sent.
12018 If the freezing was automatic, the reason(s) for freezing can be found in the
12019 message log. If you configure freezing in a filter or ACL, you must arrange for
12020 any logging that you require.
12021
12022 .conf gecos@_name string$**$ unset
12023 .index HP-UX
12024 .index `gecos' field, parsing
12025 Some operating systems, notably HP-UX, use the `gecos' field in the system
12026 password file to hold other information in addition to users' real names. Exim
12027 looks up this field for use when it is creating ::Sender:: or ::From:: headers.
12028 If either \gecos@_pattern\ or \gecos@_name\ are unset, the contents of the
12029 field are used unchanged, except that, if an ampersand is encountered, it is
12030 replaced by the user's login name with the first character forced to
12031 upper case, since this is a convention that is observed on many systems.
12032
12033 When these options are set, \gecos@_pattern\ is treated as a regular expression
12034 that is to be applied to the field (again with & replaced by the login name),
12035 and if it matches, \gecos@_name\ is expanded and used as the user's name.
12036 .index numerical variables (\$1$\, \$2$\, etc)||in \gecos@_name\
12037 Numeric variables such as \$1$\, \$2$\, etc. can be used in the expansion to
12038 pick up sub-fields that were matched by the pattern. In HP-UX, where the user's
12039 name terminates at the first comma, the following can be used:
12040 .display asis
12041 gecos_pattern = ([^,]*)
12042 gecos_name = $1
12043 .endd
12044
12045 .conf gecos@_pattern string unset
12046 See \gecos@_name\ above.
12047
12048 .conf headers@_charset string "see below"
12049 This option sets a default character set for translating from encoded MIME
12050 `words' in header lines, when referenced by an \$h@_xxx$\ expansion item. The
12051 default is the value of \\HEADERS@_CHARSET\\ in \(Local/Makefile)\. The
12052 ultimate default is ISO-8859-1. For more details see the description of header
12053 insertions in section ~~SECTexpansionitems.
12054
12055
12056 .conf header@_maxsize integer "see below"
12057 .index header section||maximum size of
12058 .index limit||size of message header section
12059 This option controls the overall maximum size of a message's header
12060 section. The default is the value of \\HEADER@_MAXSIZE\\ in
12061 \(Local/Makefile)\; the default for that is 1M. Messages with larger header
12062 sections are rejected.
12063
12064 .conf header@_line@_maxsize integer 0
12065 .index header lines||maximum size of
12066 .index limit||size of one header line
12067 This option limits the length of any individual header line in a message, after
12068 all the continuations have been joined together. Messages with individual
12069 header lines that are longer than the limit are rejected. The default value of
12070 zero means `no limit'.
12071
12072
12073
12074 .conf helo@_accept@_junk@_hosts "host list$**$" unset
12075 .index \\HELO\\||accepting junk data
12076 .index \\EHLO\\||accepting junk data
12077 Exim checks the syntax of \\HELO\\ and \\EHLO\\ commands for incoming SMTP
12078 mail, and gives an error response for invalid data. Unfortunately, there are
12079 some SMTP clients that send syntactic junk. They can be accommodated by setting
12080 this option. Note that this is a syntax check only. See \helo@_verify@_hosts\
12081 if you want to do semantic checking.
12082 See also \helo@_allow@_chars\ for a way of extending the permitted character
12083 set.
12084
12085 .conf helo@_allow@_chars string unset
12086 .index \\HELO\\||underscores in
12087 .index \\EHLO\\||underscores in
12088 .index underscore in \\EHLO\\/\\HELO\\
12089 This option can be set to a string of rogue characters that are permitted in
12090 all \\EHLO\\ and \\HELO\\ names in addition to the standard letters, digits,
12091 hyphens, and dots. If you really must allow underscores, you can set
12092 .display asis
12093 helo_allow_chars = _
12094 .endd
12095 Note that the value is one string, not a list.
12096
12097 .conf helo@_lookup@_domains "domain list$**$" "$tt{@@:@@[]}"
12098 .index \\HELO\\||forcing reverse lookup
12099 .index \\EHLO\\||forcing reverse lookup
12100 If the domain given by a client in a \\HELO\\ or \\EHLO\\ command matches this
12101 list, a reverse lookup is done in order to establish the host's true name. The
12102 default forces a lookup if the client host gives the server's name or any of
12103 its IP addresses (in brackets), something that broken clients have been seen to
12104 do.
12105
12106 .conf helo@_try@_verify@_hosts "host list$**$" unset
12107 .index \\HELO\\||verifying, optional
12108 .index \\EHLO\\||verifying, optional
12109 The RFCs mandate that a server must not reject a message because it doesn't
12110 like the \\HELO\\ or \\EHLO\\ command. By default, Exim just checks the syntax
12111 of these commands (see \helo__accept__junk__hosts\ and \helo@_allow@_chars\
12112 above). However, some sites like to be stricter. If the calling host matches
12113 \helo@_try@_verify@_hosts\, Exim checks that the host name given in the \\HELO\\
12114 or \\EHLO\\ command either:
12115 .numberpars $.
12116 is an IP literal matching the calling address of the host (the RFCs
12117 specifically allow this), or
12118 .nextp
12119 .index DNS||reverse lookup
12120 .index reverse DNS lookup
12121 matches the host name that Exim obtains by doing a reverse lookup of the
12122 calling host address, or
12123 .nextp
12124 when looked up using \*gethostbyname()*\ (or \*getipnodebyname()*\ when
12125 available) yields the calling host address.
12126 .endp
12127 However, the \\EHLO\\ or \\HELO\\ command is not rejected if any of the checks
12128 fail. Processing continues, but the result of the check is remembered, and can
12129 be detected later in an ACL by the \"verify = helo"\ condition. If you want
12130 verification failure to cause rejection of \\EHLO\\ or \\HELO\\, use
12131 \helo@_verify@_hosts\ instead.
12132
12133
12134 .conf helo@_verify@_hosts "host list$**$" unset
12135 .index \\HELO\\||verifying, mandatory
12136 .index \\EHLO\\||verifying, mandatory
12137 For hosts that match this option, Exim checks the host name given in the
12138 \\HELO\\ or \\EHLO\\ in the same way as for \helo@_try@_verify@_hosts\. If the
12139 check fails, the \\HELO\\ or \\EHLO\\ command is rejected with a 550 error, and
12140 entries are written to the main and reject logs. If a \\MAIL\\ command is
12141 received before \\EHLO\\ or \\HELO\\, it is rejected with a
12142 503
12143 error.
12144
12145 .conf hold@_domains "domain list$**$" unset
12146 .index domain||delaying delivery
12147 .index delivery||delaying certain domains
12148 This option allows mail for particular domains to be held on the queue
12149 manually. The option is overridden if a message delivery is forced with the
12150 \-M-\, \-qf-\, \-Rf-\ or \-Sf-\ options, and also while testing or verifying
12151 addresses using \-bt-\ or \-bv-\. Otherwise, if a domain matches an item in
12152 \hold@_domains\, no routing or delivery for that address is done, and it is
12153 deferred every time the message is looked at.
12154
12155 This option is intended as a temporary operational measure for delaying the
12156 delivery of mail while some problem is being sorted out, or some new
12157 configuration tested. If you just want to delay the processing of some
12158 domains until a queue run occurs, you should use \queue@_domains\ or
12159 \queue@_smtp@_domains\, not \hold@_domains\.
12160
12161 A setting of \hold@_domains\ does not override Exim's code for removing
12162 messages from the queue if they have been there longer than the longest retry
12163 time in any retry rule. If you want to hold messages for longer than the normal
12164 retry times, insert a dummy retry rule with a long retry time.
12165
12166 .conf host@_lookup "host list$**$" unset
12167 .index host||name lookup, forcing
12168 Exim does not look up the name of a calling host from its IP address unless it
12169 is required to compare against some host list, or the host matches
12170 \helo@_try@_verify@_hosts\ or \helo@_verify@_hosts\, or the host matches this
12171 option (which normally contains IP addresses rather than host names). The
12172 default configuration file contains
12173 .display asis
12174 host_lookup = *
12175 .endd
12176 which causes a lookup to happen for all hosts. If the expense of these lookups
12177 is felt to be too great, the setting can be changed or removed.
12178
12179 After a successful reverse lookup, Exim does a forward lookup on the name it
12180 has obtained, to verify that it yields the IP address that it started with. If
12181 this check fails, Exim behaves as if the name lookup failed.
12182
12183 After any kind of failure, the host name (in \$sender@_host@_name$\) remains
12184 unset, and \$host@_lookup@_failed$\ is set to the string `1'. See also
12185 \dns@_again@_means@_nonexist\, \helo__lookup__domains\, and \"verify =
12186 reverse@_host@_lookup"\ in ACLs.
12187
12188 .conf host@_lookup@_order "string list" $tt{bydns:byaddr}
12189 This option specifies the order of different lookup methods when Exim is trying
12190 to find a host name from an IP address. The default is to do a DNS lookup
12191 first, and then to try a local lookup (using \*gethostbyaddr()*\ or equivalent)
12192 if that fails. You can change the order of these lookups, or omit one entirely,
12193 if you want.
12194
12195 \**Warning**\: the `byaddr' method does not always yield aliases when there are
12196 multiple PTR records in the DNS and the IP address is not listed in
12197 \(/etc/hosts)\. Different operating systems give different results in this
12198 case. That is why the default tries a DNS lookup first.
12199
12200
12201 .conf host@_reject@_connection "host list$**$" unset
12202 .index host||rejecting connections from
12203 If this option is set, incoming SMTP calls from the hosts listed are rejected
12204 as soon as the connection is made.
12205 This option is obsolete, and retained only for backward compatibility, because
12206 nowadays the ACL specified by \acl@_smtp@_connect\ can also reject incoming
12207 connections immediately.
12208
12209 The ability to give an immediate rejection (either by this option or using an
12210 ACL) is provided for use in unusual cases. Many hosts will just try again,
12211 sometimes without much delay. Normally, it is better to use an ACL to reject
12212 incoming messages at a later stage, such as after \\RCPT\\ commands. See
12213 chapter ~~CHAPACL.
12214
12215 .em
12216 .conf hosts@_connection@_nolog "host list$**$" unset
12217 .index host||not logging connections from
12218 This option defines a list of hosts for which connection logging does not
12219 happen, even though the \smtp@_connection\ log selector is set. For example,
12220 you might want not to log SMTP connections from local processes, or from
12221 127.0.0.1, or from your local LAN. This option is consulted in the main loop of
12222 the daemon; you should therefore strive to restrict its value to a short inline
12223 list of IP addresses and networks. To disable logging SMTP connections from
12224 local processes, you must create a host list with an empty item. For example:
12225 .display asis
12226 hosts_connection_nolog = :
12227 .endd
12228 If the \smtp@_connection\ log selector is not set, this option has no effect.
12229 .nem
12230
12231 .conf hosts@_treat@_as@_local "domain list$**$" unset
12232 .index local host||domains treated as
12233 .index host||treated as local
12234 If this option is set, any host names that match the domain list are treated as
12235 if they were the local host when Exim is scanning host lists obtained from MX
12236 records
12237 or other sources. Note that the value of this option is a domain list, not a
12238 host list, because it is always used to check host names, not IP addresses.
12239
12240 This option also applies when Exim is matching the special items
12241 \"@@mx@_any"\, \"@@mx@_primary"\, and \"@@mx@_secondary"\ in a domain list (see
12242 section ~~SECTdomainlist), and when checking the \hosts\ option in the \%smtp%\
12243 transport for the local host (see the \allow@_localhost\ option in that
12244 transport).
12245 See also \local@_interfaces\, \extra@_local@_interfaces\, and chapter
12246 ~~CHAPinterfaces, which contains a discussion about local network interfaces
12247 and recognising the local host.
12248
12249 .conf ignore@_bounce@_errors@_after time 10w
12250 .index bounce message||discarding
12251 .index discarding bounce message
12252 This option affects the processing of bounce messages that cannot be delivered,
12253 that is, those that suffer a permanent delivery failure. (Bounce messages that
12254 suffer temporary delivery failures are of course retried in the usual way.)
12255
12256 After a permanent delivery failure, bounce messages are frozen,
12257 because there is no sender to whom they can be returned. When a frozen bounce
12258 message has been on the queue for more than the given time, it is unfrozen at
12259 the next queue run, and a further delivery is attempted. If delivery fails
12260 again, the bounce message is discarded. This makes it possible to keep failed
12261 bounce messages around for a shorter time than the normal maximum retry time
12262 for frozen messages. For example,
12263 .display asis
12264 ignore_bounce_errors_after = 12h
12265 .endd
12266 retries failed bounce message deliveries after 12 hours, discarding any further
12267 failures. If the value of this option is set to a zero time period, bounce
12268 failures are discarded immediately. Setting a very long time (as in the default
12269 value) has the effect of disabling this option. For ways of automatically
12270 dealing with other kinds of frozen message, see \auto@_thaw\ and
12271 \timeout@_frozen@_after\.
12272
12273 .conf ignore@_fromline@_hosts "host list$**$" unset
12274 .index `From' line
12275 .index UUCP||`From' line
12276 Some broken SMTP clients insist on sending a UUCP-like `From' line before the
12277 headers of a message. By default this is treated as the start of the message's
12278 body, which means that any following headers are not recognized as such. Exim
12279 can be made to ignore it by setting \ignore@_fromline@_hosts\ to match those
12280 hosts that insist on sending it. If the sender is actually a local process
12281 rather than a remote host, and is using \-bs-\ to inject the messages,
12282 \ignore__fromline__local\ must be set to achieve this effect.
12283
12284 .conf ignore@_fromline@_local boolean false
12285 See \ignore@_fromline@_hosts\ above.
12286
12287 .conf keep@_malformed time 4d
12288 This option specifies the length of time to keep messages whose spool files
12289 have been corrupted in some way. This should, of course, never happen. At the
12290 next attempt to deliver such a message, it gets removed. The incident is
12291 logged.
12292
12293 .conf ldap@_default@_servers "string list" unset
12294 .index LDAP||default servers
12295 This option provides a list of LDAP servers which are tried in turn when an
12296 LDAP query does not contain a server. See section ~~SECTforldaque for details
12297 of LDAP queries. This option is available only when Exim has been built with
12298 LDAP support.
12299
12300 .conf ldap@_version integer unset
12301 .index LDAP||protocol version, forcing
12302 This option can be used to force Exim to set a specific protocol version for
12303 LDAP. If it option is unset, it is shown by the \-bP-\ command line option as
12304 -1. When this is the case, the default is 3 if \\LDAP@_VERSION3\\ is defined in
12305 the LDAP headers; otherwise it is 2. This option is available only when Exim
12306 has been built with LDAP support.
12307
12308
12309 .conf local@_from@_check boolean true
12310 .index ::Sender:: header line||disabling addition of
12311 .index ::From:: header line||disabling checking of
12312 When a message is submitted locally (that is, not over a TCP/IP connection) by
12313 an untrusted user, Exim removes any existing ::Sender:: header line, and checks
12314 that the ::From:: header line matches 
12315 .em
12316 the login of the calling user and the domain specified by \qualify@_domain\.
12317
12318 \**Note**\: An unqualified address (no domain) in the ::From:: header in a 
12319 locally submitted message is automatically qualified by Exim, unless the 
12320 \-bnq-\ command line option is used.
12321 .nem
12322
12323 You can use \local@_from@_prefix\ and \local@_from@_suffix\ to permit affixes
12324 on the local part. If the ::From:: header line does not match, Exim adds a
12325 ::Sender:: header with an address constructed from the calling user's login and
12326 the default qualify domain.
12327
12328 If \local@_from@_check\ is set false, the ::From:: header check is disabled,
12329 and no ::Sender:: header is ever added. If, in addition, you want to retain
12330 ::Sender:: header lines supplied by untrusted users, you must also set
12331 \local@_sender@_retain\ to be true.
12332
12333 .index envelope sender
12334 These options affect only the header lines in the message. The envelope sender
12335 is still forced to be the login id at the qualify domain unless
12336 \untrusted@_set@_sender\ permits the user to supply an envelope sender.
12337
12338 .em
12339 For messages received over TCP/IP, an ACL can specify `submission mode' to
12340 request similar header line checking. See section ~~SECTthesenhea, which has
12341 more details about ::Sender:: processing.
12342 .nem
12343
12344
12345 .conf local@_from@_prefix string unset
12346 When Exim checks the ::From:: header line of locally submitted messages for
12347 matching the login id (see \local@_from@_check\ above), it can be configured to
12348 ignore certain prefixes and suffixes in the local part of the address. This is
12349 done by setting \local@_from@_prefix\ and/or \local@_from@_suffix\ to
12350 appropriate lists, in the same form as the \local@_part@_prefix\ and
12351 \local@_part@_suffix\ router options (see chapter ~~CHAProutergeneric). For
12352 example, if
12353 .display asis
12354 local_from_prefix = *-
12355 .endd
12356 is set, a ::From:: line containing
12357 .display asis
12358 From: anything-user@your.domain.example
12359 .endd
12360 will not cause a ::Sender:: header to be added if \*user@@your.domain.example*\
12361 matches the actual sender address that is constructed from the login name and
12362 qualify domain.
12363
12364 .conf local@_from@_suffix string unset
12365 See \local@_from@_prefix\ above.
12366
12367 .conf local@_interfaces "string list" "see below"
12368 This option controls which network interfaces are used by the daemon for
12369 listening; they are also used to identify the local host when routing. Chapter
12370 ~~CHAPinterfaces contains a full description of this option and the related
12371 options 
12372 .em
12373 \daemon@_smtp@_ports\, \extra@_local@_interfaces\, \hosts@_treat@_as@_local\,
12374 and \tls@_on@_connect@_ports\. 
12375 .nem
12376 The default value for \local@_interfaces\ is
12377 .display asis
12378 local_interfaces = 0.0.0.0
12379 .endd
12380 when Exim is built without IPv6 support; otherwise it is
12381 .display asis
12382 local_interfaces = <; ::0 ; 0.0.0.0
12383 .endd
12384
12385 .conf local@_scan@_timeout time 5m
12386 .index timeout||for \*local@_scan()*\ function
12387 .index \*local@_scan()*\ function||timeout
12388 This timeout applies to the \*local@_scan()*\ function (see chapter
12389 ~~CHAPlocalscan). Zero means `no timeout'. If the timeout is exceeded, the
12390 incoming message is rejected with a temporary error if it is an SMTP message.
12391 For a non-SMTP message, the message is dropped and Exim ends with a non-zero
12392 code. The incident is logged on the main and reject logs.
12393
12394
12395 .conf local@_sender@_retain boolean false
12396 .index ::Sender:: header line||retaining from local submission
12397 When a message is submitted locally (that is, not over a TCP/IP connection) by
12398 an untrusted user, Exim removes any existing ::Sender:: header line. If you
12399 do not want this to happen, you must set \local@_sender@_retain\, and you must
12400 also set \local@_from@_check\ to be false (Exim will complain if you do not).
12401 Section ~~SECTthesenhea has more details about ::Sender:: processing.
12402
12403
12404
12405 .conf localhost@_number string$**$ unset
12406 .index host||locally unique number for
12407 .index message||ids, with multiple hosts
12408 Exim's message ids are normally unique only within the local host. If
12409 uniqueness among a set of hosts is required, each host must set a different
12410 value for the \localhost@_number\ option. The string is expanded immediately
12411 after reading the configuration file (so that a number can be computed from the
12412 host name, for example) and the result of the expansion must be a number in the
12413 range 0--16 (or 0--10 on operating systems with case-insensitive file systems).
12414 This is available in subsequent string expansions via the variable
12415 \$localhost@_number$\. When \localhost@_number is set\, the final two
12416 characters of the message id, instead of just being a fractional part of the
12417 time, are computed from the time and the local host number as described in
12418 section ~~SECTmessiden.
12419
12420
12421 .conf log@_file@_path "string list$**$" "set at compile time"
12422 .index log||file path for
12423 This option sets the path which is used to determine the names of Exim's log
12424 files, or indicates that logging is to be to syslog, or both. It is expanded
12425 when Exim is entered, so it can, for example, contain a reference to the host
12426 name. If no specific path is set for the log files at compile or run time, they
12427 are written in a sub-directory called \(log)\ in Exim's spool directory.
12428 Chapter ~~CHAPlog contains further details about Exim's logging, and section
12429 ~~SECTwhelogwri describes how the contents of \log@_file@_path\ are used. If
12430 this string is fixed at your installation (contains no expansion variables) it
12431 is recommended that you do not set this option in the configuration file, but
12432 instead supply the path using \\LOG@_FILE@_PATH\\ in \(Local/Makefile)\ so that
12433 it is available to Exim for logging errors detected early on -- in particular,
12434 failure to read the configuration file.
12435
12436 .conf log@_selector string unset
12437 .index log||selectors
12438 This option can be used to reduce or increase the number of things that Exim
12439 writes to its log files. Its argument is made up of names preceded by plus or
12440 minus characters. For example:
12441 .display asis
12442 log_selector = +arguments -retry_defer
12443 .endd
12444 A list of possible names and what they control is given in the chapter on
12445 logging, in section ~~SECTlogselector.
12446
12447 .conf log@_timezone boolean false
12448 .index log||timezone for entries
12449 By default, the timestamps on log lines are in local time without the
12450 timezone. This means that if your timezone changes twice a year, the timestamps
12451 in log lines are ambiguous for an hour when the clocks go back. One way of
12452 avoiding this problem is to set the timezone to UTC. An alternative is to set
12453 \log@_timezone\ true. This turns on the addition of the timezone offset to
12454 timestamps in log lines. Turning on this option can add quite a lot to the size
12455 of log files because each line is extended by 6 characters. Note that the
12456 \$tod@_log$\ variable contains the log timestamp without the zone, but there is
12457 another variable called \$tod@_zone$\ that contains just the timezone offset.
12458
12459 .conf lookup@_open@_max integer 25
12460 .index too many open files
12461 .index open files, too many
12462 .index file||too many open
12463 .index lookup||maximum open files
12464 .index limit||open files for lookups
12465 This option limits the number of simultaneously open files for single-key
12466 lookups that use regular files (that is, \%lsearch%\, \%dbm%\, and \%cdb%\). Exim
12467 normally keeps these files open during routing, because often the same file is
12468 required several times. If the limit is reached, Exim closes the least recently
12469 used file. Note that if you are using the \*ndbm*\ library, it actually opens
12470 two files for each logical DBM database, though it still counts as one for the
12471 purposes of \lookup@_open@_max\. If you are getting `too many open files'
12472 errors with NDBM, you need to reduce the value of \lookup@_open@_max\.
12473
12474 .conf max@_username@_length integer 0
12475 .index length of login name
12476 .index user name||maximum length
12477 .index limit||user name length
12478 Some operating systems are broken in that they truncate long arguments to
12479 \*getpwnam()*\ to eight characters, instead of returning `no such user'. If
12480 this option is set greater than zero, any attempt to call \*getpwnam()*\ with
12481 an argument that is longer behaves as if \*getpwnam()*\ failed.
12482
12483
12484 .conf message@_body@_visible integer 500
12485 .index body of message||visible size
12486 .index message||body, visible size
12487 This option specifies how much of a message's body is to be included in the
12488 \$message@_body$\ and \$message@_body@_end$\ expansion variables.
12489
12490 .conf message@_id@_header@_domain string$**$ unset
12491 .index ::Message-ID:: header line
12492 If this option is set, the string is expanded and used as the right hand side
12493 (domain) of the ::Message-ID:: header that Exim creates if a
12494 locally-originated incoming message does not have one. `Locally-originated'
12495 means `not received over TCP/IP.'
12496 Otherwise, the primary host name is used.
12497 Only letters, digits, dot and hyphen are accepted; any other characters are
12498 replaced by hyphens. If the expansion is forced to fail, or if the result is an
12499 empty string, the option is ignored.
12500
12501 .conf message@_id@_header@_text string$**$ unset
12502 If this variable is set, the string is expanded and used to augment the text of
12503 the ::Message-id:: header that Exim creates if a
12504 locally-originated
12505 incoming message does not have one. The text of this header is required by RFC
12506 2822 to take the form of an address. By default, Exim uses its internal message
12507 id as the local part, and the primary host name as the domain. If this option
12508 is set, it is expanded, and provided the expansion is not forced to fail, and
12509 does not yield an empty string, the result is inserted into the header
12510 immediately before the @@, separated from the internal message id by a dot. Any
12511 characters that are illegal in an address are automatically converted into
12512 hyphens. This means that variables such as \$tod@_log$\ can be used, because
12513 the spaces and colons will become hyphens.
12514
12515 .conf message@_logs boolean true
12516 .index message||log, disabling
12517 .index log||message log, disabling
12518 If this option is turned off, per-message log files are not created in the
12519 \(msglog)\ spool sub-directory. This reduces the amount of disk I/O required by
12520 Exim, by reducing the number of files involved in handling a message from a
12521 minimum of four (header spool file, body spool file, delivery journal, and
12522 per-message log) to three. The other major I/O activity is Exim's main log,
12523 which is not affected by this option.
12524
12525 .conf message@_size@_limit string$**$ 50M
12526 .index message||size limit
12527 .index limit||message size
12528 .index size||of message, limit
12529 This option limits the maximum size of message that Exim will process. The
12530 value is expanded for each incoming
12531 connection so, for example, it can be made to depend on the IP address of the
12532 remote host for messages arriving via TCP/IP. \**Note**\: This limit cannot be
12533 made to depend on a message's sender or any other properties of an individual
12534 message, because it has to be advertised in the server's response to \\EHLO\\.
12535 String expansion failure causes a temporary error. A value of zero means no
12536 limit, but its use is not recommended. See also \bounce@_return@_size@_limit\.
12537
12538 Incoming SMTP messages are failed with a 552 error if the limit is
12539 exceeded; locally-generated messages either get a stderr message or a delivery
12540 failure message to the sender, depending on the \-oe-\ setting. Rejection of an
12541 oversized message is logged in both the main and the reject logs. See also the
12542 generic transport option \message@_size@_limit\, which limits the size of
12543 message that an individual transport can process.
12544
12545 .conf move@_frozen@_messages boolean false
12546 .index frozen messages||moving
12547 This option, which is available only if Exim has been built with the setting
12548 .display asis
12549 SUPPORT_MOVE_FROZEN_MESSAGES=yes
12550 .endd
12551 in \(Local/Makefile)\, causes frozen messages and their message logs to be
12552 moved from the \(input)\ and \(msglog)\ directories on the spool to \(Finput)\
12553 and \(Fmsglog)\, respectively. There is currently no support in Exim or the
12554 standard utilities for handling such moved messages, and they do not show up in
12555 lists generated by \-bp-\ or by the Exim monitor.
12556
12557 .em
12558 .conf mua@_wrapper boolean false
12559 Setting this option true causes Exim to run in a very restrictive mode in which
12560 it passes messages synchronously to a smart host. Chapter ~~CHAPnonqueueing
12561 contains a full description of this facility.
12562 .nem
12563
12564 .conf mysql@_servers "string list" unset
12565 .index MySQL||server list
12566 This option provides a list of MySQL servers and associated connection data, to
12567 be used in conjunction with \%mysql%\ lookups (see section ~~SECTsql). The
12568 option is available only if Exim has been built with MySQL support.
12569
12570 .conf never@_users "string list" unset
12571 Local message deliveries are normally run in processes that are setuid to the
12572 recipient, and remote deliveries are normally run under Exim's own uid and gid.
12573 It is usually desirable to prevent any deliveries from running as root, as a
12574 safety precaution.
12575
12576 When Exim is built, an option called \\FIXED@_NEVER@_USERS\\ can be set to a
12577 list of users that must not be used for local deliveries. This list is fixed in
12578 the binary and cannot be overridden by the configuration file. By default, it
12579 contains just the single user name `root'. The \never@_users\ runtime option
12580 can be used to add more users to the fixed list.
12581
12582 If a message is to be delivered as one of the users on the fixed list or the
12583 \never@_users\ list, an error occurs, and delivery is deferred. A common
12584 example is
12585 .display
12586 never@_users = root:daemon:bin
12587 .endd
12588 Including root is redundant if it is also on the fixed list, but it does no
12589 harm.
12590 This option overrides the \pipe@_as@_creator\ option of the \%pipe%\ transport
12591 driver.
12592
12593 .conf oracle@_servers "string list" unset
12594 .index Oracle||server list
12595 This option provides a list of Oracle servers and associated connection data,
12596 to be used in conjunction with \%oracle%\ lookups (see section ~~SECTsql). The
12597 option is available only if Exim has been built with Oracle support.
12598
12599 .conf percent@_hack@_domains "domain list$**$" unset
12600 .index `percent hack'
12601 .index source routing||in email address
12602 .index address||source-routed
12603 The `percent hack' is the convention whereby a local part containing a percent
12604 sign is re-interpreted as a new email address, with the percent replaced by @@.
12605 This is sometimes called `source routing', though that term is also applied to
12606 RFC 2822 addresses that begin with an @@ character. If this option is set, Exim
12607 implements the percent facility for those domains listed, but no others. This
12608 happens before an incoming SMTP address is tested against an ACL.
12609
12610 \**Warning**\: The `percent hack' has often been abused by people who are
12611 trying to get round relaying restrictions. For this reason, it is best avoided
12612 if at all possible. Unfortunately, a number of less security-conscious MTAs
12613 implement it unconditionally. If you are running Exim on a gateway host, and
12614 routing mail through to internal MTAs without processing the local parts, it is
12615 a good idea to reject recipient addresses with percent characters in their
12616 local parts. Exim's default configuration does this.
12617
12618 .conf perl@_at@_start boolean false
12619 This option is available only when Exim is built with an embedded Perl
12620 interpreter. See chapter ~~CHAPperl for details of its use.
12621
12622 .conf perl@_startup string unset
12623 This option is available only when Exim is built with an embedded Perl
12624 interpreter. See chapter ~~CHAPperl for details of its use.
12625
12626 .conf pgsql@_servers "string list" unset
12627 .index PostgreSQL lookup type||server list
12628 This option provides a list of PostgreSQL servers and associated connection
12629 data, to be used in conjunction with \%pgsql%\ lookups (see section ~~SECTsql).
12630 The option is available only if Exim has been built with PostgreSQL support.
12631
12632 .conf pid@_file@_path string$**$ "set at compile time"
12633 .index daemon||pid file path
12634 .index pid file, path for
12635 This option sets the name of the file to which the Exim daemon writes its
12636 process id. The string is expanded, so it can contain, for example, references
12637 to the host name:
12638 .display asis
12639 pid_file_path = /var/log/$primary_hostname/exim.pid
12640 .endd
12641 If no path is set, the pid is written to the file \(exim-daemon.pid)\ in Exim's
12642 spool directory.
12643 The value set by the option can be overridden by the \-oP-\ command line
12644 option. A pid file is not written if a `non-standard' daemon is run by means of
12645 the \-oX-\ option, unless a path is explicitly supplied by \-oP-\.
12646
12647 .conf pipelining@_advertise@_hosts "host list$**$" $*$
12648 .index \\PIPELINING\\||advertising, suppressing
12649 This option can be used to suppress the advertisement of the SMTP
12650 \\PIPELINING\\ extension to specific hosts. When \\PIPELINING\\ is not
12651 advertised and \smtp@_enforce@_sync\ is true, an Exim server enforces strict
12652 synchronization for each SMTP command and response.
12653 When \\PIPELINING\\ is advertised, Exim assumes that clients will use it; `out
12654 of order' commands that are `expected' do not count as protocol errors (see
12655 \smtp@_max@_synprot@_errors\).
12656
12657 .conf preserve@_message@_logs boolean false
12658 .index message logs, preserving
12659 If this option is set, message log files are not deleted when messages are
12660 completed. Instead, they are moved to a sub-directory of the spool directory
12661 called \(msglog.OLD)\, where they remain available for statistical or debugging
12662 purposes. This is a dangerous option to set on systems with any appreciable
12663 volume of mail. Use with care!
12664
12665 .conf primary@_hostname string "see below"
12666 .index name||of local host
12667 .index host||name of local
12668 .index local host||name of
12669 This specifies the name of the current host. It is used in the default \\EHLO\\
12670 or \\HELO\\ command for outgoing SMTP messages (changeable via the \helo@_data\
12671 option in the \%smtp%\ transport),
12672 and as the default for \qualify@_domain\. If it is not set, Exim calls
12673 \*uname()*\ to find it. If this fails, Exim panics and dies. If the name
12674 returned by \*uname()*\ contains only one component, Exim passes it to
12675 \*gethostbyname()*\ (or \*getipnodebyname()*\ when available) in order to
12676 obtain the fully qualified version.
12677
12678 The value of \$primary@_hostname$\ is also used by default in some SMTP
12679 response messages from an Exim server. This can be changed dynamically by
12680 setting \smtp@_active@_hostname\.
12681
12682 .conf print@_topbitchars boolean false
12683 .index printing characters
12684 .index 8-bit characters
12685 By default, Exim considers only those characters whose codes lie in the range
12686 32--126 to be printing characters. In a number of circumstances (for example,
12687 when writing log entries) non-printing characters are converted into escape
12688 sequences, primarily to avoid messing up the layout. If \print@_topbitchars\ is
12689 set, code values of 128 and above are also considered to be printing
12690 characters.
12691
12692 .conf process@_log@_path string unset
12693 .index process log path
12694 .index log||process log
12695 .index \*exiwhat*\
12696 This option sets the name of the file to which an Exim process writes its
12697 `process log' when sent a USR1 signal. This is used by the \*exiwhat*\ utility
12698 script. If this option is unset, the file called \(exim-process.info)\ in
12699 Exim's spool directory is used. The ability to specify the name explicitly can
12700 be useful in environments where two different Exims are running, using
12701 different spool directories.
12702
12703 .conf prod@_requires@_admin boolean true
12704 .index \-M-\ option
12705 .index \-R-\ option
12706 .index \-q-\ option
12707 The \-M-\, \-R-\, and \-q-\ command-line options require the caller to be an
12708 admin user unless \prod@_requires@_admin\ is set false. See also
12709 \queue@_list@_requires@_admin\.
12710
12711 .conf qualify@_domain string "see below"
12712 .index domain||for qualifying addresses
12713 .index address||qualification
12714 This option specifies the domain name that is added to any envelope sender
12715 addresses that do not have a domain qualification. It also applies to
12716 recipient addresses if \qualify@_recipient\ is not set. 
12717 .em
12718 Unqualified addresses are accepted by default only for locally-generated
12719 messages.
12720
12721 Qualification is also applied to addresses in header lines such as ::From:: and 
12722 ::To:: for locally-generated messages, unless the \-bnq-\ command line option 
12723 is used.
12724 .nem
12725
12726 Messages from external sources must always contain fully qualified addresses,
12727 unless the sending host matches \sender@_unqualified@_hosts\ or
12728 \recipient@_unqualified@_hosts\ (as appropriate), in which case incoming
12729 addresses are qualified with \qualify@_domain\ or \qualify@_recipient\ as
12730 necessary. Internally, Exim always works with fully qualified envelope
12731 addresses. If \qualify@_domain\ is not set, it defaults to the
12732 \primary@_hostname\ value.
12733
12734 .conf qualify@_recipient string "see below"
12735 .em
12736 This option allows you to specify a different domain for qualifying recipient
12737 addresses to the one that is used for senders. See \qualify@_domain\ above.
12738 .nem
12739
12740 .conf queue@_domains "domain list$**$" unset
12741 .index domain||specifying non-immediate delivery
12742 .index queueing incoming messages
12743 .index message||queueing certain domains
12744 This option lists domains for which immediate delivery is not required.
12745 A delivery process is started whenever a message is received, but only those
12746 domains that do not match are processed. All other deliveries wait until the
12747 next queue run. See also \hold@_domains\ and \queue@_smtp@_domains\.
12748
12749 .conf queue@_list@_requires@_admin boolean true
12750 .index \-bp-\ option
12751 The \-bp-\ command-line option, which lists the messages that are on the queue,
12752 requires the caller to be an admin user unless \queue__list__requires__admin\
12753 is set false. See also \prod@_requires@_admin\.
12754
12755 .conf queue@_only boolean false
12756 .index queueing incoming messages
12757 .index message||queueing unconditionally
12758 If \queue@_only\ is set, a delivery process is not automatically started
12759 whenever a message is received. Instead, the message waits on the queue for the
12760 next queue run. Even if \queue@_only\ is false, incoming messages may not get
12761 delivered immediately when certain conditions (such as heavy load) occur.
12762
12763 The \-odq-\ command line has the same effect as \queue@_only\. The \-odb-\ and
12764 \-odi-\ command line options override \queue@_only\ unless
12765 \queue@_only@_override\ is set false. See also \queue@_only@_file\,
12766 \queue@_only@_load\, and \smtp@_accept@_queue\.
12767
12768 .conf queue@_only@_file string unset
12769 .index queueing incoming messages
12770 .index message||queueing by file existence
12771 This option can be set to a colon-separated list of absolute path names, each
12772 one optionally preceded by `smtp'. When Exim is receiving a message,
12773 it tests for the existence of each listed path using a call to \*stat()*\. For
12774 each path that exists, the corresponding queuing option is set.
12775 For paths with no prefix, \queue@_only\ is set; for paths prefixed by `smtp',
12776 \queue@_smtp@_domains\ is set to match all domains. So, for example,
12777 .display asis
12778 queue_only_file = smtp/some/file
12779 .endd
12780 causes Exim to behave as if \queue@_smtp@_domains\ were set to `$*$' whenever
12781 \(/some/file)\ exists.
12782
12783 .conf queue@_only@_load fixed-point unset
12784 .index load average
12785 .index queueing incoming messages
12786 .index message||queueing by load
12787 If the system load average is higher than this value, incoming messages from
12788 all sources are queued, and no automatic deliveries are started. If this
12789 happens during local or remote SMTP input, all subsequent messages on the same
12790 connection are queued. Deliveries will subsequently be performed by queue
12791 runner processes. This option has no effect on ancient operating systems on
12792 which Exim cannot determine the load average. See also
12793 \deliver@_queue@_load@_max\ and \smtp@_load@_reserve\.
12794
12795 .conf queue@_only@_override boolean true
12796 .index queueing incoming messages
12797 When this option is true, the \-od\*x*\-\ command line options override the
12798 setting of \queue@_only\ or \queue@_only@_file\ in the configuration file. If
12799 \queue@_only@_override\ is set false, the \-od\*x*\-\ options cannot be used to
12800 override; they are accepted, but ignored.
12801
12802 .conf queue@_run@_in@_order boolean false
12803 .index queue runner||processing messages in order
12804 If this option is set, queue runs happen in order of message arrival instead of
12805 in an arbitrary order. For this to happen, a complete list of the entire queue
12806 must be set up before the deliveries start. When the queue is all in a single
12807 directory (the default), this happens anyway, but if \split@_spool@_directory\
12808 is set it does not -- for delivery in random order, the sub-directories are
12809 processed one at a time (in random order), to avoid setting up one huge list.
12810 Thus, setting \queue@_run@_in@_order\ with \split@_spool@_directory\ may
12811 degrade performance when the queue is large. In most situations,
12812 \queue@_run@_in@_order\ should not be set.
12813
12814 .conf queue@_run@_max integer 5
12815 .index queue runner||maximum number of
12816 This controls the maximum number of queue runner processes that an Exim daemon
12817 can run simultaneously. This does not mean that it starts them all at once,
12818 but rather that if the maximum number are still running when the time comes to
12819 start another one, it refrains from starting another one. This can happen with
12820 very large queues and/or very sluggish deliveries. This option does not,
12821 however, interlock with other processes, so additional queue runners can be
12822 started by other means, or by killing and restarting the daemon.
12823
12824 .conf queue@_smtp@_domains "domain list$**$" unset
12825 .index queueing incoming messages
12826 .index message||queueing remote deliveries
12827 When this option is set, a delivery process is started whenever a message is
12828 received, routing is performed, and local deliveries take place.
12829 However, if any SMTP deliveries are required for domains that match
12830 \queue@_smtp@_domains\, they are not immediately delivered, but instead the
12831 message waits on the queue for the next queue run. Since routing of the message
12832 has taken place, Exim knows to which remote hosts it must be delivered, and so
12833 when the queue run happens, multiple messages for the same host are delivered
12834 over a single SMTP connection. The \-odqs-\ command line option causes all SMTP
12835 deliveries to be queued in this way, and is equivalent to setting
12836 \queue@_smtp@_domains\ to `$*$'. See also \hold@_domains\ and \queue@_domains\.
12837
12838 .conf receive@_timeout time 0s
12839 .index timeout||for non-SMTP input
12840 This option sets the timeout for accepting a non-SMTP message, that is, the
12841 maximum time that Exim waits when reading a message on the standard input. If
12842 the value is zero, it will wait for ever. This setting is overridden by the
12843 \-or-\ command line option. The timeout for incoming SMTP messages is
12844 controlled by \smtp@_receive@_timeout\.
12845
12846 .index customizing|| ::Received:: header
12847 .index ::Received:: header line||customizing
12848 .conf received@_header@_text string$**$ "see below"
12849 This string defines the contents of the ::Received:: message header that is
12850 added to each message, except for the timestamp, which is automatically added
12851 on at the end (preceded by a semicolon). The string is expanded each time it is
12852 used. If the expansion yields an empty string, no ::Received:: header line is
12853 added to the message. Otherwise, the string should start with the text
12854 `Received:' and conform to the RFC 2822 specification for ::Received:: header
12855 lines. The default setting is:
12856 .display asis
12857 received_header_text = Received: \
12858     ${if def:sender_rcvhost {from $sender_rcvhost\n\t}\
12859     {${if def:sender_ident {from $sender_ident }}\
12860     ${if def:sender_helo_name {(helo=$sender_helo_name)\n\t}}}}\
12861     by $primary_hostname \
12862     ${if def:received_protocol {with $received_protocol}} \
12863     ${if def:tls_cipher {($tls_cipher)\n\t}}\
12864     (Exim $version_number)\n\t\
12865     id $message_id\
12866     ${if def:received_for {\n\tfor $received_for}}
12867 .endd
12868 Note the use of quotes, to allow the sequences \"@\n"\ and \"@\t"\ to be used
12869 for newlines and tabs, respectively. The reference to the TLS cipher is omitted
12870 when Exim is built without TLS support. The use of conditional expansions
12871 ensures that this works for both locally generated messages and messages
12872 received from remote hosts, giving header lines such as the following:
12873 .display asis
12874 Received: from scrooge.carol.example ([192.168.12.25] ident=root)
12875         by marley.carol.example with esmtp (Exim 4.00)
12876         id 16IOWa-00019l-00
12877         for chas@dickens.example; Tue, 25 Dec 2001 14:43:44 +0000
12878 Received: by scrooge.carol.example with local (Exim 4.00)
12879         id 16IOWW-000083-00; Tue, 25 Dec 2001 14:43:41 +0000
12880 .endd
12881 Until the body of the message has been received, the timestamp is the time when
12882 the message started to be received. Once the body has arrived, and all policy
12883 checks have taken place, the timestamp is updated to the time at which the
12884 message was accepted.
12885
12886 .conf received@_headers@_max integer 30
12887 .index loop||prevention
12888 .index mail loop prevention
12889 .index ::Received:: header line||counting
12890 When a message is to be delivered, the number of ::Received:: headers is
12891 counted, and if it is greater than this parameter, a mail loop is assumed to
12892 have occurred, the delivery is abandoned, and an error message is generated.
12893 This applies to both local and remote deliveries.
12894
12895 .conf recipient@_unqualified@_hosts "host list$**$" unset
12896 .index unqualified addresses
12897 .index host||unqualified addresses from
12898 This option lists those hosts from which Exim is prepared to accept unqualified
12899 recipient addresses in message envelopes. The addresses are made fully
12900 qualified by the addition of the \qualify@_recipient\ value. This option also
12901 affects message header lines. Exim does not reject unqualified recipient
12902 addresses in headers, but it qualifies them only if the message came from a
12903 host that matches \recipient@_unqualified@_hosts\,
12904 or if the message was submitted locally (not using TCP/IP), and the \-bnq-\
12905 option was not set.
12906
12907 .conf recipients@_max integer 0
12908 .index limit||number of recipients
12909 .index recipient||maximum number
12910 If this option is set greater than zero, it specifies the maximum number of
12911 original recipients for any message. Additional recipients that are generated
12912 by aliasing or forwarding do not count. SMTP messages get a 452 response for
12913 all recipients over the limit; earlier recipients are delivered as normal.
12914 Non-SMTP messages with too many recipients are failed, and no deliveries are
12915 done.
12916 .index \\RCPT\\||maximum number of incoming
12917 Note that the RFCs specify that an SMTP server should accept at least 100
12918 \\RCPT\\ commands in a single message.
12919
12920 .conf recipients@_max@_reject boolean false
12921 If this option is set true, Exim rejects SMTP messages containing too many
12922 recipients by giving 552 errors to the surplus \\RCPT\\ commands, and a 554
12923 error to the eventual \\DATA\\ command. Otherwise (the default) it gives a 452
12924 error to the surplus \\RCPT\\ commands and accepts the message on behalf of the
12925 initial set of recipients. The remote server should then re-send the message
12926 for the remaining recipients at a later time.
12927
12928 .conf remote@_max@_parallel integer 2
12929 .index delivery||parallelism for remote
12930 This option controls parallel delivery of one message to a number of remote
12931 hosts. If the value is less than 2, parallel delivery is disabled, and Exim
12932 does all the remote deliveries for a message one by one. Otherwise, if a single
12933 message has to be delivered to more than one remote host, or if several copies
12934 have to be sent to the same remote host, up to \remote@_max@_parallel\
12935 deliveries are done simultaneously. If more than \remote@_max@_parallel\
12936 deliveries are required, the maximum number of processes are started, and as
12937 each one finishes, another is begun. The order of starting processes is the
12938 same as if sequential delivery were being done, and can be controlled by the
12939 \remote@_sort@_domains\ option. If parallel delivery takes place while running
12940 with debugging turned on, the debugging output from each delivery process is
12941 tagged with its process id.
12942
12943 This option controls only the maximum number of parallel deliveries for one
12944 message in one Exim delivery process. Because Exim has no central queue
12945 manager, there is no way of controlling the total number of simultaneous
12946 deliveries if the configuration allows a delivery attempt as soon as a message
12947 is received.
12948 .index number of deliveries
12949 .index delivery||maximum number of
12950 If you want to control the total number of deliveries on the system, you
12951 need to set the \queue@_only\ option. This ensures that all incoming messages
12952 are added to the queue without starting a delivery process. Then set up an Exim
12953 daemon to start queue runner processes at appropriate intervals (probably
12954 fairly often, for example, every minute), and limit the total number of queue
12955 runners by setting the \queue__run__max\ parameter. Because each queue runner
12956 delivers only one message at a time, the maximum number of deliveries that can
12957 then take place at once is \queue@_run@_max\ multiplied by
12958 \remote@_max@_parallel\.
12959
12960 If it is purely remote deliveries you want to control, use
12961 \queue@_smtp@_domains\ instead of \queue@_only\. This has the added benefit of
12962 doing the SMTP routing before queuing, so that several messages for the same
12963 host will eventually get delivered down the same connection.
12964
12965 .conf remote@_sort@_domains "domain list$**$" unset
12966 .index sorting remote deliveries
12967 .index delivery||sorting remote
12968 When there are a number of remote deliveries for a message, they are sorted by
12969 domain into the order given by this list. For example,
12970 .display asis
12971 remote_sort_domains = *.cam.ac.uk:*.uk
12972 .endd
12973 would attempt to deliver to all addresses in the \*cam.ac.uk*\ domain first, then
12974 to those in the \uk\ domain, then to any others.
12975
12976 .conf retry@_data@_expire time 7d
12977 .index hints database||data expiry
12978 This option sets a `use before' time on retry information in Exim's hints
12979 database. Any older retry data is ignored. This means that, for example, once a
12980 host has not been tried for 7 days, Exim behaves as if it has no knowledge of
12981 past failures.
12982
12983 .conf retry@_interval@_max time 24h
12984 .index retry||limit on interval
12985 .index limit||on retry interval
12986 Chapter ~~CHAPretry describes Exim's mechanisms for controlling the intervals
12987 between delivery attempts for messages that cannot be delivered straight away.
12988 This option sets an overall limit to the length of time between retries.
12989
12990 .conf return@_path@_remove boolean true
12991 .index ::Return-path:: header line||removing
12992 RFC 2821, section 4.4, states that an SMTP server must insert a ::Return-path::
12993 header line into a message when it makes a `final delivery'. The ::Return-path::
12994 header preserves the sender address as received in the \\MAIL\\ command. This
12995 description implies that this header should not be present in an incoming
12996 message. If \return@_path@_remove\ is true, any existing ::Return-path::
12997 headers are removed from messages at the time they are received. Exim's
12998 transports have options for adding ::Return-path:: headers at the time of
12999 delivery. They are normally used only for final local deliveries.
13000
13001 .conf return@_size@_limit integer 100K
13002 This option is an obsolete synonym for \bounce@_return@_size@_limit\.
13003
13004 .conf rfc1413@_hosts "host list$**$" $*$
13005 .index RFC 1413
13006 .index host||for RFC 1413 calls
13007 RFC 1413 identification calls are made to any client host which matches an item
13008 in the list.
13009
13010 .conf rfc1413@_query@_timeout time 30s
13011 .index RFC 1413||query timeout
13012 .index timeout||for RFC 1413 call
13013 This sets the timeout on RFC 1413 identification calls. If it is set to zero,
13014 no RFC 1413 calls are ever made.
13015
13016 .conf sender@_unqualified@_hosts "host list$**$" unset
13017 .index unqualified addresses
13018 .index host||unqualified addresses from
13019 This option lists those hosts from which Exim is prepared to accept unqualified
13020 sender addresses. The addresses are made fully qualified by the addition of
13021 \qualify@_domain\. This option also affects message header lines. Exim does not
13022 reject unqualified addresses in headers that contain sender addresses, but it
13023 qualifies them only if the message came from a host that matches
13024 \sender@_unqualified@_hosts\,
13025 or if the message was submitted locally (not using TCP/IP), and the \-bnq-\
13026 option was not set.
13027
13028 .conf smtp@_accept@_keepalive boolean true
13029 .index keepalive||on incoming connection
13030 This option controls the setting of the \\SO@_KEEPALIVE\\ option on incoming
13031 TCP/IP socket connections. When set, it causes the kernel to probe idle
13032 connections periodically, by sending packets with `old' sequence numbers. The
13033 other end of the connection should send an acknowledgement if the connection is
13034 still okay or a reset if the connection has been aborted. The reason for doing
13035 this is that it has the beneficial effect of freeing up certain types of
13036 connection that can get stuck when the remote host is disconnected without
13037 tidying up the TCP/IP call properly. The keepalive mechanism takes several
13038 hours to detect unreachable hosts.
13039
13040
13041 .conf smtp@_accept@_max integer 20
13042 .index limit||incoming SMTP connections
13043 .index SMTP||incoming connection count
13044 .index inetd
13045 This option specifies the maximum number of simultaneous incoming SMTP calls
13046 that Exim will accept. It applies only to the listening daemon; there is no
13047 control (in Exim) when incoming SMTP is being handled by \*inetd*\. If the value
13048 is set to zero, no limit is applied. However, it is required to be non-zero if
13049 either \smtp@_accept@_max@_per@_host\ or \smtp@_accept@_queue\ is set. See also
13050 \smtp@_accept@_reserve\.
13051
13052
13053 .conf smtp@_accept@_max@_nonmail integer 10
13054 .index limit||non-mail SMTP commands
13055 .index SMTP||limiting non-mail commands
13056 Exim counts the number of `non-mail' commands in an SMTP session, and drops the
13057 connection if there are too many. This option defines `too many'. The check
13058 catches some denial-of-service attacks, repeated failing \\AUTH\\s, or a mad
13059 client looping sending \\EHLO\\, for example. The check is applied only if the
13060 client host matches \smtp@_accept@_max@_nonmail@_hosts\.
13061
13062 When a new message is expected, one occurrence of \\RSET\\ is not counted. This
13063 allows a client to send one \\RSET\\ between messages (this is not necessary,
13064 but some clients do it). Exim also allows one uncounted occurence of \\HELO\\
13065 or \\EHLO\\, and one occurrence of \\STARTTLS\\ between messages. After
13066 starting up a TLS session, another \\EHLO\\ is expected, and so it too is not
13067 counted. The first occurrence of \\AUTH\\ in a connection, or immediately
13068 following \\STARTTLS\\ is not counted. Otherwise, all commands other than
13069 \\MAIL\\, \\RCPT\\, \\DATA\\, and \\QUIT\\ are counted.
13070
13071 .conf smtp@_accept@_max@_nonmail@_hosts "host list$**$" $*$
13072 You can control which hosts are subject to the \smtp@_accept@_max@_nonmail\
13073 check by setting this option. The default value makes it apply to all hosts. By
13074 changing the value, you can exclude any badly-behaved hosts that you have to
13075 live with.
13076
13077
13078 .conf smtp@_accept@_max@_per@_connection integer 1000
13079 .index SMTP||incoming message count, limiting
13080 .index limit||messages per SMTP connection
13081 The value of this option limits the number of \\MAIL\\ commands that Exim is
13082 prepared to accept over a single SMTP connection, whether or not each command
13083 results in the transfer of a message. After the limit is reached, a 421
13084 response is given to subsequent \\MAIL\\ commands. This limit is a safety
13085 precaution against a client that goes mad (incidents of this type have been
13086 seen).
13087
13088 .conf smtp@_accept@_max@_per@_host string$**$ unset
13089 .index limit||SMTP connections from one host
13090 .index host||limiting SMTP connections from
13091 This option restricts the number of simultaneous IP connections from a single
13092 host (strictly, from a single IP address) to the Exim daemon. The option is
13093 expanded, to enable different limits to be applied to different hosts by
13094 reference to \$sender@_host@_address$\. Once the limit is reached, additional
13095 connection attempts from the same host are rejected with error code 421. The
13096 default value of zero imposes no limit. If this option is set, it is required
13097 that \smtp@_accept@_max\ be non-zero.
13098
13099 \**Warning**\: When setting this option you should not use any expansion
13100 constructions that take an appreciable amount of time. The expansion and test
13101 happen in the main daemon loop, in order to reject additional connections
13102 without forking additional processes (otherwise a denial-of-service attack
13103 could cause a vast number or processes to be created). While the daemon is
13104 doing this processing, it cannot accept any other incoming connections.
13105
13106
13107 .conf smtp@_accept@_queue integer 0
13108 .index SMTP||incoming connection count
13109 .index queueing incoming messages
13110 .index message||queueing by SMTP connection count
13111 If the number of simultaneous incoming SMTP calls handled via the listening
13112 daemon exceeds this value, messages received by SMTP are just placed on the
13113 queue; no delivery processes are started automatically. A value of zero implies
13114 no limit, and clearly any non-zero value is useful only if it is less than the
13115 \smtp@_accept@_max\ value (unless that is zero). See also \queue@_only\,
13116 \queue@_only@_load\, \queue@_smtp@_domains\, and the various \-od-\ command
13117 line options.
13118
13119 .conf smtp@_accept@_queue@_per@_connection integer 10
13120 .index queueing incoming messages
13121 .index message||queueing by message count
13122 This option limits the number of delivery processes that Exim starts
13123 automatically when receiving messages via SMTP, whether via the daemon or by
13124 the use of \-bs-\ or \-bS-\. If the value of the option is greater than zero,
13125 and the number of messages received in a single SMTP session exceeds this
13126 number, subsequent messages are placed on the queue, but no delivery processes
13127 are started. This helps to limit the number of Exim processes when a server
13128 restarts after downtime and there is a lot of mail waiting for it on other
13129 systems. On large systems, the default should probably be increased, and on
13130 dial-in client systems it should probably be set to zero (that is, disabled).
13131
13132 .conf smtp@_accept@_reserve integer 0
13133 .index SMTP||incoming call count
13134 .index host||reserved
13135 When \smtp@_accept@_max\ is set greater than zero, this option specifies a
13136 number of SMTP connections that are reserved for connections from the hosts
13137 that are specified in \smtp@_reserve@_hosts\. The value set in
13138 \smtp@_accept@_max\ includes this reserve pool. The specified hosts are not
13139 restricted to this number of connections; the option specifies a minimum number
13140 of connection slots for them, not a maximum. It is a guarantee that that group
13141 of hosts can always get at least \smtp@_accept@_reserve\ connections.
13142
13143 For example, if \smtp@_accept@_max\ is set to 50 and \smtp@_accept@_reserve\ is
13144 set to 5, once there are 45 active connections (from any hosts), new
13145 connections are accepted only from hosts listed in \smtp@_reserve@_hosts\.
13146 See also \smtp@_accept@_max@_per@_host\.
13147
13148 .conf smtp@_active@_hostname string$**$ unset
13149 .index host||name in SMTP responses
13150 .index SMTP||host name in responses
13151 This option is provided for multi-homed servers that want to masquerade as
13152 several different hosts. At the start of an SMTP connection, its value is
13153 expanded and used instead of the value of \$primary@_hostname$\ in SMTP
13154 responses. For example, it is used as domain name in the response to an
13155 incoming \\HELO\\ or \\EHLO\\ command. 
13156 .em
13157 The active hostname is placed in the \$smtp__active__hostname$\ variable, which 
13158 is saved with any messages that are received. It is therefore available for use 
13159 in routers and transports when the message is later delivered.
13160 .nem
13161
13162 If this option is unset, or if its expansion is forced to fail, or if the
13163 expansion results in an empty string, the value of \$primary@_hostname$\ is
13164 used. Other expansion failures cause a message to be written to the main and
13165 panic logs, and the SMTP command receives a temporary error. Typically, the
13166 value of \smtp@_active@_hostname\ depends on the incoming interface address.
13167 For example:
13168 .display asis
13169 smtp_active_hostname = ${if eq{$interface_address}{10.0.0.1}\
13170   {cox.mydomain}{box.mydomain}}
13171 .endd
13172
13173 .conf smtp@_banner string$**$ "see below"
13174 .index SMTP||welcome banner
13175 .index banner for SMTP
13176 .index welcome banner for SMTP
13177 .index customizing||SMTP banner
13178 This string, which is expanded every time it is used, is output as the initial
13179 positive response to an SMTP connection. The default setting is:
13180 .display asis
13181 .em
13182 smtp_banner = $smtp_active_hostname ESMTP Exim \
13183   $version_number $tod_full
13184 .nem   
13185 .endd
13186 Failure to expand the string causes a panic error. If you want to create a
13187 multiline response to the initial SMTP connection, use `@\n' in the string at
13188 appropriate points, but not at the end. Note that the 220 code is not included
13189 in this string. Exim adds it automatically (several times in the case of a
13190 multiline response).
13191
13192 .conf smtp@_check@_spool@_space boolean true
13193 .index checking disk space
13194 .index disk space, checking
13195 .index spool directory||checking space
13196 When this option is set, if an incoming SMTP session encounters the \\SIZE\\
13197 option on a \\MAIL\\ command, it checks that there is enough space in the
13198 spool directory's partition to accept a message of that size, while still
13199 leaving free the amount specified by \check@_spool@_space\ (even if that value
13200 is zero). If there isn't enough space, a temporary error code is returned.
13201
13202 .conf smtp@_connect@_backlog integer 20
13203 .index connection backlog
13204 .index SMTP||connection backlog
13205 .index backlog of connections
13206 This option specifies a maximum number of waiting SMTP connections. Exim passes
13207 this value to the TCP/IP system when it sets up its listener. Once this number
13208 of connections are waiting for the daemon's attention, subsequent connection
13209 attempts are refused at the TCP/IP level. At least, that is what the manuals
13210 say; in some circumstances such connection attempts have been observed to time
13211 out instead. For large systems it is probably a good idea to increase the
13212 value (to 50, say). It also gives some protection against denial-of-service
13213 attacks by SYN flooding.
13214
13215 .conf smtp@_enforce@_sync boolean true
13216 .index SMTP||synchronization checking
13217 .index synchronization checking in SMTP
13218 The SMTP protocol specification requires the client to wait for a response from
13219 the server at certain points in the dialogue. Without \\PIPELINING\\ these
13220 synchronization points are after every command; with \\PIPELINING\\ they are
13221 fewer, but they still exist. 
13222
13223 Some spamming sites send out a complete set of SMTP commands without waiting
13224 for any response. Exim protects against this by rejecting a message if the
13225 client has sent further input when it should not have. The error response `554
13226 SMTP synchronization error' is sent, and the connection is dropped. Testing for
13227 this error cannot be perfect because of transmission delays (unexpected input
13228 may be on its way but not yet received when Exim checks). However, it does
13229 detect many instances.
13230
13231 .em
13232 The check can be globally disabled by setting \smtp@_enforce@_sync\ false.
13233 If you want to disable the check selectively (for example, only for certain 
13234 hosts), you can do so by an appropriate use of a \control\ modifier in an ACL
13235 (see section ~~SECTcontrols). See also \pipelining@_advertise@_hosts\.
13236 .nem
13237
13238 .conf smtp@_etrn@_command string$**$ unset
13239 .index \\ETRN\\||command to be run
13240 If this option is set, the given command is run whenever an SMTP \\ETRN\\
13241 command is received from a host that is permitted to issue such commands (see
13242 chapter ~~CHAPACL). The string is split up into separate arguments which are
13243 independently expanded. The expansion variable \$domain$\ is set to the
13244 argument of the \\ETRN\\ command, and no syntax checking is done on it. For
13245 example:
13246 .display asis
13247 smtp_etrn_command = /etc/etrn_command $domain $sender_host_address
13248 .endd
13249 A new process is created to run the command, but Exim does not wait for it to
13250 complete. Consequently, its status cannot be checked. If the command cannot be
13251 run, a line is written to the panic log, but the \\ETRN\\ caller still receives
13252 a 250 success response. Exim is normally running under its own uid when
13253 receiving SMTP, so it is not possible for it to change the uid before running
13254 the command.
13255
13256 .conf smtp@_etrn@_serialize boolean true
13257 .index \\ETRN\\||serializing
13258 When this option is set, it prevents the simultaneous execution of more than
13259 one identical command as a result of \\ETRN\\ in an SMTP connection. See
13260 section ~~SECTETRN for details.
13261
13262 .conf smtp@_load@_reserve fixed-point unset
13263 .index load average
13264 If the system load average ever gets higher than this, incoming SMTP calls are
13265 accepted only from those hosts that match an entry in \smtp@_reserve@_hosts\.
13266 If \smtp@_reserve@_hosts\ is not set, no incoming SMTP calls are accepted when
13267 the load is over the limit. The option has no effect on ancient operating
13268 systems on which Exim cannot determine the load average. See also
13269 \deliver@_queue@_load@_max\ and \queue@_only@_load\.
13270
13271
13272 .conf smtp@_max@_synprot@_errors integer 3
13273 .index SMTP||limiting syntax and protocol errors
13274 .index limit||SMTP syntax and protocol errors
13275 Exim rejects SMTP commands that contain syntax or protocol errors. In
13276 particular, a syntactically invalid email address, as in this command:
13277 .display asis
13278 RCPT TO:<abc xyz@a.b.c>
13279 .endd
13280 causes immediate rejection of the command, before any other tests are done.
13281 (The ACL cannot be run if there is no valid address to set up for it.) An
13282 example of a protocol error is receiving \\RCPT\\ before \\MAIL\\. If there are
13283 too many syntax or protocol errors in one SMTP session, the connection is
13284 dropped. The limit is set by this option.
13285
13286 .index \\PIPELINING\\||expected errors
13287 When the \\PIPELINING\\ extension to SMTP is in use, some protocol errors are
13288 `expected', for instance, a \\RCPT\\ command after a rejected \\MAIL\\ command.
13289 Exim assumes that \\PIPELINING\\ will be used if it advertises it (see
13290 \pipelining@_advertise@_hosts\), and in this situation, `expected' errors do
13291 not count towards the limit.
13292
13293
13294 .conf smtp@_max@_unknown@_commands integer 3
13295 .index SMTP||limiting unknown commands
13296 .index limit||unknown SMTP commands
13297 If there are too many unrecognized commands in an incoming SMTP session, an
13298 Exim server drops the connection. This is a defence against some kinds of abuse
13299 that subvert web
13300 clients
13301 into making connections to SMTP ports; in these circumstances, a number of
13302 non-SMTP command lines are sent first.
13303
13304
13305 .conf smtp@_ratelimit@_hosts "host list$**$" unset
13306 .index SMTP||rate limiting
13307 .index limit||rate of message arrival
13308 .index \\RCPT\\||rate limiting
13309 Some sites find it helpful to be able to limit the rate at which certain hosts
13310 can send them messages, and the rate at which an individual message can specify
13311 recipients. When a host matches \smtp@_ratelimit@_hosts\, the values of
13312 \smtp@_ratelimit@_mail\ and \smtp@_ratelimit@_rcpt\ are used to control the
13313 rate of acceptance of \\MAIL\\ and \\RCPT\\ commands in a single SMTP session,
13314 respectively. Each option, if set, must contain a set of four comma-separated
13315 values:
13316 .numberpars $.
13317 A threshold, before which there is no rate limiting.
13318 .nextp
13319 An initial time delay. Unlike other times in Exim, numbers with decimal
13320 fractional parts are allowed here.
13321 .nextp
13322 A factor by which to increase the delay each time.
13323 .nextp
13324 A maximum value for the delay. This should normally be less than 5 minutes,
13325 because after that time, the client is liable to timeout the SMTP command.
13326 .endp
13327 For example, these settings have been used successfully at the site which
13328 first suggested this feature, for controlling mail from their customers:
13329 .display asis
13330 smtp_ratelimit_mail = 2,0.5s,1.05,4m
13331 smtp_ratelimit_rcpt = 4,0.25s,1.015,4m
13332 .endd
13333 The first setting specifies delays that are applied to \\MAIL\\ commands after
13334 two have been received over a single connection. The initial delay is 0.5
13335 seconds, increasing by a factor of 1.05 each time. The second setting applies
13336 delays to \\RCPT\\ commands when more than four occur in a single message.
13337
13338 It is also possible to configure delays explicitly in ACLs. See section
13339 ~~SECTACLmodi for details.
13340
13341
13342 .conf smtp@_ratelimit@_mail string unset
13343 See \smtp@_ratelimit@_hosts\ above.
13344
13345 .conf smtp@_ratelimit@_rcpt string unset
13346 See \smtp@_ratelimit@_hosts\ above.
13347
13348 .conf smtp@_receive@_timeout time 5m
13349 .index timeout||for SMTP input
13350 .index SMTP||timeout, input
13351 This sets a timeout value for SMTP reception. It applies to all forms of SMTP
13352 input, including batch SMTP. If a line of input (either an SMTP command or a
13353 data line) is not received within this time, the SMTP connection is dropped and
13354 the message is abandoned.
13355 A line is written to the log containing one of the following messages:
13356 .display asis
13357 SMTP command timeout on connection from...
13358 SMTP data timeout on connection from...
13359 .endd
13360 The former means that Exim was expecting to read an SMTP command; the latter
13361 means that it was in the \\DATA\\ phase, reading the contents of a message.
13362
13363
13364 .index \-os-\ option
13365 The value set by this option can be overridden by the
13366 \-os-\ command-line option. A setting of zero time disables the timeout, but
13367 this should never be used for SMTP over TCP/IP. (It can be useful in some cases
13368 of local input using \-bs-\ or \-bS-\.) For non-SMTP input, the reception
13369 timeout is controlled by \receive@_timeout\ and \-or-\.
13370
13371 .conf smtp@_reserve@_hosts "host list$**$" unset
13372 This option defines hosts for which SMTP connections are reserved; see
13373 \smtp@_accept@_reserve\ and \smtp@_load@_reserve\ above.
13374
13375 .conf smtp@_return@_error@_details boolean false
13376 .index SMTP||details policy failures
13377 .index policy control||rejection, returning details
13378 In the default state, Exim uses bland messages such as
13379 `Administrative prohibition' when it rejects SMTP commands for policy
13380 reasons. Many sysadmins like this because it gives away little information
13381 to spammers. However, some other syadmins who are applying strict checking
13382 policies want to give out much fuller information about failures. Setting
13383 \smtp@_return@_error@_details\ true causes Exim to be more forthcoming. For
13384 example, instead of `Administrative prohibition', it might give:
13385 .display asis
13386 550-Rejected after DATA: '>' missing at end of address:
13387 550 failing address in "From" header is: <user@dom.ain
13388 .endd
13389
13390 .em
13391 .conf spamd@_address string "$tt{127.0.0.1 783}"
13392 This option is available when Exim is compiled with the content-scanning
13393 extension. It specifies how Exim connects to SpamAssassin's \spamd\ daemon. See
13394 section ~~SECTscanspamass for more details.
13395 .nem
13396
13397 .conf split@_spool@_directory boolean false
13398 .index multiple spool directories
13399 .index spool directory||split
13400 .index directories, multiple
13401 If this option is set, it causes Exim to split its input directory into 62
13402 subdirectories, each with a single alphanumeric character as its name. The
13403 sixth character of the message id is used to allocate messages to
13404 subdirectories; this is the least significant base-62 digit of the time of
13405 arrival of the message.
13406
13407 Splitting up the spool in this way may provide better performance on systems
13408 where there are long mail queues, by reducing the number of files in any one
13409 directory. The msglog directory is also split up in a similar way to the input
13410 directory; however, if \preserve@_message@_logs\ is set, all old msglog files
13411 are still placed in the single directory \(msglog.OLD)\.
13412
13413 It is not necessary to take any special action for existing messages when
13414 changing \split@_spool@_directory\. Exim notices messages that are in the
13415 `wrong' place, and continues to process them. If the option is turned off after
13416 a period of being on, the subdirectories will eventually empty and be
13417 automatically deleted.
13418
13419 When \split@_spool@_directory\ is set, the behaviour of queue runner processes
13420 changes. Instead of creating a list of all messages in the queue, and then
13421 trying to deliver each one in turn, it constructs a list of those in one
13422 sub-directory and tries to deliver them, before moving on to the next
13423 sub-directory. The sub-directories are processed in a random order. This
13424 spreads out the scanning of the input directories, and uses less memory. It is
13425 particularly beneficial when there are lots of messages on the queue. However,
13426 if \queue@_run@_in@_order\ is set, none of this new processing happens. The
13427 entire queue has to be scanned and sorted before any deliveries can start.
13428
13429 .conf spool@_directory string$**$ "set at compile time"
13430 .index spool directory||path to
13431 This defines the directory in which Exim keeps its spool, that is, the messages
13432 it is waiting to deliver. The default value is taken from the compile-time
13433 configuration setting, if there is one. If not, this option must be set. The
13434 string is expanded, so it can contain, for example, a reference to
13435 \$primary@_hostname$\.
13436
13437 If the spool directory name is fixed on your installation, it is recommended
13438 that you set it at build time rather than from this option, particularly if the
13439 log files are being written to the spool directory (see \log@_file@_path\).
13440 Otherwise log files cannot be used for errors that are detected early on, such
13441 as failures in the configuration file.
13442
13443 By using this option to override the compiled-in path, it is possible to run
13444 tests of Exim without using the standard spool.
13445
13446 .conf strip@_excess@_angle@_brackets boolean false
13447 .index angle brackets, excess
13448 If this option is set, redundant pairs of angle brackets round `route-addr'
13449 items in addresses are stripped. For example, \*@<@<xxx@@a.b.c.d@>@>*\ is treated
13450 as \*@<xxx@@a.b.c.d@>*\. If this is in the envelope and the message is passed on
13451 to another MTA, the excess angle brackets are not passed on. If this option is
13452 not set, multiple pairs of angle brackets cause a syntax error.
13453
13454 .conf strip@_trailing@_dot boolean false
13455 .index trailing dot on domain
13456 .index dot||trailing on domain
13457 If this option is set, a trailing dot at the end of a domain in an address is
13458 ignored. If this is in the envelope and the message is passed on to another
13459 MTA, the dot is not passed on. If this option is not set, a dot at the end of a
13460 domain causes a syntax error.
13461 However, addresses in header lines are checked only when an ACL requests header
13462 syntax checking.
13463
13464 .conf syslog@_duplication boolean true
13465 .index syslog||duplicate log lines, suppressing
13466 When Exim is logging to syslog, it writes the log lines for its three
13467 separate logs at different syslog priorities so that they can in principle
13468 be separated on the logging hosts. Some installations do not require this
13469 separation, and in those cases, the duplication of certain log lines is a
13470 nuisance. If \syslog@_duplication\ is set false, only one copy of any
13471 particular log line is written to syslog. For lines that normally go to
13472 both the main log and the reject log, the reject log version (possibly
13473 containing message header lines) is written, at \\LOG@_NOTICE\\ priority.
13474 Lines that normally go to both the main and the panic log are written at
13475 the \\LOG@_ALERT\\ priority.
13476
13477 .conf syslog@_facility string unset
13478 .index syslog||facility, setting
13479 This option sets the syslog `facility' name, used when Exim is logging to
13480 syslog. The value must be one of the strings `mail', `user', `news', `uucp',
13481 `daemon', or `local\*x*\' where \*x*\ is a digit between 0 and 7. If this
13482 option is unset, `mail' is used. See chapter ~~CHAPlog for details of Exim's
13483 logging.
13484
13485
13486 .conf syslog@_processname string "$tt{exim}"
13487 .index syslog||process name, setting
13488 This option sets the syslog `ident' name, used when Exim is logging to syslog.
13489 The value must be no longer than 32 characters. See chapter ~~CHAPlog for
13490 details of Exim's logging.
13491
13492
13493 .conf syslog@_timestamp boolean true
13494 .index syslog||timestamps
13495 If \syslog@_timestamp\ is set false, the timestamps on Exim's log lines are
13496 omitted when these lines are sent to syslog. See chapter ~~CHAPlog for
13497 details of Exim's logging.
13498
13499 .conf system@_filter string$**$ unset
13500 .index filter||system filter
13501 .index system filter||specifying
13502 .index Sieve filter||not available for system filter
13503 This option specifies an Exim filter file that is applied to all messages at
13504 the start of each delivery attempt, before any routing is done. System filters
13505 must be Exim filters; they cannot be Sieve filters. If the system filter
13506 generates any deliveries to files or pipes, or any new mail messages, the
13507 appropriate \system@_filter@_...@_transport\ option(s) must be set, to define
13508 which transports are to be used. Details of this facility are given in chapter
13509 ~~CHAPsystemfilter.
13510
13511 .conf system@_filter@_directory@_transport string$**$ unset
13512 This sets the name of the transport driver that is to be used when the
13513 \save\ command in a system message filter specifies a path ending in `/',
13514 implying delivery of each message into a separate file in some directory.
13515 During the delivery, the variable \$address@_file$\ contains the path name.
13516
13517 .conf system@_filter@_file@_transport string$**$ unset
13518 .index file||transport for system filter
13519 This sets the name of the transport driver that is to be used when the \save\
13520 command in a system message filter specifies a path not ending in `/'. During
13521 the delivery, the variable \$address@_file$\ contains the path name.
13522
13523 .index gid (group id)||system filter
13524 .conf system@_filter@_group string unset
13525 This option is used only when \system@_filter@_user\ is also set. It sets the
13526 gid under which the system filter is run, overriding any gid that is associated
13527 with the user. The value may be numerical or symbolic.
13528
13529 .conf system@_filter@_pipe@_transport string$**$ unset 7
13530 .index \%pipe%\ transport||for system filter
13531 This specifies the transport driver that is to be used when a \pipe\ command is
13532 used in a system filter. During the delivery, the variable \$address@_pipe$\
13533 contains the pipe command.
13534
13535 .conf system@_filter@_reply@_transport string$**$ unset
13536 .index \%autoreply%\ transport||for system filter
13537 This specifies the transport driver that is to be used when a \mail\ command is
13538 used in a system filter.
13539
13540 .index uid (user id)||system filter
13541 .conf system@_filter@_user string unset
13542 If this option is not set, the system filter is run in the main Exim delivery
13543 process, as root. When the option is set, the system filter runs in a separate
13544 process, as the given user. Unless the string consists entirely of digits, it
13545 is looked up in the password data. Failure to find the named user causes a
13546 configuration error. The gid is either taken from the password data, or
13547 specified by \system@_filter@_group\. When the uid is specified numerically,
13548 \system@_filter@_group\ is required to be set.
13549
13550 If the system filter generates any pipe, file, or reply deliveries, the uid
13551 under which the filter is run is used when transporting them, unless a
13552 transport option overrides.
13553 Normally you should set \system@_filter@_user\ if your system filter generates
13554 these kinds of delivery.
13555
13556 .conf tcp@_nodelay boolean true
13557 .index daemon||\\TCP@_NODELAY\\ on sockets
13558 .index Nagle algorithm
13559 .index \\TCP@_NODELAY\\ on listening sockets
13560 If this option is set false, it stops the Exim daemon setting the
13561 \\TCP@_NODELAY\\ option on its listening sockets. Setting \\TCP@_NODELAY\\
13562 turns off the `Nagle algorithm', which is a way of improving network
13563 performance in interactive (character-by-character) situations. Turning it off
13564 should improve Exim's performance a bit, so that is what happens by default.
13565 However, it appears that some broken clients cannot cope, and time out. Hence
13566 this option. It affects only those sockets that are set up for listening by the
13567 daemon. Sockets created by the smtp transport for delivering mail always set
13568 \\TCP@_NODELAY\\.
13569
13570 .conf timeout@_frozen@_after time 0s
13571 .index frozen messages||timing out
13572 .index timeout||frozen messages
13573 If \timeout@_frozen@_after\ is set to a time greater than zero, a frozen
13574 message of any kind that has been on the queue for longer than the given
13575 time is automatically cancelled at the next queue run. If it is a bounce
13576 message, it is just discarded; otherwise, a bounce is sent to the sender, in a
13577 similar manner to cancellation by the \-Mg-\ command line option. If you want
13578 to timeout frozen bounce messages earlier than other kinds of frozen message,
13579 see \ignore@_bounce@_errors@_after\.
13580
13581 .conf timezone string unset
13582 .index timezone, setting
13583 The value of \timezone\ is used to set the environment variable \\TZ\\ while
13584 running Exim (if it is different on entry). This ensures that all timestamps
13585 created by Exim are in the required timezone. If you want all your timestamps
13586 to be in UTC (aka GMT) you should set
13587 .display asis
13588 timezone = UTC
13589 .endd
13590 The default value is taken from \\TIMEZONE@_DEFAULT\\ in \(Local/Makefile)\,
13591 or, if that is not set, from the value of the TZ environment variable when Exim
13592 is built. If \timezone\ is set to the empty string, either at build or run
13593 time, any existing \\TZ\\ variable is removed from the environment when Exim
13594 runs. This is appropriate behaviour for obtaining wall-clock time on some, but
13595 unfortunately not all, operating systems.
13596
13597 .conf tls@_advertise@_hosts "host list$**$" unset
13598 .index TLS||advertising
13599 .index encryption||on SMTP connection
13600 .index SMTP||encrypted connection
13601 When Exim is built with support for TLS encrypted connections, the availability
13602 of the \\STARTTLS\\ command to set up an encrypted session is advertised in
13603 response to \\EHLO\\ only to those client hosts that match this option. See
13604 chapter ~~CHAPTLS for details of Exim's support for TLS.
13605
13606 .conf tls@_certificate string$**$ unset
13607 .index TLS||server certificate, location of
13608 .index certificate||for server, location of
13609 The value of this option is expanded, and must then be the absolute path to a
13610 file which contains the server's certificates. The server's private key is also
13611 assumed to be in this file if \tls@_privatekey\ is unset. See chapter ~~CHAPTLS
13612 for further details.
13613
13614 \**Note**\: The certificates defined by this option are used only when Exim is
13615 receiving incoming messages as a server. If you want to supply certificates for
13616 use when sending messages as a client, you must set the \tls@_certificate\
13617 option in the relevant \%smtp%\ transport.
13618
13619 .conf tls@_crl string$**$ unset
13620 .index TLS||server certificate revocation list
13621 .index certificate||revocation list for server
13622 This option specifies a certificate revocation list. The expanded value must
13623 be the name of a file that contains a CRL in PEM format.
13624
13625 .conf tls@_dhparam string$**$ unset
13626 .index TLS||D-H parameters for server
13627 The value of this option is expanded, and must then be the absolute path to
13628 a file which contains the server's DH parameter values.
13629 This is used only for OpenSSL. When Exim is linked with GnuTLS, this option is
13630 ignored. See section ~~SECTopenvsgnu for further details.
13631
13632 .em
13633 .conf tls@_on@_connect@_ports "string list" unset
13634 This option specifies a list of incoming SSMTP ports that should operate the 
13635 obsolete SSMTP protocol, where a TLS session is immediately set up without 
13636 waiting for the client to issue a \\STARTTLS\\ command. For further details,
13637 see section ~~SECTsupobssmt.
13638 .nem
13639
13640 .conf tls@_privatekey string$**$ unset
13641 .index TLS||server private key, location of
13642 The value of this option is expanded, and must then be the absolute path to a
13643 file which contains the server's private key. If this option is unset, the
13644 private key is assumed to be in the same file as the server's certificates. See
13645 chapter ~~CHAPTLS for further details.
13646
13647 .conf tls@_remember@_esmtp boolean false
13648 .index TLS||esmtp state, remembering
13649 .index TLS||broken clients
13650 If this option is set true, Exim violates the RFCs by remembering that it is in
13651 `esmtp' state after successfully negotiating a TLS session. This provides
13652 support for broken clients that fail to send a new \\EHLO\\ after starting a
13653 TLS session.
13654
13655 .conf tls@_require@_ciphers string$**$ unset
13656 .index TLS||requiring specific ciphers
13657 .index cipher||requiring specific
13658 This option controls which ciphers can be used for incoming TLS connections.
13659 The \%smtp%\ transport has an option of the same name for controlling outgoing
13660 connections. This option is expanded for each connection, so can be varied for
13661 different clients if required. The value of this option must be a list of
13662 permitted cipher suites. The OpenSSL and GnuTLS libraries handle cipher control
13663 in somewhat different ways.
13664 .em
13665 If GnuTLS is being used, the client controls the preference order of the
13666 available ciphers.
13667 .nem
13668 Details are given in sections ~~SECTreqciphssl and ~~SECTreqciphgnu.
13669
13670 .conf tls@_try@_verify@_hosts "host list$**$" unset
13671 .index TLS||client certificate verification
13672 .index certificate||verification of client
13673 See \tls@_verify@_hosts\ below.
13674
13675 .conf tls@_verify@_certificates string$**$ unset
13676 .index TLS||client certificate verification
13677 .index certificate||verification of client
13678 The value of this option is expanded, and must then be the absolute path to
13679 a file containing permitted certificates for clients that
13680 match \tls@_verify@_hosts\ or \tls@_try@_verify@_hosts\. Alternatively, if you
13681 are using OpenSSL, you can set \tls@_verify@_certificates\ to the name of a
13682 directory containing certificate files. This does not work with GnuTLS; the
13683 option must be set to the name of a single file if you are using GnuTLS.
13684
13685 .conf tls@_verify@_hosts "host list$**$" unset
13686 .index TLS||client certificate verification
13687 .index certificate||verification of client
13688 This option, along with \tls@_try@_verify@_hosts\, controls the checking of
13689 certificates from clients.
13690 The expected certificates are defined by \tls@_verify@_certificates\, which
13691 must be set. A configuration error occurs if either \tls@_verify@_hosts\ or
13692 \tls@_try@_verify@_hosts\ is set and \tls@_verify@_certificates\ is not set.
13693
13694 Any client that matches \tls@_verify@_hosts\ is constrained by
13695 \tls@_verify@_certificates\. The client must present one of the listed
13696 certificates. If it does not, the connection is aborted.
13697
13698 A weaker form of checking is provided by \tls@_try@_verify@_hosts\. If a client
13699 matches this option (but not \tls@_verify@_hosts\), Exim requests a
13700 certificate and checks it against \tls@_verify@_certificates\, but does not
13701 abort the connection if there is no certificate or if it does not match. This
13702 state can be detected in an ACL, which makes it possible to implement policies
13703 such as `accept for relay only if a verified certificate has been received, but
13704 accept for local delivery if encrypted, even without a verified certificate'.
13705
13706 Client hosts that match neither of these lists are not asked to present
13707 certificates.
13708
13709 .conf trusted@_groups "string list" unset
13710 .index trusted group
13711 .index group||trusted
13712 If this option is set, any process that is running in one of the listed groups,
13713 or which has one of them as a supplementary group, is trusted.
13714 The groups can be specified numerically or by name.
13715 See section ~~SECTtrustedadmin for details of what trusted callers are
13716 permitted to do. If neither \trusted@_groups\ nor \trusted@_users\ is set, only
13717 root and the Exim user are trusted.
13718
13719 .conf trusted@_users "string list" unset
13720 .index trusted user
13721 .index user||trusted
13722 If this option is set, any process that is running as one of the listed users
13723 is trusted.
13724 The users can be specified numerically or by name.
13725 See section ~~SECTtrustedadmin for details of what trusted callers are
13726 permitted to do. If neither \trusted@_groups\ nor \trusted@_users\ is set, only
13727 root and the Exim user are trusted.
13728
13729 .index uid (user id)||unknown caller
13730 .conf unknown@_login string$**$ unset
13731 This is a specialized feature for use in unusual configurations. By default, if
13732 the uid of the caller of Exim cannot be looked up using \*getpwuid()*\, Exim
13733 gives up. The \unknown@_login\ option can be used to set a login name to be
13734 used in this circumstance. It is expanded, so values like \user@$caller@_uid\
13735 can be set. When \unknown@_login\ is used, the value of \unknown@_username\ is
13736 used for the user's real name (gecos field), unless this has been set by the
13737 \-F-\ option.
13738
13739 .conf unknown@_username string unset
13740 See \unknown@_login\.
13741
13742 .conf untrusted@_set@_sender "address list$**$" unset
13743 .index trusted user
13744 .index sender||setting by untrusted user
13745 .index untrusted user, setting sender
13746 .index user||untrusted setting sender
13747 .index envelope sender
13748 When an untrusted user submits a message to Exim using the standard input, Exim
13749 normally creates an envelope sender address from the user's login and the
13750 default qualification domain. Data from the \-f-\ option (for setting envelope
13751 senders on non-SMTP messages) or the SMTP \\MAIL\\ command (if \-bs-\ or \-bS-\
13752 is used) is ignored.
13753
13754 However, untrusted users are permitted to set an empty envelope sender address,
13755 to declare that a message should never generate any bounces. For example:
13756 .display asis
13757 exim -f '<>' user@domain.example
13758 .endd
13759 The \untrusted@_set@_sender\ option allows you to permit untrusted users to set
13760 other envelope sender addresses in a controlled way. When it is set, untrusted
13761 users are allowed to set envelope sender addresses that match any of the
13762 patterns in the list. Like all address lists, the string is expanded. The
13763 identity of the user is in \$sender@_ident$\, so you can, for example, restrict
13764 users to setting senders that start with their login ids
13765 followed by a hyphen
13766 by a setting like this:
13767 .display asis
13768 untrusted_set_sender = ^$sender_ident-
13769 .endd
13770 If you want to allow untrusted users to set envelope sender addresses without
13771 restriction, you can use
13772 .display asis
13773 untrusted_set_sender = *
13774 .endd
13775 The \untrusted@_set@_sender\ option applies to all forms of local input, but
13776 only to the setting of the envelope sender. It does not permit untrusted users
13777 to use the other options which trusted user can use to override message
13778 parameters. Furthermore, it does not stop Exim from removing an existing
13779 ::Sender:: header in the message, or from adding a ::Sender:: header if
13780 necessary. See \local__sender__retain\ and \local@_from@_check\ for ways of
13781 overriding these actions. The handling of the ::Sender:: header is also
13782 described in section ~~SECTthesenhea.
13783
13784 The log line for a message's arrival shows the envelope sender following `<='.
13785 For local messages, the user's login always follows, after `U='. In \-bp-\
13786 displays, and in the Exim monitor, if an untrusted user sets an envelope sender
13787 address, the user's login is shown in parentheses after the sender address.
13788
13789 .conf uucp@_from@_pattern string "see below"
13790 .index `From' line
13791 .index UUCP||`From' line
13792 Some applications that pass messages to an MTA via a command line interface use
13793 an initial line starting with `From' to pass the envelope sender. In
13794 particular, this is used by UUCP software. Exim recognizes such a line by means
13795 of a regular expression that is set in \uucp@_from@_pattern\. When the pattern
13796 matches, the sender address is constructed by expanding the contents of
13797 \uucp@_from@_sender\, provided that the caller of Exim is a trusted user. The
13798 default pattern recognizes lines in the following two forms:
13799 .display asis
13800    From ph10 Fri Jan  5 12:35 GMT 1996
13801    From ph10 Fri, 7 Jan 97 14:00:00 GMT
13802 .endd
13803 The pattern can be seen by running
13804 .display asis
13805 exim -bP uucp_from_pattern
13806 .endd
13807 It checks only up to the hours and minutes, and allows for a 2-digit or 4-digit
13808 year in the second case. The first word after `From' is matched in the regular
13809 expression by a parenthesized subpattern. The default value for
13810 \uucp@_from@_sender\ is `$1', which therefore just uses this first word (`ph10'
13811 in the example above) as the message's sender. See also
13812 \ignore@_fromline@_hosts\.
13813
13814 .conf uucp@_from@_sender string$**$ "$tt{@$1}"
13815 See \uucp@_from@_pattern\ above.
13816
13817 .conf warn@_message@_file string unset
13818 .index warning of delay||customizing the message
13819 .index customizing||warning message
13820 This option defines a template file containing paragraphs of text to be used
13821 for constructing the warning message which is sent by Exim when a message has
13822 been on the queue for a specified amount of time, as specified by
13823 \delay@_warning\. Details of the file's contents are given in chapter
13824 ~~CHAPemsgcust. See also \bounce@_message@_file\.
13825
13826 .conf write@_rejectlog boolean true
13827 .index reject log||disabling
13828 If this option is set false, Exim no longer writes anything to the reject log.
13829 See chapter ~~CHAPlog for details of what Exim writes to its logs.
13830
13831 .endconf
13832
13833
13834
13835 .
13836 .
13837 .
13838 .
13839 . ============================================================================
13840 .chapter Generic options for routers
13841 .rset CHAProutergeneric "~~chapter"
13842 .set runningfoot "generic router options"
13843 .index options||generic, for routers
13844 .index generic options||router
13845
13846 This chapter describes the generic options that apply to all routers,
13847 identifying those that are preconditions. For a general description of how a
13848 router operates, see sections ~~SECTrunindrou and ~~SECTrouprecon. The latter
13849 specifies the order in which the preconditions are tested. The order of
13850 expansion of the options that provide data for a transport is: \errors@_to\,
13851 \headers@_add\, \headers@_remove\, \transport\.
13852
13853 .startconf routers
13854
13855 .conf address@_data string$**$ unset
13856 .index router||data attached to address
13857 The string is expanded just before the router is run, that is, after all the
13858 precondition tests have succeeded. If the expansion is forced to fail, the
13859 router declines. Other expansion failures cause delivery of the address to be
13860 deferred.
13861
13862 When the expansion succeeds, the value is retained with the address, and can be
13863 accessed using the variable \$address@_data$\ in the current router, subsequent
13864 routers, and the eventual transport.
13865
13866 \**Warning**\: if the current or any subsequent router is a \%redirect%\ router
13867 that runs a user's filter file, the contents of \$address@_data$\ are
13868 accessible in the filter. This is not normally a problem, because such data is
13869 usually either not confidential or it `belongs' to the current user, but if you
13870 do put confidential data into \$address@_data$\ you need to remember this
13871 point.
13872
13873 Even if the router declines or passes, the value of \$address@_data$\ remains
13874 with the address, though it can be changed by another \address@_data\ setting
13875 on a subsequent router. If a router generates child addresses, the value of
13876 \$address@_data$\ propagates to them. This also applies to the special kind of
13877 `child' that is generated by a router with the \unseen\ option.
13878
13879 The idea of \address@_data\ is that you can use it to look up a lot of data for
13880 the address once, and then pick out parts of the data later. For example, you
13881 could use a single LDAP lookup to return a string of the form
13882 .display asis
13883 uid=1234 gid=5678 mailbox=/mail/xyz forward=/home/xyz/.forward
13884 .endd
13885 In the transport you could pick out the mailbox by a setting such as
13886 .display asis
13887 file = ${extract{mailbox}{$address_data}}
13888 .endd
13889 This makes the configuration file less messy, and also reduces the number of
13890 lookups (though Exim does cache lookups).
13891
13892 The \address@_data\ facility is also useful as a means of passing information
13893 from one router to another, and from a router to a transport. In addition, if
13894 .em
13895 \$address@_data$\ is set by a router when verifying a recipient address from an
13896 ACL, it remains available for use in the rest of the ACL statement. After
13897 verifying a sender, the value is transferred to \$sender@_address@_data$\.
13898 .nem
13899
13900
13901 .conf address@_test "boolean (precondition)" true
13902 .index \-bt-\ option
13903 .index router||skipping when address testing
13904 If this option is set false, the router is skipped when routing is being tested
13905 by means of the \-bt-\ command line option. This can be a convenience when your
13906 first router sends messages to an external scanner, because it saves you
13907 having to set the `already scanned' indicator when testing real address
13908 routing.
13909
13910
13911 .conf cannot@_route@_message string$**$ unset
13912 .index router||customizing `cannot route' message
13913 .index customizing||`cannot route' message
13914 This option specifies a text message that is used when an address cannot be
13915 routed because Exim has run out of routers. The default message is `Unrouteable
13916 address'. This option is useful only on routers that have \more\ set false, or
13917 on the very last router in a configuration, because the value that is used is
13918 taken from the last router that inspects an address. For example, using the
13919 default configuration, you could put:
13920 .display asis
13921 cannot_route_message = Remote domain not found in DNS
13922 .endd
13923 on the first (\%dnslookup%\) router, and
13924 .display asis
13925 cannot_route_message = Unknown local user
13926 .endd
13927 on the final router that checks for local users. If string expansion fails, the
13928 default message is used.
13929 Unless the expansion failure was explicitly forced, a message about the failure
13930 is written to the main and panic logs, in addition to the normal message about
13931 the routing failure.
13932
13933 .conf caseful@_local@_part boolean false
13934 .index case of local parts
13935 .index router||case of local parts
13936 By default, routers handle the local parts of addresses in a case-insensitive
13937 manner, though the actual case is preserved for transmission with the message.
13938 If you want the case of letters to be significant in a router, you must set
13939 this option true. For individual router options that contain address or local
13940 part lists (for example, \local@_parts\), case-sensitive matching can be turned
13941 on by `+caseful' as a list item. See section ~~SECTcasletadd for more details.
13942
13943 .em
13944 The value of the \$local@_part$\ variable is forced to lower case while a
13945 router is running unless \caseful@_local@_part\ is set. When a router assigns
13946 an address to a transport, the value of \$local@_part$\ when the transport runs
13947 is the same as it was in the router. Similarly, when a router generates child 
13948 addresses by aliasing or forwarding, the values of \$original@_local@_part$\
13949 and \$parent@_local@_part$\ are those that were used by the redirecting router.
13950
13951 This option applies to the processing of an address by a router. When a 
13952 recipient address is being processed in an ACL, there is a separate \control\ 
13953 modifier that can be used to specify case-sensitive processing within the ACL
13954 (see section ~~SECTcontrols).
13955 .nem
13956
13957 .conf check@_local@_user "boolean (precondition)" false
13958 .index local user, checking in router
13959 .index router||checking for local user
13960 .index \(/etc/passwd)\
13961 When this option is true, Exim checks that the local part of the recipient
13962 address (with affixes removed if relevant) is the name of an account on the
13963 local system. The check is done by calling the \*getpwnam()*\ function rather
13964 than trying to read \(/etc/passwd)\ directly. This means that other methods of
13965 holding password data (such as NIS) are supported. If the local part is a local
13966 user, \$home$\ is set from the password data, and can be tested in other
13967 preconditions that are evaluated after this one (the order of evaluation is
13968 given in section ~~SECTrouprecon). However, the value of \$home$\ can be
13969 overridden by \router@_home@_directory\. If the local part is not a local user,
13970 the router is skipped.
13971
13972 If you want to check that the local part is either the name of a local user
13973 or matches something else, you cannot combine \check@_local@_user\ with a
13974 setting of \local@_parts\, because that specifies the logical \*and*\ of the
13975 two conditions. However, you can use a \%passwd%\ lookup in a \local@_parts\
13976 setting to achieve this. For example:
13977 .display asis
13978 local_parts = passwd;$local_part : lsearch;/etc/other/users
13979 .endd
13980 Note, however, that the side effects of \check@_local@_user\ (such as setting
13981 up a home directory) do not occur when a \%passwd%\ lookup is used in a
13982 \local@_parts\ (or any other) precondition.
13983
13984
13985 .conf condition "string$**$ (precondition)"  unset
13986 .index router||customized precondition
13987 This option specifies a general precondition test that has to succeed for the
13988 router to be called. The \condition\ option is the last precondition to be
13989 evaluated (see section ~~SECTrouprecon). The string is expanded, and if the
13990 result is a forced failure, or an empty string, or one of the strings `0' or
13991 `no' or `false' (checked without regard to the case of the letters), the router
13992 is skipped, and the address is offered to the next one.
13993 .em
13994 If the result is any other value, the router is run (as this is the last
13995 precondition to be evaluated, all the other preconditions must be true).
13996
13997 The \condition\ option provides a means of applying custom conditions to the
13998 running of routers. Note that in the case of a simple conditional expansion,
13999 the default expansion values are exactly what is wanted. For example:
14000 .display asis
14001 condition = ${if >{$message_age}{600}}
14002 .endd
14003 Because of the default behaviour of the string expansion, this is equivalent to
14004 .display asis
14005 condition = ${if >{$message_age}{600}{true}{}}
14006 .endd
14007 .nem
14008
14009 If the expansion fails (other than forced failure) delivery is deferred. Some
14010 of the other precondition options are common special cases that could in fact
14011 be specified using \condition\. 
14012
14013
14014 .conf debug@_print string$**$ unset
14015 .index testing||variables in drivers
14016 If this option is set and debugging is enabled (see the \-d-\ command line
14017 option), the string is expanded and included in the debugging output.
14018 If expansion of the string fails, the error message is written to the debugging
14019 output, and Exim carries on processing.
14020 This option is provided to help with checking out the values of variables and
14021 so on when debugging router configurations. For example, if a \condition\
14022 option appears not to be working, \debug@_print\ can be used to output the
14023 variables it references. The output happens after checks for \domains\,
14024 \local@_parts\, and \check@_local@_user\ but before any other preconditions are
14025 tested. A newline is added to the text if it does not end with one.
14026
14027
14028 .conf disable@_logging boolean false
14029 If this option is set true, nothing is logged for any routing errors
14030 or for any deliveries caused by this router. You should not set this option
14031 unless you really, really know what you are doing. See also the generic
14032 transport option of the same name.
14033
14034 .conf domains "domain list$**$ (precondition)" unset
14035 .index router||restricting to specific domains
14036 If this option is set, the router is skipped unless the current domain matches
14037 the list. If the match is achieved by means of a file lookup, the data that the
14038 lookup returned for the domain is placed in \$domain@_data$\ for use in string
14039 expansions of the driver's private options.
14040 See section ~~SECTrouprecon for a list of the order in which preconditions
14041 are evaluated.
14042
14043
14044 .conf driver string unset
14045 This option must always be set. It specifies which of the available routers is
14046 to be used.
14047
14048
14049 .conf errors@_to string$**$ unset
14050 .index envelope sender
14051 .index router||changing address for errors
14052 If a router successfully handles an address, it may queue the address for
14053 delivery or it may generate child addresses. In both cases, if there is a
14054 delivery problem during later processing, the resulting bounce message is sent
14055 to the address that results from expanding this string, provided that the
14056 address verifies successfully.
14057 \errors@_to\ is expanded before \headers@_add\, \headers@_remove\, and
14058 \transport\.
14059
14060 If the option is unset, or the expansion is forced to fail, or the result of
14061 the expansion fails to verify, the errors address associated with the incoming
14062 address is used. At top level, this is the envelope sender. A non-forced
14063 expansion failure causes delivery to be deferred.
14064
14065 If an address for which \errors@_to\ has been set ends up being delivered over
14066 SMTP, the envelope sender for that delivery is the \errors@_to\ value, so that
14067 any bounces that are generated by other MTAs on the delivery route are also
14068 sent there. The most common use of \errors@_to\ is probably to direct mailing
14069 list bounces to the manager of the list, as described in section
14070 ~~SECTmailinglists.
14071
14072 The \errors@_to\ setting associated with an address can be overridden if it
14073 subsequently passes through other routers that have their own \errors@_to\
14074 settings,
14075 or if it is delivered by a transport with a \return@_path\ setting.
14076
14077 You can set \errors@_to\ to the empty string by either of these settings:
14078 .display asis
14079 errors_to =
14080 errors_to = ""
14081 .endd
14082 An expansion item that yields an empty string has the same effect. If you do
14083 this, a locally detected delivery error for addresses processed by this router
14084 no longer gives rise to a bounce message; the error is discarded. If the
14085 address is delivered to a remote host, the return path is set to \"<>"\, unless
14086 overridden by the \return@_path\ option on the transport.
14087
14088 If for some reason you want to discard local errors, but use a non-empty
14089 \\MAIL\\ command for remote delivery, you can preserve the original return
14090 path in \$address@_data$\ in the router, and reinstate it in the transport by
14091 setting \return@_path\.
14092
14093
14094 .conf expn "boolean (precondition)" true
14095 .index address||testing
14096 .index testing||addresses
14097 .index \\EXPN\\||router skipping
14098 .index router||skipping for \\EXPN\\
14099 If this option is turned off, the router is skipped when testing an address
14100 as a result of processing an SMTP \\EXPN\\ command. You might, for example,
14101 want to turn it off on a router for users' \(.forward)\ files, while leaving it
14102 on for the system alias file.
14103 See section ~~SECTrouprecon for a list of the order in which preconditions
14104 are evaluated.
14105
14106 The use of the SMTP \\EXPN\\ command is controlled by an ACL (see chapter
14107 ~~CHAPACL). When Exim is running an \\EXPN\\ command, it is similar to testing
14108 an address with \-bt-\. Compare \\VRFY\\, whose counterpart is \-bv-\.
14109
14110
14111 .conf fail@_verify boolean false
14112 .index router||forcing verification failure
14113 Setting this option has the effect of setting both \fail@_verify@_sender\ and
14114 \fail@_verify@_recipient\ to the same value.
14115
14116
14117 .conf fail@_verify@_recipient boolean false
14118 If this option is true and an address is accepted by this router when
14119 verifying a recipient, verification fails.
14120
14121
14122 .conf fail@_verify@_sender boolean false
14123 If this option is true and an address is accepted by this router when
14124 verifying a sender, verification fails.
14125
14126
14127 .conf fallback@_hosts "string list" unset
14128 .index router||fallback hosts
14129 .index fallback||hosts specified on router
14130 String expansion is not applied to this option. The argument must be a
14131 colon-separated list of host names or IP addresses. If a router queues an
14132 address for a remote transport, this host list is associated with the address,
14133 and used instead of the transport's fallback host list. If \hosts@_randomize\
14134 is set on the transport, the order of the list is randomized for each use. See
14135 the \fallback@_hosts\ option of the \%smtp%\ transport for further details.
14136
14137 .conf group string$**$ "see below"
14138 .index gid (group id)||local delivery
14139 .index local transports||uid and gid
14140 .index transport||local
14141 .index router||setting group
14142 When a router queues an address for a transport, and the transport does not
14143 specify a group, the group given here is used when running the delivery
14144 process.
14145 The group may be specified numerically or by name. If expansion fails, the
14146 error is logged and delivery is deferred.
14147 The default is unset, unless \check@_local@_user\ is set, when the default
14148 is taken from the password information. See also \initgroups\ and \user\ and
14149 the discussion in chapter ~~CHAPenvironment.
14150
14151
14152 .conf headers@_add string$**$ unset
14153 .index header lines||adding
14154 .index router||adding header lines
14155 .em
14156 This option specifies a string of text that is expanded at routing time, and
14157 associated with any addresses that are accepted by the router. However, this
14158 option has no effect when an address is just being verified. The way in which
14159 the text is used to add header lines at transport time is described in section
14160 ~~SECTheadersaddrem.
14161
14162 The \headers@_add\ option is expanded after \errors@_to\, but before
14163 \headers@_remove\ and \transport\. If the expanded string is empty, or if the
14164 expansion is forced to fail, the option has no effect. Other expansion failures
14165 are treated as configuration errors.
14166
14167 \**Warning**\: The \headers@_add\ option cannot be used for a \%redirect%\
14168 router that has the \one@_time\ option set.
14169 .nem
14170
14171
14172 .conf headers@_remove string$**$ unset
14173 .index header lines||removing
14174 .index router||removing header lines
14175 .em
14176 This option specifies a string of text that is expanded at routing time, and
14177 associated with any addresses that are accepted by the router. However, this
14178 option has no effect when an address is just being verified. The way in which
14179 the text is used to remove header lines at transport time is described in
14180 section ~~SECTheadersaddrem.
14181
14182 The \headers@_remove\ option is expanded after \errors@_to\ and \headers@_add\,
14183 but before \transport\. If the expansion is forced to fail, the option has no
14184 effect. Other expansion failures are treated as configuration errors.
14185
14186 \**Warning**\: The \headers@_remove\ option cannot be used for a \%redirect%\
14187 router that has the \one@_time\ option set.
14188 .nem
14189
14190
14191 .conf ignore@_target@_hosts "host list$**$" unset
14192 .index IP address||discarding
14193 .index router||discarding IP addresses
14194 Although this option is a host list, it should normally contain IP address
14195 entries rather than names. If any host that is looked up by the router has an
14196 IP address that matches an item in this list, Exim behaves as if that IP
14197 address did not exist. This option allows you to cope with rogue DNS entries
14198 like
14199 .display asis
14200 remote.domain.example.  A  127.0.0.1
14201 .endd
14202 by setting
14203 .display asis
14204 ignore_target_hosts = 127.0.0.1
14205 .endd
14206 on the relevant router. If all the hosts found by a \%dnslookup%\ router are
14207 discarded in this way, the router declines. In a conventional configuration, an
14208 attempt to mail to such a domain would normally provoke the `unrouteable
14209 domain' error, and an attempt to verify an address in the domain would fail.
14210
14211 Similarly, if \ignore@_target@_hosts\ is set on an \%ipliteral%\ router, the
14212 router declines if presented with one of the listed addresses.
14213
14214 This option may also be useful for ignoring link-local and site-local IPv6
14215 addresses. Because, like all host lists, the value of \ignore@_target@_hosts\
14216 is expanded before use as a list, it is possible to make it dependent on the
14217 domain that is being routed.
14218 .em
14219 During its expansion, \$host@_address$\ is set to the IP address that is being 
14220 checked.
14221 .nem
14222
14223
14224
14225 .index additional groups
14226 .index groups, additional
14227 .index local transports||uid and gid
14228 .index transport||local
14229 .conf initgroups boolean false
14230 If the router queues an address for a transport, and this option is true, and
14231 the uid supplied by the router is not overridden by the transport, the
14232 \*initgroups()*\ function is called when running the transport to ensure that
14233 any additional groups associated with the uid are set up. See also \group\ and
14234 \user\ and the discussion in chapter ~~CHAPenvironment.
14235
14236
14237 .conf local@_part@_prefix "string list (precondition)" unset
14238 .index router||prefix for local part
14239 .index prefix||for local part, used in router
14240 If this option is set, the router is skipped unless the local part
14241 starts with one of the given strings, or \local@_part@_prefix@_optional\ is
14242 true.
14243 See section ~~SECTrouprecon for a list of the order in which preconditions
14244 are evaluated.
14245
14246 The list is scanned from left to right, and the first prefix that matches is
14247 used. A limited form of wildcard is available; if the prefix begins with an
14248 asterisk, it matches the longest possible sequence of arbitrary characters at
14249 the start of the local part. An asterisk should therefore always be followed by
14250 some character that does not occur in normal local parts.
14251 .index multiple mailboxes
14252 .index mailbox||multiple
14253 Wildcarding can be used to set up multiple user mailboxes, as described in
14254 section ~~SECTmulbox.
14255
14256 During the testing of the \local@_parts\ option, and while the router is
14257 running, the prefix is removed from the local part, and is available in the
14258 expansion variable \$local@_part@_prefix$\. If the router accepts the address,
14259 this remains true during subsequent delivery.
14260 In particular, the local part that is transmitted in the \\RCPT\\ command
14261 for LMTP, SMTP, and BSMTP deliveries has the prefix removed by default. This
14262 behaviour can be overridden by setting \rcpt@_include@_affixes\ true on the
14263 relevant transport.
14264
14265 The prefix facility is commonly used to handle local parts of the form
14266 \owner-something\. Another common use is to support local parts of the form
14267 \real-username\ to bypass a user's \(.forward)\ file -- helpful when trying to
14268 tell a user their forwarding is broken -- by placing a router like this one
14269 immediately before the router that handles \(.forward)\ files:
14270 .display asis
14271 real_localuser:
14272   driver = accept
14273   local_part_prefix = real-
14274   check_local_user
14275   transport = local_delivery
14276 .endd
14277 If both \local@_part@_prefix\ and \local@_part@_suffix\ are set for a router,
14278 both conditions must be met if not optional. Care must be taken if wildcards
14279 are used in both a prefix and a suffix on the same router. Different
14280 separator characters must be used to avoid ambiguity.
14281
14282 .conf local@_part@_prefix@_optional boolean false
14283 See \local@_part@_prefix\ above.
14284
14285
14286 .conf local@_part@_suffix "string list (precondition)" unset
14287 .index router||suffix for local part
14288 .index suffix for local part, used in router
14289 This option operates in the same way as \local@_part@_prefix\, except that the
14290 local part must end (rather than start) with the given string, the
14291 \local@_part@_suffix@_optional\ option determines whether the suffix is
14292 mandatory, and the wildcard $*$ character, if present, must be the last
14293 character of the suffix. This option facility is commonly used to handle local
14294 parts of the form \something-request\ and multiple user mailboxes of the form
14295 \username-foo\.
14296
14297 .conf local@_part@_suffix@_optional boolean false
14298 See \local@_part@_suffix\ above.
14299
14300
14301 .conf local@_parts "local part list$**$ (precondition)" unset
14302 .index router||restricting to specific local parts
14303 .index local part||checking in router
14304 The router is run only if the local part of the address matches the list.
14305 See section ~~SECTrouprecon for a list of the order in which preconditions
14306 are evaluated, and
14307 section ~~SECTlocparlis for a discussion of local part lists. Because the
14308 string is expanded, it is possible to make it depend on the domain, for
14309 example:
14310 .display asis
14311 local_parts = dbm;/usr/local/specials/$domain
14312 .endd
14313 If the match is achieved by a lookup, the data that the lookup returned
14314 for the local part is placed in the variable \$local@_part@_data$\ for use in
14315 expansions of the router's private options. You might use this option, for
14316 example, if you have a large number of local virtual domains, and you want to
14317 send all postmaster mail to the same place without having to set up an alias in
14318 each virtual domain:
14319 .display asis
14320 postmaster:
14321   driver = redirect
14322   local_parts = postmaster
14323   data = postmaster@real.domain.example
14324 .endd
14325
14326
14327 .conf log@_as@_local boolean "see below"
14328 .index log||delivery line
14329 .index delivery||log line format
14330 Exim has two logging styles for delivery, the idea being to make local
14331 deliveries stand out more visibly from remote ones. In the `local' style, the
14332 recipient address is given just as the local part, without a domain. The use of
14333 this style is controlled by this option. It defaults to true for the \%accept%\
14334 router, and false for all the others.
14335
14336
14337 .conf more boolean$**$ true
14338 The result of string expansion for this option must be a valid boolean value,
14339 that is, one of the strings `yes', `no', `true', or `false'. Any other result
14340 causes an error, and delivery is deferred. If the expansion is forced to fail,
14341 the default value for the option (true) is used. Other failures cause delivery
14342 to be deferred.
14343
14344 If this option is set false, and the router is run, but declines to handle the
14345 address, no further routers are tried, routing fails, and the address is
14346 bounced.
14347 .index \self\ option
14348 However, if the router explicitly passes an address to the following router by
14349 means of the setting
14350 .display asis
14351 self = pass
14352 .endd
14353 or otherwise, the setting of \more\ is ignored. Also, the setting of \more\
14354 does not affect the behaviour if one of the precondition tests fails. In that
14355 case, the address is always passed to the next router.
14356
14357
14358 .conf pass@_on@_timeout boolean false
14359 .index timeout||of router
14360 .index router||timeout
14361 If a router times out during a host lookup, it normally causes deferral of the
14362 address. If \pass@_on@_timeout\ is set, the address is passed on to the next
14363 router, overriding \no@_more\. This may be helpful for systems that are
14364 intermittently connected to the Internet, or those that want to pass to a smart
14365 host any messages that cannot immediately be delivered.
14366
14367 There are occasional other temporary errors that can occur while doing DNS
14368 lookups. They are treated in the same way as a timeout, and this option
14369 applies to all of them.
14370
14371
14372 .conf pass@_router string unset
14373 .index router||go to after `pass'
14374 When a router returns `pass', the address is normally handed on to the next
14375 router in sequence. This can be changed by setting \pass@_router\ to the name
14376 of another router. However (unlike \redirect@_router\) the named router must be
14377 below the current router, to avoid loops. Note that this option applies only to
14378 the special case of `pass'. It does not apply when a router returns `decline'.
14379
14380
14381 .conf redirect@_router string unset
14382 .index router||start at after redirection
14383 Sometimes an administrator knows that it is pointless to reprocess addresses
14384 generated from alias or forward files with the same router again. For
14385 example, if an alias file translates real names into login ids there is no
14386 point searching the alias file a second time, especially if it is a large file.
14387
14388 The \redirect@_router\ option can be set to the name of any router instance. It
14389 causes the routing of any generated addresses to start at the named router
14390 instead of at the first router. This option has no effect if the router in
14391 which it is set does not generate new addresses.
14392
14393
14394 .conf require@_files "string list$**$ (precondition)" unset
14395 .index file||requiring for router
14396 .index router||requiring file existence
14397 This option provides a general mechanism for predicating the running of a
14398 router on the existence or non-existence of certain files or directories.
14399 Before running a router, as one of its precondition tests, Exim works its way
14400 through the \require@_files\ list, expanding each item separately.
14401
14402 Because the list is split before expansion, any colons in expansion items must
14403 be doubled, or the facility for using a different list separator must be used.
14404 If any expansion is forced to fail, the item is ignored. Other expansion
14405 failures cause routing of the address to be deferred.
14406
14407 If any expanded string is empty, it is ignored. Otherwise, except as described
14408 below, each string must be a fully qualified file path, optionally preceded by
14409 `!'. The paths are passed to the \*stat()*\ function to test for the existence
14410 of the files or directories. The router is skipped if any paths not preceded by
14411 `!' do not exist, or if any paths preceded by `!' do exist.
14412
14413 .index NFS
14414 If \*stat()*\ cannot determine whether a file exists or not, delivery of
14415 the message is deferred. This can happen when NFS-mounted filesystems are
14416 unavailable.
14417
14418 This option is checked after the \domains\, \local@_parts\, and \senders\
14419 options, so you cannot use it to check for the existence of a file in which to
14420 look up a domain, local part, or sender. (See section ~~SECTrouprecon for a
14421 full list of the order in which preconditions are evaluated.) However, as
14422 these options are all expanded, you can use the \exists\ expansion condition to
14423 make such tests. The \require@_files\ option is intended for checking files
14424 that the router may be going to use internally, or which are needed by a
14425 transport (for example \(.procmailrc)\).
14426
14427 During delivery, the \*stat()*\ function is run as root, but there is a
14428 facility for some checking of the accessibility of a file by another user.
14429 This is not a proper permissions check, but just a `rough' check that
14430 operates as follows:
14431
14432 If an item in a \require@_files\ list does not contain any forward slash
14433 characters, it is taken to be the user (and optional group, separated by a
14434 comma) to be checked for subsequent files in the list. If no group is specified
14435 but the user is specified symbolically, the gid associated with the uid is
14436 used. For example:
14437 .display asis
14438 require_files = mail:/some/file
14439 require_files = $local_part:$home/.procmailrc
14440 .endd
14441 If a user or group name in a \require@_files\ list does not exist, the
14442 \require@_files\ condition fails.
14443
14444 Exim performs the check by scanning along the components of the file path, and
14445 checking the access for the given uid and gid. It checks for `x' access on
14446 directories, and `r' access on the final file. Note that this means that file
14447 access control lists, if the operating system has them, are ignored.
14448
14449 \**Warning 1**\: When the router is being run to verify addresses for an
14450 incoming SMTP message, Exim is not running as root, but under its own uid. This
14451 may affect the result of a \require@_files\ check. In particular, \*stat()*\
14452 may yield the error \\EACCES\\ (`Permission denied'). This means that the Exim
14453 user is not permitted to read one of the directories on the file's path.
14454
14455 \**Warning 2**\: Even when Exim is running as root while delivering a message,
14456 \*stat()*\ can yield \\EACCES\\ for a file in an NFS directory that is mounted
14457 without root access.
14458 .em
14459 In this case, if a check for access by a particular user is requested, Exim 
14460 creates a subprocess that runs as that user, and tries the check again in that
14461 process.
14462
14463 The default action for handling an unresolved \\EACCES\\ is to consider it to
14464 be caused by a configuration error,
14465 .nem
14466 and routing is deferred because the existence or non-existence of the file
14467 cannot be determined. However, in some circumstances it may be desirable to
14468 treat this condition as if the file did not exist. If the file name (or the
14469 exclamation mark that precedes the file name for non-existence) is preceded by
14470 a plus sign, the \\EACCES\\ error is treated as if the file did not exist. For
14471 example:
14472 .display asis
14473 require_files = +/some/file
14474 .endd
14475 If the router is not an essential part of verification (for example, it
14476 handles users' \(.forward)\ files), another solution is to set the \verify\
14477 option false so that the router is skipped when verifying.
14478
14479
14480 .conf retry@_use@_local@_part boolean "see below"
14481 .index hints database||retry keys
14482 .index local part||in retry keys
14483 When a delivery suffers a temporary routing failure, a retry record is created
14484 in Exim's hints database. For addresses whose routing depends only on the
14485 domain, the key for the retry record should not involve the local part, but for
14486 other addresses, both the domain and the local part should be included.
14487 Usually, remote routing is of the former kind, and local routing is of the
14488 latter kind.
14489
14490 This option controls whether the local part is used to form the key for retry
14491 hints for addresses that suffer temporary errors while being handled by this
14492 router. The default value is true for any router that has \check@_local@_user\
14493 set, and false otherwise. Note that this option does not apply to hints keys
14494 for transport delays; they are controlled by a generic transport option of the
14495 same name.
14496
14497 The setting of \retry@_use@_local@_part\ applies only to the router on which it
14498 appears. If the router generates child addresses, they are routed
14499 independently; this setting does not become attached to them.
14500
14501
14502 .conf router@_home@_directory string$**$ unset
14503 .index router||home directory for
14504 .index home directory||for router
14505 This option sets a home directory for use while the router is running. (Compare
14506 \transport__home@_directory\, which sets a home directory for later
14507 transporting.) In particular, if used on a \%redirect%\ router, this option
14508 sets a value for \$home$\ while a filter is running. The value is expanded;
14509 forced expansion failure causes the option to be ignored -- other failures
14510 cause the router to defer.
14511
14512 Expansion of \router@_home@_directory\ happens immediately after the
14513 \check@_local@_user\ test (if configured), before any further expansions take
14514 place.
14515 (See section ~~SECTrouprecon for a list of the order in which preconditions
14516 are evaluated.)
14517 While the router is running, \router__home@_directory\ overrides the value of
14518 \$home$\ that came from \check@_local@_user\.
14519
14520 When a router accepts an address and routes it to a transport (including the
14521 cases when a redirect router generates a pipe, file, or autoreply delivery),
14522 the home directory setting for the transport is taken from the first of these
14523 values that is set:
14524 .numberpars $.
14525 The \home@_directory\ option on the transport;
14526 .nextp
14527 The \transport@_home@_directory\ option on the router;
14528 .nextp
14529 The password data if \check@_local@_user\ is set on the router;
14530 .nextp
14531 The \router@_home@_directory\ option on the router.
14532 .endp
14533 In other words, \router@_home@_directory\ overrides the password data for the
14534 router, but not for the transport.
14535
14536
14537 .conf self string "freeze"
14538 .index MX record||pointing to local host
14539 .index local host||MX pointing to
14540 This option applies to those routers that use a recipient address to find a
14541 list of remote hosts. Currently, these are the \%dnslookup%\, \%ipliteral%\,
14542 and \%manualroute%\ routers.
14543 Certain configurations of the \%queryprogram%\ router can also specify a list
14544 of remote hosts.
14545 Usually such routers are configured to send the message to a remote host via an
14546 \%smtp%\ transport. The \self\ option specifies what happens when the first
14547 host on the list turns out to be the local host.
14548 The way in which Exim checks for the local host is described in section
14549 ~~SECTreclocipadd.
14550
14551 Normally this situation indicates either an error in Exim's configuration (for
14552 example, the router should be configured not to process this domain), or an
14553 error in the DNS (for example, the MX should not point to this host). For this
14554 reason, the default action is to log the incident, defer the address, and
14555 freeze the message. The following alternatives are provided for use in special
14556 cases:
14557 .numberpars $.
14558 \defer\
14559 .newline
14560 Delivery of the message is tried again later, but the message is not frozen.
14561 .nextp
14562 \reroute: <<domain>>\
14563 .newline
14564 The domain is changed to the given domain, and the address is passed back to
14565 be reprocessed by the routers. No rewriting of headers takes place. This
14566 behaviour is essentially a redirection.
14567 .nextp
14568 \reroute: rewrite: <<domain>>\
14569 .newline
14570 The domain is changed to the given domain, and the address is passed back to be
14571 reprocessed by the routers. Any headers that contain the original domain are
14572 rewritten.
14573 .nextp
14574 \pass\
14575 .newline
14576 The router passes the address to the next router, or to the router named in the
14577 \pass@_router\ option if it is set.
14578 .index \more\ option
14579 This overrides \no@_more\.
14580
14581 During subsequent routing and delivery, the variable
14582 \$self@_hostname$\ contains the name of the local host that the router
14583 encountered. This can be used to distinguish between different cases for hosts
14584 with multiple names. The combination
14585 .display asis
14586 self = pass
14587 no_more
14588 .endd
14589 ensures that only those addresses that routed to the local host are passed on.
14590 Without \no@_more\, addresses that were declined for other reasons would also
14591 be passed to the next router.
14592 .nextp
14593 \fail\
14594 .newline
14595 Delivery fails and an error report is generated.
14596 .nextp
14597 \send\
14598 .newline
14599 .index local host||sending to
14600 The anomaly is ignored and the address is queued for the transport. This
14601 setting should be used with extreme caution. For an \%smtp%\ transport, it makes
14602 sense only in cases where the program that is listening on the SMTP port is not
14603 this version of Exim. That is, it must be some other MTA, or Exim with a
14604 different configuration file that handles the domain in another way.
14605 .endp
14606
14607 .conf senders "address list$**$ (precondition)" unset
14608 .index router||checking senders
14609 If this option is set, the router is skipped unless the message's sender
14610 address matches something on the list.
14611 See section ~~SECTrouprecon for a list of the order in which preconditions
14612 are evaluated.
14613
14614 There are issues concerning verification when the running of routers is
14615 dependent on the sender. When Exim is verifying the address in an \errors@_to\
14616 setting, it sets the sender to the null string. When using the \-bt-\ option to
14617 check a configuration file, it is necessary also to use the \-f-\ option to set
14618 an appropriate sender. For incoming mail, the sender is unset when verifying
14619 the sender, but is available when verifying any recipients. If the SMTP
14620 \\VRFY\\ command is enabled, it must be used after \\MAIL\\ if the sender
14621 address matters.
14622
14623 .conf translate@_ip@_address string$**$ unset
14624 .index IP address||translating
14625 .index packet radio
14626 .index router||IP address translation
14627 There exist some rare networking situations (for example, packet radio) where
14628 it is helpful to be able to translate IP addresses generated by normal routing
14629 mechanisms into other IP addresses, thus performing a kind of manual IP
14630 routing. This should be done only if the normal IP routing of the TCP/IP stack
14631 is inadequate or broken. Because this is an extremely uncommon requirement, the
14632 code to support this option is not included in the Exim binary unless
14633 \\SUPPORT__TRANSLATE__IP__ADDRESS\\=yes is set in \(Local/Makefile)\.
14634
14635 The \translate@_ip@_address\ string is expanded for every IP address generated
14636 by the router, with the generated address set in \$host@_address$\. If the
14637 expansion is forced to fail, no action is taken.
14638 For any other expansion error, delivery of the message is deferred.
14639 If the result of the expansion is an IP address, that replaces the original
14640 address; otherwise the result is assumed to be a host name -- this is looked up
14641 using \*gethostbyname()*\ (or \*getipnodebyname()*\ when available) to produce
14642 one or more replacement IP addresses. For example, to subvert all IP addresses
14643 in some specific networks, this could be added to a router:
14644 .display
14645 $smc{translate@_ip@_address = @\
14646   @$@{lookup@{@$@{mask:@$host@_address/26@}@}lsearch@{/some/file@}@{@$value@}fail@}}
14647 .endd
14648 The file would contain lines like
14649 .display asis
14650 10.2.3.128/26    some.host
14651 10.8.4.34/26     10.44.8.15
14652 .endd
14653 You should not make use of this facility unless you really understand what you
14654 are doing.
14655
14656
14657 .conf transport string$**$ unset
14658 This option specifies the transport to be used when a router accepts an address
14659 and sets it up for delivery. A transport is never needed if a router is used
14660 only for verification. The value of the option is expanded at routing time,
14661 after the expansion of \errors@_to\, \headers@_add\, and \headers@_remove\, and
14662 result must be the name of one of the configured transports. If it is not,
14663 delivery is deferred.
14664
14665 The \transport\ option is not used by the \%redirect%\ router, but it does have
14666 some private options that set up transports for pipe and file deliveries (see
14667 chapter ~~CHAPredirect).
14668
14669
14670 .conf transport@_current@_directory string$**$ unset
14671 .index current directory for local transport
14672 This option associates a current directory with any address that is routed
14673 to a local transport. This can happen either because a transport is
14674 explicitly configured for the router, or because it generates a delivery to a
14675 file or a pipe. During the delivery process (that is, at transport time), this
14676 option string is expanded and is set as the current directory, unless
14677 overridden by a setting on the transport.
14678 If the expansion fails for any reason, including forced failure, an error is
14679 logged, and delivery is deferred.
14680 See chapter ~~CHAPenvironment for details of the local delivery environment.
14681
14682
14683
14684 .conf transport@_home@_directory string$**$ "see below"
14685 .index home directory||for local transport
14686 This option associates a home directory with any address that is routed to a
14687 local transport. This can happen either because a transport is explicitly
14688 configured for the router, or because it generates a delivery to a file or a
14689 pipe. During the delivery process (that is, at transport time), the option
14690 string is expanded and is set as the home directory, unless overridden by a
14691 setting of \home@_directory\ on the transport.
14692 If the expansion fails for any reason, including forced failure, an error is
14693 logged, and delivery is deferred.
14694
14695 If the transport does not specify a home directory, and
14696 \transport@_home@_directory\ is not set for the router, the home directory for
14697 the tranport is taken from the password data if \check@_local@_user\ is set for
14698 the router. Otherwise it is taken from \router@_home@_directory\ if that option
14699 is set; if not, no home directory is set for the transport.
14700
14701 See chapter ~~CHAPenvironment for further details of the local delivery
14702 environment.
14703
14704
14705
14706 .conf unseen boolean$**$ false
14707 .index router||carrying on after success
14708 The result of string expansion for this option must be a valid boolean value,
14709 that is, one of the strings `yes', `no', `true', or `false'. Any other result
14710 causes an error, and delivery is deferred. If the expansion is forced to fail,
14711 the default value for the option (false) is used. Other failures cause delivery
14712 to be deferred.
14713
14714 When this option is set true, routing does not cease if the router accepts the
14715 address. Instead, a copy of the incoming address is passed to the next router,
14716 overriding a false setting of \more\. There is little point in setting \more\
14717 false if \unseen\ is always true, but it may be useful in cases when the value
14718 of \unseen\ contains expansion items (and therefore, presumably, is sometimes
14719 true and sometimes false).
14720
14721 The \unseen\ option can be used to cause
14722 .index copy of message (\unseen\ option)
14723 copies of messages to be delivered to some other destination, while also
14724 carrying out a normal delivery. In effect, the current address is made into a
14725 `parent' that has two children -- one that is delivered as specified by this
14726 router, and a clone that goes on to be routed further.
14727
14728 Header lines added to the address (or specified for removal) by this router or
14729 by previous routers affect the `unseen' copy of the message only. The clone
14730 that continues to be processed by further routers starts with no added headers
14731 and none specified for removal.
14732
14733 However, any data that was set by the \address@_data\ option in the current or
14734 previous routers is passed on. Setting this option has a similar effect to the
14735 \unseen\ command qualifier in filter files.
14736
14737
14738 .conf user string$**$ "see below"
14739 .index uid (user id)||local delivery
14740 .index local transports||uid and gid
14741 .index transport||local
14742 .index router||user for filter processing
14743 .index filter||user for processing
14744 When a router queues an address for a transport, and the transport does not
14745 specify a user, the user given here is used when running the delivery process.
14746 The user may be specified numerically or by name. If expansion fails, the
14747 error is logged and delivery is deferred.
14748 This user is also used by the \%redirect%\ router when running a filter file.
14749 The default is unset, except when \check@_local@_user\ is set. In this case,
14750 the default is taken from the password information. If the user is specified as
14751 a name, and \group\ is not set, the group associated with the user is used. See
14752 also \initgroups\ and \group\ and the discussion in chapter ~~CHAPenvironment.
14753
14754
14755 .conf verify "boolean (precondition)" true
14756 Setting this option has the effect of setting \verify@_sender\ and
14757 \verify@_recipient\ to the same value.
14758
14759 .conf verify@_only "boolean (precondition)" false
14760 .index \\EXPN\\||with \verify@_only\
14761 .index \-bv-\ option
14762 .index router||used only when verifying
14763 If this option is set, the router is used only when verifying an address or
14764 testing with the \-bv-\ option, not when actually doing a delivery, testing
14765 with the \-bt-\ option, or running the SMTP \\EXPN\\ command. It can be further
14766 restricted to verifying only senders or recipients by means of \verify@_sender\
14767 and \verify@_recipient\.
14768
14769 \**Warning**\: When the router is being run to verify addresses for an incoming
14770 SMTP message, Exim is not running as root, but under its own uid. If the router
14771 accesses any files, you need to make sure that they are accessible to the Exim
14772 user or group.
14773
14774 .conf verify@_recipient "boolean (precondition)" true
14775 If this option is false, the router is skipped when verifying recipient
14776 addresses
14777 or testing recipient verification using \-bv-\.
14778 See section ~~SECTrouprecon for a list of the order in which preconditions
14779 are evaluated.
14780
14781 .conf verify@_sender "boolean (precondition)" true
14782 If this option is false, the router is skipped when verifying sender addresses
14783 or testing sender verification using \-bvs-\.
14784 See section ~~SECTrouprecon for a list of the order in which preconditions
14785 are evaluated.
14786
14787 .endconf
14788
14789
14790
14791
14792
14793 .
14794 .
14795 .
14796 .
14797 . ============================================================================
14798 .chapter The accept router
14799 .set runningfoot "accept router"
14800 .index \%accept%\ router
14801 .index routers||\%accept%\
14802 The \%accept%\ router has no private options of its own. Unless it is being used
14803 purely for verification (see \verify@_only\) a transport is required to be
14804 defined by the generic \transport\ option. If the preconditions that are
14805 specified by generic options are met, the router accepts the address and queues
14806 it for the given transport. The most common use of this router is for setting
14807 up deliveries to local mailboxes. For example:
14808 .display asis
14809 localusers:
14810   driver = accept
14811   domains = mydomain.example
14812   check_local_user
14813   transport = local_delivery
14814 .endd
14815 The \domains\ condition in this example checks the domain of the address, and
14816 \check@_local@_user\ checks that the local part is the login of a local user.
14817 When both preconditions are met, the \%accept%\ router runs, and queues the
14818 address for the \%local@_delivery%\ transport.
14819
14820
14821
14822
14823
14824
14825 .
14826 .
14827 .
14828 .
14829 . ============================================================================
14830 .chapter The dnslookup router
14831 .rset CHAPdnslookup "~~chapter"
14832 .set runningfoot "dnslookup router"
14833 .index \%dnslookup%\ router
14834 .index routers||\%dnslookup%\
14835 The \%dnslookup%\ router looks up the hosts that handle mail for the 
14836 recipient's domain in the DNS. A transport must always be set for this router,
14837 unless \verify@_only\ is set.
14838
14839 If SRV support is configured (see \check@_srv\ below), Exim first searches for
14840 SRV records. If none are found, or if SRV support is not configured,
14841 MX records are looked up. If no MX records exist, address records are sought.
14842 However, \mx@_domains\ can be set to disable the direct use of address records.
14843
14844 MX records of equal priority are sorted by Exim into a random order. Exim then
14845 looks for address records for the host names obtained from MX or SRV records.
14846 When a host has more than one IP address, they are sorted into a random order,
14847 except that IPv6 addresses are always sorted before IPv4 addresses. If all the
14848 IP addresses found are discarded by a setting of the \ignore@_target@_hosts\
14849 generic option, the router declines.
14850
14851 Unless they have the highest priority (lowest MX value), MX records that point
14852 to the local host, or to any host name that matches \hosts__treat__as__local\,
14853 are discarded, together with any other MX records of equal or lower priority.
14854
14855 .index MX record||pointing to local host
14856 .index local host||MX pointing to
14857 .index \self\ option||in \%dnslookup%\ router
14858 If the host pointed to by the highest priority MX record, or looked up as an
14859 address record, is the local host, or matches \hosts__treat__as__local\, what
14860 happens is controlled by the generic \self\ option.
14861
14862 .em
14863 .section Problems with DNS lookups
14864 .rset SECTprowitdnsloo "~~chapter.~~section"
14865 There have been problems with DNS servers when SRV records are looked up.
14866 Some mis-behaving servers return a DNS error or timeout when a non-existent
14867 SRV record is sought. Similar problems have in the past been reported for
14868 MX records. The global \dns@_again@_means@_nonexist\ option can help with this
14869 problem, but it is heavy-handed because it is a global option.
14870
14871 For this reason, there are two options, \srv@_fail@_domains\ and
14872 \mx@_fail@_domains\, that control what happens when a DNS lookup in a
14873 \%dnslookup%\ router results in a DNS failure or a `try again' response. If an
14874 attempt to look up an SRV or MX record causes one of these results, and the
14875 domain matches the relevant list, Exim behaves as if the DNS had responded `no
14876 such record'. In the case of an SRV lookup, this means that the router proceeds
14877 to look for MX records; in the case of an MX lookup, it proceeds to look for A
14878 or AAAA records, unless the domain matches \mx@_domains\, in which case routing
14879 fails.
14880 .nem
14881
14882
14883 .section Private options for dnslookup
14884 The private options for the \%dnslookup%\ router are as follows:
14885
14886
14887 .startconf dnslookup
14888
14889 .index options||\%dnslookup%\ router
14890 .conf check@_secondary@_mx boolean false
14891 .index MX record||checking for secondary
14892 If this option is set, the router declines unless the local host is found in
14893 (and removed from) the list of hosts obtained by MX lookup. This can be used to
14894 process domains for which the local host is a secondary mail exchanger
14895 differently to other domains. The way in which Exim decides whether a host is
14896 the local host is described in section ~~SECTreclocipadd.
14897
14898 .conf check@_srv string$**$ unset
14899 .index SRV record||enabling use of
14900 The \%dnslookup%\ router supports the use of SRV records (see RFC 2782) in
14901 addition to MX and address records. The support is disabled by default. To
14902 enable SRV support, set the \check@_srv\ option to the name of the service
14903 required. For example,
14904 .display asis
14905 check_srv = smtp
14906 .endd
14907 looks for SRV records that refer to the normal smtp service. The option is
14908 expanded, so the service name can vary from message to message or address
14909 to address. This might be helpful if SRV records are being used for a
14910 submission service. If the expansion is forced to fail, the \check@_srv\
14911 option is ignored, and the router proceeds to look for MX records in the
14912 normal way.
14913
14914 When the expansion succeeds, the router searches first for SRV records for
14915 the given service (it assumes TCP protocol). A single SRV record with a
14916 host name that consists of just a single dot indicates `no such service for
14917 this domain'; if this is encountered, the router declines. If other kinds of
14918 SRV record are found, they are used to construct a host list for delivery
14919 according to the rules of RFC 2782. MX records are not sought in this case.
14920
14921 When no SRV records are found, MX records (and address records) are sought in
14922 the traditional way. In other words, SRV records take precedence over MX
14923 records, just as MX records take precedence over address records. Note that
14924 this behaviour is not sanctioned by RFC 2782, though a previous draft RFC
14925 defined it. It is apparently believed that MX records are sufficient for email
14926 and that SRV records should not be used for this purpose. However, SRV records
14927 have an additional `weight' feature which some people might find useful when
14928 trying to split an SMTP load between hosts of different power.
14929
14930 .em
14931 See section ~~SECTprowitdnsloo above for a discussion of Exim's behaviour when 
14932 there is a DNS lookup error.
14933 .nem
14934
14935 .conf mx@_domains "domain list$**$" unset
14936 .index MX record||required to exist
14937 .index SRV record||required to exist
14938 A domain that matches \mx@_domains\ is required to have either an MX or an SRV
14939 record in order to be recognised. (The name of this option could be improved.)
14940 For example, if all the mail hosts in \*fict.example*\ are known to have MX
14941 records, except for those in \*discworld.fict.example*\, you could use this
14942 setting:
14943 .display asis
14944 mx_domains = ! *.discworld.fict.example : *.fict.example
14945 .endd
14946 This specifies that messages addressed to a domain that matches the list but
14947 has no MX record should be bounced immediately instead of being routed using
14948 the address record.
14949
14950 .em
14951 .conf mx@_fail@_domains "domain list$**$" unset
14952 If the DNS lookup for MX records for one of the domains in this list causes a
14953 DNS lookup error, Exim behaves as if no MX records were found. See section
14954 ~~SECTprowitdnsloo for more discussion.
14955 .nem
14956
14957
14958 .conf qualify@_single boolean true
14959 .index DNS||resolver options
14960 .index DNS||qualifying single-component names
14961 When this option is true, the resolver option \\RES@_DEFNAMES\\ is set for DNS
14962 lookups. Typically, but not standardly, this causes the resolver to qualify
14963 single-component names with the default domain. For example, on a machine
14964 called \*dictionary.ref.example*\, the domain \*thesaurus*\ would be changed to
14965 \*thesaurus.ref.example*\ inside the resolver. For details of what your resolver
14966 actually does, consult your man pages for \*resolver*\ and \*resolv.conf*\.
14967
14968
14969 .conf rewrite@_headers boolean true
14970 .index rewriting||header lines
14971 .index header lines||rewriting
14972 If the domain name in the address that is being processed is not fully
14973 qualified, it may be expanded to its full form by a DNS lookup. For example, if
14974 an address is specified as \*dormouse@@teaparty*\, the domain might be
14975 expanded to \*teaparty.wonderland.fict.example*\. Domain expansion can also
14976 occur as a result of setting the \widen@_domains\ option. If \rewrite@_headers\
14977 is true, all occurrences of the abbreviated domain name in any ::Bcc::, ::Cc::,
14978 ::From::, ::Reply-to::, ::Sender::, and ::To:: header lines of the message are
14979 rewritten with the full domain name.
14980
14981 This option should be turned off only when it is known that no message is
14982 ever going to be sent outside an environment where the abbreviation makes
14983 sense.
14984
14985 When an MX record is looked up in the DNS and matches a wildcard record, name
14986 servers normally return a record containing the name that has been looked up,
14987 making it impossible to detect whether a wildcard was present or not. However,
14988 some name servers have recently been seen to return the wildcard entry. If the
14989 name returned by a DNS lookup begins with an asterisk, it is not used for
14990 header rewriting.
14991
14992 .conf same@_domain@_copy@_routing boolean false
14993 .index address||copying routing
14994 Addresses with the same domain are normally routed by the \%dnslookup%\ router
14995 to the same list of hosts. However, this cannot be presumed, because the router
14996 options and preconditions may refer to the local part of the address. By
14997 default, therefore, Exim routes each address in a message independently. DNS
14998 servers run caches, so repeated DNS lookups are not normally expensive, and in
14999 any case, personal messages rarely have more than a few recipients.
15000
15001 If you are running mailing lists with large numbers of subscribers at the same
15002 domain, and you are using a \%dnslookup%\ router which is independent of the
15003 local part, you can set \same__domain__copy@_routing\ to bypass repeated DNS
15004 lookups for identical domains in one message. In this case, when \%dnslookup%\
15005 routes an address to a remote transport, any other unrouted addresses in the
15006 message that have the same domain are automatically given the same routing
15007 without processing them independently,
15008 provided the following conditions are met:
15009 .numberpars $.
15010 No router that processed the address specified \headers@_add\ or
15011 \headers@_remove\.
15012 .nextp
15013 The router did not change the address in any way, for example, by `widening'
15014 the domain.
15015 .endp
15016
15017
15018 .conf search@_parents boolean false
15019 .index DNS||resolver options
15020 When this option is true, the resolver option \\RES@_DNSRCH\\ is set for DNS
15021 lookups. This is different from the \qualify@_single\ option in that it applies
15022 to domains containing dots. Typically, but not standardly, it causes the
15023 resolver to search for the name in the current domain and in parent domains.
15024 For example, on a machine in the \*fict.example*\ domain, if looking up
15025 \*teaparty.wonderland*\ failed, the resolver would try
15026 \*teaparty.wonderland.fict.example*\. For details of what your resolver
15027 actually does, consult your man pages for \*resolver*\ and \*resolv.conf*\.
15028
15029 Setting this option true can cause problems in domains that have a wildcard MX
15030 record, because any domain that does not have its own MX record matches the
15031 local wildcard.
15032
15033
15034 .em
15035 .conf srv@_fail@_domains "domain list$**$" unset
15036 If the DNS lookup for SRV records for one of the domains in this list causes a
15037 DNS lookup error, Exim behaves as if no SRV records were found. See section
15038 ~~SECTprowitdnsloo for more discussion.
15039 .nem
15040
15041
15042 .conf widen@_domains "string list" unset
15043 .index domain||partial, widening
15044 If a DNS lookup fails and this option is set, each of its strings in turn is
15045 added onto the end of the domain, and the lookup is tried again. For example,
15046 if
15047 .display asis
15048 widen_domains = fict.example:ref.example
15049 .endd
15050 is set and a lookup of \*klingon.dictionary*\ fails,
15051 \*klingon.dictionary.fict.example*\ is looked up, and if this fails,
15052 \*klingon.dictionary.ref.example*\ is tried. Note that the \qualify@_single\
15053 and \search@_parents\ options can cause some widening to be undertaken inside
15054 the DNS resolver.
15055
15056 .endconf
15057
15058 .section Effect of qualify@_single and search@_parents
15059 When a domain from an envelope recipient is changed by the resolver as a result
15060 of the \qualify@_single\ or \search@_parents\ options, Exim rewrites the
15061 corresponding address in the message's header lines unless \rewrite@_headers\
15062 is set false. Exim then re-routes the address, using the full domain.
15063
15064 These two options affect only the DNS lookup that takes place inside the router
15065 for the domain of the address that is being routed. They do not affect lookups
15066 such as that implied by
15067 .display asis
15068 domains = @mx_any
15069 .endd
15070 that may happen while processing a router precondition before the router is
15071 entered. No widening ever takes place for these lookups.
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081 .
15082 .
15083 .
15084 .
15085 . ============================================================================
15086 .chapter The ipliteral router
15087 .set runningfoot "ipliteral router"
15088 .index \%ipliteral%\ router
15089 .index domain literal||routing
15090 .index routers||\%ipliteral%\
15091 This router has no private options. Unless it is being used purely for
15092 verification (see \verify@_only\) a transport is required to be defined by the
15093 generic \transport\ option. The router accepts the address if its domain part
15094 takes the form of an RFC 2822 domain literal, that is, an IP address enclosed
15095 in square brackets. For example, this router handles the address
15096 .display asis
15097 root@[192.168.1.1]
15098 .endd
15099 by setting up delivery to the host with that IP address.
15100
15101 If the IP address matches something in \ignore@_target@_hosts\, the router
15102 declines.
15103 .index \self\ option||in \%ipliteral%\ router
15104 If an IP literal turns out to refer to the local host, the generic \self\
15105 option determines what happens.
15106
15107 The RFCs require support for domain literals; however, their use is
15108 controversial in today's Internet. If you want to use this router, you must
15109 also set the main configuration option \allow@_domain@_literals\. Otherwise,
15110 Exim will not recognize the domain literal syntax in addresses.
15111
15112
15113
15114 .
15115 .
15116 .
15117 .
15118 . ============================================================================
15119 .chapter The iplookup router
15120 .set runningfoot "iplookup router"
15121 .index \%iplookup%\ router
15122 .index routers||\%iplookup%\
15123 The \%iplookup%\ router was written to fulfil a specific requirement in
15124 Cambridge University (which in fact no longer exists). For this reason, it is
15125 not included in the binary of Exim by default. If you want to include it, you
15126 must set
15127 .display asis
15128 ROUTER_IPLOOKUP=yes
15129 .endd
15130 in your \(Local/Makefile)\ configuration file.
15131
15132 The \%iplookup%\ router routes an address by sending it over a TCP or UDP
15133 connection to one or more specific hosts. The host can then return the same or
15134 a different address -- in effect rewriting the recipient address in the
15135 message's envelope. The new address is then passed on to subsequent routers.
15136
15137
15138 If this process fails, the address can be passed on to
15139 other routers, or delivery can be deferred.
15140
15141 Background, for those that are interested: We have an Oracle database of all
15142 Cambridge users, and one of the items of data it maintains for each user is
15143 where to send mail addressed to \*user@@cam.ac.uk*\. The MX records for
15144 \*cam.ac.uk*\ point to a central machine that has a large alias list that is
15145 abstracted from the database. Mail from outside is switched by this system, and
15146 originally internal mail was also done this way. However, this resulted in a
15147 fair number of messages travelling from some of our larger systems to the
15148 switch and back again. The Oracle machine now runs a UDP service that can be
15149 called by the \%iplookup%\ router in Exim to find out where \*user@@cam.ac.uk*\
15150 addresses really have to go; this saves passing through the central switch, and
15151 in many cases saves doing any remote delivery at all.
15152
15153 Since \%iplookup%\ is just a rewriting router, a transport must not be
15154 specified for it.
15155
15156 .startconf iplookup
15157 .index options||\%iplookup%\ router
15158
15159 .conf hosts string unset
15160 This option must be supplied. Its value is a colon-separated list of host
15161 names. The hosts are looked up using \*gethostbyname()*\
15162 (or \*getipnodebyname()*\ when available)
15163 and are tried in order until one responds to the query. If none respond, what
15164 happens is controlled by \optional\.
15165
15166 .conf optional boolean false
15167 If \optional\ is true, if no response is obtained from any host, the address is
15168 passed to the next router, overriding \no@_more\. If \optional\ is false,
15169 delivery to the address is deferred.
15170
15171 .conf port integer 0
15172 .index port||\%iplookup%\ router
15173 This option must be supplied. It specifies the port number for the TCP or UDP
15174 call.
15175
15176 .conf protocol string "udp"
15177 This option can be set to `udp' or `tcp' to specify which of the two protocols
15178 is to be used.
15179
15180 .conf query string$**$ "$tt{@$local@_part@@@$domain @$local@_part@@@$domain}"
15181 This defines the content of the query that is sent to the remote hosts. The
15182 repetition serves as a way of checking that a response is to the correct query
15183 in the default case (see \response@_pattern\ below).
15184
15185 .conf reroute string$**$ unset
15186 If this option is not set, the rerouted address is precisely the byte string
15187 returned by the remote host, up to the first white space, if any. If set, the
15188 string is expanded to form the rerouted address. It can include parts matched
15189 in the response by \response@_pattern\ by means of numeric variables such as
15190 \$1$\, \$2$\, etc. The variable \$0$\ refers to the entire input string,
15191 whether or not a pattern is in use. In all cases, the rerouted address must end
15192 up in the form \*local@_part@@domain*\.
15193
15194 .conf response@_pattern string unset
15195 This option can be set to a regular expression that is applied to the string
15196 returned from the remote host. If the pattern does not match the response, the
15197 router declines. If \response@_pattern\ is not set, no checking of the response
15198 is done, unless the query was defaulted, in which case there is a check that
15199 the text returned after the first white space is the original address. This
15200 checks that the answer that has been received is in response to the correct
15201 question. For example, if the response is just a new domain, the following
15202 could be used:
15203 .display asis
15204 response_pattern = ^([^@]+)$
15205 reroute = $local_part@$1
15206 .endd
15207
15208 .conf timeout time 5s
15209 This specifies the amount of time to wait for a response from the remote
15210 machine. The same timeout is used for the \*connect()*\ function for a TCP
15211 call. It does not apply to UDP.
15212
15213 .endconf
15214
15215
15216
15217
15218 .
15219 .
15220 .
15221 .
15222 . ============================================================================
15223 .chapter The manualroute router
15224 .set runningfoot "manualroute router"
15225 .index \%manualroute%\ router
15226 .index routers||\%manualroute%\
15227 .index domain||manually routing
15228 The \%manualroute%\ router is so-called because it provides a way of manually
15229 routing an address according to its domain. It is mainly used when you want to
15230 route addresses to remote hosts according to your own rules, bypassing the
15231 normal DNS routing that looks up MX records. However, \%manualroute%\ can also
15232 route to local transports, a facility that may be useful if you want to save
15233 messages for dial-in hosts in local files.
15234
15235 The \%manualroute%\ router compares a list of domain patterns with the domain it
15236 is trying to route. If there is no match, the router declines. Each pattern has
15237 associated with it a list of hosts and some other optional data, which may
15238 include a transport. The combination of a pattern and its data is called a
15239 `routing rule'. For patterns that do not have an associated transport, the
15240 generic \transport\ option must specify a transport, unless the router is being
15241 used purely for verification (see \verify@_only\).
15242
15243 In the case of verification, matching the domain pattern is sufficient for the
15244 router to accept the address. When actually routing an address for delivery,
15245 an address that matches a domain pattern is queued for the associated
15246 transport. If the transport is not a local one, a host list must be associated
15247 with the pattern; IP addresses are looked up for the hosts, and these are
15248 passed to the transport along with the mail address. For local transports, a
15249 host list is optional. If it is present, it is passed in \$host$\ as a single
15250 text string.
15251
15252 The list of routing rules can be provided as an inline string in \route@_list\,
15253 or the data can be obtained by looking up the domain in a file or database by
15254 setting \route@_data\. Only one of these settings may appear in any one
15255 instance of \%manualroute%\. The format of routing rules is described below,
15256 following the list of private options.
15257
15258 .section Private options for manualroute
15259 .rset SECTprioptman "~~chapter.~~section"
15260
15261 The private options for the \%manualroute%\ router are as follows:
15262
15263 .startconf manualroute
15264 .index options||\%manualroute%\ router
15265
15266 .conf host@_find@_failed string "freeze"
15267 This option controls what happens when \%manualroute%\ tries to find an IP
15268 address for a host, and the host does not exist. The option can be set to one
15269 of
15270 .display asis
15271 decline
15272 defer
15273 fail
15274 freeze
15275 pass
15276 .endd
15277 The default assumes that this state is a serious configuration error. The
15278 difference between `pass' and `decline' is that the former forces the address
15279 to be passed to the next router (or the router defined by \pass@_router\),
15280 .index \more\ option
15281 overriding \no@_more\, whereas the latter passes the address to the next router
15282 only if \more\ is true.
15283
15284 This option applies only to a definite `does not exist' state; if a host lookup
15285 gets a temporary error, delivery is deferred unless the generic
15286 \pass@_on@_timeout\ option is set.
15287
15288 .conf hosts@_randomize boolean false
15289 .index randomized host list
15290 .index host||list of, randomized
15291 If this option is set, the order of the items in a host list in a routing rule
15292 is randomized each time the list is used, unless an option in the routing rule
15293 overrides (see below). Randomizing the order of a host list can be used to do
15294 crude load sharing. However, if more than one mail address is routed by the
15295 same router to the same host list, the host lists are considered to be the same
15296 (even though they may be randomized into different orders) for the purpose of
15297 deciding whether to batch the deliveries into a single SMTP transaction.
15298
15299 When \hosts@_randomize\ is true, a host list may be split
15300 into groups whose order is separately randomized. This makes it possible to
15301 set up MX-like behaviour. The boundaries between groups are indicated by an
15302 item that is just \"+"\ in the host list. For example:
15303 .display asis
15304 route_list = * host1:host2:host3:+:host4:host5
15305 .endd
15306 The order of the first three hosts and the order of the last two hosts is
15307 randomized for each use, but the first three always end up before the last two.
15308 If \hosts@_randomize\ is not set, a \"+"\ item in the list is ignored. If a
15309 randomized host list is passed to an \%smtp%\ transport that also has
15310 \hosts@_randomize set\, the list is not re-randomized.
15311
15312 .conf route@_data string$**$ unset
15313 If this option is set, it must expand to yield the data part of a routing rule.
15314 Typically, the expansion string includes a lookup based on the domain. For
15315 example:
15316 .display asis
15317 route_data = ${lookup{$domain}dbm{/etc/routes}}
15318 .endd
15319 If the expansion is forced to fail, or the result is an empty string, the
15320 router declines. Other kinds of expansion failure cause delivery to be
15321 deferred.
15322
15323 .conf route@_list "string list, semicolon-separated" unset
15324 This string is a list of routing rules, in the form defined below. Note that,
15325 unlike most string lists, the items are separated by semicolons. This is so
15326 that they may contain colon-separated host lists.
15327
15328 .conf same@_domain@_copy@_routing boolean false
15329 .index address||copying routing
15330 Addresses with the same domain are normally routed by the \%manualroute%\ router
15331 to the same list of hosts. However, this cannot be presumed, because the router
15332 options and preconditions may refer to the local part of the address. By
15333 default, therefore, Exim routes each address in a message independently. DNS
15334 servers run caches, so repeated DNS lookups are not normally expensive, and in
15335 any case, personal messages rarely have more than a few recipients.
15336
15337 If you are running mailing lists with large numbers of subscribers at the same
15338 domain, and you are using a \%manualroute%\ router which is independent of the
15339 local part, you can set \same@_domain@_copy@_routing\ to bypass repeated DNS
15340 lookups for identical domains in one message. In this case, when \%manualroute%\
15341 routes an address to a remote transport, any other unrouted addresses in the
15342 message that have the same domain are automatically given the same routing
15343 without processing them independently. However, this is only done if
15344 \headers@_add\ and \headers@_remove\ are unset.
15345
15346 .endconf
15347
15348
15349 .section Routing rules in route@_list
15350 The value of \route@_list\ is a string consisting of a sequence of routing
15351 rules, separated by semicolons. If a semicolon is needed in a rule, it can be
15352 entered as two semicolons. Empty rules are ignored. The format of each rule is
15353 .display
15354 <<domain pattern>>  <<list of hosts>>  <<options>>
15355 .endd
15356 The following example contains two rules, each with a simple domain pattern and
15357 no options:
15358 .display asis
15359 route_list = \
15360   dict.ref.example  mail-1.ref.example:mail-2.ref.example ; \
15361   thes.ref.example  mail-3.ref.example:mail-4.ref.example
15362 .endd
15363 The three parts of a rule are separated by white space. The pattern and the
15364 list of hosts can be enclosed in quotes if necessary, and if they are, the
15365 usual quoting rules apply. Each rule in a \route@_list\ must start with a
15366 single domain pattern, which is the only mandatory item in the rule. The
15367 pattern is in the same format as one item in a domain list (see section
15368 ~~SECTdomainlist),
15369 except that it may not be the name of an interpolated file.
15370 That is, it may be wildcarded, or a regular expression, or a file or database
15371 lookup (with semicolons doubled, because of the use of semicolon as a separator
15372 in a \route@_list\).
15373
15374 The rules in \route@_list\ are searched in order until one of the patterns
15375 matches the domain that is being routed. The list of hosts and then options are
15376 then used as described below. If there is no match, the router declines. When
15377 \route@_list\ is set, \route@_data\ must not be set.
15378
15379
15380 .section Routing rules in route@_data
15381 The use of \route@_list\ is convenient when there are only a small number of
15382 routing rules. For larger numbers, it is easier to use a file or database to
15383 hold the routing information, and use the \route@_data\ option instead.
15384 The value of \route@_data\ is a list of hosts, followed by (optional) options.
15385 Most commonly, \route@_data\ is set as a string that contains an
15386 expansion lookup. For example, suppose we place two routing rules in a file
15387 like this:
15388 .display asis
15389 dict.ref.example:  mail-1.ref.example:mail-2.ref.example
15390 thes.ref.example:  mail-3.ref.example:mail-4.ref.example
15391 .endd
15392 This data can be accessed by setting
15393 .display asis
15394 route_data = ${lookup{$domain}lsearch{/the/file/name}}
15395 .endd
15396 Failure of the lookup results in an empty string, causing the router to
15397 decline. However, you do not have to use a lookup in \route@_data\. The only
15398 requirement is that the result of expanding the string is a list of hosts,
15399 possibly followed by options, separated by white space. The list of hosts must
15400 be enclosed in quotes if it contains white space.
15401
15402
15403
15404 .section Format of the list of hosts
15405 A list of hosts, whether obtained via \route@_data\ or \route@_list\, is always
15406 separately expanded before use. If the expansion fails, the router declines.
15407 The result of the expansion must be a colon-separated list of names and/or
15408 IP addresses. IP addresses are not enclosed in brackets.
15409
15410 If the list of hosts was obtained from a \route@_list\ item, the following
15411 variables are set during its expansion:
15412 .index numerical variables (\$1$\, \$2$\, etc)||in \%manualroute%\ router
15413 .numberpars $.
15414 If the domain was matched against a regular expression, the numeric variables
15415 \$1$\, \$2$\, etc. may be set.
15416 .nextp
15417 \$0$\ is always set to the entire domain.
15418 .nextp
15419 \$1$\ is also set when partial matching is done in a file lookup.
15420 .nextp
15421 .index \$value$\
15422 If the pattern that matched the domain was a lookup item, the data that was
15423 looked up is available in the expansion variable \$value$\.
15424 .endp
15425
15426
15427 .section How the list of hosts is used
15428 When an address is routed to an \%smtp%\ transport by \%manualroute%\, each of
15429 the hosts is tried, in the order specified, when carrying out the SMTP
15430 delivery. However, the order can be changed by setting the \hosts@_randomize\
15431 option, either on the router (see section ~~SECTprioptman above), or on the
15432 transport.
15433
15434 Hosts may be listed by name or by IP address. An unadorned name in the list of
15435 hosts is interpreted as a host name. A name that is followed by \"/MX"\ is
15436 interpreted as an indirection to a sublist of hosts obtained by looking up MX
15437 records in the DNS. For example:
15438 .display asis
15439 route_list = *  x.y.z:p.q.r/MX:e.f.g
15440 .endd
15441 If the \hosts@_randomize\ option is set, the order of the items in the list is
15442 randomized before any lookups are done. Exim then scans the list; for any name
15443 that is not followed by \"/MX"\ it looks up an IP address. If this turns out to
15444 be an interface on the local host and the item is not the first in the list,
15445 Exim discards it and any subsequent items. If it is the first item, what
15446 happens is controlled by the
15447 .index \self\ option||in \%manualroute%\ router
15448 \self\ option of the router.
15449
15450 A name on the list that is followed by \"/MX"\ is replaced with the list of
15451 hosts obtained by looking up MX records for the name. This is always a DNS
15452 lookup; the \bydns\ and \byname\ options (see section ~~SECThowoptused below)
15453 are not relevant here. The order of these hosts is determined by the preference
15454 values in the MX records, according to the usual rules. Because randomizing
15455 happens before the MX lookup, it does not affect the order that is defined by
15456 MX preferences.
15457
15458 If the local host is present in the sublist obtained from MX records, but is
15459 not the most preferred host in that list, it and any equally or less
15460 preferred hosts are removed before the sublist is inserted into the main list.
15461
15462 If the local host is the most preferred host in the MX list, what happens
15463 depends on where in the original list of hosts the \"/MX"\ item appears. If it
15464 is not the first item (that is, there are previous hosts in the main list),
15465 Exim discards this name and any subsequent items in the main list.
15466
15467 If the MX item is first in the list of hosts, and the local host is the
15468 most preferred host, what happens is controlled by the \self\ option of the
15469 router.
15470
15471 DNS failures when lookup up the MX records are treated in the same way as DNS
15472 failures when looking up IP addresses: \pass@_on@_timeout\ and
15473 \host@_find@_failed\ are used when relevant.
15474
15475 The generic \ignore@_target@_hosts\ option applies to all hosts in the list,
15476 whether obtained from an MX lookup or not.
15477
15478
15479 .section How the options are used
15480 .rset SECThowoptused "~~chapter.~~section"
15481 The options are a sequence of words; in practice no more than three are ever
15482 present. One of the words can be the name of a transport; this overrides the
15483 \transport\ option on the router for this particular routing rule only. The
15484 other words (if present) control randomization of the list of hosts on a
15485 per-rule basis, and how the IP addresses of the hosts are to be found when
15486 routing to a remote transport. These options are as follows:
15487 .numberpars $.
15488 \randomize\: randomize the order of the hosts in this list, overriding the
15489 setting of \hosts@_randomize\ for this routing rule only.
15490 .nextp
15491 \no@_randomize\: do not randomize the order of the hosts in this list,
15492 overriding the setting of \hosts@_randomize\ for this routing rule only.
15493 .nextp
15494 \byname\: use \*getipnodebyname()*\ (\*gethostbyname()*\ on older systems) to
15495 find IP addresses. This function may ultimately cause a DNS lookup, but it may
15496 also look in \(/etc/hosts)\ or other sources of information.
15497 .nextp
15498 \bydns\: look up address records for the hosts directly in the DNS; fail if
15499 no address records are found. If there is a temporary DNS error (such as a
15500 timeout), delivery is deferred.
15501 .endp
15502 For example:
15503 .display asis
15504 route_list = domain1  host1:host2:host3  randomize bydns;\
15505              domain2  host4:host5
15506 .endd
15507 If neither \byname\ nor \bydns\ is given, Exim behaves as follows: First, a DNS
15508 lookup is done. If this yields anything other than \\HOST@_NOT@_FOUND\\, that
15509 result is used. Otherwise, Exim goes on to try a call to \*getipnodebyname()*\
15510 or \*gethostbyname()*\, and the result of the lookup is the result of that
15511 call.
15512
15513 \**Warning**\: It has been discovered that on some systems, if a DNS lookup
15514 called via \*getipnodebyname()*\ times out, \\HOST@_NOT@_FOUND\\ is returned
15515 instead of \\TRY@_AGAIN\\. That is why the default action is to try a DNS
15516 lookup first. Only if that gives a definite `no such host' is the local
15517 function called.
15518
15519
15520
15521 If no IP address for a host can be found, what happens is controlled by the
15522 \host@_find@_failed\ option.
15523
15524 When an address is routed to a local transport, IP addresses are not looked up.
15525 The host list is passed to the transport in the \$host$\ variable.
15526
15527
15528 .section Manualroute examples
15529 In some of the examples that follow, the presence of the \remote@_smtp\
15530 transport, as defined in the default configuration file, is assumed:
15531
15532 .numberpars $.
15533 .index smart host||example router
15534 The \%manualroute%\ router can be used to forward all external mail to a
15535 \*smart host*\. If you have set up, in the main part of the configuration, a
15536 named domain list that contains your local domains, for example,
15537 .display asis
15538 domainlist local_domains = my.domain.example
15539 .endd
15540 you can arrange for all other domains to be routed to a smart host by making
15541 your first router something like this:
15542 .display asis
15543 smart_route:
15544   driver = manualroute
15545   domains = !+local_domains
15546   transport = remote_smtp
15547   route_list = * smarthost.ref.example
15548 .endd
15549 This causes all non-local addresses to be sent to the single host
15550 \*smarthost.ref.example*\. If a colon-separated list of smart hosts is given,
15551 they are tried in order
15552 (but you can use \hosts@_randomize\ to vary the order each time).
15553 Another way of configuring the same thing is this:
15554 .display asis
15555 smart_route:
15556   driver = manualroute
15557   transport = remote_smtp
15558   route_list = !+local_domains  smarthost.ref.example
15559 .endd
15560 There is no difference in behaviour between these two routers as they stand.
15561 However, they behave differently if \no@_more\ is added to them. In the first
15562 example, the router is skipped if the domain does not match the \domains\
15563 precondition; the following router is always tried. If the router runs, it
15564 always matches the domain and so can never decline. Therefore, \no@_more\ would
15565 have no effect. In the second case, the router is never skipped; it always
15566 runs. However, if it doesn't match the domain, it declines. In this case
15567 \no@_more\ would prevent subsequent routers from running.
15568
15569 .nextp
15570 .index mail hub example
15571 A \*mail hub*\ is a host which receives mail for a number of domains via MX
15572 records in the DNS and delivers it via its own private routing mechanism. Often
15573 the final destinations are behind a firewall, with the mail hub being the one
15574 machine that can connect to machines both inside and outside the firewall. The
15575 \%manualroute%\ router is usually used on a mail hub to route incoming messages
15576 to the correct hosts. For a small number of domains, the routing can be inline,
15577 using the \route@_list\ option, but for a larger number a file or database
15578 lookup is easier to manage.
15579
15580 If the domain names are in fact the names of the machines to which the mail is
15581 to be sent by the mail hub, the configuration can be quite simple. For
15582 example,
15583 .display asis
15584 hub_route:
15585   driver = manualroute
15586   transport = remote_smtp
15587   route_list = *.rhodes.tvs.example  $domain
15588 .endd
15589 This configuration routes domains that match \"*.rhodes.tvs.example"\ to hosts
15590 whose names are the same as the mail domains. A similar approach can be taken
15591 if the host name can be obtained from the domain name by a string manipulation
15592 that the expansion facilities can handle. Otherwise, a lookup based on the
15593 domain can be used to find the host:
15594 .display asis
15595 through_firewall:
15596   driver = manualroute
15597   transport = remote_smtp
15598   route_data = ${lookup {$domain} cdb {/internal/host/routes}}
15599 .endd
15600 The result of the lookup must be the name or IP address of the host (or
15601 hosts) to which the address is to be routed. If the lookup fails, the route
15602 data is empty, causing the router to decline. The address then passes to the
15603 next router.
15604
15605 .nextp
15606 .index batched SMTP output example
15607 .index SMTP||batched outgoing, example
15608 You can use \%manualroute%\ to deliver messages to pipes or files in batched
15609 SMTP format for onward transportation by some other means. This is one way of
15610 storing mail for a dial-up host when it is not connected. The route list entry
15611 can be as simple as a single domain name in a configuration like this:
15612 .display asis
15613 save_in_file:
15614   driver = manualroute
15615   transport = batchsmtp_appendfile
15616   route_list = saved.domain.example
15617 .endd
15618 though often a pattern is used to pick up more than one domain. If there are
15619 several domains or groups of domains with different transport requirements,
15620 different transports can be listed in the routing information:
15621 .display asis
15622 save_in_file:
15623   driver = manualroute
15624   route_list = \
15625     *.saved.domain1.example  $domain  batch_appendfile; \
15626     *.saved.domain2.example  \
15627       ${lookup{$domain}dbm{/domain2/hosts}{$value}fail} \
15628       batch_pipe
15629 .endd
15630 The first of these just passes the domain in the \$host$\ variable, which
15631 doesn't achieve much (since it is also in \$domain$\), but the second does a
15632 file lookup to find a value to pass, causing the router to decline to handle
15633 the address if the lookup fails.
15634 .nextp
15635 .index UUCP||example of router for
15636 Routing mail directly to UUCP software is a specific case of the use of
15637 \%manualroute%\ in a gateway to another mail environment. This is an example of
15638 one way it can be done:
15639 .display asis
15640 # Transport
15641 uucp:
15642   driver = pipe
15643   user = nobody
15644   command = /usr/local/bin/uux -r - \
15645     ${substr_-5:$host}!rmail ${local_part}
15646   return_fail_output = true
15647 .endd
15648 .display asis
15649 # Router
15650 uucphost:
15651   transport = uucp
15652   driver = manualroute
15653   route_data = \
15654     ${lookup{$domain}lsearch{/usr/local/exim/uucphosts}}
15655 .endd
15656 The file \(/usr/local/exim/uucphosts)\ contains entries like
15657 .display asis
15658 darksite.ethereal.example:           darksite.UUCP
15659 .endd
15660 It can be set up more simply without adding and removing `.UUCP' but this way
15661 makes clear the distinction between the domain name
15662 \*darksite.ethereal.example*\ and the UUCP host name \*darksite*\.
15663 .endp
15664
15665
15666
15667
15668
15669
15670 .
15671 .
15672 .
15673 .
15674 . ============================================================================
15675 .chapter The queryprogram router
15676 .set runningfoot "queryprogram router"
15677 .rset CHAPdriverlast "~~chapter"
15678 .index \%queryprogram%\ router
15679 .index routers||\%queryprogram%\
15680 .index routing||by external program
15681 The \%queryprogram%\ router routes an address by running an external command and
15682 acting on its output. This is an expensive way to route, and is intended mainly
15683 for use in lightly-loaded systems, or for performing experiments. However, if
15684 it is possible to use the precondition options (\domains\, \local@_parts\,
15685 etc) to skip this router for most addresses, it could sensibly be used in
15686 special cases, even on a busy host. There are the following private options:
15687
15688 .startconf queryprogram
15689 .index options||\%queryprogram%\ router
15690 .conf command string$**$ unset
15691 This option must be set. It specifies the command that is to be run. The
15692 command is split up into a command name and arguments, and then each is
15693 expanded separately (exactly as for a \%pipe%\ transport, described in chapter
15694 ~~CHAPpipetransport).
15695
15696 .conf command@_group string unset
15697 .index gid (group id)||in \%queryprogram%\ router
15698 This option specifies a gid to be set when running the command. It must be set
15699 if \command@_user\ specifies a numerical uid. If it begins with a digit, it is
15700 interpreted as the numerical value of the gid. Otherwise it is looked up using
15701 \*getgrnam()*\.
15702
15703 .conf command@_user string unset
15704 .index uid (user id)||for \%queryprogram%\
15705 This option must be set. It specifies the uid which is set when running the
15706 command. If it begins with a digit it is interpreted as the numerical value of
15707 the uid. Otherwise, it is looked up using \*getpwnam()*\ to obtain a value for
15708 the uid and, if \command@_group\ is not set, a value for the gid also.
15709
15710 .conf current@_directory string /
15711 This option specifies an absolute path which is made the current directory
15712 before running the command.
15713
15714 .conf timeout time 1h
15715 If the command does not complete within the timeout period, its process group
15716 is killed and the message is frozen. A value of zero time specifies no
15717 timeout.
15718
15719 .endconf
15720
15721 The standard output of the command is connected to a pipe, which is read when
15722 the command terminates. It should consist of a single line of output,
15723 containing up to five fields, separated by white space. 
15724 .em
15725 The maximum length of the line is 1023 characters. Longer lines are silently 
15726 truncated.
15727 .nem
15728 The first field is one of the following words (case-insensitive):
15729 .numberpars $.
15730 \*Accept*\: routing succeeded; the remaining fields specify what to do (see
15731 below).
15732 .nextp
15733 \*Decline*\: the router declines; pass the address to the next router, unless
15734 \no@_more\ is set.
15735 .nextp
15736 \*Fail*\: routing failed; do not pass the address to any more routers. Any
15737 subsequent text on the line is an error message. If the router is run as part
15738 of address verification during an incoming SMTP message, the message is
15739 included in the SMTP response.
15740 .nextp
15741 \*Defer*\: routing could not be completed at this time; try again later. Any
15742 subsequent text on the line is an error message which is logged. It is not
15743 included in any SMTP response.
15744 .nextp
15745 \*Freeze*\: the same as \*defer*\, except that the message is frozen.
15746 .nextp
15747 \*Pass*\: pass the address to the next router (or the router specified by
15748 \pass@_router\), overriding \no@_more\.
15749 .nextp
15750 \*Redirect*\: the message is redirected. The remainder of the line is a list of
15751 new addresses, which are routed independently, starting with the first router,
15752 or the router specified by \redirect@_router\, if set.
15753 .endp
15754 When the first word is \*accept*\, the remainder of the line consists of a
15755 number of keyed data values, as follows (split into two lines here, to fit on
15756 the page):
15757 .display
15758 ACCEPT TRANSPORT=<<transport>> HOSTS=<<list of hosts>>
15759        LOOKUP=byname|bydns DATA=<<text>>
15760 .endd
15761 The data items can be given in any order, and all are optional. If no transport
15762 is included, the transport specified by the generic \transport\ option is used.
15763 The list of hosts and the lookup type are needed only if the transport is an
15764 \%smtp%\ transport that does not itself supply a list of hosts.
15765
15766 The format of the list of hosts is the same as for the \%manualroute%\ router.
15767 As well as host names and IP addresses, it may contain names followed by
15768 \"/MX"\ to specify sublists of hosts that are obtained by looking up MX
15769 records.
15770
15771 If the lookup type is not specified, Exim behaves as follows when trying to
15772 find an IP address for each host: First, a DNS lookup is done. If this yields
15773 anything other than \\HOST@_NOT@_FOUND\\, that result is used. Otherwise, Exim
15774 goes on to try a call to \*getipnodebyname()*\ or \*gethostbyname()*\, and the
15775 result of the lookup is the result of that call.
15776
15777 If the DATA field is set, its value is placed in the \$address@_data$\
15778 variable. For example, this return line
15779 .display asis
15780 accept hosts=x1.y.example:x2.y.example data="rule1"
15781 .endd
15782 routes the address to the default transport, passing a list of two hosts. When
15783 the transport runs, the string `rule1' is in \$address@_data$\.
15784
15785
15786
15787 .
15788 .
15789 .
15790 .
15791 . ============================================================================
15792 .chapter The redirect router
15793 .set runningfoot "redirect router"
15794 .rset CHAPredirect "~~chapter"
15795 .index \%redirect%\ router
15796 .index routers||\%redirect%\
15797 .index alias file||in a \%redirect%\ router
15798 .index address redirection||\%redirect%\ router
15799 The \%redirect%\ router handles several kinds of address redirection. Its most
15800 common uses are for resolving local part aliases from a central alias file
15801 (usually called \(/etc/aliases)\) and for handling users' personal \(.forward)\
15802 files, but it has many other potential uses. The incoming address can be
15803 redirected in several different ways:
15804 .numberpars $.
15805 It can be replaced by one or more new addresses which are themselves routed
15806 independently.
15807 .nextp
15808 It can be routed to be delivered to a given file or directory.
15809 .nextp
15810 It can be routed to be delivered to a specified pipe command.
15811 .nextp
15812 It can cause an automatic reply to be generated.
15813 .nextp
15814 It can be forced to fail, with a custom error message.
15815 .nextp
15816 It can be temporarily deferred.
15817 .nextp
15818 It can be discarded.
15819 .endp
15820 The generic \transport\ option must not be set for \%redirect%\ routers.
15821 However, there are some private options which define transports for delivery to
15822 files and pipes, and for generating autoreplies. See the \file@_transport\,
15823 \pipe@_transport\ and \reply@_transport\ descriptions below.
15824
15825
15826 .section Redirection data
15827 The router operates by interpreting a text string which it obtains either by
15828 expanding the contents of the \data\ option, or by reading the entire contents
15829 of a file whose name is given in the \file\ option. These two options are
15830 mutually exclusive. The first is commonly used for handling system aliases, in
15831 a configuration like this:
15832 .display asis
15833 system_aliases:
15834   driver = redirect
15835   data = ${lookup{$local_part}lsearch{/etc/aliases}}
15836 .endd
15837 If the lookup fails, the expanded string in this example is empty. When the
15838 expansion of \data\ results in an empty string, the router declines. A forced
15839 expansion failure also causes the router to decline; other expansion failures
15840 cause delivery to be deferred.
15841
15842 A configuration using \file\ is commonly used for handling users' \(.forward)\
15843 files, like this:
15844 .display asis
15845 userforward:
15846   driver = redirect
15847   check_local_user
15848   file = $home/.forward
15849   no_verify
15850 .endd
15851 If the file does not exist, or causes no action to be taken (for example, it is
15852 empty or consists only of comments), the router declines. \**Warning**\: This
15853 is not the case when the file contains syntactically valid items that happen to
15854 yield empty addresses, for example, items containing only RFC 2822 address
15855 comments.
15856
15857
15858 .section Forward files and address verification
15859 .index address redirection||while verifying
15860 It is usual to set \no@_verify\ on \%redirect%\ routers which handle users'
15861 \(.forward)\ files, as in the example above. There are two reasons for this:
15862 .numberpars $.
15863 When Exim is receiving an incoming SMTP message from a remote host, it is
15864 running under the Exim uid, not as root.
15865 No additional groups are set up, even if the Exim uid is a member of other
15866 groups (that is, the \*initgroups()*\ function is not run).
15867 Exim is unable to change uid to read the file as the user, and it may not be
15868 able to read it as the Exim user. So in practice the router may not be able to
15869 operate.
15870 .nextp
15871 However, even when the router can operate, the existence of a \(.forward)\ file
15872 is unimportant when verifying an address. What should be checked is whether the
15873 local part is a valid user name or not. Cutting out the redirection processing
15874 saves some resources.
15875 .endp
15876
15877
15878
15879
15880 .section Interpreting redirection data
15881 .index Sieve filter||specifying in redirection data
15882 .index filter||specifying in redirection data
15883 The contents of the data string, whether obtained from \data\ or \file\, can be
15884 interpreted in two different ways:
15885 .numberpars $.
15886 If the \allow@_filter\ option is set true, and the data begins with the text
15887 `@#Exim filter' or `@#Sieve filter', it is interpreted as a list of
15888 \*filtering*\ instructions in the form of an Exim or Sieve filter file,
15889 respectively. Details of the syntax and semantics of filter files are described
15890 in a separate document entitled \*Exim's interfaces to mail filtering*\; this
15891 document is intended for use by end users.
15892 .nextp
15893 Otherwise, the data must be a comma-separated list of redirection items, as
15894 described in the next section.
15895 .endp
15896 When a message is redirected to a file (a `mail folder'), the file name given
15897 in a non-filter redirection list must always be an absolute path. A filter may
15898 generate a relative path -- how this is handled depends on the transport's
15899 configuration. See section ~~SECTfildiropt for a discussion of this issue for
15900 the \%appendfile%\ transport.
15901
15902
15903 .section Items in a non-filter redirection list
15904 .rset SECTitenonfilred "~~chapter.~~section"
15905 .index address redirection||non-filter list items
15906 When the redirection data is not an Exim or Sieve filter, for example, if it
15907 comes from a conventional alias or forward file, it consists of a list of
15908 addresses, file names, pipe commands, or certain special items (see section
15909 ~~SECTspecitredli below). The special items can be individually enabled or
15910 disabled by means of options whose names begin with \allow@_\ or \forbid@_\,
15911 depending on their default values. The items in the list are separated by
15912 commas or newlines.
15913 If a comma is required in an item, the entire item must be enclosed in double
15914 quotes.
15915
15916 Lines starting with a @# character are comments, and are ignored, and @# may
15917 also appear following a comma, in which case everything between the @# and the
15918 next newline character is ignored.
15919
15920 If an item is entirely enclosed in double quotes, these are removed. Otherwise
15921 double quotes are retained because some forms of mail address require their use
15922 (but never to enclose the entire address). In the following description, `item'
15923 refers to what remains after any surrounding double quotes have been removed.
15924
15925 \**Warning**\: If you use an Exim expansion to construct a redirection address,
15926 and the expansion contains a reference to \$local@_part$\, you should make use
15927 of the \quote\ expansion operator, in case the local part contains special
15928 characters. For example, to redirect all mail for the domain
15929 \*obsolete.example*\, retaining the existing local part, you could use this
15930 setting:
15931 .display asis
15932 data = ${quote:$local_part}@newdomain.example
15933 .endd
15934
15935
15936 .section Redirecting to a local mailbox
15937 .rset SECTredlocmai "~~chapter.~~section"
15938 .index routing||loops in
15939 .index loop||while routing, avoidance of
15940 .index address redirection||to local mailbox
15941 A redirection item may safely be the same as the address currently under
15942 consideration. This does not cause a routing loop, because a router is
15943 automatically skipped if any ancestor of the address that is being processed
15944 is the same as the current address and was processed by the current router.
15945 Such an address is therefore passed to the following routers, so it is handled
15946 as if there were no redirection. When making this loop-avoidance test, the
15947 complete local part, including any prefix or suffix, is used.
15948
15949 .index address redirection||local part without domain
15950 Specifying the same local part without a domain is a common usage in personal
15951 filter files when the user wants to have messages delivered to the local
15952 mailbox and also forwarded elsewhere. For example, the user whose login is
15953 \*cleo*\ might have a \(.forward)\ file containing this:
15954 .display asis
15955 cleo, cleopatra@egypt.example
15956 .endd
15957 .index backslash in alias file
15958 .index alias file||backslash in
15959 For compatibility with other MTAs, such unqualified local parts may be
15960 preceeded by `@\', but this is not a requirement for loop prevention. However,
15961 it does make a difference if more than one domain is being handled
15962 synonymously.
15963
15964 If an item begins with `@\' and the rest of the item parses as a valid RFC 2822
15965 address that does not include a domain, the item is qualified using the domain
15966 of the incoming address. In the absence of a leading `@\', unqualified
15967 addresses are qualified using the value in \qualify@_recipient\, but you can
15968 force the incoming domain to be used by setting \qualify__preserve@_domain\.
15969
15970 Care must be taken if there are alias names for local users.
15971 Consider an MTA handling a single local domain where the system alias file
15972 contains:
15973 .display asis
15974 Sam.Reman: spqr
15975 .endd
15976 Now suppose that Sam (whose login id is \*spqr*\) wants to save copies of
15977 messages in the local mailbox, and also forward copies elsewhere. He creates
15978 this forward file:
15979 .display asis
15980 Sam.Reman, spqr@reme.elsewhere.example
15981 .endd
15982 With these settings, an incoming message addressed to \*Sam.Reman*\ fails. The
15983 \%redirect%\ router for system aliases does not process \*Sam.Reman*\ the
15984 second time round, because it has previously routed it,
15985 and the following routers presumably cannot handle the alias. The forward file
15986 should really contain
15987 .display asis
15988 spqr, spqr@reme.elsewhere.example
15989 .endd
15990 but because this is such a common error, the \check@_ancestor\ option (see
15991 below) exists to provide a way to get round it. This is normally set on a
15992 \%redirect%\ router that is handling users' \(.forward)\ files.
15993
15994
15995 .section Special items in redirection lists
15996 .rset SECTspecitredli "~~chapter.~~section"
15997 In addition to addresses, the following types of item may appear in redirection
15998 lists (that is, in non-filter redirection data):
15999
16000 .numberpars $.
16001 .index pipe||in redirection list
16002 .index address redirection||to pipe
16003 An item is treated as a pipe command if it begins with `|' and does not parse
16004 as a valid RFC 2822 address that includes a domain. A transport for running the
16005 command must be specified by the \pipe@_transport\ option.
16006 Normally, either the router or the transport specifies a user and a group under
16007 which to run the delivery. The default is to use the Exim user and group.
16008
16009 Single or double quotes can be used for enclosing the individual arguments of
16010 the pipe command; no interpretation of escapes is done for single quotes. If
16011 the command contains a comma character, it is necessary to put the whole item
16012 in double quotes, for example:
16013 .display asis
16014 "|/some/command ready,steady,go"
16015 .endd
16016 since items in redirection lists are terminated by commas. Do not, however,
16017 quote just the command. An item such as
16018 .display asis
16019 |"/some/command ready,steady,go"
16020 .endd
16021 is interpreted as a pipe with a rather strange command name, and no arguments.
16022 .nextp
16023 .index file||in redirection list
16024 .index address redirection||to file
16025 An item is interpreted as a path name if it begins with `/' and does not parse
16026 as a valid RFC 2822 address that includes a domain. For example,
16027 .display asis
16028 /home/world/minbari
16029 .endd
16030 is treated as a file name, but
16031 .display asis
16032 /s=molari/o=babylon/@x400gate.way
16033 .endd
16034 is treated as an address. For a file name, a transport must be specified using
16035 the \file@_transport\ option. However, if the generated path name ends with a
16036 forward slash character, it is interpreted as a directory name rather than a
16037 file name, and \directory@_transport\ is used instead.
16038
16039 Normally, either the router or the transport specifies a user and a group under
16040 which to run the delivery. The default is to use the Exim user and group.
16041 .index \(/dev/null)\
16042 However, if a redirection item is the path \(/dev/null)\, delivery to it is
16043 bypassed at a high level, and the log entry shows `$*$$*$bypassed$*$$*$'
16044 instead of a transport name. In this case the user and group are not used.
16045 .nextp
16046 .index included address list
16047 .index address redirection||included external list
16048 If an item is of the form
16049 .display
16050 :include:<<path name>>
16051 .endd
16052 a list of further items is taken from the given file and included at that
16053 point.
16054 \**Note**\: such a file can not be a filter file; it is just an out-of-line
16055 addition to the list.
16056 The items in the included list are separated by commas or newlines and are not
16057 subject to expansion. If this is the first item in an alias list in an
16058 \%lsearch%\ file, a colon must be used to terminate the alias name. This
16059 example is incorrect:
16060 .display asis
16061 list1    :include:/opt/lists/list1
16062 .endd
16063 It must be given as
16064 .display asis
16065 list1:   :include:/opt/lists/list1
16066 .endd
16067 .nextp
16068 .index address redirection||to black hole
16069 Sometimes you want to throw away mail to a particular local part. Making the
16070 \data\ option expand to an empty string does not work, because that causes the
16071 router to decline. Instead, the alias item
16072 .index black hole
16073 .index abandoning mail
16074 .display
16075 :blackhole:
16076 .endd
16077 can be used. It does what its name implies. No delivery is done, and no error
16078 message is generated. This has the same effect as specifing \(/dev/null)\, but
16079 can be independently disabled.
16080
16081 \**Warning**\: If \":blackhole:"\ appears anywhere in a redirection list, no
16082 delivery is done for the original local part, even if other redirection items
16083 are present. If you are generating a multi-item list (for example, by reading a
16084 database) and need the ability to provide a no-op item, you must use
16085 \(/dev/null)\.
16086
16087 .nextp
16088 .index delivery||forcing failure
16089 .index delivery||forcing deferral
16090 .index failing delivery||forcing
16091 .index deferred delivery, forcing
16092 .index customizing||failure message
16093 An attempt to deliver a particular address can be deferred or forced to fail by
16094 redirection items of the form
16095 .display
16096 :defer:
16097 $rm{or}
16098 :fail:
16099 .endd
16100 respectively. When a redirection list contains such an item, it applies to the
16101 entire redirection; any other items in the list are ignored (:::blackhole:: is
16102 different). Any text following :::fail:: or :::defer:: is placed in the error
16103 text associated with the failure. For example, an alias file might contain:
16104 .display asis
16105 X.Employee:  :fail: Gone away, no forwarding address
16106 .endd
16107 In the case of an address that is being verified from an ACL or as the subject
16108 of a \\VRFY\\ command, the text is included in the SMTP error response by
16109 default. In an ACL, an explicitly provided message overrides the default, but
16110 the default message is available in the variable \$acl@_verify@_message$\ and
16111 can therefore be included in a custom message if this is desired. Exim sends a
16112 451 SMTP code for a :::defer::, and 550 for :::fail::. In non-SMTP cases the
16113 text is included in the error message that Exim generates.
16114
16115
16116
16117 Normally the error text is the rest of the redirection list -- a comma does not
16118 terminate it -- but a newline does act as a terminator. Newlines are not
16119 normally present in alias expansions. In \%lsearch%\ lookups they are removed as
16120 part of the continuation process, but they may exist in other kinds of lookup
16121 and in :::include:: files.
16122
16123 During routing for message delivery (as opposed to verification), a redirection
16124 containing :::fail:: causes an immediate failure of the incoming address,
16125 whereas :::defer:: causes the message to remain on the queue so that a
16126 subsequent delivery attempt can happen at a later time. If an address is
16127 deferred for too long, it will ultimately fail, because the normal retry
16128 rules still apply.
16129 .nextp
16130 .index alias file||exception to default
16131 Sometimes it is useful to use a single-key search type with a default (see
16132 chapter ~~CHAPfdlookup) to look up aliases. However, there may be a need for
16133 exceptions to the default. These can be handled by aliasing them to
16134 .display asis
16135 :unknown:
16136 .endd
16137 This differs from :::fail:: in that it causes the \%redirect%\ router to decline,
16138 whereas :::fail:: forces routing to fail. A lookup which results in an empty
16139 redirection list has the same effect.
16140 .endp
16141
16142 .section Duplicate addresses
16143 .index duplicate addresses
16144 .index address||duplicate, discarding
16145 .index pipe||duplicated
16146 Exim removes duplicate addresses from the list to which it is delivering, so as
16147 to deliver just one copy to each address. This does not apply to deliveries
16148 routed to pipes by different immediate parent addresses, but an indirect
16149 aliasing scheme of the type
16150 .display asis
16151 pipe:       |/some/command $local_part
16152 localpart1: pipe
16153 localpart2: pipe
16154 .endd
16155 does not work with a message that is addressed to both local parts, because
16156 when the second is aliased to the intermediate local part `pipe' it gets
16157 discarded as being the same as a previously handled address. However, a scheme
16158 such as
16159 .display asis
16160 localpart1: |/some/command $local_part
16161 localpart2: |/some/command $local_part
16162 .endd
16163 does result in two different pipe deliveries, because the immediate parents of
16164 the pipes are distinct.
16165
16166
16167 .section Repeated redirection expansion
16168 .index repeated redirection expansion
16169 .index address redirection||repeated for each delivery attempt
16170 When a message cannot be delivered to all of its recipients immediately,
16171 leading to two or more delivery attempts, redirection expansion is carried out
16172 afresh each time for those addresses whose children were not all previously
16173 delivered. If redirection is being used as a mailing list, this can lead to new
16174 members of the list receiving copies of old messages. The \one@_time\ option
16175 can be used to avoid this.
16176
16177 .section Errors in redirection lists
16178 .index address redirection||errors
16179 If \skip@_syntax@_errors\ is set, a malformed address that causes a parsing
16180 error is skipped, and an entry is written to the main log. This may be useful
16181 for mailing lists that are automatically managed. Otherwise, if an error is
16182 detected while generating the list of new addresses, the original address is
16183 deferred. See also \syntax@_errors@_to\.
16184
16185
16186 .section Private options for the redirect router
16187
16188 The private options for the \%redirect%\ router are as follows:
16189
16190 .startconf redirect
16191 .index options||\%redirect%\ router
16192
16193 .conf allow@_defer boolean false
16194 Setting this option allows the use of :::defer:: in non-filter redirection
16195 data,
16196 or the \defer\ command in an Exim filter file.
16197
16198 .conf allow@_fail boolean false
16199 .index failing delivery||from filter
16200 If this option is true, the :::fail:: item can be used in a redirection list,
16201 and the \fail\ command may be used in a filter file.
16202
16203 .conf allow@_filter boolean false
16204 .index filter||enabling use of
16205 .index Sieve filter||enabling use of
16206 Setting this option allows Exim to interpret redirection data that starts with
16207 `@#Exim filter' or `@#Sieve filter' as a set of filtering instructions. There
16208 are some features of Exim filter files that some administrators may wish to
16209 lock out; see the \forbid@_filter@_xxx\ options below. 
16210 .em
16211 It is also possible to lock out Exim filters or Sieve filters while allowing 
16212 the other type; see \forbid@_exim@_filter\ and \forbid@_sieve@_filter\.
16213 .nem
16214
16215 The filter is run using the uid and gid set by the generic \user\ and \group\
16216 options. These take their defaults from the password data if
16217 \check@_local@_user\ is set, so in the normal case of users' personal filter
16218 files, the filter is run as the relevant user. When \allow@_filter\ is set
16219 true, Exim insists that either \check@_local@_user\ or \user\ is set.
16220
16221
16222 .conf allow@_freeze boolean false
16223 .index freezing messages||allowing in filter
16224 Setting this option allows the use of the \freeze\ command in an Exim filter.
16225 This command is more normally encountered in system filters, and is disabled by
16226 default for redirection filters because it isn't something you usually want to
16227 let ordinary users do.
16228
16229
16230 .conf check@_ancestor boolean false
16231 This option is concerned with handling generated addresses that are the same
16232 as some address in the list of redirection ancestors of the current address.
16233 Although it is turned off by default in the code, it is set in the default
16234 configuration file for handling users' \(.forward)\ files. It is recommended
16235 for this use of the \%redirect%\ router.
16236
16237 When \check@_ancestor\ is set, if a generated address (including the domain) is
16238 the same as any ancestor of the current address, it is replaced by a copy of
16239 the current address. This helps in the case where local part A is aliased to B,
16240 and B has a \(.forward)\ file pointing back to A. For example, within a single
16241 domain, the local part `Joe.Bloggs' is aliased to `jb' and \(@~jb/.forward)\
16242 contains:
16243 .display
16244 @\Joe.Bloggs, <<other item(s)>>
16245 .endd
16246 Without the \check@_ancestor\ setting, either local part (`jb' or `joe.bloggs')
16247 gets processed once by each router and so ends up as it was originally. If `jb'
16248 is the real mailbox name, mail to `jb' gets delivered (having been turned into
16249 `joe.bloggs' by the \(.forward)\ file and back to `jb' by the alias), but mail
16250 to `joe.bloggs' fails. Setting \check@_ancestor\ on the \%redirect%\ router that
16251 handles the \(.forward)\ file prevents it from turning `jb' back into
16252 `joe.bloggs' when that was the original address. See also the \repeat@_use\
16253 option below.
16254
16255 .conf check@_group boolean "see below"
16256 When the \file\ option is used, the group owner of the file is checked only
16257 when this option is set. The permitted groups are those listed in the
16258 \owngroups\ option, together with the user's default group if
16259 \check@_local@_user\ is set. If the file has the wrong group, routing is
16260 deferred. The default setting for this option is true if \check@_local@_user\
16261 is set and the \modemask\ option permits the group write bit, or if the
16262 \owngroups\ option is set. Otherwise it is false, and no group check occurs.
16263
16264
16265 .conf check@_owner boolean "see below"
16266 When the \file\ option is used, the owner of the file is checked only when this
16267 option is set. If \check@_local@_user\ is set, the local user is permitted;
16268 otherwise the owner must be one of those listed in the \owners\ option. The
16269 default value for this option is true if \check@_local@_user\ or \owners\ is
16270 set. Otherwise the default is false, and no owner check occurs.
16271
16272 .conf data string$**$ unset
16273 This option is mutually exclusive with \file\. One or other of them must be
16274 set, but not both. The contents of \data\ are expanded, and then used as the
16275 list of forwarding items, or as a set of filtering instructions. If the
16276 expansion is forced to fail, or the result is an empty string or a string that
16277 has no effect (consists entirely of comments), the router declines.
16278
16279 When filtering instructions are used, the string must begin with `@#Exim
16280 filter', and all comments in the string, including this initial one, must be
16281 terminated with newline characters. For example:
16282 .display asis
16283 data = #Exim filter\n\
16284        if $h_to: contains Exim then save $home/mail/exim endif
16285 .endd
16286 If you are reading the data from a database where newlines cannot be included,
16287 you can use the \$@{sg@}$\ expansion item to turn the escape string of your
16288 choice into a newline.
16289
16290 .conf directory@_transport string$**$ unset
16291 A \%redirect%\ router sets up a direct delivery to a directory when a path name
16292 ending with a slash is specified as a new `address'. The transport used is
16293 specified by this option, which, after expansion, must be the name of a
16294 configured transport. This should normally be an \%appendfile%\ transport.
16295
16296 .conf file string$**$ unset
16297 This option specifies the name of a file that contains the redirection data. It
16298 is mutually exclusive with the \data\ option. The string is expanded before
16299 use; if the expansion is forced to fail, the router declines. Other expansion
16300 failures cause delivery to be deferred. The result of a successful expansion
16301 must be an absolute path. The entire file is read and used as the redirection
16302 data. If the data is an empty string or a string that has no effect (consists
16303 entirely of comments), the router declines.
16304
16305 .index NFS||checking for file existence
16306 If the attempt to open the file fails with a `does not exist' error, Exim
16307 runs a check on the containing directory,
16308 unless \ignore@_enotdir\ is true (see below).
16309 If the directory does not appear to exist, delivery is deferred. This can
16310 happen when users' \(.forward)\ files are in NFS-mounted directories, and there
16311 is a mount problem. If the containing directory does exist, but the file does
16312 not, the router declines.
16313
16314 .conf file@_transport string$**$ unset
16315 A \%redirect%\ router sets up a direct delivery to a file when a path name not
16316 ending in a slash is specified as a new `address'. The transport used is
16317 specified by this option, which, after expansion, must be the name of a
16318 configured transport.
16319 This should normally be an \%appendfile%\ transport.
16320 When it is running, the file name is in \$address@_file$\.
16321
16322 .conf forbid@_blackhole boolean false
16323 If this option is true, the :::blackhole:: item may not appear in a redirection
16324 list.
16325
16326 .em
16327 .conf forbid@_exim@_filter boolean false
16328 If this option is set true, only Sieve filters are permitted when 
16329 \allow@_filter\ is true.
16330 .nem
16331
16332
16333 .conf forbid@_file boolean false
16334 .index delivery||to file, forbidding
16335 .index Sieve filter||forbidding delivery to a file
16336 .index Sieve filter||`keep' facility, disabling
16337 If this option is true, this router may not generate a new address that
16338 specifies delivery to a local file or directory, either from a filter or from a
16339 conventional forward file. This option is forced to be true if \one@_time\ is
16340 set. It applies to Sieve filters as well as to Exim filters, but if true, it
16341 locks out the Sieve's `keep' facility.
16342
16343 .conf forbid@_filter@_existstest boolean false
16344 .index filter||locking out certain features
16345 If this option is true, string expansions in Exim filters are not allowed to
16346 make use of the \exists\ condition.
16347
16348 .conf forbid@_filter@_logwrite boolean false
16349 If this option is true, use of the logging facility in Exim filters is not
16350 permitted. Logging is in any case available only if the filter is being run
16351 under some unprivileged uid (which is normally the case for ordinary users'
16352 \(.forward)\ files).
16353
16354 .conf forbid@_filter@_lookup boolean false
16355 If this option is true, string expansions in Exim filter files are not allowed
16356 to make use of \lookup\ items.
16357
16358 .conf forbid@_filter@_perl boolean false
16359 This option is available only if Exim is built with embedded Perl support. If
16360 it is true, string expansions in Exim filter files are not allowed to make use
16361 of the embedded Perl support.
16362
16363 .conf forbid@_filter@_readfile boolean false
16364 If this option is true, string expansions in Exim filter files are not allowed
16365 to make use of \readfile\ items.
16366
16367 .conf forbid@_filter@_readsocket boolean false
16368 If this option is true, string expansions in Exim filter files are not allowed
16369 to make use of \readsocket\ items.
16370
16371 .conf forbid@_filter@_reply boolean false
16372 If this option is true, this router may not generate an automatic reply
16373 message. Automatic replies can be generated only from Exim 
16374 .em
16375 or Sieve filter files, not from traditional forward files.
16376 .nem
16377 This option is forced to be true if \one@_time\ is set.
16378
16379 .conf forbid@_filter@_run boolean false
16380 If this option is true, string expansions in Exim filter files are not allowed
16381 to make use of \run\ items.
16382
16383 .conf forbid@_include boolean false
16384 If this option is true, items of the form
16385 .display
16386 :include:<<path name>>
16387 .endd
16388 are not permitted in non-filter redirection lists.
16389
16390 .conf forbid@_pipe boolean false
16391 .index delivery||to pipe, forbidding
16392 If this option is true, this router may not generate a new address which
16393 specifies delivery to a pipe, either from an Exim filter or from a conventional
16394 forward file. This option is forced to be true if \one@_time\ is set.
16395
16396 .em
16397 .conf forbid@_sieve@_filter boolean false
16398 If this option is set true, only Exim filters are permitted when 
16399 \allow@_filter\ is true.
16400 .nem
16401
16402
16403 .conf hide@_child@_in@_errmsg boolean false
16404 .index bounce message||redirection details, suppressing
16405 If this option is true, it prevents Exim from quoting a child address if it
16406 generates a bounce or delay message for it. Instead it says `an address
16407 generated from <<the top level address>>'. Of course, this applies only to
16408 bounces generated locally. If a message is forwarded to another host, $it{its}
16409 bounce may well quote the generated address.
16410
16411 .conf ignore@_eacces boolean false
16412 .index \\EACCES\\
16413 If this option is set and an attempt to open a redirection file yields the
16414 \\EACCES\\ error (permission denied), the \%redirect%\ router behaves as if the
16415 file did not exist.
16416
16417 .conf ignore@_enotdir boolean false
16418 .index \\ENOTDIR\\
16419 If this option is set and an attempt to open a redirection file yields the
16420 \\ENOTDIR\\ error (something on the path is not a directory), the \%redirect%\
16421 router behaves as if the file did not exist.
16422
16423 Setting \ignore@_enotdir\ has another effect as well: When a \%redirect%\
16424 router that has the \file\ option set discovers that the file does not exist
16425 (the \\ENOENT\\ error), it tries to \*stat()*\ the parent directory, as a check
16426 against unmounted NFS directories. If the parent can not be statted, delivery
16427 is deferred. However, it seems wrong to do this check when \ignore@_enotdir\ is
16428 set, because that option tells Exim to ignore `something on the path is not a
16429 directory' (the \\ENOTDIR\\ error). This is a confusing area, because it seems
16430 that some operating systems give \\ENOENT\\ where others give \\ENOTDIR\\.
16431
16432
16433 .conf include@_directory string unset
16434 If this option is set, the path names of any :::include:: items in a redirection
16435 list must start with this directory.
16436
16437 .conf modemask "octal integer" 022
16438 This specifies mode bits which must not be set for a file specified by the
16439 \file\ option. If any of the forbidden bits are set, delivery is deferred.
16440
16441 .conf one@_time boolean false
16442 .index one-time aliasing/forwarding expansion
16443 .index alias file||one-time expansion
16444 .index forward file||one-time expansion
16445 .index mailing lists||one-time expansion
16446 .index address redirection||one-time expansion
16447 Sometimes the fact that Exim re-evaluates aliases and reprocesses redirection
16448 files each time it tries to deliver a message causes a problem
16449 when one or more of the generated addresses fails be delivered at the first
16450 attempt. The problem is not one of duplicate delivery -- Exim is clever enough
16451 to handle that -- but of what happens when the redirection list changes during
16452 the time that the message is on Exim's queue. This is particularly true in the
16453 case of mailing lists, where new subscribers might receive copies of messages
16454 that were posted before they subscribed.
16455
16456 If \one@_time\ is set and any addresses generated by the router fail to
16457 deliver at the first attempt, the failing addresses are added to the message as
16458 `top level' addresses, and the parent address that generated them is marked
16459 `delivered'. Thus, redirection does not happen again at the next
16460 delivery attempt.
16461
16462 \**Warning 1**\: This means that any header line addition or removal that is
16463 specified by this router would be lost if delivery did not succeed at the
16464 first attempt. For this reason, the \headers@_add\ and \headers@_remove\
16465 generic options are not permitted when \one@_time\ is set.
16466
16467 \**Warning 2**\: To ensure that the router generates only addresses (as opposed
16468 to pipe or file deliveries or auto-replies) \forbid@_file\, \forbid@_pipe\,
16469 and \forbid@_filter@_reply\ are forced to be true when \one@_time\ is set.
16470
16471 The original top-level address is remembered with each of the generated
16472 addresses, and is output in any log messages. However, any intermediate parent
16473 addresses are not recorded. This makes a difference to the log only if
16474 \all__parents\ log selector is set. It is expected that \one@_time\ will
16475 typically be used for mailing lists, where there is normally just one level of
16476 expansion.
16477
16478 .conf owners "string list" unset
16479 .index ownership||alias file
16480 .index ownership||forward file
16481 .index alias file||ownership
16482 .index forward file||ownership
16483 This specifies a list of permitted owners for the file specified by \file\.
16484 This list is in addition to the local user when \check@_local@_user\ is set.
16485 See \check@_owner\ above.
16486
16487 .conf owngroups "string list" unset
16488 This specifies a list of permitted groups for the file specified by \file\. The
16489 list is in addition to the local user's primary group when \check@_local@_user\
16490 is set. See \check@_group\ above.
16491
16492 .conf pipe@_transport string$**$ unset
16493 A \%redirect%\ router sets up a direct delivery to a pipe when a string starting
16494 with a vertical bar character is specified as a new `address'. The transport
16495 used is specified by this option, which, after expansion, must be the name of a
16496 configured transport.
16497 This should normally be a \%pipe%\ transport.
16498 When the transport is run, the pipe command is in \$address@_pipe$\.
16499
16500 .conf qualify@_domain string$**$ unset
16501 If this option is set and an unqualified address (one without a domain) is
16502 generated, it is qualified with the domain specified by expanding this string,
16503 instead of the global setting in \qualify@_recipient\. If the expansion fails,
16504 the router declines. If you want to revert to the default, you can have the
16505 expansion generate \$qualify@_recipient$\.
16506
16507 .conf qualify@_preserve@_domain boolean false
16508 .index domain||in redirection, preserving
16509 .index preserving domain in redirection
16510 .index address redirection||domain, preserving
16511 If this is set and an unqualified address (one without a domain) is generated,
16512 it is qualified with the domain of the
16513 parent address (the immediately preceding ancestor) instead of the local
16514 \qualify@_domain\ or global \qualify@_recipient\ value.
16515
16516 .conf repeat@_use boolean true
16517 If this option is set false, the router is skipped for a child address that has
16518 any ancestor that was routed by this router. This test happens before any of
16519 the other preconditions are tested. Exim's default anti-looping rules skip
16520 only when the ancestor is the same as the current address. See also
16521 \check@_ancestor\ above and the generic \redirect@_router\ option.
16522
16523 .conf reply@_transport string$**$ unset
16524 A \%redirect%\ router sets up an automatic reply when a \mail\ or \vacation\
16525 command is used in a filter file. The transport used is specified by this
16526 option, which, after expansion, must be the name of a configured transport.
16527 This should normally be an \%autoreply%\ transport. Other transports are
16528 unlikely to do anything sensible or useful.
16529
16530 .conf rewrite boolean true
16531 .index address redirection||disabling rewriting
16532 If this option is set false, addresses generated by the router are not
16533 subject to address rewriting. Otherwise, they are treated like new addresses
16534 and are rewritten according to the global rewriting rules.
16535
16536
16537 .em
16538 .conf sieve@_vacation@_directory string$**$ unset
16539 .index Sieve filter||vacation directory
16540 To enable the `vacation' extension for Sieve filters, you must set
16541 \sieve@_vacation@_directory\ to the directory where vacation databases are held
16542 (do not put anything else in that directory), and ensure that the
16543 \reply@_transport\ option refers to an \%autoreply%\ transport.
16544 .nem
16545
16546
16547 .conf skip@_syntax@_errors boolean false
16548 .index forward file||broken
16549 .index address redirection||broken files
16550 .index alias file||broken
16551 .index broken alias or forward files
16552 .index ignoring faulty addresses
16553 .index skipping faulty addresses
16554 .index error||skipping bad syntax
16555 If \skip@_syntax@_errors\ is set, syntactically malformed addresses in
16556 non-filter redirection data are skipped, and each failing address is logged. If
16557 \syntax@_errors@_to\ is set, a message is sent to the address it defines,
16558 giving details of the failures. If \syntax@_errors@_text\ is set, its contents
16559 are expanded and placed at the head of the error message generated by
16560 \syntax@_errors@_to\. Usually it is appropriate to set \syntax@_errors@_to\ to
16561 be the same address as the generic \errors@_to\ option. The
16562 \skip@_syntax@_errors\ option is often used when handling mailing lists.
16563
16564 If all the addresses in a redirection list are skipped because of syntax
16565 errors, the router declines to handle the original address, and it is passed to
16566 the following routers.
16567
16568 If \skip@_syntax@_errors\ is set when an Exim filter is interpreted, any syntax
16569 error in the filter causes filtering to be abandoned without any action being
16570 taken. The incident is logged, and the router declines to handle the address,
16571 so it is passed to the following routers.
16572
16573 .index Sieve filter||syntax errors in
16574 .em
16575 Syntax errors in a Sieve filter file cause the `keep' action to
16576 occur. This action is specified by RFC 3028.
16577 .nem
16578 The values of \skip@_syntax@_errors\, \syntax@_errors@_to\, and
16579 \syntax@_errors@_text\ are not used.
16580
16581 \skip@_syntax@_errors\ can be used to specify that errors in users' forward
16582 lists or filter files should not prevent delivery. The \syntax@_errors@_to\
16583 option, used with an address that does not get redirected, can be used to
16584 notify users of these errors, by means of a router like this:
16585 .display flow asis
16586 userforward:
16587   driver = redirect
16588   allow_filter
16589   check_local_user
16590   file = $home/.forward
16591   file_transport = address_file
16592   pipe_transport = address_pipe
16593   reply_transport = address_reply
16594   no_verify
16595   skip_syntax_errors
16596   syntax_errors_to = real-$local_part@$domain
16597   syntax_errors_text = \
16598     This is an automatically generated message. An error has\n\
16599     been found in your .forward file. Details of the error are\n\
16600     reported below. While this error persists, you will receive\n\
16601     a copy of this message for every message that is addressed\n\
16602     to you. If your .forward file is a filter file, or if it is\n\
16603     a non-filter file containing no valid forwarding addresses,\n\
16604     a copy of each incoming message will be put in your normal\n\
16605     mailbox. If a non-filter file contains at least one valid\n\
16606     forwarding address, forwarding to the valid addresses will\n\
16607     happen, and those will be the only deliveries that occur.
16608 .endd
16609 You also need a router to ensure that local addresses that are prefixed by
16610 \"real-"\ are recognized, but not forwarded or filtered. For example, you could
16611 put this immediately before the \%userforward%\ router:
16612 .display asis
16613 real_localuser:
16614   driver = accept
16615   check_local_user
16616   local_part_prefix = real-
16617   transport = local_delivery
16618 .endd
16619
16620 .conf syntax@_errors@_text string$**$ unset
16621 See \skip@_syntax@_errors\ above.
16622
16623 .conf syntax@_errors@_to string unset
16624 See \skip@_syntax@_errors\ above.
16625
16626 .endconf
16627
16628
16629
16630
16631
16632 .
16633 .
16634 .
16635 . ============================================================================
16636 .chapter Environment for running local transports
16637 .rset CHAPenvironment "~~chapter"
16638 .set runningfoot "local transport environment"
16639 .index local transports||environment for
16640 .index environment for local transports
16641 .index transport||local, environment for
16642 Local transports handle deliveries to files and pipes. (The \%autoreply%\
16643 transport can be thought of as similar to a pipe.) Exim always runs transports
16644 in subprocesses, under specified uids and gids. Typical deliveries to local
16645 mailboxes run under the uid and gid of the local user.
16646
16647 Exim also sets a specific current directory while running the transport; for
16648 some transports a home directory setting is also relevant. The \%pipe%\
16649 transport is the only one that sets up environment variables; see section
16650 ~~SECTpipeenv for details.
16651
16652 The values used for the uid, gid, and the directories may come from several
16653 different places. In many cases, the router that handles the address associates
16654 settings with that address as a result of its \check@_local@_user\, \group\, or
16655 \user\ options. However, values may also be given in the transport's own
16656 configuration, and these override anything that comes from the router.
16657
16658
16659 .em
16660 .section Concurrent deliveries
16661 .index concurrent deliveries
16662 .index simultaneous deliveries
16663 If two different messages for the same local recpient arrive more or less 
16664 simultaneously, the two delivery processes are likely to run concurrently. When 
16665 the \%appendfile%\ transport is used to write to a file, Exim applies locking 
16666 rules to stop concurrent processes from writing to the same file at the same 
16667 time.
16668
16669 However, when you use a \%pipe%\ transport, it is up to you to arrange any 
16670 locking that is needed. Here is a silly example:
16671 .display asis
16672 my_transport:
16673   driver = pipe
16674   command = /bin/sh -c 'cat >>/some/file'
16675 .endd    
16676 This is supposed to write the message at the end of the file. However, if two
16677 messages arrive at the same time, the file will be scrambled. You can use the
16678 \exim@_lock\ utility program (see section ~~SECTmailboxmaint) to lock a file
16679 using the same algorithm that Exim itself uses.
16680 .nem
16681
16682
16683 .section Uids and gids
16684 .rset SECTenvuidgid "~~chapter.~~section"
16685 .index local transports||uid and gid
16686 .index transport||local, uid and gid
16687 All transports have the options \group\ and \user\. If \group\ is set, it
16688 overrides any group that the router set in the address, even if \user\ is not
16689 set for the transport. This makes it possible, for example, to run local mail
16690 delivery under the uid of the recipient (set by the router), but in a special
16691 group (set by the transport). For example:
16692 .display asis
16693 # Routers ...
16694 # User/group are set by check_local_user in this router
16695 local_users:
16696   driver = accept
16697   check_local_user
16698   transport = group_delivery
16699
16700 # Transports ...
16701 # This transport overrides the group
16702 group_delivery:
16703   driver = appendfile
16704   file = /var/spool/mail/$local_part
16705   group = mail
16706 .endd
16707 If \user\ is set for a transport, its value overrides what is set in the
16708 address. If \user\ is non-numeric and \group\ is not set, the gid associated
16709 with the user is used. If \user\ is numeric, \group\ must be set.
16710
16711 .index \initgroups\ option
16712 When the uid is taken from the transport's configuration, the \*initgroups()*\
16713 function is called for the groups associated with that uid if the \initgroups\
16714 option is set for the transport. When the uid is not specified by the
16715 transport, but is associated with the address by a router, the option for
16716 calling \*initgroups()*\ is taken from the router configuration.
16717
16718 .index \%pipe%\ transport||uid for
16719 The \%pipe%\ transport contains the special option \pipe@_as@_creator\. If this
16720 is set and \user\ is not set, the uid of the process that called Exim to
16721 receive the message is used, and if \group\ is not set, the corresponding
16722 original gid is also used.
16723
16724
16725 .section Current and home directories
16726 .index current directory for local transport
16727 .index home directory||for local transport
16728 .index transport||local, home directory for
16729 .index transport||local, current directory for
16730 Routers may set current and home directories for local transports by means of
16731 the \transport__current@_directory\ and \transport@_home@_directory\ options.
16732 However, if the transport's \current__directory\ or \home@_directory\ options
16733 are set, they override the router's values. In detail, the home directory
16734 for a local transport is taken from the first of these values that is set:
16735 .numberpars $.
16736 The \home@_directory\ option on the transport;
16737 .nextp
16738 The \transport@_home@_directory\ option on the router;
16739 .nextp
16740 The password data if \check@_local@_user\ is set on the router;
16741 .nextp
16742 The \router@_home@_directory\ option on the router.
16743 .endp
16744 The current directory is taken from the first of these values that is set:
16745 .numberpars $.
16746 The \current@_directory\ option on the transport;
16747 .nextp
16748 The \transport@_current@_directory\ option on the router.
16749 .endp
16750
16751 If neither the router nor the transport sets a current directory, Exim uses the
16752 value of the home directory, if it is set. Otherwise it sets the current
16753 directory to \(/)\ before running a local transport.
16754
16755
16756 .section Expansion variables derived from the address
16757 Normally a local delivery is handling a single address, and in that case the
16758 variables such as \$domain$\ and \$local@_part$\ are set during local
16759 deliveries. However, in some circumstances more than one address may be handled
16760 at once (for example, while writing batch SMTP for onward transmission by some
16761 other means). In this case, the variables associated with the local part are
16762 never set, \$domain$\ is set only if all the addresses have the same
16763 domain, and \$original@_domain$\ is never set.
16764
16765
16766
16767
16768
16769
16770
16771 .
16772 .
16773 .
16774 . ============================================================================
16775 .chapter Generic options for transports
16776 .rset CHAPtransportgeneric "~~chapter"
16777 .set runningfoot "generic transport options"
16778
16779 .index generic options||transport
16780 .index options||generic, for transports
16781 .index transport||generic options for
16782 The following generic options apply to all transports:
16783
16784 .startconf transports
16785 .conf body@_only boolean false
16786 .index transport||body only
16787 .index message||transporting body only
16788 .index body of message||transporting
16789 If this option is set, the message's headers are not transported. It is
16790 mutually exclusive with \headers@_only\. If it is used with the \%appendfile%\ or
16791 \%pipe%\ transports, the settings of \message@_prefix\ and \message@_suffix\
16792 should be checked, because this option does not automatically suppress them.
16793
16794 .conf current@_directory string$**$ unset
16795 .index transport||current directory for
16796 This specifies the current directory that is to be set while running the
16797 transport, overriding any value that may have been set by the router.
16798 If the expansion fails for any reason, including forced failure, an error is
16799 logged, and delivery is deferred.
16800
16801 .conf disable@_logging boolean false
16802 If this option is set true, nothing is logged for any
16803 deliveries by the transport or for any
16804 transport errors. You should not set this option unless you really, really know
16805 what you are doing.
16806
16807 .conf debug@_print string$**$ unset
16808 .index testing||variables in drivers
16809 If this option is set and debugging is enabled (see the \-d-\ command line
16810 option), the string is expanded and included in the debugging output when the
16811 transport is run.
16812 If expansion of the string fails, the error message is written to the debugging
16813 output, and Exim carries on processing.
16814 This facility is provided to help with checking out the values of variables and
16815 so on when debugging driver configurations. For example, if a \headers@_add\
16816 option is not working properly, \debug@_print\ could be used to output the
16817 variables it references. A newline is added to the text if it does not end with
16818 one.
16819
16820 .conf delivery@_date@_add boolean false
16821 .index ::Delivery-date:: header line
16822 If this option is true, a ::Delivery-date:: header is added to the message. This
16823 gives the actual time the delivery was made. As this is not a standard header,
16824 Exim has a configuration option (\delivery@_date@_remove\) which requests its
16825 removal from incoming messages, so that delivered messages can safely be resent
16826 to other recipients.
16827
16828 .conf driver string unset
16829 This specifies which of the available transport drivers is to be used.
16830 There is no default, and this option must be set for every transport.
16831
16832 .conf envelope@_to@_add boolean false
16833 .index ::Envelope-to:: header line
16834 If this option is true, an ::Envelope-to:: header is added to the message. This
16835 gives the original address(es) in the incoming envelope that caused this
16836 delivery to happen. More than one address may be present if the transport is
16837 configured to handle several addresses at once, or if more than one original
16838 address was redirected to the same final address. As this is not a standard
16839 header, Exim has a configuration option (\envelope@_to@_remove\) which requests
16840 its removal from incoming messages, so that delivered messages can safely be
16841 resent to other recipients.
16842
16843 .conf group string$**$ "Exim group"
16844 .index transport||group, specifying
16845 This option specifies a gid for running the transport process, overriding any
16846 value that the router supplies, and also overriding any value associated with
16847 \user\ (see below).
16848
16849 .conf headers@_add string$**$ unset
16850 .index header lines||adding in transport
16851 .index transport||header lines, adding
16852 .em
16853 This option specifies a string of text that is expanded and added to the header
16854 portion of a message as it is transported, as described in section
16855 ~~SECTheadersaddrem. Additional header lines can also be specified by routers.
16856 If the result of the expansion is an empty string, or if the expansion is
16857 forced to fail, no action is taken. Other expansion failures are treated as
16858 errors and cause the delivery to be deferred.
16859 .nem
16860
16861 .conf headers@_only boolean false
16862 .index transport||header lines only
16863 .index message||transporting headers only
16864 .index header lines||transporting
16865 If this option is set, the message's body is not transported. It is mutually
16866 exclusive with \body@_only\. If it is used with the \%appendfile%\ or \%pipe%\
16867 transports, the settings of \message@_prefix\ and \message__suffix\ should be
16868 checked, since this option does not automatically suppress them.
16869
16870 .conf headers@_remove string$**$ unset
16871 .index header lines||removing
16872 .index transport||header lines, removing
16873 .em
16874 This option specifies a string that is expanded into a list of header names;
16875 these headers are omitted from the message as it is transported, as described 
16876 in section ~~SECTheadersaddrem. Header removal can also be specified by
16877 routers. If the result of the expansion is an empty string, or if the expansion
16878 is forced to fail, no action is taken. Other expansion failures are treated as
16879 errors and cause the delivery to be deferred.
16880 .nem
16881
16882 .conf headers@_rewrite string unset
16883 .index transport||header lines, rewriting
16884 .index rewriting||at transport time
16885 This option allows addresses in header lines to be rewritten at transport time,
16886 that is, as the message is being copied to its destination. The contents of the
16887 option are a colon-separated list of rewriting rules. Each rule is in exactly
16888 the same form as one of the general rewriting rules that are applied when a
16889 message is received. These are described in chapter ~~CHAPrewrite. For example,
16890 .display asis
16891 headers_rewrite = a@b c@d f : \
16892                   x@y w@z
16893 .endd
16894 changes \a@@b\ into \c@@d\ in ::From:: header lines, and \x@@y\ into \w@@z\ in
16895 all address-bearing header lines. The rules are applied to the header lines
16896 just before they are written out at transport time, so they affect only those
16897 copies of the message that pass through the transport. However, only the
16898 message's original header lines, and any that were added by a system filter,
16899 are rewritten. If a router or transport adds header lines, they are
16900 not affected by this option. These rewriting rules are $it{not} applied to the
16901 envelope. You can change the return path using \return@_path\, but you cannot
16902 change envelope recipients at this time.
16903
16904 .conf home@_directory string$**$ unset
16905 .index transport||home directory for
16906 This option specifies a home directory setting for the transport, overriding
16907 any value that may be set by the router. The home directory is placed in
16908 \$home$\ while expanding the transport's private options. It is also used as
16909 the current directory if no current directory is set by the
16910 \current__directory\ option on the transport or the
16911 \transport__current__directory\ option on the router.
16912 If the expansion fails for any reason, including forced failure, an error is
16913 logged, and delivery is deferred.
16914
16915
16916 .index additional groups
16917 .index groups, additional
16918 .index transport||group, additional
16919 .conf initgroups boolean false
16920 If this option is true and the uid for the delivery process is provided by the
16921 transport, the \*initgroups()*\ function is called when running the transport
16922 to ensure that any additional groups associated with the uid are set up.
16923
16924 .conf message@_size@_limit string$**$ 0
16925 .index limit||message size per transport
16926 .index size||of message, limit
16927 .index transport||message size, limiting
16928 This option controls the size of messages passed through the transport. It is
16929 expanded before use; the result of the expansion must be a sequence of digits,
16930 optionally followed by K or M.
16931 If the expansion fails for any reason, including forced failure, or if the
16932 result is not of the required form, delivery is deferred.
16933 If the value is greater than zero and the size of a message exceeds this
16934 limit, the address is failed. If there is any chance that the resulting bounce
16935 message could be routed to the same transport, you should ensure that
16936 \return@_size@_limit\ is less than the transport's \message@_size@_limit\, as
16937 otherwise the bounce message will fail to get delivered.
16938
16939
16940 .conf rcpt@_include@_affixes boolean false
16941 .index prefix||for local part, including in envelope
16942 .index suffix||for local part, including in envelope
16943 .index local part||prefix
16944 .index local part||suffix
16945 When this option is false (the default), and an address that has had any
16946 affixes (prefixes or suffixes) removed from the local part is delivered by any
16947 form of SMTP or LMTP, the affixes are not included. For example, if a router
16948 that contains
16949 .display asis
16950 local_part_prefix = *-
16951 .endd
16952 routes the address \*abc-xyz@@some.domain*\ to an SMTP transport, the envelope
16953 is delivered with
16954 .display asis
16955 RCPT TO:<xyz@some.domain>
16956 .endd
16957 If \rcpt@_include@_affixes\ is set true, the whole local part is included in
16958 the \\RCPT\\ command. This option applies to BSMTP deliveries by the
16959 \%appendfile%\ and \%pipe%\ transports as well as to the \%lmtp%\ and \%smtp%\
16960 transports.
16961
16962 .conf retry@_use@_local@_part boolean "see below"
16963 .index hints database||retry keys
16964 When a delivery suffers a temporary failure, a retry record is created
16965 in Exim's hints database. For remote deliveries, the key for the retry record
16966 is based on the name and/or IP address of the failing remote host. For local
16967 deliveries, the key is normally the entire address, including both the local
16968 part and the domain. This is suitable for most common cases of local delivery
16969 temporary failure -- for example, exceeding a mailbox quota should delay only
16970 deliveries to that mailbox, not to the whole domain.
16971
16972 However, in some special cases you may want to treat a temporary local delivery
16973 as a failure associated with the domain, and not with a particular local part.
16974 (For example, if you are storing all mail for some domain in files.) You can do
16975 this by setting \retry@_use@_local@_part\ false.
16976
16977 For all the local transports, its default value is true. For remote transports,
16978 the default value is false for tidiness, but changing the value has no effect
16979 on a remote transport in the current implementation.
16980
16981 .conf return@_path string$**$ unset
16982 .index envelope sender
16983 .index transport||return path, changing
16984 .index return path||changing in transport
16985 If this option is set, the string is expanded at transport time and replaces
16986 the existing return path (envelope sender) value in the copy of the message
16987 that is being delivered. An empty return path is permitted. This feature is
16988 designed for remote deliveries, where the value of this option is used in the
16989 SMTP \\MAIL\\ command. If you set \return@_path\ for a local transport, the
16990 only effect is to change the address that is placed in the ::Return-path::
16991 header line, if one is added to the message (see the next option).
16992
16993 The expansion can refer to the existing value via \$return@_path$\. This is
16994 either the message's envelope sender, or an address set by the
16995 \errors@_to\ option on a router. If the expansion is forced to fail, no
16996 replacement occurs; if it fails for another reason, delivery is deferred. This
16997 option can be used to support VERP (Variable Envelope Return Paths) -- see
16998 chapter ~~CHAPSMTP.
16999
17000 \**Note**\: If a delivery error is detected locally,
17001 including the case when a remote server rejects a message at SMTP time,
17002 the bounce message is not sent to the value of this option, but to the
17003 previously set errors address (which defaults to the incoming sender address).
17004
17005
17006 .conf return@_path@_add boolean false
17007 .index ::Return-path:: header line
17008 If this option is true, a ::Return-path:: header is added to the message.
17009 Although the return path is normally available in the prefix line of BSD
17010 mailboxes, this is commonly not displayed by MUAs, and so the user does not
17011 have easy access to it.
17012
17013 RFC 2821 states that the ::Return-path:: header is added to a message `when the
17014 delivery SMTP server makes the final delivery'. This implies that this header
17015 should not be present in incoming messages. Exim has a configuration option,
17016 \return@_path@_remove\, which requests removal of this header from incoming
17017 messages, so that delivered messages can safely be resent to other recipients.
17018
17019 .conf shadow@_condition string$**$ unset
17020 See \shadow@_transport\ below.
17021
17022 .conf shadow@_transport string unset
17023 .index shadow transport
17024 .index transport||shadow
17025 A local transport may set the \shadow@_transport\ option to the name of another
17026 local transport. Shadow remote transports are not supported.
17027
17028 Whenever a delivery to the main transport succeeds, and either
17029 \shadow@_condition\ is unset, or its expansion does not result in the empty
17030 string or one of the strings `0' or `no' or `false', the message is also passed
17031 to the shadow transport, with the same delivery address or addresses.
17032 If expansion fails, no action is taken except that non-forced expansion
17033 failures cause a log line to be written.
17034
17035 The result of the shadow transport is discarded and does not affect the
17036 subsequent processing of the message. Only a single level of shadowing is
17037 provided; the \shadow@_transport\ option is ignored on any transport when it is
17038 running as a shadow. Options concerned with output from pipes are also ignored.
17039
17040 The log line for the successful delivery has an item added on the end, of the
17041 form
17042 .display
17043 ST=<<shadow transport name>>
17044 .endd
17045 If the shadow transport did not succeed, the error message is put in
17046 parentheses afterwards.
17047
17048 Shadow transports can be used for a number of different purposes, including
17049 keeping more detailed log information than Exim normally provides, and
17050 implementing automatic acknowledgement policies based on message headers that
17051 some sites insist on.
17052
17053 .conf transport@_filter string$**$ unset
17054 .index transport||filter
17055 .index filter||transport filter
17056 This option sets up a filtering (in the Unix shell sense) process for messages
17057 at transport time. It should not be confused with mail filtering as set up by
17058 individual users or via a system filter.
17059
17060 When the message is about to be written out, the command specified by
17061 \transport@_filter\ is started up in a separate process, and the entire
17062 message, including the header lines, is passed to it on its standard input
17063 (this in fact is done from a third process, to avoid deadlock).
17064 The command must be specified as an absolute path.
17065
17066 .em
17067 The lines of the message that are written to the transport filter are
17068 terminated by newline (`@\n').
17069 .nem
17070 The message is passed to the filter before any SMTP-specific processing, such
17071 as turning `@\n' into `@\r@\n' and escaping lines beginning with a dot, and
17072 also before any processing implied by the settings of \check@_string\ and
17073 \escape@_string\ in the \%appendfile%\ or \%pipe%\ transports.
17074
17075 .em
17076 The standard error for the filter process is set to the same destination as its 
17077 standard output; this is read and written to the message's ultimate
17078 destination.
17079 .nem
17080 The filter can perform any transformations it likes, but of course should take
17081 care not to break RFC 2822 syntax. A demonstration Perl script is provided in
17082 \(util/transport-filter.pl)\; this makes a few arbitrary modifications just to
17083 show the possibilities. Exim does not check the result, except to test for a
17084 final newline when SMTP is in use. All messages transmitted over SMTP must end
17085 with a newline, so Exim supplies one if it is missing.
17086
17087 .index SMTP||\\SIZE\\
17088 A problem might arise if the filter increases the size of a message that is
17089 being sent down an SMTP connection. If the receiving SMTP server has indicated
17090 support for the \\SIZE\\ parameter, Exim will have sent the size of the message
17091 at the start of the SMTP session. If what is actually sent is substantially
17092 more, the server might reject the message. This can be worked round by setting
17093 the \size@_addition\ option on the \%smtp%\ transport, either to allow for
17094 additions to the message, or to disable the use of \\SIZE\\ altogether.
17095
17096 The value of the \transport@_filter\ option is the command string for starting
17097 the filter, which is run directly from Exim, not under a shell. The string is
17098 parsed by Exim in the same way as a command string for the \%pipe%\ transport:
17099 Exim breaks it up into arguments and then expands each argument separately. The
17100 special argument \$pipe@_addresses$\ is replaced by a number of arguments, one
17101 for each address that applies to this delivery. (This isn't an ideal name for
17102 this feature here, but as it was already implemented for the \%pipe%\
17103 transport, it seemed sensible not to change it.)
17104
17105 .index \$host$\
17106 .index \$host@_address$\
17107 The expansion variables \$host$\ and \$host@_address$\ are available when the
17108 transport is a remote one. They contain the name and IP address of the host to
17109 which the message is being sent. For example:
17110 .display asis
17111 transport_filter = /some/directory/transport-filter.pl \
17112   $host $host_address $sender_address $pipe_addresses
17113 .endd
17114 The filter process is run under the same uid and gid as the normal delivery.
17115 For remote deliveries this is the Exim uid/gid by default.
17116 .em
17117 The command should normally yield a zero return code. A non-zero code is taken
17118 to mean that the transport filter failed in some way. Delivery of the message
17119 is deferred. It is not possible to cause a message to be bounced from a 
17120 transport filter.
17121 .nem
17122
17123 If a transport filter is set on an autoreply transport, the original message is
17124 passed through the filter as it is being copied into the newly generated
17125 message, which happens if the \return@_message\ option is set.
17126
17127 .conf transport@_filter@_timeout time 5m
17128 .index transport||filter, timeout
17129 When Exim is reading the output of a transport filter, it a applies a timeout
17130 that can be set by this option. Exceeding the timeout is treated as a
17131 temporary delivery failure.
17132
17133
17134 .conf user string$**$ "Exim user"
17135 .index uid (user id)||local delivery
17136 .index transport||user, specifying
17137 This option specifies the user under whose uid the delivery process is to be
17138 run, overriding any uid that may have been set by the router. If the user is
17139 given as a name, the uid is looked up from the password data, and the
17140 associated group is taken as the value of the gid to be used if the \group\
17141 option is not set.
17142
17143 For deliveries that use local transports, a user and group are normally
17144 specified explicitly or implicitly (for example, as a result of
17145 \check@_local@_user\) by the router or transport.
17146
17147 .index hints database||access by remote transport
17148 For remote transports, you should leave this option unset unless you really are
17149 sure you know what you are doing. When a remote transport is running, it needs
17150 to be able to access Exim's hints databases, because each host may have its own
17151 retry data.
17152
17153 .endconf
17154
17155
17156
17157
17158
17159 .
17160 .
17161 .
17162 . ============================================================================
17163 .chapter Address batching in local transports
17164 .set runningfoot "address batching"
17165 .rset CHAPbatching ~~chapter
17166 .index transport||local, address batching in
17167 The only remote transport (\%smtp%\) is normally configured to handle more than
17168 one address at a time, so that when several addresses are routed to the same
17169 remote host, just one copy of the message is sent. Local transports, however,
17170 normally handle one address at a time. That is, a separate instance of the
17171 transport is run for each address that is routed to the transport. A separate
17172 copy of the message is delivered each time.
17173
17174 .index batched local delivery
17175 .index \batch@_max\
17176 .index \batch@_id\
17177 In special cases, it may be desirable to handle several addresses at once in a
17178 local transport, for example:
17179 .numberpars $.
17180 In an \%appendfile%\ transport, when storing messages in files for later
17181 delivery by some other means, a single copy of the message with multiple
17182 recipients saves space.
17183 .nextp
17184 In an \%lmtp%\ transport, when delivering over `local SMTP' to some process,
17185 a single copy saves time, and is the normal way LMTP is expected to work.
17186 .nextp
17187 In a \%pipe%\ transport, when passing the message
17188 to a scanner program or
17189 to some other delivery mechanism such as UUCP, multiple recipients may be
17190 acceptable.
17191 .endp
17192 The three local transports (\%appendfile%\, \%lmtp%\, and \%pipe%\) all have
17193 the same options for controlling multiple (`batched') deliveries, namely
17194 \batch@_max\ and \batch@_id\. To save repeating the information for each
17195 transport, these options are described here.
17196
17197 The \batch@_max\ option specifies the maximum number of addresses that can be
17198 delivered together in a single run of the transport. Its default value is one.
17199 When more than one address is routed to a transport that has a \batch@_max\
17200 value greater than one, the addresses are delivered in a batch (that is, in a
17201 single run of the transport), subject to certain conditions:
17202 .numberpars $.
17203 If any of the transport's options contain a reference to \$local@_part$\, no
17204 batching is possible.
17205 .nextp
17206 If any of the transport's options contain a reference to \$domain$\, only
17207 addresses with the same domain are batched.
17208 .nextp
17209 .index customizing||batching condition
17210 If \batch@_id\ is set, it is expanded for each address, and only those
17211 addresses with the same expanded value are batched. This allows you to specify
17212 customized batching conditions.
17213 Failure of the expansion for any reason, including forced failure, disables
17214 batching, but it does not stop the delivery from taking place.
17215 .nextp
17216 Batched addresses must also have the same errors address (where to send
17217 delivery errors), the same header additions and removals, the same user and
17218 group for the transport, and if a host list is present, the first host must
17219 be the same.
17220 .endp
17221 .index ::Envelope-to:: header line
17222 If the generic \envelope@_to@_add\ option is set for the transport, the
17223 ::Envelope-to:: header that is added to the message contains all the addresses
17224 that are batched together.
17225
17226 The \%appendfile%\ and \%pipe%\ transports have an option called \use@_bsmtp\,
17227 which causes them to deliver the message in `batched SMTP' format, with the
17228 envelope represented as SMTP commands. The \check@_string\ and \escape@_string\
17229 options are forced to the values
17230 .display asis
17231 check_string = "."
17232 escape_string = ".."
17233 .endd
17234 when batched SMTP is in use. A full description of the batch SMTP mechanism is
17235 given in section ~~SECTbatchSMTP. The \%lmtp%\ transport does not have a
17236 \use@_bsmtp\ option, because it always delivers using the SMTP protocol.
17237
17238 .index \%pipe%\ transport||with multiple addresses
17239 If you are not using BSMTP, but are using a \%pipe%\ transport, you can include
17240 \$pipe@_addresses$\ as part of the command. This is not a true variable; it is
17241 a bit of magic that causes each of the recipient addresses to be inserted into
17242 the command as a separate argument. This provides a way of accessing all the
17243 addresses that are being delivered in the batch.
17244
17245 If you are using a batching \%appendfile%\ transport without \use@_bsmtp\, the
17246 only way to preserve the recipient addresses is to set the \envelope@_to@_add\
17247 option. This causes an ::Envelope-to:: header line to be added to the message,
17248 containing all the recipients.
17249
17250
17251
17252 .
17253 .
17254 .
17255 . ============================================================================
17256 .chapter The appendfile transport
17257 .set runningfoot "appendfile transport"
17258 .rset CHAPappendfile ~~chapter
17259 .index \%appendfile%\ transport
17260 .index transports||\%appendfile%\
17261 .index directory creation
17262 .index creating directories
17263 The \%appendfile%\ transport delivers a message by appending it to an existing
17264 file, or by creating an entirely new file in a specified directory. Single
17265 files to which messages are appended can be in the traditional Unix mailbox
17266 format, or optionally in the MBX format supported by the Pine MUA and
17267 University of Washington IMAP daemon, $it{inter alia}. When each message is
17268 being delivered as a separate file, `maildir' format can optionally be used to
17269 give added protection against failures that happen part-way through the
17270 delivery. A third form of separate-file delivery known as `mailstore' is also
17271 supported. For all file formats, Exim attempts to create as many levels of
17272 directory as necessary, provided that \create@_directory\ is set.
17273
17274 The code for the optional formats is not included in the Exim binary by
17275 default. It is necessary to set \\SUPPORT@_MBX\\, \\SUPPORT@_MAILDIR\\ and/or
17276 \\SUPPORT@_MAILSTORE\\ in \(Local/Makefile)\ to have the appropriate code
17277 included.
17278
17279 .index quota||system
17280 Exim recognises system quota errors, and generates an appropriate message. Exim
17281 also supports its own quota control within the transport, for use when the
17282 system facility is unavailable or cannot be used for some reason.
17283
17284 If there is an error while appending to a file (for example, quota exceeded or
17285 partition filled), Exim attempts to reset the file's length and last
17286 modification time back to what they were before. If there is an error while
17287 creating an entirely new file, the new file is removed.
17288
17289 Before appending to a file, a number of security checks are made, and the
17290 file is locked. A detailed description is given below, after the list of
17291 private options.
17292
17293 \%appendfile%\ is most commonly used for local deliveries to users' mailboxes.
17294 However, it can also be used as a pseudo-remote transport for putting messages
17295 into files for remote delivery by some means other than Exim. `Batch SMTP'
17296 format is often used in this case (see the \use@_bsmtp\ option).
17297
17298
17299 .section The file and directory options
17300 .rset SECTfildiropt "~~chapter.~~section"
17301 The \file\ option specifies a single file, to which the message is appended;
17302 the \directory\ option specifies a directory, in which a new file containing
17303 the message is created. Only one of these two options can be set, and for
17304 normal deliveries to mailboxes, one of them \*must*\ be set.
17305
17306 However, \%appendfile%\ is also used for delivering messages to files or
17307 directories whose names (or parts of names) are obtained from alias,
17308 forwarding, or filtering operations (for example, a \save\ command in a user's
17309 Exim filter). When such a transport is running, \$local@_part$\ contains the
17310 local part that was aliased or forwarded, and \$address@_file$\ contains the
17311 name (or partial name) of the file or directory generated by the redirection
17312 operation. There are two cases:
17313 .numberpars $.
17314 If neither \file\ nor \directory\ is set, the redirection operation
17315 must specify an absolute path (one that begins with \"/"\). This is the most
17316 common case when users with local accounts use filtering to sort mail into
17317 different folders. See for example, the \%address@_file%\ transport in the
17318 default configuration. If the path ends with a slash, it is assumed to be the
17319 name of a directory. A delivery to a directory can also be forced by setting
17320 \maildir@_format\ or \mailstore@_format\.
17321 .nextp
17322 If \file\ or \directory\ is set for a delivery from a redirection, it is used
17323 to determine the file or directory name for the delivery. Normally, the
17324 contents of \$address@_file$\ are used in some way in the string expansion.
17325 .endp
17326
17327 .index Sieve filter||configuring \%appendfile%\
17328 .index Sieve filter||relative mailbox path handling
17329 As an example of the second case, consider an environment where users do not
17330 have home directories. They may be permitted to use Exim filter commands of the
17331 form:
17332 .display asis
17333 save folder23
17334 .endd
17335 or Sieve filter commands of the form:
17336 .display asis
17337 require "fileinto";
17338 fileinto "folder23";
17339 .endd
17340 In this situation, the expansion of \file\ or \directory\ in the transport must
17341 transform the relative path into an appropriate absolute file name. In the case
17342 of Sieve filters, the name \*inbox*\ must be handled. It is the name that is
17343 used as a result of a `keep' action in the filter. This example shows one way
17344 of handling this requirement:
17345 .display asis
17346 file = ${if eq{$address_file}{inbox} \
17347             {/var/mail/$local_part} \
17348             {${if eq{${substr_0_1:$address_file}}{/} \
17349                   {$address_file} \
17350                   {$home/mail/$address_file} \
17351             }} \
17352        }
17353 .endd
17354 With this setting of \file\, \*inbox*\ refers to the standard mailbox location,
17355 absolute paths are used without change, and other folders are in the \(mail)\
17356 directory within the home directory.
17357
17358 \**Note 1**\: While processing an Exim filter, a relative path such as
17359 \(folder23)\ is turned into an absolute path if a home directory is known to
17360 the router. In particular, this is the case if \check@_local@_user\ is set. If
17361 you want to prevent this happening at routing time, you can set
17362 \router@_home@_directory\ empty. This forces the router to pass the relative
17363 path to the transport.
17364
17365 \**Note 2**\: An absolute path in \$address@_file$\ is not treated specially;
17366 the \file\ or \directory\ option is still used if it is set.
17367
17368
17369
17370 .section Private options for appendfile
17371 .index options||\%appendfile%\ transport
17372
17373 .startconf appendfile
17374
17375 .conf allow@_fifo boolean false
17376 .index fifo (named pipe)
17377 .index named pipe (fifo)
17378 .index pipe||named (fifo)
17379 Setting this option permits delivery to named pipes (FIFOs) as well as to
17380 regular files. If no process is reading the named pipe at delivery time, the
17381 delivery is deferred.
17382
17383 .conf allow@_symlink boolean false
17384 .index symbolic link||to mailbox
17385 .index mailbox||symbolic link
17386 By default, \%appendfile%\ will not deliver if the path name for the file is
17387 that of a symbolic link. Setting this option relaxes that constraint, but there
17388 are security issues involved in the use of symbolic links. Be sure you know
17389 what you are doing if you set this. Details of exactly what this option affects
17390 are included in the discussion which follows this list of options.
17391
17392 .conf batch@_id string$**$ unset
17393 See the description of local delivery batching in chapter ~~CHAPbatching.
17394 However, batching is automatically disabled for \%appendfile%\ deliveries that
17395 happen as a result of forwarding or aliasing or other redirection directly to a
17396 file.
17397
17398 .conf batch@_max integer 1
17399 See the description of local delivery batching in chapter ~~CHAPbatching.
17400
17401 .conf check@_group boolean false
17402 When this option is set, the group owner of the file defined by the \file\
17403 option is checked to see that it is the same as the group under which the
17404 delivery process is running. The default setting is false because the default
17405 file mode is 0600, which means that the group is irrelevant.
17406
17407 .conf check@_owner boolean true
17408 When this option is set, the owner of the file defined by the \file\ option is
17409 checked to ensure that it is the same as the user under which the delivery
17410 process is running.
17411
17412 .conf check@_string string "see below"
17413 .index `From' line
17414 As \%appendfile%\ writes the message, the start of each line is tested for
17415 matching \check@_string\, and if it does, the initial matching characters are
17416 replaced by the contents of \escape@_string\. The value of \check@_string\ is a
17417 literal string, not a regular expression, and the case of any letters it
17418 contains is significant.
17419
17420 If \use@_bsmtp\ is set the values of \check@_string\ and \escape@_string\ are
17421 forced to `.' and `..' respectively, and any settings in the configuration are
17422 ignored. Otherwise, they default to `From ' and `>From ' when the \file\ option
17423 is set, and unset when
17424 any of the \directory\, \maildir\, or \mailstore\ options are set.
17425
17426 The default settings, along with \message@_prefix\ and \message@_suffix\, are
17427 suitable for traditional `BSD' mailboxes, where a line beginning with `From '
17428 indicates the start of a new message. All four options need changing if another
17429 format is used. For example, to deliver to mailboxes in MMDF format:
17430 .index MMDF format mailbox
17431 .index mailbox||MMDF format
17432 .display asis
17433 check_string = "\1\1\1\1\n"
17434 escape_string = "\1\1\1\1 \n"
17435 message_prefix = "\1\1\1\1\n"
17436 message_suffix = "\1\1\1\1\n"
17437 .endd
17438
17439 .index directory creation
17440 .conf create@_directory boolean true
17441 When this option is true, Exim attempts to create any missing superior
17442 directories for the file that it is about to write. A created directory's mode
17443 is given by the \directory@_mode\ option.
17444 .em
17445 The group ownership of a newly created directory is highly dependent on the 
17446 operating system (and possibly the file system) that is being used. For
17447 example, in Solaris, if the parent directory has the setgid bit set, its group
17448 is propagated to the child; if not, the currently set group is used. However,
17449 in FreeBSD, the parent's group is always used.
17450 .nem
17451
17452 .conf create@_file string "anywhere"
17453 This option constrains the location of files and directories that are created
17454 by this transport. It applies to files defined by the \file\ option and
17455 directories defined by the \directory\ option. In the case of maildir delivery,
17456 it applies to the top level directory, not the maildir directories beneath.
17457
17458 The option must be set to one of the words `anywhere', `inhome', or
17459 `belowhome'. In the second and third cases, a home directory must have been set
17460 for the transport. This option is not useful when an explicit file name is
17461 given for normal mailbox deliveries. It is intended for the case when file
17462 names are generated from users' \(.forward)\ files. These are usually handled
17463 by an \%appendfile%\ transport called \address@_file\. See also
17464 \file@_must@_exist\.
17465
17466 .conf directory string$**$ unset
17467 This option is mutually exclusive with the \file\ option, but one of \file\ or
17468 \directory\ must be set, unless the delivery is the direct result of a
17469 redirection (see section ~~SECTfildiropt).
17470
17471 When \directory\ is set, the string is expanded, and the message is delivered
17472 into a new file or files in or below the given directory, instead of being
17473 appended to a single mailbox file. A number of different formats are provided
17474 (see \maildir@_format\ and \mailstore@_format\), and see section ~~SECTopdir
17475 for further details of this form of delivery.
17476
17477 .conf directory@_file string$**$ "$tt{q@$@{base62:@$tod@_epoch@}-@$inode}"
17478 .index base62
17479 When \directory\ is set, but neither \maildir@_format\ nor \mailstore@_format\
17480 is set, \%appendfile%\ delivers each message into a file whose name is obtained
17481 by expanding this string. The default value generates a unique name from the
17482 current time, in base 62 form, and the inode of the file. The variable
17483 \$inode$\ is available only when expanding this option.
17484
17485 .conf directory@_mode "octal integer" 0700
17486 If \%appendfile%\ creates any directories as a result of the \create@_directory\
17487 option, their mode is specified by this option.
17488
17489 .conf escape@_string string "see description"
17490 See \check@_string\ above.
17491
17492 .conf file string$**$ unset
17493 This option is mutually exclusive with the \directory\ option, but one of
17494 \file\ or \directory\ must be set, unless the delivery is the direct result of
17495 a redirection (see section ~~SECTfildiropt). The \file\ option specifies a
17496 single file, to which the message is appended. One or more of
17497 \use@_fcntl@_lock\, \use@_flock@_lock\, or \use@_lockfile\ must be set with
17498 \file\.
17499 .index NFS||lock file
17500 .index locking files
17501 .index lock files
17502 If you are using more than one host to deliver over NFS into the same
17503 mailboxes, you should always use lock files.
17504
17505 The string value is expanded for each delivery, and must yield an absolute
17506 path. The most common settings of this option are variations on one of these
17507 examples:
17508 .display asis
17509 file = /var/spool/mail/$local_part
17510 file = /home/$local_part/inbox
17511 file = $home/inbox
17512 .endd
17513 .index `sticky' bit
17514 In the first example, all deliveries are done into the same directory. If Exim
17515 is configured to use lock files (see \use@_lockfile\ below) it must be able to
17516 create a file in the directory, so the `sticky' bit must be turned on for
17517 deliveries to be possible, or alternatively the \group\ option can be used to
17518 run the delivery under a group id which has write access to the directory.
17519
17520
17521 .conf file@_format string unset
17522 .index file||mailbox, checking existing format
17523 This option requests the transport to check the format of an existing file
17524 before adding to it. The check consists of matching a specific string at the
17525 start of the file. The value of the option consists of an even number of
17526 colon-separated strings. The first of each pair is the test string, and the
17527 second is the name of a transport. If the transport associated with a matched
17528 string is not the current transport, control is passed over to the other
17529 transport. For example, suppose the standard \%local@_delivery%\ transport has
17530 this added to it:
17531 .display asis
17532 file_format = "From       : local_delivery :\
17533                \1\1\1\1\n : local_mmdf_delivery"
17534 .endd
17535 Mailboxes that begin with `From' are still handled by this transport, but if a
17536 mailbox begins with four binary ones followed by a newline, control is passed
17537 to a transport called \local__mmdf__delivery\, which presumably is configured
17538 to do the delivery in MMDF format. If a mailbox does not exist or is empty, it
17539 is assumed to match the current transport. If the start of a mailbox doesn't
17540 match any string, or if the transport named for a given string is not defined,
17541 delivery is deferred.
17542
17543 .conf file@_must@_exist boolean false
17544 If this option is true, the file specified by the \file\ option must exist, and
17545 an error occurs if it does not. Otherwise, it is created if it does not exist.
17546
17547 .conf lock@_fcntl@_timeout time 0s
17548 .index timeout||mailbox locking
17549 .index mailbox locking||blocking and non-blocking
17550 .index locking files
17551 By default, the \%appendfile%\ transport uses non-blocking calls to \*fcntl()*\
17552 when locking an open mailbox file. If the call fails, the delivery process
17553 sleeps for \lock@_interval\ and tries again, up to \lock@_retries\ times.
17554 Non-blocking calls are used so that the file is not kept open during the wait
17555 for the lock; the reason for this is to make it as safe as possible for
17556 deliveries over NFS in the case when processes might be accessing an NFS
17557 mailbox without using a lock file. This should not be done, but
17558 misunderstandings and hence misconfigurations are not unknown.
17559
17560 On a busy system, however, the performance of a non-blocking lock approach is
17561 not as good as using a blocking lock with a timeout. In this case, the waiting
17562 is done inside the system call, and Exim's delivery process acquires the lock
17563 and can proceed as soon as the previous lock holder releases it.
17564
17565 If \lock@_fcntl@_timeout\ is set to a non-zero time, blocking locks, with that
17566 timeout, are used. There may still be some retrying: the maximum number of
17567 retries is
17568 .display asis
17569 (lock_retries * lock_interval) / lock_fcntl_timeout
17570 .endd
17571 rounded up to the next whole number. In other words, the total time during
17572 which \%appendfile%\ is trying to get a lock is roughly the same, unless
17573 \lock@_fcntl@_timeout\ is set very large.
17574
17575 You should consider setting this option if you are getting a lot of delayed
17576 local deliveries because of errors of the form
17577 .display asis
17578 failed to lock mailbox /some/file (fcntl)
17579 .endd
17580
17581 .conf lock@_flock@_timeout time 0s
17582 This timeout applies to file locking when using \*flock()*\ (see \use@_flock\);
17583 the timeout operates in a similar manner to \lock@_fcntl@_timeout\.
17584
17585 .conf lock@_interval time 3s
17586 This specifies the time to wait between attempts to lock the file. See below
17587 for details of locking.
17588
17589 .conf lock@_retries integer 10
17590 This specifies the maximum number of attempts to lock the file. A value of zero
17591 is treated as 1. See below for details of locking.
17592
17593 .conf lockfile@_mode "octal integer" 0600
17594 This specifies the mode of the created lock file, when a lock file is being
17595 used (see \use@_lockfile\).
17596
17597 .conf lockfile@_timeout time 30m
17598 .index timeout||mailbox locking
17599 When a lock file is being used (see \use@_lockfile\), if a lock file already
17600 exists and is older than this value, it is assumed to have been left behind by
17601 accident, and Exim attempts to remove it.
17602
17603 .em
17604 .conf mailbox@_filecount string$**$ unset
17605 .index mailbox||specifying size of
17606 .index size||of mailbox
17607 If this option is set, it is expanded, and the result is taken as the current 
17608 number of files in the mailbox. It must be a decimal number, optionally 
17609 followed by K or M. This provides a way of obtaining this information from an 
17610 external source that maintains the data.
17611
17612 .conf mailbox@_size string$**$ unset
17613 .index mailbox||specifying size of
17614 .index size||of mailbox
17615 If this option is set, it is expanded, and the result is taken as the current
17616 size the mailbox. It must be a decimal number, optionally followed by K or M.
17617 This provides a way of obtaining this information from an external source that 
17618 maintains the data. This is likely to be helpful for maildir deliveries where 
17619 it is computationally expensive to compute the size of a mailbox.
17620 .nem
17621
17622 .conf maildir@_format boolean false
17623 .index maildir format||specifying
17624 If this option is set with the \directory\ option, the delivery is into a new
17625 file, in the `maildir' format that is used by other mail software. When the
17626 transport is activated directly from a \%redirect%\ router (for example, the
17627 \%address@_file%\ transport in the default configuration), setting
17628 \maildir@_format\ causes the path received from the router to be treated as a
17629 directory, whether or not it ends with \"/"\. This option is available only if
17630 \\SUPPORT@_MAILDIR\\ is present in \(Local/Makefile)\. See section
17631 ~~SECTmaildirdelivery below for further details.
17632
17633 .conf maildir@_quota@_directory@_regex string "See below"
17634 .index maildir format||quota, directories included in
17635 .index quota||maildir, directories included in
17636 This option is relevant only when \maildir@_use@_size@_file\ is set. It defines
17637 a regular expression for specifying directories that should be included in the
17638 quota calculation. The default value is
17639 .display asis
17640 maildir_quota_directory_regex = ^(?:cur|new|\..*)$
17641 .endd
17642 which includes the \(cur)\ and \(new)\ directories, and any maildir++ folders
17643 (directories whose names begin with a dot). If you want to exclude the
17644 \(Trash)\
17645 folder from the count (as some sites do), you need to change this setting to
17646 .display asis
17647 maildir_quota_directory_regex = ^(?:cur|new|\.(?!Trash).*)$
17648 .endd
17649 This uses a negative lookahead in the regular expression to exclude the
17650 directory whose name is \(.Trash)\.
17651
17652 .conf maildir@_retries integer 10
17653 This option specifies the number of times to retry when writing a file in
17654 `maildir' format. See section ~~SECTmaildirdelivery below.
17655
17656 .conf maildir@_tag string$**$ unset
17657 This option applies only to deliveries in maildir format, and is described in
17658 section ~~SECTmaildirdelivery below.
17659
17660 .conf maildir@_use@_size@_file boolean false
17661 .index maildir format||\(maildirsize)\ file
17662 Setting this option true enables support for \(maildirsize)\ files. Exim
17663 creates a \(maildirsize)\ file in a maildir if one does not exist, taking the
17664 quota from the \quota\ option of the transport. If \quota\ is unset, the value
17665 is zero. See section ~~SECTmaildirdelivery below for further details.
17666
17667 .conf mailstore@_format boolean false
17668 .index mailstore format||specifying
17669 If this option is set with the \directory\ option, the delivery is into two new
17670 files in  `mailstore' format. The option is available only if
17671 \\SUPPORT@_MAILSTORE\\ is present in \(Local/Makefile)\. See section
17672 ~~SECTopdir below for further details.
17673
17674 .conf mailstore@_prefix string$**$ unset
17675 This option applies only to deliveries in mailstore format, and is described in
17676 section ~~SECTopdir below.
17677
17678 .conf mailstore@_suffix string$**$ unset
17679 This option applies only to deliveries in mailstore format, and is described in
17680 section ~~SECTopdir below.
17681
17682 .conf mbx@_format boolean false
17683 .index locking files
17684 .index file||locking
17685 .index file||MBX format
17686 .index MBX format, specifying
17687 This option is available only if Exim has been compiled with \\SUPPORT@_MBX\\
17688 set in \(Local/Makefile)\. If \mbx@_format\ is set with the \file\ option,
17689 the message is appended to the mailbox file in MBX format instead of
17690 traditional Unix format. This format is supported by Pine4 and its associated
17691 IMAP and POP daemons, by means of the \*c-client*\ library that they all use.
17692
17693 \**Note**\: The \message@_prefix\ and \message@_suffix\ options are not
17694 automatically changed by the use of \mbx@_format\. They should normally be set
17695 empty when using MBX format, so this option almost always appears in this
17696 combination:
17697 .display asis
17698 mbx_format = true
17699 message_prefix =
17700 message_suffix =
17701 .endd
17702
17703 If none of the locking options are mentioned in the configuration,
17704 \use@_mbx@_lock\ is assumed and the other locking options default to false. It
17705 is possible to specify the other kinds of locking with \mbx@_format\, but
17706 \use@_fcntl@_lock\ and \use@_mbx@_lock\ are mutually exclusive. MBX locking
17707 interworks with \*c-client*\, providing for shared access to the mailbox. It
17708 should not be used if any program that does not use this form of locking is
17709 going to access the mailbox, nor should it be used if the mailbox file is NFS
17710 mounted, because it works only when the mailbox is accessed from a single host.
17711
17712 If you set \use@_fcntl@_lock\ with an MBX-format mailbox, you cannot use
17713 the standard version of \*c-client*\, because as long as it has a mailbox open
17714 (this means for the whole of a Pine or IMAP session), Exim will not be able to
17715 append messages to it.
17716
17717 .conf message@_prefix string$**$ "see below"
17718 .index `From' line
17719 The string specified here is expanded and output at the start of every message.
17720 The default is unset unless \file\ is specified and \use@_bsmtp\ is not set, in
17721 which case it is:
17722 .display asis
17723 message_prefix = "From ${if def:return_path{$return_path}\
17724   {MAILER-DAEMON}} $tod_bsdinbox\n"
17725 .endd
17726
17727 .conf message@_suffix string$**$ "see below"
17728 The string specified here is expanded and output at the end of every message.
17729 The default is unset unless \file\ is specified and \use@_bsmtp\ is not set, in
17730 which case it is a single newline character. The suffix can be suppressed by
17731 setting
17732 .display asis
17733 message_suffix =
17734 .endd
17735
17736 .conf mode "octal integer" 0600
17737 If the output file is created, it is given this mode. If it already exists and
17738 has wider permissions, they are reduced to this mode. If it has narrower
17739 permissions, an error occurs unless \mode__fail__narrower\ is false. However,
17740 if the delivery is the result of a \save\ command in a filter file specifing a
17741 particular mode, the mode of the output file is always forced to take that
17742 value, and this option is ignored.
17743
17744 .conf mode@_fail@_narrower boolean true
17745 This option applies in the case when an existing mailbox file has a narrower
17746 mode than that specified by the \mode\ option. If \mode@_fail@_narrower\ is
17747 true, the delivery is deferred (`mailbox has the wrong mode'); otherwise Exim
17748 continues with the delivery attempt, using the existing mode of the file.
17749
17750 .conf notify@_comsat boolean false
17751 If this option is true, the \*comsat*\ daemon is notified after every successful
17752 delivery to a user mailbox. This is the daemon that notifies logged on users
17753 about incoming mail.
17754
17755 .conf quota string$**$ unset
17756 .index quota||imposed by Exim
17757 This option imposes a limit on the size of the file to which Exim is appending,
17758 or to the total space used in the directory tree when the \directory\ option is
17759 set. In the latter case, computation of the space used is expensive, because
17760 all the files in the directory (and any sub-directories) have to be
17761 individually inspected and their sizes summed.
17762 (See \quota@_size@_regex\ and \maildir@_use@_size@_file\ for ways to avoid this
17763 in environments where users have no shell access to their mailboxes).
17764
17765 As there is no interlock against two simultaneous deliveries into a
17766 multi-file mailbox, it is possible for the quota to be overrun in this case.
17767 For single-file mailboxes, of course, an interlock is a necessity.
17768
17769 A file's size is taken as its \*used*\ value. Because of blocking effects, this
17770 may be a lot less than the actual amount of disk space allocated to the file.
17771 If the sizes of a number of files are being added up, the rounding effect can
17772 become quite noticeable, especially on systems that have large block sizes.
17773 Nevertheless, it seems best to stick to the \*used*\ figure, because this is
17774 the obvious value which users understand most easily.
17775
17776 The value of the option is expanded, and must then be a numerical value
17777 (decimal point allowed), optionally followed by one of the letters K or M. The
17778 expansion happens while Exim is running as root, before it changes uid for the
17779 delivery. This means that files which are inaccessible to the end user can be
17780 used to hold quota values that are looked up in the expansion. When delivery
17781 fails because this quota is exceeded, the handling of the error is as for
17782 system quota failures.
17783
17784 \**Note**\: A value of zero is interpreted as `no quota'.
17785
17786 By default, Exim's quota checking mimics system quotas, and restricts the
17787 mailbox to the specified maximum size, though the value is not accurate to the
17788 last byte, owing to separator lines and additional headers that may get added
17789 during message delivery. When a mailbox is nearly full, large messages may get
17790 refused even though small ones are accepted, because the size of the current
17791 message is added to the quota when the check is made. This behaviour can be
17792 changed by setting \quota@_is@_inclusive\ false. When this is done, the check
17793 for exceeding the quota does not include the current message. Thus, deliveries
17794 continue until the quota has been exceeded; thereafter, no further messages are
17795 delivered. See also \quota@_warn@_threshold\.
17796
17797 .conf quota@_directory string$**$ unset
17798 This option defines the directory to check for quota purposes when delivering
17799 into individual files. The default is the delivery directory, or, if a file
17800 called \(maildirfolder)\ exists in a maildir directory, the parent of the
17801 delivery directory.
17802
17803 .conf quota@_filecount string$**$ 0
17804 This option applies when the \directory\ option is set. It limits the total
17805 number of files in the directory (compare the inode limit in system quotas). It
17806 can only be used if \quota\ is also set. The value is expanded; an expansion
17807 failure causes delivery to be deferred.
17808
17809 .conf quota@_is@_inclusive boolean true
17810 See \quota\ above.
17811
17812 .conf quota@_size@_regex string unset
17813 This option applies when one of the delivery modes that writes a separate file
17814 for each message is being used. When Exim wants to find the size of one of
17815 these files in order to test the quota, it first checks \quota@_size@_regex\.
17816 If this is set to a regular expression that matches the file name, and it
17817 captures one string, that string is interpreted as a representation of the
17818 file's size. The value of \quota@_size@_regex\ is not expanded.
17819
17820 This feature is useful only when users have no shell access to their mailboxes
17821 -- otherwise they could defeat the quota simply by renaming the files. This
17822 facility can be used with maildir deliveries, by setting \maildir@_tag\ to add
17823 the file length to the file name. For example:
17824 .display asis
17825 maildir_tag = ,S=$message_size
17826 quota_size_regex = ,S=(\d+)
17827 .endd
17828 The regular expression should not assume that the length is at the end of the
17829 file name (even though \maildir@_tag\ puts it there) because maildir MUAs
17830 sometimes add other information onto the ends of message file names.
17831
17832 .conf quota@_warn@_message string$**$ "see below"
17833 See below for the use of this option. If it is not set when
17834 \quota@_warn@_threshold\ is set, it defaults to
17835 .display asis
17836 quota_warn_message = "\
17837   To: $local_part@$domain\n\
17838   Subject: Your mailbox\n\n\
17839   This message is automatically created \
17840   by mail delivery software.\n\n\
17841   The size of your mailbox has exceeded \
17842   a warning threshold that is\n\
17843   set by the system administrator.\n"
17844 .endd
17845
17846 .conf quota@_warn@_threshold string$**$ 0
17847 .index quota||warning threshold
17848 .index mailbox||size warning
17849 .index size||of mailbox
17850 This option is expanded in the same way as \quota\ (see above). If the
17851 resulting value is greater than zero, and delivery of the message causes the
17852 size of the file or total space in the directory tree to cross the given
17853 threshold, a warning message is sent. If \quota\ is also set, the threshold may
17854 be specified as a percentage of it by following the value with a percent sign.
17855 For example:
17856 .display asis
17857 quota = 10M
17858 quota_warn_threshold = 75%
17859 .endd
17860 If \quota\ is not set, a setting of \quota@_warn@_threshold\ that ends with a
17861 percent sign is ignored.
17862
17863 The warning message itself is specified by the \quota@_warn@_message\ option,
17864 and it must start with a ::To:: header line containing the recipient(s). A
17865 ::Subject:: line should also normally be supplied. The \quota\ option does not
17866 have to be set in order to use this option; they are independent of one
17867 another except when the threshold is specified as a percentage.
17868
17869 .conf use@_bsmtp boolean false
17870 .index envelope sender
17871 If this option is set true, \%appendfile%\ writes messages in `batch SMTP'
17872 format, with the envelope sender and recipient(s) included as SMTP commands. If
17873 you want to include a leading \\HELO\\ command with such messages, you can do
17874 so by setting the \message@_prefix\ option. See section ~~SECTbatchSMTP for
17875 details of batch SMTP.
17876
17877 .conf use@_crlf boolean false
17878 .index carriage return
17879 .index linefeed
17880 This option causes lines to be terminated with the two-character CRLF sequence
17881 (carriage return, linefeed) instead of just a linefeed character. In the case
17882 of batched SMTP, the byte sequence written to the file is then an exact image
17883 of what would be sent down a real SMTP connection.
17884
17885 The contents of the \message@_prefix\ and \message@_suffix\ options are written
17886 verbatim, so must contain their own carriage return characters if these are
17887 needed. In cases where these options have non-empty defaults, the values end
17888 with a single linefeed, so they
17889 must
17890 be changed to end with \"@\r@\n"\ if \use@_crlf\ is set.
17891
17892 .conf use@_fcntl@_lock boolean "see below"
17893 This option controls the use of the \*fcntl()*\ function to lock a file for
17894 exclusive use when a message is being appended. It is set by default unless
17895 \use@_flock@_lock\ is set. Otherwise, it should be turned off only if you know
17896 that all your MUAs use lock file locking. When both \use@_fcntl@_lock\ and
17897 \use@_flock@_lock\ are unset, \use@_lockfile\ must be set.
17898
17899 .conf use@_flock@_lock boolean false
17900 This option is provided to support the use of \*flock()*\ for file locking, for
17901 the few situations where it is needed. Most modern operating systems support
17902 \*fcntl()*\ and \*lockf()*\ locking, and these two functions interwork with
17903 each other. Exim uses \*fcntl()*\ locking by default.
17904
17905 This option is required only if you are using an operating system where
17906 \*flock()*\ is used by programs that access mailboxes (typically MUAs), and
17907 where \*flock()*\ does not correctly interwork with \*fcntl()*\. You can use
17908 both \*fcntl()*\ and \*flock()*\ locking simultaneously if you want.
17909
17910 .index Solaris||\*flock()*\ support
17911 Not all operating systems provide \*flock()*\. Some versions of Solaris do not
17912 have it (and some, I think, provide a not quite right version built on top of
17913 \*lockf()*\). If the OS does not have \*flock()*\, Exim will be built without
17914 the ability to use it, and any attempt to do so will cause a configuration
17915 error.
17916
17917 \**Warning**\: \*flock()*\ locks do not work on NFS files (unless \*flock()*\
17918 is just being mapped onto \*fcntl()*\ by the OS).
17919
17920 .conf use@_lockfile boolean "see below"
17921 If this option is turned off, Exim does not attempt to create a lock file when
17922 appending to a mailbox file. In this situation, the only locking is by
17923 \*fcntl()*\. You should only turn \use@_lockfile\ off if you are absolutely
17924 sure that every MUA that is ever going to look at your users' mailboxes uses
17925 \*fcntl()*\ rather than a lock file, and even then only when you are not
17926 delivering over NFS from more than one host.
17927
17928 .index NFS||lock file
17929 In order to append to an NFS file safely from more than one host, it is
17930 necessary to take out a lock $it{before} opening the file, and the lock file
17931 achieves this. Otherwise, even with \*fcntl()*\ locking, there is a risk of
17932 file corruption.
17933
17934 The \use@_lockfile\ option is set by default unless \use@_mbx@_lock\ is set. It
17935 is not possible to turn both \use@_lockfile\ and \use@_fcntl@_lock\ off, except
17936 when \mbx@_format\ is set.
17937
17938 .conf use@_mbx@_lock boolean "see below"
17939 This option is available only if Exim has been compiled with \\SUPPORT@_MBX\\
17940 set in \(Local/Makefile)\. Setting the option specifies that special MBX
17941 locking rules be used. It is set by default if \mbx@_format\ is set and none of
17942 the locking options are mentioned in the configuration. The locking rules are
17943 the same as are used by the \*c-client*\ library that underlies Pine and the
17944 IMAP4 and POP daemons that come with it (see the discussion below). The rules
17945 allow for shared access to the mailbox. However, this kind of locking does not
17946 work when the mailbox is NFS mounted.
17947
17948 You can set \use@_mbx@_lock\ with either (or both) of \use@_fcntl@_lock\ and
17949 \use@_flock@_lock\ to control what kind of locking is used in implementing the
17950 MBX locking rules. The default is to use \*fcntl()*\ if \use@_mbx@_lock\ is set
17951 without \use@_fcntl@_lock\ or \use@_flock@_lock\.
17952 .endconf
17953
17954
17955 .section Operational details for appending
17956 .rset SECTopappend "~~chapter.~~section"
17957 .index appending to a file
17958 .index file||appending
17959 Before appending to a file, the following preparations are made:
17960 .numberpars $.
17961 If the name of the file is \(/dev/null)\, no action is taken, and a success
17962 return is given.
17963 .nextp
17964 .index directory creation
17965 If any directories on the file's path are missing, Exim creates them if the
17966 \create@_directory\ option is set. A created directory's mode is given by the
17967 \directory@_mode\ option.
17968 .nextp
17969 If \file@_format\ is set, the format of an existing file is checked. If this
17970 indicates that a different transport should be used, control is passed to that
17971 transport.
17972 .nextp
17973 .index file||locking
17974 .index locking files
17975 .index NFS||lock file
17976 If \use@_lockfile\ is set, a lock file is built in a way that will work
17977 reliably over NFS, as follows:
17978 .numberpars $.
17979 Create a `hitching post' file whose name is that of the lock file with the
17980 current time, primary host name, and process id added, by opening for writing
17981 as a new file. If this fails with an access error, delivery is deferred.
17982 .nextp
17983 Close the hitching post file, and hard link it to the lock file name.
17984 .nextp
17985 If the call to \*link()*\ succeeds, creation of the lock file has succeeded.
17986 Unlink the hitching post name.
17987 .nextp
17988 Otherwise, use \*stat()*\ to get information about the hitching post file, and
17989 then unlink hitching post name. If the number of links is exactly two, creation
17990 of the lock file succeeded but something (for example, an NFS server crash and
17991 restart) caused this fact not to be communicated to the \*link()*\ call.
17992 .nextp
17993 If creation of the lock file failed, wait for \lock@_interval\ and try again,
17994 up to \lock@_retries\ times. However, since any program that writes to a
17995 mailbox should complete its task very quickly, it is reasonable to time out old
17996 lock files that are normally the result of user agent and system crashes. If an
17997 existing lock file is older than \lockfile@_timeout\ Exim attempts to unlink it
17998 before trying again.
17999 .endp
18000 .nextp
18001 A call is made to \*lstat()*\ to discover whether the main file exists, and if
18002 so, what its characteristics are. If \*lstat()*\ fails for any reason other
18003 than non-existence, delivery is deferred.
18004 .nextp
18005 .index symbolic link||to mailbox
18006 .index mailbox||symbolic link
18007 If the file does exist and is a symbolic link, delivery is deferred, unless the
18008 \allow@_symlink\ option is set, in which case the ownership of the link is
18009 checked, and then \*stat()*\ is called to find out about the real file, which
18010 is then subjected to the checks below. The check on the top-level link
18011 ownership prevents one user creating a link for another's mailbox in a sticky
18012 directory, though allowing symbolic links in this case is definitely not a good
18013 idea. If there is a chain of symbolic links, the intermediate ones are not
18014 checked.
18015 .nextp
18016 If the file already exists but is not a regular file, or if the file's owner
18017 and group (if the group is being checked -- see \check@_group\ above) are
18018 different from the user and group under which the delivery is running,
18019 delivery is deferred.
18020 .nextp
18021 If the file's permissions are more generous than specified, they are reduced.
18022 If they are insufficient, delivery is deferred, unless \mode@_fail@_narrower\
18023 is set false, in which case the delivery is tried using the existing
18024 permissions.
18025 .nextp
18026 The file's inode number is saved, and the file is then opened for appending. If
18027 this fails because the file has vanished, \%appendfile%\ behaves as if it hadn't
18028 existed (see below). For any other failures, delivery is deferred.
18029 .nextp
18030 If the file is opened successfully, check that the inode number hasn't
18031 changed, that it is still a regular file, and that the owner and permissions
18032 have not changed. If anything is wrong, defer delivery and freeze the message.
18033 .nextp
18034 If the file did not exist originally, defer delivery if the \file@_must@_exist\
18035 option is set. Otherwise, check that the file is being created in a permitted
18036 directory if the \create@_file\ option is set (deferring on failure), and then
18037 open for writing as a new file, with the \\O@_EXCL\\ and \\O@_CREAT\\ options,
18038 except when dealing with a symbolic link (the \allow@_symlink\ option must be
18039 set). In this case, which can happen if the link points to a non-existent file,
18040 the file is opened for writing using \\O@_CREAT\\ but not \\O@_EXCL\\, because
18041 that prevents link following.
18042 .nextp
18043 .index loop||while file testing
18044 If opening fails because the file exists, obey the tests given above for
18045 existing files. However, to avoid looping in a situation where the file is
18046 being continuously created and destroyed, the exists/not-exists loop is broken
18047 after 10 repetitions, and the message is then frozen.
18048 .nextp
18049 If opening fails with any other error, defer delivery.
18050 .nextp
18051 .index file||locking
18052 .index locking files
18053 Once the file is open, unless both \use@_fcntl@_lock\ and \use@_flock@_lock\
18054 are false, it is locked using \*fcntl()*\ or \*flock()*\ or both. If
18055 \use@_mbx@_lock\ is false, an exclusive lock is requested in each case.
18056 However, if \use@_mbx@_lock\ is true,
18057 Exim takes out a shared lock on the open file,
18058 and an exclusive lock on the file whose name is
18059 .display
18060 /tmp/.<<device-number>>.<<inode-number>>
18061 .endd
18062 using the device and inode numbers of the open mailbox file, in accordance with
18063 the MBX locking rules.
18064
18065 If Exim fails to lock the file, there are two possible courses of action,
18066 depending on the value of the locking timeout. This is obtained from
18067 \lock@_fcntl@_timeout\ or \lock@_flock@_timeout\, as appropriate.
18068
18069 If the timeout value is zero, the file is closed, Exim waits for
18070 \lock@_interval\, and then goes back and re-opens the file as above and tries
18071 to lock it again. This happens up to \lock@_retries\ times, after which the
18072 delivery is deferred.
18073
18074 If the timeout has a value greater than zero, blocking calls to \*fcntl()*\ or
18075 \*flock()*\ are used (with the given timeout), so there has already been some
18076 waiting involved by the time locking fails. Nevertheless, Exim does not give up
18077 immediately. It retries up to
18078 .display
18079 (lock@_retries * lock@_interval) / <<timeout>>
18080 .endd
18081 times (rounded up).
18082 .endp
18083
18084 At the end of delivery, Exim closes the file (which releases the \*fcntl()*\
18085 and/or \*flock()*\ locks) and then deletes the lock file if one was created.
18086
18087 .section Operational details for delivery to a new file
18088 .rset SECTopdir "~~chapter.~~section"
18089 .index delivery||to single file
18090 .index `From' line
18091 When the \directory\ option is set instead of \file\, each message is delivered
18092 into a newly-created file or set of files. When \%appendfile%\ is activated
18093 directly from a \%redirect%\ router, neither \file\ nor \directory\ is normally
18094 set, because the path for delivery is supplied by the router. (See for example,
18095 the \%address@_file%\ transport in the default configuration.) In this case,
18096 delivery is to a new file if either the path name ends in \"/"\, or the
18097 \maildir@_format\ or \mailstore@_format\ option is set.
18098
18099 No locking is required while writing the message to a new file, so the various
18100 locking options of the transport are ignored. The `From' line that by default
18101 separates messages in a single file is not normally needed, nor is the escaping
18102 of message lines that start with `From', and there is no need to ensure a
18103 newline at the end of each message. Consequently, the default values for
18104 \check@_string\, \message@_prefix\, and \message@_suffix\ are all unset when
18105 any of \directory\, \maildir@_format\, or \mailstore@_format\ is set.
18106
18107 If Exim is required to check a \quota\ setting, it adds up the sizes of all the
18108 files in the delivery directory by default. However, you can specify a
18109 different directory by setting \quota@_directory\. Also, for maildir deliveries
18110 (see below) the \(maildirfolder)\ convention is honoured.
18111
18112
18113 .index maildir format
18114 .index mailstore format
18115 There are three different ways in which delivery to individual files can be
18116 done, controlled by the settings of the \maildir@_format\ and
18117 \mailstore@_format\ options. Note that code to support maildir or mailstore
18118 formats is not included in the binary unless \\SUPPORT@_MAILDIR\\ or
18119 \\SUPPORT@_MAILSTORE\\, respectively, is set in \(Local/Makefile)\.
18120
18121 .index directory creation
18122 In all three cases an attempt is made to create the directory and any necessary
18123 sub-directories if they do not exist, provided that the \create@_directory\
18124 option is set (the default). The location of a created directory can be
18125 constrained by setting \create@_file\. A created directory's mode is given by
18126 the \directory@_mode\ option. If creation fails, or if the \create@_directory\
18127 option is not set when creation is required, delivery is deferred.
18128
18129
18130 .section Maildir delivery
18131 .rset SECTmaildirdelivery "~~chapter.~~section"
18132 .index maildir format||description of
18133 If the \maildir@_format\ option is true, Exim delivers each message by writing
18134 it to a file whose name is \(tmp/<<stime>>.H<<mtime>>P<<pid>>.<<host>>)\ in the
18135 given directory. If the delivery is successful, the file is renamed into the
18136 \(new)\ subdirectory.
18137
18138 In the file name, <<stime>> is the current time of day in seconds, and
18139 <<mtime>> is the microsecond fraction of the time. After a maildir delivery,
18140 Exim checks that the time-of-day clock has moved on by at least one microsecond
18141 before terminating the delivery process. This guarantees uniqueness for the
18142 file name. However, as a precaution, Exim calls \*stat()*\ for the file before
18143 opening it. If any response other than \\ENOENT\\ (does not exist) is given,
18144 Exim waits 2 seconds and tries again, up to \maildir@_retries\ times.
18145
18146 .index quota||in maildir delivery
18147 .index maildir++
18148 If Exim is required to check a \quota\ setting before a maildir delivery, and
18149 \quota@_directory\ is not set, it looks for a file called \(maildirfolder)\ in
18150 the maildir directory (alongside \(new)\, \(cur)\, \(tmp)\). If this exists,
18151 Exim assumes the directory is a maildir++ folder directory, which is one level
18152 down from the user's top level mailbox directory. This causes it to start at
18153 the parent directory instead of the current directory when calculating the
18154 amount of space used.
18155
18156 .em
18157 One problem with delivering into a multi-file mailbox is that it is 
18158 computationally expensive to compute the size of the mailbox for quota 
18159 checking. Various approaches have been taken to reduce the amount of work 
18160 needed. The next two sections describe two of them. A third alternative is to 
18161 use some external process for maintaining the size data, and use the expansion 
18162 of the \mailbox@_size\ option as a way of importing it into Exim.
18163 .nem
18164
18165
18166 .section Using tags to record message sizes
18167 If \maildir@_tag\ is set, the string is expanded for each delivery.
18168 When the maildir file is renamed into the \(new)\ sub-directory, the
18169 tag is added to its name. However, if adding the tag takes the length of the
18170 name to the point where the test \*stat()*\ call fails with \\ENAMETOOLONG\\,
18171 the tag is dropped and the maildir file is created with no tag.
18172
18173 Tags can be used to encode the size of files in their names; see
18174 \quota@_size@_regex\ above for an example. The expansion of \maildir@_tag\
18175 happens after the message has been written. The value of the \$message@_size$\
18176 variable is set to the number of bytes actually written. If the expansion is
18177 forced to fail, the tag is ignored, but a non-forced failure causes delivery to
18178 be deferred. The expanded tag may contain any printing characters except `/'.
18179 Non-printing characters in the string are ignored; if the resulting string is
18180 empty, it is ignored. If it starts with an alphanumeric character, a leading
18181 colon is inserted.
18182
18183
18184 .section Using a maildirsize file
18185 .index quota||in maildir delivery
18186 .index maildir format||\(maildirsize)\ file
18187 If \maildir@_use@_size@_file\ is true, Exim implements the maildir++ rules for
18188 storing quota and message size information in a file called \(maildirsize)\
18189 within the maildir directory. If this file does not exist, Exim creates it,
18190 setting the quota from the \quota\ option of the transport. If the maildir
18191 directory itself does not exist, it is created before any attempt to write a
18192 \(maildirsize)\ file.
18193
18194 The \(maildirsize)\ file is used to hold information about the sizes of
18195 messages in the maildir, thus speeding up quota calculations. The quota value
18196 in the file is just a cache; if the quota is changed in the transport, the new
18197 value overrides the cached value when the next message is delivered. The cache
18198 is maintained for the benefit of other programs that access the maildir and
18199 need to know the quota.
18200
18201 If the \quota\ option in the transport is unset or zero, the \(maildirsize)\
18202 file is maintained (with a zero quota setting), but no quota is imposed.
18203
18204 A regular expression is available for controlling which directories in the
18205 maildir participate in quota calculations. See the description of the
18206 \maildir@_quota@_directory@_regex\ option above for details.
18207
18208
18209 .section Mailstore delivery
18210 .index mailstore format||description of
18211 If the \mailstore@_format\ option is true, each message is written as two files
18212 in the given directory. A unique base name is constructed from the message id
18213 and the current delivery process, and the files that are written use this base
18214 name plus the suffixes \(.env)\ and \(.msg)\. The \(.env)\ file contains the
18215 message's envelope, and the \(.msg)\ file contains the message itself.
18216
18217 During delivery, the envelope is first written to a file with the suffix
18218 \(.tmp)\. The \(.msg)\ file is then written, and when it is complete, the
18219 \(.tmp)\ file is renamed as the \(.env)\ file. Programs that access messages in
18220 mailstore format should wait for the presence of both a \(.msg)\ and a \(.env)\
18221 file before accessing either of them. An alternative approach is to wait for
18222 the absence of a \(.tmp)\ file.
18223
18224 The envelope file starts with any text defined by the \mailstore@_prefix\
18225 option, expanded and terminated by a newline if there isn't one. Then follows
18226 the sender address on one line, then all the recipient addresses, one per line.
18227 There can be more than one recipient only if the \batch@_max\ option is set
18228 greater than one. Finally, \mailstore@_suffix\ is expanded and the result
18229 appended to the file, followed by a newline if it does not end with one.
18230
18231 If expansion of \mailstore@_prefix\ or \mailstore@_suffix\ ends with a forced
18232 failure, it is ignored. Other expansion errors are treated as serious
18233 configuration errors, and delivery is deferred.
18234
18235
18236 .section Non-special new file delivery
18237 If neither \maildir@_format\ nor \mailstore@_format\ is set, a single new file
18238 is created directly in the named directory. For example, when delivering
18239 messages into files in batched SMTP format for later delivery to some host (see
18240 section ~~SECTbatchSMTP), a setting such as
18241 .display asis
18242 directory = /var/bsmtp/$host
18243 .endd
18244 might be used. A message is written to a file with a temporary name, which is
18245 then renamed when the delivery is complete. The final name is obtained by
18246 expanding the contents of the \directory@_file\ option.
18247
18248
18249
18250
18251
18252 .
18253 .
18254 .
18255 .
18256 . ============================================================================
18257 .chapter The autoreply transport
18258 .set runningfoot "autoreply transport"
18259 .index transports||\%autoreply%\
18260 .index \%autoreply%\ transport
18261 The \%autoreply%\ transport is not a true transport in that it does not cause
18262 the message to be transmitted. Instead, it generates a new mail message.
18263 .em
18264 If the router that passes the message to this transport does not have the 
18265 \unseen\ option set, the original message (for the current recipient) is not
18266 delivered anywhere. However, when the \unseen\ option is set on the router that
18267 passes the message to this transport, routing of the address continues, so
18268 another router can set up a normal message delivery.
18269 .nem
18270
18271 The \%autoreply%\ transport is usually run as the result of mail filtering, a
18272 `vacation' message being the standard example. However, it can also be run
18273 directly from a router like any other transport. To reduce the possibility of
18274 message cascades, messages created by the \%autoreply%\ transport always have
18275 empty envelope sender addresses, like bounce messages.
18276
18277 The parameters of the message to be sent can be specified in the configuration
18278 by options described below. However, these are used only when the address
18279 passed to the transport does not contain its own reply information. When the
18280 transport is run as a consequence of a
18281 \mail\
18282 or \vacation\ command in a filter file, the parameters of the message are
18283 supplied by the filter, and passed with the address. The transport's options
18284 that define the message are then ignored (so they are not usually set in this
18285 case). The message is specified entirely by the filter or by the transport; it
18286 is never built from a mixture of options. However, the \file@_optional\,
18287 \mode\, and \return@_message\ options apply in all cases.
18288
18289 \%Autoreply%\ is implemented as a local transport. When used as a result of a
18290 command in a user's filter file, \%autoreply%\ normally runs under the uid and
18291 gid of the user, and with appropriate current and home directories (see chapter
18292 ~~CHAPenvironment).
18293
18294 There is a subtle difference between routing a message to a \%pipe%\ transport
18295 that generates some text to be returned to the sender, and routing it to an
18296 \%autoreply%\ transport. This difference is noticeable only if more than one
18297 address from the same message is so handled. In the case of a pipe, the
18298 separate outputs from the different addresses are gathered up and returned to
18299 the sender in a single message, whereas if \%autoreply%\ is used, a separate
18300 message is generated for each address that is passed to it.
18301
18302 Non-printing characters are not permitted in the header lines generated for the
18303 message that \%autoreply%\ creates, with the exception of newlines that are
18304 immediately followed by whitespace. If any non-printing characters are found,
18305 the transport defers.
18306 Whether characters with the top bit set count as printing characters or not is
18307 controlled by the \print@_topbitchars\ global option.
18308
18309 If any of the generic options for manipulating headers (for example,
18310 \headers@_add\) are set on an \%autoreply%\ transport, they apply to the copy of
18311 the original message that is included in the generated message when
18312 \return@_message\ is set. They do not apply to the generated message itself.
18313
18314 If the \%autoreply%\ transport receives return code 2 from Exim when it submits
18315 the message, indicating that there were no recipients, it does not treat this
18316 as an error. This means that autoreplies sent to \$sender@_address$\ when this
18317 is empty (because the incoming message is a bounce message) do not cause
18318 problems. They are just discarded.
18319
18320
18321 .section Private options for autoreply
18322
18323 .startconf autoreply
18324 .index options||\%autoreply%\ transport
18325 .conf bcc string$**$ unset
18326 This specifies the addresses that are to receive `blind carbon copies' of the
18327 message when the message is specified by the transport.
18328
18329 .conf cc string$**$ unset
18330 This specifies recipients of the message and the contents of the ::Cc:: header
18331 when the message is specified by the transport.
18332
18333 .conf file string$**$ unset
18334 The contents of the file are sent as the body of the message when the message
18335 is specified by the transport. If both \file\ and \text\ are set, the text
18336 string comes first.
18337
18338 .conf file@_expand boolean false
18339 If this is set, the contents of the file named by the \file\ option are
18340 subjected to string expansion as they are added to the message.
18341
18342 .conf file@_optional boolean false
18343 If this option is true, no error is generated if the file named by the \file\
18344 option or passed with the address does not exist or cannot be read.
18345
18346 .conf from string$**$ unset
18347 This specifies the contents of the ::From:: header when the message is specified
18348 by the transport.
18349
18350 .conf headers string$**$ unset
18351 This specifies additional RFC 2822 headers that are to be added to the message when
18352 the message is specified by the transport. Several can be given by using `@\n'
18353 to separate them. There is no check on the format.
18354
18355 .conf log string$**$ unset
18356 This option names a file in which a record of every message sent is logged when
18357 the message is specified by the transport.
18358
18359 .conf mode "octal integer" 0600
18360 If either the log file or the `once' file has to be created, this mode is used.
18361
18362 .em
18363 .conf never@_mail "address list$**$" unset
18364 If any run of the transport creates a message with a recipient that matches any
18365 item in the list, that recipient is quietly discarded. If all recipients are
18366 discarded, no message is created.
18367 .nem
18368
18369 .conf once string$**$ unset
18370 This option names a file or DBM database in which a record of each
18371 ::To:: recipient is kept when the message is specified by the transport.
18372 \**Note**\: This does not apply to ::Cc:: or ::Bcc:: recipients.
18373 If \once@_file@_size\ is not set, a DBM database is used, and it is allowed to
18374 grow as large as necessary. If a potential recipient is already in the
18375 database, no message is sent by default. However, if \once@_repeat\ specifies a
18376 time greater than zero, the message is sent if that much time has elapsed since
18377 a message was last sent to this recipient. If \once\ is unset, the message is
18378 always sent.
18379
18380 If \once@_file@_size\ is set greater than zero, it changes the way Exim
18381 implements the \once\ option. Instead of using a DBM file to record every
18382 recipient it sends to, it uses a regular file, whose size will never get larger
18383 than the given value. In the file, it keeps a linear list of recipient
18384 addresses and times at which they were sent messages. If the file is full when
18385 a new address needs to be added, the oldest address is dropped. If
18386 \once@_repeat\ is not set, this means that a given recipient may receive
18387 multiple messages, but at unpredictable intervals that depend on the rate of
18388 turnover of addresses in the file. If \once@_repeat\ is set, it specifies a
18389 maximum time between repeats.
18390
18391 .conf once@_file@_size integer 0
18392 See \once\ above.
18393
18394 .conf once@_repeat time$**$ 0s
18395 See \once\ above.
18396 After expansion, the value of this option must be a valid time value.
18397
18398 .conf reply@_to string$**$ unset
18399 This specifies the contents of the ::Reply-To:: header when the message is
18400 specified by the transport.
18401
18402 .conf return@_message boolean false
18403 If this is set, a copy of the original message is returned with the new
18404 message, subject to the maximum size set in the \return@_size@_limit\ global
18405 configuration option.
18406
18407 .conf subject string$**$ unset
18408 This specifies the contents of the ::Subject:: header when the message is
18409 specified by the transport.
18410 .em
18411 It is tempting to quote the original subject in automatic responses. For
18412 example:
18413 .display asis
18414 subject = Re: $h_subject:
18415 .endd
18416 There is a danger in doing this, however. It may allow a third party to 
18417 subscribe your users to an opt-in mailing list, provided that the list accepts
18418 bounce messages as subscription confirmations. Well-managed lists require a
18419 non-bounce message to confirm a subscription, so the danger is relatively
18420 small.
18421 .nem
18422
18423 .conf text string$**$ unset
18424 This specifies a single string to be used as the body of the message when the
18425 message is specified by the transport. If both \text\ and \file\ are set, the
18426 text comes first.
18427
18428 .conf to string$**$ unset
18429 This specifies recipients of the message and the contents of the ::To:: header
18430 when the message is specified by the transport.
18431
18432 .endconf
18433
18434
18435
18436 .
18437 .
18438 .
18439 .
18440 . ============================================================================
18441 .chapter The lmtp transport
18442 .set runningfoot "lmtp transport"
18443 .index transports||\%lmtp%\
18444 .index \%lmtp%\ transport
18445 .index LMTP||over a pipe
18446 .index LMTP||over a socket
18447 .rset CHAPLMTP "~~chapter"
18448 The \%lmtp%\ transport runs the LMTP protocol (RFC 2033) over a pipe to a
18449 specified command
18450 or by interacting with a Unix domain socket.
18451 This transport is something of a cross between the \%pipe%\ and \%smtp%\
18452 transports. Exim also has support for using LMTP over TCP/IP; this is
18453 implemented as an option for the \%smtp%\ transport. Because LMTP is expected
18454 to be of minority interest, the default build-time configure in \(src/EDITME)\
18455 has it commented out. You need to ensure that
18456 .display asis
18457 TRANSPORT_LMTP=yes
18458 .endd
18459 is present in your \(Local/Makefile)\ in order to have the \%lmtp%\ transport
18460 included in the Exim binary.
18461
18462 The private options of the \%lmtp%\ transport are as follows:
18463
18464 .startconf lmtp
18465 .index options||\%lmtp%\ transport
18466
18467 .conf batch@_id string$**$ unset
18468 See the description of local delivery batching in chapter ~~CHAPbatching.
18469
18470 .conf batch@_max integer 1
18471 This limits the number of addresses that can be handled in a single delivery.
18472 Most LMTP servers can handle several addresses at once, so it is normally a
18473 good idea to increase this value. See the description of local delivery
18474 batching in chapter ~~CHAPbatching.
18475
18476 .conf command string$**$ unset
18477 This option must be set if \socket\ is not set.
18478 The string is a command which is run in a separate process. It is split up into
18479 a command name and list of arguments, each of which is separately expanded (so
18480 expansion cannot change the number of arguments). The command is run directly,
18481 not via a shell. The message is passed to the new process using the standard
18482 input and output to operate the LMTP protocol.
18483
18484 .conf socket string$**$ unset
18485 This option must be set if \command\ is not set. The result of expansion must
18486 be the name of a Unix domain socket. The transport connects to the socket and
18487 delivers the message to it using the LMTP protocol.
18488
18489 .conf timeout time 5m
18490 The transport is aborted if the created process
18491 or Unix domain socket
18492 does not respond to LMTP commands or message input within this timeout.
18493
18494 .endconf
18495
18496 Here is an example of a typical LMTP transport:
18497 .display asis
18498 lmtp:
18499   driver = lmtp
18500   command = /some/local/lmtp/delivery/program
18501   batch_max = 20
18502   user = exim
18503 .endd
18504 This delivers up to 20 addresses at a time, in a mixture of domains if
18505 necessary, running as the user \*exim*\.
18506
18507
18508
18509 .
18510 .
18511 .
18512 .
18513 . ============================================================================
18514 .chapter The pipe transport
18515 .rset CHAPpipetransport "~~chapter"
18516 .set runningfoot "pipe transport"
18517 .index transports||\%pipe%\
18518 .index \%pipe%\ transport
18519 The \%pipe%\ transport is used to deliver messages via a pipe to a command
18520 running in another process. 
18521 .em
18522 One example is the
18523 use of \%pipe%\ as a pseudo-remote transport for passing messages to some other
18524 delivery mechanism (such as UUCP). Another is the use by individual users to
18525 automatically process their incoming messages. The \%pipe%\ transport can be
18526 used in one of the following ways:
18527 .nem
18528 .numberpars $.
18529 A router routes one address to a transport in the normal way, and the transport
18530 is configured as a \%pipe%\ transport. In this case, \$local@_part$\ contains
18531 the local part of the address (as usual), and the command that is run is
18532 specified by the \command\ option on the transport.
18533 .nextp
18534 .em
18535 If the \batch@_max\ option is set greater than 1 (the default), the transport 
18536 can be called upon to handle more than one address in a single run. In this
18537 case, \$local@_part$\ is not set (because it is not unique). However, the
18538 pseudo-variable \$pipe@_addresses$\ (described in section ~~SECThowcommandrun
18539 below) contains all the addresses that are being handled.
18540 .nem
18541 .nextp
18542 A router redirects an address directly to a pipe command (for example, from an
18543 alias or forward file). In this case, \$local@_part$\ contains the local part
18544 that was redirected, and \$address@_pipe$\ contains the text of the pipe
18545 command itself. The \command\ option on the transport is ignored.
18546 .endp
18547
18548 The \%pipe%\ transport is a non-interactive delivery method. Exim can also
18549 deliver messages over pipes using the LMTP interactive protocol. This is
18550 implemented by the \%lmtp%\ transport.
18551
18552 In the case when \%pipe%\ is run as a consequence of an entry in a local user's
18553 \(.forward)\ file, the command runs under the uid and gid of that user. In
18554 other cases, the uid and gid have to be specified explicitly, either on the
18555 transport or on the router that handles the address. Current and `home'
18556 directories are also controllable. See chapter ~~CHAPenvironment for details of
18557 the local delivery environment.
18558
18559
18560 .em
18561 .section Concurrent delivery
18562 If two messages arrive at almost the same time, and both are routed to a pipe 
18563 delivery, the two pipe transports may be run concurrently. You must ensure that 
18564 any pipe commands you set up are robust against this happening. If the commands 
18565 write to a file, the \exim@_lock\ utility might be of use.
18566 .nem
18567
18568
18569 .section Returned status and data
18570 .index \%pipe%\ transport||returned data
18571 If the command exits with a non-zero return code, the delivery is deemed to
18572 have failed, unless either the \ignore@_status\ option is set (in which case
18573 the return code is treated as zero), or the return code is one of those listed
18574 in the \temp@_errors\ option, which are interpreted as meaning `try again
18575 later'. In this case, delivery is deferred. Details of a permanent failure are
18576 logged, but are not included in the bounce message, which merely contains
18577 `local delivery failed'.
18578
18579 If the return code is greater than 128 and the command being run is a shell
18580 script, it normally means that the script was terminated by a signal whose
18581 value is the return code minus 128.
18582
18583 If Exim is unable to run the command (that is, if \*execve()*\ fails), the
18584 return code is set to 127. This is the value that a shell returns if it is
18585 asked to run a non-existent command. The wording for the log line suggests that
18586 a non-existent command may be the problem.
18587
18588 The \return@_output\ option can affect the result of a pipe delivery. If it is
18589 set and the command produces any output on its standard output or standard
18590 error streams, the command is considered to have failed, even if it gave a zero
18591 return code or if \ignore@_status\ is set. The output from the command is
18592 included as part of the bounce message. The \return@_fail@_output\ option is
18593 similar, except that output is returned only when the command exits with a
18594 failure return code, that is, a value other than zero or a code that matches
18595 \temp@_errors\.
18596
18597
18598 .section How the command is run
18599 .rset SECThowcommandrun "~~chapter.~~section"
18600 .index \%pipe%\ transport||path for command
18601 The command line is (by default) broken down into a command name and arguments
18602 by the \%pipe%\ transport itself. The \allow@_commands\ and \restrict@_to@_path\
18603 options can be used to restrict the commands that may be run.
18604 .index quoting||in pipe command
18605 Unquoted arguments are delimited by white space. If an argument appears in
18606 double quotes, backslash is interpreted as an escape character in the usual
18607 way. If an argument appears in single quotes, no escaping is done.
18608
18609 String expansion is applied to the command line except when it comes from a
18610 traditional \(.forward)\ file (commands from a filter file are expanded). The
18611 expansion is applied to each argument in turn rather than to the whole line.
18612 For this reason, any string expansion item that contains white space must be
18613 quoted so as to be contained within a single argument. A setting such as
18614 .display asis
18615 command = /some/path ${if eq{$local_part}{postmaster}{xxx}{yyy}}
18616 .endd
18617 will not work, because the expansion item gets split between several
18618 arguments. You have to write
18619 .display asis
18620 command = /some/path "${if eq{$local_part}{postmaster}{xxx}{yyy}}"
18621 .endd
18622 to ensure that it is all in one argument. The expansion is done in this way,
18623 argument by argument, so that the number of arguments cannot be changed as a
18624 result of expansion, and quotes or backslashes in inserted variables do not
18625 interact with external quoting.
18626
18627 .index transport||filter
18628 .index filter||transport filter
18629 Special handling takes place when an argument consists of precisely the text
18630 `$tt{@$pipe@_addresses}'. This is not a general expansion variable; the only
18631 place this string is recognized is when it appears as an argument for a pipe or
18632 transport filter command. It causes each address that is being handled to be
18633 inserted in the argument list at that point $it{as a separate argument}. This
18634 avoids any problems with spaces or shell metacharacters, and is of use when a
18635 \%pipe%\ transport is handling groups of addresses in a batch.
18636
18637 After splitting up into arguments and expansion, the resulting command is run
18638 in a subprocess directly from the transport, $it{not} under a shell. The
18639 message that is being delivered is supplied on the standard input, and the
18640 standard output and standard error are both connected to a single pipe that is
18641 read by Exim. The \max@_output\ option controls how much output the command may
18642 produce, and the \return@_output\ and \return@_fail@_output\ options control
18643 what is done with it.
18644
18645 Not running the command under a shell (by default) lessens the security risks
18646 in cases when a command from a user's filter file is built out of data that was
18647 taken from an incoming message. If a shell is required, it can of course be
18648 explicitly specified as the command to be run. However, there are circumstances
18649 where existing commands (for example, in \(.forward)\ files) expect to be run
18650 under a shell and cannot easily be modified. To allow for these cases, there is
18651 an option called \use@_shell\, which changes the way the \%pipe%\ transport
18652 works. Instead of breaking up the command line as just described, it expands it
18653 as a single string and passes the result to \(/bin/sh)\. The
18654 \restrict@_to@_path\ option and the \$pipe@_addresses$\ facility cannot be used
18655 with \use@_shell\, and the whole mechanism is inherently less secure.
18656
18657
18658 .section Environment variables
18659 .rset SECTpipeenv "~~chapter.~~section"
18660 .index \%pipe%\ transport||environment for command
18661 .index environment for pipe transport
18662 The environment variables listed below are set up when the command is invoked.
18663 This list is a compromise for maximum compatibility with other MTAs. Note that
18664 the \environment\ option can be used to add additional variables to this
18665 environment.
18666 .display flow
18667 .tabs 20
18668 DOMAIN              $t $rm{the domain of the address}
18669 HOME                $t $rm{the home directory, if set}
18670 HOST                $t $rm{the host name when called from a router (see below)}
18671 LOCAL@_PART         $t $rm{see below}
18672 LOCAL@_PART@_PREFIX $t $rm{see below}
18673 LOCAL@_PART@_SUFFIX $t $rm{see below}
18674 LOGNAME             $t $rm{see below}
18675 MESSAGE@_ID         $t $rm{the message's id}
18676 PATH                $t $rm{as specified by the \path\ option below}
18677 QUALIFY@_DOMAIN     $t $rm{the sender qualification domain}
18678 RECIPIENT           $t $rm{the complete recipient address}
18679 SENDER              $t $rm{the sender of the message (empty if a bounce)}
18680 SHELL               $t `$tt{/bin/sh}'
18681 TZ                  $t $rm{the value of the \timezone\ option, if set}
18682 USER                $t $rm{see below}
18683 .endd
18684
18685 When a \%pipe%\ transport is called directly from (for example) an \%accept%\
18686 router, \\LOCAL@_PART\\ is set to the local part of the address. When it is
18687 called as a result of a forward or alias expansion, \\LOCAL@_PART\\ is set to
18688 the local part of the address that was expanded. In both cases, any affixes are
18689 removed from the local part, and made available in \\LOCAL@_PART@_PREFIX\\ and
18690 \\LOCAL@_PART@_SUFFIX\\, respectively. \\LOGNAME\\ and \\USER\\ are set to the
18691 same value as \\LOCAL@_PART\\ for compatibility with other MTAs.
18692
18693 .index \\HOST\\
18694 \\HOST\\ is set only when a \%pipe%\ transport is called from a router that
18695 associates hosts with an address, typically when using \%pipe%\ as a
18696 pseudo-remote transport. \\HOST\\ is set to the first host name specified by
18697 the router.
18698
18699 .index \\HOME\\
18700 If the transport's generic \home@_directory\ option is set, its value is used
18701 for the \\HOME\\ environment variable. Otherwise, a home directory may be set
18702 by the router's \transport@_home@_directory\ option, which defaults to the
18703 user's home directory if \check@_local@_user\ is set.
18704
18705 .section Private options for pipe
18706 .index options||\%pipe%\ transport
18707
18708 .startconf pipe
18709
18710 .conf allow@_commands "string list$**$" unset
18711 .index \%pipe%\ transport||permitted commands
18712 The string is expanded, and is then interpreted as a colon-separated list of
18713 permitted commands. If \restrict@_to@_path\ is not set, the only commands
18714 permitted are those in the \allow@_commands\ list. They need not be absolute
18715 paths; the \path\ option is still used for relative paths. If
18716 \restrict@_to@_path\ is set with \allow@_commands\, the command must either be
18717 in the \allow@_commands\ list, or a name without any slashes that is found on
18718 the path. In other words, if neither \allow@_commands\ nor \restrict@_to@_path\
18719 is set, there is no restriction on the command, but otherwise only commands
18720 that are permitted by one or the other are allowed. For example, if
18721 .display asis
18722 allow_commands = /usr/bin/vacation
18723 .endd
18724 and \restrict@_to@_path\ is not set, the only permitted command is
18725 \(/usr/bin/vacation)\. The \allow@_commands\ option may not be set if
18726 \use@_shell\ is set.
18727
18728 .conf batch@_id string$**$ unset
18729 See the description of local delivery batching in chapter ~~CHAPbatching.
18730
18731 .conf batch@_max integer 1
18732 This limits the number of addresses that can be handled in a single delivery.
18733 See the description of local delivery batching in chapter ~~CHAPbatching.
18734
18735 .conf check@_string string unset
18736 As \%pipe%\ writes the message, the start of each line is tested for matching
18737 \check@_string\, and if it does, the initial matching characters are replaced
18738 by the contents of \escape@_string\, provided both are set. The value of
18739 \check@_string\ is a literal string, not a regular expression, and the case of
18740 any letters it contains is significant. When \use@_bsmtp\ is set, the contents
18741 of \check@_string\ and \escape@_string\ are forced to values that implement the
18742 SMTP escaping protocol. Any settings made in the configuration file are
18743 ignored.
18744
18745 .conf command string$**$ unset
18746 This option need not be set when \%pipe%\ is being used to deliver to pipes
18747 obtained directly from address redirections. In other cases, the option must be
18748 set, to provide a command to be run. It need not yield an absolute path (see
18749 the \path\ option below). The command is split up into separate arguments by
18750 Exim, and each argument is separately expanded, as described in section
18751 ~~SECThowcommandrun above.
18752
18753 .conf environment string$**$ unset
18754 .index \%pipe%\ transport||environment for command
18755 .index environment for \%pipe%\ transport
18756 This option is used to add additional variables to the environment in which the
18757 command runs (see section ~~SECTpipeenv for the default list). Its value is a
18758 string which is expanded, and then interpreted as a colon-separated list of
18759 environment settings of the form `<<name>>=<<value>>'.
18760
18761 .conf escape@_string string unset
18762 See \check@_string\ above.
18763
18764 .conf freeze@_exec@_fail boolean false
18765 .index exec failure
18766 .index failure of exec
18767 .index \%pipe%\ transport||failure of exec
18768 Failure to exec the command in a pipe transport is by default treated like
18769 any other failure while running the command. However, if \freeze@_exec@_fail\
18770 is set, failure to exec is treated specially, and causes the message to be
18771 frozen, whatever the setting of \ignore@_status\.
18772
18773 .conf ignore@_status boolean false
18774 If this option is true, the status returned by the subprocess that is set up to
18775 run the command is ignored, and Exim behaves as if zero had been returned.
18776 Otherwise, a non-zero status
18777 or termination by signal
18778 causes an error return from the transport unless the status value is one of
18779 those listed in \temp@_errors\; these cause the delivery to be deferred and
18780 tried again later.
18781
18782 .conf log@_defer@_output boolean false
18783 .index \%pipe%\ transport||logging output
18784 If this option is set, and the status returned by the command is
18785 one of the codes listed in \temp@_errors\ (that is, delivery was deferred),
18786 and any output was produced, the first line of it is written to the main log.
18787
18788 .conf log@_fail@_output boolean false
18789 If this option is set, and the command returns any output, and also ends with a
18790 return code that is neither zero nor one of the return codes listed in
18791 \temp@_errors\ (that is, the delivery failed), the first line of output is
18792 written to the main log.
18793
18794 .conf log@_output boolean false
18795 If this option is set and the command returns any output, the first line of
18796 output is written to the main log, whatever the return code.
18797
18798 .conf max@_output integer 20K
18799 This specifies the maximum amount of output that the command may produce on its
18800 standard output and standard error file combined. If the limit is exceeded, the
18801 process running the command is killed. This is intended as a safety measure to
18802 catch runaway processes. The limit is applied independently of the settings of
18803 the options that control what is done with such output (for example,
18804 \return@_output\). Because of buffering effects, the amount of output may
18805 exceed the limit by a small amount before Exim notices.
18806
18807 .conf message@_prefix string$**$ "see below"
18808 The string specified here is expanded and output at the start of every message.
18809 The default is unset if \use@_bsmtp\ is set. Otherwise it is
18810 .display asis
18811 message_prefix = \
18812   From ${if def:return_path{$return_path}{MAILER-DAEMON}}\
18813   ${tod_bsdinbox}\n
18814 .endd
18815 .index Cyrus
18816 .index \tmail\
18817 .index `From' line
18818 This is required by the commonly used \(/usr/bin/vacation)\ program.
18819 However, it must $it{not} be present if delivery is to the Cyrus IMAP server,
18820 or to the \tmail\ local delivery agent. The prefix can be suppressed by setting
18821 .display asis
18822 message_prefix =
18823 .endd
18824
18825 .conf message@_suffix string$**$ "see below"
18826 The string specified here is expanded and output at the end of every message.
18827 The default is unset if \use@_bsmtp\ is set. Otherwise it is a single newline.
18828 The suffix can be suppressed by setting
18829 .display asis
18830 message_suffix =
18831 .endd
18832
18833 .conf path string $tt{/usr/bin}
18834 This option specifies the string that is set up in the \\PATH\\ environment
18835 variable of the subprocess. If the \command\ option does not yield an absolute
18836 path name, the command is sought in the \\PATH\\ directories, in the usual way.
18837 \**Warning**\: This does not apply to a command specified as a transport
18838 filter.
18839
18840 .conf pipe@_as@_creator boolean false
18841 .index uid (user id)||local delivery
18842 If the generic \user\ option is not set and this option is true, the delivery
18843 process is run under the uid that was in force when Exim was originally called
18844 to accept the message. If the group id is not otherwise set (via the generic
18845 \group\ option), the gid that was in force when Exim was originally called to
18846 accept the message is used.
18847
18848 .conf restrict@_to@_path boolean false
18849 When this option is set, any command name not listed in \allow@_commands\ must
18850 contain no slashes. The command is searched for only in the directories listed
18851 in the \path\ option. This option is intended for use in the case when a pipe
18852 command has been generated from a user's \(.forward)\ file. This is usually
18853 handled by a \%pipe%\ transport called \address@_pipe\.
18854
18855 .conf return@_fail@_output boolean false
18856 If this option is true, and the command produced any output and ended with a
18857 return code other than zero or one of the codes listed in \temp@_errors\ (that
18858 is, the delivery failed), the output is returned in the bounce message.
18859 However, if the message has a null sender (that is, it is itself a bounce
18860 message), output from the command is discarded.
18861
18862 .conf return@_output boolean false
18863 If this option is true, and the command produced any output, the delivery is
18864 deemed to have failed whatever the return code from the command, and the output
18865 is returned in the bounce message. Otherwise, the output is just discarded.
18866 However, if the message has a null sender (that is, it is a bounce message),
18867 output from the command is always discarded, whatever the setting of this
18868 option.
18869
18870 .conf temp@_errors "string list" "see below"
18871 .index \%pipe%\ transport||temporary failure
18872 This option contains either a colon-separated list of numbers, or a single
18873 asterisk. If \ignore@_status\ is false
18874 and \return@_output\ is not set,
18875 and the command exits with a non-zero return code, the failure is treated as
18876 temporary and the delivery is deferred if the return code matches one of the
18877 numbers, or if the setting is a single asterisk. Otherwise, non-zero return
18878 codes are treated as permanent errors. The default setting contains the codes
18879 defined by \\EX@_TEMPFAIL\\ and \\EX@_CANTCREAT\\ in \(sysexits.h)\. If Exim is
18880 compiled on a system that does not define these macros, it assumes values of 75
18881 and 73, respectively.
18882
18883 .conf timeout time 1h
18884 If the command fails to complete within this time, it is killed. This normally
18885 causes the delivery to fail. A zero time interval specifies no timeout. In
18886 order to ensure that any subprocesses created by the command are also killed,
18887 Exim makes the initial process a process group leader, and kills the whole
18888 process group on a timeout. However, this can be defeated if one of the
18889 processes starts a new process group.
18890
18891 .conf umask "octal integer" 022
18892 This specifies the umask setting for the subprocess that runs the command.
18893
18894 .conf use@_bsmtp boolean false
18895 .index envelope sender
18896 If this option is set true, the \%pipe%\ transport writes messages in `batch
18897 SMTP' format, with the envelope sender and recipient(s) included as SMTP
18898 commands. If you want to include a leading \\HELO\\ command with such messages,
18899 you can do so by setting the \message@_prefix\ option. See section
18900 ~~SECTbatchSMTP for details of batch SMTP.
18901
18902 .conf use@_crlf boolean false
18903 .index carriage return
18904 .index linefeed
18905 This option causes lines to be terminated with the two-character CRLF sequence
18906 (carriage return, linefeed) instead of just a linefeed character. In the case
18907 of batched SMTP, the byte sequence written to the pipe is then an exact image
18908 of what would be sent down a real SMTP connection.
18909
18910 The contents of the \message@_prefix\ and \message@_suffix\ options are written
18911 verbatim, so must contain their own carriage return characters if these are
18912 needed. Since the default values for both \message@_prefix\ and
18913 \message@_suffix\ end with a single linefeed, their values
18914 must
18915 be changed to end with \"@\r@\n"\ if \use@_crlf\ is set.
18916
18917 .conf use@_shell boolean false
18918 If this option is set, it causes the command to be passed to \(/bin/sh)\
18919 instead of being run directly from the transport, as described in section
18920 ~~SECThowcommandrun. This is less secure, but is needed in some situations
18921 where the command is expected to be run under a shell and cannot easily be
18922 modified. The \allow@_commands\ and \restrict@_to@_path\ options, and the
18923 `$tt{@$pipe@_addresses}' facility are incompatible with \use@_shell\. The
18924 command is expanded as a single string, and handed to \(/bin/sh)\ as data for
18925 its \-c-\ option.
18926
18927 .endconf
18928
18929 .section Using an external local delivery agent
18930 .index local delivery||using an external agent
18931 .index \*procmail*\
18932 .index external local delivery
18933 .index delivery||\*procmail*\
18934 .index delivery||by external agent
18935 The \%pipe%\ transport can be used to pass all messages that require local
18936 delivery to a separate local delivery agent such as \procmail\. When doing
18937 this, care must be taken to ensure that the pipe is run under an appropriate
18938 uid and gid. In some configurations one wants this to be a uid that is trusted
18939 by the delivery agent to supply the correct sender of the message. It may be
18940 necessary to recompile or reconfigure the delivery agent so that it trusts an
18941 appropriate user. The following is an example transport and router
18942 configuration for \procmail\:
18943 .display asis
18944 # transport
18945 procmail_pipe:
18946   driver = pipe
18947   command = /usr/local/bin/procmail -d $local_part
18948   return_path_add
18949   delivery_date_add
18950   envelope_to_add
18951   check_string = "From "
18952   escape_string = ">From "
18953   user = $local_part
18954   group = mail
18955 .endd
18956 .display asis
18957 # router
18958 procmail:
18959   driver = accept
18960   check_local_user
18961   transport = procmail_pipe
18962 .endd
18963
18964 In this example, the pipe is run as the local user, but with the group set to
18965 \*mail*\. An alternative is to run the pipe as a specific user such as \*mail*\
18966 or \*exim*\, but in this case you must arrange for \procmail\ to trust that
18967 user to supply a correct sender address. If you do not specify either a \group\
18968 or a \user\ option, the pipe command is run as the local user. The home
18969 directory is the user's home directory by default.
18970
18971 Note that the command that the pipe transport runs does $it{not} begin with
18972 .display asis
18973 IFS=" "
18974 .endd
18975 as shown in the \procmail\ documentation, because Exim does not by default use
18976 a shell to run pipe commands.
18977
18978 .index Cyrus
18979 The next example shows a transport and a router for a system where local
18980 deliveries are handled by the Cyrus IMAP server.
18981 .display asis
18982 # transport
18983 local_delivery_cyrus:
18984   driver = pipe
18985   command = /usr/cyrus/bin/deliver \
18986             -m ${substr_1:$local_part_suffix} -- $local_part
18987   user = cyrus
18988   group = mail
18989   return_output
18990   log_output
18991   message_prefix =
18992   message_suffix =
18993 .endd
18994 .display asis
18995 # router
18996 local_user_cyrus:
18997   driver = accept
18998   check_local_user
18999   local_part_suffix = .*
19000   transport = local_delivery_cyrus
19001 .endd
19002 Note the unsetting of \message@_prefix\ and \message@_suffix\, and the use of
19003 \return@_output\ to cause any text written by Cyrus to be returned to the
19004 sender.
19005
19006
19007 .
19008 .
19009 .
19010 .
19011 . ============================================================================
19012 .chapter The smtp transport
19013 .rset CHAPsmtptrans "~~chapter"
19014 .set runningfoot "smtp transport"
19015 .index transports||\%smtp%\
19016 .index \%smtp%\ transport
19017 The \%smtp%\ transport delivers messages over TCP/IP connections using the SMTP
19018 or LMTP protocol. The list of hosts to try can either be taken from the address
19019 that is being processed (having been set up by the router), or specified
19020 explicitly for the transport. Timeout and retry processing (see chapter
19021 ~~CHAPretry) is applied to each IP address independently.
19022
19023 .section Multiple messages on a single connection
19024 The sending of multiple messages over a single TCP/IP connection can arise in
19025 two ways:
19026 .numberpars $.
19027 If a message contains more than \max@_rcpt\ (see below) addresses that are
19028 routed to the same host, more than one copy of the message has to be sent to
19029 that host. In this situation, multiple copies may be sent in a single run of
19030 the \%smtp%\ transport over a single TCP/IP connection. (What Exim actually does
19031 when it has too many addresses to send in one message also depends on the value
19032 of the global \remote@_max@_parallel\ option. Details are given in section
19033 ~~SECToutSMTPTCP.)
19034 .nextp
19035 .index hints database||remembering routing
19036 When a message has been successfully delivered over a TCP/IP connection, Exim
19037 looks in its hints database to see if there are any other messages awaiting a
19038 connection to the same host. If there are, a new delivery process is started
19039 for one of them, and the current TCP/IP connection is passed on to it. The new
19040 process may in turn send multiple copies and possibly create yet another
19041 process.
19042 .endp
19043
19044 For each copy sent over the same TCP/IP connection, a sequence counter is
19045 incremented, and if it ever gets to the value of \connection@_max@_messages\,
19046 no further messages are sent over that connection.
19047
19048
19049 .section Use of the @$host variable
19050 .index \$host$\
19051 .index \$host@_address$\
19052 At the start of a run of the \%smtp%\ transport, the values of \$host$\ and
19053 \$host@_address$\ are the name and IP address of the first host on the host list
19054 passed by the router. However, when the transport is about to connect to a
19055 specific host, and while it is connected to that host, \$host$\ and
19056 \$host@_address$\ are set to the values for that host. These are the values
19057 that are in force when the \helo@_data\, \hosts@_try@_auth\, \interface\,
19058 \serialize@_hosts\, and the various TLS options are expanded.
19059
19060
19061 .section Private options for smtp
19062 The private options of the \%smtp%\ transport are as follows:
19063
19064 .index options||\%smtp%\ transport
19065 .startconf smtp
19066 .conf allow@_localhost boolean false
19067 .index local host||sending to
19068 .index fallback||hosts specified on transport
19069 When a host specified in \hosts\ or \fallback@_hosts\ (see below) turns out to
19070 be the local host, or is listed in \hosts@_treat@_as@_local\, delivery is
19071 deferred by default. However, if \allow@_localhost\ is set, Exim goes on to do
19072 the delivery anyway. This should be used only in special cases when the
19073 configuration ensures that no looping will result (for example, a differently
19074 configured Exim is listening on the port to which the message is sent).
19075
19076 .conf authenticated@_sender string$**$ unset
19077 .index Cyrus
19078 When Exim has authenticated as a client, this option sets a value for the
19079 \\AUTH=\\ item on outgoing \\MAIL\\ commands, overriding any existing
19080 authenticated sender value. If the string expansion is forced to fail, the
19081 option is ignored. Other expansion failures cause delivery to be deferred. If
19082 the result of expansion is an empty string, that is also ignored.
19083
19084 If the SMTP session is not authenticated, the expansion of
19085 \authenticated@_sender\ still happens (and can cause the delivery to be
19086 deferred if it fails), but no \\AUTH=\\ item is added to \\MAIL\\ commands.
19087
19088 This option allows you to use the \%smtp%\ transport in LMTP mode to
19089 deliver mail to Cyrus IMAP and provide the proper local part as the
19090 `authenticated sender', via a setting such as:
19091 .display asis
19092 authenticated_sender = $local_part
19093 .endd
19094 This removes the need for IMAP subfolders to be assigned special ACLs to
19095 allow direct delivery to those subfolders.
19096
19097 Because of expected uses such as that just described for Cyrus (when no
19098 domain is involved), there is no checking on the syntax of the provided
19099 value.
19100
19101 .conf command@_timeout time 5m
19102 This sets a timeout for receiving a response to an SMTP command that has been
19103 sent out. It is also used when waiting for the initial banner line from the
19104 remote host. Its value must not be zero.
19105
19106 .conf connect@_timeout time 5m
19107 This sets a timeout for the \*connect()*\ function, which sets up a TCP/IP call
19108 to a remote host. A setting of zero allows the system timeout (typically
19109 several minutes) to act. To have any effect, the value of this option must be
19110 less than the system timeout. However, it has been observed that on some
19111 systems there is no system timeout, which is why the default value for this
19112 option is 5 minutes, a value recommended by RFC 1123.
19113
19114 .index SMTP||passed connection
19115 .index SMTP||multiple deliveries
19116 .index multiple SMTP deliveries
19117 .conf connection@_max@_messages integer 500
19118 This controls the maximum number of separate message deliveries that are sent
19119 over a single TCP/IP connection. If the value is zero, there is no limit.
19120 For testing purposes, this value can be overridden by the \-oB-\ command line
19121 option.
19122
19123 .conf data@_timeout time 5m
19124 This sets a timeout for the transmission of each block in the data portion of
19125 the message. As a result, the overall timeout for a message depends on the size
19126 of the message. Its value must not be zero. See also \final@_timeout\.
19127
19128 .conf delay@_after@_cutoff boolean true
19129 This option controls what happens when all remote IP addresses for a given
19130 domain have been inaccessible for so long that they have passed their retry
19131 cutoff times.
19132
19133 In the default state, if the next retry time has not been reached for any of
19134 them, the address is bounced without trying any deliveries. In other words,
19135 Exim delays retrying an IP address after the final cutoff time until a new
19136 retry time is reached, and can therefore bounce an address without ever trying
19137 a delivery, when machines have been down for a long time. Some people are
19138 unhappy at this prospect, so...
19139
19140 If \delay@_after@_cutoff\ is set false, Exim behaves differently. If all IP
19141 addresses are past their final cutoff time, Exim tries to deliver to those
19142 IP addresses that have not been tried since the message arrived. If there are
19143 none, of if they all fail, the address is bounced. In other words, it does not
19144 delay when a new message arrives, but immediately tries those expired IP
19145 addresses that haven't been tried since the message arrived. If there is a
19146 continuous stream of messages for the dead hosts, unsetting
19147 \delay@_after@_cutoff\ means that there will be many more attempts to deliver
19148 to them.
19149
19150 .conf dns@_qualify@_single boolean true
19151 If the \hosts\ or \fallback@_hosts\ option is being used,
19152 and the \gethostbyname\ option is false,
19153 the \\RES@_DEFNAMES\\ resolver option is set. See the \qualify@_single\ option
19154 in chapter ~~CHAPdnslookup for more details.
19155
19156 .conf dns@_search@_parents boolean false
19157 .index \search@_parents\
19158 If the \hosts\ or \fallback@_hosts\ option is being used, and the
19159 \gethostbyname\ option is false, the \\RES@_DNSRCH\\ resolver option is set.
19160 See the \search@_parents\ option in chapter ~~CHAPdnslookup for more details.
19161
19162
19163 .conf fallback@_hosts "string list" unset
19164 .index fallback||hosts specified on transport
19165 String expansion is not applied to this option. The argument must be a
19166 colon-separated list of host names or IP addresses. Fallback hosts can also be
19167 specified on routers, which associate them with the addresses they process. As
19168 for the \hosts\ option without \hosts@_override\, \fallback@_hosts\ specified
19169 on the transport is used only if the address does not have its own associated
19170 fallback host list. Unlike \hosts\, a setting of \fallback@_hosts\ on an
19171 address is not overridden by \hosts@_override\. However, \hosts@_randomize\
19172 does apply to fallback host lists.
19173
19174 If Exim is unable to deliver to any of the hosts for a particular address, and
19175 the errors are not permanent rejections, the address is put on a separate
19176 transport queue with its host list replaced by the fallback hosts, unless the
19177 address was routed via MX records and the current host was in the original MX
19178 list. In that situation, the fallback host list is not used.
19179
19180 Once normal deliveries are complete, the fallback queue is delivered by
19181 re-running the same transports with the new host lists. If several failing
19182 addresses have the same fallback hosts (and \max@_rcpt\ permits it), a single
19183 copy of the message is sent.
19184
19185 The resolution of the host names on the fallback list is controlled by the
19186 \gethostbyname\ option, as for the \hosts\ option. Fallback hosts apply
19187 both to cases when the host list comes with the address and when it is taken
19188 from \hosts\. This option provides a `use a smart host only if delivery fails'
19189 facility.
19190
19191 .conf final@_timeout time 10m
19192 This is the timeout that applies while waiting for the response to the final
19193 line containing just `.' that terminates a message. Its value must not be zero.
19194
19195 .conf gethostbyname boolean false
19196 If this option is true when the \hosts\ and/or \fallback@_hosts\ options are
19197 being used, names are looked up using \*gethostbyname()*\
19198 (or \*getipnodebyname()*\ when available)
19199 instead of using the DNS. Of course, that function may in fact use the DNS, but
19200 it may also consult other sources of information such as \(/etc/hosts)\.
19201
19202 .index \\HELO\\||argument, setting
19203 .index \\EHLO\\||argument, setting
19204 .conf helo@_data string$**$ $tt{@$primary@_hostname}
19205 The value of this option is expanded, and used as the argument for the \\EHLO\\
19206 or \\HELO\\ command that starts the outgoing SMTP session.
19207
19208 .conf hosts "string list$**$" unset
19209 Hosts are associated with an address by a router such as \%dnslookup%\, which
19210 finds the hosts by looking up the address domain in the DNS. However, addresses
19211 can be passed to the \%smtp%\ transport by any router, and not all of them can
19212 provide an associated host list. The \hosts\ option specifies a list of hosts
19213 which are used if the address being processed does not have any hosts
19214 associated with it. The hosts specified by \hosts\ are also used, whether or
19215 not the address has its own hosts, if \hosts@_override\ is set.
19216
19217 The string is first expanded, before being interpreted as a colon-separated
19218 list of host names or IP addresses. If the expansion fails, delivery is
19219 deferred. Unless the failure was caused by the inability to complete a lookup,
19220 the error is logged to the panic log as well as the main log. Host names are
19221 looked up either by searching directly for address records in the DNS or by
19222 calling \*gethostbyname()*\
19223 (or \*getipnodebyname()*\ when available),
19224 depending on the setting of the \gethostbyname\ option. When Exim is compiled
19225 with IPv6 support, if a host that is looked up in the DNS has both IPv4 and
19226 IPv6 addresses, both types of address are used.
19227
19228 During delivery, the hosts are tried in order, subject to their retry status,
19229 unless \hosts@_randomize\ is set.
19230
19231 .conf hosts@_avoid@_esmtp "host list$**$" unset
19232 .index ESMTP, avoiding use of
19233 .index \\HELO\\||forcing use of
19234 .index \\EHLO\\||avoiding use of
19235 .index \\PIPELINING\\||avoiding the use of
19236 This option is for use with broken hosts that announce ESMTP facilities (for
19237 example, \\PIPELINING\\) and then fail to implement them properly. When a host
19238 matches \hosts@_avoid@_esmtp\, Exim sends \\HELO\\ rather than \\EHLO\\ at the
19239 start of the SMTP session. This means that it cannot use any of the ESMTP
19240 facilities such as \\AUTH\\, \\PIPELINING\\, \\SIZE\\, and \\STARTTLS\\.
19241
19242 .conf hosts@_avoid@_tls "host list$**$" unset
19243 .index TLS||avoiding for certain hosts
19244 Exim will not try to start a TLS session when delivering to any host that
19245 matches this list. See chapter ~~CHAPTLS for details of TLS.
19246
19247 .conf hosts@_max@_try integer 5
19248 .index host||maximum number to try
19249 .index limit||number of hosts tried
19250 .index limit||number of MX tried
19251 .index MX record||maximum tried
19252 This option limits the number of IP addresses that are tried for any one
19253 delivery in cases where there are temporary delivery errors. Section
19254 ~~SECTvalhosmax describes in detail how the value of this option is used.
19255
19256 .em
19257 .conf hosts@_max@_try@_hardlimit integer 50
19258 This is an additional check on the maximum number of IP addresses that Exim 
19259 tries for any one delivery. Section ~~SECTvalhosmax describes its use and why 
19260 it exists.
19261 .nem
19262
19263 .conf hosts@_nopass@_tls "host list$**$" unset
19264 .index TLS||passing connection
19265 .index multiple SMTP deliveries
19266 .index TLS||multiple message deliveries
19267 For any host that matches this list, a connection on which a TLS session has
19268 been started will not be passed to a new delivery process for sending another
19269 message on the same connection. See section ~~SECTmulmessam for an explanation
19270 of when this might be needed.
19271
19272 .conf hosts@_override boolean false
19273 If this option is set and the \hosts\ option is also set, any hosts that are
19274 attached to the address are ignored, and instead the hosts specified by the
19275 \hosts\ option are always used. This option does not apply to
19276 \fallback@_hosts\.
19277
19278 .conf hosts@_randomize boolean false
19279 .index randomized host list
19280 .index host||list of, randomized
19281 .index fallback||randomized hosts
19282 If this option is set, and either the list of hosts is taken from the
19283 \hosts\ or the \fallback@_hosts\ option, or the hosts supplied by the router
19284 were not obtained from MX records (this includes fallback hosts from the
19285 router), and were not randomizied by the router, the order of trying the hosts
19286 is randomized each time the transport runs. Randomizing the order of a host
19287 list can be used to do crude load sharing.
19288
19289 When \hosts@_randomize\ is true, a host list may be split into groups whose
19290 order is separately randomized. This makes it possible to set up MX-like
19291 behaviour. The boundaries between groups are indicated by an item that is just
19292 \"+"\ in the host list. For example:
19293 .display asis
19294 hosts = host1:host2:host3:+:host4:host5
19295 .endd
19296 The order of the first three hosts and the order of the last two hosts is
19297 randomized for each use, but the first three always end up before the last two.
19298 If \hosts@_randomize\ is not set, a \"+"\ item in the list is ignored.
19299
19300 .index authentication||required by client
19301 .conf hosts@_require@_auth "host list$**$" unset
19302 This option provides a list of servers for which authentication must succeed
19303 before Exim will try to transfer a message. If authentication fails for
19304 servers which are not in this list, Exim tries to send unauthenticated. If
19305 authentication fails for one of these servers, delivery is deferred. This
19306 temporary error is detectable in the retry rules, so it can be turned into a
19307 hard failure if required. See also \hosts@_try@_auth\, and chapter
19308 ~~CHAPSMTPAUTH for details of authentication.
19309
19310 .conf hosts@_require@_tls "host list$**$" unset
19311 .index TLS||requiring for certain servers
19312 Exim will insist on using a TLS session when delivering to any host that
19313 matches this list. See chapter ~~CHAPTLS for details of TLS.
19314 \**Note**\: This option affects outgoing mail only. To insist on TLS for
19315 incoming messages, use an appropriate ACL.
19316
19317 .index authentication||optional in client
19318 .conf hosts@_try@_auth "host list$**$" unset
19319 This option provides a list of servers to which, provided they announce
19320 authentication support, Exim will attempt to authenticate as a client when it
19321 connects. If authentication fails, Exim will try to transfer the message
19322 unauthenticated. See also \hosts@_require@_auth\, and chapter ~~CHAPSMTPAUTH
19323 for details of authentication.
19324
19325 .index bind IP address
19326 .index IP address||binding
19327 .conf interface "string list$**$" unset
19328 This option specifies which interface to bind to when making an outgoing SMTP
19329 call. The variables \$host$\ and \$host@_address$\ refer to the host to which a
19330 connection is about to be made during the expansion of the string. Forced
19331 expansion failure, or an empty string result causes the option to be ignored.
19332 Otherwise, after expansion,
19333 the string must be a list of IP addresses, colon-separated by default, but the
19334 separator can be changed in the usual way.
19335 For example:
19336 .display asis
19337 interface = <; 192.168.123.123 ; 3ffe:ffff:836f::fe86:a061
19338 .endd
19339 The first interface of the correct type (IPv4 or IPv6) is used for the outgoing
19340 connection. If none of them are the correct type, the option is ignored. If
19341 \interface\ is not set, or is ignored, the system's IP functions choose which
19342 interface to use if the host has more than one.
19343
19344 .conf keepalive boolean true
19345 .index keepalive||on outgoing connection
19346 This option controls the setting of \\SO@_KEEPALIVE\\ on outgoing TCP/IP socket
19347 connections. When set, it causes the kernel to probe idle connections
19348 periodically, by sending packets with `old' sequence numbers. The other end of
19349 the connection should send a acknowledgement if the connection is still okay or
19350 a reset if the connection has been aborted. The reason for doing this is that
19351 it has the beneficial effect of freeing up certain types of connection that can
19352 get stuck when the remote host is disconnected without tidying up the TCP/IP
19353 call properly. The keepalive mechanism takes several hours to detect
19354 unreachable hosts.
19355
19356 .conf max@_rcpt integer 100
19357 .index \\RCPT\\||maximum number of outgoing
19358 This option limits the number of \\RCPT\\ commands that are sent in a single
19359 SMTP message transaction. Each set of addresses is treated independently, and
19360 so can cause parallel connections to the same host if \remote@_max@_parallel\
19361 permits this.
19362
19363 .conf multi@_domain boolean true
19364 When this option is set, the \%smtp%\ transport can handle a number of addresses
19365 containing a mixture of different domains provided they all resolve to the same
19366 list of hosts. Turning the option off restricts the transport to handling only
19367 one domain at a time. This is useful if you want to use \$domain$\ in an
19368 expansion for the transport, because it is set only when there is a single
19369 domain involved in a remote delivery.
19370
19371 .conf port string$**$ "see below"
19372 .index port||sending TCP/IP
19373 .index TCP/IP||setting outgoing port
19374 This option specifies the TCP/IP port on the server to which Exim connects. If
19375 it begins with a digit it is taken as a port number; otherwise it is looked up
19376 using \*getservbyname()*\. The default value is normally `smtp', but if
19377 \protocol\ is set to `lmtp', the default is `lmtp'.
19378 If the expansion fails, or if a port number cannot be found, delivery is
19379 deferred.
19380
19381
19382 .conf protocol string "smtp"
19383 .index LMTP||over TCP/IP
19384 If this option is set to `lmtp' instead of `smtp', the default value for the
19385 \port\ option changes to `lmtp', and the transport operates the LMTP protocol
19386 (RFC 2033) instead of SMTP. This protocol is sometimes used for local
19387 deliveries into closed message stores. Exim also has support for running LMTP
19388 over a pipe to a local process -- see chapter ~~CHAPLMTP.
19389
19390 .conf retry@_include@_ip@_address boolean true
19391 Exim normally includes both the host name and the IP address in the key it
19392 constructs for indexing retry data after a temporary delivery failure. This
19393 means that when one of several IP addresses for a host is failing, it gets
19394 tried periodically (controlled by the retry rules), but use of the other IP
19395 addresses is not affected.
19396
19397 However, in some dialup environments hosts are assigned a different IP address
19398 each time they connect. In this situation the use of the IP address as part of
19399 the retry key leads to undesirable behaviour. Setting this option false causes
19400 Exim to use only the host name. This should normally be done on a separate
19401 instance of the \%smtp%\ transport, set up specially to handle the dialup hosts.
19402
19403 .conf serialize@_hosts "host list$**$" unset
19404 .index serializing connections
19405 .index host||serializing connections
19406 Because Exim operates in a distributed manner, if several messages for the same
19407 host arrive at around the same time, more than one simultaneous connection to
19408 the remote host can occur. This is not usually a problem except when there is a
19409 slow link between the hosts. In that situation it may be helpful to restrict
19410 Exim to one connection at a time. This can be done by setting
19411 \serialize@_hosts\ to match the relevant hosts.
19412
19413 .index hints database||serializing deliveries to a host
19414 Exim implements serialization by means of a hints database in which a record is
19415 written whenever a process connects to one of the restricted hosts. The record
19416 is deleted when the connection is completed. Obviously there is scope for
19417 records to get left lying around if there is a system or program crash. To
19418 guard against this, Exim ignores any records that are more than six hours old.
19419
19420 If you set up this kind of serialization, you should also arrange to delete the
19421 relevant hints database whenever your system reboots. The names of the files
19422 start with \(misc)\ and they are kept in the \(spool/db)\ directory. There
19423 may be one or two files, depending on the type of DBM in use. The same files
19424 are used for ETRN serialization.
19425
19426 .conf size@_addition integer 1024
19427 .index SMTP||\\SIZE\\
19428 .index message||size issue for transport filter
19429 .index size||of message
19430 .index transport||filter
19431 .index filter||transport filter
19432 If a remote SMTP server indicates that it supports the \\SIZE\\ option of the
19433 \\MAIL\\ command, Exim uses this to pass over the message size at the start of
19434 an SMTP transaction. It adds the value of \size@_addition\ to the value it
19435 sends, to allow for headers and other text that may be added during delivery by
19436 configuration options or in a transport filter. It may be necessary to increase
19437 this if a lot of text is added to messages.
19438
19439 Alternatively, if the value of \size@_addition\ is set negative, it disables
19440 the use of the \\SIZE\\ option altogether.
19441
19442 .conf tls@_certificate string$**$ unset
19443 .index TLS||client certificate, location of
19444 .index certificate||for client, location of
19445 The value of this option must be the absolute path to a file which contains the
19446 client's certificate, for use when sending a message over an encrypted
19447 connection. The values of \$host$\ and \$host@_address$\ are set to the name
19448 and address of the server during the expansion. See chapter ~~CHAPTLS for
19449 details of TLS.
19450
19451 \**Note**\: This option must be set if you want Exim to use TLS when sending
19452 messages as a client. The global option of the same name specifies the
19453 certificate for Exim as a server; it is not automatically assumed that the same
19454 certificate should be used when Exim is operating as a client.
19455
19456 .conf tls@_crl string$**$ unset
19457 .index TLS||client certificate revocation list
19458 .index certificate||revocation list for client
19459 This option specifies a certificate revocation list. The expanded value must
19460 be the name of a file that contains a CRL in PEM format.
19461
19462 .conf tls@_privatekey string$**$ unset
19463 .index TLS||client private key, location of
19464 The value of this option must be the absolute path to a file which contains the
19465 client's private key, for use when sending a message over an encrypted
19466 connection. The values of \$host$\ and \$host@_address$\ are set to the name
19467 and address of the server during the expansion.
19468 If this option is unset, the private key is assumed to be in the same file as
19469 the certificate.
19470 See chapter ~~CHAPTLS for details of TLS.
19471
19472 .conf tls@_require@_ciphers string$**$ unset
19473 .index TLS||requiring specific ciphers
19474 .index cipher||requiring specific
19475 The value of this option must be a list of permitted cipher suites, for use
19476 when setting up an outgoing encrypted connection. (There is a global option of
19477 the same name for controlling incoming connections.) The values of \$host$\ and
19478 \$host@_address$\ are set to the name and address of the server during the
19479 expansion. See chapter ~~CHAPTLS for details of TLS; note that this option is
19480 used in different ways by OpenSSL and GnuTLS (see sections ~~SECTreqciphssl and 
19481 ~~SECTreqciphgnu).
19482 .em
19483 For GnuTLS, the order of the ciphers is a preference order.
19484 .nem
19485
19486 .conf tls@_tempfail@_tryclear boolean true
19487 When the server host is not in \hosts@_require@_tls\, and there is a problem in
19488 setting up a TLS session, this option determines whether or not Exim should try
19489 to deliver the message unencrypted. If it is set false, delivery to the
19490 current host is deferred; if there are other hosts, they are tried. If this
19491 option is set true, Exim attempts to deliver unencrypted after a 4\*xx*\
19492 response to \\STARTTLS\\. Also, if \\STARTTLS\\ is accepted, but the subsequent
19493 TLS negotiation fails, Exim closes the current connection (because it is in an
19494 unknown state), opens a new one to the same host, and then tries the delivery
19495 in clear.
19496
19497 .conf tls@_verify@_certificates string$**$ unset
19498 .index TLS||server certificate verification
19499 .index certificate||verification of server
19500 The value of this option must be the absolute path to a file containing
19501 permitted server certificates, for use when setting up an encrypted connection.
19502 Alternatively, if you are using OpenSSL, you can set
19503 \tls@_verify@_certificates\ to the name of a directory containing certificate
19504 files. This does not work with GnuTLS; the option must be set to the name of a
19505 single file if you are using GnuTLS. The values of \$host$\ and
19506 \$host@_address$\ are set to the name and address of the server during the
19507 expansion of this option. See chapter ~~CHAPTLS for details of TLS.
19508
19509 .endconf
19510
19511
19512 .section How the limits for the number of hosts to try are used
19513 .rset SECTvalhosmax "~~chapter.~~section"
19514 .index host||maximum number to try
19515 .index limit||hosts, maximum number tried
19516 .em
19517 There are two options that are concerned with the number of hosts that are 
19518 tried when an SMTP delivery takes place. They are \hosts@_max@_try\ and 
19519 \hosts@_max@_try@_hardlimit\.
19520 .nem
19521
19522 The \hosts@_max@_try\ option limits the number of hosts that are tried
19523 for a single delivery. However, despite the term `host' in its name, the option
19524 actually applies to each IP address independently. In other words, a multihomed
19525 host is treated as several independent hosts, just as it is for retrying.
19526
19527 Many of the larger ISPs have multiple MX records which often point to
19528 multihomed hosts. As a result, a list of a dozen or more IP addresses may be
19529 created as a result of routing one of these domains.
19530
19531 Trying every single IP address on such a long list does not seem sensible; if
19532 several at the top of the list fail, it is reasonable to assume there is some
19533 problem that is likely to affect all of them. Roughly speaking, the value of
19534 \hosts@_max@_try\ is the maximum number that are tried before deferring the
19535 delivery. However, the logic cannot be quite that simple.
19536
19537 Firstly, IP addresses that are skipped because their retry times have not
19538 arrived do not count, and in addition, addresses that are past their retry
19539 limits are also not counted, even when they are tried. This means that when
19540 some IP addresses are past their retry limits, more than the value of
19541 \hosts@_max@_retry\ may be tried. The reason for this behaviour is to ensure
19542 that all IP addresses are considered before timing out an email address (but 
19543 see below for an exception).
19544
19545 Secondly, when the \hosts@_max@_try\ limit is reached, Exim looks down the host
19546 list to see if there is a subsequent host with a different (higher valued) MX.
19547 If there is, that host is considered next, and the current IP address is used
19548 but not counted. This behaviour helps in the case of a domain with a retry rule
19549 that hardly ever delays any hosts, as is now explained:
19550
19551 Consider the case of a long list of hosts with one MX value, and a few with a
19552 higher MX value. If \hosts@_max@_try\ is small (the default is 5) only a few
19553 hosts at the top of the list are tried at first. With the default retry rule,
19554 which specifies increasing retry times, the higher MX hosts are eventually
19555 tried when those at the top of the list are skipped because they have not
19556 reached their retry times.
19557
19558 However, it is common practice to put a fixed short retry time on domains for
19559 large ISPs, on the grounds that their servers are rarely down for very long.
19560 Unfortunately, these are exactly the domains that tend to resolve to long lists
19561 of hosts. The short retry time means that the lowest MX hosts are tried every
19562 time. The attempts may be in a different order because of random sorting, but
19563 without the special MX check, the higher MX hosts would never be tried
19564 .em
19565 until all the lower MX hosts had timed out (which might be several days),
19566 because there are always some lower MX hosts that have reached their retry
19567 times. With the special check, Exim considers at least one IP address from each
19568 MX value at every delivery attempt, even if the \hosts@_max@_try\ limit has
19569 already been reached.
19570
19571 The above logic means that \hosts@_max@_try\ is not a hard limit, and in
19572 particular, Exim normally eventually tries all the IP addresses before timing
19573 out an email address. When \hosts@_max@_try\ was implemented, this seemed a 
19574 reasonable thing to do. Recently, however, some lunatic DNS configurations have 
19575 been set up with hundreds of IP addresses for some domains. It can 
19576 take a very long time indeed for an address to time out in these cases.
19577
19578 The \hosts@_max@_try@_hardlimit\ option was added to help with this problem.
19579 Exim never tries more than this number of IP addresses; if it hits this limit
19580 and they are all timed out, the email address is bounced, even though not all
19581 possible IP addresses have been tried.
19582 .nem
19583
19584
19585
19586
19587 .
19588 .
19589 .
19590 .
19591 . ============================================================================
19592 .chapter Address rewriting
19593 .set runningfoot "address rewriting"
19594 .rset CHAPrewrite ~~chapter
19595 .index rewriting||addresses
19596 There are some circumstances in which Exim automatically rewrites domains in
19597 addresses. The two most common are when an address is given without a domain
19598 (referred to as an `unqualified address') or when an address contains an
19599 abbreviated domain that is expanded by DNS lookup.
19600
19601 Unqualified envelope addresses are accepted only for locally submitted
19602 messages, or messages from hosts that match \sender@_unqualified@_hosts\ or
19603 \recipient@_unqualified@_hosts\, respectively. Unqualified addresses in header
19604 lines are qualified if they are in locally submitted messages, or messages from
19605 hosts that are permitted to send unqualified envelope addresses. Otherwise,
19606 unqualified addresses in header lines are neither qualified nor rewritten.
19607
19608 One situation in which Exim does $it{not} automatically rewrite a domain is
19609 when it is the name of a CNAME record in the DNS. The older RFCs suggest that
19610 such a domain should be rewritten using the `canonical' name, and some MTAs do
19611 this. The new RFCs do not contain this suggestion.
19612  
19613 .section Explicitly configured address rewriting
19614 This chapter describes the rewriting rules that can be used in the
19615 main rewrite section of the configuration file, and also in the generic
19616 \headers@_rewrite\ option that can be set on any transport.
19617
19618 Some people believe that configured address rewriting is a Mortal Sin.
19619 Others believe that life is not possible without it. Exim provides the
19620 facility; you do not have to use it.
19621
19622 The main rewriting rules that appear in the `rewrite' section of the
19623 configuration file are applied to addresses in incoming messages, both envelope
19624 addresses and addresses in header lines. Each rule specifies the types of
19625 address to which it applies.
19626
19627 Rewriting of addresses in header lines applies only to those headers that
19628 were received with the message, and, in the case of transport rewriting, those
19629 that were added by a system filter. That is, it applies only to those headers
19630 that are common to all copies of the message. Header lines that are added by
19631 individual routers or transports (and which are therefore specific to
19632 individual recipient addresses) are not rewritten.
19633
19634 In general, rewriting addresses from your own system or domain has some
19635 legitimacy. Rewriting other addresses should be done only with great care and
19636 in special circumstances. The author of Exim believes that rewriting should be
19637 used sparingly, and mainly for `regularizing' addresses in your own domains.
19638 Although it can sometimes be used as a routing tool, this is very strongly
19639 discouraged.
19640
19641 There are two commonly encountered circumstances where rewriting is used, as
19642 illustrated by these examples:
19643 .numberpars $.
19644 The company whose domain is \*hitch.fict.example*\ has a number of hosts that
19645 exchange mail with each other behind a firewall, but there is only a single
19646 gateway to the outer world. The gateway rewrites \*@*.hitch.fict.example*\ as
19647 \*hitch.fict.example*\ when sending mail off-site.
19648 .nextp
19649 A host rewrites the local parts of its own users so that, for example,
19650 \*fp42@@hitch.fict.example*\ becomes \*Ford.Prefect@@hitch.fict.example*\.
19651 .endp
19652
19653 .section When does rewriting happen?
19654 .index rewriting||timing of
19655 .index ~~ACL||rewriting addresses in
19656 Configured address rewriting can take place at several different stages of a
19657 message's processing.
19658
19659 At the start of an ACL for \\MAIL\\, the sender address may have been rewritten
19660 by a special SMTP-time rewrite rule (see section ~~SECTrewriteS), but no
19661 ordinary rewrite rules have yet been applied. If, however, the sender address
19662 is verified in the ACL, it is rewritten before verification, and remains
19663 rewritten thereafter. The subsequent value of \$sender@_address$\ is the
19664 rewritten address. This also applies if sender verification happens in a
19665 \\RCPT\\ ACL. Otherwise, when the sender address is not verified, it is
19666 rewritten as soon as a message's header lines have been received.
19667
19668 Similarly, at the start of an ACL for \\RCPT\\, the current recipient's address
19669 may have been rewritten by a special SMTP-time rewrite rule, but no ordinary
19670 rewrite rules have yet been applied to it. However, the behaviour is different
19671 from the sender address when a recipient is verified. The address is rewritten
19672 for the verification, but the rewriting is not remembered at this stage. The
19673 value of \$local@_part$\ and \$domain$\ after verification are always the same
19674 as they were before (that is, they contain the unrewritten -- except for
19675 SMTP-time rewriting -- address).
19676
19677 Once a message's header lines have been received, all the envelope recipient
19678 addresses are permanently rewritten, and rewriting is also applied to the
19679 addresses in the header lines (if configured).
19680 .index \*local@_scan()*\ function||address rewriting, timing of
19681 Thus, all the rewriting is completed before the \\DATA\\ ACL and
19682 \*local@_scan()*\ functions are run.
19683
19684 When an address is being routed, either for delivery or for verification,
19685 rewriting is applied immediately to child addresses that are generated by
19686 redirection, unless \no@_rewrite\ is set on the router.
19687
19688 .index envelope sender, rewriting
19689 .index rewriting||at transport time
19690 At transport time, additional rewriting of addresses in header lines can be
19691 specified by setting the generic \headers@_rewrite\ option on a transport. This
19692 option contains rules that are identical in form to those in the rewrite
19693 section of the configuration file. In addition, the outgoing envelope sender
19694 can be rewritten by means of the \return@_path\ transport option. However, it
19695 is not possible to rewrite envelope recipients at transport time.
19696
19697
19698
19699 .section Testing the rewriting rules that apply on input
19700 .index rewriting||testing
19701 .index testing||rewriting
19702 Exim's input rewriting configuration appears in a part of the run time
19703 configuration file headed by `begin rewrite'. It can be tested by the \-brw-\
19704 command line option. This takes an address (which can be a full RFC 2822
19705 address) as its argument. The output is a list of how the address would be
19706 transformed by the rewriting rules for each of the different places it might
19707 appear in an incoming message, that is, for each different header and for the
19708 envelope sender and recipient fields. For example,
19709 .display asis
19710 exim -brw ph10@exim.workshop.example
19711 .endd
19712 might produce the output
19713 .display asis
19714   sender: Philip.Hazel@exim.workshop.example
19715     from: Philip.Hazel@exim.workshop.example
19716       to: ph10@exim.workshop.example
19717       cc: ph10@exim.workshop.example
19718      bcc: ph10@exim.workshop.example
19719 reply-to: Philip.Hazel@exim.workshop.example
19720 env-from: Philip.Hazel@exim.workshop.example
19721   env-to: ph10@exim.workshop.example
19722 .endd
19723 which shows that rewriting has been set up for that address when used in any of
19724 the source fields, but not when it appears as a recipient address. At the
19725 present time, there is no equivalent way of testing rewriting rules that are
19726 set for a particular transport.
19727
19728 .section Rewriting rules
19729 .index rewriting||rules
19730 The rewrite section of the configuration file consists of lines of rewriting
19731 rules in the form
19732 .display
19733 <<source pattern>>  <<replacement>>  <<flags>>
19734 .endd
19735 Rewriting rules that are specified for the \headers@_rewrite\ generic transport
19736 option are given as a colon-separated list. Each item in the list takes the
19737 same form as a line in the main rewriting configuration
19738 (except that any colons must be doubled, of course).
19739
19740 The formats of source patterns and replacement strings are described below.
19741 Each is terminated by white space, unless enclosed in double quotes, in which
19742 case normal quoting conventions apply inside the quotes. The flags are single
19743 characters which may appear in any order. Spaces and tabs between them are
19744 ignored.
19745
19746 For each address that could potentially be rewritten, the rules are scanned in
19747 order, and replacements for the address from earlier rules can themselves be
19748 replaced by later rules (but see the `q' and `R' flags).
19749
19750 The order in which addresses are rewritten is undefined, may change between
19751 releases, and must not be relied on, with one exception: when a message is
19752 received, the envelope sender is always rewritten first, before any header
19753 lines are rewritten. For example, the replacement string for a rewrite of an
19754 address in ::To:: must not assume that the message's address in ::From:: has (or
19755 has not) already been rewritten. However, a rewrite of ::From:: may assume that
19756 the envelope sender has already been rewritten.
19757
19758 The variables \$local@_part$\ and \$domain$\ can be used in the replacement
19759 string to refer to the address that is being rewritten. Note that lookup-driven
19760 rewriting can be done by a rule of the form
19761 .display asis
19762 *@*   ${lookup ...
19763 .endd
19764 where the lookup key uses \$1$\ and \$2$\ or \$local@_part$\ and \$domain$\ to
19765 refer to the address that is being rewritten.
19766
19767 .section Rewriting patterns
19768 .index rewriting||patterns
19769 .index address list||in a rewriting pattern
19770 The source pattern in a rewriting rule is any item which may appear in an
19771 address list (see section ~~SECTaddresslist). It is in fact processed as a
19772 single-item address list, which means that it is expanded before being tested
19773 against the address.
19774
19775 Domains in patterns should be given in lower case. Local parts in patterns are
19776 case-sensitive. If you want to do case-insensitive matching of local parts, you
19777 can use a regular expression that starts with \"^(?i)"\.
19778
19779 .index numerical variables (\$1$\, \$2$\, etc)||in rewriting rules
19780 After matching, the numerical variables \$1$\, \$2$\, etc. may be set,
19781 depending on the type of match which occurred. These can be used in the
19782 replacement string to insert portions of the incoming address. \$0$\ always
19783 refers to the complete incoming address. When a regular expression is used, the
19784 numerical variables are set from its capturing subexpressions. For other types
19785 of pattern they are set as follows:
19786
19787 .numberpars $.
19788 If a local part or domain starts with an asterisk, the numerical variables
19789 refer to the character strings matched by asterisks, with \$1$\ associated with
19790 the first asterisk, and \$2$\ with the second, if present. For example, if the
19791 pattern
19792 .display
19793 *queen@@*.fict.example
19794 .endd
19795 is matched against the address \*hearts-queen@@wonderland.fict.example*\ then
19796 .display asis
19797 $0 = hearts-queen@wonderland.fict.example
19798 $1 = hearts-
19799 $2 = wonderland
19800 .endd
19801 Note that if the local part does not start with an asterisk, but the domain
19802 does, it is \$1$\ that contains the wild part of the domain.
19803 .nextp
19804 If the domain part of the pattern is a partial lookup, the wild and fixed parts
19805 of the domain are placed in the next available numerical variables. Suppose,
19806 for example, that the address \*foo@@bar.baz.example*\ is processed by a
19807 rewriting rule of the form
19808 .display
19809 *@@partial-dbm;/some/dbm/file    <<replacement string>>
19810 .endd
19811 and the key in the file that matches the domain is \"*.baz.example"\. Then
19812 .display asis
19813 $1 = foo
19814 $2 = bar
19815 $3 = baz.example
19816 .endd
19817 If the address \*foo@@baz.example*\ is looked up, this matches the same
19818 wildcard file entry, and in this case \$2$\ is set to the empty string, but
19819 \$3$\ is still set to \*baz.example*\. If a non-wild key is matched in a
19820 partial lookup, \$2$\ is again set to the empty string and \$3$\ is set to the
19821 whole domain. For non-partial domain lookups, no numerical variables are set.
19822 .endp
19823
19824 .section Rewriting replacements
19825 .index rewriting||replacements
19826 If the replacement string for a rule is a single asterisk, addresses that
19827 match the pattern and the flags are $it{not} rewritten, and no subsequent
19828 rewriting rules are scanned. For example,
19829 .display asis
19830 hatta@lookingglass.fict.example  *  f
19831 .endd
19832 specifies that \*hatta@@lookingglass.fict.example*\ is never to be rewritten in
19833 ::From:: headers.
19834
19835 If the replacement string is not a single asterisk, it is expanded, and must
19836 yield a fully qualified address. Within the expansion, the variables
19837 \$local@_part$\ and \$domain$\ refer to the address that is being rewritten.
19838 Any letters they contain retain their original case -- they are not lower
19839 cased. The numerical variables are set up according to the type of pattern that
19840 matched the address, as described above. If the expansion is forced to fail by
19841 the presence of `fail' in a conditional or lookup item, rewriting by the
19842 current rule is abandoned, but subsequent rules may take effect. Any other
19843 expansion failure causes the entire rewriting operation to be abandoned, and an
19844 entry written to the panic log.
19845
19846
19847 .section Rewriting flags
19848 There are three different kinds of flag that may appear on rewriting rules:
19849 .numberpars $.
19850 Flags that specify which headers and envelope addresses to rewrite: E, F, T, b,
19851 c, f, h, r, s, t.
19852 .nextp
19853 A flag that specifies rewriting at SMTP time: S.
19854 .nextp
19855 Flags that control the rewriting process: Q, q, R, w.
19856 .endp
19857 For rules that are part of the \headers@_rewrite\ generic transport option,
19858 E, F, T, and S are not permitted.
19859
19860
19861 .section Flags specifying which headers and envelope addresses to rewrite
19862 .index rewriting||flags
19863 If none of the following flag letters, nor the `S' flag (see section
19864 ~~SECTrewriteS) are present, a main rewriting rule applies to all headers and
19865 to both the sender and recipient fields of the envelope, whereas a
19866 transport-time rewriting rule just applies to all headers. Otherwise, the
19867 rewriting rule is skipped unless the relevant addresses are being processed.
19868 .display
19869 E       $rm{rewrite all envelope fields}
19870 F       $rm{rewrite the envelope From field}
19871 T       $rm{rewrite the envelope To field}
19872 b       $rm{rewrite the ::Bcc:: header}
19873 c       $rm{rewrite the ::Cc:: header}
19874 f       $rm{rewrite the ::From:: header}
19875 h       $rm{rewrite all headers}
19876 r       $rm{rewrite the ::Reply-To:: header}
19877 s       $rm{rewrite the ::Sender:: header}
19878 t       $rm{rewrite the ::To:: header}
19879 .endd
19880 You should be particularly careful about rewriting ::Sender:: headers, and
19881 restrict this to special known cases in your own domains.
19882
19883 .section The SMTP-time rewriting flag
19884 .rset SECTrewriteS "~~chapter.~~section"
19885 .index SMTP||rewriting malformed addresses
19886 .index \\RCPT\\||rewriting argument of
19887 .index \\MAIL\\||rewriting argument of
19888 The rewrite flag `S' specifies a rewrite of incoming envelope addresses at SMTP
19889 time, as soon as an address is received in a \\MAIL\\ or \\RCPT\\ command, and
19890 before any other processing; even before syntax checking. The pattern is
19891 required to be a regular expression, and it is matched against the whole of the
19892 data for the command, including any surrounding angle brackets.
19893
19894 This form of rewrite rule allows for the handling of addresses that are not
19895 compliant with RFCs 2821 and 2822 (for example, `bang paths' in batched SMTP
19896 input). Because the input is not required to be a syntactically valid address,
19897 the variables \$local@_part$\ and \$domain$\ are not available during the
19898 expansion of the replacement string. The result of rewriting replaces the
19899 original address in the \\MAIL\\ or \\RCPT\\ command.
19900
19901 .section Flags controlling the rewriting process
19902 There are four flags which control the way the rewriting process works. These
19903 take effect only when a rule is invoked, that is, when the address is of the
19904 correct type (matches the flags) and matches the pattern:
19905 .numberpars $.
19906 If the `Q' flag is set on a rule, the rewritten address is permitted to be an
19907 unqualified local part. It is qualified with \qualify@_recipient\. In the
19908 absence of `Q' the rewritten address must always include a domain.
19909 .nextp
19910 If the `q' flag is set on a rule, no further rewriting rules are considered,
19911 even if no rewriting actually takes place because of a `fail' in the expansion.
19912 The `q' flag is not effective if the address is of the wrong type (does not
19913 match the flags) or does not match the pattern.
19914 .nextp
19915 The `R' flag causes a successful rewriting rule to be re-applied to the new
19916 address, up to ten times. It can be combined with the `q' flag, to stop
19917 rewriting once it fails to match (after at least one successful rewrite).
19918 .nextp
19919 .index rewriting||whole addresses
19920 When an address in a header is rewritten, the rewriting normally applies only
19921 to the working part of the address, with any comments and RFC 2822 `phrase'
19922 left unchanged. For example, rewriting might change
19923 .display asis
19924 From: Ford Prefect <fp42@restaurant.hitch.fict.example>
19925 .endd
19926 into
19927 .display asis
19928 From: Ford Prefect <prefectf@hitch.fict.example>
19929 .endd
19930 Sometimes there is a need to replace the whole address item, and this can be
19931 done by adding the flag letter `w' to a rule. If this is set on a rule that
19932 causes an address in a header line to be rewritten, the entire address is
19933 replaced, not just the working part. The replacement must be a complete RFC
19934 2822 address, including the angle brackets if necessary. If text outside angle
19935 brackets contains a character whose value is greater than 126 or less than 32
19936 (except for tab), the text is encoded according to RFC 2047.
19937 The character set is taken from \headers@_charset\, which defaults to
19938 ISO-8859-1.
19939
19940 When the `w' flag is set on a rule that causes an envelope address to be
19941 rewritten, all but the working part of the replacement address is discarded.
19942 .endp
19943
19944 .section Rewriting examples
19945 Here is an example of the two common rewriting paradigms:
19946 .display asis
19947 *@*.hitch.fict.example  $1@hitch.fict.example
19948 *@hitch.fict.example    ${lookup{$1}dbm{/etc/realnames}\
19949                      {$value}fail}@hitch.fict.example bctfrF
19950 .endd
19951 Note the use of `fail' in the lookup expansion in the second rule, forcing
19952 the string expansion to fail if the lookup does not succeed. In this context it
19953 has the effect of leaving the original address unchanged, but Exim goes on to
19954 consider subsequent rewriting rules, if any, because the `q' flag is not
19955 present in that rule. An alternative to `fail' would be to supply \$1$\
19956 explicitly, which would cause the rewritten address to be the same as before,
19957 at the cost of a small bit of processing. Not supplying either of these is an
19958 error, since the rewritten address would then contain no local part.
19959
19960 The first example above replaces the domain with a superior, more general
19961 domain. This may not be desirable for certain local parts. If the rule
19962 .display asis
19963 root@*.hitch.fict.example  *
19964 .endd
19965 were inserted before the first rule, rewriting would be suppressed for the
19966 local part \*root*\ at any domain ending in \*hitch.fict.example*\.
19967
19968 Rewriting can be made conditional on a number of tests, by making use of
19969 \${if$\ in the expansion item. For example, to apply a rewriting rule only to
19970 messages that originate outside the local host:
19971 .display asis
19972 *@*.hitch.fict.example  "${if !eq {$sender_host_address}{}\
19973                          {$1@hitch.fict.example}fail}"
19974 .endd
19975 The replacement string is quoted in this example because it contains white
19976 space.
19977
19978 .index rewriting||bang paths
19979 .index bang paths||rewriting
19980 Exim does not handle addresses in the form of `bang paths'. If it sees such an
19981 address it treats it as an unqualified local part which it qualifies with the
19982 local qualification domain (if the source of the message is local or if the
19983 remote host is permitted to send unqualified addresses). Rewriting can
19984 sometimes be used to handle simple bang paths with a fixed number of
19985 components. For example, the rule
19986 .display asis
19987 \N^([^!]+)!(.*)@your.domain.example$\N   $2@$1
19988 .endd
19989 rewrites a two-component bang path \*host.name!user*\ as the domain address
19990 \*user@@host.name*\. However, there is a security implication in using this as
19991 a global rewriting rule for envelope addresses. It can provide a backdoor
19992 method for using your system as a relay, because the incoming addresses appear
19993 to be local. If the bang path addresses are received via SMTP, it is safer to
19994 use the `S' flag to rewrite them as they are received, so that relay checking
19995 can be done on the rewritten addresses.
19996
19997
19998
19999
20000
20001 .
20002 .
20003 .
20004 .
20005 . ============================================================================
20006 .chapter Retry configuration
20007 .set runningfoot "retry configuration"
20008 .rset CHAPretry ~~chapter
20009 .index retry||configuration, description of
20010 .index configuration file||retry section
20011 The `retry' section of the run time configuration file contains a list of retry
20012 rules which control how often Exim tries to deliver messages that cannot be
20013 delivered at the first attempt. If there are no retry rules, temporary errors
20014 are treated as permanent. The \-brt-\ command line option can be used to test
20015 which retry rule will be used for a given address or domain.
20016
20017 The most common cause of retries is temporary failure to deliver to a remote
20018 host because the host is down, or inaccessible because of a network problem.
20019 Exim's retry processing in this case is applied on a per-host (strictly, per IP
20020 address) basis, not on a per-message basis. Thus, if one message has recently
20021 been delayed, delivery of a new message to the same host is not immediately
20022 tried, but waits for the host's retry time to arrive. If the \retry@_defer\ log
20023 selector is set, the message
20024 .index retry||time not reached
20025 `retry time not reached' is written to the main log whenever a delivery is
20026 skipped for this reason. Section ~~SECToutSMTPerr contains more details of the
20027 handling of errors during remote deliveries.
20028
20029 Retry processing applies to routing as well as to delivering, except as covered
20030 in the next paragraph. The retry rules do not distinguish between these
20031 actions. It is not possible, for example, to specify different behaviour for
20032 failures to route the domain \*snark.fict.example*\ and failures to deliver to
20033 the host \*snark.fict.example*\. I didn't think anyone would ever need this
20034 added complication, so did not implement it. However, although they share the
20035 same retry rule, the actual retry times for routing and transporting a given
20036 domain are maintained independently.
20037
20038 When a delivery is not part of a queue run (typically an immediate delivery on
20039 receipt of a message), the routers are always run, and local deliveries are
20040 always attempted, even if retry times are set for them. This makes for better
20041 behaviour if one particular message is causing problems (for example, causing
20042 quota overflow, or provoking an error in a filter file). If such a delivery
20043 suffers a temporary failure, the retry data is updated as normal, and
20044 subsequent delivery attempts from queue runs occur only when the retry time for
20045 the local address is reached.
20046
20047
20048 .section Retry rules
20049 .index retry||rules
20050 .em
20051 Each retry rule occupies one line and consists of three or four parts,
20052 separated by white space: a pattern, an error name, an optional list of sender
20053 addresses, and a list of retry parameters. The pattern and sender lists must be
20054 enclosed in double quotes if they contain white space. The rules are searched in
20055 order until one is found where the pattern, error name, and sender list (if
20056 present) match the failing host or address, the error that occurred, and the
20057 message's sender, respectively.
20058 .nem
20059
20060 The pattern is any single item that may appear in an address list (see section
20061 ~~SECTaddresslist). It is in fact processed as a one-item address list, which
20062 means that it is expanded before being tested against the address that has
20063 been delayed. Address list processing treats a plain domain name as if it were
20064 preceded by `*@@', which makes it possible for many retry rules to start with
20065 just a domain. For example,
20066 .display asis
20067 lookingglass.fict.example        *  F,24h,30m;
20068 .endd
20069 provides a rule for any address in the \*lookingglass.fict.example*\ domain,
20070 whereas
20071 .display asis
20072 alice@lookingglass.fict.example  *  F,24h,30m;
20073 .endd
20074 applies only to temporary failures involving the local part \alice\.
20075 In practice, almost all rules start with a domain name pattern without a local
20076 part.
20077
20078 .index regular expressions||in retry rules
20079 \**Warning**\: If you use a regular expression in a routing rule pattern, it
20080 must match a complete address, not just a domain, because that is how regular
20081 expressions work in address lists.
20082 .display
20083 ^@\Nxyz@\d+@\.abc@\.example@$@\N        *  G,1h,10m,2     \Wrong\
20084 ^@\N[^@@]+@@xyz@\d+@\.abc@\.example@$@\N  *  G,1h,10m,2     \Right\
20085 .endd
20086
20087
20088 .section Choosing which retry rule to use
20089 When Exim is looking for a retry rule after a routing attempt has failed (for
20090 example, after a DNS timeout), each line in the retry configuration is tested
20091 against the complete address only if \retry__use@_local@_part\ is set for the
20092 router. Otherwise, only the domain is used, except when matching against a
20093 regular expression, when the local part of the address is replaced with `*'. A
20094 domain on its own can match a domain pattern, or a pattern that starts with
20095 `*@@'. By default, \retry@_use@_local@_part\ is true for routers where
20096 \check@_local@_user\ is true, and false for other routers.
20097
20098 Similarly, when Exim is looking for a retry rule after a local delivery has
20099 failed (for example, after a mailbox full error), each line in the retry
20100 configuration is tested against the complete address only if
20101 \retry@_use@_local@_part\ is set for the transport (it defaults true for all
20102 local transports).
20103
20104 When Exim is looking for a retry rule after a remote delivery attempt has
20105 failed, what happens depends on the type of failure. After a 4\*xx*\ SMTP
20106 response for a recipient address, the whole address is used when searching the
20107 retry rules. The rule that is found is used to create a retry time for the
20108 failing address.
20109
20110 For a temporary error that is not related to an individual address,
20111 (for example, a connection timeout), each line in the retry configuration is
20112 checked twice. First, the name of the remote host is used as a domain name
20113 (preceded by `*@@' when matching a regular expression). If this does not match
20114 the line, the domain from the email address is tried in a similar fashion. For
20115 example, suppose the MX records for \*a.b.c.example*\ are
20116 .display asis
20117 a.b.c.example  MX  5  x.y.z.example
20118                MX  6  p.q.r.example
20119                MX  7  m.n.o.example
20120 .endd
20121 and the retry rules are
20122 .display asis
20123 p.q.r.example    *      F,24h,30m;
20124 a.b.c.example    *      F,4d,45m;
20125 .endd
20126 and a delivery to the host \*x.y.z.example*\ fails. The first rule matches
20127 neither the host nor the domain, so Exim looks at the second rule. This does
20128 not match the host, but it does match the domain, so it is used to calculate
20129 the retry time for the host \*x.y.z.example*\. Meanwhile, Exim tries to deliver
20130 to \*p.q.r.example*\. If this fails, the first retry rule is used, because it
20131 matches the host.
20132
20133 In other words, failures to deliver to host \*p.q.r.example*\ use the first
20134 rule to determine retry times, but for all the other hosts for the domain
20135 \*a.b.c.example*\, the second rule is used. The second rule is also used if
20136 routing to \*a.b.c.example*\ suffers a temporary failure.
20137
20138 .section Retry rules for specific errors
20139 .index retry||specific errors, specifying
20140 The second field in a retry rule is the name of a particular error, or an
20141 asterisk, which matches any error. The errors that can be tested for are:
20142 .em
20143
20144 .push
20145 .indent 2em
20146 .tempindent 0
20147 \auth@_failed\: Authentication failed when trying to send to a host in the
20148 \hosts@_require@_auth\ list in an \%smtp%\ transport.
20149
20150 .tempindent 0
20151 \rcpt@_4xx\: A 4\*xx*\ error was received for an outgoing \\RCPT\\ command.
20152 Either the first or both of the x's can be given as specific digits, for
20153 example: \"rcpt@_45x"\ or \"rcpt@_436"\. For example, to recognize 452 errors
20154 given to \\RCPT\\ commands by a particular host, and have retries every ten 
20155 minutes and a one-hour timeout, you could set up a retry rule of this form:
20156 .display asis
20157 the.host.name  rcpt_452   F,1h,10m
20158 .endd
20159 These errors apply to both outgoing SMTP (the \%smtp%\ transport) and outgoing
20160 LMTP (either the \%lmtp%\ transport, or the \%smtp%\ transport in LMTP mode).
20161 Note, however, that they apply only to responses to \\RCPT\\ commands.
20162
20163 .tempindent 0
20164 \refused@_MX\: A connection to a host obtained from an MX record was refused.
20165
20166 .tempindent 0
20167 \refused@_A\: A connection to a host not obtained from an MX record was
20168 refused.
20169
20170 .tempindent 0
20171 \refused\: A connection was refused.
20172
20173 .tempindent 0
20174 \timeout@_connect@_MX\: A connection attempt to a host obtained from an MX
20175 record timed out.
20176
20177 .tempindent 0
20178 \timeout@_connect@_A\: A connection attempt to a host not obtained from an MX
20179 record timed out.
20180
20181 .tempindent 0
20182 \timeout@_connect\: A connection attempt timed out.
20183
20184 .tempindent 0
20185 \timeout@_MX\: There was a timeout while connecting or during an SMTP session 
20186 with a host obtained from an MX record.
20187
20188 .tempindent 0
20189 \timeout@_A\: There was a timeout while connecting or during an SMTP session 
20190 with a host not obtained from an MX record.
20191
20192 .tempindent 0
20193 \timeout\: There was a timeout while connecting or during an SMTP session.
20194
20195 .tempindent 0
20196 \quota\: A mailbox quota was exceeded in a local delivery by the
20197 \%appendfile%\ transport.
20198
20199 .index quota||error testing in retry rule
20200 .index retry||quota error testing
20201 .tempindent 0
20202 \quota@_\<<time>>: A mailbox quota was exceeded in a local delivery by 
20203 the \%appendfile%\ transport, and the mailbox has not been accessed for
20204 <<time>>. For example, \*quota@_4d*\ applies to a quota error when the mailbox
20205 has not been accessed for four days.
20206
20207 .pop
20208
20209
20210 .index mailbox||time of last read
20211 The idea of \quota@_\<<time>> is to make it possible to have shorter timeouts
20212 when the mailbox is full and is not being read by its owner. Ideally, it should
20213 be based on the last time that the user accessed the mailbox. However, it is
20214 not always possible to determine this. Exim uses the following heuristic rules:
20215 .numberpars $.
20216 If the mailbox is a single file, the time of last access (the `atime') is used.
20217 As no new messages are being delivered (because the mailbox is over quota), 
20218 Exim does not access the file, so this is the time of last user access.
20219 .nextp
20220 .index maildir format||time of last read
20221 For a maildir delivery, the time of last modification of the \(new)\
20222 subdirectory is used. As the mailbox is over quota, no new files are created in
20223 the \(new)\ subdirectory, because no new messages are being delivered. Any
20224 change to the \(new)\ subdirectory is therefore assumed to be the result of an
20225 MUA moving a new message to the \(cur)\ directory when it is first read. The
20226 time that is used is therefore the last time that the user read a new message.
20227 .nextp
20228 For other kinds of multi-file mailbox, the time of last access cannot be
20229 obtained, so a retry rule that uses this type of error field is never matched.
20230 .endp
20231 .nem
20232 The quota errors apply both to system-enforced quotas and to Exim's own quota
20233 mechanism in the \%appendfile%\ transport. The \*quota*\ error also applies
20234 when a local delivery is deferred because a partition is full (the \\ENOSPC\\
20235 error).
20236
20237
20238 .em
20239 .section Retry rules for specified senders
20240 .index retry||rules, sender-specific
20241 You can specify retry rules that apply only when the failing message has a
20242 specific sender. In particular, this can be used to define retry rules that
20243 apply only to bounce messages. The third item in a retry rule can be of this
20244 form:
20245 .display 
20246 senders=<<address list>>
20247 .endd
20248 The retry timings themselves are then the fourth item. For example:
20249 .display asis
20250 *   *   senders=:   F,1h,30m
20251 .endd
20252 matches all temporary errors for bounce messages sent to any host. If the
20253 address list contains white space, it must be enclosed in quotes. For example:
20254 .display
20255 a.domain  timeout  senders="x@b.dom : y@c.dom"  G,8h,10m,1.5
20256 .endd
20257 When testing retry rules using \-brt-\, you can supply a sender using the \-f-\
20258 command line option, like this:
20259 .display asis
20260 exim -f "" -brt user@dom.ain
20261 .endd
20262 If you do not set \-f-\ with \-brt-\, a retry rule that contains a senders list
20263 is never matched.
20264 .nem
20265
20266
20267
20268 .section Retry parameters
20269 .index retry||parameters in rules
20270 The third 
20271 .em
20272 (or fourth, if a senders list is present)
20273 .nem
20274 field in a retry rule is a sequence of retry parameter sets, separated by
20275 semicolons. Each set consists of
20276 .display
20277 <<letter>>,<<cutoff time>>,<<arguments>>
20278 .endd
20279 The letter identifies the algorithm for computing a new retry time; the cutoff
20280 time is the time beyond which this algorithm no longer applies, and the
20281 arguments vary the algorithm's action. The cutoff time is measured from the
20282 time that the first failure for the domain (combined with the local part if
20283 relevant) was detected, not from the time the message was received.
20284 .index retry||algorithms
20285 The available algorithms are:
20286 .numberpars $.
20287 \*F*\: retry at fixed intervals. There is a single time parameter specifying
20288 the interval.
20289 .nextp
20290 \*G*\: retry at geometrically increasing intervals. The first argument
20291 specifies a starting value for the interval, and the second a multiplier, which
20292 is used to increase the size of the interval at each retry.
20293 .endp
20294 When computing the next retry time, the algorithm definitions are scanned in
20295 order until one whose cutoff time has not yet passed is reached. This is then
20296 used to compute a new retry time that is later than the current time. In the
20297 case of fixed interval retries, this simply means adding the interval to the
20298 current time. For geometrically increasing intervals, retry intervals are
20299 computed from the rule's parameters until one that is greater than the previous
20300 interval is found. The main configuration variable
20301 .index limit||retry interval
20302 .index retry||interval, maximum
20303 .index \retry@_interval@_max\
20304 \retry@_interval@_max\ limits the maximum interval between retries.
20305
20306 A single remote domain may have a number of hosts associated with it, and each
20307 host may have more than one IP address. Retry algorithms are selected on the
20308 basis of the domain name, but are applied to each IP address independently. If,
20309 for example, a host has two IP addresses and one is unusable, Exim will
20310 generate retry times for it and will not try to use it until its next retry
20311 time comes. Thus the good IP address is likely to be tried first most of the
20312 time.
20313
20314 .index hints database||use for retrying
20315 Retry times are hints rather than promises. Exim does not make any attempt to
20316 run deliveries exactly at the computed times. Instead, a queue runner process
20317 starts delivery processes for delayed messages periodically, and these attempt
20318 new deliveries only for those addresses that have passed their next retry time.
20319 If a new message arrives for a deferred address, an immediate delivery attempt
20320 occurs only if the address has passed its retry time. In the absence of new
20321 messages, the minimum time between retries is the interval between queue runner
20322 processes. There is not much point in setting retry times of five minutes if
20323 your queue runners happen only once an hour, unless there are a significant
20324 number of incoming messages (which might be the case on a system that is
20325 sending everything to a smart host, for example).
20326
20327 The data in the retry hints database can be inspected by using the
20328 \*exim@_dumpdb*\ or \*exim@_fixdb*\ utility programs (see chapter ~~CHAPutils). The
20329 latter utility can also be used to change the data. The \*exinext*\ utility
20330 script can be used to find out what the next retry times are for the hosts
20331 associated with a particular mail domain, and also for local deliveries that
20332 have been deferred.
20333
20334 .section Retry rule examples
20335 Here are some example retry rules:
20336 .display asis
20337 alice@wonderland.fict.example quota_5d  F,7d,3h
20338 wonderland.fict.example       quota_5d
20339 wonderland.fict.example       *         F,1h,15m; G,2d,1h,2;
20340 lookingglass.fict.example     *         F,24h,30m;
20341 *                          refused_A F,2h,20m;
20342 *                          *         F,2h,15m; G,16h,1h,1.5; F,5d,8h
20343 .endd
20344 The first rule sets up special handling for mail to
20345 \*alice@@wonderland.fict.example*\ when there is an over-quota error and the
20346 mailbox has not been read for at least 5 days. Retries continue every three
20347 hours for 7 days. The second rule handles over-quota errors for all other local
20348 parts at \*wonderland.fict.example*\; the absence of a local part has the same
20349 effect as supplying `$*$@@'. As no retry algorithms are supplied, messages that
20350 fail are bounced immediately if the mailbox has not been read for at least 5
20351 days.
20352
20353 The third rule handles all other errors at \*wonderland.fict.example*\; retries
20354 happen every 15 minutes for an hour, then with geometrically increasing
20355 intervals until two days have passed since a delivery first failed. After the
20356 first hour there is a delay of one hour, then two hours, then four hours, and
20357 so on (this is a rather extreme example).
20358
20359 The fourth rule controls retries for the domain \*lookingglass.fict.example*\.
20360 They happen every 30 minutes for 24 hours only. The remaining two rules handle
20361 all other domains, with special action for connection refusal from hosts that
20362 were not obtained from an MX record.
20363
20364 The final rule in a retry configuration should always have asterisks in the
20365 first two fields so as to provide a general catch-all for any addresses that do
20366 not have their own special handling. This example tries every 15 minutes for 2
20367 hours, then with intervals starting at one hour and increasing by a factor of
20368 1.5 up to 16 hours, then every 8 hours up to 5 days.
20369
20370
20371 .section Timeout of retry data
20372 .index timeout||of retry data
20373 .index \retry@_data@_expire\
20374 .index hints database||data expiry
20375 .index retry||timeout of data
20376 Exim timestamps the data that it writes to its retry hints database. When it
20377 consults the data during a delivery it ignores any that is older than the value
20378 set in \retry@_data@_expire\ (default 7 days). If, for example, a host hasn't
20379 been tried for 7 days, Exim will try to deliver to it immediately a message
20380 arrives, and if that fails, it will calculate a retry time as if it were
20381 failing for the first time.
20382
20383 This improves the behaviour for messages routed to rarely-used hosts such as MX
20384 backups. If such a host was down at one time, and happens to be down again when
20385 Exim tries a month later, using the old retry data would imply that it had been
20386 down all the time, which is not a justified assumption.
20387
20388 If a host really is permanently dead, this behaviour causes a burst of retries
20389 every now and again, but only if messages routed to it are rare. It there is a
20390 message at least once every 7 days the retry data never expires.
20391
20392
20393
20394 .section Long-term failures
20395 .index delivery||failure, long-term
20396 .index retry||after long-term failure
20397 Special processing happens when an email address has been failing for so long
20398 that the cutoff time for the last algorithm is reached. For example, using the
20399 default retry rule:
20400 .display asis
20401 * * F,2h,15m; G,16h,1h,1.5; F,4d,6h
20402 .endd
20403 the cutoff time is four days. Reaching the retry cutoff is independent of how
20404 long any specific message has been failing; it is the length of continuous
20405 failure for the recipient address that counts.
20406
20407 When the cutoff time is reached for a local delivery, or for all the IP
20408 addresses associated with a remote delivery, a subsequent delivery failure
20409 causes Exim to give up on the address, and a bounce message is generated.
20410 In order to cater for new messages that use the failing address, a next retry
20411 time is still computed from the final algorithm, and is used as follows:
20412
20413 For local deliveries, one delivery attempt is always made for any subsequent
20414 messages. If this delivery fails, the address fails immediately. The
20415 post-cutoff retry time is not used.
20416
20417 If the delivery is remote, there are two possibilities, controlled by the
20418 .index \delay@_after@_cutoff\
20419 \delay@_after@_cutoff\ option of the \%smtp%\ transport. The option is true by
20420 default and in that case:
20421 .numberpars " "
20422 Until the post-cutoff retry time for one of the IP addresses is reached,
20423 the failing email address is bounced immediately, without a delivery attempt
20424 taking place. After that time, one new delivery attempt is made to those IP
20425 addresses that are past their retry times, and if that still fails, the address
20426 is bounced and new retry times are computed.
20427 .endp
20428
20429 In other words, when all the hosts for a given email address have been failing
20430 for a long time, Exim bounces rather then defers until one of the hosts' retry
20431 times is reached. Then it tries once, and bounces if that attempt fails. This
20432 behaviour ensures that few resources are wasted in repeatedly trying to deliver
20433 to a broken destination, but if the host does recover, Exim will eventually
20434 notice.
20435
20436 If \delay@_after@_cutoff\ is set false, Exim behaves differently. If all IP
20437 addresses are past their final cutoff time, Exim tries to deliver to those IP
20438 addresses that have not been tried since the message arrived. If there are
20439 no suitable IP addresses, or if they all fail, the address is bounced. In other
20440 words, it does not delay when a new message arrives, but tries the expired
20441 addresses immediately, unless they have been tried since the message arrived.
20442 If there is a continuous stream of messages for the failing domains, setting
20443 \delay@_after@_cutoff\ false means that there will be many more attempts to
20444 deliver to permanently failing IP addresses than when \delay@_after@_cutoff\ is
20445 true.
20446
20447 .section Ultimate address timeout
20448 .index retry||ultimate address timeout
20449 An additional rule is needed to cope with cases where a host is intermittently
20450 available, or when a message has some attribute that prevents its delivery when
20451 others to the same address get through. In this situation, because some
20452 messages are successfully delivered, the `retry clock' for the address keeps
20453 getting restarted, and so a message could remain on the queue for ever. To
20454 prevent this, if a message has been on the queue for longer than the cutoff
20455 time of any applicable retry rule for a given address, a delivery is attempted
20456 for that address, even if it is not yet time, and if this delivery fails, the
20457 address is timed out. A new retry time is not computed in this case, so that
20458 other messages for the same address are considered immediately.
20459
20460
20461
20462
20463
20464 .
20465 .
20466 .
20467 .
20468 . ============================================================================
20469 .chapter SMTP authentication
20470 .set runningfoot "SMTP authentication"
20471 .rset CHAPSMTPAUTH "~~chapter"
20472 .index SMTP||authentication configuration
20473 .index authentication
20474 The `authenticators' section of Exim's run time configuration is concerned with
20475 SMTP authentication. This facility is an extension to the SMTP protocol,
20476 described in RFC 2554, which allows a client SMTP host to authenticate itself
20477 to a server. This is a common way for a server to recognize clients that
20478 are permitted to use it as a relay. SMTP authentication is not of relevance to
20479 the transfer of mail between servers that have no managerial connection with
20480 each other.
20481
20482 .index \\AUTH\\||description of
20483 Very briefly, the way SMTP authentication works is as follows:
20484 .numberpars $.
20485 The server advertises a number of authentication \*mechanisms*\ in response to
20486 the client's \\EHLO\\ command.
20487 .nextp
20488 The client issues an \\AUTH\\ command, naming a specific mechanism. The command
20489 may, optionally, contain some authentication data.
20490 .nextp
20491 The server may issue one or more \*challenges*\, to which the client must send
20492 appropriate responses. In simple authentication mechanisms, the challenges are
20493 just prompts for user names and passwords. The server does not have to issue
20494 any challenges -- in some mechanisms the relevant data may all be transmitted
20495 with the \\AUTH\\ command.
20496 .nextp
20497 The server either accepts or denies authentication.
20498 .nextp
20499 If authentication succeeds, the client may optionally make use of the \\AUTH\\
20500 option on the \\MAIL\\ command to pass an authenticated sender in subsequent
20501 mail transactions. Authentication lasts for the remainder of the SMTP
20502 connection.
20503 .nextp
20504 If authentication fails, the client may give up, or it may try a different
20505 authentication mechanism, or it may try transferring mail over the
20506 unauthenticated connection.
20507 .endp
20508 If you are setting up a client, and want to know which authentication
20509 mechanisms the server supports, you can use Telnet to connect to port 25 (the
20510 SMTP port) on the server, and issue an \\EHLO\\ command. The response to this
20511 includes the list of supported mechanisms. For example:
20512 .display
20513 @$ $cb{telnet server.example 25}
20514 Trying 192.168.34.25...
20515 Connected to server.example.
20516 Escape character is '@^]'.
20517 220 server.example ESMTP Exim 4.20 ...
20518 $cb{ehlo client.example}
20519 250-server.example Hello client.example [10.8.4.5]
20520 250-SIZE 52428800
20521 250-PIPELINING
20522 250-AUTH PLAIN
20523 250 HELP
20524 .endd
20525 The second-last line of this example output shows that the server supports
20526 authentication using the PLAIN mechanism. In Exim, the different authentication
20527 mechanisms are configured by specifying \*authenticator*\ drivers. Like the
20528 routers and transports, which authenticators are included in the binary is
20529 controlled by build-time definitions. The following are currently available,
20530 included by setting
20531 .display asis
20532 AUTH_CRAM_MD5=yes
20533 AUTH_PLAINTEXT=yes
20534 AUTH_SPA=yes
20535 .endd
20536 in \(Local/Makefile)\, respectively. The first of these supports the CRAM-MD5
20537 authentication mechanism (RFC 2195), and the second can be configured to
20538 support the PLAIN authentication mechanism (RFC 2595) or the LOGIN mechanism,
20539 which is not formally documented, but used by several MUAs. The third
20540 authenticator supports Microsoft's \*Secure Password Authentication*\
20541 mechanism.
20542
20543 The authenticators are configured using the same syntax as other drivers (see
20544 section ~~SECTfordricon). If no authenticators are required, no authentication
20545 section need be present in the configuration file. Each authenticator can in
20546 principle have both server and client functions. When Exim is receiving SMTP
20547 mail, it is acting as a server; when it is sending out messages over SMTP, it
20548 is acting as a client. Authenticator configuration options are provided for use
20549 in both these circumstances.
20550
20551 To make it clear which options apply to which situation, the prefixes
20552 \server@_\ and \client@_\ are used on option names that are specific to either
20553 the server or the client function, respectively. Server and client functions
20554 are disabled if none of their options are set. If an authenticator is to be
20555 used for both server and client functions, a single definition, using both sets
20556 of options, is required. For example:
20557 .display asis
20558 cram:
20559   driver = cram_md5
20560   public_name = CRAM-MD5
20561   server_secret = ${if eq{$1}{ph10}{secret1}fail}
20562   client_name = ph10
20563   client_secret = secret2
20564 .endd
20565 The \server@_\ option is used when Exim is acting as a server, and the
20566 \client@_\ options when it is acting as a client.
20567
20568 Descriptions of the individual authenticators are given in subsequent chapters.
20569 The remainder of this chapter covers the generic options for the
20570 authenticators, followed by general discussion of the way authentication works
20571 in Exim.
20572
20573
20574 .section Generic options for authenticators
20575 .index authentication||generic options
20576
20577 .startconf authenticators
20578 .index options||generic, for authenticators
20579
20580 .conf driver string unset
20581 This option must always be set. It specifies which of the available
20582 authenticators is to be used.
20583
20584 .conf public@_name string unset
20585 This option specifies the name of the authentication mechanism that the driver
20586 implements, and by which it is known to the outside world. These names should
20587 contain only upper case letters, digits, underscores, and hyphens (RFC 2222),
20588 but Exim in fact matches them caselessly. If \public@_name\ is not set, it
20589 defaults to the driver's instance name.
20590
20591 .conf server@_advertise@_condition string$**$ unset
20592 When a server is about to advertise an authentication mechanism, the condition
20593 is expanded. If it yields the empty string, `0', `no', or `false', the
20594 mechanism is not advertised.
20595 If the expansion fails, the mechanism is not advertised. If the failure was not
20596 forced, and was not caused by a lookup defer, the incident is logged.
20597 See section ~~SECTauthexiser below for further discussion.
20598
20599 .conf server@_debug@_print string$**$ unset
20600 If this option is set and authentication debugging is enabled (see the \-d-\
20601 command line option), the string is expanded and included in the debugging
20602 output when the authenticator is run as a server. This can help with checking
20603 out the values of variables.
20604 If expansion of the string fails, the error message is written to the debugging
20605 output, and Exim carries on processing.
20606
20607 .conf server@_set@_id string$**$ unset
20608 When an Exim server successfully authenticates a client, this string is
20609 expanded using data from the authentication, and preserved for any incoming
20610 messages in the variable \$authenticated@_id$\. It is also included in the log
20611 lines for incoming messages. For example, a user/password authenticator
20612 configuration might preserve the user name that was used to authenticate, and
20613 refer to it subsequently during delivery of the message.
20614 If expansion fails, the option is ignored.
20615
20616 .conf server@_mail@_auth@_condition string$**$ unset
20617 This option allows a server to discard authenticated sender addresses supplied
20618 as part of \\MAIL\\ commands in SMTP connections that are authenticated by the
20619 driver on which \server__mail__auth@_condition\ is set. The option is not used
20620 as part of the authentication process; instead its (unexpanded) value is
20621 remembered for later use.
20622 How it is used is described in the following section.
20623 .endconf
20624
20625
20626
20627 .section The AUTH parameter on MAIL commands
20628 .rset SECTauthparamail "~~chapter.~~section"
20629 .index authentication||sender, authenticated
20630 .index \\AUTH\\||on \\MAIL\\ command
20631 When a client supplied an \\AUTH=\\ item on a \\MAIL\\ command, Exim applies
20632 the following checks before accepting it as the authenticated sender of the
20633 message:
20634 .numberpars $.
20635 If the connection is not using extended SMTP (that is, \\HELO\\ was used rather
20636 than \\EHLO\\), the use of \\AUTH=\\ is a syntax error.
20637 .nextp
20638 If the value of the \\AUTH=\\ parameter is `@<@>', it is ignored.
20639 .nextp
20640 If \acl@_smtp@_mailauth\ is defined, the ACL it specifies is run. While it is
20641 running, the value of \$authenticated@_sender$\ is set to the value obtained
20642 from the \\AUTH=\\ parameter. If the ACL does not yield `accept', the value of
20643 \$authenticated@_sender$\ is deleted. The \acl@_smtp@_mailauth\ ACL may not
20644 return `drop' or `discard'. If it defers, a temporary error code (451) is given
20645 for the \\MAIL\\ command.
20646 .nextp
20647 If \acl@_smtp@_mailauth\ is not defined, the value of the \\AUTH=\\ parameter
20648 is accepted and placed in \$authenticated@_sender$\ only if the client has
20649 authenticated.
20650 .nextp
20651 If the \\AUTH=\\ value was accepted by either of the two previous rules, and
20652 the client has authenticated, and the authenticator has a setting for the
20653 \server@_mail@_auth@_condition\, the condition is checked at this point. The
20654 valued that was saved from the authenticator is expanded. If the expansion
20655 fails, or yields an empty string, `0', `no', or `false', the value of
20656 \$authenticated__sender$\ is deleted. If the expansion yields any other value,
20657 the value of \$authenticated@_sender$\ is retained and passed on with the
20658 message.
20659 .endp
20660
20661 When \$authenticated@_sender$\ is set for a message, it is passed on to other
20662 hosts to which Exim authenticates as a client. Do not confuse this value with
20663 \$authenticated@_id$\, which is a string obtained from the authentication
20664 process, and which is not usually a complete email address.
20665
20666 Whenever an \\AUTH=\\ value is ignored, the incident is logged. The ACL for
20667 \\MAIL\\, if defined, is run after \\AUTH=\\ is accepted or ignored. It can
20668 therefore make use of \$authenticated@_sender$\. The converse is not true: the
20669 value of \$sender@_address$\ is not yet set up when the \acl@_smtp@_mailauth\
20670 ACL is run.
20671
20672
20673 .section Authentication on an Exim server
20674 .rset SECTauthexiser "~~chapter.~~section"
20675 .index authentication||on an Exim server
20676 When Exim receives an \\EHLO\\ command, it advertises the public names of those
20677 authenticators that are configured as servers, subject to the following
20678 conditions:
20679 .numberpars $.
20680 The client host must match \auth@_advertise@_hosts\ (default $*$).
20681 .nextp
20682 It the \server@_advertise@_condition\ option is set, its expansion must not
20683 yield the empty string, `0', `no', or `false'.
20684 .endp
20685 The order in which the authenticators are defined controls the order in which
20686 the mechanisms are advertised.
20687
20688 Some mail clients (for example, some versions of Netscape) require the user to
20689 provide a name and password for authentication whenever \\AUTH\\ is advertised,
20690 even though authentication may not in fact be needed (for example, Exim may be
20691 set up to allow unconditional relaying from the client by an IP address check).
20692 You can make such clients more friendly by not advertising \\AUTH\\ to them.
20693 For example, if clients on the 10.9.8.0/24 network are permitted (by the ACL
20694 that runs for \\RCPT\\) to relay without authentication, you should set
20695 .display asis
20696 auth_advertise_hosts = ! 10.9.8.0/24
20697 .endd
20698 so that no authentication mechanisms are advertised to them.
20699
20700 The \server@_advertise@_condition\ controls the advertisement of individual
20701 authentication mechanisms. For example, it can be used to restrict the
20702 advertisement of a patricular mechanism to encrypted connections, by a setting
20703 such as:
20704 .display asis
20705 server_advertise_condition = ${if eq{$tls_cipher}{}{no}{yes}}
20706 .endd
20707 If the session is encrypted, \$tls@_cipher$\ is not empty, and so the expansion
20708 yields `yes', which allows the advertisement to happen.
20709
20710 When an Exim server receives an \\AUTH\\ command from a client, it rejects it
20711 immediately if \\AUTH\\ was not advertised in response to an earlier \\EHLO\\
20712 command. This is the case if
20713 .numberpars $.
20714 The client host does not match \auth@_advertise@_hosts\; or
20715 .nextp
20716 No authenticators are configured with server options; or
20717 .nextp
20718 Expansion of \server@_advertise@_condition\ blocked the advertising of all the
20719 server authenticators.
20720 .endp
20721
20722 Otherwise, Exim runs the ACL specified by \acl@_smtp@_auth\ in order
20723 to decide whether to accept the command. If \acl@_smtp@_auth\ is not set,
20724 \\AUTH\\ is accepted from any client host.
20725
20726 If \\AUTH\\ is not rejected by the ACL, Exim searches its configuration for a
20727 server authentication mechanism that was advertised in response to \\EHLO\\ and
20728 that matches the one named in the \\AUTH\\ command. If it finds one, it runs
20729 the appropriate authentication protocol, and authentication either succeeds or
20730 fails. If there is no matching advertised mechanism, the \\AUTH\\ command is
20731 rejected with a 504 error.
20732
20733 When a message is received from an authenticated host, the value of
20734 \$received@_protocol$\ is set to 
20735 .em
20736 `esmtpa' 
20737 .nem
20738 instead of `esmtp', and \$sender@_host@_authenticated$\ contains the name (not
20739 the public name) of the authenticator driver that successfully authenticated
20740 the client from which the message was received. This variable is empty if there
20741 was no successful authentication.
20742
20743
20744
20745 .section Testing server authentication
20746 .index authentication||testing a server
20747 .index \\AUTH\\||testing a server
20748 .index base64 encoding||creating authentication test data
20749 Exim's \-bh-\ option can be useful for testing server authentication
20750 configurations. The data for the \\AUTH\\ command has to be sent using base64
20751 encoding. A quick way to produce such data for testing is the following Perl
20752 script:
20753 .display asis
20754 use MIME::Base64;
20755 printf ("%s", encode_base64(eval "\"$ARGV[0]\""));
20756 .endd
20757 .index binary zero||in authentication data
20758 This interprets its argument as a Perl string, and then encodes it. The
20759 interpretation as a Perl string allows binary zeros, which are required for
20760 some kinds of authentication, to be included in the data. For example, a
20761 command line to run this script on such data might be
20762 .display asis
20763 encode '\0user\0password'
20764 .endd
20765 Note the use of single quotes to prevent the shell interpreting the
20766 backslashes, so that they can be interpreted by Perl to specify characters
20767 whose code value is zero.
20768
20769 \**Warning 1**\: If either of the user or password strings starts with an octal
20770 digit, you must use three zeros instead of one after the leading backslash. If
20771 you do not, the octal digit that starts your string will be incorrectly
20772 interpreted as part of the code for the first character.
20773
20774 \**Warning 2**\: If there are characters in the strings that Perl interprets
20775 specially, you must use a Perl escape to prevent them being misinterpreted. For
20776 example, a command such as
20777 .display asis
20778 encode '\0user@domain.com\0pas$$word'
20779 .endd
20780 gives an incorrect answer because of the unescaped `@@' and `@$' characters.
20781
20782 If you have the \mimencode\ command installed, another way to do produce
20783 base64-encoded strings is to run the command
20784 .display asis
20785 echo -e -n `\0user\0password' | mimencode
20786 .endd
20787 The \-e-\ option of \echo\ enables the interpretation of backslash escapes in
20788 the argument, and the \-n-\ option specifies no newline at the end of its
20789 output. However, not all versions of \echo\ recognize these options, so you
20790 should check your version before relying on this suggestion.
20791
20792
20793 .section Authentication by an Exim client
20794 .index authentication||on an Exim client
20795 The \%smtp%\ transport has two options called \hosts@_require@_auth\ and
20796 \hosts@_try@_auth\. When the \%smtp%\ transport connects to a server that
20797 announces support for authentication, and the host matches an entry in either
20798 of these options, Exim (as a client) tries to authenticate as follows:
20799 .numberpars $.
20800 For each authenticator that is configured as a client, it searches the
20801 authentication mechanisms announced by the server for one whose name
20802 matches the public name of the authenticator.
20803 .nextp
20804 When it finds one that matches, it runs the authenticator's client code.
20805 The variables \$host$\ and \$host@_address$\ are available for any string
20806 expansions that the client might do. They are set to the server's name and
20807 IP address. If any expansion is forced to fail, the authentication attempt
20808 is abandoned,
20809 and Exim moves on to the next authenticator.
20810 Otherwise an expansion failure causes delivery to be
20811 deferred.
20812 .nextp
20813 If the result of the authentication attempt is a temporary error or a timeout,
20814 Exim abandons trying to send the message to the host for the moment. It will
20815 try again later. If there are any backup hosts available, they are tried in the
20816 usual way.
20817 .nextp
20818 If the response to authentication is a permanent error (5xx code), Exim carries
20819 on searching the list of authenticators and tries another one if possible. If
20820 all authentication attempts give permanent errors, or if there are no attempts
20821 because no mechanisms match
20822 (or option expansions force failure),
20823 what happens depends on whether the host matches \hosts@_require@_auth\ or
20824 \hosts@_try@_auth\. In the first case, a temporary error is generated, and
20825 delivery is deferred. The error can be detected in the retry rules, and thereby
20826 turned into a permanent error if you wish. In the second case, Exim tries to
20827 deliver the message unauthenticated.
20828 .endp
20829 .index \\AUTH\\||on \\MAIL\\ command
20830 When Exim has authenticated itself to a remote server, it adds the \\AUTH\\
20831 parameter to the \\MAIL\\ commands it sends, if it has an authenticated sender
20832 for the message.
20833 If the message came from a remote host, the authenticated sender is the one
20834 that was receiving on an incoming \\MAIL\\ command, provided that the incoming
20835 connection was authenticated and the \server@_mail@_auth\ condition allowed the
20836 authenticated sender to be retained. If a local process calls Exim to send a
20837 message, the sender address that is built from the login name and
20838 \qualify@_domain\ is treated as authenticated. However, if the
20839 \authenticated@_sender\ option is set on the \%smtp%\ transport, it overrides
20840 the authenticated sender that was received with the message.
20841
20842
20843
20844
20845
20846
20847 .
20848 .
20849 .
20850 .
20851 . ============================================================================
20852 .chapter The plaintext authenticator
20853 .rset CHAPplaintext "~~chapter"
20854 .set runningfoot "plaintext authenticator"
20855 .index \%plaintext%\ authenticator
20856 .index authenticators||\%plaintext%\
20857 The \%plaintext%\ authenticator can be configured to support the PLAIN and
20858 LOGIN authentication mechanisms, both of which transfer authentication data as
20859 plain (unencrypted) text (though base64 encoded). The use of plain text is a
20860 security risk. If you use one of these mechanisms without also making use of
20861 SMTP encryption (see chapter ~~CHAPTLS) you should not use the same passwords
20862 for SMTP connections as you do for login accounts.
20863
20864 .section Using plaintext in a server
20865 When running as a server, \%plaintext%\ performs the authentication test by
20866 expanding a string. It has the following options:
20867
20868 .startconf plaintext
20869 .index options||\%plaintext%\ authenticator (server)
20870
20871 .conf server@_prompts string$**$ unset
20872 The contents of this option, after expansion, must be a colon-separated list of
20873 prompt strings. If expansion fails, a temporary authentication rejection is
20874 given.
20875
20876 .conf server@_condition string$**$ unset
20877 This option must be set in order to configure the driver as a server. Its use
20878 is described below.
20879
20880 .endconf
20881
20882 .index \\AUTH\\||in \%plaintext%\ authenticator
20883 .index binary zero||in \%plaintext%\ authenticator
20884 .index numerical variables (\$1$\, \$2$\, etc)||in \%plaintext%\ authenticator
20885 .index base64 encoding||in \%plaintext%\ authenticator
20886 The data sent by the client with the \\AUTH\\ command, or in response to
20887 subsequent prompts, is base64 encoded, and so may contain any byte values
20888 when decoded. If any data is supplied with the command, it is treated as a
20889 list of strings, separated by NULs (binary zeros), which are placed in the
20890 expansion variables \$1$\, \$2$\, etc. If there are more strings in
20891 \server@_prompts\ than the number of strings supplied with the \\AUTH\\
20892 command, the remaining prompts are used to obtain more data. Each response from
20893 the client may be a list of NUL-separated strings.
20894
20895 Once a sufficient number of data strings have been received,
20896 \server@_condition\ is expanded.
20897 If the expansion is forced to fail, authentication fails. Any other expansion
20898 failure causes a temporary error code to be returned.
20899 If the result of a successful expansion is an empty string, `0', `no', or
20900 `false', authentication fails. If the result of the expansion is `1', `yes', or
20901 `true', authentication succeeds and the generic \server@_set@_id\ option is
20902 expanded and saved in \$authenticated@_id$\. For any other result, a temporary
20903 error code is returned, with the expanded string as the error text.
20904
20905 \**Warning**\: If you use a lookup in the expansion to find the user's
20906 password, be sure to make the authentication fail if the user is unknown.
20907 There are good and bad examples at the end of the next section.
20908
20909
20910 .section The PLAIN authentication mechanism
20911 .index PLAIN authentication mechanism
20912 .index authentication||PLAIN mechanism
20913 .index binary zero||in \%plaintext%\ authenticator
20914 The PLAIN authentication mechanism (RFC 2595) specifies that three strings be
20915 sent as one item of data (that is, one combined string containing two NUL
20916 separators). The data is sent either as part of the \\AUTH\\ command, or
20917 subsequently in response to an empty prompt from the server.
20918
20919 The second and third strings are a user name and a corresponding password.
20920 Using a single fixed user name and password as an example, this could be
20921 configured as follows:
20922 .display asis
20923 fixed_plain:
20924   driver = plaintext
20925   public_name = PLAIN
20926   server_prompts = :
20927   server_condition = \
20928     ${if and {{eq{$2}{username}}{eq{$3}{mysecret}}}{yes}{no}}
20929   server_set_id = $2
20930 .endd
20931 The \server@_prompts\ setting specifies a single, empty prompt (empty items at
20932 the end of a string list are ignored). If all the data comes as part of the
20933 \\AUTH\\ command, as is commonly the case, the prompt is not used. This
20934 authenticator is advertised in the response to \\EHLO\\ as
20935 .display asis
20936 250-AUTH PLAIN
20937 .endd
20938 and a client host can authenticate itself by sending the command
20939 .display asis
20940 AUTH PLAIN AHVzZXJuYW1lAG15c2VjcmV0
20941 .endd
20942 As this contains three strings (more than the number of prompts), no further
20943 data is required from the client. Alternatively, the client may just send
20944 .display asis
20945 AUTH PLAIN
20946 .endd
20947 to initiate authentication, in which case the server replies with an empty
20948 prompt. The client must respond with the combined data string.
20949
20950 The data string is base64 encoded, as required by the RFC. This example,
20951 when decoded, is \"<<NUL>>username<<NUL>>mysecret"\, where <<NUL>> represents a
20952 zero byte. This is split up into three strings, the first of which is empty.
20953 The \server@_condition\ option in the authenticator checks that the second two
20954 are \"username"\ and \"mysecret"\ respectively.
20955
20956 Having just one fixed user name and password, as in this example, is not very
20957 realistic, though for a small organization with only a handful of
20958 authenticating clients it could make sense.
20959
20960 A more sophisticated instance of this authenticator could use the user name in
20961 \$2$\ to look up a password in a file or database, and maybe do an encrypted
20962 comparison (see \crypteq\ in chapter ~~CHAPexpand). Here is a example of this
20963 approach, where the passwords are looked up in a DBM file. \**Warning**\: This
20964 is an incorrect example:
20965 .display asis
20966 server_condition = \
20967   ${if eq{$3}{${lookup{$2}dbm{/etc/authpwd}}}{yes}{no}}
20968 .endd
20969 The expansion uses the user name (\$2$\) as the key to look up a password,
20970 which it then compares to the supplied password (\$3$\). Why is this example
20971 incorrect? It works fine for existing users, but consider what happens if a
20972 non-existent user name is given. The lookup fails, but as no success/failure
20973 strings are given for the lookup, it yields an empty string. Thus, to defeat
20974 the authentication, all a client has to do is to supply a non-existent user
20975 name and an empty password. The correct way of writing this test is:
20976 .display asis
20977 server_condition = ${lookup{$2}dbm{/etc/authpwd}\
20978   {${if eq{$value}{$3}{yes}{no}}}{no}}
20979 .endd
20980 In this case, if the lookup succeeds, the result is checked; if the lookup
20981 fails, authentication fails. If \crypteq\ is being used instead of \eq\, the
20982 first example is in fact safe, because \crypteq\ always fails if its second
20983 argument is empty. However, the second way of writing the test makes the logic
20984 clearer.
20985
20986
20987 .section The LOGIN authentication mechanism
20988 .index LOGIN authentication mechanism
20989 .index authentication||LOGIN mechanism
20990 The LOGIN authentication mechanism is not documented in any RFC, but is in use
20991 in a number of programs. No data is sent with the \\AUTH\\ command. Instead, a
20992 user name and password are supplied separately, in response to prompts. The
20993 plaintext authenticator can be configured to support this as in this example:
20994 .display asis
20995 fixed_login:
20996   driver = plaintext
20997   public_name = LOGIN
20998   server_prompts = User Name : Password
20999   server_condition = \
21000     ${if and {{eq{$1}{username}}{eq{$2}{mysecret}}}{yes}{no}}
21001   server_set_id = $1
21002 .endd
21003 Because of the way plaintext operates, this authenticator accepts data supplied
21004 with the \\AUTH\\ command (in contravention of the specification of LOGIN), but
21005 if the client does not supply it (as is the case for LOGIN clients), the prompt
21006 strings are used to obtain two data items.
21007
21008 Some clients are very particular about the precise text of the prompts. For
21009 example, Outlook Express is reported to recognize only `Username:' and
21010 `Password:'. Here is an example of a LOGIN authenticator which uses those
21011 strings, and which uses the \ldapauth\ expansion condition to check the user
21012 name and password by binding to an LDAP server:
21013 .display asis
21014 login:
21015   driver = plaintext
21016   public_name = LOGIN
21017   server_prompts = Username:: : Password::
21018   server_condition = ${if ldapauth \
21019 .newline
21020     {user="cn=${quote_ldap_dn:$1},ou=people,o=example.org" \
21021     pass=${quote:$2} \
21022 .newline
21023     ldap://ldap.example.org/}{yes}{no}}
21024   server_set_id = uid=$1,ou=people,o=example.org
21025 .endd
21026 Note the use of the \quote@_ldap@_dn\ operator to correctly quote the DN for
21027 authentication. However, the basic \quote\ operator, rather than any of the
21028 LDAP quoting operators, is the correct one to use for the password, because
21029 quoting is needed only to make the password conform to the Exim syntax. At the
21030 LDAP level, the password is an uninterpreted string.
21031
21032
21033 .section Support for different kinds of authentication
21034 A number of string expansion features are provided for the purpose of
21035 interfacing to different ways of user authentication. These include checking
21036 traditionally encrypted passwords from \(/etc/passwd)\ (or equivalent), PAM,
21037 Radius, \ldapauth\, and \*pwcheck*\. For details see section ~~SECTexpcond.
21038
21039
21040
21041 .section Using plaintext in a client
21042 The \%plaintext%\ authenticator has just one client option:
21043
21044 .startconf plaintext
21045 .index options||\%plaintext%\ authenticator (client)
21046
21047 .conf client@_send string$**$ unset
21048 The string is a colon-separated list of authentication data strings. Each
21049 string is independently expanded before being sent to the server. The first
21050 string is sent with the \\AUTH\\ command; any more strings are sent in response
21051 to prompts from the server.
21052
21053 \**Note**\: you cannot use expansion to create multiple strings, because
21054 splitting takes priority and happens first.
21055
21056 Because the PLAIN authentication mechanism requires NUL (binary zero) bytes in
21057 the data, further processing is applied to each string before it is sent. If
21058 there are any single circumflex characters in the string, they are converted to
21059 NULs. Should an actual circumflex be required as data, it must be doubled in
21060 the string.
21061
21062 .endconf
21063
21064 This is an example of a client configuration that implements the PLAIN
21065 authentication mechanism with a fixed user name and password:
21066 .display asis
21067 fixed_plain:
21068   driver = plaintext
21069   public_name = PLAIN
21070   client_send = ^username^mysecret
21071 .endd
21072 The lack of colons means that the entire text is sent with the \\AUTH\\
21073 command, with the circumflex characters converted to NULs. A similar example
21074 that uses the LOGIN mechanism is:
21075 .display asis
21076 fixed_login:
21077   driver = plaintext
21078   public_name = LOGIN
21079   client_send = : username : mysecret
21080 .endd
21081 The initial colon means that the first string is empty, so no data is sent with
21082 the \\AUTH\\ command itself. The remaining strings are sent in response to
21083 prompts.
21084
21085
21086
21087
21088 .
21089 .
21090 .
21091 .
21092 . ============================================================================
21093 .chapter The cram@_md5 authenticator
21094 .set runningfoot "cram@_md5 authenticator"
21095 .index \%cram@_md5%\ authenticator
21096 .index authenticators||\%cram@_md5%\
21097 .index CRAM-MD5 authentication mechanism
21098 .index authentication||CRAM-MD5 mechanism
21099 The CRAM-MD5 authentication mechanism is described in RFC 2195. The server
21100 sends a challenge string to the client, and the response consists of a user
21101 name and the CRAM-MD5 digest of the challenge string combined with a secret
21102 string (password) which is known to both server and client. Thus, the secret
21103 is not sent over the network as plain text, which makes this authenticator more
21104 secure than \%plaintext%\. However, the downside is that the secret has to be
21105 available in plain text at either end.
21106
21107 .section Using cram@_md5 as a server
21108 This authenticator has one server option, which must be set to configure the
21109 authenticator as a server:
21110
21111 .startconf cram@_md5
21112 .index options||\%cram@_md5%\ authenticator (server)
21113
21114 .conf server@_secret string$**$ unset
21115 .index numerical variables (\$1$\, \$2$\, etc)||in \%cram@_md5%\ authenticator
21116 When the server receives the client's response, the user name is placed in
21117 the expansion variable \$1$\, and \server@_secret\ is expanded to obtain the
21118 password for that user. The server then computes the CRAM-MD5 digest that the
21119 client should have sent, and checks that it received the correct string. If the
21120 expansion of \server@_secret\ is forced to fail, authentication fails. If the
21121 expansion fails for some other reason, a temporary error code is returned to
21122 the client.
21123
21124 .endconf
21125
21126 For example, the following authenticator checks that the user name given by the
21127 client is `ph10', and if so, uses `secret' as the password. For any other user
21128 name, authentication fails.
21129 .display asis
21130 fixed_cram:
21131   driver = cram_md5
21132   public_name = CRAM-MD5
21133   server_secret = ${if eq{$1}{ph10}{secret}fail}
21134   server_set_id = $1
21135 .endd
21136 If authentication succeeds, the setting of \server@_set@_id\ preserves the user
21137 name in \$authenticated@_id$\.
21138 A more tyical configuration might look up the secret string in a file, using
21139 the user name as the key. For example:
21140 .display asis
21141 lookup_cram:
21142   driver = cram_md5
21143   public_name = CRAM-MD5
21144   server_secret = ${lookup{$1}lsearch{/etc/authpwd}{$value}fail}
21145   server_set_id = $1
21146 .endd
21147 Note that this expansion explicitly forces failure if the lookup fails
21148 because \$1$\ contains an unknown user name.
21149
21150 .section Using cram@_md5 as a client
21151 When used as a client, the \%cram@_md5%\ authenticator has two options:
21152
21153 .startconf cram@_md5
21154 .index options||\%cram@_md5%\ authenticator (client)
21155
21156 .conf client@_name string$**$ "the primary host name"
21157 This string is expanded, and the result used as the user name data when
21158 computing the response to the server's challenge.
21159
21160 .conf client@_secret string$**$ unset
21161 This option must be set for the authenticator to work as a client. Its value is
21162 expanded and the result used as the secret string when computing the response.
21163
21164 .endconf
21165
21166 Different user names and secrets can be used for different servers by referring
21167 to \$host$\ or \$host@_address$\ in the options.
21168
21169 Forced failure of either expansion string is treated as an indication that this
21170 authenticator is not prepared to handle this case. Exim moves on to the next
21171 configured client authenticator. Any other expansion failure causes Exim to
21172 give up trying to send the message to the current server.
21173
21174 A simple example configuration of a \%cram@_md5%\ authenticator, using fixed
21175 strings, is:
21176 .display asis
21177 fixed_cram:
21178   driver = cram_md5
21179   public_name = CRAM-MD5
21180   client_name = ph10
21181   client_secret = secret
21182 .endd
21183
21184
21185
21186
21187 .
21188 .
21189 .
21190 .
21191 . ============================================================================
21192 .chapter The cyrus@_sasl authenticator
21193 .set runningfoot "cyrus@_sasl authenticator"
21194 .index \%cyrus@_sasl%\ authenticator
21195 .index authenticators||\%cyrus@_sasl%\
21196 .index Cyrus, SASL library
21197 .em
21198 The code for this authenticator was provided by Matthew Byng-Maddick of A L
21199 Digital Ltd (\?http://www.aldigital.co.uk?\).
21200
21201 The \%cyrus@_sasl%\ authenticator provides server support for the Cyrus SASL
21202 library implementation of the RFC 2222 (`Simple Authentication and Security
21203 Layer'). This library supports a number of authentication mechanisms, including
21204 PLAIN and LOGIN, but also several others that Exim does not support directly.
21205 The \%cyrus@_sasl%\ authenticator provides a gatewaying mechanism directly to
21206 the Cyrus interface, so if your Cyrus library can do, for example, CRAM-MD5,
21207 then so can the \%cyrus@_sasl%\ authenticator. By default it uses the public
21208 name of the driver to determine which mechanism to support.
21209
21210 Where access to some kind of secret file is required, for example in GSSAPI
21211 or CRAM-MD5, it is worth noting that the authenticator runs as the \*exim*\
21212 user, and that the Cyrus SASL library has no way of escalating privileges
21213 by default. You may also find you need to set environment variables,
21214 depending on the driver you are using.
21215
21216 .section Using cyrus@_sasl as a server
21217 The \%cyrus@_sasl%\ authenticator has four private options. It puts the
21218 username (on a successful authentication) into \$1$\.
21219
21220 .startconf cyrus@_sasl
21221 .conf server@_hostname string$**$ $tt{$primary@_hostname}
21222 This option selects the hostname that is used when communicating with
21223 the library. It is up to the underlying SASL plug-in what it does with
21224 this data.
21225
21226 .conf server@_mech string $tt{public@_name}
21227 This option selects the authentication mechanism this driver should
21228 use. It allows you to use a different underlying mechanism from the
21229 advertised name. For example:
21230 .display asis
21231 sasl:
21232   driver = cyrus_sasl
21233   public_name = X-ANYTHING
21234   server_mech = CRAM-MD5
21235   server_set_id = $1
21236 .endd
21237
21238 .conf server@_realm  string  unset
21239 This specifies the SASL realm that the server claims to be in.
21240
21241 .conf server@_service string $tt{smtp}
21242 This is the SASL service that the server claims to implement.
21243
21244 .endconf
21245
21246 For straightforward cases, you do not need to set any of the authenticator's
21247 private options. All you need to do is to specify an appropriate mechanism as
21248 the public name. Thus, if you have a SASL library that supports CRAM-MD5 and
21249 PLAIN, you could have two authenticators as follows:
21250 .display asis
21251 sasl_cram_md5:
21252   driver = cyrus_sasl
21253   public_name = CRAM-MD5
21254   server_set_id = $1
21255
21256 sasl_plain:
21257   driver = cyrus_sasl
21258   public_name = PLAIN
21259   server_set_id = $1
21260 .endd
21261
21262 Cyrus SASL does implement the LOGIN authentication method, even though it is 
21263 not a standard method. It is disabled by default in the source distribution,
21264 but it is present in many binary distributions.
21265
21266 .nem
21267
21268
21269
21270 .
21271 .
21272 .
21273 .
21274 . ============================================================================
21275 .chapter The spa authenticator
21276 .set runningfoot "spa authenticator"
21277 .index \%spa%\ authenticator
21278 .index authenticators||\%spa%\
21279 .index authentication||Microsoft Secure Password
21280 .index authentication||NTLM
21281 .index Microsoft Secure Password Authentication
21282 .index NTLM authentication
21283 The \%spa%\ authenticator provides client support for Microsoft's \*Secure
21284 Password Authentication*\ mechanism,
21285 which is also sometimes known as NTLM (NT LanMan). The code for client side of
21286 this authenticator was contributed by Marc Prud'hommeaux, and much of it is
21287 taken from the Samba project (\?http://www.samba.org?\). The code for the
21288 server side was subsequently contributed by Tom Kistner.
21289
21290 The mechanism works as follows:
21291 .numberpars $.
21292 After the \\AUTH\\ command has been accepted, the client sends an SPA
21293 authentication request based on the user name and optional domain.
21294 .nextp
21295 The server sends back a challenge.
21296 .nextp
21297 The client builds a challenge response which makes use of the user's password
21298 and sends it to the server, which then accepts or rejects it.
21299 .endp
21300 Encryption is used to protect the password in transit.
21301
21302
21303 .section Using spa as a server
21304 The \%spa%\ authenticator has just one server option:
21305
21306 .startconf spa
21307 .index options||\%spa%\ authenticator (server)
21308
21309 .conf server@_password string$**$ unset
21310 .index numerical variables (\$1$\, \$2$\, etc)||in \%spa%\ authenticator
21311 This option is expanded, and the result must be the cleartext password for the
21312 authenticating user, whose name is at this point in \$1$\. For example:
21313 .display asis
21314 spa:
21315   driver = spa
21316   public_name = NTLM
21317   server_password = ${lookup{$1}lsearch{/etc/exim/spa_clearpass}}
21318 .endd
21319 If the expansion is forced to fail, authentication fails. Any other expansion
21320 failure causes a temporary error code to be returned.
21321
21322 .endconf
21323
21324
21325
21326 .section Using spa as a client
21327 The \%spa%\ authenticator has the following client options:
21328
21329 .startconf spa
21330 .index options||\%spa%\ authenticator (client)
21331
21332 .conf client@_domain string$**$ unset
21333 This option specifies an optional domain for the authentication.
21334
21335 .conf client@_password string$**$ unset
21336 This option specifies the user's password, and must be set.
21337
21338 .conf client@_username string$**$ unset
21339 This option specifies the user name, and must be set.
21340
21341 .endconf
21342
21343 Here is an example of a configuration of this authenticator for use with the
21344 mail servers at \*msn.com*\:
21345 .display asis
21346 msn:
21347   driver = spa
21348   public_name = MSN
21349   client_username = msn/msn_username
21350   client_password = msn_plaintext_password
21351   client_domain = DOMAIN_OR_UNSET
21352 .endd
21353
21354
21355
21356
21357
21358
21359 .
21360 .
21361 .
21362 .
21363 . ============================================================================
21364 .chapter Encrypted SMTP connections using TLS/SSL
21365 .set runningfoot "TLS encryption"
21366 .rset CHAPTLS "~~chapter"
21367 .index encryption||on SMTP connection
21368 .index SMTP||encryption
21369 .index TLS||on SMTP connection
21370 .index OpenSSL
21371 .index GnuTLS
21372 Support for TLS (Transport Layer Security), formerly known as SSL (Secure
21373 Sockets Layer), is implemented by making use of the OpenSSL library or the
21374 GnuTLS library (Exim requires GnuTLS release 1.0 or later). There is no
21375 cryptographic code in the Exim distribution itself for implementing TLS. In
21376 order to use this feature you must install OpenSSL or GnuTLS, and then build a
21377 version of Exim that includes TLS support (see section ~~SECTinctlsssl). You
21378 also need to understand the basic concepts of encryption at a managerial level,
21379 and in particular, the way that public keys, private keys, and certificates are
21380 used.
21381
21382 RFC 2487 defines how SMTP connections can make use of encryption. Once a
21383 connection is established, the client issues a \\STARTTLS\\ command. If the
21384 server accepts this, the client and the server negotiate an encryption
21385 mechanism. If the negotiation succeeds, the data that subsequently passes
21386 between them is encrypted.
21387
21388 Exim's ACLs can detect whether the current SMTP session is encrypted or not,
21389 and if so, what cipher suite is in use, whether the client supplied a
21390 certificate, and whether or not that certificate was verified. This makes it
21391 possible for an Exim server to deny or accept certain commands based on the
21392 encryption state.
21393
21394 \**Warning**\: certain types of firewall and certain anti-virus products can
21395 disrupt TLS connections. You need to turn off SMTP scanning for these products
21396 in order to get TLS to work.
21397
21398
21399 .em
21400 .section Support for the legacy `ssmtp' protocol
21401 .index ssmtp protocol
21402 .index SMTP||ssmtp protocol
21403 Early implementations of encrypted SMTP used a different TCP port from normal
21404 SMTP, and expected an encryption negotiation to start immediately, instead of 
21405 waiting for a \\STARTTLS\\ command from the client using the standard SMTP 
21406 port. The protocol was called `ssmtp' and port 465 was allocated for this
21407 purpose. 
21408
21409 This approach was abandoned when encrypted SMTP was standardised, but there are
21410 still some legacy clients that use it. Exim supports these clients by means of
21411 the \tls@_on@_connect@_ports\ global option. Its value must be a list of port
21412 numbers; the most common use is expected to be:
21413 .display asis
21414 tls_on_connect_ports = 465
21415 .endd
21416 The port numbers specified by this option apply to all SMTP connections, both
21417 via the daemon and via \*inetd*\. You still need to specify all the ports that
21418 the daemon uses (by setting \daemon@_smtp@_ports\ or \local@_interfaces\ or the
21419 \-oX-\ command line option) because \tls@_on@_connect@_ports\ does not add an
21420 extra port -- rather, it specifies different behaviour on a port that is
21421 defined elsewhere.
21422
21423 There is also a \-tls-on-connect-\ command line option. This overrides
21424 \tls@_on@_connect@_ports\; it forces the legacy behaviour for all ports.
21425 .nem
21426
21427
21428
21429
21430 .section OpenSSL vs GnuTLS
21431 .index TLS||OpenSSL \*vs*\ GnuTLS
21432 .rset SECTopenvsgnu "~~chapter.~~section"
21433 The first TLS support in Exim was implemented using OpenSSL. Support for GnuTLS
21434 followed later, when the first versions of GnuTLS were released. To build Exim
21435 to use GnuTLS, you need to set
21436 .display asis
21437 USE_GNUTLS=yes
21438 .endd
21439 in Local/Makefile, in addition to
21440 .display asis
21441 SUPPORT_TLS=yes
21442 .endd
21443 You must also set \\TLS@_LIBS\\ and \\TLS@_INCLUDE\\ appropriately, so that the
21444 include files and libraries for GnuTLS can be found.
21445
21446 There are some differences in usage when using GnuTLS instead of OpenSSL:
21447 .numberpars $.
21448 The \tls@_verify@_certificates\ option must contain the name of a file, not the
21449 name of a directory (for OpenSSL it can be either).
21450 .nextp
21451 The \tls@_dhparam\ option is ignored, because early versions of GnuTLS had no
21452 facility for varying its Diffie-Hellman parameters. I understand that this has
21453 changed, but Exim has not been updated to provide this facility.
21454 .nextp
21455 GnuTLS uses RSA and D-H parameters that take a substantial amount of
21456 time to compute. It is unreasonable to re-compute them for every TLS
21457 session. Therefore, Exim keeps this data in a file in its spool
21458 directory, called \(gnutls-params)\. The file is owned by the Exim user and is
21459 readable only by its owner. Every Exim process that start up GnuTLS reads the
21460 RSA and D-H parameters from this file. If the file does not exist, the first
21461 Exim process that needs it computes the data and writes it to a temporary file
21462 which is renamed once it is complete. It does not matter if several Exim
21463 processes do this simultaneously (apart from wasting a few resources). Once a
21464 file is in place, new Exim processes immediately start using it.
21465
21466 For maximum security, the parameters that are stored in this file should be
21467 recalculated periodically, the frequency depending on your paranoia level.
21468 Arranging this is easy; just delete the file when you want new values to be
21469 computed.
21470 .nextp
21471 Distinguished Name (DN) strings reported by the OpenSSL library use a slash for
21472 separating fields; GnuTLS uses commas, in accordance with RFC 2253. This
21473 affects the value of the \$tls@_peerdn$\ variable.
21474 .nextp
21475 OpenSSL identifies cipher suites using hyphens as separators, for example:
21476 DES-CBC3-SHA. GnuTLS uses underscores, for example: RSA@_ARCFOUR@_SHA. What is
21477 more, OpenSSL complains if underscores are present in a cipher list. To make
21478 life simpler, Exim changes underscores to hyhens for OpenSSL and hyphens to
21479 underscores for GnuTLS when processing lists of cipher suites in the
21480 \tls@_require@_ciphers\ options (the global option and the \%smtp%\ transport
21481 option).
21482 .nextp
21483 The \tls@_require@_ciphers\ options operate differently, as described in the
21484 following sections.
21485 .endp
21486
21487 .section Requiring specific ciphers in OpenSSL
21488 .rset SECTreqciphssl "~~chapter.~~section"
21489 .index TLS||requiring specific ciphers (OpenSSL)
21490 .index \tls@_require@_ciphers\||OpenSSL
21491 There is a function in the OpenSSL library that can be passed a list of cipher
21492 suites before the cipher negotiation takes place. This specifies which ciphers
21493 are acceptable. The list is colon separated and may contain names like
21494 DES-CBC3-SHA. Exim passes the expanded value of \tls@_require@_ciphers\
21495 directly to this function call. The following quotation from the OpenSSL
21496 documentation specifies what forms of item are allowed in the cipher string:
21497 .numberpars $.
21498 It can consist of a single cipher suite such as RC4-SHA.
21499 .nextp
21500 It can represent a list of cipher suites containing a certain algorithm,
21501 or cipher suites of a certain type. For example SHA1 represents all
21502 ciphers suites using the digest algorithm SHA1 and SSLv3 represents all
21503 SSL v3 algorithms.
21504 .nextp
21505 Lists of cipher suites can be combined in a single cipher string using
21506 the + character. This is used as a logical and operation. For example
21507 SHA1+DES represents all cipher suites containing the SHA1 and the DES
21508 algorithms.
21509 .nextp
21510 Each cipher string can be optionally preceded by the characters \"!"\, \"-"\ or
21511 \"+"\.
21512 .numberpars " "
21513 If \"!"\ is used then the ciphers are permanently deleted from the list. The
21514 ciphers deleted can never reappear in the list even if they are explicitly
21515 stated.
21516 .nextp
21517 If \"-"\ is used then the ciphers are deleted from the list, but some or all
21518 of the ciphers can be added again by later options.
21519 .nextp
21520 If \"+"\ is used then the ciphers are moved to the end of the list. This
21521 option doesn't add any new ciphers it just moves matching existing ones.
21522 .nextp
21523 If none of these characters is present then the string is just interpreted as a
21524 list of ciphers to be appended to the current preference list. If the list
21525 includes any ciphers already present they will be ignored: that is, they will
21526 not moved to the end of the list.
21527 .endp
21528 .endp
21529
21530
21531 .section Requiring specific ciphers in GnuTLS
21532 .rset SECTreqciphgnu "~~chapter.~~section"
21533 .index TLS||requiring specific ciphers (GnuTLS)
21534 .index \tls@_require@_ciphers\||GnuTLS
21535 The GnuTLS library does not have a combined function like OpenSSL. Instead,
21536 it allows the caller to specify separate lists of key-exchange methods,
21537 main cipher algorithms, and MAC algorithms. Unfortunately, these lists are
21538 numerical, and the library does not have a function for turning names into
21539 numbers. Consequently, the list of recognized names has to be built into
21540 the application.
21541
21542 At present, Exim permits only the list of main cipher algorithms to be
21543 changed. The \tls@_require@_ciphers\ option is in the same format as for
21544 OpenSSL. Exim searches each item for the name of available algorithm. For
21545 example, if the list contains RSA@_AES@_SHA then AES is recognized.
21546
21547 The cipher algorithms list starts out with a default set of algorithms. If
21548 the first item in \tls@_require@_ciphers\ does \*not*\ start with an
21549 exclamation mark, all the default items are deleted. Thus, only those specified
21550 can be used. If the first item in \tls@_require@_ciphers\ \*does*\ start with
21551 an exclamation mark, the defaults are left on the list.
21552
21553 Then, any item that starts with an exclamation mark causes the relevent
21554 algorithms to be removed from the list, and any item that does not start
21555 with an exclamation mark causes the relevant algorithms to be added to the
21556 list. Thus,
21557 .display asis
21558 tls_require_ciphers = !RSA_ARCFOUR_SHA
21559 .endd
21560 allows all the defaults except those that use ARCFOUR, whereas
21561 .display asis
21562 tls_require_ciphers = AES : 3DES
21563 .endd
21564 allows only cipher suites that use AES and 3DES. The currently recognized
21565 algorithms are: 
21566 .em
21567 AES@_256, AES@_128, AES (both of the preceding), 3DES, and ARCFOUR@_128.
21568 Unrecognized algorithms are ignored. In a server, the order of the list is 
21569 unimportant; the server will advertise the availability of all the relevant 
21570 cipher suites. However, in a client, the order of the list specifies a
21571 preference order for the algorithms. The first one in the client's list that is
21572 also advertised by the server is tried first. The default order is as listed
21573 above.
21574 .nem
21575
21576
21577 .section Configuring an Exim server to use TLS
21578 .index TLS||configuring an Exim server
21579 When Exim has been built with TLS support, it advertises the availability of
21580 the \\STARTTLS\\ command to client hosts that match \tls@_advertise@_hosts\,
21581 but not to any others. The default value of this option is unset, which means
21582 that \\STARTTLS\\ is not advertised at all. This default is chosen because you
21583 need to set some other options in order to make TLS avaliable, and also it is
21584 sensible for systems that want to use TLS only as a client.
21585
21586 If a client issues a \\STARTTLS\\ command and there is some configuration
21587 problem in the server, the command is rejected with a 454 error. If the client
21588 persists in trying to issue SMTP commands, all except \\QUIT\\ are rejected
21589 with the error
21590 .display asis
21591 554 Security failure
21592 .endd
21593 If a \\STARTTLS\\ command is issued within an existing TLS session, it is
21594 rejected with a 554 error code.
21595
21596 To enable TLS operations on a server, you must set \tls@_advertise@_hosts\ to
21597 match some hosts. You can, of course, set it to $*$ to match all hosts.
21598 However, this is not all you need to do. TLS sessions to a server won't work
21599 without some further configuration at the server end.
21600
21601 It is rumoured that all existing clients that support TLS/SSL use RSA
21602 encryption. To make this work you need to set, in the server,
21603 .display asis
21604 tls_certificate = /some/file/name
21605 tls_privatekey = /some/file/name
21606 .endd
21607 The first file contains the server's X509 certificate, and the second contains
21608 the private key that goes with it. These files need to be readable by the Exim
21609 user, and must always be given as full path names. They can be the same file if
21610 both the certificate and the key are contained within it. If \tls@_privatekey\
21611 is not set, this is assumed to be the case. The certificate file may also
21612 contain intermediate certificates that need to be sent to the client to enable
21613 it to authenticate the server's certificate.
21614
21615 If you do not understand about certificates and keys, please try to find a
21616 source of this background information, which is not Exim-specific. (There are a
21617 few comments below in section ~~SECTcerandall.)
21618
21619 \**Note**\: These options do not apply when Exim is operating as a client --
21620 they apply only in the case of a server. For a client, you must set the options
21621 of the same name in an \%smtp%\ transport.
21622
21623 With just these options, Exim will work as a server with clients such as
21624 Netscape. It does not require the client to have a certificate (but see below
21625 for how to insist on this). There is one other option that may be needed in
21626 other situations. If
21627 .display asis
21628 tls_dhparam = /some/file/name
21629 .endd
21630 is set, the SSL library is initialized for the use of Diffie-Hellman ciphers
21631 with the parameters contained in the file. This increases the set of cipher
21632 suites that the server supports. See the command
21633 .display asis
21634 openssl dhparam
21635 .endd
21636 for a way of generating this data.
21637 At present, \tls@_dhparam\ is used only when Exim is linked with OpenSSL. It is
21638 ignored if GnuTLS is being used.
21639
21640 The strings supplied for these three options are expanded every time a client
21641 host connects. It is therefore possible to use different certificates and keys
21642 for different hosts, if you so wish, by making use of the client's IP address
21643 in \$sender@_host@_address$\ to control the expansion. If a string expansion is
21644 forced to fail, Exim behaves as if the option is not set.
21645
21646 .index cipher||logging
21647 .index log||TLS cipher
21648 The variable \$tls@_cipher$\ is set to the cipher suite that was negotiated for
21649 an incoming TLS connection. It is included in the ::Received:: header of an
21650 incoming message (by default -- you can, of course, change this), and it is
21651 also included in the log line that records a message's arrival, keyed by `X=',
21652 unless the \tls@_cipher\ log selector is turned off.
21653 The \encrypted\ condition can be used to test for specific cipher suites in
21654 ACLs.
21655
21656 The ACLs that run for subsequent SMTP commands can check the name of the cipher
21657 suite and vary their actions accordingly. The cipher suite names are those used
21658 by OpenSSL. These may differ from the names used elsewhere. For example,
21659 OpenSSL uses the name DES-CBC3-SHA for the cipher suite which in other contexts
21660 is known as TLS@_RSA@_WITH@_3DES@_EDE@_CBC@_SHA. Check the OpenSSL
21661 documentation for more details.
21662
21663
21664 .section Requesting and verifying client certificates
21665 .index certificate||verification of client
21666 .index TLS||client certificate verification
21667 If you want an Exim server to request a certificate when negotiating a TLS
21668 session with a client, you must set either \tls@_verify@_hosts\ or
21669 \tls@_try@_verify@_hosts\. You can, of course, set either of them to $*$ to
21670 apply to all TLS connections. For any host that matches one of these options,
21671 Exim requests a certificate as part of the setup of the TLS session. The
21672 contents of the certificate are verified by comparing it with a list of
21673 expected certificates. These must be available in a file or,
21674 for OpenSSL only (not GnuTLS), a directory, identified by
21675 \tls@_verify@_certificates\.
21676
21677 A file can contain multiple certificates, concatenated end to end. If a
21678 directory is used
21679 (OpenSSL only),
21680 each certificate must be in a separate file, with a name (or a symbolic link)
21681 of the form <<hash>>.0, where <<hash>> is a hash value constructed from the
21682 certificate. You can compute the relevant hash by running the command
21683 .display asis
21684 openssl x509 -hash -noout -in /cert/file
21685 .endd
21686 where \(/cert/file)\ contains a single certificate.
21687
21688 The difference between \tls@_verify@_hosts\ and \tls@_try@_verify@_hosts\ is
21689 what happens if the client does not supply a certificate, or if the certificate
21690 does not match any of the certificates in the collection named by
21691 \tls@_verify@_certificates\. If the client matches \tls@_verify@_hosts\, the
21692 attempt to set up a TLS session is aborted, and the incoming connection is
21693 dropped. If the client matches \tls@_try@_verify@_hosts\, the (encrypted) SMTP
21694 session continues. ACLs that run for subsequent SMTP commands can detect the
21695 fact that no certificate was verified, and vary their actions accordingly. For
21696 example, you can insist on a certificate before accepting a message for
21697 relaying, but not when the message is destined for local delivery.
21698
21699 When a client supplies a certificate (whether it verifies or not), the value of
21700 the Distinguished Name of the certificate is made available in the variable
21701 \$tls@_peerdn$\ during subsequent processing of the message.
21702 .index log||distinguished name
21703 Because it is often a long text string, it is not included in the log line or
21704 ::Received:: header by default. You can arrange for it to be logged, keyed by
21705 `DN=', by setting the \tls@_peerdn\ log selector, and you can use
21706 \received@_header@_text\ to change the ::Received:: header. When no certificate
21707 is supplied, \$tls@_peerdn$\ is empty.
21708
21709 .section Revoked certificates
21710 .index TLS||revoked certificates
21711 .index revocation list
21712 .index certificate||revocation list
21713 Certificate issuing authorities issue Certificate Revocation Lists (CRLs) when
21714 certificates are revoked. If you have such a list, you can pass it to an Exim
21715 server using the global option called \tls@_crl\ and to an Exim client using an
21716 identically named option for the \%smtp%\ transport. In each case, the value of
21717 the option is expanded and must then be the name of a file that contains a CRL
21718 in PEM format.
21719
21720 .section Configuring an Exim client to use TLS
21721 .index cipher||logging
21722 .index log||TLS cipher
21723 .index log||distinguished name
21724 .index TLS||configuring an Exim client
21725 The \tls@_cipher\ and \tls@_peerdn\ log selectors apply to outgoing SMTP
21726 deliveries as well as to incoming, the latter one causing logging of the
21727 server certificate's DN. The remaining client configuration for TLS is all
21728 within the \%smtp%\ transport.
21729
21730 It is not necessary to set any options to have TLS work in the \%smtp%\
21731 transport. If Exim is built with TLS support, and TLS is advertised by a
21732 server, the \%smtp%\ transport always tries to start a TLS session. However,
21733 this can be prevented by setting \hosts@_avoid@_tls\ (an option of the
21734 transport) to a list of server hosts for which TLS should not be used.
21735
21736 If you do not want Exim to attempt to send messages unencrypted when an attempt
21737 to set up an encrypted connection fails in any way, you can set
21738 \hosts@_require@_tls\ to a list of hosts for which encryption is mandatory. For
21739 those hosts, delivery is always deferred if an encrypted connection cannot be
21740 set up. If there are any other hosts for the address, they are tried in the
21741 usual way.
21742
21743 When the server host is not in \hosts@_require@_tls\, Exim may try to deliver
21744 the message unencrypted. It always does this if the response to \\STARTTLS\\ is
21745 a 5\*xx*\ code. For a temporary error code, or for a failure to negotiate a TLS
21746 session after a success response code, what happens is controlled by the
21747 \tls@_tempfail@_tryclear\ option of the \%smtp%\ transport. If it is false,
21748 delivery to this host is deferred, and other hosts (if available) are tried. If
21749 it is true, Exim attempts to deliver unencrypted after a 4\*xx*\ response to
21750 \\STARTTLS\\, and if \\STARTTLS\\ is accepted, but the subsequent TLS
21751 negotiation fails, Exim closes the current connection (because it is in an
21752 unknown state), opens a new one to the same host, and then tries the delivery
21753 unencrypted.
21754
21755
21756 The \tls@_certificate\ and \tls@_privatekey\ options of the \%smtp%\ transport
21757 provide the client with a certificate, which is passed to the server if it
21758 requests it. If the server is Exim, it will request a certificate only if
21759 \tls@_verify@_hosts\ or \tls@_try@_verify@_hosts\ matches the client.
21760 \**Note**\: these options must be set in the \%smtp%\ transport for Exim to use
21761 TLS when it is operating as a client. Exim does not assume that a server
21762 certificate (set by the global options of the same name) should also be used
21763 when operating as a client.
21764
21765 If \tls@_verify@_certificates\ is set, it must name a file or,
21766 for OpenSSL only (not GnuTLS), a directory, that contains a collection of
21767 expected server certificates. The client verifies the server's certificate
21768 against this collection, taking into account any revoked certificates that are
21769 in the list defined by \tls@_crl\.
21770
21771 If
21772 \tls@_require@_ciphers\ is set on the \%smtp%\ transport, it must contain a
21773 list of permitted cipher suites. If either of these checks fails, delivery to
21774 the current host is abandoned, and the \%smtp%\ transport tries to deliver to
21775 alternative hosts, if any.
21776
21777 All the TLS options in the \%smtp%\ transport are expanded before use, with
21778 \$host$\ and \$host@_address$\ containing the name and address of the server to
21779 which the client is connected. Forced failure of an expansion causes Exim to
21780 behave as if the relevant option were unset.
21781
21782
21783 .section Multiple messages on the same encrypted TCP/IP connection
21784 .rset SECTmulmessam "~~chapter.~~section"
21785 .index multiple SMTP deliveries with TLS
21786 .index TLS||multiple message deliveries
21787 Exim sends multiple messages down the same TCP/IP connection by starting up
21788 an entirely new delivery process for each message, passing the socket from
21789 one process to the next. This implementation does not fit well with the use
21790 of TLS, because there is quite a lot of state information associated with a TLS
21791 connection, not just a socket identification. Passing all the state information
21792 to a new process is not feasible. Consequently, Exim shuts down an existing TLS
21793 session before passing the socket to a new process. The new process may then
21794 try to start a new TLS session, and if successful, may try to re-authenticate
21795 if \\AUTH\\ is in use, before sending the next message.
21796
21797 The RFC is not clear as to whether or not an SMTP session continues in clear
21798 after TLS has been shut down, or whether TLS may be restarted again later, as
21799 just described. However, if the server is Exim, this shutdown and
21800 reinitialization works. It is not known which (if any) other servers operate
21801 successfully if the client closes a TLS session and continues with unencrypted
21802 SMTP, but there are certainly some that do not work. For such servers, Exim
21803 should not pass the socket to another process, because the failure of the
21804 subsequent attempt to use it would cause Exim to record a temporary host error,
21805 and delay other deliveries to that host.
21806
21807 To test for this case, Exim sends an \\EHLO\\ command to the server after
21808 closing down the TLS session. If this fails in any way, the connection is
21809 closed instead of being passed to a new delivery process, but no retry
21810 information is recorded.
21811
21812 There is also a manual override; you can set \hosts@_nopass@_tls\ on the
21813 \%smtp%\ transport to match those hosts for which Exim should not pass
21814 connections to new processes if TLS has been used.
21815
21816
21817
21818 .section Certificates and all that
21819 .rset SECTcerandall "~~chapter.~~section"
21820 .index certificate||references to discussion
21821 In order to understand fully how TLS works, you need to know about
21822 certificates, certificate signing, and certificate authorities. This is not the
21823 place to give a tutorial, especially as I do not know very much about it
21824 myself. Some helpful introduction can be found in the FAQ for the SSL addition
21825 to Apache, currently at
21826 .display rm
21827 \?http://www.modssl.org/docs/2.7/ssl@_faq.html@#ToC24?\
21828 .endd
21829 Other parts of the \*modssl*\ documentation are also helpful, and have
21830 links to further files.
21831 Eric Rescorla's book, \*SSL and TLS*\, published by Addison-Wesley (ISBN
21832 0-201-61598-3), contains both introductory and more in-depth descriptions.
21833 Some sample programs taken from the book are available from
21834 .display rm
21835 \?http://www.rtfm.com/openssl-examples/?\
21836 .endd
21837
21838 .section Certificate chains
21839 The file named by \tls@_certificate\ may contain more than one
21840 certificate. This is useful in the case where the certificate that is being
21841 sent is validated by an intermediate certificate which the other end does
21842 not have. Multiple certificates must be in the correct order in the file.
21843 First the host's certificate itself, then the first intermediate
21844 certificate to validate the issuer of the host certificate, then the next
21845 intermediate certificate to validate the issuer of the first intermediate
21846 certificate, and so on, until finally (optionally) the root certificate.
21847 The root certificate must already be trusted by the recipient for
21848 validation to succeed, of course, but if it's not preinstalled, sending the
21849 root certificate along with the rest makes it available for the user to
21850 install if the receiving end is a client MUA that can interact with a user.
21851
21852 .section Self-signed certificates
21853 .index certificate||self-signed
21854 You can create a self-signed certificate using the \*req*\ command provided
21855 with OpenSSL, like this:
21856 .display asis
21857 openssl req -x509 -newkey rsa:1024 -keyout file1 -out file2 \
21858             -days 9999 -nodes
21859 .endd
21860 \(file1)\ and \(file2)\ can be the same file; the key and the certificate are
21861 delimited and so can be identified independently. The \-days-\ option
21862 specifies a period for which the certificate is valid. The \-nodes-\ option is
21863 important: if you do not set it, the key is encrypted with a passphrase
21864 that you are prompted for, and any use that is made of the key causes more
21865 prompting for the passphrase. This is not helpful if you are going to use
21866 this certificate and key in an MTA, where prompting is not possible.
21867
21868 A self-signed certificate made in this way is sufficient for testing, and
21869 may be adequate for all your requirements if you are mainly interested in
21870 encrypting transfers, and not in secure identification.
21871
21872 However, many clients require that the certificate presented by the server be a
21873 user (also called `leaf' or `site') certificate, and not a self-signed
21874 certificate. In this situation, the self-signed certificate described above
21875 must be installed on the client host as a trusted root \*certification
21876 authority*\ (CA), and the certificate used by Exim must be a user certificate
21877 signed with that self-signed certificate.
21878
21879 For information on creating self-signed CA certificates and using them to sign
21880 user certificates, see the \*General implementation overview*\ chapter of the
21881 Open-source PKI book, available online at \?http://ospkibook.sourceforge.net/?\.
21882
21883
21884
21885 .
21886 .
21887 .
21888 .
21889 . ============================================================================
21890 .chapter Access control lists
21891 .set runningfoot "ACL"
21892 .rset CHAPACL "~~chapter"
21893 .index ~~ACL||description
21894 .index control of incoming mail
21895 .index message||controlling incoming
21896 .index policy control||access control lists
21897 Access Control Lists (ACLs) are defined in a separate section of the run time
21898 configuration file, headed by `begin acl'. Each ACL definition starts with a
21899 name, terminated by a colon. Here is a complete ACL section that contains just
21900 one very small ACL:
21901 .display asis
21902 begin acl
21903
21904 small_acl:
21905   accept   hosts = one.host.only
21906 .endd
21907 You can have as many lists as you like in the ACL section, and the order in
21908 which they appear does not matter. The lists are self-terminating.
21909
21910 The majority of ACLs are used to control Exim's behaviour when it receives
21911 certain SMTP commands. This applies both to incoming TCP/IP connections, and
21912 when a local process submits a message using SMTP by specifying the \-bs-\
21913 option. The most common use is for controlling which recipients are accepted
21914 in incoming messages. In addition, you can define an ACL that is used to check
21915 local non-SMTP messages. The default configuration file contains an example of
21916 a realistic ACL for checking \\RCPT\\ commands. This is discussed in chapter
21917 ~~CHAPdefconfil.
21918
21919 .section Testing ACLs
21920 The \-bh-\ command line option provides a way of testing your ACL configuration
21921 locally by running a fake SMTP session with which you interact. The host
21922 \*relay-test.mail-abuse.org*\ provides a service for checking your relaying
21923 configuration (see section ~~SECTcheralcon for more details).
21924
21925
21926 .section Specifying when ACLs are used
21927 .index ~~ACL||options for specifying
21928 In order to cause an ACL to be used, you have to name it in one of the relevant
21929 options in the main part of the configuration. These options are:
21930 .index \\AUTH\\||ACL for
21931 .index \\DATA\\, ACLs for
21932 .index \\ETRN\\||ACL for
21933 .index \\EXPN\\||ACL for
21934 .index \\HELO\\||ACL for
21935 .index \\EHLO\\||ACL for
21936 .index \\MAIL\\||ACL for
21937 .index \\QUIT\\, ACL for
21938 .index \\RCPT\\||ACL for
21939 .index \\STARTTLS\\, ACL for
21940 .index \\VRFY\\||ACL for
21941 .index SMTP||connection, ACL for
21942 .index non-smtp message, ACL for
21943 .display
21944 .tabs 20
21945 .if !~~sys.fancy
21946 .tabs 24
21947 .fi
21948 \acl@_not@_smtp\      $t $rm{ACL for non-SMTP messages}
21949 \acl@_smtp@_auth\     $t $rm{ACL for \\AUTH\\}
21950 \acl@_smtp@_connect\  $t $rm{ACL for start of SMTP connection}
21951 \acl@_smtp@_data\     $t $rm{ACL after \\DATA\\ is complete}
21952 \acl@_smtp@_etrn\     $t $rm{ACL for \\ETRN\\}
21953 \acl@_smtp@_expn\     $t $rm{ACL for \\EXPN\\}
21954 \acl@_smtp@_helo\     $t $rm{ACL for \\HELO\\ or \\EHLO\\}
21955 \acl@_smtp@_mail\     $t $rm{ACL for \\MAIL\\}
21956 \acl@_smtp@_mailauth\ $t $rm{ACL for the \\AUTH\\ parameter of \\MAIL\\}
21957 .newline
21958 .em
21959 \acl@_smtp@_mime\     $t $rm{ACL for content-scanning MIME parts}
21960 \acl@_smtp@_predata\  $t $rm{ACL at start of \\DATA\\ command}
21961 \acl@_smtp@_quit\     $t $rm{ACL for \\QUIT\\}
21962 .nem
21963 .newline
21964 \acl@_smtp@_rcpt\     $t $rm{ACL for \\RCPT\\}
21965 \acl@_smtp@_starttls\ $t $rm{ACL for \\STARTTLS\\}
21966 \acl@_smtp@_vrfy\     $t $rm{ACL for \\VRFY\\}
21967 .endd
21968 For example, if you set
21969 .display asis
21970 acl_smtp_rcpt = small_acl
21971 .endd
21972 the little ACL defined above is used whenever Exim receives a \\RCPT\\ command
21973 in an SMTP dialogue. The majority of policy tests on incoming messages can be
21974 done when \\RCPT\\ commands arrive. A rejection of \\RCPT\\ should cause the
21975 sending MTA to give up on the recipient address contained in the \\RCPT\\
21976 command, whereas rejection at other times may cause the client MTA to keep on
21977 trying to deliver the message. It is therefore recommended that you do as much
21978 testing as possible at \\RCPT\\ time.
21979
21980 .section The non-SMTP ACL
21981 .index non-smtp message, ACL for
21982 The non-SMTP ACL applies to all non-interactive incoming messages, that is, it
21983 applies to batch SMTP as well as to non-SMTP messages. (Batch SMTP is not
21984 really SMTP.) This ACL is run just before the \*local@_scan()*\ function. Any
21985 kind of rejection is treated as permanent, because there is no way of sending a
21986 temporary error for these kinds of message. Many of the ACL conditions (for
21987 example, host tests, and tests on the state of the SMTP connection such as
21988 encryption and authentication) are not relevant and are forbidden in this ACL.
21989
21990 .section The connect ACL
21991 .index SMTP||connection, ACL for
21992 The ACL test specified by \acl@_smtp@_connect\ happens after the test specified
21993 by \host__reject__connection\ (which is now an anomaly) and any TCP Wrappers
21994 testing (if configured).
21995
21996 .em
21997 .section The DATA ACLs
21998 .index \\DATA\\, ACLs for
21999 Two ACLs are associated with the \\DATA\\ command, because it is two-stage 
22000 command, with two responses being sent to the client.
22001 When the \\DATA\\ command is received, the ACL defined by \acl@_smtp@_predata\
22002 is obeyed. This gives you control after all the \\RCPT\\ commands, but before
22003 the message itself is received. It offers the opportunity to give a negative
22004 response to the \\DATA\\ command before the data is transmitted. Header lines
22005 added by \\MAIL\\ or \\RCPT\\ ACLs are not visible at this time, but any that
22006 are defined here are visible when the \acl@_smtp@_data\ ACL is run.
22007
22008 You cannot test the contents of the message, for example, to verify addresses
22009 in the headers, at \\RCPT\\ time or when the \\DATA\\ command is received. Such
22010 tests have to appear in the ACL that is run after the message itself has been
22011 received, before the final response to the \\DATA\\ command is sent. This is
22012 the ACL specified by \acl@_smtp@_data\, which is the second ACL that is
22013 associated with the \\DATA\\ command.
22014
22015 For both of these ACLs, it is not possible to reject individual recipients. An
22016 error response rejects the entire message. Unfortunately, it is known that some
22017 MTAs do not treat hard (5$it{xx}) responses to the \\DATA\\ command (either 
22018 before or after the data) correctly -- they keep the message on their queues
22019 and try again later, but that is their problem, though it does waste some of
22020 your resources.
22021
22022 .section The MIME ACL
22023 The \acl@_smtp@_mime\ option is available only when Exim is compiled with the
22024 content-scanning extension. For details, see chapter ~~CHAPexiscan.
22025
22026 .section The QUIT ACL
22027 .rset SECTQUITACL "~~chapter.~~section"
22028 .index \\QUIT\\, ACL for
22029 The ACL for the SMTP \\QUIT\\ command is anomalous, in that the
22030 outcome of the ACL does not affect the response code to \\QUIT\\,
22031 which is always 221. Thus, the ACL does not in fact control any access.
22032 For this reason, the only verbs that are permitted are \accept\ and \warn\.
22033
22034 This ACL can be used for tasks such as custom logging at the end of an SMTP
22035 session. For example, you can use ACL variables in other ACLs to count
22036 messages, recipients, etc., and log the totals at \\QUIT\\ time using one or
22037 more \logwrite\ modifiers on a \warn\ verb.
22038
22039 You do not need to have a final \accept\, but if you do, you can use a
22040 \message\ modifier to specify custom text that is sent as part of the 221
22041 response to \\QUIT\\.
22042
22043 This ACL is run only for a `normal' \\QUIT\\. For certain kinds of disastrous
22044 failure (for example, failure to open a log file, or when Exim is bombing out
22045 because it has detected an unrecoverable error), all SMTP commands from the
22046 client are given temporary error responses until \\QUIT\\ is received or the
22047 connection is closed. In these special cases, the \\QUIT\\ ACL does not run.
22048 .nem
22049
22050 .section Finding an ACL to use
22051 .index ~~ACL||finding which to use
22052 The value of an \acl@_smtp@_$it{xxx}\ option is expanded before use, so you can
22053 use different ACLs in different circumstances. The resulting string does not
22054 have to be the name of an ACL in the configuration file; there are other
22055 possibilities. Having expanded the string, Exim searches for an ACL as follows:
22056 .numberpars $.
22057 If the string begins with a slash, Exim uses it as a file name, and reads its
22058 contents as an ACL. The lines are processed in the same way as lines in the
22059 Exim configuration file. In particular, continuation lines are supported, blank
22060 lines are ignored, as are lines whose first non-whitespace character is `@#'.
22061 If the file does not exist or cannot be read, an error occurs (typically
22062 causing a temporary failure of whatever caused the ACL to be run). For example:
22063 .display asis
22064 acl_smtp_data = /etc/acls/\
22065   ${lookup{$sender_host_address}lsearch\
22066   {/etc/acllist}{$value}{default}}
22067 .endd
22068 This looks up an ACL file to use on the basis of the host's IP address, falling
22069 back to a default if the lookup fails. If an ACL is successfully read from a
22070 file, it is retained in memory for the duration of the Exim process, so that it
22071 can be re-used without having to re-read the file.
22072 .nextp
22073 If the string does not start with a slash, and does not contain any spaces,
22074 Exim searches the ACL section of the configuration for an ACL whose name
22075 matches the string.
22076 .nextp
22077 If no named ACL is found, or if the string contains spaces, Exim parses
22078 the string as an inline ACL. This can save typing in cases where you just
22079 want to have something like
22080 .display asis
22081 acl_smtp_vrfy = accept
22082 .endd
22083 in order to allow free use of the \\VRFY\\ command. Such a string may contain
22084 newlines; it is processed in the same way as an ACL that is read from a file.
22085 .endp
22086
22087
22088 .section ACL return codes
22089 .index ~~ACL||return codes
22090 .em
22091 Except for the \\QUIT\\ ACL, which does not affect the SMTP return code (see
22092 section ~~SECTQUITACL above), the
22093 .nem
22094 result of running an ACL is either `accept' or `deny', or, if some test
22095 cannot be completed (for example, if a database is down), `defer'. These
22096 results cause 2$it{xx}, 5$it{xx}, and 4$it{xx} return codes, respectively, to
22097 be used in the SMTP dialogue. A fourth return, `error', occurs when there is an
22098 error such as invalid syntax in the ACL. This also causes a 4$it{xx} return
22099 code.
22100
22101 .em
22102 For the non-SMTP ACL, `defer' and `error' are treated in the same way as
22103 `deny', because there is no mechanism for passing temporary errors to the
22104 submitters of non-SMTP messages.
22105 .nem
22106
22107 ACLs that are relevant to message reception may also return `discard'. This
22108 has the effect of `accept', but causes either the entire message or an
22109 individual recipient address to be discarded. In other words, it is a
22110 blackholing facility. Use it with care.
22111
22112 If the ACL for \\MAIL\\ returns `discard', all recipients are discarded, and no
22113 ACL is run for subsequent \\RCPT\\ commands. The effect of `discard' in a
22114 \\RCPT\\ ACL is to discard just the one recipient address. If there are no
22115 recipients left when the message's data is received, the \\DATA\\ ACL is not
22116 run. A `discard' return from the \\DATA\\ or the non-SMTP ACL discards all the
22117 remaining recipients.
22118 .em
22119 The `discard' return is not permitted for the \acl@_smtp@_predata\ ACL.
22120 .nem
22121
22122 .index \*local@_scan()*\ function||when all recipients discarded
22123 The \*local@_scan()*\ function is always run, even if there are no remaining
22124 recipients; it may create new recipients.
22125
22126
22127 .section Unset ACL options
22128 .index ~~ACL||unset options
22129 The default actions when any of the \acl@_$it{xxx}\ options are unset are not
22130 all the same. \**Note**\: These defaults apply only when the relevant ACL is
22131 not defined at all. For any defined ACL, the default action when control reaches
22132 the end of the ACL statements is `deny'.
22133
22134 For \acl@_not@_smtp\, \acl@_smtp@_auth\, \acl@_smtp@_connect\,
22135 \acl@_smtp@_data\, \acl@_smtp@_helo\, \acl__smtp__mail\, \acl@_smtp@_mailauth\,
22136 .em
22137 \acl@_smtp@_mime\, \acl@_smtp@_predata\, \acl@_smtp@_quit\,
22138 .nem
22139 and \acl__smtp__starttls\, the action when the ACL is not defined is `accept'.
22140
22141 For the others (\acl@_smtp@_etrn\, \acl@_smtp@_expn\, \acl@_smtp@_rcpt\, and
22142 \acl@_smtp@_vrfy\), the action when the ACL is not defined is `deny'.
22143 This means that \acl@_smtp@_rcpt\ must be defined in order to receive any
22144 messages over an SMTP connection. For an example, see the ACL in the default
22145 configuration file.
22146
22147
22148
22149 .section Data for message ACLs
22150 .index ~~ACL||data for message ACL
22151 .em
22152 When a \\MAIL\\ or \\RCPT\\ ACL, or either of the \\DATA\\ ACLs, is running,
22153 the variables that contain information about the host and the message's sender
22154 (for example, \$sender@_host@_address$\ and \$sender@_address$\) are set, and
22155 can be used in ACL statements. In the case of \\RCPT\\ (but not \\MAIL\\ or
22156 \\DATA\\), \$domain$\ and \$local@_part$\ are set from the argument address.
22157
22158 When an ACL for the \\AUTH\\ parameter of \\MAIL\\ is running, the variables
22159 that contain information about the host are set, but \$sender@_address$\ is not
22160 yet set. Section ~~SECTauthparamail contains a discussion of this parameter and
22161 how it is used.
22162
22163 The \$message@_size$\ variable is set to the value of the \\SIZE\\ parameter on
22164 the \\MAIL\\ command at \\MAIL\\, \\RCPT\\ and pre-data time, or to -1 if
22165 that parameter is not given. The value is updated to the true message size by
22166 the time the final \\DATA\\ ACL is run (after the message data has been
22167 received).
22168
22169 The \$rcpt@_count$\ variable increases by one for each \\RCPT\\ command
22170 received. The \$recipients@_count$\ variable increases by one each time a
22171 \\RCPT\\ command is accepted, so while an ACL for \\RCPT\\ is being processed,
22172 it contains the number of previously accepted recipients. At \\DATA\\ time (for
22173 both the \\DATA\\ ACLs), \$rcpt@_count$\ contains the total number of \\RCPT\\
22174 commands, and \$recipients@_count$\ contains the total number of accepted
22175 recipients.
22176 .nem
22177
22178
22179
22180 .section Data for non-message ACLs
22181 .rset SECTdatfornon "~~chapter.~~section"
22182 .index ~~ACL||data for non-message ACL
22183 .em
22184 When an ACL is being run for \\AUTH\\, \\EHLO\\, \\ETRN\\, \\EXPN\\, \\HELO\\,
22185 .nem
22186 \\STARTTLS\\, or \\VRFY\\, the remainder of the SMTP command line is placed in
22187 \$smtp@_command@_argument$\. This can be tested using a \condition\ condition.
22188 For example, here is an ACL for use with \\AUTH\\, which insists that either
22189 the session is encrypted, or the CRAM-MD5 authentication method is used. In
22190 other words, it does not permit authentication methods that use cleartext
22191 passwords on unencrypted connections.
22192 .display asis
22193 acl_check_auth:
22194   accept encrypted = *
22195 .newline
22196 .em
22197   accept condition = ${if eq{${uc:$smtp_command_argument}}\
22198                      {CRAM-MD5}}
22199 .nem
22200 .newline
22201   deny   message   = TLS encryption or CRAM-MD5 required
22202 .endd
22203 (Another way of applying this restriction is to arrange for the authenticators
22204 that use cleartext passwords not to be advertised when the connection is not
22205 encrypted. You can use the generic \server@_advertise@_condition\ authenticator
22206 option to do this.)
22207
22208
22209 .section Format of an ACL
22210 .index ~~ACL||format of
22211 .index ~~ACL||verbs, definition of
22212 An individual ACL consists of a number of statements. Each statement starts
22213 with a verb, optionally followed by a number of conditions and `modifiers'.
22214 .em
22215 Modifiers can change the way the verb operates, define error and log messages,
22216 set variables, insert delays, and vary the processing of accepted messages.
22217 .nem
22218
22219 If all the conditions are met, the verb is obeyed. The same condition may be
22220 used (with different arguments) more than once in the same statement. This
22221 provides a means of specifying an `and' conjunction between conditions. For
22222 example:
22223 .display asis
22224 deny  dnslists = list1.example
22225       dnslists = list2.example
22226 .endd
22227 If there are no conditions, the verb is always obeyed.
22228 .em
22229 Exim stops evaluating the conditions and modifiers when it reaches a condition
22230 that fails. What happens then
22231 .nem
22232 depends on the verb (and in one case, on a special modifier). Not all the
22233 conditions make sense at every testing point. For example, you cannot test a
22234 sender address in the ACL that is run for a \\VRFY\\ command.
22235
22236 .section ACL verbs
22237 The ACL verbs are as follows:
22238 .numberpars $.
22239 .index \accept\, ACL verb
22240 \accept\: If all the conditions are met, the ACL returns `accept'. If any of
22241 the conditions are not met, what happens depends on whether \endpass\ appears
22242 among the conditions (for syntax see below). If the failing condition is before
22243 \endpass\, control is passed to the next ACL statement; if it is after
22244 \endpass\, the ACL returns `deny'. Consider this statement, used to check a
22245 \\RCPT\\ command:
22246 .display asis
22247 accept domains = +local_domains
22248        endpass
22249        verify = recipient
22250 .endd
22251 If the recipient domain does not match the \domains\ condition, control passes
22252 to the next statement. If it does match, the recipient is verified, and the
22253 command is accepted if verification succeeds. However, if verification fails,
22254 the ACL yields `deny', because the failing condition is after \endpass\.
22255 .nextp
22256 .index \defer\, ACL verb
22257 \defer\: If all the conditions are met, the ACL returns `defer' which, in an
22258 SMTP session, causes a 4\*xx*\ response to be given. For a non-SMTP ACL,
22259 \defer\ is the same as \deny\, because there is no way of sending a temporary
22260 error. For a \\RCPT\\ command, \defer\ is much the same as using a
22261 \%redirect%\ router and \":defer:"\ while verifying, but the \defer\ verb can
22262 be used in any ACL, and even for a recipient it might be a simpler approach.
22263 .nextp
22264 .index \deny\, ACL verb
22265 \deny\: If all the conditions are met, the ACL returns `deny'. If any of the
22266 conditions are not met, control is passed to the next ACL statement. For
22267 example,
22268 .display asis
22269 deny dnslists = blackholes.mail-abuse.org
22270 .endd
22271 rejects commands from hosts that are on a DNS black list.
22272 .nextp
22273 .index \discard\, ACL verb
22274 \discard\: This verb behaves like \accept\, except that it returns `discard'
22275 from the ACL instead of `accept'. It is permitted only on ACLs that are
22276 concerned with receiving messages, and it causes recipients to be discarded.
22277 If the \log@_message\ modifier is set when \discard\ operates, its contents are
22278 added to the line that is automatically written to the log.
22279
22280 If \discard\ is used in an ACL for \\RCPT\\, just the one recipient is
22281 discarded; if used for \\MAIL\\, \\DATA\\ or in the non-SMTP ACL, all the
22282 message's recipients are discarded. Recipients that are discarded before
22283 \\DATA\\ do not appear in the log line when the \log@_recipients\ log selector
22284 is set.
22285 .nextp
22286 .index \drop\, ACL verb
22287 \drop\: This verb behaves like \deny\, except that an SMTP connection is
22288 forcibly closed after the 5\*xx*\ error message has been sent. For example:
22289 .display asis
22290 drop   message   = I don't take more than 20 RCPTs
22291 .newline
22292 .em
22293        condition = ${if > {$rcpt_count}{20}}
22294 .nem
22295 .endd
22296 There is no difference between \deny\ and \drop\ for the connect-time ACL. The
22297 connection is always dropped after sending a 550 response.
22298 .nextp
22299 .index \require\, ACL verb
22300 \require\: If all the conditions are met, control is passed to the next ACL
22301 statement. If any of the conditions are not met, the ACL returns `deny'. For
22302 example, when checking a \\RCPT\\ command,
22303 .display asis
22304 require verify = sender
22305 .endd
22306 passes control to subsequent statements only if the message's sender can be
22307 verified. Otherwise, it rejects the command.
22308 .nextp
22309 .index \warn\, ACL verb
22310 \warn\: If all the conditions are met, a header line is added to an incoming
22311 message and/or a line is written to Exim's main log. In all cases, control
22312 passes to the next ACL statement. The text of the added header line and the log
22313 line are specified by modifiers; if they are not present, a \warn\ verb just
22314 checks its conditions and obeys any `immediate' modifiers such as \set\ and
22315 \logwrite\.
22316 .em
22317 There is more about adding header lines in section ~~SECTaddheadwarn.
22318 .nem
22319
22320 If any condition on a \warn\ statement cannot be completed (that is, there is
22321 some sort of defer), no header lines are added and the configured log line is
22322 not written. No further conditions or modifiers in the \warn\ statement are
22323 processed. The incident is logged, but the ACL continues to be processed, from
22324 the next statement onwards.
22325
22326 If a \message\ modifier is present on a \warn\ verb in an ACL that is not
22327 testing an incoming message, it is ignored, and the incident is logged.
22328
22329 A \warn\ statement may use the \log@_message\ modifier to cause a line to be
22330 written to the main log when the statement's conditions are true.
22331 If an identical log line is requested several times in the same message, only
22332 one copy is actually written to the log. If you want to force duplicates to be
22333 written, use the \logwrite\ modifier instead.
22334
22335 When one of the \warn\ conditions is an address verification that fails, the
22336 text of the verification failure message is in \$acl@_verify@_message$\. If you
22337 want this logged, you must set it up explicitly. For example:
22338 .display asis
22339 warn   !verify = sender
22340         log_message = sender verify failed: $acl_verify_message
22341 .endd
22342 .endp
22343
22344 At the end of each ACL there is an implicit unconditional \deny\.
22345
22346 As you can see from the examples above, the conditions and modifiers are
22347 written one to a line, with the first one on the same line as the verb, and
22348 subsequent ones on following lines. If you have a very long condition, you can
22349 continue it onto several physical lines by the usual backslash continuation
22350 mechanism. It is conventional to align the conditions vertically.
22351
22352
22353 .section ACL variables
22354 .rset SECTaclvariables "~~chapter.~~section"
22355 .index ~~ACL||variables
22356 There are some special variables that can be set during ACL processing. They
22357 can be used to pass information between different ACLs, different invocations
22358 of the same ACL in the same SMTP connection, and between ACLs and the routers,
22359 transports, and filters that are used to deliver a message. There are two sets
22360 of these variables:
22361 .numberpars $.
22362 The values of \$acl@_c0$\ to \$acl@_c9$\ persist throughout an SMTP connection.
22363 They are never reset. Thus, a value that is set while receiving one message is
22364 still available when receiving the next message on the same SMTP connection.
22365 .nextp
22366 The values of \$acl@_m0$\ to \$acl@_m9$\ persist only while a message is being
22367 received. They are reset afterwards. They are also reset by \\MAIL\\, \\RSET\\,
22368 \\EHLO\\, \\HELO\\, and after starting up a TLS session.
22369 .endp
22370 When a message is accepted, the current values of all the ACL variables are
22371 preserved with the message and are subsequently made available at delivery
22372 time. The ACL variables are set by modifier called \set\. For example:
22373 .display asis
22374 accept hosts = whatever
22375        set acl_m4 = some value
22376 .endd
22377 \**Note**\: a leading dollar sign is not used when naming a variable that is to
22378 be set. If you want to set a variable without taking any action, you can use a
22379 \warn\ verb without any other modifiers or conditions.
22380
22381
22382 .section Condition and modifier processing
22383 .index ~~ACL||conditions, processing
22384 .index ~~ACL||modifiers, processing
22385 An exclamation mark preceding a condition negates its result. For example,
22386 .display asis
22387 deny   domains = *.dom.example
22388       !verify = recipient
22389 .endd
22390 causes the ACL to return `deny' if the recipient domain ends in
22391 \*dom.example*\ and the recipient address cannot be verified.
22392
22393 The arguments of conditions and modifiers are expanded. A forced failure
22394 of an expansion causes a condition to be ignored, that is, it behaves as if the
22395 condition is true. Consider these two statements:
22396 .display asis
22397 accept  senders = ${lookup{$host_name}lsearch\
22398                   {/some/file}{$value}fail}
22399 accept  senders = ${lookup{$host_name}lsearch\
22400                   {/some/file}{$value}{}}
22401 .endd
22402 Each attempts to look up a list of acceptable senders. If the lookup succeeds,
22403 the returned list is searched, but if the lookup fails the behaviour is
22404 different in the two cases. The \fail\ in the first statement causes the
22405 condition to be ignored, leaving no further conditions. The \accept\ verb
22406 therefore succeeds. The second statement, however, generates an empty list when
22407 the lookup fails. No sender can match an empty list, so the condition fails,
22408 and therefore the \accept\ also fails.
22409
22410 ACL modifiers appear mixed in with conditions in ACL statements. Some of them
22411 specify actions that are taken as the conditions for a statement are checked;
22412 others specify text for messages that are used when access is denied or a
22413 warning is generated.
22414 .em
22415 The \control\ modifier affects the way an incoming message is handled.
22416 .nem
22417
22418 The positioning of the modifiers in an ACL statement important, because the
22419 processing of a verb ceases as soon as its outcome is known. Only those
22420 modifiers that have already been encountered will take effect. For example,
22421 consider this use of the \message\ modifier:
22422 .display asis
22423 require message = Can't verify sender
22424         verify = sender
22425         message = Can't verify recipient
22426         verify = recipient
22427         message = This message cannot be used
22428 .endd
22429 If sender verification fails, Exim knows that the result of the statement is
22430 `deny', so it goes no further. The first \message\ modifier has been seen, so
22431 its text is used as the error message. If sender verification succeeds, but
22432 recipient verification fails, the second message is used. If recipient
22433 verification succeeds, the third message becomes `current', but is never used
22434 because there are no more conditions to cause failure.
22435
22436 For the \deny\ verb, on the other hand, it is always the last \message\
22437 modifier that is used, because all the conditions must be true for rejection to
22438 happen. Specifying more than one \message\ modifier does not make sense, and
22439 the message can even be specified after all the conditions. For example:
22440 .display asis
22441 deny   hosts = ...
22442       !senders = *@my.domain.example
22443        message = Invalid sender from client host
22444 .endd
22445 The `deny' result does not happen until the end of the statement is reached, by
22446 which time Exim has set up the message.
22447
22448
22449 .section ACL modifiers
22450 .rset SECTACLmodi "~~chapter.~~section"
22451 .index ~~ACL||modifiers, list of
22452 The ACL modifiers are as follows:
22453
22454 .startitems
22455
22456 .item "control = <<text>>"
22457 .index \control\, ACL modifier
22458 .em
22459 This modifier affects the subsequent processing of the SMTP connection or of an
22460 incoming message that is accepted. The effect of the first type of control
22461 lasts for the duration of the connection, whereas the effect of the second type
22462 lasts only until the current message has been received. The message-specific
22463 controls always apply to the whole message, not to individual recipients,
22464 even if the \control\ modifier appears in a \\RCPT\\ ACL.
22465
22466 As there are now quite a few controls that can be applied, they are described
22467 separately in section ~~SECTcontrols.
22468 .nem
22469 The \control\ modifier can be used in several different ways. For example:
22470 .numberpars $.
22471 It can be at the end of an \accept\ statement:
22472 .display asis
22473 accept  ...some conditions
22474         control = queue_only
22475 .endd
22476 In this case, the control is applied when this statement yields `accept', in
22477 other words, when the conditions are all true.
22478 .nextp
22479 It can be in the middle of an \accept\ statement:
22480 .display asis
22481 accept  ...some conditions...
22482         control = queue_only
22483         ...some more conditions...
22484 .endd
22485 If the first set of conditions are true, the control is applied, even if the
22486 statement does not accept because one of the second set of conditions is false.
22487 In this case, some subsequent statement must yield `accept' for the control to
22488 be relevant.
22489 .nextp
22490 It can be used with \warn\ to apply the control, leaving the
22491 decision about accepting or denying to a subsequent verb. For
22492 example:
22493 .display asis
22494 warn    ...some conditions...
22495         control = freeze
22496 accept  ...
22497 .endd
22498 This example of \warn\ does not contain \message\, \log@_message\, or
22499 \logwrite\, so it does not add anything to the message and does not write a log
22500 entry.
22501 .nextp
22502 .em
22503 If you want to apply a control unconditionally, you can use it with a \require\ 
22504 verb. For example:
22505 .display asis
22506 require  control = no_multiline_response
22507 .nem
22508 .endd
22509 .endp
22510
22511 .item "delay = <<time>>"
22512 .index \delay\, ACL modifier
22513 .index \-bh-\ option
22514 This modifier causes Exim to wait for the time interval before proceeding. The
22515 time is given in the usual Exim notation. This modifier may appear in any ACL.
22516 The delay happens as soon as the modifier is processed. However, when testing
22517 Exim using the \-bh-\ option, the delay is not actually imposed (an appropriate
22518 message is output instead).
22519
22520 Like \control\, \delay\ can be used with \accept\ or
22521 \deny\, for example:
22522 .display asis
22523 deny    ...some conditions...
22524         delay = 30s
22525 .endd
22526 The delay happens if all the conditions are true, before the statement returns
22527 `deny'. Compare this with:
22528 .display asis
22529 deny    delay = 30s
22530         ...some conditions...
22531 .endd
22532 which waits for 30s before processing the conditions. The \delay\ modifier can
22533 also be used with \warn\ and together with \control\:
22534 .display
22535 warn    ...some conditions...
22536         delay = 2m
22537         control = freeze
22538 accept  ...
22539 .endd
22540
22541 .item endpass
22542 .index \endpass\, ACL modifier
22543 This modifier, which has no argument, is recognized only in \accept\
22544 statements. It marks the boundary between the conditions whose failure causes
22545 control to pass to the next statement, and the conditions whose failure causes
22546 the ACL to return `deny'. See the description of \accept\ above.
22547
22548 .item "log@_message = <<text>>"
22549 .index \log@_message\, ACL modifier
22550 This modifier sets up a message that is used as part of the log message if the
22551 ACL denies access or a \warn\ statement's conditions are true. For example:
22552 .display asis
22553 require log_message = wrong cipher suite $tls_cipher
22554         encrypted   = DES-CBC3-SHA
22555 .endd
22556 \log@_message\ adds to any underlying error message that may exist because of
22557 the condition failure. For example, while verifying a recipient address, a
22558 :::fail:: redirection might have already set up a message. Although the message
22559 is usually defined before the conditions to which it applies, the expansion
22560 does not happen until Exim decides that access is to be denied. This means that
22561 any variables that are set by the condition are available for inclusion in the
22562 message. For example, the \$dnslist@_<<xxx>>$\ variables are set after a DNS
22563 black list lookup succeeds. If the expansion of \log@_message\ fails, or if the
22564 result is an empty string, the modifier is ignored.
22565
22566 If you want to use a \warn\ statement to log the result of an address
22567 verification, you can use \$acl__verify__message$\ to include the verification
22568 error message.
22569
22570 If \log@_message\ is used with a \warn\ statement, `Warning:' is added to the
22571 start of the logged message. If the same warning log message is requested more
22572 than once while receiving  a single email message, only one copy is actually
22573 logged. If you want to log multiple copies, use \logwrite\ instead of
22574 \log@_message\. In the absence of \log@_message\ and \logwrite\, nothing is
22575 logged for a succesful \warn\ statement.
22576
22577 If \log@_message\ is not present and there is no underlying error message (for
22578 example, from the failure of address verification), but \message\ is present,
22579 the \message\ text is used for logging rejections. However, if any text for
22580 logging contains newlines, only the first line is logged. In the absence of
22581 both \log@_message\ and \message\, a default built-in message is used for
22582 logging rejections.
22583
22584 .item "logwrite = <<text>>"
22585 .index \logwrite\, ACL modifier
22586 .index log||in ACL, immediate
22587 This modifier writes a message to a log file as soon as it is encountered when
22588 processing an ACL. (Compare \log@_message\, which, except in the case of
22589 \warn\, is used only if the ACL statement denies access.) The \logwrite\
22590 modifier can be used to log special incidents in ACLs. For example:
22591 .display
22592 accept <<some special conditions>>
22593        control  = freeze
22594        logwrite = froze message because ...
22595 .endd
22596 By default, the message is written to the main log. However, it may begin
22597 with a colon, followed by a comma-separated list of log names, and then
22598 another colon, to specify exactly which logs are to be written. For
22599 example:
22600 .display asis
22601 logwrite = :main,reject: text for main and reject logs
22602 logwrite = :panic: text for panic log only
22603 .endd
22604
22605 .item "message = <<text>>"
22606 .index \message\, ACL modifier
22607 This modifier sets up a text string that is expanded and used as an error
22608 message if the current statement causes the ACL to deny access. The expansion
22609 happens at the time Exim decides that access is to be denied, not at the time
22610 it processes \message\. If the expansion fails, or generates an empty string,
22611 the modifier is ignored. For ACLs that are triggered by SMTP commands, the
22612 message is returned as part of the SMTP error response.
22613
22614 The \message\ modifier is also used with the \warn\ verb to specify one or more
22615 header lines to be added to an incoming message when all the conditions are
22616 true. See section ~~SECTaddheadwarn for more details. If \message\ is used with
22617 \warn\ in an ACL that is not concerned with receiving a message, it has no
22618 effect.
22619
22620 The text is literal; any quotes are taken as literals, but because the string
22621 is expanded, backslash escapes are processed anyway. If the message contains
22622 newlines, this gives rise to a multi-line SMTP response. Like \log@_message\,
22623 the contents of \message\ are not expanded until after a condition has failed.
22624
22625 If \message\ is used on a statement that verifies an address, the message
22626 specified overrides any message that is generated by the verification process.
22627 However, the original message is available in the variable
22628 \$acl@_verify@_message$\, so you can incorporate it into your message if you
22629 wish. In particular, if you want the text from \:fail:\ items in \%redirect%\
22630 routers to be passed back as part of the SMTP response, you should either not
22631 use a \message\ modifier, or make use of \$acl@_verify@_message$\.
22632
22633 .item "set <<acl@_name>> = <<value>>"
22634 .index \set\, ACL modifier
22635 This modifier puts a value into one of the ACL variables (see section
22636 ~~SECTaclvariables).
22637
22638 .enditems
22639
22640
22641 .em
22642 .section Use of the control modifier
22643 .rset SECTcontrols "~~chapter.~~section"
22644 .index \control\, ACL modifier
22645 The \control\ modifier supports the following settings:
22646
22647 .startitems
22648
22649 .item "control = caseful@_local@_part"
22650 .item "control = caselower@_local@_part"
22651 .index ~~ACL||case of local part in
22652 .index case of local parts
22653 These two controls are permitted only in the ACL specified by \acl@_smtp@_rcpt\
22654 (that is, during \\RCPT\\ processing). By default, the contents of
22655 \$local@_part$\ are lower cased before ACL processing. If
22656 `caseful@_local@_part' is specified, any uppercase letters in the original
22657 local part are restored in \$local@_part$\ for the rest of the ACL, or until a
22658 control that sets `caselower@_local@_part' is encountered. 
22659
22660 This control affects only the current recipient. Moreover, it applies only to
22661 local part handling that takes place directly in the ACL (for example, as a key
22662 in lookups). If a test to verify the recipient is obeyed, the case-related
22663 handling of the local part during the verification is controlled by the router
22664 configuration (see the \caseful@_local@_part\ generic router option).
22665
22666 This facility could be used, for example, to add a spam score to local parts
22667 containing upper case letters. For example, using \$acl@_m4$\ to accumulate the
22668 spam score:
22669 .display asis
22670 warn  control = caseful_local_part
22671       set acl_m4 = ${eval:\
22672                      $acl_m4 + \
22673                      ${if match{$local_part}{[A-Z]}{1}{0}}\
22674                     }
22675       control = caselower_local_part
22676 .endd
22677 Notice that we put back the lower cased version afterwards, assuming that
22678 is what is wanted for subsequent tests.
22679
22680 .item "control = enforce@_sync"
22681 .item "control = no@_enforce@_sync"
22682 .index SMTP||synchronization checking
22683 .index synchronization checking in SMTP
22684 These controls make it possible to be selective about when SMTP synchronization
22685 is enforced. The global option \smtp@_enforce@_sync\ specifies the initial
22686 state of the switch (it is true by default). See the description of this option
22687 in chapter ~~CHAPmainconfig for details of SMTP synchronization checking.
22688
22689 The effect of these two controls lasts for the remainder of the SMTP
22690 connection. They can appear in any ACL except the one for the non-SMTP
22691 messages. The most straightforward place to put them is in the ACL defined by
22692 \acl@_smtp@_connect\, which is run at the start of an incoming SMTP connection,
22693 before the first synchronization check. The expected use is to turn off the
22694 synchronization checks for badly-behaved hosts that you nevertheless need to
22695 work with.
22696
22697 .item "control = fakereject/<<message>>"
22698 .index fake rejection
22699 .index rejection, fake
22700 This control is permitted only for the \\MAIL\\, \\RCPT\\, and \\DATA\\ ACLs,
22701 in other words, only when an SMTP message is being received. If Exim accepts
22702 the message, instead the final 250 response, a 550 rejection message is sent.
22703 However, Exim proceeds to deliver the message as normal. The control applies 
22704 only to the current message, not to any subsequent ones that may be received in 
22705 the same SMTP connection.
22706
22707 The text for the 550 response is taken from the \control\ modifier. If no
22708 message is supplied, the following is used:
22709 .display asis
22710 550-Your message has been rejected but is being 
22711 550-kept for evaluation.
22712 550-If it was a legitimate message, it may still be 
22713 550 delivered to the target recipient(s).
22714 .endd
22715 This facilty should be used with extreme caution.
22716
22717
22718 .item "control = freeze"
22719 .index frozen messages||forcing in ACL
22720 This control is permitted only for the \\MAIL\\, \\RCPT\\, \\DATA\\, and
22721 non-SMTP ACLs, in other words, only when a message is being received. If the
22722 message is accepted, it is placed on Exim's queue and frozen. The control
22723 applies only to the current message, not to any subsequent ones that may be
22724 received in the same SMTP connection.
22725
22726
22727 .item "control = no@_mbox@_unspool"
22728 This control is available when Exim is compiled with the content scanning 
22729 extension. Content scanning may require a copy of the current message, or parts 
22730 of it, to be written in `mbox format' to a spool file, for passing to a virus
22731 or spam scanner. Normally, such copies are deleted when they are no longer 
22732 needed. If this control is set, the copies are not deleted. The control
22733 applies only to the current message, not to any subsequent ones that may be
22734 received in the same SMTP connection. It is provided for debugging purposes and 
22735 is unlikely to be useful in production.
22736
22737
22738 .item "control = no@_multiline@_response"
22739 .index multiline responses, suppressing
22740 This control is permitted for any ACL except the one for non-SMTP messages.
22741 It seems that there are broken clients in use that cannot handle multiline
22742 SMTP responses, despite the fact that RFC 821 defined them over 20 years ago.
22743
22744 If this control is set, multiline SMTP responses from ACL rejections are
22745 suppressed. One way of doing this would have been to put out these responses as
22746 one long line. However, RFC 2821 specifies a maximum of 512 bytes per response
22747 (`use multiline responses for more' it says -- ha!), and some of the responses
22748 might get close to that. So this facility, which is after all only a sop to
22749 broken clients, is implemented by doing two very easy things:
22750 .numberpars
22751 Extra information that is normally output as part of a rejection caused by
22752 sender verification failure is omitted. Only the final line (typically `sender
22753 verification failed') is sent.
22754 .nextp
22755 If a \message\ modifier supplies a multiline response, only the first
22756 line is output.
22757 .endp
22758 The setting of the switch can, of course, be made conditional on the
22759 calling host. Its effect lasts until the end of the SMTP connection.
22760
22761
22762 .item "control = queue@_only"
22763 .index \queue@_only\
22764 .index queueing incoming messages
22765 This control is permitted only for the \\MAIL\\, \\RCPT\\, \\DATA\\, and
22766 non-SMTP ACLs, in other words, only when a message is being received. If the
22767 message is accepted, it is placed on Exim's queue and left there for delivery
22768 by a subsequent queue runner. No immediate delivery process is started. In
22769 other words, it has the effect as the \queue@_only\ global option. However, the
22770 control applies only to the current message, not to any subsequent ones that
22771 may be received in the same SMTP connection.
22772
22773
22774 .item "control = submission/<<options>>"
22775 .index message||submission
22776 .index submission mode
22777 This control is permitted only for the \\MAIL\\, \\RCPT\\, and start of data
22778 ACLs (the latter is the one defined by \acl@_smtp@_predata\). Setting it tells
22779 Exim that the current message is a submission from a local MUA. In this case,
22780 Exim operates in `submission mode', and applies certain fixups to the message
22781 if necessary. For example, it add a ::Date:: header line if one is not present.
22782 This control is not permitted in the \acl@_smtp@_data\ ACL, because that is too
22783 late (the message has already been created). 
22784
22785 Chapter ~~CHAPmsgproc describes the processing that Exim applies to messages.
22786 Section ~~SECTsubmodnon covers the processing that happens in submission mode;
22787 the available options for this control are described there. The control applies
22788 only to the current message, not to any subsequent ones that may be received in
22789 the same SMTP connection.
22790
22791 .enditems
22792 .nem
22793
22794
22795 .em
22796 .section Adding header lines with the warn verb
22797 .rset SECTaddheadwarn "~~chapter.~~section"
22798 .index header lines||adding in an ACL
22799 .index header lines||position of added lines
22800 .index \warn\, ACL verb
22801 .index \message\, ACL modifier
22802 The \message\ modifier can be used on a \warn\ statement to add an extra header
22803 line to an incoming message, as in this example:
22804 .display asis
22805 warn message = X-blacklisted-at: $dnslist_domain
22806      dnslists = sbl.spamhaus.org : \
22807                 dialup.mail-abuse.org
22808 .endd
22809 If an identical header line is requested several times (provoked, for example,
22810 by multiple \\RCPT\\ commands), only one copy is actually added to the message.
22811 If the text of the \message\ modifier contains one or more newlines that are
22812 not followed by a space or a tab, it is assumed to contain multiple header
22813 lines. Each one is checked for valid syntax; \"X-ACL-Warn:"\ is added to the
22814 front of any line that is not a valid header line.
22815
22816 By default, new lines are added at the end of the existing header lines.
22817 However, you can specify that any particular header line should be added right
22818 at the start (before all the ::Received:: lines), immediately after the first
22819 block of ::Received:: lines, or immediately before any line that is not a
22820 ::Received:: or ::Resent-something:: header.
22821
22822 This is done by specifying `:at@_start:', `:after@_received:', or
22823 `:at@_start@_rfc:' (or, for completeness, `:at@_end:') before the text of the
22824 header line, respectively. (Header text cannot start with a colon, as there has
22825 to be a header name first.) For example:
22826 .display asis
22827 warn message = :after_received:X-My-Header: something or other...
22828 .endd
22829
22830 If more than one header is supplied in a single warn statement, each one is
22831 treated independently and can therefore be placed differently. If you add
22832 more than one line at the start, or after the Received: block, they will
22833 end up in reverse order.
22834
22835 \**Warning**\: This facility currently applies only to header lines that are
22836 added in an ACL. It does NOT work for header lines that are added in a
22837 system filter or in a router or transport.
22838
22839 .index header lines||added, visibility of
22840 Header lines that are added by an ACL at \\MAIL\\ or \\RCPT\\ time are not
22841 visible in string expansions in ACLs for subsequent \\RCPT\\ commands or in the
22842 \acl@_smtp@_predata\ ACL. However, they are visible in string expansions in the
22843 ACL that is run after \\DATA\\ is complete (the \acl@_smtp@_data\ ACL). This is
22844 also true for header lines that are added in the \acl@_smtp@_predata\ ACL.
22845 If a message is rejected after \\DATA\\, all added header lines are included in
22846 the entry that is written to the reject log.
22847
22848 If you want to preserve data between \\MAIL\\, \\RCPT\\, and the
22849 \acl@_smtp@_predata\ ACLs, you can use ACL variables, as described in section
22850 ~~SECTaclvariables.
22851 .nem
22852
22853
22854
22855 .section ACL conditions
22856 .rset SECTaclconditions "~~chapter.~~section"
22857 .index ~~ACL||conditions, list of
22858 .em
22859 Some of conditions listed in this section are available only when Exim is
22860 compiled with the content-scanning extension. They are included here briefly
22861 for completeness. More detailed descriptions can be found in the discussion on
22862 content scanning in chapter ~~CHAPexiscan.
22863 .nem
22864
22865 Not all conditions are relevant in all circumstances. For example, testing
22866 senders and recipients does not make sense in an ACL that is being run as the
22867 result of the arrival of an \\ETRN\\ command, and checks on message headers can
22868 be done only in the ACLs specified by \acl@_smtp@_data\ and \acl__not__smtp\.
22869 You can use the same condition (with different parameters) more than once in
22870 the same ACL statement. This provides a way of specifying an `and' conjunction.
22871 The conditions are as follows:
22872
22873 .startitems
22874
22875 .item "acl = <<name of acl or ACL string or file name >>"
22876 .index ~~ACL||nested
22877 .index ~~ACL||indirect
22878 .index \acl\, ACL condition
22879 The possible values of the argument are the same as for the
22880 \acl@_smtp@_$it{xxx}\ options. The named or inline ACL is run. If it returns
22881 `accept' the condition is true; if it returns `deny' the condition is false. If
22882 it returns `defer', the current ACL returns `defer'
22883 .em
22884 unless the condition is on a \warn\ verb. In that case, a `defer' return makes
22885 the condition false. This means that further processing of the \warn\ verb
22886 ceases, but processing of the ACL continues.
22887 .nem
22888
22889 If the nested \acl\ returns `drop' and the outer condition denies access,
22890 the connection is dropped. If it returns `discard', the verb must be \accept\
22891 or \discard\, and the action is taken immediately -- no further conditions are
22892 tested.
22893
22894 ACLs may be nested up to 20 deep; the limit exists purely to catch runaway
22895 loops. This condition allows you to use different ACLs in different
22896 circumstances. For example, different ACLs can be used to handle \\RCPT\\
22897 commands for different local users or different local domains.
22898
22899 .item "authenticated = <<string list>>"
22900 .index \authenticated\, ACL condition
22901 .index authentication||ACL checking
22902 .index ~~ACL||testing for authentication
22903 If the SMTP connection is not authenticated, the condition is false. Otherwise,
22904 the name of the authenticator is tested against the list. To test for
22905 authentication by any authenticator, you can set
22906 .display asis
22907 authenticated = *
22908 .endd
22909
22910 .item "condition = <<string>>"
22911 .index \condition\, ACL condition
22912 .index customizing||ACL condition
22913 .index ~~ACL||customized test
22914 .index ~~ACL||testing, customized
22915 This feature allows you to make up custom conditions. If the result of
22916 expanding the string is an empty string, the number zero, or one of the strings
22917 `no' or `false', the condition is false. If the result is any non-zero number,
22918 or one of the strings `yes' or `true', the condition is true. For any other
22919 values, some error is assumed to have occured, and the ACL returns `defer'.
22920
22921
22922 .em
22923 .item "decode = <<location>>"
22924 .index \decode\, ACL condition
22925 This condition is available only when Exim is compiled with the
22926 content-scanning extension, and it is allowed only the the ACL defined by
22927 \acl@_smtp@_mime\. It causes the current MIME part to be decoded into a file.
22928 For details, see chapter ~~CHAPexiscan.
22929 .nem
22930
22931
22932 .item "dnslists = <<list of domain names and other data>>"
22933 .index \dnslists\, ACL condition
22934 .index DNS list||in ACL
22935 .index black list (DNS)
22936 .index ~~ACL||testing a DNS list
22937 This condition checks for entries in DNS black lists. These are also known as
22938 `RBL lists', after the original Realtime Blackhole List, but note that the use
22939 of the lists at \*mail-abuse.org*\ now carries a charge.
22940 There are too many different variants of this condition to describe briefly
22941 here. See sections ~~SECTmorednslists--~~SECTmorednslistslast for details.
22942
22943 .item "domains = <<domain list>>"
22944 .index \domains\, ACL condition
22945 .index domain||ACL checking
22946 .index ~~ACL||testing a recipient domain
22947 This condition is relevant only after a \\RCPT\\ command. It checks that the
22948 domain of the recipient address is in the domain list. If percent-hack
22949 processing is enabled, it is done before this test is done. If the check
22950 succeeds with a lookup, the result of the lookup is placed in \$domain@_data$\
22951 until the next \domains\ test.
22952
22953 .item "encrypted = <<string list>>"
22954 .index \encrypted\, ACL condition
22955 .index encryption||checking in an ACL
22956 .index ~~ACL||testing for encryption
22957 If the SMTP connection is not encrypted, the condition is false. Otherwise, the
22958 name of the cipher suite in use is tested against the list. To test for
22959 encryption without testing for any specific cipher suite(s), set
22960 .display asis
22961 encrypted = *
22962 .endd
22963
22964 .item "hosts = << host list>>"
22965 .index \hosts\, ACL condition
22966 .index host||ACL checking
22967 .index ~~ACL||testing the client host
22968 This condition tests that the calling host matches the host list. If you have
22969 name lookups or wildcarded host names and IP addresses in the same host list,
22970 you should normally put the IP addresses first. For example, you could have:
22971 .display asis
22972 accept hosts = 10.9.8.7 : dbm;/etc/friendly/hosts
22973 .endd
22974 The reason for this lies in the left-to-right way that Exim processes lists.
22975 It can test IP addresses without doing any DNS lookups, but when it reaches an
22976 item that requires a host name, it fails if it cannot find a host name to
22977 compare with the pattern. If the above list is given in the opposite order, the
22978 \accept\ statement fails for a host whose name cannot be found, even if its
22979 IP address is 10.9.8.7.
22980
22981 If you really do want to do the name check first, and still recognize the IP
22982 address even if the name lookup fails, you can rewrite the ACL like this:
22983 .display asis
22984 accept hosts = dbm;/etc/friendly/hosts
22985 accept hosts = 10.9.8.7
22986 .endd
22987 The default action on failing to find the host name is to assume that the host
22988 is not in the list, so the first \accept\ statement fails. The second statement
22989 can then check the IP address.
22990
22991 If a \hosts\ condition is satisfied by means of a lookup, the result
22992 of the lookup is made available in the \$host@_data$\ variable. This
22993 allows you, for example, to set up a statement like this:
22994 .display asis
22995 deny  hosts = net-lsearch;/some/file
22996       message = $host_data
22997 .endd
22998 which gives a custom error message for each denied host.
22999
23000 .item "local@_parts = <<local part list>>"
23001 .index \local@_parts\, ACL condition
23002 .index local part||ACL checking
23003 .index ~~ACL||testing a local part
23004 This condition is relevant only after a \\RCPT\\ command. It checks that the
23005 local part of the recipient address is in the list. If percent-hack processing
23006 is enabled, it is done before this test. If the check succeeds with a lookup,
23007 the result of the lookup is placed in \$local@_part@_data$\ until the next
23008 \local@_parts\ test.
23009
23010
23011 .em
23012 .item "malware = <<option>>"
23013 .index \malware\, ACL condition
23014 .index ~~ACL||virus scanning
23015 .index ~~ACL||scanning for viruses
23016 This condition is available only when Exim is compiled with the
23017 content-scanning extension. It causes the incoming message to be scanned for
23018 viruses. For details, see chapter ~~CHAPexiscan.
23019 .nem
23020
23021
23022 .em
23023 .item "mime@_regex = <<list of regular expressions>>"
23024 .index \mime@_regex\, ACL condition
23025 .index ~~ACL||testing by regex matching
23026 This condition is available only when Exim is compiled with the
23027 content-scanning extension, and it is allowed only the the ACL defined by
23028 \acl@_smtp@_mime\. It causes the current MIME part to be scanned for a match
23029 with any of the regular expressions. For details, see chapter ~~CHAPexiscan.
23030 .nem
23031
23032
23033 .item "recipients = <<address list>>"
23034 .index \recipients\, ACL condition
23035 .index recipient||ACL checking
23036 .index ~~ACL||testing a recipient
23037 This condition is relevant only after a \\RCPT\\ command. It checks the entire
23038 recipient address against a list of recipients.
23039
23040
23041 .em
23042 .item "regex = <<list of regular expressions>>"
23043 .index \regex\, ACL condition
23044 .index ~~ACL||testing by regex matching
23045 This condition is available only when Exim is compiled with the
23046 content-scanning extension. It causes the incoming message to be scanned
23047 for a match with any of the regular expressions. For details, see chapter
23048 ~~CHAPexiscan.
23049 .nem
23050
23051
23052 .item "sender@_domains = <<domain list>>"
23053 .index \sender@_domains\, ACL condition
23054 .index sender||ACL checking
23055 .index ~~ACL||testing a sender domain
23056 This condition tests the domain of the sender of the message against the given
23057 domain list.
23058 \**Note**\: the domain of the sender address is in
23059 \$sender@_address@_domain$\. It is \*not*\ put in \$domain$\ during the testing
23060 of this condition. This is an exception to the general rule for testing
23061 domain lists. It is done this way so that, if this condition is used in an
23062 ACL for a \\RCPT\\ command, the recipient's domain (which is in \$domain$\) can
23063 be used to influence the sender checking.
23064
23065 .item "senders = <<address list>>"
23066 .index \senders\, ACL condition
23067 .index sender||ACL checking
23068 .index ~~ACL||testing a sender
23069 This condition tests the sender of the message against the given list. To test
23070 for a bounce message, which has an empty sender, set
23071 .display asis
23072 senders = :
23073 .endd
23074
23075
23076 .em
23077 .item "spam = <<username>>"
23078 .index \spam\, ACL condition
23079 .index ~~ACL||scanning for spam
23080 This condition is available only when Exim is compiled with the
23081 content-scanning extension. It causes the incoming message to be scanned by
23082 SpamAssassin. For details, see chapter ~~CHAPexiscan.
23083 .nem
23084
23085
23086 .item "verify = certificate"
23087 .index \verify\, ACL condition
23088 .index TLS||client certificate verification
23089 .index certificate||verification of client
23090 .index ~~ACL||certificate verification
23091 .index ~~ACL||testing a TLS certificate
23092 This condition is true in an SMTP session if the session is encrypted, and a
23093 certificate was received from the client, and the certificate was verified. The
23094 server requests a certificate only if the client matches \tls@_verify@_hosts\
23095 or \tls@_try@_verify@_hosts\ (see chapter ~~CHAPTLS).
23096
23097 .item "verify = header@_sender/<<options>>"
23098 .index \verify\, ACL condition
23099 .index ~~ACL||verifying sender in the header
23100 .index header lines||verifying the sender in
23101 .index sender||verifying in header
23102 .index verifying||sender in header
23103 This condition is relevant only in an ACL that is run after a message has been
23104 received, that is, in an ACL specified by \acl@_smtp@_data\
23105 .em
23106 or \acl@_not@_smtp\. It checks that there is a verifiable address in at least
23107 one of the ::Sender::, ::Reply-To::, or ::From:: header lines. Such an address
23108 is loosely thought of as a `sender' address (hence the name of the test).
23109 However, an address that appears in one of these headers need not be an address
23110 that accepts bounce messages; only sender addresses in envelopes are required
23111 to accept bounces. Therefore, if you use the callout option on this check, you
23112 might want to arrange for a non-empty address in the \\MAIL\\ command.
23113 .nem
23114
23115 Details of address verification and the options are given later, starting at
23116 section ~~SECTaddressverification (callouts are described in section
23117 ~~SECTcallver). You can combine this condition with the \senders\ condition to
23118 restrict it to bounce messages only:
23119 .display asis
23120 deny    senders = :
23121         message = A valid sender header is required for bounces
23122        !verify  = header_sender
23123 .endd
23124
23125 .item "verify = header@_syntax"
23126 .index \verify\, ACL condition
23127 .index ~~ACL||verifying header syntax
23128 .index header lines||verifying syntax
23129 .index verifying||header syntax
23130 This condition is relevant only in an ACL that is run after a message has been
23131 received, that is, in an ACL specified by \acl@_smtp@_data\
23132 or \acl@_not@_smtp\.
23133 It checks the syntax of all header lines that can contain lists of addresses
23134 (::Sender::, ::From::, ::Reply-To::, ::To::, ::Cc::, and ::Bcc::).
23135 Unqualified addresses (local parts without domains) are permitted only in
23136 locally generated messages and from hosts that match
23137 \sender@_unqualified@_hosts\ or \recipient@_unqualified@_hosts\, as
23138 appropriate.
23139
23140 Note that this condition is a syntax check only. However, a common spamming
23141 ploy is to send syntactically invalid headers such as
23142 .display asis
23143 To: @
23144 .endd
23145 and this condition can be used to reject such messages.
23146
23147 .item "verify = helo"
23148 .index \verify\, ACL condition
23149 .index ~~ACL||verifying HELO/EHLO
23150 .index \\HELO\\||verifying
23151 .index \\EHLO\\||verifying
23152 .index verifying||\\EHLO\\
23153 .index verifying||\\HELO\\
23154 This condition is true if a \\HELO\\ or \\EHLO\\ command has been received from
23155 the client host, and its contents have been verified. Verification of these
23156 commands does not happen by default. See the description of the
23157 \helo@_verify@_hosts\ and \helo@_try@_verify@_hosts\ options for details of how
23158 to request it.
23159
23160 .item "verify = recipient/<<options>>"
23161 .index \verify\, ACL condition
23162 .index ~~ACL||verifying recipient
23163 .index recipient||verifying
23164 .index verifying||recipient
23165 This condition is relevant only after a \\RCPT\\ command. It verifies the
23166 current recipient. Details of address verification are given later, starting at
23167 section ~~SECTaddressverification. After a recipient has been verified, the
23168 value of \$address@_data$\ is the last value that was set while routing the
23169 address. This applies even if the verification fails. When an address that is
23170 being verified is redirected to a single address, verification continues with
23171 the new address, and in that case, the subsequent value of \$address@_data$\ is
23172 the value for the child address.
23173
23174
23175 .item "verify = reverse@_host@_lookup"
23176 .index \verify\, ACL condition
23177 .index ~~ACL||verifying host reverse lookup
23178 .index host||verifying reverse lookup
23179 This condition ensures that a verified host name has been looked up from the IP
23180 address of the client host. (This may have happened already if the host name
23181 was needed for checking a host list, or if the host matched \host@_lookup\.)
23182 Verification ensures that the host name obtained from a reverse DNS lookup, or
23183 one of its aliases, does, when it is itself looked up in the DNS, yield the
23184 original IP address.
23185
23186 If this condition is used for a locally generated message (that is, when there
23187 is no client host involved), it always succeeds.
23188
23189
23190 .item "verify = sender/<<options>>"
23191 .index \verify\, ACL condition
23192 .index ~~ACL||verifying sender
23193 .index sender||verifying
23194 .index verifying||sender
23195 This condition is relevant only after a \\MAIL\\ or \\RCPT\\ command, or after
23196 a message has been received (the \acl@_smtp@_data\ or \acl@_not@_smtp\ ACLs).
23197 If the message's sender is empty (that is, this is a bounce message), the
23198 condition is true. Otherwise, the sender address is verified.
23199 .em
23200 If there is data in the \$address@_data$\ variable at the end of routing, its 
23201 value is placed in \$sender__address__data$\ at the end of verification. This
23202 value can be used in subsequent conditions and modifiers in the same ACL
23203 statement. It does not persist after the end of the current statement. If you
23204 want to preserve the value for longer, you can save it in an ACL variable.
23205
23206 Details of verification are given later, starting at section
23207 ~~SECTaddressverification. Exim caches the result of sender verification, to
23208 avoid doing it more than once per message.
23209
23210 .item "verify = sender=address/<<options>>"
23211 .index \verify\, ACL condition
23212 This is a variation of the previous option, in which a modified address is
23213 verified as a sender.
23214
23215 .enditems
23216
23217
23218
23219 .section Using DNS lists
23220 .rset SECTmorednslists "~~chapter.~~section"
23221 .index DNS list||in ACL
23222 .index black list (DNS)
23223 .index ~~ACL||testing a DNS list
23224 In its simplest form, the \dnslists\ condition tests whether the calling host
23225 is on at least one of a number of DNS lists by looking up the inverted IP
23226 address in one or more DNS domains. For example, if the calling host's IP
23227 address is 192.168.62.43, and the ACL statement is
23228 .display asis
23229 deny dnslists = blackholes.mail-abuse.org : \
23230                 dialups.mail-abuse.org
23231 .endd
23232 the following records are looked up:
23233 .display asis
23234 43.62.168.192.blackholes.mail-abuse.org
23235 43.62.168.192.dialups.mail-abuse.org
23236 .endd
23237 .em
23238 As soon as Exim finds an existing DNS record, processing of the list stops.
23239 Thus, multiple entries on the list provide an `or' conjunction. If you want to
23240 test that a host is on more than one list (an `and' conjunction), you can use
23241 two separate conditions:
23242 .display asis
23243 deny dnslists = blackholes.mail-abuse.org
23244      dnslists = dialups.mail-abuse.org
23245 .endd
23246 .nem
23247 If a DNS lookup times out or otherwise fails to give a decisive answer, Exim
23248 behaves as if the host
23249 .em
23250 does not match the list item, that is, as if the DNS record does not exist. If
23251 there are further items in the DNS list, they are processed.
23252 .nem
23253 This is usually the required action when \dnslists\ is used with \deny\ (which
23254 is the most common usage), because it prevents a DNS failure from blocking
23255 mail. However, you can change this behaviour by putting one of the following
23256 special items in the list:
23257 .index \"+include@_unknown"\
23258 .index \"+exclude@_unknown"\
23259 .index \"+defer@_unknown"\
23260 .display
23261 +include@_unknown    $rm{behave as if the item is on the list}
23262 +exclude@_unknown    $rm{behave as if the item is not on the list (default)}
23263 +defer@_unknown      $rm{give a temporary error}
23264 .endd
23265 Each of these applies to any subsequent items on the list. For example:
23266 .display asis
23267 deny dnslists = +defer_unknown : foo.bar.example
23268 .endd
23269
23270 Testing the list of domains stops as soon as a match is found. If you want to
23271 warn for one list and block for another, you can use two different statements:
23272 .display asis
23273 deny  dnslists = blackholes.mail-abuse.org
23274 warn  message  = X-Warn: sending host is on dialups list
23275       dnslists = dialups.mail-abuse.org
23276 .endd
23277
23278 DNS list lookups are cached by Exim for the duration of the SMTP session,
23279 so a lookup based on the IP address is done at most once for any incoming
23280 connection. Exim does not share information between multiple incoming
23281 connections (but your local name server cache should be active).
23282
23283
23284 .em
23285 .section Specifying the IP address for a DNS list lookup
23286 .index DNS list||keyed by explicit IP address
23287 By default, the IP address that is used in a DNS list lookup is the IP address
23288 of the calling host. However, you can specify another IP address by listing it
23289 after the domain name, introduced by a slash. For example:
23290 .display asis
23291 deny dnslists = black.list.tls/192.168.1.2
23292 .endd
23293 This feature is not very helpful with explicit IP addresses; it is intended for
23294 use with IP addresses that are looked up, for example, the IP addresses of the
23295 MX hosts or nameservers of an email sender address. For an example, see section
23296 ~~SECTmulkeyfor below.
23297 .nem
23298
23299
23300 .section DNS lists keyed on domain names
23301 .index DNS list||keyed by domain name
23302 There are some lists that are keyed on domain names rather than inverted IP
23303 addresses (see for example the \*domain based zones*\ link at
23304 \?http://www.rfc-ignorant.org/?\). No reversing of components is used with
23305 these lists. You can change the name that is looked up in a DNS list by listing
23306 it after the domain name, introduced by a slash. For example,
23307 .display asis
23308 deny  message  = Sender's domain is listed at $dnslist_domain
23309       dnslists = dsn.rfc-ignorant.org/$sender_address_domain
23310 .endd
23311 This particular example is useful only in ACLs that are obeyed after the
23312 \\RCPT\\ or \\DATA\\ commands, when a sender address is available. If (for
23313 example) the message's sender is \*user@@tld.example*\ the name that is looked
23314 up by this example is
23315 .display asis
23316 tld.example.dsn.rfc-ignorant.org
23317 .endd
23318 .em
23319 A single \dnslists\ condition can contain entries for both names and IP
23320 addresses. For example:
23321 .display asis
23322 deny dnslists = sbl.spamhaus.org : \
23323                 dsn.rfc-ignorant.org/$sender_address_domain
23324 .endd
23325 The first item checks the sending host's IP address; the second checks a domain
23326 name. The whole condition is true if either of the DNS lookups succeeds.
23327 .nem
23328
23329
23330 .em
23331 .section Multiple explicit keys for a DNS list
23332 .rset SECTmulkeyfor "~~chapter.~~section"
23333 .index DNS list||multiple keys for
23334 The syntax described above for looking up explicitly-defined values (either
23335 names or IP addresses) in a DNS blacklist is a simplification. After the domain
23336 name for the DNS list, what follows the slash can in fact be a list of items.
23337 As with all lists in Exim, the default separator is a colon. However, because
23338 this is a sublist within the list of DNS blacklist domains, it is necessary
23339 either to double the separators like this:
23340 .display asis
23341 dnslists = black.list.tld/name.1::name.2
23342 .endd
23343 or to change the separator character, like this:
23344 .display asis
23345 dnslists = black.list.tld/<;name.1;name.2
23346 .endd
23347 If an item in the list is an IP address, it is inverted before the DNS
23348 blacklist domain is appended. If it is not an IP address, no inversion
23349 occurs. Consider this condition:
23350 .display asis
23351 dnslists = black.list.tld/<;192.168.1.2;a.domain
23352 .endd
23353 The DNS lookups that occur are:
23354 .display asis
23355 2.1.168.192.black.list.tld
23356 a.domain.black.list.tld
23357 .endd
23358 Once a DNS record has been found (that matches a specific IP return
23359 address, if specified -- see section ~~SECTaddmatcon), no further lookups are
23360 done. If there is a temporary DNS error, the rest of the sublist of domains or
23361 IP addresses is tried. A temporary error for the whole dnslists item occurs
23362 only if no other DNS lookup in this sublist succeeds. In other words, a
23363 successful lookup for any of the items in the sublist overrides a temporary
23364 error for a previous item.
23365
23366 The ability to supply a list of items after the slash is in some sense just a
23367 syntactic convenience. These two examples have the same effect:
23368 .display asis
23369 dnslists = black.list.tld/a.domain : black.list.tld/b.domain
23370 dnslists = black.list.tld/a.domain::b.domain
23371 .endd
23372 However, when the data for the list is obtained from a lookup, the second form
23373 is usually much more convenient. Consider this example:
23374 .display asis
23375 deny message  =  The mail servers for the domain \
23376                  $sender_address_domain \
23377                  are listed at $dnslist_domain ($dnslist_value); \
23378                  see $dnslist_text.
23379      dnslists =  sbl.spamhaus.org/<|${lookup dnsdb {>|a=<|\
23380                                     ${lookup dnsdb {>|mxh=\
23381                                     $sender_address_domain} }} }
23382 .endd
23383 Note the use of \">|"\ in the dnsdb lookup to specify the separator for
23384 multiple DNS records. The inner dnsdb lookup produces a list of MX hosts
23385 and the outer dnsdb lookup finds the IP addresses for these hosts. The result
23386 of expanding the condition might be something like this:
23387 .display asis
23388 dnslists = sbl.spahmaus.org/<|192.168.2.3|192.168.5.6|...
23389 .endd
23390 Thus, this example checks whether or not the IP addresses of the sender
23391 domain's mail servers are on the Spamhaus black list.
23392 .nem
23393
23394
23395
23396 .section Data returned by DNS lists
23397 .index DNS list||data returned from
23398 DNS lists are constructed using address records in the DNS. The original RBL
23399 just used the address 127.0.0.1 on the right hand side of each record, but the
23400 RBL+ list and some other lists use a number of values with different meanings.
23401 The values used on the RBL+ list are:
23402 .display rm
23403 .tabs 12
23404 127.1.0.1 $t RBL
23405 127.1.0.2 $t DUL
23406 127.1.0.3 $t DUL and RBL
23407 127.1.0.4 $t RSS
23408 127.1.0.5 $t RSS and RBL
23409 127.1.0.6 $t RSS and DUL
23410 127.1.0.7 $t RSS and DUL and RBL
23411 .endd
23412 Some DNS lists may return more than one address record.
23413
23414 .section Variables set from DNS lists
23415 .index DNS list||variables set from
23416 When an entry is found in a DNS list, the variable \$dnslist@_domain$\
23417 contains the name of the domain that matched, \$dnslist@_value$\ contains the
23418 data from the entry, and \$dnslist@_text$\ contains the contents of any
23419 associated TXT record. If more than one address record is returned by the DNS
23420 lookup, all the IP addresses are included in \$dnslist@_value$\, separated by
23421 commas and spaces.
23422
23423 You can use these variables in \message\ or \log@_message\ modifiers --
23424 although these appear before the condition in the ACL, they are not expanded
23425 until after it has failed. For example:
23426 .display asis
23427 deny    hosts = !+local_networks
23428         message = $sender_host_address is listed \
23429                   at $dnslist_domain
23430         dnslists = rbl-plus.mail-abuse.example
23431 .endd
23432
23433
23434 .section Additional matching conditions for DNS lists
23435 .rset SECTaddmatcon "~~chapter.~~section"
23436 .index DNS list||matching specific returned data
23437 You can add an equals sign and an IP address after a \dnslists\ domain name in
23438 order to restrict its action to DNS records with a matching right hand side.
23439 For example,
23440 .display asis
23441 deny dnslists = rblplus.mail-abuse.org=127.0.0.2
23442 .endd
23443 rejects only those hosts that yield 127.0.0.2. Without this additional data,
23444 any address record is considered to be a match. If more than one address record
23445 is found on the list, they are all checked for a matching right-hand side.
23446
23447 More than one IP address may be given for checking, using a comma as a
23448 separator. These are alternatives -- if any one of them matches, the \dnslists\
23449 condition is true. For example:
23450 .display asis
23451 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
23452 .endd
23453
23454 If you want to specify a constraining address list and also specify names or IP
23455 addresses to be looked up, the constraining address list must be specified
23456 first. For example:
23457 .display asis
23458 deny dnslists = dsn.rfc-ignorant.org\
23459                 =127.0.0.2/$sender_address_domain
23460 .endd
23461
23462 If the character `&' is used instead of `=', the comparison for each listed
23463 IP address is done by a bitwise `and' instead of by an equality test. In
23464 other words, the listed addresses are used as bit masks. The comparison is
23465 true if all the bits in the mask are present in the address that is being
23466 tested. For example:
23467 .display asis
23468 dnslists = a.b.c&0.0.0.3
23469 .endd
23470 matches if the address is \*x.x.x.*\3, \*x.x.x.*\7, \*x.x.x.*\11, etc. If you
23471 want to test whether one bit or another bit is present (as opposed to both
23472 being present), you must use multiple values. For example:
23473 .display asis
23474 dnslists = a.b.c&0.0.0.1,0.0.0.2
23475 .endd
23476 matches if the final component of the address is an odd number or two times
23477 an odd number.
23478
23479
23480 .section Negated DNS matching conditions
23481 You can supply a negative list of IP addresses as part of a \dnslists\
23482 condition. Whereas
23483 .display asis
23484 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
23485 .endd
23486 means `deny if the host is in the black list at the domain \*a.b.c*\ and the IP
23487 address yielded by the list is either 127.0.0.2 or 127.0.0.3',
23488 .display asis
23489 deny  dnslists = a.b.c!=127.0.0.2,127.0.0.3
23490 .endd
23491 means `deny if the host is in the black list at the domain \*a.b.c*\ and the IP
23492 address yielded by the list is not 127.0.0.2 and not 127.0.0.3'. In other
23493 words, the result of the test is inverted if an exclamation mark appears before
23494 the `=' (or the `&') sign.
23495
23496 \**Note**\: this kind of negation is not the same as negation in a domain,
23497 host, or address list (which is why the syntax is different).
23498
23499 If you are using just one list, the negation syntax does not gain you much. The
23500 previous example is precisely equivalent to
23501 .display asis
23502 deny  dnslists = a.b.c
23503      !dnslists = a.b.c=127.0.0.2,127.0.0.3
23504 .endd
23505 However, if you are using multiple lists, the negation syntax is clearer.
23506 Consider this example:
23507 .display asis
23508 deny  dnslists = sbl.spamhaus.org : \
23509                  list.dsbl.org : \
23510                  dnsbl.njabl.org!=127.0.0.3 : \
23511                  relays.ordb.org
23512 .endd
23513 Using only positive lists, this would have to be:
23514 .display asis
23515 deny  dnslists = sbl.spamhaus.org : \
23516                  list.dsbl.org
23517 deny  dnslists = dnsbl.njabl.org
23518      !dnslists = dnsbl.njabl.org=127.0.0.3
23519 deny  dnslists = relays.ordb.org
23520 .endd
23521 which is less clear, and harder to maintain.
23522
23523
23524
23525 .section DNS lists and IPv6
23526 .rset SECTmorednslistslast "~~chapter.~~section"
23527 .index IPv6||DNS black lists
23528 .index DNS list||IPv6 usage
23529 If Exim is asked to do a dnslist lookup for an IPv6 address, it inverts it
23530 nibble by nibble. For example, if the calling host's IP address is
23531 3ffe:ffff:836f:0a00:000a:0800:200a:c031, Exim might look up
23532 .display asis
23533 1.3.0.c.a.0.0.2.0.0.8.0.a.0.0.0.0.0.a.0.f.6.3.8.
23534   f.f.f.f.e.f.f.3.blackholes.mail-abuse.org
23535 .endd
23536 (split over two lines here to fit on the page). Unfortunately, some of the DNS
23537 lists contain wildcard records, intended for IPv4, that interact badly with
23538 IPv6. For example, the DNS entry
23539 .display asis
23540 *.3.some.list.example.    A    127.0.0.1
23541 .endd
23542 is probably intended to put the entire 3.0.0.0/8 IPv4 network on the list.
23543 Unfortunately, it also matches the entire 3@:@:/4 IPv6 network.
23544
23545 You can exclude IPv6 addresses from DNS lookups by making use of a suitable
23546 \condition\ condition, as in this example:
23547 .display asis
23548 .newline
23549 .em
23550 deny   condition = ${if isip4{$sender_host_address}}
23551 .nem
23552 .newline
23553        dnslists  = some.list.example
23554 .endd
23555
23556
23557 .section Address verification
23558 .rset SECTaddressverification "~~chapter.~~section"
23559 .index verifying||address, options for
23560 .index policy control||address verification
23561 Several of the \verify\ conditions described in section ~~SECTaclconditions
23562 cause addresses to be verified. These conditions can be followed by options
23563 that modify the verification process. The options are separated from the
23564 keyword and from each other by slashes, and some of them contain parameters.
23565 For example:
23566 .display asis
23567 verify = sender/callout
23568 verify = recipient/defer_ok/callout=10s,defer_ok
23569 .endd
23570 .em
23571 The first stage of address verification, which always happens, is to run the
23572 address through the routers, in `verify mode'. Routers can detect the
23573 difference between verification and routing for delivery, and their actions can
23574 be varied by a number of generic options such as \verify\ and \verify@_only\
23575 (see chapter ~~CHAProutergeneric). If routing fails, verification fails.
23576 The available options are as follows:
23577 .numberpars $.
23578 If the \callout\ option is specified, successful routing to one or more remote
23579 hosts is followed by a `callout' to those hosts as an additional check.
23580 Callouts and their sub-options are discussed in the next section.
23581 .nextp
23582 If there is a defer error while doing verification routing, the ACL
23583 normally returns `defer'. However, if you include \defer@_ok\ in the options,
23584 the condition is forced to be true instead. Note that this is a main
23585 verification option as well as a suboption for callouts.
23586 .nextp
23587 The \no@_details\ option is covered in section ~~SECTsenaddver, which discusses
23588 the reporting of sender address verification failures.
23589 .endp
23590
23591 .index verifying||address, differentiating failures
23592 After an address verification failure, \$sender@_verify@_failure$\ or
23593 \$recipient@_verify@_failure$\ (as appropriate) contains one of the following
23594 words:
23595 .numberpars $.
23596 \qualify\: The address was unqualified (no domain), and the message
23597 was neither local nor came from an exempted host.
23598 .nextp
23599 \route\: Routing failed.
23600 .nextp
23601 \mail\: Routing succeeded, and a callout was attempted; rejection
23602 occurred at or before the \\MAIL\\ command (that is, on initial
23603 connection, \\HELO\\, or \\MAIL\\).
23604 .nextp
23605 \recipient\: The \\RCPT\\ command in a callout was rejected.
23606 .nextp
23607 \postmaster\: The postmaster check in a callout was rejected.
23608 .endp
23609
23610 The main use of these variables is expected to be to distinguish between
23611 rejections of \\MAIL\\ and rejections of \\RCPT\\ in callouts.
23612
23613 .nem
23614
23615
23616 .section Callout verification
23617 .rset SECTcallver "~~chapter.~~section"
23618 .index verifying||address, by callout
23619 .index callout||verification
23620 .index SMTP||callout verification
23621 For non-local addresses, routing verifies the domain, but is unable to do any
23622 checking of the local part. There are situations where some means of verifying
23623 the local part is desirable. One way this can be done is to make an SMTP
23624 \*callback*\ to the sending host (for a sender address) or a \*callforward*\ to
23625 a subsequent host (for a recipient address), to see if the host accepts the
23626 address. We use the term \*callout*\ to cover both cases. This facility should
23627 be used with care, because it can add a lot of resource usage to the cost of
23628 verifying an address. However, Exim does cache the results of callouts, which
23629 helps to reduce the cost. Details of caching are in the next section.
23630
23631 Recipient callouts are usually used only between hosts that are controlled by
23632 the same administration. For example, a corporate gateway host could use
23633 callouts to check for valid recipients on an internal mailserver.
23634 A successful callout does not guarantee that a real delivery to the address
23635 would succeed; on the other hand, a failing callout does guarantee that
23636 a delivery would fail.
23637
23638 If the \callout\ option is present on a condition that verifies an address, a
23639 second stage of verification occurs if the address is successfully routed to
23640 one or more remote hosts. The usual case is routing by a \%dnslookup%\ or a
23641 \%manualroute%\ router, where the router specifies the hosts. However, if a
23642 router that does not set up hosts routes to an \%smtp%\ transport with a
23643 \hosts\ setting, the transport's hosts are used. If an \%smtp%\ transport has
23644 \hosts@_override\ set, its hosts are always used, whether or not the router
23645 supplies a host list.
23646
23647 The port that is used is taken from the transport, if it is specified and is a
23648 remote transport. (For routers that do verification only, no transport need be
23649 specified.) Otherwise, the default SMTP port is used. If a remote transport
23650 specifies an outgoing interface, this is used; otherwise the interface is not
23651 specified.
23652
23653 For a sender callout check, Exim makes SMTP connections to the remote hosts, to
23654 test whether a bounce message could be delivered to the sender address. The
23655 following SMTP commands are sent:
23656 .display
23657 .newline
23658 .em
23659 HELO <<smtp active host name>>
23660 .nem
23661 .newline
23662 MAIL FROM:@<@>
23663 RCPT TO:<<the address to be tested>>
23664 QUIT
23665 .endd
23666 \\LHLO\\ is used instead of \\HELO\\ if the transport's \protocol\ option is
23667 set to `lmtp'.
23668
23669 A recipient callout check is similar. By default, it also uses an empty address
23670 for the sender. This default is chosen because most hosts do not make use of
23671 the sender address when verifying a recipient. Using the same address means
23672 that a single cache entry can be used for each recipient. Some sites, however,
23673 do make use of the sender address when verifying. These are catered for by the
23674 \use@_sender\ and \use@_postmaster\ options, described in the next section.
23675
23676 If the response to the \\RCPT\\ command is a 2$it{xx} code, the verification
23677 succeeds. If it is 5$it{xx}, the verification fails. For any other condition,
23678 Exim tries the next host, if any. If there is a problem with all the remote
23679 hosts, the ACL yields `defer', unless the \defer@_ok\ parameter of the
23680 \callout\ option is given, in which case the condition is forced to succeed.
23681
23682
23683
23684
23685 .section Additional parameters for callouts
23686 .rset CALLaddparcall "~~chapter.~~section"
23687 .index callout||additional parameters for
23688 The \callout\ option can be followed by an equals sign and a number of optional
23689 parameters, separated by commas. For example:
23690 .display asis
23691 verify = recipient/callout=10s,defer_ok
23692 .endd
23693 The old syntax, which had \callout@_defer@_ok\ and \check@_postmaster\ as
23694 separate verify options, is retained for backwards compatibility, but is now
23695 deprecated. The additional parameters for \callout\ are as follows:
23696
23697 .startitems
23698
23699 .item "<<a time interval>>"
23700 .index callout||timeout, specifying
23701 This specifies the timeout that applies for the callout attempt to each host.
23702 For example:
23703 .display asis
23704 verify = sender/callout=5s
23705 .endd
23706 The default is 30 seconds. The timeout is used for each response from the
23707 remote host.
23708 .em
23709 It is also used for the intial connection, unless overridden by the \connect\
23710 parameter.
23711 .nem
23712
23713 .em
23714 .item "connect = <<time interval>>"
23715 .index callout||connection timeout, specifying
23716 This parameter makes it possible to set a different (usually
23717 smaller) timeout for making the SMTP connection.
23718 For example:
23719 .display asis
23720 verify = sender/callout=5s,connect=1s
23721 .endd
23722 If not specified, this timeout defaults to the general timeout value.
23723 .nem
23724
23725 .item "defer@_ok"
23726 .index callout||defer, action on
23727 When this parameter is present, failure to contact any host, or any other kind
23728 of temporary error, is treated as success by the ACL. However, the cache is not
23729 updated in this circumstance.
23730
23731 .em
23732 .item "mailfrom = <<email address>>"
23733 .index callout||sender when verifying header
23734 When verifying addresses in header lines using the \header@_sender\
23735 verification option, Exim behaves by default as if the addresses are envelope
23736 sender addresses from a message. Callout verification therefore tests to see
23737 whether a bounce message could be delivered, by using an empty address in the
23738 \\MAIL\\ command. However, it is arguable that these addresses might never be
23739 used as envelope senders, and could therefore justifiably reject bounce
23740 messages (empty senders). The \mailfrom\ callout parameter allows you to
23741 specify what address to use in the \\MAIL\\ command. For example:
23742 .display asis
23743 require  verify = header_sender/callout=mailfrom=abcd@x.y.z
23744 .endd
23745 This parameter is available only for the \header@_sender\ verification option.
23746 .nem
23747
23748 .em
23749 .item "maxwait = <<time interval>>"
23750 .index callout||overall timeout, specifying
23751 This parameter sets an overall timeout for performing a callout verification.
23752 For example:
23753 .display asis
23754 verify = sender/callout=5s,maxwait=30s
23755 .endd
23756 This timeout defaults to four times the callout timeout for individual SMTP
23757 commands. The overall timeout applies when there is more than one host that can
23758 be tried. The timeout is checked before trying the next host. This prevents
23759 very long delays if there are a large number of hosts and all are timing out
23760 (for example, when network connections are timing out).
23761 .nem
23762
23763 .item "no@_cache"
23764 .index callout||cache, suppressing
23765 .index caching||callout, suppressing
23766 When this parameter is given, the callout cache is neither read nor updated.
23767
23768 .item "postmaster"
23769 .index callout||postmaster, checking
23770 When this parameter is set, a sucessful callout check is followed by a similar
23771 check for the local part \*postmaster*\ at the same domain. If this address is
23772 rejected, the callout fails. The result of the postmaster check is recorded in
23773 a cache record; if it is a failure, this is used to fail subsequent callouts
23774 for the domain without a connection being made, until the cache record expires.
23775
23776 .em
23777 .item "postmaster@_mailfrom = <<email address>>"
23778 The postmaster check uses an empty sender in the \\MAIL\\ command by default.
23779 You can use this parameter to do a postmaster check using a different address.
23780 For example:
23781 .display asis
23782 require  verify = sender/callout=postmaster_mailfrom=abc@x.y.z
23783 .endd
23784 If both \postmaster\ and \postmaster@_mailfrom\ are present, the rightmost one
23785 overrides. The \postmaster\ parameter is equivalent to this example:
23786 .display asis
23787 require  verify = sender/callout=postmaster_mailfrom=
23788 .endd
23789 \**Warning**\: The caching arrangements for postmaster checking do not take
23790 account of the sender address. It is assumed that either the empty address or
23791 a fixed non-empty address will be used. All that Exim remembers is that the
23792 postmaster check for the domain succeeded or failed.
23793 .nem
23794
23795 .item "random"
23796 .index callout||`random' check
23797 When this parameter is set, before doing the normal callout check, Exim does a
23798 check for a `random' local part at the same domain. The local part is not
23799 really random -- it is defined by the expansion of the option
23800 \callout@_random@_local@_part\, which defaults to
23801 .display asis
23802 $primary_host_name-$tod_epoch-testing
23803 .endd
23804 The idea here is to try to determine whether the remote host accepts all local
23805 parts without checking. If it does, there is no point in doing callouts for
23806 specific local parts. If the `random' check succeeds, the result is saved in
23807 a cache record, and used to force the current and subsequent callout checks to
23808 succeed without a connection being made, until the cache record expires.
23809
23810 .item "use@_postmaster"
23811 .index callout||sender for recipient check
23812 This parameter applies to recipient callouts only. For example:
23813 .display asis
23814 deny  !verify = recipient/callout=use_postmaster
23815 .endd
23816 It causes a non-empty postmaster address to be used in the \\MAIL\\ command
23817 when performing the callout. The local part of the address is \"postmaster"\
23818 and the domain is the contents of \$qualify@_domain$\.
23819
23820 .item "use@_sender"
23821 This option applies to recipient callouts only. For example:
23822 .display asis
23823 require  verify = recipient/callout=use_sender
23824 .endd
23825 It causes the message's actual sender address to be used in the \\MAIL\\
23826 command when performing the callout, instead of an empty address. There is no
23827 need to use this option unless you know that the called hosts make use of the
23828 sender when checking recipients. If used indiscriminately, it reduces the
23829 usefulness of callout caching.
23830
23831 .enditems
23832
23833 .em
23834 If you use any of the parameters that set a non-empty sender for the \\MAIL\\
23835 command (\mailfrom\, \postmaster@_mailfrom\, \use@_postmaster\, or
23836 \use@_sender\), you should think about possible loops. Recipient checking is
23837 usually done between two hosts that are under the same management, and the host
23838 that receives the callouts is not normally configured to do callouts itself.
23839 Therefore, it is normally safe to use \use@_postmaster\ or \use@_sender\ in
23840 these circumstances.
23841
23842 However, if you use a non-empty sender address for a callout to an arbitrary
23843 host, there is the likelihood that the remote host will itself initiate a
23844 callout check back to your host. As it is checking what appears to be a message
23845 sender, it is likely to use an empty address in \\MAIL\\, thus avoiding a
23846 callout loop. However, to be on the safe side it would be best to set up your
23847 own ACLs so that they do not do sender verification checks when the recipient
23848 is the address you use for header sender or postmaster callout checking.
23849
23850 Another issue to think about when using non-empty senders for callouts is
23851 caching. When you set \mailfrom\ or \use@_sender\, the cache record is keyed by
23852 the sender/recipient combination; thus, for any given recipient, many more
23853 actual callouts are performed than when an empty sender or postmaster is used.
23854
23855 .nem
23856
23857
23858 .section Callout caching
23859 .rset SECTcallvercache "~~chapter.~~section"
23860 .index hints database||callout cache
23861 .index callout||caching
23862 .index caching||callout
23863 Exim caches the results of callouts in order to reduce the amount of resources
23864 used, unless you specify the \no@_cache\ parameter with the \callout\ option.
23865 A hints database called `callout' is used for the cache. Two different record
23866 types are used: one records the result of a callout check for a specific
23867 address, and the other records information that applies to the entire domain
23868 (for example, that it accepts the local part \*postmaster*\).
23869
23870 When an original callout fails, a detailed SMTP error message is given about
23871 the failure. However, for subsequent failures use the cache data, this message
23872 is not available.
23873
23874 The expiry times for negative and positive address cache records are
23875 independent, and can be set by the global options \callout@_negative@_expire\
23876 (default 2h) and \callout@_positive@_expire\ (default 24h), respectively.
23877
23878 If a host gives a negative response to an SMTP connection, or rejects any
23879 commands up to and including
23880 .display asis
23881 MAIL FROM:<>
23882 .endd
23883 (but not including the \\MAIL\\ command with a non-empty address),
23884 any callout attempt is bound to fail. Exim remembers such failures in a
23885 domain cache record, which it uses to fail callouts for the domain without
23886 making new connections, until the domain record times out. There are two
23887 separate expiry times for domain cache records:
23888 \callout@_domain@_negative@_expire\ (default 3h) and
23889 \callout__domain__positive@_expire\ (default 7d).
23890
23891 Domain records expire when the negative expiry time is reached if callouts
23892 cannot be made for the domain, or if the postmaster check failed.
23893 Otherwise, they expire when the positive expiry time is reached. This
23894 ensures that, for example, a host that stops accepting `random' local parts
23895 will eventually be noticed.
23896
23897 The callout caching mechanism is based on the domain of the address that is
23898 being tested. If the domain routes to several hosts, it is assumed that their
23899 behaviour will be the same.
23900
23901
23902 .section Sender address verification reporting
23903 .rset SECTsenaddver "~~chapter.~~section"
23904 .index verifying||suppressing error details
23905 When sender verification fails in an ACL, the details of the failure are
23906 given as additional output lines before the 550 response to the relevant
23907 SMTP command (\\RCPT\\ or \\DATA\\). For example, if sender callout is in use,
23908 you might see:
23909 .display asis
23910 MAIL FROM:<xyz@abc.example>
23911 250 OK
23912 RCPT TO:<pqr@def.example>
23913 550-Verification failed for <xyz@abc.example>
23914 550-Called:   192.168.34.43
23915 550-Sent:     RCPT TO:<xyz@abc.example>
23916 550-Response: 550 Unknown local part xyz in <xyz@abc.example>
23917 550 Sender verification failed
23918 .endd
23919 If more than one \\RCPT\\ command fails in the same way, the details are given
23920 only for the first of them. However, some administrators do not want to send
23921 out this much information. You can suppress the details by adding
23922 `/no@_details' to the ACL statement that requests sender verification. For
23923 example:
23924 .display asis
23925 verify = sender/no_details
23926 .endd
23927
23928
23929 .section Redirection while verifying
23930 .index verifying||redirection while
23931 .index address redirection||while verifying
23932 A dilemma arises when a local address is redirected by aliasing or forwarding
23933 during verification: should the generated addresses themselves be verified,
23934 or should the successful expansion of the original address be enough to verify
23935 it? Exim takes the following pragmatic approach:
23936 .numberpars $.
23937 When an incoming address is redirected to just one child address, verification
23938 continues with the child address, and if that fails to verify, the original
23939 verification also fails.
23940 .nextp
23941 When an incoming address is redirected to more than one child address,
23942 verification does not continue. A success result is returned.
23943 .endp
23944 This seems the most reasonable behaviour for the common use of aliasing as a
23945 way of redirecting different local parts to the same mailbox. It means, for
23946 example, that a pair of alias entries of the form
23947 .display asis
23948 A.Wol:   aw123
23949 aw123:   :fail: Gone away, no forwarding address
23950 .endd
23951 work as expected, with both local parts causing verification failure. When a
23952 redirection generates more than one address, the behaviour is more like a
23953 mailing list, where the existence of the alias itself is sufficient for
23954 verification to succeed.
23955
23956
23957 .section Using an ACL to control relaying
23958 .rset SECTrelaycontrol "~~chapter.~~section"
23959 .index ~~ACL||relay control
23960 .index relaying||control by ACL
23961 .index policy control||relay control
23962 An MTA is said to \*relay*\ a message if it receives it from some host and
23963 delivers it directly to another host as a result of a remote address contained
23964 within it. Redirecting a local address via an alias or forward file and then
23965 passing the message on to another host is not relaying,
23966 .index `percent hack'
23967 but a redirection as a result of the `percent hack' is.
23968
23969 Two kinds of relaying exist, which are termed `incoming' and `outgoing'. A host
23970 which is acting as a gateway or an MX backup is concerned with incoming
23971 relaying from arbitrary hosts to a specific set of domains. On the other hand,
23972 a host which is acting as a smart host for a number of clients is concerned
23973 with outgoing relaying from those clients to the Internet at large. Often the
23974 same host is fulfilling both functions, as illustrated in the diagram below,
23975 but in principle these two kinds of relaying are entirely independent. What is
23976 not wanted is the transmission of mail from arbitrary remote hosts through your
23977 system to arbitrary domains.
23978 .if ~~sys.fancy
23979 .figure "Controlled relaying" rm
23980 .indent 0
23981 .call aspic -sgcal -nv
23982 centre ~~sys.linelength;
23983 magnify 0.8;
23984 boundingbox 30;
23985 textdepth 16;
23986     boxwidth 120;
23987     boxdepth 44;
23988 A:  box "Arbitrary" "remote hosts";
23989 C:  ibox;
23990 D:  box "Arbitrary" "domains";
23991     iline down 50 from bottom of C;
23992 H:  box width 180 "Local host";
23993     iline down 50;
23994 E:  ibox;
23995 SH: box "Specific" "hosts";
23996 SD: box join right to E "Specific" "domains";
23997     arcarrow clockwise from top of SH to bottom of D plus (-10,-4)
23998       via right of H plus (-20,0);
23999     arcarrow clockwise from bottom of A to top of SD plus (10,4)
24000       via left of H plus (20,0);
24001
24002     ibox join left to right of H "$it{Outgoing}";
24003     goto H;
24004     ibox join right to left of H "$it{Incoming}";
24005
24006 L:  line dashed from right of A to top of H plus (-15,0);
24007     arc dashed to top of H plus (15,0);
24008     arrow dashed to left of D plus (-2,0);
24009
24010     arrow dashed back up 72 right 32 from middle of L plus (8,0);
24011     text at end plus (0, 4) "$it{Not wanted}";
24012 .endcall
24013 .endfigure
24014 .elif !~~html
24015 .display asis
24016    --------------    -----------
24017    | Arbitrary  |    |Arbitrary|
24018    |remote hosts|    | domains |
24019    --------------    -----------
24020  I       v                ^       O
24021  n       v                ^       u
24022  c    ---v----------------^---    t
24023  o    |  v     Local      ^  |    g
24024  m    |  v      host      ^  |    o
24025  i    ---v----------------^---    i
24026  n       v                ^       n
24027  g       v                ^       g
24028       Specific         Specific
24029       domains           hosts
24030 .endd
24031 .else
24032 [(IMG SRC="relaying.gif" alt="Controlled relaying")][(br)]
24033 .fi
24034
24035 You can implement relay control by means of suitable statements in the ACL that
24036 runs for each \\RCPT\\ command. For convenience, it is often easiest to use
24037 Exim's named list facility to define the domains and hosts involved. For
24038 example, suppose you want to do the following:
24039 .numberpars $.
24040 Deliver a number of domains to mailboxes on the local host (or process them
24041 locally in some other way). Let's say these are \*my.dom1.example*\ and
24042 \*my.dom2.example*\.
24043 .nextp
24044 Relay mail for a number of other domains for which you are the secondary MX.
24045 These might be \*friend1.example*\ and \*friend2.example*\.
24046 .nextp
24047 Relay mail from the hosts on your local LAN, to whatever domains are involved.
24048 Suppose your LAN is 192.168.45.0/24.
24049 .endp
24050 In the main part of the configuration, you put the following definitions:
24051 .display asis
24052 domainlist local_domains = my.dom1.example : my.dom2.example
24053 domainlist relay_domains = friend1.example : friend2.example
24054 hostlist   relay_hosts   = 192.168.45.0/24
24055 .endd
24056 Now you can use these definitions in the ACL that is run for every \\RCPT\\
24057 command:
24058 .display asis
24059 acl_check_rcpt:
24060   accept domains = +local_domains : +relay_domains
24061   accept hosts   = +relay_hosts
24062 .endd
24063 The first statement accepts any \\RCPT\\ command that contains an address in
24064 the local or relay domains. For any other domain, control passes to the second
24065 statement, which accepts the command only if it comes from one of the relay
24066 hosts. In practice, you will probably want to make your ACL more sophisticated
24067 than this, for example, by including sender and recipient verification. The
24068 default configuration includes a more comprehensive example, which is described
24069 in chapter ~~CHAPdefconfil.
24070
24071
24072 .section Checking a relay configuration
24073 .rset SECTcheralcon "~~chapter.~~section"
24074 .index relaying||checking control of
24075 You can check the relay characteristics of your configuration in the same way
24076 that you can test any ACL behaviour for an incoming SMTP connection, by using
24077 the \-bh-\ option to run a fake SMTP session with which you interact.
24078
24079 For specifically testing for unwanted relaying, the host
24080 \*relay-test.mail-abuse.org*\ provides a useful service. If you telnet to this
24081 host from the host on which Exim is running, using the normal telnet port, you
24082 will see a normal telnet connection message and then quite a long delay. Be
24083 patient. The remote host is making an SMTP connection back to your host, and
24084 trying a number of common probes to test for open relay vulnerability. The
24085 results of the tests will eventually appear on your terminal.
24086
24087
24088
24089
24090 .
24091 .
24092 .
24093 .
24094 . ============================================================================
24095 .chapter Content scanning
24096 .set runningfoot "content scanning"
24097 .rset CHAPexiscan "~~chapter"
24098 .index content scanning
24099 .em
24100 The content-scanning extension of Exim, formerly known as `exiscan', was
24101 originally implemented as a patch by Tom Kistner. The code was integrated into
24102 the main source for Exim release 4.50, and Tom continues to maintain it. Most
24103 of the wording of this chapter is taken from Tom's specification.
24104
24105 If you want to include the content-scanning features when you compile Exim, you
24106 need to arrange for \\WITH@_CONTENT@_SCAN\\ to be defined in your
24107 \(Local/Makefile)\. When you do that, the Exim binary is built with:
24108 .numberpars $.
24109 An additional ACL (\acl@_smtp@_mime\) that is run for all MIME parts.
24110 .nextp
24111 Additional ACL conditions and modifiers: \decode\, \malware\, \mime@_regex\,
24112 \regex\, and \spam\. These can be used in the ACL that is run at the end of
24113 message reception (the \acl@_smtp@_data\ ACL).
24114 .nextp
24115 An additional control feature (`no@_mbox@_unspool') that saves spooled copies 
24116 of messages, or parts of messages, for debugging purposes. 
24117 .nextp
24118 Additional expansion variables that are set in the new ACL and by the new
24119 conditions.
24120 .nextp
24121 Two new main configuration options: \av@_scanner\ and \spamd@_address\.
24122 .endp
24123 There is another content-scanning configuration option for \(Local/Makefile)\,
24124 called \\WITH@_OLD@_DEMIME\\. If this is set, the old, deprecated \demime\ ACL
24125 condition is compiled, in addition to all the other content-scanning features.
24126
24127 Content-scanning is continually evolving, and new features are still being
24128 added. While such features are still unstable and liable to incompatible
24129 changes, they are made available in Exim by setting options whose names begin
24130 \\EXPERIMENTAL@_\\ in \(Local/Makefile)\. Such features are not documented in
24131 this manual. You can find out about them by reading the file called
24132 \(doc/experimental.txt)\.
24133
24134 All the content-scanning facilites work on a MBOX copy of the message that is
24135 temporarily created in a file called:
24136 .display
24137 <<spool@_directory>>/scan/<<message@_id>>/<<message@_id>>.eml
24138 .endd
24139 The \(.eml)\ extension is a friendly hint to virus scanners that they can
24140 expect an MBOX-like structure inside that file. The file is created when the
24141 first content scanning facility is called. Subsequent calls to content
24142 scanning conditions open the same file again. The directory is recursively
24143 removed when the \acl@_smtp@_data\ ACL has finished running, unless 
24144 .display asis
24145 control = no_mbox_unspool
24146 .endd
24147 has been encountered. When the MIME ACL decodes files, they are put into the
24148 same directory by default.
24149
24150
24151 .section Scanning for viruses
24152 .rset SECTscanvirus "~~chapter.~~section"
24153 .index virus scanning
24154 .index content scanning||for viruses
24155 .index content scanning||the \malware\ condition
24156 The \malware\ ACL condition lets you connect virus scanner software to Exim. It
24157 supports a `generic' interface to scanners called via the shell, and
24158 specialized interfaces for `daemon' type virus scanners, which are resident in
24159 memory and thus are much faster.
24160
24161 .index \av@_scanner\
24162 You can set the \av@_scanner\ option in first part of the Exim configuration
24163 file to specify which scanner to use, together with any additional options that
24164 are needed. The basic syntax is as follows:
24165 .display
24166 av@_scanner = <<scanner-type>>:<<option1>>:<<option2>>:[...]
24167 .endd
24168 If you do not set \av@_scanner\, it defaults to
24169 .display asis
24170 av_scanner = sophie:/var/run/sophie
24171 .endd
24172 If the value of \av@_scanner\ starts with dollar character, it is expanded
24173 before use.
24174
24175 The following scanner types are supported in this release:
24176 .numberpars $.
24177 .index virus scanners||Kaspersky
24178 \aveserver\: This is the scanner daemon of Kaspersky Version 5. You can get a
24179 trial version at \?http://www.kaspersky.com?\. This scanner type takes one
24180 option, which is the path to the daemon's UNIX socket. The default is shown in
24181 this example:
24182 .display asis
24183 av_scanner = aveserver:/var/run/aveserver
24184 .endd
24185
24186 .nextp
24187 .index virus scanners||clamd
24188 \clamd\: This daemon-type scanner is GPL and free. You can get it at
24189 \?http://www.clamav.net/?\. Clamd does not seem to unpack MIME containers, so
24190 it is recommended to unpack MIME attachments in the MIME ACL. It takes one
24191 option: either the path and name of a UNIX socket file, or a hostname or IP
24192 number, and a port, separated by space, as in the second of these examples:
24193 .display asis
24194 av_scanner = clamd:/opt/clamd/socket
24195 av_scanner = clamd:192.168.2.100 1234
24196 .endd
24197 If the option is unset, the default is \(/tmp/clamd)\. Thanks to David Saez for 
24198 contributing the code for this scanner.
24199
24200 .nextp
24201 .index virus scanners||command line interface
24202 \cmdline\: This is the keyword for the generic command line scanner interface.
24203 It can be used to attach virus scanners that are invoked from the shell. This
24204 scanner type takes 3 mantadory options:
24205 .numberpars
24206 The full path and name of the scanner binary, with all command line options,
24207 and a placeholder (%s) for the directory to scan.
24208 .nextp
24209 A regular expression to match against the STDOUT and STDERR output of the virus
24210 scanner. If the expression matches, a virus was found. You must make absolutely
24211 sure that this expression matches on `virus found'. This is called the
24212 `trigger' expression.
24213 .nextp
24214 Another regular expression, containing exactly one pair of parentheses, to
24215 match the name of the virus found in the scanners output. This is called the
24216 `name' expression.
24217 .endp
24218 For example, Sophos Sweep reports a virus on a line like this:
24219 .display asis
24220 Virus 'W32/Magistr-B' found in file ./those.bat
24221 .endd
24222 For the trigger expression, we can just match the word `found'. For the name
24223 expression, we want to extract the W32/Magistr-B string, so we can match for
24224 the single quotes left and right of it. Altogether, this makes the
24225 configuration setting:
24226 .display asis
24227 av_scanner = cmdline:\
24228              /path/to/sweep -all -rec -archive %s:\
24229              found:'(.+)'
24230 .endd
24231
24232 .nextp
24233 .index virus scanners||DrWeb
24234 \drweb\: The DrWeb daemon scanner (\?http://www.sald.com/?\) interface
24235 takes one argument, either a full path to a UNIX socket, or an IP address and
24236 port separated by whitespace, as in these examples:
24237 .display asis
24238 av_scanner = drweb:/var/run/drwebd.sock
24239 av_scanner = drweb:192.168.2.20 31337
24240 .endd
24241 If you omit the argument, the default path \(/usr/local/drweb/run/drwebd.sock)\
24242 is used. Thanks to Alex Miller for contributing the code for this scanner.
24243
24244 .nextp
24245 .index virus scanners||F-Secure
24246 \fsecure\: The F-Secure daemon scanner (\?http://www.f-secure.com?\) takes one
24247 argument which is the path to a UNIX socket. For example:
24248 .display asis
24249 av_scanner = fsecure:/path/to/.fsav
24250 .endd
24251 If no argument is given, the default is \(/var/run/.fsav)\. Thanks to Johan
24252 Thelmen for contributing the code for this scanner.
24253
24254 .nextp
24255 .index virus scanners||Kaspersky
24256 \kavdaemon\: This is the scanner daemon of Kaspersky Version 4. This version of
24257 the Kaspersky scanner is outdated. Please upgrade (see \aveserver\ above). This
24258 scanner type takes one option, which is the path to the daemon's UNIX socket.
24259 For example:
24260 .display asis
24261 av_scanner = kavdaemon:/opt/AVP/AvpCtl
24262 .endd
24263 The default path is \(/var/run/AvpCtl)\.
24264
24265 .nextp
24266 .index virus scanners||mksd
24267 \mksd\: This is a daemon type scanner that is aimed mainly at Polish users,
24268 though some parts of documentation are now available in English. You can get it
24269 at \?http://linux.mks.com.pl/?\. The only option for this scanner type is the
24270 maximum number of processes used simultaneously to scan the attachments,
24271 provided that the demime facility is employed and also provided that mksd has
24272 been run with at least the same number of child processes. For example:
24273 .display asis
24274 av_scanner = mksd:2
24275 .endd
24276 You can safely omit this option (the default value is 1).
24277
24278 .nextp
24279 .index virus scanners||Sophos and Sophie
24280 \sophie\:  Sophie is a daemon that uses Sophos' \libsavi\ library to scan for
24281 viruses. You can get Sophie at \?http://www.vanja.com/tools/sophie/?\. The only
24282 option for this scanner type is the path to the UNIX socket that Sophie uses
24283 for client communication. For example:
24284 .display asis
24285 av_scanner = sophie:/tmp/sophie
24286 .endd
24287 The default path is \(/var/run/sophie)\, so if you are using this, you can omit
24288 the option.
24289 .endp
24290
24291 When \av@_scanner\ is correctly set, you can use the \malware\ condition in the
24292 \\DATA\\ ACL. The \av@_scanner\ option is expanded each time \malware\ is
24293 called. This makes it possible to use different scanners. See further below for
24294 an example. The \malware\ condition caches its results, so when you use it
24295 multiple times for the same message, the actual scanning process is only
24296 carried out once. However, using expandable items in \av@_scanner\ disables
24297 this caching, in which case each use of the \malware\ condition causes a new 
24298 scan of the message.
24299
24300 The \malware\ condition takes a right-hand argument that is expanded before
24301 use. It can then be one of
24302 .numberpars $.
24303 `true', `*', or `1', in which case the message is scanned for viruses. The
24304 condition succeeds if a virus was found, and fail otherwise. This is the
24305 recommended usage.
24306 .nextp
24307 `false' or `0', in which case no scanning is done and the condition fails
24308 immediately.
24309 .nextp
24310 A regular expression, in which case the message is scanned for viruses. The
24311 condition succeeds if a virus is found and its name matches the regular
24312 expression. This allows you to take special actions on certain types of virus.
24313 .endp
24314 You can append \"/defer@_ok"\ to the \malware\ condition to accept messages even
24315 if there is a problem with the virus scanner.
24316
24317 .index \$malware@_name$\
24318 When a virus is found, the condition sets up an expansion variable called
24319 \$malware@_name$\ that contains the name of the virus. You can use it in a
24320 \message\ modifier that specifies the error returned to the sender, and/or in
24321 logging data.
24322
24323 If your virus scanner cannot unpack MIME and TNEF containers itself, you should
24324 use the \demime\ condition (see section ~~SECTdemimecond) before the \malware\
24325 condition.
24326
24327 Here is a very simple scanning example:
24328 .display asis
24329 deny message = This message contains malware ($malware_name)
24330    demime = *
24331    malware = *
24332 .endd
24333 The next example accepts messages when there is a problem with the scanner:
24334 .display asis
24335 deny message = This message contains malware ($malware_name)
24336    demime = *
24337    malware = */defer_ok
24338 .endd
24339 The next example shows how to use an ACL variable to scan with both sophie and
24340 aveserver. It assumes you have set:
24341 .display asis
24342 av_scanner = $acl_m0
24343 .endd
24344 in the main Exim configuration.
24345 .display asis
24346 deny message = This message contains malware ($malware_name)
24347    set acl_m0 = sophie
24348    malware = *
24349
24350 deny message = This message contains malware ($malware_name)
24351    set acl_m0 = aveserver
24352    malware = *
24353 .endd
24354
24355
24356 .section Scanning with SpamAssassin
24357 .rset SECTscanspamass "~~chapter.~~section"
24358 .index content scanning||for spam
24359 .index spam scanning
24360 .index SpamAssassin, scanning with
24361 The \spam\ ACL condition calls SpamAssassin's \spamd\ daemon to get a spam
24362 score and a report for the message. You can get SpamAssassin at
24363 \?http://www.spamassassin.org?\, or, if you have a working Perl installation,
24364 you can use CPAN by running:
24365 .display asis
24366 perl -MCPAN -e 'install Mail::SpamAssassin'
24367 .endd
24368 SpamAssassin has its own set of configuration files. Please review its
24369 documentation to see how you can tweak it. The default installation should work
24370 nicely, however.
24371
24372 .index \spamd@_address\
24373 After having installed and configured SpamAssassin, start the \spamd\ daemon.
24374 By default, it listens on 127.0.0.1, TCP port 783. If you use another host or
24375 port for \spamd\, you must set the \spamd@_address\ option in the global part
24376 of the Exim configuration as follows (example):
24377 .display asis
24378 spamd_address = 192.168.99.45 387
24379 .endd
24380 You do not need to set this option if you use the default. As of version 2.60,
24381 \spamd\ also supports communication over UNIX sockets. If you want to use
24382 these, supply \spamd@_address\ with an absolute file name instead of a
24383 address/port pair:
24384 .display asis
24385 spamd_address = /var/run/spamd_socket
24386 .endd
24387
24388 You can have multiple \spamd\ servers to improve scalability. These can reside
24389 on other hardware reachable over the network. To specify multiple \spamd\
24390 servers, put multiple address/port pairs in the \spamd@_address\ option,
24391 separated with colons:
24392 .display asis
24393 spamd_address = 192.168.2.10 783 : \
24394                 192.168.2.11 783 : \
24395                 192.168.2.12 783
24396 .endd
24397 Up to 32 \spamd\ servers are supported. The servers are
24398 queried in a random fashion. When a server fails to respond
24399 to the connection attempt, all other servers are tried
24400 until one succeeds. If no server responds, the \spam\
24401 condition defers. 
24402
24403 \**Warning**\: It is not possible to use the UNIX socket connection method with
24404 multiple \spamd\ servers.
24405
24406 Here is a simple example of the use of the \spam\ condition in a DATA ACL:
24407 .display asis
24408 deny message = This message was classified as SPAM
24409         spam = joe
24410 .endd
24411 The right-hand side of the \spam\ condition specifies the username that
24412 SpamAssassin should scan for. If you do not want to scan for a particular user,
24413 but rather use the SpamAssassin system-wide default profile, you can scan for
24414 an unknown user, or simply use `nobody'. However, you must put something on the
24415 right-hand side.
24416
24417 The username allows you to use per-domain or per-user antispam profiles. The
24418 right-hand side is expanded before being used, so you can put lookups or
24419 conditions there. When the right-hand side evaluates to `0' or `false', no
24420 scanning is done and the condition fails immediately.
24421
24422 The \spam\ condition returns true if the threshold specified in the user's
24423 SpamAssassin profile has been matched or exceeded. If you want to use the
24424 \spam\ condition for its side effects (see the variables below), you can make
24425 it always return `true' by appending \":true"\ to the username.
24426
24427 .index spam scanning||returned variables
24428 When the \spam\ condition is run, it sets up the following expansion
24429 variables:
24430
24431 .push
24432 .indent 2em
24433
24434 .tempindent 0
24435 \$spam@_score$\: The spam score of the message, for example `3.4' or `30.5'.
24436 This is useful for inclusion in log or reject messages.
24437
24438 .tempindent 0
24439 \$spam@_score@_int$\: The spam score of the message, multiplied by ten, as an
24440 integer value. For example `34' or `305'. This is useful for numeric
24441 comparisons in conditions. This variable is special; it is saved with the
24442 message, and written to Exim's spool file. This means that it can be used
24443 during the whole life of the message on your Exim system, in particular, in
24444 routers or transports during the later delivery phase.
24445
24446 .tempindent 0
24447 \$spam@_bar$\: A string consisting of a number of `+' or `@-' characters,
24448 representing the integer part of the spam score value. A spam score of 4.4
24449 would have a \$spam@_bar$\ value of `++++'. This is useful for inclusion in
24450 warning headers, since MUAs can match on such strings.
24451
24452 .tempindent 0
24453 \$spam@_report$\: A multiline text table, containing the full SpamAssassin
24454 report for the message. Useful for inclusion in headers or reject messages.
24455
24456 .pop
24457
24458 The \spam\ condition caches its results. If you call it again with the same user
24459 name, it does not scan again, but rather returns the same values as before.
24460
24461 The \spam\ condition returns DEFER if there is any error while running the
24462 message through SpamAssassin. If you want to treat DEFER as FAIL (to pass on to
24463 the next ACL statement block), append \"/defer@_ok"\ to the right-hand side of
24464 the spam condition, like this:
24465 .display asis
24466 deny message = This message was classified as SPAM
24467      spam    = joe/defer_ok
24468 .endd
24469 This causes messages to be accepted even if there is a
24470 problem with \spamd\.
24471
24472 Here is a longer, commented example of the use of the \spam\
24473 condition:
24474 .display asis
24475 # put headers in all messages (no matter if spam or not)
24476 warn  message = X-Spam-Score: $spam_score ($spam_bar)
24477       spam = nobody:true
24478 warn  message = X-Spam-Report: $spam_report
24479       spam = nobody:true
24480
24481 # add second subject line with *SPAM* marker when message
24482 # is over threshold
24483 warn  message = Subject: *SPAM* $h_Subject:
24484       spam = nobody
24485
24486 # reject spam at high scores (> 12)
24487 deny   message = This message scored $spam_score spam points.
24488        spam = nobody:true
24489        condition = ${if >{$spam_score_int}{120}{1}{0}}
24490 .endd
24491
24492
24493
24494 .section Scanning MIME parts
24495 .rset SECTscanmimepart "~~chapter.~~section"
24496 .index content scanning||MIME parts
24497 .index MIME content scanning
24498 .index \acl@_smtp@_mime\
24499 The \acl@_smtp@_mime\ global option defines an ACL that is called once for each
24500 MIME part of a message, including multipart types, in the sequence of their
24501 position in the message.
24502  
24503 This ACL is called (possibly many times) just before the \acl@_smtp@_data\ ACL,
24504 but only if the message has a ::MIME-Version:: header. When a call to the MIME
24505 ACL does not yield `accept', ACL processing is aborted and the appropriate
24506 result code is sent to the remote client. The \acl@_smtp@_data\ ACL is not
24507 called in this circumstance.
24508
24509 At the start of the MIME ACL, a number of variables are set from the header 
24510 information for the relevant MIME part. These are described below. The contents 
24511 of the MIME part are not by default decoded into a disk file except for MIME 
24512 parts whose content-type is `message/rfc822'. If you want to decode a MIME part 
24513 into a disk file, you can use the \decode\ modifier. The general syntax is:
24514 .display
24515 decode = [/<<path>>/]<<filename>>
24516 .endd
24517 The right hand side is expanded before use. After expansion,
24518 the value can be:
24519 .numberpars
24520 `0' or `false', in which case no decoding is done.
24521 .nextp
24522 The string `default'. In that case, the file is put in the temporary `default'
24523 directory \(<<spool@_directory>>/scan/<<message@_id>>/)\ with a sequential file
24524 name consisting of the message id and a sequence number. The full path and name
24525 is available in \$mime@_decoded@_filename$\ after decoding.
24526 .nextp
24527 A full path name starting with a slash. If the full name is an existing
24528 directory, it is used as a replacement for the default directory. The filename
24529 is then sequentially assigned. If the path does not exist, it is used as
24530 the full path and file name.
24531 .nextp
24532 If the string does not start with a slash, it is used as the
24533 filename, and the default path is then used.
24534 .endp
24535 You can easily decode a file with its original, proposed
24536 filename using
24537 .display asis
24538 decode = $mime_filename
24539 .endd
24540 However, you should keep in mind that \$mime@_filename$\ might contain
24541 anything. If you place files outside of the default path, they are not
24542 automatically unlinked.
24543
24544 For RFC822 attachments (these are messages attached to messages, with a
24545 content-type of `message/rfc822'), the ACL is called again in the same manner
24546 as for the primary message, only that the \$mime@_is@_rfc822$\ expansion
24547 variable is set (see below). Attached messages are always decoded to disk
24548 before being checked, and the files are unlinked once the check is done.
24549
24550 The MIME ACL supports the \regex\ and \mime@_regex\ conditions. These can be
24551 used to match regular expressions against raw and decoded MIME parts,
24552 respectively. They are described in section ~~SECTscanregex.
24553
24554 .index MIME content scanning||returned variables
24555 The following list describes all expansion variables that are
24556 available in the MIME ACL:
24557
24558 .push
24559 .indent 2em
24560
24561 .tempindent 0
24562 \$mime@_boundary$\:
24563 If the current part is a multipart (see \$mime@_is@_multipart$\) below, it
24564 should have a boundary string, which is stored in this variable. If the current
24565 part has no boundary parameter in the ::Content-Type:: header, this variable
24566 contains the empty string.
24567
24568 .tempindent 0
24569 \$mime@_charset$\:
24570 This variable contains the character set identifier, if one was found in the
24571 ::Content-Type:: header. Examples for charset identifiers are:
24572 .display asis
24573 us-ascii
24574 gb2312 (Chinese)
24575 iso-8859-1
24576 .endd
24577 Please note that this value is not normalized, so you should do matches
24578 case-insensitively.
24579
24580 .tempindent 0
24581 \$mime@_content@_description$\:
24582 This variable contains the normalized content of the ::Content-Description::
24583 header. It can contain a human-readable description of the parts content. Some
24584 implementations repeat the filename for attachments here, but they are
24585 usually only used for display purposes.
24586
24587 .tempindent 0
24588 \$mime@_content@_disposition$\:
24589 This variable contains the normalized content of the ::Content-Disposition::
24590 header. You can expect strings like `attachment' or `inline' here.
24591
24592 .tempindent 0
24593 \$mime@_content@_id$\:
24594 This variable contains the normalized content of the ::Content-ID:: header.
24595 This is a unique ID that can be used to reference a part from another part.
24596
24597 .tempindent 0
24598 \$mime@_content@_size$\:
24599 This variable is set only after the \decode\ modifier (see above) has been
24600 successfully run. It contains the size of the decoded part in kilobytes. The
24601 size is always rounded up to full kilobytes, so only a completely empty part
24602 has a \$mime@_content@_size$\ of zero.
24603
24604 .tempindent 0
24605 \$mime@_content@_transfer@_encoding$\:
24606 This variable contains the normalized content of the
24607 ::Content-transfer-encoding:: header. This is a symbolic name for an encoding
24608 type. Typical values are `base64' and `quoted-printable'.
24609
24610 .tempindent 0
24611 \$mime@_content@_type$\: If the MIME part has a ::Content-Type:: header, this
24612 variable contains its value, lowercased, and without any options (like `name'
24613 or `charset'). Here are some examples of popular MIME types, as they may appear
24614 in this variable:
24615 .display asis
24616 text/plain
24617 text/html
24618 application/octet-stream
24619 image/jpeg
24620 audio/midi
24621 .endd
24622 If the MIME part has no ::Content-Type:: header, this variable contains the
24623 empty string.
24624
24625 .tempindent 0
24626 \$mime@_decoded@_filename$\:
24627 This variable is set only after the \decode\ modifier (see above) has been
24628 successfully run. It contains the full path and file name of the file
24629 containing the decoded data.
24630
24631 .tempindent 0
24632 \$mime@_filename$\: This is perhaps the most important of the MIME variables.
24633 It contains a proposed filename for an attachment, if one was found in either
24634 the ::Content-Type:: or ::Content-Disposition:: headers. The filename will be
24635 RFC2047 decoded, but no additional sanity checks are done. If no filename was
24636 found, this variable contains the empty string.
24637
24638 .tempindent 0
24639 \$mime@_is@_coverletter$\:
24640 This variable attempts to differentiate the `cover letter' of an e-mail from
24641 attached data. It can be used to clamp down on flashy or unneccessarily encoded
24642 content in the cover letter, while not restricting attachments at all.
24643
24644 The variable contains 1 (true) for a MIME part believed to be part of the
24645 cover letter, and 0 (false) for an attachment. At present, the algorithm is as
24646 follows:
24647 .numberpars
24648 The outermost MIME part of a message is always a cover letter.
24649 .nextp
24650 If a multipart/alternative or multipart/related MIME part is a cover letter, so
24651 are all MIME subparts within that multipart.
24652 .nextp
24653 If any other multipart is a cover letter, the first subpart is a cover letter,
24654 and the rest are attachments.
24655 .nextp
24656 All parts contained within an attachment multipart are attachments.
24657 .endp
24658
24659 As an example, the following will ban `HTML mail' (including that sent with
24660 alternative plain text), while allowing HTML files to be attached. HTML 
24661 coverletter mail attached to non-HMTL coverletter mail will also be allowed:
24662 .display asis
24663 deny message = HTML mail is not accepted here
24664    !condition = $mime_is_rfc822
24665    condition = $mime_is_coverletter
24666    condition = ${if eq{$mime_content_type}{text/html}{1}{0}}
24667 .endd
24668
24669
24670 .tempindent 0
24671 \$mime@_is@_multipart$\:
24672 This variable has the value 1 (true) when the current part has the main type
24673 `multipart', for example `multipart/alternative' or `multipart/mixed'. Since
24674 multipart entities only serve as containers for other parts, you may not want
24675 to carry out specific actions on them.
24676
24677 .tempindent 0
24678 \$mime@_is@_rfc822$\:
24679 This variable has the value 1 (true) if the current part is not a part of the
24680 checked message itself, but part of an attached message. Attached message
24681 decoding is fully recursive.
24682
24683 .tempindent 0
24684 \$mime@_part@_count$\:
24685 This variable is a counter that is raised for each processed MIME part. It
24686 starts at zero for the very first part (which is usually a multipart). The
24687 counter is per-message, so it is reset when processing RFC822 attachments (see
24688 \$mime@_is@_rfc822$\). The counter stays set after \acl@_smtp@_mime\ is
24689 complete, so you can use it in the DATA ACL to determine the number of MIME
24690 parts of a message. For non-MIME messages, this variable contains the value -1.
24691
24692 .pop
24693
24694
24695 .section Scanning with regular expressions
24696 .rset SECTscanregex "~~chapter.~~section"
24697 .index content scanning||with regular expressions
24698 .index regular expressions||content scanning with
24699 You can specify your own custom regular expression matches on the full body of 
24700 the message, or on individual MIME parts.
24701
24702 The \regex\ condition takes one or more regular expressions as arguments and
24703 matches them against the full message (when called in the DATA ACL) or a raw
24704 MIME part (when called in the MIME ACL). The \regex\ condition matches
24705 linewise, with a maximum line length of 32K characters. That means you cannot
24706 have multiline matches with the \regex\ condition.
24707
24708 The \mime@_regex\ condition can be called only in the MIME ACL. It matches up
24709 to 32K of decoded content (the whole content at once, not linewise). If the
24710 part has not been decoded with the \decode\ modifier earlier in the ACL, it is
24711 decoded automatically when \mime@_regex\ is executed (using default path and
24712 filename values). If the decoded data is larger than  32K, only the first 32K
24713 characters are checked.
24714
24715 The regular expressions are passed as a colon-separated list. To include a
24716 literal colon, you must double it. Since the whole right-hand side string is
24717 expanded before being used, you must also escape dollar signs and backslashes
24718 with more backslashes, or use the \"@\N"\ facility to disable expansion.
24719 Here is a simple example that contains two regular expressions:
24720 .display asis
24721 deny message = contains blacklisted regex ($regex_match_string)
24722        regex = [Mm]ortgage : URGENT BUSINESS PROPOSAL
24723 .endd
24724 The conditions returns true if any one of the regular expressions matches. The
24725 \$regex@_match@_string$\ expansion variable is then set up and contains the
24726 matching regular expression.
24727
24728 \**Warning**\: With large messages, these conditions can be fairly
24729 CPU-intensive.
24730
24731
24732
24733 .section The demime condition
24734 .rset SECTdemimecond "~~chapter.~~section"
24735 .index content scanning||MIME checking
24736 .index MIME content scanning
24737 The \demime\ ACL condition provides MIME unpacking, sanity checking and file
24738 extension blocking. It uses a simpler interface to MIME decoding than the MIME
24739 ACL functionality, but provides no additional facilities. Please note that this
24740 condition is deprecated and kept only for for backward compatibility. You must
24741 set the \\WITH@_OLD@_DEMIME\\ option in \(Local/Makefile)\ at build time to be
24742 able to use the \demime\ condition.
24743
24744 The \demime\ condition unpacks MIME containers in the message. It detects
24745 errors in MIME containers and can match file extensions found in the message
24746 against a list. Using this facility produces files containing the unpacked MIME
24747 parts of the message in the temporary scan directory. If you do antivirus
24748 scanning, it is recommened that you use the \demime\ condition before the
24749 antivirus (\malware\) condition.
24750
24751 On the right-hand side of the \demime\ condition you can pass a colon-separated
24752 list of file extensions that it should match against. For example:
24753 .display asis
24754 deny message = Found blacklisted file attachment
24755      demime  = vbs:com:bat:pif:prf:lnk
24756 .endd
24757 If one of the file extensions is found, the condition is true, otherwise it is
24758 false. If there is a temporary error while demimeing (for example, `disk
24759 full'), the condition defers, and the message is temporarily rejected (unless
24760 the condition is on a \warn\ verb).
24761
24762 The right-hand side is expanded before being treated as a list, so you can have
24763 conditions and lookups there. If it expands to an empty string, `false', or
24764 zero (`0'), no demimeing is done and the condition is false.
24765
24766 The \demime\ condition set the following variables:
24767
24768 .push
24769 .indent 2em
24770
24771 .tempindent 0
24772 \$demime@_errorlevel$\: When an error is detected in a MIME container, this
24773 variable contains the severity of the error, as an integer number. The higher
24774 the value, the more severe the error. If this variable is unset or zero, no
24775 error occurred.
24776
24777 .tempindent 0
24778 \$demime@_reason$\: When \$demime@_errorlevel$\ is greater than zero, this
24779 variable contains a human-readable text string describing the MIME error that
24780 occurred.
24781
24782 .tempindent 0
24783 \$found@_extension$\: When the \demime\ condition is true, this variable
24784 contains the file extension it found.
24785  
24786 .pop 
24787  
24788 Both \$demime@_errorlevel$\ and \$demime@_reason$\ are set by the first call of
24789 the \demime\ condition, and are not changed on subsequent calls.
24790
24791 If you do not want to check for file extensions, but rather use the \demime\
24792 condition for unpacking or error checking purposes, pass `*' as the
24793 right-hand side value. Here is a more elaborate example of how to use this
24794 facility:
24795 .display asis
24796 # Reject messages with serious MIME container errors
24797 deny  message = Found MIME error ($demime_reason).
24798       demime = *
24799       condition = ${if >{$demime_errorlevel}{2}{1}{0}}
24800
24801 # Reject known virus spreading file extensions.
24802 # Accepting these is pretty much braindead.
24803 deny  message = contains $found_extension file (blacklisted).
24804       demime  = com:vbs:bat:pif:scr
24805
24806 # Freeze .exe and .doc files. Postmaster can
24807 # examine them and eventually thaw them.
24808 deny  log_message = Another $found_extension file.
24809       demime = exe:doc
24810       control = freeze
24811 .endd
24812
24813
24814 .nem
24815
24816
24817
24818 .
24819 .
24820 .
24821 .
24822 . ============================================================================
24823 .chapter Adding a local scan function to Exim
24824 .set runningfoot "local scan function"
24825 .rset CHAPlocalscan "~~chapter"
24826 .index \*local@_scan()*\ function||description of
24827 .index customizing||input scan using C function
24828 .index policy control||by local scan function
24829
24830 In these days of email worms, viruses, and ever-increasing spam, some sites
24831 want to apply a lot of checking to messages before accepting them. 
24832 .em
24833 The content scanning extension (chapter ~~CHAPexiscan) has facilities for 
24834 passing messages to external virus and spam scanning software. You can also do
24835 .nem
24836 a certain amount in Exim itself through string expansions and the \condition\
24837 condition in the ACL that runs after the SMTP \\DATA\\ command or the ACL for
24838 non-SMTP messages (see chapter ~~CHAPACL), but this has its limitations.
24839
24840 To allow for further customization to a site's own requirements, there is the
24841 possibility of linking Exim with a private message scanning function, written
24842 in C. If you want to run code that is written in something other than C, you
24843 can of course use a little C stub to call it.
24844
24845 The local scan function is run once for every incoming message, at the point
24846 when Exim is just about to accept the message.
24847 It can therefore be used to control non-SMTP messages from local processes as
24848 well as messages arriving via SMTP.
24849
24850 Exim applies a timeout to calls of the local scan function, and there is an
24851 option called \local@_scan@_timeout\ for setting it. The default is 5 minutes.
24852 Zero means `no timeout'.
24853 Exim also sets up signal handlers for SIGSEGV, SIGILL, SIGFPE, and SIGBUS
24854 before calling the local scan function, so that the most common types of crash
24855 are caught. If the timeout is exceeded or one of those signals is caught, the
24856 incoming message is rejected with a temporary error if it is an SMTP message.
24857 For a non-SMTP message, the message is dropped and Exim ends with a non-zero
24858 code. The incident is logged on the main and reject logs.
24859
24860
24861 .section Building Exim to use a local scan function
24862 .index \*local@_scan()*\ function||building Exim to use
24863 To make use of the local scan function feature, you must tell Exim where your
24864 function is before building Exim, by setting \\LOCAL@_SCAN@_SOURCE\\ in your
24865 \(Local/Makefile)\. A recommended place to put it is in the \(Local)\
24866 directory, so you might set
24867 .display asis
24868 LOCAL_SCAN_SOURCE=Local/local_scan.c
24869 .endd
24870 for example. The function must be called \*local@_scan()*\. It is called by
24871 Exim after it has received a message, when the success return code is about to
24872 be sent. This is after all the ACLs have been run. The return code from your
24873 function controls whether the message is actually accepted or not. There is a
24874 commented template function (that just accepts the message) in the file
24875 \(src/local@_scan.c)\.
24876
24877 If you want to make use of Exim's run time configuration file to set options
24878 for your \*local@_scan()*\ function, you must also set
24879 .display asis
24880 LOCAL_SCAN_HAS_OPTIONS=yes
24881 .endd
24882 in \(Local/Makefile)\ (see section ~~SECTconoptloc below).
24883
24884
24885
24886 .section API for local@_scan()
24887 .rset SECTapiforloc "~~chapter.~~section"
24888 .index \*local@_scan()*\ function||API description
24889 You must include this line near the start of your code:
24890 .display asis
24891 #include "local_scan.h"
24892 .endd
24893 This header file defines a number of variables and other values, and the
24894 prototype for the function itself. Exim is coded to use unsigned char values
24895 almost exclusively, and one of the things this header defines is a shorthand
24896 for \"unsigned char"\ called \"uschar"\.
24897 It also contains the following macro definitions, to simplify casting character
24898 strings and pointers to character strings:
24899 .display asis
24900 #define CS   (char *)
24901 #define CCS  (const char *)
24902 #define CSS  (char **)
24903 #define US   (unsigned char *)
24904 #define CUS  (const unsigned char *)
24905 #define USS  (unsigned char **)
24906 .endd
24907
24908 The function prototype for \*local@_scan()*\ is:
24909 .display asis
24910 extern int local_scan(int fd, uschar **return_text);
24911 .endd
24912 The arguments are as follows:
24913 .numberpars $.
24914 \fd\ is a file descriptor for the file that contains the body of the message
24915 (the -D file).
24916 The file is open for reading and writing, but updating it is not recommended.
24917 \**Warning**\: You must \*not*\ close this file descriptor.
24918
24919 The descriptor is positioned at character 19 of the file, which is the first
24920 character of the body itself, because the first 19 characters are the message
24921 id followed by \"-D"\ and a newline. If you rewind the file, you should use the
24922 macro \\SPOOL@_DATA@_START@_OFFSET\\ to reset to the start of the data, just in
24923 case this changes in some future version.
24924
24925 .nextp
24926 \return@_text\ is an address which you can use to return a pointer to a text
24927 string at the end of the function. The value it points to on entry is NULL.
24928 .endp
24929 The function must return an \int\ value which is one of the following macros:
24930 .numberpars $.
24931 \"LOCAL@_SCAN@_ACCEPT"\
24932
24933 The message is accepted. If you pass back a string of text, it is saved with
24934 the message, and made available in the variable \$local@_scan@_data$\. No
24935 newlines are permitted (if there are any, they are turned into spaces) and the
24936 maximum length of text is 1000 characters.
24937 .nextp
24938 \"LOCAL@_SCAN@_ACCEPT@_FREEZE"\
24939
24940 This behaves as \\LOCAL@_SCAN@_ACCEPT\\, except that the accepted message is
24941 queued without immediate delivery, and is frozen.
24942 .nextp
24943 \"LOCAL@_SCAN@_ACCEPT@_QUEUE"\
24944
24945 This behaves as \\LOCAL@_SCAN@_ACCEPT\\, except that the accepted message is
24946 queued without immediate delivery.
24947 .nextp
24948 \"LOCAL@_SCAN@_REJECT"\
24949
24950 The message is rejected; the returned text is used as an error message which is
24951 passed back to the sender and which is also logged. Newlines are permitted --
24952 they cause a multiline response for SMTP rejections, but are converted to
24953 \"@\n"\ in log lines.
24954 If no message is given, `Administrative prohibition' is used.
24955 .nextp
24956 \"LOCAL@_SCAN@_TEMPREJECT"\
24957
24958 The message is temporarily rejected; the returned text is used as an error
24959 message as for \\LOCAL@_SCAN@_REJECT\\. If no message is given, `Temporary
24960 local problem' is used.
24961 .nextp
24962 \"LOCAL@_SCAN@_REJECT@_NOLOGHDR"\
24963
24964 This behaves as \\LOCAL@_SCAN@_REJECT\\, except that the header of the rejected
24965 message is not written to the reject log. It has the effect of unsetting the
24966 \rejected@_header\ log selector for just this rejection. If \rejected@_header\
24967 is already unset (see the discussion of the \log@_selection\ option in section
24968 ~~SECTlogselector), this code is the same as \\LOCAL@_SCAN@_REJECT\\.
24969
24970 .nextp
24971 \"LOCAL@_SCAN@_TEMPREJECT@_NOLOGHDR"\
24972
24973 This code is a variation of \\LOCAL@_SCAN@_TEMPREJECT\\ in the same way that
24974 \\LOCAL__SCAN__REJECT__NOLOGHDR\\ is a variation of \\LOCAL@_SCAN@_REJECT\\.
24975 .endp
24976
24977 If the message is not being received by interactive SMTP, rejections are
24978 reported by writing to \stderr\ or by sending an email, as configured by the
24979 \-oe-\ command line options.
24980
24981
24982 .section Configuration options for local@_scan()
24983 .rset SECTconoptloc "~~chapter.~~section"
24984 .index \*local@_scan()*\ function||configuration options
24985 It is possible to have option settings in the main configuration file
24986 that set values in static variables in the \*local@_scan()*\ module. If you
24987 want to do this, you must have the line
24988 .display asis
24989 LOCAL_SCAN_HAS_OPTIONS=yes
24990 .endd
24991 in your \(Local/Makefile)\ when you build Exim. (This line is in
24992 \(OS/Makefile-Default)\, commented out). Then, in the \*local@_scan()*\ source
24993 file, you must define static variables to hold the option values, and a table to
24994 define them.
24995
24996 The table must be a vector called \local@_scan@_options\, of type
24997 \"optionlist"\. Each entry is a triplet, consisting of a name, an option type,
24998 and a pointer to the variable that holds the value. The entries must appear in
24999 alphabetical order. Following \local@_scan@_options\ you must also define a
25000 variable called \local@_scan@_options@_count\ that contains the number of
25001 entries in the table. Here is a short example, showing two kinds of option:
25002 .display asis
25003 static int my_integer_option = 42;
25004 static uschar *my_string_option = US"a default string";
25005
25006 optionlist local_scan_options[] = {
25007   { "my_integer", opt_int,       &my_integer_option },
25008   { "my_string",  opt_stringptr, &my_string_option }
25009 };
25010 int local_scan_options_count =
25011   sizeof(local_scan_options)/sizeof(optionlist);
25012 .endd
25013 The values of the variables can now be changed from Exim's runtime
25014 configuration file by including a local scan section as in this example:
25015 .display asis
25016 begin local_scan
25017 my_integer = 99
25018 my_string = some string of text...
25019 .endd
25020 The available types of option data are as follows:
25021
25022 .startitems
25023
25024 .item opt@_bool
25025 This specifies a boolean (true/false) option. The address should point to
25026 a variable of type \"BOOL"\, which will be set to \\TRUE\\ or \\FALSE\\, which
25027 are macros that are defined as `1' and `0', respectively. If you want to detect
25028 whether such a variable has been set at all, you can initialize it to
25029 \\TRUE@_UNSET\\. (BOOL variables are integers underneath, so can hold more than
25030 two values.)
25031
25032 .item "opt@_fixed"
25033 This specifies a fixed point number, such as is used for load averages.
25034 The address should point to a variable of type \"int"\. The value is stored
25035 multiplied by 1000, so, for example, 1.4142 is truncated and stored as 1414.
25036
25037 .item "opt@_int"
25038 This specifies an integer; the address should point to a variable of type
25039 \"int"\. The value may be specified in any of the integer formats accepted by
25040 Exim.
25041
25042 .item "opt@_mkint"
25043 This is the same as \opt@_int\, except that when such a value is output in a
25044 \-bP-\ listing, if it is an exact number of kilobytes or megabytes, it is
25045 printed with the suffix K or M.
25046
25047 .item "opt@_octint"
25048 This also specifies an integer, but the value is always interpeted as an
25049 octal integer, whether or not it starts with the digit zero, and it is
25050 always output in octal.
25051
25052 .item "opt@_stringptr"
25053 This specifies a string value; the address must be a pointer to a
25054 variable that points to a string (for example, of type \"uschar $*$"\).
25055
25056 .item "opt@_time"
25057 This specifies a time interval value. The address must point to a variable of
25058 type \"int"\. The value that is placed there is a number of seconds.
25059
25060 .enditems
25061
25062 If the \-bP-\ command line option is followed by \"local@_scan"\, Exim prints
25063 out the values of all the \*local@_scan()*\ options.
25064
25065
25066 .section Available Exim variables
25067 .index \*local@_scan()*\ function||available Exim variables
25068 The header \(local@_scan.h)\ gives you access to a number of C variables.
25069 These are the only ones that are guaranteed to be maintained from release to
25070 release. Note, however, that you can obtain the value of any Exim variable by
25071 calling \*expand@_string()*\. The exported variables are as follows:
25072
25073 .startitems
25074
25075 .item "unsigned int debug@_selector"
25076 This variable is set to zero when no debugging is taking place. Otherwise, it
25077 is a bitmap of debugging selectors. Two bits are identified for use in
25078 \*local@_scan()*\; they are defined as macros:
25079 .numberpars $.
25080 The \"D@_v"\ bit is set when \-v-\ was present on the command line. This is a
25081 testing option that is not privileged -- any caller may set it. All the
25082 other selector bits can be set only by admin users.
25083 .nextp
25084 The \"D@_local@_scan"\ bit is provided for use by \*local@_scan()*\; it is set
25085 by the \"+local@_scan"\ debug selector. It is not included in the default set
25086 of debugging bits.
25087 .endp
25088 Thus, to write to the debugging output only when \"+local@_scan"\ has been
25089 selected, you should use code like this:
25090 .display asis
25091 if ((debug_selector & D_local_scan) != 0)
25092   debug_printf("xxx", ...);
25093 .endd
25094
25095 .item "uschar *expand@_string@_message"
25096 After a failing call to \*expand@_string()*\ (returned value NULL), the
25097 variable \expand__string__message\ contains the error message, zero-terminated.
25098
25099 .item "header@_line *header@_list"
25100 A pointer to a chain of header lines. The \header@_line\ structure is discussed
25101 below.
25102
25103 .item "header@_line *header@_last"
25104 A pointer to the last of the header lines.
25105
25106 .item "uschar *headers@_charset"
25107 The value of the \headers@_charset\ configuration option.
25108
25109 .item "BOOL host@_checking"
25110 This variable is TRUE during a host checking session that is initiated by the
25111 \-bh-\ command line option.
25112
25113 .item "uschar *interface@_address"
25114 The IP address of the interface that received the message, as a string. This
25115 is NULL for locally submitted messages.
25116
25117 .item "int interface@_port"
25118 The port on which this message was received.
25119
25120 .item "uschar *message@_id"
25121 This variable contains the message id for the incoming message as a
25122 zero-terminated string.
25123
25124
25125 .item "uschar *received@_protocol"
25126 The name of the protocol by which the message was received.
25127
25128 .item "int recipients@_count"
25129 The number of accepted recipients.
25130
25131 .item "recipient@_item *recipients@_list"
25132 .index recipient||adding in local scan
25133 .index recipient||removing in local scan
25134 The list of accepted recipients, held in a vector of length
25135 \recipients@_count\. The \recipient@_item\ structure is discussed below. You
25136 can add additional recipients by calling \*receive@_add@_recipient()*\ (see
25137 below). You can delete recipients by removing them from the vector and adusting
25138 the value in \recipients@_count\. In particular, by setting \recipients@_count\
25139 to zero you remove all recipients. If you then return the value
25140 \"LOCAL@_SCAN@_ACCEPT"\, the message is accepted, but immediately blackholed.
25141 To replace the recipients, set \recipients@_count\ to zero and then call
25142 \*receive@_add@_recipient()*\ as often as needed.
25143
25144 .item "uschar *sender@_address"
25145 The envelope sender address. For bounce messages this is the empty string.
25146
25147 .item "uschar *sender@_host@_address"
25148 The IP address of the sending host, as a string. This is NULL for
25149 locally-submitted messages.
25150
25151 .item "uschar *sender@_host@_authenticated"
25152 The name of the authentication mechanism that was used, or NULL if the message
25153 was not received over an authenticated SMTP connection.
25154
25155 .item "uschar *sender@_host@_name"
25156 The name of the sending host, if known.
25157
25158 .item "int sender@_host@_port"
25159 The port on the sending host.
25160
25161 .item "BOOL smtp@_input"
25162 This variable is TRUE for all SMTP input, including BSMTP.
25163
25164 .item "BOOL smtp@_batched@_input"
25165 This variable is TRUE for BSMTP input.
25166
25167 .item "int store@_pool"
25168 The contents of this variable control which pool of memory is used for new
25169 requests. See section ~~SECTmemhanloc for details.
25170
25171 .enditems
25172
25173
25174 .section Structure of header lines
25175 The \header@_line\ structure contains the members listed below.
25176 You can add additional header lines by calling the \*header@_add()*\ function
25177 (see below). You can cause header lines to be ignored (deleted) by setting
25178 their type to $*$.
25179
25180 .startitems
25181
25182 .item "struct header@_line *next"
25183 A pointer to the next header line, or NULL for the last line.
25184
25185 .item "int type"
25186 A code identifying certain headers that Exim recognizes. The codes are printing
25187 characters, and are documented in chapter ~~CHAPspool of this manual. Notice in
25188 particular that any header line whose type is $*$ is not transmitted with the
25189 message. This flagging is used for header lines that have been rewritten, or
25190 are to be removed (for example, ::Envelope-sender:: header lines.) Effectively,
25191 $*$ means `deleted'.
25192
25193 .item "int slen"
25194 The number of characters in the header line, including the terminating and any
25195 internal newlines.
25196
25197 .item "uschar *text"
25198 A pointer to the text of the header. It always ends with a newline, followed by
25199 a zero byte. Internal newlines are preserved.
25200
25201 .enditems
25202
25203
25204
25205 .section Structure of recipient items
25206 The \recipient@_item\ structure contains these members:
25207
25208 .startitems
25209
25210 .item "uschar *address"
25211 This is a pointer to the recipient address as it was received.
25212
25213 .item "int pno"
25214 This is used in later Exim processing when top level addresses are created
25215 by the \one@_time\ option. It is not relevant at the time \*local@_scan()*\ is
25216 run and
25217 must always contain -1 at this stage.
25218
25219 .item "uschar *errors@_to"
25220 If this value is not NULL, bounce messages caused by failing to deliver to the
25221 recipient are sent to the address it contains. In other words, it overrides the
25222 envelope sender for this one recipient. (Compare the \errors@_to\ generic
25223 router option.)
25224 If a \*local@_scan()*\ function sets an \errors@_to\ field to an unqualified
25225 address, Exim qualifies it using the domain from \qualify@_recipient\.
25226 When \*local@_scan()*\ is called, the \errors@_to\ field is NULL for all
25227 recipients.
25228 .enditems
25229
25230
25231 .section Available Exim functions
25232 .index \*local@_scan()*\ function||available Exim functions
25233 The header \(local@_scan.h)\ gives you access to a number of Exim functions.
25234 These are the only ones that are guaranteed to be maintained from release to
25235 release:
25236
25237 .startitems
25238
25239 .item "pid@_t child@_open(uschar **argv, uschar **envp, int newumask, int *infdptr, int *outfdptr, BOOL make@_leader)"
25240 This function creates a child process that runs the command specified by
25241 \argv\. The environment for the process is specified by \envp\, which can be
25242 NULL if no environment variables are to be passed. A new umask is supplied for
25243 the process in \newumask\.
25244
25245 Pipes to the standard input and output of the new process are set up
25246 and returned to the caller via the \infdptr\ and \outfdptr\ arguments. The
25247 standard error is cloned to the standard output. If there are any file
25248 descriptors `in the way' in the new process, they are closed. If the final
25249 argument is TRUE, the new process is made into a process group leader.
25250
25251 The function returns the pid of the new process, or -1 if things go wrong.
25252
25253
25254 .item "int child@_close(pid@_t pid, int timeout)"
25255 This function waits for a child process to terminate, or for a timeout (in
25256 seconds) to expire. A timeout value of zero means wait as long as it takes. The
25257 return value is as follows:
25258 .numberpars $.
25259 >= 0
25260
25261 The process terminated by a normal exit and the value is the process ending
25262 status.
25263 .nextp
25264 < 0 and > --256
25265
25266 The process was terminated by a signal and the value is the negation of the
25267 signal number.
25268 .nextp
25269 --256
25270
25271 The process timed out.
25272 .nextp
25273 --257
25274
25275 The was some other error in wait(); \errno\ is still set.
25276 .endp
25277
25278
25279 .item "pid@_t child@_open@_exim(int *fd)"
25280 This function provide you with a means of submitting a new message to
25281 Exim. (Of course, you can also call \(/usr/sbin/sendmail)\ yourself if you
25282 want, but this packages it all up for you.) The function creates a pipe,
25283 forks a subprocess that is running
25284 .display asis
25285 exim -t -oem -oi -f <>
25286 .endd
25287 and returns to you (via the \"int *"\ argument) a file descriptor for the pipe
25288 that is connected to the standard input. The yield of the function is the PID
25289 of the subprocess. You can then write a message to the file descriptor, with
25290 recipients in ::To::, ::Cc::, and/or ::Bcc:: header lines.
25291
25292 When you have finished, call \*child@_close()*\ to wait for the process to
25293 finish and to collect its ending status. A timeout value of zero is usually
25294 fine in this circumstance. Unless you have made a mistake with the recipient
25295 addresses, you should get a return code of zero.
25296
25297 .item "void debug@_printf(char *, ...)"
25298 This is Exim's debugging function, with arguments as for \*(printf()*\. The
25299 output is written to the standard error stream. If no debugging is selected,
25300 calls to \*debug@_printf()*\ have no effect. Normally, you should make calls
25301 conditional on the \"local@_scan"\ debug selector by coding like this:
25302 .display asis
25303 if ((debug_selector & D_local_scan) != 0)
25304   debug_printf("xxx", ...);
25305 .endd
25306
25307 .item "uschar *expand@_string(uschar *string)"
25308 This is an interface to Exim's string expansion code. The return value is the
25309 expanded string, or NULL if there was an expansion failure.
25310 The C variable \expand@_string@_message\ contains an error message after an
25311 expansion failure. If expansion does not change the string, the return value is
25312 the pointer to the input string. Otherwise, the return value points to a new
25313 block of memory that was obtained by a call to \*store@_get()*\. See section
25314 ~~SECTmemhanloc below for a discussion of memory handling.
25315
25316 .item "void header@_add(int type, char *format, ...)"
25317 .em
25318 This function allows you to an add additional header line at the end of the 
25319 existing ones.
25320 .nem
25321 The first argument is the type, and should normally be a space character. The
25322 second argument is a format string and any number of substitution arguments as
25323 for \*sprintf()*\. You may include internal newlines if you want, and you must
25324 ensure that the string ends with a newline.
25325
25326 .em
25327 .item "void header@_add@_at@_position(BOOL after, uschar *name, BOOL topnot, int type, char *$nh{format}, ...)"
25328 This function adds a new header line at a specified point in the header
25329 chain. The header itself is specified as for \*header@_add()*\.
25330
25331 If \name\ is NULL, the new header is added at the end of the chain if \after\
25332 is true, or at the start if \after\ is false. If \name\ is not NULL, the header
25333 lines are searched for the first non-deleted header that matches the name. If
25334 one is found, the new header is added before it if \after\ is false. If \after\
25335 is true, the new header is added after the found header and any adjacent
25336 subsequent ones with the same name (even if marked `deleted'). If no matching
25337 non-deleted header is found, the \topnot\ option controls where the header is
25338 added. If it is true, addition is at the top; otherwise at the bottom. Thus, to
25339 add a header after all the ::Received:: headers, or at the top if there are no
25340 ::Received:: headers, you could use
25341 .display asis
25342 header_add_at_position(TRUE, US"Received", TRUE, 
25343   ' ', "X-xxx: ...");
25344 .endd
25345 Normally, there is always at least one non-deleted ::Received:: header, but
25346 there may not be if \received@_header@_text\ expands to an empty string.
25347
25348
25349 .item "void header@_remove(int occurrence, uschar *name)"
25350 This function removes header lines. If \occurrence\ is zero or negative, all
25351 occurrences of the header are removed. If occurrence is greater than zero, that
25352 particular instance of the header is removed. If no header(s) can be found that
25353 match the specification, the function does nothing.
25354
25355
25356 .item "BOOL header@_testname(header@_line *hdr, uschar *name, int length, BOOL notdel)"
25357 This function tests whether the given header has the given name. It is not just
25358 a string comparison, because whitespace is permitted between the name and the
25359 colon. If the \notdel\ argument is true, a false return is forced for all
25360 `deleted' headers; otherwise they are not treated specially. For example:
25361 .display asis
25362 if (header_testname(h, US"X-Spam", 6, TRUE)) ...
25363 .endd
25364 .nem
25365
25366
25367 .item "uschar *lss@_b64encode(uschar *cleartext, int length)"
25368 .index base64 encoding||functions for \*local@_scan()*\ use
25369 This function base64-encodes a string, which is passed by address and length.
25370 The text may contain bytes of any value, including zero. The result is passed
25371 back in dynamic memory that is obtained by calling \*store@_get()*\. It is
25372 zero-terminated.
25373
25374 .item "int lss@_b64decode(uschar *codetext, uschar **cleartext)"
25375 This function decodes a base64-encoded string. Its arguments are a
25376 zero-terminated base64-encoded string and the address of a variable that is set
25377 to point to the result, which is in dynamic memory. The length of the
25378 decoded string is the yield of the function. If the input is invalid base64
25379 data, the yield is -1. A zero byte is added to the end of the output string to
25380 make it easy to interpret as a C string (assuming it contains no zeros of its
25381 own). The added zero byte is not included in the returned count.
25382
25383 .item "int lss@_match@_domain(uschar *domain, uschar *list)"
25384 This function checks for a match in a domain list. Domains are always
25385 matched caselessly. The return value is one of the following:
25386 .display
25387 OK     $rm{match succeeded}
25388 FAIL   $rm{match failed}
25389 DEFER  $rm{match deferred}
25390 .endd
25391 DEFER is usually caused by some kind of lookup defer, such as the
25392 inability to contact a database.
25393
25394 .item "int lss@_match@_local@_part(uschar *localpart, uschar *list, BOOL caseless)"
25395 This function checks for a match in a local part list. The third argument
25396 controls case-sensitivity. The return values are as for
25397 \*lss@_match@_domain()*\.
25398
25399 .item "int lss@_match@_address(uschar *address, uschar *list, BOOL caseless)"
25400 This function checks for a match in an address list. The third argument
25401 controls the case-sensitivity of the local part match. The domain is always
25402 matched caselessly. The return values are as for \*lss@_match@_domain()*\.
25403
25404 .item "int lss@_match@_host(uschar *host@_name, uschar *host@_address, uschar *list)"
25405 This function checks for a match in a host list. The most common usage is
25406 expected to be
25407 .display asis
25408 lss_match_host(sender_host_name, sender_host_address, ...)
25409 .endd
25410 An empty address field matches an empty item in the host list. If the
25411 host name is NULL, the name corresponding to \$sender@_host@_address$\ is
25412 automatically looked up if a host name is required to match an item in the
25413 list. The return values are as for \*lss@_match@_domain()*\, but in addition,
25414 \*lss@_match@_host()*\ returns ERROR in the case when it had to look up a host
25415 name, but the lookup failed.
25416
25417 .item "void log@_write(unsigned int selector, int which, char *format, ...)"
25418 This function writes to Exim's log files. The first argument should be zero (it
25419 is concerned with \log@_selector\). The second argument can be \"LOG@_MAIN"\ or
25420 \"LOG@_REJECT"\ or
25421 \"LOG@_PANIC"\ or the inclusive `or' of any combination of them. It specifies
25422 to which log or logs the message is written.
25423 The remaining arguments are a format and relevant insertion arguments. The
25424 string should not contain any newlines, not even at the end.
25425
25426
25427 .item "void receive@_add@_recipient(uschar *address, int pno)"
25428 This function adds an additional recipient to the message. The first argument
25429 is the recipient address. If it is unqualified (has no domain), it is qualified
25430 with the \qualify@_recipient\ domain. The second argument must always be -1.
25431
25432 This function does not allow you to specify a private \errors@_to\ address (as
25433 described with the structure of \recipient@_item\ above), because it pre-dates
25434 the addition of that field to the structure. However, it is easy to add such a
25435 value afterwards. For example:
25436 .display asis
25437 receive_add_recipient(US"monitor@mydom.example", -1);
25438 recipients_list[recipients_count-1].errors_to =
25439   US"postmaster@mydom.example";
25440 .endd
25441
25442 .em
25443 .item "BOOL receive@_remove@_recipient(uschar *recipient)"
25444 This is a convenience function to remove a named recipient from the
25445 list of recipients. It returns true if a recipient was removed, and
25446 false if no matching recipient could be found. The argument must be a
25447 complete email address.
25448 .nem
25449
25450
25451 .item "uschar *rfc2047@_decode(uschar *string, BOOL lencheck, uschar *target, int zeroval, int *lenptr, uschar **error)"
25452 This function decodes strings that are encoded according to RFC 2047. Typically
25453 these are the contents of header lines. First, each encoded `word' is decoded
25454 from the Q or B encoding into a byte-string. Then, if provided with the name of
25455 a charset encoding, and if the \*iconv()*\ function is available, an attempt is
25456 made  to translate the result to the named character set. If this fails, the
25457 binary string is returned with an error message.
25458
25459 The first argument is the string to be decoded. If \lencheck\ is TRUE, the
25460 maximum MIME word length is enforced. The third argument is the target
25461 encoding, or NULL if no translation is wanted.
25462
25463 .index binary zero||in RFC 2047 decoding
25464 If a binary zero is encountered in the decoded string, it is replaced by the
25465 contents of the \zeroval\ argument. For use with Exim headers, the value must
25466 not be 0 because header lines are handled as zero-terminated strings.
25467
25468 The function returns the result of processing the string, zero-terminated; if
25469 \lenptr\ is not NULL, the length of the result is set in the variable to which
25470 it points. When \zeroval\ is 0, \lenptr\ should not be NULL.
25471
25472 If an error is encountered, the function returns NULL and uses the \error\
25473 argument to return an error message. The variable pointed to by \error\ is set
25474 to NULL if there is no error; it may be set non-NULL even when the function
25475 returns a non-NULL value if decoding was successful, but there was a problem
25476 with translation.
25477
25478
25479 .item "int smtp@_fflush(void)"
25480 This function is used in conjunction with \*smtp@_printf()*\, as described
25481 below.
25482
25483 .item "void smtp@_printf(char *, ...)"
25484 The arguments of this function are like \*printf()*\; it writes to the SMTP
25485 output stream. You should use this function only when there is an SMTP output
25486 stream, that is, when the incoming message is being received via interactive
25487 SMTP. This is the case when \smtp@_input\ is TRUE and \smtp@_batched@_input\ is
25488 FALSE. If you want to test for an incoming message from another host (as
25489 opposed to a local process that used the \-bs-\ command line option), you can
25490 test the value of \sender@_host@_address\, which is non-NULL when a remote host
25491 is involved.
25492
25493 If an SMTP TLS connection is established, \*smtp@_printf()*\ uses the TLS
25494 output function, so it can be used for all forms of SMTP connection.
25495
25496 Strings that are written by \*smtp@_printf()*\ from within \*local@_scan()*\
25497 must start with an appropriate response code: 550 if you are going to return
25498 \\LOCAL@_SCAN@_REJECT\\, 451 if you are going to return
25499 \\LOCAL@_SCAN@_TEMPREJECT\\, and 250 otherwise. Because you are writing the
25500 initial lines of a multi-line response, the code must be followed by a hyphen
25501 to indicate that the line is not the final response line. You must also ensure
25502 that the lines you write terminate with CRLF. For example:
25503 .display asis
25504 smtp_printf("550-this is some extra info\r\n");
25505 return LOCAL_SCAN_REJECT;
25506 .endd
25507 Note that you can also create multi-line responses by including newlines in
25508 the data returned via the \return@_text\ argument. The added value of using
25509 \*smtp@_printf()*\ is that, for instance, you could introduce delays between
25510 multiple output lines.
25511
25512 The \*smtp@_printf()*\ function does not return any error indication, because it
25513 does not automatically flush pending output, and therefore does not test
25514 the state of the stream. (In the main code of Exim, flushing and error
25515 detection is done when Exim is ready for the next SMTP input command.) If
25516 you want to flush the output and check for an error (for example, the
25517 dropping of a TCP/IP connection), you can call \*smtp@_fflush()*\, which has no
25518 arguments. It flushes the output stream, and returns a non-zero value if there
25519 is an error.
25520
25521 .item "void *store@_get(int)"
25522 This function accesses Exim's internal store (memory) manager. It gets a new
25523 chunk of memory whose size is given by the argument. Exim bombs out if it ever
25524 runs out of memory. See the next section for a discussion of memory handling.
25525
25526 .item "void *store@_get@_perm(int)"
25527 This function is like \*store@_get()*\, but it always gets memory from the
25528 permanent pool. See the next section for a discussion of memory handling.
25529
25530 .item "uschar *string@_copy(uschar *string)"
25531 .item "uschar *string@_copyn(uschar *string, int length)" 0
25532 .item "uschar *string@_sprintf(char *format, ...)" 0
25533 These three functions create strings using Exim's dynamic memory facilities.
25534 The first makes a copy of an entire string. The second copies up to a maximum
25535 number of characters, indicated by the second argument. The third uses a format
25536 and insertion arguments to create a new string. In each case, the result is a
25537 pointer to a new string
25538 in the current memory pool. See the next section for more discussion.
25539
25540 .enditems
25541
25542
25543
25544 .section More about Exim's memory handling
25545 .rset SECTmemhanloc "~~chapter.~~section"
25546 .index \*local@_scan()*\ function||memory handling
25547 No function is provided for freeing memory, because that is never needed.
25548 The dynamic memory that Exim uses when receiving a message is automatically
25549 recycled if another message is received by the same process (this applies only
25550 to incoming SMTP connections -- other input methods can supply only one message
25551 at a time). After receiving the last message, a reception process terminates.
25552
25553 Because it is recycled, the normal dynamic memory cannot be used for holding
25554 data that must be preserved over a number of incoming messages on the same SMTP
25555 connection. However, Exim in fact uses two pools of dynamic memory; the second
25556 one is not recycled, and can be used for this purpose.
25557
25558 If you want to allocate memory that remains available for subsequent messages
25559 in the same SMTP connection, you should set
25560 .display asis
25561 store_pool = POOL_PERM
25562 .endd
25563 before calling the function that does the allocation. There is no need to
25564 restore the value if you do not need to; however, if you do want to revert to
25565 the normal pool, you can either restore the previous value of \store@_pool\ or
25566 set it explicitly to \\POOL@_MAIN\\.
25567
25568 The pool setting applies to all functions that get dynamic memory, including
25569 \*expand@_string()*\, \*store@_get()*\, and the \*string@_xxx()*\ functions.
25570 There is also a convenience function called \*store__get__perm()*\ that gets a
25571 block of memory from the permanent pool while preserving the value of
25572 \store@_pool\.
25573
25574
25575
25576
25577
25578 .
25579 .
25580 .
25581 .
25582 . ============================================================================
25583 .chapter System-wide message filtering
25584 .set runningfoot "system filtering"
25585 .rset CHAPsystemfilter "~~chapter"
25586 .index filter||system filter
25587 .index filtering all mail
25588 .index system filter
25589 The previous chapters (on ACLs and the local scan function) describe checks
25590 that can be applied to messages before they are accepted by a host. There is
25591 also a mechanism for checking messages once they have been received, but before
25592 they are delivered. This is called the $it{system filter}.
25593
25594 The system filter operates in a similar manner to users' filter files, but it
25595 is run just once per message (however many recipients the message has).
25596 It should not normally be used as a substitute for routing, because \deliver\
25597 commands in a system router provide new envelope recipient addresses.
25598 The system filter must be an Exim filter. It cannot be a Sieve filter.
25599
25600 The system filter is run at the start of a delivery attempt, before any routing
25601 is done. If a message fails to be completely delivered at the first attempt,
25602 the system filter is run again at the start of every retry.
25603 If you want your filter to do something only once per message, you can make use
25604 of the \first@_delivery\ condition in an \if\ command in the filter to prevent
25605 it happening on retries.
25606
25607 \**Warning**\: Because the system filter runs just once, variables that are
25608 specific to individual recipient addresses, such as \$local@_part$\ and
25609 \$domain$\, are not set, and the `personal' condition is not meaningful. If you
25610 want to run a centrally-specified filter for each recipient address
25611 independently, you can do so by setting up a suitable \%redirect%\ router, as
25612 described in section ~~SECTperaddfil below.
25613
25614 .section Specifying a system filter
25615 .index uid (user id)||system filter
25616 .index gid (group id)||system filter
25617 The name of the file that contains the system filter must be specified by
25618 setting \system@_filter\. If you want the filter to run under a uid and gid
25619 other than root, you must also set \system@_filter@_user\ and
25620 \system@_filter@_group\ as appropriate. For example:
25621 .display asis
25622 system_filter = /etc/mail/exim.filter
25623 system_filter_user = exim
25624 .endd
25625 If a system filter generates any deliveries directly to files or pipes (via the
25626 \save\ or \pipe\ commands), transports to handle these deliveries must be
25627 specified by setting \system@_filter@_file@_transport\ and
25628 \system@_filter@_pipe@_transport\, respectively. Similarly,
25629 \system@_filter@_reply@_transport\ must be set to handle any messages generated
25630 by the \reply\ command.
25631
25632 .section Testing a system filter
25633 You can run simple tests of a system filter in the same way as for a user
25634 filter, but you should use \-bF-\ rather than \-bf-\, so that features that
25635 are permitted only in system filters are recognized.
25636 .em
25637 If you want to test the combined effect of a system filter and a user filter, 
25638 you can use both \-bF-\ and \-bf-\ on the same command line.
25639 .nem
25640
25641 .section Contents of a system filter
25642 The language used to specify system filters is the same as for users' filter
25643 files. It is described in the separate end-user document \*Exim's interface to
25644 mail filtering*\. However, there are some additional features that are
25645 available only in system filters; these are described in subsequent sections.
25646 If they are encountered in a user's filter file or when testing with \-bf-\,
25647 they cause errors.
25648
25649 .index frozen messages||manual thaw, testing in filter
25650 There are two special conditions which, though available in users' filter
25651 files, are designed for use in system filters. The condition \first@_delivery\
25652 is true only for the first attempt at delivering a message, and
25653 \manually@_thawed\ is true only if the message has been frozen, and
25654 subsequently thawed by an admin user. An explicit forced delivery counts as a
25655 manual thaw, but thawing as a result of the \auto__thaw\ setting does not.
25656
25657 \**Warning**\: If a system filter uses the \first@_delivery\ condition to
25658 specify an `unseen' (non-significant) delivery, and that delivery does not
25659 succeed, it will not be tried again.
25660 If you want Exim to retry an unseen delivery until it succeeds, you should
25661 arrange to set it up every time the filter runs.
25662
25663 When a system filter finishes running, the values of the variables \$n0$\ --
25664 \$n9$\ are copied into \$sn0$\ -- \$sn9$\ and are thereby made available to
25665 users' filter files. Thus a system filter can, for example, set up `scores' to
25666 which users' filter files can refer.
25667
25668
25669 .section Additional variable for system filters
25670 The expansion variable \$recipients$\, containing a list of all the recipients
25671 of the message (separated by commas and white space), is available in system
25672 filters. It is not available in users' filters for privacy reasons.
25673
25674
25675 .section Defer, freeze, and fail commands for system filters
25676 .index freezing messages
25677 .index message||freezing
25678 .index message||forced failure
25679 .index \fail\||in system filter
25680 .index \freeze\ in system filter
25681 .index \defer\ in system filter
25682 There are three extra commands (\defer\, \freeze\ and \fail\) which are always
25683 available in system filters, but are not normally enabled in users' filters.
25684 (See the \allow@_defer\,
25685 \allow@_freeze\ and \allow@_fail\ options for the \%redirect%\ router.) These
25686 commands can optionally be followed by the word \text\ and a string containing
25687 an error message, for example:
25688 .display asis
25689 fail text "this message looks like spam to me"
25690 .endd
25691 The keyword \text\ is optional if the next character is a double quote.
25692
25693 The \defer\ command defers delivery of the original recipients of the message.
25694 The \fail\ command causes all the original recipients to be failed, and a
25695 bounce message to be created. The \freeze\ command suspends all delivery
25696 attempts for the original recipients. In all cases, any new deliveries that are
25697 specified by the filter are attempted as normal after the filter has run.
25698
25699 The \freeze\ command is ignored if the message has been manually unfrozen and
25700 not manually frozen since. This means that automatic freezing by a system
25701 filter can be used as a way of checking out suspicious messages. If a message
25702 is found to be all right, manually unfreezing it allows it to be delivered.
25703
25704 .index log||\fail\ command log line
25705 .index \fail\||log line, reducing
25706 The text given with a fail command is used as part of the bounce message as
25707 well as being written to the log. If the message is quite long, this can fill
25708 up a lot of log space when such failures are common. To reduce the size of the
25709 log message, Exim interprets the text in a special way if it starts with the
25710 two characters \"@<@<"\ and contains \"@>@>"\ later. The text between these two
25711 strings is written to the log, and the rest of the text is used in the bounce
25712 message. For example:
25713 .display asis
25714 fail "<<filter test 1>>Your message is rejected \
25715      because it contains attachments that we are \
25716      not prepared to receive."
25717 .endd
25718
25719 .index loop||caused by \fail\
25720 Take great care with the \fail\ command when basing the decision to fail on the
25721 contents of the message, because the bounce message will of course include the
25722 contents of the original message and will therefore trigger the \fail\ command
25723 again (causing a mail loop) unless steps are taken to prevent this. Testing the
25724 \error@_message\ condition is one way to prevent this. You could use, for
25725 example
25726 .display asis
25727 if $message_body contains "this is spam" and not error_message
25728   then fail text "spam is not wanted here" endif
25729 .endd
25730 though of course that might let through unwanted bounce messages. The
25731 alternative is clever checking of the body and/or headers to detect bounces
25732 generated by the filter.
25733
25734 The interpretation of a system filter file ceases after a
25735 \defer\,
25736 \freeze\, or \fail\ command is obeyed. However, any deliveries that were set up
25737 earlier in the filter file are honoured, so you can use a sequence such as
25738 .display asis
25739 mail ...
25740 freeze
25741 .endd
25742 to send a specified message when the system filter is freezing (or deferring or
25743 failing) a message. The normal deliveries for the message do not, of course,
25744 take place.
25745
25746
25747 .section Adding and removing headers in a system filter
25748 .rset SECTaddremheasys "~~chapter.~~section"
25749 .index header lines||adding, in system filter
25750 .index header lines||removing, in system filter
25751 .index filter||header lines, adding/removing
25752 Two filter commands that are available only in system filters are:
25753 .display
25754 headers add <<string>>
25755 headers remove <<string>>
25756 .endd
25757 The argument for the \headers add\ is a string that is expanded and then added
25758 to the end of the message's headers. It is the responsibility of the filter
25759 maintainer to make sure it conforms to RFC 2822 syntax. Leading white space is
25760 ignored, and if the string is otherwise empty, or if the expansion is forced to
25761 fail, the command has no effect.
25762
25763 You can use `@\n' within the string, followed by white space, to specify
25764 continued header lines. More than one header may be added in one command by
25765 including `@\n' within the string without any following white space. For
25766 example:
25767 .display asis
25768 headers add "X-header-1: ....\n  \
25769              continuation of X-header-1 ...\n\
25770              X-header-2: ...."
25771 .endd
25772 Note that the header line continuation white space after the first newline must
25773 be placed before the backslash that continues the input string, because white
25774 space after input continuations is ignored.
25775
25776 The argument for \headers remove\ is a colon-separated list of header names.
25777 This command applies only to those headers that are stored with the message;
25778 those that are added at delivery time (such as ::Envelope-To:: and
25779 ::Return-Path::) cannot be removed by this means. If there is more than one
25780 header with the same name, they are all removed.
25781
25782 .em
25783 The \headers\ command in a system filter makes an immediate change to the set
25784 of header lines that was received with the message (with possible additions 
25785 from ACL processing). Subsequent commands in the system filter operate on the
25786 modified set, which also forms the basis for subsequent message delivery. 
25787 Unless further modified during routing or transporting, this set of headers is 
25788 used for all recipients of the message.
25789
25790 During routing and transporting, the variables that refer to the contents of
25791 header lines refer only to those lines that are in this set. Thus, header lines
25792 that are added by a system filter are visible to users' filter files and to all
25793 routers and transports. This contrasts with the manipulation of header lines by
25794 routers and transports, which is not immediate, but which instead is saved up 
25795 until the message is actually being written (see section ~~SECTheadersaddrem).
25796
25797 If the message is not delivered at the first attempt, header lines that were
25798 added by the system filter are stored with the message, and so are still
25799 present at the next delivery attempt. Header lines that were removed are still
25800 present, but marked `deleted' so that they are not transported with the
25801 message. For this reason, it is usual to make the \headers\ command conditional
25802 on \first@_delivery\ so that the set of header lines is not modified more than 
25803 once.
25804
25805 Because header modification in a system filter acts immediately, you have to 
25806 use an indirect approach if you want to modify the contents of a header line. 
25807 For example:
25808 .display asis
25809 headers add "Old-Subject: $h_subject:"
25810 headers remove "Subject"
25811 headers add "Subject: new subject (was: $h_old-subject:)"
25812 headers remove "Old-Subject"
25813 .endd
25814 .nem
25815
25816
25817
25818 .section Setting an errors address in a system filter
25819 .index envelope sender
25820 In a system filter, if a \deliver\ command is followed by
25821 .display
25822 errors@_to <<some address>>
25823 .endd
25824 in order to change the envelope sender (and hence the error reporting) for that
25825 delivery, any address may be specified. (In a user filter, only the current
25826 user's address can be set.) For example, if some mail is being monitored, you
25827 might use
25828 .display asis
25829 unseen deliver monitor@spying.example errors_to root@local.example
25830 .endd
25831 to take a copy which would not be sent back to the normal error reporting
25832 address if its delivery failed.
25833
25834
25835 .section Per-address filtering
25836 .rset SECTperaddfil "~~chapter.~~section"
25837 In contrast to the system filter, which is run just once per message for each
25838 delivery attempt, it is also possible to set up a system-wide filtering
25839 operation that runs once for each recipient address. In this case, variables
25840 such as \$local@_part$\ and \$domain$\ can be used, and indeed, the choice of
25841 filter file could be made dependent on them. This is an example of a router
25842 which implements such a filter:
25843 .display asis
25844 central_filter:
25845 .newline
25846   check_local_user
25847 .newline
25848   driver = redirect
25849   domains = +local_domains
25850   file = /central/filters/$local_part
25851   no_verify
25852   allow_filter
25853   allow_freeze
25854 .endd
25855 The filter is run in a separate process under its own uid. Therefore, either
25856 \check@_local@_user\ must be set (as above), in which case the filter is run as
25857 the local user, or the \user\ option must be used to specify which user to use.
25858 If both are set, \user\ overrides.
25859
25860 Care should be taken to ensure that none of the commands in the filter file
25861 specify a significant delivery if the message is to go on to be delivered to
25862 its intended recipient. The router will not then claim to have dealt with the
25863 address, so it will be passed on to subsequent routers to be delivered in the
25864 normal way.
25865
25866
25867
25868
25869
25870
25871 .
25872 .
25873 .
25874 .
25875 . ============================================================================
25876 .chapter Message processing
25877 .set runningfoot "message processing"
25878 .rset CHAPmsgproc "~~chapter"
25879 .index message||general processing
25880 Exim performs various transformations on the sender and recipient addresses of
25881 all messages that it handles, and also on the messages' header lines. Some of
25882 these are optional and configurable, while others always take place. All of
25883 this processing, except rewriting as a result of routing, and the addition or
25884 removal of header lines while delivering, happens when a message is received,
25885 before it is placed on Exim's queue.
25886
25887 Some of the automatic processing takes place by default only for
25888 `locally-originated' messages. This adjective is used to describe messages that
25889 are not received over TCP/IP, but instead are passed to an Exim process on its
25890 standard input. This includes the interactive `local SMTP' case that is set up
25891 by the \-bs-\ command line option. 
25892
25893 \**Note**\: messages received over TCP/IP on the loopback interface (127.0.0.1
25894 or @:@:1) are not considered to be locally-originated. Exim does not treat the
25895 loopback interface specially in any way.
25896 .em
25897 If you want the loopback interface to be treated specially, you must ensure 
25898 that there are appropriate entries in your ACLs.
25899 .nem
25900
25901
25902 .section Submission mode for non-local messages
25903 .rset SECTsubmodnon "~~chapter.~~section"
25904 .index message||submission
25905 .index submission mode
25906 .em
25907 Processing that happens automatically for locally-originated messages can also
25908 be requested for other messages. The term `submission mode' is used to describe
25909 this state. Submisssion mode is set by the modifier
25910 .display asis
25911 control = submission
25912 .endd
25913 in a \\MAIL\\, \\RCPT\\, or pre-data ACL for an incoming SMTP message (see
25914 sections ~~SECTACLmodi and ~~SECTcontrols). This makes Exim treat the message
25915 as a local submission, and is normally used when the source of the message is
25916 known to be an MUA running on a client host (as opposed to an MTA). For
25917 example, to set submission mode for messages originating on the IPv4 loopback
25918 interface, you could include the following in the \\MAIL\\ ACL:
25919 .display asis
25920 warn  hosts = 127.0.0.1
25921       control = submission
25922 .endd
25923 There are some options that can be used when setting submission mode. A slash 
25924 is used to separate options. For example:
25925 .display asis
25926 control = submission/sender_retain
25927 .endd
25928 Specifying \sender@_retain\ has the effect of setting \local@_sender@_retain\
25929 true and \local@_from@_check\ false for the current incoming message. The first
25930 of these allows an existing ::Sender:: header in the message to remain, and the
25931 second suppresses the check to ensure that ::From:: matches the authenticated
25932 sender. With this setting, Exim still fixes up messages by adding ::Date:: and
25933 ::Message-ID:: header lines if they are missing, but makes no attempt to check
25934 sender authenticity in header lines.
25935
25936 A submission mode setting may also specify a domain to be used when generating 
25937 a ::From:: or ::Sender:: header. For example:
25938 .display asis
25939 control = submission/domain=some.domain
25940 .endd
25941 The domain may be empty. How this value is used is described in sections
25942 ~~SECTthefrohea and ~~SECTthesenhea.
25943 .nem
25944
25945
25946
25947 .section Line endings
25948 .rset SECTlineendings "~~chapter.~~section"
25949 .index line endings
25950 .index carriage return
25951 .index linefeed
25952 RFC 2821 specifies that CRLF (two characters: carriage-return, followed by
25953 linefeed) is the line ending for messages transmitted over the Internet using
25954 SMTP over TCP/IP. However, within individual operating systems, different
25955 conventions are used. For example, Unix-like systems use just LF, but others
25956 use CRLF or just CR.
25957
25958 Exim was designed for Unix-like systems, and internally, it stores messages
25959 using the system's convention of a single LF as a line terminator. When
25960 receiving a message, all line endings are translated to this standard format.
25961 Originally, it was thought that programs that passed messages directly to an
25962 MTA within an operating system would use that system's convention. Experience
25963 has shown that this is not the case; for example, there are Unix applications
25964 that use CRLF in this circumstance. For this reason, and for compatibility with
25965 other MTAs, the way Exim handles line endings for all messages is now as
25966 follows:
25967 .numberpars $.
25968 LF not preceded by CR is treated as a line ending.
25969 .nextp
25970 CR is treated as a line ending; if it is immediately followed by LF, the LF
25971 is ignored.
25972 .nextp
25973 The sequence `CR, dot, CR' does not terminate an incoming SMTP message,
25974 nor a local message in the state where a line containing only a dot is a
25975 terminator.
25976 .nextp
25977 If a bare CR is encountered within a header line, an extra space is added after
25978 the line terminator so as not to end the header line. The reasoning behind this
25979 is that bare CRs in header lines are most likely either to be mistakes, or
25980 people trying to play silly games.
25981 .nextp
25982 If the first header line received in a message ends with CRLF, a subsequent
25983 bare LF in a header line is treated in the same way as a bare CR in a header
25984 line.
25985 .endp
25986
25987
25988
25989 .section Unqualified addresses
25990 .index unqualified addresses
25991 .index address||qualification
25992 By default, Exim expects every envelope address it receives from an external
25993 host to be fully qualified. Unqualified addresses cause negative responses to
25994 SMTP commands. However, because SMTP is used as a means of transporting
25995 messages from MUAs running on personal workstations, there is sometimes a
25996 requirement to accept unqualified addresses from specific hosts or IP networks.
25997
25998 Exim has two options that separately control which hosts may send unqualified
25999 sender or receipient addresses in SMTP commands, namely
26000 \sender__unqualified__hosts\ and \recipient__unqualified__hosts\. In both
26001 cases, if an unqualified address is accepted, it is qualified by adding the
26002 value of \qualify__domain\ or \qualify__recipient\, as appropriate.
26003 .index \qualify@_domain\
26004 .index \qualify@_recipient\
26005
26006 .em
26007 Unqualified addresses in header lines are automatically qualified for messages 
26008 that are locally originated, unless the \-bnq-\ option is given on the command 
26009 line. For messages received over SMTP, unqualified addresses in header lines 
26010 are qualified only if unqualified addresses are permitted in SMTP commands. In 
26011 other words, such qualification is also controlled by 
26012 \sender__unqualified__hosts\ and \recipient__unqualified__hosts\,
26013 .nem
26014
26015
26016 .section The UUCP From line
26017 .index `From' line
26018 .index UUCP||`From' line
26019 .index sender||address
26020 .index \uucp@_from@_pattern\
26021 .index \uucp@_from@_sender\
26022 .index envelope sender
26023 .index Sendmail compatibility||`From' line
26024 Messages that have come from UUCP (and some other applications) often begin
26025 with a line containing the envelope sender and a timestamp, following the word
26026 `From'. Examples of two common formats are:
26027 .display asis
26028 From a.oakley@berlin.mus Fri Jan  5 12:35 GMT 1996
26029 From f.butler@berlin.mus Fri, 7 Jan 97 14:00:00 GMT
26030 .endd
26031 This line precedes the RFC 2822 header lines. For compatibility with Sendmail,
26032 Exim recognizes such lines at the start of messages that are submitted to it
26033 via the command line (that is, on the standard input). It does not recognize
26034 such lines in incoming SMTP messages, unless the sending host matches
26035 \ignore@_fromline@_hosts\ or the \-bs-\ option was used for a local message and
26036 \ignore@_fromline@_local\ is set. The recognition is controlled by a regular
26037 expression that is defined by the \uucp@_from@_pattern\ option, whose default
26038 value matches the two common cases shown above and puts the address that
26039 follows `From' into \$1$\.
26040
26041 .index numerical variables (\$1$\, \$2$\, etc)||in `From ' line handling
26042 When the caller of Exim for a non-SMTP message that contains a `From' line is a
26043 trusted user, the message's sender address is constructed by expanding the
26044 contents of \uucp@_sender@_address\, whose default value is `@$1'. This is then
26045 parsed as an RFC 2822 address. If there is no domain, the local part is
26046 qualified with \qualify@_domain\ unless it is the empty string. However, if the
26047 command line \-f-\ option is used, it overrides the `From' line.
26048
26049 If the caller of Exim is not trusted, the `From' line is recognized, but the
26050 sender address is not changed. This is also the case for incoming SMTP messages
26051 that are permitted to contain `From' lines.
26052
26053 Only one `From' line is recognized. If there is more than one, the second is
26054 treated as a data line that starts the body of the message, as it is not valid
26055 as a header line. This also happens if a `From' line is present in an incoming
26056 SMTP message from a source that is not permitted to send them.
26057
26058
26059 .section Resent- header lines
26060 .index \Resent@-\ header lines
26061 RFC 2822 makes provision for sets of header lines starting with the string
26062 \"Resent-"\ to be added to a message when it is resent by the original
26063 recipient to somebody else. These headers are ::Resent-Date::, ::Resent-From::,
26064 ::Resent-Sender::, ::Resent-To::, ::Resent-Cc::, ::Resent-Bcc:: and
26065 ::Resent-Message-ID::. The RFC says:
26066
26067 \*Resent fields are strictly informational. They MUST NOT be used in the normal
26068 processing of replies or other such automatic actions on messages.*\
26069
26070 This leaves things a bit vague as far as other processing actions such as
26071 address rewriting are concerned. Exim treats \Resent@-\ header lines as
26072 follows:
26073 .numberpars $.
26074 A ::Resent-From:: line that just contains the login id of the submitting user
26075 is automatically rewritten in the same way as ::From:: (see below).
26076 .nextp
26077 If there's a rewriting rule for a particular header line, it is also applied to
26078 \Resent@-\ header lines of the same type. For example, a rule that rewrites
26079 ::From:: also rewrites ::Resent-From::.
26080 .nextp
26081 For local messages, if ::Sender:: is removed on input, ::Resent-Sender:: is also
26082 removed.
26083 .nextp
26084 For a locally-submitted message,
26085 if there are any \Resent@-\ header lines but no ::Resent-Date::,
26086 ::Resent-From::, or ::Resent-Message-Id::, they are added as necessary. It is
26087 the contents of ::Resent-Message-Id:: (rather than ::Message-Id::) which are
26088 included in log lines in this case.
26089 .nextp
26090 The logic for adding ::Sender:: is duplicated for ::Resent-Sender:: when any
26091 \Resent@-\ header lines are present.
26092 .endp
26093
26094
26095 .section The Auto-Submitted: header line
26096 Whenever Exim generates a bounce or a delay warning message, it includes the
26097 header line
26098 .display asis
26099 Auto-Submitted: auto-generated
26100 .endd
26101
26102
26103 .section The Bcc: header line
26104 .index ::Bcc:: header line
26105 If Exim is called with the \-t-\ option, to take recipient addresses from a
26106 message's header, it removes any ::Bcc:: header line that may exist (after
26107 extracting its addresses). If \-t-\ is not present on the command line, any
26108 existing ::Bcc:: is not removed.
26109
26110 .section The Date: header line
26111 .index ::Date:: header line
26112 If a locally-generated
26113 or submission-mode
26114 message has no ::Date:: header line, Exim adds one, using the current date and
26115 time.
26116
26117 .section The Delivery-date: header line
26118 .index ::Delivery-date:: header line
26119 .index \delivery@_date@_remove\
26120 ::Delivery-date:: header lines are not part of the standard RFC 2822 header
26121 set. Exim can be configured to add them to the final delivery of messages. (See
26122 the generic \delivery@_date@_add\ transport option.) They should not be present
26123 in messages in transit. If the \delivery@_date@_remove\ configuration option is
26124 set (the default), Exim removes ::Delivery-date:: header lines from incoming
26125 messages.
26126
26127 .section The Envelope-to: header line
26128 .index ::Envelope-to:: header line
26129 .index \envelope@_to@_remove\
26130 ::Envelope-to:: header lines are not part of the standard RFC 2822 header set.
26131 Exim can be configured to add them to the final delivery of messages. (See the
26132 generic \envelope@_to@_add\ transport option.) They should not be present in
26133 messages in transit. If the \envelope@_to@_remove\ configuration option is set
26134 (the default), Exim removes ::Envelope-to:: header lines from incoming
26135 messages.
26136
26137 .section The From: header line
26138 .rset SECTthefrohea "~~chapter.~~section"
26139 .index ::From:: header line
26140 .index Sendmail compatibility||`From' line
26141 .index message||submission
26142 .index submission mode
26143 If a submission-mode message does not contain a ::From:: header line, Exim adds
26144 one if either of the following conditions is true:
26145 .numberpars $.
26146 The envelope sender address is not empty (that is, this is not a bounce
26147 message). The added header line copies the envelope sender address.
26148 .nextp
26149 The SMTP session is authenticated and \$authenticated@_id$\ is not empty. 
26150 .em
26151 .numberpars alpha
26152 If no domain is specified by the submission control, the local part is 
26153 \$authenticated@_id$\ and the domain is \$qualify@_domain$\.
26154 .nextp
26155 If a non-empty domain is specified by the submission control, the local part is 
26156 \$authenticated@_id$\, and the the domain is the specified domain.
26157 .nextp
26158 If an empty domain is specified by the submission control, 
26159 \$authenticated@_id$\ is assumed to be the complete address.
26160 .endp
26161 .nem
26162 .endp
26163 A non-empty envelope sender takes precedence.
26164
26165 If a locally-generated incoming message does not contain a ::From:: header
26166 line, Exim adds one containing the sender's address. The calling user's login
26167 name and full name are used to construct the address, as described in section
26168 ~~SECTconstr. They are obtained from the password data by calling
26169 \*getpwuid()*\ (but see the \unknown@_login\ configuration option). The address
26170 is qualified with \qualify@_domain\.
26171
26172 For compatibility with Sendmail, if an incoming, non-SMTP message has a
26173 ::From:: header line containing just the unqualified login name of the calling
26174 user, this is replaced by an address containing the user's login name and full
26175 name as described in section ~~SECTconstr.
26176
26177 .section The Message-ID: header line
26178 .index ::Message-ID:: header line
26179 .index message||submission
26180 If a locally-generated or submission-mode incoming message does not contain a
26181 ::Message-ID:: or ::Resent-Message-ID:: header line, Exim adds one to the
26182 message. If there are any ::Resent-:: headers in the message, it creates
26183 ::Resent-Message-ID::. The id is constructed from Exim's internal message id,
26184 preceded by the letter E to ensure it starts with a letter, and followed by @@
26185 and the primary host name. Additional information can be included in this
26186 header line by setting the
26187 .index \message@_id@_header@_text\
26188 \message@_id@_header@_text\ and/or \message__id__header__domain\ options.
26189
26190
26191 .section The Received: header line
26192 .index ::Received:: header line
26193 A ::Received:: header line is added at the start of every message. The contents
26194 are defined by the \received@_header@_text\ configuration option, and Exim
26195 automatically adds a semicolon and a timestamp to the configured string.
26196
26197 The ::Received:: header is generated as soon as the message's header lines have
26198 been received. At this stage, the timestamp in the ::Received:: header line is
26199 the time that the message started to be received. This is the value that is
26200 seen by the \\DATA\\ ACL and by the \*local@_scan()*\ function.
26201
26202 Once a message is accepted, the timestamp in the ::Received:: header line is
26203 changed to the time of acceptance, which is (apart from a small delay while the
26204 -H spool file is written) the earliest time at which delivery could start.
26205
26206
26207 .section The Return-path: header line
26208 .index ::Return-path:: header line
26209 .index \return@_path@_remove\
26210 ::Return-path:: header lines are defined as something an MTA may insert when
26211 it does the final delivery of messages. (See the generic \return@_path@_add\
26212 transport option.) Therefore, they should not be present in messages in
26213 transit. If the \return@_path@_remove\ configuration option is set (the
26214 default), Exim removes ::Return-path:: header lines from incoming messages.
26215
26216
26217 .section The Sender: header line
26218 .rset SECTthesenhea "~~chapter.~~section"
26219 .index ::Sender:: header line
26220 .index message||submission
26221 For a locally-originated message from an untrusted user, Exim may remove an
26222 existing ::Sender:: header line, and it may add a new one. You can modify these
26223 actions by setting \local@_sender@_retain\ true or \local@_from@_check\ false.
26224
26225 When a local message is received from an untrusted user and
26226 \local@_from@_check\ is true (the default), a check is made to see if the
26227 address given in the ::From:: header line is the correct (local) sender of the
26228 message. The address that is expected has the login name as the local part and
26229 the value of \qualify@_domain\ as the domain. Prefixes and suffixes for the
26230 local part can be permitted by setting \local@_from@_prefix\ and
26231 \local@_from@_suffix\ appropriately. If ::From:: does not contain the correct
26232 sender, a ::Sender:: line is added to the message.
26233
26234 If you set \local@_from@_check\ false, this checking does not occur. However,
26235 the removal of an existing ::Sender:: line still happens, unless you also set
26236 \local@_sender@_retain\ to be true. It is not possible to set both of these
26237 options true at the same time.
26238
26239 .em
26240 .index submission mode
26241 By default, no processing of ::Sender:: header lines is done for messages
26242 received over TCP/IP or for messages submitted by trusted users. However, when
26243 a message is received over TCP/IP in submission mode, and \sender@_retain\ is
26244 not specified on the submission control, the following processing takes place:
26245
26246 First, any existing ::Sender:: lines are removed. Then, if the SMTP session is
26247 authenticated, and \$authenticated@_id$\ is not empty, a sender address is
26248 created as follows:
26249 .numberpars $.
26250 If no domain is specified by the submission control, the local part is 
26251 \$authenticated@_id$\ and the domain is \$qualify@_domain$\.
26252 .nextp
26253 If a non-empty domain is specified by the submission control, the local part is 
26254 \$authenticated@_id$\, and the the domain is the specified domain.
26255 .nextp
26256 If an empty domain is specified by the submission control, 
26257 \$authenticated@_id$\ is assumed to be the complete address.
26258 .endp
26259 This address is compared with the address in the ::From:: header line. If they
26260 are different, a ::Sender:: header line containing the created address is
26261 added. Prefixes and suffixes for the local part in ::From:: can be permitted by
26262 setting \local@_from@_prefix\ and \local@_from@_suffix\ appropriately.
26263 .nem
26264
26265
26266 .section Adding and removing header lines in routers and transports
26267 .index header lines||adding, in router or transport
26268 .index header lines||removing, in router or transport
26269 .rset SECTheadersaddrem "~~chapter.~~section"
26270 .em
26271 When a message is delivered, the addition and removal of header lines can be
26272 specified in a system filter, or on any of the routers and transports that 
26273 process the message. Section ~~SECTaddremheasys contains details about 
26274 modifying headers in a system filter. 
26275
26276 In contrast to what happens in a system filter, header modifications that are
26277 specified on routers and transports apply only to the particular recipient
26278 addresses that are being processed by those routers and transports. These
26279 changes do not actually take place until a copy of the message is being
26280 transported. Therefore, they do not affect the basic set of header lines, and
26281 they do not affect the values of the variables that refer to header lines.
26282
26283 For both routers and transports, the result of expanding a \headers@_add\
26284 option must be in the form of one or more RFC 2822 header lines, separated by
26285 newlines (coded as `@\n'). For example:
26286 .display asis
26287 headers_add = X-added-header: added by $primary_hostname\n\
26288               X-added-second: another added header line
26289 .endd
26290 Exim does not check the syntax of these added header lines. 
26291
26292 The result of expanding \headers@_remove\ must consist of a colon-separated
26293 list of header names. This is confusing, because header names themselves are
26294 often terminated by colons. In this case, the colons are the list separators,
26295 not part of the names. For example:
26296 .display asis
26297 headers_remove = return-receipt-to:acknowledge-to
26298 .endd
26299
26300 When \headers@_add\ or \headers@_remove\ is specified on a router, its value is 
26301 expanded at routing time, and then associated with all addresses that are
26302 accepted by that router, and also with any new addresses that it generates. If
26303 an address passes through several routers as a result of aliasing or
26304 forwarding, the changes are cumulative.
26305 .index \unseen\ option
26306 However, this does not apply to multiple routers that result from the use of
26307 the \unseen\ option. Any header modifications that were specified by the
26308 `unseen' router or its predecessors apply only to the `unseen' delivery.
26309
26310 Addresses that end up with different \headers@_add\ or \headers@_remove\
26311 settings cannot be delivered together in a batch, so a transport is always 
26312 dealing with a set of addresses that have the same header-processing 
26313 requirements. 
26314
26315 The transport starts by writing the original set of header lines that arrived 
26316 with the message, possibly modified by the system filter. As it writes out
26317 these lines, it consults the list of header names that were attached to the
26318 recipient address(es) by \headers@_remove\ options in routers, and it also
26319 consults the transport's own \headers@_remove\ option. Header lines whose names
26320 are on either of these lists are not written out. If there are multiple
26321 instances of any listed header, they are all skipped.
26322
26323 After the remaining original header lines have been written, new header
26324 lines that were specified by routers' \headers@_add\ options are written, in
26325 the order in which they were attached to the address. These are followed by any
26326 header lines specified by the transport's \headers@_add\ option.
26327
26328 This way of handling header line modifications in routers and transports has
26329 the following consequences:
26330 .numberpars $.
26331 The original set of header lines, possibly modified by the system filter, 
26332 remains `visible', in the sense that the \$header@_$\\*xxx*\ variables refer to
26333 it, at all times. 
26334 .nextp
26335 Header lines that are added by a router's
26336 \headers@_add\ option are not accessible by means of the \$header@_$\\*xxx*\
26337 expansion syntax in subsequent routers or the transport.
26338 .nextp
26339 Conversely, header lines that are specified for removal by \headers@_remove\ in
26340 a router remain visible to subsequent routers and the transport.
26341 .nextp
26342 Headers added to an address by \headers@_add\ in a router cannot be removed by 
26343 a later router or by a transport.
26344 .nextp
26345 An added header can refer to the contents of an original header that is to be 
26346 removed, even it has the same name as the added header. For example:
26347 .display asis
26348 headers_remove = subject
26349 headers_add = Subject: new subject (was: $h_subject:)
26350 .endd
26351 .endp
26352
26353 \**Warning**\: The \headers@_add\ and \headers@_remove\ options cannot be used
26354 for a \%redirect%\ router that has the \one@_time\ option set.
26355 .nem
26356
26357
26358
26359 .section Constructed addresses
26360 .rset SECTconstr "~~chapter.~~section"
26361 .index address||constructed
26362 .index constructed address
26363 When Exim constructs a sender address for a locally-generated message, it uses
26364 the form
26365 .display
26366 <<user name>> <$$<<login>>@@<<qualify@_domain>>$$>
26367 .endd
26368 For example:
26369 .display asis
26370 Zaphod Beeblebrox <zaphod@end.univ.example>
26371 .endd
26372 The user name is obtained from the \-F-\ command line option if set, or
26373 otherwise by looking up the calling user by \*getpwuid()*\ and extracting the
26374 `gecos' field from the password entry. If the `gecos' field contains an
26375 ampersand character, this is replaced by the login name with the first letter
26376 upper cased, as is conventional in a number of operating systems. See the
26377 \gecos@_name\ option for a way to tailor the handling of the `gecos' field. The
26378 \unknown@_username\ option can be used to specify user names in cases when
26379 there is no password file entry.
26380
26381 In all cases, the user name is made to conform to RFC 2822 by quoting all or
26382 parts of it if necessary. In addition, if it contains any non-printing
26383 characters, it is encoded as described in RFC 2047, which defines a way of
26384 including non-ASCII characters in header lines.
26385 The value of the \headers@_charset\ option specifies the name of the encoding
26386 that is used (the characters are assumed to be in this encoding).
26387 The setting of \print@_topbitchars\ controls whether characters with the top
26388 bit set (that is, with codes greater than 127) count as printing characters or
26389 not.
26390
26391
26392 .section Case of local parts
26393 .index case of local parts
26394 .index local part||case of
26395 RFC 2822 states that the case of letters in the local parts of addresses cannot
26396 be assumed to be non-significant. Exim preserves the case of local parts of
26397 addresses, but by default it uses a lower-cased form when it is routing,
26398 because on most Unix systems, usernames are in lower case and case-insensitive
26399 routing is required. However, any particular router can be made to use the
26400 original case for local parts by setting the \caseful@_local@_part\ generic
26401 router option.
26402
26403 .index mixed-case login names
26404 If you must have mixed-case user names on your system, the best way to proceed,
26405 assuming you want case-independent handling of incoming email, is to set up
26406 your first router to convert incoming local parts in your domains to the
26407 correct case by means of a file lookup. For example:
26408 .display asis
26409 correct_case:
26410   driver = redirect
26411   domains = +local_domains
26412   data = ${lookup{$local_part}cdb\
26413               {/etc/usercased.cdb}{$value}fail}\
26414               @$domain
26415 .endd
26416 For this router, the local part is forced to lower case by the default action
26417 (\caseful@_local@_part\ is not set). The lower-cased local part is used to look
26418 up a new local part in the correct case. If you then set \caseful@_local@_part\
26419 on any subsequent routers which process your domains, they will operate on
26420 local parts with the correct case in a case-sensitive manner.
26421
26422
26423 .section Dots in local parts
26424 .index dot||in local part
26425 .index local part||dots in
26426 RFC 2822 forbids empty components in local parts. That is, an unquoted local
26427 part may not begin or end with a dot, nor have two consecutive dots in the
26428 middle. However, it seems that many MTAs do not enforce this, so Exim permits
26429 empty components for compatibility.
26430
26431
26432 .section Rewriting addresses
26433 .index rewriting||addresses
26434 Rewriting of sender and recipient addresses, and addresses in headers, can
26435 happen automatically, or as the result of configuration options, as described
26436 in chapter ~~CHAPrewrite. The headers that may be affected by this are ::Bcc::,
26437 ::Cc::, ::From::, ::Reply-To::, ::Sender::, and ::To::.
26438
26439 Automatic rewriting includes qualification, as mentioned above. The other case
26440 in which it can happen is when an incomplete non-local domain is given. The
26441 routing process may cause this to be expanded into the full domain name. For
26442 example, a header such as
26443 .display asis
26444 To: hare@teaparty
26445 .endd
26446 might get rewritten as
26447 .display asis
26448 To: hare@teaparty.wonderland.fict.example
26449 .endd
26450 Rewriting as a result of routing is the one kind of message processing that
26451 does not happen at input time, as it cannot be done until the address has
26452 been routed.
26453
26454 Strictly, one should not do $it{any} deliveries of a message until all its
26455 addresses have been routed, in case any of the headers get changed as a
26456 result of routing. However, doing this in practice would hold up many
26457 deliveries for unreasonable amounts of time, just because one address could not
26458 immediately be routed. Exim therefore does not delay other deliveries when
26459 routing of one or more addresses is deferred.
26460
26461
26462 .
26463 .
26464 .
26465 .
26466 . ============================================================================
26467 .chapter SMTP processing
26468 .set runningfoot "smtp processing"
26469 .rset CHAPSMTP ~~chapter
26470 .index SMTP||processing details
26471 .index LMTP||processing details
26472 Exim supports a number of different ways of using the SMTP protocol, and its
26473 LMTP variant, which is an interactive protocol for transferring messages into a
26474 closed mail store application. This chapter contains details of how SMTP is
26475 processed. For incoming mail, the following are available:
26476 .numberpars $.
26477 SMTP over TCP/IP (Exim daemon or \*inetd*\);
26478 .nextp
26479 SMTP over the standard input and output (the \-bs-\ option);
26480 .nextp
26481 Batched SMTP on the standard input (the \-bS-\ option).
26482 .endp
26483 For mail delivery, the following are available:
26484 .numberpars $.
26485 SMTP over TCP/IP (the \%smtp%\ transport);
26486 .nextp
26487 LMTP over TCP/IP (the \%smtp%\ transport with the \protocol\ option set to
26488 `lmtp');
26489 .nextp
26490 LMTP over a pipe to a process running in the local host (the \%lmtp%\
26491 transport);
26492 .nextp
26493 Batched SMTP to a file or pipe (the \%appendfile%\ and \%pipe%\ transports with
26494 the \use@_bsmtp\ option set).
26495 .endp
26496 \*Batched SMTP*\ is the name for a process in which batches of messages are
26497 stored in or read from files (or pipes), in a format in which SMTP commands are
26498 used to contain the envelope information.
26499
26500
26501 .section Outgoing SMTP and LMTP over TCP/IP
26502 .rset SECToutSMTPTCP "~~chapter.~~section"
26503 .index SMTP||outgoing over TCP/IP
26504 .index outgoing SMTP over TCP/IP
26505 .index LMTP||over TCP/IP
26506 .index outgoing LMTP over TCP/IP
26507 .index \\EHLO\\
26508 .index \\HELO\\
26509 .index \\SIZE\\ option on \\MAIL\\ command
26510 Outgoing SMTP and LMTP over TCP/IP is implemented by the \%smtp%\ transport.
26511 The \protocol\ option selects which protocol is to be used, but the actual
26512 processing is the same in both cases.
26513
26514 If, in response to its \\EHLO\\ command, Exim is told that the \\SIZE\\
26515 parameter is supported, it adds \\SIZE\\=<<n>> to each subsequent \\MAIL\\
26516 command. The value of <<n>> is the message size plus the value of the
26517 \size@_addition\ option (default 1024) to allow for additions to the message
26518 such as per-transport header lines, or changes made in a
26519 .index transport||filter
26520 .index filter||transport filter
26521 transport filter. If \size@_addition\ is set negative, the use of \\SIZE\\ is
26522 suppressed.
26523
26524 If the remote server advertises support for \\PIPELINING\\, Exim uses the
26525 pipelining extension to SMTP (RFC 2197) to reduce the number of TCP/IP packets
26526 required for the transaction.
26527
26528 If the remote server advertises support for the \\STARTTLS\\ command, and Exim
26529 was built to support TLS encryption, it tries to start a TLS session unless the
26530 server matches \hosts@_avoid@_tls\. See chapter ~~CHAPTLS for more details.
26531
26532 If the remote server advertises support for the \\AUTH\\ command, Exim scans
26533 the authenticators configuration for any suitable client settings, as described
26534 in chapter ~~CHAPSMTPAUTH.
26535
26536 .index carriage return
26537 .index linefeed
26538 Responses from the remote host are supposed to be terminated by CR followed by
26539 LF. However, there are known to be hosts that do not send CR characters, so in
26540 order to be able to interwork with such hosts, Exim treats LF on its own as a
26541 line terminator.
26542
26543 If a message contains a number of different addresses, all those with the same
26544 characteristics (for example, the same envelope sender) that resolve to the
26545 same set of hosts, in the same order, are sent in a single SMTP transaction,
26546 even if they are for different domains, unless there are more than the setting
26547 of the \max@_rcpts\ option in the \%smtp%\ transport allows, in which case they
26548 are split into groups containing no more than \max@_rcpts\ addresses each. If
26549 \remote@_max@_parallel\ is greater than one, such groups may be sent in
26550 parallel sessions. The order of hosts with identical MX values is not
26551 significant when checking whether addresses can be batched in this way.
26552
26553 When the \%smtp%\ transport suffers a temporary failure that is not
26554 message-related, Exim updates its transport-specific database, which contains
26555 records indexed by host name that remember which messages are waiting for each
26556 particular host. It also updates the retry database with new retry times.
26557 .index hints database||retry keys
26558 Exim's retry hints are based on host name plus IP address, so if one address of
26559 a multi-homed host is broken, it will soon be skipped most of the time.
26560 See the next section for more detail about error handling.
26561
26562 .index SMTP||passed connection
26563 .index SMTP||batching over TCP/IP
26564 When a message is successfully delivered over a TCP/IP SMTP connection, Exim
26565 looks in the hints database for the transport to see if there are any queued
26566 messages waiting for the host to which it is connected. If it finds one, it
26567 creates a new Exim process using the \-MC-\ option (which can only be used by a
26568 process running as root or the Exim user) and passes the TCP/IP socket to it so
26569 that it can deliver another message using the same socket. The new process does
26570 only those deliveries that are routed to the connected host, and may in turn
26571 pass the socket on to a third process, and so on.
26572
26573 The \connection@_max@_messages\ option of the \%smtp%\ transport can be used to
26574 limit the number of messages sent down a single TCP/IP connection.
26575 .index asterisk||after IP address
26576 The second and subsequent messages delivered down an existing connection are
26577 identified in the main log by the addition of an asterisk after the closing
26578 square bracket of the IP address.
26579
26580
26581
26582 .section Errors in outgoing SMTP
26583 .rset SECToutSMTPerr "~~chapter.~~section"
26584 .index error||in outgoing SMTP
26585 .index SMTP||errors in outgoing
26586 .index host||error
26587 Three different kinds of error are recognized for outgoing SMTP: host errors,
26588 message errors, and recipient errors.
26589 .numberpars
26590 A host error is not associated with a particular message or with a
26591 particular recipient of a message. The host errors are:
26592 .numberpars $.
26593 Connection refused or timed out,
26594 .nextp
26595 Any error response code on connection,
26596 .nextp
26597 Any error response code to \\EHLO\\ or \\HELO\\,
26598 .nextp
26599 Loss of connection at any time, except after `.',
26600 .nextp
26601 I/O errors at any time,
26602 .nextp
26603 Timeouts during the session, other than in response to \\MAIL\\, \\RCPT\\ or
26604 the `.' at the end of the data.
26605 .endp
26606 For a host error, a permanent error response on connection, or in response to
26607 \\EHLO\\, causes all addresses routed to the host to be failed. Any other host
26608 error causes all addresses to be deferred, and retry data to be created for the
26609 host. It is not tried again, for any message, until its retry time arrives. If
26610 the current set of addresses are not all delivered in this run (to some
26611 alternative host), the message is added to the list of those waiting for this
26612 host, so if it is still undelivered when a subsequent successful delivery is
26613 made to the host, it will be sent down the same SMTP connection.
26614 .nextp
26615 .index message||error
26616 A message error is associated with a particular message when sent to a
26617 particular host, but not with a particular recipient of the message. The
26618 message errors are:
26619 .numberpars $.
26620 Any error response code to \\MAIL\\, \\DATA\\, or the `.' that terminates
26621 the data,
26622 .nextp
26623 Timeout after \\MAIL\\,
26624 .nextp
26625 Timeout
26626 or loss of connection after the `.' that terminates the data. A timeout after
26627 the \\DATA\\ command itself is treated as a host error, as is loss of
26628 connection at any other time.
26629 .endp
26630 For a message error, a permanent error response (5$it{xx}) causes all addresses
26631 to be failed, and a delivery error report to be returned to the sender. A
26632 temporary error response (4$it{xx}), or one of the timeouts, causes all
26633 addresses to be deferred. Retry data is not created for the host, but instead,
26634 a retry record for the combination of host plus message id is created. The
26635 message is not added to the list of those waiting for this host. This ensures
26636 that the failing message will not be sent to this host again until the retry
26637 time arrives. However, other messages that are routed to the host are not
26638 affected, so if it is some property of the message that is causing the error,
26639 it will not stop the delivery of other mail.
26640
26641 If the remote host specified support for the \\SIZE\\ parameter in its response
26642 to \\EHLO\\, Exim adds SIZE=$it{nnn} to the \\MAIL\\ command, so an
26643 over-large message will cause a message error because the error arrives as a
26644 response to \\MAIL\\.
26645 .nextp
26646 .index recipient||error
26647 A recipient error is associated with a particular recipient of a message. The
26648 recipient errors are:
26649 .numberpars $.
26650 Any error response to \\RCPT\\,
26651 .nextp
26652 Timeout after \\RCPT\\.
26653 .endp
26654 For a recipient error, a permanent error response (5$it{xx}) causes the
26655 recipient address to be failed, and a bounce message to be returned to the
26656 sender. A temporary error response (4$it{xx}) or a timeout causes the failing
26657 address to be deferred, and routing retry data to be created for it. This is
26658 used to delay processing of the address in subsequent queue runs, until its
26659 routing retry time arrives. This applies to all messages, but because it
26660 operates only in queue runs, one attempt will be made to deliver a new message
26661 to the failing address before the delay starts to operate. This ensures that,
26662 if the failure is really related to the message rather than the recipient
26663 (`message too big for this recipient' is a possible example), other messages
26664 have a chance of getting delivered. If a delivery to the address does succeed,
26665 the retry information gets cleared, so all stuck messages get tried again, and
26666 the retry clock is reset.
26667
26668 The message is not added to the list of those waiting for this host. Use of the
26669 host for other messages is unaffected, and except in the case of a timeout,
26670 other recipients are processed independently, and may be successfully delivered
26671 in the current SMTP session. After a timeout it is of course impossible to
26672 proceed with the session, so all addresses get deferred. However, those other
26673 than the one that failed do not suffer any subsequent retry delays. Therefore,
26674 if one recipient is causing trouble, the others have a chance of getting
26675 through when a subsequent delivery attempt occurs before the failing
26676 recipient's retry time.
26677 .endp
26678
26679 In all cases, if there are other hosts (or IP addresses) available for the
26680 current set of addresses (for example, from multiple MX records), they are
26681 tried in this run for any undelivered addresses, subject of course to their
26682 own retry data. In other words, recipient error retry data does not take effect
26683 until the next delivery attempt.
26684
26685 Some hosts have been observed to give temporary error responses to every
26686 \\MAIL\\ command at certain times (`insufficient space' has been seen). It
26687 would be nice if such circumstances could be recognized, and defer data for the
26688 host itself created, but this is not possible within the current Exim design.
26689 What actually happens is that retry data for every (host, message) combination
26690 is created.
26691
26692 The reason that timeouts after \\MAIL\\ and \\RCPT\\ are treated specially is
26693 that these can sometimes arise as a result of the remote host's verification
26694 procedures. Exim makes this assumption, and treats them as if a temporary error
26695 response had been received. A timeout after `.' is treated specially because it
26696 is known that some broken implementations fail to recognize the end of the
26697 message if the last character of the last line is a binary zero. Thus, it is
26698 helpful to treat this case as a message error.
26699
26700 Timeouts at other times are treated as host errors, assuming a problem with the
26701 host, or the connection to it. If a timeout after \\MAIL\\, \\RCPT\\,
26702 or `.' is really a connection problem, the assumption is that at the next try
26703 the timeout is likely to occur at some other point in the dialogue, causing it
26704 then to be treated as a host error.
26705
26706 There is experimental evidence that some MTAs drop the connection after the
26707 terminating `.' if they do not like the contents of the message for some
26708 reason, in contravention of the RFC, which indicates that a 5$it{xx} response
26709 should be given. That is why Exim treats this case as a message rather than a
26710 host error, in order not to delay other messages to the same host.
26711
26712
26713
26714
26715 .section Variable Envelope Return Paths (VERP)
26716 .index VERP
26717 .index Variable Envelope Return Paths
26718 .index envelope sender
26719 Variable Envelope Return Paths -- see
26720 \?ftp://koobera.math.uic.edu/www/proto/verp.txt?\ -- can be supported in Exim
26721 by using the \return@_path\ generic transport option to rewrite the return path
26722 at transport time. For example, the following could be used on an \%smtp%\
26723 transport:
26724 .display asis
26725 return_path = \
26726   ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
26727   {$1-request=$local_part%$domain@your.dom.example}fail}
26728 .endd
26729 This has the effect of rewriting the return path (envelope sender) on all
26730 outgoing SMTP messages, if the local part of the original return path ends in
26731 `-request', and the domain is \*your.dom.example*\. The rewriting inserts the
26732 local part and domain of the recipient into the return path. Suppose, for
26733 example, that a message whose return path has been set to
26734 \*somelist-request@@your.dom.example*\ is sent to
26735 \*subscriber@@other.dom.example*\. In the transport, the return path is
26736 rewritten as
26737 .display asis
26738 somelist-request=subscriber%other.dom.example@your.dom.example
26739 .endd
26740 For this to work, you must arrange for outgoing messages that have `-request'
26741 in their return paths to have just a single recipient. This can be done by
26742 setting
26743 .display asis
26744 max_rcpt = 1
26745 .endd
26746 in the \%smtp%\ transport. Otherwise a single copy of a message might be
26747 addressed to several different recipients in the same domain, in which case
26748 \$local@_part$\ is not available (because it is not unique). Of course, if you
26749 do start sending out messages with this kind of return path, you must also
26750 configure Exim to accept the bounce messages that come back to those paths.
26751 Typically this would be done by setting an \local@_part@_suffix\ option for a
26752 suitable router.
26753
26754 The overhead incurred in using VERP depends very much on the size of the
26755 message, the number of recipient addresses that resolve to the same remote
26756 host, and the speed of the connection over which the message is being sent. If
26757 a lot of addresses resolve to the same host and the connection is slow, sending
26758 a separate copy of the message for each address may take substantially longer
26759 than sending a single copy with many recipients (for which VERP cannot be
26760 used).
26761
26762
26763 .section Incoming SMTP messages over TCP/IP
26764 .index SMTP||incoming over TCP/IP
26765 .index incoming SMTP over TCP/IP
26766 .index inetd
26767 .index daemon
26768 Incoming SMTP messages can be accepted in one of two ways: by running a
26769 listening daemon, or by using \*inetd*\. In the latter case, the entry in
26770 \(/etc/inetd.conf)\ should be like this:
26771 .display asis
26772 smtp  stream  tcp  nowait  exim  /opt/exim/bin/exim  in.exim  -bs
26773 .endd
26774 Exim distinguishes between this case and the case of a locally running user
26775 agent using the \-bs-\ option by checking whether or not the standard input is
26776 a socket. When it is, either the port must be privileged (less than 1024), or
26777 the caller must be root or the Exim user. If any other user passes a socket
26778 with an unprivileged port number, Exim prints a message on the standard error
26779 stream and exits with an error code.
26780
26781 By default, Exim does not make a log entry when a remote host connects or
26782 disconnects (either via the daemon or \*inetd*\), unless the disconnection is
26783 unexpected. It can be made to write such log entries by setting the
26784 \smtp@_connection\ log selector.
26785
26786 .index carriage return
26787 .index linefeed
26788 Commands from the remote host are supposed to be terminated by CR followed by
26789 LF. However, there are known to be hosts that do not send CR characters. In
26790 order to be able to interwork with such hosts, Exim treats LF on its own as a
26791 line terminator.
26792 Furthermore, because common code is used for receiving messages from all
26793 sources, a CR on its own is also interpreted as a line terminator. However, the
26794 sequence `CR, dot, CR' does not terminate incoming SMTP data.
26795
26796 .index \\EHLO\\||invalid data
26797 .index \\HELO\\||invalid data
26798 One area that sometimes gives rise to problems concerns the \\EHLO\\ or
26799 \\HELO\\ commands. Some clients send syntactically invalid versions of these
26800 commands, which Exim rejects by default. (This is nothing to do with verifying
26801 the data that is sent, so \helo@_verify@_hosts\ is not relevant.) You can tell
26802 Exim not to apply a syntax check by setting \helo@_accept@_junk@_hosts\ to
26803 match the broken hosts that send invalid commands.
26804
26805 .index \\SIZE\\ option on \\MAIL\\ command
26806 .index \\MAIL\\||\\SIZE\\ option
26807 The amount of disk space available is checked whenever \\SIZE\\ is received on
26808 a \\MAIL\\ command, independently of whether \message@_size@_limit\ or
26809 \check@_spool@_space\ is configured, unless \smtp__check__spool__space\ is set
26810 false. A temporary error is given if there is not enough space. If
26811 \check@_spool@_space\ is set, the check is for that amount of space plus the
26812 value given with \\SIZE\\, that is, it checks that the addition of the incoming
26813 message will not reduce the space below the threshold.
26814
26815 When a message is successfully received, Exim includes the local message id in
26816 its response to the final `.' that terminates the data. If the remote host logs
26817 this text it can help with tracing what has happened to a message.
26818
26819 The Exim daemon can limit the number of simultaneous incoming connections it is
26820 prepared to handle (see the \smtp@_accept@_max\ option). It can also limit the
26821 number of simultaneous incoming connections from a single remote host (see the
26822 \smtp@_accept@_max@_per@_host\ option). Additional connection attempts are
26823 rejected using the SMTP temporary error code 421.
26824
26825 The Exim daemon does not rely on the \\SIGCHLD\\ signal to detect when a
26826 subprocess has finished, as this can get lost at busy times. Instead, it looks
26827 for completed subprocesses every time it wakes up. Provided there are other
26828 things happening (new incoming calls, starts of queue runs), completed
26829 processes will be noticed and tidied away. On very quiet systems you may
26830 sometimes see a `defunct' Exim process hanging about. This is not a problem; it
26831 will be noticed when the daemon next wakes up.
26832
26833 When running as a daemon, Exim can reserve some SMTP slots for specific hosts,
26834 and can also be set up to reject SMTP calls from non-reserved hosts at times of
26835 high system load -- for details see the \smtp@_accept@_reserve\,
26836 \smtp@_load@_reserve\, and \smtp@_reserve@_hosts\ options. The load check
26837 applies in both the daemon and \*inetd*\ cases.
26838
26839 Exim normally starts a delivery process for each message received, though this
26840 can be varied by means of the \-odq-\ command line option and the
26841 \queue@_only\, \queue@_only@_file\, and \queue@_only@_load\ options. The number
26842 of simultaneously running delivery processes started in this way from SMTP
26843 input can be limited by the \smtp__accept__queue\ and
26844 \smtp__accept__queue__per__connection\ options. When either limit is reached,
26845 subsequently received messages are just put on the input queue without starting
26846 a delivery process.
26847
26848 The controls that involve counts of incoming SMTP calls (\smtp@_accept@_max\,
26849 \smtp@_accept@_queue\, \smtp__accept__reserve\) are not available when Exim is
26850 started up from the \*inetd*\ daemon, because in that case each connection is
26851 handled by an entirely independent Exim process. Control by load average is,
26852 however, available with \*inetd*\.
26853
26854 Exim can be configured to verify addresses in incoming SMTP commands as they
26855 are received. See chapter ~~CHAPACL for details. It can also be configured to
26856 rewrite addresses at this time -- before any syntax checking is done. See
26857 section ~~SECTrewriteS.
26858
26859 Exim can also be configured to limit the rate at which a client host submits
26860 \\MAIL\\ and \\RCPT\\ commands in a single SMTP session. See the
26861 \smtp@_ratelimit@_hosts\ option.
26862
26863
26864 .section Unrecognized SMTP commands
26865 .index SMTP||unrecognized commands
26866 If Exim receives more than \smtp@_max@_unknown@_commands\ unrecognized SMTP
26867 commands during a single SMTP connection, it drops the connection after sending
26868 the error response to the last command. The default value for
26869 \smtp@_max@_unknown@_commands\ is 3. This is a defence against some kinds of
26870 abuse that subvert web servers into making connections to SMTP ports; in these
26871 circumstances, a number of non-SMTP lines are sent first.
26872
26873 .section Syntax and protocol errors in SMTP commands
26874 .index SMTP||syntax errors
26875 .index SMTP||protocol errors
26876 A syntax error is detected if an SMTP command is recognized, but there is
26877 something syntactically wrong with its data, for example, a malformed email
26878 address in a \\RCPT\\ command. Protocol errors include invalid command
26879 sequencing such as \\RCPT\\ before \\MAIL\\. If Exim receives more than
26880 \smtp@_max@_synprot@_errors\ such commands during a single SMTP connection, it
26881 drops the connection after sending the error response to the last command. The
26882 default value for \smtp__max__synprot__errors\ is 3. This is a defence against
26883 broken clients that loop sending bad commands (yes, it has been seen).
26884
26885
26886 .section Use of non-mail SMTP commands
26887 .index SMTP||non-mail commands
26888 The `non-mail' SMTP commands are those other than \\MAIL\\, \\RCPT\\, and
26889 \\DATA\\. Exim counts such commands, and drops the connection if there are too
26890 many of them in a single SMTP session. This action catches some
26891 denial-of-service attempts and things like repeated failing \\AUTH\\s, or a mad
26892 client looping sending \\EHLO\\. The global option \smtp@_accept@_max@_nonmail\
26893 defines what `too many' means. Its default value is 10.
26894
26895 When a new message is expected, one occurrence of \\RSET\\ is not counted. This
26896 allows a client to send one \\RSET\\ between messages (this is not necessary,
26897 but some clients do it). Exim also allows one uncounted occurence of \\HELO\\
26898 or \\EHLO\\, and one occurrence of \\STARTTLS\\ between messages. After
26899 starting up a TLS session, another \\EHLO\\ is expected, and so it too is not
26900 counted.
26901
26902 The first occurrence of \\AUTH\\ in a connection, or immediately following
26903 \\STARTTLS\\ is also not counted. Otherwise, all commands other than \\MAIL\\,
26904 \\RCPT\\, \\DATA\\, and \\QUIT\\ are counted.
26905
26906 You can control which hosts are subject to the limit set by
26907 \smtp@_accept@_max@_nonmail\ by setting
26908 \smtp@_accept@_max@_nonmail@_hosts\. The default value is \"$*$"\, which makes
26909 the limit apply to all hosts. This option means that you can exclude any
26910 specific badly-behaved hosts that you have to live with.
26911
26912
26913
26914 .section The \\VRFY\\ and \\EXPN\\ commands
26915 When Exim receives a \\VRFY\\ or \\EXPN\\ command on a TCP/IP connection, it
26916 runs the ACL specified by \acl@_smtp@_vrfy\ or \acl@_smtp@_expn\ (as
26917 appropriate) in order to decide whether the command should be accepted or not.
26918 If no ACL is defined, the command is rejected.
26919
26920 .index \\VRFY\\||processing
26921 When \\VRFY\\ is accepted, it runs exactly the same code as when Exim is
26922 called with the \-bv-\ option.
26923 .index \\EXPN\\||processing
26924 When \\EXPN\\ is accepted, a single-level expansion of the address is done.
26925 \\EXPN\\ is treated as an `address test' (similar to the \-bt-\ option) rather
26926 than a verification (the \-bv-\ option). If an unqualified local part is given
26927 as the argument to \\EXPN\\, it is qualified with \qualify@_domain\. Rejections
26928 of \\VRFY\\ and \\EXPN\\ commands are logged on the main and reject logs, and
26929 \\VRFY\\ verification failures are logged on the main log for consistency with
26930 \\RCPT\\ failures.
26931
26932
26933 .section The \\ETRN\\ command
26934 .rset SECTETRN "~~chapter.~~section"
26935 .index \\ETRN\\||processing
26936 RFC 1985 describes an SMTP command called \\ETRN\\ that is designed to
26937 overcome the security problems of the \\TURN\\ command (which has fallen into
26938 disuse). When Exim receives an \\ETRN\\ command on a TCP/IP connection, it runs
26939 the ACL specified by \acl@_smtp@_etrn\ in order to decide whether the command
26940 should be accepted or not. If no ACL is defined, the command is rejected.
26941
26942 The \\ETRN\\ command is concerned with `releasing' messages that are awaiting
26943 delivery to certain hosts. As Exim does not organize its message queue by host,
26944 the only form of \\ETRN\\ that is supported by default is the one where the
26945 text starts with the `@#' prefix, in which case the remainder of the text is
26946 specific to the SMTP server. A valid \\ETRN\\ command causes a run of Exim with
26947 the \-R-\ option to happen, with the remainder of the \\ETRN\\ text as its
26948 argument. For example,
26949 .display asis
26950 ETRN #brigadoon
26951 .endd
26952 runs the command
26953 .display asis
26954 exim -R brigadoon
26955 .endd
26956 which causes a delivery attempt on all messages with undelivered addresses
26957 containing the text `brigadoon'. When \smtp@_etrn@_serialize\ is set (the
26958 default), Exim prevents the simultaneous execution of more than one queue run
26959 for the same argument string as a result of an \\ETRN\\ command. This stops
26960 a misbehaving client from starting more than one queue runner at once.
26961
26962 .index hints database||\\ETRN\\ serialization
26963 Exim implements the serialization by means of a hints database in which a
26964 record is written whenever a process is started by \\ETRN\\, and deleted when
26965 the process completes. However, Exim does not keep the SMTP session waiting for
26966 the \\ETRN\\ process to complete. Once \\ETRN\\ is accepted, the client is sent
26967 a `success' return code. Obviously there is scope for hints records to get left
26968 lying around if there is a system or program crash. To guard against this, Exim
26969 ignores any records that are more than six hours old.
26970
26971 .index \smtp@_etrn@_command\
26972 For more control over what \\ETRN\\ does, the \smtp@_etrn@_command\ option can
26973 used. This specifies a command that is run whenever \\ETRN\\ is received,
26974 whatever the form of its argument. For
26975 example:
26976 .display asis
26977 smtp_etrn_command = /etc/etrn_command $domain $sender_host_address
26978 .endd
26979 The string is split up into arguments which are independently expanded. The
26980 expansion variable \$domain$\ is set to the argument of the \\ETRN\\ command,
26981 and no syntax checking is done on the contents of this argument. Exim does not
26982 wait for the command to complete, so its status code is not checked. Exim runs
26983 under its own uid and gid when receiving incoming SMTP, so it is not possible
26984 for it to change them before running the command.
26985
26986
26987 .section Incoming local SMTP
26988 .index SMTP||local incoming
26989 Some user agents use SMTP to pass messages to their local MTA using the
26990 standard input and output, as opposed to passing the envelope on the command
26991 line and writing the message to the standard input. This is supported by the
26992 \-bs-\ option. This form of SMTP is handled in the same way as incoming
26993 messages over TCP/IP (including the use of ACLs), except that the envelope
26994 sender given in a \\MAIL\\ command is ignored unless the caller is trusted. In
26995 an ACL you can detect this form of SMTP input by testing for an empty host
26996 identification. It is common to have this as the first line in the ACL that
26997 runs for \\RCPT\\ commands:
26998 .display asis
26999 accept hosts = :
27000 .endd
27001 This accepts SMTP messages from local processes without doing any other tests.
27002
27003
27004 .section Outgoing batched SMTP
27005 .rset SECTbatchSMTP "~~chapter.~~section"
27006 .index SMTP||batched outgoing
27007 .index batched SMTP output
27008 Both the \%appendfile%\ and \%pipe%\ transports can be used for handling batched
27009 SMTP. Each has an option called \use@_bsmtp\ which causes messages to be output
27010 in BSMTP format. No SMTP responses are possible for this form of delivery. All
27011 it is doing is using SMTP commands as a way of transmitting the envelope along
27012 with the message.
27013
27014 The message is written to the file or pipe preceded by the SMTP commands
27015 \\MAIL\\ and \\RCPT\\, and followed by a line containing a single dot. Lines in
27016 the message that start with a dot have an extra dot added. The SMTP command
27017 \\HELO\\ is not normally used. If it is required, the \message@_prefix\ option
27018 can be used to specify it.
27019
27020 Because \%appendfile%\ and \%pipe%\ are both local transports, they accept only
27021 one recipient address at a time by default. However, you can arrange for them
27022 to handle several addresses at once by setting the \batch@_max\ option. When
27023 this is done for BSMTP, messages may contain multiple \\RCPT\\ commands. See
27024 chapter ~~CHAPbatching for more details.
27025
27026 When one or more addresses are routed to a BSMTP transport by a router that
27027 sets up a host list, the name of the first host on the list is available to the
27028 transport in the variable \$host$\. Here is an example of such a transport and
27029 router:
27030 .display asis
27031 begin routers
27032 route_append:
27033   driver = manualroute
27034   transport = smtp_appendfile
27035   route_list = domain.example  batch.host.example
27036
27037 begin transports
27038 smtp_appendfile:
27039   driver = appendfile
27040   directory = /var/bsmtp/$host
27041   batch_max = 1000
27042   use_bsmtp
27043   user = exim
27044 .endd
27045 This causes messages addressed to \*domain.example*\ to be written in BSMTP
27046 format to \(/var/bsmtp/batch.host.example)\, with only a single copy of each
27047 message (unless there are more than 1000 recipients).
27048
27049
27050 .section Incoming batched SMTP
27051 .rset SECTincomingbatchedSMTP "~~chapter.~~section"
27052 .index SMTP||batched incoming
27053 .index batched SMTP input
27054 The \-bS-\ command line option causes Exim to accept one or more messages by
27055 reading SMTP on the standard input, but to generate no responses. If the caller
27056 is trusted, the senders in the \\MAIL\\ commands are believed; otherwise the
27057 sender is always the caller of Exim. Unqualified senders and receivers are not
27058 rejected (there seems little point) but instead just get qualified. \\HELO\\
27059 and \\EHLO\\ act as \\RSET\\; \\VRFY\\, \\EXPN\\, \\ETRN\\ and  \\HELP\\, act
27060 as \\NOOP\\; \\QUIT\\ quits.
27061
27062 No policy checking is done for BSMTP input. That is, no ACL is run at anytime.
27063 In this respect it is like non-SMTP local input.
27064
27065 If an error is detected while reading a message, including a missing `.' at
27066 the end, Exim gives up immediately. It writes details of the error to the
27067 standard output in a stylized way that the calling program should be able to
27068 make some use of automatically, for example:
27069 .display asis
27070 554 Unexpected end of file
27071 Transaction started in line 10
27072 Error detected in line 14
27073 .endd
27074 It writes a more verbose version, for human consumption, to the standard error
27075 file, for example:
27076 .display asis
27077 An error was detected while processing a file of BSMTP input.
27078 The error message was:
27079
27080   501 '>' missing at end of address
27081
27082 The SMTP transaction started in line 10.
27083 The error was detected in line 12.
27084 The SMTP command at fault was:
27085
27086    rcpt to:<malformed@in.com.plete
27087
27088 1 previous message was successfully processed.
27089 The rest of the batch was abandoned.
27090 .endd
27091 The return code from Exim is zero only if there were no errors. It is 1 if some
27092 messages were accepted before an error was detected, and 2 if no messages were
27093 accepted.
27094
27095
27096
27097 .
27098 .
27099 .
27100 .
27101 . ============================================================================
27102 .chapter Customizing bounce and warning messages
27103 .set runningfoot "customizing messages"
27104 .rset CHAPemsgcust "~~chapter"
27105 When a message fails to be delivered, or remains on the queue for more than a
27106 configured amount of time, Exim sends a message to the original sender, or
27107 to an alternative configured address. The text of these messages is built into
27108 the code of Exim, but it is possible to change it, either by adding a single
27109 string, or by replacing each of the paragraphs by text supplied in a file.
27110
27111 The ::From:: and ::To:: header lines are automatically generated; you can cause
27112 a ::Reply-To:: line to be added by setting the \errors@_reply@_to\ option. Exim
27113 also adds the line
27114 .display asis
27115 Auto-Submitted: auto-generated
27116 .endd
27117 to all warning and bounce messages,
27118
27119 .section Customizing bounce messages
27120 .index customizing||bounce message
27121 .index bounce message||customizing
27122 If \bounce@_message@_text\ is set, its contents are included in the default
27123 message immediately after `This message was created automatically by mail
27124 delivery software.' The string is not expanded. It is not used if
27125 \bounce@_message@_file\ is set.
27126
27127 When \bounce@_message@_file\ is set, it must point to a template file for
27128 constructing error messages. The file consists of a series of text items,
27129 separated by lines consisting of exactly four asterisks. If the file cannot be
27130 opened, default text is used and a message is written to the main and panic
27131 logs. If any text item in the file is empty, default text is used for that
27132 item.
27133
27134 Each item of text that is read from the file is expanded, and there are two
27135 expansion variables which can be of use here: \$bounce@_recipient$\ is set to
27136 the recipient of an error message while it is being created, and
27137 \$return@_size@_limit$\ contains the value of the \return@_size@_limit\ option,
27138 rounded to a whole number.
27139
27140 The items must appear in the file in the following order:
27141 .numberpars $.
27142 The first item is included in the headers, and should include at least a
27143 ::Subject:: header. Exim does not check the syntax of these headers.
27144 .nextp
27145 The second item forms the start of the error message. After it, Exim lists the
27146 failing addresses with their error messages.
27147 .nextp
27148 The third item is used to introduce any text from pipe transports that is to be
27149 returned to the sender. It is omitted if there is no such text.
27150 .nextp
27151 The fourth item is used to introduce the copy of the message that is returned
27152 as part of the error report.
27153 .nextp
27154 The fifth item is added after the fourth one if the returned message is
27155 truncated because it is bigger than \return@_size@_limit\.
27156 .nextp
27157 The sixth item is added after the copy of the original message.
27158 .endp
27159 The default state (\bounce@_message@_file\ unset) is equivalent to the
27160 following file, in which the sixth item is empty. The ::Subject:: line has been
27161 split into two here in order to fit it on the page:
27162 .if ~~sys.fancy
27163 .display flow asis
27164 .fontgroup 0
27165 .font 54
27166 .else
27167 .rule
27168 .display flow asis
27169 .linelength 80em
27170 .indent 0
27171 .fi
27172 Subject: Mail delivery failed
27173   ${if eq{$sender_address}{$bounce_recipient}{: returning message to sender}}
27174 ****
27175 This message was created automatically by mail delivery software.
27176
27177 A message ${if eq{$sender_address}{$bounce_recipient}{that you sent }{sent by
27178
27179   <$sender_address>
27180
27181 }}could not be delivered to all of its recipients.
27182 The following address(es) failed:
27183 ****
27184 The following text was generated during the delivery attempt(s):
27185 ****
27186 ------ This is a copy of the message, including all the headers. ------
27187 ****
27188 ------ The body of the message is $message_size characters long; only the first
27189 ------ $return_size_limit or so are included here.
27190 ****
27191 .endd
27192 .if !~~sys.fancy
27193 .rule
27194 .fi
27195
27196 .section Customizing warning messages
27197 .rset SECTcustwarn "~~chapter.~~section"
27198 .index customizing||warning message
27199 .index warning of delay||customizing the message
27200 The option
27201 \warn@_message@_file\
27202 can be pointed at a template file for use when
27203 warnings about message delays are created. In this case there are only three
27204 text sections:
27205 .numberpars $.
27206 The first item is included in the headers, and should include at least a
27207 ::Subject:: header. Exim does not check the syntax of these headers.
27208 .nextp
27209 The second item forms the start of the warning message. After it, Exim lists
27210 the delayed addresses.
27211 .nextp
27212 The third item then ends the message.
27213 .endp
27214 The default state is equivalent to the following file, except that the line
27215 starting `A message' has been split here, in order to fit it on the page:
27216 .if ~~sys.fancy
27217 .display asis
27218 .fontgroup 0
27219 .font 54
27220 .else
27221 .rule
27222 .display asis
27223 .linelength 80em
27224 .indent 0
27225 .fi
27226 .newline
27227 Subject: Warning: message $message_id delayed $warn_message_delay
27228 ****
27229 This message was created automatically by mail delivery software.
27230
27231 A message ${if eq{$sender_address}{$warn_message_recipients}
27232   {that you sent }{sent by
27233
27234   <$sender_address>
27235
27236 }}has not been delivered to all of its recipients after
27237 more than $warn_message_delay on the queue on $primary_hostname.
27238 .newline
27239
27240 The message identifier is:     $message_id
27241 The subject of the message is: $h_subject
27242 The date of the message is:    $h_date
27243
27244 The following address(es) have not yet been delivered:
27245 ****
27246 No action is required on your part. Delivery attempts will continue for
27247 some time, and this warning may be repeated at intervals if the message
27248 remains undelivered. Eventually the mail delivery software will give up,
27249 and when that happens, the message will be returned to you.
27250 .endd
27251 .if !~~sys.fancy
27252 .rule
27253 .fi
27254 except that in the default state the subject and date lines are omitted if no
27255 appropriate headers exist. During the expansion of this file,
27256 \$warn@_message@_delay$\
27257 is set to the delay time in one of the forms `<<n>> minutes'
27258 or `<<n>> hours', and
27259 \$warn@_message@_recipients$\
27260 contains a list of recipients for the warning message. There may be more than
27261 one if there are multiple addresses with different \errors@_to\ settings on the
27262 routers that handled them.
27263
27264
27265
27266
27267 .
27268 .
27269 .
27270 . ============================================================================
27271 .chapter Some common configuration requirements
27272 .set runningfoot "common configuration requirements"
27273 .rset CHAPcomconreq "~~chapter"
27274 This chapter discusses some configuration requirements that seem to be fairly
27275 common. More examples and discussion can be found in the Exim book.
27276
27277
27278 .section Sending mail to a smart host
27279 .index smart host||example router
27280 If you want to send all mail for non-local domains to a `smart host', you
27281 should replace the default \%dnslookup%\ router with a router which does the
27282 routing explicitly:
27283 .display asis
27284 send_to_smart_host:
27285   driver = manualroute
27286   route_list = !+local_domains smart.host.name
27287   transport = remote_smtp
27288 .endd
27289 You can use the smart host's IP address instead of the name if you wish.
27290 .em
27291 If you are using Exim only to submit messages to a smart host, and not for
27292 receiving incoming messages, you can arrange for it to do the submission
27293 synchronously by setting the \mua@_wrapper\ option (see chapter
27294 ~~CHAPnonqueueing).
27295 .nem
27296
27297
27298 .section Using Exim to handle mailing lists
27299 .rset SECTmailinglists "~~chapter.~~section"
27300 .index mailing lists
27301 Exim can be used to run simple mailing lists, but for large and/or complicated
27302 requirements, the use of additional specialized mailing list software such as
27303 Majordomo or Mailman is recommended.
27304
27305 The \%redirect%\ router can be used to handle mailing lists where each list
27306 is maintained in a separate file, which can therefore be managed by an
27307 independent manager. The \domains\ router option can be used to run these
27308 lists in a separate domain from normal mail. For example:
27309 .display asis
27310 lists:
27311   driver = redirect
27312   domains = lists.example
27313   file = /usr/lists/$local_part
27314   forbid_pipe
27315   forbid_file
27316   errors_to = $local_part-request@lists.example
27317   no_more
27318 .endd
27319 This router is skipped for domains other than \*lists.example*\. For addresses
27320 in that domain, it looks for a file that matches the local part. If there is no
27321 such file, the router declines, but because \no@_more\ is set, no subsequent
27322 routers are tried, and so the whole delivery fails.
27323
27324 The \forbid@_pipe\ and \forbid@_file\ options prevent a local part from being
27325 expanded into a file name or a pipe delivery, which is usually inappropriate in
27326 a mailing list.
27327
27328 .index \errors@_to\
27329 The \errors@_to\ option specifies that any delivery errors caused by addresses
27330 taken from a mailing list are to be sent to the given address rather than the
27331 original sender of the message. However, before acting on this, Exim verifies
27332 the error address, and ignores it if verification fails.
27333
27334 For example, using the configuration above, mail sent to
27335 \*dicts@@lists.example*\ is passed on to those addresses contained in
27336 \(/usr/lists/dicts)\, with error reports directed to
27337 \*dicts-request@@lists.example*\, provided that this address can be verified.
27338 There could be a file called \(/usr/lists/dicts-request)\ containing
27339 the address(es) of this particular list's manager(s), but other approaches,
27340 such as setting up an earlier router (possibly using the \local@_part@_prefix\
27341 or \local@_part@_suffix\ options) to handle addresses of the form \owner-xxx\
27342 or \xxx-request\, are also possible.
27343
27344
27345 .section Syntax errors in mailing lists
27346 .index mailing lists||syntax errors in
27347 If an entry in redirection data contains a syntax error, Exim normally defers
27348 delivery of the original address. That means that a syntax error in a mailing
27349 list holds up all deliveries to the list. This may not be appropriate when a
27350 list is being maintained automatically from data supplied by users, and the
27351 addresses are not rigorously checked.
27352
27353 If the \skip@_syntax@_errors\ option is set, the \%redirect%\ router just skips
27354 entries that fail to parse, noting the incident in the log. If in addition
27355 \syntax@_errors@_to\ is set to a verifiable address, a message is sent to it
27356 whenever a broken address is skipped. It is usually appropriate to set
27357 \syntax@_errors@_to\ to the same address as \errors@_to\.
27358
27359
27360 .section Re-expansion of mailing lists
27361 .index mailing lists||re-expansion of
27362 Exim remembers every individual address to which a message has been delivered,
27363 in order to avoid duplication, but it normally stores only the original
27364 recipient addresses with a message. If all the deliveries to a mailing list
27365 cannot be done at the first attempt, the mailing list is re-expanded when the
27366 delivery is next tried. This means that alterations to the list are taken into
27367 account at each delivery attempt, so addresses that have been added to
27368 the list since the message arrived will therefore receive a copy of the
27369 message, even though it pre-dates their subscription.
27370
27371 If this behaviour is felt to be undesirable, the \one@_time\ option can be set
27372 on the \%redirect%\ router. If this is done, any addresses generated by the
27373 router that fail to deliver at the first attempt are added to the message as
27374 `top level' addresses, and the parent address that generated them is marked
27375 `delivered'. Thus, expansion of the mailing list does not happen again at the
27376 subsequent delivery attempts. The disadvantage of this is that if any of the
27377 failing addresses are incorrect, correcting them in the file has no effect on
27378 pre-existing messages.
27379
27380 The original top-level address is remembered with each of the generated
27381 addresses, and is output in any log messages. However, any intermediate parent
27382 addresses are not recorded. This makes a difference to the log only if the
27383 \all@_parents\ selector is set, but for mailing lists there is normally only
27384 one level of expansion anyway.
27385
27386
27387 .section Closed mailing lists
27388 .index mailing lists||closed
27389 The examples so far have assumed open mailing lists, to which anybody may
27390 send mail. It is also possible to set up closed lists, where mail is accepted
27391 from specified senders only. This is done by making use of the generic
27392 \senders\ option to restrict the router that handles the list.
27393
27394 The following example uses the same file as a list of recipients and as a list
27395 of permitted senders. It requires three routers:
27396 .display asis
27397 lists_request:
27398   driver = redirect
27399   domains = lists.example
27400   local_part_suffix = -request
27401   file = /usr/lists/$local_part$local_part_suffix
27402   no_more
27403
27404 lists_post:
27405   driver = redirect
27406   domains = lists.example
27407   senders = ${if exists {/usr/lists/$local_part}\
27408              {lsearch;/usr/lists/$local_part}{*}}
27409   file = /usr/lists/$local_part
27410   forbid_pipe
27411   forbid_file
27412   errors_to = $local_part-request@lists.example
27413   no_more
27414
27415 lists_closed:
27416   driver = redirect
27417   domains = lists.example
27418   allow_fail
27419   data = :fail: $local_part@lists.example is a closed mailing list
27420 .endd
27421 All three routers have the same \domains\ setting, so for any other domains,
27422 they are all skipped. The first router runs only if the local part ends in
27423 \@-request\. It handles messages to the list manager(s) by means of an open
27424 mailing list.
27425
27426 The second router runs only if the \senders\ precondition is satisfied. It
27427 checks for the existence of a list that corresponds to the local part, and then
27428 checks that the sender is on the list by means of a linear search. It is
27429 necessary to check for the existence of the file before trying to search it,
27430 because otherwise Exim thinks there is a configuration error. If the file does
27431 not exist, the expansion of \senders\ is $*$, which matches all senders. This
27432 means that the router runs, but because there is no list, declines, and
27433 \no@_more\ ensures that no further routers are run. The address fails with an
27434 `unrouteable address' error.
27435
27436 The third router runs only if the second router is skipped, which happens when
27437 a mailing list exists, but the sender is not on it. This router forcibly fails
27438 the address, giving a suitable error message.
27439
27440
27441
27442 .section Virtual domains
27443 .rset SECTvirtualdomains "~~chapter.~~section"
27444 .index virtual domains
27445 .index domain||virtual
27446 The phrase \*virtual domain*\ is unfortunately used with two rather different
27447 meanings:
27448 .numberpars $.
27449 A domain for which there are no real mailboxes; all valid local parts are
27450 aliases for other email addresses. Common examples are organizational
27451 top-level domains and `vanity' domains.
27452 .nextp
27453 One of a number of independent domains that are all handled by the same host,
27454 with mailboxes on that host, but where the mailbox owners do not necessarily
27455 have login accounts on that host.
27456 .endp
27457 The first usage is probably more common, and does seem more `virtual' than the
27458 second. This kind of domain can be handled in Exim with a straightforward
27459 aliasing router. One approach is to create a separate alias file for each
27460 virtual domain. Exim can test for the existence of the alias file to determine
27461 whether the domain exists. The \%dsearch%\ lookup type is useful here, leading
27462 to a router of this form:
27463 .display asis
27464 virtual:
27465   driver = redirect
27466   domains = dsearch;/etc/mail/virtual
27467   data = ${lookup{$local_part}lsearch{/etc/mail/virtual/$domain}}
27468   no_more
27469 .endd
27470 The \domains\ option specifies that the router is to be skipped, unless there
27471 is a file in the \(/etc/mail/virtual)\ directory whose name is the same as the
27472 domain that is being processed. When the router runs, it looks up the local
27473 part in the file to find a new address (or list of addresses). The \no@_more\
27474 setting ensures that if the lookup fails (leading to \data\ being an empty
27475 string), Exim gives up on the address without trying any subsequent routers.
27476
27477 This one router can handle all the virtual domains because the alias file names
27478 follow a fixed pattern. Permissions can be arranged so that appropriate people
27479 can edit the different alias files. A successful aliasing operation results in
27480 a new envelope recipient address, which is then routed from scratch.
27481
27482 The other kind of `virtual' domain can also be handled in a straightforward
27483 way. One approach is to create a file for each domain containing a list of
27484 valid local parts, and use it in a router like this:
27485 .display asis
27486 my_domains:
27487   driver = accept
27488   domains = dsearch;/etc/mail/domains
27489   local_parts = lsearch;/etc/mail/domains/$domain
27490   transport = my_mailboxes
27491 .endd
27492 The address is accepted if there is a file for the domain, and the local part
27493 can be found in the file. The \domains\ option is used to check for the file's
27494 existence because \domains\ is tested before the \local@_parts\ option (see
27495 section ~~SECTrouprecon). You can't use \require@_files\, because that option
27496 is tested after \local@_parts\. The transport is as follows:
27497 .display asis
27498 my_mailboxes:
27499   driver = appendfile
27500   file = /var/mail/$domain/$local_part
27501   user = mail
27502 .endd
27503 This uses a directory of mailboxes for each domain. The \user\ setting is
27504 required, to specify which uid is to be used for writing to the mailboxes.
27505
27506 The configuration shown here is just one example of how you might support this
27507 requirement. There are many other ways this kind of configuration can be set
27508 up, for example, by using a database instead of separate files to hold all the
27509 information about the domains.
27510
27511
27512 .section Multiple user mailboxes
27513 .rset SECTmulbox "~~chapter.~~section"
27514 .index multiple mailboxes
27515 .index mailbox||multiple
27516 .index local part||prefix
27517 .index local part||suffix
27518 Heavy email users often want to operate with multiple mailboxes, into which
27519 incoming mail is automatically sorted. A popular way of handling this is to
27520 allow users to use multiple sender addresses, so that replies can easily be
27521 identified. Users are permitted to add prefixes or suffixes to their local
27522 parts for this purpose. The wildcard facility of the generic router options
27523 \local@_part@_prefix\ and \local@_part@_suffix\ can be used for this. For
27524 example, consider this router:
27525 .display asis
27526 userforward:
27527   driver = redirect
27528   check_local_user
27529   file = $home/.forward
27530   local_part_suffix = -*
27531   local_part_suffix_optional
27532   allow_filter
27533 .endd
27534 It runs a user's \(.forward)\ file for all local parts of the form
27535 \*username-$*$*\. Within the filter file the user can distinguish different
27536 cases by testing the variable \$local@_part@_suffix$\. For example:
27537 .display asis
27538 if $local_part_suffix contains -special then
27539   save /home/$local_part/Mail/special
27540 endif
27541 .endd
27542 If the filter file does not exist, or does not deal with such addresses, they
27543 fall through to subsequent routers, and, assuming no subsequent use of the
27544 \local@_part@_suffix\ option is made, they presumably fail. Thus, users have
27545 control over which suffixes are valid.
27546
27547 Alternatively, a suffix can be used to trigger the use of a different
27548 \(.forward)\ file -- which is the way a similar facility is implemented in
27549 another MTA:
27550 .display asis
27551 userforward:
27552   driver = redirect
27553   check_local_user
27554   file = $home/.forward$local_part_suffix
27555   local_part_suffix = -*
27556   local_part_suffix_optional
27557   allow_filter
27558 .endd
27559 If there is no suffix, \(.forward)\ is used; if the suffix is \*-special*\, for
27560 example, \(.forward-special)\ is used. Once again, if the appropriate file
27561 does not exist, or does not deal with the address, it is passed on to
27562 subsequent routers, which could, if required, look for an unqualified
27563 \(.forward)\ file to use as a default.
27564
27565
27566 .section Simplified vacation processing
27567 .index vacation processing
27568 The traditional way of running the \*vacation*\ program is for a user to set up
27569 a pipe command in a \(.forward)\ file
27570 (see section ~~SECTspecitredli for syntax details).
27571 This is prone to error by inexperienced users. There are two features of Exim
27572 that can be used to make this process simpler for users:
27573 .numberpars $.
27574 A local part prefix such as `vacation-' can be specified on a router which
27575 can cause the message to be delivered directly to the \*vacation*\ program, or
27576 alternatively can use Exim's \%autoreply%\ transport. The contents of a user's
27577 \(.forward)\ file are then much simpler. For example:
27578 .display asis
27579 spqr, vacation-spqr
27580 .endd
27581 .nextp
27582 The \require@_files\ generic router option can be used to trigger a
27583 vacation delivery by checking for the existence of a certain file in the
27584 user's home directory. The \unseen\ generic option should also be used, to
27585 ensure that the original delivery also proceeds. In this case, all the user has
27586 to do is to create a file called, say, \(.vacation)\, containing a vacation
27587 message.
27588 .endp
27589 Another advantage of both these methods is that they both work even when the
27590 use of arbitrary pipes by users is locked out.
27591
27592
27593 .section Taking copies of mail
27594 .index message||copying every
27595 Some installations have policies that require archive copies of all messages to
27596 be made. A single copy of each message can easily be taken by an appropriate
27597 command in a system filter, which could, for example, use a different file for
27598 each day's messages.
27599
27600 There is also a shadow transport mechanism that can be used to take copies of
27601 messages that are successfully delivered by local transports, one copy per
27602 delivery. This could be used, $it{inter alia}, to implement automatic
27603 notification of delivery by sites that insist on doing such things.
27604
27605
27606 .section Intermittently connected hosts
27607 .index intermittently connected hosts
27608 It has become quite common (because it is cheaper) for hosts to connect to the
27609 Internet periodically rather than remain connected all the time. The normal
27610 arrangement is that mail for such hosts accumulates on a system that is
27611 permanently connected.
27612
27613 Exim was designed for use on permanently connected hosts, and so it is not
27614 particularly well-suited to use in an intermittently connected environment.
27615 Nevertheless there are some features that can be used.
27616
27617 .section Exim on the upstream server host
27618 It is tempting to arrange for incoming mail for the intermittently connected
27619 host to remain on Exim's queue until the client connects. However, this
27620 approach does not scale very well. Two different kinds of waiting message are
27621 being mixed up in the same queue -- those that cannot be delivered because of
27622 some temporary problem, and those that are waiting for their destination host
27623 to connect. This makes it hard to manage the queue, as well as wasting
27624 resources, because each queue runner scans the entire queue.
27625
27626 A better approach is to separate off those messages that are waiting for an
27627 intermittently connected host. This can be done by delivering these messages
27628 into local files in batch SMTP, `mailstore', or other envelope-preserving
27629 format, from where they are transmitted by other software when their
27630 destination connects. This makes it easy to collect all the mail for one host
27631 in a single directory, and to apply local timeout rules on a per-message basis
27632 if required.
27633
27634 On a very small scale, leaving the mail on Exim's queue can be made to work. If
27635 you are doing this, you should configure Exim with a long retry period for the
27636 intermittent host. For example:
27637 .display
27638 cheshire.wonderland.fict.example    *   F,5d,24h
27639 .endd
27640 This stops a lot of failed delivery attempts from occurring, but Exim remembers
27641 which messages it has queued up for that host. Once the intermittent host comes
27642 online, forcing delivery of one message (either by using the \-M-\ or \-R-\
27643 options, or by using the \\ETRN\\ SMTP command (see section ~~SECTETRN)
27644 causes all the queued up messages to be delivered, often down a single SMTP
27645 connection. While the host remains connected, any new messages get delivered
27646 immediately.
27647
27648 If the connecting hosts do not have fixed IP addresses, that is, if a host is
27649 issued with a different IP address each time it connects, Exim's retry
27650 mechanisms on the holding host get confused, because the IP address is normally
27651 used as part of the key string for holding retry information. This can be
27652 avoided by unsetting \retry__include__ip__address\ on the \%smtp%\ transport.
27653 Since this has disadvantages for permanently connected hosts, it is best to
27654 arrange a separate transport for the intermittently connected ones.
27655
27656
27657 .section Exim on the intermittently connected client host
27658 The value of \smtp@_accept@_queue@_per@_connection\ should probably be
27659 increased, or even set to zero (that is, disabled) on the intermittently
27660 connected host, so that all incoming messages down a single connection get
27661 delivered immediately.
27662
27663 .index SMTP||passed connection
27664 .index SMTP||multiple deliveries
27665 .index multiple SMTP deliveries
27666 Mail waiting to be sent from an intermittently connected host will probably
27667 not have been routed, because without a connection DNS lookups are not
27668 possible. This means that if a normal queue run is done at connection time,
27669 each message is likely to be sent in a separate SMTP session. This can be
27670 avoided by starting the queue run with a command line option beginning with
27671 \-qq-\ instead of \-q-\. In this case, the queue is scanned twice. In the first
27672 pass, routing is done but no deliveries take place. The second pass is a normal
27673 queue run; since all the messages have been previously routed, those destined
27674 for the same host are likely to get sent as multiple deliveries in a single
27675 SMTP connection.
27676
27677
27678
27679 .
27680 .
27681 .
27682 .
27683 . ============================================================================
27684 .chapter Using Exim as a non-queueing client
27685 .set runningfoot "non-queueing client"
27686 .rset CHAPnonqueueing "~~chapter"
27687 .index client, non-queueing
27688 .index smart host||queueing, suppressing
27689 .em
27690 On a personal computer, it is a common requirement for all
27691 email to be sent to a `smart host'. There are plenty of MUAs that can be
27692 configured to operate that way, for all the popular operating systems.
27693 However, there are some MUAs for Unix-like systems that cannot be so
27694 configured: they submit messages using the command line interface of
27695 \(/usr/sbin/sendmail)\. Furthermore, utility programs such as \*cron*\ submit
27696 messages this way.
27697
27698 If the personal computer runs continuously, there is no problem, because it can 
27699 run a conventional MTA that handles delivery to the smart host, and deal with
27700 any delays via its queueing mechanism. However, if the computer does not run 
27701 continuously or runs different operating systems at different times, queueing 
27702 email is not desirable.
27703
27704 There is therefore a requirement for something that can provide the
27705 \(/usr/sbin/sendmail)\ interface but deliver messages to a smart host without
27706 any queueing or retrying facilities. Furthermore, the delivery to the smart
27707 host should be synchronous, so that if it fails, the sending MUA is immediately
27708 informed. In other words, we want something that extends an MUA that submits
27709 to a local MTA via the command line so that it behaves like one that submits
27710 to a remote smart host using TCP/SMTP.
27711
27712 There are a number of applications (for example, there is one called \*ssmtp*\)
27713 that do this job. However, people have found them to be lacking in various
27714 ways. For instance, you might want to allow aliasing and forwarding to be done
27715 before sending a message to the smart host.
27716
27717 Exim already had the necessary infrastructure for doing this job. Just a few
27718 tweaks were needed to make it behave as required, though it is somewhat of an
27719 overkill to use a fully-featured MTA for this purpose.
27720
27721 .index \mua@_wrapper\
27722 There is a Boolean global option called \mua@_wrapper\, defaulting false.
27723 Setting \mua@_wrapper\ true causes Exim to run in a special mode where it
27724 assumes that it is being used to `wrap' a command-line MUA in the manner
27725 just described. As well as setting \mua@_wrapper\, you also need to provide a
27726 compatible router and transport configuration. Typically there will be just one
27727 router and one transport, sending everything to a smart host.
27728
27729 When run in MUA wrapping mode, the behaviour of Exim changes in the
27730 following ways:
27731 .numberpars alpha
27732 A daemon cannot be run, nor will Exim accept incoming messages from \*inetd*\.
27733 In other words, the only way to submit messages is via the command line.
27734 .nextp
27735 Each message is synchonously delivered as soon as it is received (\-odi-\ is
27736 assumed). All queueing options (\queue@_only\, \queue@_smtp@_domains\,
27737 \control\ in an ACL, etc.) are quietly ignored. The Exim reception process does
27738 not finish until the delivery attempt is complete. If the delivery is
27739 successful, a zero return code is given.
27740 .nextp
27741 Address redirection is permitted, but the final routing for all addresses must
27742 be to the same remote transport, and to the same list of hosts. Furthermore,
27743 the return address (envelope sender) must be the same for all recipients, as
27744 must any added or deleted header lines. In other words, it must be possible to
27745 deliver the message in a single SMTP transaction, however many recipients there
27746 are.
27747 .nextp
27748 If these conditions are not met, or if routing any address results in a failure
27749 or defer status, or if Exim is unable to deliver all the recipients
27750 successfully to one of the smart hosts, delivery of the entire message fails.
27751 .nextp
27752 Because no queueing is allowed, all failures are treated as permanent; there is
27753 no distinction between 4\*xx*\ and 5\*xx*\ SMTP response codes from the smart
27754 host. Furthermore, because only a single yes/no response can be given to the
27755 caller, it is not possible to deliver to some recipients and not others. If
27756 there is an error (temporary or permanent) for any recipient, all are failed.
27757 .nextp
27758 If more than one smart host is listed, Exim will try another host after a
27759 connection failure or a timeout, in the normal way. However, if this kind of
27760 failure happens for all the hosts, the delivery fails.
27761 .nextp
27762 When delivery fails, an error message is written to the standard error stream
27763 (as well as to Exim's log), and Exim exits to the caller with a return code
27764 value 1. The message is expunged from Exim's spool files. No bounce messages
27765 are ever generated.
27766 .nextp
27767 No retry data is maintained, and any retry rules are ignored.
27768 .nextp
27769 A number of Exim options are overridden: \deliver@_drop@_privilege\ is forced
27770 true, \max@_rcpt\ in the smtp transport is forced to `unlimited',
27771 \remote@_max@_parallel\ is forced to one, and fallback hosts are ignored.
27772 .endp
27773 The overall effect is that Exim makes a single synchronous attempt to deliver
27774 the message, failing if there is any kind of problem. Because no local
27775 deliveries are done and no daemon can be run, Exim does not need root
27776 privilege. It should be possible to run it setuid to \*exim*\ instead of setuid
27777 to \*root*\. See section ~~SECTrunexiwitpri for a general discussion about the
27778 advantages and disadvantages of running without root privilege.
27779 .nem
27780
27781
27782
27783 .
27784 .
27785 .
27786 .
27787 . ============================================================================
27788 .chapter Log files
27789 .set runningfoot "log files"
27790 .rset CHAPlog "~~chapter"
27791 .index log||types of
27792 .index log||general description
27793 Exim writes three different logs, referred to as the main log, the reject log,
27794 and the panic log:
27795 .numberpars $.
27796 .index main log
27797 The main log records the arrival of each message and each delivery in a single
27798 line in each case. The format is as compact as possible, in an attempt to keep
27799 down the size of log files. Two-character flag sequences make it easy to pick
27800 out these lines. A number of other events are recorded in the main log. Some of
27801 them are optional, in which case the \log@_selector\ option controls whether
27802 they are included or not. A Perl script called \*eximstats*\, which does simple
27803 analysis of main log files, is provided in the Exim distribution (see section
27804 ~~SECTmailstat).
27805 .nextp
27806 .index reject log
27807 The reject log records information from messages that are rejected as a result
27808 of a configuration option (that is, for policy reasons).
27809 The first line of each rejection is a copy of the line that is also written to
27810 the main log. Then, if the message's header has been read at the time the log
27811 is written, its contents are written to this log. Only the original header
27812 lines are available; header lines added by ACLs are not logged. You can use the
27813 reject log to check that your policy controls are working correctly; on a busy
27814 host this may be easier than scanning the main log for rejection messages. You
27815 can suppress the writing of the reject log by setting \write@_rejectlog\ false.
27816 .nextp
27817 .index panic log
27818 .index system log
27819 When certain serious errors occur, Exim writes entries to its panic log. If the
27820 error is sufficiently disastrous, Exim bombs out afterwards. Panic log entries
27821 are usually written to the main log as well, but can get lost amid the mass of
27822 other entries. The panic log should be empty under normal circumstances. It is
27823 therefore a good idea to check it (or to have a \*cron*\ script check it)
27824 regularly, in order to become aware of any problems. When Exim cannot open its
27825 panic log, it tries as a last resort to write to the system log (syslog). This
27826 is opened with LOG@_PID+LOG@_CONS and the facility code of LOG@_MAIL. The
27827 message itself is written at priority LOG@_CRIT.
27828 .endp
27829 Every log line starts with a timestamp, in the format shown in this example:
27830 .display asis
27831 2001-09-16 16:09:47 SMTP connection from [127.0.0.1] closed by QUIT
27832 .endd
27833 By default, the timestamps are in the local timezone. There are two
27834 ways of changing this:
27835 .numberpars $.
27836 You can set the \timezone\ option to a different time zone; in particular, if
27837 you set
27838 .display asis
27839 timezone = UTC
27840 .endd
27841 the timestamps will be in UTC (aka GMT).
27842 .nextp
27843 If you set \log@_timezone\ true, the time zone is added to the timestamp, for
27844 example:
27845 .display asis
27846 2003-04-25 11:17:07 +0100 Start queue run: pid=12762
27847 .endd
27848 .endp
27849
27850
27851
27852 .section Where the logs are written
27853 .rset SECTwhelogwri "~~chapter.~~section"
27854 .index log||destination
27855 .index log||to file
27856 .index log||to syslog
27857 .index syslog
27858 The logs may be written to local files, or to syslog, or both. However, it
27859 should be noted that many syslog implementations use UDP as a transport, and
27860 are therefore unreliable in the sense that messages are not guaranteed to
27861 arrive at the loghost, nor is the ordering of messages necessarily maintained.
27862 It has also been reported that on large log files (tens of megabytes) you may
27863 need to tweak syslog to prevent it syncing the file with each write -- on Linux
27864 this has been seen to make syslog take 90% plus of CPU time.
27865
27866 The destination for Exim's logs is configured by setting \\LOG@_FILE@_PATH\\ in
27867 \(Local/Makefile)\ or by setting \log@_file@_path\ in the run time
27868 configuration. This latter string is expanded, so it can contain, for example,
27869 references to the host name:
27870 .display asis
27871 log_file_path = /var/log/$primary_hostname/exim_%slog
27872 .endd
27873 It is generally advisable, however, to set the string in \(Local/Makefile)\
27874 rather than at run time, because then the setting is available right from the
27875 start of Exim's execution. Otherwise, if there's something it wants to log
27876 before it has read the configuration file (for example, an error in the
27877 configuration file) it will not use the path you want, and may not be able to
27878 log at all.
27879
27880 The value of \\LOG@_FILE@_PATH\\ or \log@_file@_path\ is a colon-separated
27881 list, currently limited to at most two items. This is one option where the
27882 facility for changing a list separator may not be used. The list must always be
27883 colon-separated. If an item in the list is `syslog' then syslog is used;
27884 otherwise the item must either be an absolute path, containing \"%s"\ at the
27885 point where `main', `reject', or `panic' is to be inserted, or be empty,
27886 implying the use of a default path.
27887
27888 When Exim encounters an empty item in the list, it searches the list defined by
27889 \\LOG@_FILE@_PATH\\, and uses the first item it finds that is neither empty nor
27890 `syslog'. This means that an empty item in \log@_file@_path\ can be used to
27891 mean `use the path specified at build time'. It no such item exists, log files
27892 are written in the \(log)\ subdirectory of the spool directory. This is
27893 equivalent to the setting:
27894 .display asis
27895 log_file_path = $spool_directory/log/%slog
27896 .endd
27897 If you do not specify anything at build time or run time, that is where the
27898 logs are written.
27899
27900 A log file path may also contain \"%D"\ if datestamped log file names are in
27901 use -- see section ~~SECTdatlogfil below.
27902
27903 Here are some examples of possible settings:
27904 .display
27905 .tabs 42
27906 LOG@_FILE@_PATH=syslog                      $t $rm{syslog only}
27907 LOG@_FILE@_PATH=:syslog                     $t $rm{syslog and default path}
27908 LOG@_FILE@_PATH=syslog : /usr/log/exim@_%s  $t $rm{syslog and specified path}
27909 LOG@_FILE@_PATH=/usr/log/exim@_%s           $t $rm{specified path only}
27910 .endd
27911 If there are more than two paths in the list, the first is used and a panic
27912 error is logged.
27913
27914
27915 .section Logging to local files that are periodically `cycled'
27916 .index log||cycling local files
27917 .index cycling logs
27918 .index \*exicyclog*\
27919 .index log||local files, writing to
27920 Some operating systems provide centralized and standardised methods for cycling
27921 log files. For those that do not, a utility script called \*exicyclog*\ is
27922 provided (see section ~~SECTcyclogfil). This renames and compresses the main
27923 and reject logs each time it is called. The maximum number of old logs to keep
27924 can be set. It is suggested this script is run as a daily \*cron*\ job.
27925
27926 An Exim delivery process opens the main log when it first needs to write to it,
27927 and it keeps the file open in case subsequent entries are required -- for
27928 example, if a number of different deliveries are being done for the same
27929 message. However, remote SMTP deliveries can take a long time, and this means
27930 that the file may be kept open long after it is renamed if \*exicyclog*\ or
27931 something similar is being used to rename log files on a regular basis. To
27932 ensure that a switch of log files is noticed as soon as possible, Exim calls
27933 \*stat()*\ on the main log's name before reusing an open file, and if the file
27934 does not exist, or its inode has changed, the old file is closed and Exim
27935 tries to open the main log from scratch. Thus, an old log file may remain open
27936 for quite some time, but no Exim processes should write to it once it has been
27937 renamed.
27938
27939
27940 .section Datestamped log files
27941 .rset SECTdatlogfil "~~chapter.~~section"
27942 .index log||datestamped files
27943 Instead of cycling the main and reject log files by renaming them
27944 periodically, some sites like to use files whose names contain a datestamp,
27945 for example, \(mainlog-20031225)\. The datestamp is in the form \(yyyymmdd)\.
27946 Exim has support for this way of working. It is enabled by setting the
27947 \log@_file@_path\ option to a path that includes \"%D"\ at the point where the
27948 datestamp is required. For example:
27949 .display asis
27950 log_file_path = /var/spool/exim/log/%slog-%D
27951 log_file_path = /var/log/exim-%s-%D.log
27952 log_file_path = /var/spool/exim/log/%D-%slog
27953 .endd
27954 As before, \"%s"\ is replaced by `main' or `reject'; the following are examples
27955 of names generated by the above examples:
27956 .display asis
27957 /var/spool/exim/log/mainlog-20021225
27958 /var/log/exim-reject-20021225.log
27959 /var/spool/exim/log/20021225-mainlog
27960 .endd
27961 When this form of log file is specified, Exim automatically switches to new
27962 files at midnight. It does not make any attempt to compress old logs; you
27963 will need to write your own script if you require this. You should not
27964 run \*exicyclog*\ with this form of logging.
27965
27966 The location of the panic log is also determined by \log@_file@_path\, but it
27967 is not datestamped, because rotation of the panic log does not make sense.
27968 When generating the name of the panic log, \"%D"\ is removed from the string.
27969 In addition, if it immediately follows a slash, a following non-alphanumeric
27970 character is removed; otherwise a preceding non-alphanumeric character is
27971 removed. Thus, the three examples above would give these panic log names:
27972 .display asis
27973 /var/spool/exim/log/paniclog
27974 /var/log/exim-panic.log
27975 /var/spool/exim/log/paniclog
27976 .endd
27977
27978
27979 .section Logging to syslog
27980 .index log||syslog, writing to
27981 The use of syslog does not change what Exim logs or the format of its messages,
27982 except in one respect. If \syslog@_timestamp\ is set false, the timestamps on
27983 Exim's log lines are omitted when these lines are sent to syslog. Apart from
27984 that, the same strings are written to syslog as to log files. The syslog
27985 `facility' is set to \\LOG@_MAIL\\, and the program name to `exim'
27986 by default, but you can change these by setting the \syslog@_facility\ and
27987 \syslog@_processname\ options, respectively. If Exim was compiled with
27988 \\SYSLOG@_LOG@_PID\\ set in \(Local/Makefile)\ (this is the default in
27989 \(src/EDITME)\), then, on systems that permit it (all except ULTRIX), the
27990 \\LOG@_PID\\ flag is set so that the \*syslog()*\ call adds the pid as well as
27991 the time and host name to each line.
27992 The three log streams are mapped onto syslog priorities as follows:
27993 .numberpars " "
27994 \*mainlog*\ is mapped to \\LOG@_INFO\\
27995 .nextp
27996 \*rejectlog*\ is mapped to \\LOG@_NOTICE\\
27997 .nextp
27998 \*paniclog*\ is mapped to \\LOG@_ALERT\\
27999 .endp
28000 Many log lines are written to both \*mainlog*\ and \*rejectlog*\, and some are
28001 written to both \*mainlog*\ and \*paniclog*\, so there will be duplicates if
28002 these are routed by syslog to the same place. You can suppress this duplication
28003 by setting \syslog@_duplication\ false.
28004
28005 Exim's log lines can sometimes be very long, and some of its \*rejectlog*\
28006 entries contain multiple lines when headers are included. To cope with both
28007 these cases, entries written to syslog are split into separate \*syslog()*\
28008 calls at each internal newline, and also after a maximum of
28009 870 data characters. (This allows for a total syslog line length of 1024, when
28010 additions such as timestamps are added.) If you are running a syslog
28011 replacement that can handle lines longer than the 1024 characters allowed by
28012 RFC 3164, you should set
28013 .display asis
28014 SYSLOG_LONG_LINES=yes
28015 .endd
28016 in \(Local/Makefile)\ before building Exim. That stops Exim from splitting long
28017 lines, but it still splits at internal newlines in \*reject*\ log entries.
28018
28019 To make it easy to re-assemble split lines later, each component of a split
28020 entry starts with a string of the form `[<<n>>/<<m>>]' or `[<<n>>@\<<m>>]'
28021 where <<n>> is the component number and <<m>> is the total number of components
28022 in the entry. The / delimiter is used when the line was split because it was
28023 too long; if it was split because of an internal newline, the @\ delimiter is
28024 used. For example, supposing the length limit to be 70 instead of 1000, the
28025 following would be the result of a typical rejection message to \*mainlog*\
28026 (LOG@_INFO), each line in addition being preceded by the time, host name, and
28027 pid as added by syslog:
28028 .display
28029 .indent 0
28030 $smc{[1/3] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from [127.0.0.1] (ph10):
28031 [2/3]  syntax error in 'From' header when scanning for sender: missing or ma
28032 [3/3] lformed local part in "<>" (envelope sender is <ph10@@cam.example>)}
28033 .endd
28034 The same error might cause the following lines to be written to `rejectlog'
28035 (LOG@_NOTICE):
28036 .display flow
28037 .indent 0
28038 $smc{[1/14] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from [127.0.0.1] (ph10):
28039 [2/14]  syntax error in 'From' header when scanning for sender: missing or ma
28040 [3@\14] lformed local part in "@<@>" (envelope sender is <ph10@@cam.example>)
28041 [4@\14] Recipients: ph10@@some.domain.cam.example
28042 [5@\14] P Received: from [127.0.0.1] (ident=ph10)
28043 [6@\14]        by xxxxx.cam.example with smtp (Exim 4.00)
28044 [7@\14]        id 16RdAL-0006pc-00
28045 [8@\14]        for ph10@@cam.example; Mon, 16 Sep 2002 16:09:43 +0100
28046 [9@\14] F From: @<@>
28047 [10@\14]   Subject: this is a test header
28048 [11@\14]   X-something: this is another header
28049 [12@\14] I Message-Id: <E16RdAL-0006pc-00@@xxxxx.cam.example>
28050 [13@\14] B Bcc:
28051 [14/14]   Date: Mon, 16 Sep 2002 16:09:43 +0100}
28052 .endd
28053 Log lines that are neither too long nor contain newlines are written to syslog
28054 without modification.
28055
28056 If only syslog is being used, the Exim monitor is unable to provide a log tail
28057 display, unless syslog is routing \*mainlog*\ to a file on the local host and
28058 the environment variable \\EXIMON@_LOG@_FILE@_PATH\\ is set to tell the monitor
28059 where it is.
28060
28061
28062 .section Log line flags
28063 One line is written to the main log for each message received, and for each
28064 successful, unsuccessful, and delayed delivery. These lines can readily be
28065 picked out by the distinctive two-character flags that immediately follow the
28066 timestamp. The flags are:
28067 .display
28068 .tabs 6
28069 <=    $t $rm{message arrival}
28070 =>    $t $rm{normal message delivery}
28071 ->    $t $rm{additional address in same delivery}
28072 *>    $t $rm{delivery suppressed by \-N-\}
28073 **    $t $rm{delivery failed; address bounced}
28074 ==    $t $rm{delivery deferred; temporary problem}
28075 .endd
28076
28077
28078 .section Logging message reception
28079 .index log||reception line
28080 The format of the single-line entry in the main log that is written for every
28081 message received is shown in the basic example below, which is split over
28082 several lines in order to fit it on the page:
28083 .display
28084 .indent 0
28085 2002-10-31 08:57:53 16ZCW1-0005MB-00 <= kryten@@dwarf.fict.example
28086   H=mailer.fict.example [192.168.123.123] U=exim
28087   P=smtp S=5678 id=<<incoming message id>>
28088 .endd
28089 The address immediately following `<=' is the envelope sender address. A bounce
28090 message is shown with the sender address `<>', and if it is locally generated,
28091 this is followed by an item of the form
28092 .display
28093 R=<<message id>>
28094 .endd
28095 which is a reference to the message that caused the bounce to be sent.
28096
28097 .index \\HELO\\
28098 .index \\EHLO\\
28099 For messages from other hosts, the H and U fields identify the remote host and
28100 record the RFC 1413 identity of the user that sent the message, if one was
28101 received. The number given in square brackets is the IP address of the sending
28102 host. If there is a single, unparenthesized  host name in the H field, as
28103 above, it has been verified to correspond to the IP address (see the
28104 \host@_lookup\ option). If the name is in parentheses, it was the name quoted
28105 by the remote host in the SMTP \\HELO\\ or \\EHLO\\ command, and has not been
28106 verified. If verification yields a different name to that given for \\HELO\\ or
28107 \\EHLO\\, the verified name appears first, followed by the \\HELO\\ or \\EHLO\\
28108 name in parentheses.
28109
28110 Misconfigured hosts (and mail forgers) sometimes put an IP address, with or
28111 without brackets, in the \\HELO\\ or \\EHLO\\ command, leading to entries in
28112 the log containing text like these examples:
28113 .display
28114 H=(10.21.32.43) [192.168.8.34]
28115 H=([10.21.32.43]) [192.168.8.34]
28116 .endd
28117 This can be confusing. Only the final address in square brackets can be relied
28118 on.
28119
28120 For locally generated messages (that is, messages not received over TCP/IP),
28121 the H field is omitted, and the U field contains the login name of the caller
28122 of Exim.
28123
28124 .index authentication||logging
28125 .index \\AUTH\\||logging
28126 For all messages, the P field specifies the protocol used to receive the
28127 message. This is set to 
28128 .em
28129 `esmtpa' 
28130 .nem
28131 for messages received from hosts that have authenticated themselves using the
28132 SMTP \\AUTH\\ command. In this case there is an additional item A= followed by
28133 the name of the authenticator that was used. If an authenticated identification
28134 was set up by the authenticator's \server@_set@_id\ option, this is logged too,
28135 separated by a colon from the authenticator name.
28136
28137 The id field records the existing message id, if present.
28138 .index size||of message
28139 The size of the received message is given by the S field. When the message is
28140 delivered, headers may get removed or added, so that the size of delivered
28141 copies of the message may not correspond with this value (and indeed may be
28142 different to each other).
28143
28144 The \log@_selector\ option can be used to request the logging of additional
28145 data when a message is received. See section ~~SECTlogselector below.
28146
28147
28148 .section Logging deliveries
28149 .index log||delivery line
28150 The format of the single-line entry in the main log that is written for every
28151 delivery is shown in one of the examples below, for local and remote deliveries,
28152 respectively. Each example has been split into two lines in order to fit
28153 it on the page:
28154 .display
28155 .indent 0
28156 2002-10-31 08:59:13 16ZCW1-0005MB-00 => marv <marv@@hitch.fict.example>
28157   R=localuser T=local@_delivery
28158 2002-10-31 09:00:10 16ZCW1-0005MB-00 => monk@@holistic.fict.example
28159   R=dnslookup T=remote@_smtp H=holistic.fict.example [192.168.234.234]
28160 .endd
28161 For ordinary local deliveries, the original address is given in angle brackets
28162 after the final delivery address, which might be a pipe or a file. If
28163 intermediate address(es) exist between the original and the final address, the
28164 last of these is given in parentheses after the final address. The R and T
28165 fields record the router and transport that were used to process the address.
28166
28167 If a shadow transport was run after a successful local delivery, the log line
28168 for the successful delivery has an item added on the end, of the form
28169 .display
28170 ST=<<shadow transport name>>
28171 .endd
28172 If the shadow transport did not succeed, the error message is put in
28173 parentheses afterwards.
28174
28175 When more than one address is included in a single delivery (for example, two
28176 SMTP \\RCPT\\ commands in one transaction) the second and subsequent
28177 addresses are flagged with `$tt{@-@>}' instead of `$tt{@=@>}'. When two or more
28178 messages are delivered down a single SMTP connection, an asterisk follows the
28179 IP address in the log lines for the second and subsequent messages.
28180
28181 The generation of a reply message by a filter file gets logged as a `delivery'
28182 to the addressee, preceded by `>'.
28183
28184 The \log@_selector\ option can be used to request the logging of additional
28185 data when a message is delivered. See section ~~SECTlogselector below.
28186
28187
28188 .section Discarded deliveries
28189 .index discarded messages
28190 .index message||discarded
28191 .index delivery||discarded, logging
28192 When a message is discarded as a result of the command `seen finish' being
28193 obeyed in a filter file which generates no deliveries, a log entry of the form
28194 .display
28195 2002-12-10 00:50:49 16auJc-0001UB-00 => discarded
28196   <low.club@@bridge.example> R=userforward
28197 .endd
28198 is written, to record why no deliveries are logged. When a message is discarded
28199 because it is aliased to `:blackhole:' the log line is like this:
28200 .display asis
28201 1999-03-02 09:44:33 10HmaX-0005vi-00 => :blackhole:
28202   <hole@nowhere.example> R=blackhole_router
28203 .endd
28204
28205
28206 .section Deferred deliveries
28207 When a delivery is deferred, a line of the following form is logged:
28208 .display
28209 .indent 0
28210 2002-12-19 16:20:23 16aiQz-0002Q5-00 == marvin@@endrest.example
28211   R=dnslookup T=smtp defer (146): Connection refused
28212 .endd
28213 In the case of remote deliveries, the error is the one that was given for the
28214 last IP address that was tried. Details of individual SMTP failures are also
28215 written to the log, so the above line would be preceded by something like
28216 .display
28217 .indent 0
28218 2002-12-19 16:20:23 16aiQz-0002Q5-00 Failed to connect to
28219   mail1.endrest.example [192.168.239.239]: Connection refused
28220 .endd
28221 When a deferred address is skipped because its retry time has not been reached,
28222 a message is written to the log, but this can be suppressed by setting an
28223 appropriate value in \log@_selector\.
28224
28225
28226 .section Delivery failures
28227 .index delivery||failure, logging
28228 If a delivery fails because an address cannot be routed, a line of the
28229 following form is logged:
28230 .display asis
28231 .indent 0
28232 1995-12-19 16:20:23 0tRiQz-0002Q5-00 ** jim@trek99.example
28233   <jim@trek99.example>: unknown mail domain
28234 .endd
28235 If a delivery fails at transport time, the router and transport are shown, and
28236 the response from the remote host is included, as in this example:
28237 .display asis
28238 .indent 0
28239 2002-07-11 07:14:17 17SXDU-000189-00 ** ace400@pb.example R=dnslookup
28240 .newline
28241   T=remote_smtp: SMTP error from remote mailer after pipelined
28242 .newline
28243   RCPT TO:<ace400@pb.example>: host pbmail3.py.example
28244   [192.168.63.111]: 553 5.3.0 <ace400@pb.example>...
28245   Addressee unknown
28246 .endd
28247 The word `pipelined' indicates that the SMTP \\PIPELINING\\ extension was being
28248 used. See \hosts@_avoid@_esmtp\ in the \%smtp%\ transport for a way of
28249 disabling \\PIPELINING\\.
28250
28251 The log lines for all forms of delivery failure are flagged with \"**"\.
28252
28253
28254 .section Fake deliveries
28255 .index delivery||fake, logging
28256 If a delivery does not actually take place because the \-N-\ option has been
28257 used to suppress it, a normal delivery line is written to the log, except that
28258 `=>' is replaced by `$*$>'.
28259
28260
28261 .section Completion
28262 A line of the form
28263 .display
28264 2002-10-31 09:00:11 16ZCW1-0005MB-00 Completed
28265 .endd
28266 is written to the main log when a message is about to be removed from the spool
28267 at the end of its processing.
28268
28269
28270
28271 .section Summary of Fields in Log Lines
28272 .index log||summary of fields
28273 A summary of the field identifiers that are used in log lines is shown in
28274 the following table:
28275 .display flow
28276 .tabs 8
28277 A          $t $rm{authenticator name (and optional id)}
28278 C          $t $rm{SMTP confirmation on delivery}
28279 CV         $t $rm{certificate verification status}
28280 DN         $t $rm{distinguished name from peer certificate}
28281 .newline
28282 .em
28283 DT         $t $rm{on \"=>"\ lines: time taken for a delivery}
28284 .nem
28285 .newline
28286 F          $t $rm{sender address (on delivery lines)}
28287 H          $t $rm{host name and IP address}
28288 I          $t $rm{local interface used}
28289 id         $t $rm{message id for incoming message}
28290 P          $t $rm{on \"<="\ lines: protocol used}
28291 .newline
28292 .em
28293            $t $rm{on \"=>"\ and \"**"\ lines: return path}
28294 QT         $t $rm{on \"=>"\ lines: time spent on queue so far}
28295            $t $rm{on `Completed' lines: time spent on queue}
28296 .nem
28297 .newline            
28298 R          $t $rm{on \"<="\ lines: reference for local bounce}
28299 .newline
28300 .em
28301            $t $rm{on \"=>"\  \"**"\ and \"=="\ lines: router name}
28302 .nem
28303 .newline            
28304 S          $t $rm{size of message}
28305 ST         $t $rm{shadow transport name}
28306 T          $t $rm{on \"<="\ lines: message subject (topic)}
28307 .newline
28308 .em
28309            $t $rm{on \"=>"\ \"**"\ and \"=="\ lines: transport name}
28310 .nem
28311 .newline            
28312 U          $t $rm{local user or RFC 1413 identity}
28313 X          $t $rm{TLS cipher suite}
28314 .endd
28315
28316
28317 .section Other log entries
28318 Various other types of log entry are written from time to time. Most should be
28319 self-explanatory. Among the more common are:
28320 .numberpars $.
28321 .index retry||time not reached
28322 \*retry time not reached*\##An address previously suffered a temporary error
28323 during routing or local delivery, and the time to retry has not yet arrived.
28324 This message is not written to an individual message log file unless it happens
28325 during the first delivery attempt.
28326 .nextp
28327 \*retry time not reached for any host*\##An address previously suffered
28328 temporary errors during remote delivery, and the retry time has not yet arrived
28329 for any of the hosts to which it is routed.
28330 .nextp
28331 .index spool directory||file locked
28332 \*spool file locked*\##An attempt to deliver a message cannot proceed because
28333 some other Exim process is already working on the message. This can be quite
28334 common if queue running processes are started at frequent intervals. The
28335 \*exiwhat*\ utility script can be used to find out what Exim processes are
28336 doing.
28337 .nextp
28338 .index error||ignored
28339 \*error ignored*\##There are several circumstances that give rise to this
28340 message:
28341 .numberpars " "
28342 Exim failed to deliver a bounce message whose age was greater than
28343 \ignore__bounce__errors__after\. The bounce was discarded.
28344 .nextp
28345 A filter file set up a delivery using the `noerror' option, and the delivery
28346 failed. The delivery was discarded.
28347 .nextp
28348 A delivery set up by a router configured with
28349 .display asis
28350 errors_to = <>
28351 .endd
28352 failed. The delivery was discarded.
28353 .endp
28354 .endp
28355
28356
28357
28358 .section Reducing or increasing what is logged
28359 .rset SECTlogselector "~~chapter.~~section"
28360 .index log||selectors
28361 By setting the \log@_selector\ global option, you can disable some of Exim's
28362 default logging, or you can request additional logging. The value of
28363 \log@_selector\ is made up of names preceded by plus or minus characters. For
28364 example:
28365 .display asis
28366 log_selector = +arguments -retry_defer
28367 .endd
28368 The list of optional log items is in the following table, with the default
28369 selection marked by asterisks:
28370 .display flow
28371 .tabs 32
28372  address@_rewrite           $t $rm{address rewriting}
28373  all@_parents               $t $rm{all parents in => lines}
28374  arguments                  $t $rm{command line arguments}
28375 *connection@_reject         $t $rm{connection rejections}
28376 *delay@_delivery            $t $rm{immediate delivery delayed}
28377  deliver@_time              $t $rm{time taken to perform delivery}
28378  delivery@_size             $t $rm{add S=nnn to => lines}
28379 *dnslist@_defer             $t $rm{defers of DNS list (aka RBL) lookups}
28380 *etrn                       $t $rm{ETRN commands}
28381 *host@_lookup@_failed       $t $rm{as it says}
28382  ident@_timeout             $t $rm{timeout for ident connection}
28383  incoming@_interface        $t $rm{incoming interface on <= lines}
28384  incoming@_port             $t $rm{incoming port on <= lines}
28385 *lost@_incoming@_connection $t $rm{as it says (includes timeouts)}
28386  outgoing@_port             $t $rm{add remote port to => lines}
28387 *queue@_run                 $t $rm{start and end queue runs}
28388 .newline
28389 .em 
28390  queue@_time                $t $rm{time on queue for one recipient}
28391  queue@_time@_overall       $t $rm{time on queue for whole message} 
28392 .nem
28393 .newline
28394  received@_recipients       $t $rm{recipients on <= lines}
28395  received@_sender           $t $rm{sender on <= lines}
28396 *rejected@_header           $t $rm{header contents on reject log}
28397 *retry@_defer               $t $rm{`retry time not reached'}
28398  return@_path@_on@_delivery $t $rm{put return path on => and ** lines}
28399  sender@_on@_delivery       $t $rm{add sender to => lines}
28400 *size@_reject               $t $rm{rejection because too big}
28401 *skip@_delivery             $t $rm{delivery skipped in a queue run}
28402  smtp@_confirmation         $t $rm{SMTP confirmation on => lines}
28403  smtp@_connection           $t $rm{SMTP connections}
28404  smtp@_incomplete@_transaction $t $rm{incomplete SMTP transactions}
28405  smtp@_protocol@_error      $t $rm{SMTP protocol errors}
28406  smtp@_syntax@_error        $t $rm{SMTP syntax errors}
28407  subject                    $t $rm{contents of ::Subject:: on <= lines}
28408  tls@_certificate@_verified $t $rm{certificate verification status}
28409 *tls@_cipher                $t $rm{TLS cipher suite on <= and => lines}
28410  tls@_peerdn                $t $rm{TLS peer DN on <= and => lines}
28411
28412  all                        $t $rm{all of the above}
28413 .endd
28414 More details on each of these items follows:
28415 .numberpars $.
28416 .index log||rewriting
28417 .index rewriting||logging
28418 \address@_rewrite\: This applies both to global rewrites and per-transport
28419 rewrites,
28420 but not to rewrites in filters run as an unprivileged user (because such users
28421 cannot access the log).
28422 .nextp
28423 .index log||full parentage
28424 \all@_parents\: Normally only the original and final addresses are logged on
28425 delivery lines; with this selector, intermediate parents are given in
28426 parentheses between them.
28427 .nextp
28428 .index log||Exim arguments
28429 .index Exim arguments, logging
28430 \arguments\: This causes Exim to write the arguments with which it was called
28431 to the main log,
28432 preceded by the current working directory.
28433 This is a debugging feature, added to make it easier to find out how certain
28434 MUAs call \(/usr/sbin/sendmail)\. The logging does not happen if Exim has given
28435 up root privilege because it was called with the \-C-\ or \-D-\ options.
28436 Arguments that are empty or that contain whitespace are quoted. Non-printing
28437 characters are shown as escape sequences.
28438 This facility cannot log unrecognized arguments, because the arguments are
28439 checked before the configuration file is read. The only way to log such cases
28440 is to interpose a script such as \(util/logargs.sh)\ between the caller and
28441 Exim.
28442 .nextp
28443 .index log||connection rejections
28444 \connection@_reject\: A log entry is written whenever an incoming SMTP
28445 connection is rejected, for whatever reason.
28446 .nextp
28447 .index log||delayed delivery
28448 .index delayed delivery, logging
28449 \delay@_delivery\: A log entry is written whenever a delivery process is not
28450 started for an incoming message because the load is too high or too many
28451 messages were received on one connection. Logging does not occur if no delivery
28452 process is started because \queue@_only\ is set or \-odq-\ was used.
28453 .nextp
28454 .index log||delivery duration
28455 \deliver@_time\: For each delivery, the amount of real time it has taken to
28456 perform the actual delivery is logged as DT=<<time>>, for example, \"DT=1s"\.
28457 .nextp
28458 .index log||message size on delivery
28459 .index size||of message
28460 \delivery@_size\: For each delivery, the size of message delivered is added to
28461 the `=>' line, tagged with S=.
28462 .nextp
28463 .index log||dnslist defer
28464 .index DNS list||logging defer
28465 .index black list (DNS)
28466 \dnslist@_defer\: A log entry is written if an attempt to look up a host in a
28467 DNS black list suffers a temporary error.
28468 .nextp
28469 .index log||ETRN commands
28470 .index \\ETRN\\||logging
28471 \etrn\: Every legal ETRN command that is received is logged, before the ACL is
28472 run to determine whether or not it is actually accepted. An invalid ETRN
28473 command, or one received within a message transaction is not logged by this
28474 selector (see \smtp@_syntax@_error\ and \smtp@_protocol@_error\).
28475 .nextp
28476 .index log||host lookup failure
28477 \host@_lookup@_failed\: When a lookup of a host's IP addresses fails to find
28478 any addresses, or when a lookup of an IP address fails to find a host name, a
28479 log line is written. This logging does not apply to direct DNS lookups when
28480 routing email addresses, but it does apply to `byname' lookups.
28481 .nextp
28482 .index log||ident timeout
28483 .index RFC 1413||logging timeout
28484 \ident@_timeout\: A log line is written whenever an attempt to connect to a
28485 client's ident port times out.
28486 .nextp
28487 .index log||incoming interface
28488 .index interface||logging
28489 \incoming@_interface\: The interface on which a message was received is added
28490 to the `<=' line as an IP address in square brackets, tagged by I= and followed
28491 by a colon and the port number.
28492 The local interface and port are also added to other SMTP log
28493 lines, for example `SMTP connection from', and to rejection lines.
28494 .nextp
28495 .index log||incoming remote port
28496 .index port||logging remote
28497 .index TCP/IP||logging incoming remote port
28498 \incoming@_port\: The remote port number from which a message was received is
28499 added to log entries and ::Received:: header lines, following the IP address in
28500 square brackets, and separated from it by a colon. This is implemented by
28501 changing the value that is put in the \$sender@_fullhost$\ and
28502 \$sender@_rcvhost$\ variables. Recording the remote port number has become more
28503 important with the widening use of NAT (see RFC 2505).
28504 .nextp
28505 .index log||dropped connection
28506 \lost@_incoming@_connection\: A log line is written when an incoming SMTP
28507 connection is unexpectedly dropped.
28508 .nextp
28509 .index log||outgoing remote port
28510 .index port||logging outgoint remote
28511 .index TCP/IP||logging ougtoing remote port
28512 \outgoing@_port\: The remote port number is added to delivery log lines (those
28513 containing => tags) following the IP address. This option is not included in
28514 the default setting, because for most ordinary configurations, the remote port
28515 number is always 25 (the SMTP port).
28516 .nextp
28517 .index log||queue run
28518 .index queue runner||logging
28519 \queue@_run\: The start and end of every queue run are logged.
28520 .nextp
28521 .index log||queue time
28522 \queue@_time\: The amount of time the message has been in the queue on the
28523 local host is logged as QT=<<time>>
28524 .em
28525 on delivery (\"=>"\) lines, for example, \"QT=3m45s"\. The clock starts when
28526 Exim starts to receive the message, so it includes reception time as well as
28527 the delivery time for the current address. This means that it may be longer
28528 than the difference between the arrival and delivery log line times, because
28529 the arrival log line is not written until the message has been successfully
28530 received.
28531 .nem
28532
28533 .nextp
28534 .em
28535 \queue@_time@_overall\: The amount of time the message has been in the queue on
28536 the local host is logged as QT=<<time>> on `Completed' lines, for
28537 example, \"QT=3m45s"\. The clock starts when Exim starts to receive the
28538 message, so it includes reception time as well as the total delivery time.
28539 .nem
28540 .nextp
28541 .index log||recipients
28542 \received@_recipients\: The recipients of a message are listed in the main log
28543 as soon as the message is received. The list appears at the end of the log line
28544 that is written when a message is received, preceded by the word `for'. The
28545 addresses are listed after they have been qualified, but before any rewriting
28546 has taken place.
28547 Recipients that were discarded by an ACL for \\MAIL\\ or \\RCPT\\ do not appear
28548 in the list.
28549 .nextp
28550 .index log||sender reception
28551 \received@_sender\: The unrewritten original sender of a message is added to
28552 the end of the log line that records the message's arrival, after the word
28553 `from' (before the recipients if \received@_recipients\ is also set).
28554 .nextp
28555 .index log||header lines for rejection
28556 \rejected@_header\: If a message's header has been received at the time a
28557 rejection is written to the reject log, the complete header is added to the
28558 log. Header logging can be turned off individually for messages that are
28559 rejected by the \*local@_scan()*\ function (see section ~~SECTapiforloc).
28560 .nextp
28561 .index log||retry defer
28562 \retry@_defer\: A log line is written if a delivery is deferred because a retry
28563 time has not yet been reached. However, this `retry time not reached' message
28564 is always omitted from individual message logs after the first delivery
28565 attempt.
28566 .nextp
28567 .index log||return path
28568 \return@_path@_on@_delivery\: The return path that is being transmitted with
28569 the message is included in delivery and bounce lines, using the tag P=.
28570 .em
28571 This is omitted if no delivery actually happens, for example, if routing fails, 
28572 or if delivery is to \(/dev/null)\ or to \":blackhole:"\.
28573 .nem
28574 .nextp
28575 .index log||sender on delivery
28576 \sender@_on@_delivery\: The message's sender address is added to every delivery
28577 and bounce line, tagged by F= (for `from').
28578 This is the original sender that was received with the message; it is not
28579 necessarily the same as the outgoing return path.
28580 .nextp
28581 .index log||size rejection
28582 \size@_reject\: A log line is written whenever a message is rejected because it
28583 is too big.
28584 .nextp
28585 .index log||frozen messages, skipped
28586 .index frozen messages||logging skipping
28587 \skip@_delivery\: A log line is written whenever a message is skipped during a
28588 queue run because it is frozen or because another process is already delivering
28589 it.
28590 .em
28591 .index `spool file is locked'
28592 The message that is written is `spool file is locked'.
28593 .nem
28594 .nextp
28595 .index log||smtp confirmation
28596 .index SMTP||logging confirmation
28597 \smtp@_confirmation\: The response to the final `.' in the SMTP dialogue for
28598 outgoing messages is added to delivery log lines in the form `C="<<text>>"'. A
28599 number of MTAs (including Exim) return an identifying string in this response.
28600 .nextp
28601 .index log||SMTP connections
28602 .index SMTP||logging connections
28603 \smtp@_connection\: A log line is written whenever an SMTP connection is
28604 established or closed,
28605 .em
28606 unless the connection is from a host that matches \hosts@_connection@_nolog\.
28607 .nem
28608 (In contrast, \lost__incoming__connection\ applies only when the closure is
28609 unexpected.) This applies to connections from local processes that use \-bs-\
28610 as well as to TCP/IP connections. If a connection is dropped in the middle of a
28611 message, a log line is always written, whether or not this selector is set, but
28612 otherwise nothing is written at the start and end of connections unless this
28613 selector is enabled.
28614
28615 For TCP/IP connections to an Exim daemon, the current number of connections is
28616 included in the log message for each new connection, but note that the count is
28617 reset if the daemon is restarted.
28618 Also, because connections are closed (and the closure is logged) in
28619 subprocesses, the count may not include connections that have been closed but
28620 whose termination the daemon has not yet noticed. Thus, while it is possible to
28621 match up the opening and closing of connections in the log, the value of the
28622 logged counts may not be entirely accurate.
28623 .nextp
28624 .index log||SMTP transaction, incomplete
28625 .index SMTP||logging incomplete transactions
28626 \smtp@_incomplete@_transaction\: When a mail transaction is aborted by
28627 \\RSET\\, \\QUIT\\, loss of connection, or otherwise, the incident is logged,
28628 and the message sender plus any accepted recipients are included in the log
28629 line. This can provide evidence of dictionary attacks.
28630 .nextp
28631 .index log||SMTP protocol error
28632 .index SMTP||logging protocol error
28633 \smtp@_protocol@_error\: A log line is written for every SMTP protocol error
28634 encountered.
28635 Exim does not have perfect detection of all protocol errors because of
28636 transmission delays and the use of pipelining. If \\PIPELINING\\ has been
28637 advertised to a client, an Exim server assumes that the client will use it, and
28638 therefore it does not count `expected' errors (for example, \\RCPT\\ received
28639 after rejecting \\MAIL\\) as protocol errors.
28640 .nextp
28641 .index SMTP||logging syntax errors
28642 .index SMTP||syntax errors, logging
28643 .index SMTP||unknown command, logging
28644 .index log||unknown SMTP command
28645 .index log||SMTP syntax error
28646 \smtp@_syntax@_error\: A log line is written for every SMTP syntax error
28647 encountered. An unrecognized command is treated as a syntax error. For an
28648 external connection, the host identity is given; for an internal connection
28649 using \-bs-\ the sender identification (normally the calling user) is given.
28650 .nextp
28651 .index log||subject
28652 .index subject, logging
28653 \subject\: The subject of the message is added to the arrival log line,
28654 preceded by `T=' (T for `topic', since S is already used for `size').
28655 Any MIME `words' in the subject are decoded. The \print@_topbitchars\ option
28656 specifies whether characters with values greater than 127 should be logged
28657 unchanged, or whether they should be rendered as escape sequences.
28658 .nextp
28659 .index log||certificate verification
28660 \tls@_certificate@_verified\: An extra item is added to <= and => log lines
28661 when TLS is in use. The item is \"CV=yes"\ if the peer's certificate was
28662 verified, and \"CV=no"\ if not.
28663 .nextp
28664 .index log||TLS cipher
28665 .index TLS||logging cipher
28666 \tls@_cipher\: When a message is sent or received over an encrypted connection,
28667 the cipher suite used is added to the log line, preceded by X=.
28668 .nextp
28669 .index log||TLS peer DN
28670 .index TLS||logging peer DN
28671 \tls@_peerdn\: When a message is sent or received over an encrypted connection,
28672 and a certificate is supplied by the remote host, the peer DN is added to the
28673 log line, preceded by DN=.
28674 .endp
28675
28676 .section Message log
28677 .index message||log file for
28678 .index log||message log, description of
28679 In addition to the general log files, Exim writes a log file for each message
28680 that it handles. The names of these per-message logs are the message ids, and
28681 .index \(msglog)\ directory
28682 they are kept in the \(msglog)\ sub-directory of the spool directory. Each
28683 message log contains copies of the log lines that apply to the message. This
28684 makes it easier to inspect the status of an individual message without having
28685 to search the main log. A message log is deleted when processing of the message
28686 is complete,
28687 .index \preserve@_message@_logs\
28688 unless \preserve__message__logs\ is set, but this should be used only with
28689 great care because they can fill up your disk very quickly.
28690
28691 On a heavily loaded system, it may be desirable to disable the use of
28692 per-message logs, in order to reduce disk I/O. This can be done by setting the
28693 \message@_logs\ option false.
28694
28695
28696
28697 .
28698 .
28699 .
28700 . ============================================================================
28701 .chapter Exim utilities
28702 .set runningfoot "utilities"
28703 .rset CHAPutils ~~chapter
28704 .index utilities
28705 A number of utility scripts and programs are supplied with Exim and are
28706 described in this chapter. There is also the Exim Monitor, which is covered in
28707 the next chapter. The utilities described here are:
28708
28709 . This duplication seems to be the only way to arrange that the cross-
28710 . references are omitted in the Texinfo version. They look horribly ugly.
28711
28712 .if ~~texinfo
28713 .display rm
28714 .tabs 22
28715 \*exiwhat*\           $t $rm{list what Exim processes are doing}
28716 .newline
28717 \*exiqgrep*\          $t $rm{grep the queue}
28718 .newline
28719 \*exiqsumm*\          $t $rm{summarize the queue}
28720 \*exigrep*\           $t $rm{search the main log}
28721 \*exipick*\           $t $rm{select messages on various criteria}
28722 \*exicyclog*\         $t $rm{cycle (rotate) log files}
28723 \*eximstats*\         $t $rm{extract statistics from the log}
28724 \*exim@_checkaccess*\ $t $rm{check address acceptance from given IP}
28725 \*exim@_dbmbuild*\    $t $rm{build a DBM file}
28726 \*exinext*\           $t $rm{extract retry information}
28727 \*exim@_dumpdb*\      $t $rm{dump a hints database}
28728 \*exim@_tidydb*\      $t $rm{clean up a hints database}
28729 \*exim@_fixdb*\       $t $rm{patch a hints database}
28730 \*exim@_lock*\        $t $rm{lock a mailbox file}
28731 .endd
28732 .
28733 .else
28734 .
28735 .display rm
28736 .tabs 22
28737 ~~SECTfinoutwha  \*exiwhat*\           $t $rm{list what Exim processes are doing}
28738 ~~SECTgreptheque  \*exiqgrep*\         $t $rm{grep the queue}
28739 ~~SECTsumtheque  \*exiqsumm*\          $t $rm{summarize the queue}
28740 ~~SECTextspeinf  \*exigrep*\           $t $rm{search the main log}
28741 ~~SECTexipick  \*exipick*\           $t $rm{select messages on various criteria}
28742 ~~SECTcyclogfil  \*exicyclog*\         $t $rm{cycle (rotate) log files}
28743 ~~SECTmailstat  \*eximstats*\         $t $rm{extract statistics from the log}
28744 ~~SECTcheckaccess  \*exim@_checkaccess*\ $t $rm{check address acceptance from given IP}
28745 ~~SECTdbmbuild  \*exim@_dbmbuild*\    $t $rm{build a DBM file}
28746 ~~SECTfinindret  \*exinext*\           $t $rm{extract retry information}
28747 ~~SECThindatmai  \*exim@_dumpdb*\      $t $rm{dump a hints database}
28748 ~~SECThindatmai  \*exim@_tidydb*\      $t $rm{clean up a hints database}
28749 ~~SECThindatmai  \*exim@_fixdb*\       $t $rm{patch a hints database}
28750 ~~SECTmailboxmaint  \*exim@_lock*\     $t $rm{lock a mailbox file}
28751 .endd
28752 .fi
28753
28754 .section Finding out what Exim processes are doing (exiwhat)
28755 .rset SECTfinoutwha "~~chapter.~~section"
28756 .index \*exiwhat*\
28757 .index process, querying
28758 .index \\SIGUSR1\\
28759 On operating systems that can restart a system call after receiving a signal
28760 (most modern OS), an Exim process responds to the \\SIGUSR1\\ signal by writing
28761 a line describing what it is doing to the file \(exim-process.info)\ in the
28762 Exim spool directory. The \*exiwhat*\ script sends the signal to all Exim
28763 processes it can find, having first emptied the file. It then waits for one
28764 second to allow the Exim processes to react before displaying the results. In
28765 order to run \*exiwhat*\ successfully you have to have sufficient privilege to
28766 send the signal to the Exim processes, so it is normally run as root.
28767
28768 .em
28769 \**Warning**\: This is not an efficient process. It is intended for occasional 
28770 use by system administrators. It is not sensible, for example, to set up a 
28771 script that sends \\SIGUSR1\\ signals to Exim processes at short intervals.
28772 .nem
28773
28774 Unfortunately, the \*ps*\ command that \*exiwhat*\ uses to find Exim processes
28775 varies in different operating systems. Not only are different options used,
28776 but the format of the output is different. For this reason, there are some
28777 system configuration options that configure exactly how \*exiwhat*\ works. If it
28778 doesn't seem to be working for you, check the following compile-time options:
28779 .display
28780 EXIWHAT@_PS@_CMD     $rm{the command for running \*ps*\}
28781 EXIWHAT@_PS@_ARG     $rm{the argument for \*ps*\}
28782 EXIWHAT@_EGREP@_ARG  $rm{the argument for \*egrep*\ to select from \*ps*\ output}
28783 EXIWHAT@_KILL@_ARG   $rm{the argument for the \*kill*\ command}
28784 .endd
28785 An example of typical output from \*exiwhat*\ is
28786 .display
28787 .indent 0
28788   164 daemon: -q1h, listening on port 25
28789 10483 running queue: waiting for 0tAycK-0002ij-00 (10492)
28790 10492 delivering 0tAycK-0002ij-00 to mail.ref.example [10.19.42.42]
28791   (editor@@ref.example)
28792 10592 handling incoming call from [192.168.243.242]
28793 10628 accepting a local non-SMTP message
28794 .endd
28795 The first number in the output line is the process number. The third line has
28796 been split here, in order to fit it on the page.
28797
28798
28799 .section Selective queue listing (exiqgrep)
28800 .rset SECTgreptheque "~~chapter.~~section"
28801 .index \*exiqgrep*\
28802 .index queue||grepping
28803 This utility is a Perl script contributed by Matt Hubbard. It runs
28804 .display asis
28805 exim -bpu
28806 .endd
28807 to obtain a queue listing with undelivered recipients only, and then greps the
28808 output to select messages that match given criteria. The following selection
28809 options are available:
28810
28811 .startoptions
28812
28813 .option f <<regex>>
28814 Match the sender address. The field that is tested is enclosed in angle
28815 brackets, so you can test for bounce messages with
28816 .display asis
28817 exiqgrep -f '^<>$'
28818 .endd
28819
28820 .option r <<regex>>
28821 Match a recipient address. The field that is tested is not enclosed in angle
28822 brackets.
28823
28824 .option s <<regex>>
28825 Match against the size field.
28826
28827 .option y <<seconds>>
28828 Match messages that are younger than the given time.
28829
28830 .option o <<seconds>>
28831 Match messages that are older than the given time.
28832
28833 .option z
28834 Match only frozen messages.
28835
28836 .option x
28837 Match only non-frozen messages.
28838
28839 .endoptions
28840
28841 The following options control the format of the output:
28842
28843 .startoptions
28844
28845 .option c
28846 Display only the count of matching messages.
28847
28848 .option l
28849 Long format -- display the full message information as output by Exim. This is
28850 the default.
28851
28852 .option i
28853 Display message ids only.
28854
28855 .option b
28856 Brief format -- one line per message.
28857
28858 .option R
28859 Display messages in reverse order.
28860
28861 .endoptions
28862
28863 There is one more option, \-h-\, which outputs a list of options.
28864
28865
28866 .section Summarising the queue (exiqsumm)
28867 .rset SECTsumtheque "~~chapter.~~section"
28868 .index \*exiqsumm*\
28869 .index queue||summary
28870 The \*exiqsumm*\ utility is a Perl script which reads the output of \*exim
28871 -bp*\ and produces a summary of the messages on the queue. Thus, you use it by
28872 running a command such as
28873 .display asis
28874 exim -bp | exiqsumm
28875 .endd
28876 The output consists of one line for each domain that has messages waiting for
28877 it, as in the following example:
28878 .display asis
28879   3   2322   74m   66m  msn.com.example
28880 .endd
28881 Each line lists the number of
28882 pending deliveries for a domain, their total volume, and the length of time
28883 that the oldest and the newest messages have been waiting. Note that the number
28884 of pending deliveries is greater than the number of messages when messages
28885 have more than one recipient.
28886
28887 A summary line is output at the end. By default the output is sorted on the
28888 domain name, but \*exiqsumm*\ has the options \-a-\ and \-c-\, which cause the
28889 output to be sorted by oldest message and by count of messages, respectively.
28890
28891 The output of \*exim -bp*\ contains the original addresses in the message, so
28892 this also applies to the output from \*exiqsumm*\. No domains from addresses
28893 generated by aliasing or forwarding are included (unless the \one@_time\ option
28894 of the \%redirect%\ router has been used to convert them into `top level'
28895 addresses).
28896
28897
28898
28899 .section Extracting specific information from the log (exigrep)
28900 .rset SECTextspeinf "~~chapter.~~section"
28901 .index \*exigrep*\
28902 .index log||extracts, grepping for
28903 The \*exigrep*\ utility is a Perl script that searches one or more main log
28904 files for entries that match a given pattern. When it finds a match, it
28905 extracts all the log entries for the relevant message, not just those that
28906 match the pattern. Thus, \*exigrep*\ can extract complete log entries for a
28907 given message, or all mail for a given user, or for a given host, for example.
28908
28909 If a matching log line is not associated with a specific message, it is always
28910 included in \*exigrep*\'s output.
28911 The usage is:
28912 .display asis
28913 exigrep [-l] [-t<n>] <pattern> [<log file>] ...
28914 .endd
28915 The \-t-\ argument specifies a number of seconds. It adds an additional
28916 condition for message selection. Messages that are complete are shown only if
28917 they spent more than <<n>> seconds on the queue.
28918
28919 The \-l-\ flag means `literal', that is, treat all characters in the
28920 pattern as standing for themselves. Otherwise the pattern must be a Perl
28921 regular expression. The pattern match is case-insensitive. If no file names are
28922 given on the command line, the standard input is read.
28923
28924 If the location of a \*zcat*\ command is known from the definition of
28925 \\ZCAT@_COMMAND\\ in \(Local/Makefile)\, \*exigrep*\ automatically passes any
28926 file whose name ends in \\COMPRESS@_SUFFIX\\ through \*zcat*\ as it searches
28927 it.
28928
28929 .section Selecting messages by various criteria (exipick)
28930 .rset SECTexipick "~~chapter.~~section"
28931 .index \*exipick*\
28932 John Jetmore's \*exipick*\ utility is included in the Exim distribution. It
28933 lists messages from the queue according to a variety of criteria. For details,
28934 run:
28935 .display asis
28936 exipick --help
28937 .endd
28938
28939
28940 .section Cycling log files (exicyclog)
28941 .rset SECTcyclogfil "~~chapter.~~section"
28942 .index log||cycling local files
28943 .index cycling logs
28944 .index \*exicyclog*\
28945 The \*exicyclog*\ script can be used to cycle (rotate) \*mainlog*\ and
28946 \*rejectlog*\ files. This is not necessary if only syslog is being used, or if
28947 you are using log files with datestamps in their names (see section
28948 ~~SECTdatlogfil). Some operating systems have their own standard mechanisms for
28949 log cycling, and these can be used instead of \*exicyclog*\ if preferred.
28950
28951 Each time \*exicyclog*\ is run the file names get `shuffled down' by one. If
28952 the main log file name is \(mainlog)\ (the default) then when \*exicyclog*\ is
28953 run \(mainlog)\ becomes \(mainlog.01)\, the previous \(mainlog.01)\ becomes
28954 \(mainlog.02)\ and so on, up to a limit which is set in the script, and which
28955 defaults to 10. 
28956 .em
28957 Log files whose numbers exceed the limit are discarded.
28958 .nem
28959 Reject logs are handled similarly.
28960
28961 .em
28962 If the limit is greater than 99, the script uses 3-digit numbers such as
28963 \(mainlog.001)\, \(mainlog.002)\, etc. If you change from a number less than 99
28964 to one that is greater, or \*vice versa*\, you will have to fix the names of
28965 any existing log files.
28966 .nem
28967
28968 If no \(mainlog)\ file exists, the script does nothing. Files that `drop off'
28969 the end are deleted. All files with numbers greater than 01 are compressed,
28970 using a compression command which is configured by the \\COMPRESS@_COMMAND\\
28971 setting in \(Local/Makefile)\. It is usual to run \*exicyclog*\ daily from a
28972 root \crontab\ entry of the form
28973 .display
28974 1 0 * * * su exim -c /usr/exim/bin/exicyclog
28975 .endd
28976 assuming you have used the name `exim' for the Exim user. You can run
28977 \*exicyclog*\ as root if you wish, but there is no need.
28978
28979
28980 .section Mail statistics (eximstats)
28981 .rset SECTmailstat "~~chapter.~~section"
28982 .index statistics
28983 .index \*eximstats*\
28984 A Perl script called \*eximstats*\ is provided for extracting statistical
28985 information from log files. The output is either plain text, or HTML.
28986 Exim log files are also suported by the \*Lire*\ system produced by the
28987 LogReport Foundation (\?http://www.logreport.org?\).
28988
28989 The \*eximstats*\ script has been hacked about quite a bit over time. The
28990 latest version is the result of some extensive revision by Steve Campbell. A
28991 lot of information is given by default, but there are options for suppressing
28992 various parts of it. Following any options, the arguments to the script are a
28993 list of files, which should be main log files. For example:
28994 .display asis
28995 eximstats -nr /var/spool/exim/log/mainlog.01
28996 .endd
28997 By default, \*eximstats*\ extracts information about the number and volume of
28998 messages received from or delivered to various hosts. The information is sorted
28999 both by message count and by volume, and the top fifty hosts in each category
29000 are listed on the standard output. Similar information, based on email
29001 addresses or domains instead of hosts can be requested by means of various
29002 options. For messages delivered and received locally, similar statistics are
29003 also produced per user.
29004
29005 The output also includes total counts and statistics about delivery errors, and
29006 histograms showing the number of messages received and deliveries made in each
29007 hour of the day. A delivery with more than one address in its envelope (for
29008 example, an SMTP transaction with more than one \\RCPT\\ command) is counted
29009 as a single delivery by \*eximstats*\.
29010
29011 Though normally more deliveries than receipts are reported (as messages may
29012 have multiple recipients), it is possible for \*eximstats*\ to report more
29013 messages received than delivered, even though the queue is empty at the start
29014 and end of the period in question. If an incoming message contains no valid
29015 recipients, no deliveries are recorded for it. A bounce message is handled as
29016 an entirely separate message.
29017
29018 \*eximstats*\ always outputs a grand total summary giving the volume and number
29019 of messages received and deliveries made, and the number of hosts involved in
29020 each case. It also outputs the number of messages that were delayed (that is,
29021 not completely delivered at the first attempt), and the number that had at
29022 least one address that failed.
29023
29024 The remainder of the output is in sections that can be independently disabled
29025 or modified by various options. It consists of a summary of deliveries by
29026 transport, histograms of messages received and delivered per time interval
29027 (default per hour), information about the time messages spent on the queue,
29028 a list of relayed messages, lists of the top fifty sending hosts, local
29029 senders, destination hosts, and destination local users by count and by volume,
29030 and a list of delivery errors that occurred.
29031
29032 The relay information lists messages that were actually relayed, that is, they
29033 came from a remote host and were directly delivered to some other remote host,
29034 without being processed (for example, for aliasing or forwarding) locally.
29035
29036 The options for \*eximstats*\ are as follows:
29037
29038 .startoptions
29039 .index \*eximstats*\||options
29040 .option bydomain
29041 The `league tables' are computed on the basis of the superior domains of the
29042 sending hosts instead of the sending and receiving hosts. This option may be
29043 combined with \-byhost-\ and/or \-byemail-\.
29044
29045 .option byedomain
29046 This is a synonym for \-byemaildomain-\.
29047
29048 .option byemail
29049 The `league tables' are computed on the basis of complete email addresses,
29050 instead of sending and receiving hosts. This option may be combined with
29051 \-byhost-\ and/or \-bydomain-\.
29052
29053 .option byemaildomain
29054 The `league tables' are computed on the basis of the sender's email domain
29055 instead of the sending and receiving hosts. This option may be combined with
29056 \-byhost-\, \-bydomain-\, or \-byemail-\.
29057
29058 .option byhost
29059 The `league tables' are computed on the basis of sending and receiving hosts.
29060 This is the default option. It may be combined with \-bydomain-\ and/or
29061 \-byemail-\.
29062
29063 .option cache
29064 Cache results of \*timegm()*\ lookups. This results in a significant speedup
29065 when processing hundreds of thousands of messages, at a cost of increasing the
29066 memory utilisation.
29067
29068 .option chartdir <<dir>>
29069 When \-charts-\ is specified, create the charts in the directory <<dir>>.
29070
29071 .option chartrel <<dir>>
29072 When \-charts-\ is specified, this option specifies the relative directory for
29073 the \"img src="\ tags from where to include the charts.
29074
29075 .option charts
29076 Create graphical charts to be displayed in HTML output. This requires the
29077 \"GD"\, \"GDTextUtil"\, and \"GDGraph"\ Perl modules, which can be obtained
29078 from \?http://www.cpan.org/modules/01modules.index.html?\.
29079
29080 To install these, download and unpack them, then use the normal Perl
29081 installation procedure:
29082 .display asis
29083 perl Makefile.PL
29084 make
29085 make test
29086 make install
29087 .endd
29088
29089 .option d
29090 This is a debug flag. It causes \*eximstats*\ to output the \*eval()*\'d parser
29091 to the standard output, which makes it easier to trap errors in the eval
29092 section. Remember to add one to the line numbers to allow for the title.
29093
29094
29095 .option help
29096 Show help information about \*eximstats*\' options.
29097
29098 .option h <<n>>
29099 This option controls the histograms of messages received and deliveries per
29100 time interval. By default the time interval is one hour. If \-h0-\ is given,
29101 the histograms are suppressed; otherwise the value of <<n>> gives the number of
29102 divisions per hour. Valid values are 0, 1, 2, 3, 5, 10, 15, 20, 30 or 60, so
29103 \-h2-\ sets an interval of 30 minutes, and the default is equivalent to \-h1-\.
29104
29105 .option html
29106 Output the results in HTML instead of plain text.
29107
29108 .option merge
29109 This option causes \*eximstats*\ to merge old reports into a combined report.
29110 When this option is used, the input files must be outputs from previous calls
29111 to \*eximstats*\, not raw log files. For example, you could produce a set of
29112 daily reports and a weekly report by commands such as
29113 .display asis
29114 eximstats mainlog.sun > report.sun.txt
29115 eximstats mainlog.mon > report.mon.txt
29116 eximstats mainlog.tue > report.tue.txt
29117 eximstats mainlog.wed > report.wed.txt
29118 eximstats mainlog.thu > report.thu.txt
29119 eximstats mainlog.fri > report.fri.txt
29120 eximstats mainlog.sat > report.sat.txt
29121 eximstats -merge -html report.*.txt > weekly_report.html
29122 .endd
29123 You can merge text or html reports and output the results as text or html. You
29124 can use all the normal \*eximstats*\ output options, but only data included in
29125 the original reports can be shown. When merging reports, some loss of accuracy
29126 may occur in the `league tables', towards the ends of the lists. The order of
29127 items in the `league tables' may vary when the data volumes round to the same
29128 value.
29129
29130 .option ne
29131 Suppress the display of information about failed deliveries (errors).
29132
29133 .option nr
29134 Suppress information about messages relayed through this host.
29135
29136 .option nr /pattern/
29137 Suppress information about relayed messages that match the pattern, which is
29138 matched against a string of the following form (split over two lines here in
29139 order to fit it on the page):
29140 .display asis
29141 H=<host> [<ip address>] A=<sender address> =>
29142   H=<host> A=<recipient address>
29143 .endd
29144 for example
29145 .display asis
29146 H=in.host [1.2.3.4] A=from@some.where.example =>
29147   H=out.host A=to@else.where.example
29148 .endd
29149 The sending host name appears in parentheses if it has not been verified as
29150 matching the IP address. The mail addresses are taken from the envelope, not
29151 the headers. This option allows you to screen out hosts whom you are happy to
29152 have using your host as a relay.
29153
29154 .option nt
29155 Suppress the statistics about delivery by transport.
29156
29157 .option nt/<<pattern>>/
29158 Suppress the statistics about delivery by any transport whose name matches the
29159 pattern. If you are using one transport to send all messages to a scanning
29160 mechanism before doing the real delivery, this feature can be used to omit that
29161 transport from your normal statistics (on the grounds that it is of no
29162 interest).
29163
29164
29165 .option "pattern" "#<<description>>#/<<pattern>>/"
29166 Count lines matching specified patterns and show them in
29167 the results. For example:
29168 .display asis
29169 -pattern 'Refused connections' '/refused connection/'
29170 .endd
29171 This option can be specified multiple times.
29172
29173 .option q0
29174 Suppress information about times messages spend on the queue.
29175
29176 .option q <<n1>>...
29177 This option sets an alternative list of time intervals for the queueing
29178 information. The values are separated by commas and are in seconds, but can
29179 involve arithmetic multipliers, so for example you can set 3$*$60 to specify 3
29180 minutes. A setting such as
29181 .display asis
29182 -q60,5*60,10*60
29183 .endd
29184 causes \*eximstats*\ to give counts of messages that stayed on the queue for less
29185 than one minute, less than five minutes, less than ten minutes, and over ten
29186 minutes.
29187
29188 .option t <<n>>
29189 Sets the `top' count to <<n>>. This controls the listings of the `top <<n>>'
29190 hosts and users by count and volume. The default is 50, and setting 0
29191 suppresses the output altogether.
29192
29193 .option tnl
29194 Omit local information from the `top' listings.
29195
29196 .option t@_remote@_users
29197 Include remote users in the `top' listings.
29198
29199 .endoptions
29200
29201
29202 .section Checking access policy (exim@_checkaccess)
29203 .rset SECTcheckaccess "~~chapter.~~section"
29204 .index \*exim@_checkaccess*\
29205 .index policy control||checking access
29206 .index checking access
29207 The \-bh-\ command line argument allows you to run a fake SMTP session with
29208 debugging output, in order to check what Exim is doing when it is applying
29209 policy controls to incoming SMTP mail. However, not everybody is sufficiently
29210 familiar with the SMTP protocol to be able to make full use of \-bh-\, and
29211 sometimes you just want to answer the question \*Does this address have
29212 access?*\ without bothering with any further details.
29213
29214 The \*exim@_checkaccess*\ utility is a `packaged' version of \-bh-\. It takes
29215 two arguments, an IP address and an email address:
29216 .display asis
29217 exim_checkaccess 10.9.8.7 A.User@a.domain.example
29218 .endd
29219 The utility runs a call to Exim with the \-bh-\ option, to test whether the
29220 given email address would be accepted in a \\RCPT\\ command in a TCP/IP
29221 connection from the host with the given IP address. The output of the utility
29222 is either the word `accepted', or the SMTP error response, for example:
29223 .display asis
29224 Rejected:
29225   550 Relay not permitted
29226 .endd
29227 When running this test, the utility uses \"<>"\ as the envelope sender address
29228 for the \\MAIL\\ command, but you can change this by providing additional
29229 options. These are passed directly to the Exim command. For example, to specify
29230 that the test is to be run with the sender address \*himself@@there.example*\
29231 you can use:
29232 .display asis
29233 exim_checkaccess 10.9.8.7 A.User@a.domain.example \
29234                  -f himself@there.example
29235 .endd
29236 Note that these additional Exim command line items must be given after the two
29237 mandatory arguments.
29238
29239 Because the \exim@_checkaccess\ uses \-bh-\, it does not perform callouts while
29240 running its checks. You can run checks that include callouts by using \-bhc-\,
29241 but this is not yet available in a `packaged' form.
29242
29243
29244 .section Making DBM files (exim@_dbmbuild)
29245 .rset SECTdbmbuild "~~chapter.~~section"
29246 .index DBM||building dbm files
29247 .index building DBM files
29248 .index \*exim@_dbmbuild*\
29249 .index lower casing
29250 .index binary zero||in lookup key
29251 The \*exim@_dbmbuild*\ program reads an input file containing keys and data in
29252 the format used by the \%lsearch%\ lookup (see section ~~SECTsinglekeylookups).
29253 It writes a DBM file using the lower-cased alias names as keys and the
29254 remainder of the information as data. The lower-casing can be prevented by
29255 calling the program with the \-nolc-\ option.
29256
29257 A terminating zero is included as part of the key string. This is expected by
29258 the \%dbm%\ lookup type. However, if the option \-nozero-\ is given,
29259 \*exim@_dbmbuild*\ creates files without terminating zeroes in either the key
29260 strings or the data strings. The \%dbmnz%\ lookup type can be used with such
29261 files.
29262
29263 The program requires two arguments: the name of the input file (which can be a
29264 single hyphen to indicate the standard input), and the name of the output file.
29265 It creates the output under a temporary name, and then renames it if all went
29266 well.
29267 .index \\USE@_DB\\
29268 If the native DB interface is in use (\\USE@_DB\\ is set in a compile-time
29269 configuration file -- this is common in free versions of Unix) the two file
29270 names must be different, because in this mode the Berkeley DB functions create
29271 a single output file using exactly the name given. For example,
29272 .display asis
29273 exim_dbmbuild /etc/aliases /etc/aliases.db
29274 .endd
29275 reads the system alias file and creates a DBM version of it in
29276 \(/etc/aliases.db)\.
29277
29278 In systems that use the \*ndbm*\ routines (mostly proprietary versions of Unix),
29279 two files are used, with the suffixes \(.dir)\ and \(.pag)\. In this
29280 environment, the suffixes are added to the second argument of
29281 \*exim@_dbmbuild*\, so it can be the same as the first. This is also the case
29282 when the Berkeley functions are used in compatibility mode (though this is not
29283 recommended), because in that case it adds a \(.db)\ suffix to the file name.
29284
29285 If a duplicate key is encountered, the program outputs a warning, and when it
29286 finishes, its return code is 1 rather than zero, unless the \-noduperr-\ option
29287 is used. By default, only the first of a set of duplicates is used -- this
29288 makes it compatible with \%lsearch%\ lookups. There is an option \-lastdup-\
29289 which causes it to use the data for the last duplicate instead. There is also
29290 an option \-nowarn-\, which stops it listing duplicate keys to \stderr\. For
29291 other errors, where it doesn't actually make a new file, the return code is 2.
29292
29293
29294
29295 .section Finding individual retry times (exinext)
29296 .rset SECTfinindret "~~chapter.~~section"
29297 .index retry||times
29298 .index \*exinext*\
29299 A utility called \*exinext*\ (mostly a Perl script) provides the ability to fish
29300 specific information out of the retry database. Given a mail domain (or a
29301 complete address), it looks up the hosts for that domain, and outputs any retry
29302 information for the hosts or for the domain. At present, the retry information
29303 is obtained by running \*exim@_dumpdb*\ (see below) and post-processing the
29304 output. For example:
29305 .display asis
29306 $ exinext piglet@milne.fict.example
29307 kanga.milne.fict.example:192.168.8.1 error 146: Connection refused
29308   first failed: 21-Feb-1996 14:57:34
29309   last tried:   21-Feb-1996 14:57:34
29310   next try at:  21-Feb-1996 15:02:34
29311 roo.milne.fict.example:192.168.8.3 error 146: Connection refused
29312   first failed: 20-Jan-1996 13:12:08
29313   last tried:   21-Feb-1996 11:42:03
29314   next try at:  21-Feb-1996 19:42:03
29315   past final cutoff time
29316 .endd
29317 You can also give \*exinext*\ a local part, without a domain, and it
29318 will give any retry information for that local part in your default domain.
29319 A message id can be used to obtain retry information pertaining to a specific
29320 message. This exists only when an attempt to deliver a message to a remote host
29321 suffers a message-specific error (see section ~~SECToutSMTPerr). \*exinext*\ is
29322 not particularly efficient, but then it isn't expected to be run very often.
29323
29324 The \*exinext*\ utility calls Exim to find out information such as the location
29325 of the spool directory. The utility has \-C-\ and \-D-\ options, which are
29326 passed on to the \*exim*\ commands. The first specifies an alternate Exim
29327 configuration file, and the second sets macros for use within the configuration
29328 file. These features are mainly to help in testing, but might also be useful in
29329 environments where more than one configuration file is in use.
29330
29331
29332
29333 .section Hints database maintenance (exim@_dumpdb, exim@_fixdb, exim@_tidydb)
29334 .rset SECThindatmai "~~chapter.~~section"
29335 .index hints database||maintenance
29336 .index maintaining Exim's hints database
29337 Three utility programs are provided for maintaining the DBM files that Exim
29338 uses to contain its delivery hint information. Each program requires two
29339 arguments. The first specifies the name of Exim's spool directory, and the
29340 second is the name of the database it is to operate on. These are as
29341 follows:
29342 .numberpars $.
29343 \*retry*\: the database of retry information
29344 .nextp
29345 \*wait-*\<<transport name>>: databases of information about messages waiting
29346 for remote hosts
29347 .nextp
29348 \*callout*\: the callout cache
29349 .nextp
29350 \*misc*\: other hints data
29351 .endp
29352 The \*misc*\ database is used for
29353 .numberpars alpha
29354 Serializing \\ETRN\\ runs (when \smtp@_etrn@_serialize\ is set)
29355 .nextp
29356 Serializing delivery to a specific host (when \serialize@_hosts\ is set in an
29357 \%smtp%\ transport)
29358 .endp
29359
29360 .section exim@_dumpdb
29361 .index \*exim@_dumpdb*\
29362 The entire contents of a database are written to the standard output by the
29363 \*exim@_dumpdb*\ program, which has no options or arguments other than the
29364 spool and database names. For example, to dump the retry database:
29365 .display asis
29366 exim_dumpdb /var/spool/exim retry
29367 .endd
29368 Two lines of output are produced for each entry:
29369 .display
29370   T:mail.ref.example:192.168.242.242 146 77 Connection refused
29371 31-Oct-1995 12:00:12  02-Nov-1995 12:21:39  02-Nov-1995 20:21:39 *
29372 .endd
29373 The first item on the first line is the key of the record. It starts with one
29374 of the letters R, or T, depending on whether it refers to a routing or
29375 transport retry. For a local delivery, the next part is the local address; for
29376 a remote delivery it is the name of the remote host, followed by its failing IP
29377 address (unless \no@_retry@_include@_ip@_address\ is set on the \%smtp%\
29378 transport). If the remote port is not the standard one (port 25), it is added
29379 to the IP address. Then there follows an error code, an additional error code,
29380 and a textual description of the error.
29381
29382 The three times on the second line are the time of first failure, the time of
29383 the last delivery attempt, and the computed time for the next attempt. The line
29384 ends with an asterisk if the cutoff time for the last retry rule has been
29385 exceeded.
29386
29387 Each output line from \*exim@_dumpdb*\ for the \*wait-*\$it{xxx} databases
29388 consists of a host name followed by a list of ids for messages that are or were
29389 waiting to be delivered to that host. If there are a very large number for any
29390 one host, continuation records, with a sequence number added to the host name,
29391 may be seen. The data in these records is often out of date, because a message
29392 may be routed to several alternative hosts, and Exim makes no effort to keep
29393 cross-references.
29394
29395
29396 .section exim@_tidydb
29397 .index \*exim@_tidydb*\
29398 The \*exim@_tidydb*\ utility program is used to tidy up the contents of the
29399 hints databases. If run with no options, it removes all records from a database
29400 that are more than 30 days old. The cutoff date can be altered by means of the
29401 \-t-\ option, which must be followed by a time. For example, to remove all
29402 records older than a week from the retry database:
29403 .display asis
29404 exim_tidydb -t 7d /var/spool/exim retry
29405 .endd
29406 Both the \*wait-*\$it{xxx} and \*retry*\ databases contain items that involve
29407 message ids. In the former these appear as data in records keyed by host --
29408 they were messages that were waiting for that host -- and in the latter they
29409 are the keys for retry information for messages that have suffered certain
29410 types of error. When \*exim@_tidydb*\ is run, a check is made to ensure that
29411 message ids in database records are those of messages that are still on the
29412 queue. Message ids for messages that no longer exist are removed from
29413 \*wait-*\$it{xxx} records, and if this leaves any records empty, they are
29414 deleted. For the \*retry*\ database, records whose keys are non-existent
29415 message ids are removed. The \*exim@_tidydb*\ utility outputs comments on the
29416 standard output whenever it removes information from the database.
29417
29418 .em
29419 Certain records are automatically removed by Exim when they are no longer 
29420 needed, but others are not. For example, if all the MX hosts for a domain are 
29421 down, a retry record is created for each one. If the primary MX host comes back
29422 first, its record is removed when Exim successfully delivers to it, but the 
29423 records for the others remain because Exim has not tried to use those hosts.
29424
29425 It is important, therefore, to run \*exim@_tidydb*\ periodically on all the
29426 hints databases. You should do this at a quiet time of day, because it requires
29427 a database to be locked (and therefore inaccessible to Exim) while it does its
29428 work. Removing records from a DBM file does not normally make the file smaller,
29429 but all the common DBM libraries are able to re-use the space that is released.
29430 After an initial phase of increasing in size, the databases normally reach a 
29431 point at which they no longer get any bigger, as long as they are regularly 
29432 tidied.
29433
29434 \**Warning**\: If you never run \*exim@_tidydb*\, the space used by the hints 
29435 databases is likely to keep on increasing.
29436 .nem
29437
29438
29439 .section exim@_fixdb
29440 .index \*exim@_fixdb*\
29441 The \*exim@_fixdb*\ program is a utility for interactively modifying databases.
29442 Its main use is for testing Exim, but it might also be occasionally useful for
29443 getting round problems in a live system. It has no options, and its interface
29444 is somewhat crude. On entry, it prompts for input with a right angle-bracket. A
29445 key of a database record can then be entered, and the data for that record is
29446 displayed.
29447
29448 If `d' is typed at the next prompt, the entire record is deleted. For all
29449 except the \*retry*\ database, that is the only operation that can be carried
29450 out. For the \*retry*\ database, each field is output preceded by a number, and
29451 data for individual fields can be changed by typing the field number followed
29452 by new data, for example:
29453 .display asis
29454 > 4 951102:1000
29455 .endd
29456 resets the time of the next delivery attempt. Time values are given as a
29457 sequence of digit pairs for year, month, day, hour, and minute. Colons can be
29458 used as optional separators.
29459
29460
29461
29462 .section Mailbox maintenance (exim@_lock)
29463 .rset SECTmailboxmaint "~~chapter.~~section"
29464 .index mailbox||maintenance
29465 .index \*exim@_lock*\
29466 .index locking mailboxes
29467 The \*exim@_lock*\ utility locks a mailbox file using the same algorithm as
29468 Exim. For a discussion of locking issues, see section ~~SECTopappend.
29469 \*Exim@_lock*\ can be used to prevent any modification of a mailbox by Exim or
29470 a user agent while investigating a problem. The utility requires the name of
29471 the file as its first argument. If the locking is successful, the second
29472 argument is run as a command (using C's \*system()*\ function); if there is no
29473 second argument, the value of the SHELL environment variable is used; if this
29474 is unset or empty, \(/bin/sh)\ is run. When the command finishes, the mailbox
29475 is unlocked and the utility ends. The following options are available:
29476
29477 .startoptions
29478
29479 .option fcntl
29480 Use \*fcntl()*\ locking on the open mailbox.
29481
29482 .option flock
29483 Use \*flock()*\ locking on the open mailbox, provided the operating system
29484 supports it.
29485
29486 .option interval
29487 This must be followed by a number, which is a number of seconds; it sets the
29488 interval to sleep between retries (default 3).
29489
29490 .option lockfile
29491 Create a lock file before opening the mailbox.
29492
29493 .option mbx
29494 Lock the mailbox using MBX rules.
29495
29496 .option q
29497 Suppress verification output.
29498
29499 .option retries
29500 This must be followed by a number; it sets the number of times to try to get
29501 the lock (default 10).
29502
29503 .option restore@_time
29504 This option causes \exim@_lock\ to restore the modified and read times to the
29505 locked file before exiting. This allows you to access a locked mailbox (for
29506 example, to take a backup copy) without disturbing the times that the user
29507 subsequently sees.
29508
29509 .option timeout
29510 This must be followed by a number, which is a number of seconds; it sets a
29511 timeout to be used with a blocking \*fcntl()*\ lock. If it is not set (the
29512 default), a non-blocking call is used.
29513
29514 .option v
29515 Generate verbose output.
29516
29517 .endoptions
29518
29519 If none of \-fcntl-\,
29520 \-flock-\,
29521 \-lockfile-\ or \-mbx-\ are given, the default is to create a lock file and
29522 also to use \*fcntl()*\ locking on the mailbox, which is the same as Exim's
29523 default. The use of
29524 \-flock-\
29525 or \-fcntl-\ requires that the file be writeable; the use of
29526 \-lockfile-\ requires that the directory containing the file be writeable.
29527 Locking by lock file does not last for ever; Exim assumes that a lock file is
29528 expired if it is more than 30 minutes old.
29529
29530 The \-mbx-\ option can be used with either or both of \-fcntl-\ or \-flock-\.
29531 It assumes \-fcntl-\ by default.
29532 MBX locking causes a shared lock to be taken out on the open mailbox, and an
29533 exclusive lock on the file \(/tmp/.$it{n}.$it{m})\ where $it{n} and $it{m} are
29534 the device number and inode number of the mailbox file. When the locking is
29535 released, if an exclusive lock can be obtained for the mailbox, the file in
29536 \(/tmp)\ is deleted.
29537
29538 The default output contains verification of the locking that takes place. The
29539 \-v-\ option causes some additional information to be given. The \-q-\ option
29540 suppresses all output except error messages.
29541
29542 A command such as
29543 .display asis
29544 exim_lock /var/spool/mail/spqr
29545 .endd
29546 runs an interactive shell while the file is locked, whereas
29547 .display
29548 exim@_lock -q /var/spool/mail/spqr @<@<End
29549 <<some commands>>
29550 End
29551 .endd
29552 runs a specific non-interactive sequence of commands while the file is locked,
29553 suppressing all verification output. A single command can be run by a command
29554 such as
29555 .display asis
29556 exim_lock -q /var/spool/mail/spqr \
29557   "cp /var/spool/mail/spqr /some/where"
29558 .endd
29559 Note that if a command is supplied, it must be entirely contained within the
29560 second argument -- hence the quotes.
29561
29562
29563
29564 .
29565 .
29566 .
29567 .
29568 . ============================================================================
29569 .chapter The Exim monitor
29570 .set runningfoot "monitor"
29571 .rset CHAPeximon ~~chapter
29572 .index monitor
29573 .index Exim monitor
29574 .index X-windows
29575 .index \*eximon*\
29576 .index Local/eximon.conf
29577 .index \(exim@_monitor/EDITME)\
29578 The Exim monitor is an application which displays in an X window information
29579 about the state of Exim's queue and what Exim is doing. An admin user can
29580 perform certain operations on messages from this GUI interface; however all
29581 such facilities are also available from the command line, and indeed, the
29582 monitor itself makes use of the command line to perform any actions requested.
29583
29584
29585 .section Running the monitor
29586 The monitor is started by running the script called \*eximon*\. This is a shell
29587 script that sets up a number of environment variables, and then runs the
29588 binary called \(eximon.bin)\. The default appearance of the monitor window can
29589 be changed by editing the \(Local/eximon.conf)\ file created by editing
29590 \(exim@_monitor/EDITME)\. Comments in that file describe what the various
29591 parameters are for.
29592
29593 The parameters that get built into the \*eximon*\ script can be overridden for a
29594 particular invocation by setting up environment variables of the same names,
29595 preceded by `$tt{EXIMON@_}'. For example, a shell command such as
29596 .display asis
29597 EXIMON_LOG_DEPTH=400 eximon
29598 .endd
29599 (in a Bourne-compatible shell) runs \*eximon*\ with an overriding setting of the
29600 \\LOG@_DEPTH\\ parameter. If \\EXIMON@_LOG@_FILE@_PATH\\ is set in the
29601 environment, it overrides the Exim log file configuration. This makes it
29602 possible to have \*eximon*\ tailing log data that is written to syslog, provided
29603 that MAIL.INFO syslog messages are routed to a file on the local host.
29604
29605 X resources can be used to change the appearance of the window in the normal
29606 way. For example, a resource setting of the form
29607 .display asis
29608 Eximon*background: gray94
29609 .endd
29610 changes the colour of the background to light grey rather than white. The
29611 stripcharts are drawn with both the data lines and the reference lines in
29612 black. This means that the reference lines are not visible when on top of the
29613 data. However, their colour can be changed by setting a resource called
29614 `highlight' (an odd name, but that's what the Athena stripchart widget uses).
29615 For example, if your X server is running Unix, you could set up lighter
29616 reference lines in the stripcharts by obeying
29617 .display asis
29618 xrdb -merge <<End
29619 Eximon*highlight: gray
29620 End
29621 .endd
29622
29623 .index admin user
29624 In order to see the contents of messages on the queue, and to operate on them,
29625 \*eximon*\ must either be run as root or by an admin user.
29626
29627 The monitor's window is divided into three parts. The first contains one or
29628 more stripcharts and two action buttons, the second contains a `tail' of the
29629 main log file, and the third is a display of the queue of messages awaiting
29630 delivery, with two more action buttons. The following sections describe these
29631 different parts of the display.
29632
29633
29634
29635 .section The stripcharts
29636 .index stripchart
29637 The first stripchart is always a count of messages on the queue. Its name can
29638 be configured by setting \\QUEUE@_STRIPCHART@_NAME\\ in the
29639 \(Local/eximon.conf)\ file. The remaining stripcharts are defined in the
29640 configuration script by regular expression matches on log file entries, making
29641 it possible to display, for example, counts of messages delivered to certain
29642 hosts or using certain transports. The supplied defaults display counts of
29643 received and delivered messages, and of local and SMTP deliveries. The default
29644 period between stripchart updates is one minute; this can be adjusted by a
29645 parameter in the \(Local/eximon.conf)\ file.
29646
29647 The stripchart displays rescale themselves automatically as the value they are
29648 displaying changes. There are always 10 horizontal lines in each chart; the
29649 title string indicates the value of each division when it is greater than one.
29650 For example, `x2' means that each division represents a value of 2.
29651
29652 It is also possible to have a stripchart which shows the percentage fullness of
29653 a particular disk partition, which is useful when local deliveries are confined
29654 to a single partition.
29655 .index \statvfs\ function
29656 This relies on the availability of the \*statvfs()*\ function or equivalent in
29657 the operating system. Most, but not all versions of Unix that support Exim have
29658 this. For this particular stripchart, the top of the chart always represents
29659 100%, and the scale is given as `x10%'. This chart is configured by setting
29660 \\SIZE@_STRIPCHART\\ and (optionally) \\SIZE@_STRIPCHART@_NAME\\ in the
29661 \(Local/eximon.conf)\ file.
29662
29663
29664
29665 .section Main action buttons
29666 .index size||of monitor window
29667 .index monitor window size
29668 .index window size
29669 Below the stripcharts there is an action button for quitting the monitor. Next
29670 to this is another button marked `Size'. They are placed here so that shrinking
29671 the window to its default minimum size leaves just the queue count stripchart
29672 and these two buttons visible. Pressing the `Size' button causes the window to
29673 expand to its maximum size, unless it is already at the maximum, in which case
29674 it is reduced to its minimum.
29675
29676 When expanding to the maximum, if the window cannot be fully seen where it
29677 currently is, it is moved back to where it was the last time it was at full
29678 size. When it is expanding from its minimum size, the old position is
29679 remembered, and next time it is reduced to the minimum it is moved back there.
29680
29681 The idea is that you can keep a reduced window just showing one or two
29682 stripcharts at a convenient place on your screen, easily expand it to show
29683 the full window when required, and just as easily put it back to what it was.
29684 The idea is copied from what the \*twm*\ window manager does for its
29685 \*f.fullzoom*\ action. The minimum size of the window can be changed by setting
29686 the \\MIN@_HEIGHT\\ and \\MIN@_WIDTH\\ values in \(Local/eximon.conf)\.
29687
29688 Normally, the monitor starts up with the window at its full size, but it can be
29689 built so that it starts up with the window at its smallest size, by setting
29690 \\START@_SMALL\\=yes in \(Local/eximon.conf)\.
29691
29692
29693 .section The log display
29694 .index log||tail of, in monitor
29695 The second section of the window is an area in which a display of the tail of
29696 the main log is maintained.
29697 To save space on the screen, the timestamp on each log line is shortened by
29698 removing the date and, if \log@_timezone\ is set, the timezone.
29699 The log tail is not available when the only destination for logging data is
29700 syslog, unless the syslog lines are routed to a local file whose name is passed
29701 to \*eximon*\ via the \\EXIMON@_LOG@_FILE@_PATH\\ environment variable.
29702
29703 The log sub-window has a scroll bar at its lefthand side which can be used to
29704 move back to look at earlier text, and the up and down arrow keys also have a
29705 scrolling effect. The amount of log that is kept depends on the setting of
29706 \\LOG@_BUFFER\\ in \(Local/eximon.conf)\, which specifies the amount of memory
29707 to use. When this is full, the earlier 50% of data is discarded -- this is much
29708 more efficient than throwing it away line by line. The sub-window also has a
29709 horizontal scroll bar for accessing the ends of long log lines. This is the
29710 only means of horizontal scrolling; the right and left arrow keys are not
29711 available. Text can be cut from this part of the window using the mouse in the
29712 normal way. The size of this subwindow is controlled by parameters in the
29713 configuration file \(Local/eximon.conf)\.
29714
29715 Searches of the text in the log window can be carried out by means of the ^R
29716 and ^S keystrokes, which default to a reverse and a forward search,
29717 respectively. The search covers only the text that is displayed in the window.
29718 It cannot go further back up the log.
29719
29720 The point from which the search starts is indicated by a caret marker. This is
29721 normally at the end of the text in the window, but can be positioned explicitly
29722 by pointing and clicking with the left mouse button, and is moved automatically
29723 by a successful search. If new text arrives in the window when it is scrolled
29724 back, the caret remains where it is, but if the window is not scrolled back,
29725 the caret is moved to the end of the new text.
29726
29727 Pressing ^R or ^S pops up a window into which the search text can be typed.
29728 There are buttons for selecting forward or reverse searching, for carrying out
29729 the search, and for cancelling. If the `Search' button is pressed, the search
29730 happens and the window remains so that further searches can be done. If the
29731 `Return' key is pressed, a single search is done and the window is closed. If
29732 ^C is typed the search is cancelled.
29733
29734 The searching facility is implemented using the facilities of the Athena text
29735 widget. By default this pops up a window containing both `search' and `replace'
29736 options. In order to suppress the unwanted `replace' portion for eximon, a
29737 modified version of the \TextPop\ widget is distributed with Exim. However, the
29738 linkers in BSDI and HP-UX seem unable to handle an externally provided version
29739 of \TextPop\ when the remaining parts of the text widget come from the standard
29740 libraries. The compile-time option \\EXIMON@_TEXTPOP\\ can be unset to cut out
29741 the modified \TextPop\, making it possible to build Eximon on these systems, at
29742 the expense of having unwanted items in the search popup window.
29743
29744
29745 .section The queue display
29746 .index queue||display in monitor
29747 The bottom section of the monitor window contains a list of all messages that
29748 are on the queue, which includes those currently being received or delivered,
29749 as well as those awaiting delivery. The size of this subwindow is controlled by
29750 parameters in the configuration file \(Local/eximon.conf)\, and the frequency
29751 at which it is updated is controlled by another parameter in the same file --
29752 the default is 5 minutes, since queue scans can be quite expensive. However,
29753 there is an `Update' action button just above the display which can be used to
29754 force an update of the queue display at any time.
29755
29756 When a host is down for some time, a lot of pending mail can build up for it,
29757 and this can make it hard to deal with other messages on the queue. To help
29758 with this situation there is a button next to `Update' called `Hide'. If
29759 pressed, a dialogue box called `Hide addresses ending with' is put up. If you
29760 type anything in here and press `Return', the text is added to a chain of such
29761 texts, and if every undelivered address in a message matches at least one
29762 of the texts, the message is not displayed.
29763
29764 If there is an address that does not match any of the texts, all the addresses
29765 are displayed as normal. The matching happens on the ends of addresses so, for
29766 example, \*cam.ac.uk*\ specifies all addresses in Cambridge, while
29767 \*xxx@@foo.com.example*\ specifies just one specific address. When any hiding
29768 has been set up, a button called `Unhide' is displayed. If pressed, it cancels
29769 all hiding. Also, to ensure that hidden messages do not get forgotten, a hide
29770 request is automatically cancelled after one hour.
29771
29772 While the dialogue box is displayed, you can't press any buttons or do anything
29773 else to the monitor window. For this reason, if you want to cut text from the
29774 queue display to use in the dialogue box, you have to do the cutting before
29775 pressing the `Hide' button.
29776
29777 The queue display contains, for each unhidden queued message, the length of
29778 time it has been on the queue, the size of the message, the message id, the
29779 message sender, and the first undelivered recipient, all on one line. If it is
29780 a bounce message, the sender is shown as `<>'. If there is more than one
29781 recipient to which the message has not yet been delivered, subsequent ones are
29782 listed on additional lines, up to a maximum configured number, following which
29783 an ellipsis is displayed. Recipients that have already received the message are
29784 not shown.
29785 .index frozen messages||display
29786 If a message is frozen, an asterisk is displayed at the left-hand side.
29787
29788 The queue display has a vertical scroll bar, and can also be scrolled by means
29789 of the arrow keys. Text can be cut from it using the mouse in the normal way.
29790 The text searching facilities, as described above for the log window, are also
29791 available, but the caret is always moved to the end of the text when the queue
29792 display is updated.
29793
29794
29795 .section The queue menu
29796 .index queue||menu in monitor
29797 If the \shift\ key is held down and the left button is clicked when the mouse
29798 pointer is over the text for any message, an action menu pops up, and the first
29799 line of the queue display for the message is highlighted. This does not affect
29800 any selected text.
29801
29802 If you want to use some other event for popping up the menu, you can set the
29803 \\MENU@_EVENT\\ parameter in \(Local/eximon.conf)\ to change the default, or
29804 set \\EXIMON@_MENU@_EVENT\\ in the environment before starting the monitor. The
29805 value set in this parameter is a standard X event description. For example, to
29806 run eximon using \ctrl\ rather than \shift\ you could use
29807 .display asis
29808 EXIMON_MENU_EVENT='Ctrl<Btn1Down>' eximon
29809 .endd
29810 The title of the menu is the message id, and it contains entries which act as
29811 follows:
29812 .numberpars $.
29813 \*message log*\: The contents of the message log for the message are displayed in
29814 a new text window.
29815 .nextp
29816 \*headers*\: Information from the spool file that contains the envelope
29817 information and headers is displayed in a new text window. See chapter
29818 ~~CHAPspool for a description of the format of spool files.
29819 .nextp
29820 \*body*\: The contents of the spool file containing the body of the message are
29821 displayed in a new text window. There is a default limit of 20,000 bytes to the
29822 amount of data displayed. This can be changed by setting the \\BODY@_MAX\\
29823 option at compile time, or the \\EXIMON@_BODY@_MAX\\ option at run time.
29824 .nextp
29825 \*deliver message*\: A call to Exim is made using the \-M-\ option to request
29826 delivery of the message. This causes an automatic thaw if the message is
29827 frozen. The \-v-\ option is also set, and the output from Exim is displayed in
29828 a new text window. The delivery is run in a separate process, to avoid holding
29829 up the monitor while the delivery proceeds.
29830 .nextp
29831 \*freeze message*\: A call to Exim is made using the \-Mf-\ option to request
29832 that the message be frozen.
29833 .nextp
29834 .index thawing messages
29835 .index unfreezing messages
29836 .index frozen messages||thawing
29837 \*thaw message*\: A call to Exim is made using the \-Mt-\ option to request that
29838 the message be thawed.
29839 .nextp
29840 .index delivery||forcing failure
29841 \*give up on msg*\: A call to Exim is made using the \-Mg-\ option to request
29842 that Exim gives up trying to deliver the message. A bounce message is generated
29843 for any remaining undelivered addresses.
29844 .nextp
29845 \*remove message*\: A call to Exim is made using the \-Mrm-\ option to request
29846 that the message be deleted from the system without generating a bounce
29847 message.
29848 .nextp
29849 \*add recipient*\: A dialog box is displayed into which a recipient address can
29850 be typed. If the address is not qualified and the \\QUALIFY@_DOMAIN\\ parameter
29851 is set in \(Local/eximon.conf)\, the address is qualified with that domain.
29852 Otherwise it must be entered as a fully qualified address. Pressing \\RETURN\\
29853 causes a call to Exim to be made using the \-Mar-\ option to request that an
29854 additional recipient be added to the message, unless the entry box is empty, in
29855 which case no action is taken.
29856 .nextp
29857 \*mark delivered*\: A dialog box is displayed into which a recipient address can
29858 be typed. If the address is not qualified and the \\QUALIFY@_DOMAIN\\ parameter
29859 is set in \(Local/eximon.conf)\, the address is qualified with that domain.
29860 Otherwise it must be entered as a fully qualified address. Pressing \\RETURN\\
29861 causes a call to Exim to be made using the \-Mmd-\ option to mark the given
29862 recipient address as already delivered, unless the entry box is empty, in which
29863 case no action is taken.
29864 .nextp
29865 \*mark all delivered*\: A call to Exim is made using the \-Mmad-\ option to mark
29866 all recipient addresses as already delivered.
29867 .nextp
29868 \*edit sender*\: A dialog box is displayed initialized with the current sender's
29869 address. Pressing \\RETURN\\ causes a call to Exim to be made using the \-Mes-\
29870 option to replace the sender address, unless the entry box is empty, in which
29871 case no action is taken. If you want to set an empty sender (as in bounce
29872 messages), you must specify it as `<>'. Otherwise, if the address is not
29873 qualified and the \\QUALIFY@_DOMAIN\\ parameter is set in
29874 \(Local/eximon.conf)\, the address is qualified with that domain.
29875 .endp
29876 When a delivery is forced, a window showing the \-v-\ output is displayed. In
29877 other cases when a call to Exim is made, if there is any output from Exim (in
29878 particular, if the command fails) a window containing the command and the
29879 output is displayed. Otherwise, the results of the action are normally apparent
29880 from the log and queue displays. However, if you set \\ACTION@_OUTPUT\\=yes in
29881 \(Local/eximon.conf)\, a window showing the Exim command is always opened, even
29882 if no output is generated.
29883
29884 The queue display is automatically updated for actions such as freezing and
29885 thawing, unless \\ACTION@_QUEUE@_UPDATE\\=no has been set in
29886 \(Local/eximon.conf)\. In this case the `Update' button has to be used to force
29887 an update of the display after one of these actions.
29888
29889 In any text window that is displayed as result of a menu action, the normal
29890 cut-and-paste facility is available, and searching can be carried out using ^R
29891 and ^S, as described above for the log tail window.
29892
29893
29894
29895
29896
29897
29898 .
29899 .
29900 .
29901 .
29902 . ============================================================================
29903 .chapter Security considerations
29904 .set runningfoot "security"
29905 .rset CHAPsecurity ~~chapter
29906 .index security
29907 This chapter discusses a number of issues concerned with security, some of
29908 which are also covered in other parts of this manual.
29909
29910 For reasons that this author does not understand, some people have promoted
29911 Exim as a `particularly secure' mailer. Perhaps it is because of the existence
29912 of this chapter in the documentation. However, the intent of the chapter is
29913 simply to describe the way Exim works in relation to certain security concerns,
29914 not to make any specific claims about the effectiveness of its security as
29915 compared with other MTAs.
29916
29917 What follows is a description of the way Exim is supposed to be. Best efforts
29918 have been made to try to ensure that the code agrees with the theory, but an
29919 absence of bugs can never be guaranteed. Any that are reported will get fixed
29920 as soon as possible.
29921
29922 .section Building a more `hardened' Exim
29923 .index security||build-time features
29924 There are a number of build-time options that can be set in \(Local/Makefile)\
29925 to create Exim binaries that are `harder' to attack, in particular by a rogue
29926 Exim administrator who does not have the root password, or by someone who has
29927 penetrated the Exim (but not the root) account. These options are as follows:
29928 .numberpars $.
29929 \\ALT@_CONFIG@_PREFIX\\ can be set to a string that is required to match the
29930 start of any file names used with the \-C-\ option. When it is set, these file
29931 names are also not allowed to contain the sequence `/../'. (However, if the
29932 value of the \-C-\ option is identical to the value of \\CONFIGURE@_FILE\\ in
29933 \(Local/Makefile)\, Exim ignores \-C-\ and proceeds as usual.) There is no
29934 default setting for \ALT@_CONFIG@_PREFIX\.
29935
29936 If the permitted configuration files are confined to a directory to
29937 which only root has access, this guards against someone who has broken
29938 into the Exim account from running a privileged Exim with an arbitrary
29939 configuration file, and using it to break into other accounts.
29940 .nextp
29941 If \\ALT@_CONFIG@_ROOT@_ONLY\\ is defined, root privilege is retained for \-C-\
29942 and \-D-\ only if the caller of Exim is root. Without it, the Exim user may
29943 also use \-C-\ and \-D-\ and retain privilege. Setting this option locks out
29944 the possibility of testing a configuration using \-C-\ right through message
29945 reception and delivery, even if the caller is root. The reception works, but by
29946 that time, Exim is running as the Exim user, so when it re-execs to regain
29947 privilege for the delivery, the use of \-C-\ causes privilege to be lost.
29948 However, root can test reception and delivery using two separate commands.
29949 \\ALT@_CONFIG@_ROOT@_ONLY\\ is not set by default.
29950 .nextp
29951 If \\DISABLE@_D@_OPTION\\ is defined, the use of the \-D-\ command line option
29952 is disabled.
29953 .nextp
29954 \\FIXED@_NEVER@_USERS\\ can be set to a colon-separated list of users that are
29955 never to be used for any deliveries. This is like the \never@_users\ runtime
29956 option, but it cannot be overridden; the runtime option adds additional users
29957 to the list. The default setting is `root'; this prevents a non-root user who
29958 is permitted to modify the runtime file from using Exim as a way to get root.
29959 .endp
29960
29961
29962 .section Root privilege
29963 .index setuid
29964 .index root privilege
29965 The Exim binary is normally setuid to root, which means that it gains root
29966 privilege (runs as root) when it starts execution. In some special cases (for
29967 example, when the daemon is not in use and there are no local deliveries), it
29968 may be possible to run Exim setuid to some user other than root. This is
29969 discussed in the next section. However, in most installations, root privilege
29970 is required for two things:
29971 .numberpars $.
29972 To set up a socket connected to the standard SMTP port (25) when initialising
29973 the listening daemon. If Exim is run from \*inetd*\, this privileged action is
29974 not required.
29975 .nextp
29976 To be able to change uid and gid in order to read users' \(.forward)\ files and
29977 perform local deliveries as the receiving user or as specified in the
29978 configuration.
29979 .endp
29980 It is not necessary to be root to do any of the other things Exim does, such as
29981 receiving messages and delivering them externally over SMTP, and it is
29982 obviously more secure if Exim does not run as root except when necessary.
29983 For this reason, a user and group for Exim to use must be defined in
29984 \(Local/Makefile)\. These are known as `the Exim user' and `the Exim group'.
29985 Their values can be changed by the run time configuration, though this is not
29986 recommended. Often a user called \*exim*\ is used, but some sites use \*mail*\
29987 or another user name altogether.
29988
29989 Exim uses \*setuid()*\ whenever it gives up root privilege. This is a permanent
29990 abdication; the process cannot regain root afterwards. Prior to release 4.00,
29991 \*seteuid()*\ was used in some circumstances, but this is no longer the case.
29992
29993 After a new Exim process has interpreted its command line options, it changes
29994 uid and gid in the following cases:
29995 .numberpars $.
29996 .index \-C-\ option
29997 .index \-D-\ option
29998 If the \-C-\ option is used to specify an alternate configuration file, or if
29999 the \-D-\ option is used to define macro values for the configuration, and the
30000 calling process is not running as root or the Exim user, the uid and gid are
30001 changed to those of the calling process.
30002 However, if \\ALT@_CONFIG@_ROOT@_ONLY\\ is defined in \(Local/Makefile)\, only
30003 root callers may use \-C-\ and \-D-\ without losing privilege, and if
30004 \\DISABLE@_D@_OPTION\\ is set, the \-D-\ option may not be used at all.
30005 .nextp
30006 .index \-be-\ option
30007 .index \-bf-\ option
30008 .index \-bF-\ option
30009 If the expansion test option (\-be-\) or one of the filter testing options
30010 (\-bf-\ or \-bF-\) are used, the uid and gid are changed to those of the
30011 calling process.
30012 .nextp
30013 If the process is not a daemon process or a queue runner process or a delivery
30014 process or a process for testing address routing (started with \-bt-\), the uid
30015 and gid are changed to the Exim user and group. This means that Exim always
30016 runs under its own uid and gid when receiving messages. This also applies when
30017 testing address verification
30018 .index \-bv-\ option
30019 .index \-bh-\ option
30020 (the \-bv-\ option) and testing incoming message policy controls (the \-bh-\
30021 option).
30022 .nextp
30023 For a daemon, queue runner, delivery, or address testing process, the uid
30024 remains as root at this stage, but the gid is changed to the Exim group.
30025 .endp
30026 The processes that initially retain root privilege behave as follows:
30027 .numberpars $.
30028 A daemon process changes the gid to the Exim group and the uid to the Exim user
30029 after setting up one or more listening sockets. The \*initgroups()*\ function
30030 is called, so that if the Exim user is in any additional groups, they will be
30031 used during message reception.
30032 .nextp
30033 A queue runner process retains root privilege throughout its execution. Its job
30034 is to fork a controlled sequence of delivery processes.
30035 .nextp
30036 A delivery process retains root privilege throughout most of its execution,
30037 but any actual deliveries (that is, the transports themselves) are run in
30038 subprocesses which always change to a non-root uid and gid. For local
30039 deliveries this is typically the uid and gid of the owner of the mailbox; for
30040 remote deliveries, the Exim uid and gid are used. Once all the delivery
30041 subprocesses have been run, a delivery process changes to the Exim uid and gid
30042 while doing post-delivery tidying up such as updating the retry database and
30043 generating bounce and warning messages.
30044
30045 While the recipient addresses in a message are being routed, the delivery
30046 process runs as root. However, if a user's filter file has to be processed,
30047 this is done in a subprocess that runs under the individual user's uid and
30048 gid. A system filter is run as root unless \system@_filter@_user\ is set.
30049 .nextp
30050 A process that is testing addresses (the \-bt-\ option) runs as root so that
30051 the routing is done in the same environment as a message delivery.
30052 .endp
30053
30054
30055 .section Running Exim without privilege
30056 .rset SECTrunexiwitpri "~~chapter.~~section"
30057 .index privilege, running without
30058 .index unprivileged running
30059 .index root privilege||running without
30060 Some installations like to run Exim in an unprivileged state for more of its
30061 operation, for added security. Support for this mode of operation is provided
30062 by the global option \deliver@_drop@_privilege\. When this is set, the uid and
30063 gid are changed to the Exim user and group at the start of a delivery process
30064 (and also queue runner and address testing processes). This means that address
30065 routing is no longer run as root, and the deliveries themselves cannot change
30066 to any other uid.
30067
30068 Leaving the binary setuid to root, but setting \deliver@_drop@_privilege\ means
30069 that the daemon can still be started in the usual way, and it can respond
30070 correctly to SIGHUP because the re-invocation regains root privilege.
30071
30072 An alternative approach is to make Exim setuid to the Exim user and also setgid
30073 to the Exim group.
30074 If you do this, the daemon must be started from a root process. (Calling
30075 Exim from a root process makes it behave in the way it does when it is setuid
30076 root.) However, the daemon cannot restart itself after a SIGHUP signal because
30077 it cannot regain privilege.
30078
30079 It is still useful to set \deliver@_drop@_privilege\ in this case, because it
30080 stops Exim from trying to re-invoke itself to do a delivery after a message has
30081 been received. Such a re-invocation is a waste of resources because it has no
30082 effect.
30083
30084 If restarting the daemon is not an issue (for example, if 
30085 .em
30086 \mua@_wrapper\ is set, or 
30087 .nem
30088 \*inetd*\ is being used instead of a daemon), having the binary setuid to the
30089 Exim user seems a clean approach, but there is one complication:
30090
30091 In this style of operation, Exim is running with the real uid and gid set to
30092 those of the calling process, and the effective uid/gid set to Exim's values.
30093 Ideally, any association with the calling process' uid/gid should be dropped,
30094 that is, the real uid/gid should be reset to the effective values so as to
30095 discard any privileges that the caller may have. While some operating systems
30096 have a function that permits this action for a non-root effective uid, quite a
30097 number of them do not. Because of this lack of standardization, Exim does not
30098 address this problem at this time.
30099
30100 For this reason, the recommended approach for `mostly unprivileged' running is
30101 to keep the Exim binary setuid to root, and to set \deliver@_drop@_privilege\.
30102 This also has the advantage of allowing a daemon to be used in the most
30103 straightforward way.
30104
30105 If you configure Exim not to run delivery processes as root, there are a
30106 number of restrictions on what you can do:
30107 .numberpars $.
30108 You can deliver only as the Exim user/group. You should  explicitly use the
30109 \user\ and \group\ options to override routers or local transports that
30110 normally deliver as the recipient. This makes sure that configurations that
30111 work in this mode function the same way in normal mode. Any implicit or
30112 explicit specification of another user causes an error.
30113 .nextp
30114 Use of \(.forward)\ files is severely restricted, such that it is usually
30115 not worthwhile to include them in the configuration.
30116 .nextp
30117 Users who wish to use \(.forward)\ would have to make their home directory and
30118 the file itself accessible to the Exim user. Pipe and append-to-file entries,
30119 and their equivalents in Exim filters, cannot be used. While they could be
30120 enabled in the Exim user's name, that would be insecure and not very useful.
30121 .nextp
30122 Unless the local user mailboxes are all owned by the Exim user (possible in
30123 some POP3 or IMAP-only environments):
30124 .numberpars $*$
30125 They must be owned by the Exim group and be writable by that group. This
30126 implies you must set \mode\ in the appendfile configuration, as well as the
30127 mode of the mailbox files themselves.
30128 .nextp
30129 You must set \no@_check@_owner\, since most or all of the files will not be
30130 owned by the Exim user.
30131 .nextp
30132 You must set \file@_must@_exist\, because Exim cannot set the owner correctly
30133 on a newly created mailbox when unprivileged. This also implies that new
30134 mailboxes need to be created manually.
30135 .endp
30136 .endp
30137 These restrictions severely restrict what can be done in local deliveries.
30138 However, there are no restrictions on remote deliveries. If you are running a
30139 gateway host that does no local deliveries, setting \deliver@_drop@_privilege\
30140 gives more security at essentially no cost.
30141 .em
30142 If you are using the \mua@_wrapper\ facility (see chapter ~~CHAPnonqueueing), 
30143 \deliver@_drop@_privilege\ is forced to be true.
30144 .nem
30145
30146
30147 .section Delivering to local files
30148 Full details of the checks applied by \%appendfile%\ before it writes to a file
30149 are given in chapter ~~CHAPappendfile.
30150
30151
30152 .section IPv4 source routing
30153 .index source routing||in IP packets
30154 .index IP source routing
30155 Many operating systems suppress IP source-routed packets in the kernel, but
30156 some cannot be made to do this, so Exim does its own check. It logs incoming
30157 IPv4 source-routed TCP calls, and then drops them. Things are all different in
30158 IPv6. No special checking is currently done.
30159
30160
30161 .section The VRFY, EXPN, and ETRN commands in SMTP
30162 Support for these SMTP commands is disabled by default. If required, they can
30163 be enabled by defining suitable ACLs.
30164
30165
30166
30167 .section Privileged users
30168 .index trusted user
30169 .index admin user
30170 .index privileged user
30171 .index user||trusted
30172 .index user||admin
30173 Exim recognises two sets of users with special privileges. Trusted users are
30174 able to submit new messages to Exim locally, but supply their own sender
30175 addresses and information about a sending host. For other users submitting
30176 local messages, Exim sets up the sender address from the uid, and doesn't
30177 permit a remote host to be specified.
30178
30179 .index \-f-\ option
30180 However, an untrusted user is permitted to use the \-f-\ command line option in
30181 the special form \-f @<@>-\ to indicate that a delivery failure for the message
30182 should not cause an error report. This affects the message's envelope, but it
30183 does not affect the ::Sender:: header. Untrusted users may also be permitted to
30184 use specific forms of address with the \-f-\ option by setting the
30185 \untrusted@_set@_sender\ option.
30186
30187 Trusted users are used to run processes that receive mail messages from some
30188 other mail domain and pass them on to Exim for delivery either locally, or over
30189 the Internet. Exim trusts a caller that is running as root, as the Exim user,
30190 as any user listed in the \trusted@_users\ configuration option, or under any
30191 group listed in the \trusted@_groups\ option.
30192
30193 Admin users are permitted to do things to the messages on Exim's queue. They
30194 can freeze or thaw messages, cause them to be returned to their senders, remove
30195 them entirely, or modify them in various ways. In addition, admin users can run
30196 the Exim monitor and see all the information it is capable of providing, which
30197 includes the contents of files on the spool.
30198
30199 .index \-M-\ option
30200 .index \-q-\ option
30201 By default, the use of the \-M-\ and \-q-\ options to cause Exim to attempt
30202 delivery of messages on its queue is restricted to admin users. This
30203 restriction can be relaxed by setting the \no@_prod@_requires@_admin\ option.
30204 Similarly, the use of \-bp-\ (and its variants) to list the contents of the
30205 queue is also restricted to admin users. This restriction can be relaxed by
30206 setting \no@_queue@_list@_requires@_admin\.
30207
30208 Exim recognises an admin user if the calling process is running as root or as
30209 the Exim user or if any of the groups associated with the calling process is
30210 the Exim group. It is not necessary actually to be running under the Exim
30211 group. However, if admin users who are not root or the Exim user are to access
30212 the contents of files on the spool via the Exim monitor (which runs
30213 unprivileged), Exim must be built to allow group read access to its spool
30214 files.
30215
30216
30217 .section Spool files
30218 .index spool directory||files
30219 Exim's spool directory and everything it contains is owned by the Exim user and
30220 set to the Exim group. The mode for spool files is defined in the
30221 \(Local/Makefile)\ configuration file, and defaults to 0640. This means that
30222 any user who is a member of the Exim group can access these files.
30223
30224
30225 .section Use of argv[0]
30226 Exim examines the last component of \argv[0]\, and if it matches one of a set
30227 of specific strings, Exim assumes certain options. For example, calling Exim
30228 with the last component of \argv[0]\ set to `rsmtp' is exactly equivalent to
30229 calling it with the option \-bS-\. There are no security implications in this.
30230
30231
30232 .section Use of %f formatting
30233 The only use made of `%f' by Exim is in formatting load average values. These
30234 are actually stored in integer variables as 1000 times the load average.
30235 Consequently, their range is limited and so therefore is the length of the
30236 converted output.
30237
30238
30239 .section Embedded Exim path
30240 Exim uses its own path name, which is embedded in the code, only when it needs
30241 to re-exec in order to regain root privilege. Therefore, it is not root when it
30242 does so. If some bug allowed the path to get overwritten, it would lead to an
30243 arbitrary program's being run as exim, not as root.
30244
30245
30246 .section Use of sprintf()
30247 .index \*sprintf()*\
30248 A large number of occurrences of `sprintf' in the code are actually calls to
30249 \*string@_sprintf()*\, a function that returns the result in malloc'd store.
30250 The intermediate formatting is done into a large fixed buffer by a function
30251 that runs through the format string itself, and checks the length of each
30252 conversion before performing it, thus preventing buffer overruns.
30253
30254 The remaining uses of \*sprintf()*\ happen in controlled circumstances where
30255 the output buffer is known to be sufficiently long to contain the converted
30256 string.
30257
30258
30259 .section Use of debug@_printf() and log@_write()
30260 Arbitrary strings are passed to both these functions, but they do their
30261 formatting by calling the function \*string@_vformat()*\, which runs through
30262 the format string itself, and checks the length of each conversion.
30263
30264
30265 .section Use of strcat() and strcpy()
30266 These are used only in cases where the output buffer is known to be large
30267 enough to hold the result.
30268
30269
30270
30271
30272 .
30273 .
30274 .
30275 .
30276 . ============================================================================
30277 .chapter Format of spool files
30278 .set runningfoot "spool file format"
30279 .rset CHAPspool ~~chapter
30280 .index format||spool files
30281 .index spool directory||format of files
30282 .index spool||files, format of
30283 .index spool||files, editing
30284 A message on Exim's queue consists of two files, whose names are the message id
30285 followed by -D and -H, respectively. The data portion of the message is kept in
30286 the -D file on its own. The message's envelope, status, and headers are all
30287 kept in the -H file, whose format is described in this chapter. Each of these
30288 two files contains the final component of its own name as its first line. This
30289 is insurance against disk crashes where the directory is lost but the files
30290 themselves are recoverable.
30291
30292 Some people are tempted into editing -D files in order to modify messages. You
30293 need to be extremely careful if you do this; it is not recommended and you are
30294 on your own if you do it. Here are some of the pitfalls:
30295 .numberpars $.
30296 You must use the \*exim@_lock*\ utility to ensure that Exim does not try to
30297 deliver the message while you are fiddling with it. The lock is implemented
30298 by opening the -D file and taking out a write lock on it. If you update the
30299 file in place, the lock will be retained. If you write a new file and rename
30300 it, the lock will be lost at the instant of rename.
30301 .nextp
30302 If you change the number of lines in the file, the value of
30303 \$body@_linecount$\, which is stored in the -H file, will be incorrect.
30304 .nextp
30305 If the message is in MIME format, you must take care not to break it.
30306 .nextp
30307 If the message is cryptographically signed, any change will invalidate the
30308 signature.
30309 .endp
30310
30311 Files whose names end with -J may also be seen in the \(input)\ directory (or
30312 its subdirectories when \split@_spool@_directory\ is set). These are journal
30313 files, used to record addresses to which the message has been delivered during
30314 the course of a delivery run. At the end of the run, the -H file is updated,
30315 and the -J file is deleted.
30316
30317 .section Format of the -H file
30318 .index uid (user id)||in spool file
30319 .index gid (group id)||in spool file
30320 The second line of the -H file contains the login name for the uid of the
30321 process that called Exim to read the message, followed by the numerical uid and
30322 gid. For a locally generated message, this is normally the user who sent the
30323 message. For a message received over TCP/IP, it is normally the Exim user.
30324
30325 The third line of the file contains the address of the message's sender as
30326 transmitted in the envelope, contained in angle brackets. The sender address is
30327 empty for bounce messages. For incoming SMTP mail, the sender address is given
30328 in the \\MAIL\\ command. For locally generated mail, the sender address is
30329 created by Exim from the login name of the current user and the configured
30330 \qualify@_domain\. However, this can be overridden by the \-f-\ option or a
30331 leading `From' line if the caller is trusted, or if the supplied address is
30332 `@<@>' or an address that matches \untrusted@_set@_senders\.
30333
30334 The fourth line contains two numbers. The first is the time that the message
30335 was received, in the conventional Unix form -- the number of seconds since the
30336 start of the epoch. The second number is a count of the number of messages
30337 warning of delayed delivery that have been sent to the sender.
30338
30339 There follow a number of lines starting with a hyphen. These can appear in any
30340 order, and are omitted when not relevant:
30341 .numberpars $.
30342 \-acl <<number>> <<length>>-\: A line of this form is present for every ACL
30343 variable that is not empty. The number identifies the variable; the
30344 \acl@_c\*x*\$$\ variables are numbered 0--9 and the \acl@_m\*x*\$$\ variables
30345 are numbered 10--19. The length is the length of the data string for the
30346 variable. The string itself starts at the beginning of the next line, and is
30347 followed by a newline character. It may contain internal newlines.
30348 .nextp
30349 .em
30350 \-active@_hostname <<hostname>>-\: This is present if, when the message was 
30351 received over SMTP, the value of \$smtp@_active@_hostname$\ was different to 
30352 the value of \$primary@_hostname$\.
30353 .nem
30354 .nextp
30355 \-allow@_unqualified@_recipient-\: This is present if unqualified recipient
30356 addresses are permitted in header lines (to stop such addresses from being
30357 qualified if rewriting occurs at transport time). Local messages that were
30358 input using \-bnq-\ and remote messages from hosts that match
30359 \recipient@_unqualified@_hosts\ set this flag.
30360 .nextp
30361 \-allow@_unqualified@_sender-\: This is present if unqualified sender
30362 addresses are permitted in header lines (to stop such addresses from being
30363 qualified if rewriting occurs at transport time). Local messages that were
30364 input using \-bnq-\ and remote messages from hosts that match
30365 \sender@_unqualified@_hosts\ set this flag.
30366 .nextp
30367 \-auth@_id <<text>>-\: The id information for a message received on an
30368 authenticated SMTP connection -- the value of the \$authenticated@_id$\
30369 variable.
30370 .nextp
30371 \-auth@_sender <<address>>-\: The address of an authenticated sender -- the
30372 value of the \$authenticated@_sender$\ variable.
30373 .nextp
30374 \-body@_linecount <<number>>-\: This records the number of lines in the body of
30375 the message, and is always present.
30376 .nextp
30377 .em
30378 \-body@_zerocount <<number>>-\: This records the number of binary zero bytes in 
30379 the body of the message, and is present if the number is greater than zero.
30380 .nem
30381 .nextp
30382 \-deliver@_firsttime-\: This is written when a new message is first added to
30383 the spool. When the spool file is updated after a deferral, it is omitted.
30384 .nextp
30385 .index frozen messages||spool data
30386 \-frozen <<time>>-\: The message is frozen, and the freezing happened at
30387 <<time>>.
30388 .nextp
30389 \-helo@_name <<text>>-\: This records the host name as specified by a remote
30390 host in a \\HELO\\ or \\EHLO\\ command.
30391 .nextp
30392 \-host@_address <<address>>.<<port>>-\: This records the IP address of the host
30393 from which the message was received and the remote port number that was used.
30394 It is omitted for locally generated messages.
30395 .nextp
30396 \-host@_auth <<text>>-\: If the message was received on an authenticated SMTP
30397 connection, this records the name of the authenticator -- the value of the
30398 \$sender@_host@_authenticated$\ variable.
30399 .nextp
30400 \-host@_lookup@_failed-\: This is present if an attempt to look up the sending
30401 host's name from its IP address failed. It corresponds to the
30402 \$host@_lookup@_failed$\ variable.
30403 .nextp
30404 .index DNS||reverse lookup
30405 .index reverse DNS lookup
30406 \-host@_name <<text>>-\: This records the name of the remote host from which
30407 the message was received, if the host name was looked up from the IP address
30408 when the message was being received. It is not present if no reverse lookup was
30409 done.
30410 .nextp
30411 \-ident <<text>>-\: For locally submitted messages, this records the login of
30412 the originating user, unless it was a trusted user and the \-oMt-\ option was
30413 used to specify an ident value. For messages received over TCP/IP, this records
30414 the ident string supplied by the remote host, if any.
30415 .nextp
30416 \-interface@_address <<address>>.<<port>>-\: This records the IP address of the
30417 local interface and the port number through which a message was received from a
30418 remote host. It is omitted for locally generated messages.
30419 .nextp
30420 \-local-\: The message is from a local sender.
30421 .nextp
30422 \-localerror-\: The message is a locally-generated bounce message.
30423 .nextp
30424 \-local@_scan <<string>>-\: This records the data string that was
30425 returned by the \*local@_scan()*\ function when the message was received -- the
30426 value of the \$local@_scan@_data$\ variable. It is omitted if no data was
30427 returned.
30428 .nextp
30429 \-manual@_thaw-\: The message was frozen but has been thawed manually, that is,
30430 by an explicit Exim command rather than via the auto-thaw process.
30431 .nextp
30432 \-N-\: A testing delivery process was started using the \-N-\ option to
30433 suppress any actual deliveries, but delivery was deferred. At any further
30434 delivery attempts, \-N-\ is assumed.
30435 .nextp
30436 \-received@_protocol-\: This records the value of the \$received@_protocol$\
30437 variable, which contains the name of the protocol by which the message was
30438 received.
30439 .nextp
30440 \-sender@_set@_untrusted-\: The envelope sender of this message was set by an
30441 untrusted local caller (used to ensure that the caller is displayed in queue
30442 listings).
30443 .nextp
30444 .em
30445 \-spam@_score@_int-\: If a message was scanned by SpamAssassin, this is 
30446 present. It records the value of \$spam@_score@_int$\.
30447 .nem
30448 .nextp
30449 \-tls@_certificate@_verified-\: A TLS certificate was received from the client
30450 that sent this message, and the certificate was verified by the server.
30451 .nextp
30452 \-tls@_cipher <<cipher name>>-\: When the message was received over an
30453 encrypted connection, this records the name of the cipher suite that was used.
30454 .nextp
30455 \-tls@_peerdn <<peer DN>>-\: When the message was received over an encrypted
30456 connection, and a certificate was received from the client, this records the
30457 Distinguished Name from that certificate.
30458 .endp
30459
30460 Following the options there is a list of those addresses to which the message
30461 is not to be delivered. This set of addresses is initialized from the command
30462 line when the \-t-\ option is used and \extract__addresses__remove__arguments\
30463 is set; otherwise it starts out empty. Whenever a successful delivery is made,
30464 the address is added to this set. The addresses are kept internally as a
30465 balanced binary tree, and it is a representation of that tree which is written
30466 to the spool file. If an address is expanded via an alias or forward file, the
30467 original address is added to the tree when deliveries to all its child
30468 addresses are complete.
30469
30470 If the tree is empty, there is a single line in the spool file containing just
30471 the text `XX'. Otherwise, each line consists of two letters, which are either Y
30472 or N, followed by an address. The address is the value for the node of the
30473 tree, and the letters indicate whether the node has a left branch and/or a
30474 right branch attached to it, respectively. If branches exist, they immediately
30475 follow. Here is an example of a three-node tree:
30476 .display asis
30477 YY darcy@austen.fict.example
30478 NN alice@wonderland.fict.example
30479 NN editor@thesaurus.ref.example
30480 .endd
30481 After the non-recipients tree, there is a list of the message's recipients.
30482 This is a simple list, preceded by a count. It includes all the original
30483 recipients of the message, including those to whom the message has already been
30484 delivered. In the simplest case, the list contains one address per line. For
30485 example:
30486 .display asis
30487 4
30488 editor@thesaurus.ref.example
30489 darcy@austen.fict.example
30490 rdo@foundation
30491 alice@wonderland.fict.example
30492 .endd
30493 However, when a child address has been added to the top-level addresses as a
30494 result of the use of the \one@_time\ option on a \%redirect%\ router, each line
30495 is of the following form:
30496 .display
30497 <<top-level address>> <<errors@_to address>> <<length>>,<<parent number>>@#<<flag bits>>
30498 .endd
30499 The 01 flag bit indicates the presence of the three other fields that follow
30500 the top-level address. Other bits may be used in future to support additional
30501 fields. The <<parent number>> is the offset in the recipients list of the
30502 original parent of the `one time' address. The first two fields are the
30503 envelope sender that is associated with this address and its length. If the
30504 length is zero, there is no special envelope sender (there are then two space
30505 characters in the line). A non-empty field can arise from a \%redirect%\ router
30506 that has an \errors@_to\ setting.
30507
30508
30509 A blank line separates the envelope and status information from the headers
30510 which follow. A header may occupy several lines of the file, and to save effort
30511 when reading it in, each header is preceded by a number and an identifying
30512 character. The number is the number of characters in the header, including any
30513 embedded newlines and the terminating newline. The character is one of the
30514 following:
30515 .display
30516 .tabs 9
30517 <<blank>>  $t $rm{header in which Exim has no special interest}
30518 #B      $t $rm{::Bcc:: header}
30519 #C      $t $rm{::Cc:: header}
30520 #F      $t $rm{::From:: header}
30521 #I      $t $rm{::Message-id:: header}
30522 #P      $t $rm{::Received:: header -- P for `postmark'}
30523 #R      $t $rm{::Reply-To:: header}
30524 #S      $t $rm{::Sender:: header}
30525 #T      $t $rm{::To:: header}
30526 #*      $t $rm{replaced or deleted header}
30527 .endd
30528 Deleted or replaced (rewritten) headers remain in the spool file for debugging
30529 purposes. They are not transmitted when the message is delivered. Here is a
30530 typical set of headers:
30531 .display asis
30532 111P Received: by hobbit.fict.example with local (Exim 4.00)
30533         id 14y9EI-00026G-00; Fri, 11 May 2001 10:28:59 +0100
30534 049  Message-Id: <E14y9EI-00026G-00@hobbit.fict.example>
30535 038* X-rewrote-sender: bb@hobbit.fict.example
30536 042* From: Bilbo Baggins <bb@hobbit.fict.example>
30537 049F From: Bilbo Baggins <B.Baggins@hobbit.fict.example>
30538 099* To: alice@wonderland.fict.example, rdo@foundation,
30539  darcy@austen.fict.example, editor@thesaurus.ref.example
30540 109T To: alice@wonderland.fict.example, rdo@foundation.fict.example,
30541  darcy@austen.fict.example, editor@thesaurus.ref.example
30542 038  Date: Fri, 11 May 2001 10:28:59 +0100
30543 .endd
30544 The asterisked headers indicate that the envelope sender, ::From:: header, and
30545 ::To:: header have been rewritten, the last one because routing expanded the
30546 unqualified domain \*foundation*\.
30547
30548 .
30549 .
30550 .
30551 .
30552 . ============================================================================
30553 .chapter Adding new drivers or lookup types
30554 .set runningfoot "adding drivers"
30555 .index adding drivers
30556 .index new drivers, adding
30557 .index drivers||adding new
30558 The following actions have to be taken in order to add a new router, transport,
30559 authenticator, or lookup type to Exim:
30560 .numberpars
30561 Choose a name for the driver or lookup type that does not conflict with any
30562 existing name; I will use `newdriver' in what follows.
30563 .nextp
30564 Add to \(src/EDITME)\ the line
30565 .display
30566 <<type>>@_NEWDRIVER=yes
30567 .endd
30568 where <<type>> is \\ROUTER\\, \\TRANSPORT\\, \\AUTH\\, or \\LOOKUP\\. If the
30569 code is not to be included in the binary by default, comment this line out. You
30570 should also add any relevant comments about the driver or lookup type.
30571 .nextp
30572 Add to \(src/config.h.defaults)\ the line
30573 .display
30574 @#define <<type>>@_NEWDRIVER
30575 .endd
30576 .nextp
30577 Edit \(src/drtables.c)\, adding conditional code to pull in the private header
30578 and create a table entry as is done for all the other drivers and lookup types.
30579 .nextp
30580 Edit \(Makefile)\ in the appropriate sub-directory (\(src/routers)\,
30581 \(src/transports)\, \(src/auths)\, or \(src/lookups)\); add a line for the new
30582 driver or lookup type and add it to the definition of OBJ.
30583 .nextp
30584 Create \(newdriver.h)\ and \(newdriver.c)\ in the appropriate sub-directory of
30585 \(src)\.
30586 .nextp
30587 Edit \(scripts/MakeLinks)\ and add commands to link the \(.h)\ and \(.c)\ files
30588 as for other drivers and lookups.
30589 .endp
30590 Then all you need to do is write the code! A good way to start is to make a
30591 proforma by copying an existing module of the same type, globally changing all
30592 occurrences of the name, and cutting out most of the code. Note that any
30593 options you create must be listed in alphabetical order, because the tables are
30594 searched using a binary chop procedure.
30595
30596 There is a \(README)\ file in each of the sub-directories of \(src)\ describing
30597 the interface that is expected.
30598
30599 .
30600 .
30601 .
30602 .
30603 . ============================================================================
30604 . Fudge for the index page number. We want it to be on a right-hand page.
30605 .
30606 .set indexpage ~~sys.pagenumber + 1
30607 .if even ~~indexpage
30608 .set indexpage ~~indexpage + 1
30609 .fi
30610 .if ~~sgcal
30611 .%index Index$e~~indexpage--
30612 .fi
30613 .
30614 .
30615 . End of Exim specification