Include note about exicyclog and keeping more than 99 back copies.
[exim.git] / doc / doc-src / spec.src
... / ...
CommitLineData
1. $Cambridge: exim/doc/doc-src/spec.src,v 1.1 2004/10/07 15:04:35 ph10 Exp $
2.
3.set version "4.40"
4.set previousversion "4.30"
5.set versionmonth "July"
6.set versionyear "2004"
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.newline
143.push
144.if ~~sys.fancy
145.indent 2em
146.tabset 9em
147.else
148.indent 4em
149.tabset 13em
150.fi
151.endm
152
153.macro endconf
154.newline
155.pop
156.endm
157
158.macro conf "option" "type" "default" "6"
159.newpar
160.if ~~sys.leftonpage < ~~4ld
161.newpage
162.fi
163.testunderscore "~~1"
164.if ~~underscore
165.index \~~1\
166.else
167.index \~~1\ option
168.fi
169.tempindent 0
170\**~~1**\ $c $rm{Type:} $it{~~2} $e $rm{Default:} $it{~~3}
171.blank
172.endm
173
174.set contents true
175.set figurenumber -1
176.set displayindent 2em
177
178.index @$1, @$2, etc. $it{see numerical variables}
179.index address||rewriting $it{see rewriting}
180.index CR character $it{see carriage return}
181.index CRL $it{see certificate revocation list}
182.index delivery||failure report $it{see bounce message}
183.index dialup $it{see intermittently connected hosts}
184.index failover $it{see fallback}
185.index fallover $it{see fallback}
186.index filter||Sieve $it{see Sieve filter}
187.index ident $it{see RFC 1413}
188.index LF character $it{see linefeed}
189.index maximum $it{see limit}
190.index NUL $it{see binary zero}
191.index process id $it{see pid}
192.index RBL $it{see DNS list}
193.index redirection $it{see address redirection}
194.index return path||$it{see also envelope sender}
195.index SSL $it{see TLS}
196.index string||expansion $it{see expansion}
197.index top bit $it{see 8-bit characters}
198.index variables $it{see expansion, variables}
199.index zero, binary $it{see binary zero}
200
201. This is used for the printed index. See setting above for
202. the HTML index value.
203
204.set ACL "access control lists (ACLs)"
205
206. ======================================================
207
208.push
209.disable filling
210.justify centre
211.nofoot
212.space 8ld
213$chead{University of Cambridge Computing Service}
214.space 2ld
215$chead{Specification of the Exim Mail Transfer Agent}
216.space 3ld
217by
218.space 1ld
219Philip Hazel
220.space ~~sys.leftonpage - 15*~~sys.linedepth
221.justify left
222University Computing Service
223New Museums Site
224Pembroke Street
225Cambridge CB2 3QH
226United Kingdom
227.blank
228.tabs 6
229$it{phone:} $t +44 1223 334600
230$it{fax:} $t +44 1223 334679
231$it{email:} $t ph10 $it{at} cus.cam.ac.uk
232.blank
233Edition for Exim ~~version, ~~versionmonth ~~versionyear
234.space 2ld
235.if ~~sgcal
236.fontgroup 1
237.fi
238$c$rm{Copyright (c) University of Cambridge ~~versionyear}
239
240
241.if ~~sgcal
242.fontgroup 0
243.font 0
244.fi
245
246.pop
247.newpage
248
249. Blank verso for title page
250.space 1ld
251.newpage
252
253
254. Set up for actual text pages
255.page 1
256. The first one to prevent a warning from sgfr
257. set runningfoot "~~chapter"
258.set runningfoot ""
259
260.if ~~sys.fancy
261.footdepth 2ld
262.foot
263.if "~~runningfoot" == ""
264.set rhs ""
265.else
266.set rhs "~~runningfoot (~~chapter)"
267.fi
268.set lhs "Exim ~~version"
269.linelength ~~newlinelength
270$it{~~lhs}$c[~~sys.pagenumber]$e$it{~~rhs}
271.endfoot
272.fi
273
274
275
276
277.
278.
279.
280.
281. ============================================================================
282.chapter Introduction
283.set runningfoot "introduction"
284
285.if ~~sys.fancy
286$c$bi{If I have seen further it is by standing on the shoulders of giants.}##(Isaac Newton)
287.elif !~~html
288$c"If I have seen further it is by standing on the shoulders of giants."
289.newline
290$e (Isaac Newton)
291.else
292\*If I have seen further it is by standing on the shoulders of giants.*\
293(Isaac Newton).
294.fi
295.blank 4
296
297Exim is a mail transfer agent (MTA) for hosts that are running Unix or
298Unix-like operating systems. It was designed on the assumption that it would be
299run on hosts that are permanently connected to the Internet. However, it can be
300used on intermittently connected hosts with suitable configuration adjustments.
301
302Configuration files currently exist for the following operating systems: AIX,
303BSD/OS (aka BSDI), Darwin (Mac OS X), DGUX, FreeBSD, GNU/Hurd, GNU/Linux,
304HI-OSF (Hitachi), HP-UX, IRIX, MIPS RISCOS, NetBSD, OpenBSD, QNX, SCO, SCO
305SVR4.2 (aka UNIX-SV), Solaris (aka SunOS5), SunOS4, Tru64-Unix (formerly
306Digital UNIX, formerly DEC-OSF1), Ultrix, and Unixware. Some of these operating
307systems are no longer current and cannot easily be tested, so the configuration
308files may no longer work in practice.
309
310There are also configuration files for compiling Exim in the Cygwin environment
311that can be installed on systems running Windows. However, this document does
312not contain any information about running Exim in the Cygwin environment.
313
314The terms and conditions for the use and distribution of Exim are contained in
315the file \(NOTICE)\. Exim is distributed under the terms of the GNU General
316Public Licence, a copy of which may be found in the file \(LICENCE)\.
317
318The use, supply or promotion of Exim for the purpose of sending bulk,
319unsolicited electronic mail is incompatible with the basic aims of the program,
320which revolve around the free provision of a service that enhances the quality
321of personal communications. The author of Exim regards indiscriminate
322mass-mailing as an antisocial, irresponsible abuse of the Internet.
323
324Exim owes a great deal to Smail 3 and its author, Ron Karr. Without the
325experience of running and working on the Smail 3 code, I could never have
326contemplated starting to write a new MTA. Many of the ideas and user interfaces
327were originally taken from Smail 3, though the actual code of Exim is entirely
328new, and has developed far beyond the initial concept.
329
330Many people, both in Cambridge and around the world, have contributed to the
331development and the testing of Exim, and to porting it to various operating
332systems. I am grateful to them all. The distribution now contains a file called
333\(ACKNOWLEDGMENTS)\, in which I have started recording the names of
334contributors.
335
336.section Exim documentation
337.index documentation
338.em
339This edition of the Exim specification applies to version ~~version of Exim.
340Substantive changes from the ~~previousversion edition are marked by bars in
341the right-hand margin in the PostScript, PDF, and plain text versions of the
342document, and by green text in the HTML version, as shown by this paragraph.
343Changes are not marked in the Texinfo version, because Texinfo doesn't support
344change bars. Minor corrections and rewordings are not marked.
345.nem
346
347This document is very much a reference manual; it is not a tutorial. The reader
348is expected to have some familiarity with the SMTP mail transfer protocol and
349with general Unix system administration. Although there are some discussions
350and examples in places, the information is mostly organized in a way that makes
351it easy to look up, rather than in a natural order for sequential reading.
352Furthermore, the manual aims to cover every aspect of Exim in detail, including
353a number of rarely-used, special-purpose features that are unlikely to be of
354very wide interest.
355
356.index books about Exim
357An `easier' discussion of Exim which provides more in-depth explanatory,
358introductory, and tutorial material can be found in a book entitled
359.if ~~html
360[(A HREF="http://www.uit.co.uk/exim-book/")]
361$it{The Exim SMTP Mail Server},
362[(/A)]
363published by UIT Cambridge.
364.else
365$it{The Exim SMTP Mail Server}, published by UIT Cambridge
366(\?http://www.uit.co.uk/exim-book/?\).
367.fi
368
369This book also contains a chapter that gives a general introduction to SMTP and
370Internet mail. Inevitably, however, the book is unlikely to be fully up-to-date
371with the latest release of Exim. (Note that the earlier book about Exim,
372published by O'Reilly, covers Exim 3, and many things have changed in Exim 4.)
373
374.index \(doc/NewStuff)\
375.index \(doc/ChangeLog)\
376.index change log
377As the program develops, there may be features in newer versions that have not
378yet made it into this document, which is updated only when the most significant
379digit of the fractional part of the version number changes. However,
380specifications of new features that are not yet in this manual are placed in
381the file \(doc/NewStuff)\ in the Exim distribution. All changes to the program
382(whether new features, bug fixes, or other kinds of change) are noted briefly
383in the file called \(doc/ChangeLog)\.
384
385.index \(doc/spec.txt)\
386This specification itself is available as an ASCII file in \(doc/spec.txt)\ so
387that it can easily be searched with a text editor. Other files in the \(doc)\
388directory are:
389.display rm
390.tabs 18
391\(OptionLists.txt)\ $t $rm{list of all options in alphabetical order}
392\(dbm.discuss.txt)\ $t $rm{discussion about DBM libraries}
393\(exim.8)\ $t $rm{a man page of Exim's command line options}
394\(filter.txt)\ $t $rm{specification of the filter language}
395\(pcrepattern.txt)\ $t $rm{specification of PCRE regular expressions}
396\(pcretest.txt)\ $t $rm{specification of the PCRE testing program}
397\(Exim3.upgrade)\ $t $rm{upgrade notes from release 2 to release 3}
398\(Exim4.upgrade)\ $t $rm{upgrade notes from release 3 to release 4}
399.endd
400The main specification and the specification of the filtering language are also
401available in other formats (HTML, PostScript, PDF, and Texinfo). Section
402~~SECTavail below tells you how to get hold of these.
403
404
405.section FTP and web sites, and mailing list
406.index web site
407.index FTP site
408The primary distribution site for Exim is an FTP site, whose contents are
409described in \*Where to find the Exim distribution*\ below. In addition,
410there is a web site at \?http://www.exim.org?\ by courtesy of Energis Squared,
411formerly Planet Online Ltd, who are situated in the UK. The site is mirrored in
412a number of other countries; links to the mirrors are listed on the home page.
413The web site contains the Exim distribution, and you can also find the
414documentation and the
415.index FAQ
416.if ~~html
417[(A HREF="FAQ.html")]
418.fi
419FAQ
420.if ~~html
421[(/A)]
422.fi
423online there, as well as other relevant material.
424
425.index mailing lists||for Exim users
426Energis Squared also provide resources for the following mailing lists:
427.display rm
428.tabs 28
429$it{exim-users@@exim.org} $t general discussion list
430$it{exim-announce@@exim.org} $t moderated, low volume announcements list
431.endd
432You can subscribe to these lists, change your existing subscriptions, and view
433or search the archives via the
434.if ~~html
435[(A HREF="http://www.exim.org/maillist.html")]
436.fi
437mailing lists
438.if ~~html
439[(/A)]
440.fi
441link on the Exim home page. The $it{exim-users} mailing list is also forwarded
442to \?http://www.egroups.com/list/exim-users?\, an archiving system with
443searching capabilities.
444
445.section Exim training
446.index training courses
447From time to time (approximately annually at the time of writing),
448lecture-based training courses are run by the author of Exim in Cambridge, UK.
449Details can be found on the web site
450.if ~~html
451[(A HREF="http://www-tus.csx.cam.ac.uk/courses/exim/")]
452.fi
453\?http://www-tus@.csx@.cam@.ac.uk/courses/exim/?\.
454.if ~~html
455[(/A)]
456.fi
457
458.section Bug reports
459.index bug reports
460.index reporting bugs
461Reports of obvious bugs should be emailed to \*bugs@@exim.org*\. However, if
462you are unsure whether some behaviour is a bug or not, the best thing to do is
463to post a message to the $it{exim-users} mailing list and have it discussed.
464
465
466.section Where to find the Exim distribution
467.rset SECTavail "~~chapter.~~section"
468.index FTP site
469.index distribution||ftp site
470The master ftp site for the Exim distribution is
471.display rm
472.if ! ~~sys.fancy
473.indent 0
474.fi
475\?ftp://ftp.csx.cam.ac.uk/pub/software/email/exim?\
476.endd
477Within that directory there are subdirectories called \(exim3)\ (for previous
478Exim 3 distributions), \(exim4)\ (for the latest Exim 4 distributions), and
479\(Testing)\ for occasional testing versions. Those mirror sites that I know
480about are listed in the file
481.display rm
482.if ! ~~sys.fancy
483.indent 0
484.fi
485\?ftp://ftp.csx.cam.ac.uk/pub/software/email/exim/Mirrors?\
486.endd
487In the \(exim4)\ subdirectory, the current release can always be found in
488files called
489.display rm
490\(exim-$it{n.nn}.tar.gz)\
491\(exim-$it{n.nn}.tar.bz2)\
492.endd
493where $it{n.nn} is the highest such version number in the directory. The two
494files contain identical data; the only difference is the type of compression.
495The \(.bz2)\ file is usually a lot smaller than the \(.gz)\ file.
496.index distribution||signing details
497.index distribution||public key
498.index public key for signed distribution
499The distributions are signed with Philip Hazel's GPG key.
500The corresponding public key is available from a number of keyservers, and
501there is also a copy in the file:
502.display rm
503.if ! ~~sys.fancy
504.indent 0
505.fi
506\?ftp://ftp.csx.cam.ac.uk/pub/software/email/exim/Public-Key?\
507.endd
508The signatures for the tar bundles are in:
509.display rm
510\(exim-$it{n.nn}.tar.gz.sig)\
511\(exim-$it{n.nn}.tar.bz2.sig)\
512.endd
513
514When there is only a small amount of change from one release to the next, a
515patch file may be provided, with a final component name of the form
516.display rm
517\(exim-patch-$it{n.nn}-$it{m.mm}.gz)\
518.endd
519For each released version, the log of changes is made separately available in
520the directory
521.display rm
522\?ftp://ftp.csx.cam.ac.uk/pub/software/email/exim/ChangeLogs?\
523.endd
524so that it is possible to find out what has changed without having to download
525the entire distribution.
526
527.index documentation||available formats
528The main distribution contains ASCII versions of this specification and other
529documentation; other formats of the documents are available in separate files
530inside the \(exim4)\ directory of the FTP site:
531.display rm
532\(exim-html-$it{n.nn}.tar.gz)\
533\(exim-pdf-$it{n.nn}.tar.gz)\
534\(exim-postscript-$it{n.nn}.tar.gz)\
535\(exim-texinfo-$it{n.nn}.tar.gz)\
536.endd
537These tar files contain only the \(doc)\ directory, not the complete
538distribution, and are also available in \(.bz2)\ as well as \(.gz)\ forms.
539
540.index FAQ
541The FAQ is available for downloading in two different formats from
542.display rm
543.if ! ~~sys.fancy
544.indent 0
545.fi
546\?ftp://ftp.csx.cam.ac.uk/pub/software/email/exim/exim4/FAQ.txt.gz?\
547\?ftp://ftp.csx.cam.ac.uk/pub/software/email/exim/exim4/FAQ.html.tar.gz?\
548.endd
549The first of these is a single ASCII file that can be searched with a text
550editor. The second is a directory of HTML files, normally accessed by starting
551at \(index.html)\. The HTML version of the FAQ (which is also included in the
552HTML documentation tarbundle) includes a keyword-in-context index, which is
553often the most convenient way of finding your way around.
554
555.section Wish list
556.index wish list
557A wish list is maintained, containing ideas for new features that have been
558submitted. From time to time the file is exported to the ftp site:
559.display rm
560\?ftp://ftp.csx.cam.ac.uk/pub/software/email/exim/exim4/WishList?\
561.endd
562Items are removed from the list if they get implemented.
563
564
565.section Contributed material
566.index contributed material
567At the ftp site, there is a directory called
568.display rm
569.if ! ~~sys.fancy
570.indent 0
571.fi
572\?ftp://ftp.csx.cam.ac.uk/pub/software/email/exim/exim4/Contrib/?\
573.endd
574which contains miscellaneous files contributed to the Exim community by Exim
575users. There is also a collection of contributed configuration examples in
576.display rm
577.if ! ~~sys.fancy
578.indent 0
579.fi
580\?ftp://ftp.csx.cam.ac.uk/pub/software/email/exim/exim4/config.samples.tar.gz?\
581.endd
582These samples are referenced from the FAQ.
583
584
585.section Limitations
586.index limitations of Exim
587.numberpars $.
588Exim is designed for use as an Internet MTA, and therefore handles addresses
589in RFC 2822 domain format only.
590.index bang paths||not handled by Exim
591It cannot handle UUCP `bang paths', though simple two-component bang paths can
592be converted by a straightforward rewriting configuration. This restriction
593does not prevent Exim from being interfaced to UUCP as a transport mechanism,
594provided that domain addresses are used.
595.nextp
596.index domainless addresses
597.index address||without domain
598Exim insists that every address it handles has a domain attached. For incoming
599local messages, domainless addresses are automatically qualified with a
600configured domain value. Configuration options specify from which remote
601systems unqualified addresses are acceptable. These are then qualified on
602arrival.
603.nextp
604.index transport||external
605.index external transports
606The only external transport currently implemented is an SMTP transport over a
607TCP/IP network (using sockets, including support for IPv6). However, a pipe
608transport is available, and there are facilities for writing messages to files
609and pipes, optionally in \*batched SMTP*\ format; these facilities can be used
610to send messages to some other transport mechanism such as UUCP, provided it
611can handle domain-style addresses. Batched SMTP input is also catered for.
612.nextp
613Exim is not designed for storing mail for dial-in hosts. When the volumes of
614such mail are large, it is better to get the messages `delivered' into files
615(that is, off Exim's queue) and subsequently passed on to the dial-in hosts by
616other means.
617.nextp
618Although Exim does have some facilities for scanning incoming messages, these
619are not comprehensive enough to do full virus or spam scanning. Such operations
620are best carried out using additional specialized software packages.
621.endp
622
623
624
625.section Run time configuration
626Exim's run time configuration is held in a single text file that is divided
627into a number of sections. The entries in this file consist of keywords and
628values, in the style of Smail 3 configuration files. A default configuration
629file which is suitable for simple online installations is provided in the
630distribution, and is described in chapter ~~CHAPdefconfil below.
631
632
633.section Calling interface
634.index Sendmail compatibility||command line interface
635Like many MTAs, Exim has adopted the Sendmail command line interface so that it
636can be a straight replacement for \(/usr/lib/sendmail)\ or
637\(/usr/sbin/sendmail)\ when sending mail, but you do not need to know anything
638about Sendmail in order to run Exim. For actions other than sending messages,
639Sendmail-compatible options also exist, but those that produce output (for
640example, \-bp-\, which lists the messages on the queue) do so in Exim's own
641format. There are also some additional options that are compatible with Smail
6423, and some further options that are new to Exim. Chapter ~~CHAPcommandline
643documents all Exim's command line options. This information is automatically
644made into the man page that forms part of the Exim distribution.
645
646Control of messages on the queue can be done via certain privileged command
647line options. There is also an optional monitor program called \*eximon*\, which
648displays current information in an X window, and which contains a menu
649interface to Exim's command line administration options.
650
651
652.section Terminology
653.index terminology definitions
654.index body of message||definition of
655The \*body*\ of a message is the actual data that the sender wants to transmit.
656It is the last part of a message, and is separated from the \*header*\ (see
657below) by a blank line.
658
659.index bounce message||definition of
660When a message cannot be delivered, it is normally returned to the sender in a
661delivery failure message. The term \*bounce*\ is commonly used for this action,
662and the error reports are often called \*bounce messages*\. This is a
663convenient shorthand for `delivery failure error report'. Such messages have an
664empty sender address in the message's \*envelope*\ (see below) to ensure that
665they cannot themselves give rise to further bounce messages.
666
667The term \*default*\ appears frequently in this manual. It is used to qualify a
668value which is used in the absence of any setting in the configuration. It may
669also qualify an action which is taken unless a configuration setting specifies
670otherwise.
671
672The term \*defer*\ is used when the delivery of a message to a specific
673destination cannot immediately take place for some reason (a remote host may be
674down, or a user's local mailbox may be full). Such deliveries are \*deferred*\
675until a later time.
676
677The word \*domain*\ is sometimes used to mean all but the first component of a
678host's name. It is $it{not} used in that sense here, where it normally
679refers to the part of an email address following the @@ sign.
680
681.index envelope, definition of
682.index sender||definition of
683A message in transit has an associated \*envelope*\, as well as a header and a
684body. The envelope contains a sender address (to which bounce messages should
685be delivered), and any number of recipient addresses. References to the
686sender or the recipients of a message usually mean the addresses in the
687envelope. An MTA uses these addresses for delivery, and for returning bounce
688messages, not the addresses that appear in the header lines.
689
690.index message||header, definition of
691.index header section||definition of
692The \*header*\ of a message is the first part of a message's text, consisting
693of a number of lines, each of which has a name such as ::From::, ::To::,
694::Subject::, etc. Long header lines can be split over several text lines by
695indenting the continuations. The header is separated from the body by a blank
696line.
697
698.index local part||definition of
699.index domain||definition of
700The term \*local part*\, which is taken from RFC 2822, is used to refer to that
701part of an email address that precedes the @@ sign. The part that follows the
702@@ sign is called the \*domain*\ or \*mail domain*\.
703
704.index local delivery||definition of
705.index remote delivery, definition of
706The terms \*local delivery*\ and \*remote delivery*\ are used to distinguish
707delivery to a file or a pipe on the local host from delivery by SMTP over
708TCP/IP to a remote host.
709
710.index return path||definition of
711\*Return path*\ is another name that is used for the sender address in a
712message's envelope.
713
714.index queue||definition of
715The term \*queue*\ is used to refer to the set of messages awaiting delivery,
716because this term is in widespread use in the context of MTAs. However, in
717Exim's case the reality is more like a pool than a queue, because there is
718normally no ordering of waiting messages.
719
720.index queue runner||definition of
721The term \*queue runner*\ is used to describe a process that scans the queue
722and attempts to deliver those messages whose retry times have come. This term
723is used by other MTAs, and also relates to the command \runq\, but in Exim
724the waiting messages are normally processed in an unpredictable order.
725
726.index spool directory||definition of
727The term \*spool directory*\ is used for a directory in which Exim keeps the
728messages on its queue -- that is, those that it is in the process of
729delivering. This should not be confused with the directory in which local
730mailboxes are stored, which is called a `spool directory' by some people. In
731the Exim documentation, `spool' is always used in the first sense.
732
733
734
735.
736.
737.
738.
739. ============================================================================
740.chapter Incorporated code
741.set runningfoot "incorporated code"
742.index incorporated code
743.index regular expressions||library
744.index PCRE
745A number of pieces of external code are included in the Exim distribution.
746.numberpars $.
747Regular expressions are supported in the main Exim program and in the Exim
748monitor using the freely-distributable PCRE library, copyright (c) 2003
749University of Cambridge. The source is distributed in the directory
750\(src/pcre)\. However, this is a cut-down version of PCRE. If you want to use
751the PCRE library in other programs, you should obtain and install the full
752version from \?ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre?\.
753
754.space 1ld
755.nextp
756.index cdb||acknowledgement
757Support for the cdb (Constant DataBase) lookup method is provided by code
758contributed by Nigel Metheringham of Planet Online Ltd. which contains the
759following statements:
760.rule
761.push
762.if ~~sgcal
763.fontgroup 9
764.font 0
765.fi
766Copyright (c) 1998 Nigel Metheringham, Planet Online Ltd
767
768This program is free software; you can redistribute it and/or modify it under
769the terms of the GNU General Public License as published by the Free Software
770Foundation; either version 2 of the License, or (at your option) any later
771version.
772
773This code implements Dan Bernstein's Constant DataBase (cdb) spec. Information,
774the spec and sample code for cdb can be obtained from
775\?http://www.pobox.com/@~djb/cdb.html?\. This implementation borrows some code
776from Dan Bernstein's implementation (which has no license restrictions applied
777to it).
778.newline
779.pop
780.rule
781The implementation is completely contained within the code of Exim.
782It does not link against an external cdb library.
783.space 1ld
784.nextp
785.index SPA authentication
786.index Samba project
787.index Microsoft Secure Password Authentication
788Client support for Microsoft's \*Secure Password Authentication*\ is provided
789by code contributed by Marc Prud'hommeaux. Server support was contributed by
790Tom Kistner. This includes code taken from the Samba project, which is released
791under the Gnu GPL.
792
793.space 1ld
794.nextp
795.index Cyrus
796.index \*pwcheck*\ daemon
797.index \*pwauthd*\ daemon
798Support for calling the Cyrus \*pwcheck*\ and \*saslauthd*\ daemons is provided
799by code taken from the Cyrus-SASL library and adapted by Alexander S.
800Sabourenkov. The permission notice appears below, in accordance with the
801conditions expressed therein.
802
803.rule
804.push
805.if ~~sgcal
806.fontgroup 9
807.font 0
808.fi
809Copyright (c) 2001 Carnegie Mellon University. All rights reserved.
810
811Redistribution and use in source and binary forms, with or without
812modification, are permitted provided that the following conditions
813are met:
814
815.if ~~sgcal
816.cancelflag $npbracket
817.flag $npbracket "" "."
818.fi
819.numberpars
820Redistributions of source code must retain the above copyright
821notice, this list of conditions and the following disclaimer.
822.nextp
823Redistributions in binary form must reproduce the above copyright
824notice, this list of conditions and the following disclaimer in
825the documentation and/or other materials provided with the
826distribution.
827.nextp
828The name `Carnegie Mellon University' must not be used to
829endorse or promote products derived from this software without
830prior written permission. For permission or any other legal
831details, please contact
832.display rm
833Office of Technology Transfer
834Carnegie Mellon University
8355000 Forbes Avenue
836Pittsburgh, PA 15213-3890
837(412) 268-4387, fax: (412) 268-7395
838tech-transfer@@andrew.cmu.edu
839.endd
840.nextp
841Redistributions of any form whatsoever must retain the following
842acknowledgment:
843.newline
844.push
845.indent ~~sys.indent + 3em
846.justify left
847$it{This product includes software developed by Computing Services
848at Carnegie Mellon University (\?http://www.cmu.edu/computing/?\).}
849.newline
850.pop
851.endp
852.if ~~sgcal
853.cancelflag $npbracket
854.flag $npbracket "(" ")"
855.fi
856
857CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
858THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
859AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
860FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
861WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
862AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
863OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
864.newline
865.pop
866.rule
867
868.space 1ld
869.nextp
870.index monitor
871.index X-windows
872.index Athena
873The Exim Monitor program, which is an X-Window application, includes
874modified versions of the Athena StripChart and TextPop widgets.
875This code is copyright by DEC and MIT, and their permission notice appears
876below, in accordance with the conditions expressed therein.
877
878.rule
879.push
880.if ~~sgcal
881.fontgroup 9
882.font 0
883.fi
884Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
885and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
886.blank
887$c All Rights Reserved
888.blank
889Permission to use, copy, modify, and distribute this software and its
890documentation for any purpose and without fee is hereby granted,
891provided that the above copyright notice appear in all copies and that
892both that copyright notice and this permission notice appear in
893supporting documentation, and that the names of Digital or MIT not be
894used in advertising or publicity pertaining to distribution of the
895software without specific, written prior permission.
896
897DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
898ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
899DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
900ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
901WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
902ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
903SOFTWARE.
904.newline
905.pop
906.rule
907.endp
908
909
910
911.
912.
913.
914.
915. ============================================================================
916.chapter How Exim receives and delivers mail
917.set runningfoot "receiving & delivering mail"
918
919.section Overall philosophy
920.index design philosophy
921Exim is designed to work efficiently on systems that are permanently connected
922to the Internet and are handling a general mix of mail. In such circumstances,
923most messages can be delivered immediately. Consequently, Exim does not
924maintain independent queues of messages for specific domains or hosts, though
925it does try to send several messages in a single SMTP connection after a host
926has been down, and it also maintains per-host retry information.
927
928
929.section Policy control
930.index policy control||overview
931Policy controls are now an important feature of MTAs that are connected to the
932Internet. Perhaps their most important job is to stop MTAs being abused as
933`open relays' by misguided individuals who send out vast amounts of unsolicited
934junk, and want to disguise its source. Exim provides flexible facilities for
935specifying policy controls on incoming mail:
936.numberpars $.
937.index ~~ACL||introduction
938Exim 4 (unlike previous versions of Exim) implements policy controls on
939incoming SMTP mail by means of \*Access Control Lists*\ (ACLs). Each list is a
940series of statements that may either grant or deny access. ACLs can be used at
941several places in the SMTP dialogue while receiving a message. However, the
942most common places are after each \\RCPT\\ command, and at the very end of the
943message. The sysadmin can specify conditions for accepting or rejecting
944individual recipients or the entire message, respectively, at these two points
945(see chapter ~~CHAPACL). Denial of access results in an SMTP error code.
946.nextp
947An ACL is also available for locally generated, non-SMTP messages. In this
948case, the only available actions are to accept or deny the entire message.
949.nextp
950When a message has been received, either from a remote host or from the local
951host, but before the final acknowledgement has been sent, a locally supplied C
952function called \*local@_scan()*\ can be run to inspect the message and decide
953whether to accept it or not (see chapter ~~CHAPlocalscan). If the message is
954accepted, the list of recipients can be modified by the function.
955.nextp
956After a message has been accepted, a further checking mechanism is available in
957the form of the $it{system filter} (see chapter ~~CHAPsystemfilter). This runs
958at the start of every delivery process.
959.endp
960
961.section User filters
962.index filter||introduction
963.index Sieve filter
964In a conventional Exim configuration, users are able to run private filters by
965setting up appropriate \(.forward)\ files in their home directories. See
966chapter ~~CHAPredirect (about the \%redirect%\ router) for the configuration
967needed to support this, and the separate document entitled
968.if ~~html
969[(A HREF="filter_toc.html")]
970.fi
971\*Exim's interfaces to mail filtering*\
972.if ~~html
973[(/A)]
974.fi
975for user details. Two different kinds of filtering are available:
976.numberpars $.
977Sieve filters are written in the standard filtering language that is defined by
978RFC 3028.
979.nextp
980Exim filters are written in a syntax that is unique to Exim, but which is more
981powerful than Sieve, which it pre-dates.
982.endp
983User filters are run as part of the routing process, described below.
984
985
986.section Message identification
987.rset SECTmessiden "~~chapter.~~section"
988.index message||ids, details of format
989.index format||of message id
990.index id of message
991.index base62
992.index base36
993.index Darwin
994.index Cygwin
995Every message handled by Exim is given a \*message id*\ which is sixteen
996characters long. It is divided into three parts, separated by hyphens, for
997example \"16VDhn-0001bo-D3"\. Each part is a sequence of letters and digits,
998normally encoding numbers in base 62. However, in the Darwin operating
999system (Mac OS X) and when Exim is compiled to run under Cygwin, base 36
1000(avoiding the use of lower case letters) is used instead, because the message
1001id is used to construct file names, and the names of files in those systems are
1002not case-sensitive.
1003
1004.index pid (process id)||re-use of
1005The detail of the contents of the message id have changed as Exim has evolved.
1006Earlier versions relied on the operating system not re-using a process id (pid)
1007within one second. On modern operating systems, this assumption can no longer
1008be made, so the algorithm had to be changed. To retain backward compatibility,
1009the format of the message id was retained, which is why the following rules are
1010somewhat eccentric:
1011.numberpars $.
1012The first six characters of the message id are the time at which the message
1013started to be received, to a granularity of one second. That is, this field
1014contains the number of seconds since the start of the epoch (the normal Unix
1015way of representing the date and time of day).
1016.nextp
1017After the first hyphen, the next six characters are the id of the process that
1018received the message.
1019.nextp
1020There are two different possibilities for the final two characters:
1021.numberpars alpha
1022.index \localhost@_number\
1023If \localhost@_number\ is not set, this value is the fractional part of the
1024time of reception, normally in units of 1/2000 of a second, but for systems
1025that must use base 36 instead of base 62 (because of case-insensitive file
1026systems), the units are 1/1000 of a second.
1027.nextp
1028If \localhost@_number\ is set, it is multiplied by 200 (100) and added to
1029the fractional part of the time, which in this case is in units of 1/200
1030(1/100) of a second.
1031.endp
1032.endp
1033After a message has been received, Exim waits for the clock to tick at the
1034appropriate resolution before proceeding, so that if another message is
1035received by the same process, or by another process with the same (re-used)
1036pid, it is guaranteed that the time will be different. In most cases, the clock
1037will already have ticked while the message was being received.
1038
1039.section Receiving mail
1040.index receiving mail
1041.index message||reception
1042The only way Exim can receive mail from a remote host is using SMTP over
1043TCP/IP, in which case the sender and recipient addresses are tranferred using
1044SMTP commands. However, from a locally running process (such as a user's MUA),
1045there are several possibilities:
1046.numberpars $.
1047If the process runs Exim with the \-bm-\ option, the message is read
1048non-interactively (usually via a pipe), with the recipients taken from the
1049command line, or from the body of the message if \-t-\ is also used.
1050.nextp
1051If the process runs Exim with the \-bS-\ option, the message is also read
1052non-interactively, but in this case the recipients are listed at the start of
1053the message in a series of SMTP \\RCPT\\ commands, terminated by a \\DATA\\
1054command. This is so-called `batch SMTP' format,
1055but it isn't really SMTP. The SMTP commands are just another way of passing
1056envelope addresses in a non-interactive submission.
1057.nextp
1058If the process runs Exim with the \-bs-\ option, the message is read
1059interactively, using the SMTP protocol. A two-way pipe is normally used for
1060passing data between the local process and the Exim process.
1061This is `real' SMTP and is handled in the same way as SMTP over TCP/IP. For
1062example, the ACLs for SMTP commands are used for this form of submission.
1063.nextp
1064A local process may also make a TCP/IP call to the host's loopback address
1065(127.0.0.1) or any other of its IP addresses. When receiving messages, Exim
1066does not treat the loopback address specially. It treats all such connections
1067in the same way as connections from other hosts.
1068.endp
1069
1070.index message||sender, constructed by Exim
1071.index sender||constructed by Exim
1072In the three cases that do not involve TCP/IP, the sender address is
1073constructed from the login name of the user that called Exim and a default
1074qualification domain (which can be set by the \qualify@_domain\ configuration
1075option). For local or batch SMTP, a sender address that is passed using the
1076SMTP \\MAIL\\ command is ignored. However, the system administrator may allow
1077certain users (`trusted users') to specify a different sender address
1078unconditionally, or all users to specify certain forms of different sender
1079address. The \-f-\ option or the SMTP \\MAIL\\ command is used to specify these
1080different addresses. See section ~~SECTtrustedadmin for details of trusted
1081users, and the \untrusted@_set@_sender\ option for a way of allowing untrusted
1082users to change sender addresses.
1083
1084Messages received by either of the non-interactive mechanisms are subject to
1085checking by the non-SMTP ACL, if one is defined. Messages received using SMTP
1086(either over TCP/IP, or interacting with a local process) can be checked by a
1087number of ACLs that operate at different times during the SMTP session. Either
1088individual recipients, or the entire message, can be rejected if local policy
1089requirements are not met. The \*local@_scan()*\ function (see chapter
1090~~CHAPlocalscan) is run for all incoming messages.
1091
1092Exim can be configured not to start a delivery process when a message is
1093received; this can be unconditional, or depend on the number of incoming SMTP
1094connections or the system load. In these situations, new messages wait on the
1095queue until a queue runner process picks them up. However, in standard
1096configurations under normal conditions, delivery is started as soon as a
1097message is received.
1098
1099
1100
1101
1102.section Handling an incoming message
1103.index spool directory||files that hold a message
1104.index file||how a message is held
1105When Exim accepts a message, it writes two files in its spool directory. The
1106first contains the envelope information, the current status of the message,
1107and the header lines, and the second contains the body of the message. The
1108names of the two spool files consist of the message id, followed by $tt{-H} for
1109the file containing the envelope and header, and $tt{-D} for the data file.
1110
1111.index spool directory||\(input)\ sub-directory
1112By default all these message files are held in a single directory called
1113\(input)\ inside the general Exim spool directory. Some operating systems do
1114not perform very well if the number of files in a directory gets very large; to
1115improve performance in such cases, the \split@_spool@_directory\ option can be
1116used. This causes Exim to split up the input files into 62 sub-directories
1117whose names are single letters or digits.
1118
1119The envelope information consists of the address of the message's sender and
1120the addresses of the recipients. This information is entirely separate from
1121any addresses contained in the header lines. The status of the message includes
1122a list of recipients who have already received the message. The format of the
1123first spool file is described in chapter ~~CHAPspool.
1124
1125.index rewriting||addresses
1126Address rewriting that is specified in the rewrite section of the configuration
1127(see chapter ~~CHAPrewrite) is done once and for all on incoming addresses,
1128both in the header lines and the envelope, at the time the message is accepted.
1129If during the course of delivery additional addresses are generated (for
1130example, via aliasing), these new addresses are rewritten as soon as they are
1131generated. At the time a message is actually delivered (transported) further
1132rewriting can take place; because this is a transport option, it can be
1133different for different forms of delivery. It is also possible to specify the
1134addition or removal of certain header lines at the time the message is
1135delivered (see chapters ~~CHAProutergeneric and ~~CHAPtransportgeneric).
1136
1137
1138.section Life of a message
1139.index message||life of
1140.index message||frozen
1141A message remains in the spool directory until it is completely delivered to
1142its recipients or to an error address, or until it is deleted by an
1143administrator or by the user who originally created it. In cases when delivery
1144cannot proceed -- for example, when a message can neither be delivered to its
1145recipients nor returned to its sender, the message is marked `frozen' on the
1146spool, and no more deliveries are attempted.
1147
1148.index frozen messages||thawing
1149.index message||thawing frozen
1150An administrator can `thaw' such messages when the problem has been corrected,
1151and can also freeze individual messages by hand if necessary. In addition, an
1152administrator can force a delivery error, causing a bounce message to be sent.
1153
1154.index \auto@_thaw\
1155There is an option called \auto@_thaw\, which can be used to cause Exim to
1156retry frozen messages after a certain time. When this is set, no message will
1157remain on the queue for ever, because the delivery timeout will eventually be
1158reached. Delivery failure reports (bounce messages) that reach this timeout are
1159discarded.
1160.index \timeout@_frozen@_after\
1161There is also an option called \timeout@_frozen@_after\, which discards frozen
1162messages after a certain time.
1163
1164.index message||log file for
1165.index log||file for each message
1166While Exim is working on a message, it writes information about each delivery
1167attempt to the main log file. This includes successful, unsuccessful, and
1168delayed deliveries for each recipient (see chapter ~~CHAPlog). The log lines
1169are also written to a separate $it{message log} file for each message. These
1170logs are solely for the benefit of the administrator, and are normally deleted
1171along with the spool files when processing of a message is complete.
1172The use of individual message logs can be disabled by setting
1173\no@_message@_logs\; this might give an improvement in performance on very
1174busy systems.
1175
1176.index journal file
1177.index file||journal
1178All the information Exim itself needs to set up a delivery is kept in the first
1179spool file, along with the header lines. When a successful delivery occurs, the
1180address is immediately written at the end of a journal file, whose name is the
1181message id followed by $tt{-J}. At the end of a delivery run, if there are some
1182addresses left to be tried again later, the first spool file (the $tt{-H} file)
1183is updated to indicate which these are, and the journal file is then deleted.
1184Updating the spool file is done by writing a new file and renaming it, to
1185minimize the possibility of data loss.
1186
1187Should the system or the program crash after a successful delivery but before
1188the spool file has been updated, the journal is left lying around. The next
1189time Exim attempts to deliver the message, it reads the journal file and
1190updates the spool file before proceeding. This minimizes the chances of double
1191deliveries caused by crashes.
1192
1193
1194.section Processing an address for delivery
1195.rset SECTprocaddress "~~chapter.~~section"
1196.index drivers||definition of
1197.index router||definition of
1198.index transport||definition of
1199The main delivery processing elements of Exim are called $it{routers} and
1200$it{transports}, and collectively these are known as $it{drivers}. Code for a
1201number of them is provided in the source distribution, and compile-time options
1202specify which ones are included in the binary. Run time options specify which
1203ones are actually used for delivering messages.
1204
1205.index drivers||instance definition
1206Each driver that is specified in the run time configuration is an \*instance*\
1207of that particular driver type. Multiple instances are allowed; for example,
1208you can set up several different \%smtp%\ transports, each with different
1209option values that might specify different ports or different timeouts. Each
1210instance has its own identifying name. In what follows we will normally use the
1211instance name when discussing one particular instance (that is, one specific
1212configuration of the driver), and the generic driver name when discussing
1213the driver's features in general.
1214
1215A $it{router} is a driver that operates on an address, either determining how
1216its delivery should happen, by routing it to a specific transport, or
1217converting the address into one or more new addresses (for example, via an
1218alias file). A router may also explicitly choose to fail an address, causing it
1219to be bounced.
1220
1221A $it{transport} is a driver that transmits a copy of the message from Exim's
1222spool to some destination. There are two kinds of transport: for a $it{local}
1223transport, the destination is a file or a pipe on the local host, whereas for a
1224$it{remote} transport the destination is some other host. A message is passed
1225to a specific transport as a result of successful routing. If a message has
1226several recipients, it may be passed to a number of different transports.
1227
1228.index preconditions||definition of
1229An address is processed by passing it to each configured router instance in
1230turn, subject to certain preconditions, until a router accepts the address or
1231specifies that it should be bounced. We will describe this process in more
1232detail shortly. As a simple example, the diagram below illustrates how each
1233recipient address in a message is processed in a small configuration of three
1234routers that are configured in various ways.
1235
1236.if ~~sys.fancy
1237.figure "Routing an address" rm
1238.indent 0
1239.call aspic
1240centre ~~sys.linelength;
1241magnify 0.8;
1242boundingbox 30;
1243 ibox depth 14 "address";
1244B: arrow down 44;
1245 textdepth 14;
1246A: box width 100 "first router" "conditions ok?";
1247 arrow right "yes";
1248C: box width 100 "run" "first router";
1249 arrow down "fail";
1250D: ibox depth 20 "address bounces";
1251
1252 arc clockwise from right of C "accept";
1253 arrow down 10;
1254 ibox "queue for" "transport";
1255
1256 arrow down from A align bottom of D plus (0,-20) "no"(-6,20)/r;
1257E: box width 100 "second router" "conditions ok?";
1258 arrow right "yes";
1259F: box width 100 "run" "second router";
1260 line right 100 "redirect";
1261 line up align middle of B;
1262 arrow left to middle of B "new addresses";
1263
1264 line down 20 from bottom left of F plus (30,0);
1265 arrow left align centre of E "decline";
1266
1267 line down 20 from bottom right of F plus (-30,0);
1268 arrow right "fail";
1269 ibox width 64 "address" "bounces";
1270
1271 arrow down 64 from E "no"(-6,20)/r;
1272G: box width 100 "third router" "conditions ok?";
1273 arrow right "yes";
1274H: box width 100 "run" "third router";
1275 arc clockwise from right of H "accept";
1276 arrow down 10;
1277 ibox "queue for" "transport";
1278
1279 line down 20 from bottom of H;
1280 arrow left align centre of G "decline";
1281 arrow down 64 from G "no"(-6,20)/r;
1282
1283 ibox "no more routers" "address bounces";
1284.endcall
1285.endfigure
1286.elif !~~html
1287.display asis
1288
1289 address
1290 |
1291 |<------------- new addresses -----------------------------
1292 V |
1293 ----------------- ----------------- |
1294 | first router |----- yes ----->| run |--- accept |
1295 | conditions ok?| | first router | | |
1296 ----------------- ----------------- | |
1297 | | V |
1298 no | fail | queue for |
1299 | V transport |
1300 | address bounces |
1301 | |
1302 V |
1303 ----------------- ----------------- |
1304 | second router |----- yes ----->| run |----redirect ----
1305 | conditions ok?| | second router |
1306 ----------------- -----------------
1307 | | |
1308 no | | |
1309 |<-------- decline ----------- --- fail ---> address
1310 | bounces
1311 V
1312 ----------------- -----------------
1313 | third router |----- yes ----->| run |--- accept
1314 | conditions ok?| | third router | |
1315 ----------------- ----------------- |
1316 | | V
1317 no | | queue for
1318 |<-------- decline --------------- transport
1319 |
1320 V
1321 no more routers
1322 address bounces
1323.endd
1324.else
1325[(img src="routing.gif" alt="Routing an address")][(br)]
1326.fi
1327To make this a more concrete example, we'll describe it in terms of some actual
1328routers, but remember, this is only an example. You can configure Exim's
1329routers in many different ways, and there may be any number of routers in a
1330configuration.
1331
1332The first router that is specified in a configuration is often one that handles
1333addresses in domains that are not recognized specially by the local host. These
1334are typically addresses for arbitrary domains on the Internet. A precondition
1335is set up which looks for the special domains known to the host (for example,
1336its own domain name), and the router is run for addresses that do $it{not}
1337match. Typically, this is a router that looks up domains in the DNS in order to
1338find the hosts to which this address routes. If it succeeds, the address is
1339queued for a suitable SMTP transport; if it does not succeed, the router is
1340configured to fail the address.
1341
1342The example pictured could be a configuration of this type. The second and
1343third routers can only be run for addresses for which the preconditions for
1344the first router are not met. If one of these preconditions checks the
1345domain, the second and third routers are run only for domains that are somehow
1346special to the local host.
1347
1348The second router does redirection -- also known as aliasing and forwarding.
1349When it generates one or more new addresses from the original, each of them is
1350routed independently from the start. Otherwise, the router may cause an address
1351to fail, or it may simply decline to handle the address, in which case the
1352address is passed to the next router.
1353
1354The final router in many configurations is one that checks to see if the
1355address belongs to a local mailbox. The precondition may involve a check to
1356see if the local part is the name of a login account, or it may look up the
1357local part in a file or a database. If its preconditions are not met, or if
1358the router declines, we have reached the end of the routers. When this happens,
1359the address is bounced.
1360
1361
1362.section Processing an address for verification
1363.index router||for verification
1364.index verifying||address, overview
1365As well as being used to decide how to deliver to an address, Exim's routers
1366are also used for \*address verification*\. Verification can be requested as
1367one of the checks to be performed in an ACL for incoming messages, on both
1368sender and recipient addresses, and it can be tested using the \-bv-\ and
1369\-bvs-\ command line options.
1370
1371When an address is being verified, the routers are run in `verify mode'. This
1372does not affect the way the routers work, but it is a state that can be
1373detected. By this means, a router can be skipped or made to behave differently
1374when verifying. A common example is a configuration in which the first router
1375sends all messages to a message-scanning program, unless they have been
1376previously scanned. Thus, the first router accepts all addresses without any
1377checking, making it useless for verifying. Normally, the \no@_verify\ option
1378would be set for such a router, causing it to be skipped in verify mode.
1379
1380
1381
1382.section Running an individual router
1383.rset SECTrunindrou "~~chapter.~~section"
1384.index router||running details
1385.index preconditions||checking
1386.index router||result of running
1387As explained in the example above, a number of preconditions are checked before
1388running a router. If any are not met, the router is skipped, and the address is
1389passed to the next router. When all the preconditions on a router $it{are} met,
1390the router is run. What happens next depends on the outcome, which is one of
1391the following:
1392.numberpars $.
1393\*accept*\: The router accepts the address, and either queues it for a
1394transport, or generates one or more `child' addresses. Processing the original
1395address ceases,
1396.index \unseen\ option
1397unless the \unseen\ option is set on the router. This option
1398can be used to set up multiple deliveries with different routing (for example,
1399for keeping archive copies of messages). When \unseen\ is set, the address is
1400passed to the next router. Normally, however, an \*accept*\ return marks the
1401end of routing.
1402
1403.index case of local parts
1404.index address||duplicate, discarding
1405If child addresses are generated, Exim checks to see whether they are
1406duplicates of any existing recipient addresses. During this check, local parts
1407are treated as case-sensitive. Duplicate addresses are discarded. Each of the
1408remaining child addresses is then processed independently, starting with the
1409first router by default. It is possible to change this by setting the
1410\redirect@_router\ option to specify which router to start at for child
1411addresses. Unlike \pass@_router\ (see below) the router specified by
1412\redirect@_router\ may be anywhere in the router configuration.
1413.nextp
1414\*pass*\: The router recognizes the address, but cannot handle it itself. It
1415requests that the address be passed to another router. By default the address
1416is passed to the next router, but this can be changed by setting the
1417\pass@_router\ option. However, (unlike \redirect@_router\) the named router
1418must be below the current router (to avoid loops).
1419.nextp
1420\*decline*\: The router declines to accept the address because it does not
1421recognize it at all. By default, the address is passed to the next router, but
1422this can be prevented by setting the \no@_more\ option. When \no@_more\ is set,
1423all the remaining routers are skipped.
1424.nextp
1425\*fail*\: The router determines that the address should fail, and queues it for
1426the generation of a bounce message. There is no further processing of the
1427original address unless \unseen\ is set on the router.
1428.nextp
1429\*defer*\: The router cannot handle the address at the present time. (A database
1430may be offline, or a DNS lookup may have timed out.) No further processing of
1431the address happens in this delivery attempt. It is tried again next time the
1432message is considered for delivery.
1433.nextp
1434\*error*\: There is some error in the router (for example, a syntax error in
1435its configuration). The action is as for defer.
1436.endp
1437If an address reaches the end of the routers without having been accepted by
1438any of them, it is bounced as unrouteable.
1439The default error message in this situation is `unrouteable address', but you
1440can set your own message by making use of the \cannot@_route@_message\ option.
1441This can be set for any router; the value from the last router that `saw'
1442the address is used.
1443
1444Sometimes while routing you want to fail a delivery when some conditions are
1445met but others are not, instead of passing the address on for further routing.
1446You can do this by having a second router that explicitly fails the delivery
1447when the relevant conditions are met. The \%redirect%\ router has a `fail'
1448facility for this purpose.
1449
1450
1451
1452.section Router preconditions
1453.rset SECTrouprecon "~~chapter.~~section"
1454.index router||preconditions, order of processing
1455.index preconditions||order of processing
1456The preconditions that are tested for each router are listed below, in the
1457order in which they are tested. The individual configuration options are
1458described in more detail in chapter ~~CHAProutergeneric.
1459.numberpars $.
1460The \local@_part@_prefix\ and \local@_part@_suffix\ options can specify that
1461the local parts handled by the router may or must have certain prefixes and/or
1462suffixes. If a mandatory affix (prefix or suffix) is not present, the router is
1463skipped. These conditions are tested first. When an affix is present, it is
1464removed from the local part before further processing, including the evaluation
1465of any other conditions.
1466.nextp
1467Routers can be designated for use only when not verifying an address, that is,
1468only when routing it for delivery (or testing its delivery routing). If the
1469\verify\ option is set false, the router is skipped when Exim is verifying an
1470address.
1471Setting the \verify\ option actually sets two options, \verify@_sender\ and
1472\verify@_recipient\, which independently control the use of the router for
1473sender and recipient verification. You can set these options directly if
1474you want a router to be used for only one type of verification.
1475.nextp
1476If the \address@_test\ option is set false, the router is skipped when Exim is
1477run with the \-bt-\ option to test an address routing. This can be helpful when
1478the first router sends all new messages to a scanner of some sort; it makes it
1479possible to use \-bt-\ to test subsequent delivery routing without having to
1480simulate the effect of the scanner.
1481.nextp
1482Routers can be designated for use only when verifying an address, as
1483opposed to routing it for delivery. The \verify@_only\ option controls this.
1484.nextp
1485Certain routers can be explicitly skipped when running the routers to check an
1486address given in the SMTP \\EXPN\\ command (see the \expn\ option).
1487.nextp
1488If the \domains\ option is set, the domain of the address must be in the set of
1489domains that it defines.
1490.nextp
1491If the \local@_parts\ option is set, the local part of the address must be in
1492the set of local parts that it defines. If \local@_part@_prefix\ or
1493\local@_part@_suffix\ is in use, the prefix or suffix is removed from the local
1494part before this check. If you want to do precondition tests on local parts
1495that include affixes, you can do so by using a \condition\ option (see below)
1496that uses the variables \$local@_part$\, \$local@_part@_prefix$\, and
1497\$local@_part@_suffix$\ as necessary.
1498.nextp
1499If the \check@_local@_user\ option is set, the local part must be the name of
1500an account on the local host.
1501If this check succeeds, the uid and gid of the local user are placed in
1502\$local@_user@_uid$\ and \$local@_user@_gid$\; these values can be used in the
1503remaining preconditions.
1504.nextp
1505If the \router@_home@_directory\ option is set, it is expanded at this point,
1506because it overrides the value of \$home$\. If this expansion were left till
1507later, the value of \$home$\ as set by \check@_local@_user\ would be used in
1508subsequent tests. Having two different values of \$home$\ in the same router
1509could lead to confusion.
1510.nextp
1511If the \senders\ option is set, the envelope sender address must be in the set
1512of addresses that it defines.
1513.nextp
1514If the \require@_files\ option is set, the existence or non-existence of
1515specified files is tested.
1516.nextp
1517.index customizing||precondition
1518If the \condition\ option is set, it is evaluated and tested. This option uses
1519an expanded string to allow you to set up your own custom preconditions.
1520Expanded strings are described in chapter ~~CHAPexpand.
1521.endp
1522
1523Note that \require@_files\ comes near the end of the list, so you cannot use it
1524to check for the existence of a file in which to lookup up a domain, local
1525part, or sender. However, as these options are all expanded, you can use the
1526\exists\ expansion condition to make such tests within each condition. The
1527\require@_files\ option is intended for checking files that the router may be
1528going to use internally, or which are needed by a specific transport (for
1529example, \(.procmailrc)\).
1530
1531
1532.section Delivery in detail
1533.index delivery||in detail
1534When a message is to be delivered, the sequence of events is as follows:
1535.numberpars $.
1536If a system-wide filter file is specified, the message is passed to it. The
1537filter may add recipients to the message, replace the recipients, discard the
1538message, cause a new message to be generated, or cause the message delivery to
1539fail. The format of the system filter file is the same as for Exim user filter
1540files, described in the separate document entitled
1541.if ~~html
1542[(A HREF="filter.html")]
1543.fi
1544\*Exim's interfaces to mail filtering*\.
1545.if ~~html
1546[(/A)]
1547.fi
1548.index Sieve filter||not available for system filter
1549(\**Note**\: Sieve cannot be used for system filter files.)
1550Some additional features are available in system filters -- see chapter
1551~~CHAPsystemfilter for details. Note that a message is passed to the system
1552filter only once per delivery attempt, however many recipients it has. However,
1553if there are several delivery attempts because one or more addresses could not
1554be immediately delivered, the system filter is run each time. The filter
1555condition \first@_delivery\ can be used to detect the first run of the system
1556filter.
1557.nextp
1558Each recipient address is offered to each configured router in turn, subject to
1559its preconditions, until one is able to handle it. If no router can handle
1560the address, that is, if they all decline, the address is failed. Because
1561routers can be targeted at particular domains, several locally handled domains
1562can be processed entirely independently of each other.
1563.nextp
1564.index routing||loops in
1565.index loop||while routing
1566A router that accepts an address may set up a local or a remote transport for
1567it. However, the transport is not run at this time. Instead, the address is
1568placed on a list for the particular transport, to be run later. Alternatively,
1569the router may generate one or more new addresses (typically from alias,
1570forward, or filter files). New addresses are fed back into this process from
1571the top, but in order to avoid loops, a router ignores any address which has an
1572identically-named ancestor that was processed by itself.
1573.nextp
1574When all the routing has been done, addresses that have been successfully
1575handled are passed to their assigned transports. When local transports are
1576doing real local deliveries, they handle only one address at a time, but if a
1577local transport is being used as a pseudo-remote transport (for example, to
1578collect batched SMTP messages for transmission by some other means) multiple
1579addresses can be handled. Remote transports can always handle more than one
1580address at a time, but can be configured not to do so, or to restrict multiple
1581addresses to the same domain.
1582.nextp
1583Each local delivery to a file or a pipe runs in a separate process under a
1584non-privileged uid, and these deliveries are run one at a time. Remote
1585deliveries also run in separate processes, normally under a uid that is private
1586to Exim (`the Exim user'), but in this case, several remote deliveries can be
1587run in parallel. The maximum number of simultaneous remote deliveries for any
1588one message is set by the \remote@_max@_parallel\ option.
1589.em
1590The order in which deliveries are done is not defined, except that all local
1591deliveries happen before any remote deliveries.
1592.nem
1593.nextp
1594.index queue runner
1595When it encounters a local delivery during a queue run, Exim checks its retry
1596database to see if there has been a previous temporary delivery failure for the
1597address before running the local transport. If there was a previous failure,
1598Exim does not attempt a new delivery until the retry time for the address is
1599reached. However, this happens only for delivery attempts that are part of a
1600queue run. Local deliveries are always attempted when delivery immediately
1601follows message reception, even if retry times are set for them. This makes for
1602better behaviour if one particular message is causing problems (for example,
1603causing quota overflow, or provoking an error in a filter file).
1604.nextp
1605.index delivery||retry in remote transports
1606Remote transports do their own retry handling, since an address may be
1607deliverable to one of a number of hosts, each of which may have a different
1608retry time. If there have been previous temporary failures and no host has
1609reached its retry time, no delivery is attempted, whether in a queue run or
1610not. See chapter ~~CHAPretry for details of retry strategies.
1611.nextp
1612If there were any permanent errors, a bounce message is returned to an
1613appropriate address (the sender in the common case), with details of the error
1614for each failing address. Exim can be configured to send copies of bounce
1615messages to other addresses.
1616.nextp
1617.index delivery||deferral
1618If one or more addresses suffered a temporary failure, the message is left on
1619the queue, to be tried again later. Delivery of these addresses is said to be
1620\*deferred*\.
1621.nextp
1622When all the recipient addresses have either been delivered or bounced,
1623handling of the message is complete. The spool files and message log are
1624deleted, though the message log can optionally be preserved if required.
1625.endp
1626
1627
1628.section Retry mechanism
1629.index delivery||retry mechanism
1630.index retry||description of mechanism
1631.index queue runner
1632Exim's mechanism for retrying messages that fail to get delivered at the first
1633attempt is the queue runner process. You must either run an Exim daemon that
1634uses the \-q-\ option with a time interval to start queue runners at regular
1635intervals, or use some other means (such as \*cron*\) to start them. If you do
1636not arrange for queue runners to be run, messages that fail temporarily at the
1637first attempt will remain on your queue for ever. A queue runner process works
1638it way through the queue, one message at a time, trying each delivery that has
1639passed its retry time.
1640You can run several queue runners at once.
1641
1642Exim uses a set of configured rules to determine when next to retry the failing
1643address (see chapter ~~CHAPretry). These rules also specify when Exim should
1644give up trying to deliver to the address, at which point it generates a bounce
1645message. If no retry rules are set for a particular host, address, and error
1646combination, no retries are attempted, and temporary errors are treated as
1647permanent.
1648
1649
1650.section Temporary delivery failure
1651.index delivery||temporary failure
1652There are many reasons why a message may not be immediately deliverable to a
1653particular address. Failure to connect to a remote machine (because it, or the
1654connection to it, is down) is one of the most common. Temporary failures may be
1655detected during routing as well as during the transport stage of delivery.
1656Local deliveries may be delayed if NFS files are unavailable, or if a mailbox
1657is on a file system where the user is over quota. Exim can be configured to
1658impose its own quotas on local mailboxes; where system quotas are set they will
1659also apply.
1660
1661If a host is unreachable for a period of time, a number of messages may be
1662waiting for it by the time it recovers, and sending them in a single SMTP
1663connection is clearly beneficial. Whenever a delivery to a remote host is
1664deferred,
1665.index hints database
1666Exim makes a note in its hints database, and whenever a successful
1667SMTP delivery has happened, it looks to see if any other messages are waiting
1668for the same host. If any are found, they are sent over the same SMTP
1669connection, subject to a configuration limit as to the maximum number in any
1670one connection.
1671
1672
1673
1674.section Permanent delivery failure
1675.index delivery||permanent failure
1676.index bounce message||when generated
1677When a message cannot be delivered to some or all of its intended recipients, a
1678bounce message is generated. Temporary delivery failures turn into permanent
1679errors when their timeout expires. All the addresses that fail in a given
1680delivery attempt are listed in a single message. If the original message has
1681many recipients, it is possible for some addresses to fail in one delivery
1682attempt and others to fail subsequently, giving rise to more than one bounce
1683message. The wording of bounce messages can be customized by the administrator.
1684See chapter ~~CHAPemsgcust for details.
1685
1686.index ::X-Failed-Recipients:: header line
1687Bounce messages contain an ::X-Failed-Recipients:: header line that lists the
1688failed addresses, for the benefit of programs that try to analyse such messages
1689automatically.
1690
1691.index bounce message||recipient of
1692A bounce message is normally sent to the sender of the original message, as
1693obtained from the message's envelope. For incoming SMTP messages, this is the
1694address given in the \\MAIL\\ command. However, when an address is
1695expanded via a forward or alias file, an alternative address can be specified
1696for delivery failures of the generated addresses. For a mailing list expansion
1697(see section ~~SECTmailinglists) it is common to direct bounce messages to the
1698manager of the list.
1699
1700
1701
1702.section Failures to deliver bounce messages
1703.index bounce message||failure to deliver
1704If a bounce message (either locally generated or received from a remote host)
1705itself suffers a permanent delivery failure, the message is left on the queue,
1706but it is frozen, awaiting the attention of an administrator. There are options
1707which can be used to make Exim discard such failed messages, or to keep them
1708for only a short time (see \timeout@_frozen@_after\ and
1709\ignore@_bounce@_errors@_after\).
1710
1711
1712
1713.
1714.
1715.
1716.
1717. ============================================================================
1718.chapter Building and installing Exim
1719.set runningfoot "building/installing"
1720
1721.index building Exim
1722.section Unpacking
1723Exim is distributed as a gzipped or bzipped tar file which, when upacked,
1724creates a directory with the name of the current release (for example,
1725\(exim-~~version)\) into which the following files are placed:
1726.display rm
1727.if !~~sys.fancy && ~~sgcal
1728.tabs 16
1729.else
1730.tabs 22
1731.fi
1732\(ACKNOWLEDGMENTS)\ $t contains some acknowledgments
1733.newline
1734\(CHANGES)\ $t contains a reference to where changes are documented
1735\(LICENCE)\ $t the GNU General Public Licence
1736\(Makefile)\ $t top-level make file
1737\(NOTICE)\ $t conditions for the use of Exim
1738\(README)\ $t list of files, directories and simple build instructions
1739.endd
1740Other files whose names begin with \(README)\ may also be present. The
1741following subdirectories are created:
1742.display rm
1743.if !~~sys.fancy && ~~sgcal
1744.tabs 16
1745.else
1746.tabs 22
1747.fi
1748\(Local)\ $t an empty directory for local configuration files
1749\(OS)\ $t OS-specific files
1750\(doc)\ $t documentation files
1751\(exim@_monitor)\$t source files for the Exim monitor
1752\(scripts)\ $t scripts used in the build process
1753\(src)\ $t remaining source files
1754\(util)\ $t independent utilities
1755.endd
1756The main utility programs are contained in the \(src)\ directory, and are built
1757with the Exim binary. The \(util)\ directory contains a few optional scripts
1758that may be useful to some sites.
1759
1760.section Multiple machine architectures and operating systems
1761.index building Exim||multiple OS/architectures
1762The building process for Exim is arranged to make it easy to build binaries for
1763a number of different architectures and operating systems from the same set of
1764source files. Compilation does not take place in the \(src)\ directory. Instead,
1765a \*build directory*\ is created for each architecture and operating system.
1766.index symbolic link||to build directory
1767Symbolic links to the sources are installed in this directory, which is where
1768the actual building takes place.
1769
1770In most cases, Exim can discover the machine architecture and operating system
1771for itself, but the defaults can be overridden if necessary.
1772
1773.section DBM libraries
1774.rset SECTdb "~~chapter.~~section"
1775.index DBM||libraries, discussion of
1776.index hints database||DBM files used for
1777Even if you do not use any DBM files in your configuration, Exim still needs a
1778DBM library in order to operate, because it uses indexed files for its hints
1779databases. Unfortunately, there are a number of DBM libraries in existence, and
1780different operating systems often have different ones installed.
1781
1782.index Solaris||DBM library for
1783.index IRIX, DBM library for
1784.index BSD, DBM library for
1785.index Linux, DBM library for
1786If you are using Solaris, IRIX, one of the modern BSD systems, or a modern
1787Linux distribution, the DBM configuration should happen automatically, and you
1788may be able to ignore this section. Otherwise, you may have to learn more than
1789you would like about DBM libraries from what follows.
1790
1791.index \*ndbm*\ DBM library
1792Licensed versions of Unix normally contain a library of DBM functions operating
1793via the \*ndbm*\ interface, and this is what Exim expects by default. Free
1794versions of Unix seem to vary in what they contain as standard. In particular,
1795some early versions of Linux have no default DBM library, and different
1796distributors have chosen to bundle different libraries with their packaged
1797versions. However, the more recent releases seem to have standardised on the
1798Berkeley DB library.
1799
1800Different DBM libraries have different conventions for naming the files they
1801use. When a program opens a file called \(dbmfile)\, there are four
1802possibilities:
1803.numberpars
1804A traditional \*ndbm*\ implementation, such as that supplied as part of
1805Solaris, operates on two files called \(dbmfile.dir)\ and \(dbmfile.pag)\.
1806.nextp
1807.index \*gdbm*\ DBM library
1808The GNU library, \*gdbm*\, operates on a single file. If used via its \*ndbm*\
1809compatibility interface it makes two different hard links to it with names
1810\(dbmfile.dir)\ and \(dbmfile.pag)\, but if used via its native interface, the
1811file name is used unmodified.
1812.nextp
1813.index Berkeley DB library
1814The Berkeley DB package, if called via its \*ndbm*\ compatibility interface,
1815operates on a single file called \(dbmfile.db)\, but otherwise looks to the
1816programmer exactly the same as the traditional \*ndbm*\ implementation.
1817.nextp
1818If the Berkeley package is used in its native mode, it operates on a single
1819file called \(dbmfile)\; the programmer's interface is somewhat different to
1820the traditional \*ndbm*\ interface.
1821.nextp
1822To complicate things further, there are several very different versions of the
1823Berkeley DB package. Version 1.85 was stable for a very long time, releases
18242.$it{x} and 3.$it{x} were current for a while, but the latest versions are now
1825numbered 4.$it{x}. Maintenance of some of the earlier releases has ceased. All
1826versions of Berkeley DB can be obtained from
1827.display rm
1828\?http://www.sleepycat.com/?\
1829.endd
1830.nextp
1831.index \*tdb*\ DBM library
1832Yet another DBM library, called \*tdb*\, has become available from
1833.display rm
1834\?http://download.sourceforge.net/tdb?\
1835.endd
1836It has its own interface, and also operates on a single file.
1837.endp
1838.index \\USE@_DB\\
1839.index DBM||libraries, configuration for building
1840Exim and its utilities can be compiled to use any of these interfaces. In order
1841to use any version of the Berkeley DB package in native mode, you must set
1842\\USE@_DB\\ in an appropriate configuration file (typically
1843\(Local/Makefile)\). For example:
1844.display asis
1845USE_DB=yes
1846.endd
1847Similarly, for gdbm you set \\USE@_GDBM\\, and for tdb you set \\USE@_TDB\\. An
1848error is diagnosed if you set more than one of these.
1849
1850At the lowest level, the build-time configuration sets none of these options,
1851thereby assuming an interface of type (1). However, some operating system
1852configuration files (for example, those for the BSD operating systems and
1853Linux) assume type (4) by setting \\USE@_DB\\ as their default, and the
1854configuration files for Cygwin set \\USE@_GDBM\\. Anything you set in
1855\(Local/Makefile)\, however, overrides these system defaults.
1856
1857As well as setting \\USE@_DB\\, \\USE@_GDBM\\, or \\USE@_TDB\\, it may also be
1858necessary to set \\DBMLIB\\, to cause inclusion of the appropriate library, as
1859in one of these lines:
1860.display asis
1861DBMLIB = -ldb
1862DBMLIB = -ltdb
1863.endd
1864Settings like that will work if the DBM library is installed in the standard
1865place. Sometimes it is not, and the library's header file may also not be in
1866the default path. You may need to set \\INCLUDE\\ to specify where the header
1867file is, and to specify the path to the library more fully in \\DBMLIB\\, as in
1868this example:
1869.display asis
1870INCLUDE=-I/usr/local/include/db-4.1
1871DBMLIB=/usr/local/lib/db-4.1/libdb.a
1872.endd
1873
1874There is further detailed discussion about the various DBM libraries in the
1875file \(doc/dbm.discuss.txt)\ in the Exim distribution.
1876
1877
1878.section Pre-building configuration
1879.index building Exim||pre-building configuration
1880.index configuration for building Exim
1881.index \(Local/Makefile)\
1882.index \(src/EDITME)\
1883Before building Exim, a local configuration file that specifies options
1884independent of any operating system has to be created with the name
1885\(Local/Makefile)\. A template for this file is supplied as the file
1886\(src/EDITME)\, and it contains full descriptions of all the option settings
1887therein. These descriptions are therefore not repeated here. If you are
1888building Exim for the first time, the simplest thing to do is to copy
1889\(src/EDITME)\ to \(Local/Makefile)\, then read it and edit it appropriately.
1890
1891There are three settings that you must supply, because Exim will not build
1892without them. They are the location of the run time configuration file
1893(\\CONFIGURE@_FILE\\), the directory in which Exim binaries will be installed
1894(\\BIN@_DIRECTORY\\), and the identity of the Exim user (\\EXIM@_USER\\ and
1895maybe \\EXIM@_GROUP\\ as well). The value of \\CONFIGURE@_FILE\\ can in fact be
1896a colon-separated list of file names; Exim uses the first of them that exists.
1897
1898There are a few other parameters that can be specified either at build time or
1899at run time, to enable the same binary to be used on a number of different
1900machines. However, if the locations of Exim's spool directory and log file
1901directory (if not within the spool directory) are fixed, it is recommended that
1902you specify them in \(Local/Makefile)\ instead of at run time, so that errors
1903detected early in Exim's execution (such as a malformed configuration file) can
1904be logged.
1905
1906.index \(Local/eximon.conf)\
1907.index \(exim@_monitor/EDITME)\
1908If you are going to build the Exim monitor, a similar configuration process is
1909required. The file \(exim@_monitor/EDITME)\ must be edited appropriately for
1910your installation and saved under the name \(Local/eximon.conf)\. If you are
1911happy with the default settings described in \(exim@_monitor/EDITME)\,
1912\(Local/eximon.conf)\ can be empty, but it must exist.
1913
1914This is all the configuration that is needed in straightforward cases for known
1915operating systems. However, the building process is set up so that it is easy
1916to override options that are set by default or by operating-system-specific
1917configuration files, for example to change the name of the C compiler, which
1918defaults to \gcc\. See section ~~SECToverride below for details of how to do
1919this.
1920
1921
1922.section Support for iconv()
1923.index \*iconv()*\ support
1924The contents of header lines in messages may be encoded according to the rules
1925described RFC 2047. This makes it possible to transmit characters that are not
1926in the ASCII character set, and to label them as being in a particular
1927character set. When Exim is inspecting header lines by means of the \@$h@_\
1928mechanism, it decodes them, and translates them into a specified character set
1929(default ISO-8859-1). The translation is possible only if the operating system
1930supports the \*iconv()*\ function.
1931
1932However, some of the operating systems that supply \*iconv()*\ do not support
1933very many conversions. The GNU \libiconv\ library (available from
1934\?http:/@/www.gnu.org/software/libiconv/?\) can be installed on such systems to
1935remedy this deficiency, as well as on systems that do not supply \*iconv()*\ at
1936all. After installing \libiconv\, you should add
1937.display asis
1938HAVE_ICONV=yes
1939.endd
1940to your \(Local/Makefile)\ and rebuild Exim.
1941
1942
1943.section Including TLS/SSL encryption support
1944.rset SECTinctlsssl "~~chapter.~~section"
1945.index TLS||including support for TLS
1946.index encryption||including support for
1947.index \\SUPPORT@_TLS\\
1948.index OpenSSL||building Exim with
1949.index GnuTLS||building Exim with
1950Exim can be built to support encrypted SMTP connections, using the \\STARTTLS\\
1951command as per RFC 2487. It can also support legacy clients that expect to
1952start a TLS session immediately on connection to a non-standard port (see the
1953\-tls-on-connect-\ command line option).
1954
1955If you want to build Exim with TLS support, you must first install either the
1956OpenSSL or GnuTLS library. There is no cryptographic code in Exim itself for
1957implementing SSL.
1958
1959If OpenSSL is installed, you should set
1960.display asis
1961SUPPORT_TLS=yes
1962TLS_LIBS=-lssl -lcrypto
1963.endd
1964in \(Local/Makefile)\. You may also need to specify the locations of the
1965OpenSSL library and include files. For example:
1966.display asis
1967SUPPORT_TLS=yes
1968TLS_LIBS=-L/usr/local/openssl/lib -lssl -lcrypto
1969TLS_INCLUDE=-I/usr/local/openssl/include/
1970.endd
1971
1972If GnuTLS is installed, you should set
1973.index \\USE@_GNUTLS\\
1974.display asis
1975SUPPORT_TLS=yes
1976USE_GNUTLS=yes
1977TLS_LIBS=-lgnutls -ltasn1 -lgcrypt
1978.endd
1979in \(Local/Makefile)\, and again you may need to specify the locations of the
1980library and include files. For example:
1981.display asis
1982SUPPORT_TLS=yes
1983USE_GNUTLS=yes
1984TLS_LIBS=-L/usr/gnu/lib -lgnutls -ltasn1 -lgcrypt
1985TLS_INCLUDE=-I/usr/gnu/include
1986.endd
1987You do not need to set \\TLS@_INCLUDE\\ if the relevant directory is already
1988specified in \\INCLUDE\\. Details of how to configure Exim to make use of TLS
1989are given in chapter ~~CHAPTLS.
1990
1991
1992
1993.section Use of tcpwrappers
1994.index tcpwrappers, building Exim to support
1995.index \\USE@_TCP@_WRAPPERS\\
1996Exim can be linked with the \*tcpwrappers*\ library in order to check incoming
1997SMTP calls using the \*tcpwrappers*\ control files. This may be a convenient
1998alternative to Exim's own checking facilities for installations that are
1999already making use of \*tcpwrappers*\ for other purposes. To do this, you should
2000set \\USE@_TCP@_WRAPPERS\\ in \(Local/Makefile)\, arrange for the file
2001\(tcpd.h)\ to be available at compile time, and also ensure that the library
2002\(libwrap.a)\ is available at link time, typically by including \-lwrap-\ in
2003\\EXTRALIBS@_EXIM\\. For example, if \*tcpwrappers*\ is installed in
2004\(/usr/local)\, you might have
2005.display
2006USE@_TCP@_WRAPPERS=yes
2007CFLAGS=-O -I/usr/local/include
2008.newline
2009EXTRALIBS@_EXIM=-L/usr/local/lib -lwrap
2010.endd
2011in \(Local/Makefile)\. The name to use in the \*tcpwrappers*\ control files is
2012`exim'. For example, the line
2013.display
2014exim : LOCAL 192.168.1. .friendly.domain.example
2015.endd
2016in your \(/etc/hosts.allow)\ file allows connections from the local host, from
2017the subnet 192.168.1.0/24, and from all hosts in \*friendly.domain.example*\.
2018All other connections are denied. Consult the \*tcpwrappers*\ documentation for
2019further details.
2020
2021
2022.section Including support for IPv6
2023.index IPv6||including support for
2024Exim contains code for use on systems that have IPv6 support. Setting
2025\\HAVE@_IPV6=YES\\ in \(Local/Makefile)\ causes the IPv6 code to be included;
2026it may also be necessary to set \\IPV6@_INCLUDE\\ and \\IPV6@_LIBS\\ on systems
2027where the IPv6 support is not fully integrated into the normal include and
2028library files.
2029
2030IPv6 is still changing rapidly. Two different types of DNS record for handling
2031IPv6 addresses have been defined. AAAA records are already in use, and are
2032currently seen as the `mainstream', but another record type called A6 is being
2033argued about. Its status is currently `experimental'. Exim has support for A6
2034records, but this is included only if you set \\SUPPORT@_A6=YES\\ in
2035\(Local/Makefile)\.
2036
2037
2038.section The building process
2039.index build directory
2040Once \(Local/Makefile)\ (and \(Local/eximon.conf)\, if required) have been
2041created, run \*make*\ at the top level. It determines the architecture and
2042operating system types, and creates a build directory if one does not exist.
2043For example, on a Sun system running Solaris 8, the directory
2044\(build-SunOS5-5.8-sparc)\ is created.
2045.index symbolic link||to source files
2046Symbolic links to relevant source files are installed in the build directory.
2047
2048.em
2049\**Warning**\: The \-j-\ (parallel) flag must not be used with \*make*\; the
2050building process fails if it is set.
2051.nem
2052
2053If this is the first time \*make*\ has been run, it calls a script that builds
2054a make file inside the build directory, using the configuration files from the
2055\(Local)\ directory. The new make file is then passed to another instance of
2056\*make*\. This does the real work, building a number of utility scripts, and
2057then compiling and linking the binaries for the Exim monitor (if configured), a
2058number of utility programs, and finally Exim itself. The command \*make
2059makefile*\ can be used to force a rebuild of the make file in the build
2060directory, should this ever be necessary.
2061
2062If you have problems building Exim, check for any comments there may be in the
2063\(README)\ file concerning your operating system, and also take a look at the
2064.if ~~html
2065[(A HREF="FAQ.html")]
2066.fi
2067FAQ,
2068.if ~~html
2069[(/A)]
2070.fi
2071where some common problems are covered.
2072
2073
2074
2075.section Overriding build-time options for Exim
2076.index build-time options, overriding
2077.rset SECToverride "~~chapter.~~section"
2078The main make file that is created at the beginning of the building process
2079consists of the concatenation of a number of files which set configuration
2080values, followed by a fixed set of \*make*\ instructions. If a value is set
2081more than once, the last setting overrides any previous ones. This provides a
2082convenient way of overriding defaults. The files that are concatenated are, in
2083order:
2084.display rm
2085\(OS/Makefile-Default)\
2086\(OS/Makefile-)\<<ostype>>
2087\(Local/Makefile)\
2088\(Local/Makefile-)\<<ostype>>
2089\(Local/Makefile-)\<<archtype>>
2090\(Local/Makefile-)\<<ostype>>-<<archtype>>
2091\(OS/Makefile-Base)\
2092.endd
2093.index \(Local/Makefile)\
2094where <<ostype>> is the operating system type and <<archtype>> is the
2095.index building Exim||operating system type
2096.index building Exim||architecture type
2097architecture type. \(Local/Makefile)\ is required to exist, and the building
2098process fails if it is absent. The other three \(Local)\ files are optional,
2099and are often not needed.
2100
2101The values used for <<ostype>> and <<archtype>> are obtained from scripts
2102called \(scripts/os-type)\ and \(scripts/arch-type)\ respectively. If either of
2103the environment variables \\EXIM@_OSTYPE\\ or \\EXIM@_ARCHTYPE\\ is set, their
2104values are used, thereby providing a means of forcing particular settings.
2105Otherwise, the scripts try to get values from the \uname\ command. If this
2106fails, the shell variables \\OSTYPE\\ and \\ARCHTYPE\\ are inspected. A number
2107of $it{ad hoc} transformations are then applied, to produce the standard names
2108that Exim expects. You can run these scripts directly from the shell in order
2109to find out what values are being used on your system.
2110
2111
2112\(OS/Makefile-Default)\ contains comments about the variables that are set
2113therein. Some (but not all) are mentioned below. If there is something that
2114needs changing, review the contents of this file and the contents of the make
2115file for your operating system (\(OS/Makefile-<<ostype>>)\) to see what the
2116default values are.
2117
2118
2119.index building Exim||overriding default settings
2120If you need to change any of the values that are set in \(OS/Makefile-Default)\
2121or in \(OS/Makefile-<<ostype>>)\, or to add any new definitions, you do not
2122need to change the original files. Instead, you should make the changes by
2123putting the new values in an appropriate \(Local)\ file. For example,
2124.index Tru64-Unix build-time settings
2125when building Exim in many releases of the Tru64-Unix (formerly Digital UNIX,
2126formerly DEC-OSF1) operating system, it is necessary to specify that the C
2127compiler is called \*cc*\ rather than \*gcc*\. Also, the compiler must be
2128called with the option \-std1-\, to make it recognize some of the features of
2129Standard C that Exim uses. (Most other compilers recognize Standard C by
2130default.) To do this, you should create a file called \(Local/Makefile-OSF1)\
2131containing the lines
2132.display
2133CC=cc
2134CFLAGS=-std1
2135.endd
2136If you are compiling for just one operating system, it may be easier to put
2137these lines directly into \(Local/Makefile)\.
2138
2139Keeping all your local configuration settings separate from the distributed
2140files makes it easy to transfer them to new versions of Exim simply by copying
2141the contents of the \(Local)\ directory.
2142
2143
2144.index NIS lookup type||including support for
2145.index NIS@+ lookup type||including support for
2146.index LDAP||including support for
2147.index lookup||inclusion in binary
2148Exim contains support for doing LDAP, NIS, NIS+, and other kinds of file
2149lookup, but not all systems have these components installed, so the default is
2150not to include the relevant code in the binary. All the different kinds of file
2151and database lookup that Exim supports are implemented as separate code modules
2152which are included only if the relevant compile-time options are set. In the
2153case of LDAP, NIS, and NIS+, the settings for \(Local/Makefile)\ are:
2154.display asis
2155LOOKUP_LDAP=yes
2156LOOKUP_NIS=yes
2157LOOKUP_NISPLUS=yes
2158.endd
2159and similar settings apply to the other lookup types. They are all listed in
2160\(src/EDITME)\. In most cases the relevant include files and interface
2161libraries need to be installed before compiling Exim.
2162.index cdb||including support for
2163However, in the case of cdb, which is included in the binary only if
2164.display asis
2165LOOKUP_CDB=yes
2166.endd
2167is set, the code is entirely contained within Exim, and no external include
2168files or libraries are required. When a lookup type is not included in the
2169binary, attempts to configure Exim to use it cause run time configuration
2170errors.
2171
2172.index Perl||including support for
2173Exim can be linked with an embedded Perl interpreter, allowing Perl
2174subroutines to be called during string expansion. To enable this facility,
2175.display asis
2176EXIM_PERL=perl.o
2177.endd
2178must be defined in \(Local/Makefile)\. Details of this facility are given in
2179chapter ~~CHAPperl.
2180
2181.index X11 libraries, location of
2182The location of the X11 libraries is something that varies a lot between
2183operating systems, and of course there are different versions of X11 to cope
2184with. Exim itself makes no use of X11, but if you are compiling the Exim
2185monitor, the X11 libraries must be available.
2186The following three variables are set in \(OS/Makefile-Default)\:
2187.display asis
2188X11=/usr/X11R6
2189XINCLUDE=-I$(X11)/include
2190XLFLAGS=-L$(X11)/lib
2191.endd
2192These are overridden in some of the operating-system configuration files. For
2193example, in \(OS/Makefile-SunOS5)\ there is
2194.display asis
2195X11=/usr/openwin
2196XINCLUDE=-I$(X11)/include
2197XLFLAGS=-L$(X11)/lib -R$(X11)/lib
2198.endd
2199If you need to override the default setting for your operating system, place a
2200definition of all three of these variables into your
2201\(Local/Makefile-<<ostype>>)\ file.
2202
2203.index \\EXTRALIBS\\
2204If you need to add any extra libraries to the link steps, these can be put in a
2205variable called \\EXTRALIBS\\, which appears in all the link commands, but by
2206default is not defined. In contrast, \\EXTRALIBS@_EXIM\\ is used only on the
2207command for linking the main Exim binary, and not for any associated utilities.
2208.index DBM||libraries, configuration for building
2209There is also \\DBMLIB\\, which appears in the link commands for binaries that
2210use DBM functions (see also section ~~SECTdb). Finally, there is
2211\\EXTRALIBS@_EXIMON\\, which appears only in the link step for the Exim monitor
2212binary, and which can be used, for example, to include additional X11
2213libraries.
2214
2215.index configuration file||editing
2216The make file copes with rebuilding Exim correctly if any of the configuration
2217files are edited. However, if an optional configuration file is deleted, it is
2218necessary to touch the associated non-optional file (that is, \(Local/Makefile)\
2219or \(Local/eximon.conf)\) before rebuilding.
2220
2221.section OS-specific header files
2222.index \(os.h)\
2223.index building Exim||OS-specific C header files
2224The \(OS)\ directory contains a number of files with names of the form
2225\(os.h-<<ostype>>)\. These are system-specific C header files that should not
2226normally need to be changed. There is a list of macro settings that are
2227recognized in the file \(OS/os.configuring)\, which should be consulted if you
2228are porting Exim to a new operating system.
2229
2230
2231.section Overriding build-time options for the monitor
2232.index building Eximon||overriding default options
2233A similar process is used for overriding things when building the Exim monitor,
2234where the files that are involved are
2235.display rm
2236\(OS/eximon.conf-Default)\
2237\(OS/eximon.conf-)\<<ostype>>
2238\(Local/eximon.conf)\
2239\(Local/eximon.conf-)\<<ostype>>
2240\(Local/eximon.conf-)\<<archtype>>
2241\(Local/eximon.conf-)\<<ostype>>-<<archtype>>
2242.endd
2243.index \(Local/eximon.conf)\
2244As with Exim itself, the final three files need not exist, and in this case the
2245\(OS/eximon.conf-<<ostype>>)\ file is also optional. The default values in
2246\(OS/eximon.conf-Default)\ can be overridden dynamically by setting environment
2247variables of the same name, preceded by \\EXIMON@_\\. For example, setting
2248\\EXIMON@_LOG@_DEPTH\\ in the environment overrides the value of
2249\\LOG@_DEPTH\\ at run time.
2250
2251
2252
2253.section Installing Exim binaries and scripts
2254.index installing Exim
2255.index \\BIN@_DIRECTORY\\
2256The command \*make install*\ runs the \*exim@_install*\ script with no
2257arguments. The script copies binaries and utility scripts into the directory
2258whose name is specified by the \\BIN@_DIRECTORY\\ setting in
2259\(Local/Makefile)\.
2260
2261Exim's run time configuration file is named by the \\CONFIGURE@_FILE\\ setting
2262.index \\CONFIGURE@_FILE\\
2263in \(Local/Makefile)\. If this names a single file, and the file does not
2264exist, the default configuration file \(src/configure.default)\ is copied there
2265by the installation script. If a run time configuration file already exists, it
2266is left alone. If \\CONFIGURE@_FILE\\ is a colon-separated list, naming several
2267alternative files, no default is installed.
2268
2269.index system aliases file
2270.index \(/etc/aliases)\
2271One change is made to the default configuration file when it is installed: the
2272default configuration contains a router that references a system aliases file.
2273The path to this file is set to the value specified by
2274\\SYSTEM@_ALIASES@_FILE\\ in \(Local/Makefile)\ (\(/etc/aliases)\ by default).
2275If the system aliases file does not exist, the installation script creates it,
2276and outputs a comment to the user.
2277
2278The created file contains no aliases, but it does contain comments about the
2279aliases a site should normally have. Mail aliases have traditionally been
2280kept in \(/etc/aliases)\. However, some operating systems are now using
2281\(/etc/mail/aliases)\. You should check if yours is one of these, and change
2282Exim's configuration if necessary.
2283
2284The default configuration uses the local host's name as the only local domain,
2285and is set up to do local deliveries into the shared directory \(/var/mail)\,
2286running as the local user. System aliases and \(.forward)\ files in users' home
2287directories are supported, but no NIS or NIS+ support is configured. Domains
2288other than the name of the local host are routed using the DNS, with delivery
2289over SMTP.
2290
2291The install script copies files only if they are newer than the files they are
2292going to replace. The Exim binary is required to be owned by root and have the
2293\*setuid*\ bit set,
2294.index setuid||installing Exim with
2295for normal configurations. Therefore, you must run \*make install*\ as root so
2296that it can set up the Exim binary in this way. However, in some special
2297situations (for example, if a host is doing no local deliveries) it may be
2298possible to run Exim without making the binary setuid root (see chapter
2299~~CHAPsecurity for details).
2300
2301It is possible to install Exim for special purposes (such as building a binary
2302distribution) in a private part of the file system. You can do this by a
2303command such as
2304.display asis
2305make DESTDIR=/some/directory/ install
2306.endd
2307This has the effect of pre-pending the specified directory to all the file
2308paths, except the name of the system aliases file that appears in the default
2309configuration. (If a default alias file is created, its name \*is*\ modified.)
2310For backwards compatibility, \\ROOT\\ is used if \\DESTDIR\\ is not set,
2311but this usage is deprecated.
2312
2313.index installing Exim||what is not installed
2314Running \*make install*\ does not copy the Exim 4 conversion script
2315\*convert4r4*\, or the \*pcretest*\ test program. You will probably run the
2316first of these only once (if you are upgrading from Exim 3), and the second
2317isn't really part of Exim. None of the documentation files in the \(doc)\
2318directory are copied, except for the info files when you have set
2319\\INFO@_DIRECTORY\\, as described in section ~~SECTinsinfdoc below.
2320
2321For the utility programs, old versions are renamed by adding the suffix \(.O)\
2322to their names. The Exim binary itself, however, is handled differently. It is
2323installed under a name that includes the version number and the compile number,
2324for example \(exim-~~version-1)\. The script then arranges for a symbolic link
2325called \(exim)\ to point to the binary. If you are updating a previous version
2326of Exim, the script takes care to ensure that the name \(exim)\ is never absent
2327from the directory (as seen by other processes).
2328
2329.index installing Exim||testing the script
2330If you want to see what the \*make install*\ will do before running it for
2331real, you can pass the \-n-\ option to the installation script by this command:
2332.display asis
2333make INSTALL_ARG=-n install
2334.endd
2335The contents of the variable \\INSTALL@_ARG\\ are passed to the installation
2336script. You do not need to be root to run this test. Alternatively, you can run
2337the installation script directly, but this must be from within the build
2338directory. For example, from the top-level Exim directory you could use this
2339command:
2340.display
2341(cd build-SunOS5-5.5.1-sparc; ../scripts/exim@_install -n)
2342.endd
2343
2344.index installing Exim||install script options
2345There are two other options that can be supplied to the installation script.
2346.numberpars $.
2347\-no@_chown-\ bypasses the call to change the owner of the installed binary
2348to root, and the call to make it a setuid binary.
2349.nextp
2350\-no@_symlink-\ bypasses the setting up of the symbolic link \(exim)\ to the
2351installed binary.
2352.endp
2353\\INSTALL@_ARG\\ can be used to pass these options to the script. For example:
2354.display asis
2355make INSTALL_ARG=-no_symlink install
2356.endd
2357
2358The installation script can also be given arguments specifying which files are
2359to be copied. For example, to install just the Exim binary, and nothing else,
2360without creating the symbolic link, you could use:
2361.display asis
2362make INSTALL_ARG='-no_symlink exim' install
2363.endd
2364
2365
2366.section Installing info documentation
2367.rset SECTinsinfdoc "~~chapter.~~section"
2368.index installing Exim||\*info*\ documentation
2369Not all systems use the GNU \*info*\ system for documentation, and for this
2370reason, the Texinfo source of Exim's documentation is not included in the main
2371distribution. Instead it is available separately from the ftp site (see section
2372~~SECTavail).
2373
2374If you have defined \\INFO@_DIRECTORY\\ in \(Local/Makefile)\ and the Texinfo
2375source of the documentation is found in the source tree, running \*make
2376install*\ automatically builds the info files and installs them.
2377
2378
2379.section Setting up the spool directory
2380.index spool directory||creating
2381When it starts up, Exim tries to create its spool directory if it does not
2382exist. The Exim uid and gid are used for the owner and group of the spool
2383directory. Sub-directories are automatically created in the spool directory as
2384necessary.
2385
2386
2387
2388.section Testing
2389.index testing||installation
2390Having installed Exim, you can check that the run time configuration file is
2391syntactically valid by running the following command, which assumes that the
2392Exim binary directory is within your \\PATH\\ environment variable:
2393.display
2394exim -bV
2395.endd
2396If there are any errors in the configuration file, Exim outputs error messages.
2397Otherwise it outputs the version number and build date,
2398the DBM library that is being used, and information about which drivers and
2399other optional code modules are included in the binary.
2400Some simple routing tests can be done by using the address testing option. For
2401example,
2402.display
2403exim -bt <<local username>>
2404.endd
2405should verify that it recognizes a local mailbox, and
2406.display
2407exim -bt <<remote address>>
2408.endd
2409a remote one. Then try getting it to deliver mail, both locally and remotely.
2410This can be done by passing messages directly to Exim, without going through a
2411user agent. For example:
2412.display
2413exim -v postmaster@@your.domain.example
2414From: user@@your.domain.example
2415To: postmaster@@your.domain.example
2416Subject: Testing Exim
2417
2418This is a test message.
2419^D
2420.endd
2421The \-v-\ option causes Exim to output some verification of what it is doing.
2422In this case you should see copies of three log lines, one for the message's
2423arrival, one for its delivery, and one containing `Completed'.
2424
2425.index delivery||problems with
2426If you encounter problems, look at Exim's log files (\*mainlog*\ and
2427\*paniclog*\) to see if there is any relevant information there. Another source
2428of information is running Exim with debugging turned on, by specifying the
2429\-d-\ option. If a message is stuck on Exim's spool, you can force a delivery
2430with debugging turned on by a command of the form
2431.display
2432exim -d -M <<message-id>>
2433.endd
2434You must be root or an `admin user' in order to do this. The \-d-\ option
2435produces rather a lot of output, but you can cut this down to specific areas.
2436For example, if you use \-d-all+route-\ only the debugging information relevant
2437to routing is included. (See the \-d-\ option in chapter ~~CHAPcommandline for
2438more details.)
2439
2440.index `sticky' bit
2441.index lock files
2442One specific problem that has shown up on some sites is the inability to do
2443local deliveries into a shared mailbox directory, because it does not have the
2444`sticky bit' set on it. By default, Exim tries to create a lock file before
2445writing to a mailbox file, and if it cannot create the lock file, the delivery
2446is deferred. You can get round this either by setting the `sticky bit' on the
2447directory, or by setting a specific group for local deliveries and allowing
2448that group to create files in the directory (see the comments above the
2449\%local@_delivery%\ transport in the default configuration file). Another
2450approach is to configure Exim not to use lock files, but just to rely on
2451\*fcntl()*\ locking instead. However, you should do this only if all user
2452agents also use \*fcntl()*\ locking. For further discussion of locking issues,
2453see chapter ~~CHAPappendfile.
2454
2455One thing that cannot be tested on a system that is already running an MTA is
2456the receipt of incoming SMTP mail on the standard SMTP port. However, the
2457\-oX-\ option can be used to run an Exim daemon that listens on some other
2458port, or \*inetd*\ can be used to do this. The \-bh-\ option and the
2459\*exim@_checkaccess*\ utility can be used to check out policy controls on
2460incoming SMTP mail.
2461
2462Testing a new version on a system that is already running Exim can most easily
2463be done by building a binary with a different \\CONFIGURE@_FILE\\ setting. From
2464within the run time configuration, all other file and directory names
2465that Exim uses can be altered, in order to keep it entirely clear of the
2466production version.
2467
2468.section Replacing another MTA with Exim
2469.index replacing another MTA
2470Building and installing Exim for the first time does not of itself put it in
2471general use. The name by which the system's MTA is called by mail user agents
2472is either \(/usr/sbin/sendmail)\, or \(/usr/lib/sendmail)\ (depending on the
2473operating system), and it is necessary to make this name point to the \*exim*\
2474binary in order to get the user agents to pass messages to Exim. This is
2475normally done by renaming any existing file and making \(/usr/sbin/sendmail)\
2476or \(/usr/lib/sendmail)\
2477.index symbolic link||to \*exim*\ binary
2478a symbolic link to the \*exim*\ binary. It is a good idea to remove any setuid
2479privilege and executable status from the old MTA. It is then necessary to stop
2480and restart the mailer daemon, if one is running.
2481
2482.index FreeBSD, MTA indirection
2483.index \(/etc/mail/mailer.conf)\
2484Some operating systems have introduced alternative ways of switching MTAs. For
2485example, if you are running FreeBSD, you need to edit the file
2486\(/etc/mail/mailer.conf)\ instead of setting up a symbolic link as just
2487described. A typical example of the contents of this file for running Exim is
2488as follows:
2489.display asis
2490sendmail /usr/exim/bin/exim
2491send-mail /usr/exim/bin/exim
2492mailq /usr/exim/bin/exim -bp
2493newaliases /usr/bin/true
2494.endd
2495
2496Once you have set up the symbolic link, or edited \(/etc/mail/mailer.conf)\,
2497your Exim installation is `live'. Check it by sending a message from your
2498favourite user agent.
2499
2500You should consider what to tell your users about the change of MTA. Exim may
2501have different capabilities to what was previously running, and there are
2502various operational differences such as the text of messages produced by
2503command line options and in bounce messages. If you allow your users to make
2504use of Exim's filtering capabilities, you should make the document entitled
2505.if ~~html
2506[(A HREF="filter.html")]
2507.fi
2508\*Exim's interface to mail filtering*\
2509.if ~~html
2510[(/A)]
2511.fi
2512available to them.
2513
2514
2515.section Upgrading Exim
2516.index upgrading Exim
2517If you are already running Exim on your host, building and installing a new
2518version automatically makes it available to MUAs, or any other programs that
2519call the MTA directly. However, if you are running an Exim daemon, you do need
2520to send it a HUP signal, to make it re-exec itself, and thereby pick up the new
2521binary. You do not need to stop processing mail in order to install a new
2522version of Exim.
2523
2524
2525.section Stopping the Exim daemon on Solaris
2526.index Solaris||stopping Exim on
2527The standard command for stopping the mailer daemon on Solaris is
2528.display
2529/etc/init.d/sendmail stop
2530.endd
2531If \(/usr/lib/sendmail)\ has been turned into a symbolic link, this script
2532fails to stop Exim because it uses the command \*ps -e*\ and greps the output
2533for the text `sendmail'; this is not present because the actual program name
2534(that is, `exim') is given by the \*ps*\ command with these options. A solution
2535is to replace the line that finds the process id with something like
2536.display asis
2537pid=`cat /var/spool/exim/exim-daemon.pid`
2538.endd
2539to obtain the daemon's pid directly from the file that Exim saves it in.
2540
2541Note, however, that stopping the daemon does not `stop Exim'. Messages can
2542still be received from local processes, and if automatic delivery is configured
2543(the normal case), deliveries will still occur.
2544
2545
2546.
2547.
2548.
2549.
2550. ============================================================================
2551.chapter The Exim command line
2552.set runningfoot "command line"
2553.rset CHAPcommandline ~~chapter
2554.index command line||options
2555.index options||command line
2556
2557Exim's command line takes the standard Unix form of a sequence of options,
2558each starting with a hyphen character, followed by a number of arguments. The
2559options are compatible with the main options of Sendmail, and there are also
2560some additional options, some of which are compatible with Smail 3. Certain
2561combinations of options do not make sense, and provoke an error if used.
2562The form of the arguments depends on which options are set.
2563
2564.section Setting options by program name
2565.index \*mailq*\
2566If Exim is called under the name \*mailq*\, it behaves as if the option \-bp-\
2567were present before any other options.
2568The \-bp-\ option requests a listing of the contents of the mail queue on the
2569standard output.
2570This feature is for compatibility with some systems that contain a command of
2571that name in one of the standard libraries, symbolically linked to
2572\(/usr/sbin/sendmail)\ or \(/usr/lib/sendmail)\.
2573
2574.index \*rsmtp*\
2575If Exim is called under the name \*rsmtp*\ it behaves as if the option \-bS-\
2576were present before any other options, for compatibility with Smail. The \-bS-\
2577option is used for reading in a number of messages in batched SMTP format.
2578
2579.index \*rmail*\
2580If Exim is called under the name \*rmail*\ it behaves as if the \-i-\ and
2581\-oee-\ options were present before any other options, for compatibility with
2582Smail. The name \*rmail*\ is used as an interface by some UUCP systems.
2583
2584.index \*runq*\
2585.index queue runner
2586If Exim is called under the name \*runq*\ it behaves as if the option \-q-\ were
2587present before any other options, for compatibility with Smail. The \-q-\
2588option causes a single queue runner process to be started.
2589
2590.index \*newaliases*\
2591.index alias file||building
2592.index Sendmail compatibility||calling Exim as \*newaliases*\
2593If Exim is called under the name \*newaliases*\ it behaves as if the option
2594\-bi-\ were present before any other options, for compatibility with Sendmail.
2595This option is used for rebuilding Sendmail's alias file. Exim does not have
2596the concept of a single alias file, but can be configured to run a given
2597command if called with the \-bi-\ option.
2598
2599.section Trusted and admin users
2600.rset SECTtrustedadmin "~~chapter.~~section"
2601Some Exim options are available only to \*trusted users*\ and others are
2602available only to \*admin users*\. In the description below, the phrases `Exim
2603user' and `Exim group' mean the user and group defined by \\EXIM@_USER\\ and
2604\\EXIM@_GROUP\\ in \(Local/Makefile)\ or set by the \exim@_user\ and
2605\exim@_group\ options. These do not necessarily have to use the name `exim'.
2606
2607.numberpars $.
2608.index trusted user||definition of
2609.index user||trusted, definition of
2610The trusted users are root, the Exim user, any user listed in the
2611\trusted@_users\ configuration option, and any user whose current group or any
2612supplementary group is one of those listed in the \trusted@_groups\
2613configuration option. Note that the Exim group is not automatically trusted.
2614
2615.index `From' line
2616.index envelope sender
2617Trusted users are always permitted to use the \-f-\ option or a leading `From '
2618line to specify the envelope sender of a message that is passed to Exim through
2619the local interface (see the \-bm-\ and \-f-\ options below). See the
2620\untrusted@_set@_sender\ option for a way of permitting non-trusted users to
2621set envelope senders.
2622.index ::From:: header line
2623.index ::Sender:: header line
2624For a trusted user, there is never any check on the contents of the ::From::
2625header line, and a ::Sender:: line is never added. Furthermore, any existing
2626::Sender:: line in incoming local (non-TCP/IP) messages is not removed.
2627
2628Trusted users may also specify a host name, host address, interface address,
2629protocol name, ident value, and authentication data when submitting a message
2630locally. Thus, they are able to insert messages into Exim's queue locally that
2631have the characteristics of messages received from a remote host. Untrusted
2632users may in some circumstances use \-f-\, but can never set the other values
2633that are available to trusted users.
2634.nextp
2635.index user||admin, definition of
2636.index admin user||definition of
2637The admin users are root, the Exim user, and any user that is a member of the
2638Exim group or of any group listed in the \admin@_groups\ configuration option.
2639The current group does not have to be one of these groups.
2640
2641Admin users are permitted to list the queue, and to carry out certain
2642operations on messages, for example, to force delivery failures. It is also
2643necessary to be an admin user in order to see the full information provided by
2644the Exim monitor, and full debugging output.
2645
2646By default, the use of the \-M-\, \-q-\, \-R-\, and \-S-\ options to cause Exim
2647to attempt delivery of messages on its queue is restricted to admin users.
2648However, this restriction can be relaxed by setting the \prod@_requires@_admin\
2649option false (that is, specifying \no@_prod@_requires@_admin\).
2650
2651Similarly, the use of the \-bp-\ option to list all the messages in the queue
2652is restricted to admin users unless \queue@_list@_requires@_admin\ is set
2653false.
2654.endp
2655
2656\**Warning**\: If you configure your system so that admin users are able to
2657edit Exim's configuration file, you are giving those users an easy way of
2658getting root. There is further discussion of this issue at the start of chapter
2659~~CHAPconf.
2660
2661
2662
2663.section Command line options
2664The command options are described in alphabetical order below.
2665
2666.startoptions
2667
2668.option @-
2669.index options||command line, terminating
2670This is a pseudo-option whose only purpose is to terminate the options and
2671therefore to cause subsequent command line items to be treated as arguments
2672rather than options, even if they begin with hyphens.
2673
2674.option -help
2675This option causes Exim to output a few sentences stating what it is.
2676The same output is generated if the Exim binary is called with no options and
2677no arguments.
2678
2679.option B <<type>>
2680.index 8-bit characters
2681.index Sendmail compatibility||8-bit characters
2682This is a Sendmail option for selecting 7 or 8 bit processing. Exim is 8-bit
2683clean; it ignores this option.
2684
2685.option bd
2686.index daemon
2687.index SMTP listener
2688.index queue runner
2689This option runs Exim as a daemon, awaiting incoming SMTP connections. Usually
2690the \-bd-\ option is combined with the \-q-\<<time>> option, to specify that
2691the daemon should also initiate periodic queue runs.
2692
2693The \-bd-\ option can be used only by an admin user. If either of the \-d-\
2694(debugging) or \-v-\ (verifying) options are set, the daemon does not
2695disconnect from the controlling terminal. When running this way, it can be
2696stopped by pressing ctrl-C.
2697
2698By default, Exim listens for incoming connections to the standard SMTP port on
2699all the host's running interfaces. However, it is possible to listen on other
2700ports, on multiple ports, and only on specific interfaces. Chapter
2701~~CHAPinterfaces contains a description of the options that control this.
2702
2703.index daemon||process id (pid)
2704.index pid (process id)||of daemon
2705When a listening daemon is started without the use of \-oX-\ (that is, without
2706overriding the normal configuration), it writes its process id to a file called
2707\(exim-daemon.pid)\ in Exim's spool directory. This location can be overridden
2708by setting \\PID@_FILE@_PATH\\ in \(Local/Makefile)\. The file is written while
2709Exim is still running as root.
2710
2711When \-oX-\ is used on the command line to start a listening daemon, the
2712process id is not written to the normal pid file path. However, \-oP-\ can be
2713used to specify a path on the command line if a pid file is required.
2714
2715.index \\SIGHUP\\
2716The \\SIGHUP\\ signal can be used to cause the daemon to re-exec itself. This
2717should be done whenever Exim's configuration file, or any file that is
2718incorporated into it by means of the \.include\ facility, is changed, and also
2719whenever a new version of Exim is installed. It is not necessary to do this
2720when other files that are referenced from the configuration (for example, alias
2721files) are changed, because these are reread each time they are used.
2722
2723.option bdf
2724This option has the same effect as \-bd-\ except that it never disconnects from
2725the controlling terminal, even when no debugging is specified.
2726
2727.option be
2728.index testing||string expansion
2729.index expansion||testing
2730Run Exim in expansion testing mode. Exim discards its root privilege, to
2731prevent ordinary users from using this mode to read otherwise inaccessible
2732files. If no arguments are given, Exim runs interactively, prompting for lines
2733of data. Long expressions can be split over several lines by using backslash
2734continuations.
2735As in Exim's run time configuration, whitespace at the start of continuation
2736lines is ignored.
2737
2738Each argument or data line is passed through the string expansion mechanism,
2739and the result is output. Variable values from the configuration file (for
2740example, \$qualify@_domain$\) are available, but no message-specific values
2741(such as \$domain$\) are set, because no message is being processed.
2742
2743.option bF #<<filename>>
2744.index system filter||testing
2745.index testing||system filter
2746This option is the same as \-bf-\ except that it assumes that the filter being
2747tested is a system filter. The additional commands that are available only in
2748system filters are recognized.
2749
2750.option bf #<<filename>>
2751.index filter||testing
2752.index testing||filter file
2753.index forward file||testing
2754.index testing||forward file
2755.index Sieve filter||testing
2756This option runs Exim in filter testing mode; the file is the filter file to be
2757tested, and a test message must be supplied on the standard input. If there are
2758no message-dependent tests in the filter, an empty file can be supplied. If a
2759system filter file is being tested, \-bF-\ should be used instead of \-bf-\. If
2760the test file does not begin with
2761one of the special lines
2762.display asis
2763# Exim filter
2764# Sieve filter
2765.endd
2766it is taken to be a normal \(.forward)\ file, and is tested for validity under
2767that interpretation. See sections ~~SECTitenonfilred to ~~SECTspecitredli for a
2768description of the possible contents of non-filter redirection lists.
2769
2770The result of an Exim command that uses \-bf-\, provided no errors are
2771detected, is a list of the actions that Exim would try to take if presented
2772with the message for real. More details of filter testing are given in the
2773separate document entitled \*Exim's interfaces to mail filtering*\.
2774
2775.index `From' line
2776.index envelope sender
2777.index \-f-\ option||for filter testing
2778When testing a filter file, the envelope sender can be set by the \-f-\ option,
2779or by a `From ' line at the start of the test message. Various parameters that
2780would normally be taken from the envelope recipient address of the message can
2781be set by means of additional command line options. These are:
2782.display rm
2783.if ~~sys.fancy
2784.tabset 12em 16em
2785.else
2786.tabset 15em 20em
2787.fi
2788. The odd alignment here gets it lined up in the man page.
2789\-bfd-\ $t <<domain>> $t $rm{default is the qualify domain}
2790\-bfl-\ $t <<local@_part>> $t $rm{default is the logged in user}
2791\-bfp-\ $t <<local@_part@_prefix>> $t $rm{default is null}
2792\-bfs-\ $t <<local@_part@_suffix>> $t $rm{default is null}
2793.endd
2794The local part should always be set to the incoming address with any prefix or
2795suffix stripped, because that is how it appears to the filter when a message is
2796actually being delivered.
2797
2798.option bh #<<IP address>>
2799.index testing||incoming SMTP
2800.index SMTP||testing incoming
2801.index testing||relay control
2802.index relaying||testing configuration
2803.index policy control||testing
2804.index debugging||\-bh-\ option
2805This option runs a fake SMTP session as if from the given IP address, using the
2806standard input and output. The IP address may include a port number at the end,
2807after a full stop. For example:
2808.display asis
2809exim -bh 10.9.8.7.1234
2810exim -bh fe80::a00:20ff:fe86:a061.5678
2811.endd
2812Comments as to what is going on are written to the standard error file. These
2813include lines beginning with `LOG' for anything that would have been logged.
2814This facility is provided for testing configuration options for incoming
2815messages, to make sure they implement the required policy. For example, you can
2816test your relay controls using \-bh-\.
2817
2818.index RFC 1413
2819\**Warning 1**\: You cannot test features of the configuration that rely on
2820ident (RFC 1413) callouts. These cannot be done when testing using
2821\-bh-\ because there is no incoming SMTP connection.
2822
2823\**Warning 2**\: Address verification callouts (see section ~~SECTcallver) are
2824also skipped when testing using \-bh-\. If you want these callouts to occur,
2825use \-bhc-\ instead.
2826
2827Messages supplied during the testing session are discarded, and nothing is
2828written to any of the real log files. There may be pauses when DNS (and other)
2829lookups are taking place, and of course these may time out. The \-oMi-\ option
2830can be used to specify a specific IP interface and port if this is important.
2831
2832The \*exim@_checkaccess*\ utility is a `packaged' version of \-bh-\ whose
2833output just states whether a given recipient address from a given host is
2834acceptable or not. See section ~~SECTcheckaccess.
2835
2836.option bhc #<<IP address>>
2837This option operates in the same way as \-bh-\, except that address
2838verification callouts are performed if required. This includes consulting and
2839updating the callout cache database.
2840
2841.option bi
2842.index alias file||building
2843.index building alias file
2844.index Sendmail compatibility||\-bi-\ option
2845Sendmail interprets the \-bi-\ option as a request to rebuild its alias file.
2846Exim does not have the concept of a single alias file, and so it cannot mimic
2847this behaviour. However, calls to \(/usr/lib/sendmail)\ with the \-bi-\ option
2848tend to appear in various scripts such as NIS make files, so the option must be
2849recognized.
2850
2851If \-bi-\ is encountered, the command specified by the \bi@_command\
2852configuration option is run, under the uid and gid of the caller of Exim. If
2853the \-oA-\ option is used, its value is passed to the command as an argument.
2854The command set by \bi@_command\ may not contain arguments. The command can use
2855the \*exim@_dbmbuild*\ utility, or some other means, to rebuild alias files if
2856this is required. If the \bi@_command\ option is not set, calling Exim with
2857\-bi-\ is a no-op.
2858
2859.option bm
2860.index local message reception
2861This option runs an Exim receiving process that accepts an incoming,
2862locally-generated message on the current input. The recipients are given as the
2863command arguments (except when \-t-\ is also present -- see below). Each
2864argument can be a comma-separated list of RFC 2822 addresses. This is the
2865default option for selecting the overall action of an Exim call; it is assumed
2866if no other conflicting option is present.
2867
2868If any addresses in the message are unqualified (have no domain), they are
2869qualified by the values of the \qualify@_domain\ or \qualify@_recipient\
2870options, as appropriate. The \-bnq-\ option (see below) provides a way of
2871suppressing this for special cases.
2872
2873Policy checks on the contents of local messages can be enforced by means of the
2874non-SMTP ACL. See chapter ~~CHAPACL for details.
2875.index return code||for \-bm-\
2876The return code is zero if the message is successfully accepted. Otherwise, the
2877action is controlled by the \-oe$it{x}-\ option setting -- see below.
2878
2879.index message||format
2880.index format||message
2881.index `From' line
2882.index UUCP||`From' line
2883.index Sendmail compatibility||`From' line
2884The format of the message must be as defined in RFC 2822, except that, for
2885compatibility with Sendmail and Smail, a line in one of the forms
2886.display
2887From sender Fri Jan 5 12:55 GMT 1997
2888From sender Fri, 5 Jan 97 12:55:01
2889.endd
2890(with the weekday optional, and possibly with additional text after the date)
2891is permitted to appear at the start of the message. There appears to be no
2892authoritative specification of the format of this line. Exim recognizes it by
2893matching against the regular expression defined by the \uucp@_from@_pattern\
2894option, which can be changed if necessary.
2895.index \-f-\ option||overriding `From' line
2896The specified sender is treated as if it were given as the argument to the
2897\-f-\ option, but if a \-f-\ option is also present, its argument is used in
2898preference to the address taken from the message. The caller of Exim must be a
2899trusted user for the sender of a message to be set in this way.
2900
2901.option bnq
2902.index address||qualification, suppressing
2903By default, Exim automatically qualifies unqualified addresses (those
2904without domains) that appear in messages that are submitted locally (that
2905is, not over TCP/IP). This qualification applies both to addresses in
2906envelopes, and addresses in header lines. Sender addresses are qualified using
2907\qualify@_domain\, and recipient addresses using \qualify@_recipient\ (which
2908defaults to the value of \qualify@_domain\).
2909
2910Sometimes, qualification is not wanted. For example, if \-bS-\ (batch SMTP) is
2911being used to re-submit messages that originally came from remote hosts after
2912content scanning, you probably do not want to qualify unqualified addresses in
2913header lines. (Such lines will be present only if you have not enabled a header
2914syntax check in the appropriate ACL.)
2915
2916The \-bnq-\ option suppresses all qualification of unqualified addresses in
2917messages that originate on the local host. When this is used, unqualified
2918addresses in the envelope provoke errors (causing message rejection) and
2919unqualified addresses in header lines are left alone.
2920
2921
2922.option bP
2923.index configuration options, extracting
2924.index options||configuration, extracting
2925If this option is given with no arguments, it causes the values of all Exim's
2926main configuration options to be written to the standard output. The values
2927of one or more specific options can be requested by giving their names as
2928arguments, for example:
2929.display
2930exim -bP qualify@_domain hold@_domains
2931.endd
2932However, any option setting that is preceded by the word `hide' in the
2933configuration file is not shown in full, except to an admin user. For other
2934users, the output is as in this example:
2935.display asis
2936mysql_servers = <value not displayable>
2937.endd
2938If \configure@_file\ is given as an argument, the name of the run time
2939configuration file is output.
2940If a list of configuration files was supplied, the value that is output here
2941is the name of the file that was actually used.
2942
2943.index daemon||process id (pid)
2944.index pid (process id)||of daemon
2945If \log__file__path\ or \pid@_file@_path\ are given, the names of the
2946directories where log files and daemon pid files are written are output,
2947respectively. If these values are unset, log files are written in a
2948sub-directory of the spool directory called \log\, and the pid file is written
2949directly into the spool directory.
2950
2951If \-bP-\ is followed by a name preceded by \"+"\, for example,
2952.display asis
2953exim -bP +local_domains
2954.endd
2955it searches for a matching named list of any type (domain, host, address, or
2956local part) and outputs what it finds.
2957
2958.index options||router, extracting
2959.index options||transport, extracting
2960If one of the words \router\, \transport\, or \authenticator\ is given,
2961followed by the name of an appropriate driver instance, the option settings for
2962that driver are output. For example:
2963.display
2964exim -bP transport local@_delivery
2965.endd
2966The generic driver options are output first, followed by the driver's private
2967options. A list of the names of drivers of a particular type can be obtained by
2968using one of the words \router@_list\, \transport@_list\, or
2969\authenticator@_list\, and a complete list of all drivers with their option
2970settings can be obtained by using \routers\, \transports\, or \authenticators\.
2971
2972
2973.option bp
2974.index queue||listing messages on
2975.index listing||messages on the queue
2976This option requests a listing of the contents of the mail queue on the
2977standard output. If the \-bp-\ option is followed by a list of message ids,
2978just those messages are listed. By default, this option can be used only by an
2979admin user. However, the \queue__list__requires__admin\ option can be set false
2980to allow any user to see the queue.
2981
2982Each message on the queue is displayed as in the following example:
2983.display
298425m 2.9K 0t5C6f-0000c8-00 <alice@@wonderland.fict.example>
2985 red.king@@looking-glass.fict.example
2986 <<other addresses>>
2987.endd
2988.index message||size in queue listing
2989.index size||of message
2990The first line contains the length of time the message has been on the queue
2991(in this case 25 minutes), the size of the message (2.9K), the unique local
2992identifier for the message, and the message sender, as contained in the
2993envelope. For bounce messages, the sender address is empty, and appears as
2994`<>'. If the message was submitted locally by an untrusted user who overrode
2995the default sender address, the user's login name is shown in parentheses
2996before the sender address.
2997.index frozen messages||in queue listing
2998If the message is frozen (attempts to deliver it are suspended) then the text
2999`$*$$*$$*$ frozen $*$$*$$*$' is displayed at the end of this line.
3000
3001The recipients of the message (taken from the envelope, not the headers) are
3002displayed on subsequent lines. Those addresses to which the message has already
3003been delivered are marked with the letter D. If an original address gets
3004expanded into several addresses via an alias or forward file, the original is
3005displayed with a D only when deliveries for all of its child addresses are
3006complete.
3007
3008
3009.option bpa
3010This option operates like \-bp-\, but in addition it shows delivered addresses
3011that were generated from the original top level address(es) in each message by
3012alias or forwarding operations. These addresses are flagged with `+D' instead
3013of just `D'.
3014
3015
3016.option bpc
3017.index queue||count of messages on
3018This option counts the number of messages on the queue, and writes the total
3019to the standard output. It is restricted to admin users, unless
3020\queue__list__requires__admin\ is set false.
3021
3022
3023.option bpr
3024This option operates like \-bp-\, but the output is not sorted into
3025chronological order of message arrival. This can speed it up when there are
3026lots of messages on the queue, and is particularly useful if the output is
3027going to be post-processed in a way that doesn't need the sorting.
3028
3029.option bpra
3030This option is a combination of \-bpr-\ and \-bpa-\.
3031
3032.option bpru
3033This option is a combination of \-bpr-\ and \-bpu-\.
3034
3035
3036.option bpu
3037This option operates like \-bp-\ but shows only undelivered top-level addresses
3038for each message displayed. Addresses generated by aliasing or forwarding are
3039not shown, unless the message was deferred after processing by a router with
3040the \one@_time\ option set.
3041
3042
3043.option brt
3044.index testing||retry configuration
3045.index retry||configuration testing
3046This option is for testing retry rules, and it must be followed by up to three
3047arguments. It causes Exim to look for a retry rule that matches the values
3048and to write it to the standard output. For example:
3049.display asis
3050exim -brt bach.comp.mus.example
3051Retry rule: *.comp.mus.example F,2h,15m; F,4d,30m;
3052.endd
3053See chapter ~~CHAPretry for a description of Exim's retry rules. The first
3054argument, which is required, can be a complete address in the form
3055\*local@_part@@domain*\, or it can be just a domain name. The second argument is
3056an optional second domain name; if no retry rule is found for the first
3057argument, the second is tried. This ties in with Exim's behaviour when looking
3058for retry rules for remote hosts -- if no rule is found that matches the host,
3059one that matches the mail domain is sought. The final argument is the name of a
3060specific delivery error, as used in setting up retry rules, for example
3061`quota@_3d'.
3062
3063.option brw
3064.index testing||rewriting
3065.index rewriting||testing
3066This option is for testing address rewriting rules, and it must be followed by
3067a single argument, consisting of either a local part without a domain, or a
3068complete address with a fully qualified domain. Exim outputs how this address
3069would be rewritten for each possible place it might appear. See chapter
3070~~CHAPrewrite for further details.
3071
3072.option bS
3073.index SMTP||batched incoming
3074.index batched SMTP input
3075This option is used for batched SMTP input, which is an alternative interface
3076for non-interactive local message submission. A number of messages can be
3077submitted in a single run. However, despite its name, this is not really SMTP
3078input. Exim reads each message's envelope from SMTP commands on the standard
3079input, but generates no responses. If the caller is trusted, or
3080\untrusted@_set@_sender\ is set, the senders in the SMTP \\MAIL\\ commands are
3081believed; otherwise the sender is always the caller of Exim.
3082
3083The message itself is read from the standard input, in SMTP format (leading
3084dots doubled), terminated by a line containing just a single dot. An error is
3085provoked if the terminating dot is missing. A further message may then follow.
3086
3087As for other local message submissions, the contents of incoming batch SMTP
3088messages can be checked using the non-SMTP ACL (see chapter ~~CHAPACL).
3089Unqualified addresses are automatically qualified using \qualify@_domain\ and
3090\qualify@_recipient\, as appropriate, unless the \-bnq-\ option is used.
3091
3092Some other SMTP commands are recognized in the input. \\HELO\\ and \\EHLO\\ act
3093as \\RSET\\; \\VRFY\\, \\EXPN\\, \\ETRN\\, and \\HELP\\ act as \\NOOP\\;
3094\\QUIT\\ quits, ignoring the rest of the standard input.
3095
3096If any error is encountered, reports are written to the standard output and
3097error streams, and Exim gives up immediately.
3098.index return code||for \-bS-\
3099The return code is 0 if no error was detected; it is 1 if one or more messages
3100were accepted before the error was detected; otherwise it is 2.
3101
3102More details of input using batched SMTP are given in section
3103~~SECTincomingbatchedSMTP.
3104
3105.option bs
3106.index SMTP||local input
3107.index local SMTP input
3108This option causes Exim to accept one or more messages by reading SMTP commands
3109on the standard input, and producing SMTP replies on the standard output. SMTP
3110policy controls, as defined in ACLs (see chapter ~~CHAPACL) are applied.
3111
3112Some user agents use this interface as a way of passing locally-generated
3113messages to the MTA.
3114.index sender||source of
3115In this usage, if the caller of Exim is trusted, or \untrusted@_set@_sender\ is
3116set, the senders of messages are taken from the SMTP \\MAIL\\ commands.
3117Otherwise the content of these commands is ignored and the sender is set up as
3118the calling user. Unqualified addresses are automatically qualified using
3119\qualify@_domain\ and \qualify@_recipient\, as appropriate, unless the \-bnq-\
3120option is used.
3121
3122.index inetd
3123The \-bs-\ option is also used to run Exim from \*inetd*\, as an alternative to
3124using a listening daemon. Exim can distinguish the two cases by checking
3125whether the standard input is a TCP/IP socket. When Exim is called from
3126\*inetd*\, the source of the mail is assumed to be remote, and the comments
3127above concerning senders and qualification do not apply. In this situation,
3128Exim behaves in exactly the same way as it does when receiving a message via
3129the listening daemon.
3130
3131.option bt
3132.index testing||addresses
3133.index address||testing
3134This option runs Exim in address testing mode, in which each argument is taken
3135as an address to be tested for deliverability. The results are written to the
3136standard output.
3137If a test fails, and the caller is not an admin user, no details of the
3138failure are output, because these might contain sensitive information such as
3139usernames and passwords for database lookups.
3140
3141If no arguments are given, Exim runs in an interactive manner, prompting with a
3142right angle bracket for addresses to be tested. Each address is handled as if
3143it were the recipient address of a message (compare the \-bv-\ option). It is
3144passed to the routers and the result is written to the standard output.
3145However, any router that has \no@_address@_test\ set is bypassed. This can
3146make \-bt-\ easier to use for genuine routing tests if your first router passes
3147everything to a scanner program.
3148
3149.index return code||for \-bt-\
3150The return code is 2 if any address failed outright; it is 1 if no address
3151failed outright but at least one could not be resolved for some reason. Return
3152code 0 is given only when all addresses succeed.
3153
3154\**Warning**\: \-bt-\ can only do relatively simple testing. If any of the
3155routers in the configuration makes any tests on the sender address of a
3156message,
3157.index \-f-\ option||for address testing
3158you can use the \-f-\ option to set an appropriate sender when running
3159\-bt-\ tests. Without it, the sender is assumed to be the calling user at the
3160default qualifying domain. However, if you have set up (for example) routers
3161whose behaviour depends on the contents of an incoming message, you cannot test
3162those conditions using \-bt-\. The \-N-\ option provides a possible way of
3163doing such tests.
3164
3165.option bV
3166.index version number of Exim, verifying
3167This option causes Exim to write the current version number, compilation
3168number, and compilation date of the \*exim*\ binary to the standard output.
3169It also lists the DBM library this is being used, the optional modules (such as
3170specific lookup types), the drivers that are included in the binary, and the
3171name of the run time configuration file that is in use.
3172
3173.option bv
3174.index verifying||address, using \-bv-\
3175.index address||verification
3176This option runs Exim in address verification mode, in which each argument is
3177taken as an address to be verified. During normal operation, verification
3178happens mostly as a consequence processing a \verify\ condition in an ACL (see
3179chapter ~~CHAPACL). If you want to test an entire ACL, see the \-bh-\ option.
3180
3181If verification fails, and the caller is not an admin user, no details of the
3182failure are output, because these might contain sensitive information such as
3183usernames and passwords for database lookups.
3184
3185If no arguments are given, Exim runs in an interactive manner, prompting with a
3186right angle bracket for addresses to be verified. Verification differs from
3187address testing (the \-bt-\ option) in that routers that have \no@_verify\ set
3188are skipped, and if the address is accepted by a router that has \fail@_verify\
3189set, verification fails. The address is verified as a recipient if \-bv-\ is
3190used; to test verification for a sender address, \-bvs-\ should be used.
3191
3192If the \-v-\ option is not set, the output consists of a single line for each
3193address, stating whether it was verified or not, and giving a reason in the
3194latter case. Otherwise, more details are given of how the address has been
3195handled, and in the case of address redirection, all the generated addresses
3196are also considered. Without \-v-\, generating more than one address by
3197redirection causes verification to end sucessfully.
3198
3199.index return code||for \-bv-\
3200The return code is 2 if any address failed outright; it is 1 if no address
3201failed outright but at least one could not be resolved for some reason. Return
3202code 0 is given only when all addresses succeed.
3203
3204If any of the routers in the configuration makes any tests on the sender
3205address of a message, you should use the \-f-\ option to set an appropriate
3206sender when running \-bv-\ tests. Without it, the sender is assumed to be the
3207calling user at the default qualifying domain.
3208
3209.option bvs
3210This option acts like \-bv-\, but verifies the address as a sender rather
3211than a recipient address. This affects any rewriting and qualification that
3212might happen.
3213
3214.option C #<<filelist>>
3215.index configuration file||alternate
3216.index \\CONFIGURE@_FILE\\
3217.index alternate configuration file
3218This option causes Exim to find the run time configuration file from the given
3219list instead of from the list specified by the \\CONFIGURE@_FILE\\
3220compile-time setting. Usually, the list will consist of just a single file
3221name, but it can be a colon-separated list of names. In this case, the first
3222file that exists is used. Failure to open an existing file stops Exim from
3223proceeding any further along the list, and an error is generated.
3224
3225When this option is used by a caller other than root or the Exim user,
3226and the list is different from the compiled-in list, Exim gives up
3227its root privilege immediately, and runs with the real and effective uid and
3228gid set to those of the caller.
3229However, if \\ALT@_CONFIG@_ROOT@_ONLY\\ is defined in \(Local/Makefile)\, root
3230privilege is retained for \-C-\ only if the caller of Exim is root.
3231This option is not set by default.
3232
3233Setting \\ALT@_CONFIG@_ROOT@_ONLY\\ locks out the possibility of testing a
3234configuration using \-C-\ right through message reception and delivery, even if
3235the caller is root. The reception works, but by that time, Exim is running as
3236the Exim user, so when it re-execs to regain privilege for the delivery, the
3237use of \-C-\ causes privilege to be lost. However, root can test reception and
3238delivery using two separate commands (one to put a message on the queue, using
3239\-odq-\, and another to do the delivery, using \-M-\).
3240
3241If \\ALT@_CONFIG@_PREFIX\\ is defined \(in Local/Makefile)\, it specifies a
3242prefix string with which any file named in a \-C-\ command line option
3243must start. In addition, the file name must not contain the sequence \"/../"\.
3244However, if the value of the \-C-\ option is identical to the value of
3245\\CONFIGURE@_FILE\\ in \(Local/Makefile)\, Exim ignores \-C-\ and proceeds as
3246usual. There is no default setting for \\ALT@_CONFIG@_PREFIX\\; when it is
3247unset, any file name can be used with \-C-\.
3248
3249\\ALT@_CONFIG@_PREFIX\\ can be used to confine alternative configuration files
3250to a directory to which only root has access. This prevents someone who has
3251broken into the Exim account from running a privileged Exim with an arbitrary
3252configuration file.
3253
3254The \-C-\ facility is useful for ensuring that configuration files are
3255syntactically correct, but cannot be used for test deliveries, unless the
3256caller is privileged, or unless it is an exotic configuration that does not
3257require privilege. No check is made on the owner or group of the files
3258specified by this option.
3259
3260.option D <<macro>>=<<value>>
3261.index macro||setting on command line
3262This option can be used to override macro definitions in the configuration file
3263(see section ~~SECTmacrodefs). However, like \-C-\, if it is used by an
3264unprivileged caller, it causes Exim to give up its root privilege.
3265If \\DISABLE@_D@_OPTION\\ is defined in \(Local/Makefile)\, the use of \-D-\ is
3266completely disabled, and its use causes an immediate error exit.
3267
3268The entire option (including equals sign if present) must all be within one
3269command line item. \-D-\ can be used to set the value of a macro to the empty
3270string, in which case the equals sign is optional. These two commands are
3271synonymous:
3272.display asis
3273exim -DABC ...
3274exim -DABC= ...
3275.endd
3276To include spaces in a macro definition item, quotes must be used. If you use
3277quotes, spaces are permitted around the macro name and the equals sign. For
3278example:
3279.display asis
3280exim '-D ABC = something' ...
3281.endd
3282\-D-\ may be repeated up to 10 times on a command line.
3283
3284.option d <<debug options>>
3285.index debugging||list of selectors
3286.index debugging||\-d-\ option
3287This option causes debugging information to be written to the standard
3288error stream. It is restricted to admin users because debugging output may show
3289database queries that contain password information. Also, the details of users'
3290filter files should be protected. When \-d-\ is used, \-v-\ is assumed. If
3291\-d-\ is given on its own, a lot of standard debugging data is output. This can
3292be reduced, or increased to include some more rarely needed information, by
3293following \-d-\ with a string made up of names preceded by plus or minus
3294characters. These add or remove sets of debugging data, respectively. For
3295example, \-d+filter-\ adds filter debugging, whereas \-d-all+filter-\ selects
3296only filter debugging. The available debugging categories are:
3297.display flow
3298.tabs 21
3299.
3300. The odd formatting of the lines below is deliberate. It does not affect the
3301. SGCAL output, but by putting in the space it keeps things aligned in the man
3302. page that is automatically generated from this text.
3303.
3304acl $t $rm{ACL interpretation}
3305auth $t $rm{authenticators}
3306deliver $t $rm{general delivery logic}
3307dns $t $rm{DNS lookups (see also resolver)}
3308dnsbl $t $rm{DNS black list (aka RBL) code}
3309exec $t $rm{arguments for \execv@(@)\ calls}
3310expand $t $rm{detailed debugging for string expansions}
3311filter $t $rm{filter handling}
3312hints@_lookup $t $rm{hints data lookups}
3313host@_lookup $t $rm{all types of name-to-IP address handling}
3314ident $t $rm{ident lookup}
3315interface $t $rm{lists of local interfaces}
3316lists $t $rm{matching things in lists}
3317load $t $rm{system load checks}
3318local@_scan $t $rm{can be used by \*local@_scan()*\ (see chapter ~~CHAPlocalscan)}
3319lookup $t $rm{general lookup code and all lookups}
3320memory $t $rm{memory handling}
3321pid $t $rm{add pid to debug output lines}
3322process@_info $t $rm{setting info for the process log}
3323queue@_run $t $rm{queue runs}
3324receive $t $rm{general message reception logic}
3325resolver $t $rm{turn on the DNS resolver's debugging output}
3326retry $t $rm{retry handling}
3327rewrite $t $rm{address rewriting}
3328route $t $rm{address routing}
3329timestamp $t $rm{add timestamp to debug output lines}
3330tls $t $rm{TLS logic}
3331transport $t $rm{transports}
3332uid $t $rm{changes of uid/gid and looking up uid/gid}
3333verify $t $rm{address verification logic}
3334
3335all $t $rm{all of the above, and also \-v-\}
3336.endd
3337.em
3338.index resolver, debugging output
3339.index DNS||resolver, debugging output
3340The \"resolver"\ option produces output only if the DNS resolver was compiled
3341with \\DEBUG\\ enabled. This is not the case in some operating systems. Also,
3342unfortunately, debugging output from the DNS resolver is written to stdout
3343rather than stderr.
3344.nem
3345
3346The default (\-d-\ with no argument) omits \"expand"\, \"filter"\,
3347\"interface"\, \"load"\, \"memory"\, \"pid"\, \"resolver"\, and \"timestamp"\.
3348However, the \"pid"\ selector is forced when debugging is turned on for a
3349daemon, which then passes it on to any re-executed Exims. Exim also
3350automatically adds the pid to debug lines when several remote deliveries are
3351run in parallel.
3352
3353The \"timestamp"\ selector causes the current time to be inserted at the start
3354of all debug output lines. This can be useful when trying to track down delays
3355in processing.
3356
3357If the \debug@_print\ option is set in any driver, it produces output whenever
3358any debugging is selected, or if \-v-\ is used.
3359
3360.option dropcr
3361This is an obsolete option that is now a no-op. It used to affect the way Exim
3362handled CR and LF characters in incoming messages. What happens now is
3363described in section ~~SECTlineendings.
3364
3365
3366.option E
3367.index bounce message||generating
3368This option specifies that an incoming message is a locally-generated delivery
3369failure report. It is used internally by Exim when handling delivery failures
3370and is not intended for external use. Its only effect is to stop Exim
3371generating certain messages to the postmaster, as otherwise message cascades
3372could occur in some situations. As part of the same option, a message id may
3373follow the characters \-E-\. If it does, the log entry for the receipt of the
3374new message contains the id, following `R=', as a cross-reference.
3375
3376.option e$it{x}
3377There are a number of Sendmail options starting with \-oe-\ which seem to be
3378called by various programs without the leading \o\ in the option. For example,
3379the \vacation\ program uses \-eq-\. Exim treats all options of the form
3380\-e$it{x}-\ as synonymous with the corresponding \-oe$it{x}-\ options.
3381
3382.option F #<<string>>
3383.index sender||name
3384.index name||of sender
3385This option sets the sender's full name for use when a locally-generated
3386message is being accepted. In the absence of this option, the user's \*gecos*\
3387entry from the password data is used. As users are generally permitted to alter
3388their \*gecos*\ entries, no security considerations are involved. White space
3389between \-F-\ and the <<string>> is optional.
3390
3391.option f #<<address>>
3392.index sender||address
3393.index address||sender
3394.index trusted user
3395.index envelope sender
3396.index user||trusted
3397This option sets the address of the envelope sender of a locally-generated
3398message (also known as the return path). The option can normally be used only
3399by a trusted user, but \untrusted@_set@_sender\ can be set to allow untrusted
3400users to use it. In the absence of \-f-\, or if the caller is not allowed to
3401use it, the sender of a local message is set to the caller's login name at the
3402default qualify domain.
3403
3404There is one exception to the restriction on the use of \-f-\: an empty sender
3405can be specified by any user, to create a message that can never provoke a
3406bounce. An empty sender can be specified either as an empty string, or as a
3407pair of angle brackets with nothing between them, as in these examples of shell
3408commands:
3409.display asis
3410exim -f '<>' user@domain
3411exim -f "" user@domain
3412.endd
3413In addition, the use of \-f-\ is not restricted when testing a filter file with
3414\-bf-\ or when testing or verifying addresses using the \-bt-\ or \-bv-\
3415options.
3416
3417Allowing untrusted users to change the sender address does not of itself make
3418it possible to send anonymous mail. Exim still checks that the ::From:: header
3419refers to the local user, and if it does not, it adds a ::Sender:: header,
3420though this can be overridden by setting \no@_local@_from@_check\.
3421
3422.index `From' line
3423White space between \-f-\ and the <<address>> is optional
3424(that is, they can be given as two arguments or one combined argument).
3425The sender of a locally-generated message can also be set (when permitted) by
3426an initial `From ' line in the message -- see the description of \-bm-\ above
3427-- but if \-f-\ is also present, it overrides `From'.
3428
3429.option G
3430.index Sendmail compatibility||\-G-\ option ignored
3431This is a Sendmail option which is ignored by Exim.
3432
3433.option h #<<number>>
3434.index Sendmail compatibility||\-h-\ option ignored
3435This option is accepted for compatibility with Sendmail, but has no effect. (In
3436Sendmail it overrides the `hop count' obtained by counting ::Received::
3437headers.)
3438
3439.option i
3440.index Solaris||\*mail*\ command
3441.index dot||in incoming, non-SMTP message
3442This option, which has the same effect as \-oi-\, specifies that a dot on a
3443line by itself should not terminate an incoming, non-SMTP message. I can find
3444no documentation for this option in Solaris 2.4 Sendmail, but the \*mailx*\
3445command in Solaris 2.4 uses it. See also \-ti-\.
3446
3447.option M #<<message id>>#<<message id>> ...
3448.index forcing delivery
3449.index delivery||forcing attempt
3450.index frozen messages||forcing delivery
3451This option requests Exim to run a delivery attempt on each message in turn. If
3452any of the messages are frozen, they are automatically thawed before the
3453delivery attempt. The settings of \queue@_domains\, \queue@_smtp@_domains\, and
3454\hold@_domains\ are ignored.
3455.index hints database||overriding retry hints
3456Retry hints for any of the addresses are
3457overridden -- Exim tries to deliver even if the normal retry time has not yet
3458been reached. This option requires the caller to be an admin user. However,
3459there is an option called \prod@_requires@_admin\ which can be set false to
3460relax this restriction (and also the same requirement for the \-q-\, \-R-\, and
3461\-S-\ options).
3462
3463
3464.option Mar #<<message id>>#<<address>>#<<address>> ...
3465.index message||adding recipients
3466.index recipient||adding
3467This option requests Exim to add the addresses to the list of recipients of the
3468message (`ar' for `add recipients'). The first argument must be a message id,
3469and the remaining ones must be email addresses. However, if the message is
3470active (in the middle of a delivery attempt), it is not altered. This option
3471can be used only by an admin user.
3472
3473.index SMTP||passed connection
3474.index SMTP||multiple deliveries
3475.index multiple SMTP deliveries
3476.option MC #<<transport>>#<<hostname>>#<<sequence number>>#<<message id>>
3477This option is not intended for use by external callers. It is used internally
3478by Exim to invoke another instance of itself to deliver a waiting message using
3479an existing SMTP connection, which is passed as the standard input. Details are
3480given in chapter ~~CHAPSMTP. This must be the final option, and the caller must
3481be root or the Exim user in order to use it.
3482
3483.option MCA
3484This option is not intended for use by external callers. It is used internally
3485by Exim in conjunction with the \-MC-\ option. It signifies that the connection
3486to the remote host has been authenticated.
3487
3488.option MCP
3489This option is not intended for use by external callers. It is used internally
3490by Exim in conjunction with the \-MC-\ option. It signifies that the server to
3491which Exim is connected supports pipelining.
3492
3493.option MCQ #<<process id>> <<pipe fd>>
3494This option is not intended for use by external callers. It is used internally
3495by Exim in conjunction with the \-MC-\ option when the original delivery was
3496started by a queue runner. It passes on the process id of the queue runner,
3497together with the file descriptor number of an open pipe. Closure of the pipe
3498signals the final completion of the sequence of processes that are passing
3499messages through the same SMTP connection.
3500
3501.option MCS
3502This option is not intended for use by external callers. It is used internally
3503by Exim in conjunction with the \-MC-\ option, and passes on the fact that the
3504SMTP \\SIZE\\ option should be used on messages delivered down the existing
3505connection.
3506
3507.option MCT
3508This option is not intended for use by external callers. It is used internally
3509by Exim in conjunction with the \-MC-\ option, and passes on the fact that the
3510host to which Exim is connected supports TLS encryption.
3511
3512.option Mc #<<message id>>#<<message id>> ...
3513.index hints database||not overridden by \-Mc-\
3514.index delivery||manually started, not forced
3515This option requests Exim to run a delivery attempt on each message in turn,
3516but unlike the \-M-\ option, it does check for retry hints, and respects any
3517that are found. This option is not very useful to external callers. It is
3518provided mainly for internal use by Exim when it needs to re-invoke itself in
3519order to regain root privilege for a delivery (see chapter ~~CHAPsecurity).
3520However, \-Mc-\ can be useful when testing, in order to run a delivery that
3521respects retry times and other options such as \hold@_domains\ that are
3522overridden when \-M-\ is used. Such a delivery does not count as a queue run.
3523If you want to run a specific delivery as if in a queue run, you should use
3524\-q-\ with a message id argument. A distinction between queue run deliveries
3525and other deliveries is made in one or two places.
3526
3527.option Mes #<<message id>>#<<address>>
3528.index message||changing sender
3529.index sender||changing
3530This option requests Exim to change the sender address in the message to the
3531given address, which must be a fully qualified address or `<>' (`es' for `edit
3532sender'). There must be exactly two arguments. The first argument must be a
3533message id, and the second one an email address. However, if the message is
3534active (in the middle of a delivery attempt), its status is not altered. This
3535option can be used only by an admin user.
3536
3537.option Mf #<<message id>>#<<message id>> ...
3538.index freezing messages
3539.index message||manually freezing
3540This option requests Exim to mark each listed message as `frozen'. This
3541prevents any delivery attempts taking place until the message is `thawed',
3542either manually or as a result of the \auto@_thaw\ configuration option.
3543However, if any of the messages are active (in the middle of a delivery
3544attempt), their status is not altered. This option can be used only by an admin
3545user.
3546
3547.option Mg #<<message id>>#<<message id>> ...
3548.index giving up on messages
3549.index message||abandoning delivery attempts
3550.index delivery||abandoning further attempts
3551This option requests Exim to give up trying to deliver the listed messages,
3552including any that are frozen. However, if any of the messages are active,
3553their status is not altered.
3554For non-bounce messages, a delivery error message is sent to the sender,
3555containing the text `cancelled by administrator'. Bounce messages are just
3556discarded.
3557This option can be used only by an admin user.
3558
3559.option Mmad #<<message id>>#<<message id>> ...
3560.index delivery||cancelling all
3561This option requests Exim to mark all the recipient addresses in the messages
3562as already delivered (`mad' for `mark all delivered'). However, if any message
3563is active (in the middle of a delivery attempt), its status is not altered.
3564This option can be used only by an admin user.
3565
3566.option Mmd #<<message id>>#<<address>>#<<address>> ...
3567.index delivery||cancelling by address
3568.index recipient||removing
3569.index removing recipients
3570This option requests Exim to mark the given addresses as already delivered
3571(`md' for `mark delivered'). The first argument must be a message id, and the
3572remaining ones must be email addresses. These are matched to recipient
3573addresses in the message in a case-sensitive manner. If the message is active
3574(in the middle of a delivery attempt), its status is not altered. This option
3575can be used only by an admin user.
3576
3577.option Mrm #<<message id>>#<<message id>> ...
3578.index removing messages
3579.index abandoning mail
3580.index message||manually discarding
3581This option requests Exim to remove the given messages from the queue. No
3582bounce messages are sent; each message is simply forgotten. However, if any of
3583the messages are active, their status is not altered. This option can be used
3584only by an admin user or by the user who originally caused the message to be
3585placed on the queue.
3586
3587.option Mt #<<message id>>#<<message id>> ...
3588.index thawing messages
3589.index unfreezing messages
3590.index frozen messages||thawing
3591.index message||thawing frozen
3592This option requests Exim to `thaw' any of the listed messages that are
3593`frozen', so that delivery attempts can resume. However, if any of the messages
3594are active, their status is not altered. This option can be used only by an
3595admin user.
3596
3597.option Mvb #<<message id>>
3598.index listing||message body
3599.index message||listing body of
3600This option causes the contents of the message body (-D) spool file to be
3601written to the standard output. This option can be used only by an admin user.
3602
3603.option Mvh #<<message id>>
3604.index listing||message headers
3605.index header lines||listing
3606.index message||listing header lines
3607This option causes the contents of the message headers (-H) spool file to be
3608written to the standard output. This option can be used only by an admin user.
3609
3610.option Mvl #<<message id>>
3611.index listing||message log
3612.index message||listing message log
3613This option causes the contents of the message log spool file to be written to
3614the standard output. This option can be used only by an admin user.
3615
3616.option m
3617This is apparently a synonym for \-om-\ that is accepted by Sendmail, so Exim
3618treats it that way too.
3619
3620.option N
3621.index debugging||\-N-\ option
3622.index debugging||suppressing delivery
3623This is a debugging option that inhibits delivery of a message at the transport
3624level. It implies \-v-\. Exim goes through many of the motions of delivery --
3625it just doesn't actually transport the message, but instead behaves as if it
3626had successfully done so. However, it does not make any updates to the retry
3627database, and the log entries for deliveries are flagged with `$*$>' rather
3628than `=>'.
3629
3630Because \-N-\ discards any message to which it applies, only root or the Exim
3631user are allowed to use it with \-bd-\, \-q-\, \-R-\ or \-M-\. In other words,
3632an ordinary user can use it only when supplying an incoming message to which it
3633will apply. Although transportation never fails when \-N-\ is set, an address
3634may be deferred because of a configuration problem on a transport, or a routing
3635problem. Once \-N-\ has been used for a delivery attempt, it sticks to the
3636message, and applies to any subsequent delivery attempts that may happen for
3637that message.
3638
3639.option n
3640.index Sendmail compatibility||\-n-\ option ignored
3641This option is interpreted by Sendmail to mean `no aliasing'. It is ignored by
3642Exim.
3643
3644.option O #<<data>>
3645This option is interpreted by Sendmail to mean `set option`. It is ignored by
3646Exim.
3647
3648.option oA #<<file name>>
3649.index Sendmail compatibility||\-oA-\ option
3650This option is used by Sendmail in conjunction with \-bi-\ to specify an
3651alternative alias file name. Exim handles \-bi-\ differently; see the
3652description above.
3653
3654.index SMTP||passed connection
3655.option oB #<<n>>
3656.index SMTP||multiple deliveries
3657.index multiple SMTP deliveries
3658This is a debugging option which limits the maximum number of messages that can
3659be delivered down one SMTP connection, overriding the value set in any \%smtp%\
3660transport. If <<n>> is omitted, the limit is set to 1.
3661
3662.option odb
3663.index background delivery
3664.index delivery||in the background
3665This option applies to all modes in which Exim accepts incoming messages,
3666including the listening daemon. It requests `background' delivery of such
3667messages, which means that the accepting process automatically starts delivery
3668process for each message received, but does not wait for the delivery process
3669to complete. This is the default action if none of the \-od-\ options are
3670present.
3671
3672If one of the queueing options in the configuration file
3673(\queue@_only\ or \queue@_only@_file\, for example) is in effect, \-odb-\
3674overrides it if \queue@_only@_override\ is set true, which is the default
3675setting. If \queue@_only@_override\ is set false, \-odb-\ has no effect.
3676
3677.option odf
3678.index foreground delivery
3679.index delivery||in the foreground
3680This option requests `foreground' (synchronous) delivery when Exim has accepted
3681a locally-generated message. (For the daemon it is exactly the same as
3682\-odb-\.) A delivery process is automatically started to deliver the
3683message, and Exim waits for it to complete before proceeding.
3684However, like \-odb-\, this option has no effect if \queue@_only@_override\ is
3685false and one of the queueing options in the configuration file is in effect.
3686
3687.option odi
3688This option is synonymous with \-odf-\. It is provided for compatibility with
3689Sendmail.
3690
3691.option odq
3692.index non-immediate delivery
3693.index delivery||suppressing immediate
3694.index queueing incoming messages
3695This option applies to all modes in which Exim accepts incoming messages,
3696including the listening daemon. It specifies that the accepting process should
3697not automatically start a delivery process for each message received. Messages
3698are placed on the queue, and remain there until a subsequent queue runner
3699process encounters them.
3700There are several configuration options (such as \queue@_only\) that can be
3701used to queue incoming messages under certain conditions. This option overrides
3702all of them and also \-odqs-\. It always forces queueing.
3703
3704.option odqs
3705.index SMTP||delaying delivery
3706This option is a hybrid between \-odb-\/\-odi-\ and \-odq-\.
3707However, like \-odb-\ and \-odi-\, this option has no effect if
3708\queue@_only@_override\ is false and one of the queueing options in the
3709configuration file is in effect.
3710
3711When \-odqs-\ does operate, a delivery process is started for each incoming
3712message, in the background by default, but in the foreground if \-odi-\ is also
3713present.
3714The recipient addresses are routed, and local deliveries are done in the normal
3715way. However, if any SMTP deliveries are required, they are not done at this
3716time, so the message remains on the queue until a subsequent queue runner
3717process encounters it. Because routing was done, Exim knows which messages are
3718waiting for which hosts, and so a number of messages for the same host can be
3719sent in a single SMTP connection. The \queue@_smtp@_domains\ configuration
3720option has the same effect for specific domains. See also the \-qq-\ option.
3721
3722.option oee
3723.index error||reporting
3724If an error is detected while a non-SMTP message is being received (for
3725example, a malformed address), the error is reported to the sender in a mail
3726message.
3727.index return code||for \-oee-\
3728Provided this error message is successfully sent, the Exim receiving process
3729exits with a return code of zero. If not, the return code is 2 if the problem
3730is that the original message has no recipients, or 1 any other error. This is
3731the default \-oe$it{x}-\ option if Exim is called as \*rmail*\.
3732
3733.option oem
3734.index error||reporting
3735.index return code||for \-oem-\
3736This is the same as \-oee-\, except that Exim always exits with a non-zero
3737return code, whether or not the error message was successfully sent.
3738This is the default \-oe$it{x}-\ option, unless Exim is called as \*rmail*\.
3739
3740.option oep
3741.index error||reporting
3742If an error is detected while a non-SMTP message is being received, the
3743error is reported by writing a message to the standard error file (stderr).
3744.index return code||for \-oep-\
3745The return code is 1 for all errors.
3746
3747.option oeq
3748.index error||reporting
3749This option is supported for compatibility with Sendmail, but has the same
3750effect as \-oep-\.
3751
3752.option oew
3753.index error||reporting
3754This option is supported for compatibility with Sendmail, but has the same
3755effect as \-oem-\.
3756
3757.option oi
3758.index dot||in incoming, non-SMTP message
3759This option, which has the same effect as \-i-\, specifies that a dot on a line
3760by itself should not terminate an incoming, non-SMTP message.
3761.em
3762Otherwise, a single dot does terminate, though Exim does no special processing
3763for other lines that start with a dot.
3764.nem
3765This option is set by default if Exim is called as \*rmail*\. See also \-ti-\.
3766
3767.option oitrue
3768This option is treated as synonymous with \-oi-\.
3769
3770.option oMa #<<host address>>
3771.index sender||host address, specifying for local message
3772A number of options starting with \-oM-\ can be used to set values associated
3773with remote hosts on locally-submitted messages (that is, messages not received
3774over TCP/IP). These options can be used by any caller in conjunction with the
3775\-bh-\,
3776\-be-\,
3777\-bf-\, \-bF-\, \-bt-\, or \-bv-\ testing options. In other circumstances, they
3778are ignored unless the caller is trusted.
3779
3780The \-oMa-\ option sets the sender host address. This may include a port number
3781at the end, after a full stop (period). For example:
3782.display asis
3783exim -bs -oMa 10.9.8.7.1234
3784.endd
3785An alternative syntax is to enclose the IP address in square brackets, followed
3786by a colon and the port number:
3787.display asis
3788exim -bs -oMa [10.9.8.7]:1234
3789.endd
3790The IP address is placed in the \$sender@_host@_address$\ variable, and the
3791port, if present, in \$sender@_host@_port$\.
3792
3793.option oMaa #<<name>>
3794.index authentication||name, specifying for local message
3795See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMaa-\
3796option sets the value of \$sender@_host@_authenticated$\ (the authenticator
3797name). See chapter ~~CHAPSMTPAUTH for a discussion of SMTP authentication.
3798
3799.option oMai #<<string>>
3800.index authentication||id, specifying for local message
3801See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMai-\
3802option sets the
3803value of \$authenticated@_id$\ (the id that was authenticated).
3804This overrides the default value (the caller's login id) for messages from
3805local sources. See chapter ~~CHAPSMTPAUTH for a discussion of authenticated
3806ids.
3807
3808.option oMas #<<address>>
3809.index authentication||sender, specifying for local message
3810See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMas-\
3811option sets the authenticated sender value
3812in \$authenticated@_sender$\.
3813It overrides the sender address that is created from the caller's login id for
3814messages from local sources. See chapter ~~CHAPSMTPAUTH for a discussion of
3815authenticated senders.
3816
3817.option oMi #<<interface address>>
3818.index interface||address, specifying for local message
3819See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMi-\
3820option sets the IP interface address value. A port number may be included,
3821using the same syntax as for \-oMa-\.
3822The interface address is placed in \$interface@_address$\ and the port number,
3823if present, in \$interface@_port$\.
3824
3825.option oMr #<<protocol name>>
3826.index protocol||incoming, specifying for local message
3827See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMr-\
3828option sets the received protocol value
3829in \$received@_protocol$\.
3830However, this applies only when \-bs-\ is not used. For interactive SMTP input,
3831the protocol is determined by whether \\EHLO\\ or \\HELO\\ is used, and is
3832always either `local-esmtp' or `local-smtp'. For \-bS-\ (batch SMTP) however,
3833the protocol can be set by \-oMr-\.
3834
3835.option oMs #<<host name>>
3836.index sender||host name, specifying for local message
3837See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMs-\
3838option sets the sender host name
3839in \$sender@_host@_name$\. When this option is present, Exim does not attempt
3840to look up a host name from an IP address; it uses the name it is given.
3841
3842.option oMt #<<ident string>>
3843.index sender||ident string, specifying for local message
3844See \-oMa-\ above for general remarks about the \-oM-\ options. The \-oMt-\
3845option sets the sender ident value
3846in \$sender@_ident$\.
3847The default setting for local callers is the login id of the calling process.
3848
3849.option om
3850.index Sendmail compatibility||\-om-\ option ignored
3851In Sendmail, this option means `me too', indicating that the sender of a
3852message should receive a copy of the message if the sender appears in an alias
3853expansion. Exim always does this, so the option does nothing.
3854
3855.option oo
3856.index Sendmail compatibility||\-oo-\ option ignored
3857This option is ignored. In Sendmail it specifies `old style headers', whatever
3858that means.
3859
3860.option oP #<<path>>
3861.index pid (process id)||of daemon
3862.index daemon||process id (pid)
3863This option is useful only in conjunction with \-bd-\ or \-q-\ with a time
3864value. The option specifies the file to which the process id of the daemon is
3865written. When \-oX-\ is used with \-bd-\, or when \-q-\ with a time is used
3866without \-bd-\, this is the only way of causing Exim to write a pid file,
3867because in those cases, the normal pid file is not used.
3868
3869.option or #<<time>>
3870.index timeout||for non-SMTP input
3871This option sets a timeout value for incoming non-SMTP messages. If it is not
3872set, Exim will wait forever for the standard input. The value can also be set
3873by the \receive@_timeout\ option. The format used for specifying times is
3874described in section ~~SECTtimeformat.
3875
3876.option os #<<time>>
3877.index timeout||for SMTP input
3878.index SMTP||timeout, input
3879This option sets a timeout value for incoming SMTP messages. The timeout
3880applies to each SMTP command and block of data. The value can also be set by
3881the \smtp@_receive@_timeout\ option; it defaults to 5 minutes. The format used
3882for specifying times is described in section ~~SECTtimeformat.
3883
3884.option ov
3885This option has exactly the same effect as \-v-\.
3886
3887.option oX #<<number or string>>
3888.index TCP/IP||setting listening ports
3889.index TCP/IP||setting listening interfaces
3890.index port||receiving TCP/IP
3891This option is relevant only when the \-bd-\ (start listening daemon) option is
3892also given. It controls which ports and interfaces the daemon uses. Details of
3893the syntax, and how it interacts with configuration file options, are given in
3894chapter ~~CHAPinterfaces. When \-oX-\ is used to start a daemon, no pid file is
3895written unless \-oP-\ is also present to specify a pid file name.
3896
3897.option pd
3898.index Perl||starting the interpreter
3899This option applies when an embedded Perl interpreter is linked with Exim (see
3900chapter ~~CHAPperl). It overrides the setting of the \perl@_at@_start\ option,
3901forcing the starting of the interpreter to be delayed until it is needed.
3902
3903.option ps
3904.index Perl||starting the interpreter
3905This option applies when an embedded Perl interpreter is linked with Exim (see
3906chapter ~~CHAPperl). It overrides the setting of the \perl@_at@_start\ option,
3907forcing the starting of the interpreter to occur as soon as Exim is started.
3908
3909.em
3910.option p<<rval>>:<<sval>>
3911For compatibility with Sendmail, this option
3912is equivalent to
3913.display
3914-oMr <<rval>> -oMs <<sval>>
3915.endd
3916It sets the incoming protocol and host name (for trusted callers). The
3917host name and its colon can be omitted when only the protocol is to be set.
3918Note the Exim already has two private options, \-pd-\ and \-ps-\, that refer to
3919embedded Perl. It is therefore impossible to set a protocol value of \"p"\ or
3920\"s"\ using this option (but that does not seem a real limitation).
3921.nem
3922
3923.option q
3924.index queue runner||starting manually
3925This option is normally restricted to admin users. However, there is a
3926configuration option called \prod@_requires@_admin\ which can be set false to
3927relax this restriction (and also the same requirement for the \-M-\, \-R-\, and
3928\-S-\ options).
3929
3930.index queue runner||description of operation
3931The \-q-\ option starts one queue runner process. This scans the queue of
3932waiting messages, and runs a delivery process for each one in turn. It waits
3933for each delivery process to finish before starting the next one. A delivery
3934process may not actually do any deliveries if the retry times for the addresses
3935have not been reached. Use \-qf-\ (see below) if you want to override this.
3936.index SMTP||passed connection
3937.index SMTP||multiple deliveries
3938.index multiple SMTP deliveries
3939If the delivery process spawns other processes to deliver other messages down
3940passed SMTP connections, the queue runner waits for these to finish before
3941proceeding.
3942
3943When all the queued messages have been considered, the original queue runner
3944process terminates. In other words, a single pass is made over the waiting
3945mail, one message at a time. Use \-q-\ with a time (see below) if you want this
3946to be repeated periodically.
3947
3948Exim processes the waiting messages in an unpredictable order. It isn't very
3949random, but it is likely to be different each time, which is all that matters.
3950If one particular message screws up a remote MTA, other messages to the same
3951MTA have a chance of getting through if they get tried first.
3952
3953It is possible to cause the messages to be processed in lexical message id
3954order, which is essentially the order in which they arrived, by setting the
3955\queue@_run@_in@_order\ option, but this is not recommended for normal use.
3956
3957.option q <<qflags>>
3958The \-q-\ option may be followed by one or more flag letters that change its
3959behaviour. They are all optional, but if more than one is present, they must
3960appear in the correct order. Each flag is described in a separate item below.
3961
3962.option qq...
3963.index queue||double scanning
3964.index queue||routing
3965.index routing||whole queue before delivery
3966An option starting with \-qq-\ requests a two-stage queue run. In the first
3967stage, the queue is scanned as if the \queue@_smtp@_domains\ option matched
3968every domain. Addresses are routed, local deliveries happen, but no remote
3969transports are run.
3970.index hints database||remembering routing
3971The hints database that remembers which messages are
3972waiting for specific hosts is updated, as if delivery to those hosts had been
3973deferred. After this is complete, a second, normal queue scan happens, with
3974routing and delivery taking place as normal. Messages that are routed to the
3975same host should mostly be delivered down a single SMTP
3976.index SMTP||passed connection
3977.index SMTP||multiple deliveries
3978.index multiple SMTP deliveries
3979connection because of the hints that were set up during the first queue scan.
3980This option may be useful for hosts that are connected to the Internet
3981intermittently.
3982
3983.option q[q]i...
3984.index queue||initial delivery
3985If the \*i*\ flag is present, the queue runner runs delivery processes only for
3986those messages that haven't previously been tried. (\*i*\ stands for `initial
3987delivery'.) This can be helpful if you are putting messages on the queue using
3988\-odq-\ and want a queue runner just to process the new messages.
3989
3990.option q[q][i]f...
3991.index queue||forcing delivery
3992.index delivery||forcing in queue run
3993If one \*f*\ flag is present, a delivery attempt is forced for each non-frozen
3994message, whereas without \f\ only those non-frozen addresses that have passed
3995their retry times are tried.
3996
3997.option q[q][i]ff...
3998.index frozen messages||forcing delivery
3999If \*ff*\ is present, a delivery attempt is forced for every message, whether
4000frozen or not.
4001
4002.option q[q][i][f[f]]l
4003.index queue||local deliveries only
4004The \*l*\ (the letter `ell') flag specifies that only local deliveries are to be
4005done. If a message requires any remote deliveries, it remains on the queue for
4006later delivery.
4007
4008.option q <<qflags>>#<<start id>>#<<end id>>
4009.index queue||delivering specific messages
4010When scanning the queue, Exim can be made to skip over messages whose ids are
4011lexically less than a given value by following the \-q-\ option with a starting
4012message id. For example:
4013.display
4014exim -q 0t5C6f-0000c8-00
4015.endd
4016Messages that arrived earlier than \"0t5C6f-0000c8-00"\ are not inspected. If a
4017second message id is given, messages whose ids are lexically greater than it
4018are also skipped. If the same id is given twice, for example,
4019.display
4020exim -q 0t5C6f-0000c8-00 0t5C6f-0000c8-00
4021.endd
4022just one delivery process is started, for that message. This differs from \-M-\
4023in that retry data is respected, and it also differs from \-Mc-\ in that it
4024counts as a delivery from a queue run. Note that the selection mechanism does
4025not affect the order in which the messages are scanned. There are also other
4026ways of selecting specific sets of messages for delivery in a queue run -- see
4027\-R-\ and \-S-\.
4028
4029.option q <<qflags>><<time>>
4030.index queue runner||starting periodically
4031.index periodic queue running
4032When a time value is present, the \-q-\ option causes Exim to run as a daemon,
4033starting a queue runner process at intervals specified by the given time value
4034(whose format is described in section ~~SECTtimeformat). This form of the \-q-\
4035option is commonly combined with the \-bd-\ option, in which case a single
4036daemon process handles both functions. A common way of starting up a combined
4037daemon at system boot time is to use a command such as
4038.display
4039/usr/exim/bin/exim -bd -q30m
4040.endd
4041Such a daemon listens for incoming SMTP calls, and also starts a queue runner
4042process every 30 minutes.
4043
4044When a daemon is started by \-q-\ with a time value, but without \-bd-\, no pid
4045file is written unless one is explicitly requested by the \-oP-\ option.
4046
4047.option qR <<rsflags>>#<<string>>
4048This option is synonymous with \-R-\. It is provided for Sendmail
4049compatibility.
4050
4051.option qS <<rsflags>>#<<string>>
4052This option is synonymous with \-S-\.
4053
4054.option R <<rsflags>>#<<string>>
4055.index queue runner||for specific recipients
4056.index delivery||to given domain
4057.index domain||delivery to
4058The <<rsflags>> may be empty, in which case the white space before the string
4059is optional, unless the string is \*f*\, \*ff*\, \*r*\, \*rf*\, or \*rff*\,
4060which are the possible values for <<rsflags>>. White space is required if
4061<<rsflags>> is not empty.
4062
4063This option is similar to \-q-\ with no time value, that is, it causes Exim to
4064perform a single queue run, except that, when scanning the messages on the
4065queue, Exim processes only those that have at least one undelivered recipient
4066address containing the given string, which is checked in a case-independent
4067way. If the <<rsflags>> start with \*r*\, <<string>> is interpreted as a regular
4068expression; otherwise it is a literal string.
4069
4070Once a message is selected, all its addresses are processed. For the first
4071selected message, Exim overrides any retry information and forces a delivery
4072attempt for each undelivered address. This means that if delivery of any
4073address in the first message is successful, any existing retry information is
4074deleted, and so delivery attempts for that address in subsequently selected
4075messages (which are processed without forcing) will run. However, if delivery
4076of any address does not succeed, the retry information is updated, and in
4077subsequently selected messages, the failing address will be skipped.
4078
4079If the <<rsflags>> contain \*f*\ or \*ff*\, the delivery forcing applies to all
4080selected messages, not just the first;
4081.index frozen messages||forcing delivery
4082frozen messages are included when \*ff*\ is present.
4083
4084The \-R-\ option makes it straightforward to initiate delivery of all messages
4085to a given domain after a host has been down for some time. When the SMTP
4086command \\ETRN\\ is accepted by its ACL (see chapter ~~CHAPACL), its default
4087effect is to run Exim with the \-R-\ option, but it can be configured to run an
4088arbitrary command instead.
4089
4090.option r
4091This is a documented (for Sendmail) obsolete alternative name for \-f-\.
4092
4093.index delivery||from given sender
4094.option S <<rsflags>>#<<string>>
4095.index queue runner||for specific senders
4096This option acts like \-R-\ except that it checks the string against each
4097message's sender instead of against the recipients. If \-R-\ is also set, both
4098conditions must be met for a message to be selected. If either of the options
4099has \*f*\ or \*ff*\ in its flags, the associated action is taken.
4100
4101.em
4102.option Tqt#<<times>>
4103This an option that is exclusively for use by the Exim testing suite.
4104It is not recognized when Exim is run normally. It allows for the setting up
4105of explicit `queue times' so that various warning/retry features can be
4106tested.
4107.nem
4108
4109.option t
4110.index recipient||extracting from header lines
4111.index ::Bcc:: header line
4112.index ::Cc:: header line
4113.index ::To:: header line
4114When Exim is receiving a locally-generated, non-SMTP message on its standard
4115input, the \-t-\ option causes the recipients of the message to be obtained
4116from the ::To::, ::Cc::, and ::Bcc:: header lines in the message instead of from
4117the command arguments. The addresses are extracted before any rewriting takes
4118place.
4119
4120.index Sendmail compatibility||\-t-\ option
4121If the command has any arguments, they specify addresses to which the message
4122is $it{not} to be delivered. That is, the argument addresses are removed from
4123the recipients list obtained from the headers. This is compatible with Smail 3
4124and in accordance with the documented behaviour of several versions of
4125Sendmail, as described in man pages on a number of operating systems (e.g.
4126Solaris 8, IRIX 6.5, HP-UX 11). However, some versions of Sendmail $it{add}
4127argument addresses to those obtained from the headers, and the O'Reilly
4128Sendmail book documents it that way. Exim can be made to add argument addresses
4129instead of subtracting them by setting the option
4130\extract__addresses__remove__arguments\ false.
4131
4132If a ::Bcc:: header line is present, it is removed from the message unless
4133there is no ::To:: or ::Cc::, in which case a ::Bcc:: line with no data is
4134created. This is necessary for conformity with the original RFC 822 standard;
4135the requirement has been removed in RFC 2822, but that is still very new.
4136
4137.index \Resent@-\ header lines||with \-t-\
4138If there are any \Resent@-\ header lines in the message, Exim extracts
4139recipients from all ::Resent-To::, ::Resent-Cc::, and ::Resent-Bcc:: header
4140lines instead of from ::To::, ::Cc::, and ::Bcc::. This is for compatibility
4141with Sendmail and other MTAs. (Prior to release 4.20, Exim gave an error if
4142\-t-\ was used in conjunction with \Resent@-\ header lines.)
4143
4144RFC 2822 talks about different sets of \Resent@-\ header lines (for when a
4145message is resent several times). The RFC also specifies that they should be
4146added at the front of the message, and separated by ::Received:: lines. It is
4147not at all clear how \-t-\ should operate in the present of multiple sets,
4148nor indeed exactly what constitutes a `set'.
4149In practice, it seems that MUAs do not follow the RFC. The \Resent@-\ lines are
4150often added at the end of the header, and if a message is resent more than
4151once, it is common for the original set of \Resent@-\ headers to be renamed as
4152\X-Resent@-\ when a new set is added. This removes any possible ambiguity.
4153
4154.option ti
4155This option is exactly equivalent to \-t-\ \-i-\. It is provided for
4156compatibility with Sendmail.
4157
4158.option tls-on-connect
4159.index TLS||use without STARTTLS
4160.index TLS||automatic start
4161This option is available when Exim is compiled with TLS support. It makes it
4162possible to support legacy clients that do not support the \\STARTTLS\\
4163command, but instead expect to start up a TLS session as soon as a connection
4164to the server is established. These clients use a special port (usually called
4165the `ssmtp' port) instead of the normal SMTP port 25. The \-tls-on-connect-\
4166option can be used to run Exim in this way from \*inetd*\, and it can also be
4167used to run a special daemon that operates in this manner (use \-oX-\ to
4168specify the port). However, although it is possible to run one daemon that
4169listens on several ports, it is not possible to have some of them operate one
4170way and some the other. With only a few clients that need the legacy support, a
4171convenient approach is to use a daemon for normal SMTP (with or without
4172\\STARTTLS\\) and \*inetd*\ with \-tls-on-connect-\ for the legacy clients.
4173
4174.option U
4175.index Sendmail compatibility||\-U-\ option ignored
4176Sendmail uses this option for `initial message submission', and its
4177documentation states that in future releases, it may complain about
4178syntactically invalid messages rather than fixing them when this flag is not
4179set. Exim ignores this option.
4180
4181.option v
4182This option causes Exim to write information to the standard error stream,
4183describing what it is doing. In particular, it shows the log lines for
4184receiving and delivering a message, and if an SMTP connection is made, the SMTP
4185dialogue is shown. Some of the log lines shown may not actually be written to
4186the log if the setting of \log@_selector\ discards them. Any relevant selectors
4187are shown with each log line. If none are shown, the logging is unconditional.
4188
4189.option x
4190AIX uses \-x-\ for a private purpose (`mail from a local mail program has
4191National Language Support extended characters in the body of the mail item').
4192It sets \-x-\ when calling the MTA from its \mail\ command. Exim ignores this
4193option.
4194
4195.endoptions
4196
4197
4198
4199.
4200.
4201.
4202.
4203. ============================================================================
4204.chapter The Exim run time configuration file
4205.set runningfoot "configuration file"
4206.rset CHAPconf ~~chapter
4207
4208.index run time configuration
4209.index configuration file||general description
4210.index \\CONFIGURE@_FILE\\
4211Exim uses a single run time configuration file that is read whenever an Exim
4212binary is executed. Note that in normal operation, this happens frequently,
4213because Exim is designed to operate in a distributed manner, without central
4214control.
4215
4216The name of the configuration file is compiled into the binary for security
4217reasons, and is specified by the \\CONFIGURE@_FILE\\ compilation option. In
4218most configurations, this specifies a single file. However, it is permitted to
4219give a colon-separated list of file names, in which case Exim uses the first
4220existing file in the list.
4221
4222.index \\EXIM@_USER\\
4223.index \\EXIM@_GROUP\\
4224.index configuration file||ownership
4225.index ownership||configuration file
4226The run time configuration file must be owned by root or by the user that
4227is specified at compile time by the \\EXIM@_USER\\ option,
4228.em
4229or by the user that is specified at compile time by the \\CONFIGURE@_OWNER\\
4230option (if set).
4231.nem
4232The configuration file must not be world-writeable or group-writeable, unless
4233its group is the one specified at compile time by the \\EXIM@_GROUP\\ option.
4234
4235\**Warning**\: In a conventional configuration, where the Exim binary is setuid
4236to root, anybody who is able to edit the run time configuration file has an
4237easy way to run commands as root. If you make your mail administrators members
4238of the Exim group, but do not trust them with root, make sure that the run time
4239configuration is not group writeable.
4240
4241
4242A default configuration file, which will work correctly in simple situations,
4243is provided in the file \(src/configure.default)\.
4244If \\CONFIGURE@_FILE\\ defines just one file name, the installation process
4245copies the default configuration to a new file of that name if it did not
4246previously exist. If \\CONFIGURE@_FILE\\ is a list, no default is automatically
4247installed. Chapter ~~CHAPdefconfil is a `walk-through' discussion of the
4248default configuration.
4249
4250.index configuration file||errors in
4251.index error||in configuration file
4252.index return code||for bad configuration
4253If a syntax error is detected while reading the configuration file, Exim
4254writes a message on the standard error, and exits with a non-zero return code.
4255The message is also written to the panic log.
4256
4257
4258.section Using a different configuration file
4259.index configuration file||alternate
4260A one-off alternate configuration can be specified by the \-C-\ command line
4261option, which may specify a single file or a list of files. However, when \-C-\
4262is used, Exim gives up its root privilege, unless called by root or the Exim
4263user (or unless the argument for \-C-\ is identical to the built-in value from
4264\\CONFIGURE@_FILE\\). \-C-\ is useful mainly for checking the syntax of
4265configuration files before installing them. No owner or group checks are done
4266on a configuration file specified by \-C-\.
4267
4268The privileged use of \-C-\ by the Exim user can be locked out by setting
4269\\ALT@_CONFIG@_ROOT@_ONLY\\ in \(Local/Makefile)\ when building Exim. However,
4270if you do this, you also lock out the possibility of testing a
4271configuration using \-C-\ right through message reception and delivery, even if
4272the caller is root. The reception works, but by that time, Exim is running as
4273the Exim user, so when it re-execs to regain privilege for the delivery, the
4274use of \-C-\ causes privilege to be lost. However, root can test reception and
4275delivery using two separate commands (one to put a message on the queue, using
4276\-odq-\, and another to do the delivery, using \-M-\).
4277
4278If \\ALT@_CONFIG@_PREFIX\\ is defined \(in Local/Makefile)\, it specifies a
4279prefix string with which any file named in a \-C-\ command line option must
4280start. In addition, the file name must not contain the sequence \"/../"\. There
4281is no default setting for \\ALT@_CONFIG@_PREFIX\\; when it is unset, any file
4282name can be used with \-C-\.
4283
4284One-off changes to a configuration can be specified by the \-D-\ command line
4285option, which defines and overrides values for macros used inside the
4286configuration file. However, like \-C-\, the use of this option by a
4287non-privileged user causes Exim to discard its root privilege.
4288If \\DISABLE@_D@_OPTION\\ is defined in \(Local/Makefile)\, the use of \-D-\ is
4289completely disabled, and its use causes an immediate error exit.
4290
4291Some sites may wish to use the same Exim binary on different machines that
4292share a file system, but to use different configuration files on each machine.
4293If \\CONFIGURE@_FILE@_USE@_NODE\\ is defined in \(Local/Makefile)\, Exim first
4294looks for a file whose name is the configuration file name followed by a dot
4295and the machine's node name, as obtained from the \*uname()*\ function. If this
4296file does not exist, the standard name is tried. This processing occurs for
4297each file name in the list given by \\CONFIGURE@_FILE\\ or \-C-\.
4298
4299In some esoteric situations different versions of Exim may be run under
4300different effective uids and the \\CONFIGURE@_FILE@_USE@_EUID\\ is defined to
4301help with this. See the comments in \(src/EDITME)\ for details.
4302
4303
4304.section Configuration file format
4305.rset SECTconffilfor "~~chapter.~~section"
4306.index configuration file||format of
4307.index format||configuration file
4308Exim's configuration file is divided into a number of different parts. General
4309option settings must always appear at the start of the file. The other parts
4310are all optional, and may appear in any order. Each part other than the first
4311is introduced by the word `begin' followed by the name of the part. The
4312optional parts are:
4313
4314.numberpars $.
4315\*ACL*\: Access control lists for controlling incoming SMTP mail.
4316.nextp
4317.index \\AUTH\\||configuration
4318\*authenticators*\: Configuration settings for the authenticator drivers. These
4319are concerned with the SMTP \\AUTH\\ command (see chapter ~~CHAPSMTPAUTH).
4320.nextp
4321\*routers*\: Configuration settings for the router drivers. Routers process
4322addresses and determine how the message is to be delivered.
4323.nextp
4324\*transports*\: Configuration settings for the transport drivers. Transports
4325define mechanisms for copying messages to destinations.
4326.nextp
4327\*retry*\: Retry rules, for use when a message cannot be immediately delivered.
4328.nextp
4329\*rewrite*\: Global address rewriting rules, for use when a message arrives and
4330when new addresses are generated during delivery.
4331.nextp
4332\*local@_scan*\: Private options for the \*local@_scan()*\ function. If you
4333want to use this feature, you must set
4334.display asis
4335LOCAL_SCAN_HAS_OPTIONS=yes
4336.endd
4337in \(Local/Makefile)\ before building Exim. Full details of the
4338\*local@_scan()*\ facility are given in chapter ~~CHAPlocalscan.
4339.endp
4340Blank lines in the file, and lines starting with a @# character (ignoring
4341leading white space) are treated as comments and are ignored. \**Note**\: a
4342@# character other than at the beginning of a line is not treated specially,
4343and does not introduce a comment.
4344
4345Any non-comment line can be continued by ending it with a backslash. Trailing
4346white space after the backslash is ignored, and leading white space at the
4347start of continuation lines is also ignored.
4348Comment lines beginning with @# (but not empty lines) may appear in the middle
4349of a sequence of continuation lines.
4350
4351A convenient way to create a configuration file is to start from the
4352default, which is supplied in \(src/configure.default)\, and add, delete, or
4353change settings as required.
4354
4355The ACLs, retry rules, and rewriting rules have their own syntax which is
4356described in chapters ~~CHAPACL, ~~CHAPretry, and ~~CHAPrewrite, respectively.
4357The other parts of the configuration file have some syntactic items in common,
4358and these are described below, from section ~~SECTcos onwards. Before that, the
4359inclusion, macro, and conditional facilities are described.
4360
4361
4362.section File inclusions in the configuration file
4363.index inclusions in configuration file
4364.index configuration file||including other files
4365.index .include in configuration file
4366.index .include@_if@_exists in configuration file
4367You can include other files inside Exim's run time configuration file by
4368using this syntax:
4369.display
4370@.include <<file name>>
4371.endd
4372or
4373.display
4374@.include@_if@_exists <<file name>>
4375.endd
4376on a line by itself. Double quotes round the file name are optional. If you use
4377the first form, a configuration error occurs if the file does not exist; the
4378second form does nothing for non-existent files.
4379
4380Includes may be nested to any depth, but remember that Exim reads its
4381configuration file often, so it is a good idea to keep them to a minimum.
4382If you change the contents of an included file, you must HUP the daemon,
4383because an included file is read only when the configuration itself is read.
4384
4385The processing of inclusions happens early, at a physical line level, so, like
4386comment lines, an inclusion can be used in the middle of an option setting,
4387for example:
4388.display asis
4389hosts_lookup = a.b.c \
4390 .include /some/file
4391.endd
4392Include processing happens
4393after
4394macro processing (see below). Its effect is to process the lines of the file as
4395if they occurred inline where the inclusion appears.
4396
4397
4398.section Macros in the configuration file
4399.rset SECTmacrodefs "~~chapter.~~section"
4400.index macro||description of
4401.index configuration file||macros
4402If a line in the main part of the configuration (that is, before the first
4403`begin' line) begins with an upper case letter, it is taken as a macro
4404definition, and must be of the form
4405.display
4406<<name>> = <<rest of line>>
4407.endd
4408The name must consist of letters, digits, and underscores, and need not all be
4409in upper case, though that is recommended. The rest of the line, including any
4410continuations, is the replacement text, and has leading and trailing white
4411space removed. Quotes are not removed. The replacement text can never end with
4412a backslash character, but this doesn't seem to be a serious limitation.
4413
4414Once a macro is defined, all subsequent lines in the file (and any included
4415files) are scanned for the macro name; if there are several macros, the line is
4416scanned for each in turn, in the order in which they are defined. The
4417replacement text is not re-scanned for the current macro, though it is scanned
4418for subsequently defined macros. For this reason, a macro name may not contain
4419the name of a previously defined macro as a substring. You could, for example,
4420define
4421.display asis
4422ABCD_XYZ = <<something>>
4423ABCD = <<something else>>
4424.endd
4425but putting the definitions in the opposite order would provoke a configuration
4426error.
4427
4428Macro expansion is applied to individual lines from the file, before checking
4429for line continuation or file inclusion (see below). If a line consists solely
4430of a macro name, and the expansion of the macro is empty, the line is ignored.
4431A macro at the start of a line may turn the line into a comment line or a
4432\".include"\ line.
4433
4434As an example of macro usage, consider a configuration where aliases are looked
4435up in a MySQL database. It helps to keep the file less cluttered if long
4436strings such as SQL statements are defined separately as macros, for example:
4437.display asis
4438ALIAS_QUERY = select mailbox from user where \
4439 login=${quote_mysql:$local_part};
4440.endd
4441This can then be used in a \%redirect%\ router setting like this:
4442.display asis
4443data = ${lookup mysql{ALIAS_QUERY}}
4444.endd
4445In earlier versions of Exim macros were sometimes used for domain, host, or
4446address lists. In Exim 4 these are handled better by named lists -- see section
4447~~SECTnamedlists.
4448
4449Macros in the configuration file can be overridden by the \-D-\ command line
4450option, but Exim gives up its root privilege when \-D-\ is used, unless called
4451by root or the Exim user.
4452
4453
4454.section Conditional skips in the configuration file
4455.index configuration file||conditional skips
4456.index .ifdef
4457You can use the directives \".ifdef"\, \".ifndef"\, \".elifdef"\,
4458\".elifndef"\, \".else"\, and \".endif"\ to dynamically include or exclude
4459portions of the configuration file. The processing happens whenever the file is
4460read (that is, when an Exim binary starts to run).
4461
4462The implementation is very simple. Instances of the first four directives must
4463be followed by text that includes the names of one or macros. The condition
4464that is tested is whether or not any macro substitution has taken place in the
4465line. Thus:
4466.display
4467@.ifdef AAA
4468message@_size@_limit = 50M
4469@.else
4470message@_size@_limit = 100M
4471@.endif
4472.endd
4473sets a message size limit of 50M if the macro \"AAA"\ is defined, and 100M
4474otherwise. If there is more than one macro named on the line, the condition
4475is true if any of them are defined. That is, it is an `or' condition. To
4476obtain an `and' condition, you need to use nested \".ifdef"\s.
4477
4478Although you can use a macro expansion to generate one of these directives,
4479it is not very useful, because the condition `there was a macro substitution
4480in this line' will always be true.
4481
4482Text following \".else"\ and \".endif"\ is ignored, and can be used as comment
4483to clarify complicated nestings.
4484
4485
4486.section Common option syntax
4487.rset SECTcos "~~chapter.~~section"
4488.index common option syntax
4489.index syntax of common options
4490.index configuration file||common option syntax
4491For the main set of options, driver options, and \*local@_scan()*\ options,
4492each setting is on a line by itself, and starts with a name consisting of
4493lower-case letters and underscores. Many options require a data value, and in
4494these cases the name must be followed by an equals sign (with optional white
4495space) and then the value. For example:
4496.display asis
4497qualify_domain = mydomain.example.com
4498.endd
4499Some option settings may contain sensitive data, for example, passwords for
4500accessing databases. To stop non-admin users from using the \-bP-\ command line
4501option to read these values, you can precede the option settings with the word
4502`hide'. For example:
4503.display asis
4504hide mysql_servers = localhost/users/admin/secret-password
4505.endd
4506For non-admin users, such options are displayed like this:
4507.display asis
4508mysql_servers = <value not displayable>
4509.endd
4510If `hide' is used on a driver option, it hides the value of that option on all
4511instances of the same driver.
4512
4513The following sections describe the syntax used for the different data types
4514that are found in option settings.
4515
4516.section Boolean options
4517.index format||boolean
4518.index boolean configuration values
4519Options whose type is given as boolean are on/off switches. There are two
4520different ways of specifying such options: with and without a data value. If
4521the option name is specified on its own without data, the switch is turned on;
4522if it is preceded by `no@_' or `not@_' the switch is turned off. However,
4523boolean options may optionally be followed by an equals sign and one of the
4524words `true', `false', `yes', or `no', as an alternative syntax. For example,
4525the following two settings have exactly the same effect:
4526.display asis
4527queue_only
4528queue_only = true
4529.endd
4530The following two lines also have the same (opposite) effect:
4531.display asis
4532no_queue_only
4533queue_only = false
4534.endd
4535You can use whichever syntax you prefer.
4536
4537
4538
4539.section Integer values
4540.index integer configuration values
4541.index format||integer
4542If an integer data item starts with the characters `0x', the remainder of it
4543is interpreted as a hexadecimal number. Otherwise, it is treated as octal if it
4544starts with the digit 0, and decimal if not. If an integer value is followed by
4545the letter K, it is multiplied by 1024; if it is followed by the letter M, it
4546is multiplied by 1024x1024.
4547
4548When the values of integer option settings are output, values which are an
4549exact multiple of 1024 or 1024x1024 are
4550sometimes, but not always,
4551printed using the letters K and M. The printing style is independent of the
4552actual input format that was used.
4553
4554.section Octal integer values
4555.index integer format
4556.index format||octal integer
4557The value of an option specified as an octal integer is always interpreted in
4558octal, whether or not it starts with the digit zero. Such options are always
4559output in octal.
4560
4561
4562.section Fixed point number values
4563.index fixed point configuration values
4564.index format||fixed point
4565A fixed point number consists of a decimal integer, optionally followed by a
4566decimal point and up to three further digits.
4567
4568
4569.section Time interval values
4570.index time interval||specifying in configuration
4571.index format||time interval
4572.rset SECTtimeformat "~~chapter.~~section"
4573A time interval is specified as a sequence of numbers, each followed by one of
4574the following letters, with no intervening white space:
4575.display rm
4576.tabs 5
4577\s\ $t seconds
4578\m\ $t minutes
4579\h\ $t hours
4580\d\ $t days
4581\w\ $t weeks
4582.endd
4583For example, `3h50m' specifies 3 hours and 50 minutes. The values of time
4584intervals are output in the same format.
4585Exim does not restrict the values; it is perfectly acceptable, for example, to
4586specify `90m' instead of `1h30m'.
4587
4588
4589.section String values
4590.index string||format of configuration values
4591.index format||string
4592.rset SECTstrings "~~chapter.~~section"
4593If a string data item does not start with a double-quote character, it is taken
4594as consisting of the remainder of the line plus any continuation lines,
4595starting at the first character after any leading white space, with trailing
4596white space characters removed, and with no interpretation of the characters in
4597the string. Because Exim removes comment lines (those beginning with @#) at an
4598early stage, they can appear in the middle of a multi-line string. The
4599following settings are therefore equivalent:
4600.display asis
4601trusted_users = uucp:mail
4602
4603trusted_users = uucp:\
4604 # This comment line is ignored
4605 mail
4606.endd
4607.index string||quoted
4608.index escape characters in quoted strings
4609If a string does start with a double-quote, it must end with a closing
4610double-quote, and any backslash characters other than those used for line
4611continuation are interpreted as escape characters, as follows:
4612.display
4613.tabs 15
4614@\@\ $t $rm{single backslash}
4615@\n $t $rm{newline}
4616@\r $t $rm{carriage return}
4617@\t $t $rm{tab}
4618@\<<octal digits>> $t $rm{up to 3 octal digits specify one character}
4619@\x<<hex digits>> $t $rm{up to 2 hexadecimal digits specify one character}
4620.endd
4621If a backslash is followed by some other character, including a double-quote
4622character, that character replaces the pair.
4623
4624Quoting is necessary only if you want to make use of the backslash escapes to
4625insert special characters, or if you need to specify a value with leading or
4626trailing spaces. These cases are rare, so quoting is almost never needed in
4627current versions of Exim. In versions of Exim before 3.14, quoting was required
4628in order to continue lines, so you may come across older configuration files
4629and examples that apparently quote unnecessarily.
4630
4631.section Expanded strings
4632.index string||expansion, definition of
4633.index expansion||definition of
4634Some strings in the configuration file are subjected to \*string expansion*\,
4635by which means various parts of the string may be changed according to the
4636circumstances (see chapter ~~CHAPexpand). The input syntax for such strings is
4637as just described; in particular, the handling of backslashes in quoted strings
4638is done as part of the input process, before expansion takes place. However,
4639backslash is also an escape character for the expander, so any backslashes that
4640are required for that reason must be doubled if they are within a quoted
4641configuration string.
4642
4643.section User and group names
4644.index user name||format of
4645.index format||user name
4646.index group||name format
4647.index format||group name
4648User and group names are specified as strings, using the syntax described
4649above, but the strings are interpreted specially. A user or group name must
4650either consist entirely of digits, or be a name that can be looked up using the
4651\*getpwnam()*\ or \*getgrnam()*\ function, as appropriate.
4652
4653.section List construction
4654.index list||syntax of in configuration
4655.index format||list item in configuration
4656.index string list, definition
4657.rset SECTlistconstruct "~~chapter.~~section"
4658The data for some configuration options is a colon-separated list of items.
4659Many of these options are shown with type `string list' in the descriptions
4660later in this document. Others are listed as `domain list', `host list',
4661`address list', or `local part list'. Syntactically, they are all the same;
4662however, those other than `string list' are subject to particular kinds of
4663interpretation, as described in chapter ~~CHAPdomhosaddlists.
4664
4665In all these cases, the entire list is treated as a single string as far as the
4666input syntax is concerned. The \trusted@_users\ setting in section
4667~~SECTstrings above is an example. If a colon is actually needed in an item in
4668a list, it must be entered as two colons. Leading and trailing white space on
4669each item in a list is ignored. This makes it possible to include items that
4670start with a colon, and in particular, certain forms of IPv6 address. For
4671example, the list
4672.display asis
4673local_interfaces = 127.0.0.1 : ::::1
4674.endd
4675contains two IP addresses, the IPv4 address 127.0.0.1 and the IPv6 address
4676@:@:1. IPv6 addresses are going to become more and more common as the new
4677protocol gets more widely deployed.
4678.index list||separator, changing
4679.index IPv6||addresses in lists
4680Doubling their colons is an unwelcome chore, so a mechanism was introduced to
4681allow the separator character to be changed. If a list begins with a left angle
4682bracket, followed by any punctuation character, that character is used instead
4683of colon as the list separator. For example, the list above can be rewritten to
4684use a semicolon separator like this:
4685.display asis
4686local_interfaces = <; 127.0.0.1 ; ::1
4687.endd
4688This facility applies to all lists, with the exception of the list in
4689\log@_file@_path\. It is recommended that the use of non-colon separators be
4690confined to circumstances where they really are needed.
4691
4692
4693.section Format of driver configurations
4694.rset SECTfordricon "~~chapter.~~section"
4695.index drivers||configuration format
4696There are separate parts in the configuration for defining routers, transports,
4697and authenticators. In each part, you are defining a number of driver
4698instances, each with its own set of options. Each driver instance is defined by
4699a sequence of lines like this:
4700.display
4701<<instance name>>:
4702 <<option>>
4703 ...
4704 <<option>>
4705.endd
4706In the following example, the instance name is \%localuser%\, and it is
4707followed by three options settings:
4708.display asis
4709localuser:
4710 driver = accept
4711 check_local_user
4712 transport = local_delivery
4713.endd
4714For each driver instance, you specify which Exim code module it uses -- by the
4715setting of the \driver\ option -- and (optionally) some configuration settings.
4716For example, in the case of transports, if you want a transport to deliver with
4717SMTP you would use the \%smtp%\ driver; if you want to deliver to a local file
4718you would use the \%appendfile%\ driver. Each of the drivers is described in
4719detail in its own separate chapter later in this manual.
4720
4721You can have several routers, transports, or authenticators that are based on
4722the same underlying driver (each must have a different name).
4723
4724The order in which routers are defined is important, because addresses are
4725passed to individual routers one by one, in order. The order in which
4726transports are defined does not matter at all. The order in which
4727authenticators are defined is used only when Exim, as a client, is searching
4728them to find one that matches an authentication mechanism offered by the
4729server.
4730
4731.index generic options
4732.index options||generic, definition of
4733Within a driver instance definition, there are two kinds of option:
4734$it{generic} and $it{private}. The generic options are those that apply to all
4735drivers of the same type (that is, all routers, all transports or all
4736authenticators).
4737The \driver\ option is a generic option that must appear in every definition.
4738.index private options
4739The private options are special for each driver, and none need appear, because
4740they all have default values.
4741
4742The options may appear in any order, except that the \driver\ option must
4743precede any private options, since these depend on the particular driver. For
4744this reason, it is recommended that \driver\ always be the first option.
4745
4746Driver instance names, which are used for reference in log entries and
4747elsewhere, can be any sequence of letters, digits, and underscores (starting
4748with a letter) and must be unique among drivers of the same type. A router and
4749a transport (for example) can each have the same name, but no two router
4750instances can have the same name. The name of a driver instance should not be
4751confused with the name of the underlying driver module. For example, the
4752configuration lines:
4753.display asis
4754remote_smtp:
4755 driver = smtp
4756.endd
4757create an instance of the \%smtp%\ transport driver whose name is
4758\%remote@_smtp%\. The same driver code can be used more than once, with
4759different instance names and different option settings each time. A second
4760instance of the \%smtp%\ transport, with different options, might be defined
4761thus:
4762.display asis
4763special_smtp:
4764 driver = smtp
4765 port = 1234
4766 command_timeout = 10s
4767.endd
4768The names \%remote@_smtp%\ and \%special@_smtp%\ would be used to reference
4769these transport instances from routers, and these names would appear in log
4770lines.
4771
4772Comment lines may be present in the middle of driver specifications. The full
4773list of option settings for any particular driver instance, including all the
4774defaulted values, can be extracted by making use of the \-bP-\ command line
4775option.
4776
4777
4778
4779
4780
4781
4782.
4783.
4784.
4785.
4786. ============================================================================
4787.chapter The default configuration file
4788.set runningfoot "default configuration"
4789.rset CHAPdefconfil "~~chapter"
4790.index configuration file||default, `walk through'
4791.index default||configuration file `walk through'
4792The default configuration file supplied with Exim as \(src/configure.default)\
4793is sufficient for a host with simple mail requirements. As an introduction to
4794the way Exim is configured, this chapter `walks through' the default
4795configuration, giving brief explanations of the settings. Detailed descriptions
4796of the options are given in subsequent chapters. The default configuration file
4797itself contains extensive comments about ways you might want to modify the
4798initial settings. However, note that there are many options that are not
4799mentioned at all in the default configuration.
4800
4801
4802.section Main configuration settings
4803The main (global) configuration option settings must always come first in the
4804file. The first thing you'll see in the file, after some initial comments, is
4805the line
4806.display asis
4807# primary_hostname =
4808.endd
4809This is a commented-out setting of the \primary@_hostname\ option. Exim needs
4810to know the official, fully qualified name of your host, and this is where you
4811can specify it. However, in most cases you do not need to set this option. When
4812it is unset, Exim uses the \*uname()*\ system function to obtain the host name.
4813
4814The first three non-comment configuration lines are as follows:
4815.display asis
4816domainlist local_domains = @
4817domainlist relay_to_domains =
4818hostlist relay_from_hosts = 127.0.0.1
4819.endd
4820These are not, in fact, option settings. They are definitions of two named
4821domain lists and one named host list. Exim allows you to give names to lists of
4822domains, hosts, and email addresses, in order to make it easier to manage the
4823configuration file (see section ~~SECTnamedlists).
4824
4825The first line defines a domain list called \*local@_domains*\; this is used
4826later in the configuration to identify domains that are to be delivered
4827on the local host.
4828.index @@ in a domain list
4829There is just one item in this list, the string `@@'. This is a special form of
4830entry which means `the name of the local host'. Thus, if the local host is
4831called \*a.host.example*\, mail to \*any.user@@a.host.example*\ is expected to
4832be delivered locally. Because the local host's name is referenced indirectly,
4833the same configuration file can be used on different hosts.
4834
4835The second line defines a domain list called \*relay@_to@_domains*\, but the
4836list itself is empty. Later in the configuration we will come to the part that
4837controls mail relaying through the local host; it allows relaying to any
4838domains in this list. By default, therefore, no relaying on the basis of a mail
4839domain is permitted.
4840
4841The third line defines a host list called \*relay@_from@_hosts*\. This list is
4842used later in the configuration to permit relaying from any host or IP address
4843that matches the list. The default contains just the IP address of the IPv4
4844loopback interface, which means that processes on the local host are able to
4845submit mail for relaying by sending it over TCP/IP to that interface. No other
4846hosts are permitted to submit messages for relaying.
4847
4848Just to be sure there's no misunderstanding: at this point in the configuration
4849we aren't actually setting up any controls. We are just defining some domains
4850and hosts that will be used in the controls that are specified later.
4851
4852The next configuration line is a genuine option setting:
4853.display asis
4854acl_smtp_rcpt = acl_check_rcpt
4855.endd
4856This option specifies an \*Access Control List*\ (ACL) which is to be used
4857during an incoming SMTP session for every recipient of a message (every
4858\\RCPT\\ command). The name of the list is \*acl@_check@_rcpt*\, and we will
4859come to its definition below, in the ACL section of the configuration. ACLs
4860control which recipients are accepted for an incoming message -- if a
4861configuration does not provide an ACL to check recipients, no SMTP mail can be
4862accepted.
4863
4864Two commented-out options settings are next:
4865.display asis
4866# qualify_domain =
4867# qualify_recipient =
4868.endd
4869The first of these specifies a domain that Exim uses when it constructs a
4870complete email address from a local login name. This is often needed when Exim
4871receives a message from a local process. If you do not set \qualify@_domain\,
4872the value of \primary@_hostname\ is used. If you set both of these options, you
4873can have different qualification domains for sender and recipient addresses. If
4874you set only the first one, its value is used in both cases.
4875
4876.index domain literal||recognizing format
4877The following line must be uncommented if you want Exim to recognize
4878addresses of the form \*user@@[10.11.12.13]*\ that is, with a `domain literal'
4879(an IP address) instead of a named domain.
4880.display asis
4881# allow_domain_literals
4882.endd
4883.em
4884The RFCs still require this form, but many people think that in the modern
4885Internet it makes little sense to permit mail to be sent to specific hosts by
4886quoting their IP addresses. This ancient format has been used by people who
4887try to abuse hosts by using them for unwanted relaying. However, some
4888people believe there are circumstances (for example, messages addressed to
4889\*postmaster*\) where domain literals are still useful.
4890.nem
4891
4892The next configuration line is a kind of trigger guard:
4893.display asis
4894never_users = root
4895.endd
4896It specifies that no delivery must ever be run as the root user. The normal
4897convention is to set up \*root*\ as an alias for the system administrator. This
4898setting is a guard against slips in the configuration.
4899The list of users specified by \never@_users\ is not, however, the complete
4900list; the build-time configuration in \(Local/Makefile)\ has an option called
4901\\FIXED@_NEVER@_USERS\\ specifying a list that cannot be overridden. The
4902contents of \never@_users\ are added to this list. By default
4903\\FIXED@_NEVER@_USERS\\ also specifies root.
4904
4905When a remote host connects to Exim in order to send mail, the only information
4906Exim has about the host's identity is its IP address. The next configuration
4907line,
4908.display asis
4909host_lookup = *
4910.endd
4911specifies that Exim should do a reverse DNS lookup on all incoming connections,
4912in order to get a host name. This improves the quality of the logging
4913information, but if you feel it is too expensive, you can remove it entirely,
4914or restrict the lookup to hosts on `nearby' networks.
4915Note that it is not always possible to find a host name from an IP address,
4916because not all DNS reverse zones are maintained, and sometimes DNS servers are
4917unreachable.
4918
4919The next two lines are concerned with \*ident*\ callbacks, as defined by RFC
49201413 (hence their names):
4921.display asis
4922rfc1413_hosts = *
4923rfc1413_query_timeout = 30s
4924.endd
4925These settings cause Exim to make ident callbacks for all incoming SMTP calls.
4926You can limit the hosts to which these calls are made, or change the timeout
4927that is used. If you set the timeout to zero, all ident calls are disabled.
4928Although they are cheap and can provide useful information for tracing problem
4929messages, some hosts and firewalls have problems with ident calls. This can
4930result in a timeout instead of an immediate refused connection, leading to
4931delays on starting up an incoming SMTP session.
4932
4933When Exim receives messages over SMTP connections, it expects all addresses to
4934be fully qualified with a domain, as required by the SMTP definition. However,
4935if you are running a server to which simple clients submit messages, you may
4936find that they send unqualified addresses. The two commented-out options:
4937.display asis
4938# sender_unqualified_hosts =
4939# recipient_unqualified_hosts =
4940.endd
4941show how you can specify hosts that are permitted to send unqualified sender
4942and recipient addresses, respectively.
4943
4944The \percent@_hack@_domains\ option is also commented out:
4945.display asis
4946# percent_hack_domains =
4947.endd
4948It provides a list of domains for which the `percent hack' is to operate. This
4949is an almost obsolete form of explicit email routing. If you do not know
4950anything about it, you can safely ignore this topic.
4951
4952The last two settings in the main part of the default configuration are
4953concerned with messages that have been `frozen' on Exim's queue. When a message
4954is frozen, Exim no longer continues to try to deliver it. Freezing occurs when
4955a bounce message encounters a permanent failure because the sender address of
4956the original message that caused the bounce is invalid, so the bounce cannot be
4957delivered. This is probably the most common case, but there are also other
4958conditions that cause freezing, and frozen messages are not always bounce
4959messages.
4960.display asis
4961ignore_bounce_errors_after = 2d
4962timeout_frozen_after = 7d
4963.endd
4964The first of these options specifies that failing bounce messages are to be
4965discarded after 2 days on the queue. The second specifies that any frozen
4966message (whether a bounce message or not) is to be timed out (and discarded)
4967after a week. In this configuration, the first setting ensures that no failing
4968bounce message ever lasts a week.
4969
4970
4971.section ACL configuration
4972.index default||ACLs
4973.index ~~ACL||default configuration
4974In the default configuration, the ACL section follows the main configuration.
4975It starts with the line
4976.display asis
4977begin acl
4978.endd
4979and it contains the definition of one ACL called \*acl@_check@_rcpt*\ that was
4980referenced in the setting of \acl@_smtp@_rcpt\ above.
4981.index \\RCPT\\||ACL for
4982This ACL is used for every \\RCPT\\ command in an incoming SMTP message. Each
4983\\RCPT\\ command specifies one of the message's recipients. The ACL statements
4984are considered in order, until the recipient address is either accepted or
4985rejected. The \\RCPT\\ command is then accepted or rejected, according to the
4986result of the ACL processing.
4987.display asis
4988acl_check_rcpt:
4989.endd
4990This line, consisting of a name terminated by a colon, marks the start of the
4991ACL, and names it.
4992.display asis
4993accept hosts = :
4994.endd
4995This ACL statement accepts the recipient if the sending host matches the list.
4996But what does that strange list mean? It doesn't actually contain any host
4997names or IP addresses. The presence of the colon puts an empty item in the
4998list; Exim matches this only if the incoming message didn't come from a remote
4999host. The colon is important. Without it, the list itself is empty, and can
5000never match anything.
5001
5002What this statement is doing is to accept unconditionally all recipients in
5003messages that are submitted by SMTP from local processes using the standard
5004input and output (that is, not using TCP/IP). A number of MUAs operate in this
5005manner.
5006.display asis
5007deny domains = +local_domains
5008 local_parts = ^[.] : ^.*[@%!/|]
5009
5010deny domains = !+local_domains
5011 local_parts = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
5012.endd
5013These statements are concerned with local parts that contain any of the
5014characters `@@', `%', `!', `/', `|', or dots in unusual places. Although these
5015characters are entirely legal in local parts (in the case of `@@' and leading
5016dots, only if correctly quoted), they do not commonly occur in Internet mail
5017addresses.
5018
5019The first three have in the past been associated with explicitly routed
5020addresses (percent is still sometimes used -- see the \percent@_hack@_domains\
5021option). Addresses containing these characters are regularly tried by spammers
5022in an attempt to bypass relaying restrictions, and also by open relay testing
5023programs. Unless you really need them it is safest to reject these characters
5024at this early stage. This configuration is heavy-handed in rejecting these
5025characters for all messages it accepts from remote hosts. This is a deliberate
5026policy of being as safe as possible.
5027
5028The first rule above is stricter, and is applied to messages that are addressed
5029to one of the local domains handled by this host. This is implemented by the
5030first condition, which restricts it to domains that are listed in the
5031\*local@_domains*\ domain list. The `+' character is used to indicate a
5032reference to a named list. In this configuration, there is just one domain in
5033\*local@_domains*\, but in general there may be many.
5034
5035The second condition on the first statement uses two regular expressions to
5036block local parts that begin with a dot or contain `@@', `%', `!', `/', or `|'.
5037If you have local accounts that include these characters, you will have to
5038modify this rule.
5039
5040Empty components (two dots in a row) are not valid in RFC 2822, but Exim
5041allows them because they have been encountered in practice. (Consider local
5042parts constructed as `first-initial.second-initial.family-name' when applied to
5043someone like the author of Exim, who has no second initial.) However, a local
5044part starting with a dot or containing `/../' can cause trouble if it is used
5045as part of a file name (for example, for a mailing list). This is also true for
5046local parts that contain slashes. A pipe symbol can also be troublesome if the
5047local part is incorporated unthinkingly into a shell command line.
5048
5049The second rule above applies to all other domains, and is less strict. This
5050allows your own users to send outgoing messages to sites that use slashes
5051and vertical bars in their local parts. It blocks local parts that begin
5052with a dot, slash, or vertical bar, but allows these characters within the
5053local part. However, the sequence `/../' is barred. The use of `@@', `%', and
5054`!' is blocked, as before. The motivation here is to prevent your users (or
5055your users' viruses) from mounting certain kinds of attack on remote sites.
5056
5057.display asis
5058accept local_parts = postmaster
5059 domains = +local_domains
5060.endd
5061This statement, which has two conditions, accepts an incoming address if the
5062local part is \*postmaster*\ and the domain is one of those listed in the
5063\*local@_domains*\ domain list. The `+' character is used to indicate a
5064reference to a named list. In this configuration, there is just one domain in
5065\*local@_domains*\, but in general there may be many.
5066
5067The presence of this statement means that mail to postmaster is never blocked
5068by any of the subsequent tests. This can be helpful while sorting out problems
5069in cases where the subsequent tests are incorrectly denying access.
5070.display asis
5071require verify = sender
5072.endd
5073This statement requires the sender address to be verified before any subsequent
5074ACL statement can be used. If verification fails, the incoming recipient
5075address is refused. Verification consists of trying to route the address, to
5076see if a
5077bounce
5078message could be delivered to it. In the case of remote addresses, basic
5079verification checks only the domain, but \*callouts*\ can be used for more
5080verification if required. Section ~~SECTaddressverification discusses the
5081details of address verification.
5082
5083.display asis
5084# deny message = rejected because $sender_host_address is \
5085# in a black list at $dnslist_domain\n\
5086# $dnslist_text
5087# dnslists = black.list.example
5088#
5089# warn message = X-Warning: $sender_host_address is \
5090# in a black list at $dnslist_domain
5091# log_message = found in $dnslist_domain
5092# dnslists = black.list.example
5093.endd
5094These commented-out lines are examples of how you could configure Exim to check
5095sending hosts against a DNS black list. The first statement rejects messages
5096from blacklisted hosts, whereas the second merely inserts a warning header
5097line.
5098
5099.display asis
5100accept domains = +local_domains
5101 endpass
5102 message = unknown user
5103 verify = recipient
5104.endd
5105This statement accepts the incoming recipient address if its domain is one of
5106the local domains, but only if the address can be verified. Verification of
5107local addresses normally checks both the local part and the domain. The
5108\endpass\ line needs some explanation: if the condition above \endpass\ fails,
5109that is, if the address is not in a local domain, control is passed to the next
5110ACL statement. However, if the condition below \endpass\ fails, that is, if a
5111recipient in a local domain cannot be verified, access is denied and the
5112recipient is rejected.
5113.index customizing||ACL failure message
5114The \message\ modifier provides a customized error message for the failure.
5115.display asis
5116accept domains = +relay_to_domains
5117 endpass
5118 message = unrouteable address
5119 verify = recipient
5120.endd
5121This statement accepts the incoming recipient address if its domain is one of
5122the domains for which this host is a relay, but again, only if the address can
5123be verified.
5124.display asis
5125accept hosts = +relay_from_hosts
5126.endd
5127Control reaches this statement only if the recipient's domain is neither a
5128local domain, nor a relay domain. The statement accepts the address if the
5129message is coming from one of the hosts that are defined as being allowed to
5130relay through this host. Recipient verification is omitted here, because in
5131many cases the clients are dumb MUAs that do not cope well with SMTP error
5132responses. If you are actually relaying out from MTAs, you should probably add
5133recipient verification here.
5134.display asis
5135accept authenticated = *
5136.endd
5137Control reaches here for attempts to relay to arbitrary domains from arbitrary
5138hosts. The statement accepts the address only if the client host has
5139authenticated itself. The default configuration does not define any
5140authenticators, which means that no client can in fact authenticate. You will
5141need to add authenticator definitions if you want to make use of this ACL
5142statement.
5143.display asis
5144deny message = relay not permitted
5145.endd
5146The final statement denies access, giving a specific error message. Reaching
5147the end of the ACL also causes access to be denied, but with the generic
5148message `administrative prohibition'.
5149
5150
5151.section Router configuration
5152.index default||routers
5153.index routers||default
5154The router configuration comes next in the default configuration, introduced
5155by the line
5156.display asis
5157begin routers
5158.endd
5159Routers are the modules in Exim that make decisions about where to send
5160messages. An address is passed to each router in turn, until it is either
5161accepted, or failed. This means that the order in which you define the routers
5162matters. Each router is fully described in its own chapter later in this
5163manual. Here we give only brief overviews.
5164
5165.index domain literal||default router
5166.display asis
5167# domain_literal:
5168# driver = ipliteral
5169# domains = !+local_domains
5170# transport = remote_smtp
5171.endd
5172This router is commented out because the majority of sites do not want to
5173support domain literal addresses (those of the form \*user@@[10.9.8.7]*\). If
5174you uncomment this router, you also need to uncomment the setting of
5175\allow@_domain@_literals\ in the main part of the configuration.
5176
5177.display asis
5178dnslookup:
5179 driver = dnslookup
5180 domains = ! +local_domains
5181 transport = remote_smtp
5182.newline
5183 ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
5184.newline
5185 no_more
5186.endd
5187The first uncommented router handles addresses that do not involve any local
5188domains. This is specified by the line
5189.display asis
5190domains = ! +local_domains
5191.endd
5192The \domains\ option lists the domains to which this router applies, but the
5193exclamation mark is a negation sign, so the router is used only for domains
5194that are not in the domain list called \*local@_domains*\ (which was defined at
5195the start of the configuration). The plus sign before \*local@_domains*\
5196indicates that it is referring to a named list. Addresses in other domains are
5197passed on to the following routers.
5198
5199The name of the router driver is \%dnslookup%\,
5200and is specified by the \driver\ option. Do not be confused by the fact that
5201the name of this router instance is the same as the name of the driver. The
5202instance name is arbitrary, but the name set in the \driver\ option must be one
5203of the driver modules that is in the Exim binary.
5204
5205The \%dnslookup%\ router routes addresses by looking up their domains in the
5206DNS in order to obtain a list of hosts to which the address is routed. If the
5207router succeeds, the address is queued for the \%remote@_smtp%\ transport, as
5208specified by the \transport\ option. If the router does not find the domain in
5209the DNS, no further routers are tried because of the \no@_more\ setting, so the
5210address fails and is bounced.
5211
5212The \ignore@_target@_hosts\ option specifies a list of IP addresses that are to
5213be entirely ignored. This option is present because a number of cases have been
5214encountered where MX records in the DNS point to host names
5215whose IP addresses are 0.0.0.0 or are in the 127 subnet (typically 127.0.0.1).
5216Completely ignoring these IP addresses causes Exim to fail to route the
5217email address, so it bounces. Otherwise, Exim would log a routing problem, and
5218continue to try to deliver the message periodically until the address timed
5219out.
5220.display asis
5221system_aliases:
5222 driver = redirect
5223 allow_fail
5224 allow_defer
5225 data = ${lookup{$local_part}lsearch{/etc/aliases}}
5226# user = exim
5227 file_transport = address_file
5228 pipe_transport = address_pipe
5229.endd
5230Control reaches this and subsequent routers only for addresses in the local
5231domains. This router checks to see whether the local part is defined as an
5232alias in the \(/etc/aliases)\ file, and if so, redirects it according to the
5233data that it looks up from that file. If no data is found for the local part,
5234the value of the \data\ option is empty, causing the address to be passed to
5235the next router.
5236
5237\(/etc/aliases)\ is a conventional name for the system aliases file that is
5238often used. That is why it is referenced by from the default configuration
5239file. However, you can change this by setting \\SYSTEM@_ALIASES@_FILE\\ in
5240\(Local/Makefile)\ before building Exim.
5241
5242.display asis
5243userforward:
5244 driver = redirect
5245 check_local_user
5246 file = $home/.forward
5247 no_verify
5248 no_expn
5249 check_ancestor
5250# allow_filter
5251 file_transport = address_file
5252 pipe_transport = address_pipe
5253 reply_transport = address_reply
5254.endd
5255This is the most complicated router in the default configuration. It is another
5256redirection router, but this time it is looking for forwarding data set up by
5257individual users. The \check@_local@_user\ setting means that the first thing it
5258does is to check that the local part of the address is the login name of a
5259local user. If it is not, the router is skipped. When a local user is found,
5260the file called \(.forward)\ in the user's home directory is consulted. If it
5261does not exist, or is empty, the router declines. Otherwise, the contents of
5262\(.forward)\ are interpreted as redirection data (see chapter ~~CHAPredirect
5263for more details).
5264
5265.index Sieve filter||enabling in default router
5266Traditional \(.forward)\ files contain just a list of addresses, pipes, or
5267files. Exim supports this by default. However, if \allow@_filter\ is set (it is
5268commented out by default), the contents of the file are interpreted as a set of
5269Exim or Sieve filtering instructions, provided the file begins with `@#Exim
5270filter' or `@#Sieve filter', respectively. User filtering is discussed in the
5271separate document entitled \*Exim's interfaces to mail filtering*\.
5272
5273The \no@_verify\ and \no@_expn\ options mean that this router is skipped when
5274verifying addresses, or when running as a consequence of an SMTP \\EXPN\\
5275command.
5276There are two reasons for doing this:
5277.numberpars
5278Whether or not a local user has a \(.forward)\ file is not really relevant when
5279checking an address for validity; it makes sense not to waste resources doing
5280unnecessary work.
5281.nextp
5282More importantly, when Exim is verifying addresses or handling an \\EXPN\\
5283command during an SMTP session, it is running as the Exim user, not as root.
5284The group is the Exim group, and no additional groups are set up.
5285It may therefore not be possible for Exim to read users' \(.forward)\ files at
5286this time.
5287.endp
5288
5289The setting of \check@_ancestor\ prevents the router from generating a new
5290address that is the same as any previous address that was redirected. (This
5291works round a problem concerning a bad interaction between aliasing and
5292forwarding -- see section ~~SECTredlocmai).
5293
5294The final three option settings specify the transports that are to be used when
5295forwarding generates a direct delivery to a file, or to a pipe, or sets up an
5296auto-reply, respectively. For example, if a \(.forward)\ file contains
5297.display asis
5298a.nother@elsewhere.example, /home/spqr/archive
5299.endd
5300the delivery to \(/home/spqr/archive)\ is done by running the \address@_file\
5301transport.
5302.display asis
5303localuser:
5304 driver = accept
5305 check_local_user
5306 transport = local_delivery
5307.endd
5308The final router sets up delivery into local mailboxes, provided that the local
5309part is the name of a local login, by accepting the address and queuing it for
5310the \%local@_delivery%\ transport. Otherwise, we have reached the end of the
5311routers, so the address is bounced.
5312
5313
5314.section Transport configuration
5315.index default||transports
5316.index transports||default
5317Transports define mechanisms for actually delivering messages. They operate
5318only when referenced from routers, so the order in which they are defined does
5319not matter. The transports section of the configuration starts with
5320.display asis
5321begin transports
5322.endd
5323One remote transport and four local transports are defined.
5324.display asis
5325remote_smtp:
5326 driver = smtp
5327.endd
5328This transport is used for delivering messages over SMTP connections. All its
5329options are defaulted. The list of remote hosts comes from the router.
5330.display asis
5331local_delivery:
5332 driver = appendfile
5333 file = /var/mail/$local_part
5334 delivery_date_add
5335 envelope_to_add
5336 return_path_add
5337# group = mail
5338# mode = 0660
5339.endd
5340This \%appendfile%\ transport is used for local delivery to user mailboxes in
5341traditional BSD mailbox format. By default it runs under the uid and gid of the
5342local user, which requires the sticky bit to be set on the \(/var/mail)\
5343directory. Some systems use the alternative approach of running mail deliveries
5344under a particular group instead of using the sticky bit. The commented options
5345show how this can be done.
5346
5347Exim adds three headers to the message as it delivers it: ::Delivery-date::,
5348::Envelope-to:: and ::Return-path::. This action is requested by the three
5349similarly-named options above.
5350.display asis
5351address_pipe:
5352 driver = pipe
5353 return_output
5354.endd
5355This transport is used for handling deliveries to pipes that are generated by
5356redirection (aliasing or users' \(.forward)\ files). The \return@_output\
5357option specifies that any output generated by the pipe is to be returned to the
5358sender.
5359.display asis
5360address_file:
5361 driver = appendfile
5362 delivery_date_add
5363 envelope_to_add
5364 return_path_add
5365.endd
5366This transport is used for handling deliveries to files that are generated by
5367redirection. The name of the file is not specified in this instance of
5368\%appendfile%\, because it comes from the \%redirect%\ router.
5369.display asis
5370address_reply:
5371 driver = autoreply
5372.endd
5373This transport is used for handling automatic replies generated by users'
5374filter files.
5375
5376
5377.section Default retry rule
5378.index retry||default rule
5379.index default||retry rule
5380The retry section of the configuration file contains rules which affect the way
5381Exim retries deliveries that cannot be completed at the first attempt. It is
5382introduced by the line
5383.display asis
5384begin retry
5385.endd
5386In the default configuration, there is just one rule, which applies to all
5387errors:
5388.display asis
5389* * F,2h,15m; G,16h,1h,1.5; F,4d,6h
5390.endd
5391This causes any temporarily failing address to be retried every 15 minutes for
53922 hours, then at intervals starting at one hour and increasing by a factor of
53931.5 until 16 hours have passed, then every 6 hours up to 4 days. If an address
5394is not delivered after 4 days of failure, it is bounced.
5395
5396
5397.section Rewriting configuration
5398The rewriting section of the configuration, introduced by
5399.display asis
5400begin rewrite
5401.endd
5402contains rules for rewriting addresses in messages as they arrive. There are no
5403rewriting rules in the default configuration file.
5404
5405
5406.section Authenticators configuration
5407.index \\AUTH\\||configuration
5408The authenticators section of the configuration, introduced by
5409.display asis
5410begin authenticators
5411.endd
5412defines mechanisms for the use of the SMTP \\AUTH\\ command. No authenticators
5413are specified in the default configuration file.
5414
5415
5416
5417.
5418.
5419.
5420.
5421. ============================================================================
5422.chapter Regular expressions
5423.set runningfoot "regular expressions"
5424.rset CHAPregexp ~~chapter
5425
5426.index regular expressions||library
5427.index PCRE
5428Exim supports the use of regular expressions in many of its options. It
5429uses the PCRE regular expression library; this provides regular expression
5430matching that is compatible with Perl 5. The syntax and semantics of
5431regular expressions is discussed in many Perl reference books, and also in
5432Jeffrey Friedl's
5433.if ~~html
5434[(A HREF="http://www.oreilly.com/catalog/regex/")]
5435.fi
5436$it{Mastering Regular Expressions}
5437.if ~~html
5438[(/A)]
5439.fi
5440(O'Reilly, ISBN 0-596-00289-0).
5441
5442The documentation for the syntax and semantics of the regular expressions that
5443are supported by PCRE is included in plain text in the file
5444\(doc/pcrepattern.txt)\ in the Exim distribution, and also in the HTML
5445tarbundle of Exim documentation, and as an appendix to the
5446.if ~~html
5447[(A HREF="http://www.uit.co.uk/exim-book/")]
5448.fi
5449Exim book.
5450.if ~~html
5451[(/A)]
5452.fi
5453It describes in detail the features of the regular expressions that PCRE
5454supports, so no further description is included here. The PCRE functions are
5455called from Exim using the default option settings (that is, with no PCRE
5456options set), except that the \\PCRE@_CASELESS\\ option is set when the
5457matching is required to be case-insensitive.
5458
5459.em
5460In most cases, when a regular expression is required in an Exim configuration,
5461it has to start with a circumflex, in order to distinguish it from plain text
5462or an `ends with' wildcard. In this example of a configuration setting, the
5463second item in the colon-separated list is a regular expression.
5464.display asis
5465domains = a.b.c : ^\\d{3} : *.y.z : ...
5466.endd
5467The doubling of the backslash is required because of string expansion that
5468precedes interpretation -- see section ~~SECTlittext for more discussion of
5469this issue, and a way of avoiding the need for doubling backslashes. The
5470regular expression that is eventually used in this example contains just one
5471backslash. The circumflex is included in the regular expression, and has the
5472normal effect of `anchoring' it to the start of the string that is being
5473matched.
5474
5475There are, however, two cases where a circumflex is not required for the
5476recognition of a regular expression: these are the \match\ condition in a
5477string expansion, and the \matches\ condition in an Exim filter file. In these
5478cases, the relevant string is always treated as a regular expression; if it
5479does not start with a circumflex, the expression is not anchored, and can match
5480anywhere in the subject string.
5481
5482In all cases, if you want a regular expression to match at the end of a string,
5483you must code the @$ metacharacter to indicate this. For example:
5484.display asis
5485domains = ^\\d{3}\\.example
5486.endd
5487matches the domain \*123.example*\, but it also matches \*123.example.com*\.
5488You need to use:
5489.display asis
5490domains = ^\\d{3}\\.example\$
5491.endd
5492if you want \*example*\ to be the top-level domain. (The backslash before the
5493@$ is another artefact of string expansion.)
5494.nem
5495
5496
5497.section Testing regular expressions
5498.index testing||regular expressions
5499.index regular expressions||testing
5500.index \*pcretest*\
5501A program called \*pcretest*\ forms part of the PCRE distribution and is built
5502with PCRE during the process of building Exim. It is primarily intended for
5503testing PCRE itself, but it can also be used for experimenting with regular
5504expressions. After building Exim, the binary can be found in the build
5505directory (it is not installed anywhere automatically). There is documentation
5506of various options in \(doc/pcretest.txt)\, but for simple testing, none are
5507needed. This is the output of a sample run of \*pcretest*\:
5508.display
5509 re> $cb{/^([^@@]+)@@.+@\.(ac|edu)@\.(?!kr)[a-z]@{2@}@$/}
5510data> $cb{x@@y.ac.uk}
5511 0: x@@y.ac.uk
5512 1: x
5513 2: ac
5514data> $cb{x@@y.ac.kr}
5515No match
5516data> $cb{x@@y.edu.com}
5517No match
5518data> $cb{x@@y.edu.co}
5519 0: x@@y.edu.co
5520 1: x
5521 2: edu
5522.endd
5523.if ~~sys.fancy
5524Input typed by the user is shown in bold face.
5525.fi
5526After the `re>' prompt, a regular expression enclosed in delimiters is
5527expected. If this compiles without error, `data>' prompts are given for strings
5528against which the expression is matched. An empty data line causes a new
5529regular expression to be read. If the match is successful, the captured
5530substring values (that is, what would be in the variables \$0$\, \$1$\, \$2$\,
5531etc.) are shown. The above example tests for an email address whose domain ends
5532with either `ac' or `edu' followed by a two-character top-level domain that is
5533not `kr'. The local part is captured in \$1$\ and the `ac' or `edu' in \$2$\.
5534
5535
5536
5537
5538
5539
5540.
5541.
5542.
5543.
5544. ============================================================================
5545.chapter File and database lookups
5546.set runningfoot "file/database lookups"
5547.rset CHAPfdlookup "~~chapter"
5548.index file||lookup
5549.index database lookups
5550.index lookup||description of
5551Exim can be configured to look up data in files or databases as it processes
5552messages. Two different kinds of syntax are used:
5553.numberpars
5554A string that is to be expanded may contain explicit lookup requests. These
5555cause parts of the string to be replaced by data that is obtained from the
5556lookup.
5557.nextp
5558Lists of domains, hosts, and email addresses can contain lookup requests as a
5559way of avoiding excessively long linear lists. In this case, the data that is
5560returned by the lookup is often (but not always) discarded; whether the lookup
5561succeeds or fails is what really counts. These kinds of list are described in
5562chapter ~~CHAPdomhosaddlists.
5563.endp
5564It is easy to confuse the two different kinds of lookup, especially as the
5565lists that may contain the second kind are always expanded before being
5566processed as lists. Therefore, they may also contain lookups of the first kind.
5567Be careful to distinguish between the following two examples:
5568.display asis
5569domains = ${lookup{$sender_host_address}lsearch{/some/file}}
5570domains = lsearch;/some/file
5571.endd
5572The first uses a string expansion, the result of which must be a domain list.
5573String expansions are described in detail in chapter ~~CHAPexpand. The
5574expansion takes place first, and the file that is searched could contain lines
5575like this:
5576.display asis
5577192.168.3.4: domain1 : domain2 : ...
5578192.168.1.9: domain3 : domain4 : ...
5579.endd
5580Thus, the result of the expansion is a list of domains (and possibly other
5581types of item that are allowed in domain lists).
5582
5583In the second case, the lookup is a single item in a domain list. It causes
5584Exim to use a lookup to see if the domain that is being processed can be found
5585in the file. The file could contains lines like this:
5586.display asis
5587domain1:
5588domain2:
5589.endd
5590Any data that follows the keys is not relevant when checking that the domain
5591matches the list item.
5592
5593It is possible to use both kinds of lookup at once. Consider a file containing
5594lines like this:
5595.display asis
5596192.168.5.6: lsearch;/another/file
5597.endd
5598If the value of \$sender@_host@_address$\ is 192.168.5.6, expansion of the
5599first \domains\ setting above generates the second setting, which therefore
5600causes a second lookup to occur.
5601
5602The rest of this chapter describes the different lookup types that are
5603available. Any of them can be used in either of the circumstances described
5604above. The syntax requirements for the two cases are described in chapters
5605~~CHAPexpand and ~~CHAPdomhosaddlists, respectively.
5606
5607.section Lookup types
5608.index lookup||types of
5609.index single-key lookup||definition of
5610Two different styles of data lookup are implemented:
5611.numberpars $.
5612The \*single-key*\ style requires the specification of a file in which to look,
5613and a single key to search for. The lookup type determines how the file is
5614searched.
5615.nextp
5616.index query-style lookup||definition of
5617The \*query*\ style accepts a generalized database query.
5618No particular key value is assumed by Exim for query-style lookups. You can
5619use whichever Exim variable(s) you need to construct the database query.
5620.endp
5621The code for each lookup type is in a separate source file that is included in
5622the binary of Exim only if the corresponding compile-time option is set. The
5623default settings in \(src/EDITME)\ are:
5624.display asis
5625LOOKUP_DBM=yes
5626LOOKUP_LSEARCH=yes
5627.endd
5628which means that only linear searching and DBM lookups are included by default.
5629For some types of lookup (e.g. SQL databases), you need to install appropriate
5630libraries and header files before building Exim.
5631
5632
5633
5634.section Single-key lookup types
5635.rset SECTsinglekeylookups "~~chapter.~~section"
5636.index lookup||single-key types
5637.index single-key lookup||list of types
5638The following single-key lookup types are implemented:
5639.numberpars $.
5640.index cdb||description of
5641.index lookup||cdb
5642.index binary zero||in lookup key
5643\%cdb%\: The given file is searched as a Constant DataBase file, using the key
5644string without a terminating binary zero. The cdb format is designed for
5645indexed files that are read frequently and never updated, except by total
5646re-creation. As such, it is particulary suitable for large files containing
5647aliases or other indexed data referenced by an MTA. Information about cdb can
5648be found in several places:
5649.display rm
5650\?http://www.pobox.com/@~djb/cdb.html?\
5651\?ftp://ftp.corpit.ru/pub/tinycdb/?\
5652\?http://packages.debian.org/stable/utils/freecdb.html?\
5653.endd
5654A cdb distribution is not needed in order to build Exim with cdb support,
5655because the code for reading cdb files is included directly in Exim itself.
5656However, no means of building or testing cdb files is provided with Exim, so
5657you need to obtain a cdb distribution in order to do this.
5658.nextp
5659.index DBM||lookup type
5660.index lookup||dbm
5661.index binary zero||in lookup key
5662\%dbm%\: Calls to DBM library functions are used to extract data from the given
5663DBM file by looking up the record with the given key. A terminating binary
5664zero is included in the key that is passed to the DBM library. See section
5665~~SECTdb for a discussion of DBM libraries.
5666.index Berkeley DB library||file format
5667For all versions of Berkeley DB, Exim uses the \\DB@_HASH\\ style of database
5668when building DBM files using the \exim@_dbmbuild\ utility. However, when using
5669Berkeley DB versions 3 or 4, it opens existing databases for reading with the
5670\\DB@_UNKNOWN\\ option. This enables it to handle any of the types of database
5671that the library supports, and can be useful for accessing DBM files created by
5672other applications. (For earlier DB versions, \\DB@_HASH\\ is always used.)
5673
5674.nextp
5675.index lookup||dbmnz
5676.index lookup||dbm, terminating zero
5677.index binary zero||in lookup key
5678.index Courier
5679.index \(/etc/userdbshadow.dat)\
5680.index dmbnz lookup type
5681\%dbmnz%\: This is the same as \%dbm%\, except that a terminating binary zero
5682is not included in the key that is passed to the DBM library. You may need this
5683if you want to look up data in files that are created by or shared with some
5684other application that does not use terminating zeros. For example, you need to
5685use \%dbmnz%\ rather than \%dbm%\ if you want to authenticate incoming SMTP
5686calls using the passwords from Courier's \(/etc/userdbshadow.dat)\ file. Exim's
5687utility program for creating DBM files (\*exim@_dbmbuild*\) includes the zeros
5688by default, but has an option to omit them (see section ~~SECTdbmbuild).
5689.nextp
5690.index lookup||dsearch
5691.index dsearch lookup type
5692\%dsearch%\: The given file must be a directory; this is searched for a file
5693whose name is the key. The key may not contain any forward slash characters.
5694The result of a successful lookup is the name of the file. An example of how
5695this lookup can be used to support virtual domains is given in section
5696~~SECTvirtualdomains.
5697.nextp
5698.index lookup||iplsearch
5699.index iplsearch lookup type
5700.em
5701\%iplsearch%\: The given file is a text file containing keys and data. A key is
5702terminated by a colon or white space or the end of the line. The keys in the
5703file must be IP addresses, or IP addresses with CIDR masks. Keys that involve
5704IPv6 addresses must be enclosed in quotes to prevent the first internal colon
5705being interpreted as a key terminator. For example:
5706.display asis
57071.2.3.4: data for 1.2.3.4
5708192.168.0.0/16 data for 192.168.0.0/16
5709"abcd::cdab": data for abcd::cdab
5710"abcd:abcd::/32" data for abcd:abcd::/32
5711.endd
5712The key for an \%iplsearch%\ lookup must be an IP address (without a mask). The
5713file is searched linearly, using the CIDR masks where present, until a matching
5714key is found. The first key that matches is used; there is no attempt to find a
5715`best' match. Apart from the way the keys are matched, the processing for
5716\%iplsearch%\ is the same as for \%lsearch%\.
5717
5718\**Warning 1**\: Unlike most other single-key lookup types, a file of data for
5719\%iplsearch%\ can \*not*\ be turned into a DBM or cdb file, because those
5720lookup types support only literal keys.
5721
5722\**Warning 2**\: In a host list, you must always use \%net-iplsearch%\ so that
5723the implicit key is the host's IP address rather than its name (see section
5724~~SECThoslispatsikey).
5725.nem
5726
5727.nextp
5728.index linear search
5729.index lookup||lsearch
5730.index lsearch lookup type
5731\%lsearch%\: The given file is a text file that is searched linearly for a
5732line beginning with the search key, terminated by a colon or white space or the
5733end of the line. The first occurrence that is found in the file is used. White
5734space between the key and the colon is permitted. The remainder of the line,
5735with leading and trailing white space removed, is the data. This can be
5736continued onto subsequent lines by starting them with any amount of white
5737space, but only a single space character is included in the data at such a
5738junction. If the data begins with a colon, the key must be terminated by a
5739colon, for example:
5740.display
5741baduser: :fail:
5742.endd
5743Empty lines and lines beginning with @# are ignored, even if they occur in the
5744middle of an item. This is the traditional textual format of alias files. Note
5745that the keys in an \%lsearch%\ file are literal strings. There is no
5746wildcarding of any kind.
5747
5748.index lookup||lsearch, colons in keys
5749In most \%lsearch%\ files, keys are not required to contain colons
5750.em
5751or @# characters, or
5752.nem
5753whitespace. However, if you need this feature, it is available. If a key begins
5754with a doublequote character, it is terminated only by a matching quote (or end
5755of line), and the normal escaping rules apply to its contents (see section
5756~~SECTstrings). An optional colon is permitted after quoted keys (exactly as
5757for unquoted keys). There is no special handling of quotes for the data part of
5758an \%lsearch%\ line.
5759.nextp
5760.index NIS lookup type
5761.index lookup||NIS
5762.index binary zero||in lookup key
5763\%nis%\: The given file is the name of a NIS map, and a NIS lookup is done with
5764the given key, without a terminating binary zero. There is a variant called
5765\%nis0%\ which does include the terminating binary zero in the key. This is
5766reportedly needed for Sun-style alias files. Exim does not recognize NIS
5767aliases; the full map names must be used.
5768.nextp
5769.index wildlsearch lookup type
5770.index lookup||wildlsearch
5771.index nwildlsearch lookup type
5772.index lookup||nwildlsearch
5773\%wildlsearch%\ or \%nwildlsearch%\: These search a file linearly, like
5774\%lsearch%\, but instead of being interpreted as a literal string, each key may
5775be wildcarded. The difference between these two lookup types is that for
5776\%wildlsearch%\, each key in the file is string-expanded before being used,
5777whereas for \%nwildlsearch%\, no expansion takes place.
5778
5779Like \%lsearch%\, the testing is done case-insensitively. The following forms
5780of wildcard are recognized:
5781.numberpars "$*$"
5782The string may begin with an asterisk to mean `begins with'. For example:
5783.display asis
5784*.a.b.c data for anything.a.b.c
5785*fish data for anythingfish
5786.endd
5787.nextp
5788The string may begin with a circumflex to indicate a regular expression. For
5789example, for \%wildlsearch%\:
5790.display asis
5791^\N\d+\.a\.b\N data for <digits>.a.b
5792.endd
5793Note the use of \"@\N"\ to disable expansion of the contents of the regular
5794expression. If you are using \%nwildlsearch%\, where the keys are not
5795string-expanded, the equivalent entry is:
5796.display asis
5797^\d+\.a\.b data for <digits>.a.b
5798.endd
5799
5800If the regular expression contains white space or colon characters, you must
5801either quote it (see \%lsearch%\ above), or represent these characters in other
5802ways. For example, \"@\s"\ can be used for white space and \"@\x3A"\ for a
5803colon. This may be easier than quoting, because if you quote, you have to
5804escape all the backslashes inside the quotes.
5805.nextp
5806Although I cannot see it being of much use, the general matching function
5807that is used to implement
5808\%(n)wildlsearch%\
5809means that the string may begin with a lookup name terminated by a semicolon,
5810and followed by lookup data. For example:
5811.display asis
5812cdb;/some/file data for keys that match the file
5813.endd
5814The data that is obtained from the nested lookup is discarded.
5815.endp
5816Keys that do not match any of these patterns are interpreted literally. The
5817continuation rules for the data are the same as for \%lsearch%\, and keys may
5818be followed by optional colons.
5819
5820\**Warning**\: Unlike most other single-key lookup types, a file of data for
5821\%(n)wildlsearch%\ can \*not*\ be turned into a DBM or cdb file, because those
5822lookup types support only literal keys.
5823.endp
5824
5825.section Query-style lookup types
5826.index lookup||query-style types
5827.index query-style lookup||list of types
5828The supported query-style lookup types are listed below. Further details about
5829many of them are given in later sections.
5830.numberpars $.
5831.index DNS||as a lookup type
5832.index lookup||DNS
5833\%dnsdb%\: This does a DNS search for a record whose domain name is the supplied
5834query. The resulting data is the contents of the record. See section
5835~~SECTdnsdb.
5836.nextp
5837.index Interbase lookup type
5838.index lookup||Interbase
5839\%ibase%\: This does a lookup in an Interbase database.
5840.nextp
5841.index LDAP||lookup type
5842.index lookup||LDAP
5843\%ldap%\: This does an LDAP lookup using a query in the form of a URL, and
5844returns attributes from a single entry. There is a variant called \%ldapm%\
5845that permits values from multiple entries to be returned. A third variant
5846called \%ldapdn%\ returns the Distinguished Name of a single entry instead of
5847any attribute values. See section ~~SECTldap.
5848.nextp
5849.index MySQL||lookup type
5850.index lookup||MySQL
5851\%mysql%\: The format of the query is an SQL statement that is passed to a MySQL
5852database. See section ~~SECTsql.
5853.nextp
5854.index NIS@+ lookup type
5855.index lookup||NIS+
5856\%nisplus%\: This does a NIS+ lookup using a query that can specify the name of
5857the field to be returned. See section ~~SECTnisplus.
5858.nextp
5859.index Oracle||lookup type
5860.index lookup||Oracle
5861\%oracle%\: The format of the query is an SQL statement that is passed to an
5862Oracle database. See section ~~SECTsql.
5863.nextp
5864.index lookup||passwd
5865.index passwd lookup type
5866\%passwd%\ is a query-style lookup with queries that are just user names. The
5867lookup calls \*getpwnam()*\ to interrogate the system password data, and on
5868success, the result string is the same as you would get from an \%lsearch%\
5869lookup on a traditional \(/etc/passwd file)\, though with \"*"\ for the
5870password value. For example:
5871.display asis
5872*:42:42:King Rat:/home/kr:/bin/bash
5873.endd
5874.nextp
5875.index PostgreSQL lookup type
5876.index lookup||PostgreSQL
5877\%pgsql%\: The format of the query is an SQL statement that is passed to a
5878PostgreSQL database. See section ~~SECTsql.
5879.nextp
5880\%testdb%\: This is a lookup type that is used for testing Exim. It is
5881not likely to be useful in normal operation.
5882.nextp
5883.index whoson lookup type
5884.index lookup||whoson
5885\%whoson%\: \*Whoson*\ (\?http://whoson.sourceforge.net?\) is a proposed
5886Internet protocol that allows Internet server programs to check whether a
5887particular (dynamically allocated) IP address is currently allocated to a known
5888(trusted) user and, optionally, to obtain the identity of the said user. In
5889Exim, this can be used to implement `POP before SMTP' checking using ACL
5890statements such as
5891.display asis
5892require condition = \
5893 ${lookup whoson {$sender_host_address}{yes}{no}}
5894.endd
5895The query consists of a single IP address. The value returned is the name of
5896the authenticated user.
5897.endp
5898
5899.section Temporary errors in lookups
5900.index lookup||temporary error in
5901Lookup functions can return temporary error codes if the lookup cannot be
5902completed. For example, a NIS or LDAP database might be unavailable. For this
5903reason, it is not advisable to use a lookup that might do this for critical
5904options such as a list of local domains.
5905
5906When a lookup cannot be completed in a router or transport, delivery
5907of the message (to the relevant address) is deferred, as for any other
5908temporary error. In other circumstances Exim may assume the lookup has failed,
5909or may give up altogether.
5910
5911
5912.section Default values in single-key lookups
5913.rset SECTdefaultvaluelookups "~~chapter.~~section"
5914.index wildcard lookups
5915.index lookup||default values
5916.index lookup||wildcard
5917.index lookup||$*$ added to type
5918.index default||in single-key lookups
5919In this context, a `default value' is a value specified by the administrator
5920that is to be used if a lookup fails.
5921
5922If `$*$' is added to a single-key lookup type (for example, \lsearch$*$\) and
5923the initial lookup fails, the key `$*$' is looked up in the file to provide
5924a default value. See also the section on partial matching below.
5925
5926.index @*@@ with single-key lookup
5927.index lookup||$*$@@ added to type
5928.index alias file||per-domain default
5929Alternatively, if `$*$@@' is added to a single-key lookup type (for example
5930\dbm$*$@@\) then, if the initial lookup fails and the key contains an @@
5931character, a second lookup is done with everything before the last @@ replaced
5932by $*$. This makes it possible to provide per-domain defaults in alias files
5933that include the domains in the keys. If the second lookup fails (or doesn't
5934take place because there is no @@ in the key), `$*$' is looked up.
5935For example, a \%redirect%\ router might contain:
5936.display asis
5937data = ${lookup{$local_part@$domain}lsearch*@{/etc/mixed-aliases}}
5938.endd
5939Suppose the address that is being processed is \*jane@@eyre.example*\. Exim
5940looks up these keys, in this order:
5941.display asis
5942jane@eyre.example
5943*@eyre.example
5944*
5945.endd
5946The data is taken from whichever key it finds first. \**Note**\: in an
5947\%lsearch%\ file, this does not mean the first of these keys in the file. A
5948complete scan is done for each key, and only if it is not found at all does
5949Exim move on to try the next key.
5950
5951
5952.section Partial matching in single-key lookups
5953.rset SECTpartiallookup "~~chapter.~~section"
5954.index partial matching
5955.index wildcard lookups
5956.index lookup||partial matching
5957.index lookup||wildcard
5958.index asterisk||in search type
5959The normal operation of a single-key lookup is to search the file for an exact
5960match with the given key. However, in a number of situations where domains are
5961being looked up, it is useful to be able to do partial matching. In this case,
5962information in the file that has a key starting with `$*$.' is matched by any
5963domain that ends with the components that follow the full stop. For example, if
5964a key in a DBM file is
5965.display
5966*.dates.fict.example
5967.endd
5968then when partial matching is enabled this is matched by (amongst others)
5969\*2001.dates.fict.example*\ and \*1984.dates.fict.example*\. It is also matched
5970by \*dates.fict.example*\, if that does not appear as a separate key in the
5971file.
5972
5973\**Note**\: Partial matching is not available for query-style lookups. It is
5974also not available for any lookup items in address lists (see section
5975~~SECTaddresslist).
5976
5977Partial matching is implemented by doing a series of separate lookups using
5978keys constructed by modifying the original subject key. This means that it can
5979be used with any of the single-key lookup types, provided that
5980partial matching keys
5981beginning with a special prefix (default `$*$.') are included in the data file.
5982Keys in the file that do not begin with the prefix are matched only by
5983unmodified subject keys when partial matching is in use.
5984
5985Partial matching is requested by adding the string `partial-' to the front of
5986the name of a single-key lookup type, for example, \partial-dbm\. When this is
5987done, the subject key is first looked up unmodified; if that fails, `$*$.'
5988is added at the start of the subject key, and it is looked up again. If that
5989fails, further lookups are tried with dot-separated components removed
5990from the start of the subject key, one-by-one, and `$*$.' added on the front of
5991what remains.
5992
5993A minimum number of two non-$*$ components are required. This can be adjusted
5994by including a number before the hyphen in the search type. For example,
5995\partial3-lsearch\ specifies a minimum of three non-$*$ components in the
5996modified keys. Omitting the number is equivalent to `partial2-'. If the subject
5997key is \*2250.dates.fict.example*\ then the following keys are looked up when
5998the minimum number of non-$*$ components is two:
5999.display asis
60002250.dates.fict.example
6001*.2250.dates.fict.example
6002*.dates.fict.example
6003*.fict.example
6004.endd
6005As soon as one key in the sequence is successfully looked up, the lookup
6006finishes.
6007
6008.index lookup||partial matching, changing prefix
6009.index prefix||for partial matching
6010The use of `$*$.' as the partial matching prefix is a default that can be
6011changed. The motivation for this feature is to allow Exim to operate with file
6012formats that are used by other MTAs. A different prefix can be supplied in
6013parentheses instead of the hyphen after `partial'. For example:
6014.display asis
6015domains = partial(.)lsearch;/some/file
6016.endd
6017In this example, if the domain is \*a.b.c*\, the sequence of lookups is
6018\"a.b.c"\, \".a.b.c"\, and \".b.c"\ (the default minimum of 2 non-wild
6019components is unchanged). The prefix may consist of any punctuation characters
6020other than a closing parenthesis. It may be empty, for example:
6021.display asis
6022domains = partial1()cdb;/some/file
6023.endd
6024For this example, if the domain is \*a.b.c*\, the sequence of lookups is
6025\"a.b.c"\, \"b.c"\, and \"c"\.
6026
6027If `partial0' is specified, what happens at the end (when the lookup with just
6028one non-wild component has failed, and the original key is shortened right down
6029to the null string) depends on the prefix:
6030.numberpars $.
6031If the prefix has zero length, the whole lookup fails.
6032.nextp
6033If the prefix has length 1, a lookup for just the prefix is done. For
6034example, the final lookup for `partial0(.)' is for \"."\ alone.
6035.nextp
6036Otherwise, if the prefix ends in a dot, the dot is removed, and the
6037remainder is looked up. With the default prefix, therefore, the final lookup is
6038for `$*$' on its own.
6039.nextp
6040Otherwise, the whole prefix is looked up.
6041.endp
6042
6043If the search type ends in `$*$' or `$*$@@' (see section
6044~~SECTdefaultvaluelookups above), the search for an ultimate default that this
6045implies happens after all partial lookups have failed. If `partial0' is
6046specified, adding `$*$' to the search type has no effect with the default
6047prefix, because the `$*$' key is already included in the sequence of partial
6048lookups. However, there might be a use for lookup types such as
6049`partial0(.)lsearch$*$'.
6050
6051The use of `$*$' in lookup partial matching differs from its use as a wildcard
6052in domain lists and the like. Partial matching works only in terms of
6053dot-separated components; a key such as \"*fict.example"\
6054in a database file is useless, because the asterisk in a partial matching
6055subject key is always followed by a dot.
6056
6057
6058
6059.section Lookup caching
6060.index lookup||caching
6061.index caching||lookup data
6062An Exim process
6063caches the most recent lookup result on a per-file basis for single-key
6064lookup types, and keeps the relevant files open. In some types of configuration
6065this can lead to many files being kept open for messages with many recipients.
6066To avoid hitting the operating system limit on the number of simultaneously
6067open files, Exim closes the least recently used file when it needs to open more
6068files than its own internal limit, which can be changed via the
6069\lookup@_open@_max\ option.
6070
6071For query-style lookups, a single data cache per lookup type is kept. The files
6072are closed and the caches flushed at strategic points during delivery -- for
6073example, after all routing is complete.
6074
6075
6076.section Quoting lookup data
6077.index lookup||quoting
6078.index quoting||in lookups
6079When data from an incoming message is included in a query-style lookup, there
6080is the possibility of special characters in the data messing up the syntax of
6081the query. For example, a NIS+ query that contains
6082.display asis
6083[name=$local_part]
6084.endd
6085will be broken if the local part happens to contain a closing square bracket.
6086For NIS+, data can be enclosed in double quotes like this:
6087.display asis
6088[name="$local_part"]
6089.endd
6090but this still leaves the problem of a double quote in the data. The rule for
6091NIS+ is that double quotes must be doubled. Other lookup types have different
6092rules, and to cope with the differing requirements, an expansion operator
6093of the following form is provided:
6094.display
6095@$@{quote@_<<lookup-type>>:<<string>>@}
6096.endd
6097For example, the safest way to write the NIS+ query is
6098.display asis
6099[name="${quote_nisplus:$local_part}"]
6100.endd
6101See chapter ~~CHAPexpand for full coverage of string expansions. The quote
6102operator can be used for all lookup types, but has no effect for single-key
6103lookups, since no quoting is ever needed in their key strings.
6104
6105
6106
6107.section More about dnsdb
6108.rset SECTdnsdb "~~chapter.~~section"
6109.index dnsdb lookup
6110.index lookup||dnsdb
6111.index DNS||as a lookup type
6112The \%dnsdb%\ lookup type uses the DNS as its database. A query consists of a
6113record type and a domain name, separated by an equals sign. For example, an
6114expansion string could contain:
6115.display asis
6116${lookup dnsdb{mx=a.b.example}{$value}fail}
6117.endd
6118.em
6119The supported record types are A, CNAME, MX, NS, PTR, SRV, and TXT,
6120.nem
6121and, when Exim is compiled with IPv6 support, AAAA (and A6 if that is also
6122configured). If no type is given, TXT is assumed. When the type is PTR, the
6123address should be given as normal; it is converted to the necessary inverted
6124format internally. For example:
6125.display asis
6126${lookup dnsdb{ptr=192.168.4.5}{$value}fail}
6127.endd
6128
6129.index MX record||in \%dnsdb%\ lookup
6130For MX records, both the preference value and the host name are returned,
6131separated by a space.
6132.em
6133.index SRV record||in \%dnsdb%\ lookup
6134For SRV records, the priority, weight, port, and host name are returned,
6135separated by spaces. For any record type,
6136.nem
6137if multiple records are found (or, for A6 lookups, if a single record leads to
6138multiple addresses), the data is returned as a concatenation, separated by
6139newlines. The order, of course, depends on the DNS resolver.
6140
6141
6142
6143
6144.section More about LDAP
6145.rset SECTldap "~~chapter.~~section"
6146.index LDAP lookup
6147.index lookup||LDAP
6148.index Solaris||LDAP
6149The original LDAP implementation came from the University of Michigan; this has
6150become `Open LDAP', and there are now two different releases. Another
6151implementation comes from Netscape, and Solaris 7 and subsequent releases
6152contain inbuilt LDAP support. Unfortunately, though these are all compatible at
6153the lookup function level, their error handling is different. For this reason
6154it is necessary to set a compile-time variable when building Exim with LDAP, to
6155indicate which LDAP library is in use. One of the following should appear in
6156your \(Local/Makefile)\:
6157.display asis
6158LDAP_LIB_TYPE=UMICHIGAN
6159LDAP_LIB_TYPE=OPENLDAP1
6160LDAP_LIB_TYPE=OPENLDAP2
6161LDAP_LIB_TYPE=NETSCAPE
6162LDAP_LIB_TYPE=SOLARIS
6163.endd
6164If \\LDAP@_LIB@_TYPE\\ is not set, Exim assumes \"OPENLDAP1"\, which has the
6165same interface as the University of Michigan version.
6166
6167There are three LDAP lookup types in Exim. These behave slightly differently in
6168the way they handle the results of a query:
6169.numberpars $.
6170\%ldap%\ requires the result to contain just one entry; if there are more, it
6171gives an error.
6172.nextp
6173\%ldapdn%\ also requires the result to contain just one entry, but it is the
6174Distinguished Name that is returned rather than any attribute values.
6175.nextp
6176\%ldapm%\ permits the result to contain more than one entry; the attributes from
6177all of them are returned.
6178.endp
6179
6180For \%ldap%\ and \%ldapm%\, if a query finds only entries with no attributes,
6181Exim behaves as if the entry did not exist, and the lookup fails. The format of
6182the data returned by a successful lookup is described in the next section.
6183First we explain how LDAP queries are coded.
6184
6185.section Format of LDAP queries
6186.rset SECTforldaque "~~chapter.~~section"
6187.index LDAP||query format
6188An LDAP query takes the form of a URL as defined in RFC 2255. For example, in
6189the configuration of a \%redirect%\ router one might have this setting:
6190.display asis
6191data = ${lookup ldap \
6192 {ldap:///cn=$local_part,o=University%20of%20Cambridge,\
6193 c=UK?mailbox?base?}}
6194.endd
6195.index LDAP||with TLS
6196The URL may begin with \"ldap"\ or \"ldaps"\ if your LDAP library supports
6197secure (encrypted) LDAP connections. The second of these ensures that an
6198encrypted TLS connection is used.
6199
6200.section LDAP quoting
6201.index LDAP||quoting
6202Two levels of quoting are required in LDAP queries, the first for LDAP itself
6203and the second because the LDAP query is represented as a URL. Furthermore,
6204within an LDAP query, two different kinds of quoting are required. For this
6205reason, there are two different LDAP-specific quoting operators.
6206
6207The \quote@_ldap\ operator is designed for use on strings that are part of
6208filter specifications. Conceptually, it first does the following conversions on
6209the string:
6210.display asis
6211* => \2A
6212( => \28
6213) => \29
6214\ => \5C
6215.endd
6216in accordance with RFC 2254. The resulting string is then quoted according
6217to the rules for URLs, that is, all characters except
6218.display asis
6219! $ ' - . _ ( ) * +
6220.endd
6221are converted to their hex values, preceded by a percent sign. For example:
6222.display asis
6223${quote_ldap: a(bc)*, a<yz>; }
6224.endd
6225yields
6226.display asis
6227%20a%5C28bc%5C29%5C2A%2C%20a%3Cyz%3E%3B%20
6228.endd
6229Removing the URL quoting, this is (with a leading and a trailing space):
6230.display asis
6231a\28bc\29\2A, a<yz>;
6232.endd
6233
6234The \quote@_ldap@_dn\ operator is designed for use on strings that are part of
6235base DN specifications in queries. Conceptually, it first converts the string
6236by inserting a backslash in front of any of the following characters:
6237.display asis
6238, + " \ < > ;
6239.endd
6240It also inserts a backslash before any leading spaces or @# characters, and
6241before any trailing spaces. (These rules are in RFC 2253.) The resulting string
6242is then quoted according to the rules for URLs. For example:
6243.display asis
6244${quote_ldap_dn: a(bc)*, a<yz>; }
6245.endd
6246yields
6247.display asis
6248%5C%20a(bc)*%5C%2C%20a%5C%3Cyz%5C%3E%5C%3B%5C%20
6249.endd
6250Removing the URL quoting, this is (with a trailing space):
6251.display asis
6252\ a(bc)*\, a\<yz\>\;\
6253.endd
6254There are some further comments about quoting in the section on LDAP
6255authentication below.
6256
6257.section LDAP connections
6258.index LDAP||connections
6259The connection to an LDAP server may either be over TCP/IP, or, when OpenLDAP
6260is in use, via a Unix domain socket. The example given above does not specify
6261an LDAP server. A server that is reached by TCP/IP can be specified in a query
6262by starting it with
6263.display
6264ldap://<<hostname>>:<<port>>/...
6265.endd
6266If the port (and preceding colon) are omitted, the standard LDAP port (389) is
6267used. When no server is specified in a query, a list of default servers is
6268taken from the \ldap@_default@_servers\ configuration option. This supplies a
6269colon-separated list of servers which are tried in turn until one successfully
6270handles a query, or there is a serious error. Successful handling either
6271returns the requested data, or indicates that it does not exist. Serious errors
6272are syntactical, or multiple values when only a single value is expected.
6273Errors which cause the next server to be tried are connection failures, bind
6274failures, and timeouts.
6275
6276For each server name in the list, a port number can be given. The standard way
6277of specifing a host and port is to use a colon separator (RFC 1738). Because
6278\ldap@_default@_servers\ is a colon-separated list, such colons have to be
6279doubled. For example
6280.display asis
6281ldap_default_servers = ldap1.example.com::145:ldap2.example.com
6282.endd
6283If \ldap@_default@_servers\ is unset, a URL with no server name is passed
6284to the LDAP library with no server name, and the library's default (normally
6285the local host) is used.
6286
6287If you are using the OpenLDAP library, you can connect to an LDAP server using
6288a Unix domain socket instead of a TCP/IP connection. This is specified by using
6289\"ldapi"\ instead of \"ldap"\ in LDAP queries. What follows here applies only
6290to OpenLDAP. If Exim is compiled with a different LDAP library, this feature is
6291not available.
6292
6293For this type of connection, instead of a host name for the server, a pathname
6294for the socket is required, and the port number is not relevant. The pathname
6295can be specified either as an item in \ldap@_default@_servers\, or inline in
6296the query. In the former case, you can have settings such as
6297.display asis
6298ldap_default_servers = /tmp/ldap.sock : backup.ldap.your.domain
6299.endd
6300When the pathname is given in the query, you have to escape the slashes as
6301\"%2F"\ to fit in with the LDAP URL syntax. For example:
6302.display asis
6303${lookup ldap {ldapi://%2Ftmp%2Fldap.sock/o=...
6304.endd
6305When Exim processes an LDAP lookup and finds that the `hostname' is really
6306a pathname, it uses the Unix domain socket code, even if the query actually
6307specifies \"ldap"\ or \"ldaps"\. In particular, no encryption is used for a
6308socket connection. This behaviour means that you can use a setting of
6309\ldap@_default@_servers\ such as in the example above with traditional \"ldap"\
6310or \"ldaps"\ queries, and it will work. First, Exim tries a connection via
6311the Unix domain socket; if that fails, it tries a TCP/IP connection to the
6312backup host.
6313
6314If an explicit \"ldapi"\ type is given in a query when a host name is
6315specified, an error is diagnosed. However, if there are more items in
6316\ldap@_default@_servers\, they are tried. In other words:
6317.numberpars $.
6318Using a pathname with \"ldap"\ or \"ldaps"\ forces the use of the Unix domain
6319interface.
6320.nextp
6321Using \"ldapi"\ with a host name causes an error.
6322.endp
6323
6324Using \"ldapi"\ with no host or path in the query, and no setting of
6325\ldap@_default@_servers\, does whatever the library does by default.
6326
6327
6328.section LDAP authentication and control information
6329.index LDAP||authentication
6330The LDAP URL syntax provides no way of passing authentication and other control
6331information to the server. To make this possible, the URL in an LDAP query may
6332be preceded by any number of `<<name>>=<<value>>' settings, separated by
6333spaces. If a value contains spaces it must be enclosed in double quotes, and
6334when double quotes are used, backslash is interpreted in the usual way inside
6335them.
6336
6337The following names are recognized:
6338.display
6339CONNECT $rm{set a connection timeout}
6340.newline
6341DEREFERENCE $rm{set the dereferencing parameter}
6342USER $rm{set the DN, for authenticating the LDAP bind}
6343PASS $rm{set the password, likewise}
6344SIZE $rm{set the limit for the number of entries returned}
6345TIME $rm{set the maximum waiting time for a query}
6346.endd
6347The value of the \\DEREFERENCE\\ parameter must be one of the words `never',
6348`searching', `finding', or `always'.
6349
6350Here is an example of an LDAP query in an Exim lookup that uses some of these
6351values. This is a single line, folded for ease of reading:
6352.display asis
6353.indent 0
6354${lookup ldap
6355 {user="cn=manager,o=University of Cambridge,c=UK" pass=secret
6356 ldap:///o=University%20of%20Cambridge,c=UK?sn?sub?(cn=foo)}
6357 {$value}fail}
6358.endd
6359The encoding of spaces as %20 is a URL thing which should not be done for any
6360of the auxiliary data. Exim configuration settings that include lookups which
6361contain password information should be preceded by `hide' to prevent non-admin
6362users from using the \-bP-\ option to see their values.
6363
6364The auxiliary data items may be given in any order. The default is no
6365connection timeout (the system timeout is used), no user or password, no limit
6366on the number of entries returned, and no time limit on queries.
6367
6368The time limit for connection is given in seconds; zero means use the default.
6369This facility is available in Netscape SDK 4.1; it may not be available in
6370other LDAP implementations. Exim uses the given value if
6371\\LDAP@_X@_OPT@_CONNECT@_TIMEOUT\\ is defined in the LDAP headers.
6372
6373When a DN is quoted in the \\USER=\\ setting for LDAP authentication, Exim
6374removes any URL quoting that it may contain before passing it LDAP. Apparently
6375some libraries do this for themselves, but some do not. Removing the URL
6376quoting has two advantages:
6377.numberpars $.
6378It makes it possible to use the same \quote@_ldap@_dn\ expansion for \\USER=\\
6379DNs as with DNs inside actual queries.
6380.nextp
6381It permits spaces inside \\USER=\\ DNs.
6382.endp
6383For example, a setting such as
6384.display asis
6385USER=cn=${quote_ldap_dn:$1}
6386.endd
6387should work even if \$1$\ contains spaces.
6388
6389Expanded data for the \\PASS=\\ value should be quoted using the \quote\
6390expansion operator, rather than the LDAP quote operators. The only reason this
6391field needs quoting is to ensure that it conforms to the Exim syntax, which
6392does not allow unquoted spaces. For example:
6393.display asis
6394PASS=${quote:$3}
6395.endd
6396
6397The LDAP authentication mechanism can be used to check passwords as part of
6398SMTP authentication. See the \ldapauth\ expansion string condition in chapter
6399~~CHAPexpand.
6400
6401
6402.section Format of data returned by LDAP
6403.index LDAP||returned data formats
6404The \%ldapdn%\ lookup type returns the Distinguished Name from a single entry as
6405a sequence of values, for example
6406.display asis
6407cn=manager, o=University of Cambridge, c=UK
6408.endd
6409
6410The \%ldap%\ lookup type generates an error if more than one entry matches the
6411search filter, whereas \%ldapm%\ permits this case, and inserts a newline in the
6412result between the data from different entries. It is possible for multiple
6413values to be returned for both \%ldap%\ and \%ldapm%\, but in the former case you
6414know that whatever values are returned all came from a single entry in the
6415directory.
6416
6417In the common case where you specify a single attribute in your LDAP query, the
6418result is not quoted, and does not contain the attribute name. If the attribute
6419has multiple values, they are separated by commas.
6420
6421If you specify multiple attributes, the result contains space-separated, quoted
6422strings, each preceded by the attribute name and an equals sign. Within the
6423quotes, the quote character, backslash, and newline are escaped with
6424backslashes, and commas are used to separate multiple values for the attribute.
6425Apart from the escaping, the string within quotes takes the same form as the
6426output when a single attribute is requested. Specifying no attributes is the
6427same as specifying all of an entry's attributes.
6428
6429Here are some examples of the output format. The first line of each pair is an
6430LDAP query, and the second is the data that is returned. The attribute called
6431\attr1\ has two values, whereas \attr2\ has only one value:
6432.display asis
6433ldap:///o=base?attr1?sub?(uid=fred)
6434value1.1, value1.2
6435
6436ldap:///o=base?attr2?sub?(uid=fred)
6437value two
6438
6439ldap:///o=base?attr1,attr2?sub?(uid=fred)
6440attr1="value1.1, value1.2" attr2="value two"
6441
6442ldap:///o=base??sub?(uid=fred)
6443objectClass="top" attr1="value1.1, value1.2" attr2="value two"
6444.endd
6445The \extract\ operator in string expansions can be used to pick out individual
6446fields from data that consists of $it{key}=$it{value} pairs. You can make use
6447of Exim's \-be-\ option to run expansion tests and thereby check the results of
6448LDAP lookups.
6449
6450
6451
6452.section More about NIS+
6453.rset SECTnisplus "~~chapter.~~section"
6454.index NIS@+ lookup type
6455.index lookup||NIS+
6456NIS+ queries consist of a NIS+ \*indexed name*\ followed by an optional colon
6457and field name. If this is given, the result of a successful query is the
6458contents of the named field; otherwise the result consists of a concatenation
6459of \*field-name=field-value*\ pairs, separated by spaces. Empty values and
6460values containing spaces are quoted. For example, the query
6461.display asis
6462[name=mg1456],passwd.org_dir
6463.endd
6464might return the string
6465.display asis
6466name=mg1456 passwd="" uid=999 gid=999 gcos="Martin Guerre"
6467home=/home/mg1456 shell=/bin/bash shadow=""
6468.endd
6469(split over two lines here to fit on the page), whereas
6470.display asis
6471[name=mg1456],passwd.org_dir:gcos
6472.endd
6473would just return
6474.display asis
6475Martin Guerre
6476.endd
6477with no quotes. A NIS+ lookup fails if NIS+ returns more than one table entry
6478for the given indexed key. The effect of the \quote@_nisplus\ expansion
6479operator is to double any quote characters within the text.
6480
6481
6482.section More about MySQL, PostgreSQL, Oracle, and Interbase
6483.rset SECTsql "~~chapter.~~section"
6484.index MySQL||lookup type
6485.index PostgreSQL lookup type
6486.index lookup||MySQL
6487.index lookup||PostgreSQL
6488.index Oracle||lookup type
6489.index lookup||Oracle
6490.index Interbase lookup type
6491.index lookup||Interbase
6492If any MySQL, PostgreSQL, Oracle, or Interbase lookups are used, the
6493\mysql@_servers\, \pgsql@_servers\, \oracle@_servers\, or \ibase@_servers\
6494option (as appropriate) must be set to a colon-separated list of server
6495information. Each item in the list is a slash-separated list of four items:
6496host name, database name, user name, and password. In the case of Oracle, the
6497host name field is used for the `service name', and the database name field is
6498not used and should be empty. For example:
6499.display asis
6500hide oracle_servers = oracle.plc.example//ph10/abcdwxyz
6501.endd
6502Because password data is sensitive, you should always precede the setting with
6503`hide', to prevent non-admin users from obtaining the setting via the \-bP-\
6504option. Here is an example where two MySQL servers are listed:
6505.display asis
6506hide mysql_servers = localhost/users/root/secret:\
6507 otherhost/users/root/othersecret
6508.endd
6509For MySQL and PostgreSQL, a host may be specified as <<name>>:<<port>> but
6510because this is a colon-separated list, the colon has to be doubled.
6511
6512For each query, these parameter groups are tried in order until a connection
6513and a query succeeds. Queries for these databases are SQL statements, so an
6514example might be
6515.display asis
6516.indent 0
6517${lookup mysql{select mailbox from users where id='ph10'}{$value}fail}
6518.endd
6519If the result of the query contains more than one field, the data for
6520each field in the row is returned, preceded by its name, so the result
6521of
6522.display asis
6523.indent 0
6524${lookup pgsql{select home,name from users where id='ph10'}{$value}}
6525.endd
6526might be
6527.display asis
6528home=/home/ph10 name="Philip Hazel"
6529.endd
6530Values containing spaces and empty values are double quoted, with embedded
6531quotes escaped by a backslash.
6532
6533If the result of the query contains just one field, the value is passed back
6534verbatim, without a field name, for example:
6535.display asis
6536Philip Hazel
6537.endd
6538If the result of the query yields more than one row, it is all concatenated,
6539with a newline between the data for each row.
6540
6541The \quote@_mysql\, \quote@_pgsql\, and \quote@_oracle\ expansion operators
6542convert newline, tab, carriage return, and backspace to @\n, @\t, @\r, and @\b
6543respectively, and the characters single-quote, double-quote, and backslash
6544itself are escaped with backslashes. The \quote@_pgsql\ expansion operator, in
6545addition, escapes the percent and underscore characters. This cannot be done
6546for MySQL because these escapes are not recognized in contexts where these
6547characters are not special.
6548
6549
6550.section Special MySQL features
6551For MySQL, an empty host name or the use of `localhost' in \mysql@_servers\
6552causes a connection to the server on the local host by means of a Unix domain
6553socket. An alternate socket can be specified in parentheses. The full syntax of
6554each item in \mysql@_servers\ is:
6555.display
6556<<hostname>>@:@:<<port>>(<<socket name>>)/<<database>>/<<user>>/<<password>>
6557.endd
6558Any of the three sub-parts of the first field can be omitted. For normal use on
6559the local host it can be left blank or set to just `localhost'.
6560
6561No database need be supplied -- but if it is absent here, it must be given in
6562the queries.
6563
6564If a MySQL query is issued that does not request any data (an insert, update,
6565or delete command), the result of the lookup is the number of rows affected.
6566
6567
6568
6569.section Special PostgreSQL features
6570PostgreSQL lookups can also use Unix domain socket connections to the database.
6571This is usually faster and costs less CPU time than a TCP/IP connection.
6572However it can be used only if the mail server runs on the same machine as the
6573database server. A configuration line for PostgreSQL via Unix domain sockets
6574looks like this:
6575.display asis
6576hide pgsql_servers = (/tmp/.s.PGSQL.5432)/db/user/password : ...
6577.endd
6578In other words, instead of supplying a host name, a path to the socket is
6579given. The path name is enclosed in parentheses so that its slashes aren't
6580visually confused with the delimiters for the other server parameters.
6581
6582If a PostgreSQL query is issued that does not request any data (an insert,
6583update, or delete command), the result of the lookup is the number of rows
6584affected.
6585
6586
6587
6588
6589.
6590.
6591.
6592.
6593. ============================================================================
6594.chapter Domain, host, address, and local part lists
6595.set runningfoot "domain, host, and address lists"
6596.rset CHAPdomhosaddlists "~~chapter"
6597.index list||of domains, hosts, etc.
6598A number of Exim configuration options contain lists of domains, hosts,
6599email addresses, or local parts. For example, the \hold@_domains\ option
6600contains a list of domains whose delivery is currently suspended. These lists
6601are also used as data in ACL statements (see chapter ~~CHAPACL).
6602
6603Each item in one of these lists is a pattern to be matched against a domain,
6604host, email address, or local part, respectively. In the sections below, the
6605different types of pattern for each case are described, but first we cover some
6606general facilities that apply to all four kinds of list.
6607
6608
6609.section Expansion of lists
6610.index expansion||of lists
6611Each list is expanded as a single string before it is used. If the expansion is
6612forced to fail, Exim behaves as if the item it is testing (domain, host,
6613address, or local part) is not in the list. Other expansion failures cause
6614temporary errors.
6615
6616If an item in a list is a regular expression, backslashes, dollars and possibly
6617other special characters in the expression must be protected against
6618misinterpretation by the string expander. The easiest way to do this is to use
6619the \"@\N"\ expansion feature to indicate that the contents of the regular
6620expression should not be expanded. For example, in an ACL you might have:
6621.display asis
6622deny senders = \N^\d{8}\w@.*\.baddomain\.example$\N :
6623 ${lookup{$domain}lsearch{/badsenders/bydomain}}
6624.endd
6625The first item is a regular expression that is protected from expansion by
6626\"@\N"\, whereas the second uses the expansion to obtain a list of unwanted
6627senders based on the receiving domain.
6628
6629After expansion, the list is split up into separate items for matching.
6630Normally, colon is used as the separator character, but this can be varied if
6631necessary, as described in section ~~SECTlistconstruct.
6632
6633
6634.section Negated items in lists
6635.index list||negation
6636.index negation in lists
6637Items in a list may be positive or negative. Negative items are indicated by a
6638leading exclamation mark, which may be followed by optional white space. A list
6639defines a set of items (domains, etc). When Exim processes one of these lists,
6640it is trying to find out whether a domain, host, address, or local part
6641(respectively) is in the set that is defined by the list. It works like this:
6642
6643The list is scanned from left to right. If a positive item is matched, the
6644subject that is being checked is in the set; if a negative item is matched, the
6645subject is not in the set. If the end of the list is reached without the
6646subject having matched any of the patterns, it is in the set if the last item
6647was a negative one, but not if it was a positive one. For example, the list in
6648.display asis
6649domainlist relay_domains = !a.b.c : *.b.c
6650.endd
6651matches any domain ending in \*.b.c*\ except for \*a.b.c*\. Domains that match
6652neither \*a.b.c*\ nor \*@*.b.c*\ do not match, because the last item in the
6653list is positive. However, if the setting were
6654.display asis
6655domainlist relay_domains = !a.b.c
6656.endd
6657then all domains other than \*a.b.c*\ would match because the last item in the
6658list is negative. In other words, a list that ends with a negative item behaves
6659as if it had an extra item \":*"\ on the end.
6660
6661Another way of thinking about positive and negative items in lists is to read
6662the connector as `or' after a positive item and as `and' after a negative
6663item.
6664
6665
6666.section File names in lists
6667.rset SECTfilnamlis "~~chapter.~~section"
6668.index list||file name in
6669If an item in a domain, host, address, or local part list is an absolute file
6670name (beginning with a slash character), each line of the file is read and
6671processed as if it were an independent item in the list, except that further
6672file names are not allowed,
6673and no expansion of the data from the file takes place.
6674Empty lines in the file are ignored, and the file may also contain comment
6675lines:
6676.numberpars $.
6677For domain and host lists, if a @# character appears anywhere in a line of the
6678file, it and all following characters are ignored.
6679.nextp
6680Because local parts may legitimately contain @# characters, a comment in an
6681address list or local part list file is recognized only if @# is preceded by
6682white space or the start of the line. For example:
6683.display asis
6684not#comment@x.y.z # but this is a comment
6685.endd
6686.endp
6687Putting a file name in a list has the same effect as inserting each line of the
6688file as an item in the list (blank lines and comments excepted). However, there
6689is one important difference: the file is read each time the list is processed,
6690so if its contents vary over time, Exim's behaviour changes.
6691
6692If a file name is preceded by an exclamation mark, the sense of any match
6693within the file is inverted. For example, if
6694.display asis
6695hold_domains = !/etc/nohold-domains
6696.endd
6697and the file contains the lines
6698.display asis
6699!a.b.c
6700*.b.c
6701.endd
6702then \*a.b.c*\ is in the set of domains defined by \hold@_domains\, whereas any
6703domain matching \"*.b.c"\ is not.
6704
6705
6706.section An lsearch file is not an out-of-line list
6707As will be described in the sections that follow, lookups can be used in lists
6708to provide indexed methods of checking list membership. There has been some
6709confusion about the way \%lsearch%\ lookups work in lists. Because
6710an \%lsearch%\ file contains plain text and is scanned sequentially, it is
6711sometimes thought that it is allowed to contain wild cards and other kinds of
6712non-constant pattern. This is not the case. The keys in an \%lsearch%\ file are
6713always fixed strings, just as for any other single-key lookup type.
6714
6715If you want to use a file to contain wild-card patterns that form part of a
6716list, just give the file name on its own, without a search type, as described
6717in the previous section.
6718
6719
6720
6721.section Named lists
6722.rset SECTnamedlists "~~chapter.~~section"
6723.index named lists
6724.index list||named
6725A list of domains, hosts, email addresses, or local parts can be given a name
6726which is then used to refer to the list elsewhere in the configuration. This is
6727particularly convenient if the same list is required in several different
6728places. It also allows lists to be given meaningful names, which can improve
6729the readability of the configuration. For example, it is conventional to define
6730a domain list called \*local@_domains*\ for all the domains that are handled
6731locally on a host, using a configuration line such as
6732.display asis
6733domainlist local_domains = localhost:my.dom.example
6734.endd
6735Named lists are referenced by giving their name preceded by a plus sign, so,
6736for example, a router that is intended to handle local domains would be
6737configured with the line
6738.display asis
6739domains = +local_domains
6740.endd
6741The first router in a configuration is often one that handles all domains
6742except the local ones, using a configuration with a negated item like this:
6743.display asis
6744dnslookup:
6745 driver = dnslookup
6746 domains = ! +local_domains
6747 transport = remote_smtp
6748 no_more
6749.endd
6750The four kinds of named list are created by configuration lines starting with
6751the words \domainlist\, \hostlist\, \addresslist\, or \localpartlist\,
6752respectively. Then there follows the name that you are defining, followed by an
6753equals sign and the list itself. For example:
6754.display asis
6755hostlist relay_hosts = 192.168.23.0/24 : my.friend.example
6756addresslist bad_senders = cdb;/etc/badsenders
6757.endd
6758A named list may refer to other named lists:
6759.display asis
6760domainlist dom1 = first.example : second.example
6761domainlist dom2 = +dom1 : third.example
6762domainlist dom3 = fourth.example : +dom2 : fifth.example
6763.endd
6764
6765\**Warning**\: If the last item in a referenced list is a negative one, the
6766effect may not be what you intended, because the negation does not propagate
6767out to the higher level. For example, consider:
6768.display asis
6769domainlist dom1 = !a.b
6770domainlist dom2 = +dom1 : *.b
6771.endd
6772The second list specifies `either in the \dom1\ list or \*@*.b*\'. The first
6773list specifies just `not \*a.b*\', so the domain \*x.y*\ matches it. That means
6774it matches the second list as well. The effect is not the same as
6775.display asis
6776domainlist dom2 = !a.b : *.b
6777.endd
6778where \*x.y*\ does not match. It's best to avoid negation altogether in
6779referenced lists if you can.
6780
6781Named lists may have a performance advantage. When Exim is routing an
6782address or checking an incoming message, it caches the result of tests on named
6783lists. So, if you have a setting such as
6784.display asis
6785domains = +local_domains
6786.endd
6787on several of your routers
6788or in several ACL statements,
6789the actual test is done only for the first one. However, the caching works only
6790if there are no expansions within the list itself or any sublists that it
6791references. In other words, caching happens only for lists that are known to be
6792the same each time they are referenced.
6793
6794By default, there may be up to 16 named lists of each type. This limit can be
6795extended by changing a compile-time variable. The use of domain and host lists
6796is recommended for concepts such as local domains, relay domains, and relay
6797hosts. The default configuration is set up like this.
6798
6799
6800.section Named lists compared with macros
6801.index list||named compared with macro
6802.index macro||compared with named list
6803At first sight, named lists might seem to be no different from macros in the
6804configuration file. However, macros are just textual substitutions. If you
6805write
6806.display asis
6807ALIST = host1 : host2
6808auth_advertise_hosts = !ALIST
6809.endd
6810it probably won't do what you want, because that is exactly the same as
6811.display asis
6812auth_advertise_hosts = !host1 : host2
6813.endd
6814Notice that the second host name is not negated. However, if you use a host
6815list, and write
6816.display asis
6817hostlist alist = host1 : host2
6818auth_advertise_hosts = ! +alist
6819.endd
6820the negation applies to the whole list, and so that is equivalent to
6821.display asis
6822auth_advertise_hosts = !host1 : !host2
6823.endd
6824
6825
6826.em
6827.section Named list caching
6828.index list||caching of named
6829.index caching||named lists
6830While processing a message, Exim caches the result of checking a named list if
6831it is sure that the list is the same each time. In practice, this means that
6832the cache operates only if the list contains no @$ characters, which guarantees
6833that it will not change when it is expanded. Sometimes, however, you may have
6834an expanded list that you know will be the same each time within a given
6835message. For example:
6836.display asis
6837domainlist special_domains = \
6838 ${lookup{$sender_host_address}cdb{/some/file}}
6839.endd
6840This provides a list of domains that depends only on the sending host's IP
6841address. If this domain list is referenced a number of times (for example,
6842in several ACL lines, or in several routers) the result of the check is not
6843cached by default, because Exim does not know that it is going to be the
6844same list each time.
6845
6846By appending \"@_cache"\ to \"domainlist"\ you can tell Exim to go ahead and
6847cache the result anyway. For example:
6848.display asis
6849domainlist_cache special_domains = ${lookup{...
6850.endd
6851If you do this, you should be absolutely sure that caching is going to do
6852the right thing in all cases. When in doubt, leave it out.
6853.nem
6854
6855
6856.section Domain lists
6857.rset SECTdomainlist "~~chapter.~~section"
6858.index domain list||patterns for
6859.index list||domain list
6860Domain lists contain patterns that are to be matched against a mail domain.
6861The following types of item may appear in domain lists:
6862.numberpars $.
6863.index primary host name
6864.index host||name, matched in domain list
6865.index \primary@_hostname\
6866.index domain list||matching primary host name
6867.index @@ in a domain list
6868If a pattern consists of a single @@ character, it matches the local host name,
6869as set by the \primary@_hostname\ option (or defaulted). This makes it possible
6870to use the same configuration file on several different hosts that differ only
6871in their names.
6872.nextp
6873.index @@[] in a domain list
6874.index domain list||matching local IP interfaces
6875.index domain literal
6876If a pattern consists of the string \"@@[]"\ it matches any local IP interface
6877address, enclosed in square brackets, as in an email address that contains a
6878domain literal.
6879.em
6880In today's Internet, the use of domain literals is controversial.
6881.nem
6882.nextp
6883.index @@mx@_any
6884.index @@mx@_primary
6885.index @@mx@_secondary
6886.index domain list||matching MX pointers to local host
6887If a pattern consists of the string \"@@mx@_any"\ it matches any domain that
6888has an MX record pointing to the local host or to any host that is listed in
6889.index \hosts@_treat@_as@_local\
6890\hosts@_treat@_as@_local\. The items \"@@mx@_primary"\ and \"@@mx@_secondary"\
6891are similar, except that the first matches only when a primary MX target is the
6892local host, and the second only when no primary MX target is the local host,
6893but a secondary MX target is. `Primary' means an MX record with the lowest
6894preference value -- there may of course be more than one of them.
6895
6896.em
6897The MX lookup that takes place when matching a pattern of this type is
6898performed with the resolver options for widening names turned off. Thus, for
6899example, a single-component domain will \*not*\ be expanded by adding the
6900resolver's default domain. See the \qualify@_single\ and \search@_parents\
6901options of the \%dnslookup%\ router for a discussion of domain widening.
6902
6903Sometimes you may want to ignore certain IP addresses when using one of these
6904patterns. You can specify this by following the pattern with \"/ignore=<<ip
6905list>>"\, where <<ip list>> is a list of IP addresses. These addresses are
6906ignored when processing the pattern (compare the \ignore@_target@_hosts\ option
6907on a router). For example:
6908.display asis
6909domains = @mx_any/ignore=127.0.0.1
6910.endd
6911This example matches any domain that has an MX record pointing to one of
6912the local host's IP addresses other than 127.0.0.1.
6913
6914The list of IP addresses is in fact processed by the same code that processes
6915host lists, so it may contain CIDR-coded network specifications and it may also
6916contain negative items.
6917
6918Because the list of IP addresses is a sublist within a domain list, you have to
6919be careful about delimiters if there is more than one address. Like any other
6920list, the default delimiter can be changed. Thus, you might have:
6921.display asis
6922domains = @mx_any/ignore=<;127.0.0.1;0.0.0.0 : \
6923 an.other.domain : ...
6924.endd
6925so that the sublist uses semicolons for delimiters. When IPv6 addresses are
6926involved, it is easiest to change the delimiter for the main list as well:
6927.display asis
6928domains = <? @mx_any/ignore=<;127.0.0.1;::1 ? \
6929 an.other.domain ? ...
6930.endd
6931.nem
6932
6933.nextp
6934.index asterisk||in domain list
6935.index domain list||asterisk in
6936.index domain list||matching `ends with'
6937If a pattern starts with an asterisk, the remaining characters of the pattern
6938are compared with the terminating characters of the domain. The use of `$*$' in
6939domain lists differs from its use in partial matching lookups. In a domain
6940list, the character following the asterisk need not be a dot, whereas partial
6941matching works only in terms of dot-separated components. For example, a domain
6942list item such as \"*key.ex"\ matches \*donkey.ex*\ as well as
6943\*cipher.key.ex*\.
6944.nextp
6945.index regular expressions||in domain list
6946.index domain list||matching regular expression
6947If a pattern starts with a circumflex character, it is treated as a regular
6948expression, and matched against the domain using a regular expression matching
6949function. The circumflex is treated as part of the regular expression.
6950References to descriptions of the syntax of regular expressions are given in
6951chapter ~~CHAPregexp.
6952
6953\**Warning**\: Because domain lists are expanded before being processed, you
6954must escape any backslash and dollar characters in the regular expression, or
6955use the special \"@\N"\ sequence (see chapter ~~CHAPexpand) to specify that it
6956is not to be expanded (unless you really do want to build a regular expression
6957by expansion, of course).
6958.nextp
6959.index lookup||in domain list
6960.index domain list||matching by lookup
6961If a pattern starts with the name of a single-key lookup type followed by a
6962semicolon (for example, `dbm;' or `lsearch;'), the remainder of the pattern
6963must be a file name in a suitable format for the lookup type. For example, for
6964`cdb;' it must be an absolute path:
6965.display asis
6966domains = cdb;/etc/mail/local_domains.cdb
6967.endd
6968The appropriate type of lookup is done on the file using the domain name as the
6969key. In most cases, the data that is looked up is not used; Exim is interested
6970only in whether or not the key is present in the file. However, when a lookup
6971is used for the \domains\ option on a router
6972or a \domains\ condition in an ACL statement, the data is preserved in the
6973\$domain@_data$\ variable and can be referred to in other router options or
6974other statements in the same ACL.
6975.nextp
6976Any of the single-key lookup type names may be preceded by `partial<<n>>-',
6977where the <<n>> is optional, for example,
6978.display asis
6979domains = partial-dbm;/partial/domains
6980.endd
6981This causes partial matching logic to be invoked; a description of how this
6982works is given in section ~~SECTpartiallookup.
6983.nextp
6984.index asterisk||in lookup type
6985Any of the single-key lookup types may be followed by an asterisk. This causes
6986a default lookup for a key consisting of a single asterisk to be done if the
6987original lookup fails. This is not a useful feature when using a domain list to
6988select particular domains (because any domain would match), but it might have
6989value if the result of the lookup is being used via the \$domain@_data$\
6990expansion variable.
6991.nextp
6992If the pattern starts with the name of a query-style lookup type followed by a
6993semicolon (for example, `nisplus;' or `ldap;'), the remainder of the pattern
6994must be an appropriate query for the lookup type, as described in chapter
6995~~CHAPfdlookup. For example:
6996.display asis
6997hold_domains = mysql;select domain from holdlist \
6998 where domain = '$domain';
6999.endd
7000In most cases, the data that is looked up is not used (so for an SQL query, for
7001example, it doesn't matter what field you select). Exim is interested only in
7002whether or not the query succeeds. However, when a lookup is used for the
7003\domains\ option on a router, the data is preserved in the \$domain@_data$\
7004variable and can be referred to in other options.
7005.nextp
7006.index domain list||matching literal domain name
7007If none of the above cases apply, a caseless textual comparison is made between
7008the pattern and the domain.
7009.endp
7010
7011Here is an example that uses several different kinds of pattern:
7012.display asis
7013domainlist funny_domains = \
7014 @ : \
7015 lib.unseen.edu : \
7016 *.foundation.fict.example : \
7017 \N^[1-2]\d{3}\.fict\.example$\N : \
7018 partial-dbm;/opt/data/penguin/book : \
7019 nis;domains.byname : \
7020 nisplus;[name=$domain,status=local],domains.org_dir
7021.endd
7022There are obvious processing trade-offs among the various matching modes. Using
7023an asterisk is faster than a regular expression, and listing a few names
7024explicitly probably is too. The use of a file or database lookup is expensive,
7025but may be the only option if hundreds of names are required. Because the
7026patterns are tested in order, it makes sense to put the most commonly matched
7027patterns earlier.
7028
7029
7030.section Host lists
7031.rset SECThostlist "~~chapter.~~section"
7032.index host list||patterns in
7033.index list||host list
7034Host lists are used to control what remote hosts are allowed to do. For
7035example, some hosts may be allowed to use the local host as a relay, and some
7036may be permitted to use the SMTP \\ETRN\\ command. Hosts can be identified in
7037two different ways, by name or by IP address. In a host list, some types of
7038pattern are matched to a host name, and some are matched to an IP address.
7039You need to be particularly careful with this when single-key lookups are
7040involved, to ensure that the right value is being used as the key.
7041
7042.section Special host list patterns
7043.index empty item in hosts list
7044.index host list||empty string in
7045If a host list item is the empty string, it matches only when no remote host is
7046involved. This is the case when a message is being received from a local
7047process using SMTP on the standard input, that is, when a TCP/IP connection is
7048not used.
7049
7050.index asterisk||in host list
7051The special pattern `$*$' in a host list matches any host or no host. Neither
7052the IP address nor the name is actually inspected.
7053
7054
7055.section Host list patterns that match by IP address
7056.rset SECThoslispatip "~~chapter.~~section"
7057.index host list||matching IP addresses
7058If an IPv4 host calls an IPv6 host and the call is accepted on an IPv6 socket,
7059the incoming address actually appears in the IPv6 host as
7060`@:@:$tt{ffff}:<<v4address>>'. When such an address is tested against a host
7061list, it is converted into a traditional IPv4 address first. (Not all operating
7062systems accept IPv4 calls on IPv6 sockets, as there have been some security
7063concerns.)
7064
7065The following types of pattern in a host list check the remote host by
7066inspecting its IP address:
7067.numberpars $.
7068If the pattern is a plain domain name (not a regular expression, not starting
7069with $*$, not a lookup of any kind), Exim calls the operating system function
7070to find the associated IP address(es). Exim uses the newer
7071\*getipnodebyname()*\ function when available, otherwise \*gethostbyname()*\.
7072This typically causes a forward DNS lookup of the name. The result is compared
7073with the IP address of the subject host.
7074
7075.em
7076If there is a temporary problem (such as a DNS timeout) with the host name
7077lookup, a temporary error occurs. For example, if the list is being used in an
7078ACL condition, the ACL gives a `defer' response, usually leading to a temporary
7079SMTP error code. If no IP address can be found for the host name, what happens
7080is described in section ~~SECTbehipnot below.
7081.nem
7082
7083.nextp
7084.index @@ in a host list
7085If the pattern is `@@', the primary host name is substituted and used as a
7086domain name, as just described.
7087.nextp
7088If the pattern is an IP address, it is matched against the IP address of the
7089subject host. IPv4 addresses are given in the normal `dotted-quad' notation.
7090IPv6 addresses can be given in colon-separated format, but the colons have to
7091be doubled so as not to be taken as item separators when the default list
7092separator is used. IPv6 addresses are recognized even when Exim is compiled
7093without IPv6 support. This means that if they appear in a host list on an
7094IPv4-only host, Exim will not treat them as host names. They are just addresses
7095that can never match a client host.
7096.nextp
7097.index @@[] in a host list
7098If the pattern is `@@[]', it matches the IP address of any IP interface on
7099the local host. For example, if the local host is an IPv4 host with one
7100interface address 10.45.23.56, these two ACL statements have the same effect:
7101.display asis
7102accept hosts = 127.0.0.1 : 10.45.23.56
7103accept hosts = @[]
7104.endd
7105.nextp
7106If the pattern is an IP address followed by a slash and a mask length (for
7107example 10.11.42.0/24), it is matched against the IP address of the subject
7108host under the given mask.
7109This allows, an entire network of hosts to be included (or excluded) by a
7110single item.
7111.index CIDR notation
7112The mask uses CIDR notation; it specifies the number of address bits that must
7113match, starting from the most significant end of the address.
7114
7115\**Note**\: the mask is \*not*\ a count of addresses, nor is it the high number
7116of a range of addresses. It is the number of bits in the network portion of the
7117address. The above example specifies a 24-bit netmask, so it matches all 256
7118addresses in the 10.11.42.0 network. An item such as
7119.display asis
7120192.168.23.236/31
7121.endd
7122matches just two addresses, 192.168.23.236 and 192.168.23.237. A mask value of
712332 for an IPv4 address is the same as no mask at all; just a single address
7124matches.
7125
7126Here is another example which shows an IPv4 and an IPv6 network:
7127.display asis
7128recipient_unqualified_hosts = 192.168.0.0/16: \
7129 3ffe::ffff::836f::::/48
7130.endd
7131The doubling of list separator characters applies only when these items
7132appear inline in a host list. It is not required when indirecting via a file.
7133For example,
7134.display asis
7135recipient_unqualified_hosts = /opt/exim/unqualnets
7136.endd
7137could make use of a file containing
7138.display asis
7139172.16.0.0/12
71403ffe:ffff:836f::/48
7141.endd
7142to have exactly the same effect as the previous example. When listing IPv6
7143addresses inline, it is usually more convenient to use the facility for
7144changing separator characters. This list contains the same two networks:
7145.display asis
7146recipient_unqualified_hosts = <; 172.16.0.0/12; \
7147 3ffe:ffff:836f::/48
7148.endd
7149The separator is changed to semicolon by the leading `<;' at the start of the
7150list.
7151.endp
7152
7153
7154.section Host list patterns for single-key lookups by host address
7155.rset SECThoslispatsikey "~~chapter.~~section"
7156.index host list||lookup of IP address
7157When a host is to be identified by a single-key lookup of its complete IP
7158address, the pattern takes this form:
7159.display
7160net-<<single-key-search-type>>;<<search-data>>
7161.endd
7162For example:
7163.display asis
7164hosts_lookup = net-cdb;/hosts-by-ip.db
7165.endd
7166The text form of the IP address of the subject host is used as the lookup key.
7167IPv6 addresses are converted to an unabbreviated form, using lower case
7168letters, with dots as separators because colon is the key terminator in
7169\%lsearch%\ files. [Colons can in fact be used in keys in \%lsearch%\ files by
7170quoting the keys, but this is a facility that was added later.] The data
7171returned by the lookup is not used.
7172
7173.index IP address||masking
7174.index host list||masked IP address
7175Single-key lookups can also be performed using masked IP addresses, using
7176patterns of this form:
7177.display
7178net<<number>>-<<single-key-search-type>>;<<search-data>>
7179.endd
7180For example:
7181.display asis
7182net24-dbm;/networks.db
7183.endd
7184The IP address of the subject host is masked using <<number>> as the mask
7185length. A textual string is constructed from the masked value, followed by the
7186mask, and this is used as the lookup key. For example, if the host's IP address
7187is 192.168.34.6, the key that is looked up for the above example is
7188`192.168.34.0/24'. IPv6 addresses are converted to a text value using lower
7189case letters and dots as separators instead of the more usual colon, because
7190colon is the key terminator in \%lsearch%\ files. Full, unabbreviated IPv6
7191addresses are always used.
7192
7193\**Warning**\: Specifing \net32@-\ (for an IPv4 address) or \net128@-\ (for an
7194IPv6 address) is not the same as specifing just \net@-\ without a number. In
7195the former case the key strings include the mask value, whereas in the latter
7196case the IP address is used on its own.
7197
7198
7199.section Host list patterns that match by host name
7200.rset SECThoslispatnam "~~chapter.~~section"
7201.index host||lookup failures
7202.index unknown host name
7203.index host list||matching host name
7204There are several types of pattern that require Exim to know the name of the
7205remote host. These are either wildcard patterns or lookups by name. (If a
7206complete hostname is given without any wildcarding, it is used to find an IP
7207address to match against, as described in the section ~~SECThoslispatip above.)
7208
7209If the remote host name is not already known when Exim encounters one of these
7210patterns, it has to be found from the IP address.
7211.em
7212Although many sites on the Internet are conscientious about maintaining reverse
7213DNS data for their hosts, there are also many that do not do this.
7214Consequently, a name cannot always be found, and this may lead to unwanted
7215effects. Take care when configuring host lists with wildcarded name patterns.
7216Consider what will happen if a name cannot be found.
7217
7218Because of the problems of determining host names from IP addresses, matching
7219against host names is not as common as matching against IP addresses.
7220
7221By default, in order to find a host name, Exim first does a reverse DNS lookup;
7222if no name is found in the DNS, the system function (\*gethostbyaddr()*\ or
7223\*getipnodebyaddr()*\ if available) is tried. The order in which these lookups
7224are done can be changed by setting the \host@_lookup@_order\ option.
7225
7226There are some options that control what happens if a host name cannot be
7227found. These are described in section ~~SECTbehipnot below.
7228.nem
7229
7230
7231.index host||alias for
7232.index alias for host
7233As a result of aliasing, hosts may have more than one name. When processing any
7234of the following types of pattern, all the host's names are checked:
7235.numberpars $.
7236.index asterisk||in host list
7237If a pattern starts with `$*$' the remainder of the item must match the end of
7238the host name. For example, \"*.b.c"\ matches all hosts whose names end in
7239\*.b.c*\. This special simple form is provided because this is a very common
7240requirement. Other kinds of wildcarding require the use of a regular
7241expression.
7242.nextp
7243.index regular expressions||in host list
7244.index host list||regular expression in
7245If the item starts with `@^' it is taken to be a regular expression which is
7246matched against the host name. For example,
7247.display asis
7248^(a|b)\.c\.d$
7249.endd
7250is a regular expression that matches either of the two hosts \*a.c.d*\ or
7251\*b.c.d*\. When a regular expression is used in a host list, you must take care
7252that backslash and dollar characters are not misinterpreted as part of the
7253string expansion. The simplest way to do this is to use \"@\N"\ to mark that
7254part of the string as non-expandable. For example:
7255.display asis
7256sender_unqualified_hosts = \N^(a|b)\.c\.d$\N : ....
7257.endd
7258.em
7259\**Warning**\: If you want to match a complete host name, you must include the
7260\"@$"\ terminating metacharacter in the regular expression, as in the above
7261example. Without it, a match at the start of the host name is all that is
7262required.
7263.nem
7264.endp
7265
7266
7267.em
7268.section Behaviour when an IP address or name cannot be found
7269.rset SECTbehipnot "~~chapter.~~section"
7270.index host||lookup failures
7271While processing a host list, Exim may need to look up an IP address from a
7272name (see section ~~SECThoslispatip), or it may need to look up a host name
7273from an IP address (see section ~~SECThoslispatnam). In either case, the
7274behaviour when it fails to find the information it is seeking is the same.
7275
7276.index \"+include@_unknown"\
7277.index \"+ignore@_unknown"\
7278By default, Exim behaves as if the host does not match the list. This may not
7279always be what you want to happen. To change Exim's behaviour, the special
7280items \"+include@_unknown"\ or \"+ignore@_unknown"\ may appear in the list (at
7281top level -- they are not recognized in an indirected file).
7282.numberpars $.
7283If any item that follows \"+include@_unknown"\ requires information that
7284cannot found, Exim behaves as if the host does match the list. For example,
7285.display asis
7286host_reject_connection = +include_unknown:*.enemy.ex
7287.endd
7288rejects connections from any host whose name matches \"*.enemy.ex"\, and also
7289any hosts whose name it cannot find.
7290.nextp
7291If any item that follows \"+ignore@_unknown"\ requires information that cannot
7292be found, Exim ignores that item and proceeds to the rest of the list. For
7293example:
7294.display asis
7295accept hosts = +ignore_unknown : friend.example : \
7296 192.168.4.5
7297.endd
7298accepts from any host whose name is \*friend.example*\ and from 192.168.4.5,
7299whether or not its host name can be found. Without \"+ignore@_unknown"\, if no
7300name can be found for 192.168.4.5, it is rejected.
7301.endp
7302Both \"+include@_unknown"\ and \"+ignore@_unknown"\ may appear in the same
7303list. The effect of each one lasts until the next, or until the end of the
7304list.
7305
7306\**Note**\: This section applies to permanent lookup failures. It does \*not*\
7307apply to temporary DNS errors. They always cause a defer action.
7308.nem
7309
7310
7311.section Host list patterns for single-key lookups by host name
7312.rset SECThoslispatnamsk "~~chapter.~~section"
7313.index host||lookup failures
7314.index unknown host name
7315.index host list||matching host name
7316If a pattern is of the form
7317.display
7318<<single-key-search-type>>;<<search-data>>
7319.endd
7320for example
7321.display asis
7322dbm;/host/accept/list
7323.endd
7324a single-key lookup is performend, using the host name as its key. If the
7325lookup succeeds, the host matches the item. The actual data that is looked up
7326is not used.
7327
7328\**Reminder**\: With this kind of pattern, you must have host $it{names} as
7329keys in the file, not IP addresses. If you want to do lookups based on IP
7330addresses, you must precede the search type with `net-' (see section
7331~~SECThoslispatsikey). There is, however, no reason why you could not use two
7332items in the same list, one doing an address lookup and one doing a name
7333lookup, both using the same file.
7334
7335
7336.section Host list patterns for query-style lookups
7337If a pattern is of the form
7338.display
7339<<query-style-search-type>>;<<query>>
7340.endd
7341the query is obeyed, and if it succeeds, the host matches the item. The actual
7342data that is looked up is not used. The variables \$sender@_host@_address$\ and
7343\$sender@_host@_name$\ can be used in the query. For example:
7344.display asis
7345hosts_lookup = pgsql;\
7346 select ip from hostlist where ip='$sender_host_address'
7347.endd
7348The value of \$sender@_host@_address$\ for an IPv6 address uses colon
7349separators. You can use the \sg\ expansion item to change this if you need to.
7350If you want to use masked IP addresses in database queries, you can use the
7351\mask\ expansion operator.
7352
7353If the query contains a reference to \$sender@_host@_name$\, Exim automatically
7354looks up the host name if has not already done so. (See section
7355~~SECThoslispatnam for comments on finding host names.)
7356
7357Historical note: prior to release 4.30, Exim would always attempt to find a
7358host name before running the query, unless the search type was preceded by
7359\"net-"\. This is no longer the case. For backwards compatibility, \"net-"\ is
7360still recognized for query-style lookups, but its presence or absence has no
7361effect. (Of course, for single-key lookups, \"net-"\ $it{is} important.)
7362
7363
7364.section Mixing wildcarded host names and addresses in host lists
7365.rset SECTmixwilhos "~~chapter.~~section"
7366.index host list||mixing names and addresses in
7367If you have name lookups or wildcarded host names and IP addresses in the same
7368host list, you should normally put the IP addresses first. For example, in an
7369ACL you could have:
7370.display asis
7371accept hosts = 10.9.8.7 : *.friend.example
7372.endd
7373The reason for this lies in the left-to-right way that Exim processes lists.
7374It can test IP addresses without doing any DNS lookups, but when it reaches an
7375item that requires a host name, it fails if it cannot find a host name to
7376compare with the pattern. If the above list is given in the opposite order, the
7377\accept\ statement fails for a host whose name cannot be found, even if its
7378IP address is 10.9.8.7.
7379
7380If you really do want to do the name check first, and still recognize the IP
7381address, you can rewrite the ACL like this:
7382.display asis
7383accept hosts = *.friend.example
7384accept hosts = 10.9.8.7
7385.endd
7386If the first \accept\ fails, Exim goes on to try the second one. See chapter
7387~~CHAPACL for details of ACLs.
7388
7389
7390
7391
7392.section Address lists
7393.index list||address list
7394.index address list||empty item
7395.index address list||patterns
7396.rset SECTaddresslist "~~chapter.~~section"
7397Address lists contain patterns that are matched against mail addresses. There
7398is one special case to be considered: the sender address of a bounce message is
7399always empty. You can test for this by providing an empty item in an address
7400list. For example, you can set up a router to process bounce messages by
7401using this option setting:
7402.display asis
7403senders = :
7404.endd
7405The presence of the colon creates an empty item. If you do not provide any
7406data, the list is empty and matches nothing. The empty sender can also be
7407detected by a regular expression that matches an empty string.
7408
7409The following kinds of pattern are supported in address lists:
7410.numberpars $.
7411.index regular expressions||in address list
7412.index address list||regular expression in
7413If (after expansion) a pattern starts with `@^', a regular expression match is
7414done against the complete address, with the pattern as the regular expression.
7415You must take care that backslash and dollar characters are not misinterpreted
7416as part of the string expansion. The simplest way to do this is to use \"@\N"\
7417to mark that part of the string as non-expandable. For example:
7418.display asis
7419deny senders = \N^\d{8}.+@spamhaus.example$\N : ...
7420.endd
7421The \"@\N"\ sequences are removed by the expansion, so the item does start
7422with `@^' by the time it is being interpreted as an address pattern.
7423.nextp
7424.index @@@@ with single-key lookup
7425.index address list||@@@@ lookup type
7426.index address list||split local part and domain
7427If a pattern starts with `@@@@' followed by a single-key lookup item
7428(for example, \"@@@@lsearch;/some/file"\), the address that is being checked is
7429split into a local part and a domain. The domain is looked up in the file. If
7430it is not found, there is no match. If it is found, the data that is looked up
7431from the file is treated as a colon-separated list of local part patterns, each
7432of which is matched against the subject local part in turn.
7433
7434.index asterisk||in address list
7435The lookup may be a partial one, and/or one involving a search for a default
7436keyed by `$*$' (see section ~~SECTdefaultvaluelookups). The local part patterns
7437that are looked up can be regular expressions or begin with `$*$', or even be
7438further lookups. They may also be independently negated. For example, with
7439.display asis
7440deny senders = @@dbm;/etc/reject-by-domain
7441.endd
7442the data from which the DBM file is built could contain lines like
7443.display asis
7444baddomain.com: !postmaster : *
7445.endd
7446to reject all senders except \postmaster\ from that domain.
7447.index local part||starting with !
7448If a local part that actually begins with an exclamation mark is required, it
7449has to be specified using a regular expression. In \%lsearch%\ files, an entry
7450may be split over several lines by indenting the second and subsequent lines,
7451but the separating colon must still be included at line breaks. White space
7452surrounding the colons is ignored. For example:
7453.display asis
7454aol.com: spammer1 : spammer2 : ^[0-9]+$ :
7455 spammer3 : spammer4
7456.endd
7457As in all colon-separated lists in Exim, a colon can be included in an item by
7458doubling.
7459
7460If the last item in the list starts with a right angle-bracket, the remainder
7461of the item is taken as a new key to look up in order to obtain a continuation
7462list of local parts. The new key can be any sequence of characters. Thus one
7463might have entries like
7464.display asis
7465aol.com: spammer1 : spammer 2 : >*
7466xyz.com: spammer3 : >*
7467*: ^\d{8}$
7468.endd
7469in a file that was searched with \@@@@dbm$*$\, to specify a match for 8-digit
7470local parts for all domains, in addition to the specific local parts listed for
7471each domain. Of course, using this feature costs another lookup each time a
7472chain is followed, but the effort needed to maintain the data is reduced.
7473.index loop||in lookups
7474It is possible to construct loops using this facility, and in order to catch
7475them, the chains may be no more than fifty items long.
7476.nextp
7477The @@@@<<lookup>> style of item can also be used with a query-style
7478lookup, but in this case, the chaining facility is not available. The lookup
7479can only return a single list of local parts.
7480.nextp
7481.index address list||lookup for complete address
7482Complete addresses can be looked up by using a pattern that
7483starts with a lookup type terminated by a semicolon, follwed by the data for
7484the lookup.
7485For example:
7486.display asis
7487deny senders = cdb;/etc/blocked.senders : \
7488 mysql;select address from blocked where \
7489 address='${quote_mysql:$sender_address}'
7490.endd
7491For a single-key lookup type, Exim uses the complete address as the key.
7492Partial matching (section ~~SECTpartiallookup) cannot be used, and is ignored
7493if specified, with an entry being written to the panic log.
7494
7495.index @*@@ with single-key lookup
7496You can configure lookup defaults, as described in section
7497~~SECTdefaultvaluelookups, but this is useful only for the `$*$@@' type of
7498default. For example, with this lookup:
7499.display asis
7500accept senders = lsearch*@;/some/file
7501.endd
7502the file could contains lines like this:
7503.display asis
7504user1@domain1.example
7505*@domain2.example
7506.endd
7507and for the sender address \*nimrod@@jaeger.example*\, the sequence of keys
7508that are tried is:
7509.display asis
7510nimrod@jaeger.example
7511*@jaeger.example
7512*
7513.endd
7514\**Warning 1**\: Do not include a line keyed by `$*$' in the file, because that
7515would mean that every address matches, thus rendering the test useless.
7516
7517\**Warning 2**\: Do not confuse these two kinds of item:
7518.display asis
7519deny recipients = dbm*@;/some/file
7520deny recipients = *@dbm;/some/file
7521.endd
7522The first does a whole address lookup, with defaulting, as just described,
7523because it starts with a lookup type. The second matches the local part and
7524domain independently, as described in the next paragraph.
7525.nextp
7526If a pattern contains an @@ character, but is not a regular expression
7527and does not begin with a lookup type
7528as described above, the local part of the subject address is compared with the
7529local part of the pattern, which may start with an asterisk. If the local parts
7530match, the domain is checked in exactly the same way as for a pattern in a
7531domain list. For example, the domain can be wildcarded, refer to a named list,
7532or be a lookup:
7533.display asis
7534deny senders = *@*.spamming.site:\
7535 *@+hostile_domains:\
7536 bozo@partial-lsearch;/list/of/dodgy/sites:\
7537.newline
7538 *@dbm;/bad/domains.db
7539.endd
7540.index local part||starting with !
7541.index address list||local part starting with !
7542If a local part that begins with an exclamation mark is required, it has to be
7543specified using a regular expression, because otherwise the exclamation mark is
7544treated as a sign of negation.
7545.nextp
7546If a pattern is not one of the above syntax forms, that is, if a pattern which
7547is not a regular expression or a lookup does not contain an @@ character, it is
7548matched against the domain part of the subject address. The only two formats
7549that are recognized this way are a literal domain, or a domain pattern that
7550starts with $*$. In both these cases, the effect is the same as if \"*@@"\
7551preceded the pattern.
7552.endp
7553
7554\**Warning**\: there is an important difference between the address list items
7555in these two examples:
7556.display asis
7557senders = +my_list
7558senders = *@+my_list
7559.endd
7560In the first one, \"my@_list"\ is a named address list, whereas in the second
7561example it is a named domain list.
7562
7563
7564
7565.section Case of letters in address lists
7566.rset SECTcasletadd "~~chapter.~~section"
7567.index case of local parts
7568.index address list||case forcing
7569.index case forcing in address lists
7570Domains in email addresses are always handled caselessly, but for local parts
7571case may be significant on some systems (see \caseful@_local@_part\ for how
7572Exim deals with this when routing addresses). However, RFC 2505 ($it{Anti-Spam
7573Recommendations for SMTP MTAs}) suggests that matching of addresses to blocking
7574lists should be done in a case-independent manner. Since most address lists in
7575Exim are used for this kind of control, Exim attempts to do this by default.
7576
7577The domain portion of an address is always lowercased before matching it to an
7578address list. The local part is lowercased by default, and any string
7579comparisons that take place are done caselessly. This means that the data in
7580the address list itself, in files included as plain file names, and in any file
7581that is looked up using the `@@@@' mechanism, can be in any case. However, the
7582keys in files that are looked up by a search type other than \%lsearch%\ (which
7583works caselessly) must be in lower case, because these lookups are not
7584case-independent.
7585
7586.index \"+caseful"\
7587To allow for the possibility of caseful address list matching, if an item in
7588an address list is the string `+caseful', the original case of the local
7589part is restored for any comparisons that follow, and string comparisons are no
7590longer case-independent. This does not affect the domain, which remains in
7591lower case. However, although independent matches on the domain alone are still
7592performed caselessly, regular expressions that match against an entire address
7593become case-sensitive after `+caseful' has been seen.
7594
7595
7596.section Local part lists
7597.rset SECTlocparlis "~~chapter.~~section"
7598.index list||local part list
7599.index local part||list
7600Case-sensitivity in local part lists is handled in the same way as for address
7601lists, as just described. The `+caseful' item can be used if required. In a
7602setting of the \local@_parts\ option in a router with \caseful@_local@_part\
7603set false, the subject is lowercased and the matching is initially
7604case-insensitive. In this case, `+caseful' will restore case-sensitive matching
7605in the local part list, but not elsewhere in the router. If
7606\caseful@_local@_part\ is set true in a router, matching in the \local@_parts\
7607option is case-sensitive from the start.
7608
7609If a local part list is indirected to a file (see section ~~SECTfilnamlis),
7610comments are handled in the same way as address lists -- they are recognized
7611only if the @# is preceded by white space or the start of the line.
7612Otherwise, local part lists are matched in the same way as domain lists, except
7613that the special items that refer to the local host (\"@@"\, \"@@[]"\,
7614\"@@mx@_any"\, \"@@mx@_primary"\, and \"@@mx@_secondary"\) are not recognized.
7615Refer to section ~~SECTdomainlist for details of the other available item
7616types.
7617
7618
7619
7620.
7621.
7622.
7623.
7624. ============================================================================
7625.chapter String expansions
7626.set runningfoot "string expansions"
7627.rset CHAPexpand ~~chapter
7628.index expansion||of strings
7629Many strings in Exim's run time configuration are expanded before use. Some of
7630them are expanded every time they are used; others are expanded only once.
7631
7632When a string is being expanded it is copied verbatim from left to right except
7633when a dollar or backslash character is encountered. A dollar specifies the
7634start of a portion of the string which is interpreted and replaced as described
7635below in section ~~SECTexpansionitems onwards. Backslash is used as an escape
7636character, as described in the following section.
7637
7638
7639.section Literal text in expanded strings
7640.rset SECTlittext "~~chapter.~~section"
7641.index expansion||including literal text
7642An uninterpreted dollar can be included in an expanded string by putting a
7643backslash in front of it. A backslash can be used to prevent any special
7644character being treated specially in an expansion, including itself. If the
7645string appears in quotes in the configuration file, two backslashes are
7646required because the quotes themselves cause interpretation of backslashes when
7647the string is read in (see section ~~SECTstrings).
7648
7649.index expansion||non-expandable substrings
7650A portion of the string can specified as non-expandable by placing it between
7651two occurrences of \"@\N"\. This is particularly useful for protecting regular
7652expressions, which often contain backslashes and dollar signs. For example:
7653.display asis
7654deny senders = \N^\d{8}[a-z]@some\.site\.example$\N
7655.endd
7656On encountering the first \"@\N"\, the expander copies subsequent characters
7657without interpretation until it reaches the next \"@\N"\ or the end of the
7658string.
7659
7660
7661.section Character escape sequences in expanded strings
7662.index expansion||escape sequences
7663A backslash followed by one of the letters `n', `r', or `t' in an expanded
7664string is recognized as an escape sequence for the character newline, carriage
7665return, or tab, respectively. A backslash followed by up to three octal digits
7666is recognized as an octal encoding for a single character, and a backslash
7667followed by `x' and up to two hexadecimal digits is a hexadecimal encoding.
7668
7669These escape sequences are also recognized in quoted strings when they are read
7670in. Their interpretation in expansions as well is useful for unquoted strings,
7671and for other cases such as looked-up strings that are then expanded.
7672
7673.section Testing string expansions
7674.index expansion||testing
7675.index testing||string expansion
7676.index \-be-\ option
7677Many expansions can be tested by calling Exim with the \-be-\ option. This takes
7678the command arguments, or lines from the standard input if there are no
7679arguments, runs them through the string expansion code, and writes the results
7680to the standard output. Variables based on configuration values are set up, but
7681since no message is being processed, variables such as \$local@_part$\ have no
7682value. Nevertheless the \-be-\ option can be useful for checking out file and
7683database lookups, and the use of expansion operators such as \sg\, \substr\ and
7684\nhash\.
7685
7686Exim gives up its root privilege when it is called with the \-be-\ option, and
7687instead runs under the uid and gid it was called with, to prevent users from
7688using \-be-\ for reading files to which they do not have access.
7689
7690
7691.section Expansion items
7692.rset SECTexpansionitems "~~chapter.~~section"
7693The following items are recognized in expanded strings. White space may be used
7694between sub-items that are keywords or substrings enclosed in braces inside an
7695outer set of braces, to improve readability. \**Warning**\: Within braces,
7696white space is significant.
7697
7698.startitems
7699
7700.item "@$<<variable name>>#$rm{or}#@$@{<<variable name>>@}"
7701.index expansion||variables
7702Substitute the contents of the named variable, for example
7703.display asis
7704$local_part
7705${domain}
7706.endd
7707The second form can be used to separate the name from subsequent alphanumeric
7708characters. This form (using curly brackets) is available only for variables;
7709it does $it{not} apply to message headers. The names of the variables are given
7710in section ~~SECTexpvar below. If the name of a non-existent variable is given,
7711the expansion fails.
7712
7713.item "@$@{<<op>>:<<string>>@}"
7714.index expansion||operators
7715The string is first itself expanded, and then the operation specified by <<op>>
7716is applied to it. For example,
7717.display asis
7718${lc:$local_part}
7719.endd
7720The string starts with the first character after the colon, which may be
7721leading white space. A list of operators is given in section ~~SECTexpop below.
7722The operator notation is used for simple expansion items that have just one
7723argument, because it reduces the number of braces and therefore makes the
7724string easier to understand.
7725
7726.item "@$@{extract@{<<key>>@}@{<<string1>>@}@{<<string2>>@}@{<<string3>>@}@}"
7727.index expansion||extracting substrings by key
7728The key and <<string1>> are first expanded separately.
7729Leading and trailing whitespace is removed from the key (but not from any of
7730the strings).
7731The key must not consist entirely of digits. The expanded <<string1>> must be
7732of the form:
7733.display
7734<<key1>> = <<value1>> <<key2>> = <<value2>> ...
7735.endd
7736where the equals signs and spaces (but not both) are optional. If any of the
7737values contain white space, they must be enclosed in double quotes, and any
7738values that are enclosed in double quotes are subject to escape processing as
7739described in section ~~SECTstrings. The expanded <<string1>> is searched for
7740the value that corresponds to the key. The search is case-insensitive. If the
7741key is found, <<string2>> is expanded, and replaces the whole item; otherwise
7742<<string3>> is used. During the expansion of <<string2>> the variable \$value$\
7743contains the value that has been extracted. Afterwards, it is restored to any
7744previous value it might have had.
7745
7746If @{<<string3>>@} is omitted, the item is replaced by an empty string if the
7747key is not found. If @{<<string2>>@} is also omitted, the value that was
7748extracted is used. Thus, for example, these two expansions are identical, and
7749yield `2001':
7750.display
7751@$@{extract@{gid@}{uid=1984 gid=2001@}@}
7752@$@{extract@{gid@}{uid=1984 gid=2001@}@{@$value@}@}
7753.endd
7754Instead of @{<<string3>>@} the word `fail' (not in curly brackets) can appear,
7755for example:
7756.display
7757@$@{extract@{Z@}@{A=... B=...@}@{@$value@} fail @}
7758.endd
7759@{<<string2>>@} must be present for `fail' to be recognized. When this syntax
7760is used, if the extraction fails, the entire string expansion fails in a way
7761that can be detected by the code in Exim which requested the expansion. This is
7762called `forced expansion failure', and its consequences depend on the
7763circumstances. In some cases it is no different from any other expansion
7764failure, but in others a different action may be taken. Such variations are
7765mentioned in the documentation of the option which is expanded.
7766
7767
7768.item "@$@{extract@{<<number>>@}@{<<separators>>@}@{<<string1>>@}@{<<string2>>@}@{<<string3>>@}@}"
7769.index expansion||extracting substrings by number
7770The <<number>> argument must consist entirely of decimal digits,
7771apart from leading and trailing whitespace, which is ignored.
7772This is what distinguishes this form of \extract\ from the previous kind. It
7773behaves in the same way, except that, instead of extracting a named field, it
7774extracts from <<string1>> the field whose number is given as the first
7775argument. You can use \$value$\ in <<string2>> or \"fail"\ instead of
7776<<string3>> as before.
7777
7778The fields in the string are separated by any one of the characters in the
7779separator string. These may include space or tab characters.
7780The first field is numbered one. If the number is negative, the fields are
7781counted from the end of the string, with the rightmost one numbered -1. If the
7782number given is zero, the entire string is returned. If the modulus of the
7783number is greater than the number of fields in the string, the result is the
7784expansion of <<string3>>, or the empty string if <<string3>> is not provided.
7785For example:
7786.display asis
7787${extract{2}{:}{x:42:99:& Mailer::/bin/bash}}
7788.endd
7789yields `42', and
7790.display asis
7791${extract{-4}{:}{x:42:99:& Mailer::/bin/bash}}
7792.endd
7793yields `99'. Two successive separators mean that the field between them is
7794empty (for example, the fifth field above).
7795
7796
7797.item "@$@{hash@{<<string1>>@}@{<<string2>>@}@{<<string3>>@}@}"
7798.index hash function||textual
7799.index expansion||textual hash
7800This is a textual hashing function, and was the first to be implemented in
7801early versions of Exim. In current releases, there are other hashing functions
7802(numeric, MD5, and SHA-1), which are described below.
7803
7804The first two strings, after expansion, must be numbers. Call them <<m>> and
7805<<n>>. If you are using fixed values for these numbers, that is, if <<string1>>
7806and <<string2>> do not change when they are expanded, you can use the
7807simpler operator notation that avoids some of the braces:
7808.display
7809@$@{hash@_<<n>>@_<<m>>:<<string>>@}
7810.endd
7811The second number is optional (in both notations).
7812
7813If <<n>> is greater than or equal to the length of the string, the expansion
7814item returns the string. Otherwise it computes a new string of length <<n>> by
7815applying a hashing function to the string. The new string consists of
7816characters taken from the first <<m>> characters of the string
7817.display asis
7818abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQWRSTUVWXYZ0123456789
7819.endd
7820If <<m>> is not present the value 26 is used, so that only lower case
7821letters appear. For example:
7822.display
7823@$@{hash@{3@}@{monty@}@} $rm{yields} \"jmg"\
7824@$@{hash@{5@}@{monty@}@} $rm{yields} \"monty"\
7825@$@{hash@{4@}@{62@}@{monty python@}@} $rm{yields} \"fbWx"\
7826.endd
7827
7828
7829.item "@$header@_<<header name>>:#$rm{or}#@$h@_<<header name>>:"
7830.item "@$bheader@_<<header name>>:#$rm{or}#@$bh@_<<header name>>:"
7831.item "@$rheader@_<<header name>>:#$rm{or}#@$rh@_<<header name>>:"
7832.index expansion||header insertion
7833.index \$header@_$\
7834.index \$bheader@_$\
7835.index \$rheader@_$\
7836.index header lines||in expansion strings
7837.index header lines||character sets
7838.index header lines||decoding
7839Substitute the contents of the named message header line, for example
7840.display asis
7841$header_reply-to:
7842.endd
7843The newline that terminates a header line is not included in the expansion, but
7844internal newlines (caused by splitting the header line over several physical
7845lines) may be present.
7846
7847The difference between \rheader\, \bheader\, and \header\ is in the way the
7848data in the header line is interpreted.
7849.numberpars $.
7850\rheader\ gives the original `raw' content of the header line, with no
7851processing at all, and without the removal of leading and trailing whitespace.
7852.nextp
7853.index base64 encoding||in header lines
7854\bheader\ removes leading and trailing whitespace, and then decodes base64 or
7855quoted-printable MIME `words' within the header text, but does no character
7856set translation. If decoding of what looks superficially like a MIME `word'
7857fails, the raw string is returned.
7858.index binary zero||in header line
7859If decoding produces a binary zero character, it is replaced by a question mark
7860-- this is what Exim does for binary zeros that are actually received in header
7861lines.
7862.nextp
7863\header\ tries to translate the string as decoded by \bheader\ to a standard
7864character set. This is an attempt to produce the same string as would be
7865displayed on a user's MUA. If translation fails, the \bheader\ string is
7866returned. Translation is attempted only on operating systems that support the
7867\*iconv()*\ function. This is indicated by the compile-time macro
7868\\HAVE@_ICONV\\ in a system Makefile or in \(Local/Makefile)\.
7869.endp
7870
7871In a filter file, the target character set for \header\ can be specified by a
7872command of the following form:
7873.display asis
7874headers charset "UTF-8"
7875.endd
7876This command affects all references to \$h@_$\ (or \$header@_$\) expansions in
7877subsequently obeyed filter commands. In the absence of this command, the target
7878character set in a filter is taken from the setting of the \headers@_charset\
7879option in the runtime configuration. The value of this option defaults to the
7880value of \\HEADERS@_CHARSET\\ in \(Local/Makefile)\. The ultimate default is
7881ISO-8859-1.
7882
7883Header names follow the syntax of RFC 2822, which states that they may contain
7884any printing characters except space and colon. Consequently, curly brackets
7885$it{do not} terminate header names, and should not be used to enclose them as
7886if they were variables. Attempting to do so causes a syntax error.
7887
7888Only header lines that are common to all copies of a message are visible to
7889this mechanism. These are the original header lines that are received with the
7890message, and any that are added by
7891an ACL \warn\ statement or by
7892a system filter. Header lines that are added to a particular copy of a message
7893by a router or transport are not accessible.
7894
7895For incoming SMTP messages, no header lines are visible in ACLs that are obeyed
7896before the \\DATA\\ ACL, because the header structure is not set up until the
7897message is received. Header lines that are added by \warn\ statements in a
7898\\RCPT\\ ACL (for example) are saved until the message's incoming header lines
7899are available, at which point they are added. When a \\DATA\\ ACL is running,
7900however, header lines added by earlier ACLs are visible.
7901
7902Upper case and lower case letters are synonymous in header names. If the
7903following character is white space, the terminating colon may be omitted, but
7904this is not recommended, because you may then forget it when it is needed. When
7905white space terminates the header name, it is included in the expanded string.
7906If the message does not contain the given header, the expansion item is
7907replaced by an empty string. (See the \def\ condition in section ~~SECTexpcond
7908for a means of testing for the existence of a header.)
7909
7910If there is more than one header with the same name, they are all concatenated
7911to form the substitution string, up to a maximum length of 64K. A newline
7912character is inserted between each line.
7913For the \header\ expansion, for those headers that contain lists of addresses,
7914a comma is also inserted at the junctions between lines. This does not happen
7915for the \rheader\ expansion.
7916
7917
7918
7919.item "@$@{hmac@{<<hashname>>@}@{<<secret>>@}@{<<string>>@}@}"
7920.index expansion||hmac hashing
7921This function uses cryptographic hashing (either MD5 or SHA-1) to convert a
7922shared secret and some text into a message authentication code, as specified in
7923RFC 2104.
7924This differs from \"@$@{md5:secret@_text...@}"\ or
7925\"@$@{sha1:secret@_text...@}"\ in that the hmac step adds a signature to the
7926cryptographic hash, allowing for authentication that is not possible with MD5
7927or SHA-1 alone.
7928The hash name must expand to either \"md5"\ or \"sha1"\ at present. For
7929example:
7930.display asis
7931${hmac{md5}{somesecret}{$primary_hostname $tod_log}}
7932.endd
7933For the hostname \*mail.example.com*\ and time 2002-10-17 11:30:59, this
7934produces:
7935.display asis
7936dd97e3ba5d1a61b5006108f8c8252953
7937.endd
7938As an example of how this might be used, you might put in the main part of
7939an Exim configuration:
7940.display asis
7941SPAMSCAN_SECRET=cohgheeLei2thahw
7942.endd
7943In a router or a transport you could then have:
7944.display asis
7945headers_add = \
7946 X-Spam-Scanned: ${primary_hostname} ${message_id} \
7947 ${hmac{md5}{SPAMSCAN_SECRET}\
7948 {${primary_hostname},${message_id},$h_message-id:}}
7949.endd
7950Then given a message, you can check where it was scanned by looking at the
7951::X-Spam-Scanned:: header line. If you know the secret, you can check that this
7952header line is authentic by recomputing the authentication code from the host
7953name, message ID and the ::Message-id:: header line. This can be done using
7954Exim's \-be-\ option, or by other means, for example by using the
7955\*hmac@_md5@_hex()*\ function in Perl.
7956
7957
7958
7959.item "@${if <<condition>> @{<<string1>>@}@{<<string2>>@}@}"
7960.index expansion||conditional
7961If <<condition>> is true, <<string1>> is expanded and replaces the whole item;
7962otherwise <<string2>> is used. For example,
7963.display asis
7964${if eq {$local_part}{postmaster} {yes}{no} }
7965.endd
7966The second string need not be present; if it is not and the condition is not
7967true, the item is replaced with nothing. Alternatively, the word `fail' may be
7968present instead of the second string (without any curly brackets). In this
7969case, the expansion is forced to fail if the condition is not true. The
7970available conditions are described in section ~~SECTexpcond below.
7971
7972
7973.item "@$@{length@{<<string1>>@}@{<<string2>>@}@}"
7974.index expansion||string truncation
7975The \length\ item is used to extract the initial portion of a string. Both
7976strings are expanded, and the first one must yield a number, <<n>>, say. If you
7977are using a fixed value for the number, that is, if <<string1>> does not change
7978when expanded, you can use the simpler operator notation that avoids some of
7979the braces:
7980.display
7981@$@{length@_<<n>>:<<string>>@}
7982.endd
7983The result of this item is either the first <<n>> characters or the whole
7984of <<string2>>, whichever is the shorter. Do not confuse \length\ with
7985\strlen\, which gives the length of a string.
7986
7987
7988.item "@${lookup@{<<key>>@} <<search type>> @{<<file>>@} @{<<string1>>@} @{<<string2>>@}@}"
7989.item "@${lookup <<search type>> @{<<query>>@} @{<<string1>>@} @{<<string2>>@}@}"
7990.index expansion||lookup in
7991.index file||lookup
7992.index lookup||in expanded string
7993These items specify data lookups in files and databases, as discussed in
7994chapter ~~CHAPfdlookup. The first form is used for single-key lookups, and the
7995second is used for query-style lookups. The <<key>>, <<file>>, and <<query>>
7996strings are expanded before use.
7997
7998If there is any white space in a lookup item which is part of a filter command,
7999a retry or rewrite rule, a routing rule for the \%manualroute%\ router, or any
8000other place where white space is significant, the lookup item must be enclosed
8001in double quotes. The use of data lookups in users' filter files may be locked
8002out by the system administrator.
8003
8004.index \$value$\
8005If the lookup succeeds, <<string1>> is expanded and replaces the entire item.
8006During its expansion, the variable \$value$\ contains the data returned by the
8007lookup. Afterwards it reverts to the value it had previously (at the outer
8008level it is empty). If the lookup fails, <<string2>> is expanded and replaces
8009the entire item. If @{<<string2>>@} is omitted, the replacement is null on
8010failure. Alternatively, <<string2>> can itself be a nested lookup, thus
8011providing a mechanism for looking up a default value when the original lookup
8012fails.
8013
8014If a nested lookup is used as part of <<string1>>, \$value$\ contains the data
8015for the outer lookup while the parameters of the second lookup are expanded,
8016and also while <<string2>> of the second lookup is expanded, should the second
8017lookup fail.
8018
8019Instead of @{<<string2>>@} the word `fail' can appear, and in this case, if the
8020lookup fails, the entire expansion is forced to fail. If both @{<<string1>>@}
8021and @{<<string2>>@} are omitted, the result is the looked up value in the case
8022of a successful lookup, and nothing in the case of failure.
8023
8024For single-key lookups, the string `partial' is permitted to precede the
8025search type in order to do partial matching, and $*$ or $*$@@ may follow a
8026search type to request default lookups if the key does not match (see sections
8027~~SECTdefaultvaluelookups and ~~SECTpartiallookup for details).
8028
8029.index numerical variables (\$1$\, \$2$\, etc)||in lookup expansion
8030If a partial search is used, the variables \$1$\ and \$2$\ contain the wild
8031and non-wild parts of the key during the expansion of the replacement text.
8032They return to their previous values at the end of the lookup item.
8033
8034This example looks up the postmaster alias in the conventional alias file:
8035.display asis
8036${lookup {postmaster} lsearch {/etc/aliases} {$value}}
8037.endd
8038This example uses NIS+ to look up the full name of the user corresponding to
8039the local part of an address, forcing the expansion to fail if it is not found:
8040.display asis
8041${lookup nisplus {[name=$local_part],passwd.org_dir:gcos} \
8042 {$value}fail}
8043.endd
8044
8045
8046.item "@$@{nhash@{<<string1>>@}@{<<string2>>@}@{<<string3>>@}@}"
8047.index expansion||numeric hash
8048.index hash function||numeric
8049The three strings are expanded; the first two must yield numbers. Call them
8050<<n>> and <<m>>. If you are using fixed values for these numbers, that is, if
8051<<string1>> and <<string2>> do not change when they are expanded, you can use
8052the simpler operator notation that avoids some of the braces:
8053.display
8054@$@{nhash@_<<n>>@_<<m>>:<<string>>@}
8055.endd
8056The second number is optional (in both notations). If there is only one number,
8057the result is a number in the range 0--<<n>>-1. Otherwise, the string is
8058processed by a div/mod hash function that returns two numbers, separated by a
8059slash, in the ranges 0 to <<n>>-1 and 0 to <<m>>-1, respectively. For example,
8060.display asis
8061${nhash{8}{64}{supercalifragilisticexpialidocious}}
8062.endd
8063returns the string `6/33'.
8064
8065
8066
8067.item "@$@{perl@{<<subroutine>>@}@{<<arg>>@}@{<<arg>>@}...@}"
8068.index Perl||use in expanded string
8069.index expansion||calling Perl from
8070This item is available only if Exim has been built to include an embedded Perl
8071interpreter. The subroutine name and the arguments are first separately
8072expanded, and then the Perl subroutine is called with those arguments. No
8073additional arguments need be given; the maximum number permitted, including the
8074name of the subroutine, is nine.
8075
8076The return value of the subroutine is inserted into the expanded string, unless
8077the return value is \undef\. In that case, the expansion fails in the same way
8078as an explicit `fail' on a lookup item.
8079The return value is a scalar. Whatever you return is evaluated in a scalar
8080context. For example, if you return the name of a Perl vector, the
8081return value is the size of the vector, not its contents.
8082
8083If the subroutine exits by calling Perl's \die\ function, the expansion fails
8084with the error message that was passed to \die\. More details of the embedded
8085Perl facility are given in chapter ~~CHAPperl.
8086
8087The \%redirect%\ router has an option called \forbid@_filter@_perl\ which locks
8088out the use of this expansion item in filter files.
8089
8090
8091.item "@$@{readfile@{<<file name>>@}@{<<eol string>>@}@}"
8092.index expansion||inserting an entire file
8093.index file||inserting into expansion
8094The file name and end-of-line string are first expanded separately. The file is
8095then read, and its contents replace the entire item. All newline characters in
8096the file are replaced by the end-of-line string if it is present. Otherwise,
8097newlines are left in the string.
8098String expansion is not applied to the contents of the file. If you want this,
8099you must wrap the item in an \expand\ operator. If the file cannot be read, the
8100string expansion fails.
8101
8102The \%redirect%\ router has an option called \forbid@_filter@_readfile\ which
8103locks out the use of this expansion item in filter files.
8104
8105
8106
8107.item "@$@{readsocket@{<<name>>@}@{<<request>>@}@{<<timeout>>@}@{<<eol string>>@}@{<<fail string>>@}@}"
8108.index expansion||inserting from a socket
8109.index socket, use of in expansion
8110This item inserts data that is read from a Unix domain socket into the expanded
8111string. The minimal way of using it uses just two arguments:
8112.display asis
8113${readsocket{/socket/name}{request string}}
8114.endd
8115Exim connects to the socket, writes the request string (unless it is an
8116empty string) and reads from the socket until an end-of-file is read. A timeout
8117of 5 seconds is applied. Additional, optional arguments extend what can be
8118done. Firstly, you can vary the timeout. For example:
8119.display asis
8120${readsocket{/socket/name}{request-string}{3s}}
8121.endd
8122A fourth argument allows you to change any newlines that are in the data
8123that is read, in the same way as for \readfile\ (see above). This example turns
8124them into spaces:
8125.display asis
8126${readsocket{/socket/name}{request-string}{3s}{ }}
8127.endd
8128As with all expansions, the substrings are expanded before the processing
8129happens. Errors in these sub-expansions cause the expansion to fail. In
8130addition, the following errors can occur:
8131.numberpars $.
8132Failure to create a socket file descriptor;
8133.nextp
8134Failure to connect the socket;
8135.nextp
8136Failure to write the request-string;
8137.nextp
8138Timeout on reading from the socket.
8139.endp
8140By default, any of these errors causes the expansion to fail. However, if
8141you supply a fifth substring, it is expanded and used when any of the above
8142errors occurs. For example:
8143.display asis
8144${readsocket{/socket/name}{request-string}{3s}{\n}\
8145 {socket failure}}
8146.endd
8147You can test for the existence of the socket by wrapping this expansion in
8148\"@$@{if exists"\, but there is a race condition between that test and the
8149actual opening of the socket, so it is safer to use the fifth argument if you
8150want to be absolutely sure of avoiding an expansion error for a non-existent
8151socket.
8152
8153The \%redirect%\ router has an option called \forbid@_filter@_readsocket\ which
8154locks out the use of this expansion item in filter files.
8155
8156.item "@$rheader@_<<header name>>:#$rm{or}#@$rh@_<<header name>>:"
8157This item inserts `raw' header lines. It is described with the \header\
8158expansion item above.
8159
8160
8161
8162.item "@$@{run@{<<command>> <<args>>@}@{<<string1>>@}@{<<string2>>@}@}"
8163.index expansion||running a command
8164The command and its arguments are first expanded separately, and then the
8165command is run in a separate process, but under the same uid and gid. As in
8166other command executions from Exim, a shell is not used by default. If you want
8167a shell, you must explicitly code it.
8168.index return code||from \run\ expansion
8169If the command succeeds (gives a zero return code) <<string1>> is expanded and
8170replaces the entire item; during this expansion, the standard output from the
8171command is in the variable \$value$\. If the command fails, <<string2>>, if
8172present, is expanded. If it is absent, the result is empty. Alternatively,
8173<<string2>> can be the word `fail' (not in braces) to force expansion failure
8174if the command does not succeed. If both strings are omitted, the result is the
8175standard output on success, and nothing on failure.
8176
8177The return code from the command is put in the variable \$runrc$\, and this
8178remains set afterwards, so in a filter file you can do things like this:
8179.display asis
8180if "${run{x y z}{}}$runrc" is 1 then ...
8181 elif $runrc is 2 then ...
8182 ...
8183endif
8184.endd
8185If execution of the command fails (for example, the command does not exist),
8186the return code is 127 -- the same code that shells use for non-existent
8187commands.
8188
8189\**Warning**\: In a router or transport, you cannot assume the order in which
8190option values are expanded, except for those pre-conditions whose order of
8191testing is documented. Therefore, you cannot reliably expect to set \$runrc$\
8192by the expansion of one option, and use it in another.
8193
8194The \%redirect%\ router has an option called \forbid@_filter@_run\ which locks
8195out the use of this expansion item in filter files.
8196
8197
8198.item "@$@{sg@{<<subject>>@}@{<<regex>>@}@{<<replacement>>@}@}"
8199.index expansion||string substitution
8200This item works like Perl's substitution operator (s) with the global (/g)
8201option; hence its name. However, unlike the Perl equivalent, Exim does not
8202modify the subject string; instead it returns the modified string for insertion
8203into the overall expansion. The item takes three arguments: the subject string,
8204a regular expression, and a substitution string. For example
8205.display asis
8206${sg{abcdefabcdef}{abc}{xyz}}
8207.endd
8208yields `xyzdefxyzdef'. Because all three arguments are expanded before use, if
8209any @$ or @\ characters are required in the regular expression or in the
8210substitution string, they have to be escaped. For example
8211.display asis
8212${sg{abcdef}{^(...)(...)\$}{\$2\$1}}
8213.endd
8214yields `defabc', and
8215.display asis
8216${sg{1=A 4=D 3=C}{\N(\d+)=\N}{K\$1=}}
8217.endd
8218yields `K1=A K4=D K3=C'.
8219Note the use of \"@\N"\ to protect the contents of the regular expression from
8220string expansion.
8221
8222
8223
8224.item "@$@{substr@{<<string1>>@}@{<<string2>>@}@{<<string3>>@}@}"
8225.index \substr\
8226.index substring extraction
8227.index expansion||substring extraction
8228The three strings are expanded; the first two must yield numbers. Call them
8229<<n>> and <<m>>. If you are using fixed values for these numbers, that is, if
8230<<string1>> and <<string2>> do not change when they are expanded, you can use
8231the simpler operator notation that avoids some of the braces:
8232.display
8233@$@{substr@_<<n>>@_<<m>>:<<string>>@}
8234.endd
8235The second number is optional (in both notations).
8236
8237The \substr\ item can be used to extract more general substrings than \length\.
8238The first number, <<n>>, is a starting offset, and <<m>> is the length
8239required. For example
8240.display asis
8241${substr{3}{2}{$local_part}}
8242.endd
8243If the starting offset is greater than the string length the result is the null
8244string; if the length plus starting offset is greater than the string length,
8245the result is the right-hand part of the string, starting from the given
8246offset. The first character in the string has offset zero.
8247
8248The \substr\ expansion item can take negative offset values to count
8249from the right-hand end of its operand. The last character is offset -1, the
8250second-last is offset -2, and so on. Thus, for example,
8251.display asis
8252${substr{-5}{2}{1234567}}
8253.endd
8254yields `34'. If the absolute value of a negative offset is greater than the
8255length of the string, the substring starts at the beginning of the string, and
8256the length is reduced by the amount of overshoot. Thus, for example,
8257.display asis
8258${substr{-5}{2}{12}}
8259.endd
8260yields an empty string, but
8261.display asis
8262${substr{-3}{2}{12}}
8263.endd
8264yields `1'.
8265
8266If the second number is omitted from \substr\, the remainder of the string is
8267taken if the offset was positive. If it was negative, all characters in the
8268string preceding the offset point are taken. For example, an offset of -1 and
8269no length yields all but the last character of the string.
8270
8271
8272
8273.item "@$@{tr@{<<subject>>@}@{<<characters>>@}@{<<replacements>>@}@}"
8274.index expansion||character translation
8275This item does single-character translation on its subject string. The second
8276argument is a list of characters to be translated in the subject string. Each
8277matching character is replaced by the corresponding character from the
8278replacement list. For example
8279.display asis
8280${tr{abcdea}{ac}{13}}
8281.endd
8282yields `1b3de1'. If there are duplicates in the second character string, the
8283last occurrence is used. If the third string is shorter than the second, its
8284last character is replicated. However, if it is empty, no translation takes
8285place.
8286
8287.enditems
8288
8289
8290.section Expansion operators
8291.rset SECTexpop "~~chapter.~~section"
8292.index expansion||operators
8293For expansion items that perform transformations on a single argument string,
8294the `operator' notation is used because it is simpler and uses fewer braces.
8295The substring is first expanded before the operation is applied to it. The
8296following operations can be performed:
8297
8298.startitems
8299
8300.item "@$@{address:<<string>>@}"
8301.index expansion||RFC 2822 address handling
8302The string is interpreted as an RFC 2822 address, as it might appear in a
8303header line, and the effective address is extracted from it. If the string does
8304not parse successfully, the result is empty.
8305
8306
8307.item "@$@{base62:<<digits>>@}"
8308.index base62
8309.index expansion||conversion to base 62
8310The string must consist entirely of decimal digits. The number is converted to
8311base 62 (sic) and output as a string of six characters, including leading
8312zeros. \**Note**\: Just to be absolutely clear: this is \*not*\ base64
8313encoding.
8314
8315.em
8316.item "@$@{base62d:<<base-62 digits>>@}"
8317.index base62
8318.index expansion||conversion to base 62
8319The string must consist entirely of base-62 digits. The number is converted to
8320decimal and output as a string.
8321.nem
8322
8323
8324.item "@$@{domain:<<string>>@}"
8325.index domain||extraction
8326.index expansion||domain extraction
8327The string is interpreted as an RFC 2822 address and the domain is extracted
8328from it. If the string does not parse successfully, the result is empty.
8329
8330
8331.item "@$@{escape:<<string>>@}"
8332.index expansion||escaping non-printing characters
8333If the string contains any non-printing characters, they are converted to
8334escape sequences starting with a backslash. Whether characters with the most
8335significant bit set (so-called `8-bit characters') count as printing or not is
8336controlled by the \print@_topbitchars\ option.
8337
8338
8339.em
8340.item "@$@{eval:<<string>>@}"
8341.item "@$@{eval10:<<string>>@}"
8342.index expansion||expression evaluation
8343.index expansion||arithmetic expression
8344These items supports simple arithmetic in expansion strings. The string (after
8345expansion) must be a conventional arithmetic expression, but it is limited to
8346the four basic operators (plus, minus, times, divide) and parentheses. All
8347operations are carried out using integer arithmetic. Plus and minus have a
8348lower priority than times and divide; operators with the same priority are
8349evaluated from left to right.
8350
8351For \eval\, numbers may be decimal, octal (starting with `0') or hexadecimal
8352(starting with `0x'). For \eval10\, all numbers are taken as decimal, even if
8353they start with a leading zero. This can be useful when processing numbers
8354extracted from dates or times, which often do have leading zeros.
8355.nem
8356
8357A number may be followed by `K' or `M' to multiply it by 1024 or 1024$*$1024,
8358respectively. Negative numbers are supported. The result of the computation is
8359a decimal representation of the answer (without `K' or `M'). For example:
8360.display
8361 @$@{eval:1+1@} $rm{yields} 2
8362 @$@{eval:1+2*3@} $rm{yields} 7
8363 @$@{eval:(1+2)*3@} $rm{yields} 9
8364.endd
8365As a more realistic example, in an ACL you might have
8366.display asis
8367deny message = Too many bad recipients
8368 condition = \
8369 ${if and { \
8370 {>{$rcpt_count}{10}} \
8371 { \
8372 < \
8373 {$recipients_count} \
8374 {${eval:$rcpt_count/2}} \
8375 } \
8376 }{yes}{no}}
8377.endd
8378The condition is true if there have been more than 10 \\RCPT\\ commands and
8379fewer than half of them have resulted in a valid recipient.
8380
8381
8382.item "@$@{expand:<<string>>@}"
8383.index expansion||re-expansion of substring
8384The \expand\ operator causes a string to be expanded for a second time. For
8385example,
8386.display asis
8387${expand:${lookup{$domain}dbm{/some/file}{$value}}}
8388.endd
8389first looks up a string in a file while expanding the operand for \expand\, and
8390then re-expands what it has found.
8391
8392
8393.item "@$@{from@_utf8:<<string>>@}"
8394.index Unicode
8395.index UTF-8||conversion from
8396.index expansion||UTF-8 conversion
8397The world is slowly moving towards Unicode, although there are no standards for
8398email yet. However, other applications (including some databases) are starting
8399to store data in Unicode, using UTF-8 encoding. This operator converts from a
8400UTF-8 string to an ISO-8859-1 string. UTF-8 code values greater than 255 are
8401converted to underscores. The input must be a valid UTF-8 string. If it is not,
8402the result is an undefined sequence of bytes.
8403
8404Unicode code points with values less than 256 are compatible with ASCII and
8405ISO-8859-1 (also known as Latin-1).
8406For example, character 169 is the copyright symbol in both cases, though the
8407way it is encoded is different. In UTF-8, more than one byte is needed for
8408characters with code values greater than 127, whereas ISO-8859-1 is a
8409single-byte encoding (but thereby limited to 256 characters). This makes
8410translation from UTF-8 to ISO-8859-1 straightforward.
8411
8412
8413.item "@$@{hash@_<<n>>@_<<m>>:<<string>>@}"
8414.index hash function||textual
8415.index expansion||textual hash
8416The \hash\ operator is a simpler interface to the hashing function that can be
8417used when the two parameters are fixed numbers (as opposed to strings that
8418change when expanded). The effect is the same as
8419.display
8420@$@{hash@{<<n>>@}@{<<m>>@}@{<<string>>@}@}
8421.endd
8422See the description of the general \hash\ item above for details. The
8423abbreviation \h\ can be used when \hash\ is used as an operator.
8424
8425
8426
8427.item "@$@{hex2b64:<<hexstring>>@}"
8428.index base64 encoding||conversion from hex
8429.index expansion||hex to base64
8430This operator converts a hex string into one that is base64 encoded. This can
8431be useful for processing the output of the MD5 and SHA-1 hashing functions.
8432
8433
8434.item "@$@{lc:<<string>>@}"
8435.index case forcing in strings
8436.index string||case forcing
8437.index lower casing
8438.index expansion||case forcing
8439This forces the letters in the string into lower-case, for example:
8440.display asis
8441${lc:$local_part}
8442.endd
8443
8444
8445.item "@$@{length@_<<number>>:<<string>>@}"
8446.index expansion||string truncation
8447The \length\ operator is a simpler interface to the \length\ function that can
8448be used when the parameter is a fixed number (as opposed to a string that
8449changes when expanded). The effect is the same as
8450.display
8451@$@{length@{<<number>>@}@{<<string>>@}@}
8452.endd
8453See the description of the general \length\ item above for details. Note that
8454\length\ is not the same as \strlen\. The abbreviation \l\ can be used when
8455\length\ is used as an operator.
8456
8457
8458.item "@$@{local@_part:<<string>>@}"
8459.index expansion||local part extraction
8460The string is interpreted as an RFC 2822 address and the local part is
8461extracted from it. If the string does not parse successfully, the result is
8462empty.
8463
8464
8465.item "@$@{mask:<<IP address>>/<<bit count>>@}"
8466.index masked IP address
8467.index IP address||masking
8468.index CIDR notation
8469.index expansion||IP address masking
8470If the form of the string to be operated on is not an IP address followed by a
8471slash and an integer (that is, a network address in CIDR notation), the
8472expansion fails. Otherwise, this operator converts the IP address to binary,
8473masks off the least significant bits according to the bit count, and converts
8474the result back to text, with mask appended. For example,
8475.display asis
8476${mask:10.111.131.206/28}
8477.endd
8478returns the string `10.111.131.192/28'. Since this operation is expected to be
8479mostly used for looking up masked addresses in files, the result for an IPv6
8480address uses dots to separate components instead of colons, because colon
8481terminates a key string in lsearch files. So, for example,
8482.display asis
8483${mask:3ffe:ffff:836f:0a00:000a:0800:200a:c031/99}
8484.endd
8485returns the string
8486.display asis
84873ffe.ffff.836f.0a00.000a.0800.2000.0000/99
8488.endd
8489Letters in IPv6 addresses are always output in lower case.
8490
8491
8492.item "@$@{md5:<<string>>@}"
8493.index MD5 hash
8494.index expansion||MD5 hash
8495The \md5\ operator computes the MD5 hash value of the string, and returns it as
8496a 32-digit hexadecimal number,
8497in which any letters are in lower case.
8498
8499
8500.item "@$@{nhash@_<<n>>@_<<m>>:<<string>>@}"
8501.index expansion||numeric hash
8502.index hash function||numeric
8503The \nhash\ operator is a simpler interface to the numeric hashing function
8504that can be used when the two parameters are fixed numbers (as opposed to
8505strings that change when expanded). The effect is the same as
8506.display
8507@$@{nhash@{<<n>>@}@{<<m>>@}@{<<string>>@}@}
8508.endd
8509See the description of the general \nhash\ item above for details.
8510
8511
8512.item "@$@{quote:<<string>>@}"
8513.index quoting||in string expansions
8514.index expansion||quoting
8515The \quote\ operator puts its argument into double quotes if it
8516is an empty string or
8517contains anything other than letters, digits, underscores, dots, and hyphens.
8518Any occurrences of double quotes and backslashes are escaped with a backslash.
8519Newlines and carriage returns are converted to \"@\n"\ and \"@\r"\,
8520respectively For example,
8521.display asis
8522${quote:ab"*"cd}
8523.endd
8524becomes
8525.display asis
8526"ab\"*\"cd"
8527.endd
8528The place where this is useful is when the argument is a substitution from a
8529variable or a message header.
8530
8531.item "@$@{quote@_local@_part:<<string>>@}"
8532This operator is like \quote\, except that it quotes the string only if
8533required to do so by the rules of RFC 2822 for quoting local parts. For
8534example, a plus sign would not cause quoting (but it would for \quote\).
8535If you are creating a new email address from the contents of \$local@_part$\
8536(or any other unknown data), you should always use this operator.
8537
8538
8539.item "@$@{quote@_<<lookup-type>>:<<string>>@}"
8540.index quoting||lookup-specific
8541This operator applies lookup-specific quoting rules to the string. Each
8542query-style lookup type has its own quoting rules which are described with
8543the lookups in chapter ~~CHAPfdlookup. For example,
8544.display asis
8545${quote_ldap:two * two}
8546.endd
8547returns
8548.display asis
8549two%20%5C2A%20two
8550.endd
8551For single-key lookup types, no quoting is ever necessary and this operator
8552yields an unchanged string.
8553
8554
8555.item "@$@{rxquote:<<string>>@}"
8556.index quoting||in regular expressions
8557.index regular expressions||quoting
8558The \rxquote\ operator inserts a backslash before any non-alphanumeric
8559characters in its argument. This is useful when substituting the values of
8560variables or headers inside regular expressions.
8561
8562
8563.item "@$@{rfc2047:<<string>>@}"
8564.index expansion||RFC 2047
8565This operator encodes text according to the rules of RFC 2047. This is an
8566encoding that is used in header lines to encode non-ASCII characters. It is
8567assumed that the input string is in the encoding specified by the
8568\headers@_charset\ option, which defaults to ISO-8859-1.
8569If the string contains only characters in the range 33--126, and no instances
8570of the characters
8571.display asis
8572? = ( ) < > @ , ; : \ " . [ ] _
8573.endd
8574it is not modified. Otherwise, the result is the RFC 2047 encoding, as a single
8575`coded word'.
8576
8577
8578.item "@$@{sha1:<<string>>@}"
8579.index SHA-1 hash
8580.index expansion||SHA-1 hashing
8581The \sha1\ operator computes the SHA-1 hash value of the string, and returns it
8582as a 40-digit hexadecimal number, in which any letters are in upper case.
8583
8584
8585.item "@$@{stat:<<string>>@}"
8586.index expansion||statting a file
8587.index file||extracting characteristics
8588The string, after expansion, must be a file path. A call to the \*stat()*\
8589function is made for this path. If \*stat()*\ fails, an error occurs and the
8590expansion fails. If it succeeds, the data from the stat replaces the item, as a
8591series of <<name>>=<<value>> pairs, where the values are all numerical,
8592except for the value of `smode'. The names are: `mode' (giving the mode as a
85934-digit octal number), `smode' (giving the mode in symbolic format as a
859410-character string, as for the \*ls*\ command), `inode', `device', `links',
8595`uid', `gid', `size', `atime', `mtime', and `ctime'. You can extract individual
8596fields using the \extract\ expansion item. \**Warning**\: The file size may be
8597incorrect on 32-bit systems for files larger than 2GB.
8598
8599
8600.item "@$@{strlen:<<string>>@}"
8601.index expansion||string length
8602.index string||length in expansion
8603The item is replace by the length of the expanded string, expressed as a
8604decimal number. \**Note**\: Do not confuse \strlen\ with \length\.
8605
8606
8607.item "@$@{substr@_<<start>>@_<<length>>:<<string>>@}"
8608.index \substr\
8609.index substring extraction
8610.index expansion||substring expansion
8611The \substr\ operator is a simpler interface to the \substr\ function that can
8612be used when the two parameters are fixed numbers (as opposed to strings that
8613change when expanded). The effect is the same as
8614.display
8615@$@{substr@{<<start>>@}@{<<length>>@}@{<<string>>@}@}
8616.endd
8617See the description of the general \substr\ item above for details. The
8618abbreviation \s\ can be used when \substr\ is used as an operator.
8619
8620.em
8621.item "@$@{time@_interval:<<string>>@}"
8622.index \time@_interval\
8623.index time interval||formatting
8624The argument (after sub-expansion) must be a sequence of decimal digits that
8625represents an interval of time as a number of seconds. It is converted into a
8626number of larger units and output in Exim's normal time format, for example,
8627\"1w3d4h2m6s"\.
8628.nem
8629
8630.item "@$@{uc:<<string>>@}"
8631.index case forcing in strings
8632.index string||case forcing
8633.index upper casing
8634.index expansion||case forcing
8635This forces the letters in the string into upper-case.
8636
8637.enditems
8638
8639
8640
8641.section Expansion conditions
8642.rset SECTexpcond "~~chapter.~~section"
8643.index expansion||conditions
8644The following conditions are available for testing by the \@$@{if\ construct
8645while expanding strings:
8646
8647.startitems
8648
8649.item "!<<condition>>"
8650.index expansion||negating a condition
8651Preceding any condition with an exclamation mark negates the result of the
8652condition.
8653
8654.item "<<symbolic operator>> @{<<string1>>@}@{<<string2>>@}"
8655.index numeric comparison
8656.index expansion||numeric comparison
8657There are a number of symbolic operators for doing numeric comparisons. They
8658are:
8659.display
8660.tabs 8
8661= $t $rm{equal}
8662== $t $rm{equal}
8663> $t $rm{greater}
8664>= $t $rm{greater or equal}
8665< $t $rm{less}
8666<= $t $rm{less or equal}
8667.endd
8668For example,
8669.display asis
8670${if >{$message_size}{10M} ...
8671.endd
8672Note that the general negation operator provides for inequality testing. The
8673two strings must take the form of optionally signed decimal integers,
8674optionally followed by one of the letters `K' or `M' (in either upper or lower
8675case), signifying multiplication by 1024 or 1024$*$1024, respectively.
8676
8677.item "crypteq @{<<string1>>@}@{<<string2>>@}"
8678.index expansion||encrypted comparison
8679.index encrypted strings, comparing
8680This condition is included in the Exim binary if it is built to support any
8681authentication mechanisms (see chapter ~~CHAPSMTPAUTH). Otherwise, it is
8682necessary to define \\SUPPORT@_CRYPTEQ\\ in \(Local/Makefile)\ to get \crypteq\
8683included in the binary.
8684
8685The \crypteq\ condition has two arguments. The first is encrypted and compared
8686against the second, which is already encrypted. The second string may be in the
8687LDAP form for storing encrypted strings, which starts with the encryption type
8688in curly brackets, followed by the data. If the second string does not begin
8689with `{' it is assumed to be encrypted with \*crypt()*\
8690or \*crypt16()*\ (see below),
8691since such strings cannot begin with `{'. Typically this will be a field from a
8692password file.
8693
8694An example of an encrypted string in LDAP form is:
8695.display asis
8696{md5}CY9rzUYh03PK3k6DJie09g==
8697.endd
8698If such a string appears directly in an expansion, the curly brackets have to
8699be quoted, because they are part of the expansion syntax. For example:
8700.display asis
8701${if crypteq {test}{\{md5\}CY9rzUYh03PK3k6DJie09g==}{yes}{no}}
8702.endd
8703The following encryption types
8704(whose names are matched case-independently)
8705are supported:
8706.numberpars $.
8707.index MD5 hash
8708.index base64 encoding||in encrypted password
8709\@{md5@}\ computes the MD5 digest of the first string, and expresses this as
8710printable characters to compare with the remainder of the second string. If the
8711length of the comparison string is 24, Exim assumes that it is base64 encoded
8712(as in the above example). If the length is 32, Exim assumes that it is a
8713hexadecimal encoding of the MD5 digest. If the length not 24 or 32, the
8714comparison fails.
8715.nextp
8716.index SHA-1 hash
8717\@{sha1@}\ computes the SHA-1 digest of the first string, and expresses this as
8718printable characters to compare with the remainder of the second string. If the
8719length of the comparison string is 28, Exim assumes that it is base64 encoded.
8720If the length is 40, Exim assumes that it is a hexadecimal encoding of the
8721SHA-1 digest. If the length is not 28 or 40, the comparison fails.
8722.nextp
8723.index \*crypt()*\
8724\@{crypt@}\ calls the \*crypt()*\ function, which uses only the first eight
8725characters of the password.
8726.nextp
8727.index \*crypt16()*\
8728\@{crypt16@}\ calls the \*crypt16()*\ function (also known as \*bigcrypt()*\),
8729which uses up to 16 characters of the password.
8730.endp
8731Exim has its own version of \*crypt16()*\ (which is just a double call to
8732\*crypt()*\). For operating systems that have their own version, setting
8733\\HAVE@_CRYPT16\\ in \(Local/Makefile)\ when building Exim causes it to use the
8734operating system version instead of its own. This option is set by default in
8735the OS-dependent \(Makefile)\ for those operating systems that are known to
8736support \*crypt16()*\.
8737
8738If you do not put any curly bracket encryption type in a \crypteq\ comparison,
8739the default is either \"@{crypt@}"\ or \"@{crypt16@}"\, as determined by the
8740setting of \\DEFAULT@_CRYPT\\ in \(Local/Makefile)\. The default default is
8741\"@{crypt@}"\. Whatever the default, you can always use either function by
8742specifying it explicitly in curly brackets.
8743
8744Note that if a password is no longer than 8 characters, the results of
8745encrypting it with \*crypt()*\ and \*crypt16()*\ are identical. That means that
8746\*crypt16()*\ is backwards compatible, as long as nobody feeds it a password
8747longer than 8 characters.
8748
8749
8750.item "def:<<variable name>>"
8751.index expansion||checking for empty variable
8752The \def\ condition must be followed by the name of one of the expansion
8753variables defined in section ~~SECTexpvar. The condition is true if the named
8754expansion variable does not contain the empty string, for example
8755.display asis
8756${if def:sender_ident {from $sender_ident}}
8757.endd
8758Note that the variable name is given without a leading \@$\ character. If the
8759variable does not exist, the expansion fails.
8760
8761.item "def:header@_<<header name>>:##or##def:h@_<<header name>>:"
8762.index expansion||checking header line existence
8763This condition is true if a message is being processed and the named header
8764exists in the message. For example,
8765.display asis
8766${if def:header_reply-to:{$h_reply-to:}{$h_from:}}
8767.endd
8768Note that no \@$\ appears before \header@_\ or \h@_\ in the condition,
8769and that header names must be terminated by colons if white space does not
8770follow.
8771
8772.item "eq @{<<string1>>@}@{<<string2>>@}"
8773.item "eqi @{<<string1>>@}@{<<string2>>@}"
8774.index string||comparison
8775.index expansion||string comparison
8776The two substrings are first expanded. The condition is true if the two
8777resulting strings are identical: for \eq\ the comparison includes the case of
8778letters, whereas for \eqi\ the comparison is case-independent.
8779
8780.item "exists @{<<file name>>@}"
8781.index expansion||file existence test
8782.index file||existence test
8783The substring is first expanded and then interpreted as an absolute path. The
8784condition is true if the named file (or directory) exists. The existence test
8785is done by calling the \*stat()*\ function. The use of the \exists\ test in
8786users' filter files may be locked out by the system administrator.
8787
8788.item "first@_delivery"
8789.index delivery||first
8790.index first delivery
8791.index expansion||first delivery test
8792This condition, which has no data, is true during a message's first delivery
8793attempt. It is false during any subsequent delivery attempts.
8794
8795.em
8796.item "ge @{<<string1>>@}@{<<string2>>@}"
8797.item "gei @{<<string1>>@}@{<<string2>>@}"
8798.index string||comparison
8799.index expansion||string comparison
8800The two substrings are first expanded. The condition is true if the first
8801string is lexically greater than or equal to the second string: for \ge\ the
8802comparison includes the case of letters, whereas for \gei\ the comparison is
8803case-independent.
8804
8805.item "gt @{<<string1>>@}@{<<string2>>@}"
8806.item "gti @{<<string1>>@}@{<<string2>>@}"
8807.index string||comparison
8808.index expansion||string comparison
8809The two substrings are first expanded. The condition is true if the first
8810string is lexically greater than the second string: for \gt\ the comparison
8811includes the case of letters, whereas for \gti\ the comparison is
8812case-independent.
8813.nem
8814
8815.item "isip @{<<string>>@}" 8
8816.item "isip4 @{<<string>>@}"
8817.item "isip6 @{<<string>>@}"
8818.index IP address||testing string format
8819.index string||testing for IP address
8820The substring is first expanded, and then tested to see if it has the form of
8821an IP address. Both IPv4 and IPv6 addresses are valid for \isip\, whereas
8822\isip4\ and \isip6\ test just for IPv4 or IPv6 addresses, respectively. For
8823example, you could use
8824.display asis
8825${if isip4{$sender_host_address}...
8826.endd
8827to test which version of IP an incoming SMTP connection is using.
8828
8829
8830.item "ldapauth @{<<ldap query>>@}"
8831.index LDAP||use for authentication
8832.index expansion||LDAP authentication test
8833This condition supports user authentication using LDAP. See section ~~SECTldap
8834for details of how to use LDAP in lookups and the syntax of queries. For this
8835use, the query must contain a user name and password. The query itself is not
8836used, and can be empty. The condition is true if
8837the password is not empty, and the user name and password are accepted by the
8838LDAP server. An empty password is rejected without calling LDAP because LDAP
8839binds with an empty password are considered anonymous regardless of
8840the username, and will succeed in most configurations.
8841See chapter ~~CHAPSMTPAUTH for details of SMTP authentication, and chapter
8842~~CHAPplaintext for an example of how this can be used.
8843
8844
8845.em
8846.item "le @{<<string1>>@}@{<<string2>>@}"
8847.item "lei @{<<string1>>@}@{<<string2>>@}"
8848.index string||comparison
8849.index expansion||string comparison
8850The two substrings are first expanded. The condition is true if the first
8851string is lexically less than or equal to the second string: for \le\ the
8852comparison includes the case of letters, whereas for \lei\ the comparison is
8853case-independent.
8854
8855.item "lt @{<<string1>>@}@{<<string2>>@}"
8856.item "lti @{<<string1>>@}@{<<string2>>@}"
8857.index string||comparison
8858.index expansion||string comparison
8859The two substrings are first expanded. The condition is true if the first
8860string is lexically less than the second string: for \lt\ the comparison
8861includes the case of letters, whereas for \lti\ the comparison is
8862case-independent.
8863.nem
8864
8865
8866.item "match @{<<string1>>@}@{<<string2>>@}"
8867.index expansion||regular expression comparison
8868.index regular expressions||match in expanded string
8869The two substrings are first expanded. The second is then treated as a regular
8870expression and applied to the first. Because of the pre-expansion, if the
8871regular expression contains dollar, or backslash characters, they must be
8872escaped. Care must also be taken if the regular expression contains braces
8873(curly brackets). A closing brace must be escaped so that it is not taken as a
8874premature termination of <<string2>>. The easiest approach is to use the
8875\"@\N"\ feature to disable expansion of the regular expression.
8876For example,
8877.display asis
8878${if match {$local_part}{\N^\d{3}\N} ...
8879.endd
8880If the whole expansion string is in double quotes, further escaping of
8881backslashes is also required.
8882
8883The condition is true if the regular expression match succeeds.
8884.em
8885The regular expression is not required to begin with a circumflex
8886metacharacter, but if there is no circumflex, the expression is not anchored,
8887and it may match anywhere in the subject, not just at the start. If you want
8888the pattern to match at the end of the subject, you must include the \"@$"\
8889metacharacter at an appropriate point.
8890.nem
8891
8892.index numerical variables (\$1$\, \$2$\, etc)||in \if\ expansion
8893At the start of an \if\ expansion the values of the numeric variable
8894substitutions \$1$\ etc. are remembered. Obeying a \match\ condition that
8895succeeds causes them to be reset to the substrings of that condition and they
8896will have these values during the expansion of the success string. At the end
8897of the \if\ expansion, the previous values are restored. After testing a
8898combination of conditions using \or\, the subsequent values of the numeric
8899variables are those of the condition that succeeded.
8900
8901.em
8902.item "match@_domain @{<<string1>>@}@{<<string2>>@}"
8903.item "match@_address @{<<string1>>@}@{<<string2>>@}"
8904.item "match@_local@_part @{<<string1>>@}@{<<string2>>@}"
8905.index domain list||in expansion condition
8906.index address list||in expansion condition
8907.index local part list||in expansion condition
8908These conditions make it possible to test domain, address, and local
8909part lists within expansions. Each condition requires two arguments: an item
8910and a list to match. A trivial example is:
8911.display asis
8912${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
8913.endd
8914In each case, the second argument may contain any of the allowable items for a
8915list of the appropriate type. Also, because the second argument (after
8916expansion) is a standard form of list, it is possible to refer to a named list.
8917Thus, you can use conditions like this:
8918.display asis
8919${if match_domain{$domain}{+local_domains}{...
8920.endd
8921.index \"+caseful"\
8922For address lists, the matching starts off caselessly, but the \"+caseful"\
8923item can be used, as in all address lists, to cause subsequent items to
8924have their local parts matched casefully. Domains are always matched
8925caselessly.
8926
8927\**Note**\: Host lists are \*not*\ supported in this way. This is because
8928hosts have two identities: a name and an IP address, and it is not clear
8929how to specify cleanly how such a test would work. At least, I haven't come
8930up with anything yet.
8931.nem
8932
8933.item "pam {<<string1>>:<<string2>>:...@}"
8934.index PAM authentication
8935.index \\AUTH\\||with PAM
8936.index Solaris||PAM support
8937.index expansion||PAM authentication test
8938\*Pluggable Authentication Modules*\
8939(\?http://www.kernel.org/pub/linux/libs/pam/?\)
8940are a facility which is available in the latest releases of Solaris and in some
8941GNU/Linux distributions. The Exim support, which is intended for use in
8942conjunction with the SMTP \\AUTH\\ command, is available only if Exim is
8943compiled with
8944.display asis
8945SUPPORT_PAM=yes
8946.endd
8947in \(Local/Makefile)\. You probably need to add \-lpam-\ to \\EXTRALIBS\\, and
8948in some releases of GNU/Linux \-ldl-\ is also needed.
8949
8950The argument string is first expanded, and the result must be a colon-separated
8951list of strings.
8952Leading and trailing whitespace is ignored.
8953The PAM module is initialized with the service name `exim' and the user name
8954taken from the first item in the colon-separated data string (<<string1>>). The
8955remaining items in the data string are passed over in response to requests from
8956the authentication function. In the simple case there will only be one request,
8957for a password, so the data consists of just two strings.
8958
8959There can be problems if any of the strings are permitted to contain colon
8960characters. In the usual way, these have to be doubled to avoid being taken as
8961separators. If the data is being inserted from a variable, the \sg\ expansion
8962item can be used to double any existing colons. For example, the configuration
8963of a LOGIN authenticator might contain this setting:
8964.display asis
8965server_condition = ${if pam{$1:${sg{$2}{:}{::}}}{yes}{no}}
8966.endd
8967For a PLAIN authenticator you could use:
8968.display asis
8969server_condition = ${if pam{$2:${sg{$3}{:}{::}}}{yes}{no}}
8970.endd
8971In some operating systems, PAM authentication can be done only from a process
8972running as root. Since Exim is running as the Exim user when receiving
8973messages, this means that PAM cannot be used directly in those systems.
8974A patched version of the \*pam@_unix*\ module that comes with the
8975Linux PAM package is available from \?http:@/@/www.e-admin.de/pam@_exim/?\.
8976The patched module allows one special uid/gid combination, in addition to root,
8977to authenticate. If you build the patched module to allow the Exim user and
8978group, PAM can then be used from an Exim authenticator.
8979
8980
8981.item "pwcheck {<<string1>>:<<string2>>@}"
8982.index \*pwcheck*\ daemon
8983.index Cyrus
8984.index expansion||\*pwcheck*\ authentication test
8985This condition supports user authentication using the Cyrus \*pwcheck*\ daemon.
8986This is one way of making it possible for passwords to be checked by a process
8987that is not running as root.
8988\**Note:**\ The use of \*pwcheck*\ is now deprecated. Its replacement is
8989\*saslauthd*\ (see below).
8990
8991The pwcheck support is not included in Exim by default. You need to specify
8992the location of the pwcheck daemon's socket in \(Local/Makefile)\ before
8993building Exim. For example:
8994.display asis
8995CYRUS_PWCHECK_SOCKET=/var/pwcheck/pwcheck
8996.endd
8997You do not need to install the full Cyrus software suite in order to use
8998the pwcheck daemon. You can compile and install just the daemon alone
8999from the Cyrus SASL library. Ensure that \*exim*\ is the only user that has
9000access to the \(/var/pwcheck)\ directory.
9001
9002The \pwcheck\ condition takes one argument, which must be the user name and
9003password, separated by a colon. For example, in a LOGIN authenticator
9004configuration, you might have this:
9005.display asis
9006server_condition = ${if pwcheck{$1:$2}{1}{0}}
9007.endd
9008
9009.item "queue@_running"
9010.index queue runner||detecting when delivering from
9011.index expansion||queue runner test
9012This condition, which has no data, is true during delivery attempts that are
9013initiated by queue runner processes, and false otherwise.
9014
9015
9016.item "radius {<<authentication string>>@}"
9017.index Radius
9018.index expansion||Radius authentication
9019Radius authentication (RFC 2865) is supported in a similar way to PAM. You must
9020set \\RADIUS@_CONFIG@_FILE\\ in \(Local/Makefile)\ to specify the location of
9021the Radius client configuration file in order to build Exim with Radius
9022support.
9023You may also have to supply a suitable setting in \\EXTRALIBS\\ so that the
9024Radius library can be found when Exim is linked.
9025The string specified by \\RADIUS@_CONFIG@_FILE\\ is expanded and passed to the
9026Radius client library, which calls the Radius server. The condition is true if
9027the authentication is successful. For example
9028.display
9029server@_condition = @$@{if radius@{<<arguments>>@}@{yes@}@{no@}@}
9030.endd
9031
9032
9033
9034.item "saslauthd @{@{<<user>>@}@{<<password>>@}@{<<service>>@}@{<<realm>>@}@}"
9035.index \*saslauthd*\ daemon
9036.index Cyrus
9037.index expansion||\*saslauthd*\ authentication test
9038This condition supports user authentication using the Cyrus \*saslauthd*\
9039daemon. This replaces the older \*pwcheck*\ daemon, which is now deprecated.
9040Using this daemon is one way of making it possible for passwords to be checked
9041by a process that is not running as root.
9042
9043The saslauthd support is not included in Exim by default. You need to specify
9044the location of the saslauthd daemon's socket in \(Local/Makefile)\ before
9045building Exim. For example:
9046.display asis
9047CYRUS_SASLAUTHD_SOCKET=/var/state/saslauthd/mux
9048.endd
9049You do not need to install the full Cyrus software suite in order to use
9050the saslauthd daemon. You can compile and install just the daemon alone
9051from the Cyrus SASL library.
9052
9053Up to four arguments can be supplied to the \saslauthd\ condition, but only two
9054are mandatory. For example:
9055.display asis
9056server_condition = ${if saslauthd{{$1}{$2}}{1}{0}}
9057.endd
9058The service and the realm are optional (which is why the arguments are enclosed
9059in their own set of braces). For details of the meaning of the service and
9060realm, and how to run the daemon, consult the Cyrus documentation.
9061
9062.enditems
9063
9064
9065
9066.section Combining expansion conditions
9067.index expansion||combining conditions
9068Several conditions can be tested at once by combining them using the \and\ and
9069\or\ combination conditions. Note that \and\ and \or\ are complete conditions
9070on their own, and precede their lists of sub-conditions. Each sub-condition
9071must be enclosed in braces within the overall braces that contain the list. No
9072repetition of \if\ is used.
9073
9074.startitems
9075
9076.item "or @{@{<<cond1>>@}@{<<cond2>>@}...@}"
9077.index `or' expansion condition
9078.index expansion||`or' of conditions
9079The sub-conditions are evaluated from left to right. The condition is true if
9080any one of the sub-conditions is true.
9081For example,
9082.display asis
9083${if or {{eq{$local_part}{spqr}}{eq{$domain}{testing.com}}}...
9084.endd
9085When a true sub-condition is found, the following ones are parsed but not
9086evaluated. If there are several `match' sub-conditions the values of the
9087numeric variables afterwards are taken from the first one that succeeds.
9088
9089.item "and @{@{<<cond1>>@}@{<<cond2>>@}...@}"
9090.index `and' expansion condition
9091.index expansion||`and' of conditions
9092The sub-conditions are evaluated from left to right. The condition is true if
9093all of the sub-conditions are true. If there are several `match'
9094sub-conditions, the values of the numeric variables afterwards are taken from
9095the last one. When a false sub-condition is found, the following ones are
9096parsed but not evaluated.
9097
9098.enditems
9099
9100
9101
9102.section Expansion variables
9103.rset SECTexpvar "~~chapter.~~section"
9104.index expansion||variables, list of
9105
9106The variables that are available for use in expansion strings are:
9107
9108.push
9109.indent 2em
9110.tempindent 0
9111.index numerical variables (\$1$\, \$2$\, etc)
9112\$0$\, \$1$\, etc: When a \match\ expansion condition succeeds, these
9113variables contain the captured substrings identified by the regular expression
9114during subsequent processing of the success string of the containing \if\
9115expansion item. They may also be set externally by some other matching process
9116which precedes the expansion of the string. For example, the commands available
9117in Exim filter files include an \if\ command with its own regular expression
9118matching condition.
9119
9120.tempindent 0
9121\$acl@_c0$\ -- \$acl@_c9$\: Values can be placed in these variables by the
9122\set\ modifier in an ACL. The values persist throughout the lifetime of an SMTP
9123connection. They can be used to pass information between ACLs and different
9124invocations of the same ACL.
9125When a message is received, the values of these variables are saved with the
9126message, and can be accessed by filters, routers, and transports during
9127subsequent delivery.
9128
9129.tempindent 0
9130\$acl@_m0$\ -- \$acl@_m9$\: Values can be placed in these variables by the
9131\set\ modifier in an ACL. They retain their values while a message is being
9132received, but are reset afterwards. They are also reset by \\MAIL\\, \\RSET\\,
9133\\EHLO\\, \\HELO\\, and after starting a TLS session.
9134When a message is received, the values of these variables are saved with the
9135message, and can be accessed by filters, routers, and transports during
9136subsequent delivery.
9137
9138
9139.tempindent 0
9140\$acl@_verify@_message$\: During the expansion of the \message\ and
9141\log@_message\ modifiers in an ACL statement after an address verification has
9142failed, this variable contains the original failure message that will be
9143overridden by the expanded string.
9144
9145.tempindent 0
9146\$address@_data$\: This variable is set by means of the \address@_data\
9147option in routers. The value then remains with the address while it is
9148processed by subsequent routers and eventually a transport. If the transport is
9149handling multiple addresses, the value from the first address is used. See
9150chapter ~~CHAProutergeneric for more details.
9151\**Note**\: the contents of \$address@_data$\ are visible in user filter files.
9152
9153If \$address@_data$\ is set when the routers are called to verify an address
9154from an ACL, the final value remains available in subsequent conditions in the
9155ACL statement. If routing the address caused it to be redirected to a single
9156address, the child address is also routed as part of the verification, and in
9157this case the final value of \$address@_data$\ is from the child's routing.
9158
9159.tempindent 0
9160\$address@_file$\: When, as a result of aliasing, forwarding, or filtering, a
9161message is directed to a specific file, this variable holds the name of the
9162file when the transport is running. At other times, the variable is empty. For
9163example, using the default configuration, if user \r2d2\ has a \(.forward)\
9164file containing
9165.display asis
9166/home/r2d2/savemail
9167.endd
9168then when the \%address@_file%\ transport is running, \$address@_file$\
9169contains `/home/r2d2/savemail'.
9170.index Sieve filter||value of \$address@_file$\
9171For Sieve filters, the value may be `inbox' or a relative folder name. It is
9172then up to the transport configuration to generate an appropriate absolute path
9173to the relevant file.
9174
9175
9176.tempindent 0
9177\$address@_pipe$\: When, as a result of aliasing or forwarding, a message is
9178directed to a pipe, this variable holds the pipe command when the transport is
9179running.
9180
9181.index authentication||id
9182.tempindent 0
9183\$authenticated@_id$\: When a server successfully authenticates a client it may
9184be configured to preserve some of the authentication information in the
9185variable \$authenticated@_id$\ (see chapter ~~CHAPSMTPAUTH). For example, a
9186user/password authenticator configuration might preserve the user name for use
9187in the routers. When a message is submitted locally (that is, not over a TCP
9188connection), the value of \$authenticated@_id$\ is the login name of the
9189calling process.
9190
9191.index sender||authenticated
9192.index authentication||sender
9193.index \\AUTH\\||on \\MAIL\\ command
9194.tempindent 0
9195\$authenticated@_sender$\:
9196.em
9197When acting as a server, Exim takes note of the \\AUTH=\\ parameter on an
9198incoming SMTP \\MAIL\\ command
9199.nem
9200if it believes the sender is sufficiently trusted, as described in section
9201~~SECTauthparamail. Unless the data is the string `@<@>', it is set as the
9202authenticated sender of the message, and the value is available during delivery
9203in the \$authenticated@_sender$\ variable. If the sender is not trusted, Exim
9204accepts the syntax of \\AUTH=\\, but ignores the data.
9205
9206When a message is submitted locally (that is, not over a TCP connection), the
9207value of \$authenticated@_sender$\ is an address constructed from the login
9208name of the calling process and \$qualify@_domain$\.
9209
9210
9211.index authentication||failure
9212.tempindent 0
9213\$authentication@_failed$\:
9214This variable is set to `1' in an Exim server if a client issues an \\AUTH\\
9215command that does not succeed. Otherwise it is set to `0'. This makes it
9216possible to distinguish between `did not try to authenticate'
9217(\$sender@_host@_authenticated$\ is empty and \$authentication__failed$\ is set
9218to `0') and `tried to authenticate but failed' (\$sender@_host@_authenticated$\
9219is empty and \$authentication@_failed$\ is set to `1'). Failure includes any
9220negative response to an \\AUTH\\ command, including (for example) an attempt to
9221use an undefined mechanism.
9222
9223
9224.index message||body, line count
9225.index body of message||line count
9226.tempindent 0
9227\$body@_linecount$\:
9228When a message is being received or delivered, this variable contains the
9229number of lines in the message's body.
9230
9231.index message||body, binary zero count
9232.index body of message||binary zero count
9233.index binary zero||in message body
9234.tempindent 0
9235.em
9236\$body@_zerocount$\:
9237When a message is being received or delivered, this variable contains the
9238number of binary zero bytes in the message's body.
9239.nem
9240
9241.tempindent 0
9242\$bounce@_recipient$\:
9243This is set to the recipient address of a bounce message while Exim is creating
9244it. It is useful if a customized bounce message text file is in use (see
9245chapter ~~CHAPemsgcust).
9246
9247.tempindent 0
9248\$bounce@_return@_size@_limit$\: This contains the value set in the
9249\bounce@_return@_size@_limit\ option, rounded up to a multiple of 1000. It is
9250useful when a customized error message text file is in use (see chapter
9251~~CHAPemsgcust).
9252
9253.index gid (group id)||caller
9254.tempindent 0
9255\$caller@_gid$\: The
9256.em
9257real
9258.nem
9259group id under which the process that called Exim was
9260running. This is not the same as the group id of the originator of a message
9261(see \$originator@_gid$\). If Exim re-execs itself, this variable in the new
9262incarnation normally contains the Exim gid.
9263
9264.index uid (user id)||caller
9265.tempindent 0
9266\$caller@_uid$\: The
9267.em
9268real
9269.nem
9270user id under which the process that called Exim was
9271running. This is not the same as the user id of the originator of a message
9272(see \$originator@_uid$\). If Exim re-execs itself, this variable in the new
9273incarnation normally contains the Exim uid.
9274
9275.tempindent 0
9276\$compile@_date$\: The date on which the Exim binary was compiled.
9277
9278.tempindent 0
9279\$compile@_number$\: The building process for Exim keeps a count of the number
9280of times it has been compiled. This serves to distinguish different
9281compilations of the same version of the program.
9282
9283.index black list (DNS)
9284.tempindent 0
9285\$dnslist@_domain$\: When a client host is found to be on a DNS (black) list,
9286the list's domain name is put into this variable so that it can be included in
9287the rejection message.
9288
9289.tempindent 0
9290\$dnslist@_text$\: When a client host is found to be on a DNS (black) list, the
9291contents of any associated TXT record are placed in this variable.
9292
9293.tempindent 0
9294\$dnslist@_value$\: When a client host is found to be on a DNS (black) list,
9295the IP address from the resource record is placed in this variable.
9296If there are multiple records, all the addresses are included, comma-space
9297separated.
9298
9299.tempindent 0
9300\$domain$\: When an address is being routed, or delivered on its own, this
9301variable contains the domain. Global address rewriting happens when a message
9302is received, so the value of \$domain$\ during routing and delivery is the
9303value after rewriting. \$domain$\ is set during user filtering, but not during
9304system filtering, because a message may have many recipients and the system
9305filter is called just once.
9306
9307When more than one address is being delivered at once (for example, several
9308\\RCPT\\ commands in one SMTP delivery), \$domain$\ is set only if they all
9309have the same domain. Transports can be restricted to handling only one domain
9310at a time if the value of \$domain$\ is required at transport time -- this is
9311the default for local transports. For further details of the environment in
9312which local transports are run, see chapter ~~CHAPenvironment.
9313
9314.index \delay@_warning@_condition\
9315At the end of a delivery, if all deferred addresses have the same domain, it is
9316set in \$domain$\ during the expansion of \delay@_warning@_condition\.
9317
9318The \$domain$\ variable is also used in some other circumstances:
9319.numberpars $.
9320When an ACL is running for a \\RCPT\\ command, \$domain$\ contains the domain
9321of the recipient address.
9322\**Note:**\ the domain of the sender address is in \$sender@_address@_domain$\
9323at \\MAIL\\ time and at \\RCPT\\ time. \$domain$\ is not set for the \\MAIL\\
9324ACL.
9325.nextp
9326When a rewrite item is being processed (see chapter ~~CHAPrewrite), \$domain$\
9327contains the domain portion of the address that is being rewritten; it can be
9328used in the expansion of the replacement address, for example, to rewrite
9329domains by file lookup.
9330.nextp
9331With one important exception, whenever a domain list is being scanned,
9332\$domain$\ contains the subject domain. \**Exception**\: When a domain list in
9333a \sender@_domains\ condition in an ACL is being processed, the subject domain
9334is in \$sender@_address@_domain$\ and not in \$domain$\. It works this way so
9335that, in a \\RCPT\\ ACL, the sender domain list can be dependent on the
9336recipient domain (which is what is in \$domain$\ at this time).
9337.nextp
9338.index \\ETRN\\||value of \$domain$\
9339.index \smtp@_etrn@_command\
9340When the \smtp@_etrn@_command\ option is being expanded, \$domain$\ contains
9341the complete argument of the \\ETRN\\ command (see section ~~SECTETRN).
9342.endp
9343
9344.tempindent 0
9345\$domain@_data$\: When the \domains\ option on a router matches a domain by
9346means of a lookup, the data read by the lookup is available during the running
9347of the router as \$domain@_data$\. In addition, if the driver routes the
9348address to a transport, the value is available in that transport. If the
9349transport is handling multiple addresses, the value from the first address is
9350used.
9351
9352\$domain@_data$\ is also set when the \domains\ condition in an ACL matches a
9353domain by means of a lookup. The data read by the lookup is available during
9354the rest of the ACL statement. In all other situations, this variable expands
9355to nothing.
9356
9357.em
9358.tempindent 0
9359\$exim@_gid$\: This variable contains the numerical value of the Exim group id.
9360
9361.tempindent 0
9362\$exim@_path$\: This variable contains the path to the Exim binary.
9363
9364.tempindent 0
9365\$exim@_uid$\: This variable contains the numerical value of the Exim user id.
9366.nem
9367
9368.tempindent 0
9369\$header@_<<name>>$\: This is not strictly an expansion variable. It is
9370expansion syntax for inserting the message header line with the given name.
9371Note that the name must be terminated by colon or white space, because it may
9372contain a wide variety of characters.
9373Note also that braces must \*not*\ be used.
9374
9375.tempindent 0
9376\$home$\:
9377When the \check@_local@_user\ option is set for a router, the user's home
9378directory is placed in \$home$\ when the check succeeds. In particular, this
9379means it is set during the running of users' filter files. A router may also
9380explicitly set a home directory for use by a transport; this can be overridden
9381by a setting on the transport itself.
9382
9383When running a filter test via the \-bf-\ option, \$home$\ is set to the value
9384of the environment variable \\HOME\\.
9385
9386.tempindent 0
9387\$host$\:
9388When the \%smtp%\ transport is expanding its options for encryption using TLS,
9389\$host$\ contains the name of the host to which it is connected. Likewise, when
9390used in the client part of an authenticator configuration (see chapter
9391~~CHAPSMTPAUTH), \$host$\ contains the name of the server to which the client
9392is connected.
9393.index transport||filter
9394.index filter||transport filter
9395When used in a transport filter (see chapter ~~CHAPtransportgeneric) \$host$\
9396refers to the host involved in the current connection. When a local transport
9397is run as a result of a router that sets up a host list, \$host$\ contains the
9398name of the first host.
9399
9400.tempindent 0
9401\$host@_address$\:
9402This variable is set to the remote host's IP address whenever \$host$\ is set
9403for a remote connection.
9404
9405.tempindent 0
9406\$host@_data$\:
9407If a \hosts\ condition in an ACL is satisfied by means of a lookup, the result
9408of the lookup is made available in the \$host@_data$\ variable. This
9409allows you, for example, to do things like this:
9410.display asis
9411deny hosts = net-lsearch;/some/file
9412 message = $host_data
9413.endd
9414
9415.index host||name lookup, failure of
9416.tempindent 0
9417\$host@_lookup@_failed$\:
9418This variable contains `1' if the message came from a remote host and there was
9419an attempt to look up the host's name from its IP address, but the attempt
9420failed. Otherwise the value of the variable is `0'.
9421.em
9422Exim checks that a forward lookup of at least one of the names it receives from
9423a reverse lookup yields the original IP address. If this is not the case, Exim
9424does not accept the looked up name(s), and \$host@_lookup@_failed$\ is set to
9425`1'. Thus, being able to find a name from an IP address (for example, the
9426existence of a PTR record in the DNS) is not sufficient on its own for the
9427success of a host name lookup.
9428.nem
9429
9430.tempindent 0
9431\$inode$\:
9432The only time this variable is set is while expanding the \directory@_file\
9433option in the \%appendfile%\ transport. The variable contains the inode number
9434of the temporary file which is about to be renamed. It can be used to construct
9435a unique name for the file.
9436
9437.tempindent 0
9438\$interface@_address$\:
9439When a message is received over a TCP/IP connection, this variable contains the
9440address of the local IP interface. See also the \-oMi-\ command line option.
9441This variable can be used in ACLs and also, for example, to make the file name
9442for a TLS certificate depend on which interface is being used.
9443
9444.tempindent 0
9445\$interface@_port$\:
9446When a message is received over a TCP/IP connection, this variable contains the
9447local port number. See also the \-oMi-\ command line option.
9448This variable can be used in ACLs and also, for example, to make the file name
9449for a TLS certificate depend on which port is being used.
9450
9451.tempindent 0
9452\$ldap@_dn$\:
9453This variable, which is available only when Exim is compiled with LDAP support,
9454contains the DN from the last entry in the most recently successful LDAP
9455lookup.
9456
9457
9458.tempindent 0
9459\$load@_average$\:
9460This variable contains the system load average, multiplied by 1000 to that it
9461is an integer. For example, if the load average is 0.21, the value of the
9462variable is 210. The value is recomputed every time the variable is referenced.
9463
9464.tempindent 0
9465\$local@_part$\: When an address is being routed, or delivered on its own, this
9466variable contains the local part. When a number of addresses are being
9467delivered together (for example, multiple \\RCPT\\ commands in an SMTP
9468session), \$local@_part$\ is not set.
9469
9470Global address rewriting happens when a message is received, so the value of
9471\$local@_part$\ during routing and delivery is the value after rewriting.
9472\$local@_part$\ is set during user filtering, but not during system filtering,
9473because a message may have many recipients and the system filter is called just
9474once.
9475
9476If a local part prefix or suffix has been recognized, it is not included in the
9477value of \$local@_part$\ during routing and subsequent delivery. The values of
9478any prefix or suffix are in \$local@_part@_prefix$\ and
9479\$local@_part@_suffix$\, respectively.
9480
9481When a message is being delivered to a file, pipe, or autoreply transport as a
9482result of aliasing or forwarding, \$local@_part$\ is set to the local part of
9483the parent address, not to the file name or command (see \$address@_file$\ and
9484\$address@_pipe$\).
9485
9486When an ACL is running for a \\RCPT\\ command, \$local@_part$\ contains the
9487local part of the recipient address.
9488
9489When a rewrite item is being processed (see chapter ~~CHAPrewrite),
9490\$local@_part$\ contains the local part of the address that is being rewritten;
9491it can be used in the expansion of the replacement address, for example.
9492
9493In all cases, all quoting is removed from the local part. For example, for both
9494the addresses
9495.display asis
9496"abc:xyz"@test.example
9497abc\:xyz@test.example
9498.endd
9499the value of \$local@_part$\ is
9500.display asis
9501abc:xyz
9502.endd
9503If you use \$local@_part$\ to create another address, you should always wrap it
9504inside a quoting operator. For example, in a \%redirect%\ router you could have:
9505.display asis
9506data = ${quote_local_part:$local_part}@new.domain.example
9507.endd
9508.em
9509\**Note**\: The value of \$local@_part$\ is normally lower cased. If you want
9510to process local parts in a case-dependent manner in a router, you can set the
9511\caseful@_local@_part\ option (see chapter ~~CHAProutergeneric).
9512.nem
9513
9514.tempindent 0
9515\$local@_part@_data$\:
9516When the \local@_parts\ option on a router matches a local part by means of a
9517lookup, the data read by the lookup is available during the running of the
9518router as \$local@_part@_data$\. In addition, if the driver routes the address
9519to a transport, the value is available in that transport. If the transport is
9520handling multiple addresses, the value from the first address is used.
9521
9522\$local@_part@_data$\ is also set when the \local@_parts\ condition in an ACL
9523matches a local part by means of a lookup. The data read by the lookup is
9524available during the rest of the ACL statement. In all other situations, this
9525variable expands to nothing.
9526
9527.tempindent 0
9528\$local@_part@_prefix$\: When an address is being routed or delivered, and a
9529specific prefix for the local part was recognized, it is available in this
9530variable, having been removed from \$local@_part$\.
9531
9532.tempindent 0
9533\$local@_part@_suffix$\: When an address is being routed or delivered, and a
9534specific suffix for the local part was recognized, it is available in this
9535variable, having been removed from \$local@_part$\.
9536
9537.tempindent 0
9538\$local@_scan@_data$\: This variable contains the text returned by the
9539\*local@_scan()*\ function when a message is received. See chapter
9540~~CHAPlocalscan for more details.
9541
9542.tempindent 0
9543\$local@_user@_gid$\: See \$local@_user@_uid$\.
9544
9545.tempindent 0
9546\$local@_user@_uid$\: This variable and \$local@_user@_gid$\ are set to
9547the uid and gid after the \check__local__user\ router precondition succeeds.
9548This means that their values are available for the remaining preconditions
9549(\senders\, \require@_files\, and \condition\), for the \address@_data\
9550expansion, and for any router-specific expansions. At all other times, the
9551values in these variables are \"(uid@_t)(-1)"\ and \"(gid@_t)(-1)"\,
9552respectively.
9553
9554
9555.tempindent 0
9556\$localhost@_number$\: This contains the expanded value of the
9557\localhost@_number\ option. The expansion happens after the main options have
9558been read.
9559
9560.tempindent 0
9561\$mailstore@_basename$\: This variable is set only when doing deliveries in
9562`mailstore' format in the \%appendfile%\ transport. During the expansion of the
9563\mailstore@_prefix\, \mailstore@_suffix\, \message__prefix\, and
9564\message@_suffix\ options, it contains the basename of the files that are being
9565written, that is, the name without the `.tmp', `.env', or `.msg' suffix. At all
9566other times, this variable is empty.
9567
9568.index message||age of
9569.tempindent 0
9570\$message@_age$\: This variable is set at the start of a delivery attempt to
9571contain the number of seconds since the message was received. It does not
9572change during a single delivery attempt.
9573
9574.index body of message||expansion variable
9575.index message||body, in expansion
9576.index binary zero||in message body
9577.tempindent 0
9578\$message@_body$\: This variable contains the initial portion of a message's
9579body while it is being delivered, and is intended mainly for use in filter
9580files. The maximum number of characters of the body that are put into the
9581variable is set by the \message@_body@_visible\ configuration option; the
9582default is 500. Newlines are converted into spaces to make it easier to search
9583for phrases that might be split over a line break.
9584Binary zeros are also converted into spaces.
9585
9586.index body of message||expansion variable
9587.index message||body, in expansion
9588.tempindent 0
9589\$message@_body@_end$\: This variable contains the final portion of a message's
9590body while it is being delivered. The format and maximum size are as for
9591\$message@_body$\.
9592
9593.index body of message||size
9594.index message||body, size
9595.tempindent 0
9596\$message@_body@_size$\: When a message is being processed, this variable
9597contains the size of the body in bytes. The count starts from the character
9598after the blank line that separates the body from the header. Newlines are
9599included in the count. See also \$message@_size$\ and \$body@_linecount$\.
9600
9601.tempindent 0
9602\$message@_headers$\:
9603This variable contains a concatenation of all the header lines when a message
9604is being processed, except for lines added by routers or transports. The header
9605lines are separated by newline characters.
9606
9607.tempindent 0
9608\$message@_id$\:
9609When a message is being received or delivered, this variable contains the
9610unique message id that is used by Exim to identify the message.
9611An id is not created for a message until after its header has been
9612successfully received.
9613.em
9614\**Note**\: This is \*not*\ the contents of the ::Message-ID:: header line; it
9615is the local id that Exim assigns to the message, for example:
9616\"1BXTIK-0001yO-VA"\.
9617.nem
9618
9619.index size||of message
9620.index message||size
9621.tempindent 0
9622\$message@_size$\:
9623When a message is being processed, this variable contains its size in bytes. In
9624most cases, the size includes those headers that were received with the
9625message, but not those (such as ::Envelope-to::) that are added to individual
9626deliveries as they are written. However, there is one special case: during the
9627expansion of the \maildir@_tag\ option in the \%appendfile%\ transport while
9628doing a delivery in maildir format, the value of \$message@_size$\ is the
9629precise size of the file that has been written. See also
9630\$message@_body@_size$\ and \$body@_linecount$\.
9631
9632.index \\RCPT\\||value of \$message@_size$\
9633While running an ACL at the time of an SMTP \\RCPT\\ command, \$message@_size$\
9634contains the size supplied on the \\MAIL\\ command, or
9635-1
9636if no size was given. The value may not, of course, be truthful.
9637
9638.tempindent 0
9639\$n0$\ -- \$n9$\: These variables are counters that can be incremented by means
9640of the \add\ command in filter files.
9641
9642.tempindent 0
9643\$original@_domain$\: When a top-level address is being processed for delivery,
9644this contains the same value as \$domain$\. However, if a `child' address (for
9645example, generated by an alias, forward, or filter file) is being processed,
9646this variable contains the domain of the original address. This differs from
9647\$parent@_domain$\ only when there is more than one level of aliasing or
9648forwarding. When more than one address is being delivered in a single transport
9649run, \$original@_domain$\ is not set.
9650
9651If new an address is created by means of a \deliver\ command in a system
9652filter, it is set up with an artificial `parent' address. This has the local
9653part \*system-filter*\ and the default qualify domain.
9654
9655.tempindent 0
9656\$original@_local@_part$\: When a top-level address is being processed for
9657delivery, this contains the same value as \$local@_part$\, unless a prefix or
9658suffix was removed from the local part, in which case \$original@_local@_part$\
9659contains the full local part. When a `child' address (for example, generated by
9660an alias, forward, or filter file) is being processed, this variable contains
9661the full local part of the original address. If the router that did the
9662redirection processed the local part case-insensitively, the value in
9663\$original@_local@_part$\ is in lower case. This variable differs from
9664\$parent@_local@_part$\ only when there is more than one level of aliasing or
9665forwarding. When more than one address is being delivered in a single transport
9666run, \$original@_local@_part$\ is not set.
9667
9668If new an address is created by means of a \deliver\ command in a system
9669filter, it is set up with an artificial `parent' address. This has the local
9670part \*system-filter*\ and the default qualify domain.
9671
9672
9673.index gid (group id)||of originating user
9674.index sender||gid
9675.tempindent 0
9676\$originator@_gid$\: The value of \$caller@_gid$\ that was set when the message
9677was received. For messages received via the command line, this is the gid of
9678the sending user. For messages received by SMTP over TCP/IP, this is normally
9679the gid of the Exim user.
9680
9681.index uid (user id)||of originating user
9682.index sender||uid
9683.tempindent 0
9684\$originator@_uid$\: The value of \$caller@_uid$\ that was set when the message
9685was received. For messages received via the command line, this is the uid of
9686the sending user. For messages received by SMTP over TCP/IP, this is normally
9687the uid of the Exim user.
9688
9689.tempindent 0
9690\$parent@_domain$\: This variable is similar to \$original@_domain$\ (see
9691above), except that it refers to the immediately preceding parent address.
9692
9693.tempindent 0
9694\$parent@_local@_part$\: This variable is similar to \$original@_local@_part$\
9695(see above), except that it refers to the immediately preceding parent address.
9696
9697.index pid (process id)||of current process
9698.tempindent 0
9699\$pid$\: This variable contains the current process id.
9700
9701.index filter||transport filter
9702.index transport||filter
9703.tempindent 0
9704\$pipe@_addresses$\: This is not an expansion variable, but is mentioned here
9705because the string `@$pipe@_addresses' is handled specially in the command
9706specification for the \%pipe%\ transport (chapter ~~CHAPpipetransport) and in
9707transport filters (described under \transport@_filter\ in chapter
9708~~CHAPtransportgeneric). It cannot be used in general expansion strings, and
9709provokes an `unknown variable' error if encountered.
9710
9711.tempindent 0
9712\$primary@_hostname$\: The value set in the configuration file, or read by the
9713\*uname()*\ function. If \*uname()*\ returns a single-component name, Exim
9714calls \*gethostbyname()*\ (or \*getipnodebyname()*\ where available) in an
9715attempt to acquire a fully qualified host name.
9716.em
9717See also \$smtp@_active@_hostname$\.
9718.nem
9719
9720.tempindent 0
9721\$qualify@_domain$\: The value set for this option in the configuration file.
9722
9723.tempindent 0
9724\$qualify@_recipient$\: The value set for this option in the configuration file,
9725or if not set, the value of \$qualify@_domain$\.
9726
9727.tempindent 0
9728\$rcpt@_count$\: When a message is being received by SMTP, this variable
9729contains the number of \\RCPT\\ commands received for the current message. If
9730this variable is used in a \\RCPT\\ ACL, its value includes the current
9731command.
9732
9733.tempindent 0
9734\$rcpt@_defer@_count$\: When a message is being received by SMTP, this variable
9735contains the number of \\RCPT\\ commands in the current message that have
9736previously been rejected with a temporary (4\*xx*\) response.
9737
9738.tempindent 0
9739\$rcpt@_fail@_count$\: When a message is being received by SMTP, this variable
9740contains the number of \\RCPT\\ commands in the current message that have
9741previously been rejected with a permanent (5\*xx*\) response.
9742
9743.tempindent 0
9744\$received@_count$\: This variable contains the number of ::Received:: header
9745lines in the message, including the one added by Exim (so its value is always
9746greater than zero). It is available in the \\DATA\\ ACL, the non-SMTP ACL, and
9747while routing and delivering.
9748
9749.tempindent 0
9750\$received@_for$\: If there is only a single recipient address in an incoming
9751message, this variable contains that address when the ::Received:: header line
9752is being built.
9753.em
9754The value is copied after recipient rewriting has happened, but before the
9755\*local@_scan()*\ function is run.
9756.nem
9757
9758.tempindent 0
9759\$received@_protocol$\: When a message is being processed, this variable
9760contains the name of the protocol by which it was received. See also the
9761\-oMr-\ option.
9762
9763.em
9764.tempindent 0
9765\$recipient@_data$\: This variable is set after an indexing lookup success in
9766an ACL \recipients\ condition. It contains the data from the lookup, and the
9767value remains set until the next \recipients\ test. Thus, you can do things
9768like this:
9769.display
9770require recipients = cdb*@@;/some/file
9771deny \*some further test involving*\ @$recipient@_data
9772.endd
9773\**Warning**\: This variable is set only when a lookup is used as an indexing
9774method in the address list, using the semicolon syntax as in the example above.
9775The variable is not set for a lookup that is used as part of the string
9776expansion that all such lists undergo before being interpreted.
9777.nem
9778
9779.tempindent 0
9780\$recipients$\: This variable contains a list of envelope recipients for a
9781message. A comma and a space separate the addresses in the replacement text.
9782However, the variable is not generally available, to prevent exposure of Bcc
9783recipients in unprivileged users' filter files. You can use \$recipients$\ only
9784.numberpars
9785In a system filter file.
9786.nextp
9787In the \\DATA\\ or non-SMTP ACL, that is, in the final ACL for accepting a
9788message.
9789.endp
9790
9791.tempindent 0
9792\$recipients@_count$\: When a message is being processed, this variable
9793contains the number of envelope recipients that came with the message.
9794Duplicates are not excluded from the count. While a message is being received
9795over SMTP, the number increases for each accepted recipient. It can be
9796referenced in an ACL.
9797
9798.tempindent 0
9799\$reply@_address$\: When a message is being processed, this variable contains
9800the contents of the ::Reply-To:: header line if one exists
9801and it is not empty,
9802or otherwise the contents of the ::From:: header line.
9803
9804.tempindent 0
9805\$return@_path$\: When a message is being delivered, this variable contains the
9806return path -- the sender field that will be sent as part of the envelope. It
9807is not enclosed in @<@> characters.
9808At the start of routing an address,
9809\$return@_path$\ has the same value as \$sender@_address$\, but if, for
9810example, an incoming message to a mailing list has been expanded by a router
9811which specifies a different address for bounce messages, \$return@_path$\
9812subsequently contains the new bounce address, whereas \$sender@_address$\
9813always contains the original sender address that was received with the message.
9814In other words, \$sender@_address$\ contains the incoming envelope sender, and
9815\$return@_path$\ contains the outgoing envelope sender.
9816
9817.tempindent 0
9818\$return@_size@_limit$\: This is an obsolete name for
9819\$bounce@_return@_size@_limit$\.
9820
9821.index return code||from \run\ expansion
9822.tempindent 0
9823\$runrc$\: This variable contains the return code from a command that is run by
9824the \@$@{run...@}\ expansion item.
9825\**Warning**\: In a router or transport, you cannot assume the order in which
9826option values are expanded, except for those pre-conditions whose order of
9827testing is documented. Therefore, you cannot reliably expect to set \$runrc$\
9828by the expansion of one option, and use it in another.
9829
9830.tempindent 0
9831\$self@_hostname$\: When an address is routed to a supposedly remote host that
9832turns out to be the local host, what happens is controlled by the
9833.index \self\ option||value of host name
9834\self\ generic router option. One of its values causes the address to be passed
9835to another router. When this happens, \$self@_hostname$\ is set to the name of
9836the local host that the original router encountered. In other circumstances its
9837contents are null.
9838
9839.tempindent 0
9840\$sender@_address$\: When a message is being processed, this variable contains
9841the sender's address that was received in the message's envelope. For bounce
9842messages, the value of this variable is the empty string.
9843See also \$return@_path$\.
9844
9845.tempindent 0
9846\$sender@_address@_domain$\: The domain portion of \$sender@_address$\.
9847
9848.tempindent 0
9849\$sender@_address@_local@_part$\: The local part portion of \$sender@_address$\.
9850
9851.em
9852.tempindent 0
9853\$sender@_data$\: This variable is set after a lookup success in an ACL
9854\senders\ condition or in a router \senders\ option. It contains the data from
9855the lookup, and the value remains set until the next \senders\ test. Thus, you
9856can do things like this:
9857.display
9858require senders = cdb*@@;/some/file
9859deny \*some further test involving*\ @$sender@_data
9860.endd
9861\**Warning**\: This variable is set only when a lookup is used as an indexing
9862method in the address list, using the semicolon syntax as in the example above.
9863The variable is not set for a lookup that is used as part of the string
9864expansion that all such lists undergo before being interpreted.
9865.nem
9866
9867.tempindent 0
9868\$sender@_fullhost$\: When a message is received from a remote host, this
9869variable contains the host name and IP address in a single string. It ends
9870with the IP address in square brackets, followed by a colon and a port number
9871if the logging of ports is enabled. The format of the rest of the string
9872depends on whether the host issued a \\HELO\\ or \\EHLO\\ SMTP command, and
9873whether the host name was verified by looking up its IP address. (Looking up
9874the IP address can be forced by the \host@_lookup\ option, independent of
9875verification.) A plain host name at the start of the string is a verified host
9876name; if this is not present, verification either failed or was not requested.
9877A host name in parentheses is the argument of a \\HELO\\ or \\EHLO\\ command.
9878This is omitted if it is identical to the verified host name or to the host's
9879IP address in square brackets.
9880
9881.tempindent 0
9882\$sender@_helo@_name$\: When a message is received from a remote host that has
9883issued a \\HELO\\ or \\EHLO\\ command, the argument of that command is placed
9884in this variable. It is also set if \\HELO\\ or \\EHLO\\ is used when a message
9885is received using SMTP locally via the \-bs-\ or \-bS-\ options.
9886
9887.tempindent 0
9888\$sender@_host@_address$\: When a message is received from a remote host, this
9889variable contains that host's IP address. For locally submitted messages, it is
9890empty.
9891
9892.tempindent 0
9893\$sender@_host@_authenticated$\: This variable contains the name (not the
9894public name) of the authenticator driver which successfully authenticated the
9895client from which the message was received. It is empty if there was no
9896successful authentication.
9897
9898.tempindent 0
9899\$sender@_host@_name$\: When a message is received from a remote host, this
9900variable contains the host's name as obtained by looking up its IP address.
9901For messages received by other means, this variable is empty.
9902
9903If the host name has not previously been looked up, a reference to
9904\$sender@_host@_name$\ triggers a lookup (for messages from remote hosts).
9905.em
9906A looked up name is accepted only if it leads back to the original IP address
9907via a forward lookup. If either the reverse or the forward lookup fails, or if
9908the forward lookup does not yield the original IP address,
9909\$sender@_host@_name$\ remains empty, and \$host@_lookup@_failed$\ is set to
9910`1'.
9911.nem
9912
9913Exim does not automatically look up every calling host's name. If you want
9914maximum efficiency, you should arrange your configuration so that it avoids
9915these lookups altogether. The lookup happens only if one or more of the
9916following are true:
9917.numberpars
9918A string containing \$sender@_host@_name$\ is expanded.
9919.nextp
9920The calling host matches the list in \host@_lookup\. In the default
9921configuration, this option is set to $*$, so it must be changed if lookups are
9922to be avoided. (In the code, the default for \host@_lookup\ is unset.)
9923.nextp
9924Exim needs the host name in order to test an item in a host list. The items
9925that require this are described in sections ~~SECThoslispatnam and
9926~~SECThoslispatnamsk.
9927.nextp
9928The calling host matches \helo@_try@_verify@_hosts\ or \helo@_verify@_hosts\.
9929In this case, the host name is required to compare with the name quoted in any
9930\\EHLO\\ or \\HELO\\ commands that the client issues.
9931.nextp
9932The remote host issues a \\EHLO\\ or \\HELO\\ command that quotes one of the
9933domains in \helo@_lookup@_domains\. The default value of this option is
9934.display asis
9935helo_lookup_domains = @ : @[]
9936.endd
9937which causes a lookup if a remote host (incorrectly) gives the server's name or
9938IP address in an \\EHLO\\ or \\HELO\\ command.
9939.endp
9940
9941.tempindent 0
9942\$sender@_host@_port$\: When a message is received from a remote host, this
9943variable contains the port number that was used on the remote host.
9944
9945.tempindent 0
9946\$sender@_ident$\: When a message is received from a remote host, this variable
9947contains the identification received in response to an RFC 1413 request. When a
9948message has been received locally, this variable contains the login name of the
9949user that called Exim.
9950
9951.tempindent 0
9952\$sender@_rcvhost$\: This is provided specifically for use in ::Received::
9953headers. It starts with either the verified host name (as obtained from a
9954.index DNS||reverse lookup
9955.index reverse DNS lookup
9956reverse DNS lookup) or, if there is no verified host name, the IP address in
9957square brackets. After that there may be text in parentheses. When the first
9958item is a verified host name, the first thing in the parentheses is the IP
9959address in square brackets, followed by a colon and a port number if port
9960logging is enabled. When the first item is an IP address, the port is recorded
9961as `port=$it{xxxx}' inside the parentheses.
9962
9963There may also be items of the form `helo=$it{xxxx}' if \\HELO\\ or \\EHLO\\
9964was used and its argument was not identical to the real host name or IP
9965address, and `ident=$it{xxxx}' if an RFC 1413 ident string is available. If all
9966three items are present in the parentheses, a newline and tab are inserted into
9967the string, to improve the formatting of the ::Received:: header.
9968
9969.index \\AUTH\\||argument
9970.index \\EXPN\\||argument
9971.index \\ETRN\\||argument
9972.index \\VRFY\\||argument
9973.tempindent 0
9974\$smtp@_command@_argument$\: While an ACL is running to check an \\AUTH\\,
9975\\EHLO\\, \\EXPN\\, \\ETRN\\, \\HELO\\, or \\VRFY\\ command, this variable
9976contains the argument for the SMTP command.
9977
9978.tempindent 0
9979\$sn0$\ -- \$sn9$\: These variables are copies of the values of the \$n0$\
9980-- \$n9$\ accumulators that were current at the end of the system filter file.
9981This allows a system filter file to set values that can be tested in users'
9982filter files. For example, a system filter could set a value indicating how
9983likely it is that a message is junk mail.
9984
9985.tempindent 0
9986\$spool@_directory$\: The name of Exim's spool directory.
9987
9988.tempindent 0
9989\$thisaddress$\: This variable is set only during the processing of the
9990\foranyaddress\ command in a filter file. Its use is explained in the
9991description of that command.
9992
9993.tempindent 0
9994\$tls@_certificate@_verified$\:
9995This variable is set to `1' if a TLS certificate was verified when the message
9996was received, and `0' otherwise.
9997
9998.tempindent 0
9999\$tls@_cipher$\: When a message is received from a remote host over an
10000encrypted SMTP connection, this variable is set to the cipher suite that was
10001negotiated, for example DES-CBC3-SHA.
10002In other circumstances, in particular, for message received over unencrypted
10003connections, the variable is empty.
10004See chapter ~~CHAPTLS for details of TLS support.
10005
10006.tempindent 0
10007\$tls@_peerdn$\: When a message is received from a remote host over an
10008encrypted SMTP connection,
10009and Exim is configured to request a certificate from the client,
10010the value of the Distinguished Name of the certificate is made available in the
10011\$tls@_peerdn$\ during subsequent processing.
10012
10013.tempindent 0
10014\$tod@_bsdinbox$\: The time of day and date, in the format required for
10015BSD-style mailbox files, for example: Thu Oct 17 17:14:09 1995.
10016
10017.tempindent 0
10018\$tod@_epoch$\: The time and date as a number of seconds since the start of the
10019Unix epoch.
10020
10021.tempindent 0
10022\$tod@_full$\: A full version of the time and date, for example: Wed, 16 Oct
100231995 09:51:40 +0100. The timezone is always given as a numerical offset from
10024UTC, with positive values used for timezones that are ahead (east) of UTC, and
10025negative values for those that are behind (west).
10026
10027.tempindent 0
10028\$tod@_log$\: The time and date in the format used for writing Exim's log
10029files, for example: 1995-10-12 15:32:29,
10030but without a timezone.
10031
10032.tempindent 0
10033\$tod@_logfile$\:
10034This variable contains the date in the format yyyymmdd. This is the format that
10035is used for datestamping log files when \log@_file@_path\ contains the \"%D"\
10036flag.
10037
10038.tempindent 0
10039\$tod@_zone$\: This variable contains the numerical value of the local
10040timezone, for example: -0500.
10041
10042.tempindent 0
10043\$tod@_zulu$\:
10044This variable contains the UTC date and time in `Zulu' format, as specified by
10045ISO 8601, for example: 20030221154023Z.
10046
10047.index \$value$\
10048.tempindent 0
10049\$value$\: This variable contains the result of an expansion lookup, extraction
10050operation, or external command, as described above.
10051
10052.tempindent 0
10053\$version@_number$\: The version number of Exim.
10054
10055.tempindent 0
10056\$warn@_message@_delay$\: This variable is set only during the creation of a
10057message warning about a delivery delay. Details of its use are explained in
10058section ~~SECTcustwarn.
10059
10060.tempindent 0
10061\$warn@_message@_recipients$\: This variable is set only during the creation of
10062a message warning about a delivery delay. Details of its use are explained in
10063section ~~SECTcustwarn.
10064.pop
10065
10066
10067
10068.
10069.
10070. ============================================================================
10071.chapter Embedded Perl
10072.set runningfoot "embedded Perl"
10073.rset CHAPperl "~~chapter"
10074.index Perl||calling from Exim
10075
10076Exim can be built to include an embedded Perl interpreter. When this is done,
10077Perl subroutines can be called as part of the string expansion process. To make
10078use of the Perl support, you need version 5.004 or later of Perl installed on
10079your system. To include the embedded interpreter in the Exim binary, include
10080the line
10081.display asis
10082EXIM_PERL = perl.o
10083.endd
10084in your \(Local/Makefile)\ and then build Exim in the normal way.
10085
10086Access to Perl subroutines is via a global configuration option called
10087.index \perl@_startup\
10088\perl@_startup\ and an expansion string operator \@$@{perl ...@}\. If there is
10089no \perl@_startup\ option in the Exim configuration file then no Perl
10090interpreter is started and there is almost no overhead for Exim (since none of
10091the Perl library will be paged in unless used). If there is a \perl@_startup\
10092option then the associated value is taken to be Perl code which is executed in
10093a newly created Perl interpreter.
10094
10095The value of \perl@_startup\ is not expanded in the Exim sense, so you do not
10096need backslashes before any characters to escape special meanings. The option
10097should usually be something like
10098.display asis
10099perl_startup = do '/etc/exim.pl'
10100.endd
10101where \(/etc/exim.pl)\ is Perl code which defines any subroutines you want to
10102use from Exim. Exim can be configured either to start up a Perl interpreter as
10103soon as it is entered, or to wait until the first time it is needed. Starting
10104the interpreter at the beginning ensures that it is done while Exim still has
10105its setuid privilege, but can impose an unnecessary overhead if Perl is not in
10106fact used in a particular run. Also, note that this does not mean that Exim is
10107necessarily running as root when Perl is called at a later time. By default,
10108the interpreter is started only when it is needed, but this can be changed in
10109two ways:
10110.numberpars $.
10111.index \perl@_at@_start\
10112Setting \perl@_at@_start\ (a boolean option) in the configuration requests
10113a startup when Exim is entered.
10114.nextp
10115The command line option \-ps-\ also requests a startup when Exim is entered,
10116overriding the setting of \perl@_at@_start\.
10117.endp
10118There is also a command line option \-pd-\ (for delay) which suppresses the
10119initial startup, even if \perl@_at@_start\ is set.
10120
10121When the configuration file includes a \perl@_startup\ option you can make use
10122of the string expansion item to call the Perl subroutines that are defined
10123by the \perl@_startup\ code. The operator is used in any of the following
10124forms:
10125.display asis
10126${perl{foo}}
10127${perl{foo}{argument}}
10128${perl{foo}{argument1}{argument2} ... }
10129.endd
10130which calls the subroutine \foo\ with the given arguments. A maximum of eight
10131arguments may be passed. Passing more than this results in an expansion failure
10132with an error message of the form
10133.display asis
10134Too many arguments passed to Perl subroutine "foo" (max is 8)
10135.endd
10136The return value of the Perl subroutine is evaluated in a scalar context before
10137it is passed back to Exim to be inserted into the expanded string. If the
10138return value is \*undef*\, the expansion fails in the same way as an explicit
10139`fail' on an \@$@{if ...@}\ or \@$@{lookup...@}\ item.
10140If the subroutine aborts by obeying Perl's \die\ function, the expansion fails
10141with the error message that was passed to \die\.
10142
10143Within any Perl code called from Exim, the function \*Exim@:@:expand@_string*\
10144is available to call back into Exim's string expansion function. For example,
10145the Perl code
10146.display asis
10147my $lp = Exim::expand_string('$local_part');
10148.endd
10149makes the current Exim \$local@_part$\ available in the Perl variable \$lp$\.
10150Note those are single quotes and not double quotes to protect against
10151\$local@_part$\ being interpolated as a Perl variable.
10152
10153If the string expansion is forced to fail by a `fail' item, the result of
10154\*Exim@:@:expand@_string*\ is \undef\. If there is a syntax error in the
10155expansion string, the Perl call from the original expansion string fails with
10156an appropriate error message, in the same way as if \die\ were used.
10157
10158.index debugging||from embedded Perl
10159.index log||writing from embedded Perl
10160Two other Exim functions are available for use from within Perl code.
10161\*Exim@:@:debug@_write(<<string>>)*\ writes the string to the standard error
10162stream if Exim's debugging is enabled. If you want a newline at the end, you
10163must supply it. \*Exim@:@:log@_write(<<string>>)*\ writes the string to Exim's
10164main log, adding a leading timestamp. In this case, you should not supply a
10165terminating newline.
10166
10167
10168
10169.
10170.
10171.
10172.
10173. ============================================================================
10174.chapter Starting the daemon and the use of network interfaces
10175.set runningfoot "starting the daemon"
10176.rset CHAPinterfaces "~~chapter"
10177.index daemon||starting
10178.index interface||listening
10179.index network interface
10180.index interface||network
10181.index IP address||for listening
10182.index daemon||listening IP addresses
10183.index TCP/IP||setting listening interfaces
10184.index TCP/IP||setting listening ports
10185
10186A host that is connected to a TCP/IP network may have one or more physical
10187hardware network interfaces. Each of these interfaces may be configured as one
10188or more `logical' interfaces, which are the entities that a program actually
10189works with. Each of these logical interfaces is associated with an IP address.
10190In addition, TCP/IP software supports `loopback' interfaces (127.0.0.1 in IPv4
10191and @:@:1 in IPv6), which do not use any physical hardware. Exim requires
10192knowledge about the host's interfaces for use in three different circumstances:
10193.numberpars
10194When a listening daemon is started, Exim needs to know which interfaces
10195and ports to listen on.
10196.nextp
10197When Exim is routing an address, it needs to know which IP addresses
10198are associated with local interfaces. This is required for the correct
10199processing of MX lists by removing the local host and others with the
10200same or higher priority values. Also, Exim needs to detect cases
10201when an address is routed to an IP address that in fact belongs to the
10202local host. Unless the \self\ router option or the \allow@_localhost\
10203option of the smtp transport is set (as appropriate), this is treated
10204as an error situation.
10205.nextp
10206When Exim connects to a remote host, it may need to know which interface to use
10207for the outgoing connection.
10208.endp
10209
10210Exim's default behaviour is likely to be appropriate in the vast majority
10211of cases. If your host has only one interface, and you want all its IP
10212addresses to be treated in the same way, and you are using only the
10213standard SMTP port, you should not need to take any special action. The
10214rest of this chapter does not apply to you.
10215
10216In a more complicated situation you may want to listen only on certain
10217interfaces, or on different ports, and for this reason there are a number of
10218options that can be used to influence Exim's behaviour. The rest of this
10219chapter describes how they operate.
10220
10221When a message is received over TCP/IP, the interface and port that were
10222actually used are set in \$interface@_address$\ and \$interface@_port$\.
10223
10224
10225.section Starting a listening daemon
10226When a listening daemon is started (by means of the \-bd-\ command line
10227option), the interfaces and ports on which it listens are controlled by the
10228following options:
10229.numberpars $.
10230\daemon@_smtp@_ports\ contains a list of default ports. (For backward
10231compatibility, this option can also be specified in the singular.)
10232.nextp
10233\local@_interfaces\ contains list of interface IP addresses on which to
10234listen. Each item may optionally also specify a port.
10235.endp
10236The default list separator in both cases is a colon, but this can be changed as
10237described in section ~~SECTlistconstruct. When IPv6 addresses are involved, it
10238is usually best to change the separator to avoid having to double all the
10239colons. For example:
10240.display asis
10241local_interfaces = <; 127.0.0.1 ; \
10242 192.168.23.65 ; \
10243 ::1 ; \
10244 3ffe:ffff:836f::fe86:a061
10245.endd
10246There are two different formats for specifying a port along with an IP address
10247in \local@_interfaces\:
10248.numberpars
10249The port is added onto the address with a dot separator. For example, to listen
10250on port 1234 on two different IP addresses:
10251.display asis
10252local_interfaces = <; 192.168.23.65.1234 ; \
10253 3ffe:ffff:836f::fe86:a061.1234
10254.endd
10255.nextp
10256The IP address is enclosed in square brackets, and the port is added
10257with a colon separator, for example:
10258.display asis
10259local_interfaces = <; [192.168.23.65]:1234 ; \
10260 [3ffe:ffff:836f::fe86:a061]:1234
10261.endd
10262.endp
10263When a port is not specified, the value of \daemon@_smtp@_ports\ is used. The
10264default setting contains just one port:
10265.display asis
10266daemon_smtp_ports = smtp
10267.endd
10268If more than one port is listed, each interface that does not have its own port
10269specified listens on all of them. Ports that are listed in
10270\daemon@_smtp@_ports\ can be identified either by name (defined in
10271\(/etc/services)\) or by number. However, when ports are given with individual
10272IP addresses in \local@_interfaces\, only numbers (not names) can be used.
10273
10274
10275.section Special IP listening addresses
10276The addresses 0.0.0.0 and @:@:0 are treated specially. They are interpreted
10277as `all IPv4 interfaces' and `all IPv6 interfaces', respectively. In each
10278case, Exim tells the TCP/IP stack to `listen on all IPv\*x*\ interfaces'
10279instead of setting up separate listening sockets for each interface. The
10280default value of \local@_interfaces\ is
10281.display asis
10282local_interfaces = 0.0.0.0
10283.endd
10284when Exim is built without IPv6 support; otherwise it is:
10285.display asis
10286local_interfaces = <; ::0 ; 0.0.0.0
10287.endd
10288Thus, by default, Exim listens on all available interfaces, on the SMTP port.
10289
10290
10291.section Overriding local@_interfaces and daemon@_smtp@_ports
10292The \-oX-\ command line option can be used to override the values of
10293\daemon@_smtp@_ports\ and/or \local@_interfaces\ for a particular daemon
10294instance. Another way of doing this would be to use macros and the \-D-\
10295option. However, \-oX-\ can be used by any admin user, whereas modification of
10296the runtime configuration by \-D-\ is allowed only when the caller is root or
10297exim.
10298
10299The value of \-oX-\ is a list of items. The default colon separator can be
10300changed in the usual way if required. If there are any items that do not
10301contain dots or colons (that is, are not IP addresses), the value of
10302\daemon@_smtp@_ports\ is replaced by the list of those items. If there are any
10303items that do contain dots or colons, the value of \local@_interfaces\ is
10304replaced by those items. Thus, for example,
10305.display asis
10306-oX 1225
10307.endd
10308overrides \daemon@_smtp@_ports\, but leaves \local@_interfaces\ unchanged,
10309whereas
10310.display asis
10311-oX 192.168.34.5.1125
10312.endd
10313overrides \local@_interfaces\, leaving \daemon@_smtp@_ports\ unchanged.
10314(However, since \local@_interfaces\ now contains no items without ports, the
10315value of \daemon@_smtp@_ports\ is no longer relevant in this example.)
10316
10317
10318.section IPv6 address scopes
10319IPv6 addresses have `scopes', and a host with multiple hardware interfaces
10320can, in principle, have the same link-local IPv6 address on different
10321interfaces. Thus, additional information is needed, over and above the IP
10322address, to distinguish individual interfaces. A convention of using a
10323percent sign followed by something (often the interface name) has been
10324adopted in some cases, leading to addresses like this:
10325.display asis
103263ffe:2101:12:1:a00:20ff:fe86:a061%eth0
10327.endd
10328To accommodate this usage, a percent sign followed by an arbitrary string is
10329allowed at the end of an IPv6 address. By default, Exim calls \*getaddrinfo()*\
10330to convert a textual IPv6 address for actual use. This function recognizes the
10331percent convention in operating systems that support it, and it processes the
10332address appropriately. Unfortunately, some older libraries have problems with
10333\*getaddrinfo()*\. If
10334.display asis
10335IPV6_USE_INET_PTON=yes
10336.endd
10337is set in \(Local/Makefile)\ (or an OS-dependent Makefile) when Exim is built,
10338Exim uses \*inet@_pton()*\ to convert a textual IPv6 address for actual use,
10339instead of \*getaddrinfo()*\. (Before version 4.14, it always used this
10340function.) Of course, this means that the additional functionality of
10341\*getaddrinfo()*\ -- recognizing scoped addresses -- is lost.
10342
10343
10344.section Examples of starting a listening daemon
10345The default case in an IPv6 environment is
10346.display asis
10347daemon_smtp_port = smtp
10348local_interfaces = <; ::0 ; 0.0.0.0
10349.endd
10350This specifies listening on the smtp port on all IPv6 and IPv4 interfaces.
10351Either one or two sockets may be used, depending on the characteristics of
10352the TCP/IP stack. (This is complicated and messy; for more information,
10353read the comments in the \(daemon.c)\ source file.)
10354
10355To specify listening on ports 25 and 26 on all interfaces:
10356.display asis
10357daemon_smtp_ports = 25 : 26
10358.endd
10359(leaving \local@_interfaces\ at the default setting) or, more explicitly:
10360.display asis
10361local_interfaces = <; ::0.25 ; ::0.26 \
10362 0.0.0.0.25 ; 0.0.0.0.26
10363.endd
10364To listen on the default port on all IPv4 interfaces, and on port 26 on the
10365IPv4 loopback address only:
10366.display asis
10367local_interfaces = 0.0.0.0 : 127.0.0.1.26
10368.endd
10369To specify listening on the default port on specific interfaces only:
10370.display asis
10371local_interfaces = 192.168.34.67 : 192.168.34.67
10372.endd
10373\**Note**\: such a setting excludes listening on the loopback interfaces.
10374
10375
10376.section Recognising the local host
10377.rset SECTreclocipadd "~~chapter.~~section"
10378The \local@_interfaces\ option is also used when Exim needs to determine
10379whether or not an IP address refers to the local host. That is, the IP
10380addresses of all the interfaces on which a daemon is listening are always
10381treated as local.
10382
10383For this usage, port numbers in \local@_interfaces\ are ignored. If either of
10384the items 0.0.0.0 or @:@:0 are encountered, Exim gets a complete list of
10385available interfaces from the operating system, and extracts the relevant
10386(that is, IPv4 or IPv6) addresses to use for checking.
10387
10388Some systems set up large numbers of virtual interfaces in order to provide
10389many virtual web servers. In this situation, you may want to listen for
10390email on only a few of the available interfaces, but nevertheless treat all
10391interfaces as local when routing. You can do this by setting
10392\extra@_local@_interfaces\ to a list of IP addresses, possibly including the
10393`all' wildcard values. These addresses are recognized as local, but are not
10394used for listening. Consider this example:
10395.display asis
10396local_interfaces = <; 127.0.0.1 ; ::1 ; \
10397 192.168.53.235 ; \
10398 3ffe:2101:12:1:a00:20ff:fe86:a061
10399
10400extra_local_interfaces = <; ::0 ; 0.0.0.0
10401.endd
10402The daemon listens on the loopback interfaces and just one IPv4 and one IPv6
10403address, but all available interface addresses are treated as local when
10404Exim is routing.
10405
10406In some environments the local host name may be in an MX list, but with an IP
10407address that is not assigned to any local interface. In other cases it may be
10408desirable to treat other host names as if they referred to the local host. Both
10409these cases can be handled by setting the \hosts@_treat@_as@_local\ option.
10410This contains host names rather than IP addresses. When a host is referenced
10411during routing, either via an MX record or directly, it is treated as the local
10412host if its name matches \hosts@_treat@_as@_local\, or if any of its IP
10413addresses match \local@_interfaces\ or \extra@_local@_interfaces\.
10414
10415
10416.section Delivering to a remote host
10417Delivery to a remote host is handled by the smtp transport. By default, it
10418allows the system's TCP/IP functions to choose which interface to use (if
10419there is more than one) when connecting to a remote host. However, the
10420\interface\ option can be set to specify which interface is used. See the
10421description of the smtp transport in chapter ~~CHAPsmtptrans for more details.
10422
10423
10424
10425
10426
10427.
10428.
10429.
10430.
10431. ============================================================================
10432.chapter Main configuration
10433.set runningfoot "main configuration"
10434.rset CHAPmainconfig "~~chapter"
10435.index configuration file||main section
10436.index main configuration
10437The first part of the run time configuration file contains three types of item:
10438.numberpars $.
10439Macro definitions: These lines start with an upper case letter. See section
10440~~SECTmacrodefs for details of macro processing.
10441.nextp
10442Named list definitions: These lines start with one of the words `domainlist',
10443`hostlist', `addresslist', or `localpartlist'. Their use is described in
10444section ~~SECTnamedlists.
10445.nextp
10446Main configuration settings: Each setting occupies one line of the file
10447(with possible continuations). If any setting is preceded by the word
10448`hide', the \-bP-\ command line option displays its value to admin users only.
10449See section ~~SECTcos for a description of the syntax of these option settings.
10450.endp
10451This chapter specifies all the main configuration options, along with their
10452types and default values. For ease of finding a particular option, they appear
10453in alphabetical order in section ~~SECTalomo below. However, because there are
10454now so many options, they are first listed briefly in functional groups, as an
10455aid to finding the name of the option you are looking for.
10456Some options are listed in more than one group.
10457
10458.set savedisplayflowcheck ~~displayflowcheck
10459.set displayflowcheck 0
10460
10461.section Miscellaneous
10462.display flow rm
10463.tabs 31
10464\bi@_command\ $t$rm{to run for \-bi-\ command line option}
10465\keep@_malformed\ $t$rm{for broken files -- should not happen}
10466\localhost@_number\ $t$rm{for unique message ids in clusters}
10467\message@_body@_visible\ $t$rm{how much to show in \$message@_body$\}
10468\print@_topbitchars\ $t$rm{top-bit characters are printing}
10469\timezone\ $t$rm{force time zone}
10470.endd
10471
10472.section Exim parameters
10473.display flow rm
10474.tabs 31
10475\exim@_group\ $t$rm{override compiled-in value}
10476\exim@_path\ $t$rm{override compiled-in value}
10477\exim@_user\ $t$rm{override compiled-in value}
10478\primary@_hostname\ $t$rm{default from \*uname()*\}
10479\split@_spool@_directory\ $t$rm{use multiple directories}
10480\spool@_directory\ $t$rm{override compiled-in value}
10481.endd
10482
10483.section Privilege controls
10484.display flow rm
10485.tabs 31
10486\admin@_groups\ $t$rm{groups that are Exim admin users}
10487\deliver@_drop@_privilege\ $t$rm{drop root for delivery processes}
10488\local@_from@_check\ $t$rm{insert ::Sender:: if necessary}
10489\local@_from@_prefix\ $t$rm{for testing ::From:: for local sender}
10490\local@_from@_suffix\ $t$rm{for testing ::From:: for local sender}
10491\local@_sender@_retain\ $t$rm{keep ::Sender:: from untrusted user}
10492\never@_users\ $t$rm{do not run deliveries as these}
10493\prod@_requires@_admin\ $t$rm{forced delivery requires admin user}
10494\queue@_list@_requires@_admin\ $t$rm{queue listing requires admin user}
10495\trusted@_groups\ $t$rm{groups that are trusted}
10496\trusted@_users\ $t$rm{users that are trusted}
10497.endd
10498
10499.section Logging
10500.display flow rm
10501.tabs 31
10502\log@_file@_path\ $t$rm{override compiled-in value}
10503\log@_selector\ $t$rm{set/unset optional logging}
10504\log@_timezone\ $t$rm{add timezone to log lines}
10505\message@_logs\ $t$rm{create per-message logs}
10506\preserve@_message@_logs\ $t$rm{in another directory after message completion}
10507\process@_log@_path\ $t$rm{for SIGUSR1 and \*exiwhat*\}
10508\syslog@_duplication\ $t$rm{controls duplicate log lines on syslog }
10509\syslog@_facility\ $t$rm{set syslog `facility' field}
10510\syslog@_processname\ $t$rm{set syslog `ident' field}
10511\syslog@_timestamp\ $t$rm{timestamp syslog lines}
10512.newline
10513.em
10514\write@_rejectlog\ $t$rm{control use of message log}
10515.newline
10516.nem
10517.endd
10518
10519.section Frozen messages
10520.display flow rm
10521.tabs 31
10522\auto@_thaw\ $t$rm{sets time for retrying frozen messages}
10523\freeze@_tell\ $t$rm{send message when freezing}
10524\move@_frozen@_messages\ $t$rm{to another directory}
10525\timeout@_frozen@_after\ $t$rm{keep frozen messages only so long}
10526.endd
10527
10528.section Data lookups
10529.display flow rm
10530.tabs 31
10531\ldap@_default@_servers\ $t$rm{used if no server in query}
10532\ldap@_version\ $t$rm{set protocol version}
10533\lookup@_open@_max\ $t$rm{lookup files held open}
10534\mysql@_servers\ $t$rm{as it says}
10535\oracle@_servers\ $t$rm{as it says}
10536\pgsql@_servers\ $t$rm{as it says}
10537.endd
10538
10539.section Message ids
10540.display flow rm
10541.tabs 31
10542\message@_id@_header@_domain\ $t$rm{used to build ::Message-ID:: header}
10543\message@_id@_header@_text\ $t$rm{ditto}
10544.endd
10545
10546.section Embedded Perl Startup
10547.display flow rm
10548.tabs 31
10549\perl@_at@_start\ $t$rm{always start the interpreter}
10550\perl@_startup\ $t$rm{code to obey when starting Perl}
10551.endd
10552
10553.section Daemon
10554.display flow rm
10555.tabs 31
10556\daemon@_smtp@_ports\ $t$rm{default ports}
10557\extra@_local@_interfaces\ $t$rm{not necessarily listened on}
10558\local@_interfaces\ $t$rm{on which to listen, with optional ports}
10559\pid@_file@_path\ $t$rm{override compiled-in value}
10560\queue@_run@_max\ $t$rm{maximum number of simultaneous queue runners}
10561.endd
10562
10563.section Resource control
10564.display flow rm
10565.tabs 31
10566\check@_log@_inodes\ $t$rm{before accepting a message}
10567\check@_log@_space\ $t$rm{before accepting a message}
10568\check@_spool@_inodes\ $t$rm{before accepting a message}
10569\check@_spool@_space\ $t$rm{before accepting a message}
10570\deliver@_queue@_load@_max\ $t$rm{no queue deliveries if load high}
10571\queue@_only@_load\ $t$rm{queue incoming if load high}
10572\queue@_run@_max\ $t$rm{maximum number of simultaneous queue runners}
10573\remote@_max@_parallel\ $t$rm{parallel SMTP delivery per message}
10574\smtp@_accept@_max\ $t$rm{simultaneous incoming connections}
10575\smtp@_accept@_max@_nommail\ $t$rm{non-mail commands}
10576\smtp@_accept@_max@_nonmail@_hosts\ $t$rm{hosts to which the limit applies}
10577\smtp@_accept@_max@_per@_connection\ $t$rm{messages per connection}
10578\smtp@_accept@_max@_per@_host\ $t$rm{connections from one host}
10579\smtp@_accept@_queue\ $t$rm{queue mail if more connections}
10580\smtp@_accept@_queue@_per@_connection\ $t$rm{queue if more messages per connection}
10581\smtp@_accept@_reserve\ $t$rm{only reserve hosts if more connections}
10582\smtp@_check@_spool@_space\ $t$rm{from \\SIZE\\ on \\MAIL\\ command}
10583\smtp@_connect@_backlog\ $t$rm{passed to TCP/IP stack}
10584\smtp@_load@_reserve\ $t$rm{SMTP from reserved hosts if load high}
10585\smtp@_reserve@_hosts\ $t$rm{these are the reserve hosts}
10586.endd
10587
10588.section Policy controls
10589.display flow rm
10590.tabs 31
10591\acl@_not@_smtp\ $t$rm{set ACL for non-SMTP messages}
10592\acl@_smtp@_auth\ $t$rm{set ACL for \\AUTH\\}
10593\acl@_smtp@_connect\ $t$rm{set ACL for connection}
10594\acl@_smtp@_data\ $t$rm{set ACL for \\DATA\\}
10595\acl@_smtp@_etrn\ $t$rm{set ACL for \\ETRN\\}
10596\acl@_smtp@_expn\ $t$rm{set ACL for \\EXPN\\}
10597\acl@_smtp@_helo\ $t$rm{set ACL for \\EHLO\\ or \\HELO\\}
10598\acl@_smtp@_mail\ $t$rm{set ACL for \\MAIL\\}
10599\acl@_smtp@_mailauth\ $t$rm{set ACL for \\AUTH\\ on \\MAIL\\ command}
10600\acl@_smtp@_rcpt\ $t$rm{set ACL for \\RCPT\\}
10601\acl@_smtp@_starttls\ $t$rm{set ACL for \\STARTTLS\\}
10602\acl@_smtp@_vrfy\ $t$rm{set ACL for \\VRFY\\}
10603\header@_maxsize\ $t$rm{total size of message header}
10604\header@_line@_maxsize\ $t$rm{individual header line limit}
10605\helo@_accept@_junk@_hosts\ $t$rm{allow syntactic junk from these hosts}
10606\helo@_allow@_chars\ $t$rm{allow illegal chars in \\HELO\\ names}
10607\helo@_lookup@_domains\ $t$rm{lookup hostname for these \\HELO\\ names}
10608\helo@_try@_verify@_hosts\ $t$rm{\\HELO\\ soft-checked for these hosts}
10609\helo@_verify@_hosts\ $t$rm{\\HELO\\ hard-checked for these hosts}
10610\host@_lookup\ $t$rm{host name looked up for these hosts}
10611\host@_lookup@_order\ $t$rm{order of DNS and local name lookups}
10612\host@_reject@_connection\ $t$rm{reject connection from these hosts}
10613\hosts@_treat@_as@_local\ $t$rm{useful in some cluster configurations}
10614\local@_scan@_timeout\ $t$rm{timeout for \*local@_scan()*\}
10615\message@_size@_limit\ $t$rm{for all messages}
10616\percent@_hack@_domains\ $t$rm{recognize %-hack for these domains}
10617.endd
10618
10619.section Callout cache
10620.display flow rm
10621.tabs 31
10622\callout@_domain@_negative@_expire\ $t$rm{timeout for negative domain cache item}
10623\callout@_domain@_positive@_expire\ $t$rm{timeout for positive domain cache item}
10624\callout@_negative@_expire\ $t$rm{timeout for negative address cache item}
10625\callout@_positive@_expire\ $t$rm{timeout for positive address cache item}
10626\callout@_random@_local@_part\ $t$rm{string to use for `random' testing}
10627.endd
10628
10629.section TLS
10630.display flow rm
10631.tabs 31
10632\tls@_advertise@_hosts\ $t$rm{advertise TLS to these hosts}
10633\tls@_certificate\ $t$rm{location of server certificate}
10634.newline
10635.em
10636\tls@_crl\ $t$rm{certificate revocation list}
10637.newline
10638.nem
10639\tls@_dhparam\ $t$rm{DH parameters for server}
10640\tls@_privatekey\ $t$rm{location of server private key}
10641\tls@_remember@_esmtp\ $t$rm{don't reset after starting TLS}
10642.newline
10643.em
10644\tls@_require@_ciphers\ $t$rm{specify acceptable cipers}
10645.newline
10646.nem
10647\tls@_try@_verify@_hosts\ $t$rm{try to verify client certificate}
10648\tls@_verify@_certificates\ $t$rm{expected client certificates}
10649\tls@_verify@_hosts\ $t$rm{insist on client certificate verify}
10650.endd
10651
10652.section Local user handling
10653.display flow rm
10654.tabs 31
10655\finduser@_retries\ $t$rm{useful in NIS environments}
10656\gecos@_name\ $t$rm{used when creating ::Sender::}
10657\gecos@_pattern\ $t$rm{ditto}
10658\max@_username@_length\ $t$rm{for systems that truncate}
10659\unknown@_login\ $t$rm{used when no login name found}
10660\unknown@_username\ $t$rm{ditto}
10661\uucp@_from@_pattern\ $t$rm{for recognizing `From ' lines}
10662\uucp@_from@_sender\ $t$rm{ditto}
10663.endd
10664
10665.section All incoming messages (SMTP and non-SMTP)
10666.display flow rm
10667.tabs 31
10668\header@_maxsize\ $t$rm{total size of message header}
10669\header@_line@_maxsize\ $t$rm{individual header line limit}
10670\message@_size@_limit\ $t$rm{applies to all messages}
10671\percent@_hack@_domains\ $t$rm{recognize %-hack for these domains}
10672\received@_header@_text\ $t$rm{expanded to make ::Received::}
10673\received@_headers@_max\ $t$rm{for mail loop detection}
10674\recipients@_max\ $t$rm{limit per message}
10675\recipients@_max@_reject\ $t$rm{permanently reject excess}
10676.endd
10677
10678
10679.section Non-SMTP incoming messages
10680.display rm
10681.tabs 31
10682\receive@_timeout\ $t$rm{for non-SMTP messages}
10683.endd
10684
10685
10686
10687.section Incoming SMTP messages
10688See also the \*Policy controls*\ section above.
10689.display flow rm
10690.tabs 31
10691\host@_lookup\ $t$rm{host name looked up for these hosts}
10692\host@_lookup@_order\ $t$rm{order of DNS and local name lookups}
10693\recipient@_unqualified@_hosts\ $t$rm{may send unqualified recipients}
10694\rfc1413@_hosts\ $t$rm{make ident calls to these hosts}
10695\rfc1413@_query@_timeout\ $t$rm{zero disables ident calls}
10696\sender@_unqualified@_hosts\ $t$rm{may send unqualified senders}
10697\smtp@_accept@_keepalive\ $t$rm{some TCP/IP magic}
10698\smtp@_accept@_max\ $t$rm{simultaneous incoming connections}
10699\smtp@_accept@_max@_nommail\ $t$rm{non-mail commands}
10700\smtp@_accept@_max@_nonmail@_hosts\ $t$rm{hosts to which the limit applies}
10701\smtp@_accept@_max@_per@_connection\ $t$rm{messages per connection}
10702\smtp@_accept@_max@_per@_host\ $t$rm{connections from one host}
10703\smtp@_accept@_queue\ $t$rm{queue mail if more connections}
10704\smtp@_accept@_queue@_per@_connection\ $t$rm{queue if more messages per connection}
10705\smtp@_accept@_reserve\ $t$rm{only reserve hosts if more connections}
10706.newline
10707.em
10708\smtp@_active@_hostname\ $t$rm{host name to use in messages}
10709.newline
10710.nem
10711\smtp@_banner\ $t$rm{text for welcome banner}
10712\smtp@_check@_spool@_space\ $t$rm{from \\SIZE\\ on \\MAIL\\ command}
10713\smtp@_connect@_backlog\ $t$rm{passed to TCP/IP stack}
10714\smtp@_enforce@_sync\ $t$rm{of SMTP command/responses}
10715\smtp@_etrn@_command\ $t$rm{what to run for \\ETRN\\}
10716\smtp@_etrn@_serialize\ $t$rm{only one at once}
10717\smtp@_load@_reserve\ $t$rm{only reserve hosts if this load}
10718\smtp@_max@_unknown@_commands\ $t$rm{before dropping connection}
10719\smtp@_ratelimit@_hosts\ $t$rm{apply ratelimiting to these hosts}
10720\smtp@_ratelimit@_mail\ $t$rm{ratelimit for \\MAIL\\ commands}
10721\smtp@_ratelimit@_rcpt\ $t$rm{ratelimit for \\RCPT\\ commands}
10722\smtp@_receive@_timeout\ $t$rm{per command or data line}
10723\smtp@_reserve@_hosts\ $t$rm{these are the reserve hosts}
10724\smtp@_return@_error@_details\ $t$rm{give detail on rejections}
10725.endd
10726
10727.section SMTP extensions
10728.display flow rm
10729.tabs 31
10730\accept@_8bitmime\ $t$rm{advertise \\8BITMIME\\}
10731\auth@_advertise@_hosts\ $t$rm{advertise \\AUTH\\ to these hosts}
10732\ignore@_fromline@_hosts\ $t$rm{allow `From ' from these hosts}
10733\ignore@_fromline@_local\ $t$rm{allow `From ' from local SMTP}
10734\pipelining@_advertise@_hosts\ $t$rm{advertise pipelining to these hosts}
10735\tls@_advertise@_hosts\ $t$rm{advertise TLS to these hosts}
10736.endd
10737
10738.section Processing messages
10739.display flow rm
10740.tabs 31
10741\allow@_domain@_literals\ $t$rm{recognize domain literal syntax}
10742\allow@_mx@_to@_ip\ $t$rm{allow MX to point to IP address}
10743\allow@_utf8@_domains\ $t$rm{in addresses}
10744\delivery@_date@_remove\ $t$rm{from incoming messages}
10745\envelope@_to@_remote\ $t$rm{from incoming messages}
10746\extract@_addresses@_remove@_arguments\ $t$rm{affects \-t-\ processing}
10747\headers@_charset\ $t$rm{default for translations}
10748\qualify@_domain\ $t$rm{default for senders}
10749\qualify@_recipient\ $t$rm{default for recipients}
10750\return@_path@_remove\ $t$rm{from incoming messages}
10751\strip@_excess@_angle@_brackets\ $t$rm{in addresses}
10752\strip@_trailing@_dot\ $t$rm{at end of addresses}
10753\untrusted@_set@_sender\ $t$rm{untrusted can set envelope sender}
10754.endd
10755
10756.section System filter
10757.display flow rm
10758.tabs 31
10759\system@_filter\ $t$rm{locate system filter}
10760\system@_filter@_directory@_transport\ $t$rm{transport for delivery to a directory}
10761\system@_filter@_file@_transport\ $t$rm{transport for delivery to a file}
10762\system@_filter@_group\ $t$rm{group for filter running}
10763\system@_filter@_pipe@_transport\ $t$rm{transport for delivery to a pipe}
10764\system@_filter@_reply@_transport\ $t$rm{transport for autoreply delivery}
10765\system@_filter@_user\ $t$rm{user for filter running}
10766.endd
10767
10768.section Routing and delivery
10769.display flow rm
10770.tabs 31
10771\dns@_again@_means@_nonexist\ $t$rm{for broken domains}
10772\dns@_check@_names@_pattern\ $t$rm{pre-DNS syntax check}
10773\dns@_ipv4@_lookup\ $t$rm{only v4 lookup for these domains}
10774\dns@_retrans\ $t$rm{parameter for resolver}
10775\dns@_retry\ $t$rm{parameter for resolver}
10776\hold@_domains\ $t$rm{hold delivery for these domains}
10777\local@_interfaces\ $t$rm{for routing checks}
10778\queue@_domains\ $t$rm{no immediate delivery for these}
10779\queue@_only\ $t$rm{no immediate delivery at all}
10780\queue@_only@_file\ $t$rm{no immediate deliveryif file exists}
10781\queue@_only@_load\ $t$rm{no immediate delivery if load is high}
10782\queue@_only@_override\ $t$rm{allow command line to override}
10783\queue@_run@_in@_order\ $t$rm{order of arrival}
10784\queue@_run@_max\ $t$rm{of simultaneous queue runners}
10785\queue@_smtp@_domains\ $t$rm{no immediate SMTP delivery for these}
10786\remote@_max@_parallel\ $t$rm{parallel SMTP delivery (per message, not overall)}
10787\remote@_sort@_domains\ $t$rm{order of remote deliveries}
10788\retry@_data@_expire\ $t$rm{timeout for retry data}
10789\retry@_interval@_max\ $t$rm{safety net for retry rules}
10790.endd
10791
10792.section Bounce and warning messages
10793.display flow rm
10794.tabs 31
10795\bounce@_message@_file\ $t$rm{content of bounce}
10796\bounce@_message@_text\ $t$rm{content of bounce}
10797\bounce@_return@_body\ $t$rm{include body if returning message}
10798\bounce@_return@_message\ $t$rm{include original message in bounce}
10799\bounce@_return@_size@_limit\ $t$rm{limit on returned message}
10800\bounce@_sender@_authentication\ $t$rm{send authenticated sender with bounce}
10801\errors@_copy\ $t$rm{copy bounce messages}
10802\errors@_reply@_to\ $t$rm{::Reply-to:: in bounces}
10803\delay@_warning\ $t$rm{time schedule}
10804\delay@_warning@_condition\ $t$rm{condition for warning messages}
10805\ignore@_bounce@_errors@_after\ $t$rm{discard undeliverable bounces}
10806\warn@_message@_file\ $t$rm{content of warning message}
10807.endd
10808
10809.set displayflowcheck ~~savedisplayflowcheck
10810
10811.section Alphabetical list of main options
10812.rset SECTalomo "~~chapter.~~section"
10813.if ~~sgcal
10814Those options that undergo string expansion before use are marked with $**$.
10815.fi
10816
10817.startconf
10818
10819.index \\8BITMIME\\
10820.index 8-bit characters
10821.conf accept@_8bitmime boolean false
10822This option causes Exim to send \\8BITMIME\\ in its response to an SMTP
10823\\EHLO\\ command, and to accept the \\BODY=\\ parameter on \\MAIL\\ commands.
10824However, though Exim is 8-bit clean, it is not a protocol converter, and it
10825takes no steps to do anything special with messages received by this route.
10826Consequently, this option is turned off by default.
10827
10828.index ~~ACL||for non-SMTP messages
10829.index non-SMTP messages, ACL for
10830.conf acl@_not@_smtp string$**$ unset
10831This option defines the ACL that is run when a non-SMTP message is on the point
10832of being accepted. See chapter ~~CHAPACL for further details.
10833
10834.index ~~ACL||on SMTP connection
10835.conf acl@_smtp@_connect string$**$ unset
10836This option defines the ACL that is run when an SMTP connection is received.
10837See chapter ~~CHAPACL for further details.
10838
10839.index ~~ACL||setting up for SMTP commands
10840.index \\AUTH\\||ACL for
10841.conf acl@_smtp@_auth string$**$ unset
10842This option defines the ACL that is run when an SMTP \\AUTH\\ command is
10843received. See chapter ~~CHAPACL for further details.
10844
10845.index \\DATA\\, ACL for
10846.conf acl@_smtp@_data string$**$ unset
10847This option defines the ACL that is run after an SMTP \\DATA\\ command has been
10848processed and the message itself has been received, but before the final
10849acknowledgement is sent. See chapter ~~CHAPACL for further details.
10850
10851.index \\ETRN\\||ACL for
10852.conf acl@_smtp@_etrn string$**$ unset
10853This option defines the ACL that is run when an SMTP \\ETRN\\ command is
10854received. See chapter ~~CHAPACL for further details.
10855
10856.index \\EXPN\\||ACL for
10857.conf acl@_smtp@_expn string$**$ unset
10858This option defines the ACL that is run when an SMTP \\EXPN\\ command is
10859received. See chapter ~~CHAPACL for further details.
10860
10861.index \\EHLO\\||ACL for
10862.index \\HELO\\||ACL for
10863.conf acl@_smtp@_helo string$**$ unset
10864This option defines the ACL that is run when an SMTP \\EHLO\\ or \\HELO\\
10865command is received. See chapter ~~CHAPACL for further details.
10866
10867.index \\MAIL\\||ACL for
10868.conf acl@_smtp@_mail string$**$ unset
10869This option defines the ACL that is run when an SMTP \\MAIL\\ command is
10870received. See chapter ~~CHAPACL for further details.
10871
10872.index \\AUTH\\||on \\MAIL\\ command
10873.conf acl@_smtp@_mailauth string$**$ unset
10874This option defines the ACL that is run when there is an \\AUTH\\ parameter on
10875a \\MAIL\\ command. See chapter ~~CHAPACL for details of ACLs, and chapter
10876~~CHAPSMTPAUTH for details of authentication.
10877
10878.index \\RCPT\\||ACL for
10879.conf acl@_smtp@_rcpt string$**$ unset
10880This option defines the ACL that is run when an SMTP \\RCPT\\ command is
10881received. See chapter ~~CHAPACL for further details.
10882
10883.index \\STARTTLS\\, ACL for
10884.conf acl@_smtp@_starttls string$**$ unset
10885This option defines the ACL that is run when an SMTP \\STARTTLS\\ command is
10886received. See chapter ~~CHAPACL for further details.
10887
10888.index \\VRFY\\||ACL for
10889.conf acl@_smtp@_vrfy string$**$ unset
10890This option defines the ACL that is run when an SMTP \\VRFY\\ command is
10891received. See chapter ~~CHAPACL for further details.
10892
10893.conf admin@_groups "string list" unset
10894.index admin user
10895If the current group or any of the supplementary groups of the caller is in
10896this colon-separated list, the caller has admin privileges. If all your system
10897programmers are in a specific group, for example, you can give them all Exim
10898admin privileges by putting that group in \admin@_groups\. However, this does
10899not permit them to read Exim's spool files (whose group owner is the Exim gid).
10900To permit this, you have to add individuals to the Exim group.
10901
10902.conf allow@_domain@_literals boolean false
10903.index domain literal
10904If this option is set, the RFC 2822 domain literal format is permitted in
10905email addresses. The option is not set by default, because the domain literal
10906format is not normally required these days, and few people know about it. It
10907has, however, been exploited by mail abusers.
10908
10909Unfortunately, it seems that some DNS black list maintainers are using this
10910format to report black listing to postmasters. If you want to accept messages
10911addressed to your hosts by IP address, you need to set
10912\allow@_domain@_literals\ true, and also to add \"@@[]"\ to the list of local
10913domains (defined in the named domain list \local@_domains\ in the default
10914configuration). This `magic string' matches the domain literal form of all the
10915local host's IP addresses.
10916
10917.conf allow@_mx@_to@_ip boolean false
10918.index MX record||pointing to IP address
10919It appears that more and more DNS zone administrators are breaking the rules
10920and putting domain names that look like IP addresses on the right hand side of
10921MX records. Exim follows the rules and rejects this, giving an error message
10922that explains the mis-configuration. However, some other MTAs support this
10923practice, so to avoid `Why can't Exim do this?' complaints, \allow@_mx@_to@_ip\
10924exists, in order to enable this heinous activity. It is not recommended, except
10925when you have no other choice.
10926
10927.index domain||UTF-8 characters in
10928.index UTF-8||in domain name
10929.conf allow@_utf8@_domains boolean false
10930Lots of discussion is going on about internationalized domain names. One
10931camp is strongly in favour of just using UTF-8 characters, and it seems
10932that at least two other MTAs permit this. This option allows Exim users to
10933experiment if they wish.
10934
10935If it is set true, Exim's domain parsing function allows valid
10936UTF-8 multicharacters to appear in domain name components, in addition to
10937letters, digits, and hyphens. However, just setting this option is not
10938enough; if you want to look up these domain names in the DNS, you must also
10939adjust the value of \dns@_check@_names@_pattern\ to match the extended form. A
10940suitable setting is:
10941.display asis
10942dns_check_names_pattern = (?i)^(?>(?(1)\.|())[a-z0-9\xc0-\xff]\
10943 (?>[-a-z0-9\x80-\xff]*[a-z0-9\x80-\xbf])?)+$
10944.endd
10945Alternatively, you can just disable this feature by setting
10946.display asis
10947dns_check_names_pattern =
10948.endd
10949That is, set the option to an empty string so that no check is done.
10950
10951.conf auth@_advertise@_hosts "host list$**$" $*$
10952.index authentication||advertising
10953.index \\AUTH\\||advertising
10954If any server authentication mechanisms are configured, Exim advertises them in
10955response to an \\EHLO\\ command only if the calling host matches this list.
10956Otherwise, Exim does not advertise \\AUTH\\.
10957Exim does not accept \\AUTH\\ commands from clients to which it has not
10958advertised the availability of \\AUTH\\. The advertising of individual
10959authentication mechanisms can be controlled by the use of the
10960\server@_advertise@_condition\ generic authenticator option on the individual
10961authenticators. See chapter ~~CHAPSMTPAUTH for further details.
10962
10963Certain mail clients (for example, Netscape) require the user to provide a name
10964and password for authentication if \\AUTH\\ is advertised, even though it may
10965not be needed (the host may accept messages from hosts on its local LAN without
10966authentication, for example). The \auth@_advertise@_hosts\ option can be used
10967to make these clients more friendly by excluding them from the set of hosts to
10968which Exim advertises \\AUTH\\.
10969
10970.index \\AUTH\\||advertising when encrypted
10971If you want to advertise the availability of \\AUTH\\ only when the connection
10972is encrypted using TLS, you can make use of the fact that the value of this
10973option is expanded, with a setting like this:
10974.display asis
10975auth_advertise_hosts = ${if eq{$tls_cipher}{}{}{*}}
10976.endd
10977If \$tls@_cipher$\ is empty, the session is not encrypted, and the result of
10978the expansion is empty, thus matching no hosts. Otherwise, the result of the
10979expansion is $*$, which matches all hosts.
10980
10981.conf auto@_thaw time 0s
10982.index thawing messages
10983.index unfreezing messages
10984If this option is set to a time greater than zero, a queue runner will try a
10985new delivery attempt on any frozen message if this much time has passed since
10986it was frozen. This may result in the message being re-frozen if nothing has
10987changed since the last attempt. It is a way of saying `keep on trying, even
10988though there are big problems'. See also \timeout@_frozen@_after\ and
10989\ignore@_bounce@_errors@_after\.
10990
10991.conf bi@_command string unset
10992.index \-bi-\ option
10993This option supplies the name of a command that is run when Exim is called with
10994the \-bi-\ option (see chapter ~~CHAPcommandline). The string value is just the
10995command name, it is not a complete command line. If an argument is required, it
10996must come from the \-oA-\ command line option.
10997
10998.conf bounce@_message@_file string unset
10999.index bounce message||customizing
11000.index customizing||bounce message
11001This option defines a template file containing paragraphs of text to be used
11002for constructing bounce messages. Details of the file's contents are given in
11003chapter ~~CHAPemsgcust. See also \warn@_message@_file\.
11004
11005.conf bounce@_message@_text string unset
11006When this option is set, its contents are included in the default bounce
11007message immediately after `This message was created automatically by mail
11008delivery software.' It is not used if \bounce@_message@_file\ is set.
11009
11010.index bounce message||including body
11011.conf bounce@_return@_body boolean true
11012This option controls whether the body of an incoming message is included in a
11013bounce message when \bounce@_return@_message\ is true. If it is not set, only
11014the message header is included.
11015
11016.index bounce message||including original
11017.conf bounce@_return@_message boolean true
11018If this option is set false, the original message is not included in bounce
11019messages generated by Exim. See also \bounce@_return@_size@_limit\.
11020
11021.conf bounce@_return@_size@_limit integer 100K
11022.index size||of bounce, limit
11023.index bounce message||size limit
11024.index limit||bounce message size
11025This option sets a limit in bytes on the size of messages that are returned to
11026senders as part of bounce messages when \bounce@_return@_message\ is true. The
11027limit should be less than the value of the global \message@_size@_limit\ and of
11028any \message@_size@_limit\ settings on transports, to allow for the bounce text
11029that Exim generates. If this option is set to zero there is no limit.
11030
11031When the body of any message that is to be included in a bounce message is
11032greater than the limit, it is truncated, and a comment pointing this out is
11033added at the top. The actual cutoff may be greater than the value given, owing
11034to the use of buffering for transferring the message in chunks (typically 8K in
11035size). The idea is to save bandwidth on those undeliverable 15-megabyte
11036messages.
11037
11038.index bounce message||sender authentication
11039.index authentication||bounce message
11040.index \\AUTH\\||on bounce message
11041.conf bounce@_sender@_authentication string unset
11042This option provides an authenticated sender address that is sent with any
11043bounce messages generated by Exim that are sent over an authenticated SMTP
11044connection. A typical setting might be:
11045.display asis
11046bounce_sender_authentication = mailer-daemon@my.domain.example
11047.endd
11048which would cause bounce messages to be sent using the SMTP command:
11049.display asis
11050MAIL FROM:<> AUTH=mailer-daemon@my.domain.example
11051.endd
11052The value of \bounce@_sender@_authentication\ must always be a complete email
11053address.
11054
11055.index caching||callout, timeouts
11056.index callout||caching timeouts
11057.conf callout@_domain@_negative@_expire time 3h
11058This option specifies the expiry time for negative callout cache data for a
11059domain. See section ~~SECTcallver for details of callout verification, and
11060section ~~SECTcallvercache for details of the caching.
11061
11062.conf callout@_domain@_positive@_expire time 7d
11063This option specifies the expiry time for positive callout cache data for a
11064domain. See section ~~SECTcallver for details of callout verification, and
11065section ~~SECTcallvercache for details of the caching.
11066
11067.conf callout@_negative@_expire time 2h
11068This option specifies the expiry time for negative callout cache data for an
11069address. See section ~~SECTcallver for details of callout verification, and
11070section ~~SECTcallvercache for details of the caching.
11071
11072.conf callout@_positive@_expire time 24h
11073This option specifies the expiry time for positive callout cache data for an
11074address. See section ~~SECTcallver for details of callout verification, and
11075section ~~SECTcallvercache for details of the caching.
11076
11077.conf callout@_random@_local@_part string$**$ "see below"
11078This option defines the `random' local part that can be used as part of callout
11079verification. The default value is
11080.display asis
11081$primary_host_name-$tod_epoch-testing
11082.endd
11083See section ~~CALLaddparcall for details of how this value is used.
11084
11085.conf check@_log@_inodes integer 0
11086See \check@_spool@_space\ below.
11087
11088.conf check@_log@_space integer 0
11089See \check@_spool@_space\ below.
11090
11091.conf check@_spool@_inodes integer 0
11092See \check@_spool@_space\ below.
11093
11094.conf check@_spool@_space integer 0
11095.index checking disk space
11096.index disk space, checking
11097.index spool directory||checking space
11098The four \check@_...\ options allow for checking of disk resources before a
11099message is accepted. \check@_spool@_space\ and \check@_spool@_inodes\ check the
11100spool partition if either value is greater than zero, for example:
11101.display asis
11102check_spool_space = 10M
11103check_spool_inodes = 100
11104.endd
11105The spool partition is the one which contains the directory defined by
11106\\SPOOL@_DIRECTORY\\ in \(Local/Makefile)\. It is used for holding messages in
11107transit.
11108
11109\check@_log@_space\ and \check@_log@_inodes\ check the partition in which log
11110files are written if either is greater than zero. These should be set only if
11111\log@_file@_path\ and \spool@_directory\ refer to different partitions.
11112
11113If there is less space or fewer inodes than requested, Exim refuses to accept
11114incoming mail. In the case of SMTP input this is done by giving a 452 temporary
11115error response to the \\MAIL\\ command. If ESMTP is in use and there was a
11116\\SIZE\\ parameter on the \\MAIL\\ command, its value is added to the
11117\check@_spool@_space\ value, and the check is performed even if
11118\check@_spool@_space\ is zero, unless \no@_smtp@_check@_spool@_space\ is set.
11119
11120The values for \check@_spool@_space\ and \check@_log@_space\ are held as a
11121number of kilobytes. If a non-multiple of 1024 is specified, it is rounded up.
11122
11123For non-SMTP input and for batched SMTP input, the test is done at start-up; on
11124failure a message is written to stderr and Exim exits with a non-zero code, as
11125it obviously cannot send an error message of any kind.
11126
11127.index port||for daemon
11128.index TCP/IP||setting listening ports
11129.conf daemon@_smtp@_ports string "$tt{smtp}"
11130This option specifies one or more default SMTP ports on which the Exim daemon
11131listens. See chapter ~~CHAPinterfaces for details of how it is used. For
11132backward compatibility, \daemon@_smtp@_port\ (singular) is a synonym.
11133
11134.conf delay@_warning "time list" 24h
11135.index warning of delay
11136.index delay warning, specifying
11137When a message is delayed, Exim sends a warning message to the sender at
11138intervals specified by this option. If it is set to a zero, no warnings are
11139sent. The data is a colon-separated list of times after which to send warning
11140messages. Up to 10 times may be given. If a message has been on the queue for
11141longer than the last time, the last interval between the times is used to
11142compute subsequent warning times. For example, with
11143.display asis
11144delay_warning = 4h:8h:24h
11145.endd
11146the first message is sent after 4 hours, the second after 8 hours, and
11147the third one after 24 hours. After that, messages are sent every 16 hours,
11148because that is the interval between the last two times on the list. If you set
11149just one time, it specifies the repeat interval. For example, with:
11150.display asis
11151delay_warning = 6h
11152.endd
11153messages are repeated every six hours. To stop warnings after a given time, set
11154a very large time at the end of the list. For example:
11155.display asis
11156delay_warning = 2h:12h:99d
11157.endd
11158
11159.conf delay@_warning@_condition string$**$ "see below"
11160The string is expanded at the time a warning message might be sent. If all the
11161deferred addresses have the same domain, it is set in \$domain$\ during the
11162expansion. Otherwise \$domain$\ is empty. If the result of the expansion is a
11163forced failure, an empty string, or a string matching any of `0', `no' or
11164`false' (the comparison being done caselessly) then the warning message is not
11165sent. The default is
11166.display asis
11167delay_warning_condition = \
11168 ${if match{$h_precedence:}{(?i)bulk|list|junk}{no}{yes}}
11169.endd
11170which suppresses the sending of warnings about messages that have `bulk',
11171`list' or `junk' in a ::Precedence:: header.
11172
11173.index unprivileged delivery
11174.index delivery||unprivileged
11175.conf deliver@_drop@_privilege boolean false
11176If this option is set true, Exim drops its root privilege at the start of a
11177delivery process, and runs as the Exim user throughout. This severely restricts
11178the kinds of local delivery that are possible, but is viable in certain types
11179of configuration. There is a discussion about the use of root privilege in
11180chapter ~~CHAPsecurity.
11181
11182.index load average
11183.index queue runner||abandoning
11184.conf deliver@_queue@_load@_max fixed-point unset
11185When this option is set, a queue run is abandoned if the system load average
11186becomes greater than the value of the option. The option has no effect on
11187ancient operating systems on which Exim cannot determine the load average.
11188See also \queue@_only@_load\ and \smtp@_load@_reserve\.
11189
11190.conf delivery@_date@_remove boolean true
11191.index ::Delivery-date:: header line
11192Exim's transports have an option for adding a ::Delivery-date:: header to a
11193message when it is delivered -- in exactly the same way as ::Return-path:: is
11194handled. ::Delivery-date:: records the actual time of delivery. Such headers
11195should not be present in incoming messages, and this option causes them to be
11196removed at the time the message is received, to avoid any problems that might
11197occur when a delivered message is subsequently sent on to some other recipient.
11198
11199.index DNS||`try again' response, overriding
11200.conf dns@_again@_means@_nonexist "domain list$**$" unset
11201DNS lookups give a `try again' response for the DNS errors `non-authoritative
11202host not found' and `\\SERVERFAIL\\'. This can cause Exim to keep trying to
11203deliver a message, or to give repeated temporary errors to incoming mail.
11204Sometimes the effect is caused by a badly set up name server and may persist
11205for a long time. If a domain which exhibits this problem matches anything in
11206\dns__again__means__nonexist\, it is treated as if it did not exist. This
11207option should be used with care.
11208.em
11209You can make it apply to reverse lookups by a setting such as this:
11210.display asis
11211dns_again_means_nonexist = *.in-addr.arpa
11212.endd
11213.nem
11214
11215.index DNS||pre-check of name syntax
11216.conf dns@_check@_names@_pattern string "see below"
11217When this option is set to a non-empty string, it causes Exim to check domain
11218names for illegal characters before handing them to the DNS resolver, because
11219some resolvers give temporary errors for malformed names. If a domain name
11220contains any illegal characters, a `not found' result is forced, and the
11221resolver is not called. The check is done by matching the domain name against a
11222regular expression, which is the value of this option. The default pattern is
11223.display asis
11224dns_check_names_pattern = \
11225 (?i)^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$
11226.endd
11227which permits only letters, digits, and hyphens in components, but they may not
11228start or end with a hyphen.
11229If you set \allow@_utf8@_domains\, you must modify this pattern, or set the
11230option to an empty string.
11231
11232.conf dns@_ipv4@_lookup "domain list$**$" unset
11233.index IPv6||DNS lookup for AAAA records
11234.index DNS||IPv6 lookup for AAAA records
11235When Exim is compiled with IPv6 support, it looks for IPv6 address records
11236(AAAA and, if configured, A6) as well as IPv4 address records when trying to
11237find IP addresses for hosts, unless the host's domain matches this list.
11238
11239This is a fudge to help with name servers that give big delays or otherwise do
11240not work for the new IPv6 record types. If Exim is handed an IPv6 address
11241record as a result of an MX lookup, it always recognizes it, and may as a
11242result make an outgoing IPv6 connection. All this option does is to make Exim
11243look only for IPv4-style A records when it needs to find an IP address for a
11244host name. In due course, when the world's name servers have all been upgraded,
11245there should be no need for this option.
11246
11247.conf dns@_retrans time 0s
11248.index DNS||resolver options
11249The options \dns@_retrans\ and \dns@_retry\ can be used to set the
11250retransmission and retry parameters for DNS lookups. Values of zero (the
11251defaults) leave the system default settings unchanged. The first value is the
11252time between retries, and the second is the number of retries. It isn't
11253totally clear exactly how these settings affect the total time a DNS lookup may
11254take. I haven't found any documentation about timeouts on DNS lookups; these
11255parameter values are available in the external resolver interface structure,
11256but nowhere does it seem to describe how they are used or what you might want
11257to set in them.
11258
11259.conf dns@_retry integer 0
11260See \dns@_retrans\ above.
11261
11262.conf drop@_cr boolean false
11263This is an obsolete option that is now a no-op. It used to affect the way Exim
11264handled CR and LF characters in incoming messages. What happens now is
11265described in section ~~SECTlineendings.
11266
11267.conf envelope@_to@_remove boolean true
11268.index ::Envelope-to:: header line
11269Exim's transports have an option for adding an ::Envelope-to:: header to a
11270message when it is delivered -- in exactly the same way as ::Return-path:: is
11271handled. ::Envelope-to:: records the original recipient address from the
11272messages's envelope that caused the delivery to happen. Such headers should not
11273be present in incoming messages, and this option causes them to be removed at
11274the time the message is received, to avoid any problems that might occur when a
11275delivered message is subsequently sent on to some other recipient.
11276
11277.conf errors@_copy "string list$**$" unset
11278.index bounce message||copy to other address
11279.index copy of bounce message
11280Setting this option causes Exim to send bcc copies of bounce messages that it
11281generates to other addresses. \**Note**\: this does not apply to bounce messages
11282coming from elsewhere. The value of the option is a colon-separated list of
11283items. Each item consists of a pattern, terminated by white space, followed by
11284a comma-separated list of email addresses. If a pattern contains spaces, it
11285must be enclosed in double quotes.
11286
11287Each pattern is processed in the same way as a single item in an address list
11288(see section ~~SECTaddresslist). When a pattern matches the recipient of the
11289bounce message, the message is copied to the addresses on the list. The items
11290are scanned in order, and once a matching one is found, no further items are
11291examined. For example:
11292.display asis
11293errors_copy = spqr@mydomain postmaster@mydomain.example :\
11294 rqps@mydomain hostmaster@mydomain.example,\
11295 postmaster@mydomain.example
11296.endd
11297The address list is expanded before use. The expansion variables
11298\$local@_part$\ and \$domain$\ are set from the original recipient of the error
11299message, and if there was any wildcard matching in the pattern, the expansion
11300.index numerical variables (\$1$\, \$2$\, etc)||in \errors@_copy\
11301variables \$0$\, \$1$\, etc. are set in the normal way.
11302
11303.conf errors@_reply@_to string unset
11304.index bounce message||::Reply-to:: in
11305Exim's bounce and delivery warning messages contain the header line
11306.display
11307From: Mail Delivery System @<Mailer-Daemon@@<<qualify-domain>>@>
11308.endd
11309where <<qualify-domain>> is the value of the \qualify@_domain\ option.
11310Experience shows that people reply to bounce messages. If the
11311\errors@_reply@_to\ option is set, a ::Reply-To:: header is added to bounce and
11312warning messages. For example:
11313.display asis
11314errors_reply_to = postmaster@my.domain.example
11315.endd
11316The value of the option is not expanded. It must specify a valid RFC 2822
11317address.
11318
11319.conf exim@_group string "compile-time configured"
11320.index gid (group id)||Exim's own
11321.index Exim group
11322This option changes the gid under which Exim runs when it gives up root
11323privilege. The default value is compiled into the binary. The value of this
11324option is used only when \exim@_user\ is also set. Unless it consists entirely
11325of digits, the string is looked up using \*getgrnam()*\, and failure causes a
11326configuration error. See chapter ~~CHAPsecurity for a discussion of security
11327issues.
11328
11329.conf exim@_path string "see below"
11330.index Exim binary, path name
11331This option specifies the path name of the Exim binary, which is used when Exim
11332needs to re-exec itself. The default is set up to point to the file \*exim*\ in
11333the directory configured at compile time by the \\BIN@_DIRECTORY\\ setting. It
11334is necessary to change \exim@_path\ if, exceptionally, Exim is run from some
11335other place.
11336\**Warning**\: Do not use a macro to define the value of this option, because
11337you will break those Exim utilities that scan the configuration file to find
11338where the binary is. (They then use the \-bP-\ option to extract option
11339settings such as the value of \spool@_directory\.)
11340
11341.conf exim@_user string "compile-time configured"
11342.index uid (user id)||Exim's own
11343.index Exim user
11344This option changes the uid under which Exim runs when it gives up root
11345privilege. The default value is compiled into the binary. Ownership of the run
11346time configuration file and the use of the \-C-\ and \-D-\ command line options
11347is checked against the values in the binary, not what is set here.
11348
11349Unless it consists entirely of digits, the string is looked up using
11350\*getpwnam()*\, and failure causes a configuration error. If \exim@_group\ is
11351not also supplied, the gid is taken from the result of \*getpwnam()*\ if it is
11352used. See chapter ~~CHAPsecurity for a discussion of security issues.
11353
11354.conf extra@_local@_interfaces "string list" unset
11355.index
11356This option defines network interfaces that are to be considered local when
11357routing, but which are not used for listening by the daemon. See section
11358~~SECTreclocipadd for details.
11359
11360.conf extract@_addresses@_remove@_arguments boolean true
11361.index \-t-\ option
11362.index command line||addresses with \-t-\
11363.index Sendmail compatibility||\-t-\ option
11364According to some Sendmail documentation (Sun, IRIX, HP-UX), if any addresses
11365are present on the command line when the \-t-\ option is used to build an
11366envelope from a message's ::To::, ::Cc:: and ::Bcc:: headers, the command line
11367addresses are removed from the recipients list. This is also how Smail behaves.
11368However, other Sendmail documentation (the O'Reilly book) states that command
11369line addresses are added to those obtained from the header lines. When
11370\extract@_addresses@_remove@_arguments\ is true (the default), Exim subtracts
11371argument headers. If it is set false, Exim adds rather than removes argument
11372addresses.
11373
11374.conf finduser@_retries integer 0
11375.index NIS, looking up users, retrying
11376On systems running NIS or other schemes in which user and group information is
11377distributed from a remote system, there can be times when \*getpwnam()*\ and
11378related functions fail, even when given valid data, because things time out.
11379Unfortunately these failures cannot be distinguished from genuine `not found'
11380errors. If \finduser@_retries\ is set greater than zero, Exim will try that
11381many extra times to find a user or a group, waiting for one second between
11382retries.
11383
11384.conf freeze@_tell "string list, comma separated" unset
11385.index freezing messages||sending a message when freezing
11386On encountering certain errors, or when configured to do so in a system filter,
11387or in an ACL,
11388Exim freezes a message. This means that no further delivery attempts take place
11389until an administrator (or the \auto@_thaw\ feature) thaws the message. If
11390\freeze@_tell\ is set, Exim generates a warning message whenever it freezes
11391something, unless the message it is freezing is a
11392locally-generated
11393bounce message. (Without this exception there is the possibility of looping.)
11394The warning message is sent to the addresses supplied as the comma-separated
11395value of this option. If several of the message's addresses cause freezing,
11396only a single message is sent.
11397If the freezing was automatic, the reason(s) for freezing can be found in the
11398message log. If you configure freezing in a filter or ACL, you must arrange for
11399any logging that you require.
11400
11401.conf gecos@_name string$**$ unset
11402.index HP-UX
11403.index `gecos' field, parsing
11404Some operating systems, notably HP-UX, use the `gecos' field in the system
11405password file to hold other information in addition to users' real names. Exim
11406looks up this field for use when it is creating ::Sender:: or ::From:: headers.
11407If either \gecos@_pattern\ or \gecos@_name\ are unset, the contents of the
11408field are used unchanged, except that, if an ampersand is encountered, it is
11409replaced by the user's login name with the first character forced to
11410upper case, since this is a convention that is observed on many systems.
11411
11412When these options are set, \gecos@_pattern\ is treated as a regular expression
11413that is to be applied to the field (again with & replaced by the login name),
11414and if it matches, \gecos@_name\ is expanded and used as the user's name.
11415.index numerical variables (\$1$\, \$2$\, etc)||in \gecos@_name\
11416Numeric variables such as \$1$\, \$2$\, etc. can be used in the expansion to
11417pick up sub-fields that were matched by the pattern. In HP-UX, where the user's
11418name terminates at the first comma, the following can be used:
11419.display asis
11420gecos_pattern = ([^,]*)
11421gecos_name = $1
11422.endd
11423
11424.conf gecos@_pattern string unset
11425See \gecos@_name\ above.
11426
11427.conf headers@_charset string "see below"
11428This option sets a default character set for translating from encoded MIME
11429`words' in header lines, when referenced by an \$h@_xxx$\ expansion item. The
11430default is the value of \\HEADERS@_CHARSET\\ in \(Local/Makefile)\. The
11431ultimate default is ISO-8859-1. For more details see the description of header
11432insertions in section ~~SECTexpansionitems.
11433
11434
11435.conf header@_maxsize integer "see below"
11436.index header section||maximum size of
11437.index limit||size of message header section
11438This option controls the overall maximum size of a message's header
11439section. The default is the value of \\HEADER@_MAXSIZE\\ in
11440\(Local/Makefile)\; the default for that is 1M. Messages with larger header
11441sections are rejected.
11442
11443.conf header@_line@_maxsize integer 0
11444.index header lines||maximum size of
11445.index limit||size of one header line
11446This option limits the length of any individual header line in a message, after
11447all the continuations have been joined together. Messages with individual
11448header lines that are longer than the limit are rejected. The default value of
11449zero means `no limit'.
11450
11451
11452
11453.conf helo@_accept@_junk@_hosts "host list$**$" unset
11454.index \\HELO\\||accepting junk data
11455.index \\EHLO\\||accepting junk data
11456Exim checks the syntax of \\HELO\\ and \\EHLO\\ commands for incoming SMTP
11457mail, and gives an error response for invalid data. Unfortunately, there are
11458some SMTP clients that send syntactic junk. They can be accommodated by setting
11459this option. Note that this is a syntax check only. See \helo@_verify@_hosts\
11460if you want to do semantic checking.
11461See also \helo@_allow@_chars\ for a way of extending the permitted character
11462set.
11463
11464.conf helo@_allow@_chars string unset
11465.index \\HELO\\||underscores in
11466.index \\EHLO\\||underscores in
11467.index underscore in \\EHLO\\/\\HELO\\
11468This option can be set to a string of rogue characters that are permitted in
11469all \\EHLO\\ and \\HELO\\ names in addition to the standard letters, digits,
11470hyphens, and dots. If you really must allow underscores, you can set
11471.display asis
11472helo_allow_chars = _
11473.endd
11474Note that the value is one string, not a list.
11475
11476.conf helo@_lookup@_domains "domain list$**$" "$tt{@@:@@[]}"
11477.index \\HELO\\||forcing reverse lookup
11478.index \\EHLO\\||forcing reverse lookup
11479If the domain given by a client in a \\HELO\\ or \\EHLO\\ command matches this
11480list, a reverse lookup is done in order to establish the host's true name. The
11481default forces a lookup if the client host gives the server's name or any of
11482its IP addresses (in brackets), something that broken clients have been seen to
11483do.
11484
11485.conf helo@_try@_verify@_hosts "host list$**$" unset
11486.index \\HELO\\||verifying, optional
11487.index \\EHLO\\||verifying, optional
11488The RFCs mandate that a server must not reject a message because it doesn't
11489like the \\HELO\\ or \\EHLO\\ command. By default, Exim just checks the syntax
11490of these commands (see \helo__accept__junk__hosts\ and \helo@_allow@_chars\
11491above). However, some sites like to be stricter. If the calling host matches
11492\helo@_try@_verify@_hosts\, Exim checks that the host name given in the \\HELO\\
11493or \\EHLO\\ command either:
11494.numberpars $.
11495is an IP literal matching the calling address of the host (the RFCs
11496specifically allow this), or
11497.nextp
11498.index DNS||reverse lookup
11499.index reverse DNS lookup
11500matches the host name that Exim obtains by doing a reverse lookup of the
11501calling host address, or
11502.nextp
11503when looked up using \*gethostbyname()*\ (or \*getipnodebyname()*\ when
11504available) yields the calling host address.
11505.endp
11506However, the \\EHLO\\ or \\HELO\\ command is not rejected if any of the checks
11507fail. Processing continues, but the result of the check is remembered, and can
11508be detected later in an ACL by the \"verify = helo"\ condition. If you want
11509verification failure to cause rejection of \\EHLO\\ or \\HELO\\, use
11510\helo@_verify@_hosts\ instead.
11511
11512
11513.conf helo@_verify@_hosts "host list$**$" unset
11514.index \\HELO\\||verifying, mandatory
11515.index \\EHLO\\||verifying, mandatory
11516For hosts that match this option, Exim checks the host name given in the
11517\\HELO\\ or \\EHLO\\ in the same way as for \helo@_try@_verify@_hosts\. If the
11518check fails, the \\HELO\\ or \\EHLO\\ command is rejected with a 550 error, and
11519entries are written to the main and reject logs. If a \\MAIL\\ command is
11520received before \\EHLO\\ or \\HELO\\, it is rejected with a
11521503
11522error.
11523
11524.conf hold@_domains "domain list$**$" unset
11525.index domain||delaying delivery
11526.index delivery||delaying certain domains
11527This option allows mail for particular domains to be held on the queue
11528manually. The option is overridden if a message delivery is forced with the
11529\-M-\, \-qf-\, \-Rf-\ or \-Sf-\ options, and also while testing or verifying
11530addresses using \-bt-\ or \-bv-\. Otherwise, if a domain matches an item in
11531\hold@_domains\, no routing or delivery for that address is done, and it is
11532deferred every time the message is looked at.
11533
11534This option is intended as a temporary operational measure for delaying the
11535delivery of mail while some problem is being sorted out, or some new
11536configuration tested. If you just want to delay the processing of some
11537domains until a queue run occurs, you should use \queue@_domains\ or
11538\queue@_smtp@_domains\, not \hold@_domains\.
11539
11540A setting of \hold@_domains\ does not override Exim's code for removing
11541messages from the queue if they have been there longer than the longest retry
11542time in any retry rule. If you want to hold messages for longer than the normal
11543retry times, insert a dummy retry rule with a long retry time.
11544
11545.conf host@_lookup "host list$**$" unset
11546.index host||name lookup, forcing
11547Exim does not look up the name of a calling host from its IP address unless it
11548is required to compare against some host list, or the host matches
11549\helo@_try@_verify@_hosts\ or \helo@_verify@_hosts\, or the host matches this
11550option (which normally contains IP addresses rather than host names). The
11551default configuration file contains
11552.display asis
11553host_lookup = *
11554.endd
11555which causes a lookup to happen for all hosts. If the expense of these lookups
11556is felt to be too great, the setting can be changed or removed.
11557
11558After a successful reverse lookup, Exim does a forward lookup on the name it
11559has obtained, to verify that it yields the IP address that it started with. If
11560this check fails, Exim behaves as if the name lookup failed.
11561
11562After any kind of failure, the host name (in \$sender@_host@_name$\) remains
11563unset, and \$host@_lookup@_failed$\ is set to the string `1'. See also
11564\dns@_again@_means@_nonexist\, \helo__lookup__domains\, and \"verify =
11565reverse@_host@_lookup"\ in ACLs.
11566
11567.conf host@_lookup@_order "string list" $tt{bydns:byaddr}
11568This option specifies the order of different lookup methods when Exim is trying
11569to find a host name from an IP address. The default is to do a DNS lookup
11570first, and then to try a local lookup (using \*gethostbyaddr()*\ or equivalent)
11571if that fails. You can change the order of these lookups, or omit one entirely,
11572if you want.
11573
11574\**Warning**\: the `byaddr' method does not always yield aliases when there are
11575multiple PTR records in the DNS and the IP address is not listed in
11576\(/etc/hosts)\. Different operating systems give different results in this
11577case. That is why the default tries a DNS lookup first.
11578
11579
11580.conf host@_reject@_connection "host list$**$" unset
11581.index host||rejecting connections from
11582If this option is set, incoming SMTP calls from the hosts listed are rejected
11583as soon as the connection is made.
11584This option is obsolete, and retained only for backward compatibility, because
11585nowadays the ACL specified by \acl@_smtp@_connect\ can also reject incoming
11586connections immediately.
11587
11588The ability to give an immediate rejection (either by this option or using an
11589ACL) is provided for use in unusual cases. Many hosts will just try again,
11590sometimes without much delay. Normally, it is better to use an ACL to reject
11591incoming messages at a later stage, such as after \\RCPT\\ commands. See
11592chapter ~~CHAPACL.
11593
11594.conf hosts@_treat@_as@_local "domain list$**$" unset
11595.index local host||domains treated as
11596.index host||treated as local
11597If this option is set, any host names that match the domain list are treated as
11598if they were the local host when Exim is scanning host lists obtained from MX
11599records
11600or other sources. Note that the value of this option is a domain list, not a
11601host list, because it is always used to check host names, not IP addresses.
11602
11603This option also applies when Exim is matching the special items
11604\"@@mx@_any"\, \"@@mx@_primary"\, and \"@@mx@_secondary"\ in a domain list (see
11605section ~~SECTdomainlist), and when checking the \hosts\ option in the \%smtp%\
11606transport for the local host (see the \allow@_localhost\ option in that
11607transport).
11608See also \local@_interfaces\, \extra@_local@_interfaces\, and chapter
11609~~CHAPinterfaces, which contains a discussion about local network interfaces
11610and recognising the local host.
11611
11612.conf ignore@_bounce@_errors@_after time 10w
11613.index bounce message||discarding
11614.index discarding bounce message
11615This option affects the processing of bounce messages that cannot be delivered,
11616that is, those that suffer a permanent delivery failure. (Bounce messages that
11617suffer temporary delivery failures are of course retried in the usual way.)
11618
11619After a permanent delivery failure, bounce messages are frozen,
11620because there is no sender to whom they can be returned. When a frozen bounce
11621message has been on the queue for more than the given time, it is unfrozen at
11622the next queue run, and a further delivery is attempted. If delivery fails
11623again, the bounce message is discarded. This makes it possible to keep failed
11624bounce messages around for a shorter time than the normal maximum retry time
11625for frozen messages. For example,
11626.display asis
11627ignore_bounce_errors_after = 12h
11628.endd
11629retries failed bounce message deliveries after 12 hours, discarding any further
11630failures. If the value of this option is set to a zero time period, bounce
11631failures are discarded immediately. Setting a very long time (as in the default
11632value) has the effect of disabling this option. For ways of automatically
11633dealing with other kinds of frozen message, see \auto@_thaw\ and
11634\timeout@_frozen@_after\.
11635
11636.conf ignore@_fromline@_hosts "host list$**$" unset
11637.index `From' line
11638.index UUCP||`From' line
11639Some broken SMTP clients insist on sending a UUCP-like `From' line before the
11640headers of a message. By default this is treated as the start of the message's
11641body, which means that any following headers are not recognized as such. Exim
11642can be made to ignore it by setting \ignore@_fromline@_hosts\ to match those
11643hosts that insist on sending it. If the sender is actually a local process
11644rather than a remote host, and is using \-bs-\ to inject the messages,
11645\ignore__fromline__local\ must be set to achieve this effect.
11646
11647.conf ignore@_fromline@_local boolean false
11648See \ignore@_fromline@_hosts\ above.
11649
11650.conf keep@_malformed time 4d
11651This option specifies the length of time to keep messages whose spool files
11652have been corrupted in some way. This should, of course, never happen. At the
11653next attempt to deliver such a message, it gets removed. The incident is
11654logged.
11655
11656.conf ldap@_default@_servers "string list" unset
11657.index LDAP||default servers
11658This option provides a list of LDAP servers which are tried in turn when an
11659LDAP query does not contain a server. See section ~~SECTforldaque for details
11660of LDAP queries. This option is available only when Exim has been built with
11661LDAP support.
11662
11663.conf ldap@_version integer unset
11664.index LDAP||protocol version, forcing
11665This option can be used to force Exim to set a specific protocol version for
11666LDAP. If it option is unset, it is shown by the \-bP-\ command line option as
11667-1. When this is the case, the default is 3 if \\LDAP@_VERSION3\\ is defined in
11668the LDAP headers; otherwise it is 2. This option is available only when Exim
11669has been built with LDAP support.
11670
11671
11672.conf local@_from@_check boolean true
11673.index ::Sender:: header line||disabling addition of
11674.index ::From:: header line||disabling checking of
11675When a message is submitted locally (that is, not over a TCP/IP connection) by
11676an untrusted user, Exim removes any existing ::Sender:: header line, and checks
11677that the ::From:: header line matches the login of the calling user. You can
11678use \local@_from@_prefix\ and \local@_from@_suffix\ to permit affixes on the
11679local part. If the ::From:: header line does not match, Exim adds a ::Sender::
11680header with an address constructed from the calling user's login and the
11681default qualify domain.
11682
11683If \local@_from@_check\ is set false, the ::From:: header check is disabled,
11684and no ::Sender:: header is ever added. If, in addition, you want to retain
11685::Sender:: header lines supplied by untrusted users, you must also set
11686\local@_sender@_retain\ to be true.
11687
11688.index envelope sender
11689These options affect only the header lines in the message. The envelope sender
11690is still forced to be the login id at the qualify domain unless
11691\untrusted@_set@_sender\ permits the user to supply an envelope sender.
11692Section ~~SECTthesenhea has more details about ::Sender:: processing.
11693
11694
11695.conf local@_from@_prefix string unset
11696When Exim checks the ::From:: header line of locally submitted messages for
11697matching the login id (see \local@_from@_check\ above), it can be configured to
11698ignore certain prefixes and suffixes in the local part of the address. This is
11699done by setting \local@_from@_prefix\ and/or \local@_from@_suffix\ to
11700appropriate lists, in the same form as the \local@_part@_prefix\ and
11701\local@_part@_suffix\ router options (see chapter ~~CHAProutergeneric). For
11702example, if
11703.display asis
11704local_from_prefix = *-
11705.endd
11706is set, a ::From:: line containing
11707.display asis
11708From: anything-user@your.domain.example
11709.endd
11710will not cause a ::Sender:: header to be added if \*user@@your.domain.example*\
11711matches the actual sender address that is constructed from the login name and
11712qualify domain.
11713
11714.conf local@_from@_suffix string unset
11715See \local@_from@_prefix\ above.
11716
11717.conf local@_interfaces "string list" "see below"
11718This option controls which network interfaces are used by the daemon for
11719listening; they are also used to identify the local host when routing. Chapter
11720~~CHAPinterfaces contains a full description of this option and the related
11721options \extra@_local@_interfaces\ and \hosts@_treat@_as@_local\. The default
11722value for \local@_interfaces\ is
11723.display asis
11724local_interfaces = 0.0.0.0
11725.endd
11726when Exim is built without IPv6 support; otherwise it is
11727.display asis
11728local_interfaces = <; ::0 ; 0.0.0.0
11729.endd
11730
11731.conf local@_scan@_timeout time 5m
11732.index timeout||for \*local@_scan()*\ function
11733.index \*local@_scan()*\ function||timeout
11734This timeout applies to the \*local@_scan()*\ function (see chapter
11735~~CHAPlocalscan). Zero means `no timeout'. If the timeout is exceeded, the
11736incoming message is rejected with a temporary error if it is an SMTP message.
11737For a non-SMTP message, the message is dropped and Exim ends with a non-zero
11738code. The incident is logged on the main and reject logs.
11739
11740
11741.conf local@_sender@_retain boolean false
11742.index ::Sender:: header line||retaining from local submission
11743When a message is submitted locally (that is, not over a TCP/IP connection) by
11744an untrusted user, Exim removes any existing ::Sender:: header line. If you
11745do not want this to happen, you must set \local@_sender@_retain\, and you must
11746also set \local@_from@_check\ to be false (Exim will complain if you do not).
11747Section ~~SECTthesenhea has more details about ::Sender:: processing.
11748
11749
11750
11751.conf localhost@_number string$**$ unset
11752.index host||locally unique number for
11753.index message||ids, with multiple hosts
11754Exim's message ids are normally unique only within the local host. If
11755uniqueness among a set of hosts is required, each host must set a different
11756value for the \localhost@_number\ option. The string is expanded immediately
11757after reading the configuration file (so that a number can be computed from the
11758host name, for example) and the result of the expansion must be a number in the
11759range 0--16 (or 0--10 on operating systems with case-insensitive file systems).
11760This is available in subsequent string expansions via the variable
11761\$localhost@_number$\. When \localhost@_number is set\, the final two
11762characters of the message id, instead of just being a fractional part of the
11763time, are computed from the time and the local host number as described in
11764section ~~SECTmessiden.
11765
11766
11767.conf log@_file@_path "string list$**$" "set at compile time"
11768.index log||file path for
11769This option sets the path which is used to determine the names of Exim's log
11770files, or indicates that logging is to be to syslog, or both. It is expanded
11771when Exim is entered, so it can, for example, contain a reference to the host
11772name. If no specific path is set for the log files at compile or run time, they
11773are written in a sub-directory called \(log)\ in Exim's spool directory.
11774Chapter ~~CHAPlog contains further details about Exim's logging, and section
11775~~SECTwhelogwri describes how the contents of \log@_file@_path\ are used. If
11776this string is fixed at your installation (contains no expansion variables) it
11777is recommended that you do not set this option in the configuration file, but
11778instead supply the path using \\LOG@_FILE@_PATH\\ in \(Local/Makefile)\ so that
11779it is available to Exim for logging errors detected early on -- in particular,
11780failure to read the configuration file.
11781
11782.conf log@_selector string unset
11783.index log||selectors
11784This option can be used to reduce or increase the number of things that Exim
11785writes to its log files. Its argument is made up of names preceded by plus or
11786minus characters. For example:
11787.display asis
11788log_selector = +arguments -retry_defer
11789.endd
11790A list of possible names and what they control is given in the chapter on
11791logging, in section ~~SECTlogselector.
11792
11793.conf log@_timezone boolean false
11794.index log||timezone for entries
11795By default, the timestamps on log lines are in local time without the
11796timezone. This means that if your timezone changes twice a year, the timestamps
11797in log lines are ambiguous for an hour when the clocks go back. One way of
11798avoiding this problem is to set the timezone to UTC. An alternative is to set
11799\log@_timezone\ true. This turns on the addition of the timezone offset to
11800timestamps in log lines. Turning on this option can add quite a lot to the size
11801of log files because each line is extended by 6 characters. Note that the
11802\$tod@_log$\ variable contains the log timestamp without the zone, but there is
11803another variable called \$tod@_zone$\ that contains just the timezone offset.
11804
11805.conf lookup@_open@_max integer 25
11806.index too many open files
11807.index open files, too many
11808.index file||too many open
11809.index lookup||maximum open files
11810.index limit||open files for lookups
11811This option limits the number of simultaneously open files for single-key
11812lookups that use regular files (that is, \%lsearch%\, \%dbm%\, and \%cdb%\). Exim
11813normally keeps these files open during routing, because often the same file is
11814required several times. If the limit is reached, Exim closes the least recently
11815used file. Note that if you are using the \*ndbm*\ library, it actually opens
11816two files for each logical DBM database, though it still counts as one for the
11817purposes of \lookup@_open@_max\. If you are getting `too many open files'
11818errors with NDBM, you need to reduce the value of \lookup@_open@_max\.
11819
11820.conf max@_username@_length integer 0
11821.index length of login name
11822.index user name||maximum length
11823.index limit||user name length
11824Some operating systems are broken in that they truncate long arguments to
11825\*getpwnam()*\ to eight characters, instead of returning `no such user'. If
11826this option is set greater than zero, any attempt to call \*getpwnam()*\ with
11827an argument that is longer behaves as if \*getpwnam()*\ failed.
11828
11829
11830.conf message@_body@_visible integer 500
11831.index body of message||visible size
11832.index message||body, visible size
11833This option specifies how much of a message's body is to be included in the
11834\$message@_body$\ and \$message@_body@_end$\ expansion variables.
11835
11836.conf message@_id@_header@_domain string$**$ unset
11837.index ::Message-ID:: header line
11838If this option is set, the string is expanded and used as the right hand side
11839(domain) of the ::Message-ID:: header that Exim creates if a
11840locally-originated incoming message does not have one. `Locally-originated'
11841means `not received over TCP/IP.'
11842Otherwise, the primary host name is used.
11843Only letters, digits, dot and hyphen are accepted; any other characters are
11844replaced by hyphens. If the expansion is forced to fail, or if the result is an
11845empty string, the option is ignored.
11846
11847.conf message@_id@_header@_text string$**$ unset
11848If this variable is set, the string is expanded and used to augment the text of
11849the ::Message-id:: header that Exim creates if a
11850locally-originated
11851incoming message does not have one. The text of this header is required by RFC
118522822 to take the form of an address. By default, Exim uses its internal message
11853id as the local part, and the primary host name as the domain. If this option
11854is set, it is expanded, and provided the expansion is not forced to fail, and
11855does not yield an empty string, the result is inserted into the header
11856immediately before the @@, separated from the internal message id by a dot. Any
11857characters that are illegal in an address are automatically converted into
11858hyphens. This means that variables such as \$tod@_log$\ can be used, because
11859the spaces and colons will become hyphens.
11860
11861.conf message@_logs boolean true
11862.index message||log, disabling
11863.index log||message log, disabling
11864If this option is turned off, per-message log files are not created in the
11865\(msglog)\ spool sub-directory. This reduces the amount of disk I/O required by
11866Exim, by reducing the number of files involved in handling a message from a
11867minimum of four (header spool file, body spool file, delivery journal, and
11868per-message log) to three. The other major I/O activity is Exim's main log,
11869which is not affected by this option.
11870
11871.conf message@_size@_limit string$**$ 50M
11872.index message||size limit
11873.index limit||message size
11874.index size||of message, limit
11875This option limits the maximum size of message that Exim will process. The
11876value is expanded for each incoming
11877connection so, for example, it can be made to depend on the IP address of the
11878remote host for messages arriving via TCP/IP. \**Note**\: This limit cannot be
11879made to depend on a message's sender or any other properties of an individual
11880message, because it has to be advertised in the server's response to \\EHLO\\.
11881String expansion failure causes a temporary error. A value of zero means no
11882limit, but its use is not recommended. See also \bounce@_return@_size@_limit\.
11883
11884Incoming SMTP messages are failed with a 552 error if the limit is
11885exceeded; locally-generated messages either get a stderr message or a delivery
11886failure message to the sender, depending on the \-oe-\ setting. Rejection of an
11887oversized message is logged in both the main and the reject logs. See also the
11888generic transport option \message@_size@_limit\, which limits the size of
11889message that an individual transport can process.
11890
11891.conf move@_frozen@_messages boolean false
11892.index frozen messages||moving
11893This option, which is available only if Exim has been built with the setting
11894.display asis
11895SUPPORT_MOVE_FROZEN_MESSAGES=yes
11896.endd
11897in \(Local/Makefile)\, causes frozen messages and their message logs to be
11898moved from the \(input)\ and \(msglog)\ directories on the spool to \(Finput)\
11899and \(Fmsglog)\, respectively. There is currently no support in Exim or the
11900standard utilities for handling such moved messages, and they do not show up in
11901lists generated by \-bp-\ or by the Exim monitor.
11902
11903.conf mysql@_servers "string list" unset
11904.index MySQL||server list
11905This option provides a list of MySQL servers and associated connection data, to
11906be used in conjunction with \%mysql%\ lookups (see section ~~SECTsql). The
11907option is available only if Exim has been built with MySQL support.
11908
11909.conf never@_users "string list" unset
11910Local message deliveries are normally run in processes that are setuid to the
11911recipient, and remote deliveries are normally run under Exim's own uid and gid.
11912It is usually desirable to prevent any deliveries from running as root, as a
11913safety precaution.
11914
11915When Exim is built, an option called \\FIXED@_NEVER@_USERS\\ can be set to a
11916list of users that must not be used for local deliveries. This list is fixed in
11917the binary and cannot be overridden by the configuration file. By default, it
11918contains just the single user name `root'. The \never@_users\ runtime option
11919can be used to add more users to the fixed list.
11920
11921If a message is to be delivered as one of the users on the fixed list or the
11922\never@_users\ list, an error occurs, and delivery is deferred. A common
11923example is
11924.display
11925never@_users = root:daemon:bin
11926.endd
11927Including root is redundant if it is also on the fixed list, but it does no
11928harm.
11929This option overrides the \pipe@_as@_creator\ option of the \%pipe%\ transport
11930driver.
11931
11932.conf oracle@_servers "string list" unset
11933.index Oracle||server list
11934This option provides a list of Oracle servers and associated connection data,
11935to be used in conjunction with \%oracle%\ lookups (see section ~~SECTsql). The
11936option is available only if Exim has been built with Oracle support.
11937
11938.conf percent@_hack@_domains "domain list$**$" unset
11939.index `percent hack'
11940.index source routing||in email address
11941.index address||source-routed
11942The `percent hack' is the convention whereby a local part containing a percent
11943sign is re-interpreted as a new email address, with the percent replaced by @@.
11944This is sometimes called `source routing', though that term is also applied to
11945RFC 2822 addresses that begin with an @@ character. If this option is set, Exim
11946implements the percent facility for those domains listed, but no others. This
11947happens before an incoming SMTP address is tested against an ACL.
11948
11949\**Warning**\: The `percent hack' has often been abused by people who are
11950trying to get round relaying restrictions. For this reason, it is best avoided
11951if at all possible. Unfortunately, a number of less security-conscious MTAs
11952implement it unconditionally. If you are running Exim on a gateway host, and
11953routing mail through to internal MTAs without processing the local parts, it is
11954a good idea to reject recipient addresses with percent characters in their
11955local parts. Exim's default configuration does this.
11956
11957.conf perl@_at@_start boolean false
11958This option is available only when Exim is built with an embedded Perl
11959interpreter. See chapter ~~CHAPperl for details of its use.
11960
11961.conf perl@_startup string unset
11962This option is available only when Exim is built with an embedded Perl
11963interpreter. See chapter ~~CHAPperl for details of its use.
11964
11965.conf pgsql@_servers "string list" unset
11966.index PostgreSQL lookup type||server list
11967This option provides a list of PostgreSQL servers and associated connection
11968data, to be used in conjunction with \%pgsql%\ lookups (see section ~~SECTsql).
11969The option is available only if Exim has been built with PostgreSQL support.
11970
11971.conf pid@_file@_path string$**$ "set at compile time"
11972.index daemon||pid file path
11973.index pid file, path for
11974This option sets the name of the file to which the Exim daemon writes its
11975process id. The string is expanded, so it can contain, for example, references
11976to the host name:
11977.display asis
11978pid_file_path = /var/log/$primary_hostname/exim.pid
11979.endd
11980If no path is set, the pid is written to the file \(exim-daemon.pid)\ in Exim's
11981spool directory.
11982The value set by the option can be overridden by the \-oP-\ command line
11983option. A pid file is not written if a `non-standard' daemon is run by means of
11984the \-oX-\ option, unless a path is explicitly supplied by \-oP-\.
11985
11986.conf pipelining@_advertise@_hosts "host list$**$" $*$
11987.index \\PIPELINING\\||advertising, suppressing
11988This option can be used to suppress the advertisement of the SMTP
11989\\PIPELINING\\ extension to specific hosts. When \\PIPELINING\\ is not
11990advertised and \smtp@_enforce@_sync\ is true, an Exim server enforces strict
11991synchronization for each SMTP command and response.
11992.em
11993When \\PIPELINING\\ is advertised, Exim assumes that clients will use it; `out
11994of order' commands that are `expected' do not count as protocol errors (see
11995\smtp@_max@_synprot@_errors\).
11996.nem
11997
11998.conf preserve@_message@_logs boolean false
11999.index message logs, preserving
12000If this option is set, message log files are not deleted when messages are
12001completed. Instead, they are moved to a sub-directory of the spool directory
12002called \(msglog.OLD)\, where they remain available for statistical or debugging
12003purposes. This is a dangerous option to set on systems with any appreciable
12004volume of mail. Use with care!
12005
12006.conf primary@_hostname string "see below"
12007.index name||of local host
12008.index host||name of local
12009.index local host||name of
12010.em
12011This specifies the name of the current host. It is used in the default \\EHLO\\
12012or \\HELO\\ command for outgoing SMTP messages (changeable via the \helo@_data\
12013option in the \%smtp%\ transport),
12014.nem
12015and as the default for \qualify@_domain\. If it is not set, Exim calls
12016\*uname()*\ to find it. If this fails, Exim panics and dies. If the name
12017returned by \*uname()*\ contains only one component, Exim passes it to
12018\*gethostbyname()*\ (or \*getipnodebyname()*\ when available) in order to
12019obtain the fully qualified version.
12020
12021.em
12022The value of \$primary@_hostname$\ is also used by default in some SMTP
12023response messages from an Exim server. This can be changed dynamically by
12024setting \smtp@_active@_hostname\.
12025.nem
12026
12027.conf print@_topbitchars boolean false
12028.index printing characters
12029.index 8-bit characters
12030By default, Exim considers only those characters whose codes lie in the range
1203132--126 to be printing characters. In a number of circumstances (for example,
12032when writing log entries) non-printing characters are converted into escape
12033sequences, primarily to avoid messing up the layout. If \print@_topbitchars\ is
12034set, code values of 128 and above are also considered to be printing
12035characters.
12036
12037.conf process@_log@_path string unset
12038.index process log path
12039.index log||process log
12040.index \*exiwhat*\
12041This option sets the name of the file to which an Exim process writes its
12042`process log' when sent a USR1 signal. This is used by the \*exiwhat*\ utility
12043script. If this option is unset, the file called \(exim-process.info)\ in
12044Exim's spool directory is used. The ability to specify the name explicitly can
12045be useful in environments where two different Exims are running, using
12046different spool directories.
12047
12048.conf prod@_requires@_admin boolean true
12049.index \-M-\ option
12050.index \-R-\ option
12051.index \-q-\ option
12052The \-M-\, \-R-\, and \-q-\ command-line options require the caller to be an
12053admin user unless \prod@_requires@_admin\ is set false. See also
12054\queue@_list@_requires@_admin\.
12055
12056.conf qualify@_domain string "see below"
12057.index domain||for qualifying addresses
12058.index address||qualification
12059This option specifies the domain name that is added to any sender addresses
12060that do not have a domain qualification. It also applies to recipient addresses
12061if \qualify@_recipient\ is not set. Such addresses are accepted by default only
12062for locally-generated messages. Messages from external sources must always
12063contain fully qualified addresses, unless the sending host matches
12064\sender@_unqualified@_hosts\ or \recipient@_unqualified@_hosts\ (as
12065appropriate), in which case incoming addresses are qualified with
12066\qualify@_domain\ or \qualify@_recipient\ as necessary. Internally, Exim always
12067works with fully qualified addresses.
12068If \qualify@_domain\ is not set, it defaults to the \primary@_hostname\ value.
12069
12070.conf qualify@_recipient string "see below"
12071This specifies the domain name that is added to any recipient addresses that do
12072not have a domain qualification. Such addresses are accepted by default only
12073for locally-generated messages. Messages from external sources must always
12074contain fully qualified recipient addresses, unless the sending host matches
12075\recipient@_unqualified@_hosts\,
12076in which case incoming recipient addresses are qualified with
12077\qualify@_recipient\.
12078If \qualify@_recipient\ is not set, it defaults to the \qualify@_domain\ value.
12079
12080.conf queue@_domains "domain list$**$" unset
12081.index domain||specifying non-immediate delivery
12082.index queueing incoming messages
12083.index message||queueing certain domains
12084This option lists domains for which immediate delivery is not required.
12085A delivery process is started whenever a message is received, but only those
12086domains that do not match are processed. All other deliveries wait until the
12087next queue run. See also \hold@_domains\ and \queue@_smtp@_domains\.
12088
12089.conf queue@_list@_requires@_admin boolean true
12090.index \-bp-\ option
12091The \-bp-\ command-line option, which lists the messages that are on the queue,
12092requires the caller to be an admin user unless \queue__list__requires__admin\
12093is set false. See also \prod@_requires@_admin\.
12094
12095.conf queue@_only boolean false
12096.index queueing incoming messages
12097.index message||queueing unconditionally
12098If \queue@_only\ is set, a delivery process is not automatically started
12099whenever a message is received. Instead, the message waits on the queue for the
12100next queue run. Even if \queue@_only\ is false, incoming messages may not get
12101delivered immediately when certain conditions (such as heavy load) occur.
12102
12103The \-odq-\ command line has the same effect as \queue@_only\. The \-odb-\ and
12104\-odi-\ command line options override \queue@_only\ unless
12105\queue@_only@_override\ is set false. See also \queue@_only@_file\,
12106\queue@_only@_load\, and \smtp@_accept@_queue\.
12107
12108.conf queue@_only@_file string unset
12109.index queueing incoming messages
12110.index message||queueing by file existence
12111This option can be set to a colon-separated list of absolute path names, each
12112one optionally preceded by `smtp'. When Exim is receiving a message,
12113it tests for the existence of each listed path using a call to \*stat()*\. For
12114each path that exists, the corresponding queuing option is set.
12115For paths with no prefix, \queue@_only\ is set; for paths prefixed by `smtp',
12116\queue@_smtp@_domains\ is set to match all domains. So, for example,
12117.display asis
12118queue_only_file = smtp/some/file
12119.endd
12120causes Exim to behave as if \queue@_smtp@_domains\ were set to `$*$' whenever
12121\(/some/file)\ exists.
12122
12123.conf queue@_only@_load fixed-point unset
12124.index load average
12125.index queueing incoming messages
12126.index message||queueing by load
12127If the system load average is higher than this value, incoming messages from
12128all sources are queued, and no automatic deliveries are started. If this
12129happens during local or remote SMTP input, all subsequent messages on the same
12130connection are queued. Deliveries will subsequently be performed by queue
12131runner processes. This option has no effect on ancient operating systems on
12132which Exim cannot determine the load average. See also
12133\deliver@_queue@_load@_max\ and \smtp@_load@_reserve\.
12134
12135.conf queue@_only@_override boolean true
12136.index queueing incoming messages
12137When this option is true, the \-od\*x*\-\ command line options override the
12138setting of \queue@_only\ or \queue@_only@_file\ in the configuration file. If
12139\queue@_only@_override\ is set false, the \-od\*x*\-\ options cannot be used to
12140override; they are accepted, but ignored.
12141
12142.conf queue@_run@_in@_order boolean false
12143.index queue runner||processing messages in order
12144If this option is set, queue runs happen in order of message arrival instead of
12145in an arbitrary order. For this to happen, a complete list of the entire queue
12146must be set up before the deliveries start. When the queue is all in a single
12147directory (the default), this happens anyway, but if \split@_spool@_directory\
12148is set it does not -- for delivery in random order, the sub-directories are
12149processed one at a time (in random order), to avoid setting up one huge list.
12150Thus, setting \queue@_run@_in@_order\ with \split@_spool@_directory\ may
12151degrade performance when the queue is large. In most situations,
12152\queue@_run@_in@_order\ should not be set.
12153
12154.conf queue@_run@_max integer 5
12155.index queue runner||maximum number of
12156This controls the maximum number of queue runner processes that an Exim daemon
12157can run simultaneously. This does not mean that it starts them all at once,
12158but rather that if the maximum number are still running when the time comes to
12159start another one, it refrains from starting another one. This can happen with
12160very large queues and/or very sluggish deliveries. This option does not,
12161however, interlock with other processes, so additional queue runners can be
12162started by other means, or by killing and restarting the daemon.
12163
12164.conf queue@_smtp@_domains "domain list$**$" unset
12165.index queueing incoming messages
12166.index message||queueing remote deliveries
12167When this option is set, a delivery process is started whenever a message is
12168received, routing is performed, and local deliveries take place.
12169However, if any SMTP deliveries are required for domains that match
12170\queue@_smtp@_domains\, they are not immediately delivered, but instead the
12171message waits on the queue for the next queue run. Since routing of the message
12172has taken place, Exim knows to which remote hosts it must be delivered, and so
12173when the queue run happens, multiple messages for the same host are delivered
12174over a single SMTP connection. The \-odqs-\ command line option causes all SMTP
12175deliveries to be queued in this way, and is equivalent to setting
12176\queue@_smtp@_domains\ to `$*$'. See also \hold@_domains\ and \queue@_domains\.
12177
12178.conf receive@_timeout time 0s
12179.index timeout||for non-SMTP input
12180This option sets the timeout for accepting a non-SMTP message, that is, the
12181maximum time that Exim waits when reading a message on the standard input. If
12182the value is zero, it will wait for ever. This setting is overridden by the
12183\-or-\ command line option. The timeout for incoming SMTP messages is
12184controlled by \smtp@_receive@_timeout\.
12185
12186.index customizing|| ::Received:: header
12187.index ::Received:: header line||customizing
12188.conf received@_header@_text string$**$ "see below"
12189This string defines the contents of the ::Received:: message header that is
12190added to each message, except for the timestamp, which is automatically added
12191on at the end (preceded by a semicolon). The string is expanded each time it is
12192used. If the expansion yields an empty string, no ::Received:: header line is
12193added to the message. Otherwise, the string should start with the text
12194`Received:' and conform to the RFC 2822 specification for ::Received:: header
12195lines. The default setting is:
12196.display asis
12197received_header_text = Received: \
12198 ${if def:sender_rcvhost {from $sender_rcvhost\n\t}\
12199 {${if def:sender_ident {from $sender_ident }}\
12200 ${if def:sender_helo_name {(helo=$sender_helo_name)\n\t}}}}\
12201 by $primary_hostname \
12202 ${if def:received_protocol {with $received_protocol}} \
12203 ${if def:tls_cipher {($tls_cipher)\n\t}}\
12204 (Exim $version_number)\n\t\
12205 id $message_id\
12206 ${if def:received_for {\n\tfor $received_for}}
12207.endd
12208Note the use of quotes, to allow the sequences \"@\n"\ and \"@\t"\ to be used
12209for newlines and tabs, respectively. The reference to the TLS cipher is omitted
12210when Exim is built without TLS support. The use of conditional expansions
12211ensures that this works for both locally generated messages and messages
12212received from remote hosts, giving header lines such as the following:
12213.display asis
12214Received: from scrooge.carol.example ([192.168.12.25] ident=root)
12215 by marley.carol.example with esmtp (Exim 4.00)
12216 id 16IOWa-00019l-00
12217 for chas@dickens.example; Tue, 25 Dec 2001 14:43:44 +0000
12218Received: by scrooge.carol.example with local (Exim 4.00)
12219 id 16IOWW-000083-00; Tue, 25 Dec 2001 14:43:41 +0000
12220.endd
12221.em
12222Until the body of the message has been received, the timestamp is the time when
12223the message started to be received. Once the body has arrived, and all policy
12224checks have taken place, the timestamp is updated to the time at which the
12225message was accepted.
12226.nem
12227
12228.conf received@_headers@_max integer 30
12229.index loop||prevention
12230.index mail loop prevention
12231.index ::Received:: header line||counting
12232When a message is to be delivered, the number of ::Received:: headers is
12233counted, and if it is greater than this parameter, a mail loop is assumed to
12234have occurred, the delivery is abandoned, and an error message is generated.
12235This applies to both local and remote deliveries.
12236
12237.conf recipient@_unqualified@_hosts "host list$**$" unset
12238.index unqualified addresses
12239.index host||unqualified addresses from
12240This option lists those hosts from which Exim is prepared to accept unqualified
12241recipient addresses in message envelopes. The addresses are made fully
12242qualified by the addition of the \qualify@_recipient\ value. This option also
12243affects message header lines. Exim does not reject unqualified recipient
12244addresses in headers, but it qualifies them only if the message came from a
12245host that matches \recipient@_unqualified@_hosts\,
12246.em
12247or if the message was submitted locally (not using TCP/IP), and the \-bnq-\
12248option was not set.
12249.nem
12250
12251.conf recipients@_max integer 0
12252.index limit||number of recipients
12253.index recipient||maximum number
12254If this option is set greater than zero, it specifies the maximum number of
12255original recipients for any message. Additional recipients that are generated
12256by aliasing or forwarding do not count. SMTP messages get a 452 response for
12257all recipients over the limit; earlier recipients are delivered as normal.
12258Non-SMTP messages with too many recipients are failed, and no deliveries are
12259done.
12260.index \\RCPT\\||maximum number of incoming
12261Note that the RFCs specify that an SMTP server should accept at least 100
12262\\RCPT\\ commands in a single message.
12263
12264.conf recipients@_max@_reject boolean false
12265If this option is set true, Exim rejects SMTP messages containing too many
12266recipients by giving 552 errors to the surplus \\RCPT\\ commands, and a 554
12267error to the eventual \\DATA\\ command. Otherwise (the default) it gives a 452
12268error to the surplus \\RCPT\\ commands and accepts the message on behalf of the
12269initial set of recipients. The remote server should then re-send the message
12270for the remaining recipients at a later time.
12271
12272.conf remote@_max@_parallel integer 2
12273.index delivery||parallelism for remote
12274This option controls parallel delivery of one message to a number of remote
12275hosts. If the value is less than 2, parallel delivery is disabled, and Exim
12276does all the remote deliveries for a message one by one. Otherwise, if a single
12277message has to be delivered to more than one remote host, or if several copies
12278have to be sent to the same remote host, up to \remote@_max@_parallel\
12279deliveries are done simultaneously. If more than \remote@_max@_parallel\
12280deliveries are required, the maximum number of processes are started, and as
12281each one finishes, another is begun. The order of starting processes is the
12282same as if sequential delivery were being done, and can be controlled by the
12283\remote@_sort@_domains\ option. If parallel delivery takes place while running
12284with debugging turned on, the debugging output from each delivery process is
12285tagged with its process id.
12286
12287This option controls only the maximum number of parallel deliveries for one
12288message in one Exim delivery process. Because Exim has no central queue
12289manager, there is no way of controlling the total number of simultaneous
12290deliveries if the configuration allows a delivery attempt as soon as a message
12291is received.
12292.index number of deliveries
12293.index delivery||maximum number of
12294If you want to control the total number of deliveries on the system, you
12295need to set the \queue@_only\ option. This ensures that all incoming messages
12296are added to the queue without starting a delivery process. Then set up an Exim
12297daemon to start queue runner processes at appropriate intervals (probably
12298fairly often, for example, every minute), and limit the total number of queue
12299runners by setting the \queue__run__max\ parameter. Because each queue runner
12300delivers only one message at a time, the maximum number of deliveries that can
12301then take place at once is \queue@_run@_max\ multiplied by
12302\remote@_max@_parallel\.
12303
12304If it is purely remote deliveries you want to control, use \queue@_smtp\
12305instead of \queue@_only\. This has the added benefit of doing the SMTP routing
12306before queuing, so that several messages for the same host will eventually get
12307delivered down the same connection.
12308
12309.conf remote@_sort@_domains "domain list$**$" unset
12310.index sorting remote deliveries
12311.index delivery||sorting remote
12312When there are a number of remote deliveries for a message, they are sorted by
12313domain into the order given by this list. For example,
12314.display asis
12315remote_sort_domains = *.cam.ac.uk:*.uk
12316.endd
12317would attempt to deliver to all addresses in the \*cam.ac.uk*\ domain first, then
12318to those in the \uk\ domain, then to any others.
12319
12320.conf retry@_data@_expire time 7d
12321.index hints database||data expiry
12322This option sets a `use before' time on retry information in Exim's hints
12323database. Any older retry data is ignored. This means that, for example, once a
12324host has not been tried for 7 days, Exim behaves as if it has no knowledge of
12325past failures.
12326
12327.conf retry@_interval@_max time 24h
12328.index retry||limit on interval
12329.index limit||on retry interval
12330Chapter ~~CHAPretry describes Exim's mechanisms for controlling the intervals
12331between delivery attempts for messages that cannot be delivered straight away.
12332This option sets an overall limit to the length of time between retries.
12333
12334.conf return@_path@_remove boolean true
12335.index ::Return-path:: header line||removing
12336RFC 2821, section 4.4, states that an SMTP server must insert a ::Return-path::
12337header line into a message when it makes a `final delivery'. The ::Return-path::
12338header preserves the sender address as received in the \\MAIL\\ command. This
12339description implies that this header should not be present in an incoming
12340message. If \return@_path@_remove\ is true, any existing ::Return-path::
12341headers are removed from messages at the time they are received. Exim's
12342transports have options for adding ::Return-path:: headers at the time of
12343delivery. They are normally used only for final local deliveries.
12344
12345.conf return@_size@_limit integer 100K
12346This option is an obsolete synonym for \bounce@_return@_size@_limit\.
12347
12348.conf rfc1413@_hosts "host list$**$" $*$
12349.index RFC 1413
12350.index host||for RFC 1413 calls
12351RFC 1413 identification calls are made to any client host which matches an item
12352in the list.
12353
12354.conf rfc1413@_query@_timeout time 30s
12355.index RFC 1413||query timeout
12356.index timeout||for RFC 1413 call
12357This sets the timeout on RFC 1413 identification calls. If it is set to zero,
12358no RFC 1413 calls are ever made.
12359
12360.conf sender@_unqualified@_hosts "host list$**$" unset
12361.index unqualified addresses
12362.index host||unqualified addresses from
12363This option lists those hosts from which Exim is prepared to accept unqualified
12364sender addresses. The addresses are made fully qualified by the addition of
12365\qualify@_domain\. This option also affects message header lines. Exim does not
12366reject unqualified addresses in headers that contain sender addresses, but it
12367qualifies them only if the message came from a host that matches
12368\sender@_unqualified@_hosts\,
12369.em
12370or if the message was submitted locally (not using TCP/IP), and the \-bnq-\
12371option was not set.
12372.nem
12373
12374.conf smtp@_accept@_keepalive boolean true
12375.index keepalive||on incoming connection
12376This option controls the setting of the \\SO@_KEEPALIVE\\ option on incoming
12377TCP/IP socket connections. When set, it causes the kernel to probe idle
12378connections periodically, by sending packets with `old' sequence numbers. The
12379other end of the connection should send an acknowledgement if the connection is
12380still okay or a reset if the connection has been aborted. The reason for doing
12381this is that it has the beneficial effect of freeing up certain types of
12382connection that can get stuck when the remote host is disconnected without
12383tidying up the TCP/IP call properly. The keepalive mechanism takes several
12384hours to detect unreachable hosts.
12385
12386
12387.conf smtp@_accept@_max integer 20
12388.index limit||incoming SMTP connections
12389.index SMTP||incoming connection count
12390.index inetd
12391This option specifies the maximum number of simultaneous incoming SMTP calls
12392that Exim will accept. It applies only to the listening daemon; there is no
12393control (in Exim) when incoming SMTP is being handled by \*inetd*\. If the value
12394is set to zero, no limit is applied. However, it is required to be non-zero if
12395either \smtp@_accept@_max@_per@_host\ or \smtp@_accept@_queue\ is set. See also
12396\smtp@_accept@_reserve\.
12397
12398
12399.conf smtp@_accept@_max@_nonmail integer 10
12400.index limit||non-mail SMTP commands
12401.index SMTP||limiting non-mail commands
12402Exim counts the number of `non-mail' commands in an SMTP session, and drops the
12403connection if there are too many. This option defines `too many'. The check
12404catches some denial-of-service attacks, repeated failing \\AUTH\\s, or a mad
12405client looping sending \\EHLO\\, for example. The check is applied only if the
12406client host matches \smtp@_accept@_max@_nonmail@_hosts\.
12407
12408When a new message is expected, one occurrence of \\RSET\\ is not counted. This
12409allows a client to send one \\RSET\\ between messages (this is not necessary,
12410but some clients do it). Exim also allows one uncounted occurence of \\HELO\\
12411or \\EHLO\\, and one occurrence of \\STARTTLS\\ between messages. After
12412starting up a TLS session, another \\EHLO\\ is expected, and so it too is not
12413counted. The first occurrence of \\AUTH\\ in a connection, or immediately
12414following \\STARTTLS\\ is not counted. Otherwise, all commands other than
12415\\MAIL\\, \\RCPT\\, \\DATA\\, and \\QUIT\\ are counted.
12416
12417.conf smtp@_accept@_max@_nonmail@_hosts "host list$**$" $*$
12418You can control which hosts are subject to the \smtp@_accept@_max@_nonmail\
12419check by setting this option. The default value makes it apply to all hosts. By
12420changing the value, you can exclude any badly-behaved hosts that you have to
12421live with.
12422
12423
12424.conf smtp@_accept@_max@_per@_connection integer 1000
12425.index SMTP||incoming message count, limiting
12426.index limit||messages per SMTP connection
12427The value of this option limits the number of \\MAIL\\ commands that Exim is
12428prepared to accept over a single SMTP connection, whether or not each command
12429results in the transfer of a message. After the limit is reached, a 421
12430response is given to subsequent \\MAIL\\ commands. This limit is a safety
12431precaution against a client that goes mad (incidents of this type have been
12432seen).
12433
12434.conf smtp@_accept@_max@_per@_host string$**$ unset
12435.index limit||SMTP connections from one host
12436.index host||limiting SMTP connections from
12437This option restricts the number of simultaneous IP connections from a single
12438host (strictly, from a single IP address) to the Exim daemon. The option is
12439expanded, to enable different limits to be applied to different hosts by
12440reference to \$sender@_host@_address$\. Once the limit is reached, additional
12441connection attempts from the same host are rejected with error code 421. The
12442default value of zero imposes no limit. If this option is set, it is required
12443that \smtp@_accept@_max\ be non-zero.
12444
12445\**Warning**\: When setting this option you should not use any expansion
12446constructions that take an appreciable amount of time. The expansion and test
12447happen in the main daemon loop, in order to reject additional connections
12448without forking additional processes (otherwise a denial-of-service attack
12449could cause a vast number or processes to be created). While the daemon is
12450doing this processing, it cannot accept any other incoming connections.
12451
12452
12453.conf smtp@_accept@_queue integer 0
12454.index SMTP||incoming connection count
12455.index queueing incoming messages
12456.index message||queueing by SMTP connection count
12457If the number of simultaneous incoming SMTP calls handled via the listening
12458daemon exceeds this value, messages received by SMTP are just placed on the
12459queue; no delivery processes are started automatically. A value of zero implies
12460no limit, and clearly any non-zero value is useful only if it is less than the
12461\smtp@_accept@_max\ value (unless that is zero). See also \queue@_only\,
12462\queue@_only@_load\, \queue@_smtp@_domains\, and the various \-od-\ command
12463line options.
12464
12465.conf smtp@_accept@_queue@_per@_connection integer 10
12466.index queueing incoming messages
12467.index message||queueing by message count
12468This option limits the number of delivery processes that Exim starts
12469automatically when receiving messages via SMTP, whether via the daemon or by
12470the use of \-bs-\ or \-bS-\. If the value of the option is greater than zero,
12471and the number of messages received in a single SMTP session exceeds this
12472number, subsequent messages are placed on the queue, but no delivery processes
12473are started. This helps to limit the number of Exim processes when a server
12474restarts after downtime and there is a lot of mail waiting for it on other
12475systems. On large systems, the default should probably be increased, and on
12476dial-in client systems it should probably be set to zero (that is, disabled).
12477
12478.conf smtp@_accept@_reserve integer 0
12479.index SMTP||incoming call count
12480.index host||reserved
12481When \smtp@_accept@_max\ is set greater than zero, this option specifies a
12482number of SMTP connections that are reserved for connections from the hosts
12483that are specified in \smtp@_reserve@_hosts\. The value set in
12484\smtp@_accept@_max\ includes this reserve pool. The specified hosts are not
12485restricted to this number of connections; the option specifies a minimum number
12486of connection slots for them, not a maximum. It is a guarantee that that group
12487of hosts can always get at least \smtp@_accept@_reserve\ connections.
12488
12489For example, if \smtp@_accept@_max\ is set to 50 and \smtp@_accept@_reserve\ is
12490set to 5, once there are 45 active connections (from any hosts), new
12491connections are accepted only from hosts listed in \smtp@_reserve@_hosts\.
12492See also \smtp@_accept@_max@_per@_host\.
12493
12494.em
12495.conf smtp@_active@_hostname string$**$ unset
12496.index host||name in SMTP responses
12497.index SMTP||host name in responses
12498This option is provided for multi-homed servers that want to masquerade as
12499several different hosts. At the start of an SMTP connection, its value is
12500expanded and used instead of the value of \$primary@_hostname$\ in SMTP
12501responses. For example, it is used as domain name in the response to an
12502incoming \\HELO\\ or \\EHLO\\ command. If this option is unset, or if its
12503expansion is forced to fail, or if the expansion results in an empty string,
12504the value of \$primary@_hostname$\ is used. Other expansion failures cause a
12505message to be written to the main and panic logs, and the SMTP command receives
12506a temporary error. Typically, the value of \smtp@_active@_hostname\ depends on
12507the incoming interface address. For example:
12508.display asis
12509smtp_active_hostname = ${if eq{$interface_address}{10.0.0.1}\
12510 {cox.mydomain}{box.mydomain}}
12511.endd
12512If you set \smtp@_active@_hostname\, you probably also want to set
12513\smtp@_banner\, since its default value references \$primary@_hostname$\.
12514.nem
12515
12516.conf smtp@_banner string$**$ "see below"
12517.index SMTP||welcome banner
12518.index banner for SMTP
12519.index welcome banner for SMTP
12520.index customizing||SMTP banner
12521This string, which is expanded every time it is used, is output as the initial
12522positive response to an SMTP connection. The default setting is:
12523.display asis
12524smtp_banner = $primary_hostname ESMTP Exim $version_number \
12525 $tod_full
12526.endd
12527Failure to expand the string causes a panic error. If you want to create a
12528multiline response to the initial SMTP connection, use `@\n' in the string at
12529appropriate points, but not at the end. Note that the 220 code is not included
12530in this string. Exim adds it automatically (several times in the case of a
12531multiline response).
12532
12533.conf smtp@_check@_spool@_space boolean true
12534.index checking disk space
12535.index disk space, checking
12536.index spool directory||checking space
12537When this option is set, if an incoming SMTP session encounters the \\SIZE\\
12538option on a \\MAIL\\ command, it checks that there is enough space in the
12539spool directory's partition to accept a message of that size, while still
12540leaving free the amount specified by \check@_spool@_space\ (even if that value
12541is zero). If there isn't enough space, a temporary error code is returned.
12542
12543.conf smtp@_connect@_backlog integer 20
12544.index connection backlog
12545.index SMTP||connection backlog
12546.index backlog of connections
12547This option specifies a maximum number of waiting SMTP connections. Exim passes
12548this value to the TCP/IP system when it sets up its listener. Once this number
12549of connections are waiting for the daemon's attention, subsequent connection
12550attempts are refused at the TCP/IP level. At least, that is what the manuals
12551say; in some circumstances such connection attempts have been observed to time
12552out instead. For large systems it is probably a good idea to increase the
12553value (to 50, say). It also gives some protection against denial-of-service
12554attacks by SYN flooding.
12555
12556.conf smtp@_enforce@_sync boolean true
12557.index SMTP||synchronization checking
12558.index synchronization checking in SMTP
12559The SMTP protocol specification requires the client to wait for a response from
12560the server at certain points in the dialogue. Without \\PIPELINING\\ these
12561synchronization points are after every command; with \\PIPELINING\\ they are
12562fewer, but they still exist. Some spamming sites send out a complete set of
12563SMTP commands without waiting for any response. Exim protects against this by
12564rejecting a message if the client has sent further input when it should not
12565have. The error response `554 SMTP synchronization error' is sent, and the
12566connection is dropped. Testing for this error cannot be perfect because of
12567transmission delays (unexpected input may be on its way but not yet received
12568when Exim checks). However, it does detect many instances. The check can be
12569disabled by setting \smtp@_enforce@_sync\ false.
12570.em
12571See also \pipelining@_advertise@_hosts\.
12572.nem
12573
12574.conf smtp@_etrn@_command string$**$ unset
12575.index \\ETRN\\||command to be run
12576If this option is set, the given command is run whenever an SMTP \\ETRN\\
12577command is received from a host that is permitted to issue such commands (see
12578chapter ~~CHAPACL). The string is split up into separate arguments which are
12579independently expanded. The expansion variable \$domain$\ is set to the
12580argument of the \\ETRN\\ command, and no syntax checking is done on it. For
12581example:
12582.display asis
12583smtp_etrn_command = /etc/etrn_command $domain $sender_host_address
12584.endd
12585A new process is created to run the command, but Exim does not wait for it to
12586complete. Consequently, its status cannot be checked. If the command cannot be
12587run, a line is written to the panic log, but the \\ETRN\\ caller still receives
12588a 250 success response. Exim is normally running under its own uid when
12589receiving SMTP, so it is not possible for it to change the uid before running
12590the command.
12591
12592.conf smtp@_etrn@_serialize boolean true
12593.index \\ETRN\\||serializing
12594When this option is set, it prevents the simultaneous execution of more than
12595one identical command as a result of \\ETRN\\ in an SMTP connection. See
12596section ~~SECTETRN for details.
12597
12598.conf smtp@_load@_reserve fixed-point unset
12599.index load average
12600If the system load average ever gets higher than this, incoming SMTP calls are
12601accepted only from those hosts that match an entry in \smtp@_reserve@_hosts\.
12602If \smtp@_reserve@_hosts\ is not set, no incoming SMTP calls are accepted when
12603the load is over the limit. The option has no effect on ancient operating
12604systems on which Exim cannot determine the load average. See also
12605\deliver@_queue@_load@_max\ and \queue@_only@_load\.
12606
12607
12608.conf smtp@_max@_synprot@_errors integer 3
12609.index SMTP||limiting syntax and protocol errors
12610.index limit||SMTP syntax and protocol errors
12611Exim rejects SMTP commands that contain syntax or protocol errors. In
12612particular, a syntactically invalid email address, as in this command:
12613.display asis
12614RCPT TO:<abc xyz@a.b.c>
12615.endd
12616causes immediate rejection of the command, before any other tests are done.
12617(The ACL cannot be run if there is no valid address to set up for it.) An
12618example of a protocol error is receiving \\RCPT\\ before \\MAIL\\. If there are
12619too many syntax or protocol errors in one SMTP session, the connection is
12620dropped. The limit is set by this option.
12621
12622.em
12623.index \\PIPELINING\\||expected errors
12624When the \\PIPELINING\\ extension to SMTP is in use, some protocol errors are
12625`expected', for instance, a \\RCPT\\ command after a rejected \\MAIL\\ command.
12626Exim assumes that \\PIPELINING\\ will be used if it advertises it (see
12627\pipelining@_advertise@_hosts\), and in this situation, `expected' errors do
12628not count towards the limit.
12629.nem
12630
12631
12632.conf smtp@_max@_unknown@_commands integer 3
12633.index SMTP||limiting unknown commands
12634.index limit||unknown SMTP commands
12635If there are too many unrecognized commands in an incoming SMTP session, an
12636Exim server drops the connection. This is a defence against some kinds of abuse
12637that subvert web
12638.em
12639clients
12640.nem
12641into making connections to SMTP ports; in these circumstances, a number of
12642non-SMTP command lines are sent first.
12643
12644
12645.conf smtp@_ratelimit@_hosts "host list$**$" unset
12646.index SMTP||rate limiting
12647.index limit||rate of message arrival
12648.index \\RCPT\\||rate limiting
12649Some sites find it helpful to be able to limit the rate at which certain hosts
12650can send them messages, and the rate at which an individual message can specify
12651recipients. When a host matches \smtp@_ratelimit@_hosts\, the values of
12652\smtp@_ratelimit@_mail\ and \smtp@_ratelimit@_rcpt\ are used to control the
12653rate of acceptance of \\MAIL\\ and \\RCPT\\ commands in a single SMTP session,
12654respectively. Each option, if set, must contain a set of four comma-separated
12655values:
12656.numberpars $.
12657A threshold, before which there is no rate limiting.
12658.nextp
12659An initial time delay. Unlike other times in Exim, numbers with decimal
12660fractional parts are allowed here.
12661.nextp
12662A factor by which to increase the delay each time.
12663.nextp
12664A maximum value for the delay. This should normally be less than 5 minutes,
12665because after that time, the client is liable to timeout the SMTP command.
12666.endp
12667For example, these settings have been used successfully at the site which
12668first suggested this feature, for controlling mail from their customers:
12669.display asis
12670smtp_ratelimit_mail = 2,0.5s,1.05,4m
12671smtp_ratelimit_rcpt = 4,0.25s,1.015,4m
12672.endd
12673The first setting specifies delays that are applied to \\MAIL\\ commands after
12674two have been received over a single connection. The initial delay is 0.5
12675seconds, increasing by a factor of 1.05 each time. The second setting applies
12676delays to \\RCPT\\ commands when more than four occur in a single message.
12677
12678It is also possible to configure delays explicitly in ACLs. See section
12679~~SECTACLmodi for details.
12680
12681
12682.conf smtp@_ratelimit@_mail string unset
12683See \smtp@_ratelimit@_hosts\ above.
12684
12685.conf smtp@_ratelimit@_rcpt string unset
12686See \smtp@_ratelimit@_hosts\ above.
12687
12688.conf smtp@_receive@_timeout time 5m
12689.index timeout||for SMTP input
12690.index SMTP||timeout, input
12691This sets a timeout value for SMTP reception. It applies to all forms of SMTP
12692input, including batch SMTP. If a line of input (either an SMTP command or a
12693data line) is not received within this time, the SMTP connection is dropped and
12694the message is abandoned.
12695A line is written to the log containing one of the following messages:
12696.display asis
12697SMTP command timeout on connection from...
12698SMTP data timeout on connection from...
12699.endd
12700The former means that Exim was expecting to read an SMTP command; the latter
12701means that it was in the \\DATA\\ phase, reading the contents of a message.
12702
12703
12704.index \-os-\ option
12705The value set by this option can be overridden by the
12706\-os-\ command-line option. A setting of zero time disables the timeout, but
12707this should never be used for SMTP over TCP/IP. (It can be useful in some cases
12708of local input using \-bs-\ or \-bS-\.) For non-SMTP input, the reception
12709timeout is controlled by \receive@_timeout\ and \-or-\.
12710
12711.conf smtp@_reserve@_hosts "host list$**$" unset
12712This option defines hosts for which SMTP connections are reserved; see
12713\smtp@_accept@_reserve\ and \smtp@_load@_reserve\ above.
12714
12715.conf smtp@_return@_error@_details boolean false
12716.index SMTP||details policy failures
12717.index policy control||rejection, returning details
12718In the default state, Exim uses bland messages such as
12719`Administrative prohibition' when it rejects SMTP commands for policy
12720reasons. Many sysadmins like this because it gives away little information
12721to spammers. However, some other syadmins who are applying strict checking
12722policies want to give out much fuller information about failures. Setting
12723\smtp@_return@_error@_details\ true causes Exim to be more forthcoming. For
12724example, instead of `Administrative prohibition', it might give:
12725.display asis
12726550-Rejected after DATA: '>' missing at end of address:
12727550 failing address in "From" header is: <user@dom.ain
12728.endd
12729
12730.conf split@_spool@_directory boolean false
12731.index multiple spool directories
12732.index spool directory||split
12733.index directories, multiple
12734If this option is set, it causes Exim to split its input directory into 62
12735subdirectories, each with a single alphanumeric character as its name. The
12736sixth character of the message id is used to allocate messages to
12737subdirectories; this is the least significant base-62 digit of the time of
12738arrival of the message.
12739
12740Splitting up the spool in this way may provide better performance on systems
12741where there are long mail queues, by reducing the number of files in any one
12742directory. The msglog directory is also split up in a similar way to the input
12743directory; however, if \preserve@_message@_logs\ is set, all old msglog files
12744are still placed in the single directory \(msglog.OLD)\.
12745
12746It is not necessary to take any special action for existing messages when
12747changing \split@_spool@_directory\. Exim notices messages that are in the
12748`wrong' place, and continues to process them. If the option is turned off after
12749a period of being on, the subdirectories will eventually empty and be
12750automatically deleted.
12751
12752When \split@_spool@_directory\ is set, the behaviour of queue runner processes
12753changes. Instead of creating a list of all messages in the queue, and then
12754trying to deliver each one in turn, it constructs a list of those in one
12755sub-directory and tries to deliver them, before moving on to the next
12756sub-directory. The sub-directories are processed in a random order. This
12757spreads out the scanning of the input directories, and uses less memory. It is
12758particularly beneficial when there are lots of messages on the queue. However,
12759if \queue@_run@_in@_order\ is set, none of this new processing happens. The
12760entire queue has to be scanned and sorted before any deliveries can start.
12761
12762.conf spool@_directory string$**$ "set at compile time"
12763.index spool directory||path to
12764This defines the directory in which Exim keeps its spool, that is, the messages
12765it is waiting to deliver. The default value is taken from the compile-time
12766configuration setting, if there is one. If not, this option must be set. The
12767string is expanded, so it can contain, for example, a reference to
12768\$primary@_hostname$\.
12769
12770If the spool directory name is fixed on your installation, it is recommended
12771that you set it at build time rather than from this option, particularly if the
12772log files are being written to the spool directory (see \log@_file@_path\).
12773Otherwise log files cannot be used for errors that are detected early on, such
12774as failures in the configuration file.
12775
12776By using this option to override the compiled-in path, it is possible to run
12777tests of Exim without using the standard spool.
12778
12779.conf strip@_excess@_angle@_brackets boolean false
12780.index angle brackets, excess
12781If this option is set, redundant pairs of angle brackets round `route-addr'
12782items in addresses are stripped. For example, \*@<@<xxx@@a.b.c.d@>@>*\ is treated
12783as \*@<xxx@@a.b.c.d@>*\. If this is in the envelope and the message is passed on
12784to another MTA, the excess angle brackets are not passed on. If this option is
12785not set, multiple pairs of angle brackets cause a syntax error.
12786
12787.conf strip@_trailing@_dot boolean false
12788.index trailing dot on domain
12789.index dot||trailing on domain
12790If this option is set, a trailing dot at the end of a domain in an address is
12791ignored. If this is in the envelope and the message is passed on to another
12792MTA, the dot is not passed on. If this option is not set, a dot at the end of a
12793domain causes a syntax error.
12794.em
12795However, addresses in header lines are checked only when an ACL requests header
12796syntax checking.
12797.nem
12798
12799.conf syslog@_duplication boolean true
12800.index syslog||duplicate log lines, suppressing
12801When Exim is logging to syslog, it writes the log lines for its three
12802separate logs at different syslog priorities so that they can in principle
12803be separated on the logging hosts. Some installations do not require this
12804separation, and in those cases, the duplication of certain log lines is a
12805nuisance. If \syslog@_duplication\ is set false, only one copy of any
12806particular log line is written to syslog. For lines that normally go to
12807both the main log and the reject log, the reject log version (possibly
12808containing message header lines) is written, at \\LOG@_NOTICE\\ priority.
12809Lines that normally go to both the main and the panic log are written at
12810the \\LOG@_ALERT\\ priority.
12811
12812.conf syslog@_facility string unset
12813.index syslog||facility, setting
12814This option sets the syslog `facility' name, used when Exim is logging to
12815syslog. The value must be one of the strings `mail', `user', `news', `uucp',
12816`daemon', or `local\*x*\' where \*x*\ is a digit between 0 and 7. If this
12817option is unset, `mail' is used. See chapter ~~CHAPlog for details of Exim's
12818logging.
12819
12820
12821.conf syslog@_processname string "$tt{exim}"
12822.index syslog||process name, setting
12823This option sets the syslog `ident' name, used when Exim is logging to syslog.
12824The value must be no longer than 32 characters. See chapter ~~CHAPlog for
12825details of Exim's logging.
12826
12827
12828.conf syslog@_timestamp boolean true
12829.index syslog||timestamps
12830If \syslog@_timestamp\ is set false, the timestamps on Exim's log lines are
12831omitted when these lines are sent to syslog. See chapter ~~CHAPlog for
12832details of Exim's logging.
12833
12834.conf system@_filter string$**$ unset
12835.index filter||system filter
12836.index system filter||specifying
12837.index Sieve filter||not available for system filter
12838This option specifies an Exim filter file that is applied to all messages at
12839the start of each delivery attempt, before any routing is done. System filters
12840must be Exim filters; they cannot be Sieve filters. If the system filter
12841generates any deliveries to files or pipes, or any new mail messages, the
12842appropriate \system@_filter@_...@_transport\ option(s) must be set, to define
12843which transports are to be used. Details of this facility are given in chapter
12844~~CHAPsystemfilter.
12845
12846.conf system@_filter@_directory@_transport string$**$ unset
12847This sets the name of the transport driver that is to be used when the
12848\save\ command in a system message filter specifies a path ending in `/',
12849implying delivery of each message into a separate file in some directory.
12850During the delivery, the variable \$address@_file$\ contains the path name.
12851
12852.conf system@_filter@_file@_transport string$**$ unset
12853.index file||transport for system filter
12854This sets the name of the transport driver that is to be used when the \save\
12855command in a system message filter specifies a path not ending in `/'. During
12856the delivery, the variable \$address@_file$\ contains the path name.
12857
12858.index gid (group id)||system filter
12859.conf system@_filter@_group string unset
12860This option is used only when \system@_filter@_user\ is also set. It sets the
12861gid under which the system filter is run, overriding any gid that is associated
12862with the user. The value may be numerical or symbolic.
12863
12864.conf system@_filter@_pipe@_transport string$**$ unset 7
12865.index \%pipe%\ transport||for system filter
12866This specifies the transport driver that is to be used when a \pipe\ command is
12867used in a system filter. During the delivery, the variable \$address@_pipe$\
12868contains the pipe command.
12869
12870.conf system@_filter@_reply@_transport string$**$ unset
12871.index \%autoreply%\ transport||for system filter
12872This specifies the transport driver that is to be used when a \mail\ command is
12873used in a system filter.
12874
12875.index uid (user id)||system filter
12876.conf system@_filter@_user string unset
12877If this option is not set, the system filter is run in the main Exim delivery
12878process, as root. When the option is set, the system filter runs in a separate
12879process, as the given user. Unless the string consists entirely of digits, it
12880is looked up in the password data. Failure to find the named user causes a
12881configuration error. The gid is either taken from the password data, or
12882specified by \system@_filter@_group\. When the uid is specified numerically,
12883\system@_filter@_group\ is required to be set.
12884
12885If the system filter generates any pipe, file, or reply deliveries, the uid
12886under which the filter is run is used when transporting them, unless a
12887transport option overrides.
12888Normally you should set \system@_filter@_user\ if your system filter generates
12889these kinds of delivery.
12890
12891.conf tcp@_nodelay boolean true
12892.index daemon||\\TCP@_NODELAY\\ on sockets
12893.index Nagle algorithm
12894.index \\TCP@_NODELAY\\ on listening sockets
12895If this option is set false, it stops the Exim daemon setting the
12896\\TCP@_NODELAY\\ option on its listening sockets. Setting \\TCP@_NODELAY\\
12897turns off the `Nagle algorithm', which is a way of improving network
12898performance in interactive (character-by-character) situations. Turning it off
12899should improve Exim's performance a bit, so that is what happens by default.
12900However, it appears that some broken clients cannot cope, and time out. Hence
12901this option. It affects only those sockets that are set up for listening by the
12902daemon. Sockets created by the smtp transport for delivering mail always set
12903\\TCP@_NODELAY\\.
12904
12905.conf timeout@_frozen@_after time 0s
12906.index frozen messages||timing out
12907.index timeout||frozen messages
12908If \timeout@_frozen@_after\ is set to a time greater than zero, a frozen
12909message of any kind that has been on the queue for longer than the given
12910time is automatically cancelled at the next queue run. If it is a bounce
12911message, it is just discarded; otherwise, a bounce is sent to the sender, in a
12912similar manner to cancellation by the \-Mg-\ command line option. If you want
12913to timeout frozen bounce messages earlier than other kinds of frozen message,
12914see \ignore@_bounce@_errors@_after\.
12915
12916.conf timezone string unset
12917.index timezone, setting
12918The value of \timezone\ is used to set the environment variable \\TZ\\ while
12919running Exim (if it is different on entry). This ensures that all timestamps
12920created by Exim are in the required timezone. If you want all your timestamps
12921to be in UTC (aka GMT) you should set
12922.display asis
12923timezone = UTC
12924.endd
12925The default value is taken from \\TIMEZONE@_DEFAULT\\ in \(Local/Makefile)\,
12926or, if that is not set, from the value of the TZ environment variable when Exim
12927is built. If \timezone\ is set to the empty string, either at build or run
12928time, any existing \\TZ\\ variable is removed from the environment when Exim
12929runs. This is appropriate behaviour for obtaining wall-clock time on some, but
12930unfortunately not all, operating systems.
12931
12932.conf tls@_advertise@_hosts "host list$**$" unset
12933.index TLS||advertising
12934.index encryption||on SMTP connection
12935.index SMTP||encrypted connection
12936When Exim is built with support for TLS encrypted connections, the availability
12937of the \\STARTTLS\\ command to set up an encrypted session is advertised in
12938response to \\EHLO\\ only to those client hosts that match this option. See
12939chapter ~~CHAPTLS for details of Exim's support for TLS.
12940
12941.conf tls@_certificate string$**$ unset
12942.index TLS||server certificate, location of
12943.index certificate||for server, location of
12944The value of this option is expanded, and must then be the absolute path to a
12945file which contains the server's certificates. The server's private key is also
12946assumed to be in this file if \tls@_privatekey\ is unset. See chapter ~~CHAPTLS
12947for further details.
12948
12949\**Note**\: The certificates defined by this option are used only when Exim is
12950receiving incoming messages as a server. If you want to supply certificates for
12951use when sending messages as a client, you must set the \tls@_certificate\
12952option in the relevant \%smtp%\ transport.
12953
12954.em
12955.conf tls@_crl string$**$ unset
12956.index TLS||server certificate revocation list
12957.index certificate||revocation list for server
12958This option specifies a certificate revocation list. The expanded value must
12959be the name of a file that contains a CRL in PEM format.
12960.nem
12961
12962.conf tls@_dhparam string$**$ unset
12963.index TLS||D-H parameters for server
12964The value of this option is expanded, and must then be the absolute path to
12965a file which contains the server's DH parameter values.
12966This is used only for OpenSSL. When Exim is linked with GnuTLS, this option is
12967ignored. See section ~~SECTopenvsgnu for further details.
12968
12969.conf tls@_privatekey string$**$ unset
12970.index TLS||server private key, location of
12971The value of this option is expanded, and must then be the absolute path to
12972a file which contains the server's private key.
12973If this option is unset, the private key is assumed to be in the same file as
12974the server's certificates. See chapter ~~CHAPTLS for further details.
12975
12976.conf tls@_remember@_esmtp boolean false
12977.index TLS||esmtp state, remembering
12978.index TLS||broken clients
12979If this option is set true, Exim violates the RFCs by remembering that it is in
12980`esmtp' state after successfully negotiating a TLS session. This provides
12981support for broken clients that fail to send a new \\EHLO\\ after starting a
12982TLS session.
12983
12984.em
12985.conf tls@_require@_ciphers string$**$ unset
12986.index TLS||requiring specific ciphers
12987.index cipher||requiring specific
12988This option controls which ciphers can be used for incoming TLS connections.
12989(The \%smtp%\ transport has an option of the same name for controlling outgoing
12990connections.) This option is expanded for each connection, so can be varied for
12991different clients if required. The value of this option must be a list of
12992permitted cipher suites. The OpenSSL and GnuTLS libraries handle cipher control
12993in somewhat different ways. Details are given in section ~~SECTreqciphsslgnu.
12994.nem
12995
12996.conf tls@_try@_verify@_hosts "host list$**$" unset
12997.index TLS||client certificate verification
12998.index certificate||verification of client
12999See \tls@_verify@_hosts\ below.
13000
13001.conf tls@_verify@_certificates string$**$ unset
13002.index TLS||client certificate verification
13003.index certificate||verification of client
13004The value of this option is expanded, and must then be the absolute path to
13005a file containing permitted certificates for clients that
13006match \tls@_verify@_hosts\ or \tls@_try@_verify@_hosts\. Alternatively, if you
13007are using OpenSSL, you can set \tls@_verify@_certificates\ to the name of a
13008directory containing certificate files. This does not work with GnuTLS; the
13009option must be set to the name of a single file if you are using GnuTLS.
13010
13011.conf tls@_verify@_hosts "host list$**$" unset
13012.index TLS||client certificate verification
13013.index certificate||verification of client
13014This option, along with \tls@_try@_verify@_hosts\, controls the checking of
13015certificates from clients.
13016The expected certificates are defined by \tls@_verify@_certificates\, which
13017must be set. A configuration error occurs if either \tls@_verify@_hosts\ or
13018\tls@_try@_verify@_hosts\ is set and \tls@_verify@_certificates\ is not set.
13019
13020Any client that matches \tls@_verify@_hosts\ is constrained by
13021\tls@_verify@_certificates\. The client must present one of the listed
13022certificates. If it does not, the connection is aborted.
13023
13024A weaker form of checking is provided by \tls@_try@_verify@_hosts\. If a client
13025matches this option (but not \tls@_verify@_hosts\), Exim requests a
13026certificate and checks it against \tls@_verify@_certificates\, but does not
13027abort the connection if there is no certificate or if it does not match. This
13028state can be detected in an ACL, which makes it possible to implement policies
13029such as `accept for relay only if a verified certificate has been received, but
13030accept for local delivery if encrypted, even without a verified certificate'.
13031
13032Client hosts that match neither of these lists are not asked to present
13033certificates.
13034
13035.conf trusted@_groups "string list" unset
13036.index trusted group
13037.index group||trusted
13038If this option is set, any process that is running in one of the listed groups,
13039or which has one of them as a supplementary group, is trusted.
13040The groups can be specified numerically or by name.
13041See section ~~SECTtrustedadmin for details of what trusted callers are
13042permitted to do. If neither \trusted@_groups\ nor \trusted@_users\ is set, only
13043root and the Exim user are trusted.
13044
13045.conf trusted@_users "string list" unset
13046.index trusted user
13047.index user||trusted
13048If this option is set, any process that is running as one of the listed users
13049is trusted.
13050The users can be specified numerically or by name.
13051See section ~~SECTtrustedadmin for details of what trusted callers are
13052permitted to do. If neither \trusted@_groups\ nor \trusted@_users\ is set, only
13053root and the Exim user are trusted.
13054
13055.index uid (user id)||unknown caller
13056.conf unknown@_login string$**$ unset
13057This is a specialized feature for use in unusual configurations. By default, if
13058the uid of the caller of Exim cannot be looked up using \*getpwuid()*\, Exim
13059gives up. The \unknown@_login\ option can be used to set a login name to be
13060used in this circumstance. It is expanded, so values like \user@$caller@_uid\
13061can be set. When \unknown@_login\ is used, the value of \unknown@_username\ is
13062used for the user's real name (gecos field), unless this has been set by the
13063\-F-\ option.
13064
13065.conf unknown@_username string unset
13066See \unknown@_login\.
13067
13068.conf untrusted@_set@_sender "address list$**$" unset
13069.index trusted user
13070.index sender||setting by untrusted user
13071.index untrusted user, setting sender
13072.index user||untrusted setting sender
13073.index envelope sender
13074When an untrusted user submits a message to Exim using the standard input, Exim
13075normally creates an envelope sender address from the user's login and the
13076default qualification domain. Data from the \-f-\ option (for setting envelope
13077senders on non-SMTP messages) or the SMTP \\MAIL\\ command (if \-bs-\ or \-bS-\
13078is used) is ignored.
13079
13080However, untrusted users are permitted to set an empty envelope sender address,
13081to declare that a message should never generate any bounces. For example:
13082.display asis
13083exim -f '<>' user@domain.example
13084.endd
13085The \untrusted@_set@_sender\ option allows you to permit untrusted users to set
13086other envelope sender addresses in a controlled way. When it is set, untrusted
13087users are allowed to set envelope sender addresses that match any of the
13088patterns in the list. Like all address lists, the string is expanded. The
13089identity of the user is in \$sender@_ident$\, so you can, for example, restrict
13090users to setting senders that start with their login ids
13091followed by a hyphen
13092by a setting like this:
13093.display asis
13094untrusted_set_sender = ^$sender_ident-
13095.endd
13096If you want to allow untrusted users to set envelope sender addresses without
13097restriction, you can use
13098.display asis
13099untrusted_set_sender = *
13100.endd
13101The \untrusted@_set@_sender\ option applies to all forms of local input, but
13102only to the setting of the envelope sender. It does not permit untrusted users
13103to use the other options which trusted user can use to override message
13104parameters. Furthermore, it does not stop Exim from removing an existing
13105::Sender:: header in the message, or from adding a ::Sender:: header if
13106necessary. See \local__sender__retain\ and \local@_from@_check\ for ways of
13107overriding these actions. The handling of the ::Sender:: header is also
13108described in section ~~SECTthesenhea.
13109
13110The log line for a message's arrival shows the envelope sender following `<='.
13111For local messages, the user's login always follows, after `U='. In \-bp-\
13112displays, and in the Exim monitor, if an untrusted user sets an envelope sender
13113address, the user's login is shown in parentheses after the sender address.
13114
13115.conf uucp@_from@_pattern string "see below"
13116.index `From' line
13117.index UUCP||`From' line
13118Some applications that pass messages to an MTA via a command line interface use
13119an initial line starting with `From' to pass the envelope sender. In
13120particular, this is used by UUCP software. Exim recognizes such a line by means
13121of a regular expression that is set in \uucp@_from@_pattern\. When the pattern
13122matches, the sender address is constructed by expanding the contents of
13123\uucp@_from@_sender\, provided that the caller of Exim is a trusted user. The
13124default pattern recognizes lines in the following two forms:
13125.display asis
13126 From ph10 Fri Jan 5 12:35 GMT 1996
13127 From ph10 Fri, 7 Jan 97 14:00:00 GMT
13128.endd
13129The pattern can be seen by running
13130.display asis
13131exim -bP uucp_from_pattern
13132.endd
13133It checks only up to the hours and minutes, and allows for a 2-digit or 4-digit
13134year in the second case. The first word after `From' is matched in the regular
13135expression by a parenthesized subpattern. The default value for
13136\uucp@_from@_sender\ is `$1', which therefore just uses this first word (`ph10'
13137in the example above) as the message's sender. See also
13138\ignore@_fromline@_hosts\.
13139
13140.conf uucp@_from@_sender string$**$ "$tt{@$1}"
13141See \uucp@_from@_pattern\ above.
13142
13143.conf warn@_message@_file string unset
13144.index warning of delay||customizing the message
13145.index customizing||warning message
13146This option defines a template file containing paragraphs of text to be used
13147for constructing the warning message which is sent by Exim when a message has
13148been on the queue for a specified amount of time, as specified by
13149\delay@_warning\. Details of the file's contents are given in chapter
13150~~CHAPemsgcust. See also \bounce@_message@_file\.
13151
13152.em
13153.conf write@_rejectlog boolean true
13154.index reject log||disabling
13155If this option is set false, Exim no longer writes anything to the reject log.
13156See chapter ~~CHAPlog for details of what Exim writes to its logs.
13157.nem
13158
13159.endconf
13160
13161
13162
13163.
13164.
13165.
13166.
13167. ============================================================================
13168.chapter Generic options for routers
13169.rset CHAProutergeneric "~~chapter"
13170.set runningfoot "generic router options"
13171.index options||generic, for routers
13172.index generic options||router
13173
13174This chapter describes the generic options that apply to all routers,
13175identifying those that are preconditions. For a general description of how a
13176router operates, see sections ~~SECTrunindrou and ~~SECTrouprecon. The second
13177of these sections specifies the order in which the preconditions are tested.
13178The order of expansion of the options that provide data for a transport is:
13179\errors@_to\, \headers@_add\, \headers@_remove\, \transport\.
13180
13181.startconf
13182
13183.conf address@_data string$**$ unset
13184.index router||data attached to address
13185The string is expanded just before the router is run, that is, after all the
13186precondition tests have succeeded. If the expansion is forced to fail, the
13187router declines. Other expansion failures cause delivery of the address to be
13188deferred.
13189
13190When the expansion succeeds, the value is retained with the address, and can be
13191accessed using the variable \$address@_data$\ in the current router, subsequent
13192routers, and the eventual transport.
13193
13194\**Warning**\: if the current or any subsequent router is a \%redirect%\ router
13195that runs a user's filter file, the contents of \$address@_data$\ are
13196accessible in the filter. This is not normally a problem, because such data is
13197usually either not confidential or it `belongs' to the current user, but if you
13198do put confidential data into \$address@_data$\ you need to remember this
13199point.
13200
13201Even if the router declines or passes, the value of \$address@_data$\ remains
13202with the address, though it can be changed by another \address@_data\ setting
13203on a subsequent router. If a router generates child addresses, the value of
13204\$address@_data$\ propagates to them. This also applies to the special kind of
13205`child' that is generated by a router with the \unseen\ option.
13206
13207The idea of \address@_data\ is that you can use it to look up a lot of data for
13208the address once, and then pick out parts of the data later. For example, you
13209could use a single LDAP lookup to return a string of the form
13210.display asis
13211uid=1234 gid=5678 mailbox=/mail/xyz forward=/home/xyz/.forward
13212.endd
13213In the transport you could pick out the mailbox by a setting such as
13214.display asis
13215file = ${extract{mailbox}{$address_data}}
13216.endd
13217This makes the configuration file less messy, and also reduces the number of
13218lookups. (Exim does cache the most recent lookup, but there may be several
13219addresses in a message which cause lookups to occur.)
13220
13221The \address@_data\ facility is also useful as a means of passing information
13222from one router to another,
13223and from a router to a transport. In addition, if \address@_data\ is set by a
13224router when verifying an address from an ACL, its value is available for use in
13225the rest of the ACL statement.
13226
13227
13228.conf address@_test "boolean (precondition)" true
13229.index \-bt-\ option
13230.index router||skipping when address testing
13231If this option is set false, the router is skipped when routing is being tested
13232by means of the \-bt-\ command line option. This can be a convenience when your
13233first router sends messages to an external scanner, because it saves you
13234having to set the `already scanned' indicator when testing real address
13235routing.
13236
13237
13238.conf cannot@_route@_message string$**$ unset
13239.index router||customizing `cannot route' message
13240.index customizing||`cannot route' message
13241This option specifies a text message that is used when an address cannot be
13242routed because Exim has run out of routers. The default message is `Unrouteable
13243address'. This option is useful only on routers that have \more\ set false, or
13244on the very last router in a configuration, because the value that is used is
13245taken from the last router that inspects an address. For example, using the
13246default configuration, you could put:
13247.display asis
13248cannot_route_message = Remote domain not found in DNS
13249.endd
13250on the first (\%dnslookup%\) router, and
13251.display asis
13252cannot_route_message = Unknown local user
13253.endd
13254on the final router that checks for local users. If string expansion fails, the
13255default message is used.
13256Unless the expansion failure was explicitly forced, a message about the failure
13257is written to the main and panic logs, in addition to the normal message about
13258the routing failure.
13259
13260.conf caseful@_local@_part boolean false
13261.index case of local parts
13262.index router||case of local parts
13263By default, routers handle the local parts of addresses in a case-insensitive
13264manner, though the actual case is preserved for transmission with the message.
13265If you want the case of letters to be significant in a router, you must set
13266this option true. For individual router options that contain address or local
13267part lists (for example, \local@_parts\), case-sensitive matching can be turned
13268on by `+caseful' as a list item. See section ~~SECTcasletadd for more details.
13269
13270
13271.conf check@_local@_user "boolean (precondition)" false
13272.index local user, checking in router
13273.index router||checking for local user
13274When this option is true, Exim checks that the local part of the recipient
13275address (with affixes removed if relevant) is the name of an account on the
13276local system. The check is done by calling the \*getpwnam()*\ function rather
13277than trying to read \(/etc/passwd)\ directly. This means that other methods of
13278holding password data (such as NIS) are supported. If the local part is a local
13279user, \$home$\ is set from the password data, and can be tested in other
13280preconditions that are evaluated after this one
13281(the order of evaluation is given in section ~~SECTrouprecon). However, the
13282value of \$home$\ can be overridden by \router@_home@_directory\.
13283If the local part is not a local user, the router is skipped.
13284
13285If you want to check that the local part is either the name of a local user
13286or matches something else, you cannot combine \check@_local@_user\ with a
13287setting of \local@_parts\, because that specifies the logical \*and*\ of the
13288two conditions. However, you can use a \%passwd%\ lookup in a \local@_parts\
13289setting to achieve this. For example:
13290.display asis
13291local_parts = passwd;$local_part : lsearch;/etc/other/users
13292.endd
13293Note, however, that the side effects of \check@_local@_user\ (such as setting
13294up a home directory) do not occur when a \%passwd%\ lookup is used in a
13295\local@_parts\ (or any other) precondition.
13296
13297.conf condition "string$**$ (precondition)" unset
13298.index router||customized precondition
13299This option specifies a general precondition test that has to succeed for the
13300router to be called. The string is expanded, and if the result is a forced
13301failure or an empty string or one of the strings `0' or `no' or `false'
13302(checked without regard to the case of the letters), the router is skipped, and
13303the address is offered to the next one. This provides a means of applying
13304special-purpose conditions to the running of routers.
13305
13306If the expansion fails (other than forced failure) delivery is deferred. Some
13307of the other options below are common special cases that could in fact be
13308specified using \condition\.
13309Note that \condition\ is the last precondition to be evaluated (see
13310section ~~SECTrouprecon).
13311
13312
13313.conf debug@_print string$**$ unset
13314.index testing||variables in drivers
13315If this option is set and debugging is enabled (see the \-d-\ command line
13316option), the string is expanded and included in the debugging output.
13317If expansion of the string fails, the error message is written to the debugging
13318output, and Exim carries on processing.
13319This option is provided to help with checking out the values of variables and
13320so on when debugging router configurations. For example, if a \condition\
13321option appears not to be working, \debug@_print\ can be used to output the
13322variables it references. The output happens after checks for \domains\,
13323\local@_parts\, and \check@_local@_user\ but before any other preconditions are
13324tested. A newline is added to the text if it does not end with one.
13325
13326
13327.conf disable@_logging boolean false
13328If this option is set true, nothing is logged for any routing errors
13329.em
13330or for any deliveries caused by this router. You should not set this option
13331unless you really, really know what you are doing. See also the generic
13332transport option of the same name.
13333.nem
13334
13335.conf domains "domain list$**$ (precondition)" unset
13336.index router||restricting to specific domains
13337If this option is set, the router is skipped unless the current domain matches
13338the list. If the match is achieved by means of a file lookup, the data that the
13339lookup returned for the domain is placed in \$domain@_data$\ for use in string
13340expansions of the driver's private options.
13341See section ~~SECTrouprecon for a list of the order in which preconditions
13342are evaluated.
13343
13344
13345.conf driver string unset
13346This option must always be set. It specifies which of the available routers is
13347to be used.
13348
13349
13350.conf errors@_to string$**$ unset
13351.index envelope sender
13352.index router||changing address for errors
13353If a router successfully handles an address, it may queue the address for
13354delivery or it may generate child addresses. In both cases, if there is a
13355delivery problem during later processing, the resulting bounce message is sent
13356to the address that results from expanding this string, provided that the
13357address verifies successfully.
13358\errors@_to\ is expanded before \headers@_add\, \headers@_remove\, and
13359\transport\.
13360
13361If the option is unset, or the expansion is forced to fail, or the result of
13362the expansion fails to verify, the errors address associated with the incoming
13363address is used. At top level, this is the envelope sender. A non-forced
13364expansion failure causes delivery to be deferred.
13365
13366If an address for which \errors@_to\ has been set ends up being delivered over
13367SMTP, the envelope sender for that delivery is the \errors@_to\ value, so that
13368any bounces that are generated by other MTAs on the delivery route are also
13369sent there. The most common use of \errors@_to\ is probably to direct mailing
13370list bounces to the manager of the list, as described in section
13371~~SECTmailinglists.
13372
13373The \errors@_to\ setting associated with an address can be overridden if it
13374subsequently passes through other routers that have their own \errors@_to\
13375settings,
13376or if it is delivered by a transport with a \return@_path\ setting.
13377
13378You can set \errors@_to\ to the empty string by either of these settings:
13379.display asis
13380errors_to =
13381errors_to = ""
13382.endd
13383An expansion item that yields an empty string has the same effect. If you do
13384this, a locally detected delivery error for addresses processed by this router
13385no longer gives rise to a bounce message; the error is discarded. If the
13386address is delivered to a remote host, the return path is set to \"<>"\, unless
13387overridden by the \return@_path\ option on the transport.
13388
13389If for some reason you want to discard local errors, but use a non-empty
13390\\MAIL\\ command for remote delivery, you can preserve the original return
13391path in \$address@_data$\ in the router, and reinstate it in the transport by
13392setting \return@_path\.
13393
13394
13395.conf expn "boolean (precondition)" true
13396.index address||testing
13397.index testing||addresses
13398.index \\EXPN\\||router skipping
13399.index router||skipping for \\EXPN\\
13400If this option is turned off, the router is skipped when testing an address
13401as a result of processing an SMTP \\EXPN\\ command. You might, for example,
13402want to turn it off on a router for users' \(.forward)\ files, while leaving it
13403on for the system alias file.
13404See section ~~SECTrouprecon for a list of the order in which preconditions
13405are evaluated.
13406
13407The use of the SMTP \\EXPN\\ command is controlled by an ACL (see chapter
13408~~CHAPACL). When Exim is running an \\EXPN\\ command, it is similar to testing
13409an address with \-bt-\. Compare \\VRFY\\, whose counterpart is \-bv-\.
13410
13411
13412.conf fail@_verify boolean false
13413.index router||forcing verification failure
13414Setting this option has the effect of setting both \fail@_verify@_sender\ and
13415\fail@_verify@_recipient\ to the same value.
13416
13417
13418.conf fail@_verify@_recipient boolean false
13419If this option is true and an address is accepted by this router when
13420verifying a recipient, verification fails.
13421
13422
13423.conf fail@_verify@_sender boolean false
13424If this option is true and an address is accepted by this router when
13425verifying a sender, verification fails.
13426
13427
13428.conf fallback@_hosts "string list" unset
13429.index router||fallback hosts
13430.index fallback||hosts specified on router
13431String expansion is not applied to this option. The argument must be a
13432colon-separated list of host names or IP addresses. If a router queues an
13433address for a remote transport, this host list is associated with the address,
13434and used instead of the transport's fallback host list. If \hosts@_randomize\
13435is set on the transport, the order of the list is randomized for each use. See
13436the \fallback@_hosts\ option of the \%smtp%\ transport for further details.
13437
13438.conf group string$**$ "see below"
13439.index gid (group id)||local delivery
13440.index local transports||uid and gid
13441.index transport||local
13442.index router||setting group
13443When a router queues an address for a transport, and the transport does not
13444specify a group, the group given here is used when running the delivery
13445process.
13446The group may be specified numerically or by name. If expansion fails, the
13447error is logged and delivery is deferred.
13448The default is unset, unless \check@_local@_user\ is set, when the default
13449is taken from the password information. See also \initgroups\ and \user\ and
13450the discussion in chapter ~~CHAPenvironment.
13451
13452
13453.conf headers@_add string$**$ unset
13454.index header lines||adding
13455.index router||adding header lines
13456This option specifies a string of text that is expanded at routing time, and
13457associated with any addresses that are processed by the router
13458when delivering a message. This option has no effect when an address is just
13459being verified.
13460
13461The \headers@_add\ option is expanded after \errors@_to\, but before
13462\headers@_remove\ and \transport\.
13463If the expanded string is empty, or if the expansion is forced to fail, the
13464option has no effect. Other expansion failures are treated as configuration
13465errors. The expanded string must be in the form of one or more RFC 2822 header
13466lines, separated by newlines (coded as `@\n'). For example:
13467.display asis
13468headers_add = X-added-header: added by $primary_hostname\n\
13469 X-added-second: another added header line
13470.endd
13471Exim does not check the syntax of these added header lines. If an address
13472passes through several routers as a result of aliasing or forwarding
13473operations, any \headers@_add\ or \headers@_remove\ specifications are
13474cumulative. This does not apply for multiple routers that result from the use
13475of `unseen'.
13476
13477At transport time, all the original headers listed in \headers__remove\ are
13478removed. If there are multiple instances of any listed header, they are all
13479removed.
13480Then the new headers specified by \headers@_add\ are added, in the order in
13481which they were attached to the address. Finally, any additional headers
13482specified by the transport are added. It is not possible to remove headers
13483added to an address by \headers@_add\.
13484
13485Because the addition does not happen until transport time, header lines that
13486are added by \headers@_add\ are not accessible by means of the \$header@_xxx$\
13487expansion syntax. Conversely, header lines that are removed by
13488\headers@_remove\ remain visible.
13489
13490Addresses with different \headers@_add\ or \headers@_remove\ settings cannot be
13491delivered together in a batch. The \headers@_add\ option cannot be used for a
13492\%redirect%\ router that has the \one@_time\ option set.
13493
13494
13495.conf headers@_remove string$**$ unset
13496.index header lines||removing
13497.index router||removing header lines
13498The string is expanded at routing time and is then associated with any
13499addresses that are processed by the router when delivering a message. This
13500option has no effect when an address is being verified. The \headers@_remove\
13501option is expanded after \errors@_to\ and \headers@_add\, but before
13502\transport\. If the expansion is forced to fail, the option has no effect.
13503Other expansion failures are treated as configuration errors.
13504
13505.em
13506After expansion, the string must consist of a colon-separated list of header
13507names. This is confusing, because header names themselves are often terminated
13508by colons. In this case, the colons are the list separators, not part of the
13509names.
13510.nem
13511For example:
13512.display asis
13513headers_remove = return-receipt-to:acknowledge-to
13514.endd
13515The list is used at transport time as described under \headers@_add\ above. The
13516\headers@_remove\ option cannot be used for a \%redirect%\ router that has the
13517\one@_time\ option set.
13518
13519.conf ignore@_target@_hosts "host list$**$" unset
13520.index IP address||discarding
13521.index router||discarding IP addresses
13522Although this option is a host list, it should normally contain IP address
13523entries rather than names. If any host that is looked up by the router has an
13524IP address that matches an item in this list, Exim behaves as if that IP
13525address did not exist. This option allows you to cope with rogue DNS entries
13526like
13527.display asis
13528remote.domain.example. A 127.0.0.1
13529.endd
13530by setting
13531.display asis
13532ignore_target_hosts = 127.0.0.1
13533.endd
13534on the relevant router.
13535.em
13536If all the hosts found by a \%dnslookup%\ router are discarded in this way, the
13537router declines. In a conventional configuration, an attempt to mail to such a
13538domain would then normally provoke the `unrouteable domain' error, and an
13539attempt to verify an address in the domain would fail.
13540
13541Similarly, if \ignore@_target@_hosts\ is set on an \%ipliteral%\ router, the
13542router declines if presented with one of the listed addresses.
13543.nem
13544
13545This option may also be useful for ignoring link-local and site-local IPv6
13546addresses. Because, like all host lists, the value of \ignore@_target@_hosts\
13547is expanded before use as a list, it is possible to make it dependent on the
13548domain that is being routed.
13549
13550
13551
13552.index additional groups
13553.index groups, additional
13554.index local transports||uid and gid
13555.index transport||local
13556.conf initgroups boolean false
13557If the router queues an address for a transport, and this option is true, and
13558the uid supplied by the router is not overridden by the transport, the
13559\*initgroups()*\ function is called when running the transport to ensure that
13560any additional groups associated with the uid are set up. See also \group\ and
13561\user\ and the discussion in chapter ~~CHAPenvironment.
13562
13563
13564.conf local@_part@_prefix "string list (precondition)" unset
13565.index router||prefix for local part
13566.index prefix||for local part, used in router
13567If this option is set, the router is skipped unless the local part
13568starts with one of the given strings, or \local@_part@_prefix@_optional\ is
13569true.
13570See section ~~SECTrouprecon for a list of the order in which preconditions
13571are evaluated.
13572
13573The list is scanned from left to right, and the first prefix that matches is
13574used. A limited form of wildcard is available; if the prefix begins with an
13575asterisk, it matches the longest possible sequence of arbitrary characters at
13576the start of the local part. An asterisk should therefore always be followed by
13577some character that does not occur in normal local parts.
13578.index multiple mailboxes
13579.index mailbox||multiple
13580Wildcarding can be used to set up multiple user mailboxes, as described in
13581section ~~SECTmulbox.
13582
13583During the testing of the \local@_parts\ option, and while the router is
13584running, the prefix is removed from the local part, and is available in the
13585expansion variable \$local@_part@_prefix$\. If the router accepts the address,
13586this remains true during subsequent delivery.
13587In particular, the local part that is transmitted in the \\RCPT\\ command
13588for LMTP, SMTP, and BSMTP deliveries has the prefix removed by default. This
13589behaviour can be overridden by setting \rcpt@_include@_affixes\ true on the
13590relevant transport.
13591
13592The prefix facility is commonly used to handle local parts of the form
13593\owner-something\. Another common use is to support local parts of the form
13594\real-username\ to bypass a user's \(.forward)\ file -- helpful when trying to
13595tell a user their forwarding is broken -- by placing a router like this one
13596immediately before the router that handles \(.forward)\ files:
13597.display asis
13598real_localuser:
13599 driver = accept
13600 local_part_prefix = real-
13601 check_local_user
13602 transport = local_delivery
13603.endd
13604If both \local@_part@_prefix\ and \local@_part@_suffix\ are set for a router,
13605both conditions must be met if not optional. Care must be taken if wildcards
13606are used in both a prefix and a suffix on the same router. Different
13607separator characters must be used to avoid ambiguity.
13608
13609.conf local@_part@_prefix@_optional boolean false
13610See \local@_part@_prefix\ above.
13611
13612
13613.conf local@_part@_suffix "string list (precondition)" unset
13614.index router||suffix for local part
13615.index suffix for local part, used in router
13616This option operates in the same way as \local@_part@_prefix\, except that the
13617local part must end (rather than start) with the given string, the
13618\local@_part@_suffix@_optional\ option determines whether the suffix is
13619mandatory, and the wildcard $*$ character, if present, must be the last
13620character of the suffix. This option facility is commonly used to handle local
13621parts of the form \something-request\ and multiple user mailboxes of the form
13622\username-foo\.
13623
13624.conf local@_part@_suffix@_optional boolean false
13625See \local@_part@_suffix\ above.
13626
13627
13628.conf local@_parts "local part list$**$ (precondition)" unset
13629.index router||restricting to specific local parts
13630.index local part||checking in router
13631The router is run only if the local part of the address matches the list.
13632See section ~~SECTrouprecon for a list of the order in which preconditions
13633are evaluated, and
13634section ~~SECTlocparlis for a discussion of local part lists. Because the
13635string is expanded, it is possible to make it depend on the domain, for
13636example:
13637.display asis
13638local_parts = dbm;/usr/local/specials/$domain
13639.endd
13640If the match is achieved by a lookup, the data that the lookup returned
13641for the local part is placed in the variable \$local@_part@_data$\ for use in
13642expansions of the router's private options. You might use this option, for
13643example, if you have a large number of local virtual domains, and you want to
13644send all postmaster mail to the same place without having to set up an alias in
13645each virtual domain:
13646.display asis
13647postmaster:
13648 driver = redirect
13649 local_parts = postmaster
13650 data = postmaster@real.domain.example
13651.endd
13652
13653
13654.conf log@_as@_local boolean "see below"
13655.index log||delivery line
13656.index delivery||log line format
13657Exim has two logging styles for delivery, the idea being to make local
13658deliveries stand out more visibly from remote ones. In the `local' style, the
13659recipient address is given just as the local part, without a domain. The use of
13660this style is controlled by this option. It defaults to true for the \%accept%\
13661router, and false for all the others.
13662
13663
13664.conf more boolean$**$ true
13665The result of string expansion for this option must be a valid boolean value,
13666that is, one of the strings `yes', `no', `true', or `false'. Any other result
13667causes an error, and delivery is deferred. If the expansion is forced to fail,
13668the default value for the option (true) is used. Other failures cause delivery
13669to be deferred.
13670
13671If this option is set false, and the router is run, but declines to handle the
13672address, no further routers are tried, routing fails, and the address is
13673bounced.
13674.index \self\ option
13675However, if the router explicitly passes an address to the following router by
13676means of the setting
13677.display asis
13678self = pass
13679.endd
13680or otherwise, the setting of \more\ is ignored. Also, the setting of \more\
13681does not affect the behaviour if one of the precondition tests fails. In that
13682case, the address is always passed to the next router.
13683
13684
13685.conf pass@_on@_timeout boolean false
13686.index timeout||of router
13687.index router||timeout
13688If a router times out during a host lookup, it normally causes deferral of the
13689address. If \pass@_on@_timeout\ is set, the address is passed on to the next
13690router, overriding \no@_more\. This may be helpful for systems that are
13691intermittently connected to the Internet, or those that want to pass to a smart
13692host any messages that cannot immediately be delivered.
13693
13694There are occasional other temporary errors that can occur while doing DNS
13695lookups. They are treated in the same way as a timeout, and this option
13696applies to all of them.
13697
13698
13699.conf pass@_router string unset
13700.index router||go to after `pass'
13701When a router returns `pass', the address is normally handed on to the next
13702router in sequence. This can be changed by setting \pass@_router\ to the name
13703of another router. However (unlike \redirect@_router\) the named router must be
13704below the current router, to avoid loops. Note that this option applies only to
13705the special case of `pass'. It does not apply when a router returns `decline'.
13706
13707
13708.conf redirect@_router string unset
13709.index router||start at after redirection
13710Sometimes an administrator knows that it is pointless to reprocess addresses
13711generated from alias or forward files with the same router again. For
13712example, if an alias file translates real names into login ids there is no
13713point searching the alias file a second time, especially if it is a large file.
13714
13715The \redirect@_router\ option can be set to the name of any router instance. It
13716causes the routing of any generated addresses to start at the named router
13717instead of at the first router. This option has no effect if the router in
13718which it is set does not generate new addresses.
13719
13720
13721.conf require@_files "string list$**$ (precondition)" unset
13722.index file||requiring for router
13723.index router||requiring file existence
13724This option provides a general mechanism for predicating the running of a
13725router on the existence or non-existence of certain files or directories.
13726Before running a router, as one of its precondition tests, Exim works its way
13727through the \require@_files\ list, expanding each item separately.
13728
13729Because the list is split before expansion, any colons in expansion items must
13730be doubled, or the facility for using a different list separator must be used.
13731If any expansion is forced to fail, the item is ignored. Other expansion
13732failures cause routing of the address to be deferred.
13733
13734If any expanded string is empty, it is ignored. Otherwise, except as described
13735below, each string must be a fully qualified file path, optionally preceded by
13736`!'. The paths are passed to the \*stat()*\ function to test for the existence
13737of the files or directories. The router is skipped if any paths not preceded by
13738`!' do not exist, or if any paths preceded by `!' do exist.
13739
13740.index NFS
13741If \*stat()*\ cannot determine whether a file exists or not, delivery of
13742the message is deferred. This can happen when NFS-mounted filesystems are
13743unavailable.
13744
13745This option is checked after the \domains\, \local@_parts\, and \senders\
13746options, so you cannot use it to check for the existence of a file in which to
13747look up a domain, local part, or sender. (See section ~~SECTrouprecon for a
13748full list of the order in which preconditions are evaluated.) However, as
13749these options are all expanded, you can use the \exists\ expansion condition to
13750make such tests. The \require@_files\ option is intended for checking files
13751that the router may be going to use internally, or which are needed by a
13752transport (for example \(.procmailrc)\).
13753
13754During delivery, the \*stat()*\ function is run as root, but there is a
13755facility for some checking of the accessibility of a file by another user.
13756This is not a proper permissions check, but just a `rough' check that
13757operates as follows:
13758
13759If an item in a \require@_files\ list does not contain any forward slash
13760characters, it is taken to be the user (and optional group, separated by a
13761comma) to be checked for subsequent files in the list. If no group is specified
13762but the user is specified symbolically, the gid associated with the uid is
13763used. For example:
13764.display asis
13765require_files = mail:/some/file
13766require_files = $local_part:$home/.procmailrc
13767.endd
13768If a user or group name in a \require@_files\ list does not exist, the
13769\require@_files\ condition fails.
13770
13771Exim performs the check by scanning along the components of the file path, and
13772checking the access for the given uid and gid. It checks for `x' access on
13773directories, and `r' access on the final file. Note that this means that file
13774access control lists, if the operating system has them, are ignored.
13775
13776\**Warning 1**\: When the router is being run to verify addresses for an
13777incoming SMTP message, Exim is not running as root, but under its own uid. This
13778may affect the result of a \require@_files\ check. In particular, \*stat()*\
13779may yield the error \\EACCES\\ (`Permission denied'). This means that the Exim
13780user is not permitted to read one of the directories on the file's path.
13781
13782\**Warning 2**\: Even when Exim is running as root while delivering a message,
13783\*stat()*\ can yield \\EACCES\\ for a file on an NFS directory that is mounted
13784without root access.
13785
13786In both cases,
13787the default action is to consider this a configuration error, and routing is
13788deferred because the existence or non-existence of the file cannot be
13789determined. However, in some circumstances it may be desirable to treat this
13790condition as if the file did not exist. If the file name (or the exclamation
13791mark that precedes the file name for non-existence) is preceded by a plus sign,
13792the \\EACCES\\ error is treated as if the file did not exist. For example:
13793.display asis
13794require_files = +/some/file
13795.endd
13796If the router is not an essential part of verification (for example, it
13797handles users' \(.forward)\ files), another solution is to set the \verify\
13798option false so that the router is skipped when verifying.
13799
13800
13801.conf retry@_use@_local@_part boolean "see below"
13802.index hints database||retry keys
13803.index local part||in retry keys
13804When a delivery suffers a temporary routing failure, a retry record is created
13805in Exim's hints database. For addresses whose routing depends only on the
13806domain, the key for the retry record should not involve the local part, but for
13807other addresses, both the domain and the local part should be included.
13808Usually, remote routing is of the former kind, and local routing is of the
13809latter kind.
13810
13811This option controls whether the local part is used to form the key for retry
13812hints for addresses that suffer temporary errors while being handled by this
13813router. The default value is true for any router that has \check@_local@_user\
13814set, and false otherwise. Note that this option does not apply to hints keys
13815for transport delays; they are controlled by a generic transport option of the
13816same name.
13817
13818.em
13819The setting of \retry@_use@_local@_part\ applies only to the router on which it
13820appears. If the router generates child addresses, they are routed
13821independently; this setting does not become attached to them.
13822.nem
13823
13824
13825.conf router@_home@_directory string$**$ unset
13826.index router||home directory for
13827.index home directory||for router
13828This option sets a home directory for use while the router is running. (Compare
13829\transport__home@_directory\, which sets a home directory for later
13830transporting.) In particular, if used on a \%redirect%\ router, this option
13831sets a value for \$home$\ while a filter is running. The value is expanded;
13832forced expansion failure causes the option to be ignored -- other failures
13833cause the router to defer.
13834
13835Expansion of \router@_home@_directory\ happens immediately after the
13836\check@_local@_user\ test (if configured), before any further expansions take
13837place.
13838(See section ~~SECTrouprecon for a list of the order in which preconditions
13839are evaluated.)
13840While the router is running, \router__home@_directory\ overrides the value of
13841\$home$\ that came from \check@_local@_user\.
13842
13843When a router accepts an address and routes it to a transport (including the
13844cases when a redirect router generates a pipe, file, or autoreply delivery),
13845the home directory setting for the transport is taken from the first of these
13846values that is set:
13847.numberpars $.
13848The \home@_directory\ option on the transport;
13849.nextp
13850The \transport@_home@_directory\ option on the router;
13851.nextp
13852The password data if \check@_local@_user\ is set on the router;
13853.nextp
13854The \router@_home@_directory\ option on the router.
13855.endp
13856In other words, \router@_home@_directory\ overrides the password data for the
13857router, but not for the transport.
13858
13859
13860.conf self string "freeze"
13861.index MX record||pointing to local host
13862.index local host||MX pointing to
13863This option applies to those routers that use a recipient address to find a
13864list of remote hosts. Currently, these are the \%dnslookup%\, \%ipliteral%\,
13865and \%manualroute%\ routers.
13866Certain configurations of the \%queryprogram%\ router can also specify a list
13867of remote hosts.
13868Usually such routers are configured to send the message to a remote host via an
13869\%smtp%\ transport. The \self\ option specifies what happens when the first
13870host on the list turns out to be the local host.
13871The way in which Exim checks for the local host is described in section
13872~~SECTreclocipadd.
13873
13874Normally this situation indicates either an error in Exim's configuration (for
13875example, the router should be configured not to process this domain), or an
13876error in the DNS (for example, the MX should not point to this host). For this
13877reason, the default action is to log the incident, defer the address, and
13878freeze the message. The following alternatives are provided for use in special
13879cases:
13880.numberpars $.
13881\defer\
13882.newline
13883Delivery of the message is tried again later, but the message is not frozen.
13884.nextp
13885\reroute: <<domain>>\
13886.newline
13887The domain is changed to the given domain, and the address is passed back to
13888be reprocessed by the routers. No rewriting of headers takes place. This
13889behaviour is essentially a redirection.
13890.nextp
13891\reroute: rewrite: <<domain>>\
13892.newline
13893The domain is changed to the given domain, and the address is passed back to be
13894reprocessed by the routers. Any headers that contain the original domain are
13895rewritten.
13896.nextp
13897\pass\
13898.newline
13899The router passes the address to the next router, or to the router named in the
13900\pass@_router\ option if it is set.
13901.index \more\ option
13902This overrides \no@_more\.
13903
13904During subsequent routing and delivery, the variable
13905\$self@_hostname$\ contains the name of the local host that the router
13906encountered. This can be used to distinguish between different cases for hosts
13907with multiple names. The combination
13908.display asis
13909self = pass
13910no_more
13911.endd
13912ensures that only those addresses that routed to the local host are passed on.
13913Without \no@_more\, addresses that were declined for other reasons would also
13914be passed to the next router.
13915.nextp
13916\fail\
13917.newline
13918Delivery fails and an error report is generated.
13919.nextp
13920\send\
13921.newline
13922.index local host||sending to
13923The anomaly is ignored and the address is queued for the transport. This
13924setting should be used with extreme caution. For an \%smtp%\ transport, it makes
13925sense only in cases where the program that is listening on the SMTP port is not
13926this version of Exim. That is, it must be some other MTA, or Exim with a
13927different configuration file that handles the domain in another way.
13928.endp
13929
13930.conf senders "address list$**$ (precondition)" unset
13931.index router||checking senders
13932If this option is set, the router is skipped unless the message's sender
13933address matches something on the list.
13934See section ~~SECTrouprecon for a list of the order in which preconditions
13935are evaluated.
13936
13937There are issues concerning verification when the running of routers is
13938dependent on the sender. When Exim is verifying the address in an \errors@_to\
13939setting, it sets the sender to the null string. When using the \-bt-\ option to
13940check a configuration file, it is necessary also to use the \-f-\ option to set
13941an appropriate sender. For incoming mail, the sender is unset when verifying
13942the sender, but is available when verifying any recipients. If the SMTP
13943\\VRFY\\ command is enabled, it must be used after \\MAIL\\ if the sender
13944address matters.
13945
13946.conf translate@_ip@_address string$**$ unset
13947.index IP address||translating
13948.index packet radio
13949.index router||IP address translation
13950There exist some rare networking situations (for example, packet radio) where
13951it is helpful to be able to translate IP addresses generated by normal routing
13952mechanisms into other IP addresses, thus performing a kind of manual IP
13953routing. This should be done only if the normal IP routing of the TCP/IP stack
13954is inadequate or broken. Because this is an extremely uncommon requirement, the
13955code to support this option is not included in the Exim binary unless
13956\\SUPPORT__TRANSLATE__IP__ADDRESS\\=yes is set in \(Local/Makefile)\.
13957
13958The \translate@_ip@_address\ string is expanded for every IP address generated
13959by the router, with the generated address set in \$host@_address$\. If the
13960expansion is forced to fail, no action is taken.
13961For any other expansion error, delivery of the message is deferred.
13962If the result of the expansion is an IP address, that replaces the original
13963address; otherwise the result is assumed to be a host name -- this is looked up
13964using \*gethostbyname()*\ (or \*getipnodebyname()*\ when available) to produce
13965one or more replacement IP addresses. For example, to subvert all IP addresses
13966in some specific networks, this could be added to a router:
13967.display
13968$smc{translate@_ip@_address = @\
13969 @$@{lookup@{@$@{mask:@$host@_address/26@}@}lsearch@{/some/file@}@{@$value@}fail@}}
13970.endd
13971The file would contain lines like
13972.display asis
1397310.2.3.128/26 some.host
1397410.8.4.34/26 10.44.8.15
13975.endd
13976You should not make use of this facility unless you really understand what you
13977are doing.
13978
13979
13980.conf transport string$**$ unset
13981This option specifies the transport to be used when a router accepts an address
13982and sets it up for delivery. A transport is never needed if a router is used
13983only for verification. The value of the option is expanded at routing time,
13984after the expansion of \errors@_to\,
13985\headers@_add\, and \headers@_remove\,
13986and result must be the name of one of the configured transports. If it is
13987not, delivery is deferred.
13988
13989The \transport\ option is not used by the \%redirect%\ router, but it does have
13990some private options that set up transports for pipe and file deliveries (see
13991chapter ~~CHAPredirect).
13992
13993
13994.conf transport@_current@_directory string$**$ unset
13995.index current directory for local transport
13996This option associates a current directory with any address that is routed
13997to a local transport. This can happen either because a transport is
13998explicitly configured for the router, or because it generates a delivery to a
13999file or a pipe. During the delivery process (that is, at transport time), this
14000option string is expanded and is set as the current directory, unless
14001overridden by a setting on the transport.
14002If the expansion fails for any reason, including forced failure, an error is
14003logged, and delivery is deferred.
14004See chapter ~~CHAPenvironment for details of the local delivery environment.
14005
14006
14007
14008.conf transport@_home@_directory string$**$ "see below"
14009.index home directory||for local transport
14010This option associates a home directory with any address that is routed to a
14011local transport. This can happen either because a transport is explicitly
14012configured for the router, or because it generates a delivery to a file or a
14013pipe. During the delivery process (that is, at transport time), the option
14014string is expanded and is set as the home directory, unless overridden by a
14015setting of \home@_directory\ on the transport.
14016If the expansion fails for any reason, including forced failure, an error is
14017logged, and delivery is deferred.
14018
14019If the transport does not specify a home directory, and
14020\transport@_home@_directory\ is not set for the router, the home directory for
14021the tranport is taken from the password data if \check@_local@_user\ is set for
14022the router. Otherwise it is taken from \router@_home@_directory\ if that option
14023is set; if not, no home directory is set for the transport.
14024
14025See chapter ~~CHAPenvironment for further details of the local delivery
14026environment.
14027
14028
14029
14030.conf unseen boolean$**$ false
14031.index router||carrying on after success
14032The result of string expansion for this option must be a valid boolean value,
14033that is, one of the strings `yes', `no', `true', or `false'. Any other result
14034causes an error, and delivery is deferred. If the expansion is forced to fail,
14035the default value for the option (false) is used. Other failures cause delivery
14036to be deferred.
14037
14038When this option is set true, routing does not cease if the router accepts the
14039address. Instead, a copy of the incoming address is passed to the next router,
14040overriding a false setting of \more\. There is little point in setting \more\
14041false if \unseen\ is always true, but it may be useful in cases when the value
14042of \unseen\ contains expansion items (and therefore, presumably, is sometimes
14043true and sometimes false).
14044
14045The \unseen\ option can be used to cause
14046.index copy of message (\unseen\ option)
14047copies of messages to be delivered to some other destination, while also
14048carrying out a normal delivery. In effect, the current address is made into a
14049`parent' that has two children -- one that is delivered as specified by this
14050router, and a clone that goes on to be routed further.
14051
14052Header lines added to the address (or specified for removal) by this router or
14053by previous routers affect the `unseen' copy of the message only. The clone
14054that continues to be processed by further routers starts with no added headers
14055and none specified for removal.
14056
14057However, any data that was set by the \address@_data\ option in the current or
14058previous routers is passed on. Setting this option has a similar effect to the
14059\unseen\ command qualifier in filter files.
14060
14061
14062.conf user string$**$ "see below"
14063.index uid (user id)||local delivery
14064.index local transports||uid and gid
14065.index transport||local
14066.index router||user for filter processing
14067.index filter||user for processing
14068When a router queues an address for a transport, and the transport does not
14069specify a user, the user given here is used when running the delivery process.
14070The user may be specified numerically or by name. If expansion fails, the
14071error is logged and delivery is deferred.
14072This user is also used by the \%redirect%\ router when running a filter file.
14073The default is unset, except when \check@_local@_user\ is set. In this case,
14074the default is taken from the password information. If the user is specified as
14075a name, and \group\ is not set, the group associated with the user is used. See
14076also \initgroups\ and \group\ and the discussion in chapter ~~CHAPenvironment.
14077
14078
14079.conf verify "boolean (precondition)" true
14080Setting this option has the effect of setting \verify@_sender\ and
14081\verify@_recipient\ to the same value.
14082
14083.conf verify@_only "boolean (precondition)" false
14084.index \\EXPN\\||with \verify@_only\
14085.index \-bv-\ option
14086.index router||used only when verifying
14087If this option is set, the router is used only when verifying an address or
14088testing with the \-bv-\ option, not when actually doing a delivery, testing
14089with the \-bt-\ option, or running the SMTP \\EXPN\\ command. It can be further
14090restricted to verifying only senders or recipients by means of \verify@_sender\
14091and \verify@_recipient\.
14092
14093\**Warning**\: When the router is being run to verify addresses for an incoming
14094SMTP message, Exim is not running as root, but under its own uid. If the router
14095accesses any files, you need to make sure that they are accessible to the Exim
14096user or group.
14097
14098.conf verify@_recipient "boolean (precondition)" true
14099If this option is false, the router is skipped when verifying recipient
14100addresses
14101or testing recipient verification using \-bv-\.
14102See section ~~SECTrouprecon for a list of the order in which preconditions
14103are evaluated.
14104
14105.conf verify@_sender "boolean (precondition)" true
14106If this option is false, the router is skipped when verifying sender addresses
14107or testing sender verification using \-bvs-\.
14108See section ~~SECTrouprecon for a list of the order in which preconditions
14109are evaluated.
14110
14111.endconf
14112
14113
14114
14115
14116
14117.
14118.
14119.
14120.
14121. ============================================================================
14122.chapter The accept router
14123.set runningfoot "accept router"
14124.index \%accept%\ router
14125.index routers||\%accept%\
14126The \%accept%\ router has no private options of its own. Unless it is being used
14127purely for verification (see \verify@_only\) a transport is required to be
14128defined by the generic \transport\ option. If the preconditions that are
14129specified by generic options are met, the router accepts the address and queues
14130it for the given transport. The most common use of this router is for setting
14131up deliveries to local mailboxes. For example:
14132.display asis
14133localusers:
14134 driver = accept
14135 domains = mydomain.example
14136 check_local_user
14137 transport = local_delivery
14138.endd
14139The \domains\ condition in this example checks the domain of the address, and
14140\check@_local@_user\ checks that the local part is the login of a local user.
14141When both preconditions are met, the \%accept%\ router runs, and queues the
14142address for the \%local@_delivery%\ transport.
14143
14144
14145
14146
14147
14148
14149.
14150.
14151.
14152.
14153. ============================================================================
14154.chapter The dnslookup router
14155.rset CHAPdnslookup "~~chapter"
14156.set runningfoot "dnslookup router"
14157.index \%dnslookup%\ router
14158.index routers||\%dnslookup%\
14159The \%dnslookup%\ router looks up the hosts that handle mail for the given
14160domain in the DNS. A transport must always be set for this router, unless
14161\verify@_only\ is set.
14162
14163.em
14164If SRV support is configured (see \check@_srv\ below), Exim first searches for
14165SRV records. If none are found, or if SRV support is not configured,
14166MX records are looked up. If no MX records exist, address records are sought.
14167However, \mx@_domains\ can be set to disable the direct use of address records.
14168
14169MX records of equal priority are sorted by Exim into a random order. Exim then
14170looks for address records for the host names obtained from MX or SRV records.
14171When a host has more than one IP address, they are sorted into a random order,
14172except that IPv6 addresses are always sorted before IPv4 addresses. If all the
14173IP addresses found are discarded by a setting of the \ignore@_target@_hosts\
14174generic option, the router declines.
14175
14176Unless they have the highest priority (lowest MX value), MX records that point
14177to the local host, or to any host name that matches \hosts__treat__as__local\,
14178are discarded, together with any other MX records of equal or lower priority.
14179.nem
14180
14181.index MX record||pointing to local host
14182.index local host||MX pointing to
14183.index \self\ option||in \%dnslookup%\ router
14184If the host pointed to by the highest priority MX record, or looked up as an
14185address record, is the local host, or matches \hosts__treat__as__local\, what
14186happens is controlled by the generic \self\ option.
14187
14188There are a number of private options that can be used to vary the way the DNS
14189lookup is handled.
14190
14191
14192.startconf
14193.index options||\%dnslookup%\ router
14194.conf check@_secondary@_mx boolean false
14195.index MX record||checking for secondary
14196If this option is set, the router declines unless the local host is found in
14197(and removed from) the list of hosts obtained by MX lookup. This can be used to
14198process domains for which the local host is a secondary mail exchanger
14199differently to other domains. The way in which Exim decides whether a host is
14200the local host is described in section ~~SECTreclocipadd.
14201
14202.em
14203.conf check@_srv string$**$ unset
14204.index SRV record||enabling use of
14205The dnslookup router supports the use of SRV records (see RFC 2782) in
14206addition to MX and address records. The support is disabled by default. To
14207enable SRV support, set the \check@_srv\ option to the name of the service
14208required. For example,
14209.display asis
14210check_srv = smtp
14211.endd
14212looks for SRV records that refer to the normal smtp service. The option is
14213expanded, so the service name can vary from message to message or address
14214to address. This might be helpful if SRV records are being used for a
14215submission service. If the expansion is forced to fail, the \check@_srv\
14216option is ignored, and the router proceeds to look for MX records in the
14217normal way.
14218
14219When the expansion succeeds, the router searches first for SRV records for
14220the given service (it assumes TCP protocol). A single SRV record with the
14221host name \"."\ indicates `no such service for this domain'; if this is
14222encountered, the router declines. If other kinds of SRV record are found,
14223they are used to construct a host list for delivery according to the rules
14224of RFC 2782. MX records are not sought in this case.
14225
14226However, when no SRV records are found, MX records (and address records)
14227are sought in the traditional way. In other words, SRV records take
14228precedence over MX records, just as MX records take precedence over address
14229records. Note that this behaviour is not sanctioned by RFC 2782, though a
14230previous draft RFC defined it. It is apparently believed that MX records
14231are sufficient for email and that SRV records should not be used for this
14232purpose. However, SRV records have an additional `weight' feature which
14233some people might find useful when trying to split an SMTP load between
14234hosts of different power.
14235.nem
14236
14237.conf mx@_domains "domain list$**$" unset
14238.index MX record||required to exist
14239.index SRV record||required to exist
14240.em
14241A domain that matches \mx@_domains\ is required to have either an MX or an SRV
14242record in order to be recognised. (The name of this option could be improved.)
14243.nem
14244For example, if all the mail hosts in \*fict.example*\ are known to have MX
14245records, except for those in \*discworld.fict.example*\, you could use this
14246setting:
14247.display asis
14248mx_domains = ! *.discworld.fict.example : *.fict.example
14249.endd
14250This specifies that messages addressed to a domain that matches the list but
14251has no MX record should be bounced immediately instead of being routed using
14252the address record.
14253
14254.conf qualify@_single boolean true
14255.index DNS||resolver options
14256.index DNS||qualifying single-component names
14257When this option is true, the resolver option \\RES@_DEFNAMES\\ is set for DNS
14258lookups. Typically, but not standardly, this causes the resolver to qualify
14259single-component names with the default domain. For example, on a machine
14260called \*dictionary.ref.example*\, the domain \*thesaurus*\ would be changed to
14261\*thesaurus.ref.example*\ inside the resolver. For details of what your resolver
14262actually does, consult your man pages for \*resolver*\ and \*resolv.conf*\.
14263
14264
14265.conf rewrite@_headers boolean true
14266.index rewriting||header lines
14267.index header lines||rewriting
14268If the domain name in the address that is being processed is not fully
14269qualified, it may be expanded to its full form by a DNS lookup. For example, if
14270an address is specified as \*dormouse@@teaparty*\, the domain might be
14271expanded to \*teaparty.wonderland.fict.example*\. Domain expansion can also
14272occur as a result of setting the \widen@_domains\ option. If \rewrite@_headers\
14273is true, all occurrences of the abbreviated domain name in any ::Bcc::, ::Cc::,
14274::From::, ::Reply-to::, ::Sender::, and ::To:: header lines of the message are
14275rewritten with the full domain name.
14276
14277This option should be turned off only when it is known that no message is
14278ever going to be sent outside an environment where the abbreviation makes
14279sense.
14280
14281When an MX record is looked up in the DNS and matches a wildcard record, name
14282servers normally return a record containing the name that has been looked up,
14283making it impossible to detect whether a wildcard was present or not. However,
14284some name servers have recently been seen to return the wildcard entry. If the
14285name returned by a DNS lookup begins with an asterisk, it is not used for
14286header rewriting.
14287
14288.conf same@_domain@_copy@_routing boolean false
14289.index address||copying routing
14290Addresses with the same domain are normally routed by the \%dnslookup%\ router
14291to the same list of hosts. However, this cannot be presumed, because the router
14292options and preconditions may refer to the local part of the address. By
14293default, therefore, Exim routes each address in a message independently. DNS
14294servers run caches, so repeated DNS lookups are not normally expensive, and in
14295any case, personal messages rarely have more than a few recipients.
14296
14297If you are running mailing lists with large numbers of subscribers at the same
14298domain, and you are using a \%dnslookup%\ router which is independent of the
14299local part, you can set \same__domain__copy@_routing\ to bypass repeated DNS
14300lookups for identical domains in one message. In this case, when \%dnslookup%\
14301routes an address to a remote transport, any other unrouted addresses in the
14302message that have the same domain are automatically given the same routing
14303without processing them independently,
14304provided the following conditions are met:
14305.numberpars $.
14306No router that processed the address specified \headers@_add\ or
14307\headers@_remove\.
14308.nextp
14309The router did not change the address in any way, for example, by `widening'
14310the domain.
14311.endp
14312
14313
14314.conf search@_parents boolean false
14315.index DNS||resolver options
14316When this option is true, the resolver option \\RES@_DNSRCH\\ is set for DNS
14317lookups. This is different from the \qualify@_single\ option in that it applies
14318to domains containing dots. Typically, but not standardly, it causes the
14319resolver to search for the name in the current domain and in parent domains.
14320For example, on a machine in the \*fict.example*\ domain, if looking up
14321\*teaparty.wonderland*\ failed, the resolver would try
14322\*teaparty.wonderland.fict.example*\. For details of what your resolver
14323actually does, consult your man pages for \*resolver*\ and \*resolv.conf*\.
14324
14325Setting this option true can cause problems in domains that have a wildcard MX
14326record, because any domain that does not have its own MX record matches the
14327local wildcard.
14328
14329.conf widen@_domains "string list" unset
14330.index domain||partial, widening
14331If a DNS lookup fails and this option is set, each of its strings in turn is
14332added onto the end of the domain, and the lookup is tried again. For example,
14333if
14334.display asis
14335widen_domains = fict.example:ref.example
14336.endd
14337is set and a lookup of \*klingon.dictionary*\ fails,
14338\*klingon.dictionary.fict.example*\ is looked up, and if this fails,
14339\*klingon.dictionary.ref.example*\ is tried. Note that the \qualify@_single\
14340and \search@_parents\ options can cause some widening to be undertaken inside
14341the DNS resolver.
14342
14343.endconf
14344
14345.em
14346.section Effect of qualify@_single and search@_parents
14347When a domain from an envelope recipient is changed by the resolver as a result
14348of the \qualify@_single\ or \search@_parents\ options, Exim rewrites the
14349corresponding address in the message's header lines unless \rewrite@_headers\
14350is set false. Exim then re-routes the address, using the full domain.
14351
14352These two options affect only the DNS lookup that takes place inside the router
14353for the domain of the address that is being routed. They do not affect lookups
14354such as that implied by
14355.display asis
14356domains = @mx_any
14357.endd
14358that may happen while processing a router precondition before the router is
14359entered. No widening ever takes place for these lookups.
14360.nem
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370.
14371.
14372.
14373.
14374. ============================================================================
14375.chapter The ipliteral router
14376.set runningfoot "ipliteral router"
14377.index \%ipliteral%\ router
14378.index domain literal||routing
14379.index routers||\%ipliteral%\
14380This router has no private options. Unless it is being used purely for
14381verification (see \verify@_only\) a transport is required to be defined by the
14382generic \transport\ option. The router accepts the address if its domain part
14383takes the form of an RFC 2822 domain literal, that is, an IP address enclosed
14384in square brackets. For example, this router handles the address
14385.display asis
14386root@[192.168.1.1]
14387.endd
14388by setting up delivery to the host with that IP address.
14389
14390.em
14391If the IP address matches something in \ignore@_target@_hosts\, the router
14392declines.
14393.nem
14394.index \self\ option||in \%ipliteral%\ router
14395If an IP literal turns out to refer to the local host, the generic \self\
14396option determines what happens.
14397
14398The RFCs require support for domain literals; however, their use is
14399controversial in today's Internet. If you want to use this router, you must
14400also set the main configuration option \allow@_domain@_literals\. Otherwise,
14401Exim will not recognize the domain literal syntax in addresses.
14402
14403
14404
14405.
14406.
14407.
14408.
14409. ============================================================================
14410.chapter The iplookup router
14411.set runningfoot "iplookup router"
14412.index \%iplookup%\ router
14413.index routers||\%iplookup%\
14414The \%iplookup%\ router was written to fulfil a specific requirement in
14415Cambridge University. For this reason, it is not included in the binary of Exim
14416by default. If you want to include it, you must set
14417.display asis
14418ROUTER_IPLOOKUP=yes
14419.endd
14420in your \(Local/Makefile)\ configuration file.
14421
14422The \%iplookup%\ router routes an address by sending it over a TCP or UDP
14423connection to one or more specific hosts. The host can then return the same or
14424a different address -- in effect rewriting the recipient address in the
14425message's envelope. The new address is then passed on to subsequent routers.
14426
14427
14428If this process fails, the address can be passed on to
14429other routers, or delivery can be deferred.
14430
14431Background, for those that are interested: We have an Oracle database of all
14432Cambridge users, and one of the items of data it maintains for each user is
14433where to send mail addressed to \*user@@cam.ac.uk*\. The MX records for
14434\*cam.ac.uk*\ point to a central machine that has a large alias list that is
14435abstracted from the database. Mail from outside is switched by this system, and
14436originally internal mail was also done this way. However, this resulted in a
14437fair number of messages travelling from some of our larger systems to the
14438switch and back again. The Oracle machine now runs a UDP service that can be
14439called by the \%iplookup%\ router in Exim to find out where \*user@@cam.ac.uk*\
14440addresses really have to go; this saves passing through the central switch, and
14441in many cases saves doing any remote delivery at all.
14442
14443Since \%iplookup%\ is just a rewriting router, a transport must not be
14444specified for it.
14445
14446.startconf
14447.index options||\%iplookup%\ router
14448
14449.conf hosts string unset
14450This option must be supplied. Its value is a colon-separated list of host
14451names. The hosts are looked up using \*gethostbyname()*\
14452(or \*getipnodebyname()*\ when available)
14453and are tried in order until one responds to the query. If none respond, what
14454happens is controlled by \optional\.
14455
14456.conf optional boolean false
14457If \optional\ is true, if no response is obtained from any host, the address is
14458passed to the next router, overriding \no@_more\. If \optional\ is false,
14459delivery to the address is deferred.
14460
14461.conf port integer 0
14462.index port||\%iplookup%\ router
14463This option must be supplied. It specifies the port number for the TCP or UDP
14464call.
14465
14466.conf protocol string "udp"
14467This option can be set to `udp' or `tcp' to specify which of the two protocols
14468is to be used.
14469
14470.conf query string$**$ "$tt{@$local@_part@@@$domain @$local@_part@@@$domain}"
14471This defines the content of the query that is sent to the remote hosts. The
14472repetition serves as a way of checking that a response is to the correct query
14473in the default case (see \response@_pattern\ below).
14474
14475.conf reroute string$**$ unset
14476If this option is not set, the rerouted address is precisely the byte string
14477returned by the remote host, up to the first white space, if any. If set, the
14478string is expanded to form the rerouted address. It can include parts matched
14479in the response by \response@_pattern\ by means of numeric variables such as
14480\$1$\, \$2$\, etc. The variable \$0$\ refers to the entire input string,
14481whether or not a pattern is in use. In all cases, the rerouted address must end
14482up in the form \*local@_part@@domain*\.
14483
14484.conf response@_pattern string unset
14485This option can be set to a regular expression that is applied to the string
14486returned from the remote host. If the pattern does not match the response, the
14487router declines. If \response@_pattern\ is not set, no checking of the response
14488is done, unless the query was defaulted, in which case there is a check that
14489the text returned after the first white space is the original address. This
14490checks that the answer that has been received is in response to the correct
14491question. For example, if the response is just a new domain, the following
14492could be used:
14493.display asis
14494response_pattern = ^([^@]+)$
14495reroute = $local_part@$1
14496.endd
14497
14498.conf timeout time 5s
14499This specifies the amount of time to wait for a response from the remote
14500machine. The same timeout is used for the \*connect()*\ function for a TCP
14501call. It does not apply to UDP.
14502
14503.endconf
14504
14505
14506
14507
14508.
14509.
14510.
14511.
14512. ============================================================================
14513.chapter The manualroute router
14514.set runningfoot "manualroute router"
14515.index \%manualroute%\ router
14516.index routers||\%manualroute%\
14517.index domain||manually routing
14518The \%manualroute%\ router is so-called because it provides a way of manually
14519routing an address according to its domain. It is mainly used when you want to
14520route addresses to remote hosts according to your own rules, bypassing the
14521normal DNS routing that looks up MX records. However, \%manualroute%\ can also
14522route to local transports, a facility that may be useful if you want to save
14523messages for dial-in hosts in local files.
14524
14525The \%manualroute%\ router compares a list of domain patterns with the domain it
14526is trying to route. If there is no match, the router declines. Each pattern has
14527associated with it a list of hosts and some other optional data, which may
14528include a transport. The combination of a pattern and its data is called a
14529`routing rule'. For patterns that do not have an associated transport, the
14530generic \transport\ option must specify a transport, unless the router is being
14531used purely for verification (see \verify@_only\).
14532
14533In the case of verification, matching the domain pattern is sufficient for the
14534router to accept the address. When actually routing an address for delivery,
14535an address that matches a domain pattern is queued for the associated
14536transport. If the transport is not a local one, a host list must be associated
14537with the pattern; IP addresses are looked up for the hosts, and these are
14538passed to the transport along with the mail address. For local transports, a
14539host list is optional. If it is present, it is passed in \$host$\ as a single
14540text string.
14541
14542The list of routing rules can be provided as an inline string in \route@_list\,
14543or the data can be obtained by looking up the domain in a file or database by
14544setting \route@_data\. Only one of these settings may appear in any one
14545instance of \%manualroute%\. The format of routing rules is described below,
14546following the list of private options.
14547
14548.section Private options for manualroute
14549.rset SECTprioptman "~~chapter.~~section"
14550
14551The private options for the \%manualroute%\ router are as follows:
14552
14553.startconf
14554.index options||\%manualroute%\ router
14555
14556.conf host@_find@_failed string "freeze"
14557This option controls what happens when \%manualroute%\ tries to find an IP
14558address for a host, and the host does not exist. The option can be set to one
14559of
14560.display asis
14561decline
14562defer
14563fail
14564freeze
14565pass
14566.endd
14567The default assumes that this state is a serious configuration error. The
14568difference between `pass' and `decline' is that the former forces the address
14569to be passed to the next router (or the router defined by \pass@_router\),
14570.index \more\ option
14571overriding \no@_more\, whereas the latter passes the address to the next router
14572only if \more\ is true.
14573
14574This option applies only to a definite `does not exist' state; if a host lookup
14575gets a temporary error, delivery is deferred unless the generic
14576\pass@_on@_timeout\ option is set.
14577
14578.conf hosts@_randomize boolean false
14579.index randomized host list
14580.index host||list of, randomized
14581If this option is set, the order of the items in a host list in a routing rule
14582is randomized each time the list is used, unless an option in the routing rule
14583overrides (see below). Randomizing the order of a host list can be used to do
14584crude load sharing. However, if more than one mail address is routed by the
14585same router to the same host list, the host lists are considered to be the same
14586(even though they may be randomized into different orders) for the purpose of
14587deciding whether to batch the deliveries into a single SMTP transaction.
14588
14589When \hosts@_randomize\ is true, a host list may be split
14590into groups whose order is separately randomized. This makes it possible to
14591set up MX-like behaviour. The boundaries between groups are indicated by an
14592item that is just \"+"\ in the host list. For example:
14593.display asis
14594route_list = * host1:host2:host3:+:host4:host5
14595.endd
14596The order of the first three hosts and the order of the last two hosts is
14597randomized for each use, but the first three always end up before the last two.
14598If \hosts@_randomize\ is not set, a \"+"\ item in the list is ignored. If a
14599randomized host list is passed to an \%smtp%\ transport that also has
14600\hosts@_randomize set\, the list is not re-randomized.
14601
14602.conf route@_data string$**$ unset
14603If this option is set, it must expand to yield the data part of a routing rule.
14604Typically, the expansion string includes a lookup based on the domain. For
14605example:
14606.display asis
14607route_data = ${lookup{$domain}dbm{/etc/routes}}
14608.endd
14609If the expansion is forced to fail, or the result is an empty string, the
14610router declines. Other kinds of expansion failure cause delivery to be
14611deferred.
14612
14613.conf route@_list "string list, semicolon-separated" unset
14614This string is a list of routing rules, in the form defined below. Note that,
14615unlike most string lists, the items are separated by semicolons. This is so
14616that they may contain colon-separated host lists.
14617
14618.conf same@_domain@_copy@_routing boolean false
14619.index address||copying routing
14620Addresses with the same domain are normally routed by the \%manualroute%\ router
14621to the same list of hosts. However, this cannot be presumed, because the router
14622options and preconditions may refer to the local part of the address. By
14623default, therefore, Exim routes each address in a message independently. DNS
14624servers run caches, so repeated DNS lookups are not normally expensive, and in
14625any case, personal messages rarely have more than a few recipients.
14626
14627If you are running mailing lists with large numbers of subscribers at the same
14628domain, and you are using a \%manualroute%\ router which is independent of the
14629local part, you can set \same@_domain@_copy@_routing\ to bypass repeated DNS
14630lookups for identical domains in one message. In this case, when \%manualroute%\
14631routes an address to a remote transport, any other unrouted addresses in the
14632message that have the same domain are automatically given the same routing
14633without processing them independently. However, this is only done if
14634\headers@_add\ and \headers@_remove\ are unset.
14635
14636.endconf
14637
14638
14639.section Routing rules in route@_list
14640The value of \route@_list\ is a string consisting of a sequence of routing
14641rules, separated by semicolons. If a semicolon is needed in a rule, it can be
14642entered as two semicolons. Empty rules are ignored. The format of each rule is
14643.display
14644<<domain pattern>> <<list of hosts>> <<options>>
14645.endd
14646The following example contains two rules, each with a simple domain pattern and
14647no options:
14648.display asis
14649route_list = \
14650 dict.ref.example mail-1.ref.example:mail-2.ref.example ; \
14651 thes.ref.example mail-3.ref.example:mail-4.ref.example
14652.endd
14653The three parts of a rule are separated by white space. The pattern and the
14654list of hosts can be enclosed in quotes if necessary, and if they are, the
14655usual quoting rules apply. Each rule in a \route@_list\ must start with a
14656single domain pattern, which is the only mandatory item in the rule. The
14657pattern is in the same format as one item in a domain list (see section
14658~~SECTdomainlist),
14659except that it may not be the name of an interpolated file.
14660That is, it may be wildcarded, or a regular expression, or a file or database
14661lookup (with semicolons doubled, because of the use of semicolon as a separator
14662in a \route@_list\).
14663
14664The rules in \route@_list\ are searched in order until one of the patterns
14665matches the domain that is being routed. The list of hosts and then options are
14666then used as described below. If there is no match, the router declines. When
14667\route@_list\ is set, \route@_data\ must not be set.
14668
14669
14670.section Routing rules in route@_data
14671The use of \route@_list\ is convenient when there are only a small number of
14672routing rules. For larger numbers, it is easier to use a file or database to
14673hold the routing information, and use the \route@_data\ option instead.
14674The value of \route@_data\ is a list of hosts, followed by (optional) options.
14675Most commonly, \route@_data\ is set as a string that contains an
14676expansion lookup. For example, suppose we place two routing rules in a file
14677like this:
14678.display asis
14679dict.ref.example: mail-1.ref.example:mail-2.ref.example
14680thes.ref.example: mail-3.ref.example:mail-4.ref.example
14681.endd
14682This data can be accessed by setting
14683.display asis
14684route_data = ${lookup{$domain}lsearch{/the/file/name}}
14685.endd
14686Failure of the lookup results in an empty string, causing the router to
14687decline. However, you do not have to use a lookup in \route@_data\. The only
14688requirement is that the result of expanding the string is a list of hosts,
14689possibly followed by options, separated by white space. The list of hosts must
14690be enclosed in quotes if it contains white space.
14691
14692
14693
14694.section Format of the list of hosts
14695A list of hosts, whether obtained via \route@_data\ or \route@_list\, is always
14696separately expanded before use. If the expansion fails, the router declines.
14697The result of the expansion must be a colon-separated list of names and/or
14698IP addresses. IP addresses are not enclosed in brackets.
14699
14700If the list of hosts was obtained from a \route@_list\ item, the following
14701variables are set during its expansion:
14702.index numerical variables (\$1$\, \$2$\, etc)||in \%manualroute%\ router
14703.numberpars $.
14704If the domain was matched against a regular expression, the numeric variables
14705\$1$\, \$2$\, etc. may be set.
14706.nextp
14707\$0$\ is always set to the entire domain.
14708.nextp
14709\$1$\ is also set when partial matching is done in a file lookup.
14710.nextp
14711.index \$value$\
14712If the pattern that matched the domain was a lookup item, the data that was
14713looked up is available in the expansion variable \$value$\.
14714.endp
14715
14716
14717.em
14718.section How the list of hosts is used
14719When an address is routed to an \%smtp%\ transport by \%manualroute%\, each of
14720the hosts is tried, in the order specified, when carrying out the SMTP
14721delivery. However, the order can be changed by setting the \hosts@_randomize\
14722option, either on the router (see section ~~SECTprioptman above), or on the
14723transport.
14724
14725Hosts may be listed by name or by IP address. An unadorned name in the list of
14726hosts is interpreted as a host name. A name that is followed by \"/MX"\ is
14727interpreted as an indirection to a sublist of hosts obtained by looking up MX
14728records in the DNS. For example:
14729.display asis
14730route_list = * x.y.z:p.q.r/MX:e.f.g
14731.endd
14732If the \hosts@_randomize\ option is set, the order of the items in the list is
14733randomized before any lookups are done. Exim then scans the list; for any name
14734that is not followed by \"/MX"\ it looks up an IP address. If this turns out to
14735be an interface on the local host and the item is not the first in the list,
14736Exim discards it and any subsequent items. If it is the first item, what
14737happens is controlled by the
14738.index \self\ option||in \%manualroute%\ router
14739\self\ option of the router.
14740
14741A name on the list that is followed by \"/MX"\ is replaced with the list of
14742hosts obtained by looking up MX records for the name. This is always a DNS
14743lookup; the \bydns\ and \byname\ options (see section ~~SECThowoptused below)
14744are not relevant here. The order of these hosts is determined by the preference
14745values in the MX records, according to the usual rules. Because randomizing
14746happens before the MX lookup, it does not affect the order that is defined by
14747MX preferences.
14748.nem
14749
14750If the local host is present in the sublist obtained from MX records, but is
14751not the most preferred host in that list, it and any equally or less
14752preferred hosts are removed before the sublist is inserted into the main list.
14753
14754If the local host is the most preferred host in the MX list, what happens
14755depends on where in the original list of hosts the \"/MX"\ item appears. If it
14756is not the first item (that is, there are previous hosts in the main list),
14757Exim discards this name and any subsequent items in the main list.
14758
14759If the MX item is first in the list of hosts, and the local host is the
14760most preferred host, what happens is controlled by the \self\ option of the
14761router.
14762
14763DNS failures when lookup up the MX records are treated in the same way as DNS
14764failures when looking up IP addresses: \pass@_on@_timeout\ and
14765\host@_find@_failed\ are used when relevant.
14766
14767.em
14768The generic \ignore@_target@_hosts\ option applies to all hosts in the list,
14769whether obtained from an MX lookup or not.
14770.nem
14771
14772
14773.section How the options are used
14774.rset SECThowoptused "~~chapter.~~section"
14775The options are a sequence of words; in practice no more than three are ever
14776present. One of the words can be the name of a transport; this overrides the
14777\transport\ option on the router for this particular routing rule only. The
14778other words (if present) control randomization of the list of hosts on a
14779per-rule basis, and how the IP addresses of the hosts are to be found when
14780routing to a remote transport. These options are as follows:
14781.numberpars $.
14782\randomize\: randomize the order of the hosts in this list, overriding the
14783setting of \hosts@_randomize\ for this routing rule only.
14784.nextp
14785\no@_randomize\: do not randomize the order of the hosts in this list,
14786overriding the setting of \hosts@_randomize\ for this routing rule only.
14787.nextp
14788\byname\: use \*getipnodebyname()*\ (\*gethostbyname()*\ on older systems) to
14789find IP addresses. This function may ultimately cause a DNS lookup, but it may
14790also look in \(/etc/hosts)\ or other sources of information.
14791.nextp
14792\bydns\: look up address records for the hosts directly in the DNS; fail if
14793no address records are found. If there is a temporary DNS error (such as a
14794timeout), delivery is deferred.
14795.endp
14796For example:
14797.display asis
14798route_list = domain1 host1:host2:host3 randomize bydns;\
14799 domain2 host4:host5
14800.endd
14801If neither \byname\ nor \bydns\ is given, Exim behaves as follows: First, a DNS
14802lookup is done. If this yields anything other than \\HOST@_NOT@_FOUND\\, that
14803result is used. Otherwise, Exim goes on to try a call to \*getipnodebyname()*\
14804or \*gethostbyname()*\, and the result of the lookup is the result of that
14805call.
14806
14807\**Warning**\: It has been discovered that on some systems, if a DNS lookup
14808called via \*getipnodebyname()*\ times out, \\HOST@_NOT@_FOUND\\ is returned
14809instead of \\TRY@_AGAIN\\. That is why the default action is to try a DNS
14810lookup first. Only if that gives a definite `no such host' is the local
14811function called.
14812
14813
14814
14815If no IP address for a host can be found, what happens is controlled by the
14816\host@_find@_failed\ option.
14817
14818When an address is routed to a local transport, IP addresses are not looked up.
14819The host list is passed to the transport in the \$host$\ variable.
14820
14821
14822.section Manualroute examples
14823In some of the examples that follow, the presence of the \remote@_smtp\
14824transport, as defined in the default configuration file, is assumed:
14825
14826.numberpars $.
14827.index smart host||example router
14828The \%manualroute%\ router can be used to forward all external mail to a
14829\*smart host*\. If you have set up, in the main part of the configuration, a
14830named domain list that contains your local domains, for example,
14831.display asis
14832domainlist local_domains = my.domain.example
14833.endd
14834you can arrange for all other domains to be routed to a smart host by making
14835your first router something like this:
14836.display asis
14837smart_route:
14838 driver = manualroute
14839 domains = !+local_domains
14840 transport = remote_smtp
14841 route_list = * smarthost.ref.example
14842.endd
14843This causes all non-local addresses to be sent to the single host
14844\*smarthost.ref.example*\. If a colon-separated list of smart hosts is given,
14845they are tried in order
14846(but you can use \hosts@_randomize\ to vary the order each time).
14847Another way of configuring the same thing is this:
14848.display asis
14849smart_route:
14850 driver = manualroute
14851 transport = remote_smtp
14852 route_list = !+local_domains smarthost.ref.example
14853.endd
14854There is no difference in behaviour between these two routers as they stand.
14855However, they behave differently if \no@_more\ is added to them. In the first
14856example, the router is skipped if the domain does not match the \domains\
14857precondition; the following router is always tried. If the router runs, it
14858always matches the domain and so can never decline. Therefore, \no@_more\ would
14859have no effect. In the second case, the router is never skipped; it always
14860runs. However, if it doesn't match the domain, it declines. In this case
14861\no@_more\ would prevent subsequent routers from running.
14862
14863.nextp
14864.index mail hub example
14865A \*mail hub*\ is a host which receives mail for a number of domains via MX
14866records in the DNS and delivers it via its own private routing mechanism. Often
14867the final destinations are behind a firewall, with the mail hub being the one
14868machine that can connect to machines both inside and outside the firewall. The
14869\%manualroute%\ router is usually used on a mail hub to route incoming messages
14870to the correct hosts. For a small number of domains, the routing can be inline,
14871using the \route@_list\ option, but for a larger number a file or database
14872lookup is easier to manage.
14873
14874If the domain names are in fact the names of the machines to which the mail is
14875to be sent by the mail hub, the configuration can be quite simple. For
14876example,
14877.display asis
14878hub_route:
14879 driver = manualroute
14880 transport = remote_smtp
14881 route_list = *.rhodes.tvs.example $domain
14882.endd
14883This configuration routes domains that match \"*.rhodes.tvs.example"\ to hosts
14884whose names are the same as the mail domains. A similar approach can be taken
14885if the host name can be obtained from the domain name by a string manipulation
14886that the expansion facilities can handle. Otherwise, a lookup based on the
14887domain can be used to find the host:
14888.display asis
14889through_firewall:
14890 driver = manualroute
14891 transport = remote_smtp
14892 route_data = ${lookup {$domain} cdb {/internal/host/routes}}
14893.endd
14894The result of the lookup must be the name or IP address of the host (or
14895hosts) to which the address is to be routed. If the lookup fails, the route
14896data is empty, causing the router to decline. The address then passes to the
14897next router.
14898
14899.nextp
14900.index batched SMTP output example
14901.index SMTP||batched outgoing, example
14902You can use \%manualroute%\ to deliver messages to pipes or files in batched
14903SMTP format for onward transportation by some other means. This is one way of
14904storing mail for a dial-up host when it is not connected. The route list entry
14905can be as simple as a single domain name in a configuration like this:
14906.display asis
14907save_in_file:
14908 driver = manualroute
14909 transport = batchsmtp_appendfile
14910 route_list = saved.domain.example
14911.endd
14912though often a pattern is used to pick up more than one domain. If there are
14913several domains or groups of domains with different transport requirements,
14914different transports can be listed in the routing information:
14915.display asis
14916save_in_file:
14917 driver = manualroute
14918 route_list = \
14919 *.saved.domain1.example $domain batch_appendfile; \
14920 *.saved.domain2.example \
14921 ${lookup{$domain}dbm{/domain2/hosts}{$value}fail} \
14922 batch_pipe
14923.endd
14924The first of these just passes the domain in the \$host$\ variable, which
14925doesn't achieve much (since it is also in \$domain$\), but the second does a
14926file lookup to find a value to pass, causing the router to decline to handle
14927the address if the lookup fails.
14928.nextp
14929.index UUCP||example of router for
14930Routing mail directly to UUCP software is a specific case of the use of
14931\%manualroute%\ in a gateway to another mail environment. This is an example of
14932one way it can be done:
14933.display asis
14934# Transport
14935uucp:
14936 driver = pipe
14937 user = nobody
14938 command = /usr/local/bin/uux -r - \
14939 ${substr_-5:$host}!rmail ${local_part}
14940 return_fail_output = true
14941.endd
14942.display asis
14943# Router
14944uucphost:
14945 transport = uucp
14946 driver = manualroute
14947 route_data = \
14948 ${lookup{$domain}lsearch{/usr/local/exim/uucphosts}}
14949.endd
14950The file \(/usr/local/exim/uucphosts)\ contains entries like
14951.display asis
14952darksite.ethereal.example: darksite.UUCP
14953.endd
14954It can be set up more simply without adding and removing `.UUCP' but this way
14955makes clear the distinction between the domain name
14956\*darksite.ethereal.example*\ and the UUCP host name \*darksite*\.
14957.endp
14958
14959
14960
14961
14962
14963
14964.
14965.
14966.
14967.
14968. ============================================================================
14969.chapter The queryprogram router
14970.set runningfoot "queryprogram router"
14971.rset CHAPdriverlast "~~chapter"
14972.index \%queryprogram%\ router
14973.index routers||\%queryprogram%\
14974.index routing||by external program
14975The \%queryprogram%\ router routes an address by running an external command and
14976acting on its output. This is an expensive way to route, and is intended mainly
14977for use in lightly-loaded systems, or for performing experiments. However, if
14978it is possible to use the precondition options (\domains\, \local@_parts\,
14979etc) to skip this router for most addresses, it could sensibly be used in
14980special cases, even on a busy host. There are the following private options:
14981
14982.startconf
14983.index options||\%queryprogram%\ router
14984.conf command string$**$ unset
14985This option must be set. It specifies the command that is to be run. The
14986command is split up into a command name and arguments, and then each is
14987expanded separately (exactly as for a \%pipe%\ transport, described in chapter
14988~~CHAPpipetransport).
14989
14990.conf command@_group string unset
14991.index gid (group id)||in \%queryprogram%\ router
14992This option specifies a gid to be set when running the command. It must be set
14993if \command@_user\ specifies a numerical uid. If it begins with a digit, it is
14994interpreted as the numerical value of the gid. Otherwise it is looked up using
14995\*getgrnam()*\.
14996
14997.conf command@_user string unset
14998.index uid (user id)||for \%queryprogram%\
14999This option must be set. It specifies the uid which is set when running the
15000command. If it begins with a digit it is interpreted as the numerical value of
15001the uid. Otherwise, it is looked up using \*getpwnam()*\ to obtain a value for
15002the uid and, if \command@_group\ is not set, a value for the gid also.
15003
15004.conf current@_directory string /
15005This option specifies an absolute path which is made the current directory
15006before running the command.
15007
15008.conf timeout time 1h
15009If the command does not complete within the timeout period, its process group
15010is killed and the message is frozen. A value of zero time specifies no
15011timeout.
15012
15013.endconf
15014
15015The standard output of the command is connected to a pipe, which is read when
15016the command terminates. It should consist of a single line of output,
15017containing up to five fields, separated by white space. The first field is one
15018of the following words (case-insensitive):
15019.numberpars $.
15020\*Accept*\: routing succeeded; the remaining fields specify what to do (see
15021below).
15022.nextp
15023\*Decline*\: the router declines; pass the address to the next router, unless
15024\no@_more\ is set.
15025.nextp
15026\*Fail*\: routing failed; do not pass the address to any more routers. Any
15027subsequent text on the line is an error message. If the router is run as part
15028of address verification during an incoming SMTP message, the message is
15029included in the SMTP response.
15030.nextp
15031\*Defer*\: routing could not be completed at this time; try again later. Any
15032subsequent text on the line is an error message which is logged. It is not
15033included in any SMTP response.
15034.nextp
15035\*Freeze*\: the same as \*defer*\, except that the message is frozen.
15036.nextp
15037\*Pass*\: pass the address to the next router (or the router specified by
15038\pass@_router\), overriding \no@_more\.
15039.nextp
15040\*Redirect*\: the message is redirected. The remainder of the line is a list of
15041new addresses, which are routed independently, starting with the first router,
15042or the router specified by \redirect@_router\, if set.
15043.endp
15044When the first word is \*accept*\, the remainder of the line consists of a
15045number of keyed data values, as follows (split into two lines here, to fit on
15046the page):
15047.display
15048ACCEPT TRANSPORT=<<transport>> HOSTS=<<list of hosts>>
15049 LOOKUP=byname|bydns DATA=<<text>>
15050.endd
15051The data items can be given in any order, and all are optional. If no transport
15052is included, the transport specified by the generic \transport\ option is used.
15053The list of hosts and the lookup type are needed only if the transport is an
15054\%smtp%\ transport that does not itself supply a list of hosts.
15055
15056The format of the list of hosts is the same as for the \%manualroute%\ router.
15057As well as host names and IP addresses, it may contain names followed by
15058\"/MX"\ to specify sublists of hosts that are obtained by looking up MX
15059records.
15060
15061If the lookup type is not specified, Exim behaves as follows when trying to
15062find an IP address for each host: First, a DNS lookup is done. If this yields
15063anything other than \\HOST@_NOT@_FOUND\\, that result is used. Otherwise, Exim
15064goes on to try a call to \*getipnodebyname()*\ or \*gethostbyname()*\, and the
15065result of the lookup is the result of that call.
15066
15067If the DATA field is set, its value is placed in the \$address@_data$\
15068variable. For example, this return line
15069.display asis
15070accept hosts=x1.y.example:x2.y.example data="rule1"
15071.endd
15072routes the address to the default transport, with a host list containing two
15073hosts. When the transport runs, the string `rule1' is in \$address@_data$\.
15074
15075
15076
15077.
15078.
15079.
15080.
15081. ============================================================================
15082.chapter The redirect router
15083.set runningfoot "redirect router"
15084.rset CHAPredirect "~~chapter"
15085.index \%redirect%\ router
15086.index routers||\%redirect%\
15087.index alias file||in a \%redirect%\ router
15088.index address redirection||\%redirect%\ router
15089The \%redirect%\ router handles several kinds of address redirection. Its most
15090common uses are for resolving local part aliases from a central alias file
15091(usually called \(/etc/aliases)\) and for handling users' personal \(.forward)\
15092files, but it has many other potential uses. The incoming address can be
15093redirected in several different ways:
15094.numberpars $.
15095It can be replaced by one or more new addresses which are themselves routed
15096independently.
15097.nextp
15098It can be routed to be delivered to a given file or directory.
15099.nextp
15100It can be routed to be delivered to a specified pipe command.
15101.nextp
15102It can cause an automatic reply to be generated.
15103.nextp
15104It can be forced to fail, with a custom error message.
15105.nextp
15106It can be temporarily deferred.
15107.nextp
15108It can be discarded.
15109.endp
15110The generic \transport\ option must not be set for \%redirect%\ routers.
15111However, there are some private options which define transports for delivery to
15112files and pipes, and for generating autoreplies. See the \file@_transport\,
15113\pipe@_transport\ and \reply@_transport\ descriptions below.
15114
15115
15116.section Redirection data
15117The router operates by interpreting a text string which it obtains either by
15118expanding the contents of the \data\ option, or by reading the entire contents
15119of a file whose name is given in the \file\ option. These two options are
15120mutually exclusive. The first is commonly used for handling system aliases, in
15121a configuration like this:
15122.display asis
15123system_aliases:
15124 driver = redirect
15125 data = ${lookup{$local_part}lsearch{/etc/aliases}}
15126.endd
15127.em
15128If the lookup fails, the expanded string in this example is empty. When the
15129expansion of \data\ results in an empty string, the router declines. A forced
15130expansion failure also causes the router to decline; other expansion failures
15131cause delivery to be deferred.
15132.nem
15133
15134A configuration using \file\ is commonly used for handling users' \(.forward)\
15135files, like this:
15136.display asis
15137userforward:
15138 driver = redirect
15139 check_local_user
15140 file = $home/.forward
15141 no_verify
15142.endd
15143If the file does not exist, or causes no action to be taken (for example, it is
15144empty or consists only of comments), the router declines. \**Warning**\: This
15145is not the case when the file contains syntactically valid items that happen to
15146yield empty addresses, for example, items containing only RFC 2822 address
15147comments.
15148
15149
15150.section Forward files and address verification
15151.index address redirection||while verifying
15152It is usual to set \no@_verify\ on \%redirect%\ routers which handle users'
15153\(.forward)\ files, as in the example above. There are two reasons for this:
15154.numberpars $.
15155When Exim is receiving an incoming SMTP message from a remote host, it is
15156running under the Exim uid, not as root.
15157No additional groups are set up, even if the Exim uid is a member of other
15158groups (that is, the \*initgroups()*\ function is not run).
15159Exim is unable to change uid to read the file as the user, and it may not be
15160able to read it as the Exim user. So in practice the router may not be able to
15161operate.
15162.nextp
15163However, even when the router can operate, the existence of a \(.forward)\ file
15164is unimportant when verifying an address. What should be checked is whether the
15165local part is a valid user name or not. Cutting out the redirection processing
15166saves some resources.
15167.endp
15168
15169
15170
15171
15172.section Interpreting redirection data
15173.index Sieve filter||specifying in redirection data
15174.index filter||specifying in redirection data
15175The contents of the data string, whether obtained from \data\ or \file\, can be
15176interpreted in two different ways:
15177.numberpars $.
15178If the \allow@_filter\ option is set true, and the data begins with the text
15179`@#Exim filter' or `@#Sieve filter', it is interpreted as a list of
15180\*filtering*\ instructions in the form of an Exim or Sieve filter file,
15181respectively. Details of the syntax and semantics of filter files are described
15182in a separate document entitled \*Exim's interfaces to mail filtering*\; this
15183document is intended for use by end users.
15184.nextp
15185Otherwise, the data must be a comma-separated list of redirection items, as
15186described in the next section.
15187.endp
15188When a message is redirected to a file (a `mail folder'), the file name given
15189in a non-filter redirection list must always be an absolute path. A filter may
15190generate a relative path -- how this is handled depends on the transport's
15191configuration. See section ~~SECTfildiropt for a discussion of this issue for
15192the \%appendfile%\ transport.
15193
15194
15195.section Items in a non-filter redirection list
15196.rset SECTitenonfilred "~~chapter.~~section"
15197.index address redirection||non-filter list items
15198When the redirection data is not an Exim or Sieve filter, for example, if it
15199comes from a conventional alias or forward file, it consists of a list of
15200addresses, file names, pipe commands, or certain special items (see section
15201~~SECTspecitredli below). The special items can be individually enabled or
15202disabled by means of options whose names begin with \allow@_\ or \forbid@_\,
15203depending on their default values. The items in the list are separated by
15204commas or newlines.
15205If a comma is required in an item, the entire item must be enclosed in double
15206quotes.
15207
15208Lines starting with a @# character are comments, and are ignored, and @# may
15209also appear following a comma, in which case everything between the @# and the
15210next newline character is ignored.
15211
15212If an item is entirely enclosed in double quotes, these are removed. Otherwise
15213double quotes are retained because some forms of mail address require their use
15214(but never to enclose the entire address). In the following description, `item'
15215refers to what remains after any surrounding double quotes have been removed.
15216
15217\**Warning**\: If you use an Exim expansion to construct a redirection address,
15218and the expansion contains a reference to \$local@_part$\, you should make use
15219of the \quote\ expansion operator, in case the local part contains special
15220characters. For example, to redirect all mail for the domain
15221\*obsolete.example*\, retaining the existing local part, you could use this
15222setting:
15223.display asis
15224data = ${quote:$local_part}@newdomain.example
15225.endd
15226
15227
15228.section Redirecting to a local mailbox
15229.rset SECTredlocmai "~~chapter.~~section"
15230.index routing||loops in
15231.index loop||while routing, avoidance of
15232.index address redirection||to local mailbox
15233A redirection item may safely be the same as the address currently under
15234consideration. This does not cause a routing loop, because a router is
15235automatically skipped if any ancestor of the address that is being processed
15236.em
15237is the same as the current address and was processed by the current router.
15238.nem
15239Such an address is therefore passed to the following routers, so it is handled
15240as if there were no redirection. When making this loop-avoidance test, the
15241complete local part, including any prefix or suffix, is used.
15242
15243.index address redirection||local part without domain
15244Specifying the same local part without a domain is a common usage in personal
15245filter files when the user wants to have messages delivered to the local
15246mailbox and also forwarded elsewhere. For example, the user whose login is
15247\*cleo*\ might have a \(.forward)\ file containing this:
15248.display asis
15249cleo, cleopatra@egypt.example
15250.endd
15251.index backslash in alias file
15252.index alias file||backslash in
15253For compatibility with other MTAs, such unqualified local parts may be
15254preceeded by `@\', but this is not a requirement for loop prevention. However,
15255it does make a difference if more than one domain is being handled
15256synonymously.
15257
15258If an item begins with `@\' and the rest of the item parses as a valid RFC 2822
15259address that does not include a domain, the item is qualified using the domain
15260of the incoming address. In the absence of a leading `@\', unqualified
15261addresses are qualified using the value in \qualify@_recipient\, but you can
15262force the incoming domain to be used by setting \qualify__preserve@_domain\.
15263
15264Care must be taken if there are alias names for local users.
15265.em
15266Consider an MTA handling a single local domain where the system alias file
15267contains:
15268.display asis
15269Sam.Reman: spqr
15270.endd
15271Now suppose that Sam (whose login id is \*spqr*\) wants to save copies of
15272messages in the local mailbox, and also forward copies elsewhere. He creates
15273this forward file:
15274.display asis
15275Sam.Reman, spqr@reme.elsewhere.example
15276.endd
15277With these settings, an incoming message addressed to \*Sam.Reman*\ fails. The
15278\%redirect%\ router for system aliases does not process \*Sam.Reman*\ the
15279second time round, because it has previously routed it,
15280.nem
15281and the following routers presumably cannot handle the alias. The forward file
15282should really contain
15283.display asis
15284spqr, spqr@reme.elsewhere.example
15285.endd
15286but because this is such a common error, the \check@_ancestor\ option (see
15287below) exists to provide a way to get round it. This is normally set on a
15288\%redirect%\ router that is handling users' \(.forward)\ files.
15289
15290
15291.section Special items in redirection lists
15292.rset SECTspecitredli "~~chapter.~~section"
15293In addition to addresses, the following types of item may appear in redirection
15294lists (that is, in non-filter redirection data):
15295
15296.numberpars $.
15297.index pipe||in redirection list
15298.index address redirection||to pipe
15299An item is treated as a pipe command if it begins with `|' and does not parse
15300as a valid RFC 2822 address that includes a domain. A transport for running the
15301command must be specified by the \pipe@_transport\ option.
15302.em
15303Normally, either the router or the transport specifies a user and a group under
15304which to run the delivery. The default is to use the Exim user and group.
15305.nem
15306
15307Single or double quotes can be used for enclosing the individual arguments of
15308the pipe command; no interpretation of escapes is done for single quotes. If
15309the command contains a comma character, it is necessary to put the whole item
15310in double quotes, for example:
15311.display asis
15312"|/some/command ready,steady,go"
15313.endd
15314since items in redirection lists are terminated by commas. Do not, however,
15315quote just the command. An item such as
15316.display asis
15317|"/some/command ready,steady,go"
15318.endd
15319is interpreted as a pipe with a rather strange command name, and no arguments.
15320.nextp
15321.index file||in redirection list
15322.index address redirection||to file
15323An item is interpreted as a path name if it begins with `/' and does not parse
15324as a valid RFC 2822 address that includes a domain. For example,
15325.display asis
15326/home/world/minbari
15327.endd
15328is treated as a file name, but
15329.display asis
15330/s=molari/o=babylon/@x400gate.way
15331.endd
15332is treated as an address. For a file name, a transport must be specified using
15333the \file@_transport\ option. However, if the generated path name ends with a
15334forward slash character, it is interpreted as a directory name rather than a
15335file name, and \directory@_transport\ is used instead.
15336
15337.em
15338Normally, either the router or the transport specifies a user and a group under
15339which to run the delivery. The default is to use the Exim user and group.
15340.index \(/dev/null)\
15341However, if a redirection item is the path \(/dev/null)\, delivery to it is
15342bypassed at a high level, and the log entry shows `$*$$*$bypassed$*$$*$'
15343instead of a transport name. In this case the user and group are not used.
15344.nem
15345.nextp
15346.index included address list
15347.index address redirection||included external list
15348If an item is of the form
15349.display
15350:include:<<path name>>
15351.endd
15352a list of further items is taken from the given file and included at that
15353point.
15354\**Note**\: such a file can not be a filter file; it is just an out-of-line
15355addition to the list.
15356The items in the included list are separated by commas or newlines and are not
15357subject to expansion. If this is the first item in an alias list in an
15358\%lsearch%\ file, a colon must be used to terminate the alias name. This
15359example is incorrect:
15360.display asis
15361list1 :include:/opt/lists/list1
15362.endd
15363It must be given as
15364.display asis
15365list1: :include:/opt/lists/list1
15366.endd
15367.nextp
15368.index address redirection||to black hole
15369Sometimes you want to throw away mail to a particular local part. Making the
15370\data\ option expand to an empty string does not work, because that causes the
15371router to decline. Instead, the alias item
15372.index black hole
15373.index abandoning mail
15374.display
15375:blackhole:
15376.endd
15377can be used. It does what its name implies. No delivery is done, and no error
15378message is generated. This has the same effect as specifing \(/dev/null)\, but
15379can be independently disabled.
15380
15381\**Warning**\: If \":blackhole:"\ appears anywhere in a redirection list, no
15382delivery is done for the original local part, even if other redirection items
15383are present. If you are generating a multi-item list (for example, by reading a
15384database) and need the ability to provide a no-op item, you must use
15385\(/dev/null)\.
15386
15387.nextp
15388.index delivery||forcing failure
15389.index delivery||forcing deferral
15390.index failing delivery||forcing
15391.index deferred delivery, forcing
15392.index customizing||failure message
15393An attempt to deliver a particular address can be deferred or forced to fail by
15394redirection items of the form
15395.display
15396:defer:
15397$rm{or}
15398:fail:
15399.endd
15400respectively. When a redirection list contains such an item, it applies to the
15401entire redirection; any other items in the list are ignored (:::blackhole:: is
15402different). Any text following :::fail:: or :::defer:: is placed in the error
15403text associated with the failure. For example, an alias file might contain:
15404.display asis
15405X.Employee: :fail: Gone away, no forwarding address
15406.endd
15407In the case of an address that is being verified from an ACL or as the subject
15408of a \\VRFY\\ command, the text is included in the SMTP error response by
15409default. In an ACL, an explicitly provided message overrides the default, but
15410the default message is available in the variable \$acl@_verify@_message$\ and
15411can therefore be included in a custom message if this is desired. Exim sends a
15412451 SMTP code for a :::defer::, and 550 for :::fail::. In non-SMTP cases the
15413text is included in the error message that Exim generates.
15414
15415
15416
15417Normally the error text is the rest of the redirection list -- a comma does not
15418terminate it -- but a newline does act as a terminator. Newlines are not
15419normally present in alias expansions. In \%lsearch%\ lookups they are removed as
15420part of the continuation process, but they may exist in other kinds of lookup
15421and in :::include:: files.
15422
15423During routing for message delivery (as opposed to verification), a redirection
15424containing :::fail:: causes an immediate failure of the incoming address,
15425whereas :::defer:: causes the message to remain on the queue so that a
15426subsequent delivery attempt can happen at a later time. If an address is
15427deferred for too long, it will ultimately fail, because the normal retry
15428rules still apply.
15429.nextp
15430.index alias file||exception to default
15431Sometimes it is useful to use a single-key search type with a default (see
15432chapter ~~CHAPfdlookup) to look up aliases. However, there may be a need for
15433exceptions to the default. These can be handled by aliasing them to
15434.display asis
15435:unknown:
15436.endd
15437This differs from :::fail:: in that it causes the \%redirect%\ router to decline,
15438whereas :::fail:: forces routing to fail. A lookup which results in an empty
15439redirection list has the same effect.
15440.endp
15441
15442.section Duplicate addresses
15443.index duplicate addresses
15444.index address||duplicate, discarding
15445.index pipe||duplicated
15446Exim removes duplicate addresses from the list to which it is delivering, so as
15447to deliver just one copy to each address. This does not apply to deliveries
15448routed to pipes by different immediate parent addresses, but an indirect
15449aliasing scheme of the type
15450.display asis
15451pipe: |/some/command $local_part
15452localpart1: pipe
15453localpart2: pipe
15454.endd
15455does not work with a message that is addressed to both local parts, because
15456when the second is aliased to the intermediate local part `pipe' it gets
15457discarded as being the same as a previously handled address. However, a scheme
15458such as
15459.display asis
15460localpart1: |/some/command $local_part
15461localpart2: |/some/command $local_part
15462.endd
15463does result in two different pipe deliveries, because the immediate parents of
15464the pipes are distinct.
15465
15466
15467.section Repeated redirection expansion
15468.index repeated redirection expansion
15469.index address redirection||repeated for each delivery attempt
15470When a message cannot be delivered to all of its recipients immediately,
15471leading to two or more delivery attempts, redirection expansion is carried out
15472afresh each time for those addresses whose children were not all previously
15473delivered. If redirection is being used as a mailing list, this can lead to new
15474members of the list receiving copies of old messages. The \one@_time\ option
15475can be used to avoid this.
15476
15477.section Errors in redirection lists
15478.index address redirection||errors
15479If \skip@_syntax@_errors\ is set, a malformed address that causes a parsing
15480error is skipped, and an entry is written to the main log. This may be useful
15481for mailing lists that are automatically managed. Otherwise, if an error is
15482detected while generating the list of new addresses, the original address is
15483deferred. See also \syntax@_errors@_to\.
15484
15485
15486.section Private options for the redirect router
15487
15488The private options for the \%redirect%\ router are as follows:
15489
15490.startconf
15491.index options||\%redirect%\ router
15492
15493.conf allow@_defer boolean false
15494Setting this option allows the use of :::defer:: in non-filter redirection
15495data,
15496or the \defer\ command in an Exim filter file.
15497
15498.conf allow@_fail boolean false
15499.index failing delivery||from filter
15500If this option is true, the :::fail:: item can be used in a redirection list,
15501and the \fail\ command may be used in a filter file.
15502
15503.conf allow@_filter boolean false
15504.index filter||enabling use of
15505.index Sieve filter||enabling use of
15506Setting this option allows Exim to interpret redirection data that starts with
15507`@#Exim filter' or `@#Sieve filter' as a set of filtering instructions. There
15508are some features of Exim filter files that some administrators may wish to
15509lock out; see the \forbid@_filter@_xxx\ options below. The filter is run using
15510the uid and gid set by the generic \user\ and \group\ options. These take their
15511defaults from the password data if \check@_local@_user\ is set, so in the
15512normal case of users' personal filter files, the filter is run as the relevant
15513user. When \allow@_filter\ is set true, Exim insists that either
15514\check@_local@_user\ or \user\ is set.
15515
15516
15517.conf allow@_freeze boolean false
15518.index freezing messages||allowing in filter
15519Setting this option allows the use of the \freeze\ command in an Exim filter.
15520This command is more normally encountered in system filters, and is disabled by
15521default for redirection filters because it isn't something you usually want to
15522let ordinary users do.
15523
15524
15525.conf check@_ancestor boolean false
15526This option is concerned with handling generated addresses that are the same
15527as some address in the list of redirection ancestors of the current address.
15528Although it is turned off by default in the code, it is set in the default
15529configuration file for handling users' \(.forward)\ files. It is recommended
15530for this use of the \%redirect%\ router.
15531
15532.em
15533When \check@_ancestor\ is set, if a generated address (including the domain) is
15534the same as any ancestor of the current address, it is replaced by a copy of
15535the current address. This helps in the case where local part A is aliased to B,
15536and B has a \(.forward)\ file pointing back to A. For example, within a single
15537domain, the local part `Joe.Bloggs' is aliased to `jb' and \(@~jb/.forward)\
15538contains:
15539.nem
15540.display
15541@\Joe.Bloggs, <<other item(s)>>
15542.endd
15543Without the \check@_ancestor\ setting, either local part (`jb' or `joe.bloggs')
15544gets processed once by each router and so ends up as it was originally. If `jb'
15545is the real mailbox name, mail to `jb' gets delivered (having been turned into
15546`joe.bloggs' by the \(.forward)\ file and back to `jb' by the alias), but mail
15547to `joe.bloggs' fails. Setting \check@_ancestor\ on the \%redirect%\ router that
15548handles the \(.forward)\ file prevents it from turning `jb' back into
15549`joe.bloggs' when that was the original address. See also the \repeat@_use\
15550option below.
15551
15552.conf check@_group boolean "see below"
15553When the \file\ option is used, the group owner of the file is checked only
15554when this option is set. The permitted groups are those listed in the
15555\owngroups\ option, together with the user's default group if
15556\check@_local@_user\ is set. If the file has the wrong group, routing is
15557deferred. The default setting for this option is true if \check@_local@_user\
15558is set and the \modemask\ option permits the group write bit, or if the
15559\owngroups\ option is set. Otherwise it is false, and no group check occurs.
15560
15561
15562.conf check@_owner boolean "see below"
15563When the \file\ option is used, the owner of the file is checked only when this
15564option is set. If \check@_local@_user\ is set, the local user is permitted;
15565otherwise the owner must be one of those listed in the \owners\ option. The
15566default value for this option is true if \check@_local@_user\ or \owners\ is
15567set. Otherwise the default is false, and no owner check occurs.
15568
15569.conf data string$**$ unset
15570This option is mutually exclusive with \file\. One or other of them must be
15571set, but not both. The contents of \data\ are expanded, and then used as the
15572list of forwarding items, or as a set of filtering instructions. If the
15573expansion is forced to fail, or the result is an empty string or a string that
15574has no effect (consists entirely of comments), the router declines.
15575
15576When filtering instructions are used, the string must begin with `@#Exim
15577filter', and all comments in the string, including this initial one, must be
15578terminated with newline characters. For example:
15579.display asis
15580data = #Exim filter\n\
15581 if $h_to: contains Exim then save $home/mail/exim endif
15582.endd
15583If you are reading the data from a database where newlines cannot be included,
15584you can use the \$@{sg@}$\ expansion item to turn the escape string of your
15585choice into a newline.
15586
15587.conf directory@_transport string$**$ unset
15588A \%redirect%\ router sets up a direct delivery to a directory when a path name
15589ending with a slash is specified as a new `address'. The transport used is
15590specified by this option, which, after expansion, must be the name of a
15591configured transport. This should normally be an \%appendfile%\ transport.
15592
15593.conf file string$**$ unset
15594This option specifies the name of a file that contains the redirection data. It
15595is mutually exclusive with the \data\ option. The string is expanded before
15596use; if the expansion is forced to fail, the router declines. Other expansion
15597failures cause delivery to be deferred. The result of a successful expansion
15598must be an absolute path. The entire file is read and used as the redirection
15599data. If the data is an empty string or a string that has no effect (consists
15600entirely of comments), the router declines.
15601
15602.index NFS||checking for file existence
15603If the attempt to open the file fails with a `does not exist' error, Exim
15604runs a check on the containing directory,
15605unless \ignore@_enotdir\ is true (see below).
15606If the directory does not appear to exist, delivery is deferred. This can
15607happen when users' \(.forward)\ files are in NFS-mounted directories, and there
15608is a mount problem. If the containing directory does exist, but the file does
15609not, the router declines.
15610
15611.conf file@_transport string$**$ unset
15612A \%redirect%\ router sets up a direct delivery to a file when a path name not
15613ending in a slash is specified as a new `address'. The transport used is
15614specified by this option, which, after expansion, must be the name of a
15615configured transport.
15616This should normally be an \%appendfile%\ transport.
15617When it is running, the file name is in \$address@_file$\.
15618
15619.conf forbid@_blackhole boolean false
15620If this option is true, the :::blackhole:: item may not appear in a redirection
15621list.
15622
15623.conf forbid@_file boolean false
15624.index delivery||to file, forbidding
15625.index Sieve filter||forbidding delivery to a file
15626.index Sieve filter||`keep' facility, disabling
15627If this option is true, this router may not generate a new address that
15628specifies delivery to a local file or directory, either from a filter or from a
15629conventional forward file. This option is forced to be true if \one@_time\ is
15630set. It applies to Sieve filters as well as to Exim filters, but if true, it
15631locks out the Sieve's `keep' facility.
15632
15633.conf forbid@_filter@_existstest boolean false
15634.index filter||locking out certain features
15635If this option is true, string expansions in Exim filters are not allowed to
15636make use of the \exists\ condition.
15637
15638.conf forbid@_filter@_logwrite boolean false
15639If this option is true, use of the logging facility in Exim filters is not
15640permitted. Logging is in any case available only if the filter is being run
15641under some unprivileged uid (which is normally the case for ordinary users'
15642\(.forward)\ files).
15643
15644.conf forbid@_filter@_lookup boolean false
15645If this option is true, string expansions in Exim filter files are not allowed
15646to make use of \lookup\ items.
15647
15648.conf forbid@_filter@_perl boolean false
15649This option is available only if Exim is built with embedded Perl support. If
15650it is true, string expansions in Exim filter files are not allowed to make use
15651of the embedded Perl support.
15652
15653.conf forbid@_filter@_readfile boolean false
15654If this option is true, string expansions in Exim filter files are not allowed
15655to make use of \readfile\ items.
15656
15657.conf forbid@_filter@_readsocket boolean false
15658If this option is true, string expansions in Exim filter files are not allowed
15659to make use of \readsocket\ items.
15660
15661.conf forbid@_filter@_reply boolean false
15662If this option is true, this router may not generate an automatic reply
15663message. Automatic replies can be generated only from Exim filter files, not
15664from traditional forward files or Sieve filters. This option is forced to be
15665true if \one@_time\ is set.
15666
15667.conf forbid@_filter@_run boolean false
15668If this option is true, string expansions in Exim filter files are not allowed
15669to make use of \run\ items.
15670
15671.conf forbid@_include boolean false
15672If this option is true, items of the form
15673.display
15674:include:<<path name>>
15675.endd
15676are not permitted in non-filter redirection lists.
15677
15678.conf forbid@_pipe boolean false
15679.index delivery||to pipe, forbidding
15680If this option is true, this router may not generate a new address which
15681specifies delivery to a pipe, either from an Exim filter or from a conventional
15682forward file. This option is forced to be true if \one@_time\ is set.
15683
15684.conf hide@_child@_in@_errmsg boolean false
15685.index bounce message||redirection details, suppressing
15686If this option is true, it prevents Exim from quoting a child address if it
15687generates a bounce or delay message for it. Instead it says `an address
15688generated from <<the top level address>>'. Of course, this applies only to
15689bounces generated locally. If a message is forwarded to another host, $it{its}
15690bounce may well quote the generated address.
15691
15692.conf ignore@_eacces boolean false
15693.index \\EACCES\\
15694If this option is set and an attempt to open a redirection file yields the
15695\\EACCES\\ error (permission denied), the \%redirect%\ router behaves as if the
15696file did not exist.
15697
15698.conf ignore@_enotdir boolean false
15699.index \\ENOTDIR\\
15700If this option is set and an attempt to open a redirection file yields the
15701\\ENOTDIR\\ error (something on the path is not a directory), the \%redirect%\
15702router behaves as if the file did not exist.
15703
15704Setting \ignore@_enotdir\ has another effect as well: When a \%redirect%\
15705router that has the \file\ option set discovers that the file does not exist
15706(the \\ENOENT\\ error), it tries to \*stat()*\ the parent directory, as a check
15707against unmounted NFS directories. If the parent can not be statted, delivery
15708is deferred. However, it seems wrong to do this check when \ignore@_enotdir\ is
15709set, because that option tells Exim to ignore `something on the path is not a
15710directory' (the \\ENOTDIR\\ error). This is a confusing area, because it seems
15711that some operating systems give \\ENOENT\\ where others give \\ENOTDIR\\.
15712
15713
15714.conf include@_directory string unset
15715If this option is set, the path names of any :::include:: items in a redirection
15716list must start with this directory.
15717
15718.conf modemask "octal integer" 022
15719This specifies mode bits which must not be set for a file specified by the
15720\file\ option. If any of the forbidden bits are set, delivery is deferred.
15721
15722.conf one@_time boolean false
15723.index one-time aliasing/forwarding expansion
15724.index alias file||one-time expansion
15725.index forward file||one-time expansion
15726.index mailing lists||one-time expansion
15727.index address redirection||one-time expansion
15728Sometimes the fact that Exim re-evaluates aliases and reprocesses redirection
15729files each time it tries to deliver a message causes a problem
15730when one or more of the generated addresses fails be delivered at the first
15731attempt. The problem is not one of duplicate delivery -- Exim is clever enough
15732to handle that -- but of what happens when the redirection list changes during
15733the time that the message is on Exim's queue. This is particularly true in the
15734case of mailing lists, where new subscribers might receive copies of messages
15735that were posted before they subscribed.
15736
15737If \one@_time\ is set and any addresses generated by the router fail to
15738deliver at the first attempt, the failing addresses are added to the message as
15739`top level' addresses, and the parent address that generated them is marked
15740`delivered'. Thus, redirection does not happen again at the next
15741delivery attempt.
15742
15743\**Warning 1**\: This means that any header line addition or removal that is
15744specified by this router would be lost if delivery did not succeed at the
15745first attempt. For this reason, the \headers@_add\ and \headers@_remove\
15746generic options are not permitted when \one@_time\ is set.
15747
15748\**Warning 2**\: To ensure that the router generates only addresses (as opposed
15749to pipe or file deliveries or auto-replies) \forbid@_file\, \forbid@_pipe\,
15750and \forbid@_filter@_reply\ are forced to be true when \one@_time\ is set.
15751
15752The original top-level address is remembered with each of the generated
15753addresses, and is output in any log messages. However, any intermediate parent
15754addresses are not recorded. This makes a difference to the log only if
15755\all__parents\ log selector is set. It is expected that \one@_time\ will
15756typically be used for mailing lists, where there is normally just one level of
15757expansion.
15758
15759.conf owners "string list" unset
15760.index ownership||alias file
15761.index ownership||forward file
15762.index alias file||ownership
15763.index forward file||ownership
15764This specifies a list of permitted owners for the file specified by \file\.
15765This list is in addition to the local user when \check@_local@_user\ is set.
15766See \check@_owner\ above.
15767
15768.conf owngroups "string list" unset
15769This specifies a list of permitted groups for the file specified by \file\. The
15770list is in addition to the local user's primary group when \check@_local@_user\
15771is set. See \check@_group\ above.
15772
15773.em
15774.conf qualify@_domain string$**$ unset
15775If this option is set and an unqualified address (one without a domain) is
15776generated, it is qualified with the domain specified by expanding this string,
15777instead of the global setting in \qualify@_recipient\. If the expansion fails,
15778the router declines. If you want to revert to the default, you can have the
15779expansion generate \$qualify@_recipient$\.
15780.nem
15781
15782.conf pipe@_transport string$**$ unset
15783A \%redirect%\ router sets up a direct delivery to a pipe when a string starting
15784with a vertical bar character is specified as a new `address'. The transport
15785used is specified by this option, which, after expansion, must be the name of a
15786configured transport.
15787This should normally be a \%pipe%\ transport.
15788When the transport is run, the pipe command is in \$address@_pipe$\.
15789
15790.conf qualify@_preserve@_domain boolean false
15791.index domain||in redirection, preserving
15792.index preserving domain in redirection
15793.index address redirection||domain, preserving
15794If this is set and an unqualified address (one without a domain) is generated,
15795it is qualified with the domain of the
15796.em
15797parent address (the immediately preceding ancestor) instead of the local
15798\qualify@_domain\ or global \qualify@_recipient\ value.
15799.nem
15800
15801.conf repeat@_use boolean true
15802If this option is set false, the router is skipped for a child address that has
15803any ancestor that was routed by this router. This test happens before any of
15804the other preconditions are tested. Exim's default anti-looping rules skip
15805only when the ancestor is the same as the current address. See also
15806\check@_ancestor\ above and the generic \redirect@_router\ option.
15807
15808.conf reply@_transport string$**$ unset
15809A \%redirect%\ router sets up an automatic reply when a \mail\ or \vacation\
15810command is used in a filter file. The transport used is specified by this
15811option, which, after expansion, must be the name of a configured transport.
15812This should normally be an \%autoreply%\ transport. Other transports are
15813unlikely to do anything sensible or useful.
15814
15815.conf rewrite boolean true
15816.index address redirection||disabling rewriting
15817If this option is set false, addresses generated by the router are not
15818subject to address rewriting. Otherwise, they are treated like new addresses
15819and are rewritten according to the global rewriting rules.
15820
15821.conf skip@_syntax@_errors boolean false
15822.index forward file||broken
15823.index address redirection||broken files
15824.index alias file||broken
15825.index broken alias or forward files
15826.index ignoring faulty addresses
15827.index skipping faulty addresses
15828.index error||skipping bad syntax
15829If \skip@_syntax@_errors\ is set, syntactically malformed addresses in
15830non-filter redirection data are skipped, and each failing address is logged. If
15831\syntax@_errors@_to\ is set, a message is sent to the address it defines,
15832giving details of the failures. If \syntax@_errors@_text\ is set, its contents
15833are expanded and placed at the head of the error message generated by
15834\syntax@_errors@_to\. Usually it is appropriate to set \syntax@_errors@_to\ to
15835be the same address as the generic \errors@_to\ option. The
15836\skip@_syntax@_errors\ option is often used when handling mailing lists.
15837
15838If all the addresses in a redirection list are skipped because of syntax
15839errors, the router declines to handle the original address, and it is passed to
15840the following routers.
15841
15842If \skip@_syntax@_errors\ is set when an Exim filter is interpreted, any syntax
15843error in the filter causes filtering to be abandoned without any action being
15844taken. The incident is logged, and the router declines to handle the address,
15845so it is passed to the following routers.
15846
15847.index Sieve filter||syntax errors in
15848Currently, any syntax errors in a Sieve filter file cause the `keep' action to
15849occur. The values of \skip@_syntax@_errors\, \syntax@_errors@_to\, and
15850\syntax@_errors@_text\ are not used.
15851
15852\skip@_syntax@_errors\ can be used to specify that errors in users' forward
15853lists or filter files should not prevent delivery. The \syntax@_errors@_to\
15854option, used with an address that does not get redirected, can be used to
15855notify users of these errors, by means of a router like this:
15856.display flow asis
15857userforward:
15858 driver = redirect
15859 allow_filter
15860 check_local_user
15861 file = $home/.forward
15862 file_transport = address_file
15863 pipe_transport = address_pipe
15864 reply_transport = address_reply
15865 no_verify
15866 skip_syntax_errors
15867 syntax_errors_to = real-$local_part@$domain
15868 syntax_errors_text = \
15869 This is an automatically generated message. An error has\n\
15870 been found in your .forward file. Details of the error are\n\
15871 reported below. While this error persists, you will receive\n\
15872 a copy of this message for every message that is addressed\n\
15873 to you. If your .forward file is a filter file, or if it is\n\
15874 a non-filter file containing no valid forwarding addresses,\n\
15875 a copy of each incoming message will be put in your normal\n\
15876 mailbox. If a non-filter file contains at least one valid\n\
15877 forwarding address, forwarding to the valid addresses will\n\
15878 happen, and those will be the only deliveries that occur.
15879.endd
15880You also need a router to ensure that local addresses that are prefixed by
15881\"real-"\ are recognized, but not forwarded or filtered. For example, you could
15882put this immediately before the \%userforward%\ router:
15883.display asis
15884real_localuser:
15885 driver = accept
15886 check_local_user
15887 local_part_prefix = real-
15888 transport = local_delivery
15889.endd
15890
15891.conf syntax@_errors@_text string$**$ unset
15892See \skip@_syntax@_errors\ above.
15893
15894.conf syntax@_errors@_to string unset
15895See \skip@_syntax@_errors\ above.
15896
15897.endconf
15898
15899
15900
15901
15902
15903.
15904.
15905.
15906. ============================================================================
15907.chapter Environment for running local transports
15908.rset CHAPenvironment "~~chapter"
15909.set runningfoot "local transport environment"
15910.index local transports||environment for
15911.index environment for local transports
15912.index transport||local, environment for
15913Local transports handle deliveries to files and pipes. (The \%autoreply%\
15914transport can be thought of as similar to a pipe.) Exim always runs transports
15915in subprocesses, under specified uids and gids. Typical deliveries to local
15916mailboxes run under the uid and gid of the local user.
15917
15918Exim also sets a specific current directory while running the transport; for
15919some transports a home directory setting is also relevant. The \%pipe%\
15920transport is the only one which sets up environment variables; see section
15921~~SECTpipeenv for details.
15922
15923The values used for the uid, gid, and the directories may come from several
15924different places. In many cases, the router that handles the address associates
15925settings with that address as a result of its \check@_local@_user\, \group\, or
15926\user\ options. However, values may also be given in the transport's own
15927configuration, and these override anything that comes from the router.
15928
15929.section Uids and gids
15930.rset SECTenvuidgid "~~chapter.~~section"
15931.index local transports||uid and gid
15932.index transport||local, uid and gid
15933All transports have the options \group\ and \user\. If \group\ is set, it
15934overrides any group that the router set in the address, even if \user\ is not
15935set for the transport. This makes it possible, for example, to run local mail
15936delivery under the uid of the recipient (set by the router), but in a special
15937group (set by the transport). For example:
15938.display asis
15939# Routers ...
15940# User/group are set by check_local_user in this router
15941local_users:
15942 driver = accept
15943 check_local_user
15944 transport = group_delivery
15945
15946# Transports ...
15947# This transport overrides the group
15948group_delivery:
15949 driver = appendfile
15950 file = /var/spool/mail/$local_part
15951 group = mail
15952.endd
15953If \user\ is set for a transport, its value overrides what is set in the
15954address. If \user\ is non-numeric and \group\ is not set, the gid associated
15955with the user is used. If \user\ is numeric, \group\ must be set.
15956
15957.index \initgroups\ option
15958When the uid is taken from the transport's configuration, the \*initgroups()*\
15959function is called for the groups associated with that uid if the \initgroups\
15960option is set for the transport. When the uid is not specified by the
15961transport, but is associated with the address by a router, the option for
15962calling \*initgroups()*\ is taken from the router configuration.
15963
15964.index \%pipe%\ transport||uid for
15965The \%pipe%\ transport contains the special option \pipe@_as@_creator\. If this
15966is set and \user\ is not set, the uid of the process that called Exim to
15967receive the message is used, and if \group\ is not set, the corresponding
15968original gid is also used.
15969
15970
15971.section Current and home directories
15972.index current directory for local transport
15973.index home directory||for local transport
15974.index transport||local, home directory for
15975.index transport||local, current directory for
15976Routers may set current and home directories for local transports by means of
15977the \transport__current@_directory\ and \transport@_home@_directory\ options.
15978However, if the transport's \current__directory\ or \home@_directory\ options
15979are set, they override the router's values. In detail, the home directory
15980for a local transport is taken from the first of these values that is set:
15981.numberpars $.
15982The \home@_directory\ option on the transport;
15983.nextp
15984The \transport@_home@_directory\ option on the router;
15985.nextp
15986The password data if \check@_local@_user\ is set on the router;
15987.nextp
15988The \router@_home@_directory\ option on the router.
15989.endp
15990The current directory is taken from the first of these values that is set:
15991.numberpars $.
15992The \current@_directory\ option on the transport;
15993.nextp
15994The \transport@_current@_directory\ option on the router.
15995.endp
15996
15997If neither the router nor the transport sets a current directory, Exim uses the
15998value of the home directory, if it is set. Otherwise it sets the current
15999directory to \(/)\ before running a local transport.
16000
16001
16002.section Expansion variables derived from the address
16003Normally a local delivery is handling a single address, and in that case the
16004variables such as \$domain$\ and \$local@_part$\ are set during local
16005deliveries. However, in some circumstances more than one address may be handled
16006at once (for example, while writing batch SMTP for onward transmission by some
16007other means). In this case, the variables associated with the local part are
16008never set, \$domain$\ is set only if all the addresses have the same
16009domain, and \$original@_domain$\ is never set.
16010
16011
16012
16013
16014
16015
16016
16017.
16018.
16019.
16020. ============================================================================
16021.chapter Generic options for transports
16022.rset CHAPtransportgeneric "~~chapter"
16023.set runningfoot "generic transport options"
16024
16025.index generic options||transport
16026.index options||generic, for transports
16027.index transport||generic options for
16028The following generic options apply to all transports:
16029
16030.startconf
16031.conf body@_only boolean false
16032.index transport||body only
16033.index message||transporting body only
16034.index body of message||transporting
16035If this option is set, the message's headers are not transported. It is
16036mutually exclusive with \headers@_only\. If it is used with the \%appendfile%\ or
16037\%pipe%\ transports, the settings of \message@_prefix\ and \message@_suffix\
16038should be checked, because this option does not automatically suppress them.
16039
16040.conf current@_directory string$**$ unset
16041.index transport||current directory for
16042This specifies the current directory that is to be set while running the
16043transport, overriding any value that may have been set by the router.
16044If the expansion fails for any reason, including forced failure, an error is
16045logged, and delivery is deferred.
16046
16047.conf disable@_logging boolean false
16048If this option is set true, nothing is logged for any
16049.em
16050deliveries by the transport or for any
16051.nem
16052transport errors. You should not set this option unless you really, really know
16053what you are doing.
16054
16055.conf debug@_print string$**$ unset
16056.index testing||variables in drivers
16057If this option is set and debugging is enabled (see the \-d-\ command line
16058option), the string is expanded and included in the debugging output when the
16059transport is run.
16060If expansion of the string fails, the error message is written to the debugging
16061output, and Exim carries on processing.
16062This facility is provided to help with checking out the values of variables and
16063so on when debugging driver configurations. For example, if a \headers@_add\
16064option is not working properly, \debug@_print\ could be used to output the
16065variables it references. A newline is added to the text if it does not end with
16066one.
16067
16068.conf delivery@_date@_add boolean false
16069.index ::Delivery-date:: header line
16070If this option is true, a ::Delivery-date:: header is added to the message. This
16071gives the actual time the delivery was made. As this is not a standard header,
16072Exim has a configuration option (\delivery@_date@_remove\) which requests its
16073removal from incoming messages, so that delivered messages can safely be resent
16074to other recipients.
16075
16076.conf driver string unset
16077This specifies which of the available transport drivers is to be used.
16078There is no default, and this option must be set for every transport.
16079
16080.conf envelope@_to@_add boolean false
16081.index ::Envelope-to:: header line
16082If this option is true, an ::Envelope-to:: header is added to the message. This
16083gives the original address(es) in the incoming envelope that caused this
16084delivery to happen. More than one address may be present if the transport is
16085configured to handle several addresses at once, or if more than one original
16086address was redirected to the same final address. As this is not a standard
16087header, Exim has a configuration option (\envelope@_to@_remove\) which requests
16088its removal from incoming messages, so that delivered messages can safely be
16089resent to other recipients.
16090
16091.conf group string$**$ "Exim group"
16092.index transport||group, specifying
16093This option specifies a gid for running the transport process, overriding any
16094value that the router supplies, and also overriding any value associated with
16095\user\ (see below).
16096
16097.conf headers@_add string$**$ unset
16098.index header lines||adding in transport
16099.index transport||header lines, adding
16100This option specifies a string of text which is expanded and added to the
16101header portion of a message as it is transported. If the result of the
16102expansion is an empty string, or if the expansion is forced to fail, no action
16103is taken. Other expansion failures are treated as errors and cause the delivery
16104to be deferred. The expanded string should be in the form of one or more RFC
161052822 header lines, separated by newlines (coded as `@\n'), for example:
16106.display asis
16107headers_add = X-added: this is a header added at $tod_log\n\
16108 X-added: this is another
16109.endd
16110Exim does not check the syntax of these added header lines. They are added at
16111the end of the existing header lines. If you include a blank line within the
16112string, you can subvert this facility into adding text at the start of the
16113message's body. This is not recommended. Additional header lines can also be
16114specified by routers. See chapter ~~CHAProutergeneric and section
16115~~SECTheadersaddrem.
16116
16117.conf headers@_only boolean false
16118.index transport||header lines only
16119.index message||transporting headers only
16120.index header lines||transporting
16121If this option is set, the message's body is not transported. It is mutually
16122exclusive with \body@_only\. If it is used with the \%appendfile%\ or \%pipe%\
16123transports, the settings of \message@_prefix\ and \message__suffix\ should be
16124checked, since this option does not automatically suppress them.
16125
16126.conf headers@_remove string$**$ unset
16127.index header lines||removing
16128.index transport||header lines, removing
16129This option is expanded; the result must consist of a colon-separated list of
16130header names, not including the terminating colon, for example:
16131.display asis
16132headers_remove = return-receipt-to:acknowledge-to
16133.endd
16134Any existing headers matching those names are not included in any message that
16135is transmitted by the transport.
16136If the result of the expansion is an empty string, or if the expansion is
16137forced to fail, no action is taken. Other expansion failures are treated as
16138errors and cause the delivery to be deferred.
16139
16140If there are multiple instances of a header, they are all removed. However,
16141added headers may have these names. Thus it is possible to replace a header by
16142specifying it in \headers@_remove\ and supplying the replacement in
16143\headers@_add\. Headers to be removed can also be specified by routers. See
16144chapter ~~CHAProutergeneric and section ~~SECTheadersaddrem.
16145
16146.conf headers@_rewrite string unset
16147.index transport||header lines, rewriting
16148.index rewriting||at transport time
16149This option allows addresses in header lines to be rewritten at transport time,
16150that is, as the message is being copied to its destination. The contents of the
16151option are a colon-separated list of rewriting rules. Each rule is in exactly
16152the same form as one of the general rewriting rules that are applied when a
16153message is received. These are described in chapter ~~CHAPrewrite. For example,
16154.display asis
16155headers_rewrite = a@b c@d f : \
16156 x@y w@z
16157.endd
16158changes \a@@b\ into \c@@d\ in ::From:: header lines, and \x@@y\ into \w@@z\ in
16159all address-bearing header lines. The rules are applied to the header lines
16160just before they are written out at transport time, so they affect only those
16161copies of the message that pass through the transport. However, only the
16162message's original header lines, and any that were added by a system filter,
16163are rewritten. If a router or transport adds header lines, they are
16164not affected by this option. These rewriting rules are $it{not} applied to the
16165envelope. You can change the return path using \return@_path\, but you cannot
16166change envelope recipients at this time.
16167
16168.conf home@_directory string$**$ unset
16169.index transport||home directory for
16170This option specifies a home directory setting for the transport, overriding
16171any value that may be set by the router. The home directory is placed in
16172\$home$\ while expanding the transport's private options. It is also used as
16173the current directory if no current directory is set by the
16174\current__directory\ option on the transport or the
16175\transport__current__directory\ option on the router.
16176If the expansion fails for any reason, including forced failure, an error is
16177logged, and delivery is deferred.
16178
16179
16180.index additional groups
16181.index groups, additional
16182.index transport||group, additional
16183.conf initgroups boolean false
16184If this option is true and the uid for the delivery process is provided by the
16185transport, the \*initgroups()*\ function is called when running the transport
16186to ensure that any additional groups associated with the uid are set up.
16187
16188.conf message@_size@_limit string$**$ 0
16189.index limit||message size per transport
16190.index size||of message, limit
16191.index transport||message size, limiting
16192This option controls the size of messages passed through the transport. It is
16193expanded before use; the result of the expansion must be a sequence of digits,
16194optionally followed by K or M.
16195If the expansion fails for any reason, including forced failure, or if the
16196result is not of the required form, delivery is deferred.
16197If the value is greater than zero and the size of a message exceeds this
16198limit, the address is failed. If there is any chance that the resulting bounce
16199message could be routed to the same transport, you should ensure that
16200\return@_size@_limit\ is less than the transport's \message@_size@_limit\, as
16201otherwise the bounce message will fail to get delivered.
16202
16203
16204.conf rcpt@_include@_affixes boolean false
16205.index prefix||for local part, including in envelope
16206.index suffix||for local part, including in envelope
16207.index local part||prefix
16208.index local part||suffix
16209When this option is false (the default), and an address that has had any
16210affixes (prefixes or suffixes) removed from the local part is delivered by any
16211form of SMTP or LMTP, the affixes are not included. For example, if a router
16212that contains
16213.display asis
16214local_part_prefix = *-
16215.endd
16216routes the address \*abc-xyz@@some.domain*\ to an SMTP transport, the envelope
16217is delivered with
16218.display asis
16219RCPT TO:<xyz@some.domain>
16220.endd
16221If \rcpt@_include@_affixes\ is set true, the whole local part is included in
16222the \\RCPT\\ command. This option applies to BSMTP deliveries by the
16223\%appendfile%\ and \%pipe%\ transports as well as to the \%lmtp%\ and \%smtp%\
16224transports.
16225
16226.conf retry@_use@_local@_part boolean "see below"
16227.index hints database||retry keys
16228When a delivery suffers a temporary failure, a retry record is created
16229in Exim's hints database. For remote deliveries, the key for the retry record
16230is based on the name and/or IP address of the failing remote host. For local
16231deliveries, the key is normally the entire address, including both the local
16232part and the domain. This is suitable for most common cases of local delivery
16233temporary failure -- for example, exceeding a mailbox quota should delay only
16234deliveries to that mailbox, not to the whole domain.
16235
16236However, in some special cases you may want to treat a temporary local delivery
16237as a failure associated with the domain, and not with a particular local part.
16238(For example, if you are storing all mail for some domain in files.) You can do
16239this by setting \retry@_use@_local@_part\ false.
16240
16241For all the local transports, its default value is true. For remote transports,
16242the default value is false for tidiness, but changing the value has no effect
16243on a remote transport in the current implementation.
16244
16245.conf return@_path string$**$ unset
16246.index envelope sender
16247.index transport||return path, changing
16248.index return path||changing in transport
16249If this option is set, the string is expanded at transport time and replaces
16250the existing return path (envelope sender) value in the copy of the message
16251that is being delivered. An empty return path is permitted. This feature is
16252designed for remote deliveries, where the value of this option is used in the
16253SMTP \\MAIL\\ command. If you set \return@_path\ for a local transport, the
16254only effect is to change the address that is placed in the ::Return-path::
16255header line, if one is added to the message (see the next option).
16256
16257The expansion can refer to the existing value via \$return@_path$\. This is
16258either the message's envelope sender, or an address set by the
16259\errors@_to\ option on a router. If the expansion is forced to fail, no
16260replacement occurs; if it fails for another reason, delivery is deferred. This
16261option can be used to support VERP (Variable Envelope Return Paths) -- see
16262chapter ~~CHAPSMTP.
16263
16264\**Note**\: If a delivery error is detected locally,
16265.em
16266including the case when a remote server rejects a message at SMTP time,
16267the bounce message is not sent to the value of this option, but to the
16268previously set errors address (which defaults to the incoming sender address).
16269.nem
16270
16271
16272.conf return@_path@_add boolean false
16273.index ::Return-path:: header line
16274If this option is true, a ::Return-path:: header is added to the message.
16275Although the return path is normally available in the prefix line of BSD
16276mailboxes, this is commonly not displayed by MUAs, and so the user does not
16277have easy access to it.
16278
16279RFC 2821 states that the ::Return-path:: header is added to a message `when the
16280delivery SMTP server makes the final delivery'. This implies that this header
16281should not be present in incoming messages. Exim has a configuration option,
16282\return@_path@_remove\, which requests removal of this header from incoming
16283messages, so that delivered messages can safely be resent to other recipients.
16284
16285.conf shadow@_condition string$**$ unset
16286See \shadow@_transport\ below.
16287
16288.conf shadow@_transport string unset
16289.index shadow transport
16290.index transport||shadow
16291A local transport may set the \shadow@_transport\ option to the name of another
16292local transport. Shadow remote transports are not supported.
16293
16294Whenever a delivery to the main transport succeeds, and either
16295\shadow@_condition\ is unset, or its expansion does not result in the empty
16296string or one of the strings `0' or `no' or `false', the message is also passed
16297to the shadow transport, with the same delivery address or addresses.
16298If expansion fails, no action is taken except that non-forced expansion
16299failures cause a log line to be written.
16300
16301The result of the shadow transport is discarded and does not affect the
16302subsequent processing of the message. Only a single level of shadowing is
16303provided; the \shadow@_transport\ option is ignored on any transport when it is
16304running as a shadow. Options concerned with output from pipes are also ignored.
16305
16306The log line for the successful delivery has an item added on the end, of the
16307form
16308.display
16309ST=<<shadow transport name>>
16310.endd
16311If the shadow transport did not succeed, the error message is put in
16312parentheses afterwards.
16313
16314Shadow transports can be used for a number of different purposes, including
16315keeping more detailed log information than Exim normally provides, and
16316implementing automatic acknowledgement policies based on message headers that
16317some sites insist on.
16318
16319.conf transport@_filter string$**$ unset
16320.index transport||filter
16321.index filter||transport filter
16322This option sets up a filtering (in the Unix shell sense) process for messages
16323at transport time. It should not be confused with mail filtering as set up by
16324individual users or via a system filter.
16325
16326When the message is about to be written out, the command specified by
16327\transport@_filter\ is started up in a separate process, and the entire
16328message, including the header lines, is passed to it on its standard input
16329(this in fact is done from a third process, to avoid deadlock).
16330The command must be specified as an absolute path.
16331
16332The message is passed to the filter before any SMTP-specific processing, such
16333as turning `@\n' into `@\r@\n' and escaping lines beginning with a dot, and
16334also before any processing implied by the settings of \check@_string\ and
16335\escape@_string\ in the \%appendfile%\ or \%pipe%\ transports.
16336
16337The filter's standard output is read and written to the message's destination.
16338The filter can perform any transformations it likes, but of course should take
16339care not to break RFC 2822 syntax. A demonstration Perl script is provided in
16340\(util/transport-filter.pl)\; this makes a few arbitrary modifications just to
16341show the possibilities. Exim does not check the result, except to test for a
16342final newline when SMTP is in use. All messages transmitted over SMTP must end
16343with a newline, so Exim supplies one if it is missing.
16344
16345.index SMTP||\\SIZE\\
16346A problem might arise if the filter increases the size of a message that is
16347being sent down an SMTP connection. If the receiving SMTP server has indicated
16348support for the \\SIZE\\ parameter, Exim will have sent the size of the message
16349at the start of the SMTP session. If what is actually sent is substantially
16350more, the server might reject the message. This can be worked round by setting
16351the \size@_addition\ option on the \%smtp%\ transport, either to allow for
16352additions to the message, or to disable the use of \\SIZE\\ altogether.
16353
16354The value of the option is the command string for starting up the filter, which
16355is run directly from Exim, not under a shell. The string is parsed by Exim in
16356the same way as a command string for the \%pipe%\ transport: Exim breaks it up
16357into arguments and then expands each argument separately. The special argument
16358\$pipe@_addresses$\ is replaced by a number of arguments, one for each address
16359that applies to this delivery. (This isn't an ideal name for this feature here,
16360but as it was already implemented for the \%pipe%\ transport, it seemed sensible
16361not to change it.)
16362
16363.index \$host$\
16364.index \$host@_address$\
16365The expansion variables \$host$\ and \$host@_address$\ are available when the
16366transport is a remote one. They contain the name and IP address of the host to
16367which the message is being sent. For example:
16368.display asis
16369transport_filter = /some/directory/transport-filter.pl \
16370 $host $host_address $sender_address $pipe_addresses
16371.endd
16372The filter process is run under the same uid and gid as the normal delivery.
16373For remote deliveries this is the Exim uid/gid by default.
16374
16375If a transport filter is set on an autoreply transport, the original message is
16376passed through the filter as it is being copied into the newly generated
16377message, which happens if the \return@_message\ option is set.
16378
16379.conf transport@_filter@_timeout time 5m
16380.index transport||filter, timeout
16381When Exim is reading the output of a transport filter, it a applies a timeout
16382that can be set by this option. Exceeding the timeout is treated as a
16383temporary delivery failure.
16384
16385
16386.conf user string$**$ "Exim user"
16387.index uid (user id)||local delivery
16388.index transport||user, specifying
16389This option specifies the user under whose uid the delivery process is to be
16390run, overriding any uid that may have been set by the router. If the user is
16391given as a name, the uid is looked up from the password data, and the
16392associated group is taken as the value of the gid to be used if the \group\
16393option is not set.
16394
16395.em
16396For deliveries that use local transports, a user and group are normally
16397specified explicitly or implicitly (for example, as a result of
16398\check@_local@_user\) by the router or transport.
16399.nem
16400
16401.index hints database||access by remote transport
16402For remote transports, you should leave this option unset unless you really are
16403sure you know what you are doing. When a remote transport is running, it needs
16404to be able to access Exim's hints databases, because each host may have its own
16405retry data.
16406
16407.endconf
16408
16409
16410
16411
16412
16413.
16414.
16415.
16416. ============================================================================
16417.chapter Address batching in local transports
16418.set runningfoot "address batching"
16419.rset CHAPbatching ~~chapter
16420.index transport||local, address batching in
16421The only remote transport (\%smtp%\) is normally configured to handle more than
16422one address at a time, so that when several addresses are routed to the same
16423remote host, just one copy of the message is sent. Local transports, however,
16424normally handle one address at a time. That is, a separate instance of the
16425transport is run for each address that is routed to the transport. A separate
16426copy of the message is delivered each time.
16427
16428.index batched local delivery
16429.index \batch@_max\
16430.index \batch@_id\
16431In special cases, it may be desirable to handle several addresses at once in a
16432local transport, for example:
16433.numberpars $.
16434In an \%appendfile%\ transport, when storing messages in files for later
16435delivery by some other means, a single copy of the message with multiple
16436recipients saves space.
16437.nextp
16438In an \%lmtp%\ transport, when delivering over `local SMTP' to some process,
16439a single copy saves time, and is the normal way LMTP is expected to work.
16440.nextp
16441In a \%pipe%\ transport, when passing the message
16442to a scanner program or
16443to some other delivery mechanism such as UUCP, multiple recipients may be
16444acceptable.
16445.endp
16446The three local transports (\%appendfile%\, \%lmtp%\, and \%pipe%\) all have
16447the same options for controlling multiple (`batched') deliveries, namely
16448\batch@_max\ and \batch@_id\. To save repeating the information for each
16449transport, these options are described here.
16450
16451The \batch@_max\ option specifies the maximum number of addresses that can be
16452delivered together in a single run of the transport. Its default value is one.
16453When more than one address is routed to a transport that has a \batch@_max\
16454value greater than one, the addresses are delivered in a batch (that is, in a
16455single run of the transport), subject to certain conditions:
16456.numberpars $.
16457If any of the transport's options contain a reference to \$local@_part$\, no
16458batching is possible.
16459.nextp
16460If any of the transport's options contain a reference to \$domain$\, only
16461addresses with the same domain are batched.
16462.nextp
16463.index customizing||batching condition
16464If \batch@_id\ is set, it is expanded for each address, and only those
16465addresses with the same expanded value are batched. This allows you to specify
16466customized batching conditions.
16467Failure of the expansion for any reason, including forced failure, disables
16468batching, but it does not stop the delivery from taking place.
16469.nextp
16470Batched addresses must also have the same errors address (where to send
16471delivery errors), the same header additions and removals, the same user and
16472group for the transport, and if a host list is present, the first host must
16473be the same.
16474.endp
16475.index ::Envelope-to:: header line
16476If the generic \envelope@_to@_add\ option is set for the transport, the
16477::Envelope-to:: header that is added to the message contains all the addresses
16478that are batched together.
16479
16480The \%appendfile%\ and \%pipe%\ transports have an option called \use@_bsmtp\,
16481which causes them to deliver the message in `batched SMTP' format, with the
16482envelope represented as SMTP commands. The \check@_string\ and \escape@_string\
16483options are forced to the values
16484.display asis
16485check_string = "."
16486escape_string = ".."
16487.endd
16488when batched SMTP is in use. A full description of the batch SMTP mechanism is
16489given in section ~~SECTbatchSMTP. The \%lmtp%\ transport does not have a
16490\use@_bsmtp\ option, because it always delivers using the SMTP protocol.
16491
16492.index \%pipe%\ transport||with multiple addresses
16493If you are not using BSMTP, but are using a \%pipe%\ transport, you can include
16494\$pipe@_addresses$\ as part of the command. This is not a true variable; it is
16495a bit of magic that causes each of the recipient addresses to be inserted into
16496the command as a separate argument. This provides a way of accessing all the
16497addresses that are being delivered in the batch.
16498
16499If you are using a batching \%appendfile%\ transport without \use@_bsmtp\, the
16500only way to preserve the recipient addresses is to set the \envelope@_to@_add\
16501option. This causes an ::Envelope-to:: header line to be added to the message,
16502containing all the recipients.
16503
16504
16505
16506.
16507.
16508.
16509. ============================================================================
16510.chapter The appendfile transport
16511.set runningfoot "appendfile transport"
16512.rset CHAPappendfile ~~chapter
16513.index \%appendfile%\ transport
16514.index transports||\%appendfile%\
16515.index directory creation
16516.index creating directories
16517The \%appendfile%\ transport delivers a message by appending it to an existing
16518file, or by creating an entirely new file in a specified directory. Single
16519files to which messages are appended can be in the traditional Unix mailbox
16520format, or optionally in the MBX format supported by the Pine MUA and
16521University of Washington IMAP daemon, $it{inter alia}. When each message is
16522being delivered as a separate file, `maildir' format can optionally be used to
16523give added protection against failures that happen part-way through the
16524delivery. A third form of separate-file delivery known as `mailstore' is also
16525supported. For all file formats, Exim attempts to create as many levels of
16526directory as necessary, provided that \create@_directory\ is set.
16527
16528The code for the optional formats is not included in the Exim binary by
16529default. It is necessary to set \\SUPPORT@_MBX\\, \\SUPPORT@_MAILDIR\\ and/or
16530\\SUPPORT@_MAILSTORE\\ in \(Local/Makefile)\ to have the appropriate code
16531included.
16532
16533.index quota||system
16534Exim recognises system quota errors, and generates an appropriate message. Exim
16535also supports its own quota control within the transport, for use when the
16536system facility is unavailable or cannot be used for some reason.
16537
16538If there is an error while appending to a file (for example, quota exceeded or
16539partition filled), Exim attempts to reset the file's length and last
16540modification time back to what they were before. If there is an error while
16541creating an entirely new file, the new file is removed.
16542
16543Before appending to a file, a number of security checks are made, and the
16544file is locked. A detailed description is given below, after the list of
16545private options.
16546
16547\%appendfile%\ is most commonly used for local deliveries to users' mailboxes.
16548However, it can also be used as a pseudo-remote transport for putting messages
16549into files for remote delivery by some means other than Exim. `Batch SMTP'
16550format is often used in this case (see the \use@_bsmtp\ option).
16551
16552
16553.section The file and directory options
16554.rset SECTfildiropt "~~chapter.~~section"
16555The \file\ option specifies a single file, to which the message is appended;
16556the \directory\ option specifies a directory, in which a new file containing
16557the message is created. Only one of these two options can be set, and for
16558normal deliveries to mailboxes, one of them \*must*\ be set.
16559
16560However, \%appendfile%\ is also used for delivering messages to files or
16561directories whose names (or parts of names) are obtained from alias,
16562forwarding, or filtering operations (for example, a \save\ command in a user's
16563Exim filter). When such a transport is running, \$local@_part$\ contains the
16564local part that was aliased or forwarded, and \$address@_file$\ contains the
16565name (or partial name) of the file or directory generated by the redirection
16566operation. There are two cases:
16567.numberpars $.
16568If neither \file\ nor \directory\ is set, the redirection operation
16569must specify an absolute path (one that begins with \"/"\). This is the most
16570common case when users with local accounts use filtering to sort mail into
16571different folders. See for example, the \%address@_file%\ transport in the
16572default configuration. If the path ends with a slash, it is assumed to be the
16573name of a directory. A delivery to a directory can also be forced by setting
16574\maildir@_format\ or \mailstore@_format\.
16575.nextp
16576If \file\ or \directory\ is set for a delivery from a redirection, it is used
16577to determine the file or directory name for the delivery. Normally, the
16578contents of \$address@_file$\ are used in some way in the string expansion.
16579.endp
16580
16581.index Sieve filter||configuring \%appendfile%\
16582.index Sieve filter||relative mailbox path handling
16583As an example of the second case, consider an environment where users do not
16584have home directories. They may be permitted to use Exim filter commands of the
16585form:
16586.display asis
16587save folder23
16588.endd
16589or Sieve filter commands of the form:
16590.display asis
16591require "fileinto";
16592fileinto "folder23";
16593.endd
16594In this situation, the expansion of \file\ or \directory\ in the transport must
16595transform the relative path into an appropriate absolute file name. In the case
16596of Sieve filters, the name \*inbox*\ must be handled. It is the name that is
16597used as a result of a `keep' action in the filter. This example shows one way
16598of handling this requirement:
16599.display asis
16600file = ${if eq{$address_file}{inbox} \
16601 {/var/mail/$local_part} \
16602 {${if eq{${substr_0_1:$address_file}}{/} \
16603 {$address_file} \
16604 {$home/mail/$address_file} \
16605 }} \
16606 }
16607.endd
16608With this setting of \file\, \*inbox*\ refers to the standard mailbox location,
16609absolute paths are used without change, and other folders are in the \(mail)\
16610directory within the home directory.
16611
16612\**Note 1**\: While processing an Exim filter, a relative path such as
16613\(folder23)\ is turned into an absolute path if a home directory is known to
16614the router. In particular, this is the case if \check@_local@_user\ is set. If
16615you want to prevent this happening at routing time, you can set
16616\router@_home@_directory\ empty. This forces the router to pass the relative
16617path to the transport.
16618
16619\**Note 2**\: An absolute path in \$address@_file$\ is not treated specially;
16620the \file\ or \directory\ option is still used if it is set.
16621
16622
16623
16624.section Private options for appendfile
16625.index options||\%appendfile%\ transport
16626
16627.startconf
16628
16629.conf allow@_fifo boolean false
16630.index fifo (named pipe)
16631.index named pipe (fifo)
16632.index pipe||named (fifo)
16633Setting this option permits delivery to named pipes (FIFOs) as well as to
16634regular files. If no process is reading the named pipe at delivery time, the
16635delivery is deferred.
16636
16637.conf allow@_symlink boolean false
16638.index symbolic link||to mailbox
16639.index mailbox||symbolic link
16640By default, \%appendfile%\ will not deliver if the path name for the file is
16641that of a symbolic link. Setting this option relaxes that constraint, but there
16642are security issues involved in the use of symbolic links. Be sure you know
16643what you are doing if you set this. Details of exactly what this option affects
16644are included in the discussion which follows this list of options.
16645
16646.conf batch@_id string$**$ unset
16647See the description of local delivery batching in chapter ~~CHAPbatching.
16648However, batching is automatically disabled for \%appendfile%\ deliveries that
16649happen as a result of forwarding or aliasing or other redirection directly to a
16650file.
16651
16652.conf batch@_max integer 1
16653See the description of local delivery batching in chapter ~~CHAPbatching.
16654
16655.conf check@_group boolean false
16656When this option is set, the group owner of the file defined by the \file\
16657option is checked to see that it is the same as the group under which the
16658delivery process is running. The default setting is false because the default
16659file mode is 0600, which means that the group is irrelevant.
16660
16661.conf check@_owner boolean true
16662When this option is set, the owner of the file defined by the \file\ option is
16663checked to ensure that it is the same as the user under which the delivery
16664process is running.
16665
16666.conf check@_string string "see below"
16667.index `From' line
16668As \%appendfile%\ writes the message, the start of each line is tested for
16669matching \check@_string\, and if it does, the initial matching characters are
16670replaced by the contents of \escape@_string\. The value of \check@_string\ is a
16671literal string, not a regular expression, and the case of any letters it
16672contains is significant.
16673
16674If \use@_bsmtp\ is set the values of \check@_string\ and \escape@_string\ are
16675forced to `.' and `..' respectively, and any settings in the configuration are
16676ignored. Otherwise, they default to `From ' and `>From ' when the \file\ option
16677is set, and unset when
16678any of the \directory\, \maildir\, or \mailstore\ options are set.
16679
16680The default settings, along with \message@_prefix\ and \message@_suffix\, are
16681suitable for traditional `BSD' mailboxes, where a line beginning with `From '
16682indicates the start of a new message. All four options need changing if another
16683format is used. For example, to deliver to mailboxes in MMDF format:
16684.index MMDF format mailbox
16685.index mailbox||MMDF format
16686.display asis
16687check_string = "\1\1\1\1\n"
16688escape_string = "\1\1\1\1 \n"
16689message_prefix = "\1\1\1\1\n"
16690message_suffix = "\1\1\1\1\n"
16691.endd
16692
16693.index directory creation
16694.conf create@_directory boolean true
16695When this option is true, Exim attempts to create any missing superior
16696directories for the file that it is about to write. A created directory's mode
16697is given by the \directory@_mode\ option.
16698
16699.conf create@_file string "anywhere"
16700This option constrains the location of files and directories that are created
16701by this transport. It applies to files defined by the \file\ option and
16702directories defined by the \directory\ option. In the case of maildir delivery,
16703it applies to the top level directory, not the maildir directories beneath.
16704
16705The option must be set to one of the words `anywhere', `inhome', or
16706`belowhome'. In the second and third cases, a home directory must have been set
16707for the transport. This option is not useful when an explicit file name is
16708given for normal mailbox deliveries. It is intended for the case when file
16709names are generated from users' \(.forward)\ files. These are usually handled
16710by an \%appendfile%\ transport called \address@_file\. See also
16711\file@_must@_exist\.
16712
16713.conf directory string$**$ unset
16714This option is mutually exclusive with the \file\ option, but one of \file\ or
16715\directory\ must be set, unless the delivery is the direct result of a
16716redirection (see section ~~SECTfildiropt).
16717
16718When \directory\ is set, the string is expanded, and the message is delivered
16719into a new file or files in or below the given directory, instead of being
16720appended to a single mailbox file. A number of different formats are provided
16721(see \maildir@_format\ and \mailstore@_format\), and see section ~~SECTopdir
16722for further details of this form of delivery.
16723
16724.conf directory@_file string$**$ "$tt{q@$@{base62:@$tod@_epoch@}-@$inode}"
16725.index base62
16726When \directory\ is set, but neither \maildir@_format\ nor \mailstore@_format\
16727is set, \%appendfile%\ delivers each message into a file whose name is obtained
16728by expanding this string. The default value generates a unique name from the
16729current time, in base 62 form, and the inode of the file. The variable
16730\$inode$\ is available only when expanding this option.
16731
16732.conf directory@_mode "octal integer" 0700
16733If \%appendfile%\ creates any directories as a result of the \create@_directory\
16734option, their mode is specified by this option.
16735
16736.conf escape@_string string "see description"
16737See \check@_string\ above.
16738
16739.conf file string$**$ unset
16740This option is mutually exclusive with the \directory\ option, but one of
16741\file\ or \directory\ must be set, unless the delivery is the direct result of
16742a redirection (see section ~~SECTfildiropt). The \file\ option specifies a
16743single file, to which the message is appended. One or more of
16744\use@_fcntl@_lock\, \use@_flock@_lock\, or \use@_lockfile\ must be set with
16745\file\.
16746.index NFS||lock file
16747.index locking files
16748.index lock files
16749If you are using more than one host to deliver over NFS into the same
16750mailboxes, you should always use lock files.
16751
16752The string value is expanded for each delivery, and must yield an absolute
16753path. The most common settings of this option are variations on one of these
16754examples:
16755.display asis
16756file = /var/spool/mail/$local_part
16757file = /home/$local_part/inbox
16758file = $home/inbox
16759.endd
16760.index `sticky' bit
16761In the first example, all deliveries are done into the same directory. If Exim
16762is configured to use lock files (see \use@_lockfile\ below) it must be able to
16763create a file in the directory, so the `sticky' bit must be turned on for
16764deliveries to be possible, or alternatively the \group\ option can be used to
16765run the delivery under a group id which has write access to the directory.
16766
16767
16768.conf file@_format string unset
16769.index file||mailbox, checking existing format
16770This option requests the transport to check the format of an existing file
16771before adding to it. The check consists of matching a specific string at the
16772start of the file. The value of the option consists of an even number of
16773colon-separated strings. The first of each pair is the test string, and the
16774second is the name of a transport. If the transport associated with a matched
16775string is not the current transport, control is passed over to the other
16776transport. For example, suppose the standard \%local@_delivery%\ transport has
16777this added to it:
16778.display asis
16779file_format = "From : local_delivery :\
16780 \1\1\1\1\n : local_mmdf_delivery"
16781.endd
16782Mailboxes that begin with `From' are still handled by this transport, but if a
16783mailbox begins with four binary ones followed by a newline, control is passed
16784to a transport called \local__mmdf__delivery\, which presumably is configured
16785to do the delivery in MMDF format. If a mailbox does not exist or is empty, it
16786is assumed to match the current transport. If the start of a mailbox doesn't
16787match any string, or if the transport named for a given string is not defined,
16788delivery is deferred.
16789
16790.conf file@_must@_exist boolean false
16791If this option is true, the file specified by the \file\ option must exist, and
16792an error occurs if it does not. Otherwise, it is created if it does not exist.
16793
16794.conf lock@_fcntl@_timeout time 0s
16795.index timeout||mailbox locking
16796.index mailbox locking||blocking and non-blocking
16797.index locking files
16798By default, the \%appendfile%\ transport uses non-blocking calls to \*fcntl()*\
16799when locking an open mailbox file. If the call fails, the delivery process
16800sleeps for \lock@_interval\ and tries again, up to \lock@_retries\ times.
16801Non-blocking calls are used so that the file is not kept open during the wait
16802for the lock; the reason for this is to make it as safe as possible for
16803deliveries over NFS in the case when processes might be accessing an NFS
16804mailbox without using a lock file. This should not be done, but
16805misunderstandings and hence misconfigurations are not unknown.
16806
16807On a busy system, however, the performance of a non-blocking lock approach is
16808not as good as using a blocking lock with a timeout. In this case, the waiting
16809is done inside the system call, and Exim's delivery process acquires the lock
16810and can proceed as soon as the previous lock holder releases it.
16811
16812If \lock@_fcntl@_timeout\ is set to a non-zero time, blocking locks, with that
16813timeout, are used. There may still be some retrying: the maximum number of
16814retries is
16815.display asis
16816(lock_retries * lock_interval) / lock_fcntl_timeout
16817.endd
16818rounded up to the next whole number. In other words, the total time during
16819which \%appendfile%\ is trying to get a lock is roughly the same, unless
16820\lock@_fcntl@_timeout\ is set very large.
16821
16822You should consider setting this option if you are getting a lot of delayed
16823local deliveries because of errors of the form
16824.display asis
16825failed to lock mailbox /some/file (fcntl)
16826.endd
16827
16828.conf lock@_flock@_timeout time 0s
16829This timeout applies to file locking when using \*flock()*\ (see \use@_flock\);
16830the timeout operates in a similar manner to \lock@_fcntl@_timeout\.
16831
16832.conf lock@_interval time 3s
16833This specifies the time to wait between attempts to lock the file. See below
16834for details of locking.
16835
16836.conf lock@_retries integer 10
16837This specifies the maximum number of attempts to lock the file. A value of zero
16838is treated as 1. See below for details of locking.
16839
16840.conf lockfile@_mode "octal integer" 0600
16841This specifies the mode of the created lock file, when a lock file is being
16842used (see \use@_lockfile\).
16843
16844.conf lockfile@_timeout time 30m
16845.index timeout||mailbox locking
16846When a lock file is being used (see \use@_lockfile\), if a lock file already
16847exists and is older than this value, it is assumed to have been left behind by
16848accident, and Exim attempts to remove it.
16849
16850.conf maildir@_format boolean false
16851.index maildir format||specifying
16852If this option is set with the \directory\ option, the delivery is into a new
16853file, in the `maildir' format that is used by other mail software. When the
16854transport is activated directly from a \%redirect%\ router (for example, the
16855\%address@_file%\ transport in the default configuration), setting
16856\maildir@_format\ causes the path received from the router to be treated as a
16857directory, whether or not it ends with \"/"\. This option is available only if
16858\\SUPPORT@_MAILDIR\\ is present in \(Local/Makefile)\. See section
16859~~SECTmaildirdelivery below for further details.
16860
16861.em
16862.conf maildir@_quota@_directory@_regex string "See below"
16863.index maildir format||quota, directories included in
16864.index quota||maildir, directories included in
16865This option is relevant only when \maildir@_use@_size@_file\ is set. It defines
16866a regular expression for specifying directories that should be included in the
16867quota calculation. The default value is
16868.display asis
16869maildir_quota_directory_regex = ^(?:cur|new|\..*)$
16870.endd
16871which includes the \(cur)\ and \(new)\ directories, and any maildir++ folders
16872(directories whose names begin with a dot). If you want to exclude the
16873\(Trash)\
16874folder from the count (as some sites do), you need to change this setting to
16875.display asis
16876maildir_quota_directory_regex = ^(?:cur|new|\.(?!Trash).*)$
16877.endd
16878This uses a negative lookahead in the regular expression to exclude the
16879directory whose name is \(.Trash)\.
16880.nem
16881
16882.conf maildir@_retries integer 10
16883This option specifies the number of times to retry when writing a file in
16884`maildir' format. See section ~~SECTmaildirdelivery below.
16885
16886.conf maildir@_tag string$**$ unset
16887This option applies only to deliveries in maildir format, and is described in
16888section ~~SECTmaildirdelivery below.
16889
16890.conf maildir@_use@_size@_file boolean false
16891.index maildir format||\(maildirsize)\ file
16892Setting this option true enables support for \(maildirsize)\ files. Exim
16893creates a \(maildirsize)\ file in a maildir if one does not exist, taking the
16894quota from the \quota\ option of the transport. If \quota\ is unset, the value
16895is zero. See section ~~SECTmaildirdelivery below for further details.
16896
16897.conf mailstore@_format boolean false
16898.index mailstore format||specifying
16899If this option is set with the \directory\ option, the delivery is into two new
16900files in `mailstore' format. The option is available only if
16901\\SUPPORT@_MAILSTORE\\ is present in \(Local/Makefile)\. See section
16902~~SECTopdir below for further details.
16903
16904.conf mailstore@_prefix string$**$ unset
16905This option applies only to deliveries in mailstore format, and is described in
16906section ~~SECTopdir below.
16907
16908.conf mailstore@_suffix string$**$ unset
16909This option applies only to deliveries in mailstore format, and is described in
16910section ~~SECTopdir below.
16911
16912.conf mbx@_format boolean false
16913.index locking files
16914.index file||locking
16915.index file||MBX format
16916.index MBX format, specifying
16917This option is available only if Exim has been compiled with \\SUPPORT@_MBX\\
16918set in \(Local/Makefile)\. If \mbx@_format\ is set with the \file\ option,
16919the message is appended to the mailbox file in MBX format instead of
16920traditional Unix format. This format is supported by Pine4 and its associated
16921IMAP and POP daemons, by means of the \*c-client*\ library that they all use.
16922
16923\**Note**\: The \message@_prefix\ and \message@_suffix\ options are not
16924automatically changed by the use of \mbx@_format\. They should normally be set
16925empty when using MBX format, so this option almost always appears in this
16926combination:
16927.display asis
16928mbx_format = true
16929message_prefix =
16930message_suffix =
16931.endd
16932
16933If none of the locking options are mentioned in the configuration,
16934\use@_mbx@_lock\ is assumed and the other locking options default to false. It
16935is possible to specify the other kinds of locking with \mbx@_format\, but
16936\use@_fcntl@_lock\ and \use@_mbx@_lock\ are mutually exclusive. MBX locking
16937interworks with \*c-client*\, providing for shared access to the mailbox. It
16938should not be used if any program that does not use this form of locking is
16939going to access the mailbox, nor should it be used if the mailbox file is NFS
16940mounted, because it works only when the mailbox is accessed from a single host.
16941
16942If you set \use@_fcntl@_lock\ with an MBX-format mailbox, you cannot use
16943the standard version of \*c-client*\, because as long as it has a mailbox open
16944(this means for the whole of a Pine or IMAP session), Exim will not be able to
16945append messages to it.
16946
16947.conf message@_prefix string$**$ "see below"
16948.index `From' line
16949The string specified here is expanded and output at the start of every message.
16950The default is unset unless \file\ is specified and \use@_bsmtp\ is not set, in
16951which case it is:
16952.display asis
16953message_prefix = "From ${if def:return_path{$return_path}\
16954 {MAILER-DAEMON}} $tod_bsdinbox\n"
16955.endd
16956
16957.conf message@_suffix string$**$ "see below"
16958The string specified here is expanded and output at the end of every message.
16959The default is unset unless \file\ is specified and \use@_bsmtp\ is not set, in
16960which case it is a single newline character. The suffix can be suppressed by
16961setting
16962.display asis
16963message_suffix =
16964.endd
16965
16966.conf mode "octal integer" 0600
16967If the output file is created, it is given this mode. If it already exists and
16968has wider permissions, they are reduced to this mode. If it has narrower
16969permissions, an error occurs unless \mode__fail__narrower\ is false. However,
16970if the delivery is the result of a \save\ command in a filter file specifing a
16971particular mode, the mode of the output file is always forced to take that
16972value, and this option is ignored.
16973
16974.conf mode@_fail@_narrower boolean true
16975This option applies in the case when an existing mailbox file has a narrower
16976mode than that specified by the \mode\ option. If \mode@_fail@_narrower\ is
16977true, the delivery is deferred (`mailbox has the wrong mode'); otherwise Exim
16978continues with the delivery attempt, using the existing mode of the file.
16979
16980.conf notify@_comsat boolean false
16981If this option is true, the \*comsat*\ daemon is notified after every successful
16982delivery to a user mailbox. This is the daemon that notifies logged on users
16983about incoming mail.
16984
16985.conf quota string$**$ unset
16986.index quota||imposed by Exim
16987This option imposes a limit on the size of the file to which Exim is appending,
16988or to the total space used in the directory tree when the \directory\ option is
16989set. In the latter case, computation of the space used is expensive, because
16990all the files in the directory (and any sub-directories) have to be
16991individually inspected and their sizes summed.
16992.em
16993(See \quota@_size@_regex\ and \maildir@_use@_size@_file\ for ways to avoid this
16994in environments where users have no shell access to their mailboxes).
16995
16996As there is no interlock against two simultaneous deliveries into a
16997multi-file mailbox, it is possible for the quota to be overrun in this case.
16998For single-file mailboxes, of course, an interlock is a necessity.
16999.nem
17000
17001A file's size is taken as its \*used*\ value. Because of blocking effects, this
17002may be a lot less than the actual amount of disk space allocated to the file.
17003If the sizes of a number of files are being added up, the rounding effect can
17004become quite noticeable, especially on systems that have large block sizes.
17005Nevertheless, it seems best to stick to the \*used*\ figure, because this is
17006the obvious value which users understand most easily.
17007
17008The value of the option is expanded, and must then be a numerical value
17009(decimal point allowed), optionally followed by one of the letters K or M. The
17010expansion happens while Exim is running as root, before it changes uid for the
17011delivery. This means that files which are inaccessible to the end user can be
17012used to hold quota values that are looked up in the expansion. When delivery
17013fails because this quota is exceeded, the handling of the error is as for
17014system quota failures.
17015
17016.em
17017\**Note**\: A value of zero is interpreted as `no quota'.
17018.nem
17019
17020By default, Exim's quota checking mimics system quotas, and restricts the
17021mailbox to the specified maximum size, though the value is not accurate to the
17022last byte, owing to separator lines and additional headers that may get added
17023during message delivery. When a mailbox is nearly full, large messages may get
17024refused even though small ones are accepted, because the size of the current
17025message is added to the quota when the check is made. This behaviour can be
17026changed by setting \quota@_is@_inclusive\ false. When this is done, the check
17027for exceeding the quota does not include the current message. Thus, deliveries
17028continue until the quota has been exceeded; thereafter, no further messages are
17029delivered. See also \quota@_warn@_threshold\.
17030
17031.conf quota@_directory string$**$ unset
17032This option defines the directory to check for quota purposes when delivering
17033into individual files. The default is the delivery directory, or, if a file
17034called \(maildirfolder)\ exists in a maildir directory, the parent of the
17035delivery directory.
17036
17037.conf quota@_filecount string$**$ 0
17038This option applies when the \directory\ option is set. It limits the total
17039number of files in the directory (compare the inode limit in system quotas). It
17040can only be used if \quota\ is also set. The value is expanded; an expansion
17041failure causes delivery to be deferred.
17042
17043.conf quota@_is@_inclusive boolean true
17044See \quota\ above.
17045
17046.conf quota@_size@_regex string unset
17047This option applies when one of the delivery modes that writes a separate file
17048for each message is being used. When Exim wants to find the size of one of
17049these files in order to test the quota, it first checks \quota@_size@_regex\.
17050If this is set to a regular expression that matches the file name, and it
17051captures one string, that string is interpreted as a representation of the
17052file's size. The value of \quota@_size@_regex\ is not expanded.
17053
17054This feature is useful only when users have no shell access to their mailboxes
17055-- otherwise they could defeat the quota simply by renaming the files. This
17056facility can be used with maildir deliveries, by setting \maildir@_tag\ to add
17057the file length to the file name. For example:
17058.display asis
17059maildir_tag = ,S=$message_size
17060quota_size_regex = ,S=(\d+)
17061.endd
17062The regular expression should not assume that the length is at the end of the
17063file name (even though \maildir@_tag\ puts it there) because maildir MUAs
17064sometimes add other information onto the ends of message file names.
17065
17066.conf quota@_warn@_message string$**$ "see below"
17067See below for the use of this option. If it is not set when
17068\quota@_warn@_threshold\ is set, it defaults to
17069.display asis
17070quota_warn_message = "\
17071 To: $local_part@$domain\n\
17072 Subject: Your mailbox\n\n\
17073 This message is automatically created \
17074 by mail delivery software.\n\n\
17075 The size of your mailbox has exceeded \
17076 a warning threshold that is\n\
17077 set by the system administrator.\n"
17078.endd
17079
17080.conf quota@_warn@_threshold string$**$ 0
17081.index quota||warning threshold
17082.index mailbox||size warning
17083.index size||of mailbox
17084This option is expanded in the same way as \quota\ (see above). If the
17085resulting value is greater than zero, and delivery of the message causes the
17086size of the file or total space in the directory tree to cross the given
17087threshold, a warning message is sent. If \quota\ is also set, the threshold may
17088be specified as a percentage of it by following the value with a percent sign.
17089For example:
17090.display asis
17091quota = 10M
17092quota_warn_threshold = 75%
17093.endd
17094If \quota\ is not set, a setting of \quota@_warn@_threshold\ that ends with a
17095percent sign is ignored.
17096
17097The warning message itself is specified by the \quota@_warn@_message\ option,
17098and it must start with a ::To:: header line containing the recipient(s). A
17099::Subject:: line should also normally be supplied. The \quota\ option does not
17100have to be set in order to use this option; they are independent of one
17101another except when the threshold is specified as a percentage.
17102
17103.conf use@_bsmtp boolean false
17104.index envelope sender
17105If this option is set true, \%appendfile%\ writes messages in `batch SMTP'
17106format, with the envelope sender and recipient(s) included as SMTP commands. If
17107you want to include a leading \\HELO\\ command with such messages, you can do
17108so by setting the \message@_prefix\ option. See section ~~SECTbatchSMTP for
17109details of batch SMTP.
17110
17111.conf use@_crlf boolean false
17112.index carriage return
17113.index linefeed
17114This option causes lines to be terminated with the two-character CRLF sequence
17115(carriage return, linefeed) instead of just a linefeed character. In the case
17116of batched SMTP, the byte sequence written to the file is then an exact image
17117of what would be sent down a real SMTP connection.
17118
17119The contents of the \message@_prefix\ and \message@_suffix\ options are written
17120verbatim, so must contain their own carriage return characters if these are
17121needed. In cases where these options have non-empty defaults, the values end
17122with a single linefeed, so they
17123must
17124be changed to end with \"@\r@\n"\ if \use@_crlf\ is set.
17125
17126.conf use@_fcntl@_lock boolean "see below"
17127This option controls the use of the \*fcntl()*\ function to lock a file for
17128exclusive use when a message is being appended. It is set by default unless
17129\use@_flock@_lock\ is set. Otherwise, it should be turned off only if you know
17130that all your MUAs use lock file locking. When both \use@_fcntl@_lock\ and
17131\use@_flock@_lock\ are unset, \use@_lockfile\ must be set.
17132
17133.conf use@_flock@_lock boolean false
17134This option is provided to support the use of \*flock()*\ for file locking, for
17135the few situations where it is needed. Most modern operating systems support
17136\*fcntl()*\ and \*lockf()*\ locking, and these two functions interwork with
17137each other. Exim uses \*fcntl()*\ locking by default.
17138
17139This option is required only if you are using an operating system where
17140\*flock()*\ is used by programs that access mailboxes (typically MUAs), and
17141where \*flock()*\ does not correctly interwork with \*fcntl()*\. You can use
17142both \*fcntl()*\ and \*flock()*\ locking simultaneously if you want.
17143
17144.index Solaris||\*flock()*\ support
17145Not all operating systems provide \*flock()*\. Some versions of Solaris do not
17146have it (and some, I think, provide a not quite right version built on top of
17147\*lockf()*\). If the OS does not have \*flock()*\, Exim will be built without
17148the ability to use it, and any attempt to do so will cause a configuration
17149error.
17150
17151\**Warning**\: \*flock()*\ locks do not work on NFS files (unless \*flock()*\
17152is just being mapped onto \*fcntl()*\ by the OS).
17153
17154.conf use@_lockfile boolean "see below"
17155If this option is turned off, Exim does not attempt to create a lock file when
17156appending to a mailbox file. In this situation, the only locking is by
17157\*fcntl()*\. You should only turn \use@_lockfile\ off if you are absolutely
17158sure that every MUA that is ever going to look at your users' mailboxes uses
17159\*fcntl()*\ rather than a lock file, and even then only when you are not
17160delivering over NFS from more than one host.
17161
17162.index NFS||lock file
17163In order to append to an NFS file safely from more than one host, it is
17164necessary to take out a lock $it{before} opening the file, and the lock file
17165achieves this. Otherwise, even with \*fcntl()*\ locking, there is a risk of
17166file corruption.
17167
17168The \use@_lockfile\ option is set by default unless \use@_mbx@_lock\ is set. It
17169is not possible to turn both \use@_lockfile\ and \use@_fcntl@_lock\ off, except
17170when \mbx@_format\ is set.
17171
17172.conf use@_mbx@_lock boolean "see below"
17173This option is available only if Exim has been compiled with \\SUPPORT@_MBX\\
17174set in \(Local/Makefile)\. Setting the option specifies that special MBX
17175locking rules be used. It is set by default if \mbx@_format\ is set and none of
17176the locking options are mentioned in the configuration. The locking rules are
17177the same as are used by the \*c-client*\ library that underlies Pine and the
17178IMAP4 and POP daemons that come with it (see the discussion below). The rules
17179allow for shared access to the mailbox. However, this kind of locking does not
17180work when the mailbox is NFS mounted.
17181
17182You can set \use@_mbx@_lock\ with either (or both) of \use@_fcntl@_lock\ and
17183\use@_flock@_lock\ to control what kind of locking is used in implementing the
17184MBX locking rules. The default is to use \*fcntl()*\ if \use@_mbx@_lock\ is set
17185without \use@_fcntl@_lock\ or \use@_flock@_lock\.
17186.endconf
17187
17188
17189.section Operational details for appending
17190.rset SECTopappend "~~chapter.~~section"
17191.index appending to a file
17192.index file||appending
17193Before appending to a file, the following preparations are made:
17194.numberpars $.
17195If the name of the file is \(/dev/null)\, no action is taken, and a success
17196return is given.
17197.nextp
17198.index directory creation
17199If any directories on the file's path are missing, Exim creates them if the
17200\create@_directory\ option is set. A created directory's mode is given by the
17201\directory@_mode\ option.
17202.nextp
17203If \file@_format\ is set, the format of an existing file is checked. If this
17204indicates that a different transport should be used, control is passed to that
17205transport.
17206.nextp
17207.index file||locking
17208.index locking files
17209.index NFS||lock file
17210If \use@_lockfile\ is set, a lock file is built in a way that will work
17211reliably over NFS, as follows:
17212.numberpars $.
17213Create a `hitching post' file whose name is that of the lock file with the
17214current time, primary host name, and process id added, by opening for writing
17215as a new file. If this fails with an access error, delivery is deferred.
17216.nextp
17217Close the hitching post file, and hard link it to the lock file name.
17218.nextp
17219If the call to \*link()*\ succeeds, creation of the lock file has succeeded.
17220Unlink the hitching post name.
17221.nextp
17222Otherwise, use \*stat()*\ to get information about the hitching post file, and
17223then unlink hitching post name. If the number of links is exactly two, creation
17224of the lock file succeeded but something (for example, an NFS server crash and
17225restart) caused this fact not to be communicated to the \*link()*\ call.
17226.nextp
17227If creation of the lock file failed, wait for \lock@_interval\ and try again,
17228up to \lock@_retries\ times. However, since any program that writes to a
17229mailbox should complete its task very quickly, it is reasonable to time out old
17230lock files that are normally the result of user agent and system crashes. If an
17231existing lock file is older than \lockfile@_timeout\ Exim attempts to unlink it
17232before trying again.
17233.endp
17234.nextp
17235A call is made to \*lstat()*\ to discover whether the main file exists, and if
17236so, what its characteristics are. If \*lstat()*\ fails for any reason other
17237than non-existence, delivery is deferred.
17238.nextp
17239.index symbolic link||to mailbox
17240.index mailbox||symbolic link
17241If the file does exist and is a symbolic link, delivery is deferred, unless the
17242\allow@_symlink\ option is set, in which case the ownership of the link is
17243checked, and then \*stat()*\ is called to find out about the real file, which
17244is then subjected to the checks below. The check on the top-level link
17245ownership prevents one user creating a link for another's mailbox in a sticky
17246directory, though allowing symbolic links in this case is definitely not a good
17247idea. If there is a chain of symbolic links, the intermediate ones are not
17248checked.
17249.nextp
17250If the file already exists but is not a regular file, or if the file's owner
17251and group (if the group is being checked -- see \check@_group\ above) are
17252different from the user and group under which the delivery is running,
17253delivery is deferred.
17254.nextp
17255If the file's permissions are more generous than specified, they are reduced.
17256If they are insufficient, delivery is deferred, unless \mode@_fail@_narrower\
17257is set false, in which case the delivery is tried using the existing
17258permissions.
17259.nextp
17260The file's inode number is saved, and the file is then opened for appending. If
17261this fails because the file has vanished, \%appendfile%\ behaves as if it hadn't
17262existed (see below). For any other failures, delivery is deferred.
17263.nextp
17264If the file is opened successfully, check that the inode number hasn't
17265changed, that it is still a regular file, and that the owner and permissions
17266have not changed. If anything is wrong, defer delivery and freeze the message.
17267.nextp
17268If the file did not exist originally, defer delivery if the \file@_must@_exist\
17269option is set. Otherwise, check that the file is being created in a permitted
17270directory if the \create@_file\ option is set (deferring on failure), and then
17271open for writing as a new file, with the \\O@_EXCL\\ and \\O@_CREAT\\ options,
17272except when dealing with a symbolic link (the \allow@_symlink\ option must be
17273set). In this case, which can happen if the link points to a non-existent file,
17274the file is opened for writing using \\O@_CREAT\\ but not \\O@_EXCL\\, because
17275that prevents link following.
17276.nextp
17277.index loop||while file testing
17278If opening fails because the file exists, obey the tests given above for
17279existing files. However, to avoid looping in a situation where the file is
17280being continuously created and destroyed, the exists/not-exists loop is broken
17281after 10 repetitions, and the message is then frozen.
17282.nextp
17283If opening fails with any other error, defer delivery.
17284.nextp
17285.index file||locking
17286.index locking files
17287Once the file is open, unless both \use@_fcntl@_lock\ and \use@_flock@_lock\
17288are false, it is locked using \*fcntl()*\ or \*flock()*\ or both. If
17289\use@_mbx@_lock\ is false, an exclusive lock is requested in each case.
17290However, if \use@_mbx@_lock\ is true,
17291Exim takes out a shared lock on the open file,
17292and an exclusive lock on the file whose name is
17293.display
17294/tmp/.<<device-number>>.<<inode-number>>
17295.endd
17296using the device and inode numbers of the open mailbox file, in accordance with
17297the MBX locking rules.
17298
17299If Exim fails to lock the file, there are two possible courses of action,
17300depending on the value of the locking timeout. This is obtained from
17301\lock@_fcntl@_timeout\ or \lock@_flock@_timeout\, as appropriate.
17302
17303If the timeout value is zero, the file is closed, Exim waits for
17304\lock@_interval\, and then goes back and re-opens the file as above and tries
17305to lock it again. This happens up to \lock@_retries\ times, after which the
17306delivery is deferred.
17307
17308If the timeout has a value greater than zero, blocking calls to \*fcntl()*\ or
17309\*flock()*\ are used (with the given timeout), so there has already been some
17310waiting involved by the time locking fails. Nevertheless, Exim does not give up
17311immediately. It retries up to
17312.display
17313(lock@_retries * lock@_interval) / <<timeout>>
17314.endd
17315times (rounded up).
17316.endp
17317
17318At the end of delivery, Exim closes the file (which releases the \*fcntl()*\
17319and/or \*flock()*\ locks) and then deletes the lock file if one was created.
17320
17321.section Operational details for delivery to a new file
17322.rset SECTopdir "~~chapter.~~section"
17323.index delivery||to single file
17324.index `From' line
17325When the \directory\ option is set instead of \file\, each message is delivered
17326into a newly-created file or set of files. When \%appendfile%\ is activated
17327directly from a \%redirect%\ router, neither \file\ nor \directory\ is normally
17328set, because the path for delivery is supplied by the router. (See for example,
17329the \%address@_file%\ transport in the default configuration.) In this case,
17330delivery is to a new file if either the path name ends in \"/"\, or the
17331\maildir@_format\ or \mailstore@_format\ option is set.
17332
17333No locking is required while writing the message to a new file, so the various
17334locking options of the transport are ignored. The `From' line that by default
17335separates messages in a single file is not normally needed, nor is the escaping
17336of message lines that start with `From', and there is no need to ensure a
17337newline at the end of each message. Consequently, the default values for
17338\check@_string\, \message@_prefix\, and \message@_suffix\ are all unset when
17339any of \directory\, \maildir@_format\, or \mailstore@_format\ is set.
17340
17341If Exim is required to check a \quota\ setting, it adds up the sizes of all the
17342files in the delivery directory by default. However, you can specify a
17343different directory by setting \quota@_directory\. Also, for maildir deliveries
17344(see below) the \(maildirfolder)\ convention is honoured.
17345
17346
17347.index maildir format
17348.index mailstore format
17349There are three different ways in which delivery to individual files can be
17350done, controlled by the settings of the \maildir@_format\ and
17351\mailstore@_format\ options. Note that code to support maildir or mailstore
17352formats is not included in the binary unless \\SUPPORT@_MAILDIR\\ or
17353\\SUPPORT@_MAILSTORE\\, respectively, is set in \(Local/Makefile)\.
17354
17355.index directory creation
17356In all three cases an attempt is made to create the directory and any necessary
17357sub-directories if they do not exist, provided that the \create@_directory\
17358option is set (the default). The location of a created directory can be
17359constrained by setting \create@_file\. A created directory's mode is given by
17360the \directory@_mode\ option. If creation fails, or if the \create@_directory\
17361option is not set when creation is required, delivery is deferred.
17362
17363
17364.section Maildir delivery
17365.rset SECTmaildirdelivery "~~chapter.~~section"
17366.index maildir format||description of
17367If the \maildir@_format\ option is true, Exim delivers each message by writing
17368it to a file whose name is \(tmp/<<stime>>.H<<mtime>>P<<pid>>.<<host>>)\ in the
17369given directory. If the delivery is successful, the file is renamed into the
17370\(new)\ subdirectory.
17371
17372In the file name, <<stime>> is the current time of day in seconds, and
17373<<mtime>> is the microsecond fraction of the time. After a maildir delivery,
17374Exim checks that the time-of-day clock has moved on by at least one microsecond
17375before terminating the delivery process. This guarantees uniqueness for the
17376file name. However, as a precaution, Exim calls \*stat()*\ for the file before
17377opening it. If any response other than \\ENOENT\\ (does not exist) is given,
17378Exim waits 2 seconds and tries again, up to \maildir@_retries\ times.
17379
17380.index quota||in maildir delivery
17381.index maildir++
17382If Exim is required to check a \quota\ setting before a maildir delivery, and
17383\quota@_directory\ is not set, it looks for a file called \(maildirfolder)\ in
17384the maildir directory (alongside \(new)\, \(cur)\, \(tmp)\). If this exists,
17385Exim assumes the directory is a maildir++ folder directory, which is one level
17386down from the user's top level mailbox directory. This causes it to start at
17387the parent directory instead of the current directory when calculating the
17388amount of space used.
17389
17390
17391.section Using tags to record message sizes
17392If \maildir@_tag\ is set, the string is expanded for each delivery.
17393When the maildir file is renamed into the \(new)\ sub-directory, the
17394tag is added to its name. However, if adding the tag takes the length of the
17395name to the point where the test \*stat()*\ call fails with \\ENAMETOOLONG\\,
17396the tag is dropped and the maildir file is created with no tag.
17397
17398Tags can be used to encode the size of files in their names; see
17399\quota@_size@_regex\ above for an example. The expansion of \maildir@_tag\
17400happens after the message has been written. The value of the \$message@_size$\
17401variable is set to the number of bytes actually written. If the expansion is
17402forced to fail, the tag is ignored, but a non-forced failure causes delivery to
17403be deferred. The expanded tag may contain any printing characters except `/'.
17404Non-printing characters in the string are ignored; if the resulting string is
17405empty, it is ignored. If it starts with an alphanumeric character, a leading
17406colon is inserted.
17407
17408
17409.em
17410.section Using a maildirsize file
17411.index quota||in maildir delivery
17412.index maildir format||\(maildirsize)\ file
17413If \maildir@_use@_size@_file\ is true, Exim implements the maildir++ rules for
17414storing quota and message size information in a file called \(maildirsize)\
17415within the maildir directory. If this file does not exist, Exim creates it,
17416setting the quota from the \quota\ option of the transport. If the maildir
17417directory itself does not exist, it is created before any attempt to write a
17418\(maildirsize)\ file.
17419
17420The \(maildirsize)\ file is used to hold information about the sizes of
17421messages in the maildir, thus speeding up quota calculations. The quota value
17422in the file is just a cache; if the quota is changed in the transport, the new
17423value overrides the cached value when the next message is delivered. The cache
17424is maintained for the benefit of other programs that access the maildir and
17425need to know the quota.
17426
17427If the \quota\ option in the transport is unset or zero, the \(maildirsize)\
17428file is maintained (with a zero quota setting), but no quota is imposed.
17429
17430A regular expression is available for controlling which directories in the
17431maildir participate in quota calculations. See the description of the
17432\maildir@_quota@_directory@_regex\ option above for details.
17433.nem
17434
17435
17436.section Mailstore delivery
17437.index mailstore format||description of
17438If the \mailstore@_format\ option is true, each message is written as two files
17439in the given directory. A unique base name is constructed from the message id
17440and the current delivery process, and the files that are written use this base
17441name plus the suffixes \(.env)\ and \(.msg)\. The \(.env)\ file contains the
17442message's envelope, and the \(.msg)\ file contains the message itself.
17443
17444During delivery, the envelope is first written to a file with the suffix
17445\(.tmp)\. The \(.msg)\ file is then written, and when it is complete, the
17446\(.tmp)\ file is renamed as the \(.env)\ file. Programs that access messages in
17447mailstore format should wait for the presence of both a \(.msg)\ and a \(.env)\
17448file before accessing either of them. An alternative approach is to wait for
17449the absence of a \(.tmp)\ file.
17450
17451The envelope file starts with any text defined by the \mailstore@_prefix\
17452option, expanded and terminated by a newline if there isn't one. Then follows
17453the sender address on one line, then all the recipient addresses, one per line.
17454There can be more than one recipient only if the \batch@_max\ option is set
17455greater than one. Finally, \mailstore@_suffix\ is expanded and the result
17456appended to the file, followed by a newline if it does not end with one.
17457
17458If expansion of \mailstore@_prefix\ or \mailstore@_suffix\ ends with a forced
17459failure, it is ignored. Other expansion errors are treated as serious
17460configuration errors, and delivery is deferred.
17461
17462
17463.section Non-special new file delivery
17464If neither \maildir@_format\ nor \mailstore@_format\ is set, a single new file
17465is created directly in the named directory. For example, when delivering
17466messages into files in batched SMTP format for later delivery to some host (see
17467section ~~SECTbatchSMTP), a setting such as
17468.display asis
17469directory = /var/bsmtp/$host
17470.endd
17471might be used. A message is written to a file with a temporary name, which is
17472then renamed when the delivery is complete. The final name is obtained by
17473expanding the contents of the \directory@_file\ option.
17474
17475
17476
17477
17478
17479.
17480.
17481.
17482.
17483. ============================================================================
17484.chapter The autoreply transport
17485.set runningfoot "autoreply transport"
17486.index transports||\%autoreply%\
17487.index \%autoreply%\ transport
17488The \%autoreply%\ transport is not a true transport in that it does not cause
17489the message to be transmitted. Instead, it generates another mail message. It
17490is usually run as the result of mail filtering, a `vacation' message being the
17491standard example. However, it can also be run directly from a router like any
17492other transport. To reduce the possibility of message cascades, messages
17493created by the \%autoreply%\ transport always have empty envelope sender
17494addresses, like bounce messages.
17495
17496The parameters of the message to be sent can be specified in the configuration
17497by options described below. However, these are used only when the address
17498passed to the transport does not contain its own reply information. When the
17499transport is run as a consequence of a
17500\mail\
17501or \vacation\ command in a filter file, the parameters of the message are
17502supplied by the filter, and passed with the address. The transport's options
17503that define the message are then ignored (so they are not usually set in this
17504case). The message is specified entirely by the filter or by the transport; it
17505is never built from a mixture of options. However, the \file@_optional\,
17506\mode\, and \return@_message\ options apply in all cases.
17507
17508\%Autoreply%\ is implemented as a local transport. When used as a result of a
17509command in a user's filter file, \%autoreply%\ normally runs under the uid and
17510gid of the user, and with appropriate current and home directories (see chapter
17511~~CHAPenvironment).
17512
17513There is a subtle difference between routing a message to a \%pipe%\ transport
17514that generates some text to be returned to the sender, and routing it to an
17515\%autoreply%\ transport. This difference is noticeable only if more than one
17516address from the same message is so handled. In the case of a pipe, the
17517separate outputs from the different addresses are gathered up and returned to
17518the sender in a single message, whereas if \%autoreply%\ is used, a separate
17519message is generated for each address that is passed to it.
17520
17521Non-printing characters are not permitted in the header lines generated for the
17522message that \%autoreply%\ creates, with the exception of newlines that are
17523immediately followed by whitespace. If any non-printing characters are found,
17524the transport defers.
17525Whether characters with the top bit set count as printing characters or not is
17526controlled by the \print@_topbitchars\ global option.
17527
17528If any of the generic options for manipulating headers (for example,
17529\headers@_add\) are set on an \%autoreply%\ transport, they apply to the copy of
17530the original message that is included in the generated message when
17531\return@_message\ is set. They do not apply to the generated message itself.
17532
17533If the \%autoreply%\ transport receives return code 2 from Exim when it submits
17534the message, indicating that there were no recipients, it does not treat this
17535as an error. This means that autoreplies sent to \$sender@_address$\ when this
17536is empty (because the incoming message is a bounce message) do not cause
17537problems. They are just discarded.
17538
17539
17540.section Private options for autoreply
17541
17542.startconf
17543.index options||\%autoreply%\ transport
17544.conf bcc string$**$ unset
17545This specifies the addresses that are to receive `blind carbon copies' of the
17546message when the message is specified by the transport.
17547
17548.conf cc string$**$ unset
17549This specifies recipients of the message and the contents of the ::Cc:: header
17550when the message is specified by the transport.
17551
17552.conf file string$**$ unset
17553The contents of the file are sent as the body of the message when the message
17554is specified by the transport. If both \file\ and \text\ are set, the text
17555string comes first.
17556
17557.conf file@_expand boolean false
17558If this is set, the contents of the file named by the \file\ option are
17559subjected to string expansion as they are added to the message.
17560
17561.conf file@_optional boolean false
17562If this option is true, no error is generated if the file named by the \file\
17563option or passed with the address does not exist or cannot be read.
17564
17565.conf from string$**$ unset
17566This specifies the contents of the ::From:: header when the message is specified
17567by the transport.
17568
17569.conf headers string$**$ unset
17570This specifies additional RFC 2822 headers that are to be added to the message when
17571the message is specified by the transport. Several can be given by using `@\n'
17572to separate them. There is no check on the format.
17573
17574.conf log string$**$ unset
17575This option names a file in which a record of every message sent is logged when
17576the message is specified by the transport.
17577
17578.conf mode "octal integer" 0600
17579If either the log file or the `once' file has to be created, this mode is used.
17580
17581.conf once string$**$ unset
17582This option names a file or DBM database in which a record of each
17583::To:: recipient is kept when the message is specified by the transport.
17584\**Note**\: This does not apply to ::Cc:: or ::Bcc:: recipients.
17585If \once@_file@_size\ is not set, a DBM database is used, and it is allowed to
17586grow as large as necessary. If a potential recipient is already in the
17587database, no message is sent by default. However, if \once@_repeat\ specifies a
17588time greater than zero, the message is sent if that much time has elapsed since
17589a message was last sent to this recipient. If \once\ is unset, the message is
17590always sent.
17591
17592If \once@_file@_size\ is set greater than zero, it changes the way Exim
17593implements the \once\ option. Instead of using a DBM file to record every
17594recipient it sends to, it uses a regular file, whose size will never get larger
17595than the given value. In the file, it keeps a linear list of recipient
17596addresses and times at which they were sent messages. If the file is full when
17597a new address needs to be added, the oldest address is dropped. If
17598\once@_repeat\ is not set, this means that a given recipient may receive
17599multiple messages, but at unpredictable intervals that depend on the rate of
17600turnover of addresses in the file. If \once@_repeat\ is set, it specifies a
17601maximum time between repeats.
17602
17603.conf once@_file@_size integer 0
17604See \once\ above.
17605
17606.conf once@_repeat time$**$ 0s
17607See \once\ above.
17608After expansion, the value of this option must be a valid time value.
17609
17610.conf reply@_to string$**$ unset
17611This specifies the contents of the ::Reply-To:: header when the message is
17612specified by the transport.
17613
17614.conf return@_message boolean false
17615If this is set, a copy of the original message is returned with the new
17616message, subject to the maximum size set in the \return@_size@_limit\ global
17617configuration option.
17618
17619.conf subject string$**$ unset
17620This specifies the contents of the ::Subject:: header when the message is
17621specified by the transport.
17622
17623.conf text string$**$ unset
17624This specifies a single string to be used as the body of the message when the
17625message is specified by the transport. If both \text\ and \file\ are set, the
17626text comes first.
17627
17628.conf to string$**$ unset
17629This specifies recipients of the message and the contents of the ::To:: header
17630when the message is specified by the transport.
17631
17632.endconf
17633
17634
17635
17636.
17637.
17638.
17639.
17640. ============================================================================
17641.chapter The lmtp transport
17642.set runningfoot "lmtp transport"
17643.index transports||\%lmtp%\
17644.index \%lmtp%\ transport
17645.index LMTP||over a pipe
17646.index LMTP||over a socket
17647.rset CHAPLMTP "~~chapter"
17648The \%lmtp%\ transport runs the LMTP protocol (RFC 2033) over a pipe to a
17649specified command
17650or by interacting with a Unix domain socket.
17651This transport is something of a cross between the \%pipe%\ and \%smtp%\
17652transports. Exim also has support for using LMTP over TCP/IP; this is
17653implemented as an option for the \%smtp%\ transport. Because LMTP is expected
17654to be of minority interest, the default build-time configure in \(src/EDITME)\
17655has it commented out. You need to ensure that
17656.display asis
17657TRANSPORT_LMTP=yes
17658.endd
17659is present in your \(Local/Makefile)\ in order to have the \%lmtp%\ transport
17660included in the Exim binary.
17661
17662The private options of the \%lmtp%\ transport are as follows:
17663
17664.startconf
17665.index options||\%lmtp%\ transport
17666
17667.conf batch@_id string$**$ unset
17668See the description of local delivery batching in chapter ~~CHAPbatching.
17669
17670.conf batch@_max integer 1
17671This limits the number of addresses that can be handled in a single delivery.
17672Most LMTP servers can handle several addresses at once, so it is normally a
17673good idea to increase this value. See the description of local delivery
17674batching in chapter ~~CHAPbatching.
17675
17676.conf command string$**$ unset
17677This option must be set if \socket\ is not set.
17678The string is a command which is run in a separate process. It is split up into
17679a command name and list of arguments, each of which is separately expanded (so
17680expansion cannot change the number of arguments). The command is run directly,
17681not via a shell. The message is passed to the new process using the standard
17682input and output to operate the LMTP protocol.
17683
17684.conf socket string$**$ unset
17685This option must be set if \command\ is not set. The result of expansion must
17686be the name of a Unix domain socket. The transport connects to the socket and
17687delivers the message to it using the LMTP protocol.
17688
17689.conf timeout time 5m
17690The transport is aborted if the created process
17691or Unix domain socket
17692does not respond to LMTP commands or message input within this timeout.
17693
17694.endconf
17695
17696Here is an example of a typical LMTP transport:
17697.display asis
17698lmtp:
17699 driver = lmtp
17700 command = /some/local/lmtp/delivery/program
17701 batch_max = 20
17702 user = exim
17703.endd
17704This delivers up to 20 addresses at a time, in a mixture of domains if
17705necessary, running as the user \*exim*\.
17706
17707
17708
17709.
17710.
17711.
17712.
17713. ============================================================================
17714.chapter The pipe transport
17715.rset CHAPpipetransport "~~chapter"
17716.set runningfoot "pipe transport"
17717.index transports||\%pipe%\
17718.index \%pipe%\ transport
17719The \%pipe%\ transport is used to deliver messages via a pipe to a command
17720running in another process. This can happen in one of two ways:
17721.numberpars $.
17722A router routes an address to a transport in the normal way, and the transport
17723is configured as a \%pipe%\ transport. In this case, \$local@_part$\ contains
17724the address (as usual), and the command which is run is specified by the
17725\command\ option on the transport. An example of this is the use of \%pipe%\ as
17726a pseudo-remote transport for passing messages to some other delivery mechanism
17727(such as UUCP).
17728.nextp
17729A router redirects an address directly to a pipe command (for example, from an
17730alias or forward file). In this case, \$local@_part$\ contains the local part
17731that was redirected, and \$address@_pipe$\ contains the text of the pipe
17732command itself. The \command\ option on the transport is ignored.
17733.endp
17734
17735The \%pipe%\ transport is a non-interactive delivery method. Exim can also
17736deliver messages over pipes using the LMTP interactive protocol. This is
17737implemented by the \%lmtp%\ transport.
17738
17739In the case when \%pipe%\ is run as a consequence of an entry in a local user's
17740\(.forward)\ file, the command runs under the uid and gid of that user. In
17741other cases, the uid and gid have to be specified explicitly, either on the
17742transport or on the router that handles the address. Current and `home'
17743directories are also controllable. See chapter ~~CHAPenvironment for details of
17744the local delivery environment.
17745
17746.section Returned status and data
17747.index \%pipe%\ transport||returned data
17748If the command exits with a non-zero return code, the delivery is deemed to
17749have failed, unless either the \ignore@_status\ option is set (in which case
17750the return code is treated as zero), or the return code is one of those listed
17751in the \temp@_errors\ option, which are interpreted as meaning `try again
17752later'. In this case, delivery is deferred. Details of a permanent failure are
17753logged, but are not included in the bounce message, which merely contains
17754`local delivery failed'.
17755
17756If the return code is greater than 128 and the command being run is a shell
17757script, it normally means that the script was terminated by a signal whose
17758value is the return code minus 128.
17759
17760If Exim is unable to run the command (that is, if \*execve()*\ fails), the
17761return code is set to 127. This is the value that a shell returns if it is
17762asked to run a non-existent command. The wording for the log line suggests that
17763a non-existent command may be the problem.
17764
17765The \return@_output\ option can affect the result of a pipe delivery. If it is
17766set and the command produces any output on its standard output or standard
17767error streams, the command is considered to have failed, even if it gave a zero
17768return code or if \ignore@_status\ is set. The output from the command is
17769included as part of the bounce message. The \return@_fail@_output\ option is
17770similar, except that output is returned only when the command exits with a
17771failure return code, that is, a value other than zero or a code that matches
17772\temp@_errors\.
17773
17774
17775.section How the command is run
17776.rset SECThowcommandrun "~~chapter.~~section"
17777.index \%pipe%\ transport||path for command
17778The command line is (by default) broken down into a command name and arguments
17779by the \%pipe%\ transport itself. The \allow@_commands\ and \restrict@_to@_path\
17780options can be used to restrict the commands that may be run.
17781.index quoting||in pipe command
17782Unquoted arguments are delimited by white space. If an argument appears in
17783double quotes, backslash is interpreted as an escape character in the usual
17784way. If an argument appears in single quotes, no escaping is done.
17785
17786String expansion is applied to the command line except when it comes from a
17787traditional \(.forward)\ file (commands from a filter file are expanded). The
17788expansion is applied to each argument in turn rather than to the whole line.
17789For this reason, any string expansion item that contains white space must be
17790quoted so as to be contained within a single argument. A setting such as
17791.display asis
17792command = /some/path ${if eq{$local_part}{postmaster}{xxx}{yyy}}
17793.endd
17794will not work, because the expansion item gets split between several
17795arguments. You have to write
17796.display asis
17797command = /some/path "${if eq{$local_part}{postmaster}{xxx}{yyy}}"
17798.endd
17799to ensure that it is all in one argument. The expansion is done in this way,
17800argument by argument, so that the number of arguments cannot be changed as a
17801result of expansion, and quotes or backslashes in inserted variables do not
17802interact with external quoting.
17803
17804.index transport||filter
17805.index filter||transport filter
17806Special handling takes place when an argument consists of precisely the text
17807`$tt{@$pipe@_addresses}'. This is not a general expansion variable; the only
17808place this string is recognized is when it appears as an argument for a pipe or
17809transport filter command. It causes each address that is being handled to be
17810inserted in the argument list at that point $it{as a separate argument}. This
17811avoids any problems with spaces or shell metacharacters, and is of use when a
17812\%pipe%\ transport is handling groups of addresses in a batch.
17813
17814After splitting up into arguments and expansion, the resulting command is run
17815in a subprocess directly from the transport, $it{not} under a shell. The
17816message that is being delivered is supplied on the standard input, and the
17817standard output and standard error are both connected to a single pipe that is
17818read by Exim. The \max@_output\ option controls how much output the command may
17819produce, and the \return@_output\ and \return@_fail@_output\ options control
17820what is done with it.
17821
17822Not running the command under a shell (by default) lessens the security risks
17823in cases when a command from a user's filter file is built out of data that was
17824taken from an incoming message. If a shell is required, it can of course be
17825explicitly specified as the command to be run. However, there are circumstances
17826where existing commands (for example, in \(.forward)\ files) expect to be run
17827under a shell and cannot easily be modified. To allow for these cases, there is
17828an option called \use@_shell\, which changes the way the \%pipe%\ transport
17829works. Instead of breaking up the command line as just described, it expands it
17830as a single string and passes the result to \(/bin/sh)\. The
17831\restrict@_to@_path\ option and the \$pipe@_addresses$\ facility cannot be used
17832with \use@_shell\, and the whole mechanism is inherently less secure.
17833
17834
17835.section Environment variables
17836.rset SECTpipeenv "~~chapter.~~section"
17837.index \%pipe%\ transport||environment for command
17838.index environment for pipe transport
17839The environment variables listed below are set up when the command is invoked.
17840This list is a compromise for maximum compatibility with other MTAs. Note that
17841the \environment\ option can be used to add additional variables to this
17842environment.
17843.display flow
17844.tabs 20
17845DOMAIN $t $rm{the domain of the address}
17846HOME $t $rm{the home directory, if set}
17847HOST $t $rm{the host name when called from a router (see below)}
17848LOCAL@_PART $t $rm{see below}
17849LOCAL@_PART@_PREFIX $t $rm{see below}
17850LOCAL@_PART@_SUFFIX $t $rm{see below}
17851LOGNAME $t $rm{see below}
17852MESSAGE@_ID $t $rm{the message's id}
17853PATH $t $rm{as specified by the \path\ option below}
17854QUALIFY@_DOMAIN $t $rm{the sender qualification domain}
17855RECIPIENT $t $rm{the complete recipient address}
17856SENDER $t $rm{the sender of the message (empty if a bounce)}
17857SHELL $t `$tt{/bin/sh}'
17858TZ $t $rm{the value of the \timezone\ option, if set}
17859USER $t $rm{see below}
17860.endd
17861
17862When a \%pipe%\ transport is called directly from (for example) an \%accept%\
17863router, \\LOCAL@_PART\\ is set to the local part of the address. When it is
17864called as a result of a forward or alias expansion, \\LOCAL@_PART\\ is set to
17865the local part of the address that was expanded. In both cases, any affixes are
17866removed from the local part, and made available in \\LOCAL@_PART@_PREFIX\\ and
17867\\LOCAL@_PART@_SUFFIX\\, respectively. \\LOGNAME\\ and \\USER\\ are set to the
17868same value as \\LOCAL@_PART\\ for compatibility with other MTAs.
17869
17870.index \\HOST\\
17871\\HOST\\ is set only when a \%pipe%\ transport is called from a router that
17872associates hosts with an address, typically when using \%pipe%\ as a
17873pseudo-remote transport. \\HOST\\ is set to the first host name specified by
17874the router.
17875
17876.index \\HOME\\
17877If the transport's generic \home@_directory\ option is set, its value is used
17878for the \\HOME\\ environment variable. Otherwise, a home directory may be set
17879by the router's \transport@_home@_directory\ option, which defaults to the
17880user's home directory if \check@_local@_user\ is set.
17881
17882.section Private options for pipe
17883.index options||\%pipe%\ transport
17884.startconf
17885
17886.conf allow@_commands "string list$**$" unset
17887.index \%pipe%\ transport||permitted commands
17888The string is expanded, and is then interpreted as a colon-separated list of
17889permitted commands. If \restrict@_to@_path\ is not set, the only commands
17890permitted are those in the \allow@_commands\ list. They need not be absolute
17891paths; the \path\ option is still used for relative paths. If
17892\restrict@_to@_path\ is set with \allow@_commands\, the command must either be
17893in the \allow@_commands\ list, or a name without any slashes that is found on
17894the path. In other words, if neither \allow@_commands\ nor \restrict@_to@_path\
17895is set, there is no restriction on the command, but otherwise only commands
17896that are permitted by one or the other are allowed. For example, if
17897.display asis
17898allow_commands = /usr/bin/vacation
17899.endd
17900and \restrict@_to@_path\ is not set, the only permitted command is
17901\(/usr/bin/vacation)\. The \allow@_commands\ option may not be set if
17902\use@_shell\ is set.
17903
17904.conf batch@_id string$**$ unset
17905See the description of local delivery batching in chapter ~~CHAPbatching.
17906
17907.conf batch@_max integer 1
17908This limits the number of addresses that can be handled in a single delivery.
17909See the description of local delivery batching in chapter ~~CHAPbatching.
17910
17911.conf check@_string string unset
17912As \%pipe%\ writes the message, the start of each line is tested for matching
17913\check@_string\, and if it does, the initial matching characters are replaced
17914by the contents of \escape@_string\, provided both are set. The value of
17915\check@_string\ is a literal string, not a regular expression, and the case of
17916any letters it contains is significant. When \use@_bsmtp\ is set, the contents
17917of \check@_string\ and \escape@_string\ are forced to values that implement the
17918SMTP escaping protocol. Any settings made in the configuration file are
17919ignored.
17920
17921.conf command string$**$ unset
17922This option need not be set when \%pipe%\ is being used to deliver to pipes
17923obtained directly from address redirections. In other cases, the option must be
17924set, to provide a command to be run. It need not yield an absolute path (see
17925the \path\ option below). The command is split up into separate arguments by
17926Exim, and each argument is separately expanded, as described in section
17927~~SECThowcommandrun above.
17928
17929.conf environment string$**$ unset
17930.index \%pipe%\ transport||environment for command
17931.index environment for \%pipe%\ transport
17932This option is used to add additional variables to the environment in which the
17933command runs (see section ~~SECTpipeenv for the default list). Its value is a
17934string which is expanded, and then interpreted as a colon-separated list of
17935environment settings of the form `<<name>>=<<value>>'.
17936
17937.conf escape@_string string unset
17938See \check@_string\ above.
17939
17940.conf freeze@_exec@_fail boolean false
17941.index exec failure
17942.index failure of exec
17943.index \%pipe%\ transport||failure of exec
17944Failure to exec the command in a pipe transport is by default treated like
17945any other failure while running the command. However, if \freeze@_exec@_fail\
17946is set, failure to exec is treated specially, and causes the message to be
17947frozen, whatever the setting of \ignore@_status\.
17948
17949.conf ignore@_status boolean false
17950If this option is true, the status returned by the subprocess that is set up to
17951run the command is ignored, and Exim behaves as if zero had been returned.
17952Otherwise, a non-zero status
17953or termination by signal
17954causes an error return from the transport unless the status value is one of
17955those listed in \temp@_errors\; these cause the delivery to be deferred and
17956tried again later.
17957
17958.conf log@_defer@_output boolean false
17959.index \%pipe%\ transport||logging output
17960If this option is set, and the status returned by the command is
17961one of the codes listed in \temp@_errors\ (that is, delivery was deferred),
17962and any output was produced, the first line of it is written to the main log.
17963
17964.conf log@_fail@_output boolean false
17965If this option is set, and the command returns any output, and also ends with a
17966return code that is neither zero nor one of the return codes listed in
17967\temp@_errors\ (that is, the delivery failed), the first line of output is
17968written to the main log.
17969
17970.conf log@_output boolean false
17971If this option is set and the command returns any output, the first line of
17972output is written to the main log, whatever the return code.
17973
17974.conf max@_output integer 20K
17975This specifies the maximum amount of output that the command may produce on its
17976standard output and standard error file combined. If the limit is exceeded, the
17977process running the command is killed. This is intended as a safety measure to
17978catch runaway processes. The limit is applied independently of the settings of
17979the options that control what is done with such output (for example,
17980\return@_output\). Because of buffering effects, the amount of output may
17981exceed the limit by a small amount before Exim notices.
17982
17983.conf message@_prefix string$**$ "see below"
17984The string specified here is expanded and output at the start of every message.
17985The default is unset if \use@_bsmtp\ is set. Otherwise it is
17986.display asis
17987message_prefix = \
17988 From ${if def:return_path{$return_path}{MAILER-DAEMON}}\
17989 ${tod_bsdinbox}\n
17990.endd
17991.index Cyrus
17992.index \tmail\
17993.index `From' line
17994This is required by the commonly used \(/usr/bin/vacation)\ program.
17995However, it must $it{not} be present if delivery is to the Cyrus IMAP server,
17996or to the \tmail\ local delivery agent. The prefix can be suppressed by setting
17997.display asis
17998message_prefix =
17999.endd
18000
18001.conf message@_suffix string$**$ "see below"
18002The string specified here is expanded and output at the end of every message.
18003The default is unset if \use@_bsmtp\ is set. Otherwise it is a single newline.
18004The suffix can be suppressed by setting
18005.display asis
18006message_suffix =
18007.endd
18008
18009.conf path string $tt{/usr/bin}
18010This option specifies the string that is set up in the \\PATH\\ environment
18011variable of the subprocess. If the \command\ option does not yield an absolute
18012path name, the command is sought in the \\PATH\\ directories, in the usual way.
18013\**Warning**\: This does not apply to a command specified as a transport
18014filter.
18015
18016.conf pipe@_as@_creator boolean false
18017.index uid (user id)||local delivery
18018If the generic \user\ option is not set and this option is true, the delivery
18019process is run under the uid that was in force when Exim was originally called
18020to accept the message. If the group id is not otherwise set (via the generic
18021\group\ option), the gid that was in force when Exim was originally called to
18022accept the message is used.
18023
18024.conf restrict@_to@_path boolean false
18025When this option is set, any command name not listed in \allow@_commands\ must
18026contain no slashes. The command is searched for only in the directories listed
18027in the \path\ option. This option is intended for use in the case when a pipe
18028command has been generated from a user's \(.forward)\ file. This is usually
18029handled by a \%pipe%\ transport called \address@_pipe\.
18030
18031.conf return@_fail@_output boolean false
18032If this option is true, and the command produced any output and ended with a
18033return code other than zero or one of the codes listed in \temp@_errors\ (that
18034is, the delivery failed), the output is returned in the bounce message.
18035However, if the message has a null sender (that is, it is itself a bounce
18036message), output from the command is discarded.
18037
18038.conf return@_output boolean false
18039If this option is true, and the command produced any output, the delivery is
18040deemed to have failed whatever the return code from the command, and the output
18041is returned in the bounce message. Otherwise, the output is just discarded.
18042However, if the message has a null sender (that is, it is a bounce message),
18043output from the command is always discarded, whatever the setting of this
18044option.
18045
18046.conf temp@_errors "string list" "see below"
18047.index \%pipe%\ transport||temporary failure
18048This option contains either a colon-separated list of numbers, or a single
18049asterisk. If \ignore@_status\ is false
18050.em
18051and \return@_output\ is not set,
18052.nem
18053and the command exits with a non-zero return code, the failure is treated as
18054temporary and the delivery is deferred if the return code matches one of the
18055numbers, or if the setting is a single asterisk. Otherwise, non-zero return
18056codes are treated as permanent errors. The default setting contains the codes
18057defined by \\EX@_TEMPFAIL\\ and \\EX@_CANTCREAT\\ in \(sysexits.h)\. If Exim is
18058compiled on a system that does not define these macros, it assumes values of 75
18059and 73, respectively.
18060
18061.conf timeout time 1h
18062If the command fails to complete within this time, it is killed. This normally
18063causes the delivery to fail. A zero time interval specifies no timeout. In
18064order to ensure that any subprocesses created by the command are also killed,
18065Exim makes the initial process a process group leader, and kills the whole
18066process group on a timeout. However, this can be defeated if one of the
18067processes starts a new process group.
18068
18069.conf umask "octal integer" 022
18070This specifies the umask setting for the subprocess that runs the command.
18071
18072.conf use@_bsmtp boolean false
18073.index envelope sender
18074If this option is set true, the \%pipe%\ transport writes messages in `batch
18075SMTP' format, with the envelope sender and recipient(s) included as SMTP
18076commands. If you want to include a leading \\HELO\\ command with such messages,
18077you can do so by setting the \message@_prefix\ option. See section
18078~~SECTbatchSMTP for details of batch SMTP.
18079
18080.conf use@_crlf boolean false
18081.index carriage return
18082.index linefeed
18083This option causes lines to be terminated with the two-character CRLF sequence
18084(carriage return, linefeed) instead of just a linefeed character. In the case
18085of batched SMTP, the byte sequence written to the pipe is then an exact image
18086of what would be sent down a real SMTP connection.
18087
18088The contents of the \message@_prefix\ and \message@_suffix\ options are written
18089verbatim, so must contain their own carriage return characters if these are
18090needed. Since the default values for both \message@_prefix\ and
18091\message@_suffix\ end with a single linefeed, their values
18092must
18093be changed to end with \"@\r@\n"\ if \use@_crlf\ is set.
18094
18095.conf use@_shell boolean false
18096If this option is set, it causes the command to be passed to \(/bin/sh)\
18097instead of being run directly from the transport, as described in section
18098~~SECThowcommandrun. This is less secure, but is needed in some situations
18099where the command is expected to be run under a shell and cannot easily be
18100modified. The \allow@_commands\ and \restrict@_to@_path\ options, and the
18101`$tt{@$pipe@_addresses}' facility are incompatible with \use@_shell\. The
18102command is expanded as a single string, and handed to \(/bin/sh)\ as data for
18103its \-c-\ option.
18104
18105.endconf
18106
18107.section Using an external local delivery agent
18108.index local delivery||using an external agent
18109.index \*procmail*\
18110.index external local delivery
18111.index delivery||\*procmail*\
18112.index delivery||by external agent
18113The \%pipe%\ transport can be used to pass all messages that require local
18114delivery to a separate local delivery agent such as \procmail\. When doing
18115this, care must be taken to ensure that the pipe is run under an appropriate
18116uid and gid. In some configurations one wants this to be a uid that is trusted
18117by the delivery agent to supply the correct sender of the message. It may be
18118necessary to recompile or reconfigure the delivery agent so that it trusts an
18119appropriate user. The following is an example transport and router
18120configuration for \procmail\:
18121.display asis
18122# transport
18123procmail_pipe:
18124 driver = pipe
18125 command = /usr/local/bin/procmail -d $local_part
18126 return_path_add
18127 delivery_date_add
18128 envelope_to_add
18129 check_string = "From "
18130 escape_string = ">From "
18131 user = $local_part
18132 group = mail
18133.endd
18134.display asis
18135# router
18136procmail:
18137 driver = accept
18138 check_local_user
18139 transport = procmail_pipe
18140.endd
18141
18142In this example, the pipe is run as the local user, but with the group set to
18143\*mail*\. An alternative is to run the pipe as a specific user such as \*mail*\
18144or \*exim*\, but in this case you must arrange for \procmail\ to trust that
18145user to supply a correct sender address. If you do not specify either a \group\
18146or a \user\ option, the pipe command is run as the local user. The home
18147directory is the user's home directory by default.
18148
18149Note that the command that the pipe transport runs does $it{not} begin with
18150.display asis
18151IFS=" "
18152.endd
18153as shown in the \procmail\ documentation, because Exim does not by default use
18154a shell to run pipe commands.
18155
18156.index Cyrus
18157The next example shows a transport and a router for a system where local
18158deliveries are handled by the Cyrus IMAP server.
18159.display asis
18160# transport
18161local_delivery_cyrus:
18162 driver = pipe
18163 command = /usr/cyrus/bin/deliver \
18164 -m ${substr_1:$local_part_suffix} -- $local_part
18165 user = cyrus
18166 group = mail
18167 return_output
18168 log_output
18169 message_prefix =
18170 message_suffix =
18171.endd
18172.display asis
18173# router
18174local_user_cyrus:
18175 driver = accept
18176 check_local_user
18177 local_part_suffix = .*
18178 transport = local_delivery_cyrus
18179.endd
18180Note the unsetting of \message@_prefix\ and \message@_suffix\, and the use of
18181\return@_output\ to cause any text written by Cyrus to be returned to the
18182sender.
18183
18184
18185.
18186.
18187.
18188.
18189. ============================================================================
18190.chapter The smtp transport
18191.rset CHAPsmtptrans "~~chapter"
18192.set runningfoot "smtp transport"
18193.index transports||\%smtp%\
18194.index \%smtp%\ transport
18195The \%smtp%\ transport delivers messages over TCP/IP connections using the SMTP
18196or LMTP protocol. The list of hosts to try can either be taken from the address
18197that is being processed (having been set up by the router), or specified
18198explicitly for the transport. Timeout and retry processing (see chapter
18199~~CHAPretry) is applied to each IP address independently.
18200
18201.section Multiple messages on a single connection
18202The sending of multiple messages over a single TCP/IP connection can arise in
18203two ways:
18204.numberpars $.
18205If a message contains more than \max@_rcpt\ (see below) addresses that are
18206routed to the same host, more than one copy of the message has to be sent to
18207that host. In this situation, multiple copies may be sent in a single run of
18208the \%smtp%\ transport over a single TCP/IP connection. (What Exim actually does
18209when it has too many addresses to send in one message also depends on the value
18210of the global \remote@_max@_parallel\ option. Details are given in section
18211~~SECToutSMTPTCP.)
18212.nextp
18213.index hints database||remembering routing
18214When a message has been successfully delivered over a TCP/IP connection, Exim
18215looks in its hints database to see if there are any other messages awaiting a
18216connection to the same host. If there are, a new delivery process is started
18217for one of them, and the current TCP/IP connection is passed on to it. The new
18218process may in turn send multiple copies and possibly create yet another
18219process.
18220.endp
18221
18222For each copy sent over the same TCP/IP connection, a sequence counter is
18223incremented, and if it ever gets to the value of \connection@_max@_messages\,
18224no further messages are sent over that connection.
18225
18226
18227.section Use of the @$host variable
18228.index \$host$\
18229.index \$host@_address$\
18230At the start of a run of the \%smtp%\ transport, the values of \$host$\ and
18231\$host@_address$\ are the name and IP address of the first host on the host list
18232passed by the router. However, when the transport is about to connect to a
18233specific host, and while it is connected to that host, \$host$\ and
18234\$host@_address$\ are set to the values for that host. These are the values
18235that are in force when the \helo@_data\, \hosts@_try@_auth\, \interface\,
18236\serialize@_hosts\, and the various TLS options are expanded.
18237
18238
18239.section Private options for smtp
18240The private options of the \%smtp%\ transport are as follows:
18241
18242.index options||\%smtp%\ transport
18243.startconf
18244.conf allow@_localhost boolean false
18245.index local host||sending to
18246.index fallback||hosts specified on transport
18247When a host specified in \hosts\ or \fallback@_hosts\ (see below) turns out to
18248be the local host, or is listed in \hosts@_treat@_as@_local\, delivery is
18249deferred by default. However, if \allow@_localhost\ is set, Exim goes on to do
18250the delivery anyway. This should be used only in special cases when the
18251configuration ensures that no looping will result (for example, a differently
18252configured Exim is listening on the port to which the message is sent).
18253
18254.conf authenticated@_sender string$**$ unset
18255.index Cyrus
18256When Exim has authenticated as a client, this option sets a value for the
18257\\AUTH=\\ item on outgoing \\MAIL\\ commands, overriding any existing
18258authenticated sender value. If the string expansion is forced to fail, the
18259option is ignored. Other expansion failures cause delivery to be deferred. If
18260the result of expansion is an empty string, that is also ignored.
18261
18262If the SMTP session is not authenticated, the expansion of
18263\authenticated@_sender\ still happens (and can cause the delivery to be
18264deferred if it fails), but no \\AUTH=\\ item is added to \\MAIL\\ commands.
18265
18266This option allows you to use the \%smtp%\ transport in LMTP mode to
18267deliver mail to Cyrus IMAP and provide the proper local part as the
18268`authenticated sender', via a setting such as:
18269.display asis
18270authenticated_sender = $local_part
18271.endd
18272This removes the need for IMAP subfolders to be assigned special ACLs to
18273allow direct delivery to those subfolders.
18274
18275Because of expected uses such as that just described for Cyrus (when no
18276domain is involved), there is no checking on the syntax of the provided
18277value.
18278
18279.conf command@_timeout time 5m
18280This sets a timeout for receiving a response to an SMTP command that has been
18281sent out. It is also used when waiting for the initial banner line from the
18282remote host. Its value must not be zero.
18283
18284.conf connect@_timeout time 5m
18285This sets a timeout for the \*connect()*\ function, which sets up a TCP/IP call
18286to a remote host. A setting of zero allows the system timeout (typically
18287several minutes) to act. To have any effect, the value of this option must be
18288less than the system timeout. However, it has been observed that on some
18289systems there is no system timeout, which is why the default value for this
18290option is 5 minutes, a value recommended by RFC 1123.
18291
18292.index SMTP||passed connection
18293.index SMTP||multiple deliveries
18294.index multiple SMTP deliveries
18295.conf connection@_max@_messages integer 500
18296This controls the maximum number of separate message deliveries that are sent
18297over a single TCP/IP connection. If the value is zero, there is no limit.
18298For testing purposes, this value can be overridden by the \-oB-\ command line
18299option.
18300
18301.conf data@_timeout time 5m
18302This sets a timeout for the transmission of each block in the data portion of
18303the message. As a result, the overall timeout for a message depends on the size
18304of the message. Its value must not be zero. See also \final@_timeout\.
18305
18306.conf delay@_after@_cutoff boolean true
18307This option controls what happens when all remote IP addresses for a given
18308domain have been inaccessible for so long that they have passed their retry
18309cutoff times.
18310
18311In the default state, if the next retry time has not been reached for any of
18312them, the address is bounced without trying any deliveries. In other words,
18313Exim delays retrying an IP address after the final cutoff time until a new
18314retry time is reached, and can therefore bounce an address without ever trying
18315a delivery, when machines have been down for a long time. Some people are
18316unhappy at this prospect, so...
18317
18318If \delay@_after@_cutoff\ is set false, Exim behaves differently. If all IP
18319addresses are past their final cutoff time, Exim tries to deliver to those
18320IP addresses that have not been tried since the message arrived. If there are
18321none, of if they all fail, the address is bounced. In other words, it does not
18322delay when a new message arrives, but immediately tries those expired IP
18323addresses that haven't been tried since the message arrived. If there is a
18324continuous stream of messages for the dead hosts, unsetting
18325\delay@_after@_cutoff\ means that there will be many more attempts to deliver
18326to them.
18327
18328.conf dns@_qualify@_single boolean true
18329If the \hosts\ or \fallback@_hosts\ option is being used,
18330and the \gethostbyname\ option is false,
18331the \\RES@_DEFNAMES\\ resolver option is set. See the \qualify@_single\ option
18332in chapter ~~CHAPdnslookup for more details.
18333
18334.conf dns@_search@_parents boolean false
18335.index \search@_parents\
18336If the \hosts\ or \fallback@_hosts\ option is being used, and the
18337\gethostbyname\ option is false, the \\RES@_DNSRCH\\ resolver option is set.
18338See the \search@_parents\ option in chapter ~~CHAPdnslookup for more details.
18339
18340
18341.conf fallback@_hosts "string list" unset
18342.index fallback||hosts specified on transport
18343String expansion is not applied to this option. The argument must be a
18344colon-separated list of host names or IP addresses. Fallback hosts can also be
18345specified on routers, which associate them with the addresses they process. As
18346for the \hosts\ option without \hosts@_override\, \fallback@_hosts\ specified
18347on the transport is used only if the address does not have its own associated
18348fallback host list. Unlike \hosts\, a setting of \fallback@_hosts\ on an
18349address is not overridden by \hosts@_override\. However, \hosts@_randomize\
18350does apply to fallback host lists.
18351
18352If Exim is unable to deliver to any of the hosts for a particular address, and
18353the errors are not permanent rejections, the address is put on a separate
18354transport queue with its host list replaced by the fallback hosts, unless the
18355address was routed via MX records and the current host was in the original MX
18356list. In that situation, the fallback host list is not used.
18357
18358Once normal deliveries are complete, the fallback queue is delivered by
18359re-running the same transports with the new host lists. If several failing
18360addresses have the same fallback hosts (and \max@_rcpt\ permits it), a single
18361copy of the message is sent.
18362
18363The resolution of the host names on the fallback list is controlled by the
18364\gethostbyname\ option, as for the \hosts\ option. Fallback hosts apply
18365both to cases when the host list comes with the address and when it is taken
18366from \hosts\. This option provides a `use a smart host only if delivery fails'
18367facility.
18368
18369.conf final@_timeout time 10m
18370This is the timeout that applies while waiting for the response to the final
18371line containing just `.' that terminates a message. Its value must not be zero.
18372
18373.conf gethostbyname boolean false
18374If this option is true when the \hosts\ and/or \fallback@_hosts\ options are
18375being used, names are looked up using \*gethostbyname()*\
18376(or \*getipnodebyname()*\ when available)
18377instead of using the DNS. Of course, that function may in fact use the DNS, but
18378it may also consult other sources of information such as \(/etc/hosts)\.
18379
18380.index \\HELO\\||argument, setting
18381.index \\EHLO\\||argument, setting
18382.conf helo@_data string$**$ $tt{@$primary@_hostname}
18383The value of this option is expanded, and used as the argument for the \\EHLO\\
18384or \\HELO\\ command that starts the outgoing SMTP session.
18385
18386.conf hosts "string list$**$" unset
18387Hosts are associated with an address by a router such as \%dnslookup%\, which
18388finds the hosts by looking up the address domain in the DNS. However, addresses
18389can be passed to the \%smtp%\ transport by any router, and not all of them can
18390provide an associated host list. The \hosts\ option specifies a list of hosts
18391which are used if the address being processed does not have any hosts
18392associated with it. The hosts specified by \hosts\ are also used, whether or
18393not the address has its own hosts, if \hosts@_override\ is set.
18394
18395The string is first expanded, before being interpreted as a colon-separated
18396list of host names or IP addresses. If the expansion fails, delivery is
18397deferred. Unless the failure was caused by the inability to complete a lookup,
18398the error is logged to the panic log as well as the main log. Host names are
18399looked up either by searching directly for address records in the DNS or by
18400calling \*gethostbyname()*\
18401(or \*getipnodebyname()*\ when available),
18402depending on the setting of the \gethostbyname\ option. When Exim is compiled
18403with IPv6 support, if a host that is looked up in the DNS has both IPv4 and
18404IPv6 addresses, both types of address are used.
18405
18406During delivery, the hosts are tried in order, subject to their retry status,
18407unless \hosts@_randomize\ is set.
18408
18409.conf hosts@_avoid@_esmtp "host list$**$" unset
18410.index ESMTP, avoiding use of
18411.index \\HELO\\||forcing use of
18412.index \\EHLO\\||avoiding use of
18413.index \\PIPELINING\\||avoiding the use of
18414This option is for use with broken hosts that announce ESMTP facilities (for
18415example, \\PIPELINING\\) and then fail to implement them properly. When a host
18416matches \hosts@_avoid@_esmtp\, Exim sends \\HELO\\ rather than \\EHLO\\ at the
18417start of the SMTP session. This means that it cannot use any of the ESMTP
18418facilities such as \\AUTH\\, \\PIPELINING\\, \\SIZE\\, and \\STARTTLS\\.
18419
18420.conf hosts@_avoid@_tls "host list$**$" unset
18421.index TLS||avoiding for certain hosts
18422Exim will not try to start a TLS session when delivering to any host that
18423matches this list. See chapter ~~CHAPTLS for details of TLS.
18424
18425.conf hosts@_max@_try integer 5
18426.index host||maximum number to try
18427.index limit||number of hosts tried
18428.index limit||number of MX tried
18429.index MX record||maximum tried
18430This option limits the number of IP addresses that are tried for any one
18431delivery
18432.em
18433in cases where there are temporary delivery errors.
18434.nem
18435Section ~~SECTvalhosmax describes in detail how the value of this option is
18436used.
18437
18438.conf hosts@_nopass@_tls "host list$**$" unset
18439.index TLS||passing connection
18440.index multiple SMTP deliveries
18441.index TLS||multiple message deliveries
18442For any host that matches this list, a connection on which a TLS session has
18443been started will not be passed to a new delivery process for sending another
18444message on the same connection. See section ~~SECTmulmessam for an explanation
18445of when this might be needed.
18446
18447.conf hosts@_override boolean false
18448If this option is set and the \hosts\ option is also set, any hosts that are
18449attached to the address are ignored, and instead the hosts specified by the
18450\hosts\ option are always used. This option does not apply to
18451\fallback@_hosts\.
18452
18453.conf hosts@_randomize boolean false
18454.index randomized host list
18455.index host||list of, randomized
18456.index fallback||randomized hosts
18457If this option is set, and either the list of hosts is taken from the
18458\hosts\ or the \fallback@_hosts\ option, or the hosts supplied by the router
18459were not obtained from MX records (this includes fallback hosts from the
18460router), and were not randomizied by the router, the order of trying the hosts
18461is randomized each time the transport runs. Randomizing the order of a host
18462list can be used to do crude load sharing.
18463
18464When \hosts@_randomize\ is true, a host list may be split into groups whose
18465order is separately randomized. This makes it possible to set up MX-like
18466behaviour. The boundaries between groups are indicated by an item that is just
18467\"+"\ in the host list. For example:
18468.display asis
18469hosts = host1:host2:host3:+:host4:host5
18470.endd
18471The order of the first three hosts and the order of the last two hosts is
18472randomized for each use, but the first three always end up before the last two.
18473If \hosts@_randomize\ is not set, a \"+"\ item in the list is ignored.
18474
18475.index authentication||required by client
18476.conf hosts@_require@_auth "host list$**$" unset
18477This option provides a list of servers for which authentication must succeed
18478before Exim will try to transfer a message. If authentication fails for
18479servers which are not in this list, Exim tries to send unauthenticated. If
18480authentication fails for one of these servers, delivery is deferred. This
18481temporary error is detectable in the retry rules, so it can be turned into a
18482hard failure if required. See also \hosts@_try@_auth\, and chapter
18483~~CHAPSMTPAUTH for details of authentication.
18484
18485.conf hosts@_require@_tls "host list$**$" unset
18486.index TLS||requiring for certain servers
18487Exim will insist on using a TLS session when delivering to any host that
18488matches this list. See chapter ~~CHAPTLS for details of TLS.
18489\**Note**\: This option affects outgoing mail only. To insist on TLS for
18490incoming messages, use an appropriate ACL.
18491
18492.index authentication||optional in client
18493.conf hosts@_try@_auth "host list$**$" unset
18494This option provides a list of servers to which, provided they announce
18495authentication support, Exim will attempt to authenticate as a client when it
18496connects. If authentication fails, Exim will try to transfer the message
18497unauthenticated. See also \hosts@_require@_auth\, and chapter ~~CHAPSMTPAUTH
18498for details of authentication.
18499
18500.index bind IP address
18501.index IP address||binding
18502.conf interface "string list$**$" unset
18503This option specifies which interface to bind to when making an outgoing SMTP
18504call. The variables \$host$\ and \$host@_address$\ refer to the host to which a
18505connection is about to be made during the expansion of the string. Forced
18506expansion failure, or an empty string result causes the option to be ignored.
18507Otherwise, after expansion,
18508.em
18509the string must be a list of IP addresses, colon-separated by default, but the
18510separator can be changed in the usual way.
18511.nem
18512For example:
18513.display asis
18514interface = <; 192.168.123.123 ; 3ffe:ffff:836f::fe86:a061
18515.endd
18516The first interface of the correct type (IPv4 or IPv6) is used for the outgoing
18517connection. If none of them are the correct type, the option is ignored. If
18518\interface\ is not set, or is ignored, the system's IP functions choose which
18519interface to use if the host has more than one.
18520
18521.conf keepalive boolean true
18522.index keepalive||on outgoing connection
18523This option controls the setting of \\SO@_KEEPALIVE\\ on outgoing TCP/IP socket
18524connections. When set, it causes the kernel to probe idle connections
18525periodically, by sending packets with `old' sequence numbers. The other end of
18526the connection should send a acknowledgement if the connection is still okay or
18527a reset if the connection has been aborted. The reason for doing this is that
18528it has the beneficial effect of freeing up certain types of connection that can
18529get stuck when the remote host is disconnected without tidying up the TCP/IP
18530call properly. The keepalive mechanism takes several hours to detect
18531unreachable hosts.
18532
18533.conf max@_rcpt integer 100
18534.index \\RCPT\\||maximum number of outgoing
18535This option limits the number of \\RCPT\\ commands that are sent in a single
18536SMTP message transaction. Each set of addresses is treated independently, and
18537so can cause parallel connections to the same host if \remote@_max@_parallel\
18538permits this.
18539
18540.conf multi@_domain boolean true
18541When this option is set, the \%smtp%\ transport can handle a number of addresses
18542containing a mixture of different domains provided they all resolve to the same
18543list of hosts. Turning the option off restricts the transport to handling only
18544one domain at a time. This is useful if you want to use \$domain$\ in an
18545expansion for the transport, because it is set only when there is a single
18546domain involved in a remote delivery.
18547
18548.conf port string$**$ "see below"
18549.index port||sending TCP/IP
18550.index TCP/IP||setting outgoing port
18551This option specifies the TCP/IP port on the server to which Exim connects. If
18552it begins with a digit it is taken as a port number; otherwise it is looked up
18553using \*getservbyname()*\. The default value is normally `smtp', but if
18554\protocol\ is set to `lmtp', the default is `lmtp'.
18555If the expansion fails, or if a port number cannot be found, delivery is
18556deferred.
18557
18558
18559.conf protocol string "smtp"
18560.index LMTP||over TCP/IP
18561If this option is set to `lmtp' instead of `smtp', the default value for the
18562\port\ option changes to `lmtp', and the transport operates the LMTP protocol
18563(RFC 2033) instead of SMTP. This protocol is sometimes used for local
18564deliveries into closed message stores. Exim also has support for running LMTP
18565over a pipe to a local process -- see chapter ~~CHAPLMTP.
18566
18567.conf retry@_include@_ip@_address boolean true
18568Exim normally includes both the host name and the IP address in the key it
18569constructs for indexing retry data after a temporary delivery failure. This
18570means that when one of several IP addresses for a host is failing, it gets
18571tried periodically (controlled by the retry rules), but use of the other IP
18572addresses is not affected.
18573
18574However, in some dialup environments hosts are assigned a different IP address
18575each time they connect. In this situation the use of the IP address as part of
18576the retry key leads to undesirable behaviour. Setting this option false causes
18577Exim to use only the host name. This should normally be done on a separate
18578instance of the \%smtp%\ transport, set up specially to handle the dialup hosts.
18579
18580.conf serialize@_hosts "host list$**$" unset
18581.index serializing connections
18582.index host||serializing connections
18583Because Exim operates in a distributed manner, if several messages for the same
18584host arrive at around the same time, more than one simultaneous connection to
18585the remote host can occur. This is not usually a problem except when there is a
18586slow link between the hosts. In that situation it may be helpful to restrict
18587Exim to one connection at a time. This can be done by setting
18588\serialize@_hosts\ to match the relevant hosts.
18589
18590.index hints database||serializing deliveries to a host
18591Exim implements serialization by means of a hints database in which a record is
18592written whenever a process connects to one of the restricted hosts. The record
18593is deleted when the connection is completed. Obviously there is scope for
18594records to get left lying around if there is a system or program crash. To
18595guard against this, Exim ignores any records that are more than six hours old.
18596
18597If you set up this kind of serialization, you should also arrange to delete the
18598relevant hints database whenever your system reboots. The names of the files
18599start with \(misc)\ and they are kept in the \(spool/db)\ directory. There
18600may be one or two files, depending on the type of DBM in use. The same files
18601are used for ETRN serialization.
18602
18603.conf size@_addition integer 1024
18604.index SMTP||\\SIZE\\
18605.index message||size issue for transport filter
18606.index size||of message
18607.index transport||filter
18608.index filter||transport filter
18609If a remote SMTP server indicates that it supports the \\SIZE\\ option of the
18610\\MAIL\\ command, Exim uses this to pass over the message size at the start of
18611an SMTP transaction. It adds the value of \size@_addition\ to the value it
18612sends, to allow for headers and other text that may be added during delivery by
18613configuration options or in a transport filter. It may be necessary to increase
18614this if a lot of text is added to messages.
18615
18616Alternatively, if the value of \size@_addition\ is set negative, it disables
18617the use of the \\SIZE\\ option altogether.
18618
18619.conf tls@_certificate string$**$ unset
18620.index TLS||client certificate, location of
18621.index certificate||for client, location of
18622The value of this option must be the absolute path to a file which contains the
18623client's certificate, for use when sending a message over an encrypted
18624connection. The values of \$host$\ and \$host@_address$\ are set to the name
18625and address of the server during the expansion. See chapter ~~CHAPTLS for
18626details of TLS.
18627
18628\**Note**\: This option must be set if you want Exim to use TLS when sending
18629messages as a client. The global option of the same name specifies the
18630certificate for Exim as a server; it is not automatically assumed that the same
18631certificate should be used when Exim is operating as a client.
18632
18633.em
18634.conf tls@_crl string$**$ unset
18635.index TLS||client certificate revocation list
18636.index certificate||revocation list for client
18637This option specifies a certificate revocation list. The expanded value must
18638be the name of a file that contains a CRL in PEM format.
18639.nem
18640
18641.conf tls@_privatekey string$**$ unset
18642.index TLS||client private key, location of
18643The value of this option must be the absolute path to a file which contains the
18644client's private key, for use when sending a message over an encrypted
18645connection. The values of \$host$\ and \$host@_address$\ are set to the name
18646and address of the server during the expansion.
18647If this option is unset, the private key is assumed to be in the same file as
18648the certificate.
18649See chapter ~~CHAPTLS for details of TLS.
18650
18651.conf tls@_require@_ciphers string$**$ unset
18652.index TLS||requiring specific ciphers
18653.index cipher||requiring specific
18654The value of this option must be a list of permitted cipher suites, for use
18655when setting up an
18656.em
18657outgoing encrypted connection. (There is a global option of the same name for
18658controlling incoming connections.)
18659.nem
18660The values of \$host$\ and \$host@_address$\ are set to the name and address of
18661the server during the expansion. See chapter ~~CHAPTLS for details of TLS; note
18662that this option is used in different ways by OpenSSL and GnuTLS (see section
18663~~SECTreqciphsslgnu).
18664
18665.conf tls@_tempfail@_tryclear boolean true
18666When the server host is not in \hosts@_require@_tls\, and there is a problem in
18667setting up a TLS session, this option determines whether or not Exim should try
18668to deliver the message unencrypted. If it is set false, delivery to the
18669current host is deferred; if there are other hosts, they are tried. If this
18670option is set true, Exim attempts to deliver unencrypted after a 4\*xx*\
18671response to \\STARTTLS\\. Also, if \\STARTTLS\\ is accepted, but the subsequent
18672TLS negotiation fails, Exim closes the current connection (because it is in an
18673unknown state), opens a new one to the same host, and then tries the delivery
18674in clear.
18675
18676.conf tls@_verify@_certificates string$**$ unset
18677.index TLS||server certificate verification
18678.index certificate||verification of server
18679The value of this option must be the absolute path to a file containing
18680permitted server certificates, for use when setting up an encrypted connection.
18681Alternatively, if you are using OpenSSL, you can set
18682\tls@_verify@_certificates\ to the name of a directory containing certificate
18683files. This does not work with GnuTLS; the option must be set to the name of a
18684single file if you are using GnuTLS. The values of \$host$\ and
18685\$host@_address$\ are set to the name and address of the server during the
18686expansion of this option. See chapter ~~CHAPTLS for details of TLS.
18687
18688.endconf
18689
18690
18691.section How the value of hosts@_max@_try is used
18692.rset SECTvalhosmax "~~chapter.~~section"
18693.index host||maximum number to try
18694.index limit||hosts, maximum number tried
18695The \hosts@_max@_try\ option limits the number of hosts that are tried
18696for a single delivery. However, despite the term `host' in its name, the option
18697actually applies to each IP address independently. In other words, a multihomed
18698host is treated as several independent hosts, just as it is for retrying.
18699
18700Many of the larger ISPs have multiple MX records which often point to
18701multihomed hosts. As a result, a list of a dozen or more IP addresses may be
18702created as a result of routing one of these domains.
18703
18704Trying every single IP address on such a long list does not seem sensible; if
18705several at the top of the list fail, it is reasonable to assume there is some
18706problem that is likely to affect all of them. Roughly speaking, the value of
18707\hosts@_max@_try\ is the maximum number that are tried before deferring the
18708delivery. However, the logic cannot be quite that simple.
18709
18710Firstly, IP addresses that are skipped because their retry times have not
18711arrived do not count, and in addition, addresses that are past their retry
18712limits are also not counted, even when they are tried. This means that when
18713some IP addresses are past their retry limits, more than the value of
18714\hosts@_max@_retry\ may be tried. The reason for this behaviour is to ensure
18715that all IP addresses are considered before timing out an email address.
18716
18717Secondly, when the \hosts@_max@_try\ limit is reached, Exim looks down the host
18718list to see if there is a subsequent host with a different (higher valued) MX.
18719If there is, that host is used next, and the current IP address is used but not
18720counted. This behaviour helps in the case of a domain with a retry rule that
18721hardly ever delays any hosts, as is now explained:
18722
18723Consider the case of a long list of hosts with one MX value, and a few with a
18724higher MX value. If \hosts@_max@_try\ is small (the default is 5) only a few
18725hosts at the top of the list are tried at first. With the default retry rule,
18726which specifies increasing retry times, the higher MX hosts are eventually
18727tried when those at the top of the list are skipped because they have not
18728reached their retry times.
18729
18730However, it is common practice to put a fixed short retry time on domains for
18731large ISPs, on the grounds that their servers are rarely down for very long.
18732Unfortunately, these are exactly the domains that tend to resolve to long lists
18733of hosts. The short retry time means that the lowest MX hosts are tried every
18734time. The attempts may be in a different order because of random sorting, but
18735without the special MX check mentioned about, the higher MX hosts would never
18736be tried at all because the lower MX hosts are never all past their retry
18737times.
18738
18739With the special check, Exim tries least one address from each MX value, even
18740if the \hosts@_max@_try\ limit has already been reached.
18741
18742
18743
18744
18745
18746
18747.
18748.
18749.
18750.
18751. ============================================================================
18752.chapter Address rewriting
18753.set runningfoot "address rewriting"
18754.rset CHAPrewrite ~~chapter
18755.index rewriting||addresses
18756There are some circumstances in which Exim automatically rewrites domains in
18757addresses. The two most common are when an address is given without a domain
18758(referred to as an `unqualified address') or when an address contains an
18759abbreviated domain that is expanded by DNS lookup.
18760
18761Unqualified envelope addresses are accepted only for locally submitted
18762messages, or messages from hosts that match \sender@_unqualified@_hosts\ or
18763\recipient@_unqualified@_hosts\, respectively. Unqualified addresses in header
18764lines are qualified if they are in locally submitted messages, or messages from
18765hosts that are permitted to send unqualified envelope addresses. Otherwise,
18766unqualified addresses in header lines are neither qualified nor rewritten.
18767
18768One situation in which Exim does $it{not} automatically rewrite a domain is
18769when it is the name of a CNAME record in the DNS. The older RFCs suggest that
18770such a domain should be rewritten using the `canonical' name, and some MTAs do
18771this. The new RFCs do not contain this suggestion.
18772
18773.section Explicitly configured address rewriting
18774This chapter describes the rewriting rules that can be used in the
18775main rewrite section of the configuration file, and also in the generic
18776\headers@_rewrite\ option that can be set on any transport.
18777
18778Some people believe that configured address rewriting is a Mortal Sin.
18779Others believe that life is not possible without it. Exim provides the
18780facility; you do not have to use it.
18781
18782.em
18783The main rewriting rules that appear in the `rewrite' section of the
18784configuration file are applied to addresses in incoming messages, both envelope
18785addresses and addresses in header lines. Each rule specifies the types of
18786address to which it applies.
18787.nem
18788
18789Rewriting of addresses in header lines applies only to those headers that
18790were received with the message, and, in the case of transport rewriting, those
18791that were added by a system filter. That is, it applies only to those headers
18792that are common to all copies of the message. Header lines that are added by
18793individual routers or transports (and which are therefore specific to
18794individual recipient addresses) are not rewritten.
18795
18796In general, rewriting addresses from your own system or domain has some
18797legitimacy. Rewriting other addresses should be done only with great care and
18798in special circumstances. The author of Exim believes that rewriting should be
18799used sparingly, and mainly for `regularizing' addresses in your own domains.
18800Although it can sometimes be used as a routing tool, this is very strongly
18801discouraged.
18802
18803There are two commonly encountered circumstances where rewriting is used, as
18804illustrated by these examples:
18805.numberpars $.
18806The company whose domain is \*hitch.fict.example*\ has a number of hosts that
18807exchange mail with each other behind a firewall, but there is only a single
18808gateway to the outer world. The gateway rewrites \*@*.hitch.fict.example*\ as
18809\*hitch.fict.example*\ when sending mail off-site.
18810.nextp
18811A host rewrites the local parts of its own users so that, for example,
18812\*fp42@@hitch.fict.example*\ becomes \*Ford.Prefect@@hitch.fict.example*\.
18813.endp
18814
18815.em
18816.section When does rewriting happen?
18817.index rewriting||timing of
18818.index ~~ACL||rewriting addresses in
18819Configured address rewriting can take place at several different stages of a
18820message's processing.
18821
18822At the start of an ACL for \\MAIL\\, the sender address may have been rewritten
18823by a special SMTP-time rewrite rule (see section ~~SECTrewriteS), but no
18824ordinary rewrite rules have yet been applied. If, however, the sender address
18825is verified in the ACL, it is rewritten before verification, and remains
18826rewritten thereafter. The subsequent value of \$sender@_address$\ is the
18827rewritten address. This also applies if sender verification happens in a
18828\\RCPT\\ ACL. Otherwise, when the sender address is not verified, it is
18829rewritten as soon as a message's header lines have been received.
18830
18831Similarly, at the start of an ACL for \\RCPT\\, the current recipient's address
18832may have been rewritten by a special SMTP-time rewrite rule, but no ordinary
18833rewrite rules have yet been applied to it. However, the behaviour is different
18834from the sender address when a recipient is verified. The address is rewritten
18835for the verification, but the rewriting is not remembered at this stage. The
18836value of \$local@_part$\ and \$domain$\ after verification are always the same
18837as they were before (that is, they contain the unrewritten -- except for
18838SMTP-time rewriting -- address).
18839
18840Once a message's header lines have been received, all the envelope recipient
18841addresses are permanently rewritten, and rewriting is also applied to the
18842addresses in the header lines (if configured).
18843.index \*local@_scan()*\ function||address rewriting, timing of
18844Thus, all the rewriting is completed before the \\DATA\\ ACL and
18845\*local@_scan()*\ functions are run.
18846
18847When an address is being routed, either for delivery or for verification,
18848rewriting is applied immediately to child addresses that are generated by
18849redirection, unless \no@_rewrite\ is set on the router.
18850.nem
18851
18852.index envelope sender, rewriting
18853.index rewriting||at transport time
18854At transport time, additional rewriting of addresses in header lines can be
18855specified by setting the generic \headers@_rewrite\ option on a transport. This
18856option contains rules that are identical in form to those in the rewrite
18857section of the configuration file. In addition, the outgoing envelope sender
18858can be rewritten by means of the \return@_path\ transport option. However, it
18859is not possible to rewrite envelope recipients at transport time.
18860
18861
18862
18863.section Testing the rewriting rules that apply on input
18864.index rewriting||testing
18865.index testing||rewriting
18866Exim's input rewriting configuration appears in a part of the run time
18867configuration file headed by `begin rewrite'. It can be tested by the \-brw-\
18868command line option. This takes an address (which can be a full RFC 2822
18869address) as its argument. The output is a list of how the address would be
18870transformed by the rewriting rules for each of the different places it might
18871appear in an incoming message, that is, for each different header and for the
18872envelope sender and recipient fields. For example,
18873.display asis
18874exim -brw ph10@exim.workshop.example
18875.endd
18876might produce the output
18877.display asis
18878 sender: Philip.Hazel@exim.workshop.example
18879 from: Philip.Hazel@exim.workshop.example
18880 to: ph10@exim.workshop.example
18881 cc: ph10@exim.workshop.example
18882 bcc: ph10@exim.workshop.example
18883reply-to: Philip.Hazel@exim.workshop.example
18884env-from: Philip.Hazel@exim.workshop.example
18885 env-to: ph10@exim.workshop.example
18886.endd
18887which shows that rewriting has been set up for that address when used in any of
18888the source fields, but not when it appears as a recipient address. At the
18889present time, there is no equivalent way of testing rewriting rules that are
18890set for a particular transport.
18891
18892.section Rewriting rules
18893.index rewriting||rules
18894The rewrite section of the configuration file consists of lines of rewriting
18895rules in the form
18896.display
18897<<source pattern>> <<replacement>> <<flags>>
18898.endd
18899Rewriting rules that are specified for the \headers@_rewrite\ generic transport
18900option are given as a colon-separated list. Each item in the list takes the
18901same form as a line in the main rewriting configuration
18902(except that any colons must be doubled, of course).
18903
18904The formats of source patterns and replacement strings are described below.
18905Each is terminated by white space, unless enclosed in double quotes, in which
18906case normal quoting conventions apply inside the quotes. The flags are single
18907characters which may appear in any order. Spaces and tabs between them are
18908ignored.
18909
18910For each address that could potentially be rewritten, the rules are scanned in
18911order, and replacements for the address from earlier rules can themselves be
18912replaced by later rules (but see the `q' and `R' flags).
18913
18914The order in which addresses are rewritten is undefined, may change between
18915releases, and must not be relied on, with one exception: when a message is
18916received, the envelope sender is always rewritten first, before any header
18917lines are rewritten. For example, the replacement string for a rewrite of an
18918address in ::To:: must not assume that the message's address in ::From:: has (or
18919has not) already been rewritten. However, a rewrite of ::From:: may assume that
18920the envelope sender has already been rewritten.
18921
18922The variables \$local@_part$\ and \$domain$\ can be used in the replacement
18923string to refer to the address that is being rewritten. Note that lookup-driven
18924rewriting can be done by a rule of the form
18925.display asis
18926*@* ${lookup ...
18927.endd
18928where the lookup key uses \$1$\ and \$2$\ or \$local@_part$\ and \$domain$\ to
18929refer to the address that is being rewritten.
18930
18931.section Rewriting patterns
18932.index rewriting||patterns
18933.index address list||in a rewriting pattern
18934The source pattern in a rewriting rule is any item which may appear in an
18935address list (see section ~~SECTaddresslist). It is in fact processed as a
18936single-item address list, which means that it is expanded before being tested
18937against the address.
18938
18939Domains in patterns should be given in lower case. Local parts in patterns are
18940case-sensitive. If you want to do case-insensitive matching of local parts, you
18941can use a regular expression that starts with \"^(?i)"\.
18942
18943.index numerical variables (\$1$\, \$2$\, etc)||in rewriting rules
18944After matching, the numerical variables \$1$\, \$2$\, etc. may be set,
18945depending on the type of match which occurred. These can be used in the
18946replacement string to insert portions of the incoming address. \$0$\ always
18947refers to the complete incoming address. When a regular expression is used, the
18948numerical variables are set from its capturing subexpressions. For other types
18949of pattern they are set as follows:
18950
18951.numberpars $.
18952If a local part or domain starts with an asterisk, the numerical variables
18953refer to the character strings matched by asterisks, with \$1$\ associated with
18954the first asterisk, and \$2$\ with the second, if present. For example, if the
18955pattern
18956.display
18957*queen@@*.fict.example
18958.endd
18959is matched against the address \*hearts-queen@@wonderland.fict.example*\ then
18960.display asis
18961$0 = hearts-queen@wonderland.fict.example
18962$1 = hearts-
18963$2 = wonderland
18964.endd
18965Note that if the local part does not start with an asterisk, but the domain
18966does, it is \$1$\ that contains the wild part of the domain.
18967.nextp
18968If the domain part of the pattern is a partial lookup, the wild and fixed parts
18969of the domain are placed in the next available numerical variables. Suppose,
18970for example, that the address \*foo@@bar.baz.example*\ is processed by a
18971rewriting rule of the form
18972.display
18973*@@partial-dbm;/some/dbm/file <<replacement string>>
18974.endd
18975and the key in the file that matches the domain is \"*.baz.example"\. Then
18976.display asis
18977$1 = foo
18978$2 = bar
18979$3 = baz.example
18980.endd
18981If the address \*foo@@baz.example*\ is looked up, this matches the same
18982wildcard file entry, and in this case \$2$\ is set to the empty string, but
18983\$3$\ is still set to \*baz.example*\. If a non-wild key is matched in a
18984partial lookup, \$2$\ is again set to the empty string and \$3$\ is set to the
18985whole domain. For non-partial domain lookups, no numerical variables are set.
18986.endp
18987
18988.section Rewriting replacements
18989.index rewriting||replacements
18990If the replacement string for a rule is a single asterisk, addresses that
18991match the pattern and the flags are $it{not} rewritten, and no subsequent
18992rewriting rules are scanned. For example,
18993.display asis
18994hatta@lookingglass.fict.example * f
18995.endd
18996specifies that \*hatta@@lookingglass.fict.example*\ is never to be rewritten in
18997::From:: headers.
18998
18999If the replacement string is not a single asterisk, it is expanded, and must
19000yield a fully qualified address. Within the expansion, the variables
19001\$local@_part$\ and \$domain$\ refer to the address that is being rewritten.
19002Any letters they contain retain their original case -- they are not lower
19003cased. The numerical variables are set up according to the type of pattern that
19004matched the address, as described above. If the expansion is forced to fail by
19005the presence of `fail' in a conditional or lookup item, rewriting by the
19006current rule is abandoned, but subsequent rules may take effect. Any other
19007expansion failure causes the entire rewriting operation to be abandoned, and an
19008entry written to the panic log.
19009
19010
19011.section Rewriting flags
19012There are three different kinds of flag that may appear on rewriting rules:
19013.numberpars $.
19014Flags that specify which headers and envelope addresses to rewrite: E, F, T, b,
19015c, f, h, r, s, t.
19016.nextp
19017A flag that specifies rewriting at SMTP time: S.
19018.nextp
19019Flags that control the rewriting process: Q, q, R, w.
19020.endp
19021For rules that are part of the \headers@_rewrite\ generic transport option,
19022E, F, T, and S are not permitted.
19023
19024
19025.section Flags specifying which headers and envelope addresses to rewrite
19026.index rewriting||flags
19027If none of the following flag letters, nor the `S' flag (see section
19028~~SECTrewriteS) are present, a main rewriting rule applies to all headers and
19029to both the sender and recipient fields of the envelope, whereas a
19030transport-time rewriting rule just applies to all headers. Otherwise, the
19031rewriting rule is skipped unless the relevant addresses are being processed.
19032.display
19033E $rm{rewrite all envelope fields}
19034F $rm{rewrite the envelope From field}
19035T $rm{rewrite the envelope To field}
19036b $rm{rewrite the ::Bcc:: header}
19037c $rm{rewrite the ::Cc:: header}
19038f $rm{rewrite the ::From:: header}
19039h $rm{rewrite all headers}
19040r $rm{rewrite the ::Reply-To:: header}
19041s $rm{rewrite the ::Sender:: header}
19042t $rm{rewrite the ::To:: header}
19043.endd
19044You should be particularly careful about rewriting ::Sender:: headers, and
19045restrict this to special known cases in your own domains.
19046
19047.section The SMTP-time rewriting flag
19048.rset SECTrewriteS "~~chapter.~~section"
19049.index SMTP||rewriting malformed addresses
19050.index \\RCPT\\||rewriting argument of
19051.index \\MAIL\\||rewriting argument of
19052The rewrite flag `S' specifies a rewrite of incoming envelope addresses at SMTP
19053time, as soon as an address is received in a \\MAIL\\ or \\RCPT\\ command, and
19054before any other processing; even before syntax checking. The pattern is
19055required to be a regular expression, and it is matched against the whole of the
19056data for the command, including any surrounding angle brackets.
19057
19058This form of rewrite rule allows for the handling of addresses that are not
19059compliant with RFCs 2821 and 2822 (for example, `bang paths' in batched SMTP
19060input). Because the input is not required to be a syntactically valid address,
19061the variables \$local@_part$\ and \$domain$\ are not available during the
19062expansion of the replacement string. The result of rewriting replaces the
19063original address in the \\MAIL\\ or \\RCPT\\ command.
19064
19065.section Flags controlling the rewriting process
19066There are four flags which control the way the rewriting process works. These
19067take effect only when a rule is invoked, that is, when the address is of the
19068correct type (matches the flags) and matches the pattern:
19069.numberpars $.
19070If the `Q' flag is set on a rule, the rewritten address is permitted to be an
19071unqualified local part. It is qualified with \qualify@_recipient\. In the
19072absence of `Q' the rewritten address must always include a domain.
19073.nextp
19074If the `q' flag is set on a rule, no further rewriting rules are considered,
19075even if no rewriting actually takes place because of a `fail' in the expansion.
19076The `q' flag is not effective if the address is of the wrong type (does not
19077match the flags) or does not match the pattern.
19078.nextp
19079The `R' flag causes a successful rewriting rule to be re-applied to the new
19080address, up to ten times. It can be combined with the `q' flag, to stop
19081rewriting once it fails to match (after at least one successful rewrite).
19082.nextp
19083.index rewriting||whole addresses
19084When an address in a header is rewritten, the rewriting normally applies only
19085to the working part of the address, with any comments and RFC 2822 `phrase'
19086left unchanged. For example, rewriting might change
19087.display asis
19088From: Ford Prefect <fp42@restaurant.hitch.fict.example>
19089.endd
19090into
19091.display asis
19092From: Ford Prefect <prefectf@hitch.fict.example>
19093.endd
19094Sometimes there is a need to replace the whole address item, and this can be
19095done by adding the flag letter `w' to a rule. If this is set on a rule that
19096causes an address in a header line to be rewritten, the entire address is
19097replaced, not just the working part. The replacement must be a complete RFC
190982822 address, including the angle brackets if necessary. If text outside angle
19099brackets contains a character whose value is greater than 126 or less than 32
19100(except for tab), the text is encoded according to RFC 2047.
19101The character set is taken from \headers@_charset\, which defaults to
19102ISO-8859-1.
19103
19104When the `w' flag is set on a rule that causes an envelope address to be
19105rewritten, all but the working part of the replacement address is discarded.
19106.endp
19107
19108.section Rewriting examples
19109Here is an example of the two common rewriting paradigms:
19110.display asis
19111*@*.hitch.fict.example $1@hitch.fict.example
19112*@hitch.fict.example ${lookup{$1}dbm{/etc/realnames}\
19113 {$value}fail}@hitch.fict.example bctfrF
19114.endd
19115Note the use of `fail' in the lookup expansion in the second rule, forcing
19116the string expansion to fail if the lookup does not succeed. In this context it
19117has the effect of leaving the original address unchanged, but Exim goes on to
19118consider subsequent rewriting rules, if any, because the `q' flag is not
19119present in that rule. An alternative to `fail' would be to supply \$1$\
19120explicitly, which would cause the rewritten address to be the same as before,
19121at the cost of a small bit of processing. Not supplying either of these is an
19122error, since the rewritten address would then contain no local part.
19123
19124The first example above replaces the domain with a superior, more general
19125domain. This may not be desirable for certain local parts. If the rule
19126.display asis
19127root@*.hitch.fict.example *
19128.endd
19129were inserted before the first rule, rewriting would be suppressed for the
19130local part \*root*\ at any domain ending in \*hitch.fict.example*\.
19131
19132Rewriting can be made conditional on a number of tests, by making use of
19133\${if$\ in the expansion item. For example, to apply a rewriting rule only to
19134messages that originate outside the local host:
19135.display asis
19136*@*.hitch.fict.example "${if !eq {$sender_host_address}{}\
19137 {$1@hitch.fict.example}fail}"
19138.endd
19139The replacement string is quoted in this example because it contains white
19140space.
19141
19142.index rewriting||bang paths
19143.index bang paths||rewriting
19144Exim does not handle addresses in the form of `bang paths'. If it sees such an
19145address it treats it as an unqualified local part which it qualifies with the
19146local qualification domain (if the source of the message is local or if the
19147remote host is permitted to send unqualified addresses). Rewriting can
19148sometimes be used to handle simple bang paths with a fixed number of
19149components. For example, the rule
19150.display asis
19151\N^([^!]+)!(.*)@your.domain.example$\N $2@$1
19152.endd
19153rewrites a two-component bang path \*host.name!user*\ as the domain address
19154\*user@@host.name*\. However, there is a security implication in using this as
19155a global rewriting rule for envelope addresses. It can provide a backdoor
19156method for using your system as a relay, because the incoming addresses appear
19157to be local. If the bang path addresses are received via SMTP, it is safer to
19158use the `S' flag to rewrite them as they are received, so that relay checking
19159can be done on the rewritten addresses.
19160
19161
19162
19163
19164
19165.
19166.
19167.
19168.
19169. ============================================================================
19170.chapter Retry configuration
19171.set runningfoot "retry configuration"
19172.rset CHAPretry ~~chapter
19173.index retry||configuration, description of
19174.index configuration file||retry section
19175The `retry' section of the run time configuration file contains a list of retry
19176rules which control how often Exim tries to deliver messages that cannot be
19177delivered at the first attempt. If there are no retry rules, temporary errors
19178are treated as permanent. The \-brt-\ command line option can be used to test
19179which retry rule will be used for a given address or domain.
19180
19181The most common cause of retries is temporary failure to deliver to a remote
19182host because the host is down, or inaccessible because of a network problem.
19183Exim's retry processing in this case is applied on a per-host (strictly, per IP
19184address) basis, not on a per-message basis. Thus, if one message has recently
19185been delayed, delivery of a new message to the same host is not immediately
19186tried, but waits for the host's retry time to arrive. If the \retry@_defer\ log
19187selector is set, the message
19188.index retry||time not reached
19189`retry time not reached' is written to the main log whenever a delivery is
19190skipped for this reason. Section ~~SECToutSMTPerr contains more details of the
19191handling of errors during remote deliveries.
19192
19193Retry processing applies to routing as well as to delivering, except as covered
19194in the next paragraph. The retry rules do not distinguish between these
19195actions. It is not possible, for example, to specify different behaviour for
19196failures to route the domain \*snark.fict.example*\ and failures to deliver to
19197the host \*snark.fict.example*\. I didn't think anyone would ever need this
19198added complication, so did not implement it. However, although they share the
19199same retry rule, the actual retry times for routing and transporting a given
19200domain are maintained independently.
19201
19202When a delivery is not part of a queue run (typically an immediate delivery on
19203receipt of a message), the routers are always run, and local deliveries are
19204always attempted, even if retry times are set for them. This makes for better
19205behaviour if one particular message is causing problems (for example, causing
19206quota overflow, or provoking an error in a filter file). If such a delivery
19207suffers a temporary failure, the retry data is updated as normal, and
19208subsequent delivery attempts from queue runs occur only when the retry time for
19209the local address is reached.
19210
19211
19212.section Retry rules
19213.index retry||rules
19214Each retry rule occupies one line and consists of three parts, separated by
19215white space: a pattern, an error name, and a list of retry parameters. The
19216pattern must be enclosed in double quotes if it contains white space. The rules
19217are searched in order until one is found whose pattern matches the failing host
19218or address.
19219
19220The pattern is any single item that may appear in an address list (see section
19221~~SECTaddresslist). It is in fact processed as a one-item address list, which
19222means that it is expanded before being tested against the address that has
19223been delayed. Address list processing treats a plain domain name as if it were
19224preceded by `*@@', which makes it possible for many retry rules to start with
19225just a domain. For example,
19226.display asis
19227lookingglass.fict.example * F,24h,30m;
19228.endd
19229provides a rule for any address in the \*lookingglass.fict.example*\ domain,
19230whereas
19231.display asis
19232alice@lookingglass.fict.example * F,24h,30m;
19233.endd
19234applies only to temporary failures involving the local part \alice\.
19235In practice, almost all rules start with a domain name pattern without a local
19236part.
19237
19238.index regular expressions||in retry rules
19239\**Warning**\: If you use a regular expression in a routing rule, it must match
19240a complete address, not just a domain, because that is how regular expressions
19241work in address lists.
19242.display
19243^@\Nxyz@\d+@\.abc@\.example@$@\N * G,1h,10m,2 \Wrong\
19244^@\N[^@@]+@@xyz@\d+@\.abc@\.example@$@\N * G,1h,10m,2 \Right\
19245.endd
19246
19247
19248.section Choosing which retry rule to use
19249When Exim is looking for a retry rule after a routing attempt has failed (for
19250example, after a DNS timeout), each line in the retry configuration is tested
19251against the complete address only if \retry__use@_local@_part\ is set for the
19252router. Otherwise, only the domain is used, except when matching against a
19253regular expression, when the local part of the address is replaced with `*'. A
19254domain on its own can match a domain pattern, or a pattern that starts with
19255`*@@'. By default, \retry@_use@_local@_part\ is true for routers where
19256\check@_local@_user\ is true, and false for other routers.
19257
19258Similarly, when Exim is looking for a retry rule after a local delivery has
19259failed (for example, after a mailbox full error), each line in the retry
19260configuration is tested against the complete address only if
19261\retry@_use@_local@_part\ is set for the transport (it defaults true for all
19262local transports).
19263
19264.em
19265When Exim is looking for a retry rule after a remote delivery attempt has
19266failed, what happens depends on the type of failure. After a 4\*xx*\ SMTP
19267response for a recipient address, the whole address is used when searching the
19268retry rules. The rule that is found is used to create a retry time for the
19269failing address.
19270
19271For a temporary error that is not related to an individual address,
19272.nem
19273(for example, a connection timeout), each line in the retry configuration is
19274checked twice. First, the name of the remote host is used as a domain name
19275(preceded by `*@@' when matching a regular expression). If this does not match
19276the line, the domain from the email address is tried in a similar fashion. For
19277example, suppose the MX records for \*a.b.c.example*\ are
19278.display asis
19279a.b.c.example MX 5 x.y.z.example
19280 MX 6 p.q.r.example
19281 MX 7 m.n.o.example
19282.endd
19283and the retry rules are
19284.display asis
19285p.q.r.example * F,24h,30m;
19286a.b.c.example * F,4d,45m;
19287.endd
19288and a delivery to the host \*x.y.z.example*\ fails. The first rule matches
19289neither the host nor the domain, so Exim looks at the second rule. This does
19290not match the host, but it does match the domain, so it is used to calculate
19291the retry time for the host \*x.y.z.example*\. Meanwhile, Exim tries to deliver
19292to \*p.q.r.example*\. If this fails, the first retry rule is used, because it
19293matches the host.
19294
19295In other words, failures to deliver to host \*p.q.r.example*\ use the first
19296rule to determine retry times, but for all the other hosts for the domain
19297\*a.b.c.example*\, the second rule is used. The second rule is also used if
19298routing to \*a.b.c.example*\ suffers a temporary failure.
19299
19300.section Retry rules for specific errors
19301.index retry||specific errors, specifying
19302The second field in a retry rule is the name of a particular error, or an
19303asterisk, which matches any error. The errors that can be tested for are:
19304.numberpars " "
19305\*auth@_failed*\: authentication failed when trying to send to a host in the
19306\hosts@_require@_auth\ list in an \%smtp%\ transport
19307.nextp
19308\*refused@_MX*\: connection refused from a host obtained from an MX record
19309.nextp
19310\*refused@_A*\: connection refused from a host not obtained from an MX record
19311.nextp
19312\*refused*\: any connection refusal
19313.nextp
19314\*timeout@_connect@_MX*\: connection timeout from a host obtained from an MX
19315record
19316.nextp
19317\*timeout@_connect@_A*\: connection timeout from a host not obtained from an MX
19318record
19319.nextp
19320\*timeout@_connect*\: any connection timeout
19321.nextp
19322\*timeout@_MX*\: any timeout from a host obtained from an MX
19323record
19324.nextp
19325\*timeout@_A*\: any timeout from a host not obtained from an MX
19326record
19327.nextp
19328\*timeout*\: any timeout
19329.nextp
19330\*quota*\: quota exceeded in local delivery by \%appendfile%\
19331.nextp
19332.index quota||error testing in retry rule
19333.index retry||quota error testing
19334\*quota@_*\<<time>>: quota exceeded in local delivery, and the mailbox has not
19335been read for <<time>>. For example, \*quota@_4d*\ applies to a quota error
19336when the mailbox has not been read for four days.
19337
19338.em
19339.index mailbox||time of last read
19340\**Warning**\: It is not always possible to determine a `time of last read' for
19341a mailbox:
19342.numberpars $.
19343If the mailbox is a single file, the time of last access is used.
19344.nextp
19345.index maildir format||time of last read
19346For a maildir delivery, the time of last modification of the \(new)\
19347subdirectory is used. As the mailbox is over quota, no new files will be
19348created in the \(new)\ subdirectory, so any change is assumed to be the result
19349of an MUA moving a new message to the \(cur)\ directory when it is first read.
19350.nextp
19351For other kinds of multi-file delivery, the time of last read cannot be
19352obtained, and so a retry rule that uses this type of error field is never
19353matched.
19354.endp
19355.nem
19356.endp
19357The quota errors apply both to system-enforced quotas and to Exim's own quota
19358mechanism in the \%appendfile%\ transport. The \*quota*\ error also applies
19359when a local delivery is deferred because a partition is full (the \\ENOSPC\\
19360error).
19361
19362
19363.section Retry rule parameters
19364.index retry||parameters in rules
19365The third field in a retry rule is a sequence of retry parameter sets,
19366separated by semicolons. Each set consists of
19367.display
19368<<letter>>,<<cutoff time>>,<<arguments>>
19369.endd
19370The letter identifies the algorithm for computing a new retry time; the cutoff
19371time is the time beyond which this algorithm no longer applies, and the
19372arguments vary the algorithm's action. The cutoff time is measured from the
19373time that the first failure for the domain (combined with the local part if
19374relevant) was detected, not from the time the message was received.
19375.index retry||algorithms
19376The available algorithms are:
19377.numberpars $.
19378\*F*\: retry at fixed intervals. There is a single time parameter specifying the
19379interval.
19380.nextp
19381\*G*\: retry at geometrically increasing intervals. The first argument specifies
19382a starting value for the interval, and the second a multiplier, which is used
19383to increase the size of the interval at each retry.
19384.endp
19385When computing the next retry time, the algorithm definitions are scanned in
19386order until one whose cutoff time has not yet passed is reached. This is then
19387used to compute a new retry time that is later than the current time. In the
19388case of fixed interval retries, this simply means adding the interval to the
19389current time. For geometrically increasing intervals, retry intervals are
19390computed from the rule's parameters until one that is greater than the previous
19391interval is found. The main configuration variable
19392.index limit||retry interval
19393.index retry||interval, maximum
19394.index \retry@_interval@_max\
19395\retry@_interval@_max\ limits the maximum interval between retries.
19396
19397A single remote domain may have a number of hosts associated with it, and each
19398host may have more than one IP address. Retry algorithms are selected on the
19399basis of the domain name, but are applied to each IP address independently. If,
19400for example, a host has two IP addresses and one is unusable, Exim will
19401generate retry times for it and will not try to use it until its next retry
19402time comes. Thus the good IP address is likely to be tried first most of the
19403time.
19404
19405.index hints database||use for retrying
19406Retry times are hints rather than promises. Exim does not make any attempt to
19407run deliveries exactly at the computed times. Instead, a queue runner process
19408starts delivery processes for delayed messages periodically, and these attempt
19409new deliveries only for those addresses that have passed their next retry time.
19410If a new message arrives for a deferred address, an immediate delivery attempt
19411occurs only if the address has passed its retry time. In the absence of new
19412messages, the minimum time between retries is the interval between queue runner
19413processes. There is not much point in setting retry times of five minutes if
19414your queue runners happen only once an hour, unless there are a significant
19415number of incoming messages (which might be the case on a system that is
19416sending everything to a smart host, for example).
19417
19418The data in the retry hints database can be inspected by using the
19419\*exim@_dumpdb*\ or \*exim@_fixdb*\ utility programs (see chapter ~~CHAPutils). The
19420latter utility can also be used to change the data. The \*exinext*\ utility
19421script can be used to find out what the next retry times are for the hosts
19422associated with a particular mail domain, and also for local deliveries that
19423have been deferred.
19424
19425.section Retry rule examples
19426Here are some example retry rules:
19427.display asis
19428alice@wonderland.fict.example quota_5d F,7d,3h
19429wonderland.fict.example quota_5d
19430wonderland.fict.example * F,1h,15m; G,2d,1h,2;
19431lookingglass.fict.example * F,24h,30m;
19432* refused_A F,2h,20m;
19433* * F,2h,15m; G,16h,1h,1.5; F,5d,8h
19434.endd
19435The first rule sets up special handling for mail to
19436\*alice@@wonderland.fict.example*\ when there is an over-quota error and the
19437mailbox has not been read for at least 5 days. Retries continue every three
19438hours for 7 days. The second rule handles over-quota errors for all other local
19439parts at \*wonderland.fict.example*\; the absence of a local part has the same
19440effect as supplying `$*$@@'. As no retry algorithms are supplied, messages that
19441fail are bounced immediately if the mailbox has not been read for at least 5
19442days.
19443
19444The third rule handles all other errors at \*wonderland.fict.example*\; retries
19445happen every 15 minutes for an hour, then with geometrically increasing
19446intervals until two days have passed since a delivery first failed. After the
19447first hour there is a delay of one hour, then two hours, then four hours, and
19448so on (this is a rather extreme example).
19449
19450The fourth rule controls retries for the domain \*lookingglass.fict.example*\.
19451They happen every 30 minutes for 24 hours only. The remaining two rules handle
19452all other domains, with special action for connection refusal from hosts that
19453were not obtained from an MX record.
19454
19455The final rule in a retry configuration should always have asterisks in the
19456first two fields so as to provide a general catch-all for any addresses that do
19457not have their own special handling. This example tries every 15 minutes for 2
19458hours, then with intervals starting at one hour and increasing by a factor of
194591.5 up to 16 hours, then every 8 hours up to 5 days.
19460
19461
19462.section Timeout of retry data
19463.index timeout||of retry data
19464.index \retry@_data@_expire\
19465.index hints database||data expiry
19466.index retry||timeout of data
19467Exim timestamps the data that it writes to its retry hints database. When it
19468consults the data during a delivery it ignores any that is older than the value
19469set in \retry@_data@_expire\ (default 7 days). If, for example, a host hasn't
19470been tried for 7 days, Exim will try to deliver to it immediately a message
19471arrives, and if that fails, it will calculate a retry time as if it were
19472failing for the first time.
19473
19474This improves the behaviour for messages routed to rarely-used hosts such as MX
19475backups. If such a host was down at one time, and happens to be down again when
19476Exim tries a month later, using the old retry data would imply that it had been
19477down all the time, which is not a justified assumption.
19478
19479If a host really is permanently dead, this behaviour causes a burst of retries
19480every now and again, but only if messages routed to it are rare. It there is a
19481message at least once every 7 days the retry data never expires.
19482
19483
19484
19485.section Long-term failures
19486.index delivery||failure, long-term
19487.index retry||after long-term failure
19488Special processing happens when an email address has been failing for so long
19489that the cutoff time for the last algorithm is reached. For example, using the
19490default retry rule:
19491.display asis
19492* * F,2h,15m; G,16h,1h,1.5; F,4d,6h
19493.endd
19494the cutoff time is four days. Reaching the retry cutoff is independent of how
19495long any specific message has been failing; it is the length of continuous
19496failure for the recipient address that counts.
19497
19498When the cutoff time is reached for a local delivery, or for all the IP
19499addresses associated with a remote delivery, a subsequent delivery failure
19500causes Exim to give up on the address, and a bounce message is generated.
19501In order to cater for new messages that use the failing address, a next retry
19502time is still computed from the final algorithm, and is used as follows:
19503
19504For local deliveries, one delivery attempt is always made for any subsequent
19505messages. If this delivery fails, the address fails immediately. The
19506post-cutoff retry time is not used.
19507
19508If the delivery is remote, there are two possibilities, controlled by the
19509.index \delay@_after@_cutoff\
19510\delay@_after@_cutoff\ option of the \%smtp%\ transport. The option is true by
19511default and in that case:
19512.numberpars " "
19513Until the post-cutoff retry time for one of the IP addresses is reached,
19514the failing email address is bounced immediately, without a delivery attempt
19515taking place. After that time, one new delivery attempt is made to those IP
19516addresses that are past their retry times, and if that still fails, the address
19517is bounced and new retry times are computed.
19518.endp
19519
19520In other words, when all the hosts for a given email address have been failing
19521for a long time, Exim bounces rather then defers until one of the hosts' retry
19522times is reached. Then it tries once, and bounces if that attempt fails. This
19523behaviour ensures that few resources are wasted in repeatedly trying to deliver
19524to a broken destination, but if the host does recover, Exim will eventually
19525notice.
19526
19527If \delay@_after@_cutoff\ is set false, Exim behaves differently. If all IP
19528addresses are past their final cutoff time, Exim tries to deliver to those IP
19529addresses that have not been tried since the message arrived. If there are
19530no suitable IP addresses, or if they all fail, the address is bounced. In other
19531words, it does not delay when a new message arrives, but tries the expired
19532addresses immediately, unless they have been tried since the message arrived.
19533If there is a continuous stream of messages for the failing domains, setting
19534\delay@_after@_cutoff\ false means that there will be many more attempts to
19535deliver to permanently failing IP addresses than when \delay@_after@_cutoff\ is
19536true.
19537
19538.section Ultimate address timeout
19539.index retry||ultimate address timeout
19540An additional rule is needed to cope with cases where a host is intermittently
19541available, or when a message has some attribute that prevents its delivery when
19542others to the same address get through. In this situation, because some
19543messages are successfully delivered, the `retry clock' for the address keeps
19544getting restarted, and so a message could remain on the queue for ever. To
19545prevent this, if a message has been on the queue for longer than the cutoff
19546time of any applicable retry rule for a given address, a delivery is attempted
19547for that address, even if it is not yet time, and if this delivery fails, the
19548address is timed out. A new retry time is not computed in this case, so that
19549other messages for the same address are considered immediately.
19550
19551
19552
19553
19554
19555.
19556.
19557.
19558.
19559. ============================================================================
19560.chapter SMTP authentication
19561.set runningfoot "SMTP authentication"
19562.rset CHAPSMTPAUTH "~~chapter"
19563.index SMTP||authentication configuration
19564.index authentication
19565The `authenticators' section of Exim's run time configuration is concerned with
19566SMTP authentication. This facility is an extension to the SMTP protocol,
19567described in RFC 2554, which allows a client SMTP host to authenticate itself
19568to a server. This is a common way for a server to recognize clients that
19569are permitted to use it as a relay. SMTP authentication is not of relevance to
19570the transfer of mail between servers that have no managerial connection with
19571each other.
19572
19573.index \\AUTH\\||description of
19574Very briefly, the way SMTP authentication works is as follows:
19575.numberpars $.
19576The server advertises a number of authentication \*mechanisms*\ in response to
19577the client's \\EHLO\\ command.
19578.nextp
19579The client issues an \\AUTH\\ command, naming a specific mechanism. The command
19580may, optionally, contain some authentication data.
19581.nextp
19582The server may issue one or more \*challenges*\, to which the client must send
19583appropriate responses. In simple authentication mechanisms, the challenges are
19584just prompts for user names and passwords. The server does not have to issue
19585any challenges -- in some mechanisms the relevant data may all be transmitted
19586with the \\AUTH\\ command.
19587.nextp
19588The server either accepts or denies authentication.
19589.nextp
19590If authentication succeeds, the client may optionally make use of the \\AUTH\\
19591option on the \\MAIL\\ command to pass an authenticated sender in subsequent
19592mail transactions. Authentication lasts for the remainder of the SMTP
19593connection.
19594.nextp
19595If authentication fails, the client may give up, or it may try a different
19596authentication mechanism, or it may try transferring mail over the
19597unauthenticated connection.
19598.endp
19599If you are setting up a client, and want to know which authentication
19600mechanisms the server supports, you can use Telnet to connect to port 25 (the
19601SMTP port) on the server, and issue an \\EHLO\\ command. The response to this
19602includes the list of supported mechanisms. For example:
19603.display
19604@$ $cb{telnet server.example 25}
19605Trying 192.168.34.25...
19606Connected to server.example.
19607Escape character is '@^]'.
19608220 server.example ESMTP Exim 4.20 ...
19609$cb{ehlo client.example}
19610250-server.example Hello client.example [10.8.4.5]
19611250-SIZE 52428800
19612250-PIPELINING
19613250-AUTH PLAIN
19614250 HELP
19615.endd
19616The second-last line of this example output shows that the server supports
19617authentication using the PLAIN mechanism. In Exim, the different authentication
19618mechanisms are configured by specifying \*authenticator*\ drivers. Like the
19619routers and transports, which authenticators are included in the binary is
19620controlled by build-time definitions. The following are currently available,
19621included by setting
19622.display asis
19623AUTH_CRAM_MD5=yes
19624AUTH_PLAINTEXT=yes
19625AUTH_SPA=yes
19626.endd
19627in \(Local/Makefile)\, respectively. The first of these supports the CRAM-MD5
19628authentication mechanism (RFC 2195), and the second can be configured to
19629support the PLAIN authentication mechanism (RFC 2595) or the LOGIN mechanism,
19630which is not formally documented, but used by several MUAs. The third
19631authenticator supports Microsoft's \*Secure Password Authentication*\
19632mechanism.
19633
19634The authenticators are configured using the same syntax as other drivers (see
19635section ~~SECTfordricon). If no authenticators are required, no authentication
19636section need be present in the configuration file. Each authenticator can in
19637principle have both server and client functions. When Exim is receiving SMTP
19638mail, it is acting as a server; when it is sending out messages over SMTP, it
19639is acting as a client. Authenticator configuration options are provided for use
19640in both these circumstances.
19641
19642To make it clear which options apply to which situation, the prefixes
19643\server@_\ and \client@_\ are used on option names that are specific to either
19644the server or the client function, respectively. Server and client functions
19645are disabled if none of their options are set. If an authenticator is to be
19646used for both server and client functions, a single definition, using both sets
19647of options, is required. For example:
19648.display asis
19649cram:
19650 driver = cram_md5
19651 public_name = CRAM-MD5
19652 server_secret = ${if eq{$1}{ph10}{secret1}fail}
19653 client_name = ph10
19654 client_secret = secret2
19655.endd
19656The \server@_\ option is used when Exim is acting as a server, and the
19657\client@_\ options when it is acting as a client.
19658
19659Descriptions of the individual authenticators are given in subsequent chapters.
19660The remainder of this chapter covers the generic options for the
19661authenticators, followed by general discussion of the way authentication works
19662in Exim.
19663
19664
19665.section Generic options for authenticators
19666.index authentication||generic options
19667
19668.startconf
19669.index options||generic, for authenticators
19670
19671.conf driver string unset
19672This option must always be set. It specifies which of the available
19673authenticators is to be used.
19674
19675.conf public@_name string unset
19676This option specifies the name of the authentication mechanism that the driver
19677implements, and by which it is known to the outside world. These names should
19678contain only upper case letters, digits, underscores, and hyphens (RFC 2222),
19679but Exim in fact matches them caselessly. If \public@_name\ is not set, it
19680defaults to the driver's instance name.
19681
19682.conf server@_advertise@_condition string$**$ unset
19683When a server is about to advertise an authentication mechanism, the condition
19684is expanded. If it yields the empty string, `0', `no', or `false', the
19685mechanism is not advertised.
19686If the expansion fails, the mechanism is not advertised. If the failure was not
19687forced, and was not caused by a lookup defer, the incident is logged.
19688See section ~~SECTauthexiser below for further discussion.
19689
19690.conf server@_debug@_print string$**$ unset
19691If this option is set and authentication debugging is enabled (see the \-d-\
19692command line option), the string is expanded and included in the debugging
19693output when the authenticator is run as a server. This can help with checking
19694out the values of variables.
19695If expansion of the string fails, the error message is written to the debugging
19696output, and Exim carries on processing.
19697
19698.conf server@_set@_id string$**$ unset
19699When an Exim server successfully authenticates a client, this string is
19700expanded using data from the authentication, and preserved for any incoming
19701messages in the variable \$authenticated@_id$\. It is also included in the log
19702lines for incoming messages. For example, a user/password authenticator
19703configuration might preserve the user name that was used to authenticate, and
19704refer to it subsequently during delivery of the message.
19705If expansion fails, the option is ignored.
19706
19707.conf server@_mail@_auth@_condition string$**$ unset
19708This option allows a server to discard authenticated sender addresses supplied
19709as part of \\MAIL\\ commands in SMTP connections that are authenticated by the
19710driver on which \server__mail__auth@_condition\ is set. The option is not used
19711as part of the authentication process; instead its (unexpanded) value is
19712remembered for later use.
19713How it is used is described in the following section.
19714.endconf
19715
19716
19717
19718.section The AUTH parameter on MAIL commands
19719.rset SECTauthparamail "~~chapter.~~section"
19720.index authentication||sender, authenticated
19721.index \\AUTH\\||on \\MAIL\\ command
19722When a client supplied an \\AUTH=\\ item on a \\MAIL\\ command, Exim applies
19723the following checks before accepting it as the authenticated sender of the
19724message:
19725.numberpars $.
19726If the connection is not using extended SMTP (that is, \\HELO\\ was used rather
19727than \\EHLO\\), the use of \\AUTH=\\ is a syntax error.
19728.nextp
19729If the value of the \\AUTH=\\ parameter is `@<@>', it is ignored.
19730.nextp
19731If \acl@_smtp@_mailauth\ is defined, the ACL it specifies is run. While it is
19732running, the value of \$authenticated@_sender$\ is set to the value obtained
19733from the \\AUTH=\\ parameter. If the ACL does not yield `accept', the value of
19734\$authenticated@_sender$\ is deleted. The \acl@_smtp@_mailauth\ ACL may not
19735return `drop' or `discard'. If it defers, a temporary error code (451) is given
19736for the \\MAIL\\ command.
19737.nextp
19738If \acl@_smtp@_mailauth\ is not defined, the value of the \\AUTH=\\ parameter
19739is accepted and placed in \$authenticated@_sender$\ only if the client has
19740authenticated.
19741.nextp
19742If the \\AUTH=\\ value was accepted by either of the two previous rules, and
19743the client has authenticated, and the authenticator has a setting for the
19744\server@_mail@_auth@_condition\, the condition is checked at this point. The
19745valued that was saved from the authenticator is expanded. If the expansion
19746fails, or yields an empty string, `0', `no', or `false', the value of
19747\$authenticated__sender$\ is deleted. If the expansion yields any other value,
19748the value of \$authenticated@_sender$\ is retained and passed on with the
19749message.
19750.endp
19751
19752When \$authenticated@_sender$\ is set for a message, it is passed on to other
19753hosts to which Exim authenticates as a client. Do not confuse this value with
19754\$authenticated@_id$\, which is a string obtained from the authentication
19755process, and which is not usually a complete email address.
19756
19757Whenever an \\AUTH=\\ value is ignored, the incident is logged. The ACL for
19758\\MAIL\\, if defined, is run after \\AUTH=\\ is accepted or ignored. It can
19759therefore make use of \$authenticated@_sender$\. The converse is not true: the
19760value of \$sender@_address$\ is not yet set up when the \acl@_smtp@_mailauth\
19761ACL is run.
19762
19763
19764.section Authentication on an Exim server
19765.rset SECTauthexiser "~~chapter.~~section"
19766.index authentication||on an Exim server
19767When Exim receives an \\EHLO\\ command, it advertises the public names of those
19768authenticators that are configured as servers, subject to the following
19769conditions:
19770.numberpars $.
19771The client host must match \auth@_advertise@_hosts\ (default $*$).
19772.nextp
19773It the \server@_advertise@_condition\ option is set, its expansion must not
19774yield the empty string, `0', `no', or `false'.
19775.endp
19776The order in which the authenticators are defined controls the order in which
19777the mechanisms are advertised.
19778
19779Some mail clients (for example, some versions of Netscape) require the user to
19780provide a name and password for authentication whenever \\AUTH\\ is advertised,
19781even though authentication may not in fact be needed (for example, Exim may be
19782set up to allow unconditional relaying from the client by an IP address check).
19783You can make such clients more friendly by not advertising \\AUTH\\ to them.
19784For example, if clients on the 10.9.8.0/24 network are permitted (by the ACL
19785that runs for \\RCPT\\) to relay without authentication, you should set
19786.display asis
19787auth_advertise_hosts = ! 10.9.8.0/24
19788.endd
19789so that no authentication mechanisms are advertised to them.
19790
19791The \server@_advertise@_condition\ controls the advertisement of individual
19792authentication mechanisms. For example, it can be used to restrict the
19793advertisement of a patricular mechanism to encrypted connections, by a setting
19794such as:
19795.display asis
19796server_advertise_condition = ${if eq{$tls_cipher}{}{no}{yes}}
19797.endd
19798If the session is encrypted, \$tls@_cipher$\ is not empty, and so the expansion
19799yields `yes', which allows the advertisement to happen.
19800
19801When an Exim server receives an \\AUTH\\ command from a client, it rejects it
19802immediately if \\AUTH\\ was not advertised in response to an earlier \\EHLO\\
19803command. This is the case if
19804.numberpars $.
19805The client host does not match \auth@_advertise@_hosts\; or
19806.nextp
19807No authenticators are configured with server options; or
19808.nextp
19809Expansion of \server@_advertise@_condition\ blocked the advertising of all the
19810server authenticators.
19811.endp
19812
19813Otherwise, Exim runs the ACL specified by \acl@_smtp@_auth\ in order
19814to decide whether to accept the command. If \acl@_smtp@_auth\ is not set,
19815\\AUTH\\ is accepted from any client host.
19816
19817If \\AUTH\\ is not rejected by the ACL, Exim searches its configuration for a
19818server authentication mechanism that was advertised in response to \\EHLO\\ and
19819that matches the one named in the \\AUTH\\ command. If it finds one, it runs
19820the appropriate authentication protocol, and authentication either succeeds or
19821fails. If there is no matching advertised mechanism, the \\AUTH\\ command is
19822rejected with a 504 error.
19823
19824When a message is received from an authenticated host, the value of
19825\$received@_protocol$\ is set to `asmtp' instead of `esmtp', and
19826\$sender@_host@_authenticated$\ contains the name (not the public name) of the
19827authenticator driver that successfully authenticated the client from which the
19828message was received. This variable is empty if there was no successful
19829authentication.
19830
19831
19832
19833.section Testing server authentication
19834.index authentication||testing a server
19835.index \\AUTH\\||testing a server
19836.index base64 encoding||creating authentication test data
19837Exim's \-bh-\ option can be useful for testing server authentication
19838configurations. The data for the \\AUTH\\ command has to be sent using base64
19839encoding. A quick way to produce such data for testing is the following Perl
19840script:
19841.display asis
19842use MIME::Base64;
19843printf ("%s", encode_base64(eval "\"$ARGV[0]\""));
19844.endd
19845.index binary zero||in authentication data
19846This interprets its argument as a Perl string, and then encodes it. The
19847interpretation as a Perl string allows binary zeros, which are required for
19848some kinds of authentication, to be included in the data. For example, a
19849command line to run this script on such data might be
19850.display asis
19851encode '\0user\0password'
19852.endd
19853Note the use of single quotes to prevent the shell interpreting the
19854backslashes, so that they can be interpreted by Perl to specify characters
19855whose code value is zero.
19856
19857\**Warning 1**\: If either of the user or password strings starts with an octal
19858digit, you must use three zeros instead of one after the leading backslash. If
19859you do not, the octal digit that starts your string will be incorrectly
19860interpreted as part of the code for the first character.
19861
19862\**Warning 2**\: If there are characters in the strings that Perl interprets
19863specially, you must use a Perl escape to prevent them being misinterpreted. For
19864example, a command such as
19865.display asis
19866encode '\0user@domain.com\0pas$$word'
19867.endd
19868gives an incorrect answer because of the unescaped `@@' and `@$' characters.
19869
19870If you have the \mimencode\ command installed, another way to do produce
19871base64-encoded strings is to run the command
19872.display asis
19873echo -e -n `\0user\0password' | mimencode
19874.endd
19875The \-e-\ option of \echo\ enables the interpretation of backslash escapes in
19876the argument, and the \-n-\ option specifies no newline at the end of its
19877output. However, not all versions of \echo\ recognize these options, so you
19878should check your version before relying on this suggestion.
19879
19880
19881.section Authentication by an Exim client
19882.index authentication||on an Exim client
19883The \%smtp%\ transport has two options called \hosts@_require@_auth\ and
19884\hosts@_try@_auth\. When the \%smtp%\ transport connects to a server that
19885announces support for authentication, and the host matches an entry in either
19886of these options, Exim (as a client) tries to authenticate as follows:
19887.numberpars $.
19888For each authenticator that is configured as a client, it searches the
19889authentication mechanisms announced by the server for one whose name
19890matches the public name of the authenticator.
19891.nextp
19892When it finds one that matches, it runs the authenticator's client code.
19893The variables \$host$\ and \$host@_address$\ are available for any string
19894expansions that the client might do. They are set to the server's name and
19895IP address. If any expansion is forced to fail, the authentication attempt
19896is abandoned,
19897and Exim moves on to the next authenticator.
19898Otherwise an expansion failure causes delivery to be
19899deferred.
19900.nextp
19901If the result of the authentication attempt is a temporary error or a timeout,
19902Exim abandons trying to send the message to the host for the moment. It will
19903try again later. If there are any backup hosts available, they are tried in the
19904usual way.
19905.nextp
19906If the response to authentication is a permanent error (5xx code), Exim carries
19907on searching the list of authenticators and tries another one if possible. If
19908all authentication attempts give permanent errors, or if there are no attempts
19909because no mechanisms match
19910(or option expansions force failure),
19911what happens depends on whether the host matches \hosts@_require@_auth\ or
19912\hosts@_try@_auth\. In the first case, a temporary error is generated, and
19913delivery is deferred. The error can be detected in the retry rules, and thereby
19914turned into a permanent error if you wish. In the second case, Exim tries to
19915deliver the message unauthenticated.
19916.endp
19917.index \\AUTH\\||on \\MAIL\\ command
19918When Exim has authenticated itself to a remote server, it adds the \\AUTH\\
19919parameter to the \\MAIL\\ commands it sends, if it has an authenticated sender
19920for the message.
19921If the message came from a remote host, the authenticated sender is the one
19922that was receiving on an incoming \\MAIL\\ command, provided that the incoming
19923connection was authenticated and the \server@_mail@_auth\ condition allowed the
19924authenticated sender to be retained. If a local process calls Exim to send a
19925message, the sender address that is built from the login name and
19926\qualify@_domain\ is treated as authenticated. However, if the
19927\authenticated@_sender\ option is set on the \%smtp%\ transport, it overrides
19928the authenticated sender that was received with the message.
19929
19930
19931
19932
19933
19934
19935.
19936.
19937.
19938.
19939. ============================================================================
19940.chapter The plaintext authenticator
19941.rset CHAPplaintext "~~chapter"
19942.set runningfoot "plaintext authenticator"
19943.index \%plaintext%\ authenticator
19944.index authenticators||\%plaintext%\
19945The \%plaintext%\ authenticator can be configured to support the PLAIN and
19946LOGIN authentication mechanisms, both of which transfer authentication data as
19947plain (unencrypted) text (though base64 encoded). The use of plain text is a
19948security risk. If you use one of these mechanisms without also making use of
19949SMTP encryption (see chapter ~~CHAPTLS) you should not use the same passwords
19950for SMTP connections as you do for login accounts.
19951
19952.section Using plaintext in a server
19953When running as a server, \%plaintext%\ performs the authentication test by
19954expanding a string. It has the following options:
19955
19956.startconf
19957.index options||\%plaintext%\ authenticator (server)
19958
19959.conf server@_prompts string$**$ unset
19960The contents of this option, after expansion, must be a colon-separated list of
19961prompt strings. If expansion fails, a temporary authentication rejection is
19962given.
19963
19964.conf server@_condition string$**$ unset
19965This option must be set in order to configure the driver as a server. Its use
19966is described below.
19967
19968.endconf
19969
19970.index \\AUTH\\||in \%plaintext%\ authenticator
19971.index binary zero||in \%plaintext%\ authenticator
19972.index numerical variables (\$1$\, \$2$\, etc)||in \%plaintext%\ authenticator
19973.index base64 encoding||in \%plaintext%\ authenticator
19974The data sent by the client with the \\AUTH\\ command, or in response to
19975subsequent prompts, is base64 encoded, and so may contain any byte values
19976when decoded. If any data is supplied with the command, it is treated as a
19977list of strings, separated by NULs (binary zeros), which are placed in the
19978expansion variables \$1$\, \$2$\, etc. If there are more strings in
19979\server@_prompts\ than the number of strings supplied with the \\AUTH\\
19980command, the remaining prompts are used to obtain more data. Each response from
19981the client may be a list of NUL-separated strings.
19982
19983Once a sufficient number of data strings have been received,
19984\server@_condition\ is expanded.
19985If the expansion is forced to fail, authentication fails. Any other expansion
19986failure causes a temporary error code to be returned.
19987If the result of a successful expansion is an empty string, `0', `no', or
19988`false', authentication fails. If the result of the expansion is `1', `yes', or
19989`true', authentication succeeds and the generic \server@_set@_id\ option is
19990expanded and saved in \$authenticated@_id$\. For any other result, a temporary
19991error code is returned, with the expanded string as the error text.
19992
19993\**Warning**\: If you use a lookup in the expansion to find the user's
19994password, be sure to make the authentication fail if the user is unknown.
19995There are good and bad examples at the end of the next section.
19996
19997
19998.section The PLAIN authentication mechanism
19999.index PLAIN authentication mechanism
20000.index authentication||PLAIN mechanism
20001.index binary zero||in \%plaintext%\ authenticator
20002The PLAIN authentication mechanism (RFC 2595) specifies that three strings be
20003sent as one item of data (that is, one combined string containing two NUL
20004separators). The data is sent either as part of the \\AUTH\\ command, or
20005subsequently in response to an empty prompt from the server.
20006
20007The second and third strings are a user name and a corresponding password.
20008Using a single fixed user name and password as an example, this could be
20009configured as follows:
20010.display asis
20011fixed_plain:
20012 driver = plaintext
20013 public_name = PLAIN
20014 server_prompts = :
20015 server_condition = \
20016 ${if and {{eq{$2}{username}}{eq{$3}{mysecret}}}{yes}{no}}
20017 server_set_id = $2
20018.endd
20019The \server@_prompts\ setting specifies a single, empty prompt (empty items at
20020the end of a string list are ignored). If all the data comes as part of the
20021\\AUTH\\ command, as is commonly the case, the prompt is not used. This
20022authenticator is advertised in the response to \\EHLO\\ as
20023.display asis
20024250-AUTH PLAIN
20025.endd
20026and a client host can authenticate itself by sending the command
20027.display asis
20028AUTH PLAIN AHVzZXJuYW1lAG15c2VjcmV0
20029.endd
20030As this contains three strings (more than the number of prompts), no further
20031data is required from the client. Alternatively, the client may just send
20032.display asis
20033AUTH PLAIN
20034.endd
20035to initiate authentication, in which case the server replies with an empty
20036prompt. The client must respond with the combined data string.
20037
20038.em
20039The data string is base64 encoded, as required by the RFC. This example,
20040when decoded, is \"<<NUL>>username<<NUL>>mysecret"\, where <<NUL>> represents a
20041zero byte. This is split up into three strings, the first of which is empty.
20042The \server@_condition\ option in the authenticator checks that the second two
20043are \"username"\ and \"mysecret"\ respectively.
20044
20045Having just one fixed user name and password, as in this example, is not very
20046realistic, though for a small organization with only a handful of
20047authenticating clients it could make sense.
20048.nem
20049
20050A more sophisticated instance of this authenticator could use the user name in
20051\$2$\ to look up a password in a file or database, and maybe do an encrypted
20052comparison (see \crypteq\ in chapter ~~CHAPexpand). Here is a example of this
20053approach, where the passwords are looked up in a DBM file. \**Warning**\: This
20054is an incorrect example:
20055.display asis
20056server_condition = \
20057 ${if eq{$3}{${lookup{$2}dbm{/etc/authpwd}}}{yes}{no}}
20058.endd
20059The expansion uses the user name (\$2$\) as the key to look up a password,
20060which it then compares to the supplied password (\$3$\). Why is this example
20061incorrect? It works fine for existing users, but consider what happens if a
20062non-existent user name is given. The lookup fails, but as no success/failure
20063strings are given for the lookup, it yields an empty string. Thus, to defeat
20064the authentication, all a client has to do is to supply a non-existent user
20065name and an empty password. The correct way of writing this test is:
20066.display asis
20067server_condition = ${lookup{$2}dbm{/etc/authpwd}\
20068 {${if eq{$value}{$3}{yes}{no}}}{no}}
20069.endd
20070In this case, if the lookup succeeds, the result is checked; if the lookup
20071fails, authentication fails. If \crypteq\ is being used instead of \eq\, the
20072first example is in fact safe, because \crypteq\ always fails if its second
20073argument is empty. However, the second way of writing the test makes the logic
20074clearer.
20075
20076
20077.section The LOGIN authentication mechanism
20078.index LOGIN authentication mechanism
20079.index authentication||LOGIN mechanism
20080The LOGIN authentication mechanism is not documented in any RFC, but is in use
20081in a number of programs. No data is sent with the \\AUTH\\ command. Instead, a
20082user name and password are supplied separately, in response to prompts. The
20083plaintext authenticator can be configured to support this as in this example:
20084.display asis
20085fixed_login:
20086 driver = plaintext
20087 public_name = LOGIN
20088 server_prompts = User Name : Password
20089 server_condition = \
20090 ${if and {{eq{$1}{username}}{eq{$2}{mysecret}}}{yes}{no}}
20091 server_set_id = $1
20092.endd
20093Because of the way plaintext operates, this authenticator accepts data supplied
20094with the \\AUTH\\ command (in contravention of the specification of LOGIN), but
20095if the client does not supply it (as is the case for LOGIN clients), the prompt
20096strings are used to obtain two data items.
20097
20098Some clients are very particular about the precise text of the prompts. For
20099example, Outlook Express is reported to recognize only `Username:' and
20100`Password:'. Here is an example of a LOGIN authenticator which uses those
20101strings, and which uses the \ldapauth\ expansion condition to check the user
20102name and password by binding to an LDAP server:
20103.display asis
20104login:
20105 driver = plaintext
20106 public_name = LOGIN
20107 server_prompts = Username:: : Password::
20108 server_condition = ${if ldapauth \
20109.newline
20110 {user="cn=${quote_ldap_dn:$1},ou=people,o=example.org" \
20111 pass=${quote:$2} \
20112.newline
20113 ldap://ldap.example.org/}{yes}{no}}
20114 server_set_id = uid=$1,ou=people,o=example.org
20115.endd
20116Note the use of the \quote@_ldap@_dn\ operator to correctly quote the DN for
20117authentication. However, the basic \quote\ operator, rather than any of the
20118LDAP quoting operators, is the correct one to use for the password, because
20119quoting is needed only to make the password conform to the Exim syntax. At the
20120LDAP level, the password is an uninterpreted string.
20121
20122
20123.section Support for different kinds of authentication
20124A number of string expansion features are provided for the purpose of
20125interfacing to different ways of user authentication. These include checking
20126traditionally encrypted passwords from \(/etc/passwd)\ (or equivalent), PAM,
20127Radius, \ldapauth\, and \*pwcheck*\. For details see section ~~SECTexpcond.
20128
20129
20130
20131.section Using plaintext in a client
20132The \%plaintext%\ authenticator has just one client option:
20133
20134.startconf
20135.index options||\%plaintext%\ authenticator (client)
20136
20137.conf client@_send string$**$ unset
20138The string is a colon-separated list of authentication data strings. Each
20139string is independently expanded before being sent to the server. The first
20140string is sent with the \\AUTH\\ command; any more strings are sent in response
20141to prompts from the server.
20142
20143\**Note**\: you cannot use expansion to create multiple strings, because
20144splitting takes priority and happens first.
20145
20146Because the PLAIN authentication mechanism requires NUL (binary zero) bytes in
20147the data, further processing is applied to each string before it is sent. If
20148there are any single circumflex characters in the string, they are converted to
20149NULs. Should an actual circumflex be required as data, it must be doubled in
20150the string.
20151
20152.endconf
20153
20154This is an example of a client configuration that implements the PLAIN
20155authentication mechanism with a fixed user name and password:
20156.display asis
20157fixed_plain:
20158 driver = plaintext
20159 public_name = PLAIN
20160 client_send = ^username^mysecret
20161.endd
20162The lack of colons means that the entire text is sent with the \\AUTH\\
20163command, with the circumflex characters converted to NULs. A similar example
20164that uses the LOGIN mechanism is:
20165.display asis
20166fixed_login:
20167 driver = plaintext
20168 public_name = LOGIN
20169 client_send = : username : mysecret
20170.endd
20171The initial colon means that the first string is empty, so no data is sent with
20172the \\AUTH\\ command itself. The remaining strings are sent in response to
20173prompts.
20174
20175
20176
20177
20178.
20179.
20180.
20181.
20182. ============================================================================
20183.chapter The cram@_md5 authenticator
20184.set runningfoot "cram@_md5 authenticator"
20185.index \%cram@_md5%\ authenticator
20186.index authenticators||\%cram@_md5%\
20187.index CRAM-MD5 authentication mechanism
20188.index authentication||CRAM-MD5 mechanism
20189The CRAM-MD5 authentication mechanism is described in RFC 2195. The server
20190sends a challenge string to the client, and the response consists of a user
20191name and the CRAM-MD5 digest of the challenge string combined with a secret
20192string (password) which is known to both server and client. Thus, the secret
20193is not sent over the network as plain text, which makes this authenticator more
20194secure than \%plaintext%\. However, the downside is that the secret has to be
20195available in plain text at either end.
20196
20197.section Using cram@_md5 as a server
20198This authenticator has one server option, which must be set to configure the
20199authenticator as a server:
20200
20201.startconf
20202.index options||\%cram@_md5%\ authenticator (server)
20203
20204.conf server@_secret string$**$ unset
20205.index numerical variables (\$1$\, \$2$\, etc)||in \%cram@_md5%\ authenticator
20206When the server receives the client's response, the user name is placed in
20207the expansion variable \$1$\, and \server@_secret\ is expanded to obtain the
20208password for that user. The server then computes the CRAM-MD5 digest that the
20209client should have sent, and checks that it received the correct string. If the
20210expansion of \server@_secret\ is forced to fail, authentication fails. If the
20211expansion fails for some other reason, a temporary error code is returned to
20212the client.
20213
20214.endconf
20215
20216For example, the following authenticator checks that the user name given by the
20217client is `ph10', and if so, uses `secret' as the password. For any other user
20218name, authentication fails.
20219.display asis
20220fixed_cram:
20221 driver = cram_md5
20222 public_name = CRAM-MD5
20223 server_secret = ${if eq{$1}{ph10}{secret}fail}
20224 server_set_id = $1
20225.endd
20226If authentication succeeds, the setting of \server@_set@_id\ preserves the user
20227name in \$authenticated@_id$\.
20228A more tyical configuration might look up the secret string in a file, using
20229the user name as the key. For example:
20230.display asis
20231lookup_cram:
20232 driver = cram_md5
20233 public_name = CRAM-MD5
20234 server_secret = ${lookup{$1}lsearch{/etc/authpwd}{$value}fail}
20235 server_set_id = $1
20236.endd
20237Note that this expansion explicitly forces failure if the lookup fails
20238because \$1$\ contains an unknown user name.
20239
20240.section Using cram@_md5 as a client
20241When used as a client, the \%cram@_md5%\ authenticator has two options:
20242
20243.startconf
20244.index options||\%cram@_md5%\ authenticator (client)
20245
20246.conf client@_name string$**$ "the primary host name"
20247This string is expanded, and the result used as the user name data when
20248computing the response to the server's challenge.
20249
20250.conf client@_secret string$**$ unset
20251This option must be set for the authenticator to work as a client. Its value is
20252expanded and the result used as the secret string when computing the response.
20253
20254.endconf
20255
20256Different user names and secrets can be used for different servers by referring
20257to \$host$\ or \$host@_address$\ in the options.
20258
20259Forced failure of either expansion string is treated as an indication that this
20260authenticator is not prepared to handle this case. Exim moves on to the next
20261configured client authenticator. Any other expansion failure causes Exim to
20262give up trying to send the message to the current server.
20263
20264A simple example configuration of a \%cram@_md5%\ authenticator, using fixed
20265strings, is:
20266.display asis
20267fixed_cram:
20268 driver = cram_md5
20269 public_name = CRAM-MD5
20270 client_name = ph10
20271 client_secret = secret
20272.endd
20273
20274
20275
20276
20277
20278.
20279.
20280.
20281.
20282. ============================================================================
20283.chapter The spa authenticator
20284.set runningfoot "spa authenticator"
20285.index \%spa%\ authenticator
20286.index authenticators||\%spa%\
20287.index authentication||Microsoft Secure Password
20288.index authentication||NTLM
20289.index Microsoft Secure Password Authentication
20290.index NTLM authentication
20291The \%spa%\ authenticator provides client support for Microsoft's \*Secure
20292Password Authentication*\ mechanism,
20293which is also sometimes known as NTLM (NT LanMan). The code for client side of
20294this authenticator was contributed by Marc Prud'hommeaux, and much of it is
20295taken from the Samba project (\?http://www.samba.org?\). The code for the
20296server side was subsequently contributed by Tom Kistner.
20297
20298The mechanism works as follows:
20299.numberpars $.
20300After the \\AUTH\\ command has been accepted, the client sends an SPA
20301authentication request based on the user name and optional domain.
20302.nextp
20303The server sends back a challenge.
20304.nextp
20305The client builds a challenge response which makes use of the user's password
20306and sends it to the server, which then accepts or rejects it.
20307.endp
20308Encryption is used to protect the password in transit.
20309
20310
20311.section Using spa as a server
20312The \%spa%\ authenticator has just one server option:
20313
20314.startconf
20315.index options||\%spa%\ authenticator (server)
20316
20317.conf server@_password string$**$ unset
20318.index numerical variables (\$1$\, \$2$\, etc)||in \%spa%\ authenticator
20319This option is expanded, and the result must be the cleartext password for the
20320authenticating user, whose name is at this point in \$1$\. For example:
20321.display asis
20322spa:
20323 driver = spa
20324 public_name = NTLM
20325 server_password = ${lookup{$1}lsearch{/etc/exim/spa_clearpass}}
20326.endd
20327If the expansion is forced to fail, authentication fails. Any other expansion
20328failure causes a temporary error code to be returned.
20329
20330.endconf
20331
20332
20333
20334.section Using spa as a client
20335The \%spa%\ authenticator has the following client options:
20336
20337.startconf
20338.index options||\%spa%\ authenticator (client)
20339
20340.conf client@_domain string$**$ unset
20341This option specifies an optional domain for the authentication.
20342
20343.conf client@_password string$**$ unset
20344This option specifies the user's password, and must be set.
20345
20346.conf client@_username string$**$ unset
20347This option specifies the user name, and must be set.
20348
20349.endconf
20350
20351Here is an example of a configuration of this authenticator for use with the
20352mail servers at \*msn.com*\:
20353.display asis
20354msn:
20355 driver = spa
20356 public_name = MSN
20357 client_username = msn/msn_username
20358 client_password = msn_plaintext_password
20359 client_domain = DOMAIN_OR_UNSET
20360.endd
20361
20362
20363
20364
20365
20366
20367.
20368.
20369.
20370.
20371. ============================================================================
20372.chapter Encrypted SMTP connections using TLS/SSL
20373.set runningfoot "TLS encryption"
20374.rset CHAPTLS "~~chapter"
20375.index encryption||on SMTP connection
20376.index SMTP||encryption
20377.index TLS||on SMTP connection
20378.index OpenSSL
20379.index GnuTLS
20380.em
20381Support for TLS (Transport Layer Security), formerly known as SSL (Secure
20382Sockets Layer), is implemented by making use of the OpenSSL library or the
20383GnuTLS library (Exim requires GnuTLS release 1.0 or later).
20384.nem
20385There is no cryptographic code in the Exim distribution itself for implementing
20386TLS. In order to use this feature you must install OpenSSL or GnuTLS, and then
20387build a version of Exim that includes TLS support (see section
20388~~SECTinctlsssl). You also need to understand the basic concepts of encryption
20389at a managerial level, and in particular, the way that public keys, private
20390keys, and certificates are used.
20391
20392RFC 2487 defines how SMTP connections can make use of encryption. Once a
20393connection is established, the client issues a \\STARTTLS\\ command. If the
20394server accepts this, the client and the server negotiate an encryption
20395mechanism. If the negotiation succeeds, the data that subsequently passes
20396between them is encrypted.
20397
20398Exim also has support for legacy clients that do not use the \\STARTTLS\\
20399mechanism. Instead, they connect to a different port on the server (usually
20400called the `ssmtp' port), and expect to negotiate a TLS session as soon as the
20401connection to the server is established. The \-tls-on-connect-\ command line
20402option can be used to run an Exim server in this way from \*inetd*\, and it can
20403also be used to run a special daemon that operates in this manner (use \-oX-\
20404to specify the port).
20405
20406Exim's ACLs can detect whether the current SMTP session is encrypted or not,
20407and if so, what cipher suite is in use, whether the client supplied a
20408certificate, and whether or not that certificate was verified. This makes it
20409possible for an Exim server to deny or accept certain commands based on the
20410encryption state.
20411
20412\**Warning**\: certain types of firewall and certain anti-virus products can
20413disrupt TLS connections. You need to turn off SMTP scanning for these products
20414in order to get TLS to work.
20415
20416
20417.section OpenSSL vs GnuTLS
20418.index TLS||OpenSSL \*vs*\ GnuTLS
20419.rset SECTopenvsgnu "~~chapter.~~section"
20420The first TLS support in Exim was implemented using OpenSSL. Support for GnuTLS
20421followed later, when the first versions of GnuTLS were released. To build Exim
20422to use GnuTLS, you need to set
20423.display asis
20424USE_GNUTLS=yes
20425.endd
20426in Local/Makefile, in addition to
20427.display asis
20428SUPPORT_TLS=yes
20429.endd
20430You must also set \\TLS@_LIBS\\ and \\TLS@_INCLUDE\\ appropriately, so that the
20431include files and libraries for GnuTLS can be found.
20432
20433There are some differences in usage when using GnuTLS instead of OpenSSL:
20434.numberpars $.
20435.em
20436The \tls@_verify@_certificates\ option must contain the name of a file, not the
20437name of a directory (for OpenSSL it can be either).
20438.nem
20439.nextp
20440The \tls@_dhparam\ option is ignored, because early versions of GnuTLS had no
20441facility for varying its Diffie-Hellman parameters. I understand that this has
20442changed, but Exim has not been updated to provide this facility.
20443.nextp
20444GnuTLS uses RSA and D-H parameters that take a substantial amount of
20445time to compute. It is unreasonable to re-compute them for every TLS
20446session. Therefore, Exim keeps this data in a file in its spool
20447directory, called \(gnutls-params)\. The file is owned by the Exim user and is
20448readable only by its owner. Every Exim process that start up GnuTLS reads the
20449RSA and D-H parameters from this file. If the file does not exist, the first
20450Exim process that needs it computes the data and writes it to a temporary file
20451which is renamed once it is complete. It does not matter if several Exim
20452processes do this simultaneously (apart from wasting a few resources). Once a
20453file is in place, new Exim processes immediately start using it.
20454
20455For maximum security, the parameters that are stored in this file should be
20456recalculated periodically, the frequency depending on your paranoia level.
20457Arranging this is easy; just delete the file when you want new values to be
20458computed.
20459.nextp
20460.em
20461Distinguished Name (DN) strings reported by the OpenSSL library use a slash for
20462separating fields; GnuTLS uses commas, in accordance with RFC 2253. This
20463affects the value of the \$tls@_peerdn$\ variable.
20464.nem
20465.nextp
20466OpenSSL identifies cipher suites using hyphens as separators, for example:
20467DES-CBC3-SHA. GnuTLS uses underscores, for example: RSA@_ARCFOUR@_SHA. What is
20468more, OpenSSL complains if underscores are present in a cipher list. To make
20469life simpler, Exim changes underscores to hyhens for OpenSSL and hyphens to
20470underscores for GnuTLS when processing lists of cipher suites in the
20471.em
20472\tls@_require@_ciphers\ options (the global option and the \%smtp%\ transport
20473option).
20474.nem
20475.nextp
20476.em
20477The \tls@_require@_ciphers\ options operate differently, as described in the
20478following section.
20479.nem
20480.endp
20481
20482.em
20483.section Requiring specific ciphers in OpenSSL and GnuTLS
20484.rset SECTreqciphsslgnu "~~chapter.~~section"
20485.index TLS||requiring specific ciphers
20486.index \tls@_require@_ciphers\||OpenSSL \*vs*\ GnuTLS
20487This section documents the different ways the \tls@_require@_ciphers\ options
20488(the global option and the \%smtp%\ transport option) operate in OpenSSL and
20489GnuTLS.
20490
20491There is a function in the OpenSSL library that can be passed a list of
20492cipher suites before the cipher negotiation takes place. This specifies which
20493ciphers are acceptable. The list is colon separated and may contain names like
20494DES-CBC3-SHA. Exim passes the expanded value of \tls@_require@_ciphers\
20495directly to this function call. The following quotation from
20496the OpenSSL documentation specifies what forms of item are allowed in the
20497cipher string:
20498.numberpars $.
20499It can consist of a single cipher suite such as RC4-SHA.
20500.nextp
20501It can represent a list of cipher suites containing a certain algorithm,
20502or cipher suites of a certain type. For example SHA1 represents all
20503ciphers suites using the digest algorithm SHA1 and SSLv3 represents all
20504SSL v3 algorithms.
20505.nextp
20506Lists of cipher suites can be combined in a single cipher string using
20507the + character. This is used as a logical and operation. For example
20508SHA1+DES represents all cipher suites containing the SHA1 and the DES
20509algorithms.
20510.nextp
20511Each cipher string can be optionally preceded by the characters \"!"\, \"-"\ or
20512\"+"\.
20513.numberpars " "
20514If \"!"\ is used then the ciphers are permanently deleted from the list. The
20515ciphers deleted can never reappear in the list even if they are explicitly
20516stated.
20517.nextp
20518If \"-"\ is used then the ciphers are deleted from the list, but some or all
20519of the ciphers can be added again by later options.
20520.nextp
20521If \"+"\ is used then the ciphers are moved to the end of the list. This
20522option doesn't add any new ciphers it just moves matching existing ones.
20523.nextp
20524If none of these characters is present then the string is just interpreted as a
20525list of ciphers to be appended to the current preference list. If the list
20526includes any ciphers already present they will be ignored: that is, they will
20527not moved to the end of the list.
20528.endp
20529.endp
20530
20531The GnuTLS library does not have a combined function like OpenSSL. Instead,
20532it allows the caller to specify separate lists of key-exchange methods,
20533main cipher algorithms, and MAC algorithms. Unfortunately, these lists are
20534numerical, and the library does not have a function for turning names into
20535numbers. Consequently, the list of recognized names has to be built into
20536the application.
20537
20538At present, Exim permits only the list of main cipher algorithms to be
20539changed. The \tls@_require@_ciphers\ option is in the same format as for
20540OpenSSL. Exim searches each item for the name of available algorithm. For
20541example, if the list contains RSA@_ARCFOUR@_SHA then ARCFOUR is recognized.
20542
20543The cipher algorithms list starts out with a default set of algorithms. If
20544the first item in \tls@_require@_ciphers\ does \*not*\ start with an
20545exclamation mark, all the default items are deleted. Thus, only those specified
20546can be used. If the first item in \tls@_require@_ciphers\ \*does*\ start with
20547an exclamation mark, the defaults are left on the list.
20548
20549Then, any item that starts with an exclamation mark causes the relevent
20550algorithms to be removed from the list, and any item that does not start
20551with an exclamation mark causes the relevant algorithms to be added to the
20552list. Thus,
20553.display asis
20554tls_require_ciphers = !RSA_ARCFOUR_SHA
20555.endd
20556allows all the defaults except those that use ARCFOUR, whereas
20557.display asis
20558tls_require_ciphers = AES : 3DES
20559.endd
20560allows only cipher suites that use AES and 3DES. The currently recognized
20561algorithms are: ARCFOUR@_128, ARCFOUR@_40, ARCFOUR (both of the preceding),
20562AES@_256, AES@_128, AES (both of the preceding), and 3DES.
20563
20564Unrecognized algorithms are ignored. In a client, the order of the list
20565specifies a preference order for the algorithms.
20566.nem
20567
20568
20569.section Configuring an Exim server to use TLS
20570.index TLS||configuring an Exim server
20571When Exim has been built with TLS support, it advertises the availability of
20572the \\STARTTLS\\ command to client hosts that match \tls@_advertise@_hosts\,
20573but not to any others. The default value of this option is unset, which means
20574that \\STARTTLS\\ is not advertised at all. This default is chosen because you
20575need to set some other options in order to make TLS avaliable, and also it is
20576sensible for systems that want to use TLS only as a client.
20577
20578If a client issues a \\STARTTLS\\ command and there is some configuration
20579problem in the server, the command is rejected with a 454 error. If the client
20580persists in trying to issue SMTP commands, all except \\QUIT\\ are rejected
20581with the error
20582.display asis
20583554 Security failure
20584.endd
20585If a \\STARTTLS\\ command is issued within an existing TLS session, it is
20586rejected with a 554 error code.
20587
20588To enable TLS operations on a server, you must set \tls@_advertise@_hosts\ to
20589match some hosts. You can, of course, set it to $*$ to match all hosts.
20590However, this is not all you need to do. TLS sessions to a server won't work
20591without some further configuration at the server end.
20592
20593It is rumoured that all existing clients that support TLS/SSL use RSA
20594encryption. To make this work you need to set, in the server,
20595.display asis
20596tls_certificate = /some/file/name
20597tls_privatekey = /some/file/name
20598.endd
20599The first file contains the server's X509 certificate, and the second contains
20600the private key that goes with it. These files need to be readable by the Exim
20601user, and must always be given as full path names. They can be the same file if
20602both the certificate and the key are contained within it. If \tls@_privatekey\
20603is not set, this is assumed to be the case. The certificate file may also
20604contain intermediate certificates that need to be sent to the client to enable
20605it to authenticate the server's certificate.
20606
20607If you do not understand about certificates and keys, please try to find a
20608source of this background information, which is not Exim-specific. (There are a
20609few comments below in section ~~SECTcerandall.)
20610
20611\**Note**\: These options do not apply when Exim is operating as a client --
20612they apply only in the case of a server. For a client, you must set the options
20613of the same name in an \%smtp%\ transport.
20614
20615With just these options, Exim will work as a server with clients such as
20616Netscape. It does not require the client to have a certificate (but see below
20617for how to insist on this). There is one other option that may be needed in
20618other situations. If
20619.display asis
20620tls_dhparam = /some/file/name
20621.endd
20622is set, the SSL library is initialized for the use of Diffie-Hellman ciphers
20623with the parameters contained in the file. This increases the set of cipher
20624suites that the server supports. See the command
20625.display asis
20626openssl dhparam
20627.endd
20628for a way of generating this data.
20629At present, \tls@_dhparam\ is used only when Exim is linked with OpenSSL. It is
20630ignored if GnuTLS is being used.
20631
20632The strings supplied for these three options are expanded every time a client
20633host connects. It is therefore possible to use different certificates and keys
20634for different hosts, if you so wish, by making use of the client's IP address
20635in \$sender@_host@_address$\ to control the expansion. If a string expansion is
20636forced to fail, Exim behaves as if the option is not set.
20637
20638.index cipher||logging
20639.index log||TLS cipher
20640The variable \$tls@_cipher$\ is set to the cipher suite that was negotiated for
20641an incoming TLS connection. It is included in the ::Received:: header of an
20642incoming message (by default -- you can, of course, change this), and it is
20643also included in the log line that records a message's arrival, keyed by `X=',
20644unless the \tls@_cipher\ log selector is turned off.
20645The \encrypted\ condition can be used to test for specific cipher suites in
20646ACLs.
20647
20648The ACLs that run for subsequent SMTP commands can check the name of the cipher
20649suite and vary their actions accordingly. The cipher suite names are those used
20650by OpenSSL. These may differ from the names used elsewhere. For example,
20651OpenSSL uses the name DES-CBC3-SHA for the cipher suite which in other contexts
20652is known as TLS@_RSA@_WITH@_3DES@_EDE@_CBC@_SHA. Check the OpenSSL
20653documentation for more details.
20654
20655
20656.section Requesting and verifying client certificates
20657.index certificate||verification of client
20658.index TLS||client certificate verification
20659If you want an Exim server to request a certificate when negotiating a TLS
20660session with a client, you must set either \tls@_verify@_hosts\ or
20661\tls@_try@_verify@_hosts\. You can, of course, set either of them to $*$ to
20662apply to all TLS connections. For any host that matches one of these options,
20663Exim requests a certificate as part of the setup of the TLS session. The
20664contents of the certificate are verified by comparing it with a list of
20665expected certificates. These must be available in a file or,
20666.em
20667for OpenSSL only (not GnuTLS), a directory, identified by
20668\tls@_verify@_certificates\.
20669.nem
20670
20671A file can contain multiple certificates, concatenated end to end. If a
20672directory is used
20673.em
20674(OpenSSL only),
20675.nem
20676each certificate must be in a separate file, with a name (or a symbolic link)
20677of the form <<hash>>.0, where <<hash>> is a hash value constructed from the
20678certificate. You can compute the relevant hash by running the command
20679.display asis
20680openssl x509 -hash -noout -in /cert/file
20681.endd
20682where \(/cert/file)\ contains a single certificate.
20683
20684The difference between \tls@_verify@_hosts\ and \tls@_try@_verify@_hosts\ is
20685what happens if the client does not supply a certificate, or if the certificate
20686does not match any of the certificates in the collection named by
20687\tls@_verify@_certificates\. If the client matches \tls@_verify@_hosts\, the
20688attempt to set up a TLS session is aborted, and the incoming connection is
20689dropped. If the client matches \tls@_try@_verify@_hosts\, the (encrypted) SMTP
20690session continues. ACLs that run for subsequent SMTP commands can detect the
20691fact that no certificate was verified, and vary their actions accordingly. For
20692example, you can insist on a certificate before accepting a message for
20693relaying, but not when the message is destined for local delivery.
20694
20695When a client supplies a certificate (whether it verifies or not), the value of
20696the Distinguished Name of the certificate is made available in the variable
20697\$tls@_peerdn$\ during subsequent processing of the message.
20698.index log||distinguished name
20699Because it is often a long text string, it is not included in the log line or
20700::Received:: header by default. You can arrange for it to be logged, keyed by
20701`DN=', by setting the \tls@_peerdn\ log selector, and you can use
20702\received@_header@_text\ to change the ::Received:: header. When no certificate
20703is supplied, \$tls@_peerdn$\ is empty.
20704
20705.em
20706.section Revoked certificates
20707.index TLS||revoked certificates
20708.index revocation list
20709.index certificate||revocation list
20710Certificate issuing authorities issue Certificate Revocation Lists (CRLs) when
20711certificates are revoked. If you have such a list, you can pass it to an Exim
20712server using the global option called \tls@_crl\ and to an Exim client using an
20713identically named option for the \%smtp%\ transport. In each case, the value of
20714the option is expanded and must then be the name of a file that contains a CRL
20715in PEM format.
20716.nem
20717
20718.section Configuring an Exim client to use TLS
20719.index cipher||logging
20720.index log||TLS cipher
20721.index log||distinguished name
20722.index TLS||configuring an Exim client
20723The \tls@_cipher\ and \tls@_peerdn\ log selectors apply to outgoing SMTP
20724deliveries as well as to incoming, the latter one causing logging of the
20725server certificate's DN. The remaining client configuration for TLS is all
20726within the \%smtp%\ transport.
20727
20728It is not necessary to set any options to have TLS work in the \%smtp%\
20729transport. If Exim is built with TLS support, and TLS is advertised by a
20730server, the \%smtp%\ transport always tries to start a TLS session. However,
20731this can be prevented by setting \hosts@_avoid@_tls\ (an option of the
20732transport) to a list of server hosts for which TLS should not be used.
20733
20734If you do not want Exim to attempt to send messages unencrypted when an attempt
20735to set up an encrypted connection fails in any way, you can set
20736\hosts@_require@_tls\ to a list of hosts for which encryption is mandatory. For
20737those hosts, delivery is always deferred if an encrypted connection cannot be
20738set up. If there are any other hosts for the address, they are tried in the
20739usual way.
20740
20741When the server host is not in \hosts@_require@_tls\, Exim may try to deliver
20742the message unencrypted. It always does this if the response to \\STARTTLS\\ is
20743a 5\*xx*\ code. For a temporary error code, or for a failure to negotiate a TLS
20744session after a success response code, what happens is controlled by the
20745\tls@_tempfail@_tryclear\ option of the \%smtp%\ transport. If it is false,
20746delivery to this host is deferred, and other hosts (if available) are tried. If
20747it is true, Exim attempts to deliver unencrypted after a 4\*xx*\ response to
20748\\STARTTLS\\, and if \\STARTTLS\\ is accepted, but the subsequent TLS
20749negotiation fails, Exim closes the current connection (because it is in an
20750unknown state), opens a new one to the same host, and then tries the delivery
20751unencrypted.
20752
20753
20754The \tls@_certificate\ and \tls@_privatekey\ options of the \%smtp%\ transport
20755provide the client with a certificate, which is passed to the server if it
20756requests it. If the server is Exim, it will request a certificate only if
20757\tls@_verify@_hosts\ or \tls@_try@_verify@_hosts\ matches the client.
20758\**Note**\: these options must be set in the \%smtp%\ transport for Exim to use
20759TLS when it is operating as a client. Exim does not assume that a server
20760certificate (set by the global options of the same name) should also be used
20761when operating as a client.
20762
20763If \tls@_verify@_certificates\ is set, it must name a file or,
20764.em
20765for OpenSSL only (not GnuTLS), a directory, that contains a collection of
20766expected server certificates. The client verifies the server's certificate
20767against this collection, taking into account any revoked certificates that are
20768in the list defined by \tls@_crl\.
20769.nem
20770
20771If
20772\tls@_require@_ciphers\ is set on the \%smtp%\ transport, it must contain a
20773list of permitted cipher suites. If either of these checks fails, delivery to
20774the current host is abandoned, and the \%smtp%\ transport tries to deliver to
20775alternative hosts, if any.
20776
20777All the TLS options in the \%smtp%\ transport are expanded before use, with
20778\$host$\ and \$host@_address$\ containing the name and address of the server to
20779which the client is connected. Forced failure of an expansion causes Exim to
20780behave as if the relevant option were unset.
20781
20782
20783.section Multiple messages on the same encrypted TCP/IP connection
20784.rset SECTmulmessam "~~chapter.~~section"
20785.index multiple SMTP deliveries with TLS
20786.index TLS||multiple message deliveries
20787Exim sends multiple messages down the same TCP/IP connection by starting up
20788an entirely new delivery process for each message, passing the socket from
20789one process to the next. This implementation does not fit well with the use
20790of TLS, because there is quite a lot of state information associated with a TLS
20791connection, not just a socket identification. Passing all the state information
20792to a new process is not feasible. Consequently, Exim shuts down an existing TLS
20793session before passing the socket to a new process. The new process may then
20794try to start a new TLS session, and if successful, may try to re-authenticate
20795if \\AUTH\\ is in use, before sending the next message.
20796
20797The RFC is not clear as to whether or not an SMTP session continues in clear
20798after TLS has been shut down, or whether TLS may be restarted again later, as
20799just described. However, if the server is Exim, this shutdown and
20800reinitialization works. It is not known which (if any) other servers operate
20801successfully if the client closes a TLS session and continues with unencrypted
20802SMTP, but there are certainly some that do not work. For such servers, Exim
20803should not pass the socket to another process, because the failure of the
20804subsequent attempt to use it would cause Exim to record a temporary host error,
20805and delay other deliveries to that host.
20806
20807To test for this case, Exim sends an \\EHLO\\ command to the server after
20808closing down the TLS session. If this fails in any way, the connection is
20809closed instead of being passed to a new delivery process, but no retry
20810information is recorded.
20811
20812There is also a manual override; you can set \hosts@_nopass@_tls\ on the
20813\%smtp%\ transport to match those hosts for which Exim should not pass
20814connections to new processes if TLS has been used.
20815
20816
20817
20818.section Certificates and all that
20819.rset SECTcerandall "~~chapter.~~section"
20820.index certificate||references to discussion
20821In order to understand fully how TLS works, you need to know about
20822certificates, certificate signing, and certificate authorities. This is not the
20823place to give a tutorial, especially as I do not know very much about it
20824myself. Some helpful introduction can be found in the FAQ for the SSL addition
20825to Apache, currently at
20826.display rm
20827\?http://www.modssl.org/docs/2.7/ssl@_faq.html@#ToC24?\
20828.endd
20829Other parts of the \*modssl*\ documentation are also helpful, and have
20830links to further files.
20831Eric Rescorla's book, \*SSL and TLS*\, published by Addison-Wesley (ISBN
208320-201-61598-3), contains both introductory and more in-depth descriptions.
20833Some sample programs taken from the book are available from
20834.display rm
20835\?http://www.rtfm.com/openssl-examples/?\
20836.endd
20837
20838.section Certificate chains
20839The file named by \tls@_certificate\ may contain more than one
20840certificate. This is useful in the case where the certificate that is being
20841sent is validated by an intermediate certificate which the other end does
20842not have. Multiple certificates must be in the correct order in the file.
20843First the host's certificate itself, then the first intermediate
20844certificate to validate the issuer of the host certificate, then the next
20845intermediate certificate to validate the issuer of the first intermediate
20846certificate, and so on, until finally (optionally) the root certificate.
20847The root certificate must already be trusted by the recipient for
20848validation to succeed, of course, but if it's not preinstalled, sending the
20849root certificate along with the rest makes it available for the user to
20850install if the receiving end is a client MUA that can interact with a user.
20851
20852.section Self-signed certificates
20853.index certificate||self-signed
20854You can create a self-signed certificate using the \*req*\ command provided
20855with OpenSSL, like this:
20856.display asis
20857openssl req -x509 -newkey rsa:1024 -keyout file1 -out file2 \
20858 -days 9999 -nodes
20859.endd
20860\(file1)\ and \(file2)\ can be the same file; the key and the certificate are
20861delimited and so can be identified independently. The \-days-\ option
20862specifies a period for which the certificate is valid. The \-nodes-\ option is
20863important: if you do not set it, the key is encrypted with a passphrase
20864that you are prompted for, and any use that is made of the key causes more
20865prompting for the passphrase. This is not helpful if you are going to use
20866this certificate and key in an MTA, where prompting is not possible.
20867
20868A self-signed certificate made in this way is sufficient for testing, and
20869may be adequate for all your requirements if you are mainly interested in
20870encrypting transfers, and not in secure identification.
20871
20872However, many clients require that the certificate presented by the server be a
20873user (also called `leaf' or `site') certificate, and not a self-signed
20874certificate. In this situation, the self-signed certificate described above
20875must be installed on the client host as a trusted root \*certification
20876authority*\ (CA), and the certificate used by Exim must be a user certificate
20877signed with that self-signed certificate.
20878
20879For information on creating self-signed CA certificates and using them to sign
20880user certificates, see the \*General implementation overview*\ chapter of the
20881Open-source PKI book, available online at \?http://ospkibook.sourceforge.net/?\.
20882
20883
20884
20885.
20886.
20887.
20888.
20889. ============================================================================
20890.chapter Access control lists
20891.set runningfoot "ACL"
20892.rset CHAPACL "~~chapter"
20893.index ~~ACL||description
20894.index control of incoming mail
20895.index message||controlling incoming
20896.index policy control||access control lists
20897Access Control Lists (ACLs) are defined in a separate section of the run time
20898configuration file, headed by `begin acl'. Each ACL definition starts with a
20899name, terminated by a colon. Here is a complete ACL section which contains just
20900one very small ACL:
20901.display asis
20902begin acl
20903
20904small_acl:
20905 accept hosts = one.host.only
20906.endd
20907You can have as many lists as you like in the ACL section, and the order in
20908which they appear does not matter. The lists are self-terminating.
20909
20910The majority of ACLs are used to control Exim's behaviour when it receives
20911certain SMTP commands. This applies both to incoming TCP/IP connections, and
20912when a local process submits a message over a pipe (using the \-bs-\ option).
20913The most common use is for controlling which recipients are accepted in
20914incoming messages. In addition, you can also define an ACL that is used to
20915check local non-SMTP messages. The default configuration file contains an
20916example of a realistic ACL for checking \\RCPT\\ commands. This is discussed in
20917chapter ~~CHAPdefconfil.
20918
20919.section Testing ACLs
20920The \-bh-\ command line option provides a way of testing your ACL configuration
20921locally by running a fake SMTP session with which you interact. The host
20922\*relay-test.mail-abuse.org*\ provides a service for checking your relaying
20923configuration (see section ~~SECTcheralcon for more details).
20924
20925
20926.section Specifying when ACLs are used
20927.index ~~ACL||options for specifying
20928In order to cause an ACL to be used, you have to name it in one of the relevant
20929options in the main part of the configuration. These options are:
20930.index \\AUTH\\||ACL for
20931.index \\DATA\\, ACL for
20932.index \\ETRN\\||ACL for
20933.index \\EXPN\\||ACL for
20934.index \\HELO\\||ACL for
20935.index \\EHLO\\||ACL for
20936.index \\MAIL\\||ACL for
20937.index \\RCPT\\||ACL for
20938.index \\STARTTLS\\, ACL for
20939.index \\VRFY\\||ACL for
20940.display
20941.tabs 20
20942.if !~~sys.fancy
20943.tabs 24
20944.fi
20945\acl@_not@_smtp\ $t $rm{ACL for non-SMTP messages}
20946\acl@_smtp@_auth\ $t $rm{ACL for \\AUTH\\}
20947\acl@_smtp@_connect\ $t $rm{ACL for start of SMTP connection}
20948\acl@_smtp@_data\ $t $rm{ACL after \\DATA\\}
20949\acl@_smtp@_etrn\ $t $rm{ACL for \\ETRN\\}
20950\acl@_smtp@_expn\ $t $rm{ACL for \\EXPN\\}
20951\acl@_smtp@_helo\ $t $rm{ACL for \\HELO\\ or \\EHLO\\}
20952\acl@_smtp@_mail\ $t $rm{ACL for \\MAIL\\}
20953.newline
20954\acl@_smtp@_mailauth\ $t $rm{ACL for the \\AUTH\\ parameter of \\MAIL\\}
20955.newline
20956\acl@_smtp@_rcpt\ $t $rm{ACL for \\RCPT\\}
20957\acl@_smtp@_starttls\ $t $rm{ACL for \\STARTTLS\\}
20958\acl@_smtp@_vrfy\ $t $rm{ACL for \\VRFY\\}
20959.endd
20960For example, if you set
20961.display asis
20962acl_smtp_rcpt = small_acl
20963.endd
20964the little ACL defined above is used whenever Exim receives a \\RCPT\\ command
20965in an SMTP dialogue. The majority of policy tests on incoming messages can be
20966done when \\RCPT\\ commands arrive. A rejection of \\RCPT\\ should cause the
20967sending MTA to give up on the recipient address contained in the \\RCPT\\
20968command, whereas rejection at other times may cause the client MTA to keep on
20969trying to deliver the message. It is therefore recommended that you do as much
20970testing as possible at \\RCPT\\ time.
20971
20972However, you cannot test the contents of the message, for example, to verify
20973addresses in the headers, at \\RCPT\\ time. Such tests have to appear in the
20974ACL that is run after the message has been received, before the final response
20975to the \\DATA\\ command is sent. This is the ACL specified by
20976\acl@_smtp@_data\. At this time, it is no longer possible to reject individual
20977recipients. An error response should reject the entire message. Unfortunately,
20978it is known that some MTAs do not treat hard (5$it{xx}) errors correctly at
20979this point -- they keep the message on their queues and try again later, but
20980that is their problem, though it does waste some of your resources.
20981
20982The ACL test specified by \acl@_smtp@_connect\ happens after the test specified
20983by \host__reject__connection\ (which is now an anomaly) and any TCP Wrappers
20984testing (if configured).
20985
20986The non-SMTP ACL applies to all non-interactive incoming messages, that is, it
20987applies to batch SMTP as well as to non-SMTP messages. (Batch SMTP is not
20988really SMTP.) This ACL is run just before the \*local@_scan()*\ function. Any
20989kind of rejection is treated as permanent, because there is no way of sending a
20990temporary error for these kinds of message. Many of the ACL conditions (for
20991example, host tests, and tests on the state of the SMTP connection such as
20992encryption and authentication) are not relevant and are forbidden in this ACL.
20993
20994
20995.section ACL return codes
20996.index ~~ACL||return codes
20997The result of running an ACL is either `accept' or `deny', or, if some test
20998cannot be completed (for example, if a database is down), `defer'. These
20999results cause 2$it{xx}, 5$it{xx}, and 4$it{xx} return codes, respectively, to
21000be used in the SMTP dialogue. A fourth return, `error', occurs when there is an
21001error such as invalid syntax in the ACL. This also causes a 4$it{xx} return
21002code.
21003
21004The ACLs that are relevant to message reception may also return `discard'. This
21005has the effect of `accept', but causes either the entire message or an
21006individual recipient address to be discarded. In other words, it is a
21007blackholing facility. Use it with great care.
21008
21009If the ACL for \\MAIL\\ returns `discard', all recipients are discarded, and no
21010ACL is run for subsequent \\RCPT\\ commands. The effect of `discard' in a
21011\\RCPT\\ ACL is to discard just the one address. If there are no recipients
21012left when the message's data is received, the \\DATA\\ ACL is not run. A
21013`discard' return from the \\DATA\\ or the non-SMTP ACL discards all the
21014remaining recipients.
21015
21016The \*local@_scan()*\ function is always run, even if there are no remaining
21017recipients; it may create new recipients.
21018
21019
21020.section Unset ACL options
21021.index ~~ACL||unset options
21022.em
21023The default actions when any of the \acl@_$it{xxx}\ options are unset are not
21024all the same. \**Note**\: These defaults apply only when the relevant ACL is
21025not defined at all. For any defined ACL, the default action if control reaches
21026the end of the ACL statements is `deny'.
21027.nem
21028
21029For \acl@_not@_smtp\, \acl@_smtp@_auth\, \acl@_smtp@_connect\,
21030\acl@_smtp@_data\, \acl@_smtp@_helo\, \acl__smtp__mail\, \acl@_smtp@_mailauth\,
21031and \acl@_smtp@_starttls\, the
21032.em
21033action when the ACL is not defined is `accept'.
21034
21035For the others (\acl@_smtp@_etrn\, \acl@_smtp@_expn\, \acl@_smtp@_rcpt\, and
21036\acl@_smtp@_vrfy\), the action when the ACL is not defined is `deny'.
21037.nem
21038This means that \acl@_smtp@_rcpt\ must be defined in order to receive any
21039messages over an SMTP connection. For an example, see the ACL in the default
21040configuration file.
21041
21042
21043
21044.section Data for message ACLs
21045.index ~~ACL||data for message ACL
21046When an ACL for \\MAIL\\, \\RCPT\\, or \\DATA\\ is being run, the variables
21047that contain information about the host and the message's sender (for example,
21048\$sender@_host@_address$\ and \$sender@_address$\) are set, and can be used in
21049ACL statements. In the case of \\RCPT\\ (but not \\MAIL\\ or \\DATA\\),
21050\$domain$\ and \$local@_part$\ are set from the argument address.
21051
21052When an ACL for the \\AUTH\\ parameter of \\MAIL\\ is being run, the variables
21053that contain information about the host are set, but \$sender@_address$\ is not
21054yet set.
21055
21056The \$message@_size$\ variable is set to the value of the \\SIZE\\ parameter on
21057the \\MAIL\\ command at \\MAIL\\ and \\RCPT\\ time, or -1 if that parameter was
21058not given.
21059Its value is updated to the true message size by the time the ACL after
21060\\DATA\\ is run.
21061
21062The \$rcpt@_count$\ variable increases by one for each \\RCPT\\ command
21063received. The \$recipients@_count$\ variable increases by one each time a
21064\\RCPT\\ command is accepted, so while an ACL for \\RCPT\\ is being processed,
21065it contains the number of previously accepted recipients. At \\DATA\\ time,
21066\$rcpt@_count$\ contains the total number of \\RCPT\\ commands, and
21067\$recipients@_count$\ contains the total number of accepted recipients.
21068
21069
21070
21071.section Data for non-message ACLs
21072.rset SECTdatfornon "~~chapter.~~section"
21073.index ~~ACL||data for non-message ACL
21074When an ACL for \\AUTH\\, \\ETRN\\, \\EXPN\\,
21075\\STARTTLS\\,
21076or \\VRFY\\ is being run, the remainder of the SMTP command line is placed in
21077\$smtp@_command@_argument$\. This can be tested using a \condition\ condition.
21078For example, here is an ACL for use with \\AUTH\\, which insists that either
21079the session is encrypted, or the CRAM-MD5 authentication method is used. In
21080other words, it does not permit authentication methods that use cleartext
21081passwords on unencrypted connections.
21082.display asis
21083acl_check_auth:
21084 accept encrypted = *
21085 accept condition = ${if eq{${uc:$smtp_command_argument}}\
21086 {CRAM-MD5}{yes}{no}}
21087 deny message = TLS encryption or CRAM-MD5 required
21088.endd
21089(Another way of applying this restriction is to arrange for the authenticators
21090that use cleartext passwords not to be advertised when the connection is not
21091encrypted. You can use the generic \server@_advertise@_condition\ authenticator
21092option to do this.)
21093
21094
21095.section Use of the ACL selection options
21096.index ~~ACL||specifying which to use
21097The value of an \acl@_smtp@_$it{xxx}\ option is expanded before use, so you can
21098use different ACLs in different circumstances, and in fact the resulting string
21099does not have to be the name of a configured list. Having expanded the string,
21100Exim searches for an ACL as follows:
21101.numberpars $.
21102If the string begins with a slash, Exim attempts to open the file and read
21103its contents as an ACL.
21104The lines are processed in the same way as lines in the Exim configuration
21105file. In particular, continuation lines are supported, blank lines are ignored,
21106as are lines whose first non-whitespace character is `@#'.
21107If the file does not exist or cannot be read, an error occurs (typically
21108causing a temporary failure of whatever caused the ACL to be run). For example:
21109.display asis
21110acl_smtp_data = /etc/acls/\
21111 ${lookup{$sender_host_address}lsearch\
21112 {/etc/acllist}{$value}{default}}
21113.endd
21114This looks up an ACL file to use on the basis of the host's IP address, falling
21115back to a default if the lookup fails. If an ACL is successfully read from a
21116file, it is retained in memory for the duration of the Exim process, so that it
21117can be re-used without having to re-read the file.
21118.nextp
21119If the string does not start with a slash, and does not contain any spaces,
21120Exim searches the ACL section of the configuration for a list whose name
21121matches the string.
21122.nextp
21123If no named ACL is found, or if the string contains spaces, Exim parses
21124the string as an inline ACL. This can save typing in cases where you just
21125want to have something like
21126.display asis
21127acl_smtp_vrfy = accept
21128.endd
21129in order to allow free use of the \\VRFY\\ command.
21130Such a string may contain newlines; it is processed in the same way as an ACL
21131that is read from a file.
21132.endp
21133
21134
21135.section Format of an ACL
21136.index ~~ACL||format of
21137.index ~~ACL||verbs, definition of
21138An individual ACL consists of a number of statements. Each statement starts
21139with a verb, optionally followed by a number of conditions and other modifiers.
21140If all the conditions are met, the verb is obeyed.
21141The same condition may be used (with different arguments) more than once in the
21142same statement. This provides a means of specifying an `and' conjunction
21143between conditions. For example:
21144.display asis
21145deny dnslists = list1.example
21146 dnslists = list2.example
21147.endd
21148
21149If there are no conditions, the verb is always obeyed. What happens if any of
21150the conditions are not met depends on the verb (and in one case, on a special
21151modifier). Not all the conditions make sense at every testing point. For
21152example, you cannot test a sender address in the ACL that is run for a \\VRFY\\
21153command.
21154
21155The verbs are as follows:
21156.numberpars $.
21157\accept\: If all the conditions are met, the ACL returns `accept'. If any of
21158the conditions are not met, what happens depends on whether \endpass\ appears
21159among the conditions (for syntax see below). If the failing condition precedes
21160\endpass\, control is passed to the next ACL statement; if it follows
21161\endpass\, the ACL returns `deny'. Consider this statement, used to check a
21162\\RCPT\\ command:
21163.display asis
21164accept domains = +local_domains
21165 endpass
21166 verify = recipient
21167.endd
21168If the recipient domain does not match the \domains\ condition, control passes
21169to the next statement. If it does match, the recipient is verified, and the
21170command is accepted if verification succeeds. However, if verification fails,
21171the ACL yields `deny', because the failing condition is after \endpass\.
21172.nextp
21173\defer\: If all the conditions are met, the ACL returns `defer' which, in an
21174SMTP session, causes a 4\*xx*\ response to be given. For a non-SMTP ACL,
21175\defer\ is the same as \deny\, because there is no way of sending a temporary
21176error. For a \\RCPT\\ command, \defer\ is much the same as using a
21177\%redirect%\ router and \":defer:"\ while verifying, but the \defer\ verb can
21178be used in any ACL, and even for a recipient it might be a simpler approach.
21179.nextp
21180\deny\: If all the conditions are met, the ACL returns `deny'. If any of the
21181conditions are not met, control is passed to the next ACL statement. For
21182example,
21183.display asis
21184deny dnslists = blackholes.mail-abuse.org
21185.endd
21186rejects commands from hosts that are on a DNS black list.
21187.nextp
21188\discard\: This verb behaves like \accept\, except that it returns `discard'
21189from the ACL instead of `accept'. It is permitted only on ACLs that are
21190concerned with receiving messages, and it causes recipients to be discarded.
21191If the \log@_message\ modifier is set when \discard\ operates, its contents are
21192added to the line that is automatically written to the log.
21193
21194If \discard\ is used in an ACL for \\RCPT\\, just the one recipient is
21195discarded; if used for \\MAIL\\, \\DATA\\ or in the non-SMTP ACL, all the
21196message's recipients are discarded. Recipients that are discarded before
21197\\DATA\\ do not appear in the log line when the \log@_recipients\ log selector
21198is set.
21199.nextp
21200\drop\: This verb behaves like \deny\, except that an SMTP connection is
21201forcibly closed after the 5\*xx*\ error message has been sent. For example:
21202.display asis
21203drop message = I don't take more than 20 RCPTs
21204 condition = ${if > {$rcpt_count}{20}{yes}{no}}
21205.endd
21206There is no difference between \deny\ and \drop\ for the connect-time ACL. The
21207connection is always dropped after sending a 550 response.
21208.nextp
21209\require\: If all the conditions are met, control is passed to the next ACL
21210statement. If any of the conditions are not met, the ACL returns `deny'. For
21211example, when checking a \\RCPT\\ command,
21212.display asis
21213require verify = sender
21214.endd
21215passes control to subsequent statements only if the message's sender can be
21216verified. Otherwise, it rejects the command.
21217.nextp
21218.em
21219\warn\: If all the conditions are met, a header line is added to an incoming
21220message and/or a line is written to Exim's main log. In all cases, control
21221passes to the next ACL statement. The text of the added header line and the log
21222line are specified by modifiers; if they are not present, a \warn\ verb just
21223checks its conditions and obeys any `immediate' modifiers such as \set\ and
21224\logwrite\.
21225
21226If any condition on a \warn\ statement cannot be completed (that is, there is
21227some sort of defer), no header is added and the configured log line is not
21228written. No further conditions or modifiers in the \warn\ statement are
21229processed. The incident is logged, but the ACL continues to be processed, from
21230the next statement onwards.
21231
21232When testing an incoming message, the \message\ modifier can be used on a
21233\warn\ statement to add an extra header line,
21234.nem
21235as in this example:
21236.display asis
21237warn message = X-blacklisted-at: $dnslist_domain
21238 dnslists = blackholes.mail-abuse.org : \
21239 dialup.mail-abuse.org
21240.endd
21241If an identical header line is requested several times (provoked, for example,
21242by multiple \\RCPT\\ commands), only one copy is actually added to the message.
21243.em
21244If the text of the \message\ modifier is not a valid header line,
21245\"X-ACL-Warn:"\ is added to the front of it.
21246.nem
21247
21248Header lines that are added by an ACL at \\MAIL\\ or \\RCPT\\ time are not
21249visible in string expansions in the ACL for subsequent \\RCPT\\ commands.
21250However they are visible in string expansions in the ACL that is run after
21251\\DATA\\. If you want to preserve data between \\MAIL\\ and \\RCPT\\ ACLs, you
21252can use ACL variables, as described in the next section. If a message is
21253rejected after \\DATA\\, all added header lines are included in the entry that
21254is written to the reject log.
21255
21256If a \message\ modifier is present on a \warn\ verb in an ACL that is not
21257testing an incoming message, it is ignored, and the incident is logged.
21258
21259A \warn\ statement may use the \log@_message\ modifier to cause a line to be
21260written to the main log when the statement's conditions are true.
21261.em
21262Just as for \message\, if an identical log line is requested several times in
21263the same message, only one copy is actually written to the log. If you want to
21264force duplicates to be written, use the \logwrite\ modifier instead.
21265.nem
21266
21267When one of the \warn\ conditions is an address verification that fails, the
21268text of the verification failure message is in \$acl@_verify@_message$\. If you
21269want this logged, you must set it up explicitly. For example:
21270.display asis
21271warn !verify = sender
21272 log_message = sender verify failed: $acl_verify_message
21273.endd
21274.endp
21275
21276At the end of each ACL there is an implicit unconditional \deny\.
21277
21278As you can see from the examples above, the conditions and modifiers are
21279written one to a line, with the first one on the same line as the verb, and
21280subsequent ones on following lines. If you have a very long condition, you can
21281continue it onto several physical lines by the usual @\ continuation mechanism.
21282It is conventional to align the conditions vertically.
21283
21284
21285.section ACL variables
21286.rset SECTaclvariables "~~chapter.~~section"
21287.index ~~ACL||variables
21288There are some special variables that can be set during ACL processing. They
21289can be used to pass information between different ACLs, different
21290invocations of the same ACL in the same SMTP connection, and between ACLs and
21291the routers, transports, and filters that are used to deliver a message.
21292There are two sets of these variables:
21293.numberpars $.
21294The values of \$acl@_c0$\ to \$acl@_c9$\ persist throughout an SMTP connection.
21295They are never reset. Thus, a value that is set while receiving one message is
21296still available when receiving the next message on the same SMTP connection.
21297.nextp
21298The values of \$acl@_m0$\ to \$acl@_m9$\ persist only while a message is being
21299received. They are reset afterwards. They are also reset by \\MAIL\\, \\RSET\\,
21300\\EHLO\\, \\HELO\\, and after starting up a TLS session.
21301.endp
21302When a message is accepted, the current values of all the ACL variables are
21303preserved with the message and are subsequently made available at delivery
21304time.
21305
21306The ACL variables are set by modifier called \set\. For example:
21307.display asis
21308accept hosts = whatever
21309 set acl_m4 = some value
21310.endd
21311Note that the leading dollar sign is not used when naming a variable that is to
21312be set. If you want to set a variable without taking any action, you can use a
21313\warn\ verb without any other modifiers.
21314
21315
21316.section Condition and modifier processing
21317.index ~~ACL||conditions, processing
21318.index ~~ACL||modifiers, processing
21319An exclamation mark preceding a condition negates its result. For example,
21320.display asis
21321deny domains = *.dom.example
21322 !verify = recipient
21323.endd
21324causes the ACL to return `deny' if the recipient domain ends in
21325\*dom.example*\, but the recipient address cannot be verified.
21326
21327The arguments of conditions and modifiers are expanded. A forced failure
21328of an expansion causes a condition to be ignored, that is, it behaves as if the
21329condition is true. Consider these two statements:
21330.display asis
21331accept senders = ${lookup{$host_name}lsearch\
21332 {/some/file}{$value}fail}
21333accept senders = ${lookup{$host_name}lsearch\
21334 {/some/file}{$value}{}}
21335.endd
21336Each attempts to look up a list of acceptable senders. If the lookup succeeds,
21337the returned list is searched, but if the lookup fails the behaviour is
21338different in the two cases. The \fail\ in the first statement causes the
21339condition to be ignored, leaving no further conditions. The \accept\ verb
21340therefore succeeds. The second statement, however, generates an empty list when
21341the lookup fails. No sender can match an empty list, so the condition fails,
21342and therefore the \accept\ also fails.
21343
21344ACL modifiers appear mixed in with conditions in ACL statements. Some of them
21345specify actions that are taken as the conditions for a statement are checked;
21346others specify text for messages that are used when access is denied or a
21347warning is generated.
21348
21349The positioning of the modifiers in an ACL statement important, because the
21350processing of a verb ceases as soon as its outcome is known. Only those
21351modifiers that have already been encountered will take effect. For the \accept\
21352and \require\ statements, this means that processing stops as soon as a false
21353condition is met. For example, consider this use of the \message\ modifier:
21354.display asis
21355require message = Can't verify sender
21356 verify = sender
21357 message = Can't verify recipient
21358 verify = recipient
21359 message = This message cannot be used
21360.endd
21361If sender verification fails, Exim knows that the result of the statement is
21362`deny', so it goes no further. The first \message\ modifier has been seen, so
21363its text is used as the error message. If sender verification succeeds, but
21364recipient verification fails, the second message is used. If recipient
21365verification succeeds, the third message becomes `current', but is never used
21366because there are no more conditions to cause failure.
21367
21368For the \deny\ verb, on the other hand, it is always the last \message\
21369modifier that is used, because all the conditions must be true for rejection to
21370happen. Specifying more than one \message\ modifier does not make sense, and
21371the message can even be specified after all the conditions. For example:
21372.display asis
21373deny hosts = ...
21374 !senders = *@my.domain.example
21375 message = Invalid sender from client host
21376.endd
21377The `deny' result does not happen until the end of the statement is reached, by
21378which time Exim has set up the message.
21379
21380
21381.section ACL modifiers
21382.rset SECTACLmodi "~~chapter.~~section"
21383.index ~~ACL||modifiers, list of
21384The ACL modifiers are as follows:
21385
21386.startitems
21387
21388.item "control = <<text>>"
21389.index message||submission
21390This modifier may appear only in ACLs for commands relating to incoming
21391messages. It affects the subsequent processing of the message, provided that
21392the message is eventually accepted.
21393.em
21394The text must be one of the words `freeze', `queue@_only', or `submission' (in
21395the latter case, optionally followed by slash-delimited options). The first two
21396cause the message to be frozen or just queued (without immediate delivery),
21397respectively. The third tells Exim that this message is a submission from a
21398local MUA. In this case, Exim applies certain fixups to the message if
21399necessary. For example, it add a ::Date:: header line if one is not present.
21400Details are given in chapter ~~CHAPmsgproc.
21401.nem
21402
21403Once one of these controls is set, it remains set for the message. For example,
21404if \control\ is used in a \\RCPT\\ ACL, it applies to the whole message, not
21405just the individual recipient. The \control\ modifier can be used in several
21406different ways. For example:
21407.numberpars $.
21408It can be at the end of an \accept\ statement:
21409.display asis
21410accept ...some conditions...
21411 control = queue_only
21412.endd
21413In this case, the control is applied when this statement yields `accept'.
21414.nextp
21415It can be in the middle of an \accept\ statement:
21416.display asis
21417accept ...some conditions...
21418 control = queue_only
21419 ...some more conditions...
21420.endd
21421If the first set of conditions are true, the control is applied, even if the
21422statement does not accept because one of the second set of conditions is false.
21423In this case, some subsequent statement must yield `accept' for the control to
21424be relevant.
21425.nextp
21426It can be used with \warn\ to apply the control, leaving the
21427decision about accepting or denying to a subsequent verb. For
21428example:
21429.display asis
21430warn ...some conditions...
21431 control = freeze
21432accept ...
21433.endd
21434.em
21435This example of \warn\ does not contain \message\, \log@_message\, or
21436\logwrite\, so it does not add anything to the message and does not write a log
21437entry.
21438.nem
21439.endp
21440
21441.item "delay = <<time>>"
21442.index \-bh-\ option
21443This modifier causes Exim to wait for the time interval before proceeding. The
21444time is given in the usual Exim notation. This modifier may appear in any ACL.
21445The delay happens as soon as the modifier is processed.
21446.em
21447However, when testing Exim using the \-bh-\ option, the delay is not actually
21448imposed (an appropriate message is output).
21449.nem
21450
21451Like \control\, \delay\ can be used with \accept\ or
21452\deny\, for example:
21453.display asis
21454deny ...some conditions...
21455 delay = 30s
21456.endd
21457The delay happens if all the conditions are true, before the statement returns
21458`deny'. Compare this with:
21459.display asis
21460deny delay = 30s
21461 ...some conditions...
21462.endd
21463which waits for 30s before processing the conditions. The \delay\ modifier can
21464also be used with \warn\ and together with \control\:
21465.display
21466warn ...some conditions...
21467 delay = 2m
21468 control = freeze
21469accept ...
21470.endd
21471
21472.item endpass
21473This modifier, which has no argument, is recognized only in \accept\
21474statements. It marks the boundary between the conditions whose failure causes
21475control to pass to the next statement, and the conditions whose failure causes
21476the ACL to return `deny'. See the description of \accept\ above.
21477
21478.item "log@_message = <<text>>"
21479This modifier sets up a message that is used as part of the log message if the
21480ACL denies access
21481.em
21482or a \warn\ statement's conditions are true.
21483.nem
21484For example:
21485.display asis
21486require log_message = wrong cipher suite $tls_cipher
21487 encrypted = DES-CBC3-SHA
21488.endd
21489\log@_message\ adds to any underlying error message that may exist because of
21490the condition failure. For example, while verifying a recipient address, a
21491:::fail:: redirection might have already set up a message. Although the message
21492is usually defined before the conditions to which it applies, the expansion
21493does not happen until Exim decides that access is to be denied. This means that
21494any variables that are set by the condition are available for inclusion in the
21495message. For example, the \$dnslist@_<<xxx>>$\ variables are set after a DNS
21496black list lookup succeeds. If the expansion of \log@_message\ fails, or if the
21497result is an empty string, the modifier is ignored.
21498
21499If you want to use a \warn\ statement to log the result of an address
21500verification, you can use \$acl__verify__message$\ to include the verification
21501error message.
21502
21503.em
21504If \log@_message\ is used with a \warn\ statement, `Warning:' is added to the
21505start of the logged message. If the same warning log message is requested more
21506than once while receiving a single email message, only one copy is actually
21507logged. If you want to log multiple copies, use \logwrite\ instead of
21508\log@_message\. In the absence of \log@_message\ and \logwrite\, nothing is
21509logged for a succesful \warn\ statement.
21510.nem
21511
21512If \log@_message\ is not present and there is no underlying error message (for
21513example, from the failure of address verification), but \message\ is present,
21514the \message\ text is used for logging rejections. However, if any text for
21515logging contains newlines, only the first line is logged. In the absence of
21516both \log@_message\ and \message\, a default built-in message is used for
21517logging rejections.
21518
21519.item "logwrite = <<text>>"
21520.index log||in ACL, immediate
21521This modifier writes a message to a log file as soon as it is encountered when
21522processing an ACL. (Compare \log@_message\, which,
21523.em
21524except in the case of \warn\,
21525.nem
21526is used only if the ACL statement denies access.) The \logwrite\ modifier can
21527be used to log special incidents in ACLs. For example:
21528.display
21529accept <<some special conditions>>
21530 control = freeze
21531 logwrite = froze message because ...
21532.endd
21533By default, the message is written to the main log. However, it may begin
21534with a colon, followed by a comma-separated list of log names, and then
21535another colon, to specify exactly which logs are to be written. For
21536example:
21537.display asis
21538logwrite = :main,reject: text for main and reject logs
21539logwrite = :panic: text for panic log only
21540.endd
21541
21542.item "message = <<text>>"
21543This modifier sets up a text string that is expanded and used as an error
21544message if the current statement causes the ACL to deny access. The expansion
21545happens at the time Exim decides that access is to be denied, not at the time
21546it processes \message\. If the expansion fails, or generates an empty string,
21547the modifier is ignored. For ACLs that are triggered by SMTP commands, the
21548message is returned as part of the SMTP error response.
21549
21550The \message\ modifier is also used with the \warn\ verb to specify one or more
21551header lines to be added to an incoming message when all the conditions are
21552true.
21553If \message\ is used with \warn\ in an ACL that is not concerned with receiving
21554a message, it has no effect.
21555
21556The text is literal; any quotes are taken as literals, but because the string
21557is expanded, backslash escapes are processed anyway. If the message contains
21558newlines, this gives rise to a multi-line SMTP response. Like \log@_message\,
21559the contents of \message\ are not expanded until after a condition has failed.
21560
21561If \message\ is used on a statement that verifies an address, the message
21562specified overrides any message that is generated by the verification process.
21563However, the original message is available in the variable
21564\$acl@_verify@_message$\, so you can incorporate it into your message if you
21565wish. In particular, if you want the text from \:fail:\ items in \%redirect%\
21566routers to be passed back as part of the SMTP response, you should either not
21567use a \message\ modifier, or make use of \$acl@_verify@_message$\.
21568
21569.item "set <<acl@_name>> = <<value>>"
21570This modifier puts a value into one of the ACL variables (see section
21571~~SECTaclvariables).
21572
21573.enditems
21574
21575
21576
21577
21578.section ACL conditions
21579.rset SECTaclconditions "~~chapter.~~section"
21580.index ~~ACL||conditions, list of
21581Not all conditions are relevant in all circumstances. For example, testing
21582senders and recipients does not make sense in an ACL that is being run as the
21583result of the arrival of an \\ETRN\\ command, and checks on message headers can
21584be done only in the ACLs specified by \acl@_smtp@_data\
21585and \acl__not__smtp\.
21586You can use the same condition (obviously with different parameters) more than
21587once in the same ACL statement. This provides a way of specifying an `and'
21588conjunction.
21589The conditions are as follows:
21590
21591.startitems
21592
21593.item "acl = <<name of acl or ACL string or file name >>"
21594.index ~~ACL||nested
21595.index ~~ACL||indirect
21596The possible values of the argument are the same as for the
21597\acl@_smtp@_$it{xxx}\ options. The named or inline ACL is run. If it returns
21598`accept' the condition is true; if it returns `deny' the condition is false; if
21599it returns `defer', the current ACL returns `defer'.
21600If it returns `drop' and the outer condition denies access, the connection is
21601dropped. If it returns `discard', the verb must be \accept\ or \discard\, and
21602the action is taken immediately -- no further conditions are tested.
21603
21604ACLs may be nested up to 20 deep; the limit exists purely to catch runaway
21605loops. This condition allows you to use different ACLs in different
21606circumstances. For example, different ACLs can be used to handle \\RCPT\\
21607commands for different local users or different local domains.
21608
21609.item "authenticated = <<string list>>"
21610.index authentication||ACL checking
21611.index ~~ACL||testing for authentication
21612If the SMTP connection is not authenticated, the condition is false. Otherwise,
21613the name of the authenticator is tested against the list. To test for
21614authentication by any authenticator, you can set
21615.display asis
21616authenticated = *
21617.endd
21618
21619.item "condition = <<string>>"
21620.index customizing||ACL condition
21621.index ~~ACL||customized test
21622This feature allows you to make up custom conditions. If the result of
21623expanding the string is an empty string, the number zero, or one of the strings
21624`no' or `false', the condition is false. If the result is any non-zero number,
21625or one of the strings `yes' or `true', the condition is true. For any other
21626values, some error is assumed to have occured, and the ACL returns `defer'.
21627
21628.item "dnslists = <<list of domain names and other data>>"
21629.index DNS list||in ACL
21630.index black list (DNS)
21631.index ~~ACL||testing a DNS list
21632This condition checks for entries in DNS black lists. These are also known as
21633`RBL lists', after the original Realtime Blackhole List, but note that the use
21634of the lists at \*mail-abuse.org*\ now carries a charge.
21635There are too many different variants of this condition to describe briefly
21636here. See sections ~~SECTmorednslists--~~SECTmorednslistslast for details.
21637
21638.item "domains = <<domain list>>"
21639.index domain||ACL checking
21640.index ~~ACL||testing a recipient domain
21641This condition is relevant only after a \\RCPT\\ command. It checks that the
21642domain of the recipient address is in the domain list. If percent-hack
21643processing is enabled, it is done before this test is done. If the check
21644succeeds with a lookup, the result of the lookup is placed in \$domain@_data$\
21645until the next \domains\ test.
21646
21647.item "encrypted = <<string list>>"
21648.index encryption||checking in an ACL
21649.index ~~ACL||testing for encryption
21650If the SMTP connection is not encrypted, the condition is false. Otherwise, the
21651name of the cipher suite in use is tested against the list. To test for
21652encryption without testing for any specific cipher suite(s), set
21653.display asis
21654encrypted = *
21655.endd
21656
21657.item "hosts = << host list>>"
21658.index host||ACL checking
21659.index ~~ACL||testing the client host
21660This condition tests that the calling host matches the host list. If you have
21661name lookups or wildcarded host names and IP addresses in the same host list,
21662you should normally put the IP addresses first. For example, you could have:
21663.display asis
21664accept hosts = 10.9.8.7 : dbm;/etc/friendly/hosts
21665.endd
21666The reason for this lies in the left-to-right way that Exim processes lists.
21667It can test IP addresses without doing any DNS lookups, but when it reaches an
21668item that requires a host name, it fails if it cannot find a host name to
21669compare with the pattern. If the above list is given in the opposite order, the
21670\accept\ statement fails for a host whose name cannot be found, even if its
21671IP address is 10.9.8.7.
21672
21673If you really do want to do the name check first, and still recognize the IP
21674address even if the name lookup fails, you can rewrite the ACL like this:
21675.display asis
21676accept hosts = dbm;/etc/friendly/hosts
21677accept hosts = 10.9.8.7
21678.endd
21679The default action on failing to find the host name is to assume that the host
21680is not in the list, so the first \accept\ statement fails. The second statement
21681can then check the IP address.
21682
21683If a \hosts\ condition is satisfied by means of a lookup, the result
21684of the lookup is made available in the \$host@_data$\ variable. This
21685allows you, for example, to set up a statement like this:
21686.display asis
21687deny hosts = net-lsearch;/some/file
21688 message = $host_data
21689.endd
21690which gives a custom error message for each denied host.
21691
21692.item "local@_parts = <<local part list>>"
21693.index local part||ACL checking
21694.index ~~ACL||testing a local part
21695This condition is relevant only after a \\RCPT\\ command. It checks that the
21696local part of the recipient address is in the list. If percent-hack processing
21697is enabled, it is done before this test. If the check succeeds with a lookup,
21698the result of the lookup is placed in \$local@_part@_data$\ until the next
21699\local@_parts\ test.
21700
21701.item "recipients = <<address list>>"
21702.index recipient||ACL checking
21703.index ~~ACL||testing a recipient
21704This condition is relevant only after a \\RCPT\\ command. It checks the entire
21705recipient address against a list of recipients.
21706
21707.item "sender@_domains = <<domain list>>"
21708.index sender||ACL checking
21709.index ~~ACL||testing a sender domain
21710This condition tests the domain of the sender of the message against the given
21711domain list.
21712\**Note**\: the domain of the sender address is in
21713\$sender@_address@_domain$\. It is \*not*\ put in \$domain$\ during the testing
21714of this condition. This is an exception to the general rule for testing
21715domain lists. It is done this way so that, if this condition is used in an
21716ACL for a \\RCPT\\ command, the recipient's domain (which is in \$domain$\) can
21717be used to influence the sender checking.
21718
21719.item "senders = <<address list>>"
21720.index sender||ACL checking
21721.index ~~ACL||testing a sender
21722This condition tests the sender of the message against the given list. To test
21723for a bounce message, which has an empty sender, set
21724.display asis
21725senders = :
21726.endd
21727
21728.item "verify = certificate"
21729.index TLS||client certificate verification
21730.index certificate||verification of client
21731.index ~~ACL||certificate verification
21732This condition is true in an SMTP session if the session is encrypted, and a
21733certificate was received from the client, and the certificate was verified. The
21734server requests a certificate only if the client matches \tls@_verify@_hosts\
21735or \tls@_try@_verify@_hosts\ (see chapter ~~CHAPTLS).
21736
21737.item "verify = header@_sender/<<options>>"
21738.index ~~ACL||verifying sender in the header
21739.index header lines||verifying the sender in
21740.index sender||verifying in header
21741.index verifying||sender in header
21742This condition is relevant only in an ACL that is run after a message has been
21743received, that is, in an ACL specified by \acl@_smtp@_data\. It checks that
21744there is a verifiable sender address in at least one of the ::Sender::,
21745::Reply-To::, or ::From:: header lines. Details of address verification and the
21746options are given later, starting at section ~~SECTaddressverification. You can
21747combine this condition with the \senders\ condition to restrict it to bounce
21748messages only:
21749.display asis
21750deny senders = :
21751 message = A valid sender header is required for bounces
21752 !verify = header_sender
21753.endd
21754
21755.item "verify = header@_syntax"
21756.index ~~ACL||verifying header syntax
21757.index header lines||verifying syntax
21758.index verifying||header syntax
21759This condition is relevant only in an ACL that is run after a message has been
21760received, that is, in an ACL specified by \acl@_smtp@_data\
21761or \acl@_not@_smtp\.
21762It checks the syntax of all header lines that can contain lists of addresses
21763(::Sender::, ::From::, ::Reply-To::, ::To::, ::Cc::, and ::Bcc::).
21764Unqualified addresses (local parts without domains) are permitted only in
21765locally generated messages and from hosts that match
21766\sender@_unqualified@_hosts\ or \recipient@_unqualified@_hosts\, as
21767appropriate.
21768
21769Note that this condition is a syntax check only. However, a common spamming
21770ploy is to send syntactically invalid headers such as
21771.display asis
21772To: @
21773.endd
21774and this condition can be used to reject such messages.
21775
21776.item "verify = helo"
21777.index ~~ACL||verifying HELO/EHLO
21778.index \\HELO\\||verifying
21779.index \\EHLO\\||verifying
21780.index verifying||\\EHLO\\
21781.index verifying||\\HELO\\
21782This condition is true if a \\HELO\\ or \\EHLO\\ command has been received from
21783the client host, and its contents have been verified. Verification of these
21784commands does not happen by default. See the description of the
21785\helo@_verify@_hosts\ and \helo@_try@_verify@_hosts\ options for details of how
21786to request it.
21787
21788.item "verify = recipient/<<options>>"
21789.index ~~ACL||verifying recipient
21790.index recipient||verifying
21791.index verifying||recipient
21792This condition is relevant only after a \\RCPT\\ command. It verifies the
21793current recipient. Details of address verification are given later, starting at
21794section ~~SECTaddressverification. After a recipient has been verified, the
21795value of \$address@_data$\ is the last value that was set while routing the
21796address. This applies even if the verification fails. When an address that is
21797being verified is redirected to a single address, verification continues with
21798the new address, and in that case, the subsequent value of \$address@_data$\ is
21799the value for the child address.
21800
21801
21802.item "verify = reverse@_host@_lookup"
21803.index ~~ACL||verifying host reverse lookup
21804.index host||verifying reverse lookup
21805This condition ensures that a verified host name has been looked up from the IP
21806address of the client host. (This may have happened already if the host name
21807was needed for checking a host list, or if the host matched \host@_lookup\.)
21808Verification ensures that the host name obtained from a reverse DNS lookup, or
21809one of its aliases, does, when it is itself looked up in the DNS, yield the
21810original IP address.
21811
21812If this condition is used for a locally generated message (that is, when there
21813is no client host involved), it always succeeds.
21814
21815
21816.item "verify = sender/<<options>>"
21817.index ~~ACL||verifying sender
21818.index sender||verifying
21819.index verifying||sender
21820This condition is relevant only after a
21821\\MAIL\\ or \\RCPT\\ command, or after a message has been received (the
21822\acl@_smtp@_data\ or \acl@_not@_smtp\ ACLs).
21823If the message's sender is empty (that is, this is a bounce message), the
21824condition is true. Otherwise, the sender address is verified. Details of
21825verification are given later, starting at section ~~SECTaddressverification.
21826Exim caches the result of sender verification, to avoid doing it more than once
21827per message.
21828
21829.item "verify = sender=address/<<options>>"
21830This is a variation of the previous option, in which a modified address is
21831verified as a sender.
21832
21833.enditems
21834
21835
21836
21837.section Using DNS lists
21838.rset SECTmorednslists "~~chapter.~~section"
21839.index DNS list||in ACL
21840.index black list (DNS)
21841.index ~~ACL||testing a DNS list
21842In its simplest form, the \dnslists\ condition tests whether the calling host
21843is on a DNS list by looking up the inverted IP address in one or more DNS
21844domains. For example, if the calling host's IP address is 192.168.62.43, and
21845the ACL statement is
21846.display asis
21847deny dnslists = blackholes.mail-abuse.org : \
21848 dialups.mail-abuse.org
21849.endd
21850the following domains are looked up:
21851.display asis
2185243.62.168.192.blackholes.mail-abuse.org
2185343.62.168.192.dialups.mail-abuse.org
21854.endd
21855If a DNS lookup times out or otherwise fails to give a decisive answer, Exim
21856behaves as if the host is not on the relevant list. This is usually the
21857required action when \dnslists\ is used with \deny\ (which is the most common
21858usage), because it prevents a DNS failure from blocking mail. However, you can
21859change this behaviour by putting one of the following special items in the
21860list:
21861.index \"+include@_unknown"\
21862.index \"+exclude@_unknown"\
21863.index \"+defer@_unknown"\
21864.display
21865+include@_unknown $rm{behave as if the item is on the list}
21866+exclude@_unknown $rm{behave as if the item is not on the list (default)}
21867+defer@_unknown $rm{give a temporary error}
21868.endd
21869Each of these applies to any subsequent items on the list. For example:
21870.display asis
21871deny dnslists = +defer_unknown : foo.bar.example
21872.endd
21873
21874Testing the list of domains stops as soon as a match is found. If you want to
21875warn for one list and block for another, you can use two different statements:
21876.display asis
21877deny dnslists = blackholes.mail-abuse.org
21878warn message = X-Warn: sending host is on dialups list
21879 dnslists = dialups.mail-abuse.org
21880.endd
21881
21882DNS list lookups are cached by Exim for the duration of the SMTP session,
21883so a lookup based on the IP address is done at most once for any incoming
21884connection. Exim does not share information between multiple incoming
21885connections (but your local name server cache should be active).
21886
21887
21888.section DNS lists keyed on domain names
21889There are some lists that are keyed on domain names rather than inverted IP
21890addresses (see for example the \*domain based zones*\ link at
21891\?http://www.rfc-ignorant.org/?\).
21892.em
21893No reversing of components is used with these lists.
21894.nem
21895You can change the name that is looked up in a DNS list by adding additional
21896data to a \dnslists\ item, introduced by a slash. For example,
21897.display asis
21898deny message = Sender's domain is listed at $dnslist_domain
21899 dnslists = dsn.rfc-ignorant.org/$sender_address_domain
21900.endd
21901This particular example is useful only in ACLs that are obeyed after the
21902\\RCPT\\ or \\DATA\\ commands, when a sender address is available. If (for
21903example) the message's sender is \*user@@tld.example*\ the name that is looked
21904up by this example is
21905.display asis
21906tld.example.dsn.rfc-ignorant.org
21907.endd
21908You can mix entries with and without additional data in the same \dnslists\
21909condition.
21910
21911.section Data returned by DNS lists
21912DNS lists are constructed using address records in the DNS. The original RBL
21913just used the address 127.0.0.1 on the right hand side of each record, but the
21914RBL+ list and some other lists use a number of values with different meanings.
21915The values used on the RBL+ list are:
21916.display rm
21917.tabs 12
21918127.1.0.1 $t RBL
21919127.1.0.2 $t DUL
21920127.1.0.3 $t DUL and RBL
21921127.1.0.4 $t RSS
21922127.1.0.5 $t RSS and RBL
21923127.1.0.6 $t RSS and DUL
21924127.1.0.7 $t RSS and DUL and RBL
21925.endd
21926Some DNS lists may return more than one address record.
21927
21928.section Variables set from DNS lists
21929When an entry is found in a DNS list, the variable \$dnslist@_domain$\
21930contains the name of the domain that matched, \$dnslist@_value$\ contains the
21931data from the entry, and \$dnslist@_text$\ contains the contents of any
21932associated TXT record. If more than one address record is returned by the DNS
21933lookup, all the IP addresses are included in \$dnslist@_value$\, separated by
21934commas and spaces.
21935
21936You can use these variables in \message\ or \log@_message\ modifiers --
21937although these appear before the condition in the ACL, they are not expanded
21938until after it has failed. For example:
21939.display asis
21940deny hosts = !+local_networks
21941 message = $sender_host_address is listed \
21942 at $dnslist_domain
21943 dnslists = rbl-plus.mail-abuse.example
21944.endd
21945
21946
21947.section Additional matching conditions for DNS lists
21948If you add an equals sign and an IP address after a \dnslists\ domain name, you
21949can restrict its action to DNS records with a matching right hand side. For
21950example,
21951.display asis
21952deny dnslists = rblplus.mail-abuse.org=127.0.0.2
21953.endd
21954rejects only those hosts that yield 127.0.0.2. Without this additional data,
21955any address record is considered to be a match. If more than one address record
21956is found on the list, they are all checked for a matching right-hand side.
21957
21958If you want to specify a constraining address and also change the name that is
21959looked up, the address list must be specified first. For example:
21960.display asis
21961deny dnslists = dsn.rfc-ignorant.org\
21962 =127.0.0.2/$sender_address_domain
21963.endd
21964
21965More than one IP address may be given for checking, using a comma as a
21966separator. These are alternatives -- if any one of them matches, the \dnslists\
21967condition is true. For example:
21968.display asis
21969deny dnslists = a.b.c=127.0.0.2,127.0.0.3
21970.endd
21971
21972If the character `&' is used instead of `=', the comparison for each listed
21973IP address is done by a bitwise `and' instead of by an equality test. In
21974other words, the listed addresses are used as bit masks. The comparison is
21975true if all the bits in the mask are present in the address that is being
21976tested. For example:
21977.display asis
21978dnslists = a.b.c&0.0.0.3
21979.endd
21980matches if the address is \*x.x.x.*\3, \*x.x.x.*\7, \*x.x.x.*\11, etc. If you
21981want to test whether one bit or another bit is present (as opposed to both
21982being present), you must use multiple values. For example:
21983.display asis
21984dnslists = a.b.c&0.0.0.1,0.0.0.2
21985.endd
21986matches if the final component of the address is an odd number or two times
21987an odd number.
21988
21989
21990.section Negated DNS matching conditions
21991You can supply a negative list of IP addresses as part of a \dnslists\
21992condition. Whereas
21993.display asis
21994deny dnslists = a.b.c=127.0.0.2,127.0.0.3
21995.endd
21996means `deny if the host is in the black list at the domain \*a.b.c*\ and the IP
21997address yielded by the list is either 127.0.0.2 or 127.0.0.3',
21998.display asis
21999deny dnslists = a.b.c!=127.0.0.2,127.0.0.3
22000.endd
22001means `deny if the host is in the black list at the domain \*a.b.c*\ and the IP
22002address yielded by the list is not 127.0.0.2 and not 127.0.0.3'. In other
22003words, the result of the test is inverted if an exclamation mark appears before
22004the `=' (or the `&') sign.
22005
22006\**Note**\: this kind of negation is not the same as negation in a domain,
22007host, or address list (which is why the syntax is different).
22008
22009If you are using just one list, the negation syntax does not gain you much. The
22010previous example is precisely equivalent to
22011.display asis
22012deny dnslists = a.b.c
22013 !dnslists = a.b.c=127.0.0.2,127.0.0.3
22014.endd
22015However, if you are using multiple lists, the negation syntax is clearer.
22016Consider this example:
22017.display asis
22018deny dnslists = sbl.spamhaus.org : \
22019 list.dsbl.org : \
22020 dnsbl.njabl.org!=127.0.0.3 : \
22021 relays.ordb.org
22022.endd
22023Using only positive lists, this would have to be:
22024.display asis
22025deny dnslists = sbl.spamhaus.org : \
22026 list.dsbl.org
22027deny dnslists = dnsbl.njabl.org
22028 !dnslists = dnsbl.njabl.org=127.0.0.3
22029deny dnslists = relays.ordb.org
22030.endd
22031which is less clear, and harder to maintain.
22032
22033
22034
22035.section DNS lists and IPv6
22036.rset SECTmorednslistslast "~~chapter.~~section"
22037If Exim is asked to do a dnslist lookup for an IPv6 address, it inverts it
22038nibble by nibble. For example, if the calling host's IP address is
220393ffe:ffff:836f:0a00:000a:0800:200a:c031, Exim might look up
22040.display asis
220411.3.0.c.a.0.0.2.0.0.8.0.a.0.0.0.0.0.a.0.f.6.3.8.
22042 f.f.f.f.e.f.f.3.blackholes.mail-abuse.org
22043.endd
22044(split over two lines here to fit on the page). Unfortunately, some of the DNS
22045lists contain wildcard records, intended for IPv4, that interact badly with
22046IPv6. For example, the DNS entry
22047.display asis
22048*.3.some.list.example. A 127.0.0.1
22049.endd
22050is probably intended to put the entire 3.0.0.0/8 IPv4 network on the list.
22051Unfortunately, it also matches the entire 3@:@:/124 IPv6 network.
22052
22053You can exclude IPv6 addresses from DNS lookups by making use of a suitable
22054\condition\ condition, as in this example:
22055.display asis
22056deny condition = ${if isip4{$sender_host_address}{yes}{no}}
22057 dnslists = some.list.example
22058.endd
22059
22060
22061.section Address verification
22062.rset SECTaddressverification "~~chapter.~~section"
22063.index verifying||address, options for
22064.index policy control||address verification
22065Several of the \verify\ conditions described in section ~~SECTaclconditions
22066cause addresses to be verified. These conditions can be followed by options
22067that modify the verification process. The options are separated from the
22068keyword and from each other by slashes, and some of them contain parameters.
22069For example:
22070.display asis
22071verify = sender/callout
22072verify = recipient/defer_ok/callout=10s,defer_ok
22073.endd
22074The first stage of verification is to run the address through the routers, in
22075`verify mode'. Routers can detect the difference between verification and
22076routing for delivery, and their actions can be varied by a number of generic
22077options such as \verify\ and \verify@_only\ (see chapter ~~CHAProutergeneric).
22078
22079If there is a defer error while doing this verification routing, the ACL
22080normally returns `defer'. However, if you include \defer@_ok\ in the options,
22081the condition is forced to be true instead.
22082
22083.section Callout verification
22084.rset SECTcallver "~~chapter.~~section"
22085.index verifying||address, by callout
22086.index callout||verification
22087.index SMTP||callout verification
22088For non-local addresses, routing verifies the domain, but is unable to do any
22089checking of the local part. There are situations where some means of verifying
22090the local part is desirable. One way this can be done is to make an SMTP
22091\*callback*\ to the sending host (for a sender address) or a \*callforward*\ to
22092a subsequent host (for a recipient address), to see if the host accepts the
22093address. We use the term \*callout*\ to cover both cases. This facility should
22094be used with care, because it can add a lot of resource usage to the cost of
22095verifying an address. However, Exim does cache the results of callouts, which
22096helps to reduce the cost. Details of caching are in the next section.
22097
22098.em
22099Recipient callouts are usually used only between hosts that are controlled by
22100the same administration. For example, a corporate gateway host could use
22101callouts to check for valid recipients on an internal mailserver.
22102.nem
22103A successful callout does not guarantee that a real delivery to the address
22104would succeed; on the other hand, a failing callout does guarantee that
22105a delivery would fail.
22106
22107If the \callout\ option is present on a condition that verifies an address, a
22108second stage of verification occurs if the address is successfully routed to
22109one or more remote hosts. The usual case is routing by a \%dnslookup%\ or a
22110\%manualroute%\ router, where the router specifies the hosts. However, if a
22111router that does not set up hosts routes to an \%smtp%\ transport with a
22112\hosts\ setting, the transport's hosts are used. If an \%smtp%\ transport has
22113\hosts@_override\ set, its hosts are always used, whether or not the router
22114supplies a host list.
22115
22116The port that is used is taken from the transport, if it is specified and is a
22117remote transport. (For routers that do verification only, no transport need be
22118specified.) Otherwise, the default SMTP port is used. If a remote transport
22119specifies an outgoing interface, this is used; otherwise the interface is not
22120specified.
22121
22122For a sender callout check, Exim makes SMTP connections to the remote hosts, to
22123test whether a bounce message could be delivered to the sender address. The
22124following SMTP commands are sent:
22125.display
22126HELO <<primary host name>>
22127MAIL FROM:@<@>
22128RCPT TO:<<the address to be tested>>
22129QUIT
22130.endd
22131\\LHLO\\ is used instead of \\HELO\\ if the transport's \protocol\ option is
22132set to `lmtp'.
22133
22134.em
22135A recipient callout check is similar. By default, it also uses an empty address
22136for the sender. This default is chosen because most hosts do not make use of
22137the sender address when verifying a recipient. Using the same address means
22138that a single cache entry can be used for each recipient. Some sites, however,
22139do make use of the sender address when verifying. These are catered for by the
22140\use@_sender\ and \use@_postmaster\ options, described in the next section.
22141.nem
22142
22143If the response to the \\RCPT\\ command is a 2$it{xx} code, the verification
22144succeeds. If it is 5$it{xx}, the verification fails. For any other condition,
22145Exim tries the next host, if any. If there is a problem with all the remote
22146hosts, the ACL yields `defer', unless the \defer@_ok\ parameter of the
22147\callout\ option is given, in which case the condition is forced to succeed.
22148
22149
22150.section Additional parameters for callouts
22151.rset CALLaddparcall "~~chapter.~~section"
22152.index callout||timeout, specifying
22153The \callout\ option can be followed by an equals sign and a number of optional
22154parameters, separated by commas. For example:
22155.display asis
22156verify = recipient/callout=10s,defer_ok
22157.endd
22158The old syntax, which had \callout@_defer@_ok\ and \check@_postmaster\ as
22159separate verify options, is retained for backwards compatibility, but is now
22160deprecated. The additional parameters for \callout\ are as follows:
22161
22162.numberpars $.
22163<<a time>>: This specifies the timeout that applies for the callout attempt to
22164each host. For example:
22165.display asis
22166verify = sender/callout=5s
22167.endd
22168The default is 30 seconds. The timeout is used for each response from the
22169remote host.
22170.nextp
22171.index callout||defer, action on
22172\defer@_ok\: Failure to contact any host, or any other kind of temporary error
22173is treated as success by the ACL. However, the cache is not updated in this
22174circumstance.
22175.nextp
22176.index callout||cache, suppressing
22177.index caching||callout, suppressing
22178\no@_cache\: The callout cache is neither read nor updated.
22179.nextp
22180.index callout||postmaster, checking
22181\postmaster\: A successful callout check is followed by a similar check for the
22182local part \*postmaster*\ at the same domain. If this address is rejected, the
22183callout fails. The result of the postmaster check is recorded in a cache
22184record; if it is a failure, this is used to fail subsequent callouts for the
22185domain without a connection being made, until the cache record expires.
22186.nextp
22187.index callout||`random' check
22188\random\: Before doing the normal callout check, Exim does a
22189check for a `random' local part at the same domain. The local part is not
22190really random -- it is defined by the expansion of the option
22191\callout@_random@_local@_part\, which defaults to
22192.display asis
22193$primary_host_name-$tod_epoch-testing
22194.endd
22195The idea here is to try to determine whether the remote host accepts all local
22196parts without checking. If it does, there is no point in doing callouts for
22197specific local parts. If the `random' check succeeds, the result is saved in
22198a cache record, and used to force the current and subsequent callout checks to
22199succeed without a connection being made, until the cache record expires.
22200.nextp
22201.index callout||sender for recipient check
22202.em
22203\use@_postmaster\: This option applies to recipient callouts only. For example:
22204.display asis
22205deny !verify = recipient/callout=use_postmaster
22206.endd
22207It causes a non-empty postmaster address to be used in the \\MAIL\\ command
22208when performing the callout. The local part of the address is \"postmaster"\
22209and the domain is the contents of \$qualify@_domain$\.
22210.nextp
22211\use@_sender\: This option applies to recipient callouts only. For example:
22212.display asis
22213require verify = recipient/callout=use_sender
22214.endd
22215It causes the message's actual sender address to be used in the \\MAIL\\
22216command when performing the callout, instead of an empty address. The cache for
22217such callouts is keyed by the sender/recipient combination; thus, for any given
22218recipient, many more actual callouts are performed than when an empty sender or
22219postmaster is used. This option should be set only when you know that the
22220called hosts make use of the sender when checking recipients.
22221.nem
22222.endp
22223
22224
22225.section Callout caching
22226.rset SECTcallvercache "~~chapter.~~section"
22227.index hints database||callout cache
22228.index callout||caching
22229.index caching||callout
22230Exim caches the results of callouts in order to reduce the amount of resources
22231used, unless you specify the \no@_cache\ parameter with the \callout\ option.
22232A hints database called `callout' is used for the cache. Two different record
22233types are used: one records the result of a callout check for a specific
22234address, and the other records information that applies to the entire domain
22235(for example, that it accepts the local part \*postmaster*\).
22236
22237When an original callout fails, a detailed SMTP error message is given about
22238the failure. However, for subsequent failures use the cache data, this message
22239is not available.
22240
22241The expiry times for negative and positive address cache records are
22242independent, and can be set by the global options \callout@_negative@_expire\
22243(default 2h) and \callout@_positive@_expire\ (default 24h), respectively.
22244
22245If a host gives a negative response to an SMTP connection, or rejects any
22246commands up to and including
22247.display asis
22248MAIL FROM:<>
22249.endd
22250.em
22251(but not including the \\MAIL\\ command with a non-empty address),
22252.nem
22253any callout attempt is bound to fail. Exim remembers such failures in a
22254domain cache record, which it uses to fail callouts for the domain without
22255making new connections, until the domain record times out. There are two
22256separate expiry times for domain cache records:
22257\callout@_domain@_negative@_expire\ (default 3h) and
22258\callout__domain__positive@_expire\ (default 7d).
22259
22260Domain records expire when the negative expiry time is reached if callouts
22261cannot be made for the domain, or if the postmaster check failed.
22262Otherwise, they expire when the positive expiry time is reached. This
22263ensures that, for example, a host that stops accepting `random' local parts
22264will eventually be noticed.
22265
22266The callout caching mechanism is based entirely on the domain of the
22267address that is being tested. If the domain routes to several hosts, it is
22268assumed that their behaviour will be the same.
22269
22270
22271.section Sender address verification reporting
22272.index verifying||suppressing error details
22273When sender verification fails in an ACL, the details of the failure are
22274given as additional output lines before the 550 response to the relevant
22275SMTP command (\\RCPT\\ or \\DATA\\). For example, if sender callout is in use,
22276you might see:
22277.display asis
22278MAIL FROM:<xyz@abc.example>
22279250 OK
22280RCPT TO:<pqr@def.example>
22281550-Verification failed for <xyz@abc.example>
22282550-Called: 192.168.34.43
22283550-Sent: RCPT TO:<xyz@abc.example>
22284550-Response: 550 Unknown local part xyz in <xyz@abc.example>
22285550 Sender verification failed
22286.endd
22287If more than one \\RCPT\\ command fails in the same way, the details are given
22288only for the first of them. However, some administrators do not want to send
22289out this much information. You can suppress the details by adding
22290`/no@_details' to the ACL statement that requests sender verification. For
22291example:
22292.display asis
22293verify = sender/no_details
22294.endd
22295
22296
22297.section Redirection while verifying
22298.index verifying||redirection while
22299.index address redirection||while verifying
22300A dilemma arises when a local address is redirected by aliasing or forwarding
22301during verification: should the generated addresses themselves be verified,
22302or should the successful expansion of the original address be enough to verify
22303it? Exim takes the following pragmatic approach:
22304.numberpars $.
22305When an incoming address is redirected to just one child address, verification
22306continues with the child address, and if that fails to verify, the original
22307verification also fails.
22308.nextp
22309When an incoming address is redirected to more than one child address,
22310verification does not continue. A success result is returned.
22311.endp
22312This seems the most reasonable behaviour for the common use of aliasing as a
22313way of redirecting different local parts to the same mailbox. It means, for
22314example, that a pair of alias entries of the form
22315.display asis
22316A.Wol: aw123
22317aw123: :fail: Gone away, no forwarding address
22318.endd
22319work as expected, with both local parts causing verification failure. When a
22320redirection generates more than one address, the behaviour is more like a
22321mailing list, where the existence of the alias itself is sufficient for
22322verification to succeed.
22323
22324
22325.section Using an ACL to control relaying
22326.rset SECTrelaycontrol "~~chapter.~~section"
22327.index ~~ACL||relay control
22328.index relaying||control by ACL
22329.index policy control||relay control
22330An MTA is said to \*relay*\ a message if it receives it from some host and
22331delivers it directly to another host as a result of a remote address contained
22332within it. Redirecting a local address via an alias or forward file and then
22333passing the message on to another host is not relaying,
22334.index `percent hack'
22335but a redirection as a result of the `percent hack' is.
22336
22337Two kinds of relaying exist, which are termed `incoming' and `outgoing'. A host
22338which is acting as a gateway or an MX backup is concerned with incoming
22339relaying from arbitrary hosts to a specific set of domains. On the other hand,
22340a host which is acting as a smart host for a number of clients is concerned
22341with outgoing relaying from those clients to the Internet at large. Often the
22342same host is fulfilling both functions, as illustrated in the diagram below,
22343but in principle these two kinds of relaying are entirely independent. What is
22344not wanted is the transmission of mail from arbitrary remote hosts through your
22345system to arbitrary domains.
22346.if ~~sys.fancy
22347.figure "Controlled relaying" rm
22348.indent 0
22349.call aspic
22350centre ~~sys.linelength;
22351magnify 0.8;
22352boundingbox 30;
22353textdepth 16;
22354 boxwidth 120;
22355 boxdepth 44;
22356A: box "Arbitrary" "remote hosts";
22357C: ibox;
22358D: box "Arbitrary" "domains";
22359 iline down 50 from bottom of C;
22360H: box width 180 "Local host";
22361 iline down 50;
22362E: ibox;
22363SH: box "Specific" "hosts";
22364SD: box join right to E "Specific" "domains";
22365 arcarrow clockwise from top of SH to bottom of D plus (-10,-4)
22366 via right of H plus (-20,0);
22367 arcarrow clockwise from bottom of A to top of SD plus (10,4)
22368 via left of H plus (20,0);
22369
22370 ibox join left to right of H "$it{Outgoing}";
22371 goto H;
22372 ibox join right to left of H "$it{Incoming}";
22373
22374L: line dashed from right of A to top of H plus (-15,0);
22375 arc dashed to top of H plus (15,0);
22376 arrow dashed to left of D plus (-2,0);
22377
22378 arrow dashed back up 72 right 32 from middle of L plus (8,0);
22379 text at end plus (0, 4) "$it{Not wanted}";
22380.endcall
22381.endfigure
22382.elif !~~html
22383.display asis
22384 -------------- -----------
22385 | Arbitrary | |Arbitrary|
22386 |remote hosts| | domains |
22387 -------------- -----------
22388 I v ^ O
22389 n v ^ u
22390 c ---v----------------^--- t
22391 o | v Local ^ | g
22392 m | v host ^ | o
22393 i ---v----------------^--- i
22394 n v ^ n
22395 g v ^ g
22396 Specific Specific
22397 domains hosts
22398.endd
22399.else
22400[(IMG SRC="relaying.gif" alt="Controlled relaying")][(br)]
22401.fi
22402
22403You can implement relay control by means of suitable statements in the ACL that
22404runs for each \\RCPT\\ command. For convenience, it is often easiest to use
22405Exim's named list facility to define the domains and hosts involved. For
22406example, suppose you want to do the following:
22407.numberpars $.
22408Deliver a number of domains to mailboxes on the local host (or process them
22409locally in some other way). Let's say these are \*my.dom1.example*\ and
22410\*my.dom2.example*\.
22411.nextp
22412Relay mail for a number of other domains for which you are the secondary MX.
22413These might be \*friend1.example*\ and \*friend2.example*\.
22414.nextp
22415Relay mail from the hosts on your local LAN, to whatever domains are involved.
22416Suppose your LAN is 192.168.45.0/24.
22417.endp
22418In the main part of the configuration, you put the following definitions:
22419.display asis
22420domainlist local_domains = my.dom1.example : my.dom2.example
22421domainlist relay_domains = friend1.example : friend2.example
22422hostlist relay_hosts = 192.168.45.0/24
22423.endd
22424Now you can use these definitions in the ACL that is run for every \\RCPT\\
22425command:
22426.display asis
22427acl_check_rcpt:
22428 accept domains = +local_domains : +relay_domains
22429 accept hosts = +relay_hosts
22430.endd
22431The first statement accepts any \\RCPT\\ command that contains an address in
22432the local or relay domains. For any other domain, control passes to the second
22433statement, which accepts the command only if it comes from one of the relay
22434hosts. In practice, you will probably want to make your ACL more sophisticated
22435than this, for example, by including sender and recipient verification. The
22436default configuration includes a more comprehensive example, which is described
22437in chapter ~~CHAPdefconfil.
22438
22439
22440.section Checking a relay configuration
22441.rset SECTcheralcon "~~chapter.~~section"
22442.index relaying||checking control of
22443You can check the relay characteristics of your configuration in the same way
22444that you can test any ACL behaviour for an incoming SMTP connection, by using
22445the \-bh-\ option to run a fake SMTP session with which you interact.
22446
22447For specifically testing for unwanted relaying, the host
22448\*relay-test.mail-abuse.org*\ provides a useful service. If you telnet to this
22449host from the host on which Exim is running, using the normal telnet port, you
22450will see a normal telnet connection message and then quite a long delay. Be
22451patient. The remote host is making an SMTP connection back to your host, and
22452trying a number of common probes to test for open relay vulnerability. The
22453results of the tests will eventually appear on your terminal.
22454
22455
22456
22457
22458.
22459.
22460.
22461.
22462. ============================================================================
22463.chapter Adding a local scan function to Exim
22464.set runningfoot "local scan function"
22465.rset CHAPlocalscan "~~chapter"
22466.index \*local@_scan()*\ function||description of
22467.index customizing||input scan using C function
22468.index policy control||by local scan function
22469
22470In these days of email worms, viruses, and ever-increasing spam, some sites
22471want to apply a lot of checking to messages before accepting them. You can do a
22472certain amount through string expansions and the \condition\ condition in the
22473ACL that runs after the SMTP \\DATA\\ command or the ACL for non-SMTP messages
22474(see chapter ~~CHAPACL), but this has its limitations.
22475
22476.index \exiscan\
22477An increasingly popular way of doing additional checking is to make use of the
22478Exiscan patch for Exim, which adds ACL conditions that perform body scans of
22479various kinds. This is available from
22480.if ~~html
22481[(A HREF="http://duncanthrax.net/exiscan-acl/")]
22482/?http://duncanthrax.net/exiscan-acl/?\.
22483[(/A)]
22484.else
22485\?http:@/@/duncanthrax.net/exiscan-acl/?\.
22486.fi
22487
22488To allow for even more general checking that can be customized to a site's own
22489requirements, there is the possibility of linking Exim with a private message
22490scanning function, written in C. If you want to run code that is written in
22491something other than C, you can of course use a little C stub to call it.
22492
22493The local scan function is run once for every incoming message, at the point
22494when Exim is just about to accept the message.
22495It can therefore be used to control non-SMTP messages from local processes as
22496well as messages arriving via SMTP.
22497
22498Exim applies a timeout to calls of the local scan function, and there is an
22499option called \local@_scan@_timeout\ for setting it. The default is 5 minutes.
22500Zero means `no timeout'.
22501Exim also sets up signal handlers for SIGSEGV, SIGILL, SIGFPE, and SIGBUS
22502before calling the local scan function, so that the most common types of crash
22503are caught. If the timeout is exceeded or one of those signals is caught, the
22504incoming message is rejected with a temporary error if it is an SMTP message.
22505For a non-SMTP message, the message is dropped and Exim ends with a non-zero
22506code. The incident is logged on the main and reject logs.
22507
22508
22509.section Building Exim to use a local scan function
22510.index \*local@_scan()*\ function||building Exim to use
22511To make use of the local scan function feature, you must tell Exim where your
22512function is before building Exim, by setting \\LOCAL@_SCAN@_SOURCE\\ in your
22513\(Local/Makefile)\. A recommended place to put it is in the \(Local)\
22514directory, so you might set
22515.display asis
22516LOCAL_SCAN_SOURCE=Local/local_scan.c
22517.endd
22518for example. The function must be called \*local@_scan()*\. It is called by
22519Exim after it has received a message, when the success return code is about to
22520be sent. This is after all the ACLs have been run. The return code from your
22521function controls whether the message is actually accepted or not. There is a
22522commented template function (that just accepts the message) in the file
22523\(src/local@_scan.c)\.
22524
22525If you want to make use of Exim's run time configuration file to set options
22526for your \*local@_scan()*\ function, you must also set
22527.display asis
22528LOCAL_SCAN_HAS_OPTIONS=yes
22529.endd
22530in \(Local/Makefile)\ (see section ~~SECTconoptloc below).
22531
22532
22533
22534.section API for local@_scan()
22535.rset SECTapiforloc "~~chapter.~~section"
22536.index \*local@_scan()*\ function||API description
22537You must include this line near the start of your code:
22538.display asis
22539#include "local_scan.h"
22540.endd
22541This header file defines a number of variables and other values, and the
22542prototype for the function itself. Exim is coded to use unsigned char values
22543almost exclusively, and one of the things this header defines is a shorthand
22544for \"unsigned char"\ called \"uschar"\.
22545It also contains the following macro definitions, to simplify casting character
22546strings and pointers to character strings:
22547.display asis
22548#define CS (char *)
22549#define CCS (const char *)
22550#define CSS (char **)
22551#define US (unsigned char *)
22552#define CUS (const unsigned char *)
22553#define USS (unsigned char **)
22554.endd
22555
22556The function prototype for \*local@_scan()*\ is:
22557.display asis
22558extern int local_scan(int fd, uschar **return_text);
22559.endd
22560The arguments are as follows:
22561.numberpars $.
22562\fd\ is a file descriptor for the file that contains the body of the message
22563(the -D file).
22564The file is open for reading and writing, but updating it is not recommended.
22565\**Warning**\: You must \*not*\ close this file descriptor.
22566
22567The descriptor is positioned at character 19 of the file, which is the first
22568character of the body itself, because the first 19 characters are the message
22569id followed by \"-D"\ and a newline. If you rewind the file, you should use the
22570macro \\SPOOL@_DATA@_START@_OFFSET\\ to reset to the start of the data, just in
22571case this changes in some future version.
22572
22573.nextp
22574\return@_text\ is an address which you can use to return a pointer to a text
22575string at the end of the function. The value it points to on entry is NULL.
22576.endp
22577The function must return an \int\ value which is one of the following macros:
22578.numberpars $.
22579\"LOCAL@_SCAN@_ACCEPT"\
22580
22581The message is accepted. If you pass back a string of text, it is saved with
22582the message, and made available in the variable \$local@_scan@_data$\. No
22583newlines are permitted (if there are any, they are turned into spaces) and the
22584maximum length of text is 1000 characters.
22585.nextp
22586\"LOCAL@_SCAN@_ACCEPT@_FREEZE"\
22587
22588This behaves as \\LOCAL@_SCAN@_ACCEPT\\, except that the accepted message is
22589queued without immediate delivery, and is frozen.
22590.nextp
22591\"LOCAL@_SCAN@_ACCEPT@_QUEUE"\
22592
22593This behaves as \\LOCAL@_SCAN@_ACCEPT\\, except that the accepted message is
22594queued without immediate delivery.
22595.nextp
22596\"LOCAL@_SCAN@_REJECT"\
22597
22598The message is rejected; the returned text is used as an error message which is
22599passed back to the sender and which is also logged. Newlines are permitted --
22600they cause a multiline response for SMTP rejections, but are converted to
22601\"@\n"\ in log lines.
22602If no message is given, `Administrative prohibition' is used.
22603.nextp
22604\"LOCAL@_SCAN@_TEMPREJECT"\
22605
22606The message is temporarily rejected; the returned text is used as an error
22607message as for \\LOCAL@_SCAN@_REJECT\\. If no message is given, `Temporary
22608local problem' is used.
22609.nextp
22610\"LOCAL@_SCAN@_REJECT@_NOLOGHDR"\
22611
22612This behaves as \\LOCAL@_SCAN@_REJECT\\, except that the header of the rejected
22613message is not written to the reject log. It has the effect of unsetting the
22614\rejected@_header\ log selector for just this rejection. If \rejected@_header\
22615is already unset (see the discussion of the \log@_selection\ option in section
22616~~SECTlogselector), this code is the same as \\LOCAL@_SCAN@_REJECT\\.
22617
22618.nextp
22619\"LOCAL@_SCAN@_TEMPREJECT@_NOLOGHDR"\
22620
22621This code is a variation of \\LOCAL@_SCAN@_TEMPREJECT\\ in the same way that
22622\\LOCAL__SCAN__REJECT__NOLOGHDR\\ is a variation of \\LOCAL@_SCAN@_REJECT\\.
22623.endp
22624
22625If the message is not being received by interactive SMTP, rejections are
22626reported by writing to \stderr\ or by sending an email, as configured by the
22627\-oe-\ command line options.
22628
22629
22630.section Configuration options for local@_scan()
22631.rset SECTconoptloc "~~chapter.~~section"
22632.index \*local@_scan()*\ function||configuration options
22633It is possible to have option settings in the main configuration file
22634that set values in static variables in the \*local@_scan()*\ module. If you
22635want to do this, you must have the line
22636.display asis
22637LOCAL_SCAN_HAS_OPTIONS=yes
22638.endd
22639in your \(Local/Makefile)\ when you build Exim. (This line is in
22640\(OS/Makefile-Default)\, commented out). Then, in the \*local@_scan()*\ source
22641file, you must define static variables to hold the option values, and a table to
22642define them.
22643
22644The table must be a vector called \local@_scan@_options\, of type
22645\"optionlist"\. Each entry is a triplet, consisting of a name, an option type,
22646and a pointer to the variable that holds the value. The entries must appear in
22647alphabetical order. Following \local@_scan@_options\ you must also define a
22648variable called \local@_scan@_options@_count\ that contains the number of
22649entries in the table. Here is a short example, showing two kinds of option:
22650.display asis
22651static int my_integer_option = 42;
22652static uschar *my_string_option = US"a default string";
22653
22654optionlist local_scan_options[] = {
22655 { "my_integer", opt_int, &my_integer_option },
22656 { "my_string", opt_stringptr, &my_string_option }
22657};
22658int local_scan_options_count =
22659 sizeof(local_scan_options)/sizeof(optionlist);
22660.endd
22661The values of the variables can now be changed from Exim's runtime
22662configuration file by including a local scan section as in this example:
22663.display asis
22664begin local_scan
22665my_integer = 99
22666my_string = some string of text...
22667.endd
22668The available types of option data are as follows:
22669
22670.startitems
22671
22672.item opt@_bool
22673This specifies a boolean (true/false) option. The address should point to
22674a variable of type \"BOOL"\, which will be set to \\TRUE\\ or \\FALSE\\, which
22675are macros that are defined as `1' and `0', respectively. If you want to detect
22676whether such a variable has been set at all, you can initialize it to
22677\\TRUE@_UNSET\\. (BOOL variables are integers underneath, so can hold more than
22678two values.)
22679
22680.item "opt@_fixed"
22681This specifies a fixed point number, such as is used for load averages.
22682The address should point to a variable of type \"int"\. The value is stored
22683multiplied by 1000, so, for example, 1.4142 is truncated and stored as 1414.
22684
22685.item "opt@_int"
22686This specifies an integer; the address should point to a variable of type
22687\"int"\. The value may be specified in any of the integer formats accepted by
22688Exim.
22689
22690.item "opt@_mkint"
22691This is the same as \opt@_int\, except that when such a value is output in a
22692\-bP-\ listing, if it is an exact number of kilobytes or megabytes, it is
22693printed with the suffix K or M.
22694
22695.item "opt@_octint"
22696This also specifies an integer, but the value is always interpeted as an
22697octal integer, whether or not it starts with the digit zero, and it is
22698always output in octal.
22699
22700.item "opt@_stringptr"
22701This specifies a string value; the address must be a pointer to a
22702variable that points to a string (for example, of type \"uschar $*$"\).
22703
22704.item "opt@_time"
22705This specifies a time interval value. The address must point to a variable of
22706type \"int"\. The value that is placed there is a number of seconds.
22707
22708.enditems
22709
22710If the \-bP-\ command line option is followed by \"local@_scan"\, Exim prints
22711out the values of all the \*local@_scan()*\ options.
22712
22713
22714.section Available Exim variables
22715.index \*local@_scan()*\ function||available Exim variables
22716The header \(local@_scan.h)\ gives you access to a number of C variables.
22717These are the only ones that are guaranteed to be maintained from release to
22718release. Note, however, that you can obtain the value of any Exim variable by
22719calling \*expand@_string()*\. The exported variables are as follows:
22720
22721.startitems
22722
22723.item "unsigned int debug@_selector"
22724This variable is set to zero when no debugging is taking place. Otherwise, it
22725is a bitmap of debugging selectors. Two bits are identified for use in
22726\*local@_scan()*\; they are defined as macros:
22727.numberpars $.
22728The \"D@_v"\ bit is set when \-v-\ was present on the command line. This is a
22729testing option that is not privileged -- any caller may set it. All the
22730other selector bits can be set only by admin users.
22731.nextp
22732The \"D@_local@_scan"\ bit is provided for use by \*local@_scan()*\; it is set
22733by the \"+local@_scan"\ debug selector. It is not included in the default set
22734of debugging bits.
22735.endp
22736Thus, to write to the debugging output only when \"+local@_scan"\ has been
22737selected, you should use code like this:
22738.display asis
22739if ((debug_selector & D_local_scan) != 0)
22740 debug_printf("xxx", ...);
22741.endd
22742
22743.item "uschar *expand@_string@_message"
22744After a failing call to \*expand@_string()*\ (returned value NULL), the
22745variable \expand__string__message\ contains the error message, zero-terminated.
22746
22747.item "header@_line *header@_list"
22748A pointer to a chain of header lines. The \header@_line\ structure is discussed
22749below.
22750
22751.item "header@_line *header@_last"
22752A pointer to the last of the header lines.
22753
22754.item "uschar *headers@_charset"
22755The value of the \headers@_charset\ configuration option.
22756
22757.item "BOOL host@_checking"
22758This variable is TRUE during a host checking session that is initiated by the
22759\-bh-\ command line option.
22760
22761.item "uschar *interface@_address"
22762The IP address of the interface that received the message, as a string. This
22763is NULL for locally submitted messages.
22764
22765.item "int interface@_port"
22766The port on which this message was received.
22767
22768.item "uschar *message@_id"
22769This variable contains the message id for the incoming message as a
22770zero-terminated string.
22771
22772
22773.item "uschar *received@_protocol"
22774The name of the protocol by which the message was received.
22775
22776.item "int recipients@_count"
22777The number of accepted recipients.
22778
22779.item "recipient@_item *recipients@_list"
22780.index recipient||adding in local scan
22781.index recipient||removing in local scan
22782The list of accepted recipients, held in a vector of length
22783\recipients@_count\. The \recipient@_item\ structure is discussed below. You
22784can add additional recipients by calling \*receive@_add@_recipient()*\ (see
22785below). You can delete recipients by removing them from the vector and adusting
22786the value in \recipients@_count\. In particular, by setting \recipients@_count\
22787to zero you remove all recipients. If you then return the value
22788\"LOCAL@_SCAN@_ACCEPT"\, the message is accepted, but immediately blackholed.
22789To replace the recipients, set \recipients@_count\ to zero and then call
22790\*receive@_add@_recipient()*\ as often as needed.
22791
22792.item "uschar *sender@_address"
22793The envelope sender address. For bounce messages this is the empty string.
22794
22795.item "uschar *sender@_host@_address"
22796The IP address of the sending host, as a string. This is NULL for
22797locally-submitted messages.
22798
22799.item "uschar *sender@_host@_authenticated"
22800The name of the authentication mechanism that was used, or NULL if the message
22801was not received over an authenticated SMTP connection.
22802
22803.item "uschar *sender@_host@_name"
22804The name of the sending host, if known.
22805
22806.item "int sender@_host@_port"
22807The port on the sending host.
22808
22809.item "BOOL smtp@_input"
22810This variable is TRUE for all SMTP input, including BSMTP.
22811
22812.item "BOOL smtp@_batched@_input"
22813This variable is TRUE for BSMTP input.
22814
22815.item "int store@_pool"
22816The contents of this variable control which pool of memory is used for new
22817requests. See section ~~SECTmemhanloc for details.
22818
22819.enditems
22820
22821
22822.section Structure of header lines
22823The \header@_line\ structure contains the members listed below.
22824You can add additional header lines by calling the \*header@_add()*\ function
22825(see below). You can cause header lines to be ignored (deleted) by setting
22826their type to $*$.
22827
22828.startitems
22829
22830.item "struct header@_line *next"
22831A pointer to the next header line, or NULL for the last line.
22832
22833.item "int type"
22834A code identifying certain headers that Exim recognizes. The codes are printing
22835characters, and are documented in chapter ~~CHAPspool of this manual. Notice in
22836particular that any header line whose type is $*$ is not transmitted with the
22837message. This flagging is used for header lines that have been rewritten, or
22838are to be removed (for example, ::Envelope-sender:: header lines.) Effectively,
22839$*$ means `deleted'.
22840
22841.item "int slen"
22842The number of characters in the header line, including the terminating and any
22843internal newlines.
22844
22845.item "uschar *text"
22846A pointer to the text of the header. It always ends with a newline, followed by
22847a zero byte. Internal newlines are preserved.
22848
22849.enditems
22850
22851
22852
22853.section Structure of recipient items
22854The \recipient@_item\ structure contains these members:
22855
22856.startitems
22857
22858.item "uschar *address"
22859This is a pointer to the recipient address as it was received.
22860
22861.item "int pno"
22862This is used in later Exim processing when top level addresses are created
22863by the \one@_time\ option. It is not relevant at the time \*local@_scan()*\ is
22864run and
22865must always contain -1 at this stage.
22866
22867.item "uschar *errors@_to"
22868If this value is not NULL, bounce messages caused by failing to deliver to the
22869recipient are sent to the address it contains. In other words, it overrides the
22870envelope sender for this one recipient. (Compare the \errors@_to\ generic
22871router option.)
22872If a \*local@_scan()*\ function sets an \errors@_to\ field to an unqualified
22873address, Exim qualifies it using the domain from \qualify@_recipient\.
22874When \*local@_scan()*\ is called, the \errors@_to\ field is NULL for all
22875recipients.
22876.enditems
22877
22878
22879.section Available Exim functions
22880.index \*local@_scan()*\ function||available Exim functions
22881The header \(local@_scan.h)\ gives you access to a number of Exim functions.
22882These are the only ones that are guaranteed to be maintained from release to
22883release:
22884
22885.startitems
22886
22887.item "pid@_t child@_open(uschar **argv, uschar **envp, int newumask, int *infdptr, int *outfdptr, BOOL make@_leader)"
22888This function creates a child process that runs the command specified by
22889\argv\. The environment for the process is specified by \envp\, which can be
22890NULL if no environment variables are to be passed. A new umask is supplied for
22891the process in \newumask\.
22892
22893Pipes to the standard input and output of the new process are set up
22894and returned to the caller via the \infdptr\ and \outfdptr\ arguments. The
22895standard error is cloned to the standard output. If there are any file
22896descriptors `in the way' in the new process, they are closed. If the final
22897argument is TRUE, the new process is made into a process group leader.
22898
22899The function returns the pid of the new process, or -1 if things go wrong.
22900
22901
22902.item "int child@_close(pid@_t pid, int timeout)"
22903This function waits for a child process to terminate, or for a timeout (in
22904seconds) to expire. A timeout value of zero means wait as long as it takes. The
22905return value is as follows:
22906.numberpars $.
22907>= 0
22908
22909The process terminated by a normal exit and the value is the process ending
22910status.
22911.nextp
22912< 0 and > --256
22913
22914The process was terminated by a signal and the value is the negation of the
22915signal number.
22916.nextp
22917--256
22918
22919The process timed out.
22920.nextp
22921--257
22922
22923The was some other error in wait(); \errno\ is still set.
22924.endp
22925
22926
22927.item "pid@_t child@_open@_exim(int *fd)"
22928This function provide you with a means of submitting a new message to
22929Exim. (Of course, you can also call \(/usr/sbin/sendmail)\ yourself if you
22930want, but this packages it all up for you.) The function creates a pipe,
22931forks a subprocess that is running
22932.display asis
22933exim -t -oem -oi -f <>
22934.endd
22935and returns to you (via the \"int *"\ argument) a file descriptor for the pipe
22936that is connected to the standard input. The yield of the function is the PID
22937of the subprocess. You can then write a message to the file descriptor, with
22938recipients in ::To::, ::Cc::, and/or ::Bcc:: header lines.
22939
22940When you have finished, call \*child@_close()*\ to wait for the process to
22941finish and to collect its ending status. A timeout value of zero is usually
22942fine in this circumstance. Unless you have made a mistake with the recipient
22943addresses, you should get a return code of zero.
22944
22945.item "void debug@_printf(char *, ...)"
22946This is Exim's debugging function, with arguments as for \*(printf()*\. The
22947output is written to the standard error stream. If no debugging is selected,
22948calls to \*debug@_printf()*\ have no effect. Normally, you should make calls
22949conditional on the \"local@_scan"\ debug selector by coding like this:
22950.display asis
22951if ((debug_selector & D_local_scan) != 0)
22952 debug_printf("xxx", ...);
22953.endd
22954
22955.item "uschar *expand@_string(uschar *string)"
22956This is an interface to Exim's string expansion code. The return value is the
22957expanded string, or NULL if there was an expansion failure.
22958The C variable \expand@_string@_message\ contains an error message after an
22959expansion failure. If expansion does not change the string, the return value is
22960the pointer to the input string. Otherwise, the return value points to a new
22961block of memory that was obtained by a call to \*store@_get()*\. See section
22962~~SECTmemhanloc below for a discussion of memory handling.
22963
22964.item "void header@_add(int type, char *format, ...)"
22965This function allows you to add additional header lines. The first argument is
22966the type, and should normally be a space character. The second argument is a
22967format string and any number of substitution arguments as for \*sprintf()*\.
22968You may include internal newlines if you want, and you must ensure that the
22969string ends with a newline.
22970
22971.item "uschar *lss@_b64encode(uschar *cleartext, int length)"
22972.index base64 encoding||functions for \*local@_scan()*\ use
22973This function base64-encodes a string, which is passed by address and length.
22974The text may contain bytes of any value, including zero. The result is passed
22975back in dynamic memory that is obtained by calling \*store@_get()*\. It is
22976zero-terminated.
22977
22978.item "int lss@_b64decode(uschar *codetext, uschar **cleartext)"
22979This function decodes a base64-encoded string. Its arguments are a
22980zero-terminated base64-encoded string and the address of a variable that is set
22981to point to the result, which is in dynamic memory. The length of the
22982decoded string is the yield of the function. If the input is invalid base64
22983data, the yield is -1. A zero byte is added to the end of the output string to
22984make it easy to interpret as a C string (assuming it contains no zeros of its
22985own). The added zero byte is not included in the returned count.
22986
22987.item "int lss@_match@_domain(uschar *domain, uschar *list)"
22988This function checks for a match in a domain list. Domains are always
22989matched caselessly. The return value is one of the following:
22990.display
22991OK $rm{match succeeded}
22992FAIL $rm{match failed}
22993DEFER $rm{match deferred}
22994.endd
22995DEFER is usually caused by some kind of lookup defer, such as the
22996inability to contact a database.
22997
22998.item "int lss@_match@_local@_part(uschar *localpart, uschar *list, BOOL caseless)"
22999This function checks for a match in a local part list. The third argument
23000controls case-sensitivity. The return values are as for
23001\*lss@_match@_domain()*\.
23002
23003.item "int lss@_match@_address(uschar *address, uschar *list, BOOL caseless)"
23004This function checks for a match in an address list. The third argument
23005controls the case-sensitivity of the local part match. The domain is always
23006matched caselessly. The return values are as for \*lss@_match@_domain()*\.
23007
23008.item "int lss@_match@_host(uschar *host@_name, uschar *host@_address, uschar *list)"
23009This function checks for a match in a host list. The most common usage is
23010expected to be
23011.display asis
23012lss_match_host(sender_host_name, sender_host_address, ...)
23013.endd
23014An empty address field matches an empty item in the host list. If the
23015host name is NULL, the name corresponding to \$sender@_host@_address$\ is
23016automatically looked up if a host name is required to match an item in the
23017list. The return values are as for \*lss@_match@_domain()*\, but in addition,
23018\*lss@_match@_host()*\ returns ERROR in the case when it had to look up a host
23019name, but the lookup failed.
23020
23021.item "void log@_write(unsigned int selector, int which, char *format, ...)"
23022This function writes to Exim's log files. The first argument should be zero (it
23023is concerned with \log@_selector\). The second argument can be \"LOG@_MAIN"\ or
23024\"LOG@_REJECT"\ or
23025\"LOG@_PANIC"\ or the inclusive `or' of any combination of them. It specifies
23026to which log or logs the message is written.
23027The remaining arguments are a format and relevant insertion arguments. The
23028string should not contain any newlines, not even at the end.
23029
23030
23031.item "void receive@_add@_recipient(uschar *address, int pno)"
23032This function adds an additional recipient to the message. The first argument
23033is the recipient address. If it is unqualified (has no domain), it is qualified
23034with the \qualify@_recipient\ domain. The second argument must always be -1.
23035
23036This function does not allow you to specify a private \errors@_to\ address (as
23037described with the structure of \recipient@_item\ above), because it pre-dates
23038the addition of that field to the structure. However, it is easy to add such a
23039value afterwards. For example:
23040.display asis
23041receive_add_recipient(US"monitor@mydom.example", -1);
23042recipients_list[recipients_count-1].errors_to =
23043 US"postmaster@mydom.example";
23044.endd
23045
23046.item "uschar *rfc2047@_decode(uschar *string, BOOL lencheck, uschar *target, int zeroval, int *lenptr, uschar **error)"
23047This function decodes strings that are encoded according to RFC 2047. Typically
23048these are the contents of header lines. First, each encoded `word' is decoded
23049from the Q or B encoding into a byte-string. Then, if provided with the name of
23050a charset encoding, and if the \*iconv()*\ function is available, an attempt is
23051made to translate the result to the named character set. If this fails, the
23052binary string is returned with an error message.
23053
23054The first argument is the string to be decoded. If \lencheck\ is TRUE, the
23055maximum MIME word length is enforced. The third argument is the target
23056encoding, or NULL if no translation is wanted.
23057
23058.index binary zero||in RFC 2047 decoding
23059If a binary zero is encountered in the decoded string, it is replaced by the
23060contents of the \zeroval\ argument. For use with Exim headers, the value must
23061not be 0 because header lines are handled as zero-terminated strings.
23062
23063The function returns the result of processing the string, zero-terminated; if
23064\lenptr\ is not NULL, the length of the result is set in the variable to which
23065it points. When \zeroval\ is 0, \lenptr\ should not be NULL.
23066
23067If an error is encountered, the function returns NULL and uses the \error\
23068argument to return an error message. The variable pointed to by \error\ is set
23069to NULL if there is no error; it may be set non-NULL even when the function
23070returns a non-NULL value if decoding was successful, but there was a problem
23071with translation.
23072
23073
23074.item "int smtp@_fflush(void)"
23075This function is used in conjunction with \*smtp@_printf()*\, as described
23076below.
23077
23078.item "void smtp@_printf(char *, ...)"
23079The arguments of this function are like \*printf()*\; it writes to the SMTP
23080output stream. You should use this function only when there is an SMTP output
23081stream, that is, when the incoming message is being received via interactive
23082SMTP. This is the case when \smtp@_input\ is TRUE and \smtp@_batched@_input\ is
23083FALSE. If you want to test for an incoming message from another host (as
23084opposed to a local process that used the \-bs-\ command line option), you can
23085test the value of \sender@_host@_address\, which is non-NULL when a remote host
23086is involved.
23087
23088If an SMTP TLS connection is established, \*smtp@_printf()*\ uses the TLS
23089output function, so it can be used for all forms of SMTP connection.
23090
23091Strings that are written by \*smtp@_printf()*\ from within \*local@_scan()*\
23092must start with an appropriate response code: 550 if you are going to return
23093\\LOCAL@_SCAN@_REJECT\\, 451 if you are going to return
23094\\LOCAL@_SCAN@_TEMPREJECT\\, and 250 otherwise. Because you are writing the
23095initial lines of a multi-line response, the code must be followed by a hyphen
23096to indicate that the line is not the final response line. You must also ensure
23097that the lines you write terminate with CRLF. For example:
23098.display asis
23099smtp_printf("550-this is some extra info\r\n");
23100return LOCAL_SCAN_REJECT;
23101.endd
23102Note that you can also create multi-line responses by including newlines in
23103the data returned via the \return@_text\ argument. The added value of using
23104\*smtp@_printf()*\ is that, for instance, you could introduce delays between
23105multiple output lines.
23106
23107The \*smtp@_printf()*\ function does not return any error indication, because it
23108does not automatically flush pending output, and therefore does not test
23109the state of the stream. (In the main code of Exim, flushing and error
23110detection is done when Exim is ready for the next SMTP input command.) If
23111you want to flush the output and check for an error (for example, the
23112dropping of a TCP/IP connection), you can call \*smtp@_fflush()*\, which has no
23113arguments. It flushes the output stream, and returns a non-zero value if there
23114is an error.
23115
23116.item "void *store@_get(int)"
23117This function accesses Exim's internal store (memory) manager. It gets a new
23118chunk of memory whose size is given by the argument. Exim bombs out if it ever
23119runs out of memory. See the next section for a discussion of memory handling.
23120
23121.item "void *store@_get@_perm(int)"
23122This function is like \*store@_get()*\, but it always gets memory from the
23123permanent pool. See the next section for a discussion of memory handling.
23124
23125.item "uschar *string@_copy(uschar *string)"
23126.item "uschar *string@_copyn(uschar *string, int length)" 0
23127.item "uschar *string@_sprintf(char *format, ...)" 0
23128These three functions create strings using Exim's dynamic memory facilities.
23129The first makes a copy of an entire string. The second copies up to a maximum
23130number of characters, indicated by the second argument. The third uses a format
23131and insertion arguments to create a new string. In each case, the result is a
23132pointer to a new string
23133in the current memory pool. See the next section for more discussion.
23134
23135.enditems
23136
23137
23138
23139.section More about Exim's memory handling
23140.rset SECTmemhanloc "~~chapter.~~section"
23141.index \*local@_scan()*\ function||memory handling
23142No function is provided for freeing memory, because that is never needed.
23143The dynamic memory that Exim uses when receiving a message is automatically
23144recycled if another message is received by the same process (this applies only
23145to incoming SMTP connections -- other input methods can supply only one message
23146at a time). After receiving the last message, a reception process terminates.
23147
23148Because it is recycled, the normal dynamic memory cannot be used for holding
23149data that must be preserved over a number of incoming messages on the same SMTP
23150connection. However, Exim in fact uses two pools of dynamic memory; the second
23151one is not recycled, and can be used for this purpose.
23152
23153If you want to allocate memory that remains available for subsequent messages
23154in the same SMTP connection, you should set
23155.display asis
23156store_pool = POOL_PERM
23157.endd
23158before calling the function that does the allocation. There is no need to
23159restore the value if you do not need to; however, if you do want to revert to
23160the normal pool, you can either restore the previous value of \store@_pool\ or
23161set it explicitly to \\POOL@_MAIN\\.
23162
23163The pool setting applies to all functions that get dynamic memory, including
23164\*expand@_string()*\, \*store@_get()*\, and the \*string@_xxx()*\ functions.
23165There is also a convenience function called \*store@_get@_perm()*\ that gets a
23166block of memory from the permanent pool while preserving the value of
23167\store@_pool\.
23168
23169
23170
23171
23172
23173.
23174.
23175.
23176.
23177. ============================================================================
23178.chapter System-wide message filtering
23179.set runningfoot "system filtering"
23180.rset CHAPsystemfilter "~~chapter"
23181.index filter||system filter
23182.index filtering all mail
23183.index system filter
23184The previous chapters (on ACLs and the local scan function) describe checks
23185that can be applied to messages before they are accepted by a host. There is
23186also a mechanism for checking messages once they have been received, but before
23187they are delivered. This is called the $it{system filter}.
23188
23189The system filter operates in a similar manner to users' filter files, but it
23190is run just once per message (however many recipients the message has).
23191It should not normally be used as a substitute for routing, because \deliver\
23192commands in a system router provide new envelope recipient addresses.
23193The system filter must be an Exim filter. It cannot be a Sieve filter.
23194
23195The system filter is run at the start of a delivery attempt, before any routing
23196is done. If a message fails to be completely delivered at the first attempt,
23197the system filter is run again at the start of every retry.
23198If you want your filter to do something only once per message, you can make use
23199of the \first@_delivery\ condition in an \if\ command in the filter to prevent
23200it happening on retries.
23201
23202\**Warning**\: Because the system filter runs just once, variables that are
23203specific to individual recipient addresses, such as \$local@_part$\ and
23204\$domain$\, are not set, and the `personal' condition is not meaningful. If you
23205want to run a centrally-specified filter for each recipient address
23206independently, you can do so by setting up a suitable \%redirect%\ router, as
23207described in section ~~SECTperaddfil below.
23208
23209.section Specifying a system filter
23210.index uid (user id)||system filter
23211.index gid (group id)||system filter
23212The name of the file that contains the system filter must be specified by
23213setting \system@_filter\. If you want the filter to run under a uid and gid
23214other than root, you must also set \system@_filter@_user\ and
23215\system@_filter@_group\ as appropriate. For example:
23216.display asis
23217system_filter = /etc/mail/exim.filter
23218system_filter_user = exim
23219.endd
23220If a system filter generates any deliveries directly to files or pipes (via the
23221\save\ or \pipe\ commands), transports to handle these deliveries must be
23222specified by setting \system@_filter@_file@_transport\ and
23223\system@_filter@_pipe@_transport\, respectively. Similarly,
23224\system@_filter@_reply@_transport\ must be set to handle any messages generated
23225by the \reply\ command.
23226
23227.section Testing a system filter
23228You can run simple tests of a system filter in the same way as for a user
23229filter, but you should use \-bF-\ rather than \-bf-\, so that features that
23230are permitted only in system filters are recognized.
23231
23232.section Contents of a system filter
23233The language used to specify system filters is the same as for users' filter
23234files. It is described in the separate end-user document \*Exim's interface to
23235mail filtering*\. However, there are some additional features that are
23236available only in system filters; these are described in subsequent sections.
23237If they are encountered in a user's filter file or when testing with \-bf-\,
23238they cause errors.
23239
23240.index frozen messages||manual thaw, testing in filter
23241There are two special conditions which, though available in users' filter
23242files, are designed for use in system filters. The condition \first@_delivery\
23243is true only for the first attempt at delivering a message, and
23244\manually@_thawed\ is true only if the message has been frozen, and
23245subsequently thawed by an admin user. An explicit forced delivery counts as a
23246manual thaw, but thawing as a result of the \auto__thaw\ setting does not.
23247
23248\**Warning**\: If a system filter uses the \first@_delivery\ condition to
23249specify an `unseen' (non-significant) delivery, and that delivery does not
23250succeed, it will not be tried again.
23251If you want Exim to retry an unseen delivery until it succeeds, you should
23252arrange to set it up every time the filter runs.
23253
23254When a system filter finishes running, the values of the variables \$n0$\ --
23255\$n9$\ are copied into \$sn0$\ -- \$sn9$\ and are thereby made available to
23256users' filter files. Thus a system filter can, for example, set up `scores' to
23257which users' filter files can refer.
23258
23259
23260.section Additional variable for system filters
23261The expansion variable \$recipients$\, containing a list of all the recipients
23262of the message (separated by commas and white space), is available in system
23263filters. It is not available in users' filters for privacy reasons.
23264
23265
23266.section Defer, freeze, and fail commands for system filters
23267.index freezing messages
23268.index message||freezing
23269.index message||forced failure
23270.index \fail\||in system filter
23271.index \freeze\ in system filter
23272.index \defer\ in system filter
23273There are three extra commands (\defer\, \freeze\ and \fail\) which are always
23274available in system filters, but are not normally enabled in users' filters.
23275(See the \allow@_defer\,
23276\allow@_freeze\ and \allow@_fail\ options for the \%redirect%\ router.) These
23277commands can optionally be followed by the word \text\ and a string containing
23278an error message, for example:
23279.display asis
23280fail text "this message looks like spam to me"
23281.endd
23282The keyword \text\ is optional if the next character is a double quote.
23283
23284The \defer\ command defers delivery of the original recipients of the message.
23285The \fail\ command causes all the original recipients to be failed, and a
23286bounce message to be created. The \freeze\ command suspends all delivery
23287attempts for the original recipients. In all cases, any new deliveries that are
23288specified by the filter are attempted as normal after the filter has run.
23289
23290The \freeze\ command is ignored if the message has been manually unfrozen and
23291not manually frozen since. This means that automatic freezing by a system
23292filter can be used as a way of checking out suspicious messages. If a message
23293is found to be all right, manually unfreezing it allows it to be delivered.
23294
23295.index log||\fail\ command log line
23296.index \fail\||log line, reducing
23297The text given with a fail command is used as part of the bounce message as
23298well as being written to the log. If the message is quite long, this can fill
23299up a lot of log space when such failures are common. To reduce the size of the
23300log message, Exim interprets the text in a special way if it starts with the
23301two characters \"@<@<"\ and contains \"@>@>"\ later. The text between these two
23302strings is written to the log, and the rest of the text is used in the bounce
23303message. For example:
23304.display asis
23305fail "<<filter test 1>>Your message is rejected \
23306 because it contains attachments that we are \
23307 not prepared to receive."
23308.endd
23309
23310.index loop||caused by \fail\
23311Take great care with the \fail\ command when basing the decision to fail on the
23312contents of the message, because the bounce message will of course include the
23313contents of the original message and will therefore trigger the \fail\ command
23314again (causing a mail loop) unless steps are taken to prevent this. Testing the
23315\error@_message\ condition is one way to prevent this. You could use, for
23316example
23317.display asis
23318if $message_body contains "this is spam" and not error_message
23319 then fail text "spam is not wanted here" endif
23320.endd
23321though of course that might let through unwanted bounce messages. The
23322alternative is clever checking of the body and/or headers to detect bounces
23323generated by the filter.
23324
23325The interpretation of a system filter file ceases after a
23326\defer\,
23327\freeze\, or \fail\ command is obeyed. However, any deliveries that were set up
23328earlier in the filter file are honoured, so you can use a sequence such as
23329.display asis
23330mail ...
23331freeze
23332.endd
23333to send a specified message when the system filter is freezing (or deferring or
23334failing) a message. The normal deliveries for the message do not, of course,
23335take place.
23336
23337
23338.section Adding and removing headers in a system filter
23339.index header lines||adding in system filter
23340.index header lines||removing in system filter
23341.index filter||header lines, adding/removing
23342Two filter commands that are available only in system filters are:
23343.display asis
23344headers add <<string>>
23345headers remove <<string>>
23346.endd
23347The argument for the \headers add\ is a string which is expanded and then added
23348to the end of the message's headers. It is the responsibility of the filter
23349maintainer to make sure it conforms to RFC 2822 syntax. Leading white space is
23350ignored, and if the string is otherwise empty, or if the expansion is forced to
23351fail, the command has no effect.
23352
23353If the message is not delivered at the first attempt, header lines that were
23354added by the system filter are stored with the message, and so are still
23355present at the next delivery attempt. For that reason, it is usual to make the
23356\headers add\ command conditional on \first@_delivery\.
23357
23358.em
23359You can use `@\n' within the string, followed by white space, to specify
23360continued header lines. More than one header may be added in one command by
23361including `@\n' within the string without any following white space. For
23362example:
23363.display asis
23364headers add "X-header-1: ....\n \
23365 continuation of X-header-1 ...\n\
23366 X-header-2: ...."
23367.endd
23368Note that the header line continuation white space after the first newline must
23369be placed before the backslash that continues the input string, because white
23370space after input continuations is ignored.
23371
23372Header lines that are added by a system filter are visible to users' filter
23373files and to all routers and transports.
23374.nem
23375
23376The argument for \headers remove\ is a colon-separated list of header names.
23377This command applies only to those headers that are stored with the message;
23378those that are added at delivery time (such as ::Envelope-To:: and
23379::Return-Path::) cannot be removed by this means.
23380If there is more than one header with the same name, they are all removed.
23381
23382
23383.section Setting an errors address in a system filter
23384.index envelope sender
23385In a system filter, if a \deliver\ command is followed by
23386.display
23387errors@_to <<some address>>
23388.endd
23389in order to change the envelope sender (and hence the error reporting) for that
23390delivery, any address may be specified. (In a user filter, only the current
23391user's address can be set.) For example, if some mail is being monitored, you
23392might use
23393.display asis
23394unseen deliver monitor@spying.example errors_to root@local.example
23395.endd
23396to take a copy which would not be sent back to the normal error reporting
23397address if its delivery failed.
23398
23399
23400.section Per-address filtering
23401.rset SECTperaddfil "~~chapter.~~section"
23402In contrast to the system filter, which is run just once per message for each
23403delivery attempt, it is also possible to set up a system-wide filtering
23404operation that runs once for each recipient address. In this case, variables
23405such as \$local@_part$\ and \$domain$\ can be used, and indeed, the choice of
23406filter file could be made dependent on them. This is an example of a router
23407which implements such a filter:
23408.display asis
23409central_filter:
23410.newline
23411.em
23412 check_local_user
23413.newline
23414.nem
23415 driver = redirect
23416 domains = +local_domains
23417 file = /central/filters/$local_part
23418 no_verify
23419 allow_filter
23420 allow_freeze
23421.endd
23422.em
23423The filter is run in a separate process under its own uid. Therefore, either
23424\check@_local@_user\ must be set (as above), in which case the filter is run as
23425the local user, or the \user\ option must be used to specify which user to use.
23426If both are set, \user\ overrides.
23427.nem
23428
23429Care should be taken to ensure that none of the commands in the filter file
23430specify a significant delivery if the message is to go on to be delivered to
23431its intended recipient. The router will not then claim to have dealt with the
23432address, so it will be passed on to subsequent routers to be delivered in the
23433normal way.
23434
23435
23436
23437
23438
23439.
23440.
23441.
23442.
23443. ============================================================================
23444.chapter Customizing bounce and warning messages
23445.set runningfoot "customizing messages"
23446.rset CHAPemsgcust "~~chapter"
23447When a message fails to be delivered, or remains on the queue for more than a
23448configured amount of time, Exim sends a message to the original sender, or
23449to an alternative configured address. The text of these messages is built into
23450the code of Exim, but it is possible to change it, either by adding a single
23451string, or by replacing each of the paragraphs by text supplied in a file.
23452
23453The ::From:: and ::To:: header lines are automatically generated; you can cause
23454a ::Reply-To:: line to be added by setting the \errors@_reply@_to\ option. Exim
23455also adds the line
23456.display asis
23457Auto-Submitted: auto-generated
23458.endd
23459to all warning and bounce messages,
23460
23461.section Customizing bounce messages
23462.index customizing||bounce message
23463.index bounce message||customizing
23464If \bounce@_message@_text\ is set, its contents are included in the default
23465message immediately after `This message was created automatically by mail
23466delivery software.' The string is not expanded. It is not used if
23467\bounce@_message@_file\ is set.
23468
23469When \bounce@_message@_file\ is set, it must point to a template file for
23470constructing error messages. The file consists of a series of text items,
23471separated by lines consisting of exactly four asterisks. If the file cannot be
23472opened, default text is used and a message is written to the main and panic
23473logs. If any text item in the file is empty, default text is used for that
23474item.
23475
23476Each item of text that is read from the file is expanded, and there are two
23477expansion variables which can be of use here: \$bounce@_recipient$\ is set to
23478the recipient of an error message while it is being created, and
23479\$return@_size@_limit$\ contains the value of the \return@_size@_limit\ option,
23480rounded to a whole number.
23481
23482The items must appear in the file in the following order:
23483.numberpars $.
23484The first item is included in the headers, and should include at least a
23485::Subject:: header. Exim does not check the syntax of these headers.
23486.nextp
23487The second item forms the start of the error message. After it, Exim lists the
23488failing addresses with their error messages.
23489.nextp
23490The third item is used to introduce any text from pipe transports that is to be
23491returned to the sender. It is omitted if there is no such text.
23492.nextp
23493The fourth item is used to introduce the copy of the message that is returned
23494as part of the error report.
23495.nextp
23496The fifth item is added after the fourth one if the returned message is
23497truncated because it is bigger than \return@_size@_limit\.
23498.nextp
23499The sixth item is added after the copy of the original message.
23500.endp
23501The default state (\bounce@_message@_file\ unset) is equivalent to the
23502following file, in which the sixth item is empty. The ::Subject:: line has been
23503split into two here in order to fit it on the page:
23504.if ~~sys.fancy
23505.display flow asis
23506.fontgroup 0
23507.font 54
23508.else
23509.rule
23510.display flow asis
23511.linelength 80em
23512.indent 0
23513.fi
23514Subject: Mail delivery failed
23515 ${if eq{$sender_address}{$bounce_recipient}{: returning message to sender}}
23516****
23517This message was created automatically by mail delivery software.
23518
23519A message ${if eq{$sender_address}{$bounce_recipient}{that you sent }{sent by
23520
23521 <$sender_address>
23522
23523}}could not be delivered to all of its recipients.
23524The following address(es) failed:
23525****
23526The following text was generated during the delivery attempt(s):
23527****
23528------ This is a copy of the message, including all the headers. ------
23529****
23530------ The body of the message is $message_size characters long; only the first
23531------ $return_size_limit or so are included here.
23532****
23533.endd
23534.if !~~sys.fancy
23535.rule
23536.fi
23537
23538.section Customizing warning messages
23539.rset SECTcustwarn "~~chapter.~~section"
23540.index customizing||warning message
23541.index warning of delay||customizing the message
23542The option
23543\warn@_message@_file\
23544can be pointed at a template file for use when
23545warnings about message delays are created. In this case there are only three
23546text sections:
23547.numberpars $.
23548The first item is included in the headers, and should include at least a
23549::Subject:: header. Exim does not check the syntax of these headers.
23550.nextp
23551The second item forms the start of the warning message. After it, Exim lists
23552the delayed addresses.
23553.nextp
23554The third item then ends the message.
23555.endp
23556The default state is equivalent to the following file, except that the line
23557starting `A message' has been split here, in order to fit it on the page:
23558.if ~~sys.fancy
23559.display asis
23560.fontgroup 0
23561.font 54
23562.else
23563.rule
23564.display asis
23565.linelength 80em
23566.indent 0
23567.fi
23568.newline
23569Subject: Warning: message $message_id delayed $warn_message_delay
23570****
23571This message was created automatically by mail delivery software.
23572
23573A message ${if eq{$sender_address}{$warn_message_recipients}
23574 {that you sent }{sent by
23575
23576 <$sender_address>
23577
23578}}has not been delivered to all of its recipients after
23579more than $warn_message_delay on the queue on $primary_hostname.
23580.newline
23581
23582The message identifier is: $message_id
23583The subject of the message is: $h_subject
23584The date of the message is: $h_date
23585
23586The following address(es) have not yet been delivered:
23587****
23588No action is required on your part. Delivery attempts will continue for
23589some time, and this warning may be repeated at intervals if the message
23590remains undelivered. Eventually the mail delivery software will give up,
23591and when that happens, the message will be returned to you.
23592.endd
23593.if !~~sys.fancy
23594.rule
23595.fi
23596except that in the default state the subject and date lines are omitted if no
23597appropriate headers exist. During the expansion of this file,
23598\$warn@_message@_delay$\
23599is set to the delay time in one of the forms `<<n>> minutes'
23600or `<<n>> hours', and
23601\$warn@_message@_recipients$\
23602contains a list of recipients for the warning message. There may be more than
23603one if there are multiple addresses with different \errors@_to\ settings on the
23604routers that handled them.
23605
23606
23607
23608
23609.
23610.
23611.
23612. ============================================================================
23613.chapter Some common configuration requirements
23614.set runningfoot "common configuration requirements"
23615.rset CHAPcomconreq "~~chapter"
23616This chapter discusses some configuration requirements that seem to be fairly
23617common. More examples and discussion can be found in the Exim book.
23618
23619
23620.section Sending mail to a smart host
23621.index smart host||example router
23622If you want to send all mail for non-local domains to a `smart host', you
23623should replace the default \%dnslookup%\ router with a router which does the
23624routing explicitly:
23625.display asis
23626send_to_smart_host:
23627 driver = manualroute
23628 route_list = !+local_domains smart.host.name
23629 transport = remote_smtp
23630.endd
23631You can use the smart host's IP address instead of the name if you wish.
23632
23633
23634.section Using Exim to handle mailing lists
23635.rset SECTmailinglists "~~chapter.~~section"
23636.index mailing lists
23637Exim can be used to run simple mailing lists, but for large and/or complicated
23638requirements, the use of additional specialized mailing list software such as
23639Majordomo or Mailman is recommended.
23640
23641The \%redirect%\ router can be used to handle mailing lists where each list
23642is maintained in a separate file, which can therefore be managed by an
23643independent manager. The \domains\ router option can be used to run these
23644lists in a separate domain from normal mail. For example:
23645.display asis
23646lists:
23647 driver = redirect
23648 domains = lists.example
23649 file = /usr/lists/$local_part
23650 forbid_pipe
23651 forbid_file
23652 errors_to = $local_part-request@lists.example
23653 no_more
23654.endd
23655This router is skipped for domains other than \*lists.example*\. For addresses
23656in that domain, it looks for a file that matches the local part. If there is no
23657such file, the router declines, but because \no@_more\ is set, no subsequent
23658routers are tried, and so the whole delivery fails.
23659
23660The \forbid@_pipe\ and \forbid@_file\ options prevent a local part from being
23661expanded into a file name or a pipe delivery, which is usually inappropriate in
23662a mailing list.
23663
23664.index \errors@_to\
23665The \errors@_to\ option specifies that any delivery errors caused by addresses
23666taken from a mailing list are to be sent to the given address rather than the
23667original sender of the message. However, before acting on this, Exim verifies
23668the error address, and ignores it if verification fails.
23669
23670For example, using the configuration above, mail sent to
23671\*dicts@@lists.example*\ is passed on to those addresses contained in
23672\(/usr/lists/dicts)\, with error reports directed to
23673\*dicts-request@@lists.example*\, provided that this address can be verified.
23674There could be a file called \(/usr/lists/dicts-request)\ containing
23675the address(es) of this particular list's manager(s), but other approaches,
23676such as setting up an earlier router (possibly using the \local@_part@_prefix\
23677or \local@_part@_suffix\ options) to handle addresses of the form \owner-xxx\
23678or \xxx-request\, are also possible.
23679
23680
23681.section Syntax errors in mailing lists
23682.index mailing lists||syntax errors in
23683If an entry in redirection data contains a syntax error, Exim normally defers
23684delivery of the original address. That means that a syntax error in a mailing
23685list holds up all deliveries to the list. This may not be appropriate when a
23686list is being maintained automatically from data supplied by users, and the
23687addresses are not rigorously checked.
23688
23689If the \skip@_syntax@_errors\ option is set, the \%redirect%\ router just skips
23690entries that fail to parse, noting the incident in the log. If in addition
23691\syntax@_errors@_to\ is set to a verifiable address, a message is sent to it
23692whenever a broken address is skipped. It is usually appropriate to set
23693\syntax@_errors@_to\ to the same address as \errors@_to\.
23694
23695
23696.section Re-expansion of mailing lists
23697.index mailing lists||re-expansion of
23698Exim remembers every individual address to which a message has been delivered,
23699in order to avoid duplication, but it normally stores only the original
23700recipient addresses with a message. If all the deliveries to a mailing list
23701cannot be done at the first attempt, the mailing list is re-expanded when the
23702delivery is next tried. This means that alterations to the list are taken into
23703account at each delivery attempt, so addresses that have been added to
23704the list since the message arrived will therefore receive a copy of the
23705message, even though it pre-dates their subscription.
23706
23707If this behaviour is felt to be undesirable, the \one@_time\ option can be set
23708on the \%redirect%\ router. If this is done, any addresses generated by the
23709router that fail to deliver at the first attempt are added to the message as
23710`top level' addresses, and the parent address that generated them is marked
23711`delivered'. Thus, expansion of the mailing list does not happen again at the
23712subsequent delivery attempts. The disadvantage of this is that if any of the
23713failing addresses are incorrect, correcting them in the file has no effect on
23714pre-existing messages.
23715
23716The original top-level address is remembered with each of the generated
23717addresses, and is output in any log messages. However, any intermediate parent
23718addresses are not recorded. This makes a difference to the log only if the
23719\all@_parents\ selector is set, but for mailing lists there is normally only
23720one level of expansion anyway.
23721
23722
23723.section Closed mailing lists
23724.index mailing lists||closed
23725The examples so far have assumed open mailing lists, to which anybody may
23726send mail. It is also possible to set up closed lists, where mail is accepted
23727from specified senders only. This is done by making use of the generic
23728\senders\ option to restrict the router that handles the list.
23729
23730The following example uses the same file as a list of recipients and as a list
23731of permitted senders. It requires three routers:
23732.display asis
23733lists_request:
23734 driver = redirect
23735 domains = lists.example
23736 local_part_suffix = -request
23737 file = /usr/lists/$local_part$local_part_suffix
23738 no_more
23739
23740lists_post:
23741 driver = redirect
23742 domains = lists.example
23743 senders = ${if exists {/usr/lists/$local_part}\
23744 {lsearch;/usr/lists/$local_part}{*}}
23745 file = /usr/lists/$local_part
23746 forbid_pipe
23747 forbid_file
23748 errors_to = $local_part-request@lists.example
23749 no_more
23750
23751lists_closed:
23752 driver = redirect
23753 domains = lists.example
23754 allow_fail
23755 data = :fail: $local_part@lists.example is a closed mailing list
23756.endd
23757All three routers have the same \domains\ setting, so for any other domains,
23758they are all skipped. The first router runs only if the local part ends in
23759\@-request\. It handles messages to the list manager(s) by means of an open
23760mailing list.
23761
23762The second router runs only if the \senders\ precondition is satisfied. It
23763checks for the existence of a list that corresponds to the local part, and then
23764checks that the sender is on the list by means of a linear search. It is
23765necessary to check for the existence of the file before trying to search it,
23766because otherwise Exim thinks there is a configuration error. If the file does
23767not exist, the expansion of \senders\ is $*$, which matches all senders. This
23768means that the router runs, but because there is no list, declines, and
23769\no@_more\ ensures that no further routers are run. The address fails with an
23770`unrouteable address' error.
23771
23772The third router runs only if the second router is skipped, which happens when
23773a mailing list exists, but the sender is not on it. This router forcibly fails
23774the address, giving a suitable error message.
23775
23776
23777
23778.section Virtual domains
23779.rset SECTvirtualdomains "~~chapter.~~section"
23780.index virtual domains
23781.index domain||virtual
23782The phrase \*virtual domain*\ is unfortunately used with two rather different
23783meanings:
23784.numberpars $.
23785A domain for which there are no real mailboxes; all valid local parts are
23786aliases for other email addresses. Common examples are organizational
23787top-level domains and `vanity' domains.
23788.nextp
23789One of a number of independent domains that are all handled by the same host,
23790with mailboxes on that host, but where the mailbox owners do not necessarily
23791have login accounts on that host.
23792.endp
23793The first usage is probably more common, and does seem more `virtual' than the
23794second. This kind of domain can be handled in Exim with a straightforward
23795aliasing router. One approach is to create a separate alias file for each
23796virtual domain. Exim can test for the existence of the alias file to determine
23797whether the domain exists. The \%dsearch%\ lookup type is useful here, leading
23798to a router of this form:
23799.display asis
23800virtual:
23801 driver = redirect
23802 domains = dsearch;/etc/mail/virtual
23803 data = ${lookup{$local_part}lsearch{/etc/mail/virtual/$domain}}
23804 no_more
23805.endd
23806The \domains\ option specifies that the router is to be skipped, unless there
23807is a file in the \(/etc/mail/virtual)\ directory whose name is the same as the
23808domain that is being processed. When the router runs, it looks up the local
23809part in the file to find a new address (or list of addresses). The \no@_more\
23810setting ensures that if the lookup fails (leading to \data\ being an empty
23811string), Exim gives up on the address without trying any subsequent routers.
23812
23813This one router can handle all the virtual domains because the alias file names
23814follow a fixed pattern. Permissions can be arranged so that appropriate people
23815can edit the different alias files. A successful aliasing operation results in
23816a new envelope recipient address, which is then routed from scratch.
23817
23818The other kind of `virtual' domain can also be handled in a straightforward
23819way. One approach is to create a file for each domain containing a list of
23820valid local parts, and use it in a router like this:
23821.display asis
23822my_domains:
23823 driver = accept
23824 domains = dsearch;/etc/mail/domains
23825 local_parts = lsearch;/etc/mail/domains/$domain
23826 transport = my_mailboxes
23827.endd
23828The address is accepted if there is a file for the domain, and the local part
23829can be found in the file. The \domains\ option is used to check for the file's
23830existence because \domains\ is tested before the \local@_parts\ option (see
23831section ~~SECTrouprecon). You can't use \require@_files\, because that option
23832is tested after \local@_parts\. The transport is as follows:
23833.display asis
23834my_mailboxes:
23835 driver = appendfile
23836 file = /var/mail/$domain/$local_part
23837 user = mail
23838.endd
23839This uses a directory of mailboxes for each domain. The \user\ setting is
23840required, to specify which uid is to be used for writing to the mailboxes.
23841
23842The configuration shown here is just one example of how you might support this
23843requirement. There are many other ways this kind of configuration can be set
23844up, for example, by using a database instead of separate files to hold all the
23845information about the domains.
23846
23847
23848.section Multiple user mailboxes
23849.rset SECTmulbox "~~chapter.~~section"
23850.index multiple mailboxes
23851.index mailbox||multiple
23852.index local part||prefix
23853.index local part||suffix
23854Heavy email users often want to operate with multiple mailboxes, into which
23855incoming mail is automatically sorted. A popular way of handling this is to
23856allow users to use multiple sender addresses, so that replies can easily be
23857identified. Users are permitted to add prefixes or suffixes to their local
23858parts for this purpose. The wildcard facility of the generic router options
23859\local@_part@_prefix\ and \local@_part@_suffix\ can be used for this. For
23860example, consider this router:
23861.display asis
23862userforward:
23863 driver = redirect
23864 check_local_user
23865 file = $home/.forward
23866 local_part_suffix = -*
23867 local_part_suffix_optional
23868 allow_filter
23869.endd
23870It runs a user's \(.forward)\ file for all local parts of the form
23871\*username-$*$*\. Within the filter file the user can distinguish different
23872cases by testing the variable \$local@_part@_suffix$\. For example:
23873.display asis
23874if $local_part_suffix contains -special then
23875 save /home/$local_part/Mail/special
23876endif
23877.endd
23878If the filter file does not exist, or does not deal with such addresses, they
23879fall through to subsequent routers, and, assuming no subsequent use of the
23880\local@_part@_suffix\ option is made, they presumably fail. Thus, users have
23881control over which suffixes are valid.
23882
23883Alternatively, a suffix can be used to trigger the use of a different
23884\(.forward)\ file -- which is the way a similar facility is implemented in
23885another MTA:
23886.display asis
23887userforward:
23888 driver = redirect
23889 check_local_user
23890 file = $home/.forward$local_part_suffix
23891 local_part_suffix = -*
23892 local_part_suffix_optional
23893 allow_filter
23894.endd
23895If there is no suffix, \(.forward)\ is used; if the suffix is \*-special*\, for
23896example, \(.forward-special)\ is used. Once again, if the appropriate file
23897does not exist, or does not deal with the address, it is passed on to
23898subsequent routers, which could, if required, look for an unqualified
23899\(.forward)\ file to use as a default.
23900
23901
23902.section Simplified vacation processing
23903.index vacation processing
23904The traditional way of running the \*vacation*\ program is for a user to set up
23905a pipe command in a \(.forward)\ file
23906(see section ~~SECTspecitredli for syntax details).
23907This is prone to error by inexperienced users. There are two features of Exim
23908that can be used to make this process simpler for users:
23909.numberpars $.
23910A local part prefix such as `vacation-' can be specified on a router which
23911can cause the message to be delivered directly to the \*vacation*\ program, or
23912alternatively can use Exim's \%autoreply%\ transport. The contents of a user's
23913\(.forward)\ file are then much simpler. For example:
23914.display asis
23915spqr, vacation-spqr
23916.endd
23917.nextp
23918The \require@_files\ generic router option can be used to trigger a
23919vacation delivery by checking for the existence of a certain file in the
23920user's home directory. The \unseen\ generic option should also be used, to
23921ensure that the original delivery also proceeds. In this case, all the user has
23922to do is to create a file called, say, \(.vacation)\, containing a vacation
23923message.
23924.endp
23925Another advantage of both these methods is that they both work even when the
23926use of arbitrary pipes by users is locked out.
23927
23928
23929.section Taking copies of mail
23930.index message||copying every
23931Some installations have policies that require archive copies of all messages to
23932be made. A single copy of each message can easily be taken by an appropriate
23933command in a system filter, which could, for example, use a different file for
23934each day's messages.
23935
23936There is also a shadow transport mechanism that can be used to take copies of
23937messages that are successfully delivered by local transports, one copy per
23938delivery. This could be used, $it{inter alia}, to implement automatic
23939notification of delivery by sites that insist on doing such things.
23940
23941
23942.section Intermittently connected hosts
23943.index intermittently connected hosts
23944It has become quite common (because it is cheaper) for hosts to connect to the
23945Internet periodically rather than remain connected all the time. The normal
23946arrangement is that mail for such hosts accumulates on a system that is
23947permanently connected.
23948
23949Exim was designed for use on permanently connected hosts, and so it is not
23950particularly well-suited to use in an intermittently connected environment.
23951Nevertheless there are some features that can be used.
23952
23953.section Exim on the upstream server host
23954It is tempting to arrange for incoming mail for the intermittently connected
23955host to remain on Exim's queue until the client connects. However, this
23956approach does not scale very well. Two different kinds of waiting message are
23957being mixed up in the same queue -- those that cannot be delivered because of
23958some temporary problem, and those that are waiting for their destination host
23959to connect. This makes it hard to manage the queue, as well as wasting
23960resources, because each queue runner scans the entire queue.
23961
23962A better approach is to separate off those messages that are waiting for an
23963intermittently connected host. This can be done by delivering these messages
23964into local files in batch SMTP, `mailstore', or other envelope-preserving
23965format, from where they are transmitted by other software when their
23966destination connects. This makes it easy to collect all the mail for one host
23967in a single directory, and to apply local timeout rules on a per-message basis
23968if required.
23969
23970On a very small scale, leaving the mail on Exim's queue can be made to work. If
23971you are doing this, you should configure Exim with a long retry period for the
23972intermittent host. For example:
23973.display
23974cheshire.wonderland.fict.example * F,5d,24h
23975.endd
23976This stops a lot of failed delivery attempts from occurring, but Exim remembers
23977which messages it has queued up for that host. Once the intermittent host comes
23978online, forcing delivery of one message (either by using the \-M-\ or \-R-\
23979options, or by using the \\ETRN\\ SMTP command (see section ~~SECTETRN)
23980causes all the queued up messages to be delivered, often down a single SMTP
23981connection. While the host remains connected, any new messages get delivered
23982immediately.
23983
23984If the connecting hosts do not have fixed IP addresses, that is, if a host is
23985issued with a different IP address each time it connects, Exim's retry
23986mechanisms on the holding host get confused, because the IP address is normally
23987used as part of the key string for holding retry information. This can be
23988avoided by unsetting \retry__include__ip__address\ on the \%smtp%\ transport.
23989Since this has disadvantages for permanently connected hosts, it is best to
23990arrange a separate transport for the intermittently connected ones.
23991
23992
23993.section Exim on the intermittently connected client host
23994The value of \smtp@_accept@_queue@_per@_connection\ should probably be
23995increased, or even set to zero (that is, disabled) on the intermittently
23996connected host, so that all incoming messages down a single connection get
23997delivered immediately.
23998
23999.index SMTP||passed connection
24000.index SMTP||multiple deliveries
24001.index multiple SMTP deliveries
24002Mail waiting to be sent from an intermittently connected host will probably
24003not have been routed, because without a connection DNS lookups are not
24004possible. This means that if a normal queue run is done at connection time,
24005each message is likely to be sent in a separate SMTP session. This can be
24006avoided by starting the queue run with a command line option beginning with
24007\-qq-\ instead of \-q-\. In this case, the queue is scanned twice. In the first
24008pass, routing is done but no deliveries take place. The second pass is a normal
24009queue run; since all the messages have been previously routed, those destined
24010for the same host are likely to get sent as multiple deliveries in a single
24011SMTP connection.
24012
24013
24014
24015
24016
24017.
24018.
24019.
24020.
24021. ============================================================================
24022.chapter SMTP processing
24023.set runningfoot "smtp processing"
24024.rset CHAPSMTP ~~chapter
24025.index SMTP||processing details
24026.index LMTP||processing details
24027Exim supports a number of different ways of using the SMTP protocol, and its
24028LMTP variant, which is an interactive protocol for transferring messages into a
24029closed mail store application. This chapter contains details of how SMTP is
24030processed. For incoming mail, the following are available:
24031.numberpars $.
24032SMTP over TCP/IP (Exim daemon or \*inetd*\);
24033.nextp
24034SMTP over the standard input and output (the \-bs-\ option);
24035.nextp
24036Batched SMTP on the standard input (the \-bS-\ option).
24037.endp
24038For mail delivery, the following are available:
24039.numberpars $.
24040SMTP over TCP/IP (the \%smtp%\ transport);
24041.nextp
24042LMTP over TCP/IP (the \%smtp%\ transport with the \protocol\ option set to
24043`lmtp');
24044.nextp
24045LMTP over a pipe to a process running in the local host (the \%lmtp%\
24046transport);
24047.nextp
24048Batched SMTP to a file or pipe (the \%appendfile%\ and \%pipe%\ transports with
24049the \use@_bsmtp\ option set).
24050.endp
24051\*Batched SMTP*\ is the name for a process in which batches of messages are
24052stored in or read from files (or pipes), in a format in which SMTP commands are
24053used to contain the envelope information.
24054
24055
24056.section Outgoing SMTP and LMTP over TCP/IP
24057.rset SECToutSMTPTCP "~~chapter.~~section"
24058.index SMTP||outgoing over TCP/IP
24059.index outgoing SMTP over TCP/IP
24060.index LMTP||over TCP/IP
24061.index outgoing LMTP over TCP/IP
24062.index \\EHLO\\
24063.index \\HELO\\
24064.index \\SIZE\\ option on \\MAIL\\ command
24065Outgoing SMTP and LMTP over TCP/IP is implemented by the \%smtp%\ transport.
24066The \protocol\ option selects which protocol is to be used, but the actual
24067processing is the same in both cases.
24068
24069If, in response to its \\EHLO\\ command, Exim is told that the \\SIZE\\
24070parameter is supported, it adds \\SIZE\\=<<n>> to each subsequent \\MAIL\\
24071command. The value of <<n>> is the message size plus the value of the
24072\size@_addition\ option (default 1024) to allow for additions to the message
24073such as per-transport header lines, or changes made in a
24074.index transport||filter
24075.index filter||transport filter
24076transport filter. If \size@_addition\ is set negative, the use of \\SIZE\\ is
24077suppressed.
24078
24079If the remote server advertises support for \\PIPELINING\\, Exim uses the
24080pipelining extension to SMTP (RFC 2197) to reduce the number of TCP/IP packets
24081required for the transaction.
24082
24083If the remote server advertises support for the \\STARTTLS\\ command, and Exim
24084was built to support TLS encryption, it tries to start a TLS session unless the
24085server matches \hosts@_avoid@_tls\. See chapter ~~CHAPTLS for more details.
24086
24087If the remote server advertises support for the \\AUTH\\ command, Exim scans
24088the authenticators configuration for any suitable client settings, as described
24089in chapter ~~CHAPSMTPAUTH.
24090
24091.index carriage return
24092.index linefeed
24093Responses from the remote host are supposed to be terminated by CR followed by
24094LF. However, there are known to be hosts that do not send CR characters, so in
24095order to be able to interwork with such hosts, Exim treats LF on its own as a
24096line terminator.
24097
24098If a message contains a number of different addresses, all those with the same
24099characteristics (for example, the same envelope sender) that resolve to the
24100same set of hosts, in the same order, are sent in a single SMTP transaction,
24101even if they are for different domains, unless there are more than the setting
24102of the \max@_rcpts\ option in the \%smtp%\ transport allows, in which case they
24103are split into groups containing no more than \max@_rcpts\ addresses each. If
24104\remote@_max@_parallel\ is greater than one, such groups may be sent in
24105parallel sessions. The order of hosts with identical MX values is not
24106significant when checking whether addresses can be batched in this way.
24107
24108When the \%smtp%\ transport suffers a temporary failure that is not
24109message-related, Exim updates its transport-specific database, which contains
24110records indexed by host name that remember which messages are waiting for each
24111particular host. It also updates the retry database with new retry times.
24112.index hints database||retry keys
24113Exim's retry hints are based on host name plus IP address, so if one address of
24114a multi-homed host is broken, it will soon be skipped most of the time.
24115See the next section for more detail about error handling.
24116
24117.index SMTP||passed connection
24118.index SMTP||batching over TCP/IP
24119When a message is successfully delivered over a TCP/IP SMTP connection, Exim
24120looks in the hints database for the transport to see if there are any queued
24121messages waiting for the host to which it is connected. If it finds one, it
24122creates a new Exim process using the \-MC-\ option (which can only be used by a
24123process running as root or the Exim user) and passes the TCP/IP socket to it so
24124that it can deliver another message using the same socket. The new process does
24125only those deliveries that are routed to the connected host, and may in turn
24126pass the socket on to a third process, and so on.
24127
24128The \connection@_max@_messages\ option of the \%smtp%\ transport can be used to
24129limit the number of messages sent down a single TCP/IP connection.
24130.index asterisk||after IP address
24131The second and subsequent messages delivered down an existing connection are
24132identified in the main log by the addition of an asterisk after the closing
24133square bracket of the IP address.
24134
24135
24136
24137.section Errors in outgoing SMTP
24138.rset SECToutSMTPerr "~~chapter.~~section"
24139.index error||in outgoing SMTP
24140.index SMTP||errors in outgoing
24141.index host||error
24142Three different kinds of error are recognized for outgoing SMTP: host errors,
24143message errors, and recipient errors.
24144.numberpars
24145A host error is not associated with a particular message or with a
24146particular recipient of a message. The host errors are:
24147.numberpars $.
24148Connection refused or timed out,
24149.nextp
24150Any error response code on connection,
24151.nextp
24152Any error response code to \\EHLO\\ or \\HELO\\,
24153.nextp
24154Loss of connection at any time, except after `.',
24155.nextp
24156I/O errors at any time,
24157.nextp
24158Timeouts during the session, other than in response to \\MAIL\\, \\RCPT\\ or
24159the `.' at the end of the data.
24160.endp
24161For a host error, a permanent error response on connection, or in response to
24162\\EHLO\\, causes all addresses routed to the host to be failed. Any other host
24163error causes all addresses to be deferred, and retry data to be created for the
24164host. It is not tried again, for any message, until its retry time arrives. If
24165the current set of addresses are not all delivered in this run (to some
24166alternative host), the message is added to the list of those waiting for this
24167host, so if it is still undelivered when a subsequent successful delivery is
24168made to the host, it will be sent down the same SMTP connection.
24169.nextp
24170.index message||error
24171A message error is associated with a particular message when sent to a
24172particular host, but not with a particular recipient of the message. The
24173message errors are:
24174.numberpars $.
24175Any error response code to \\MAIL\\, \\DATA\\, or the `.' that terminates
24176the data,
24177.nextp
24178Timeout after \\MAIL\\,
24179.nextp
24180Timeout
24181or loss of connection after the `.' that terminates the data. A timeout after
24182the \\DATA\\ command itself is treated as a host error, as is loss of
24183connection at any other time.
24184.endp
24185For a message error, a permanent error response (5$it{xx}) causes all addresses
24186to be failed, and a delivery error report to be returned to the sender. A
24187temporary error response (4$it{xx}), or one of the timeouts, causes all
24188addresses to be deferred. Retry data is not created for the host, but instead,
24189a retry record for the combination of host plus message id is created. The
24190message is not added to the list of those waiting for this host. This ensures
24191that the failing message will not be sent to this host again until the retry
24192time arrives. However, other messages that are routed to the host are not
24193affected, so if it is some property of the message that is causing the error,
24194it will not stop the delivery of other mail.
24195
24196If the remote host specified support for the \\SIZE\\ parameter in its response
24197to \\EHLO\\, Exim adds SIZE=$it{nnn} to the \\MAIL\\ command, so an
24198over-large message will cause a message error because the error arrives as a
24199response to \\MAIL\\.
24200.nextp
24201.index recipient||error
24202A recipient error is associated with a particular recipient of a message. The
24203recipient errors are:
24204.numberpars $.
24205Any error response to \\RCPT\\,
24206.nextp
24207Timeout after \\RCPT\\.
24208.endp
24209For a recipient error, a permanent error response (5$it{xx}) causes the
24210recipient address to be failed, and a bounce message to be returned to the
24211sender. A temporary error response (4$it{xx}) or a timeout causes the failing
24212address to be deferred, and routing retry data to be created for it. This is
24213used to delay processing of the address in subsequent queue runs, until its
24214routing retry time arrives. This applies to all messages, but because it
24215operates only in queue runs, one attempt will be made to deliver a new message
24216to the failing address before the delay starts to operate. This ensures that,
24217if the failure is really related to the message rather than the recipient
24218(`message too big for this recipient' is a possible example), other messages
24219have a chance of getting delivered. If a delivery to the address does succeed,
24220the retry information gets cleared, so all stuck messages get tried again, and
24221the retry clock is reset.
24222
24223The message is not added to the list of those waiting for this host. Use of the
24224host for other messages is unaffected, and except in the case of a timeout,
24225other recipients are processed independently, and may be successfully delivered
24226in the current SMTP session. After a timeout it is of course impossible to
24227proceed with the session, so all addresses get deferred. However, those other
24228than the one that failed do not suffer any subsequent retry delays. Therefore,
24229if one recipient is causing trouble, the others have a chance of getting
24230through when a subsequent delivery attempt occurs before the failing
24231recipient's retry time.
24232.endp
24233
24234In all cases, if there are other hosts (or IP addresses) available for the
24235current set of addresses (for example, from multiple MX records), they are
24236tried in this run for any undelivered addresses, subject of course to their
24237own retry data. In other words, recipient error retry data does not take effect
24238until the next delivery attempt.
24239
24240Some hosts have been observed to give temporary error responses to every
24241\\MAIL\\ command at certain times (`insufficient space' has been seen). It
24242would be nice if such circumstances could be recognized, and defer data for the
24243host itself created, but this is not possible within the current Exim design.
24244What actually happens is that retry data for every (host, message) combination
24245is created.
24246
24247The reason that timeouts after \\MAIL\\ and \\RCPT\\ are treated specially is
24248that these can sometimes arise as a result of the remote host's verification
24249procedures. Exim makes this assumption, and treats them as if a temporary error
24250response had been received. A timeout after `.' is treated specially because it
24251is known that some broken implementations fail to recognize the end of the
24252message if the last character of the last line is a binary zero. Thus, it is
24253helpful to treat this case as a message error.
24254
24255Timeouts at other times are treated as host errors, assuming a problem with the
24256host, or the connection to it. If a timeout after \\MAIL\\, \\RCPT\\,
24257or `.' is really a connection problem, the assumption is that at the next try
24258the timeout is likely to occur at some other point in the dialogue, causing it
24259then to be treated as a host error.
24260
24261There is experimental evidence that some MTAs drop the connection after the
24262terminating `.' if they do not like the contents of the message for some
24263reason, in contravention of the RFC, which indicates that a 5$it{xx} response
24264should be given. That is why Exim treats this case as a message rather than a
24265host error, in order not to delay other messages to the same host.
24266
24267
24268
24269
24270.section Variable Envelope Return Paths (VERP)
24271.index VERP
24272.index Variable Envelope Return Paths
24273.index envelope sender
24274Variable Envelope Return Paths -- see
24275\?ftp://koobera.math.uic.edu/www/proto/verp.txt?\ -- can be supported in Exim
24276by using the \return@_path\ generic transport option to rewrite the return path
24277at transport time. For example, the following could be used on an \%smtp%\
24278transport:
24279.display asis
24280return_path = \
24281 ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
24282 {$1-request=$local_part%$domain@your.dom.example}fail}
24283.endd
24284This has the effect of rewriting the return path (envelope sender) on all
24285outgoing SMTP messages, if the local part of the original return path ends in
24286`-request', and the domain is \*your.dom.example*\. The rewriting inserts the
24287local part and domain of the recipient into the return path. Suppose, for
24288example, that a message whose return path has been set to
24289\*somelist-request@@your.dom.example*\ is sent to
24290\*subscriber@@other.dom.example*\. In the transport, the return path is
24291rewritten as
24292.display asis
24293somelist-request=subscriber%other.dom.example@your.dom.example
24294.endd
24295For this to work, you must arrange for outgoing messages that have `-request'
24296in their return paths to have just a single recipient. This can be done by
24297setting
24298.display asis
24299max_rcpt = 1
24300.endd
24301in the \%smtp%\ transport. Otherwise a single copy of a message might be
24302addressed to several different recipients in the same domain, in which case
24303\$local@_part$\ is not available (because it is not unique). Of course, if you
24304do start sending out messages with this kind of return path, you must also
24305configure Exim to accept the bounce messages that come back to those paths.
24306Typically this would be done by setting an \local@_part@_suffix\ option for a
24307suitable router.
24308
24309The overhead incurred in using VERP depends very much on the size of the
24310message, the number of recipient addresses that resolve to the same remote
24311host, and the speed of the connection over which the message is being sent. If
24312a lot of addresses resolve to the same host and the connection is slow, sending
24313a separate copy of the message for each address may take substantially longer
24314than sending a single copy with many recipients (for which VERP cannot be
24315used).
24316
24317
24318.section Incoming SMTP messages over TCP/IP
24319.index SMTP||incoming over TCP/IP
24320.index incoming SMTP over TCP/IP
24321.index inetd
24322.index daemon
24323Incoming SMTP messages can be accepted in one of two ways: by running a
24324listening daemon, or by using \*inetd*\. In the latter case, the entry in
24325\(/etc/inetd.conf)\ should be like this:
24326.display asis
24327smtp stream tcp nowait exim /opt/exim/bin/exim in.exim -bs
24328.endd
24329Exim distinguishes between this case and the case of a locally running user
24330agent using the \-bs-\ option by checking whether or not the standard input is
24331a socket. When it is, either the port must be privileged (less than 1024), or
24332the caller must be root or the Exim user. If any other user passes a socket
24333with an unprivileged port number, Exim prints a message on the standard error
24334stream and exits with an error code.
24335
24336By default, Exim does not make a log entry when a remote host connects or
24337disconnects (either via the daemon or \*inetd*\), unless the disconnection is
24338unexpected. It can be made to write such log entries by setting the
24339\smtp@_connection\ log selector.
24340
24341.index carriage return
24342.index linefeed
24343Commands from the remote host are supposed to be terminated by CR followed by
24344LF. However, there are known to be hosts that do not send CR characters. In
24345order to be able to interwork with such hosts, Exim treats LF on its own as a
24346line terminator.
24347Furthermore, because common code is used for receiving messages from all
24348sources, a CR on its own is also interpreted as a line terminator. However, the
24349sequence `CR, dot, CR' does not terminate incoming SMTP data.
24350
24351.index \\EHLO\\||invalid data
24352.index \\HELO\\||invalid data
24353One area that sometimes gives rise to problems concerns the \\EHLO\\ or
24354\\HELO\\ commands. Some clients send syntactically invalid versions of these
24355commands, which Exim rejects by default. (This is nothing to do with verifying
24356the data that is sent, so \helo@_verify@_hosts\ is not relevant.) You can tell
24357Exim not to apply a syntax check by setting \helo@_accept@_junk@_hosts\ to
24358match the broken hosts that send invalid commands.
24359
24360.index \\SIZE\\ option on \\MAIL\\ command
24361.index \\MAIL\\||\\SIZE\\ option
24362The amount of disk space available is checked whenever \\SIZE\\ is received on
24363a \\MAIL\\ command, independently of whether \message@_size@_limit\ or
24364\check@_spool@_space\ is configured, unless \smtp__check__spool__space\ is set
24365false. A temporary error is given if there is not enough space. If
24366\check@_spool@_space\ is set, the check is for that amount of space plus the
24367value given with \\SIZE\\, that is, it checks that the addition of the incoming
24368message will not reduce the space below the threshold.
24369
24370When a message is successfully received, Exim includes the local message id in
24371its response to the final `.' that terminates the data. If the remote host logs
24372this text it can help with tracing what has happened to a message.
24373
24374The Exim daemon can limit the number of simultaneous incoming connections it is
24375prepared to handle (see the \smtp@_accept@_max\ option). It can also limit the
24376number of simultaneous incoming connections from a single remote host (see the
24377\smtp@_accept@_max@_per@_host\ option). Additional connection attempts are
24378rejected using the SMTP temporary error code 421.
24379
24380The Exim daemon does not rely on the \\SIGCHLD\\ signal to detect when a
24381subprocess has finished, as this can get lost at busy times. Instead, it looks
24382for completed subprocesses every time it wakes up. Provided there are other
24383things happening (new incoming calls, starts of queue runs), completed
24384processes will be noticed and tidied away. On very quiet systems you may
24385sometimes see a `defunct' Exim process hanging about. This is not a problem; it
24386will be noticed when the daemon next wakes up.
24387
24388When running as a daemon, Exim can reserve some SMTP slots for specific hosts,
24389and can also be set up to reject SMTP calls from non-reserved hosts at times of
24390high system load -- for details see the \smtp@_accept@_reserve\,
24391\smtp@_load@_reserve\, and \smtp@_reserve@_hosts\ options. The load check
24392applies in both the daemon and \*inetd*\ cases.
24393
24394Exim normally starts a delivery process for each message received, though this
24395can be varied by means of the \-odq-\ command line option and the
24396\queue@_only\, \queue@_only@_file\, and \queue@_only@_load\ options. The number
24397of simultaneously running delivery processes started in this way from SMTP
24398input can be limited by the \smtp__accept__queue\ and
24399\smtp__accept__queue__per__connection\ options. When either limit is reached,
24400subsequently received messages are just put on the input queue without starting
24401a delivery process.
24402
24403The controls that involve counts of incoming SMTP calls (\smtp@_accept@_max\,
24404\smtp@_accept@_queue\, \smtp__accept__reserve\) are not available when Exim is
24405started up from the \*inetd*\ daemon, because in that case each connection is
24406handled by an entirely independent Exim process. Control by load average is,
24407however, available with \*inetd*\.
24408
24409Exim can be configured to verify addresses in incoming SMTP commands as they
24410are received. See chapter ~~CHAPACL for details. It can also be configured to
24411rewrite addresses at this time -- before any syntax checking is done. See
24412section ~~SECTrewriteS.
24413
24414Exim can also be configured to limit the rate at which a client host submits
24415\\MAIL\\ and \\RCPT\\ commands in a single SMTP session. See the
24416\smtp@_ratelimit@_hosts\ option.
24417
24418
24419.section Unrecognized SMTP commands
24420.index SMTP||unrecognized commands
24421If Exim receives more than \smtp@_max@_unknown@_commands\ unrecognized SMTP
24422commands during a single SMTP connection, it drops the connection after sending
24423the error response to the last command. The default value for
24424\smtp@_max@_unknown@_commands\ is 3. This is a defence against some kinds of
24425abuse that subvert web servers into making connections to SMTP ports; in these
24426circumstances, a number of non-SMTP lines are sent first.
24427
24428.section Syntax and protocol errors in SMTP commands
24429.index SMTP||syntax errors
24430.index SMTP||protocol errors
24431A syntax error is detected if an SMTP command is recognized, but there is
24432something syntactically wrong with its data, for example, a malformed email
24433address in a \\RCPT\\ command. Protocol errors include invalid command
24434sequencing such as \\RCPT\\ before \\MAIL\\. If Exim receives more than
24435\smtp@_max@_synprot@_errors\ such commands during a single SMTP connection, it
24436drops the connection after sending the error response to the last command. The
24437default value for \smtp__max__synprot__errors\ is 3. This is a defence against
24438broken clients that loop sending bad commands (yes, it has been seen).
24439
24440
24441.section Use of non-mail SMTP commands
24442.index SMTP||non-mail commands
24443The `non-mail' SMTP commands are those other than \\MAIL\\, \\RCPT\\, and
24444\\DATA\\. Exim counts such commands, and drops the connection if there are too
24445many of them in a single SMTP session. This action catches some
24446denial-of-service attempts and things like repeated failing \\AUTH\\s, or a mad
24447client looping sending \\EHLO\\. The global option \smtp@_accept@_max@_nonmail\
24448defines what `too many' means. Its default value is 10.
24449
24450When a new message is expected, one occurrence of \\RSET\\ is not counted. This
24451allows a client to send one \\RSET\\ between messages (this is not necessary,
24452but some clients do it). Exim also allows one uncounted occurence of \\HELO\\
24453or \\EHLO\\, and one occurrence of \\STARTTLS\\ between messages. After
24454starting up a TLS session, another \\EHLO\\ is expected, and so it too is not
24455counted.
24456
24457The first occurrence of \\AUTH\\ in a connection, or immediately following
24458\\STARTTLS\\ is also not counted. Otherwise, all commands other than \\MAIL\\,
24459\\RCPT\\, \\DATA\\, and \\QUIT\\ are counted.
24460
24461You can control which hosts are subject to the limit set by
24462\smtp@_accept@_max@_nonmail\ by setting
24463\smtp@_accept@_max@_nonmail@_hosts\. The default value is \"$*$"\, which makes
24464the limit apply to all hosts. This option means that you can exclude any
24465specific badly-behaved hosts that you have to live with.
24466
24467
24468
24469.section The \\VRFY\\ and \\EXPN\\ commands
24470When Exim receives a \\VRFY\\ or \\EXPN\\ command on a TCP/IP connection, it
24471runs the ACL specified by \acl@_smtp@_vrfy\ or \acl@_smtp@_expn\ (as
24472appropriate) in order to decide whether the command should be accepted or not.
24473If no ACL is defined, the command is rejected.
24474
24475.index \\VRFY\\||processing
24476When \\VRFY\\ is accepted, it runs exactly the same code as when Exim is
24477called with the \-bv-\ option.
24478.index \\EXPN\\||processing
24479When \\EXPN\\ is accepted, a single-level expansion of the address is done.
24480\\EXPN\\ is treated as an `address test' (similar to the \-bt-\ option) rather
24481than a verification (the \-bv-\ option). If an unqualified local part is given
24482as the argument to \\EXPN\\, it is qualified with \qualify@_domain\. Rejections
24483of \\VRFY\\ and \\EXPN\\ commands are logged on the main and reject logs, and
24484\\VRFY\\ verification failures are logged on the main log for consistency with
24485\\RCPT\\ failures.
24486
24487
24488.section The \\ETRN\\ command
24489.rset SECTETRN "~~chapter.~~section"
24490.index \\ETRN\\||processing
24491RFC 1985 describes an SMTP command called \\ETRN\\ that is designed to
24492overcome the security problems of the \\TURN\\ command (which has fallen into
24493disuse). When Exim receives an \\ETRN\\ command on a TCP/IP connection, it runs
24494the ACL specified by \acl@_smtp@_etrn\ in order to decide whether the command
24495should be accepted or not. If no ACL is defined, the command is rejected.
24496
24497The \\ETRN\\ command is concerned with `releasing' messages that are awaiting
24498delivery to certain hosts. As Exim does not organize its message queue by host,
24499the only form of \\ETRN\\ that is supported by default is the one where the
24500text starts with the `@#' prefix, in which case the remainder of the text is
24501specific to the SMTP server. A valid \\ETRN\\ command causes a run of Exim with
24502the \-R-\ option to happen, with the remainder of the \\ETRN\\ text as its
24503argument. For example,
24504.display asis
24505ETRN #brigadoon
24506.endd
24507runs the command
24508.display asis
24509exim -R brigadoon
24510.endd
24511which causes a delivery attempt on all messages with undelivered addresses
24512containing the text `brigadoon'. When \smtp@_etrn@_serialize\ is set (the
24513default), Exim prevents the simultaneous execution of more than one queue run
24514for the same argument string as a result of an \\ETRN\\ command. This stops
24515a misbehaving client from starting more than one queue runner at once.
24516
24517.index hints database||\\ETRN\\ serialization
24518Exim implements the serialization by means of a hints database in which a
24519record is written whenever a process is started by \\ETRN\\, and deleted when
24520the process completes. However, Exim does not keep the SMTP session waiting for
24521the \\ETRN\\ process to complete. Once \\ETRN\\ is accepted, the client is sent
24522a `success' return code. Obviously there is scope for hints records to get left
24523lying around if there is a system or program crash. To guard against this, Exim
24524ignores any records that are more than six hours old.
24525
24526.index \smtp@_etrn@_command\
24527For more control over what \\ETRN\\ does, the \smtp@_etrn@_command\ option can
24528used. This specifies a command that is run whenever \\ETRN\\ is received,
24529whatever the form of its argument. For
24530example:
24531.display asis
24532smtp_etrn_command = /etc/etrn_command $domain $sender_host_address
24533.endd
24534The string is split up into arguments which are independently expanded. The
24535expansion variable \$domain$\ is set to the argument of the \\ETRN\\ command,
24536and no syntax checking is done on the contents of this argument. Exim does not
24537wait for the command to complete, so its status code is not checked. Exim runs
24538under its own uid and gid when receiving incoming SMTP, so it is not possible
24539for it to change them before running the command.
24540
24541
24542.section Incoming local SMTP
24543.index SMTP||local incoming
24544Some user agents use SMTP to pass messages to their local MTA using the
24545standard input and output, as opposed to passing the envelope on the command
24546line and writing the message to the standard input. This is supported by the
24547\-bs-\ option. This form of SMTP is handled in the same way as incoming
24548messages over TCP/IP (including the use of ACLs), except that the envelope
24549sender given in a \\MAIL\\ command is ignored unless the caller is trusted. In
24550an ACL you can detect this form of SMTP input by testing for an empty host
24551identification. It is common to have this as the first line in the ACL that
24552runs for \\RCPT\\ commands:
24553.display asis
24554accept hosts = :
24555.endd
24556This accepts SMTP messages from local processes without doing any other tests.
24557
24558
24559.section Outgoing batched SMTP
24560.rset SECTbatchSMTP "~~chapter.~~section"
24561.index SMTP||batched outgoing
24562.index batched SMTP output
24563Both the \%appendfile%\ and \%pipe%\ transports can be used for handling batched
24564SMTP. Each has an option called \use@_bsmtp\ which causes messages to be output
24565in BSMTP format. No SMTP responses are possible for this form of delivery. All
24566it is doing is using SMTP commands as a way of transmitting the envelope along
24567with the message.
24568
24569The message is written to the file or pipe preceded by the SMTP commands
24570\\MAIL\\ and \\RCPT\\, and followed by a line containing a single dot. Lines in
24571the message that start with a dot have an extra dot added. The SMTP command
24572\\HELO\\ is not normally used. If it is required, the \message@_prefix\ option
24573can be used to specify it.
24574
24575Because \%appendfile%\ and \%pipe%\ are both local transports, they accept only
24576one recipient address at a time by default. However, you can arrange for them
24577to handle several addresses at once by setting the \batch@_max\ option. When
24578this is done for BSMTP, messages may contain multiple \\RCPT\\ commands. See
24579chapter ~~CHAPbatching for more details.
24580
24581When one or more addresses are routed to a BSMTP transport by a router that
24582sets up a host list, the name of the first host on the list is available to the
24583transport in the variable \$host$\. Here is an example of such a transport and
24584router:
24585.display asis
24586begin routers
24587route_append:
24588 driver = manualroute
24589 transport = smtp_appendfile
24590 route_list = domain.example batch.host.example
24591
24592begin transports
24593smtp_appendfile:
24594 driver = appendfile
24595 directory = /var/bsmtp/$host
24596 batch_max = 1000
24597 use_bsmtp
24598 user = exim
24599.endd
24600This causes messages addressed to \*domain.example*\ to be written in BSMTP
24601format to \(/var/bsmtp/batch.host.example)\, with only a single copy of each
24602message (unless there are more than 1000 recipients).
24603
24604
24605.section Incoming batched SMTP
24606.rset SECTincomingbatchedSMTP "~~chapter.~~section"
24607.index SMTP||batched incoming
24608.index batched SMTP input
24609The \-bS-\ command line option causes Exim to accept one or more messages by
24610reading SMTP on the standard input, but to generate no responses. If the caller
24611is trusted, the senders in the \\MAIL\\ commands are believed; otherwise the
24612sender is always the caller of Exim. Unqualified senders and receivers are not
24613rejected (there seems little point) but instead just get qualified. \\HELO\\
24614and \\EHLO\\ act as \\RSET\\; \\VRFY\\, \\EXPN\\, \\ETRN\\ and \\HELP\\, act
24615as \\NOOP\\; \\QUIT\\ quits.
24616
24617No policy checking is done for BSMTP input. That is, no ACL is run at anytime.
24618In this respect it is like non-SMTP local input.
24619
24620If an error is detected while reading a message, including a missing `.' at
24621the end, Exim gives up immediately. It writes details of the error to the
24622standard output in a stylized way that the calling program should be able to
24623make some use of automatically, for example:
24624.display asis
24625554 Unexpected end of file
24626Transaction started in line 10
24627Error detected in line 14
24628.endd
24629It writes a more verbose version, for human consumption, to the standard error
24630file, for example:
24631.display asis
24632An error was detected while processing a file of BSMTP input.
24633The error message was:
24634
24635 501 '>' missing at end of address
24636
24637The SMTP transaction started in line 10.
24638The error was detected in line 12.
24639The SMTP command at fault was:
24640
24641 rcpt to:<malformed@in.com.plete
24642
246431 previous message was successfully processed.
24644The rest of the batch was abandoned.
24645.endd
24646The return code from Exim is zero only if there were no errors. It is 1 if some
24647messages were accepted before an error was detected, and 2 if no messages were
24648accepted.
24649
24650
24651
24652
24653.
24654.
24655.
24656.
24657. ============================================================================
24658.chapter Message processing
24659.set runningfoot "message processing"
24660.rset CHAPmsgproc "~~chapter"
24661.index message||general processing
24662Exim performs various transformations on the sender and recipient addresses of
24663all messages that it handles, and also on the messages' header lines. Some of
24664these are optional and configurable, while others always take place. All of
24665this processing, except rewriting as a result of routing, and the addition or
24666removal of header lines while delivering, happens when a message is received,
24667before it is placed on Exim's queue.
24668
24669Some of the automatic processing takes place
24670.em
24671by default
24672.nem
24673only for `locally-originated' messages. This adjective is used to describe
24674messages that are not received over TCP/IP, but instead are passed to an Exim
24675process on its standard input. This includes the interactive `local SMTP' case
24676that is set up by the \-bs-\ command line option. \**Note**\: messages received
24677over TCP/IP on the loopback interface (127.0.0.1 or @:@:1) are not considered
24678to be locally-originated. Exim does not treat the loopback interface specially
24679in any way.
24680
24681.em
24682.index message||submission
24683Processing that happens automatically for locally-originated messages can also
24684be requested for other messages. This is done by obeying the modifier
24685.display asis
24686control = submission
24687.endd
24688in one of the ACLs that are run for an incoming message (see section
24689~~SECTACLmodi). This makes Exim treat the message as a local submission, and is
24690normally used when the source of the message is known to be an MUA running on a
24691client host (as opposed to an MTA). In the descriptions below, the term
24692`submission mode' is used to describe this state.
24693
24694When a ::From:: or ::Sender:: header is generated in submission mode, the value
24695of \qualify@_domain\ is used by default. However, it is possible to specify
24696another domain by a setting such as
24697.display asis
24698control = submission/domain=some.other.domain
24699.endd
24700.nem
24701
24702
24703
24704.section Line endings
24705.rset SECTlineendings "~~chapter.~~section"
24706.index line endings
24707.index carriage return
24708.index linefeed
24709RFC 2821 specifies that CRLF (two characters: carriage-return, followed by
24710linefeed) is the line ending for messages transmitted over the Internet using
24711SMTP over TCP/IP. However, within individual operating systems, different
24712conventions are used. For example, Unix-like systems use just LF, but others
24713use CRLF or just CR.
24714
24715Exim was designed for Unix-like systems, and internally, it stores messages
24716using the system's convention of a single LF as a line terminator. When
24717receiving a message, all line endings are translated to this standard format.
24718Originally, it was thought that programs that passed messages directly to an
24719MTA within an operating system would use that system's convention. Experience
24720has shown that this is not the case; for example, there are Unix applications
24721that use CRLF in this circumstance. For this reason, and for compatibility with
24722other MTAs, the way Exim handles line endings for all messages is now as
24723follows:
24724.numberpars $.
24725LF not preceded by CR is treated as a line ending.
24726.nextp
24727CR is treated as a line ending; if it is immediately followed by LF, the LF
24728is ignored.
24729.nextp
24730The sequence `CR, dot, CR' does not terminate an incoming SMTP message,
24731nor a local message in the state where a line containing only a dot is a
24732terminator.
24733.nextp
24734If a bare CR is encountered within a header line, an extra space is added after
24735the line terminator so as not to end the header line. The reasoning behind this
24736is that bare CRs in header lines are most likely either to be mistakes, or
24737people trying to play silly games.
24738.nextp
24739.em
24740If the first header line received in a message ends with CRLF, a subsequent
24741bare LF in a header line is treated in the same way as a bare CR in a header
24742line.
24743.nem
24744.endp
24745
24746
24747
24748.section Unqualified addresses
24749.index unqualified addresses
24750.index address||qualification
24751By default, Exim expects every address it receives from an external host to be
24752fully qualified. Unqualified addresses cause negative responses to SMTP
24753commands. However, because SMTP is used as a means of transporting messages
24754from MUAs running on personal workstations, there is sometimes a requirement to
24755accept unqualified addresses from specific hosts or IP networks.
24756
24757Exim has two options that separately control which hosts may send unqualified
24758sender or receipient addresses in SMTP commands, namely
24759\sender__unqualified__hosts\ and \recipient__unqualified__hosts\. In both
24760cases, if an unqualified address is accepted, it is qualified by adding the
24761value of \qualify__domain\ or \qualify__recipient\, as appropriate.
24762.index \qualify@_domain\
24763.index \qualify@_recipient\
24764
24765
24766.section The UUCP From line
24767.index `From' line
24768.index UUCP||`From' line
24769.index sender||address
24770.index \uucp@_from@_pattern\
24771.index \uucp@_from@_sender\
24772.index envelope sender
24773.index Sendmail compatibility||`From' line
24774Messages that have come from UUCP (and some other applications) often begin
24775with a line containing the envelope sender and a timestamp, following the word
24776`From'. Examples of two common formats are:
24777.display asis
24778From a.oakley@berlin.mus Fri Jan 5 12:35 GMT 1996
24779From f.butler@berlin.mus Fri, 7 Jan 97 14:00:00 GMT
24780.endd
24781This line precedes the RFC 2822 header lines. For compatibility with Sendmail,
24782Exim recognizes such lines at the start of messages that are submitted to it
24783via the command line (that is, on the standard input). It does not recognize
24784such lines in incoming SMTP messages, unless the sending host matches
24785\ignore@_fromline@_hosts\ or the \-bs-\ option was used for a local message and
24786\ignore@_fromline@_local\ is set. The recognition is controlled by a regular
24787expression that is defined by the \uucp@_from@_pattern\ option, whose default
24788value matches the two common cases shown above and puts the address that
24789follows `From' into \$1$\.
24790
24791.index numerical variables (\$1$\, \$2$\, etc)||in `From ' line handling
24792When the caller of Exim for a non-SMTP message that contains a `From' line is a
24793trusted user, the message's sender address is constructed by expanding the
24794contents of \uucp@_sender@_address\, whose default value is `@$1'. This is then
24795parsed as an RFC 2822 address. If there is no domain, the local part is
24796qualified with \qualify@_domain\ unless it is the empty string. However, if the
24797command line \-f-\ option is used, it overrides the `From' line.
24798
24799If the caller of Exim is not trusted, the `From' line is recognized, but the
24800sender address is not changed. This is also the case for incoming SMTP messages
24801that are permitted to contain `From' lines.
24802
24803Only one `From' line is recognized. If there is more than one, the second is
24804treated as a data line that starts the body of the message, as it is not valid
24805as a header line. This also happens if a `From' line is present in an incoming
24806SMTP message from a source that is not permitted to send them.
24807
24808
24809.section Resent- header lines
24810.index \Resent@-\ header lines
24811RFC 2822 makes provision for sets of header lines starting with the string
24812\"Resent-"\ to be added to a message when it is resent by the original
24813recipient to somebody else. These headers are ::Resent-Date::, ::Resent-From::,
24814::Resent-Sender::, ::Resent-To::, ::Resent-Cc::, ::Resent-Bcc:: and
24815::Resent-Message-ID::. The RFC says:
24816
24817\*Resent fields are strictly informational. They MUST NOT be used in the normal
24818processing of replies or other such automatic actions on messages.*\
24819
24820This leaves things a bit vague as far as other processing actions such as
24821address rewriting are concerned. Exim treats \Resent@-\ header lines as
24822follows:
24823.numberpars $.
24824A ::Resent-From:: line that just contains the login id of the submitting user
24825is automatically rewritten in the same way as ::From:: (see below).
24826.nextp
24827If there's a rewriting rule for a particular header line, it is also applied to
24828\Resent@-\ header lines of the same type. For example, a rule that rewrites
24829::From:: also rewrites ::Resent-From::.
24830.nextp
24831For local messages, if ::Sender:: is removed on input, ::Resent-Sender:: is also
24832removed.
24833.nextp
24834For a locally-submitted message,
24835if there are any \Resent@-\ header lines but no ::Resent-Date::,
24836::Resent-From::, or ::Resent-Message-Id::, they are added as necessary. It is
24837the contents of ::Resent-Message-Id:: (rather than ::Message-Id::) which are
24838included in log lines in this case.
24839.nextp
24840The logic for adding ::Sender:: is duplicated for ::Resent-Sender:: when any
24841\Resent@-\ header lines are present.
24842.endp
24843
24844
24845.section The Auto-Submitted: header line
24846Whenever Exim generates a bounce or a delay warning message, it includes the
24847header line
24848.display asis
24849Auto-Submitted: auto-generated
24850.endd
24851
24852
24853.section The Bcc: header line
24854.index ::Bcc:: header line
24855If Exim is called with the \-t-\ option, to take recipient addresses from a
24856message's header, it removes any ::Bcc:: header line that may exist (after
24857extracting its addresses). If \-t-\ is not present on the command line, any
24858existing ::Bcc:: is not removed.
24859
24860.section The Date: header line
24861.index ::Date:: header line
24862If a locally-generated
24863.em
24864or submission-mode
24865.nem
24866message has no ::Date:: header line, Exim adds one, using the current date and
24867time.
24868
24869.section The Delivery-date: header line
24870.index ::Delivery-date:: header line
24871.index \delivery@_date@_remove\
24872::Delivery-date:: header lines are not part of the standard RFC 2822 header
24873set. Exim can be configured to add them to the final delivery of messages. (See
24874the generic \delivery@_date@_add\ transport option.) They should not be present
24875in messages in transit. If the \delivery@_date@_remove\ configuration option is
24876set (the default), Exim removes ::Delivery-date:: header lines from incoming
24877messages.
24878
24879.section The Envelope-to: header line
24880.index ::Envelope-to:: header line
24881.index \envelope@_to@_remove\
24882::Envelope-to:: header lines are not part of the standard RFC 2822 header set.
24883Exim can be configured to add them to the final delivery of messages. (See the
24884generic \envelope@_to@_add\ transport option.) They should not be present in
24885messages in transit. If the \envelope@_to@_remove\ configuration option is set
24886(the default), Exim removes ::Envelope-to:: header lines from incoming
24887messages.
24888
24889.section The From: header line
24890.index ::From:: header line
24891.index Sendmail compatibility||`From' line
24892.em
24893If a submission-mode message does not contain a ::From:: header line, Exim adds
24894one if either of the following conditions is true:
24895.numberpars alpha
24896The envelope sender address is not empty (that is, this is not a bounce
24897message); the added header line copies the envelope sender address.
24898.nextp
24899The SMTP session is authenticated and \$authenticated@_id$\ is not empty; the
24900added header's local part is \$authenticated@_id$\ and the domain is
24901the domain specified on the submission control, or \$qualify@_domain$\ if that
24902is not set.
24903.endp
24904A non-empty envelope sender takes precedence.
24905.nem
24906
24907If a locally-generated incoming message does not contain a ::From:: header
24908line, Exim adds one containing the sender's address. The calling user's login
24909name and full name are used to construct the address, as described in section
24910~~SECTconstr. They are obtained from the password data by calling
24911\*getpwuid()*\ (but see the \unknown@_login\ configuration option). The address
24912is qualified with \qualify@_domain\.
24913
24914For compatibility with Sendmail, if an incoming, non-SMTP message has a
24915::From:: header line containing just the unqualified login name of the calling
24916user, this is replaced by an address containing the user's login name and full
24917name as described in section ~~SECTconstr.
24918
24919.section The Message-ID: header line
24920.index ::Message-ID:: header line
24921If a locally-generated
24922.em
24923or submission-mode
24924.nem
24925incoming message does not contain a ::Message-ID:: or ::Resent-Message-ID::
24926header line, Exim adds one to the message. If there are any ::Resent-:: headers
24927in the message, it creates ::Resent-Message-ID::. The id is constructed from
24928Exim's internal message id, preceded by the letter E to ensure it starts with a
24929letter, and followed by @@ and the primary host name. Additional information
24930can be included in this header line by setting the
24931.index \message@_id@_header@_text\
24932\message@_id@_header@_text\ and/or \message__id__header__domain\ options.
24933
24934
24935.section The Received: header line
24936.index ::Received:: header line
24937A ::Received:: header line is added at the start of every message. The contents
24938are defined by the \received@_header@_text\ configuration option, and Exim
24939automatically adds a semicolon and a timestamp to the configured string.
24940
24941.em
24942The ::Received:: header is generated as soon as the message's header lines have
24943been received. At this stage, the timestamp in the ::Received:: header line is
24944the time that the message started to be received. This is the value that is
24945seen by the \\DATA\\ ACL and by the \*local@_scan()*\ function.
24946
24947Once a message is accepted, the timestamp in the ::Received:: header line is
24948changed to the time of acceptance, which is (apart from a small delay while the
24949-H spool file is written) the earliest time at which delivery could start.
24950.nem
24951
24952
24953.section The Return-path: header line
24954.index ::Return-path:: header line
24955.index \return@_path@_remove\
24956::Return-path:: header lines are defined as something an MTA may insert when
24957it does the final delivery of messages. (See the generic \return@_path@_add\
24958transport option.) Therefore, they should not be present in messages in
24959transit. If the \return@_path@_remove\ configuration option is set (the
24960default), Exim removes ::Return-path:: header lines from incoming messages.
24961
24962
24963.section The Sender: header line
24964.rset SECTthesenhea "~~chapter.~~section"
24965.index ::Sender:: header line
24966For a locally-originated message from an untrusted user, Exim may remove an
24967existing ::Sender:: header line, and it may add a new one. You can modify these
24968actions by setting \local@_sender@_retain\ true or \local@_from@_check\ false.
24969
24970When a local message is received from an untrusted user and
24971\local@_from@_check\ is true (the default), a check is made to see if the
24972address given in the ::From:: header line is the correct (local) sender of the
24973message. The address that is expected has the login name as the local part and
24974the value of \qualify@_domain\ as the domain. Prefixes and suffixes for the
24975local part can be permitted by setting \local@_from@_prefix\ and
24976\local@_from@_suffix\ appropriately. If ::From:: does not contain the correct
24977sender, a ::Sender:: line is added to the message.
24978
24979If you set \local@_from@_check\ false, this checking does not occur. However,
24980the removal of an existing ::Sender:: line still happens, unless you also set
24981\local@_sender@_retain\ to be true. It is not possible to set both of these
24982options true at the same time.
24983
24984.em
24985By default, no processing of ::Sender:: header lines is done for messages
24986received by TCP/IP or for messages submitted by trusted users. However, when a
24987message is received over TCP/IP in submission mode, ::Sender:: header lines are
24988always removed. If the SMTP session is authenticated, and \$authenticated@_id$\
24989is not empty, a sender address is created with \$authenticated@_id$\ as the
24990local part and either the domain specified in the submission control or, if
24991that is not specified, \$qualify@_domain$\ as the domain. This is compared with
24992the address in the ::From:: header line. If they are different, a ::Sender::
24993header line is added. Prefixes and suffixes for the local part in ::From:: can
24994be permitted by setting \local@_from@_prefix\ and \local@_from@_suffix\
24995appropriately.
24996.nem
24997
24998
24999.section Adding and removing header lines
25000.index header lines||adding
25001.index header lines||removing
25002.rset SECTheadersaddrem "~~chapter.~~section"
25003When a message is delivered, the addition and removal of header lines can be
25004specified on any of the routers and transports, and also in the system filter.
25005Changes specified in the system filter affect all deliveries of a message.
25006
25007Header changes specified on a router affect all addresses handled by that
25008router, and also any new addresses it generates. If an address passes through
25009several routers, the changes are cumulative. When a message is processed by a
25010transport, the message's original set of header lines is output, except for
25011those named in any \headers@_remove\ options that the address has encountered
25012as it was processed, and any in the transport's own \headers@_remove\ option.
25013Then the new header lines from \headers@_add\ options are output.
25014
25015
25016.section Constructed addresses
25017.rset SECTconstr "~~chapter.~~section"
25018.index address||constructed
25019.index constructed address
25020When Exim constructs a sender address for a locally-generated message, it uses
25021the form
25022.display
25023<<user name>> <$$<<login>>@@<<qualify@_domain>>$$>
25024.endd
25025For example:
25026.display asis
25027Zaphod Beeblebrox <zaphod@end.univ.example>
25028.endd
25029The user name is obtained from the \-F-\ command line option if set, or
25030otherwise by looking up the calling user by \*getpwuid()*\ and extracting the
25031`gecos' field from the password entry. If the `gecos' field contains an
25032ampersand character, this is replaced by the login name with the first letter
25033upper cased, as is conventional in a number of operating systems. See the
25034\gecos@_name\ option for a way to tailor the handling of the `gecos' field. The
25035\unknown@_username\ option can be used to specify user names in cases when
25036there is no password file entry.
25037
25038In all cases, the user name is made to conform to RFC 2822 by quoting all or
25039parts of it if necessary. In addition, if it contains any non-printing
25040characters, it is encoded as described in RFC 2047, which defines a way of
25041including non-ASCII characters in header lines.
25042The value of the \headers@_charset\ option specifies the name of the encoding
25043that is used (the characters are assumed to be in this encoding).
25044The setting of \print@_topbitchars\ controls whether characters with the top
25045bit set (that is, with codes greater than 127) count as printing characters or
25046not.
25047
25048
25049.section Case of local parts
25050.index case of local parts
25051.index local part||case of
25052RFC 2822 states that the case of letters in the local parts of addresses cannot
25053be assumed to be non-significant. Exim preserves the case of local parts of
25054addresses, but by default it uses a lower-cased form when it is routing,
25055because on most Unix systems, usernames are in lower case and case-insensitive
25056routing is required. However, any particular router can be made to use the
25057original case for local parts by setting the \caseful@_local@_part\ generic
25058router option.
25059
25060.index mixed-case login names
25061If you must have mixed-case user names on your system, the best way to proceed,
25062assuming you want case-independent handling of incoming email, is to set up
25063your first router to convert incoming local parts in your domains to the
25064correct case by means of a file lookup. For example:
25065.display asis
25066correct_case:
25067 driver = redirect
25068 domains = +local_domains
25069 data = ${lookup{$local_part}cdb\
25070 {/etc/usercased.cdb}{$value}fail}\
25071 @$domain
25072.endd
25073For this router, the local part is forced to lower case by the default action
25074(\caseful@_local@_part\ is not set). The lower-cased local part is used to look
25075up a new local part in the correct case. If you then set \caseful@_local@_part\
25076on any subsequent routers which process your domains, they will operate on
25077local parts with the correct case in a case-sensitive manner.
25078
25079
25080.section Dots in local parts
25081.index dot||in local part
25082.index local part||dots in
25083RFC 2822 forbids empty components in local parts. That is, an unquoted local
25084part may not begin or end with a dot, nor have two consecutive dots in the
25085middle. However, it seems that many MTAs do not enforce this, so Exim permits
25086empty components for compatibility.
25087
25088
25089.section Rewriting addresses
25090.index rewriting||addresses
25091Rewriting of sender and recipient addresses, and addresses in headers, can
25092happen automatically, or as the result of configuration options, as described
25093in chapter ~~CHAPrewrite. The headers that may be affected by this are ::Bcc::,
25094::Cc::, ::From::, ::Reply-To::, ::Sender::, and ::To::.
25095
25096Automatic rewriting includes qualification, as mentioned above. The other case
25097in which it can happen is when an incomplete non-local domain is given. The
25098routing process may cause this to be expanded into the full domain name. For
25099example, a header such as
25100.display asis
25101To: hare@teaparty
25102.endd
25103might get rewritten as
25104.display asis
25105To: hare@teaparty.wonderland.fict.example
25106.endd
25107Rewriting as a result of routing is the one kind of message processing that
25108does not happen at input time, as it cannot be done until the address has
25109been routed.
25110
25111Strictly, one should not do $it{any} deliveries of a message until all its
25112addresses have been routed, in case any of the headers get changed as a
25113result of routing. However, doing this in practice would hold up many
25114deliveries for unreasonable amounts of time, just because one address could not
25115immediately be routed. Exim therefore does not delay other deliveries when
25116routing of one or more addresses is deferred.
25117
25118
25119
25120
25121
25122.
25123.
25124.
25125.
25126. ============================================================================
25127.chapter Log files
25128.set runningfoot "log files"
25129.rset CHAPlog "~~chapter"
25130.index log||types of
25131.index log||general description
25132Exim writes three different logs, referred to as the main log, the reject log,
25133and the panic log:
25134.numberpars $.
25135.index main log
25136The main log records the arrival of each message and each delivery in a single
25137line in each case. The format is as compact as possible, in an attempt to keep
25138down the size of log files. Two-character flag sequences make it easy to pick
25139out these lines. A number of other events are recorded in the main log. Some of
25140them are optional, in which case the \log@_selector\ option controls whether
25141they are included or not. A Perl script called \*eximstats*\, which does simple
25142analysis of main log files, is provided in the Exim distribution (see section
25143~~SECTmailstat).
25144.nextp
25145.index reject log
25146The reject log records information from messages that are rejected as a result
25147of a configuration option (that is, for policy reasons).
25148.em
25149The first line of each rejection is a copy of the line that is also written to
25150the main log. Then, if the message's header has been read at the time the log
25151is written, its contents are written to this log. Only the original header
25152lines are available; header lines added by ACLs are not logged. You can use the
25153reject log to check that your policy controls are working correctly; on a busy
25154host this may be easier than scanning the main log for rejection messages. You
25155can suppress the writing of the reject log by setting \write@_rejectlog\ false.
25156.nem
25157.nextp
25158.index panic log
25159.index system log
25160When certain serious errors occur, Exim writes entries to its panic log. If the
25161error is sufficiently disastrous, Exim bombs out afterwards. Panic log entries
25162are usually written to the main log as well, but can get lost amid the mass of
25163other entries. The panic log should be empty under normal circumstances. It is
25164therefore a good idea to check it (or to have a \*cron*\ script check it)
25165regularly, in order to become aware of any problems. When Exim cannot open its
25166panic log, it tries as a last resort to write to the system log (syslog). This
25167is opened with LOG@_PID+LOG@_CONS and the facility code of LOG@_MAIL. The
25168message itself is written at priority LOG@_CRIT.
25169.endp
25170Every log line starts with a timestamp, in the format shown in this example:
25171.display asis
251722001-09-16 16:09:47 SMTP connection from [127.0.0.1] closed by QUIT
25173.endd
25174By default, the timestamps are in the local timezone. There are two
25175ways of changing this:
25176.numberpars $.
25177You can set the \timezone\ option to a different time zone; in particular, if
25178you set
25179.display asis
25180timezone = UTC
25181.endd
25182the timestamps will be in UTC (aka GMT).
25183.nextp
25184If you set \log@_timezone\ true, the time zone is added to the timestamp, for
25185example:
25186.display asis
251872003-04-25 11:17:07 +0100 Start queue run: pid=12762
25188.endd
25189.endp
25190
25191
25192
25193.section Where the logs are written
25194.rset SECTwhelogwri "~~chapter.~~section"
25195.index log||destination
25196.index log||to file
25197.index log||to syslog
25198.index syslog
25199The logs may be written to local files, or to syslog, or both. However, it
25200should be noted that many syslog implementations use UDP as a transport, and
25201are therefore unreliable in the sense that messages are not guaranteed to
25202arrive at the loghost, nor is the ordering of messages necessarily maintained.
25203It has also been reported that on large log files (tens of megabytes) you may
25204need to tweak syslog to prevent it syncing the file with each write -- on Linux
25205this has been seen to make syslog take 90% plus of CPU time.
25206
25207The destination for Exim's logs is configured by setting \\LOG@_FILE@_PATH\\ in
25208\(Local/Makefile)\ or by setting \log@_file@_path\ in the run time
25209configuration. This latter string is expanded, so it can contain, for example,
25210references to the host name:
25211.display asis
25212log_file_path = /var/log/$primary_hostname/exim_%slog
25213.endd
25214It is generally advisable, however, to set the string in \(Local/Makefile)\
25215rather than at run time, because then the setting is available right from the
25216start of Exim's execution. Otherwise, if there's something it wants to log
25217before it has read the configuration file (for example, an error in the
25218configuration file) it will not use the path you want, and may not be able to
25219log at all.
25220
25221The value of \\LOG@_FILE@_PATH\\ or \log@_file@_path\ is a colon-separated
25222list, currently limited to at most two items. This is one option where the
25223facility for changing a list separator may not be used. The list must always be
25224colon-separated. If an item in the list is `syslog' then syslog is used;
25225otherwise the item must either be an absolute path, containing \"%s"\ at the
25226point where `main', `reject', or `panic' is to be inserted, or be empty,
25227implying the use of a default path.
25228
25229When Exim encounters an empty item in the list, it searches the list defined by
25230\\LOG@_FILE@_PATH\\, and uses the first item it finds that is neither empty nor
25231`syslog'. This means that an empty item in \log@_file@_path\ can be used to
25232mean `use the path specified at build time'. It no such item exists, log files
25233are written in the \(log)\ subdirectory of the spool directory. This is
25234equivalent to the setting:
25235.display asis
25236log_file_path = $spool_directory/log/%slog
25237.endd
25238If you do not specify anything at build time or run time, that is where the
25239logs are written.
25240
25241A log file path may also contain \"%D"\ if datestamped log file names are in
25242use -- see section ~~SECTdatlogfil below.
25243
25244Here are some examples of possible settings:
25245.display
25246.tabs 42
25247LOG@_FILE@_PATH=syslog $t $rm{syslog only}
25248LOG@_FILE@_PATH=:syslog $t $rm{syslog and default path}
25249LOG@_FILE@_PATH=syslog : /usr/log/exim@_%s $t $rm{syslog and specified path}
25250LOG@_FILE@_PATH=/usr/log/exim@_%s $t $rm{specified path only}
25251.endd
25252If there are more than two paths in the list, the first is used and a panic
25253error is logged.
25254
25255
25256.section Logging to local files that are periodically `cycled'
25257.index log||cycling local files
25258.index cycling logs
25259.index \*exicyclog*\
25260.index log||local files, writing to
25261Some operating systems provide centralized and standardised methods for cycling
25262log files. For those that do not, a utility script called \*exicyclog*\ is
25263provided (see section ~~SECTcyclogfil). This renames and compresses the main
25264and reject logs each time it is called. The maximum number of old logs to keep
25265can be set. It is suggested this script is run as a daily \*cron*\ job.
25266
25267An Exim delivery process opens the main log when it first needs to write to it,
25268and it keeps the file open in case subsequent entries are required -- for
25269example, if a number of different deliveries are being done for the same
25270message. However, remote SMTP deliveries can take a long time, and this means
25271that the file may be kept open long after it is renamed if \*exicyclog*\ or
25272something similar is being used to rename log files on a regular basis. To
25273ensure that a switch of log files is noticed as soon as possible, Exim calls
25274\*stat()*\ on the main log's name before reusing an open file, and if the file
25275does not exist, or its inode has changed, the old file is closed and Exim
25276tries to open the main log from scratch. Thus, an old log file may remain open
25277for quite some time, but no Exim processes should write to it once it has been
25278renamed.
25279
25280
25281.section Datestamped log files
25282.rset SECTdatlogfil "~~chapter.~~section"
25283.index log||datestamped files
25284Instead of cycling the main and reject log files by renaming them
25285periodically, some sites like to use files whose names contain a datestamp,
25286for example, \(mainlog-20031225)\. The datestamp is in the form \(yyyymmdd)\.
25287Exim has support for this way of working. It is enabled by setting the
25288\log@_file@_path\ option to a path that includes \"%D"\ at the point where the
25289datestamp is required. For example:
25290.display asis
25291log_file_path = /var/spool/exim/log/%slog-%D
25292log_file_path = /var/log/exim-%s-%D.log
25293log_file_path = /var/spool/exim/log/%D-%slog
25294.endd
25295As before, \"%s"\ is replaced by `main' or `reject'; the following are examples
25296of names generated by the above examples:
25297.display asis
25298/var/spool/exim/log/mainlog-20021225
25299/var/log/exim-reject-20021225.log
25300/var/spool/exim/log/20021225-mainlog
25301.endd
25302When this form of log file is specified, Exim automatically switches to new
25303files at midnight. It does not make any attempt to compress old logs; you
25304will need to write your own script if you require this. You should not
25305run \*exicyclog*\ with this form of logging.
25306
25307The location of the panic log is also determined by \log@_file@_path\, but it
25308is not datestamped, because rotation of the panic log does not make sense.
25309When generating the name of the panic log, \"%D"\ is removed from the string.
25310In addition, if it immediately follows a slash, a following non-alphanumeric
25311character is removed; otherwise a preceding non-alphanumeric character is
25312removed. Thus, the three examples above would give these panic log names:
25313.display asis
25314/var/spool/exim/log/paniclog
25315/var/log/exim-panic.log
25316/var/spool/exim/log/paniclog
25317.endd
25318
25319
25320.section Logging to syslog
25321.index log||syslog, writing to
25322The use of syslog does not change what Exim logs or the format of its messages,
25323except in one respect. If \syslog@_timestamp\ is set false, the timestamps on
25324Exim's log lines are omitted when these lines are sent to syslog. Apart from
25325that, the same strings are written to syslog as to log files. The syslog
25326`facility' is set to \\LOG@_MAIL\\, and the program name to `exim'
25327by default, but you can change these by setting the \syslog@_facility\ and
25328\syslog@_processname\ options, respectively. If Exim was compiled with
25329\\SYSLOG@_LOG@_PID\\ set in \(Local/Makefile)\ (this is the default in
25330\(src/EDITME)\), then, on systems that permit it (all except ULTRIX), the
25331\\LOG@_PID\\ flag is set so that the \*syslog()*\ call adds the pid as well as
25332the time and host name to each line.
25333The three log streams are mapped onto syslog priorities as follows:
25334.numberpars " "
25335\*mainlog*\ is mapped to \\LOG@_INFO\\
25336.nextp
25337\*rejectlog*\ is mapped to \\LOG@_NOTICE\\
25338.nextp
25339\*paniclog*\ is mapped to \\LOG@_ALERT\\
25340.endp
25341Many log lines are written to both \*mainlog*\ and \*rejectlog*\, and some are
25342written to both \*mainlog*\ and \*paniclog*\, so there will be duplicates if
25343these are routed by syslog to the same place. You can suppress this duplication
25344by setting \syslog@_duplication\ false.
25345
25346Exim's log lines can sometimes be very long, and some of its \*rejectlog*\
25347entries contain multiple lines when headers are included. To cope with both
25348these cases, entries written to syslog are split into separate \*syslog()*\
25349calls at each internal newline, and also after a maximum of
25350870 data characters. (This allows for a total syslog line length of 1024, when
25351additions such as timestamps are added.) If you are running a syslog
25352replacement that can handle lines longer than the 1024 characters allowed by
25353RFC 3164, you should set
25354.display asis
25355SYSLOG_LONG_LINES=yes
25356.endd
25357in \(Local/Makefile)\ before building Exim. That stops Exim from splitting long
25358lines, but it still splits at internal newlines in \*reject*\ log entries.
25359
25360To make it easy to re-assemble split lines later, each component of a split
25361entry starts with a string of the form `[<<n>>/<<m>>]' or `[<<n>>@\<<m>>]'
25362where <<n>> is the component number and <<m>> is the total number of components
25363in the entry. The / delimiter is used when the line was split because it was
25364too long; if it was split because of an internal newline, the @\ delimiter is
25365used. For example, supposing the length limit to be 70 instead of 1000, the
25366following would be the result of a typical rejection message to \*mainlog*\
25367(LOG@_INFO), each line in addition being preceded by the time, host name, and
25368pid as added by syslog:
25369.display
25370.indent 0
25371$smc{[1/3] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from [127.0.0.1] (ph10):
25372[2/3] syntax error in 'From' header when scanning for sender: missing or ma
25373[3/3] lformed local part in "<>" (envelope sender is <ph10@@cam.example>)}
25374.endd
25375The same error might cause the following lines to be written to `rejectlog'
25376(LOG@_NOTICE):
25377.display flow
25378.indent 0
25379$smc{[1/14] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from [127.0.0.1] (ph10):
25380[2/14] syntax error in 'From' header when scanning for sender: missing or ma
25381[3@\14] lformed local part in "@<@>" (envelope sender is <ph10@@cam.example>)
25382[4@\14] Recipients: ph10@@some.domain.cam.example
25383[5@\14] P Received: from [127.0.0.1] (ident=ph10)
25384[6@\14] by xxxxx.cam.example with smtp (Exim 4.00)
25385[7@\14] id 16RdAL-0006pc-00
25386[8@\14] for ph10@@cam.example; Mon, 16 Sep 2002 16:09:43 +0100
25387[9@\14] F From: @<@>
25388[10@\14] Subject: this is a test header
25389[11@\14] X-something: this is another header
25390[12@\14] I Message-Id: <E16RdAL-0006pc-00@@xxxxx.cam.example>
25391[13@\14] B Bcc:
25392[14/14] Date: Mon, 16 Sep 2002 16:09:43 +0100}
25393.endd
25394Log lines that are neither too long nor contain newlines are written to syslog
25395without modification.
25396
25397If only syslog is being used, the Exim monitor is unable to provide a log tail
25398display, unless syslog is routing \*mainlog*\ to a file on the local host and
25399the environment variable \\EXIMON@_LOG@_FILE@_PATH\\ is set to tell the monitor
25400where it is.
25401
25402
25403.section Log line flags
25404One line is written to the main log for each message received, and for each
25405successful, unsuccessful, and delayed delivery. These lines can readily be
25406picked out by the distinctive two-character flags that immediately follow the
25407timestamp. The flags are:
25408.display
25409.tabs 6
25410<= $t $rm{message arrival}
25411=> $t $rm{normal message delivery}
25412-> $t $rm{additional address in same delivery}
25413*> $t $rm{delivery suppressed by \-N-\}
25414** $t $rm{delivery failed; address bounced}
25415== $t $rm{delivery deferred; temporary problem}
25416.endd
25417
25418
25419.section Logging message reception
25420.index log||reception line
25421The format of the single-line entry in the main log that is written for every
25422message received is shown in the basic example below, which is split over
25423several lines in order to fit it on the page:
25424.display
25425.indent 0
254262002-10-31 08:57:53 16ZCW1-0005MB-00 <= kryten@@dwarf.fict.example
25427 H=mailer.fict.example [192.168.123.123] U=exim
25428 P=smtp S=5678 id=<<incoming message id>>
25429.endd
25430The address immediately following `<=' is the envelope sender address. A bounce
25431message is shown with the sender address `<>', and if it is locally generated,
25432this is followed by an item of the form
25433.display
25434R=<<message id>>
25435.endd
25436which is a reference to the message that caused the bounce to be sent.
25437
25438.index \\HELO\\
25439.index \\EHLO\\
25440For messages from other hosts, the H and U fields identify the remote host and
25441record the RFC 1413 identity of the user that sent the message, if one was
25442received. The number given in square brackets is the IP address of the sending
25443host. If there is a single, unparenthesized host name in the H field, as
25444above, it has been verified to correspond to the IP address (see the
25445\host@_lookup\ option). If the name is in parentheses, it was the name quoted
25446by the remote host in the SMTP \\HELO\\ or \\EHLO\\ command, and has not been
25447verified. If verification yields a different name to that given for \\HELO\\ or
25448\\EHLO\\, the verified name appears first, followed by the \\HELO\\ or \\EHLO\\
25449name in parentheses.
25450
25451Misconfigured hosts (and mail forgers) sometimes put an IP address, with or
25452without brackets, in the \\HELO\\ or \\EHLO\\ command, leading to entries in
25453the log containing text like these examples:
25454.display
25455H=(10.21.32.43) [192.168.8.34]
25456H=([10.21.32.43]) [192.168.8.34]
25457.endd
25458This can be confusing. Only the final address in square brackets can be relied
25459on.
25460
25461For locally generated messages (that is, messages not received over TCP/IP),
25462the H field is omitted, and the U field contains the login name of the caller
25463of Exim.
25464
25465.index authentication||logging
25466.index \\AUTH\\||logging
25467For all messages, the P field specifies the protocol used to receive the
25468message. This is set to `asmtp' for messages received from hosts which have
25469authenticated themselves using the SMTP \\AUTH\\ command. In this case there is
25470an additional item A= followed by the name of the authenticator that was used.
25471If an authenticated identification was set up by the authenticator's
25472\server@_set@_id\ option, this is logged too, separated by a colon from the
25473authenticator name.
25474
25475The id field records the existing message id, if present.
25476.index size||of message
25477The size of the received message is given by the S field. When the message is
25478delivered, headers may get removed or added, so that the size of delivered
25479copies of the message may not correspond with this value (and indeed may be
25480different to each other).
25481
25482The \log@_selector\ option can be used to request the logging of additional
25483data when a message is received. See section ~~SECTlogselector below.
25484
25485
25486.section Logging deliveries
25487.index log||delivery line
25488The format of the single-line entry in the main log that is written for every
25489delivery is shown in one of the examples below, for local and remote deliveries,
25490respectively. Each example has been split into two lines in order to fit
25491it on the page:
25492.display
25493.indent 0
254942002-10-31 08:59:13 16ZCW1-0005MB-00 => marv <marv@@hitch.fict.example>
25495 R=localuser T=local@_delivery
254962002-10-31 09:00:10 16ZCW1-0005MB-00 => monk@@holistic.fict.example
25497 R=dnslookup T=remote@_smtp H=holistic.fict.example [192.168.234.234]
25498.endd
25499For ordinary local deliveries, the original address is given in angle brackets
25500after the final delivery address, which might be a pipe or a file. If
25501intermediate address(es) exist between the original and the final address, the
25502last of these is given in parentheses after the final address. The R and T
25503fields record the router and transport that were used to process the address.
25504
25505If a shadow transport was run after a successful local delivery, the log line
25506for the successful delivery has an item added on the end, of the form
25507.display
25508ST=<<shadow transport name>>
25509.endd
25510If the shadow transport did not succeed, the error message is put in
25511parentheses afterwards.
25512
25513When more than one address is included in a single delivery (for example, two
25514SMTP \\RCPT\\ commands in one transaction) the second and subsequent
25515addresses are flagged with `$tt{@-@>}' instead of `$tt{@=@>}'. When two or more
25516messages are delivered down a single SMTP connection, an asterisk follows the
25517IP address in the log lines for the second and subsequent messages.
25518
25519The generation of a reply message by a filter file gets logged as a `delivery'
25520to the addressee, preceded by `>'.
25521
25522The \log@_selector\ option can be used to request the logging of additional
25523data when a message is delivered. See section ~~SECTlogselector below.
25524
25525
25526.section Discarded deliveries
25527.index discarded messages
25528.index message||discarded
25529.index delivery||discarded, logging
25530When a message is discarded as a result of the command `seen finish' being
25531obeyed in a filter file which generates no deliveries, a log entry of the form
25532.display
255332002-12-10 00:50:49 16auJc-0001UB-00 => discarded
25534 <low.club@@bridge.example> R=userforward
25535.endd
25536is written, to record why no deliveries are logged. When a message is discarded
25537because it is aliased to `:blackhole:' the log line is like this:
25538.display asis
255391999-03-02 09:44:33 10HmaX-0005vi-00 => :blackhole:
25540 <hole@nowhere.example> R=blackhole_router
25541.endd
25542
25543
25544.section Deferred deliveries
25545When a delivery is deferred, a line of the following form is logged:
25546.display
25547.indent 0
255482002-12-19 16:20:23 16aiQz-0002Q5-00 == marvin@@endrest.example
25549 R=dnslookup T=smtp defer (146): Connection refused
25550.endd
25551In the case of remote deliveries, the error is the one that was given for the
25552last IP address that was tried. Details of individual SMTP failures are also
25553written to the log, so the above line would be preceded by something like
25554.display
25555.indent 0
255562002-12-19 16:20:23 16aiQz-0002Q5-00 Failed to connect to
25557 mail1.endrest.example [192.168.239.239]: Connection refused
25558.endd
25559When a deferred address is skipped because its retry time has not been reached,
25560a message is written to the log, but this can be suppressed by setting an
25561appropriate value in \log@_selector\.
25562
25563
25564.section Delivery failures
25565.index delivery||failure, logging
25566If a delivery fails because an address cannot be routed, a line of the
25567following form is logged:
25568.display asis
25569.indent 0
255701995-12-19 16:20:23 0tRiQz-0002Q5-00 ** jim@trek99.example
25571 <jim@trek99.example>: unknown mail domain
25572.endd
25573If a delivery fails at transport time, the router and transport are shown, and
25574the response from the remote host is included, as in this example:
25575.display asis
25576.indent 0
255772002-07-11 07:14:17 17SXDU-000189-00 ** ace400@pb.example R=dnslookup
25578.newline
25579.em
25580 T=remote_smtp: SMTP error from remote mailer after pipelined
25581.newline
25582.nem
25583 RCPT TO:<ace400@pb.example>: host pbmail3.py.example
25584 [192.168.63.111]: 553 5.3.0 <ace400@pb.example>...
25585 Addressee unknown
25586.endd
25587.em
25588The word `pipelined' indicates that the SMTP \\PIPELINING\\ extension was being
25589used. See \hosts@_avoid@_esmtp\ in the \%smtp%\ transport for a way of
25590disabling \\PIPELINING\\.
25591.nem
25592
25593The log lines for all forms of delivery failure are flagged with \"**"\.
25594
25595
25596.section Fake deliveries
25597.index delivery||fake, logging
25598If a delivery does not actually take place because the \-N-\ option has been
25599used to suppress it, a normal delivery line is written to the log, except that
25600`=>' is replaced by `$*$>'.
25601
25602
25603.section Completion
25604A line of the form
25605.display
256062002-10-31 09:00:11 16ZCW1-0005MB-00 Completed
25607.endd
25608is written to the main log when a message is about to be removed from the spool
25609at the end of its processing.
25610
25611
25612
25613.section Summary of Fields in Log Lines
25614.index log||summary of fields
25615A summary of the field identifiers that are used in log lines is shown in
25616the following table:
25617.display flow
25618.tabs 8
25619A $t $rm{authenticator name (and optional id)}
25620C $t $rm{SMTP confirmation on delivery}
25621.newline
25622.em
25623CV $t $rm{certificate verification status}
25624DN $t $rm{distinguished name from peer certificate}
25625DT $t $rm{time taken for a delivery}
25626.newline
25627.nem
25628F $t $rm{sender address (on delivery lines)}
25629H $t $rm{host name and IP address}
25630.newline
25631.em
25632I $t $rm{local interface used}
25633.newline
25634.nem
25635id $t $rm{message id for incoming message}
25636P $t $rm{on \"<="\ lines: protocol used}
25637.newline
25638.em
25639 $t $rm{on \"=>"\ lines: return path}
25640QT $t $rm{time spent on queue}
25641.newline
25642.nem
25643R $t $rm{on \"<="\ lines: reference for local bounce}
25644 $t $rm{on \"=>"\ lines: router name}
25645S $t $rm{size of message}
25646ST $t $rm{shadow transport name}
25647T $t $rm{on \"<="\ lines: message subject (topic)}
25648 $t $rm{on \"=>"\ lines: transport name}
25649U $t $rm{local user or RFC 1413 identity}
25650X $t $rm{TLS cipher suite}
25651.endd
25652
25653
25654.section Other log entries
25655Various other types of log entry are written from time to time. Most should be
25656self-explanatory. Among the more common are:
25657.numberpars $.
25658.index retry||time not reached
25659\*retry time not reached*\##An address previously suffered a temporary error
25660during routing or local delivery, and the time to retry has not yet arrived.
25661This message is not written to an individual message log file unless it happens
25662during the first delivery attempt.
25663.nextp
25664\*retry time not reached for any host*\##An address previously suffered
25665temporary errors during remote delivery, and the retry time has not yet arrived
25666for any of the hosts to which it is routed.
25667.nextp
25668.index spool directory||file locked
25669\*spool file locked*\##An attempt to deliver a message cannot proceed because
25670some other Exim process is already working on the message. This can be quite
25671common if queue running processes are started at frequent intervals. The
25672\*exiwhat*\ utility script can be used to find out what Exim processes are
25673doing.
25674.nextp
25675.em
25676.index error||ignored
25677\*error ignored*\##There are several circumstances that give rise to this
25678message:
25679.numberpars " "
25680Exim failed to deliver a bounce message whose age was greater than
25681\ignore__bounce__errors__after\. The bounce was discarded.
25682.nextp
25683A filter file set up a delivery using the `noerror' option, and the delivery
25684failed. The delivery was discarded.
25685.nextp
25686A delivery set up by a router configured with
25687.display asis
25688errors_to = <>
25689.endd
25690failed. The delivery was discarded.
25691.endp
25692.nem
25693.endp
25694
25695
25696
25697.section Reducing or increasing what is logged
25698.rset SECTlogselector "~~chapter.~~section"
25699.index log||selectors
25700By setting the \log@_selector\ global option, you can disable some of Exim's
25701default logging, or you can request additional logging. The value of
25702\log@_selector\ is made up of names preceded by plus or minus characters. For
25703example:
25704.display asis
25705log_selector = +arguments -retry_defer
25706.endd
25707The list of optional log items is in the following table, with the default
25708selection marked by asterisks:
25709.display flow
25710.tabs 32
25711 address@_rewrite $t $rm{address rewriting}
25712 all@_parents $t $rm{all parents in => lines}
25713 arguments $t $rm{command line arguments}
25714*connection@_reject $t $rm{connection rejections}
25715*delay@_delivery $t $rm{immediate delivery delayed (message queued)}
25716.newline
25717.em
25718 deliver@_time $t $rm{time taken to perform delivery}
25719.newline
25720.nem
25721 delivery@_size $t $rm{add S=nnn to => lines}
25722*dnslist@_defer $t $rm{defers of DNS list (aka RBL) lookups}
25723*etrn $t $rm{ETRN commands}
25724*host@_lookup@_failed $t $rm{as it says}
25725.newline
25726.em
25727 ident@_timeout $t $rm{timeout for ident connection}
25728.newline
25729.nem
25730 incoming@_interface $t $rm{incoming interface on <= lines}
25731 incoming@_port $t $rm{incoming port on <= lines}
25732*lost@_incoming@_connection $t $rm{as it says (includes timeouts)}
25733.newline
25734.em
25735 outgoing@_port $t $rm{add remote port to => lines}
25736.newline
25737.nem
25738*queue@_run $t $rm{start and end queue runs}
25739.newline
25740.em
25741 queue@_time $t $rm{time on queue}
25742.newline
25743.nem
25744 received@_recipients $t $rm{recipients on <= lines}
25745 received@_sender $t $rm{sender on <= lines}
25746*rejected@_header $t $rm{header contents on reject log}
25747*retry@_defer $t $rm{`retry time not reached'}
25748.newline
25749.em
25750 return@_path@_on@_delivery $t $rm{put return path on => and ** lines}
25751.newline
25752.nem
25753 sender@_on@_delivery $t $rm{add sender to => lines}
25754*size@_reject $t $rm{rejection because too big}
25755*skip@_delivery $t $rm{`message is frozen', `spool file is locked'}
25756.newline
25757.em
25758 smtp@_confirmation $t $rm{SMTP confirmation on => lines}
25759.newline
25760.nem
25761 smtp@_connection $t $rm{SMTP connections}
25762 smtp@_incomplete@_transaction $t $rm{incomplete SMTP transactions}
25763 smtp@_protocol@_error $t $rm{SMTP protocol errors}
25764 smtp@_syntax@_error $t $rm{SMTP syntax errors}
25765 subject $t $rm{contents of ::Subject:: on <= lines}
25766.newline
25767.em
25768 tls@_certificate@_verified $t $rm{certificate verification status}
25769.newline
25770.nem
25771*tls@_cipher $t $rm{TLS cipher suite on <= and => lines}
25772 tls@_peerdn $t $rm{TLS peer DN on <= and => lines}
25773
25774 all $t $rm{all of the above}
25775.endd
25776More details on each of these items follows:
25777.numberpars $.
25778.index log||rewriting
25779.index rewriting||logging
25780\address@_rewrite\: This applies both to global rewrites and per-transport
25781rewrites,
25782.em
25783but not to rewrites in filters run as an unprivileged user (because such users
25784cannot access the log).
25785.nem
25786.nextp
25787.index log||full parentage
25788\all@_parents\: Normally only the original and final addresses are logged on
25789delivery lines; with this selector, intermediate parents are given in
25790parentheses between them.
25791.nextp
25792.index log||Exim arguments
25793.index Exim arguments, logging
25794\arguments\: This causes Exim to write the arguments with which it was called
25795to the main log,
25796preceded by the current working directory.
25797This is a debugging feature, added to make it easier to find out how certain
25798MUAs call \(/usr/sbin/sendmail)\. The logging does not happen if Exim has given
25799up root privilege because it was called with the \-C-\ or \-D-\ options.
25800Arguments that are empty or that contain whitespace are quoted. Non-printing
25801characters are shown as escape sequences.
25802This facility cannot log unrecognized arguments, because the arguments are
25803checked before the configuration file is read. The only way to log such cases
25804is to interpose a script such as \(util/logargs.sh)\ between the caller and
25805Exim.
25806.nextp
25807.index log||connection rejections
25808\connection@_reject\: A log entry is written whenever an incoming SMTP
25809connection is rejected, for whatever reason.
25810.nextp
25811.index log||delayed delivery
25812.index delayed delivery, logging
25813\delay@_delivery\: A log entry is written whenever a delivery process is not
25814started for an incoming message because the load is too high or too many
25815messages were received on one connection. Logging does not occur if no delivery
25816process is started because \queue@_only\ is set or \-odq-\ was used.
25817.nextp
25818.em
25819.index log||delivery duration
25820\deliver@_time\: For each delivery, the amount of real time it has taken to
25821perform the actual delivery is logged as DT=<<time>>, for example, \"DT=1s"\.
25822.nem
25823.nextp
25824.index log||message size on delivery
25825.index size||of message
25826\delivery@_size\: For each delivery, the size of message delivered is added to
25827the `=>' line, tagged with S=.
25828.nextp
25829.index log||dnslist defer
25830.index DNS list||logging defer
25831.index black list (DNS)
25832\dnslist@_defer\: A log entry is written if an attempt to look up a host in a
25833DNS black list suffers a temporary error.
25834.nextp
25835.index log||ETRN commands
25836.index \\ETRN\\||logging
25837\etrn\: Every legal ETRN command that is received is logged, before the ACL is
25838run to determine whether or not it is actually accepted. An invalid ETRN
25839command, or one received within a message transaction is not logged by this
25840selector (see \smtp@_syntax@_error\ and \smtp@_protocol@_error\).
25841.nextp
25842.index log||host lookup failure
25843\host@_lookup@_failed\: When a lookup of a host's IP addresses fails to find
25844any addresses, or when a lookup of an IP address fails to find a host name, a
25845log line is written. This logging does not apply to direct DNS lookups when
25846routing email addresses, but it does apply to `byname' lookups.
25847.nextp
25848.em
25849.index log||ident timeout
25850.index RFC 1413||logging timeout
25851\ident@_timeout\: A log line is written whenever an attempt to connect to a
25852client's ident port times out.
25853.nem
25854.nextp
25855.index log||incoming interface
25856.index interface||logging
25857\incoming@_interface\: The interface on which a message was received is added
25858to the `<=' line as an IP address in square brackets, tagged by I= and followed
25859by a colon and the port number.
25860.em
25861The local interface and port are also added to other SMTP log
25862lines, for example `SMTP connection from', and to rejection lines.
25863.nem
25864.nextp
25865.index log||incoming remote port
25866.index port||logging remote
25867.index TCP/IP||logging incoming remote port
25868\incoming@_port\: The remote port number from which a message was received is
25869added to log entries and ::Received:: header lines, following the IP address in
25870square brackets, and separated from it by a colon. This is implemented by
25871changing the value that is put in the \$sender@_fullhost$\ and
25872\$sender@_rcvhost$\ variables. Recording the remote port number has become more
25873important with the widening use of NAT (see RFC 2505).
25874.nextp
25875.index log||dropped connection
25876\lost@_incoming@_connection\: A log line is written when an incoming SMTP
25877connection is unexpectedly dropped.
25878.nextp
25879.em
25880.index log||outgoing remote port
25881.index port||logging outgoint remote
25882.index TCP/IP||logging ougtoing remote port
25883\outgoing@_port\: The remote port number is added to delivery log lines (those
25884containing => tags) following the IP address. This option is not included in
25885the default setting, because for most ordinary configurations, the remote port
25886number is always 25 (the SMTP port).
25887.nem
25888.nextp
25889.index log||queue run
25890.index queue runner||logging
25891\queue@_run\: The start and end of every queue run are logged.
25892.nextp
25893.em
25894.index log||queue time
25895\queue@_time\: The amount of time the message has been in the queue on the
25896local host is logged as QT=<<time>>, for example, \"QT=3m45s"\. The clock
25897starts when Exim starts to receive the message, so it includes reception time
25898as well as the delivery time of the current address.
25899.nem
25900.nextp
25901.index log||recipients
25902\received@_recipients\: The recipients of a message are listed in the main log
25903as soon as the message is received. The list appears at the end of the log line
25904that is written when a message is received, preceded by the word `for'. The
25905addresses are listed after they have been qualified, but before any rewriting
25906has taken place.
25907Recipients that were discarded by an ACL for \\MAIL\\ or \\RCPT\\ do not appear
25908in the list.
25909.nextp
25910.index log||sender reception
25911\received@_sender\: The unrewritten original sender of a message is added to
25912the end of the log line that records the message's arrival, after the word
25913`from' (before the recipients if \received@_recipients\ is also set).
25914.nextp
25915.index log||header lines for rejection
25916\rejected@_header\: If a message's header has been received at the time a
25917rejection is written to the reject log, the complete header is added to the
25918log. Header logging can be turned off individually for messages that are
25919rejected by the \*local@_scan()*\ function (see section ~~SECTapiforloc).
25920.nextp
25921.index log||retry defer
25922\retry@_defer\: A log line is written if a delivery is deferred because a retry
25923time has not yet been reached. However, this `retry time not reached' message
25924is always omitted from individual message logs after the first delivery
25925attempt.
25926.nextp
25927.index log||return path
25928.em
25929\return@_path@_on@_delivery\: The return path that is being transmitted with
25930the message is included in delivery and bounce lines, using the tag P=.
25931.nem
25932.nextp
25933.index log||sender on delivery
25934\sender@_on@_delivery\: The message's sender address is added to every delivery
25935and bounce line, tagged by F= (for `from').
25936.em
25937This is the original sender that was received with the message; it is not
25938necessarily the same as the outgoing return path.
25939.nem
25940.nextp
25941.index log||size rejection
25942\size@_reject\: A log line is written whenever a message is rejected because it
25943is too big.
25944.nextp
25945.index log||frozen messages, skipped
25946.index frozen messages||logging skipping
25947\skip@_delivery\: A log line is written whenever a message is skipped during a
25948queue run because it is frozen or because another process is already delivering
25949it.
25950.nextp
25951.index log||smtp confirmation
25952.index SMTP||logging confirmation
25953\smtp@_confirmation\: The response to the final `.' in the SMTP dialogue for
25954outgoing messages is added to delivery log lines in the form `C="<<text>>"'. A
25955number of MTAs (including Exim) return an identifying string in this response.
25956.nextp
25957.index log||SMTP connections
25958.index SMTP||logging connections
25959\smtp@_connection\: A log line is written whenever an SMTP connection is
25960established or closed. (By contrast, \lost@_incoming@_connection\ applies only
25961when the closure is unexpected.) This applies to connections from local
25962processes that use \-bs-\ as well as to TCP/IP connections. If a connection is
25963dropped in the middle of a message, a log line is always written, whether this
25964selector is set or not, but otherwise nothing is written at the start and end
25965of connections unless this selector is enabled.
25966
25967For TCP/IP connections to an Exim daemon, the current number of connections is
25968included in the log message for each new connection, but note that the count is
25969reset if the daemon is restarted.
25970Also, because connections are closed (and the closure is logged) in
25971subprocesses, the count may not include connections that have been closed but
25972whose termination the daemon has not yet noticed. Thus, while it is possible to
25973match up the opening and closing of connections in the log, the value of the
25974logged counts may not be entirely accurate.
25975.nextp
25976.index log||SMTP transaction, incomplete
25977.index SMTP||logging incomplete transactions
25978\smtp@_incomplete@_transaction\: When a mail transaction is aborted by
25979\\RSET\\, \\QUIT\\, loss of connection, or otherwise, the incident is logged,
25980and the message sender plus any accepted recipients are included in the log
25981line. This can provide evidence of dictionary attacks.
25982.nextp
25983.index log||SMTP protocol error
25984.index SMTP||logging protocol error
25985\smtp@_protocol@_error\: A log line is written for every SMTP protocol error
25986encountered.
25987.em
25988Exim does not have perfect detection of all protocol errors because of
25989transmission delays and the use of pipelining. If \\PIPELINING\\ has been
25990advertised to a client, an Exim server assumes that the client will use it, and
25991therefore it does not count `expected' errors (for example, \\RCPT\\ received
25992after rejecting \\MAIL\\) as protocol errors.
25993.nem
25994.nextp
25995.index SMTP||logging syntax errors
25996.index SMTP||syntax errors, logging
25997.index SMTP||unknown command, logging
25998.index log||unknown SMTP command
25999.index log||SMTP syntax error
26000\smtp@_syntax@_error\: A log line is written for every SMTP syntax error
26001encountered. An unrecognized command is treated as a syntax error. For an
26002external connection, the host identity is given; for an internal connection
26003using \-bs-\ the sender identification (normally the calling user) is given.
26004.nextp
26005.index log||subject
26006.index subject, logging
26007\subject\: The subject of the message is added to the arrival log line,
26008preceded by `T=' (T for `topic', since S is already used for `size').
26009Any MIME `words' in the subject are decoded. The \print@_topbitchars\ option
26010specifies whether characters with values greater than 127 should be logged
26011unchanged, or whether they should be rendered as escape sequences.
26012.nextp
26013.index log||certificate verification
26014.em
26015\tls@_certificate@_verified\: An extra item is added to <= and => log lines
26016when TLS is in use. The item is \"CV=yes"\ if the peer's certificate was
26017verified, and \"CV=no"\ if not.
26018.nem
26019.nextp
26020.index log||TLS cipher
26021.index TLS||logging cipher
26022\tls@_cipher\: When a message is sent or received over an encrypted connection,
26023the cipher suite used is added to the log line, preceded by X=.
26024.nextp
26025.index log||TLS peer DN
26026.index TLS||logging peer DN
26027\tls@_peerdn\: When a message is sent or received over an encrypted connection,
26028and a certificate is supplied by the remote host, the peer DN is added to the
26029log line, preceded by DN=.
26030.endp
26031
26032.section Message log
26033.index message||log file for
26034.index log||message log, description of
26035In addition to the general log files, Exim writes a log file for each message
26036that it handles. The names of these per-message logs are the message ids, and
26037.index \(msglog)\ directory
26038they are kept in the \(msglog)\ sub-directory of the spool directory. Each
26039message log contains copies of the log lines that apply to the message. This
26040makes it easier to inspect the status of an individual message without having
26041to search the main log. A message log is deleted when processing of the message
26042is complete,
26043.index \preserve@_message@_logs\
26044unless \preserve__message__logs\ is set, but this should be used only with
26045great care because they can fill up your disk very quickly.
26046
26047On a heavily loaded system, it may be desirable to disable the use of
26048per-message logs, in order to reduce disk I/O. This can be done by setting the
26049\message@_logs\ option false.
26050
26051
26052
26053.
26054.
26055.
26056. ============================================================================
26057.chapter Exim utilities
26058.set runningfoot "utilities"
26059.rset CHAPutils ~~chapter
26060.index utilities
26061A number of utility scripts and programs are supplied with Exim and are
26062described in this chapter. There is also the Exim Monitor, which is covered in
26063the next chapter. The utilities described here are:
26064
26065. This duplication seems to be the only way to arrange that the cross-
26066. references are omitted in the Texinfo version. They look horribly ugly.
26067
26068.if ~~texinfo
26069.display rm
26070.tabs 22
26071\*exiwhat*\ $t $rm{list what Exim processes are doing}
26072.newline
26073\*exiqgrep*\ $t $rm{grep the queue}
26074.newline
26075\*exiqsumm*\ $t $rm{summarize the queue}
26076\*exigrep*\ $t $rm{search the main log}
26077\*exipick*\ $t $rm{select messages on various criteria}
26078\*exicyclog*\ $t $rm{cycle (rotate) log files}
26079\*eximstats*\ $t $rm{extract statistics from the log}
26080\*exim@_checkaccess*\ $t $rm{check address acceptance from given IP}
26081\*exim@_dbmbuild*\ $t $rm{build a DBM file}
26082\*exinext*\ $t $rm{extract retry information}
26083\*exim@_dumpdb*\ $t $rm{dump a hints database}
26084\*exim@_tidydb*\ $t $rm{clean up a hints database}
26085\*exim@_fixdb*\ $t $rm{patch a hints database}
26086\*exim@_lock*\ $t $rm{lock a mailbox file}
26087.endd
26088.
26089.else
26090.
26091.display rm
26092.tabs 22
26093~~SECTfinoutwha \*exiwhat*\ $t $rm{list what Exim processes are doing}
26094.newline
26095~~SECTgreptheque \*exiqgrep*\ $t $rm{grep the queue}
26096.newline
26097~~SECTsumtheque \*exiqsumm*\ $t $rm{summarize the queue}
26098~~SECTextspeinf \*exigrep*\ $t $rm{search the main log}
26099.newline
26100.em
26101~~SECTexipick \*exipick*\ $t $rm{select messages on various criteria}
26102.newline
26103.nem
26104~~SECTcyclogfil \*exicyclog*\ $t $rm{cycle (rotate) log files}
26105~~SECTmailstat \*eximstats*\ $t $rm{extract statistics from the log}
26106~~SECTcheckaccess \*exim@_checkaccess*\ $t $rm{check address acceptance from given IP}
26107~~SECTdbmbuild \*exim@_dbmbuild*\ $t $rm{build a DBM file}
26108~~SECTfinindret \*exinext*\ $t $rm{extract retry information}
26109~~SECThindatmai \*exim@_dumpdb*\ $t $rm{dump a hints database}
26110~~SECThindatmai \*exim@_tidydb*\ $t $rm{clean up a hints database}
26111~~SECThindatmai \*exim@_fixdb*\ $t $rm{patch a hints database}
26112~~SECTmailboxmaint \*exim@_lock*\ $t $rm{lock a mailbox file}
26113.endd
26114.fi
26115
26116.section Finding out what Exim processes are doing (exiwhat)
26117.rset SECTfinoutwha "~~chapter.~~section"
26118.index \*exiwhat*\
26119.index process, querying
26120.index \\SIGUSR1\\
26121On operating systems that can restart a system call after receiving a signal
26122(most modern OS), an Exim process responds to the \\SIGUSR1\\ signal by writing
26123a line describing what it is doing to the file \(exim-process.info)\ in the
26124Exim spool directory. The \*exiwhat*\ script sends the signal to all Exim
26125processes it can find, having first emptied the file. It then waits for one
26126second to allow the Exim processes to react before displaying the results.
26127In order to run \*exiwhat*\ successfully you have to have sufficient privilege to
26128send the signal to the Exim processes, so it is normally run as root.
26129
26130Unfortunately, the \*ps*\ command which \*exiwhat*\ uses to find Exim processes
26131varies in different operating systems. Not only are different options used,
26132but the format of the output is different. For this reason, there are some
26133system configuration options that configure exactly how \*exiwhat*\ works. If it
26134doesn't seem to be working for you, check the following compile-time options:
26135.display
26136EXIWHAT@_PS@_CMD $rm{the command for running \*ps*\}
26137EXIWHAT@_PS@_ARG $rm{the argument for \*ps*\}
26138EXIWHAT@_EGREP@_ARG $rm{the argument for \*egrep*\ to select from \*ps*\ output}
26139EXIWHAT@_KILL@_ARG $rm{the argument for the \*kill*\ command}
26140.endd
26141An example of typical output from \*exiwhat*\ is
26142.display
26143.indent 0
26144 164 daemon: -q1h, listening on port 25
2614510483 running queue: waiting for 0tAycK-0002ij-00 (10492)
2614610492 delivering 0tAycK-0002ij-00 to mail.ref.example [10.19.42.42]
26147 (editor@@ref.example)
2614810592 handling incoming call from [192.168.243.242]
2614910628 accepting a local non-SMTP message
26150.endd
26151The first number in the output line is the process number. The third line has
26152been split here, in order to fit it on the page.
26153
26154
26155.section Selective queue listing (exiqgrep)
26156.rset SECTgreptheque "~~chapter.~~section"
26157.index \*exiqgrep*\
26158.index queue||grepping
26159This utility is a Perl script contributed by Matt Hubbard. It runs
26160.display asis
26161exim -bpu
26162.endd
26163to obtain a queue listing with undelivered recipients only, and then greps the
26164output to select messages that match given criteria. The following selection
26165options are available:
26166
26167.startoptions
26168
26169.option f <<regex>>
26170Match the sender address. The field that is tested is enclosed in angle
26171brackets, so you can test for bounce messages with
26172.display asis
26173exiqgrep -f '^<>$'
26174.endd
26175
26176.option r <<regex>>
26177Match a recipient address. The field that is tested is not enclosed in angle
26178brackets.
26179
26180.option s <<regex>>
26181Match against the size field.
26182
26183.option y <<seconds>>
26184Match messages that are younger than the given time.
26185
26186.option o <<seconds>>
26187Match messages that are older than the given time.
26188
26189.option z
26190Match only frozen messages.
26191
26192.option x
26193Match only non-frozen messages.
26194
26195.endoptions
26196
26197The following options control the format of the output:
26198
26199.startoptions
26200
26201.option c
26202Display only the count of matching messages.
26203
26204.option l
26205Long format -- display the full message information as output by Exim. This is
26206the default.
26207
26208.option i
26209Display message ids only.
26210
26211.option b
26212Brief format -- one line per message.
26213
26214.option R
26215Display messages in reverse order.
26216
26217.endoptions
26218
26219There is one more option, \-h-\, which outputs a list of options.
26220
26221
26222.section Summarising the queue (exiqsumm)
26223.rset SECTsumtheque "~~chapter.~~section"
26224.index \*exiqsumm*\
26225.index queue||summary
26226The \*exiqsumm*\ utility is a Perl script which reads the output of \*exim
26227-bp*\ and produces a summary of the messages on the queue. Thus, you use it by
26228running a command such as
26229.display asis
26230exim -bp | exiqsumm
26231.endd
26232The output consists of one line for each domain that has messages waiting for
26233it, as in the following example:
26234.display asis
26235 3 2322 74m 66m msn.com.example
26236.endd
26237Each line lists the number of
26238pending deliveries for a domain, their total volume, and the length of time
26239that the oldest and the newest messages have been waiting. Note that the number
26240of pending deliveries is greater than the number of messages when messages
26241have more than one recipient.
26242
26243A summary line is output at the end. By default the output is sorted on the
26244domain name, but \*exiqsumm*\ has the options \-a-\ and \-c-\, which cause the
26245output to be sorted by oldest message and by count of messages, respectively.
26246
26247The output of \*exim -bp*\ contains the original addresses in the message, so
26248this also applies to the output from \*exiqsumm*\. No domains from addresses
26249generated by aliasing or forwarding are included (unless the \one@_time\ option
26250of the \%redirect%\ router has been used to convert them into `top level'
26251addresses).
26252
26253
26254
26255.section Extracting specific information from the log (exigrep)
26256.rset SECTextspeinf "~~chapter.~~section"
26257.index \*exigrep*\
26258.index log||extracts, grepping for
26259The \*exigrep*\ utility is a Perl script that searches one or more main log
26260files for entries that match a given pattern. When it finds a match, it
26261extracts all the log entries for the relevant message, not just those that
26262match the pattern. Thus, \*exigrep*\ can extract complete log entries for a
26263given message, or all mail for a given user, or for a given host, for example.
26264
26265.em
26266If a matching log line is not associated with a specific message, it is always
26267included in \*exigrep*\'s output.
26268.nem
26269The usage is:
26270.display asis
26271exigrep [-l] [-t<n>] <pattern> [<log file>] ...
26272.endd
26273The \-t-\ argument specifies a number of seconds. It adds an additional
26274condition for message selection. Messages that are complete are shown only if
26275they spent more than <<n>> seconds on the queue.
26276
26277The \-l-\ flag means `literal', that is, treat all characters in the
26278pattern as standing for themselves. Otherwise the pattern must be a Perl
26279regular expression. The pattern match is case-insensitive. If no file names are
26280given on the command line, the standard input is read.
26281
26282If the location of a \*zcat*\ command is known from the definition of
26283\\ZCAT@_COMMAND\\ in \(Local/Makefile)\, \*exigrep*\ automatically passes any
26284file whose name ends in \\COMPRESS@_SUFFIX\\ through \*zcat*\ as it searches
26285it.
26286
26287.em
26288.section Selecting messages by various criteria (exipick)
26289.rset SECTexipick "~~chapter.~~section"
26290.index \*exipick*\
26291John Jetmore's \*exipick*\ utility is included in the Exim distribution. It
26292lists messages from the queue according to a variety of criteria. For details,
26293run:
26294.display asis
26295exipick --help
26296.endd
26297.nem
26298
26299
26300.section Cycling log files (exicyclog)
26301.rset SECTcyclogfil "~~chapter.~~section"
26302.index log||cycling local files
26303.index cycling logs
26304.index \*exicyclog*\
26305The \*exicyclog*\ script can be used to cycle (rotate) \*mainlog*\ and
26306\*rejectlog*\ files. This is not necessary if only syslog is being used,
26307or if you are using log files with datestamps in their names (see section
26308~~SECTdatlogfil).
26309Some operating systems have their own standard mechanisms for log cycling, and
26310these can be used instead of \*exicyclog*\ if preferred.
26311
26312Each time \*exicyclog*\ is run the file names get `shuffled down' by one. If the
26313main log file name is \(mainlog)\ (the default) then when \*exicyclog*\ is run
26314\(mainlog)\ becomes \(mainlog.01)\, the previous \(mainlog.01)\ becomes
26315\(mainlog.02)\ and so on, up to a limit which is set in the script, and which
26316defaults to 10. Reject logs are handled similarly.
26317
26318If no \(mainlog)\ file exists, the script does nothing. Files that `drop off'
26319the end are deleted. All files with numbers greater than 01 are compressed,
26320using a compression command which is configured by the \\COMPRESS@_COMMAND\\
26321setting in \(Local/Makefile)\. It is usual to run \*exicyclog*\ daily from a
26322root \crontab\ entry of the form
26323.display
263241 0 * * * su exim -c /usr/exim/bin/exicyclog
26325.endd
26326assuming you have used the name `exim' for the Exim user. You can run
26327\*exicyclog*\ as root if you wish, but there is no need.
26328
26329
26330.section Mail statistics (eximstats)
26331.rset SECTmailstat "~~chapter.~~section"
26332.index statistics
26333.index \*eximstats*\
26334A Perl script called \*eximstats*\ is provided for extracting statistical
26335information from log files. The output is either plain text, or HTML.
26336Exim log files are also suported by the \*Lire*\ system produced by the
26337LogReport Foundation (\?http://www.logreport.org?\).
26338
26339The \*eximstats*\ script has been hacked about quite a bit over time. The
26340latest version is the result of some extensive revision by Steve Campbell. A
26341lot of information is given by default, but there are options for suppressing
26342various parts of it. Following any options, the arguments to the script are a
26343list of files, which should be main log files. For example:
26344.display asis
26345eximstats -nr /var/spool/exim/log/mainlog.01
26346.endd
26347By default, \*eximstats*\ extracts information about the number and volume of
26348messages received from or delivered to various hosts. The information is sorted
26349both by message count and by volume, and the top fifty hosts in each category
26350are listed on the standard output. Similar information, based on email
26351addresses or domains instead of hosts can be requested by means of various
26352options. For messages delivered and received locally, similar statistics are
26353also produced per user.
26354
26355The output also includes total counts and statistics about delivery errors, and
26356histograms showing the number of messages received and deliveries made in each
26357hour of the day. A delivery with more than one address in its envelope (for
26358example, an SMTP transaction with more than one \\RCPT\\ command) is counted
26359as a single delivery by \*eximstats*\.
26360
26361Though normally more deliveries than receipts are reported (as messages may
26362have multiple recipients), it is possible for \*eximstats*\ to report more
26363messages received than delivered, even though the queue is empty at the start
26364and end of the period in question. If an incoming message contains no valid
26365recipients, no deliveries are recorded for it. A bounce message is handled as
26366an entirely separate message.
26367
26368\*eximstats*\ always outputs a grand total summary giving the volume and number
26369of messages received and deliveries made, and the number of hosts involved in
26370each case. It also outputs the number of messages that were delayed (that is,
26371not completely delivered at the first attempt), and the number that had at
26372least one address that failed.
26373
26374The remainder of the output is in sections that can be independently disabled
26375or modified by various options. It consists of a summary of deliveries by
26376transport, histograms of messages received and delivered per time interval
26377(default per hour), information about the time messages spent on the queue,
26378a list of relayed messages, lists of the top fifty sending hosts, local
26379senders, destination hosts, and destination local users by count and by volume,
26380and a list of delivery errors that occurred.
26381
26382The relay information lists messages that were actually relayed, that is, they
26383came from a remote host and were directly delivered to some other remote host,
26384without being processed (for example, for aliasing or forwarding) locally.
26385
26386The options for \*eximstats*\ are as follows:
26387
26388.startoptions
26389.index \*eximstats*\||options
26390.option bydomain
26391The `league tables' are computed on the basis of the superior domains of the
26392sending hosts instead of the sending and receiving hosts. This option may be
26393combined with \-byhost-\ and/or \-byemail-\.
26394
26395.option byedomain
26396This is a synonym for \-byemaildomain-\.
26397
26398.option byemail
26399The `league tables' are computed on the basis of complete email addresses,
26400instead of sending and receiving hosts. This option may be combined with
26401\-byhost-\ and/or \-bydomain-\.
26402
26403.option byemaildomain
26404The `league tables' are computed on the basis of the sender's email domain
26405instead of the sending and receiving hosts. This option may be combined with
26406\-byhost-\, \-bydomain-\, or \-byemail-\.
26407
26408.option byhost
26409The `league tables' are computed on the basis of sending and receiving hosts.
26410This is the default option. It may be combined with \-bydomain-\ and/or
26411\-byemail-\.
26412
26413.option cache
26414Cache results of \*timegm()*\ lookups. This results in a significant speedup
26415when processing hundreds of thousands of messages, at a cost of increasing the
26416memory utilisation.
26417
26418.option chartdir <<dir>>
26419When \-charts-\ is specified, create the charts in the directory <<dir>>.
26420
26421.option chartrel <<dir>>
26422When \-charts-\ is specified, this option specifies the relative directory for
26423the \"img src="\ tags from where to include the charts.
26424
26425.option charts
26426Create graphical charts to be displayed in HTML output. This requires the
26427\"GD"\, \"GDTextUtil"\, and \"GDGraph"\ Perl modules, which can be obtained
26428from \?http://www.cpan.org/modules/01modules.index.html?\.
26429
26430To install these, download and unpack them, then use the normal Perl
26431installation procedure:
26432.display asis
26433perl Makefile.PL
26434make
26435make test
26436make install
26437.endd
26438
26439.option d
26440This is a debug flag. It causes \*eximstats*\ to output the \*eval()*\'d parser
26441to the standard output, which makes it easier to trap errors in the eval
26442section. Remember to add one to the line numbers to allow for the title.
26443
26444
26445.option help
26446Show help information about \*eximstats*\' options.
26447
26448.option h <<n>>
26449This option controls the histograms of messages received and deliveries per
26450time interval. By default the time interval is one hour. If \-h0-\ is given,
26451the histograms are suppressed; otherwise the value of <<n>> gives the number of
26452divisions per hour. Valid values are 0, 1, 2, 3, 5, 10, 15, 20, 30 or 60, so
26453\-h2-\ sets an interval of 30 minutes, and the default is equivalent to \-h1-\.
26454
26455.option html
26456Output the results in HTML instead of plain text.
26457
26458.option merge
26459This option causes \*eximstats*\ to merge old reports into a combined report.
26460When this option is used, the input files must be outputs from previous calls
26461to \*eximstats*\, not raw log files. For example, you could produce a set of
26462daily reports and a weekly report by commands such as
26463.display asis
26464eximstats mainlog.sun > report.sun.txt
26465eximstats mainlog.mon > report.mon.txt
26466eximstats mainlog.tue > report.tue.txt
26467eximstats mainlog.wed > report.wed.txt
26468eximstats mainlog.thu > report.thu.txt
26469eximstats mainlog.fri > report.fri.txt
26470eximstats mainlog.sat > report.sat.txt
26471eximstats -merge -html report.*.txt > weekly_report.html
26472.endd
26473You can merge text or html reports and output the results as text or html. You
26474can use all the normal \*eximstats*\ output options, but only data included in
26475the original reports can be shown. When merging reports, some loss of accuracy
26476may occur in the `league tables', towards the ends of the lists. The order of
26477items in the `league tables' may vary when the data volumes round to the same
26478value.
26479
26480.option ne
26481Suppress the display of information about failed deliveries (errors).
26482
26483.option nr
26484Suppress information about messages relayed through this host.
26485
26486.option nr /pattern/
26487Suppress information about relayed messages that match the pattern, which is
26488matched against a string of the following form (split over two lines here in
26489order to fit it on the page):
26490.display asis
26491H=<host> [<ip address>] A=<sender address> =>
26492 H=<host> A=<recipient address>
26493.endd
26494for example
26495.display asis
26496H=in.host [1.2.3.4] A=from@some.where.example =>
26497 H=out.host A=to@else.where.example
26498.endd
26499The sending host name appears in parentheses if it has not been verified as
26500matching the IP address. The mail addresses are taken from the envelope, not
26501the headers. This option allows you to screen out hosts whom you are happy to
26502have using your host as a relay.
26503
26504.option nt
26505Suppress the statistics about delivery by transport.
26506
26507.option nt/<<pattern>>/
26508Suppress the statistics about delivery by any transport whose name matches the
26509pattern. If you are using one transport to send all messages to a scanning
26510mechanism before doing the real delivery, this feature can be used to omit that
26511transport from your normal statistics (on the grounds that it is of no
26512interest).
26513
26514
26515.option "pattern" "#<<description>>#/<<pattern>>/"
26516Count lines matching specified patterns and show them in
26517the results. For example:
26518.display asis
26519-pattern 'Refused connections' '/refused connection/'
26520.endd
26521This option can be specified multiple times.
26522
26523.option q0
26524Suppress information about times messages spend on the queue.
26525
26526.option q <<n1>>...
26527This option sets an alternative list of time intervals for the queueing
26528information. The values are separated by commas and are in seconds, but can
26529involve arithmetic multipliers, so for example you can set 3$*$60 to specify 3
26530minutes. A setting such as
26531.display asis
26532-q60,5*60,10*60
26533.endd
26534causes \*eximstats*\ to give counts of messages that stayed on the queue for less
26535than one minute, less than five minutes, less than ten minutes, and over ten
26536minutes.
26537
26538.option t <<n>>
26539Sets the `top' count to <<n>>. This controls the listings of the `top <<n>>'
26540hosts and users by count and volume. The default is 50, and setting 0
26541suppresses the output altogether.
26542
26543.option tnl
26544Omit local information from the `top' listings.
26545
26546.option t@_remote@_users
26547Include remote users in the `top' listings.
26548
26549.endoptions
26550
26551
26552.section Checking access policy (exim@_checkaccess)
26553.rset SECTcheckaccess "~~chapter.~~section"
26554.index \*exim@_checkaccess*\
26555.index policy control||checking access
26556.index checking access
26557The \-bh-\ command line argument allows you to run a fake SMTP session with
26558debugging output, in order to check what Exim is doing when it is applying
26559policy controls to incoming SMTP mail. However, not everybody is sufficiently
26560familiar with the SMTP protocol to be able to make full use of \-bh-\, and
26561sometimes you just want to answer the question \*Does this address have
26562access?*\ without bothering with any further details.
26563
26564The \*exim@_checkaccess*\ utility is a `packaged' version of \-bh-\. It takes
26565two arguments, an IP address and an email address:
26566.display asis
26567exim_checkaccess 10.9.8.7 A.User@a.domain.example
26568.endd
26569The utility runs a call to Exim with the \-bh-\ option, to test whether the
26570given email address would be accepted in a \\RCPT\\ command in a TCP/IP
26571connection from the host with the given IP address. The output of the utility
26572is either the word `accepted', or the SMTP error response, for example:
26573.display asis
26574Rejected:
26575 550 Relay not permitted
26576.endd
26577When running this test, the utility uses \"<>"\ as the envelope sender address
26578for the \\MAIL\\ command, but you can change this by providing additional
26579options. These are passed directly to the Exim command. For example, to specify
26580that the test is to be run with the sender address \*himself@@there.example*\
26581you can use:
26582.display asis
26583exim_checkaccess 10.9.8.7 A.User@a.domain.example \
26584 -f himself@there.example
26585.endd
26586Note that these additional Exim command line items must be given after the two
26587mandatory arguments.
26588
26589Because the \exim@_checkaccess\ uses \-bh-\, it does not perform callouts while
26590running its checks. You can run checks that include callouts by using \-bhc-\,
26591but this is not yet available in a `packaged' form.
26592
26593
26594.section Making DBM files (exim@_dbmbuild)
26595.rset SECTdbmbuild "~~chapter.~~section"
26596.index DBM||building dbm files
26597.index building DBM files
26598.index \*exim@_dbmbuild*\
26599.index lower casing
26600.index binary zero||in lookup key
26601The \*exim@_dbmbuild*\ program reads an input file containing keys and data in
26602the format used by the \%lsearch%\ lookup (see section ~~SECTsinglekeylookups).
26603It writes a DBM file using the lower-cased alias names as keys and the
26604remainder of the information as data. The lower-casing can be prevented by
26605calling the program with the \-nolc-\ option.
26606
26607A terminating zero is included as part of the key string. This is expected by
26608the \%dbm%\ lookup type. However, if the option \-nozero-\ is given,
26609\*exim@_dbmbuild*\ creates files without terminating zeroes in either the key
26610strings or the data strings. The \%dbmnz%\ lookup type can be used with such
26611files.
26612
26613The program requires two arguments: the name of the input file (which can be a
26614single hyphen to indicate the standard input), and the name of the output file.
26615It creates the output under a temporary name, and then renames it if all went
26616well.
26617.index \\USE@_DB\\
26618If the native DB interface is in use (\\USE@_DB\\ is set in a compile-time
26619configuration file -- this is common in free versions of Unix) the two file
26620names must be different, because in this mode the Berkeley DB functions create
26621a single output file using exactly the name given. For example,
26622.display asis
26623exim_dbmbuild /etc/aliases /etc/aliases.db
26624.endd
26625reads the system alias file and creates a DBM version of it in
26626\(/etc/aliases.db)\.
26627
26628In systems that use the \*ndbm*\ routines (mostly proprietary versions of Unix),
26629two files are used, with the suffixes \(.dir)\ and \(.pag)\. In this
26630environment, the suffixes are added to the second argument of
26631\*exim@_dbmbuild*\, so it can be the same as the first. This is also the case
26632when the Berkeley functions are used in compatibility mode (though this is not
26633recommended), because in that case it adds a \(.db)\ suffix to the file name.
26634
26635If a duplicate key is encountered, the program outputs a warning, and when it
26636finishes, its return code is 1 rather than zero, unless the \-noduperr-\ option
26637is used. By default, only the first of a set of duplicates is used -- this
26638makes it compatible with \%lsearch%\ lookups. There is an option \-lastdup-\
26639which causes it to use the data for the last duplicate instead. There is also
26640an option \-nowarn-\, which stops it listing duplicate keys to \stderr\. For
26641other errors, where it doesn't actually make a new file, the return code is 2.
26642
26643
26644
26645.section Finding individual retry times (exinext)
26646.rset SECTfinindret "~~chapter.~~section"
26647.index retry||times
26648.index \*exinext*\
26649A utility called \*exinext*\ (mostly a Perl script) provides the ability to fish
26650specific information out of the retry database. Given a mail domain (or a
26651complete address), it looks up the hosts for that domain, and outputs any retry
26652information for the hosts or for the domain. At present, the retry information
26653is obtained by running \*exim@_dumpdb*\ (see below) and post-processing the
26654output. For example:
26655.display asis
26656$ exinext piglet@milne.fict.example
26657kanga.milne.fict.example:192.168.8.1 error 146: Connection refused
26658 first failed: 21-Feb-1996 14:57:34
26659 last tried: 21-Feb-1996 14:57:34
26660 next try at: 21-Feb-1996 15:02:34
26661roo.milne.fict.example:192.168.8.3 error 146: Connection refused
26662 first failed: 20-Jan-1996 13:12:08
26663 last tried: 21-Feb-1996 11:42:03
26664 next try at: 21-Feb-1996 19:42:03
26665 past final cutoff time
26666.endd
26667You can also give \*exinext*\ a local part, without a domain, and it
26668will give any retry information for that local part in your default domain.
26669A message id can be used to obtain retry information pertaining to a specific
26670message. This exists only when an attempt to deliver a message to a remote host
26671suffers a message-specific error (see section ~~SECToutSMTPerr). \*exinext*\ is
26672not particularly efficient, but then it isn't expected to be run very often.
26673
26674.em
26675The \*exinext*\ utility calls Exim to find out information such as the location
26676of the spool directory. The utility has \-C-\ and \-D-\ options, which are
26677passed on to the \*exim*\ commands. The first specifies an alternate Exim
26678configuration file, and the second sets macros for use within the configuration
26679file. These features are mainly to help in testing, but might also be useful in
26680environments where more than one configuration file is in use.
26681.nem
26682
26683
26684
26685.section Hints database maintenance (exim@_dumpdb, exim@_fixdb, exim@_tidydb)
26686.rset SECThindatmai "~~chapter.~~section"
26687.index hints database||maintenance
26688.index maintaining Exim's hints database
26689Three utility programs are provided for maintaining the DBM files that Exim
26690uses to contain its delivery hint information. Each program requires two
26691arguments. The first specifies the name of Exim's spool directory, and the
26692second is the name of the database it is to operate on. These are as
26693follows:
26694.numberpars $.
26695\*retry*\: the database of retry information
26696.nextp
26697\*wait-*\<<transport name>>: databases of information about messages waiting
26698for remote hosts
26699.nextp
26700.em
26701\*callout*\: the callout cache
26702.nem
26703.nextp
26704\*misc*\: other hints data
26705.endp
26706.em
26707The \*misc*\ database is used for
26708.numberpars alpha
26709Serializing \\ETRN\\ runs (when \smtp@_etrn@_serialize\ is set)
26710.nextp
26711Serializing delivery to a specific host (when \serialize@_hosts\ is set in an
26712\%smtp%\ transport)
26713.endp
26714.nem
26715.index \*exim@_dumpdb*\
26716The entire contents of a database are written to the standard output by the
26717\*exim@_dumpdb*\ program, which has no options or arguments other than the
26718spool and database names. For example, to dump the retry database:
26719.display asis
26720exim_dumpdb /var/spool/exim retry
26721.endd
26722Two lines of output are produced for each entry:
26723.display
26724 T:mail.ref.example:192.168.242.242 146 77 Connection refused
2672531-Oct-1995 12:00:12 02-Nov-1995 12:21:39 02-Nov-1995 20:21:39 *
26726.endd
26727The first item on the first line is the key of the record. It starts with one
26728of the letters R, or T, depending on whether it refers to a routing or
26729transport retry. For a local delivery, the next part is the local address; for
26730a remote delivery it is the name of the remote host, followed by its failing IP
26731address (unless \no@_retry@_include@_ip@_address\ is set on the \%smtp%\
26732transport).
26733.em
26734If the remote port is not the standard one (port 25), it is added to the IP
26735address.
26736.nem
26737Then there follows an error code, an additional error code, and a
26738textual description of the error.
26739
26740The three times on the second line are the time of first failure, the time of
26741the last delivery attempt, and the computed time for the next attempt. The line
26742ends with an asterisk if the cutoff time for the last retry rule has been
26743exceeded.
26744
26745Each output line from \*exim@_dumpdb*\ for the \*wait-*\$it{xxx} databases
26746consists of a host name followed by a list of ids for messages that are or were
26747waiting to be delivered to that host. If there are a very large number for any
26748one host, continuation records, with a sequence number added to the host name,
26749may be seen. The data in these records is often out of date, because a message
26750may be routed to several alternative hosts, and Exim makes no effort to keep
26751cross-references.
26752
26753.index \*exim@_tidydb*\
26754The \*exim@_tidydb*\ utility program is used to tidy up the contents of the
26755hints databases. If run with no options, it removes all records from a database
26756that are more than 30 days old. The cutoff date can be altered by means of the
26757\-t-\ option, which must be followed by a time. For example, to remove all
26758records older than a week from the retry database:
26759.display asis
26760exim_tidydb -t 7d /var/spool/exim retry
26761.endd
26762Both the \*wait-*\$it{xxx} and \*retry*\ databases contain items that involve
26763message ids. In the former these appear as data in records keyed by host --
26764they were messages that were waiting for that host -- and in the latter they
26765are the keys for retry information for messages that have suffered certain
26766types of error. When \*exim@_tidydb*\ is run, a check is made to ensure that
26767message ids in database records are those of messages that are still on the
26768queue. Message ids for messages that no longer exist are removed from
26769\*wait-*\$it{xxx} records, and if this leaves any records empty, they are
26770deleted. For the \*retry*\ database, records whose keys are non-existent message
26771ids are removed. The \*exim@_tidydb*\ utility outputs comments on the standard
26772output whenever it removes information from the database.
26773
26774Removing records from a DBM file does not normally make the file smaller, but
26775all the common DBM libraries are able to re-use the space that is released.
26776It is therefore suggested that \*exim@_tidydb*\ be run periodically on all the
26777hints databases, but at a quiet time of day, because it requires a database to
26778be locked (and therefore inaccessible to Exim) while it does its work.
26779
26780.index \*exim@_fixdb*\
26781The \*exim@_fixdb*\ program is a utility for interactively modifying databases.
26782Its main use is for testing Exim, but it might also be occasionally useful for
26783getting round problems in a live system. It has no options, and its interface
26784is somewhat crude. On entry, it prompts for input with a right angle-bracket. A
26785key of a database record can then be entered, and the data for that record is
26786displayed.
26787
26788If `d' is typed at the next prompt, the entire record is deleted. For all
26789except the \*retry*\ database, that is the only operation that can be carried
26790out. For the \*retry*\ database, each field is output preceded by a number, and
26791data for individual fields can be changed by typing the field number followed
26792by new data, for example:
26793.display asis
26794> 4 951102:1000
26795.endd
26796resets the time of the next delivery attempt. Time values are given as a
26797sequence of digit pairs for year, month, day, hour, and minute. Colons can be
26798used as optional separators.
26799
26800
26801
26802.section Mailbox maintenance (exim@_lock)
26803.rset SECTmailboxmaint "~~chapter.~~section"
26804.index mailbox||maintenance
26805.index \*exim@_lock*\
26806.index locking mailboxes
26807The \*exim@_lock*\ utility locks a mailbox file using the same algorithm as
26808Exim. For a discussion of locking issues, see section ~~SECTopappend.
26809\*Exim@_lock*\ can be used to prevent any modification of a mailbox by Exim or
26810a user agent while investigating a problem. The utility requires the name of
26811the file as its first argument. If the locking is successful, the second
26812argument is run as a command (using C's \*system()*\ function); if there is no
26813second argument, the value of the SHELL environment variable is used; if this
26814is unset or empty, \(/bin/sh)\ is run. When the command finishes, the mailbox
26815is unlocked and the utility ends. The following options are available:
26816
26817.startoptions
26818
26819.option fcntl
26820Use \*fcntl()*\ locking on the open mailbox.
26821
26822.option flock
26823Use \*flock()*\ locking on the open mailbox, provided the operating system
26824supports it.
26825
26826.option interval
26827This must be followed by a number, which is a number of seconds; it sets the
26828interval to sleep between retries (default 3).
26829
26830.option lockfile
26831Create a lock file before opening the mailbox.
26832
26833.option mbx
26834Lock the mailbox using MBX rules.
26835
26836.option q
26837Suppress verification output.
26838
26839.option retries
26840This must be followed by a number; it sets the number of times to try to get
26841the lock (default 10).
26842
26843.option restore@_time
26844This option causes \exim@_lock\ to restore the modified and read times to the
26845locked file before exiting. This allows you to access a locked mailbox (for
26846example, to take a backup copy) without disturbing the times that the user
26847subsequently sees.
26848
26849.option timeout
26850This must be followed by a number, which is a number of seconds; it sets a
26851timeout to be used with a blocking \*fcntl()*\ lock. If it is not set (the
26852default), a non-blocking call is used.
26853
26854.option v
26855Generate verbose output.
26856
26857.endoptions
26858
26859If none of \-fcntl-\,
26860\-flock-\,
26861\-lockfile-\ or \-mbx-\ are given, the default is to create a lock file and
26862also to use \*fcntl()*\ locking on the mailbox, which is the same as Exim's
26863default. The use of
26864\-flock-\
26865or \-fcntl-\ requires that the file be writeable; the use of
26866\-lockfile-\ requires that the directory containing the file be writeable.
26867Locking by lock file does not last for ever; Exim assumes that a lock file is
26868expired if it is more than 30 minutes old.
26869
26870The \-mbx-\ option can be used with either or both of \-fcntl-\ or \-flock-\.
26871It assumes \-fcntl-\ by default.
26872MBX locking causes a shared lock to be taken out on the open mailbox, and an
26873exclusive lock on the file \(/tmp/.$it{n}.$it{m})\ where $it{n} and $it{m} are
26874the device number and inode number of the mailbox file. When the locking is
26875released, if an exclusive lock can be obtained for the mailbox, the file in
26876\(/tmp)\ is deleted.
26877
26878The default output contains verification of the locking that takes place. The
26879\-v-\ option causes some additional information to be given. The \-q-\ option
26880suppresses all output except error messages.
26881
26882A command such as
26883.display asis
26884exim_lock /var/spool/mail/spqr
26885.endd
26886runs an interactive shell while the file is locked, whereas
26887.display
26888exim@_lock -q /var/spool/mail/spqr @<@<End
26889<<some commands>>
26890End
26891.endd
26892runs a specific non-interactive sequence of commands while the file is locked,
26893suppressing all verification output. A single command can be run by a command
26894such as
26895.display asis
26896exim_lock -q /var/spool/mail/spqr \
26897 "cp /var/spool/mail/spqr /some/where"
26898.endd
26899Note that if a command is supplied, it must be entirely contained within the
26900second argument -- hence the quotes.
26901
26902
26903
26904.
26905.
26906.
26907.
26908. ============================================================================
26909.chapter The Exim monitor
26910.set runningfoot "monitor"
26911.rset CHAPeximon ~~chapter
26912.index monitor
26913.index Exim monitor
26914.index X-windows
26915.index \*eximon*\
26916.index Local/eximon.conf
26917.index \(exim@_monitor/EDITME)\
26918The Exim monitor is an application which displays in an X window information
26919about the state of Exim's queue and what Exim is doing. An admin user can
26920perform certain operations on messages from this GUI interface; however all
26921such facilities are also available from the command line, and indeed, the
26922monitor itself makes use of the command line to perform any actions requested.
26923
26924
26925.section Running the monitor
26926The monitor is started by running the script called \*eximon*\. This is a shell
26927script that sets up a number of environment variables, and then runs the
26928binary called \(eximon.bin)\. The default appearance of the monitor window can
26929be changed by editing the \(Local/eximon.conf)\ file created by editing
26930\(exim@_monitor/EDITME)\. Comments in that file describe what the various
26931parameters are for.
26932
26933The parameters that get built into the \*eximon*\ script can be overridden for a
26934particular invocation by setting up environment variables of the same names,
26935preceded by `$tt{EXIMON@_}'. For example, a shell command such as
26936.display asis
26937EXIMON_LOG_DEPTH=400 eximon
26938.endd
26939(in a Bourne-compatible shell) runs \*eximon*\ with an overriding setting of the
26940\\LOG@_DEPTH\\ parameter. If \\EXIMON@_LOG@_FILE@_PATH\\ is set in the
26941environment, it overrides the Exim log file configuration. This makes it
26942possible to have \*eximon*\ tailing log data that is written to syslog, provided
26943that MAIL.INFO syslog messages are routed to a file on the local host.
26944
26945X resources can be used to change the appearance of the window in the normal
26946way. For example, a resource setting of the form
26947.display asis
26948Eximon*background: gray94
26949.endd
26950changes the colour of the background to light grey rather than white. The
26951stripcharts are drawn with both the data lines and the reference lines in
26952black. This means that the reference lines are not visible when on top of the
26953data. However, their colour can be changed by setting a resource called
26954`highlight' (an odd name, but that's what the Athena stripchart widget uses).
26955For example, if your X server is running Unix, you could set up lighter
26956reference lines in the stripcharts by obeying
26957.display asis
26958xrdb -merge <<End
26959Eximon*highlight: gray
26960End
26961.endd
26962
26963.index admin user
26964In order to see the contents of messages on the queue, and to operate on them,
26965\*eximon*\ must either be run as root or by an admin user.
26966
26967The monitor's window is divided into three parts. The first contains one or
26968more stripcharts and two action buttons, the second contains a `tail' of the
26969main log file, and the third is a display of the queue of messages awaiting
26970delivery, with two more action buttons. The following sections describe these
26971different parts of the display.
26972
26973
26974
26975.section The stripcharts
26976.index stripchart
26977The first stripchart is always a count of messages on the queue. Its name can
26978be configured by setting \\QUEUE@_STRIPCHART@_NAME\\ in the
26979\(Local/eximon.conf)\ file. The remaining stripcharts are defined in the
26980configuration script by regular expression matches on log file entries, making
26981it possible to display, for example, counts of messages delivered to certain
26982hosts or using certain transports. The supplied defaults display counts of
26983received and delivered messages, and of local and SMTP deliveries. The default
26984period between stripchart updates is one minute; this can be adjusted by a
26985parameter in the \(Local/eximon.conf)\ file.
26986
26987The stripchart displays rescale themselves automatically as the value they are
26988displaying changes. There are always 10 horizontal lines in each chart; the
26989title string indicates the value of each division when it is greater than one.
26990For example, `x2' means that each division represents a value of 2.
26991
26992It is also possible to have a stripchart which shows the percentage fullness of
26993a particular disk partition, which is useful when local deliveries are confined
26994to a single partition.
26995.index \statvfs\ function
26996This relies on the availability of the \*statvfs()*\ function or equivalent in
26997the operating system. Most, but not all versions of Unix that support Exim have
26998this. For this particular stripchart, the top of the chart always represents
26999100%, and the scale is given as `x10%'. This chart is configured by setting
27000\\SIZE@_STRIPCHART\\ and (optionally) \\SIZE@_STRIPCHART@_NAME\\ in the
27001\(Local/eximon.conf)\ file.
27002
27003
27004
27005.section Main action buttons
27006.index size||of monitor window
27007.index monitor window size
27008.index window size
27009Below the stripcharts there is an action button for quitting the monitor. Next
27010to this is another button marked `Size'. They are placed here so that shrinking
27011the window to its default minimum size leaves just the queue count stripchart
27012and these two buttons visible. Pressing the `Size' button causes the window to
27013expand to its maximum size, unless it is already at the maximum, in which case
27014it is reduced to its minimum.
27015
27016When expanding to the maximum, if the window cannot be fully seen where it
27017currently is, it is moved back to where it was the last time it was at full
27018size. When it is expanding from its minimum size, the old position is
27019remembered, and next time it is reduced to the minimum it is moved back there.
27020
27021The idea is that you can keep a reduced window just showing one or two
27022stripcharts at a convenient place on your screen, easily expand it to show
27023the full window when required, and just as easily put it back to what it was.
27024The idea is copied from what the \*twm*\ window manager does for its
27025\*f.fullzoom*\ action. The minimum size of the window can be changed by setting
27026the \\MIN@_HEIGHT\\ and \\MIN@_WIDTH\\ values in \(Local/eximon.conf)\.
27027
27028Normally, the monitor starts up with the window at its full size, but it can be
27029built so that it starts up with the window at its smallest size, by setting
27030\\START@_SMALL\\=yes in \(Local/eximon.conf)\.
27031
27032
27033.section The log display
27034.index log||tail of, in monitor
27035The second section of the window is an area in which a display of the tail of
27036the main log is maintained.
27037To save space on the screen, the timestamp on each log line is shortened by
27038removing the date and, if \log@_timezone\ is set, the timezone.
27039The log tail is not available when the only destination for logging data is
27040syslog, unless the syslog lines are routed to a local file whose name is passed
27041to \*eximon*\ via the \\EXIMON@_LOG@_FILE@_PATH\\ environment variable.
27042
27043The log sub-window has a scroll bar at its lefthand side which can be used to
27044move back to look at earlier text, and the up and down arrow keys also have a
27045scrolling effect. The amount of log that is kept depends on the setting of
27046\\LOG@_BUFFER\\ in \(Local/eximon.conf)\, which specifies the amount of memory
27047to use. When this is full, the earlier 50% of data is discarded -- this is much
27048more efficient than throwing it away line by line. The sub-window also has a
27049horizontal scroll bar for accessing the ends of long log lines. This is the
27050only means of horizontal scrolling; the right and left arrow keys are not
27051available. Text can be cut from this part of the window using the mouse in the
27052normal way. The size of this subwindow is controlled by parameters in the
27053configuration file \(Local/eximon.conf)\.
27054
27055Searches of the text in the log window can be carried out by means of the ^R
27056and ^S keystrokes, which default to a reverse and a forward search,
27057respectively. The search covers only the text that is displayed in the window.
27058It cannot go further back up the log.
27059
27060The point from which the search starts is indicated by a caret marker. This is
27061normally at the end of the text in the window, but can be positioned explicitly
27062by pointing and clicking with the left mouse button, and is moved automatically
27063by a successful search. If new text arrives in the window when it is scrolled
27064back, the caret remains where it is, but if the window is not scrolled back,
27065the caret is moved to the end of the new text.
27066
27067Pressing ^R or ^S pops up a window into which the search text can be typed.
27068There are buttons for selecting forward or reverse searching, for carrying out
27069the search, and for cancelling. If the `Search' button is pressed, the search
27070happens and the window remains so that further searches can be done. If the
27071`Return' key is pressed, a single search is done and the window is closed. If
27072^C is typed the search is cancelled.
27073
27074The searching facility is implemented using the facilities of the Athena text
27075widget. By default this pops up a window containing both `search' and `replace'
27076options. In order to suppress the unwanted `replace' portion for eximon, a
27077modified version of the \TextPop\ widget is distributed with Exim. However, the
27078linkers in BSDI and HP-UX seem unable to handle an externally provided version
27079of \TextPop\ when the remaining parts of the text widget come from the standard
27080libraries. The compile-time option \\EXIMON@_TEXTPOP\\ can be unset to cut out
27081the modified \TextPop\, making it possible to build Eximon on these systems, at
27082the expense of having unwanted items in the search popup window.
27083
27084
27085.section The queue display
27086.index queue||display in monitor
27087The bottom section of the monitor window contains a list of all messages that
27088are on the queue, which includes those currently being received or delivered,
27089as well as those awaiting delivery. The size of this subwindow is controlled by
27090parameters in the configuration file \(Local/eximon.conf)\, and the frequency
27091at which it is updated is controlled by another parameter in the same file --
27092the default is 5 minutes, since queue scans can be quite expensive. However,
27093there is an `Update' action button just above the display which can be used to
27094force an update of the queue display at any time.
27095
27096When a host is down for some time, a lot of pending mail can build up for it,
27097and this can make it hard to deal with other messages on the queue. To help
27098with this situation there is a button next to `Update' called `Hide'. If
27099pressed, a dialogue box called `Hide addresses ending with' is put up. If you
27100type anything in here and press `Return', the text is added to a chain of such
27101texts, and if every undelivered address in a message matches at least one
27102of the texts, the message is not displayed.
27103
27104If there is an address that does not match any of the texts, all the addresses
27105are displayed as normal. The matching happens on the ends of addresses so, for
27106example, \*cam.ac.uk*\ specifies all addresses in Cambridge, while
27107\*xxx@@foo.com.example*\ specifies just one specific address. When any hiding
27108has been set up, a button called `Unhide' is displayed. If pressed, it cancels
27109all hiding. Also, to ensure that hidden messages do not get forgotten, a hide
27110request is automatically cancelled after one hour.
27111
27112While the dialogue box is displayed, you can't press any buttons or do anything
27113else to the monitor window. For this reason, if you want to cut text from the
27114queue display to use in the dialogue box, you have to do the cutting before
27115pressing the `Hide' button.
27116
27117The queue display contains, for each unhidden queued message, the length of
27118time it has been on the queue, the size of the message, the message id, the
27119message sender, and the first undelivered recipient, all on one line. If it is
27120a bounce message, the sender is shown as `<>'. If there is more than one
27121recipient to which the message has not yet been delivered, subsequent ones are
27122listed on additional lines, up to a maximum configured number, following which
27123an ellipsis is displayed. Recipients that have already received the message are
27124not shown.
27125.index frozen messages||display
27126If a message is frozen, an asterisk is displayed at the left-hand side.
27127
27128The queue display has a vertical scroll bar, and can also be scrolled by means
27129of the arrow keys. Text can be cut from it using the mouse in the normal way.
27130The text searching facilities, as described above for the log window, are also
27131available, but the caret is always moved to the end of the text when the queue
27132display is updated.
27133
27134
27135.section The queue menu
27136.index queue||menu in monitor
27137If the \shift\ key is held down and the left button is clicked when the mouse
27138pointer is over the text for any message, an action menu pops up, and the first
27139line of the queue display for the message is highlighted. This does not affect
27140any selected text.
27141
27142If you want to use some other event for popping up the menu, you can set the
27143\\MENU@_EVENT\\ parameter in \(Local/eximon.conf)\ to change the default, or
27144set \\EXIMON@_MENU@_EVENT\\ in the environment before starting the monitor. The
27145value set in this parameter is a standard X event description. For example, to
27146run eximon using \ctrl\ rather than \shift\ you could use
27147.display asis
27148EXIMON_MENU_EVENT='Ctrl<Btn1Down>' eximon
27149.endd
27150The title of the menu is the message id, and it contains entries which act as
27151follows:
27152.numberpars $.
27153\*message log*\: The contents of the message log for the message are displayed in
27154a new text window.
27155.nextp
27156\*headers*\: Information from the spool file that contains the envelope
27157information and headers is displayed in a new text window. See chapter
27158~~CHAPspool for a description of the format of spool files.
27159.nextp
27160\*body*\: The contents of the spool file containing the body of the message are
27161displayed in a new text window. There is a default limit of 20,000 bytes to the
27162amount of data displayed. This can be changed by setting the \\BODY@_MAX\\
27163option at compile time, or the \\EXIMON@_BODY@_MAX\\ option at run time.
27164.nextp
27165\*deliver message*\: A call to Exim is made using the \-M-\ option to request
27166delivery of the message. This causes an automatic thaw if the message is
27167frozen. The \-v-\ option is also set, and the output from Exim is displayed in
27168a new text window. The delivery is run in a separate process, to avoid holding
27169up the monitor while the delivery proceeds.
27170.nextp
27171\*freeze message*\: A call to Exim is made using the \-Mf-\ option to request
27172that the message be frozen.
27173.nextp
27174.index thawing messages
27175.index unfreezing messages
27176.index frozen messages||thawing
27177\*thaw message*\: A call to Exim is made using the \-Mt-\ option to request that
27178the message be thawed.
27179.nextp
27180.index delivery||forcing failure
27181\*give up on msg*\: A call to Exim is made using the \-Mg-\ option to request
27182that Exim gives up trying to deliver the message. A bounce message is generated
27183for any remaining undelivered addresses.
27184.nextp
27185\*remove message*\: A call to Exim is made using the \-Mrm-\ option to request
27186that the message be deleted from the system without generating a bounce
27187message.
27188.nextp
27189\*add recipient*\: A dialog box is displayed into which a recipient address can
27190be typed. If the address is not qualified and the \\QUALIFY@_DOMAIN\\ parameter
27191is set in \(Local/eximon.conf)\, the address is qualified with that domain.
27192Otherwise it must be entered as a fully qualified address. Pressing \\RETURN\\
27193causes a call to Exim to be made using the \-Mar-\ option to request that an
27194additional recipient be added to the message, unless the entry box is empty, in
27195which case no action is taken.
27196.nextp
27197\*mark delivered*\: A dialog box is displayed into which a recipient address can
27198be typed. If the address is not qualified and the \\QUALIFY@_DOMAIN\\ parameter
27199is set in \(Local/eximon.conf)\, the address is qualified with that domain.
27200Otherwise it must be entered as a fully qualified address. Pressing \\RETURN\\
27201causes a call to Exim to be made using the \-Mmd-\ option to mark the given
27202recipient address as already delivered, unless the entry box is empty, in which
27203case no action is taken.
27204.nextp
27205\*mark all delivered*\: A call to Exim is made using the \-Mmad-\ option to mark
27206all recipient addresses as already delivered.
27207.nextp
27208\*edit sender*\: A dialog box is displayed initialized with the current sender's
27209address. Pressing \\RETURN\\ causes a call to Exim to be made using the \-Mes-\
27210option to replace the sender address, unless the entry box is empty, in which
27211case no action is taken. If you want to set an empty sender (as in bounce
27212messages), you must specify it as `<>'. Otherwise, if the address is not
27213qualified and the \\QUALIFY@_DOMAIN\\ parameter is set in
27214\(Local/eximon.conf)\, the address is qualified with that domain.
27215.endp
27216When a delivery is forced, a window showing the \-v-\ output is displayed. In
27217other cases when a call to Exim is made, if there is any output from Exim (in
27218particular, if the command fails) a window containing the command and the
27219output is displayed. Otherwise, the results of the action are normally apparent
27220from the log and queue displays. However, if you set \\ACTION@_OUTPUT\\=yes in
27221\(Local/eximon.conf)\, a window showing the Exim command is always opened, even
27222if no output is generated.
27223
27224The queue display is automatically updated for actions such as freezing and
27225thawing, unless \\ACTION@_QUEUE@_UPDATE\\=no has been set in
27226\(Local/eximon.conf)\. In this case the `Update' button has to be used to force
27227an update of the display after one of these actions.
27228
27229In any text window that is displayed as result of a menu action, the normal
27230cut-and-paste facility is available, and searching can be carried out using ^R
27231and ^S, as described above for the log tail window.
27232
27233
27234
27235
27236
27237
27238.
27239.
27240.
27241.
27242. ============================================================================
27243.chapter Security considerations
27244.set runningfoot "security"
27245.rset CHAPsecurity ~~chapter
27246.index security
27247This chapter discusses a number of issues concerned with security, some of
27248which are also covered in other parts of this manual.
27249
27250For reasons that this author does not understand, some people have promoted
27251Exim as a `particularly secure' mailer. Perhaps it is because of the existence
27252of this chapter in the documentation. However, the intent of the chapter is
27253simply to describe the way Exim works in relation to certain security concerns,
27254not to make any specific claims about the effectiveness of its security as
27255compared with other MTAs.
27256
27257What follows is a description of the way Exim is supposed to be. Best efforts
27258have been made to try to ensure that the code agrees with the theory, but an
27259absence of bugs can never be guaranteed. Any that are reported will get fixed
27260as soon as possible.
27261
27262.section Building a more `hardened' Exim
27263.index security||build-time features
27264There are a number of build-time options that can be set in \(Local/Makefile)\
27265to create Exim binaries that are `harder' to attack, in particular by a rogue
27266Exim administrator who does not have the root password, or by someone who has
27267penetrated the Exim (but not the root) account. These options are as follows:
27268.numberpars $.
27269\\ALT@_CONFIG@_PREFIX\\ can be set to a string that is required to match the
27270start of any file names used with the \-C-\ option. When it is set, these file
27271names are also not allowed to contain the sequence `/../'. (However, if the
27272value of the \-C-\ option is identical to the value of \\CONFIGURE@_FILE\\ in
27273\(Local/Makefile)\, Exim ignores \-C-\ and proceeds as usual.) There is no
27274default setting for \ALT@_CONFIG@_PREFIX\.
27275
27276If the permitted configuration files are confined to a directory to
27277which only root has access, this guards against someone who has broken
27278into the Exim account from running a privileged Exim with an arbitrary
27279configuration file, and using it to break into other accounts.
27280.nextp
27281If \\ALT@_CONFIG@_ROOT@_ONLY\\ is defined, root privilege is retained for \-C-\
27282and \-D-\ only if the caller of Exim is root. Without it, the Exim user may
27283also use \-C-\ and \-D-\ and retain privilege. Setting this option locks out
27284the possibility of testing a configuration using \-C-\ right through message
27285reception and delivery, even if the caller is root. The reception works, but by
27286that time, Exim is running as the Exim user, so when it re-execs to regain
27287privilege for the delivery, the use of \-C-\ causes privilege to be lost.
27288However, root can test reception and delivery using two separate commands.
27289\\ALT@_CONFIG@_ROOT@_ONLY\\ is not set by default.
27290.nextp
27291If \\DISABLE@_D@_OPTION\\ is defined, the use of the \-D-\ command line option
27292is disabled.
27293.nextp
27294\\FIXED@_NEVER@_USERS\\ can be set to a colon-separated list of users that are
27295never to be used for any deliveries. This is like the \never@_users\ runtime
27296option, but it cannot be overridden; the runtime option adds additional users
27297to the list. The default setting is `root'; this prevents a non-root user who
27298is permitted to modify the runtime file from using Exim as a way to get root.
27299.endp
27300
27301
27302.section Root privilege
27303.index setuid
27304.index root privilege
27305The Exim binary is normally setuid to root, which means that it gains root
27306privilege (runs as root) when it starts execution. In some special cases (for
27307example, when the daemon is not in use and there are no local deliveries), it
27308may be possible to run Exim setuid to some user other than root. This is
27309discussed in the next section. However, in most installations, root privilege
27310is required for two things:
27311.numberpars $.
27312To set up a socket connected to the standard SMTP port (25) when initialising
27313the listening daemon. If Exim is run from \*inetd*\, this privileged action is
27314not required.
27315.nextp
27316To be able to change uid and gid in order to read users' \(.forward)\ files and
27317perform local deliveries as the receiving user or as specified in the
27318configuration.
27319.endp
27320It is not necessary to be root to do any of the other things Exim does, such as
27321receiving messages and delivering them externally over SMTP, and it is
27322obviously more secure if Exim does not run as root except when necessary.
27323For this reason, a user and group for Exim to use must be defined in
27324\(Local/Makefile)\. These are known as `the Exim user' and `the Exim group'.
27325Their values can be changed by the run time configuration, though this is not
27326recommended. Often a user called \*exim*\ is used, but some sites use \*mail*\
27327or another user name altogether.
27328
27329Exim uses \*setuid()*\ whenever it gives up root privilege. This is a permanent
27330abdication; the process cannot regain root afterwards. Prior to release 4.00,
27331\*seteuid()*\ was used in some circumstances, but this is no longer the case.
27332
27333After a new Exim process has interpreted its command line options, it changes
27334uid and gid in the following cases:
27335.numberpars $.
27336.index \-C-\ option
27337.index \-D-\ option
27338If the \-C-\ option is used to specify an alternate configuration file, or if
27339the \-D-\ option is used to define macro values for the configuration, and the
27340calling process is not running as root or the Exim user, the uid and gid are
27341changed to those of the calling process.
27342However, if \\ALT@_CONFIG@_ROOT@_ONLY\\ is defined in \(Local/Makefile)\, only
27343root callers may use \-C-\ and \-D-\ without losing privilege, and if
27344\\DISABLE@_D@_OPTION\\ is set, the \-D-\ option may not be used at all.
27345.nextp
27346.index \-be-\ option
27347.index \-bf-\ option
27348.index \-bF-\ option
27349If the expansion test option (\-be-\) or one of the filter testing options
27350(\-bf-\ or \-bF-\) are used, the uid and gid are changed to those of the
27351calling process.
27352.nextp
27353If the process is not a daemon process or a queue runner process or a delivery
27354process or a process for testing address routing (started with \-bt-\), the uid
27355and gid are changed to the Exim user and group. This means that Exim always
27356runs under its own uid and gid when receiving messages. This also applies when
27357testing address verification
27358.index \-bv-\ option
27359.index \-bh-\ option
27360(the \-bv-\ option) and testing incoming message policy controls (the \-bh-\
27361option).
27362.nextp
27363For a daemon, queue runner, delivery, or address testing process, the uid
27364remains as root at this stage, but the gid is changed to the Exim group.
27365.endp
27366The processes that initially retain root privilege behave as follows:
27367.numberpars $.
27368A daemon process changes the gid to the Exim group and the uid to the Exim user
27369after setting up one or more listening sockets. The \*initgroups()*\ function
27370is called, so that if the Exim user is in any additional groups, they will be
27371used during message reception.
27372.nextp
27373A queue runner process retains root privilege throughout its execution. Its job
27374is to fork a controlled sequence of delivery processes.
27375.nextp
27376A delivery process retains root privilege throughout most of its execution,
27377but any actual deliveries (that is, the transports themselves) are run in
27378subprocesses which always change to a non-root uid and gid. For local
27379deliveries this is typically the uid and gid of the owner of the mailbox; for
27380remote deliveries, the Exim uid and gid are used. Once all the delivery
27381subprocesses have been run, a delivery process changes to the Exim uid and gid
27382while doing post-delivery tidying up such as updating the retry database and
27383generating bounce and warning messages.
27384
27385While the recipient addresses in a message are being routed, the delivery
27386process runs as root. However, if a user's filter file has to be processed,
27387this is done in a subprocess that runs under the individual user's uid and
27388gid. A system filter is run as root unless \system@_filter@_user\ is set.
27389.nextp
27390A process that is testing addresses (the \-bt-\ option) runs as root so that
27391the routing is done in the same environment as a message delivery.
27392.endp
27393
27394
27395.section Running Exim without privilege
27396.index privilege, running without
27397.index unprivileged running
27398.index root privilege||running without
27399Some installations like to run Exim in an unprivileged state for more of its
27400operation, for added security. Support for this mode of operation is provided
27401by the global option \deliver@_drop@_privilege\. When this is set, the uid and
27402gid are changed to the Exim user and group at the start of a delivery process
27403(and also queue runner and address testing processes). This means that address
27404routing is no longer run as root, and the deliveries themselves cannot change
27405to any other uid.
27406
27407Leaving the binary setuid to root, but setting \deliver@_drop@_privilege\ means
27408that the daemon can still be started in the usual way, and it can respond
27409correctly to SIGHUP because the re-invocation regains root privilege.
27410
27411An alternative approach is to make Exim setuid to the Exim user and also setgid
27412to the Exim group.
27413If you do this, the daemon must be started from a root process. (Calling
27414Exim from a root process makes it behave in the way it does when it is setuid
27415root.) However, the daemon cannot restart itself after a SIGHUP signal because
27416it cannot regain privilege.
27417
27418It is still useful to set \deliver@_drop@_privilege\ in this case, because it
27419stops Exim from trying to re-invoke itself to do a delivery after a message has
27420been received. Such a re-invocation is a waste of resources because it has no
27421effect.
27422
27423If restarting the daemon is not an issue (for example, if \*inetd*\ is being
27424used instead of a daemon), having the binary setuid to the Exim user seems a
27425clean approach, but there is one complication:
27426
27427In this style of operation, Exim is running with the real uid and gid set to
27428those of the calling process, and the effective uid/gid set to Exim's values.
27429Ideally, any association with the calling process' uid/gid should be dropped,
27430that is, the real uid/gid should be reset to the effective values so as to
27431discard any privileges that the caller may have. While some operating systems
27432have a function that permits this action for a non-root effective uid, quite a
27433number of them do not. Because of this lack of standardization, Exim does not
27434address this problem at this time.
27435
27436For this reason, the recommended approach for `mostly unprivileged' running is
27437to keep the Exim binary setuid to root, and to set \deliver@_drop@_privilege\.
27438This also has the advantage of allowing a daemon to be used in the most
27439straightforward way.
27440
27441If you configure Exim not to run delivery processes as root, there are a
27442number of restrictions on what you can do:
27443.numberpars $.
27444You can deliver only as the Exim user/group. You should explicitly use the
27445\user\ and \group\ options to override routers or local transports that
27446normally deliver as the recipient. This makes sure that configurations that
27447work in this mode function the same way in normal mode. Any implicit or
27448explicit specification of another user causes an error.
27449.nextp
27450Use of \(.forward)\ files is severely restricted, such that it is usually
27451not worthwhile to include them in the configuration.
27452.nextp
27453Users who wish to use \(.forward)\ would have to make their home directory and
27454the file itself accessible to the Exim user. Pipe and append-to-file entries,
27455and their equivalents in Exim filters, cannot be used. While they could be
27456enabled in the Exim user's name, that would be insecure and not very useful.
27457.nextp
27458Unless the local user mailboxes are all owned by the Exim user (possible in
27459some POP3 or IMAP-only environments):
27460.numberpars $*$
27461They must be owned by the Exim group and be writable by that group. This
27462implies you must set \mode\ in the appendfile configuration, as well as the
27463mode of the mailbox files themselves.
27464.nextp
27465You must set \no@_check@_owner\, since most or all of the files will not be
27466owned by the Exim user.
27467.nextp
27468You must set \file@_must@_exist\, because Exim cannot set the owner correctly
27469on a newly created mailbox when unprivileged. This also implies that new
27470mailboxes need to be created manually.
27471.endp
27472.endp
27473These restrictions severely restrict what can be done in local deliveries.
27474However, there are no restrictions on remote deliveries. If you are running a
27475gateway host that does no local deliveries, setting \deliver@_drop@_privilege\
27476gives more security at essentially no cost.
27477
27478
27479.section Delivering to local files
27480Full details of the checks applied by \%appendfile%\ before it writes to a file
27481are given in chapter ~~CHAPappendfile.
27482
27483
27484.section IPv4 source routing
27485.index source routing||in IP packets
27486.index IP source routing
27487Many operating systems suppress IP source-routed packets in the kernel, but
27488some cannot be made to do this, so Exim does its own check. It logs incoming
27489IPv4 source-routed TCP calls, and then drops them. Things are all different in
27490IPv6. No special checking is currently done.
27491
27492
27493.section The VRFY, EXPN, and ETRN commands in SMTP
27494Support for these SMTP commands is disabled by default. If required, they can
27495be enabled by defining suitable ACLs.
27496
27497
27498
27499.section Privileged users
27500.index trusted user
27501.index admin user
27502.index privileged user
27503.index user||trusted
27504.index user||admin
27505Exim recognises two sets of users with special privileges. Trusted users are
27506able to submit new messages to Exim locally, but supply their own sender
27507addresses and information about a sending host. For other users submitting
27508local messages, Exim sets up the sender address from the uid, and doesn't
27509permit a remote host to be specified.
27510
27511.index \-f-\ option
27512However, an untrusted user is permitted to use the \-f-\ command line option in
27513the special form \-f @<@>-\ to indicate that a delivery failure for the message
27514should not cause an error report. This affects the message's envelope, but it
27515does not affect the ::Sender:: header. Untrusted users may also be permitted to
27516use specific forms of address with the \-f-\ option by setting the
27517\untrusted@_set@_sender\ option.
27518
27519Trusted users are used to run processes that receive mail messages from some
27520other mail domain and pass them on to Exim for delivery either locally, or over
27521the Internet. Exim trusts a caller that is running as root, as the Exim user,
27522as any user listed in the \trusted@_users\ configuration option, or under any
27523group listed in the \trusted@_groups\ option.
27524
27525Admin users are permitted to do things to the messages on Exim's queue. They
27526can freeze or thaw messages, cause them to be returned to their senders, remove
27527them entirely, or modify them in various ways. In addition, admin users can run
27528the Exim monitor and see all the information it is capable of providing, which
27529includes the contents of files on the spool.
27530
27531.index \-M-\ option
27532.index \-q-\ option
27533By default, the use of the \-M-\ and \-q-\ options to cause Exim to attempt
27534delivery of messages on its queue is restricted to admin users. This
27535restriction can be relaxed by setting the \no@_prod@_requires@_admin\ option.
27536Similarly, the use of \-bp-\ (and its variants) to list the contents of the
27537queue is also restricted to admin users. This restriction can be relaxed by
27538setting \no@_queue@_list@_requires@_admin\.
27539
27540Exim recognises an admin user if the calling process is running as root or as
27541the Exim user or if any of the groups associated with the calling process is
27542the Exim group. It is not necessary actually to be running under the Exim
27543group. However, if admin users who are not root or the Exim user are to access
27544the contents of files on the spool via the Exim monitor (which runs
27545unprivileged), Exim must be built to allow group read access to its spool
27546files.
27547
27548
27549.section Spool files
27550.index spool directory||files
27551Exim's spool directory and everything it contains is owned by the Exim user and
27552set to the Exim group. The mode for spool files is defined in the
27553\(Local/Makefile)\ configuration file, and defaults to 0640. This means that
27554any user who is a member of the Exim group can access these files.
27555
27556
27557.section Use of argv[0]
27558Exim examines the last component of \argv[0]\, and if it matches one of a set
27559of specific strings, Exim assumes certain options. For example, calling Exim
27560with the last component of \argv[0]\ set to `rsmtp' is exactly equivalent to
27561calling it with the option \-bS-\. There are no security implications in this.
27562
27563
27564.section Use of %f formatting
27565The only use made of `%f' by Exim is in formatting load average values. These
27566are actually stored in integer variables as 1000 times the load average.
27567Consequently, their range is limited and so therefore is the length of the
27568converted output.
27569
27570
27571.section Embedded Exim path
27572Exim uses its own path name, which is embedded in the code, only when it needs
27573to re-exec in order to regain root privilege. Therefore, it is not root when it
27574does so. If some bug allowed the path to get overwritten, it would lead to an
27575arbitrary program's being run as exim, not as root.
27576
27577
27578.section Use of sprintf()
27579.index \*sprintf()*\
27580A large number of occurrences of `sprintf' in the code are actually calls to
27581\*string@_sprintf()*\, a function that returns the result in malloc'd store.
27582The intermediate formatting is done into a large fixed buffer by a function
27583that runs through the format string itself, and checks the length of each
27584conversion before performing it, thus preventing buffer overruns.
27585
27586The remaining uses of \*sprintf()*\ happen in controlled circumstances where
27587the output buffer is known to be sufficiently long to contain the converted
27588string.
27589
27590
27591.section Use of debug@_printf() and log@_write()
27592Arbitrary strings are passed to both these functions, but they do their
27593formatting by calling the function \*string@_vformat()*\, which runs through
27594the format string itself, and checks the length of each conversion.
27595
27596
27597.section Use of strcat() and strcpy()
27598These are used only in cases where the output buffer is known to be large
27599enough to hold the result.
27600
27601
27602
27603
27604.
27605.
27606.
27607.
27608. ============================================================================
27609.chapter Format of spool files
27610.set runningfoot "spool file format"
27611.rset CHAPspool ~~chapter
27612.index format||spool files
27613.index spool directory||format of files
27614.index spool||files, format of
27615.index spool||files, editing
27616A message on Exim's queue consists of two files, whose names are the message id
27617followed by -D and -H, respectively. The data portion of the message is kept in
27618the -D file on its own. The message's envelope, status, and headers are all
27619kept in the -H file, whose format is described in this chapter. Each of these
27620two files contains the final component of its own name as its first line. This
27621is insurance against disk crashes where the directory is lost but the files
27622themselves are recoverable.
27623
27624.em
27625Some people are tempted into editing -D files in order to modify messages. You
27626need to be extremely careful if you do this; it is not recommended and you are
27627on your own if you do it. Here are some of the pitfalls:
27628.numberpars $.
27629You must use the \*exim@_lock*\ utility to ensure that Exim does not try to
27630deliver the message while you are fiddling with it. The lock is implemented
27631by opening the -D file and taking out a write lock on it. If you update the
27632file in place, the lock will be retained. If you write a new file and rename
27633it, the lock will be lost at the instant of rename.
27634.nextp
27635If you change the number of lines in the file, the value of
27636\$body@_linecount$\, which is stored in the -H file, will be incorrect.
27637.nextp
27638If the message is in MIME format, you must take care not to break it.
27639.nextp
27640If the message is cryptographically signed, any change will invalidate the
27641signature.
27642.endp
27643.nem
27644
27645Files whose names end with -J may also be seen in the \(input)\ directory (or
27646its subdirectories when \split@_spool@_directory\ is set). These are journal
27647files, used to record addresses to which the message has been delivered during
27648the course of a delivery run. At the end of the run, the -H file is updated,
27649and the -J file is deleted.
27650
27651.section Format of the -H file
27652.index uid (user id)||in spool file
27653.index gid (group id)||in spool file
27654The second line of the -H file contains the login name for the uid of the
27655process that called Exim to read the message, followed by the numerical uid and
27656gid. For a locally generated message, this is normally the user who sent the
27657message. For a message received over TCP/IP, it is normally the Exim user.
27658
27659The third line of the file contains the address of the message's sender as
27660transmitted in the envelope, contained in angle brackets. The sender address is
27661empty for bounce messages. For incoming SMTP mail, the sender address is given
27662in the \\MAIL\\ command. For locally generated mail, the sender address is
27663created by Exim from the login name of the current user and the configured
27664\qualify@_domain\. However, this can be overridden by the \-f-\ option or a
27665leading `From' line if the caller is trusted, or if the supplied address is
27666`@<@>' or an address that matches \untrusted@_set@_senders\.
27667
27668The fourth line contains two numbers. The first is the time that the message
27669was received, in the conventional Unix form -- the number of seconds since the
27670start of the epoch. The second number is a count of the number of messages
27671warning of delayed delivery that have been sent to the sender.
27672
27673There follow a number of lines starting with a hyphen. These can appear in any
27674order, and are omitted when not relevant:
27675.numberpars $.
27676.em
27677\-acl <<number>> <<length>>-\: A line of this form is present for every ACL
27678variable that is not empty. The number identifies the variable; the
27679\acl@_c\*x*\$$\ variables are numbered 0--9 and the \acl@_m\*x*\$$\ variables
27680are numbered 10--19. The length is the length of the data string for the
27681variable. The string itself starts at the beginning of the next line, and is
27682followed by a newline character. It may contain internal newlines.
27683.nextp
27684\-allow@_unqualified@_recipient-\: This is present if unqualified recipient
27685addresses are permitted in header lines (to stop such addresses from being
27686qualified if rewriting occurs at transport time). Local messages that were
27687input using \-bnq-\ and remote messages from hosts that match
27688\recipient@_unqualified@_hosts\ set this flag.
27689.nextp
27690\-allow@_unqualified@_sender-\: This is present if unqualified sender
27691addresses are permitted in header lines (to stop such addresses from being
27692qualified if rewriting occurs at transport time). Local messages that were
27693input using \-bnq-\ and remote messages from hosts that match
27694\sender@_unqualified@_hosts\ set this flag.
27695.nem
27696.nextp
27697\-auth@_id <<text>>-\: The id information for a message received on an
27698authenticated SMTP connection -- the value of the \$authenticated@_id$\
27699variable.
27700.nextp
27701\-auth@_sender <<address>>-\: The address of an authenticated sender -- the
27702value of the \$authenticated@_sender$\ variable.
27703.nextp
27704\-body@_linecount <<number>>-\: This records the number of lines in the body of
27705the message, and is always present.
27706.nextp
27707\-deliver@_firsttime-\: This is written when a new message is first added to
27708the spool. When the spool file is updated after a deferral, it is omitted.
27709.nextp
27710.index frozen messages||spool data
27711\-frozen <<time>>-\: The message is frozen, and the freezing happened at
27712<<time>>.
27713.nextp
27714\-helo@_name <<text>>-\: This records the host name as specified by a remote
27715host in a \\HELO\\ or \\EHLO\\ command.
27716.nextp
27717\-host@_address <<address>>.<<port>>-\: This records the IP address of the host
27718from which the message was received and the remote port number that was used.
27719It is omitted for locally generated messages.
27720.nextp
27721\-host@_auth <<text>>-\: If the message was received on an authenticated SMTP
27722connection, this records the name of the authenticator -- the value of the
27723\$sender@_host@_authenticated$\ variable.
27724.nextp
27725\-host@_lookup@_failed-\: This is present if an attempt to look up the sending
27726host's name from its IP address failed. It corresponds to the
27727\$host@_lookup@_failed$\ variable.
27728.nextp
27729.index DNS||reverse lookup
27730.index reverse DNS lookup
27731\-host@_name <<text>>-\: This records the name of the remote host from which
27732the message was received, if the host name was looked up from the IP address
27733when the message was being received. It is not present if no reverse lookup was
27734done.
27735.nextp
27736\-ident <<text>>-\: For locally submitted messages, this records the login of
27737the originating user, unless it was a trusted user and the \-oMt-\ option was
27738used to specify an ident value. For messages received over TCP/IP, this records
27739the ident string supplied by the remote host, if any.
27740.nextp
27741\-interface@_address <<address>>.<<port>>-\: This records the IP address of the
27742local interface and the port number through which a message was received from a
27743remote host. It is omitted for locally generated messages.
27744.nextp
27745\-local-\: The message is from a local sender.
27746.nextp
27747\-localerror-\: The message is a locally-generated bounce message.
27748.nextp
27749\-local@_scan <<string>>-\: This records the data string that was
27750returned by the \*local@_scan()*\ function when the message was received -- the
27751value of the \$local@_scan@_data$\ variable. It is omitted if no data was
27752returned.
27753.nextp
27754\-manual@_thaw-\: The message was frozen but has been thawed manually, that is,
27755by an explicit Exim command rather than via the auto-thaw process.
27756.nextp
27757\-N-\: A testing delivery process was started using the \-N-\ option to
27758suppress any actual deliveries, but delivery was deferred. At any further
27759delivery attempts, \-N-\ is assumed.
27760.nextp
27761\-received@_protocol-\: This records the value of the \$received@_protocol$\
27762variable, which contains the name of the protocol by which the message was
27763received.
27764.nextp
27765\-sender@_set@_untrusted-\: The envelope sender of this message was set by an
27766untrusted local caller (used to ensure that the caller is displayed in queue
27767listings).
27768.nextp
27769\-tls@_certificate@_verified-\: A TLS certificate was received from the client
27770that sent this message, and the certificate was verified by the server.
27771.nextp
27772\-tls@_cipher <<cipher name>>-\: When the message was received over an
27773encrypted connection, this records the name of the cipher suite that was used.
27774.nextp
27775\-tls@_peerdn <<peer DN>>-\: When the message was received over an encrypted
27776connection, and a certificate was received from the client, this records the
27777Distinguished Name from that certificate.
27778.endp
27779
27780Following the options there is a list of those addresses to which the message
27781is not to be delivered. This set of addresses is initialized from the command
27782line when the \-t-\ option is used and \extract__addresses__remove__arguments\
27783is set; otherwise it starts out empty. Whenever a successful delivery is made,
27784the address is added to this set. The addresses are kept internally as a
27785balanced binary tree, and it is a representation of that tree which is written
27786to the spool file. If an address is expanded via an alias or forward file, the
27787original address is added to the tree when deliveries to all its child
27788addresses are complete.
27789
27790If the tree is empty, there is a single line in the spool file containing just
27791the text `XX'. Otherwise, each line consists of two letters, which are either Y
27792or N, followed by an address. The address is the value for the node of the
27793tree, and the letters indicate whether the node has a left branch and/or a
27794right branch attached to it, respectively. If branches exist, they immediately
27795follow. Here is an example of a three-node tree:
27796.display asis
27797YY darcy@austen.fict.example
27798NN alice@wonderland.fict.example
27799NN editor@thesaurus.ref.example
27800.endd
27801After the non-recipients tree, there is a list of the message's recipients.
27802This is a simple list, preceded by a count. It includes all the original
27803recipients of the message, including those to whom the message has already been
27804delivered. In the simplest case, the list contains one address per line. For
27805example:
27806.display asis
278074
27808editor@thesaurus.ref.example
27809darcy@austen.fict.example
27810rdo@foundation
27811alice@wonderland.fict.example
27812.endd
27813However, when a child address has been added to the top-level addresses as a
27814result of the use of the \one@_time\ option on a \%redirect%\ router, each line
27815is of the following form:
27816.display
27817<<top-level address>> <<errors@_to address>> <<length>>,<<parent number>>@#<<flag bits>>
27818.endd
27819The 01 flag bit indicates the presence of the three other fields that follow
27820the top-level address. Other bits may be used in future to support additional
27821fields. The <<parent number>> is the offset in the recipients list of the
27822original parent of the `one time' address. The first two fields are the
27823envelope sender that is associated with this address and its length. If the
27824length is zero, there is no special envelope sender (there are then two space
27825characters in the line). A non-empty field can arise from a \%redirect%\ router
27826that has an \errors@_to\ setting.
27827
27828
27829A blank line separates the envelope and status information from the headers
27830which follow. A header may occupy several lines of the file, and to save effort
27831when reading it in, each header is preceded by a number and an identifying
27832character. The number is the number of characters in the header, including any
27833embedded newlines and the terminating newline. The character is one of the
27834following:
27835.display
27836.tabs 9
27837<<blank>> $t $rm{header in which Exim has no special interest}
27838#B $t $rm{::Bcc:: header}
27839#C $t $rm{::Cc:: header}
27840#F $t $rm{::From:: header}
27841#I $t $rm{::Message-id:: header}
27842#P $t $rm{::Received:: header -- P for `postmark'}
27843#R $t $rm{::Reply-To:: header}
27844#S $t $rm{::Sender:: header}
27845#T $t $rm{::To:: header}
27846#* $t $rm{replaced or deleted header}
27847.endd
27848Deleted or replaced (rewritten) headers remain in the spool file for debugging
27849purposes. They are not transmitted when the message is delivered. Here is a
27850typical set of headers:
27851.display asis
27852111P Received: by hobbit.fict.example with local (Exim 4.00)
27853 id 14y9EI-00026G-00; Fri, 11 May 2001 10:28:59 +0100
27854049 Message-Id: <E14y9EI-00026G-00@hobbit.fict.example>
27855038* X-rewrote-sender: bb@hobbit.fict.example
27856042* From: Bilbo Baggins <bb@hobbit.fict.example>
27857049F From: Bilbo Baggins <B.Baggins@hobbit.fict.example>
27858099* To: alice@wonderland.fict.example, rdo@foundation,
27859 darcy@austen.fict.example, editor@thesaurus.ref.example
27860109T To: alice@wonderland.fict.example, rdo@foundation.fict.example,
27861 darcy@austen.fict.example, editor@thesaurus.ref.example
27862038 Date: Fri, 11 May 2001 10:28:59 +0100
27863.endd
27864The asterisked headers indicate that the envelope sender, ::From:: header, and
27865::To:: header have been rewritten, the last one because routing expanded the
27866unqualified domain \*foundation*\.
27867
27868.
27869.
27870.
27871.
27872. ============================================================================
27873.chapter Adding new drivers or lookup types
27874.set runningfoot "adding drivers"
27875.index adding drivers
27876.index new drivers, adding
27877.index drivers||adding new
27878The following actions have to be taken in order to add a new router, transport,
27879authenticator, or lookup type to Exim:
27880.numberpars
27881Choose a name for the driver or lookup type that does not conflict with any
27882existing name; I will use `newdriver' in what follows.
27883.nextp
27884Add to \(src/EDITME)\ the line
27885.display
27886<<type>>@_NEWDRIVER=yes
27887.endd
27888where <<type>> is \\ROUTER\\, \\TRANSPORT\\, \\AUTH\\, or \\LOOKUP\\. If the
27889code is not to be included in the binary by default, comment this line out. You
27890should also add any relevant comments about the driver or lookup type.
27891.nextp
27892Add to \(src/config.h.defaults)\ the line
27893.display
27894@#define <<type>>@_NEWDRIVER
27895.endd
27896.nextp
27897Edit \(src/drtables.c)\, adding conditional code to pull in the private header
27898and create a table entry as is done for all the other drivers and lookup types.
27899.nextp
27900Edit \(Makefile)\ in the appropriate sub-directory (\(src/routers)\,
27901\(src/transports)\, \(src/auths)\, or \(src/lookups)\); add a line for the new
27902driver or lookup type and add it to the definition of OBJ.
27903.nextp
27904Create \(newdriver.h)\ and \(newdriver.c)\ in the appropriate sub-directory of
27905\(src)\.
27906.nextp
27907Edit \(scripts/MakeLinks)\ and add commands to link the \(.h)\ and \(.c)\ files
27908as for other drivers and lookups.
27909.endp
27910Then all you need to do is write the code! A good way to start is to make a
27911proforma by copying an existing module of the same type, globally changing all
27912occurrences of the name, and cutting out most of the code. Note that any
27913options you create must be listed in alphabetical order, because the tables are
27914searched using a binary chop procedure.
27915
27916There is a \(README)\ file in each of the sub-directories of \(src)\ describing
27917the interface that is expected.
27918
27919.
27920.
27921.
27922.
27923. ============================================================================
27924. Fudge for the index page number. We want it to be on a right-hand page.
27925.
27926.set indexpage ~~sys.pagenumber + 1
27927.if even ~~indexpage
27928.set indexpage ~~indexpage + 1
27929.fi
27930.if ~~sgcal
27931.%index Index$e~~indexpage--
27932.fi
27933.
27934.
27935. End of Exim specification