Import Upstream version 4.84.2
[hcoop/debian/exim4.git] / doc / spec.txt
CommitLineData
420a0d19
CE
1Specification of the Exim Mail Transfer Agent
2
3Exim Maintainers
4
5Copyright (c) 2014 University of Cambridge
6
188b6fee
CE
7Revision 4.84.2 02 Mar 2016 EM
8
420a0d19
CE
9-------------------------------------------------------------------------------
10
11TABLE OF CONTENTS
12
131. Introduction
14
15 1.1. Exim documentation
16 1.2. FTP and web sites
17 1.3. Mailing lists
18 1.4. Exim training
19 1.5. Bug reports
20 1.6. Where to find the Exim distribution
21 1.7. Limitations
22 1.8. Run time configuration
23 1.9. Calling interface
24 1.10. Terminology
25
262. Incorporated code
273. How Exim receives and delivers mail
28
29 3.1. Overall philosophy
30 3.2. Policy control
31 3.3. User filters
32 3.4. Message identification
33 3.5. Receiving mail
34 3.6. Handling an incoming message
35 3.7. Life of a message
36 3.8. Processing an address for delivery
37 3.9. Processing an address for verification
38 3.10. Running an individual router
39 3.11. Duplicate addresses
40 3.12. Router preconditions
41 3.13. Delivery in detail
42 3.14. Retry mechanism
43 3.15. Temporary delivery failure
44 3.16. Permanent delivery failure
45 3.17. Failures to deliver bounce messages
46
474. Building and installing Exim
48
49 4.1. Unpacking
50 4.2. Multiple machine architectures and operating systems
51 4.3. PCRE library
52 4.4. DBM libraries
53 4.5. Pre-building configuration
54 4.6. Support for iconv()
55 4.7. Including TLS/SSL encryption support
56 4.8. Use of tcpwrappers
57 4.9. Including support for IPv6
58 4.10. Dynamically loaded lookup module support
59 4.11. The building process
60 4.12. Output from "make"
61 4.13. Overriding build-time options for Exim
62 4.14. OS-specific header files
63 4.15. Overriding build-time options for the monitor
64 4.16. Installing Exim binaries and scripts
65 4.17. Installing info documentation
66 4.18. Setting up the spool directory
67 4.19. Testing
68 4.20. Replacing another MTA with Exim
69 4.21. Upgrading Exim
70 4.22. Stopping the Exim daemon on Solaris
71
725. The Exim command line
73
74 5.1. Setting options by program name
75 5.2. Trusted and admin users
76 5.3. Command line options
77
786. The Exim run time configuration file
79
80 6.1. Using a different configuration file
81 6.2. Configuration file format
82 6.3. File inclusions in the configuration file
83 6.4. Macros in the configuration file
84 6.5. Macro substitution
85 6.6. Redefining macros
86 6.7. Overriding macro values
87 6.8. Example of macro usage
88 6.9. Conditional skips in the configuration file
89 6.10. Common option syntax
90 6.11. Boolean options
91 6.12. Integer values
92 6.13. Octal integer values
93 6.14. Fixed point numbers
94 6.15. Time intervals
95 6.16. String values
96 6.17. Expanded strings
97 6.18. User and group names
98 6.19. List construction
99 6.20. Changing list separators
100 6.21. Empty items in lists
101 6.22. Format of driver configurations
102
1037. The default configuration file
104
105 7.1. Main configuration settings
106 7.2. ACL configuration
107 7.3. Router configuration
108 7.4. Transport configuration
109 7.5. Default retry rule
110 7.6. Rewriting configuration
111 7.7. Authenticators configuration
112
1138. Regular expressions
1149. File and database lookups
115
116 9.1. Examples of different lookup syntax
117 9.2. Lookup types
118 9.3. Single-key lookup types
119 9.4. Query-style lookup types
120 9.5. Temporary errors in lookups
121 9.6. Default values in single-key lookups
122 9.7. Partial matching in single-key lookups
123 9.8. Lookup caching
124 9.9. Quoting lookup data
125 9.10. More about dnsdb
126 9.11. Pseudo dnsdb record types
127 9.12. Multiple dnsdb lookups
128 9.13. More about LDAP
129 9.14. Format of LDAP queries
130 9.15. LDAP quoting
131 9.16. LDAP connections
132 9.17. LDAP authentication and control information
133 9.18. Format of data returned by LDAP
134 9.19. More about NIS+
135 9.20. SQL lookups
136 9.21. More about MySQL, PostgreSQL, Oracle, and InterBase
137 9.22. Specifying the server in the query
138 9.23. Special MySQL features
139 9.24. Special PostgreSQL features
140 9.25. More about SQLite
141
14210. Domain, host, address, and local part lists
143
144 10.1. Expansion of lists
145 10.2. Negated items in lists
146 10.3. File names in lists
147 10.4. An lsearch file is not an out-of-line list
148 10.5. Named lists
149 10.6. Named lists compared with macros
150 10.7. Named list caching
151 10.8. Domain lists
152 10.9. Host lists
153 10.10. Special host list patterns
154 10.11. Host list patterns that match by IP address
155 10.12. Host list patterns for single-key lookups by host address
156 10.13. Host list patterns that match by host name
157 10.14. Behaviour when an IP address or name cannot be found
158 10.15. Mixing wildcarded host names and addresses in host lists
159 10.16. Temporary DNS errors when looking up host information
160 10.17. Host list patterns for single-key lookups by host name
161 10.18. Host list patterns for query-style lookups
162 10.19. Address lists
163 10.20. Case of letters in address lists
164 10.21. Local part lists
165
16611. String expansions
167
168 11.1. Literal text in expanded strings
169 11.2. Character escape sequences in expanded strings
170 11.3. Testing string expansions
171 11.4. Forced expansion failure
172 11.5. Expansion items
173 11.6. Expansion operators
174 11.7. Expansion conditions
175 11.8. Combining expansion conditions
176 11.9. Expansion variables
177
17812. Embedded Perl
179
180 12.1. Setting up so Perl can be used
181 12.2. Calling Perl subroutines
182 12.3. Calling Exim functions from Perl
183 12.4. Use of standard output and error by Perl
184
18513. Starting the daemon and the use of network interfaces
186
187 13.1. Starting a listening daemon
188 13.2. Special IP listening addresses
189 13.3. Overriding local_interfaces and daemon_smtp_ports
190 13.4. Support for the obsolete SSMTP (or SMTPS) protocol
191 13.5. IPv6 address scopes
192 13.6. Disabling IPv6
193 13.7. Examples of starting a listening daemon
194 13.8. Recognizing the local host
195 13.9. Delivering to a remote host
196
19714. Main configuration
198
199 14.1. Miscellaneous
200 14.2. Exim parameters
201 14.3. Privilege controls
202 14.4. Logging
203 14.5. Frozen messages
204 14.6. Data lookups
205 14.7. Message ids
206 14.8. Embedded Perl Startup
207 14.9. Daemon
208 14.10. Resource control
209 14.11. Policy controls
210 14.12. Callout cache
211 14.13. TLS
212 14.14. Local user handling
213 14.15. All incoming messages (SMTP and non-SMTP)
214 14.16. Non-SMTP incoming messages
215 14.17. Incoming SMTP messages
216 14.18. SMTP extensions
217 14.19. Processing messages
218 14.20. System filter
219 14.21. Routing and delivery
220 14.22. Bounce and warning messages
221 14.23. Alphabetical list of main options
222
22315. Generic options for routers
22416. The accept router
22517. The dnslookup router
226
227 17.1. Problems with DNS lookups
228 17.2. Declining addresses by dnslookup
229 17.3. Private options for dnslookup
230 17.4. Effect of qualify_single and search_parents
231
23218. The ipliteral router
23319. The iplookup router
23420. The manualroute router
235
236 20.1. Private options for manualroute
237 20.2. Routing rules in route_list
238 20.3. Routing rules in route_data
239 20.4. Format of the list of hosts
240 20.5. Format of one host item
241 20.6. How the list of hosts is used
242 20.7. How the options are used
243 20.8. Manualroute examples
244
24521. The queryprogram router
24622. The redirect router
247
248 22.1. Redirection data
249 22.2. Forward files and address verification
250 22.3. Interpreting redirection data
251 22.4. Items in a non-filter redirection list
252 22.5. Redirecting to a local mailbox
253 22.6. Special items in redirection lists
254 22.7. Duplicate addresses
255 22.8. Repeated redirection expansion
256 22.9. Errors in redirection lists
257 22.10. Private options for the redirect router
258
25923. Environment for running local transports
260
261 23.1. Concurrent deliveries
262 23.2. Uids and gids
263 23.3. Current and home directories
264 23.4. Expansion variables derived from the address
265
26624. Generic options for transports
26725. Address batching in local transports
26826. The appendfile transport
269
270 26.1. The file and directory options
271 26.2. Private options for appendfile
272 26.3. Operational details for appending
273 26.4. Operational details for delivery to a new file
274 26.5. Maildir delivery
275 26.6. Using tags to record message sizes
276 26.7. Using a maildirsize file
277 26.8. Mailstore delivery
278 26.9. Non-special new file delivery
279
28027. The autoreply transport
281
282 27.1. Private options for autoreply
283
28428. The lmtp transport
28529. The pipe transport
286
287 29.1. Concurrent delivery
288 29.2. Returned status and data
289 29.3. How the command is run
290 29.4. Environment variables
291 29.5. Private options for pipe
292 29.6. Using an external local delivery agent
293
29430. The smtp transport
295
296 30.1. Multiple messages on a single connection
297 30.2. Use of the $host and $host_address variables
298 30.3. Use of $tls_cipher and $tls_peerdn
299 30.4. Private options for smtp
300 30.5. How the limits for the number of hosts to try are used
301
30231. Address rewriting
303
304 31.1. Explicitly configured address rewriting
305 31.2. When does rewriting happen?
306 31.3. Testing the rewriting rules that apply on input
307 31.4. Rewriting rules
308 31.5. Rewriting patterns
309 31.6. Rewriting replacements
310 31.7. Rewriting flags
311 31.8. Flags specifying which headers and envelope addresses to rewrite
312 31.9. The SMTP-time rewriting flag
313 31.10. Flags controlling the rewriting process
314 31.11. Rewriting examples
315
31632. Retry configuration
317
318 32.1. Changing retry rules
319 32.2. Format of retry rules
320 32.3. Choosing which retry rule to use for address errors
321 32.4. Choosing which retry rule to use for host and message errors
322 32.5. Retry rules for specific errors
323 32.6. Retry rules for specified senders
324 32.7. Retry parameters
325 32.8. Retry rule examples
326 32.9. Timeout of retry data
327 32.10. Long-term failures
328 32.11. Deliveries that work intermittently
329
33033. SMTP authentication
331
332 33.1. Generic options for authenticators
333 33.2. The AUTH parameter on MAIL commands
334 33.3. Authentication on an Exim server
335 33.4. Testing server authentication
336 33.5. Authentication by an Exim client
337
33834. The plaintext authenticator
339
340 34.1. Plaintext options
341 34.2. Using plaintext in a server
342 34.3. The PLAIN authentication mechanism
343 34.4. The LOGIN authentication mechanism
344 34.5. Support for different kinds of authentication
345 34.6. Using plaintext in a client
346
34735. The cram_md5 authenticator
348
349 35.1. Using cram_md5 as a server
350 35.2. Using cram_md5 as a client
351
35236. The cyrus_sasl authenticator
353
354 36.1. Using cyrus_sasl as a server
355
35637. The dovecot authenticator
35738. The gsasl authenticator
358
359 38.1. gsasl auth variables
360
36139. The heimdal_gssapi authenticator
362
363 39.1. heimdal_gssapi auth variables
364
36540. The spa authenticator
366
367 40.1. Using spa as a server
368 40.2. Using spa as a client
369
37041. Encrypted SMTP connections using TLS/SSL
371
372 41.1. Support for the legacy "ssmtp" (aka "smtps") protocol
373 41.2. OpenSSL vs GnuTLS
374 41.3. GnuTLS parameter computation
375 41.4. Requiring specific ciphers in OpenSSL
376 41.5. Requiring specific ciphers or other parameters in GnuTLS
377 41.6. Configuring an Exim server to use TLS
378 41.7. Requesting and verifying client certificates
379 41.8. Revoked certificates
380 41.9. Configuring an Exim client to use TLS
381 41.10. Use of TLS Server Name Indication
382 41.11. Multiple messages on the same encrypted TCP/IP connection
383 41.12. Certificates and all that
384 41.13. Certificate chains
385 41.14. Self-signed certificates
386
38742. Access control lists
388
389 42.1. Testing ACLs
390 42.2. Specifying when ACLs are used
391 42.3. The non-SMTP ACLs
392 42.4. The SMTP connect ACL
393 42.5. The EHLO/HELO ACL
394 42.6. The DATA ACLs
395 42.7. The SMTP DKIM ACL
396 42.8. The SMTP MIME ACL
397 42.9. The SMTP PRDR ACL
398 42.10. The QUIT ACL
399 42.11. The not-QUIT ACL
400 42.12. Finding an ACL to use
401 42.13. ACL return codes
402 42.14. Unset ACL options
403 42.15. Data for message ACLs
404 42.16. Data for non-message ACLs
405 42.17. Format of an ACL
406 42.18. ACL verbs
407 42.19. ACL variables
408 42.20. Condition and modifier processing
409 42.21. ACL modifiers
410 42.22. Use of the control modifier
411 42.23. Summary of message fixup control
412 42.24. Adding header lines in ACLs
413 42.25. Removing header lines in ACLs
414 42.26. ACL conditions
415 42.27. Using DNS lists
416 42.28. Specifying the IP address for a DNS list lookup
417 42.29. DNS lists keyed on domain names
418 42.30. Multiple explicit keys for a DNS list
419 42.31. Data returned by DNS lists
420 42.32. Variables set from DNS lists
421 42.33. Additional matching conditions for DNS lists
422 42.34. Negated DNS matching conditions
423 42.35. Handling multiple DNS records from a DNS list
424 42.36. Detailed information from merged DNS lists
425 42.37. DNS lists and IPv6
426 42.38. Rate limiting incoming messages
427 42.39. Ratelimit options for what is being measured
428 42.40. Ratelimit update modes
429 42.41. Ratelimit options for handling fast clients
430 42.42. Limiting the rate of different events
431 42.43. Using rate limiting
432 42.44. Address verification
433 42.45. Callout verification
434 42.46. Additional parameters for callouts
435 42.47. Callout caching
436 42.48. Sender address verification reporting
437 42.49. Redirection while verifying
438 42.50. Client SMTP authorization (CSA)
439 42.51. Bounce address tag validation
440 42.52. Using an ACL to control relaying
441 42.53. Checking a relay configuration
442
44343. Content scanning at ACL time
444
445 43.1. Scanning for viruses
446 43.2. Scanning with SpamAssassin
447 43.3. Calling SpamAssassin from an Exim ACL
448 43.4. Scanning MIME parts
449 43.5. Scanning with regular expressions
450 43.6. The demime condition
451
45244. Adding a local scan function to Exim
453
454 44.1. Building Exim to use a local scan function
455 44.2. API for local_scan()
456 44.3. Configuration options for local_scan()
457 44.4. Available Exim variables
458 44.5. Structure of header lines
459 44.6. Structure of recipient items
460 44.7. Available Exim functions
461 44.8. More about Exim's memory handling
462
46345. System-wide message filtering
464
465 45.1. Specifying a system filter
466 45.2. Testing a system filter
467 45.3. Contents of a system filter
468 45.4. Additional variable for system filters
469 45.5. Defer, freeze, and fail commands for system filters
470 45.6. Adding and removing headers in a system filter
471 45.7. Setting an errors address in a system filter
472 45.8. Per-address filtering
473
47446. Message processing
475
476 46.1. Submission mode for non-local messages
477 46.2. Line endings
478 46.3. Unqualified addresses
479 46.4. The UUCP From line
480 46.5. Resent- header lines
481 46.6. The Auto-Submitted: header line
482 46.7. The Bcc: header line
483 46.8. The Date: header line
484 46.9. The Delivery-date: header line
485 46.10. The Envelope-to: header line
486 46.11. The From: header line
487 46.12. The Message-ID: header line
488 46.13. The Received: header line
489 46.14. The References: header line
490 46.15. The Return-path: header line
491 46.16. The Sender: header line
492 46.17. Adding and removing header lines in routers and transports
493 46.18. Constructed addresses
494 46.19. Case of local parts
495 46.20. Dots in local parts
496 46.21. Rewriting addresses
497
49847. SMTP processing
499
500 47.1. Outgoing SMTP and LMTP over TCP/IP
501 47.2. Errors in outgoing SMTP
502 47.3. Incoming SMTP messages over TCP/IP
503 47.4. Unrecognized SMTP commands
504 47.5. Syntax and protocol errors in SMTP commands
505 47.6. Use of non-mail SMTP commands
506 47.7. The VRFY and EXPN commands
507 47.8. The ETRN command
508 47.9. Incoming local SMTP
509 47.10. Outgoing batched SMTP
510 47.11. Incoming batched SMTP
511
51248. Customizing bounce and warning messages
513
514 48.1. Customizing bounce messages
515 48.2. Customizing warning messages
516
51749. Some common configuration settings
518
519 49.1. Sending mail to a smart host
520 49.2. Using Exim to handle mailing lists
521 49.3. Syntax errors in mailing lists
522 49.4. Re-expansion of mailing lists
523 49.5. Closed mailing lists
524 49.6. Variable Envelope Return Paths (VERP)
525 49.7. Virtual domains
526 49.8. Multiple user mailboxes
527 49.9. Simplified vacation processing
528 49.10. Taking copies of mail
529 49.11. Intermittently connected hosts
530 49.12. Exim on the upstream server host
531 49.13. Exim on the intermittently connected client host
532
53350. Using Exim as a non-queueing client
53451. Log files
535
536 51.1. Where the logs are written
537 51.2. Logging to local files that are periodically "cycled"
538 51.3. Datestamped log files
539 51.4. Logging to syslog
540 51.5. Log line flags
541 51.6. Logging message reception
542 51.7. Logging deliveries
543 51.8. Discarded deliveries
544 51.9. Deferred deliveries
545 51.10. Delivery failures
546 51.11. Fake deliveries
547 51.12. Completion
548 51.13. Summary of Fields in Log Lines
549 51.14. Other log entries
550 51.15. Reducing or increasing what is logged
551 51.16. Message log
552
55352. Exim utilities
554
555 52.1. Finding out what Exim processes are doing (exiwhat)
556 52.2. Selective queue listing (exiqgrep)
557 52.3. Summarizing the queue (exiqsumm)
558 52.4. Extracting specific information from the log (exigrep)
559 52.5. Selecting messages by various criteria (exipick)
560 52.6. Cycling log files (exicyclog)
561 52.7. Mail statistics (eximstats)
562 52.8. Checking access policy (exim_checkaccess)
563 52.9. Making DBM files (exim_dbmbuild)
564 52.10. Finding individual retry times (exinext)
565 52.11. Hints database maintenance
566 52.12. exim_dumpdb
567 52.13. exim_tidydb
568 52.14. exim_fixdb
569 52.15. Mailbox maintenance (exim_lock)
570
57153. The Exim monitor
572
573 53.1. Running the monitor
574 53.2. The stripcharts
575 53.3. Main action buttons
576 53.4. The log display
577 53.5. The queue display
578 53.6. The queue menu
579
58054. Security considerations
581
582 54.1. Building a more "hardened" Exim
583 54.2. Root privilege
584 54.3. Running Exim without privilege
585 54.4. Delivering to local files
586 54.5. Running local commands
587 54.6. Trust in configuration data
588 54.7. IPv4 source routing
589 54.8. The VRFY, EXPN, and ETRN commands in SMTP
590 54.9. Privileged users
591 54.10. Spool files
592 54.11. Use of argv[0]
593 54.12. Use of %f formatting
594 54.13. Embedded Exim path
595 54.14. Dynamic module directory
596 54.15. Use of sprintf()
597 54.16. Use of debug_printf() and log_write()
598 54.17. Use of strcat() and strcpy()
599
60055. Format of spool files
601
602 55.1. Format of the -H file
603
60456. Support for DKIM (DomainKeys Identified Mail)
605
606 56.1. Signing outgoing messages
607 56.2. Verifying DKIM signatures in incoming mail
608
60957. Adding new drivers or lookup types
610
611
612
613===============================================================================
6141. INTRODUCTION
615
616Exim is a mail transfer agent (MTA) for hosts that are running Unix or
617Unix-like operating systems. It was designed on the assumption that it would be
618run on hosts that are permanently connected to the Internet. However, it can be
619used on intermittently connected hosts with suitable configuration adjustments.
620
621Configuration files currently exist for the following operating systems: AIX,
622BSD/OS (aka BSDI), Darwin (Mac OS X), DGUX, Dragonfly, FreeBSD, GNU/Hurd, GNU/
623Linux, HI-OSF (Hitachi), HI-UX, HP-UX, IRIX, MIPS RISCOS, NetBSD, OpenBSD,
624OpenUNIX, QNX, SCO, SCO SVR4.2 (aka UNIX-SV), Solaris (aka SunOS5), SunOS4,
625Tru64-Unix (formerly Digital UNIX, formerly DEC-OSF1), Ultrix, and Unixware.
626Some of these operating systems are no longer current and cannot easily be
627tested, so the configuration files may no longer work in practice.
628
629There are also configuration files for compiling Exim in the Cygwin environment
630that can be installed on systems running Windows. However, this document does
631not contain any information about running Exim in the Cygwin environment.
632
633The terms and conditions for the use and distribution of Exim are contained in
634the file NOTICE. Exim is distributed under the terms of the GNU General Public
635Licence, a copy of which may be found in the file LICENCE.
636
637The use, supply or promotion of Exim for the purpose of sending bulk,
638unsolicited electronic mail is incompatible with the basic aims of the program,
639which revolve around the free provision of a service that enhances the quality
640of personal communications. The author of Exim regards indiscriminate
641mass-mailing as an antisocial, irresponsible abuse of the Internet.
642
643Exim owes a great deal to Smail 3 and its author, Ron Karr. Without the
644experience of running and working on the Smail 3 code, I could never have
645contemplated starting to write a new MTA. Many of the ideas and user interfaces
646were originally taken from Smail 3, though the actual code of Exim is entirely
647new, and has developed far beyond the initial concept.
648
649Many people, both in Cambridge and around the world, have contributed to the
650development and the testing of Exim, and to porting it to various operating
651systems. I am grateful to them all. The distribution now contains a file called
652ACKNOWLEDGMENTS, in which I have started recording the names of contributors.
653
654
6551.1 Exim documentation
656----------------------
657
188b6fee 658This edition of the Exim specification applies to version 4.84.2 of Exim.
420a0d19
CE
659Substantive changes from the 4.83 edition are marked in some renditions of the
660document; this paragraph is so marked if the rendition is capable of showing a
661change indicator.
662
663This document is very much a reference manual; it is not a tutorial. The reader
664is expected to have some familiarity with the SMTP mail transfer protocol and
665with general Unix system administration. Although there are some discussions
666and examples in places, the information is mostly organized in a way that makes
667it easy to look up, rather than in a natural order for sequential reading.
668Furthermore, the manual aims to cover every aspect of Exim in detail, including
669a number of rarely-used, special-purpose features that are unlikely to be of
670very wide interest.
671
672An "easier" discussion of Exim which provides more in-depth explanatory,
673introductory, and tutorial material can be found in a book entitled The Exim
674SMTP Mail Server (second edition, 2007), published by UIT Cambridge (http://
675www.uit.co.uk/exim-book/).
676
677This book also contains a chapter that gives a general introduction to SMTP and
678Internet mail. Inevitably, however, the book is unlikely to be fully up-to-date
679with the latest release of Exim. (Note that the earlier book about Exim,
680published by O'Reilly, covers Exim 3, and many things have changed in Exim 4.)
681
682If you are using a Debian distribution of Exim, you will find information about
683Debian-specific features in the file /usr/share/doc/exim4-base/README.Debian.
684The command man update-exim.conf is another source of Debian-specific
685information.
686
687As the program develops, there may be features in newer versions that have not
688yet made it into this document, which is updated only when the most significant
689digit of the fractional part of the version number changes. Specifications of
690new features that are not yet in this manual are placed in the file doc/
691NewStuff in the Exim distribution.
692
693Some features may be classified as "experimental". These may change
694incompatibly while they are developing, or even be withdrawn. For this reason,
695they are not documented in this manual. Information about experimental features
696can be found in the file doc/experimental.txt.
697
698All changes to the program (whether new features, bug fixes, or other kinds of
699change) are noted briefly in the file called doc/ChangeLog.
700
701This specification itself is available as an ASCII file in doc/spec.txt so that
702it can easily be searched with a text editor. Other files in the doc directory
703are:
704
705OptionLists.txt list of all options in alphabetical order
706dbm.discuss.txt discussion about DBM libraries
707exim.8 a man page of Exim's command line options
708experimental.txt documentation of experimental features
709filter.txt specification of the filter language
710Exim3.upgrade upgrade notes from release 2 to release 3
711Exim4.upgrade upgrade notes from release 3 to release 4
712
713The main specification and the specification of the filtering language are also
714available in other formats (HTML, PostScript, PDF, and Texinfo). Section 1.6
715below tells you how to get hold of these.
716
717
7181.2 FTP and web sites
719---------------------
720
721The primary site for Exim source distributions is currently the University of
722Cambridge's FTP site, whose contents are described in Where to find the Exim
723distribution below. In addition, there is a web site and an FTP site at
724exim.org. These are now also hosted at the University of Cambridge. The
725exim.org site was previously hosted for a number of years by Energis Squared,
726formerly Planet Online Ltd, whose support I gratefully acknowledge.
727
728As well as Exim distribution tar files, the Exim web site contains a number of
729differently formatted versions of the documentation. A recent addition to the
730online information is the Exim wiki (http://wiki.exim.org), which contains what
731used to be a separate FAQ, as well as various other examples, tips, and
732know-how that have been contributed by Exim users.
733
734An Exim Bugzilla exists at http://bugs.exim.org. You can use this to report
735bugs, and also to add items to the wish list. Please search first to check that
736you are not duplicating a previous entry.
737
738
7391.3 Mailing lists
740-----------------
741
742The following Exim mailing lists exist:
743
744exim-announce@exim.org Moderated, low volume announcements list
745exim-users@exim.org General discussion list
746exim-dev@exim.org Discussion of bugs, enhancements, etc.
747exim-cvs@exim.org Automated commit messages from the VCS
748
749You can subscribe to these lists, change your existing subscriptions, and view
750or search the archives via the mailing lists link on the Exim home page. If you
751are using a Debian distribution of Exim, you may wish to subscribe to the
752Debian-specific mailing list pkg-exim4-users@lists.alioth.debian.org via this
753web page:
754
755http://lists.alioth.debian.org/mailman/listinfo/pkg-exim4-users
756
757Please ask Debian-specific questions on this list and not on the general Exim
758lists.
759
760
7611.4 Exim training
762-----------------
763
764Training courses in Cambridge (UK) used to be run annually by the author of
765Exim, before he retired. At the time of writing, there are no plans to run
766further Exim courses in Cambridge. However, if that changes, relevant
767information will be posted at http://www-tus.csx.cam.ac.uk/courses/exim/.
768
769
7701.5 Bug reports
771---------------
772
773Reports of obvious bugs can be emailed to bugs@exim.org or reported via the
774Bugzilla (http://bugs.exim.org). However, if you are unsure whether some
775behaviour is a bug or not, the best thing to do is to post a message to the
776exim-dev mailing list and have it discussed.
777
778
7791.6 Where to find the Exim distribution
780---------------------------------------
781
782The master ftp site for the Exim distribution is
783
784ftp://ftp.csx.cam.ac.uk/pub/software/email/exim
785
786This is mirrored by
787
788ftp://ftp.exim.org/pub/exim
789
790The file references that follow are relative to the exim directories at these
791sites. There are now quite a number of independent mirror sites around the
792world. Those that I know about are listed in the file called Mirrors.
793
794Within the exim directory there are subdirectories called exim3 (for previous
795Exim 3 distributions), exim4 (for the latest Exim 4 distributions), and Testing
796for testing versions. In the exim4 subdirectory, the current release can always
797be found in files called
798
799exim-n.nn.tar.gz
800exim-n.nn.tar.bz2
801
802where n.nn is the highest such version number in the directory. The two files
803contain identical data; the only difference is the type of compression. The
804.bz2 file is usually a lot smaller than the .gz file.
805
806The distributions will be PGP signed by an individual key of the Release
807Coordinator. This key will have a uid containing an email address in the
808exim.org domain and will have signatures from other people, including other
809Exim maintainers. We expect that the key will be in the "strong set" of PGP
810keys. There should be a trust path to that key from Nigel Metheringham's PGP
811key, a version of which can be found in the release directory in the file
812nigel-pubkey.asc. All keys used will be available in public keyserver pools,
813such as pool.sks-keyservers.net.
814
815At time of last update, releases were being made by Phil Pennock and signed
816with key 0x403043153903637F, although that key is expected to be replaced in
8172013. A trust path from Nigel's key to Phil's can be observed at https://
818www.security.spodhuis.org/exim-trustpath.
819
820Releases have also been authorized to be performed by Todd Lyons who signs with
821key 0xC4F4F94804D29EBA. A direct trust path exists between previous RE Phil
822Pennock and Todd Lyons through a common associate.
823
824The signatures for the tar bundles are in:
825
826exim-n.nn.tar.gz.asc
827exim-n.nn.tar.bz2.asc
828
829For each released version, the log of changes is made separately available in a
830separate file in the directory ChangeLogs so that it is possible to find out
831what has changed without having to download the entire distribution.
832
833The main distribution contains ASCII versions of this specification and other
834documentation; other formats of the documents are available in separate files
835inside the exim4 directory of the FTP site:
836
837exim-html-n.nn.tar.gz
838exim-pdf-n.nn.tar.gz
839exim-postscript-n.nn.tar.gz
840exim-texinfo-n.nn.tar.gz
841
842These tar files contain only the doc directory, not the complete distribution,
843and are also available in .bz2 as well as .gz forms.
844
845
8461.7 Limitations
847---------------
848
849 * Exim is designed for use as an Internet MTA, and therefore handles
850 addresses in RFC 2822 domain format only. It cannot handle UUCP "bang
851 paths", though simple two-component bang paths can be converted by a
852 straightforward rewriting configuration. This restriction does not prevent
853 Exim from being interfaced to UUCP as a transport mechanism, provided that
854 domain addresses are used.
855
856 * Exim insists that every address it handles has a domain attached. For
857 incoming local messages, domainless addresses are automatically qualified
858 with a configured domain value. Configuration options specify from which
859 remote systems unqualified addresses are acceptable. These are then
860 qualified on arrival.
861
862 * The only external transport mechanisms that are currently implemented are
863 SMTP and LMTP over a TCP/IP network (including support for IPv6). However,
864 a pipe transport is available, and there are facilities for writing
865 messages to files and pipes, optionally in batched SMTP format; these
866 facilities can be used to send messages to other transport mechanisms such
867 as UUCP, provided they can handle domain-style addresses. Batched SMTP
868 input is also catered for.
869
870 * Exim is not designed for storing mail for dial-in hosts. When the volumes
871 of such mail are large, it is better to get the messages "delivered" into
872 files (that is, off Exim's queue) and subsequently passed on to the dial-in
873 hosts by other means.
874
875 * Although Exim does have basic facilities for scanning incoming messages,
876 these are not comprehensive enough to do full virus or spam scanning. Such
877 operations are best carried out using additional specialized software
878 packages. If you compile Exim with the content-scanning extension,
879 straightforward interfaces to a number of common scanners are provided.
880
881
8821.8 Run time configuration
883--------------------------
884
885Exim's run time configuration is held in a single text file that is divided
886into a number of sections. The entries in this file consist of keywords and
887values, in the style of Smail 3 configuration files. A default configuration
888file which is suitable for simple online installations is provided in the
889distribution, and is described in chapter 7 below.
890
891
8921.9 Calling interface
893---------------------
894
895Like many MTAs, Exim has adopted the Sendmail command line interface so that it
896can be a straight replacement for /usr/lib/sendmail or /usr/sbin/sendmail when
897sending mail, but you do not need to know anything about Sendmail in order to
898run Exim. For actions other than sending messages, Sendmail-compatible options
899also exist, but those that produce output (for example, -bp, which lists the
900messages on the queue) do so in Exim's own format. There are also some
901additional options that are compatible with Smail 3, and some further options
902that are new to Exim. Chapter 5 documents all Exim's command line options. This
903information is automatically made into the man page that forms part of the Exim
904distribution.
905
906Control of messages on the queue can be done via certain privileged command
907line options. There is also an optional monitor program called eximon, which
908displays current information in an X window, and which contains a menu
909interface to Exim's command line administration options.
910
911
9121.10 Terminology
913----------------
914
915The body of a message is the actual data that the sender wants to transmit. It
916is the last part of a message, and is separated from the header (see below) by
917a blank line.
918
919When a message cannot be delivered, it is normally returned to the sender in a
920delivery failure message or a "non-delivery report" (NDR). The term bounce is
921commonly used for this action, and the error reports are often called bounce
922messages. This is a convenient shorthand for "delivery failure error report".
923Such messages have an empty sender address in the message's envelope (see
924below) to ensure that they cannot themselves give rise to further bounce
925messages.
926
927The term default appears frequently in this manual. It is used to qualify a
928value which is used in the absence of any setting in the configuration. It may
929also qualify an action which is taken unless a configuration setting specifies
930otherwise.
931
932The term defer is used when the delivery of a message to a specific destination
933cannot immediately take place for some reason (a remote host may be down, or a
934user's local mailbox may be full). Such deliveries are deferred until a later
935time.
936
937The word domain is sometimes used to mean all but the first component of a
938host's name. It is not used in that sense here, where it normally refers to the
939part of an email address following the @ sign.
940
941A message in transit has an associated envelope, as well as a header and a
942body. The envelope contains a sender address (to which bounce messages should
943be delivered), and any number of recipient addresses. References to the sender
944or the recipients of a message usually mean the addresses in the envelope. An
945MTA uses these addresses for delivery, and for returning bounce messages, not
946the addresses that appear in the header lines.
947
948The header of a message is the first part of a message's text, consisting of a
949number of lines, each of which has a name such as From:, To:, Subject:, etc.
950Long header lines can be split over several text lines by indenting the
951continuations. The header is separated from the body by a blank line.
952
953The term local part, which is taken from RFC 2822, is used to refer to that
954part of an email address that precedes the @ sign. The part that follows the @
955sign is called the domain or mail domain.
956
957The terms local delivery and remote delivery are used to distinguish delivery
958to a file or a pipe on the local host from delivery by SMTP over TCP/IP to
959another host. As far as Exim is concerned, all hosts other than the host it is
960running on are remote.
961
962Return path is another name that is used for the sender address in a message's
963envelope.
964
965The term queue is used to refer to the set of messages awaiting delivery,
966because this term is in widespread use in the context of MTAs. However, in
967Exim's case the reality is more like a pool than a queue, because there is
968normally no ordering of waiting messages.
969
970The term queue runner is used to describe a process that scans the queue and
971attempts to deliver those messages whose retry times have come. This term is
972used by other MTAs, and also relates to the command runq, but in Exim the
973waiting messages are normally processed in an unpredictable order.
974
975The term spool directory is used for a directory in which Exim keeps the
976messages on its queue - that is, those that it is in the process of delivering.
977This should not be confused with the directory in which local mailboxes are
978stored, which is called a "spool directory" by some people. In the Exim
979documentation, "spool" is always used in the first sense.
980
981
982
983===============================================================================
9842. INCORPORATED CODE
985
986A number of pieces of external code are included in the Exim distribution.
987
988 * Regular expressions are supported in the main Exim program and in the Exim
989 monitor using the freely-distributable PCRE library, copyright (c)
990 University of Cambridge. The source to PCRE is no longer shipped with Exim,
991 so you will need to use the version of PCRE shipped with your system, or
992 obtain and install the full version of the library from ftp://
993 ftp.csx.cam.ac.uk/pub/software/programming/pcre.
994
995 * Support for the cdb (Constant DataBase) lookup method is provided by code
996 contributed by Nigel Metheringham of (at the time he contributed it) Planet
997 Online Ltd. The implementation is completely contained within the code of
998 Exim. It does not link against an external cdb library. The code contains
999 the following statements:
1000
1001 Copyright (c) 1998 Nigel Metheringham, Planet Online Ltd
1002
1003 This program is free software; you can redistribute it and/or modify it
1004 under the terms of the GNU General Public License as published by the
1005 Free Software Foundation; either version 2 of the License, or (at your
1006 option) any later version. This code implements Dan Bernstein's
1007 Constant DataBase (cdb) spec. Information, the spec and sample code for
1008 cdb can be obtained from http://www.pobox.com/~djb/cdb.html. This
1009 implementation borrows some code from Dan Bernstein's implementation
1010 (which has no license restrictions applied to it).
1011
1012 * Client support for Microsoft's Secure Password Authentication is provided
1013 by code contributed by Marc Prud'hommeaux. Server support was contributed
1014 by Tom Kistner. This includes code taken from the Samba project, which is
1015 released under the Gnu GPL.
1016
1017 * Support for calling the Cyrus pwcheck and saslauthd daemons is provided by
1018 code taken from the Cyrus-SASL library and adapted by Alexander S.
1019 Sabourenkov. The permission notice appears below, in accordance with the
1020 conditions expressed therein.
1021
1022 Copyright (c) 2001 Carnegie Mellon University. All rights reserved.
1023
1024 Redistribution and use in source and binary forms, with or without
1025 modification, are permitted provided that the following conditions are
1026 met:
1027
1028 1. Redistributions of source code must retain the above copyright
1029 notice, this list of conditions and the following disclaimer.
1030
1031 2. Redistributions in binary form must reproduce the above copyright
1032 notice, this list of conditions and the following disclaimer in the
1033 documentation and/or other materials provided with the
1034 distribution.
1035
1036 3. The name "Carnegie Mellon University" must not be used to endorse
1037 or promote products derived from this software without prior
1038 written permission. For permission or any other legal details,
1039 please contact
1040
1041 Office of Technology Transfer
1042 Carnegie Mellon University
1043 5000 Forbes Avenue
1044 Pittsburgh, PA 15213-3890
1045 (412) 268-4387, fax: (412) 268-7395
1046 tech-transfer@andrew.cmu.edu
1047
1048 4. Redistributions of any form whatsoever must retain the following
1049 acknowledgment:
1050
1051 "This product includes software developed by Computing Services at
1052 Carnegie Mellon University (http://www.cmu.edu/computing/."
1053
1054 CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
1055 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1056 AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
1057 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1058 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
1059 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
1060 OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
1061 SOFTWARE.
1062
1063 * The Exim Monitor program, which is an X-Window application, includes
1064 modified versions of the Athena StripChart and TextPop widgets. This code
1065 is copyright by DEC and MIT, and their permission notice appears below, in
1066 accordance with the conditions expressed therein.
1067
1068 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard,
1069 Massachusetts, and the Massachusetts Institute of Technology,
1070 Cambridge, Massachusetts.
1071
1072 All Rights Reserved
1073
1074 Permission to use, copy, modify, and distribute this software and its
1075 documentation for any purpose and without fee is hereby granted,
1076 provided that the above copyright notice appear in all copies and that
1077 both that copyright notice and this permission notice appear in
1078 supporting documentation, and that the names of Digital or MIT not be
1079 used in advertising or publicity pertaining to distribution of the
1080 software without specific, written prior permission.
1081
1082 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1083 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
1084 EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1085 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
1086 USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1087 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1088 PERFORMANCE OF THIS SOFTWARE.
1089
1090 * The DMARC implementation uses the OpenDMARC library which is Copyrighted by
1091 The Trusted Domain Project. Portions of Exim source which use OpenDMARC
1092 derived code are indicated in the respective source files. The full
1093 OpenDMARC license is provided in the LICENSE.opendmarc file contained in
1094 the distributed source code.
1095
1096 * Many people have contributed code fragments, some large, some small, that
1097 were not covered by any specific licence requirements. It is assumed that
1098 the contributors are happy to see their code incorporated into Exim under
1099 the GPL.
1100
1101
1102
1103===============================================================================
11043. HOW EXIM RECEIVES AND DELIVERS MAIL
1105
1106
11073.1 Overall philosophy
1108----------------------
1109
1110Exim is designed to work efficiently on systems that are permanently connected
1111to the Internet and are handling a general mix of mail. In such circumstances,
1112most messages can be delivered immediately. Consequently, Exim does not
1113maintain independent queues of messages for specific domains or hosts, though
1114it does try to send several messages in a single SMTP connection after a host
1115has been down, and it also maintains per-host retry information.
1116
1117
11183.2 Policy control
1119------------------
1120
1121Policy controls are now an important feature of MTAs that are connected to the
1122Internet. Perhaps their most important job is to stop MTAs being abused as
1123"open relays" by misguided individuals who send out vast amounts of unsolicited
1124junk, and want to disguise its source. Exim provides flexible facilities for
1125specifying policy controls on incoming mail:
1126
1127 * Exim 4 (unlike previous versions of Exim) implements policy controls on
1128 incoming mail by means of Access Control Lists (ACLs). Each list is a
1129 series of statements that may either grant or deny access. ACLs can be used
1130 at several places in the SMTP dialogue while receiving a message from a
1131 remote host. However, the most common places are after each RCPT command,
1132 and at the very end of the message. The sysadmin can specify conditions for
1133 accepting or rejecting individual recipients or the entire message,
1134 respectively, at these two points (see chapter 42). Denial of access
1135 results in an SMTP error code.
1136
1137 * An ACL is also available for locally generated, non-SMTP messages. In this
1138 case, the only available actions are to accept or deny the entire message.
1139
1140 * When Exim is compiled with the content-scanning extension, facilities are
1141 provided in the ACL mechanism for passing the message to external virus and
1142 /or spam scanning software. The result of such a scan is passed back to the
1143 ACL, which can then use it to decide what to do with the message.
1144
1145 * When a message has been received, either from a remote host or from the
1146 local host, but before the final acknowledgment has been sent, a locally
1147 supplied C function called local_scan() can be run to inspect the message
1148 and decide whether to accept it or not (see chapter 44). If the message is
1149 accepted, the list of recipients can be modified by the function.
1150
1151 * Using the local_scan() mechanism is another way of calling external scanner
1152 software. The SA-Exim add-on package works this way. It does not require
1153 Exim to be compiled with the content-scanning extension.
1154
1155 * After a message has been accepted, a further checking mechanism is
1156 available in the form of the system filter (see chapter 45). This runs at
1157 the start of every delivery process.
1158
1159
11603.3 User filters
1161----------------
1162
1163In a conventional Exim configuration, users are able to run private filters by
1164setting up appropriate .forward files in their home directories. See chapter 22
1165(about the redirect router) for the configuration needed to support this, and
1166the separate document entitled Exim's interfaces to mail filtering for user
1167details. Two different kinds of filtering are available:
1168
1169 * Sieve filters are written in the standard filtering language that is
1170 defined by RFC 3028.
1171
1172 * Exim filters are written in a syntax that is unique to Exim, but which is
1173 more powerful than Sieve, which it pre-dates.
1174
1175User filters are run as part of the routing process, described below.
1176
1177
11783.4 Message identification
1179--------------------------
1180
1181Every message handled by Exim is given a message id which is sixteen characters
1182long. It is divided into three parts, separated by hyphens, for example
1183"16VDhn-0001bo-D3". Each part is a sequence of letters and digits, normally
1184encoding numbers in base 62. However, in the Darwin operating system (Mac OS X)
1185and when Exim is compiled to run under Cygwin, base 36 (avoiding the use of
1186lower case letters) is used instead, because the message id is used to
1187construct file names, and the names of files in those systems are not always
1188case-sensitive.
1189
1190The detail of the contents of the message id have changed as Exim has evolved.
1191Earlier versions relied on the operating system not re-using a process id (pid)
1192within one second. On modern operating systems, this assumption can no longer
1193be made, so the algorithm had to be changed. To retain backward compatibility,
1194the format of the message id was retained, which is why the following rules are
1195somewhat eccentric:
1196
1197 * The first six characters of the message id are the time at which the
1198 message started to be received, to a granularity of one second. That is,
1199 this field contains the number of seconds since the start of the epoch (the
1200 normal Unix way of representing the date and time of day).
1201
1202 * After the first hyphen, the next six characters are the id of the process
1203 that received the message.
1204
1205 * There are two different possibilities for the final two characters:
1206
1207 1. If localhost_number is not set, this value is the fractional part of
1208 the time of reception, normally in units of 1/2000 of a second, but for
1209 systems that must use base 36 instead of base 62 (because of
1210 case-insensitive file systems), the units are 1/1000 of a second.
1211
1212 2. If localhost_number is set, it is multiplied by 200 (100) and added to
1213 the fractional part of the time, which in this case is in units of 1/
1214 200 (1/100) of a second.
1215
1216After a message has been received, Exim waits for the clock to tick at the
1217appropriate resolution before proceeding, so that if another message is
1218received by the same process, or by another process with the same (re-used)
1219pid, it is guaranteed that the time will be different. In most cases, the clock
1220will already have ticked while the message was being received.
1221
1222
12233.5 Receiving mail
1224------------------
1225
1226The only way Exim can receive mail from another host is using SMTP over TCP/IP,
1227in which case the sender and recipient addresses are transferred using SMTP
1228commands. However, from a locally running process (such as a user's MUA), there
1229are several possibilities:
1230
1231 * If the process runs Exim with the -bm option, the message is read
1232 non-interactively (usually via a pipe), with the recipients taken from the
1233 command line, or from the body of the message if -t is also used.
1234
1235 * If the process runs Exim with the -bS option, the message is also read
1236 non-interactively, but in this case the recipients are listed at the start
1237 of the message in a series of SMTP RCPT commands, terminated by a DATA
1238 command. This is so-called "batch SMTP" format, but it isn't really SMTP.
1239 The SMTP commands are just another way of passing envelope addresses in a
1240 non-interactive submission.
1241
1242 * If the process runs Exim with the -bs option, the message is read
1243 interactively, using the SMTP protocol. A two-way pipe is normally used for
1244 passing data between the local process and the Exim process. This is "real"
1245 SMTP and is handled in the same way as SMTP over TCP/IP. For example, the
1246 ACLs for SMTP commands are used for this form of submission.
1247
1248 * A local process may also make a TCP/IP call to the host's loopback address
1249 (127.0.0.1) or any other of its IP addresses. When receiving messages, Exim
1250 does not treat the loopback address specially. It treats all such
1251 connections in the same way as connections from other hosts.
1252
1253In the three cases that do not involve TCP/IP, the sender address is
1254constructed from the login name of the user that called Exim and a default
1255qualification domain (which can be set by the qualify_domain configuration
1256option). For local or batch SMTP, a sender address that is passed using the
1257SMTP MAIL command is ignored. However, the system administrator may allow
1258certain users ("trusted users") to specify a different sender address
1259unconditionally, or all users to specify certain forms of different sender
1260address. The -f option or the SMTP MAIL command is used to specify these
1261different addresses. See section 5.2 for details of trusted users, and the
1262untrusted_set_sender option for a way of allowing untrusted users to change
1263sender addresses.
1264
1265Messages received by either of the non-interactive mechanisms are subject to
1266checking by the non-SMTP ACL, if one is defined. Messages received using SMTP
1267(either over TCP/IP, or interacting with a local process) can be checked by a
1268number of ACLs that operate at different times during the SMTP session. Either
1269individual recipients, or the entire message, can be rejected if local policy
1270requirements are not met. The local_scan() function (see chapter 44) is run for
1271all incoming messages.
1272
1273Exim can be configured not to start a delivery process when a message is
1274received; this can be unconditional, or depend on the number of incoming SMTP
1275connections or the system load. In these situations, new messages wait on the
1276queue until a queue runner process picks them up. However, in standard
1277configurations under normal conditions, delivery is started as soon as a
1278message is received.
1279
1280
12813.6 Handling an incoming message
1282--------------------------------
1283
1284When Exim accepts a message, it writes two files in its spool directory. The
1285first contains the envelope information, the current status of the message, and
1286the header lines, and the second contains the body of the message. The names of
1287the two spool files consist of the message id, followed by "-H" for the file
1288containing the envelope and header, and "-D" for the data file.
1289
1290By default all these message files are held in a single directory called input
1291inside the general Exim spool directory. Some operating systems do not perform
1292very well if the number of files in a directory gets large; to improve
1293performance in such cases, the split_spool_directory option can be used. This
1294causes Exim to split up the input files into 62 sub-directories whose names are
1295single letters or digits. When this is done, the queue is processed one
1296sub-directory at a time instead of all at once, which can improve overall
1297performance even when there are not enough files in each directory to affect
1298file system performance.
1299
1300The envelope information consists of the address of the message's sender and
1301the addresses of the recipients. This information is entirely separate from any
1302addresses contained in the header lines. The status of the message includes a
1303list of recipients who have already received the message. The format of the
1304first spool file is described in chapter 55.
1305
1306Address rewriting that is specified in the rewrite section of the configuration
1307(see chapter 31) is done once and for all on incoming addresses, both in the
1308header lines and the envelope, at the time the message is accepted. If during
1309the course of delivery additional addresses are generated (for example, via
1310aliasing), these new addresses are rewritten as soon as they are generated. At
1311the time a message is actually delivered (transported) further rewriting can
1312take place; because this is a transport option, it can be different for
1313different forms of delivery. It is also possible to specify the addition or
1314removal of certain header lines at the time the message is delivered (see
1315chapters 15 and 24).
1316
1317
13183.7 Life of a message
1319---------------------
1320
1321A message remains in the spool directory until it is completely delivered to
1322its recipients or to an error address, or until it is deleted by an
1323administrator or by the user who originally created it. In cases when delivery
1324cannot proceed - for example, when a message can neither be delivered to its
1325recipients nor returned to its sender, the message is marked "frozen" on the
1326spool, and no more deliveries are attempted.
1327
1328An administrator can "thaw" such messages when the problem has been corrected,
1329and can also freeze individual messages by hand if necessary. In addition, an
1330administrator can force a delivery error, causing a bounce message to be sent.
1331
1332There are options called ignore_bounce_errors_after and timeout_frozen_after,
1333which discard frozen messages after a certain time. The first applies only to
1334frozen bounces, the second to any frozen messages.
1335
1336While Exim is working on a message, it writes information about each delivery
1337attempt to its main log file. This includes successful, unsuccessful, and
1338delayed deliveries for each recipient (see chapter 51). The log lines are also
1339written to a separate message log file for each message. These logs are solely
1340for the benefit of the administrator, and are normally deleted along with the
1341spool files when processing of a message is complete. The use of individual
1342message logs can be disabled by setting no_message_logs; this might give an
1343improvement in performance on very busy systems.
1344
1345All the information Exim itself needs to set up a delivery is kept in the first
1346spool file, along with the header lines. When a successful delivery occurs, the
1347address is immediately written at the end of a journal file, whose name is the
1348message id followed by "-J". At the end of a delivery run, if there are some
1349addresses left to be tried again later, the first spool file (the "-H" file) is
1350updated to indicate which these are, and the journal file is then deleted.
1351Updating the spool file is done by writing a new file and renaming it, to
1352minimize the possibility of data loss.
1353
1354Should the system or the program crash after a successful delivery but before
1355the spool file has been updated, the journal is left lying around. The next
1356time Exim attempts to deliver the message, it reads the journal file and
1357updates the spool file before proceeding. This minimizes the chances of double
1358deliveries caused by crashes.
1359
1360
13613.8 Processing an address for delivery
1362--------------------------------------
1363
1364The main delivery processing elements of Exim are called routers and transports
1365, and collectively these are known as drivers. Code for a number of them is
1366provided in the source distribution, and compile-time options specify which
1367ones are included in the binary. Run time options specify which ones are
1368actually used for delivering messages.
1369
1370Each driver that is specified in the run time configuration is an instance of
1371that particular driver type. Multiple instances are allowed; for example, you
1372can set up several different smtp transports, each with different option values
1373that might specify different ports or different timeouts. Each instance has its
1374own identifying name. In what follows we will normally use the instance name
1375when discussing one particular instance (that is, one specific configuration of
1376the driver), and the generic driver name when discussing the driver's features
1377in general.
1378
1379A router is a driver that operates on an address, either determining how its
1380delivery should happen, by assigning it to a specific transport, or converting
1381the address into one or more new addresses (for example, via an alias file). A
1382router may also explicitly choose to fail an address, causing it to be bounced.
1383
1384A transport is a driver that transmits a copy of the message from Exim's spool
1385to some destination. There are two kinds of transport: for a local transport,
1386the destination is a file or a pipe on the local host, whereas for a remote
1387transport the destination is some other host. A message is passed to a specific
1388transport as a result of successful routing. If a message has several
1389recipients, it may be passed to a number of different transports.
1390
1391An address is processed by passing it to each configured router instance in
1392turn, subject to certain preconditions, until a router accepts the address or
1393specifies that it should be bounced. We will describe this process in more
1394detail shortly. First, as a simple example, we consider how each recipient
1395address in a message is processed in a small configuration of three routers.
1396
1397To make this a more concrete example, it is described in terms of some actual
1398routers, but remember, this is only an example. You can configure Exim's
1399routers in many different ways, and there may be any number of routers in a
1400configuration.
1401
1402The first router that is specified in a configuration is often one that handles
1403addresses in domains that are not recognized specially by the local host. These
1404are typically addresses for arbitrary domains on the Internet. A precondition
1405is set up which looks for the special domains known to the host (for example,
1406its own domain name), and the router is run for addresses that do not match.
1407Typically, this is a router that looks up domains in the DNS in order to find
1408the hosts to which this address routes. If it succeeds, the address is assigned
1409to a suitable SMTP transport; if it does not succeed, the router is configured
1410to fail the address.
1411
1412The second router is reached only when the domain is recognized as one that
1413"belongs" to the local host. This router does redirection - also known as
1414aliasing and forwarding. When it generates one or more new addresses from the
1415original, each of them is routed independently from the start. Otherwise, the
1416router may cause an address to fail, or it may simply decline to handle the
1417address, in which case the address is passed to the next router.
1418
1419The final router in many configurations is one that checks to see if the
1420address belongs to a local mailbox. The precondition may involve a check to see
1421if the local part is the name of a login account, or it may look up the local
1422part in a file or a database. If its preconditions are not met, or if the
1423router declines, we have reached the end of the routers. When this happens, the
1424address is bounced.
1425
1426
14273.9 Processing an address for verification
1428------------------------------------------
1429
1430As well as being used to decide how to deliver to an address, Exim's routers
1431are also used for address verification. Verification can be requested as one of
1432the checks to be performed in an ACL for incoming messages, on both sender and
1433recipient addresses, and it can be tested using the -bv and -bvs command line
1434options.
1435
1436When an address is being verified, the routers are run in "verify mode". This
1437does not affect the way the routers work, but it is a state that can be
1438detected. By this means, a router can be skipped or made to behave differently
1439when verifying. A common example is a configuration in which the first router
1440sends all messages to a message-scanning program, unless they have been
1441previously scanned. Thus, the first router accepts all addresses without any
1442checking, making it useless for verifying. Normally, the no_verify option would
1443be set for such a router, causing it to be skipped in verify mode.
1444
1445
14463.10 Running an individual router
1447---------------------------------
1448
1449As explained in the example above, a number of preconditions are checked before
1450running a router. If any are not met, the router is skipped, and the address is
1451passed to the next router. When all the preconditions on a router are met, the
1452router is run. What happens next depends on the outcome, which is one of the
1453following:
1454
1455 * accept: The router accepts the address, and either assigns it to a
1456 transport, or generates one or more "child" addresses. Processing the
1457 original address ceases, unless the unseen option is set on the router.
1458 This option can be used to set up multiple deliveries with different
1459 routing (for example, for keeping archive copies of messages). When unseen
1460 is set, the address is passed to the next router. Normally, however, an
1461 accept return marks the end of routing.
1462
1463 Any child addresses generated by the router are processed independently,
1464 starting with the first router by default. It is possible to change this by
1465 setting the redirect_router option to specify which router to start at for
1466 child addresses. Unlike pass_router (see below) the router specified by
1467 redirect_router may be anywhere in the router configuration.
1468
1469 * pass: The router recognizes the address, but cannot handle it itself. It
1470 requests that the address be passed to another router. By default the
1471 address is passed to the next router, but this can be changed by setting
1472 the pass_router option. However, (unlike redirect_router) the named router
1473 must be below the current router (to avoid loops).
1474
1475 * decline: The router declines to accept the address because it does not
1476 recognize it at all. By default, the address is passed to the next router,
1477 but this can be prevented by setting the no_more option. When no_more is
1478 set, all the remaining routers are skipped. In effect, no_more converts
1479 decline into fail.
1480
1481 * fail: The router determines that the address should fail, and queues it for
1482 the generation of a bounce message. There is no further processing of the
1483 original address unless unseen is set on the router.
1484
1485 * defer: The router cannot handle the address at the present time. (A
1486 database may be offline, or a DNS lookup may have timed out.) No further
1487 processing of the address happens in this delivery attempt. It is tried
1488 again next time the message is considered for delivery.
1489
1490 * error: There is some error in the router (for example, a syntax error in
1491 its configuration). The action is as for defer.
1492
1493If an address reaches the end of the routers without having been accepted by
1494any of them, it is bounced as unrouteable. The default error message in this
1495situation is "unrouteable address", but you can set your own message by making
1496use of the cannot_route_message option. This can be set for any router; the
1497value from the last router that "saw" the address is used.
1498
1499Sometimes while routing you want to fail a delivery when some conditions are
1500met but others are not, instead of passing the address on for further routing.
1501You can do this by having a second router that explicitly fails the delivery
1502when the relevant conditions are met. The redirect router has a "fail" facility
1503for this purpose.
1504
1505
15063.11 Duplicate addresses
1507------------------------
1508
1509Once routing is complete, Exim scans the addresses that are assigned to local
1510and remote transports, and discards any duplicates that it finds. During this
1511check, local parts are treated as case-sensitive. This happens only when
1512actually delivering a message; when testing routers with -bt, all the routed
1513addresses are shown.
1514
1515
15163.12 Router preconditions
1517-------------------------
1518
1519The preconditions that are tested for each router are listed below, in the
1520order in which they are tested. The individual configuration options are
1521described in more detail in chapter 15.
1522
1523 * The local_part_prefix and local_part_suffix options can specify that the
1524 local parts handled by the router may or must have certain prefixes and/or
1525 suffixes. If a mandatory affix (prefix or suffix) is not present, the
1526 router is skipped. These conditions are tested first. When an affix is
1527 present, it is removed from the local part before further processing,
1528 including the evaluation of any other conditions.
1529
1530 * Routers can be designated for use only when not verifying an address, that
1531 is, only when routing it for delivery (or testing its delivery routing). If
1532 the verify option is set false, the router is skipped when Exim is
1533 verifying an address. Setting the verify option actually sets two options,
1534 verify_sender and verify_recipient, which independently control the use of
1535 the router for sender and recipient verification. You can set these options
1536 directly if you want a router to be used for only one type of verification.
1537 Note that cutthrough delivery is classed as a recipient verification for
1538 this purpose.
1539
1540 * If the address_test option is set false, the router is skipped when Exim is
1541 run with the -bt option to test an address routing. This can be helpful
1542 when the first router sends all new messages to a scanner of some sort; it
1543 makes it possible to use -bt to test subsequent delivery routing without
1544 having to simulate the effect of the scanner.
1545
1546 * Routers can be designated for use only when verifying an address, as
1547 opposed to routing it for delivery. The verify_only option controls this.
1548 Again, cutthrough delivery counts as a verification.
1549
1550 * Individual routers can be explicitly skipped when running the routers to
1551 check an address given in the SMTP EXPN command (see the expn option).
1552
1553 * If the domains option is set, the domain of the address must be in the set
1554 of domains that it defines.
1555
1556 * If the local_parts option is set, the local part of the address must be in
1557 the set of local parts that it defines. If local_part_prefix or
1558 local_part_suffix is in use, the prefix or suffix is removed from the local
1559 part before this check. If you want to do precondition tests on local parts
1560 that include affixes, you can do so by using a condition option (see below)
1561 that uses the variables $local_part, $local_part_prefix, and
1562 $local_part_suffix as necessary.
1563
1564 * If the check_local_user option is set, the local part must be the name of
1565 an account on the local host. If this check succeeds, the uid and gid of
1566 the local user are placed in $local_user_uid and $local_user_gid and the
1567 user's home directory is placed in $home; these values can be used in the
1568 remaining preconditions.
1569
1570 * If the router_home_directory option is set, it is expanded at this point,
1571 because it overrides the value of $home. If this expansion were left till
1572 later, the value of $home as set by check_local_user would be used in
1573 subsequent tests. Having two different values of $home in the same router
1574 could lead to confusion.
1575
1576 * If the senders option is set, the envelope sender address must be in the
1577 set of addresses that it defines.
1578
1579 * If the require_files option is set, the existence or non-existence of
1580 specified files is tested.
1581
1582 * If the condition option is set, it is evaluated and tested. This option
1583 uses an expanded string to allow you to set up your own custom
1584 preconditions. Expanded strings are described in chapter 11.
1585
1586Note that require_files comes near the end of the list, so you cannot use it to
1587check for the existence of a file in which to lookup up a domain, local part,
1588or sender. However, as these options are all expanded, you can use the exists
1589expansion condition to make such tests within each condition. The require_files
1590option is intended for checking files that the router may be going to use
1591internally, or which are needed by a specific transport (for example,
1592.procmailrc).
1593
1594
15953.13 Delivery in detail
1596-----------------------
1597
1598When a message is to be delivered, the sequence of events is as follows:
1599
1600 * If a system-wide filter file is specified, the message is passed to it. The
1601 filter may add recipients to the message, replace the recipients, discard
1602 the message, cause a new message to be generated, or cause the message
1603 delivery to fail. The format of the system filter file is the same as for
1604 Exim user filter files, described in the separate document entitled Exim's
1605 interfaces to mail filtering. (Note: Sieve cannot be used for system filter
1606 files.)
1607
1608 Some additional features are available in system filters - see chapter 45
1609 for details. Note that a message is passed to the system filter only once
1610 per delivery attempt, however many recipients it has. However, if there are
1611 several delivery attempts because one or more addresses could not be
1612 immediately delivered, the system filter is run each time. The filter
1613 condition first_delivery can be used to detect the first run of the system
1614 filter.
1615
1616 * Each recipient address is offered to each configured router in turn,
1617 subject to its preconditions, until one is able to handle it. If no router
1618 can handle the address, that is, if they all decline, the address is
1619 failed. Because routers can be targeted at particular domains, several
1620 locally handled domains can be processed entirely independently of each
1621 other.
1622
1623 * A router that accepts an address may assign it to a local or a remote
1624 transport. However, the transport is not run at this time. Instead, the
1625 address is placed on a list for the particular transport, which will be run
1626 later. Alternatively, the router may generate one or more new addresses
1627 (typically from alias, forward, or filter files). New addresses are fed
1628 back into this process from the top, but in order to avoid loops, a router
1629 ignores any address which has an identically-named ancestor that was
1630 processed by itself.
1631
1632 * When all the routing has been done, addresses that have been successfully
1633 handled are passed to their assigned transports. When local transports are
1634 doing real local deliveries, they handle only one address at a time, but if
1635 a local transport is being used as a pseudo-remote transport (for example,
1636 to collect batched SMTP messages for transmission by some other means)
1637 multiple addresses can be handled. Remote transports can always handle more
1638 than one address at a time, but can be configured not to do so, or to
1639 restrict multiple addresses to the same domain.
1640
1641 * Each local delivery to a file or a pipe runs in a separate process under a
1642 non-privileged uid, and these deliveries are run one at a time. Remote
1643 deliveries also run in separate processes, normally under a uid that is
1644 private to Exim ("the Exim user"), but in this case, several remote
1645 deliveries can be run in parallel. The maximum number of simultaneous
1646 remote deliveries for any one message is set by the remote_max_parallel
1647 option. The order in which deliveries are done is not defined, except that
1648 all local deliveries happen before any remote deliveries.
1649
1650 * When it encounters a local delivery during a queue run, Exim checks its
1651 retry database to see if there has been a previous temporary delivery
1652 failure for the address before running the local transport. If there was a
1653 previous failure, Exim does not attempt a new delivery until the retry time
1654 for the address is reached. However, this happens only for delivery
1655 attempts that are part of a queue run. Local deliveries are always
1656 attempted when delivery immediately follows message reception, even if
1657 retry times are set for them. This makes for better behaviour if one
1658 particular message is causing problems (for example, causing quota
1659 overflow, or provoking an error in a filter file).
1660
1661 * Remote transports do their own retry handling, since an address may be
1662 deliverable to one of a number of hosts, each of which may have a different
1663 retry time. If there have been previous temporary failures and no host has
1664 reached its retry time, no delivery is attempted, whether in a queue run or
1665 not. See chapter 32 for details of retry strategies.
1666
1667 * If there were any permanent errors, a bounce message is returned to an
1668 appropriate address (the sender in the common case), with details of the
1669 error for each failing address. Exim can be configured to send copies of
1670 bounce messages to other addresses.
1671
1672 * If one or more addresses suffered a temporary failure, the message is left
1673 on the queue, to be tried again later. Delivery of these addresses is said
1674 to be deferred.
1675
1676 * When all the recipient addresses have either been delivered or bounced,
1677 handling of the message is complete. The spool files and message log are
1678 deleted, though the message log can optionally be preserved if required.
1679
1680
16813.14 Retry mechanism
1682--------------------
1683
1684Exim's mechanism for retrying messages that fail to get delivered at the first
1685attempt is the queue runner process. You must either run an Exim daemon that
1686uses the -q option with a time interval to start queue runners at regular
1687intervals, or use some other means (such as cron) to start them. If you do not
1688arrange for queue runners to be run, messages that fail temporarily at the
1689first attempt will remain on your queue for ever. A queue runner process works
1690its way through the queue, one message at a time, trying each delivery that has
1691passed its retry time. You can run several queue runners at once.
1692
1693Exim uses a set of configured rules to determine when next to retry the failing
1694address (see chapter 32). These rules also specify when Exim should give up
1695trying to deliver to the address, at which point it generates a bounce message.
1696If no retry rules are set for a particular host, address, and error
1697combination, no retries are attempted, and temporary errors are treated as
1698permanent.
1699
1700
17013.15 Temporary delivery failure
1702-------------------------------
1703
1704There are many reasons why a message may not be immediately deliverable to a
1705particular address. Failure to connect to a remote machine (because it, or the
1706connection to it, is down) is one of the most common. Temporary failures may be
1707detected during routing as well as during the transport stage of delivery.
1708Local deliveries may be delayed if NFS files are unavailable, or if a mailbox
1709is on a file system where the user is over quota. Exim can be configured to
1710impose its own quotas on local mailboxes; where system quotas are set they will
1711also apply.
1712
1713If a host is unreachable for a period of time, a number of messages may be
1714waiting for it by the time it recovers, and sending them in a single SMTP
1715connection is clearly beneficial. Whenever a delivery to a remote host is
1716deferred, Exim makes a note in its hints database, and whenever a successful
1717SMTP delivery has happened, it looks to see if any other messages are waiting
1718for the same host. If any are found, they are sent over the same SMTP
1719connection, subject to a configuration limit as to the maximum number in any
1720one connection.
1721
1722
17233.16 Permanent delivery failure
1724-------------------------------
1725
1726When a message cannot be delivered to some or all of its intended recipients, a
1727bounce message is generated. Temporary delivery failures turn into permanent
1728errors when their timeout expires. All the addresses that fail in a given
1729delivery attempt are listed in a single message. If the original message has
1730many recipients, it is possible for some addresses to fail in one delivery
1731attempt and others to fail subsequently, giving rise to more than one bounce
1732message. The wording of bounce messages can be customized by the administrator.
1733See chapter 48 for details.
1734
1735Bounce messages contain an X-Failed-Recipients: header line that lists the
1736failed addresses, for the benefit of programs that try to analyse such messages
1737automatically.
1738
1739A bounce message is normally sent to the sender of the original message, as
1740obtained from the message's envelope. For incoming SMTP messages, this is the
1741address given in the MAIL command. However, when an address is expanded via a
1742forward or alias file, an alternative address can be specified for delivery
1743failures of the generated addresses. For a mailing list expansion (see section
174449.2) it is common to direct bounce messages to the manager of the list.
1745
1746
17473.17 Failures to deliver bounce messages
1748----------------------------------------
1749
1750If a bounce message (either locally generated or received from a remote host)
1751itself suffers a permanent delivery failure, the message is left on the queue,
1752but it is frozen, awaiting the attention of an administrator. There are options
1753that can be used to make Exim discard such failed messages, or to keep them for
1754only a short time (see timeout_frozen_after and ignore_bounce_errors_after).
1755
1756
1757
1758===============================================================================
17594. BUILDING AND INSTALLING EXIM
1760
1761
17624.1 Unpacking
1763-------------
1764
1765Exim is distributed as a gzipped or bzipped tar file which, when unpacked,
1766creates a directory with the name of the current release (for example,
188b6fee 1767exim-4.84.2) into which the following files are placed:
420a0d19
CE
1768
1769 ACKNOWLEDGMENTS contains some acknowledgments
1770 CHANGES contains a reference to where changes are documented
1771 LICENCE the GNU General Public Licence
1772 Makefile top-level make file
1773 NOTICE conditions for the use of Exim
1774 README list of files, directories and simple build instructions
1775
1776Other files whose names begin with README may also be present. The following
1777subdirectories are created:
1778
1779 Local an empty directory for local configuration files
1780 OS OS-specific files
1781 doc documentation files
1782 exim_monitor source files for the Exim monitor
1783 scripts scripts used in the build process
1784 src remaining source files
1785 util independent utilities
1786
1787The main utility programs are contained in the src directory, and are built
1788with the Exim binary. The util directory contains a few optional scripts that
1789may be useful to some sites.
1790
1791
17924.2 Multiple machine architectures and operating systems
1793--------------------------------------------------------
1794
1795The building process for Exim is arranged to make it easy to build binaries for
1796a number of different architectures and operating systems from the same set of
1797source files. Compilation does not take place in the src directory. Instead, a
1798build directory is created for each architecture and operating system. Symbolic
1799links to the sources are installed in this directory, which is where the actual
1800building takes place. In most cases, Exim can discover the machine architecture
1801and operating system for itself, but the defaults can be overridden if
1802necessary.
1803
1804
18054.3 PCRE library
1806----------------
1807
1808Exim no longer has an embedded PCRE library as the vast majority of modern
1809systems include PCRE as a system library, although you may need to install the
1810PCRE or PCRE development package for your operating system. If your system has
1811a normal PCRE installation the Exim build process will need no further
1812configuration. If the library or the headers are in an unusual location you
1813will need to either set the PCRE_LIBS and INCLUDE directives appropriately, or
1814set PCRE_CONFIG=yes to use the installed pcre-config command. If your operating
1815system has no PCRE support then you will need to obtain and build the current
1816PCRE from ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/. More
1817information on PCRE is available at http://www.pcre.org/.
1818
1819
18204.4 DBM libraries
1821-----------------
1822
1823Even if you do not use any DBM files in your configuration, Exim still needs a
1824DBM library in order to operate, because it uses indexed files for its hints
1825databases. Unfortunately, there are a number of DBM libraries in existence, and
1826different operating systems often have different ones installed.
1827
1828If you are using Solaris, IRIX, one of the modern BSD systems, or a modern
1829Linux distribution, the DBM configuration should happen automatically, and you
1830may be able to ignore this section. Otherwise, you may have to learn more than
1831you would like about DBM libraries from what follows.
1832
1833Licensed versions of Unix normally contain a library of DBM functions operating
1834via the ndbm interface, and this is what Exim expects by default. Free versions
1835of Unix seem to vary in what they contain as standard. In particular, some
1836early versions of Linux have no default DBM library, and different distributors
1837have chosen to bundle different libraries with their packaged versions.
1838However, the more recent releases seem to have standardized on the Berkeley DB
1839library.
1840
1841Different DBM libraries have different conventions for naming the files they
1842use. When a program opens a file called dbmfile, there are several
1843possibilities:
1844
1845 1. A traditional ndbm implementation, such as that supplied as part of
1846 Solaris, operates on two files called dbmfile.dir and dbmfile.pag.
1847
1848 2. The GNU library, gdbm, operates on a single file. If used via its ndbm
1849 compatibility interface it makes two different hard links to it with names
1850 dbmfile.dir and dbmfile.pag, but if used via its native interface, the file
1851 name is used unmodified.
1852
1853 3. The Berkeley DB package, if called via its ndbm compatibility interface,
1854 operates on a single file called dbmfile.db, but otherwise looks to the
1855 programmer exactly the same as the traditional ndbm implementation.
1856
1857 4. If the Berkeley package is used in its native mode, it operates on a single
1858 file called dbmfile; the programmer's interface is somewhat different to
1859 the traditional ndbm interface.
1860
1861 5. To complicate things further, there are several very different versions of
1862 the Berkeley DB package. Version 1.85 was stable for a very long time,
1863 releases 2.x and 3.x were current for a while, but the latest versions are
1864 now numbered 4.x. Maintenance of some of the earlier releases has ceased.
1865 All versions of Berkeley DB can be obtained from http://www.sleepycat.com/.
1866
1867 6. Yet another DBM library, called tdb, is available from http://
1868 download.sourceforge.net/tdb. It has its own interface, and also operates
1869 on a single file.
1870
1871Exim and its utilities can be compiled to use any of these interfaces. In order
1872to use any version of the Berkeley DB package in native mode, you must set
1873USE_DB in an appropriate configuration file (typically Local/Makefile). For
1874example:
1875
1876USE_DB=yes
1877
1878Similarly, for gdbm you set USE_GDBM, and for tdb you set USE_TDB. An error is
1879diagnosed if you set more than one of these.
1880
1881At the lowest level, the build-time configuration sets none of these options,
1882thereby assuming an interface of type (1). However, some operating system
1883configuration files (for example, those for the BSD operating systems and
1884Linux) assume type (4) by setting USE_DB as their default, and the
1885configuration files for Cygwin set USE_GDBM. Anything you set in Local/Makefile
1886, however, overrides these system defaults.
1887
1888As well as setting USE_DB, USE_GDBM, or USE_TDB, it may also be necessary to
1889set DBMLIB, to cause inclusion of the appropriate library, as in one of these
1890lines:
1891
1892DBMLIB = -ldb
1893DBMLIB = -ltdb
1894
1895Settings like that will work if the DBM library is installed in the standard
1896place. Sometimes it is not, and the library's header file may also not be in
1897the default path. You may need to set INCLUDE to specify where the header file
1898is, and to specify the path to the library more fully in DBMLIB, as in this
1899example:
1900
1901INCLUDE=-I/usr/local/include/db-4.1
1902DBMLIB=/usr/local/lib/db-4.1/libdb.a
1903
1904There is further detailed discussion about the various DBM libraries in the
1905file doc/dbm.discuss.txt in the Exim distribution.
1906
1907
19084.5 Pre-building configuration
1909------------------------------
1910
1911Before building Exim, a local configuration file that specifies options
1912independent of any operating system has to be created with the name Local/
1913Makefile. A template for this file is supplied as the file src/EDITME, and it
1914contains full descriptions of all the option settings therein. These
1915descriptions are therefore not repeated here. If you are building Exim for the
1916first time, the simplest thing to do is to copy src/EDITME to Local/Makefile,
1917then read it and edit it appropriately.
1918
1919There are three settings that you must supply, because Exim will not build
1920without them. They are the location of the run time configuration file
1921(CONFIGURE_FILE), the directory in which Exim binaries will be installed
1922(BIN_DIRECTORY), and the identity of the Exim user (EXIM_USER and maybe
1923EXIM_GROUP as well). The value of CONFIGURE_FILE can in fact be a
1924colon-separated list of file names; Exim uses the first of them that exists.
1925
1926There are a few other parameters that can be specified either at build time or
1927at run time, to enable the same binary to be used on a number of different
1928machines. However, if the locations of Exim's spool directory and log file
1929directory (if not within the spool directory) are fixed, it is recommended that
1930you specify them in Local/Makefile instead of at run time, so that errors
1931detected early in Exim's execution (such as a malformed configuration file) can
1932be logged.
1933
1934Exim's interfaces for calling virus and spam scanning software directly from
1935access control lists are not compiled by default. If you want to include these
1936facilities, you need to set
1937
1938WITH_CONTENT_SCAN=yes
1939
1940in your Local/Makefile. For details of the facilities themselves, see chapter
194143.
1942
1943If you are going to build the Exim monitor, a similar configuration process is
1944required. The file exim_monitor/EDITME must be edited appropriately for your
1945installation and saved under the name Local/eximon.conf. If you are happy with
1946the default settings described in exim_monitor/EDITME, Local/eximon.conf can be
1947empty, but it must exist.
1948
1949This is all the configuration that is needed in straightforward cases for known
1950operating systems. However, the building process is set up so that it is easy
1951to override options that are set by default or by operating-system-specific
1952configuration files, for example to change the name of the C compiler, which
1953defaults to gcc. See section 4.13 below for details of how to do this.
1954
1955
19564.6 Support for iconv()
1957-----------------------
1958
1959The contents of header lines in messages may be encoded according to the rules
1960described RFC 2047. This makes it possible to transmit characters that are not
1961in the ASCII character set, and to label them as being in a particular
1962character set. When Exim is inspecting header lines by means of the $h_
1963mechanism, it decodes them, and translates them into a specified character set
1964(default ISO-8859-1). The translation is possible only if the operating system
1965supports the iconv() function.
1966
1967However, some of the operating systems that supply iconv() do not support very
1968many conversions. The GNU libiconv library (available from http://www.gnu.org/
1969software/libiconv/) can be installed on such systems to remedy this deficiency,
1970as well as on systems that do not supply iconv() at all. After installing
1971libiconv, you should add
1972
1973HAVE_ICONV=yes
1974
1975to your Local/Makefile and rebuild Exim.
1976
1977
19784.7 Including TLS/SSL encryption support
1979----------------------------------------
1980
1981Exim can be built to support encrypted SMTP connections, using the STARTTLS
1982command as per RFC 2487. It can also support legacy clients that expect to
1983start a TLS session immediately on connection to a non-standard port (see the
1984tls_on_connect_ports runtime option and the -tls-on-connect command line
1985option).
1986
1987If you want to build Exim with TLS support, you must first install either the
1988OpenSSL or GnuTLS library. There is no cryptographic code in Exim itself for
1989implementing SSL.
1990
1991If OpenSSL is installed, you should set
1992
1993SUPPORT_TLS=yes
1994TLS_LIBS=-lssl -lcrypto
1995
1996in Local/Makefile. You may also need to specify the locations of the OpenSSL
1997library and include files. For example:
1998
1999SUPPORT_TLS=yes
2000TLS_LIBS=-L/usr/local/openssl/lib -lssl -lcrypto
2001TLS_INCLUDE=-I/usr/local/openssl/include/
2002
2003If you have pkg-config available, then instead you can just use:
2004
2005SUPPORT_TLS=yes
2006USE_OPENSSL_PC=openssl
2007
2008If GnuTLS is installed, you should set
2009
2010SUPPORT_TLS=yes
2011USE_GNUTLS=yes
2012TLS_LIBS=-lgnutls -ltasn1 -lgcrypt
2013
2014in Local/Makefile, and again you may need to specify the locations of the
2015library and include files. For example:
2016
2017SUPPORT_TLS=yes
2018USE_GNUTLS=yes
2019TLS_LIBS=-L/usr/gnu/lib -lgnutls -ltasn1 -lgcrypt
2020TLS_INCLUDE=-I/usr/gnu/include
2021
2022If you have pkg-config available, then instead you can just use:
2023
2024SUPPORT_TLS=yes
2025USE_GNUTLS=yes
2026USE_GNUTLS_PC=gnutls
2027
2028You do not need to set TLS_INCLUDE if the relevant directory is already
2029specified in INCLUDE. Details of how to configure Exim to make use of TLS are
2030given in chapter 41.
2031
2032
20334.8 Use of tcpwrappers
2034----------------------
2035
2036Exim can be linked with the tcpwrappers library in order to check incoming SMTP
2037calls using the tcpwrappers control files. This may be a convenient alternative
2038to Exim's own checking facilities for installations that are already making use
2039of tcpwrappers for other purposes. To do this, you should set USE_TCP_WRAPPERS
2040in Local/Makefile, arrange for the file tcpd.h to be available at compile time,
2041and also ensure that the library libwrap.a is available at link time, typically
2042by including -lwrap in EXTRALIBS_EXIM. For example, if tcpwrappers is installed
2043in /usr/local, you might have
2044
2045USE_TCP_WRAPPERS=yes
2046CFLAGS=-O -I/usr/local/include
2047EXTRALIBS_EXIM=-L/usr/local/lib -lwrap
2048
2049in Local/Makefile. The daemon name to use in the tcpwrappers control files is
2050"exim". For example, the line
2051
2052exim : LOCAL 192.168.1. .friendly.domain.example
2053
2054in your /etc/hosts.allow file allows connections from the local host, from the
2055subnet 192.168.1.0/24, and from all hosts in friendly.domain.example. All other
2056connections are denied. The daemon name used by tcpwrappers can be changed at
2057build time by setting TCP_WRAPPERS_DAEMON_NAME in Local/Makefile, or by setting
2058tcp_wrappers_daemon_name in the configure file. Consult the tcpwrappers
2059documentation for further details.
2060
2061
20624.9 Including support for IPv6
2063------------------------------
2064
2065Exim contains code for use on systems that have IPv6 support. Setting
2066"HAVE_IPV6=YES" in Local/Makefile causes the IPv6 code to be included; it may
2067also be necessary to set IPV6_INCLUDE and IPV6_LIBS on systems where the IPv6
2068support is not fully integrated into the normal include and library files.
2069
2070Two different types of DNS record for handling IPv6 addresses have been
2071defined. AAAA records (analogous to A records for IPv4) are in use, and are
2072currently seen as the mainstream. Another record type called A6 was proposed as
2073better than AAAA because it had more flexibility. However, it was felt to be
2074over-complex, and its status was reduced to "experimental". It is not known if
2075anyone is actually using A6 records. Exim has support for A6 records, but this
2076is included only if you set "SUPPORT_A6=YES" in Local/Makefile. The support has
2077not been tested for some time.
2078
2079
20804.10 Dynamically loaded lookup module support
2081---------------------------------------------
2082
2083On some platforms, Exim supports not compiling all lookup types directly into
2084the main binary, instead putting some into external modules which can be loaded
2085on demand. This permits packagers to build Exim with support for lookups with
2086extensive library dependencies without requiring all users to install all of
2087those dependencies. Most, but not all, lookup types can be built this way.
2088
2089Set "LOOKUP_MODULE_DIR" to the directory into which the modules will be
2090installed; Exim will only load modules from that directory, as a security
2091measure. You will need to set "CFLAGS_DYNAMIC" if not already defined for your
2092OS; see OS/Makefile-Linux for an example. Some other requirements for adjusting
2093"EXTRALIBS" may also be necessary, see src/EDITME for details.
2094
2095Then, for each module to be loaded dynamically, define the relevant "LOOKUP_"<
2096lookup_type> flags to have the value "2" instead of "yes". For example, this
2097will build in lsearch but load sqlite and mysql support on demand:
2098
2099LOOKUP_LSEARCH=yes
2100LOOKUP_SQLITE=2
2101LOOKUP_MYSQL=2
2102
2103
21044.11 The building process
2105-------------------------
2106
2107Once Local/Makefile (and Local/eximon.conf, if required) have been created, run
2108make at the top level. It determines the architecture and operating system
2109types, and creates a build directory if one does not exist. For example, on a
2110Sun system running Solaris 8, the directory build-SunOS5-5.8-sparc is created.
2111Symbolic links to relevant source files are installed in the build directory.
2112
2113Warning: The -j (parallel) flag must not be used with make; the building
2114process fails if it is set.
2115
2116If this is the first time make has been run, it calls a script that builds a
2117make file inside the build directory, using the configuration files from the
2118Local directory. The new make file is then passed to another instance of make.
2119This does the real work, building a number of utility scripts, and then
2120compiling and linking the binaries for the Exim monitor (if configured), a
2121number of utility programs, and finally Exim itself. The command "make
2122makefile" can be used to force a rebuild of the make file in the build
2123directory, should this ever be necessary.
2124
2125If you have problems building Exim, check for any comments there may be in the
2126README file concerning your operating system, and also take a look at the FAQ,
2127where some common problems are covered.
2128
2129
21304.12 Output from "make"
2131-----------------------
2132
2133The output produced by the make process for compile lines is often very
2134unreadable, because these lines can be very long. For this reason, the normal
2135output is suppressed by default, and instead output similar to that which
2136appears when compiling the 2.6 Linux kernel is generated: just a short line for
2137each module that is being compiled or linked. However, it is still possible to
2138get the full output, by calling make like this:
2139
2140FULLECHO='' make -e
2141
2142The value of FULLECHO defaults to "@", the flag character that suppresses
2143command reflection in make. When you ask for the full output, it is given in
2144addition to the short output.
2145
2146
21474.13 Overriding build-time options for Exim
2148-------------------------------------------
2149
2150The main make file that is created at the beginning of the building process
2151consists of the concatenation of a number of files which set configuration
2152values, followed by a fixed set of make instructions. If a value is set more
2153than once, the last setting overrides any previous ones. This provides a
2154convenient way of overriding defaults. The files that are concatenated are, in
2155order:
2156
2157OS/Makefile-Default
2158OS/Makefile-<ostype>
2159Local/Makefile
2160Local/Makefile-<ostype>
2161Local/Makefile-<archtype>
2162Local/Makefile-<ostype>-<archtype>
2163OS/Makefile-Base
2164
2165where <ostype> is the operating system type and <archtype> is the architecture
2166type. Local/Makefile is required to exist, and the building process fails if it
2167is absent. The other three Local files are optional, and are often not needed.
2168
2169The values used for <ostype> and <archtype> are obtained from scripts called
2170scripts/os-type and scripts/arch-type respectively. If either of the
2171environment variables EXIM_OSTYPE or EXIM_ARCHTYPE is set, their values are
2172used, thereby providing a means of forcing particular settings. Otherwise, the
2173scripts try to get values from the uname command. If this fails, the shell
2174variables OSTYPE and ARCHTYPE are inspected. A number of ad hoc transformations
2175are then applied, to produce the standard names that Exim expects. You can run
2176these scripts directly from the shell in order to find out what values are
2177being used on your system.
2178
2179OS/Makefile-Default contains comments about the variables that are set therein.
2180Some (but not all) are mentioned below. If there is something that needs
2181changing, review the contents of this file and the contents of the make file
2182for your operating system (OS/Makefile-<ostype>) to see what the default values
2183are.
2184
2185If you need to change any of the values that are set in OS/Makefile-Default or
2186in OS/Makefile-<ostype>, or to add any new definitions, you do not need to
2187change the original files. Instead, you should make the changes by putting the
2188new values in an appropriate Local file. For example, when building Exim in
2189many releases of the Tru64-Unix (formerly Digital UNIX, formerly DEC-OSF1)
2190operating system, it is necessary to specify that the C compiler is called cc
2191rather than gcc. Also, the compiler must be called with the option -std1, to
2192make it recognize some of the features of Standard C that Exim uses. (Most
2193other compilers recognize Standard C by default.) To do this, you should create
2194a file called Local/Makefile-OSF1 containing the lines
2195
2196CC=cc
2197CFLAGS=-std1
2198
2199If you are compiling for just one operating system, it may be easier to put
2200these lines directly into Local/Makefile.
2201
2202Keeping all your local configuration settings separate from the distributed
2203files makes it easy to transfer them to new versions of Exim simply by copying
2204the contents of the Local directory.
2205
2206Exim contains support for doing LDAP, NIS, NIS+, and other kinds of file
2207lookup, but not all systems have these components installed, so the default is
2208not to include the relevant code in the binary. All the different kinds of file
2209and database lookup that Exim supports are implemented as separate code modules
2210which are included only if the relevant compile-time options are set. In the
2211case of LDAP, NIS, and NIS+, the settings for Local/Makefile are:
2212
2213LOOKUP_LDAP=yes
2214LOOKUP_NIS=yes
2215LOOKUP_NISPLUS=yes
2216
2217and similar settings apply to the other lookup types. They are all listed in
2218src/EDITME. In many cases the relevant include files and interface libraries
2219need to be installed before compiling Exim. However, there are some optional
2220lookup types (such as cdb) for which the code is entirely contained within
2221Exim, and no external include files or libraries are required. When a lookup
2222type is not included in the binary, attempts to configure Exim to use it cause
2223run time configuration errors.
2224
2225Many systems now use a tool called pkg-config to encapsulate information about
2226how to compile against a library; Exim has some initial support for being able
2227to use pkg-config for lookups and authenticators. For any given makefile
2228variable which starts "LOOKUP_" or "AUTH_", you can add a new variable with the
2229"_PC" suffix in the name and assign as the value the name of the package to be
2230queried. The results of querying via the pkg-config command will be added to
2231the appropriate Makefile variables with "+=" directives, so your version of
2232make will need to support that syntax. For instance:
2233
2234LOOKUP_SQLITE=yes
2235LOOKUP_SQLITE_PC=sqlite3
2236AUTH_GSASL=yes
2237AUTH_GSASL_PC=libgsasl
2238AUTH_HEIMDAL_GSSAPI=yes
2239AUTH_HEIMDAL_GSSAPI_PC=heimdal-gssapi
2240
2241Exim can be linked with an embedded Perl interpreter, allowing Perl subroutines
2242to be called during string expansion. To enable this facility,
2243
2244EXIM_PERL=perl.o
2245
2246must be defined in Local/Makefile. Details of this facility are given in
2247chapter 12.
2248
2249The location of the X11 libraries is something that varies a lot between
2250operating systems, and there may be different versions of X11 to cope with.
2251Exim itself makes no use of X11, but if you are compiling the Exim monitor, the
2252X11 libraries must be available. The following three variables are set in OS/
2253Makefile-Default:
2254
2255X11=/usr/X11R6
2256XINCLUDE=-I$(X11)/include
2257XLFLAGS=-L$(X11)/lib
2258
2259These are overridden in some of the operating-system configuration files. For
2260example, in OS/Makefile-SunOS5 there is
2261
2262X11=/usr/openwin
2263XINCLUDE=-I$(X11)/include
2264XLFLAGS=-L$(X11)/lib -R$(X11)/lib
2265
2266If you need to override the default setting for your operating system, place a
2267definition of all three of these variables into your Local/Makefile-<ostype>
2268file.
2269
2270If you need to add any extra libraries to the link steps, these can be put in a
2271variable called EXTRALIBS, which appears in all the link commands, but by
2272default is not defined. In contrast, EXTRALIBS_EXIM is used only on the command
2273for linking the main Exim binary, and not for any associated utilities.
2274
2275There is also DBMLIB, which appears in the link commands for binaries that use
2276DBM functions (see also section 4.4). Finally, there is EXTRALIBS_EXIMON, which
2277appears only in the link step for the Exim monitor binary, and which can be
2278used, for example, to include additional X11 libraries.
2279
2280The make file copes with rebuilding Exim correctly if any of the configuration
2281files are edited. However, if an optional configuration file is deleted, it is
2282necessary to touch the associated non-optional file (that is, Local/Makefile or
2283Local/eximon.conf) before rebuilding.
2284
2285
22864.14 OS-specific header files
2287-----------------------------
2288
2289The OS directory contains a number of files with names of the form os.h-
2290<ostype>. These are system-specific C header files that should not normally
2291need to be changed. There is a list of macro settings that are recognized in
2292the file OS/os.configuring, which should be consulted if you are porting Exim
2293to a new operating system.
2294
2295
22964.15 Overriding build-time options for the monitor
2297--------------------------------------------------
2298
2299A similar process is used for overriding things when building the Exim monitor,
2300where the files that are involved are
2301
2302OS/eximon.conf-Default
2303OS/eximon.conf-<ostype>
2304Local/eximon.conf
2305Local/eximon.conf-<ostype>
2306Local/eximon.conf-<archtype>
2307Local/eximon.conf-<ostype>-<archtype>
2308
2309As with Exim itself, the final three files need not exist, and in this case the
2310OS/eximon.conf-<ostype> file is also optional. The default values in OS/
2311eximon.conf-Default can be overridden dynamically by setting environment
2312variables of the same name, preceded by EXIMON_. For example, setting
2313EXIMON_LOG_DEPTH in the environment overrides the value of LOG_DEPTH at run
2314time.
2315
2316
23174.16 Installing Exim binaries and scripts
2318-----------------------------------------
2319
2320The command "make install" runs the exim_install script with no arguments. The
2321script copies binaries and utility scripts into the directory whose name is
2322specified by the BIN_DIRECTORY setting in Local/Makefile. The install script
2323copies files only if they are newer than the files they are going to replace.
2324The Exim binary is required to be owned by root and have the setuid bit set,
2325for normal configurations. Therefore, you must run "make install" as root so
2326that it can set up the Exim binary in this way. However, in some special
2327situations (for example, if a host is doing no local deliveries) it may be
2328possible to run Exim without making the binary setuid root (see chapter 54 for
2329details).
2330
2331Exim's run time configuration file is named by the CONFIGURE_FILE setting in
2332Local/Makefile. If this names a single file, and the file does not exist, the
2333default configuration file src/configure.default is copied there by the
2334installation script. If a run time configuration file already exists, it is
2335left alone. If CONFIGURE_FILE is a colon-separated list, naming several
2336alternative files, no default is installed.
2337
2338One change is made to the default configuration file when it is installed: the
2339default configuration contains a router that references a system aliases file.
2340The path to this file is set to the value specified by SYSTEM_ALIASES_FILE in
2341Local/Makefile (/etc/aliases by default). If the system aliases file does not
2342exist, the installation script creates it, and outputs a comment to the user.
2343
2344The created file contains no aliases, but it does contain comments about the
2345aliases a site should normally have. Mail aliases have traditionally been kept
2346in /etc/aliases. However, some operating systems are now using /etc/mail/
2347aliases. You should check if yours is one of these, and change Exim's
2348configuration if necessary.
2349
2350The default configuration uses the local host's name as the only local domain,
2351and is set up to do local deliveries into the shared directory /var/mail,
2352running as the local user. System aliases and .forward files in users' home
2353directories are supported, but no NIS or NIS+ support is configured. Domains
2354other than the name of the local host are routed using the DNS, with delivery
2355over SMTP.
2356
2357It is possible to install Exim for special purposes (such as building a binary
2358distribution) in a private part of the file system. You can do this by a
2359command such as
2360
2361make DESTDIR=/some/directory/ install
2362
2363This has the effect of pre-pending the specified directory to all the file
2364paths, except the name of the system aliases file that appears in the default
2365configuration. (If a default alias file is created, its name is modified.) For
2366backwards compatibility, ROOT is used if DESTDIR is not set, but this usage is
2367deprecated.
2368
2369Running make install does not copy the Exim 4 conversion script convert4r4. You
2370will probably run this only once if you are upgrading from Exim 3. None of the
2371documentation files in the doc directory are copied, except for the info files
2372when you have set INFO_DIRECTORY, as described in section 4.17 below.
2373
2374For the utility programs, old versions are renamed by adding the suffix .O to
2375their names. The Exim binary itself, however, is handled differently. It is
2376installed under a name that includes the version number and the compile number,
188b6fee 2377for example exim-4.84.2-1. The script then arranges for a symbolic link called
420a0d19
CE
2378exim to point to the binary. If you are updating a previous version of Exim,
2379the script takes care to ensure that the name exim is never absent from the
2380directory (as seen by other processes).
2381
2382If you want to see what the make install will do before running it for real,
2383you can pass the -n option to the installation script by this command:
2384
2385make INSTALL_ARG=-n install
2386
2387The contents of the variable INSTALL_ARG are passed to the installation script.
2388You do not need to be root to run this test. Alternatively, you can run the
2389installation script directly, but this must be from within the build directory.
2390For example, from the top-level Exim directory you could use this command:
2391
2392(cd build-SunOS5-5.5.1-sparc; ../scripts/exim_install -n)
2393
2394There are two other options that can be supplied to the installation script.
2395
2396 * -no_chown bypasses the call to change the owner of the installed binary to
2397 root, and the call to make it a setuid binary.
2398
2399 * -no_symlink bypasses the setting up of the symbolic link exim to the
2400 installed binary.
2401
2402INSTALL_ARG can be used to pass these options to the script. For example:
2403
2404make INSTALL_ARG=-no_symlink install
2405
2406The installation script can also be given arguments specifying which files are
2407to be copied. For example, to install just the Exim binary, and nothing else,
2408without creating the symbolic link, you could use:
2409
2410make INSTALL_ARG='-no_symlink exim' install
2411
2412
24134.17 Installing info documentation
2414----------------------------------
2415
2416Not all systems use the GNU info system for documentation, and for this reason,
2417the Texinfo source of Exim's documentation is not included in the main
2418distribution. Instead it is available separately from the ftp site (see section
24191.6).
2420
2421If you have defined INFO_DIRECTORY in Local/Makefile and the Texinfo source of
2422the documentation is found in the source tree, running "make install"
2423automatically builds the info files and installs them.
2424
2425
24264.18 Setting up the spool directory
2427-----------------------------------
2428
2429When it starts up, Exim tries to create its spool directory if it does not
2430exist. The Exim uid and gid are used for the owner and group of the spool
2431directory. Sub-directories are automatically created in the spool directory as
2432necessary.
2433
2434
24354.19 Testing
2436------------
2437
2438Having installed Exim, you can check that the run time configuration file is
2439syntactically valid by running the following command, which assumes that the
2440Exim binary directory is within your PATH environment variable:
2441
2442exim -bV
2443
2444If there are any errors in the configuration file, Exim outputs error messages.
2445Otherwise it outputs the version number and build date, the DBM library that is
2446being used, and information about which drivers and other optional code modules
2447are included in the binary. Some simple routing tests can be done by using the
2448address testing option. For example,
2449
2450exim -bt <local username>
2451
2452should verify that it recognizes a local mailbox, and
2453
2454exim -bt <remote address>
2455
2456a remote one. Then try getting it to deliver mail, both locally and remotely.
2457This can be done by passing messages directly to Exim, without going through a
2458user agent. For example:
2459
2460exim -v postmaster@your.domain.example
2461From: user@your.domain.example
2462To: postmaster@your.domain.example
2463Subject: Testing Exim
2464
2465This is a test message.
2466^D
2467
2468The -v option causes Exim to output some verification of what it is doing. In
2469this case you should see copies of three log lines, one for the message's
2470arrival, one for its delivery, and one containing "Completed".
2471
2472If you encounter problems, look at Exim's log files (mainlog and paniclog) to
2473see if there is any relevant information there. Another source of information
2474is running Exim with debugging turned on, by specifying the -d option. If a
2475message is stuck on Exim's spool, you can force a delivery with debugging
2476turned on by a command of the form
2477
2478exim -d -M <exim-message-id>
2479
2480You must be root or an "admin user" in order to do this. The -d option produces
2481rather a lot of output, but you can cut this down to specific areas. For
2482example, if you use -d-all+route only the debugging information relevant to
2483routing is included. (See the -d option in chapter 5 for more details.)
2484
2485One specific problem that has shown up on some sites is the inability to do
2486local deliveries into a shared mailbox directory, because it does not have the
2487"sticky bit" set on it. By default, Exim tries to create a lock file before
2488writing to a mailbox file, and if it cannot create the lock file, the delivery
2489is deferred. You can get round this either by setting the "sticky bit" on the
2490directory, or by setting a specific group for local deliveries and allowing
2491that group to create files in the directory (see the comments above the
2492local_delivery transport in the default configuration file). Another approach
2493is to configure Exim not to use lock files, but just to rely on fcntl() locking
2494instead. However, you should do this only if all user agents also use fcntl()
2495locking. For further discussion of locking issues, see chapter 26.
2496
2497One thing that cannot be tested on a system that is already running an MTA is
2498the receipt of incoming SMTP mail on the standard SMTP port. However, the -oX
2499option can be used to run an Exim daemon that listens on some other port, or
2500inetd can be used to do this. The -bh option and the exim_checkaccess utility
2501can be used to check out policy controls on incoming SMTP mail.
2502
2503Testing a new version on a system that is already running Exim can most easily
2504be done by building a binary with a different CONFIGURE_FILE setting. From
2505within the run time configuration, all other file and directory names that Exim
2506uses can be altered, in order to keep it entirely clear of the production
2507version.
2508
2509
25104.20 Replacing another MTA with Exim
2511------------------------------------
2512
2513Building and installing Exim for the first time does not of itself put it in
2514general use. The name by which the system's MTA is called by mail user agents
2515is either /usr/sbin/sendmail, or /usr/lib/sendmail (depending on the operating
2516system), and it is necessary to make this name point to the exim binary in
2517order to get the user agents to pass messages to Exim. This is normally done by
2518renaming any existing file and making /usr/sbin/sendmail or /usr/lib/sendmail a
2519symbolic link to the exim binary. It is a good idea to remove any setuid
2520privilege and executable status from the old MTA. It is then necessary to stop
2521and restart the mailer daemon, if one is running.
2522
2523Some operating systems have introduced alternative ways of switching MTAs. For
2524example, if you are running FreeBSD, you need to edit the file /etc/mail/
2525mailer.conf instead of setting up a symbolic link as just described. A typical
2526example of the contents of this file for running Exim is as follows:
2527
2528sendmail /usr/exim/bin/exim
2529send-mail /usr/exim/bin/exim
2530mailq /usr/exim/bin/exim -bp
2531newaliases /usr/bin/true
2532
2533Once you have set up the symbolic link, or edited /etc/mail/mailer.conf, your
2534Exim installation is "live". Check it by sending a message from your favourite
2535user agent.
2536
2537You should consider what to tell your users about the change of MTA. Exim may
2538have different capabilities to what was previously running, and there are
2539various operational differences such as the text of messages produced by
2540command line options and in bounce messages. If you allow your users to make
2541use of Exim's filtering capabilities, you should make the document entitled
2542Exim's interface to mail filtering available to them.
2543
2544
25454.21 Upgrading Exim
2546-------------------
2547
2548If you are already running Exim on your host, building and installing a new
2549version automatically makes it available to MUAs, or any other programs that
2550call the MTA directly. However, if you are running an Exim daemon, you do need
2551to send it a HUP signal, to make it re-execute itself, and thereby pick up the
2552new binary. You do not need to stop processing mail in order to install a new
2553version of Exim. The install script does not modify an existing runtime
2554configuration file.
2555
2556
25574.22 Stopping the Exim daemon on Solaris
2558----------------------------------------
2559
2560The standard command for stopping the mailer daemon on Solaris is
2561
2562/etc/init.d/sendmail stop
2563
2564If /usr/lib/sendmail has been turned into a symbolic link, this script fails to
2565stop Exim because it uses the command ps -e and greps the output for the text
2566"sendmail"; this is not present because the actual program name (that is,
2567"exim") is given by the ps command with these options. A solution is to replace
2568the line that finds the process id with something like
2569
2570pid=`cat /var/spool/exim/exim-daemon.pid`
2571
2572to obtain the daemon's pid directly from the file that Exim saves it in.
2573
2574Note, however, that stopping the daemon does not "stop Exim". Messages can
2575still be received from local processes, and if automatic delivery is configured
2576(the normal case), deliveries will still occur.
2577
2578
2579
2580===============================================================================
25815. THE EXIM COMMAND LINE
2582
2583Exim's command line takes the standard Unix form of a sequence of options, each
2584starting with a hyphen character, followed by a number of arguments. The
2585options are compatible with the main options of Sendmail, and there are also
2586some additional options, some of which are compatible with Smail 3. Certain
2587combinations of options do not make sense, and provoke an error if used. The
2588form of the arguments depends on which options are set.
2589
2590
25915.1 Setting options by program name
2592-----------------------------------
2593
2594If Exim is called under the name mailq, it behaves as if the option -bp were
2595present before any other options. The -bp option requests a listing of the
2596contents of the mail queue on the standard output. This feature is for
2597compatibility with some systems that contain a command of that name in one of
2598the standard libraries, symbolically linked to /usr/sbin/sendmail or /usr/lib/
2599sendmail.
2600
2601If Exim is called under the name rsmtp it behaves as if the option -bS were
2602present before any other options, for compatibility with Smail. The -bS option
2603is used for reading in a number of messages in batched SMTP format.
2604
2605If Exim is called under the name rmail it behaves as if the -i and -oee options
2606were present before any other options, for compatibility with Smail. The name
2607rmail is used as an interface by some UUCP systems.
2608
2609If Exim is called under the name runq it behaves as if the option -q were
2610present before any other options, for compatibility with Smail. The -q option
2611causes a single queue runner process to be started.
2612
2613If Exim is called under the name newaliases it behaves as if the option -bi
2614were present before any other options, for compatibility with Sendmail. This
2615option is used for rebuilding Sendmail's alias file. Exim does not have the
2616concept of a single alias file, but can be configured to run a given command if
2617called with the -bi option.
2618
2619
26205.2 Trusted and admin users
2621---------------------------
2622
2623Some Exim options are available only to trusted users and others are available
2624only to admin users. In the description below, the phrases "Exim user" and
2625"Exim group" mean the user and group defined by EXIM_USER and EXIM_GROUP in
2626Local/Makefile or set by the exim_user and exim_group options. These do not
2627necessarily have to use the name "exim".
2628
2629 * The trusted users are root, the Exim user, any user listed in the
2630 trusted_users configuration option, and any user whose current group or any
2631 supplementary group is one of those listed in the trusted_groups
2632 configuration option. Note that the Exim group is not automatically
2633 trusted.
2634
2635 Trusted users are always permitted to use the -f option or a leading
2636 "From " line to specify the envelope sender of a message that is passed to
2637 Exim through the local interface (see the -bm and -f options below). See
2638 the untrusted_set_sender option for a way of permitting non-trusted users
2639 to set envelope senders.
2640
2641 For a trusted user, there is never any check on the contents of the From:
2642 header line, and a Sender: line is never added. Furthermore, any existing
2643 Sender: line in incoming local (non-TCP/IP) messages is not removed.
2644
2645 Trusted users may also specify a host name, host address, interface
2646 address, protocol name, ident value, and authentication data when
2647 submitting a message locally. Thus, they are able to insert messages into
2648 Exim's queue locally that have the characteristics of messages received
2649 from a remote host. Untrusted users may in some circumstances use -f, but
2650 can never set the other values that are available to trusted users.
2651
2652 * The admin users are root, the Exim user, and any user that is a member of
2653 the Exim group or of any group listed in the admin_groups configuration
2654 option. The current group does not have to be one of these groups.
2655
2656 Admin users are permitted to list the queue, and to carry out certain
2657 operations on messages, for example, to force delivery failures. It is also
2658 necessary to be an admin user in order to see the full information provided
2659 by the Exim monitor, and full debugging output.
2660
2661 By default, the use of the -M, -q, -R, and -S options to cause Exim to
2662 attempt delivery of messages on its queue is restricted to admin users.
2663 However, this restriction can be relaxed by setting the prod_requires_admin
2664 option false (that is, specifying no_prod_requires_admin).
2665
2666 Similarly, the use of the -bp option to list all the messages in the queue
2667 is restricted to admin users unless queue_list_requires_admin is set false.
2668
2669Warning: If you configure your system so that admin users are able to edit
2670Exim's configuration file, you are giving those users an easy way of getting
2671root. There is further discussion of this issue at the start of chapter 6.
2672
2673
26745.3 Command line options
2675------------------------
2676
2677Exim's command line options are described in alphabetical order below. If none
2678of the options that specifies a specific action (such as starting the daemon or
2679a queue runner, or testing an address, or receiving a message in a specific
2680format, or listing the queue) are present, and there is at least one argument
2681on the command line, -bm (accept a local message on the standard input, with
2682the arguments specifying the recipients) is assumed. Otherwise, Exim outputs a
2683brief message about itself and exits.
2684
2685--
2686
2687 This is a pseudo-option whose only purpose is to terminate the options and
2688 therefore to cause subsequent command line items to be treated as arguments
2689 rather than options, even if they begin with hyphens.
2690
2691--help
2692
2693 This option causes Exim to output a few sentences stating what it is. The
2694 same output is generated if the Exim binary is called with no options and
2695 no arguments.
2696
2697--version
2698
2699 This option is an alias for -bV and causes version information to be
2700 displayed.
2701
2702-Ac, -Am
2703
2704 These options are used by Sendmail for selecting configuration files and
2705 are ignored by Exim.
2706
2707-B<type>
2708
2709 This is a Sendmail option for selecting 7 or 8 bit processing. Exim is
2710 8-bit clean; it ignores this option.
2711
2712-bd
2713
2714 This option runs Exim as a daemon, awaiting incoming SMTP connections.
2715 Usually the -bd option is combined with the -q<time> option, to specify
2716 that the daemon should also initiate periodic queue runs.
2717
2718 The -bd option can be used only by an admin user. If either of the -d
2719 (debugging) or -v (verifying) options are set, the daemon does not
2720 disconnect from the controlling terminal. When running this way, it can be
2721 stopped by pressing ctrl-C.
2722
2723 By default, Exim listens for incoming connections to the standard SMTP port
2724 on all the host's running interfaces. However, it is possible to listen on
2725 other ports, on multiple ports, and only on specific interfaces. Chapter 13
2726 contains a description of the options that control this.
2727
2728 When a listening daemon is started without the use of -oX (that is, without
2729 overriding the normal configuration), it writes its process id to a file
2730 called exim-daemon.pid in Exim's spool directory. This location can be
2731 overridden by setting PID_FILE_PATH in Local/Makefile. The file is written
2732 while Exim is still running as root.
2733
2734 When -oX is used on the command line to start a listening daemon, the
2735 process id is not written to the normal pid file path. However, -oP can be
2736 used to specify a path on the command line if a pid file is required.
2737
2738 The SIGHUP signal can be used to cause the daemon to re-execute itself.
2739 This should be done whenever Exim's configuration file, or any file that is
2740 incorporated into it by means of the .include facility, is changed, and
2741 also whenever a new version of Exim is installed. It is not necessary to do
2742 this when other files that are referenced from the configuration (for
2743 example, alias files) are changed, because these are reread each time they
2744 are used.
2745
2746-bdf
2747
2748 This option has the same effect as -bd except that it never disconnects
2749 from the controlling terminal, even when no debugging is specified.
2750
2751-be
2752
2753 Run Exim in expansion testing mode. Exim discards its root privilege, to
2754 prevent ordinary users from using this mode to read otherwise inaccessible
2755 files. If no arguments are given, Exim runs interactively, prompting for
2756 lines of data. Otherwise, it processes each argument in turn.
2757
2758 If Exim was built with USE_READLINE=yes in Local/Makefile, it tries to load
2759 the libreadline library dynamically whenever the -be option is used without
2760 command line arguments. If successful, it uses the readline() function,
2761 which provides extensive line-editing facilities, for reading the test
2762 data. A line history is supported.
2763
2764 Long expansion expressions can be split over several lines by using
2765 backslash continuations. As in Exim's run time configuration, white space
2766 at the start of continuation lines is ignored. Each argument or data line
2767 is passed through the string expansion mechanism, and the result is output.
2768 Variable values from the configuration file (for example, $qualify_domain)
2769 are available, but no message-specific values (such as $sender_domain) are
2770 set, because no message is being processed (but see -bem and -Mset).
2771
2772 Note: If you use this mechanism to test lookups, and you change the data
2773 files or databases you are using, you must exit and restart Exim before
2774 trying the same lookup again. Otherwise, because each Exim process caches
2775 the results of lookups, you will just get the same result as before.
2776
2777-bem <filename>
2778
2779 This option operates like -be except that it must be followed by the name
2780 of a file. For example:
2781
2782 exim -bem /tmp/testmessage
2783
2784 The file is read as a message (as if receiving a locally-submitted non-SMTP
2785 message) before any of the test expansions are done. Thus, message-specific
2786 variables such as $message_size and $header_from: are available. However,
2787 no Received: header is added to the message. If the -t option is set,
2788 recipients are read from the headers in the normal way, and are shown in
2789 the $recipients variable. Note that recipients cannot be given on the
2790 command line, because further arguments are taken as strings to expand
2791 (just like -be).
2792
2793-bF <filename>
2794
2795 This option is the same as -bf except that it assumes that the filter being
2796 tested is a system filter. The additional commands that are available only
2797 in system filters are recognized.
2798
2799-bf <filename>
2800
2801 This option runs Exim in user filter testing mode; the file is the filter
2802 file to be tested, and a test message must be supplied on the standard
2803 input. If there are no message-dependent tests in the filter, an empty file
2804 can be supplied.
2805
2806 If you want to test a system filter file, use -bF instead of -bf. You can
2807 use both -bF and -bf on the same command, in order to test a system filter
2808 and a user filter in the same run. For example:
2809
2810 exim -bF /system/filter -bf /user/filter </test/message
2811
2812 This is helpful when the system filter adds header lines or sets filter
2813 variables that are used by the user filter.
2814
2815 If the test filter file does not begin with one of the special lines
2816
2817 # Exim filter
2818 # Sieve filter
2819
2820 it is taken to be a normal .forward file, and is tested for validity under
2821 that interpretation. See sections 22.4 to 22.6 for a description of the
2822 possible contents of non-filter redirection lists.
2823
2824 The result of an Exim command that uses -bf, provided no errors are
2825 detected, is a list of the actions that Exim would try to take if presented
2826 with the message for real. More details of filter testing are given in the
2827 separate document entitled Exim's interfaces to mail filtering.
2828
2829 When testing a filter file, the envelope sender can be set by the -f
2830 option, or by a "From " line at the start of the test message. Various
2831 parameters that would normally be taken from the envelope recipient address
2832 of the message can be set by means of additional command line options (see
2833 the next four options).
2834
2835-bfd <domain>
2836
2837 This sets the domain of the recipient address when a filter file is being
2838 tested by means of the -bf option. The default is the value of
2839 $qualify_domain.
2840
2841-bfl <local part>
2842
2843 This sets the local part of the recipient address when a filter file is
2844 being tested by means of the -bf option. The default is the username of the
2845 process that calls Exim. A local part should be specified with any prefix
2846 or suffix stripped, because that is how it appears to the filter when a
2847 message is actually being delivered.
2848
2849-bfp <prefix>
2850
2851 This sets the prefix of the local part of the recipient address when a
2852 filter file is being tested by means of the -bf option. The default is an
2853 empty prefix.
2854
2855-bfs <suffix>
2856
2857 This sets the suffix of the local part of the recipient address when a
2858 filter file is being tested by means of the -bf option. The default is an
2859 empty suffix.
2860
2861-bh <IP address>
2862
2863 This option runs a fake SMTP session as if from the given IP address, using
2864 the standard input and output. The IP address may include a port number at
2865 the end, after a full stop. For example:
2866
2867 exim -bh 10.9.8.7.1234
2868 exim -bh fe80::a00:20ff:fe86:a061.5678
2869
2870 When an IPv6 address is given, it is converted into canonical form. In the
2871 case of the second example above, the value of $sender_host_address after
2872 conversion to the canonical form is
2873 "fe80:0000:0000:0a00:20ff:fe86:a061.5678".
2874
2875 Comments as to what is going on are written to the standard error file.
2876 These include lines beginning with "LOG" for anything that would have been
2877 logged. This facility is provided for testing configuration options for
2878 incoming messages, to make sure they implement the required policy. For
2879 example, you can test your relay controls using -bh.
2880
2881 Warning 1: You can test features of the configuration that rely on ident
2882 (RFC 1413) information by using the -oMt option. However, Exim cannot
2883 actually perform an ident callout when testing using -bh because there is
2884 no incoming SMTP connection.
2885
2886 Warning 2: Address verification callouts (see section 42.45) are also
2887 skipped when testing using -bh. If you want these callouts to occur, use
2888 -bhc instead.
2889
2890 Messages supplied during the testing session are discarded, and nothing is
2891 written to any of the real log files. There may be pauses when DNS (and
2892 other) lookups are taking place, and of course these may time out. The -oMi
2893 option can be used to specify a specific IP interface and port if this is
2894 important, and -oMaa and -oMai can be used to set parameters as if the SMTP
2895 session were authenticated.
2896
2897 The exim_checkaccess utility is a "packaged" version of -bh whose output
2898 just states whether a given recipient address from a given host is
2899 acceptable or not. See section 52.8.
2900
2901 Features such as authentication and encryption, where the client input is
2902 not plain text, cannot easily be tested with -bh. Instead, you should use a
2903 specialized SMTP test program such as swaks.
2904
2905-bhc <IP address>
2906
2907 This option operates in the same way as -bh, except that address
2908 verification callouts are performed if required. This includes consulting
2909 and updating the callout cache database.
2910
2911-bi
2912
2913 Sendmail interprets the -bi option as a request to rebuild its alias file.
2914 Exim does not have the concept of a single alias file, and so it cannot
2915 mimic this behaviour. However, calls to /usr/lib/sendmail with the -bi
2916 option tend to appear in various scripts such as NIS make files, so the
2917 option must be recognized.
2918
2919 If -bi is encountered, the command specified by the bi_command
2920 configuration option is run, under the uid and gid of the caller of Exim.
2921 If the -oA option is used, its value is passed to the command as an
2922 argument. The command set by bi_command may not contain arguments. The
2923 command can use the exim_dbmbuild utility, or some other means, to rebuild
2924 alias files if this is required. If the bi_command option is not set,
2925 calling Exim with -bi is a no-op.
2926
2927-bI:help
2928
2929 We shall provide various options starting "-bI:" for querying Exim for
2930 information. The output of many of these will be intended for machine
2931 consumption. This one is not. The -bI:help option asks Exim for a synopsis
2932 of supported options beginning "-bI:". Use of any of these options shall
2933 cause Exim to exit after producing the requested output.
2934
2935-bI:dscp
2936
2937 This option causes Exim to emit an alphabetically sorted list of all
2938 recognised DSCP names.
2939
2940-bI:sieve
2941
2942 This option causes Exim to emit an alphabetically sorted list of all
2943 supported Sieve protocol extensions on stdout, one per line. This is
2944 anticipated to be useful for ManageSieve (RFC 5804) implementations, in
2945 providing that protocol's "SIEVE" capability response line. As the precise
2946 list may depend upon compile-time build options, which this option will
2947 adapt to, this is the only way to guarantee a correct response.
2948
2949-bm
2950
2951 This option runs an Exim receiving process that accepts an incoming,
2952 locally-generated message on the standard input. The recipients are given
2953 as the command arguments (except when -t is also present - see below). Each
2954 argument can be a comma-separated list of RFC 2822 addresses. This is the
2955 default option for selecting the overall action of an Exim call; it is
2956 assumed if no other conflicting option is present.
2957
2958 If any addresses in the message are unqualified (have no domain), they are
2959 qualified by the values of the qualify_domain or qualify_recipient options,
2960 as appropriate. The -bnq option (see below) provides a way of suppressing
2961 this for special cases.
2962
2963 Policy checks on the contents of local messages can be enforced by means of
2964 the non-SMTP ACL. See chapter 42 for details.
2965
2966 The return code is zero if the message is successfully accepted. Otherwise,
2967 the action is controlled by the -oex option setting - see below.
2968
2969 The format of the message must be as defined in RFC 2822, except that, for
2970 compatibility with Sendmail and Smail, a line in one of the forms
2971
2972 From sender Fri Jan 5 12:55 GMT 1997
2973 From sender Fri, 5 Jan 97 12:55:01
2974
2975 (with the weekday optional, and possibly with additional text after the
2976 date) is permitted to appear at the start of the message. There appears to
2977 be no authoritative specification of the format of this line. Exim
2978 recognizes it by matching against the regular expression defined by the
2979 uucp_from_pattern option, which can be changed if necessary.
2980
2981 The specified sender is treated as if it were given as the argument to the
2982 -f option, but if a -f option is also present, its argument is used in
2983 preference to the address taken from the message. The caller of Exim must
2984 be a trusted user for the sender of a message to be set in this way.
2985
2986-bmalware <filename>
2987
2988 This debugging option causes Exim to scan the given file, using the malware
2989 scanning framework. The option of av_scanner influences this option, so if
2990 av_scanner's value is dependent upon an expansion then the expansion should
2991 have defaults which apply to this invocation. ACLs are not invoked, so if
2992 av_scanner references an ACL variable then that variable will never be
2993 populated and -bmalware will fail.
2994
2995 Exim will have changed working directory before resolving the filename, so
2996 using fully qualified pathnames is advisable. Exim will be running as the
2997 Exim user when it tries to open the file, rather than as the invoking user.
2998 This option requires admin privileges.
2999
3000 The -bmalware option will not be extended to be more generally useful,
3001 there are better tools for file-scanning. This option exists to help
3002 administrators verify their Exim and AV scanner configuration.
3003
3004-bnq
3005
3006 By default, Exim automatically qualifies unqualified addresses (those
3007 without domains) that appear in messages that are submitted locally (that
3008 is, not over TCP/IP). This qualification applies both to addresses in
3009 envelopes, and addresses in header lines. Sender addresses are qualified
3010 using qualify_domain, and recipient addresses using qualify_recipient
3011 (which defaults to the value of qualify_domain).
3012
3013 Sometimes, qualification is not wanted. For example, if -bS (batch SMTP) is
3014 being used to re-submit messages that originally came from remote hosts
3015 after content scanning, you probably do not want to qualify unqualified
3016 addresses in header lines. (Such lines will be present only if you have not
3017 enabled a header syntax check in the appropriate ACL.)
3018
3019 The -bnq option suppresses all qualification of unqualified addresses in
3020 messages that originate on the local host. When this is used, unqualified
3021 addresses in the envelope provoke errors (causing message rejection) and
3022 unqualified addresses in header lines are left alone.
3023
3024-bP
3025
3026 If this option is given with no arguments, it causes the values of all
3027 Exim's main configuration options to be written to the standard output. The
3028 values of one or more specific options can be requested by giving their
3029 names as arguments, for example:
3030
3031 exim -bP qualify_domain hold_domains
3032
3033 However, any option setting that is preceded by the word "hide" in the
3034 configuration file is not shown in full, except to an admin user. For other
3035 users, the output is as in this example:
3036
3037 mysql_servers = <value not displayable>
3038
3039 If configure_file is given as an argument, the name of the run time
3040 configuration file is output. If a list of configuration files was
3041 supplied, the value that is output here is the name of the file that was
3042 actually used.
3043
3044 If the -n flag is given, then for most modes of -bP operation the name will
3045 not be output.
3046
3047 If log_file_path or pid_file_path are given, the names of the directories
3048 where log files and daemon pid files are written are output, respectively.
3049 If these values are unset, log files are written in a sub-directory of the
3050 spool directory called log, and the pid file is written directly into the
3051 spool directory.
3052
3053 If -bP is followed by a name preceded by "+", for example,
3054
3055 exim -bP +local_domains
3056
3057 it searches for a matching named list of any type (domain, host, address,
3058 or local part) and outputs what it finds.
3059
3060 If one of the words router, transport, or authenticator is given, followed
3061 by the name of an appropriate driver instance, the option settings for that
3062 driver are output. For example:
3063
3064 exim -bP transport local_delivery
3065
3066 The generic driver options are output first, followed by the driver's
3067 private options. A list of the names of drivers of a particular type can be
3068 obtained by using one of the words router_list, transport_list, or
3069 authenticator_list, and a complete list of all drivers with their option
3070 settings can be obtained by using routers, transports, or authenticators.
3071
188b6fee
CE
3072 If environment is given as an argument, the set of environment variables is
3073 output, line by line. Using the -n flag supresses the value of the
3074 variables.
3075
420a0d19
CE
3076 If invoked by an admin user, then macro, macro_list and macros are
3077 available, similarly to the drivers. Because macros are sometimes used for
3078 storing passwords, this option is restricted. The output format is one item
3079 per line.
3080
3081-bp
3082
3083 This option requests a listing of the contents of the mail queue on the
3084 standard output. If the -bp option is followed by a list of message ids,
3085 just those messages are listed. By default, this option can be used only by
3086 an admin user. However, the queue_list_requires_admin option can be set
3087 false to allow any user to see the queue.
3088
3089 Each message on the queue is displayed as in the following example:
3090
3091 25m 2.9K 0t5C6f-0000c8-00 <alice@wonderland.fict.example>
3092 red.king@looking-glass.fict.example
3093 <other addresses>
3094
3095 The first line contains the length of time the message has been on the
3096 queue (in this case 25 minutes), the size of the message (2.9K), the unique
3097 local identifier for the message, and the message sender, as contained in
3098 the envelope. For bounce messages, the sender address is empty, and appears
3099 as "<>". If the message was submitted locally by an untrusted user who
3100 overrode the default sender address, the user's login name is shown in
3101 parentheses before the sender address.
3102
3103 If the message is frozen (attempts to deliver it are suspended) then the
3104 text "*** frozen ***" is displayed at the end of this line.
3105
3106 The recipients of the message (taken from the envelope, not the headers)
3107 are displayed on subsequent lines. Those addresses to which the message has
3108 already been delivered are marked with the letter D. If an original address
3109 gets expanded into several addresses via an alias or forward file, the
3110 original is displayed with a D only when deliveries for all of its child
3111 addresses are complete.
3112
3113-bpa
3114
3115 This option operates like -bp, but in addition it shows delivered addresses
3116 that were generated from the original top level address(es) in each message
3117 by alias or forwarding operations. These addresses are flagged with "+D"
3118 instead of just "D".
3119
3120-bpc
3121
3122 This option counts the number of messages on the queue, and writes the
3123 total to the standard output. It is restricted to admin users, unless
3124 queue_list_requires_admin is set false.
3125
3126-bpr
3127
3128 This option operates like -bp, but the output is not sorted into
3129 chronological order of message arrival. This can speed it up when there are
3130 lots of messages on the queue, and is particularly useful if the output is
3131 going to be post-processed in a way that doesn't need the sorting.
3132
3133-bpra
3134
3135 This option is a combination of -bpr and -bpa.
3136
3137-bpru
3138
3139 This option is a combination of -bpr and -bpu.
3140
3141-bpu
3142
3143 This option operates like -bp but shows only undelivered top-level
3144 addresses for each message displayed. Addresses generated by aliasing or
3145 forwarding are not shown, unless the message was deferred after processing
3146 by a router with the one_time option set.
3147
3148-brt
3149
3150 This option is for testing retry rules, and it must be followed by up to
3151 three arguments. It causes Exim to look for a retry rule that matches the
3152 values and to write it to the standard output. For example:
3153
3154 exim -brt bach.comp.mus.example
3155 Retry rule: *.comp.mus.example F,2h,15m; F,4d,30m;
3156
3157 See chapter 32 for a description of Exim's retry rules. The first argument,
3158 which is required, can be a complete address in the form local_part@domain,
3159 or it can be just a domain name. If the second argument contains a dot, it
3160 is interpreted as an optional second domain name; if no retry rule is found
3161 for the first argument, the second is tried. This ties in with Exim's
3162 behaviour when looking for retry rules for remote hosts - if no rule is
3163 found that matches the host, one that matches the mail domain is sought.
3164 Finally, an argument that is the name of a specific delivery error, as used
3165 in setting up retry rules, can be given. For example:
3166
3167 exim -brt haydn.comp.mus.example quota_3d
3168 Retry rule: *@haydn.comp.mus.example quota_3d F,1h,15m
3169
3170-brw
3171
3172 This option is for testing address rewriting rules, and it must be followed
3173 by a single argument, consisting of either a local part without a domain,
3174 or a complete address with a fully qualified domain. Exim outputs how this
3175 address would be rewritten for each possible place it might appear. See
3176 chapter 31 for further details.
3177
3178-bS
3179
3180 This option is used for batched SMTP input, which is an alternative
3181 interface for non-interactive local message submission. A number of
3182 messages can be submitted in a single run. However, despite its name, this
3183 is not really SMTP input. Exim reads each message's envelope from SMTP
3184 commands on the standard input, but generates no responses. If the caller
3185 is trusted, or untrusted_set_sender is set, the senders in the SMTP MAIL
3186 commands are believed; otherwise the sender is always the caller of Exim.
3187
3188 The message itself is read from the standard input, in SMTP format (leading
3189 dots doubled), terminated by a line containing just a single dot. An error
3190 is provoked if the terminating dot is missing. A further message may then
3191 follow.
3192
3193 As for other local message submissions, the contents of incoming batch SMTP
3194 messages can be checked using the non-SMTP ACL (see chapter 42).
3195 Unqualified addresses are automatically qualified using qualify_domain and
3196 qualify_recipient, as appropriate, unless the -bnq option is used.
3197
3198 Some other SMTP commands are recognized in the input. HELO and EHLO act as
3199 RSET; VRFY, EXPN, ETRN, and HELP act as NOOP; QUIT quits, ignoring the rest
3200 of the standard input.
3201
3202 If any error is encountered, reports are written to the standard output and
3203 error streams, and Exim gives up immediately. The return code is 0 if no
3204 error was detected; it is 1 if one or more messages were accepted before
3205 the error was detected; otherwise it is 2.
3206
3207 More details of input using batched SMTP are given in section 47.11.
3208
3209-bs
3210
3211 This option causes Exim to accept one or more messages by reading SMTP
3212 commands on the standard input, and producing SMTP replies on the standard
3213 output. SMTP policy controls, as defined in ACLs (see chapter 42) are
3214 applied. Some user agents use this interface as a way of passing
3215 locally-generated messages to the MTA.
3216
3217 In this usage, if the caller of Exim is trusted, or untrusted_set_sender is
3218 set, the senders of messages are taken from the SMTP MAIL commands.
3219 Otherwise the content of these commands is ignored and the sender is set up
3220 as the calling user. Unqualified addresses are automatically qualified
3221 using qualify_domain and qualify_recipient, as appropriate, unless the -bnq
3222 option is used.
3223
3224 The -bs option is also used to run Exim from inetd, as an alternative to
3225 using a listening daemon. Exim can distinguish the two cases by checking
3226 whether the standard input is a TCP/IP socket. When Exim is called from
3227 inetd, the source of the mail is assumed to be remote, and the comments
3228 above concerning senders and qualification do not apply. In this situation,
3229 Exim behaves in exactly the same way as it does when receiving a message
3230 via the listening daemon.
3231
3232-bt
3233
3234 This option runs Exim in address testing mode, in which each argument is
3235 taken as a recipient address to be tested for deliverability. The results
3236 are written to the standard output. If a test fails, and the caller is not
3237 an admin user, no details of the failure are output, because these might
3238 contain sensitive information such as usernames and passwords for database
3239 lookups.
3240
3241 If no arguments are given, Exim runs in an interactive manner, prompting
3242 with a right angle bracket for addresses to be tested.
3243
3244 Unlike the -be test option, you cannot arrange for Exim to use the readline
3245 () function, because it is running as root and there are security issues.
3246
3247 Each address is handled as if it were the recipient address of a message
3248 (compare the -bv option). It is passed to the routers and the result is
3249 written to the standard output. However, any router that has
3250 no_address_test set is bypassed. This can make -bt easier to use for
3251 genuine routing tests if your first router passes everything to a scanner
3252 program.
3253
3254 The return code is 2 if any address failed outright; it is 1 if no address
3255 failed outright but at least one could not be resolved for some reason.
3256 Return code 0 is given only when all addresses succeed.
3257
3258 Note: When actually delivering a message, Exim removes duplicate recipient
3259 addresses after routing is complete, so that only one delivery takes place.
3260 This does not happen when testing with -bt; the full results of routing are
3261 always shown.
3262
3263 Warning: -bt can only do relatively simple testing. If any of the routers
3264 in the configuration makes any tests on the sender address of a message,
3265 you can use the -f option to set an appropriate sender when running -bt
3266 tests. Without it, the sender is assumed to be the calling user at the
3267 default qualifying domain. However, if you have set up (for example)
3268 routers whose behaviour depends on the contents of an incoming message, you
3269 cannot test those conditions using -bt. The -N option provides a possible
3270 way of doing such tests.
3271
3272-bV
3273
3274 This option causes Exim to write the current version number, compilation
3275 number, and compilation date of the exim binary to the standard output. It
3276 also lists the DBM library that is being used, the optional modules (such
3277 as specific lookup types), the drivers that are included in the binary, and
3278 the name of the run time configuration file that is in use.
3279
3280 As part of its operation, -bV causes Exim to read and syntax check its
3281 configuration file. However, this is a static check only. It cannot check
3282 values that are to be expanded. For example, although a misspelt ACL verb
3283 is detected, an error in the verb's arguments is not. You cannot rely on
3284 -bV alone to discover (for example) all the typos in the configuration;
3285 some realistic testing is needed. The -bh and -N options provide more
3286 dynamic testing facilities.
3287
3288-bv
3289
3290 This option runs Exim in address verification mode, in which each argument
3291 is taken as a recipient address to be verified by the routers. (This does
3292 not involve any verification callouts). During normal operation,
3293 verification happens mostly as a consequence processing a verify condition
3294 in an ACL (see chapter 42). If you want to test an entire ACL, possibly
3295 including callouts, see the -bh and -bhc options.
3296
3297 If verification fails, and the caller is not an admin user, no details of
3298 the failure are output, because these might contain sensitive information
3299 such as usernames and passwords for database lookups.
3300
3301 If no arguments are given, Exim runs in an interactive manner, prompting
3302 with a right angle bracket for addresses to be verified.
3303
3304 Unlike the -be test option, you cannot arrange for Exim to use the readline
3305 () function, because it is running as exim and there are security issues.
3306
3307 Verification differs from address testing (the -bt option) in that routers
3308 that have no_verify set are skipped, and if the address is accepted by a
3309 router that has fail_verify set, verification fails. The address is
3310 verified as a recipient if -bv is used; to test verification for a sender
3311 address, -bvs should be used.
3312
3313 If the -v option is not set, the output consists of a single line for each
3314 address, stating whether it was verified or not, and giving a reason in the
3315 latter case. Without -v, generating more than one address by redirection
3316 causes verification to end successfully, without considering the generated
3317 addresses. However, if just one address is generated, processing continues,
3318 and the generated address must verify successfully for the overall
3319 verification to succeed.
3320
3321 When -v is set, more details are given of how the address has been handled,
3322 and in the case of address redirection, all the generated addresses are
3323 also considered. Verification may succeed for some and fail for others.
3324
3325 The return code is 2 if any address failed outright; it is 1 if no address
3326 failed outright but at least one could not be resolved for some reason.
3327 Return code 0 is given only when all addresses succeed.
3328
3329 If any of the routers in the configuration makes any tests on the sender
3330 address of a message, you should use the -f option to set an appropriate
3331 sender when running -bv tests. Without it, the sender is assumed to be the
3332 calling user at the default qualifying domain.
3333
3334-bvs
3335
3336 This option acts like -bv, but verifies the address as a sender rather than
3337 a recipient address. This affects any rewriting and qualification that
3338 might happen.
3339
3340-bw
3341
3342 This option runs Exim as a daemon, awaiting incoming SMTP connections,
3343 similarly to the -bd option. All port specifications on the command-line
3344 and in the configuration file are ignored. Queue-running may not be
3345 specified.
3346
3347 In this mode, Exim expects to be passed a socket as fd 0 (stdin) which is
3348 listening for connections. This permits the system to start up and have
3349 inetd (or equivalent) listen on the SMTP ports, starting an Exim daemon for
3350 each port only when the first connection is received.
3351
3352 If the option is given as -bw<time> then the time is a timeout, after which
3353 the daemon will exit, which should cause inetd to listen once more.
3354
3355-C <filelist>
3356
3357 This option causes Exim to find the run time configuration file from the
3358 given list instead of from the list specified by the CONFIGURE_FILE
3359 compile-time setting. Usually, the list will consist of just a single file
3360 name, but it can be a colon-separated list of names. In this case, the
3361 first file that exists is used. Failure to open an existing file stops Exim
3362 from proceeding any further along the list, and an error is generated.
3363
188b6fee
CE
3364 The file names need to be absolute names.
3365
420a0d19
CE
3366 When this option is used by a caller other than root, and the list is
3367 different from the compiled-in list, Exim gives up its root privilege
3368 immediately, and runs with the real and effective uid and gid set to those
3369 of the caller. However, if a TRUSTED_CONFIG_LIST file is defined in Local/
3370 Makefile, that file contains a list of full pathnames, one per line, for
3371 configuration files which are trusted. Root privilege is retained for any
3372 configuration file so listed, as long as the caller is the Exim user (or
3373 the user specified in the CONFIGURE_OWNER option, if any), and as long as
3374 the configuration file is not writeable by inappropriate users or groups.
3375
3376 Leaving TRUSTED_CONFIG_LIST unset precludes the possibility of testing a
3377 configuration using -C right through message reception and delivery, even
3378 if the caller is root. The reception works, but by that time, Exim is
3379 running as the Exim user, so when it re-executes to regain privilege for
3380 the delivery, the use of -C causes privilege to be lost. However, root can
3381 test reception and delivery using two separate commands (one to put a
3382 message on the queue, using -odq, and another to do the delivery, using -M
3383 ).
3384
3385 If ALT_CONFIG_PREFIX is defined in Local/Makefile, it specifies a prefix
3386 string with which any file named in a -C command line option must start. In
3387 addition, the file name must not contain the sequence "/../". However, if
3388 the value of the -C option is identical to the value of CONFIGURE_FILE in
3389 Local/Makefile, Exim ignores -C and proceeds as usual. There is no default
3390 setting for ALT_CONFIG_PREFIX; when it is unset, any file name can be used
3391 with -C.
3392
3393 ALT_CONFIG_PREFIX can be used to confine alternative configuration files to
3394 a directory to which only root has access. This prevents someone who has
3395 broken into the Exim account from running a privileged Exim with an
3396 arbitrary configuration file.
3397
3398 The -C facility is useful for ensuring that configuration files are
3399 syntactically correct, but cannot be used for test deliveries, unless the
3400 caller is privileged, or unless it is an exotic configuration that does not
3401 require privilege. No check is made on the owner or group of the files
3402 specified by this option.
3403
3404-D<macro>=<value>
3405
3406 This option can be used to override macro definitions in the configuration
3407 file (see section 6.4). However, like -C, if it is used by an unprivileged
3408 caller, it causes Exim to give up its root privilege. If DISABLE_D_OPTION
3409 is defined in Local/Makefile, the use of -D is completely disabled, and its
3410 use causes an immediate error exit.
3411
3412 If WHITELIST_D_MACROS is defined in Local/Makefile then it should be a
3413 colon-separated list of macros which are considered safe and, if -D only
3414 supplies macros from this list, and the values are acceptable, then Exim
3415 will not give up root privilege if the caller is root, the Exim run-time
3416 user, or the CONFIGURE_OWNER, if set. This is a transition mechanism and is
3417 expected to be removed in the future. Acceptable values for the macros
3418 satisfy the regexp: "^[A-Za-z0-9_/.-]*$"
3419
3420 The entire option (including equals sign if present) must all be within one
3421 command line item. -D can be used to set the value of a macro to the empty
3422 string, in which case the equals sign is optional. These two commands are
3423 synonymous:
3424
3425 exim -DABC ...
3426 exim -DABC= ...
3427
3428 To include spaces in a macro definition item, quotes must be used. If you
3429 use quotes, spaces are permitted around the macro name and the equals sign.
3430 For example:
3431
3432 exim '-D ABC = something' ...
3433
3434 -D may be repeated up to 10 times on a command line.
3435
3436-d<debug options>
3437
3438 This option causes debugging information to be written to the standard
3439 error stream. It is restricted to admin users because debugging output may
3440 show database queries that contain password information. Also, the details
3441 of users' filter files should be protected. If a non-admin user uses -d,
3442 Exim writes an error message to the standard error stream and exits with a
3443 non-zero return code.
3444
3445 When -d is used, -v is assumed. If -d is given on its own, a lot of
3446 standard debugging data is output. This can be reduced, or increased to
3447 include some more rarely needed information, by directly following -d with
3448 a string made up of names preceded by plus or minus characters. These add
3449 or remove sets of debugging data, respectively. For example, -d+filter adds
3450 filter debugging, whereas -d-all+filter selects only filter debugging. Note
3451 that no spaces are allowed in the debug setting. The available debugging
3452 categories are:
3453
3454 acl ACL interpretation
3455 auth authenticators
3456 deliver general delivery logic
3457 dns DNS lookups (see also resolver)
3458 dnsbl DNS black list (aka RBL) code
3459 exec arguments for execv() calls
3460 expand detailed debugging for string expansions
3461 filter filter handling
3462 hints_lookup hints data lookups
3463 host_lookup all types of name-to-IP address handling
3464 ident ident lookup
3465 interface lists of local interfaces
3466 lists matching things in lists
3467 load system load checks
3468 local_scan can be used by local_scan() (see chapter 44)
3469 lookup general lookup code and all lookups
3470 memory memory handling
3471 pid add pid to debug output lines
3472 process_info setting info for the process log
3473 queue_run queue runs
3474 receive general message reception logic
3475 resolver turn on the DNS resolver's debugging output
3476 retry retry handling
3477 rewrite address rewriting
3478 route address routing
3479 timestamp add timestamp to debug output lines
3480 tls TLS logic
3481 transport transports
3482 uid changes of uid/gid and looking up uid/gid
3483 verify address verification logic
3484 all almost all of the above (see below), and also -v
3485
3486 The "all" option excludes "memory" when used as "+all", but includes it for
3487 "-all". The reason for this is that "+all" is something that people tend to
3488 use when generating debug output for Exim maintainers. If "+memory" is
3489 included, an awful lot of output that is very rarely of interest is
3490 generated, so it now has to be explicitly requested. However, "-all" does
3491 turn everything off.
3492
3493 The "resolver" option produces output only if the DNS resolver was compiled
3494 with DEBUG enabled. This is not the case in some operating systems. Also,
3495 unfortunately, debugging output from the DNS resolver is written to stdout
3496 rather than stderr.
3497
3498 The default (-d with no argument) omits "expand", "filter", "interface",
3499 "load", "memory", "pid", "resolver", and "timestamp". However, the "pid"
3500 selector is forced when debugging is turned on for a daemon, which then
3501 passes it on to any re-executed Exims. Exim also automatically adds the pid
3502 to debug lines when several remote deliveries are run in parallel.
3503
3504 The "timestamp" selector causes the current time to be inserted at the
3505 start of all debug output lines. This can be useful when trying to track
3506 down delays in processing.
3507
3508 If the debug_print option is set in any driver, it produces output whenever
3509 any debugging is selected, or if -v is used.
3510
3511-dd<debug options>
3512
3513 This option behaves exactly like -d except when used on a command that
3514 starts a daemon process. In that case, debugging is turned off for the
3515 subprocesses that the daemon creates. Thus, it is useful for monitoring the
3516 behaviour of the daemon without creating as much output as full debugging
3517 does.
3518
3519-dropcr
3520
3521 This is an obsolete option that is now a no-op. It used to affect the way
3522 Exim handled CR and LF characters in incoming messages. What happens now is
3523 described in section 46.2.
3524
3525-E
3526
3527 This option specifies that an incoming message is a locally-generated
3528 delivery failure report. It is used internally by Exim when handling
3529 delivery failures and is not intended for external use. Its only effect is
3530 to stop Exim generating certain messages to the postmaster, as otherwise
3531 message cascades could occur in some situations. As part of the same
3532 option, a message id may follow the characters -E. If it does, the log
3533 entry for the receipt of the new message contains the id, following "R=",
3534 as a cross-reference.
3535
3536-ex
3537
3538 There are a number of Sendmail options starting with -oe which seem to be
3539 called by various programs without the leading o in the option. For
3540 example, the vacation program uses -eq. Exim treats all options of the form
3541 -ex as synonymous with the corresponding -oex options.
3542
3543-F <string>
3544
3545 This option sets the sender's full name for use when a locally-generated
3546 message is being accepted. In the absence of this option, the user's gecos
3547 entry from the password data is used. As users are generally permitted to
3548 alter their gecos entries, no security considerations are involved. White
3549 space between -F and the <string> is optional.
3550
3551-f <address>
3552
3553 This option sets the address of the envelope sender of a locally-generated
3554 message (also known as the return path). The option can normally be used
3555 only by a trusted user, but untrusted_set_sender can be set to allow
3556 untrusted users to use it.
3557
3558 Processes running as root or the Exim user are always trusted. Other
3559 trusted users are defined by the trusted_users or trusted_groups options.
3560 In the absence of -f, or if the caller is not trusted, the sender of a
3561 local message is set to the caller's login name at the default qualify
3562 domain.
3563
3564 There is one exception to the restriction on the use of -f: an empty sender
3565 can be specified by any user, trusted or not, to create a message that can
3566 never provoke a bounce. An empty sender can be specified either as an empty
3567 string, or as a pair of angle brackets with nothing between them, as in
3568 these examples of shell commands:
3569
3570 exim -f '<>' user@domain
3571 exim -f "" user@domain
3572
3573 In addition, the use of -f is not restricted when testing a filter file
3574 with -bf or when testing or verifying addresses using the -bt or -bv
3575 options.
3576
3577 Allowing untrusted users to change the sender address does not of itself
3578 make it possible to send anonymous mail. Exim still checks that the From:
3579 header refers to the local user, and if it does not, it adds a Sender:
3580 header, though this can be overridden by setting no_local_from_check.
3581
3582 White space between -f and the <address> is optional (that is, they can be
3583 given as two arguments or one combined argument). The sender of a
3584 locally-generated message can also be set (when permitted) by an initial
3585 "From " line in the message - see the description of -bm above - but if -f
3586 is also present, it overrides "From ".
3587
3588-G
3589
3590 This option is equivalent to an ACL applying:
3591
3592 control = suppress_local_fixups
3593
3594 for every message received. Note that Sendmail will complain about such bad
3595 formatting, where Exim silently just does not fix it up. This may change in
3596 future.
3597
3598 As this affects audit information, the caller must be a trusted user to use
3599 this option.
3600
3601-h <number>
3602
3603 This option is accepted for compatibility with Sendmail, but has no effect.
3604 (In Sendmail it overrides the "hop count" obtained by counting Received:
3605 headers.)
3606
3607-i
3608
3609 This option, which has the same effect as -oi, specifies that a dot on a
3610 line by itself should not terminate an incoming, non-SMTP message. I can
3611 find no documentation for this option in Solaris 2.4 Sendmail, but the
3612 mailx command in Solaris 2.4 uses it. See also -ti.
3613
3614-L <tag>
3615
3616 This option is equivalent to setting syslog_processname in the config file
3617 and setting log_file_path to "syslog". Its use is restricted to
3618 administrators. The configuration file has to be read and parsed, to
3619 determine access rights, before this is set and takes effect, so early
3620 configuration file errors will not honour this flag.
3621
3622 The tag should not be longer than 32 characters.
3623
3624-M <message id> <message id> ...
3625
3626 This option requests Exim to run a delivery attempt on each message in
3627 turn. If any of the messages are frozen, they are automatically thawed
3628 before the delivery attempt. The settings of queue_domains,
3629 queue_smtp_domains, and hold_domains are ignored.
3630
3631 Retry hints for any of the addresses are overridden - Exim tries to deliver
3632 even if the normal retry time has not yet been reached. This option
3633 requires the caller to be an admin user. However, there is an option called
3634 prod_requires_admin which can be set false to relax this restriction (and
3635 also the same requirement for the -q, -R, and -S options).
3636
3637 The deliveries happen synchronously, that is, the original Exim process
3638 does not terminate until all the delivery attempts have finished. No output
3639 is produced unless there is a serious error. If you want to see what is
3640 happening, use the -v option as well, or inspect Exim's main log.
3641
3642-Mar <message id> <address> <address> ...
3643
3644 This option requests Exim to add the addresses to the list of recipients of
3645 the message ("ar" for "add recipients"). The first argument must be a
3646 message id, and the remaining ones must be email addresses. However, if the
3647 message is active (in the middle of a delivery attempt), it is not altered.
3648 This option can be used only by an admin user.
3649
3650-MC <transport> <hostname> <sequence number> <message id>
3651
3652 This option is not intended for use by external callers. It is used
3653 internally by Exim to invoke another instance of itself to deliver a
3654 waiting message using an existing SMTP connection, which is passed as the
3655 standard input. Details are given in chapter 47. This must be the final
3656 option, and the caller must be root or the Exim user in order to use it.
3657
3658-MCA
3659
3660 This option is not intended for use by external callers. It is used
3661 internally by Exim in conjunction with the -MC option. It signifies that
3662 the connection to the remote host has been authenticated.
3663
3664-MCP
3665
3666 This option is not intended for use by external callers. It is used
3667 internally by Exim in conjunction with the -MC option. It signifies that
3668 the server to which Exim is connected supports pipelining.
3669
3670-MCQ <process id> <pipe fd>
3671
3672 This option is not intended for use by external callers. It is used
3673 internally by Exim in conjunction with the -MC option when the original
3674 delivery was started by a queue runner. It passes on the process id of the
3675 queue runner, together with the file descriptor number of an open pipe.
3676 Closure of the pipe signals the final completion of the sequence of
3677 processes that are passing messages through the same SMTP connection.
3678
3679-MCS
3680
3681 This option is not intended for use by external callers. It is used
3682 internally by Exim in conjunction with the -MC option, and passes on the
3683 fact that the SMTP SIZE option should be used on messages delivered down
3684 the existing connection.
3685
3686-MCT
3687
3688 This option is not intended for use by external callers. It is used
3689 internally by Exim in conjunction with the -MC option, and passes on the
3690 fact that the host to which Exim is connected supports TLS encryption.
3691
3692-Mc <message id> <message id> ...
3693
3694 This option requests Exim to run a delivery attempt on each message in
3695 turn, but unlike the -M option, it does check for retry hints, and respects
3696 any that are found. This option is not very useful to external callers. It
3697 is provided mainly for internal use by Exim when it needs to re-invoke
3698 itself in order to regain root privilege for a delivery (see chapter 54).
3699 However, -Mc can be useful when testing, in order to run a delivery that
3700 respects retry times and other options such as hold_domains that are
3701 overridden when -M is used. Such a delivery does not count as a queue run.
3702 If you want to run a specific delivery as if in a queue run, you should use
3703 -q with a message id argument. A distinction between queue run deliveries
3704 and other deliveries is made in one or two places.
3705
3706-Mes <message id> <address>
3707
3708 This option requests Exim to change the sender address in the message to
3709 the given address, which must be a fully qualified address or "<>" ("es"
3710 for "edit sender"). There must be exactly two arguments. The first argument
3711 must be a message id, and the second one an email address. However, if the
3712 message is active (in the middle of a delivery attempt), its status is not
3713 altered. This option can be used only by an admin user.
3714
3715-Mf <message id> <message id> ...
3716
3717 This option requests Exim to mark each listed message as "frozen". This
3718 prevents any delivery attempts taking place until the message is "thawed",
3719 either manually or as a result of the auto_thaw configuration option.
3720 However, if any of the messages are active (in the middle of a delivery
3721 attempt), their status is not altered. This option can be used only by an
3722 admin user.
3723
3724-Mg <message id> <message id> ...
3725
3726 This option requests Exim to give up trying to deliver the listed messages,
3727 including any that are frozen. However, if any of the messages are active,
3728 their status is not altered. For non-bounce messages, a delivery error
3729 message is sent to the sender, containing the text "cancelled by
3730 administrator". Bounce messages are just discarded. This option can be used
3731 only by an admin user.
3732
3733-Mmad <message id> <message id> ...
3734
3735 This option requests Exim to mark all the recipient addresses in the
3736 messages as already delivered ("mad" for "mark all delivered"). However, if
3737 any message is active (in the middle of a delivery attempt), its status is
3738 not altered. This option can be used only by an admin user.
3739
3740-Mmd <message id> <address> <address> ...
3741
3742 This option requests Exim to mark the given addresses as already delivered
3743 ("md" for "mark delivered"). The first argument must be a message id, and
3744 the remaining ones must be email addresses. These are matched to recipient
3745 addresses in the message in a case-sensitive manner. If the message is
3746 active (in the middle of a delivery attempt), its status is not altered.
3747 This option can be used only by an admin user.
3748
3749-Mrm <message id> <message id> ...
3750
3751 This option requests Exim to remove the given messages from the queue. No
3752 bounce messages are sent; each message is simply forgotten. However, if any
3753 of the messages are active, their status is not altered. This option can be
3754 used only by an admin user or by the user who originally caused the message
3755 to be placed on the queue.
3756
3757-Mset <message id>
3758
3759 This option is useful only in conjunction with -be (that is, when testing
3760 string expansions). Exim loads the given message from its spool before
3761 doing the test expansions, thus setting message-specific variables such as
3762 $message_size and the header variables. The $recipients variable is made
3763 available. This feature is provided to make it easier to test expansions
3764 that make use of these variables. However, this option can be used only by
3765 an admin user. See also -bem.
3766
3767-Mt <message id> <message id> ...
3768
3769 This option requests Exim to "thaw" any of the listed messages that are
3770 "frozen", so that delivery attempts can resume. However, if any of the
3771 messages are active, their status is not altered. This option can be used
3772 only by an admin user.
3773
3774-Mvb <message id>
3775
3776 This option causes the contents of the message body (-D) spool file to be
3777 written to the standard output. This option can be used only by an admin
3778 user.
3779
3780-Mvc <message id>
3781
3782 This option causes a copy of the complete message (header lines plus body)
3783 to be written to the standard output in RFC 2822 format. This option can be
3784 used only by an admin user.
3785
3786-Mvh <message id>
3787
3788 This option causes the contents of the message headers (-H) spool file to
3789 be written to the standard output. This option can be used only by an admin
3790 user.
3791
3792-Mvl <message id>
3793
3794 This option causes the contents of the message log spool file to be written
3795 to the standard output. This option can be used only by an admin user.
3796
3797-m
3798
3799 This is apparently a synonym for -om that is accepted by Sendmail, so Exim
3800 treats it that way too.
3801
3802-N
3803
3804 This is a debugging option that inhibits delivery of a message at the
3805 transport level. It implies -v. Exim goes through many of the motions of
3806 delivery - it just doesn't actually transport the message, but instead
3807 behaves as if it had successfully done so. However, it does not make any
3808 updates to the retry database, and the log entries for deliveries are
3809 flagged with "*>" rather than "=>".
3810
3811 Because -N discards any message to which it applies, only root or the Exim
3812 user are allowed to use it with -bd, -q, -R or -M. In other words, an
3813 ordinary user can use it only when supplying an incoming message to which
3814 it will apply. Although transportation never fails when -N is set, an
3815 address may be deferred because of a configuration problem on a transport,
3816 or a routing problem. Once -N has been used for a delivery attempt, it
3817 sticks to the message, and applies to any subsequent delivery attempts that
3818 may happen for that message.
3819
3820-n
3821
3822 This option is interpreted by Sendmail to mean "no aliasing". For normal
3823 modes of operation, it is ignored by Exim. When combined with -bP it
3824 suppresses the name of an option from being output.
3825
3826-O <data>
3827
3828 This option is interpreted by Sendmail to mean "set option". It is ignored
3829 by Exim.
3830
3831-oA <file name>
3832
3833 This option is used by Sendmail in conjunction with -bi to specify an
3834 alternative alias file name. Exim handles -bi differently; see the
3835 description above.
3836
3837-oB <n>
3838
3839 This is a debugging option which limits the maximum number of messages that
3840 can be delivered down one SMTP connection, overriding the value set in any
3841 smtp transport. If <n> is omitted, the limit is set to 1.
3842
3843-odb
3844
3845 This option applies to all modes in which Exim accepts incoming messages,
3846 including the listening daemon. It requests "background" delivery of such
3847 messages, which means that the accepting process automatically starts a
3848 delivery process for each message received, but does not wait for the
3849 delivery processes to finish.
3850
3851 When all the messages have been received, the reception process exits,
3852 leaving the delivery processes to finish in their own time. The standard
3853 output and error streams are closed at the start of each delivery process.
3854 This is the default action if none of the -od options are present.
3855
3856 If one of the queueing options in the configuration file (queue_only or
3857 queue_only_file, for example) is in effect, -odb overrides it if
3858 queue_only_override is set true, which is the default setting. If
3859 queue_only_override is set false, -odb has no effect.
3860
3861-odf
3862
3863 This option requests "foreground" (synchronous) delivery when Exim has
3864 accepted a locally-generated message. (For the daemon it is exactly the
3865 same as -odb.) A delivery process is automatically started to deliver the
3866 message, and Exim waits for it to complete before proceeding.
3867
3868 The original Exim reception process does not finish until the delivery
3869 process for the final message has ended. The standard error stream is left
3870 open during deliveries.
3871
3872 However, like -odb, this option has no effect if queue_only_override is
3873 false and one of the queueing options in the configuration file is in
3874 effect.
3875
3876 If there is a temporary delivery error during foreground delivery, the
3877 message is left on the queue for later delivery, and the original reception
3878 process exits. See chapter 50 for a way of setting up a restricted
3879 configuration that never queues messages.
3880
3881-odi
3882
3883 This option is synonymous with -odf. It is provided for compatibility with
3884 Sendmail.
3885
3886-odq
3887
3888 This option applies to all modes in which Exim accepts incoming messages,
3889 including the listening daemon. It specifies that the accepting process
3890 should not automatically start a delivery process for each message
3891 received. Messages are placed on the queue, and remain there until a
3892 subsequent queue runner process encounters them. There are several
3893 configuration options (such as queue_only) that can be used to queue
3894 incoming messages under certain conditions. This option overrides all of
3895 them and also -odqs. It always forces queueing.
3896
3897-odqs
3898
3899 This option is a hybrid between -odb/-odi and -odq. However, like -odb and
3900 -odi, this option has no effect if queue_only_override is false and one of
3901 the queueing options in the configuration file is in effect.
3902
3903 When -odqs does operate, a delivery process is started for each incoming
3904 message, in the background by default, but in the foreground if -odi is
3905 also present. The recipient addresses are routed, and local deliveries are
3906 done in the normal way. However, if any SMTP deliveries are required, they
3907 are not done at this time, so the message remains on the queue until a
3908 subsequent queue runner process encounters it. Because routing was done,
3909 Exim knows which messages are waiting for which hosts, and so a number of
3910 messages for the same host can be sent in a single SMTP connection. The
3911 queue_smtp_domains configuration option has the same effect for specific
3912 domains. See also the -qq option.
3913
3914-oee
3915
3916 If an error is detected while a non-SMTP message is being received (for
3917 example, a malformed address), the error is reported to the sender in a
3918 mail message.
3919
3920 Provided this error message is successfully sent, the Exim receiving
3921 process exits with a return code of zero. If not, the return code is 2 if
3922 the problem is that the original message has no recipients, or 1 for any
3923 other error. This is the default -oex option if Exim is called as rmail.
3924
3925-oem
3926
3927 This is the same as -oee, except that Exim always exits with a non-zero
3928 return code, whether or not the error message was successfully sent. This
3929 is the default -oex option, unless Exim is called as rmail.
3930
3931-oep
3932
3933 If an error is detected while a non-SMTP message is being received, the
3934 error is reported by writing a message to the standard error file (stderr).
3935 The return code is 1 for all errors.
3936
3937-oeq
3938
3939 This option is supported for compatibility with Sendmail, but has the same
3940 effect as -oep.
3941
3942-oew
3943
3944 This option is supported for compatibility with Sendmail, but has the same
3945 effect as -oem.
3946
3947-oi
3948
3949 This option, which has the same effect as -i, specifies that a dot on a
3950 line by itself should not terminate an incoming, non-SMTP message.
3951 Otherwise, a single dot does terminate, though Exim does no special
3952 processing for other lines that start with a dot. This option is set by
3953 default if Exim is called as rmail. See also -ti.
3954
3955-oitrue
3956
3957 This option is treated as synonymous with -oi.
3958
3959-oMa <host address>
3960
3961 A number of options starting with -oM can be used to set values associated
3962 with remote hosts on locally-submitted messages (that is, messages not
3963 received over TCP/IP). These options can be used by any caller in
3964 conjunction with the -bh, -be, -bf, -bF, -bt, or -bv testing options. In
3965 other circumstances, they are ignored unless the caller is trusted.
3966
3967 The -oMa option sets the sender host address. This may include a port
3968 number at the end, after a full stop (period). For example:
3969
3970 exim -bs -oMa 10.9.8.7.1234
3971
3972 An alternative syntax is to enclose the IP address in square brackets,
3973 followed by a colon and the port number:
3974
3975 exim -bs -oMa [10.9.8.7]:1234
3976
3977 The IP address is placed in the $sender_host_address variable, and the
3978 port, if present, in $sender_host_port. If both -oMa and -bh are present on
3979 the command line, the sender host IP address is taken from whichever one is
3980 last.
3981
3982-oMaa <name>
3983
3984 See -oMa above for general remarks about the -oM options. The -oMaa option
3985 sets the value of $sender_host_authenticated (the authenticator name). See
3986 chapter 33 for a discussion of SMTP authentication. This option can be used
3987 with -bh and -bs to set up an authenticated SMTP session without actually
3988 using the SMTP AUTH command.
3989
3990-oMai <string>
3991
3992 See -oMa above for general remarks about the -oM options. The -oMai option
3993 sets the value of $authenticated_id (the id that was authenticated). This
3994 overrides the default value (the caller's login id, except with -bh, where
3995 there is no default) for messages from local sources. See chapter 33 for a
3996 discussion of authenticated ids.
3997
3998-oMas <address>
3999
4000 See -oMa above for general remarks about the -oM options. The -oMas option
4001 sets the authenticated sender value in $authenticated_sender. It overrides
4002 the sender address that is created from the caller's login id for messages
4003 from local sources, except when -bh is used, when there is no default. For
4004 both -bh and -bs, an authenticated sender that is specified on a MAIL
4005 command overrides this value. See chapter 33 for a discussion of
4006 authenticated senders.
4007
4008-oMi <interface address>
4009
4010 See -oMa above for general remarks about the -oM options. The -oMi option
4011 sets the IP interface address value. A port number may be included, using
4012 the same syntax as for -oMa. The interface address is placed in
4013 $received_ip_address and the port number, if present, in $received_port.
4014
4015-oMm <message reference>
4016
4017 See -oMa above for general remarks about the -oM options. The -oMm option
4018 sets the message reference, e.g. message-id, and is logged during delivery.
4019 This is useful when some kind of audit trail is required to tie messages
4020 together. The format of the message reference is checked and will abort if
4021 the format is invalid. The option will only be accepted if exim is running
4022 in trusted mode, not as any regular user.
4023
4024 The best example of a message reference is when Exim sends a bounce
4025 message. The message reference is the message-id of the original message
4026 for which Exim is sending the bounce.
4027
4028-oMr <protocol name>
4029
4030 See -oMa above for general remarks about the -oM options. The -oMr option
4031 sets the received protocol value that is stored in $received_protocol.
4032 However, it does not apply (and is ignored) when -bh or -bs is used. For
4033 -bh, the protocol is forced to one of the standard SMTP protocol names (see
4034 the description of $received_protocol in section 11.9). For -bs, the
4035 protocol is always "local-" followed by one of those same names. For -bS
4036 (batched SMTP) however, the protocol can be set by -oMr.
4037
4038-oMs <host name>
4039
4040 See -oMa above for general remarks about the -oM options. The -oMs option
4041 sets the sender host name in $sender_host_name. When this option is
4042 present, Exim does not attempt to look up a host name from an IP address;
4043 it uses the name it is given.
4044
4045-oMt <ident string>
4046
4047 See -oMa above for general remarks about the -oM options. The -oMt option
4048 sets the sender ident value in $sender_ident. The default setting for local
4049 callers is the login id of the calling process, except when -bh is used,
4050 when there is no default.
4051
4052-om
4053
4054 In Sendmail, this option means "me too", indicating that the sender of a
4055 message should receive a copy of the message if the sender appears in an
4056 alias expansion. Exim always does this, so the option does nothing.
4057
4058-oo
4059
4060 This option is ignored. In Sendmail it specifies "old style headers",
4061 whatever that means.
4062
4063-oP <path>
4064
4065 This option is useful only in conjunction with -bd or -q with a time value.
4066 The option specifies the file to which the process id of the daemon is
4067 written. When -oX is used with -bd, or when -q with a time is used without
4068 -bd, this is the only way of causing Exim to write a pid file, because in
4069 those cases, the normal pid file is not used.
4070
4071-or <time>
4072
4073 This option sets a timeout value for incoming non-SMTP messages. If it is
4074 not set, Exim will wait forever for the standard input. The value can also
4075 be set by the receive_timeout option. The format used for specifying times
4076 is described in section 6.15.
4077
4078-os <time>
4079
4080 This option sets a timeout value for incoming SMTP messages. The timeout
4081 applies to each SMTP command and block of data. The value can also be set
4082 by the smtp_receive_timeout option; it defaults to 5 minutes. The format
4083 used for specifying times is described in section 6.15.
4084
4085-ov
4086
4087 This option has exactly the same effect as -v.
4088
4089-oX <number or string>
4090
4091 This option is relevant only when the -bd (start listening daemon) option
4092 is also given. It controls which ports and interfaces the daemon uses.
4093 Details of the syntax, and how it interacts with configuration file
4094 options, are given in chapter 13. When -oX is used to start a daemon, no
4095 pid file is written unless -oP is also present to specify a pid file name.
4096
4097-pd
4098
4099 This option applies when an embedded Perl interpreter is linked with Exim
4100 (see chapter 12). It overrides the setting of the perl_at_start option,
4101 forcing the starting of the interpreter to be delayed until it is needed.
4102
4103-ps
4104
4105 This option applies when an embedded Perl interpreter is linked with Exim
4106 (see chapter 12). It overrides the setting of the perl_at_start option,
4107 forcing the starting of the interpreter to occur as soon as Exim is
4108 started.
4109
4110-p<rval>:<sval>
4111
4112 For compatibility with Sendmail, this option is equivalent to
4113
4114 -oMr <rval> -oMs <sval>
4115
4116 It sets the incoming protocol and host name (for trusted callers). The host
4117 name and its colon can be omitted when only the protocol is to be set. Note
4118 the Exim already has two private options, -pd and -ps, that refer to
4119 embedded Perl. It is therefore impossible to set a protocol value of "d" or
4120 "s" using this option (but that does not seem a real limitation).
4121
4122-q
4123
4124 This option is normally restricted to admin users. However, there is a
4125 configuration option called prod_requires_admin which can be set false to
4126 relax this restriction (and also the same requirement for the -M, -R, and
4127 -S options).
4128
4129 The -q option starts one queue runner process. This scans the queue of
4130 waiting messages, and runs a delivery process for each one in turn. It
4131 waits for each delivery process to finish before starting the next one. A
4132 delivery process may not actually do any deliveries if the retry times for
4133 the addresses have not been reached. Use -qf (see below) if you want to
4134 override this.
4135
4136 If the delivery process spawns other processes to deliver other messages
4137 down passed SMTP connections, the queue runner waits for these to finish
4138 before proceeding.
4139
4140 When all the queued messages have been considered, the original queue
4141 runner process terminates. In other words, a single pass is made over the
4142 waiting mail, one message at a time. Use -q with a time (see below) if you
4143 want this to be repeated periodically.
4144
4145 Exim processes the waiting messages in an unpredictable order. It isn't
4146 very random, but it is likely to be different each time, which is all that
4147 matters. If one particular message screws up a remote MTA, other messages
4148 to the same MTA have a chance of getting through if they get tried first.
4149
4150 It is possible to cause the messages to be processed in lexical message id
4151 order, which is essentially the order in which they arrived, by setting the
4152 queue_run_in_order option, but this is not recommended for normal use.
4153
4154-q<qflags>
4155
4156 The -q option may be followed by one or more flag letters that change its
4157 behaviour. They are all optional, but if more than one is present, they
4158 must appear in the correct order. Each flag is described in a separate item
4159 below.
4160
4161-qq...
4162
4163 An option starting with -qq requests a two-stage queue run. In the first
4164 stage, the queue is scanned as if the queue_smtp_domains option matched
4165 every domain. Addresses are routed, local deliveries happen, but no remote
4166 transports are run.
4167
4168 The hints database that remembers which messages are waiting for specific
4169 hosts is updated, as if delivery to those hosts had been deferred. After
4170 this is complete, a second, normal queue scan happens, with routing and
4171 delivery taking place as normal. Messages that are routed to the same host
4172 should mostly be delivered down a single SMTP connection because of the
4173 hints that were set up during the first queue scan. This option may be
4174 useful for hosts that are connected to the Internet intermittently.
4175
4176-q[q]i...
4177
4178 If the i flag is present, the queue runner runs delivery processes only for
4179 those messages that haven't previously been tried. (i stands for "initial
4180 delivery".) This can be helpful if you are putting messages on the queue
4181 using -odq and want a queue runner just to process the new messages.
4182
4183-q[q][i]f...
4184
4185 If one f flag is present, a delivery attempt is forced for each non-frozen
4186 message, whereas without f only those non-frozen addresses that have passed
4187 their retry times are tried.
4188
4189-q[q][i]ff...
4190
4191 If ff is present, a delivery attempt is forced for every message, whether
4192 frozen or not.
4193
4194-q[q][i][f[f]]l
4195
4196 The l (the letter "ell") flag specifies that only local deliveries are to
4197 be done. If a message requires any remote deliveries, it remains on the
4198 queue for later delivery.
4199
4200-q<qflags> <start id> <end id>
4201
4202 When scanning the queue, Exim can be made to skip over messages whose ids
4203 are lexically less than a given value by following the -q option with a
4204 starting message id. For example:
4205
4206 exim -q 0t5C6f-0000c8-00
4207
4208 Messages that arrived earlier than "0t5C6f-0000c8-00" are not inspected. If
4209 a second message id is given, messages whose ids are lexically greater than
4210 it are also skipped. If the same id is given twice, for example,
4211
4212 exim -q 0t5C6f-0000c8-00 0t5C6f-0000c8-00
4213
4214 just one delivery process is started, for that message. This differs from
4215 -M in that retry data is respected, and it also differs from -Mc in that it
4216 counts as a delivery from a queue run. Note that the selection mechanism
4217 does not affect the order in which the messages are scanned. There are also
4218 other ways of selecting specific sets of messages for delivery in a queue
4219 run - see -R and -S.
4220
4221-q<qflags><time>
4222
4223 When a time value is present, the -q option causes Exim to run as a daemon,
4224 starting a queue runner process at intervals specified by the given time
4225 value (whose format is described in section 6.15). This form of the -q
4226 option is commonly combined with the -bd option, in which case a single
4227 daemon process handles both functions. A common way of starting up a
4228 combined daemon at system boot time is to use a command such as
4229
4230 /usr/exim/bin/exim -bd -q30m
4231
4232 Such a daemon listens for incoming SMTP calls, and also starts a queue
4233 runner process every 30 minutes.
4234
4235 When a daemon is started by -q with a time value, but without -bd, no pid
4236 file is written unless one is explicitly requested by the -oP option.
4237
4238-qR<rsflags> <string>
4239
4240 This option is synonymous with -R. It is provided for Sendmail
4241 compatibility.
4242
4243-qS<rsflags> <string>
4244
4245 This option is synonymous with -S.
4246
4247-R<rsflags> <string>
4248
4249 The <rsflags> may be empty, in which case the white space before the string
4250 is optional, unless the string is f, ff, r, rf, or rff, which are the
4251 possible values for <rsflags>. White space is required if <rsflags> is not
4252 empty.
4253
4254 This option is similar to -q with no time value, that is, it causes Exim to
4255 perform a single queue run, except that, when scanning the messages on the
4256 queue, Exim processes only those that have at least one undelivered
4257 recipient address containing the given string, which is checked in a
4258 case-independent way. If the <rsflags> start with r, <string> is
4259 interpreted as a regular expression; otherwise it is a literal string.
4260
4261 If you want to do periodic queue runs for messages with specific
4262 recipients, you can combine -R with -q and a time value. For example:
4263
4264 exim -q25m -R @special.domain.example
4265
4266 This example does a queue run for messages with recipients in the given
4267 domain every 25 minutes. Any additional flags that are specified with -q
4268 are applied to each queue run.
4269
4270 Once a message is selected for delivery by this mechanism, all its
4271 addresses are processed. For the first selected message, Exim overrides any
4272 retry information and forces a delivery attempt for each undelivered
4273 address. This means that if delivery of any address in the first message is
4274 successful, any existing retry information is deleted, and so delivery
4275 attempts for that address in subsequently selected messages (which are
4276 processed without forcing) will run. However, if delivery of any address
4277 does not succeed, the retry information is updated, and in subsequently
4278 selected messages, the failing address will be skipped.
4279
4280 If the <rsflags> contain f or ff, the delivery forcing applies to all
4281 selected messages, not just the first; frozen messages are included when ff
4282 is present.
4283
4284 The -R option makes it straightforward to initiate delivery of all messages
4285 to a given domain after a host has been down for some time. When the SMTP
4286 command ETRN is accepted by its ACL (see chapter 42), its default effect is
4287 to run Exim with the -R option, but it can be configured to run an
4288 arbitrary command instead.
4289
4290-r
4291
4292 This is a documented (for Sendmail) obsolete alternative name for -f.
4293
4294-S<rsflags> <string>
4295
4296 This option acts like -R except that it checks the string against each
4297 message's sender instead of against the recipients. If -R is also set, both
4298 conditions must be met for a message to be selected. If either of the
4299 options has f or ff in its flags, the associated action is taken.
4300
4301-Tqt <times>
4302
4303 This is an option that is exclusively for use by the Exim testing suite. It
4304 is not recognized when Exim is run normally. It allows for the setting up
4305 of explicit "queue times" so that various warning/retry features can be
4306 tested.
4307
4308-t
4309
4310 When Exim is receiving a locally-generated, non-SMTP message on its
4311 standard input, the -t option causes the recipients of the message to be
4312 obtained from the To:, Cc:, and Bcc: header lines in the message instead of
4313 from the command arguments. The addresses are extracted before any
4314 rewriting takes place and the Bcc: header line, if present, is then
4315 removed.
4316
4317 If the command has any arguments, they specify addresses to which the
4318 message is not to be delivered. That is, the argument addresses are removed
4319 from the recipients list obtained from the headers. This is compatible with
4320 Smail 3 and in accordance with the documented behaviour of several versions
4321 of Sendmail, as described in man pages on a number of operating systems
4322 (e.g. Solaris 8, IRIX 6.5, HP-UX 11). However, some versions of Sendmail
4323 add argument addresses to those obtained from the headers, and the O'Reilly
4324 Sendmail book documents it that way. Exim can be made to add argument
4325 addresses instead of subtracting them by setting the option
4326 extract_addresses_remove_arguments false.
4327
4328 If there are any Resent- header lines in the message, Exim extracts
4329 recipients from all Resent-To:, Resent-Cc:, and Resent-Bcc: header lines
4330 instead of from To:, Cc:, and Bcc:. This is for compatibility with Sendmail
4331 and other MTAs. (Prior to release 4.20, Exim gave an error if -t was used
4332 in conjunction with Resent- header lines.)
4333
4334 RFC 2822 talks about different sets of Resent- header lines (for when a
4335 message is resent several times). The RFC also specifies that they should
4336 be added at the front of the message, and separated by Received: lines. It
4337 is not at all clear how -t should operate in the present of multiple sets,
4338 nor indeed exactly what constitutes a "set". In practice, it seems that
4339 MUAs do not follow the RFC. The Resent- lines are often added at the end of
4340 the header, and if a message is resent more than once, it is common for the
4341 original set of Resent- headers to be renamed as X-Resent- when a new set
4342 is added. This removes any possible ambiguity.
4343
4344-ti
4345
4346 This option is exactly equivalent to -t -i. It is provided for
4347 compatibility with Sendmail.
4348
4349-tls-on-connect
4350
4351 This option is available when Exim is compiled with TLS support. It forces
4352 all incoming SMTP connections to behave as if the incoming port is listed
4353 in the tls_on_connect_ports option. See section 13.4 and chapter 41 for
4354 further details.
4355
4356-U
4357
4358 Sendmail uses this option for "initial message submission", and its
4359 documentation states that in future releases, it may complain about
4360 syntactically invalid messages rather than fixing them when this flag is
4361 not set. Exim ignores this option.
4362
4363-v
4364
4365 This option causes Exim to write information to the standard error stream,
4366 describing what it is doing. In particular, it shows the log lines for
4367 receiving and delivering a message, and if an SMTP connection is made, the
4368 SMTP dialogue is shown. Some of the log lines shown may not actually be
4369 written to the log if the setting of log_selector discards them. Any
4370 relevant selectors are shown with each log line. If none are shown, the
4371 logging is unconditional.
4372
4373-x
4374
4375 AIX uses -x for a private purpose ("mail from a local mail program has
4376 National Language Support extended characters in the body of the mail
4377 item"). It sets -x when calling the MTA from its mail command. Exim ignores
4378 this option.
4379
4380-X <logfile>
4381
4382 This option is interpreted by Sendmail to cause debug information to be
4383 sent to the named file. It is ignored by Exim.
4384
4385
4386
4387===============================================================================
43886. THE EXIM RUN TIME CONFIGURATION FILE
4389
4390Exim uses a single run time configuration file that is read whenever an Exim
4391binary is executed. Note that in normal operation, this happens frequently,
4392because Exim is designed to operate in a distributed manner, without central
4393control.
4394
4395If a syntax error is detected while reading the configuration file, Exim writes
4396a message on the standard error, and exits with a non-zero return code. The
4397message is also written to the panic log. Note: Only simple syntax errors can
4398be detected at this time. The values of any expanded options are not checked
4399until the expansion happens, even when the expansion does not actually alter
4400the string.
4401
4402The name of the configuration file is compiled into the binary for security
4403reasons, and is specified by the CONFIGURE_FILE compilation option. In most
4404configurations, this specifies a single file. However, it is permitted to give
4405a colon-separated list of file names, in which case Exim uses the first
4406existing file in the list.
4407
4408The run time configuration file must be owned by root or by the user that is
4409specified at compile time by the CONFIGURE_OWNER option (if set). The
4410configuration file must not be world-writeable, or group-writeable unless its
4411group is the root group or the one specified at compile time by the
4412CONFIGURE_GROUP option.
4413
4414Warning: In a conventional configuration, where the Exim binary is setuid to
4415root, anybody who is able to edit the run time configuration file has an easy
4416way to run commands as root. If you specify a user or group in the
4417CONFIGURE_OWNER or CONFIGURE_GROUP options, then that user and/or any users who
4418are members of that group will trivially be able to obtain root privileges.
4419
4420Up to Exim version 4.72, the run time configuration file was also permitted to
4421be writeable by the Exim user and/or group. That has been changed in Exim 4.73
4422since it offered a simple privilege escalation for any attacker who managed to
4423compromise the Exim user account.
4424
4425A default configuration file, which will work correctly in simple situations,
4426is provided in the file src/configure.default. If CONFIGURE_FILE defines just
4427one file name, the installation process copies the default configuration to a
4428new file of that name if it did not previously exist. If CONFIGURE_FILE is a
4429list, no default is automatically installed. Chapter 7 is a "walk-through"
4430discussion of the default configuration.
4431
4432
44336.1 Using a different configuration file
4434----------------------------------------
4435
4436A one-off alternate configuration can be specified by the -C command line
4437option, which may specify a single file or a list of files. However, when -C is
4438used, Exim gives up its root privilege, unless called by root (or unless the
4439argument for -C is identical to the built-in value from CONFIGURE_FILE), or is
4440listed in the TRUSTED_CONFIG_LIST file and the caller is the Exim user or the
4441user specified in the CONFIGURE_OWNER setting. -C is useful mainly for checking
4442the syntax of configuration files before installing them. No owner or group
4443checks are done on a configuration file specified by -C, if root privilege has
4444been dropped.
4445
4446Even the Exim user is not trusted to specify an arbitrary configuration file
4447with the -C option to be used with root privileges, unless that file is listed
4448in the TRUSTED_CONFIG_LIST file. This locks out the possibility of testing a
4449configuration using -C right through message reception and delivery, even if
4450the caller is root. The reception works, but by that time, Exim is running as
4451the Exim user, so when it re-execs to regain privilege for the delivery, the
4452use of -C causes privilege to be lost. However, root can test reception and
4453delivery using two separate commands (one to put a message on the queue, using
4454-odq, and another to do the delivery, using -M).
4455
4456If ALT_CONFIG_PREFIX is defined in Local/Makefile, it specifies a prefix string
4457with which any file named in a -C command line option must start. In addition,
4458the file name must not contain the sequence "/../". There is no default setting
4459for ALT_CONFIG_PREFIX; when it is unset, any file name can be used with -C.
4460
4461One-off changes to a configuration can be specified by the -D command line
4462option, which defines and overrides values for macros used inside the
4463configuration file. However, like -C, the use of this option by a
4464non-privileged user causes Exim to discard its root privilege. If
4465DISABLE_D_OPTION is defined in Local/Makefile, the use of -D is completely
4466disabled, and its use causes an immediate error exit.
4467
4468The WHITELIST_D_MACROS option in Local/Makefile permits the binary builder to
4469declare certain macro names trusted, such that root privilege will not
4470necessarily be discarded. WHITELIST_D_MACROS defines a colon-separated list of
4471macros which are considered safe and, if -D only supplies macros from this
4472list, and the values are acceptable, then Exim will not give up root privilege
4473if the caller is root, the Exim run-time user, or the CONFIGURE_OWNER, if set.
4474This is a transition mechanism and is expected to be removed in the future.
4475Acceptable values for the macros satisfy the regexp: "^[A-Za-z0-9_/.-]*$"
4476
4477Some sites may wish to use the same Exim binary on different machines that
4478share a file system, but to use different configuration files on each machine.
4479If CONFIGURE_FILE_USE_NODE is defined in Local/Makefile, Exim first looks for a
4480file whose name is the configuration file name followed by a dot and the
4481machine's node name, as obtained from the uname() function. If this file does
4482not exist, the standard name is tried. This processing occurs for each file
4483name in the list given by CONFIGURE_FILE or -C.
4484
4485In some esoteric situations different versions of Exim may be run under
4486different effective uids and the CONFIGURE_FILE_USE_EUID is defined to help
4487with this. See the comments in src/EDITME for details.
4488
4489
44906.2 Configuration file format
4491-----------------------------
4492
4493Exim's configuration file is divided into a number of different parts. General
4494option settings must always appear at the start of the file. The other parts
4495are all optional, and may appear in any order. Each part other than the first
4496is introduced by the word "begin" followed by the name of the part. The
4497optional parts are:
4498
4499 * ACL: Access control lists for controlling incoming SMTP mail (see chapter
4500 42).
4501
4502 * authenticators: Configuration settings for the authenticator drivers. These
4503 are concerned with the SMTP AUTH command (see chapter 33).
4504
4505 * routers: Configuration settings for the router drivers. Routers process
4506 addresses and determine how the message is to be delivered (see chapters 15
4507 -22).
4508
4509 * transports: Configuration settings for the transport drivers. Transports
4510 define mechanisms for copying messages to destinations (see chapters 24-30
4511 ).
4512
4513 * retry: Retry rules, for use when a message cannot be delivered immediately.
4514 If there is no retry section, or if it is empty (that is, no retry rules
4515 are defined), Exim will not retry deliveries. In this situation, temporary
4516 errors are treated the same as permanent errors. Retry rules are discussed
4517 in chapter 32.
4518
4519 * rewrite: Global address rewriting rules, for use when a message arrives and
4520 when new addresses are generated during delivery. Rewriting is discussed in
4521 chapter 31.
4522
4523 * local_scan: Private options for the local_scan() function. If you want to
4524 use this feature, you must set
4525
4526 LOCAL_SCAN_HAS_OPTIONS=yes
4527
4528 in Local/Makefile before building Exim. Details of the local_scan()
4529 facility are given in chapter 44.
4530
4531Leading and trailing white space in configuration lines is always ignored.
4532
4533Blank lines in the file, and lines starting with a # character (ignoring
4534leading white space) are treated as comments and are ignored. Note: A #
4535character other than at the beginning of a line is not treated specially, and
4536does not introduce a comment.
4537
4538Any non-comment line can be continued by ending it with a backslash. Note that
4539the general rule for white space means that trailing white space after the
4540backslash and leading white space at the start of continuation lines is
4541ignored. Comment lines beginning with # (but not empty lines) may appear in the
4542middle of a sequence of continuation lines.
4543
4544A convenient way to create a configuration file is to start from the default,
4545which is supplied in src/configure.default, and add, delete, or change settings
4546as required.
4547
4548The ACLs, retry rules, and rewriting rules have their own syntax which is
4549described in chapters 42, 32, and 31, respectively. The other parts of the
4550configuration file have some syntactic items in common, and these are described
4551below, from section 6.10 onwards. Before that, the inclusion, macro, and
4552conditional facilities are described.
4553
4554
45556.3 File inclusions in the configuration file
4556---------------------------------------------
4557
4558You can include other files inside Exim's run time configuration file by using
4559this syntax:
4560
4561.include <file name>
4562.include_if_exists <file name>
4563
4564on a line by itself. Double quotes round the file name are optional. If you use
4565the first form, a configuration error occurs if the file does not exist; the
4566second form does nothing for non-existent files. In all cases, an absolute file
4567name is required.
4568
4569Includes may be nested to any depth, but remember that Exim reads its
4570configuration file often, so it is a good idea to keep them to a minimum. If
4571you change the contents of an included file, you must HUP the daemon, because
4572an included file is read only when the configuration itself is read.
4573
4574The processing of inclusions happens early, at a physical line level, so, like
4575comment lines, an inclusion can be used in the middle of an option setting, for
4576example:
4577
4578hosts_lookup = a.b.c \
4579 .include /some/file
4580
4581Include processing happens after macro processing (see below). Its effect is to
4582process the lines of the included file as if they occurred inline where the
4583inclusion appears.
4584
4585
45866.4 Macros in the configuration file
4587------------------------------------
4588
4589If a line in the main part of the configuration (that is, before the first
4590"begin" line) begins with an upper case letter, it is taken as a macro
4591definition, and must be of the form
4592
4593<name> = <rest of line>
4594
4595The name must consist of letters, digits, and underscores, and need not all be
4596in upper case, though that is recommended. The rest of the line, including any
4597continuations, is the replacement text, and has leading and trailing white
4598space removed. Quotes are not removed. The replacement text can never end with
4599a backslash character, but this doesn't seem to be a serious limitation.
4600
4601Macros may also be defined between router, transport, authenticator, or ACL
4602definitions. They may not, however, be defined within an individual driver or
4603ACL, or in the local_scan, retry, or rewrite sections of the configuration.
4604
4605
46066.5 Macro substitution
4607----------------------
4608
4609Once a macro is defined, all subsequent lines in the file (and any included
4610files) are scanned for the macro name; if there are several macros, the line is
4611scanned for each in turn, in the order in which the macros are defined. The
4612replacement text is not re-scanned for the current macro, though it is scanned
4613for subsequently defined macros. For this reason, a macro name may not contain
4614the name of a previously defined macro as a substring. You could, for example,
4615define
4616
4617ABCD_XYZ = <something>
4618ABCD = <something else>
4619
4620but putting the definitions in the opposite order would provoke a configuration
4621error. Macro expansion is applied to individual physical lines from the file,
4622before checking for line continuation or file inclusion (see above). If a line
4623consists solely of a macro name, and the expansion of the macro is empty, the
4624line is ignored. A macro at the start of a line may turn the line into a
4625comment line or a ".include" line.
4626
4627
46286.6 Redefining macros
4629---------------------
4630
4631Once defined, the value of a macro can be redefined later in the configuration
4632(or in an included file). Redefinition is specified by using == instead of =.
4633For example:
4634
4635MAC = initial value
4636...
4637MAC == updated value
4638
4639Redefinition does not alter the order in which the macros are applied to the
4640subsequent lines of the configuration file. It is still the same order in which
4641the macros were originally defined. All that changes is the macro's value.
4642Redefinition makes it possible to accumulate values. For example:
4643
4644MAC = initial value
4645...
4646MAC == MAC and something added
4647
4648This can be helpful in situations where the configuration file is built from a
4649number of other files.
4650
4651
46526.7 Overriding macro values
4653---------------------------
4654
4655The values set for macros in the configuration file can be overridden by the -D
4656command line option, but Exim gives up its root privilege when -D is used,
4657unless called by root or the Exim user. A definition on the command line using
4658the -D option causes all definitions and redefinitions within the file to be
4659ignored.
4660
4661
46626.8 Example of macro usage
4663--------------------------
4664
4665As an example of macro usage, consider a configuration where aliases are looked
4666up in a MySQL database. It helps to keep the file less cluttered if long
4667strings such as SQL statements are defined separately as macros, for example:
4668
4669ALIAS_QUERY = select mailbox from user where \
4670 login='${quote_mysql:$local_part}';
4671
4672This can then be used in a redirect router setting like this:
4673
4674data = ${lookup mysql{ALIAS_QUERY}}
4675
4676In earlier versions of Exim macros were sometimes used for domain, host, or
4677address lists. In Exim 4 these are handled better by named lists - see section
467810.5.
4679
4680
46816.9 Conditional skips in the configuration file
4682-----------------------------------------------
4683
4684You can use the directives ".ifdef", ".ifndef", ".elifdef", ".elifndef",
4685".else", and ".endif" to dynamically include or exclude portions of the
4686configuration file. The processing happens whenever the file is read (that is,
4687when an Exim binary starts to run).
4688
4689The implementation is very simple. Instances of the first four directives must
4690be followed by text that includes the names of one or macros. The condition
4691that is tested is whether or not any macro substitution has taken place in the
4692line. Thus:
4693
4694.ifdef AAA
4695message_size_limit = 50M
4696.else
4697message_size_limit = 100M
4698.endif
4699
4700sets a message size limit of 50M if the macro "AAA" is defined, and 100M
4701otherwise. If there is more than one macro named on the line, the condition is
4702true if any of them are defined. That is, it is an "or" condition. To obtain an
4703"and" condition, you need to use nested ".ifdef"s.
4704
4705Although you can use a macro expansion to generate one of these directives, it
4706is not very useful, because the condition "there was a macro substitution in
4707this line" will always be true.
4708
4709Text following ".else" and ".endif" is ignored, and can be used as comment to
4710clarify complicated nestings.
4711
4712
47136.10 Common option syntax
4714-------------------------
4715
4716For the main set of options, driver options, and local_scan() options, each
4717setting is on a line by itself, and starts with a name consisting of lower-case
4718letters and underscores. Many options require a data value, and in these cases
4719the name must be followed by an equals sign (with optional white space) and
4720then the value. For example:
4721
4722qualify_domain = mydomain.example.com
4723
4724Some option settings may contain sensitive data, for example, passwords for
4725accessing databases. To stop non-admin users from using the -bP command line
4726option to read these values, you can precede the option settings with the word
4727"hide". For example:
4728
4729hide mysql_servers = localhost/users/admin/secret-password
4730
4731For non-admin users, such options are displayed like this:
4732
4733mysql_servers = <value not displayable>
4734
4735If "hide" is used on a driver option, it hides the value of that option on all
4736instances of the same driver.
4737
4738The following sections describe the syntax used for the different data types
4739that are found in option settings.
4740
4741
47426.11 Boolean options
4743--------------------
4744
4745Options whose type is given as boolean are on/off switches. There are two
4746different ways of specifying such options: with and without a data value. If
4747the option name is specified on its own without data, the switch is turned on;
4748if it is preceded by "no_" or "not_" the switch is turned off. However, boolean
4749options may be followed by an equals sign and one of the words "true", "false",
4750"yes", or "no", as an alternative syntax. For example, the following two
4751settings have exactly the same effect:
4752
4753queue_only
4754queue_only = true
4755
4756The following two lines also have the same (opposite) effect:
4757
4758no_queue_only
4759queue_only = false
4760
4761You can use whichever syntax you prefer.
4762
4763
47646.12 Integer values
4765-------------------
4766
4767If an option's type is given as "integer", the value can be given in decimal,
4768hexadecimal, or octal. If it starts with a digit greater than zero, a decimal
4769number is assumed. Otherwise, it is treated as an octal number unless it starts
4770with the characters "0x", in which case the remainder is interpreted as a
4771hexadecimal number.
4772
4773If an integer value is followed by the letter K, it is multiplied by 1024; if
4774it is followed by the letter M, it is multiplied by 1024x1024. When the values
4775of integer option settings are output, values which are an exact multiple of
47761024 or 1024x1024 are sometimes, but not always, printed using the letters K
4777and M. The printing style is independent of the actual input format that was
4778used.
4779
4780
47816.13 Octal integer values
4782-------------------------
4783
4784If an option's type is given as "octal integer", its value is always
4785interpreted as an octal number, whether or not it starts with the digit zero.
4786Such options are always output in octal.
4787
4788
47896.14 Fixed point numbers
4790------------------------
4791
4792If an option's type is given as "fixed-point", its value must be a decimal
4793integer, optionally followed by a decimal point and up to three further digits.
4794
4795
47966.15 Time intervals
4797-------------------
4798
4799A time interval is specified as a sequence of numbers, each followed by one of
4800the following letters, with no intervening white space:
4801
4802 s seconds
4803 m minutes
4804 h hours
4805 d days
4806 w weeks
4807
4808For example, "3h50m" specifies 3 hours and 50 minutes. The values of time
4809intervals are output in the same format. Exim does not restrict the values; it
4810is perfectly acceptable, for example, to specify "90m" instead of "1h30m".
4811
4812
48136.16 String values
4814------------------
4815
4816If an option's type is specified as "string", the value can be specified with
4817or without double-quotes. If it does not start with a double-quote, the value
4818consists of the remainder of the line plus any continuation lines, starting at
4819the first character after any leading white space, with trailing white space
4820removed, and with no interpretation of the characters in the string. Because
4821Exim removes comment lines (those beginning with #) at an early stage, they can
4822appear in the middle of a multi-line string. The following two settings are
4823therefore equivalent:
4824
4825trusted_users = uucp:mail
4826trusted_users = uucp:\
4827 # This comment line is ignored
4828 mail
4829
4830If a string does start with a double-quote, it must end with a closing
4831double-quote, and any backslash characters other than those used for line
4832continuation are interpreted as escape characters, as follows:
4833
4834 "\\" single backslash
4835 "\n" newline
4836 "\r" carriage return
4837 "\t" tab
4838 "\"<octal digits> up to 3 octal digits specify one character
4839 "\x"<hex digits> up to 2 hexadecimal digits specify one character
4840
4841If a backslash is followed by some other character, including a double-quote
4842character, that character replaces the pair.
4843
4844Quoting is necessary only if you want to make use of the backslash escapes to
4845insert special characters, or if you need to specify a value with leading or
4846trailing spaces. These cases are rare, so quoting is almost never needed in
4847current versions of Exim. In versions of Exim before 3.14, quoting was required
4848in order to continue lines, so you may come across older configuration files
4849and examples that apparently quote unnecessarily.
4850
4851
48526.17 Expanded strings
4853---------------------
4854
4855Some strings in the configuration file are subjected to string expansion, by
4856which means various parts of the string may be changed according to the
4857circumstances (see chapter 11). The input syntax for such strings is as just
4858described; in particular, the handling of backslashes in quoted strings is done
4859as part of the input process, before expansion takes place. However, backslash
4860is also an escape character for the expander, so any backslashes that are
4861required for that reason must be doubled if they are within a quoted
4862configuration string.
4863
4864
48656.18 User and group names
4866-------------------------
4867
4868User and group names are specified as strings, using the syntax described
4869above, but the strings are interpreted specially. A user or group name must
4870either consist entirely of digits, or be a name that can be looked up using the
4871getpwnam() or getgrnam() function, as appropriate.
4872
4873
48746.19 List construction
4875----------------------
4876
4877The data for some configuration options is a list of items, with colon as the
4878default separator. Many of these options are shown with type "string list" in
4879the descriptions later in this document. Others are listed as "domain list",
4880"host list", "address list", or "local part list". Syntactically, they are all
4881the same; however, those other than "string list" are subject to particular
4882kinds of interpretation, as described in chapter 10.
4883
4884In all these cases, the entire list is treated as a single string as far as the
4885input syntax is concerned. The trusted_users setting in section 6.16 above is
4886an example. If a colon is actually needed in an item in a list, it must be
4887entered as two colons. Leading and trailing white space on each item in a list
4888is ignored. This makes it possible to include items that start with a colon,
4889and in particular, certain forms of IPv6 address. For example, the list
4890
4891local_interfaces = 127.0.0.1 : ::::1
4892
4893contains two IP addresses, the IPv4 address 127.0.0.1 and the IPv6 address ::1.
4894
4895Note: Although leading and trailing white space is ignored in individual list
4896items, it is not ignored when parsing the list. The space after the first colon
4897in the example above is necessary. If it were not there, the list would be
4898interpreted as the two items 127.0.0.1:: and 1.
4899
4900
49016.20 Changing list separators
4902-----------------------------
4903
4904Doubling colons in IPv6 addresses is an unwelcome chore, so a mechanism was
4905introduced to allow the separator character to be changed. If a list begins
4906with a left angle bracket, followed by any punctuation character, that
4907character is used instead of colon as the list separator. For example, the list
4908above can be rewritten to use a semicolon separator like this:
4909
4910local_interfaces = <; 127.0.0.1 ; ::1
4911
4912This facility applies to all lists, with the exception of the list in
4913log_file_path. It is recommended that the use of non-colon separators be
4914confined to circumstances where they really are needed.
4915
4916It is also possible to use newline and other control characters (those with
4917code values less than 32, plus DEL) as separators in lists. Such separators
4918must be provided literally at the time the list is processed. For options that
4919are string-expanded, you can write the separator using a normal escape
4920sequence. This will be processed by the expander before the string is
4921interpreted as a list. For example, if a newline-separated list of domains is
4922generated by a lookup, you can process it directly by a line such as this:
4923
4924domains = <\n ${lookup mysql{.....}}
4925
4926This avoids having to change the list separator in such data. You are unlikely
4927to want to use a control character as a separator in an option that is not
4928expanded, because the value is literal text. However, it can be done by giving
4929the value in quotes. For example:
4930
4931local_interfaces = "<\n 127.0.0.1 \n ::1"
4932
4933Unlike printing character separators, which can be included in list items by
4934doubling, it is not possible to include a control character as data when it is
4935set as the separator. Two such characters in succession are interpreted as
4936enclosing an empty list item.
4937
4938
49396.21 Empty items in lists
4940-------------------------
4941
4942An empty item at the end of a list is always ignored. In other words, trailing
4943separator characters are ignored. Thus, the list in
4944
4945senders = user@domain :
4946
4947contains only a single item. If you want to include an empty string as one item
4948in a list, it must not be the last item. For example, this list contains three
4949items, the second of which is empty:
4950
4951senders = user1@domain : : user2@domain
4952
4953Note: There must be white space between the two colons, as otherwise they are
4954interpreted as representing a single colon data character (and the list would
4955then contain just one item). If you want to specify a list that contains just
4956one, empty item, you can do it as in this example:
4957
4958senders = :
4959
4960In this case, the first item is empty, and the second is discarded because it
4961is at the end of the list.
4962
4963
49646.22 Format of driver configurations
4965------------------------------------
4966
4967There are separate parts in the configuration for defining routers, transports,
4968and authenticators. In each part, you are defining a number of driver
4969instances, each with its own set of options. Each driver instance is defined by
4970a sequence of lines like this:
4971
4972<instance name>:
4973 <option>
4974 ...
4975 <option>
4976
4977In the following example, the instance name is localuser, and it is followed by
4978three options settings:
4979
4980localuser:
4981 driver = accept
4982 check_local_user
4983 transport = local_delivery
4984
4985For each driver instance, you specify which Exim code module it uses - by the
4986setting of the driver option - and (optionally) some configuration settings.
4987For example, in the case of transports, if you want a transport to deliver with
4988SMTP you would use the smtp driver; if you want to deliver to a local file you
4989would use the appendfile driver. Each of the drivers is described in detail in
4990its own separate chapter later in this manual.
4991
4992You can have several routers, transports, or authenticators that are based on
4993the same underlying driver (each must have a different instance name).
4994
4995The order in which routers are defined is important, because addresses are
4996passed to individual routers one by one, in order. The order in which
4997transports are defined does not matter at all. The order in which
4998authenticators are defined is used only when Exim, as a client, is searching
4999them to find one that matches an authentication mechanism offered by the
5000server.
5001
5002Within a driver instance definition, there are two kinds of option: generic and
5003private. The generic options are those that apply to all drivers of the same
5004type (that is, all routers, all transports or all authenticators). The driver
5005option is a generic option that must appear in every definition. The private
5006options are special for each driver, and none need appear, because they all
5007have default values.
5008
5009The options may appear in any order, except that the driver option must precede
5010any private options, since these depend on the particular driver. For this
5011reason, it is recommended that driver always be the first option.
5012
5013Driver instance names, which are used for reference in log entries and
5014elsewhere, can be any sequence of letters, digits, and underscores (starting
5015with a letter) and must be unique among drivers of the same type. A router and
5016a transport (for example) can each have the same name, but no two router
5017instances can have the same name. The name of a driver instance should not be
5018confused with the name of the underlying driver module. For example, the
5019configuration lines:
5020
5021remote_smtp:
5022 driver = smtp
5023
5024create an instance of the smtp transport driver whose name is remote_smtp. The
5025same driver code can be used more than once, with different instance names and
5026different option settings each time. A second instance of the smtp transport,
5027with different options, might be defined thus:
5028
5029special_smtp:
5030 driver = smtp
5031 port = 1234
5032 command_timeout = 10s
5033
5034The names remote_smtp and special_smtp would be used to reference these
5035transport instances from routers, and these names would appear in log lines.
5036
5037Comment lines may be present in the middle of driver specifications. The full
5038list of option settings for any particular driver instance, including all the
5039defaulted values, can be extracted by making use of the -bP command line
5040option.
5041
5042
5043
5044===============================================================================
50457. THE DEFAULT CONFIGURATION FILE
5046
5047The default configuration file supplied with Exim as src/configure.default is
5048sufficient for a host with simple mail requirements. As an introduction to the
5049way Exim is configured, this chapter "walks through" the default configuration,
5050giving brief explanations of the settings. Detailed descriptions of the options
5051are given in subsequent chapters. The default configuration file itself
5052contains extensive comments about ways you might want to modify the initial
5053settings. However, note that there are many options that are not mentioned at
5054all in the default configuration.
5055
5056
50577.1 Main configuration settings
5058-------------------------------
5059
5060The main (global) configuration option settings must always come first in the
5061file. The first thing you'll see in the file, after some initial comments, is
5062the line
5063
5064# primary_hostname =
5065
5066This is a commented-out setting of the primary_hostname option. Exim needs to
5067know the official, fully qualified name of your host, and this is where you can
5068specify it. However, in most cases you do not need to set this option. When it
5069is unset, Exim uses the uname() system function to obtain the host name.
5070
5071The first three non-comment configuration lines are as follows:
5072
5073domainlist local_domains = @
5074domainlist relay_to_domains =
5075hostlist relay_from_hosts = 127.0.0.1
5076
5077These are not, in fact, option settings. They are definitions of two named
5078domain lists and one named host list. Exim allows you to give names to lists of
5079domains, hosts, and email addresses, in order to make it easier to manage the
5080configuration file (see section 10.5).
5081
5082The first line defines a domain list called local_domains; this is used later
5083in the configuration to identify domains that are to be delivered on the local
5084host.
5085
5086There is just one item in this list, the string "@". This is a special form of
5087entry which means "the name of the local host". Thus, if the local host is
5088called a.host.example, mail to any.user@a.host.example is expected to be
5089delivered locally. Because the local host's name is referenced indirectly, the
5090same configuration file can be used on different hosts.
5091
5092The second line defines a domain list called relay_to_domains, but the list
5093itself is empty. Later in the configuration we will come to the part that
5094controls mail relaying through the local host; it allows relaying to any
5095domains in this list. By default, therefore, no relaying on the basis of a mail
5096domain is permitted.
5097
5098The third line defines a host list called relay_from_hosts. This list is used
5099later in the configuration to permit relaying from any host or IP address that
5100matches the list. The default contains just the IP address of the IPv4 loopback
5101interface, which means that processes on the local host are able to submit mail
5102for relaying by sending it over TCP/IP to that interface. No other hosts are
5103permitted to submit messages for relaying.
5104
5105Just to be sure there's no misunderstanding: at this point in the configuration
5106we aren't actually setting up any controls. We are just defining some domains
5107and hosts that will be used in the controls that are specified later.
5108
5109The next two configuration lines are genuine option settings:
5110
5111acl_smtp_rcpt = acl_check_rcpt
5112acl_smtp_data = acl_check_data
5113
5114These options specify Access Control Lists (ACLs) that are to be used during an
5115incoming SMTP session for every recipient of a message (every RCPT command),
5116and after the contents of the message have been received, respectively. The
5117names of the lists are acl_check_rcpt and acl_check_data, and we will come to
5118their definitions below, in the ACL section of the configuration. The RCPT ACL
5119controls which recipients are accepted for an incoming message - if a
5120configuration does not provide an ACL to check recipients, no SMTP mail can be
5121accepted. The DATA ACL allows the contents of a message to be checked.
5122
5123Two commented-out option settings are next:
5124
5125# av_scanner = clamd:/tmp/clamd
5126# spamd_address = 127.0.0.1 783
5127
5128These are example settings that can be used when Exim is compiled with the
5129content-scanning extension. The first specifies the interface to the virus
5130scanner, and the second specifies the interface to SpamAssassin. Further
5131details are given in chapter 43.
5132
5133Three more commented-out option settings follow:
5134
5135# tls_advertise_hosts = *
5136# tls_certificate = /etc/ssl/exim.crt
5137# tls_privatekey = /etc/ssl/exim.pem
5138
5139These are example settings that can be used when Exim is compiled with support
5140for TLS (aka SSL) as described in section 4.7. The first one specifies the list
5141of clients that are allowed to use TLS when connecting to this server; in this
5142case the wildcard means all clients. The other options specify where Exim
5143should find its TLS certificate and private key, which together prove the
5144server's identity to any clients that connect. More details are given in
5145chapter 41.
5146
5147Another two commented-out option settings follow:
5148
5149# daemon_smtp_ports = 25 : 465 : 587
5150# tls_on_connect_ports = 465
5151
5152These options provide better support for roaming users who wish to use this
5153server for message submission. They are not much use unless you have turned on
5154TLS (as described in the previous paragraph) and authentication (about which
5155more in section 7.7). The usual SMTP port 25 is often blocked on end-user
5156networks, so RFC 4409 specifies that message submission should use port 587
5157instead. However some software (notably Microsoft Outlook) cannot be configured
5158to use port 587 correctly, so these settings also enable the non-standard
5159"smtps" (aka "ssmtp") port 465 (see section 13.4).
5160
5161Two more commented-out options settings follow:
5162
5163# qualify_domain =
5164# qualify_recipient =
5165
5166The first of these specifies a domain that Exim uses when it constructs a
5167complete email address from a local login name. This is often needed when Exim
5168receives a message from a local process. If you do not set qualify_domain, the
5169value of primary_hostname is used. If you set both of these options, you can
5170have different qualification domains for sender and recipient addresses. If you
5171set only the first one, its value is used in both cases.
5172
5173The following line must be uncommented if you want Exim to recognize addresses
5174of the form user@[10.11.12.13] that is, with a "domain literal" (an IP address
5175within square brackets) instead of a named domain.
5176
5177# allow_domain_literals
5178
5179The RFCs still require this form, but many people think that in the modern
5180Internet it makes little sense to permit mail to be sent to specific hosts by
5181quoting their IP addresses. This ancient format has been used by people who try
5182to abuse hosts by using them for unwanted relaying. However, some people
5183believe there are circumstances (for example, messages addressed to postmaster)
5184where domain literals are still useful.
5185
5186The next configuration line is a kind of trigger guard:
5187
5188never_users = root
5189
5190It specifies that no delivery must ever be run as the root user. The normal
5191convention is to set up root as an alias for the system administrator. This
5192setting is a guard against slips in the configuration. The list of users
5193specified by never_users is not, however, the complete list; the build-time
5194configuration in Local/Makefile has an option called FIXED_NEVER_USERS
5195specifying a list that cannot be overridden. The contents of never_users are
5196added to this list. By default FIXED_NEVER_USERS also specifies root.
5197
5198When a remote host connects to Exim in order to send mail, the only information
5199Exim has about the host's identity is its IP address. The next configuration
5200line,
5201
5202host_lookup = *
5203
5204specifies that Exim should do a reverse DNS lookup on all incoming connections,
5205in order to get a host name. This improves the quality of the logging
5206information, but if you feel it is too expensive, you can remove it entirely,
5207or restrict the lookup to hosts on "nearby" networks. Note that it is not
5208always possible to find a host name from an IP address, because not all DNS
5209reverse zones are maintained, and sometimes DNS servers are unreachable.
5210
5211The next two lines are concerned with ident callbacks, as defined by RFC 1413
5212(hence their names):
5213
5214rfc1413_hosts = *
5215rfc1413_query_timeout = 0s
5216
5217These settings cause Exim to avoid ident callbacks for all incoming SMTP calls.
5218Few hosts offer RFC1413 service these days; calls have to be terminated by a
5219timeout and this needlessly delays the startup of an incoming SMTP connection.
5220If you have hosts for which you trust RFC1413 and need this information, you
5221can change this.
5222
5223This line enables an efficiency SMTP option. It is negociated by clients and
5224not expected to cause problems but can be disabled if needed.
5225
5226prdr_enable = true
5227
5228When Exim receives messages over SMTP connections, it expects all addresses to
5229be fully qualified with a domain, as required by the SMTP definition. However,
5230if you are running a server to which simple clients submit messages, you may
5231find that they send unqualified addresses. The two commented-out options:
5232
5233# sender_unqualified_hosts =
5234# recipient_unqualified_hosts =
5235
5236show how you can specify hosts that are permitted to send unqualified sender
5237and recipient addresses, respectively.
5238
5239The percent_hack_domains option is also commented out:
5240
5241# percent_hack_domains =
5242
5243It provides a list of domains for which the "percent hack" is to operate. This
5244is an almost obsolete form of explicit email routing. If you do not know
5245anything about it, you can safely ignore this topic.
5246
5247The last two settings in the main part of the default configuration are
5248concerned with messages that have been "frozen" on Exim's queue. When a message
5249is frozen, Exim no longer continues to try to deliver it. Freezing occurs when
5250a bounce message encounters a permanent failure because the sender address of
5251the original message that caused the bounce is invalid, so the bounce cannot be
5252delivered. This is probably the most common case, but there are also other
5253conditions that cause freezing, and frozen messages are not always bounce
5254messages.
5255
5256ignore_bounce_errors_after = 2d
5257timeout_frozen_after = 7d
5258
5259The first of these options specifies that failing bounce messages are to be
5260discarded after 2 days on the queue. The second specifies that any frozen
5261message (whether a bounce message or not) is to be timed out (and discarded)
5262after a week. In this configuration, the first setting ensures that no failing
5263bounce message ever lasts a week.
5264
5265
52667.2 ACL configuration
5267---------------------
5268
5269In the default configuration, the ACL section follows the main configuration.
5270It starts with the line
5271
5272begin acl
5273
5274and it contains the definitions of two ACLs, called acl_check_rcpt and
5275acl_check_data, that were referenced in the settings of acl_smtp_rcpt and
5276acl_smtp_data above.
5277
5278The first ACL is used for every RCPT command in an incoming SMTP message. Each
5279RCPT command specifies one of the message's recipients. The ACL statements are
5280considered in order, until the recipient address is either accepted or
5281rejected. The RCPT command is then accepted or rejected, according to the
5282result of the ACL processing.
5283
5284acl_check_rcpt:
5285
5286This line, consisting of a name terminated by a colon, marks the start of the
5287ACL, and names it.
5288
5289accept hosts = :
5290
5291This ACL statement accepts the recipient if the sending host matches the list.
5292But what does that strange list mean? It doesn't actually contain any host
5293names or IP addresses. The presence of the colon puts an empty item in the
5294list; Exim matches this only if the incoming message did not come from a remote
5295host, because in that case, the remote hostname is empty. The colon is
5296important. Without it, the list itself is empty, and can never match anything.
5297
5298What this statement is doing is to accept unconditionally all recipients in
5299messages that are submitted by SMTP from local processes using the standard
5300input and output (that is, not using TCP/IP). A number of MUAs operate in this
5301manner.
5302
5303deny message = Restricted characters in address
5304 domains = +local_domains
5305 local_parts = ^[.] : ^.*[@%!/|]
5306
5307deny message = Restricted characters in address
5308 domains = !+local_domains
5309 local_parts = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
5310
5311These statements are concerned with local parts that contain any of the
5312characters "@", "%", "!", "/", "|", or dots in unusual places. Although these
5313characters are entirely legal in local parts (in the case of "@" and leading
5314dots, only if correctly quoted), they do not commonly occur in Internet mail
5315addresses.
5316
5317The first three have in the past been associated with explicitly routed
5318addresses (percent is still sometimes used - see the percent_hack_domains
5319option). Addresses containing these characters are regularly tried by spammers
5320in an attempt to bypass relaying restrictions, and also by open relay testing
5321programs. Unless you really need them it is safest to reject these characters
5322at this early stage. This configuration is heavy-handed in rejecting these
5323characters for all messages it accepts from remote hosts. This is a deliberate
5324policy of being as safe as possible.
5325
5326The first rule above is stricter, and is applied to messages that are addressed
5327to one of the local domains handled by this host. This is implemented by the
5328first condition, which restricts it to domains that are listed in the
5329local_domains domain list. The "+" character is used to indicate a reference to
5330a named list. In this configuration, there is just one domain in local_domains,
5331but in general there may be many.
5332
5333The second condition on the first statement uses two regular expressions to
5334block local parts that begin with a dot or contain "@", "%", "!", "/", or "|".
5335If you have local accounts that include these characters, you will have to
5336modify this rule.
5337
5338Empty components (two dots in a row) are not valid in RFC 2822, but Exim allows
5339them because they have been encountered in practice. (Consider the common
5340convention of local parts constructed as "
5341first-initial.second-initial.family-name" when applied to someone like the
5342author of Exim, who has no second initial.) However, a local part starting with
5343a dot or containing "/../" can cause trouble if it is used as part of a file
5344name (for example, for a mailing list). This is also true for local parts that
5345contain slashes. A pipe symbol can also be troublesome if the local part is
5346incorporated unthinkingly into a shell command line.
5347
5348The second rule above applies to all other domains, and is less strict. This
5349allows your own users to send outgoing messages to sites that use slashes and
5350vertical bars in their local parts. It blocks local parts that begin with a
5351dot, slash, or vertical bar, but allows these characters within the local part.
5352However, the sequence "/../" is barred. The use of "@", "%", and "!" is
5353blocked, as before. The motivation here is to prevent your users (or your
5354users' viruses) from mounting certain kinds of attack on remote sites.
5355
5356accept local_parts = postmaster
5357 domains = +local_domains
5358
5359This statement, which has two conditions, accepts an incoming address if the
5360local part is postmaster and the domain is one of those listed in the
5361local_domains domain list. The "+" character is used to indicate a reference to
5362a named list. In this configuration, there is just one domain in local_domains,
5363but in general there may be many.
5364
5365The presence of this statement means that mail to postmaster is never blocked
5366by any of the subsequent tests. This can be helpful while sorting out problems
5367in cases where the subsequent tests are incorrectly denying access.
5368
5369require verify = sender
5370
5371This statement requires the sender address to be verified before any subsequent
5372ACL statement can be used. If verification fails, the incoming recipient
5373address is refused. Verification consists of trying to route the address, to
5374see if a bounce message could be delivered to it. In the case of remote
5375addresses, basic verification checks only the domain, but callouts can be used
5376for more verification if required. Section 42.44 discusses the details of
5377address verification.
5378
5379accept hosts = +relay_from_hosts
5380 control = submission
5381
5382This statement accepts the address if the message is coming from one of the
5383hosts that are defined as being allowed to relay through this host. Recipient
5384verification is omitted here, because in many cases the clients are dumb MUAs
5385that do not cope well with SMTP error responses. For the same reason, the
5386second line specifies "submission mode" for messages that are accepted. This is
5387described in detail in section 46.1; it causes Exim to fix messages that are
5388deficient in some way, for example, because they lack a Date: header line. If
5389you are actually relaying out from MTAs, you should probably add recipient
5390verification here, and disable submission mode.
5391
5392accept authenticated = *
5393 control = submission
5394
5395This statement accepts the address if the client host has authenticated itself.
5396Submission mode is again specified, on the grounds that such messages are most
5397likely to come from MUAs. The default configuration does not define any
5398authenticators, though it does include some nearly complete commented-out
5399examples described in 7.7. This means that no client can in fact authenticate
5400until you complete the authenticator definitions.
5401
5402require message = relay not permitted
5403 domains = +local_domains : +relay_to_domains
5404
5405This statement rejects the address if its domain is neither a local domain nor
5406one of the domains for which this host is a relay.
5407
5408require verify = recipient
5409
5410This statement requires the recipient address to be verified; if verification
5411fails, the address is rejected.
5412
5413# deny message = rejected because $sender_host_address \
5414# is in a black list at $dnslist_domain\n\
5415# $dnslist_text
5416# dnslists = black.list.example
5417#
5418# warn dnslists = black.list.example
5419# add_header = X-Warning: $sender_host_address is in \
5420# a black list at $dnslist_domain
5421# log_message = found in $dnslist_domain
5422
5423These commented-out lines are examples of how you could configure Exim to check
5424sending hosts against a DNS black list. The first statement rejects messages
5425from blacklisted hosts, whereas the second just inserts a warning header line.
5426
5427# require verify = csa
5428
5429This commented-out line is an example of how you could turn on client SMTP
5430authorization (CSA) checking. Such checks do DNS lookups for special SRV
5431records.
5432
5433accept
5434
5435The final statement in the first ACL unconditionally accepts any recipient
5436address that has successfully passed all the previous tests.
5437
5438acl_check_data:
5439
5440This line marks the start of the second ACL, and names it. Most of the contents
5441of this ACL are commented out:
5442
5443# deny malware = *
5444# message = This message contains a virus \
5445# ($malware_name).
5446
5447These lines are examples of how to arrange for messages to be scanned for
5448viruses when Exim has been compiled with the content-scanning extension, and a
5449suitable virus scanner is installed. If the message is found to contain a
5450virus, it is rejected with the given custom error message.
5451
5452# warn spam = nobody
5453# message = X-Spam_score: $spam_score\n\
5454# X-Spam_score_int: $spam_score_int\n\
5455# X-Spam_bar: $spam_bar\n\
5456# X-Spam_report: $spam_report
5457
5458These lines are an example of how to arrange for messages to be scanned by
5459SpamAssassin when Exim has been compiled with the content-scanning extension,
5460and SpamAssassin has been installed. The SpamAssassin check is run with
5461"nobody" as its user parameter, and the results are added to the message as a
5462series of extra header line. In this case, the message is not rejected,
5463whatever the spam score.
5464
5465accept
5466
5467This final line in the DATA ACL accepts the message unconditionally.
5468
5469
54707.3 Router configuration
5471------------------------
5472
5473The router configuration comes next in the default configuration, introduced by
5474the line
5475
5476begin routers
5477
5478Routers are the modules in Exim that make decisions about where to send
5479messages. An address is passed to each router in turn, until it is either
5480accepted, or failed. This means that the order in which you define the routers
5481matters. Each router is fully described in its own chapter later in this
5482manual. Here we give only brief overviews.
5483
5484# domain_literal:
5485# driver = ipliteral
5486# domains = !+local_domains
5487# transport = remote_smtp
5488
5489This router is commented out because the majority of sites do not want to
5490support domain literal addresses (those of the form user@[10.9.8.7]). If you
5491uncomment this router, you also need to uncomment the setting of
5492allow_domain_literals in the main part of the configuration.
5493
5494dnslookup:
5495 driver = dnslookup
5496 domains = ! +local_domains
5497 transport = remote_smtp
5498 ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
5499 no_more
5500
5501The first uncommented router handles addresses that do not involve any local
5502domains. This is specified by the line
5503
5504domains = ! +local_domains
5505
5506The domains option lists the domains to which this router applies, but the
5507exclamation mark is a negation sign, so the router is used only for domains
5508that are not in the domain list called local_domains (which was defined at the
5509start of the configuration). The plus sign before local_domains indicates that
5510it is referring to a named list. Addresses in other domains are passed on to
5511the following routers.
5512
5513The name of the router driver is dnslookup, and is specified by the driver
5514option. Do not be confused by the fact that the name of this router instance is
5515the same as the name of the driver. The instance name is arbitrary, but the
5516name set in the driver option must be one of the driver modules that is in the
5517Exim binary.
5518
5519The dnslookup router routes addresses by looking up their domains in the DNS in
5520order to obtain a list of hosts to which the address is routed. If the router
5521succeeds, the address is queued for the remote_smtp transport, as specified by
5522the transport option. If the router does not find the domain in the DNS, no
5523further routers are tried because of the no_more setting, so the address fails
5524and is bounced.
5525
5526The ignore_target_hosts option specifies a list of IP addresses that are to be
5527entirely ignored. This option is present because a number of cases have been
5528encountered where MX records in the DNS point to host names whose IP addresses
5529are 0.0.0.0 or are in the 127 subnet (typically 127.0.0.1). Completely ignoring
5530these IP addresses causes Exim to fail to route the email address, so it
5531bounces. Otherwise, Exim would log a routing problem, and continue to try to
5532deliver the message periodically until the address timed out.
5533
5534system_aliases:
5535 driver = redirect
5536 allow_fail
5537 allow_defer
5538 data = ${lookup{$local_part}lsearch{/etc/aliases}}
5539# user = exim
5540 file_transport = address_file
5541 pipe_transport = address_pipe
5542
5543Control reaches this and subsequent routers only for addresses in the local
5544domains. This router checks to see whether the local part is defined as an
5545alias in the /etc/aliases file, and if so, redirects it according to the data
5546that it looks up from that file. If no data is found for the local part, the
5547value of the data option is empty, causing the address to be passed to the next
5548router.
5549
5550/etc/aliases is a conventional name for the system aliases file that is often
5551used. That is why it is referenced by from the default configuration file.
5552However, you can change this by setting SYSTEM_ALIASES_FILE in Local/Makefile
5553before building Exim.
5554
5555userforward:
5556 driver = redirect
5557 check_local_user
5558# local_part_suffix = +* : -*
5559# local_part_suffix_optional
5560 file = $home/.forward
5561# allow_filter
5562 no_verify
5563 no_expn
5564 check_ancestor
5565 file_transport = address_file
5566 pipe_transport = address_pipe
5567 reply_transport = address_reply
5568
5569This is the most complicated router in the default configuration. It is another
5570redirection router, but this time it is looking for forwarding data set up by
5571individual users. The check_local_user setting specifies a check that the local
5572part of the address is the login name of a local user. If it is not, the router
5573is skipped. The two commented options that follow check_local_user, namely:
5574
5575# local_part_suffix = +* : -*
5576# local_part_suffix_optional
5577
5578show how you can specify the recognition of local part suffixes. If the first
5579is uncommented, a suffix beginning with either a plus or a minus sign, followed
5580by any sequence of characters, is removed from the local part and placed in the
5581variable $local_part_suffix. The second suffix option specifies that the
5582presence of a suffix in the local part is optional. When a suffix is present,
5583the check for a local login uses the local part with the suffix removed.
5584
5585When a local user account is found, the file called .forward in the user's home
5586directory is consulted. If it does not exist, or is empty, the router declines.
5587Otherwise, the contents of .forward are interpreted as redirection data (see
5588chapter 22 for more details).
5589
5590Traditional .forward files contain just a list of addresses, pipes, or files.
5591Exim supports this by default. However, if allow_filter is set (it is commented
5592out by default), the contents of the file are interpreted as a set of Exim or
5593Sieve filtering instructions, provided the file begins with "#Exim filter" or "
5594#Sieve filter", respectively. User filtering is discussed in the separate
5595document entitled Exim's interfaces to mail filtering.
5596
5597The no_verify and no_expn options mean that this router is skipped when
5598verifying addresses, or when running as a consequence of an SMTP EXPN command.
5599There are two reasons for doing this:
5600
5601 1. Whether or not a local user has a .forward file is not really relevant when
5602 checking an address for validity; it makes sense not to waste resources
5603 doing unnecessary work.
5604
5605 2. More importantly, when Exim is verifying addresses or handling an EXPN
5606 command during an SMTP session, it is running as the Exim user, not as
5607 root. The group is the Exim group, and no additional groups are set up. It
5608 may therefore not be possible for Exim to read users' .forward files at
5609 this time.
5610
5611The setting of check_ancestor prevents the router from generating a new address
5612that is the same as any previous address that was redirected. (This works round
5613a problem concerning a bad interaction between aliasing and forwarding - see
5614section 22.5).
5615
5616The final three option settings specify the transports that are to be used when
5617forwarding generates a direct delivery to a file, or to a pipe, or sets up an
5618auto-reply, respectively. For example, if a .forward file contains
5619
5620a.nother@elsewhere.example, /home/spqr/archive
5621
5622the delivery to /home/spqr/archive is done by running the address_file
5623transport.
5624
5625localuser:
5626 driver = accept
5627 check_local_user
5628# local_part_suffix = +* : -*
5629# local_part_suffix_optional
5630 transport = local_delivery
5631
5632The final router sets up delivery into local mailboxes, provided that the local
5633part is the name of a local login, by accepting the address and assigning it to
5634the local_delivery transport. Otherwise, we have reached the end of the
5635routers, so the address is bounced. The commented suffix settings fulfil the
5636same purpose as they do for the userforward router.
5637
5638
56397.4 Transport configuration
5640---------------------------
5641
5642Transports define mechanisms for actually delivering messages. They operate
5643only when referenced from routers, so the order in which they are defined does
5644not matter. The transports section of the configuration starts with
5645
5646begin transports
5647
5648One remote transport and four local transports are defined.
5649
5650remote_smtp:
5651 driver = smtp
5652 hosts_try_prdr = *
5653
5654This transport is used for delivering messages over SMTP connections. The list
5655of remote hosts comes from the router. The hosts_try_prdr option enables an
5656efficiency SMTP option. It is negotiated between client and server and not
5657expected to cause problems but can be disabled if needed. All other options are
5658defaulted.
5659
5660local_delivery:
5661 driver = appendfile
5662 file = /var/mail/$local_part
5663 delivery_date_add
5664 envelope_to_add
5665 return_path_add
5666# group = mail
5667# mode = 0660
5668
5669This appendfile transport is used for local delivery to user mailboxes in
5670traditional BSD mailbox format. By default it runs under the uid and gid of the
5671local user, which requires the sticky bit to be set on the /var/mail directory.
5672Some systems use the alternative approach of running mail deliveries under a
5673particular group instead of using the sticky bit. The commented options show
5674how this can be done.
5675
5676Exim adds three headers to the message as it delivers it: Delivery-date:,
5677Envelope-to: and Return-path:. This action is requested by the three
5678similarly-named options above.
5679
5680address_pipe:
5681 driver = pipe
5682 return_output
5683
5684This transport is used for handling deliveries to pipes that are generated by
5685redirection (aliasing or users' .forward files). The return_output option
5686specifies that any output generated by the pipe is to be returned to the
5687sender.
5688
5689address_file:
5690 driver = appendfile
5691 delivery_date_add
5692 envelope_to_add
5693 return_path_add
5694
5695This transport is used for handling deliveries to files that are generated by
5696redirection. The name of the file is not specified in this instance of
5697appendfile, because it comes from the redirect router.
5698
5699address_reply:
5700 driver = autoreply
5701
5702This transport is used for handling automatic replies generated by users'
5703filter files.
5704
5705
57067.5 Default retry rule
5707----------------------
5708
5709The retry section of the configuration file contains rules which affect the way
5710Exim retries deliveries that cannot be completed at the first attempt. It is
5711introduced by the line
5712
5713begin retry
5714
5715In the default configuration, there is just one rule, which applies to all
5716errors:
5717
5718* * F,2h,15m; G,16h,1h,1.5; F,4d,6h
5719
5720This causes any temporarily failing address to be retried every 15 minutes for
57212 hours, then at intervals starting at one hour and increasing by a factor of
57221.5 until 16 hours have passed, then every 6 hours up to 4 days. If an address
5723is not delivered after 4 days of temporary failure, it is bounced.
5724
5725If the retry section is removed from the configuration, or is empty (that is,
5726if no retry rules are defined), Exim will not retry deliveries. This turns
5727temporary errors into permanent errors.
5728
5729
57307.6 Rewriting configuration
5731---------------------------
5732
5733The rewriting section of the configuration, introduced by
5734
5735begin rewrite
5736
5737contains rules for rewriting addresses in messages as they arrive. There are no
5738rewriting rules in the default configuration file.
5739
5740
57417.7 Authenticators configuration
5742--------------------------------
5743
5744The authenticators section of the configuration, introduced by
5745
5746begin authenticators
5747
5748defines mechanisms for the use of the SMTP AUTH command. The default
5749configuration file contains two commented-out example authenticators which
5750support plaintext username/password authentication using the standard PLAIN
5751mechanism and the traditional but non-standard LOGIN mechanism, with Exim
5752acting as the server. PLAIN and LOGIN are enough to support most MUA software.
5753
5754The example PLAIN authenticator looks like this:
5755
5756#PLAIN:
5757# driver = plaintext
5758# server_set_id = $auth2
5759# server_prompts = :
5760# server_condition = Authentication is not yet configured
5761# server_advertise_condition = ${if def:tls_in_cipher }
5762
5763And the example LOGIN authenticator looks like this:
5764
5765#LOGIN:
5766# driver = plaintext
5767# server_set_id = $auth1
5768# server_prompts = <| Username: | Password:
5769# server_condition = Authentication is not yet configured
5770# server_advertise_condition = ${if def:tls_in_cipher }
5771
5772The server_set_id option makes Exim remember the authenticated username in
5773$authenticated_id, which can be used later in ACLs or routers. The
5774server_prompts option configures the plaintext authenticator so that it
5775implements the details of the specific authentication mechanism, i.e. PLAIN or
5776LOGIN. The server_advertise_condition setting controls when Exim offers
5777authentication to clients; in the examples, this is only when TLS or SSL has
5778been started, so to enable the authenticators you also need to add support for
5779TLS as described in section 7.1.
5780
5781The server_condition setting defines how to verify that the username and
5782password are correct. In the examples it just produces an error message. To
5783make the authenticators work, you can use a string expansion expression like
5784one of the examples in chapter 34.
5785
5786Beware that the sequence of the parameters to PLAIN and LOGIN differ; the
5787usercode and password are in different positions. Chapter 34 covers both.
5788
5789
5790
5791===============================================================================
57928. REGULAR EXPRESSIONS
5793
5794Exim supports the use of regular expressions in many of its options. It uses
5795the PCRE regular expression library; this provides regular expression matching
5796that is compatible with Perl 5. The syntax and semantics of regular expressions
5797is discussed in many Perl reference books, and also in Jeffrey Friedl's
5798Mastering Regular Expressions, which is published by O'Reilly (see http://
5799www.oreilly.com/catalog/regex2/).
5800
5801The documentation for the syntax and semantics of the regular expressions that
5802are supported by PCRE is included in the PCRE distribution, and no further
5803description is included here. The PCRE functions are called from Exim using the
5804default option settings (that is, with no PCRE options set), except that the
5805PCRE_CASELESS option is set when the matching is required to be
5806case-insensitive.
5807
5808In most cases, when a regular expression is required in an Exim configuration,
5809it has to start with a circumflex, in order to distinguish it from plain text
5810or an "ends with" wildcard. In this example of a configuration setting, the
5811second item in the colon-separated list is a regular expression.
5812
5813domains = a.b.c : ^\\d{3} : *.y.z : ...
5814
5815The doubling of the backslash is required because of string expansion that
5816precedes interpretation - see section 11.1 for more discussion of this issue,
5817and a way of avoiding the need for doubling backslashes. The regular expression
5818that is eventually used in this example contains just one backslash. The
5819circumflex is included in the regular expression, and has the normal effect of
5820"anchoring" it to the start of the string that is being matched.
5821
5822There are, however, two cases where a circumflex is not required for the
5823recognition of a regular expression: these are the match condition in a string
5824expansion, and the matches condition in an Exim filter file. In these cases,
5825the relevant string is always treated as a regular expression; if it does not
5826start with a circumflex, the expression is not anchored, and can match anywhere
5827in the subject string.
5828
5829In all cases, if you want a regular expression to match at the end of a string,
5830you must code the $ metacharacter to indicate this. For example:
5831
5832domains = ^\\d{3}\\.example
5833
5834matches the domain 123.example, but it also matches 123.example.com. You need
5835to use:
5836
5837domains = ^\\d{3}\\.example\$
5838
5839if you want example to be the top-level domain. The backslash before the $ is
5840needed because string expansion also interprets dollar characters.
5841
5842
5843
5844===============================================================================
58459. FILE AND DATABASE LOOKUPS
5846
5847Exim can be configured to look up data in files or databases as it processes
5848messages. Two different kinds of syntax are used:
5849
5850 1. A string that is to be expanded may contain explicit lookup requests. These
5851 cause parts of the string to be replaced by data that is obtained from the
5852 lookup. Lookups of this type are conditional expansion items. Different
5853 results can be defined for the cases of lookup success and failure. See
5854 chapter 11, where string expansions are described in detail.
5855
5856 2. Lists of domains, hosts, and email addresses can contain lookup requests as
5857 a way of avoiding excessively long linear lists. In this case, the data
5858 that is returned by the lookup is often (but not always) discarded; whether
5859 the lookup succeeds or fails is what really counts. These kinds of list are
5860 described in chapter 10.
5861
5862String expansions, lists, and lookups interact with each other in such a way
5863that there is no order in which to describe any one of them that does not
5864involve references to the others. Each of these three chapters makes more sense
5865if you have read the other two first. If you are reading this for the first
5866time, be aware that some of it will make a lot more sense after you have read
5867chapters 10 and 11.
5868
5869
58709.1 Examples of different lookup syntax
5871---------------------------------------
5872
5873It is easy to confuse the two different kinds of lookup, especially as the
5874lists that may contain the second kind are always expanded before being
5875processed as lists. Therefore, they may also contain lookups of the first kind.
5876Be careful to distinguish between the following two examples:
5877
5878domains = ${lookup{$sender_host_address}lsearch{/some/file}}
5879domains = lsearch;/some/file
5880
5881The first uses a string expansion, the result of which must be a domain list.
5882No strings have been specified for a successful or a failing lookup; the
5883defaults in this case are the looked-up data and an empty string, respectively.
5884The expansion takes place before the string is processed as a list, and the
5885file that is searched could contain lines like this:
5886
5887192.168.3.4: domain1:domain2:...
5888192.168.1.9: domain3:domain4:...
5889
5890When the lookup succeeds, the result of the expansion is a list of domains (and
5891possibly other types of item that are allowed in domain lists).
5892
5893In the second example, the lookup is a single item in a domain list. It causes
5894Exim to use a lookup to see if the domain that is being processed can be found
5895in the file. The file could contains lines like this:
5896
5897domain1:
5898domain2:
5899
5900Any data that follows the keys is not relevant when checking that the domain
5901matches the list item.
5902
5903It is possible, though no doubt confusing, to use both kinds of lookup at once.
5904Consider a file containing lines like this:
5905
5906192.168.5.6: lsearch;/another/file
5907
5908If the value of $sender_host_address is 192.168.5.6, expansion of the first
5909domains setting above generates the second setting, which therefore causes a
5910second lookup to occur.
5911
5912The rest of this chapter describes the different lookup types that are
5913available. Any of them can be used in any part of the configuration where a
5914lookup is permitted.
5915
5916
59179.2 Lookup types
5918----------------
5919
5920Two different types of data lookup are implemented:
5921
5922 * The single-key type requires the specification of a file in which to look,
5923 and a single key to search for. The key must be a non-empty string for the
5924 lookup to succeed. The lookup type determines how the file is searched.
5925
5926 * The query-style type accepts a generalized database query. No particular
5927 key value is assumed by Exim for query-style lookups. You can use whichever
5928 Exim variables you need to construct the database query.
5929
5930The code for each lookup type is in a separate source file that is included in
5931the binary of Exim only if the corresponding compile-time option is set. The
5932default settings in src/EDITME are:
5933
5934LOOKUP_DBM=yes
5935LOOKUP_LSEARCH=yes
5936
5937which means that only linear searching and DBM lookups are included by default.
5938For some types of lookup (e.g. SQL databases), you need to install appropriate
5939libraries and header files before building Exim.
5940
5941
59429.3 Single-key lookup types
5943---------------------------
5944
5945The following single-key lookup types are implemented:
5946
5947 * cdb: The given file is searched as a Constant DataBase file, using the key
5948 string without a terminating binary zero. The cdb format is designed for
5949 indexed files that are read frequently and never updated, except by total
5950 re-creation. As such, it is particularly suitable for large files
5951 containing aliases or other indexed data referenced by an MTA. Information
5952 about cdb can be found in several places:
5953
5954 http://www.pobox.com/~djb/cdb.html
5955 ftp://ftp.corpit.ru/pub/tinycdb/
5956 http://packages.debian.org/stable/utils/freecdb.html
5957
5958 A cdb distribution is not needed in order to build Exim with cdb support,
5959 because the code for reading cdb files is included directly in Exim itself.
5960 However, no means of building or testing cdb files is provided with Exim,
5961 so you need to obtain a cdb distribution in order to do this.
5962
5963 * dbm: Calls to DBM library functions are used to extract data from the given
5964 DBM file by looking up the record with the given key. A terminating binary
5965 zero is included in the key that is passed to the DBM library. See section
5966 4.4 for a discussion of DBM libraries.
5967
5968 For all versions of Berkeley DB, Exim uses the DB_HASH style of database
5969 when building DBM files using the exim_dbmbuild utility. However, when
5970 using Berkeley DB versions 3 or 4, it opens existing databases for reading
5971 with the DB_UNKNOWN option. This enables it to handle any of the types of
5972 database that the library supports, and can be useful for accessing DBM
5973 files created by other applications. (For earlier DB versions, DB_HASH is
5974 always used.)
5975
5976 * dbmjz: This is the same as dbm, except that the lookup key is interpreted
5977 as an Exim list; the elements of the list are joined together with ASCII
5978 NUL characters to form the lookup key. An example usage would be to
5979 authenticate incoming SMTP calls using the passwords from Cyrus SASL's /etc
5980 /sasldb2 file with the gsasl authenticator or Exim's own cram_md5
5981 authenticator.
5982
5983 * dbmnz: This is the same as dbm, except that a terminating binary zero is
5984 not included in the key that is passed to the DBM library. You may need
5985 this if you want to look up data in files that are created by or shared
5986 with some other application that does not use terminating zeros. For
5987 example, you need to use dbmnz rather than dbm if you want to authenticate
5988 incoming SMTP calls using the passwords from Courier's /etc/
5989 userdbshadow.dat file. Exim's utility program for creating DBM files (
5990 exim_dbmbuild) includes the zeros by default, but has an option to omit
5991 them (see section 52.9).
5992
5993 * dsearch: The given file must be a directory; this is searched for an entry
5994 whose name is the key by calling the lstat() function. The key may not
5995 contain any forward slash characters. If lstat() succeeds, the result of
5996 the lookup is the name of the entry, which may be a file, directory,
5997 symbolic link, or any other kind of directory entry. An example of how this
5998 lookup can be used to support virtual domains is given in section 49.7.
5999
6000 * iplsearch: The given file is a text file containing keys and data. A key is
6001 terminated by a colon or white space or the end of the line. The keys in
6002 the file must be IP addresses, or IP addresses with CIDR masks. Keys that
6003 involve IPv6 addresses must be enclosed in quotes to prevent the first
6004 internal colon being interpreted as a key terminator. For example:
6005
6006 1.2.3.4: data for 1.2.3.4
6007 192.168.0.0/16: data for 192.168.0.0/16
6008 "abcd::cdab": data for abcd::cdab
6009 "abcd:abcd::/32" data for abcd:abcd::/32
6010
6011 The key for an iplsearch lookup must be an IP address (without a mask). The
6012 file is searched linearly, using the CIDR masks where present, until a
6013 matching key is found. The first key that matches is used; there is no
6014 attempt to find a "best" match. Apart from the way the keys are matched,
6015 the processing for iplsearch is the same as for lsearch.
6016
6017 Warning 1: Unlike most other single-key lookup types, a file of data for
6018 iplsearch can not be turned into a DBM or cdb file, because those lookup
6019 types support only literal keys.
6020
6021 Warning 2: In a host list, you must always use net-iplsearch so that the
6022 implicit key is the host's IP address rather than its name (see section
6023 10.12).
6024
6025 * lsearch: The given file is a text file that is searched linearly for a line
6026 beginning with the search key, terminated by a colon or white space or the
6027 end of the line. The search is case-insensitive; that is, upper and lower
6028 case letters are treated as the same. The first occurrence of the key that
6029 is found in the file is used.
6030
6031 White space between the key and the colon is permitted. The remainder of
6032 the line, with leading and trailing white space removed, is the data. This
6033 can be continued onto subsequent lines by starting them with any amount of
6034 white space, but only a single space character is included in the data at
6035 such a junction. If the data begins with a colon, the key must be
6036 terminated by a colon, for example:
6037
6038 baduser: :fail:
6039
6040 Empty lines and lines beginning with # are ignored, even if they occur in
6041 the middle of an item. This is the traditional textual format of alias
6042 files. Note that the keys in an lsearch file are literal strings. There is
6043 no wildcarding of any kind.
6044
6045 In most lsearch files, keys are not required to contain colons or #
6046 characters, or white space. However, if you need this feature, it is
6047 available. If a key begins with a doublequote character, it is terminated
6048 only by a matching quote (or end of line), and the normal escaping rules
6049 apply to its contents (see section 6.16). An optional colon is permitted
6050 after quoted keys (exactly as for unquoted keys). There is no special
6051 handling of quotes for the data part of an lsearch line.
6052
6053 * nis: The given file is the name of a NIS map, and a NIS lookup is done with
6054 the given key, without a terminating binary zero. There is a variant called
6055 nis0 which does include the terminating binary zero in the key. This is
6056 reportedly needed for Sun-style alias files. Exim does not recognize NIS
6057 aliases; the full map names must be used.
6058
6059 * wildlsearch or nwildlsearch: These search a file linearly, like lsearch,
6060 but instead of being interpreted as a literal string, each key in the file
6061 may be wildcarded. The difference between these two lookup types is that
6062 for wildlsearch, each key in the file is string-expanded before being used,
6063 whereas for nwildlsearch, no expansion takes place.
6064
6065 Like lsearch, the testing is done case-insensitively. However, keys in the
6066 file that are regular expressions can be made case-sensitive by the use of
6067 "(-i)" within the pattern. The following forms of wildcard are recognized:
6068
6069 1. The string may begin with an asterisk to mean "ends with". For example:
6070
6071 *.a.b.c data for anything.a.b.c
6072 *fish data for anythingfish
6073
6074 2. The string may begin with a circumflex to indicate a regular
6075 expression. For example, for wildlsearch:
6076
6077 ^\N\d+\.a\.b\N data for <digits>.a.b
6078
6079 Note the use of "\N" to disable expansion of the contents of the
6080 regular expression. If you are using nwildlsearch, where the keys are
6081 not string-expanded, the equivalent entry is:
6082
6083 ^\d+\.a\.b data for <digits>.a.b
6084
6085 The case-insensitive flag is set at the start of compiling the regular
6086 expression, but it can be turned off by using "(-i)" at an appropriate
6087 point. For example, to make the entire pattern case-sensitive:
6088
6089 ^(?-i)\d+\.a\.b data for <digits>.a.b
6090
6091 If the regular expression contains white space or colon characters, you
6092 must either quote it (see lsearch above), or represent these characters
6093 in other ways. For example, "\s" can be used for white space and "\x3A"
6094 for a colon. This may be easier than quoting, because if you quote, you
6095 have to escape all the backslashes inside the quotes.
6096
6097 Note: It is not possible to capture substrings in a regular expression
6098 match for later use, because the results of all lookups are cached. If
6099 a lookup is repeated, the result is taken from the cache, and no actual
6100 pattern matching takes place. The values of all the numeric variables
6101 are unset after a (n)wildlsearch match.
6102
6103 3. Although I cannot see it being of much use, the general matching
6104 function that is used to implement (n)wildlsearch means that the string
6105 may begin with a lookup name terminated by a semicolon, and followed by
6106 lookup data. For example:
6107
6108 cdb;/some/file data for keys that match the file
6109
6110 The data that is obtained from the nested lookup is discarded.
6111
6112 Keys that do not match any of these patterns are interpreted literally. The
6113 continuation rules for the data are the same as for lsearch, and keys may
6114 be followed by optional colons.
6115
6116 Warning: Unlike most other single-key lookup types, a file of data for (n)
6117 wildlsearch can not be turned into a DBM or cdb file, because those lookup
6118 types support only literal keys.
6119
6120
61219.4 Query-style lookup types
6122----------------------------
6123
6124The supported query-style lookup types are listed below. Further details about
6125many of them are given in later sections.
6126
6127 * dnsdb: This does a DNS search for one or more records whose domain names
6128 are given in the supplied query. The resulting data is the contents of the
6129 records. See section 9.10.
6130
6131 * ibase: This does a lookup in an InterBase database.
6132
6133 * ldap: This does an LDAP lookup using a query in the form of a URL, and
6134 returns attributes from a single entry. There is a variant called ldapm
6135 that permits values from multiple entries to be returned. A third variant
6136 called ldapdn returns the Distinguished Name of a single entry instead of
6137 any attribute values. See section 9.13.
6138
6139 * mysql: The format of the query is an SQL statement that is passed to a
6140 MySQL database. See section 9.20.
6141
6142 * nisplus: This does a NIS+ lookup using a query that can specify the name of
6143 the field to be returned. See section 9.19.
6144
6145 * oracle: The format of the query is an SQL statement that is passed to an
6146 Oracle database. See section 9.20.
6147
6148 * passwd is a query-style lookup with queries that are just user names. The
6149 lookup calls getpwnam() to interrogate the system password data, and on
6150 success, the result string is the same as you would get from an lsearch
6151 lookup on a traditional /etc/passwd file, though with "*" for the password
6152 value. For example:
6153
6154 *:42:42:King Rat:/home/kr:/bin/bash
6155
6156 * pgsql: The format of the query is an SQL statement that is passed to a
6157 PostgreSQL database. See section 9.20.
6158
6159 * sqlite: The format of the query is a file name followed by an SQL statement
6160 that is passed to an SQLite database. See section 9.25.
6161
6162 * testdb: This is a lookup type that is used for testing Exim. It is not
6163 likely to be useful in normal operation.
6164
6165 * whoson: Whoson (http://whoson.sourceforge.net) is a protocol that allows a
6166 server to check whether a particular (dynamically allocated) IP address is
6167 currently allocated to a known (trusted) user and, optionally, to obtain
6168 the identity of the said user. For SMTP servers, Whoson was popular at one
6169 time for "POP before SMTP" authentication, but that approach has been
6170 superseded by SMTP authentication. In Exim, Whoson can be used to implement
6171 "POP before SMTP" checking using ACL statements such as
6172
6173 require condition = \
6174 ${lookup whoson {$sender_host_address}{yes}{no}}
6175
6176 The query consists of a single IP address. The value returned is the name
6177 of the authenticated user, which is stored in the variable $value. However,
6178 in this example, the data in $value is not used; the result of the lookup
6179 is one of the fixed strings "yes" or "no".
6180
6181
61829.5 Temporary errors in lookups
6183-------------------------------
6184
6185Lookup functions can return temporary error codes if the lookup cannot be
6186completed. For example, an SQL or LDAP database might be unavailable. For this
6187reason, it is not advisable to use a lookup that might do this for critical
6188options such as a list of local domains.
6189
6190When a lookup cannot be completed in a router or transport, delivery of the
6191message (to the relevant address) is deferred, as for any other temporary
6192error. In other circumstances Exim may assume the lookup has failed, or may
6193give up altogether.
6194
6195
61969.6 Default values in single-key lookups
6197----------------------------------------
6198
6199In this context, a "default value" is a value specified by the administrator
6200that is to be used if a lookup fails.
6201
6202Note: This section applies only to single-key lookups. For query-style lookups,
6203the facilities of the query language must be used. An attempt to specify a
6204default for a query-style lookup provokes an error.
6205
6206If "*" is added to a single-key lookup type (for example, lsearch*) and the
6207initial lookup fails, the key "*" is looked up in the file to provide a default
6208value. See also the section on partial matching below.
6209
6210Alternatively, if "*@" is added to a single-key lookup type (for example dbm*@)
6211then, if the initial lookup fails and the key contains an @ character, a second
6212lookup is done with everything before the last @ replaced by *. This makes it
6213possible to provide per-domain defaults in alias files that include the domains
6214in the keys. If the second lookup fails (or doesn't take place because there is
6215no @ in the key), "*" is looked up. For example, a redirect router might
6216contain:
6217
6218data = ${lookup{$local_part@$domain}lsearch*@{/etc/mix-aliases}}
6219
6220Suppose the address that is being processed is jane@eyre.example. Exim looks up
6221these keys, in this order:
6222
6223jane@eyre.example
6224*@eyre.example
6225*
6226
6227The data is taken from whichever key it finds first. Note: In an lsearch file,
6228this does not mean the first of these keys in the file. A complete scan is done
6229for each key, and only if it is not found at all does Exim move on to try the
6230next key.
6231
6232
62339.7 Partial matching in single-key lookups
6234------------------------------------------
6235
6236The normal operation of a single-key lookup is to search the file for an exact
6237match with the given key. However, in a number of situations where domains are
6238being looked up, it is useful to be able to do partial matching. In this case,
6239information in the file that has a key starting with "*." is matched by any
6240domain that ends with the components that follow the full stop. For example, if
6241a key in a DBM file is
6242
6243*.dates.fict.example
6244
6245then when partial matching is enabled this is matched by (amongst others)
62462001.dates.fict.example and 1984.dates.fict.example. It is also matched by
6247dates.fict.example, if that does not appear as a separate key in the file.
6248
6249Note: Partial matching is not available for query-style lookups. It is also not
6250available for any lookup items in address lists (see section 10.19).
6251
6252Partial matching is implemented by doing a series of separate lookups using
6253keys constructed by modifying the original subject key. This means that it can
6254be used with any of the single-key lookup types, provided that partial matching
6255keys beginning with a special prefix (default "*.") are included in the data
6256file. Keys in the file that do not begin with the prefix are matched only by
6257unmodified subject keys when partial matching is in use.
6258
6259Partial matching is requested by adding the string "partial-" to the front of
6260the name of a single-key lookup type, for example, partial-dbm. When this is
6261done, the subject key is first looked up unmodified; if that fails, "*." is
6262added at the start of the subject key, and it is looked up again. If that
6263fails, further lookups are tried with dot-separated components removed from the
6264start of the subject key, one-by-one, and "*." added on the front of what
6265remains.
6266
6267A minimum number of two non-* components are required. This can be adjusted by
6268including a number before the hyphen in the search type. For example,
6269partial3-lsearch specifies a minimum of three non-* components in the modified
6270keys. Omitting the number is equivalent to "partial2-". If the subject key is
62712250.dates.fict.example then the following keys are looked up when the minimum
6272number of non-* components is two:
6273
62742250.dates.fict.example
6275*.2250.dates.fict.example
6276*.dates.fict.example
6277*.fict.example
6278
6279As soon as one key in the sequence is successfully looked up, the lookup
6280finishes.
6281
6282The use of "*." as the partial matching prefix is a default that can be
6283changed. The motivation for this feature is to allow Exim to operate with file
6284formats that are used by other MTAs. A different prefix can be supplied in
6285parentheses instead of the hyphen after "partial". For example:
6286
6287domains = partial(.)lsearch;/some/file
6288
6289In this example, if the domain is a.b.c, the sequence of lookups is "a.b.c",
6290".a.b.c", and ".b.c" (the default minimum of 2 non-wild components is
6291unchanged). The prefix may consist of any punctuation characters other than a
6292closing parenthesis. It may be empty, for example:
6293
6294domains = partial1()cdb;/some/file
6295
6296For this example, if the domain is a.b.c, the sequence of lookups is "a.b.c",
6297"b.c", and "c".
6298
6299If "partial0" is specified, what happens at the end (when the lookup with just
6300one non-wild component has failed, and the original key is shortened right down
6301to the null string) depends on the prefix:
6302
6303 * If the prefix has zero length, the whole lookup fails.
6304
6305 * If the prefix has length 1, a lookup for just the prefix is done. For
6306 example, the final lookup for "partial0(.)" is for "." alone.
6307
6308 * Otherwise, if the prefix ends in a dot, the dot is removed, and the
6309 remainder is looked up. With the default prefix, therefore, the final
6310 lookup is for "*" on its own.
6311
6312 * Otherwise, the whole prefix is looked up.
6313
6314If the search type ends in "*" or "*@" (see section 9.6 above), the search for
6315an ultimate default that this implies happens after all partial lookups have
6316failed. If "partial0" is specified, adding "*" to the search type has no effect
6317with the default prefix, because the "*" key is already included in the
6318sequence of partial lookups. However, there might be a use for lookup types
6319such as "partial0(.)lsearch*".
6320
6321The use of "*" in lookup partial matching differs from its use as a wildcard in
6322domain lists and the like. Partial matching works only in terms of
6323dot-separated components; a key such as "*fict.example" in a database file is
6324useless, because the asterisk in a partial matching subject key is always
6325followed by a dot.
6326
6327
63289.8 Lookup caching
6329------------------
6330
6331Exim caches all lookup results in order to avoid needless repetition of
6332lookups. However, because (apart from the daemon) Exim operates as a collection
6333of independent, short-lived processes, this caching applies only within a
6334single Exim process. There is no inter-process lookup caching facility.
6335
6336For single-key lookups, Exim keeps the relevant files open in case there is
6337another lookup that needs them. In some types of configuration this can lead to
6338many files being kept open for messages with many recipients. To avoid hitting
6339the operating system limit on the number of simultaneously open files, Exim
6340closes the least recently used file when it needs to open more files than its
6341own internal limit, which can be changed via the lookup_open_max option.
6342
6343The single-key lookup files are closed and the lookup caches are flushed at
6344strategic points during delivery - for example, after all routing is complete.
6345
6346
63479.9 Quoting lookup data
6348-----------------------
6349
6350When data from an incoming message is included in a query-style lookup, there
6351is the possibility of special characters in the data messing up the syntax of
6352the query. For example, a NIS+ query that contains
6353
6354[name=$local_part]
6355
6356will be broken if the local part happens to contain a closing square bracket.
6357For NIS+, data can be enclosed in double quotes like this:
6358
6359[name="$local_part"]
6360
6361but this still leaves the problem of a double quote in the data. The rule for
6362NIS+ is that double quotes must be doubled. Other lookup types have different
6363rules, and to cope with the differing requirements, an expansion operator of
6364the following form is provided:
6365
6366${quote_<lookup-type>:<string>}
6367
6368For example, the safest way to write the NIS+ query is
6369
6370[name="${quote_nisplus:$local_part}"]
6371
6372See chapter 11 for full coverage of string expansions. The quote operator can
6373be used for all lookup types, but has no effect for single-key lookups, since
6374no quoting is ever needed in their key strings.
6375
6376
63779.10 More about dnsdb
6378---------------------
6379
6380The dnsdb lookup type uses the DNS as its database. A simple query consists of
6381a record type and a domain name, separated by an equals sign. For example, an
6382expansion string could contain:
6383
6384${lookup dnsdb{mx=a.b.example}{$value}fail}
6385
6386If the lookup succeeds, the result is placed in $value, which in this case is
6387used on its own as the result. If the lookup does not succeed, the "fail"
6388keyword causes a forced expansion failure - see section 11.4 for an explanation
6389of what this means.
6390
6391The supported DNS record types are A, CNAME, MX, NS, PTR, SPF, SRV, TLSA and
6392TXT, and, when Exim is compiled with IPv6 support, AAAA (and A6 if that is also
6393configured). If no type is given, TXT is assumed. When the type is PTR, the
6394data can be an IP address, written as normal; inversion and the addition of
6395in-addr.arpa or ip6.arpa happens automatically. For example:
6396
6397${lookup dnsdb{ptr=192.168.4.5}{$value}fail}
6398
6399If the data for a PTR record is not a syntactically valid IP address, it is not
6400altered and nothing is added.
6401
6402For an MX lookup, both the preference value and the host name are returned for
6403each record, separated by a space. For an SRV lookup, the priority, weight,
6404port, and host name are returned for each record, separated by spaces.
6405
6406For any record type, if multiple records are found (or, for A6 lookups, if a
6407single record leads to multiple addresses), the data is returned as a
6408concatenation, with newline as the default separator. The order, of course,
6409depends on the DNS resolver. You can specify a different separator character
6410between multiple records by putting a right angle-bracket followed immediately
6411by the new separator at the start of the query. For example:
6412
6413${lookup dnsdb{>: a=host1.example}}
6414
6415It is permitted to specify a space as the separator character. Further white
6416space is ignored.
6417
6418For TXT records with multiple items of data, only the first item is returned,
6419unless a separator for them is specified using a comma after the separator
6420character followed immediately by the TXT record item separator. To concatenate
6421items without a separator, use a semicolon instead. For SPF records the default
6422behaviour is to concatenate multiple items without using a separator.
6423
6424${lookup dnsdb{>\n,: txt=a.b.example}}
6425${lookup dnsdb{>\n; txt=a.b.example}}
6426${lookup dnsdb{spf=example.org}}
6427
6428It is permitted to specify a space as the separator character. Further white
6429space is ignored.
6430
6431
64329.11 Pseudo dnsdb record types
6433------------------------------
6434
6435By default, both the preference value and the host name are returned for each
6436MX record, separated by a space. If you want only host names, you can use the
6437pseudo-type MXH:
6438
6439${lookup dnsdb{mxh=a.b.example}}
6440
6441In this case, the preference values are omitted, and just the host names are
6442returned.
6443
6444Another pseudo-type is ZNS (for "zone NS"). It performs a lookup for NS records
6445on the given domain, but if none are found, it removes the first component of
6446the domain name, and tries again. This process continues until NS records are
6447found or there are no more components left (or there is a DNS error). In other
6448words, it may return the name servers for a top-level domain, but it never
6449returns the root name servers. If there are no NS records for the top-level
6450domain, the lookup fails. Consider these examples:
6451
6452${lookup dnsdb{zns=xxx.quercite.com}}
6453${lookup dnsdb{zns=xxx.edu}}
6454
6455Assuming that in each case there are no NS records for the full domain name,
6456the first returns the name servers for quercite.com, and the second returns the
6457name servers for edu.
6458
6459You should be careful about how you use this lookup because, unless the
6460top-level domain does not exist, the lookup always returns some host names. The
6461sort of use to which this might be put is for seeing if the name servers for a
6462given domain are on a blacklist. You can probably assume that the name servers
6463for the high-level domains such as com or co.uk are not going to be on such a
6464list.
6465
6466A third pseudo-type is CSA (Client SMTP Authorization). This looks up SRV
6467records according to the CSA rules, which are described in section 42.50.
6468Although dnsdb supports SRV lookups directly, this is not sufficient because of
6469the extra parent domain search behaviour of CSA. The result of a successful
6470lookup such as:
6471
6472${lookup dnsdb {csa=$sender_helo_name}}
6473
6474has two space-separated fields: an authorization code and a target host name.
6475The authorization code can be "Y" for yes, "N" for no, "X" for explicit
6476authorization required but absent, or "?" for unknown.
6477
6478The pseudo-type A+ performs an A6 lookup (if configured) followed by an AAAA
6479and then an A lookup. All results are returned; defer processing (see below) is
6480handled separately for each lookup. Example:
6481
6482${lookup dnsdb {>; a+=$sender_helo_name}}
6483
6484
64859.12 Multiple dnsdb lookups
6486---------------------------
6487
6488In the previous sections, dnsdb lookups for a single domain are described.
6489However, you can specify a list of domains or IP addresses in a single dnsdb
6490lookup. The list is specified in the normal Exim way, with colon as the default
6491separator, but with the ability to change this. For example:
6492
6493${lookup dnsdb{one.domain.com:two.domain.com}}
6494${lookup dnsdb{a=one.host.com:two.host.com}}
6495${lookup dnsdb{ptr = <; 1.2.3.4 ; 4.5.6.8}}
6496
6497In order to retain backwards compatibility, there is one special case: if the
6498lookup type is PTR and no change of separator is specified, Exim looks to see
6499if the rest of the string is precisely one IPv6 address. In this case, it does
6500not treat it as a list.
6501
6502The data from each lookup is concatenated, with newline separators by default,
6503in the same way that multiple DNS records for a single item are handled. A
6504different separator can be specified, as described above.
6505
6506Modifiers for dnsdb lookups are givien by optional keywords, each followed by a
6507comma, that may appear before the record type.
6508
6509The dnsdb lookup fails only if all the DNS lookups fail. If there is a
6510temporary DNS error for any of them, the behaviour is controlled by a
6511defer-option modifier. The possible keywords are "defer_strict", "defer_never",
6512and "defer_lax". With "strict" behaviour, any temporary DNS error causes the
6513whole lookup to defer. With "never" behaviour, a temporary DNS error is
6514ignored, and the behaviour is as if the DNS lookup failed to find anything.
6515With "lax" behaviour, all the queries are attempted, but a temporary DNS error
6516causes the whole lookup to defer only if none of the other lookups succeed. The
6517default is "lax", so the following lookups are equivalent:
6518
6519${lookup dnsdb{defer_lax,a=one.host.com:two.host.com}}
6520${lookup dnsdb{a=one.host.com:two.host.com}}
6521
6522Thus, in the default case, as long as at least one of the DNS lookups yields
6523some data, the lookup succeeds.
6524
6525Use of DNSSEC is controlled by a dnssec modifier. The possible keywords are
6526"dnssec_strict", "dnssec_lax", and "dnssec_never". With "strict" or "lax"
6527DNSSEC information is requested with the lookup. With "strict" a response from
6528the DNS resolver that is not labelled as authenticated data is treated as
6529equivalent to a temporary DNS error. The default is "never".
6530
6531See also the $lookup_dnssec_authenticated variable.
6532
6533
65349.13 More about LDAP
6535--------------------
6536
6537The original LDAP implementation came from the University of Michigan; this has
6538become "Open LDAP", and there are now two different releases. Another
6539implementation comes from Netscape, and Solaris 7 and subsequent releases
6540contain inbuilt LDAP support. Unfortunately, though these are all compatible at
6541the lookup function level, their error handling is different. For this reason
6542it is necessary to set a compile-time variable when building Exim with LDAP, to
6543indicate which LDAP library is in use. One of the following should appear in
6544your Local/Makefile:
6545
6546LDAP_LIB_TYPE=UMICHIGAN
6547LDAP_LIB_TYPE=OPENLDAP1
6548LDAP_LIB_TYPE=OPENLDAP2
6549LDAP_LIB_TYPE=NETSCAPE
6550LDAP_LIB_TYPE=SOLARIS
6551
6552If LDAP_LIB_TYPE is not set, Exim assumes "OPENLDAP1", which has the same
6553interface as the University of Michigan version.
6554
6555There are three LDAP lookup types in Exim. These behave slightly differently in
6556the way they handle the results of a query:
6557
6558 * ldap requires the result to contain just one entry; if there are more, it
6559 gives an error.
6560
6561 * ldapdn also requires the result to contain just one entry, but it is the
6562 Distinguished Name that is returned rather than any attribute values.
6563
6564 * ldapm permits the result to contain more than one entry; the attributes
6565 from all of them are returned.
6566
6567For ldap and ldapm, if a query finds only entries with no attributes, Exim
6568behaves as if the entry did not exist, and the lookup fails. The format of the
6569data returned by a successful lookup is described in the next section. First we
6570explain how LDAP queries are coded.
6571
6572
65739.14 Format of LDAP queries
6574---------------------------
6575
6576An LDAP query takes the form of a URL as defined in RFC 2255. For example, in
6577the configuration of a redirect router one might have this setting:
6578
6579data = ${lookup ldap \
6580 {ldap:///cn=$local_part,o=University%20of%20Cambridge,\
6581 c=UK?mailbox?base?}}
6582
6583The URL may begin with "ldap" or "ldaps" if your LDAP library supports secure
6584(encrypted) LDAP connections. The second of these ensures that an encrypted TLS
6585connection is used.
6586
6587With sufficiently modern LDAP libraries, Exim supports forcing TLS over regular
6588LDAP connections, rather than the SSL-on-connect "ldaps". See the
6589ldap_start_tls option.
6590
6591Starting with Exim 4.83, the initialization of LDAP with TLS is more tightly
6592controlled. Every part of the TLS configuration can be configured by settings
6593in exim.conf. Depending on the version of the client libraries installed on
6594your system, some of the initialization may have required setting options in /
6595etc/ldap.conf or ~/.ldaprc to get TLS working with self-signed certificates.
6596This revealed a nuance where the current UID that exim was running as could
6597affect which config files it read. With Exim 4.83, these methods become
6598optional, only taking effect if not specifically set in exim.conf.
6599
6600
66019.15 LDAP quoting
6602-----------------
6603
6604Two levels of quoting are required in LDAP queries, the first for LDAP itself
6605and the second because the LDAP query is represented as a URL. Furthermore,
6606within an LDAP query, two different kinds of quoting are required. For this
6607reason, there are two different LDAP-specific quoting operators.
6608
6609The quote_ldap operator is designed for use on strings that are part of filter
6610specifications. Conceptually, it first does the following conversions on the
6611string:
6612
6613* => \2A
6614( => \28
6615) => \29
6616\ => \5C
6617
6618in accordance with RFC 2254. The resulting string is then quoted according to
6619the rules for URLs, that is, all non-alphanumeric characters except
6620
6621! $ ' - . _ ( ) * +
6622
6623are converted to their hex values, preceded by a percent sign. For example:
6624
6625${quote_ldap: a(bc)*, a<yz>; }
6626
6627yields
6628
6629%20a%5C28bc%5C29%5C2A%2C%20a%3Cyz%3E%3B%20
6630
6631Removing the URL quoting, this is (with a leading and a trailing space):
6632
6633a\28bc\29\2A, a<yz>;
6634
6635The quote_ldap_dn operator is designed for use on strings that are part of base
6636DN specifications in queries. Conceptually, it first converts the string by
6637inserting a backslash in front of any of the following characters:
6638
6639, + " \ < > ;
6640
6641It also inserts a backslash before any leading spaces or # characters, and
6642before any trailing spaces. (These rules are in RFC 2253.) The resulting string
6643is then quoted according to the rules for URLs. For example:
6644
6645${quote_ldap_dn: a(bc)*, a<yz>; }
6646
6647yields
6648
6649%5C%20a(bc)*%5C%2C%20a%5C%3Cyz%5C%3E%5C%3B%5C%20
6650
6651Removing the URL quoting, this is (with a trailing space):
6652
6653\ a(bc)*\, a\<yz\>\;\
6654
6655There are some further comments about quoting in the section on LDAP
6656authentication below.
6657
6658
66599.16 LDAP connections
6660---------------------
6661
6662The connection to an LDAP server may either be over TCP/IP, or, when OpenLDAP
6663is in use, via a Unix domain socket. The example given above does not specify
6664an LDAP server. A server that is reached by TCP/IP can be specified in a query
6665by starting it with
6666
6667ldap://<hostname>:<port>/...
6668
6669If the port (and preceding colon) are omitted, the standard LDAP port (389) is
6670used. When no server is specified in a query, a list of default servers is
6671taken from the ldap_default_servers configuration option. This supplies a
6672colon-separated list of servers which are tried in turn until one successfully
6673handles a query, or there is a serious error. Successful handling either
6674returns the requested data, or indicates that it does not exist. Serious errors
6675are syntactical, or multiple values when only a single value is expected.
6676Errors which cause the next server to be tried are connection failures, bind
6677failures, and timeouts.
6678
6679For each server name in the list, a port number can be given. The standard way
6680of specifying a host and port is to use a colon separator (RFC 1738). Because
6681ldap_default_servers is a colon-separated list, such colons have to be doubled.
6682For example
6683
6684ldap_default_servers = ldap1.example.com::145:ldap2.example.com
6685
6686If ldap_default_servers is unset, a URL with no server name is passed to the
6687LDAP library with no server name, and the library's default (normally the local
6688host) is used.
6689
6690If you are using the OpenLDAP library, you can connect to an LDAP server using
6691a Unix domain socket instead of a TCP/IP connection. This is specified by using
6692"ldapi" instead of "ldap" in LDAP queries. What follows here applies only to
6693OpenLDAP. If Exim is compiled with a different LDAP library, this feature is
6694not available.
6695
6696For this type of connection, instead of a host name for the server, a pathname
6697for the socket is required, and the port number is not relevant. The pathname
6698can be specified either as an item in ldap_default_servers, or inline in the
6699query. In the former case, you can have settings such as
6700
6701ldap_default_servers = /tmp/ldap.sock : backup.ldap.your.domain
6702
6703When the pathname is given in the query, you have to escape the slashes as
6704"%2F" to fit in with the LDAP URL syntax. For example:
6705
6706${lookup ldap {ldapi://%2Ftmp%2Fldap.sock/o=...
6707
6708When Exim processes an LDAP lookup and finds that the "hostname" is really a
6709pathname, it uses the Unix domain socket code, even if the query actually
6710specifies "ldap" or "ldaps". In particular, no encryption is used for a socket
6711connection. This behaviour means that you can use a setting of
6712ldap_default_servers such as in the example above with traditional "ldap" or
6713"ldaps" queries, and it will work. First, Exim tries a connection via the Unix
6714domain socket; if that fails, it tries a TCP/IP connection to the backup host.
6715
6716If an explicit "ldapi" type is given in a query when a host name is specified,
6717an error is diagnosed. However, if there are more items in ldap_default_servers
6718, they are tried. In other words:
6719
6720 * Using a pathname with "ldap" or "ldaps" forces the use of the Unix domain
6721 interface.
6722
6723 * Using "ldapi" with a host name causes an error.
6724
6725Using "ldapi" with no host or path in the query, and no setting of
6726ldap_default_servers, does whatever the library does by default.
6727
6728
67299.17 LDAP authentication and control information
6730------------------------------------------------
6731
6732The LDAP URL syntax provides no way of passing authentication and other control
6733information to the server. To make this possible, the URL in an LDAP query may
6734be preceded by any number of <name>=<value> settings, separated by spaces. If a
6735value contains spaces it must be enclosed in double quotes, and when double
6736quotes are used, backslash is interpreted in the usual way inside them. The
6737following names are recognized:
6738
6739DEREFERENCE set the dereferencing parameter
6740NETTIME set a timeout for a network operation
6741USER set the DN, for authenticating the LDAP bind
6742PASS set the password, likewise
6743REFERRALS set the referrals parameter
6744SERVERS set alternate server list for this query only
6745SIZE set the limit for the number of entries returned
6746TIME set the maximum waiting time for a query
6747
6748The value of the DEREFERENCE parameter must be one of the words "never",
6749"searching", "finding", or "always". The value of the REFERRALS parameter must
6750be "follow" (the default) or "nofollow". The latter stops the LDAP library from
6751trying to follow referrals issued by the LDAP server.
6752
6753The name CONNECT is an obsolete name for NETTIME, retained for backwards
6754compatibility. This timeout (specified as a number of seconds) is enforced from
6755the client end for operations that can be carried out over a network.
6756Specifically, it applies to network connections and calls to the ldap_result()
6757function. If the value is greater than zero, it is used if
6758LDAP_OPT_NETWORK_TIMEOUT is defined in the LDAP headers (OpenLDAP), or if
6759LDAP_X_OPT_CONNECT_TIMEOUT is defined in the LDAP headers (Netscape SDK 4.1). A
6760value of zero forces an explicit setting of "no timeout" for Netscape SDK; for
6761OpenLDAP no action is taken.
6762
6763The TIME parameter (also a number of seconds) is passed to the server to set a
6764server-side limit on the time taken to complete a search.
6765
6766The SERVERS parameter allows you to specify an alternate list of ldap servers
6767to use for an individual lookup. The global ldap_servers option provides a
6768default list of ldap servers, and a single lookup can specify a single ldap
6769server to use. But when you need to do a lookup with a list of servers that is
6770different than the default list (maybe different order, maybe a completely
6771different set of servers), the SERVERS parameter allows you to specify this
6772alternate list.
6773
6774Here is an example of an LDAP query in an Exim lookup that uses some of these
6775values. This is a single line, folded to fit on the page:
6776
6777${lookup ldap
6778 {user="cn=manager,o=University of Cambridge,c=UK" pass=secret
6779 ldap:///o=University%20of%20Cambridge,c=UK?sn?sub?(cn=foo)}
6780 {$value}fail}
6781
6782The encoding of spaces as "%20" is a URL thing which should not be done for any
6783of the auxiliary data. Exim configuration settings that include lookups which
6784contain password information should be preceded by "hide" to prevent non-admin
6785users from using the -bP option to see their values.
6786
6787The auxiliary data items may be given in any order. The default is no
6788connection timeout (the system timeout is used), no user or password, no limit
6789on the number of entries returned, and no time limit on queries.
6790
6791When a DN is quoted in the USER= setting for LDAP authentication, Exim removes
6792any URL quoting that it may contain before passing it LDAP. Apparently some
6793libraries do this for themselves, but some do not. Removing the URL quoting has
6794two advantages:
6795
6796 * It makes it possible to use the same quote_ldap_dn expansion for USER= DNs
6797 as with DNs inside actual queries.
6798
6799 * It permits spaces inside USER= DNs.
6800
6801For example, a setting such as
6802
6803USER=cn=${quote_ldap_dn:$1}
6804
6805should work even if $1 contains spaces.
6806
6807Expanded data for the PASS= value should be quoted using the quote expansion
6808operator, rather than the LDAP quote operators. The only reason this field
6809needs quoting is to ensure that it conforms to the Exim syntax, which does not
6810allow unquoted spaces. For example:
6811
6812PASS=${quote:$3}
6813
6814The LDAP authentication mechanism can be used to check passwords as part of
6815SMTP authentication. See the ldapauth expansion string condition in chapter 11.
6816
6817
68189.18 Format of data returned by LDAP
6819------------------------------------
6820
6821The ldapdn lookup type returns the Distinguished Name from a single entry as a
6822sequence of values, for example
6823
6824cn=manager, o=University of Cambridge, c=UK
6825
6826The ldap lookup type generates an error if more than one entry matches the
6827search filter, whereas ldapm permits this case, and inserts a newline in the
6828result between the data from different entries. It is possible for multiple
6829values to be returned for both ldap and ldapm, but in the former case you know
6830that whatever values are returned all came from a single entry in the
6831directory.
6832
6833In the common case where you specify a single attribute in your LDAP query, the
6834result is not quoted, and does not contain the attribute name. If the attribute
6835has multiple values, they are separated by commas.
6836
6837If you specify multiple attributes, the result contains space-separated, quoted
6838strings, each preceded by the attribute name and an equals sign. Within the
6839quotes, the quote character, backslash, and newline are escaped with
6840backslashes, and commas are used to separate multiple values for the attribute.
6841Apart from the escaping, the string within quotes takes the same form as the
6842output when a single attribute is requested. Specifying no attributes is the
6843same as specifying all of an entry's attributes.
6844
6845Here are some examples of the output format. The first line of each pair is an
6846LDAP query, and the second is the data that is returned. The attribute called
6847attr1 has two values, whereas attr2 has only one value:
6848
6849ldap:///o=base?attr1?sub?(uid=fred)
6850value1.1, value1.2
6851
6852ldap:///o=base?attr2?sub?(uid=fred)
6853value two
6854
6855ldap:///o=base?attr1,attr2?sub?(uid=fred)
6856attr1="value1.1, value1.2" attr2="value two"
6857
6858ldap:///o=base??sub?(uid=fred)
6859objectClass="top" attr1="value1.1, value1.2" attr2="value two"
6860
6861The extract operator in string expansions can be used to pick out individual
6862fields from data that consists of key=value pairs. You can make use of Exim's
6863-be option to run expansion tests and thereby check the results of LDAP
6864lookups.
6865
6866
68679.19 More about NIS+
6868--------------------
6869
6870NIS+ queries consist of a NIS+ indexed name followed by an optional colon and
6871field name. If this is given, the result of a successful query is the contents
6872of the named field; otherwise the result consists of a concatenation of
6873field-name=field-value pairs, separated by spaces. Empty values and values
6874containing spaces are quoted. For example, the query
6875
6876[name=mg1456],passwd.org_dir
6877
6878might return the string
6879
6880name=mg1456 passwd="" uid=999 gid=999 gcos="Martin Guerre"
6881home=/home/mg1456 shell=/bin/bash shadow=""
6882
6883(split over two lines here to fit on the page), whereas
6884
6885[name=mg1456],passwd.org_dir:gcos
6886
6887would just return
6888
6889Martin Guerre
6890
6891with no quotes. A NIS+ lookup fails if NIS+ returns more than one table entry
6892for the given indexed key. The effect of the quote_nisplus expansion operator
6893is to double any quote characters within the text.
6894
6895
68969.20 SQL lookups
6897----------------
6898
6899Exim can support lookups in InterBase, MySQL, Oracle, PostgreSQL, and SQLite
6900databases. Queries for these databases contain SQL statements, so an example
6901might be
6902
6903${lookup mysql{select mailbox from users where id='userx'}\
6904 {$value}fail}
6905
6906If the result of the query contains more than one field, the data for each
6907field in the row is returned, preceded by its name, so the result of
6908
6909${lookup pgsql{select home,name from users where id='userx'}\
6910 {$value}}
6911
6912might be
6913
6914home=/home/userx name="Mister X"
6915
6916Empty values and values containing spaces are double quoted, with embedded
6917quotes escaped by a backslash. If the result of the query contains just one
6918field, the value is passed back verbatim, without a field name, for example:
6919
6920Mister X
6921
6922If the result of the query yields more than one row, it is all concatenated,
6923with a newline between the data for each row.
6924
6925
69269.21 More about MySQL, PostgreSQL, Oracle, and InterBase
6927--------------------------------------------------------
6928
6929If any MySQL, PostgreSQL, Oracle, or InterBase lookups are used, the
6930mysql_servers, pgsql_servers, oracle_servers, or ibase_servers option (as
6931appropriate) must be set to a colon-separated list of server information. (For
6932MySQL and PostgreSQL only, the global option need not be set if all queries
6933contain their own server information - see section 9.22.) Each item in the list
6934is a slash-separated list of four items: host name, database name, user name,
6935and password. In the case of Oracle, the host name field is used for the
6936"service name", and the database name field is not used and should be empty.
6937For example:
6938
6939hide oracle_servers = oracle.plc.example//userx/abcdwxyz
6940
6941Because password data is sensitive, you should always precede the setting with
6942"hide", to prevent non-admin users from obtaining the setting via the -bP
6943option. Here is an example where two MySQL servers are listed:
6944
6945hide mysql_servers = localhost/users/root/secret:\
6946 otherhost/users/root/othersecret
6947
6948For MySQL and PostgreSQL, a host may be specified as <name>:<port> but because
6949this is a colon-separated list, the colon has to be doubled. For each query,
6950these parameter groups are tried in order until a connection is made and a
6951query is successfully processed. The result of a query may be that no data is
6952found, but that is still a successful query. In other words, the list of
6953servers provides a backup facility, not a list of different places to look.
6954
6955The quote_mysql, quote_pgsql, and quote_oracle expansion operators convert
6956newline, tab, carriage return, and backspace to \n, \t, \r, and \b
6957respectively, and the characters single-quote, double-quote, and backslash
6958itself are escaped with backslashes. The quote_pgsql expansion operator, in
6959addition, escapes the percent and underscore characters. This cannot be done
6960for MySQL because these escapes are not recognized in contexts where these
6961characters are not special.
6962
6963
69649.22 Specifying the server in the query
6965---------------------------------------
6966
6967For MySQL and PostgreSQL lookups (but not currently for Oracle and InterBase),
6968it is possible to specify a list of servers with an individual query. This is
6969done by starting the query with
6970
6971servers=server1:server2:server3:...;
6972
6973Each item in the list may take one of two forms:
6974
6975 1. If it contains no slashes it is assumed to be just a host name. The
6976 appropriate global option (mysql_servers or pgsql_servers) is searched for
6977 a host of the same name, and the remaining parameters (database, user,
6978 password) are taken from there.
6979
6980 2. If it contains any slashes, it is taken as a complete parameter set.
6981
6982The list of servers is used in exactly the same way as the global list. Once a
6983connection to a server has happened and a query has been successfully executed,
6984processing of the lookup ceases.
6985
6986This feature is intended for use in master/slave situations where updates are
6987occurring and you want to update the master rather than a slave. If the master
6988is in the list as a backup for reading, you might have a global setting like
6989this:
6990
6991mysql_servers = slave1/db/name/pw:\
6992 slave2/db/name/pw:\
6993 master/db/name/pw
6994
6995In an updating lookup, you could then write:
6996
6997${lookup mysql{servers=master; UPDATE ...} }
6998
6999That query would then be sent only to the master server. If, on the other hand,
7000the master is not to be used for reading, and so is not present in the global
7001option, you can still update it by a query of this form:
7002
7003${lookup pgsql{servers=master/db/name/pw; UPDATE ...} }
7004
7005
70069.23 Special MySQL features
7007---------------------------
7008
7009For MySQL, an empty host name or the use of "localhost" in mysql_servers causes
7010a connection to the server on the local host by means of a Unix domain socket.
7011An alternate socket can be specified in parentheses. The full syntax of each
7012item in mysql_servers is:
7013
7014<hostname>::<port>(<socket name>)/<database>/<user>/<password>
7015
7016Any of the three sub-parts of the first field can be omitted. For normal use on
7017the local host it can be left blank or set to just "localhost".
7018
7019No database need be supplied - but if it is absent here, it must be given in
7020the queries.
7021
7022If a MySQL query is issued that does not request any data (an insert, update,
7023or delete command), the result of the lookup is the number of rows affected.
7024
7025Warning: This can be misleading. If an update does not actually change anything
7026(for example, setting a field to the value it already has), the result is zero
7027because no rows are affected.
7028
7029
70309.24 Special PostgreSQL features
7031--------------------------------
7032
7033PostgreSQL lookups can also use Unix domain socket connections to the database.
7034This is usually faster and costs less CPU time than a TCP/IP connection.
7035However it can be used only if the mail server runs on the same machine as the
7036database server. A configuration line for PostgreSQL via Unix domain sockets
7037looks like this:
7038
7039hide pgsql_servers = (/tmp/.s.PGSQL.5432)/db/user/password : ...
7040
7041In other words, instead of supplying a host name, a path to the socket is
7042given. The path name is enclosed in parentheses so that its slashes aren't
7043visually confused with the delimiters for the other server parameters.
7044
7045If a PostgreSQL query is issued that does not request any data (an insert,
7046update, or delete command), the result of the lookup is the number of rows
7047affected.
7048
7049
70509.25 More about SQLite
7051----------------------
7052
7053SQLite is different to the other SQL lookups because a file name is required in
7054addition to the SQL query. An SQLite database is a single file, and there is no
7055daemon as in the other SQL databases. The interface to Exim requires the name
7056of the file, as an absolute path, to be given at the start of the query. It is
7057separated from the query by white space. This means that the path name cannot
7058contain white space. Here is a lookup expansion example:
7059
7060${lookup sqlite {/some/thing/sqlitedb \
7061 select name from aliases where id='userx';}}
7062
7063In a list, the syntax is similar. For example:
7064
7065domainlist relay_to_domains = sqlite;/some/thing/sqlitedb \
7066 select * from relays where ip='$sender_host_address';
7067
7068The only character affected by the quote_sqlite operator is a single quote,
7069which it doubles.
7070
7071The SQLite library handles multiple simultaneous accesses to the database
7072internally. Multiple readers are permitted, but only one process can update at
7073once. Attempts to access the database while it is being updated are rejected
7074after a timeout period, during which the SQLite library waits for the lock to
7075be released. In Exim, the default timeout is set to 5 seconds, but it can be
7076changed by means of the sqlite_lock_timeout option.
7077
7078
7079
7080===============================================================================
708110. DOMAIN, HOST, ADDRESS, AND LOCAL PART LISTS
7082
7083A number of Exim configuration options contain lists of domains, hosts, email
7084addresses, or local parts. For example, the hold_domains option contains a list
7085of domains whose delivery is currently suspended. These lists are also used as
7086data in ACL statements (see chapter 42), and as arguments to expansion
7087conditions such as match_domain.
7088
7089Each item in one of these lists is a pattern to be matched against a domain,
7090host, email address, or local part, respectively. In the sections below, the
7091different types of pattern for each case are described, but first we cover some
7092general facilities that apply to all four kinds of list.
7093
7094
709510.1 Expansion of lists
7096-----------------------
7097
7098Each list is expanded as a single string before it is used. The result of
7099expansion must be a list, possibly containing empty items, which is split up
7100into separate items for matching. By default, colon is the separator character,
7101but this can be varied if necessary. See sections 6.19 and 6.21 for details of
7102the list syntax; the second of these discusses the way to specify empty list
7103items.
7104
7105If the string expansion is forced to fail, Exim behaves as if the item it is
7106testing (domain, host, address, or local part) is not in the list. Other
7107expansion failures cause temporary errors.
7108
7109If an item in a list is a regular expression, backslashes, dollars and possibly
7110other special characters in the expression must be protected against
7111misinterpretation by the string expander. The easiest way to do this is to use
7112the "\N" expansion feature to indicate that the contents of the regular
7113expression should not be expanded. For example, in an ACL you might have:
7114
7115deny senders = \N^\d{8}\w@.*\.baddomain\.example$\N : \
7116 ${lookup{$domain}lsearch{/badsenders/bydomain}}
7117
7118The first item is a regular expression that is protected from expansion by "\
7119N", whereas the second uses the expansion to obtain a list of unwanted senders
7120based on the receiving domain.
7121
7122
712310.2 Negated items in lists
7124---------------------------
7125
7126Items in a list may be positive or negative. Negative items are indicated by a
7127leading exclamation mark, which may be followed by optional white space. A list
7128defines a set of items (domains, etc). When Exim processes one of these lists,
7129it is trying to find out whether a domain, host, address, or local part
7130(respectively) is in the set that is defined by the list. It works like this:
7131
7132The list is scanned from left to right. If a positive item is matched, the
7133subject that is being checked is in the set; if a negative item is matched, the
7134subject is not in the set. If the end of the list is reached without the
7135subject having matched any of the patterns, it is in the set if the last item
7136was a negative one, but not if it was a positive one. For example, the list in
7137
7138domainlist relay_to_domains = !a.b.c : *.b.c
7139
7140matches any domain ending in .b.c except for a.b.c. Domains that match neither
7141a.b.c nor *.b.c do not match, because the last item in the list is positive.
7142However, if the setting were
7143
7144domainlist relay_to_domains = !a.b.c
7145
7146then all domains other than a.b.c would match because the last item in the list
7147is negative. In other words, a list that ends with a negative item behaves as
7148if it had an extra item ":*" on the end.
7149
7150Another way of thinking about positive and negative items in lists is to read
7151the connector as "or" after a positive item and as "and" after a negative item.
7152
7153
715410.3 File names in lists
7155------------------------
7156
7157If an item in a domain, host, address, or local part list is an absolute file
7158name (beginning with a slash character), each line of the file is read and
7159processed as if it were an independent item in the list, except that further
7160file names are not allowed, and no expansion of the data from the file takes
7161place. Empty lines in the file are ignored, and the file may also contain
7162comment lines:
7163
7164 * For domain and host lists, if a # character appears anywhere in a line of
7165 the file, it and all following characters are ignored.
7166
7167 * Because local parts may legitimately contain # characters, a comment in an
7168 address list or local part list file is recognized only if # is preceded by
7169 white space or the start of the line. For example:
7170
7171 not#comment@x.y.z # but this is a comment
7172
7173Putting a file name in a list has the same effect as inserting each line of the
7174file as an item in the list (blank lines and comments excepted). However, there
7175is one important difference: the file is read each time the list is processed,
7176so if its contents vary over time, Exim's behaviour changes.
7177
7178If a file name is preceded by an exclamation mark, the sense of any match
7179within the file is inverted. For example, if
7180
7181hold_domains = !/etc/nohold-domains
7182
7183and the file contains the lines
7184
7185!a.b.c
7186*.b.c
7187
7188then a.b.c is in the set of domains defined by hold_domains, whereas any domain
7189matching "*.b.c" is not.
7190
7191
719210.4 An lsearch file is not an out-of-line list
7193-----------------------------------------------
7194
7195As will be described in the sections that follow, lookups can be used in lists
7196to provide indexed methods of checking list membership. There has been some
7197confusion about the way lsearch lookups work in lists. Because an lsearch file
7198contains plain text and is scanned sequentially, it is sometimes thought that
7199it is allowed to contain wild cards and other kinds of non-constant pattern.
7200This is not the case. The keys in an lsearch file are always fixed strings,
7201just as for any other single-key lookup type.
7202
7203If you want to use a file to contain wild-card patterns that form part of a
7204list, just give the file name on its own, without a search type, as described
7205in the previous section. You could also use the wildlsearch or nwildlsearch,
7206but there is no advantage in doing this.
7207
7208
720910.5 Named lists
7210----------------
7211
7212A list of domains, hosts, email addresses, or local parts can be given a name
7213which is then used to refer to the list elsewhere in the configuration. This is
7214particularly convenient if the same list is required in several different
7215places. It also allows lists to be given meaningful names, which can improve
7216the readability of the configuration. For example, it is conventional to define
7217a domain list called local_domains for all the domains that are handled locally
7218on a host, using a configuration line such as
7219
7220domainlist local_domains = localhost:my.dom.example
7221
7222Named lists are referenced by giving their name preceded by a plus sign, so,
7223for example, a router that is intended to handle local domains would be
7224configured with the line
7225
7226domains = +local_domains
7227
7228The first router in a configuration is often one that handles all domains
7229except the local ones, using a configuration with a negated item like this:
7230
7231dnslookup:
7232 driver = dnslookup
7233 domains = ! +local_domains
7234 transport = remote_smtp
7235 no_more
7236
7237The four kinds of named list are created by configuration lines starting with
7238the words domainlist, hostlist, addresslist, or localpartlist, respectively.
7239Then there follows the name that you are defining, followed by an equals sign
7240and the list itself. For example:
7241
7242hostlist relay_from_hosts = 192.168.23.0/24 : my.friend.example
7243addresslist bad_senders = cdb;/etc/badsenders
7244
7245A named list may refer to other named lists:
7246
7247domainlist dom1 = first.example : second.example
7248domainlist dom2 = +dom1 : third.example
7249domainlist dom3 = fourth.example : +dom2 : fifth.example
7250
7251Warning: If the last item in a referenced list is a negative one, the effect
7252may not be what you intended, because the negation does not propagate out to
7253the higher level. For example, consider:
7254
7255domainlist dom1 = !a.b
7256domainlist dom2 = +dom1 : *.b
7257
7258The second list specifies "either in the dom1 list or *.b". The first list
7259specifies just "not a.b", so the domain x.y matches it. That means it matches
7260the second list as well. The effect is not the same as
7261
7262domainlist dom2 = !a.b : *.b
7263
7264where x.y does not match. It's best to avoid negation altogether in referenced
7265lists if you can.
7266
7267Named lists may have a performance advantage. When Exim is routing an address
7268or checking an incoming message, it caches the result of tests on named lists.
7269So, if you have a setting such as
7270
7271domains = +local_domains
7272
7273on several of your routers or in several ACL statements, the actual test is
7274done only for the first one. However, the caching works only if there are no
7275expansions within the list itself or any sublists that it references. In other
7276words, caching happens only for lists that are known to be the same each time
7277they are referenced.
7278
7279By default, there may be up to 16 named lists of each type. This limit can be
7280extended by changing a compile-time variable. The use of domain and host lists
7281is recommended for concepts such as local domains, relay domains, and relay
7282hosts. The default configuration is set up like this.
7283
7284
728510.6 Named lists compared with macros
7286-------------------------------------
7287
7288At first sight, named lists might seem to be no different from macros in the
7289configuration file. However, macros are just textual substitutions. If you
7290write
7291
7292ALIST = host1 : host2
7293auth_advertise_hosts = !ALIST
7294
7295it probably won't do what you want, because that is exactly the same as
7296
7297auth_advertise_hosts = !host1 : host2
7298
7299Notice that the second host name is not negated. However, if you use a host
7300list, and write
7301
7302hostlist alist = host1 : host2
7303auth_advertise_hosts = ! +alist
7304
7305the negation applies to the whole list, and so that is equivalent to
7306
7307auth_advertise_hosts = !host1 : !host2
7308
7309
731010.7 Named list caching
7311-----------------------
7312
7313While processing a message, Exim caches the result of checking a named list if
7314it is sure that the list is the same each time. In practice, this means that
7315the cache operates only if the list contains no $ characters, which guarantees
7316that it will not change when it is expanded. Sometimes, however, you may have
7317an expanded list that you know will be the same each time within a given
7318message. For example:
7319
7320domainlist special_domains = \
7321 ${lookup{$sender_host_address}cdb{/some/file}}
7322
7323This provides a list of domains that depends only on the sending host's IP
7324address. If this domain list is referenced a number of times (for example, in
7325several ACL lines, or in several routers) the result of the check is not cached
7326by default, because Exim does not know that it is going to be the same list
7327each time.
7328
7329By appending "_cache" to "domainlist" you can tell Exim to go ahead and cache
7330the result anyway. For example:
7331
7332domainlist_cache special_domains = ${lookup{...
7333
7334If you do this, you should be absolutely sure that caching is going to do the
7335right thing in all cases. When in doubt, leave it out.
7336
7337
733810.8 Domain lists
7339-----------------
7340
7341Domain lists contain patterns that are to be matched against a mail domain. The
7342following types of item may appear in domain lists:
7343
7344 * If a pattern consists of a single @ character, it matches the local host
7345 name, as set by the primary_hostname option (or defaulted). This makes it
7346 possible to use the same configuration file on several different hosts that
7347 differ only in their names.
7348
7349 * If a pattern consists of the string "@[]" it matches an IP address enclosed
7350 in square brackets (as in an email address that contains a domain literal),
7351 but only if that IP address is recognized as local for email routing
7352 purposes. The local_interfaces and extra_local_interfaces options can be
7353 used to control which of a host's several IP addresses are treated as
7354 local. In today's Internet, the use of domain literals is controversial.
7355
7356 * If a pattern consists of the string "@mx_any" it matches any domain that
7357 has an MX record pointing to the local host or to any host that is listed
7358 in hosts_treat_as_local. The items "@mx_primary" and "@mx_secondary" are
7359 similar, except that the first matches only when a primary MX target is the
7360 local host, and the second only when no primary MX target is the local
7361 host, but a secondary MX target is. "Primary" means an MX record with the
7362 lowest preference value - there may of course be more than one of them.
7363
7364 The MX lookup that takes place when matching a pattern of this type is
7365 performed with the resolver options for widening names turned off. Thus,
7366 for example, a single-component domain will not be expanded by adding the
7367 resolver's default domain. See the qualify_single and search_parents
7368 options of the dnslookup router for a discussion of domain widening.
7369
7370 Sometimes you may want to ignore certain IP addresses when using one of
7371 these patterns. You can specify this by following the pattern with "/ignore
7372 ="<ip list>, where <ip list> is a list of IP addresses. These addresses are
7373 ignored when processing the pattern (compare the ignore_target_hosts option
7374 on a router). For example:
7375
7376 domains = @mx_any/ignore=127.0.0.1
7377
7378 This example matches any domain that has an MX record pointing to one of
7379 the local host's IP addresses other than 127.0.0.1.
7380
7381 The list of IP addresses is in fact processed by the same code that
7382 processes host lists, so it may contain CIDR-coded network specifications
7383 and it may also contain negative items.
7384
7385 Because the list of IP addresses is a sublist within a domain list, you
7386 have to be careful about delimiters if there is more than one address. Like
7387 any other list, the default delimiter can be changed. Thus, you might have:
7388
7389 domains = @mx_any/ignore=<;127.0.0.1;0.0.0.0 : \
7390 an.other.domain : ...
7391
7392 so that the sublist uses semicolons for delimiters. When IPv6 addresses are
7393 involved, it is easiest to change the delimiter for the main list as well:
7394
7395 domains = <? @mx_any/ignore=<;127.0.0.1;::1 ? \
7396 an.other.domain ? ...
7397
7398 * If a pattern starts with an asterisk, the remaining characters of the
7399 pattern are compared with the terminating characters of the domain. The use
7400 of "*" in domain lists differs from its use in partial matching lookups. In
7401 a domain list, the character following the asterisk need not be a dot,
7402 whereas partial matching works only in terms of dot-separated components.
7403 For example, a domain list item such as "*key.ex" matches donkey.ex as well
7404 as cipher.key.ex.
7405
7406 * If a pattern starts with a circumflex character, it is treated as a regular
7407 expression, and matched against the domain using a regular expression
7408 matching function. The circumflex is treated as part of the regular
7409 expression. Email domains are case-independent, so this regular expression
7410 match is by default case-independent, but you can make it case-dependent by
7411 starting it with "(?-i)". References to descriptions of the syntax of
7412 regular expressions are given in chapter 8.
7413
7414 Warning: Because domain lists are expanded before being processed, you must
7415 escape any backslash and dollar characters in the regular expression, or
7416 use the special "\N" sequence (see chapter 11) to specify that it is not to
7417 be expanded (unless you really do want to build a regular expression by
7418 expansion, of course).
7419
7420 * If a pattern starts with the name of a single-key lookup type followed by a
7421 semicolon (for example, "dbm;" or "lsearch;"), the remainder of the pattern
7422 must be a file name in a suitable format for the lookup type. For example,
7423 for "cdb;" it must be an absolute path:
7424
7425 domains = cdb;/etc/mail/local_domains.cdb
7426
7427 The appropriate type of lookup is done on the file using the domain name as
7428 the key. In most cases, the data that is looked up is not used; Exim is
7429 interested only in whether or not the key is present in the file. However,
7430 when a lookup is used for the domains option on a router or a domains
7431 condition in an ACL statement, the data is preserved in the $domain_data
7432 variable and can be referred to in other router options or other statements
7433 in the same ACL.
7434
7435 * Any of the single-key lookup type names may be preceded by "partial"<n>"-",
7436 where the <n> is optional, for example,
7437
7438 domains = partial-dbm;/partial/domains
7439
7440 This causes partial matching logic to be invoked; a description of how this
7441 works is given in section 9.7.
7442
7443 * Any of the single-key lookup types may be followed by an asterisk. This
7444 causes a default lookup for a key consisting of a single asterisk to be
7445 done if the original lookup fails. This is not a useful feature when using
7446 a domain list to select particular domains (because any domain would
7447 match), but it might have value if the result of the lookup is being used
7448 via the $domain_data expansion variable.
7449
7450 * If the pattern starts with the name of a query-style lookup type followed
7451 by a semicolon (for example, "nisplus;" or "ldap;"), the remainder of the
7452 pattern must be an appropriate query for the lookup type, as described in
7453 chapter 9. For example:
7454
7455 hold_domains = mysql;select domain from holdlist \
7456 where domain = '${quote_mysql:$domain}';
7457
7458 In most cases, the data that is looked up is not used (so for an SQL query,
7459 for example, it doesn't matter what field you select). Exim is interested
7460 only in whether or not the query succeeds. However, when a lookup is used
7461 for the domains option on a router, the data is preserved in the
7462 $domain_data variable and can be referred to in other options.
7463
7464 * If none of the above cases apply, a caseless textual comparison is made
7465 between the pattern and the domain.
7466
7467Here is an example that uses several different kinds of pattern:
7468
7469domainlist funny_domains = \
7470 @ : \
7471 lib.unseen.edu : \
7472 *.foundation.fict.example : \
7473 \N^[1-2]\d{3}\.fict\.example$\N : \
7474 partial-dbm;/opt/data/penguin/book : \
7475 nis;domains.byname : \
7476 nisplus;[name=$domain,status=local],domains.org_dir
7477
7478There are obvious processing trade-offs among the various matching modes. Using
7479an asterisk is faster than a regular expression, and listing a few names
7480explicitly probably is too. The use of a file or database lookup is expensive,
7481but may be the only option if hundreds of names are required. Because the
7482patterns are tested in order, it makes sense to put the most commonly matched
7483patterns earlier.
7484
7485
748610.9 Host lists
7487---------------
7488
7489Host lists are used to control what remote hosts are allowed to do. For
7490example, some hosts may be allowed to use the local host as a relay, and some
7491may be permitted to use the SMTP ETRN command. Hosts can be identified in two
7492different ways, by name or by IP address. In a host list, some types of pattern
7493are matched to a host name, and some are matched to an IP address. You need to
7494be particularly careful with this when single-key lookups are involved, to
7495ensure that the right value is being used as the key.
7496
7497
749810.10 Special host list patterns
7499--------------------------------
7500
7501If a host list item is the empty string, it matches only when no remote host is
7502involved. This is the case when a message is being received from a local
7503process using SMTP on the standard input, that is, when a TCP/IP connection is
7504not used.
7505
7506The special pattern "*" in a host list matches any host or no host. Neither the
7507IP address nor the name is actually inspected.
7508
7509
751010.11 Host list patterns that match by IP address
7511-------------------------------------------------
7512
7513If an IPv4 host calls an IPv6 host and the call is accepted on an IPv6 socket,
7514the incoming address actually appears in the IPv6 host as "::ffff:"<v4address>.
7515When such an address is tested against a host list, it is converted into a
7516traditional IPv4 address first. (Not all operating systems accept IPv4 calls on
7517IPv6 sockets, as there have been some security concerns.)
7518
7519The following types of pattern in a host list check the remote host by
7520inspecting its IP address:
7521
7522 * If the pattern is a plain domain name (not a regular expression, not
7523 starting with *, not a lookup of any kind), Exim calls the operating system
7524 function to find the associated IP address(es). Exim uses the newer
7525 getipnodebyname() function when available, otherwise gethostbyname(). This
7526 typically causes a forward DNS lookup of the name. The result is compared
7527 with the IP address of the subject host.
7528
7529 If there is a temporary problem (such as a DNS timeout) with the host name
7530 lookup, a temporary error occurs. For example, if the list is being used in
7531 an ACL condition, the ACL gives a "defer" response, usually leading to a
7532 temporary SMTP error code. If no IP address can be found for the host name,
7533 what happens is described in section 10.14 below.
7534
7535 * If the pattern is "@", the primary host name is substituted and used as a
7536 domain name, as just described.
7537
7538 * If the pattern is an IP address, it is matched against the IP address of
7539 the subject host. IPv4 addresses are given in the normal "dotted-quad"
7540 notation. IPv6 addresses can be given in colon-separated format, but the
7541 colons have to be doubled so as not to be taken as item separators when the
7542 default list separator is used. IPv6 addresses are recognized even when
7543 Exim is compiled without IPv6 support. This means that if they appear in a
7544 host list on an IPv4-only host, Exim will not treat them as host names.
7545 They are just addresses that can never match a client host.
7546
7547 * If the pattern is "@[]", it matches the IP address of any IP interface on
7548 the local host. For example, if the local host is an IPv4 host with one
7549 interface address 10.45.23.56, these two ACL statements have the same
7550 effect:
7551
7552 accept hosts = 127.0.0.1 : 10.45.23.56
7553 accept hosts = @[]
7554
7555 * If the pattern is an IP address followed by a slash and a mask length (for
7556 example 10.11.42.0/24), it is matched against the IP address of the subject
7557 host under the given mask. This allows, an entire network of hosts to be
7558 included (or excluded) by a single item. The mask uses CIDR notation; it
7559 specifies the number of address bits that must match, starting from the
7560 most significant end of the address.
7561
7562 Note: The mask is not a count of addresses, nor is it the high number of a
7563 range of addresses. It is the number of bits in the network portion of the
7564 address. The above example specifies a 24-bit netmask, so it matches all
7565 256 addresses in the 10.11.42.0 network. An item such as
7566
7567 192.168.23.236/31
7568
7569 matches just two addresses, 192.168.23.236 and 192.168.23.237. A mask value
7570 of 32 for an IPv4 address is the same as no mask at all; just a single
7571 address matches.
7572
7573 Here is another example which shows an IPv4 and an IPv6 network:
7574
7575 recipient_unqualified_hosts = 192.168.0.0/16: \
7576 3ffe::ffff::836f::::/48
7577
7578 The doubling of list separator characters applies only when these items
7579 appear inline in a host list. It is not required when indirecting via a
7580 file. For example:
7581
7582 recipient_unqualified_hosts = /opt/exim/unqualnets
7583
7584 could make use of a file containing
7585
7586 172.16.0.0/12
7587 3ffe:ffff:836f::/48
7588
7589 to have exactly the same effect as the previous example. When listing IPv6
7590 addresses inline, it is usually more convenient to use the facility for
7591 changing separator characters. This list contains the same two networks:
7592
7593 recipient_unqualified_hosts = <; 172.16.0.0/12; \
7594 3ffe:ffff:836f::/48
7595
7596 The separator is changed to semicolon by the leading "<;" at the start of
7597 the list.
7598
7599
760010.12 Host list patterns for single-key lookups by host address
7601---------------------------------------------------------------
7602
7603When a host is to be identified by a single-key lookup of its complete IP
7604address, the pattern takes this form:
7605
7606net-<single-key-search-type>;<search-data>
7607
7608For example:
7609
7610hosts_lookup = net-cdb;/hosts-by-ip.db
7611
7612The text form of the IP address of the subject host is used as the lookup key.
7613IPv6 addresses are converted to an unabbreviated form, using lower case
7614letters, with dots as separators because colon is the key terminator in lsearch
7615files. [Colons can in fact be used in keys in lsearch files by quoting the
7616keys, but this is a facility that was added later.] The data returned by the
7617lookup is not used.
7618
7619Single-key lookups can also be performed using masked IP addresses, using
7620patterns of this form:
7621
7622net<number>-<single-key-search-type>;<search-data>
7623
7624For example:
7625
7626net24-dbm;/networks.db
7627
7628The IP address of the subject host is masked using <number> as the mask length.
7629A textual string is constructed from the masked value, followed by the mask,
7630and this is used as the lookup key. For example, if the host's IP address is
7631192.168.34.6, the key that is looked up for the above example is "192.168.34.0/
763224".
7633
7634When an IPv6 address is converted to a string, dots are normally used instead
7635of colons, so that keys in lsearch files need not contain colons (which
7636terminate lsearch keys). This was implemented some time before the ability to
7637quote keys was made available in lsearch files. However, the more recently
7638implemented iplsearch files do require colons in IPv6 keys (notated using the
7639quoting facility) so as to distinguish them from IPv4 keys. For this reason,
7640when the lookup type is iplsearch, IPv6 addresses are converted using colons
7641and not dots. In all cases, full, unabbreviated IPv6 addresses are always used.
7642
7643Ideally, it would be nice to tidy up this anomalous situation by changing to
7644colons in all cases, given that quoting is now available for lsearch. However,
7645this would be an incompatible change that might break some existing
7646configurations.
7647
7648Warning: Specifying net32- (for an IPv4 address) or net128- (for an IPv6
7649address) is not the same as specifying just net- without a number. In the
7650former case the key strings include the mask value, whereas in the latter case
7651the IP address is used on its own.
7652
7653
765410.13 Host list patterns that match by host name
7655------------------------------------------------
7656
7657There are several types of pattern that require Exim to know the name of the
7658remote host. These are either wildcard patterns or lookups by name. (If a
7659complete hostname is given without any wildcarding, it is used to find an IP
7660address to match against, as described in section 10.11 above.)
7661
7662If the remote host name is not already known when Exim encounters one of these
7663patterns, it has to be found from the IP address. Although many sites on the
7664Internet are conscientious about maintaining reverse DNS data for their hosts,
7665there are also many that do not do this. Consequently, a name cannot always be
7666found, and this may lead to unwanted effects. Take care when configuring host
7667lists with wildcarded name patterns. Consider what will happen if a name cannot
7668be found.
7669
7670Because of the problems of determining host names from IP addresses, matching
7671against host names is not as common as matching against IP addresses.
7672
7673By default, in order to find a host name, Exim first does a reverse DNS lookup;
7674if no name is found in the DNS, the system function (gethostbyaddr() or
7675getipnodebyaddr() if available) is tried. The order in which these lookups are
7676done can be changed by setting the host_lookup_order option. For security, once
7677Exim has found one or more names, it looks up the IP addresses for these names
7678and compares them with the IP address that it started with. Only those names
7679whose IP addresses match are accepted. Any other names are discarded. If no
7680names are left, Exim behaves as if the host name cannot be found. In the most
7681common case there is only one name and one IP address.
7682
7683There are some options that control what happens if a host name cannot be
7684found. These are described in section 10.14 below.
7685
7686As a result of aliasing, hosts may have more than one name. When processing any
7687of the following types of pattern, all the host's names are checked:
7688
7689 * If a pattern starts with "*" the remainder of the item must match the end
7690 of the host name. For example, "*.b.c" matches all hosts whose names end in
7691 .b.c. This special simple form is provided because this is a very common
7692 requirement. Other kinds of wildcarding require the use of a regular
7693 expression.
7694
7695 * If the item starts with "^" it is taken to be a regular expression which is
7696 matched against the host name. Host names are case-independent, so this
7697 regular expression match is by default case-independent, but you can make
7698 it case-dependent by starting it with "(?-i)". References to descriptions
7699 of the syntax of regular expressions are given in chapter 8. For example,
7700
7701 ^(a|b)\.c\.d$
7702
7703 is a regular expression that matches either of the two hosts a.c.d or b.c.d
7704 . When a regular expression is used in a host list, you must take care that
7705 backslash and dollar characters are not misinterpreted as part of the
7706 string expansion. The simplest way to do this is to use "\N" to mark that
7707 part of the string as non-expandable. For example:
7708
7709 sender_unqualified_hosts = \N^(a|b)\.c\.d$\N : ....
7710
7711 Warning: If you want to match a complete host name, you must include the
7712 "$" terminating metacharacter in the regular expression, as in the above
7713 example. Without it, a match at the start of the host name is all that is
7714 required.
7715
7716
771710.14 Behaviour when an IP address or name cannot be found
7718----------------------------------------------------------
7719
7720While processing a host list, Exim may need to look up an IP address from a
7721name (see section 10.11), or it may need to look up a host name from an IP
7722address (see section 10.13). In either case, the behaviour when it fails to
7723find the information it is seeking is the same.
7724
7725Note: This section applies to permanent lookup failures. It does not apply to
7726temporary DNS errors, whose handling is described in the next section.
7727
7728Exim parses a host list from left to right. If it encounters a permanent lookup
7729failure in any item in the host list before it has found a match, Exim treats
7730it as a failure and the default behavior is as if the host does not match the
7731list. This may not always be what you want to happen. To change Exim's
7732behaviour, the special items "+include_unknown" or "+ignore_unknown" may appear
7733in the list (at top level - they are not recognized in an indirected file).
7734
7735 * If any item that follows "+include_unknown" requires information that
7736 cannot found, Exim behaves as if the host does match the list. For example,
7737
7738 host_reject_connection = +include_unknown:*.enemy.ex
7739
7740 rejects connections from any host whose name matches "*.enemy.ex", and also
7741 any hosts whose name it cannot find.
7742
7743 * If any item that follows "+ignore_unknown" requires information that cannot
7744 be found, Exim ignores that item and proceeds to the rest of the list. For
7745 example:
7746
7747 accept hosts = +ignore_unknown : friend.example : \
7748 192.168.4.5
7749
7750 accepts from any host whose name is friend.example and from 192.168.4.5,
7751 whether or not its host name can be found. Without "+ignore_unknown", if no
7752 name can be found for 192.168.4.5, it is rejected.
7753
7754Both "+include_unknown" and "+ignore_unknown" may appear in the same list. The
7755effect of each one lasts until the next, or until the end of the list.
7756
7757
775810.15 Mixing wildcarded host names and addresses in host lists
7759--------------------------------------------------------------
7760
7761This section explains the host/ip processing logic with the same concepts as
7762the previous section, but specifically addresses what happens when a wildcarded
7763hostname is one of the items in the hostlist.
7764
7765 * If you have name lookups or wildcarded host names and IP addresses in the
7766 same host list, you should normally put the IP addresses first. For
7767 example, in an ACL you could have:
7768
7769 accept hosts = 10.9.8.7 : *.friend.example
7770
7771 The reason you normally would order it this way lies in the left-to-right
7772 way that Exim processes lists. It can test IP addresses without doing any
7773 DNS lookups, but when it reaches an item that requires a host name, it
7774 fails if it cannot find a host name to compare with the pattern. If the
7775 above list is given in the opposite order, the accept statement fails for a
7776 host whose name cannot be found, even if its IP address is 10.9.8.7.
7777
7778 * If you really do want to do the name check first, and still recognize the
7779 IP address, you can rewrite the ACL like this:
7780
7781 accept hosts = *.friend.example
7782 accept hosts = 10.9.8.7
7783
7784 If the first accept fails, Exim goes on to try the second one. See chapter
7785 42 for details of ACLs. Alternatively, you can use "+ignore_unknown", which
7786 was discussed in depth in the first example in this section.
7787
7788
778910.16 Temporary DNS errors when looking up host information
7790-----------------------------------------------------------
7791
7792A temporary DNS lookup failure normally causes a defer action (except when
7793dns_again_means_nonexist converts it into a permanent error). However, host
7794lists can include "+ignore_defer" and "+include_defer", analagous to
7795"+ignore_unknown" and "+include_unknown", as described in the previous section.
7796These options should be used with care, probably only in non-critical host
7797lists such as whitelists.
7798
7799
780010.17 Host list patterns for single-key lookups by host name
7801------------------------------------------------------------
7802
7803If a pattern is of the form
7804
7805<single-key-search-type>;<search-data>
7806
7807for example
7808
7809dbm;/host/accept/list
7810
7811a single-key lookup is performed, using the host name as its key. If the lookup
7812succeeds, the host matches the item. The actual data that is looked up is not
7813used.
7814
7815Reminder: With this kind of pattern, you must have host names as keys in the
7816file, not IP addresses. If you want to do lookups based on IP addresses, you
7817must precede the search type with "net-" (see section 10.12). There is,
7818however, no reason why you could not use two items in the same list, one doing
7819an address lookup and one doing a name lookup, both using the same file.
7820
7821
782210.18 Host list patterns for query-style lookups
7823------------------------------------------------
7824
7825If a pattern is of the form
7826
7827<query-style-search-type>;<query>
7828
7829the query is obeyed, and if it succeeds, the host matches the item. The actual
7830data that is looked up is not used. The variables $sender_host_address and
7831$sender_host_name can be used in the query. For example:
7832
7833hosts_lookup = pgsql;\
7834 select ip from hostlist where ip='$sender_host_address'
7835
7836The value of $sender_host_address for an IPv6 address contains colons. You can
7837use the sg expansion item to change this if you need to. If you want to use
7838masked IP addresses in database queries, you can use the mask expansion
7839operator.
7840
7841If the query contains a reference to $sender_host_name, Exim automatically
7842looks up the host name if it has not already done so. (See section 10.13 for
7843comments on finding host names.)
7844
7845Historical note: prior to release 4.30, Exim would always attempt to find a
7846host name before running the query, unless the search type was preceded by
7847"net-". This is no longer the case. For backwards compatibility, "net-" is
7848still recognized for query-style lookups, but its presence or absence has no
7849effect. (Of course, for single-key lookups, "net-" is important. See section
785010.12.)
7851
7852
785310.19 Address lists
7854-------------------
7855
7856Address lists contain patterns that are matched against mail addresses. There
7857is one special case to be considered: the sender address of a bounce message is
7858always empty. You can test for this by providing an empty item in an address
7859list. For example, you can set up a router to process bounce messages by using
7860this option setting:
7861
7862senders = :
7863
7864The presence of the colon creates an empty item. If you do not provide any
7865data, the list is empty and matches nothing. The empty sender can also be
7866detected by a regular expression that matches an empty string, and by a
7867query-style lookup that succeeds when $sender_address is empty.
7868
7869Non-empty items in an address list can be straightforward email addresses. For
7870example:
7871
7872senders = jbc@askone.example : hs@anacreon.example
7873
7874A certain amount of wildcarding is permitted. If a pattern contains an @
7875character, but is not a regular expression and does not begin with a
7876semicolon-terminated lookup type (described below), the local part of the
7877subject address is compared with the local part of the pattern, which may start
7878with an asterisk. If the local parts match, the domain is checked in exactly
7879the same way as for a pattern in a domain list. For example, the domain can be
7880wildcarded, refer to a named list, or be a lookup:
7881
7882deny senders = *@*.spamming.site:\
7883 *@+hostile_domains:\
7884 bozo@partial-lsearch;/list/of/dodgy/sites:\
7885 *@dbm;/bad/domains.db
7886
7887If a local part that begins with an exclamation mark is required, it has to be
7888specified using a regular expression, because otherwise the exclamation mark is
7889treated as a sign of negation, as is standard in lists.
7890
7891If a non-empty pattern that is not a regular expression or a lookup does not
7892contain an @ character, it is matched against the domain part of the subject
7893address. The only two formats that are recognized this way are a literal
7894domain, or a domain pattern that starts with *. In both these cases, the effect
7895is the same as if "*@" preceded the pattern. For example:
7896
7897deny senders = enemy.domain : *.enemy.domain
7898
7899The following kinds of more complicated address list pattern can match any
7900address, including the empty address that is characteristic of bounce message
7901senders:
7902
7903 * If (after expansion) a pattern starts with "^", a regular expression match
7904 is done against the complete address, with the pattern as the regular
7905 expression. You must take care that backslash and dollar characters are not
7906 misinterpreted as part of the string expansion. The simplest way to do this
7907 is to use "\N" to mark that part of the string as non-expandable. For
7908 example:
7909
7910 deny senders = \N^.*this.*@example\.com$\N : \
7911 \N^\d{8}.+@spamhaus.example$\N : ...
7912
7913 The "\N" sequences are removed by the expansion, so these items do indeed
7914 start with "^" by the time they are being interpreted as address patterns.
7915
7916 * Complete addresses can be looked up by using a pattern that starts with a
7917 lookup type terminated by a semicolon, followed by the data for the lookup.
7918 For example:
7919
7920 deny senders = cdb;/etc/blocked.senders : \
7921 mysql;select address from blocked where \
7922 address='${quote_mysql:$sender_address}'
7923
7924 Both query-style and single-key lookup types can be used. For a single-key
7925 lookup type, Exim uses the complete address as the key. However, empty keys
7926 are not supported for single-key lookups, so a match against the empty
7927 address always fails. This restriction does not apply to query-style
7928 lookups.
7929
7930 Partial matching for single-key lookups (section 9.7) cannot be used, and
7931 is ignored if specified, with an entry being written to the panic log.
7932 However, you can configure lookup defaults, as described in section 9.6,
7933 but this is useful only for the "*@" type of default. For example, with
7934 this lookup:
7935
7936 accept senders = lsearch*@;/some/file
7937
7938 the file could contains lines like this:
7939
7940 user1@domain1.example
7941 *@domain2.example
7942
7943 and for the sender address nimrod@jaeger.example, the sequence of keys that
7944 are tried is:
7945
7946 nimrod@jaeger.example
7947 *@jaeger.example
7948 *
7949
7950 Warning 1: Do not include a line keyed by "*" in the file, because that
7951 would mean that every address matches, thus rendering the test useless.
7952
7953 Warning 2: Do not confuse these two kinds of item:
7954
7955 deny recipients = dbm*@;/some/file
7956 deny recipients = *@dbm;/some/file
7957
7958 The first does a whole address lookup, with defaulting, as just described,
7959 because it starts with a lookup type. The second matches the local part and
7960 domain independently, as described in a bullet point below.
7961
7962The following kinds of address list pattern can match only non-empty addresses.
7963If the subject address is empty, a match against any of these pattern types
7964always fails.
7965
7966 * If a pattern starts with "@@" followed by a single-key lookup item (for
7967 example, "@@lsearch;/some/file"), the address that is being checked is
7968 split into a local part and a domain. The domain is looked up in the file.
7969 If it is not found, there is no match. If it is found, the data that is
7970 looked up from the file is treated as a colon-separated list of local part
7971 patterns, each of which is matched against the subject local part in turn.
7972
7973 The lookup may be a partial one, and/or one involving a search for a
7974 default keyed by "*" (see section 9.6). The local part patterns that are
7975 looked up can be regular expressions or begin with "*", or even be further
7976 lookups. They may also be independently negated. For example, with
7977
7978 deny senders = @@dbm;/etc/reject-by-domain
7979
7980 the data from which the DBM file is built could contain lines like
7981
7982 baddomain.com: !postmaster : *
7983
7984 to reject all senders except postmaster from that domain.
7985
7986 If a local part that actually begins with an exclamation mark is required,
7987 it has to be specified using a regular expression. In lsearch files, an
7988 entry may be split over several lines by indenting the second and
7989 subsequent lines, but the separating colon must still be included at line
7990 breaks. White space surrounding the colons is ignored. For example:
7991
7992 aol.com: spammer1 : spammer2 : ^[0-9]+$ :
7993 spammer3 : spammer4
7994
7995 As in all colon-separated lists in Exim, a colon can be included in an item
7996 by doubling.
7997
7998 If the last item in the list starts with a right angle-bracket, the
7999 remainder of the item is taken as a new key to look up in order to obtain a
8000 continuation list of local parts. The new key can be any sequence of
8001 characters. Thus one might have entries like
8002
8003 aol.com: spammer1 : spammer 2 : >*
8004 xyz.com: spammer3 : >*
8005 *: ^\d{8}$
8006
8007 in a file that was searched with @@dbm*, to specify a match for 8-digit
8008 local parts for all domains, in addition to the specific local parts listed
8009 for each domain. Of course, using this feature costs another lookup each
8010 time a chain is followed, but the effort needed to maintain the data is
8011 reduced.
8012
8013 It is possible to construct loops using this facility, and in order to
8014 catch them, the chains may be no more than fifty items long.
8015
8016 * The @@<lookup> style of item can also be used with a query-style lookup,
8017 but in this case, the chaining facility is not available. The lookup can
8018 only return a single list of local parts.
8019
8020Warning: There is an important difference between the address list items in
8021these two examples:
8022
8023senders = +my_list
8024senders = *@+my_list
8025
8026In the first one, "my_list" is a named address list, whereas in the second
8027example it is a named domain list.
8028
8029
803010.20 Case of letters in address lists
8031--------------------------------------
8032
8033Domains in email addresses are always handled caselessly, but for local parts
8034case may be significant on some systems (see caseful_local_part for how Exim
8035deals with this when routing addresses). However, RFC 2505 (Anti-Spam
8036Recommendations for SMTP MTAs) suggests that matching of addresses to blocking
8037lists should be done in a case-independent manner. Since most address lists in
8038Exim are used for this kind of control, Exim attempts to do this by default.
8039
8040The domain portion of an address is always lowercased before matching it to an
8041address list. The local part is lowercased by default, and any string
8042comparisons that take place are done caselessly. This means that the data in
8043the address list itself, in files included as plain file names, and in any file
8044that is looked up using the "@@" mechanism, can be in any case. However, the
8045keys in files that are looked up by a search type other than lsearch (which
8046works caselessly) must be in lower case, because these lookups are not
8047case-independent.
8048
8049To allow for the possibility of caseful address list matching, if an item in an
8050address list is the string "+caseful", the original case of the local part is
8051restored for any comparisons that follow, and string comparisons are no longer
8052case-independent. This does not affect the domain, which remains in lower case.
8053However, although independent matches on the domain alone are still performed
8054caselessly, regular expressions that match against an entire address become
8055case-sensitive after "+caseful" has been seen.
8056
8057
805810.21 Local part lists
8059----------------------
8060
8061Case-sensitivity in local part lists is handled in the same way as for address
8062lists, as just described. The "+caseful" item can be used if required. In a
8063setting of the local_parts option in a router with caseful_local_part set
8064false, the subject is lowercased and the matching is initially
8065case-insensitive. In this case, "+caseful" will restore case-sensitive matching
8066in the local part list, but not elsewhere in the router. If caseful_local_part
8067is set true in a router, matching in the local_parts option is case-sensitive
8068from the start.
8069
8070If a local part list is indirected to a file (see section 10.3), comments are
8071handled in the same way as address lists - they are recognized only if the # is
8072preceded by white space or the start of the line. Otherwise, local part lists
8073are matched in the same way as domain lists, except that the special items that
8074refer to the local host ("@", "@[]", "@mx_any", "@mx_primary", and
8075"@mx_secondary") are not recognized. Refer to section 10.8 for details of the
8076other available item types.
8077
8078
8079
8080===============================================================================
808111. STRING EXPANSIONS
8082
8083Many strings in Exim's run time configuration are expanded before use. Some of
8084them are expanded every time they are used; others are expanded only once.
8085
8086When a string is being expanded it is copied verbatim from left to right except
8087when a dollar or backslash character is encountered. A dollar specifies the
8088start of a portion of the string that is interpreted and replaced as described
8089below in section 11.5 onwards. Backslash is used as an escape character, as
8090described in the following section.
8091
8092Whether a string is expanded depends upon the context. Usually this is solely
8093dependent upon the option for which a value is sought; in this documentation,
8094options for which string expansion is performed are marked with * after the
8095data type. ACL rules always expand strings. A couple of expansion conditions do
8096not expand some of the brace-delimited branches, for security reasons.
8097
8098
809911.1 Literal text in expanded strings
8100-------------------------------------
8101
8102An uninterpreted dollar can be included in an expanded string by putting a
8103backslash in front of it. A backslash can be used to prevent any special
8104character being treated specially in an expansion, including backslash itself.
8105If the string appears in quotes in the configuration file, two backslashes are
8106required because the quotes themselves cause interpretation of backslashes when
8107the string is read in (see section 6.16).
8108
8109A portion of the string can specified as non-expandable by placing it between
8110two occurrences of "\N". This is particularly useful for protecting regular
8111expressions, which often contain backslashes and dollar signs. For example:
8112
8113deny senders = \N^\d{8}[a-z]@some\.site\.example$\N
8114
8115On encountering the first "\N", the expander copies subsequent characters
8116without interpretation until it reaches the next "\N" or the end of the string.
8117
8118
811911.2 Character escape sequences in expanded strings
8120---------------------------------------------------
8121
8122A backslash followed by one of the letters "n", "r", or "t" in an expanded
8123string is recognized as an escape sequence for the character newline, carriage
8124return, or tab, respectively. A backslash followed by up to three octal digits
8125is recognized as an octal encoding for a single character, and a backslash
8126followed by "x" and up to two hexadecimal digits is a hexadecimal encoding.
8127
8128These escape sequences are also recognized in quoted strings when they are read
8129in. Their interpretation in expansions as well is useful for unquoted strings,
8130and for other cases such as looked-up strings that are then expanded.
8131
8132
813311.3 Testing string expansions
8134------------------------------
8135
8136Many expansions can be tested by calling Exim with the -be option. This takes
8137the command arguments, or lines from the standard input if there are no
8138arguments, runs them through the string expansion code, and writes the results
8139to the standard output. Variables based on configuration values are set up, but
8140since no message is being processed, variables such as $local_part have no
8141value. Nevertheless the -be option can be useful for checking out file and
8142database lookups, and the use of expansion operators such as sg, substr and
8143nhash.
8144
8145Exim gives up its root privilege when it is called with the -be option, and
8146instead runs under the uid and gid it was called with, to prevent users from
8147using -be for reading files to which they do not have access.
8148
8149If you want to test expansions that include variables whose values are taken
8150from a message, there are two other options that can be used. The -bem option
8151is like -be except that it is followed by a file name. The file is read as a
8152message before doing the test expansions. For example:
8153
8154exim -bem /tmp/test.message '$h_subject:'
8155
8156The -Mset option is used in conjunction with -be and is followed by an Exim
8157message identifier. For example:
8158
8159exim -be -Mset 1GrA8W-0004WS-LQ '$recipients'
8160
8161This loads the message from Exim's spool before doing the test expansions, and
8162is therefore restricted to admin users.
8163
8164
816511.4 Forced expansion failure
8166-----------------------------
8167
8168A number of expansions that are described in the following section have
8169alternative "true" and "false" substrings, enclosed in brace characters (which
8170are sometimes called "curly brackets"). Which of the two strings is used
8171depends on some condition that is evaluated as part of the expansion. If,
8172instead of a "false" substring, the word "fail" is used (not in braces), the
8173entire string expansion fails in a way that can be detected by the code that
8174requested the expansion. This is called "forced expansion failure", and its
8175consequences depend on the circumstances. In some cases it is no different from
8176any other expansion failure, but in others a different action may be taken.
8177Such variations are mentioned in the documentation of the option that is being
8178expanded.
8179
8180
818111.5 Expansion items
8182--------------------
8183
8184The following items are recognized in expanded strings. White space may be used
8185between sub-items that are keywords or substrings enclosed in braces inside an
8186outer set of braces, to improve readability. Warning: Within braces, white
8187space is significant.
8188
8189$<variable name> or ${<variable name>}
8190
8191 Substitute the contents of the named variable, for example:
8192
8193 $local_part
8194 ${domain}
8195
8196 The second form can be used to separate the name from subsequent
8197 alphanumeric characters. This form (using braces) is available only for
8198 variables; it does not apply to message headers. The names of the variables
8199 are given in section 11.9 below. If the name of a non-existent variable is
8200 given, the expansion fails.
8201
8202${<op>:<string>}
8203
8204 The string is first itself expanded, and then the operation specified by <
8205 op> is applied to it. For example:
8206
8207 ${lc:$local_part}
8208
8209 The string starts with the first character after the colon, which may be
8210 leading white space. A list of operators is given in section 11.6 below.
8211 The operator notation is used for simple expansion items that have just one
8212 argument, because it reduces the number of braces and therefore makes the
8213 string easier to understand.
8214
8215$bheader_<header name>: or $bh_<header name>:
8216
8217 This item inserts "basic" header lines. It is described with the header
8218 expansion item below.
8219
8220${acl{<name>}{<arg>}...}
8221
8222 The name and zero to nine argument strings are first expanded separately.
8223 The expanded arguments are assigned to the variables $acl_arg1 to $acl_arg9
8224 in order. Any unused are made empty. The variable $acl_narg is set to the
8225 number of arguments. The named ACL (see chapter 42) is called and may use
8226 the variables; if another acl expansion is used the values are restored
8227 after it returns. If the ACL sets a value using a "message =" modifier and
8228 returns accept or deny, the value becomes the result of the expansion. If
8229 no message is set and the ACL returns accept or deny the expansion result
8230 is an empty string. If the ACL returns defer the result is a forced-fail.
8231 Otherwise the expansion fails.
8232
8233${certextract{<field>}{<certificate>}{<string2>}{<string3>}}
8234
8235 The <certificate> must be a variable of type certificate. The field name is
8236 expanded and used to retrive the relevant field from the certificate.
8237 Supported fields are:
8238
8239 version
8240 serial_number
8241 subject RFC4514 DN
8242 issuer RFC4514 DN
8243 notbefore time
8244 notafter time
8245 sig_algorithm
8246 signature
8247 subj_altname tagged list
8248 ocsp_uri list
8249 crl_uri list
8250
8251 If the field is found, <string2> is expanded, and replaces the whole item;
8252 otherwise <string3> is used. During the expansion of <string2> the variable
8253 $value contains the value that has been extracted. Afterwards, it is
8254 restored to any previous value it might have had.
8255
8256 If {<string3>} is omitted, the item is replaced by an empty string if the
8257 key is not found. If {<string2>} is also omitted, the value that was
8258 extracted is used.
8259
8260 Some field names take optional modifiers, appended and separated by commas.
8261
8262 The field selectors marked as "RFC4514" above output a Distinguished Name
8263 string which is not quite parseable by Exim as a comma-separated tagged
8264 list (the exceptions being elements containin commas). RDN elements of a
8265 single type may be selected by a modifier of the type label; if so the
8266 expansion result is a list (newline-separated by default). The separator
8267 may be changed by another modifer of a right angle-bracket followed
8268 immediately by the new separator. Recognised RDN type labels include "CN",
8269 "O", "OU" and "DC".
8270
8271 The field selectors marked as "time" above may output a number of seconds
8272 since epoch if the modifier "int" is used.
8273
8274 The field selectors marked as "list" above return a list, newline-separated
8275 by default, (embedded separator characters in elements are doubled). The
8276 separator may be changed by a modifier of a right angle-bracket followed
8277 immediately by the new separator.
8278
8279 The field selectors marked as "tagged" above prefix each list element with
8280 a type string and an equals sign. Elements of only one type may be selected
8281 by a modifier which is one of "dns", "uri" or "mail"; if so the elenment
8282 tags are omitted.
8283
8284 If not otherwise noted field values are presented in human-readable form.
8285
8286${dlfunc{<file>}{<function>}{<arg>}{<arg>}...}
8287
8288 This expansion dynamically loads and then calls a locally-written C
8289 function. This functionality is available only if Exim is compiled with
8290
8291 EXPAND_DLFUNC=yes
8292
8293 set in Local/Makefile. Once loaded, Exim remembers the dynamically loaded
8294 object so that it doesn't reload the same object file in the same Exim
8295 process (but of course Exim does start new processes frequently).
8296
8297 There may be from zero to eight arguments to the function. When compiling a
8298 local function that is to be called in this way, local_scan.h should be
8299 included. The Exim variables and functions that are defined by that API are
8300 also available for dynamically loaded functions. The function itself must
8301 have the following type:
8302
8303 int dlfunction(uschar **yield, int argc, uschar *argv[])
8304
8305 Where "uschar" is a typedef for "unsigned char" in local_scan.h. The
8306 function should return one of the following values:
8307
8308 "OK": Success. The string that is placed in the variable yield is put into
8309 the expanded string that is being built.
8310
8311 "FAIL": A non-forced expansion failure occurs, with the error message taken
8312 from yield, if it is set.
8313
8314 "FAIL_FORCED": A forced expansion failure occurs, with the error message
8315 taken from yield if it is set.
8316
8317 "ERROR": Same as "FAIL", except that a panic log entry is written.
8318
8319 When compiling a function that is to be used in this way with gcc, you need
8320 to add -shared to the gcc command. Also, in the Exim build-time
8321 configuration, you must add -export-dynamic to EXTRALIBS.
8322
8323${extract{<key>}{<string1>}{<string2>}{<string3>}}
8324
8325 The key and <string1> are first expanded separately. Leading and trailing
8326 white space is removed from the key (but not from any of the strings). The
8327 key must not consist entirely of digits. The expanded <string1> must be of
8328 the form:
8329
8330 <key1> = <value1> <key2> = <value2> ...
8331
8332 where the equals signs and spaces (but not both) are optional. If any of
8333 the values contain white space, they must be enclosed in double quotes, and
8334 any values that are enclosed in double quotes are subject to escape
8335 processing as described in section 6.16. The expanded <string1> is searched
8336 for the value that corresponds to the key. The search is case-insensitive.
8337 If the key is found, <string2> is expanded, and replaces the whole item;
8338 otherwise <string3> is used. During the expansion of <string2> the variable
8339 $value contains the value that has been extracted. Afterwards, it is
8340 restored to any previous value it might have had.
8341
8342 If {<string3>} is omitted, the item is replaced by an empty string if the
8343 key is not found. If {<string2>} is also omitted, the value that was
8344 extracted is used. Thus, for example, these two expansions are identical,
8345 and yield "2001":
8346
8347 ${extract{gid}{uid=1984 gid=2001}}
8348 ${extract{gid}{uid=1984 gid=2001}{$value}}
8349
8350 Instead of {<string3>} the word "fail" (not in curly brackets) can appear,
8351 for example:
8352
8353 ${extract{Z}{A=... B=...}{$value} fail }
8354
8355 This forces an expansion failure (see section 11.4); {<string2>} must be
8356 present for "fail" to be recognized.
8357
8358${extract{<number>}{<separators>}{<string1>}{<string2>}{<string3>}}
8359
8360 The <number> argument must consist entirely of decimal digits, apart from
8361 leading and trailing white space, which is ignored. This is what
8362 distinguishes this form of extract from the previous kind. It behaves in
8363 the same way, except that, instead of extracting a named field, it extracts
8364 from <string1> the field whose number is given as the first argument. You
8365 can use $value in <string2> or "fail" instead of <string3> as before.
8366
8367 The fields in the string are separated by any one of the characters in the
8368 separator string. These may include space or tab characters. The first
8369 field is numbered one. If the number is negative, the fields are counted
8370 from the end of the string, with the rightmost one numbered -1. If the
8371 number given is zero, the entire string is returned. If the modulus of the
8372 number is greater than the number of fields in the string, the result is
8373 the expansion of <string3>, or the empty string if <string3> is not
8374 provided. For example:
8375
8376 ${extract{2}{:}{x:42:99:& Mailer::/bin/bash}}
8377
8378 yields "42", and
8379
8380 ${extract{-4}{:}{x:42:99:& Mailer::/bin/bash}}
8381
8382 yields "99". Two successive separators mean that the field between them is
8383 empty (for example, the fifth field above).
8384
8385${filter{<string>}{<condition>}}
8386
8387 After expansion, <string> is interpreted as a list, colon-separated by
8388 default, but the separator can be changed in the usual way. For each item
8389 in this list, its value is place in $item, and then the condition is
8390 evaluated. If the condition is true, $item is added to the output as an
8391 item in a new list; if the condition is false, the item is discarded. The
8392 separator used for the output list is the same as the one used for the
8393 input, but a separator setting is not included in the output. For example:
8394
8395 ${filter{a:b:c}{!eq{$item}{b}}
8396
8397 yields "a:c". At the end of the expansion, the value of $item is restored
8398 to what it was before. See also the map and reduce expansion items.
8399
8400${hash{<string1>}{<string2>}{<string3>}}
8401
8402 This is a textual hashing function, and was the first to be implemented in
8403 early versions of Exim. In current releases, there are other hashing
8404 functions (numeric, MD5, and SHA-1), which are described below.
8405
8406 The first two strings, after expansion, must be numbers. Call them <m> and
8407 <n>. If you are using fixed values for these numbers, that is, if <string1>
8408 and <string2> do not change when they are expanded, you can use the simpler
8409 operator notation that avoids some of the braces:
8410
8411 ${hash_<n>_<m>:<string>}
8412
8413 The second number is optional (in both notations). If <n> is greater than
8414 or equal to the length of the string, the expansion item returns the
8415 string. Otherwise it computes a new string of length <n> by applying a
8416 hashing function to the string. The new string consists of characters taken
8417 from the first <m> characters of the string
8418
8419 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQWRSTUVWXYZ0123456789
8420
8421 If <m> is not present the value 26 is used, so that only lower case letters
8422 appear. For example:
8423
8424 $hash{3}{monty}} yields jmg
8425 $hash{5}{monty}} yields monty
8426 $hash{4}{62}{monty python}} yields fbWx
8427
8428$header_<header name>: or $h_<header name>:, $bheader_<header name>: or $bh_<
8429 header name>:, $rheader_<header name>: or $rh_<header name>:
8430
8431 Substitute the contents of the named message header line, for example
8432
8433 $header_reply-to:
8434
8435 The newline that terminates a header line is not included in the expansion,
8436 but internal newlines (caused by splitting the header line over several
8437 physical lines) may be present.
8438
8439 The difference between rheader, bheader, and header is in the way the data
8440 in the header line is interpreted.
8441
8442 * rheader gives the original "raw" content of the header line, with no
8443 processing at all, and without the removal of leading and trailing
8444 white space.
8445
8446 * bheader removes leading and trailing white space, and then decodes
8447 base64 or quoted-printable MIME "words" within the header text, but
8448 does no character set translation. If decoding of what looks
8449 superficially like a MIME "word" fails, the raw string is returned. If
8450 decoding produces a binary zero character, it is replaced by a question
8451 mark - this is what Exim does for binary zeros that are actually
8452 received in header lines.
8453
8454 * header tries to translate the string as decoded by bheader to a
8455 standard character set. This is an attempt to produce the same string
8456 as would be displayed on a user's MUA. If translation fails, the
8457 bheader string is returned. Translation is attempted only on operating
8458 systems that support the iconv() function. This is indicated by the
8459 compile-time macro HAVE_ICONV in a system Makefile or in Local/Makefile
8460 .
8461
8462 In a filter file, the target character set for header can be specified by a
8463 command of the following form:
8464
8465 headers charset "UTF-8"
8466
8467 This command affects all references to $h_ (or $header_) expansions in
8468 subsequently obeyed filter commands. In the absence of this command, the
8469 target character set in a filter is taken from the setting of the
8470 headers_charset option in the runtime configuration. The value of this
8471 option defaults to the value of HEADERS_CHARSET in Local/Makefile. The
8472 ultimate default is ISO-8859-1.
8473
8474 Header names follow the syntax of RFC 2822, which states that they may
8475 contain any printing characters except space and colon. Consequently, curly
8476 brackets do not terminate header names, and should not be used to enclose
8477 them as if they were variables. Attempting to do so causes a syntax error.
8478
8479 Only header lines that are common to all copies of a message are visible to
8480 this mechanism. These are the original header lines that are received with
8481 the message, and any that are added by an ACL statement or by a system
8482 filter. Header lines that are added to a particular copy of a message by a
8483 router or transport are not accessible.
8484
8485 For incoming SMTP messages, no header lines are visible in ACLs that are
8486 obeyed before the DATA ACL, because the header structure is not set up
8487 until the message is received. Header lines that are added in a RCPT ACL
8488 (for example) are saved until the message's incoming header lines are
8489 available, at which point they are added. When a DATA ACL is running,
8490 however, header lines added by earlier ACLs are visible.
8491
8492 Upper case and lower case letters are synonymous in header names. If the
8493 following character is white space, the terminating colon may be omitted,
8494 but this is not recommended, because you may then forget it when it is
8495 needed. When white space terminates the header name, it is included in the
8496 expanded string. If the message does not contain the given header, the
8497 expansion item is replaced by an empty string. (See the def condition in
8498 section 11.7 for a means of testing for the existence of a header.)
8499
8500 If there is more than one header with the same name, they are all
8501 concatenated to form the substitution string, up to a maximum length of
8502 64K. Unless rheader is being used, leading and trailing white space is
8503 removed from each header before concatenation, and a completely empty
8504 header is ignored. A newline character is then inserted between non-empty
8505 headers, but there is no newline at the very end. For the header and
8506 bheader expansion, for those headers that contain lists of addresses, a
8507 comma is also inserted at the junctions between headers. This does not
8508 happen for the rheader expansion.
8509
8510${hmac{<hashname>}{<secret>}{<string>}}
8511
8512 This function uses cryptographic hashing (either MD5 or SHA-1) to convert a
8513 shared secret and some text into a message authentication code, as
8514 specified in RFC 2104. This differs from "${md5:secret_text...}" or "$
8515 {sha1:secret_text...}" in that the hmac step adds a signature to the
8516 cryptographic hash, allowing for authentication that is not possible with
8517 MD5 or SHA-1 alone. The hash name must expand to either "md5" or "sha1" at
8518 present. For example:
8519
8520 ${hmac{md5}{somesecret}{$primary_hostname $tod_log}}
8521
8522 For the hostname mail.example.com and time 2002-10-17 11:30:59, this
8523 produces:
8524
8525 dd97e3ba5d1a61b5006108f8c8252953
8526
8527 As an example of how this might be used, you might put in the main part of
8528 an Exim configuration:
8529
8530 SPAMSCAN_SECRET=cohgheeLei2thahw
8531
8532 In a router or a transport you could then have:
8533
8534 headers_add = \
8535 X-Spam-Scanned: ${primary_hostname} ${message_exim_id} \
8536 ${hmac{md5}{SPAMSCAN_SECRET}\
8537 {${primary_hostname},${message_exim_id},$h_message-id:}}
8538
8539 Then given a message, you can check where it was scanned by looking at the
8540 X-Spam-Scanned: header line. If you know the secret, you can check that
8541 this header line is authentic by recomputing the authentication code from
8542 the host name, message ID and the Message-id: header line. This can be done
8543 using Exim's -be option, or by other means, for example by using the
8544 hmac_md5_hex() function in Perl.
8545
8546${if <condition> {<string1>}{<string2>}}
8547
8548 If <condition> is true, <string1> is expanded and replaces the whole item;
8549 otherwise <string2> is used. The available conditions are described in
8550 section 11.7 below. For example:
8551
8552 ${if eq {$local_part}{postmaster} {yes}{no} }
8553
8554 The second string need not be present; if it is not and the condition is
8555 not true, the item is replaced with nothing. Alternatively, the word "fail"
8556 may be present instead of the second string (without any curly brackets).
8557 In this case, the expansion is forced to fail if the condition is not true
8558 (see section 11.4).
8559
8560 If both strings are omitted, the result is the string "true" if the
8561 condition is true, and the empty string if the condition is false. This
8562 makes it less cumbersome to write custom ACL and router conditions. For
8563 example, instead of
8564
8565 condition = ${if >{$acl_m4}{3}{true}{false}}
8566
8567 you can use
8568
8569 condition = ${if >{$acl_m4}{3}}
8570
8571${length{<string1>}{<string2>}}
8572
8573 The length item is used to extract the initial portion of a string. Both
8574 strings are expanded, and the first one must yield a number, <n>, say. If
8575 you are using a fixed value for the number, that is, if <string1> does not
8576 change when expanded, you can use the simpler operator notation that avoids
8577 some of the braces:
8578
8579 ${length_<n>:<string>}
8580
8581 The result of this item is either the first <n> characters or the whole of
8582 <string2>, whichever is the shorter. Do not confuse length with strlen,
8583 which gives the length of a string.
8584
8585${listextract{<number>}{<string1>}{<string2>}{<string3>}}
8586
8587 The <number> argument must consist entirely of decimal digits, apart from
8588 an optional leading minus, and leading and trailing white space (which is
8589 ignored).
8590
8591 After expansion, <string1> is interpreted as a list, colon-separated by
8592 default, but the separator can be changed in the usual way.
8593
8594 The first field of the list is numbered one. If the number is negative, the
8595 fields are counted from the end of the list, with the rightmost one
8596 numbered -1. The numbered element of the list is extracted and placed in
8597 $value, then <string2> is expanded as the result.
8598
8599 If the modulus of the number is zero or greater than the number of fields
8600 in the string, the result is the expansion of <string3>.
8601
8602 For example:
8603
8604 ${listextract{2}{x:42:99}}
8605
8606 yields "42", and
8607
8608 ${listextract{-3}{<, x,42,99,& Mailer,,/bin/bash}{result: $value}}
8609
8610 yields "result: 99".
8611
8612 If {<string3>} is omitted, an empty string is used for string3. If {<
8613 string2>} is also omitted, the value that was extracted is used. You can
8614 use "fail" instead of {<string3>} as in a string extract.
8615
8616${lookup{<key>} <search type> {<file>} {<string1>} {<string2>}}
8617
8618 This is the first of one of two different types of lookup item, which are
8619 both described in the next item.
8620
8621${lookup <search type> {<query>} {<string1>} {<string2>}}
8622
8623 The two forms of lookup item specify data lookups in files and databases,
8624 as discussed in chapter 9. The first form is used for single-key lookups,
8625 and the second is used for query-style lookups. The <key>, <file>, and <
8626 query> strings are expanded before use.
8627
8628 If there is any white space in a lookup item which is part of a filter
8629 command, a retry or rewrite rule, a routing rule for the manualroute
8630 router, or any other place where white space is significant, the lookup
8631 item must be enclosed in double quotes. The use of data lookups in users'
8632 filter files may be locked out by the system administrator.
8633
8634 If the lookup succeeds, <string1> is expanded and replaces the entire item.
8635 During its expansion, the variable $value contains the data returned by the
8636 lookup. Afterwards it reverts to the value it had previously (at the outer
8637 level it is empty). If the lookup fails, <string2> is expanded and replaces
8638 the entire item. If {<string2>} is omitted, the replacement is the empty
8639 string on failure. If <string2> is provided, it can itself be a nested
8640 lookup, thus providing a mechanism for looking up a default value when the
8641 original lookup fails.
8642
8643 If a nested lookup is used as part of <string1>, $value contains the data
8644 for the outer lookup while the parameters of the second lookup are
8645 expanded, and also while <string2> of the second lookup is expanded, should
8646 the second lookup fail. Instead of {<string2>} the word "fail" can appear,
8647 and in this case, if the lookup fails, the entire expansion is forced to
8648 fail (see section 11.4). If both {<string1>} and {<string2>} are omitted,
8649 the result is the looked up value in the case of a successful lookup, and
8650 nothing in the case of failure.
8651
8652 For single-key lookups, the string "partial" is permitted to precede the
8653 search type in order to do partial matching, and * or *@ may follow a
8654 search type to request default lookups if the key does not match (see
8655 sections 9.6 and 9.7 for details).
8656
8657 If a partial search is used, the variables $1 and $2 contain the wild and
8658 non-wild parts of the key during the expansion of the replacement text.
8659 They return to their previous values at the end of the lookup item.
8660
8661 This example looks up the postmaster alias in the conventional alias file:
8662
8663 ${lookup {postmaster} lsearch {/etc/aliases} {$value}}
8664
8665 This example uses NIS+ to look up the full name of the user corresponding
8666 to the local part of an address, forcing the expansion to fail if it is not
8667 found:
8668
8669 ${lookup nisplus {[name=$local_part],passwd.org_dir:gcos} \
8670 {$value}fail}
8671
8672${map{<string1>}{<string2>}}
8673
8674 After expansion, <string1> is interpreted as a list, colon-separated by
8675 default, but the separator can be changed in the usual way. For each item
8676 in this list, its value is place in $item, and then <string2> is expanded
8677 and added to the output as an item in a new list. The separator used for
8678 the output list is the same as the one used for the input, but a separator
8679 setting is not included in the output. For example:
8680
8681 ${map{a:b:c}{[$item]}} ${map{<- x-y-z}{($item)}}
8682
8683 expands to "[a]:[b]:[c] (x)-(y)-(z)". At the end of the expansion, the
8684 value of $item is restored to what it was before. See also the filter and
8685 reduce expansion items.
8686
8687${nhash{<string1>}{<string2>}{<string3>}}
8688
8689 The three strings are expanded; the first two must yield numbers. Call them
8690 <n> and <m>. If you are using fixed values for these numbers, that is, if <
8691 string1> and <string2> do not change when they are expanded, you can use
8692 the simpler operator notation that avoids some of the braces:
8693
8694 ${nhash_<n>_<m>:<string>}
8695
8696 The second number is optional (in both notations). If there is only one
8697 number, the result is a number in the range 0-<n>-1. Otherwise, the string
8698 is processed by a div/mod hash function that returns two numbers, separated
8699 by a slash, in the ranges 0 to <n>-1 and 0 to <m>-1, respectively. For
8700 example,
8701
8702 ${nhash{8}{64}{supercalifragilisticexpialidocious}}
8703
8704 returns the string "6/33".
8705
8706${perl{<subroutine>}{<arg>}{<arg>}...}
8707
8708 This item is available only if Exim has been built to include an embedded
8709 Perl interpreter. The subroutine name and the arguments are first
8710 separately expanded, and then the Perl subroutine is called with those
8711 arguments. No additional arguments need be given; the maximum number
8712 permitted, including the name of the subroutine, is nine.
8713
8714 The return value of the subroutine is inserted into the expanded string,
8715 unless the return value is undef. In that case, the expansion fails in the
8716 same way as an explicit "fail" on a lookup item. The return value is a
8717 scalar. Whatever you return is evaluated in a scalar context. For example,
8718 if you return the name of a Perl vector, the return value is the size of
8719 the vector, not its contents.
8720
8721 If the subroutine exits by calling Perl's die function, the expansion fails
8722 with the error message that was passed to die. More details of the embedded
8723 Perl facility are given in chapter 12.
8724
8725 The redirect router has an option called forbid_filter_perl which locks out
8726 the use of this expansion item in filter files.
8727
8728${prvs{<address>}{<secret>}{<keynumber>}}
8729
8730 The first argument is a complete email address and the second is secret
8731 keystring. The third argument, specifying a key number, is optional. If
8732 absent, it defaults to 0. The result of the expansion is a prvs-signed
8733 email address, to be typically used with the return_path option on an smtp
8734 transport as part of a bounce address tag validation (BATV) scheme. For
8735 more discussion and an example, see section 42.51.
8736
8737${prvscheck{<address>}{<secret>}{<string>}}
8738
8739 This expansion item is the complement of the prvs item. It is used for
8740 checking prvs-signed addresses. If the expansion of the first argument does
8741 not yield a syntactically valid prvs-signed address, the whole item expands
8742 to the empty string. When the first argument does expand to a syntactically
8743 valid prvs-signed address, the second argument is expanded, with the
8744 prvs-decoded version of the address and the key number extracted from the
8745 address in the variables $prvscheck_address and $prvscheck_keynum,
8746 respectively.
8747
8748 These two variables can be used in the expansion of the second argument to
8749 retrieve the secret. The validity of the prvs-signed address is then
8750 checked against the secret. The result is stored in the variable
8751 $prvscheck_result, which is empty for failure or "1" for success.
8752
8753 The third argument is optional; if it is missing, it defaults to an empty
8754 string. This argument is now expanded. If the result is an empty string,
8755 the result of the expansion is the decoded version of the address. This is
8756 the case whether or not the signature was valid. Otherwise, the result of
8757 the expansion is the expansion of the third argument.
8758
8759 All three variables can be used in the expansion of the third argument.
8760 However, once the expansion is complete, only $prvscheck_result remains
8761 set. For more discussion and an example, see section 42.51.
8762
8763${readfile{<file name>}{<eol string>}}
8764
8765 The file name and end-of-line string are first expanded separately. The
8766 file is then read, and its contents replace the entire item. All newline
8767 characters in the file are replaced by the end-of-line string if it is
8768 present. Otherwise, newlines are left in the string. String expansion is
8769 not applied to the contents of the file. If you want this, you must wrap
8770 the item in an expand operator. If the file cannot be read, the string
8771 expansion fails.
8772
8773 The redirect router has an option called forbid_filter_readfile which locks
8774 out the use of this expansion item in filter files.
8775
8776${readsocket{<name>}{<request>}{<timeout>}{<eol string>}{<fail string>}}
8777
8778 This item inserts data from a Unix domain or Internet socket into the
8779 expanded string. The minimal way of using it uses just two arguments, as in
8780 these examples:
8781
8782 ${readsocket{/socket/name}{request string}}
8783 ${readsocket{inet:some.host:1234}{request string}}
8784
8785 For a Unix domain socket, the first substring must be the path to the
8786 socket. For an Internet socket, the first substring must contain "inet:"
8787 followed by a host name or IP address, followed by a colon and a port,
8788 which can be a number or the name of a TCP port in /etc/services. An IP
8789 address may optionally be enclosed in square brackets. This is best for
8790 IPv6 addresses. For example:
8791
8792 ${readsocket{inet:[::1]:1234}{request string}}
8793
8794 Only a single host name may be given, but if looking it up yields more than
8795 one IP address, they are each tried in turn until a connection is made. For
8796 both kinds of socket, Exim makes a connection, writes the request string
8797 (unless it is an empty string) and reads from the socket until an
8798 end-of-file is read. A timeout of 5 seconds is applied. Additional,
8799 optional arguments extend what can be done. Firstly, you can vary the
8800 timeout. For example:
8801
8802 ${readsocket{/socket/name}{request string}{3s}}
8803
8804 A fourth argument allows you to change any newlines that are in the data
8805 that is read, in the same way as for readfile (see above). This example
8806 turns them into spaces:
8807
8808 ${readsocket{inet:127.0.0.1:3294}{request string}{3s}{ }}
8809
8810 As with all expansions, the substrings are expanded before the processing
8811 happens. Errors in these sub-expansions cause the expansion to fail. In
8812 addition, the following errors can occur:
8813
8814 * Failure to create a socket file descriptor;
8815
8816 * Failure to connect the socket;
8817
8818 * Failure to write the request string;
8819
8820 * Timeout on reading from the socket.
8821
8822 By default, any of these errors causes the expansion to fail. However, if
8823 you supply a fifth substring, it is expanded and used when any of the above
8824 errors occurs. For example:
8825
8826 ${readsocket{/socket/name}{request string}{3s}{\n}\
8827 {socket failure}}
8828
8829 You can test for the existence of a Unix domain socket by wrapping this
8830 expansion in "${if exists", but there is a race condition between that test
8831 and the actual opening of the socket, so it is safer to use the fifth
8832 argument if you want to be absolutely sure of avoiding an expansion error
8833 for a non-existent Unix domain socket, or a failure to connect to an
8834 Internet socket.
8835
8836 The redirect router has an option called forbid_filter_readsocket which
8837 locks out the use of this expansion item in filter files.
8838
8839${reduce{<string1>}{<string2>}{<string3>}}
8840
8841 This operation reduces a list to a single, scalar string. After expansion,
8842 <string1> is interpreted as a list, colon-separated by default, but the
8843 separator can be changed in the usual way. Then <string2> is expanded and
8844 assigned to the $value variable. After this, each item in the <string1>
8845 list is assigned to $item in turn, and <string3> is expanded for each of
8846 them. The result of that expansion is assigned to $value before the next
8847 iteration. When the end of the list is reached, the final value of $value
8848 is added to the expansion output. The reduce expansion item can be used in
8849 a number of ways. For example, to add up a list of numbers:
8850
8851 ${reduce {<, 1,2,3}{0}{${eval:$value+$item}}}
8852
8853 The result of that expansion would be "6". The maximum of a list of numbers
8854 can be found:
8855
8856 ${reduce {3:0:9:4:6}{0}{${if >{$item}{$value}{$item}{$value}}}}
8857
8858 At the end of a reduce expansion, the values of $item and $value are
8859 restored to what they were before. See also the filter and map expansion
8860 items.
8861
8862$rheader_<header name>: or $rh_<header name>:
8863
8864 This item inserts "raw" header lines. It is described with the header
8865 expansion item above.
8866
8867${run{<command> <args>}{<string1>}{<string2>}}
8868
8869 The command and its arguments are first expanded as one string. The string
8870 is split apart into individual arguments by spaces, and then the command is
8871 run in a separate process, but under the same uid and gid. As in other
8872 command executions from Exim, a shell is not used by default. If the
8873 command requires a shell, you must explicitly code it.
8874
8875 Since the arguments are split by spaces, when there is a variable expansion
8876 which has an empty result, it will cause the situation that the argument
8877 will simply be omitted when the program is actually executed by Exim. If
8878 the script/program requires a specific number of arguments and the expanded
8879 variable could possibly result in this empty expansion, the variable must
8880 be quoted. This is more difficult if the expanded variable itself could
8881 result in a string containing quotes, because it would interfere with the
8882 quotes around the command arguments. A possible guard against this is to
8883 wrap the variable in the sg operator to change any quote marks to some
8884 other character.
8885
8886 The standard input for the command exists, but is empty. The standard
8887 output and standard error are set to the same file descriptor. If the
8888 command succeeds (gives a zero return code) <string1> is expanded and
8889 replaces the entire item; during this expansion, the standard output/error
8890 from the command is in the variable $value. If the command fails, <string2
8891 >, if present, is expanded and used. Once again, during the expansion, the
8892 standard output/error from the command is in the variable $value.
8893
8894 If <string2> is absent, the result is empty. Alternatively, <string2> can
8895 be the word "fail" (not in braces) to force expansion failure if the
8896 command does not succeed. If both strings are omitted, the result is
8897 contents of the standard output/error on success, and nothing on failure.
8898
8899 The standard output/error of the command is put in the variable $value. In
8900 this ACL example, the output of a command is logged for the admin to
8901 troubleshoot:
8902
8903 warn condition = ${run{/usr/bin/id}{yes}{no}}
8904 log_message = Output of id: $value
8905
8906 If the command requires shell idioms, such as the > redirect operator, the
8907 shell must be invoked directly, such as with:
8908
8909 ${run{/bin/bash -c "/usr/bin/id >/tmp/id"}{yes}{yes}}
8910
8911 The return code from the command is put in the variable $runrc, and this
8912 remains set afterwards, so in a filter file you can do things like this:
8913
8914 if "${run{x y z}{}}$runrc" is 1 then ...
8915 elif $runrc is 2 then ...
8916 ...
8917 endif
8918
8919 If execution of the command fails (for example, the command does not
8920 exist), the return code is 127 - the same code that shells use for
8921 non-existent commands.
8922
8923 Warning: In a router or transport, you cannot assume the order in which
8924 option values are expanded, except for those preconditions whose order of
8925 testing is documented. Therefore, you cannot reliably expect to set $runrc
8926 by the expansion of one option, and use it in another.
8927
8928 The redirect router has an option called forbid_filter_run which locks out
8929 the use of this expansion item in filter files.
8930
8931${sg{<subject>}{<regex>}{<replacement>}}
8932
8933 This item works like Perl's substitution operator (s) with the global (/g)
8934 option; hence its name. However, unlike the Perl equivalent, Exim does not
8935 modify the subject string; instead it returns the modified string for
8936 insertion into the overall expansion. The item takes three arguments: the
8937 subject string, a regular expression, and a substitution string. For
8938 example:
8939
8940 ${sg{abcdefabcdef}{abc}{xyz}}
8941
8942 yields "xyzdefxyzdef". Because all three arguments are expanded before use,
8943 if any $ or \ characters are required in the regular expression or in the
8944 substitution string, they have to be escaped. For example:
8945
8946 ${sg{abcdef}{^(...)(...)\$}{\$2\$1}}
8947
8948 yields "defabc", and
8949
8950 ${sg{1=A 4=D 3=C}{\N(\d+)=\N}{K\$1=}}
8951
8952 yields "K1=A K4=D K3=C". Note the use of "\N" to protect the contents of
8953 the regular expression from string expansion.
8954
8955${substr{<string1>}{<string2>}{<string3>}}
8956
8957 The three strings are expanded; the first two must yield numbers. Call them
8958 <n> and <m>. If you are using fixed values for these numbers, that is, if <
8959 string1> and <string2> do not change when they are expanded, you can use
8960 the simpler operator notation that avoids some of the braces:
8961
8962 ${substr_<n>_<m>:<string>}
8963
8964 The second number is optional (in both notations). If it is absent in the
8965 simpler format, the preceding underscore must also be omitted.
8966
8967 The substr item can be used to extract more general substrings than length.
8968 The first number, <n>, is a starting offset, and <m> is the length
8969 required. For example
8970
8971 ${substr{3}{2}{$local_part}}
8972
8973 If the starting offset is greater than the string length the result is the
8974 null string; if the length plus starting offset is greater than the string
8975 length, the result is the right-hand part of the string, starting from the
8976 given offset. The first character in the string has offset zero.
8977
8978 The substr expansion item can take negative offset values to count from the
8979 right-hand end of its operand. The last character is offset -1, the
8980 second-last is offset -2, and so on. Thus, for example,
8981
8982 ${substr{-5}{2}{1234567}}
8983
8984 yields "34". If the absolute value of a negative offset is greater than the
8985 length of the string, the substring starts at the beginning of the string,
8986 and the length is reduced by the amount of overshoot. Thus, for example,
8987
8988 ${substr{-5}{2}{12}}
8989
8990 yields an empty string, but
8991
8992 ${substr{-3}{2}{12}}
8993
8994 yields "1".
8995
8996 When the second number is omitted from substr, the remainder of the string
8997 is taken if the offset is positive. If it is negative, all characters in
8998 the string preceding the offset point are taken. For example, an offset of
8999 -1 and no length, as in these semantically identical examples:
9000
9001 ${substr_-1:abcde}
9002 ${substr{-1}{abcde}}
9003
9004 yields all but the last character of the string, that is, "abcd".
9005
9006${tr{<subject>}{<characters>}{<replacements>}}
9007
9008 This item does single-character translation on its subject string. The
9009 second argument is a list of characters to be translated in the subject
9010 string. Each matching character is replaced by the corresponding character
9011 from the replacement list. For example
9012
9013 ${tr{abcdea}{ac}{13}}
9014
9015 yields "1b3de1". If there are duplicates in the second character string,
9016 the last occurrence is used. If the third string is shorter than the
9017 second, its last character is replicated. However, if it is empty, no
9018 translation takes place.
9019
9020
902111.6 Expansion operators
9022------------------------
9023
9024For expansion items that perform transformations on a single argument string,
9025the "operator" notation is used because it is simpler and uses fewer braces.
9026The substring is first expanded before the operation is applied to it. The
9027following operations can be performed:
9028
9029${address:<string>}
9030
9031 The string is interpreted as an RFC 2822 address, as it might appear in a
9032 header line, and the effective address is extracted from it. If the string
9033 does not parse successfully, the result is empty.
9034
9035${addresses:<string>}
9036
9037 The string (after expansion) is interpreted as a list of addresses in RFC
9038 2822 format, such as can be found in a To: or Cc: header line. The
9039 operative address (local-part@domain) is extracted from each item, and the
9040 result of the expansion is a colon-separated list, with appropriate
9041 doubling of colons should any happen to be present in the email addresses.
9042 Syntactically invalid RFC2822 address items are omitted from the output.
9043
9044 It is possible to specify a character other than colon for the output
9045 separator by starting the string with > followed by the new separator
9046 character. For example:
9047
9048 ${addresses:>& Chief <ceo@up.stairs>, sec@base.ment (dogsbody)}
9049
9050 expands to "ceo@up.stairs&sec@base.ment". Compare the address (singular)
9051 expansion item, which extracts the working address from a single RFC2822
9052 address. See the filter, map, and reduce items for ways of processing
9053 lists.
9054
9055 To clarify "list of addresses in RFC 2822 format" mentioned above, Exim
9056 follows a strict interpretation of header line formatting. Exim parses the
9057 bare, unquoted portion of an email address and if it finds a comma, treats
9058 it as an email address seperator. For the example header line:
9059
9060 From: =?iso-8859-2?Q?Last=2C_First?= <user@example.com>
9061
9062 The first example below demonstrates that Q-encoded email addresses are
9063 parsed properly if it is given the raw header (in this example,
9064 "$rheader_from:"). It does not see the comma because it's still encoded as
9065 "=2C". The second example below is passed the contents of "$header_from:",
9066 meaning it gets de-mimed. Exim sees the decoded "," so it treats it as two
9067 email addresses. The third example shows that the presence of a comma is
9068 skipped when it is quoted.
9069
9070 # exim -be '${addresses:From: \
9071 =?iso-8859-2?Q?Last=2C_First?= <user@example.com>}'
9072 user@example.com
9073 # exim -be '${addresses:From: Last, First <user@example.com>}'
9074 Last:user@example.com
9075 # exim -be '${addresses:From: "Last, First" <user@example.com>}'
9076 user@example.com
9077
9078${base62:<digits>}
9079
9080 The string must consist entirely of decimal digits. The number is converted
9081 to base 62 and output as a string of six characters, including leading
9082 zeros. In the few operating environments where Exim uses base 36 instead of
9083 base 62 for its message identifiers (because those systems do not have
9084 case-sensitive file names), base 36 is used by this operator, despite its
9085 name. Note: Just to be absolutely clear: this is not base64 encoding.
9086
9087${base62d:<base-62 digits>}
9088
9089 The string must consist entirely of base-62 digits, or, in operating
9090 environments where Exim uses base 36 instead of base 62 for its message
9091 identifiers, base-36 digits. The number is converted to decimal and output
9092 as a string.
9093
9094${domain:<string>}
9095
9096 The string is interpreted as an RFC 2822 address and the domain is
9097 extracted from it. If the string does not parse successfully, the result is
9098 empty.
9099
9100${escape:<string>}
9101
9102 If the string contains any non-printing characters, they are converted to
9103 escape sequences starting with a backslash. Whether characters with the
9104 most significant bit set (so-called "8-bit characters") count as printing
9105 or not is controlled by the print_topbitchars option.
9106
9107${eval:<string>} and ${eval10:<string>}
9108
9109 These items supports simple arithmetic and bitwise logical operations in
9110 expansion strings. The string (after expansion) must be a conventional
9111 arithmetic expression, but it is limited to basic arithmetic operators,
9112 bitwise logical operators, and parentheses. All operations are carried out
9113 using integer arithmetic. The operator priorities are as follows (the same
9114 as in the C programming language):
9115
9116 highest: not (~), negate (-)
9117 multiply (*), divide (/), remainder (%)
9118 plus (+), minus (-)
9119 shift-left (<<), shift-right (>>)
9120 and (&)
9121 xor (^)
9122 lowest: or (|)
9123
9124 Binary operators with the same priority are evaluated from left to right.
9125 White space is permitted before or after operators.
9126
9127 For eval, numbers may be decimal, octal (starting with "0") or hexadecimal
9128 (starting with "0x"). For eval10, all numbers are taken as decimal, even if
9129 they start with a leading zero; hexadecimal numbers are not permitted. This
9130 can be useful when processing numbers extracted from dates or times, which
9131 often do have leading zeros.
9132
9133 A number may be followed by "K", "M" or "G" to multiply it by 1024,
9134 1024*1024 or 1024*1024*1024, respectively. Negative numbers are supported.
9135 The result of the computation is a decimal representation of the answer
9136 (without "K", "M" or "G"). For example:
9137
9138 ${eval:1+1} yields 2
9139 ${eval:1+2*3} yields 7
9140 ${eval:(1+2)*3} yields 9
9141 ${eval:2+42%5} yields 4
9142 ${eval:0xc&5} yields 4
9143 ${eval:0xc|5} yields 13
9144 ${eval:0xc^5} yields 9
9145 ${eval:0xc>>1} yields 6
9146 ${eval:0xc<<1} yields 24
9147 ${eval:~255&0x1234} yields 4608
9148 ${eval:-(~255&0x1234)} yields -4608
9149
9150 As a more realistic example, in an ACL you might have
9151
9152 deny message = Too many bad recipients
9153 condition = \
9154 ${if and { \
9155 {>{$rcpt_count}{10}} \
9156 { \
9157 < \
9158 {$recipients_count} \
9159 {${eval:$rcpt_count/2}} \
9160 } \
9161 }{yes}{no}}
9162
9163 The condition is true if there have been more than 10 RCPT commands and
9164 fewer than half of them have resulted in a valid recipient.
9165
9166${expand:<string>}
9167
9168 The expand operator causes a string to be expanded for a second time. For
9169 example,
9170
9171 ${expand:${lookup{$domain}dbm{/some/file}{$value}}}
9172
9173 first looks up a string in a file while expanding the operand for expand,
9174 and then re-expands what it has found.
9175
9176${from_utf8:<string>}
9177
9178 The world is slowly moving towards Unicode, although there are no standards
9179 for email yet. However, other applications (including some databases) are
9180 starting to store data in Unicode, using UTF-8 encoding. This operator
9181 converts from a UTF-8 string to an ISO-8859-1 string. UTF-8 code values
9182 greater than 255 are converted to underscores. The input must be a valid
9183 UTF-8 string. If it is not, the result is an undefined sequence of bytes.
9184
9185 Unicode code points with values less than 256 are compatible with ASCII and
9186 ISO-8859-1 (also known as Latin-1). For example, character 169 is the
9187 copyright symbol in both cases, though the way it is encoded is different.
9188 In UTF-8, more than one byte is needed for characters with code values
9189 greater than 127, whereas ISO-8859-1 is a single-byte encoding (but thereby
9190 limited to 256 characters). This makes translation from UTF-8 to ISO-8859-1
9191 straightforward.
9192
9193${hash_<n>_<m>:<string>}
9194
9195 The hash operator is a simpler interface to the hashing function that can
9196 be used when the two parameters are fixed numbers (as opposed to strings
9197 that change when expanded). The effect is the same as
9198
9199 ${hash{<n>}{<m>}{<string>}}
9200
9201 See the description of the general hash item above for details. The
9202 abbreviation h can be used when hash is used as an operator.
9203
9204${hex2b64:<hexstring>}
9205
9206 This operator converts a hex string into one that is base64 encoded. This
9207 can be useful for processing the output of the MD5 and SHA-1 hashing
9208 functions.
9209
9210${hexquote:<string>}
9211
9212 This operator converts non-printable characters in a string into a hex
9213 escape form. Byte values between 33 (!) and 126 (~) inclusive are left as
9214 is, and other byte values are converted to "\xNN", for example a byte value
9215 127 is converted to "\x7f".
9216
9217${lc:<string>}
9218
9219 This forces the letters in the string into lower-case, for example:
9220
9221 ${lc:$local_part}
9222
9223${length_<number>:<string>}
9224
9225 The length operator is a simpler interface to the length function that can
9226 be used when the parameter is a fixed number (as opposed to a string that
9227 changes when expanded). The effect is the same as
9228
9229 ${length{<number>}{<string>}}
9230
9231 See the description of the general length item above for details. Note that
9232 length is not the same as strlen. The abbreviation l can be used when
9233 length is used as an operator.
9234
9235${listcount:<string>}
9236
9237 The string is interpreted as a list and the number of items is returned.
9238
9239${listnamed:<name>} and ${listnamed_<type>:<name>}
9240
9241 The name is interpreted as a named list and the content of the list is
9242 returned, expanding any referenced lists, re-quoting as needed for
9243 colon-separation. If the optional type is given it must be one of "a", "d",
9244 "h" or "l" and selects address-, domain-, host- or localpart- lists to
9245 search among respectively. Otherwise all types are searched in an undefined
9246 order and the first matching list is returned.
9247
9248${local_part:<string>}
9249
9250 The string is interpreted as an RFC 2822 address and the local part is
9251 extracted from it. If the string does not parse successfully, the result is
9252 empty.
9253
9254${mask:<IP address>/<bit count>}
9255
9256 If the form of the string to be operated on is not an IP address followed
9257 by a slash and an integer (that is, a network address in CIDR notation),
9258 the expansion fails. Otherwise, this operator converts the IP address to
9259 binary, masks off the least significant bits according to the bit count,
9260 and converts the result back to text, with mask appended. For example,
9261
9262 ${mask:10.111.131.206/28}
9263
9264 returns the string "10.111.131.192/28". Since this operation is expected to
9265 be mostly used for looking up masked addresses in files, the result for an
9266 IPv6 address uses dots to separate components instead of colons, because
9267 colon terminates a key string in lsearch files. So, for example,
9268
9269 ${mask:3ffe:ffff:836f:0a00:000a:0800:200a:c031/99}
9270
9271 returns the string
9272
9273 3ffe.ffff.836f.0a00.000a.0800.2000.0000/99
9274
9275 Letters in IPv6 addresses are always output in lower case.
9276
9277${md5:<string>}
9278
9279 The md5 operator computes the MD5 hash value of the string, and returns it
9280 as a 32-digit hexadecimal number, in which any letters are in lower case.
9281
9282${nhash_<n>_<m>:<string>}
9283
9284 The nhash operator is a simpler interface to the numeric hashing function
9285 that can be used when the two parameters are fixed numbers (as opposed to
9286 strings that change when expanded). The effect is the same as
9287
9288 ${nhash{<n>}{<m>}{<string>}}
9289
9290 See the description of the general nhash item above for details.
9291
9292${quote:<string>}
9293
9294 The quote operator puts its argument into double quotes if it is an empty
9295 string or contains anything other than letters, digits, underscores, dots,
9296 and hyphens. Any occurrences of double quotes and backslashes are escaped
9297 with a backslash. Newlines and carriage returns are converted to "\n" and "
9298 \r", respectively For example,
9299
9300 ${quote:ab"*"cd}
9301
9302 becomes
9303
9304 "ab\"*\"cd"
9305
9306 The place where this is useful is when the argument is a substitution from
9307 a variable or a message header.
9308
9309${quote_local_part:<string>}
9310
9311 This operator is like quote, except that it quotes the string only if
9312 required to do so by the rules of RFC 2822 for quoting local parts. For
9313 example, a plus sign would not cause quoting (but it would for quote). If
9314 you are creating a new email address from the contents of $local_part (or
9315 any other unknown data), you should always use this operator.
9316
9317${quote_<lookup-type>:<string>}
9318
9319 This operator applies lookup-specific quoting rules to the string. Each
9320 query-style lookup type has its own quoting rules which are described with
9321 the lookups in chapter 9. For example,
9322
9323 ${quote_ldap:two * two}
9324
9325 returns
9326
9327 two%20%5C2A%20two
9328
9329 For single-key lookup types, no quoting is ever necessary and this operator
9330 yields an unchanged string.
9331
9332${randint:<n>}
9333
9334 This operator returns a somewhat random number which is less than the
9335 supplied number and is at least 0. The quality of this randomness depends
9336 on how Exim was built; the values are not suitable for keying material. If
9337 Exim is linked against OpenSSL then RAND_pseudo_bytes() is used. If Exim is
9338 linked against GnuTLS then gnutls_rnd(GNUTLS_RND_NONCE) is used, for
9339 versions of GnuTLS with that function. Otherwise, the implementation may be
9340 arc4random(), random() seeded by srandomdev() or srandom(), or a custom
9341 implementation even weaker than random().
9342
9343${reverse_ip:<ipaddr>}
9344
9345 This operator reverses an IP address; for IPv4 addresses, the result is in
9346 dotted-quad decimal form, while for IPv6 addreses the result is in
9347 dotted-nibble hexadecimal form. In both cases, this is the "natural" form
9348 for DNS. For example,
9349
9350 ${reverse_ip:192.0.2.4}
9351 ${reverse_ip:2001:0db8:c42:9:1:abcd:192.0.2.127}
9352
9353 returns
9354
9355 4.2.0.192
9356 f.7.2.0.0.0.0.c.d.c.b.a.1.0.0.0.9.0.0.0.2.4.c.0.8.b.d.0.1.0.0.2
9357
9358${rfc2047:<string>}
9359
9360 This operator encodes text according to the rules of RFC 2047. This is an
9361 encoding that is used in header lines to encode non-ASCII characters. It is
9362 assumed that the input string is in the encoding specified by the
9363 headers_charset option, which defaults to ISO-8859-1. If the string
9364 contains only characters in the range 33-126, and no instances of the
9365 characters
9366
9367 ? = ( ) < > @ , ; : \ " . [ ] _
9368
9369 it is not modified. Otherwise, the result is the RFC 2047 encoding of the
9370 string, using as many "encoded words" as necessary to encode all the
9371 characters.
9372
9373${rfc2047d:<string>}
9374
9375 This operator decodes strings that are encoded as per RFC 2047. Binary zero
9376 bytes are replaced by question marks. Characters are converted into the
9377 character set defined by headers_charset. Overlong RFC 2047 "words" are not
9378 recognized unless check_rfc2047_length is set false.
9379
9380 Note: If you use $header_xxx: (or $h_xxx:) to access a header line, RFC
9381 2047 decoding is done automatically. You do not need to use this operator
9382 as well.
9383
9384${rxquote:<string>}
9385
9386 The rxquote operator inserts a backslash before any non-alphanumeric
9387 characters in its argument. This is useful when substituting the values of
9388 variables or headers inside regular expressions.
9389
9390${sha1:<string>}
9391
9392 The sha1 operator computes the SHA-1 hash value of the string, and returns
9393 it as a 40-digit hexadecimal number, in which any letters are in upper
9394 case.
9395
9396${sha256:<certificate>}
9397
9398 The sha256 operator computes the SHA-256 hash fingerprint of the
9399 certificate, and returns it as a 64-digit hexadecimal number, in which any
9400 letters are in upper case. Only arguments which are a single variable of
9401 certificate type are supported.
9402
9403${stat:<string>}
9404
9405 The string, after expansion, must be a file path. A call to the stat()
9406 function is made for this path. If stat() fails, an error occurs and the
9407 expansion fails. If it succeeds, the data from the stat replaces the item,
9408 as a series of <name>=<value> pairs, where the values are all numerical,
9409 except for the value of "smode". The names are: "mode" (giving the mode as
9410 a 4-digit octal number), "smode" (giving the mode in symbolic format as a
9411 10-character string, as for the ls command), "inode", "device", "links",
9412 "uid", "gid", "size", "atime", "mtime", and "ctime". You can extract
9413 individual fields using the extract expansion item.
9414
9415 The use of the stat expansion in users' filter files can be locked out by
9416 the system administrator. Warning: The file size may be incorrect on 32-bit
9417 systems for files larger than 2GB.
9418
9419${str2b64:<string>}
9420
9421 This operator converts a string into one that is base64 encoded.
9422
9423${strlen:<string>}
9424
9425 The item is replace by the length of the expanded string, expressed as a
9426 decimal number. Note: Do not confuse strlen with length.
9427
9428${substr_<start>_<length>:<string>}
9429
9430 The substr operator is a simpler interface to the substr function that can
9431 be used when the two parameters are fixed numbers (as opposed to strings
9432 that change when expanded). The effect is the same as
9433
9434 ${substr{<start>}{<length>}{<string>}}
9435
9436 See the description of the general substr item above for details. The
9437 abbreviation s can be used when substr is used as an operator.
9438
9439${time_eval:<string>}
9440
9441 This item converts an Exim time interval such as "2d4h5m" into a number of
9442 seconds.
9443
9444${time_interval:<string>}
9445
9446 The argument (after sub-expansion) must be a sequence of decimal digits
9447 that represents an interval of time as a number of seconds. It is converted
9448 into a number of larger units and output in Exim's normal time format, for
9449 example, "1w3d4h2m6s".
9450
9451${uc:<string>}
9452
9453 This forces the letters in the string into upper-case.
9454
9455${utf8clean:<string>}
9456
9457 This replaces any invalid utf-8 sequence in the string by the character "?
9458 ".
9459
9460
946111.7 Expansion conditions
9462-------------------------
9463
9464The following conditions are available for testing by the ${if construct while
9465expanding strings:
9466
9467!<condition>
9468
9469 Preceding any condition with an exclamation mark negates the result of the
9470 condition.
9471
9472<symbolic operator> {<string1>}{<string2>}
9473
9474 There are a number of symbolic operators for doing numeric comparisons.
9475 They are:
9476
9477 = equal
9478 == equal
9479 > greater
9480 >= greater or equal
9481 < less
9482 <= less or equal
9483
9484 For example:
9485
9486 ${if >{$message_size}{10M} ...
9487
9488 Note that the general negation operator provides for inequality testing.
9489 The two strings must take the form of optionally signed decimal integers,
9490 optionally followed by one of the letters "K", "M" or "G" (in either upper
9491 or lower case), signifying multiplication by 1024, 1024*1024 or
9492 1024*1024*1024, respectively. As a special case, the numerical value of an
9493 empty string is taken as zero.
9494
9495 In all cases, a relative comparator OP is testing if <string1> OP <string2
9496 >; the above example is checking if $message_size is larger than 10M, not
9497 if 10M is larger than $message_size.
9498
9499acl {{<name>}{<arg1>}{<arg2>}...}
9500
9501 The name and zero to nine argument strings are first expanded separately.
9502 The expanded arguments are assigned to the variables $acl_arg1 to $acl_arg9
9503 in order. Any unused are made empty. The variable $acl_narg is set to the
9504 number of arguments. The named ACL (see chapter 42) is called and may use
9505 the variables; if another acl expansion is used the values are restored
9506 after it returns. If the ACL sets a value using a "message =" modifier the
9507 variable $value becomes the result of the expansion, otherwise it is empty.
9508 If the ACL returns accept the condition is true; if deny, false. If the ACL
9509 returns defer the result is a forced-fail.
9510
9511bool {<string>}
9512
9513 This condition turns a string holding a true or false representation into a
9514 boolean state. It parses "true", "false", "yes" and "no"
9515 (case-insensitively); also integer numbers map to true if non-zero, false
9516 if zero. An empty string is treated as false. Leading and trailing
9517 whitespace is ignored; thus a string consisting only of whitespace is
9518 false. All other string values will result in expansion failure.
9519
9520 When combined with ACL variables, this expansion condition will let you
9521 make decisions in one place and act on those decisions in another place.
9522 For example:
9523
9524 ${if bool{$acl_m_privileged_sender} ...
9525
9526bool_lax {<string>}
9527
9528 Like bool, this condition turns a string into a boolean state. But where
9529 bool accepts a strict set of strings, bool_lax uses the same loose
9530 definition that the Router condition option uses. The empty string and the
9531 values "false", "no" and "0" map to false, all others map to true. Leading
9532 and trailing whitespace is ignored.
9533
9534 Note that where "bool{00}" is false, "bool_lax{00}" is true.
9535
9536crypteq {<string1>}{<string2>}
9537
9538 This condition is included in the Exim binary if it is built to support any
9539 authentication mechanisms (see chapter 33). Otherwise, it is necessary to
9540 define SUPPORT_CRYPTEQ in Local/Makefile to get crypteq included in the
9541 binary.
9542
9543 The crypteq condition has two arguments. The first is encrypted and
9544 compared against the second, which is already encrypted. The second string
9545 may be in the LDAP form for storing encrypted strings, which starts with
9546 the encryption type in curly brackets, followed by the data. If the second
9547 string does not begin with "{" it is assumed to be encrypted with crypt()
9548 or crypt16() (see below), since such strings cannot begin with "{".
9549 Typically this will be a field from a password file. An example of an
9550 encrypted string in LDAP form is:
9551
9552 {md5}CY9rzUYh03PK3k6DJie09g==
9553
9554 If such a string appears directly in an expansion, the curly brackets have
9555 to be quoted, because they are part of the expansion syntax. For example:
9556
9557 ${if crypteq {test}{\{md5\}CY9rzUYh03PK3k6DJie09g==}{yes}{no}}
9558
9559 The following encryption types (whose names are matched case-independently)
9560 are supported:
9561
9562 * {md5} computes the MD5 digest of the first string, and expresses this
9563 as printable characters to compare with the remainder of the second
9564 string. If the length of the comparison string is 24, Exim assumes that
9565 it is base64 encoded (as in the above example). If the length is 32,
9566 Exim assumes that it is a hexadecimal encoding of the MD5 digest. If
9567 the length not 24 or 32, the comparison fails.
9568
9569 * {sha1} computes the SHA-1 digest of the first string, and expresses
9570 this as printable characters to compare with the remainder of the
9571 second string. If the length of the comparison string is 28, Exim
9572 assumes that it is base64 encoded. If the length is 40, Exim assumes
9573 that it is a hexadecimal encoding of the SHA-1 digest. If the length is
9574 not 28 or 40, the comparison fails.
9575
9576 * {crypt} calls the crypt() function, which traditionally used to use
9577 only the first eight characters of the password. However, in modern
9578 operating systems this is no longer true, and in many cases the entire
9579 password is used, whatever its length.
9580
9581 * {crypt16} calls the crypt16() function, which was originally created to
9582 use up to 16 characters of the password in some operating systems.
9583 Again, in modern operating systems, more characters may be used.
9584
9585 Exim has its own version of crypt16(), which is just a double call to crypt
9586 (). For operating systems that have their own version, setting HAVE_CRYPT16
9587 in Local/Makefile when building Exim causes it to use the operating system
9588 version instead of its own. This option is set by default in the
9589 OS-dependent Makefile for those operating systems that are known to support
9590 crypt16().
9591
9592 Some years after Exim's crypt16() was implemented, a user discovered that
9593 it was not using the same algorithm as some operating systems' versions. It
9594 turns out that as well as crypt16() there is a function called bigcrypt()
9595 in some operating systems. This may or may not use the same algorithm, and
9596 both of them may be different to Exim's built-in crypt16().
9597
9598 However, since there is now a move away from the traditional crypt()
9599 functions towards using SHA1 and other algorithms, tidying up this area of
9600 Exim is seen as very low priority.
9601
9602 If you do not put a encryption type (in curly brackets) in a crypteq
9603 comparison, the default is usually either "{crypt}" or "{crypt16}", as
9604 determined by the setting of DEFAULT_CRYPT in Local/Makefile. The default
9605 default is "{crypt}". Whatever the default, you can always use either
9606 function by specifying it explicitly in curly brackets.
9607
9608def:<variable name>
9609
9610 The def condition must be followed by the name of one of the expansion
9611 variables defined in section 11.9. The condition is true if the variable
9612 does not contain the empty string. For example:
9613
9614 ${if def:sender_ident {from $sender_ident}}
9615
9616 Note that the variable name is given without a leading $ character. If the
9617 variable does not exist, the expansion fails.
9618
9619def:header_<header name>: or def:h_<header name>:
9620
9621 This condition is true if a message is being processed and the named header
9622 exists in the message. For example,
9623
9624 ${if def:header_reply-to:{$h_reply-to:}{$h_from:}}
9625
9626 Note: No $ appears before header_ or h_ in the condition, and the header
9627 name must be terminated by a colon if white space does not follow.
9628
9629eq {<string1>}{<string2>}, eqi {<string1>}{<string2>}
9630
9631 The two substrings are first expanded. The condition is true if the two
9632 resulting strings are identical. For eq the comparison includes the case of
9633 letters, whereas for eqi the comparison is case-independent.
9634
9635exists {<file name>}
9636
9637 The substring is first expanded and then interpreted as an absolute path.
9638 The condition is true if the named file (or directory) exists. The
9639 existence test is done by calling the stat() function. The use of the
9640 exists test in users' filter files may be locked out by the system
9641 administrator.
9642
9643first_delivery
9644
9645 This condition, which has no data, is true during a message's first
9646 delivery attempt. It is false during any subsequent delivery attempts.
9647
9648forall{<a list>}{<a condition>}, forany{<a list>}{<a condition>}
9649
9650 These conditions iterate over a list. The first argument is expanded to
9651 form the list. By default, the list separator is a colon, but it can be
9652 changed by the normal method. The second argument is interpreted as a
9653 condition that is to be applied to each item in the list in turn. During
9654 the interpretation of the condition, the current list item is placed in a
9655 variable called $item.
9656
9657 * For forany, interpretation stops if the condition is true for any item,
9658 and the result of the whole condition is true. If the condition is
9659 false for all items in the list, the overall condition is false.
9660
9661 * For forall, interpretation stops if the condition is false for any
9662 item, and the result of the whole condition is false. If the condition
9663 is true for all items in the list, the overall condition is true.
9664
9665 Note that negation of forany means that the condition must be false for all
9666 items for the overall condition to succeed, and negation of forall means
9667 that the condition must be false for at least one item. In this example,
9668 the list separator is changed to a comma:
9669
9670 ${if forany{<, $recipients}{match{$item}{^user3@}}{yes}{no}}
9671
9672 The value of $item is saved and restored while forany or forall is being
9673 processed, to enable these expansion items to be nested.
9674
9675 To scan a named list, expand it with the listnamed operator.
9676
9677ge {<string1>}{<string2>}, gei {<string1>}{<string2>}
9678
9679 The two substrings are first expanded. The condition is true if the first
9680 string is lexically greater than or equal to the second string. For ge the
9681 comparison includes the case of letters, whereas for gei the comparison is
9682 case-independent.
9683
9684gt {<string1>}{<string2>}, gti {<string1>}{<string2>}
9685
9686 The two substrings are first expanded. The condition is true if the first
9687 string is lexically greater than the second string. For gt the comparison
9688 includes the case of letters, whereas for gti the comparison is
9689 case-independent.
9690
9691inlist {<string1>}{<string2>}, inlisti {<string1>}{<string2>}
9692
9693 Both strings are expanded; the second string is treated as a list of simple
9694 strings; if the first string is a member of the second, then the condition
9695 is true.
9696
9697 These are simpler to use versions of the more powerful forany condition.
9698 Examples, and the forany equivalents:
9699
9700 ${if inlist{needle}{foo:needle:bar}}
9701 ${if forany{foo:needle:bar}{eq{$item}{needle}}}
9702 ${if inlisti{Needle}{fOo:NeeDLE:bAr}}
9703 ${if forany{fOo:NeeDLE:bAr}{eqi{$item}{Needle}}}
9704
9705isip {<string>}, isip4 {<string>}, isip6 {<string>}
9706
9707 The substring is first expanded, and then tested to see if it has the form
9708 of an IP address. Both IPv4 and IPv6 addresses are valid for isip, whereas
9709 isip4 and isip6 test specifically for IPv4 or IPv6 addresses.
9710
9711 For an IPv4 address, the test is for four dot-separated components, each of
9712 which consists of from one to three digits. For an IPv6 address, up to
9713 eight colon-separated components are permitted, each containing from one to
9714 four hexadecimal digits. There may be fewer than eight components if an
9715 empty component (adjacent colons) is present. Only one empty component is
9716 permitted.
9717
9718 Note: The checks are just on the form of the address; actual numerical
9719 values are not considered. Thus, for example, 999.999.999.999 passes the
9720 IPv4 check. The main use of these tests is to distinguish between IP
9721 addresses and host names, or between IPv4 and IPv6 addresses. For example,
9722 you could use
9723
9724 ${if isip4{$sender_host_address}...
9725
9726 to test which IP version an incoming SMTP connection is using.
9727
9728ldapauth {<ldap query>}
9729
9730 This condition supports user authentication using LDAP. See section 9.13
9731 for details of how to use LDAP in lookups and the syntax of queries. For
9732 this use, the query must contain a user name and password. The query itself
9733 is not used, and can be empty. The condition is true if the password is not
9734 empty, and the user name and password are accepted by the LDAP server. An
9735 empty password is rejected without calling LDAP because LDAP binds with an
9736 empty password are considered anonymous regardless of the username, and
9737 will succeed in most configurations. See chapter 33 for details of SMTP
9738 authentication, and chapter 34 for an example of how this can be used.
9739
9740le {<string1>}{<string2>}, lei {<string1>}{<string2>}
9741
9742 The two substrings are first expanded. The condition is true if the first
9743 string is lexically less than or equal to the second string. For le the
9744 comparison includes the case of letters, whereas for lei the comparison is
9745 case-independent.
9746
9747lt {<string1>}{<string2>}, lti {<string1>}{<string2>}
9748
9749 The two substrings are first expanded. The condition is true if the first
9750 string is lexically less than the second string. For lt the comparison
9751 includes the case of letters, whereas for lti the comparison is
9752 case-independent.
9753
9754match {<string1>}{<string2>}
9755
9756 The two substrings are first expanded. The second is then treated as a
9757 regular expression and applied to the first. Because of the pre-expansion,
9758 if the regular expression contains dollar, or backslash characters, they
9759 must be escaped. Care must also be taken if the regular expression contains
9760 braces (curly brackets). A closing brace must be escaped so that it is not
9761 taken as a premature termination of <string2>. The easiest approach is to
9762 use the "\N" feature to disable expansion of the regular expression. For
9763 example,
9764
9765 ${if match {$local_part}{\N^\d{3}\N} ...
9766
9767 If the whole expansion string is in double quotes, further escaping of
9768 backslashes is also required.
9769
9770 The condition is true if the regular expression match succeeds. The regular
9771 expression is not required to begin with a circumflex metacharacter, but if
9772 there is no circumflex, the expression is not anchored, and it may match
9773 anywhere in the subject, not just at the start. If you want the pattern to
9774 match at the end of the subject, you must include the "$" metacharacter at
9775 an appropriate point.
9776
9777 At the start of an if expansion the values of the numeric variable
9778 substitutions $1 etc. are remembered. Obeying a match condition that
9779 succeeds causes them to be reset to the substrings of that condition and
9780 they will have these values during the expansion of the success string. At
9781 the end of the if expansion, the previous values are restored. After
9782 testing a combination of conditions using or, the subsequent values of the
9783 numeric variables are those of the condition that succeeded.
9784
9785match_address {<string1>}{<string2>}
9786
9787 See match_local_part.
9788
9789match_domain {<string1>}{<string2>}
9790
9791 See match_local_part.
9792
9793match_ip {<string1>}{<string2>}
9794
9795 This condition matches an IP address to a list of IP address patterns. It
9796 must be followed by two argument strings. The first (after expansion) must
9797 be an IP address or an empty string. The second (not expanded) is a
9798 restricted host list that can match only an IP address, not a host name.
9799 For example:
9800
9801 ${if match_ip{$sender_host_address}{1.2.3.4:5.6.7.8}{...}{...}}
9802
9803 The specific types of host list item that are permitted in the list are:
9804
9805 * An IP address, optionally with a CIDR mask.
9806
9807 * A single asterisk, which matches any IP address.
9808
9809 * An empty item, which matches only if the IP address is empty. This
9810 could be useful for testing for a locally submitted message or one from
9811 specific hosts in a single test such as
9812
9813 ${if match_ip{$sender_host_address}{:4.3.2.1:...}{...}{...}}
9814
9815 where the first item in the list is the empty string.
9816
9817 * The item @[] matches any of the local host's interface addresses.
9818
9819 * Single-key lookups are assumed to be like "net-" style lookups in host
9820 lists, even if "net-" is not specified. There is never any attempt to
9821 turn the IP address into a host name. The most common type of linear
9822 search for match_ip is likely to be iplsearch, in which the file can
9823 contain CIDR masks. For example:
9824
9825 ${if match_ip{$sender_host_address}{iplsearch;/some/file}...
9826
9827 It is of course possible to use other kinds of lookup, and in such a
9828 case, you do need to specify the "net-" prefix if you want to specify a
9829 specific address mask, for example:
9830
9831 ${if match_ip{$sender_host_address}{net24-dbm;/some/file}...
9832
9833 However, unless you are combining a match_ip condition with others, it
9834 is just as easy to use the fact that a lookup is itself a condition,
9835 and write:
9836
9837 ${lookup{${mask:$sender_host_address/24}}dbm{/a/file}...
9838
9839 Note that <string2> is not itself subject to string expansion, unless Exim
9840 was built with the EXPAND_LISTMATCH_RHS option.
9841
9842 Consult section 10.11 for further details of these patterns.
9843
9844match_local_part {<string1>}{<string2>}
9845
9846 This condition, together with match_address and match_domain, make it
9847 possible to test domain, address, and local part lists within expansions.
9848 Each condition requires two arguments: an item and a list to match. A
9849 trivial example is:
9850
9851 ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
9852
9853 In each case, the second argument may contain any of the allowable items
9854 for a list of the appropriate type. Also, because the second argument
9855 (after expansion) is a standard form of list, it is possible to refer to a
9856 named list. Thus, you can use conditions like this:
9857
9858 ${if match_domain{$domain}{+local_domains}{...
9859
9860 For address lists, the matching starts off caselessly, but the "+caseful"
9861 item can be used, as in all address lists, to cause subsequent items to
9862 have their local parts matched casefully. Domains are always matched
9863 caselessly.
9864
9865 Note that <string2> is not itself subject to string expansion, unless Exim
9866 was built with the EXPAND_LISTMATCH_RHS option.
9867
9868 Note: Host lists are not supported in this way. This is because hosts have
9869 two identities: a name and an IP address, and it is not clear how to
9870 specify cleanly how such a test would work. However, IP addresses can be
9871 matched using match_ip.
9872
9873pam {<string1>:<string2>:...}
9874
9875 Pluggable Authentication Modules (http://www.kernel.org/pub/linux/libs/pam/
9876 ) are a facility that is available in the latest releases of Solaris and in
9877 some GNU/Linux distributions. The Exim support, which is intended for use
9878 in conjunction with the SMTP AUTH command, is available only if Exim is
9879 compiled with
9880
9881 SUPPORT_PAM=yes
9882
9883 in Local/Makefile. You probably need to add -lpam to EXTRALIBS, and in some
9884 releases of GNU/Linux -ldl is also needed.
9885
9886 The argument string is first expanded, and the result must be a
9887 colon-separated list of strings. Leading and trailing white space is
9888 ignored. The PAM module is initialized with the service name "exim" and the
9889 user name taken from the first item in the colon-separated data string (<
9890 string1>). The remaining items in the data string are passed over in
9891 response to requests from the authentication function. In the simple case
9892 there will only be one request, for a password, so the data consists of
9893 just two strings.
9894
9895 There can be problems if any of the strings are permitted to contain colon
9896 characters. In the usual way, these have to be doubled to avoid being taken
9897 as separators. If the data is being inserted from a variable, the sg
9898 expansion item can be used to double any existing colons. For example, the
9899 configuration of a LOGIN authenticator might contain this setting:
9900
9901 server_condition = ${if pam{$auth1:${sg{$auth2}{:}{::}}}}
9902
9903 For a PLAIN authenticator you could use:
9904
9905 server_condition = ${if pam{$auth2:${sg{$auth3}{:}{::}}}}
9906
9907 In some operating systems, PAM authentication can be done only from a
9908 process running as root. Since Exim is running as the Exim user when
9909 receiving messages, this means that PAM cannot be used directly in those
9910 systems. A patched version of the pam_unix module that comes with the Linux
9911 PAM package is available from http://www.e-admin.de/pam_exim/. The patched
9912 module allows one special uid/gid combination, in addition to root, to
9913 authenticate. If you build the patched module to allow the Exim user and
9914 group, PAM can then be used from an Exim authenticator.
9915
9916pwcheck {<string1>:<string2>}
9917
9918 This condition supports user authentication using the Cyrus pwcheck daemon.
9919 This is one way of making it possible for passwords to be checked by a
9920 process that is not running as root. Note: The use of pwcheck is now
9921 deprecated. Its replacement is saslauthd (see below).
9922
9923 The pwcheck support is not included in Exim by default. You need to specify
9924 the location of the pwcheck daemon's socket in Local/Makefile before
9925 building Exim. For example:
9926
9927 CYRUS_PWCHECK_SOCKET=/var/pwcheck/pwcheck
9928
9929 You do not need to install the full Cyrus software suite in order to use
9930 the pwcheck daemon. You can compile and install just the daemon alone from
9931 the Cyrus SASL library. Ensure that exim is the only user that has access
9932 to the /var/pwcheck directory.
9933
9934 The pwcheck condition takes one argument, which must be the user name and
9935 password, separated by a colon. For example, in a LOGIN authenticator
9936 configuration, you might have this:
9937
9938 server_condition = ${if pwcheck{$auth1:$auth2}}
9939
9940 Again, for a PLAIN authenticator configuration, this would be:
9941
9942 server_condition = ${if pwcheck{$auth2:$auth3}}
9943
9944queue_running
9945
9946 This condition, which has no data, is true during delivery attempts that
9947 are initiated by queue runner processes, and false otherwise.
9948
9949radius {<authentication string>}
9950
9951 Radius authentication (RFC 2865) is supported in a similar way to PAM. You
9952 must set RADIUS_CONFIG_FILE in Local/Makefile to specify the location of
9953 the Radius client configuration file in order to build Exim with Radius
9954 support.
9955
9956 With just that one setting, Exim expects to be linked with the radiusclient
9957 library, using the original API. If you are using release 0.4.0 or later of
9958 this library, you need to set
9959
9960 RADIUS_LIB_TYPE=RADIUSCLIENTNEW
9961
9962 in Local/Makefile when building Exim. You can also link Exim with the
9963 libradius library that comes with FreeBSD. To do this, set
9964
9965 RADIUS_LIB_TYPE=RADLIB
9966
9967 in Local/Makefile, in addition to setting RADIUS_CONFIGURE_FILE. You may
9968 also have to supply a suitable setting in EXTRALIBS so that the Radius
9969 library can be found when Exim is linked.
9970
9971 The string specified by RADIUS_CONFIG_FILE is expanded and passed to the
9972 Radius client library, which calls the Radius server. The condition is true
9973 if the authentication is successful. For example:
9974
9975 server_condition = ${if radius{<arguments>}}
9976
9977saslauthd {{<user>}{<password>}{<service>}{<realm>}}
9978
9979 This condition supports user authentication using the Cyrus saslauthd
9980 daemon. This replaces the older pwcheck daemon, which is now deprecated.
9981 Using this daemon is one way of making it possible for passwords to be
9982 checked by a process that is not running as root.
9983
9984 The saslauthd support is not included in Exim by default. You need to
9985 specify the location of the saslauthd daemon's socket in Local/Makefile
9986 before building Exim. For example:
9987
9988 CYRUS_SASLAUTHD_SOCKET=/var/state/saslauthd/mux
9989
9990 You do not need to install the full Cyrus software suite in order to use
9991 the saslauthd daemon. You can compile and install just the daemon alone
9992 from the Cyrus SASL library.
9993
9994 Up to four arguments can be supplied to the saslauthd condition, but only
9995 two are mandatory. For example:
9996
9997 server_condition = ${if saslauthd{{$auth1}{$auth2}}}
9998
9999 The service and the realm are optional (which is why the arguments are
10000 enclosed in their own set of braces). For details of the meaning of the
10001 service and realm, and how to run the daemon, consult the Cyrus
10002 documentation.
10003
10004
1000511.8 Combining expansion conditions
10006-----------------------------------
10007
10008Several conditions can be tested at once by combining them using the and and or
10009combination conditions. Note that and and or are complete conditions on their
10010own, and precede their lists of sub-conditions. Each sub-condition must be
10011enclosed in braces within the overall braces that contain the list. No
10012repetition of if is used.
10013
10014or {{<cond1>}{<cond2>}...}
10015
10016 The sub-conditions are evaluated from left to right. The condition is true
10017 if any one of the sub-conditions is true. For example,
10018
10019 ${if or {{eq{$local_part}{spqr}}{eq{$domain}{testing.com}}}...
10020
10021 When a true sub-condition is found, the following ones are parsed but not
10022 evaluated. If there are several "match" sub-conditions the values of the
10023 numeric variables afterwards are taken from the first one that succeeds.
10024
10025and {{<cond1>}{<cond2>}...}
10026
10027 The sub-conditions are evaluated from left to right. The condition is true
10028 if all of the sub-conditions are true. If there are several "match"
10029 sub-conditions, the values of the numeric variables afterwards are taken
10030 from the last one. When a false sub-condition is found, the following ones
10031 are parsed but not evaluated.
10032
10033
1003411.9 Expansion variables
10035------------------------
10036
10037This section contains an alphabetical list of all the expansion variables. Some
10038of them are available only when Exim is compiled with specific options such as
10039support for TLS or the content scanning extension.
10040
10041$0, $1, etc
10042
10043 When a match expansion condition succeeds, these variables contain the
10044 captured substrings identified by the regular expression during subsequent
10045 processing of the success string of the containing if expansion item.
10046 However, they do not retain their values afterwards; in fact, their
10047 previous values are restored at the end of processing an if item. The
10048 numerical variables may also be set externally by some other matching
10049 process which precedes the expansion of the string. For example, the
10050 commands available in Exim filter files include an if command with its own
10051 regular expression matching condition.
10052
10053$acl_arg1, $acl_arg2, etc
10054
10055 Within an acl condition, expansion condition or expansion item any
10056 arguments are copied to these variables, any unused variables being made
10057 empty.
10058
10059$acl_c...
10060
10061 Values can be placed in these variables by the set modifier in an ACL. They
10062 can be given any name that starts with $acl_c and is at least six
10063 characters long, but the sixth character must be either a digit or an
10064 underscore. For example: $acl_c5, $acl_c_mycount. The values of the
10065 $acl_c... variables persist throughout the lifetime of an SMTP connection.
10066 They can be used to pass information between ACLs and between different
10067 invocations of the same ACL. When a message is received, the values of
10068 these variables are saved with the message, and can be accessed by filters,
10069 routers, and transports during subsequent delivery.
10070
10071$acl_m...
10072
10073 These variables are like the $acl_c... variables, except that their values
10074 are reset after a message has been received. Thus, if several messages are
10075 received in one SMTP connection, $acl_m... values are not passed on from
10076 one message to the next, as $acl_c... values are. The $acl_m... variables
10077 are also reset by MAIL, RSET, EHLO, HELO, and after starting a TLS session.
10078 When a message is received, the values of these variables are saved with
10079 the message, and can be accessed by filters, routers, and transports during
10080 subsequent delivery.
10081
10082$acl_narg
10083
10084 Within an acl condition, expansion condition or expansion item this
10085 variable has the number of arguments.
10086
10087$acl_verify_message
10088
10089 After an address verification has failed, this variable contains the
10090 failure message. It retains its value for use in subsequent modifiers. The
10091 message can be preserved by coding like this:
10092
10093 warn !verify = sender
10094 set acl_m0 = $acl_verify_message
10095
10096 You can use $acl_verify_message during the expansion of the message or
10097 log_message modifiers, to include information about the verification
10098 failure.
10099
10100$address_data
10101
10102 This variable is set by means of the address_data option in routers. The
10103 value then remains with the address while it is processed by subsequent
10104 routers and eventually a transport. If the transport is handling multiple
10105 addresses, the value from the first address is used. See chapter 15 for
10106 more details. Note: The contents of $address_data are visible in user
10107 filter files.
10108
10109 If $address_data is set when the routers are called from an ACL to verify a
10110 recipient address, the final value is still in the variable for subsequent
10111 conditions and modifiers of the ACL statement. If routing the address
10112 caused it to be redirected to just one address, the child address is also
10113 routed as part of the verification, and in this case the final value of
10114 $address_data is from the child's routing.
10115
10116 If $address_data is set when the routers are called from an ACL to verify a
10117 sender address, the final value is also preserved, but this time in
10118 $sender_address_data, to distinguish it from data from a recipient address.
10119
10120 In both cases (recipient and sender verification), the value does not
10121 persist after the end of the current ACL statement. If you want to preserve
10122 these values for longer, you can save them in ACL variables.
10123
10124$address_file
10125
10126 When, as a result of aliasing, forwarding, or filtering, a message is
10127 directed to a specific file, this variable holds the name of the file when
10128 the transport is running. At other times, the variable is empty. For
10129 example, using the default configuration, if user r2d2 has a .forward file
10130 containing
10131
10132 /home/r2d2/savemail
10133
10134 then when the address_file transport is running, $address_file contains the
10135 text string "/home/r2d2/savemail". For Sieve filters, the value may be
10136 "inbox" or a relative folder name. It is then up to the transport
10137 configuration to generate an appropriate absolute path to the relevant
10138 file.
10139
10140$address_pipe
10141
10142 When, as a result of aliasing or forwarding, a message is directed to a
10143 pipe, this variable holds the pipe command when the transport is running.
10144
10145$auth1 - $auth3
10146
10147 These variables are used in SMTP authenticators (see chapters 34-40).
10148 Elsewhere, they are empty.
10149
10150$authenticated_id
10151
10152 When a server successfully authenticates a client it may be configured to
10153 preserve some of the authentication information in the variable
10154 $authenticated_id (see chapter 33). For example, a user/password
10155 authenticator configuration might preserve the user name for use in the
10156 routers. Note that this is not the same information that is saved in
10157 $sender_host_authenticated. When a message is submitted locally (that is,
10158 not over a TCP connection) the value of $authenticated_id is normally the
10159 login name of the calling process. However, a trusted user can override
10160 this by means of the -oMai command line option.
10161
10162$authenticated_fail_id
10163
10164 When an authentication attempt fails, the variable $authenticated_fail_id
10165 will contain the failed authentication id. If more than one authentication
10166 id is attempted, it will contain only the last one. The variable is
10167 available for processing in the ACL's, generally the quit or notquit ACL. A
10168 message to a local recipient could still be accepted without requiring
10169 authentication, which means this variable could also be visible in all of
10170 the ACL's as well.
10171
10172$authenticated_sender
10173
10174 When acting as a server, Exim takes note of the AUTH= parameter on an
10175 incoming SMTP MAIL command if it believes the sender is sufficiently
10176 trusted, as described in section 33.2. Unless the data is the string "<>",
10177 it is set as the authenticated sender of the message, and the value is
10178 available during delivery in the $authenticated_sender variable. If the
10179 sender is not trusted, Exim accepts the syntax of AUTH=, but ignores the
10180 data.
10181
10182 When a message is submitted locally (that is, not over a TCP connection),
10183 the value of $authenticated_sender is an address constructed from the login
10184 name of the calling process and $qualify_domain, except that a trusted user
10185 can override this by means of the -oMas command line option.
10186
10187$authentication_failed
10188
10189 This variable is set to "1" in an Exim server if a client issues an AUTH
10190 command that does not succeed. Otherwise it is set to "0". This makes it
10191 possible to distinguish between "did not try to authenticate" (
10192 $sender_host_authenticated is empty and $authentication_failed is set to
10193 "0") and "tried to authenticate but failed" ($sender_host_authenticated is
10194 empty and $authentication_failed is set to "1"). Failure includes any
10195 negative response to an AUTH command, including (for example) an attempt to
10196 use an undefined mechanism.
10197
10198$av_failed
10199
10200 This variable is available when Exim is compiled with the content-scanning
10201 extension. It is set to "0" by default, but will be set to "1" if any
10202 problem occurs with the virus scanner (specified by av_scanner) during the
10203 ACL malware condition.
10204
10205$body_linecount
10206
10207 When a message is being received or delivered, this variable contains the
10208 number of lines in the message's body. See also $message_linecount.
10209
10210$body_zerocount
10211
10212 When a message is being received or delivered, this variable contains the
10213 number of binary zero bytes (ASCII NULs) in the message's body.
10214
10215$bounce_recipient
10216
10217 This is set to the recipient address of a bounce message while Exim is
10218 creating it. It is useful if a customized bounce message text file is in
10219 use (see chapter 48).
10220
10221$bounce_return_size_limit
10222
10223 This contains the value set in the bounce_return_size_limit option, rounded
10224 up to a multiple of 1000. It is useful when a customized error message text
10225 file is in use (see chapter 48).
10226
10227$caller_gid
10228
10229 The real group id under which the process that called Exim was running.
10230 This is not the same as the group id of the originator of a message (see
10231 $originator_gid). If Exim re-execs itself, this variable in the new
10232 incarnation normally contains the Exim gid.
10233
10234$caller_uid
10235
10236 The real user id under which the process that called Exim was running. This
10237 is not the same as the user id of the originator of a message (see
10238 $originator_uid). If Exim re-execs itself, this variable in the new
10239 incarnation normally contains the Exim uid.
10240
10241$compile_date
10242
10243 The date on which the Exim binary was compiled.
10244
10245$compile_number
10246
10247 The building process for Exim keeps a count of the number of times it has
10248 been compiled. This serves to distinguish different compilations of the
10249 same version of the program.
10250
10251$demime_errorlevel
10252
10253 This variable is available when Exim is compiled with the content-scanning
10254 extension and the obsolete demime condition. For details, see section 43.6.
10255
10256$demime_reason
10257
10258 This variable is available when Exim is compiled with the content-scanning
10259 extension and the obsolete demime condition. For details, see section 43.6.
10260
10261$dnslist_domain, $dnslist_matched, $dnslist_text, $dnslist_value
10262
10263 When a DNS (black) list lookup succeeds, these variables are set to contain
10264 the following data from the lookup: the list's domain name, the key that
10265 was looked up, the contents of any associated TXT record, and the value
10266 from the main A record. See section 42.32 for more details.
10267
10268$domain
10269
10270 When an address is being routed, or delivered on its own, this variable
10271 contains the domain. Uppercase letters in the domain are converted into
10272 lower case for $domain.
10273
10274 Global address rewriting happens when a message is received, so the value
10275 of $domain during routing and delivery is the value after rewriting.
10276 $domain is set during user filtering, but not during system filtering,
10277 because a message may have many recipients and the system filter is called
10278 just once.
10279
10280 When more than one address is being delivered at once (for example, several
10281 RCPT commands in one SMTP delivery), $domain is set only if they all have
10282 the same domain. Transports can be restricted to handling only one domain
10283 at a time if the value of $domain is required at transport time - this is
10284 the default for local transports. For further details of the environment in
10285 which local transports are run, see chapter 23.
10286
10287 At the end of a delivery, if all deferred addresses have the same domain,
10288 it is set in $domain during the expansion of delay_warning_condition.
10289
10290 The $domain variable is also used in some other circumstances:
10291
10292 * When an ACL is running for a RCPT command, $domain contains the domain
10293 of the recipient address. The domain of the sender address is in
10294 $sender_address_domain at both MAIL time and at RCPT time. $domain is
10295 not normally set during the running of the MAIL ACL. However, if the
10296 sender address is verified with a callout during the MAIL ACL, the
10297 sender domain is placed in $domain during the expansions of hosts,
10298 interface, and port in the smtp transport.
10299
10300 * When a rewrite item is being processed (see chapter 31), $domain
10301 contains the domain portion of the address that is being rewritten; it
10302 can be used in the expansion of the replacement address, for example,
10303 to rewrite domains by file lookup.
10304
10305 * With one important exception, whenever a domain list is being scanned,
10306 $domain contains the subject domain. Exception: When a domain list in a
10307 sender_domains condition in an ACL is being processed, the subject
10308 domain is in $sender_address_domain and not in $domain. It works this
10309 way so that, in a RCPT ACL, the sender domain list can be dependent on
10310 the recipient domain (which is what is in $domain at this time).
10311
10312 * When the smtp_etrn_command option is being expanded, $domain contains
10313 the complete argument of the ETRN command (see section 47.8).
10314
10315$domain_data
10316
10317 When the domains option on a router matches a domain by means of a lookup,
10318 the data read by the lookup is available during the running of the router
10319 as $domain_data. In addition, if the driver routes the address to a
10320 transport, the value is available in that transport. If the transport is
10321 handling multiple addresses, the value from the first address is used.
10322
10323 $domain_data is also set when the domains condition in an ACL matches a
10324 domain by means of a lookup. The data read by the lookup is available
10325 during the rest of the ACL statement. In all other situations, this
10326 variable expands to nothing.
10327
10328$exim_gid
10329
10330 This variable contains the numerical value of the Exim group id.
10331
10332$exim_path
10333
10334 This variable contains the path to the Exim binary.
10335
10336$exim_uid
10337
10338 This variable contains the numerical value of the Exim user id.
10339
10340$found_extension
10341
10342 This variable is available when Exim is compiled with the content-scanning
10343 extension and the obsolete demime condition. For details, see section 43.6.
10344
10345$header_<name>
10346
10347 This is not strictly an expansion variable. It is expansion syntax for
10348 inserting the message header line with the given name. Note that the name
10349 must be terminated by colon or white space, because it may contain a wide
10350 variety of characters. Note also that braces must not be used.
10351
10352$headers_added
10353
10354 Within an ACL this variable contains the headers added so far by the ACL
10355 modifier add_header (section 42.24). The headers are a newline-separated
10356 list.
10357
10358$home
10359
10360 When the check_local_user option is set for a router, the user's home
10361 directory is placed in $home when the check succeeds. In particular, this
10362 means it is set during the running of users' filter files. A router may
10363 also explicitly set a home directory for use by a transport; this can be
10364 overridden by a setting on the transport itself.
10365
10366 When running a filter test via the -bf option, $home is set to the value of
10367 the environment variable HOME.
10368
10369$host
10370
10371 If a router assigns an address to a transport (any transport), and passes a
10372 list of hosts with the address, the value of $host when the transport
10373 starts to run is the name of the first host on the list. Note that this
10374 applies both to local and remote transports.
10375
10376 For the smtp transport, if there is more than one host, the value of $host
10377 changes as the transport works its way through the list. In particular,
10378 when the smtp transport is expanding its options for encryption using TLS,
10379 or for specifying a transport filter (see chapter 24), $host contains the
10380 name of the host to which it is connected.
10381
10382 When used in the client part of an authenticator configuration (see chapter
10383 33), $host contains the name of the server to which the client is
10384 connected.
10385
10386$host_address
10387
10388 This variable is set to the remote host's IP address whenever $host is set
10389 for a remote connection. It is also set to the IP address that is being
10390 checked when the ignore_target_hosts option is being processed.
10391
10392$host_data
10393
10394 If a hosts condition in an ACL is satisfied by means of a lookup, the
10395 result of the lookup is made available in the $host_data variable. This
10396 allows you, for example, to do things like this:
10397
10398 deny hosts = net-lsearch;/some/file
10399 message = $host_data
10400
10401$host_lookup_deferred
10402
10403 This variable normally contains "0", as does $host_lookup_failed. When a
10404 message comes from a remote host and there is an attempt to look up the
10405 host's name from its IP address, and the attempt is not successful, one of
10406 these variables is set to "1".
10407
10408 * If the lookup receives a definite negative response (for example, a DNS
10409 lookup succeeded, but no records were found), $host_lookup_failed is
10410 set to "1".
10411
10412 * If there is any kind of problem during the lookup, such that Exim
10413 cannot tell whether or not the host name is defined (for example, a
10414 timeout for a DNS lookup), $host_lookup_deferred is set to "1".
10415
10416 Looking up a host's name from its IP address consists of more than just a
10417 single reverse lookup. Exim checks that a forward lookup of at least one of
10418 the names it receives from a reverse lookup yields the original IP address.
10419 If this is not the case, Exim does not accept the looked up name(s), and
10420 $host_lookup_failed is set to "1". Thus, being able to find a name from an
10421 IP address (for example, the existence of a PTR record in the DNS) is not
10422 sufficient on its own for the success of a host name lookup. If the reverse
10423 lookup succeeds, but there is a lookup problem such as a timeout when
10424 checking the result, the name is not accepted, and $host_lookup_deferred is
10425 set to "1". See also $sender_host_name.
10426
10427$host_lookup_failed
10428
10429 See $host_lookup_deferred.
10430
10431$inode
10432
10433 The only time this variable is set is while expanding the directory_file
10434 option in the appendfile transport. The variable contains the inode number
10435 of the temporary file which is about to be renamed. It can be used to
10436 construct a unique name for the file.
10437
10438$interface_address
10439
10440 This is an obsolete name for $received_ip_address.
10441
10442$interface_port
10443
10444 This is an obsolete name for $received_port.
10445
10446$item
10447
10448 This variable is used during the expansion of forall and forany conditions
10449 (see section 11.7), and filter, map, and reduce items (see section 11.7).
10450 In other circumstances, it is empty.
10451
10452$ldap_dn
10453
10454 This variable, which is available only when Exim is compiled with LDAP
10455 support, contains the DN from the last entry in the most recently
10456 successful LDAP lookup.
10457
10458$load_average
10459
10460 This variable contains the system load average, multiplied by 1000 so that
10461 it is an integer. For example, if the load average is 0.21, the value of
10462 the variable is 210. The value is recomputed every time the variable is
10463 referenced.
10464
10465$local_part
10466
10467 When an address is being routed, or delivered on its own, this variable
10468 contains the local part. When a number of addresses are being delivered
10469 together (for example, multiple RCPT commands in an SMTP session),
10470 $local_part is not set.
10471
10472 Global address rewriting happens when a message is received, so the value
10473 of $local_part during routing and delivery is the value after rewriting.
10474 $local_part is set during user filtering, but not during system filtering,
10475 because a message may have many recipients and the system filter is called
10476 just once.
10477
10478 If a local part prefix or suffix has been recognized, it is not included in
10479 the value of $local_part during routing and subsequent delivery. The values
10480 of any prefix or suffix are in $local_part_prefix and $local_part_suffix,
10481 respectively.
10482
10483 When a message is being delivered to a file, pipe, or autoreply transport
10484 as a result of aliasing or forwarding, $local_part is set to the local part
10485 of the parent address, not to the file name or command (see $address_file
10486 and $address_pipe).
10487
10488 When an ACL is running for a RCPT command, $local_part contains the local
10489 part of the recipient address.
10490
10491 When a rewrite item is being processed (see chapter 31), $local_part
10492 contains the local part of the address that is being rewritten; it can be
10493 used in the expansion of the replacement address, for example.
10494
10495 In all cases, all quoting is removed from the local part. For example, for
10496 both the addresses
10497
10498 "abc:xyz"@test.example
10499 abc\:xyz@test.example
10500
10501 the value of $local_part is
10502
10503 abc:xyz
10504
10505 If you use $local_part to create another address, you should always wrap it
10506 inside a quoting operator. For example, in a redirect router you could
10507 have:
10508
10509 data = ${quote_local_part:$local_part}@new.domain.example
10510
10511 Note: The value of $local_part is normally lower cased. If you want to
10512 process local parts in a case-dependent manner in a router, you can set the
10513 caseful_local_part option (see chapter 15).
10514
10515$local_part_data
10516
10517 When the local_parts option on a router matches a local part by means of a
10518 lookup, the data read by the lookup is available during the running of the
10519 router as $local_part_data. In addition, if the driver routes the address
10520 to a transport, the value is available in that transport. If the transport
10521 is handling multiple addresses, the value from the first address is used.
10522
10523 $local_part_data is also set when the local_parts condition in an ACL
10524 matches a local part by means of a lookup. The data read by the lookup is
10525 available during the rest of the ACL statement. In all other situations,
10526 this variable expands to nothing.
10527
10528$local_part_prefix
10529
10530 When an address is being routed or delivered, and a specific prefix for the
10531 local part was recognized, it is available in this variable, having been
10532 removed from $local_part.
10533
10534$local_part_suffix
10535
10536 When an address is being routed or delivered, and a specific suffix for the
10537 local part was recognized, it is available in this variable, having been
10538 removed from $local_part.
10539
10540$local_scan_data
10541
10542 This variable contains the text returned by the local_scan() function when
10543 a message is received. See chapter 44 for more details.
10544
10545$local_user_gid
10546
10547 See $local_user_uid.
10548
10549$local_user_uid
10550
10551 This variable and $local_user_gid are set to the uid and gid after the
10552 check_local_user router precondition succeeds. This means that their values
10553 are available for the remaining preconditions (senders, require_files, and
10554 condition), for the address_data expansion, and for any router-specific
10555 expansions. At all other times, the values in these variables are "(uid_t)
10556 (-1)" and "(gid_t)(-1)", respectively.
10557
10558$localhost_number
10559
10560 This contains the expanded value of the localhost_number option. The
10561 expansion happens after the main options have been read.
10562
10563$log_inodes
10564
10565 The number of free inodes in the disk partition where Exim's log files are
10566 being written. The value is recalculated whenever the variable is
10567 referenced. If the relevant file system does not have the concept of
10568 inodes, the value of is -1. See also the check_log_inodes option.
10569
10570$log_space
10571
10572 The amount of free space (as a number of kilobytes) in the disk partition
10573 where Exim's log files are being written. The value is recalculated
10574 whenever the variable is referenced. If the operating system does not have
10575 the ability to find the amount of free space (only true for experimental
10576 systems), the space value is -1. See also the check_log_space option.
10577
10578$lookup_dnssec_authenticated
10579
10580 This variable is set after a DNS lookup done by a dnsdb lookup expansion,
10581 dnslookup router or smtp transport. It will be empty if DNSSEC was not
10582 requested, "no" if the result was not labelled as authenticated data and
10583 "yes" if it was.
10584
10585$mailstore_basename
10586
10587 This variable is set only when doing deliveries in "mailstore" format in
10588 the appendfile transport. During the expansion of the mailstore_prefix,
10589 mailstore_suffix, message_prefix, and message_suffix options, it contains
10590 the basename of the files that are being written, that is, the name without
10591 the ".tmp", ".env", or ".msg" suffix. At all other times, this variable is
10592 empty.
10593
10594$malware_name
10595
10596 This variable is available when Exim is compiled with the content-scanning
10597 extension. It is set to the name of the virus that was found when the ACL
10598 malware condition is true (see section 43.1).
10599
10600$max_received_linelength
10601
10602 This variable contains the number of bytes in the longest line that was
10603 received as part of the message, not counting the line termination
10604 character(s).
10605
10606$message_age
10607
10608 This variable is set at the start of a delivery attempt to contain the
10609 number of seconds since the message was received. It does not change during
10610 a single delivery attempt.
10611
10612$message_body
10613
10614 This variable contains the initial portion of a message's body while it is
10615 being delivered, and is intended mainly for use in filter files. The
10616 maximum number of characters of the body that are put into the variable is
10617 set by the message_body_visible configuration option; the default is 500.
10618
10619 By default, newlines are converted into spaces in $message_body, to make it
10620 easier to search for phrases that might be split over a line break.
10621 However, this can be disabled by setting message_body_newlines to be true.
10622 Binary zeros are always converted into spaces.
10623
10624$message_body_end
10625
10626 This variable contains the final portion of a message's body while it is
10627 being delivered. The format and maximum size are as for $message_body.
10628
10629$message_body_size
10630
10631 When a message is being delivered, this variable contains the size of the
10632 body in bytes. The count starts from the character after the blank line
10633 that separates the body from the header. Newlines are included in the
10634 count. See also $message_size, $body_linecount, and $body_zerocount.
10635
10636$message_exim_id
10637
10638 When a message is being received or delivered, this variable contains the
10639 unique message id that is generated and used by Exim to identify the
10640 message. An id is not created for a message until after its header has been
10641 successfully received. Note: This is not the contents of the Message-ID:
10642 header line; it is the local id that Exim assigns to the message, for
10643 example: "1BXTIK-0001yO-VA".
10644
10645$message_headers
10646
10647 This variable contains a concatenation of all the header lines when a
10648 message is being processed, except for lines added by routers or
10649 transports. The header lines are separated by newline characters. Their
10650 contents are decoded in the same way as a header line that is inserted by
10651 bheader.
10652
10653$message_headers_raw
10654
10655 This variable is like $message_headers except that no processing of the
10656 contents of header lines is done.
10657
10658$message_id
10659
10660 This is an old name for $message_exim_id, which is now deprecated.
10661
10662$message_linecount
10663
10664 This variable contains the total number of lines in the header and body of
10665 the message. Compare $body_linecount, which is the count for the body only.
10666 During the DATA and content-scanning ACLs, $message_linecount contains the
10667 number of lines received. Before delivery happens (that is, before filters,
10668 routers, and transports run) the count is increased to include the
10669 Received: header line that Exim standardly adds, and also any other header
10670 lines that are added by ACLs. The blank line that separates the message
10671 header from the body is not counted.
10672
10673 As with the special case of $message_size, during the expansion of the
10674 appendfile transport's maildir_tag option in maildir format, the value of
10675 $message_linecount is the precise size of the number of newlines in the
10676 file that has been written (minus one for the blank line between the header
10677 and the body).
10678
10679 Here is an example of the use of this variable in a DATA ACL:
10680
10681 deny message = Too many lines in message header
10682 condition = \
10683 ${if <{250}{${eval:$message_linecount - $body_linecount}}}
10684
10685 In the MAIL and RCPT ACLs, the value is zero because at that stage the
10686 message has not yet been received.
10687
10688$message_size
10689
10690 When a message is being processed, this variable contains its size in
10691 bytes. In most cases, the size includes those headers that were received
10692 with the message, but not those (such as Envelope-to:) that are added to
10693 individual deliveries as they are written. However, there is one special
10694 case: during the expansion of the maildir_tag option in the appendfile
10695 transport while doing a delivery in maildir format, the value of
10696 $message_size is the precise size of the file that has been written. See
10697 also $message_body_size, $body_linecount, and $body_zerocount.
10698
10699 While running a per message ACL (mail/rcpt/predata), $message_size contains
10700 the size supplied on the MAIL command, or -1 if no size was given. The
10701 value may not, of course, be truthful.
10702
10703$mime_xxx
10704
10705 A number of variables whose names start with $mime are available when Exim
10706 is compiled with the content-scanning extension. For details, see section
10707 43.4.
10708
10709$n0 - $n9
10710
10711 These variables are counters that can be incremented by means of the add
10712 command in filter files.
10713
10714$original_domain
10715
10716 When a top-level address is being processed for delivery, this contains the
10717 same value as $domain. However, if a "child" address (for example,
10718 generated by an alias, forward, or filter file) is being processed, this
10719 variable contains the domain of the original address (lower cased). This
10720 differs from $parent_domain only when there is more than one level of
10721 aliasing or forwarding. When more than one address is being delivered in a
10722 single transport run, $original_domain is not set.
10723
10724 If a new address is created by means of a deliver command in a system
10725 filter, it is set up with an artificial "parent" address. This has the
10726 local part system-filter and the default qualify domain.
10727
10728$original_local_part
10729
10730 When a top-level address is being processed for delivery, this contains the
10731 same value as $local_part, unless a prefix or suffix was removed from the
10732 local part, because $original_local_part always contains the full local
10733 part. When a "child" address (for example, generated by an alias, forward,
10734 or filter file) is being processed, this variable contains the full local
10735 part of the original address.
10736
10737 If the router that did the redirection processed the local part
10738 case-insensitively, the value in $original_local_part is in lower case.
10739 This variable differs from $parent_local_part only when there is more than
10740 one level of aliasing or forwarding. When more than one address is being
10741 delivered in a single transport run, $original_local_part is not set.
10742
10743 If a new address is created by means of a deliver command in a system
10744 filter, it is set up with an artificial "parent" address. This has the
10745 local part system-filter and the default qualify domain.
10746
10747$originator_gid
10748
10749 This variable contains the value of $caller_gid that was set when the
10750 message was received. For messages received via the command line, this is
10751 the gid of the sending user. For messages received by SMTP over TCP/IP,
10752 this is normally the gid of the Exim user.
10753
10754$originator_uid
10755
10756 The value of $caller_uid that was set when the message was received. For
10757 messages received via the command line, this is the uid of the sending
10758 user. For messages received by SMTP over TCP/IP, this is normally the uid
10759 of the Exim user.
10760
10761$parent_domain
10762
10763 This variable is similar to $original_domain (see above), except that it
10764 refers to the immediately preceding parent address.
10765
10766$parent_local_part
10767
10768 This variable is similar to $original_local_part (see above), except that
10769 it refers to the immediately preceding parent address.
10770
10771$pid
10772
10773 This variable contains the current process id.
10774
10775$pipe_addresses
10776
10777 This is not an expansion variable, but is mentioned here because the string
10778 "$pipe_addresses" is handled specially in the command specification for the
10779 pipe transport (chapter 29) and in transport filters (described under
10780 transport_filter in chapter 24). It cannot be used in general expansion
10781 strings, and provokes an "unknown variable" error if encountered.
10782
10783$primary_hostname
10784
10785 This variable contains the value set by primary_hostname in the
10786 configuration file, or read by the uname() function. If uname() returns a
10787 single-component name, Exim calls gethostbyname() (or getipnodebyname()
10788 where available) in an attempt to acquire a fully qualified host name. See
10789 also $smtp_active_hostname.
10790
10791$prvscheck_address
10792
10793 This variable is used in conjunction with the prvscheck expansion item,
10794 which is described in sections 11.5 and 42.51.
10795
10796$prvscheck_keynum
10797
10798 This variable is used in conjunction with the prvscheck expansion item,
10799 which is described in sections 11.5 and 42.51.
10800
10801$prvscheck_result
10802
10803 This variable is used in conjunction with the prvscheck expansion item,
10804 which is described in sections 11.5 and 42.51.
10805
10806$qualify_domain
10807
10808 The value set for the qualify_domain option in the configuration file.
10809
10810$qualify_recipient
10811
10812 The value set for the qualify_recipient option in the configuration file,
10813 or if not set, the value of $qualify_domain.
10814
10815$rcpt_count
10816
10817 When a message is being received by SMTP, this variable contains the number
10818 of RCPT commands received for the current message. If this variable is used
10819 in a RCPT ACL, its value includes the current command.
10820
10821$rcpt_defer_count
10822
10823 When a message is being received by SMTP, this variable contains the number
10824 of RCPT commands in the current message that have previously been rejected
10825 with a temporary (4xx) response.
10826
10827$rcpt_fail_count
10828
10829 When a message is being received by SMTP, this variable contains the number
10830 of RCPT commands in the current message that have previously been rejected
10831 with a permanent (5xx) response.
10832
10833$received_count
10834
10835 This variable contains the number of Received: header lines in the message,
10836 including the one added by Exim (so its value is always greater than zero).
10837 It is available in the DATA ACL, the non-SMTP ACL, and while routing and
10838 delivering.
10839
10840$received_for
10841
10842 If there is only a single recipient address in an incoming message, this
10843 variable contains that address when the Received: header line is being
10844 built. The value is copied after recipient rewriting has happened, but
10845 before the local_scan() function is run.
10846
10847$received_ip_address
10848
10849 As soon as an Exim server starts processing an incoming TCP/IP connection,
10850 this variable is set to the address of the local IP interface, and
10851 $received_port is set to the local port number. (The remote IP address and
10852 port are in $sender_host_address and $sender_host_port.) When testing with
10853 -bh, the port value is -1 unless it has been set using the -oMi command
10854 line option.
10855
10856 As well as being useful in ACLs (including the "connect" ACL), these
10857 variable could be used, for example, to make the file name for a TLS
10858 certificate depend on which interface and/or port is being used for the
10859 incoming connection. The values of $received_ip_address and $received_port
10860 are saved with any messages that are received, thus making these variables
10861 available at delivery time.
10862
10863 Note: There are no equivalent variables for outgoing connections, because
10864 the values are unknown (unless they are explicitly set by options of the
10865 smtp transport).
10866
10867$received_port
10868
10869 See $received_ip_address.
10870
10871$received_protocol
10872
10873 When a message is being processed, this variable contains the name of the
10874 protocol by which it was received. Most of the names used by Exim are
10875 defined by RFCs 821, 2821, and 3848. They start with "smtp" (the client
10876 used HELO) or "esmtp" (the client used EHLO). This can be followed by "s"
10877 for secure (encrypted) and/or "a" for authenticated. Thus, for example, if
10878 the protocol is set to "esmtpsa", the message was received over an
10879 encrypted SMTP connection and the client was successfully authenticated.
10880
10881 Exim uses the protocol name "smtps" for the case when encryption is
10882 automatically set up on connection without the use of STARTTLS (see
10883 tls_on_connect_ports), and the client uses HELO to initiate the encrypted
10884 SMTP session. The name "smtps" is also used for the rare situation where
10885 the client initially uses EHLO, sets up an encrypted connection using
10886 STARTTLS, and then uses HELO afterwards.
10887
10888 The -oMr option provides a way of specifying a custom protocol name for
10889 messages that are injected locally by trusted callers. This is commonly
10890 used to identify messages that are being re-injected after some kind of
10891 scanning.
10892
10893$received_time
10894
10895 This variable contains the date and time when the current message was
10896 received, as a number of seconds since the start of the Unix epoch.
10897
10898$recipient_data
10899
10900 This variable is set after an indexing lookup success in an ACL recipients
10901 condition. It contains the data from the lookup, and the value remains set
10902 until the next recipients test. Thus, you can do things like this:
10903
10904 require recipients = cdb*@;/some/file
10905 deny some further test involving $recipient_data
10906
10907 Warning: This variable is set only when a lookup is used as an indexing
10908 method in the address list, using the semicolon syntax as in the example
10909 above. The variable is not set for a lookup that is used as part of the
10910 string expansion that all such lists undergo before being interpreted.
10911
10912$recipient_verify_failure
10913
10914 In an ACL, when a recipient verification fails, this variable contains
10915 information about the failure. It is set to one of the following words:
10916
10917 * "qualify": The address was unqualified (no domain), and the message was
10918 neither local nor came from an exempted host.
10919
10920 * "route": Routing failed.
10921
10922 * "mail": Routing succeeded, and a callout was attempted; rejection
10923 occurred at or before the MAIL command (that is, on initial connection,
10924 HELO, or MAIL).
10925
10926 * "recipient": The RCPT command in a callout was rejected.
10927
10928 * "postmaster": The postmaster check in a callout was rejected.
10929
10930 The main use of this variable is expected to be to distinguish between
10931 rejections of MAIL and rejections of RCPT.
10932
10933$recipients
10934
10935 This variable contains a list of envelope recipients for a message. A comma
10936 and a space separate the addresses in the replacement text. However, the
10937 variable is not generally available, to prevent exposure of Bcc recipients
10938 in unprivileged users' filter files. You can use $recipients only in these
10939 cases:
10940
10941 1. In a system filter file.
10942
10943 2. In the ACLs associated with the DATA command and with non-SMTP
10944 messages, that is, the ACLs defined by acl_smtp_predata, acl_smtp_data,
10945 acl_smtp_mime, acl_not_smtp_start, acl_not_smtp, and acl_not_smtp_mime.
10946
10947 3. From within a local_scan() function.
10948
10949$recipients_count
10950
10951 When a message is being processed, this variable contains the number of
10952 envelope recipients that came with the message. Duplicates are not excluded
10953 from the count. While a message is being received over SMTP, the number
10954 increases for each accepted recipient. It can be referenced in an ACL.
10955
10956$regex_match_string
10957
10958 This variable is set to contain the matching regular expression after a
10959 regex ACL condition has matched (see section 43.5).
10960
10961$reply_address
10962
10963 When a message is being processed, this variable contains the contents of
10964 the Reply-To: header line if one exists and it is not empty, or otherwise
10965 the contents of the From: header line. Apart from the removal of leading
10966 white space, the value is not processed in any way. In particular, no RFC
10967 2047 decoding or character code translation takes place.
10968
10969$return_path
10970
10971 When a message is being delivered, this variable contains the return path -
10972 the sender field that will be sent as part of the envelope. It is not
10973 enclosed in <> characters. At the start of routing an address, $return_path
10974 has the same value as $sender_address, but if, for example, an incoming
10975 message to a mailing list has been expanded by a router which specifies a
10976 different address for bounce messages, $return_path subsequently contains
10977 the new bounce address, whereas $sender_address always contains the
10978 original sender address that was received with the message. In other words,
10979 $sender_address contains the incoming envelope sender, and $return_path
10980 contains the outgoing envelope sender.
10981
10982$return_size_limit
10983
10984 This is an obsolete name for $bounce_return_size_limit.
10985
10986$router_name
10987
10988 During the running of a router this variable contains its name.
10989
10990$runrc
10991
10992 This variable contains the return code from a command that is run by the $
10993 {run...} expansion item. Warning: In a router or transport, you cannot
10994 assume the order in which option values are expanded, except for those
10995 preconditions whose order of testing is documented. Therefore, you cannot
10996 reliably expect to set $runrc by the expansion of one option, and use it in
10997 another.
10998
10999$self_hostname
11000
11001 When an address is routed to a supposedly remote host that turns out to be
11002 the local host, what happens is controlled by the self generic router
11003 option. One of its values causes the address to be passed to another
11004 router. When this happens, $self_hostname is set to the name of the local
11005 host that the original router encountered. In other circumstances its
11006 contents are null.
11007
11008$sender_address
11009
11010 When a message is being processed, this variable contains the sender's
11011 address that was received in the message's envelope. The case of letters in
11012 the address is retained, in both the local part and the domain. For bounce
11013 messages, the value of this variable is the empty string. See also
11014 $return_path.
11015
11016$sender_address_data
11017
11018 If $address_data is set when the routers are called from an ACL to verify a
11019 sender address, the final value is preserved in $sender_address_data, to
11020 distinguish it from data from a recipient address. The value does not
11021 persist after the end of the current ACL statement. If you want to preserve
11022 it for longer, you can save it in an ACL variable.
11023
11024$sender_address_domain
11025
11026 The domain portion of $sender_address.
11027
11028$sender_address_local_part
11029
11030 The local part portion of $sender_address.
11031
11032$sender_data
11033
11034 This variable is set after a lookup success in an ACL senders condition or
11035 in a router senders option. It contains the data from the lookup, and the
11036 value remains set until the next senders test. Thus, you can do things like
11037 this:
11038
11039 require senders = cdb*@;/some/file
11040 deny some further test involving $sender_data
11041
11042 Warning: This variable is set only when a lookup is used as an indexing
11043 method in the address list, using the semicolon syntax as in the example
11044 above. The variable is not set for a lookup that is used as part of the
11045 string expansion that all such lists undergo before being interpreted.
11046
11047$sender_fullhost
11048
11049 When a message is received from a remote host, this variable contains the
11050 host name and IP address in a single string. It ends with the IP address in
11051 square brackets, followed by a colon and a port number if the logging of
11052 ports is enabled. The format of the rest of the string depends on whether
11053 the host issued a HELO or EHLO SMTP command, and whether the host name was
11054 verified by looking up its IP address. (Looking up the IP address can be
11055 forced by the host_lookup option, independent of verification.) A plain
11056 host name at the start of the string is a verified host name; if this is
11057 not present, verification either failed or was not requested. A host name
11058 in parentheses is the argument of a HELO or EHLO command. This is omitted
11059 if it is identical to the verified host name or to the host's IP address in
11060 square brackets.
11061
11062$sender_helo_name
11063
11064 When a message is received from a remote host that has issued a HELO or
11065 EHLO command, the argument of that command is placed in this variable. It
11066 is also set if HELO or EHLO is used when a message is received using SMTP
11067 locally via the -bs or -bS options.
11068
11069$sender_host_address
11070
11071 When a message is received from a remote host, this variable contains that
11072 host's IP address. For locally submitted messages, it is empty.
11073
11074$sender_host_authenticated
11075
11076 This variable contains the name (not the public name) of the authenticator
11077 driver that successfully authenticated the client from which the message
11078 was received. It is empty if there was no successful authentication. See
11079 also $authenticated_id.
11080
11081$sender_host_dnssec
11082
11083 If an attempt to populate $sender_host_name has been made (by reference,
11084 hosts_lookup or otherwise) then this boolean will have been set true if,
11085 and only if, the resolver library states that the reverse DNS was
11086 authenticated data. At all other times, this variable is false.
11087
11088 It is likely that you will need to coerce DNSSEC support on in the resolver
11089 library, by setting:
11090
11091 dns_dnssec_ok = 1
11092
11093 Exim does not perform DNSSEC validation itself, instead leaving that to a
11094 validating resolver (eg, unbound, or bind with suitable configuration).
11095
11096 Exim does not (currently) check to see if the forward DNS was also secured
11097 with DNSSEC, only the reverse DNS.
11098
11099 If you have changed host_lookup_order so that "bydns" is not the first
11100 mechanism in the list, then this variable will be false.
11101
11102$sender_host_name
11103
11104 When a message is received from a remote host, this variable contains the
11105 host's name as obtained by looking up its IP address. For messages received
11106 by other means, this variable is empty.
11107
11108 If the host name has not previously been looked up, a reference to
11109 $sender_host_name triggers a lookup (for messages from remote hosts). A
11110 looked up name is accepted only if it leads back to the original IP address
11111 via a forward lookup. If either the reverse or the forward lookup fails to
11112 find any data, or if the forward lookup does not yield the original IP
11113 address, $sender_host_name remains empty, and $host_lookup_failed is set to
11114 "1".
11115
11116 However, if either of the lookups cannot be completed (for example, there
11117 is a DNS timeout), $host_lookup_deferred is set to "1", and
11118 $host_lookup_failed remains set to "0".
11119
11120 Once $host_lookup_failed is set to "1", Exim does not try to look up the
11121 host name again if there is a subsequent reference to $sender_host_name in
11122 the same Exim process, but it does try again if $host_lookup_deferred is
11123 set to "1".
11124
11125 Exim does not automatically look up every calling host's name. If you want
11126 maximum efficiency, you should arrange your configuration so that it avoids
11127 these lookups altogether. The lookup happens only if one or more of the
11128 following are true:
11129
11130 * A string containing $sender_host_name is expanded.
11131
11132 * The calling host matches the list in host_lookup. In the default
11133 configuration, this option is set to *, so it must be changed if
11134 lookups are to be avoided. (In the code, the default for host_lookup is
11135 unset.)
11136
11137 * Exim needs the host name in order to test an item in a host list. The
11138 items that require this are described in sections 10.13 and 10.17.
11139
11140 * The calling host matches helo_try_verify_hosts or helo_verify_hosts. In
11141 this case, the host name is required to compare with the name quoted in
11142 any EHLO or HELO commands that the client issues.
11143
11144 * The remote host issues a EHLO or HELO command that quotes one of the
11145 domains in helo_lookup_domains. The default value of this option is
11146
11147 helo_lookup_domains = @ : @[]
11148
11149 which causes a lookup if a remote host (incorrectly) gives the server's
11150 name or IP address in an EHLO or HELO command.
11151
11152$sender_host_port
11153
11154 When a message is received from a remote host, this variable contains the
11155 port number that was used on the remote host.
11156
11157$sender_ident
11158
11159 When a message is received from a remote host, this variable contains the
11160 identification received in response to an RFC 1413 request. When a message
11161 has been received locally, this variable contains the login name of the
11162 user that called Exim.
11163
11164$sender_rate_xxx
11165
11166 A number of variables whose names begin $sender_rate_ are set as part of
11167 the ratelimit ACL condition. Details are given in section 42.38.
11168
11169$sender_rcvhost
11170
11171 This is provided specifically for use in Received: headers. It starts with
11172 either the verified host name (as obtained from a reverse DNS lookup) or,
11173 if there is no verified host name, the IP address in square brackets. After
11174 that there may be text in parentheses. When the first item is a verified
11175 host name, the first thing in the parentheses is the IP address in square
11176 brackets, followed by a colon and a port number if port logging is enabled.
11177 When the first item is an IP address, the port is recorded as "port=xxxx"
11178 inside the parentheses.
11179
11180 There may also be items of the form "helo=xxxx" if HELO or EHLO was used
11181 and its argument was not identical to the real host name or IP address, and
11182 "ident=xxxx" if an RFC 1413 ident string is available. If all three items
11183 are present in the parentheses, a newline and tab are inserted into the
11184 string, to improve the formatting of the Received: header.
11185
11186$sender_verify_failure
11187
11188 In an ACL, when a sender verification fails, this variable contains
11189 information about the failure. The details are the same as for
11190 $recipient_verify_failure.
11191
11192$sending_ip_address
11193
11194 This variable is set whenever an outgoing SMTP connection to another host
11195 has been set up. It contains the IP address of the local interface that is
11196 being used. This is useful if a host that has more than one IP address
11197 wants to take on different personalities depending on which one is being
11198 used. For incoming connections, see $received_ip_address.
11199
11200$sending_port
11201
11202 This variable is set whenever an outgoing SMTP connection to another host
11203 has been set up. It contains the local port that is being used. For
11204 incoming connections, see $received_port.
11205
11206$smtp_active_hostname
11207
11208 During an incoming SMTP session, this variable contains the value of the
11209 active host name, as specified by the smtp_active_hostname option. The
11210 value of $smtp_active_hostname is saved with any message that is received,
11211 so its value can be consulted during routing and delivery.
11212
11213$smtp_command
11214
11215 During the processing of an incoming SMTP command, this variable contains
11216 the entire command. This makes it possible to distinguish between HELO and
11217 EHLO in the HELO ACL, and also to distinguish between commands such as
11218 these:
11219
11220 MAIL FROM:<>
11221 MAIL FROM: <>
11222
11223 For a MAIL command, extra parameters such as SIZE can be inspected. For a
11224 RCPT command, the address in $smtp_command is the original address before
11225 any rewriting, whereas the values in $local_part and $domain are taken from
11226 the address after SMTP-time rewriting.
11227
11228$smtp_command_argument
11229
11230 While an ACL is running to check an SMTP command, this variable contains
11231 the argument, that is, the text that follows the command name, with leading
11232 white space removed. Following the introduction of $smtp_command, this
11233 variable is somewhat redundant, but is retained for backwards
11234 compatibility.
11235
11236$smtp_count_at_connection_start
11237
11238 This variable is set greater than zero only in processes spawned by the
11239 Exim daemon for handling incoming SMTP connections. The name is
11240 deliberately long, in order to emphasize what the contents are. When the
11241 daemon accepts a new connection, it increments this variable. A copy of the
11242 variable is passed to the child process that handles the connection, but
11243 its value is fixed, and never changes. It is only an approximation of how
11244 many incoming connections there actually are, because many other
11245 connections may come and go while a single connection is being processed.
11246 When a child process terminates, the daemon decrements its copy of the
11247 variable.
11248
11249$sn0 - $sn9
11250
11251 These variables are copies of the values of the $n0 - $n9 accumulators that
11252 were current at the end of the system filter file. This allows a system
11253 filter file to set values that can be tested in users' filter files. For
11254 example, a system filter could set a value indicating how likely it is that
11255 a message is junk mail.
11256
11257$spam_xxx
11258
11259 A number of variables whose names start with $spam are available when Exim
11260 is compiled with the content-scanning extension. For details, see section
11261 43.2.
11262
11263$spool_directory
11264
11265 The name of Exim's spool directory.
11266
11267$spool_inodes
11268
11269 The number of free inodes in the disk partition where Exim's spool files
11270 are being written. The value is recalculated whenever the variable is
11271 referenced. If the relevant file system does not have the concept of
11272 inodes, the value of is -1. See also the check_spool_inodes option.
11273
11274$spool_space
11275
11276 The amount of free space (as a number of kilobytes) in the disk partition
11277 where Exim's spool files are being written. The value is recalculated
11278 whenever the variable is referenced. If the operating system does not have
11279 the ability to find the amount of free space (only true for experimental
11280 systems), the space value is -1. For example, to check in an ACL that there
11281 is at least 50 megabytes free on the spool, you could write:
11282
11283 condition = ${if > {$spool_space}{50000}}
11284
11285 See also the check_spool_space option.
11286
11287$thisaddress
11288
11289 This variable is set only during the processing of the foranyaddress
11290 command in a filter file. Its use is explained in the description of that
11291 command, which can be found in the separate document entitled Exim's
11292 interfaces to mail filtering.
11293
11294$tls_in_bits
11295
11296 Contains an approximation of the TLS cipher's bit-strength on the inbound
11297 connection; the meaning of this depends upon the TLS implementation used.
11298 If TLS has not been negotiated, the value will be 0. The value of this is
11299 automatically fed into the Cyrus SASL authenticator when acting as a
11300 server, to specify the "external SSF" (a SASL term).
11301
11302 The deprecated $tls_bits variable refers to the inbound side except when
11303 used in the context of an outbound SMTP delivery, when it refers to the
11304 outbound.
11305
11306$tls_out_bits
11307
11308 Contains an approximation of the TLS cipher's bit-strength on an outbound
11309 SMTP connection; the meaning of this depends upon the TLS implementation
11310 used. If TLS has not been negotiated, the value will be 0.
11311
11312$tls_in_ourcert
11313
11314 This variable refers to the certificate presented to the peer of an inbound
11315 connection when the message was received. It is only useful as the argument
11316 of a certextract expansion item, md5 or sha1 operator, or a def condition.
11317
11318$tls_in_peercert
11319
11320 This variable refers to the certificate presented by the peer of an inbound
11321 connection when the message was received. It is only useful as the argument
11322 of a certextract expansion item, md5 or sha1 operator, or a def condition.
11323
11324$tls_out_ourcert
11325
11326 This variable refers to the certificate presented to the peer of an
11327 outbound connection. It is only useful as the argument of a certextract
11328 expansion item, md5 or sha1 operator, or a def condition.
11329
11330$tls_out_peercert
11331
11332 This variable refers to the certificate presented by the peer of an
11333 outbound connection. It is only useful as the argument of a certextract
11334 expansion item, md5 or sha1 operator, or a def condition.
11335
11336$tls_in_certificate_verified
11337
11338 This variable is set to "1" if a TLS certificate was verified when the
11339 message was received, and "0" otherwise.
11340
11341 The deprecated $tls_certificate_verfied variable refers to the inbound side
11342 except when used in the context of an outbound SMTP delivery, when it
11343 refers to the outbound.
11344
11345$tls_out_certificate_verified
11346
11347 This variable is set to "1" if a TLS certificate was verified when an
11348 outbound SMTP connection was made, and "0" otherwise.
11349
11350$tls_in_cipher
11351
11352 When a message is received from a remote host over an encrypted SMTP
11353 connection, this variable is set to the cipher suite that was negotiated,
11354 for example DES-CBC3-SHA. In other circumstances, in particular, for
11355 message received over unencrypted connections, the variable is empty.
11356 Testing $tls_cipher for emptiness is one way of distinguishing between
11357 encrypted and non-encrypted connections during ACL processing.
11358
11359 The deprecated $tls_cipher variable is the same as $tls_in_cipher during
11360 message reception, but in the context of an outward SMTP delivery taking
11361 place via the smtp transport becomes the same as $tls_out_cipher.
11362
11363$tls_out_cipher
11364
11365 This variable is cleared before any outgoing SMTP connection is made, and
11366 then set to the outgoing cipher suite if one is negotiated. See chapter 41
11367 for details of TLS support and chapter 30 for details of the smtp
11368 transport.
11369
11370$tls_in_ocsp
11371
11372 When a message is received from a remote client connection the result of
11373 any OCSP request from the client is encoded in this variable:
11374
11375 0 OCSP proof was not requested (default value)
11376 1 No response to request
11377 2 Response not verified
11378 3 Verification failed
11379 4 Verification succeeded
11380
11381$tls_out_ocsp
11382
11383 When a message is sent to a remote host connection the result of any OCSP
11384 request made is encoded in this variable. See $tls_in_ocsp for values.
11385
11386$tls_in_peerdn
11387
11388 When a message is received from a remote host over an encrypted SMTP
11389 connection, and Exim is configured to request a certificate from the
11390 client, the value of the Distinguished Name of the certificate is made
11391 available in the $tls_in_peerdn during subsequent processing.
11392
11393 The deprecated $tls_peerdn variable refers to the inbound side except when
11394 used in the context of an outbound SMTP delivery, when it refers to the
11395 outbound.
11396
11397$tls_out_peerdn
11398
11399 When a message is being delivered to a remote host over an encrypted SMTP
11400 connection, and Exim is configured to request a certificate from the
11401 server, the value of the Distinguished Name of the certificate is made
11402 available in the $tls_out_peerdn during subsequent processing.
11403
11404$tls_in_sni
11405
11406 When a TLS session is being established, if the client sends the Server
11407 Name Indication extension, the value will be placed in this variable. If
11408 the variable appears in tls_certificate then this option and some others,
11409 described in 41.10, will be re-expanded early in the TLS session, to permit
11410 a different certificate to be presented (and optionally a different key to
11411 be used) to the client, based upon the value of the SNI extension.
11412
11413 The deprecated $tls_sni variable refers to the inbound side except when
11414 used in the context of an outbound SMTP delivery, when it refers to the
11415 outbound.
11416
11417$tls_out_sni
11418
11419 During outbound SMTP deliveries, this variable reflects the value of the
11420 tls_sni option on the transport.
11421
11422$tod_bsdinbox
11423
11424 The time of day and the date, in the format required for BSD-style mailbox
11425 files, for example: Thu Oct 17 17:14:09 1995.
11426
11427$tod_epoch
11428
11429 The time and date as a number of seconds since the start of the Unix epoch.
11430
11431$tod_epoch_l
11432
11433 The time and date as a number of microseconds since the start of the Unix
11434 epoch.
11435
11436$tod_full
11437
11438 A full version of the time and date, for example: Wed, 16 Oct 1995 09:51:40
11439 +0100. The timezone is always given as a numerical offset from UTC, with
11440 positive values used for timezones that are ahead (east) of UTC, and
11441 negative values for those that are behind (west).
11442
11443$tod_log
11444
11445 The time and date in the format used for writing Exim's log files, for
11446 example: 1995-10-12 15:32:29, but without a timezone.
11447
11448$tod_logfile
11449
11450 This variable contains the date in the format yyyymmdd. This is the format
11451 that is used for datestamping log files when log_file_path contains the
11452 "%D" flag.
11453
11454$tod_zone
11455
11456 This variable contains the numerical value of the local timezone, for
11457 example: -0500.
11458
11459$tod_zulu
11460
11461 This variable contains the UTC date and time in "Zulu" format, as specified
11462 by ISO 8601, for example: 20030221154023Z.
11463
11464$transport_name
11465
11466 During the running of a transport, this variable contains its name.
11467
11468$value
11469
11470 This variable contains the result of an expansion lookup, extraction
11471 operation, or external command, as described above. It is also used during
11472 a reduce expansion.
11473
11474$version_number
11475
11476 The version number of Exim.
11477
11478$warn_message_delay
11479
11480 This variable is set only during the creation of a message warning about a
11481 delivery delay. Details of its use are explained in section 48.2.
11482
11483$warn_message_recipients
11484
11485 This variable is set only during the creation of a message warning about a
11486 delivery delay. Details of its use are explained in section 48.2.
11487
11488
11489
11490===============================================================================
1149112. EMBEDDED PERL
11492
11493Exim can be built to include an embedded Perl interpreter. When this is done,
11494Perl subroutines can be called as part of the string expansion process. To make
11495use of the Perl support, you need version 5.004 or later of Perl installed on
11496your system. To include the embedded interpreter in the Exim binary, include
11497the line
11498
11499EXIM_PERL = perl.o
11500
11501in your Local/Makefile and then build Exim in the normal way.
11502
11503
1150412.1 Setting up so Perl can be used
11505-----------------------------------
11506
11507Access to Perl subroutines is via a global configuration option called
11508perl_startup and an expansion string operator ${perl ...}. If there is no
11509perl_startup option in the Exim configuration file then no Perl interpreter is
11510started and there is almost no overhead for Exim (since none of the Perl
11511library will be paged in unless used). If there is a perl_startup option then
11512the associated value is taken to be Perl code which is executed in a newly
11513created Perl interpreter.
11514
11515The value of perl_startup is not expanded in the Exim sense, so you do not need
11516backslashes before any characters to escape special meanings. The option should
11517usually be something like
11518
11519perl_startup = do '/etc/exim.pl'
11520
11521where /etc/exim.pl is Perl code which defines any subroutines you want to use
11522from Exim. Exim can be configured either to start up a Perl interpreter as soon
11523as it is entered, or to wait until the first time it is needed. Starting the
11524interpreter at the beginning ensures that it is done while Exim still has its
11525setuid privilege, but can impose an unnecessary overhead if Perl is not in fact
11526used in a particular run. Also, note that this does not mean that Exim is
11527necessarily running as root when Perl is called at a later time. By default,
11528the interpreter is started only when it is needed, but this can be changed in
11529two ways:
11530
11531 * Setting perl_at_start (a boolean option) in the configuration requests a
11532 startup when Exim is entered.
11533
11534 * The command line option -ps also requests a startup when Exim is entered,
11535 overriding the setting of perl_at_start.
11536
11537There is also a command line option -pd (for delay) which suppresses the
11538initial startup, even if perl_at_start is set.
11539
11540
1154112.2 Calling Perl subroutines
11542-----------------------------
11543
11544When the configuration file includes a perl_startup option you can make use of
11545the string expansion item to call the Perl subroutines that are defined by the
11546perl_startup code. The operator is used in any of the following forms:
11547
11548${perl{foo}}
11549${perl{foo}{argument}}
11550${perl{foo}{argument1}{argument2} ... }
11551
11552which calls the subroutine foo with the given arguments. A maximum of eight
11553arguments may be passed. Passing more than this results in an expansion failure
11554with an error message of the form
11555
11556Too many arguments passed to Perl subroutine "foo" (max is 8)
11557
11558The return value of the Perl subroutine is evaluated in a scalar context before
11559it is passed back to Exim to be inserted into the expanded string. If the
11560return value is undef, the expansion is forced to fail in the same way as an
11561explicit "fail" on an if or lookup item. If the subroutine aborts by obeying
11562Perl's die function, the expansion fails with the error message that was passed
11563to die.
11564
11565
1156612.3 Calling Exim functions from Perl
11567-------------------------------------
11568
11569Within any Perl code called from Exim, the function Exim::expand_string() is
11570available to call back into Exim's string expansion function. For example, the
11571Perl code
11572
11573my $lp = Exim::expand_string('$local_part');
11574
11575makes the current Exim $local_part available in the Perl variable $lp. Note
11576those are single quotes and not double quotes to protect against $local_part
11577being interpolated as a Perl variable.
11578
11579If the string expansion is forced to fail by a "fail" item, the result of
11580Exim::expand_string() is undef. If there is a syntax error in the expansion
11581string, the Perl call from the original expansion string fails with an
11582appropriate error message, in the same way as if die were used.
11583
11584Two other Exim functions are available for use from within Perl code.
11585Exim::debug_write() writes a string to the standard error stream if Exim's
11586debugging is enabled. If you want a newline at the end, you must supply it.
11587Exim::log_write() writes a string to Exim's main log, adding a leading
11588timestamp. In this case, you should not supply a terminating newline.
11589
11590
1159112.4 Use of standard output and error by Perl
11592---------------------------------------------
11593
11594You should not write to the standard error or output streams from within your
11595Perl code, as it is not defined how these are set up. In versions of Exim
11596before 4.50, it is possible for the standard output or error to refer to the
11597SMTP connection during message reception via the daemon. Writing to this stream
11598is certain to cause chaos. From Exim 4.50 onwards, the standard output and
11599error streams are connected to /dev/null in the daemon. The chaos is avoided,
11600but the output is lost.
11601
11602The Perl warn statement writes to the standard error stream by default. Calls
11603to warn may be embedded in Perl modules that you use, but over which you have
11604no control. When Exim starts up the Perl interpreter, it arranges for output
11605from the warn statement to be written to the Exim main log. You can change this
11606by including appropriate Perl magic somewhere in your Perl code. For example,
11607to discard warn output completely, you need this:
11608
11609$SIG{__WARN__} = sub { };
11610
11611Whenever a warn is obeyed, the anonymous subroutine is called. In this example,
11612the code for the subroutine is empty, so it does nothing, but you can include
11613any Perl code that you like. The text of the warn message is passed as the
11614first subroutine argument.
11615
11616
11617
11618===============================================================================
1161913. STARTING THE DAEMON AND THE USE OF NETWORK INTERFACES
11620
11621A host that is connected to a TCP/IP network may have one or more physical
11622hardware network interfaces. Each of these interfaces may be configured as one
11623or more "logical" interfaces, which are the entities that a program actually
11624works with. Each of these logical interfaces is associated with an IP address.
11625In addition, TCP/IP software supports "loopback" interfaces (127.0.0.1 in IPv4
11626and ::1 in IPv6), which do not use any physical hardware. Exim requires
11627knowledge about the host's interfaces for use in three different circumstances:
11628
11629 1. When a listening daemon is started, Exim needs to know which interfaces and
11630 ports to listen on.
11631
11632 2. When Exim is routing an address, it needs to know which IP addresses are
11633 associated with local interfaces. This is required for the correct
11634 processing of MX lists by removing the local host and others with the same
11635 or higher priority values. Also, Exim needs to detect cases when an address
11636 is routed to an IP address that in fact belongs to the local host. Unless
11637 the self router option or the allow_localhost option of the smtp transport
11638 is set (as appropriate), this is treated as an error situation.
11639
11640 3. When Exim connects to a remote host, it may need to know which interface to
11641 use for the outgoing connection.
11642
11643Exim's default behaviour is likely to be appropriate in the vast majority of
11644cases. If your host has only one interface, and you want all its IP addresses
11645to be treated in the same way, and you are using only the standard SMTP port,
11646you should not need to take any special action. The rest of this chapter does
11647not apply to you.
11648
11649In a more complicated situation you may want to listen only on certain
11650interfaces, or on different ports, and for this reason there are a number of
11651options that can be used to influence Exim's behaviour. The rest of this
11652chapter describes how they operate.
11653
11654When a message is received over TCP/IP, the interface and port that were
11655actually used are set in $received_ip_address and $received_port.
11656
11657
1165813.1 Starting a listening daemon
11659--------------------------------
11660
11661When a listening daemon is started (by means of the -bd command line option),
11662the interfaces and ports on which it listens are controlled by the following
11663options:
11664
11665 * daemon_smtp_ports contains a list of default ports or service names. (For
11666 backward compatibility, this option can also be specified in the singular.)
11667
11668 * local_interfaces contains list of interface IP addresses on which to
11669 listen. Each item may optionally also specify a port.
11670
11671The default list separator in both cases is a colon, but this can be changed as
11672described in section 6.19. When IPv6 addresses are involved, it is usually best
11673to change the separator to avoid having to double all the colons. For example:
11674
11675local_interfaces = <; 127.0.0.1 ; \
11676 192.168.23.65 ; \
11677 ::1 ; \
11678 3ffe:ffff:836f::fe86:a061
11679
11680There are two different formats for specifying a port along with an IP address
11681in local_interfaces:
11682
11683 1. The port is added onto the address with a dot separator. For example, to
11684 listen on port 1234 on two different IP addresses:
11685
11686 local_interfaces = <; 192.168.23.65.1234 ; \
11687 3ffe:ffff:836f::fe86:a061.1234
11688
11689 2. The IP address is enclosed in square brackets, and the port is added with a
11690 colon separator, for example:
11691
11692 local_interfaces = <; [192.168.23.65]:1234 ; \
11693 [3ffe:ffff:836f::fe86:a061]:1234
11694
11695When a port is not specified, the value of daemon_smtp_ports is used. The
11696default setting contains just one port:
11697
11698daemon_smtp_ports = smtp
11699
11700If more than one port is listed, each interface that does not have its own port
11701specified listens on all of them. Ports that are listed in daemon_smtp_ports
11702can be identified either by name (defined in /etc/services) or by number.
11703However, when ports are given with individual IP addresses in local_interfaces,
11704only numbers (not names) can be used.
11705
11706
1170713.2 Special IP listening addresses
11708-----------------------------------
11709
11710The addresses 0.0.0.0 and ::0 are treated specially. They are interpreted as
11711"all IPv4 interfaces" and "all IPv6 interfaces", respectively. In each case,
11712Exim tells the TCP/IP stack to "listen on all IPvx interfaces" instead of
11713setting up separate listening sockets for each interface. The default value of
11714local_interfaces is
11715
11716local_interfaces = 0.0.0.0
11717
11718when Exim is built without IPv6 support; otherwise it is:
11719
11720local_interfaces = <; ::0 ; 0.0.0.0
11721
11722Thus, by default, Exim listens on all available interfaces, on the SMTP port.
11723
11724
1172513.3 Overriding local_interfaces and daemon_smtp_ports
11726------------------------------------------------------
11727
11728The -oX command line option can be used to override the values of
11729daemon_smtp_ports and/or local_interfaces for a particular daemon instance.
11730Another way of doing this would be to use macros and the -D option. However,
11731-oX can be used by any admin user, whereas modification of the runtime
11732configuration by -D is allowed only when the caller is root or exim.
11733
11734The value of -oX is a list of items. The default colon separator can be changed
11735in the usual way if required. If there are any items that do not contain dots
11736or colons (that is, are not IP addresses), the value of daemon_smtp_ports is
11737replaced by the list of those items. If there are any items that do contain
11738dots or colons, the value of local_interfaces is replaced by those items. Thus,
11739for example,
11740
11741-oX 1225
11742
11743overrides daemon_smtp_ports, but leaves local_interfaces unchanged, whereas
11744
11745-oX 192.168.34.5.1125
11746
11747overrides local_interfaces, leaving daemon_smtp_ports unchanged. (However,
11748since local_interfaces now contains no items without ports, the value of
11749daemon_smtp_ports is no longer relevant in this example.)
11750
11751
1175213.4 Support for the obsolete SSMTP (or SMTPS) protocol
11753-------------------------------------------------------
11754
11755Exim supports the obsolete SSMTP protocol (also known as SMTPS) that was used
11756before the STARTTLS command was standardized for SMTP. Some legacy clients
11757still use this protocol. If the tls_on_connect_ports option is set to a list of
11758port numbers or service names, connections to those ports must use SSMTP. The
11759most common use of this option is expected to be
11760
11761tls_on_connect_ports = 465
11762
11763because 465 is the usual port number used by the legacy clients. There is also
11764a command line option -tls-on-connect, which forces all ports to behave in this
11765way when a daemon is started.
11766
11767Warning: Setting tls_on_connect_ports does not of itself cause the daemon to
11768listen on those ports. You must still specify them in daemon_smtp_ports,
11769local_interfaces, or the -oX option. (This is because tls_on_connect_ports
11770applies to inetd connections as well as to connections via the daemon.)
11771
11772
1177313.5 IPv6 address scopes
11774------------------------
11775
11776IPv6 addresses have "scopes", and a host with multiple hardware interfaces can,
11777in principle, have the same link-local IPv6 address on different interfaces.
11778Thus, additional information is needed, over and above the IP address, to
11779distinguish individual interfaces. A convention of using a percent sign
11780followed by something (often the interface name) has been adopted in some
11781cases, leading to addresses like this:
11782
11783fe80::202:b3ff:fe03:45c1%eth0
11784
11785To accommodate this usage, a percent sign followed by an arbitrary string is
11786allowed at the end of an IPv6 address. By default, Exim calls getaddrinfo() to
11787convert a textual IPv6 address for actual use. This function recognizes the
11788percent convention in operating systems that support it, and it processes the
11789address appropriately. Unfortunately, some older libraries have problems with
11790getaddrinfo(). If
11791
11792IPV6_USE_INET_PTON=yes
11793
11794is set in Local/Makefile (or an OS-dependent Makefile) when Exim is built, Exim
11795uses inet_pton() to convert a textual IPv6 address for actual use, instead of
11796getaddrinfo(). (Before version 4.14, it always used this function.) Of course,
11797this means that the additional functionality of getaddrinfo() - recognizing
11798scoped addresses - is lost.
11799
11800
1180113.6 Disabling IPv6
11802-------------------
11803
11804Sometimes it happens that an Exim binary that was compiled with IPv6 support is
11805run on a host whose kernel does not support IPv6. The binary will fall back to
11806using IPv4, but it may waste resources looking up AAAA records, and trying to
11807connect to IPv6 addresses, causing delays to mail delivery. If you set the
11808disable_ipv6 option true, even if the Exim binary has IPv6 support, no IPv6
11809activities take place. AAAA records are never looked up, and any IPv6 addresses
11810that are listed in local_interfaces, data for the manualroute router, etc. are
11811ignored. If IP literals are enabled, the ipliteral router declines to handle
11812IPv6 literal addresses.
11813
11814On the other hand, when IPv6 is in use, there may be times when you want to
11815disable it for certain hosts or domains. You can use the dns_ipv4_lookup option
11816to globally suppress the lookup of AAAA records for specified domains, and you
11817can use the ignore_target_hosts generic router option to ignore IPv6 addresses
11818in an individual router.
11819
11820
1182113.7 Examples of starting a listening daemon
11822--------------------------------------------
11823
11824The default case in an IPv6 environment is
11825
11826daemon_smtp_ports = smtp
11827local_interfaces = <; ::0 ; 0.0.0.0
11828
11829This specifies listening on the smtp port on all IPv6 and IPv4 interfaces.
11830Either one or two sockets may be used, depending on the characteristics of the
11831TCP/IP stack. (This is complicated and messy; for more information, read the
11832comments in the daemon.c source file.)
11833
11834To specify listening on ports 25 and 26 on all interfaces:
11835
11836daemon_smtp_ports = 25 : 26
11837
11838(leaving local_interfaces at the default setting) or, more explicitly:
11839
11840local_interfaces = <; ::0.25 ; ::0.26 \
11841 0.0.0.0.25 ; 0.0.0.0.26
11842
11843To listen on the default port on all IPv4 interfaces, and on port 26 on the
11844IPv4 loopback address only:
11845
11846local_interfaces = 0.0.0.0 : 127.0.0.1.26
11847
11848To specify listening on the default port on specific interfaces only:
11849
11850local_interfaces = 10.0.0.67 : 192.168.34.67
11851
11852Warning: Such a setting excludes listening on the loopback interfaces.
11853
11854
1185513.8 Recognizing the local host
11856-------------------------------
11857
11858The local_interfaces option is also used when Exim needs to determine whether
11859or not an IP address refers to the local host. That is, the IP addresses of all
11860the interfaces on which a daemon is listening are always treated as local.
11861
11862For this usage, port numbers in local_interfaces are ignored. If either of the
11863items 0.0.0.0 or ::0 are encountered, Exim gets a complete list of available
11864interfaces from the operating system, and extracts the relevant (that is, IPv4
11865or IPv6) addresses to use for checking.
11866
11867Some systems set up large numbers of virtual interfaces in order to provide
11868many virtual web servers. In this situation, you may want to listen for email
11869on only a few of the available interfaces, but nevertheless treat all
11870interfaces as local when routing. You can do this by setting
11871extra_local_interfaces to a list of IP addresses, possibly including the "all"
11872wildcard values. These addresses are recognized as local, but are not used for
11873listening. Consider this example:
11874
11875local_interfaces = <; 127.0.0.1 ; ::1 ; \
11876 192.168.53.235 ; \
11877 3ffe:2101:12:1:a00:20ff:fe86:a061
11878
11879extra_local_interfaces = <; ::0 ; 0.0.0.0
11880
11881The daemon listens on the loopback interfaces and just one IPv4 and one IPv6
11882address, but all available interface addresses are treated as local when Exim
11883is routing.
11884
11885In some environments the local host name may be in an MX list, but with an IP
11886address that is not assigned to any local interface. In other cases it may be
11887desirable to treat other host names as if they referred to the local host. Both
11888these cases can be handled by setting the hosts_treat_as_local option. This
11889contains host names rather than IP addresses. When a host is referenced during
11890routing, either via an MX record or directly, it is treated as the local host
11891if its name matches hosts_treat_as_local, or if any of its IP addresses match
11892local_interfaces or extra_local_interfaces.
11893
11894
1189513.9 Delivering to a remote host
11896--------------------------------
11897
11898Delivery to a remote host is handled by the smtp transport. By default, it
11899allows the system's TCP/IP functions to choose which interface to use (if there
11900is more than one) when connecting to a remote host. However, the interface
11901option can be set to specify which interface is used. See the description of
11902the smtp transport in chapter 30 for more details.
11903
11904
11905
11906===============================================================================
1190714. MAIN CONFIGURATION
11908
11909The first part of the run time configuration file contains three types of item:
11910
11911 * Macro definitions: These lines start with an upper case letter. See section
11912 6.4 for details of macro processing.
11913
11914 * Named list definitions: These lines start with one of the words
11915 "domainlist", "hostlist", "addresslist", or "localpartlist". Their use is
11916 described in section 10.5.
11917
11918 * Main configuration settings: Each setting occupies one line of the file
11919 (with possible continuations). If any setting is preceded by the word
11920 "hide", the -bP command line option displays its value to admin users only.
11921 See section 6.10 for a description of the syntax of these option settings.
11922
11923This chapter specifies all the main configuration options, along with their
11924types and default values. For ease of finding a particular option, they appear
11925in alphabetical order in section 14.23 below. However, because there are now so
11926many options, they are first listed briefly in functional groups, as an aid to
11927finding the name of the option you are looking for. Some options are listed in
11928more than one group.
11929
11930
1193114.1 Miscellaneous
11932------------------
11933
11934bi_command to run for -bi command line option
11935disable_ipv6 do no IPv6 processing
11936keep_malformed for broken files - should not happen
11937localhost_number for unique message ids in clusters
11938message_body_newlines retain newlines in $message_body
11939message_body_visible how much to show in $message_body
11940mua_wrapper run in "MUA wrapper" mode
11941print_topbitchars top-bit characters are printing
11942timezone force time zone
11943
11944
1194514.2 Exim parameters
11946--------------------
11947
11948exim_group override compiled-in value
11949exim_path override compiled-in value
11950exim_user override compiled-in value
11951primary_hostname default from uname()
11952split_spool_directory use multiple directories
11953spool_directory override compiled-in value
11954
11955
1195614.3 Privilege controls
11957-----------------------
11958
11959admin_groups groups that are Exim admin users
11960deliver_drop_privilege drop root for delivery processes
11961local_from_check insert Sender: if necessary
11962local_from_prefix for testing From: for local sender
11963local_from_suffix for testing From: for local sender
11964local_sender_retain keep Sender: from untrusted user
11965never_users do not run deliveries as these
11966prod_requires_admin forced delivery requires admin user
11967queue_list_requires_admin queue listing requires admin user
11968trusted_groups groups that are trusted
11969trusted_users users that are trusted
11970
11971
1197214.4 Logging
11973------------
11974
11975hosts_connection_nolog exemption from connect logging
11976log_file_path override compiled-in value
11977log_selector set/unset optional logging
11978log_timezone add timezone to log lines
11979message_logs create per-message logs
11980preserve_message_logs after message completion
11981process_log_path for SIGUSR1 and exiwhat
11982syslog_duplication controls duplicate log lines on syslog
11983syslog_facility set syslog "facility" field
11984syslog_processname set syslog "ident" field
11985syslog_timestamp timestamp syslog lines
11986write_rejectlog control use of message log
11987
11988
1198914.5 Frozen messages
11990--------------------
11991
11992auto_thaw sets time for retrying frozen messages
11993freeze_tell send message when freezing
11994move_frozen_messages to another directory
11995timeout_frozen_after keep frozen messages only so long
11996
11997
1199814.6 Data lookups
11999-----------------
12000
12001ibase_servers InterBase servers
12002ldap_ca_cert_dir dir of CA certs to verify LDAP server's
12003ldap_ca_cert_file file of CA certs to verify LDAP server's
12004ldap_cert_file client cert file for LDAP
12005ldap_cert_key client key file for LDAP
12006ldap_cipher_suite TLS negotiation preference control
12007ldap_default_servers used if no server in query
12008ldap_require_cert action to take without LDAP server cert
12009ldap_start_tls require TLS within LDAP
12010ldap_version set protocol version
12011lookup_open_max lookup files held open
12012mysql_servers default MySQL servers
12013oracle_servers Oracle servers
12014pgsql_servers default PostgreSQL servers
12015sqlite_lock_timeout as it says
12016
12017
1201814.7 Message ids
12019----------------
12020
12021message_id_header_domain used to build Message-ID: header
12022message_id_header_text ditto
12023
12024
1202514.8 Embedded Perl Startup
12026--------------------------
12027
12028perl_at_start always start the interpreter
12029perl_startup code to obey when starting Perl
12030
12031
1203214.9 Daemon
12033-----------
12034
12035daemon_smtp_ports default ports
12036daemon_startup_retries number of times to retry
12037daemon_startup_sleep time to sleep between tries
12038extra_local_interfaces not necessarily listened on
12039local_interfaces on which to listen, with optional ports
12040pid_file_path override compiled-in value
12041queue_run_max maximum simultaneous queue runners
12042
12043
1204414.10 Resource control
12045----------------------
12046
12047check_log_inodes before accepting a message
12048check_log_space before accepting a message
12049check_spool_inodes before accepting a message
12050check_spool_space before accepting a message
12051deliver_queue_load_max no queue deliveries if load high
12052queue_only_load queue incoming if load high
12053queue_only_load_latch don't re-evaluate load for each message
12054queue_run_max maximum simultaneous queue runners
12055remote_max_parallel parallel SMTP delivery per message
12056smtp_accept_max simultaneous incoming connections
12057smtp_accept_max_nonmail non-mail commands
12058smtp_accept_max_nonmail_hosts hosts to which the limit applies
12059smtp_accept_max_per_connection messages per connection
12060smtp_accept_max_per_host connections from one host
12061smtp_accept_queue queue mail if more connections
12062smtp_accept_queue_per_connection queue if more messages per connection
12063smtp_accept_reserve only reserve hosts if more connections
12064smtp_check_spool_space from SIZE on MAIL command
12065smtp_connect_backlog passed to TCP/IP stack
12066smtp_load_reserve SMTP from reserved hosts if load high
12067smtp_reserve_hosts these are the reserve hosts
12068
12069
1207014.11 Policy controls
12071---------------------
12072
12073acl_not_smtp ACL for non-SMTP messages
12074acl_not_smtp_mime ACL for non-SMTP MIME parts
12075acl_not_smtp_start ACL for start of non-SMTP message
12076acl_smtp_auth ACL for AUTH
12077acl_smtp_connect ACL for connection
12078acl_smtp_data ACL for DATA
12079acl_smtp_data_prdr ACL for DATA, per-recipient
12080acl_smtp_dkim ACL for DKIM verification
12081acl_smtp_etrn ACL for ETRN
12082acl_smtp_expn ACL for EXPN
12083acl_smtp_helo ACL for EHLO or HELO
12084acl_smtp_mail ACL for MAIL
12085acl_smtp_mailauth ACL for AUTH on MAIL command
12086acl_smtp_mime ACL for MIME parts
12087acl_smtp_predata ACL for start of data
12088acl_smtp_quit ACL for QUIT
12089acl_smtp_rcpt ACL for RCPT
12090acl_smtp_starttls ACL for STARTTLS
12091acl_smtp_vrfy ACL for VRFY
12092av_scanner specify virus scanner
12093check_rfc2047_length check length of RFC 2047 "encoded words"
12094dns_csa_search_limit control CSA parent search depth
12095dns_csa_use_reverse en/disable CSA IP reverse search
12096header_maxsize total size of message header
12097header_line_maxsize individual header line limit
12098helo_accept_junk_hosts allow syntactic junk from these hosts
12099helo_allow_chars allow illegal chars in HELO names
12100helo_lookup_domains lookup hostname for these HELO names
12101helo_try_verify_hosts HELO soft-checked for these hosts
12102helo_verify_hosts HELO hard-checked for these hosts
12103host_lookup host name looked up for these hosts
12104host_lookup_order order of DNS and local name lookups
12105host_reject_connection reject connection from these hosts
12106hosts_treat_as_local useful in some cluster configurations
12107local_scan_timeout timeout for local_scan()
12108message_size_limit for all messages
12109percent_hack_domains recognize %-hack for these domains
12110spamd_address set interface to SpamAssassin
12111strict_acl_vars object to unset ACL variables
12112
12113
1211414.12 Callout cache
12115-------------------
12116
12117callout_domain_negative_expire timeout for negative domain cache item
12118callout_domain_positive_expire timeout for positive domain cache item
12119callout_negative_expire timeout for negative address cache item
12120callout_positive_expire timeout for positive address cache item
12121callout_random_local_part string to use for "random" testing
12122
12123
1212414.13 TLS
12125---------
12126
12127gnutls_compat_mode use GnuTLS compatibility mode
12128gnutls_allow_auto_pkcs11 allow GnuTLS to autoload PKCS11 modules
12129openssl_options adjust OpenSSL compatibility options
12130tls_advertise_hosts advertise TLS to these hosts
12131tls_certificate location of server certificate
12132tls_crl certificate revocation list
12133tls_dh_max_bits clamp D-H bit count suggestion
12134tls_dhparam DH parameters for server
12135tls_ocsp_file location of server certificate status proof
12136tls_on_connect_ports specify SSMTP (SMTPS) ports
12137tls_privatekey location of server private key
12138tls_remember_esmtp don't reset after starting TLS
12139tls_require_ciphers specify acceptable ciphers
12140tls_try_verify_hosts try to verify client certificate
12141tls_verify_certificates expected client certificates
12142tls_verify_hosts insist on client certificate verify
12143
12144
1214514.14 Local user handling
12146-------------------------
12147
12148finduser_retries useful in NIS environments
12149gecos_name used when creating Sender:
12150gecos_pattern ditto
12151max_username_length for systems that truncate
12152unknown_login used when no login name found
12153unknown_username ditto
12154uucp_from_pattern for recognizing "From " lines
12155uucp_from_sender ditto
12156
12157
1215814.15 All incoming messages (SMTP and non-SMTP)
12159-----------------------------------------------
12160
12161header_maxsize total size of message header
12162header_line_maxsize individual header line limit
12163message_size_limit applies to all messages
12164percent_hack_domains recognize %-hack for these domains
12165received_header_text expanded to make Received:
12166received_headers_max for mail loop detection
12167recipients_max limit per message
12168recipients_max_reject permanently reject excess recipients
12169
12170
1217114.16 Non-SMTP incoming messages
12172--------------------------------
12173
12174receive_timeout for non-SMTP messages
12175
12176
1217714.17 Incoming SMTP messages
12178----------------------------
12179
12180See also the Policy controls section above.
12181
12182host_lookup host name looked up for these hosts
12183host_lookup_order order of DNS and local name lookups
12184recipient_unqualified_hosts may send unqualified recipients
12185rfc1413_hosts make ident calls to these hosts
12186rfc1413_query_timeout zero disables ident calls
12187sender_unqualified_hosts may send unqualified senders
12188smtp_accept_keepalive some TCP/IP magic
12189smtp_accept_max simultaneous incoming connections
12190smtp_accept_max_nonmail non-mail commands
12191smtp_accept_max_nonmail_hosts hosts to which the limit applies
12192smtp_accept_max_per_connection messages per connection
12193smtp_accept_max_per_host connections from one host
12194smtp_accept_queue queue mail if more connections
12195smtp_accept_queue_per_connection queue if more messages per connection
12196smtp_accept_reserve only reserve hosts if more connections
12197smtp_active_hostname host name to use in messages
12198smtp_banner text for welcome banner
12199smtp_check_spool_space from SIZE on MAIL command
12200smtp_connect_backlog passed to TCP/IP stack
12201smtp_enforce_sync of SMTP command/responses
12202smtp_etrn_command what to run for ETRN
12203smtp_etrn_serialize only one at once
12204smtp_load_reserve only reserve hosts if this load
12205smtp_max_unknown_commands before dropping connection
12206smtp_ratelimit_hosts apply ratelimiting to these hosts
12207smtp_ratelimit_mail ratelimit for MAIL commands
12208smtp_ratelimit_rcpt ratelimit for RCPT commands
12209smtp_receive_timeout per command or data line
12210smtp_reserve_hosts these are the reserve hosts
12211smtp_return_error_details give detail on rejections
12212
12213
1221414.18 SMTP extensions
12215---------------------
12216
12217accept_8bitmime advertise 8BITMIME
12218auth_advertise_hosts advertise AUTH to these hosts
12219ignore_fromline_hosts allow "From " from these hosts
12220ignore_fromline_local allow "From " from local SMTP
12221pipelining_advertise_hosts advertise pipelining to these hosts
12222prdr_enable advertise PRDR to all hosts
12223tls_advertise_hosts advertise TLS to these hosts
12224
12225
1222614.19 Processing messages
12227-------------------------
12228
12229allow_domain_literals recognize domain literal syntax
12230allow_mx_to_ip allow MX to point to IP address
12231allow_utf8_domains in addresses
12232check_rfc2047_length check length of RFC 2047 "encoded words"
12233delivery_date_remove from incoming messages
12234envelope_to_remove from incoming messages
12235extract_addresses_remove_arguments affects -t processing
12236headers_charset default for translations
12237qualify_domain default for senders
12238qualify_recipient default for recipients
12239return_path_remove from incoming messages
12240strip_excess_angle_brackets in addresses
12241strip_trailing_dot at end of addresses
12242untrusted_set_sender untrusted can set envelope sender
12243
12244
1224514.20 System filter
12246-------------------
12247
12248system_filter locate system filter
12249system_filter_directory_transport transport for delivery to a directory
12250system_filter_file_transport transport for delivery to a file
12251system_filter_group group for filter running
12252system_filter_pipe_transport transport for delivery to a pipe
12253system_filter_reply_transport transport for autoreply delivery
12254system_filter_user user for filter running
12255
12256
1225714.21 Routing and delivery
12258--------------------------
12259
12260disable_ipv6 do no IPv6 processing
12261dns_again_means_nonexist for broken domains
12262dns_check_names_pattern pre-DNS syntax check
12263dns_dnssec_ok parameter for resolver
12264dns_ipv4_lookup only v4 lookup for these domains
12265dns_retrans parameter for resolver
12266dns_retry parameter for resolver
12267dns_use_edns0 parameter for resolver
12268hold_domains hold delivery for these domains
12269local_interfaces for routing checks
12270queue_domains no immediate delivery for these
12271queue_only no immediate delivery at all
12272queue_only_file no immediate delivery if file exists
12273queue_only_load no immediate delivery if load is high
12274queue_only_load_latch don't re-evaluate load for each message
12275queue_only_override allow command line to override
12276queue_run_in_order order of arrival
12277queue_run_max of simultaneous queue runners
12278queue_smtp_domains no immediate SMTP delivery for these
12279remote_max_parallel parallel SMTP delivery per message
12280remote_sort_domains order of remote deliveries
12281retry_data_expire timeout for retry data
12282retry_interval_max safety net for retry rules
12283
12284
1228514.22 Bounce and warning messages
12286---------------------------------
12287
12288bounce_message_file content of bounce
12289bounce_message_text content of bounce
12290bounce_return_body include body if returning message
12291bounce_return_message include original message in bounce
12292bounce_return_size_limit limit on returned message
12293bounce_sender_authentication send authenticated sender with bounce
12294dsn_from set From: contents in bounces
12295errors_copy copy bounce messages
12296errors_reply_to Reply-to: in bounces
12297delay_warning time schedule
12298delay_warning_condition condition for warning messages
12299ignore_bounce_errors_after discard undeliverable bounces
12300smtp_return_error_details give detail on rejections
12301warn_message_file content of warning message
12302
12303
1230414.23 Alphabetical list of main options
12305---------------------------------------
12306
12307Those options that undergo string expansion before use are marked with *.
12308
12309+---------------+---------+-------------+-------------+
12310|accept_8bitmime|Use: main|Type: boolean|Default: true|
12311+---------------+---------+-------------+-------------+
12312
12313This option causes Exim to send 8BITMIME in its response to an SMTP EHLO
12314command, and to accept the BODY= parameter on MAIL commands. However, though
12315Exim is 8-bit clean, it is not a protocol converter, and it takes no steps to
12316do anything special with messages received by this route.
12317
12318Historically Exim kept this option off by default, but the maintainers feel
12319that in today's Internet, this causes more problems than it solves. It now
12320defaults to true. A more detailed analysis of the issues is provided by Dan
12321Bernstein:
12322
12323http://cr.yp.to/smtp/8bitmime.html
12324
12325To log received 8BITMIME status use
12326
12327log_selector = +8bitmime
12328
12329+------------+---------+-------------+--------------+
12330|acl_not_smtp|Use: main|Type: string*|Default: unset|
12331+------------+---------+-------------+--------------+
12332
12333This option defines the ACL that is run when a non-SMTP message has been read
12334and is on the point of being accepted. See chapter 42 for further details.
12335
12336+-----------------+---------+-------------+--------------+
12337|acl_not_smtp_mime|Use: main|Type: string*|Default: unset|
12338+-----------------+---------+-------------+--------------+
12339
12340This option defines the ACL that is run for individual MIME parts of non-SMTP
12341messages. It operates in exactly the same way as acl_smtp_mime operates for
12342SMTP messages.
12343
12344+------------------+---------+-------------+--------------+
12345|acl_not_smtp_start|Use: main|Type: string*|Default: unset|
12346+------------------+---------+-------------+--------------+
12347
12348This option defines the ACL that is run before Exim starts reading a non-SMTP
12349message. See chapter 42 for further details.
12350
12351+-------------+---------+-------------+--------------+
12352|acl_smtp_auth|Use: main|Type: string*|Default: unset|
12353+-------------+---------+-------------+--------------+
12354
12355This option defines the ACL that is run when an SMTP AUTH command is received.
12356See chapter 42 for further details.
12357
12358+----------------+---------+-------------+--------------+
12359|acl_smtp_connect|Use: main|Type: string*|Default: unset|
12360+----------------+---------+-------------+--------------+
12361
12362This option defines the ACL that is run when an SMTP connection is received.
12363See chapter 42 for further details.
12364
12365+-------------+---------+-------------+--------------+
12366|acl_smtp_data|Use: main|Type: string*|Default: unset|
12367+-------------+---------+-------------+--------------+
12368
12369This option defines the ACL that is run after an SMTP DATA command has been
12370processed and the message itself has been received, but before the final
12371acknowledgment is sent. See chapter 42 for further details.
12372
12373+------------------+---------+-------------+--------------+
12374|acl_smtp_data_prdr|Use: main|Type: string*|Default: unset|
12375+------------------+---------+-------------+--------------+
12376
12377This option defines the ACL that, if the PRDR feature has been negotiated, is
12378run for each recipient after an SMTP DATA command has been processed and the
12379message itself has been received, but before the acknowledgment is sent. See
12380chapter 42 for further details.
12381
12382+-------------+---------+-------------+--------------+
12383|acl_smtp_etrn|Use: main|Type: string*|Default: unset|
12384+-------------+---------+-------------+--------------+
12385
12386This option defines the ACL that is run when an SMTP ETRN command is received.
12387See chapter 42 for further details.
12388
12389+-------------+---------+-------------+--------------+
12390|acl_smtp_expn|Use: main|Type: string*|Default: unset|
12391+-------------+---------+-------------+--------------+
12392
12393This option defines the ACL that is run when an SMTP EXPN command is received.
12394See chapter 42 for further details.
12395
12396+-------------+---------+-------------+--------------+
12397|acl_smtp_helo|Use: main|Type: string*|Default: unset|
12398+-------------+---------+-------------+--------------+
12399
12400This option defines the ACL that is run when an SMTP EHLO or HELO command is
12401received. See chapter 42 for further details.
12402
12403+-------------+---------+-------------+--------------+
12404|acl_smtp_mail|Use: main|Type: string*|Default: unset|
12405+-------------+---------+-------------+--------------+
12406
12407This option defines the ACL that is run when an SMTP MAIL command is received.
12408See chapter 42 for further details.
12409
12410+-----------------+---------+-------------+--------------+
12411|acl_smtp_mailauth|Use: main|Type: string*|Default: unset|
12412+-----------------+---------+-------------+--------------+
12413
12414This option defines the ACL that is run when there is an AUTH parameter on a
12415MAIL command. See chapter 42 for details of ACLs, and chapter 33 for details of
12416authentication.
12417
12418+-------------+---------+-------------+--------------+
12419|acl_smtp_mime|Use: main|Type: string*|Default: unset|
12420+-------------+---------+-------------+--------------+
12421
12422This option is available when Exim is built with the content-scanning
12423extension. It defines the ACL that is run for each MIME part in a message. See
12424section 43.4 for details.
12425
12426+----------------+---------+-------------+--------------+
12427|acl_smtp_predata|Use: main|Type: string*|Default: unset|
12428+----------------+---------+-------------+--------------+
12429
12430This option defines the ACL that is run when an SMTP DATA command is received,
12431before the message itself is received. See chapter 42 for further details.
12432
12433+-------------+---------+-------------+--------------+
12434|acl_smtp_quit|Use: main|Type: string*|Default: unset|
12435+-------------+---------+-------------+--------------+
12436
12437This option defines the ACL that is run when an SMTP QUIT command is received.
12438See chapter 42 for further details.
12439
12440+-------------+---------+-------------+--------------+
12441|acl_smtp_rcpt|Use: main|Type: string*|Default: unset|
12442+-------------+---------+-------------+--------------+
12443
12444This option defines the ACL that is run when an SMTP RCPT command is received.
12445See chapter 42 for further details.
12446
12447+-----------------+---------+-------------+--------------+
12448|acl_smtp_starttls|Use: main|Type: string*|Default: unset|
12449+-----------------+---------+-------------+--------------+
12450
12451This option defines the ACL that is run when an SMTP STARTTLS command is
12452received. See chapter 42 for further details.
12453
12454+-------------+---------+-------------+--------------+
12455|acl_smtp_vrfy|Use: main|Type: string*|Default: unset|
12456+-------------+---------+-------------+--------------+
12457
12458This option defines the ACL that is run when an SMTP VRFY command is received.
12459See chapter 42 for further details.
12460
188b6fee
CE
12461+---------------+---------+-----------------+--------------+
12462|add_environment|Use: main|Type: string list|Default: empty|
12463+---------------+---------+-----------------+--------------+
12464
12465This option allows to set individual environment variables that the currently
12466linked libraries and programs in child processes use. The default list is
12467empty,
12468
420a0d19
CE
12469+------------+---------+------------------+--------------+
12470|admin_groups|Use: main|Type: string list*|Default: unset|
12471+------------+---------+------------------+--------------+
12472
12473This option is expanded just once, at the start of Exim's processing. If the
12474current group or any of the supplementary groups of an Exim caller is in this
12475colon-separated list, the caller has admin privileges. If all your system
12476programmers are in a specific group, for example, you can give them all Exim
12477admin privileges by putting that group in admin_groups. However, this does not
12478permit them to read Exim's spool files (whose group owner is the Exim gid). To
12479permit this, you have to add individuals to the Exim group.
12480
12481+---------------------+---------+-------------+--------------+
12482|allow_domain_literals|Use: main|Type: boolean|Default: false|
12483+---------------------+---------+-------------+--------------+
12484
12485If this option is set, the RFC 2822 domain literal format is permitted in email
12486addresses. The option is not set by default, because the domain literal format
12487is not normally required these days, and few people know about it. It has,
12488however, been exploited by mail abusers.
12489
12490Unfortunately, it seems that some DNS black list maintainers are using this
12491format to report black listing to postmasters. If you want to accept messages
12492addressed to your hosts by IP address, you need to set allow_domain_literals
12493true, and also to add "@[]" to the list of local domains (defined in the named
12494domain list local_domains in the default configuration). This "magic string"
12495matches the domain literal form of all the local host's IP addresses.
12496
12497+--------------+---------+-------------+--------------+
12498|allow_mx_to_ip|Use: main|Type: boolean|Default: false|
12499+--------------+---------+-------------+--------------+
12500
12501It appears that more and more DNS zone administrators are breaking the rules
12502and putting domain names that look like IP addresses on the right hand side of
12503MX records. Exim follows the rules and rejects this, giving an error message
12504that explains the mis-configuration. However, some other MTAs support this
12505practice, so to avoid "Why can't Exim do this?" complaints, allow_mx_to_ip
12506exists, in order to enable this heinous activity. It is not recommended, except
12507when you have no other choice.
12508
12509+------------------+---------+-------------+--------------+
12510|allow_utf8_domains|Use: main|Type: boolean|Default: false|
12511+------------------+---------+-------------+--------------+
12512
12513Lots of discussion is going on about internationalized domain names. One camp
12514is strongly in favour of just using UTF-8 characters, and it seems that at
12515least two other MTAs permit this. This option allows Exim users to experiment
12516if they wish.
12517
12518If it is set true, Exim's domain parsing function allows valid UTF-8
12519multicharacters to appear in domain name components, in addition to letters,
12520digits, and hyphens. However, just setting this option is not enough; if you
12521want to look up these domain names in the DNS, you must also adjust the value
12522of dns_check_names_pattern to match the extended form. A suitable setting is:
12523
12524dns_check_names_pattern = (?i)^(?>(?(1)\.|())[a-z0-9\xc0-\xff]\
12525 (?>[-a-z0-9\x80-\xff]*[a-z0-9\x80-\xbf])?)+$
12526
12527Alternatively, you can just disable this feature by setting
12528
12529dns_check_names_pattern =
12530
12531That is, set the option to an empty string so that no check is done.
12532
12533+--------------------+---------+----------------+----------+
12534|auth_advertise_hosts|Use: main|Type: host list*|Default: *|
12535+--------------------+---------+----------------+----------+
12536
12537If any server authentication mechanisms are configured, Exim advertises them in
12538response to an EHLO command only if the calling host matches this list.
12539Otherwise, Exim does not advertise AUTH. Exim does not accept AUTH commands
12540from clients to which it has not advertised the availability of AUTH. The
12541advertising of individual authentication mechanisms can be controlled by the
12542use of the server_advertise_condition generic authenticator option on the
12543individual authenticators. See chapter 33 for further details.
12544
12545Certain mail clients (for example, Netscape) require the user to provide a name
12546and password for authentication if AUTH is advertised, even though it may not
12547be needed (the host may accept messages from hosts on its local LAN without
12548authentication, for example). The auth_advertise_hosts option can be used to
12549make these clients more friendly by excluding them from the set of hosts to
12550which Exim advertises AUTH.
12551
12552If you want to advertise the availability of AUTH only when the connection is
12553encrypted using TLS, you can make use of the fact that the value of this option
12554is expanded, with a setting like this:
12555
12556auth_advertise_hosts = ${if eq{$tls_in_cipher}{}{}{*}}
12557
12558If $tls_in_cipher is empty, the session is not encrypted, and the result of the
12559expansion is empty, thus matching no hosts. Otherwise, the result of the
12560expansion is *, which matches all hosts.
12561
12562+---------+---------+----------+-----------+
12563|auto_thaw|Use: main|Type: time|Default: 0s|
12564+---------+---------+----------+-----------+
12565
12566If this option is set to a time greater than zero, a queue runner will try a
12567new delivery attempt on any frozen message, other than a bounce message, if
12568this much time has passed since it was frozen. This may result in the message
12569being re-frozen if nothing has changed since the last attempt. It is a way of
12570saying "keep on trying, even though there are big problems".
12571
12572Note: This is an old option, which predates timeout_frozen_after and
12573ignore_bounce_errors_after. It is retained for compatibility, but it is not
12574thought to be very useful any more, and its use should probably be avoided.
12575
12576+----------+---------+------------+------------------+
12577|av_scanner|Use: main|Type: string|Default: see below|
12578+----------+---------+------------+------------------+
12579
12580This option is available if Exim is built with the content-scanning extension.
12581It specifies which anti-virus scanner to use. The default value is:
12582
12583sophie:/var/run/sophie
12584
12585If the value of av_scanner starts with a dollar character, it is expanded
12586before use. See section 43.1 for further details.
12587
12588+----------+---------+------------+--------------+
12589|bi_command|Use: main|Type: string|Default: unset|
12590+----------+---------+------------+--------------+
12591
12592This option supplies the name of a command that is run when Exim is called with
12593the -bi option (see chapter 5). The string value is just the command name, it
12594is not a complete command line. If an argument is required, it must come from
12595the -oA command line option.
12596
12597+-------------------+---------+------------+--------------+
12598|bounce_message_file|Use: main|Type: string|Default: unset|
12599+-------------------+---------+------------+--------------+
12600
12601This option defines a template file containing paragraphs of text to be used
12602for constructing bounce messages. Details of the file's contents are given in
12603chapter 48. See also warn_message_file.
12604
12605+-------------------+---------+------------+--------------+
12606|bounce_message_text|Use: main|Type: string|Default: unset|
12607+-------------------+---------+------------+--------------+
12608
12609When this option is set, its contents are included in the default bounce
12610message immediately after "This message was created automatically by mail
12611delivery software." It is not used if bounce_message_file is set.
12612
12613+------------------+---------+-------------+-------------+
12614|bounce_return_body|Use: main|Type: boolean|Default: true|
12615+------------------+---------+-------------+-------------+
12616
12617This option controls whether the body of an incoming message is included in a
12618bounce message when bounce_return_message is true. The default setting causes
12619the entire message, both header and body, to be returned (subject to the value
12620of bounce_return_size_limit). If this option is false, only the message header
12621is included. In the case of a non-SMTP message containing an error that is
12622detected during reception, only those header lines preceding the point at which
12623the error was detected are returned.
12624
12625+---------------------+---------+-------------+-------------+
12626|bounce_return_message|Use: main|Type: boolean|Default: true|
12627+---------------------+---------+-------------+-------------+
12628
12629If this option is set false, none of the original message is included in bounce
12630messages generated by Exim. See also bounce_return_size_limit and
12631bounce_return_body.
12632
12633+------------------------+---------+-------------+-------------+
12634|bounce_return_size_limit|Use: main|Type: integer|Default: 100K|
12635+------------------------+---------+-------------+-------------+
12636
12637This option sets a limit in bytes on the size of messages that are returned to
12638senders as part of bounce messages when bounce_return_message is true. The
12639limit should be less than the value of the global message_size_limit and of any
12640message_size_limit settings on transports, to allow for the bounce text that
12641Exim generates. If this option is set to zero there is no limit.
12642
12643When the body of any message that is to be included in a bounce message is
12644greater than the limit, it is truncated, and a comment pointing this out is
12645added at the top. The actual cutoff may be greater than the value given, owing
12646to the use of buffering for transferring the message in chunks (typically 8K in
12647size). The idea is to save bandwidth on those undeliverable 15-megabyte
12648messages.
12649
12650+----------------------------+---------+------------+--------------+
12651|bounce_sender_authentication|Use: main|Type: string|Default: unset|
12652+----------------------------+---------+------------+--------------+
12653
12654This option provides an authenticated sender address that is sent with any
12655bounce messages generated by Exim that are sent over an authenticated SMTP
12656connection. A typical setting might be:
12657
12658bounce_sender_authentication = mailer-daemon@my.domain.example
12659
12660which would cause bounce messages to be sent using the SMTP command:
12661
12662MAIL FROM:<> AUTH=mailer-daemon@my.domain.example
12663
12664The value of bounce_sender_authentication must always be a complete email
12665address.
12666
12667+------------------------------+---------+----------+-----------+
12668|callout_domain_negative_expire|Use: main|Type: time|Default: 3h|
12669+------------------------------+---------+----------+-----------+
12670
12671This option specifies the expiry time for negative callout cache data for a
12672domain. See section 42.45 for details of callout verification, and section
1267342.47 for details of the caching.
12674
12675+------------------------------+---------+----------+-----------+
12676|callout_domain_positive_expire|Use: main|Type: time|Default: 7d|
12677+------------------------------+---------+----------+-----------+
12678
12679This option specifies the expiry time for positive callout cache data for a
12680domain. See section 42.45 for details of callout verification, and section
1268142.47 for details of the caching.
12682
12683+-----------------------+---------+----------+-----------+
12684|callout_negative_expire|Use: main|Type: time|Default: 2h|
12685+-----------------------+---------+----------+-----------+
12686
12687This option specifies the expiry time for negative callout cache data for an
12688address. See section 42.45 for details of callout verification, and section
1268942.47 for details of the caching.
12690
12691+-----------------------+---------+----------+------------+
12692|callout_positive_expire|Use: main|Type: time|Default: 24h|
12693+-----------------------+---------+----------+------------+
12694
12695This option specifies the expiry time for positive callout cache data for an
12696address. See section 42.45 for details of callout verification, and section
1269742.47 for details of the caching.
12698
12699+-------------------------+---------+-------------+------------------+
12700|callout_random_local_part|Use: main|Type: string*|Default: see below|
12701+-------------------------+---------+-------------+------------------+
12702
12703This option defines the "random" local part that can be used as part of callout
12704verification. The default value is
12705
12706$primary_hostname-$tod_epoch-testing
12707
12708See section 42.46 for details of how this value is used.
12709
12710+----------------+---------+-------------+----------+
12711|check_log_inodes|Use: main|Type: integer|Default: 0|
12712+----------------+---------+-------------+----------+
12713
12714See check_spool_space below.
12715
12716+---------------+---------+-------------+----------+
12717|check_log_space|Use: main|Type: integer|Default: 0|
12718+---------------+---------+-------------+----------+
12719
12720See check_spool_space below.
12721
12722+--------------------+---------+-------------+-------------+
12723|check_rfc2047_length|Use: main|Type: boolean|Default: true|
12724+--------------------+---------+-------------+-------------+
12725
12726RFC 2047 defines a way of encoding non-ASCII characters in headers using a
12727system of "encoded words". The RFC specifies a maximum length for an encoded
12728word; strings to be encoded that exceed this length are supposed to use
12729multiple encoded words. By default, Exim does not recognize encoded words that
12730exceed the maximum length. However, it seems that some software, in violation
12731of the RFC, generates overlong encoded words. If check_rfc2047_length is set
12732false, Exim recognizes encoded words of any length.
12733
12734+------------------+---------+-------------+----------+
12735|check_spool_inodes|Use: main|Type: integer|Default: 0|
12736+------------------+---------+-------------+----------+
12737
12738See check_spool_space below.
12739
12740+-----------------+---------+-------------+----------+
12741|check_spool_space|Use: main|Type: integer|Default: 0|
12742+-----------------+---------+-------------+----------+
12743
12744The four check_... options allow for checking of disk resources before a
12745message is accepted.
12746
12747When any of these options are set, they apply to all incoming messages. If you
12748want to apply different checks to different kinds of message, you can do so by
12749testing the variables $log_inodes, $log_space, $spool_inodes, and $spool_space
12750in an ACL with appropriate additional conditions.
12751
12752check_spool_space and check_spool_inodes check the spool partition if either
12753value is greater than zero, for example:
12754
12755check_spool_space = 10M
12756check_spool_inodes = 100
12757
12758The spool partition is the one that contains the directory defined by
12759SPOOL_DIRECTORY in Local/Makefile. It is used for holding messages in transit.
12760
12761check_log_space and check_log_inodes check the partition in which log files are
12762written if either is greater than zero. These should be set only if
12763log_file_path and spool_directory refer to different partitions.
12764
12765If there is less space or fewer inodes than requested, Exim refuses to accept
12766incoming mail. In the case of SMTP input this is done by giving a 452 temporary
12767error response to the MAIL command. If ESMTP is in use and there was a SIZE
12768parameter on the MAIL command, its value is added to the check_spool_space
12769value, and the check is performed even if check_spool_space is zero, unless
12770no_smtp_check_spool_space is set.
12771
12772The values for check_spool_space and check_log_space are held as a number of
12773kilobytes. If a non-multiple of 1024 is specified, it is rounded up.
12774
12775For non-SMTP input and for batched SMTP input, the test is done at start-up; on
12776failure a message is written to stderr and Exim exits with a non-zero code, as
12777it obviously cannot send an error message of any kind.
12778
12779+-----------------+---------+------------+---------------+
12780|daemon_smtp_ports|Use: main|Type: string|Default: "smtp"|
12781+-----------------+---------+------------+---------------+
12782
12783This option specifies one or more default SMTP ports on which the Exim daemon
12784listens. See chapter 13 for details of how it is used. For backward
12785compatibility, daemon_smtp_port (singular) is a synonym.
12786
12787+----------------------+---------+-------------+----------+
12788|daemon_startup_retries|Use: main|Type: integer|Default: 9|
12789+----------------------+---------+-------------+----------+
12790
12791This option, along with daemon_startup_sleep, controls the retrying done by the
12792daemon at startup when it cannot immediately bind a listening socket (typically
12793because the socket is already in use): daemon_startup_retries defines the
12794number of retries after the first failure, and daemon_startup_sleep defines the
12795length of time to wait between retries.
12796
12797+--------------------+---------+----------+------------+
12798|daemon_startup_sleep|Use: main|Type: time|Default: 30s|
12799+--------------------+---------+----------+------------+
12800
12801See daemon_startup_retries.
12802
12803+-------------+---------+---------------+------------+
12804|delay_warning|Use: main|Type: time list|Default: 24h|
12805+-------------+---------+---------------+------------+
12806
12807When a message is delayed, Exim sends a warning message to the sender at
12808intervals specified by this option. The data is a colon-separated list of times
12809after which to send warning messages. If the value of the option is an empty
12810string or a zero time, no warnings are sent. Up to 10 times may be given. If a
12811message has been on the queue for longer than the last time, the last interval
12812between the times is used to compute subsequent warning times. For example,
12813with
12814
12815delay_warning = 4h:8h:24h
12816
12817the first message is sent after 4 hours, the second after 8 hours, and the
12818third one after 24 hours. After that, messages are sent every 16 hours, because
12819that is the interval between the last two times on the list. If you set just
12820one time, it specifies the repeat interval. For example, with:
12821
12822delay_warning = 6h
12823
12824messages are repeated every six hours. To stop warnings after a given time, set
12825a very large time at the end of the list. For example:
12826
12827delay_warning = 2h:12h:99d
12828
12829Note that the option is only evaluated at the time a delivery attempt fails,
12830which depends on retry and queue-runner configuration. Typically retries will
12831be configured more frequently than warning messages.
12832
12833+-----------------------+---------+-------------+------------------+
12834|delay_warning_condition|Use: main|Type: string*|Default: see below|
12835+-----------------------+---------+-------------+------------------+
12836
12837The string is expanded at the time a warning message might be sent. If all the
12838deferred addresses have the same domain, it is set in $domain during the
12839expansion. Otherwise $domain is empty. If the result of the expansion is a
12840forced failure, an empty string, or a string matching any of "0", "no" or
12841"false" (the comparison being done caselessly) then the warning message is not
12842sent. The default is:
12843
12844delay_warning_condition = ${if or {\
12845 { !eq{$h_list-id:$h_list-post:$h_list-subscribe:}{} }\
12846 { match{$h_precedence:}{(?i)bulk|list|junk} }\
12847 { match{$h_auto-submitted:}{(?i)auto-generated|auto-replied} }\
12848 } {no}{yes}}
12849
12850This suppresses the sending of warnings for messages that contain List-ID:,
12851List-Post:, or List-Subscribe: headers, or have "bulk", "list" or "junk" in a
12852Precedence: header, or have "auto-generated" or "auto-replied" in an
12853Auto-Submitted: header.
12854
12855+----------------------+---------+-------------+--------------+
12856|deliver_drop_privilege|Use: main|Type: boolean|Default: false|
12857+----------------------+---------+-------------+--------------+
12858
12859If this option is set true, Exim drops its root privilege at the start of a
12860delivery process, and runs as the Exim user throughout. This severely restricts
12861the kinds of local delivery that are possible, but is viable in certain types
12862of configuration. There is a discussion about the use of root privilege in
12863chapter 54.
12864
12865+----------------------+---------+-----------------+--------------+
12866|deliver_queue_load_max|Use: main|Type: fixed-point|Default: unset|
12867+----------------------+---------+-----------------+--------------+
12868
12869When this option is set, a queue run is abandoned if the system load average
12870becomes greater than the value of the option. The option has no effect on
12871ancient operating systems on which Exim cannot determine the load average. See
12872also queue_only_load and smtp_load_reserve.
12873
12874+--------------------+---------+-------------+-------------+
12875|delivery_date_remove|Use: main|Type: boolean|Default: true|
12876+--------------------+---------+-------------+-------------+
12877
12878Exim's transports have an option for adding a Delivery-date: header to a
12879message when it is delivered, in exactly the same way as Return-path: is
12880handled. Delivery-date: records the actual time of delivery. Such headers
12881should not be present in incoming messages, and this option causes them to be
12882removed at the time the message is received, to avoid any problems that might
12883occur when a delivered message is subsequently sent on to some other recipient.
12884
12885+-------------+---------+-------------+--------------+
12886|disable_fsync|Use: main|Type: boolean|Default: false|
12887+-------------+---------+-------------+--------------+
12888
12889This option is available only if Exim was built with the compile-time option
12890ENABLE_DISABLE_FSYNC. When this is not set, a reference to disable_fsync in a
12891runtime configuration generates an "unknown option" error. You should not build
12892Exim with ENABLE_DISABLE_FSYNC or set disable_fsync unless you really, really,
12893really understand what you are doing. No pre-compiled distributions of Exim
12894should ever make this option available.
12895
12896When disable_fsync is set true, Exim no longer calls fsync() to force updated
12897files' data to be written to disc before continuing. Unexpected events such as
12898crashes and power outages may cause data to be lost or scrambled. Here be
12899Dragons. Beware.
12900
12901+------------+---------+-------------+--------------+
12902|disable_ipv6|Use: main|Type: boolean|Default: false|
12903+------------+---------+-------------+--------------+
12904
12905If this option is set true, even if the Exim binary has IPv6 support, no IPv6
12906activities take place. AAAA records are never looked up, and any IPv6 addresses
12907that are listed in local_interfaces, data for the manualroute router, etc. are
12908ignored. If IP literals are enabled, the ipliteral router declines to handle
12909IPv6 literal addresses.
12910
12911+------------------------+---------+------------------+--------------+
12912|dns_again_means_nonexist|Use: main|Type: domain list*|Default: unset|
12913+------------------------+---------+------------------+--------------+
12914
12915DNS lookups give a "try again" response for the DNS errors "non-authoritative
12916host not found" and "SERVERFAIL". This can cause Exim to keep trying to deliver
12917a message, or to give repeated temporary errors to incoming mail. Sometimes the
12918effect is caused by a badly set up name server and may persist for a long time.
12919If a domain which exhibits this problem matches anything in
12920dns_again_means_nonexist, it is treated as if it did not exist. This option
12921should be used with care. You can make it apply to reverse lookups by a setting
12922such as this:
12923
12924dns_again_means_nonexist = *.in-addr.arpa
12925
12926This option applies to all DNS lookups that Exim does. It also applies when the
12927gethostbyname() or getipnodebyname() functions give temporary errors, since
12928these are most likely to be caused by DNS lookup problems. The dnslookup router
12929has some options of its own for controlling what happens when lookups for MX or
12930SRV records give temporary errors. These more specific options are applied
12931after this global option.
12932
12933+-----------------------+---------+------------+------------------+
12934|dns_check_names_pattern|Use: main|Type: string|Default: see below|
12935+-----------------------+---------+------------+------------------+
12936
12937When this option is set to a non-empty string, it causes Exim to check domain
12938names for characters that are not allowed in host names before handing them to
12939the DNS resolver, because some resolvers give temporary errors for names that
12940contain unusual characters. If a domain name contains any unwanted characters,
12941a "not found" result is forced, and the resolver is not called. The check is
12942done by matching the domain name against a regular expression, which is the
12943value of this option. The default pattern is
12944
12945dns_check_names_pattern = \
12946 (?i)^(?>(?(1)\.|())[^\W_](?>[a-z0-9/-]*[^\W_])?)+$
12947
12948which permits only letters, digits, slashes, and hyphens in components, but
12949they must start and end with a letter or digit. Slashes are not, in fact,
12950permitted in host names, but they are found in certain NS records (which can be
12951accessed in Exim by using a dnsdb lookup). If you set allow_utf8_domains, you
12952must modify this pattern, or set the option to an empty string.
12953
12954+--------------------+---------+-------------+----------+
12955|dns_csa_search_limit|Use: main|Type: integer|Default: 5|
12956+--------------------+---------+-------------+----------+
12957
12958This option controls the depth of parental searching for CSA SRV records in the
12959DNS, as described in more detail in section 42.50.
12960
12961+-------------------+---------+-------------+-------------+
12962|dns_csa_use_reverse|Use: main|Type: boolean|Default: true|
12963+-------------------+---------+-------------+-------------+
12964
12965This option controls whether or not an IP address, given as a CSA domain, is
12966reversed and looked up in the reverse DNS, as described in more detail in
12967section 42.50.
12968
12969+-------------+---------+-------------+-----------+
12970|dns_dnssec_ok|Use: main|Type: integer|Default: -1|
12971+-------------+---------+-------------+-----------+
12972
12973If this option is set to a non-negative number then Exim will initialise the
12974DNS resolver library to either use or not use DNSSEC, overriding the system
12975default. A value of 0 coerces DNSSEC off, a value of 1 coerces DNSSEC on.
12976
12977If the resolver library does not support DNSSEC then this option has no effect.
12978
12979+---------------+---------+------------------+--------------+
12980|dns_ipv4_lookup|Use: main|Type: domain list*|Default: unset|
12981+---------------+---------+------------------+--------------+
12982
12983When Exim is compiled with IPv6 support and disable_ipv6 is not set, it looks
12984for IPv6 address records (AAAA records) as well as IPv4 address records (A
12985records) when trying to find IP addresses for hosts, unless the host's domain
12986matches this list.
12987
12988This is a fudge to help with name servers that give big delays or otherwise do
12989not work for the AAAA record type. In due course, when the world's name servers
12990have all been upgraded, there should be no need for this option.
12991
12992+-----------+---------+----------+-----------+
12993|dns_retrans|Use: main|Type: time|Default: 0s|
12994+-----------+---------+----------+-----------+
12995
12996The options dns_retrans and dns_retry can be used to set the retransmission and
12997retry parameters for DNS lookups. Values of zero (the defaults) leave the
12998system default settings unchanged. The first value is the time between retries,
12999and the second is the number of retries. It isn't totally clear exactly how
13000these settings affect the total time a DNS lookup may take. I haven't found any
13001documentation about timeouts on DNS lookups; these parameter values are
13002available in the external resolver interface structure, but nowhere does it
13003seem to describe how they are used or what you might want to set in them.
13004
13005+---------+---------+-------------+----------+
13006|dns_retry|Use: main|Type: integer|Default: 0|
13007+---------+---------+-------------+----------+
13008
13009See dns_retrans above.
13010
13011+-------------+---------+-------------+-----------+
13012|dns_use_edns0|Use: main|Type: integer|Default: -1|
13013+-------------+---------+-------------+-----------+
13014
13015If this option is set to a non-negative number then Exim will initialise the
13016DNS resolver library to either use or not use EDNS0 extensions, overriding the
13017system default. A value of 0 coerces EDNS0 off, a value of 1 coerces EDNS0 on.
13018
13019If the resolver library does not support EDNS0 then this option has no effect.
13020
13021+-------+---------+-------------+--------------+
13022|drop_cr|Use: main|Type: boolean|Default: false|
13023+-------+---------+-------------+--------------+
13024
13025This is an obsolete option that is now a no-op. It used to affect the way Exim
13026handled CR and LF characters in incoming messages. What happens now is
13027described in section 46.2.
13028
13029+--------+---------+-------------+------------------+
13030|dsn_from|Use: main|Type: string*|Default: see below|
13031+--------+---------+-------------+------------------+
13032
13033This option can be used to vary the contents of From: header lines in bounces
13034and other automatically generated messages ("Delivery Status Notifications" -
13035hence the name of the option). The default setting is:
13036
13037dsn_from = Mail Delivery System <Mailer-Daemon@$qualify_domain>
13038
13039The value is expanded every time it is needed. If the expansion fails, a panic
13040is logged, and the default value is used.
13041
13042+------------------+---------+-------------+-------------+
13043|envelope_to_remove|Use: main|Type: boolean|Default: true|
13044+------------------+---------+-------------+-------------+
13045
13046Exim's transports have an option for adding an Envelope-to: header to a message
13047when it is delivered, in exactly the same way as Return-path: is handled.
13048Envelope-to: records the original recipient address from the messages's
13049envelope that caused the delivery to happen. Such headers should not be present
13050in incoming messages, and this option causes them to be removed at the time the
13051message is received, to avoid any problems that might occur when a delivered
13052message is subsequently sent on to some other recipient.
13053
13054+-----------+---------+------------------+--------------+
13055|errors_copy|Use: main|Type: string list*|Default: unset|
13056+-----------+---------+------------------+--------------+
13057
13058Setting this option causes Exim to send bcc copies of bounce messages that it
13059generates to other addresses. Note: This does not apply to bounce messages
13060coming from elsewhere. The value of the option is a colon-separated list of
13061items. Each item consists of a pattern, terminated by white space, followed by
13062a comma-separated list of email addresses. If a pattern contains spaces, it
13063must be enclosed in double quotes.
13064
13065Each pattern is processed in the same way as a single item in an address list
13066(see section 10.19). When a pattern matches the recipient of the bounce
13067message, the message is copied to the addresses on the list. The items are
13068scanned in order, and once a matching one is found, no further items are
13069examined. For example:
13070
13071errors_copy = spqr@mydomain postmaster@mydomain.example :\
13072 rqps@mydomain hostmaster@mydomain.example,\
13073 postmaster@mydomain.example
13074
13075The address list is expanded before use. The expansion variables $local_part
13076and $domain are set from the original recipient of the error message, and if
13077there was any wildcard matching in the pattern, the expansion variables $0, $1,
13078etc. are set in the normal way.
13079
13080+---------------+---------+------------+--------------+
13081|errors_reply_to|Use: main|Type: string|Default: unset|
13082+---------------+---------+------------+--------------+
13083
13084By default, Exim's bounce and delivery warning messages contain the header line
13085
13086From: Mail Delivery System <Mailer-Daemon@qualify-domain>
13087
13088where qualify-domain is the value of the qualify_domain option. A warning
13089message that is generated by the quota_warn_message option in an appendfile
13090transport may contain its own From: header line that overrides the default.
13091
13092Experience shows that people reply to bounce messages. If the errors_reply_to
13093option is set, a Reply-To: header is added to bounce and warning messages. For
13094example:
13095
13096errors_reply_to = postmaster@my.domain.example
13097
13098The value of the option is not expanded. It must specify a valid RFC 2822
13099address. However, if a warning message that is generated by the
13100quota_warn_message option in an appendfile transport contain its own Reply-To:
13101header line, the value of the errors_reply_to option is not used.
13102
13103+----------+---------+------------+--------------------------------+
13104|exim_group|Use: main|Type: string|Default: compile-time configured|
13105+----------+---------+------------+--------------------------------+
13106
13107This option changes the gid under which Exim runs when it gives up root
13108privilege. The default value is compiled into the binary. The value of this
13109option is used only when exim_user is also set. Unless it consists entirely of
13110digits, the string is looked up using getgrnam(), and failure causes a
13111configuration error. See chapter 54 for a discussion of security issues.
13112
13113+---------+---------+------------+------------------+
13114|exim_path|Use: main|Type: string|Default: see below|
13115+---------+---------+------------+------------------+
13116
13117This option specifies the path name of the Exim binary, which is used when Exim
13118needs to re-exec itself. The default is set up to point to the file exim in the
13119directory configured at compile time by the BIN_DIRECTORY setting. It is
13120necessary to change exim_path if, exceptionally, Exim is run from some other
13121place. Warning: Do not use a macro to define the value of this option, because
13122you will break those Exim utilities that scan the configuration file to find
13123where the binary is. (They then use the -bP option to extract option settings
13124such as the value of spool_directory.)
13125
13126+---------+---------+------------+--------------------------------+
13127|exim_user|Use: main|Type: string|Default: compile-time configured|
13128+---------+---------+------------+--------------------------------+
13129
13130This option changes the uid under which Exim runs when it gives up root
13131privilege. The default value is compiled into the binary. Ownership of the run
13132time configuration file and the use of the -C and -D command line options is
13133checked against the values in the binary, not what is set here.
13134
13135Unless it consists entirely of digits, the string is looked up using getpwnam()
13136, and failure causes a configuration error. If exim_group is not also supplied,
13137the gid is taken from the result of getpwnam() if it is used. See chapter 54
13138for a discussion of security issues.
13139
13140+----------------------+---------+-----------------+--------------+
13141|extra_local_interfaces|Use: main|Type: string list|Default: unset|
13142+----------------------+---------+-----------------+--------------+
13143
13144This option defines network interfaces that are to be considered local when
13145routing, but which are not used for listening by the daemon. See section 13.8
13146for details.
13147
13148+-------------------------------------+---------+-------------+-------------+
13149|extract_addresses_remove_ arguments|Use: main|Type: boolean|Default: true|
13150+-------------------------------------+---------+-------------+-------------+
13151
13152According to some Sendmail documentation (Sun, IRIX, HP-UX), if any addresses
13153are present on the command line when the -t option is used to build an envelope
13154from a message's To:, Cc: and Bcc: headers, the command line addresses are
13155removed from the recipients list. This is also how Smail behaves. However,
13156other Sendmail documentation (the O'Reilly book) states that command line
13157addresses are added to those obtained from the header lines. When
13158extract_addresses_remove_arguments is true (the default), Exim subtracts
13159argument headers. If it is set false, Exim adds rather than removes argument
13160addresses.
13161
13162+----------------+---------+-------------+----------+
13163|finduser_retries|Use: main|Type: integer|Default: 0|
13164+----------------+---------+-------------+----------+
13165
13166On systems running NIS or other schemes in which user and group information is
13167distributed from a remote system, there can be times when getpwnam() and
13168related functions fail, even when given valid data, because things time out.
13169Unfortunately these failures cannot be distinguished from genuine "not found"
13170errors. If finduser_retries is set greater than zero, Exim will try that many
13171extra times to find a user or a group, waiting for one second between retries.
13172
13173You should not set this option greater than zero if your user information is in
13174a traditional /etc/passwd file, because it will cause Exim needlessly to search
13175the file multiple times for non-existent users, and also cause delay.
13176
13177+-----------+---------+----------------------------------+--------------+
13178|freeze_tell|Use: main|Type: string list, comma separated|Default: unset|
13179+-----------+---------+----------------------------------+--------------+
13180
13181On encountering certain errors, or when configured to do so in a system filter,
13182ACL, or special router, Exim freezes a message. This means that no further
13183delivery attempts take place until an administrator thaws the message, or the
13184auto_thaw, ignore_bounce_errors_after, or timeout_frozen_after feature cause it
13185to be processed. If freeze_tell is set, Exim generates a warning message
13186whenever it freezes something, unless the message it is freezing is a
13187locally-generated bounce message. (Without this exception there is the
13188possibility of looping.) The warning message is sent to the addresses supplied
13189as the comma-separated value of this option. If several of the message's
13190addresses cause freezing, only a single message is sent. If the freezing was
13191automatic, the reason(s) for freezing can be found in the message log. If you
13192configure freezing in a filter or ACL, you must arrange for any logging that
13193you require.
13194
13195+----------+---------+-------------+--------------+
13196|gecos_name|Use: main|Type: string*|Default: unset|
13197+----------+---------+-------------+--------------+
13198
13199Some operating systems, notably HP-UX, use the "gecos" field in the system
13200password file to hold other information in addition to users' real names. Exim
13201looks up this field for use when it is creating Sender: or From: headers. If
13202either gecos_pattern or gecos_name are unset, the contents of the field are
13203used unchanged, except that, if an ampersand is encountered, it is replaced by
13204the user's login name with the first character forced to upper case, since this
13205is a convention that is observed on many systems.
13206
13207When these options are set, gecos_pattern is treated as a regular expression
13208that is to be applied to the field (again with & replaced by the login name),
13209and if it matches, gecos_name is expanded and used as the user's name.
13210
13211Numeric variables such as $1, $2, etc. can be used in the expansion to pick up
13212sub-fields that were matched by the pattern. In HP-UX, where the user's name
13213terminates at the first comma, the following can be used:
13214
13215gecos_pattern = ([^,]*)
13216gecos_name = $1
13217
13218+-------------+---------+------------+--------------+
13219|gecos_pattern|Use: main|Type: string|Default: unset|
13220+-------------+---------+------------+--------------+
13221
13222See gecos_name above.
13223
13224+------------------+---------+-------------+--------------+
13225|gnutls_compat_mode|Use: main|Type: boolean|Default: unset|
13226+------------------+---------+-------------+--------------+
13227
13228This option controls whether GnuTLS is used in compatibility mode in an Exim
13229server. This reduces security slightly, but improves interworking with older
13230implementations of TLS.
13231
13232option gnutls_allow_auto_pkcs11 main boolean unset This option will let GnuTLS
13233(2.12.0 or later) autoload PKCS11 modules with the p11-kit configuration files
13234in /etc/pkcs11/modules/.
13235
13236See http://www.gnutls.org/manual/gnutls.html#Smart-cards-and-HSMs for
13237documentation.
13238
13239+---------------+---------+------------+------------------+
13240|headers_charset|Use: main|Type: string|Default: see below|
13241+---------------+---------+------------+------------------+
13242
13243This option sets a default character set for translating from encoded MIME
13244"words" in header lines, when referenced by an $h_xxx expansion item. The
13245default is the value of HEADERS_CHARSET in Local/Makefile. The ultimate default
13246is ISO-8859-1. For more details see the description of header insertions in
13247section 11.5.
13248
13249+--------------+---------+-------------+------------------+
13250|header_maxsize|Use: main|Type: integer|Default: see below|
13251+--------------+---------+-------------+------------------+
13252
13253This option controls the overall maximum size of a message's header section.
13254The default is the value of HEADER_MAXSIZE in Local/Makefile; the default for
13255that is 1M. Messages with larger header sections are rejected.
13256
13257+-------------------+---------+-------------+----------+
13258|header_line_maxsize|Use: main|Type: integer|Default: 0|
13259+-------------------+---------+-------------+----------+
13260
13261This option limits the length of any individual header line in a message, after
13262all the continuations have been joined together. Messages with individual
13263header lines that are longer than the limit are rejected. The default value of
13264zero means "no limit".
13265
13266+----------------------+---------+----------------+--------------+
13267|helo_accept_junk_hosts|Use: main|Type: host list*|Default: unset|
13268+----------------------+---------+----------------+--------------+
13269
13270Exim checks the syntax of HELO and EHLO commands for incoming SMTP mail, and
13271gives an error response for invalid data. Unfortunately, there are some SMTP
13272clients that send syntactic junk. They can be accommodated by setting this
13273option. Note that this is a syntax check only. See helo_verify_hosts if you
13274want to do semantic checking. See also helo_allow_chars for a way of extending
13275the permitted character set.
13276
13277+----------------+---------+------------+--------------+
13278|helo_allow_chars|Use: main|Type: string|Default: unset|
13279+----------------+---------+------------+--------------+
13280
13281This option can be set to a string of rogue characters that are permitted in
13282all EHLO and HELO names in addition to the standard letters, digits, hyphens,
13283and dots. If you really must allow underscores, you can set
13284
13285helo_allow_chars = _
13286
13287Note that the value is one string, not a list.
13288
13289+-------------------+---------+------------------+----------------+
13290|helo_lookup_domains|Use: main|Type: domain list*|Default: "@:@[]"|
13291+-------------------+---------+------------------+----------------+
13292
13293If the domain given by a client in a HELO or EHLO command matches this list, a
13294reverse lookup is done in order to establish the host's true name. The default
13295forces a lookup if the client host gives the server's name or any of its IP
13296addresses (in brackets), something that broken clients have been seen to do.
13297
13298+---------------------+---------+----------------+--------------+
13299|helo_try_verify_hosts|Use: main|Type: host list*|Default: unset|
13300+---------------------+---------+----------------+--------------+
13301
13302By default, Exim just checks the syntax of HELO and EHLO commands (see
13303helo_accept_junk_hosts and helo_allow_chars). However, some sites like to do
13304more extensive checking of the data supplied by these commands. The ACL
13305condition "verify = helo" is provided to make this possible. Formerly, it was
13306necessary also to set this option (helo_try_verify_hosts) to force the check to
13307occur. From release 4.53 onwards, this is no longer necessary. If the check has
13308not been done before "verify = helo" is encountered, it is done at that time.
13309Consequently, this option is obsolete. Its specification is retained here for
13310backwards compatibility.
13311
13312When an EHLO or HELO command is received, if the calling host matches
13313helo_try_verify_hosts, Exim checks that the host name given in the HELO or EHLO
13314command either:
13315
13316 * is an IP literal matching the calling address of the host, or
13317
13318 * matches the host name that Exim obtains by doing a reverse lookup of the
13319 calling host address, or
13320
13321 * when looked up using gethostbyname() (or getipnodebyname() when available)
13322 yields the calling host address.
13323
13324However, the EHLO or HELO command is not rejected if any of the checks fail.
13325Processing continues, but the result of the check is remembered, and can be
13326detected later in an ACL by the "verify = helo" condition.
13327
13328+-----------------+---------+----------------+--------------+
13329|helo_verify_hosts|Use: main|Type: host list*|Default: unset|
13330+-----------------+---------+----------------+--------------+
13331
13332Like helo_try_verify_hosts, this option is obsolete, and retained only for
13333backwards compatibility. For hosts that match this option, Exim checks the host
13334name given in the HELO or EHLO in the same way as for helo_try_verify_hosts. If
13335the check fails, the HELO or EHLO command is rejected with a 550 error, and
13336entries are written to the main and reject logs. If a MAIL command is received
13337before EHLO or HELO, it is rejected with a 503 error.
13338
13339+------------+---------+------------------+--------------+
13340|hold_domains|Use: main|Type: domain list*|Default: unset|
13341+------------+---------+------------------+--------------+
13342
13343This option allows mail for particular domains to be held on the queue
13344manually. The option is overridden if a message delivery is forced with the -M,
13345-qf, -Rf or -Sf options, and also while testing or verifying addresses using
13346-bt or -bv. Otherwise, if a domain matches an item in hold_domains, no routing
13347or delivery for that address is done, and it is deferred every time the message
13348is looked at.
13349
13350This option is intended as a temporary operational measure for delaying the
13351delivery of mail while some problem is being sorted out, or some new
13352configuration tested. If you just want to delay the processing of some domains
13353until a queue run occurs, you should use queue_domains or queue_smtp_domains,
13354not hold_domains.
13355
13356A setting of hold_domains does not override Exim's code for removing messages
13357from the queue if they have been there longer than the longest retry time in
13358any retry rule. If you want to hold messages for longer than the normal retry
13359times, insert a dummy retry rule with a long retry time.
13360
13361+-----------+---------+----------------+--------------+
13362|host_lookup|Use: main|Type: host list*|Default: unset|
13363+-----------+---------+----------------+--------------+
13364
13365Exim does not look up the name of a calling host from its IP address unless it
13366is required to compare against some host list, or the host matches
13367helo_try_verify_hosts or helo_verify_hosts, or the host matches this option
13368(which normally contains IP addresses rather than host names). The default
13369configuration file contains
13370
13371host_lookup = *
13372
13373which causes a lookup to happen for all hosts. If the expense of these lookups
13374is felt to be too great, the setting can be changed or removed.
13375
13376After a successful reverse lookup, Exim does a forward lookup on the name it
13377has obtained, to verify that it yields the IP address that it started with. If
13378this check fails, Exim behaves as if the name lookup failed.
13379
13380After any kind of failure, the host name (in $sender_host_name) remains unset,
13381and $host_lookup_failed is set to the string "1". See also
13382dns_again_means_nonexist, helo_lookup_domains, and "verify =
13383reverse_host_lookup" in ACLs.
13384
13385+-----------------+---------+-----------------+-----------------------+
13386|host_lookup_order|Use: main|Type: string list|Default: "bydns:byaddr"|
13387+-----------------+---------+-----------------+-----------------------+
13388
13389This option specifies the order of different lookup methods when Exim is trying
13390to find a host name from an IP address. The default is to do a DNS lookup
13391first, and then to try a local lookup (using gethostbyaddr() or equivalent) if
13392that fails. You can change the order of these lookups, or omit one entirely, if
13393you want.
13394
13395Warning: The "byaddr" method does not always yield aliases when there are
13396multiple PTR records in the DNS and the IP address is not listed in /etc/hosts.
13397Different operating systems give different results in this case. That is why
13398the default tries a DNS lookup first.
13399
13400+----------------------+---------+----------------+--------------+
13401|host_reject_connection|Use: main|Type: host list*|Default: unset|
13402+----------------------+---------+----------------+--------------+
13403
13404If this option is set, incoming SMTP calls from the hosts listed are rejected
13405as soon as the connection is made. This option is obsolete, and retained only
13406for backward compatibility, because nowadays the ACL specified by
13407acl_smtp_connect can also reject incoming connections immediately.
13408
13409The ability to give an immediate rejection (either by this option or using an
13410ACL) is provided for use in unusual cases. Many hosts will just try again,
13411sometimes without much delay. Normally, it is better to use an ACL to reject
13412incoming messages at a later stage, such as after RCPT commands. See chapter 42
13413.
13414
13415+----------------------+---------+----------------+--------------+
13416|hosts_connection_nolog|Use: main|Type: host list*|Default: unset|
13417+----------------------+---------+----------------+--------------+
13418
13419This option defines a list of hosts for which connection logging does not
13420happen, even though the smtp_connection log selector is set. For example, you
13421might want not to log SMTP connections from local processes, or from 127.0.0.1,
13422or from your local LAN. This option is consulted in the main loop of the
13423daemon; you should therefore strive to restrict its value to a short inline
13424list of IP addresses and networks. To disable logging SMTP connections from
13425local processes, you must create a host list with an empty item. For example:
13426
13427hosts_connection_nolog = :
13428
13429If the smtp_connection log selector is not set, this option has no effect.
13430
13431+--------------------+---------+------------------+--------------+
13432|hosts_treat_as_local|Use: main|Type: domain list*|Default: unset|
13433+--------------------+---------+------------------+--------------+
13434
13435If this option is set, any host names that match the domain list are treated as
13436if they were the local host when Exim is scanning host lists obtained from MX
13437records or other sources. Note that the value of this option is a domain list,
13438not a host list, because it is always used to check host names, not IP
13439addresses.
13440
13441This option also applies when Exim is matching the special items "@mx_any",
13442"@mx_primary", and "@mx_secondary" in a domain list (see section 10.8), and
13443when checking the hosts option in the smtp transport for the local host (see
13444the allow_localhost option in that transport). See also local_interfaces,
13445extra_local_interfaces, and chapter 13, which contains a discussion about local
13446network interfaces and recognizing the local host.
13447
13448+-------------+---------+-----------------+--------------+
13449|ibase_servers|Use: main|Type: string list|Default: unset|
13450+-------------+---------+-----------------+--------------+
13451
13452This option provides a list of InterBase servers and associated connection
13453data, to be used in conjunction with ibase lookups (see section 9.21). The
13454option is available only if Exim has been built with InterBase support.
13455
13456+--------------------------+---------+----------+------------+
13457|ignore_bounce_errors_after|Use: main|Type: time|Default: 10w|
13458+--------------------------+---------+----------+------------+
13459
13460This option affects the processing of bounce messages that cannot be delivered,
13461that is, those that suffer a permanent delivery failure. (Bounce messages that
13462suffer temporary delivery failures are of course retried in the usual way.)
13463
13464After a permanent delivery failure, bounce messages are frozen, because there
13465is no sender to whom they can be returned. When a frozen bounce message has
13466been on the queue for more than the given time, it is unfrozen at the next
13467queue run, and a further delivery is attempted. If delivery fails again, the
13468bounce message is discarded. This makes it possible to keep failed bounce
13469messages around for a shorter time than the normal maximum retry time for
13470frozen messages. For example,
13471
13472ignore_bounce_errors_after = 12h
13473
13474retries failed bounce message deliveries after 12 hours, discarding any further
13475failures. If the value of this option is set to a zero time period, bounce
13476failures are discarded immediately. Setting a very long time (as in the default
13477value) has the effect of disabling this option. For ways of automatically
13478dealing with other kinds of frozen message, see auto_thaw and
13479timeout_frozen_after.
13480
13481+---------------------+---------+----------------+--------------+
13482|ignore_fromline_hosts|Use: main|Type: host list*|Default: unset|
13483+---------------------+---------+----------------+--------------+
13484
13485Some broken SMTP clients insist on sending a UUCP-like "From " line before the
13486headers of a message. By default this is treated as the start of the message's
13487body, which means that any following headers are not recognized as such. Exim
13488can be made to ignore it by setting ignore_fromline_hosts to match those hosts
13489that insist on sending it. If the sender is actually a local process rather
13490than a remote host, and is using -bs to inject the messages,
13491ignore_fromline_local must be set to achieve this effect.
13492
13493+---------------------+---------+-------------+--------------+
13494|ignore_fromline_local|Use: main|Type: boolean|Default: false|
13495+---------------------+---------+-------------+--------------+
13496
13497See ignore_fromline_hosts above.
13498
188b6fee
CE
13499+----------------+---------+-----------------+--------------+
13500|keep_environment|Use: main|Type: string list|Default: unset|
13501+----------------+---------+-----------------+--------------+
13502
13503This option contains a string list of environment variables to keep. You have
13504to trust these variables or you have to be sure that these variables do not
13505impose any security risk. Keep in mind that during the startup phase Exim is
13506running with an effective UID 0 in most installations. As the default value is
13507an empty list, the default environment for using libraries, running embedded
13508Perl code, or running external binaries is empty, and does not not even contain
13509PATH or HOME.
13510
13511Actually the list is interpreted as a list of patterns (10.1), except that it
13512is not expanded first.
13513
13514WARNING: Macro substitution is still done first, so having a macro FOO and
13515having FOO_HOME in your keep_environment option may have unexpected results.
13516You may work around this using a regular expression that does not match the
13517macro name: ^[F]OO_HOME$.
13518
13519Current versions of Exim issue a warning during startupif you do not mention
13520keep_environment or add_environment in your runtime configuration file.
13521
420a0d19
CE
13522+--------------+---------+----------+-----------+
13523|keep_malformed|Use: main|Type: time|Default: 4d|
13524+--------------+---------+----------+-----------+
13525
13526This option specifies the length of time to keep messages whose spool files
13527have been corrupted in some way. This should, of course, never happen. At the
13528next attempt to deliver such a message, it gets removed. The incident is
13529logged.
13530
13531+----------------+---------+------------+--------------+
13532|ldap_ca_cert_dir|Use: main|Type: string|Default: unset|
13533+----------------+---------+------------+--------------+
13534
13535This option indicates which directory contains CA certificates for verifying a
13536TLS certificate presented by an LDAP server. While Exim does not provide a
13537default value, your SSL library may. Analogous to tls_verify_certificates but
13538as a client-side option for LDAP and constrained to be a directory.
13539
13540+-----------------+---------+------------+--------------+
13541|ldap_ca_cert_file|Use: main|Type: string|Default: unset|
13542+-----------------+---------+------------+--------------+
13543
13544This option indicates which file contains CA certificates for verifying a TLS
13545certificate presented by an LDAP server. While Exim does not provide a default
13546value, your SSL library may. Analogous to tls_verify_certificates but as a
13547client-side option for LDAP and constrained to be a file.
13548
13549+--------------+---------+------------+--------------+
13550|ldap_cert_file|Use: main|Type: string|Default: unset|
13551+--------------+---------+------------+--------------+
13552
13553This option indicates which file contains an TLS client certificate which Exim
13554should present to the LDAP server during TLS negotiation. Should be used
13555together with ldap_cert_key.
13556
13557+-------------+---------+------------+--------------+
13558|ldap_cert_key|Use: main|Type: string|Default: unset|
13559+-------------+---------+------------+--------------+
13560
13561This option indicates which file contains the secret/private key to use to
13562prove identity to the LDAP server during TLS negotiation. Should be used
13563together with ldap_cert_file, which contains the identity to be proven.
13564
13565+-----------------+---------+------------+--------------+
13566|ldap_cipher_suite|Use: main|Type: string|Default: unset|
13567+-----------------+---------+------------+--------------+
13568
13569This controls the TLS cipher-suite negotiation during TLS negotiation with the
13570LDAP server. See 41.4 for more details of the format of cipher-suite options
13571with OpenSSL (as used by LDAP client libraries).
13572
13573+--------------------+---------+-----------------+--------------+
13574|ldap_default_servers|Use: main|Type: string list|Default: unset|
13575+--------------------+---------+-----------------+--------------+
13576
13577This option provides a list of LDAP servers which are tried in turn when an
13578LDAP query does not contain a server. See section 9.14 for details of LDAP
13579queries. This option is available only when Exim has been built with LDAP
13580support.
13581
13582+-----------------+---------+------------+---------------+
13583|ldap_require_cert|Use: main|Type: string|Default: unset.|
13584+-----------------+---------+------------+---------------+
13585
13586This should be one of the values "hard", "demand", "allow", "try" or "never". A
13587value other than one of these is interpreted as "never". See the entry
13588"TLS_REQCERT" in your system man page for ldap.conf(5). Although Exim does not
13589set a default, the LDAP library probably defaults to hard/demand.
13590
13591+--------------+---------+-------------+--------------+
13592|ldap_start_tls|Use: main|Type: boolean|Default: false|
13593+--------------+---------+-------------+--------------+
13594
13595If set, Exim will attempt to negotiate TLS with the LDAP server when connecting
13596on a regular LDAP port. This is the LDAP equivalent of SMTP's "STARTTLS". This
13597is distinct from using "ldaps", which is the LDAP form of SSL-on-connect. In
13598the event of failure to negotiate TLS, the action taken is controlled by
13599ldap_require_cert.
13600
13601+------------+---------+-------------+--------------+
13602|ldap_version|Use: main|Type: integer|Default: unset|
13603+------------+---------+-------------+--------------+
13604
13605This option can be used to force Exim to set a specific protocol version for
13606LDAP. If it option is unset, it is shown by the -bP command line option as -1.
13607When this is the case, the default is 3 if LDAP_VERSION3 is defined in the LDAP
13608headers; otherwise it is 2. This option is available only when Exim has been
13609built with LDAP support.
13610
13611+----------------+---------+-------------+-------------+
13612|local_from_check|Use: main|Type: boolean|Default: true|
13613+----------------+---------+-------------+-------------+
13614
13615When a message is submitted locally (that is, not over a TCP/IP connection) by
13616an untrusted user, Exim removes any existing Sender: header line, and checks
13617that the From: header line matches the login of the calling user and the domain
13618specified by qualify_domain.
13619
13620Note: An unqualified address (no domain) in the From: header in a locally
13621submitted message is automatically qualified by Exim, unless the -bnq command
13622line option is used.
13623
13624You can use local_from_prefix and local_from_suffix to permit affixes on the
13625local part. If the From: header line does not match, Exim adds a Sender: header
13626with an address constructed from the calling user's login and the default
13627qualify domain.
13628
13629If local_from_check is set false, the From: header check is disabled, and no
13630Sender: header is ever added. If, in addition, you want to retain Sender:
13631header lines supplied by untrusted users, you must also set local_sender_retain
13632to be true.
13633
13634These options affect only the header lines in the message. The envelope sender
13635is still forced to be the login id at the qualify domain unless
13636untrusted_set_sender permits the user to supply an envelope sender.
13637
13638For messages received over TCP/IP, an ACL can specify "submission mode" to
13639request similar header line checking. See section 46.16, which has more details
13640about Sender: processing.
13641
13642+-----------------+---------+------------+--------------+
13643|local_from_prefix|Use: main|Type: string|Default: unset|
13644+-----------------+---------+------------+--------------+
13645
13646When Exim checks the From: header line of locally submitted messages for
13647matching the login id (see local_from_check above), it can be configured to
13648ignore certain prefixes and suffixes in the local part of the address. This is
13649done by setting local_from_prefix and/or local_from_suffix to appropriate
13650lists, in the same form as the local_part_prefix and local_part_suffix router
13651options (see chapter 15). For example, if
13652
13653local_from_prefix = *-
13654
13655is set, a From: line containing
13656
13657From: anything-user@your.domain.example
13658
13659will not cause a Sender: header to be added if user@your.domain.example matches
13660the actual sender address that is constructed from the login name and qualify
13661domain.
13662
13663+-----------------+---------+------------+--------------+
13664|local_from_suffix|Use: main|Type: string|Default: unset|
13665+-----------------+---------+------------+--------------+
13666
13667See local_from_prefix above.
13668
13669+----------------+---------+-----------------+------------------+
13670|local_interfaces|Use: main|Type: string list|Default: see below|
13671+----------------+---------+-----------------+------------------+
13672
13673This option controls which network interfaces are used by the daemon for
13674listening; they are also used to identify the local host when routing. Chapter
1367513 contains a full description of this option and the related options
13676daemon_smtp_ports, extra_local_interfaces, hosts_treat_as_local, and
13677tls_on_connect_ports. The default value for local_interfaces is
13678
13679local_interfaces = 0.0.0.0
13680
13681when Exim is built without IPv6 support; otherwise it is
13682
13683local_interfaces = <; ::0 ; 0.0.0.0
13684
13685+------------------+---------+----------+-----------+
13686|local_scan_timeout|Use: main|Type: time|Default: 5m|
13687+------------------+---------+----------+-----------+
13688
13689This timeout applies to the local_scan() function (see chapter 44). Zero means
13690"no timeout". If the timeout is exceeded, the incoming message is rejected with
13691a temporary error if it is an SMTP message. For a non-SMTP message, the message
13692is dropped and Exim ends with a non-zero code. The incident is logged on the
13693main and reject logs.
13694
13695+-------------------+---------+-------------+--------------+
13696|local_sender_retain|Use: main|Type: boolean|Default: false|
13697+-------------------+---------+-------------+--------------+
13698
13699When a message is submitted locally (that is, not over a TCP/IP connection) by
13700an untrusted user, Exim removes any existing Sender: header line. If you do not
13701want this to happen, you must set local_sender_retain, and you must also set
13702local_from_check to be false (Exim will complain if you do not). See also the
13703ACL modifier "control = suppress_local_fixups". Section 46.16 has more details
13704about Sender: processing.
13705
13706+----------------+---------+-------------+--------------+
13707|localhost_number|Use: main|Type: string*|Default: unset|
13708+----------------+---------+-------------+--------------+
13709
13710Exim's message ids are normally unique only within the local host. If
13711uniqueness among a set of hosts is required, each host must set a different
13712value for the localhost_number option. The string is expanded immediately after
13713reading the configuration file (so that a number can be computed from the host
13714name, for example) and the result of the expansion must be a number in the
13715range 0-16 (or 0-10 on operating systems with case-insensitive file systems).
13716This is available in subsequent string expansions via the variable
13717$localhost_number. When localhost_number is set, the final two characters of
13718the message id, instead of just being a fractional part of the time, are
13719computed from the time and the local host number as described in section 3.4.
13720
13721+-------------+---------+------------------+----------------------------+
13722|log_file_path|Use: main|Type: string list*|Default: set at compile time|
13723+-------------+---------+------------------+----------------------------+
13724
13725This option sets the path which is used to determine the names of Exim's log
13726files, or indicates that logging is to be to syslog, or both. It is expanded
13727when Exim is entered, so it can, for example, contain a reference to the host
13728name. If no specific path is set for the log files at compile or run time, they
13729are written in a sub-directory called log in Exim's spool directory. Chapter 51
13730contains further details about Exim's logging, and section 51.1 describes how
13731the contents of log_file_path are used. If this string is fixed at your
13732installation (contains no expansion variables) it is recommended that you do
13733not set this option in the configuration file, but instead supply the path
13734using LOG_FILE_PATH in Local/Makefile so that it is available to Exim for
13735logging errors detected early on - in particular, failure to read the
13736configuration file.
13737
13738+------------+---------+------------+--------------+
13739|log_selector|Use: main|Type: string|Default: unset|
13740+------------+---------+------------+--------------+
13741
13742This option can be used to reduce or increase the number of things that Exim
13743writes to its log files. Its argument is made up of names preceded by plus or
13744minus characters. For example:
13745
13746log_selector = +arguments -retry_defer
13747
13748A list of possible names and what they control is given in the chapter on
13749logging, in section 51.15.
13750
13751+------------+---------+-------------+--------------+
13752|log_timezone|Use: main|Type: boolean|Default: false|
13753+------------+---------+-------------+--------------+
13754
13755By default, the timestamps on log lines are in local time without the timezone.
13756This means that if your timezone changes twice a year, the timestamps in log
13757lines are ambiguous for an hour when the clocks go back. One way of avoiding
13758this problem is to set the timezone to UTC. An alternative is to set
13759log_timezone true. This turns on the addition of the timezone offset to
13760timestamps in log lines. Turning on this option can add quite a lot to the size
13761of log files because each line is extended by 6 characters. Note that the
13762$tod_log variable contains the log timestamp without the zone, but there is
13763another variable called $tod_zone that contains just the timezone offset.
13764
13765+---------------+---------+-------------+-----------+
13766|lookup_open_max|Use: main|Type: integer|Default: 25|
13767+---------------+---------+-------------+-----------+
13768
13769This option limits the number of simultaneously open files for single-key
13770lookups that use regular files (that is, lsearch, dbm, and cdb). Exim normally
13771keeps these files open during routing, because often the same file is required
13772several times. If the limit is reached, Exim closes the least recently used
13773file. Note that if you are using the ndbm library, it actually opens two files
13774for each logical DBM database, though it still counts as one for the purposes
13775of lookup_open_max. If you are getting "too many open files" errors with NDBM,
13776you need to reduce the value of lookup_open_max.
13777
13778+-------------------+---------+-------------+----------+
13779|max_username_length|Use: main|Type: integer|Default: 0|
13780+-------------------+---------+-------------+----------+
13781
13782Some operating systems are broken in that they truncate long arguments to
13783getpwnam() to eight characters, instead of returning "no such user". If this
13784option is set greater than zero, any attempt to call getpwnam() with an
13785argument that is longer behaves as if getpwnam() failed.
13786
13787+---------------------+---------+----------+--------------+
13788|message_body_newlines|Use: main|Type: bool|Default: false|
13789+---------------------+---------+----------+--------------+
13790
13791By default, newlines in the message body are replaced by spaces when setting
13792the $message_body and $message_body_end expansion variables. If this option is
13793set true, this no longer happens.
13794
13795+--------------------+---------+-------------+------------+
13796|message_body_visible|Use: main|Type: integer|Default: 500|
13797+--------------------+---------+-------------+------------+
13798
13799This option specifies how much of a message's body is to be included in the
13800$message_body and $message_body_end expansion variables.
13801
13802+------------------------+---------+-------------+--------------+
13803|message_id_header_domain|Use: main|Type: string*|Default: unset|
13804+------------------------+---------+-------------+--------------+
13805
13806If this option is set, the string is expanded and used as the right hand side
13807(domain) of the Message-ID: header that Exim creates if a locally-originated
13808incoming message does not have one. "Locally-originated" means "not received
13809over TCP/IP." Otherwise, the primary host name is used. Only letters, digits,
13810dot and hyphen are accepted; any other characters are replaced by hyphens. If
13811the expansion is forced to fail, or if the result is an empty string, the
13812option is ignored.
13813
13814+----------------------+---------+-------------+--------------+
13815|message_id_header_text|Use: main|Type: string*|Default: unset|
13816+----------------------+---------+-------------+--------------+
13817
13818If this variable is set, the string is expanded and used to augment the text of
13819the Message-id: header that Exim creates if a locally-originated incoming
13820message does not have one. The text of this header is required by RFC 2822 to
13821take the form of an address. By default, Exim uses its internal message id as
13822the local part, and the primary host name as the domain. If this option is set,
13823it is expanded, and provided the expansion is not forced to fail, and does not
13824yield an empty string, the result is inserted into the header immediately
13825before the @, separated from the internal message id by a dot. Any characters
13826that are illegal in an address are automatically converted into hyphens. This
13827means that variables such as $tod_log can be used, because the spaces and
13828colons will become hyphens.
13829
13830+------------+---------+-------------+-------------+
13831|message_logs|Use: main|Type: boolean|Default: true|
13832+------------+---------+-------------+-------------+
13833
13834If this option is turned off, per-message log files are not created in the
13835msglog spool sub-directory. This reduces the amount of disk I/O required by
13836Exim, by reducing the number of files involved in handling a message from a
13837minimum of four (header spool file, body spool file, delivery journal, and
13838per-message log) to three. The other major I/O activity is Exim's main log,
13839which is not affected by this option.
13840
13841+------------------+---------+-------------+------------+
13842|message_size_limit|Use: main|Type: string*|Default: 50M|
13843+------------------+---------+-------------+------------+
13844
13845This option limits the maximum size of message that Exim will process. The
13846value is expanded for each incoming connection so, for example, it can be made
13847to depend on the IP address of the remote host for messages arriving via TCP/
13848IP. After expansion, the value must be a sequence of decimal digits, optionally
13849followed by K or M.
13850
13851Note: This limit cannot be made to depend on a message's sender or any other
13852properties of an individual message, because it has to be advertised in the
13853server's response to EHLO. String expansion failure causes a temporary error. A
13854value of zero means no limit, but its use is not recommended. See also
13855bounce_return_size_limit.
13856
13857Incoming SMTP messages are failed with a 552 error if the limit is exceeded;
13858locally-generated messages either get a stderr message or a delivery failure
13859message to the sender, depending on the -oe setting. Rejection of an oversized
13860message is logged in both the main and the reject logs. See also the generic
13861transport option message_size_limit, which limits the size of message that an
13862individual transport can process.
13863
13864If you use a virus-scanner and set this option to to a value larger than the
13865maximum size that your virus-scanner is configured to support, you may get
13866failures triggered by large mails. The right size to configure for the
13867virus-scanner depends upon what data is passed and the options in use but it's
13868probably safest to just set it to a little larger than this value. Eg, with a
13869default Exim message size of 50M and a default ClamAV StreamMaxLength of 10M,
13870some problems may result.
13871
13872A value of 0 will disable size limit checking; Exim will still advertise the
13873SIZE extension in an EHLO response, but without a limit, so as to permit SMTP
13874clients to still indicate the message size along with the MAIL verb.
13875
13876+--------------------+---------+-------------+--------------+
13877|move_frozen_messages|Use: main|Type: boolean|Default: false|
13878+--------------------+---------+-------------+--------------+
13879
13880This option, which is available only if Exim has been built with the setting
13881
13882SUPPORT_MOVE_FROZEN_MESSAGES=yes
13883
13884in Local/Makefile, causes frozen messages and their message logs to be moved
13885from the input and msglog directories on the spool to Finput and Fmsglog,
13886respectively. There is currently no support in Exim or the standard utilities
13887for handling such moved messages, and they do not show up in lists generated by
13888-bp or by the Exim monitor.
13889
13890+-----------+---------+-------------+--------------+
13891|mua_wrapper|Use: main|Type: boolean|Default: false|
13892+-----------+---------+-------------+--------------+
13893
13894Setting this option true causes Exim to run in a very restrictive mode in which
13895it passes messages synchronously to a smart host. Chapter 50 contains a full
13896description of this facility.
13897
13898+-------------+---------+-----------------+--------------+
13899|mysql_servers|Use: main|Type: string list|Default: unset|
13900+-------------+---------+-----------------+--------------+
13901
13902This option provides a list of MySQL servers and associated connection data, to
13903be used in conjunction with mysql lookups (see section 9.21). The option is
13904available only if Exim has been built with MySQL support.
13905
13906+-----------+---------+------------------+--------------+
13907|never_users|Use: main|Type: string list*|Default: unset|
13908+-----------+---------+------------------+--------------+
13909
13910This option is expanded just once, at the start of Exim's processing. Local
13911message deliveries are normally run in processes that are setuid to the
13912recipient, and remote deliveries are normally run under Exim's own uid and gid.
13913It is usually desirable to prevent any deliveries from running as root, as a
13914safety precaution.
13915
13916When Exim is built, an option called FIXED_NEVER_USERS can be set to a list of
13917users that must not be used for local deliveries. This list is fixed in the
13918binary and cannot be overridden by the configuration file. By default, it
13919contains just the single user name "root". The never_users runtime option can
13920be used to add more users to the fixed list.
13921
13922If a message is to be delivered as one of the users on the fixed list or the
13923never_users list, an error occurs, and delivery is deferred. A common example
13924is
13925
13926never_users = root:daemon:bin
13927
13928Including root is redundant if it is also on the fixed list, but it does no
13929harm. This option overrides the pipe_as_creator option of the pipe transport
13930driver.
13931
13932+---------------+---------+-----------------+------------------+
13933|openssl_options|Use: main|Type: string list|Default: +no_sslv2|
13934+---------------+---------+-----------------+------------------+
13935
13936This option allows an administrator to adjust the SSL options applied by
13937OpenSSL to connections. It is given as a space-separated list of items, each
13938one to be +added or -subtracted from the current value.
13939
13940This option is only available if Exim is built against OpenSSL. The values
13941available for this option vary according to the age of your OpenSSL install.
13942The "all" value controls a subset of flags which are available, typically the
13943bug workaround options. The SSL_CTX_set_options man page will list the values
13944known on your system and Exim should support all the "bug workaround" options
13945and many of the "modifying" options. The Exim names lose the leading "SSL_OP_"
13946and are lower-cased.
13947
13948Note that adjusting the options can have severe impact upon the security of SSL
13949as used by Exim. It is possible to disable safety checks and shoot yourself in
13950the foot in various unpleasant ways. This option should not be adjusted
13951lightly. An unrecognised item will be detected at startup, by invoking Exim
13952with the -bV flag.
13953
13954Historical note: prior to release 4.80, Exim defaulted this value to
13955"+dont_insert_empty_fragments", which may still be needed for compatibility
13956with some clients, but which lowers security by increasing exposure to some now
13957infamous attacks.
13958
13959An example:
13960
13961# Make both old MS and old Eudora happy:
13962openssl_options = -all +microsoft_big_sslv3_buffer \
13963 +dont_insert_empty_fragments
13964
13965Possible options may include:
13966
13967 * "all"
13968
13969 * "allow_unsafe_legacy_renegotiation"
13970
13971 * "cipher_server_preference"
13972
13973 * "dont_insert_empty_fragments"
13974
13975 * "ephemeral_rsa"
13976
13977 * "legacy_server_connect"
13978
13979 * "microsoft_big_sslv3_buffer"
13980
13981 * "microsoft_sess_id_bug"
13982
13983 * "msie_sslv2_rsa_padding"
13984
13985 * "netscape_challenge_bug"
13986
13987 * "netscape_reuse_cipher_change_bug"
13988
13989 * "no_compression"
13990
13991 * "no_session_resumption_on_renegotiation"
13992
13993 * "no_sslv2"
13994
13995 * "no_sslv3"
13996
13997 * "no_ticket"
13998
13999 * "no_tlsv1"
14000
14001 * "no_tlsv1_1"
14002
14003 * "no_tlsv1_2"
14004
14005 * "safari_ecdhe_ecdsa_bug"
14006
14007 * "single_dh_use"
14008
14009 * "single_ecdh_use"
14010
14011 * "ssleay_080_client_dh_bug"
14012
14013 * "sslref2_reuse_cert_type_bug"
14014
14015 * "tls_block_padding_bug"
14016
14017 * "tls_d5_bug"
14018
14019 * "tls_rollback_bug"
14020
14021As an aside, the "safari_ecdhe_ecdsa_bug" item is a misnomer and affects all
14022clients connecting using the MacOS SecureTransport TLS facility prior to MacOS
1402310.8.4, including email clients. If you see old MacOS clients failing to
14024negotiate TLS then this option value might help, provided that your OpenSSL
14025release is new enough to contain this work-around. This may be a situation
14026where you have to upgrade OpenSSL to get buggy clients working.
14027
14028+--------------+---------+-----------------+--------------+
14029|oracle_servers|Use: main|Type: string list|Default: unset|
14030+--------------+---------+-----------------+--------------+
14031
14032This option provides a list of Oracle servers and associated connection data,
14033to be used in conjunction with oracle lookups (see section 9.21). The option is
14034available only if Exim has been built with Oracle support.
14035
14036+--------------------+---------+------------------+--------------+
14037|percent_hack_domains|Use: main|Type: domain list*|Default: unset|
14038+--------------------+---------+------------------+--------------+
14039
14040The "percent hack" is the convention whereby a local part containing a percent
14041sign is re-interpreted as a new email address, with the percent replaced by @.
14042This is sometimes called "source routing", though that term is also applied to
14043RFC 2822 addresses that begin with an @ character. If this option is set, Exim
14044implements the percent facility for those domains listed, but no others. This
14045happens before an incoming SMTP address is tested against an ACL.
14046
14047Warning: The "percent hack" has often been abused by people who are trying to
14048get round relaying restrictions. For this reason, it is best avoided if at all
14049possible. Unfortunately, a number of less security-conscious MTAs implement it
14050unconditionally. If you are running Exim on a gateway host, and routing mail
14051through to internal MTAs without processing the local parts, it is a good idea
14052to reject recipient addresses with percent characters in their local parts.
14053Exim's default configuration does this.
14054
14055+-------------+---------+-------------+--------------+
14056|perl_at_start|Use: main|Type: boolean|Default: false|
14057+-------------+---------+-------------+--------------+
14058
14059This option is available only when Exim is built with an embedded Perl
14060interpreter. See chapter 12 for details of its use.
14061
14062+------------+---------+------------+--------------+
14063|perl_startup|Use: main|Type: string|Default: unset|
14064+------------+---------+------------+--------------+
14065
14066This option is available only when Exim is built with an embedded Perl
14067interpreter. See chapter 12 for details of its use.
14068
14069+-------------+---------+-----------------+--------------+
14070|pgsql_servers|Use: main|Type: string list|Default: unset|
14071+-------------+---------+-----------------+--------------+
14072
14073This option provides a list of PostgreSQL servers and associated connection
14074data, to be used in conjunction with pgsql lookups (see section 9.21). The
14075option is available only if Exim has been built with PostgreSQL support.
14076
14077+-------------+---------+-------------+----------------------------+
14078|pid_file_path|Use: main|Type: string*|Default: set at compile time|
14079+-------------+---------+-------------+----------------------------+
14080
14081This option sets the name of the file to which the Exim daemon writes its
14082process id. The string is expanded, so it can contain, for example, references
14083to the host name:
14084
14085pid_file_path = /var/log/$primary_hostname/exim.pid
14086
14087If no path is set, the pid is written to the file exim-daemon.pid in Exim's
14088spool directory. The value set by the option can be overridden by the -oP
14089command line option. A pid file is not written if a "non-standard" daemon is
14090run by means of the -oX option, unless a path is explicitly supplied by -oP.
14091
14092+--------------------------+---------+----------------+----------+
14093|pipelining_advertise_hosts|Use: main|Type: host list*|Default: *|
14094+--------------------------+---------+----------------+----------+
14095
14096This option can be used to suppress the advertisement of the SMTP PIPELINING
14097extension to specific hosts. See also the no_pipelining control in section
1409842.22. When PIPELINING is not advertised and smtp_enforce_sync is true, an Exim
14099server enforces strict synchronization for each SMTP command and response. When
14100PIPELINING is advertised, Exim assumes that clients will use it; "out of order"
14101commands that are "expected" do not count as protocol errors (see
14102smtp_max_synprot_errors).
14103
14104+-----------+---------+-------------+--------------+
14105|prdr_enable|Use: main|Type: boolean|Default: false|
14106+-----------+---------+-------------+--------------+
14107
14108This option can be used to enable the Per-Recipient Data Response extension to
14109SMTP, defined by Eric Hall. If the option is set, PRDR is advertised by Exim
14110when operating as a server. If the client requests PRDR, and more than one
14111recipient, for a message an additional ACL is called for each recipient after
14112the message content is recieved. See section 42.9.
14113
14114+---------------------+---------+-------------+--------------+
14115|preserve_message_logs|Use: main|Type: boolean|Default: false|
14116+---------------------+---------+-------------+--------------+
14117
14118If this option is set, message log files are not deleted when messages are
14119completed. Instead, they are moved to a sub-directory of the spool directory
14120called msglog.OLD, where they remain available for statistical or debugging
14121purposes. This is a dangerous option to set on systems with any appreciable
14122volume of mail. Use with care!
14123
14124+----------------+---------+------------+------------------+
14125|primary_hostname|Use: main|Type: string|Default: see below|
14126+----------------+---------+------------+------------------+
14127
14128This specifies the name of the current host. It is used in the default EHLO or
14129HELO command for outgoing SMTP messages (changeable via the helo_data option in
14130the smtp transport), and as the default for qualify_domain. The value is also
14131used by default in some SMTP response messages from an Exim server. This can be
14132changed dynamically by setting smtp_active_hostname.
14133
14134If primary_hostname is not set, Exim calls uname() to find the host name. If
14135this fails, Exim panics and dies. If the name returned by uname() contains only
14136one component, Exim passes it to gethostbyname() (or getipnodebyname() when
14137available) in order to obtain the fully qualified version. The variable
14138$primary_hostname contains the host name, whether set explicitly by this
14139option, or defaulted.
14140
14141+-----------------+---------+-------------+--------------+
14142|print_topbitchars|Use: main|Type: boolean|Default: false|
14143+-----------------+---------+-------------+--------------+
14144
14145By default, Exim considers only those characters whose codes lie in the range
1414632-126 to be printing characters. In a number of circumstances (for example,
14147when writing log entries) non-printing characters are converted into escape
14148sequences, primarily to avoid messing up the layout. If print_topbitchars is
14149set, code values of 128 and above are also considered to be printing
14150characters.
14151
14152This option also affects the header syntax checks performed by the autoreply
14153transport, and whether Exim uses RFC 2047 encoding of the user's full name when
14154constructing From: and Sender: addresses (as described in section 46.18).
14155Setting this option can cause Exim to generate eight bit message headers that
14156do not conform to the standards.
14157
14158+----------------+---------+------------+--------------+
14159|process_log_path|Use: main|Type: string|Default: unset|
14160+----------------+---------+------------+--------------+
14161
14162This option sets the name of the file to which an Exim process writes its
14163"process log" when sent a USR1 signal. This is used by the exiwhat utility
14164script. If this option is unset, the file called exim-process.info in Exim's
14165spool directory is used. The ability to specify the name explicitly can be
14166useful in environments where two different Exims are running, using different
14167spool directories.
14168
14169+-------------------+---------+-------------+-------------+
14170|prod_requires_admin|Use: main|Type: boolean|Default: true|
14171+-------------------+---------+-------------+-------------+
14172
14173The -M, -R, and -q command-line options require the caller to be an admin user
14174unless prod_requires_admin is set false. See also queue_list_requires_admin.
14175
14176+--------------+---------+------------+------------------+
14177|qualify_domain|Use: main|Type: string|Default: see below|
14178+--------------+---------+------------+------------------+
14179
14180This option specifies the domain name that is added to any envelope sender
14181addresses that do not have a domain qualification. It also applies to recipient
14182addresses if qualify_recipient is not set. Unqualified addresses are accepted
14183by default only for locally-generated messages. Qualification is also applied
14184to addresses in header lines such as From: and To: for locally-generated
14185messages, unless the -bnq command line option is used.
14186
14187Messages from external sources must always contain fully qualified addresses,
14188unless the sending host matches sender_unqualified_hosts or
14189recipient_unqualified_hosts (as appropriate), in which case incoming addresses
14190are qualified with qualify_domain or qualify_recipient as necessary.
14191Internally, Exim always works with fully qualified envelope addresses. If
14192qualify_domain is not set, it defaults to the primary_hostname value.
14193
14194+-----------------+---------+------------+------------------+
14195|qualify_recipient|Use: main|Type: string|Default: see below|
14196+-----------------+---------+------------+------------------+
14197
14198This option allows you to specify a different domain for qualifying recipient
14199addresses to the one that is used for senders. See qualify_domain above.
14200
14201+-------------+---------+------------------+--------------+
14202|queue_domains|Use: main|Type: domain list*|Default: unset|
14203+-------------+---------+------------------+--------------+
14204
14205This option lists domains for which immediate delivery is not required. A
14206delivery process is started whenever a message is received, but only those
14207domains that do not match are processed. All other deliveries wait until the
14208next queue run. See also hold_domains and queue_smtp_domains.
14209
14210+-------------------------+---------+-------------+-------------+
14211|queue_list_requires_admin|Use: main|Type: boolean|Default: true|
14212+-------------------------+---------+-------------+-------------+
14213
14214The -bp command-line option, which lists the messages that are on the queue,
14215requires the caller to be an admin user unless queue_list_requires_admin is set
14216false. See also prod_requires_admin.
14217
14218+----------+---------+-------------+--------------+
14219|queue_only|Use: main|Type: boolean|Default: false|
14220+----------+---------+-------------+--------------+
14221
14222If queue_only is set, a delivery process is not automatically started whenever
14223a message is received. Instead, the message waits on the queue for the next
14224queue run. Even if queue_only is false, incoming messages may not get delivered
14225immediately when certain conditions (such as heavy load) occur.
14226
14227The -odq command line has the same effect as queue_only. The -odb and -odi
14228command line options override queue_only unless queue_only_override is set
14229false. See also queue_only_file, queue_only_load, and smtp_accept_queue.
14230
14231+---------------+---------+------------+--------------+
14232|queue_only_file|Use: main|Type: string|Default: unset|
14233+---------------+---------+------------+--------------+
14234
14235This option can be set to a colon-separated list of absolute path names, each
14236one optionally preceded by "smtp". When Exim is receiving a message, it tests
14237for the existence of each listed path using a call to stat(). For each path
14238that exists, the corresponding queueing option is set. For paths with no
14239prefix, queue_only is set; for paths prefixed by "smtp", queue_smtp_domains is
14240set to match all domains. So, for example,
14241
14242queue_only_file = smtp/some/file
14243
14244causes Exim to behave as if queue_smtp_domains were set to "*" whenever /some/
14245file exists.
14246
14247+---------------+---------+-----------------+--------------+
14248|queue_only_load|Use: main|Type: fixed-point|Default: unset|
14249+---------------+---------+-----------------+--------------+
14250
14251If the system load average is higher than this value, incoming messages from
14252all sources are queued, and no automatic deliveries are started. If this
14253happens during local or remote SMTP input, all subsequent messages received on
14254the same SMTP connection are queued by default, whatever happens to the load in
14255the meantime, but this can be changed by setting queue_only_load_latch false.
14256
14257Deliveries will subsequently be performed by queue runner processes. This
14258option has no effect on ancient operating systems on which Exim cannot
14259determine the load average. See also deliver_queue_load_max and
14260smtp_load_reserve.
14261
14262+---------------------+---------+-------------+-------------+
14263|queue_only_load_latch|Use: main|Type: boolean|Default: true|
14264+---------------------+---------+-------------+-------------+
14265
14266When this option is true (the default), once one message has been queued
14267because the load average is higher than the value set by queue_only_load, all
14268subsequent messages received on the same SMTP connection are also queued. This
14269is a deliberate choice; even though the load average may fall below the
14270threshold, it doesn't seem right to deliver later messages on the same
14271connection when not delivering earlier ones. However, there are special
14272circumstances such as very long-lived connections from scanning appliances
14273where this is not the best strategy. In such cases, queue_only_load_latch
14274should be set false. This causes the value of the load average to be
14275re-evaluated for each message.
14276
14277+-------------------+---------+-------------+-------------+
14278|queue_only_override|Use: main|Type: boolean|Default: true|
14279+-------------------+---------+-------------+-------------+
14280
14281When this option is true, the -odx command line options override the setting of
14282queue_only or queue_only_file in the configuration file. If queue_only_override
14283is set false, the -odx options cannot be used to override; they are accepted,
14284but ignored.
14285
14286+------------------+---------+-------------+--------------+
14287|queue_run_in_order|Use: main|Type: boolean|Default: false|
14288+------------------+---------+-------------+--------------+
14289
14290If this option is set, queue runs happen in order of message arrival instead of
14291in an arbitrary order. For this to happen, a complete list of the entire queue
14292must be set up before the deliveries start. When the queue is all held in a
14293single directory (the default), a single list is created for both the ordered
14294and the non-ordered cases. However, if split_spool_directory is set, a single
14295list is not created when queue_run_in_order is false. In this case, the
14296sub-directories are processed one at a time (in a random order), and this
14297avoids setting up one huge list for the whole queue. Thus, setting
14298queue_run_in_order with split_spool_directory may degrade performance when the
14299queue is large, because of the extra work in setting up the single, large list.
14300In most situations, queue_run_in_order should not be set.
14301
14302+-------------+---------+-------------+----------+
14303|queue_run_max|Use: main|Type: integer|Default: 5|
14304+-------------+---------+-------------+----------+
14305
14306This controls the maximum number of queue runner processes that an Exim daemon
14307can run simultaneously. This does not mean that it starts them all at once, but
14308rather that if the maximum number are still running when the time comes to
14309start another one, it refrains from starting another one. This can happen with
14310very large queues and/or very sluggish deliveries. This option does not,
14311however, interlock with other processes, so additional queue runners can be
14312started by other means, or by killing and restarting the daemon.
14313
14314Setting this option to zero does not suppress queue runs; rather, it disables
14315the limit, allowing any number of simultaneous queue runner processes to be
14316run. If you do not want queue runs to occur, omit the -qxx setting on the
14317daemon's command line.
14318
14319+------------------+---------+------------------+--------------+
14320|queue_smtp_domains|Use: main|Type: domain list*|Default: unset|
14321+------------------+---------+------------------+--------------+
14322
14323When this option is set, a delivery process is started whenever a message is
14324received, routing is performed, and local deliveries take place. However, if
14325any SMTP deliveries are required for domains that match queue_smtp_domains,
14326they are not immediately delivered, but instead the message waits on the queue
14327for the next queue run. Since routing of the message has taken place, Exim
14328knows to which remote hosts it must be delivered, and so when the queue run
14329happens, multiple messages for the same host are delivered over a single SMTP
14330connection. The -odqs command line option causes all SMTP deliveries to be
14331queued in this way, and is equivalent to setting queue_smtp_domains to "*". See
14332also hold_domains and queue_domains.
14333
14334+---------------+---------+----------+-----------+
14335|receive_timeout|Use: main|Type: time|Default: 0s|
14336+---------------+---------+----------+-----------+
14337
14338This option sets the timeout for accepting a non-SMTP message, that is, the
14339maximum time that Exim waits when reading a message on the standard input. If
14340the value is zero, it will wait for ever. This setting is overridden by the -or
14341command line option. The timeout for incoming SMTP messages is controlled by
14342smtp_receive_timeout.
14343
14344+--------------------+---------+-------------+------------------+
14345|received_header_text|Use: main|Type: string*|Default: see below|
14346+--------------------+---------+-------------+------------------+
14347
14348This string defines the contents of the Received: message header that is added
14349to each message, except for the timestamp, which is automatically added on at
14350the end (preceded by a semicolon). The string is expanded each time it is used.
14351If the expansion yields an empty string, no Received: header line is added to
14352the message. Otherwise, the string should start with the text "Received:" and
14353conform to the RFC 2822 specification for Received: header lines. The default
14354setting is:
14355
14356received_header_text = Received: \
14357 ${if def:sender_rcvhost {from $sender_rcvhost\n\t}\
14358 {${if def:sender_ident \
14359 {from ${quote_local_part:$sender_ident} }}\
14360 ${if def:sender_helo_name {(helo=$sender_helo_name)\n\t}}}}\
14361 by $primary_hostname \
14362 ${if def:received_protocol {with $received_protocol}} \
14363 ${if def:tls_in_cipher {($tls_in_cipher)\n\t}}\
14364 (Exim $version_number)\n\t\
14365 ${if def:sender_address \
14366 {(envelope-from <$sender_address>)\n\t}}\
14367 id $message_exim_id\
14368 ${if def:received_for {\n\tfor $received_for}}
14369
14370The reference to the TLS cipher is omitted when Exim is built without TLS
14371support. The use of conditional expansions ensures that this works for both
14372locally generated messages and messages received from remote hosts, giving
14373header lines such as the following:
14374
14375Received: from scrooge.carol.example ([192.168.12.25] ident=root)
14376by marley.carol.example with esmtp (Exim 4.00)
14377(envelope-from <bob@carol.example>)
14378id 16IOWa-00019l-00
14379for chas@dickens.example; Tue, 25 Dec 2001 14:43:44 +0000
14380Received: by scrooge.carol.example with local (Exim 4.00)
14381id 16IOWW-000083-00; Tue, 25 Dec 2001 14:43:41 +0000
14382
14383Until the body of the message has been received, the timestamp is the time when
14384the message started to be received. Once the body has arrived, and all policy
14385checks have taken place, the timestamp is updated to the time at which the
14386message was accepted.
14387
14388+--------------------+---------+-------------+-----------+
14389|received_headers_max|Use: main|Type: integer|Default: 30|
14390+--------------------+---------+-------------+-----------+
14391
14392When a message is to be delivered, the number of Received: headers is counted,
14393and if it is greater than this parameter, a mail loop is assumed to have
14394occurred, the delivery is abandoned, and an error message is generated. This
14395applies to both local and remote deliveries.
14396
14397+---------------------------+---------+----------------+--------------+
14398|recipient_unqualified_hosts|Use: main|Type: host list*|Default: unset|
14399+---------------------------+---------+----------------+--------------+
14400
14401This option lists those hosts from which Exim is prepared to accept unqualified
14402recipient addresses in message envelopes. The addresses are made fully
14403qualified by the addition of the qualify_recipient value. This option also
14404affects message header lines. Exim does not reject unqualified recipient
14405addresses in headers, but it qualifies them only if the message came from a
14406host that matches recipient_unqualified_hosts, or if the message was submitted
14407locally (not using TCP/IP), and the -bnq option was not set.
14408
14409+--------------+---------+-------------+----------+
14410|recipients_max|Use: main|Type: integer|Default: 0|
14411+--------------+---------+-------------+----------+
14412
14413If this option is set greater than zero, it specifies the maximum number of
14414original recipients for any message. Additional recipients that are generated
14415by aliasing or forwarding do not count. SMTP messages get a 452 response for
14416all recipients over the limit; earlier recipients are delivered as normal.
14417Non-SMTP messages with too many recipients are failed, and no deliveries are
14418done.
14419
14420Note: The RFCs specify that an SMTP server should accept at least 100 RCPT
14421commands in a single message.
14422
14423+---------------------+---------+-------------+--------------+
14424|recipients_max_reject|Use: main|Type: boolean|Default: false|
14425+---------------------+---------+-------------+--------------+
14426
14427If this option is set true, Exim rejects SMTP messages containing too many
14428recipients by giving 552 errors to the surplus RCPT commands, and a 554 error
14429to the eventual DATA command. Otherwise (the default) it gives a 452 error to
14430the surplus RCPT commands and accepts the message on behalf of the initial set
14431of recipients. The remote server should then re-send the message for the
14432remaining recipients at a later time.
14433
14434+-------------------+---------+-------------+----------+
14435|remote_max_parallel|Use: main|Type: integer|Default: 2|
14436+-------------------+---------+-------------+----------+
14437
14438This option controls parallel delivery of one message to a number of remote
14439hosts. If the value is less than 2, parallel delivery is disabled, and Exim
14440does all the remote deliveries for a message one by one. Otherwise, if a single
14441message has to be delivered to more than one remote host, or if several copies
14442have to be sent to the same remote host, up to remote_max_parallel deliveries
14443are done simultaneously. If more than remote_max_parallel deliveries are
14444required, the maximum number of processes are started, and as each one
14445finishes, another is begun. The order of starting processes is the same as if
14446sequential delivery were being done, and can be controlled by the
14447remote_sort_domains option. If parallel delivery takes place while running with
14448debugging turned on, the debugging output from each delivery process is tagged
14449with its process id.
14450
14451This option controls only the maximum number of parallel deliveries for one
14452message in one Exim delivery process. Because Exim has no central queue
14453manager, there is no way of controlling the total number of simultaneous
14454deliveries if the configuration allows a delivery attempt as soon as a message
14455is received.
14456
14457If you want to control the total number of deliveries on the system, you need
14458to set the queue_only option. This ensures that all incoming messages are added
14459to the queue without starting a delivery process. Then set up an Exim daemon to
14460start queue runner processes at appropriate intervals (probably fairly often,
14461for example, every minute), and limit the total number of queue runners by
14462setting the queue_run_max parameter. Because each queue runner delivers only
14463one message at a time, the maximum number of deliveries that can then take
14464place at once is queue_run_max multiplied by remote_max_parallel.
14465
14466If it is purely remote deliveries you want to control, use queue_smtp_domains
14467instead of queue_only. This has the added benefit of doing the SMTP routing
14468before queueing, so that several messages for the same host will eventually get
14469delivered down the same connection.
14470
14471+-------------------+---------+------------------+--------------+
14472|remote_sort_domains|Use: main|Type: domain list*|Default: unset|
14473+-------------------+---------+------------------+--------------+
14474
14475When there are a number of remote deliveries for a message, they are sorted by
14476domain into the order given by this list. For example,
14477
14478remote_sort_domains = *.cam.ac.uk:*.uk
14479
14480would attempt to deliver to all addresses in the cam.ac.uk domain first, then
14481to those in the uk domain, then to any others.
14482
14483+-----------------+---------+----------+-----------+
14484|retry_data_expire|Use: main|Type: time|Default: 7d|
14485+-----------------+---------+----------+-----------+
14486
14487This option sets a "use before" time on retry information in Exim's hints
14488database. Any older retry data is ignored. This means that, for example, once a
14489host has not been tried for 7 days, Exim behaves as if it has no knowledge of
14490past failures.
14491
14492+------------------+---------+----------+------------+
14493|retry_interval_max|Use: main|Type: time|Default: 24h|
14494+------------------+---------+----------+------------+
14495
14496Chapter 32 describes Exim's mechanisms for controlling the intervals between
14497delivery attempts for messages that cannot be delivered straight away. This
14498option sets an overall limit to the length of time between retries. It cannot
14499be set greater than 24 hours; any attempt to do so forces the default value.
14500
14501+------------------+---------+-------------+-------------+
14502|return_path_remove|Use: main|Type: boolean|Default: true|
14503+------------------+---------+-------------+-------------+
14504
14505RFC 2821, section 4.4, states that an SMTP server must insert a Return-path:
14506header line into a message when it makes a "final delivery". The Return-path:
14507header preserves the sender address as received in the MAIL command. This
14508description implies that this header should not be present in an incoming
14509message. If return_path_remove is true, any existing Return-path: headers are
14510removed from messages at the time they are received. Exim's transports have
14511options for adding Return-path: headers at the time of delivery. They are
14512normally used only for final local deliveries.
14513
14514+-----------------+---------+-------------+-------------+
14515|return_size_limit|Use: main|Type: integer|Default: 100K|
14516+-----------------+---------+-------------+-------------+
14517
14518This option is an obsolete synonym for bounce_return_size_limit.
14519
14520+-------------+---------+----------------+----------+
14521|rfc1413_hosts|Use: main|Type: host list*|Default: *|
14522+-------------+---------+----------------+----------+
14523
14524RFC 1413 identification calls are made to any client host which matches an item
14525in the list.
14526
14527+---------------------+---------+----------+-----------+
14528|rfc1413_query_timeout|Use: main|Type: time|Default: 5s|
14529+---------------------+---------+----------+-----------+
14530
14531This sets the timeout on RFC 1413 identification calls. If it is set to zero,
14532no RFC 1413 calls are ever made.
14533
14534+------------------------+---------+----------------+--------------+
14535|sender_unqualified_hosts|Use: main|Type: host list*|Default: unset|
14536+------------------------+---------+----------------+--------------+
14537
14538This option lists those hosts from which Exim is prepared to accept unqualified
14539sender addresses. The addresses are made fully qualified by the addition of
14540qualify_domain. This option also affects message header lines. Exim does not
14541reject unqualified addresses in headers that contain sender addresses, but it
14542qualifies them only if the message came from a host that matches
14543sender_unqualified_hosts, or if the message was submitted locally (not using
14544TCP/IP), and the -bnq option was not set.
14545
188b6fee
CE
14546+---------------+---------+-----------------+--------------+
14547|set_environment|Use: main|Type: string list|Default: empty|
14548+---------------+---------+-----------------+--------------+
14549
14550This option allows to set individual environment variables that the currently
14551linked libraries and programs in child processes use. The default list is
14552empty,
14553
420a0d19
CE
14554+---------------------+---------+-------------+-------------+
14555|smtp_accept_keepalive|Use: main|Type: boolean|Default: true|
14556+---------------------+---------+-------------+-------------+
14557
14558This option controls the setting of the SO_KEEPALIVE option on incoming TCP/IP
14559socket connections. When set, it causes the kernel to probe idle connections
14560periodically, by sending packets with "old" sequence numbers. The other end of
14561the connection should send an acknowledgment if the connection is still okay or
14562a reset if the connection has been aborted. The reason for doing this is that
14563it has the beneficial effect of freeing up certain types of connection that can
14564get stuck when the remote host is disconnected without tidying up the TCP/IP
14565call properly. The keepalive mechanism takes several hours to detect
14566unreachable hosts.
14567
14568+---------------+---------+-------------+-----------+
14569|smtp_accept_max|Use: main|Type: integer|Default: 20|
14570+---------------+---------+-------------+-----------+
14571
14572This option specifies the maximum number of simultaneous incoming SMTP calls
14573that Exim will accept. It applies only to the listening daemon; there is no
14574control (in Exim) when incoming SMTP is being handled by inetd. If the value is
14575set to zero, no limit is applied. However, it is required to be non-zero if
14576either smtp_accept_max_per_host or smtp_accept_queue is set. See also
14577smtp_accept_reserve and smtp_load_reserve.
14578
14579A new SMTP connection is immediately rejected if the smtp_accept_max limit has
14580been reached. If not, Exim first checks smtp_accept_max_per_host. If that limit
14581has not been reached for the client host, smtp_accept_reserve and
14582smtp_load_reserve are then checked before accepting the connection.
14583
14584+-----------------------+---------+-------------+-----------+
14585|smtp_accept_max_nonmail|Use: main|Type: integer|Default: 10|
14586+-----------------------+---------+-------------+-----------+
14587
14588Exim counts the number of "non-mail" commands in an SMTP session, and drops the
14589connection if there are too many. This option defines "too many". The check
14590catches some denial-of-service attacks, repeated failing AUTHs, or a mad client
14591looping sending EHLO, for example. The check is applied only if the client host
14592matches smtp_accept_max_nonmail_hosts.
14593
14594When a new message is expected, one occurrence of RSET is not counted. This
14595allows a client to send one RSET between messages (this is not necessary, but
14596some clients do it). Exim also allows one uncounted occurrence of HELO or EHLO,
14597and one occurrence of STARTTLS between messages. After starting up a TLS
14598session, another EHLO is expected, and so it too is not counted. The first
14599occurrence of AUTH in a connection, or immediately following STARTTLS is not
14600counted. Otherwise, all commands other than MAIL, RCPT, DATA, and QUIT are
14601counted.
14602
14603+-----------------------------+---------+----------------+----------+
14604|smtp_accept_max_nonmail_hosts|Use: main|Type: host list*|Default: *|
14605+-----------------------------+---------+----------------+----------+
14606
14607You can control which hosts are subject to the smtp_accept_max_nonmail check by
14608setting this option. The default value makes it apply to all hosts. By changing
14609the value, you can exclude any badly-behaved hosts that you have to live with.
14610
14611+------------------------------+---------+-------------+-------------+
14612|smtp_accept_max_per_connection|Use: main|Type: integer|Default: 1000|
14613+------------------------------+---------+-------------+-------------+
14614
14615The value of this option limits the number of MAIL commands that Exim is
14616prepared to accept over a single SMTP connection, whether or not each command
14617results in the transfer of a message. After the limit is reached, a 421
14618response is given to subsequent MAIL commands. This limit is a safety
14619precaution against a client that goes mad (incidents of this type have been
14620seen).
14621
14622+------------------------+---------+-------------+--------------+
14623|smtp_accept_max_per_host|Use: main|Type: string*|Default: unset|
14624+------------------------+---------+-------------+--------------+
14625
14626This option restricts the number of simultaneous IP connections from a single
14627host (strictly, from a single IP address) to the Exim daemon. The option is
14628expanded, to enable different limits to be applied to different hosts by
14629reference to $sender_host_address. Once the limit is reached, additional
14630connection attempts from the same host are rejected with error code 421. This
14631is entirely independent of smtp_accept_reserve. The option's default value of
14632zero imposes no limit. If this option is set greater than zero, it is required
14633that smtp_accept_max be non-zero.
14634
14635Warning: When setting this option you should not use any expansion
14636constructions that take an appreciable amount of time. The expansion and test
14637happen in the main daemon loop, in order to reject additional connections
14638without forking additional processes (otherwise a denial-of-service attack
14639could cause a vast number or processes to be created). While the daemon is
14640doing this processing, it cannot accept any other incoming connections.
14641
14642+-----------------+---------+-------------+----------+
14643|smtp_accept_queue|Use: main|Type: integer|Default: 0|
14644+-----------------+---------+-------------+----------+
14645
14646If the number of simultaneous incoming SMTP connections being handled via the
14647listening daemon exceeds this value, messages received by SMTP are just placed
14648on the queue; no delivery processes are started automatically. The count is
14649fixed at the start of an SMTP connection. It cannot be updated in the
14650subprocess that receives messages, and so the queueing or not queueing applies
14651to all messages received in the same connection.
14652
14653A value of zero implies no limit, and clearly any non-zero value is useful only
14654if it is less than the smtp_accept_max value (unless that is zero). See also
14655queue_only, queue_only_load, queue_smtp_domains, and the various -odx command
14656line options.
14657
14658+--------------------------------+---------+-------------+-----------+
14659|smtp_accept_queue_per_connection|Use: main|Type: integer|Default: 10|
14660+--------------------------------+---------+-------------+-----------+
14661
14662This option limits the number of delivery processes that Exim starts
14663automatically when receiving messages via SMTP, whether via the daemon or by
14664the use of -bs or -bS. If the value of the option is greater than zero, and the
14665number of messages received in a single SMTP session exceeds this number,
14666subsequent messages are placed on the queue, but no delivery processes are
14667started. This helps to limit the number of Exim processes when a server
14668restarts after downtime and there is a lot of mail waiting for it on other
14669systems. On large systems, the default should probably be increased, and on
14670dial-in client systems it should probably be set to zero (that is, disabled).
14671
14672+-------------------+---------+-------------+----------+
14673|smtp_accept_reserve|Use: main|Type: integer|Default: 0|
14674+-------------------+---------+-------------+----------+
14675
14676When smtp_accept_max is set greater than zero, this option specifies a number
14677of SMTP connections that are reserved for connections from the hosts that are
14678specified in smtp_reserve_hosts. The value set in smtp_accept_max includes this
14679reserve pool. The specified hosts are not restricted to this number of
14680connections; the option specifies a minimum number of connection slots for
14681them, not a maximum. It is a guarantee that this group of hosts can always get
14682at least smtp_accept_reserve connections. However, the limit specified by
14683smtp_accept_max_per_host is still applied to each individual host.
14684
14685For example, if smtp_accept_max is set to 50 and smtp_accept_reserve is set to
146865, once there are 45 active connections (from any hosts), new connections are
14687accepted only from hosts listed in smtp_reserve_hosts, provided the other
14688criteria for acceptance are met.
14689
14690+--------------------+---------+-------------+--------------+
14691|smtp_active_hostname|Use: main|Type: string*|Default: unset|
14692+--------------------+---------+-------------+--------------+
14693
14694This option is provided for multi-homed servers that want to masquerade as
14695several different hosts. At the start of an incoming SMTP connection, its value
14696is expanded and used instead of the value of $primary_hostname in SMTP
14697responses. For example, it is used as domain name in the response to an
14698incoming HELO or EHLO command.
14699
14700The active hostname is placed in the $smtp_active_hostname variable, which is
14701saved with any messages that are received. It is therefore available for use in
14702routers and transports when the message is later delivered.
14703
14704If this option is unset, or if its expansion is forced to fail, or if the
14705expansion results in an empty string, the value of $primary_hostname is used.
14706Other expansion failures cause a message to be written to the main and panic
14707logs, and the SMTP command receives a temporary error. Typically, the value of
14708smtp_active_hostname depends on the incoming interface address. For example:
14709
14710smtp_active_hostname = ${if eq{$received_ip_address}{10.0.0.1}\
14711 {cox.mydomain}{box.mydomain}}
14712
14713Although $smtp_active_hostname is primarily concerned with incoming messages,
14714it is also used as the default for HELO commands in callout verification if
14715there is no remote transport from which to obtain a helo_data value.
14716
14717+-----------+---------+-------------+------------------+
14718|smtp_banner|Use: main|Type: string*|Default: see below|
14719+-----------+---------+-------------+------------------+
14720
14721This string, which is expanded every time it is used, is output as the initial
14722positive response to an SMTP connection. The default setting is:
14723
14724smtp_banner = $smtp_active_hostname ESMTP Exim \
14725 $version_number $tod_full
14726
14727Failure to expand the string causes a panic error. If you want to create a
14728multiline response to the initial SMTP connection, use "\n" in the string at
14729appropriate points, but not at the end. Note that the 220 code is not included
14730in this string. Exim adds it automatically (several times in the case of a
14731multiline response).
14732
14733+----------------------+---------+-------------+-------------+
14734|smtp_check_spool_space|Use: main|Type: boolean|Default: true|
14735+----------------------+---------+-------------+-------------+
14736
14737When this option is set, if an incoming SMTP session encounters the SIZE option
14738on a MAIL command, it checks that there is enough space in the spool
14739directory's partition to accept a message of that size, while still leaving
14740free the amount specified by check_spool_space (even if that value is zero). If
14741there isn't enough space, a temporary error code is returned.
14742
14743+--------------------+---------+-------------+-----------+
14744|smtp_connect_backlog|Use: main|Type: integer|Default: 20|
14745+--------------------+---------+-------------+-----------+
14746
14747This option specifies a maximum number of waiting SMTP connections. Exim passes
14748this value to the TCP/IP system when it sets up its listener. Once this number
14749of connections are waiting for the daemon's attention, subsequent connection
14750attempts are refused at the TCP/IP level. At least, that is what the manuals
14751say; in some circumstances such connection attempts have been observed to time
14752out instead. For large systems it is probably a good idea to increase the value
14753(to 50, say). It also gives some protection against denial-of-service attacks
14754by SYN flooding.
14755
14756+-----------------+---------+-------------+-------------+
14757|smtp_enforce_sync|Use: main|Type: boolean|Default: true|
14758+-----------------+---------+-------------+-------------+
14759
14760The SMTP protocol specification requires the client to wait for a response from
14761the server at certain points in the dialogue. Without PIPELINING these
14762synchronization points are after every command; with PIPELINING they are fewer,
14763but they still exist.
14764
14765Some spamming sites send out a complete set of SMTP commands without waiting
14766for any response. Exim protects against this by rejecting a message if the
14767client has sent further input when it should not have. The error response "554
14768SMTP synchronization error" is sent, and the connection is dropped. Testing for
14769this error cannot be perfect because of transmission delays (unexpected input
14770may be on its way but not yet received when Exim checks). However, it does
14771detect many instances.
14772
14773The check can be globally disabled by setting smtp_enforce_sync false. If you
14774want to disable the check selectively (for example, only for certain hosts),
14775you can do so by an appropriate use of a control modifier in an ACL (see
14776section 42.22). See also pipelining_advertise_hosts.
14777
14778+-----------------+---------+-------------+--------------+
14779|smtp_etrn_command|Use: main|Type: string*|Default: unset|
14780+-----------------+---------+-------------+--------------+
14781
14782If this option is set, the given command is run whenever an SMTP ETRN command
14783is received from a host that is permitted to issue such commands (see chapter
1478442). The string is split up into separate arguments which are independently
14785expanded. The expansion variable $domain is set to the argument of the ETRN
14786command, and no syntax checking is done on it. For example:
14787
14788smtp_etrn_command = /etc/etrn_command $domain \
14789 $sender_host_address
14790
14791A new process is created to run the command, but Exim does not wait for it to
14792complete. Consequently, its status cannot be checked. If the command cannot be
14793run, a line is written to the panic log, but the ETRN caller still receives a
14794250 success response. Exim is normally running under its own uid when receiving
14795SMTP, so it is not possible for it to change the uid before running the
14796command.
14797
14798+-------------------+---------+-------------+-------------+
14799|smtp_etrn_serialize|Use: main|Type: boolean|Default: true|
14800+-------------------+---------+-------------+-------------+
14801
14802When this option is set, it prevents the simultaneous execution of more than
14803one identical command as a result of ETRN in an SMTP connection. See section
1480447.8 for details.
14805
14806+-----------------+---------+-----------------+--------------+
14807|smtp_load_reserve|Use: main|Type: fixed-point|Default: unset|
14808+-----------------+---------+-----------------+--------------+
14809
14810If the system load average ever gets higher than this, incoming SMTP calls are
14811accepted only from those hosts that match an entry in smtp_reserve_hosts. If
14812smtp_reserve_hosts is not set, no incoming SMTP calls are accepted when the
14813load is over the limit. The option has no effect on ancient operating systems
14814on which Exim cannot determine the load average. See also
14815deliver_queue_load_max and queue_only_load.
14816
14817+-----------------------+---------+-------------+----------+
14818|smtp_max_synprot_errors|Use: main|Type: integer|Default: 3|
14819+-----------------------+---------+-------------+----------+
14820
14821Exim rejects SMTP commands that contain syntax or protocol errors. In
14822particular, a syntactically invalid email address, as in this command:
14823
14824RCPT TO:<abc xyz@a.b.c>
14825
14826causes immediate rejection of the command, before any other tests are done.
14827(The ACL cannot be run if there is no valid address to set up for it.) An
14828example of a protocol error is receiving RCPT before MAIL. If there are too
14829many syntax or protocol errors in one SMTP session, the connection is dropped.
14830The limit is set by this option.
14831
14832When the PIPELINING extension to SMTP is in use, some protocol errors are
14833"expected", for instance, a RCPT command after a rejected MAIL command. Exim
14834assumes that PIPELINING will be used if it advertises it (see
14835pipelining_advertise_hosts), and in this situation, "expected" errors do not
14836count towards the limit.
14837
14838+-------------------------+---------+-------------+----------+
14839|smtp_max_unknown_commands|Use: main|Type: integer|Default: 3|
14840+-------------------------+---------+-------------+----------+
14841
14842If there are too many unrecognized commands in an incoming SMTP session, an
14843Exim server drops the connection. This is a defence against some kinds of abuse
14844that subvert web clients into making connections to SMTP ports; in these
14845circumstances, a number of non-SMTP command lines are sent first.
14846
14847+--------------------+---------+----------------+--------------+
14848|smtp_ratelimit_hosts|Use: main|Type: host list*|Default: unset|
14849+--------------------+---------+----------------+--------------+
14850
14851Some sites find it helpful to be able to limit the rate at which certain hosts
14852can send them messages, and the rate at which an individual message can specify
14853recipients.
14854
14855Exim has two rate-limiting facilities. This section describes the older
14856facility, which can limit rates within a single connection. The newer ratelimit
14857ACL condition can limit rates across all connections. See section 42.38 for
14858details of the newer facility.
14859
14860When a host matches smtp_ratelimit_hosts, the values of smtp_ratelimit_mail and
14861smtp_ratelimit_rcpt are used to control the rate of acceptance of MAIL and RCPT
14862commands in a single SMTP session, respectively. Each option, if set, must
14863contain a set of four comma-separated values:
14864
14865 * A threshold, before which there is no rate limiting.
14866
14867 * An initial time delay. Unlike other times in Exim, numbers with decimal
14868 fractional parts are allowed here.
14869
14870 * A factor by which to increase the delay each time.
14871
14872 * A maximum value for the delay. This should normally be less than 5 minutes,
14873 because after that time, the client is liable to timeout the SMTP command.
14874
14875For example, these settings have been used successfully at the site which first
14876suggested this feature, for controlling mail from their customers:
14877
14878smtp_ratelimit_mail = 2,0.5s,1.05,4m
14879smtp_ratelimit_rcpt = 4,0.25s,1.015,4m
14880
14881The first setting specifies delays that are applied to MAIL commands after two
14882have been received over a single connection. The initial delay is 0.5 seconds,
14883increasing by a factor of 1.05 each time. The second setting applies delays to
14884RCPT commands when more than four occur in a single message.
14885
14886+-------------------+---------+------------+--------------+
14887|smtp_ratelimit_mail|Use: main|Type: string|Default: unset|
14888+-------------------+---------+------------+--------------+
14889
14890See smtp_ratelimit_hosts above.
14891
14892+-------------------+---------+------------+--------------+
14893|smtp_ratelimit_rcpt|Use: main|Type: string|Default: unset|
14894+-------------------+---------+------------+--------------+
14895
14896See smtp_ratelimit_hosts above.
14897
14898+--------------------+---------+----------+-----------+
14899|smtp_receive_timeout|Use: main|Type: time|Default: 5m|
14900+--------------------+---------+----------+-----------+
14901
14902This sets a timeout value for SMTP reception. It applies to all forms of SMTP
14903input, including batch SMTP. If a line of input (either an SMTP command or a
14904data line) is not received within this time, the SMTP connection is dropped and
14905the message is abandoned. A line is written to the log containing one of the
14906following messages:
14907
14908SMTP command timeout on connection from...
14909SMTP data timeout on connection from...
14910
14911The former means that Exim was expecting to read an SMTP command; the latter
14912means that it was in the DATA phase, reading the contents of a message.
14913
14914The value set by this option can be overridden by the -os command-line option.
14915A setting of zero time disables the timeout, but this should never be used for
14916SMTP over TCP/IP. (It can be useful in some cases of local input using -bs or
14917-bS.) For non-SMTP input, the reception timeout is controlled by
14918receive_timeout and -or.
14919
14920+------------------+---------+----------------+--------------+
14921|smtp_reserve_hosts|Use: main|Type: host list*|Default: unset|
14922+------------------+---------+----------------+--------------+
14923
14924This option defines hosts for which SMTP connections are reserved; see
14925smtp_accept_reserve and smtp_load_reserve above.
14926
14927+-------------------------+---------+-------------+--------------+
14928|smtp_return_error_details|Use: main|Type: boolean|Default: false|
14929+-------------------------+---------+-------------+--------------+
14930
14931In the default state, Exim uses bland messages such as "Administrative
14932prohibition" when it rejects SMTP commands for policy reasons. Many sysadmins
14933like this because it gives away little information to spammers. However, some
14934other sysadmins who are applying strict checking policies want to give out much
14935fuller information about failures. Setting smtp_return_error_details true
14936causes Exim to be more forthcoming. For example, instead of "Administrative
14937prohibition", it might give:
14938
14939550-Rejected after DATA: '>' missing at end of address:
14940550 failing address in "From" header is: <user@dom.ain
14941
14942+-------------+---------+------------+------------------+
14943|spamd_address|Use: main|Type: string|Default: see below|
14944+-------------+---------+------------+------------------+
14945
14946This option is available when Exim is compiled with the content-scanning
14947extension. It specifies how Exim connects to SpamAssassin's spamd daemon. The
14948default value is
14949
14950127.0.0.1 783
14951
14952See section 43.2 for more details.
14953
14954+---------------------+---------+-------------+--------------+
14955|split_spool_directory|Use: main|Type: boolean|Default: false|
14956+---------------------+---------+-------------+--------------+
14957
14958If this option is set, it causes Exim to split its input directory into 62
14959subdirectories, each with a single alphanumeric character as its name. The
14960sixth character of the message id is used to allocate messages to
14961subdirectories; this is the least significant base-62 digit of the time of
14962arrival of the message.
14963
14964Splitting up the spool in this way may provide better performance on systems
14965where there are long mail queues, by reducing the number of files in any one
14966directory. The msglog directory is also split up in a similar way to the input
14967directory; however, if preserve_message_logs is set, all old msglog files are
14968still placed in the single directory msglog.OLD.
14969
14970It is not necessary to take any special action for existing messages when
14971changing split_spool_directory. Exim notices messages that are in the "wrong"
14972place, and continues to process them. If the option is turned off after a
14973period of being on, the subdirectories will eventually empty and be
14974automatically deleted.
14975
14976When split_spool_directory is set, the behaviour of queue runner processes
14977changes. Instead of creating a list of all messages in the queue, and then
14978trying to deliver each one in turn, it constructs a list of those in one
14979sub-directory and tries to deliver them, before moving on to the next
14980sub-directory. The sub-directories are processed in a random order. This
14981spreads out the scanning of the input directories, and uses less memory. It is
14982particularly beneficial when there are lots of messages on the queue. However,
14983if queue_run_in_order is set, none of this new processing happens. The entire
14984queue has to be scanned and sorted before any deliveries can start.
14985
14986+---------------+---------+-------------+----------------------------+
14987|spool_directory|Use: main|Type: string*|Default: set at compile time|
14988+---------------+---------+-------------+----------------------------+
14989
14990This defines the directory in which Exim keeps its spool, that is, the messages
14991it is waiting to deliver. The default value is taken from the compile-time
14992configuration setting, if there is one. If not, this option must be set. The
14993string is expanded, so it can contain, for example, a reference to
14994$primary_hostname.
14995
14996If the spool directory name is fixed on your installation, it is recommended
14997that you set it at build time rather than from this option, particularly if the
14998log files are being written to the spool directory (see log_file_path).
14999Otherwise log files cannot be used for errors that are detected early on, such
15000as failures in the configuration file.
15001
15002By using this option to override the compiled-in path, it is possible to run
15003tests of Exim without using the standard spool.
15004
15005+-------------------+---------+----------+-----------+
15006|sqlite_lock_timeout|Use: main|Type: time|Default: 5s|
15007+-------------------+---------+----------+-----------+
15008
15009This option controls the timeout that the sqlite lookup uses when trying to
15010access an SQLite database. See section 9.25 for more details.
15011
15012+---------------+---------+-------------+--------------+
15013|strict_acl_vars|Use: main|Type: boolean|Default: false|
15014+---------------+---------+-------------+--------------+
15015
15016This option controls what happens if a syntactically valid but undefined ACL
15017variable is referenced. If it is false (the default), an empty string is
15018substituted; if it is true, an error is generated. See section 42.19 for
15019details of ACL variables.
15020
15021+---------------------------+---------+-------------+--------------+
15022|strip_excess_angle_brackets|Use: main|Type: boolean|Default: false|
15023+---------------------------+---------+-------------+--------------+
15024
15025If this option is set, redundant pairs of angle brackets round "route-addr"
15026items in addresses are stripped. For example, <<xxx@a.b.c.d>> is treated as
15027<xxx@a.b.c.d>. If this is in the envelope and the message is passed on to
15028another MTA, the excess angle brackets are not passed on. If this option is not
15029set, multiple pairs of angle brackets cause a syntax error.
15030
15031+------------------+---------+-------------+--------------+
15032|strip_trailing_dot|Use: main|Type: boolean|Default: false|
15033+------------------+---------+-------------+--------------+
15034
15035If this option is set, a trailing dot at the end of a domain in an address is
15036ignored. If this is in the envelope and the message is passed on to another
15037MTA, the dot is not passed on. If this option is not set, a dot at the end of a
15038domain causes a syntax error. However, addresses in header lines are checked
15039only when an ACL requests header syntax checking.
15040
15041+------------------+---------+-------------+-------------+
15042|syslog_duplication|Use: main|Type: boolean|Default: true|
15043+------------------+---------+-------------+-------------+
15044
15045When Exim is logging to syslog, it writes the log lines for its three separate
15046logs at different syslog priorities so that they can in principle be separated
15047on the logging hosts. Some installations do not require this separation, and in
15048those cases, the duplication of certain log lines is a nuisance. If
15049syslog_duplication is set false, only one copy of any particular log line is
15050written to syslog. For lines that normally go to both the main log and the
15051reject log, the reject log version (possibly containing message header lines)
15052is written, at LOG_NOTICE priority. Lines that normally go to both the main and
15053the panic log are written at the LOG_ALERT priority.
15054
15055+---------------+---------+------------+--------------+
15056|syslog_facility|Use: main|Type: string|Default: unset|
15057+---------------+---------+------------+--------------+
15058
15059This option sets the syslog "facility" name, used when Exim is logging to
15060syslog. The value must be one of the strings "mail", "user", "news", "uucp",
15061"daemon", or "localx" where x is a digit between 0 and 7. If this option is
15062unset, "mail" is used. See chapter 51 for details of Exim's logging.
15063
15064+------------------+---------+------------+---------------+
15065|syslog_processname|Use: main|Type: string|Default: "exim"|
15066+------------------+---------+------------+---------------+
15067
15068This option sets the syslog "ident" name, used when Exim is logging to syslog.
15069The value must be no longer than 32 characters. See chapter 51 for details of
15070Exim's logging.
15071
15072+----------------+---------+-------------+-------------+
15073|syslog_timestamp|Use: main|Type: boolean|Default: true|
15074+----------------+---------+-------------+-------------+
15075
15076If syslog_timestamp is set false, the timestamps on Exim's log lines are
15077omitted when these lines are sent to syslog. See chapter 51 for details of
15078Exim's logging.
15079
15080+-------------+---------+-------------+--------------+
15081|system_filter|Use: main|Type: string*|Default: unset|
15082+-------------+---------+-------------+--------------+
15083
15084This option specifies an Exim filter file that is applied to all messages at
15085the start of each delivery attempt, before any routing is done. System filters
15086must be Exim filters; they cannot be Sieve filters. If the system filter
15087generates any deliveries to files or pipes, or any new mail messages, the
15088appropriate system_filter_..._transport option(s) must be set, to define which
15089transports are to be used. Details of this facility are given in chapter 45.
15090
15091+---------------------------------+---------+-------------+--------------+
15092|system_filter_directory_transport|Use: main|Type: string*|Default: unset|
15093+---------------------------------+---------+-------------+--------------+
15094
15095This sets the name of the transport driver that is to be used when the save
15096command in a system message filter specifies a path ending in "/", implying
15097delivery of each message into a separate file in some directory. During the
15098delivery, the variable $address_file contains the path name.
15099
15100+----------------------------+---------+-------------+--------------+
15101|system_filter_file_transport|Use: main|Type: string*|Default: unset|
15102+----------------------------+---------+-------------+--------------+
15103
15104This sets the name of the transport driver that is to be used when the save
15105command in a system message filter specifies a path not ending in "/". During
15106the delivery, the variable $address_file contains the path name.
15107
15108+-------------------+---------+------------+--------------+
15109|system_filter_group|Use: main|Type: string|Default: unset|
15110+-------------------+---------+------------+--------------+
15111
15112This option is used only when system_filter_user is also set. It sets the gid
15113under which the system filter is run, overriding any gid that is associated
15114with the user. The value may be numerical or symbolic.
15115
15116+----------------------------+---------+-------------+--------------+
15117|system_filter_pipe_transport|Use: main|Type: string*|Default: unset|
15118+----------------------------+---------+-------------+--------------+
15119
15120This specifies the transport driver that is to be used when a pipe command is
15121used in a system filter. During the delivery, the variable $address_pipe
15122contains the pipe command.
15123
15124+-----------------------------+---------+-------------+--------------+
15125|system_filter_reply_transport|Use: main|Type: string*|Default: unset|
15126+-----------------------------+---------+-------------+--------------+
15127
15128This specifies the transport driver that is to be used when a mail command is
15129used in a system filter.
15130
15131+------------------+---------+------------+--------------+
15132|system_filter_user|Use: main|Type: string|Default: unset|
15133+------------------+---------+------------+--------------+
15134
15135If this option is set to root, the system filter is run in the main Exim
15136delivery process, as root. Otherwise, the system filter runs in a separate
15137process, as the given user, defaulting to the Exim run-time user. Unless the
15138string consists entirely of digits, it is looked up in the password data.
15139Failure to find the named user causes a configuration error. The gid is either
15140taken from the password data, or specified by system_filter_group. When the uid
15141is specified numerically, system_filter_group is required to be set.
15142
15143If the system filter generates any pipe, file, or reply deliveries, the uid
15144under which the filter is run is used when transporting them, unless a
15145transport option overrides.
15146
15147+-----------+---------+-------------+-------------+
15148|tcp_nodelay|Use: main|Type: boolean|Default: true|
15149+-----------+---------+-------------+-------------+
15150
15151If this option is set false, it stops the Exim daemon setting the TCP_NODELAY
15152option on its listening sockets. Setting TCP_NODELAY turns off the "Nagle
15153algorithm", which is a way of improving network performance in interactive
15154(character-by-character) situations. Turning it off should improve Exim's
15155performance a bit, so that is what happens by default. However, it appears that
15156some broken clients cannot cope, and time out. Hence this option. It affects
15157only those sockets that are set up for listening by the daemon. Sockets created
15158by the smtp transport for delivering mail always set TCP_NODELAY.
15159
15160+--------------------+---------+----------+-----------+
15161|timeout_frozen_after|Use: main|Type: time|Default: 0s|
15162+--------------------+---------+----------+-----------+
15163
15164If timeout_frozen_after is set to a time greater than zero, a frozen message of
15165any kind that has been on the queue for longer than the given time is
15166automatically cancelled at the next queue run. If the frozen message is a
15167bounce message, it is just discarded; otherwise, a bounce is sent to the
15168sender, in a similar manner to cancellation by the -Mg command line option. If
15169you want to timeout frozen bounce messages earlier than other kinds of frozen
15170message, see ignore_bounce_errors_after.
15171
15172Note: the default value of zero means no timeouts; with this setting, frozen
15173messages remain on the queue forever (except for any frozen bounce messages
15174that are released by ignore_bounce_errors_after).
15175
15176+--------+---------+------------+--------------+
15177|timezone|Use: main|Type: string|Default: unset|
15178+--------+---------+------------+--------------+
15179
15180The value of timezone is used to set the environment variable TZ while running
15181Exim (if it is different on entry). This ensures that all timestamps created by
15182Exim are in the required timezone. If you want all your timestamps to be in UTC
15183(aka GMT) you should set
15184
15185timezone = UTC
15186
15187The default value is taken from TIMEZONE_DEFAULT in Local/Makefile, or, if that
15188is not set, from the value of the TZ environment variable when Exim is built.
15189If timezone is set to the empty string, either at build or run time, any
15190existing TZ variable is removed from the environment when Exim runs. This is
15191appropriate behaviour for obtaining wall-clock time on some, but unfortunately
15192not all, operating systems.
15193
15194+-------------------+---------+----------------+--------------+
15195|tls_advertise_hosts|Use: main|Type: host list*|Default: unset|
15196+-------------------+---------+----------------+--------------+
15197
15198When Exim is built with support for TLS encrypted connections, the availability
15199of the STARTTLS command to set up an encrypted session is advertised in
15200response to EHLO only to those client hosts that match this option. See chapter
1520141 for details of Exim's support for TLS.
15202
15203+---------------+---------+-------------+--------------+
15204|tls_certificate|Use: main|Type: string*|Default: unset|
15205+---------------+---------+-------------+--------------+
15206
15207The value of this option is expanded, and must then be the absolute path to a
15208file which contains the server's certificates. The server's private key is also
15209assumed to be in this file if tls_privatekey is unset. See chapter 41 for
15210further details.
15211
15212Note: The certificates defined by this option are used only when Exim is
15213receiving incoming messages as a server. If you want to supply certificates for
15214use when sending messages as a client, you must set the tls_certificate option
15215in the relevant smtp transport.
15216
15217If the option contains $tls_out_sni and Exim is built against OpenSSL, then if
15218the OpenSSL build supports TLS extensions and the TLS client sends the Server
15219Name Indication extension, then this option and others documented in 41.10 will
15220be re-expanded.
15221
15222+-------+---------+-------------+--------------+
15223|tls_crl|Use: main|Type: string*|Default: unset|
15224+-------+---------+-------------+--------------+
15225
15226This option specifies a certificate revocation list. The expanded value must be
15227the name of a file that contains a CRL in PEM format.
15228
15229See 41.10 for discussion of when this option might be re-expanded.
15230
15231+---------------+---------+-------------+-------------+
15232|tls_dh_max_bits|Use: main|Type: integer|Default: 2236|
15233+---------------+---------+-------------+-------------+
15234
15235The number of bits used for Diffie-Hellman key-exchange may be suggested by the
15236chosen TLS library. That value might prove to be too high for interoperability.
15237This option provides a maximum clamp on the value suggested, trading off
15238security for interoperability.
15239
15240The value must be at least 1024.
15241
15242The value 2236 was chosen because, at time of adding the option, it was the
15243hard-coded maximum value supported by the NSS cryptographic library, as used by
15244Thunderbird, while GnuTLS was suggesting 2432 bits as normal.
15245
15246If you prefer more security and are willing to break some clients, raise this
15247number.
15248
15249Note that the value passed to GnuTLS for *generating* a new prime may be a
15250little less than this figure, because GnuTLS is inexact and may produce a
15251larger prime than requested.
15252
15253+-----------+---------+-------------+--------------+
15254|tls_dhparam|Use: main|Type: string*|Default: unset|
15255+-----------+---------+-------------+--------------+
15256
15257The value of this option is expanded and indicates the source of DH parameters
15258to be used by Exim.
15259
15260If it is a filename starting with a "/", then it names a file from which DH
15261parameters should be loaded. If the file exists, it should hold a PEM-encoded
15262PKCS#3 representation of the DH prime. If the file does not exist, for OpenSSL
15263it is an error. For GnuTLS, Exim will attempt to create the file and fill it
15264with a generated DH prime. For OpenSSL, if the DH bit-count from loading the
15265file is greater than tls_dh_max_bits then it will be ignored, and treated as
15266though the tls_dhparam were set to "none".
15267
15268If this option expands to the string "none", then no DH parameters will be
15269loaded by Exim.
15270
15271If this option expands to the string "historic" and Exim is using GnuTLS, then
15272Exim will attempt to load a file from inside the spool directory. If the file
15273does not exist, Exim will attempt to create it. See section 41.3 for further
15274details.
15275
15276If Exim is using OpenSSL and this option is empty or unset, then Exim will load
15277a default DH prime; the default is the 2048 bit prime described in section 2.2
15278of RFC 5114, "2048-bit MODP Group with 224-bit Prime Order Subgroup", which in
15279IKE is assigned number 23.
15280
15281Otherwise, the option must expand to the name used by Exim for any of a number
15282of DH primes specified in RFC 2409, RFC 3526 and RFC 5114. As names, Exim uses
15283"ike" followed by the number used by IKE, of "default" which corresponds to
15284"ike23".
15285
15286The available primes are: "ike1", "ike2", "ike5", "ike14", "ike15", "ike16",
15287"ike17", "ike18", "ike22", "ike23" (aka "default") and "ike24".
15288
15289Some of these will be too small to be accepted by clients. Some may be too
15290large to be accepted by clients.
15291
15292The TLS protocol does not negotiate an acceptable size for this; clients tend
15293to hard-drop connections if what is offered by the server is unacceptable,
15294whether too large or too small, and there's no provision for the client to tell
15295the server what these constraints are. Thus, as a server operator, you need to
15296make an educated guess as to what is most likely to work for your userbase.
15297
15298Some known size constraints suggest that a bit-size in the range 2048 to 2236
15299is most likely to maximise interoperability. The upper bound comes from
15300applications using the Mozilla Network Security Services (NSS) library, which
15301used to set its "DH_MAX_P_BITS" upper-bound to 2236. This affects many mail
15302user agents (MUAs). The lower bound comes from Debian installs of Exim4 prior
15303to the 4.80 release, as Debian used to patch Exim to raise the minimum
15304acceptable bound from 1024 to 2048.
15305
15306+-------------+---------+-------------+--------------+
15307|tls_ocsp_file|Use: main|Type: string*|Default: unset|
15308+-------------+---------+-------------+--------------+
15309
15310This option must if set expand to the absolute path to a file which contains a
15311current status proof for the server's certificate, as obtained from the
15312Certificate Authority.
15313
15314+--------------------+---------+-----------------+--------------+
15315|tls_on_connect_ports|Use: main|Type: string list|Default: unset|
15316+--------------------+---------+-----------------+--------------+
15317
15318This option specifies a list of incoming SSMTP (aka SMTPS) ports that should
15319operate the obsolete SSMTP (SMTPS) protocol, where a TLS session is immediately
15320set up without waiting for the client to issue a STARTTLS command. For further
15321details, see section 13.4.
15322
15323+--------------+---------+-------------+--------------+
15324|tls_privatekey|Use: main|Type: string*|Default: unset|
15325+--------------+---------+-------------+--------------+
15326
15327The value of this option is expanded, and must then be the absolute path to a
15328file which contains the server's private key. If this option is unset, or if
15329the expansion is forced to fail, or the result is an empty string, the private
15330key is assumed to be in the same file as the server's certificates. See chapter
1533141 for further details.
15332
15333See 41.10 for discussion of when this option might be re-expanded.
15334
15335+------------------+---------+-------------+--------------+
15336|tls_remember_esmtp|Use: main|Type: boolean|Default: false|
15337+------------------+---------+-------------+--------------+
15338
15339If this option is set true, Exim violates the RFCs by remembering that it is in
15340"esmtp" state after successfully negotiating a TLS session. This provides
15341support for broken clients that fail to send a new EHLO after starting a TLS
15342session.
15343
15344+-------------------+---------+-------------+--------------+
15345|tls_require_ciphers|Use: main|Type: string*|Default: unset|
15346+-------------------+---------+-------------+--------------+
15347
15348This option controls which ciphers can be used for incoming TLS connections.
15349The smtp transport has an option of the same name for controlling outgoing
15350connections. This option is expanded for each connection, so can be varied for
15351different clients if required. The value of this option must be a list of
15352permitted cipher suites. The OpenSSL and GnuTLS libraries handle cipher control
15353in somewhat different ways. If GnuTLS is being used, the client controls the
15354preference order of the available ciphers. Details are given in sections 41.4
15355and 41.5.
15356
15357+--------------------+---------+----------------+--------------+
15358|tls_try_verify_hosts|Use: main|Type: host list*|Default: unset|
15359+--------------------+---------+----------------+--------------+
15360
15361See tls_verify_hosts below.
15362
15363+-----------------------+---------+-------------+--------------+
15364|tls_verify_certificates|Use: main|Type: string*|Default: unset|
15365+-----------------------+---------+-------------+--------------+
15366
15367The value of this option is expanded, and must then be the absolute path to a
15368file containing permitted certificates for clients that match tls_verify_hosts
15369or tls_try_verify_hosts. Alternatively, if you are using OpenSSL, you can set
15370tls_verify_certificates to the name of a directory containing certificate
15371files. This does not work with GnuTLS; the option must be set to the name of a
15372single file if you are using GnuTLS.
15373
15374These certificates should be for the certificate authorities trusted, rather
15375than the public cert of individual clients. With both OpenSSL and GnuTLS, if
15376the value is a file then the certificates are sent by Exim as a server to
15377connecting clients, defining the list of accepted certificate authorities. Thus
15378the values defined should be considered public data. To avoid this, use OpenSSL
15379with a directory.
15380
15381See 41.10 for discussion of when this option might be re-expanded.
15382
15383A forced expansion failure or setting to an empty string is equivalent to being
15384unset.
15385
15386+----------------+---------+----------------+--------------+
15387|tls_verify_hosts|Use: main|Type: host list*|Default: unset|
15388+----------------+---------+----------------+--------------+
15389
15390This option, along with tls_try_verify_hosts, controls the checking of
15391certificates from clients. The expected certificates are defined by
15392tls_verify_certificates, which must be set. A configuration error occurs if
15393either tls_verify_hosts or tls_try_verify_hosts is set and
15394tls_verify_certificates is not set.
15395
15396Any client that matches tls_verify_hosts is constrained by
15397tls_verify_certificates. When the client initiates a TLS session, it must
15398present one of the listed certificates. If it does not, the connection is
15399aborted. Warning: Including a host in tls_verify_hosts does not require the
15400host to use TLS. It can still send SMTP commands through unencrypted
15401connections. Forcing a client to use TLS has to be done separately using an ACL
15402to reject inappropriate commands when the connection is not encrypted.
15403
15404A weaker form of checking is provided by tls_try_verify_hosts. If a client
15405matches this option (but not tls_verify_hosts), Exim requests a certificate and
15406checks it against tls_verify_certificates, but does not abort the connection if
15407there is no certificate or if it does not match. This state can be detected in
15408an ACL, which makes it possible to implement policies such as "accept for relay
15409only if a verified certificate has been received, but accept for local delivery
15410if encrypted, even without a verified certificate".
15411
15412Client hosts that match neither of these lists are not asked to present
15413certificates.
15414
15415+--------------+---------+------------------+--------------+
15416|trusted_groups|Use: main|Type: string list*|Default: unset|
15417+--------------+---------+------------------+--------------+
15418
15419This option is expanded just once, at the start of Exim's processing. If this
15420option is set, any process that is running in one of the listed groups, or
15421which has one of them as a supplementary group, is trusted. The groups can be
15422specified numerically or by name. See section 5.2 for details of what trusted
15423callers are permitted to do. If neither trusted_groups nor trusted_users is
15424set, only root and the Exim user are trusted.
15425
15426+-------------+---------+------------------+--------------+
15427|trusted_users|Use: main|Type: string list*|Default: unset|
15428+-------------+---------+------------------+--------------+
15429
15430This option is expanded just once, at the start of Exim's processing. If this
15431option is set, any process that is running as one of the listed users is
15432trusted. The users can be specified numerically or by name. See section 5.2 for
15433details of what trusted callers are permitted to do. If neither trusted_groups
15434nor trusted_users is set, only root and the Exim user are trusted.
15435
15436+-------------+---------+-------------+--------------+
15437|unknown_login|Use: main|Type: string*|Default: unset|
15438+-------------+---------+-------------+--------------+
15439
15440This is a specialized feature for use in unusual configurations. By default, if
15441the uid of the caller of Exim cannot be looked up using getpwuid(), Exim gives
15442up. The unknown_login option can be used to set a login name to be used in this
15443circumstance. It is expanded, so values like user$caller_uid can be set. When
15444unknown_login is used, the value of unknown_username is used for the user's
15445real name (gecos field), unless this has been set by the -F option.
15446
15447+----------------+---------+------------+--------------+
15448|unknown_username|Use: main|Type: string|Default: unset|
15449+----------------+---------+------------+--------------+
15450
15451See unknown_login.
15452
15453+--------------------+---------+-------------------+--------------+
15454|untrusted_set_sender|Use: main|Type: address list*|Default: unset|
15455+--------------------+---------+-------------------+--------------+
15456
15457When an untrusted user submits a message to Exim using the standard input, Exim
15458normally creates an envelope sender address from the user's login and the
15459default qualification domain. Data from the -f option (for setting envelope
15460senders on non-SMTP messages) or the SMTP MAIL command (if -bs or -bS is used)
15461is ignored.
15462
15463However, untrusted users are permitted to set an empty envelope sender address,
15464to declare that a message should never generate any bounces. For example:
15465
15466exim -f '<>' user@domain.example
15467
15468The untrusted_set_sender option allows you to permit untrusted users to set
15469other envelope sender addresses in a controlled way. When it is set, untrusted
15470users are allowed to set envelope sender addresses that match any of the
15471patterns in the list. Like all address lists, the string is expanded. The
15472identity of the user is in $sender_ident, so you can, for example, restrict
15473users to setting senders that start with their login ids followed by a hyphen
15474by a setting like this:
15475
15476untrusted_set_sender = ^$sender_ident-
15477
15478If you want to allow untrusted users to set envelope sender addresses without
15479restriction, you can use
15480
15481untrusted_set_sender = *
15482
15483The untrusted_set_sender option applies to all forms of local input, but only
15484to the setting of the envelope sender. It does not permit untrusted users to
15485use the other options which trusted user can use to override message
15486parameters. Furthermore, it does not stop Exim from removing an existing
15487Sender: header in the message, or from adding a Sender: header if necessary.
15488See local_sender_retain and local_from_check for ways of overriding these
15489actions. The handling of the Sender: header is also described in section 46.16.
15490
15491The log line for a message's arrival shows the envelope sender following "<=".
15492For local messages, the user's login always follows, after "U=". In -bp
15493displays, and in the Exim monitor, if an untrusted user sets an envelope sender
15494address, the user's login is shown in parentheses after the sender address.
15495
15496+-----------------+---------+------------+------------------+
15497|uucp_from_pattern|Use: main|Type: string|Default: see below|
15498+-----------------+---------+------------+------------------+
15499
15500Some applications that pass messages to an MTA via a command line interface use
15501an initial line starting with "From " to pass the envelope sender. In
15502particular, this is used by UUCP software. Exim recognizes such a line by means
15503of a regular expression that is set in uucp_from_pattern. When the pattern
15504matches, the sender address is constructed by expanding the contents of
15505uucp_from_sender, provided that the caller of Exim is a trusted user. The
15506default pattern recognizes lines in the following two forms:
15507
15508From ph10 Fri Jan 5 12:35 GMT 1996
15509From ph10 Fri, 7 Jan 97 14:00:00 GMT
15510
15511The pattern can be seen by running
15512
15513exim -bP uucp_from_pattern
15514
15515It checks only up to the hours and minutes, and allows for a 2-digit or 4-digit
15516year in the second case. The first word after "From " is matched in the regular
15517expression by a parenthesized subpattern. The default value for
15518uucp_from_sender is "$1", which therefore just uses this first word ("ph10" in
15519the example above) as the message's sender. See also ignore_fromline_hosts.
15520
15521+----------------+---------+-------------+-------------+
15522|uucp_from_sender|Use: main|Type: string*|Default: "$1"|
15523+----------------+---------+-------------+-------------+
15524
15525See uucp_from_pattern above.
15526
15527+-----------------+---------+------------+--------------+
15528|warn_message_file|Use: main|Type: string|Default: unset|
15529+-----------------+---------+------------+--------------+
15530
15531This option defines a template file containing paragraphs of text to be used
15532for constructing the warning message which is sent by Exim when a message has
15533been on the queue for a specified amount of time, as specified by delay_warning
15534. Details of the file's contents are given in chapter 48. See also
15535bounce_message_file.
15536
15537+---------------+---------+-------------+-------------+
15538|write_rejectlog|Use: main|Type: boolean|Default: true|
15539+---------------+---------+-------------+-------------+
15540
15541If this option is set false, Exim no longer writes anything to the reject log.
15542See chapter 51 for details of what Exim writes to its logs.
15543
15544
15545
15546===============================================================================
1554715. GENERIC OPTIONS FOR ROUTERS
15548
15549This chapter describes the generic options that apply to all routers. Those
15550that are preconditions are marked with ** in the "use" field.
15551
15552For a general description of how a router operates, see sections 3.10 and 3.12.
15553The latter specifies the order in which the preconditions are tested. The order
15554of expansion of the options that provide data for a transport is: errors_to,
15555headers_add, headers_remove, transport.
15556
15557+------------+------------+-------------+--------------+
15558|address_data|Use: routers|Type: string*|Default: unset|
15559+------------+------------+-------------+--------------+
15560
15561The string is expanded just before the router is run, that is, after all the
15562precondition tests have succeeded. If the expansion is forced to fail, the
15563router declines, the value of address_data remains unchanged, and the more
15564option controls what happens next. Other expansion failures cause delivery of
15565the address to be deferred.
15566
15567When the expansion succeeds, the value is retained with the address, and can be
15568accessed using the variable $address_data in the current router, subsequent
15569routers, and the eventual transport.
15570
15571Warning: If the current or any subsequent router is a redirect router that runs
15572a user's filter file, the contents of $address_data are accessible in the
15573filter. This is not normally a problem, because such data is usually either not
15574confidential or it "belongs" to the current user, but if you do put
15575confidential data into $address_data you need to remember this point.
15576
15577Even if the router declines or passes, the value of $address_data remains with
15578the address, though it can be changed by another address_data setting on a
15579subsequent router. If a router generates child addresses, the value of
15580$address_data propagates to them. This also applies to the special kind of
15581"child" that is generated by a router with the unseen option.
15582
15583The idea of address_data is that you can use it to look up a lot of data for
15584the address once, and then pick out parts of the data later. For example, you
15585could use a single LDAP lookup to return a string of the form
15586
15587uid=1234 gid=5678 mailbox=/mail/xyz forward=/home/xyz/.forward
15588
15589In the transport you could pick out the mailbox by a setting such as
15590
15591file = ${extract{mailbox}{$address_data}}
15592
15593This makes the configuration file less messy, and also reduces the number of
15594lookups (though Exim does cache lookups).
15595
15596The address_data facility is also useful as a means of passing information from
15597one router to another, and from a router to a transport. In addition, if
15598$address_data is set by a router when verifying a recipient address from an
15599ACL, it remains available for use in the rest of the ACL statement. After
15600verifying a sender, the value is transferred to $sender_address_data.
15601
15602+------------+--------------+-------------+-------------+
15603|address_test|Use: routers**|Type: boolean|Default: true|
15604+------------+--------------+-------------+-------------+
15605
15606If this option is set false, the router is skipped when routing is being tested
15607by means of the -bt command line option. This can be a convenience when your
15608first router sends messages to an external scanner, because it saves you having
15609to set the "already scanned" indicator when testing real address routing.
15610
15611+--------------------+------------+-------------+--------------+
15612|cannot_route_message|Use: routers|Type: string*|Default: unset|
15613+--------------------+------------+-------------+--------------+
15614
15615This option specifies a text message that is used when an address cannot be
15616routed because Exim has run out of routers. The default message is "Unrouteable
15617address". This option is useful only on routers that have more set false, or on
15618the very last router in a configuration, because the value that is used is
15619taken from the last router that is considered. This includes a router that is
15620skipped because its preconditions are not met, as well as a router that
15621declines. For example, using the default configuration, you could put:
15622
15623cannot_route_message = Remote domain not found in DNS
15624
15625on the first router, which is a dnslookup router with more set false, and
15626
15627cannot_route_message = Unknown local user
15628
15629on the final router that checks for local users. If string expansion fails for
15630this option, the default message is used. Unless the expansion failure was
15631explicitly forced, a message about the failure is written to the main and panic
15632logs, in addition to the normal message about the routing failure.
15633
15634+------------------+------------+-------------+--------------+
15635|caseful_local_part|Use: routers|Type: boolean|Default: false|
15636+------------------+------------+-------------+--------------+
15637
15638By default, routers handle the local parts of addresses in a case-insensitive
15639manner, though the actual case is preserved for transmission with the message.
15640If you want the case of letters to be significant in a router, you must set
15641this option true. For individual router options that contain address or local
15642part lists (for example, local_parts), case-sensitive matching can be turned on
15643by "+caseful" as a list item. See section 10.20 for more details.
15644
15645The value of the $local_part variable is forced to lower case while a router is
15646running unless caseful_local_part is set. When a router assigns an address to a
15647transport, the value of $local_part when the transport runs is the same as it
15648was in the router. Similarly, when a router generates child addresses by
15649aliasing or forwarding, the values of $original_local_part and
15650$parent_local_part are those that were used by the redirecting router.
15651
15652This option applies to the processing of an address by a router. When a
15653recipient address is being processed in an ACL, there is a separate control
15654modifier that can be used to specify case-sensitive processing within the ACL
15655(see section 42.22).
15656
15657+----------------+--------------+-------------+--------------+
15658|check_local_user|Use: routers**|Type: boolean|Default: false|
15659+----------------+--------------+-------------+--------------+
15660
15661When this option is true, Exim checks that the local part of the recipient
15662address (with affixes removed if relevant) is the name of an account on the
15663local system. The check is done by calling the getpwnam() function rather than
15664trying to read /etc/passwd directly. This means that other methods of holding
15665password data (such as NIS) are supported. If the local part is a local user,
15666$home is set from the password data, and can be tested in other preconditions
15667that are evaluated after this one (the order of evaluation is given in section
156683.12). However, the value of $home can be overridden by router_home_directory.
15669If the local part is not a local user, the router is skipped.
15670
15671If you want to check that the local part is either the name of a local user or
15672matches something else, you cannot combine check_local_user with a setting of
15673local_parts, because that specifies the logical and of the two conditions.
15674However, you can use a passwd lookup in a local_parts setting to achieve this.
15675For example:
15676
15677local_parts = passwd;$local_part : lsearch;/etc/other/users
15678
15679Note, however, that the side effects of check_local_user (such as setting up a
15680home directory) do not occur when a passwd lookup is used in a local_parts (or
15681any other) precondition.
15682
15683+---------+--------------+-------------+--------------+
15684|condition|Use: routers**|Type: string*|Default: unset|
15685+---------+--------------+-------------+--------------+
15686
15687This option specifies a general precondition test that has to succeed for the
15688router to be called. The condition option is the last precondition to be
15689evaluated (see section 3.12). The string is expanded, and if the result is a
15690forced failure, or an empty string, or one of the strings "0" or "no" or
15691"false" (checked without regard to the case of the letters), the router is
15692skipped, and the address is offered to the next one.
15693
15694If the result is any other value, the router is run (as this is the last
15695precondition to be evaluated, all the other preconditions must be true).
15696
15697This option is unusual in that multiple condition options may be present. All
15698condition options must succeed.
15699
15700The condition option provides a means of applying custom conditions to the
15701running of routers. Note that in the case of a simple conditional expansion,
15702the default expansion values are exactly what is wanted. For example:
15703
15704condition = ${if >{$message_age}{600}}
15705
15706Because of the default behaviour of the string expansion, this is equivalent to
15707
15708condition = ${if >{$message_age}{600}{true}{}}
15709
15710A multiple condition example, which succeeds:
15711
15712condition = ${if >{$message_age}{600}}
15713condition = ${if !eq{${lc:$local_part}}{postmaster}}
15714condition = foobar
15715
15716If the expansion fails (other than forced failure) delivery is deferred. Some
15717of the other precondition options are common special cases that could in fact
15718be specified using condition.
15719
15720+-----------+------------+-------------+--------------+
15721|debug_print|Use: routers|Type: string*|Default: unset|
15722+-----------+------------+-------------+--------------+
15723
15724If this option is set and debugging is enabled (see the -d command line option)
15725or in address-testing mode (see the -bt command line option), the string is
15726expanded and included in the debugging output. If expansion of the string
15727fails, the error message is written to the debugging output, and Exim carries
15728on processing. This option is provided to help with checking out the values of
15729variables and so on when debugging router configurations. For example, if a
15730condition option appears not to be working, debug_print can be used to output
15731the variables it references. The output happens after checks for domains,
15732local_parts, and check_local_user but before any other preconditions are
15733tested. A newline is added to the text if it does not end with one. The
15734variable $router_name contains the name of the router.
15735
15736+---------------+------------+-------------+--------------+
15737|disable_logging|Use: routers|Type: boolean|Default: false|
15738+---------------+------------+-------------+--------------+
15739
15740If this option is set true, nothing is logged for any routing errors or for any
15741deliveries caused by this router. You should not set this option unless you
15742really, really know what you are doing. See also the generic transport option
15743of the same name.
15744
15745+-------+--------------+------------------+--------------+
15746|domains|Use: routers**|Type: domain list*|Default: unset|
15747+-------+--------------+------------------+--------------+
15748
15749If this option is set, the router is skipped unless the current domain matches
15750the list. If the match is achieved by means of a file lookup, the data that the
15751lookup returned for the domain is placed in $domain_data for use in string
15752expansions of the driver's private options. See section 3.12 for a list of the
15753order in which preconditions are evaluated.
15754
15755+------+------------+------------+--------------+
15756|driver|Use: routers|Type: string|Default: unset|
15757+------+------------+------------+--------------+
15758
15759This option must always be set. It specifies which of the available routers is
15760to be used.
15761
15762+---------+------------+-------------+--------------+
15763|errors_to|Use: routers|Type: string*|Default: unset|
15764+---------+------------+-------------+--------------+
15765
15766If a router successfully handles an address, it may assign the address to a
15767transport for delivery or it may generate child addresses. In both cases, if
15768there is a delivery problem during later processing, the resulting bounce
15769message is sent to the address that results from expanding this string,
15770provided that the address verifies successfully. The errors_to option is
15771expanded before headers_add, headers_remove, and transport.
15772
15773The errors_to setting associated with an address can be overridden if it
15774subsequently passes through other routers that have their own errors_to
15775settings, or if the message is delivered by a transport with a return_path
15776setting.
15777
15778If errors_to is unset, or the expansion is forced to fail, or the result of the
15779expansion fails to verify, the errors address associated with the incoming
15780address is used. At top level, this is the envelope sender. A non-forced
15781expansion failure causes delivery to be deferred.
15782
15783If an address for which errors_to has been set ends up being delivered over
15784SMTP, the envelope sender for that delivery is the errors_to value, so that any
15785bounces that are generated by other MTAs on the delivery route are also sent
15786there. You can set errors_to to the empty string by either of these settings:
15787
15788errors_to =
15789errors_to = ""
15790
15791An expansion item that yields an empty string has the same effect. If you do
15792this, a locally detected delivery error for addresses processed by this router
15793no longer gives rise to a bounce message; the error is discarded. If the
15794address is delivered to a remote host, the return path is set to "<>", unless
15795overridden by the return_path option on the transport.
15796
15797If for some reason you want to discard local errors, but use a non-empty MAIL
15798command for remote delivery, you can preserve the original return path in
15799$address_data in the router, and reinstate it in the transport by setting
15800return_path.
15801
15802The most common use of errors_to is to direct mailing list bounces to the
15803manager of the list, as described in section 49.2, or to implement VERP
15804(Variable Envelope Return Paths) (see section 49.6).
15805
15806+----+--------------+-------------+-------------+
15807|expn|Use: routers**|Type: boolean|Default: true|
15808+----+--------------+-------------+-------------+
15809
15810If this option is turned off, the router is skipped when testing an address as
15811a result of processing an SMTP EXPN command. You might, for example, want to
15812turn it off on a router for users' .forward files, while leaving it on for the
15813system alias file. See section 3.12 for a list of the order in which
15814preconditions are evaluated.
15815
15816The use of the SMTP EXPN command is controlled by an ACL (see chapter 42). When
15817Exim is running an EXPN command, it is similar to testing an address with -bt.
15818Compare VRFY, whose counterpart is -bv.
15819
15820+-----------+------------+-------------+--------------+
15821|fail_verify|Use: routers|Type: boolean|Default: false|
15822+-----------+------------+-------------+--------------+
15823
15824Setting this option has the effect of setting both fail_verify_sender and
15825fail_verify_recipient to the same value.
15826
15827+---------------------+------------+-------------+--------------+
15828|fail_verify_recipient|Use: routers|Type: boolean|Default: false|
15829+---------------------+------------+-------------+--------------+
15830
15831If this option is true and an address is accepted by this router when verifying
15832a recipient, verification fails.
15833
15834+------------------+------------+-------------+--------------+
15835|fail_verify_sender|Use: routers|Type: boolean|Default: false|
15836+------------------+------------+-------------+--------------+
15837
15838If this option is true and an address is accepted by this router when verifying
15839a sender, verification fails.
15840
15841+--------------+------------+-----------------+--------------+
15842|fallback_hosts|Use: routers|Type: string list|Default: unset|
15843+--------------+------------+-----------------+--------------+
15844
15845String expansion is not applied to this option. The argument must be a
15846colon-separated list of host names or IP addresses. The list separator can be
15847changed (see section 6.19), and a port can be specified with each name or
15848address. In fact, the format of each item is exactly the same as defined for
15849the list of hosts in a manualroute router (see section 20.5).
15850
15851If a router queues an address for a remote transport, this host list is
15852associated with the address, and used instead of the transport's fallback host
15853list. If hosts_randomize is set on the transport, the order of the list is
15854randomized for each use. See the fallback_hosts option of the smtp transport
15855for further details.
15856
15857+-----+------------+-------------+------------------+
15858|group|Use: routers|Type: string*|Default: see below|
15859+-----+------------+-------------+------------------+
15860
15861When a router queues an address for a transport, and the transport does not
15862specify a group, the group given here is used when running the delivery
15863process. The group may be specified numerically or by name. If expansion fails,
15864the error is logged and delivery is deferred. The default is unset, unless
15865check_local_user is set, when the default is taken from the password
15866information. See also initgroups and user and the discussion in chapter 23.
15867
15868+-----------+------------+-----------+--------------+
15869|headers_add|Use: routers|Type: list*|Default: unset|
15870+-----------+------------+-----------+--------------+
15871
15872This option specifies a list of text headers, newline-separated, that is
15873associated with any addresses that are accepted by the router. Each item is
15874separately expanded, at routing time. However, this option has no effect when
15875an address is just being verified. The way in which the text is used to add
15876header lines at transport time is described in section 46.17. New header lines
15877are not actually added until the message is in the process of being
15878transported. This means that references to header lines in string expansions in
15879the transport's configuration do not "see" the added header lines.
15880
15881The headers_add option is expanded after errors_to, but before headers_remove
15882and transport. If an item is empty, or if an item expansion is forced to fail,
15883the item has no effect. Other expansion failures are treated as configuration
15884errors.
15885
15886Unlike most options, headers_add can be specified multiple times for a router;
15887all listed headers are added.
15888
15889Warning 1: The headers_add option cannot be used for a redirect router that has
15890the one_time option set.
15891
15892Warning 2: If the unseen option is set on the router, all header additions are
15893deleted when the address is passed on to subsequent routers. For a redirect
15894router, if a generated address is the same as the incoming address, this can
15895lead to duplicate addresses with different header modifications. Exim does not
15896do duplicate deliveries (except, in certain circumstances, to pipes -- see
15897section 22.7), but it is undefined which of the duplicates is discarded, so
15898this ambiguous situation should be avoided. The repeat_use option of the
15899redirect router may be of help.
15900
15901+--------------+------------+-----------+--------------+
15902|headers_remove|Use: routers|Type: list*|Default: unset|
15903+--------------+------------+-----------+--------------+
15904
15905This option specifies a list of text headers, colon-separated, that is
15906associated with any addresses that are accepted by the router. Each item is
15907separately expanded, at routing time. However, this option has no effect when
15908an address is just being verified. The way in which the text is used to remove
15909header lines at transport time is described in section 46.17. Header lines are
15910not actually removed until the message is in the process of being transported.
15911This means that references to header lines in string expansions in the
15912transport's configuration still "see" the original header lines.
15913
15914The headers_remove option is expanded after errors_to and headers_add, but
15915before transport. If an item expansion is forced to fail, the item has no
15916effect. Other expansion failures are treated as configuration errors.
15917
15918Unlike most options, headers_remove can be specified multiple times for a
15919router; all listed headers are removed.
15920
15921Warning 1: The headers_remove option cannot be used for a redirect router that
15922has the one_time option set.
15923
15924Warning 2: If the unseen option is set on the router, all header removal
15925requests are deleted when the address is passed on to subsequent routers, and
15926this can lead to problems with duplicates -- see the similar warning for
15927headers_add above.
15928
15929+-------------------+------------+----------------+--------------+
15930|ignore_target_hosts|Use: routers|Type: host list*|Default: unset|
15931+-------------------+------------+----------------+--------------+
15932
15933Although this option is a host list, it should normally contain IP address
15934entries rather than names. If any host that is looked up by the router has an
15935IP address that matches an item in this list, Exim behaves as if that IP
15936address did not exist. This option allows you to cope with rogue DNS entries
15937like
15938
15939remote.domain.example. A 127.0.0.1
15940
15941by setting
15942
15943ignore_target_hosts = 127.0.0.1
15944
15945on the relevant router. If all the hosts found by a dnslookup router are
15946discarded in this way, the router declines. In a conventional configuration, an
15947attempt to mail to such a domain would normally provoke the "unrouteable
15948domain" error, and an attempt to verify an address in the domain would fail.
15949Similarly, if ignore_target_hosts is set on an ipliteral router, the router
15950declines if presented with one of the listed addresses.
15951
15952You can use this option to disable the use of IPv4 or IPv6 for mail delivery by
15953means of the first or the second of the following settings, respectively:
15954
15955ignore_target_hosts = 0.0.0.0/0
15956ignore_target_hosts = <; 0::0/0
15957
15958The pattern in the first line matches all IPv4 addresses, whereas the pattern
15959in the second line matches all IPv6 addresses.
15960
15961This option may also be useful for ignoring link-local and site-local IPv6
15962addresses. Because, like all host lists, the value of ignore_target_hosts is
15963expanded before use as a list, it is possible to make it dependent on the
15964domain that is being routed.
15965
15966During its expansion, $host_address is set to the IP address that is being
15967checked.
15968
15969+----------+------------+-------------+--------------+
15970|initgroups|Use: routers|Type: boolean|Default: false|
15971+----------+------------+-------------+--------------+
15972
15973If the router queues an address for a transport, and this option is true, and
15974the uid supplied by the router is not overridden by the transport, the
15975initgroups() function is called when running the transport to ensure that any
15976additional groups associated with the uid are set up. See also group and user
15977and the discussion in chapter 23.
15978
15979+-----------------+--------------+-----------------+--------------+
15980|local_part_prefix|Use: routers**|Type: string list|Default: unset|
15981+-----------------+--------------+-----------------+--------------+
15982
15983If this option is set, the router is skipped unless the local part starts with
15984one of the given strings, or local_part_prefix_optional is true. See section
159853.12 for a list of the order in which preconditions are evaluated.
15986
15987The list is scanned from left to right, and the first prefix that matches is
15988used. A limited form of wildcard is available; if the prefix begins with an
15989asterisk, it matches the longest possible sequence of arbitrary characters at
15990the start of the local part. An asterisk should therefore always be followed by
15991some character that does not occur in normal local parts. Wildcarding can be
15992used to set up multiple user mailboxes, as described in section 49.8.
15993
15994During the testing of the local_parts option, and while the router is running,
15995the prefix is removed from the local part, and is available in the expansion
15996variable $local_part_prefix. When a message is being delivered, if the router
15997accepts the address, this remains true during subsequent delivery by a
15998transport. In particular, the local part that is transmitted in the RCPT
15999command for LMTP, SMTP, and BSMTP deliveries has the prefix removed by default.
16000This behaviour can be overridden by setting rcpt_include_affixes true on the
16001relevant transport.
16002
16003When an address is being verified, local_part_prefix affects only the behaviour
16004of the router. If the callout feature of verification is in use, this means
16005that the full address, including the prefix, will be used during the callout.
16006
16007The prefix facility is commonly used to handle local parts of the form
16008owner-something. Another common use is to support local parts of the form
16009real-username to bypass a user's .forward file - helpful when trying to tell a
16010user their forwarding is broken - by placing a router like this one immediately
16011before the router that handles .forward files:
16012
16013real_localuser:
16014 driver = accept
16015 local_part_prefix = real-
16016 check_local_user
16017 transport = local_delivery
16018
16019For security, it would probably be a good idea to restrict the use of this
16020router to locally-generated messages, using a condition such as this:
16021
16022 condition = ${if match {$sender_host_address}\
16023 {\N^(|127\.0\.0\.1)$\N}}
16024
16025If both local_part_prefix and local_part_suffix are set for a router, both
16026conditions must be met if not optional. Care must be taken if wildcards are
16027used in both a prefix and a suffix on the same router. Different separator
16028characters must be used to avoid ambiguity.
16029
16030+--------------------------+------------+-------------+--------------+
16031|local_part_prefix_optional|Use: routers|Type: boolean|Default: false|
16032+--------------------------+------------+-------------+--------------+
16033
16034See local_part_prefix above.
16035
16036+-----------------+--------------+-----------------+--------------+
16037|local_part_suffix|Use: routers**|Type: string list|Default: unset|
16038+-----------------+--------------+-----------------+--------------+
16039
16040This option operates in the same way as local_part_prefix, except that the
16041local part must end (rather than start) with the given string, the
16042local_part_suffix_optional option determines whether the suffix is mandatory,
16043and the wildcard * character, if present, must be the last character of the
16044suffix. This option facility is commonly used to handle local parts of the form
16045something-request and multiple user mailboxes of the form username-foo.
16046
16047+--------------------------+------------+-------------+--------------+
16048|local_part_suffix_optional|Use: routers|Type: boolean|Default: false|
16049+--------------------------+------------+-------------+--------------+
16050
16051See local_part_suffix above.
16052
16053+-----------+--------------+----------------------+--------------+
16054|local_parts|Use: routers**|Type: local part list*|Default: unset|
16055+-----------+--------------+----------------------+--------------+
16056
16057The router is run only if the local part of the address matches the list. See
16058section 3.12 for a list of the order in which preconditions are evaluated, and
16059section 10.21 for a discussion of local part lists. Because the string is
16060expanded, it is possible to make it depend on the domain, for example:
16061
16062local_parts = dbm;/usr/local/specials/$domain
16063
16064If the match is achieved by a lookup, the data that the lookup returned for the
16065local part is placed in the variable $local_part_data for use in expansions of
16066the router's private options. You might use this option, for example, if you
16067have a large number of local virtual domains, and you want to send all
16068postmaster mail to the same place without having to set up an alias in each
16069virtual domain:
16070
16071postmaster:
16072 driver = redirect
16073 local_parts = postmaster
16074 data = postmaster@real.domain.example
16075
16076+------------+------------+-------------+------------------+
16077|log_as_local|Use: routers|Type: boolean|Default: see below|
16078+------------+------------+-------------+------------------+
16079
16080Exim has two logging styles for delivery, the idea being to make local
16081deliveries stand out more visibly from remote ones. In the "local" style, the
16082recipient address is given just as the local part, without a domain. The use of
16083this style is controlled by this option. It defaults to true for the accept
16084router, and false for all the others. This option applies only when a router
16085assigns an address to a transport. It has no effect on routers that redirect
16086addresses.
16087
16088+----+------------+--------------+-------------+
16089|more|Use: routers|Type: boolean*|Default: true|
16090+----+------------+--------------+-------------+
16091
16092The result of string expansion for this option must be a valid boolean value,
16093that is, one of the strings "yes", "no", "true", or "false". Any other result
16094causes an error, and delivery is deferred. If the expansion is forced to fail,
16095the default value for the option (true) is used. Other failures cause delivery
16096to be deferred.
16097
16098If this option is set false, and the router declines to handle the address, no
16099further routers are tried, routing fails, and the address is bounced. However,
16100if the router explicitly passes an address to the following router by means of
16101the setting
16102
16103self = pass
16104
16105or otherwise, the setting of more is ignored. Also, the setting of more does
16106not affect the behaviour if one of the precondition tests fails. In that case,
16107the address is always passed to the next router.
16108
16109Note that address_data is not considered to be a precondition. If its expansion
16110is forced to fail, the router declines, and the value of more controls what
16111happens next.
16112
16113+---------------+------------+-------------+--------------+
16114|pass_on_timeout|Use: routers|Type: boolean|Default: false|
16115+---------------+------------+-------------+--------------+
16116
16117If a router times out during a host lookup, it normally causes deferral of the
16118address. If pass_on_timeout is set, the address is passed on to the next
16119router, overriding no_more. This may be helpful for systems that are
16120intermittently connected to the Internet, or those that want to pass to a smart
16121host any messages that cannot immediately be delivered.
16122
16123There are occasional other temporary errors that can occur while doing DNS
16124lookups. They are treated in the same way as a timeout, and this option applies
16125to all of them.
16126
16127+-----------+------------+------------+--------------+
16128|pass_router|Use: routers|Type: string|Default: unset|
16129+-----------+------------+------------+--------------+
16130
16131Routers that recognize the generic self option (dnslookup, ipliteral, and
16132manualroute) are able to return "pass", forcing routing to continue, and
16133overriding a false setting of more. When one of these routers returns "pass",
16134the address is normally handed on to the next router in sequence. This can be
16135changed by setting pass_router to the name of another router. However (unlike
16136redirect_router) the named router must be below the current router, to avoid
16137loops. Note that this option applies only to the special case of "pass". It
16138does not apply when a router returns "decline" because it cannot handle an
16139address.
16140
16141+---------------+------------+------------+--------------+
16142|redirect_router|Use: routers|Type: string|Default: unset|
16143+---------------+------------+------------+--------------+
16144
16145Sometimes an administrator knows that it is pointless to reprocess addresses
16146generated from alias or forward files with the same router again. For example,
16147if an alias file translates real names into login ids there is no point
16148searching the alias file a second time, especially if it is a large file.
16149
16150The redirect_router option can be set to the name of any router instance. It
16151causes the routing of any generated addresses to start at the named router
16152instead of at the first router. This option has no effect if the router in
16153which it is set does not generate new addresses.
16154
16155+-------------+--------------+------------------+--------------+
16156|require_files|Use: routers**|Type: string list*|Default: unset|
16157+-------------+--------------+------------------+--------------+
16158
16159This option provides a general mechanism for predicating the running of a
16160router on the existence or non-existence of certain files or directories.
16161Before running a router, as one of its precondition tests, Exim works its way
16162through the require_files list, expanding each item separately.
16163
16164Because the list is split before expansion, any colons in expansion items must
16165be doubled, or the facility for using a different list separator must be used.
16166If any expansion is forced to fail, the item is ignored. Other expansion
16167failures cause routing of the address to be deferred.
16168
16169If any expanded string is empty, it is ignored. Otherwise, except as described
16170below, each string must be a fully qualified file path, optionally preceded by
16171"!". The paths are passed to the stat() function to test for the existence of
16172the files or directories. The router is skipped if any paths not preceded by "!
16173" do not exist, or if any paths preceded by "!" do exist.
16174
16175If stat() cannot determine whether a file exists or not, delivery of the
16176message is deferred. This can happen when NFS-mounted filesystems are
16177unavailable.
16178
16179This option is checked after the domains, local_parts, and senders options, so
16180you cannot use it to check for the existence of a file in which to look up a
16181domain, local part, or sender. (See section 3.12 for a full list of the order
16182in which preconditions are evaluated.) However, as these options are all
16183expanded, you can use the exists expansion condition to make such tests. The
16184require_files option is intended for checking files that the router may be
16185going to use internally, or which are needed by a transport (for example
16186.procmailrc).
16187
16188During delivery, the stat() function is run as root, but there is a facility
16189for some checking of the accessibility of a file by another user. This is not a
16190proper permissions check, but just a "rough" check that operates as follows:
16191
16192If an item in a require_files list does not contain any forward slash
16193characters, it is taken to be the user (and optional group, separated by a
16194comma) to be checked for subsequent files in the list. If no group is specified
16195but the user is specified symbolically, the gid associated with the uid is
16196used. For example:
16197
16198require_files = mail:/some/file
16199require_files = $local_part:$home/.procmailrc
16200
16201If a user or group name in a require_files list does not exist, the
16202require_files condition fails.
16203
16204Exim performs the check by scanning along the components of the file path, and
16205checking the access for the given uid and gid. It checks for "x" access on
16206directories, and "r" access on the final file. Note that this means that file
16207access control lists, if the operating system has them, are ignored.
16208
16209Warning 1: When the router is being run to verify addresses for an incoming
16210SMTP message, Exim is not running as root, but under its own uid. This may
16211affect the result of a require_files check. In particular, stat() may yield the
16212error EACCES ("Permission denied"). This means that the Exim user is not
16213permitted to read one of the directories on the file's path.
16214
16215Warning 2: Even when Exim is running as root while delivering a message, stat()
16216can yield EACCES for a file in an NFS directory that is mounted without root
16217access. In this case, if a check for access by a particular user is requested,
16218Exim creates a subprocess that runs as that user, and tries the check again in
16219that process.
16220
16221The default action for handling an unresolved EACCES is to consider it to be
16222caused by a configuration error, and routing is deferred because the existence
16223or non-existence of the file cannot be determined. However, in some
16224circumstances it may be desirable to treat this condition as if the file did
16225not exist. If the file name (or the exclamation mark that precedes the file
16226name for non-existence) is preceded by a plus sign, the EACCES error is treated
16227as if the file did not exist. For example:
16228
16229require_files = +/some/file
16230
16231If the router is not an essential part of verification (for example, it handles
16232users' .forward files), another solution is to set the verify option false so
16233that the router is skipped when verifying.
16234
16235+--------------------+------------+-------------+------------------+
16236|retry_use_local_part|Use: routers|Type: boolean|Default: see below|
16237+--------------------+------------+-------------+------------------+
16238
16239When a delivery suffers a temporary routing failure, a retry record is created
16240in Exim's hints database. For addresses whose routing depends only on the
16241domain, the key for the retry record should not involve the local part, but for
16242other addresses, both the domain and the local part should be included.
16243Usually, remote routing is of the former kind, and local routing is of the
16244latter kind.
16245
16246This option controls whether the local part is used to form the key for retry
16247hints for addresses that suffer temporary errors while being handled by this
16248router. The default value is true for any router that has check_local_user set,
16249and false otherwise. Note that this option does not apply to hints keys for
16250transport delays; they are controlled by a generic transport option of the same
16251name.
16252
16253The setting of retry_use_local_part applies only to the router on which it
16254appears. If the router generates child addresses, they are routed
16255independently; this setting does not become attached to them.
16256
16257+---------------------+------------+-------------+--------------+
16258|router_home_directory|Use: routers|Type: string*|Default: unset|
16259+---------------------+------------+-------------+--------------+
16260
16261This option sets a home directory for use while the router is running. (Compare
16262transport_home_directory, which sets a home directory for later transporting.)
16263In particular, if used on a redirect router, this option sets a value for $home
16264while a filter is running. The value is expanded; forced expansion failure
16265causes the option to be ignored - other failures cause the router to defer.
16266
16267Expansion of router_home_directory happens immediately after the
16268check_local_user test (if configured), before any further expansions take
16269place. (See section 3.12 for a list of the order in which preconditions are
16270evaluated.) While the router is running, router_home_directory overrides the
16271value of $home that came from check_local_user.
16272
16273When a router accepts an address and assigns it to a local transport (including
16274the cases when a redirect router generates a pipe, file, or autoreply
16275delivery), the home directory setting for the transport is taken from the first
16276of these values that is set:
16277
16278 * The home_directory option on the transport;
16279
16280 * The transport_home_directory option on the router;
16281
16282 * The password data if check_local_user is set on the router;
16283
16284 * The router_home_directory option on the router.
16285
16286In other words, router_home_directory overrides the password data for the
16287router, but not for the transport.
16288
16289+----+------------+------------+---------------+
16290|self|Use: routers|Type: string|Default: freeze|
16291+----+------------+------------+---------------+
16292
16293This option applies to those routers that use a recipient address to find a
16294list of remote hosts. Currently, these are the dnslookup, ipliteral, and
16295manualroute routers. Certain configurations of the queryprogram router can also
16296specify a list of remote hosts. Usually such routers are configured to send the
16297message to a remote host via an smtp transport. The self option specifies what
16298happens when the first host on the list turns out to be the local host. The way
16299in which Exim checks for the local host is described in section 13.8.
16300
16301Normally this situation indicates either an error in Exim's configuration (for
16302example, the router should be configured not to process this domain), or an
16303error in the DNS (for example, the MX should not point to this host). For this
16304reason, the default action is to log the incident, defer the address, and
16305freeze the message. The following alternatives are provided for use in special
16306cases:
16307
16308defer
16309
16310 Delivery of the message is tried again later, but the message is not
16311 frozen.
16312
16313reroute: <domain>
16314
16315 The domain is changed to the given domain, and the address is passed back
16316 to be reprocessed by the routers. No rewriting of headers takes place. This
16317 behaviour is essentially a redirection.
16318
16319reroute: rewrite: <domain>
16320
16321 The domain is changed to the given domain, and the address is passed back
16322 to be reprocessed by the routers. Any headers that contain the original
16323 domain are rewritten.
16324
16325pass
16326
16327 The router passes the address to the next router, or to the router named in
16328 the pass_router option if it is set. This overrides no_more. During
16329 subsequent routing and delivery, the variable $self_hostname contains the
16330 name of the local host that the router encountered. This can be used to
16331 distinguish between different cases for hosts with multiple names. The
16332 combination
16333
16334 self = pass
16335 no_more
16336
16337 ensures that only those addresses that routed to the local host are passed
16338 on. Without no_more, addresses that were declined for other reasons would
16339 also be passed to the next router.
16340
16341fail
16342
16343 Delivery fails and an error report is generated.
16344
16345send
16346
16347 The anomaly is ignored and the address is queued for the transport. This
16348 setting should be used with extreme caution. For an smtp transport, it
16349 makes sense only in cases where the program that is listening on the SMTP
16350 port is not this version of Exim. That is, it must be some other MTA, or
16351 Exim with a different configuration file that handles the domain in another
16352 way.
16353
16354+-------+--------------+-------------------+--------------+
16355|senders|Use: routers**|Type: address list*|Default: unset|
16356+-------+--------------+-------------------+--------------+
16357
16358If this option is set, the router is skipped unless the message's sender
16359address matches something on the list. See section 3.12 for a list of the order
16360in which preconditions are evaluated.
16361
16362There are issues concerning verification when the running of routers is
16363dependent on the sender. When Exim is verifying the address in an errors_to
16364setting, it sets the sender to the null string. When using the -bt option to
16365check a configuration file, it is necessary also to use the -f option to set an
16366appropriate sender. For incoming mail, the sender is unset when verifying the
16367sender, but is available when verifying any recipients. If the SMTP VRFY
16368command is enabled, it must be used after MAIL if the sender address matters.
16369
16370+--------------------+------------+-------------+--------------+
16371|translate_ip_address|Use: routers|Type: string*|Default: unset|
16372+--------------------+------------+-------------+--------------+
16373
16374There exist some rare networking situations (for example, packet radio) where
16375it is helpful to be able to translate IP addresses generated by normal routing
16376mechanisms into other IP addresses, thus performing a kind of manual IP
16377routing. This should be done only if the normal IP routing of the TCP/IP stack
16378is inadequate or broken. Because this is an extremely uncommon requirement, the
16379code to support this option is not included in the Exim binary unless
16380SUPPORT_TRANSLATE_IP_ADDRESS=yes is set in Local/Makefile.
16381
16382The translate_ip_address string is expanded for every IP address generated by
16383the router, with the generated address set in $host_address. If the expansion
16384is forced to fail, no action is taken. For any other expansion error, delivery
16385of the message is deferred. If the result of the expansion is an IP address,
16386that replaces the original address; otherwise the result is assumed to be a
16387host name - this is looked up using gethostbyname() (or getipnodebyname() when
16388available) to produce one or more replacement IP addresses. For example, to
16389subvert all IP addresses in some specific networks, this could be added to a
16390router:
16391
16392translate_ip_address = \
16393 ${lookup{${mask:$host_address/26}}lsearch{/some/file}\
16394 {$value}fail}}
16395
16396The file would contain lines like
16397
1639810.2.3.128/26 some.host
1639910.8.4.34/26 10.44.8.15
16400
16401You should not make use of this facility unless you really understand what you
16402are doing.
16403
16404+---------+------------+-------------+--------------+
16405|transport|Use: routers|Type: string*|Default: unset|
16406+---------+------------+-------------+--------------+
16407
16408This option specifies the transport to be used when a router accepts an address
16409and sets it up for delivery. A transport is never needed if a router is used
16410only for verification. The value of the option is expanded at routing time,
16411after the expansion of errors_to, headers_add, and headers_remove, and result
16412must be the name of one of the configured transports. If it is not, delivery is
16413deferred.
16414
16415The transport option is not used by the redirect router, but it does have some
16416private options that set up transports for pipe and file deliveries (see
16417chapter 22).
16418
16419+---------------------------+------------+-------------+--------------+
16420|transport_current_directory|Use: routers|Type: string*|Default: unset|
16421+---------------------------+------------+-------------+--------------+
16422
16423This option associates a current directory with any address that is routed to a
16424local transport. This can happen either because a transport is explicitly
16425configured for the router, or because it generates a delivery to a file or a
16426pipe. During the delivery process (that is, at transport time), this option
16427string is expanded and is set as the current directory, unless overridden by a
16428setting on the transport. If the expansion fails for any reason, including
16429forced failure, an error is logged, and delivery is deferred. See chapter 23
16430for details of the local delivery environment.
16431
16432+------------------------+------------+-------------+------------------+
16433|transport_home_directory|Use: routers|Type: string*|Default: see below|
16434+------------------------+------------+-------------+------------------+
16435
16436This option associates a home directory with any address that is routed to a
16437local transport. This can happen either because a transport is explicitly
16438configured for the router, or because it generates a delivery to a file or a
16439pipe. During the delivery process (that is, at transport time), the option
16440string is expanded and is set as the home directory, unless overridden by a
16441setting of home_directory on the transport. If the expansion fails for any
16442reason, including forced failure, an error is logged, and delivery is deferred.
16443
16444If the transport does not specify a home directory, and
16445transport_home_directory is not set for the router, the home directory for the
16446transport is taken from the password data if check_local_user is set for the
16447router. Otherwise it is taken from router_home_directory if that option is set;
16448if not, no home directory is set for the transport.
16449
16450See chapter 23 for further details of the local delivery environment.
16451
16452+------+------------+--------------+--------------+
16453|unseen|Use: routers|Type: boolean*|Default: false|
16454+------+------------+--------------+--------------+
16455
16456The result of string expansion for this option must be a valid boolean value,
16457that is, one of the strings "yes", "no", "true", or "false". Any other result
16458causes an error, and delivery is deferred. If the expansion is forced to fail,
16459the default value for the option (false) is used. Other failures cause delivery
16460to be deferred.
16461
16462When this option is set true, routing does not cease if the router accepts the
16463address. Instead, a copy of the incoming address is passed to the next router,
16464overriding a false setting of more. There is little point in setting more false
16465if unseen is always true, but it may be useful in cases when the value of
16466unseen contains expansion items (and therefore, presumably, is sometimes true
16467and sometimes false).
16468
16469Setting the unseen option has a similar effect to the unseen command qualifier
16470in filter files. It can be used to cause copies of messages to be delivered to
16471some other destination, while also carrying out a normal delivery. In effect,
16472the current address is made into a "parent" that has two children - one that is
16473delivered as specified by this router, and a clone that goes on to be routed
16474further. For this reason, unseen may not be combined with the one_time option
16475in a redirect router.
16476
16477Warning: Header lines added to the address (or specified for removal) by this
16478router or by previous routers affect the "unseen" copy of the message only. The
16479clone that continues to be processed by further routers starts with no added
16480headers and none specified for removal. For a redirect router, if a generated
16481address is the same as the incoming address, this can lead to duplicate
16482addresses with different header modifications. Exim does not do duplicate
16483deliveries (except, in certain circumstances, to pipes -- see section 22.7),
16484but it is undefined which of the duplicates is discarded, so this ambiguous
16485situation should be avoided. The repeat_use option of the redirect router may
16486be of help.
16487
16488Unlike the handling of header modifications, any data that was set by the
16489address_data option in the current or previous routers is passed on to
16490subsequent routers.
16491
16492+----+------------+-------------+------------------+
16493|user|Use: routers|Type: string*|Default: see below|
16494+----+------------+-------------+------------------+
16495
16496When a router queues an address for a transport, and the transport does not
16497specify a user, the user given here is used when running the delivery process.
16498The user may be specified numerically or by name. If expansion fails, the error
16499is logged and delivery is deferred. This user is also used by the redirect
16500router when running a filter file. The default is unset, except when
16501check_local_user is set. In this case, the default is taken from the password
16502information. If the user is specified as a name, and group is not set, the
16503group associated with the user is used. See also initgroups and group and the
16504discussion in chapter 23.
16505
16506+------+--------------+-------------+-------------+
16507|verify|Use: routers**|Type: boolean|Default: true|
16508+------+--------------+-------------+-------------+
16509
16510Setting this option has the effect of setting verify_sender and
16511verify_recipient to the same value.
16512
16513+-----------+--------------+-------------+--------------+
16514|verify_only|Use: routers**|Type: boolean|Default: false|
16515+-----------+--------------+-------------+--------------+
16516
16517If this option is set, the router is used only when verifying an address,
16518delivering in cutthrough mode or testing with the -bv option, not when actually
16519doing a delivery, testing with the -bt option, or running the SMTP EXPN
16520command. It can be further restricted to verifying only senders or recipients
16521by means of verify_sender and verify_recipient.
16522
16523Warning: When the router is being run to verify addresses for an incoming SMTP
16524message, Exim is not running as root, but under its own uid. If the router
16525accesses any files, you need to make sure that they are accessible to the Exim
16526user or group.
16527
16528+----------------+--------------+-------------+-------------+
16529|verify_recipient|Use: routers**|Type: boolean|Default: true|
16530+----------------+--------------+-------------+-------------+
16531
16532If this option is false, the router is skipped when verifying recipient
16533addresses, delivering in cutthrough mode or testing recipient verification
16534using -bv. See section 3.12 for a list of the order in which preconditions are
16535evaluated.
16536
16537+-------------+--------------+-------------+-------------+
16538|verify_sender|Use: routers**|Type: boolean|Default: true|
16539+-------------+--------------+-------------+-------------+
16540
16541If this option is false, the router is skipped when verifying sender addresses
16542or testing sender verification using -bvs. See section 3.12 for a list of the
16543order in which preconditions are evaluated.
16544
16545
16546
16547===============================================================================
1654816. THE ACCEPT ROUTER
16549
16550The accept router has no private options of its own. Unless it is being used
16551purely for verification (see verify_only) a transport is required to be defined
16552by the generic transport option. If the preconditions that are specified by
16553generic options are met, the router accepts the address and queues it for the
16554given transport. The most common use of this router is for setting up
16555deliveries to local mailboxes. For example:
16556
16557localusers:
16558 driver = accept
16559 domains = mydomain.example
16560 check_local_user
16561 transport = local_delivery
16562
16563The domains condition in this example checks the domain of the address, and
16564check_local_user checks that the local part is the login of a local user. When
16565both preconditions are met, the accept router runs, and queues the address for
16566the local_delivery transport.
16567
16568
16569
16570===============================================================================
1657117. THE DNSLOOKUP ROUTER
16572
16573The dnslookup router looks up the hosts that handle mail for the recipient's
16574domain in the DNS. A transport must always be set for this router, unless
16575verify_only is set.
16576
16577If SRV support is configured (see check_srv below), Exim first searches for SRV
16578records. If none are found, or if SRV support is not configured, MX records are
16579looked up. If no MX records exist, address records are sought. However,
16580mx_domains can be set to disable the direct use of address records.
16581
16582MX records of equal priority are sorted by Exim into a random order. Exim then
16583looks for address records for the host names obtained from MX or SRV records.
16584When a host has more than one IP address, they are sorted into a random order,
16585except that IPv6 addresses are always sorted before IPv4 addresses. If all the
16586IP addresses found are discarded by a setting of the ignore_target_hosts
16587generic option, the router declines.
16588
16589Unless they have the highest priority (lowest MX value), MX records that point
16590to the local host, or to any host name that matches hosts_treat_as_local, are
16591discarded, together with any other MX records of equal or lower priority.
16592
16593If the host pointed to by the highest priority MX record, or looked up as an
16594address record, is the local host, or matches hosts_treat_as_local, what
16595happens is controlled by the generic self option.
16596
16597
1659817.1 Problems with DNS lookups
16599------------------------------
16600
16601There have been problems with DNS servers when SRV records are looked up. Some
16602mis-behaving servers return a DNS error or timeout when a non-existent SRV
16603record is sought. Similar problems have in the past been reported for MX
16604records. The global dns_again_means_nonexist option can help with this problem,
16605but it is heavy-handed because it is a global option.
16606
16607For this reason, there are two options, srv_fail_domains and mx_fail_domains,
16608that control what happens when a DNS lookup in a dnslookup router results in a
16609DNS failure or a "try again" response. If an attempt to look up an SRV or MX
16610record causes one of these results, and the domain matches the relevant list,
16611Exim behaves as if the DNS had responded "no such record". In the case of an
16612SRV lookup, this means that the router proceeds to look for MX records; in the
16613case of an MX lookup, it proceeds to look for A or AAAA records, unless the
16614domain matches mx_domains, in which case routing fails.
16615
16616
1661717.2 Declining addresses by dnslookup
16618-------------------------------------
16619
16620There are a few cases where a dnslookup router will decline to accept an
16621address; if such a router is expected to handle "all remaining non-local
16622domains", then it is important to set no_more.
16623
16624Reasons for a dnslookup router to decline currently include:
16625
16626 * The domain does not exist in DNS
16627
16628 * The domain exists but the MX record's host part is just "."; this is a
16629 common convention (borrowed from SRV) used to indicate that there is no
16630 such service for this domain and to not fall back to trying A/AAAA records.
16631
16632 * Ditto, but for SRV records, when check_srv is set on this router.
16633
16634 * MX record points to a non-existent host.
16635
16636 * MX record points to an IP address and the main section option
16637 allow_mx_to_ip is not set.
16638
16639 * MX records exist and point to valid hosts, but all hosts resolve only to
16640 addresses blocked by the ignore_target_hosts generic option on this router.
16641
16642 * The domain is not syntactically valid (see also allow_utf8_domains and
16643 dns_check_names_pattern for handling one variant of this)
16644
16645 * check_secondary_mx is set on this router but the local host can not be
16646 found in the MX records (see below)
16647
16648
1664917.3 Private options for dnslookup
16650----------------------------------
16651
16652The private options for the dnslookup router are as follows:
16653
16654+------------------+--------------+-------------+--------------+
16655|check_secondary_mx|Use: dnslookup|Type: boolean|Default: false|
16656+------------------+--------------+-------------+--------------+
16657
16658If this option is set, the router declines unless the local host is found in
16659(and removed from) the list of hosts obtained by MX lookup. This can be used to
16660process domains for which the local host is a secondary mail exchanger
16661differently to other domains. The way in which Exim decides whether a host is
16662the local host is described in section 13.8.
16663
16664+---------+--------------+-------------+--------------+
16665|check_srv|Use: dnslookup|Type: string*|Default: unset|
16666+---------+--------------+-------------+--------------+
16667
16668The dnslookup router supports the use of SRV records (see RFC 2782) in addition
16669to MX and address records. The support is disabled by default. To enable SRV
16670support, set the check_srv option to the name of the service required. For
16671example,
16672
16673check_srv = smtp
16674
16675looks for SRV records that refer to the normal smtp service. The option is
16676expanded, so the service name can vary from message to message or address to
16677address. This might be helpful if SRV records are being used for a submission
16678service. If the expansion is forced to fail, the check_srv option is ignored,
16679and the router proceeds to look for MX records in the normal way.
16680
16681When the expansion succeeds, the router searches first for SRV records for the
16682given service (it assumes TCP protocol). A single SRV record with a host name
16683that consists of just a single dot indicates "no such service for this domain";
16684if this is encountered, the router declines. If other kinds of SRV record are
16685found, they are used to construct a host list for delivery according to the
16686rules of RFC 2782. MX records are not sought in this case.
16687
16688When no SRV records are found, MX records (and address records) are sought in
16689the traditional way. In other words, SRV records take precedence over MX
16690records, just as MX records take precedence over address records. Note that
16691this behaviour is not sanctioned by RFC 2782, though a previous draft RFC
16692defined it. It is apparently believed that MX records are sufficient for email
16693and that SRV records should not be used for this purpose. However, SRV records
16694have an additional "weight" feature which some people might find useful when
16695trying to split an SMTP load between hosts of different power.
16696
16697See section 17.1 above for a discussion of Exim's behaviour when there is a DNS
16698lookup error.
16699
16700+----------------------+--------------+------------------+--------------+
16701|dnssec_request_domains|Use: dnslookup|Type: domain list*|Default: unset|
16702+----------------------+--------------+------------------+--------------+
16703
16704DNS lookups for domains matching dnssec_request_domains will be done with the
16705dnssec request bit set. This applies to all of the SRV, MX A6, AAAA, A lookup
16706sequence.
16707
16708+----------------------+--------------+------------------+--------------+
16709|dnssec_require_domains|Use: dnslookup|Type: domain list*|Default: unset|
16710+----------------------+--------------+------------------+--------------+
16711
16712DNS lookups for domains matching dnssec_request_domains will be done with the
16713dnssec request bit set. Any returns not having the Authenticated Data bit (AD
16714bit) set wil be ignored and logged as a host-lookup failure. This applies to
16715all of the SRV, MX A6, AAAA, A lookup sequence.
16716
16717+----------+--------------+------------------+--------------+
16718|mx_domains|Use: dnslookup|Type: domain list*|Default: unset|
16719+----------+--------------+------------------+--------------+
16720
16721A domain that matches mx_domains is required to have either an MX or an SRV
16722record in order to be recognized. (The name of this option could be improved.)
16723For example, if all the mail hosts in fict.example are known to have MX
16724records, except for those in discworld.fict.example, you could use this
16725setting:
16726
16727mx_domains = ! *.discworld.fict.example : *.fict.example
16728
16729This specifies that messages addressed to a domain that matches the list but
16730has no MX record should be bounced immediately instead of being routed using
16731the address record.
16732
16733+---------------+--------------+------------------+--------------+
16734|mx_fail_domains|Use: dnslookup|Type: domain list*|Default: unset|
16735+---------------+--------------+------------------+--------------+
16736
16737If the DNS lookup for MX records for one of the domains in this list causes a
16738DNS lookup error, Exim behaves as if no MX records were found. See section 17.1
16739for more discussion.
16740
16741+--------------+--------------+-------------+-------------+
16742|qualify_single|Use: dnslookup|Type: boolean|Default: true|
16743+--------------+--------------+-------------+-------------+
16744
16745When this option is true, the resolver option RES_DEFNAMES is set for DNS
16746lookups. Typically, but not standardly, this causes the resolver to qualify
16747single-component names with the default domain. For example, on a machine
16748called dictionary.ref.example, the domain thesaurus would be changed to
16749thesaurus.ref.example inside the resolver. For details of what your resolver
16750actually does, consult your man pages for resolver and resolv.conf.
16751
16752+---------------+--------------+-------------+-------------+
16753|rewrite_headers|Use: dnslookup|Type: boolean|Default: true|
16754+---------------+--------------+-------------+-------------+
16755
16756If the domain name in the address that is being processed is not fully
16757qualified, it may be expanded to its full form by a DNS lookup. For example, if
16758an address is specified as dormouse@teaparty, the domain might be expanded to
16759teaparty.wonderland.fict.example. Domain expansion can also occur as a result
16760of setting the widen_domains option. If rewrite_headers is true, all
16761occurrences of the abbreviated domain name in any Bcc:, Cc:, From:, Reply-to:,
16762Sender:, and To: header lines of the message are rewritten with the full domain
16763name.
16764
16765This option should be turned off only when it is known that no message is ever
16766going to be sent outside an environment where the abbreviation makes sense.
16767
16768When an MX record is looked up in the DNS and matches a wildcard record, name
16769servers normally return a record containing the name that has been looked up,
16770making it impossible to detect whether a wildcard was present or not. However,
16771some name servers have recently been seen to return the wildcard entry. If the
16772name returned by a DNS lookup begins with an asterisk, it is not used for
16773header rewriting.
16774
16775+------------------------+--------------+-------------+--------------+
16776|same_domain_copy_routing|Use: dnslookup|Type: boolean|Default: false|
16777+------------------------+--------------+-------------+--------------+
16778
16779Addresses with the same domain are normally routed by the dnslookup router to
16780the same list of hosts. However, this cannot be presumed, because the router
16781options and preconditions may refer to the local part of the address. By
16782default, therefore, Exim routes each address in a message independently. DNS
16783servers run caches, so repeated DNS lookups are not normally expensive, and in
16784any case, personal messages rarely have more than a few recipients.
16785
16786If you are running mailing lists with large numbers of subscribers at the same
16787domain, and you are using a dnslookup router which is independent of the local
16788part, you can set same_domain_copy_routing to bypass repeated DNS lookups for
16789identical domains in one message. In this case, when dnslookup routes an
16790address to a remote transport, any other unrouted addresses in the message that
16791have the same domain are automatically given the same routing without
16792processing them independently, provided the following conditions are met:
16793
16794 * No router that processed the address specified headers_add or
16795 headers_remove.
16796
16797 * The router did not change the address in any way, for example, by
16798 "widening" the domain.
16799
16800+--------------+--------------+-------------+--------------+
16801|search_parents|Use: dnslookup|Type: boolean|Default: false|
16802+--------------+--------------+-------------+--------------+
16803
16804When this option is true, the resolver option RES_DNSRCH is set for DNS
16805lookups. This is different from the qualify_single option in that it applies to
16806domains containing dots. Typically, but not standardly, it causes the resolver
16807to search for the name in the current domain and in parent domains. For
16808example, on a machine in the fict.example domain, if looking up
16809teaparty.wonderland failed, the resolver would try
16810teaparty.wonderland.fict.example. For details of what your resolver actually
16811does, consult your man pages for resolver and resolv.conf.
16812
16813Setting this option true can cause problems in domains that have a wildcard MX
16814record, because any domain that does not have its own MX record matches the
16815local wildcard.
16816
16817+----------------+--------------+------------------+--------------+
16818|srv_fail_domains|Use: dnslookup|Type: domain list*|Default: unset|
16819+----------------+--------------+------------------+--------------+
16820
16821If the DNS lookup for SRV records for one of the domains in this list causes a
16822DNS lookup error, Exim behaves as if no SRV records were found. See section
1682317.1 for more discussion.
16824
16825+-------------+--------------+-----------------+--------------+
16826|widen_domains|Use: dnslookup|Type: string list|Default: unset|
16827+-------------+--------------+-----------------+--------------+
16828
16829If a DNS lookup fails and this option is set, each of its strings in turn is
16830added onto the end of the domain, and the lookup is tried again. For example,
16831if
16832
16833widen_domains = fict.example:ref.example
16834
16835is set and a lookup of klingon.dictionary fails,
16836klingon.dictionary.fict.example is looked up, and if this fails,
16837klingon.dictionary.ref.example is tried. Note that the qualify_single and
16838search_parents options can cause some widening to be undertaken inside the DNS
16839resolver. widen_domains is not applied to sender addresses when verifying,
16840unless rewrite_headers is false (not the default).
16841
16842
1684317.4 Effect of qualify_single and search_parents
16844------------------------------------------------
16845
16846When a domain from an envelope recipient is changed by the resolver as a result
16847of the qualify_single or search_parents options, Exim rewrites the
16848corresponding address in the message's header lines unless rewrite_headers is
16849set false. Exim then re-routes the address, using the full domain.
16850
16851These two options affect only the DNS lookup that takes place inside the router
16852for the domain of the address that is being routed. They do not affect lookups
16853such as that implied by
16854
16855domains = @mx_any
16856
16857that may happen while processing a router precondition before the router is
16858entered. No widening ever takes place for these lookups.
16859
16860
16861
16862===============================================================================
1686318. THE IPLITERAL ROUTER
16864
16865This router has no private options. Unless it is being used purely for
16866verification (see verify_only) a transport is required to be defined by the
16867generic transport option. The router accepts the address if its domain part
16868takes the form of an RFC 2822 domain literal. For example, the ipliteral router
16869handles the address
16870
16871root@[192.168.1.1]
16872
16873by setting up delivery to the host with that IP address. IPv4 domain literals
16874consist of an IPv4 address enclosed in square brackets. IPv6 domain literals
16875are similar, but the address is preceded by "ipv6:". For example:
16876
16877postmaster@[ipv6:fe80::a00:20ff:fe86:a061.5678]
16878
16879Exim allows "ipv4:" before IPv4 addresses, for consistency, and on the grounds
16880that sooner or later somebody will try it.
16881
16882If the IP address matches something in ignore_target_hosts, the router
16883declines. If an IP literal turns out to refer to the local host, the generic
16884self option determines what happens.
16885
16886The RFCs require support for domain literals; however, their use is
16887controversial in today's Internet. If you want to use this router, you must
16888also set the main configuration option allow_domain_literals. Otherwise, Exim
16889will not recognize the domain literal syntax in addresses.
16890
16891
16892
16893===============================================================================
1689419. THE IPLOOKUP ROUTER
16895
16896The iplookup router was written to fulfil a specific requirement in Cambridge
16897University (which in fact no longer exists). For this reason, it is not
16898included in the binary of Exim by default. If you want to include it, you must
16899set
16900
16901ROUTER_IPLOOKUP=yes
16902
16903in your Local/Makefile configuration file.
16904
16905The iplookup router routes an address by sending it over a TCP or UDP
16906connection to one or more specific hosts. The host can then return the same or
16907a different address - in effect rewriting the recipient address in the
16908message's envelope. The new address is then passed on to subsequent routers. If
16909this process fails, the address can be passed on to other routers, or delivery
16910can be deferred. Since iplookup is just a rewriting router, a transport must
16911not be specified for it.
16912
16913+-----+-------------+------------+--------------+
16914|hosts|Use: iplookup|Type: string|Default: unset|
16915+-----+-------------+------------+--------------+
16916
16917This option must be supplied. Its value is a colon-separated list of host
16918names. The hosts are looked up using gethostbyname() (or getipnodebyname() when
16919available) and are tried in order until one responds to the query. If none
16920respond, what happens is controlled by optional.
16921
16922+--------+-------------+-------------+--------------+
16923|optional|Use: iplookup|Type: boolean|Default: false|
16924+--------+-------------+-------------+--------------+
16925
16926If optional is true, if no response is obtained from any host, the address is
16927passed to the next router, overriding no_more. If optional is false, delivery
16928to the address is deferred.
16929
16930+----+-------------+-------------+----------+
16931|port|Use: iplookup|Type: integer|Default: 0|
16932+----+-------------+-------------+----------+
16933
16934This option must be supplied. It specifies the port number for the TCP or UDP
16935call.
16936
16937+--------+-------------+------------+------------+
16938|protocol|Use: iplookup|Type: string|Default: udp|
16939+--------+-------------+------------+------------+
16940
16941This option can be set to "udp" or "tcp" to specify which of the two protocols
16942is to be used.
16943
16944+-----+-------------+-------------+------------------+
16945|query|Use: iplookup|Type: string*|Default: see below|
16946+-----+-------------+-------------+------------------+
16947
16948This defines the content of the query that is sent to the remote hosts. The
16949default value is:
16950
16951$local_part@$domain $local_part@$domain
16952
16953The repetition serves as a way of checking that a response is to the correct
16954query in the default case (see response_pattern below).
16955
16956+-------+-------------+-------------+--------------+
16957|reroute|Use: iplookup|Type: string*|Default: unset|
16958+-------+-------------+-------------+--------------+
16959
16960If this option is not set, the rerouted address is precisely the byte string
16961returned by the remote host, up to the first white space, if any. If set, the
16962string is expanded to form the rerouted address. It can include parts matched
16963in the response by response_pattern by means of numeric variables such as $1,
16964$2, etc. The variable $0 refers to the entire input string, whether or not a
16965pattern is in use. In all cases, the rerouted address must end up in the form
16966local_part@domain.
16967
16968+----------------+-------------+------------+--------------+
16969|response_pattern|Use: iplookup|Type: string|Default: unset|
16970+----------------+-------------+------------+--------------+
16971
16972This option can be set to a regular expression that is applied to the string
16973returned from the remote host. If the pattern does not match the response, the
16974router declines. If response_pattern is not set, no checking of the response is
16975done, unless the query was defaulted, in which case there is a check that the
16976text returned after the first white space is the original address. This checks
16977that the answer that has been received is in response to the correct question.
16978For example, if the response is just a new domain, the following could be used:
16979
16980response_pattern = ^([^@]+)$
16981reroute = $local_part@$1
16982
16983+-------+-------------+----------+-----------+
16984|timeout|Use: iplookup|Type: time|Default: 5s|
16985+-------+-------------+----------+-----------+
16986
16987This specifies the amount of time to wait for a response from the remote
16988machine. The same timeout is used for the connect() function for a TCP call. It
16989does not apply to UDP.
16990
16991
16992
16993===============================================================================
1699420. THE MANUALROUTE ROUTER
16995
16996The manualroute router is so-called because it provides a way of manually
16997routing an address according to its domain. It is mainly used when you want to
16998route addresses to remote hosts according to your own rules, bypassing the
16999normal DNS routing that looks up MX records. However, manualroute can also
17000route to local transports, a facility that may be useful if you want to save
17001messages for dial-in hosts in local files.
17002
17003The manualroute router compares a list of domain patterns with the domain it is
17004trying to route. If there is no match, the router declines. Each pattern has
17005associated with it a list of hosts and some other optional data, which may
17006include a transport. The combination of a pattern and its data is called a
17007"routing rule". For patterns that do not have an associated transport, the
17008generic transport option must specify a transport, unless the router is being
17009used purely for verification (see verify_only).
17010
17011In the case of verification, matching the domain pattern is sufficient for the
17012router to accept the address. When actually routing an address for delivery, an
17013address that matches a domain pattern is queued for the associated transport.
17014If the transport is not a local one, a host list must be associated with the
17015pattern; IP addresses are looked up for the hosts, and these are passed to the
17016transport along with the mail address. For local transports, a host list is
17017optional. If it is present, it is passed in $host as a single text string.
17018
17019The list of routing rules can be provided as an inline string in route_list, or
17020the data can be obtained by looking up the domain in a file or database by
17021setting route_data. Only one of these settings may appear in any one instance
17022of manualroute. The format of routing rules is described below, following the
17023list of private options.
17024
17025
1702620.1 Private options for manualroute
17027------------------------------------
17028
17029The private options for the manualroute router are as follows:
17030
17031+----------------+----------------+------------+--------------+
17032|host_all_ignored|Use: manualroute|Type: string|Default: defer|
17033+----------------+----------------+------------+--------------+
17034
17035See host_find_failed.
17036
17037+----------------+----------------+------------+---------------+
17038|host_find_failed|Use: manualroute|Type: string|Default: freeze|
17039+----------------+----------------+------------+---------------+
17040
17041This option controls what happens when manualroute tries to find an IP address
17042for a host, and the host does not exist. The option can be set to one of the
17043following values:
17044
17045decline
17046defer
17047fail
17048freeze
17049ignore
17050pass
17051
17052The default ("freeze") assumes that this state is a serious configuration
17053error. The difference between "pass" and "decline" is that the former forces
17054the address to be passed to the next router (or the router defined by
17055pass_router), overriding no_more, whereas the latter passes the address to the
17056next router only if more is true.
17057
17058The value "ignore" causes Exim to completely ignore a host whose IP address
17059cannot be found. If all the hosts in the list are ignored, the behaviour is
17060controlled by the host_all_ignored option. This takes the same values as
17061host_find_failed, except that it cannot be set to "ignore".
17062
17063The host_find_failed option applies only to a definite "does not exist" state;
17064if a host lookup gets a temporary error, delivery is deferred unless the
17065generic pass_on_timeout option is set.
17066
17067+---------------+----------------+-------------+--------------+
17068|hosts_randomize|Use: manualroute|Type: boolean|Default: false|
17069+---------------+----------------+-------------+--------------+
17070
17071If this option is set, the order of the items in a host list in a routing rule
17072is randomized each time the list is used, unless an option in the routing rule
17073overrides (see below). Randomizing the order of a host list can be used to do
17074crude load sharing. However, if more than one mail address is routed by the
17075same router to the same host list, the host lists are considered to be the same
17076(even though they may be randomized into different orders) for the purpose of
17077deciding whether to batch the deliveries into a single SMTP transaction.
17078
17079When hosts_randomize is true, a host list may be split into groups whose order
17080is separately randomized. This makes it possible to set up MX-like behaviour.
17081The boundaries between groups are indicated by an item that is just "+" in the
17082host list. For example:
17083
17084route_list = * host1:host2:host3:+:host4:host5
17085
17086The order of the first three hosts and the order of the last two hosts is
17087randomized for each use, but the first three always end up before the last two.
17088If hosts_randomize is not set, a "+" item in the list is ignored. If a
17089randomized host list is passed to an smtp transport that also has
17090hosts_randomize set, the list is not re-randomized.
17091
17092+----------+----------------+-------------+--------------+
17093|route_data|Use: manualroute|Type: string*|Default: unset|
17094+----------+----------------+-------------+--------------+
17095
17096If this option is set, it must expand to yield the data part of a routing rule.
17097Typically, the expansion string includes a lookup based on the domain. For
17098example:
17099
17100route_data = ${lookup{$domain}dbm{/etc/routes}}
17101
17102If the expansion is forced to fail, or the result is an empty string, the
17103router declines. Other kinds of expansion failure cause delivery to be
17104deferred.
17105
17106+----------+----------------+-----------------+--------------+
17107|route_list|Use: manualroute|Type: string list|Default: unset|
17108+----------+----------------+-----------------+--------------+
17109
17110This string is a list of routing rules, in the form defined below. Note that,
17111unlike most string lists, the items are separated by semicolons. This is so
17112that they may contain colon-separated host lists.
17113
17114+------------------------+----------------+-------------+--------------+
17115|same_domain_copy_routing|Use: manualroute|Type: boolean|Default: false|
17116+------------------------+----------------+-------------+--------------+
17117
17118Addresses with the same domain are normally routed by the manualroute router to
17119the same list of hosts. However, this cannot be presumed, because the router
17120options and preconditions may refer to the local part of the address. By
17121default, therefore, Exim routes each address in a message independently. DNS
17122servers run caches, so repeated DNS lookups are not normally expensive, and in
17123any case, personal messages rarely have more than a few recipients.
17124
17125If you are running mailing lists with large numbers of subscribers at the same
17126domain, and you are using a manualroute router which is independent of the
17127local part, you can set same_domain_copy_routing to bypass repeated DNS lookups
17128for identical domains in one message. In this case, when manualroute routes an
17129address to a remote transport, any other unrouted addresses in the message that
17130have the same domain are automatically given the same routing without
17131processing them independently. However, this is only done if headers_add and
17132headers_remove are unset.
17133
17134
1713520.2 Routing rules in route_list
17136--------------------------------
17137
17138The value of route_list is a string consisting of a sequence of routing rules,
17139separated by semicolons. If a semicolon is needed in a rule, it can be entered
17140as two semicolons. Alternatively, the list separator can be changed as
17141described (for colon-separated lists) in section 6.19. Empty rules are ignored.
17142The format of each rule is
17143
17144<domain pattern> <list of hosts> <options>
17145
17146The following example contains two rules, each with a simple domain pattern and
17147no options:
17148
17149route_list = \
17150 dict.ref.example mail-1.ref.example:mail-2.ref.example ; \
17151 thes.ref.example mail-3.ref.example:mail-4.ref.example
17152
17153The three parts of a rule are separated by white space. The pattern and the
17154list of hosts can be enclosed in quotes if necessary, and if they are, the
17155usual quoting rules apply. Each rule in a route_list must start with a single
17156domain pattern, which is the only mandatory item in the rule. The pattern is in
17157the same format as one item in a domain list (see section 10.8), except that it
17158may not be the name of an interpolated file. That is, it may be wildcarded, or
17159a regular expression, or a file or database lookup (with semicolons doubled,
17160because of the use of semicolon as a separator in a route_list).
17161
17162The rules in route_list are searched in order until one of the patterns matches
17163the domain that is being routed. The list of hosts and then options are then
17164used as described below. If there is no match, the router declines. When
17165route_list is set, route_data must not be set.
17166
17167
1716820.3 Routing rules in route_data
17169--------------------------------
17170
17171The use of route_list is convenient when there are only a small number of
17172routing rules. For larger numbers, it is easier to use a file or database to
17173hold the routing information, and use the route_data option instead. The value
17174of route_data is a list of hosts, followed by (optional) options. Most
17175commonly, route_data is set as a string that contains an expansion lookup. For
17176example, suppose we place two routing rules in a file like this:
17177
17178dict.ref.example: mail-1.ref.example:mail-2.ref.example
17179thes.ref.example: mail-3.ref.example:mail-4.ref.example
17180
17181This data can be accessed by setting
17182
17183route_data = ${lookup{$domain}lsearch{/the/file/name}}
17184
17185Failure of the lookup results in an empty string, causing the router to
17186decline. However, you do not have to use a lookup in route_data. The only
17187requirement is that the result of expanding the string is a list of hosts,
17188possibly followed by options, separated by white space. The list of hosts must
17189be enclosed in quotes if it contains white space.
17190
17191
1719220.4 Format of the list of hosts
17193--------------------------------
17194
17195A list of hosts, whether obtained via route_data or route_list, is always
17196separately expanded before use. If the expansion fails, the router declines.
17197The result of the expansion must be a colon-separated list of names and/or IP
17198addresses, optionally also including ports. The format of each item in the list
17199is described in the next section. The list separator can be changed as
17200described in section 6.19.
17201
17202If the list of hosts was obtained from a route_list item, the following
17203variables are set during its expansion:
17204
17205 * If the domain was matched against a regular expression, the numeric
17206 variables $1, $2, etc. may be set. For example:
17207
17208 route_list = ^domain(\d+) host-$1.text.example
17209
17210 * $0 is always set to the entire domain.
17211
17212 * $1 is also set when partial matching is done in a file lookup.
17213
17214 * If the pattern that matched the domain was a lookup item, the data that was
17215 looked up is available in the expansion variable $value. For example:
17216
17217 route_list = lsearch;;/some/file.routes $value
17218
17219Note the doubling of the semicolon in the pattern that is necessary because
17220semicolon is the default route list separator.
17221
17222
1722320.5 Format of one host item
17224----------------------------
17225
17226Each item in the list of hosts is either a host name or an IP address,
17227optionally with an attached port number. When no port is given, an IP address
17228is not enclosed in brackets. When a port is specified, it overrides the port
17229specification on the transport. The port is separated from the name or address
17230by a colon. This leads to some complications:
17231
17232 * Because colon is the default separator for the list of hosts, either the
17233 colon that specifies a port must be doubled, or the list separator must be
17234 changed. The following two examples have the same effect:
17235
17236 route_list = * "host1.tld::1225 : host2.tld::1226"
17237 route_list = * "<+ host1.tld:1225 + host2.tld:1226"
17238
17239 * When IPv6 addresses are involved, it gets worse, because they contain
17240 colons of their own. To make this case easier, it is permitted to enclose
17241 an IP address (either v4 or v6) in square brackets if a port number
17242 follows. For example:
17243
17244 route_list = * "</ [10.1.1.1]:1225 / [::1]:1226"
17245
17246
1724720.6 How the list of hosts is used
17248----------------------------------
17249
17250When an address is routed to an smtp transport by manualroute, each of the
17251hosts is tried, in the order specified, when carrying out the SMTP delivery.
17252However, the order can be changed by setting the hosts_randomize option, either
17253on the router (see section 20.1 above), or on the transport.
17254
17255Hosts may be listed by name or by IP address. An unadorned name in the list of
17256hosts is interpreted as a host name. A name that is followed by "/MX" is
17257interpreted as an indirection to a sublist of hosts obtained by looking up MX
17258records in the DNS. For example:
17259
17260route_list = * x.y.z:p.q.r/MX:e.f.g
17261
17262If this feature is used with a port specifier, the port must come last. For
17263example:
17264
17265route_list = * dom1.tld/mx::1225
17266
17267If the hosts_randomize option is set, the order of the items in the list is
17268randomized before any lookups are done. Exim then scans the list; for any name
17269that is not followed by "/MX" it looks up an IP address. If this turns out to
17270be an interface on the local host and the item is not the first in the list,
17271Exim discards it and any subsequent items. If it is the first item, what
17272happens is controlled by the self option of the router.
17273
17274A name on the list that is followed by "/MX" is replaced with the list of hosts
17275obtained by looking up MX records for the name. This is always a DNS lookup;
17276the bydns and byname options (see section 20.7 below) are not relevant here.
17277The order of these hosts is determined by the preference values in the MX
17278records, according to the usual rules. Because randomizing happens before the
17279MX lookup, it does not affect the order that is defined by MX preferences.
17280
17281If the local host is present in the sublist obtained from MX records, but is
17282not the most preferred host in that list, it and any equally or less preferred
17283hosts are removed before the sublist is inserted into the main list.
17284
17285If the local host is the most preferred host in the MX list, what happens
17286depends on where in the original list of hosts the "/MX" item appears. If it is
17287not the first item (that is, there are previous hosts in the main list), Exim
17288discards this name and any subsequent items in the main list.
17289
17290If the MX item is first in the list of hosts, and the local host is the most
17291preferred host, what happens is controlled by the self option of the router.
17292
17293DNS failures when lookup up the MX records are treated in the same way as DNS
17294failures when looking up IP addresses: pass_on_timeout and host_find_failed are
17295used when relevant.
17296
17297The generic ignore_target_hosts option applies to all hosts in the list,
17298whether obtained from an MX lookup or not.
17299
17300
1730120.7 How the options are used
17302-----------------------------
17303
17304The options are a sequence of words; in practice no more than three are ever
17305present. One of the words can be the name of a transport; this overrides the
17306transport option on the router for this particular routing rule only. The other
17307words (if present) control randomization of the list of hosts on a per-rule
17308basis, and how the IP addresses of the hosts are to be found when routing to a
17309remote transport. These options are as follows:
17310
17311 * randomize: randomize the order of the hosts in this list, overriding the
17312 setting of hosts_randomize for this routing rule only.
17313
17314 * no_randomize: do not randomize the order of the hosts in this list,
17315 overriding the setting of hosts_randomize for this routing rule only.
17316
17317 * byname: use getipnodebyname() (gethostbyname() on older systems) to find IP
17318 addresses. This function may ultimately cause a DNS lookup, but it may also
17319 look in /etc/hosts or other sources of information.
17320
17321 * bydns: look up address records for the hosts directly in the DNS; fail if
17322 no address records are found. If there is a temporary DNS error (such as a
17323 timeout), delivery is deferred.
17324
17325For example:
17326
17327route_list = domain1 host1:host2:host3 randomize bydns;\
17328 domain2 host4:host5
17329
17330If neither byname nor bydns is given, Exim behaves as follows: First, a DNS
17331lookup is done. If this yields anything other than HOST_NOT_FOUND, that result
17332is used. Otherwise, Exim goes on to try a call to getipnodebyname() or
17333gethostbyname(), and the result of the lookup is the result of that call.
17334
17335Warning: It has been discovered that on some systems, if a DNS lookup called
17336via getipnodebyname() times out, HOST_NOT_FOUND is returned instead of
17337TRY_AGAIN. That is why the default action is to try a DNS lookup first. Only if
17338that gives a definite "no such host" is the local function called.
17339
17340If no IP address for a host can be found, what happens is controlled by the
17341host_find_failed option.
17342
17343When an address is routed to a local transport, IP addresses are not looked up.
17344The host list is passed to the transport in the $host variable.
17345
17346
1734720.8 Manualroute examples
17348-------------------------
17349
17350In some of the examples that follow, the presence of the remote_smtp transport,
17351as defined in the default configuration file, is assumed:
17352
17353 * The manualroute router can be used to forward all external mail to a smart
17354 host. If you have set up, in the main part of the configuration, a named
17355 domain list that contains your local domains, for example:
17356
17357 domainlist local_domains = my.domain.example
17358
17359 You can arrange for all other domains to be routed to a smart host by
17360 making your first router something like this:
17361
17362 smart_route:
17363 driver = manualroute
17364 domains = !+local_domains
17365 transport = remote_smtp
17366 route_list = * smarthost.ref.example
17367
17368 This causes all non-local addresses to be sent to the single host
17369 smarthost.ref.example. If a colon-separated list of smart hosts is given,
17370 they are tried in order (but you can use hosts_randomize to vary the order
17371 each time). Another way of configuring the same thing is this:
17372
17373 smart_route:
17374 driver = manualroute
17375 transport = remote_smtp
17376 route_list = !+local_domains smarthost.ref.example
17377
17378 There is no difference in behaviour between these two routers as they
17379 stand. However, they behave differently if no_more is added to them. In the
17380 first example, the router is skipped if the domain does not match the
17381 domains precondition; the following router is always tried. If the router
17382 runs, it always matches the domain and so can never decline. Therefore,
17383 no_more would have no effect. In the second case, the router is never
17384 skipped; it always runs. However, if it doesn't match the domain, it
17385 declines. In this case no_more would prevent subsequent routers from
17386 running.
17387
17388 * A mail hub is a host which receives mail for a number of domains via MX
17389 records in the DNS and delivers it via its own private routing mechanism.
17390 Often the final destinations are behind a firewall, with the mail hub being
17391 the one machine that can connect to machines both inside and outside the
17392 firewall. The manualroute router is usually used on a mail hub to route
17393 incoming messages to the correct hosts. For a small number of domains, the
17394 routing can be inline, using the route_list option, but for a larger number
17395 a file or database lookup is easier to manage.
17396
17397 If the domain names are in fact the names of the machines to which the mail
17398 is to be sent by the mail hub, the configuration can be quite simple. For
17399 example:
17400
17401 hub_route:
17402 driver = manualroute
17403 transport = remote_smtp
17404 route_list = *.rhodes.tvs.example $domain
17405
17406 This configuration routes domains that match "*.rhodes.tvs.example" to
17407 hosts whose names are the same as the mail domains. A similar approach can
17408 be taken if the host name can be obtained from the domain name by a string
17409 manipulation that the expansion facilities can handle. Otherwise, a lookup
17410 based on the domain can be used to find the host:
17411
17412 through_firewall:
17413 driver = manualroute
17414 transport = remote_smtp
17415 route_data = ${lookup {$domain} cdb {/internal/host/routes}}
17416
17417 The result of the lookup must be the name or IP address of the host (or
17418 hosts) to which the address is to be routed. If the lookup fails, the route
17419 data is empty, causing the router to decline. The address then passes to
17420 the next router.
17421
17422 * You can use manualroute to deliver messages to pipes or files in batched
17423 SMTP format for onward transportation by some other means. This is one way
17424 of storing mail for a dial-up host when it is not connected. The route list
17425 entry can be as simple as a single domain name in a configuration like
17426 this:
17427
17428 save_in_file:
17429 driver = manualroute
17430 transport = batchsmtp_appendfile
17431 route_list = saved.domain.example
17432
17433 though often a pattern is used to pick up more than one domain. If there
17434 are several domains or groups of domains with different transport
17435 requirements, different transports can be listed in the routing
17436 information:
17437
17438 save_in_file:
17439 driver = manualroute
17440 route_list = \
17441 *.saved.domain1.example $domain batch_appendfile; \
17442 *.saved.domain2.example \
17443 ${lookup{$domain}dbm{/domain2/hosts}{$value}fail} \
17444 batch_pipe
17445
17446 The first of these just passes the domain in the $host variable, which
17447 doesn't achieve much (since it is also in $domain), but the second does a
17448 file lookup to find a value to pass, causing the router to decline to
17449 handle the address if the lookup fails.
17450
17451 * Routing mail directly to UUCP software is a specific case of the use of
17452 manualroute in a gateway to another mail environment. This is an example of
17453 one way it can be done:
17454
17455 # Transport
17456 uucp:
17457 driver = pipe
17458 user = nobody
17459 command = /usr/local/bin/uux -r - \
17460 ${substr_-5:$host}!rmail ${local_part}
17461 return_fail_output = true
17462
17463 # Router
17464 uucphost:
17465 transport = uucp
17466 driver = manualroute
17467 route_data = \
17468 ${lookup{$domain}lsearch{/usr/local/exim/uucphosts}}
17469
17470 The file /usr/local/exim/uucphosts contains entries like
17471
17472 darksite.ethereal.example: darksite.UUCP
17473
17474 It can be set up more simply without adding and removing ".UUCP" but this
17475 way makes clear the distinction between the domain name
17476 darksite.ethereal.example and the UUCP host name darksite.
17477
17478
17479
17480===============================================================================
1748121. THE QUERYPROGRAM ROUTER
17482
17483The queryprogram router routes an address by running an external command and
17484acting on its output. This is an expensive way to route, and is intended mainly
17485for use in lightly-loaded systems, or for performing experiments. However, if
17486it is possible to use the precondition options (domains, local_parts, etc) to
17487skip this router for most addresses, it could sensibly be used in special
17488cases, even on a busy host. There are the following private options:
17489
17490+-------+-----------------+-------------+--------------+
17491|command|Use: queryprogram|Type: string*|Default: unset|
17492+-------+-----------------+-------------+--------------+
17493
17494This option must be set. It specifies the command that is to be run. The
17495command is split up into a command name and arguments, and then each is
17496expanded separately (exactly as for a pipe transport, described in chapter 29).
17497
17498+-------------+-----------------+------------+--------------+
17499|command_group|Use: queryprogram|Type: string|Default: unset|
17500+-------------+-----------------+------------+--------------+
17501
17502This option specifies a gid to be set when running the command while routing an
17503address for deliver. It must be set if command_user specifies a numerical uid.
17504If it begins with a digit, it is interpreted as the numerical value of the gid.
17505Otherwise it is looked up using getgrnam().
17506
17507+------------+-----------------+------------+--------------+
17508|command_user|Use: queryprogram|Type: string|Default: unset|
17509+------------+-----------------+------------+--------------+
17510
17511This option must be set. It specifies the uid which is set when running the
17512command while routing an address for delivery. If the value begins with a
17513digit, it is interpreted as the numerical value of the uid. Otherwise, it is
17514looked up using getpwnam() to obtain a value for the uid and, if command_group
17515is not set, a value for the gid also.
17516
17517Warning: Changing uid and gid is possible only when Exim is running as root,
17518which it does during a normal delivery in a conventional configuration.
17519However, when an address is being verified during message reception, Exim is
17520usually running as the Exim user, not as root. If the queryprogram router is
17521called from a non-root process, Exim cannot change uid or gid before running
17522the command. In this circumstance the command runs under the current uid and
17523gid.
17524
17525+-----------------+-----------------+------------+----------+
17526|current_directory|Use: queryprogram|Type: string|Default: /|
17527+-----------------+-----------------+------------+----------+
17528
17529This option specifies an absolute path which is made the current directory
17530before running the command.
17531
17532+-------+-----------------+----------+-----------+
17533|timeout|Use: queryprogram|Type: time|Default: 1h|
17534+-------+-----------------+----------+-----------+
17535
17536If the command does not complete within the timeout period, its process group
17537is killed and the message is frozen. A value of zero time specifies no timeout.
17538
17539The standard output of the command is connected to a pipe, which is read when
17540the command terminates. It should consist of a single line of output,
17541containing up to five fields, separated by white space. The maximum length of
17542the line is 1023 characters. Longer lines are silently truncated. The first
17543field is one of the following words (case-insensitive):
17544
17545 * Accept: routing succeeded; the remaining fields specify what to do (see
17546 below).
17547
17548 * Decline: the router declines; pass the address to the next router, unless
17549 no_more is set.
17550
17551 * Fail: routing failed; do not pass the address to any more routers. Any
17552 subsequent text on the line is an error message. If the router is run as
17553 part of address verification during an incoming SMTP message, the message
17554 is included in the SMTP response.
17555
17556 * Defer: routing could not be completed at this time; try again later. Any
17557 subsequent text on the line is an error message which is logged. It is not
17558 included in any SMTP response.
17559
17560 * Freeze: the same as defer, except that the message is frozen.
17561
17562 * Pass: pass the address to the next router (or the router specified by
17563 pass_router), overriding no_more.
17564
17565 * Redirect: the message is redirected. The remainder of the line is a list of
17566 new addresses, which are routed independently, starting with the first
17567 router, or the router specified by redirect_router, if set.
17568
17569When the first word is accept, the remainder of the line consists of a number
17570of keyed data values, as follows (split into two lines here, to fit on the
17571page):
17572
17573ACCEPT TRANSPORT=<transport> HOSTS=<list of hosts>
17574LOOKUP=byname|bydns DATA=<text>
17575
17576The data items can be given in any order, and all are optional. If no transport
17577is included, the transport specified by the generic transport option is used.
17578The list of hosts and the lookup type are needed only if the transport is an
17579smtp transport that does not itself supply a list of hosts.
17580
17581The format of the list of hosts is the same as for the manualroute router. As
17582well as host names and IP addresses with optional port numbers, as described in
17583section 20.5, it may contain names followed by "/MX" to specify sublists of
17584hosts that are obtained by looking up MX records (see section 20.6).
17585
17586If the lookup type is not specified, Exim behaves as follows when trying to
17587find an IP address for each host: First, a DNS lookup is done. If this yields
17588anything other than HOST_NOT_FOUND, that result is used. Otherwise, Exim goes
17589on to try a call to getipnodebyname() or gethostbyname(), and the result of the
17590lookup is the result of that call.
17591
17592If the DATA field is set, its value is placed in the $address_data variable.
17593For example, this return line
17594
17595accept hosts=x1.y.example:x2.y.example data="rule1"
17596
17597routes the address to the default transport, passing a list of two hosts. When
17598the transport runs, the string "rule1" is in $address_data.
17599
17600
17601
17602===============================================================================
1760322. THE REDIRECT ROUTER
17604
17605The redirect router handles several kinds of address redirection. Its most
17606common uses are for resolving local part aliases from a central alias file
17607(usually called /etc/aliases) and for handling users' personal .forward files,
17608but it has many other potential uses. The incoming address can be redirected in
17609several different ways:
17610
17611 * It can be replaced by one or more new addresses which are themselves routed
17612 independently.
17613
17614 * It can be routed to be delivered to a given file or directory.
17615
17616 * It can be routed to be delivered to a specified pipe command.
17617
17618 * It can cause an automatic reply to be generated.
17619
17620 * It can be forced to fail, optionally with a custom error message.
17621
17622 * It can be temporarily deferred, optionally with a custom message.
17623
17624 * It can be discarded.
17625
17626The generic transport option must not be set for redirect routers. However,
17627there are some private options which define transports for delivery to files
17628and pipes, and for generating autoreplies. See the file_transport,
17629pipe_transport and reply_transport descriptions below.
17630
17631
1763222.1 Redirection data
17633---------------------
17634
17635The router operates by interpreting a text string which it obtains either by
17636expanding the contents of the data option, or by reading the entire contents of
17637a file whose name is given in the file option. These two options are mutually
17638exclusive. The first is commonly used for handling system aliases, in a
17639configuration like this:
17640
17641system_aliases:
17642 driver = redirect
17643 data = ${lookup{$local_part}lsearch{/etc/aliases}}
17644
17645If the lookup fails, the expanded string in this example is empty. When the
17646expansion of data results in an empty string, the router declines. A forced
17647expansion failure also causes the router to decline; other expansion failures
17648cause delivery to be deferred.
17649
17650A configuration using file is commonly used for handling users' .forward files,
17651like this:
17652
17653userforward:
17654 driver = redirect
17655 check_local_user
17656 file = $home/.forward
17657 no_verify
17658
17659If the file does not exist, or causes no action to be taken (for example, it is
17660empty or consists only of comments), the router declines. Warning: This is not
17661the case when the file contains syntactically valid items that happen to yield
17662empty addresses, for example, items containing only RFC 2822 address comments.
17663
17664
1766522.2 Forward files and address verification
17666-------------------------------------------
17667
17668It is usual to set no_verify on redirect routers which handle users' .forward
17669files, as in the example above. There are two reasons for this:
17670
17671 * When Exim is receiving an incoming SMTP message from a remote host, it is
17672 running under the Exim uid, not as root. Exim is unable to change uid to
17673 read the file as the user, and it may not be able to read it as the Exim
17674 user. So in practice the router may not be able to operate.
17675
17676 * However, even when the router can operate, the existence of a .forward file
17677 is unimportant when verifying an address. What should be checked is whether
17678 the local part is a valid user name or not. Cutting out the redirection
17679 processing saves some resources.
17680
17681
1768222.3 Interpreting redirection data
17683----------------------------------
17684
17685The contents of the data string, whether obtained from data or file, can be
17686interpreted in two different ways:
17687
17688 * If the allow_filter option is set true, and the data begins with the text "
17689 #Exim filter" or "#Sieve filter", it is interpreted as a list of filtering
17690 instructions in the form of an Exim or Sieve filter file, respectively.
17691 Details of the syntax and semantics of filter files are described in a
17692 separate document entitled Exim's interfaces to mail filtering; this
17693 document is intended for use by end users.
17694
17695 * Otherwise, the data must be a comma-separated list of redirection items, as
17696 described in the next section.
17697
17698When a message is redirected to a file (a "mail folder"), the file name given
17699in a non-filter redirection list must always be an absolute path. A filter may
17700generate a relative path - how this is handled depends on the transport's
17701configuration. See section 26.1 for a discussion of this issue for the
17702appendfile transport.
17703
17704
1770522.4 Items in a non-filter redirection list
17706-------------------------------------------
17707
17708When the redirection data is not an Exim or Sieve filter, for example, if it
17709comes from a conventional alias or forward file, it consists of a list of
17710addresses, file names, pipe commands, or certain special items (see section
1771122.6 below). The special items can be individually enabled or disabled by means
17712of options whose names begin with allow_ or forbid_, depending on their default
17713values. The items in the list are separated by commas or newlines. If a comma
17714is required in an item, the entire item must be enclosed in double quotes.
17715
17716Lines starting with a # character are comments, and are ignored, and # may also
17717appear following a comma, in which case everything between the # and the next
17718newline character is ignored.
17719
17720If an item is entirely enclosed in double quotes, these are removed. Otherwise
17721double quotes are retained because some forms of mail address require their use
17722(but never to enclose the entire address). In the following description, "item"
17723refers to what remains after any surrounding double quotes have been removed.
17724
17725Warning: If you use an Exim expansion to construct a redirection address, and
17726the expansion contains a reference to $local_part, you should make use of the
17727quote_local_part expansion operator, in case the local part contains special
17728characters. For example, to redirect all mail for the domain obsolete.example,
17729retaining the existing local part, you could use this setting:
17730
17731data = ${quote_local_part:$local_part}@newdomain.example
17732
17733
1773422.5 Redirecting to a local mailbox
17735-----------------------------------
17736
17737A redirection item may safely be the same as the address currently under
17738consideration. This does not cause a routing loop, because a router is
17739automatically skipped if any ancestor of the address that is being processed is
17740the same as the current address and was processed by the current router. Such
17741an address is therefore passed to the following routers, so it is handled as if
17742there were no redirection. When making this loop-avoidance test, the complete
17743local part, including any prefix or suffix, is used.
17744
17745Specifying the same local part without a domain is a common usage in personal
17746filter files when the user wants to have messages delivered to the local
17747mailbox and also forwarded elsewhere. For example, the user whose login is cleo
17748might have a .forward file containing this:
17749
17750cleo, cleopatra@egypt.example
17751
17752For compatibility with other MTAs, such unqualified local parts may be preceded
17753by "\", but this is not a requirement for loop prevention. However, it does
17754make a difference if more than one domain is being handled synonymously.
17755
17756If an item begins with "\" and the rest of the item parses as a valid RFC 2822
17757address that does not include a domain, the item is qualified using the domain
17758of the incoming address. In the absence of a leading "\", unqualified addresses
17759are qualified using the value in qualify_recipient, but you can force the
17760incoming domain to be used by setting qualify_preserve_domain.
17761
17762Care must be taken if there are alias names for local users. Consider an MTA
17763handling a single local domain where the system alias file contains:
17764
17765Sam.Reman: spqr
17766
17767Now suppose that Sam (whose login id is spqr) wants to save copies of messages
17768in the local mailbox, and also forward copies elsewhere. He creates this
17769forward file:
17770
17771Sam.Reman, spqr@reme.elsewhere.example
17772
17773With these settings, an incoming message addressed to Sam.Reman fails. The
17774redirect router for system aliases does not process Sam.Reman the second time
17775round, because it has previously routed it, and the following routers
17776presumably cannot handle the alias. The forward file should really contain
17777
17778spqr, spqr@reme.elsewhere.example
17779
17780but because this is such a common error, the check_ancestor option (see below)
17781exists to provide a way to get round it. This is normally set on a redirect
17782router that is handling users' .forward files.
17783
17784
1778522.6 Special items in redirection lists
17786---------------------------------------
17787
17788In addition to addresses, the following types of item may appear in redirection
17789lists (that is, in non-filter redirection data):
17790
17791 * An item is treated as a pipe command if it begins with "|" and does not
17792 parse as a valid RFC 2822 address that includes a domain. A transport for
17793 running the command must be specified by the pipe_transport option.
17794 Normally, either the router or the transport specifies a user and a group
17795 under which to run the delivery. The default is to use the Exim user and
17796 group.
17797
17798 Single or double quotes can be used for enclosing the individual arguments
17799 of the pipe command; no interpretation of escapes is done for single
17800 quotes. If the command contains a comma character, it is necessary to put
17801 the whole item in double quotes, for example:
17802
17803 "|/some/command ready,steady,go"
17804
17805 since items in redirection lists are terminated by commas. Do not, however,
17806 quote just the command. An item such as
17807
17808 |"/some/command ready,steady,go"
17809
17810 is interpreted as a pipe with a rather strange command name, and no
17811 arguments.
17812
17813 Note that the above example assumes that the text comes from a lookup
17814 source of some sort, so that the quotes are part of the data. If composing
17815 a redirect router with a data option directly specifying this command, the
17816 quotes will be used by the configuration parser to define the extent of one
17817 string, but will not be passed down into the redirect router itself. There
17818 are two main approaches to get around this: escape quotes to be part of the
17819 data itself, or avoid using this mechanism and instead create a custom
17820 transport with the command option set and reference that transport from an
17821 accept router.
17822
17823 * An item is interpreted as a path name if it begins with "/" and does not
17824 parse as a valid RFC 2822 address that includes a domain. For example,
17825
17826 /home/world/minbari
17827
17828 is treated as a file name, but
17829
17830 /s=molari/o=babylon/@x400gate.way
17831
17832 is treated as an address. For a file name, a transport must be specified
17833 using the file_transport option. However, if the generated path name ends
17834 with a forward slash character, it is interpreted as a directory name
17835 rather than a file name, and directory_transport is used instead.
17836
17837 Normally, either the router or the transport specifies a user and a group
17838 under which to run the delivery. The default is to use the Exim user and
17839 group.
17840
17841 However, if a redirection item is the path /dev/null, delivery to it is
17842 bypassed at a high level, and the log entry shows "**bypassed**" instead of
17843 a transport name. In this case the user and group are not used.
17844
17845 * If an item is of the form
17846
17847 :include:<path name>
17848
17849 a list of further items is taken from the given file and included at that
17850 point. Note: Such a file can not be a filter file; it is just an
17851 out-of-line addition to the list. The items in the included list are
17852 separated by commas or newlines and are not subject to expansion. If this
17853 is the first item in an alias list in an lsearch file, a colon must be used
17854 to terminate the alias name. This example is incorrect:
17855
17856 list1 :include:/opt/lists/list1
17857
17858 It must be given as
17859
17860 list1: :include:/opt/lists/list1
17861
17862 * Sometimes you want to throw away mail to a particular local part. Making
17863 the data option expand to an empty string does not work, because that
17864 causes the router to decline. Instead, the alias item :blackhole: can be
17865 used. It does what its name implies. No delivery is done, and no error
17866 message is generated. This has the same effect as specifing /dev/null as a
17867 destination, but it can be independently disabled.
17868
17869 Warning: If :blackhole: appears anywhere in a redirection list, no delivery
17870 is done for the original local part, even if other redirection items are
17871 present. If you are generating a multi-item list (for example, by reading a
17872 database) and need the ability to provide a no-op item, you must use /dev/
17873 null.
17874
17875 * An attempt to deliver a particular address can be deferred or forced to
17876 fail by redirection items of the form
17877
17878 :defer:
17879 :fail:
17880
17881 respectively. When a redirection list contains such an item, it applies to
17882 the entire redirection; any other items in the list are ignored. Any text
17883 following :fail: or :defer: is placed in the error text associated with the
17884 failure. For example, an alias file might contain:
17885
17886 X.Employee: :fail: Gone away, no forwarding address
17887
17888 In the case of an address that is being verified from an ACL or as the
17889 subject of a VRFY command, the text is included in the SMTP error response
17890 by default. The text is not included in the response to an EXPN command. In
17891 non-SMTP cases the text is included in the error message that Exim
17892 generates.
17893
17894 By default, Exim sends a 451 SMTP code for a :defer:, and 550 for :fail:.
17895 However, if the message starts with three digits followed by a space,
17896 optionally followed by an extended code of the form n.n.n, also followed by
17897 a space, and the very first digit is the same as the default error code,
17898 the code from the message is used instead. If the very first digit is
17899 incorrect, a panic error is logged, and the default code is used. You can
17900 suppress the use of the supplied code in a redirect router by setting the
17901 forbid_smtp_code option true. In this case, any SMTP code is quietly
17902 ignored.
17903
17904 In an ACL, an explicitly provided message overrides the default, but the
17905 default message is available in the variable $acl_verify_message and can
17906 therefore be included in a custom message if this is desired.
17907
17908 Normally the error text is the rest of the redirection list - a comma does
17909 not terminate it - but a newline does act as a terminator. Newlines are not
17910 normally present in alias expansions. In lsearch lookups they are removed
17911 as part of the continuation process, but they may exist in other kinds of
17912 lookup and in :include: files.
17913
17914 During routing for message delivery (as opposed to verification), a
17915 redirection containing :fail: causes an immediate failure of the incoming
17916 address, whereas :defer: causes the message to remain on the queue so that
17917 a subsequent delivery attempt can happen at a later time. If an address is
17918 deferred for too long, it will ultimately fail, because the normal retry
17919 rules still apply.
17920
17921 * Sometimes it is useful to use a single-key search type with a default (see
17922 chapter 9) to look up aliases. However, there may be a need for exceptions
17923 to the default. These can be handled by aliasing them to :unknown:. This
17924 differs from :fail: in that it causes the redirect router to decline,
17925 whereas :fail: forces routing to fail. A lookup which results in an empty
17926 redirection list has the same effect.
17927
17928
1792922.7 Duplicate addresses
17930------------------------
17931
17932Exim removes duplicate addresses from the list to which it is delivering, so as
17933to deliver just one copy to each address. This does not apply to deliveries
17934routed to pipes by different immediate parent addresses, but an indirect
17935aliasing scheme of the type
17936
17937pipe: |/some/command $local_part
17938localpart1: pipe
17939localpart2: pipe
17940
17941does not work with a message that is addressed to both local parts, because
17942when the second is aliased to the intermediate local part "pipe" it gets
17943discarded as being the same as a previously handled address. However, a scheme
17944such as
17945
17946localpart1: |/some/command $local_part
17947localpart2: |/some/command $local_part
17948
17949does result in two different pipe deliveries, because the immediate parents of
17950the pipes are distinct.
17951
17952
1795322.8 Repeated redirection expansion
17954-----------------------------------
17955
17956When a message cannot be delivered to all of its recipients immediately,
17957leading to two or more delivery attempts, redirection expansion is carried out
17958afresh each time for those addresses whose children were not all previously
17959delivered. If redirection is being used as a mailing list, this can lead to new
17960members of the list receiving copies of old messages. The one_time option can
17961be used to avoid this.
17962
17963
1796422.9 Errors in redirection lists
17965--------------------------------
17966
17967If skip_syntax_errors is set, a malformed address that causes a parsing error
17968is skipped, and an entry is written to the main log. This may be useful for
17969mailing lists that are automatically managed. Otherwise, if an error is
17970detected while generating the list of new addresses, the original address is
17971deferred. See also syntax_errors_to.
17972
17973
1797422.10 Private options for the redirect router
17975---------------------------------------------
17976
17977The private options for the redirect router are as follows:
17978
17979+-----------+-------------+-------------+--------------+
17980|allow_defer|Use: redirect|Type: boolean|Default: false|
17981+-----------+-------------+-------------+--------------+
17982
17983Setting this option allows the use of :defer: in non-filter redirection data,
17984or the defer command in an Exim filter file.
17985
17986+----------+-------------+-------------+--------------+
17987|allow_fail|Use: redirect|Type: boolean|Default: false|
17988+----------+-------------+-------------+--------------+
17989
17990If this option is true, the :fail: item can be used in a redirection list, and
17991the fail command may be used in an Exim filter file.
17992
17993+------------+-------------+-------------+--------------+
17994|allow_filter|Use: redirect|Type: boolean|Default: false|
17995+------------+-------------+-------------+--------------+
17996
17997Setting this option allows Exim to interpret redirection data that starts with
17998"#Exim filter" or "#Sieve filter" as a set of filtering instructions. There are
17999some features of Exim filter files that some administrators may wish to lock
18000out; see the forbid_filter_xxx options below.
18001
18002It is also possible to lock out Exim filters or Sieve filters while allowing
18003the other type; see forbid_exim_filter and forbid_sieve_filter.
18004
18005The filter is run using the uid and gid set by the generic user and group
18006options. These take their defaults from the password data if check_local_user
18007is set, so in the normal case of users' personal filter files, the filter is
18008run as the relevant user. When allow_filter is set true, Exim insists that
18009either check_local_user or user is set.
18010
18011+------------+-------------+-------------+--------------+
18012|allow_freeze|Use: redirect|Type: boolean|Default: false|
18013+------------+-------------+-------------+--------------+
18014
18015Setting this option allows the use of the freeze command in an Exim filter.
18016This command is more normally encountered in system filters, and is disabled by
18017default for redirection filters because it isn't something you usually want to
18018let ordinary users do.
18019
18020+--------------+-------------+-------------+--------------+
18021|check_ancestor|Use: redirect|Type: boolean|Default: false|
18022+--------------+-------------+-------------+--------------+
18023
18024This option is concerned with handling generated addresses that are the same as
18025some address in the list of redirection ancestors of the current address.
18026Although it is turned off by default in the code, it is set in the default
18027configuration file for handling users' .forward files. It is recommended for
18028this use of the redirect router.
18029
18030When check_ancestor is set, if a generated address (including the domain) is
18031the same as any ancestor of the current address, it is replaced by a copy of
18032the current address. This helps in the case where local part A is aliased to B,
18033and B has a .forward file pointing back to A. For example, within a single
18034domain, the local part "Joe.Bloggs" is aliased to "jb" and jb/.forward
18035contains:
18036
18037\Joe.Bloggs, <other item(s)>
18038
18039Without the check_ancestor setting, either local part ("jb" or "joe.bloggs")
18040gets processed once by each router and so ends up as it was originally. If "jb"
18041is the real mailbox name, mail to "jb" gets delivered (having been turned into
18042"joe.bloggs" by the .forward file and back to "jb" by the alias), but mail to
18043"joe.bloggs" fails. Setting check_ancestor on the redirect router that handles
18044the .forward file prevents it from turning "jb" back into "joe.bloggs" when
18045that was the original address. See also the repeat_use option below.
18046
18047+-----------+-------------+-------------+------------------+
18048|check_group|Use: redirect|Type: boolean|Default: see below|
18049+-----------+-------------+-------------+------------------+
18050
18051When the file option is used, the group owner of the file is checked only when
18052this option is set. The permitted groups are those listed in the owngroups
18053option, together with the user's default group if check_local_user is set. If
18054the file has the wrong group, routing is deferred. The default setting for this
18055option is true if check_local_user is set and the modemask option permits the
18056group write bit, or if the owngroups option is set. Otherwise it is false, and
18057no group check occurs.
18058
18059+-----------+-------------+-------------+------------------+
18060|check_owner|Use: redirect|Type: boolean|Default: see below|
18061+-----------+-------------+-------------+------------------+
18062
18063When the file option is used, the owner of the file is checked only when this
18064option is set. If check_local_user is set, the local user is permitted;
18065otherwise the owner must be one of those listed in the owners option. The
18066default value for this option is true if check_local_user or owners is set.
18067Otherwise the default is false, and no owner check occurs.
18068
18069+----+-------------+-------------+--------------+
18070|data|Use: redirect|Type: string*|Default: unset|
18071+----+-------------+-------------+--------------+
18072
18073This option is mutually exclusive with file. One or other of them must be set,
18074but not both. The contents of data are expanded, and then used as the list of
18075forwarding items, or as a set of filtering instructions. If the expansion is
18076forced to fail, or the result is an empty string or a string that has no effect
18077(consists entirely of comments), the router declines.
18078
18079When filtering instructions are used, the string must begin with "#Exim
18080filter", and all comments in the string, including this initial one, must be
18081terminated with newline characters. For example:
18082
18083data = #Exim filter\n\
18084 if $h_to: contains Exim then save $home/mail/exim endif
18085
18086If you are reading the data from a database where newlines cannot be included,
18087you can use the ${sg} expansion item to turn the escape string of your choice
18088into a newline.
18089
18090+-------------------+-------------+-------------+--------------+
18091|directory_transport|Use: redirect|Type: string*|Default: unset|
18092+-------------------+-------------+-------------+--------------+
18093
18094A redirect router sets up a direct delivery to a directory when a path name
18095ending with a slash is specified as a new "address". The transport used is
18096specified by this option, which, after expansion, must be the name of a
18097configured transport. This should normally be an appendfile transport.
18098
18099+----+-------------+-------------+--------------+
18100|file|Use: redirect|Type: string*|Default: unset|
18101+----+-------------+-------------+--------------+
18102
18103This option specifies the name of a file that contains the redirection data. It
18104is mutually exclusive with the data option. The string is expanded before use;
18105if the expansion is forced to fail, the router declines. Other expansion
18106failures cause delivery to be deferred. The result of a successful expansion
18107must be an absolute path. The entire file is read and used as the redirection
18108data. If the data is an empty string or a string that has no effect (consists
18109entirely of comments), the router declines.
18110
18111If the attempt to open the file fails with a "does not exist" error, Exim runs
18112a check on the containing directory, unless ignore_enotdir is true (see below).
18113If the directory does not appear to exist, delivery is deferred. This can
18114happen when users' .forward files are in NFS-mounted directories, and there is
18115a mount problem. If the containing directory does exist, but the file does not,
18116the router declines.
18117
18118+--------------+-------------+-------------+--------------+
18119|file_transport|Use: redirect|Type: string*|Default: unset|
18120+--------------+-------------+-------------+--------------+
18121
18122A redirect router sets up a direct delivery to a file when a path name not
18123ending in a slash is specified as a new "address". The transport used is
18124specified by this option, which, after expansion, must be the name of a
18125configured transport. This should normally be an appendfile transport. When it
18126is running, the file name is in $address_file.
18127
18128+-------------------+-------------+-------------+-------------+
18129|filter_prepend_home|Use: redirect|Type: boolean|Default: true|
18130+-------------------+-------------+-------------+-------------+
18131
18132When this option is true, if a save command in an Exim filter specifies a
18133relative path, and $home is defined, it is automatically prepended to the
18134relative path. If this option is set false, this action does not happen. The
18135relative path is then passed to the transport unmodified.
18136
18137+----------------+-------------+-------------+--------------+
18138|forbid_blackhole|Use: redirect|Type: boolean|Default: false|
18139+----------------+-------------+-------------+--------------+
18140
18141If this option is true, the :blackhole: item may not appear in a redirection
18142list.
18143
18144+------------------+-------------+-------------+--------------+
18145|forbid_exim_filter|Use: redirect|Type: boolean|Default: false|
18146+------------------+-------------+-------------+--------------+
18147
18148If this option is set true, only Sieve filters are permitted when allow_filter
18149is true.
18150
18151+-----------+-------------+-------------+--------------+
18152|forbid_file|Use: redirect|Type: boolean|Default: false|
18153+-----------+-------------+-------------+--------------+
18154
18155If this option is true, this router may not generate a new address that
18156specifies delivery to a local file or directory, either from a filter or from a
18157conventional forward file. This option is forced to be true if one_time is set.
18158It applies to Sieve filters as well as to Exim filters, but if true, it locks
18159out the Sieve's "keep" facility.
18160
18161+--------------------+-------------+-------------+--------------+
18162|forbid_filter_dlfunc|Use: redirect|Type: boolean|Default: false|
18163+--------------------+-------------+-------------+--------------+
18164
18165If this option is true, string expansions in Exim filters are not allowed to
18166make use of the dlfunc expansion facility to run dynamically loaded functions.
18167
18168+------------------------+-------------+-------------+--------------+
18169|forbid_filter_existstest|Use: redirect|Type: boolean|Default: false|
18170+------------------------+-------------+-------------+--------------+
18171
18172If this option is true, string expansions in Exim filters are not allowed to
18173make use of the exists condition or the stat expansion item.
18174
18175+----------------------+-------------+-------------+--------------+
18176|forbid_filter_logwrite|Use: redirect|Type: boolean|Default: false|
18177+----------------------+-------------+-------------+--------------+
18178
18179If this option is true, use of the logging facility in Exim filters is not
18180permitted. Logging is in any case available only if the filter is being run
18181under some unprivileged uid (which is normally the case for ordinary users'
18182.forward files).
18183
18184+--------------------+-------------+-------------+--------------+
18185|forbid_filter_lookup|Use: redirect|Type: boolean|Default: false|
18186+--------------------+-------------+-------------+--------------+
18187
18188If this option is true, string expansions in Exim filter files are not allowed
18189to make use of lookup items.
18190
18191+------------------+-------------+-------------+--------------+
18192|forbid_filter_perl|Use: redirect|Type: boolean|Default: false|
18193+------------------+-------------+-------------+--------------+
18194
18195This option has an effect only if Exim is built with embedded Perl support. If
18196it is true, string expansions in Exim filter files are not allowed to make use
18197of the embedded Perl support.
18198
18199+----------------------+-------------+-------------+--------------+
18200|forbid_filter_readfile|Use: redirect|Type: boolean|Default: false|
18201+----------------------+-------------+-------------+--------------+
18202
18203If this option is true, string expansions in Exim filter files are not allowed
18204to make use of readfile items.
18205
18206+------------------------+-------------+-------------+--------------+
18207|forbid_filter_readsocket|Use: redirect|Type: boolean|Default: false|
18208+------------------------+-------------+-------------+--------------+
18209
18210If this option is true, string expansions in Exim filter files are not allowed
18211to make use of readsocket items.
18212
18213+-------------------+-------------+-------------+--------------+
18214|forbid_filter_reply|Use: redirect|Type: boolean|Default: false|
18215+-------------------+-------------+-------------+--------------+
18216
18217If this option is true, this router may not generate an automatic reply
18218message. Automatic replies can be generated only from Exim or Sieve filter
18219files, not from traditional forward files. This option is forced to be true if
18220one_time is set.
18221
18222+-----------------+-------------+-------------+--------------+
18223|forbid_filter_run|Use: redirect|Type: boolean|Default: false|
18224+-----------------+-------------+-------------+--------------+
18225
18226If this option is true, string expansions in Exim filter files are not allowed
18227to make use of run items.
18228
18229+--------------+-------------+-------------+--------------+
18230|forbid_include|Use: redirect|Type: boolean|Default: false|
18231+--------------+-------------+-------------+--------------+
18232
18233If this option is true, items of the form
18234
18235:include:<path name>
18236
18237are not permitted in non-filter redirection lists.
18238
18239+-----------+-------------+-------------+--------------+
18240|forbid_pipe|Use: redirect|Type: boolean|Default: false|
18241+-----------+-------------+-------------+--------------+
18242
18243If this option is true, this router may not generate a new address which
18244specifies delivery to a pipe, either from an Exim filter or from a conventional
18245forward file. This option is forced to be true if one_time is set.
18246
18247+-------------------+-------------+-------------+--------------+
18248|forbid_sieve_filter|Use: redirect|Type: boolean|Default: false|
18249+-------------------+-------------+-------------+--------------+
18250
18251If this option is set true, only Exim filters are permitted when allow_filter
18252is true.
18253
18254+----------------+-------------+-------------+--------------+
18255|forbid_smtp_code|Use: redirect|Type: boolean|Default: false|
18256+----------------+-------------+-------------+--------------+
18257
18258If this option is set true, any SMTP error codes that are present at the start
18259of messages specified for ":defer:" or ":fail:" are quietly ignored, and the
18260default codes (451 and 550, respectively) are always used.
18261
18262+--------------------+-------------+-------------+--------------+
18263|hide_child_in_errmsg|Use: redirect|Type: boolean|Default: false|
18264+--------------------+-------------+-------------+--------------+
18265
18266If this option is true, it prevents Exim from quoting a child address if it
18267generates a bounce or delay message for it. Instead it says "an address
18268generated from <the top level address>". Of course, this applies only to
18269bounces generated locally. If a message is forwarded to another host, its
18270bounce may well quote the generated address.
18271
18272+-------------+-------------+-------------+--------------+
18273|ignore_eacces|Use: redirect|Type: boolean|Default: false|
18274+-------------+-------------+-------------+--------------+
18275
18276If this option is set and an attempt to open a redirection file yields the
18277EACCES error (permission denied), the redirect router behaves as if the file
18278did not exist.
18279
18280+--------------+-------------+-------------+--------------+
18281|ignore_enotdir|Use: redirect|Type: boolean|Default: false|
18282+--------------+-------------+-------------+--------------+
18283
18284If this option is set and an attempt to open a redirection file yields the
18285ENOTDIR error (something on the path is not a directory), the redirect router
18286behaves as if the file did not exist.
18287
18288Setting ignore_enotdir has another effect as well: When a redirect router that
18289has the file option set discovers that the file does not exist (the ENOENT
18290error), it tries to stat() the parent directory, as a check against unmounted
18291NFS directories. If the parent can not be statted, delivery is deferred.
18292However, it seems wrong to do this check when ignore_enotdir is set, because
18293that option tells Exim to ignore "something on the path is not a directory"
18294(the ENOTDIR error). This is a confusing area, because it seems that some
18295operating systems give ENOENT where others give ENOTDIR.
18296
18297+-----------------+-------------+------------+--------------+
18298|include_directory|Use: redirect|Type: string|Default: unset|
18299+-----------------+-------------+------------+--------------+
18300
18301If this option is set, the path names of any :include: items in a redirection
18302list must start with this directory.
18303
18304+--------+-------------+-------------------+------------+
18305|modemask|Use: redirect|Type: octal integer|Default: 022|
18306+--------+-------------+-------------------+------------+
18307
18308This specifies mode bits which must not be set for a file specified by the file
18309option. If any of the forbidden bits are set, delivery is deferred.
18310
18311+--------+-------------+-------------+--------------+
18312|one_time|Use: redirect|Type: boolean|Default: false|
18313+--------+-------------+-------------+--------------+
18314
18315Sometimes the fact that Exim re-evaluates aliases and reprocesses redirection
18316files each time it tries to deliver a message causes a problem when one or more
18317of the generated addresses fails be delivered at the first attempt. The problem
18318is not one of duplicate delivery - Exim is clever enough to handle that - but
18319of what happens when the redirection list changes during the time that the
18320message is on Exim's queue. This is particularly true in the case of mailing
18321lists, where new subscribers might receive copies of messages that were posted
18322before they subscribed.
18323
18324If one_time is set and any addresses generated by the router fail to deliver at
18325the first attempt, the failing addresses are added to the message as "top
18326level" addresses, and the parent address that generated them is marked
18327"delivered". Thus, redirection does not happen again at the next delivery
18328attempt.
18329
18330Warning 1: Any header line addition or removal that is specified by this router
18331would be lost if delivery did not succeed at the first attempt. For this
18332reason, the headers_add and headers_remove generic options are not permitted
18333when one_time is set.
18334
18335Warning 2: To ensure that the router generates only addresses (as opposed to
18336pipe or file deliveries or auto-replies) forbid_file, forbid_pipe, and
18337forbid_filter_reply are forced to be true when one_time is set.
18338
18339Warning 3: The unseen generic router option may not be set with one_time.
18340
18341The original top-level address is remembered with each of the generated
18342addresses, and is output in any log messages. However, any intermediate parent
18343addresses are not recorded. This makes a difference to the log only if
18344all_parents log selector is set. It is expected that one_time will typically be
18345used for mailing lists, where there is normally just one level of expansion.
18346
18347+------+-------------+-----------------+--------------+
18348|owners|Use: redirect|Type: string list|Default: unset|
18349+------+-------------+-----------------+--------------+
18350
18351This specifies a list of permitted owners for the file specified by file. This
18352list is in addition to the local user when check_local_user is set. See
18353check_owner above.
18354
18355+---------+-------------+-----------------+--------------+
18356|owngroups|Use: redirect|Type: string list|Default: unset|
18357+---------+-------------+-----------------+--------------+
18358
18359This specifies a list of permitted groups for the file specified by file. The
18360list is in addition to the local user's primary group when check_local_user is
18361set. See check_group above.
18362
18363+--------------+-------------+-------------+--------------+
18364|pipe_transport|Use: redirect|Type: string*|Default: unset|
18365+--------------+-------------+-------------+--------------+
18366
18367A redirect router sets up a direct delivery to a pipe when a string starting
18368with a vertical bar character is specified as a new "address". The transport
18369used is specified by this option, which, after expansion, must be the name of a
18370configured transport. This should normally be a pipe transport. When the
18371transport is run, the pipe command is in $address_pipe.
18372
18373+--------------+-------------+-------------+--------------+
18374|qualify_domain|Use: redirect|Type: string*|Default: unset|
18375+--------------+-------------+-------------+--------------+
18376
18377If this option is set, and an unqualified address (one without a domain) is
18378generated, and that address would normally be qualified by the global setting
18379in qualify_recipient, it is instead qualified with the domain specified by
18380expanding this string. If the expansion fails, the router declines. If you want
18381to revert to the default, you can have the expansion generate
18382$qualify_recipient.
18383
18384This option applies to all unqualified addresses generated by Exim filters, but
18385for traditional .forward files, it applies only to addresses that are not
18386preceded by a backslash. Sieve filters cannot generate unqualified addresses.
18387
18388+-----------------------+-------------+-------------+--------------+
18389|qualify_preserve_domain|Use: redirect|Type: boolean|Default: false|
18390+-----------------------+-------------+-------------+--------------+
18391
18392If this option is set, the router's local qualify_domain option must not be set
18393(a configuration error occurs if it is). If an unqualified address (one without
18394a domain) is generated, it is qualified with the domain of the parent address
18395(the immediately preceding ancestor) instead of the global qualify_recipient
18396value. In the case of a traditional .forward file, this applies whether or not
18397the address is preceded by a backslash.
18398
18399+----------+-------------+-------------+-------------+
18400|repeat_use|Use: redirect|Type: boolean|Default: true|
18401+----------+-------------+-------------+-------------+
18402
18403If this option is set false, the router is skipped for a child address that has
18404any ancestor that was routed by this router. This test happens before any of
18405the other preconditions are tested. Exim's default anti-looping rules skip only
18406when the ancestor is the same as the current address. See also check_ancestor
18407above and the generic redirect_router option.
18408
18409+---------------+-------------+-------------+--------------+
18410|reply_transport|Use: redirect|Type: string*|Default: unset|
18411+---------------+-------------+-------------+--------------+
18412
18413A redirect router sets up an automatic reply when a mail or vacation command is
18414used in a filter file. The transport used is specified by this option, which,
18415after expansion, must be the name of a configured transport. This should
18416normally be an autoreply transport. Other transports are unlikely to do
18417anything sensible or useful.
18418
18419+-------+-------------+-------------+-------------+
18420|rewrite|Use: redirect|Type: boolean|Default: true|
18421+-------+-------------+-------------+-------------+
18422
18423If this option is set false, addresses generated by the router are not subject
18424to address rewriting. Otherwise, they are treated like new addresses and are
18425rewritten according to the global rewriting rules.
18426
18427+----------------+-------------+-------------+--------------+
18428|sieve_subaddress|Use: redirect|Type: string*|Default: unset|
18429+----------------+-------------+-------------+--------------+
18430
18431The value of this option is passed to a Sieve filter to specify the :subaddress
18432part of an address.
18433
18434+-----------------+-------------+-------------+--------------+
18435|sieve_useraddress|Use: redirect|Type: string*|Default: unset|
18436+-----------------+-------------+-------------+--------------+
18437
18438The value of this option is passed to a Sieve filter to specify the :user part
18439of an address. However, if it is unset, the entire original local part
18440(including any prefix or suffix) is used for :user.
18441
18442+------------------------+-------------+-------------+--------------+
18443|sieve_vacation_directory|Use: redirect|Type: string*|Default: unset|
18444+------------------------+-------------+-------------+--------------+
18445
18446To enable the "vacation" extension for Sieve filters, you must set
18447sieve_vacation_directory to the directory where vacation databases are held (do
18448not put anything else in that directory), and ensure that the reply_transport
18449option refers to an autoreply transport. Each user needs their own directory;
18450Exim will create it if necessary.
18451
18452+------------------+-------------+-------------+--------------+
18453|skip_syntax_errors|Use: redirect|Type: boolean|Default: false|
18454+------------------+-------------+-------------+--------------+
18455
18456If skip_syntax_errors is set, syntactically malformed addresses in non-filter
18457redirection data are skipped, and each failing address is logged. If
18458syntax_errors_to is set, a message is sent to the address it defines, giving
18459details of the failures. If syntax_errors_text is set, its contents are
18460expanded and placed at the head of the error message generated by
18461syntax_errors_to. Usually it is appropriate to set syntax_errors_to to be the
18462same address as the generic errors_to option. The skip_syntax_errors option is
18463often used when handling mailing lists.
18464
18465If all the addresses in a redirection list are skipped because of syntax
18466errors, the router declines to handle the original address, and it is passed to
18467the following routers.
18468
18469If skip_syntax_errors is set when an Exim filter is interpreted, any syntax
18470error in the filter causes filtering to be abandoned without any action being
18471taken. The incident is logged, and the router declines to handle the address,
18472so it is passed to the following routers.
18473
18474Syntax errors in a Sieve filter file cause the "keep" action to occur. This
18475action is specified by RFC 3028. The values of skip_syntax_errors,
18476syntax_errors_to, and syntax_errors_text are not used.
18477
18478skip_syntax_errors can be used to specify that errors in users' forward lists
18479or filter files should not prevent delivery. The syntax_errors_to option, used
18480with an address that does not get redirected, can be used to notify users of
18481these errors, by means of a router like this:
18482
18483userforward:
18484 driver = redirect
18485 allow_filter
18486 check_local_user
18487 file = $home/.forward
18488 file_transport = address_file
18489 pipe_transport = address_pipe
18490 reply_transport = address_reply
18491 no_verify
18492 skip_syntax_errors
18493 syntax_errors_to = real-$local_part@$domain
18494 syntax_errors_text = \
18495 This is an automatically generated message. An error has\n\
18496 been found in your .forward file. Details of the error are\n\
18497 reported below. While this error persists, you will receive\n\
18498 a copy of this message for every message that is addressed\n\
18499 to you. If your .forward file is a filter file, or if it is\n\
18500 a non-filter file containing no valid forwarding addresses,\n\
18501 a copy of each incoming message will be put in your normal\n\
18502 mailbox. If a non-filter file contains at least one valid\n\
18503 forwarding address, forwarding to the valid addresses will\n\
18504 happen, and those will be the only deliveries that occur.
18505
18506You also need a router to ensure that local addresses that are prefixed by
18507"real-" are recognized, but not forwarded or filtered. For example, you could
18508put this immediately before the userforward router:
18509
18510real_localuser:
18511 driver = accept
18512 check_local_user
18513 local_part_prefix = real-
18514 transport = local_delivery
18515
18516For security, it would probably be a good idea to restrict the use of this
18517router to locally-generated messages, using a condition such as this:
18518
18519 condition = ${if match {$sender_host_address}\
18520 {\N^(|127\.0\.0\.1)$\N}}
18521
18522+------------------+-------------+-------------+--------------+
18523|syntax_errors_text|Use: redirect|Type: string*|Default: unset|
18524+------------------+-------------+-------------+--------------+
18525
18526See skip_syntax_errors above.
18527
18528+----------------+-------------+------------+--------------+
18529|syntax_errors_to|Use: redirect|Type: string|Default: unset|
18530+----------------+-------------+------------+--------------+
18531
18532See skip_syntax_errors above.
18533
18534
18535
18536===============================================================================
1853723. ENVIRONMENT FOR RUNNING LOCAL TRANSPORTS
18538
18539Local transports handle deliveries to files and pipes. (The autoreply transport
18540can be thought of as similar to a pipe.) Exim always runs transports in
18541subprocesses, under specified uids and gids. Typical deliveries to local
18542mailboxes run under the uid and gid of the local user.
18543
18544Exim also sets a specific current directory while running the transport; for
18545some transports a home directory setting is also relevant. The pipe transport
18546is the only one that sets up environment variables; see section 29.4 for
18547details.
18548
18549The values used for the uid, gid, and the directories may come from several
18550different places. In many cases, the router that handles the address associates
18551settings with that address as a result of its check_local_user, group, or user
18552options. However, values may also be given in the transport's own
18553configuration, and these override anything that comes from the router.
18554
18555
1855623.1 Concurrent deliveries
18557--------------------------
18558
18559If two different messages for the same local recipient arrive more or less
18560simultaneously, the two delivery processes are likely to run concurrently. When
18561the appendfile transport is used to write to a file, Exim applies locking rules
18562to stop concurrent processes from writing to the same file at the same time.
18563
18564However, when you use a pipe transport, it is up to you to arrange any locking
18565that is needed. Here is a silly example:
18566
18567my_transport:
18568 driver = pipe
18569 command = /bin/sh -c 'cat >>/some/file'
18570
18571This is supposed to write the message at the end of the file. However, if two
18572messages arrive at the same time, the file will be scrambled. You can use the
18573exim_lock utility program (see section 52.15) to lock a file using the same
18574algorithm that Exim itself uses.
18575
18576
1857723.2 Uids and gids
18578------------------
18579
18580All transports have the options group and user. If group is set, it overrides
18581any group that the router set in the address, even if user is not set for the
18582transport. This makes it possible, for example, to run local mail delivery
18583under the uid of the recipient (set by the router), but in a special group (set
18584by the transport). For example:
18585
18586# Routers ...
18587# User/group are set by check_local_user in this router
18588local_users:
18589 driver = accept
18590 check_local_user
18591 transport = group_delivery
18592
18593# Transports ...
18594# This transport overrides the group
18595group_delivery:
18596 driver = appendfile
18597 file = /var/spool/mail/$local_part
18598 group = mail
18599
18600If user is set for a transport, its value overrides what is set in the address
18601by the router. If user is non-numeric and group is not set, the gid associated
18602with the user is used. If user is numeric, group must be set.
18603
18604When the uid is taken from the transport's configuration, the initgroups()
18605function is called for the groups associated with that uid if the initgroups
18606option is set for the transport. When the uid is not specified by the
18607transport, but is associated with the address by a router, the option for
18608calling initgroups() is taken from the router configuration.
18609
18610The pipe transport contains the special option pipe_as_creator. If this is set
18611and user is not set, the uid of the process that called Exim to receive the
18612message is used, and if group is not set, the corresponding original gid is
18613also used.
18614
18615This is the detailed preference order for obtaining a gid; the first of the
18616following that is set is used:
18617
18618 * A group setting of the transport;
18619
18620 * A group setting of the router;
18621
18622 * A gid associated with a user setting of the router, either as a result of
18623 check_local_user or an explicit non-numeric user setting;
18624
18625 * The group associated with a non-numeric user setting of the transport;
18626
18627 * In a pipe transport, the creator's gid if deliver_as_creator is set and the
18628 uid is the creator's uid;
18629
18630 * The Exim gid if the Exim uid is being used as a default.
18631
18632If, for example, the user is specified numerically on the router and there are
18633no group settings, no gid is available. In this situation, an error occurs.
18634This is different for the uid, for which there always is an ultimate default.
18635The first of the following that is set is used:
18636
18637 * A user setting of the transport;
18638
18639 * In a pipe transport, the creator's uid if deliver_as_creator is set;
18640
18641 * A user setting of the router;
18642
18643 * A check_local_user setting of the router;
18644
18645 * The Exim uid.
18646
18647Of course, an error will still occur if the uid that is chosen is on the
18648never_users list.
18649
18650
1865123.3 Current and home directories
18652---------------------------------
18653
18654Routers may set current and home directories for local transports by means of
18655the transport_current_directory and transport_home_directory options. However,
18656if the transport's current_directory or home_directory options are set, they
18657override the router's values. In detail, the home directory for a local
18658transport is taken from the first of these values that is set:
18659
18660 * The home_directory option on the transport;
18661
18662 * The transport_home_directory option on the router;
18663
18664 * The password data if check_local_user is set on the router;
18665
18666 * The router_home_directory option on the router.
18667
18668The current directory is taken from the first of these values that is set:
18669
18670 * The current_directory option on the transport;
18671
18672 * The transport_current_directory option on the router.
18673
18674If neither the router nor the transport sets a current directory, Exim uses the
18675value of the home directory, if it is set. Otherwise it sets the current
18676directory to / before running a local transport.
18677
18678
1867923.4 Expansion variables derived from the address
18680-------------------------------------------------
18681
18682Normally a local delivery is handling a single address, and in that case the
18683variables such as $domain and $local_part are set during local deliveries.
18684However, in some circumstances more than one address may be handled at once
18685(for example, while writing batch SMTP for onward transmission by some other
18686means). In this case, the variables associated with the local part are never
18687set, $domain is set only if all the addresses have the same domain, and
18688$original_domain is never set.
18689
18690
18691
18692===============================================================================
1869324. GENERIC OPTIONS FOR TRANSPORTS
18694
18695The following generic options apply to all transports:
18696
18697+---------+---------------+-------------+--------------+
18698|body_only|Use: transports|Type: boolean|Default: false|
18699+---------+---------------+-------------+--------------+
18700
18701If this option is set, the message's headers are not transported. It is
18702mutually exclusive with headers_only. If it is used with the appendfile or pipe
18703transports, the settings of message_prefix and message_suffix should be
18704checked, because this option does not automatically suppress them.
18705
18706+-----------------+---------------+-------------+--------------+
18707|current_directory|Use: transports|Type: string*|Default: unset|
18708+-----------------+---------------+-------------+--------------+
18709
18710This specifies the current directory that is to be set while running the
18711transport, overriding any value that may have been set by the router. If the
18712expansion fails for any reason, including forced failure, an error is logged,
18713and delivery is deferred.
18714
18715+---------------+---------------+-------------+--------------+
18716|disable_logging|Use: transports|Type: boolean|Default: false|
18717+---------------+---------------+-------------+--------------+
18718
18719If this option is set true, nothing is logged for any deliveries by the
18720transport or for any transport errors. You should not set this option unless
18721you really, really know what you are doing.
18722
18723+-----------+---------------+-------------+--------------+
18724|debug_print|Use: transports|Type: string*|Default: unset|
18725+-----------+---------------+-------------+--------------+
18726
18727If this option is set and debugging is enabled (see the -d command line
18728option), the string is expanded and included in the debugging output when the
18729transport is run. If expansion of the string fails, the error message is
18730written to the debugging output, and Exim carries on processing. This facility
18731is provided to help with checking out the values of variables and so on when
18732debugging driver configurations. For example, if a headers_add option is not
18733working properly, debug_print could be used to output the variables it
18734references. A newline is added to the text if it does not end with one. The
18735variables $transport_name and $router_name contain the name of the transport
18736and the router that called it.
18737
18738+-----------------+---------------+-------------+--------------+
18739|delivery_date_add|Use: transports|Type: boolean|Default: false|
18740+-----------------+---------------+-------------+--------------+
18741
18742If this option is true, a Delivery-date: header is added to the message. This
18743gives the actual time the delivery was made. As this is not a standard header,
18744Exim has a configuration option (delivery_date_remove) which requests its
18745removal from incoming messages, so that delivered messages can safely be resent
18746to other recipients.
18747
18748+------+---------------+------------+--------------+
18749|driver|Use: transports|Type: string|Default: unset|
18750+------+---------------+------------+--------------+
18751
18752This specifies which of the available transport drivers is to be used. There is
18753no default, and this option must be set for every transport.
18754
18755+---------------+---------------+-------------+--------------+
18756|envelope_to_add|Use: transports|Type: boolean|Default: false|
18757+---------------+---------------+-------------+--------------+
18758
18759If this option is true, an Envelope-to: header is added to the message. This
18760gives the original address(es) in the incoming envelope that caused this
18761delivery to happen. More than one address may be present if the transport is
18762configured to handle several addresses at once, or if more than one original
18763address was redirected to the same final address. As this is not a standard
18764header, Exim has a configuration option (envelope_to_remove) which requests its
18765removal from incoming messages, so that delivered messages can safely be resent
18766to other recipients.
18767
18768+-----+---------------+-------------+-------------------+
18769|group|Use: transports|Type: string*|Default: Exim group|
18770+-----+---------------+-------------+-------------------+
18771
18772This option specifies a gid for running the transport process, overriding any
18773value that the router supplies, and also overriding any value associated with
18774user (see below).
18775
18776+-----------+---------------+-----------+--------------+
18777|headers_add|Use: transports|Type: list*|Default: unset|
18778+-----------+---------------+-----------+--------------+
18779
18780This option specifies a list of text headers, newline-separated, which are
18781(separately) expanded and added to the header portion of a message as it is
18782transported, as described in section 46.17. Additional header lines can also be
18783specified by routers. If the result of the expansion is an empty string, or if
18784the expansion is forced to fail, no action is taken. Other expansion failures
18785are treated as errors and cause the delivery to be deferred.
18786
18787Unlike most options, headers_add can be specified multiple times for a
18788transport; all listed headers are added.
18789
18790+------------+---------------+-------------+--------------+
18791|headers_only|Use: transports|Type: boolean|Default: false|
18792+------------+---------------+-------------+--------------+
18793
18794If this option is set, the message's body is not transported. It is mutually
18795exclusive with body_only. If it is used with the appendfile or pipe transports,
18796the settings of message_prefix and message_suffix should be checked, since this
18797option does not automatically suppress them.
18798
18799+--------------+---------------+-----------+--------------+
18800|headers_remove|Use: transports|Type: list*|Default: unset|
18801+--------------+---------------+-----------+--------------+
18802
18803This option specifies a list of header names, colon-separated; these headers
18804are omitted from the message as it is transported, as described in section
1880546.17. Header removal can also be specified by routers. Each list item is
18806separately expanded. If the result of the expansion is an empty string, or if
18807the expansion is forced to fail, no action is taken. Other expansion failures
18808are treated as errors and cause the delivery to be deferred.
18809
18810Unlike most options, headers_remove can be specified multiple times for a
18811router; all listed headers are removed.
18812
18813+---------------+---------------+------------+--------------+
18814|headers_rewrite|Use: transports|Type: string|Default: unset|
18815+---------------+---------------+------------+--------------+
18816
18817This option allows addresses in header lines to be rewritten at transport time,
18818that is, as the message is being copied to its destination. The contents of the
18819option are a colon-separated list of rewriting rules. Each rule is in exactly
18820the same form as one of the general rewriting rules that are applied when a
18821message is received. These are described in chapter 31. For example,
18822
18823headers_rewrite = a@b c@d f : \
18824 x@y w@z
18825
18826changes a@b into c@d in From: header lines, and x@y into w@z in all
18827address-bearing header lines. The rules are applied to the header lines just
18828before they are written out at transport time, so they affect only those copies
18829of the message that pass through the transport. However, only the message's
18830original header lines, and any that were added by a system filter, are
18831rewritten. If a router or transport adds header lines, they are not affected by
18832this option. These rewriting rules are not applied to the envelope. You can
18833change the return path using return_path, but you cannot change envelope
18834recipients at this time.
18835
18836+--------------+---------------+-------------+--------------+
18837|home_directory|Use: transports|Type: string*|Default: unset|
18838+--------------+---------------+-------------+--------------+
18839
18840This option specifies a home directory setting for a local transport,
18841overriding any value that may be set by the router. The home directory is
18842placed in $home while expanding the transport's private options. It is also
18843used as the current directory if no current directory is set by the
18844current_directory option on the transport or the transport_current_directory
18845option on the router. If the expansion fails for any reason, including forced
18846failure, an error is logged, and delivery is deferred.
18847
18848+----------+---------------+-------------+--------------+
18849|initgroups|Use: transports|Type: boolean|Default: false|
18850+----------+---------------+-------------+--------------+
18851
18852If this option is true and the uid for the delivery process is provided by the
18853transport, the initgroups() function is called when running the transport to
18854ensure that any additional groups associated with the uid are set up.
18855
18856+------------------+---------------+-------------+----------+
18857|message_size_limit|Use: transports|Type: string*|Default: 0|
18858+------------------+---------------+-------------+----------+
18859
18860This option controls the size of messages passed through the transport. It is
18861expanded before use; the result of the expansion must be a sequence of decimal
18862digits, optionally followed by K or M. If the expansion fails for any reason,
18863including forced failure, or if the result is not of the required form,
18864delivery is deferred. If the value is greater than zero and the size of a
18865message exceeds this limit, the address is failed. If there is any chance that
18866the resulting bounce message could be routed to the same transport, you should
18867ensure that return_size_limit is less than the transport's message_size_limit,
18868as otherwise the bounce message will fail to get delivered.
18869
18870+--------------------+---------------+-------------+--------------+
18871|rcpt_include_affixes|Use: transports|Type: boolean|Default: false|
18872+--------------------+---------------+-------------+--------------+
18873
18874When this option is false (the default), and an address that has had any
18875affixes (prefixes or suffixes) removed from the local part is delivered by any
18876form of SMTP or LMTP, the affixes are not included. For example, if a router
18877that contains
18878
18879local_part_prefix = *-
18880
18881routes the address abc-xyz@some.domain to an SMTP transport, the envelope is
18882delivered with
18883
18884RCPT TO:<xyz@some.domain>
18885
18886This is also the case when an ACL-time callout is being used to verify a
18887recipient address. However, if rcpt_include_affixes is set true, the whole
18888local part is included in the RCPT command. This option applies to BSMTP
18889deliveries by the appendfile and pipe transports as well as to the lmtp and
18890smtp transports.
18891
18892+--------------------+---------------+-------------+------------------+
18893|retry_use_local_part|Use: transports|Type: boolean|Default: see below|
18894+--------------------+---------------+-------------+------------------+
18895
18896When a delivery suffers a temporary failure, a retry record is created in
18897Exim's hints database. For remote deliveries, the key for the retry record is
18898based on the name and/or IP address of the failing remote host. For local
18899deliveries, the key is normally the entire address, including both the local
18900part and the domain. This is suitable for most common cases of local delivery
18901temporary failure - for example, exceeding a mailbox quota should delay only
18902deliveries to that mailbox, not to the whole domain.
18903
18904However, in some special cases you may want to treat a temporary local delivery
18905as a failure associated with the domain, and not with a particular local part.
18906(For example, if you are storing all mail for some domain in files.) You can do
18907this by setting retry_use_local_part false.
18908
18909For all the local transports, its default value is true. For remote transports,
18910the default value is false for tidiness, but changing the value has no effect
18911on a remote transport in the current implementation.
18912
18913+-----------+---------------+-------------+--------------+
18914|return_path|Use: transports|Type: string*|Default: unset|
18915+-----------+---------------+-------------+--------------+
18916
18917If this option is set, the string is expanded at transport time and replaces
18918the existing return path (envelope sender) value in the copy of the message
18919that is being delivered. An empty return path is permitted. This feature is
18920designed for remote deliveries, where the value of this option is used in the
18921SMTP MAIL command. If you set return_path for a local transport, the only
18922effect is to change the address that is placed in the Return-path: header line,
18923if one is added to the message (see the next option).
18924
18925Note: A changed return path is not logged unless you add
18926return_path_on_delivery to the log selector.
18927
18928The expansion can refer to the existing value via $return_path. This is either
18929the message's envelope sender, or an address set by the errors_to option on a
18930router. If the expansion is forced to fail, no replacement occurs; if it fails
18931for another reason, delivery is deferred. This option can be used to support
18932VERP (Variable Envelope Return Paths) - see section 49.6.
18933
18934Note: If a delivery error is detected locally, including the case when a remote
18935server rejects a message at SMTP time, the bounce message is not sent to the
18936value of this option. It is sent to the previously set errors address. This
18937defaults to the incoming sender address, but can be changed by setting
18938errors_to in a router.
18939
18940+---------------+---------------+-------------+--------------+
18941|return_path_add|Use: transports|Type: boolean|Default: false|
18942+---------------+---------------+-------------+--------------+
18943
18944If this option is true, a Return-path: header is added to the message. Although
18945the return path is normally available in the prefix line of BSD mailboxes, this
18946is commonly not displayed by MUAs, and so the user does not have easy access to
18947it.
18948
18949RFC 2821 states that the Return-path: header is added to a message "when the
18950delivery SMTP server makes the final delivery". This implies that this header
18951should not be present in incoming messages. Exim has a configuration option,
18952return_path_remove, which requests removal of this header from incoming
18953messages, so that delivered messages can safely be resent to other recipients.
18954
18955+----------------+---------------+-------------+--------------+
18956|shadow_condition|Use: transports|Type: string*|Default: unset|
18957+----------------+---------------+-------------+--------------+
18958
18959See shadow_transport below.
18960
18961+----------------+---------------+------------+--------------+
18962|shadow_transport|Use: transports|Type: string|Default: unset|
18963+----------------+---------------+------------+--------------+
18964
18965A local transport may set the shadow_transport option to the name of another
18966local transport. Shadow remote transports are not supported.
18967
18968Whenever a delivery to the main transport succeeds, and either shadow_condition
18969is unset, or its expansion does not result in the empty string or one of the
18970strings "0" or "no" or "false", the message is also passed to the shadow
18971transport, with the same delivery address or addresses. If expansion fails, no
18972action is taken except that non-forced expansion failures cause a log line to
18973be written.
18974
18975The result of the shadow transport is discarded and does not affect the
18976subsequent processing of the message. Only a single level of shadowing is
18977provided; the shadow_transport option is ignored on any transport when it is
18978running as a shadow. Options concerned with output from pipes are also ignored.
18979The log line for the successful delivery has an item added on the end, of the
18980form
18981
18982ST=<shadow transport name>
18983
18984If the shadow transport did not succeed, the error message is put in
18985parentheses afterwards. Shadow transports can be used for a number of different
18986purposes, including keeping more detailed log information than Exim normally
18987provides, and implementing automatic acknowledgment policies based on message
18988headers that some sites insist on.
18989
18990+----------------+---------------+-------------+--------------+
18991|transport_filter|Use: transports|Type: string*|Default: unset|
18992+----------------+---------------+-------------+--------------+
18993
18994This option sets up a filtering (in the Unix shell sense) process for messages
18995at transport time. It should not be confused with mail filtering as set up by
18996individual users or via a system filter.
18997
18998When the message is about to be written out, the command specified by
18999transport_filter is started up in a separate, parallel process, and the entire
19000message, including the header lines, is passed to it on its standard input
19001(this in fact is done from a third process, to avoid deadlock). The command
19002must be specified as an absolute path.
19003
19004The lines of the message that are written to the transport filter are
19005terminated by newline ("\n"). The message is passed to the filter before any
19006SMTP-specific processing, such as turning "\n" into "\r\n" and escaping lines
19007beginning with a dot, and also before any processing implied by the settings of
19008check_string and escape_string in the appendfile or pipe transports.
19009
19010The standard error for the filter process is set to the same destination as its
19011standard output; this is read and written to the message's ultimate
19012destination. The process that writes the message to the filter, the filter
19013itself, and the original process that reads the result and delivers it are all
19014run in parallel, like a shell pipeline.
19015
19016The filter can perform any transformations it likes, but of course should take
19017care not to break RFC 2822 syntax. Exim does not check the result, except to
19018test for a final newline when SMTP is in use. All messages transmitted over
19019SMTP must end with a newline, so Exim supplies one if it is missing.
19020
19021A transport filter can be used to provide content-scanning on a per-user basis
19022at delivery time if the only required effect of the scan is to modify the
19023message. For example, a content scan could insert a new header line containing
19024a spam score. This could be interpreted by a filter in the user's MUA. It is
19025not possible to discard a message at this stage.
19026
19027A problem might arise if the filter increases the size of a message that is
19028being sent down an SMTP connection. If the receiving SMTP server has indicated
19029support for the SIZE parameter, Exim will have sent the size of the message at
19030the start of the SMTP session. If what is actually sent is substantially more,
19031the server might reject the message. This can be worked round by setting the
19032size_addition option on the smtp transport, either to allow for additions to
19033the message, or to disable the use of SIZE altogether.
19034
19035The value of the transport_filter option is the command string for starting the
19036filter, which is run directly from Exim, not under a shell. The string is
19037parsed by Exim in the same way as a command string for the pipe transport: Exim
19038breaks it up into arguments and then expands each argument separately (see
19039section 29.3). Any kind of expansion failure causes delivery to be deferred.
19040The special argument $pipe_addresses is replaced by a number of arguments, one
19041for each address that applies to this delivery. (This isn't an ideal name for
19042this feature here, but as it was already implemented for the pipe transport, it
19043seemed sensible not to change it.)
19044
19045The expansion variables $host and $host_address are available when the
19046transport is a remote one. They contain the name and IP address of the host to
19047which the message is being sent. For example:
19048
19049transport_filter = /some/directory/transport-filter.pl \
19050 $host $host_address $sender_address $pipe_addresses
19051
19052Two problems arise if you want to use more complicated expansion items to
19053generate transport filter commands, both of which due to the fact that the
19054command is split up before expansion.
19055
19056 * If an expansion item contains white space, you must quote it, so that it is
19057 all part of the same command item. If the entire option setting is one such
19058 expansion item, you have to take care what kind of quoting you use. For
19059 example:
19060
19061 transport_filter = '/bin/cmd${if eq{$host}{a.b.c}{1}{2}}'
19062
19063 This runs the command /bin/cmd1 if the host name is a.b.c, and /bin/cmd2
19064 otherwise. If double quotes had been used, they would have been stripped by
19065 Exim when it read the option's value. When the value is used, if the single
19066 quotes were missing, the line would be split into two items, "/bin/cmd${if"
19067 and "eq{$host}{a.b.c}{1}{2}", and an error would occur when Exim tried to
19068 expand the first one.
19069
19070 * Except for the special case of $pipe_addresses that is mentioned above, an
19071 expansion cannot generate multiple arguments, or a command name followed by
19072 arguments. Consider this example:
19073
19074 transport_filter = ${lookup{$host}lsearch{/a/file}\
19075 {$value}{/bin/cat}}
19076
19077 The result of the lookup is interpreted as the name of the command, even if
19078 it contains white space. The simplest way round this is to use a shell:
19079
19080 transport_filter = /bin/sh -c ${lookup{$host}lsearch{/a/file}\
19081 {$value}{/bin/cat}}
19082
19083The filter process is run under the same uid and gid as the normal delivery.
19084For remote deliveries this is the Exim uid/gid by default. The command should
19085normally yield a zero return code. Transport filters are not supposed to fail.
19086A non-zero code is taken to mean that the transport filter encountered some
19087serious problem. Delivery of the message is deferred; the message remains on
19088the queue and is tried again later. It is not possible to cause a message to be
19089bounced from a transport filter.
19090
19091If a transport filter is set on an autoreply transport, the original message is
19092passed through the filter as it is being copied into the newly generated
19093message, which happens if the return_message option is set.
19094
19095+------------------------+---------------+----------+-----------+
19096|transport_filter_timeout|Use: transports|Type: time|Default: 5m|
19097+------------------------+---------------+----------+-----------+
19098
19099When Exim is reading the output of a transport filter, it applies a timeout
19100that can be set by this option. Exceeding the timeout is normally treated as a
19101temporary delivery failure. However, if a transport filter is used with a pipe
19102transport, a timeout in the transport filter is treated in the same way as a
19103timeout in the pipe command itself. By default, a timeout is a hard error, but
19104if the pipe transport's timeout_defer option is set true, it becomes a
19105temporary error.
19106
19107+----+---------------+-------------+------------------+
19108|user|Use: transports|Type: string*|Default: Exim user|
19109+----+---------------+-------------+------------------+
19110
19111This option specifies the user under whose uid the delivery process is to be
19112run, overriding any uid that may have been set by the router. If the user is
19113given as a name, the uid is looked up from the password data, and the
19114associated group is taken as the value of the gid to be used if the group
19115option is not set.
19116
19117For deliveries that use local transports, a user and group are normally
19118specified explicitly or implicitly (for example, as a result of
19119check_local_user) by the router or transport.
19120
19121For remote transports, you should leave this option unset unless you really are
19122sure you know what you are doing. When a remote transport is running, it needs
19123to be able to access Exim's hints databases, because each host may have its own
19124retry data.
19125
19126
19127
19128===============================================================================
1912925. ADDRESS BATCHING IN LOCAL TRANSPORTS
19130
19131The only remote transport (smtp) is normally configured to handle more than one
19132address at a time, so that when several addresses are routed to the same remote
19133host, just one copy of the message is sent. Local transports, however, normally
19134handle one address at a time. That is, a separate instance of the transport is
19135run for each address that is routed to the transport. A separate copy of the
19136message is delivered each time.
19137
19138In special cases, it may be desirable to handle several addresses at once in a
19139local transport, for example:
19140
19141 * In an appendfile transport, when storing messages in files for later
19142 delivery by some other means, a single copy of the message with multiple
19143 recipients saves space.
19144
19145 * In an lmtp transport, when delivering over "local SMTP" to some process, a
19146 single copy saves time, and is the normal way LMTP is expected to work.
19147
19148 * In a pipe transport, when passing the message to a scanner program or to
19149 some other delivery mechanism such as UUCP, multiple recipients may be
19150 acceptable.
19151
19152These three local transports all have the same options for controlling multiple
19153("batched") deliveries, namely batch_max and batch_id. To save repeating the
19154information for each transport, these options are described here.
19155
19156The batch_max option specifies the maximum number of addresses that can be
19157delivered together in a single run of the transport. Its default value is one
19158(no batching). When more than one address is routed to a transport that has a
19159batch_max value greater than one, the addresses are delivered in a batch (that
19160is, in a single run of the transport with multiple recipients), subject to
19161certain conditions:
19162
19163 * If any of the transport's options contain a reference to $local_part, no
19164 batching is possible.
19165
19166 * If any of the transport's options contain a reference to $domain, only
19167 addresses with the same domain are batched.
19168
19169 * If batch_id is set, it is expanded for each address, and only those
19170 addresses with the same expanded value are batched. This allows you to
19171 specify customized batching conditions. Failure of the expansion for any
19172 reason, including forced failure, disables batching, but it does not stop
19173 the delivery from taking place.
19174
19175 * Batched addresses must also have the same errors address (where to send
19176 delivery errors), the same header additions and removals, the same user and
19177 group for the transport, and if a host list is present, the first host must
19178 be the same.
19179
19180In the case of the appendfile and pipe transports, batching applies both when
19181the file or pipe command is specified in the transport, and when it is
19182specified by a redirect router, but all the batched addresses must of course be
19183routed to the same file or pipe command. These two transports have an option
19184called use_bsmtp, which causes them to deliver the message in "batched SMTP"
19185format, with the envelope represented as SMTP commands. The check_string and
19186escape_string options are forced to the values
19187
19188check_string = "."
19189escape_string = ".."
19190
19191when batched SMTP is in use. A full description of the batch SMTP mechanism is
19192given in section 47.10. The lmtp transport does not have a use_bsmtp option,
19193because it always delivers using the SMTP protocol.
19194
19195If the generic envelope_to_add option is set for a batching transport, the
19196Envelope-to: header that is added to the message contains all the addresses
19197that are being processed together. If you are using a batching appendfile
19198transport without use_bsmtp, the only way to preserve the recipient addresses
19199is to set the envelope_to_add option.
19200
19201If you are using a pipe transport without BSMTP, and setting the transport's
19202command option, you can include $pipe_addresses as part of the command. This is
19203not a true variable; it is a bit of magic that causes each of the recipient
19204addresses to be inserted into the command as a separate argument. This provides
19205a way of accessing all the addresses that are being delivered in the batch.
19206Note: This is not possible for pipe commands that are specified by a redirect
19207router.
19208
19209
19210
19211===============================================================================
1921226. THE APPENDFILE TRANSPORT
19213
19214The appendfile transport delivers a message by appending it to an existing
19215file, or by creating an entirely new file in a specified directory. Single
19216files to which messages are appended can be in the traditional Unix mailbox
19217format, or optionally in the MBX format supported by the Pine MUA and
19218University of Washington IMAP daemon, inter alia. When each message is being
19219delivered as a separate file, "maildir" format can optionally be used to give
19220added protection against failures that happen part-way through the delivery. A
19221third form of separate-file delivery known as "mailstore" is also supported.
19222For all file formats, Exim attempts to create as many levels of directory as
19223necessary, provided that create_directory is set.
19224
19225The code for the optional formats is not included in the Exim binary by
19226default. It is necessary to set SUPPORT_MBX, SUPPORT_MAILDIR and/or
19227SUPPORT_MAILSTORE in Local/Makefile to have the appropriate code included.
19228
19229Exim recognizes system quota errors, and generates an appropriate message. Exim
19230also supports its own quota control within the transport, for use when the
19231system facility is unavailable or cannot be used for some reason.
19232
19233If there is an error while appending to a file (for example, quota exceeded or
19234partition filled), Exim attempts to reset the file's length and last
19235modification time back to what they were before. If there is an error while
19236creating an entirely new file, the new file is removed.
19237
19238Before appending to a file, a number of security checks are made, and the file
19239is locked. A detailed description is given below, after the list of private
19240options.
19241
19242The appendfile transport is most commonly used for local deliveries to users'
19243mailboxes. However, it can also be used as a pseudo-remote transport for
19244putting messages into files for remote delivery by some means other than Exim.
19245"Batch SMTP" format is often used in this case (see the use_bsmtp option).
19246
19247
1924826.1 The file and directory options
19249-----------------------------------
19250
19251The file option specifies a single file, to which the message is appended; the
19252directory option specifies a directory, in which a new file containing the
19253message is created. Only one of these two options can be set, and for normal
19254deliveries to mailboxes, one of them must be set.
19255
19256However, appendfile is also used for delivering messages to files or
19257directories whose names (or parts of names) are obtained from alias,
19258forwarding, or filtering operations (for example, a save command in a user's
19259Exim filter). When such a transport is running, $local_part contains the local
19260part that was aliased or forwarded, and $address_file contains the name (or
19261partial name) of the file or directory generated by the redirection operation.
19262There are two cases:
19263
19264 * If neither file nor directory is set, the redirection operation must
19265 specify an absolute path (one that begins with "/"). This is the most
19266 common case when users with local accounts use filtering to sort mail into
19267 different folders. See for example, the address_file transport in the
19268 default configuration. If the path ends with a slash, it is assumed to be
19269 the name of a directory. A delivery to a directory can also be forced by
19270 setting maildir_format or mailstore_format.
19271
19272 * If file or directory is set for a delivery from a redirection, it is used
19273 to determine the file or directory name for the delivery. Normally, the
19274 contents of $address_file are used in some way in the string expansion.
19275
19276As an example of the second case, consider an environment where users do not
19277have home directories. They may be permitted to use Exim filter commands of the
19278form:
19279
19280save folder23
19281
19282or Sieve filter commands of the form:
19283
19284require "fileinto";
19285fileinto "folder23";
19286
19287In this situation, the expansion of file or directory in the transport must
19288transform the relative path into an appropriate absolute file name. In the case
19289of Sieve filters, the name inbox must be handled. It is the name that is used
19290as a result of a "keep" action in the filter. This example shows one way of
19291handling this requirement:
19292
19293file = ${if eq{$address_file}{inbox} \
19294 {/var/mail/$local_part} \
19295 {${if eq{${substr_0_1:$address_file}}{/} \
19296 {$address_file} \
19297 {$home/mail/$address_file} \
19298 }} \
19299 }
19300
19301With this setting of file, inbox refers to the standard mailbox location,
19302absolute paths are used without change, and other folders are in the mail
19303directory within the home directory.
19304
19305Note 1: While processing an Exim filter, a relative path such as folder23 is
19306turned into an absolute path if a home directory is known to the router. In
19307particular, this is the case if check_local_user is set. If you want to prevent
19308this happening at routing time, you can set router_home_directory empty. This
19309forces the router to pass the relative path to the transport.
19310
19311Note 2: An absolute path in $address_file is not treated specially; the file or
19312directory option is still used if it is set.
19313
19314
1931526.2 Private options for appendfile
19316-----------------------------------
19317
19318+----------+---------------+-------------+--------------+
19319|allow_fifo|Use: appendfile|Type: boolean|Default: false|
19320+----------+---------------+-------------+--------------+
19321
19322Setting this option permits delivery to named pipes (FIFOs) as well as to
19323regular files. If no process is reading the named pipe at delivery time, the
19324delivery is deferred.
19325
19326+-------------+---------------+-------------+--------------+
19327|allow_symlink|Use: appendfile|Type: boolean|Default: false|
19328+-------------+---------------+-------------+--------------+
19329
19330By default, appendfile will not deliver if the path name for the file is that
19331of a symbolic link. Setting this option relaxes that constraint, but there are
19332security issues involved in the use of symbolic links. Be sure you know what
19333you are doing if you set this. Details of exactly what this option affects are
19334included in the discussion which follows this list of options.
19335
19336+--------+---------------+-------------+--------------+
19337|batch_id|Use: appendfile|Type: string*|Default: unset|
19338+--------+---------------+-------------+--------------+
19339
19340See the description of local delivery batching in chapter 25. However, batching
19341is automatically disabled for appendfile deliveries that happen as a result of
19342forwarding or aliasing or other redirection directly to a file.
19343
19344+---------+---------------+-------------+----------+
19345|batch_max|Use: appendfile|Type: integer|Default: 1|
19346+---------+---------------+-------------+----------+
19347
19348See the description of local delivery batching in chapter 25.
19349
19350+-----------+---------------+-------------+--------------+
19351|check_group|Use: appendfile|Type: boolean|Default: false|
19352+-----------+---------------+-------------+--------------+
19353
19354When this option is set, the group owner of the file defined by the file option
19355is checked to see that it is the same as the group under which the delivery
19356process is running. The default setting is false because the default file mode
19357is 0600, which means that the group is irrelevant.
19358
19359+-----------+---------------+-------------+-------------+
19360|check_owner|Use: appendfile|Type: boolean|Default: true|
19361+-----------+---------------+-------------+-------------+
19362
19363When this option is set, the owner of the file defined by the file option is
19364checked to ensure that it is the same as the user under which the delivery
19365process is running.
19366
19367+------------+---------------+------------+------------------+
19368|check_string|Use: appendfile|Type: string|Default: see below|
19369+------------+---------------+------------+------------------+
19370
19371As appendfile writes the message, the start of each line is tested for matching
19372check_string, and if it does, the initial matching characters are replaced by
19373the contents of escape_string. The value of check_string is a literal string,
19374not a regular expression, and the case of any letters it contains is
19375significant.
19376
19377If use_bsmtp is set the values of check_string and escape_string are forced to
19378"." and ".." respectively, and any settings in the configuration are ignored.
19379Otherwise, they default to "From " and ">From " when the file option is set,
19380and unset when any of the directory, maildir, or mailstore options are set.
19381
19382The default settings, along with message_prefix and message_suffix, are
19383suitable for traditional "BSD" mailboxes, where a line beginning with "From "
19384indicates the start of a new message. All four options need changing if another
19385format is used. For example, to deliver to mailboxes in MMDF format:
19386
19387check_string = "\1\1\1\1\n"
19388escape_string = "\1\1\1\1 \n"
19389message_prefix = "\1\1\1\1\n"
19390message_suffix = "\1\1\1\1\n"
19391
19392+----------------+---------------+-------------+-------------+
19393|create_directory|Use: appendfile|Type: boolean|Default: true|
19394+----------------+---------------+-------------+-------------+
19395
19396When this option is true, Exim attempts to create any missing superior
19397directories for the file that it is about to write. A created directory's mode
19398is given by the directory_mode option.
19399
19400The group ownership of a newly created directory is highly dependent on the
19401operating system (and possibly the file system) that is being used. For
19402example, in Solaris, if the parent directory has the setgid bit set, its group
19403is propagated to the child; if not, the currently set group is used. However,
19404in FreeBSD, the parent's group is always used.
19405
19406+-----------+---------------+------------+-----------------+
19407|create_file|Use: appendfile|Type: string|Default: anywhere|
19408+-----------+---------------+------------+-----------------+
19409
19410This option constrains the location of files and directories that are created
19411by this transport. It applies to files defined by the file option and
19412directories defined by the directory option. In the case of maildir delivery,
19413it applies to the top level directory, not the maildir directories beneath.
19414
19415The option must be set to one of the words "anywhere", "inhome", or
19416"belowhome". In the second and third cases, a home directory must have been set
19417for the transport. This option is not useful when an explicit file name is
19418given for normal mailbox deliveries. It is intended for the case when file
19419names are generated from users' .forward files. These are usually handled by an
19420appendfile transport called address_file. See also file_must_exist.
19421
19422+---------+---------------+-------------+--------------+
19423|directory|Use: appendfile|Type: string*|Default: unset|
19424+---------+---------------+-------------+--------------+
19425
19426This option is mutually exclusive with the file option, but one of file or
19427directory must be set, unless the delivery is the direct result of a
19428redirection (see section 26.1).
19429
19430When directory is set, the string is expanded, and the message is delivered
19431into a new file or files in or below the given directory, instead of being
19432appended to a single mailbox file. A number of different formats are provided
19433(see maildir_format and mailstore_format), and see section 26.4 for further
19434details of this form of delivery.
19435
19436+--------------+---------------+-------------+------------------+
19437|directory_file|Use: appendfile|Type: string*|Default: see below|
19438+--------------+---------------+-------------+------------------+
19439
19440When directory is set, but neither maildir_format nor mailstore_format is set,
19441appendfile delivers each message into a file whose name is obtained by
19442expanding this string. The default value is:
19443
19444q${base62:$tod_epoch}-$inode
19445
19446This generates a unique name from the current time, in base 62 form, and the
19447inode of the file. The variable $inode is available only when expanding this
19448option.
19449
19450+--------------+---------------+-------------------+-------------+
19451|directory_mode|Use: appendfile|Type: octal integer|Default: 0700|
19452+--------------+---------------+-------------------+-------------+
19453
19454If appendfile creates any directories as a result of the create_directory
19455option, their mode is specified by this option.
19456
19457+-------------+---------------+------------+------------------------+
19458|escape_string|Use: appendfile|Type: string|Default: see description|
19459+-------------+---------------+------------+------------------------+
19460
19461See check_string above.
19462
19463+----+---------------+-------------+--------------+
19464|file|Use: appendfile|Type: string*|Default: unset|
19465+----+---------------+-------------+--------------+
19466
19467This option is mutually exclusive with the directory option, but one of file or
19468directory must be set, unless the delivery is the direct result of a
19469redirection (see section 26.1). The file option specifies a single file, to
19470which the message is appended. One or more of use_fcntl_lock, use_flock_lock,
19471or use_lockfile must be set with file.
19472
19473If you are using more than one host to deliver over NFS into the same
19474mailboxes, you should always use lock files.
19475
19476The string value is expanded for each delivery, and must yield an absolute
19477path. The most common settings of this option are variations on one of these
19478examples:
19479
19480file = /var/spool/mail/$local_part
19481file = /home/$local_part/inbox
19482file = $home/inbox
19483
19484In the first example, all deliveries are done into the same directory. If Exim
19485is configured to use lock files (see use_lockfile below) it must be able to
19486create a file in the directory, so the "sticky" bit must be turned on for
19487deliveries to be possible, or alternatively the group option can be used to run
19488the delivery under a group id which has write access to the directory.
19489
19490+-----------+---------------+------------+--------------+
19491|file_format|Use: appendfile|Type: string|Default: unset|
19492+-----------+---------------+------------+--------------+
19493
19494This option requests the transport to check the format of an existing file
19495before adding to it. The check consists of matching a specific string at the
19496start of the file. The value of the option consists of an even number of
19497colon-separated strings. The first of each pair is the test string, and the
19498second is the name of a transport. If the transport associated with a matched
19499string is not the current transport, control is passed over to the other
19500transport. For example, suppose the standard local_delivery transport has this
19501added to it:
19502
19503file_format = "From : local_delivery :\
19504 \1\1\1\1\n : local_mmdf_delivery"
19505
19506Mailboxes that begin with "From" are still handled by this transport, but if a
19507mailbox begins with four binary ones followed by a newline, control is passed
19508to a transport called local_mmdf_delivery, which presumably is configured to do
19509the delivery in MMDF format. If a mailbox does not exist or is empty, it is
19510assumed to match the current transport. If the start of a mailbox doesn't match
19511any string, or if the transport named for a given string is not defined,
19512delivery is deferred.
19513
19514+---------------+---------------+-------------+--------------+
19515|file_must_exist|Use: appendfile|Type: boolean|Default: false|
19516+---------------+---------------+-------------+--------------+
19517
19518If this option is true, the file specified by the file option must exist. A
19519temporary error occurs if it does not, causing delivery to be deferred. If this
19520option is false, the file is created if it does not exist.
19521
19522+------------------+---------------+----------+-----------+
19523|lock_fcntl_timeout|Use: appendfile|Type: time|Default: 0s|
19524+------------------+---------------+----------+-----------+
19525
19526By default, the appendfile transport uses non-blocking calls to fcntl() when
19527locking an open mailbox file. If the call fails, the delivery process sleeps
19528for lock_interval and tries again, up to lock_retries times. Non-blocking calls
19529are used so that the file is not kept open during the wait for the lock; the
19530reason for this is to make it as safe as possible for deliveries over NFS in
19531the case when processes might be accessing an NFS mailbox without using a lock
19532file. This should not be done, but misunderstandings and hence
19533misconfigurations are not unknown.
19534
19535On a busy system, however, the performance of a non-blocking lock approach is
19536not as good as using a blocking lock with a timeout. In this case, the waiting
19537is done inside the system call, and Exim's delivery process acquires the lock
19538and can proceed as soon as the previous lock holder releases it.
19539
19540If lock_fcntl_timeout is set to a non-zero time, blocking locks, with that
19541timeout, are used. There may still be some retrying: the maximum number of
19542retries is
19543
19544(lock_retries * lock_interval) / lock_fcntl_timeout
19545
19546rounded up to the next whole number. In other words, the total time during
19547which appendfile is trying to get a lock is roughly the same, unless
19548lock_fcntl_timeout is set very large.
19549
19550You should consider setting this option if you are getting a lot of delayed
19551local deliveries because of errors of the form
19552
19553failed to lock mailbox /some/file (fcntl)
19554
19555+------------------+---------------+----------+-----------+
19556|lock_flock_timeout|Use: appendfile|Type: time|Default: 0s|
19557+------------------+---------------+----------+-----------+
19558
19559This timeout applies to file locking when using flock() (see use_flock); the
19560timeout operates in a similar manner to lock_fcntl_timeout.
19561
19562+-------------+---------------+----------+-----------+
19563|lock_interval|Use: appendfile|Type: time|Default: 3s|
19564+-------------+---------------+----------+-----------+
19565
19566This specifies the time to wait between attempts to lock the file. See below
19567for details of locking.
19568
19569+------------+---------------+-------------+-----------+
19570|lock_retries|Use: appendfile|Type: integer|Default: 10|
19571+------------+---------------+-------------+-----------+
19572
19573This specifies the maximum number of attempts to lock the file. A value of zero
19574is treated as 1. See below for details of locking.
19575
19576+-------------+---------------+-------------------+-------------+
19577|lockfile_mode|Use: appendfile|Type: octal integer|Default: 0600|
19578+-------------+---------------+-------------------+-------------+
19579
19580This specifies the mode of the created lock file, when a lock file is being
19581used (see use_lockfile and use_mbx_lock).
19582
19583+----------------+---------------+----------+------------+
19584|lockfile_timeout|Use: appendfile|Type: time|Default: 30m|
19585+----------------+---------------+----------+------------+
19586
19587When a lock file is being used (see use_lockfile), if a lock file already
19588exists and is older than this value, it is assumed to have been left behind by
19589accident, and Exim attempts to remove it.
19590
19591+-----------------+---------------+-------------+--------------+
19592|mailbox_filecount|Use: appendfile|Type: string*|Default: unset|
19593+-----------------+---------------+-------------+--------------+
19594
19595If this option is set, it is expanded, and the result is taken as the current
19596number of files in the mailbox. It must be a decimal number, optionally
19597followed by K or M. This provides a way of obtaining this information from an
19598external source that maintains the data.
19599
19600+------------+---------------+-------------+--------------+
19601|mailbox_size|Use: appendfile|Type: string*|Default: unset|
19602+------------+---------------+-------------+--------------+
19603
19604If this option is set, it is expanded, and the result is taken as the current
19605size the mailbox. It must be a decimal number, optionally followed by K or M.
19606This provides a way of obtaining this information from an external source that
19607maintains the data. This is likely to be helpful for maildir deliveries where
19608it is computationally expensive to compute the size of a mailbox.
19609
19610+--------------+---------------+-------------+--------------+
19611|maildir_format|Use: appendfile|Type: boolean|Default: false|
19612+--------------+---------------+-------------+--------------+
19613
19614If this option is set with the directory option, the delivery is into a new
19615file, in the "maildir" format that is used by other mail software. When the
19616transport is activated directly from a redirect router (for example, the
19617address_file transport in the default configuration), setting maildir_format
19618causes the path received from the router to be treated as a directory, whether
19619or not it ends with "/". This option is available only if SUPPORT_MAILDIR is
19620present in Local/Makefile. See section 26.5 below for further details.
19621
19622+-----------------------------+---------------+------------+------------------+
19623|maildir_quota_directory_regex|Use: appendfile|Type: string|Default: See below|
19624+-----------------------------+---------------+------------+------------------+
19625
19626This option is relevant only when maildir_use_size_file is set. It defines a
19627regular expression for specifying directories, relative to the quota directory
19628(see quota_directory), that should be included in the quota calculation. The
19629default value is:
19630
19631maildir_quota_directory_regex = ^(?:cur|new|\..*)$
19632
19633This includes the cur and new directories, and any maildir++ folders
19634(directories whose names begin with a dot). If you want to exclude the Trash
19635folder from the count (as some sites do), you need to change this setting to
19636
19637maildir_quota_directory_regex = ^(?:cur|new|\.(?!Trash).*)$
19638
19639This uses a negative lookahead in the regular expression to exclude the
19640directory whose name is .Trash. When a directory is excluded from quota
19641calculations, quota processing is bypassed for any messages that are delivered
19642directly into that directory.
19643
19644+---------------+---------------+-------------+-----------+
19645|maildir_retries|Use: appendfile|Type: integer|Default: 10|
19646+---------------+---------------+-------------+-----------+
19647
19648This option specifies the number of times to retry when writing a file in
19649"maildir" format. See section 26.5 below.
19650
19651+-----------+---------------+-------------+--------------+
19652|maildir_tag|Use: appendfile|Type: string*|Default: unset|
19653+-----------+---------------+-------------+--------------+
19654
19655This option applies only to deliveries in maildir format, and is described in
19656section 26.5 below.
19657
19658+---------------------+----------------+-------------+--------------+
19659|maildir_use_size_file|Use: appendfile*|Type: boolean|Default: false|
19660+---------------------+----------------+-------------+--------------+
19661
19662The result of string expansion for this option must be a valid boolean value.
19663If it is true, it enables support for maildirsize files. Exim creates a
19664maildirsize file in a maildir if one does not exist, taking the quota from the
19665quota option of the transport. If quota is unset, the value is zero. See
19666maildir_quota_directory_regex above and section 26.5 below for further details.
19667
19668+--------------------------+---------------+------------+--------------+
19669|maildirfolder_create_regex|Use: appendfile|Type: string|Default: unset|
19670+--------------------------+---------------+------------+--------------+
19671
19672The value of this option is a regular expression. If it is unset, it has no
19673effect. Otherwise, before a maildir delivery takes place, the pattern is
19674matched against the name of the maildir directory, that is, the directory
19675containing the new and tmp subdirectories that will be used for the delivery.
19676If there is a match, Exim checks for the existence of a file called
19677maildirfolder in the directory, and creates it if it does not exist. See
19678section 26.5 for more details.
19679
19680+----------------+---------------+-------------+--------------+
19681|mailstore_format|Use: appendfile|Type: boolean|Default: false|
19682+----------------+---------------+-------------+--------------+
19683
19684If this option is set with the directory option, the delivery is into two new
19685files in "mailstore" format. The option is available only if SUPPORT_MAILSTORE
19686is present in Local/Makefile. See section 26.4 below for further details.
19687
19688+----------------+---------------+-------------+--------------+
19689|mailstore_prefix|Use: appendfile|Type: string*|Default: unset|
19690+----------------+---------------+-------------+--------------+
19691
19692This option applies only to deliveries in mailstore format, and is described in
19693section 26.4 below.
19694
19695+----------------+---------------+-------------+--------------+
19696|mailstore_suffix|Use: appendfile|Type: string*|Default: unset|
19697+----------------+---------------+-------------+--------------+
19698
19699This option applies only to deliveries in mailstore format, and is described in
19700section 26.4 below.
19701
19702+----------+---------------+-------------+--------------+
19703|mbx_format|Use: appendfile|Type: boolean|Default: false|
19704+----------+---------------+-------------+--------------+
19705
19706This option is available only if Exim has been compiled with SUPPORT_MBX set in
19707Local/Makefile. If mbx_format is set with the file option, the message is
19708appended to the mailbox file in MBX format instead of traditional Unix format.
19709This format is supported by Pine4 and its associated IMAP and POP daemons, by
19710means of the c-client library that they all use.
19711
19712Note: The message_prefix and message_suffix options are not automatically
19713changed by the use of mbx_format. They should normally be set empty when using
19714MBX format, so this option almost always appears in this combination:
19715
19716mbx_format = true
19717message_prefix =
19718message_suffix =
19719
19720If none of the locking options are mentioned in the configuration, use_mbx_lock
19721is assumed and the other locking options default to false. It is possible to
19722specify the other kinds of locking with mbx_format, but use_fcntl_lock and
19723use_mbx_lock are mutually exclusive. MBX locking interworks with c-client,
19724providing for shared access to the mailbox. It should not be used if any
19725program that does not use this form of locking is going to access the mailbox,
19726nor should it be used if the mailbox file is NFS mounted, because it works only
19727when the mailbox is accessed from a single host.
19728
19729If you set use_fcntl_lock with an MBX-format mailbox, you cannot use the
19730standard version of c-client, because as long as it has a mailbox open (this
19731means for the whole of a Pine or IMAP session), Exim will not be able to append
19732messages to it.
19733
19734+--------------+---------------+-------------+------------------+
19735|message_prefix|Use: appendfile|Type: string*|Default: see below|
19736+--------------+---------------+-------------+------------------+
19737
19738The string specified here is expanded and output at the start of every message.
19739The default is unset unless file is specified and use_bsmtp is not set, in
19740which case it is:
19741
19742message_prefix = "From ${if def:return_path{$return_path}\
19743 {MAILER-DAEMON}} $tod_bsdinbox\n"
19744
19745Note: If you set use_crlf true, you must change any occurrences of "\n" to "\r\
19746n" in message_prefix.
19747
19748+--------------+---------------+-------------+------------------+
19749|message_suffix|Use: appendfile|Type: string*|Default: see below|
19750+--------------+---------------+-------------+------------------+
19751
19752The string specified here is expanded and output at the end of every message.
19753The default is unset unless file is specified and use_bsmtp is not set, in
19754which case it is a single newline character. The suffix can be suppressed by
19755setting
19756
19757message_suffix =
19758
19759Note: If you set use_crlf true, you must change any occurrences of "\n" to "\r\
19760n" in message_suffix.
19761
19762+----+---------------+-------------------+-------------+
19763|mode|Use: appendfile|Type: octal integer|Default: 0600|
19764+----+---------------+-------------------+-------------+
19765
19766If the output file is created, it is given this mode. If it already exists and
19767has wider permissions, they are reduced to this mode. If it has narrower
19768permissions, an error occurs unless mode_fail_narrower is false. However, if
19769the delivery is the result of a save command in a filter file specifying a
19770particular mode, the mode of the output file is always forced to take that
19771value, and this option is ignored.
19772
19773+------------------+---------------+-------------+-------------+
19774|mode_fail_narrower|Use: appendfile|Type: boolean|Default: true|
19775+------------------+---------------+-------------+-------------+
19776
19777This option applies in the case when an existing mailbox file has a narrower
19778mode than that specified by the mode option. If mode_fail_narrower is true, the
19779delivery is deferred ("mailbox has the wrong mode"); otherwise Exim continues
19780with the delivery attempt, using the existing mode of the file.
19781
19782+-------------+---------------+-------------+--------------+
19783|notify_comsat|Use: appendfile|Type: boolean|Default: false|
19784+-------------+---------------+-------------+--------------+
19785
19786If this option is true, the comsat daemon is notified after every successful
19787delivery to a user mailbox. This is the daemon that notifies logged on users
19788about incoming mail.
19789
19790+-----+---------------+-------------+--------------+
19791|quota|Use: appendfile|Type: string*|Default: unset|
19792+-----+---------------+-------------+--------------+
19793
19794This option imposes a limit on the size of the file to which Exim is appending,
19795or to the total space used in the directory tree when the directory option is
19796set. In the latter case, computation of the space used is expensive, because
19797all the files in the directory (and any sub-directories) have to be
19798individually inspected and their sizes summed. (See quota_size_regex and
19799maildir_use_size_file for ways to avoid this in environments where users have
19800no shell access to their mailboxes).
19801
19802As there is no interlock against two simultaneous deliveries into a multi-file
19803mailbox, it is possible for the quota to be overrun in this case. For
19804single-file mailboxes, of course, an interlock is a necessity.
19805
19806A file's size is taken as its used value. Because of blocking effects, this may
19807be a lot less than the actual amount of disk space allocated to the file. If
19808the sizes of a number of files are being added up, the rounding effect can
19809become quite noticeable, especially on systems that have large block sizes.
19810Nevertheless, it seems best to stick to the used figure, because this is the
19811obvious value which users understand most easily.
19812
19813The value of the option is expanded, and must then be a numerical value
19814(decimal point allowed), optionally followed by one of the letters K, M, or G,
19815for kilobytes, megabytes, or gigabytes. If Exim is running on a system with
19816large file support (Linux and FreeBSD have this), mailboxes larger than 2G can
19817be handled.
19818
19819Note: A value of zero is interpreted as "no quota".
19820
19821The expansion happens while Exim is running as root, before it changes uid for
19822the delivery. This means that files that are inaccessible to the end user can
19823be used to hold quota values that are looked up in the expansion. When delivery
19824fails because this quota is exceeded, the handling of the error is as for
19825system quota failures.
19826
19827By default, Exim's quota checking mimics system quotas, and restricts the
19828mailbox to the specified maximum size, though the value is not accurate to the
19829last byte, owing to separator lines and additional headers that may get added
19830during message delivery. When a mailbox is nearly full, large messages may get
19831refused even though small ones are accepted, because the size of the current
19832message is added to the quota when the check is made. This behaviour can be
19833changed by setting quota_is_inclusive false. When this is done, the check for
19834exceeding the quota does not include the current message. Thus, deliveries
19835continue until the quota has been exceeded; thereafter, no further messages are
19836delivered. See also quota_warn_threshold.
19837
19838+---------------+---------------+-------------+--------------+
19839|quota_directory|Use: appendfile|Type: string*|Default: unset|
19840+---------------+---------------+-------------+--------------+
19841
19842This option defines the directory to check for quota purposes when delivering
19843into individual files. The default is the delivery directory, or, if a file
19844called maildirfolder exists in a maildir directory, the parent of the delivery
19845directory.
19846
19847+---------------+---------------+-------------+----------+
19848|quota_filecount|Use: appendfile|Type: string*|Default: 0|
19849+---------------+---------------+-------------+----------+
19850
19851This option applies when the directory option is set. It limits the total
19852number of files in the directory (compare the inode limit in system quotas). It
19853can only be used if quota is also set. The value is expanded; an expansion
19854failure causes delivery to be deferred. A value of zero is interpreted as "no
19855quota".
19856
19857+------------------+---------------+-------------+-------------+
19858|quota_is_inclusive|Use: appendfile|Type: boolean|Default: true|
19859+------------------+---------------+-------------+-------------+
19860
19861See quota above.
19862
19863+----------------+---------------+------------+--------------+
19864|quota_size_regex|Use: appendfile|Type: string|Default: unset|
19865+----------------+---------------+------------+--------------+
19866
19867This option applies when one of the delivery modes that writes a separate file
19868for each message is being used. When Exim wants to find the size of one of
19869these files in order to test the quota, it first checks quota_size_regex. If
19870this is set to a regular expression that matches the file name, and it captures
19871one string, that string is interpreted as a representation of the file's size.
19872The value of quota_size_regex is not expanded.
19873
19874This feature is useful only when users have no shell access to their mailboxes
19875- otherwise they could defeat the quota simply by renaming the files. This
19876facility can be used with maildir deliveries, by setting maildir_tag to add the
19877file length to the file name. For example:
19878
19879maildir_tag = ,S=$message_size
19880quota_size_regex = ,S=(\d+)
19881
19882An alternative to $message_size is $message_linecount, which contains the
19883number of lines in the message.
19884
19885The regular expression should not assume that the length is at the end of the
19886file name (even though maildir_tag puts it there) because maildir MUAs
19887sometimes add other information onto the ends of message file names.
19888
19889Section 26.7 contains further information.
19890
19891+------------------+---------------+-------------+------------------+
19892|quota_warn_message|Use: appendfile|Type: string*|Default: see below|
19893+------------------+---------------+-------------+------------------+
19894
19895See below for the use of this option. If it is not set when
19896quota_warn_threshold is set, it defaults to
19897
19898quota_warn_message = "\
19899 To: $local_part@$domain\n\
19900 Subject: Your mailbox\n\n\
19901 This message is automatically created \
19902 by mail delivery software.\n\n\
19903 The size of your mailbox has exceeded \
19904 a warning threshold that is\n\
19905 set by the system administrator.\n"
19906
19907+--------------------+---------------+-------------+----------+
19908|quota_warn_threshold|Use: appendfile|Type: string*|Default: 0|
19909+--------------------+---------------+-------------+----------+
19910
19911This option is expanded in the same way as quota (see above). If the resulting
19912value is greater than zero, and delivery of the message causes the size of the
19913file or total space in the directory tree to cross the given threshold, a
19914warning message is sent. If quota is also set, the threshold may be specified
19915as a percentage of it by following the value with a percent sign. For example:
19916
19917quota = 10M
19918quota_warn_threshold = 75%
19919
19920If quota is not set, a setting of quota_warn_threshold that ends with a percent
19921sign is ignored.
19922
19923The warning message itself is specified by the quota_warn_message option, and
19924it must start with a To: header line containing the recipient(s) of the warning
19925message. These do not necessarily have to include the recipient(s) of the
19926original message. A Subject: line should also normally be supplied. You can
19927include any other header lines that you want. If you do not include a From:
19928line, the default is:
19929
19930From: Mail Delivery System <mailer-daemon@$qualify_domain_sender>
19931
19932If you supply a Reply-To: line, it overrides the global errors_reply_to option.
19933
19934The quota option does not have to be set in order to use this option; they are
19935independent of one another except when the threshold is specified as a
19936percentage.
19937
19938+---------+---------------+-------------+--------------+
19939|use_bsmtp|Use: appendfile|Type: boolean|Default: false|
19940+---------+---------------+-------------+--------------+
19941
19942If this option is set true, appendfile writes messages in "batch SMTP" format,
19943with the envelope sender and recipient(s) included as SMTP commands. If you
19944want to include a leading HELO command with such messages, you can do so by
19945setting the message_prefix option. See section 47.10 for details of batch SMTP.
19946
19947+--------+---------------+-------------+--------------+
19948|use_crlf|Use: appendfile|Type: boolean|Default: false|
19949+--------+---------------+-------------+--------------+
19950
19951This option causes lines to be terminated with the two-character CRLF sequence
19952(carriage return, linefeed) instead of just a linefeed character. In the case
19953of batched SMTP, the byte sequence written to the file is then an exact image
19954of what would be sent down a real SMTP connection.
19955
19956Note: The contents of the message_prefix and message_suffix options (which are
19957used to supply the traditional "From " and blank line separators in
19958Berkeley-style mailboxes) are written verbatim, so must contain their own
19959carriage return characters if these are needed. In cases where these options
19960have non-empty defaults, the values end with a single linefeed, so they must be
19961changed to end with "\r\n" if use_crlf is set.
19962
19963+--------------+---------------+-------------+------------------+
19964|use_fcntl_lock|Use: appendfile|Type: boolean|Default: see below|
19965+--------------+---------------+-------------+------------------+
19966
19967This option controls the use of the fcntl() function to lock a file for
19968exclusive use when a message is being appended. It is set by default unless
19969use_flock_lock is set. Otherwise, it should be turned off only if you know that
19970all your MUAs use lock file locking. When both use_fcntl_lock and
19971use_flock_lock are unset, use_lockfile must be set.
19972
19973+--------------+---------------+-------------+--------------+
19974|use_flock_lock|Use: appendfile|Type: boolean|Default: false|
19975+--------------+---------------+-------------+--------------+
19976
19977This option is provided to support the use of flock() for file locking, for the
19978few situations where it is needed. Most modern operating systems support fcntl
19979() and lockf() locking, and these two functions interwork with each other. Exim
19980uses fcntl() locking by default.
19981
19982This option is required only if you are using an operating system where flock()
19983is used by programs that access mailboxes (typically MUAs), and where flock()
19984does not correctly interwork with fcntl(). You can use both fcntl() and flock()
19985locking simultaneously if you want.
19986
19987Not all operating systems provide flock(). Some versions of Solaris do not have
19988it (and some, I think, provide a not quite right version built on top of lockf
19989()). If the OS does not have flock(), Exim will be built without the ability to
19990use it, and any attempt to do so will cause a configuration error.
19991
19992Warning: flock() locks do not work on NFS files (unless flock() is just being
19993mapped onto fcntl() by the OS).
19994
19995+------------+---------------+-------------+------------------+
19996|use_lockfile|Use: appendfile|Type: boolean|Default: see below|
19997+------------+---------------+-------------+------------------+
19998
19999If this option is turned off, Exim does not attempt to create a lock file when
20000appending to a mailbox file. In this situation, the only locking is by fcntl().
20001You should only turn use_lockfile off if you are absolutely sure that every MUA
20002that is ever going to look at your users' mailboxes uses fcntl() rather than a
20003lock file, and even then only when you are not delivering over NFS from more
20004than one host.
20005
20006In order to append to an NFS file safely from more than one host, it is
20007necessary to take out a lock before opening the file, and the lock file
20008achieves this. Otherwise, even with fcntl() locking, there is a risk of file
20009corruption.
20010
20011The use_lockfile option is set by default unless use_mbx_lock is set. It is not
20012possible to turn both use_lockfile and use_fcntl_lock off, except when
20013mbx_format is set.
20014
20015+------------+---------------+-------------+------------------+
20016|use_mbx_lock|Use: appendfile|Type: boolean|Default: see below|
20017+------------+---------------+-------------+------------------+
20018
20019This option is available only if Exim has been compiled with SUPPORT_MBX set in
20020Local/Makefile. Setting the option specifies that special MBX locking rules be
20021used. It is set by default if mbx_format is set and none of the locking options
20022are mentioned in the configuration. The locking rules are the same as are used
20023by the c-client library that underlies Pine and the IMAP4 and POP daemons that
20024come with it (see the discussion below). The rules allow for shared access to
20025the mailbox. However, this kind of locking does not work when the mailbox is
20026NFS mounted.
20027
20028You can set use_mbx_lock with either (or both) of use_fcntl_lock and
20029use_flock_lock to control what kind of locking is used in implementing the MBX
20030locking rules. The default is to use fcntl() if use_mbx_lock is set without
20031use_fcntl_lock or use_flock_lock.
20032
20033
2003426.3 Operational details for appending
20035--------------------------------------
20036
20037Before appending to a file, the following preparations are made:
20038
20039 * If the name of the file is /dev/null, no action is taken, and a success
20040 return is given.
20041
20042 * If any directories on the file's path are missing, Exim creates them if the
20043 create_directory option is set. A created directory's mode is given by the
20044 directory_mode option.
20045
20046 * If file_format is set, the format of an existing file is checked. If this
20047 indicates that a different transport should be used, control is passed to
20048 that transport.
20049
20050 * If use_lockfile is set, a lock file is built in a way that will work
20051 reliably over NFS, as follows:
20052
20053 1. Create a "hitching post" file whose name is that of the lock file with
20054 the current time, primary host name, and process id added, by opening
20055 for writing as a new file. If this fails with an access error, delivery
20056 is deferred.
20057
20058 2. Close the hitching post file, and hard link it to the lock file name.
20059
20060 3. If the call to link() succeeds, creation of the lock file has
20061 succeeded. Unlink the hitching post name.
20062
20063 4. Otherwise, use stat() to get information about the hitching post file,
20064 and then unlink hitching post name. If the number of links is exactly
20065 two, creation of the lock file succeeded but something (for example, an
20066 NFS server crash and restart) caused this fact not to be communicated
20067 to the link() call.
20068
20069 5. If creation of the lock file failed, wait for lock_interval and try
20070 again, up to lock_retries times. However, since any program that writes
20071 to a mailbox should complete its task very quickly, it is reasonable to
20072 time out old lock files that are normally the result of user agent and
20073 system crashes. If an existing lock file is older than lockfile_timeout
20074 Exim attempts to unlink it before trying again.
20075
20076 * A call is made to lstat() to discover whether the main file exists, and if
20077 so, what its characteristics are. If lstat() fails for any reason other
20078 than non-existence, delivery is deferred.
20079
20080 * If the file does exist and is a symbolic link, delivery is deferred, unless
20081 the allow_symlink option is set, in which case the ownership of the link is
20082 checked, and then stat() is called to find out about the real file, which
20083 is then subjected to the checks below. The check on the top-level link
20084 ownership prevents one user creating a link for another's mailbox in a
20085 sticky directory, though allowing symbolic links in this case is definitely
20086 not a good idea. If there is a chain of symbolic links, the intermediate
20087 ones are not checked.
20088
20089 * If the file already exists but is not a regular file, or if the file's
20090 owner and group (if the group is being checked - see check_group above) are
20091 different from the user and group under which the delivery is running,
20092 delivery is deferred.
20093
20094 * If the file's permissions are more generous than specified, they are
20095 reduced. If they are insufficient, delivery is deferred, unless
20096 mode_fail_narrower is set false, in which case the delivery is tried using
20097 the existing permissions.
20098
20099 * The file's inode number is saved, and the file is then opened for
20100 appending. If this fails because the file has vanished, appendfile behaves
20101 as if it hadn't existed (see below). For any other failures, delivery is
20102 deferred.
20103
20104 * If the file is opened successfully, check that the inode number hasn't
20105 changed, that it is still a regular file, and that the owner and
20106 permissions have not changed. If anything is wrong, defer delivery and
20107 freeze the message.
20108
20109 * If the file did not exist originally, defer delivery if the file_must_exist
20110 option is set. Otherwise, check that the file is being created in a
20111 permitted directory if the create_file option is set (deferring on
20112 failure), and then open for writing as a new file, with the O_EXCL and
20113 O_CREAT options, except when dealing with a symbolic link (the
20114 allow_symlink option must be set). In this case, which can happen if the
20115 link points to a non-existent file, the file is opened for writing using
20116 O_CREAT but not O_EXCL, because that prevents link following.
20117
20118 * If opening fails because the file exists, obey the tests given above for
20119 existing files. However, to avoid looping in a situation where the file is
20120 being continuously created and destroyed, the exists/not-exists loop is
20121 broken after 10 repetitions, and the message is then frozen.
20122
20123 * If opening fails with any other error, defer delivery.
20124
20125 * Once the file is open, unless both use_fcntl_lock and use_flock_lock are
20126 false, it is locked using fcntl() or flock() or both. If use_mbx_lock is
20127 false, an exclusive lock is requested in each case. However, if
20128 use_mbx_lock is true, Exim takes out a shared lock on the open file, and an
20129 exclusive lock on the file whose name is
20130
20131 /tmp/.<device-number>.<inode-number>
20132
20133 using the device and inode numbers of the open mailbox file, in accordance
20134 with the MBX locking rules. This file is created with a mode that is
20135 specified by the lockfile_mode option.
20136
20137 If Exim fails to lock the file, there are two possible courses of action,
20138 depending on the value of the locking timeout. This is obtained from
20139 lock_fcntl_timeout or lock_flock_timeout, as appropriate.
20140
20141 If the timeout value is zero, the file is closed, Exim waits for
20142 lock_interval, and then goes back and re-opens the file as above and tries
20143 to lock it again. This happens up to lock_retries times, after which the
20144 delivery is deferred.
20145
20146 If the timeout has a value greater than zero, blocking calls to fcntl() or
20147 flock() are used (with the given timeout), so there has already been some
20148 waiting involved by the time locking fails. Nevertheless, Exim does not
20149 give up immediately. It retries up to
20150
20151 (lock_retries * lock_interval) / <timeout>
20152
20153 times (rounded up).
20154
20155At the end of delivery, Exim closes the file (which releases the fcntl() and/or
20156flock() locks) and then deletes the lock file if one was created.
20157
20158
2015926.4 Operational details for delivery to a new file
20160---------------------------------------------------
20161
20162When the directory option is set instead of file, each message is delivered
20163into a newly-created file or set of files. When appendfile is activated
20164directly from a redirect router, neither file nor directory is normally set,
20165because the path for delivery is supplied by the router. (See for example, the
20166address_file transport in the default configuration.) In this case, delivery is
20167to a new file if either the path name ends in "/", or the maildir_format or
20168mailstore_format option is set.
20169
20170No locking is required while writing the message to a new file, so the various
20171locking options of the transport are ignored. The "From" line that by default
20172separates messages in a single file is not normally needed, nor is the escaping
20173of message lines that start with "From", and there is no need to ensure a
20174newline at the end of each message. Consequently, the default values for
20175check_string, message_prefix, and message_suffix are all unset when any of
20176directory, maildir_format, or mailstore_format is set.
20177
20178If Exim is required to check a quota setting, it adds up the sizes of all the
20179files in the delivery directory by default. However, you can specify a
20180different directory by setting quota_directory. Also, for maildir deliveries
20181(see below) the maildirfolder convention is honoured.
20182
20183There are three different ways in which delivery to individual files can be
20184done, controlled by the settings of the maildir_format and mailstore_format
20185options. Note that code to support maildir or mailstore formats is not included
20186in the binary unless SUPPORT_MAILDIR or SUPPORT_MAILSTORE, respectively, is set
20187in Local/Makefile.
20188
20189In all three cases an attempt is made to create the directory and any necessary
20190sub-directories if they do not exist, provided that the create_directory option
20191is set (the default). The location of a created directory can be constrained by
20192setting create_file. A created directory's mode is given by the directory_mode
20193option. If creation fails, or if the create_directory option is not set when
20194creation is required, delivery is deferred.
20195
20196
2019726.5 Maildir delivery
20198---------------------
20199
20200If the maildir_format option is true, Exim delivers each message by writing it
20201to a file whose name is tmp/<stime>.H<mtime>P<pid>.<host> in the directory that
20202is defined by the directory option (the "delivery directory"). If the delivery
20203is successful, the file is renamed into the new subdirectory.
20204
20205In the file name, <stime> is the current time of day in seconds, and <mtime> is
20206the microsecond fraction of the time. After a maildir delivery, Exim checks
20207that the time-of-day clock has moved on by at least one microsecond before
20208terminating the delivery process. This guarantees uniqueness for the file name.
20209However, as a precaution, Exim calls stat() for the file before opening it. If
20210any response other than ENOENT (does not exist) is given, Exim waits 2 seconds
20211and tries again, up to maildir_retries times.
20212
20213Before Exim carries out a maildir delivery, it ensures that subdirectories
20214called new, cur, and tmp exist in the delivery directory. If they do not exist,
20215Exim tries to create them and any superior directories in their path, subject
20216to the create_directory and create_file options. If the
20217maildirfolder_create_regex option is set, and the regular expression it
20218contains matches the delivery directory, Exim also ensures that a file called
20219maildirfolder exists in the delivery directory. If a missing directory or
20220maildirfolder file cannot be created, delivery is deferred.
20221
20222These features make it possible to use Exim to create all the necessary files
20223and directories in a maildir mailbox, including subdirectories for maildir++
20224folders. Consider this example:
20225
20226maildir_format = true
20227directory = /var/mail/$local_part\
20228 ${if eq{$local_part_suffix}{}{}\
20229 {/.${substr_1:$local_part_suffix}}}
20230maildirfolder_create_regex = /\.[^/]+$
20231
20232If $local_part_suffix is empty (there was no suffix for the local part),
20233delivery is into a toplevel maildir with a name like /var/mail/pimbo (for the
20234user called pimbo). The pattern in maildirfolder_create_regex does not match
20235this name, so Exim will not look for or create the file /var/mail/pimbo/
20236maildirfolder, though it will create /var/mail/pimbo/{cur,new,tmp} if
20237necessary.
20238
20239However, if $local_part_suffix contains "-eximusers" (for example), delivery is
20240into the maildir++ folder /var/mail/pimbo/.eximusers, which does match
20241maildirfolder_create_regex. In this case, Exim will create /var/mail/pimbo
20242/.eximusers/maildirfolder as well as the three maildir directories /var/mail/
20243pimbo/.eximusers/{cur,new,tmp}.
20244
20245Warning: Take care when setting maildirfolder_create_regex that it does not
20246inadvertently match the toplevel maildir directory, because a maildirfolder
20247file at top level would completely break quota calculations.
20248
20249If Exim is required to check a quota setting before a maildir delivery, and
20250quota_directory is not set, it looks for a file called maildirfolder in the
20251maildir directory (alongside new, cur, tmp). If this exists, Exim assumes the
20252directory is a maildir++ folder directory, which is one level down from the
20253user's top level mailbox directory. This causes it to start at the parent
20254directory instead of the current directory when calculating the amount of space
20255used.
20256
20257One problem with delivering into a multi-file mailbox is that it is
20258computationally expensive to compute the size of the mailbox for quota
20259checking. Various approaches have been taken to reduce the amount of work
20260needed. The next two sections describe two of them. A third alternative is to
20261use some external process for maintaining the size data, and use the expansion
20262of the mailbox_size option as a way of importing it into Exim.
20263
20264
2026526.6 Using tags to record message sizes
20266---------------------------------------
20267
20268If maildir_tag is set, the string is expanded for each delivery. When the
20269maildir file is renamed into the new sub-directory, the tag is added to its
20270name. However, if adding the tag takes the length of the name to the point
20271where the test stat() call fails with ENAMETOOLONG, the tag is dropped and the
20272maildir file is created with no tag.
20273
20274Tags can be used to encode the size of files in their names; see
20275quota_size_regex above for an example. The expansion of maildir_tag happens
20276after the message has been written. The value of the $message_size variable is
20277set to the number of bytes actually written. If the expansion is forced to
20278fail, the tag is ignored, but a non-forced failure causes delivery to be
20279deferred. The expanded tag may contain any printing characters except "/".
20280Non-printing characters in the string are ignored; if the resulting string is
20281empty, it is ignored. If it starts with an alphanumeric character, a leading
20282colon is inserted; this default has not proven to be the path that popular
20283maildir implementations have chosen (but changing it in Exim would break
20284backwards compatibility).
20285
20286For one common implementation, you might set:
20287
20288maildir_tag = ,S=${message_size}
20289
20290but you should check the documentation of the other software to be sure.
20291
20292It is advisable to also set quota_size_regex when setting maildir_tag as this
20293allows Exim to extract the size from your tag, instead of having to stat() each
20294message file.
20295
20296
2029726.7 Using a maildirsize file
20298-----------------------------
20299
20300If maildir_use_size_file is true, Exim implements the maildir++ rules for
20301storing quota and message size information in a file called maildirsize within
20302the toplevel maildir directory. If this file does not exist, Exim creates it,
20303setting the quota from the quota option of the transport. If the maildir
20304directory itself does not exist, it is created before any attempt to write a
20305maildirsize file.
20306
20307The maildirsize file is used to hold information about the sizes of messages in
20308the maildir, thus speeding up quota calculations. The quota value in the file
20309is just a cache; if the quota is changed in the transport, the new value
20310overrides the cached value when the next message is delivered. The cache is
20311maintained for the benefit of other programs that access the maildir and need
20312to know the quota.
20313
20314If the quota option in the transport is unset or zero, the maildirsize file is
20315maintained (with a zero quota setting), but no quota is imposed.
20316
20317A regular expression is available for controlling which directories in the
20318maildir participate in quota calculations when a maildirsizefile is in use. See
20319the description of the maildir_quota_directory_regex option above for details.
20320
20321
2032226.8 Mailstore delivery
20323-----------------------
20324
20325If the mailstore_format option is true, each message is written as two files in
20326the given directory. A unique base name is constructed from the message id and
20327the current delivery process, and the files that are written use this base name
20328plus the suffixes .env and .msg. The .env file contains the message's envelope,
20329and the .msg file contains the message itself. The base name is placed in the
20330variable $mailstore_basename.
20331
20332During delivery, the envelope is first written to a file with the suffix .tmp.
20333The .msg file is then written, and when it is complete, the .tmp file is
20334renamed as the .env file. Programs that access messages in mailstore format
20335should wait for the presence of both a .msg and a .env file before accessing
20336either of them. An alternative approach is to wait for the absence of a .tmp
20337file.
20338
20339The envelope file starts with any text defined by the mailstore_prefix option,
20340expanded and terminated by a newline if there isn't one. Then follows the
20341sender address on one line, then all the recipient addresses, one per line.
20342There can be more than one recipient only if the batch_max option is set
20343greater than one. Finally, mailstore_suffix is expanded and the result appended
20344to the file, followed by a newline if it does not end with one.
20345
20346If expansion of mailstore_prefix or mailstore_suffix ends with a forced
20347failure, it is ignored. Other expansion errors are treated as serious
20348configuration errors, and delivery is deferred. The variable
20349$mailstore_basename is available for use during these expansions.
20350
20351
2035226.9 Non-special new file delivery
20353----------------------------------
20354
20355If neither maildir_format nor mailstore_format is set, a single new file is
20356created directly in the named directory. For example, when delivering messages
20357into files in batched SMTP format for later delivery to some host (see section
2035847.10), a setting such as
20359
20360directory = /var/bsmtp/$host
20361
20362might be used. A message is written to a file with a temporary name, which is
20363then renamed when the delivery is complete. The final name is obtained by
20364expanding the contents of the directory_file option.
20365
20366
20367
20368===============================================================================
2036927. THE AUTOREPLY TRANSPORT
20370
20371The autoreply transport is not a true transport in that it does not cause the
20372message to be transmitted. Instead, it generates a new mail message as an
20373automatic reply to the incoming message. References: and Auto-Submitted: header
20374lines are included. These are constructed according to the rules in RFCs 2822
20375and 3834, respectively.
20376
20377If the router that passes the message to this transport does not have the
20378unseen option set, the original message (for the current recipient) is not
20379delivered anywhere. However, when the unseen option is set on the router that
20380passes the message to this transport, routing of the address continues, so
20381another router can set up a normal message delivery.
20382
20383The autoreply transport is usually run as the result of mail filtering, a
20384"vacation" message being the standard example. However, it can also be run
20385directly from a router like any other transport. To reduce the possibility of
20386message cascades, messages created by the autoreply transport always have empty
20387envelope sender addresses, like bounce messages.
20388
20389The parameters of the message to be sent can be specified in the configuration
20390by options described below. However, these are used only when the address
20391passed to the transport does not contain its own reply information. When the
20392transport is run as a consequence of a mail or vacation command in a filter
20393file, the parameters of the message are supplied by the filter, and passed with
20394the address. The transport's options that define the message are then ignored
20395(so they are not usually set in this case). The message is specified entirely
20396by the filter or by the transport; it is never built from a mixture of options.
20397However, the file_optional, mode, and return_message options apply in all
20398cases.
20399
20400Autoreply is implemented as a local transport. When used as a result of a
20401command in a user's filter file, autoreply normally runs under the uid and gid
20402of the user, and with appropriate current and home directories (see chapter 23
20403).
20404
20405There is a subtle difference between routing a message to a pipe transport that
20406generates some text to be returned to the sender, and routing it to an
20407autoreply transport. This difference is noticeable only if more than one
20408address from the same message is so handled. In the case of a pipe, the
20409separate outputs from the different addresses are gathered up and returned to
20410the sender in a single message, whereas if autoreply is used, a separate
20411message is generated for each address that is passed to it.
20412
20413Non-printing characters are not permitted in the header lines generated for the
20414message that autoreply creates, with the exception of newlines that are
20415immediately followed by white space. If any non-printing characters are found,
20416the transport defers. Whether characters with the top bit set count as printing
20417characters or not is controlled by the print_topbitchars global option.
20418
20419If any of the generic options for manipulating headers (for example,
20420headers_add) are set on an autoreply transport, they apply to the copy of the
20421original message that is included in the generated message when return_message
20422is set. They do not apply to the generated message itself.
20423
20424If the autoreply transport receives return code 2 from Exim when it submits the
20425message, indicating that there were no recipients, it does not treat this as an
20426error. This means that autoreplies sent to $sender_address when this is empty
20427(because the incoming message is a bounce message) do not cause problems. They
20428are just discarded.
20429
20430
2043127.1 Private options for autoreply
20432----------------------------------
20433
20434+---+--------------+-------------+--------------+
20435|bcc|Use: autoreply|Type: string*|Default: unset|
20436+---+--------------+-------------+--------------+
20437
20438This specifies the addresses that are to receive "blind carbon copies" of the
20439message when the message is specified by the transport.
20440
20441+--+--------------+-------------+--------------+
20442|cc|Use: autoreply|Type: string*|Default: unset|
20443+--+--------------+-------------+--------------+
20444
20445This specifies recipients of the message and the contents of the Cc: header
20446when the message is specified by the transport.
20447
20448+----+--------------+-------------+--------------+
20449|file|Use: autoreply|Type: string*|Default: unset|
20450+----+--------------+-------------+--------------+
20451
20452The contents of the file are sent as the body of the message when the message
20453is specified by the transport. If both file and text are set, the text string
20454comes first.
20455
20456+-----------+--------------+-------------+--------------+
20457|file_expand|Use: autoreply|Type: boolean|Default: false|
20458+-----------+--------------+-------------+--------------+
20459
20460If this is set, the contents of the file named by the file option are subjected
20461to string expansion as they are added to the message.
20462
20463+-------------+--------------+-------------+--------------+
20464|file_optional|Use: autoreply|Type: boolean|Default: false|
20465+-------------+--------------+-------------+--------------+
20466
20467If this option is true, no error is generated if the file named by the file
20468option or passed with the address does not exist or cannot be read.
20469
20470+----+--------------+-------------+--------------+
20471|from|Use: autoreply|Type: string*|Default: unset|
20472+----+--------------+-------------+--------------+
20473
20474This specifies the contents of the From: header when the message is specified
20475by the transport.
20476
20477+-------+--------------+-------------+--------------+
20478|headers|Use: autoreply|Type: string*|Default: unset|
20479+-------+--------------+-------------+--------------+
20480
20481This specifies additional RFC 2822 headers that are to be added to the message
20482when the message is specified by the transport. Several can be given by using "
20483\n" to separate them. There is no check on the format.
20484
20485+---+--------------+-------------+--------------+
20486|log|Use: autoreply|Type: string*|Default: unset|
20487+---+--------------+-------------+--------------+
20488
20489This option names a file in which a record of every message sent is logged when
20490the message is specified by the transport.
20491
20492+----+--------------+-------------------+-------------+
20493|mode|Use: autoreply|Type: octal integer|Default: 0600|
20494+----+--------------+-------------------+-------------+
20495
20496If either the log file or the "once" file has to be created, this mode is used.
20497
20498+----------+--------------+-------------------+--------------+
20499|never_mail|Use: autoreply|Type: address list*|Default: unset|
20500+----------+--------------+-------------------+--------------+
20501
20502If any run of the transport creates a message with a recipient that matches any
20503item in the list, that recipient is quietly discarded. If all recipients are
20504discarded, no message is created. This applies both when the recipients are
20505generated by a filter and when they are specified in the transport.
20506
20507+----+--------------+-------------+--------------+
20508|once|Use: autoreply|Type: string*|Default: unset|
20509+----+--------------+-------------+--------------+
20510
20511This option names a file or DBM database in which a record of each To:
20512recipient is kept when the message is specified by the transport. Note: This
20513does not apply to Cc: or Bcc: recipients.
20514
20515If once is unset, or is set to an empty string, the message is always sent. By
20516default, if once is set to a non-empty file name, the message is not sent if a
20517potential recipient is already listed in the database. However, if the
20518once_repeat option specifies a time greater than zero, the message is sent if
20519that much time has elapsed since a message was last sent to this recipient. A
20520setting of zero time for once_repeat (the default) prevents a message from
20521being sent a second time - in this case, zero means infinity.
20522
20523If once_file_size is zero, a DBM database is used to remember recipients, and
20524it is allowed to grow as large as necessary. If once_file_size is set greater
20525than zero, it changes the way Exim implements the once option. Instead of using
20526a DBM file to record every recipient it sends to, it uses a regular file, whose
20527size will never get larger than the given value.
20528
20529In the file, Exim keeps a linear list of recipient addresses and the times at
20530which they were sent messages. If the file is full when a new address needs to
20531be added, the oldest address is dropped. If once_repeat is not set, this means
20532that a given recipient may receive multiple messages, but at unpredictable
20533intervals that depend on the rate of turnover of addresses in the file. If
20534once_repeat is set, it specifies a maximum time between repeats.
20535
20536+--------------+--------------+-------------+----------+
20537|once_file_size|Use: autoreply|Type: integer|Default: 0|
20538+--------------+--------------+-------------+----------+
20539
20540See once above.
20541
20542+-----------+--------------+-----------+-----------+
20543|once_repeat|Use: autoreply|Type: time*|Default: 0s|
20544+-----------+--------------+-----------+-----------+
20545
20546See once above. After expansion, the value of this option must be a valid time
20547value.
20548
20549+--------+--------------+-------------+--------------+
20550|reply_to|Use: autoreply|Type: string*|Default: unset|
20551+--------+--------------+-------------+--------------+
20552
20553This specifies the contents of the Reply-To: header when the message is
20554specified by the transport.
20555
20556+--------------+--------------+-------------+--------------+
20557|return_message|Use: autoreply|Type: boolean|Default: false|
20558+--------------+--------------+-------------+--------------+
20559
20560If this is set, a copy of the original message is returned with the new
20561message, subject to the maximum size set in the return_size_limit global
20562configuration option.
20563
20564+-------+--------------+-------------+--------------+
20565|subject|Use: autoreply|Type: string*|Default: unset|
20566+-------+--------------+-------------+--------------+
20567
20568This specifies the contents of the Subject: header when the message is
20569specified by the transport. It is tempting to quote the original subject in
20570automatic responses. For example:
20571
20572subject = Re: $h_subject:
20573
20574There is a danger in doing this, however. It may allow a third party to
20575subscribe your users to an opt-in mailing list, provided that the list accepts
20576bounce messages as subscription confirmations. Well-managed lists require a
20577non-bounce message to confirm a subscription, so the danger is relatively
20578small.
20579
20580+----+--------------+-------------+--------------+
20581|text|Use: autoreply|Type: string*|Default: unset|
20582+----+--------------+-------------+--------------+
20583
20584This specifies a single string to be used as the body of the message when the
20585message is specified by the transport. If both text and file are set, the text
20586comes first.
20587
20588+--+--------------+-------------+--------------+
20589|to|Use: autoreply|Type: string*|Default: unset|
20590+--+--------------+-------------+--------------+
20591
20592This specifies recipients of the message and the contents of the To: header
20593when the message is specified by the transport.
20594
20595
20596
20597===============================================================================
2059828. THE LMTP TRANSPORT
20599
20600The lmtp transport runs the LMTP protocol (RFC 2033) over a pipe to a specified
20601command or by interacting with a Unix domain socket. This transport is
20602something of a cross between the pipe and smtp transports. Exim also has
20603support for using LMTP over TCP/IP; this is implemented as an option for the
20604smtp transport. Because LMTP is expected to be of minority interest, the
20605default build-time configure in src/EDITME has it commented out. You need to
20606ensure that
20607
20608TRANSPORT_LMTP=yes
20609
20610is present in your Local/Makefile in order to have the lmtp transport included
20611in the Exim binary. The private options of the lmtp transport are as follows:
20612
20613+--------+---------+-------------+--------------+
20614|batch_id|Use: lmtp|Type: string*|Default: unset|
20615+--------+---------+-------------+--------------+
20616
20617See the description of local delivery batching in chapter 25.
20618
20619+---------+---------+-------------+----------+
20620|batch_max|Use: lmtp|Type: integer|Default: 1|
20621+---------+---------+-------------+----------+
20622
20623This limits the number of addresses that can be handled in a single delivery.
20624Most LMTP servers can handle several addresses at once, so it is normally a
20625good idea to increase this value. See the description of local delivery
20626batching in chapter 25.
20627
20628+-------+---------+-------------+--------------+
20629|command|Use: lmtp|Type: string*|Default: unset|
20630+-------+---------+-------------+--------------+
20631
20632This option must be set if socket is not set. The string is a command which is
20633run in a separate process. It is split up into a command name and list of
20634arguments, each of which is separately expanded (so expansion cannot change the
20635number of arguments). The command is run directly, not via a shell. The message
20636is passed to the new process using the standard input and output to operate the
20637LMTP protocol.
20638
20639+------------+---------+-------------+--------------+
20640|ignore_quota|Use: lmtp|Type: boolean|Default: false|
20641+------------+---------+-------------+--------------+
20642
20643If this option is set true, the string "IGNOREQUOTA" is added to RCPT commands,
20644provided that the LMTP server has advertised support for IGNOREQUOTA in its
20645response to the LHLO command.
20646
20647+------+---------+-------------+--------------+
20648|socket|Use: lmtp|Type: string*|Default: unset|
20649+------+---------+-------------+--------------+
20650
20651This option must be set if command is not set. The result of expansion must be
20652the name of a Unix domain socket. The transport connects to the socket and
20653delivers the message to it using the LMTP protocol.
20654
20655+-------+---------+----------+-----------+
20656|timeout|Use: lmtp|Type: time|Default: 5m|
20657+-------+---------+----------+-----------+
20658
20659The transport is aborted if the created process or Unix domain socket does not
20660respond to LMTP commands or message input within this timeout. Delivery is
20661deferred, and will be tried again later. Here is an example of a typical LMTP
20662transport:
20663
20664lmtp:
20665 driver = lmtp
20666 command = /some/local/lmtp/delivery/program
20667 batch_max = 20
20668 user = exim
20669
20670This delivers up to 20 addresses at a time, in a mixture of domains if
20671necessary, running as the user exim.
20672
20673
20674
20675===============================================================================
2067629. THE PIPE TRANSPORT
20677
20678The pipe transport is used to deliver messages via a pipe to a command running
20679in another process. One example is the use of pipe as a pseudo-remote transport
20680for passing messages to some other delivery mechanism (such as UUCP). Another
20681is the use by individual users to automatically process their incoming
20682messages. The pipe transport can be used in one of the following ways:
20683
20684 * A router routes one address to a transport in the normal way, and the
20685 transport is configured as a pipe transport. In this case, $local_part
20686 contains the local part of the address (as usual), and the command that is
20687 run is specified by the command option on the transport.
20688
20689 * If the batch_max option is set greater than 1 (the default is 1), the
20690 transport can handle more than one address in a single run. In this case,
20691 when more than one address is routed to the transport, $local_part is not
20692 set (because it is not unique). However, the pseudo-variable
20693 $pipe_addresses (described in section 29.3 below) contains all the
20694 addresses that are routed to the transport.
20695
20696 * A router redirects an address directly to a pipe command (for example, from
20697 an alias or forward file). In this case, $address_pipe contains the text of
20698 the pipe command, and the command option on the transport is ignored unless
20699 force_command is set. If only one address is being transported (batch_max
20700 is not greater than one, or only one address was redirected to this pipe
20701 command), $local_part contains the local part that was redirected.
20702
20703The pipe transport is a non-interactive delivery method. Exim can also deliver
20704messages over pipes using the LMTP interactive protocol. This is implemented by
20705the lmtp transport.
20706
20707In the case when pipe is run as a consequence of an entry in a local user's
20708.forward file, the command runs under the uid and gid of that user. In other
20709cases, the uid and gid have to be specified explicitly, either on the transport
20710or on the router that handles the address. Current and "home" directories are
20711also controllable. See chapter 23 for details of the local delivery environment
20712and chapter 25 for a discussion of local delivery batching.
20713
20714
2071529.1 Concurrent delivery
20716------------------------
20717
20718If two messages arrive at almost the same time, and both are routed to a pipe
20719delivery, the two pipe transports may be run concurrently. You must ensure that
20720any pipe commands you set up are robust against this happening. If the commands
20721write to a file, the exim_lock utility might be of use.
20722
20723
2072429.2 Returned status and data
20725-----------------------------
20726
20727If the command exits with a non-zero return code, the delivery is deemed to
20728have failed, unless either the ignore_status option is set (in which case the
20729return code is treated as zero), or the return code is one of those listed in
20730the temp_errors option, which are interpreted as meaning "try again later". In
20731this case, delivery is deferred. Details of a permanent failure are logged, but
20732are not included in the bounce message, which merely contains "local delivery
20733failed".
20734
20735If the command exits on a signal and the freeze_signal option is set then the
20736message will be frozen in the queue. If that option is not set, a bounce will
20737be sent as normal.
20738
20739If the return code is greater than 128 and the command being run is a shell
20740script, it normally means that the script was terminated by a signal whose
20741value is the return code minus 128. The freeze_signal option does not apply in
20742this case.
20743
20744If Exim is unable to run the command (that is, if execve() fails), the return
20745code is set to 127. This is the value that a shell returns if it is asked to
20746run a non-existent command. The wording for the log line suggests that a
20747non-existent command may be the problem.
20748
20749The return_output option can affect the result of a pipe delivery. If it is set
20750and the command produces any output on its standard output or standard error
20751streams, the command is considered to have failed, even if it gave a zero
20752return code or if ignore_status is set. The output from the command is included
20753as part of the bounce message. The return_fail_output option is similar, except
20754that output is returned only when the command exits with a failure return code,
20755that is, a value other than zero or a code that matches temp_errors.
20756
20757
2075829.3 How the command is run
20759---------------------------
20760
20761The command line is (by default) broken down into a command name and arguments
20762by the pipe transport itself. The allow_commands and restrict_to_path options
20763can be used to restrict the commands that may be run.
20764
20765Unquoted arguments are delimited by white space. If an argument appears in
20766double quotes, backslash is interpreted as an escape character in the usual
20767way. If an argument appears in single quotes, no escaping is done.
20768
20769String expansion is applied to the command line except when it comes from a
20770traditional .forward file (commands from a filter file are expanded). The
20771expansion is applied to each argument in turn rather than to the whole line.
20772For this reason, any string expansion item that contains white space must be
20773quoted so as to be contained within a single argument. A setting such as
20774
20775command = /some/path ${if eq{$local_part}{postmaster}{xx}{yy}}
20776
20777will not work, because the expansion item gets split between several arguments.
20778You have to write
20779
20780command = /some/path "${if eq{$local_part}{postmaster}{xx}{yy}}"
20781
20782to ensure that it is all in one argument. The expansion is done in this way,
20783argument by argument, so that the number of arguments cannot be changed as a
20784result of expansion, and quotes or backslashes in inserted variables do not
20785interact with external quoting. However, this leads to problems if you want to
20786generate multiple arguments (or the command name plus arguments) from a single
20787expansion. In this situation, the simplest solution is to use a shell. For
20788example:
20789
20790command = /bin/sh -c ${lookup{$local_part}lsearch{/some/file}}
20791
20792Special handling takes place when an argument consists of precisely the text
20793"$pipe_addresses". This is not a general expansion variable; the only place
20794this string is recognized is when it appears as an argument for a pipe or
20795transport filter command. It causes each address that is being handled to be
20796inserted in the argument list at that point as a separate argument. This avoids
20797any problems with spaces or shell metacharacters, and is of use when a pipe
20798transport is handling groups of addresses in a batch.
20799
20800If force_command is enabled on the transport, Special handling takes place for
20801an argument that consists of precisely the text "$address_pipe". It is handled
20802similarly to $pipe_addresses above. It is expanded and each argument is
20803inserted in the argument list at that point as a separate argument. The
20804"$address_pipe" item does not need to be the only item in the argument; in
20805fact, if it were then force_command should behave as a no-op. Rather, it should
20806be used to adjust the command run while preserving the argument vector
20807separation.
20808
20809After splitting up into arguments and expansion, the resulting command is run
20810in a subprocess directly from the transport, not under a shell. The message
20811that is being delivered is supplied on the standard input, and the standard
20812output and standard error are both connected to a single pipe that is read by
20813Exim. The max_output option controls how much output the command may produce,
20814and the return_output and return_fail_output options control what is done with
20815it.
20816
20817Not running the command under a shell (by default) lessens the security risks
20818in cases when a command from a user's filter file is built out of data that was
20819taken from an incoming message. If a shell is required, it can of course be
20820explicitly specified as the command to be run. However, there are circumstances
20821where existing commands (for example, in .forward files) expect to be run under
20822a shell and cannot easily be modified. To allow for these cases, there is an
20823option called use_shell, which changes the way the pipe transport works.
20824Instead of breaking up the command line as just described, it expands it as a
20825single string and passes the result to /bin/sh. The restrict_to_path option and
20826the $pipe_addresses facility cannot be used with use_shell, and the whole
20827mechanism is inherently less secure.
20828
20829
2083029.4 Environment variables
20831--------------------------
20832
20833The environment variables listed below are set up when the command is invoked.
20834This list is a compromise for maximum compatibility with other MTAs. Note that
20835the environment option can be used to add additional variables to this
20836environment.
20837
20838DOMAIN the domain of the address
20839HOME the home directory, if set
20840HOST the host name when called from a router (see below)
20841LOCAL_PART see below
20842LOCAL_PART_PREFIX see below
20843LOCAL_PART_SUFFIX see below
20844LOGNAME see below
20845MESSAGE_ID Exim's local ID for the message
20846PATH as specified by the path option below
20847QUALIFY_DOMAIN the sender qualification domain
20848RECIPIENT the complete recipient address
20849SENDER the sender of the message (empty if a bounce)
20850SHELL /bin/sh
20851TZ the value of the timezone option, if set
20852USER see below
20853
20854When a pipe transport is called directly from (for example) an accept router,
20855LOCAL_PART is set to the local part of the address. When it is called as a
20856result of a forward or alias expansion, LOCAL_PART is set to the local part of
20857the address that was expanded. In both cases, any affixes are removed from the
20858local part, and made available in LOCAL_PART_PREFIX and LOCAL_PART_SUFFIX,
20859respectively. LOGNAME and USER are set to the same value as LOCAL_PART for
20860compatibility with other MTAs.
20861
20862HOST is set only when a pipe transport is called from a router that associates
20863hosts with an address, typically when using pipe as a pseudo-remote transport.
20864HOST is set to the first host name specified by the router.
20865
20866If the transport's generic home_directory option is set, its value is used for
20867the HOME environment variable. Otherwise, a home directory may be set by the
20868router's transport_home_directory option, which defaults to the user's home
20869directory if check_local_user is set.
20870
20871
2087229.5 Private options for pipe
20873-----------------------------
20874
20875+--------------+---------+------------------+--------------+
20876|allow_commands|Use: pipe|Type: string list*|Default: unset|
20877+--------------+---------+------------------+--------------+
20878
20879The string is expanded, and is then interpreted as a colon-separated list of
20880permitted commands. If restrict_to_path is not set, the only commands permitted
20881are those in the allow_commands list. They need not be absolute paths; the path
20882option is still used for relative paths. If restrict_to_path is set with
20883allow_commands, the command must either be in the allow_commands list, or a
20884name without any slashes that is found on the path. In other words, if neither
20885allow_commands nor restrict_to_path is set, there is no restriction on the
20886command, but otherwise only commands that are permitted by one or the other are
20887allowed. For example, if
20888
20889allow_commands = /usr/bin/vacation
20890
20891and restrict_to_path is not set, the only permitted command is /usr/bin/
20892vacation. The allow_commands option may not be set if use_shell is set.
20893
20894+--------+---------+-------------+--------------+
20895|batch_id|Use: pipe|Type: string*|Default: unset|
20896+--------+---------+-------------+--------------+
20897
20898See the description of local delivery batching in chapter 25.
20899
20900+---------+---------+-------------+----------+
20901|batch_max|Use: pipe|Type: integer|Default: 1|
20902+---------+---------+-------------+----------+
20903
20904This limits the number of addresses that can be handled in a single delivery.
20905See the description of local delivery batching in chapter 25.
20906
20907+------------+---------+------------+--------------+
20908|check_string|Use: pipe|Type: string|Default: unset|
20909+------------+---------+------------+--------------+
20910
20911As pipe writes the message, the start of each line is tested for matching
20912check_string, and if it does, the initial matching characters are replaced by
20913the contents of escape_string, provided both are set. The value of check_string
20914is a literal string, not a regular expression, and the case of any letters it
20915contains is significant. When use_bsmtp is set, the contents of check_string
20916and escape_string are forced to values that implement the SMTP escaping
20917protocol. Any settings made in the configuration file are ignored.
20918
20919+-------+---------+-------------+--------------+
20920|command|Use: pipe|Type: string*|Default: unset|
20921+-------+---------+-------------+--------------+
20922
20923This option need not be set when pipe is being used to deliver to pipes
20924obtained directly from address redirections. In other cases, the option must be
20925set, to provide a command to be run. It need not yield an absolute path (see
20926the path option below). The command is split up into separate arguments by
20927Exim, and each argument is separately expanded, as described in section 29.3
20928above.
20929
20930+-----------+---------+-------------+--------------+
20931|environment|Use: pipe|Type: string*|Default: unset|
20932+-----------+---------+-------------+--------------+
20933
20934This option is used to add additional variables to the environment in which the
20935command runs (see section 29.4 for the default list). Its value is a string
20936which is expanded, and then interpreted as a colon-separated list of
20937environment settings of the form <name>=<value>.
20938
20939+-------------+---------+------------+--------------+
20940|escape_string|Use: pipe|Type: string|Default: unset|
20941+-------------+---------+------------+--------------+
20942
20943See check_string above.
20944
20945+----------------+---------+-------------+--------------+
20946|freeze_exec_fail|Use: pipe|Type: boolean|Default: false|
20947+----------------+---------+-------------+--------------+
20948
20949Failure to exec the command in a pipe transport is by default treated like any
20950other failure while running the command. However, if freeze_exec_fail is set,
20951failure to exec is treated specially, and causes the message to be frozen,
20952whatever the setting of ignore_status.
20953
20954+-------------+---------+-------------+--------------+
20955|freeze_signal|Use: pipe|Type: boolean|Default: false|
20956+-------------+---------+-------------+--------------+
20957
20958Normally if the process run by a command in a pipe transport exits on a signal,
20959a bounce message is sent. If freeze_signal is set, the message will be frozen
20960in Exim's queue instead.
20961
20962+-------------+---------+-------------+--------------+
20963|force_command|Use: pipe|Type: boolean|Default: false|
20964+-------------+---------+-------------+--------------+
20965
20966Normally when a router redirects an address directly to a pipe command the
20967command option on the transport is ignored. If force_command is set, the
20968command option will used. This is especially useful for forcing a wrapper or
20969additional argument to be added to the command. For example:
20970
20971command = /usr/bin/remote_exec myhost -- $address_pipe
20972force_command
20973
20974Note that $address_pipe is handled specially in command when force_command is
20975set, expanding out to the original argument vector as separate items, similarly
20976to a Unix shell ""$@"" construct.
20977
20978+-------------+---------+-------------+--------------+
20979|ignore_status|Use: pipe|Type: boolean|Default: false|
20980+-------------+---------+-------------+--------------+
20981
20982If this option is true, the status returned by the subprocess that is set up to
20983run the command is ignored, and Exim behaves as if zero had been returned.
20984Otherwise, a non-zero status or termination by signal causes an error return
20985from the transport unless the status value is one of those listed in
20986temp_errors; these cause the delivery to be deferred and tried again later.
20987
20988Note: This option does not apply to timeouts, which do not return a status. See
20989the timeout_defer option for how timeouts are handled.
20990
20991+----------------+---------+-------------+--------------+
20992|log_defer_output|Use: pipe|Type: boolean|Default: false|
20993+----------------+---------+-------------+--------------+
20994
20995If this option is set, and the status returned by the command is one of the
20996codes listed in temp_errors (that is, delivery was deferred), and any output
20997was produced, the first line of it is written to the main log.
20998
20999+---------------+---------+-------------+--------------+
21000|log_fail_output|Use: pipe|Type: boolean|Default: false|
21001+---------------+---------+-------------+--------------+
21002
21003If this option is set, and the command returns any output, and also ends with a
21004return code that is neither zero nor one of the return codes listed in
21005temp_errors (that is, the delivery failed), the first line of output is written
21006to the main log. This option and log_output are mutually exclusive. Only one of
21007them may be set.
21008
21009+----------+---------+-------------+--------------+
21010|log_output|Use: pipe|Type: boolean|Default: false|
21011+----------+---------+-------------+--------------+
21012
21013If this option is set and the command returns any output, the first line of
21014output is written to the main log, whatever the return code. This option and
21015log_fail_output are mutually exclusive. Only one of them may be set.
21016
21017+----------+---------+-------------+------------+
21018|max_output|Use: pipe|Type: integer|Default: 20K|
21019+----------+---------+-------------+------------+
21020
21021This specifies the maximum amount of output that the command may produce on its
21022standard output and standard error file combined. If the limit is exceeded, the
21023process running the command is killed. This is intended as a safety measure to
21024catch runaway processes. The limit is applied independently of the settings of
21025the options that control what is done with such output (for example,
21026return_output). Because of buffering effects, the amount of output may exceed
21027the limit by a small amount before Exim notices.
21028
21029+--------------+---------+-------------+------------------+
21030|message_prefix|Use: pipe|Type: string*|Default: see below|
21031+--------------+---------+-------------+------------------+
21032
21033The string specified here is expanded and output at the start of every message.
21034The default is unset if use_bsmtp is set. Otherwise it is
21035
21036message_prefix = \
21037 From ${if def:return_path{$return_path}{MAILER-DAEMON}}\
21038 ${tod_bsdinbox}\n
21039
21040This is required by the commonly used /usr/bin/vacation program. However, it
21041must not be present if delivery is to the Cyrus IMAP server, or to the tmail
21042local delivery agent. The prefix can be suppressed by setting
21043
21044message_prefix =
21045
21046Note: If you set use_crlf true, you must change any occurrences of "\n" to "\r\
21047n" in message_prefix.
21048
21049+--------------+---------+-------------+------------------+
21050|message_suffix|Use: pipe|Type: string*|Default: see below|
21051+--------------+---------+-------------+------------------+
21052
21053The string specified here is expanded and output at the end of every message.
21054The default is unset if use_bsmtp is set. Otherwise it is a single newline. The
21055suffix can be suppressed by setting
21056
21057message_suffix =
21058
21059Note: If you set use_crlf true, you must change any occurrences of "\n" to "\r\
21060n" in message_suffix.
21061
21062+----+---------+------------+------------------+
21063|path|Use: pipe|Type: string|Default: see below|
21064+----+---------+------------+------------------+
21065
21066This option specifies the string that is set up in the PATH environment
21067variable of the subprocess. The default is:
21068
21069/bin:/usr/bin
21070
21071If the command option does not yield an absolute path name, the command is
21072sought in the PATH directories, in the usual way. Warning: This does not apply
21073to a command specified as a transport filter.
21074
21075+---------------+---------+-------------+--------------+
21076|permit_coredump|Use: pipe|Type: boolean|Default: false|
21077+---------------+---------+-------------+--------------+
21078
21079Normally Exim inhibits core-dumps during delivery. If you have a need to get a
21080core-dump of a pipe command, enable this command. This enables core-dumps
21081during delivery and affects both the Exim binary and the pipe command run. It
21082is recommended that this option remain off unless and until you have a need for
21083it and that this only be enabled when needed, as the risk of excessive resource
21084consumption can be quite high. Note also that Exim is typically installed as a
21085setuid binary and most operating systems will inhibit coredumps of these by
21086default, so further OS-specific action may be required.
21087
21088+---------------+---------+-------------+--------------+
21089|pipe_as_creator|Use: pipe|Type: boolean|Default: false|
21090+---------------+---------+-------------+--------------+
21091
21092If the generic user option is not set and this option is true, the delivery
21093process is run under the uid that was in force when Exim was originally called
21094to accept the message. If the group id is not otherwise set (via the generic
21095group option), the gid that was in force when Exim was originally called to
21096accept the message is used.
21097
21098+----------------+---------+-------------+--------------+
21099|restrict_to_path|Use: pipe|Type: boolean|Default: false|
21100+----------------+---------+-------------+--------------+
21101
21102When this option is set, any command name not listed in allow_commands must
21103contain no slashes. The command is searched for only in the directories listed
21104in the path option. This option is intended for use in the case when a pipe
21105command has been generated from a user's .forward file. This is usually handled
21106by a pipe transport called address_pipe.
21107
21108+------------------+---------+-------------+--------------+
21109|return_fail_output|Use: pipe|Type: boolean|Default: false|
21110+------------------+---------+-------------+--------------+
21111
21112If this option is true, and the command produced any output and ended with a
21113return code other than zero or one of the codes listed in temp_errors (that is,
21114the delivery failed), the output is returned in the bounce message. However, if
21115the message has a null sender (that is, it is itself a bounce message), output
21116from the command is discarded. This option and return_output are mutually
21117exclusive. Only one of them may be set.
21118
21119+-------------+---------+-------------+--------------+
21120|return_output|Use: pipe|Type: boolean|Default: false|
21121+-------------+---------+-------------+--------------+
21122
21123If this option is true, and the command produced any output, the delivery is
21124deemed to have failed whatever the return code from the command, and the output
21125is returned in the bounce message. Otherwise, the output is just discarded.
21126However, if the message has a null sender (that is, it is a bounce message),
21127output from the command is always discarded, whatever the setting of this
21128option. This option and return_fail_output are mutually exclusive. Only one of
21129them may be set.
21130
21131+-----------+---------+-----------------+------------------+
21132|temp_errors|Use: pipe|Type: string list|Default: see below|
21133+-----------+---------+-----------------+------------------+
21134
21135This option contains either a colon-separated list of numbers, or a single
21136asterisk. If ignore_status is false and return_output is not set, and the
21137command exits with a non-zero return code, the failure is treated as temporary
21138and the delivery is deferred if the return code matches one of the numbers, or
21139if the setting is a single asterisk. Otherwise, non-zero return codes are
21140treated as permanent errors. The default setting contains the codes defined by
21141EX_TEMPFAIL and EX_CANTCREAT in sysexits.h. If Exim is compiled on a system
21142that does not define these macros, it assumes values of 75 and 73,
21143respectively.
21144
21145+-------+---------+----------+-----------+
21146|timeout|Use: pipe|Type: time|Default: 1h|
21147+-------+---------+----------+-----------+
21148
21149If the command fails to complete within this time, it is killed. This normally
21150causes the delivery to fail (but see timeout_defer). A zero time interval
21151specifies no timeout. In order to ensure that any subprocesses created by the
21152command are also killed, Exim makes the initial process a process group leader,
21153and kills the whole process group on a timeout. However, this can be defeated
21154if one of the processes starts a new process group.
21155
21156+-------------+---------+-------------+--------------+
21157|timeout_defer|Use: pipe|Type: boolean|Default: false|
21158+-------------+---------+-------------+--------------+
21159
21160A timeout in a pipe transport, either in the command that the transport runs,
21161or in a transport filter that is associated with it, is by default treated as a
21162hard error, and the delivery fails. However, if timeout_defer is set true, both
21163kinds of timeout become temporary errors, causing the delivery to be deferred.
21164
21165+-----+---------+-------------------+------------+
21166|umask|Use: pipe|Type: octal integer|Default: 022|
21167+-----+---------+-------------------+------------+
21168
21169This specifies the umask setting for the subprocess that runs the command.
21170
21171+---------+---------+-------------+--------------+
21172|use_bsmtp|Use: pipe|Type: boolean|Default: false|
21173+---------+---------+-------------+--------------+
21174
21175If this option is set true, the pipe transport writes messages in "batch SMTP"
21176format, with the envelope sender and recipient(s) included as SMTP commands. If
21177you want to include a leading HELO command with such messages, you can do so by
21178setting the message_prefix option. See section 47.10 for details of batch SMTP.
21179
21180+------------------+---------+-------------+--------------+
21181|use_classresources|Use: pipe|Type: boolean|Default: false|
21182+------------------+---------+-------------+--------------+
21183
21184This option is available only when Exim is running on FreeBSD, NetBSD, or BSD/
21185OS. If it is set true, the setclassresources() function is used to set resource
21186limits when a pipe transport is run to perform a delivery. The limits for the
21187uid under which the pipe is to run are obtained from the login class database.
21188
21189+--------+---------+-------------+--------------+
21190|use_crlf|Use: pipe|Type: boolean|Default: false|
21191+--------+---------+-------------+--------------+
21192
21193This option causes lines to be terminated with the two-character CRLF sequence
21194(carriage return, linefeed) instead of just a linefeed character. In the case
21195of batched SMTP, the byte sequence written to the pipe is then an exact image
21196of what would be sent down a real SMTP connection.
21197
21198The contents of the message_prefix and message_suffix options are written
21199verbatim, so must contain their own carriage return characters if these are
21200needed. When use_bsmtp is not set, the default values for both message_prefix
21201and message_suffix end with a single linefeed, so their values must be changed
21202to end with "\r\n" if use_crlf is set.
21203
21204+---------+---------+-------------+--------------+
21205|use_shell|Use: pipe|Type: boolean|Default: false|
21206+---------+---------+-------------+--------------+
21207
21208If this option is set, it causes the command to be passed to /bin/sh instead of
21209being run directly from the transport, as described in section 29.3. This is
21210less secure, but is needed in some situations where the command is expected to
21211be run under a shell and cannot easily be modified. The allow_commands and
21212restrict_to_path options, and the "$pipe_addresses" facility are incompatible
21213with use_shell. The command is expanded as a single string, and handed to /bin/
21214sh as data for its -c option.
21215
21216
2121729.6 Using an external local delivery agent
21218-------------------------------------------
21219
21220The pipe transport can be used to pass all messages that require local delivery
21221to a separate local delivery agent such as procmail. When doing this, care must
21222be taken to ensure that the pipe is run under an appropriate uid and gid. In
21223some configurations one wants this to be a uid that is trusted by the delivery
21224agent to supply the correct sender of the message. It may be necessary to
21225recompile or reconfigure the delivery agent so that it trusts an appropriate
21226user. The following is an example transport and router configuration for
21227procmail:
21228
21229# transport
21230procmail_pipe:
21231 driver = pipe
21232 command = /usr/local/bin/procmail -d $local_part
21233 return_path_add
21234 delivery_date_add
21235 envelope_to_add
21236 check_string = "From "
21237 escape_string = ">From "
21238 umask = 077
21239 user = $local_part
21240 group = mail
21241
21242# router
21243procmail:
21244 driver = accept
21245 check_local_user
21246 transport = procmail_pipe
21247
21248In this example, the pipe is run as the local user, but with the group set to
21249mail. An alternative is to run the pipe as a specific user such as mail or exim
21250, but in this case you must arrange for procmail to trust that user to supply a
21251correct sender address. If you do not specify either a group or a user option,
21252the pipe command is run as the local user. The home directory is the user's
21253home directory by default.
21254
21255Note: The command that the pipe transport runs does not begin with
21256
21257IFS=" "
21258
21259as shown in some procmail documentation, because Exim does not by default use a
21260shell to run pipe commands.
21261
21262The next example shows a transport and a router for a system where local
21263deliveries are handled by the Cyrus IMAP server.
21264
21265# transport
21266local_delivery_cyrus:
21267 driver = pipe
21268 command = /usr/cyrus/bin/deliver \
21269 -m ${substr_1:$local_part_suffix} -- $local_part
21270 user = cyrus
21271 group = mail
21272 return_output
21273 log_output
21274 message_prefix =
21275 message_suffix =
21276
21277# router
21278local_user_cyrus:
21279 driver = accept
21280 check_local_user
21281 local_part_suffix = .*
21282 transport = local_delivery_cyrus
21283
21284Note the unsetting of message_prefix and message_suffix, and the use of
21285return_output to cause any text written by Cyrus to be returned to the sender.
21286
21287
21288
21289===============================================================================
2129030. THE SMTP TRANSPORT
21291
21292The smtp transport delivers messages over TCP/IP connections using the SMTP or
21293LMTP protocol. The list of hosts to try can either be taken from the address
21294that is being processed (having been set up by the router), or specified
21295explicitly for the transport. Timeout and retry processing (see chapter 32) is
21296applied to each IP address independently.
21297
21298
2129930.1 Multiple messages on a single connection
21300---------------------------------------------
21301
21302The sending of multiple messages over a single TCP/IP connection can arise in
21303two ways:
21304
21305 * If a message contains more than max_rcpt (see below) addresses that are
21306 routed to the same host, more than one copy of the message has to be sent
21307 to that host. In this situation, multiple copies may be sent in a single
21308 run of the smtp transport over a single TCP/IP connection. (What Exim
21309 actually does when it has too many addresses to send in one message also
21310 depends on the value of the global remote_max_parallel option. Details are
21311 given in section 47.1.)
21312
21313 * When a message has been successfully delivered over a TCP/IP connection,
21314 Exim looks in its hints database to see if there are any other messages
21315 awaiting a connection to the same host. If there are, a new delivery
21316 process is started for one of them, and the current TCP/IP connection is
21317 passed on to it. The new process may in turn send multiple copies and
21318 possibly create yet another process.
21319
21320For each copy sent over the same TCP/IP connection, a sequence counter is
21321incremented, and if it ever gets to the value of connection_max_messages, no
21322further messages are sent over that connection.
21323
21324
2132530.2 Use of the $host and $host_address variables
21326-------------------------------------------------
21327
21328At the start of a run of the smtp transport, the values of $host and
21329$host_address are the name and IP address of the first host on the host list
21330passed by the router. However, when the transport is about to connect to a
21331specific host, and while it is connected to that host, $host and $host_address
21332are set to the values for that host. These are the values that are in force
21333when the helo_data, hosts_try_auth, interface, serialize_hosts, and the various
21334TLS options are expanded.
21335
21336
2133730.3 Use of $tls_cipher and $tls_peerdn
21338---------------------------------------
21339
21340At the start of a run of the smtp transport, the values of $tls_bits,
21341$tls_cipher, $tls_peerdn and $tls_sni are the values that were set when the
21342message was received. These are the values that are used for options that are
21343expanded before any SMTP connections are made. Just before each connection is
21344made, these four variables are emptied. If TLS is subsequently started, they
21345are set to the appropriate values for the outgoing connection, and these are
21346the values that are in force when any authenticators are run and when the
21347authenticated_sender option is expanded.
21348
21349These variables are deprecated in favour of $tls_in_cipher et. al. and will be
21350removed in a future release.
21351
21352
2135330.4 Private options for smtp
21354-----------------------------
21355
21356The private options of the smtp transport are as follows:
21357
21358+----------------------------+---------+-------------+-------------+
21359|address_retry_include_sender|Use: smtp|Type: boolean|Default: true|
21360+----------------------------+---------+-------------+-------------+
21361
21362When an address is delayed because of a 4xx response to a RCPT command, it is
21363the combination of sender and recipient that is delayed in subsequent queue
21364runs until the retry time is reached. You can delay the recipient without
21365reference to the sender (which is what earlier versions of Exim did), by
21366setting address_retry_include_sender false. However, this can lead to problems
21367with servers that regularly issue 4xx responses to RCPT commands.
21368
21369+---------------+---------+-------------+--------------+
21370|allow_localhost|Use: smtp|Type: boolean|Default: false|
21371+---------------+---------+-------------+--------------+
21372
21373When a host specified in hosts or fallback_hosts (see below) turns out to be
21374the local host, or is listed in hosts_treat_as_local, delivery is deferred by
21375default. However, if allow_localhost is set, Exim goes on to do the delivery
21376anyway. This should be used only in special cases when the configuration
21377ensures that no looping will result (for example, a differently configured Exim
21378is listening on the port to which the message is sent).
21379
21380+--------------------+---------+-------------+--------------+
21381|authenticated_sender|Use: smtp|Type: string*|Default: unset|
21382+--------------------+---------+-------------+--------------+
21383
21384When Exim has authenticated as a client, or if authenticated_sender_force is
21385true, this option sets a value for the AUTH= item on outgoing MAIL commands,
21386overriding any existing authenticated sender value. If the string expansion is
21387forced to fail, the option is ignored. Other expansion failures cause delivery
21388to be deferred. If the result of expansion is an empty string, that is also
21389ignored.
21390
21391The expansion happens after the outgoing connection has been made and TLS
21392started, if required. This means that the $host, $host_address, $tls_out_cipher
21393, and $tls_out_peerdn variables are set according to the particular connection.
21394
21395If the SMTP session is not authenticated, the expansion of authenticated_sender
21396still happens (and can cause the delivery to be deferred if it fails), but no
21397AUTH= item is added to MAIL commands unless authenticated_sender_force is true.
21398
21399This option allows you to use the smtp transport in LMTP mode to deliver mail
21400to Cyrus IMAP and provide the proper local part as the "authenticated sender",
21401via a setting such as:
21402
21403authenticated_sender = $local_part
21404
21405This removes the need for IMAP subfolders to be assigned special ACLs to allow
21406direct delivery to those subfolders.
21407
21408Because of expected uses such as that just described for Cyrus (when no domain
21409is involved), there is no checking on the syntax of the provided value.
21410
21411+--------------------------+---------+-------------+--------------+
21412|authenticated_sender_force|Use: smtp|Type: boolean|Default: false|
21413+--------------------------+---------+-------------+--------------+
21414
21415If this option is set true, the authenticated_sender option's value is used for
21416the AUTH= item on outgoing MAIL commands, even if Exim has not authenticated as
21417a client.
21418
21419+---------------+---------+----------+-----------+
21420|command_timeout|Use: smtp|Type: time|Default: 5m|
21421+---------------+---------+----------+-----------+
21422
21423This sets a timeout for receiving a response to an SMTP command that has been
21424sent out. It is also used when waiting for the initial banner line from the
21425remote host. Its value must not be zero.
21426
21427+---------------+---------+----------+-----------+
21428|connect_timeout|Use: smtp|Type: time|Default: 5m|
21429+---------------+---------+----------+-----------+
21430
21431This sets a timeout for the connect() function, which sets up a TCP/IP call to
21432a remote host. A setting of zero allows the system timeout (typically several
21433minutes) to act. To have any effect, the value of this option must be less than
21434the system timeout. However, it has been observed that on some systems there is
21435no system timeout, which is why the default value for this option is 5 minutes,
21436a value recommended by RFC 1123.
21437
21438+-----------------------+---------+-------------+------------+
21439|connection_max_messages|Use: smtp|Type: integer|Default: 500|
21440+-----------------------+---------+-------------+------------+
21441
21442This controls the maximum number of separate message deliveries that are sent
21443over a single TCP/IP connection. If the value is zero, there is no limit. For
21444testing purposes, this value can be overridden by the -oB command line option.
21445
21446+------------+---------+----------+-----------+
21447|data_timeout|Use: smtp|Type: time|Default: 5m|
21448+------------+---------+----------+-----------+
21449
21450This sets a timeout for the transmission of each block in the data portion of
21451the message. As a result, the overall timeout for a message depends on the size
21452of the message. Its value must not be zero. See also final_timeout.
21453
21454+------------------+---------+-------------+-------------+
21455|delay_after_cutoff|Use: smtp|Type: boolean|Default: true|
21456+------------------+---------+-------------+-------------+
21457
21458This option controls what happens when all remote IP addresses for a given
21459domain have been inaccessible for so long that they have passed their retry
21460cutoff times.
21461
21462In the default state, if the next retry time has not been reached for any of
21463them, the address is bounced without trying any deliveries. In other words,
21464Exim delays retrying an IP address after the final cutoff time until a new
21465retry time is reached, and can therefore bounce an address without ever trying
21466a delivery, when machines have been down for a long time. Some people are
21467unhappy at this prospect, so...
21468
21469If delay_after_cutoff is set false, Exim behaves differently. If all IP
21470addresses are past their final cutoff time, Exim tries to deliver to those IP
21471addresses that have not been tried since the message arrived. If there are
21472none, of if they all fail, the address is bounced. In other words, it does not
21473delay when a new message arrives, but immediately tries those expired IP
21474addresses that haven't been tried since the message arrived. If there is a
21475continuous stream of messages for the dead hosts, unsetting delay_after_cutoff
21476means that there will be many more attempts to deliver to them.
21477
21478+------------------+---------+-------------+-------------+
21479|dns_qualify_single|Use: smtp|Type: boolean|Default: true|
21480+------------------+---------+-------------+-------------+
21481
21482If the hosts or fallback_hosts option is being used, and the gethostbyname
21483option is false, the RES_DEFNAMES resolver option is set. See the
21484qualify_single option in chapter 17 for more details.
21485
21486+------------------+---------+-------------+--------------+
21487|dns_search_parents|Use: smtp|Type: boolean|Default: false|
21488+------------------+---------+-------------+--------------+
21489
21490If the hosts or fallback_hosts option is being used, and the gethostbyname
21491option is false, the RES_DNSRCH resolver option is set. See the search_parents
21492option in chapter 17 for more details.
21493
21494+----------------------+---------+------------------+--------------+
21495|dnssec_request_domains|Use: smtp|Type: domain list*|Default: unset|
21496+----------------------+---------+------------------+--------------+
21497
21498DNS lookups for domains matching dnssec_request_domains will be done with the
21499dnssec request bit set. This applies to all of the SRV, MX A6, AAAA, A lookup
21500sequence.
21501
21502+----------------------+---------+------------------+--------------+
21503|dnssec_require_domains|Use: smtp|Type: domain list*|Default: unset|
21504+----------------------+---------+------------------+--------------+
21505
21506DNS lookups for domains matching dnssec_request_domains will be done with the
21507dnssec request bit set. Any returns not having the Authenticated Data bit (AD
21508bit) set wil be ignored and logged as a host-lookup failure. This applies to
21509all of the SRV, MX A6, AAAA, A lookup sequence.
21510
21511+----+---------+-------------+--------------+
21512|dscp|Use: smtp|Type: string*|Default: unset|
21513+----+---------+-------------+--------------+
21514
21515This option causes the DSCP value associated with a socket to be set to one of
21516a number of fixed strings or to numeric value. The -bI:dscp option may be used
21517to ask Exim which names it knows of. Common values include "throughput",
21518"mincost", and on newer systems "ef", "af41", etc. Numeric values may be in the
21519range 0 to 0x3F.
21520
21521The outbound packets from Exim will be marked with this value in the header
21522(for IPv4, the TOS field; for IPv6, the TCLASS field); there is no guarantee
21523that these values will have any effect, not be stripped by networking
21524equipment, or do much of anything without cooperation with your Network
21525Engineer and those of all network operators between the source and destination.
21526
21527+--------------+---------+-----------------+--------------+
21528|fallback_hosts|Use: smtp|Type: string list|Default: unset|
21529+--------------+---------+-----------------+--------------+
21530
21531String expansion is not applied to this option. The argument must be a
21532colon-separated list of host names or IP addresses, optionally also including
21533port numbers, though the separator can be changed, as described in section 6.19
21534. Each individual item in the list is the same as an item in a route_list
21535setting for the manualroute router, as described in section 20.5.
21536
21537Fallback hosts can also be specified on routers, which associate them with the
21538addresses they process. As for the hosts option without hosts_override,
21539fallback_hosts specified on the transport is used only if the address does not
21540have its own associated fallback host list. Unlike hosts, a setting of
21541fallback_hosts on an address is not overridden by hosts_override. However,
21542hosts_randomize does apply to fallback host lists.
21543
21544If Exim is unable to deliver to any of the hosts for a particular address, and
21545the errors are not permanent rejections, the address is put on a separate
21546transport queue with its host list replaced by the fallback hosts, unless the
21547address was routed via MX records and the current host was in the original MX
21548list. In that situation, the fallback host list is not used.
21549
21550Once normal deliveries are complete, the fallback queue is delivered by
21551re-running the same transports with the new host lists. If several failing
21552addresses have the same fallback hosts (and max_rcpt permits it), a single copy
21553of the message is sent.
21554
21555The resolution of the host names on the fallback list is controlled by the
21556gethostbyname option, as for the hosts option. Fallback hosts apply both to
21557cases when the host list comes with the address and when it is taken from hosts
21558. This option provides a "use a smart host only if delivery fails" facility.
21559
21560+-------------+---------+----------+------------+
21561|final_timeout|Use: smtp|Type: time|Default: 10m|
21562+-------------+---------+----------+------------+
21563
21564This is the timeout that applies while waiting for the response to the final
21565line containing just "." that terminates a message. Its value must not be zero.
21566
21567+-------------+---------+-------------+--------------+
21568|gethostbyname|Use: smtp|Type: boolean|Default: false|
21569+-------------+---------+-------------+--------------+
21570
21571If this option is true when the hosts and/or fallback_hosts options are being
21572used, names are looked up using gethostbyname() (or getipnodebyname() when
21573available) instead of using the DNS. Of course, that function may in fact use
21574the DNS, but it may also consult other sources of information such as /etc/
21575hosts.
21576
21577+------------------+---------+-------------+--------------+
21578|gnutls_compat_mode|Use: smtp|Type: boolean|Default: unset|
21579+------------------+---------+-------------+--------------+
21580
21581This option controls whether GnuTLS is used in compatibility mode in an Exim
21582server. This reduces security slightly, but improves interworking with older
21583implementations of TLS.
21584
21585+---------+---------+-------------+------------------+
21586|helo_data|Use: smtp|Type: string*|Default: see below|
21587+---------+---------+-------------+------------------+
21588
21589The value of this option is expanded after a connection to a another host has
21590been set up. The result is used as the argument for the EHLO, HELO, or LHLO
21591command that starts the outgoing SMTP or LMTP session. The default value of the
21592option is:
21593
21594$primary_hostname
21595
21596During the expansion, the variables $host and $host_address are set to the
21597identity of the remote host, and the variables $sending_ip_address and
21598$sending_port are set to the local IP address and port number that are being
21599used. These variables can be used to generate different values for different
21600servers or different local IP addresses. For example, if you want the string
21601that is used for helo_data to be obtained by a DNS lookup of the outgoing
21602interface address, you could use this:
21603
21604helo_data = ${lookup dnsdb{ptr=$sending_ip_address}{$value}\
21605 {$primary_hostname}}
21606
21607The use of helo_data applies both to sending messages and when doing callouts.
21608
21609+-----+---------+------------------+--------------+
21610|hosts|Use: smtp|Type: string list*|Default: unset|
21611+-----+---------+------------------+--------------+
21612
21613Hosts are associated with an address by a router such as dnslookup, which finds
21614the hosts by looking up the address domain in the DNS, or by manualroute, which
21615has lists of hosts in its configuration. However, email addresses can be passed
21616to the smtp transport by any router, and not all of them can provide an
21617associated list of hosts.
21618
21619The hosts option specifies a list of hosts to be used if the address being
21620processed does not have any hosts associated with it. The hosts specified by
21621hosts are also used, whether or not the address has its own hosts, if
21622hosts_override is set.
21623
21624The string is first expanded, before being interpreted as a colon-separated
21625list of host names or IP addresses, possibly including port numbers. The
21626separator may be changed to something other than colon, as described in section
216276.19. Each individual item in the list is the same as an item in a route_list
21628setting for the manualroute router, as described in section 20.5. However, note
21629that the "/MX" facility of the manualroute router is not available here.
21630
21631If the expansion fails, delivery is deferred. Unless the failure was caused by
21632the inability to complete a lookup, the error is logged to the panic log as
21633well as the main log. Host names are looked up either by searching directly for
21634address records in the DNS or by calling gethostbyname() (or getipnodebyname()
21635when available), depending on the setting of the gethostbyname option. When
21636Exim is compiled with IPv6 support, if a host that is looked up in the DNS has
21637both IPv4 and IPv6 addresses, both types of address are used.
21638
21639During delivery, the hosts are tried in order, subject to their retry status,
21640unless hosts_randomize is set.
21641
21642+-----------------+---------+----------------+--------------+
21643|hosts_avoid_esmtp|Use: smtp|Type: host list*|Default: unset|
21644+-----------------+---------+----------------+--------------+
21645
21646This option is for use with broken hosts that announce ESMTP facilities (for
21647example, PIPELINING) and then fail to implement them properly. When a host
21648matches hosts_avoid_esmtp, Exim sends HELO rather than EHLO at the start of the
21649SMTP session. This means that it cannot use any of the ESMTP facilities such as
21650AUTH, PIPELINING, SIZE, and STARTTLS.
21651
21652+----------------------+---------+----------------+--------------+
21653|hosts_avoid_pipelining|Use: smtp|Type: host list*|Default: unset|
21654+----------------------+---------+----------------+--------------+
21655
21656Exim will not use the SMTP PIPELINING extension when delivering to any host
21657that matches this list, even if the server host advertises PIPELINING support.
21658
21659+---------------+---------+----------------+--------------+
21660|hosts_avoid_tls|Use: smtp|Type: host list*|Default: unset|
21661+---------------+---------+----------------+--------------+
21662
21663Exim will not try to start a TLS session when delivering to any host that
21664matches this list. See chapter 41 for details of TLS.
21665
21666+----------------------+---------+----------------+----------+
21667|hosts_verify_avoid_tls|Use: smtp|Type: host list*|Default: *|
21668+----------------------+---------+----------------+----------+
21669
21670Exim will not try to start a TLS session for a verify callout, or when
21671delivering in cutthrough mode, to any host that matches this list. Note that
21672the default is to not use TLS.
21673
21674+-------------+---------+-------------+----------+
21675|hosts_max_try|Use: smtp|Type: integer|Default: 5|
21676+-------------+---------+-------------+----------+
21677
21678This option limits the number of IP addresses that are tried for any one
21679delivery in cases where there are temporary delivery errors. Section 30.5
21680describes in detail how the value of this option is used.
21681
21682+-----------------------+---------+-------------+-----------+
21683|hosts_max_try_hardlimit|Use: smtp|Type: integer|Default: 50|
21684+-----------------------+---------+-------------+-----------+
21685
21686This is an additional check on the maximum number of IP addresses that Exim
21687tries for any one delivery. Section 30.5 describes its use and why it exists.
21688
21689+----------------+---------+----------------+--------------+
21690|hosts_nopass_tls|Use: smtp|Type: host list*|Default: unset|
21691+----------------+---------+----------------+--------------+
21692
21693For any host that matches this list, a connection on which a TLS session has
21694been started will not be passed to a new delivery process for sending another
21695message on the same connection. See section 41.11 for an explanation of when
21696this might be needed.
21697
21698+--------------+---------+-------------+--------------+
21699|hosts_override|Use: smtp|Type: boolean|Default: false|
21700+--------------+---------+-------------+--------------+
21701
21702If this option is set and the hosts option is also set, any hosts that are
21703attached to the address are ignored, and instead the hosts specified by the
21704hosts option are always used. This option does not apply to fallback_hosts.
21705
21706+---------------+---------+-------------+--------------+
21707|hosts_randomize|Use: smtp|Type: boolean|Default: false|
21708+---------------+---------+-------------+--------------+
21709
21710If this option is set, and either the list of hosts is taken from the hosts or
21711the fallback_hosts option, or the hosts supplied by the router were not
21712obtained from MX records (this includes fallback hosts from the router), and
21713were not randomized by the router, the order of trying the hosts is randomized
21714each time the transport runs. Randomizing the order of a host list can be used
21715to do crude load sharing.
21716
21717When hosts_randomize is true, a host list may be split into groups whose order
21718is separately randomized. This makes it possible to set up MX-like behaviour.
21719The boundaries between groups are indicated by an item that is just "+" in the
21720host list. For example:
21721
21722hosts = host1:host2:host3:+:host4:host5
21723
21724The order of the first three hosts and the order of the last two hosts is
21725randomized for each use, but the first three always end up before the last two.
21726If hosts_randomize is not set, a "+" item in the list is ignored.
21727
21728+------------------+---------+----------------+--------------+
21729|hosts_require_auth|Use: smtp|Type: host list*|Default: unset|
21730+------------------+---------+----------------+--------------+
21731
21732This option provides a list of servers for which authentication must succeed
21733before Exim will try to transfer a message. If authentication fails for servers
21734which are not in this list, Exim tries to send unauthenticated. If
21735authentication fails for one of these servers, delivery is deferred. This
21736temporary error is detectable in the retry rules, so it can be turned into a
21737hard failure if required. See also hosts_try_auth, and chapter 33 for details
21738of authentication.
21739
21740+------------------+---------+----------------+----------+
21741|hosts_request_ocsp|Use: smtp|Type: host list*|Default: *|
21742+------------------+---------+----------------+----------+
21743
21744Exim will request a Certificate Status on a TLS session for any host that
21745matches this list. tls_verify_certificates should also be set for the
21746transport.
21747
21748+------------------+---------+----------------+--------------+
21749|hosts_require_ocsp|Use: smtp|Type: host list*|Default: unset|
21750+------------------+---------+----------------+--------------+
21751
21752Exim will request, and check for a valid Certificate Status being given, on a
21753TLS session for any host that matches this list. tls_verify_certificates should
21754also be set for the transport.
21755
21756+-----------------+---------+----------------+--------------+
21757|hosts_require_tls|Use: smtp|Type: host list*|Default: unset|
21758+-----------------+---------+----------------+--------------+
21759
21760Exim will insist on using a TLS session when delivering to any host that
21761matches this list. See chapter 41 for details of TLS. Note: This option affects
21762outgoing mail only. To insist on TLS for incoming messages, use an appropriate
21763ACL.
21764
21765+--------------+---------+----------------+--------------+
21766|hosts_try_auth|Use: smtp|Type: host list*|Default: unset|
21767+--------------+---------+----------------+--------------+
21768
21769This option provides a list of servers to which, provided they announce
21770authentication support, Exim will attempt to authenticate as a client when it
21771connects. If authentication fails, Exim will try to transfer the message
21772unauthenticated. See also hosts_require_auth, and chapter 33 for details of
21773authentication.
21774
21775+--------------+---------+----------------+--------------+
21776|hosts_try_prdr|Use: smtp|Type: host list*|Default: unset|
21777+--------------+---------+----------------+--------------+
21778
21779This option provides a list of servers to which, provided they announce PRDR
21780support, Exim will attempt to negotiate PRDR for multi-recipient messages.
21781
21782+---------+---------+------------------+--------------+
21783|interface|Use: smtp|Type: string list*|Default: unset|
21784+---------+---------+------------------+--------------+
21785
21786This option specifies which interface to bind to when making an outgoing SMTP
21787call. The value is an IP address, not an interface name such as "eth0". Do not
21788confuse this with the interface address that was used when a message was
21789received, which is in $received_ip_address, formerly known as
21790$interface_address. The name was changed to minimize confusion with the
21791outgoing interface address. There is no variable that contains an outgoing
21792interface address because, unless it is set by this option, its value is
21793unknown.
21794
21795During the expansion of the interface option the variables $host and
21796$host_address refer to the host to which a connection is about to be made
21797during the expansion of the string. Forced expansion failure, or an empty
21798string result causes the option to be ignored. Otherwise, after expansion, the
21799string must be a list of IP addresses, colon-separated by default, but the
21800separator can be changed in the usual way. For example:
21801
21802interface = <; 192.168.123.123 ; 3ffe:ffff:836f::fe86:a061
21803
21804The first interface of the correct type (IPv4 or IPv6) is used for the outgoing
21805connection. If none of them are the correct type, the option is ignored. If
21806interface is not set, or is ignored, the system's IP functions choose which
21807interface to use if the host has more than one.
21808
21809+---------+---------+-------------+-------------+
21810|keepalive|Use: smtp|Type: boolean|Default: true|
21811+---------+---------+-------------+-------------+
21812
21813This option controls the setting of SO_KEEPALIVE on outgoing TCP/IP socket
21814connections. When set, it causes the kernel to probe idle connections
21815periodically, by sending packets with "old" sequence numbers. The other end of
21816the connection should send a acknowledgment if the connection is still okay or
21817a reset if the connection has been aborted. The reason for doing this is that
21818it has the beneficial effect of freeing up certain types of connection that can
21819get stuck when the remote host is disconnected without tidying up the TCP/IP
21820call properly. The keepalive mechanism takes several hours to detect
21821unreachable hosts.
21822
21823+-----------------+---------+-------------+--------------+
21824|lmtp_ignore_quota|Use: smtp|Type: boolean|Default: false|
21825+-----------------+---------+-------------+--------------+
21826
21827If this option is set true when the protocol option is set to "lmtp", the
21828string "IGNOREQUOTA" is added to RCPT commands, provided that the LMTP server
21829has advertised support for IGNOREQUOTA in its response to the LHLO command.
21830
21831+--------+---------+-------------+------------+
21832|max_rcpt|Use: smtp|Type: integer|Default: 100|
21833+--------+---------+-------------+------------+
21834
21835This option limits the number of RCPT commands that are sent in a single SMTP
21836message transaction. Each set of addresses is treated independently, and so can
21837cause parallel connections to the same host if remote_max_parallel permits
21838this.
21839
21840+------------+---------+-------------+-------------+
21841|multi_domain|Use: smtp|Type: boolean|Default: true|
21842+------------+---------+-------------+-------------+
21843
21844When this option is set, the smtp transport can handle a number of addresses
21845containing a mixture of different domains provided they all resolve to the same
21846list of hosts. Turning the option off restricts the transport to handling only
21847one domain at a time. This is useful if you want to use $domain in an expansion
21848for the transport, because it is set only when there is a single domain
21849involved in a remote delivery.
21850
21851+----+---------+-------------+------------------+
21852|port|Use: smtp|Type: string*|Default: see below|
21853+----+---------+-------------+------------------+
21854
21855This option specifies the TCP/IP port on the server to which Exim connects.
21856Note: Do not confuse this with the port that was used when a message was
21857received, which is in $received_port, formerly known as $interface_port. The
21858name was changed to minimize confusion with the outgoing port. There is no
21859variable that contains an outgoing port.
21860
21861If the value of this option begins with a digit it is taken as a port number;
21862otherwise it is looked up using getservbyname(). The default value is normally
21863"smtp", but if protocol is set to "lmtp", the default is "lmtp". If the
21864expansion fails, or if a port number cannot be found, delivery is deferred.
21865
21866+--------+---------+------------+-------------+
21867|protocol|Use: smtp|Type: string|Default: smtp|
21868+--------+---------+------------+-------------+
21869
21870If this option is set to "lmtp" instead of "smtp", the default value for the
21871port option changes to "lmtp", and the transport operates the LMTP protocol
21872(RFC 2033) instead of SMTP. This protocol is sometimes used for local
21873deliveries into closed message stores. Exim also has support for running LMTP
21874over a pipe to a local process - see chapter 28.
21875
21876If this option is set to "smtps", the default vaule for the port option changes
21877to "smtps", and the transport initiates TLS immediately after connecting, as an
21878outbound SSL-on-connect, instead of using STARTTLS to upgrade. The Internet
21879standards bodies strongly discourage use of this mode.
21880
21881+------------------------+---------+-------------+-------------+
21882|retry_include_ip_address|Use: smtp|Type: boolean|Default: true|
21883+------------------------+---------+-------------+-------------+
21884
21885Exim normally includes both the host name and the IP address in the key it
21886constructs for indexing retry data after a temporary delivery failure. This
21887means that when one of several IP addresses for a host is failing, it gets
21888tried periodically (controlled by the retry rules), but use of the other IP
21889addresses is not affected.
21890
21891However, in some dialup environments hosts are assigned a different IP address
21892each time they connect. In this situation the use of the IP address as part of
21893the retry key leads to undesirable behaviour. Setting this option false causes
21894Exim to use only the host name. This should normally be done on a separate
21895instance of the smtp transport, set up specially to handle the dialup hosts.
21896
21897+---------------+---------+----------------+--------------+
21898|serialize_hosts|Use: smtp|Type: host list*|Default: unset|
21899+---------------+---------+----------------+--------------+
21900
21901Because Exim operates in a distributed manner, if several messages for the same
21902host arrive at around the same time, more than one simultaneous connection to
21903the remote host can occur. This is not usually a problem except when there is a
21904slow link between the hosts. In that situation it may be helpful to restrict
21905Exim to one connection at a time. This can be done by setting serialize_hosts
21906to match the relevant hosts.
21907
21908Exim implements serialization by means of a hints database in which a record is
21909written whenever a process connects to one of the restricted hosts. The record
21910is deleted when the connection is completed. Obviously there is scope for
21911records to get left lying around if there is a system or program crash. To
21912guard against this, Exim ignores any records that are more than six hours old.
21913
21914If you set up this kind of serialization, you should also arrange to delete the
21915relevant hints database whenever your system reboots. The names of the files
21916start with misc and they are kept in the spool/db directory. There may be one
21917or two files, depending on the type of DBM in use. The same files are used for
21918ETRN serialization.
21919
21920+-------------+---------+-------------+-------------+
21921|size_addition|Use: smtp|Type: integer|Default: 1024|
21922+-------------+---------+-------------+-------------+
21923
21924If a remote SMTP server indicates that it supports the SIZE option of the MAIL
21925command, Exim uses this to pass over the message size at the start of an SMTP
21926transaction. It adds the value of size_addition to the value it sends, to allow
21927for headers and other text that may be added during delivery by configuration
21928options or in a transport filter. It may be necessary to increase this if a lot
21929of text is added to messages.
21930
21931Alternatively, if the value of size_addition is set negative, it disables the
21932use of the SIZE option altogether.
21933
21934+---------------+---------+-------------+--------------+
21935|tls_certificate|Use: smtp|Type: string*|Default: unset|
21936+---------------+---------+-------------+--------------+
21937
21938The value of this option must be the absolute path to a file which contains the
21939client's certificate, for possible use when sending a message over an encrypted
21940connection. The values of $host and $host_address are set to the name and
21941address of the server during the expansion. See chapter 41 for details of TLS.
21942
21943Note: This option must be set if you want Exim to be able to use a TLS
21944certificate when sending messages as a client. The global option of the same
21945name specifies the certificate for Exim as a server; it is not automatically
21946assumed that the same certificate should be used when Exim is operating as a
21947client.
21948
21949+-------+---------+-------------+--------------+
21950|tls_crl|Use: smtp|Type: string*|Default: unset|
21951+-------+---------+-------------+--------------+
21952
21953This option specifies a certificate revocation list. The expanded value must be
21954the name of a file that contains a CRL in PEM format.
21955
21956+---------------+---------+-------------+-------------+
21957|tls_dh_min_bits|Use: smtp|Type: integer|Default: 1024|
21958+---------------+---------+-------------+-------------+
21959
21960When establishing a TLS session, if a ciphersuite which uses Diffie-Hellman key
21961agreement is negotiated, the server will provide a large prime number for use.
21962This option establishes the minimum acceptable size of that number. If the
21963parameter offered by the server is too small, then the TLS handshake will fail.
21964
21965Only supported when using GnuTLS.
21966
21967+--------------+---------+-------------+--------------+
21968|tls_privatekey|Use: smtp|Type: string*|Default: unset|
21969+--------------+---------+-------------+--------------+
21970
21971The value of this option must be the absolute path to a file which contains the
21972client's private key. This is used when sending a message over an encrypted
21973connection using a client certificate. The values of $host and $host_address
21974are set to the name and address of the server during the expansion. If this
21975option is unset, or the expansion is forced to fail, or the result is an empty
21976string, the private key is assumed to be in the same file as the certificate.
21977See chapter 41 for details of TLS.
21978
21979+-------------------+---------+-------------+--------------+
21980|tls_require_ciphers|Use: smtp|Type: string*|Default: unset|
21981+-------------------+---------+-------------+--------------+
21982
21983The value of this option must be a list of permitted cipher suites, for use
21984when setting up an outgoing encrypted connection. (There is a global option of
21985the same name for controlling incoming connections.) The values of $host and
21986$host_address are set to the name and address of the server during the
21987expansion. See chapter 41 for details of TLS; note that this option is used in
21988different ways by OpenSSL and GnuTLS (see sections 41.4 and 41.5). For GnuTLS,
21989the order of the ciphers is a preference order.
21990
21991+-------+---------+-------------+--------------+
21992|tls_sni|Use: smtp|Type: string*|Default: unset|
21993+-------+---------+-------------+--------------+
21994
21995If this option is set then it sets the $tls_out_sni variable and causes any TLS
21996session to pass this value as the Server Name Indication extension to the
21997remote side, which can be used by the remote side to select an appropriate
21998certificate and private key for the session.
21999
22000See 41.10 for more information.
22001
22002Note that for OpenSSL, this feature requires a build of OpenSSL that supports
22003TLS extensions.
22004
22005+---------------------+---------+-------------+-------------+
22006|tls_tempfail_tryclear|Use: smtp|Type: boolean|Default: true|
22007+---------------------+---------+-------------+-------------+
22008
22009When the server host is not in hosts_require_tls, and there is a problem in
22010setting up a TLS session, this option determines whether or not Exim should try
22011to deliver the message unencrypted. If it is set false, delivery to the current
22012host is deferred; if there are other hosts, they are tried. If this option is
22013set true, Exim attempts to deliver unencrypted after a 4xx response to
22014STARTTLS. Also, if STARTTLS is accepted, but the subsequent TLS negotiation
22015fails, Exim closes the current connection (because it is in an unknown state),
22016opens a new one to the same host, and then tries the delivery in clear.
22017
22018+--------------------+---------+----------------------+--------+
22019|tls_try_verify_hosts|Use: smtp|Type: host list* unset|Default:|
22020+--------------------+---------+----------------------+--------+
22021
22022This option gives a list of hosts for which, on encrypted connections,
22023certificate verification will be tried but need not succeed. The
22024tls_verify_certificates option must also be set. Note that unless the host is
22025in this list TLS connections will be denied to hosts using self-signed
22026certificates when tls_verify_certificates is set. The
22027$tls_out_certificate_verified variable is set when certificate verification
22028succeeds.
22029
22030+-----------------------+---------+-------------+--------------+
22031|tls_verify_certificates|Use: smtp|Type: string*|Default: unset|
22032+-----------------------+---------+-------------+--------------+
22033
22034The value of this option must be the absolute path to a file containing
22035permitted server certificates, for use when setting up an encrypted connection.
22036Alternatively, if you are using OpenSSL, you can set tls_verify_certificates to
22037the name of a directory containing certificate files. This does not work with
22038GnuTLS; the option must be set to the name of a single file if you are using
22039GnuTLS. The values of $host and $host_address are set to the name and address
22040of the server during the expansion of this option. See chapter 41 for details
22041of TLS.
22042
22043For back-compatability, if neither tls_verify_hosts nor tls_try_verify_hosts
22044are set and certificate verification fails the TLS connection is closed.
22045
22046+----------------+---------+----------------------+--------+
22047|tls_verify_hosts|Use: smtp|Type: host list* unset|Default:|
22048+----------------+---------+----------------------+--------+
22049
22050This option gives a list of hosts for which. on encrypted connections,
22051certificate verification must succeed. The tls_verify_certificates option must
22052also be set. If both this option and tls_try_verify_hosts are unset operation
22053is as if this option selected all hosts.
22054
22055
2205630.5 How the limits for the number of hosts to try are used
22057-----------------------------------------------------------
22058
22059There are two options that are concerned with the number of hosts that are
22060tried when an SMTP delivery takes place. They are hosts_max_try and
22061hosts_max_try_hardlimit.
22062
22063The hosts_max_try option limits the number of hosts that are tried for a single
22064delivery. However, despite the term "host" in its name, the option actually
22065applies to each IP address independently. In other words, a multihomed host is
22066treated as several independent hosts, just as it is for retrying.
22067
22068Many of the larger ISPs have multiple MX records which often point to
22069multihomed hosts. As a result, a list of a dozen or more IP addresses may be
22070created as a result of routing one of these domains.
22071
22072Trying every single IP address on such a long list does not seem sensible; if
22073several at the top of the list fail, it is reasonable to assume there is some
22074problem that is likely to affect all of them. Roughly speaking, the value of
22075hosts_max_try is the maximum number that are tried before deferring the
22076delivery. However, the logic cannot be quite that simple.
22077
22078Firstly, IP addresses that are skipped because their retry times have not
22079arrived do not count, and in addition, addresses that are past their retry
22080limits are also not counted, even when they are tried. This means that when
22081some IP addresses are past their retry limits, more than the value of
22082hosts_max_retry may be tried. The reason for this behaviour is to ensure that
22083all IP addresses are considered before timing out an email address (but see
22084below for an exception).
22085
22086Secondly, when the hosts_max_try limit is reached, Exim looks down the host
22087list to see if there is a subsequent host with a different (higher valued) MX.
22088If there is, that host is considered next, and the current IP address is used
22089but not counted. This behaviour helps in the case of a domain with a retry rule
22090that hardly ever delays any hosts, as is now explained:
22091
22092Consider the case of a long list of hosts with one MX value, and a few with a
22093higher MX value. If hosts_max_try is small (the default is 5) only a few hosts
22094at the top of the list are tried at first. With the default retry rule, which
22095specifies increasing retry times, the higher MX hosts are eventually tried when
22096those at the top of the list are skipped because they have not reached their
22097retry times.
22098
22099However, it is common practice to put a fixed short retry time on domains for
22100large ISPs, on the grounds that their servers are rarely down for very long.
22101Unfortunately, these are exactly the domains that tend to resolve to long lists
22102of hosts. The short retry time means that the lowest MX hosts are tried every
22103time. The attempts may be in a different order because of random sorting, but
22104without the special MX check, the higher MX hosts would never be tried until
22105all the lower MX hosts had timed out (which might be several days), because
22106there are always some lower MX hosts that have reached their retry times. With
22107the special check, Exim considers at least one IP address from each MX value at
22108every delivery attempt, even if the hosts_max_try limit has already been
22109reached.
22110
22111The above logic means that hosts_max_try is not a hard limit, and in
22112particular, Exim normally eventually tries all the IP addresses before timing
22113out an email address. When hosts_max_try was implemented, this seemed a
22114reasonable thing to do. Recently, however, some lunatic DNS configurations have
22115been set up with hundreds of IP addresses for some domains. It can take a very
22116long time indeed for an address to time out in these cases.
22117
22118The hosts_max_try_hardlimit option was added to help with this problem. Exim
22119never tries more than this number of IP addresses; if it hits this limit and
22120they are all timed out, the email address is bounced, even though not all
22121possible IP addresses have been tried.
22122
22123
22124
22125===============================================================================
2212631. ADDRESS REWRITING
22127
22128There are some circumstances in which Exim automatically rewrites domains in
22129addresses. The two most common are when an address is given without a domain
22130(referred to as an "unqualified address") or when an address contains an
22131abbreviated domain that is expanded by DNS lookup.
22132
22133Unqualified envelope addresses are accepted only for locally submitted
22134messages, or for messages that are received from hosts matching
22135sender_unqualified_hosts or recipient_unqualified_hosts, as appropriate.
22136Unqualified addresses in header lines are qualified if they are in locally
22137submitted messages, or messages from hosts that are permitted to send
22138unqualified envelope addresses. Otherwise, unqualified addresses in header
22139lines are neither qualified nor rewritten.
22140
22141One situation in which Exim does not automatically rewrite a domain is when it
22142is the name of a CNAME record in the DNS. The older RFCs suggest that such a
22143domain should be rewritten using the "canonical" name, and some MTAs do this.
22144The new RFCs do not contain this suggestion.
22145
22146
2214731.1 Explicitly configured address rewriting
22148--------------------------------------------
22149
22150This chapter describes the rewriting rules that can be used in the main rewrite
22151section of the configuration file, and also in the generic headers_rewrite
22152option that can be set on any transport.
22153
22154Some people believe that configured address rewriting is a Mortal Sin. Others
22155believe that life is not possible without it. Exim provides the facility; you
22156do not have to use it.
22157
22158The main rewriting rules that appear in the "rewrite" section of the
22159configuration file are applied to addresses in incoming messages, both envelope
22160addresses and addresses in header lines. Each rule specifies the types of
22161address to which it applies.
22162
22163Whether or not addresses in header lines are rewritten depends on the origin of
22164the headers and the type of rewriting. Global rewriting, that is, rewriting
22165rules from the rewrite section of the configuration file, is applied only to
22166those headers that were received with the message. Header lines that are added
22167by ACLs or by a system filter or by individual routers or transports (which are
22168specific to individual recipient addresses) are not rewritten by the global
22169rules.
22170
22171Rewriting at transport time, by means of the headers_rewrite option, applies
22172all headers except those added by routers and transports. That is, as well as
22173the headers that were received with the message, it also applies to headers
22174that were added by an ACL or a system filter.
22175
22176In general, rewriting addresses from your own system or domain has some
22177legitimacy. Rewriting other addresses should be done only with great care and
22178in special circumstances. The author of Exim believes that rewriting should be
22179used sparingly, and mainly for "regularizing" addresses in your own domains.
22180Although it can sometimes be used as a routing tool, this is very strongly
22181discouraged.
22182
22183There are two commonly encountered circumstances where rewriting is used, as
22184illustrated by these examples:
22185
22186 * The company whose domain is hitch.fict.example has a number of hosts that
22187 exchange mail with each other behind a firewall, but there is only a single
22188 gateway to the outer world. The gateway rewrites *.hitch.fict.example as
22189 hitch.fict.example when sending mail off-site.
22190
22191 * A host rewrites the local parts of its own users so that, for example,
22192 fp42@hitch.fict.example becomes Ford.Prefect@hitch.fict.example.
22193
22194
2219531.2 When does rewriting happen?
22196--------------------------------
22197
22198Configured address rewriting can take place at several different stages of a
22199message's processing.
22200
22201At the start of an ACL for MAIL, the sender address may have been rewritten by
22202a special SMTP-time rewrite rule (see section 31.9), but no ordinary rewrite
22203rules have yet been applied. If, however, the sender address is verified in the
22204ACL, it is rewritten before verification, and remains rewritten thereafter. The
22205subsequent value of $sender_address is the rewritten address. This also applies
22206if sender verification happens in a RCPT ACL. Otherwise, when the sender
22207address is not verified, it is rewritten as soon as a message's header lines
22208have been received.
22209
22210Similarly, at the start of an ACL for RCPT, the current recipient's address may
22211have been rewritten by a special SMTP-time rewrite rule, but no ordinary
22212rewrite rules have yet been applied to it. However, the behaviour is different
22213from the sender address when a recipient is verified. The address is rewritten
22214for the verification, but the rewriting is not remembered at this stage. The
22215value of $local_part and $domain after verification are always the same as they
22216were before (that is, they contain the unrewritten - except for SMTP-time
22217rewriting - address).
22218
22219As soon as a message's header lines have been received, all the envelope
22220recipient addresses are permanently rewritten, and rewriting is also applied to
22221the addresses in the header lines (if configured). This happens before adding
22222any header lines that were specified in MAIL or RCPT ACLs, and before the DATA
22223ACL and local_scan() functions are run.
22224
22225When an address is being routed, either for delivery or for verification,
22226rewriting is applied immediately to child addresses that are generated by
22227redirection, unless no_rewrite is set on the router.
22228
22229At transport time, additional rewriting of addresses in header lines can be
22230specified by setting the generic headers_rewrite option on a transport. This
22231option contains rules that are identical in form to those in the rewrite
22232section of the configuration file. They are applied to the original message
22233header lines and any that were added by ACLs or a system filter. They are not
22234applied to header lines that are added by routers or the transport.
22235
22236The outgoing envelope sender can be rewritten by means of the return_path
22237transport option. However, it is not possible to rewrite envelope recipients at
22238transport time.
22239
22240
2224131.3 Testing the rewriting rules that apply on input
22242----------------------------------------------------
22243
22244Exim's input rewriting configuration appears in a part of the run time
22245configuration file headed by "begin rewrite". It can be tested by the -brw
22246command line option. This takes an address (which can be a full RFC 2822
22247address) as its argument. The output is a list of how the address would be
22248transformed by the rewriting rules for each of the different places it might
22249appear in an incoming message, that is, for each different header and for the
22250envelope sender and recipient fields. For example,
22251
22252exim -brw ph10@exim.workshop.example
22253
22254might produce the output
22255
22256sender: Philip.Hazel@exim.workshop.example
22257from: Philip.Hazel@exim.workshop.example
22258to: ph10@exim.workshop.example
22259cc: ph10@exim.workshop.example
22260bcc: ph10@exim.workshop.example
22261reply-to: Philip.Hazel@exim.workshop.example
22262env-from: Philip.Hazel@exim.workshop.example
22263env-to: ph10@exim.workshop.example
22264
22265which shows that rewriting has been set up for that address when used in any of
22266the source fields, but not when it appears as a recipient address. At the
22267present time, there is no equivalent way of testing rewriting rules that are
22268set for a particular transport.
22269
22270
2227131.4 Rewriting rules
22272--------------------
22273
22274The rewrite section of the configuration file consists of lines of rewriting
22275rules in the form
22276
22277<source pattern> <replacement> <flags>
22278
22279Rewriting rules that are specified for the headers_rewrite generic transport
22280option are given as a colon-separated list. Each item in the list takes the
22281same form as a line in the main rewriting configuration (except that any colons
22282must be doubled, of course).
22283
22284The formats of source patterns and replacement strings are described below.
22285Each is terminated by white space, unless enclosed in double quotes, in which
22286case normal quoting conventions apply inside the quotes. The flags are single
22287characters which may appear in any order. Spaces and tabs between them are
22288ignored.
22289
22290For each address that could potentially be rewritten, the rules are scanned in
22291order, and replacements for the address from earlier rules can themselves be
22292replaced by later rules (but see the "q" and "R" flags).
22293
22294The order in which addresses are rewritten is undefined, may change between
22295releases, and must not be relied on, with one exception: when a message is
22296received, the envelope sender is always rewritten first, before any header
22297lines are rewritten. For example, the replacement string for a rewrite of an
22298address in To: must not assume that the message's address in From: has (or has
22299not) already been rewritten. However, a rewrite of From: may assume that the
22300envelope sender has already been rewritten.
22301
22302The variables $local_part and $domain can be used in the replacement string to
22303refer to the address that is being rewritten. Note that lookup-driven rewriting
22304can be done by a rule of the form
22305
22306*@* ${lookup ...
22307
22308where the lookup key uses $1 and $2 or $local_part and $domain to refer to the
22309address that is being rewritten.
22310
22311
2231231.5 Rewriting patterns
22313-----------------------
22314
22315The source pattern in a rewriting rule is any item which may appear in an
22316address list (see section 10.19). It is in fact processed as a single-item
22317address list, which means that it is expanded before being tested against the
22318address. As always, if you use a regular expression as a pattern, you must take
22319care to escape dollar and backslash characters, or use the "\N" facility to
22320suppress string expansion within the regular expression.
22321
22322Domains in patterns should be given in lower case. Local parts in patterns are
22323case-sensitive. If you want to do case-insensitive matching of local parts, you
22324can use a regular expression that starts with "^(?i)".
22325
22326After matching, the numerical variables $1, $2, etc. may be set, depending on
22327the type of match which occurred. These can be used in the replacement string
22328to insert portions of the incoming address. $0 always refers to the complete
22329incoming address. When a regular expression is used, the numerical variables
22330are set from its capturing subexpressions. For other types of pattern they are
22331set as follows:
22332
22333 * If a local part or domain starts with an asterisk, the numerical variables
22334 refer to the character strings matched by asterisks, with $1 associated
22335 with the first asterisk, and $2 with the second, if present. For example,
22336 if the pattern
22337
22338 *queen@*.fict.example
22339
22340 is matched against the address hearts-queen@wonderland.fict.example then
22341
22342 $0 = hearts-queen@wonderland.fict.example
22343 $1 = hearts-
22344 $2 = wonderland
22345
22346 Note that if the local part does not start with an asterisk, but the domain
22347 does, it is $1 that contains the wild part of the domain.
22348
22349 * If the domain part of the pattern is a partial lookup, the wild and fixed
22350 parts of the domain are placed in the next available numerical variables.
22351 Suppose, for example, that the address foo@bar.baz.example is processed by
22352 a rewriting rule of the form
22353
22354 *@partial-dbm;/some/dbm/file <replacement string>
22355
22356 and the key in the file that matches the domain is "*.baz.example". Then
22357
22358 $1 = foo
22359 $2 = bar
22360 $3 = baz.example
22361
22362 If the address foo@baz.example is looked up, this matches the same wildcard
22363 file entry, and in this case $2 is set to the empty string, but $3 is still
22364 set to baz.example. If a non-wild key is matched in a partial lookup, $2 is
22365 again set to the empty string and $3 is set to the whole domain. For
22366 non-partial domain lookups, no numerical variables are set.
22367
22368
2236931.6 Rewriting replacements
22370---------------------------
22371
22372If the replacement string for a rule is a single asterisk, addresses that match
22373the pattern and the flags are not rewritten, and no subsequent rewriting rules
22374are scanned. For example,
22375
22376hatta@lookingglass.fict.example * f
22377
22378specifies that hatta@lookingglass.fict.example is never to be rewritten in
22379From: headers.
22380
22381If the replacement string is not a single asterisk, it is expanded, and must
22382yield a fully qualified address. Within the expansion, the variables
22383$local_part and $domain refer to the address that is being rewritten. Any
22384letters they contain retain their original case - they are not lower cased. The
22385numerical variables are set up according to the type of pattern that matched
22386the address, as described above. If the expansion is forced to fail by the
22387presence of "fail" in a conditional or lookup item, rewriting by the current
22388rule is abandoned, but subsequent rules may take effect. Any other expansion
22389failure causes the entire rewriting operation to be abandoned, and an entry
22390written to the panic log.
22391
22392
2239331.7 Rewriting flags
22394--------------------
22395
22396There are three different kinds of flag that may appear on rewriting rules:
22397
22398 * Flags that specify which headers and envelope addresses to rewrite: E, F,
22399 T, b, c, f, h, r, s, t.
22400
22401 * A flag that specifies rewriting at SMTP time: S.
22402
22403 * Flags that control the rewriting process: Q, q, R, w.
22404
22405For rules that are part of the headers_rewrite generic transport option, E, F,
22406T, and S are not permitted.
22407
22408
2240931.8 Flags specifying which headers and envelope addresses to rewrite
22410---------------------------------------------------------------------
22411
22412If none of the following flag letters, nor the "S" flag (see section 31.9) are
22413present, a main rewriting rule applies to all headers and to both the sender
22414and recipient fields of the envelope, whereas a transport-time rewriting rule
22415just applies to all headers. Otherwise, the rewriting rule is skipped unless
22416the relevant addresses are being processed.
22417
22418E rewrite all envelope fields
22419F rewrite the envelope From field
22420T rewrite the envelope To field
22421b rewrite the Bcc: header
22422c rewrite the Cc: header
22423f rewrite the From: header
22424h rewrite all headers
22425r rewrite the Reply-To: header
22426s rewrite the Sender: header
22427t rewrite the To: header
22428
22429"All headers" means all of the headers listed above that can be selected
22430individually, plus their Resent- versions. It does not include other headers
22431such as Subject: etc.
22432
22433You should be particularly careful about rewriting Sender: headers, and
22434restrict this to special known cases in your own domains.
22435
22436
2243731.9 The SMTP-time rewriting flag
22438---------------------------------
22439
22440The rewrite flag "S" specifies a rewrite of incoming envelope addresses at SMTP
22441time, as soon as an address is received in a MAIL or RCPT command, and before
22442any other processing; even before syntax checking. The pattern is required to
22443be a regular expression, and it is matched against the whole of the data for
22444the command, including any surrounding angle brackets.
22445
22446This form of rewrite rule allows for the handling of addresses that are not
22447compliant with RFCs 2821 and 2822 (for example, "bang paths" in batched SMTP
22448input). Because the input is not required to be a syntactically valid address,
22449the variables $local_part and $domain are not available during the expansion of
22450the replacement string. The result of rewriting replaces the original address
22451in the MAIL or RCPT command.
22452
22453
2245431.10 Flags controlling the rewriting process
22455---------------------------------------------
22456
22457There are four flags which control the way the rewriting process works. These
22458take effect only when a rule is invoked, that is, when the address is of the
22459correct type (matches the flags) and matches the pattern:
22460
22461 * If the "Q" flag is set on a rule, the rewritten address is permitted to be
22462 an unqualified local part. It is qualified with qualify_recipient. In the
22463 absence of "Q" the rewritten address must always include a domain.
22464
22465 * If the "q" flag is set on a rule, no further rewriting rules are
22466 considered, even if no rewriting actually takes place because of a "fail"
22467 in the expansion. The "q" flag is not effective if the address is of the
22468 wrong type (does not match the flags) or does not match the pattern.
22469
22470 * The "R" flag causes a successful rewriting rule to be re-applied to the new
22471 address, up to ten times. It can be combined with the "q" flag, to stop
22472 rewriting once it fails to match (after at least one successful rewrite).
22473
22474 * When an address in a header is rewritten, the rewriting normally applies
22475 only to the working part of the address, with any comments and RFC 2822
22476 "phrase" left unchanged. For example, rewriting might change
22477
22478 From: Ford Prefect <fp42@restaurant.hitch.fict.example>
22479
22480 into
22481
22482 From: Ford Prefect <prefectf@hitch.fict.example>
22483
22484 Sometimes there is a need to replace the whole address item, and this can
22485 be done by adding the flag letter "w" to a rule. If this is set on a rule
22486 that causes an address in a header line to be rewritten, the entire address
22487 is replaced, not just the working part. The replacement must be a complete
22488 RFC 2822 address, including the angle brackets if necessary. If text
22489 outside angle brackets contains a character whose value is greater than 126
22490 or less than 32 (except for tab), the text is encoded according to RFC
22491 2047. The character set is taken from headers_charset, which defaults to
22492 ISO-8859-1.
22493
22494 When the "w" flag is set on a rule that causes an envelope address to be
22495 rewritten, all but the working part of the replacement address is
22496 discarded.
22497
22498
2249931.11 Rewriting examples
22500------------------------
22501
22502Here is an example of the two common rewriting paradigms:
22503
22504*@*.hitch.fict.example $1@hitch.fict.example
22505*@hitch.fict.example ${lookup{$1}dbm{/etc/realnames}\
22506 {$value}fail}@hitch.fict.example bctfrF
22507
22508Note the use of "fail" in the lookup expansion in the second rule, forcing the
22509string expansion to fail if the lookup does not succeed. In this context it has
22510the effect of leaving the original address unchanged, but Exim goes on to
22511consider subsequent rewriting rules, if any, because the "q" flag is not
22512present in that rule. An alternative to "fail" would be to supply $1
22513explicitly, which would cause the rewritten address to be the same as before,
22514at the cost of a small bit of processing. Not supplying either of these is an
22515error, since the rewritten address would then contain no local part.
22516
22517The first example above replaces the domain with a superior, more general
22518domain. This may not be desirable for certain local parts. If the rule
22519
22520root@*.hitch.fict.example *
22521
22522were inserted before the first rule, rewriting would be suppressed for the
22523local part root at any domain ending in hitch.fict.example.
22524
22525Rewriting can be made conditional on a number of tests, by making use of ${if
22526in the expansion item. For example, to apply a rewriting rule only to messages
22527that originate outside the local host:
22528
22529*@*.hitch.fict.example "${if !eq {$sender_host_address}{}\
22530 {$1@hitch.fict.example}fail}"
22531
22532The replacement string is quoted in this example because it contains white
22533space.
22534
22535Exim does not handle addresses in the form of "bang paths". If it sees such an
22536address it treats it as an unqualified local part which it qualifies with the
22537local qualification domain (if the source of the message is local or if the
22538remote host is permitted to send unqualified addresses). Rewriting can
22539sometimes be used to handle simple bang paths with a fixed number of
22540components. For example, the rule
22541
22542\N^([^!]+)!(.*)@your.domain.example$\N $2@$1
22543
22544rewrites a two-component bang path host.name!user as the domain address
22545user@host.name. However, there is a security implication in using this as a
22546global rewriting rule for envelope addresses. It can provide a backdoor method
22547for using your system as a relay, because the incoming addresses appear to be
22548local. If the bang path addresses are received via SMTP, it is safer to use the
22549"S" flag to rewrite them as they are received, so that relay checking can be
22550done on the rewritten addresses.
22551
22552
22553
22554===============================================================================
2255532. RETRY CONFIGURATION
22556
22557The "retry" section of the runtime configuration file contains a list of retry
22558rules that control how often Exim tries to deliver messages that cannot be
22559delivered at the first attempt. If there are no retry rules (the section is
22560empty or not present), there are no retries. In this situation, temporary
22561errors are treated as permanent. The default configuration contains a single,
22562general-purpose retry rule (see section 7.5). The -brt command line option can
22563be used to test which retry rule will be used for a given address, domain and
22564error.
22565
22566The most common cause of retries is temporary failure to deliver to a remote
22567host because the host is down, or inaccessible because of a network problem.
22568Exim's retry processing in this case is applied on a per-host (strictly, per IP
22569address) basis, not on a per-message basis. Thus, if one message has recently
22570been delayed, delivery of a new message to the same host is not immediately
22571tried, but waits for the host's retry time to arrive. If the retry_defer log
22572selector is set, the message "retry time not reached" is written to the main
22573log whenever a delivery is skipped for this reason. Section 47.2 contains more
22574details of the handling of errors during remote deliveries.
22575
22576Retry processing applies to routing as well as to delivering, except as covered
22577in the next paragraph. The retry rules do not distinguish between these
22578actions. It is not possible, for example, to specify different behaviour for
22579failures to route the domain snark.fict.example and failures to deliver to the
22580host snark.fict.example. I didn't think anyone would ever need this added
22581complication, so did not implement it. However, although they share the same
22582retry rule, the actual retry times for routing and transporting a given domain
22583are maintained independently.
22584
22585When a delivery is not part of a queue run (typically an immediate delivery on
22586receipt of a message), the routers are always run, and local deliveries are
22587always attempted, even if retry times are set for them. This makes for better
22588behaviour if one particular message is causing problems (for example, causing
22589quota overflow, or provoking an error in a filter file). If such a delivery
22590suffers a temporary failure, the retry data is updated as normal, and
22591subsequent delivery attempts from queue runs occur only when the retry time for
22592the local address is reached.
22593
22594
2259532.1 Changing retry rules
22596-------------------------
22597
22598If you change the retry rules in your configuration, you should consider
22599whether or not to delete the retry data that is stored in Exim's spool area in
22600files with names like db/retry. Deleting any of Exim's hints files is always
22601safe; that is why they are called "hints".
22602
22603The hints retry data contains suggested retry times based on the previous
22604rules. In the case of a long-running problem with a remote host, it might
22605record the fact that the host has timed out. If your new rules increase the
22606timeout time for such a host, you should definitely remove the old retry data
22607and let Exim recreate it, based on the new rules. Otherwise Exim might bounce
22608messages that it should now be retaining.
22609
22610
2261132.2 Format of retry rules
22612--------------------------
22613
22614Each retry rule occupies one line and consists of three or four parts,
22615separated by white space: a pattern, an error name, an optional list of sender
22616addresses, and a list of retry parameters. The pattern and sender lists must be
22617enclosed in double quotes if they contain white space. The rules are searched
22618in order until one is found where the pattern, error name, and sender list (if
22619present) match the failing host or address, the error that occurred, and the
22620message's sender, respectively.
22621
22622The pattern is any single item that may appear in an address list (see section
2262310.19). It is in fact processed as a one-item address list, which means that it
22624is expanded before being tested against the address that has been delayed. A
22625negated address list item is permitted. Address list processing treats a plain
22626domain name as if it were preceded by "*@", which makes it possible for many
22627retry rules to start with just a domain. For example,
22628
22629lookingglass.fict.example * F,24h,30m;
22630
22631provides a rule for any address in the lookingglass.fict.example domain,
22632whereas
22633
22634alice@lookingglass.fict.example * F,24h,30m;
22635
22636applies only to temporary failures involving the local part alice. In practice,
22637almost all rules start with a domain name pattern without a local part.
22638
22639Warning: If you use a regular expression in a retry rule pattern, it must match
22640a complete address, not just a domain, because that is how regular expressions
22641work in address lists.
22642
22643^\Nxyz\d+\.abc\.example$\N * G,1h,10m,2 Wrong
22644^\N[^@]+@xyz\d+\.abc\.example$\N * G,1h,10m,2 Right
22645
22646
2264732.3 Choosing which retry rule to use for address errors
22648--------------------------------------------------------
22649
22650When Exim is looking for a retry rule after a routing attempt has failed (for
22651example, after a DNS timeout), each line in the retry configuration is tested
22652against the complete address only if retry_use_local_part is set for the
22653router. Otherwise, only the domain is used, except when matching against a
22654regular expression, when the local part of the address is replaced with "*". A
22655domain on its own can match a domain pattern, or a pattern that starts with
22656"*@". By default, retry_use_local_part is true for routers where
22657check_local_user is true, and false for other routers.
22658
22659Similarly, when Exim is looking for a retry rule after a local delivery has
22660failed (for example, after a mailbox full error), each line in the retry
22661configuration is tested against the complete address only if
22662retry_use_local_part is set for the transport (it defaults true for all local
22663transports).
22664
22665However, when Exim is looking for a retry rule after a remote delivery attempt
22666suffers an address error (a 4xx SMTP response for a recipient address), the
22667whole address is always used as the key when searching the retry rules. The
22668rule that is found is used to create a retry time for the combination of the
22669failing address and the message's sender. It is the combination of sender and
22670recipient that is delayed in subsequent queue runs until its retry time is
22671reached. You can delay the recipient without regard to the sender by setting
22672address_retry_include_sender false in the smtp transport but this can lead to
22673problems with servers that regularly issue 4xx responses to RCPT commands.
22674
22675
2267632.4 Choosing which retry rule to use for host and message errors
22677-----------------------------------------------------------------
22678
22679For a temporary error that is not related to an individual address (for
22680example, a connection timeout), each line in the retry configuration is checked
22681twice. First, the name of the remote host is used as a domain name (preceded by
22682"*@" when matching a regular expression). If this does not match the line, the
22683domain from the email address is tried in a similar fashion. For example,
22684suppose the MX records for a.b.c.example are
22685
22686a.b.c.example MX 5 x.y.z.example
22687 MX 6 p.q.r.example
22688 MX 7 m.n.o.example
22689
22690and the retry rules are
22691
22692p.q.r.example * F,24h,30m;
22693a.b.c.example * F,4d,45m;
22694
22695and a delivery to the host x.y.z.example suffers a connection failure. The
22696first rule matches neither the host nor the domain, so Exim looks at the second
22697rule. This does not match the host, but it does match the domain, so it is used
22698to calculate the retry time for the host x.y.z.example. Meanwhile, Exim tries
22699to deliver to p.q.r.example. If this also suffers a host error, the first retry
22700rule is used, because it matches the host.
22701
22702In other words, temporary failures to deliver to host p.q.r.example use the
22703first rule to determine retry times, but for all the other hosts for the domain
22704a.b.c.example, the second rule is used. The second rule is also used if routing
22705to a.b.c.example suffers a temporary failure.
22706
22707Note: The host name is used when matching the patterns, not its IP address.
22708However, if a message is routed directly to an IP address without the use of a
22709host name, for example, if a manualroute router contains a setting such as:
22710
22711route_list = *.a.example 192.168.34.23
22712
22713then the "host name" that is used when searching for a retry rule is the
22714textual form of the IP address.
22715
22716
2271732.5 Retry rules for specific errors
22718------------------------------------
22719
22720The second field in a retry rule is the name of a particular error, or an
22721asterisk, which matches any error. The errors that can be tested for are:
22722
22723auth_failed
22724
22725 Authentication failed when trying to send to a host in the
22726 hosts_require_auth list in an smtp transport.
22727
22728data_4xx
22729
22730 A 4xx error was received for an outgoing DATA command, either immediately
22731 after the command, or after sending the message's data.
22732
22733mail_4xx
22734
22735 A 4xx error was received for an outgoing MAIL command.
22736
22737rcpt_4xx
22738
22739 A 4xx error was received for an outgoing RCPT command.
22740
22741For the three 4xx errors, either the first or both of the x's can be given as
22742specific digits, for example: "mail_45x" or "rcpt_436". For example, to
22743recognize 452 errors given to RCPT commands for addresses in a certain domain,
22744and have retries every ten minutes with a one-hour timeout, you could set up a
22745retry rule of this form:
22746
22747the.domain.name rcpt_452 F,1h,10m
22748
22749These errors apply to both outgoing SMTP (the smtp transport) and outgoing LMTP
22750(either the lmtp transport, or the smtp transport in LMTP mode).
22751
22752lost_connection
22753
22754 A server unexpectedly closed the SMTP connection. There may, of course,
22755 legitimate reasons for this (host died, network died), but if it repeats a
22756 lot for the same host, it indicates something odd.
22757
22758refused_MX
22759
22760 A connection to a host obtained from an MX record was refused.
22761
22762refused_A
22763
22764 A connection to a host not obtained from an MX record was refused.
22765
22766refused
22767
22768 A connection was refused.
22769
22770timeout_connect_MX
22771
22772 A connection attempt to a host obtained from an MX record timed out.
22773
22774timeout_connect_A
22775
22776 A connection attempt to a host not obtained from an MX record timed out.
22777
22778timeout_connect
22779
22780 A connection attempt timed out.
22781
22782timeout_MX
22783
22784 There was a timeout while connecting or during an SMTP session with a host
22785 obtained from an MX record.
22786
22787timeout_A
22788
22789 There was a timeout while connecting or during an SMTP session with a host
22790 not obtained from an MX record.
22791
22792timeout
22793
22794 There was a timeout while connecting or during an SMTP session.
22795
22796tls_required
22797
22798 The server was required to use TLS (it matched hosts_require_tls in the
22799 smtp transport), but either did not offer TLS, or it responded with 4xx to
22800 STARTTLS, or there was a problem setting up the TLS connection.
22801
22802quota
22803
22804 A mailbox quota was exceeded in a local delivery by the appendfile
22805 transport.
22806
22807quota_<time>
22808
22809 A mailbox quota was exceeded in a local delivery by the appendfile
22810 transport, and the mailbox has not been accessed for <time>. For example,
22811 quota_4d applies to a quota error when the mailbox has not been accessed
22812 for four days.
22813
22814The idea of quota_<time> is to make it possible to have shorter timeouts when
22815the mailbox is full and is not being read by its owner. Ideally, it should be
22816based on the last time that the user accessed the mailbox. However, it is not
22817always possible to determine this. Exim uses the following heuristic rules:
22818
22819 * If the mailbox is a single file, the time of last access (the "atime") is
22820 used. As no new messages are being delivered (because the mailbox is over
22821 quota), Exim does not access the file, so this is the time of last user
22822 access.
22823
22824 * For a maildir delivery, the time of last modification of the new
22825 subdirectory is used. As the mailbox is over quota, no new files are
22826 created in the new subdirectory, because no new messages are being
22827 delivered. Any change to the new subdirectory is therefore assumed to be
22828 the result of an MUA moving a new message to the cur directory when it is
22829 first read. The time that is used is therefore the last time that the user
22830 read a new message.
22831
22832 * For other kinds of multi-file mailbox, the time of last access cannot be
22833 obtained, so a retry rule that uses this type of error field is never
22834 matched.
22835
22836The quota errors apply both to system-enforced quotas and to Exim's own quota
22837mechanism in the appendfile transport. The quota error also applies when a
22838local delivery is deferred because a partition is full (the ENOSPC error).
22839
22840
2284132.6 Retry rules for specified senders
22842--------------------------------------
22843
22844You can specify retry rules that apply only when the failing message has a
22845specific sender. In particular, this can be used to define retry rules that
22846apply only to bounce messages. The third item in a retry rule can be of this
22847form:
22848
22849senders=<address list>
22850
22851The retry timings themselves are then the fourth item. For example:
22852
22853* rcpt_4xx senders=: F,1h,30m
22854
22855matches recipient 4xx errors for bounce messages sent to any address at any
22856host. If the address list contains white space, it must be enclosed in quotes.
22857For example:
22858
22859a.domain rcpt_452 senders="xb.dom : yc.dom" G,8h,10m,1.5
22860
22861Warning: This facility can be unhelpful if it is used for host errors (which do
22862not depend on the recipient). The reason is that the sender is used only to
22863match the retry rule. Once the rule has been found for a host error, its
22864contents are used to set a retry time for the host, and this will apply to all
22865messages, not just those with specific senders.
22866
22867When testing retry rules using -brt, you can supply a sender using the -f
22868command line option, like this:
22869
22870exim -f "" -brt user@dom.ain
22871
22872If you do not set -f with -brt, a retry rule that contains a senders list is
22873never matched.
22874
22875
2287632.7 Retry parameters
22877---------------------
22878
22879The third (or fourth, if a senders list is present) field in a retry rule is a
22880sequence of retry parameter sets, separated by semicolons. Each set consists of
22881
22882<letter>,<cutoff time>,<arguments>
22883
22884The letter identifies the algorithm for computing a new retry time; the cutoff
22885time is the time beyond which this algorithm no longer applies, and the
22886arguments vary the algorithm's action. The cutoff time is measured from the
22887time that the first failure for the domain (combined with the local part if
22888relevant) was detected, not from the time the message was received.
22889
22890The available algorithms are:
22891
22892 * F: retry at fixed intervals. There is a single time parameter specifying
22893 the interval.
22894
22895 * G: retry at geometrically increasing intervals. The first argument
22896 specifies a starting value for the interval, and the second a multiplier,
22897 which is used to increase the size of the interval at each retry.
22898
22899 * H: retry at randomized intervals. The arguments are as for G. For each
22900 retry, the previous interval is multiplied by the factor in order to get a
22901 maximum for the next interval. The minimum interval is the first argument
22902 of the parameter, and an actual interval is chosen randomly between them.
22903 Such a rule has been found to be helpful in cluster configurations when all
22904 the members of the cluster restart at once, and may therefore synchronize
22905 their queue processing times.
22906
22907When computing the next retry time, the algorithm definitions are scanned in
22908order until one whose cutoff time has not yet passed is reached. This is then
22909used to compute a new retry time that is later than the current time. In the
22910case of fixed interval retries, this simply means adding the interval to the
22911current time. For geometrically increasing intervals, retry intervals are
22912computed from the rule's parameters until one that is greater than the previous
22913interval is found. The main configuration variable retry_interval_max limits
22914the maximum interval between retries. It cannot be set greater than "24h",
22915which is its default value.
22916
22917A single remote domain may have a number of hosts associated with it, and each
22918host may have more than one IP address. Retry algorithms are selected on the
22919basis of the domain name, but are applied to each IP address independently. If,
22920for example, a host has two IP addresses and one is unusable, Exim will
22921generate retry times for it and will not try to use it until its next retry
22922time comes. Thus the good IP address is likely to be tried first most of the
22923time.
22924
22925Retry times are hints rather than promises. Exim does not make any attempt to
22926run deliveries exactly at the computed times. Instead, a queue runner process
22927starts delivery processes for delayed messages periodically, and these attempt
22928new deliveries only for those addresses that have passed their next retry time.
22929If a new message arrives for a deferred address, an immediate delivery attempt
22930occurs only if the address has passed its retry time. In the absence of new
22931messages, the minimum time between retries is the interval between queue runner
22932processes. There is not much point in setting retry times of five minutes if
22933your queue runners happen only once an hour, unless there are a significant
22934number of incoming messages (which might be the case on a system that is
22935sending everything to a smart host, for example).
22936
22937The data in the retry hints database can be inspected by using the exim_dumpdb
22938or exim_fixdb utility programs (see chapter 52). The latter utility can also be
22939used to change the data. The exinext utility script can be used to find out
22940what the next retry times are for the hosts associated with a particular mail
22941domain, and also for local deliveries that have been deferred.
22942
22943
2294432.8 Retry rule examples
22945------------------------
22946
22947Here are some example retry rules:
22948
22949alice@wonderland.fict.example quota_5d F,7d,3h
22950wonderland.fict.example quota_5d
22951wonderland.fict.example * F,1h,15m; G,2d,1h,2;
22952lookingglass.fict.example * F,24h,30m;
22953* refused_A F,2h,20m;
22954* * F,2h,15m; G,16h,1h,1.5; F,5d,8h
22955
22956The first rule sets up special handling for mail to
22957alice@wonderland.fict.example when there is an over-quota error and the mailbox
22958has not been read for at least 5 days. Retries continue every three hours for 7
22959days. The second rule handles over-quota errors for all other local parts at
22960wonderland.fict.example; the absence of a local part has the same effect as
22961supplying "*@". As no retry algorithms are supplied, messages that fail are
22962bounced immediately if the mailbox has not been read for at least 5 days.
22963
22964The third rule handles all other errors at wonderland.fict.example; retries
22965happen every 15 minutes for an hour, then with geometrically increasing
22966intervals until two days have passed since a delivery first failed. After the
22967first hour there is a delay of one hour, then two hours, then four hours, and
22968so on (this is a rather extreme example).
22969
22970The fourth rule controls retries for the domain lookingglass.fict.example. They
22971happen every 30 minutes for 24 hours only. The remaining two rules handle all
22972other domains, with special action for connection refusal from hosts that were
22973not obtained from an MX record.
22974
22975The final rule in a retry configuration should always have asterisks in the
22976first two fields so as to provide a general catch-all for any addresses that do
22977not have their own special handling. This example tries every 15 minutes for 2
22978hours, then with intervals starting at one hour and increasing by a factor of
229791.5 up to 16 hours, then every 8 hours up to 5 days.
22980
22981
2298232.9 Timeout of retry data
22983--------------------------
22984
22985Exim timestamps the data that it writes to its retry hints database. When it
22986consults the data during a delivery it ignores any that is older than the value
22987set in retry_data_expire (default 7 days). If, for example, a host hasn't been
22988tried for 7 days, Exim will try to deliver to it immediately a message arrives,
22989and if that fails, it will calculate a retry time as if it were failing for the
22990first time.
22991
22992This improves the behaviour for messages routed to rarely-used hosts such as MX
22993backups. If such a host was down at one time, and happens to be down again when
22994Exim tries a month later, using the old retry data would imply that it had been
22995down all the time, which is not a justified assumption.
22996
22997If a host really is permanently dead, this behaviour causes a burst of retries
22998every now and again, but only if messages routed to it are rare. If there is a
22999message at least once every 7 days the retry data never expires.
23000
23001
2300232.10 Long-term failures
23003------------------------
23004
23005Special processing happens when an email address has been failing for so long
23006that the cutoff time for the last algorithm is reached. For example, using the
23007default retry rule:
23008
23009* * F,2h,15m; G,16h,1h,1.5; F,4d,6h
23010
23011the cutoff time is four days. Reaching the retry cutoff is independent of how
23012long any specific message has been failing; it is the length of continuous
23013failure for the recipient address that counts.
23014
23015When the cutoff time is reached for a local delivery, or for all the IP
23016addresses associated with a remote delivery, a subsequent delivery failure
23017causes Exim to give up on the address, and a bounce message is generated. In
23018order to cater for new messages that use the failing address, a next retry time
23019is still computed from the final algorithm, and is used as follows:
23020
23021For local deliveries, one delivery attempt is always made for any subsequent
23022messages. If this delivery fails, the address fails immediately. The
23023post-cutoff retry time is not used.
23024
23025If the delivery is remote, there are two possibilities, controlled by the
23026delay_after_cutoff option of the smtp transport. The option is true by default.
23027Until the post-cutoff retry time for one of the IP addresses is reached, the
23028failing email address is bounced immediately, without a delivery attempt taking
23029place. After that time, one new delivery attempt is made to those IP addresses
23030that are past their retry times, and if that still fails, the address is
23031bounced and new retry times are computed.
23032
23033In other words, when all the hosts for a given email address have been failing
23034for a long time, Exim bounces rather then defers until one of the hosts' retry
23035times is reached. Then it tries once, and bounces if that attempt fails. This
23036behaviour ensures that few resources are wasted in repeatedly trying to deliver
23037to a broken destination, but if the host does recover, Exim will eventually
23038notice.
23039
23040If delay_after_cutoff is set false, Exim behaves differently. If all IP
23041addresses are past their final cutoff time, Exim tries to deliver to those IP
23042addresses that have not been tried since the message arrived. If there are no
23043suitable IP addresses, or if they all fail, the address is bounced. In other
23044words, it does not delay when a new message arrives, but tries the expired
23045addresses immediately, unless they have been tried since the message arrived.
23046If there is a continuous stream of messages for the failing domains, setting
23047delay_after_cutoff false means that there will be many more attempts to deliver
23048to permanently failing IP addresses than when delay_after_cutoff is true.
23049
23050
2305132.11 Deliveries that work intermittently
23052-----------------------------------------
23053
23054Some additional logic is needed to cope with cases where a host is
23055intermittently available, or when a message has some attribute that prevents
23056its delivery when others to the same address get through. In this situation,
23057because some messages are successfully delivered, the "retry clock" for the
23058host or address keeps getting reset by the successful deliveries, and so
23059failing messages remain on the queue for ever because the cutoff time is never
23060reached.
23061
23062Two exceptional actions are applied to prevent this happening. The first
23063applies to errors that are related to a message rather than a remote host.
23064Section 47.2 has a discussion of the different kinds of error; examples of
23065message-related errors are 4xx responses to MAIL or DATA commands, and quota
23066failures. For this type of error, if a message's arrival time is earlier than
23067the "first failed" time for the error, the earlier time is used when scanning
23068the retry rules to decide when to try next and when to time out the address.
23069
23070The exceptional second action applies in all cases. If a message has been on
23071the queue for longer than the cutoff time of any applicable retry rule for a
23072given address, a delivery is attempted for that address, even if it is not yet
23073time, and if this delivery fails, the address is timed out. A new retry time is
23074not computed in this case, so that other messages for the same address are
23075considered immediately.
23076
23077
23078
23079===============================================================================
2308033. SMTP AUTHENTICATION
23081
23082The "authenticators" section of Exim's run time configuration is concerned with
23083SMTP authentication. This facility is an extension to the SMTP protocol,
23084described in RFC 2554, which allows a client SMTP host to authenticate itself
23085to a server. This is a common way for a server to recognize clients that are
23086permitted to use it as a relay. SMTP authentication is not of relevance to the
23087transfer of mail between servers that have no managerial connection with each
23088other.
23089
23090Very briefly, the way SMTP authentication works is as follows:
23091
23092 * The server advertises a number of authentication mechanisms in response to
23093 the client's EHLO command.
23094
23095 * The client issues an AUTH command, naming a specific mechanism. The command
23096 may, optionally, contain some authentication data.
23097
23098 * The server may issue one or more challenges, to which the client must send
23099 appropriate responses. In simple authentication mechanisms, the challenges
23100 are just prompts for user names and passwords. The server does not have to
23101 issue any challenges - in some mechanisms the relevant data may all be
23102 transmitted with the AUTH command.
23103
23104 * The server either accepts or denies authentication.
23105
23106 * If authentication succeeds, the client may optionally make use of the AUTH
23107 option on the MAIL command to pass an authenticated sender in subsequent
23108 mail transactions. Authentication lasts for the remainder of the SMTP
23109 connection.
23110
23111 * If authentication fails, the client may give up, or it may try a different
23112 authentication mechanism, or it may try transferring mail over the
23113 unauthenticated connection.
23114
23115If you are setting up a client, and want to know which authentication
23116mechanisms the server supports, you can use Telnet to connect to port 25 (the
23117SMTP port) on the server, and issue an EHLO command. The response to this
23118includes the list of supported mechanisms. For example:
23119
23120$ telnet server.example 25
23121Trying 192.168.34.25...
23122Connected to server.example.
23123Escape character is '^]'.
23124220 server.example ESMTP Exim 4.20 ...
23125ehlo client.example
23126250-server.example Hello client.example [10.8.4.5]
23127250-SIZE 52428800
23128250-PIPELINING
23129250-AUTH PLAIN
23130250 HELP
23131
23132The second-last line of this example output shows that the server supports
23133authentication using the PLAIN mechanism. In Exim, the different authentication
23134mechanisms are configured by specifying authenticator drivers. Like the routers
23135and transports, which authenticators are included in the binary is controlled
23136by build-time definitions. The following are currently available, included by
23137setting
23138
23139AUTH_CRAM_MD5=yes
23140AUTH_CYRUS_SASL=yes
23141AUTH_DOVECOT=yes
23142AUTH_GSASL=yes
23143AUTH_HEIMDAL_GSSAPI=yes
23144AUTH_PLAINTEXT=yes
23145AUTH_SPA=yes
23146
23147in Local/Makefile, respectively. The first of these supports the CRAM-MD5
23148authentication mechanism (RFC 2195), and the second provides an interface to
23149the Cyrus SASL authentication library. The third is an interface to Dovecot's
23150authentication system, delegating the work via a socket interface. The fourth
23151provides an interface to the GNU SASL authentication library, which provides
23152mechanisms but typically not data sources. The fifth provides direct access to
23153Heimdal GSSAPI, geared for Kerberos, but supporting setting a server keytab.
23154The sixth can be configured to support the PLAIN authentication mechanism (RFC
231552595) or the LOGIN mechanism, which is not formally documented, but used by
23156several MUAs. The seventh authenticator supports Microsoft's Secure Password
23157Authentication mechanism.
23158
23159The authenticators are configured using the same syntax as other drivers (see
23160section 6.22). If no authenticators are required, no authentication section
23161need be present in the configuration file. Each authenticator can in principle
23162have both server and client functions. When Exim is receiving SMTP mail, it is
23163acting as a server; when it is sending out messages over SMTP, it is acting as
23164a client. Authenticator configuration options are provided for use in both
23165these circumstances.
23166
23167To make it clear which options apply to which situation, the prefixes server_
23168and client_ are used on option names that are specific to either the server or
23169the client function, respectively. Server and client functions are disabled if
23170none of their options are set. If an authenticator is to be used for both
23171server and client functions, a single definition, using both sets of options,
23172is required. For example:
23173
23174cram:
23175 driver = cram_md5
23176 public_name = CRAM-MD5
23177 server_secret = ${if eq{$auth1}{ph10}{secret1}fail}
23178 client_name = ph10
23179 client_secret = secret2
23180
23181The server_ option is used when Exim is acting as a server, and the client_
23182options when it is acting as a client.
23183
23184Descriptions of the individual authenticators are given in subsequent chapters.
23185The remainder of this chapter covers the generic options for the
23186authenticators, followed by general discussion of the way authentication works
23187in Exim.
23188
23189Beware: the meaning of $auth1, $auth2, ... varies on a per-driver and
23190per-mechanism basis. Please read carefully to determine which variables hold
23191account labels such as usercodes and which hold passwords or other
23192authenticating data.
23193
23194Note that some mechanisms support two different identifiers for accounts: the
23195authentication id and the authorization id. The contractions authn and authz
23196are commonly encountered. The American spelling is standard here. Conceptually,
23197authentication data such as passwords are tied to the identifier used to
23198authenticate; servers may have rules to permit one user to act as a second
23199user, so that after login the session is treated as though that second user had
23200logged in. That second user is the authorization id. A robust configuration
23201might confirm that the authz field is empty or matches the authn field. Often
23202this is just ignored. The authn can be considered as verified data, the authz
23203as an unverified request which the server might choose to honour.
23204
23205A realm is a text string, typically a domain name, presented by a server to a
23206client to help it select an account and credentials to use. In some mechanisms,
23207the client and server provably agree on the realm, but clients typically can
23208not treat the realm as secure data to be blindly trusted.
23209
23210
2321133.1 Generic options for authenticators
23212---------------------------------------
23213
23214+----------------+-------------------+-------------+--------------+
23215|client_condition|Use: authenticators|Type: string*|Default: unset|
23216+----------------+-------------------+-------------+--------------+
23217
23218When Exim is authenticating as a client, it skips any authenticator whose
23219client_condition expansion yields "0", "no", or "false". This can be used, for
23220example, to skip plain text authenticators when the connection is not encrypted
23221by a setting such as:
23222
23223client_condition = ${if !eq{$tls_out_cipher}{}}
23224
23225+-------------+-------------------+-------------+--------------+
23226|client_set_id|Use: authenticators|Type: string*|Default: unset|
23227+-------------+-------------------+-------------+--------------+
23228
23229When client authentication succeeds, this condition is expanded; the result is
23230used in the log lines for outbound messasges. Typically it will be the user
23231name used for authentication.
23232
23233+------+-------------------+------------+--------------+
23234|driver|Use: authenticators|Type: string|Default: unset|
23235+------+-------------------+------------+--------------+
23236
23237This option must always be set. It specifies which of the available
23238authenticators is to be used.
23239
23240+-----------+-------------------+------------+--------------+
23241|public_name|Use: authenticators|Type: string|Default: unset|
23242+-----------+-------------------+------------+--------------+
23243
23244This option specifies the name of the authentication mechanism that the driver
23245implements, and by which it is known to the outside world. These names should
23246contain only upper case letters, digits, underscores, and hyphens (RFC 2222),
23247but Exim in fact matches them caselessly. If public_name is not set, it
23248defaults to the driver's instance name.
23249
23250+--------------------------+-------------------+-------------+--------------+
23251|server_advertise_condition|Use: authenticators|Type: string*|Default: unset|
23252+--------------------------+-------------------+-------------+--------------+
23253
23254When a server is about to advertise an authentication mechanism, the condition
23255is expanded. If it yields the empty string, "0", "no", or "false", the
23256mechanism is not advertised. If the expansion fails, the mechanism is not
23257advertised. If the failure was not forced, and was not caused by a lookup
23258defer, the incident is logged. See section 33.3 below for further discussion.
23259
23260+----------------+-------------------+-------------+--------------+
23261|server_condition|Use: authenticators|Type: string*|Default: unset|
23262+----------------+-------------------+-------------+--------------+
23263
23264This option must be set for a plaintext server authenticator, where it is used
23265directly to control authentication. See section 34.2 for details.
23266
23267For the gsasl authenticator, this option is required for various mechanisms;
23268see chapter 38 for details.
23269
23270For the other authenticators, server_condition can be used as an additional
23271authentication or authorization mechanism that is applied after the other
23272authenticator conditions succeed. If it is set, it is expanded when the
23273authenticator would otherwise return a success code. If the expansion is forced
23274to fail, authentication fails. Any other expansion failure causes a temporary
23275error code to be returned. If the result of a successful expansion is an empty
23276string, "0", "no", or "false", authentication fails. If the result of the
23277expansion is "1", "yes", or "true", authentication succeeds. For any other
23278result, a temporary error code is returned, with the expanded string as the
23279error text.
23280
23281+------------------+-------------------+-------------+--------------+
23282|server_debug_print|Use: authenticators|Type: string*|Default: unset|
23283+------------------+-------------------+-------------+--------------+
23284
23285If this option is set and authentication debugging is enabled (see the -d
23286command line option), the string is expanded and included in the debugging
23287output when the authenticator is run as a server. This can help with checking
23288out the values of variables. If expansion of the string fails, the error
23289message is written to the debugging output, and Exim carries on processing.
23290
23291+-------------+-------------------+-------------+--------------+
23292|server_set_id|Use: authenticators|Type: string*|Default: unset|
23293+-------------+-------------------+-------------+--------------+
23294
23295When an Exim server successfully authenticates a client, this string is
23296expanded using data from the authentication, and preserved for any incoming
23297messages in the variable $authenticated_id. It is also included in the log
23298lines for incoming messages. For example, a user/password authenticator
23299configuration might preserve the user name that was used to authenticate, and
23300refer to it subsequently during delivery of the message. If expansion fails,
23301the option is ignored.
23302
23303+--------------------------+-------------------+-------------+--------------+
23304|server_mail_auth_condition|Use: authenticators|Type: string*|Default: unset|
23305+--------------------------+-------------------+-------------+--------------+
23306
23307This option allows a server to discard authenticated sender addresses supplied
23308as part of MAIL commands in SMTP connections that are authenticated by the
23309driver on which server_mail_auth_condition is set. The option is not used as
23310part of the authentication process; instead its (unexpanded) value is
23311remembered for later use. How it is used is described in the following section.
23312
23313
2331433.2 The AUTH parameter on MAIL commands
23315----------------------------------------
23316
23317When a client supplied an AUTH= item on a MAIL command, Exim applies the
23318following checks before accepting it as the authenticated sender of the
23319message:
23320
23321 * If the connection is not using extended SMTP (that is, HELO was used rather
23322 than EHLO), the use of AUTH= is a syntax error.
23323
23324 * If the value of the AUTH= parameter is "<>", it is ignored.
23325
23326 * If acl_smtp_mailauth is defined, the ACL it specifies is run. While it is
23327 running, the value of $authenticated_sender is set to the value obtained
23328 from the AUTH= parameter. If the ACL does not yield "accept", the value of
23329 $authenticated_sender is deleted. The acl_smtp_mailauth ACL may not return
23330 "drop" or "discard". If it defers, a temporary error code (451) is given
23331 for the MAIL command.
23332
23333 * If acl_smtp_mailauth is not defined, the value of the AUTH= parameter is
23334 accepted and placed in $authenticated_sender only if the client has
23335 authenticated.
23336
23337 * If the AUTH= value was accepted by either of the two previous rules, and
23338 the client has authenticated, and the authenticator has a setting for the
23339 server_mail_auth_condition, the condition is checked at this point. The
23340 valued that was saved from the authenticator is expanded. If the expansion
23341 fails, or yields an empty string, "0", "no", or "false", the value of
23342 $authenticated_sender is deleted. If the expansion yields any other value,
23343 the value of $authenticated_sender is retained and passed on with the
23344 message.
23345
23346When $authenticated_sender is set for a message, it is passed on to other hosts
23347to which Exim authenticates as a client. Do not confuse this value with
23348$authenticated_id, which is a string obtained from the authentication process,
23349and which is not usually a complete email address.
23350
23351Whenever an AUTH= value is ignored, the incident is logged. The ACL for MAIL,
23352if defined, is run after AUTH= is accepted or ignored. It can therefore make
23353use of $authenticated_sender. The converse is not true: the value of
23354$sender_address is not yet set up when the acl_smtp_mailauth ACL is run.
23355
23356
2335733.3 Authentication on an Exim server
23358-------------------------------------
23359
23360When Exim receives an EHLO command, it advertises the public names of those
23361authenticators that are configured as servers, subject to the following
23362conditions:
23363
23364 * The client host must match auth_advertise_hosts (default *).
23365
23366 * It the server_advertise_condition option is set, its expansion must not
23367 yield the empty string, "0", "no", or "false".
23368
23369The order in which the authenticators are defined controls the order in which
23370the mechanisms are advertised.
23371
23372Some mail clients (for example, some versions of Netscape) require the user to
23373provide a name and password for authentication whenever AUTH is advertised,
23374even though authentication may not in fact be needed (for example, Exim may be
23375set up to allow unconditional relaying from the client by an IP address check).
23376You can make such clients more friendly by not advertising AUTH to them. For
23377example, if clients on the 10.9.8.0/24 network are permitted (by the ACL that
23378runs for RCPT) to relay without authentication, you should set
23379
23380auth_advertise_hosts = ! 10.9.8.0/24
23381
23382so that no authentication mechanisms are advertised to them.
23383
23384The server_advertise_condition controls the advertisement of individual
23385authentication mechanisms. For example, it can be used to restrict the
23386advertisement of a particular mechanism to encrypted connections, by a setting
23387such as:
23388
23389server_advertise_condition = ${if eq{$tls_in_cipher}{}{no}{yes}}
23390
23391If the session is encrypted, $tls_in_cipher is not empty, and so the expansion
23392yields "yes", which allows the advertisement to happen.
23393
23394When an Exim server receives an AUTH command from a client, it rejects it
23395immediately if AUTH was not advertised in response to an earlier EHLO command.
23396This is the case if
23397
23398 * The client host does not match auth_advertise_hosts; or
23399
23400 * No authenticators are configured with server options; or
23401
23402 * Expansion of server_advertise_condition blocked the advertising of all the
23403 server authenticators.
23404
23405Otherwise, Exim runs the ACL specified by acl_smtp_auth in order to decide
23406whether to accept the command. If acl_smtp_auth is not set, AUTH is accepted
23407from any client host.
23408
23409If AUTH is not rejected by the ACL, Exim searches its configuration for a
23410server authentication mechanism that was advertised in response to EHLO and
23411that matches the one named in the AUTH command. If it finds one, it runs the
23412appropriate authentication protocol, and authentication either succeeds or
23413fails. If there is no matching advertised mechanism, the AUTH command is
23414rejected with a 504 error.
23415
23416When a message is received from an authenticated host, the value of
23417$received_protocol is set to "esmtpa" or "esmtpsa" instead of "esmtp" or
23418"esmtps", and $sender_host_authenticated contains the name (not the public
23419name) of the authenticator driver that successfully authenticated the client
23420from which the message was received. This variable is empty if there was no
23421successful authentication.
23422
23423
2342433.4 Testing server authentication
23425----------------------------------
23426
23427Exim's -bh option can be useful for testing server authentication
23428configurations. The data for the AUTH command has to be sent using base64
23429encoding. A quick way to produce such data for testing is the following Perl
23430script:
23431
23432use MIME::Base64;
23433printf ("%s", encode_base64(eval "\"$ARGV[0]\""));
23434
23435This interprets its argument as a Perl string, and then encodes it. The
23436interpretation as a Perl string allows binary zeros, which are required for
23437some kinds of authentication, to be included in the data. For example, a
23438command line to run this script on such data might be
23439
23440encode '\0user\0password'
23441
23442Note the use of single quotes to prevent the shell interpreting the
23443backslashes, so that they can be interpreted by Perl to specify characters
23444whose code value is zero.
23445
23446Warning 1: If either of the user or password strings starts with an octal
23447digit, you must use three zeros instead of one after the leading backslash. If
23448you do not, the octal digit that starts your string will be incorrectly
23449interpreted as part of the code for the first character.
23450
23451Warning 2: If there are characters in the strings that Perl interprets
23452specially, you must use a Perl escape to prevent them being misinterpreted. For
23453example, a command such as
23454
23455encode '\0user@domain.com\0pas$$word'
23456
23457gives an incorrect answer because of the unescaped "@" and "$" characters.
23458
23459If you have the mimencode command installed, another way to do produce
23460base64-encoded strings is to run the command
23461
23462echo -e -n `\0user\0password' | mimencode
23463
23464The -e option of echo enables the interpretation of backslash escapes in the
23465argument, and the -n option specifies no newline at the end of its output.
23466However, not all versions of echo recognize these options, so you should check
23467your version before relying on this suggestion.
23468
23469
2347033.5 Authentication by an Exim client
23471-------------------------------------
23472
23473The smtp transport has two options called hosts_require_auth and hosts_try_auth
23474. When the smtp transport connects to a server that announces support for
23475authentication, and the host matches an entry in either of these options, Exim
23476(as a client) tries to authenticate as follows:
23477
23478 * For each authenticator that is configured as a client, in the order in
23479 which they are defined in the configuration, it searches the authentication
23480 mechanisms announced by the server for one whose name matches the public
23481 name of the authenticator.
23482
23483 * When it finds one that matches, it runs the authenticator's client code.
23484 The variables $host and $host_address are available for any string
23485 expansions that the client might do. They are set to the server's name and
23486 IP address. If any expansion is forced to fail, the authentication attempt
23487 is abandoned, and Exim moves on to the next authenticator. Otherwise an
23488 expansion failure causes delivery to be deferred.
23489
23490 * If the result of the authentication attempt is a temporary error or a
23491 timeout, Exim abandons trying to send the message to the host for the
23492 moment. It will try again later. If there are any backup hosts available,
23493 they are tried in the usual way.
23494
23495 * If the response to authentication is a permanent error (5xx code), Exim
23496 carries on searching the list of authenticators and tries another one if
23497 possible. If all authentication attempts give permanent errors, or if there
23498 are no attempts because no mechanisms match (or option expansions force
23499 failure), what happens depends on whether the host matches
23500 hosts_require_auth or hosts_try_auth. In the first case, a temporary error
23501 is generated, and delivery is deferred. The error can be detected in the
23502 retry rules, and thereby turned into a permanent error if you wish. In the
23503 second case, Exim tries to deliver the message unauthenticated.
23504
23505When Exim has authenticated itself to a remote server, it adds the AUTH
23506parameter to the MAIL commands it sends, if it has an authenticated sender for
23507the message. If the message came from a remote host, the authenticated sender
23508is the one that was receiving on an incoming MAIL command, provided that the
23509incoming connection was authenticated and the server_mail_auth condition
23510allowed the authenticated sender to be retained. If a local process calls Exim
23511to send a message, the sender address that is built from the login name and
23512qualify_domain is treated as authenticated. However, if the
23513authenticated_sender option is set on the smtp transport, it overrides the
23514authenticated sender that was received with the message.
23515
23516
23517
23518===============================================================================
2351934. THE PLAINTEXT AUTHENTICATOR
23520
23521The plaintext authenticator can be configured to support the PLAIN and LOGIN
23522authentication mechanisms, both of which transfer authentication data as plain
23523(unencrypted) text (though base64 encoded). The use of plain text is a security
23524risk; you are strongly advised to insist on the use of SMTP encryption (see
23525chapter 41) if you use the PLAIN or LOGIN mechanisms. If you do use unencrypted
23526plain text, you should not use the same passwords for SMTP connections as you
23527do for login accounts.
23528
23529
2353034.1 Plaintext options
23531----------------------
23532
23533When configured as a server, plaintext uses the following options:
23534
23535+----------------+-------------------+-------------+--------------+
23536|server_condition|Use: authenticators|Type: string*|Default: unset|
23537+----------------+-------------------+-------------+--------------+
23538
23539This is actually a global authentication option, but it must be set in order to
23540configure the plaintext driver as a server. Its use is described below.
23541
23542+--------------+--------------+-------------+--------------+
23543|server_prompts|Use: plaintext|Type: string*|Default: unset|
23544+--------------+--------------+-------------+--------------+
23545
23546The contents of this option, after expansion, must be a colon-separated list of
23547prompt strings. If expansion fails, a temporary authentication rejection is
23548given.
23549
23550
2355134.2 Using plaintext in a server
23552--------------------------------
23553
23554When running as a server, plaintext performs the authentication test by
23555expanding a string. The data sent by the client with the AUTH command, or in
23556response to subsequent prompts, is base64 encoded, and so may contain any byte
23557values when decoded. If any data is supplied with the command, it is treated as
23558a list of strings, separated by NULs (binary zeros), the first three of which
23559are placed in the expansion variables $auth1, $auth2, and $auth3 (neither LOGIN
23560nor PLAIN uses more than three strings).
23561
23562For compatibility with previous releases of Exim, the values are also placed in
23563the expansion variables $1, $2, and $3. However, the use of these variables for
23564this purpose is now deprecated, as it can lead to confusion in string
23565expansions that also use them for other things.
23566
23567If there are more strings in server_prompts than the number of strings supplied
23568with the AUTH command, the remaining prompts are used to obtain more data. Each
23569response from the client may be a list of NUL-separated strings.
23570
23571Once a sufficient number of data strings have been received, server_condition
23572is expanded. If the expansion is forced to fail, authentication fails. Any
23573other expansion failure causes a temporary error code to be returned. If the
23574result of a successful expansion is an empty string, "0", "no", or "false",
23575authentication fails. If the result of the expansion is "1", "yes", or "true",
23576authentication succeeds and the generic server_set_id option is expanded and
23577saved in $authenticated_id. For any other result, a temporary error code is
23578returned, with the expanded string as the error text
23579
23580Warning: If you use a lookup in the expansion to find the user's password, be
23581sure to make the authentication fail if the user is unknown. There are good and
23582bad examples at the end of the next section.
23583
23584
2358534.3 The PLAIN authentication mechanism
23586---------------------------------------
23587
23588The PLAIN authentication mechanism (RFC 2595) specifies that three strings be
23589sent as one item of data (that is, one combined string containing two NUL
23590separators). The data is sent either as part of the AUTH command, or
23591subsequently in response to an empty prompt from the server.
23592
23593The second and third strings are a user name and a corresponding password.
23594Using a single fixed user name and password as an example, this could be
23595configured as follows:
23596
23597fixed_plain:
23598 driver = plaintext
23599 public_name = PLAIN
23600 server_prompts = :
23601 server_condition = \
23602 ${if and {{eq{$auth2}{username}}{eq{$auth3}{mysecret}}}}
23603 server_set_id = $auth2
23604
23605Note that the default result strings from if ("true" or an empty string) are
23606exactly what we want here, so they need not be specified. Obviously, if the
23607password contains expansion-significant characters such as dollar, backslash,
23608or closing brace, they have to be escaped.
23609
23610The server_prompts setting specifies a single, empty prompt (empty items at the
23611end of a string list are ignored). If all the data comes as part of the AUTH
23612command, as is commonly the case, the prompt is not used. This authenticator is
23613advertised in the response to EHLO as
23614
23615250-AUTH PLAIN
23616
23617and a client host can authenticate itself by sending the command
23618
23619AUTH PLAIN AHVzZXJuYW1lAG15c2VjcmV0
23620
23621As this contains three strings (more than the number of prompts), no further
23622data is required from the client. Alternatively, the client may just send
23623
23624AUTH PLAIN
23625
23626to initiate authentication, in which case the server replies with an empty
23627prompt. The client must respond with the combined data string.
23628
23629The data string is base64 encoded, as required by the RFC. This example, when
23630decoded, is <NUL>"username"<NUL>"mysecret", where <NUL> represents a zero byte.
23631This is split up into three strings, the first of which is empty. The
23632server_condition option in the authenticator checks that the second two are
23633"username" and "mysecret" respectively.
23634
23635Having just one fixed user name and password, as in this example, is not very
23636realistic, though for a small organization with only a handful of
23637authenticating clients it could make sense.
23638
23639A more sophisticated instance of this authenticator could use the user name in
23640$auth2 to look up a password in a file or database, and maybe do an encrypted
23641comparison (see crypteq in chapter 11). Here is a example of this approach,
23642where the passwords are looked up in a DBM file. Warning: This is an incorrect
23643example:
23644
23645server_condition = \
23646 ${if eq{$auth3}{${lookup{$auth2}dbm{/etc/authpwd}}}}
23647
23648The expansion uses the user name ($auth2) as the key to look up a password,
23649which it then compares to the supplied password ($auth3). Why is this example
23650incorrect? It works fine for existing users, but consider what happens if a
23651non-existent user name is given. The lookup fails, but as no success/failure
23652strings are given for the lookup, it yields an empty string. Thus, to defeat
23653the authentication, all a client has to do is to supply a non-existent user
23654name and an empty password. The correct way of writing this test is:
23655
23656server_condition = ${lookup{$auth2}dbm{/etc/authpwd}\
23657 {${if eq{$value}{$auth3}}} {false}}
23658
23659In this case, if the lookup succeeds, the result is checked; if the lookup
23660fails, "false" is returned and authentication fails. If crypteq is being used
23661instead of eq, the first example is in fact safe, because crypteq always fails
23662if its second argument is empty. However, the second way of writing the test
23663makes the logic clearer.
23664
23665
2366634.4 The LOGIN authentication mechanism
23667---------------------------------------
23668
23669The LOGIN authentication mechanism is not documented in any RFC, but is in use
23670in a number of programs. No data is sent with the AUTH command. Instead, a user
23671name and password are supplied separately, in response to prompts. The
23672plaintext authenticator can be configured to support this as in this example:
23673
23674fixed_login:
23675 driver = plaintext
23676 public_name = LOGIN
23677 server_prompts = User Name : Password
23678 server_condition = \
23679 ${if and {{eq{$auth1}{username}}{eq{$auth2}{mysecret}}}}
23680 server_set_id = $auth1
23681
23682Because of the way plaintext operates, this authenticator accepts data supplied
23683with the AUTH command (in contravention of the specification of LOGIN), but if
23684the client does not supply it (as is the case for LOGIN clients), the prompt
23685strings are used to obtain two data items.
23686
23687Some clients are very particular about the precise text of the prompts. For
23688example, Outlook Express is reported to recognize only "Username:" and
23689"Password:". Here is an example of a LOGIN authenticator that uses those
23690strings. It uses the ldapauth expansion condition to check the user name and
23691password by binding to an LDAP server:
23692
23693login:
23694 driver = plaintext
23695 public_name = LOGIN
23696 server_prompts = Username:: : Password::
23697 server_condition = ${if and{{ \
23698 !eq{}{$auth1} }{ \
23699 ldapauth{\
23700 user="uid=${quote_ldap_dn:$auth1},ou=people,o=example.org" \
23701 pass=${quote:$auth2} \
23702 ldap://ldap.example.org/} }} }
23703 server_set_id = uid=$auth1,ou=people,o=example.org
23704
23705We have to check that the username is not empty before using it, because LDAP
23706does not permit empty DN components. We must also use the quote_ldap_dn
23707operator to correctly quote the DN for authentication. However, the basic quote
23708operator, rather than any of the LDAP quoting operators, is the correct one to
23709use for the password, because quoting is needed only to make the password
23710conform to the Exim syntax. At the LDAP level, the password is an uninterpreted
23711string.
23712
23713
2371434.5 Support for different kinds of authentication
23715--------------------------------------------------
23716
23717A number of string expansion features are provided for the purpose of
23718interfacing to different ways of user authentication. These include checking
23719traditionally encrypted passwords from /etc/passwd (or equivalent), PAM,
23720Radius, ldapauth, pwcheck, and saslauthd. For details see section 11.7.
23721
23722
2372334.6 Using plaintext in a client
23724--------------------------------
23725
23726The plaintext authenticator has two client options:
23727
23728+----------------------------+--------------+-------------+--------------+
23729|client_ignore_invalid_base64|Use: plaintext|Type: boolean|Default: false|
23730+----------------------------+--------------+-------------+--------------+
23731
23732If the client receives a server prompt that is not a valid base64 string,
23733authentication is abandoned by default. However, if this option is set true,
23734the error in the challenge is ignored and the client sends the response as
23735usual.
23736
23737+-----------+--------------+-------------+--------------+
23738|client_send|Use: plaintext|Type: string*|Default: unset|
23739+-----------+--------------+-------------+--------------+
23740
23741The string is a colon-separated list of authentication data strings. Each
23742string is independently expanded before being sent to the server. The first
23743string is sent with the AUTH command; any more strings are sent in response to
23744prompts from the server. Before each string is expanded, the value of the most
23745recent prompt is placed in the next $auth<n> variable, starting with $auth1 for
23746the first prompt. Up to three prompts are stored in this way. Thus, the prompt
23747that is received in response to sending the first string (with the AUTH
23748command) can be used in the expansion of the second string, and so on. If an
23749invalid base64 string is received when client_ignore_invalid_base64 is set, an
23750empty string is put in the $auth<n> variable.
23751
23752Note: You cannot use expansion to create multiple strings, because splitting
23753takes priority and happens first.
23754
23755Because the PLAIN authentication mechanism requires NUL (binary zero) bytes in
23756the data, further processing is applied to each string before it is sent. If
23757there are any single circumflex characters in the string, they are converted to
23758NULs. Should an actual circumflex be required as data, it must be doubled in
23759the string.
23760
23761This is an example of a client configuration that implements the PLAIN
23762authentication mechanism with a fixed user name and password:
23763
23764fixed_plain:
23765 driver = plaintext
23766 public_name = PLAIN
23767 client_send = ^username^mysecret
23768
23769The lack of colons means that the entire text is sent with the AUTH command,
23770with the circumflex characters converted to NULs. A similar example that uses
23771the LOGIN mechanism is:
23772
23773fixed_login:
23774 driver = plaintext
23775 public_name = LOGIN
23776 client_send = : username : mysecret
23777
23778The initial colon means that the first string is empty, so no data is sent with
23779the AUTH command itself. The remaining strings are sent in response to prompts.
23780
23781
23782
23783===============================================================================
2378435. THE CRAM_MD5 AUTHENTICATOR
23785
23786The CRAM-MD5 authentication mechanism is described in RFC 2195. The server
23787sends a challenge string to the client, and the response consists of a user
23788name and the CRAM-MD5 digest of the challenge string combined with a secret
23789string (password) which is known to both server and client. Thus, the secret is
23790not sent over the network as plain text, which makes this authenticator more
23791secure than plaintext. However, the downside is that the secret has to be
23792available in plain text at either end.
23793
23794
2379535.1 Using cram_md5 as a server
23796-------------------------------
23797
23798This authenticator has one server option, which must be set to configure the
23799authenticator as a server:
23800
23801+-------------+-------------+-------------+--------------+
23802|server_secret|Use: cram_md5|Type: string*|Default: unset|
23803+-------------+-------------+-------------+--------------+
23804
23805When the server receives the client's response, the user name is placed in the
23806expansion variable $auth1, and server_secret is expanded to obtain the password
23807for that user. The server then computes the CRAM-MD5 digest that the client
23808should have sent, and checks that it received the correct string. If the
23809expansion of server_secret is forced to fail, authentication fails. If the
23810expansion fails for some other reason, a temporary error code is returned to
23811the client.
23812
23813For compatibility with previous releases of Exim, the user name is also placed
23814in $1. However, the use of this variables for this purpose is now deprecated,
23815as it can lead to confusion in string expansions that also use numeric
23816variables for other things.
23817
23818For example, the following authenticator checks that the user name given by the
23819client is "ph10", and if so, uses "secret" as the password. For any other user
23820name, authentication fails.
23821
23822fixed_cram:
23823 driver = cram_md5
23824 public_name = CRAM-MD5
23825 server_secret = ${if eq{$auth1}{ph10}{secret}fail}
23826 server_set_id = $auth1
23827
23828If authentication succeeds, the setting of server_set_id preserves the user
23829name in $authenticated_id. A more typical configuration might look up the
23830secret string in a file, using the user name as the key. For example:
23831
23832lookup_cram:
23833 driver = cram_md5
23834 public_name = CRAM-MD5
23835 server_secret = ${lookup{$auth1}lsearch{/etc/authpwd}\
23836 {$value}fail}
23837 server_set_id = $auth1
23838
23839Note that this expansion explicitly forces failure if the lookup fails because
23840$auth1 contains an unknown user name.
23841
23842As another example, if you wish to re-use a Cyrus SASL sasldb2 file without
23843using the relevant libraries, you need to know the realm to specify in the
23844lookup and then ask for the "userPassword" attribute for that user in that
23845realm, with:
23846
23847cyrusless_crammd5:
23848 driver = cram_md5
23849 public_name = CRAM-MD5
23850 server_secret = ${lookup{$auth1:mail.example.org:userPassword}\
23851 dbmjz{/etc/sasldb2}}
23852 server_set_id = $auth1
23853
23854
2385535.2 Using cram_md5 as a client
23856-------------------------------
23857
23858When used as a client, the cram_md5 authenticator has two options:
23859
23860+-----------+-------------+-------------+------------------------------+
23861|client_name|Use: cram_md5|Type: string*|Default: the primary host name|
23862+-----------+-------------+-------------+------------------------------+
23863
23864This string is expanded, and the result used as the user name data when
23865computing the response to the server's challenge.
23866
23867+-------------+-------------+-------------+--------------+
23868|client_secret|Use: cram_md5|Type: string*|Default: unset|
23869+-------------+-------------+-------------+--------------+
23870
23871This option must be set for the authenticator to work as a client. Its value is
23872expanded and the result used as the secret string when computing the response.
23873
23874Different user names and secrets can be used for different servers by referring
23875to $host or $host_address in the options. Forced failure of either expansion
23876string is treated as an indication that this authenticator is not prepared to
23877handle this case. Exim moves on to the next configured client authenticator.
23878Any other expansion failure causes Exim to give up trying to send the message
23879to the current server.
23880
23881A simple example configuration of a cram_md5 authenticator, using fixed
23882strings, is:
23883
23884fixed_cram:
23885 driver = cram_md5
23886 public_name = CRAM-MD5
23887 client_name = ph10
23888 client_secret = secret
23889
23890
23891
23892===============================================================================
2389336. THE CYRUS_SASL AUTHENTICATOR
23894
23895The code for this authenticator was provided by Matthew Byng-Maddick of A L
23896Digital Ltd (http://www.aldigital.co.uk).
23897
23898The cyrus_sasl authenticator provides server support for the Cyrus SASL library
23899implementation of the RFC 2222 ("Simple Authentication and Security Layer").
23900This library supports a number of authentication mechanisms, including PLAIN
23901and LOGIN, but also several others that Exim does not support directly. In
23902particular, there is support for Kerberos authentication.
23903
23904The cyrus_sasl authenticator provides a gatewaying mechanism directly to the
23905Cyrus interface, so if your Cyrus library can do, for example, CRAM-MD5, then
23906so can the cyrus_sasl authenticator. By default it uses the public name of the
23907driver to determine which mechanism to support.
23908
23909Where access to some kind of secret file is required, for example in GSSAPI or
23910CRAM-MD5, it is worth noting that the authenticator runs as the Exim user, and
23911that the Cyrus SASL library has no way of escalating privileges by default. You
23912may also find you need to set environment variables, depending on the driver
23913you are using.
23914
23915The application name provided by Exim is "exim", so various SASL options may be
23916set in exim.conf in your SASL directory. If you are using GSSAPI for Kerberos,
23917note that because of limitations in the GSSAPI interface, changing the server
23918keytab might need to be communicated down to the Kerberos layer independently.
23919The mechanism for doing so is dependent upon the Kerberos implementation.
23920
23921For example, for older releases of Heimdal, the environment variable
23922KRB5_KTNAME may be set to point to an alternative keytab file. Exim will pass
23923this variable through from its own inherited environment when started as root
23924or the Exim user. The keytab file needs to be readable by the Exim user. With
23925newer releases of Heimdal, a setuid Exim may cause Heimdal to discard the
23926environment variable. In practice, for those releases, the Cyrus authenticator
23927is not a suitable interface for GSSAPI (Kerberos) support. Instead, consider
23928the heimdal_gssapi authenticator, described in chapter 39
23929
23930
2393136.1 Using cyrus_sasl as a server
23932---------------------------------
23933
23934The cyrus_sasl authenticator has four private options. It puts the username (on
23935a successful authentication) into $auth1. For compatibility with previous
23936releases of Exim, the username is also placed in $1. However, the use of this
23937variable for this purpose is now deprecated, as it can lead to confusion in
23938string expansions that also use numeric variables for other things.
23939
23940+---------------+---------------+-------------+------------------+
23941|server_hostname|Use: cyrus_sasl|Type: string*|Default: see below|
23942+---------------+---------------+-------------+------------------+
23943
23944This option selects the hostname that is used when communicating with the
23945library. The default value is "$primary_hostname". It is up to the underlying
23946SASL plug-in what it does with this data.
23947
23948+-----------+---------------+------------+------------------+
23949|server_mech|Use: cyrus_sasl|Type: string|Default: see below|
23950+-----------+---------------+------------+------------------+
23951
23952This option selects the authentication mechanism this driver should use. The
23953default is the value of the generic public_name option. This option allows you
23954to use a different underlying mechanism from the advertised name. For example:
23955
23956sasl:
23957 driver = cyrus_sasl
23958 public_name = X-ANYTHING
23959 server_mech = CRAM-MD5
23960 server_set_id = $auth1
23961
23962+------------+---------------+-------------+--------------+
23963|server_realm|Use: cyrus_sasl|Type: string*|Default: unset|
23964+------------+---------------+-------------+--------------+
23965
23966This specifies the SASL realm that the server claims to be in.
23967
23968+--------------+---------------+------------+---------------+
23969|server_service|Use: cyrus_sasl|Type: string|Default: "smtp"|
23970+--------------+---------------+------------+---------------+
23971
23972This is the SASL service that the server claims to implement.
23973
23974For straightforward cases, you do not need to set any of the authenticator's
23975private options. All you need to do is to specify an appropriate mechanism as
23976the public name. Thus, if you have a SASL library that supports CRAM-MD5 and
23977PLAIN, you could have two authenticators as follows:
23978
23979sasl_cram_md5:
23980 driver = cyrus_sasl
23981 public_name = CRAM-MD5
23982 server_set_id = $auth1
23983
23984sasl_plain:
23985 driver = cyrus_sasl
23986 public_name = PLAIN
23987 server_set_id = $auth2
23988
23989Cyrus SASL does implement the LOGIN authentication method, even though it is
23990not a standard method. It is disabled by default in the source distribution,
23991but it is present in many binary distributions.
23992
23993
23994
23995===============================================================================
2399637. THE DOVECOT AUTHENTICATOR
23997
23998This authenticator is an interface to the authentication facility of the
23999Dovecot POP/IMAP server, which can support a number of authentication methods.
24000
24001Note that Dovecot must be configured to use auth-client not auth-userdb.
24002
24003If you are using Dovecot to authenticate POP/IMAP clients, it might be helpful
24004to use the same mechanisms for SMTP authentication. This is a server
24005authenticator only. There is only one option:
24006
24007+-------------+------------+------------+--------------+
24008|server_socket|Use: dovecot|Type: string|Default: unset|
24009+-------------+------------+------------+--------------+
24010
24011This option must specify the socket that is the interface to Dovecot
24012authentication. The public_name option must specify an authentication mechanism
24013that Dovecot is configured to support. You can have several authenticators for
24014different mechanisms. For example:
24015
24016dovecot_plain:
24017 driver = dovecot
24018 public_name = PLAIN
24019 server_socket = /var/run/dovecot/auth-client
24020 server_set_id = $auth1
24021
24022dovecot_ntlm:
24023 driver = dovecot
24024 public_name = NTLM
24025 server_socket = /var/run/dovecot/auth-client
24026 server_set_id = $auth1
24027
24028If the SMTP connection is encrypted, or if $sender_host_address is equal to
24029$received_ip_address (that is, the connection is local), the "secured" option
24030is passed in the Dovecot authentication command. If, for a TLS connection, a
24031client certificate has been verified, the "valid-client-cert" option is passed.
24032When authentication succeeds, the identity of the user who authenticated is
24033placed in $auth1.
24034
24035
24036
24037===============================================================================
2403838. THE GSASL AUTHENTICATOR
24039
24040The gsasl authenticator provides server integration for the GNU SASL library
24041and the mechanisms it provides. This is new as of the 4.80 release and there
24042are a few areas where the library does not let Exim smoothly scale to handle
24043future authentication mechanisms, so no guarantee can be made that any
24044particular new authentication mechanism will be supported without code changes
24045in Exim.
24046
24047+---------------------+----------+-------------+--------------+
24048|server_channelbinding|Use: gsasl|Type: boolean|Default: false|
24049+---------------------+----------+-------------+--------------+
24050
24051Some authentication mechanisms are able to use external context at both ends of
24052the session to bind the authentication to that context, and fail the
24053authentication process if that context differs. Specifically, some TLS
24054ciphersuites can provide identifying information about the cryptographic
24055context.
24056
24057This means that certificate identity and verification becomes a non-issue, as a
24058man-in-the-middle attack will cause the correct client and server to see
24059different identifiers and authentication will fail.
24060
24061This is currently only supported when using the GnuTLS library. This is only
24062usable by mechanisms which support "channel binding"; at time of writing,
24063that's the SCRAM family.
24064
24065This defaults off to ensure smooth upgrade across Exim releases, in case this
24066option causes some clients to start failing. Some future release of Exim may
24067switch the default to be true.
24068
24069+---------------+----------+-------------+------------------+
24070|server_hostname|Use: gsasl|Type: string*|Default: see below|
24071+---------------+----------+-------------+------------------+
24072
24073This option selects the hostname that is used when communicating with the
24074library. The default value is "$primary_hostname". Some mechanisms will use
24075this data.
24076
24077+-----------+----------+------------+------------------+
24078|server_mech|Use: gsasl|Type: string|Default: see below|
24079+-----------+----------+------------+------------------+
24080
24081This option selects the authentication mechanism this driver should use. The
24082default is the value of the generic public_name option. This option allows you
24083to use a different underlying mechanism from the advertised name. For example:
24084
24085sasl:
24086 driver = gsasl
24087 public_name = X-ANYTHING
24088 server_mech = CRAM-MD5
24089 server_set_id = $auth1
24090
24091+---------------+----------+-------------+--------------+
24092|server_password|Use: gsasl|Type: string*|Default: unset|
24093+---------------+----------+-------------+--------------+
24094
24095Various mechanisms need access to the cleartext password on the server, so that
24096proof-of-possession can be demonstrated on the wire, without sending the
24097password itself.
24098
24099The data available for lookup varies per mechanism. In all cases, $auth1 is set
24100to the authentication id. The $auth2 variable will always be the authorization
24101id (authz) if available, else the empty string. The $auth3 variable will always
24102be the realm if available, else the empty string.
24103
24104A forced failure will cause authentication to defer.
24105
24106If using this option, it may make sense to set the server_condition option to
24107be simply "true".
24108
24109+------------+----------+-------------+--------------+
24110|server_realm|Use: gsasl|Type: string*|Default: unset|
24111+------------+----------+-------------+--------------+
24112
24113This specifies the SASL realm that the server claims to be in. Some mechanisms
24114will use this data.
24115
24116+-----------------+----------+-------------+--------------+
24117|server_scram_iter|Use: gsasl|Type: string*|Default: unset|
24118+-----------------+----------+-------------+--------------+
24119
24120This option provides data for the SCRAM family of mechanisms. $auth1 is not
24121available at evaluation time. (This may change, as we receive feedback on use)
24122
24123+-----------------+----------+-------------+--------------+
24124|server_scram_salt|Use: gsasl|Type: string*|Default: unset|
24125+-----------------+----------+-------------+--------------+
24126
24127This option provides data for the SCRAM family of mechanisms. $auth1 is not
24128available at evaluation time. (This may change, as we receive feedback on use)
24129
24130+--------------+----------+------------+---------------+
24131|server_service|Use: gsasl|Type: string|Default: "smtp"|
24132+--------------+----------+------------+---------------+
24133
24134This is the SASL service that the server claims to implement. Some mechanisms
24135will use this data.
24136
24137
2413838.1 gsasl auth variables
24139-------------------------
24140
24141These may be set when evaluating specific options, as detailed above. They will
24142also be set when evaluating server_condition.
24143
24144Unless otherwise stated below, the gsasl integration will use the following
24145meanings for these variables:
24146
24147 * $auth1: the authentication id
24148
24149 * $auth2: the authorization id
24150
24151 * $auth3: the realm
24152
24153On a per-mechanism basis:
24154
24155 * EXTERNAL: only $auth1 is set, to the possibly empty authorization id; the
24156 server_condition option must be present.
24157
24158 * ANONYMOUS: only $auth1 is set, to the possibly empty anonymous token; the
24159 server_condition option must be present.
24160
24161 * GSSAPI: $auth1 will be set to the GSSAPI Display Name; $auth2 will be set
24162 to the authorization id, the server_condition option must be present.
24163
24164An anonymous token is something passed along as an unauthenticated identifier;
24165this is analogous to FTP anonymous authentication passing an email address, or
24166software-identifier@, as the "password".
24167
24168An example showing the password having the realm specified in the callback and
24169demonstrating a Cyrus SASL to GSASL migration approach is:
24170
24171gsasl_cyrusless_crammd5:
24172 driver = gsasl
24173 public_name = CRAM-MD5
24174 server_realm = imap.example.org
24175 server_password = ${lookup{$auth1:$auth3:userPassword}\
24176 dbmjz{/etc/sasldb2}{$value}fail}
24177 server_set_id = ${quote:$auth1}
24178 server_condition = yes
24179
24180
24181
24182===============================================================================
2418339. THE HEIMDAL_GSSAPI AUTHENTICATOR
24184
24185The heimdal_gssapi authenticator provides server integration for the Heimdal
24186GSSAPI/Kerberos library, permitting Exim to set a keytab pathname reliably.
24187
24188+---------------+-------------------+-------------+------------------+
24189|server_hostname|Use: heimdal_gssapi|Type: string*|Default: see below|
24190+---------------+-------------------+-------------+------------------+
24191
24192This option selects the hostname that is used, with server_service, for
24193constructing the GSS server name, as a GSS_C_NT_HOSTBASED_SERVICE identifier.
24194The default value is "$primary_hostname".
24195
24196+-------------+-------------------+-------------+--------------+
24197|server_keytab|Use: heimdal_gssapi|Type: string*|Default: unset|
24198+-------------+-------------------+-------------+--------------+
24199
24200If set, then Heimdal will not use the system default keytab (typically /etc/
24201krb5.keytab) but instead the pathname given in this option. The value should be
24202a pathname, with no "file:" prefix.
24203
24204+--------------+-------------------+-------------+-------------+
24205|server_service|Use: heimdal_gssapi|Type: string*|Default: smtp|
24206+--------------+-------------------+-------------+-------------+
24207
24208This option specifies the service identifier used, in conjunction with
24209server_hostname, for building the identifer for finding credentials from the
24210keytab.
24211
24212
2421339.1 heimdal_gssapi auth variables
24214----------------------------------
24215
24216Beware that these variables will typically include a realm, thus will appear to
24217be roughly like an email address already. The authzid in $auth2 is not
24218verified, so a malicious client can set it to anything.
24219
24220The $auth1 field should be safely trustable as a value from the Key
24221Distribution Center. Note that these are not quite email addresses. Each
24222identifier is for a role, and so the left-hand-side may include a role suffix.
24223For instance, "joe/admin@EXAMPLE.ORG".
24224
24225 * $auth1: the authentication id, set to the GSS Display Name.
24226
24227 * $auth2: the authorization id, sent within SASL encapsulation after
24228 authentication. If that was empty, this will also be set to the GSS Display
24229 Name.
24230
24231
24232
24233===============================================================================
2423440. THE SPA AUTHENTICATOR
24235
24236The spa authenticator provides client support for Microsoft's Secure Password
24237Authentication mechanism, which is also sometimes known as NTLM (NT LanMan).
24238The code for client side of this authenticator was contributed by Marc
24239Prud'hommeaux, and much of it is taken from the Samba project (http://
24240www.samba.org). The code for the server side was subsequently contributed by
24241Tom Kistner. The mechanism works as follows:
24242
24243 * After the AUTH command has been accepted, the client sends an SPA
24244 authentication request based on the user name and optional domain.
24245
24246 * The server sends back a challenge.
24247
24248 * The client builds a challenge response which makes use of the user's
24249 password and sends it to the server, which then accepts or rejects it.
24250
24251Encryption is used to protect the password in transit.
24252
24253
2425440.1 Using spa as a server
24255--------------------------
24256
24257The spa authenticator has just one server option:
24258
24259+---------------+--------+-------------+--------------+
24260|server_password|Use: spa|Type: string*|Default: unset|
24261+---------------+--------+-------------+--------------+
24262
24263This option is expanded, and the result must be the cleartext password for the
24264authenticating user, whose name is at this point in $auth1. For compatibility
24265with previous releases of Exim, the user name is also placed in $1. However,
24266the use of this variable for this purpose is now deprecated, as it can lead to
24267confusion in string expansions that also use numeric variables for other
24268things. For example:
24269
24270spa:
24271 driver = spa
24272 public_name = NTLM
24273 server_password = \
24274 ${lookup{$auth1}lsearch{/etc/exim/spa_clearpass}{$value}fail}
24275
24276If the expansion is forced to fail, authentication fails. Any other expansion
24277failure causes a temporary error code to be returned.
24278
24279
2428040.2 Using spa as a client
24281--------------------------
24282
24283The spa authenticator has the following client options:
24284
24285+-------------+--------+-------------+--------------+
24286|client_domain|Use: spa|Type: string*|Default: unset|
24287+-------------+--------+-------------+--------------+
24288
24289This option specifies an optional domain for the authentication.
24290
24291+---------------+--------+-------------+--------------+
24292|client_password|Use: spa|Type: string*|Default: unset|
24293+---------------+--------+-------------+--------------+
24294
24295This option specifies the user's password, and must be set.
24296
24297+---------------+--------+-------------+--------------+
24298|client_username|Use: spa|Type: string*|Default: unset|
24299+---------------+--------+-------------+--------------+
24300
24301This option specifies the user name, and must be set. Here is an example of a
24302configuration of this authenticator for use with the mail servers at msn.com:
24303
24304msn:
24305 driver = spa
24306 public_name = MSN
24307 client_username = msn/msn_username
24308 client_password = msn_plaintext_password
24309 client_domain = DOMAIN_OR_UNSET
24310
24311
24312
24313===============================================================================
2431441. ENCRYPTED SMTP CONNECTIONS USING TLS/SSL
24315
24316Support for TLS (Transport Layer Security), formerly known as SSL (Secure
24317Sockets Layer), is implemented by making use of the OpenSSL library or the
24318GnuTLS library (Exim requires GnuTLS release 1.0 or later). There is no
24319cryptographic code in the Exim distribution itself for implementing TLS. In
24320order to use this feature you must install OpenSSL or GnuTLS, and then build a
24321version of Exim that includes TLS support (see section 4.7). You also need to
24322understand the basic concepts of encryption at a managerial level, and in
24323particular, the way that public keys, private keys, and certificates are used.
24324
24325RFC 3207 defines how SMTP connections can make use of encryption. Once a
24326connection is established, the client issues a STARTTLS command. If the server
24327accepts this, the client and the server negotiate an encryption mechanism. If
24328the negotiation succeeds, the data that subsequently passes between them is
24329encrypted.
24330
24331Exim's ACLs can detect whether the current SMTP session is encrypted or not,
24332and if so, what cipher suite is in use, whether the client supplied a
24333certificate, and whether or not that certificate was verified. This makes it
24334possible for an Exim server to deny or accept certain commands based on the
24335encryption state.
24336
24337Warning: Certain types of firewall and certain anti-virus products can disrupt
24338TLS connections. You need to turn off SMTP scanning for these products in order
24339to get TLS to work.
24340
24341
2434241.1 Support for the legacy "ssmtp" (aka "smtps") protocol
24343----------------------------------------------------------
24344
24345Early implementations of encrypted SMTP used a different TCP port from normal
24346SMTP, and expected an encryption negotiation to start immediately, instead of
24347waiting for a STARTTLS command from the client using the standard SMTP port.
24348The protocol was called "ssmtp" or "smtps", and port 465 was allocated for this
24349purpose.
24350
24351This approach was abandoned when encrypted SMTP was standardized, but there are
24352still some legacy clients that use it. Exim supports these clients by means of
24353the tls_on_connect_ports global option. Its value must be a list of port
24354numbers; the most common use is expected to be:
24355
24356tls_on_connect_ports = 465
24357
24358The port numbers specified by this option apply to all SMTP connections, both
24359via the daemon and via inetd. You still need to specify all the ports that the
24360daemon uses (by setting daemon_smtp_ports or local_interfaces or the -oX
24361command line option) because tls_on_connect_ports does not add an extra port -
24362rather, it specifies different behaviour on a port that is defined elsewhere.
24363
24364There is also a -tls-on-connect command line option. This overrides
24365tls_on_connect_ports; it forces the legacy behaviour for all ports.
24366
24367
2436841.2 OpenSSL vs GnuTLS
24369----------------------
24370
24371The first TLS support in Exim was implemented using OpenSSL. Support for GnuTLS
24372followed later, when the first versions of GnuTLS were released. To build Exim
24373to use GnuTLS, you need to set
24374
24375USE_GNUTLS=yes
24376
24377in Local/Makefile, in addition to
24378
24379SUPPORT_TLS=yes
24380
24381You must also set TLS_LIBS and TLS_INCLUDE appropriately, so that the include
24382files and libraries for GnuTLS can be found.
24383
24384There are some differences in usage when using GnuTLS instead of OpenSSL:
24385
24386 * The tls_verify_certificates option must contain the name of a file, not the
24387 name of a directory (for OpenSSL it can be either).
24388
24389 * The default value for tls_dhparam differs for historical reasons.
24390
24391 * Distinguished Name (DN) strings reported by the OpenSSL library use a slash
24392 for separating fields; GnuTLS uses commas, in accordance with RFC 2253.
24393 This affects the value of the $tls_in_peerdn and $tls_out_peerdn variables.
24394
24395 * OpenSSL identifies cipher suites using hyphens as separators, for example:
24396 DES-CBC3-SHA. GnuTLS historically used underscores, for example:
24397 RSA_ARCFOUR_SHA. What is more, OpenSSL complains if underscores are present
24398 in a cipher list. To make life simpler, Exim changes underscores to hyphens
24399 for OpenSSL and passes the string unchanged to GnuTLS (expecting the
24400 library to handle its own older variants) when processing lists of cipher
24401 suites in the tls_require_ciphers options (the global option and the smtp
24402 transport option).
24403
24404 * The tls_require_ciphers options operate differently, as described in the
24405 sections 41.4 and 41.5.
24406
24407 * The tls_dh_min_bits SMTP transport option is only honoured by GnuTLS. When
24408 using OpenSSL, this option is ignored. (If an API is found to let OpenSSL
24409 be configured in this way, let the Exim Maintainers know and we'll likely
24410 use it).
24411
24412 * Some other recently added features may only be available in one or the
24413 other. This should be documented with the feature. If the documentation
24414 does not explicitly state that the feature is infeasible in the other TLS
24415 implementation, then patches are welcome.
24416
24417
2441841.3 GnuTLS parameter computation
24419---------------------------------
24420
24421This section only applies if tls_dhparam is set to "historic" or to an explicit
24422path; if the latter, then the text about generation still applies, but not the
24423chosen filename. By default, as of Exim 4.80 a hard-coded D-H prime is used.
24424See the documentation of tls_dhparam for more information.
24425
24426GnuTLS uses D-H parameters that may take a substantial amount of time to
24427compute. It is unreasonable to re-compute them for every TLS session.
24428Therefore, Exim keeps this data in a file in its spool directory, called
24429gnutls-params-NNNN for some value of NNNN, corresponding to the number of bits
24430requested. The file is owned by the Exim user and is readable only by its
24431owner. Every Exim process that start up GnuTLS reads the D-H parameters from
24432this file. If the file does not exist, the first Exim process that needs it
24433computes the data and writes it to a temporary file which is renamed once it is
24434complete. It does not matter if several Exim processes do this simultaneously
24435(apart from wasting a few resources). Once a file is in place, new Exim
24436processes immediately start using it.
24437
24438For maximum security, the parameters that are stored in this file should be
24439recalculated periodically, the frequency depending on your paranoia level. If
24440you are avoiding using the fixed D-H primes published in RFCs, then you are
24441concerned about some advanced attacks and will wish to do this; if you do not
24442regenerate then you might as well stick to the standard primes.
24443
24444Arranging this is easy in principle; just delete the file when you want new
24445values to be computed. However, there may be a problem. The calculation of new
24446parameters needs random numbers, and these are obtained from /dev/random. If
24447the system is not very active, /dev/random may delay returning data until
24448enough randomness (entropy) is available. This may cause Exim to hang for a
24449substantial amount of time, causing timeouts on incoming connections.
24450
24451The solution is to generate the parameters externally to Exim. They are stored
24452in gnutls-params-N in PEM format, which means that they can be generated
24453externally using the certtool command that is part of GnuTLS.
24454
24455To replace the parameters with new ones, instead of deleting the file and
24456letting Exim re-create it, you can generate new parameters using certtool and,
24457when this has been done, replace Exim's cache file by renaming. The relevant
24458commands are something like this:
24459
24460# ls
24461[ look for file; assume gnutls-params-2236 is the most recent ]
24462# rm -f new-params
24463# touch new-params
24464# chown exim:exim new-params
24465# chmod 0600 new-params
24466# certtool --generate-dh-params --bits 2236 >>new-params
24467# openssl dhparam -noout -text -in new-params | head
24468[ check the first line, make sure it's not more than 2236;
24469 if it is, then go back to the start ("rm") and repeat
24470 until the size generated is at most the size requested ]
24471# chmod 0400 new-params
24472# mv new-params gnutls-params-2236
24473
24474If Exim never has to generate the parameters itself, the possibility of
24475stalling is removed.
24476
24477The filename changed in Exim 4.80, to gain the -bits suffix. The value which
24478Exim will choose depends upon the version of GnuTLS in use. For older GnuTLS,
24479the value remains hard-coded in Exim as 1024. As of GnuTLS 2.12.x, there is a
24480way for Exim to ask for the "normal" number of bits for D-H public-key usage,
24481and Exim does so. This attempt to remove Exim from TLS policy decisions failed,
24482as GnuTLS 2.12 returns a value higher than the current hard-coded limit of the
24483NSS library. Thus Exim gains the tls_dh_max_bits global option, which applies
24484to all D-H usage, client or server. If the value returned by GnuTLS is greater
24485than tls_dh_max_bits then the value will be clamped down to tls_dh_max_bits.
24486The default value has been set at the current NSS limit, which is still much
24487higher than Exim historically used.
24488
24489The filename and bits used will change as the GnuTLS maintainers change the
24490value for their parameter "GNUTLS_SEC_PARAM_NORMAL", as clamped by
24491tls_dh_max_bits. At the time of writing (mid 2012), GnuTLS 2.12 recommends 2432
24492bits, while NSS is limited to 2236 bits.
24493
24494In fact, the requested value will be *lower* than tls_dh_max_bits, to increase
24495the chance of the generated prime actually being within acceptable bounds, as
24496GnuTLS has been observed to overshoot. Note the check step in the procedure
24497above. There is no sane procedure available to Exim to double-check the size of
24498the generated prime, so it might still be too large.
24499
24500
2450141.4 Requiring specific ciphers in OpenSSL
24502------------------------------------------
24503
24504There is a function in the OpenSSL library that can be passed a list of cipher
24505suites before the cipher negotiation takes place. This specifies which ciphers
24506are acceptable. The list is colon separated and may contain names like
24507DES-CBC3-SHA. Exim passes the expanded value of tls_require_ciphers directly to
24508this function call. Many systems will install the OpenSSL manual-pages, so you
24509may have ciphers(1) available to you. The following quotation from the OpenSSL
24510documentation specifies what forms of item are allowed in the cipher string:
24511
24512 * It can consist of a single cipher suite such as RC4-SHA.
24513
24514 * It can represent a list of cipher suites containing a certain algorithm, or
24515 cipher suites of a certain type. For example SHA1 represents all ciphers
24516 suites using the digest algorithm SHA1 and SSLv3 represents all SSL v3
24517 algorithms.
24518
24519 * Lists of cipher suites can be combined in a single cipher string using the
24520 + character. This is used as a logical and operation. For example SHA1+DES
24521 represents all cipher suites containing the SHA1 and the DES algorithms.
24522
24523Each cipher string can be optionally preceded by one of the characters "!", "-"
24524or "+".
24525
24526 * If "!" is used, the ciphers are permanently deleted from the list. The
24527 ciphers deleted can never reappear in the list even if they are explicitly
24528 stated.
24529
24530 * If "-" is used, the ciphers are deleted from the list, but some or all of
24531 the ciphers can be added again by later options.
24532
24533 * If "+" is used, the ciphers are moved to the end of the list. This option
24534 does not add any new ciphers; it just moves matching existing ones.
24535
24536If none of these characters is present, the string is interpreted as a list of
24537ciphers to be appended to the current preference list. If the list includes any
24538ciphers already present they will be ignored: that is, they will not be moved
24539to the end of the list.
24540
24541The OpenSSL ciphers(1) command may be used to test the results of a given
24542string:
24543
24544# note single-quotes to get ! past any shell history expansion
24545$ openssl ciphers 'HIGH:!MD5:!SHA1'
24546
24547This example will let the library defaults be permitted on the MX port, where
24548there's probably no identity verification anyway, but ups the ante on the
24549submission ports where the administrator might have some influence on the
24550choice of clients used:
24551
24552# OpenSSL variant; see man ciphers(1)
24553tls_require_ciphers = ${if =={$received_port}{25}\
24554 {DEFAULT}\
24555 {HIGH:!MD5:!SHA1}}
24556
24557
2455841.5 Requiring specific ciphers or other parameters in GnuTLS
24559-------------------------------------------------------------
24560
24561The GnuTLS library allows the caller to provide a "priority string", documented
24562as part of the gnutls_priority_init function. This is very similar to the
24563ciphersuite specification in OpenSSL.
24564
24565The tls_require_ciphers option is treated as the GnuTLS priority string.
24566
24567The tls_require_ciphers option is available both as an global option,
24568controlling how Exim behaves as a server, and also as an option of the smtp
24569transport, controlling how Exim behaves as a client. In both cases the value is
24570string expanded. The resulting string is not an Exim list and the string is
24571given to the GnuTLS library, so that Exim does not need to be aware of future
24572feature enhancements of GnuTLS.
24573
24574Documentation of the strings accepted may be found in the GnuTLS manual, under
24575"Priority strings". This is online as http://www.gnutls.org/manual/html_node/
24576Priority-Strings.html, but beware that this relates to GnuTLS 3, which may be
24577newer than the version installed on your system. If you are using GnuTLS 3,
24578then the example code on that site can be used to test a given string.
24579
24580Prior to Exim 4.80, an older API of GnuTLS was used, and Exim supported three
24581additional options, "gnutls_require_kx", "gnutls_require_mac" and "
24582gnutls_require_protocols". tls_require_ciphers was an Exim list.
24583
24584This example will let the library defaults be permitted on the MX port, where
24585there's probably no identity verification anyway, and lowers security further
24586by increasing compatibility; but this ups the ante on the submission ports
24587where the administrator might have some influence on the choice of clients
24588used:
24589
24590# GnuTLS variant
24591tls_require_ciphers = ${if =={$received_port}{25}\
24592 {NORMAL:%COMPAT}\
24593 {SECURE128}}
24594
24595
2459641.6 Configuring an Exim server to use TLS
24597------------------------------------------
24598
24599When Exim has been built with TLS support, it advertises the availability of
24600the STARTTLS command to client hosts that match tls_advertise_hosts, but not to
24601any others. The default value of this option is unset, which means that
24602STARTTLS is not advertised at all. This default is chosen because you need to
24603set some other options in order to make TLS available, and also it is sensible
24604for systems that want to use TLS only as a client.
24605
24606If a client issues a STARTTLS command and there is some configuration problem
24607in the server, the command is rejected with a 454 error. If the client persists
24608in trying to issue SMTP commands, all except QUIT are rejected with the error
24609
24610554 Security failure
24611
24612If a STARTTLS command is issued within an existing TLS session, it is rejected
24613with a 554 error code.
24614
24615To enable TLS operations on a server, you must set tls_advertise_hosts to match
24616some hosts. You can, of course, set it to * to match all hosts. However, this
24617is not all you need to do. TLS sessions to a server won't work without some
24618further configuration at the server end.
24619
24620It is rumoured that all existing clients that support TLS/SSL use RSA
24621encryption. To make this work you need to set, in the server,
24622
24623tls_certificate = /some/file/name
24624tls_privatekey = /some/file/name
24625
24626These options are, in fact, expanded strings, so you can make them depend on
24627the identity of the client that is connected if you wish. The first file
24628contains the server's X509 certificate, and the second contains the private key
24629that goes with it. These files need to be readable by the Exim user, and must
24630always be given as full path names. They can be the same file if both the
24631certificate and the key are contained within it. If tls_privatekey is not set,
24632or if its expansion is forced to fail or results in an empty string, this is
24633assumed to be the case. The certificate file may also contain intermediate
24634certificates that need to be sent to the client to enable it to authenticate
24635the server's certificate.
24636
24637If you do not understand about certificates and keys, please try to find a
24638source of this background information, which is not Exim-specific. (There are a
24639few comments below in section 41.12.)
24640
24641Note: These options do not apply when Exim is operating as a client - they
24642apply only in the case of a server. If you need to use a certificate in an Exim
24643client, you must set the options of the same names in an smtp transport.
24644
24645With just these options, an Exim server will be able to use TLS. It does not
24646require the client to have a certificate (but see below for how to insist on
24647this). There is one other option that may be needed in other situations. If
24648
24649tls_dhparam = /some/file/name
24650
24651is set, the SSL library is initialized for the use of Diffie-Hellman ciphers
24652with the parameters contained in the file. Set this to "none" to disable use of
24653DH entirely, by making no prime available:
24654
24655tls_dhparam = none
24656
24657This may also be set to a string identifying a standard prime to be used for
24658DH; if it is set to "default" or, for OpenSSL, is unset, then the prime used is
24659"ike23". There are a few standard primes available, see the documentation for
24660tls_dhparam for the complete list.
24661
24662See the command
24663
24664openssl dhparam
24665
24666for a way of generating file data.
24667
24668The strings supplied for these three options are expanded every time a client
24669host connects. It is therefore possible to use different certificates and keys
24670for different hosts, if you so wish, by making use of the client's IP address
24671in $sender_host_address to control the expansion. If a string expansion is
24672forced to fail, Exim behaves as if the option is not set.
24673
24674The variable $tls_in_cipher is set to the cipher suite that was negotiated for
24675an incoming TLS connection. It is included in the Received: header of an
24676incoming message (by default - you can, of course, change this), and it is also
24677included in the log line that records a message's arrival, keyed by "X=",
24678unless the tls_cipher log selector is turned off. The encrypted condition can
24679be used to test for specific cipher suites in ACLs.
24680
24681Once TLS has been established, the ACLs that run for subsequent SMTP commands
24682can check the name of the cipher suite and vary their actions accordingly. The
24683cipher suite names vary, depending on which TLS library is being used. For
24684example, OpenSSL uses the name DES-CBC3-SHA for the cipher suite which in other
24685contexts is known as TLS_RSA_WITH_3DES_EDE_CBC_SHA. Check the OpenSSL or GnuTLS
24686documentation for more details.
24687
24688For outgoing SMTP deliveries, $tls_out_cipher is used and logged (again
24689depending on the tls_cipher log selector).
24690
24691
2469241.7 Requesting and verifying client certificates
24693-------------------------------------------------
24694
24695If you want an Exim server to request a certificate when negotiating a TLS
24696session with a client, you must set either tls_verify_hosts or
24697tls_try_verify_hosts. You can, of course, set either of them to * to apply to
24698all TLS connections. For any host that matches one of these options, Exim
24699requests a certificate as part of the setup of the TLS session. The contents of
24700the certificate are verified by comparing it with a list of expected
24701certificates. These must be available in a file or, for OpenSSL only (not
24702GnuTLS), a directory, identified by tls_verify_certificates.
24703
24704A file can contain multiple certificates, concatenated end to end. If a
24705directory is used (OpenSSL only), each certificate must be in a separate file,
24706with a name (or a symbolic link) of the form <hash>.0, where <hash> is a hash
24707value constructed from the certificate. You can compute the relevant hash by
24708running the command
24709
24710openssl x509 -hash -noout -in /cert/file
24711
24712where /cert/file contains a single certificate.
24713
24714The difference between tls_verify_hosts and tls_try_verify_hosts is what
24715happens if the client does not supply a certificate, or if the certificate does
24716not match any of the certificates in the collection named by
24717tls_verify_certificates. If the client matches tls_verify_hosts, the attempt to
24718set up a TLS session is aborted, and the incoming connection is dropped. If the
24719client matches tls_try_verify_hosts, the (encrypted) SMTP session continues.
24720ACLs that run for subsequent SMTP commands can detect the fact that no
24721certificate was verified, and vary their actions accordingly. For example, you
24722can insist on a certificate before accepting a message for relaying, but not
24723when the message is destined for local delivery.
24724
24725When a client supplies a certificate (whether it verifies or not), the value of
24726the Distinguished Name of the certificate is made available in the variable
24727$tls_in_peerdn during subsequent processing of the message.
24728
24729Because it is often a long text string, it is not included in the log line or
24730Received: header by default. You can arrange for it to be logged, keyed by "DN=
24731", by setting the tls_peerdn log selector, and you can use received_header_text
24732to change the Received: header. When no certificate is supplied, $tls_in_peerdn
24733is empty.
24734
24735
2473641.8 Revoked certificates
24737-------------------------
24738
24739Certificate issuing authorities issue Certificate Revocation Lists (CRLs) when
24740certificates are revoked. If you have such a list, you can pass it to an Exim
24741server using the global option called tls_crl and to an Exim client using an
24742identically named option for the smtp transport. In each case, the value of the
24743option is expanded and must then be the name of a file that contains a CRL in
24744PEM format. The downside is that clients have to periodically re-download a
24745potentially huge file from every certificate authority the know of.
24746
24747The way with most moving parts at query time is Online Certificate Status
24748Protocol (OCSP), where the client verifies the certificate against an OCSP
24749server run by the CA. This lets the CA track all usage of the certs. It
24750requires running software with access to the private key of the CA, to sign the
24751responses to the OCSP queries. OCSP is based on HTTP and can be proxied
24752accordingly.
24753
24754The only widespread OCSP server implementation (known to this writer) comes as
24755part of OpenSSL and aborts on an invalid request, such as connecting to the
24756port and then disconnecting. This requires re-entering the passphrase each time
24757some random client does this.
24758
24759The third way is OCSP Stapling; in this, the server using a certificate issued
24760by the CA periodically requests an OCSP proof of validity from the OCSP server,
24761then serves it up inline as part of the TLS negotiation. This approach adds no
24762extra round trips, does not let the CA track users, scales well with number of
24763certs issued by the CA and is resilient to temporary OCSP server failures, as
24764long as the server starts retrying to fetch an OCSP proof some time before its
24765current proof expires. The downside is that it requires server support.
24766
24767Unless Exim is built with the support disabled, or with GnuTLS earlier than
24768version 3.1.3, support for OCSP stapling is included.
24769
24770There is a global option called tls_ocsp_file. The file specified therein is
24771expected to be in DER format, and contain an OCSP proof. Exim will serve it as
24772part of the TLS handshake. This option will be re-expanded for SNI, if the
24773tls_certificate option contains "tls_in_sni", as per other TLS options.
24774
24775Exim does not at this time implement any support for fetching a new OCSP proof.
24776The burden is on the administrator to handle this, outside of Exim. The file
24777specified should be replaced atomically, so that the contents are always valid.
24778Exim will expand the tls_ocsp_file option on each connection, so a new file
24779will be handled transparently on the next connection.
24780
24781When built with OpenSSL Exim will check for a valid next update timestamp in
24782the OCSP proof; if not present, or if the proof has expired, it will be
24783ignored.
24784
24785For the client to be able to verify the stapled OCSP the server must also
24786supply, in its stapled information, any intermediate certificates for the chain
24787leading to the OCSP proof from the signer of the server certificate. There may
24788be zero or one such. These intermediate certificates should be added to the
24789server OCSP stapling file named by tls_ocsp_file.
24790
24791Note that the proof only covers the terminal server certificate, not any of the
24792chain from CA to it.
24793
24794There is no current way to staple a proof for a client certificate.
24795
24796 A helper script "ocsp_fetch.pl" for fetching a proof from a CA
24797 OCSP server is supplied. The server URL may be included in the
24798 server certificate, if the CA is helpful.
24799
24800 One failure mode seen was the OCSP Signer cert expiring before the end
24801 of validity of the OCSP proof. The checking done by Exim/OpenSSL
24802 noted this as invalid overall, but the re-fetch script did not.
24803
24804
2480541.9 Configuring an Exim client to use TLS
24806------------------------------------------
24807
24808The tls_cipher and tls_peerdn log selectors apply to outgoing SMTP deliveries
24809as well as to incoming, the latter one causing logging of the server
24810certificate's DN. The remaining client configuration for TLS is all within the
24811smtp transport.
24812
24813It is not necessary to set any options to have TLS work in the smtp transport.
24814If Exim is built with TLS support, and TLS is advertised by a server, the smtp
24815transport always tries to start a TLS session. However, this can be prevented
24816by setting hosts_avoid_tls (an option of the transport) to a list of server
24817hosts for which TLS should not be used.
24818
24819If you do not want Exim to attempt to send messages unencrypted when an attempt
24820to set up an encrypted connection fails in any way, you can set
24821hosts_require_tls to a list of hosts for which encryption is mandatory. For
24822those hosts, delivery is always deferred if an encrypted connection cannot be
24823set up. If there are any other hosts for the address, they are tried in the
24824usual way.
24825
24826When the server host is not in hosts_require_tls, Exim may try to deliver the
24827message unencrypted. It always does this if the response to STARTTLS is a 5xx
24828code. For a temporary error code, or for a failure to negotiate a TLS session
24829after a success response code, what happens is controlled by the
24830tls_tempfail_tryclear option of the smtp transport. If it is false, delivery to
24831this host is deferred, and other hosts (if available) are tried. If it is true,
24832Exim attempts to deliver unencrypted after a 4xx response to STARTTLS, and if
24833STARTTLS is accepted, but the subsequent TLS negotiation fails, Exim closes the
24834current connection (because it is in an unknown state), opens a new one to the
24835same host, and then tries the delivery unencrypted.
24836
24837The tls_certificate and tls_privatekey options of the smtp transport provide
24838the client with a certificate, which is passed to the server if it requests it.
24839If the server is Exim, it will request a certificate only if tls_verify_hosts
24840or tls_try_verify_hosts matches the client.
24841
24842If the tls_verify_certificates option is set on the smtp transport, it must
24843name a file or, for OpenSSL only (not GnuTLS), a directory, that contains a
24844collection of expected server certificates. The client verifies the server's
24845certificate against this collection, taking into account any revoked
24846certificates that are in the list defined by tls_crl. Failure to verify fails
24847the TLS connection unless either of the tls_verify_hosts or
24848tls_try_verify_hosts options are set.
24849
24850The tls_verify_hosts and tls_try_verify_hosts options restrict certificate
24851verification to the listed servers. Verification either must or need not
24852succeed respectively.
24853
24854The smtp transport has two OCSP-related options: hosts_require_ocsp; a
24855host-list for which a Certificate Status is requested and required for the
24856connection to proceed. The default value is empty. hosts_request_ocsp; a
24857host-list for which (additionally) a Certificate Status is requested (but not
24858necessarily verified). The default value is "*" meaning that requests are made
24859unless configured otherwise.
24860
24861The host(s) should also be in hosts_require_tls, and tls_verify_certificates
24862configured for the transport, for OCSP to be relevant.
24863
24864If tls_require_ciphers is set on the smtp transport, it must contain a list of
24865permitted cipher suites. If either of these checks fails, delivery to the
24866current host is abandoned, and the smtp transport tries to deliver to
24867alternative hosts, if any.
24868
24869Note: These options must be set in the smtp transport for Exim to use TLS when
24870it is operating as a client. Exim does not assume that a server certificate
24871(set by the global options of the same name) should also be used when operating
24872as a client.
24873
24874All the TLS options in the smtp transport are expanded before use, with $host
24875and $host_address containing the name and address of the server to which the
24876client is connected. Forced failure of an expansion causes Exim to behave as if
24877the relevant option were unset.
24878
24879Before an SMTP connection is established, the $tls_out_bits, $tls_out_cipher,
24880$tls_out_peerdn and $tls_out_sni variables are emptied. (Until the first
24881connection, they contain the values that were set when the message was
24882received.) If STARTTLS is subsequently successfully obeyed, these variables are
24883set to the relevant values for the outgoing connection.
24884
24885
2488641.10 Use of TLS Server Name Indication
24887---------------------------------------
24888
24889With TLS1.0 or above, there is an extension mechanism by which extra
24890information can be included at various points in the protocol. One of these
24891extensions, documented in RFC 6066 (and before that RFC 4366) is "Server Name
24892Indication", commonly "SNI". This extension is sent by the client in the
24893initial handshake, so that the server can examine the servername within and
24894possibly choose to use different certificates and keys (and more) for this
24895session.
24896
24897This is analagous to HTTP's "Host:" header, and is the main mechanism by which
24898HTTPS-enabled web-sites can be virtual-hosted, many sites to one IP address.
24899
24900With SMTP to MX, there are the same problems here as in choosing the identity
24901against which to validate a certificate: you can't rely on insecure DNS to
24902provide the identity which you then cryptographically verify. So this will be
24903of limited use in that environment.
24904
24905With SMTP to Submission, there is a well-defined hostname which clients are
24906connecting to and can validate certificates against. Thus clients can choose to
24907include this information in the TLS negotiation. If this becomes wide-spread,
24908then hosters can choose to present different certificates to different clients.
24909Or even negotiate different cipher suites.
24910
24911The tls_sni option on an SMTP transport is an expanded string; the result, if
24912not empty, will be sent on a TLS session as part of the handshake. There's
24913nothing more to it. Choosing a sensible value not derived insecurely is the
24914only point of caution. The $tls_out_sni variable will be set to this string for
24915the lifetime of the client connection (including during authentication).
24916
24917Except during SMTP client sessions, if $tls_in_sni is set then it is a string
24918received from a client. It can be logged with the log_selector item "+tls_sni".
24919
24920If the string "tls_in_sni" appears in the main section's tls_certificate option
24921(prior to expansion) then the following options will be re-expanded during TLS
24922session handshake, to permit alternative values to be chosen:
24923
24924 * tls_certificate
24925
24926 * tls_crl
24927
24928 * tls_privatekey
24929
24930 * tls_verify_certificates
24931
24932 * tls_verify_certificates
24933
24934Great care should be taken to deal with matters of case, various injection
24935attacks in the string ("../" or SQL), and ensuring that a valid filename can
24936always be referenced; it is important to remember that $tls_sni is arbitrary
24937unverified data provided prior to authentication.
24938
24939The Exim developers are proceeding cautiously and so far no other TLS options
24940are re-expanded.
24941
24942When Exim is built againt OpenSSL, OpenSSL must have been built with support
24943for TLS Extensions. This holds true for OpenSSL 1.0.0+ and 0.9.8+ with
24944enable-tlsext in EXTRACONFIGURE. If you invoke openssl s_client -h and see
24945"-servername" in the output, then OpenSSL has support.
24946
24947When Exim is built against GnuTLS, SNI support is available as of GnuTLS
249480.5.10. (Its presence predates the current API which Exim uses, so if Exim
24949built, then you have SNI support).
24950
24951
2495241.11 Multiple messages on the same encrypted TCP/IP connection
24953---------------------------------------------------------------
24954
24955Exim sends multiple messages down the same TCP/IP connection by starting up an
24956entirely new delivery process for each message, passing the socket from one
24957process to the next. This implementation does not fit well with the use of TLS,
24958because there is quite a lot of state information associated with a TLS
24959connection, not just a socket identification. Passing all the state information
24960to a new process is not feasible. Consequently, Exim shuts down an existing TLS
24961session before passing the socket to a new process. The new process may then
24962try to start a new TLS session, and if successful, may try to re-authenticate
24963if AUTH is in use, before sending the next message.
24964
24965The RFC is not clear as to whether or not an SMTP session continues in clear
24966after TLS has been shut down, or whether TLS may be restarted again later, as
24967just described. However, if the server is Exim, this shutdown and
24968reinitialization works. It is not known which (if any) other servers operate
24969successfully if the client closes a TLS session and continues with unencrypted
24970SMTP, but there are certainly some that do not work. For such servers, Exim
24971should not pass the socket to another process, because the failure of the
24972subsequent attempt to use it would cause Exim to record a temporary host error,
24973and delay other deliveries to that host.
24974
24975To test for this case, Exim sends an EHLO command to the server after closing
24976down the TLS session. If this fails in any way, the connection is closed
24977instead of being passed to a new delivery process, but no retry information is
24978recorded.
24979
24980There is also a manual override; you can set hosts_nopass_tls on the smtp
24981transport to match those hosts for which Exim should not pass connections to
24982new processes if TLS has been used.
24983
24984
2498541.12 Certificates and all that
24986-------------------------------
24987
24988In order to understand fully how TLS works, you need to know about
24989certificates, certificate signing, and certificate authorities. This is not the
24990place to give a tutorial, especially as I do not know very much about it
24991myself. Some helpful introduction can be found in the FAQ for the SSL addition
24992to Apache, currently at
24993
24994http://www.modssl.org/docs/2.7/ssl_faq.html#ToC24
24995
24996Other parts of the modssl documentation are also helpful, and have links to
24997further files. Eric Rescorla's book, SSL and TLS, published by Addison-Wesley
24998(ISBN 0-201-61598-3), contains both introductory and more in-depth
24999descriptions. Some sample programs taken from the book are available from
25000
25001http://www.rtfm.com/openssl-examples/
25002
25003
2500441.13 Certificate chains
25005------------------------
25006
25007The file named by tls_certificate may contain more than one certificate. This
25008is useful in the case where the certificate that is being sent is validated by
25009an intermediate certificate which the other end does not have. Multiple
25010certificates must be in the correct order in the file. First the host's
25011certificate itself, then the first intermediate certificate to validate the
25012issuer of the host certificate, then the next intermediate certificate to
25013validate the issuer of the first intermediate certificate, and so on, until
25014finally (optionally) the root certificate. The root certificate must already be
25015trusted by the recipient for validation to succeed, of course, but if it's not
25016preinstalled, sending the root certificate along with the rest makes it
25017available for the user to install if the receiving end is a client MUA that can
25018interact with a user.
25019
25020Note that certificates using MD5 are unlikely to work on today's Internet; even
25021if your libraries allow loading them for use in Exim when acting as a server,
25022increasingly clients will not accept such certificates. The error diagnostics
25023in such a case can be frustratingly vague.
25024
25025
2502641.14 Self-signed certificates
25027------------------------------
25028
25029You can create a self-signed certificate using the req command provided with
25030OpenSSL, like this:
25031
25032openssl req -x509 -newkey rsa:1024 -keyout file1 -out file2 \
25033 -days 9999 -nodes
25034
25035file1 and file2 can be the same file; the key and the certificate are delimited
25036and so can be identified independently. The -days option specifies a period for
25037which the certificate is valid. The -nodes option is important: if you do not
25038set it, the key is encrypted with a passphrase that you are prompted for, and
25039any use that is made of the key causes more prompting for the passphrase. This
25040is not helpful if you are going to use this certificate and key in an MTA,
25041where prompting is not possible.
25042
25043NB: we are now past the point where 9999 days takes us past the 32-bit Unix
25044epoch. If your system uses unsigned time_t (most do) and is 32-bit, then the
25045above command might produce a date in the past. Think carefully about the
25046lifetime of the systems you're deploying, and either reduce the duration of the
25047certificate or reconsider your platform deployment. (At time of writing,
25048reducing the duration is the most likely choice, but the inexorable progression
25049of time takes us steadily towards an era where this will not be a sensible
25050resolution).
25051
25052A self-signed certificate made in this way is sufficient for testing, and may
25053be adequate for all your requirements if you are mainly interested in
25054encrypting transfers, and not in secure identification.
25055
25056However, many clients require that the certificate presented by the server be a
25057user (also called "leaf" or "site") certificate, and not a self-signed
25058certificate. In this situation, the self-signed certificate described above
25059must be installed on the client host as a trusted root certification authority
25060(CA), and the certificate used by Exim must be a user certificate signed with
25061that self-signed certificate.
25062
25063For information on creating self-signed CA certificates and using them to sign
25064user certificates, see the General implementation overview chapter of the
25065Open-source PKI book, available online at http://ospkibook.sourceforge.net/.
25066
25067
25068
25069===============================================================================
2507042. ACCESS CONTROL LISTS
25071
25072Access Control Lists (ACLs) are defined in a separate section of the run time
25073configuration file, headed by "begin acl". Each ACL definition starts with a
25074name, terminated by a colon. Here is a complete ACL section that contains just
25075one very small ACL:
25076
25077begin acl
25078small_acl:
25079 accept hosts = one.host.only
25080
25081You can have as many lists as you like in the ACL section, and the order in
25082which they appear does not matter. The lists are self-terminating.
25083
25084The majority of ACLs are used to control Exim's behaviour when it receives
25085certain SMTP commands. This applies both to incoming TCP/IP connections, and
25086when a local process submits a message using SMTP by specifying the -bs option.
25087The most common use is for controlling which recipients are accepted in
25088incoming messages. In addition, you can define an ACL that is used to check
25089local non-SMTP messages. The default configuration file contains an example of
25090a realistic ACL for checking RCPT commands. This is discussed in chapter 7.
25091
25092
2509342.1 Testing ACLs
25094-----------------
25095
25096The -bh command line option provides a way of testing your ACL configuration
25097locally by running a fake SMTP session with which you interact. The host
25098relay-test.mail-abuse.org provides a service for checking your relaying
25099configuration (see section 42.53 for more details).
25100
25101
2510242.2 Specifying when ACLs are used
25103----------------------------------
25104
25105In order to cause an ACL to be used, you have to name it in one of the relevant
25106options in the main part of the configuration. These options are:
25107
25108 acl_not_smtp ACL for non-SMTP messages
25109 acl_not_smtp_mime ACL for non-SMTP MIME parts
25110 acl_not_smtp_start ACL at start of non-SMTP message
25111 acl_smtp_auth ACL for AUTH
25112 acl_smtp_connect ACL for start of SMTP connection
25113 acl_smtp_data ACL after DATA is complete
25114 acl_smtp_data_prdr ACL for each recipient, after DATA is complete
25115 acl_smtp_etrn ACL for ETRN
25116 acl_smtp_expn ACL for EXPN
25117 acl_smtp_helo ACL for HELO or EHLO
25118 acl_smtp_mail ACL for MAIL
25119 acl_smtp_mailauth ACL for the AUTH parameter of MAIL
25120 acl_smtp_mime ACL for content-scanning MIME parts
25121 acl_smtp_notquit ACL for non-QUIT terminations
25122 acl_smtp_predata ACL at start of DATA command
25123 acl_smtp_quit ACL for QUIT
25124 acl_smtp_rcpt ACL for RCPT
25125 acl_smtp_starttls ACL for STARTTLS
25126 acl_smtp_vrfy ACL for VRFY
25127
25128For example, if you set
25129
25130acl_smtp_rcpt = small_acl
25131
25132the little ACL defined above is used whenever Exim receives a RCPT command in
25133an SMTP dialogue. The majority of policy tests on incoming messages can be done
25134when RCPT commands arrive. A rejection of RCPT should cause the sending MTA to
25135give up on the recipient address contained in the RCPT command, whereas
25136rejection at other times may cause the client MTA to keep on trying to deliver
25137the message. It is therefore recommended that you do as much testing as
25138possible at RCPT time.
25139
25140
2514142.3 The non-SMTP ACLs
25142----------------------
25143
25144The non-SMTP ACLs apply to all non-interactive incoming messages, that is, they
25145apply to batched SMTP as well as to non-SMTP messages. (Batched SMTP is not
25146really SMTP.) Many of the ACL conditions (for example, host tests, and tests on
25147the state of the SMTP connection such as encryption and authentication) are not
25148relevant and are forbidden in these ACLs. However, the sender and recipients
25149are known, so the senders and sender_domains conditions and the $sender_address
25150and $recipients variables can be used. Variables such as $authenticated_sender
25151are also available. You can specify added header lines in any of these ACLs.
25152
25153The acl_not_smtp_start ACL is run right at the start of receiving a non-SMTP
25154message, before any of the message has been read. (This is the analogue of the
25155acl_smtp_predata ACL for SMTP input.) In the case of batched SMTP input, it
25156runs after the DATA command has been reached. The result of this ACL is
25157ignored; it cannot be used to reject a message. If you really need to, you
25158could set a value in an ACL variable here and reject based on that in the
25159acl_not_smtp ACL. However, this ACL can be used to set controls, and in
25160particular, it can be used to set
25161
25162control = suppress_local_fixups
25163
25164This cannot be used in the other non-SMTP ACLs because by the time they are
25165run, it is too late.
25166
25167The acl_not_smtp_mime ACL is available only when Exim is compiled with the
25168content-scanning extension. For details, see chapter 43.
25169
25170The acl_not_smtp ACL is run just before the local_scan() function. Any kind of
25171rejection is treated as permanent, because there is no way of sending a
25172temporary error for these kinds of message.
25173
25174
2517542.4 The SMTP connect ACL
25176-------------------------
25177
25178The ACL test specified by acl_smtp_connect happens at the start of an SMTP
25179session, after the test specified by host_reject_connection (which is now an
25180anomaly) and any TCP Wrappers testing (if configured). If the connection is
25181accepted by an accept verb that has a message modifier, the contents of the
25182message override the banner message that is otherwise specified by the
25183smtp_banner option.
25184
25185
2518642.5 The EHLO/HELO ACL
25187----------------------
25188
25189The ACL test specified by acl_smtp_helo happens when the client issues an EHLO
25190or HELO command, after the tests specified by helo_accept_junk_hosts,
25191helo_allow_chars, helo_verify_hosts, and helo_try_verify_hosts. Note that a
25192client may issue more than one EHLO or HELO command in an SMTP session, and
25193indeed is required to issue a new EHLO or HELO after successfully setting up
25194encryption following a STARTTLS command.
25195
25196If the command is accepted by an accept verb that has a message modifier, the
25197message may not contain more than one line (it will be truncated at the first
25198newline and a panic logged if it does). Such a message cannot affect the EHLO
25199options that are listed on the second and subsequent lines of an EHLO response.
25200
25201
2520242.6 The DATA ACLs
25203------------------
25204
25205Two ACLs are associated with the DATA command, because it is two-stage command,
25206with two responses being sent to the client. When the DATA command is received,
25207the ACL defined by acl_smtp_predata is obeyed. This gives you control after all
25208the RCPT commands, but before the message itself is received. It offers the
25209opportunity to give a negative response to the DATA command before the data is
25210transmitted. Header lines added by MAIL or RCPT ACLs are not visible at this
25211time, but any that are defined here are visible when the acl_smtp_data ACL is
25212run.
25213
25214You cannot test the contents of the message, for example, to verify addresses
25215in the headers, at RCPT time or when the DATA command is received. Such tests
25216have to appear in the ACL that is run after the message itself has been
25217received, before the final response to the DATA command is sent. This is the
25218ACL specified by acl_smtp_data, which is the second ACL that is associated with
25219the DATA command.
25220
25221For both of these ACLs, it is not possible to reject individual recipients. An
25222error response rejects the entire message. Unfortunately, it is known that some
25223MTAs do not treat hard (5xx) responses to the DATA command (either before or
25224after the data) correctly - they keep the message on their queues and try again
25225later, but that is their problem, though it does waste some of your resources.
25226
25227The acl_smtp_data ACL is run after the acl_smtp_data_prdr, the acl_smtp_dkim
25228and the acl_smtp_mime ACLs.
25229
25230
2523142.7 The SMTP DKIM ACL
25232----------------------
25233
25234The acl_smtp_dkim ACL is available only when Exim is compiled with DKIM support
25235enabled (which is the default).
25236
25237The ACL test specified by acl_smtp_dkim happens after a message has been
25238received, and is executed for each DKIM signature found in a message. If not
25239otherwise specified, the default action is to accept.
25240
25241This ACL is evaluated before acl_smtp_mime and acl_smtp_data.
25242
25243For details on the operation of DKIM, see chapter 56.
25244
25245
2524642.8 The SMTP MIME ACL
25247----------------------
25248
25249The acl_smtp_mime option is available only when Exim is compiled with the
25250content-scanning extension. For details, see chapter 43.
25251
25252This ACL is evaluated after acl_smtp_dkim but before acl_smtp_data.
25253
25254
2525542.9 The SMTP PRDR ACL
25256----------------------
25257
25258The acl_smtp_data_prdr ACL is available only when Exim is compiled with PRDR
25259support enabled (which is the default). It becomes active only when the PRDR
25260feature is negotiated between client and server for a message, and more than
25261one recipient has been accepted.
25262
25263The ACL test specfied by acl_smtp_data_prdr happens after a message has been
25264recieved, and is executed for each recipient of the message. The test may
25265accept or deny for inividual recipients. The acl_smtp_data will still be called
25266after this ACL and can reject the message overall, even if this ACL has
25267accepted it for some or all recipients.
25268
25269PRDR may be used to support per-user content filtering. Without it one must
25270defer any recipient after the first that has a different content-filter
25271configuration. With PRDR, the RCPT-time check for this can be disabled when the
25272MAIL-time $smtp_command included "PRDR". Any required difference in behaviour
25273of the main DATA-time ACL should however depend on the PRDR-time ACL having
25274run, as Exim will avoid doing so in some situations (eg. single-recipient
25275mails).
25276
25277See also the prdr_enable global option and the hosts_try_prdr smtp transport
25278option.
25279
25280This ACL is evaluated after acl_smtp_dkim but before acl_smtp_data. If the ACL
25281is not defined, processing completes as if the feature was not requested by the
25282client.
25283
25284
2528542.10 The QUIT ACL
25286------------------
25287
25288The ACL for the SMTP QUIT command is anomalous, in that the outcome of the ACL
25289does not affect the response code to QUIT, which is always 221. Thus, the ACL
25290does not in fact control any access. For this reason, the only verbs that are
25291permitted are accept and warn.
25292
25293This ACL can be used for tasks such as custom logging at the end of an SMTP
25294session. For example, you can use ACL variables in other ACLs to count
25295messages, recipients, etc., and log the totals at QUIT time using one or more
25296logwrite modifiers on a warn verb.
25297
25298Warning: Only the $acl_cx variables can be used for this, because the $acl_mx
25299variables are reset at the end of each incoming message.
25300
25301You do not need to have a final accept, but if you do, you can use a message
25302modifier to specify custom text that is sent as part of the 221 response to
25303QUIT.
25304
25305This ACL is run only for a "normal" QUIT. For certain kinds of disastrous
25306failure (for example, failure to open a log file, or when Exim is bombing out
25307because it has detected an unrecoverable error), all SMTP commands from the
25308client are given temporary error responses until QUIT is received or the
25309connection is closed. In these special cases, the QUIT ACL does not run.
25310
25311
2531242.11 The not-QUIT ACL
25313----------------------
25314
25315The not-QUIT ACL, specified by acl_smtp_notquit, is run in most cases when an
25316SMTP session ends without sending QUIT. However, when Exim itself is in bad
25317trouble, such as being unable to write to its log files, this ACL is not run,
25318because it might try to do things (such as write to log files) that make the
25319situation even worse.
25320
25321Like the QUIT ACL, this ACL is provided to make it possible to do customized
25322logging or to gather statistics, and its outcome is ignored. The delay modifier
25323is forbidden in this ACL, and the only permitted verbs are accept and warn.
25324
25325When the not-QUIT ACL is running, the variable $smtp_notquit_reason is set to a
25326string that indicates the reason for the termination of the SMTP connection.
25327The possible values are:
25328
25329 "acl-drop" Another ACL issued a drop command
25330 "bad-commands" Too many unknown or non-mail commands
25331 "command-timeout" Timeout while reading SMTP commands
25332 "connection-lost" The SMTP connection has been lost
25333 "data-timeout" Timeout while reading message data
25334 "local-scan-error" The local_scan() function crashed
25335 "local-scan-timeout" The local_scan() function timed out
25336 "signal-exit" SIGTERM or SIGINT
25337 "synchronization-error" SMTP synchronization error
25338 "tls-failed" TLS failed to start
25339
25340In most cases when an SMTP connection is closed without having received QUIT,
25341Exim sends an SMTP response message before actually closing the connection.
25342With the exception of the "acl-drop" case, the default message can be
25343overridden by the message modifier in the not-QUIT ACL. In the case of a drop
25344verb in another ACL, it is the message from the other ACL that is used.
25345
25346
2534742.12 Finding an ACL to use
25348---------------------------
25349
25350The value of an acl_smtp_xxx option is expanded before use, so you can use
25351different ACLs in different circumstances. For example,
25352
25353acl_smtp_rcpt = ${if ={25}{$interface_port} \
25354 {acl_check_rcpt} {acl_check_rcpt_submit} }
25355
25356In the default configuration file there are some example settings for providing
25357an RFC 4409 message submission service on port 587 and a non-standard "smtps"
25358service on port 465. You can use a string expansion like this to choose an ACL
25359for MUAs on these ports which is more appropriate for this purpose than the
25360default ACL on port 25.
25361
25362The expanded string does not have to be the name of an ACL in the configuration
25363file; there are other possibilities. Having expanded the string, Exim searches
25364for an ACL as follows:
25365
25366 * If the string begins with a slash, Exim uses it as a file name, and reads
25367 its contents as an ACL. The lines are processed in the same way as lines in
25368 the Exim configuration file. In particular, continuation lines are
25369 supported, blank lines are ignored, as are lines whose first non-whitespace
25370 character is "#". If the file does not exist or cannot be read, an error
25371 occurs (typically causing a temporary failure of whatever caused the ACL to
25372 be run). For example:
25373
25374 acl_smtp_data = /etc/acls/\
25375 ${lookup{$sender_host_address}lsearch\
25376 {/etc/acllist}{$value}{default}}
25377
25378 This looks up an ACL file to use on the basis of the host's IP address,
25379 falling back to a default if the lookup fails. If an ACL is successfully
25380 read from a file, it is retained in memory for the duration of the Exim
25381 process, so that it can be re-used without having to re-read the file.
25382
25383 * If the string does not start with a slash, and does not contain any spaces,
25384 Exim searches the ACL section of the configuration for an ACL whose name
25385 matches the string.
25386
25387 * If no named ACL is found, or if the string contains spaces, Exim parses the
25388 string as an inline ACL. This can save typing in cases where you just want
25389 to have something like
25390
25391 acl_smtp_vrfy = accept
25392
25393 in order to allow free use of the VRFY command. Such a string may contain
25394 newlines; it is processed in the same way as an ACL that is read from a
25395 file.
25396
25397
2539842.13 ACL return codes
25399----------------------
25400
25401Except for the QUIT ACL, which does not affect the SMTP return code (see
25402section 42.10 above), the result of running an ACL is either "accept" or
25403"deny", or, if some test cannot be completed (for example, if a database is
25404down), "defer". These results cause 2xx, 5xx, and 4xx return codes,
25405respectively, to be used in the SMTP dialogue. A fourth return, "error", occurs
25406when there is an error such as invalid syntax in the ACL. This also causes a 4
25407xx return code.
25408
25409For the non-SMTP ACL, "defer" and "error" are treated in the same way as
25410"deny", because there is no mechanism for passing temporary errors to the
25411submitters of non-SMTP messages.
25412
25413ACLs that are relevant to message reception may also return "discard". This has
25414the effect of "accept", but causes either the entire message or an individual
25415recipient address to be discarded. In other words, it is a blackholing
25416facility. Use it with care.
25417
25418If the ACL for MAIL returns "discard", all recipients are discarded, and no ACL
25419is run for subsequent RCPT commands. The effect of "discard" in a RCPT ACL is
25420to discard just the one recipient address. If there are no recipients left when
25421the message's data is received, the DATA ACL is not run. A "discard" return
25422from the DATA or the non-SMTP ACL discards all the remaining recipients. The
25423"discard" return is not permitted for the acl_smtp_predata ACL.
25424
25425The local_scan() function is always run, even if there are no remaining
25426recipients; it may create new recipients.
25427
25428
2542942.14 Unset ACL options
25430-----------------------
25431
25432The default actions when any of the acl_xxx options are unset are not all the
25433same. Note: These defaults apply only when the relevant ACL is not defined at
25434all. For any defined ACL, the default action when control reaches the end of
25435the ACL statements is "deny".
25436
25437For acl_smtp_quit and acl_not_smtp_start there is no default because these two
25438are ACLs that are used only for their side effects. They cannot be used to
25439accept or reject anything.
25440
25441For acl_not_smtp, acl_smtp_auth, acl_smtp_connect, acl_smtp_data, acl_smtp_helo
25442, acl_smtp_mail, acl_smtp_mailauth, acl_smtp_mime, acl_smtp_predata, and
25443acl_smtp_starttls, the action when the ACL is not defined is "accept".
25444
25445For the others (acl_smtp_etrn, acl_smtp_expn, acl_smtp_rcpt, and acl_smtp_vrfy
25446), the action when the ACL is not defined is "deny". This means that
25447acl_smtp_rcpt must be defined in order to receive any messages over an SMTP
25448connection. For an example, see the ACL in the default configuration file.
25449
25450
2545142.15 Data for message ACLs
25452---------------------------
25453
25454When a MAIL or RCPT ACL, or either of the DATA ACLs, is running, the variables
25455that contain information about the host and the message's sender (for example,
25456$sender_host_address and $sender_address) are set, and can be used in ACL
25457statements. In the case of RCPT (but not MAIL or DATA), $domain and $local_part
25458are set from the argument address. The entire SMTP command is available in
25459$smtp_command.
25460
25461When an ACL for the AUTH parameter of MAIL is running, the variables that
25462contain information about the host are set, but $sender_address is not yet set.
25463Section 33.2 contains a discussion of this parameter and how it is used.
25464
25465The $message_size variable is set to the value of the SIZE parameter on the
25466MAIL command at MAIL, RCPT and pre-data time, or to -1 if that parameter is not
25467given. The value is updated to the true message size by the time the final DATA
25468ACL is run (after the message data has been received).
25469
25470The $rcpt_count variable increases by one for each RCPT command received. The
25471$recipients_count variable increases by one each time a RCPT command is
25472accepted, so while an ACL for RCPT is being processed, it contains the number
25473of previously accepted recipients. At DATA time (for both the DATA ACLs),
25474$rcpt_count contains the total number of RCPT commands, and $recipients_count
25475contains the total number of accepted recipients.
25476
25477
2547842.16 Data for non-message ACLs
25479-------------------------------
25480
25481When an ACL is being run for AUTH, EHLO, ETRN, EXPN, HELO, STARTTLS, or VRFY,
25482the remainder of the SMTP command line is placed in $smtp_command_argument, and
25483the entire SMTP command is available in $smtp_command. These variables can be
25484tested using a condition condition. For example, here is an ACL for use with
25485AUTH, which insists that either the session is encrypted, or the CRAM-MD5
25486authentication method is used. In other words, it does not permit
25487authentication methods that use cleartext passwords on unencrypted connections.
25488
25489acl_check_auth:
25490 accept encrypted = *
25491 accept condition = ${if eq{${uc:$smtp_command_argument}}\
25492 {CRAM-MD5}}
25493 deny message = TLS encryption or CRAM-MD5 required
25494
25495(Another way of applying this restriction is to arrange for the authenticators
25496that use cleartext passwords not to be advertised when the connection is not
25497encrypted. You can use the generic server_advertise_condition authenticator
25498option to do this.)
25499
25500
2550142.17 Format of an ACL
25502----------------------
25503
25504An individual ACL consists of a number of statements. Each statement starts
25505with a verb, optionally followed by a number of conditions and "modifiers".
25506Modifiers can change the way the verb operates, define error and log messages,
25507set variables, insert delays, and vary the processing of accepted messages.
25508
25509If all the conditions are met, the verb is obeyed. The same condition may be
25510used (with different arguments) more than once in the same statement. This
25511provides a means of specifying an "and" conjunction between conditions. For
25512example:
25513
25514deny dnslists = list1.example
25515dnslists = list2.example
25516
25517If there are no conditions, the verb is always obeyed. Exim stops evaluating
25518the conditions and modifiers when it reaches a condition that fails. What
25519happens then depends on the verb (and in one case, on a special modifier). Not
25520all the conditions make sense at every testing point. For example, you cannot
25521test a sender address in the ACL that is run for a VRFY command.
25522
25523
2552442.18 ACL verbs
25525---------------
25526
25527The ACL verbs are as follows:
25528
25529 * accept: If all the conditions are met, the ACL returns "accept". If any of
25530 the conditions are not met, what happens depends on whether endpass appears
25531 among the conditions (for syntax see below). If the failing condition is
25532 before endpass, control is passed to the next ACL statement; if it is after
25533 endpass, the ACL returns "deny". Consider this statement, used to check a
25534 RCPT command:
25535
25536 accept domains = +local_domains
25537 endpass
25538 verify = recipient
25539
25540 If the recipient domain does not match the domains condition, control
25541 passes to the next statement. If it does match, the recipient is verified,
25542 and the command is accepted if verification succeeds. However, if
25543 verification fails, the ACL yields "deny", because the failing condition is
25544 after endpass.
25545
25546 The endpass feature has turned out to be confusing to many people, so its
25547 use is not recommended nowadays. It is always possible to rewrite an ACL so
25548 that endpass is not needed, and it is no longer used in the default
25549 configuration.
25550
25551 If a message modifier appears on an accept statement, its action depends on
25552 whether or not endpass is present. In the absence of endpass (when an
25553 accept verb either accepts or passes control to the next statement),
25554 message can be used to vary the message that is sent when an SMTP command
25555 is accepted. For example, in a RCPT ACL you could have:
25556
25557 accept <some conditions>
25558 message = OK, I will allow you through today
25559
25560 You can specify an SMTP response code, optionally followed by an "extended
25561 response code" at the start of the message, but the first digit must be the
25562 same as would be sent by default, which is 2 for an accept verb.
25563
25564 If endpass is present in an accept statement, message specifies an error
25565 message that is used when access is denied. This behaviour is retained for
25566 backward compatibility, but current "best practice" is to avoid the use of
25567 endpass.
25568
25569 * defer: If all the conditions are true, the ACL returns "defer" which, in an
25570 SMTP session, causes a 4xx response to be given. For a non-SMTP ACL, defer
25571 is the same as deny, because there is no way of sending a temporary error.
25572 For a RCPT command, defer is much the same as using a redirect router and
25573 ":defer:" while verifying, but the defer verb can be used in any ACL, and
25574 even for a recipient it might be a simpler approach.
25575
25576 * deny: If all the conditions are met, the ACL returns "deny". If any of the
25577 conditions are not met, control is passed to the next ACL statement. For
25578 example,
25579
25580 deny dnslists = blackholes.mail-abuse.org
25581
25582 rejects commands from hosts that are on a DNS black list.
25583
25584 * discard: This verb behaves like accept, except that it returns "discard"
25585 from the ACL instead of "accept". It is permitted only on ACLs that are
25586 concerned with receiving messages. When all the conditions are true, the
25587 sending entity receives a "success" response. However, discard causes
25588 recipients to be discarded. If it is used in an ACL for RCPT, just the one
25589 recipient is discarded; if used for MAIL, DATA or in the non-SMTP ACL, all
25590 the message's recipients are discarded. Recipients that are discarded
25591 before DATA do not appear in the log line when the received_recipients log
25592 selector is set.
25593
25594 If the log_message modifier is set when discard operates, its contents are
25595 added to the line that is automatically written to the log. The message
25596 modifier operates exactly as it does for accept.
25597
25598 * drop: This verb behaves like deny, except that an SMTP connection is
25599 forcibly closed after the 5xx error message has been sent. For example:
25600
25601 drop message = I don't take more than 20 RCPTs
25602 condition = ${if > {$rcpt_count}{20}}
25603
25604 There is no difference between deny and drop for the connect-time ACL. The
25605 connection is always dropped after sending a 550 response.
25606
25607 * require: If all the conditions are met, control is passed to the next ACL
25608 statement. If any of the conditions are not met, the ACL returns "deny".
25609 For example, when checking a RCPT command,
25610
25611 require message = Sender did not verify
25612 verify = sender
25613
25614 passes control to subsequent statements only if the message's sender can be
25615 verified. Otherwise, it rejects the command. Note the positioning of the
25616 message modifier, before the verify condition. The reason for this is
25617 discussed in section 42.20.
25618
25619 * warn: If all the conditions are true, a line specified by the log_message
25620 modifier is written to Exim's main log. Control always passes to the next
25621 ACL statement. If any condition is false, the log line is not written. If
25622 an identical log line is requested several times in the same message, only
25623 one copy is actually written to the log. If you want to force duplicates to
25624 be written, use the logwrite modifier instead.
25625
25626 If log_message is not present, a warn verb just checks its conditions and
25627 obeys any "immediate" modifiers (such as control, set, logwrite, add_header
25628 , and remove_header) that appear before the first failing condition. There
25629 is more about adding header lines in section 42.24.
25630
25631 If any condition on a warn statement cannot be completed (that is, there is
25632 some sort of defer), the log line specified by log_message is not written.
25633 This does not include the case of a forced failure from a lookup, which is
25634 considered to be a successful completion. After a defer, no further
25635 conditions or modifiers in the warn statement are processed. The incident
25636 is logged, and the ACL continues to be processed, from the next statement
25637 onwards.
25638
25639 When one of the warn conditions is an address verification that fails, the
25640 text of the verification failure message is in $acl_verify_message. If you
25641 want this logged, you must set it up explicitly. For example:
25642
25643 warn !verify = sender
25644 log_message = sender verify failed: $acl_verify_message
25645
25646At the end of each ACL there is an implicit unconditional deny.
25647
25648As you can see from the examples above, the conditions and modifiers are
25649written one to a line, with the first one on the same line as the verb, and
25650subsequent ones on following lines. If you have a very long condition, you can
25651continue it onto several physical lines by the usual backslash continuation
25652mechanism. It is conventional to align the conditions vertically.
25653
25654
2565542.19 ACL variables
25656-------------------
25657
25658There are some special variables that can be set during ACL processing. They
25659can be used to pass information between different ACLs, different invocations
25660of the same ACL in the same SMTP connection, and between ACLs and the routers,
25661transports, and filters that are used to deliver a message. The names of these
25662variables must begin with $acl_c or $acl_m, followed either by a digit or an
25663underscore, but the remainder of the name can be any sequence of alphanumeric
25664characters and underscores that you choose. There is no limit on the number of
25665ACL variables. The two sets act as follows:
25666
25667 * The values of those variables whose names begin with $acl_c persist
25668 throughout an SMTP connection. They are never reset. Thus, a value that is
25669 set while receiving one message is still available when receiving the next
25670 message on the same SMTP connection.
25671
25672 * The values of those variables whose names begin with $acl_m persist only
25673 while a message is being received. They are reset afterwards. They are also
25674 reset by MAIL, RSET, EHLO, HELO, and after starting up a TLS session.
25675
25676When a message is accepted, the current values of all the ACL variables are
25677preserved with the message and are subsequently made available at delivery
25678time. The ACL variables are set by a modifier called set. For example:
25679
25680accept hosts = whatever
25681 set acl_m4 = some value
25682accept authenticated = *
25683 set acl_c_auth = yes
25684
25685Note: A leading dollar sign is not used when naming a variable that is to be
25686set. If you want to set a variable without taking any action, you can use a
25687warn verb without any other modifiers or conditions.
25688
25689What happens if a syntactically valid but undefined ACL variable is referenced
25690depends on the setting of the strict_acl_vars option. If it is false (the
25691default), an empty string is substituted; if it is true, an error is generated.
25692
25693Versions of Exim before 4.64 have a limited set of numbered variables, but
25694their names are compatible, so there is no problem with upgrading.
25695
25696
2569742.20 Condition and modifier processing
25698---------------------------------------
25699
25700An exclamation mark preceding a condition negates its result. For example:
25701
25702deny domains = *.dom.example
25703 !verify = recipient
25704
25705causes the ACL to return "deny" if the recipient domain ends in dom.example and
25706the recipient address cannot be verified. Sometimes negation can be used on the
25707right-hand side of a condition. For example, these two statements are
25708equivalent:
25709
25710deny hosts = !192.168.3.4
25711deny !hosts = 192.168.3.4
25712
25713However, for many conditions (verify being a good example), only left-hand side
25714negation of the whole condition is possible.
25715
25716The arguments of conditions and modifiers are expanded. A forced failure of an
25717expansion causes a condition to be ignored, that is, it behaves as if the
25718condition is true. Consider these two statements:
25719
25720accept senders = ${lookup{$host_name}lsearch\
25721 {/some/file}{$value}fail}
25722accept senders = ${lookup{$host_name}lsearch\
25723 {/some/file}{$value}{}}
25724
25725Each attempts to look up a list of acceptable senders. If the lookup succeeds,
25726the returned list is searched, but if the lookup fails the behaviour is
25727different in the two cases. The fail in the first statement causes the
25728condition to be ignored, leaving no further conditions. The accept verb
25729therefore succeeds. The second statement, however, generates an empty list when
25730the lookup fails. No sender can match an empty list, so the condition fails,
25731and therefore the accept also fails.
25732
25733ACL modifiers appear mixed in with conditions in ACL statements. Some of them
25734specify actions that are taken as the conditions for a statement are checked;
25735others specify text for messages that are used when access is denied or a
25736warning is generated. The control modifier affects the way an incoming message
25737is handled.
25738
25739The positioning of the modifiers in an ACL statement is important, because the
25740processing of a verb ceases as soon as its outcome is known. Only those
25741modifiers that have already been encountered will take effect. For example,
25742consider this use of the message modifier:
25743
25744require message = Can't verify sender
25745 verify = sender
25746 message = Can't verify recipient
25747 verify = recipient
25748 message = This message cannot be used
25749
25750If sender verification fails, Exim knows that the result of the statement is
25751"deny", so it goes no further. The first message modifier has been seen, so its
25752text is used as the error message. If sender verification succeeds, but
25753recipient verification fails, the second message is used. If recipient
25754verification succeeds, the third message becomes "current", but is never used
25755because there are no more conditions to cause failure.
25756
25757For the deny verb, on the other hand, it is always the last message modifier
25758that is used, because all the conditions must be true for rejection to happen.
25759Specifying more than one message modifier does not make sense, and the message
25760can even be specified after all the conditions. For example:
25761
25762deny hosts = ...
25763 !senders = *@my.domain.example
25764 message = Invalid sender from client host
25765
25766The "deny" result does not happen until the end of the statement is reached, by
25767which time Exim has set up the message.
25768
25769
2577042.21 ACL modifiers
25771-------------------
25772
25773The ACL modifiers are as follows:
25774
25775add_header = <text>
25776
25777 This modifier specifies one or more header lines that are to be added to an
25778 incoming message, assuming, of course, that the message is ultimately
25779 accepted. For details, see section 42.24.
25780
25781continue = <text>
25782
25783 This modifier does nothing of itself, and processing of the ACL always
25784 continues with the next condition or modifier. The value of continue is in
25785 the side effects of expanding its argument. Typically this could be used to
25786 update a database. It is really just a syntactic tidiness, to avoid having
25787 to write rather ugly lines like this:
25788
25789 condition = ${if eq{0}{<some expansion>}{true}{true}}
25790
25791 Instead, all you need is
25792
25793 continue = <some expansion>
25794
25795control = <text>
25796
25797 This modifier affects the subsequent processing of the SMTP connection or
25798 of an incoming message that is accepted. The effect of the first type of
25799 control lasts for the duration of the connection, whereas the effect of the
25800 second type lasts only until the current message has been received. The
25801 message-specific controls always apply to the whole message, not to
25802 individual recipients, even if the control modifier appears in a RCPT ACL.
25803
25804 As there are now quite a few controls that can be applied, they are
25805 described separately in section 42.22. The control modifier can be used in
25806 several different ways. For example:
25807
25808 * It can be at the end of an accept statement:
25809
25810 accept ...some conditions
25811 control = queue_only
25812
25813 In this case, the control is applied when this statement yields
25814 "accept", in other words, when the conditions are all true.
25815
25816 * It can be in the middle of an accept statement:
25817
25818 accept ...some conditions...
25819 control = queue_only
25820 ...some more conditions...
25821
25822 If the first set of conditions are true, the control is applied, even
25823 if the statement does not accept because one of the second set of
25824 conditions is false. In this case, some subsequent statement must yield
25825 "accept" for the control to be relevant.
25826
25827 * It can be used with warn to apply the control, leaving the decision
25828 about accepting or denying to a subsequent verb. For example:
25829
25830 warn ...some conditions...
25831 control = freeze
25832 accept ...
25833
25834 This example of warn does not contain message, log_message, or logwrite
25835 , so it does not add anything to the message and does not write a log
25836 entry.
25837
25838 * If you want to apply a control unconditionally, you can use it with a
25839 require verb. For example:
25840
25841 require control = no_multiline_responses
25842
25843delay = <time>
25844
25845 This modifier may appear in any ACL except notquit. It causes Exim to wait
25846 for the time interval before proceeding. However, when testing Exim using
25847 the -bh option, the delay is not actually imposed (an appropriate message
25848 is output instead). The time is given in the usual Exim notation, and the
25849 delay happens as soon as the modifier is processed. In an SMTP session,
25850 pending output is flushed before the delay is imposed.
25851
25852 Like control, delay can be used with accept or deny, for example:
25853
25854 deny ...some conditions...
25855 delay = 30s
25856
25857 The delay happens if all the conditions are true, before the statement
25858 returns "deny". Compare this with:
25859
25860 deny delay = 30s
25861 ...some conditions...
25862
25863 which waits for 30s before processing the conditions. The delay modifier
25864 can also be used with warn and together with control:
25865
25866 warn ...some conditions...
25867 delay = 2m
25868 control = freeze
25869 accept ...
25870
25871 If delay is encountered when the SMTP PIPELINING extension is in use,
25872 responses to several commands are no longer buffered and sent in one packet
25873 (as they would normally be) because all output is flushed before imposing
25874 the delay. This optimization is disabled so that a number of small delays
25875 do not appear to the client as one large aggregated delay that might
25876 provoke an unwanted timeout. You can, however, disable output flushing for
25877 delay by using a control modifier to set no_delay_flush.
25878
25879endpass
25880
25881 This modifier, which has no argument, is recognized only in accept and
25882 discard statements. It marks the boundary between the conditions whose
25883 failure causes control to pass to the next statement, and the conditions
25884 whose failure causes the ACL to return "deny". This concept has proved to
25885 be confusing to some people, so the use of endpass is no longer recommended
25886 as "best practice". See the description of accept above for more details.
25887
25888log_message = <text>
25889
25890 This modifier sets up a message that is used as part of the log message if
25891 the ACL denies access or a warn statement's conditions are true. For
25892 example:
25893
25894 require log_message = wrong cipher suite $tls_in_cipher
25895 encrypted = DES-CBC3-SHA
25896
25897 log_message is also used when recipients are discarded by discard. For
25898 example:
25899
25900 discard <some conditions>
25901 log_message = Discarded $local_part@$domain because...
25902
25903 When access is denied, log_message adds to any underlying error message
25904 that may exist because of a condition failure. For example, while verifying
25905 a recipient address, a :fail: redirection might have already set up a
25906 message.
25907
25908 The message may be defined before the conditions to which it applies,
25909 because the string expansion does not happen until Exim decides that access
25910 is to be denied. This means that any variables that are set by the
25911 condition are available for inclusion in the message. For example, the
25912 $dnslist_<xxx> variables are set after a DNS black list lookup succeeds. If
25913 the expansion of log_message fails, or if the result is an empty string,
25914 the modifier is ignored.
25915
25916 If you want to use a warn statement to log the result of an address
25917 verification, you can use $acl_verify_message to include the verification
25918 error message.
25919
25920 If log_message is used with a warn statement, "Warning:" is added to the
25921 start of the logged message. If the same warning log message is requested
25922 more than once while receiving a single email message, only one copy is
25923 actually logged. If you want to log multiple copies, use logwrite instead
25924 of log_message. In the absence of log_message and logwrite, nothing is
25925 logged for a successful warn statement.
25926
25927 If log_message is not present and there is no underlying error message (for
25928 example, from the failure of address verification), but message is present,
25929 the message text is used for logging rejections. However, if any text for
25930 logging contains newlines, only the first line is logged. In the absence of
25931 both log_message and message, a default built-in message is used for
25932 logging rejections.
25933
25934log_reject_target = <log name list>
25935
25936 This modifier makes it possible to specify which logs are used for messages
25937 about ACL rejections. Its argument is a colon-separated list of words that
25938 can be "main", "reject", or "panic". The default is "main:reject". The list
25939 may be empty, in which case a rejection is not logged at all. For example,
25940 this ACL fragment writes no logging information when access is denied:
25941
25942 deny <some conditions>
25943 log_reject_target =
25944
25945 This modifier can be used in SMTP and non-SMTP ACLs. It applies to both
25946 permanent and temporary rejections. Its effect lasts for the rest of the
25947 current ACL.
25948
25949logwrite = <text>
25950
25951 This modifier writes a message to a log file as soon as it is encountered
25952 when processing an ACL. (Compare log_message, which, except in the case of
25953 warn and discard, is used only if the ACL statement denies access.) The
25954 logwrite modifier can be used to log special incidents in ACLs. For
25955 example:
25956
25957 accept <some special conditions>
25958 control = freeze
25959 logwrite = froze message because ...
25960
25961 By default, the message is written to the main log. However, it may begin
25962 with a colon, followed by a comma-separated list of log names, and then
25963 another colon, to specify exactly which logs are to be written. For
25964 example:
25965
25966 logwrite = :main,reject: text for main and reject logs
25967 logwrite = :panic: text for panic log only
25968
25969message = <text>
25970
25971 This modifier sets up a text string that is expanded and used as a response
25972 message when an ACL statement terminates the ACL with an "accept", "deny",
25973 or "defer" response. (In the case of the accept and discard verbs, there is
25974 some complication if endpass is involved; see the description of accept for
25975 details.)
25976
25977 The expansion of the message happens at the time Exim decides that the ACL
25978 is to end, not at the time it processes message. If the expansion fails, or
25979 generates an empty string, the modifier is ignored. Here is an example
25980 where message must be specified first, because the ACL ends with a
25981 rejection if the hosts condition fails:
25982
25983 require message = Host not recognized
25984 hosts = 10.0.0.0/8
25985
25986 (Once a condition has failed, no further conditions or modifiers are
25987 processed.)
25988
25989 For ACLs that are triggered by SMTP commands, the message is returned as
25990 part of the SMTP response. The use of message with accept (or discard) is
25991 meaningful only for SMTP, as no message is returned when a non-SMTP message
25992 is accepted. In the case of the connect ACL, accepting with a message
25993 modifier overrides the value of smtp_banner. For the EHLO/HELO ACL, a
25994 customized accept message may not contain more than one line (otherwise it
25995 will be truncated at the first newline and a panic logged), and it cannot
25996 affect the EHLO options.
25997
25998 When SMTP is involved, the message may begin with an overriding response
25999 code, consisting of three digits optionally followed by an "extended
26000 response code" of the form n.n.n, each code being followed by a space. For
26001 example:
26002
26003 deny message = 599 1.2.3 Host not welcome
26004 hosts = 192.168.34.0/24
26005
26006 The first digit of the supplied response code must be the same as would be
26007 sent by default. A panic occurs if it is not. Exim uses a 550 code when it
26008 denies access, but for the predata ACL, note that the default success code
26009 is 354, not 2xx.
26010
26011 Notwithstanding the previous paragraph, for the QUIT ACL, unlike the
26012 others, the message modifier cannot override the 221 response code.
26013
26014 The text in a message modifier is literal; any quotes are taken as
26015 literals, but because the string is expanded, backslash escapes are
26016 processed anyway. If the message contains newlines, this gives rise to a
26017 multi-line SMTP response.
26018
26019 If message is used on a statement that verifies an address, the message
26020 specified overrides any message that is generated by the verification
26021 process. However, the original message is available in the variable
26022 $acl_verify_message, so you can incorporate it into your message if you
26023 wish. In particular, if you want the text from :fail: items in redirect
26024 routers to be passed back as part of the SMTP response, you should either
26025 not use a message modifier, or make use of $acl_verify_message.
26026
26027 For compatibility with previous releases of Exim, a message modifier that
26028 is used with a warn verb behaves in a similar way to the add_header
26029 modifier, but this usage is now deprecated. However, message acts only when
26030 all the conditions are true, wherever it appears in an ACL command, whereas
26031 add_header acts as soon as it is encountered. If message is used with warn
26032 in an ACL that is not concerned with receiving a message, it has no effect.
26033
26034remove_header = <text>
26035
26036 This modifier specifies one or more header names in a colon-separated list
26037 that are to be removed from an incoming message, assuming, of course, that
26038 the message is ultimately accepted. For details, see section 42.25.
26039
26040set <acl_name> = <value>
26041
26042 This modifier puts a value into one of the ACL variables (see section 42.19
26043 ).
26044
26045udpsend = <parameters>
26046
26047 This modifier sends a UDP packet, for purposes such as statistics
26048 collection or behaviour monitoring. The parameters are expanded, and the
26049 result of the expansion must be a colon-separated list consisting of a
26050 destination server, port number, and the packet contents. The server can be
26051 specified as a host name or IPv4 or IPv6 address. The separator can be
26052 changed with the usual angle bracket syntax. For example, you might want to
26053 collect information on which hosts connect when:
26054
26055 udpsend = <; 2001:dB8::dead:beef ; 1234 ;\
26056 $tod_zulu $sender_host_address
26057
26058
2605942.22 Use of the control modifier
26060---------------------------------
26061
26062The control modifier supports the following settings:
26063
26064control = allow_auth_unadvertised
26065
26066 This modifier allows a client host to use the SMTP AUTH command even when
26067 it has not been advertised in response to EHLO. Furthermore, because there
26068 are apparently some really broken clients that do this, Exim will accept
26069 AUTH after HELO (rather than EHLO) when this control is set. It should be
26070 used only if you really need it, and you should limit its use to those
26071 broken clients that do not work without it. For example:
26072
26073 warn hosts = 192.168.34.25
26074 control = allow_auth_unadvertised
26075
26076 Normally, when an Exim server receives an AUTH command, it checks the name
26077 of the authentication mechanism that is given in the command to ensure that
26078 it matches an advertised mechanism. When this control is set, the check
26079 that a mechanism has been advertised is bypassed. Any configured mechanism
26080 can be used by the client. This control is permitted only in the connection
26081 and HELO ACLs.
26082
26083control = caseful_local_part, control = caselower_local_part
26084
26085 These two controls are permitted only in the ACL specified by acl_smtp_rcpt
26086 (that is, during RCPT processing). By default, the contents of $local_part
26087 are lower cased before ACL processing. If "caseful_local_part" is
26088 specified, any uppercase letters in the original local part are restored in
26089 $local_part for the rest of the ACL, or until a control that sets
26090 "caselower_local_part" is encountered.
26091
26092 These controls affect only the current recipient. Moreover, they apply only
26093 to local part handling that takes place directly in the ACL (for example,
26094 as a key in lookups). If a test to verify the recipient is obeyed, the
26095 case-related handling of the local part during the verification is
26096 controlled by the router configuration (see the caseful_local_part generic
26097 router option).
26098
26099 This facility could be used, for example, to add a spam score to local
26100 parts containing upper case letters. For example, using $acl_m4 to
26101 accumulate the spam score:
26102
26103 warn control = caseful_local_part
26104 set acl_m4 = ${eval:\
26105 $acl_m4 + \
26106 ${if match{$local_part}{[A-Z]}{1}{0}}\
26107 }
26108 control = caselower_local_part
26109
26110 Notice that we put back the lower cased version afterwards, assuming that
26111 is what is wanted for subsequent tests.
26112
26113control = cutthrough_delivery
26114
26115 This option requests delivery be attempted while the item is being
26116 received. It is usable in the RCPT ACL and valid only for single-recipient
26117 mails forwarded from one SMTP connection to another. If a recipient-verify
26118 callout connection is requested in the same ACL it is held open and used
26119 for the data, otherwise one is made after the ACL completes.
26120
26121 Note that routers are used in verify mode, and cannot depend on content of
26122 received headers. Note also that headers cannot be modified by any of the
26123 post-data ACLs (DATA, MIME and DKIM). Headers may be modified by routers
26124 (subject to the above) and transports.
26125
26126 Cutthrough delivery is not supported via transport-filters or when DKIM
26127 signing of outgoing messages is done, because it sends data to the ultimate
26128 destination before the entire message has been received from the source.
26129
26130 Should the ultimate destination system positively accept or reject the
26131 mail, a corresponding indication is given to the source system and nothing
26132 is queued. If there is a temporary error the item is queued for later
26133 delivery in the usual fashion. If the item is successfully delivered in
26134 cutthrough mode the log line is tagged with ">>" rather than "=>" and
26135 appears before the acceptance "<=" line.
26136
26137 Delivery in this mode avoids the generation of a bounce mail to a (possibly
26138 faked) sender when the destination system is doing content-scan based
26139 rejection.
26140
26141control = debug/<options>
26142
26143 This control turns on debug logging, almost as though Exim had been invoked
26144 with "-d", with the output going to a new logfile, by default called
26145 debuglog. The filename can be adjusted with the tag option, which may
26146 access any variables already defined. The logging may be adjusted with the
26147 opts option, which takes the same values as the "-d" command-line option.
26148 Some examples (which depend on variables that don't exist in all contexts):
26149
26150 control = debug
26151 control = debug/tag=.$sender_host_address
26152 control = debug/opts=+expand+acl
26153 control = debug/tag=.$message_exim_id/opts=+expand
26154
26155control = dkim_disable_verify
26156
26157 This control turns off DKIM verification processing entirely. For details
26158 on the operation and configuration of DKIM, see chapter 56.
26159
26160control = dscp/<value>
26161
26162 This option causes the DSCP value associated with the socket for the
26163 inbound connection to be adjusted to a given value, given as one of a
26164 number of fixed strings or to numeric value. The -bI:dscp option may be
26165 used to ask Exim which names it knows of. Common values include
26166 "throughput", "mincost", and on newer systems "ef", "af41", etc. Numeric
26167 values may be in the range 0 to 0x3F.
26168
26169 The outbound packets from Exim will be marked with this value in the header
26170 (for IPv4, the TOS field; for IPv6, the TCLASS field); there is no
26171 guarantee that these values will have any effect, not be stripped by
26172 networking equipment, or do much of anything without cooperation with your
26173 Network Engineer and those of all network operators between the source and
26174 destination.
26175
26176control = enforce_sync, control = no_enforce_sync
26177
26178 These controls make it possible to be selective about when SMTP
26179 synchronization is enforced. The global option smtp_enforce_sync specifies
26180 the initial state of the switch (it is true by default). See the
26181 description of this option in chapter 14 for details of SMTP
26182 synchronization checking.
26183
26184 The effect of these two controls lasts for the remainder of the SMTP
26185 connection. They can appear in any ACL except the one for the non-SMTP
26186 messages. The most straightforward place to put them is in the ACL defined
26187 by acl_smtp_connect, which is run at the start of an incoming SMTP
26188 connection, before the first synchronization check. The expected use is to
26189 turn off the synchronization checks for badly-behaved hosts that you
26190 nevertheless need to work with.
26191
26192control = fakedefer/<message>
26193
26194 This control works in exactly the same way as fakereject (described below)
26195 except that it causes an SMTP 450 response after the message data instead
26196 of a 550 response. You must take care when using fakedefer because it
26197 causes the messages to be duplicated when the sender retries. Therefore,
26198 you should not use fakedefer if the message is to be delivered normally.
26199
26200control = fakereject/<message>
26201
26202 This control is permitted only for the MAIL, RCPT, and DATA ACLs, in other
26203 words, only when an SMTP message is being received. If Exim accepts the
26204 message, instead the final 250 response, a 550 rejection message is sent.
26205 However, Exim proceeds to deliver the message as normal. The control
26206 applies only to the current message, not to any subsequent ones that may be
26207 received in the same SMTP connection.
26208
26209 The text for the 550 response is taken from the control modifier. If no
26210 message is supplied, the following is used:
26211
26212 550-Your message has been rejected but is being
26213 550-kept for evaluation.
26214 550-If it was a legitimate message, it may still be
26215 550 delivered to the target recipient(s).
26216
26217 This facility should be used with extreme caution.
26218
26219control = freeze
26220
26221 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs,
26222 in other words, only when a message is being received. If the message is
26223 accepted, it is placed on Exim's queue and frozen. The control applies only
26224 to the current message, not to any subsequent ones that may be received in
26225 the same SMTP connection.
26226
26227 This modifier can optionally be followed by "/no_tell". If the global
26228 option freeze_tell is set, it is ignored for the current message (that is,
26229 nobody is told about the freezing), provided all the control=freeze
26230 modifiers that are obeyed for the current message have the "/no_tell"
26231 option.
26232
26233control = no_delay_flush
26234
26235 Exim normally flushes SMTP output before implementing a delay in an ACL, to
26236 avoid unexpected timeouts in clients when the SMTP PIPELINING extension is
26237 in use. This control, as long as it is encountered before the delay
26238 modifier, disables such output flushing.
26239
26240control = no_callout_flush
26241
26242 Exim normally flushes SMTP output before performing a callout in an ACL, to
26243 avoid unexpected timeouts in clients when the SMTP PIPELINING extension is
26244 in use. This control, as long as it is encountered before the verify
26245 condition that causes the callout, disables such output flushing.
26246
26247control = no_mbox_unspool
26248
26249 This control is available when Exim is compiled with the content scanning
26250 extension. Content scanning may require a copy of the current message, or
26251 parts of it, to be written in "mbox format" to a spool file, for passing to
26252 a virus or spam scanner. Normally, such copies are deleted when they are no
26253 longer needed. If this control is set, the copies are not deleted. The
26254 control applies only to the current message, not to any subsequent ones
26255 that may be received in the same SMTP connection. It is provided for
26256 debugging purposes and is unlikely to be useful in production.
26257
26258control = no_multiline_responses
26259
26260 This control is permitted for any ACL except the one for non-SMTP messages.
26261 It seems that there are broken clients in use that cannot handle multiline
26262 SMTP responses, despite the fact that RFC 821 defined them over 20 years
26263 ago.
26264
26265 If this control is set, multiline SMTP responses from ACL rejections are
26266 suppressed. One way of doing this would have been to put out these
26267 responses as one long line. However, RFC 2821 specifies a maximum of 512
26268 bytes per response ("use multiline responses for more" it says - ha!), and
26269 some of the responses might get close to that. So this facility, which is
26270 after all only a sop to broken clients, is implemented by doing two very
26271 easy things:
26272
26273 * Extra information that is normally output as part of a rejection caused
26274 by sender verification failure is omitted. Only the final line
26275 (typically "sender verification failed") is sent.
26276
26277 * If a message modifier supplies a multiline response, only the first
26278 line is output.
26279
26280 The setting of the switch can, of course, be made conditional on the
26281 calling host. Its effect lasts until the end of the SMTP connection.
26282
26283control = no_pipelining
26284
26285 This control turns off the advertising of the PIPELINING extension to SMTP
26286 in the current session. To be useful, it must be obeyed before Exim sends
26287 its response to an EHLO command. Therefore, it should normally appear in an
26288 ACL controlled by acl_smtp_connect or acl_smtp_helo. See also
26289 pipelining_advertise_hosts.
26290
26291control = queue_only
26292
26293 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs,
26294 in other words, only when a message is being received. If the message is
26295 accepted, it is placed on Exim's queue and left there for delivery by a
26296 subsequent queue runner. No immediate delivery process is started. In other
26297 words, it has the effect as the queue_only global option. However, the
26298 control applies only to the current message, not to any subsequent ones
26299 that may be received in the same SMTP connection.
26300
26301control = submission/<options>
26302
26303 This control is permitted only for the MAIL, RCPT, and start of data ACLs
26304 (the latter is the one defined by acl_smtp_predata). Setting it tells Exim
26305 that the current message is a submission from a local MUA. In this case,
26306 Exim operates in "submission mode", and applies certain fixups to the
26307 message if necessary. For example, it adds a Date: header line if one is
26308 not present. This control is not permitted in the acl_smtp_data ACL,
26309 because that is too late (the message has already been created).
26310
26311 Chapter 46 describes the processing that Exim applies to messages. Section
26312 46.1 covers the processing that happens in submission mode; the available
26313 options for this control are described there. The control applies only to
26314 the current message, not to any subsequent ones that may be received in the
26315 same SMTP connection.
26316
26317control = suppress_local_fixups
26318
26319 This control applies to locally submitted (non TCP/IP) messages, and is the
26320 complement of "control = submission". It disables the fixups that are
26321 normally applied to locally-submitted messages. Specifically:
26322
26323 * Any Sender: header line is left alone (in this respect, it is a dynamic
26324 version of local_sender_retain).
26325
26326 * No Message-ID:, From:, or Date: header lines are added.
26327
26328 * There is no check that From: corresponds to the actual sender.
26329
26330 This control may be useful when a remotely-originated message is accepted,
26331 passed to some scanning program, and then re-submitted for delivery. It can
26332 be used only in the acl_smtp_mail, acl_smtp_rcpt, acl_smtp_predata, and
26333 acl_not_smtp_start ACLs, because it has to be set before the message's data
26334 is read.
26335
26336 Note: This control applies only to the current message, not to any others
26337 that are being submitted at the same time using -bs or -bS.
26338
26339
2634042.23 Summary of message fixup control
26341--------------------------------------
26342
26343All four possibilities for message fixups can be specified:
26344
26345 * Locally submitted, fixups applied: the default.
26346
26347 * Locally submitted, no fixups applied: use "control =
26348 suppress_local_fixups".
26349
26350 * Remotely submitted, no fixups applied: the default.
26351
26352 * Remotely submitted, fixups applied: use "control = submission".
26353
26354
2635542.24 Adding header lines in ACLs
26356---------------------------------
26357
26358The add_header modifier can be used to add one or more extra header lines to an
26359incoming message, as in this example:
26360
26361warn dnslists = sbl.spamhaus.org : \
26362 dialup.mail-abuse.org
26363 add_header = X-blacklisted-at: $dnslist_domain
26364
26365The add_header modifier is permitted in the MAIL, RCPT, PREDATA, DATA, MIME,
26366DKIM, and non-SMTP ACLs (in other words, those that are concerned with
26367receiving a message). The message must ultimately be accepted for add_header to
26368have any significant effect. You can use add_header with any ACL verb,
26369including deny (though this is potentially useful only in a RCPT ACL).
26370
26371Headers will not be added to the message if the modifier is used in DATA, MIME
26372or DKIM ACLs for messages delivered by cutthrough routing.
26373
26374Leading and trailing newlines are removed from the data for the add_header
26375modifier; if it then contains one or more newlines that are not followed by a
26376space or a tab, it is assumed to contain multiple header lines. Each one is
26377checked for valid syntax; "X-ACL-Warn:" is added to the front of any line that
26378is not a valid header line.
26379
26380Added header lines are accumulated during the MAIL, RCPT, and predata ACLs.
26381They are added to the message before processing the DATA and MIME ACLs.
26382However, if an identical header line is requested more than once, only one copy
26383is actually added to the message. Further header lines may be accumulated
26384during the DATA and MIME ACLs, after which they are added to the message, again
26385with duplicates suppressed. Thus, it is possible to add two identical header
26386lines to an SMTP message, but only if one is added before DATA and one after.
26387In the case of non-SMTP messages, new headers are accumulated during the
26388non-SMTP ACLs, and are added to the message after all the ACLs have run. If a
26389message is rejected after DATA or by the non-SMTP ACL, all added header lines
26390are included in the entry that is written to the reject log.
26391
26392Header lines are not visible in string expansions of message headers until they
26393are added to the message. It follows that header lines defined in the MAIL,
26394RCPT, and predata ACLs are not visible until the DATA ACL and MIME ACLs are
26395run. Similarly, header lines that are added by the DATA or MIME ACLs are not
26396visible in those ACLs. Because of this restriction, you cannot use header lines
26397as a way of passing data between (for example) the MAIL and RCPT ACLs. If you
26398want to do this, you can use ACL variables, as described in section 42.19.
26399
26400The list of headers yet to be added is given by the $headers_added variable.
26401
26402The add_header modifier acts immediately as it is encountered during the
26403processing of an ACL. Notice the difference between these two cases:
26404
26405accept add_header = ADDED: some text
26406 <some condition>
26407
26408accept <some condition>
26409 add_header = ADDED: some text
26410
26411In the first case, the header line is always added, whether or not the
26412condition is true. In the second case, the header line is added only if the
26413condition is true. Multiple occurrences of add_header may occur in the same ACL
26414statement. All those that are encountered before a condition fails are
26415honoured.
26416
26417For compatibility with previous versions of Exim, a message modifier for a warn
26418verb acts in the same way as add_header, except that it takes effect only if
26419all the conditions are true, even if it appears before some of them.
26420Furthermore, only the last occurrence of message is honoured. This usage of
26421message is now deprecated. If both add_header and message are present on a warn
26422verb, both are processed according to their specifications.
26423
26424By default, new header lines are added to a message at the end of the existing
26425header lines. However, you can specify that any particular header line should
26426be added right at the start (before all the Received: lines), immediately after
26427the first block of Received: lines, or immediately before any line that is not
26428a Received: or Resent-something: header.
26429
26430This is done by specifying ":at_start:", ":after_received:", or
26431":at_start_rfc:" (or, for completeness, ":at_end:") before the text of the
26432header line, respectively. (Header text cannot start with a colon, as there has
26433to be a header name first.) For example:
26434
26435warn add_header = \
26436 :after_received:X-My-Header: something or other...
26437
26438If more than one header line is supplied in a single add_header modifier, each
26439one is treated independently and can therefore be placed differently. If you
26440add more than one line at the start, or after the Received: block, they end up
26441in reverse order.
26442
26443Warning: This facility currently applies only to header lines that are added in
26444an ACL. It does NOT work for header lines that are added in a system filter or
26445in a router or transport.
26446
26447
2644842.25 Removing header lines in ACLs
26449-----------------------------------
26450
26451The remove_header modifier can be used to remove one or more header lines from
26452an incoming message, as in this example:
26453
26454warn message = Remove internal headers
26455 remove_header = x-route-mail1 : x-route-mail2
26456
26457The remove_header modifier is permitted in the MAIL, RCPT, PREDATA, DATA, MIME,
26458DKIM, and non-SMTP ACLs (in other words, those that are concerned with
26459receiving a message). The message must ultimately be accepted for remove_header
26460to have any significant effect. You can use remove_header with any ACL verb,
26461including deny, though this is really not useful for any verb that doesn't
26462result in a delivered message.
26463
26464Headers will not be removed to the message if the modifier is used in DATA,
26465MIME or DKIM ACLs for messages delivered by cutthrough routing.
26466
26467More than one header can be removed at the same time by using a colon separated
26468list of header names. The header matching is case insensitive. Wildcards are
26469not permitted, nor is list expansion performed, so you cannot use hostlists to
26470create a list of headers, however both connection and message variable
26471expansion are performed ($acl_c_* and $acl_m_*), illustrated in this example:
26472
26473warn hosts = +internal_hosts
26474 set acl_c_ihdrs = x-route-mail1 : x-route-mail2
26475warn message = Remove internal headers
26476 remove_header = $acl_c_ihdrs
26477
26478Removed header lines are accumulated during the MAIL, RCPT, and predata ACLs.
26479They are removed from the message before processing the DATA and MIME ACLs.
26480There is no harm in attempting to remove the same header twice nor is removing
26481a non-existent header. Further header lines to be removed may be accumulated
26482during the DATA and MIME ACLs, after which they are removed from the message,
26483if present. In the case of non-SMTP messages, headers to be removed are
26484accumulated during the non-SMTP ACLs, and are removed from the message after
26485all the ACLs have run. If a message is rejected after DATA or by the non-SMTP
26486ACL, there really is no effect because there is no logging of what headers
26487would have been removed.
26488
26489Header lines are not visible in string expansions until the DATA phase when it
26490is received. Any header lines removed in the MAIL, RCPT, and predata ACLs are
26491not visible in the DATA ACL and MIME ACLs. Similarly, header lines that are
26492removed by the DATA or MIME ACLs are still visible in those ACLs. Because of
26493this restriction, you cannot use header lines as a way of controlling data
26494passed between (for example) the MAIL and RCPT ACLs. If you want to do this,
26495you should instead use ACL variables, as described in section 42.19.
26496
26497The remove_header modifier acts immediately as it is encountered during the
26498processing of an ACL. Notice the difference between these two cases:
26499
26500accept remove_header = X-Internal
26501 <some condition>
26502
26503accept <some condition>
26504 remove_header = X-Internal
26505
26506In the first case, the header line is always removed, whether or not the
26507condition is true. In the second case, the header line is removed only if the
26508condition is true. Multiple occurrences of remove_header may occur in the same
26509ACL statement. All those that are encountered before a condition fails are
26510honoured.
26511
26512Warning: This facility currently applies only to header lines that are present
26513during ACL processing. It does NOT remove header lines that are added in a
26514system filter or in a router or transport.
26515
26516
2651742.26 ACL conditions
26518--------------------
26519
26520Some of the conditions listed in this section are available only when Exim is
26521compiled with the content-scanning extension. They are included here briefly
26522for completeness. More detailed descriptions can be found in the discussion on
26523content scanning in chapter 43.
26524
26525Not all conditions are relevant in all circumstances. For example, testing
26526senders and recipients does not make sense in an ACL that is being run as the
26527result of the arrival of an ETRN command, and checks on message headers can be
26528done only in the ACLs specified by acl_smtp_data and acl_not_smtp. You can use
26529the same condition (with different parameters) more than once in the same ACL
26530statement. This provides a way of specifying an "and" conjunction. The
26531conditions are as follows:
26532
26533acl = <name of acl or ACL string or file name >
26534
26535 The possible values of the argument are the same as for the acl_smtp_xxx
26536 options. The named or inline ACL is run. If it returns "accept" the
26537 condition is true; if it returns "deny" the condition is false. If it
26538 returns "defer", the current ACL returns "defer" unless the condition is on
26539 a warn verb. In that case, a "defer" return makes the condition false. This
26540 means that further processing of the warn verb ceases, but processing of
26541 the ACL continues.
26542
26543 If the argument is a named ACL, up to nine space-separated optional values
26544 can be appended; they appear within the called ACL in $acl_arg1 to
26545 $acl_arg9, and $acl_narg is set to the count of values. Previous values of
26546 these variables are restored after the call returns. The name and values
26547 are expanded separately.
26548
26549 If the nested acl returns "drop" and the outer condition denies access, the
26550 connection is dropped. If it returns "discard", the verb must be accept or
26551 discard, and the action is taken immediately - no further conditions are
26552 tested.
26553
26554 ACLs may be nested up to 20 deep; the limit exists purely to catch runaway
26555 loops. This condition allows you to use different ACLs in different
26556 circumstances. For example, different ACLs can be used to handle RCPT
26557 commands for different local users or different local domains.
26558
26559authenticated = <string list>
26560
26561 If the SMTP connection is not authenticated, the condition is false.
26562 Otherwise, the name of the authenticator is tested against the list. To
26563 test for authentication by any authenticator, you can set
26564
26565 authenticated = *
26566
26567condition = <string>
26568
26569 This feature allows you to make up custom conditions. If the result of
26570 expanding the string is an empty string, the number zero, or one of the
26571 strings "no" or "false", the condition is false. If the result is any
26572 non-zero number, or one of the strings "yes" or "true", the condition is
26573 true. For any other value, some error is assumed to have occurred, and the
26574 ACL returns "defer". However, if the expansion is forced to fail, the
26575 condition is ignored. The effect is to treat it as true, whether it is
26576 positive or negative.
26577
26578decode = <location>
26579
26580 This condition is available only when Exim is compiled with the
26581 content-scanning extension, and it is allowed only in the ACL defined by
26582 acl_smtp_mime. It causes the current MIME part to be decoded into a file.
26583 If all goes well, the condition is true. It is false only if there are
26584 problems such as a syntax error or a memory shortage. For more details, see
26585 chapter 43.
26586
26587demime = <extension list>
26588
26589 This condition is available only when Exim is compiled with the
26590 content-scanning extension. Its use is described in section 43.6.
26591
26592dnslists = <list of domain names and other data>
26593
26594 This condition checks for entries in DNS black lists. These are also known
26595 as "RBL lists", after the original Realtime Blackhole List, but note that
26596 the use of the lists at mail-abuse.org now carries a charge. There are too
26597 many different variants of this condition to describe briefly here. See
26598 sections 42.27-42.37 for details.
26599
26600domains = <domain list>
26601
26602 This condition is relevant only after a RCPT command. It checks that the
26603 domain of the recipient address is in the domain list. If percent-hack
26604 processing is enabled, it is done before this test is done. If the check
26605 succeeds with a lookup, the result of the lookup is placed in $domain_data
26606 until the next domains test.
26607
26608 Note carefully (because many people seem to fall foul of this): you cannot
26609 use domains in a DATA ACL.
26610
26611encrypted = <string list>
26612
26613 If the SMTP connection is not encrypted, the condition is false. Otherwise,
26614 the name of the cipher suite in use is tested against the list. To test for
26615 encryption without testing for any specific cipher suite(s), set
26616
26617 encrypted = *
26618
26619hosts = <host list>
26620
26621 This condition tests that the calling host matches the host list. If you
26622 have name lookups or wildcarded host names and IP addresses in the same
26623 host list, you should normally put the IP addresses first. For example, you
26624 could have:
26625
26626 accept hosts = 10.9.8.7 : dbm;/etc/friendly/hosts
26627
26628 The lookup in this example uses the host name for its key. This is implied
26629 by the lookup type "dbm". (For a host address lookup you would use
26630 "net-dbm" and it wouldn't matter which way round you had these two items.)
26631
26632 The reason for the problem with host names lies in the left-to-right way
26633 that Exim processes lists. It can test IP addresses without doing any DNS
26634 lookups, but when it reaches an item that requires a host name, it fails if
26635 it cannot find a host name to compare with the pattern. If the above list
26636 is given in the opposite order, the accept statement fails for a host whose
26637 name cannot be found, even if its IP address is 10.9.8.7.
26638
26639 If you really do want to do the name check first, and still recognize the
26640 IP address even if the name lookup fails, you can rewrite the ACL like
26641 this:
26642
26643 accept hosts = dbm;/etc/friendly/hosts
26644 accept hosts = 10.9.8.7
26645
26646 The default action on failing to find the host name is to assume that the
26647 host is not in the list, so the first accept statement fails. The second
26648 statement can then check the IP address.
26649
26650 If a hosts condition is satisfied by means of a lookup, the result of the
26651 lookup is made available in the $host_data variable. This allows you, for
26652 example, to set up a statement like this:
26653
26654 deny hosts = net-lsearch;/some/file
26655 message = $host_data
26656
26657 which gives a custom error message for each denied host.
26658
26659local_parts = <local part list>
26660
26661 This condition is relevant only after a RCPT command. It checks that the
26662 local part of the recipient address is in the list. If percent-hack
26663 processing is enabled, it is done before this test. If the check succeeds
26664 with a lookup, the result of the lookup is placed in $local_part_data,
26665 which remains set until the next local_parts test.
26666
26667malware = <option>
26668
26669 This condition is available only when Exim is compiled with the
26670 content-scanning extension. It causes the incoming message to be scanned
26671 for viruses. For details, see chapter 43.
26672
26673mime_regex = <list of regular expressions>
26674
26675 This condition is available only when Exim is compiled with the
26676 content-scanning extension, and it is allowed only in the ACL defined by
26677 acl_smtp_mime. It causes the current MIME part to be scanned for a match
26678 with any of the regular expressions. For details, see chapter 43.
26679
26680ratelimit = <parameters>
26681
26682 This condition can be used to limit the rate at which a user or host
26683 submits messages. Details are given in section 42.38.
26684
26685recipients = <address list>
26686
26687 This condition is relevant only after a RCPT command. It checks the entire
26688 recipient address against a list of recipients.
26689
26690regex = <list of regular expressions>
26691
26692 This condition is available only when Exim is compiled with the
26693 content-scanning extension, and is available only in the DATA, MIME, and
26694 non-SMTP ACLs. It causes the incoming message to be scanned for a match
26695 with any of the regular expressions. For details, see chapter 43.
26696
26697sender_domains = <domain list>
26698
26699 This condition tests the domain of the sender of the message against the
26700 given domain list. Note: The domain of the sender address is in
26701 $sender_address_domain. It is not put in $domain during the testing of this
26702 condition. This is an exception to the general rule for testing domain
26703 lists. It is done this way so that, if this condition is used in an ACL for
26704 a RCPT command, the recipient's domain (which is in $domain) can be used to
26705 influence the sender checking.
26706
26707 Warning: It is a bad idea to use this condition on its own as a control on
26708 relaying, because sender addresses are easily, and commonly, forged.
26709
26710senders = <address list>
26711
26712 This condition tests the sender of the message against the given list. To
26713 test for a bounce message, which has an empty sender, set
26714
26715 senders = :
26716
26717 Warning: It is a bad idea to use this condition on its own as a control on
26718 relaying, because sender addresses are easily, and commonly, forged.
26719
26720spam = <username>
26721
26722 This condition is available only when Exim is compiled with the
26723 content-scanning extension. It causes the incoming message to be scanned by
26724 SpamAssassin. For details, see chapter 43.
26725
26726verify = certificate
26727
26728 This condition is true in an SMTP session if the session is encrypted, and
26729 a certificate was received from the client, and the certificate was
26730 verified. The server requests a certificate only if the client matches
26731 tls_verify_hosts or tls_try_verify_hosts (see chapter 41).
26732
26733verify = csa
26734
26735 This condition checks whether the sending host (the client) is authorized
26736 to send email. Details of how this works are given in section 42.50.
26737
26738verify = header_names_ascii
26739
26740 This condition is relevant only in an ACL that is run after a message has
26741 been received, that is, in an ACL specified by acl_smtp_data or
26742 acl_not_smtp. It checks all header names (not the content) to make sure
26743 there are no non-ASCII characters, also excluding control characters. The
26744 allowable characters are decimal ASCII values 33 through 126.
26745
26746 Exim itself will handle headers with non-ASCII characters, but it can cause
26747 problems for downstream applications, so this option will allow their
26748 detection and rejection in the DATA ACL's.
26749
26750verify = header_sender/<options>
26751
26752 This condition is relevant only in an ACL that is run after a message has
26753 been received, that is, in an ACL specified by acl_smtp_data or
26754 acl_not_smtp. It checks that there is a verifiable address in at least one
26755 of the Sender:, Reply-To:, or From: header lines. Such an address is
26756 loosely thought of as a "sender" address (hence the name of the test).
26757 However, an address that appears in one of these headers need not be an
26758 address that accepts bounce messages; only sender addresses in envelopes
26759 are required to accept bounces. Therefore, if you use the callout option on
26760 this check, you might want to arrange for a non-empty address in the MAIL
26761 command.
26762
26763 Details of address verification and the options are given later, starting
26764 at section 42.44 (callouts are described in section 42.45). You can combine
26765 this condition with the senders condition to restrict it to bounce messages
26766 only:
26767
26768 deny senders = :
26769 message = A valid sender header is required for bounces
26770 !verify = header_sender
26771
26772verify = header_syntax
26773
26774 This condition is relevant only in an ACL that is run after a message has
26775 been received, that is, in an ACL specified by acl_smtp_data or
26776 acl_not_smtp. It checks the syntax of all header lines that can contain
26777 lists of addresses (Sender:, From:, Reply-To:, To:, Cc:, and Bcc:).
26778 Unqualified addresses (local parts without domains) are permitted only in
26779 locally generated messages and from hosts that match
26780 sender_unqualified_hosts or recipient_unqualified_hosts, as appropriate.
26781
26782 Note that this condition is a syntax check only. However, a common spamming
26783 ploy used to be to send syntactically invalid headers such as
26784
26785 To: @
26786
26787 and this condition can be used to reject such messages, though they are not
26788 as common as they used to be.
26789
26790verify = helo
26791
26792 This condition is true if a HELO or EHLO command has been received from the
26793 client host, and its contents have been verified. If there has been no
26794 previous attempt to verify the HELO/EHLO contents, it is carried out when
26795 this condition is encountered. See the description of the helo_verify_hosts
26796 and helo_try_verify_hosts options for details of how to request
26797 verification independently of this condition.
26798
26799 For SMTP input that does not come over TCP/IP (the -bs command line
26800 option), this condition is always true.
26801
26802verify = not_blind
26803
26804 This condition checks that there are no blind (bcc) recipients in the
26805 message. Every envelope recipient must appear either in a To: header line
26806 or in a Cc: header line for this condition to be true. Local parts are
26807 checked case-sensitively; domains are checked case-insensitively. If
26808 Resent-To: or Resent-Cc: header lines exist, they are also checked. This
26809 condition can be used only in a DATA or non-SMTP ACL.
26810
26811 There are, of course, many legitimate messages that make use of blind (bcc)
26812 recipients. This check should not be used on its own for blocking messages.
26813
26814verify = recipient/<options>
26815
26816 This condition is relevant only after a RCPT command. It verifies the
26817 current recipient. Details of address verification are given later,
26818 starting at section 42.44. After a recipient has been verified, the value
26819 of $address_data is the last value that was set while routing the address.
26820 This applies even if the verification fails. When an address that is being
26821 verified is redirected to a single address, verification continues with the
26822 new address, and in that case, the subsequent value of $address_data is the
26823 value for the child address.
26824
26825verify = reverse_host_lookup
26826
26827 This condition ensures that a verified host name has been looked up from
26828 the IP address of the client host. (This may have happened already if the
26829 host name was needed for checking a host list, or if the host matched
26830 host_lookup.) Verification ensures that the host name obtained from a
26831 reverse DNS lookup, or one of its aliases, does, when it is itself looked
26832 up in the DNS, yield the original IP address.
26833
26834 If this condition is used for a locally generated message (that is, when
26835 there is no client host involved), it always succeeds.
26836
26837verify = sender/<options>
26838
26839 This condition is relevant only after a MAIL or RCPT command, or after a
26840 message has been received (the acl_smtp_data or acl_not_smtp ACLs). If the
26841 message's sender is empty (that is, this is a bounce message), the
26842 condition is true. Otherwise, the sender address is verified.
26843
26844 If there is data in the $address_data variable at the end of routing, its
26845 value is placed in $sender_address_data at the end of verification. This
26846 value can be used in subsequent conditions and modifiers in the same ACL
26847 statement. It does not persist after the end of the current statement. If
26848 you want to preserve the value for longer, you can save it in an ACL
26849 variable.
26850
26851 Details of verification are given later, starting at section 42.44. Exim
26852 caches the result of sender verification, to avoid doing it more than once
26853 per message.
26854
26855verify = sender=<address>/<options>
26856
26857 This is a variation of the previous option, in which a modified address is
26858 verified as a sender.
26859
26860
2686142.27 Using DNS lists
26862---------------------
26863
26864In its simplest form, the dnslists condition tests whether the calling host is
26865on at least one of a number of DNS lists by looking up the inverted IP address
26866in one or more DNS domains. (Note that DNS list domains are not mail domains,
26867so the "+" syntax for named lists doesn't work - it is used for special options
26868instead.) For example, if the calling host's IP address is 192.168.62.43, and
26869the ACL statement is
26870
26871deny dnslists = blackholes.mail-abuse.org : \
26872 dialups.mail-abuse.org
26873
26874the following records are looked up:
26875
2687643.62.168.192.blackholes.mail-abuse.org
2687743.62.168.192.dialups.mail-abuse.org
26878
26879As soon as Exim finds an existing DNS record, processing of the list stops.
26880Thus, multiple entries on the list provide an "or" conjunction. If you want to
26881test that a host is on more than one list (an "and" conjunction), you can use
26882two separate conditions:
26883
26884deny dnslists = blackholes.mail-abuse.org
26885 dnslists = dialups.mail-abuse.org
26886
26887If a DNS lookup times out or otherwise fails to give a decisive answer, Exim
26888behaves as if the host does not match the list item, that is, as if the DNS
26889record does not exist. If there are further items in the DNS list, they are
26890processed.
26891
26892This is usually the required action when dnslists is used with deny (which is
26893the most common usage), because it prevents a DNS failure from blocking mail.
26894However, you can change this behaviour by putting one of the following special
26895items in the list:
26896
26897+include_unknown behave as if the item is on the list
26898+exclude_unknown behave as if the item is not on the list (default)
26899+defer_unknown give a temporary error
26900
26901Each of these applies to any subsequent items on the list. For example:
26902
26903deny dnslists = +defer_unknown : foo.bar.example
26904
26905Testing the list of domains stops as soon as a match is found. If you want to
26906warn for one list and block for another, you can use two different statements:
26907
26908deny dnslists = blackholes.mail-abuse.org
26909warn message = X-Warn: sending host is on dialups list
26910 dnslists = dialups.mail-abuse.org
26911
26912DNS list lookups are cached by Exim for the duration of the SMTP session, so a
26913lookup based on the IP address is done at most once for any incoming
26914connection. Exim does not share information between multiple incoming
26915connections (but your local name server cache should be active).
26916
26917
2691842.28 Specifying the IP address for a DNS list lookup
26919-----------------------------------------------------
26920
26921By default, the IP address that is used in a DNS list lookup is the IP address
26922of the calling host. However, you can specify another IP address by listing it
26923after the domain name, introduced by a slash. For example:
26924
26925deny dnslists = black.list.tld/192.168.1.2
26926
26927This feature is not very helpful with explicit IP addresses; it is intended for
26928use with IP addresses that are looked up, for example, the IP addresses of the
26929MX hosts or nameservers of an email sender address. For an example, see section
2693042.30 below.
26931
26932
2693342.29 DNS lists keyed on domain names
26934-------------------------------------
26935
26936There are some lists that are keyed on domain names rather than inverted IP
26937addresses (see for example the domain based zones link at http://
26938www.rfc-ignorant.org/). No reversing of components is used with these lists.
26939You can change the name that is looked up in a DNS list by listing it after the
26940domain name, introduced by a slash. For example,
26941
26942deny message = Sender's domain is listed at $dnslist_domain
26943 dnslists = dsn.rfc-ignorant.org/$sender_address_domain
26944
26945This particular example is useful only in ACLs that are obeyed after the RCPT
26946or DATA commands, when a sender address is available. If (for example) the
26947message's sender is user@tld.example the name that is looked up by this example
26948is
26949
26950tld.example.dsn.rfc-ignorant.org
26951
26952A single dnslists condition can contain entries for both names and IP
26953addresses. For example:
26954
26955deny dnslists = sbl.spamhaus.org : \
26956 dsn.rfc-ignorant.org/$sender_address_domain
26957
26958The first item checks the sending host's IP address; the second checks a domain
26959name. The whole condition is true if either of the DNS lookups succeeds.
26960
26961
2696242.30 Multiple explicit keys for a DNS list
26963-------------------------------------------
26964
26965The syntax described above for looking up explicitly-defined values (either
26966names or IP addresses) in a DNS blacklist is a simplification. After the domain
26967name for the DNS list, what follows the slash can in fact be a list of items.
26968As with all lists in Exim, the default separator is a colon. However, because
26969this is a sublist within the list of DNS blacklist domains, it is necessary
26970either to double the separators like this:
26971
26972dnslists = black.list.tld/name.1::name.2
26973
26974or to change the separator character, like this:
26975
26976dnslists = black.list.tld/<;name.1;name.2
26977
26978If an item in the list is an IP address, it is inverted before the DNS
26979blacklist domain is appended. If it is not an IP address, no inversion occurs.
26980Consider this condition:
26981
26982dnslists = black.list.tld/<;192.168.1.2;a.domain
26983
26984The DNS lookups that occur are:
26985
269862.1.168.192.black.list.tld
26987a.domain.black.list.tld
26988
26989Once a DNS record has been found (that matches a specific IP return address, if
26990specified - see section 42.33), no further lookups are done. If there is a
26991temporary DNS error, the rest of the sublist of domains or IP addresses is
26992tried. A temporary error for the whole dnslists item occurs only if no other
26993DNS lookup in this sublist succeeds. In other words, a successful lookup for
26994any of the items in the sublist overrides a temporary error for a previous
26995item.
26996
26997The ability to supply a list of items after the slash is in some sense just a
26998syntactic convenience. These two examples have the same effect:
26999
27000dnslists = black.list.tld/a.domain : black.list.tld/b.domain
27001dnslists = black.list.tld/a.domain::b.domain
27002
27003However, when the data for the list is obtained from a lookup, the second form
27004is usually much more convenient. Consider this example:
27005
27006deny message = The mail servers for the domain \
27007 $sender_address_domain \
27008 are listed at $dnslist_domain ($dnslist_value); \
27009 see $dnslist_text.
27010 dnslists = sbl.spamhaus.org/<|${lookup dnsdb {>|a=<|\
27011 ${lookup dnsdb {>|mxh=\
27012 $sender_address_domain} }} }
27013
27014Note the use of ">|" in the dnsdb lookup to specify the separator for multiple
27015DNS records. The inner dnsdb lookup produces a list of MX hosts and the outer
27016dnsdb lookup finds the IP addresses for these hosts. The result of expanding
27017the condition might be something like this:
27018
27019dnslists = sbl.spahmaus.org/<|192.168.2.3|192.168.5.6|...
27020
27021Thus, this example checks whether or not the IP addresses of the sender
27022domain's mail servers are on the Spamhaus black list.
27023
27024The key that was used for a successful DNS list lookup is put into the variable
27025$dnslist_matched (see section 42.32).
27026
27027
2702842.31 Data returned by DNS lists
27029--------------------------------
27030
27031DNS lists are constructed using address records in the DNS. The original RBL
27032just used the address 127.0.0.1 on the right hand side of each record, but the
27033RBL+ list and some other lists use a number of values with different meanings.
27034The values used on the RBL+ list are:
27035
27036127.1.0.1 RBL
27037127.1.0.2 DUL
27038127.1.0.3 DUL and RBL
27039127.1.0.4 RSS
27040127.1.0.5 RSS and RBL
27041127.1.0.6 RSS and DUL
27042127.1.0.7 RSS and DUL and RBL
27043
27044Section 42.33 below describes how you can distinguish between different values.
27045Some DNS lists may return more than one address record; see section 42.35 for
27046details of how they are checked.
27047
27048
2704942.32 Variables set from DNS lists
27050----------------------------------
27051
27052When an entry is found in a DNS list, the variable $dnslist_domain contains the
27053name of the overall domain that matched (for example, "spamhaus.example"),
27054$dnslist_matched contains the key within that domain (for example,
27055"192.168.5.3"), and $dnslist_value contains the data from the DNS record. When
27056the key is an IP address, it is not reversed in $dnslist_matched (though it is,
27057of course, in the actual lookup). In simple cases, for example:
27058
27059deny dnslists = spamhaus.example
27060
27061the key is also available in another variable (in this case,
27062$sender_host_address). In more complicated cases, however, this is not true.
27063For example, using a data lookup (as described in section 42.30) might generate
27064a dnslists lookup like this:
27065
27066deny dnslists = spamhaus.example/<|192.168.1.2|192.168.6.7|...
27067
27068If this condition succeeds, the value in $dnslist_matched might be
27069"192.168.6.7" (for example).
27070
27071If more than one address record is returned by the DNS lookup, all the IP
27072addresses are included in $dnslist_value, separated by commas and spaces. The
27073variable $dnslist_text contains the contents of any associated TXT record. For
27074lists such as RBL+ the TXT record for a merged entry is often not very
27075meaningful. See section 42.36 for a way of obtaining more information.
27076
27077You can use the DNS list variables in message or log_message modifiers -
27078although these appear before the condition in the ACL, they are not expanded
27079until after it has failed. For example:
27080
27081deny hosts = !+local_networks
27082 message = $sender_host_address is listed \
27083 at $dnslist_domain
27084 dnslists = rbl-plus.mail-abuse.example
27085
27086
2708742.33 Additional matching conditions for DNS lists
27088--------------------------------------------------
27089
27090You can add an equals sign and an IP address after a dnslists domain name in
27091order to restrict its action to DNS records with a matching right hand side.
27092For example,
27093
27094deny dnslists = rblplus.mail-abuse.org=127.0.0.2
27095
27096rejects only those hosts that yield 127.0.0.2. Without this additional data,
27097any address record is considered to be a match. For the moment, we assume that
27098the DNS lookup returns just one record. Section 42.35 describes how multiple
27099records are handled.
27100
27101More than one IP address may be given for checking, using a comma as a
27102separator. These are alternatives - if any one of them matches, the dnslists
27103condition is true. For example:
27104
27105deny dnslists = a.b.c=127.0.0.2,127.0.0.3
27106
27107If you want to specify a constraining address list and also specify names or IP
27108addresses to be looked up, the constraining address list must be specified
27109first. For example:
27110
27111deny dnslists = dsn.rfc-ignorant.org\
27112 =127.0.0.2/$sender_address_domain
27113
27114If the character "&" is used instead of "=", the comparison for each listed IP
27115address is done by a bitwise "and" instead of by an equality test. In other
27116words, the listed addresses are used as bit masks. The comparison is true if
27117all the bits in the mask are present in the address that is being tested. For
27118example:
27119
27120dnslists = a.b.c&0.0.0.3
27121
27122matches if the address is x.x.x.3, x.x.x.7, x.x.x.11, etc. If you want to test
27123whether one bit or another bit is present (as opposed to both being present),
27124you must use multiple values. For example:
27125
27126dnslists = a.b.c&0.0.0.1,0.0.0.2
27127
27128matches if the final component of the address is an odd number or two times an
27129odd number.
27130
27131
2713242.34 Negated DNS matching conditions
27133-------------------------------------
27134
27135You can supply a negative list of IP addresses as part of a dnslists condition.
27136Whereas
27137
27138deny dnslists = a.b.c=127.0.0.2,127.0.0.3
27139
27140means "deny if the host is in the black list at the domain a.b.c and the IP
27141address yielded by the list is either 127.0.0.2 or 127.0.0.3",
27142
27143deny dnslists = a.b.c!=127.0.0.2,127.0.0.3
27144
27145means "deny if the host is in the black list at the domain a.b.c and the IP
27146address yielded by the list is not 127.0.0.2 and not 127.0.0.3". In other
27147words, the result of the test is inverted if an exclamation mark appears before
27148the "=" (or the "&") sign.
27149
27150Note: This kind of negation is not the same as negation in a domain, host, or
27151address list (which is why the syntax is different).
27152
27153If you are using just one list, the negation syntax does not gain you much. The
27154previous example is precisely equivalent to
27155
27156deny dnslists = a.b.c
27157 !dnslists = a.b.c=127.0.0.2,127.0.0.3
27158
27159However, if you are using multiple lists, the negation syntax is clearer.
27160Consider this example:
27161
27162deny dnslists = sbl.spamhaus.org : \
27163 list.dsbl.org : \
27164 dnsbl.njabl.org!=127.0.0.3 : \
27165 relays.ordb.org
27166
27167Using only positive lists, this would have to be:
27168
27169deny dnslists = sbl.spamhaus.org : \
27170 list.dsbl.org
27171deny dnslists = dnsbl.njabl.org
27172 !dnslists = dnsbl.njabl.org=127.0.0.3
27173deny dnslists = relays.ordb.org
27174
27175which is less clear, and harder to maintain.
27176
27177
2717842.35 Handling multiple DNS records from a DNS list
27179---------------------------------------------------
27180
27181A DNS lookup for a dnslists condition may return more than one DNS record,
27182thereby providing more than one IP address. When an item in a dnslists list is
27183followed by "=" or "&" and a list of IP addresses, in order to restrict the
27184match to specific results from the DNS lookup, there are two ways in which the
27185checking can be handled. For example, consider the condition:
27186
27187dnslists = a.b.c=127.0.0.1
27188
27189What happens if the DNS lookup for the incoming IP address yields both
27190127.0.0.1 and 127.0.0.2 by means of two separate DNS records? Is the condition
27191true because at least one given value was found, or is it false because at
27192least one of the found values was not listed? And how does this affect negated
27193conditions? Both possibilities are provided for with the help of additional
27194separators "==" and "=&".
27195
27196 * If "=" or "&" is used, the condition is true if any one of the looked up IP
27197 addresses matches one of the listed addresses. For the example above, the
27198 condition is true because 127.0.0.1 matches.
27199
27200 * If "==" or "=&" is used, the condition is true only if every one of the
27201 looked up IP addresses matches one of the listed addresses. If the
27202 condition is changed to:
27203
27204 dnslists = a.b.c==127.0.0.1
27205
27206 and the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
27207 false because 127.0.0.2 is not listed. You would need to have:
27208
27209 dnslists = a.b.c==127.0.0.1,127.0.0.2
27210
27211 for the condition to be true.
27212
27213When "!" is used to negate IP address matching, it inverts the result, giving
27214the precise opposite of the behaviour above. Thus:
27215
27216 * If "!=" or "!&" is used, the condition is true if none of the looked up IP
27217 addresses matches one of the listed addresses. Consider:
27218
27219 dnslists = a.b.c!&0.0.0.1
27220
27221 If the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
27222 false because 127.0.0.1 matches.
27223
27224 * If "!==" or "!=&" is used, the condition is true if there is at least one
27225 looked up IP address that does not match. Consider:
27226
27227 dnslists = a.b.c!=&0.0.0.1
27228
27229 If the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
27230 true, because 127.0.0.2 does not match. You would need to have:
27231
27232 dnslists = a.b.c!=&0.0.0.1,0.0.0.2
27233
27234 for the condition to be false.
27235
27236When the DNS lookup yields only a single IP address, there is no difference
27237between "=" and "==" and between "&" and "=&".
27238
27239
2724042.36 Detailed information from merged DNS lists
27241------------------------------------------------
27242
27243When the facility for restricting the matching IP values in a DNS list is used,
27244the text from the TXT record that is set in $dnslist_text may not reflect the
27245true reason for rejection. This happens when lists are merged and the IP
27246address in the A record is used to distinguish them; unfortunately there is
27247only one TXT record. One way round this is not to use merged lists, but that
27248can be inefficient because it requires multiple DNS lookups where one would do
27249in the vast majority of cases when the host of interest is not on any of the
27250lists.
27251
27252A less inefficient way of solving this problem is available. If two domain
27253names, comma-separated, are given, the second is used first to do an initial
27254check, making use of any IP value restrictions that are set. If there is a
27255match, the first domain is used, without any IP value restrictions, to get the
27256TXT record. As a byproduct of this, there is also a check that the IP being
27257tested is indeed on the first list. The first domain is the one that is put in
27258$dnslist_domain. For example:
27259
27260reject message = \
27261 rejected because $sender_host_address is blacklisted \
27262 at $dnslist_domain\n$dnslist_text
27263 dnslists = \
27264 sbl.spamhaus.org,sbl-xbl.spamhaus.org=127.0.0.2 : \
27265 dul.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.10
27266
27267For the first blacklist item, this starts by doing a lookup in
27268sbl-xbl.spamhaus.org and testing for a 127.0.0.2 return. If there is a match,
27269it then looks in sbl.spamhaus.org, without checking the return value, and as
27270long as something is found, it looks for the corresponding TXT record. If there
27271is no match in sbl-xbl.spamhaus.org, nothing more is done. The second blacklist
27272item is processed similarly.
27273
27274If you are interested in more than one merged list, the same list must be given
27275several times, but because the results of the DNS lookups are cached, the DNS
27276calls themselves are not repeated. For example:
27277
27278reject dnslists = \
27279 http.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.2 : \
27280 socks.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.3 : \
27281 misc.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.4 : \
27282 dul.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.10
27283
27284In this case there is one lookup in dnsbl.sorbs.net, and if none of the IP
27285values matches (or if no record is found), this is the only lookup that is
27286done. Only if there is a match is one of the more specific lists consulted.
27287
27288
2728942.37 DNS lists and IPv6
27290------------------------
27291
27292If Exim is asked to do a dnslist lookup for an IPv6 address, it inverts it
27293nibble by nibble. For example, if the calling host's IP address is
272943ffe:ffff:836f:0a00:000a:0800:200a:c031, Exim might look up
27295
272961.3.0.c.a.0.0.2.0.0.8.0.a.0.0.0.0.0.a.0.f.6.3.8.
27297 f.f.f.f.e.f.f.3.blackholes.mail-abuse.org
27298
27299(split over two lines here to fit on the page). Unfortunately, some of the DNS
27300lists contain wildcard records, intended for IPv4, that interact badly with
27301IPv6. For example, the DNS entry
27302
27303*.3.some.list.example. A 127.0.0.1
27304
27305is probably intended to put the entire 3.0.0.0/8 IPv4 network on the list.
27306Unfortunately, it also matches the entire 3::/4 IPv6 network.
27307
27308You can exclude IPv6 addresses from DNS lookups by making use of a suitable
27309condition condition, as in this example:
27310
27311deny condition = ${if isip4{$sender_host_address}}
27312 dnslists = some.list.example
27313
27314If an explicit key is being used for a DNS lookup and it may be an IPv6 address
27315you should specify alternate list separators for both the outer (DNS list name)
27316list and inner (lookup keys) list:
27317
27318 dnslists = <; dnsbl.example.com/<|$acl_m_addrslist
27319
27320
2732142.38 Rate limiting incoming messages
27322-------------------------------------
27323
27324The ratelimit ACL condition can be used to measure and control the rate at
27325which clients can send email. This is more powerful than the smtp_ratelimit_*
27326options, because those options control the rate of commands in a single SMTP
27327session only, whereas the ratelimit condition works across all connections
27328(concurrent and sequential) from the same client host. The syntax of the
27329ratelimit condition is:
27330
27331ratelimit = <m> / <p> / <options> / <key>
27332
27333If the average client sending rate is less than m messages per time period p
27334then the condition is false; otherwise it is true.
27335
27336As a side-effect, the ratelimit condition sets the expansion variable
27337$sender_rate to the client's computed rate, $sender_rate_limit to the
27338configured value of m, and $sender_rate_period to the configured value of p.
27339
27340The parameter p is the smoothing time constant, in the form of an Exim time
27341interval, for example, "8h" for eight hours. A larger time constant means that
27342it takes Exim longer to forget a client's past behaviour. The parameter m is
27343the maximum number of messages that a client is permitted to send in each time
27344interval. It also specifies the number of messages permitted in a fast burst.
27345By increasing both m and p but keeping m/p constant, you can allow a client to
27346send more messages in a burst without changing its long-term sending rate
27347limit. Conversely, if m and p are both small, messages must be sent at an even
27348rate.
27349
27350There is a script in util/ratelimit.pl which extracts sending rates from log
27351files, to assist with choosing appropriate settings for m and p when deploying
27352the ratelimit ACL condition. The script prints usage instructions when it is
27353run with no arguments.
27354
27355The key is used to look up the data for calculating the client's average
27356sending rate. This data is stored in Exim's spool directory, alongside the
27357retry and other hints databases. The default key is $sender_host_address, which
27358means Exim computes the sending rate of each client host IP address. By
27359changing the key you can change how Exim identifies clients for the purpose of
27360ratelimiting. For example, to limit the sending rate of each authenticated
27361user, independent of the computer they are sending from, set the key to
27362$authenticated_id. You must ensure that the lookup key is meaningful; for
27363example, $authenticated_id is only meaningful if the client has authenticated
27364(which you can check with the authenticated ACL condition).
27365
27366The lookup key does not have to identify clients: If you want to limit the rate
27367at which a recipient receives messages, you can use the key
27368"$local_part@$domain" with the per_rcpt option (see below) in a RCPT ACL.
27369
27370Each ratelimit condition can have up to four options. A per_* option specifies
27371what Exim measures the rate of, for example messages or recipients or bytes.
27372You can adjust the measurement using the unique= and/or count= options. You can
27373also control when Exim updates the recorded rate using a strict, leaky, or
27374readonly option. The options are separated by a slash, like the other
27375parameters. They may appear in any order.
27376
27377Internally, Exim appends the smoothing constant p onto the lookup key with any
27378options that alter the meaning of the stored data. The limit m is not stored,
27379so you can alter the configured maximum rate and Exim will still remember
27380clients' past behaviour. If you change the per_* mode or add or remove the
27381unique= option, the lookup key changes so Exim will forget past behaviour. The
27382lookup key is not affected by changes to the update mode and the count= option.
27383
27384
2738542.39 Ratelimit options for what is being measured
27386--------------------------------------------------
27387
27388The per_conn option limits the client's connection rate. It is not normally
27389used in the acl_not_smtp, acl_not_smtp_mime, or acl_not_smtp_start ACLs.
27390
27391The per_mail option limits the client's rate of sending messages. This is the
27392default if none of the per_* options is specified. It can be used in
27393acl_smtp_mail, acl_smtp_rcpt, acl_smtp_predata, acl_smtp_mime, acl_smtp_data,
27394or acl_not_smtp.
27395
27396The per_byte option limits the sender's email bandwidth. It can be used in the
27397same ACLs as the per_mail option, though it is best to use this option in the
27398acl_smtp_mime, acl_smtp_data or acl_not_smtp ACLs; if it is used in an earlier
27399ACL, Exim relies on the SIZE parameter given by the client in its MAIL command,
27400which may be inaccurate or completely missing. You can follow the limit m in
27401the configuration with K, M, or G to specify limits in kilobytes, megabytes, or
27402gigabytes, respectively.
27403
27404The per_rcpt option causes Exim to limit the rate at which recipients are
27405accepted. It can be used in the acl_smtp_rcpt, acl_smtp_predata, acl_smtp_mime,
27406acl_smtp_data, or acl_smtp_rcpt ACLs. In acl_smtp_rcpt the rate is updated one
27407recipient at a time; in the other ACLs the rate is updated with the total
27408recipient count in one go. Note that in either case the rate limiting engine
27409will see a message with many recipients as a large high-speed burst.
27410
27411The per_addr option is like the per_rcpt option, except it counts the number of
27412different recipients that the client has sent messages to in the last time
27413period. That is, if the client repeatedly sends messages to the same recipient,
27414its measured rate is not increased. This option can only be used in
27415acl_smtp_rcpt.
27416
27417The per_cmd option causes Exim to recompute the rate every time the condition
27418is processed. This can be used to limit the rate of any SMTP command. If it is
27419used in multiple ACLs it can limit the aggregate rate of multiple different
27420commands.
27421
27422The count= option can be used to alter how much Exim adds to the client's
27423measured rate. For example, the per_byte option is equivalent to "per_mail/
27424count=$message_size". If there is no count= option, Exim increases the measured
27425rate by one (except for the per_rcpt option in ACLs other than acl_smtp_rcpt).
27426The count does not have to be an integer.
27427
27428The unique= option is described in section 42.42 below.
27429
27430
2743142.40 Ratelimit update modes
27432----------------------------
27433
27434You can specify one of three options with the ratelimit condition to control
27435when its database is updated. This section describes the readonly mode, and the
27436next section describes the strict and leaky modes.
27437
27438If the ratelimit condition is used in readonly mode, Exim looks up a
27439previously-computed rate to check against the limit.
27440
27441For example, you can test the client's sending rate and deny it access (when it
27442is too fast) in the connect ACL. If the client passes this check then it can go
27443on to send a message, in which case its recorded rate will be updated in the
27444MAIL ACL. Subsequent connections from the same client will check this new rate.
27445
27446acl_check_connect:
27447 deny ratelimit = 100 / 5m / readonly
27448 log_message = RATE CHECK: $sender_rate/$sender_rate_period \
27449 (max $sender_rate_limit)
27450# ...
27451acl_check_mail:
27452 warn ratelimit = 100 / 5m / strict
27453 log_message = RATE UPDATE: $sender_rate/$sender_rate_period \
27454 (max $sender_rate_limit)
27455
27456If Exim encounters multiple ratelimit conditions with the same key when
27457processing a message then it may increase the client's measured rate more than
27458it should. For example, this will happen if you check the per_rcpt option in
27459both acl_smtp_rcpt and acl_smtp_data. However it's OK to check the same
27460ratelimit condition multiple times in the same ACL. You can avoid any multiple
27461update problems by using the readonly option on later ratelimit checks.
27462
27463The per_* options described above do not make sense in some ACLs. If you use a
27464per_* option in an ACL where it is not normally permitted then the update mode
27465defaults to readonly and you cannot specify the strict or leaky modes. In other
27466ACLs the default update mode is leaky (see the next section) so you must
27467specify the readonly option explicitly.
27468
27469
2747042.41 Ratelimit options for handling fast clients
27471-------------------------------------------------
27472
27473If a client's average rate is greater than the maximum, the rate limiting
27474engine can react in two possible ways, depending on the presence of the strict
27475or leaky update modes. This is independent of the other counter-measures (such
27476as rejecting the message) that may be specified by the rest of the ACL.
27477
27478The leaky (default) option means that the client's recorded rate is not updated
27479if it is above the limit. The effect of this is that Exim measures the client's
27480average rate of successfully sent email, which cannot be greater than the
27481maximum allowed. If the client is over the limit it may suffer some
27482counter-measures (as specified in the ACL), but it will still be able to send
27483email at the configured maximum rate, whatever the rate of its attempts. This
27484is generally the better choice if you have clients that retry automatically.
27485For example, it does not prevent a sender with an over-aggressive retry rate
27486from getting any email through.
27487
27488The strict option means that the client's recorded rate is always updated. The
27489effect of this is that Exim measures the client's average rate of attempts to
27490send email, which can be much higher than the maximum it is actually allowed.
27491If the client is over the limit it may be subjected to counter-measures by the
27492ACL. It must slow down and allow sufficient time to pass that its computed rate
27493falls below the maximum before it can send email again. The time (the number of
27494smoothing periods) it must wait and not attempt to send mail can be calculated
27495with this formula:
27496
27497 ln(peakrate/maxrate)
27498
27499
2750042.42 Limiting the rate of different events
27501-------------------------------------------
27502
27503The ratelimit unique= option controls a mechanism for counting the rate of
27504different events. For example, the per_addr option uses this mechanism to count
27505the number of different recipients that the client has sent messages to in the
27506last time period; it is equivalent to "per_rcpt/unique=$local_part@$domain".
27507You could use this feature to measure the rate that a client uses different
27508sender addresses with the options "per_mail/unique=$sender_address".
27509
27510For each ratelimit key Exim stores the set of unique= values that it has seen
27511for that key. The whole set is thrown away when it is older than the rate
27512smoothing period p, so each different event is counted at most once per period.
27513In the leaky update mode, an event that causes the client to go over the limit
27514is not added to the set, in the same way that the client's recorded rate is not
27515updated in the same situation.
27516
27517When you combine the unique= and readonly options, the specific unique= value
27518is ignored, and Exim just retrieves the client's stored rate.
27519
27520The unique= mechanism needs more space in the ratelimit database than the other
27521ratelimit options in order to store the event set. The number of unique values
27522is potentially as large as the rate limit, so the extra space required
27523increases with larger limits.
27524
27525The uniqueification is not perfect: there is a small probability that Exim will
27526think a new event has happened before. If the sender's rate is less than the
27527limit, Exim should be more than 99.9% correct. However in strict mode the
27528measured rate can go above the limit, in which case Exim may under-count events
27529by a significant margin. Fortunately, if the rate is high enough (2.7 times the
27530limit) that the false positive rate goes above 9%, then Exim will throw away
27531the over-full event set before the measured rate falls below the limit.
27532Therefore the only harm should be that exceptionally high sending rates are
27533logged incorrectly; any countermeasures you configure will be as effective as
27534intended.
27535
27536
2753742.43 Using rate limiting
27538-------------------------
27539
27540Exim's other ACL facilities are used to define what counter-measures are taken
27541when the rate limit is exceeded. This might be anything from logging a warning
27542(for example, while measuring existing sending rates in order to define
27543policy), through time delays to slow down fast senders, up to rejecting the
27544message. For example:
27545
27546# Log all senders' rates
27547warn ratelimit = 0 / 1h / strict
27548 log_message = Sender rate $sender_rate / $sender_rate_period
27549
27550# Slow down fast senders; note the need to truncate $sender_rate
27551# at the decimal point.
27552warn ratelimit = 100 / 1h / per_rcpt / strict
27553 delay = ${eval: ${sg{$sender_rate}{[.].*}{}} - \
27554 $sender_rate_limit }s
27555
27556# Keep authenticated users under control
27557deny authenticated = *
27558 ratelimit = 100 / 1d / strict / $authenticated_id
27559
27560# System-wide rate limit
27561defer message = Sorry, too busy. Try again later.
27562 ratelimit = 10 / 1s / $primary_hostname
27563
27564# Restrict incoming rate from each host, with a default
27565# set using a macro and special cases looked up in a table.
27566defer message = Sender rate exceeds $sender_rate_limit \
27567 messages per $sender_rate_period
27568 ratelimit = ${lookup {$sender_host_address} \
27569 cdb {DB/ratelimits.cdb} \
27570 {$value} {RATELIMIT} }
27571
27572Warning: If you have a busy server with a lot of ratelimit tests, especially
27573with the per_rcpt option, you may suffer from a performance bottleneck caused
27574by locking on the ratelimit hints database. Apart from making your ACLs less
27575complicated, you can reduce the problem by using a RAM disk for Exim's hints
27576directory (usually /var/spool/exim/db/). However this means that Exim will lose
27577its hints data after a reboot (including retry hints, the callout cache, and
27578ratelimit data).
27579
27580
2758142.44 Address verification
27582--------------------------
27583
27584Several of the verify conditions described in section 42.26 cause addresses to
27585be verified. Section 42.48 discusses the reporting of sender verification
27586failures. The verification conditions can be followed by options that modify
27587the verification process. The options are separated from the keyword and from
27588each other by slashes, and some of them contain parameters. For example:
27589
27590verify = sender/callout
27591verify = recipient/defer_ok/callout=10s,defer_ok
27592
27593The first stage of address verification, which always happens, is to run the
27594address through the routers, in "verify mode". Routers can detect the
27595difference between verification and routing for delivery, and their actions can
27596be varied by a number of generic options such as verify and verify_only (see
27597chapter 15). If routing fails, verification fails. The available options are as
27598follows:
27599
27600 * If the callout option is specified, successful routing to one or more
27601 remote hosts is followed by a "callout" to those hosts as an additional
27602 check. Callouts and their sub-options are discussed in the next section.
27603
27604 * If there is a defer error while doing verification routing, the ACL
27605 normally returns "defer". However, if you include defer_ok in the options,
27606 the condition is forced to be true instead. Note that this is a main
27607 verification option as well as a suboption for callouts.
27608
27609 * The no_details option is covered in section 42.48, which discusses the
27610 reporting of sender address verification failures.
27611
27612 * The success_on_redirect option causes verification always to succeed
27613 immediately after a successful redirection. By default, if a redirection
27614 generates just one address, that address is also verified. See further
27615 discussion in section 42.49.
27616
27617After an address verification failure, $acl_verify_message contains the error
27618message that is associated with the failure. It can be preserved by coding like
27619this:
27620
27621warn !verify = sender
27622 set acl_m0 = $acl_verify_message
27623
27624If you are writing your own custom rejection message or log message when
27625denying access, you can use this variable to include information about the
27626verification failure.
27627
27628In addition, $sender_verify_failure or $recipient_verify_failure (as
27629appropriate) contains one of the following words:
27630
27631 * qualify: The address was unqualified (no domain), and the message was
27632 neither local nor came from an exempted host.
27633
27634 * route: Routing failed.
27635
27636 * mail: Routing succeeded, and a callout was attempted; rejection occurred at
27637 or before the MAIL command (that is, on initial connection, HELO, or MAIL).
27638
27639 * recipient: The RCPT command in a callout was rejected.
27640
27641 * postmaster: The postmaster check in a callout was rejected.
27642
27643The main use of these variables is expected to be to distinguish between
27644rejections of MAIL and rejections of RCPT in callouts.
27645
27646
2764742.45 Callout verification
27648--------------------------
27649
27650For non-local addresses, routing verifies the domain, but is unable to do any
27651checking of the local part. There are situations where some means of verifying
27652the local part is desirable. One way this can be done is to make an SMTP
27653callback to a delivery host for the sender address or a callforward to a
27654subsequent host for a recipient address, to see if the host accepts the
27655address. We use the term callout to cover both cases. Note that for a sender
27656address, the callback is not to the client host that is trying to deliver the
27657message, but to one of the hosts that accepts incoming mail for the sender's
27658domain.
27659
27660Exim does not do callouts by default. If you want them to happen, you must
27661request them by setting appropriate options on the verify condition, as
27662described below. This facility should be used with care, because it can add a
27663lot of resource usage to the cost of verifying an address. However, Exim does
27664cache the results of callouts, which helps to reduce the cost. Details of
27665caching are in section 42.47.
27666
27667Recipient callouts are usually used only between hosts that are controlled by
27668the same administration. For example, a corporate gateway host could use
27669callouts to check for valid recipients on an internal mailserver. A successful
27670callout does not guarantee that a real delivery to the address would succeed;
27671on the other hand, a failing callout does guarantee that a delivery would fail.
27672
27673If the callout option is present on a condition that verifies an address, a
27674second stage of verification occurs if the address is successfully routed to
27675one or more remote hosts. The usual case is routing by a dnslookup or a
27676manualroute router, where the router specifies the hosts. However, if a router
27677that does not set up hosts routes to an smtp transport with a hosts setting,
27678the transport's hosts are used. If an smtp transport has hosts_override set,
27679its hosts are always used, whether or not the router supplies a host list.
27680Callouts are only supported on smtp transports.
27681
27682The port that is used is taken from the transport, if it is specified and is a
27683remote transport. (For routers that do verification only, no transport need be
27684specified.) Otherwise, the default SMTP port is used. If a remote transport
27685specifies an outgoing interface, this is used; otherwise the interface is not
27686specified. Likewise, the text that is used for the HELO command is taken from
27687the transport's helo_data option; if there is no transport, the value of
27688$smtp_active_hostname is used.
27689
27690For a sender callout check, Exim makes SMTP connections to the remote hosts, to
27691test whether a bounce message could be delivered to the sender address. The
27692following SMTP commands are sent:
27693
27694HELO <local host name>
27695MAIL FROM:<>
27696RCPT TO:<the address to be tested>
27697QUIT
27698
27699LHLO is used instead of HELO if the transport's protocol option is set to
27700"lmtp".
27701
27702The callout may use EHLO, AUTH and/or STARTTLS given appropriate option
27703settings.
27704
27705A recipient callout check is similar. By default, it also uses an empty address
27706for the sender. This default is chosen because most hosts do not make use of
27707the sender address when verifying a recipient. Using the same address means
27708that a single cache entry can be used for each recipient. Some sites, however,
27709do make use of the sender address when verifying. These are catered for by the
27710use_sender and use_postmaster options, described in the next section.
27711
27712If the response to the RCPT command is a 2xx code, the verification succeeds.
27713If it is 5xx, the verification fails. For any other condition, Exim tries the
27714next host, if any. If there is a problem with all the remote hosts, the ACL
27715yields "defer", unless the defer_ok parameter of the callout option is given,
27716in which case the condition is forced to succeed.
27717
27718A callout may take a little time. For this reason, Exim normally flushes SMTP
27719output before performing a callout in an ACL, to avoid unexpected timeouts in
27720clients when the SMTP PIPELINING extension is in use. The flushing can be
27721disabled by using a control modifier to set no_callout_flush.
27722
27723
2772442.46 Additional parameters for callouts
27725----------------------------------------
27726
27727The callout option can be followed by an equals sign and a number of optional
27728parameters, separated by commas. For example:
27729
27730verify = recipient/callout=10s,defer_ok
27731
27732The old syntax, which had callout_defer_ok and check_postmaster as separate
27733verify options, is retained for backwards compatibility, but is now deprecated.
27734The additional parameters for callout are as follows:
27735
27736<a time interval>
27737
27738 This specifies the timeout that applies for the callout attempt to each
27739 host. For example:
27740
27741 verify = sender/callout=5s
27742
27743 The default is 30 seconds. The timeout is used for each response from the
27744 remote host. It is also used for the initial connection, unless overridden
27745 by the connect parameter.
27746
27747connect = <time interval>
27748
27749 This parameter makes it possible to set a different (usually smaller)
27750 timeout for making the SMTP connection. For example:
27751
27752 verify = sender/callout=5s,connect=1s
27753
27754 If not specified, this timeout defaults to the general timeout value.
27755
27756defer_ok
27757
27758 When this parameter is present, failure to contact any host, or any other
27759 kind of temporary error, is treated as success by the ACL. However, the
27760 cache is not updated in this circumstance.
27761
27762fullpostmaster
27763
27764 This operates like the postmaster option (see below), but if the check for
27765 postmaster@domain fails, it tries just postmaster, without a domain, in
27766 accordance with the specification in RFC 2821. The RFC states that the
27767 unqualified address postmaster should be accepted.
27768
27769mailfrom = <email address>
27770
27771 When verifying addresses in header lines using the header_sender
27772 verification option, Exim behaves by default as if the addresses are
27773 envelope sender addresses from a message. Callout verification therefore
27774 tests to see whether a bounce message could be delivered, by using an empty
27775 address in the MAIL command. However, it is arguable that these addresses
27776 might never be used as envelope senders, and could therefore justifiably
27777 reject bounce messages (empty senders). The mailfrom callout parameter
27778 allows you to specify what address to use in the MAIL command. For example:
27779
27780 require verify = header_sender/callout=mailfrom=abcd@x.y.z
27781
27782 This parameter is available only for the header_sender verification option.
27783
27784maxwait = <time interval>
27785
27786 This parameter sets an overall timeout for performing a callout
27787 verification. For example:
27788
27789 verify = sender/callout=5s,maxwait=30s
27790
27791 This timeout defaults to four times the callout timeout for individual SMTP
27792 commands. The overall timeout applies when there is more than one host that
27793 can be tried. The timeout is checked before trying the next host. This
27794 prevents very long delays if there are a large number of hosts and all are
27795 timing out (for example, when network connections are timing out).
27796
27797no_cache
27798
27799 When this parameter is given, the callout cache is neither read nor
27800 updated.
27801
27802postmaster
27803
27804 When this parameter is set, a successful callout check is followed by a
27805 similar check for the local part postmaster at the same domain. If this
27806 address is rejected, the callout fails (but see fullpostmaster above). The
27807 result of the postmaster check is recorded in a cache record; if it is a
27808 failure, this is used to fail subsequent callouts for the domain without a
27809 connection being made, until the cache record expires.
27810
27811postmaster_mailfrom = <email address>
27812
27813 The postmaster check uses an empty sender in the MAIL command by default.
27814 You can use this parameter to do a postmaster check using a different
27815 address. For example:
27816
27817 require verify = sender/callout=postmaster_mailfrom=abc@x.y.z
27818
27819 If both postmaster and postmaster_mailfrom are present, the rightmost one
27820 overrides. The postmaster parameter is equivalent to this example:
27821
27822 require verify = sender/callout=postmaster_mailfrom=
27823
27824 Warning: The caching arrangements for postmaster checking do not take
27825 account of the sender address. It is assumed that either the empty address
27826 or a fixed non-empty address will be used. All that Exim remembers is that
27827 the postmaster check for the domain succeeded or failed.
27828
27829random
27830
27831 When this parameter is set, before doing the normal callout check, Exim
27832 does a check for a "random" local part at the same domain. The local part
27833 is not really random - it is defined by the expansion of the option
27834 callout_random_local_part, which defaults to
27835
27836 $primary_hostname-$tod_epoch-testing
27837
27838 The idea here is to try to determine whether the remote host accepts all
27839 local parts without checking. If it does, there is no point in doing
27840 callouts for specific local parts. If the "random" check succeeds, the
27841 result is saved in a cache record, and used to force the current and
27842 subsequent callout checks to succeed without a connection being made, until
27843 the cache record expires.
27844
27845use_postmaster
27846
27847 This parameter applies to recipient callouts only. For example:
27848
27849 deny !verify = recipient/callout=use_postmaster
27850
27851 It causes a non-empty postmaster address to be used in the MAIL command
27852 when performing the callout for the recipient, and also for a "random"
27853 check if that is configured. The local part of the address is "postmaster"
27854 and the domain is the contents of $qualify_domain.
27855
27856use_sender
27857
27858 This option applies to recipient callouts only. For example:
27859
27860 require verify = recipient/callout=use_sender
27861
27862 It causes the message's actual sender address to be used in the MAIL
27863 command when performing the callout, instead of an empty address. There is
27864 no need to use this option unless you know that the called hosts make use
27865 of the sender when checking recipients. If used indiscriminately, it
27866 reduces the usefulness of callout caching.
27867
27868If you use any of the parameters that set a non-empty sender for the MAIL
27869command (mailfrom, postmaster_mailfrom, use_postmaster, or use_sender), you
27870should think about possible loops. Recipient checking is usually done between
27871two hosts that are under the same management, and the host that receives the
27872callouts is not normally configured to do callouts itself. Therefore, it is
27873normally safe to use use_postmaster or use_sender in these circumstances.
27874
27875However, if you use a non-empty sender address for a callout to an arbitrary
27876host, there is the likelihood that the remote host will itself initiate a
27877callout check back to your host. As it is checking what appears to be a message
27878sender, it is likely to use an empty address in MAIL, thus avoiding a callout
27879loop. However, to be on the safe side it would be best to set up your own ACLs
27880so that they do not do sender verification checks when the recipient is the
27881address you use for header sender or postmaster callout checking.
27882
27883Another issue to think about when using non-empty senders for callouts is
27884caching. When you set mailfrom or use_sender, the cache record is keyed by the
27885sender/recipient combination; thus, for any given recipient, many more actual
27886callouts are performed than when an empty sender or postmaster is used.
27887
27888
2788942.47 Callout caching
27890---------------------
27891
27892Exim caches the results of callouts in order to reduce the amount of resources
27893used, unless you specify the no_cache parameter with the callout option. A
27894hints database called "callout" is used for the cache. Two different record
27895types are used: one records the result of a callout check for a specific
27896address, and the other records information that applies to the entire domain
27897(for example, that it accepts the local part postmaster).
27898
27899When an original callout fails, a detailed SMTP error message is given about
27900the failure. However, for subsequent failures use the cache data, this message
27901is not available.
27902
27903The expiry times for negative and positive address cache records are
27904independent, and can be set by the global options callout_negative_expire
27905(default 2h) and callout_positive_expire (default 24h), respectively.
27906
27907If a host gives a negative response to an SMTP connection, or rejects any
27908commands up to and including
27909
27910MAIL FROM:<>
27911
27912(but not including the MAIL command with a non-empty address), any callout
27913attempt is bound to fail. Exim remembers such failures in a domain cache
27914record, which it uses to fail callouts for the domain without making new
27915connections, until the domain record times out. There are two separate expiry
27916times for domain cache records: callout_domain_negative_expire (default 3h) and
27917callout_domain_positive_expire (default 7d).
27918
27919Domain records expire when the negative expiry time is reached if callouts
27920cannot be made for the domain, or if the postmaster check failed. Otherwise,
27921they expire when the positive expiry time is reached. This ensures that, for
27922example, a host that stops accepting "random" local parts will eventually be
27923noticed.
27924
27925The callout caching mechanism is based on the domain of the address that is
27926being tested. If the domain routes to several hosts, it is assumed that their
27927behaviour will be the same.
27928
27929
2793042.48 Sender address verification reporting
27931-------------------------------------------
27932
27933See section 42.44 for a general discussion of verification. When sender
27934verification fails in an ACL, the details of the failure are given as
27935additional output lines before the 550 response to the relevant SMTP command
27936(RCPT or DATA). For example, if sender callout is in use, you might see:
27937
27938MAIL FROM:<xyz@abc.example>
27939250 OK
27940RCPT TO:<pqr@def.example>
27941550-Verification failed for <xyz@abc.example>
27942550-Called: 192.168.34.43
27943550-Sent: RCPT TO:<xyz@abc.example>
27944550-Response: 550 Unknown local part xyz in <xyz@abc.example>
27945550 Sender verification failed
27946
27947If more than one RCPT command fails in the same way, the details are given only
27948for the first of them. However, some administrators do not want to send out
27949this much information. You can suppress the details by adding "/no_details" to
27950the ACL statement that requests sender verification. For example:
27951
27952verify = sender/no_details
27953
27954
2795542.49 Redirection while verifying
27956---------------------------------
27957
27958A dilemma arises when a local address is redirected by aliasing or forwarding
27959during verification: should the generated addresses themselves be verified, or
27960should the successful expansion of the original address be enough to verify it?
27961By default, Exim takes the following pragmatic approach:
27962
27963 * When an incoming address is redirected to just one child address,
27964 verification continues with the child address, and if that fails to verify,
27965 the original verification also fails.
27966
27967 * When an incoming address is redirected to more than one child address,
27968 verification does not continue. A success result is returned.
27969
27970This seems the most reasonable behaviour for the common use of aliasing as a
27971way of redirecting different local parts to the same mailbox. It means, for
27972example, that a pair of alias entries of the form
27973
27974A.Wol: aw123
27975aw123: :fail: Gone away, no forwarding address
27976
27977work as expected, with both local parts causing verification failure. When a
27978redirection generates more than one address, the behaviour is more like a
27979mailing list, where the existence of the alias itself is sufficient for
27980verification to succeed.
27981
27982It is possible, however, to change the default behaviour so that all successful
27983redirections count as successful verifications, however many new addresses are
27984generated. This is specified by the success_on_redirect verification option.
27985For example:
27986
27987require verify = recipient/success_on_redirect/callout=10s
27988
27989In this example, verification succeeds if a router generates a new address, and
27990the callout does not occur, because no address was routed to a remote host.
27991
27992When verification is being tested via the -bv option, the treatment of
27993redirections is as just described, unless the -v or any debugging option is
27994also specified. In that case, full verification is done for every generated
27995address and a report is output for each of them.
27996
27997
2799842.50 Client SMTP authorization (CSA)
27999-------------------------------------
28000
28001Client SMTP Authorization is a system that allows a site to advertise which
28002machines are and are not permitted to send email. This is done by placing
28003special SRV records in the DNS; these are looked up using the client's HELO
28004domain. At the time of writing, CSA is still an Internet Draft. Client SMTP
28005Authorization checks in Exim are performed by the ACL condition:
28006
28007verify = csa
28008
28009This fails if the client is not authorized. If there is a DNS problem, or if no
28010valid CSA SRV record is found, or if the client is authorized, the condition
28011succeeds. These three cases can be distinguished using the expansion variable
28012$csa_status, which can take one of the values "fail", "defer", "unknown", or
28013"ok". The condition does not itself defer because that would be likely to cause
28014problems for legitimate email.
28015
28016The error messages produced by the CSA code include slightly more detail. If
28017$csa_status is "defer", this may be because of problems looking up the CSA SRV
28018record, or problems looking up the CSA target address record. There are four
28019reasons for $csa_status being "fail":
28020
28021 * The client's host name is explicitly not authorized.
28022
28023 * The client's IP address does not match any of the CSA target IP addresses.
28024
28025 * The client's host name is authorized but it has no valid target IP
28026 addresses (for example, the target's addresses are IPv6 and the client is
28027 using IPv4).
28028
28029 * The client's host name has no CSA SRV record but a parent domain has
28030 asserted that all subdomains must be explicitly authorized.
28031
28032The csa verification condition can take an argument which is the domain to use
28033for the DNS query. The default is:
28034
28035verify = csa/$sender_helo_name
28036
28037This implementation includes an extension to CSA. If the query domain is an
28038address literal such as [192.0.2.95], or if it is a bare IP address, Exim
28039searches for CSA SRV records in the reverse DNS as if the HELO domain was (for
28040example) 95.2.0.192.in-addr.arpa. Therefore it is meaningful to say:
28041
28042verify = csa/$sender_host_address
28043
28044In fact, this is the check that Exim performs if the client does not say HELO.
28045This extension can be turned off by setting the main configuration option
28046dns_csa_use_reverse to be false.
28047
28048If a CSA SRV record is not found for the domain itself, a search is performed
28049through its parent domains for a record which might be making assertions about
28050subdomains. The maximum depth of this search is limited using the main
28051configuration option dns_csa_search_limit, which is 5 by default. Exim does not
28052look for CSA SRV records in a top level domain, so the default settings handle
28053HELO domains as long as seven (hostname.five.four.three.two.one.com). This
28054encompasses the vast majority of legitimate HELO domains.
28055
28056The dnsdb lookup also has support for CSA. Although dnsdb also supports direct
28057SRV lookups, this is not sufficient because of the extra parent domain search
28058behaviour of CSA, and (as with PTR lookups) dnsdb also turns IP addresses into
28059lookups in the reverse DNS space. The result of a successful lookup such as:
28060
28061${lookup dnsdb {csa=$sender_helo_name}}
28062
28063has two space-separated fields: an authorization code and a target host name.
28064The authorization code can be "Y" for yes, "N" for no, "X" for explicit
28065authorization required but absent, or "?" for unknown.
28066
28067
2806842.51 Bounce address tag validation
28069-----------------------------------
28070
28071Bounce address tag validation (BATV) is a scheme whereby the envelope senders
28072of outgoing messages have a cryptographic, timestamped "tag" added to them.
28073Genuine incoming bounce messages should therefore always be addressed to
28074recipients that have a valid tag. This scheme is a way of detecting unwanted
28075bounce messages caused by sender address forgeries (often called "collateral
28076spam"), because the recipients of such messages do not include valid tags.
28077
28078There are two expansion items to help with the implementation of the BATV
28079"prvs" (private signature) scheme in an Exim configuration. This scheme signs
28080the original envelope sender address by using a simple key to add a hash of the
28081address and some time-based randomizing information. The prvs expansion item
28082creates a signed address, and the prvscheck expansion item checks one. The
28083syntax of these expansion items is described in section 11.5.
28084
28085As an example, suppose the secret per-address keys are stored in an MySQL
28086database. A query to look up the key for an address could be defined as a macro
28087like this:
28088
28089PRVSCHECK_SQL = ${lookup mysql{SELECT secret FROM batv_prvs \
28090 WHERE sender='${quote_mysql:$prvscheck_address}'\
28091 }{$value}}
28092
28093Suppose also that the senders who make use of BATV are defined by an address
28094list called batv_senders. Then, in the ACL for RCPT commands, you could use
28095this:
28096
28097# Bounces: drop unsigned addresses for BATV senders
28098deny message = This address does not send an unsigned reverse path
28099 senders = :
28100 recipients = +batv_senders
28101
28102# Bounces: In case of prvs-signed address, check signature.
28103deny message = Invalid reverse path signature.
28104 senders = :
28105 condition = ${prvscheck {$local_part@$domain}\
28106 {PRVSCHECK_SQL}{1}}
28107 !condition = $prvscheck_result
28108
28109The first statement rejects recipients for bounce messages that are addressed
28110to plain BATV sender addresses, because it is known that BATV senders do not
28111send out messages with plain sender addresses. The second statement rejects
28112recipients that are prvs-signed, but with invalid signatures (either because
28113the key is wrong, or the signature has timed out).
28114
28115A non-prvs-signed address is not rejected by the second statement, because the
28116prvscheck expansion yields an empty string if its first argument is not a
28117prvs-signed address, thus causing the condition condition to be false. If the
28118first argument is a syntactically valid prvs-signed address, the yield is the
28119third string (in this case "1"), whether or not the cryptographic and timeout
28120checks succeed. The $prvscheck_result variable contains the result of the
28121checks (empty for failure, "1" for success).
28122
28123There is one more issue you must consider when implementing prvs-signing: you
28124have to ensure that the routers accept prvs-signed addresses and deliver them
28125correctly. The easiest way to handle this is to use a redirect router to remove
28126the signature with a configuration along these lines:
28127
28128batv_redirect:
28129 driver = redirect
28130 data = ${prvscheck {$local_part@$domain}{PRVSCHECK_SQL}}
28131
28132This works because, if the third argument of prvscheck is empty, the result of
28133the expansion of a prvs-signed address is the decoded value of the original
28134address. This router should probably be the first of your routers that handles
28135local addresses.
28136
28137To create BATV-signed addresses in the first place, a transport of this form
28138can be used:
28139
28140external_smtp_batv:
28141 driver = smtp
28142 return_path = ${prvs {$return_path} \
28143 {${lookup mysql{SELECT \
28144 secret FROM batv_prvs WHERE \
28145 sender='${quote_mysql:$sender_address}'} \
28146 {$value}fail}}}
28147
28148If no key can be found for the existing return path, no signing takes place.
28149
28150
2815142.52 Using an ACL to control relaying
28152--------------------------------------
28153
28154An MTA is said to relay a message if it receives it from some host and delivers
28155it directly to another host as a result of a remote address contained within
28156it. Redirecting a local address via an alias or forward file and then passing
28157the message on to another host is not relaying, but a redirection as a result
28158of the "percent hack" is.
28159
28160Two kinds of relaying exist, which are termed "incoming" and "outgoing". A host
28161which is acting as a gateway or an MX backup is concerned with incoming
28162relaying from arbitrary hosts to a specific set of domains. On the other hand,
28163a host which is acting as a smart host for a number of clients is concerned
28164with outgoing relaying from those clients to the Internet at large. Often the
28165same host is fulfilling both functions, but in principle these two kinds of
28166relaying are entirely independent. What is not wanted is the transmission of
28167mail from arbitrary remote hosts through your system to arbitrary domains.
28168
28169You can implement relay control by means of suitable statements in the ACL that
28170runs for each RCPT command. For convenience, it is often easiest to use Exim's
28171named list facility to define the domains and hosts involved. For example,
28172suppose you want to do the following:
28173
28174 * Deliver a number of domains to mailboxes on the local host (or process them
28175 locally in some other way). Let's say these are my.dom1.example and
28176 my.dom2.example.
28177
28178 * Relay mail for a number of other domains for which you are the secondary
28179 MX. These might be friend1.example and friend2.example.
28180
28181 * Relay mail from the hosts on your local LAN, to whatever domains are
28182 involved. Suppose your LAN is 192.168.45.0/24.
28183
28184In the main part of the configuration, you put the following definitions:
28185
28186domainlist local_domains = my.dom1.example : my.dom2.example
28187domainlist relay_to_domains = friend1.example : friend2.example
28188hostlist relay_from_hosts = 192.168.45.0/24
28189
28190Now you can use these definitions in the ACL that is run for every RCPT
28191command:
28192
28193acl_check_rcpt:
28194 accept domains = +local_domains : +relay_to_domains
28195 accept hosts = +relay_from_hosts
28196
28197The first statement accepts any RCPT command that contains an address in the
28198local or relay domains. For any other domain, control passes to the second
28199statement, which accepts the command only if it comes from one of the relay
28200hosts. In practice, you will probably want to make your ACL more sophisticated
28201than this, for example, by including sender and recipient verification. The
28202default configuration includes a more comprehensive example, which is described
28203in chapter 7.
28204
28205
2820642.53 Checking a relay configuration
28207------------------------------------
28208
28209You can check the relay characteristics of your configuration in the same way
28210that you can test any ACL behaviour for an incoming SMTP connection, by using
28211the -bh option to run a fake SMTP session with which you interact.
28212
28213For specifically testing for unwanted relaying, the host
28214relay-test.mail-abuse.org provides a useful service. If you telnet to this host
28215from the host on which Exim is running, using the normal telnet port, you will
28216see a normal telnet connection message and then quite a long delay. Be patient.
28217The remote host is making an SMTP connection back to your host, and trying a
28218number of common probes to test for open relay vulnerability. The results of
28219the tests will eventually appear on your terminal.
28220
28221
28222
28223===============================================================================
2822443. CONTENT SCANNING AT ACL TIME
28225
28226The extension of Exim to include content scanning at ACL time, formerly known
28227as "exiscan", was originally implemented as a patch by Tom Kistner. The code
28228was integrated into the main source for Exim release 4.50, and Tom continues to
28229maintain it. Most of the wording of this chapter is taken from Tom's
28230specification.
28231
28232It is also possible to scan the content of messages at other times. The
28233local_scan() function (see chapter 44) allows for content scanning after all
28234the ACLs have run. A transport filter can be used to scan messages at delivery
28235time (see the transport_filter option, described in chapter 24).
28236
28237If you want to include the ACL-time content-scanning features when you compile
28238Exim, you need to arrange for WITH_CONTENT_SCAN to be defined in your Local/
28239Makefile. When you do that, the Exim binary is built with:
28240
28241 * Two additional ACLs (acl_smtp_mime and acl_not_smtp_mime) that are run for
28242 all MIME parts for SMTP and non-SMTP messages, respectively.
28243
28244 * Additional ACL conditions and modifiers: decode, malware, mime_regex, regex
28245 , and spam. These can be used in the ACL that is run at the end of message
28246 reception (the acl_smtp_data ACL).
28247
28248 * An additional control feature ("no_mbox_unspool") that saves spooled copies
28249 of messages, or parts of messages, for debugging purposes.
28250
28251 * Additional expansion variables that are set in the new ACL and by the new
28252 conditions.
28253
28254 * Two new main configuration options: av_scanner and spamd_address.
28255
28256There is another content-scanning configuration option for Local/Makefile,
28257called WITH_OLD_DEMIME. If this is set, the old, deprecated demime ACL
28258condition is compiled, in addition to all the other content-scanning features.
28259
28260Content-scanning is continually evolving, and new features are still being
28261added. While such features are still unstable and liable to incompatible
28262changes, they are made available in Exim by setting options whose names begin
28263EXPERIMENTAL_ in Local/Makefile. Such features are not documented in this
28264manual. You can find out about them by reading the file called doc/
28265experimental.txt.
28266
28267All the content-scanning facilities work on a MBOX copy of the message that is
28268temporarily created in a file called:
28269
28270<spool_directory>/scan/<message_id>/<message_id>.eml
28271
28272The .eml extension is a friendly hint to virus scanners that they can expect an
28273MBOX-like structure inside that file. The file is created when the first
28274content scanning facility is called. Subsequent calls to content scanning
28275conditions open the same file again. The directory is recursively removed when
28276the acl_smtp_data ACL has finished running, unless
28277
28278control = no_mbox_unspool
28279
28280has been encountered. When the MIME ACL decodes files, they are put into the
28281same directory by default.
28282
28283
2828443.1 Scanning for viruses
28285-------------------------
28286
28287The malware ACL condition lets you connect virus scanner software to Exim. It
28288supports a "generic" interface to scanners called via the shell, and
28289specialized interfaces for "daemon" type virus scanners, which are resident in
28290memory and thus are much faster.
28291
28292You can set the av_scanner option in first part of the Exim configuration file
28293to specify which scanner to use, together with any additional options that are
28294needed. The basic syntax is as follows:
28295
28296av_scanner = <scanner-type>:<option1>:<option2>:[...]
28297
28298If you do not set av_scanner, it defaults to
28299
28300av_scanner = sophie:/var/run/sophie
28301
28302If the value of av_scanner starts with a dollar character, it is expanded
28303before use. The usual list-parsing of the content (see 6.19) applies. The
28304following scanner types are supported in this release:
28305
28306aveserver
28307
28308 This is the scanner daemon of Kaspersky Version 5. You can get a trial
28309 version at http://www.kaspersky.com. This scanner type takes one option,
28310 which is the path to the daemon's UNIX socket. The default is shown in this
28311 example:
28312
28313 av_scanner = aveserver:/var/run/aveserver
28314
28315clamd
28316
28317 This daemon-type scanner is GPL and free. You can get it at http://
28318 www.clamav.net/. Some older versions of clamd do not seem to unpack MIME
28319 containers, so it used to be recommended to unpack MIME attachments in the
28320 MIME ACL. This no longer believed to be necessary. One option is required:
28321 either the path and name of a UNIX socket file, or a hostname or IP number,
28322 and a port, separated by space, as in the second of these examples:
28323
28324 av_scanner = clamd:/opt/clamd/socket
28325 av_scanner = clamd:192.0.2.3 1234
28326 av_scanner = clamd:192.0.2.3 1234:local
28327 av_scanner = clamd:192.0.2.3 1234 : 192.0.2.4 1234
28328
28329 If the value of av_scanner points to a UNIX socket file or contains the
28330 local keyword, then the ClamAV interface will pass a filename containing
28331 the data to be scanned, which will should normally result in less I/O
28332 happening and be more efficient. Normally in the TCP case, the data is
28333 streamed to ClamAV as Exim does not assume that there is a common
28334 filesystem with the remote host. There is an option WITH_OLD_CLAMAV_STREAM
28335 in src/EDITME available, should you be running a version of ClamAV prior to
28336 0.95.
28337
28338 The final example shows that multiple TCP targets can be specified. Exim
28339 will randomly use one for each incoming email (i.e. it load balances them).
28340 Note that only TCP targets may be used if specifying a list of scanners; a
28341 UNIX socket cannot be mixed in with TCP targets. If one of the servers
28342 becomes unavailable, Exim will try the remaining one(s) until it finds one
28343 that works. When a clamd server becomes unreachable, Exim will log a
28344 message. Exim does not keep track of scanner state between multiple
28345 messages, and the scanner selection is random, so the message will get
28346 logged in the mainlog for each email that the down scanner gets chosen
28347 first (message wrapped to be readable):
28348
28349 2013-10-09 14:30:39 1VTumd-0000Y8-BQ malware acl condition:
28350 clamd: connection to localhost, port 3310 failed
28351 (Connection refused)
28352
28353 If the option is unset, the default is /tmp/clamd. Thanks to David Saez for
28354 contributing the code for this scanner.
28355
28356cmdline
28357
28358 This is the keyword for the generic command line scanner interface. It can
28359 be used to attach virus scanners that are invoked from the shell. This
28360 scanner type takes 3 mandatory options:
28361
28362 1. The full path and name of the scanner binary, with all command line
28363 options, and a placeholder ("%s") for the directory to scan.
28364
28365 2. A regular expression to match against the STDOUT and STDERR output of
28366 the virus scanner. If the expression matches, a virus was found. You
28367 must make absolutely sure that this expression matches on "virus
28368 found". This is called the "trigger" expression.
28369
28370 3. Another regular expression, containing exactly one pair of parentheses,
28371 to match the name of the virus found in the scanners output. This is
28372 called the "name" expression.
28373
28374 For example, Sophos Sweep reports a virus on a line like this:
28375
28376 Virus 'W32/Magistr-B' found in file ./those.bat
28377
28378 For the trigger expression, we can match the phrase "found in file". For
28379 the name expression, we want to extract the W32/Magistr-B string, so we can
28380 match for the single quotes left and right of it. Altogether, this makes
28381 the configuration setting:
28382
28383 av_scanner = cmdline:\
28384 /path/to/sweep -ss -all -rec -archive %s:\
28385 found in file:'(.+)'
28386
28387drweb
28388
28389 The DrWeb daemon scanner (http://www.sald.com/) interface takes one
28390 argument, either a full path to a UNIX socket, or an IP address and port
28391 separated by white space, as in these examples:
28392
28393 av_scanner = drweb:/var/run/drwebd.sock
28394 av_scanner = drweb:192.168.2.20 31337
28395
28396 If you omit the argument, the default path /usr/local/drweb/run/drwebd.sock
28397 is used. Thanks to Alex Miller for contributing the code for this scanner.
28398
28399fsecure
28400
28401 The F-Secure daemon scanner (http://www.f-secure.com) takes one argument
28402 which is the path to a UNIX socket. For example:
28403
28404 av_scanner = fsecure:/path/to/.fsav
28405
28406 If no argument is given, the default is /var/run/.fsav. Thanks to Johan
28407 Thelmen for contributing the code for this scanner.
28408
28409kavdaemon
28410
28411 This is the scanner daemon of Kaspersky Version 4. This version of the
28412 Kaspersky scanner is outdated. Please upgrade (see aveserver above). This
28413 scanner type takes one option, which is the path to the daemon's UNIX
28414 socket. For example:
28415
28416 av_scanner = kavdaemon:/opt/AVP/AvpCtl
28417
28418 The default path is /var/run/AvpCtl.
28419
28420mksd
28421
28422 This is a daemon type scanner that is aimed mainly at Polish users, though
28423 some parts of documentation are now available in English. You can get it at
28424 http://linux.mks.com.pl/. The only option for this scanner type is the
28425 maximum number of processes used simultaneously to scan the attachments,
28426 provided that the demime facility is employed and also provided that mksd
28427 has been run with at least the same number of child processes. For example:
28428
28429 av_scanner = mksd:2
28430
28431 You can safely omit this option (the default value is 1).
28432
28433sock
28434
28435 This is a general-purpose way of talking to simple scanner daemons running
28436 on the local machine. There are four options: an address (which may be an
28437 IP addres and port, or the path of a Unix socket), a commandline to send
28438 (may include a single %s which will be replaced with the path to the mail
28439 file to be scanned), an RE to trigger on from the returned data, an RE to
28440 extract malware_name from the returned data. For example:
28441
28442 av_scanner = sock:127.0.0.1 6001:%s:(SPAM|VIRUS):(.*)\$
28443
28444 Default for the socket specifier is /tmp/malware.sock. Default for the
28445 commandline is %s\n. Both regular-expressions are required.
28446
28447sophie
28448
28449 Sophie is a daemon that uses Sophos' libsavi library to scan for viruses.
28450 You can get Sophie at http://www.clanfield.info/sophie/. The only option
28451 for this scanner type is the path to the UNIX socket that Sophie uses for
28452 client communication. For example:
28453
28454 av_scanner = sophie:/tmp/sophie
28455
28456 The default path is /var/run/sophie, so if you are using this, you can omit
28457 the option.
28458
28459When av_scanner is correctly set, you can use the malware condition in the DATA
28460ACL. Note: You cannot use the malware condition in the MIME ACL.
28461
28462The av_scanner option is expanded each time malware is called. This makes it
28463possible to use different scanners. See further below for an example. The
28464malware condition caches its results, so when you use it multiple times for the
28465same message, the actual scanning process is only carried out once. However,
28466using expandable items in av_scanner disables this caching, in which case each
28467use of the malware condition causes a new scan of the message.
28468
28469The malware condition takes a right-hand argument that is expanded before use.
28470It can then be one of
28471
28472 * "true", "*", or "1", in which case the message is scanned for viruses. The
28473 condition succeeds if a virus was found, and fail otherwise. This is the
28474 recommended usage.
28475
28476 * "false" or "0" or an empty string, in which case no scanning is done and
28477 the condition fails immediately.
28478
28479 * A regular expression, in which case the message is scanned for viruses. The
28480 condition succeeds if a virus is found and its name matches the regular
28481 expression. This allows you to take special actions on certain types of
28482 virus.
28483
28484You can append "/defer_ok" to the malware condition to accept messages even if
28485there is a problem with the virus scanner. Otherwise, such a problem causes the
28486ACL to defer.
28487
28488When a virus is found, the condition sets up an expansion variable called
28489$malware_name that contains the name of the virus. You can use it in a message
28490modifier that specifies the error returned to the sender, and/or in logging
28491data.
28492
28493If your virus scanner cannot unpack MIME and TNEF containers itself, you should
28494use the demime condition (see section 43.6) before the malware condition.
28495
28496Beware the interaction of Exim's message_size_limit with any size limits
28497imposed by your anti-virus scanner.
28498
28499Here is a very simple scanning example:
28500
28501deny message = This message contains malware ($malware_name)
28502 demime = *
28503 malware = *
28504
28505The next example accepts messages when there is a problem with the scanner:
28506
28507deny message = This message contains malware ($malware_name)
28508 demime = *
28509 malware = */defer_ok
28510
28511The next example shows how to use an ACL variable to scan with both sophie and
28512aveserver. It assumes you have set:
28513
28514av_scanner = $acl_m0
28515
28516in the main Exim configuration.
28517
28518deny message = This message contains malware ($malware_name)
28519 set acl_m0 = sophie
28520 malware = *
28521
28522deny message = This message contains malware ($malware_name)
28523 set acl_m0 = aveserver
28524 malware = *
28525
28526
2852743.2 Scanning with SpamAssassin
28528-------------------------------
28529
28530The spam ACL condition calls SpamAssassin's spamd daemon to get a spam score
28531and a report for the message. You can get SpamAssassin at http://
28532www.spamassassin.org, or, if you have a working Perl installation, you can use
28533CPAN by running:
28534
28535perl -MCPAN -e 'install Mail::SpamAssassin'
28536
28537SpamAssassin has its own set of configuration files. Please review its
28538documentation to see how you can tweak it. The default installation should work
28539nicely, however.
28540
28541After having installed and configured SpamAssassin, start the spamd daemon. By
28542default, it listens on 127.0.0.1, TCP port 783. If you use another host or port
28543for spamd, you must set the spamd_address option in the global part of the Exim
28544configuration as follows (example):
28545
28546spamd_address = 192.168.99.45 387
28547
28548You do not need to set this option if you use the default. As of version 2.60,
28549spamd also supports communication over UNIX sockets. If you want to use these,
28550supply spamd_address with an absolute file name instead of a address/port pair:
28551
28552spamd_address = /var/run/spamd_socket
28553
28554You can have multiple spamd servers to improve scalability. These can reside on
28555other hardware reachable over the network. To specify multiple spamd servers,
28556put multiple address/port pairs in the spamd_address option, separated with
28557colons:
28558
28559spamd_address = 192.168.2.10 783 : \
28560 192.168.2.11 783 : \
28561 192.168.2.12 783
28562
28563Up to 32 spamd servers are supported. The servers are queried in a random
28564fashion. When a server fails to respond to the connection attempt, all other
28565servers are tried until one succeeds. If no server responds, the spam condition
28566defers.
28567
28568Warning: It is not possible to use the UNIX socket connection method with
28569multiple spamd servers.
28570
28571The spamd_address variable is expanded before use if it starts with a dollar
28572sign. In this case, the expansion may return a string that is used as the list
28573so that multiple spamd servers can be the result of an expansion.
28574
28575
2857643.3 Calling SpamAssassin from an Exim ACL
28577------------------------------------------
28578
28579Here is a simple example of the use of the spam condition in a DATA ACL:
28580
28581deny message = This message was classified as SPAM
28582 spam = joe
28583
28584The right-hand side of the spam condition specifies a name. This is relevant if
28585you have set up multiple SpamAssassin profiles. If you do not want to scan
28586using a specific profile, but rather use the SpamAssassin system-wide default
28587profile, you can scan for an unknown name, or simply use "nobody". However, you
28588must put something on the right-hand side.
28589
28590The name allows you to use per-domain or per-user antispam profiles in
28591principle, but this is not straightforward in practice, because a message may
28592have multiple recipients, not necessarily all in the same domain. Because the
28593spam condition has to be called from a DATA ACL in order to be able to read the
28594contents of the message, the variables $local_part and $domain are not set.
28595
28596The right-hand side of the spam condition is expanded before being used, so you
28597can put lookups or conditions there. When the right-hand side evaluates to "0"
28598or "false", no scanning is done and the condition fails immediately.
28599
28600Scanning with SpamAssassin uses a lot of resources. If you scan every message,
28601large ones may cause significant performance degradation. As most spam messages
28602are quite small, it is recommended that you do not scan the big ones. For
28603example:
28604
28605deny message = This message was classified as SPAM
28606 condition = ${if < {$message_size}{10K}}
28607 spam = nobody
28608
28609The spam condition returns true if the threshold specified in the user's
28610SpamAssassin profile has been matched or exceeded. If you want to use the spam
28611condition for its side effects (see the variables below), you can make it
28612always return "true" by appending ":true" to the username.
28613
28614When the spam condition is run, it sets up a number of expansion variables.
28615These variables are saved with the received message, thus they are available
28616for use at delivery time.
28617
28618$spam_score
28619
28620 The spam score of the message, for example "3.4" or "30.5". This is useful
28621 for inclusion in log or reject messages.
28622
28623$spam_score_int
28624
28625 The spam score of the message, multiplied by ten, as an integer value. For
28626 example "34" or "305". It may appear to disagree with $spam_score because
28627 $spam_score is rounded and $spam_score_int is truncated. The integer value
28628 is useful for numeric comparisons in conditions.
28629
28630$spam_bar
28631
28632 A string consisting of a number of "+" or "-" characters, representing the
28633 integer part of the spam score value. A spam score of 4.4 would have a
28634 $spam_bar value of "++++". This is useful for inclusion in warning headers,
28635 since MUAs can match on such strings.
28636
28637$spam_report
28638
28639 A multiline text table, containing the full SpamAssassin report for the
28640 message. Useful for inclusion in headers or reject messages.
28641
28642The spam condition caches its results unless expansion in spamd_address was
28643used. If you call it again with the same user name, it does not scan again, but
28644rather returns the same values as before.
28645
28646The spam condition returns DEFER if there is any error while running the
28647message through SpamAssassin or if the expansion of spamd_address failed. If
28648you want to treat DEFER as FAIL (to pass on to the next ACL statement block),
28649append "/defer_ok" to the right-hand side of the spam condition, like this:
28650
28651deny message = This message was classified as SPAM
28652 spam = joe/defer_ok
28653
28654This causes messages to be accepted even if there is a problem with spamd.
28655
28656Here is a longer, commented example of the use of the spam condition:
28657
28658# put headers in all messages (no matter if spam or not)
28659warn spam = nobody:true
28660 add_header = X-Spam-Score: $spam_score ($spam_bar)
28661 add_header = X-Spam-Report: $spam_report
28662
28663# add second subject line with *SPAM* marker when message
28664# is over threshold
28665warn spam = nobody
28666 add_header = Subject: *SPAM* $h_Subject:
28667
28668# reject spam at high scores (> 12)
28669deny message = This message scored $spam_score spam points.
28670 spam = nobody:true
28671 condition = ${if >{$spam_score_int}{120}{1}{0}}
28672
28673
2867443.4 Scanning MIME parts
28675------------------------
28676
28677The acl_smtp_mime global option specifies an ACL that is called once for each
28678MIME part of an SMTP message, including multipart types, in the sequence of
28679their position in the message. Similarly, the acl_not_smtp_mime option
28680specifies an ACL that is used for the MIME parts of non-SMTP messages. These
28681options may both refer to the same ACL if you want the same processing in both
28682cases.
28683
28684These ACLs are called (possibly many times) just before the acl_smtp_data ACL
28685in the case of an SMTP message, or just before the acl_not_smtp ACL in the case
28686of a non-SMTP message. However, a MIME ACL is called only if the message
28687contains a Content-Type: header line. When a call to a MIME ACL does not yield
28688"accept", ACL processing is aborted and the appropriate result code is sent to
28689the client. In the case of an SMTP message, the acl_smtp_data ACL is not called
28690when this happens.
28691
28692You cannot use the malware or spam conditions in a MIME ACL; these can only be
28693used in the DATA or non-SMTP ACLs. However, you can use the regex condition to
28694match against the raw MIME part. You can also use the mime_regex condition to
28695match against the decoded MIME part (see section 43.5).
28696
28697At the start of a MIME ACL, a number of variables are set from the header
28698information for the relevant MIME part. These are described below. The contents
28699of the MIME part are not by default decoded into a disk file except for MIME
28700parts whose content-type is "message/rfc822". If you want to decode a MIME part
28701into a disk file, you can use the decode condition. The general syntax is:
28702
28703decode = [/<path>/]<filename>
28704
28705The right hand side is expanded before use. After expansion, the value can be:
28706
28707 1. "0" or "false", in which case no decoding is done.
28708
28709 2. The string "default". In that case, the file is put in the temporary
28710 "default" directory <spool_directory>/scan/<message_id>/ with a sequential
28711 file name consisting of the message id and a sequence number. The full path
28712 and name is available in $mime_decoded_filename after decoding.
28713
28714 3. A full path name starting with a slash. If the full name is an existing
28715 directory, it is used as a replacement for the default directory. The
28716 filename is then sequentially assigned. If the path does not exist, it is
28717 used as the full path and file name.
28718
28719 4. If the string does not start with a slash, it is used as the filename, and
28720 the default path is then used.
28721
28722The decode condition normally succeeds. It is only false for syntax errors or
28723unusual circumstances such as memory shortages. You can easily decode a file
28724with its original, proposed filename using
28725
28726decode = $mime_filename
28727
28728However, you should keep in mind that $mime_filename might contain anything. If
28729you place files outside of the default path, they are not automatically
28730unlinked.
28731
28732For RFC822 attachments (these are messages attached to messages, with a
28733content-type of "message/rfc822"), the ACL is called again in the same manner
28734as for the primary message, only that the $mime_is_rfc822 expansion variable is
28735set (see below). Attached messages are always decoded to disk before being
28736checked, and the files are unlinked once the check is done.
28737
28738The MIME ACL supports the regex and mime_regex conditions. These can be used to
28739match regular expressions against raw and decoded MIME parts, respectively.
28740They are described in section 43.5.
28741
28742The following list describes all expansion variables that are available in the
28743MIME ACL:
28744
28745$mime_boundary
28746
28747 If the current part is a multipart (see $mime_is_multipart) below, it
28748 should have a boundary string, which is stored in this variable. If the
28749 current part has no boundary parameter in the Content-Type: header, this
28750 variable contains the empty string.
28751
28752$mime_charset
28753
28754 This variable contains the character set identifier, if one was found in
28755 the Content-Type: header. Examples for charset identifiers are:
28756
28757 us-ascii
28758 gb2312 (Chinese)
28759 iso-8859-1
28760
28761 Please note that this value is not normalized, so you should do matches
28762 case-insensitively.
28763
28764$mime_content_description
28765
28766 This variable contains the normalized content of the Content-Description:
28767 header. It can contain a human-readable description of the parts content.
28768 Some implementations repeat the filename for attachments here, but they are
28769 usually only used for display purposes.
28770
28771$mime_content_disposition
28772
28773 This variable contains the normalized content of the Content-Disposition:
28774 header. You can expect strings like "attachment" or "inline" here.
28775
28776$mime_content_id
28777
28778 This variable contains the normalized content of the Content-ID: header.
28779 This is a unique ID that can be used to reference a part from another part.
28780
28781$mime_content_size
28782
28783 This variable is set only after the decode modifier (see above) has been
28784 successfully run. It contains the size of the decoded part in kilobytes.
28785 The size is always rounded up to full kilobytes, so only a completely empty
28786 part has a $mime_content_size of zero.
28787
28788$mime_content_transfer_encoding
28789
28790 This variable contains the normalized content of the
28791 Content-transfer-encoding: header. This is a symbolic name for an encoding
28792 type. Typical values are "base64" and "quoted-printable".
28793
28794$mime_content_type
28795
28796 If the MIME part has a Content-Type: header, this variable contains its
28797 value, lowercased, and without any options (like "name" or "charset"). Here
28798 are some examples of popular MIME types, as they may appear in this
28799 variable:
28800
28801 text/plain
28802 text/html
28803 application/octet-stream
28804 image/jpeg
28805 audio/midi
28806
28807 If the MIME part has no Content-Type: header, this variable contains the
28808 empty string.
28809
28810$mime_decoded_filename
28811
28812 This variable is set only after the decode modifier (see above) has been
28813 successfully run. It contains the full path and file name of the file
28814 containing the decoded data.
28815
28816$mime_filename
28817
28818 This is perhaps the most important of the MIME variables. It contains a
28819 proposed filename for an attachment, if one was found in either the
28820 Content-Type: or Content-Disposition: headers. The filename will be RFC2047
28821 decoded, but no additional sanity checks are done. If no filename was
28822 found, this variable contains the empty string.
28823
28824$mime_is_coverletter
28825
28826 This variable attempts to differentiate the "cover letter" of an e-mail
28827 from attached data. It can be used to clamp down on flashy or unnecessarily
28828 encoded content in the cover letter, while not restricting attachments at
28829 all.
28830
28831 The variable contains 1 (true) for a MIME part believed to be part of the
28832 cover letter, and 0 (false) for an attachment. At present, the algorithm is
28833 as follows:
28834
28835 1. The outermost MIME part of a message is always a cover letter.
28836
28837 2. If a multipart/alternative or multipart/related MIME part is a cover
28838 letter, so are all MIME subparts within that multipart.
28839
28840 3. If any other multipart is a cover letter, the first subpart is a cover
28841 letter, and the rest are attachments.
28842
28843 4. All parts contained within an attachment multipart are attachments.
28844
28845 As an example, the following will ban "HTML mail" (including that sent with
28846 alternative plain text), while allowing HTML files to be attached. HTML
28847 coverletter mail attached to non-HMTL coverletter mail will also be
28848 allowed:
28849
28850 deny message = HTML mail is not accepted here
28851 !condition = $mime_is_rfc822
28852 condition = $mime_is_coverletter
28853 condition = ${if eq{$mime_content_type}{text/html}{1}{0}}
28854
28855$mime_is_multipart
28856
28857 This variable has the value 1 (true) when the current part has the main
28858 type "multipart", for example "multipart/alternative" or "multipart/mixed".
28859 Since multipart entities only serve as containers for other parts, you may
28860 not want to carry out specific actions on them.
28861
28862$mime_is_rfc822
28863
28864 This variable has the value 1 (true) if the current part is not a part of
28865 the checked message itself, but part of an attached message. Attached
28866 message decoding is fully recursive.
28867
28868$mime_part_count
28869
28870 This variable is a counter that is raised for each processed MIME part. It
28871 starts at zero for the very first part (which is usually a multipart). The
28872 counter is per-message, so it is reset when processing RFC822 attachments
28873 (see $mime_is_rfc822). The counter stays set after acl_smtp_mime is
28874 complete, so you can use it in the DATA ACL to determine the number of MIME
28875 parts of a message. For non-MIME messages, this variable contains the value
28876 -1.
28877
28878
2887943.5 Scanning with regular expressions
28880--------------------------------------
28881
28882You can specify your own custom regular expression matches on the full body of
28883the message, or on individual MIME parts.
28884
28885The regex condition takes one or more regular expressions as arguments and
28886matches them against the full message (when called in the DATA ACL) or a raw
28887MIME part (when called in the MIME ACL). The regex condition matches linewise,
28888with a maximum line length of 32K characters. That means you cannot have
28889multiline matches with the regex condition.
28890
28891The mime_regex condition can be called only in the MIME ACL. It matches up to
2889232K of decoded content (the whole content at once, not linewise). If the part
28893has not been decoded with the decode modifier earlier in the ACL, it is decoded
28894automatically when mime_regex is executed (using default path and filename
28895values). If the decoded data is larger than 32K, only the first 32K characters
28896are checked.
28897
28898The regular expressions are passed as a colon-separated list. To include a
28899literal colon, you must double it. Since the whole right-hand side string is
28900expanded before being used, you must also escape dollar signs and backslashes
28901with more backslashes, or use the "\N" facility to disable expansion. Here is a
28902simple example that contains two regular expressions:
28903
28904deny message = contains blacklisted regex ($regex_match_string)
28905 regex = [Mm]ortgage : URGENT BUSINESS PROPOSAL
28906
28907The conditions returns true if any one of the regular expressions matches. The
28908$regex_match_string expansion variable is then set up and contains the matching
28909regular expression.
28910
28911Warning: With large messages, these conditions can be fairly CPU-intensive.
28912
28913
2891443.6 The demime condition
28915-------------------------
28916
28917The demime ACL condition provides MIME unpacking, sanity checking and file
28918extension blocking. It is usable only in the DATA and non-SMTP ACLs. The demime
28919condition uses a simpler interface to MIME decoding than the MIME ACL
28920functionality, but provides no additional facilities. Please note that this
28921condition is deprecated and kept only for backward compatibility. You must set
28922the WITH_OLD_DEMIME option in Local/Makefile at build time to be able to use
28923the demime condition.
28924
28925The demime condition unpacks MIME containers in the message. It detects errors
28926in MIME containers and can match file extensions found in the message against a
28927list. Using this facility produces files containing the unpacked MIME parts of
28928the message in the temporary scan directory. If you do antivirus scanning, it
28929is recommended that you use the demime condition before the antivirus (malware)
28930condition.
28931
28932On the right-hand side of the demime condition you can pass a colon-separated
28933list of file extensions that it should match against. For example:
28934
28935deny message = Found blacklisted file attachment
28936 demime = vbs:com:bat:pif:prf:lnk
28937
28938If one of the file extensions is found, the condition is true, otherwise it is
28939false. If there is a temporary error while demimeing (for example, "disk
28940full"), the condition defers, and the message is temporarily rejected (unless
28941the condition is on a warn verb).
28942
28943The right-hand side is expanded before being treated as a list, so you can have
28944conditions and lookups there. If it expands to an empty string, "false", or
28945zero ("0"), no demimeing is done and the condition is false.
28946
28947The demime condition set the following variables:
28948
28949$demime_errorlevel
28950
28951 When an error is detected in a MIME container, this variable contains the
28952 severity of the error, as an integer number. The higher the value, the more
28953 severe the error (the current maximum value is 3). If this variable is
28954 unset or zero, no error occurred.
28955
28956$demime_reason
28957
28958 When $demime_errorlevel is greater than zero, this variable contains a
28959 human-readable text string describing the MIME error that occurred.
28960
28961$found_extension
28962
28963 When the demime condition is true, this variable contains the file
28964 extension it found.
28965
28966Both $demime_errorlevel and $demime_reason are set by the first call of the
28967demime condition, and are not changed on subsequent calls.
28968
28969If you do not want to check for file extensions, but rather use the demime
28970condition for unpacking or error checking purposes, pass "*" as the right-hand
28971side value. Here is a more elaborate example of how to use this facility:
28972
28973# Reject messages with serious MIME container errors
28974deny message = Found MIME error ($demime_reason).
28975 demime = *
28976 condition = ${if >{$demime_errorlevel}{2}{1}{0}}
28977
28978# Reject known virus spreading file extensions.
28979# Accepting these is pretty much braindead.
28980deny message = contains $found_extension file (blacklisted).
28981 demime = com:vbs:bat:pif:scr
28982
28983# Freeze .exe and .doc files. Postmaster can
28984# examine them and eventually thaw them.
28985deny log_message = Another $found_extension file.
28986 demime = exe:doc
28987 control = freeze
28988
28989
28990
28991===============================================================================
2899244. ADDING A LOCAL SCAN FUNCTION TO EXIM
28993
28994In these days of email worms, viruses, and ever-increasing spam, some sites
28995want to apply a lot of checking to messages before accepting them.
28996
28997The content scanning extension (chapter 43) has facilities for passing messages
28998to external virus and spam scanning software. You can also do a certain amount
28999in Exim itself through string expansions and the condition condition in the ACL
29000that runs after the SMTP DATA command or the ACL for non-SMTP messages (see
29001chapter 42), but this has its limitations.
29002
29003To allow for further customization to a site's own requirements, there is the
29004possibility of linking Exim with a private message scanning function, written
29005in C. If you want to run code that is written in something other than C, you
29006can of course use a little C stub to call it.
29007
29008The local scan function is run once for every incoming message, at the point
29009when Exim is just about to accept the message. It can therefore be used to
29010control non-SMTP messages from local processes as well as messages arriving via
29011SMTP.
29012
29013Exim applies a timeout to calls of the local scan function, and there is an
29014option called local_scan_timeout for setting it. The default is 5 minutes. Zero
29015means "no timeout". Exim also sets up signal handlers for SIGSEGV, SIGILL,
29016SIGFPE, and SIGBUS before calling the local scan function, so that the most
29017common types of crash are caught. If the timeout is exceeded or one of those
29018signals is caught, the incoming message is rejected with a temporary error if
29019it is an SMTP message. For a non-SMTP message, the message is dropped and Exim
29020ends with a non-zero code. The incident is logged on the main and reject logs.
29021
29022
2902344.1 Building Exim to use a local scan function
29024-----------------------------------------------
29025
29026To make use of the local scan function feature, you must tell Exim where your
29027function is before building Exim, by setting LOCAL_SCAN_SOURCE in your Local/
29028Makefile. A recommended place to put it is in the Local directory, so you might
29029set
29030
29031LOCAL_SCAN_SOURCE=Local/local_scan.c
29032
29033for example. The function must be called local_scan(). It is called by Exim
29034after it has received a message, when the success return code is about to be
29035sent. This is after all the ACLs have been run. The return code from your
29036function controls whether the message is actually accepted or not. There is a
29037commented template function (that just accepts the message) in the file _src/
29038local_scan.c_.
29039
29040If you want to make use of Exim's run time configuration file to set options
29041for your local_scan() function, you must also set
29042
29043LOCAL_SCAN_HAS_OPTIONS=yes
29044
29045in Local/Makefile (see section 44.3 below).
29046
29047
2904844.2 API for local_scan()
29049-------------------------
29050
29051You must include this line near the start of your code:
29052
29053#include "local_scan.h"
29054
29055This header file defines a number of variables and other values, and the
29056prototype for the function itself. Exim is coded to use unsigned char values
29057almost exclusively, and one of the things this header defines is a shorthand
29058for "unsigned char" called "uschar". It also contains the following macro
29059definitions, to simplify casting character strings and pointers to character
29060strings:
29061
29062#define CS (char *)
29063#define CCS (const char *)
29064#define CSS (char **)
29065#define US (unsigned char *)
29066#define CUS (const unsigned char *)
29067#define USS (unsigned char **)
29068
29069The function prototype for local_scan() is:
29070
29071extern int local_scan(int fd, uschar **return_text);
29072
29073The arguments are as follows:
29074
29075 * fd is a file descriptor for the file that contains the body of the message
29076 (the -D file). The file is open for reading and writing, but updating it is
29077 not recommended. Warning: You must not close this file descriptor.
29078
29079 The descriptor is positioned at character 19 of the file, which is the
29080 first character of the body itself, because the first 19 characters are the
29081 message id followed by "-D" and a newline. If you rewind the file, you
29082 should use the macro SPOOL_DATA_START_OFFSET to reset to the start of the
29083 data, just in case this changes in some future version.
29084
29085 * return_text is an address which you can use to return a pointer to a text
29086 string at the end of the function. The value it points to on entry is NULL.
29087
29088The function must return an int value which is one of the following macros:
29089
29090"LOCAL_SCAN_ACCEPT"
29091
29092 The message is accepted. If you pass back a string of text, it is saved
29093 with the message, and made available in the variable $local_scan_data. No
29094 newlines are permitted (if there are any, they are turned into spaces) and
29095 the maximum length of text is 1000 characters.
29096
29097"LOCAL_SCAN_ACCEPT_FREEZE"
29098
29099 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
29100 queued without immediate delivery, and is frozen.
29101
29102"LOCAL_SCAN_ACCEPT_QUEUE"
29103
29104 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
29105 queued without immediate delivery.
29106
29107"LOCAL_SCAN_REJECT"
29108
29109 The message is rejected; the returned text is used as an error message
29110 which is passed back to the sender and which is also logged. Newlines are
29111 permitted - they cause a multiline response for SMTP rejections, but are
29112 converted to "\n" in log lines. If no message is given, "Administrative
29113 prohibition" is used.
29114
29115"LOCAL_SCAN_TEMPREJECT"
29116
29117 The message is temporarily rejected; the returned text is used as an error
29118 message as for LOCAL_SCAN_REJECT. If no message is given, "Temporary local
29119 problem" is used.
29120
29121"LOCAL_SCAN_REJECT_NOLOGHDR"
29122
29123 This behaves as LOCAL_SCAN_REJECT, except that the header of the rejected
29124 message is not written to the reject log. It has the effect of unsetting
29125 the rejected_header log selector for just this rejection. If
29126 rejected_header is already unset (see the discussion of the log_selection
29127 option in section 51.15), this code is the same as LOCAL_SCAN_REJECT.
29128
29129"LOCAL_SCAN_TEMPREJECT_NOLOGHDR"
29130
29131 This code is a variation of LOCAL_SCAN_TEMPREJECT in the same way that
29132 LOCAL_SCAN_REJECT_NOLOGHDR is a variation of LOCAL_SCAN_REJECT.
29133
29134If the message is not being received by interactive SMTP, rejections are
29135reported by writing to stderr or by sending an email, as configured by the -oe
29136command line options.
29137
29138
2913944.3 Configuration options for local_scan()
29140-------------------------------------------
29141
29142It is possible to have option settings in the main configuration file that set
29143values in static variables in the local_scan() module. If you want to do this,
29144you must have the line
29145
29146LOCAL_SCAN_HAS_OPTIONS=yes
29147
29148in your Local/Makefile when you build Exim. (This line is in OS/
29149Makefile-Default, commented out). Then, in the local_scan() source file, you
29150must define static variables to hold the option values, and a table to define
29151them.
29152
29153The table must be a vector called local_scan_options, of type "optionlist".
29154Each entry is a triplet, consisting of a name, an option type, and a pointer to
29155the variable that holds the value. The entries must appear in alphabetical
29156order. Following local_scan_options you must also define a variable called
29157local_scan_options_count that contains the number of entries in the table. Here
29158is a short example, showing two kinds of option:
29159
29160static int my_integer_option = 42;
29161static uschar *my_string_option = US"a default string";
29162
29163optionlist local_scan_options[] = {
29164 { "my_integer", opt_int, &my_integer_option },
29165 { "my_string", opt_stringptr, &my_string_option }
29166};
29167
29168int local_scan_options_count =
29169 sizeof(local_scan_options)/sizeof(optionlist);
29170
29171The values of the variables can now be changed from Exim's runtime
29172configuration file by including a local scan section as in this example:
29173
29174begin local_scan
29175my_integer = 99
29176my_string = some string of text...
29177
29178The available types of option data are as follows:
29179
29180opt_bool
29181
29182 This specifies a boolean (true/false) option. The address should point to a
29183 variable of type "BOOL", which will be set to TRUE or FALSE, which are
29184 macros that are defined as "1" and "0", respectively. If you want to detect
29185 whether such a variable has been set at all, you can initialize it to
29186 TRUE_UNSET. (BOOL variables are integers underneath, so can hold more than
29187 two values.)
29188
29189opt_fixed
29190
29191 This specifies a fixed point number, such as is used for load averages. The
29192 address should point to a variable of type "int". The value is stored
29193 multiplied by 1000, so, for example, 1.4142 is truncated and stored as
29194 1414.
29195
29196opt_int
29197
29198 This specifies an integer; the address should point to a variable of type
29199 "int". The value may be specified in any of the integer formats accepted by
29200 Exim.
29201
29202opt_mkint
29203
29204 This is the same as opt_int, except that when such a value is output in a
29205 -bP listing, if it is an exact number of kilobytes or megabytes, it is
29206 printed with the suffix K or M.
29207
29208opt_octint
29209
29210 This also specifies an integer, but the value is always interpreted as an
29211 octal integer, whether or not it starts with the digit zero, and it is
29212 always output in octal.
29213
29214opt_stringptr
29215
29216 This specifies a string value; the address must be a pointer to a variable
29217 that points to a string (for example, of type "uschar *").
29218
29219opt_time
29220
29221 This specifies a time interval value. The address must point to a variable
29222 of type "int". The value that is placed there is a number of seconds.
29223
29224If the -bP command line option is followed by "local_scan", Exim prints out the
29225values of all the local_scan() options.
29226
29227
2922844.4 Available Exim variables
29229-----------------------------
29230
29231The header local_scan.h gives you access to a number of C variables. These are
29232the only ones that are guaranteed to be maintained from release to release.
29233Note, however, that you can obtain the value of any Exim expansion variable,
29234including $recipients, by calling expand_string(). The exported C variables are
29235as follows:
29236
29237int body_linecount
29238
29239 This variable contains the number of lines in the message's body.
29240
29241int body_zerocount
29242
29243 This variable contains the number of binary zero bytes in the message's
29244 body.
29245
29246unsigned int debug_selector
29247
29248 This variable is set to zero when no debugging is taking place. Otherwise,
29249 it is a bitmap of debugging selectors. Two bits are identified for use in
29250 local_scan(); they are defined as macros:
29251
29252 * The "D_v" bit is set when -v was present on the command line. This is a
29253 testing option that is not privileged - any caller may set it. All the
29254 other selector bits can be set only by admin users.
29255
29256 * The "D_local_scan" bit is provided for use by local_scan(); it is set
29257 by the "+local_scan" debug selector. It is not included in the default
29258 set of debugging bits.
29259
29260 Thus, to write to the debugging output only when "+local_scan" has been
29261 selected, you should use code like this:
29262
29263 if ((debug_selector & D_local_scan) != 0)
29264 debug_printf("xxx", ...);
29265
29266uschar *expand_string_message
29267
29268 After a failing call to expand_string() (returned value NULL), the variable
29269 expand_string_message contains the error message, zero-terminated.
29270
29271header_line *header_list
29272
29273 A pointer to a chain of header lines. The header_line structure is
29274 discussed below.
29275
29276header_line *header_last
29277
29278 A pointer to the last of the header lines.
29279
29280uschar *headers_charset
29281
29282 The value of the headers_charset configuration option.
29283
29284BOOL host_checking
29285
29286 This variable is TRUE during a host checking session that is initiated by
29287 the -bh command line option.
29288
29289uschar *interface_address
29290
29291 The IP address of the interface that received the message, as a string.
29292 This is NULL for locally submitted messages.
29293
29294int interface_port
29295
29296 The port on which this message was received. When testing with the -bh
29297 command line option, the value of this variable is -1 unless a port has
29298 been specified via the -oMi option.
29299
29300uschar *message_id
29301
29302 This variable contains Exim's message id for the incoming message (the
29303 value of $message_exim_id) as a zero-terminated string.
29304
29305uschar *received_protocol
29306
29307 The name of the protocol by which the message was received.
29308
29309int recipients_count
29310
29311 The number of accepted recipients.
29312
29313recipient_item *recipients_list
29314
29315 The list of accepted recipients, held in a vector of length
29316 recipients_count. The recipient_item structure is discussed below. You can
29317 add additional recipients by calling receive_add_recipient() (see below).
29318 You can delete recipients by removing them from the vector and adjusting
29319 the value in recipients_count. In particular, by setting recipients_count
29320 to zero you remove all recipients. If you then return the value
29321 "LOCAL_SCAN_ACCEPT", the message is accepted, but immediately blackholed.
29322 To replace the recipients, you can set recipients_count to zero and then
29323 call receive_add_recipient() as often as needed.
29324
29325uschar *sender_address
29326
29327 The envelope sender address. For bounce messages this is the empty string.
29328
29329uschar *sender_host_address
29330
29331 The IP address of the sending host, as a string. This is NULL for
29332 locally-submitted messages.
29333
29334uschar *sender_host_authenticated
29335
29336 The name of the authentication mechanism that was used, or NULL if the
29337 message was not received over an authenticated SMTP connection.
29338
29339uschar *sender_host_name
29340
29341 The name of the sending host, if known.
29342
29343int sender_host_port
29344
29345 The port on the sending host.
29346
29347BOOL smtp_input
29348
29349 This variable is TRUE for all SMTP input, including BSMTP.
29350
29351BOOL smtp_batched_input
29352
29353 This variable is TRUE for BSMTP input.
29354
29355int store_pool
29356
29357 The contents of this variable control which pool of memory is used for new
29358 requests. See section 44.8 for details.
29359
29360
2936144.5 Structure of header lines
29362------------------------------
29363
29364The header_line structure contains the members listed below. You can add
29365additional header lines by calling the header_add() function (see below). You
29366can cause header lines to be ignored (deleted) by setting their type to *.
29367
29368struct header_line *next
29369
29370 A pointer to the next header line, or NULL for the last line.
29371
29372int type
29373
29374 A code identifying certain headers that Exim recognizes. The codes are
29375 printing characters, and are documented in chapter 55 of this manual.
29376 Notice in particular that any header line whose type is * is not
29377 transmitted with the message. This flagging is used for header lines that
29378 have been rewritten, or are to be removed (for example, Envelope-sender:
29379 header lines.) Effectively, * means "deleted".
29380
29381int slen
29382
29383 The number of characters in the header line, including the terminating and
29384 any internal newlines.
29385
29386uschar *text
29387
29388 A pointer to the text of the header. It always ends with a newline,
29389 followed by a zero byte. Internal newlines are preserved.
29390
29391
2939244.6 Structure of recipient items
29393---------------------------------
29394
29395The recipient_item structure contains these members:
29396
29397uschar *address
29398
29399 This is a pointer to the recipient address as it was received.
29400
29401int pno
29402
29403 This is used in later Exim processing when top level addresses are created
29404 by the one_time option. It is not relevant at the time local_scan() is run
29405 and must always contain -1 at this stage.
29406
29407uschar *errors_to
29408
29409 If this value is not NULL, bounce messages caused by failing to deliver to
29410 the recipient are sent to the address it contains. In other words, it
29411 overrides the envelope sender for this one recipient. (Compare the
29412 errors_to generic router option.) If a local_scan() function sets an
29413 errors_to field to an unqualified address, Exim qualifies it using the
29414 domain from qualify_recipient. When local_scan() is called, the errors_to
29415 field is NULL for all recipients.
29416
29417
2941844.7 Available Exim functions
29419-----------------------------
29420
29421The header local_scan.h gives you access to a number of Exim functions. These
29422are the only ones that are guaranteed to be maintained from release to release:
29423
29424pid_t child_open
29425 (uschar **argv, uschar **envp, int newumask, int *infdptr, int *outfdptr,
29426 BOOL make_leader)
29427
29428 This function creates a child process that runs the command specified by
29429 argv. The environment for the process is specified by envp, which can be
29430 NULL if no environment variables are to be passed. A new umask is supplied
29431 for the process in newumask.
29432
29433 Pipes to the standard input and output of the new process are set up and
29434 returned to the caller via the infdptr and outfdptr arguments. The standard
29435 error is cloned to the standard output. If there are any file descriptors
29436 "in the way" in the new process, they are closed. If the final argument is
29437 TRUE, the new process is made into a process group leader.
29438
29439 The function returns the pid of the new process, or -1 if things go wrong.
29440
29441int child_close(pid_t pid, int timeout)
29442
29443 This function waits for a child process to terminate, or for a timeout (in
29444 seconds) to expire. A timeout value of zero means wait as long as it takes.
29445 The return value is as follows:
29446
29447 * >= 0
29448
29449 The process terminated by a normal exit and the value is the process
29450 ending status.
29451
29452 * < 0 and > -256
29453
29454 The process was terminated by a signal and the value is the negation of
29455 the signal number.
29456
29457 * -256
29458
29459 The process timed out.
29460
29461 * -257
29462
29463 The was some other error in wait(); errno is still set.
29464
29465pid_t child_open_exim(int *fd)
29466
29467 This function provide you with a means of submitting a new message to Exim.
29468 (Of course, you can also call /usr/sbin/sendmail yourself if you want, but
29469 this packages it all up for you.) The function creates a pipe, forks a
29470 subprocess that is running
29471
29472 exim -t -oem -oi -f <>
29473
29474 and returns to you (via the "int *" argument) a file descriptor for the
29475 pipe that is connected to the standard input. The yield of the function is
29476 the PID of the subprocess. You can then write a message to the file
29477 descriptor, with recipients in To:, Cc:, and/or Bcc: header lines.
29478
29479 When you have finished, call child_close() to wait for the process to
29480 finish and to collect its ending status. A timeout value of zero is usually
29481 fine in this circumstance. Unless you have made a mistake with the
29482 recipient addresses, you should get a return code of zero.
29483
29484pid_t child_open_exim2(int *fd, uschar *sender, uschar *sender_authentication)
29485
29486 This function is a more sophisticated version of child_open(). The command
29487 that it runs is:
29488
29489 exim -t -oem -oi -f sender -oMas sender_authentication
29490
29491 The third argument may be NULL, in which case the -oMas option is omitted.
29492
29493void debug_printf(char *, ...)
29494
29495 This is Exim's debugging function, with arguments as for (printf(). The
29496 output is written to the standard error stream. If no debugging is
29497 selected, calls to debug_printf() have no effect. Normally, you should make
29498 calls conditional on the "local_scan" debug selector by coding like this:
29499
29500 if ((debug_selector & D_local_scan) != 0)
29501 debug_printf("xxx", ...);
29502
29503uschar *expand_string(uschar *string)
29504
29505 This is an interface to Exim's string expansion code. The return value is
29506 the expanded string, or NULL if there was an expansion failure. The C
29507 variable expand_string_message contains an error message after an expansion
29508 failure. If expansion does not change the string, the return value is the
29509 pointer to the input string. Otherwise, the return value points to a new
29510 block of memory that was obtained by a call to store_get(). See section
29511 44.8 below for a discussion of memory handling.
29512
29513void header_add(int type, char *format, ...)
29514
29515 This function allows you to an add additional header line at the end of the
29516 existing ones. The first argument is the type, and should normally be a
29517 space character. The second argument is a format string and any number of
29518 substitution arguments as for sprintf(). You may include internal newlines
29519 if you want, and you must ensure that the string ends with a newline.
29520
29521void header_add_at_position
29522 (BOOL after, uschar *name, BOOL topnot, int type, char *format, ...)
29523
29524 This function adds a new header line at a specified point in the header
29525 chain. The header itself is specified as for header_add().
29526
29527 If name is NULL, the new header is added at the end of the chain if after
29528 is true, or at the start if after is false. If name is not NULL, the header
29529 lines are searched for the first non-deleted header that matches the name.
29530 If one is found, the new header is added before it if after is false. If
29531 after is true, the new header is added after the found header and any
29532 adjacent subsequent ones with the same name (even if marked "deleted"). If
29533 no matching non-deleted header is found, the topnot option controls where
29534 the header is added. If it is true, addition is at the top; otherwise at
29535 the bottom. Thus, to add a header after all the Received: headers, or at
29536 the top if there are no Received: headers, you could use
29537
29538 header_add_at_position(TRUE, US"Received", TRUE,
29539 ' ', "X-xxx: ...");
29540
29541 Normally, there is always at least one non-deleted Received: header, but
29542 there may not be if received_header_text expands to an empty string.
29543
29544void header_remove(int occurrence, uschar *name)
29545
29546 This function removes header lines. If occurrence is zero or negative, all
29547 occurrences of the header are removed. If occurrence is greater than zero,
29548 that particular instance of the header is removed. If no header(s) can be
29549 found that match the specification, the function does nothing.
29550
29551BOOL header_testname(header_line *hdr, uschar *name, int length, BOOL notdel)
29552
29553 This function tests whether the given header has the given name. It is not
29554 just a string comparison, because white space is permitted between the name
29555 and the colon. If the notdel argument is true, a false return is forced for
29556 all "deleted" headers; otherwise they are not treated specially. For
29557 example:
29558
29559 if (header_testname(h, US"X-Spam", 6, TRUE)) ...
29560
29561uschar *lss_b64encode(uschar *cleartext, int length)
29562
29563 This function base64-encodes a string, which is passed by address and
29564 length. The text may contain bytes of any value, including zero. The result
29565 is passed back in dynamic memory that is obtained by calling store_get().
29566 It is zero-terminated.
29567
29568int lss_b64decode(uschar *codetext, uschar **cleartext)
29569
29570 This function decodes a base64-encoded string. Its arguments are a
29571 zero-terminated base64-encoded string and the address of a variable that is
29572 set to point to the result, which is in dynamic memory. The length of the
29573 decoded string is the yield of the function. If the input is invalid base64
29574 data, the yield is -1. A zero byte is added to the end of the output string
29575 to make it easy to interpret as a C string (assuming it contains no zeros
29576 of its own). The added zero byte is not included in the returned count.
29577
29578int lss_match_domain(uschar *domain, uschar *list)
29579
29580 This function checks for a match in a domain list. Domains are always
29581 matched caselessly. The return value is one of the following:
29582
29583 OK match succeeded
29584 FAIL match failed
29585 DEFER match deferred
29586
29587 DEFER is usually caused by some kind of lookup defer, such as the inability
29588 to contact a database.
29589
29590int lss_match_local_part(uschar *localpart, uschar *list, BOOL caseless)
29591
29592 This function checks for a match in a local part list. The third argument
29593 controls case-sensitivity. The return values are as for lss_match_domain().
29594
29595int lss_match_address(uschar *address, uschar *list, BOOL caseless)
29596
29597 This function checks for a match in an address list. The third argument
29598 controls the case-sensitivity of the local part match. The domain is always
29599 matched caselessly. The return values are as for lss_match_domain().
29600
29601int lss_match_host(uschar *host_name, uschar *host_address, uschar *list)
29602
29603 This function checks for a match in a host list. The most common usage is
29604 expected to be
29605
29606 lss_match_host(sender_host_name, sender_host_address, ...)
29607
29608 An empty address field matches an empty item in the host list. If the host
29609 name is NULL, the name corresponding to $sender_host_address is
29610 automatically looked up if a host name is required to match an item in the
29611 list. The return values are as for lss_match_domain(), but in addition,
29612 lss_match_host() returns ERROR in the case when it had to look up a host
29613 name, but the lookup failed.
29614
29615void log_write(unsigned int selector, int which, char *format, ...)
29616
29617 This function writes to Exim's log files. The first argument should be zero
29618 (it is concerned with log_selector). The second argument can be "LOG_MAIN"
29619 or "LOG_REJECT" or "LOG_PANIC" or the inclusive "or" of any combination of
29620 them. It specifies to which log or logs the message is written. The
29621 remaining arguments are a format and relevant insertion arguments. The
29622 string should not contain any newlines, not even at the end.
29623
29624void receive_add_recipient(uschar *address, int pno)
29625
29626 This function adds an additional recipient to the message. The first
29627 argument is the recipient address. If it is unqualified (has no domain), it
29628 is qualified with the qualify_recipient domain. The second argument must
29629 always be -1.
29630
29631 This function does not allow you to specify a private errors_to address (as
29632 described with the structure of recipient_item above), because it pre-dates
29633 the addition of that field to the structure. However, it is easy to add
29634 such a value afterwards. For example:
29635
29636 receive_add_recipient(US"monitor@mydom.example", -1);
29637 recipients_list[recipients_count-1].errors_to =
29638 US"postmaster@mydom.example";
29639
29640BOOL receive_remove_recipient(uschar *recipient)
29641
29642 This is a convenience function to remove a named recipient from the list of
29643 recipients. It returns true if a recipient was removed, and false if no
29644 matching recipient could be found. The argument must be a complete email
29645 address.
29646
29647uschar rfc2047_decode
29648 (uschar *string, BOOL lencheck, uschar *target, int zeroval, int *lenptr,
29649 uschar **error)
29650
29651 This function decodes strings that are encoded according to RFC 2047.
29652 Typically these are the contents of header lines. First, each "encoded
29653 word" is decoded from the Q or B encoding into a byte-string. Then, if
29654 provided with the name of a charset encoding, and if the iconv() function
29655 is available, an attempt is made to translate the result to the named
29656 character set. If this fails, the binary string is returned with an error
29657 message.
29658
29659 The first argument is the string to be decoded. If lencheck is TRUE, the
29660 maximum MIME word length is enforced. The third argument is the target
29661 encoding, or NULL if no translation is wanted.
29662
29663 If a binary zero is encountered in the decoded string, it is replaced by
29664 the contents of the zeroval argument. For use with Exim headers, the value
29665 must not be 0 because header lines are handled as zero-terminated strings.
29666
29667 The function returns the result of processing the string, zero-terminated;
29668 if lenptr is not NULL, the length of the result is set in the variable to
29669 which it points. When zeroval is 0, lenptr should not be NULL.
29670
29671 If an error is encountered, the function returns NULL and uses the error
29672 argument to return an error message. The variable pointed to by error is
29673 set to NULL if there is no error; it may be set non-NULL even when the
29674 function returns a non-NULL value if decoding was successful, but there was
29675 a problem with translation.
29676
29677int smtp_fflush(void)
29678
29679 This function is used in conjunction with smtp_printf(), as described
29680 below.
29681
29682void smtp_printf(char *, ...)
29683
29684 The arguments of this function are like printf(); it writes to the SMTP
29685 output stream. You should use this function only when there is an SMTP
29686 output stream, that is, when the incoming message is being received via
29687 interactive SMTP. This is the case when smtp_input is TRUE and
29688 smtp_batched_input is FALSE. If you want to test for an incoming message
29689 from another host (as opposed to a local process that used the -bs command
29690 line option), you can test the value of sender_host_address, which is
29691 non-NULL when a remote host is involved.
29692
29693 If an SMTP TLS connection is established, smtp_printf() uses the TLS output
29694 function, so it can be used for all forms of SMTP connection.
29695
29696 Strings that are written by smtp_printf() from within local_scan() must
29697 start with an appropriate response code: 550 if you are going to return
29698 LOCAL_SCAN_REJECT, 451 if you are going to return LOCAL_SCAN_TEMPREJECT,
29699 and 250 otherwise. Because you are writing the initial lines of a
29700 multi-line response, the code must be followed by a hyphen to indicate that
29701 the line is not the final response line. You must also ensure that the
29702 lines you write terminate with CRLF. For example:
29703
29704 smtp_printf("550-this is some extra info\r\n");
29705 return LOCAL_SCAN_REJECT;
29706
29707 Note that you can also create multi-line responses by including newlines in
29708 the data returned via the return_text argument. The added value of using
29709 smtp_printf() is that, for instance, you could introduce delays between
29710 multiple output lines.
29711
29712 The smtp_printf() function does not return any error indication, because it
29713 does not automatically flush pending output, and therefore does not test
29714 the state of the stream. (In the main code of Exim, flushing and error
29715 detection is done when Exim is ready for the next SMTP input command.) If
29716 you want to flush the output and check for an error (for example, the
29717 dropping of a TCP/IP connection), you can call smtp_fflush(), which has no
29718 arguments. It flushes the output stream, and returns a non-zero value if
29719 there is an error.
29720
29721void *store_get(int)
29722
29723 This function accesses Exim's internal store (memory) manager. It gets a
29724 new chunk of memory whose size is given by the argument. Exim bombs out if
29725 it ever runs out of memory. See the next section for a discussion of memory
29726 handling.
29727
29728void *store_get_perm(int)
29729
29730 This function is like store_get(), but it always gets memory from the
29731 permanent pool. See the next section for a discussion of memory handling.
29732
29733uschar *string_copy(uschar *string)
29734
29735 See below.
29736
29737uschar *string_copyn(uschar *string, int length)
29738
29739 See below.
29740
29741uschar *string_sprintf(char *format, ...)
29742
29743 These three functions create strings using Exim's dynamic memory
29744 facilities. The first makes a copy of an entire string. The second copies
29745 up to a maximum number of characters, indicated by the second argument. The
29746 third uses a format and insertion arguments to create a new string. In each
29747 case, the result is a pointer to a new string in the current memory pool.
29748 See the next section for more discussion.
29749
29750
2975144.8 More about Exim's memory handling
29752--------------------------------------
29753
29754No function is provided for freeing memory, because that is never needed. The
29755dynamic memory that Exim uses when receiving a message is automatically
29756recycled if another message is received by the same process (this applies only
29757to incoming SMTP connections - other input methods can supply only one message
29758at a time). After receiving the last message, a reception process terminates.
29759
29760Because it is recycled, the normal dynamic memory cannot be used for holding
29761data that must be preserved over a number of incoming messages on the same SMTP
29762connection. However, Exim in fact uses two pools of dynamic memory; the second
29763one is not recycled, and can be used for this purpose.
29764
29765If you want to allocate memory that remains available for subsequent messages
29766in the same SMTP connection, you should set
29767
29768store_pool = POOL_PERM
29769
29770before calling the function that does the allocation. There is no need to
29771restore the value if you do not need to; however, if you do want to revert to
29772the normal pool, you can either restore the previous value of store_pool or set
29773it explicitly to POOL_MAIN.
29774
29775The pool setting applies to all functions that get dynamic memory, including
29776expand_string(), store_get(), and the string_xxx() functions. There is also a
29777convenience function called store_get_perm() that gets a block of memory from
29778the permanent pool while preserving the value of store_pool.
29779
29780
29781
29782===============================================================================
2978345. SYSTEM-WIDE MESSAGE FILTERING
29784
29785The previous chapters (on ACLs and the local scan function) describe checks
29786that can be applied to messages before they are accepted by a host. There is
29787also a mechanism for checking messages once they have been received, but before
29788they are delivered. This is called the system filter.
29789
29790The system filter operates in a similar manner to users' filter files, but it
29791is run just once per message (however many recipients the message has). It
29792should not normally be used as a substitute for routing, because deliver
29793commands in a system router provide new envelope recipient addresses. The
29794system filter must be an Exim filter. It cannot be a Sieve filter.
29795
29796The system filter is run at the start of a delivery attempt, before any routing
29797is done. If a message fails to be completely delivered at the first attempt,
29798the system filter is run again at the start of every retry. If you want your
29799filter to do something only once per message, you can make use of the
29800first_delivery condition in an if command in the filter to prevent it happening
29801on retries.
29802
29803Warning: Because the system filter runs just once, variables that are specific
29804to individual recipient addresses, such as $local_part and $domain, are not
29805set, and the "personal" condition is not meaningful. If you want to run a
29806centrally-specified filter for each recipient address independently, you can do
29807so by setting up a suitable redirect router, as described in section 45.8
29808below.
29809
29810
2981145.1 Specifying a system filter
29812-------------------------------
29813
29814The name of the file that contains the system filter must be specified by
29815setting system_filter. If you want the filter to run under a uid and gid other
29816than root, you must also set system_filter_user and system_filter_group as
29817appropriate. For example:
29818
29819system_filter = /etc/mail/exim.filter
29820system_filter_user = exim
29821
29822If a system filter generates any deliveries directly to files or pipes (via the
29823save or pipe commands), transports to handle these deliveries must be specified
29824by setting system_filter_file_transport and system_filter_pipe_transport,
29825respectively. Similarly, system_filter_reply_transport must be set to handle
29826any messages generated by the reply command.
29827
29828
2982945.2 Testing a system filter
29830----------------------------
29831
29832You can run simple tests of a system filter in the same way as for a user
29833filter, but you should use -bF rather than -bf, so that features that are
29834permitted only in system filters are recognized.
29835
29836If you want to test the combined effect of a system filter and a user filter,
29837you can use both -bF and -bf on the same command line.
29838
29839
2984045.3 Contents of a system filter
29841--------------------------------
29842
29843The language used to specify system filters is the same as for users' filter
29844files. It is described in the separate end-user document Exim's interface to
29845mail filtering. However, there are some additional features that are available
29846only in system filters; these are described in subsequent sections. If they are
29847encountered in a user's filter file or when testing with -bf, they cause
29848errors.
29849
29850There are two special conditions which, though available in users' filter
29851files, are designed for use in system filters. The condition first_delivery is
29852true only for the first attempt at delivering a message, and manually_thawed is
29853true only if the message has been frozen, and subsequently thawed by an admin
29854user. An explicit forced delivery counts as a manual thaw, but thawing as a
29855result of the auto_thaw setting does not.
29856
29857Warning: If a system filter uses the first_delivery condition to specify an
29858"unseen" (non-significant) delivery, and that delivery does not succeed, it
29859will not be tried again. If you want Exim to retry an unseen delivery until it
29860succeeds, you should arrange to set it up every time the filter runs.
29861
29862When a system filter finishes running, the values of the variables $n0 - $n9
29863are copied into $sn0 - $sn9 and are thereby made available to users' filter
29864files. Thus a system filter can, for example, set up "scores" to which users'
29865filter files can refer.
29866
29867
2986845.4 Additional variable for system filters
29869-------------------------------------------
29870
29871The expansion variable $recipients, containing a list of all the recipients of
29872the message (separated by commas and white space), is available in system
29873filters. It is not available in users' filters for privacy reasons.
29874
29875
2987645.5 Defer, freeze, and fail commands for system filters
29877--------------------------------------------------------
29878
29879There are three extra commands (defer, freeze and fail) which are always
29880available in system filters, but are not normally enabled in users' filters.
29881(See the allow_defer, allow_freeze and allow_fail options for the redirect
29882router.) These commands can optionally be followed by the word text and a
29883string containing an error message, for example:
29884
29885fail text "this message looks like spam to me"
29886
29887The keyword text is optional if the next character is a double quote.
29888
29889The defer command defers delivery of the original recipients of the message.
29890The fail command causes all the original recipients to be failed, and a bounce
29891message to be created. The freeze command suspends all delivery attempts for
29892the original recipients. In all cases, any new deliveries that are specified by
29893the filter are attempted as normal after the filter has run.
29894
29895The freeze command is ignored if the message has been manually unfrozen and not
29896manually frozen since. This means that automatic freezing by a system filter
29897can be used as a way of checking out suspicious messages. If a message is found
29898to be all right, manually unfreezing it allows it to be delivered.
29899
29900The text given with a fail command is used as part of the bounce message as
29901well as being written to the log. If the message is quite long, this can fill
29902up a lot of log space when such failures are common. To reduce the size of the
29903log message, Exim interprets the text in a special way if it starts with the
29904two characters "<<" and contains ">>" later. The text between these two strings
29905is written to the log, and the rest of the text is used in the bounce message.
29906For example:
29907
29908fail "<<filter test 1>>Your message is rejected \
29909 because it contains attachments that we are \
29910 not prepared to receive."
29911
29912Take great care with the fail command when basing the decision to fail on the
29913contents of the message, because the bounce message will of course include the
29914contents of the original message and will therefore trigger the fail command
29915again (causing a mail loop) unless steps are taken to prevent this. Testing the
29916error_message condition is one way to prevent this. You could use, for example
29917
29918if $message_body contains "this is spam" and not error_message
29919then fail text "spam is not wanted here" endif
29920
29921though of course that might let through unwanted bounce messages. The
29922alternative is clever checking of the body and/or headers to detect bounces
29923generated by the filter.
29924
29925The interpretation of a system filter file ceases after a defer, freeze, or
29926fail command is obeyed. However, any deliveries that were set up earlier in the
29927filter file are honoured, so you can use a sequence such as
29928
29929mail ...
29930freeze
29931
29932to send a specified message when the system filter is freezing (or deferring or
29933failing) a message. The normal deliveries for the message do not, of course,
29934take place.
29935
29936
2993745.6 Adding and removing headers in a system filter
29938---------------------------------------------------
29939
29940Two filter commands that are available only in system filters are:
29941
29942headers add <string>
29943headers remove <string>
29944
29945The argument for the headers add is a string that is expanded and then added to
29946the end of the message's headers. It is the responsibility of the filter
29947maintainer to make sure it conforms to RFC 2822 syntax. Leading white space is
29948ignored, and if the string is otherwise empty, or if the expansion is forced to
29949fail, the command has no effect.
29950
29951You can use "\n" within the string, followed by white space, to specify
29952continued header lines. More than one header may be added in one command by
29953including "\n" within the string without any following white space. For
29954example:
29955
29956headers add "X-header-1: ....\n \
29957 continuation of X-header-1 ...\n\
29958 X-header-2: ...."
29959
29960Note that the header line continuation white space after the first newline must
29961be placed before the backslash that continues the input string, because white
29962space after input continuations is ignored.
29963
29964The argument for headers remove is a colon-separated list of header names. This
29965command applies only to those headers that are stored with the message; those
29966that are added at delivery time (such as Envelope-To: and Return-Path:) cannot
29967be removed by this means. If there is more than one header with the same name,
29968they are all removed.
29969
29970The headers command in a system filter makes an immediate change to the set of
29971header lines that was received with the message (with possible additions from
29972ACL processing). Subsequent commands in the system filter operate on the
29973modified set, which also forms the basis for subsequent message delivery.
29974Unless further modified during routing or transporting, this set of headers is
29975used for all recipients of the message.
29976
29977During routing and transporting, the variables that refer to the contents of
29978header lines refer only to those lines that are in this set. Thus, header lines
29979that are added by a system filter are visible to users' filter files and to all
29980routers and transports. This contrasts with the manipulation of header lines by
29981routers and transports, which is not immediate, but which instead is saved up
29982until the message is actually being written (see section 46.17).
29983
29984If the message is not delivered at the first attempt, header lines that were
29985added by the system filter are stored with the message, and so are still
29986present at the next delivery attempt. Header lines that were removed are still
29987present, but marked "deleted" so that they are not transported with the
29988message. For this reason, it is usual to make the headers command conditional
29989on first_delivery so that the set of header lines is not modified more than
29990once.
29991
29992Because header modification in a system filter acts immediately, you have to
29993use an indirect approach if you want to modify the contents of a header line.
29994For example:
29995
29996headers add "Old-Subject: $h_subject:"
29997headers remove "Subject"
29998headers add "Subject: new subject (was: $h_old-subject:)"
29999headers remove "Old-Subject"
30000
30001
3000245.7 Setting an errors address in a system filter
30003-------------------------------------------------
30004
30005In a system filter, if a deliver command is followed by
30006
30007errors_to <some address>
30008
30009in order to change the envelope sender (and hence the error reporting) for that
30010delivery, any address may be specified. (In a user filter, only the current
30011user's address can be set.) For example, if some mail is being monitored, you
30012might use
30013
30014unseen deliver monitor@spying.example errors_to root@local.example
30015
30016to take a copy which would not be sent back to the normal error reporting
30017address if its delivery failed.
30018
30019
3002045.8 Per-address filtering
30021--------------------------
30022
30023In contrast to the system filter, which is run just once per message for each
30024delivery attempt, it is also possible to set up a system-wide filtering
30025operation that runs once for each recipient address. In this case, variables
30026such as $local_part and $domain can be used, and indeed, the choice of filter
30027file could be made dependent on them. This is an example of a router which
30028implements such a filter:
30029
30030central_filter:
30031 check_local_user
30032 driver = redirect
30033 domains = +local_domains
30034 file = /central/filters/$local_part
30035 no_verify
30036 allow_filter
30037 allow_freeze
30038
30039The filter is run in a separate process under its own uid. Therefore, either
30040check_local_user must be set (as above), in which case the filter is run as the
30041local user, or the user option must be used to specify which user to use. If
30042both are set, user overrides.
30043
30044Care should be taken to ensure that none of the commands in the filter file
30045specify a significant delivery if the message is to go on to be delivered to
30046its intended recipient. The router will not then claim to have dealt with the
30047address, so it will be passed on to subsequent routers to be delivered in the
30048normal way.
30049
30050
30051
30052===============================================================================
3005346. MESSAGE PROCESSING
30054
30055Exim performs various transformations on the sender and recipient addresses of
30056all messages that it handles, and also on the messages' header lines. Some of
30057these are optional and configurable, while others always take place. All of
30058this processing, except rewriting as a result of routing, and the addition or
30059removal of header lines while delivering, happens when a message is received,
30060before it is placed on Exim's queue.
30061
30062Some of the automatic processing takes place by default only for
30063"locally-originated" messages. This adjective is used to describe messages that
30064are not received over TCP/IP, but instead are passed to an Exim process on its
30065standard input. This includes the interactive "local SMTP" case that is set up
30066by the -bs command line option.
30067
30068Note: Messages received over TCP/IP on the loopback interface (127.0.0.1 or
30069::1) are not considered to be locally-originated. Exim does not treat the
30070loopback interface specially in any way.
30071
30072If you want the loopback interface to be treated specially, you must ensure
30073that there are appropriate entries in your ACLs.
30074
30075
3007646.1 Submission mode for non-local messages
30077-------------------------------------------
30078
30079Processing that happens automatically for locally-originated messages (unless
30080suppress_local_fixups is set) can also be requested for messages that are
30081received over TCP/IP. The term "submission mode" is used to describe this
30082state. Submission mode is set by the modifier
30083
30084control = submission
30085
30086in a MAIL, RCPT, or pre-data ACL for an incoming message (see sections 42.21
30087and 42.22). This makes Exim treat the message as a local submission, and is
30088normally used when the source of the message is known to be an MUA running on a
30089client host (as opposed to an MTA). For example, to set submission mode for
30090messages originating on the IPv4 loopback interface, you could include the
30091following in the MAIL ACL:
30092
30093warn hosts = 127.0.0.1
30094 control = submission
30095
30096There are some options that can be used when setting submission mode. A slash
30097is used to separate options. For example:
30098
30099control = submission/sender_retain
30100
30101Specifying sender_retain has the effect of setting local_sender_retain true and
30102local_from_check false for the current incoming message. The first of these
30103allows an existing Sender: header in the message to remain, and the second
30104suppresses the check to ensure that From: matches the authenticated sender.
30105With this setting, Exim still fixes up messages by adding Date: and Message-ID:
30106header lines if they are missing, but makes no attempt to check sender
30107authenticity in header lines.
30108
30109When sender_retain is not set, a submission mode setting may specify a domain
30110to be used when generating a From: or Sender: header line. For example:
30111
30112control = submission/domain=some.domain
30113
30114The domain may be empty. How this value is used is described in sections 46.11
30115and 46.16. There is also a name option that allows you to specify the user's
30116full name for inclusion in a created Sender: or From: header line. For example:
30117
30118accept authenticated = *
30119 control = submission/domain=wonderland.example/\
30120 name=${lookup {$authenticated_id} \
30121 lsearch {/etc/exim/namelist}}
30122
30123Because the name may contain any characters, including slashes, the name option
30124must be given last. The remainder of the string is used as the name. For the
30125example above, if /etc/exim/namelist contains:
30126
30127bigegg: Humpty Dumpty
30128
30129then when the sender has authenticated as bigegg, the generated Sender: line
30130would be:
30131
30132Sender: Humpty Dumpty <bigegg@wonderland.example>
30133
30134By default, submission mode forces the return path to the same address as is
30135used to create the Sender: header. However, if sender_retain is specified, the
30136return path is also left unchanged.
30137
30138Note: The changes caused by submission mode take effect after the predata ACL.
30139This means that any sender checks performed before the fix-ups use the
30140untrusted sender address specified by the user, not the trusted sender address
30141specified by submission mode. Although this might be slightly unexpected, it
30142does mean that you can configure ACL checks to spot that a user is trying to
30143spoof another's address.
30144
30145
3014646.2 Line endings
30147-----------------
30148
30149RFC 2821 specifies that CRLF (two characters: carriage-return, followed by
30150linefeed) is the line ending for messages transmitted over the Internet using
30151SMTP over TCP/IP. However, within individual operating systems, different
30152conventions are used. For example, Unix-like systems use just LF, but others
30153use CRLF or just CR.
30154
30155Exim was designed for Unix-like systems, and internally, it stores messages
30156using the system's convention of a single LF as a line terminator. When
30157receiving a message, all line endings are translated to this standard format.
30158Originally, it was thought that programs that passed messages directly to an
30159MTA within an operating system would use that system's convention. Experience
30160has shown that this is not the case; for example, there are Unix applications
30161that use CRLF in this circumstance. For this reason, and for compatibility with
30162other MTAs, the way Exim handles line endings for all messages is now as
30163follows:
30164
30165 * LF not preceded by CR is treated as a line ending.
30166
30167 * CR is treated as a line ending; if it is immediately followed by LF, the LF
30168 is ignored.
30169
30170 * The sequence "CR, dot, CR" does not terminate an incoming SMTP message, nor
30171 a local message in the state where a line containing only a dot is a
30172 terminator.
30173
30174 * If a bare CR is encountered within a header line, an extra space is added
30175 after the line terminator so as not to end the header line. The reasoning
30176 behind this is that bare CRs in header lines are most likely either to be
30177 mistakes, or people trying to play silly games.
30178
30179 * If the first header line received in a message ends with CRLF, a subsequent
30180 bare LF in a header line is treated in the same way as a bare CR in a
30181 header line.
30182
30183
3018446.3 Unqualified addresses
30185--------------------------
30186
30187By default, Exim expects every envelope address it receives from an external
30188host to be fully qualified. Unqualified addresses cause negative responses to
30189SMTP commands. However, because SMTP is used as a means of transporting
30190messages from MUAs running on personal workstations, there is sometimes a
30191requirement to accept unqualified addresses from specific hosts or IP networks.
30192
30193Exim has two options that separately control which hosts may send unqualified
30194sender or recipient addresses in SMTP commands, namely sender_unqualified_hosts
30195and recipient_unqualified_hosts. In both cases, if an unqualified address is
30196accepted, it is qualified by adding the value of qualify_domain or
30197qualify_recipient, as appropriate.
30198
30199Unqualified addresses in header lines are automatically qualified for messages
30200that are locally originated, unless the -bnq option is given on the command
30201line. For messages received over SMTP, unqualified addresses in header lines
30202are qualified only if unqualified addresses are permitted in SMTP commands. In
30203other words, such qualification is also controlled by sender_unqualified_hosts
30204and recipient_unqualified_hosts,
30205
30206
3020746.4 The UUCP From line
30208-----------------------
30209
30210Messages that have come from UUCP (and some other applications) often begin
30211with a line containing the envelope sender and a timestamp, following the word
30212"From". Examples of two common formats are:
30213
30214From a.oakley@berlin.mus Fri Jan 5 12:35 GMT 1996
30215From f.butler@berlin.mus Fri, 7 Jan 97 14:00:00 GMT
30216
30217This line precedes the RFC 2822 header lines. For compatibility with Sendmail,
30218Exim recognizes such lines at the start of messages that are submitted to it
30219via the command line (that is, on the standard input). It does not recognize
30220such lines in incoming SMTP messages, unless the sending host matches
30221ignore_fromline_hosts or the -bs option was used for a local message and
30222ignore_fromline_local is set. The recognition is controlled by a regular
30223expression that is defined by the uucp_from_pattern option, whose default value
30224matches the two common cases shown above and puts the address that follows
30225"From" into $1.
30226
30227When the caller of Exim for a non-SMTP message that contains a "From" line is a
30228trusted user, the message's sender address is constructed by expanding the
30229contents of uucp_sender_address, whose default value is "$1". This is then
30230parsed as an RFC 2822 address. If there is no domain, the local part is
30231qualified with qualify_domain unless it is the empty string. However, if the
30232command line -f option is used, it overrides the "From" line.
30233
30234If the caller of Exim is not trusted, the "From" line is recognized, but the
30235sender address is not changed. This is also the case for incoming SMTP messages
30236that are permitted to contain "From" lines.
30237
30238Only one "From" line is recognized. If there is more than one, the second is
30239treated as a data line that starts the body of the message, as it is not valid
30240as a header line. This also happens if a "From" line is present in an incoming
30241SMTP message from a source that is not permitted to send them.
30242
30243
3024446.5 Resent- header lines
30245-------------------------
30246
30247RFC 2822 makes provision for sets of header lines starting with the string
30248"Resent-" to be added to a message when it is resent by the original recipient
30249to somebody else. These headers are Resent-Date:, Resent-From:, Resent-Sender:,
30250Resent-To:, Resent-Cc:, Resent-Bcc: and Resent-Message-ID:. The RFC says:
30251
30252 Resent fields are strictly informational. They MUST NOT be used in the
30253 normal processing of replies or other such automatic actions on messages.
30254
30255This leaves things a bit vague as far as other processing actions such as
30256address rewriting are concerned. Exim treats Resent- header lines as follows:
30257
30258 * A Resent-From: line that just contains the login id of the submitting user
30259 is automatically rewritten in the same way as From: (see below).
30260
30261 * If there's a rewriting rule for a particular header line, it is also
30262 applied to Resent- header lines of the same type. For example, a rule that
30263 rewrites From: also rewrites Resent-From:.
30264
30265 * For local messages, if Sender: is removed on input, Resent-Sender: is also
30266 removed.
30267
30268 * For a locally-submitted message, if there are any Resent- header lines but
30269 no Resent-Date:, Resent-From:, or Resent-Message-Id:, they are added as
30270 necessary. It is the contents of Resent-Message-Id: (rather than
30271 Message-Id:) which are included in log lines in this case.
30272
30273 * The logic for adding Sender: is duplicated for Resent-Sender: when any
30274 Resent- header lines are present.
30275
30276
3027746.6 The Auto-Submitted: header line
30278------------------------------------
30279
30280Whenever Exim generates an autoreply, a bounce, or a delay warning message, it
30281includes the header line:
30282
30283Auto-Submitted: auto-replied
30284
30285
3028646.7 The Bcc: header line
30287-------------------------
30288
30289If Exim is called with the -t option, to take recipient addresses from a
30290message's header, it removes any Bcc: header line that may exist (after
30291extracting its addresses). If -t is not present on the command line, any
30292existing Bcc: is not removed.
30293
30294
3029546.8 The Date: header line
30296--------------------------
30297
30298If a locally-generated or submission-mode message has no Date: header line,
30299Exim adds one, using the current date and time, unless the
30300suppress_local_fixups control has been specified.
30301
30302
3030346.9 The Delivery-date: header line
30304-----------------------------------
30305
30306Delivery-date: header lines are not part of the standard RFC 2822 header set.
30307Exim can be configured to add them to the final delivery of messages. (See the
30308generic delivery_date_add transport option.) They should not be present in
30309messages in transit. If the delivery_date_remove configuration option is set
30310(the default), Exim removes Delivery-date: header lines from incoming messages.
30311
30312
3031346.10 The Envelope-to: header line
30314----------------------------------
30315
30316Envelope-to: header lines are not part of the standard RFC 2822 header set.
30317Exim can be configured to add them to the final delivery of messages. (See the
30318generic envelope_to_add transport option.) They should not be present in
30319messages in transit. If the envelope_to_remove configuration option is set (the
30320default), Exim removes Envelope-to: header lines from incoming messages.
30321
30322
3032346.11 The From: header line
30324---------------------------
30325
30326If a submission-mode message does not contain a From: header line, Exim adds
30327one if either of the following conditions is true:
30328
30329 * The envelope sender address is not empty (that is, this is not a bounce
30330 message). The added header line copies the envelope sender address.
30331
30332 * The SMTP session is authenticated and $authenticated_id is not empty.
30333
30334 1. If no domain is specified by the submission control, the local part is
30335 $authenticated_id and the domain is $qualify_domain.
30336
30337 2. If a non-empty domain is specified by the submission control, the local
30338 part is $authenticated_id, and the domain is the specified domain.
30339
30340 3. If an empty domain is specified by the submission control,
30341 $authenticated_id is assumed to be the complete address.
30342
30343A non-empty envelope sender takes precedence.
30344
30345If a locally-generated incoming message does not contain a From: header line,
30346and the suppress_local_fixups control is not set, Exim adds one containing the
30347sender's address. The calling user's login name and full name are used to
30348construct the address, as described in section 46.18. They are obtained from
30349the password data by calling getpwuid() (but see the unknown_login
30350configuration option). The address is qualified with qualify_domain.
30351
30352For compatibility with Sendmail, if an incoming, non-SMTP message has a From:
30353header line containing just the unqualified login name of the calling user,
30354this is replaced by an address containing the user's login name and full name
30355as described in section 46.18.
30356
30357
3035846.12 The Message-ID: header line
30359---------------------------------
30360
30361If a locally-generated or submission-mode incoming message does not contain a
30362Message-ID: or Resent-Message-ID: header line, and the suppress_local_fixups
30363control is not set, Exim adds a suitable header line to the message. If there
30364are any Resent-: headers in the message, it creates Resent-Message-ID:. The id
30365is constructed from Exim's internal message id, preceded by the letter E to
30366ensure it starts with a letter, and followed by @ and the primary host name.
30367Additional information can be included in this header line by setting the
30368message_id_header_text and/or message_id_header_domain options.
30369
30370
3037146.13 The Received: header line
30372-------------------------------
30373
30374A Received: header line is added at the start of every message. The contents
30375are defined by the received_header_text configuration option, and Exim
30376automatically adds a semicolon and a timestamp to the configured string.
30377
30378The Received: header is generated as soon as the message's header lines have
30379been received. At this stage, the timestamp in the Received: header line is the
30380time that the message started to be received. This is the value that is seen by
30381the DATA ACL and by the local_scan() function.
30382
30383Once a message is accepted, the timestamp in the Received: header line is
30384changed to the time of acceptance, which is (apart from a small delay while the
30385-H spool file is written) the earliest time at which delivery could start.
30386
30387
3038846.14 The References: header line
30389---------------------------------
30390
30391Messages created by the autoreply transport include a References: header line.
30392This is constructed according to the rules that are described in section 3.64
30393of RFC 2822 (which states that replies should contain such a header line), and
30394section 3.14 of RFC 3834 (which states that automatic responses are not
30395different in this respect). However, because some mail processing software does
30396not cope well with very long header lines, no more than 12 message IDs are
30397copied from the References: header line in the incoming message. If there are
30398more than 12, the first one and then the final 11 are copied, before adding the
30399message ID of the incoming message.
30400
30401
3040246.15 The Return-path: header line
30403----------------------------------
30404
30405Return-path: header lines are defined as something an MTA may insert when it
30406does the final delivery of messages. (See the generic return_path_add transport
30407option.) Therefore, they should not be present in messages in transit. If the
30408return_path_remove configuration option is set (the default), Exim removes
30409Return-path: header lines from incoming messages.
30410
30411
3041246.16 The Sender: header line
30413-----------------------------
30414
30415For a locally-originated message from an untrusted user, Exim may remove an
30416existing Sender: header line, and it may add a new one. You can modify these
30417actions by setting the local_sender_retain option true, the local_from_check
30418option false, or by using the suppress_local_fixups control setting.
30419
30420When a local message is received from an untrusted user and local_from_check is
30421true (the default), and the suppress_local_fixups control has not been set, a
30422check is made to see if the address given in the From: header line is the
30423correct (local) sender of the message. The address that is expected has the
30424login name as the local part and the value of qualify_domain as the domain.
30425Prefixes and suffixes for the local part can be permitted by setting
30426local_from_prefix and local_from_suffix appropriately. If From: does not
30427contain the correct sender, a Sender: line is added to the message.
30428
30429If you set local_from_check false, this checking does not occur. However, the
30430removal of an existing Sender: line still happens, unless you also set
30431local_sender_retain to be true. It is not possible to set both of these options
30432true at the same time.
30433
30434By default, no processing of Sender: header lines is done for messages received
30435over TCP/IP or for messages submitted by trusted users. However, when a message
30436is received over TCP/IP in submission mode, and sender_retain is not specified
30437on the submission control, the following processing takes place:
30438
30439First, any existing Sender: lines are removed. Then, if the SMTP session is
30440authenticated, and $authenticated_id is not empty, a sender address is created
30441as follows:
30442
30443 * If no domain is specified by the submission control, the local part is
30444 $authenticated_id and the domain is $qualify_domain.
30445
30446 * If a non-empty domain is specified by the submission control, the local
30447 part is $authenticated_id, and the domain is the specified domain.
30448
30449 * If an empty domain is specified by the submission control,
30450 $authenticated_id is assumed to be the complete address.
30451
30452This address is compared with the address in the From: header line. If they are
30453different, a Sender: header line containing the created address is added.
30454Prefixes and suffixes for the local part in From: can be permitted by setting
30455local_from_prefix and local_from_suffix appropriately.
30456
30457Note: Whenever a Sender: header line is created, the return path for the
30458message (the envelope sender address) is changed to be the same address, except
30459in the case of submission mode when sender_retain is specified.
30460
30461
3046246.17 Adding and removing header lines in routers and transports
30463----------------------------------------------------------------
30464
30465When a message is delivered, the addition and removal of header lines can be
30466specified in a system filter, or on any of the routers and transports that
30467process the message. Section 45.6 contains details about modifying headers in a
30468system filter. Header lines can also be added in an ACL as a message is
30469received (see section 42.24).
30470
30471In contrast to what happens in a system filter, header modifications that are
30472specified on routers and transports apply only to the particular recipient
30473addresses that are being processed by those routers and transports. These
30474changes do not actually take place until a copy of the message is being
30475transported. Therefore, they do not affect the basic set of header lines, and
30476they do not affect the values of the variables that refer to header lines.
30477
30478Note: In particular, this means that any expansions in the configuration of the
30479transport cannot refer to the modified header lines, because such expansions
30480all occur before the message is actually transported.
30481
30482For both routers and transports, the argument of a headers_add option must be
30483in the form of one or more RFC 2822 header lines, separated by newlines (coded
30484as "\n"). For example:
30485
30486headers_add = X-added-header: added by $primary_hostname\n\
30487 X-added-second: another added header line
30488
30489Exim does not check the syntax of these added header lines.
30490
30491Multiple headers_add options for a single router or transport can be specified;
30492the values will append to a single list of header lines. Each header-line is
30493separately expanded.
30494
30495The argument of a headers_remove option must consist of a colon-separated list
30496of header names. This is confusing, because header names themselves are often
30497terminated by colons. In this case, the colons are the list separators, not
30498part of the names. For example:
30499
30500headers_remove = return-receipt-to:acknowledge-to
30501
30502Multiple headers_remove options for a single router or transport can be
30503specified; the arguments will append to a single header-names list. Each item
30504is separately expanded.
30505
30506When headers_add or headers_remove is specified on a router, items are expanded
30507at routing time, and then associated with all addresses that are accepted by
30508that router, and also with any new addresses that it generates. If an address
30509passes through several routers as a result of aliasing or forwarding, the
30510changes are cumulative.
30511
30512However, this does not apply to multiple routers that result from the use of
30513the unseen option. Any header modifications that were specified by the "unseen"
30514router or its predecessors apply only to the "unseen" delivery.
30515
30516Addresses that end up with different headers_add or headers_remove settings
30517cannot be delivered together in a batch, so a transport is always dealing with
30518a set of addresses that have the same header-processing requirements.
30519
30520The transport starts by writing the original set of header lines that arrived
30521with the message, possibly modified by the system filter. As it writes out
30522these lines, it consults the list of header names that were attached to the
30523recipient address(es) by headers_remove options in routers, and it also
30524consults the transport's own headers_remove option. Header lines whose names
30525are on either of these lists are not written out. If there are multiple
30526instances of any listed header, they are all skipped.
30527
30528After the remaining original header lines have been written, new header lines
30529that were specified by routers' headers_add options are written, in the order
30530in which they were attached to the address. These are followed by any header
30531lines specified by the transport's headers_add option.
30532
30533This way of handling header line modifications in routers and transports has
30534the following consequences:
30535
30536 * The original set of header lines, possibly modified by the system filter,
30537 remains "visible", in the sense that the $header_xxx variables refer to it,
30538 at all times.
30539
30540 * Header lines that are added by a router's headers_add option are not
30541 accessible by means of the $header_xxx expansion syntax in subsequent
30542 routers or the transport.
30543
30544 * Conversely, header lines that are specified for removal by headers_remove
30545 in a router remain visible to subsequent routers and the transport.
30546
30547 * Headers added to an address by headers_add in a router cannot be removed by
30548 a later router or by a transport.
30549
30550 * An added header can refer to the contents of an original header that is to
30551 be removed, even it has the same name as the added header. For example:
30552
30553 headers_remove = subject
30554 headers_add = Subject: new subject (was: $h_subject:)
30555
30556Warning: The headers_add and headers_remove options cannot be used for a
30557redirect router that has the one_time option set.
30558
30559
3056046.18 Constructed addresses
30561---------------------------
30562
30563When Exim constructs a sender address for a locally-generated message, it uses
30564the form
30565
30566<user name> <login@qualify_domain>
30567
30568For example:
30569
30570Zaphod Beeblebrox <zaphod@end.univ.example>
30571
30572The user name is obtained from the -F command line option if set, or otherwise
30573by looking up the calling user by getpwuid() and extracting the "gecos" field
30574from the password entry. If the "gecos" field contains an ampersand character,
30575this is replaced by the login name with the first letter upper cased, as is
30576conventional in a number of operating systems. See the gecos_name option for a
30577way to tailor the handling of the "gecos" field. The unknown_username option
30578can be used to specify user names in cases when there is no password file
30579entry.
30580
30581In all cases, the user name is made to conform to RFC 2822 by quoting all or
30582parts of it if necessary. In addition, if it contains any non-printing
30583characters, it is encoded as described in RFC 2047, which defines a way of
30584including non-ASCII characters in header lines. The value of the
30585headers_charset option specifies the name of the encoding that is used (the
30586characters are assumed to be in this encoding). The setting of
30587print_topbitchars controls whether characters with the top bit set (that is,
30588with codes greater than 127) count as printing characters or not.
30589
30590
3059146.19 Case of local parts
30592-------------------------
30593
30594RFC 2822 states that the case of letters in the local parts of addresses cannot
30595be assumed to be non-significant. Exim preserves the case of local parts of
30596addresses, but by default it uses a lower-cased form when it is routing,
30597because on most Unix systems, usernames are in lower case and case-insensitive
30598routing is required. However, any particular router can be made to use the
30599original case for local parts by setting the caseful_local_part generic router
30600option.
30601
30602If you must have mixed-case user names on your system, the best way to proceed,
30603assuming you want case-independent handling of incoming email, is to set up
30604your first router to convert incoming local parts in your domains to the
30605correct case by means of a file lookup. For example:
30606
30607correct_case:
30608 driver = redirect
30609 domains = +local_domains
30610 data = ${lookup{$local_part}cdb\
30611 {/etc/usercased.cdb}{$value}fail}\
30612 @$domain
30613
30614For this router, the local part is forced to lower case by the default action (
30615caseful_local_part is not set). The lower-cased local part is used to look up a
30616new local part in the correct case. If you then set caseful_local_part on any
30617subsequent routers which process your domains, they will operate on local parts
30618with the correct case in a case-sensitive manner.
30619
30620
3062146.20 Dots in local parts
30622-------------------------
30623
30624RFC 2822 forbids empty components in local parts. That is, an unquoted local
30625part may not begin or end with a dot, nor have two consecutive dots in the
30626middle. However, it seems that many MTAs do not enforce this, so Exim permits
30627empty components for compatibility.
30628
30629
3063046.21 Rewriting addresses
30631-------------------------
30632
30633Rewriting of sender and recipient addresses, and addresses in headers, can
30634happen automatically, or as the result of configuration options, as described
30635in chapter 31. The headers that may be affected by this are Bcc:, Cc:, From:,
30636Reply-To:, Sender:, and To:.
30637
30638Automatic rewriting includes qualification, as mentioned above. The other case
30639in which it can happen is when an incomplete non-local domain is given. The
30640routing process may cause this to be expanded into the full domain name. For
30641example, a header such as
30642
30643To: hare@teaparty
30644
30645might get rewritten as
30646
30647To: hare@teaparty.wonderland.fict.example
30648
30649Rewriting as a result of routing is the one kind of message processing that
30650does not happen at input time, as it cannot be done until the address has been
30651routed.
30652
30653Strictly, one should not do any deliveries of a message until all its addresses
30654have been routed, in case any of the headers get changed as a result of
30655routing. However, doing this in practice would hold up many deliveries for
30656unreasonable amounts of time, just because one address could not immediately be
30657routed. Exim therefore does not delay other deliveries when routing of one or
30658more addresses is deferred.
30659
30660
30661
30662===============================================================================
3066347. SMTP PROCESSING
30664
30665Exim supports a number of different ways of using the SMTP protocol, and its
30666LMTP variant, which is an interactive protocol for transferring messages into a
30667closed mail store application. This chapter contains details of how SMTP is
30668processed. For incoming mail, the following are available:
30669
30670 * SMTP over TCP/IP (Exim daemon or inetd);
30671
30672 * SMTP over the standard input and output (the -bs option);
30673
30674 * Batched SMTP on the standard input (the -bS option).
30675
30676For mail delivery, the following are available:
30677
30678 * SMTP over TCP/IP (the smtp transport);
30679
30680 * LMTP over TCP/IP (the smtp transport with the protocol option set to
30681 "lmtp");
30682
30683 * LMTP over a pipe to a process running in the local host (the lmtp
30684 transport);
30685
30686 * Batched SMTP to a file or pipe (the appendfile and pipe transports with the
30687 use_bsmtp option set).
30688
30689Batched SMTP is the name for a process in which batches of messages are stored
30690in or read from files (or pipes), in a format in which SMTP commands are used
30691to contain the envelope information.
30692
30693
3069447.1 Outgoing SMTP and LMTP over TCP/IP
30695---------------------------------------
30696
30697Outgoing SMTP and LMTP over TCP/IP is implemented by the smtp transport. The
30698protocol option selects which protocol is to be used, but the actual processing
30699is the same in both cases.
30700
30701If, in response to its EHLO command, Exim is told that the SIZE parameter is
30702supported, it adds SIZE=<n> to each subsequent MAIL command. The value of <n>
30703is the message size plus the value of the size_addition option (default 1024)
30704to allow for additions to the message such as per-transport header lines, or
30705changes made in a transport filter. If size_addition is set negative, the use
30706of SIZE is suppressed.
30707
30708If the remote server advertises support for PIPELINING, Exim uses the
30709pipelining extension to SMTP (RFC 2197) to reduce the number of TCP/IP packets
30710required for the transaction.
30711
30712If the remote server advertises support for the STARTTLS command, and Exim was
30713built to support TLS encryption, it tries to start a TLS session unless the
30714server matches hosts_avoid_tls. See chapter 41 for more details. Either a match
30715in that or hosts_verify_avoid_tls apply when the transport is called for
30716verification.
30717
30718If the remote server advertises support for the AUTH command, Exim scans the
30719authenticators configuration for any suitable client settings, as described in
30720chapter 33.
30721
30722Responses from the remote host are supposed to be terminated by CR followed by
30723LF. However, there are known to be hosts that do not send CR characters, so in
30724order to be able to interwork with such hosts, Exim treats LF on its own as a
30725line terminator.
30726
30727If a message contains a number of different addresses, all those with the same
30728characteristics (for example, the same envelope sender) that resolve to the
30729same set of hosts, in the same order, are sent in a single SMTP transaction,
30730even if they are for different domains, unless there are more than the setting
30731of the max_rcpts option in the smtp transport allows, in which case they are
30732split into groups containing no more than max_rcpts addresses each. If
30733remote_max_parallel is greater than one, such groups may be sent in parallel
30734sessions. The order of hosts with identical MX values is not significant when
30735checking whether addresses can be batched in this way.
30736
30737When the smtp transport suffers a temporary failure that is not
30738message-related, Exim updates its transport-specific database, which contains
30739records indexed by host name that remember which messages are waiting for each
30740particular host. It also updates the retry database with new retry times.
30741
30742Exim's retry hints are based on host name plus IP address, so if one address of
30743a multi-homed host is broken, it will soon be skipped most of the time. See the
30744next section for more detail about error handling.
30745
30746When a message is successfully delivered over a TCP/IP SMTP connection, Exim
30747looks in the hints database for the transport to see if there are any queued
30748messages waiting for the host to which it is connected. If it finds one, it
30749creates a new Exim process using the -MC option (which can only be used by a
30750process running as root or the Exim user) and passes the TCP/IP socket to it so
30751that it can deliver another message using the same socket. The new process does
30752only those deliveries that are routed to the connected host, and may in turn
30753pass the socket on to a third process, and so on.
30754
30755The connection_max_messages option of the smtp transport can be used to limit
30756the number of messages sent down a single TCP/IP connection.
30757
30758The second and subsequent messages delivered down an existing connection are
30759identified in the main log by the addition of an asterisk after the closing
30760square bracket of the IP address.
30761
30762
3076347.2 Errors in outgoing SMTP
30764----------------------------
30765
30766Three different kinds of error are recognized for outgoing SMTP: host errors,
30767message errors, and recipient errors.
30768
30769Host errors
30770
30771 A host error is not associated with a particular message or with a
30772 particular recipient of a message. The host errors are:
30773
30774 * Connection refused or timed out,
30775
30776 * Any error response code on connection,
30777
30778 * Any error response code to EHLO or HELO,
30779
30780 * Loss of connection at any time, except after ".",
30781
30782 * I/O errors at any time,
30783
30784 * Timeouts during the session, other than in response to MAIL, RCPT or
30785 the "." at the end of the data.
30786
30787 For a host error, a permanent error response on connection, or in response
30788 to EHLO, causes all addresses routed to the host to be failed. Any other
30789 host error causes all addresses to be deferred, and retry data to be
30790 created for the host. It is not tried again, for any message, until its
30791 retry time arrives. If the current set of addresses are not all delivered
30792 in this run (to some alternative host), the message is added to the list of
30793 those waiting for this host, so if it is still undelivered when a
30794 subsequent successful delivery is made to the host, it will be sent down
30795 the same SMTP connection.
30796
30797Message errors
30798
30799 A message error is associated with a particular message when sent to a
30800 particular host, but not with a particular recipient of the message. The
30801 message errors are:
30802
30803 * Any error response code to MAIL, DATA, or the "." that terminates the
30804 data,
30805
30806 * Timeout after MAIL,
30807
30808 * Timeout or loss of connection after the "." that terminates the data. A
30809 timeout after the DATA command itself is treated as a host error, as is
30810 loss of connection at any other time.
30811
30812 For a message error, a permanent error response (5xx) causes all addresses
30813 to be failed, and a delivery error report to be returned to the sender. A
30814 temporary error response (4xx), or one of the timeouts, causes all
30815 addresses to be deferred. Retry data is not created for the host, but
30816 instead, a retry record for the combination of host plus message id is
30817 created. The message is not added to the list of those waiting for this
30818 host. This ensures that the failing message will not be sent to this host
30819 again until the retry time arrives. However, other messages that are routed
30820 to the host are not affected, so if it is some property of the message that
30821 is causing the error, it will not stop the delivery of other mail.
30822
30823 If the remote host specified support for the SIZE parameter in its response
30824 to EHLO, Exim adds SIZE=nnn to the MAIL command, so an over-large message
30825 will cause a message error because the error arrives as a response to MAIL.
30826
30827Recipient errors
30828
30829 A recipient error is associated with a particular recipient of a message.
30830 The recipient errors are:
30831
30832 * Any error response to RCPT,
30833
30834 * Timeout after RCPT.
30835
30836 For a recipient error, a permanent error response (5xx) causes the
30837 recipient address to be failed, and a bounce message to be returned to the
30838 sender. A temporary error response (4xx) or a timeout causes the failing
30839 address to be deferred, and routing retry data to be created for it. This
30840 is used to delay processing of the address in subsequent queue runs, until
30841 its routing retry time arrives. This applies to all messages, but because
30842 it operates only in queue runs, one attempt will be made to deliver a new
30843 message to the failing address before the delay starts to operate. This
30844 ensures that, if the failure is really related to the message rather than
30845 the recipient ("message too big for this recipient" is a possible example),
30846 other messages have a chance of getting delivered. If a delivery to the
30847 address does succeed, the retry information gets cleared, so all stuck
30848 messages get tried again, and the retry clock is reset.
30849
30850 The message is not added to the list of those waiting for this host. Use of
30851 the host for other messages is unaffected, and except in the case of a
30852 timeout, other recipients are processed independently, and may be
30853 successfully delivered in the current SMTP session. After a timeout it is
30854 of course impossible to proceed with the session, so all addresses get
30855 deferred. However, those other than the one that failed do not suffer any
30856 subsequent retry delays. Therefore, if one recipient is causing trouble,
30857 the others have a chance of getting through when a subsequent delivery
30858 attempt occurs before the failing recipient's retry time.
30859
30860In all cases, if there are other hosts (or IP addresses) available for the
30861current set of addresses (for example, from multiple MX records), they are
30862tried in this run for any undelivered addresses, subject of course to their own
30863retry data. In other words, recipient error retry data does not take effect
30864until the next delivery attempt.
30865
30866Some hosts have been observed to give temporary error responses to every MAIL
30867command at certain times ("insufficient space" has been seen). It would be nice
30868if such circumstances could be recognized, and defer data for the host itself
30869created, but this is not possible within the current Exim design. What actually
30870happens is that retry data for every (host, message) combination is created.
30871
30872The reason that timeouts after MAIL and RCPT are treated specially is that
30873these can sometimes arise as a result of the remote host's verification
30874procedures. Exim makes this assumption, and treats them as if a temporary error
30875response had been received. A timeout after "." is treated specially because it
30876is known that some broken implementations fail to recognize the end of the
30877message if the last character of the last line is a binary zero. Thus, it is
30878helpful to treat this case as a message error.
30879
30880Timeouts at other times are treated as host errors, assuming a problem with the
30881host, or the connection to it. If a timeout after MAIL, RCPT, or "." is really
30882a connection problem, the assumption is that at the next try the timeout is
30883likely to occur at some other point in the dialogue, causing it then to be
30884treated as a host error.
30885
30886There is experimental evidence that some MTAs drop the connection after the
30887terminating "." if they do not like the contents of the message for some
30888reason, in contravention of the RFC, which indicates that a 5xx response should
30889be given. That is why Exim treats this case as a message rather than a host
30890error, in order not to delay other messages to the same host.
30891
30892
3089347.3 Incoming SMTP messages over TCP/IP
30894---------------------------------------
30895
30896Incoming SMTP messages can be accepted in one of two ways: by running a
30897listening daemon, or by using inetd. In the latter case, the entry in /etc/
30898inetd.conf should be like this:
30899
30900smtp stream tcp nowait exim /opt/exim/bin/exim in.exim -bs
30901
30902Exim distinguishes between this case and the case of a locally running user
30903agent using the -bs option by checking whether or not the standard input is a
30904socket. When it is, either the port must be privileged (less than 1024), or the
30905caller must be root or the Exim user. If any other user passes a socket with an
30906unprivileged port number, Exim prints a message on the standard error stream
30907and exits with an error code.
30908
30909By default, Exim does not make a log entry when a remote host connects or
30910disconnects (either via the daemon or inetd), unless the disconnection is
30911unexpected. It can be made to write such log entries by setting the
30912smtp_connection log selector.
30913
30914Commands from the remote host are supposed to be terminated by CR followed by
30915LF. However, there are known to be hosts that do not send CR characters. In
30916order to be able to interwork with such hosts, Exim treats LF on its own as a
30917line terminator. Furthermore, because common code is used for receiving
30918messages from all sources, a CR on its own is also interpreted as a line
30919terminator. However, the sequence "CR, dot, CR" does not terminate incoming
30920SMTP data.
30921
30922One area that sometimes gives rise to problems concerns the EHLO or HELO
30923commands. Some clients send syntactically invalid versions of these commands,
30924which Exim rejects by default. (This is nothing to do with verifying the data
30925that is sent, so helo_verify_hosts is not relevant.) You can tell Exim not to
30926apply a syntax check by setting helo_accept_junk_hosts to match the broken
30927hosts that send invalid commands.
30928
30929The amount of disk space available is checked whenever SIZE is received on a
30930MAIL command, independently of whether message_size_limit or check_spool_space
30931is configured, unless smtp_check_spool_space is set false. A temporary error is
30932given if there is not enough space. If check_spool_space is set, the check is
30933for that amount of space plus the value given with SIZE, that is, it checks
30934that the addition of the incoming message will not reduce the space below the
30935threshold.
30936
30937When a message is successfully received, Exim includes the local message id in
30938its response to the final "." that terminates the data. If the remote host logs
30939this text it can help with tracing what has happened to a message.
30940
30941The Exim daemon can limit the number of simultaneous incoming connections it is
30942prepared to handle (see the smtp_accept_max option). It can also limit the
30943number of simultaneous incoming connections from a single remote host (see the
30944smtp_accept_max_per_host option). Additional connection attempts are rejected
30945using the SMTP temporary error code 421.
30946
30947The Exim daemon does not rely on the SIGCHLD signal to detect when a subprocess
30948has finished, as this can get lost at busy times. Instead, it looks for
30949completed subprocesses every time it wakes up. Provided there are other things
30950happening (new incoming calls, starts of queue runs), completed processes will
30951be noticed and tidied away. On very quiet systems you may sometimes see a
30952"defunct" Exim process hanging about. This is not a problem; it will be noticed
30953when the daemon next wakes up.
30954
30955When running as a daemon, Exim can reserve some SMTP slots for specific hosts,
30956and can also be set up to reject SMTP calls from non-reserved hosts at times of
30957high system load - for details see the smtp_accept_reserve, smtp_load_reserve,
30958and smtp_reserve_hosts options. The load check applies in both the daemon and
30959inetd cases.
30960
30961Exim normally starts a delivery process for each message received, though this
30962can be varied by means of the -odq command line option and the queue_only,
30963queue_only_file, and queue_only_load options. The number of simultaneously
30964running delivery processes started in this way from SMTP input can be limited
30965by the smtp_accept_queue and smtp_accept_queue_per_connection options. When
30966either limit is reached, subsequently received messages are just put on the
30967input queue without starting a delivery process.
30968
30969The controls that involve counts of incoming SMTP calls (smtp_accept_max,
30970smtp_accept_queue, smtp_accept_reserve) are not available when Exim is started
30971up from the inetd daemon, because in that case each connection is handled by an
30972entirely independent Exim process. Control by load average is, however,
30973available with inetd.
30974
30975Exim can be configured to verify addresses in incoming SMTP commands as they
30976are received. See chapter 42 for details. It can also be configured to rewrite
30977addresses at this time - before any syntax checking is done. See section 31.9.
30978
30979Exim can also be configured to limit the rate at which a client host submits
30980MAIL and RCPT commands in a single SMTP session. See the smtp_ratelimit_hosts
30981option.
30982
30983
3098447.4 Unrecognized SMTP commands
30985-------------------------------
30986
30987If Exim receives more than smtp_max_unknown_commands unrecognized SMTP commands
30988during a single SMTP connection, it drops the connection after sending the
30989error response to the last command. The default value for
30990smtp_max_unknown_commands is 3. This is a defence against some kinds of abuse
30991that subvert web servers into making connections to SMTP ports; in these
30992circumstances, a number of non-SMTP lines are sent first.
30993
30994
3099547.5 Syntax and protocol errors in SMTP commands
30996------------------------------------------------
30997
30998A syntax error is detected if an SMTP command is recognized, but there is
30999something syntactically wrong with its data, for example, a malformed email
31000address in a RCPT command. Protocol errors include invalid command sequencing
31001such as RCPT before MAIL. If Exim receives more than smtp_max_synprot_errors
31002such commands during a single SMTP connection, it drops the connection after
31003sending the error response to the last command. The default value for
31004smtp_max_synprot_errors is 3. This is a defence against broken clients that
31005loop sending bad commands (yes, it has been seen).
31006
31007
3100847.6 Use of non-mail SMTP commands
31009----------------------------------
31010
31011The "non-mail" SMTP commands are those other than MAIL, RCPT, and DATA. Exim
31012counts such commands, and drops the connection if there are too many of them in
31013a single SMTP session. This action catches some denial-of-service attempts and
31014things like repeated failing AUTHs, or a mad client looping sending EHLO. The
31015global option smtp_accept_max_nonmail defines what "too many" means. Its
31016default value is 10.
31017
31018When a new message is expected, one occurrence of RSET is not counted. This
31019allows a client to send one RSET between messages (this is not necessary, but
31020some clients do it). Exim also allows one uncounted occurrence of HELO or EHLO,
31021and one occurrence of STARTTLS between messages. After starting up a TLS
31022session, another EHLO is expected, and so it too is not counted.
31023
31024The first occurrence of AUTH in a connection, or immediately following STARTTLS
31025is also not counted. Otherwise, all commands other than MAIL, RCPT, DATA, and
31026QUIT are counted.
31027
31028You can control which hosts are subject to the limit set by
31029smtp_accept_max_nonmail by setting smtp_accept_max_nonmail_hosts. The default
31030value is "*", which makes the limit apply to all hosts. This option means that
31031you can exclude any specific badly-behaved hosts that you have to live with.
31032
31033
3103447.7 The VRFY and EXPN commands
31035-------------------------------
31036
31037When Exim receives a VRFY or EXPN command on a TCP/IP connection, it runs the
31038ACL specified by acl_smtp_vrfy or acl_smtp_expn (as appropriate) in order to
31039decide whether the command should be accepted or not. If no ACL is defined, the
31040command is rejected.
31041
31042When VRFY is accepted, it runs exactly the same code as when Exim is called
31043with the -bv option.
31044
31045When EXPN is accepted, a single-level expansion of the address is done. EXPN is
31046treated as an "address test" (similar to the -bt option) rather than a
31047verification (the -bv option). If an unqualified local part is given as the
31048argument to EXPN, it is qualified with qualify_domain. Rejections of VRFY and
31049EXPN commands are logged on the main and reject logs, and VRFY verification
31050failures are logged on the main log for consistency with RCPT failures.
31051
31052
3105347.8 The ETRN command
31054---------------------
31055
31056RFC 1985 describes an SMTP command called ETRN that is designed to overcome the
31057security problems of the TURN command (which has fallen into disuse). When Exim
31058receives an ETRN command on a TCP/IP connection, it runs the ACL specified by
31059acl_smtp_etrn in order to decide whether the command should be accepted or not.
31060If no ACL is defined, the command is rejected.
31061
31062The ETRN command is concerned with "releasing" messages that are awaiting
31063delivery to certain hosts. As Exim does not organize its message queue by host,
31064the only form of ETRN that is supported by default is the one where the text
31065starts with the "#" prefix, in which case the remainder of the text is specific
31066to the SMTP server. A valid ETRN command causes a run of Exim with the -R
31067option to happen, with the remainder of the ETRN text as its argument. For
31068example,
31069
31070ETRN #brigadoon
31071
31072runs the command
31073
31074exim -R brigadoon
31075
31076which causes a delivery attempt on all messages with undelivered addresses
31077containing the text "brigadoon". When smtp_etrn_serialize is set (the default),
31078Exim prevents the simultaneous execution of more than one queue run for the
31079same argument string as a result of an ETRN command. This stops a misbehaving
31080client from starting more than one queue runner at once.
31081
31082Exim implements the serialization by means of a hints database in which a
31083record is written whenever a process is started by ETRN, and deleted when the
31084process completes. However, Exim does not keep the SMTP session waiting for the
31085ETRN process to complete. Once ETRN is accepted, the client is sent a "success"
31086return code. Obviously there is scope for hints records to get left lying
31087around if there is a system or program crash. To guard against this, Exim
31088ignores any records that are more than six hours old.
31089
31090For more control over what ETRN does, the smtp_etrn_command option can used.
31091This specifies a command that is run whenever ETRN is received, whatever the
31092form of its argument. For example:
31093
31094smtp_etrn_command = /etc/etrn_command $domain \
31095 $sender_host_address
31096
31097The string is split up into arguments which are independently expanded. The
31098expansion variable $domain is set to the argument of the ETRN command, and no
31099syntax checking is done on the contents of this argument. Exim does not wait
31100for the command to complete, so its status code is not checked. Exim runs under
31101its own uid and gid when receiving incoming SMTP, so it is not possible for it
31102to change them before running the command.
31103
31104
3110547.9 Incoming local SMTP
31106------------------------
31107
31108Some user agents use SMTP to pass messages to their local MTA using the
31109standard input and output, as opposed to passing the envelope on the command
31110line and writing the message to the standard input. This is supported by the
31111-bs option. This form of SMTP is handled in the same way as incoming messages
31112over TCP/IP (including the use of ACLs), except that the envelope sender given
31113in a MAIL command is ignored unless the caller is trusted. In an ACL you can
31114detect this form of SMTP input by testing for an empty host identification. It
31115is common to have this as the first line in the ACL that runs for RCPT
31116commands:
31117
31118accept hosts = :
31119
31120This accepts SMTP messages from local processes without doing any other tests.
31121
31122
3112347.10 Outgoing batched SMTP
31124---------------------------
31125
31126Both the appendfile and pipe transports can be used for handling batched SMTP.
31127Each has an option called use_bsmtp which causes messages to be output in BSMTP
31128format. No SMTP responses are possible for this form of delivery. All it is
31129doing is using SMTP commands as a way of transmitting the envelope along with
31130the message.
31131
31132The message is written to the file or pipe preceded by the SMTP commands MAIL
31133and RCPT, and followed by a line containing a single dot. Lines in the message
31134that start with a dot have an extra dot added. The SMTP command HELO is not
31135normally used. If it is required, the message_prefix option can be used to
31136specify it.
31137
31138Because appendfile and pipe are both local transports, they accept only one
31139recipient address at a time by default. However, you can arrange for them to
31140handle several addresses at once by setting the batch_max option. When this is
31141done for BSMTP, messages may contain multiple RCPT commands. See chapter 25 for
31142more details.
31143
31144When one or more addresses are routed to a BSMTP transport by a router that
31145sets up a host list, the name of the first host on the list is available to the
31146transport in the variable $host. Here is an example of such a transport and
31147router:
31148
31149begin routers
31150route_append:
31151 driver = manualroute
31152 transport = smtp_appendfile
31153 route_list = domain.example batch.host.example
31154
31155begin transports
31156smtp_appendfile:
31157 driver = appendfile
31158 directory = /var/bsmtp/$host
31159 batch_max = 1000
31160 use_bsmtp
31161 user = exim
31162
31163This causes messages addressed to domain.example to be written in BSMTP format
31164to /var/bsmtp/batch.host.example, with only a single copy of each message
31165(unless there are more than 1000 recipients).
31166
31167
3116847.11 Incoming batched SMTP
31169---------------------------
31170
31171The -bS command line option causes Exim to accept one or more messages by
31172reading SMTP on the standard input, but to generate no responses. If the caller
31173is trusted, the senders in the MAIL commands are believed; otherwise the sender
31174is always the caller of Exim. Unqualified senders and receivers are not
31175rejected (there seems little point) but instead just get qualified. HELO and
31176EHLO act as RSET; VRFY, EXPN, ETRN and HELP, act as NOOP; QUIT quits.
31177
31178Minimal policy checking is done for BSMTP input. Only the non-SMTP ACL is run
31179in the same way as for non-SMTP local input.
31180
31181If an error is detected while reading a message, including a missing "." at the
31182end, Exim gives up immediately. It writes details of the error to the standard
31183output in a stylized way that the calling program should be able to make some
31184use of automatically, for example:
31185
31186554 Unexpected end of file
31187Transaction started in line 10
31188Error detected in line 14
31189
31190It writes a more verbose version, for human consumption, to the standard error
31191file, for example:
31192
31193An error was detected while processing a file of BSMTP input.
31194The error message was:
31195
31196501 '>' missing at end of address
31197
31198The SMTP transaction started in line 10.
31199The error was detected in line 12.
31200The SMTP command at fault was:
31201
31202rcpt to:<malformed@in.com.plete
31203
312041 previous message was successfully processed.
31205The rest of the batch was abandoned.
31206
31207The return code from Exim is zero only if there were no errors. It is 1 if some
31208messages were accepted before an error was detected, and 2 if no messages were
31209accepted.
31210
31211
31212
31213===============================================================================
3121448. CUSTOMIZING BOUNCE AND WARNING MESSAGES
31215
31216When a message fails to be delivered, or remains on the queue for more than a
31217configured amount of time, Exim sends a message to the original sender, or to
31218an alternative configured address. The text of these messages is built into the
31219code of Exim, but it is possible to change it, either by adding a single
31220string, or by replacing each of the paragraphs by text supplied in a file.
31221
31222The From: and To: header lines are automatically generated; you can cause a
31223Reply-To: line to be added by setting the errors_reply_to option. Exim also
31224adds the line
31225
31226Auto-Submitted: auto-generated
31227
31228to all warning and bounce messages,
31229
31230
3123148.1 Customizing bounce messages
31232--------------------------------
31233
31234If bounce_message_text is set, its contents are included in the default message
31235immediately after "This message was created automatically by mail delivery
31236software." The string is not expanded. It is not used if bounce_message_file is
31237set.
31238
31239When bounce_message_file is set, it must point to a template file for
31240constructing error messages. The file consists of a series of text items,
31241separated by lines consisting of exactly four asterisks. If the file cannot be
31242opened, default text is used and a message is written to the main and panic
31243logs. If any text item in the file is empty, default text is used for that
31244item.
31245
31246Each item of text that is read from the file is expanded, and there are two
31247expansion variables which can be of use here: $bounce_recipient is set to the
31248recipient of an error message while it is being created, and
31249$bounce_return_size_limit contains the value of the return_size_limit option,
31250rounded to a whole number.
31251
31252The items must appear in the file in the following order:
31253
31254 * The first item is included in the headers, and should include at least a
31255 Subject: header. Exim does not check the syntax of these headers.
31256
31257 * The second item forms the start of the error message. After it, Exim lists
31258 the failing addresses with their error messages.
31259
31260 * The third item is used to introduce any text from pipe transports that is
31261 to be returned to the sender. It is omitted if there is no such text.
31262
31263 * The fourth item is used to introduce the copy of the message that is
31264 returned as part of the error report.
31265
31266 * The fifth item is added after the fourth one if the returned message is
31267 truncated because it is bigger than return_size_limit.
31268
31269 * The sixth item is added after the copy of the original message.
31270
31271The default state (bounce_message_file unset) is equivalent to the following
31272file, in which the sixth item is empty. The Subject: and some other lines have
31273been split in order to fit them on the page:
31274
31275Subject: Mail delivery failed
31276 ${if eq{$sender_address}{$bounce_recipient}
31277 {: returning message to sender}}
31278****
31279This message was created automatically by mail delivery software.
31280
31281A message ${if eq{$sender_address}{$bounce_recipient}
31282 {that you sent }{sent by
31283
31284<$sender_address>
31285
31286}}could not be delivered to all of its recipients.
31287This is a permanent error. The following address(es) failed:
31288****
31289The following text was generated during the delivery attempt(s):
31290****
31291------ This is a copy of the message, including all the headers.
31292 ------
31293****
31294------ The body of the message is $message_size characters long;
31295 only the first
31296------ $bounce_return_size_limit or so are included here.
31297****
31298
31299
3130048.2 Customizing warning messages
31301---------------------------------
31302
31303The option warn_message_file can be pointed at a template file for use when
31304warnings about message delays are created. In this case there are only three
31305text sections:
31306
31307 * The first item is included in the headers, and should include at least a
31308 Subject: header. Exim does not check the syntax of these headers.
31309
31310 * The second item forms the start of the warning message. After it, Exim
31311 lists the delayed addresses.
31312
31313 * The third item then ends the message.
31314
31315The default state is equivalent to the following file, except that some lines
31316have been split here, in order to fit them on the page:
31317
31318Subject: Warning: message $message_exim_id delayed
31319 $warn_message_delay
31320****
31321This message was created automatically by mail delivery software.
31322
31323A message ${if eq{$sender_address}{$warn_message_recipients}
31324{that you sent }{sent by
31325
31326<$sender_address>
31327
31328}}has not been delivered to all of its recipients after
31329more than $warn_message_delay on the queue on $primary_hostname.
31330
31331The message identifier is: $message_exim_id
31332The subject of the message is: $h_subject
31333The date of the message is: $h_date
31334
31335The following address(es) have not yet been delivered:
31336****
31337No action is required on your part. Delivery attempts will
31338continue for some time, and this warning may be repeated at
31339intervals if the message remains undelivered. Eventually the
31340mail delivery software will give up, and when that happens,
31341the message will be returned to you.
31342
31343However, in the default state the subject and date lines are omitted if no
31344appropriate headers exist. During the expansion of this file,
31345$warn_message_delay is set to the delay time in one of the forms "<n> minutes"
31346or "<n> hours", and $warn_message_recipients contains a list of recipients for
31347the warning message. There may be more than one if there are multiple addresses
31348with different errors_to settings on the routers that handled them.
31349
31350
31351
31352===============================================================================
3135349. SOME COMMON CONFIGURATION SETTINGS
31354
31355This chapter discusses some configuration settings that seem to be fairly
31356common. More examples and discussion can be found in the Exim book.
31357
31358
3135949.1 Sending mail to a smart host
31360---------------------------------
31361
31362If you want to send all mail for non-local domains to a "smart host", you
31363should replace the default dnslookup router with a router which does the
31364routing explicitly:
31365
31366send_to_smart_host:
31367 driver = manualroute
31368 route_list = !+local_domains smart.host.name
31369 transport = remote_smtp
31370
31371You can use the smart host's IP address instead of the name if you wish. If you
31372are using Exim only to submit messages to a smart host, and not for receiving
31373incoming messages, you can arrange for it to do the submission synchronously by
31374setting the mua_wrapper option (see chapter 50).
31375
31376
3137749.2 Using Exim to handle mailing lists
31378---------------------------------------
31379
31380Exim can be used to run simple mailing lists, but for large and/or complicated
31381requirements, the use of additional specialized mailing list software such as
31382Majordomo or Mailman is recommended.
31383
31384The redirect router can be used to handle mailing lists where each list is
31385maintained in a separate file, which can therefore be managed by an independent
31386manager. The domains router option can be used to run these lists in a separate
31387domain from normal mail. For example:
31388
31389lists:
31390 driver = redirect
31391 domains = lists.example
31392 file = /usr/lists/$local_part
31393 forbid_pipe
31394 forbid_file
31395 errors_to = $local_part-request@lists.example
31396 no_more
31397
31398This router is skipped for domains other than lists.example. For addresses in
31399that domain, it looks for a file that matches the local part. If there is no
31400such file, the router declines, but because no_more is set, no subsequent
31401routers are tried, and so the whole delivery fails.
31402
31403The forbid_pipe and forbid_file options prevent a local part from being
31404expanded into a file name or a pipe delivery, which is usually inappropriate in
31405a mailing list.
31406
31407The errors_to option specifies that any delivery errors caused by addresses
31408taken from a mailing list are to be sent to the given address rather than the
31409original sender of the message. However, before acting on this, Exim verifies
31410the error address, and ignores it if verification fails.
31411
31412For example, using the configuration above, mail sent to dicts@lists.example is
31413passed on to those addresses contained in /usr/lists/dicts, with error reports
31414directed to dicts-request@lists.example, provided that this address can be
31415verified. There could be a file called /usr/lists/dicts-request containing the
31416address(es) of this particular list's manager(s), but other approaches, such as
31417setting up an earlier router (possibly using the local_part_prefix or
31418local_part_suffix options) to handle addresses of the form owner-xxx or xxx-
31419request, are also possible.
31420
31421
3142249.3 Syntax errors in mailing lists
31423-----------------------------------
31424
31425If an entry in redirection data contains a syntax error, Exim normally defers
31426delivery of the original address. That means that a syntax error in a mailing
31427list holds up all deliveries to the list. This may not be appropriate when a
31428list is being maintained automatically from data supplied by users, and the
31429addresses are not rigorously checked.
31430
31431If the skip_syntax_errors option is set, the redirect router just skips entries
31432that fail to parse, noting the incident in the log. If in addition
31433syntax_errors_to is set to a verifiable address, a message is sent to it
31434whenever a broken address is skipped. It is usually appropriate to set
31435syntax_errors_to to the same address as errors_to.
31436
31437
3143849.4 Re-expansion of mailing lists
31439----------------------------------
31440
31441Exim remembers every individual address to which a message has been delivered,
31442in order to avoid duplication, but it normally stores only the original
31443recipient addresses with a message. If all the deliveries to a mailing list
31444cannot be done at the first attempt, the mailing list is re-expanded when the
31445delivery is next tried. This means that alterations to the list are taken into
31446account at each delivery attempt, so addresses that have been added to the list
31447since the message arrived will therefore receive a copy of the message, even
31448though it pre-dates their subscription.
31449
31450If this behaviour is felt to be undesirable, the one_time option can be set on
31451the redirect router. If this is done, any addresses generated by the router
31452that fail to deliver at the first attempt are added to the message as "top
31453level" addresses, and the parent address that generated them is marked
31454"delivered". Thus, expansion of the mailing list does not happen again at the
31455subsequent delivery attempts. The disadvantage of this is that if any of the
31456failing addresses are incorrect, correcting them in the file has no effect on
31457pre-existing messages.
31458
31459The original top-level address is remembered with each of the generated
31460addresses, and is output in any log messages. However, any intermediate parent
31461addresses are not recorded. This makes a difference to the log only if the
31462all_parents selector is set, but for mailing lists there is normally only one
31463level of expansion anyway.
31464
31465
3146649.5 Closed mailing lists
31467-------------------------
31468
31469The examples so far have assumed open mailing lists, to which anybody may send
31470mail. It is also possible to set up closed lists, where mail is accepted from
31471specified senders only. This is done by making use of the generic senders
31472option to restrict the router that handles the list.
31473
31474The following example uses the same file as a list of recipients and as a list
31475of permitted senders. It requires three routers:
31476
31477lists_request:
31478 driver = redirect
31479 domains = lists.example
31480 local_part_suffix = -request
31481 file = /usr/lists/$local_part$local_part_suffix
31482 no_more
31483
31484lists_post:
31485 driver = redirect
31486 domains = lists.example
31487 senders = ${if exists {/usr/lists/$local_part}\
31488 {lsearch;/usr/lists/$local_part}{*}}
31489 file = /usr/lists/$local_part
31490 forbid_pipe
31491 forbid_file
31492 errors_to = $local_part-request@lists.example
31493 no_more
31494
31495lists_closed:
31496 driver = redirect
31497 domains = lists.example
31498 allow_fail
31499 data = :fail: $local_part@lists.example is a closed mailing list
31500
31501All three routers have the same domains setting, so for any other domains, they
31502are all skipped. The first router runs only if the local part ends in -request.
31503It handles messages to the list manager(s) by means of an open mailing list.
31504
31505The second router runs only if the senders precondition is satisfied. It checks
31506for the existence of a list that corresponds to the local part, and then checks
31507that the sender is on the list by means of a linear search. It is necessary to
31508check for the existence of the file before trying to search it, because
31509otherwise Exim thinks there is a configuration error. If the file does not
31510exist, the expansion of senders is *, which matches all senders. This means
31511that the router runs, but because there is no list, declines, and no_more
31512ensures that no further routers are run. The address fails with an "unrouteable
31513address" error.
31514
31515The third router runs only if the second router is skipped, which happens when
31516a mailing list exists, but the sender is not on it. This router forcibly fails
31517the address, giving a suitable error message.
31518
31519
3152049.6 Variable Envelope Return Paths (VERP)
31521------------------------------------------
31522
31523Variable Envelope Return Paths - see http://cr.yp.to/proto/verp.txt - are a way
31524of helping mailing list administrators discover which subscription address is
31525the cause of a particular delivery failure. The idea is to encode the original
31526recipient address in the outgoing envelope sender address, so that if the
31527message is forwarded by another host and then subsequently bounces, the
31528original recipient can be extracted from the recipient address of the bounce.
31529
31530Envelope sender addresses can be modified by Exim using two different
31531facilities: the errors_to option on a router (as shown in previous mailing list
31532examples), or the return_path option on a transport. The second of these is
31533effective only if the message is successfully delivered to another host; it is
31534not used for errors detected on the local host (see the description of
31535return_path in chapter 24). Here is an example of the use of return_path to
31536implement VERP on an smtp transport:
31537
31538verp_smtp:
31539 driver = smtp
31540 max_rcpt = 1
31541 return_path = \
31542 ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
31543 {$1-request+$local_part=$domain@your.dom.example}fail}
31544
31545This has the effect of rewriting the return path (envelope sender) on outgoing
31546SMTP messages, if the local part of the original return path ends in
31547"-request", and the domain is your.dom.example. The rewriting inserts the local
31548part and domain of the recipient into the return path. Suppose, for example,
31549that a message whose return path has been set to
31550somelist-request@your.dom.example is sent to subscriber@other.dom.example. In
31551the transport, the return path is rewritten as
31552
31553somelist-request+subscriber=other.dom.example@your.dom.example
31554
31555For this to work, you must tell Exim to send multiple copies of messages that
31556have more than one recipient, so that each copy has just one recipient. This is
31557achieved by setting max_rcpt to 1. Without this, a single copy of a message
31558might be sent to several different recipients in the same domain, in which case
31559$local_part is not available in the transport, because it is not unique.
31560
31561Unless your host is doing nothing but mailing list deliveries, you should
31562probably use a separate transport for the VERP deliveries, so as not to use
31563extra resources in making one-per-recipient copies for other deliveries. This
31564can easily be done by expanding the transport option in the router:
31565
31566dnslookup:
31567 driver = dnslookup
31568 domains = ! +local_domains
31569 transport = \
31570 ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
31571 {verp_smtp}{remote_smtp}}
31572 no_more
31573
31574If you want to change the return path using errors_to in a router instead of
31575using return_path in the transport, you need to set errors_to on all routers
31576that handle mailing list addresses. This will ensure that all delivery errors,
31577including those detected on the local host, are sent to the VERP address.
31578
31579On a host that does no local deliveries and has no manual routing, only the
31580dnslookup router needs to be changed. A special transport is not needed for
31581SMTP deliveries. Every mailing list recipient has its own return path value,
31582and so Exim must hand them to the transport one at a time. Here is an example
31583of a dnslookup router that implements VERP:
31584
31585verp_dnslookup:
31586 driver = dnslookup
31587 domains = ! +local_domains
31588 transport = remote_smtp
31589 errors_to = \
31590 ${if match {$return_path}{^(.+?)-request@your.dom.example\$}}
31591 {$1-request+$local_part=$domain@your.dom.example}fail}
31592 no_more
31593
31594Before you start sending out messages with VERPed return paths, you must also
31595configure Exim to accept the bounce messages that come back to those paths.
31596Typically this is done by setting a local_part_suffix option for a router, and
31597using this to route the messages to wherever you want to handle them.
31598
31599The overhead incurred in using VERP depends very much on the size of the
31600message, the number of recipient addresses that resolve to the same remote
31601host, and the speed of the connection over which the message is being sent. If
31602a lot of addresses resolve to the same host and the connection is slow, sending
31603a separate copy of the message for each address may take substantially longer
31604than sending a single copy with many recipients (for which VERP cannot be
31605used).
31606
31607
3160849.7 Virtual domains
31609--------------------
31610
31611The phrase virtual domain is unfortunately used with two rather different
31612meanings:
31613
31614 * A domain for which there are no real mailboxes; all valid local parts are
31615 aliases for other email addresses. Common examples are organizational
31616 top-level domains and "vanity" domains.
31617
31618 * One of a number of independent domains that are all handled by the same
31619 host, with mailboxes on that host, but where the mailbox owners do not
31620 necessarily have login accounts on that host.
31621
31622The first usage is probably more common, and does seem more "virtual" than the
31623second. This kind of domain can be handled in Exim with a straightforward
31624aliasing router. One approach is to create a separate alias file for each
31625virtual domain. Exim can test for the existence of the alias file to determine
31626whether the domain exists. The dsearch lookup type is useful here, leading to a
31627router of this form:
31628
31629virtual:
31630 driver = redirect
31631 domains = dsearch;/etc/mail/virtual
31632 data = ${lookup{$local_part}lsearch{/etc/mail/virtual/$domain}}
31633 no_more
31634
31635The domains option specifies that the router is to be skipped, unless there is
31636a file in the /etc/mail/virtual directory whose name is the same as the domain
31637that is being processed. When the router runs, it looks up the local part in
31638the file to find a new address (or list of addresses). The no_more setting
31639ensures that if the lookup fails (leading to data being an empty string), Exim
31640gives up on the address without trying any subsequent routers.
31641
31642This one router can handle all the virtual domains because the alias file names
31643follow a fixed pattern. Permissions can be arranged so that appropriate people
31644can edit the different alias files. A successful aliasing operation results in
31645a new envelope recipient address, which is then routed from scratch.
31646
31647The other kind of "virtual" domain can also be handled in a straightforward
31648way. One approach is to create a file for each domain containing a list of
31649valid local parts, and use it in a router like this:
31650
31651my_domains:
31652 driver = accept
31653 domains = dsearch;/etc/mail/domains
31654 local_parts = lsearch;/etc/mail/domains/$domain
31655 transport = my_mailboxes
31656
31657The address is accepted if there is a file for the domain, and the local part
31658can be found in the file. The domains option is used to check for the file's
31659existence because domains is tested before the local_parts option (see section
316603.12). You cannot use require_files, because that option is tested after
31661local_parts. The transport is as follows:
31662
31663my_mailboxes:
31664 driver = appendfile
31665 file = /var/mail/$domain/$local_part
31666 user = mail
31667
31668This uses a directory of mailboxes for each domain. The user setting is
31669required, to specify which uid is to be used for writing to the mailboxes.
31670
31671The configuration shown here is just one example of how you might support this
31672requirement. There are many other ways this kind of configuration can be set
31673up, for example, by using a database instead of separate files to hold all the
31674information about the domains.
31675
31676
3167749.8 Multiple user mailboxes
31678----------------------------
31679
31680Heavy email users often want to operate with multiple mailboxes, into which
31681incoming mail is automatically sorted. A popular way of handling this is to
31682allow users to use multiple sender addresses, so that replies can easily be
31683identified. Users are permitted to add prefixes or suffixes to their local
31684parts for this purpose. The wildcard facility of the generic router options
31685local_part_prefix and local_part_suffix can be used for this. For example,
31686consider this router:
31687
31688userforward:
31689 driver = redirect
31690 check_local_user
31691 file = $home/.forward
31692 local_part_suffix = -*
31693 local_part_suffix_optional
31694 allow_filter
31695
31696It runs a user's .forward file for all local parts of the form username-*.
31697Within the filter file the user can distinguish different cases by testing the
31698variable $local_part_suffix. For example:
31699
31700if $local_part_suffix contains -special then
31701save /home/$local_part/Mail/special
31702endif
31703
31704If the filter file does not exist, or does not deal with such addresses, they
31705fall through to subsequent routers, and, assuming no subsequent use of the
31706local_part_suffix option is made, they presumably fail. Thus, users have
31707control over which suffixes are valid.
31708
31709Alternatively, a suffix can be used to trigger the use of a different .forward
31710file - which is the way a similar facility is implemented in another MTA:
31711
31712userforward:
31713 driver = redirect
31714 check_local_user
31715 file = $home/.forward$local_part_suffix
31716 local_part_suffix = -*
31717 local_part_suffix_optional
31718 allow_filter
31719
31720If there is no suffix, .forward is used; if the suffix is -special, for
31721example, .forward-special is used. Once again, if the appropriate file does not
31722exist, or does not deal with the address, it is passed on to subsequent
31723routers, which could, if required, look for an unqualified .forward file to use
31724as a default.
31725
31726
3172749.9 Simplified vacation processing
31728-----------------------------------
31729
31730The traditional way of running the vacation program is for a user to set up a
31731pipe command in a .forward file (see section 22.6 for syntax details). This is
31732prone to error by inexperienced users. There are two features of Exim that can
31733be used to make this process simpler for users:
31734
31735 * A local part prefix such as "vacation-" can be specified on a router which
31736 can cause the message to be delivered directly to the vacation program, or
31737 alternatively can use Exim's autoreply transport. The contents of a user's
31738 .forward file are then much simpler. For example:
31739
31740 spqr, vacation-spqr
31741
31742 * The require_files generic router option can be used to trigger a vacation
31743 delivery by checking for the existence of a certain file in the user's home
31744 directory. The unseen generic option should also be used, to ensure that
31745 the original delivery also proceeds. In this case, all the user has to do
31746 is to create a file called, say, .vacation, containing a vacation message.
31747
31748Another advantage of both these methods is that they both work even when the
31749use of arbitrary pipes by users is locked out.
31750
31751
3175249.10 Taking copies of mail
31753---------------------------
31754
31755Some installations have policies that require archive copies of all messages to
31756be made. A single copy of each message can easily be taken by an appropriate
31757command in a system filter, which could, for example, use a different file for
31758each day's messages.
31759
31760There is also a shadow transport mechanism that can be used to take copies of
31761messages that are successfully delivered by local transports, one copy per
31762delivery. This could be used, inter alia, to implement automatic notification
31763of delivery by sites that insist on doing such things.
31764
31765
3176649.11 Intermittently connected hosts
31767------------------------------------
31768
31769It has become quite common (because it is cheaper) for hosts to connect to the
31770Internet periodically rather than remain connected all the time. The normal
31771arrangement is that mail for such hosts accumulates on a system that is
31772permanently connected.
31773
31774Exim was designed for use on permanently connected hosts, and so it is not
31775particularly well-suited to use in an intermittently connected environment.
31776Nevertheless there are some features that can be used.
31777
31778
3177949.12 Exim on the upstream server host
31780--------------------------------------
31781
31782It is tempting to arrange for incoming mail for the intermittently connected
31783host to remain on Exim's queue until the client connects. However, this
31784approach does not scale very well. Two different kinds of waiting message are
31785being mixed up in the same queue - those that cannot be delivered because of
31786some temporary problem, and those that are waiting for their destination host
31787to connect. This makes it hard to manage the queue, as well as wasting
31788resources, because each queue runner scans the entire queue.
31789
31790A better approach is to separate off those messages that are waiting for an
31791intermittently connected host. This can be done by delivering these messages
31792into local files in batch SMTP, "mailstore", or other envelope-preserving
31793format, from where they are transmitted by other software when their
31794destination connects. This makes it easy to collect all the mail for one host
31795in a single directory, and to apply local timeout rules on a per-message basis
31796if required.
31797
31798On a very small scale, leaving the mail on Exim's queue can be made to work. If
31799you are doing this, you should configure Exim with a long retry period for the
31800intermittent host. For example:
31801
31802cheshire.wonderland.fict.example * F,5d,24h
31803
31804This stops a lot of failed delivery attempts from occurring, but Exim remembers
31805which messages it has queued up for that host. Once the intermittent host comes
31806online, forcing delivery of one message (either by using the -M or -R options,
31807or by using the ETRN SMTP command (see section 47.8) causes all the queued up
31808messages to be delivered, often down a single SMTP connection. While the host
31809remains connected, any new messages get delivered immediately.
31810
31811If the connecting hosts do not have fixed IP addresses, that is, if a host is
31812issued with a different IP address each time it connects, Exim's retry
31813mechanisms on the holding host get confused, because the IP address is normally
31814used as part of the key string for holding retry information. This can be
31815avoided by unsetting retry_include_ip_address on the smtp transport. Since this
31816has disadvantages for permanently connected hosts, it is best to arrange a
31817separate transport for the intermittently connected ones.
31818
31819
3182049.13 Exim on the intermittently connected client host
31821------------------------------------------------------
31822
31823The value of smtp_accept_queue_per_connection should probably be increased, or
31824even set to zero (that is, disabled) on the intermittently connected host, so
31825that all incoming messages down a single connection get delivered immediately.
31826
31827Mail waiting to be sent from an intermittently connected host will probably not
31828have been routed, because without a connection DNS lookups are not possible.
31829This means that if a normal queue run is done at connection time, each message
31830is likely to be sent in a separate SMTP session. This can be avoided by
31831starting the queue run with a command line option beginning with -qq instead of
31832-q. In this case, the queue is scanned twice. In the first pass, routing is
31833done but no deliveries take place. The second pass is a normal queue run; since
31834all the messages have been previously routed, those destined for the same host
31835are likely to get sent as multiple deliveries in a single SMTP connection.
31836
31837
31838
31839===============================================================================
3184050. USING EXIM AS A NON-QUEUEING CLIENT
31841
31842On a personal computer, it is a common requirement for all email to be sent to
31843a "smart host". There are plenty of MUAs that can be configured to operate that
31844way, for all the popular operating systems. However, there are some MUAs for
31845Unix-like systems that cannot be so configured: they submit messages using the
31846command line interface of /usr/sbin/sendmail. Furthermore, utility programs
31847such as cron submit messages this way.
31848
31849If the personal computer runs continuously, there is no problem, because it can
31850run a conventional MTA that handles delivery to the smart host, and deal with
31851any delays via its queueing mechanism. However, if the computer does not run
31852continuously or runs different operating systems at different times, queueing
31853email is not desirable.
31854
31855There is therefore a requirement for something that can provide the /usr/sbin/
31856sendmail interface but deliver messages to a smart host without any queueing or
31857retrying facilities. Furthermore, the delivery to the smart host should be
31858synchronous, so that if it fails, the sending MUA is immediately informed. In
31859other words, we want something that extends an MUA that submits to a local MTA
31860via the command line so that it behaves like one that submits to a remote smart
31861host using TCP/SMTP.
31862
31863There are a number of applications (for example, there is one called ssmtp)
31864that do this job. However, people have found them to be lacking in various
31865ways. For instance, you might want to allow aliasing and forwarding to be done
31866before sending a message to the smart host.
31867
31868Exim already had the necessary infrastructure for doing this job. Just a few
31869tweaks were needed to make it behave as required, though it is somewhat of an
31870overkill to use a fully-featured MTA for this purpose.
31871
31872There is a Boolean global option called mua_wrapper, defaulting false. Setting
31873mua_wrapper true causes Exim to run in a special mode where it assumes that it
31874is being used to "wrap" a command-line MUA in the manner just described. As
31875well as setting mua_wrapper, you also need to provide a compatible router and
31876transport configuration. Typically there will be just one router and one
31877transport, sending everything to a smart host.
31878
31879When run in MUA wrapping mode, the behaviour of Exim changes in the following
31880ways:
31881
31882 * A daemon cannot be run, nor will Exim accept incoming messages from inetd.
31883 In other words, the only way to submit messages is via the command line.
31884
31885 * Each message is synchronously delivered as soon as it is received (-odi is
31886 assumed). All queueing options (queue_only, queue_smtp_domains, control in
31887 an ACL, etc.) are quietly ignored. The Exim reception process does not
31888 finish until the delivery attempt is complete. If the delivery is
31889 successful, a zero return code is given.
31890
31891 * Address redirection is permitted, but the final routing for all addresses
31892 must be to the same remote transport, and to the same list of hosts.
31893 Furthermore, the return address (envelope sender) must be the same for all
31894 recipients, as must any added or deleted header lines. In other words, it
31895 must be possible to deliver the message in a single SMTP transaction,
31896 however many recipients there are.
31897
31898 * If these conditions are not met, or if routing any address results in a
31899 failure or defer status, or if Exim is unable to deliver all the recipients
31900 successfully to one of the smart hosts, delivery of the entire message
31901 fails.
31902
31903 * Because no queueing is allowed, all failures are treated as permanent;
31904 there is no distinction between 4xx and 5xx SMTP response codes from the
31905 smart host. Furthermore, because only a single yes/no response can be given
31906 to the caller, it is not possible to deliver to some recipients and not
31907 others. If there is an error (temporary or permanent) for any recipient,
31908 all are failed.
31909
31910 * If more than one smart host is listed, Exim will try another host after a
31911 connection failure or a timeout, in the normal way. However, if this kind
31912 of failure happens for all the hosts, the delivery fails.
31913
31914 * When delivery fails, an error message is written to the standard error
31915 stream (as well as to Exim's log), and Exim exits to the caller with a
31916 return code value 1. The message is expunged from Exim's spool files. No
31917 bounce messages are ever generated.
31918
31919 * No retry data is maintained, and any retry rules are ignored.
31920
31921 * A number of Exim options are overridden: deliver_drop_privilege is forced
31922 true, max_rcpt in the smtp transport is forced to "unlimited",
31923 remote_max_parallel is forced to one, and fallback hosts are ignored.
31924
31925The overall effect is that Exim makes a single synchronous attempt to deliver
31926the message, failing if there is any kind of problem. Because no local
31927deliveries are done and no daemon can be run, Exim does not need root
31928privilege. It should be possible to run it setuid to exim instead of setuid to
31929root. See section 54.3 for a general discussion about the advantages and
31930disadvantages of running without root privilege.
31931
31932
31933
31934===============================================================================
3193551. LOG FILES
31936
31937Exim writes three different logs, referred to as the main log, the reject log,
31938and the panic log:
31939
31940 * The main log records the arrival of each message and each delivery in a
31941 single line in each case. The format is as compact as possible, in an
31942 attempt to keep down the size of log files. Two-character flag sequences
31943 make it easy to pick out these lines. A number of other events are recorded
31944 in the main log. Some of them are optional, in which case the log_selector
31945 option controls whether they are included or not. A Perl script called
31946 eximstats, which does simple analysis of main log files, is provided in the
31947 Exim distribution (see section 52.7).
31948
31949 * The reject log records information from messages that are rejected as a
31950 result of a configuration option (that is, for policy reasons). The first
31951 line of each rejection is a copy of the line that is also written to the
31952 main log. Then, if the message's header has been read at the time the log
31953 is written, its contents are written to this log. Only the original header
31954 lines are available; header lines added by ACLs are not logged. You can use
31955 the reject log to check that your policy controls are working correctly; on
31956 a busy host this may be easier than scanning the main log for rejection
31957 messages. You can suppress the writing of the reject log by setting
31958 write_rejectlog false.
31959
31960 * When certain serious errors occur, Exim writes entries to its panic log. If
31961 the error is sufficiently disastrous, Exim bombs out afterwards. Panic log
31962 entries are usually written to the main log as well, but can get lost amid
31963 the mass of other entries. The panic log should be empty under normal
31964 circumstances. It is therefore a good idea to check it (or to have a cron
31965 script check it) regularly, in order to become aware of any problems. When
31966 Exim cannot open its panic log, it tries as a last resort to write to the
31967 system log (syslog). This is opened with LOG_PID+LOG_CONS and the facility
31968 code of LOG_MAIL. The message itself is written at priority LOG_CRIT.
31969
31970Every log line starts with a timestamp, in the format shown in the following
31971example. Note that many of the examples shown in this chapter are line-wrapped.
31972In the log file, this would be all on one line:
31973
319742001-09-16 16:09:47 SMTP connection from [127.0.0.1] closed
31975 by QUIT
31976
31977By default, the timestamps are in the local timezone. There are two ways of
31978changing this:
31979
31980 * You can set the timezone option to a different time zone; in particular, if
31981 you set
31982
31983 timezone = UTC
31984
31985 the timestamps will be in UTC (aka GMT).
31986
31987 * If you set log_timezone true, the time zone is added to the timestamp, for
31988 example:
31989
31990 2003-04-25 11:17:07 +0100 Start queue run: pid=12762
31991
31992Exim does not include its process id in log lines by default, but you can
31993request that it does so by specifying the "pid" log selector (see section 51.15
31994). When this is set, the process id is output, in square brackets, immediately
31995after the time and date.
31996
31997
3199851.1 Where the logs are written
31999-------------------------------
32000
32001The logs may be written to local files, or to syslog, or both. However, it
32002should be noted that many syslog implementations use UDP as a transport, and
32003are therefore unreliable in the sense that messages are not guaranteed to
32004arrive at the loghost, nor is the ordering of messages necessarily maintained.
32005It has also been reported that on large log files (tens of megabytes) you may
32006need to tweak syslog to prevent it syncing the file with each write - on Linux
32007this has been seen to make syslog take 90% plus of CPU time.
32008
32009The destination for Exim's logs is configured by setting LOG_FILE_PATH in Local
32010/Makefile or by setting log_file_path in the run time configuration. This
32011latter string is expanded, so it can contain, for example, references to the
32012host name:
32013
32014log_file_path = /var/log/$primary_hostname/exim_%slog
32015
32016It is generally advisable, however, to set the string in Local/Makefile rather
32017than at run time, because then the setting is available right from the start of
32018Exim's execution. Otherwise, if there's something it wants to log before it has
32019read the configuration file (for example, an error in the configuration file)
32020it will not use the path you want, and may not be able to log at all.
32021
32022The value of LOG_FILE_PATH or log_file_path is a colon-separated list,
32023currently limited to at most two items. This is one option where the facility
32024for changing a list separator may not be used. The list must always be
32025colon-separated. If an item in the list is "syslog" then syslog is used;
32026otherwise the item must either be an absolute path, containing "%s" at the
32027point where "main", "reject", or "panic" is to be inserted, or be empty,
32028implying the use of a default path.
32029
32030When Exim encounters an empty item in the list, it searches the list defined by
32031LOG_FILE_PATH, and uses the first item it finds that is neither empty nor
32032"syslog". This means that an empty item in log_file_path can be used to mean
32033"use the path specified at build time". It no such item exists, log files are
32034written in the log subdirectory of the spool directory. This is equivalent to
32035the setting:
32036
32037log_file_path = $spool_directory/log/%slog
32038
32039If you do not specify anything at build time or run time, that is where the
32040logs are written.
32041
32042A log file path may also contain "%D" or "%M" if datestamped log file names are
32043in use - see section 51.3 below.
32044
32045Here are some examples of possible settings:
32046
32047LOG_FILE_PATH=syslog syslog only
32048LOG_FILE_PATH=:syslog syslog and default path
32049LOG_FILE_PATH=syslog : /usr/log/exim_%s syslog and specified path
32050LOG_FILE_PATH=/usr/log/exim_%s specified path only
32051
32052If there are more than two paths in the list, the first is used and a panic
32053error is logged.
32054
32055
3205651.2 Logging to local files that are periodically "cycled"
32057----------------------------------------------------------
32058
32059Some operating systems provide centralized and standardized methods for cycling
32060log files. For those that do not, a utility script called exicyclog is provided
32061(see section 52.6). This renames and compresses the main and reject logs each
32062time it is called. The maximum number of old logs to keep can be set. It is
32063suggested this script is run as a daily cron job.
32064
32065An Exim delivery process opens the main log when it first needs to write to it,
32066and it keeps the file open in case subsequent entries are required - for
32067example, if a number of different deliveries are being done for the same
32068message. However, remote SMTP deliveries can take a long time, and this means
32069that the file may be kept open long after it is renamed if exicyclog or
32070something similar is being used to rename log files on a regular basis. To
32071ensure that a switch of log files is noticed as soon as possible, Exim calls
32072stat() on the main log's name before reusing an open file, and if the file does
32073not exist, or its inode has changed, the old file is closed and Exim tries to
32074open the main log from scratch. Thus, an old log file may remain open for quite
32075some time, but no Exim processes should write to it once it has been renamed.
32076
32077
3207851.3 Datestamped log files
32079--------------------------
32080
32081Instead of cycling the main and reject log files by renaming them periodically,
32082some sites like to use files whose names contain a datestamp, for example,
32083mainlog-20031225. The datestamp is in the form yyyymmdd or yyyymm. Exim has
32084support for this way of working. It is enabled by setting the log_file_path
32085option to a path that includes "%D" or "%M" at the point where the datestamp is
32086required. For example:
32087
32088log_file_path = /var/spool/exim/log/%slog-%D
32089log_file_path = /var/log/exim-%s-%D.log
32090log_file_path = /var/spool/exim/log/%D-%slog
32091log_file_path = /var/log/exim/%s.%M
32092
32093As before, "%s" is replaced by "main" or "reject"; the following are examples
32094of names generated by the above examples:
32095
32096/var/spool/exim/log/mainlog-20021225
32097/var/log/exim-reject-20021225.log
32098/var/spool/exim/log/20021225-mainlog
32099/var/log/exim/main.200212
32100
32101When this form of log file is specified, Exim automatically switches to new
32102files at midnight. It does not make any attempt to compress old logs; you will
32103need to write your own script if you require this. You should not run exicyclog
32104with this form of logging.
32105
32106The location of the panic log is also determined by log_file_path, but it is
32107not datestamped, because rotation of the panic log does not make sense. When
32108generating the name of the panic log, "%D" or "%M" are removed from the string.
32109In addition, if it immediately follows a slash, a following non-alphanumeric
32110character is removed; otherwise a preceding non-alphanumeric character is
32111removed. Thus, the four examples above would give these panic log names:
32112
32113/var/spool/exim/log/paniclog
32114/var/log/exim-panic.log
32115/var/spool/exim/log/paniclog
32116/var/log/exim/panic
32117
32118
3211951.4 Logging to syslog
32120----------------------
32121
32122The use of syslog does not change what Exim logs or the format of its messages,
32123except in one respect. If syslog_timestamp is set false, the timestamps on
32124Exim's log lines are omitted when these lines are sent to syslog. Apart from
32125that, the same strings are written to syslog as to log files. The syslog
32126"facility" is set to LOG_MAIL, and the program name to "exim" by default, but
32127you can change these by setting the syslog_facility and syslog_processname
32128options, respectively. If Exim was compiled with SYSLOG_LOG_PID set in Local/
32129Makefile (this is the default in src/EDITME), then, on systems that permit it
32130(all except ULTRIX), the LOG_PID flag is set so that the syslog() call adds the
32131pid as well as the time and host name to each line. The three log streams are
32132mapped onto syslog priorities as follows:
32133
32134 * mainlog is mapped to LOG_INFO
32135
32136 * rejectlog is mapped to LOG_NOTICE
32137
32138 * paniclog is mapped to LOG_ALERT
32139
32140Many log lines are written to both mainlog and rejectlog, and some are written
32141to both mainlog and paniclog, so there will be duplicates if these are routed
32142by syslog to the same place. You can suppress this duplication by setting
32143syslog_duplication false.
32144
32145Exim's log lines can sometimes be very long, and some of its rejectlog entries
32146contain multiple lines when headers are included. To cope with both these
32147cases, entries written to syslog are split into separate syslog() calls at each
32148internal newline, and also after a maximum of 870 data characters. (This allows
32149for a total syslog line length of 1024, when additions such as timestamps are
32150added.) If you are running a syslog replacement that can handle lines longer
32151than the 1024 characters allowed by RFC 3164, you should set
32152
32153SYSLOG_LONG_LINES=yes
32154
32155in Local/Makefile before building Exim. That stops Exim from splitting long
32156lines, but it still splits at internal newlines in reject log entries.
32157
32158To make it easy to re-assemble split lines later, each component of a split
32159entry starts with a string of the form [<n>/<m>] or [<n>\<m>] where <n> is the
32160component number and <m> is the total number of components in the entry. The /
32161delimiter is used when the line was split because it was too long; if it was
32162split because of an internal newline, the \ delimiter is used. For example,
32163supposing the length limit to be 50 instead of 870, the following would be the
32164result of a typical rejection message to mainlog (LOG_INFO), each line in
32165addition being preceded by the time, host name, and pid as added by syslog:
32166
32167[1/5] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from
32168[2/5] [127.0.0.1] (ph10): syntax error in 'From' header
32169[3/5] when scanning for sender: missing or malformed lo
32170[4/5] cal part in "<>" (envelope sender is <ph10@cam.exa
32171[5/5] mple>)
32172
32173The same error might cause the following lines to be written to "rejectlog"
32174(LOG_NOTICE):
32175
32176[1/18] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected fro
32177[2/18] m [127.0.0.1] (ph10): syntax error in 'From' head
32178[3/18] er when scanning for sender: missing or malformed
32179[4/18] local part in "<>" (envelope sender is <ph10@cam
32180[5\18] .example>)
32181[6\18] Recipients: ph10@some.domain.cam.example
32182[7\18] P Received: from [127.0.0.1] (ident=ph10)
32183[8\18] by xxxxx.cam.example with smtp (Exim 4.00)
32184[9\18] id 16RdAL-0006pc-00
32185[10/18] for ph10@cam.example; Mon, 16 Sep 2002 16:
32186[11\18] 09:43 +0100
32187[12\18] F From: <>
32188[13\18] Subject: this is a test header
32189[18\18] X-something: this is another header
32190[15/18] I Message-Id: <E16RdAL-0006pc-00@xxxxx.cam.examp
32191[16\18] le>
32192[17\18] B Bcc:
32193[18/18] Date: Mon, 16 Sep 2002 16:09:43 +0100
32194
32195Log lines that are neither too long nor contain newlines are written to syslog
32196without modification.
32197
32198If only syslog is being used, the Exim monitor is unable to provide a log tail
32199display, unless syslog is routing mainlog to a file on the local host and the
32200environment variable EXIMON_LOG_FILE_PATH is set to tell the monitor where it
32201is.
32202
32203
3220451.5 Log line flags
32205-------------------
32206
32207One line is written to the main log for each message received, and for each
32208successful, unsuccessful, and delayed delivery. These lines can readily be
32209picked out by the distinctive two-character flags that immediately follow the
32210timestamp. The flags are:
32211
32212<= message arrival
32213=> normal message delivery
32214-> additional address in same delivery
32215>> cutthrough message delivery
32216*> delivery suppressed by -N
32217** delivery failed; address bounced
32218== delivery deferred; temporary problem
32219
32220
3222151.6 Logging message reception
32222------------------------------
32223
32224The format of the single-line entry in the main log that is written for every
32225message received is shown in the basic example below, which is split over
32226several lines in order to fit it on the page:
32227
322282002-10-31 08:57:53 16ZCW1-0005MB-00 <= kryten@dwarf.fict.example
32229 H=mailer.fict.example [192.168.123.123] U=exim
32230 P=smtp S=5678 id=<incoming message id>
32231
32232The address immediately following "<=" is the envelope sender address. A bounce
32233message is shown with the sender address "<>", and if it is locally generated,
32234this is followed by an item of the form
32235
32236R=<message id>
32237
32238which is a reference to the message that caused the bounce to be sent.
32239
32240For messages from other hosts, the H and U fields identify the remote host and
32241record the RFC 1413 identity of the user that sent the message, if one was
32242received. The number given in square brackets is the IP address of the sending
32243host. If there is a single, unparenthesized host name in the H field, as above,
32244it has been verified to correspond to the IP address (see the host_lookup
32245option). If the name is in parentheses, it was the name quoted by the remote
32246host in the SMTP HELO or EHLO command, and has not been verified. If
32247verification yields a different name to that given for HELO or EHLO, the
32248verified name appears first, followed by the HELO or EHLO name in parentheses.
32249
32250Misconfigured hosts (and mail forgers) sometimes put an IP address, with or
32251without brackets, in the HELO or EHLO command, leading to entries in the log
32252containing text like these examples:
32253
32254H=(10.21.32.43) [192.168.8.34]
32255H=([10.21.32.43]) [192.168.8.34]
32256
32257This can be confusing. Only the final address in square brackets can be relied
32258on.
32259
32260For locally generated messages (that is, messages not received over TCP/IP),
32261the H field is omitted, and the U field contains the login name of the caller
32262of Exim.
32263
32264For all messages, the P field specifies the protocol used to receive the
32265message. This is the value that is stored in $received_protocol. In the case of
32266incoming SMTP messages, the value indicates whether or not any SMTP extensions
32267(ESMTP), encryption, or authentication were used. If the SMTP session was
32268encrypted, there is an additional X field that records the cipher suite that
32269was used.
32270
32271The protocol is set to "esmtpsa" or "esmtpa" for messages received from hosts
32272that have authenticated themselves using the SMTP AUTH command. The first value
32273is used when the SMTP connection was encrypted ("secure"). In this case there
32274is an additional item A= followed by the name of the authenticator that was
32275used. If an authenticated identification was set up by the authenticator's
32276server_set_id option, this is logged too, separated by a colon from the
32277authenticator name.
32278
32279The id field records the existing message id, if present. The size of the
32280received message is given by the S field. When the message is delivered,
32281headers may be removed or added, so that the size of delivered copies of the
32282message may not correspond with this value (and indeed may be different to each
32283other).
32284
32285The log_selector option can be used to request the logging of additional data
32286when a message is received. See section 51.15 below.
32287
32288
3228951.7 Logging deliveries
32290-----------------------
32291
32292The format of the single-line entry in the main log that is written for every
32293delivery is shown in one of the examples below, for local and remote
32294deliveries, respectively. Each example has been split into two lines in order
32295to fit it on the page:
32296
322972002-10-31 08:59:13 16ZCW1-0005MB-00 => marv
32298 <marv@hitch.fict.example> R=localuser T=local_delivery
322992002-10-31 09:00:10 16ZCW1-0005MB-00 =>
32300 monk@holistic.fict.example R=dnslookup T=remote_smtp
32301 H=holistic.fict.example [192.168.234.234]
32302
32303For ordinary local deliveries, the original address is given in angle brackets
32304after the final delivery address, which might be a pipe or a file. If
32305intermediate address(es) exist between the original and the final address, the
32306last of these is given in parentheses after the final address. The R and T
32307fields record the router and transport that were used to process the address.
32308
32309If SMTP AUTH was used for the delivery there is an additional item A= followed
32310by the name of the authenticator that was used. If an authenticated
32311identification was set up by the authenticator's client_set_id option, this is
32312logged too, separated by a colon from the authenticator name.
32313
32314If a shadow transport was run after a successful local delivery, the log line
32315for the successful delivery has an item added on the end, of the form
32316
32317ST=<shadow transport name>
32318
32319If the shadow transport did not succeed, the error message is put in
32320parentheses afterwards.
32321
32322When more than one address is included in a single delivery (for example, two
32323SMTP RCPT commands in one transaction) the second and subsequent addresses are
32324flagged with "->" instead of "=>". When two or more messages are delivered down
32325a single SMTP connection, an asterisk follows the IP address in the log lines
32326for the second and subsequent messages.
32327
32328When delivery is done in cutthrough mode it is flagged with ">>" and the log
32329line precedes the reception line, since cutthrough waits for a possible
32330rejection from the destination in case it can reject the sourced item.
32331
32332The generation of a reply message by a filter file gets logged as a "delivery"
32333to the addressee, preceded by ">".
32334
32335The log_selector option can be used to request the logging of additional data
32336when a message is delivered. See section 51.15 below.
32337
32338
3233951.8 Discarded deliveries
32340-------------------------
32341
32342When a message is discarded as a result of the command "seen finish" being
32343obeyed in a filter file which generates no deliveries, a log entry of the form
32344
323452002-12-10 00:50:49 16auJc-0001UB-00 => discarded
32346 <low.club@bridge.example> R=userforward
32347
32348is written, to record why no deliveries are logged. When a message is discarded
32349because it is aliased to ":blackhole:" the log line is like this:
32350
323511999-03-02 09:44:33 10HmaX-0005vi-00 => :blackhole:
32352 <hole@nowhere.example> R=blackhole_router
32353
32354
3235551.9 Deferred deliveries
32356------------------------
32357
32358When a delivery is deferred, a line of the following form is logged:
32359
323602002-12-19 16:20:23 16aiQz-0002Q5-00 == marvin@endrest.example
32361 R=dnslookup T=smtp defer (146): Connection refused
32362
32363In the case of remote deliveries, the error is the one that was given for the
32364last IP address that was tried. Details of individual SMTP failures are also
32365written to the log, so the above line would be preceded by something like
32366
323672002-12-19 16:20:23 16aiQz-0002Q5-00 Failed to connect to
32368 mail1.endrest.example [192.168.239.239]: Connection refused
32369
32370When a deferred address is skipped because its retry time has not been reached,
32371a message is written to the log, but this can be suppressed by setting an
32372appropriate value in log_selector.
32373
32374
3237551.10 Delivery failures
32376-----------------------
32377
32378If a delivery fails because an address cannot be routed, a line of the
32379following form is logged:
32380
323811995-12-19 16:20:23 0tRiQz-0002Q5-00 ** jim@trek99.example
32382 <jim@trek99.example>: unknown mail domain
32383
32384If a delivery fails at transport time, the router and transport are shown, and
32385the response from the remote host is included, as in this example:
32386
323872002-07-11 07:14:17 17SXDU-000189-00 ** ace400@pb.example
32388 R=dnslookup T=remote_smtp: SMTP error from remote mailer
32389 after pipelined RCPT TO:<ace400@pb.example>: host
32390 pbmail3.py.example [192.168.63.111]: 553 5.3.0
32391 <ace400@pb.example>...Addressee unknown
32392
32393The word "pipelined" indicates that the SMTP PIPELINING extension was being
32394used. See hosts_avoid_esmtp in the smtp transport for a way of disabling
32395PIPELINING. The log lines for all forms of delivery failure are flagged with
32396"**".
32397
32398
3239951.11 Fake deliveries
32400---------------------
32401
32402If a delivery does not actually take place because the -N option has been used
32403to suppress it, a normal delivery line is written to the log, except that "=>"
32404is replaced by "*>".
32405
32406
3240751.12 Completion
32408----------------
32409
32410A line of the form
32411
324122002-10-31 09:00:11 16ZCW1-0005MB-00 Completed
32413
32414is written to the main log when a message is about to be removed from the spool
32415at the end of its processing.
32416
32417
3241851.13 Summary of Fields in Log Lines
32419------------------------------------
32420
32421A summary of the field identifiers that are used in log lines is shown in the
32422following table:
32423
32424A authenticator name (and optional id and sender)
32425C SMTP confirmation on delivery
32426 command list for "no mail in SMTP session"
32427CV certificate verification status
32428D duration of "no mail in SMTP session"
32429DN distinguished name from peer certificate
32430DT on => lines: time taken for a delivery
32431F sender address (on delivery lines)
32432H host name and IP address
32433I local interface used
32434id message id for incoming message
32435P on <= lines: protocol used
32436 on => and ** lines: return path
32437QT on => lines: time spent on queue so far
32438 on "Completed" lines: time spent on queue
32439R on <= lines: reference for local bounce
32440 on => ** and == lines: router name
32441S size of message
32442SNI server name indication from TLS client hello
32443ST shadow transport name
32444T on <= lines: message subject (topic)
32445 on => ** and == lines: transport name
32446U local user or RFC 1413 identity
32447X TLS cipher suite
32448
32449
3245051.14 Other log entries
32451-----------------------
32452
32453Various other types of log entry are written from time to time. Most should be
32454self-explanatory. Among the more common are:
32455
32456 * retry time not reached An address previously suffered a temporary error
32457 during routing or local delivery, and the time to retry has not yet
32458 arrived. This message is not written to an individual message log file
32459 unless it happens during the first delivery attempt.
32460
32461 * retry time not reached for any host An address previously suffered
32462 temporary errors during remote delivery, and the retry time has not yet
32463 arrived for any of the hosts to which it is routed.
32464
32465 * spool file locked An attempt to deliver a message cannot proceed because
32466 some other Exim process is already working on the message. This can be
32467 quite common if queue running processes are started at frequent intervals.
32468 The exiwhat utility script can be used to find out what Exim processes are
32469 doing.
32470
32471 * error ignored There are several circumstances that give rise to this
32472 message:
32473
32474 1. Exim failed to deliver a bounce message whose age was greater than
32475 ignore_bounce_errors_after. The bounce was discarded.
32476
32477 2. A filter file set up a delivery using the "noerror" option, and the
32478 delivery failed. The delivery was discarded.
32479
32480 3. A delivery set up by a router configured with
32481
32482 errors_to = <>
32483
32484 failed. The delivery was discarded.
32485
32486
3248751.15 Reducing or increasing what is logged
32488-------------------------------------------
32489
32490By setting the log_selector global option, you can disable some of Exim's
32491default logging, or you can request additional logging. The value of
32492log_selector is made up of names preceded by plus or minus characters. For
32493example:
32494
32495log_selector = +arguments -retry_defer
32496
32497The list of optional log items is in the following table, with the default
32498selection marked by asterisks:
32499
32500 8bitmime received 8BITMIME status
32501*acl_warn_skipped skipped warn statement in ACL
32502 address_rewrite address rewriting
32503 all_parents all parents in => lines
32504 arguments command line arguments
32505*connection_reject connection rejections
32506*delay_delivery immediate delivery delayed
32507 deliver_time time taken to perform delivery
32508 delivery_size add S=nnn to => lines
32509*dnslist_defer defers of DNS list (aka RBL) lookups
32510*etrn ETRN commands
32511*host_lookup_failed as it says
32512 ident_timeout timeout for ident connection
32513 incoming_interface incoming interface on <= lines
32514 incoming_port incoming port on <= lines
32515*lost_incoming_connection as it says (includes timeouts)
32516 outgoing_port add remote port to => lines
32517*queue_run start and end queue runs
32518 queue_time time on queue for one recipient
32519 queue_time_overall time on queue for whole message
32520 pid Exim process id
32521 received_recipients recipients on <= lines
32522 received_sender sender on <= lines
32523*rejected_header header contents on reject log
32524*retry_defer "retry time not reached"
32525 return_path_on_delivery put return path on => and ** lines
32526 sender_on_delivery add sender to => lines
32527*sender_verify_fail sender verification failures
32528*size_reject rejection because too big
32529*skip_delivery delivery skipped in a queue run
32530*smtp_confirmation SMTP confirmation on => lines
32531 smtp_connection SMTP connections
32532 smtp_incomplete_transaction incomplete SMTP transactions
32533 smtp_mailauth AUTH argument to MAIL commands
32534 smtp_no_mail session with no MAIL commands
32535 smtp_protocol_error SMTP protocol errors
32536 smtp_syntax_error SMTP syntax errors
32537 subject contents of Subject: on <= lines
32538 tls_certificate_verified certificate verification status
32539*tls_cipher TLS cipher suite on <= and => lines
32540 tls_peerdn TLS peer DN on <= and => lines
32541 tls_sni TLS SNI on <= lines
32542 unknown_in_list DNS lookup failed in list match
32543
32544 all all of the above
32545
32546More details on each of these items follows:
32547
32548 * 8bitmime: This causes Exim to log any 8BITMIME status of received messages,
32549 which may help in tracking down interoperability issues with ancient MTAs
32550 that are not 8bit clean. This is added to the "<=" line, tagged with "M8S="
32551 and a value of "0", "7" or "8", corresponding to "not given", "7BIT" and
32552 "8BITMIME" respectively.
32553
32554 * acl_warn_skipped: When an ACL warn statement is skipped because one of its
32555 conditions cannot be evaluated, a log line to this effect is written if
32556 this log selector is set.
32557
32558 * address_rewrite: This applies both to global rewrites and per-transport
32559 rewrites, but not to rewrites in filters run as an unprivileged user
32560 (because such users cannot access the log).
32561
32562 * all_parents: Normally only the original and final addresses are logged on
32563 delivery lines; with this selector, intermediate parents are given in
32564 parentheses between them.
32565
32566 * arguments: This causes Exim to write the arguments with which it was called
32567 to the main log, preceded by the current working directory. This is a
32568 debugging feature, added to make it easier to find out how certain MUAs
32569 call /usr/sbin/sendmail. The logging does not happen if Exim has given up
32570 root privilege because it was called with the -C or -D options. Arguments
32571 that are empty or that contain white space are quoted. Non-printing
32572 characters are shown as escape sequences. This facility cannot log
32573 unrecognized arguments, because the arguments are checked before the
32574 configuration file is read. The only way to log such cases is to interpose
32575 a script such as util/logargs.sh between the caller and Exim.
32576
32577 * connection_reject: A log entry is written whenever an incoming SMTP
32578 connection is rejected, for whatever reason.
32579
32580 * delay_delivery: A log entry is written whenever a delivery process is not
32581 started for an incoming message because the load is too high or too many
32582 messages were received on one connection. Logging does not occur if no
32583 delivery process is started because queue_only is set or -odq was used.
32584
32585 * deliver_time: For each delivery, the amount of real time it has taken to
32586 perform the actual delivery is logged as DT=<time>, for example, "DT=1s".
32587
32588 * delivery_size: For each delivery, the size of message delivered is added to
32589 the "=>" line, tagged with S=.
32590
32591 * dnslist_defer: A log entry is written if an attempt to look up a host in a
32592 DNS black list suffers a temporary error.
32593
32594 * etrn: Every valid ETRN command that is received is logged, before the ACL
32595 is run to determine whether or not it is actually accepted. An invalid ETRN
32596 command, or one received within a message transaction is not logged by this
32597 selector (see smtp_syntax_error and smtp_protocol_error).
32598
32599 * host_lookup_failed: When a lookup of a host's IP addresses fails to find
32600 any addresses, or when a lookup of an IP address fails to find a host name,
32601 a log line is written. This logging does not apply to direct DNS lookups
32602 when routing email addresses, but it does apply to "byname" lookups.
32603
32604 * ident_timeout: A log line is written whenever an attempt to connect to a
32605 client's ident port times out.
32606
32607 * incoming_interface: The interface on which a message was received is added
32608 to the "<=" line as an IP address in square brackets, tagged by I= and
32609 followed by a colon and the port number. The local interface and port are
32610 also added to other SMTP log lines, for example "SMTP connection from", and
32611 to rejection lines.
32612
32613 * incoming_port: The remote port number from which a message was received is
32614 added to log entries and Received: header lines, following the IP address
32615 in square brackets, and separated from it by a colon. This is implemented
32616 by changing the value that is put in the $sender_fullhost and
32617 $sender_rcvhost variables. Recording the remote port number has become more
32618 important with the widening use of NAT (see RFC 2505).
32619
32620 * lost_incoming_connection: A log line is written when an incoming SMTP
32621 connection is unexpectedly dropped.
32622
32623 * outgoing_port: The remote port number is added to delivery log lines (those
32624 containing => tags) following the IP address. This option is not included
32625 in the default setting, because for most ordinary configurations, the
32626 remote port number is always 25 (the SMTP port).
32627
32628 * pid: The current process id is added to every log line, in square brackets,
32629 immediately after the time and date.
32630
32631 * queue_run: The start and end of every queue run are logged.
32632
32633 * queue_time: The amount of time the message has been in the queue on the
32634 local host is logged as QT=<time> on delivery ("=>") lines, for example,
32635 "QT=3m45s". The clock starts when Exim starts to receive the message, so it
32636 includes reception time as well as the delivery time for the current
32637 address. This means that it may be longer than the difference between the
32638 arrival and delivery log line times, because the arrival log line is not
32639 written until the message has been successfully received.
32640
32641 * queue_time_overall: The amount of time the message has been in the queue on
32642 the local host is logged as QT=<time> on "Completed" lines, for example,
32643 "QT=3m45s". The clock starts when Exim starts to receive the message, so it
32644 includes reception time as well as the total delivery time.
32645
32646 * received_recipients: The recipients of a message are listed in the main log
32647 as soon as the message is received. The list appears at the end of the log
32648 line that is written when a message is received, preceded by the word
32649 "for". The addresses are listed after they have been qualified, but before
32650 any rewriting has taken place. Recipients that were discarded by an ACL for
32651 MAIL or RCPT do not appear in the list.
32652
32653 * received_sender: The unrewritten original sender of a message is added to
32654 the end of the log line that records the message's arrival, after the word
32655 "from" (before the recipients if received_recipients is also set).
32656
32657 * rejected_header: If a message's header has been received at the time a
32658 rejection is written to the reject log, the complete header is added to the
32659 log. Header logging can be turned off individually for messages that are
32660 rejected by the local_scan() function (see section 44.2).
32661
32662 * retry_defer: A log line is written if a delivery is deferred because a
32663 retry time has not yet been reached. However, this "retry time not reached"
32664 message is always omitted from individual message logs after the first
32665 delivery attempt.
32666
32667 * return_path_on_delivery: The return path that is being transmitted with the
32668 message is included in delivery and bounce lines, using the tag P=. This is
32669 omitted if no delivery actually happens, for example, if routing fails, or
32670 if delivery is to /dev/null or to ":blackhole:".
32671
32672 * sender_on_delivery: The message's sender address is added to every delivery
32673 and bounce line, tagged by F= (for "from"). This is the original sender
32674 that was received with the message; it is not necessarily the same as the
32675 outgoing return path.
32676
32677 * sender_verify_fail: If this selector is unset, the separate log line that
32678 gives details of a sender verification failure is not written. Log lines
32679 for the rejection of SMTP commands contain just "sender verify failed", so
32680 some detail is lost.
32681
32682 * size_reject: A log line is written whenever a message is rejected because
32683 it is too big.
32684
32685 * skip_delivery: A log line is written whenever a message is skipped during a
32686 queue run because it is frozen or because another process is already
32687 delivering it. The message that is written is "spool file is locked".
32688
32689 * smtp_confirmation: The response to the final "." in the SMTP or LMTP
32690 dialogue for outgoing messages is added to delivery log lines in the form
32691 "C="<text>. A number of MTAs (including Exim) return an identifying string
32692 in this response.
32693
32694 * smtp_connection: A log line is written whenever an SMTP connection is
32695 established or closed, unless the connection is from a host that matches
32696 hosts_connection_nolog. (In contrast, lost_incoming_connection applies only
32697 when the closure is unexpected.) This applies to connections from local
32698 processes that use -bs as well as to TCP/IP connections. If a connection is
32699 dropped in the middle of a message, a log line is always written, whether
32700 or not this selector is set, but otherwise nothing is written at the start
32701 and end of connections unless this selector is enabled.
32702
32703 For TCP/IP connections to an Exim daemon, the current number of connections
32704 is included in the log message for each new connection, but note that the
32705 count is reset if the daemon is restarted. Also, because connections are
32706 closed (and the closure is logged) in subprocesses, the count may not
32707 include connections that have been closed but whose termination the daemon
32708 has not yet noticed. Thus, while it is possible to match up the opening and
32709 closing of connections in the log, the value of the logged counts may not
32710 be entirely accurate.
32711
32712 * smtp_incomplete_transaction: When a mail transaction is aborted by RSET,
32713 QUIT, loss of connection, or otherwise, the incident is logged, and the
32714 message sender plus any accepted recipients are included in the log line.
32715 This can provide evidence of dictionary attacks.
32716
32717 * smtp_no_mail: A line is written to the main log whenever an accepted SMTP
32718 connection terminates without having issued a MAIL command. This includes
32719 both the case when the connection is dropped, and the case when QUIT is
32720 used. It does not include cases where the connection is rejected right at
32721 the start (by an ACL, or because there are too many connections, or
32722 whatever). These cases already have their own log lines.
32723
32724 The log line that is written contains the identity of the client in the
32725 usual way, followed by D= and a time, which records the duration of the
32726 connection. If the connection was authenticated, this fact is logged
32727 exactly as it is for an incoming message, with an A= item. If the
32728 connection was encrypted, CV=, DN=, and X= items may appear as they do for
32729 an incoming message, controlled by the same logging options.
32730
32731 Finally, if any SMTP commands were issued during the connection, a C= item
32732 is added to the line, listing the commands that were used. For example,
32733
32734 C=EHLO,QUIT
32735
32736 shows that the client issued QUIT straight after EHLO. If there were fewer
32737 than 20 commands, they are all listed. If there were more than 20 commands,
32738 the last 20 are listed, preceded by "...". However, with the default
32739 setting of 10 for smtp_accep_max_nonmail, the connection will in any case
32740 have been aborted before 20 non-mail commands are processed.
32741
32742 * smtp_mailauth: A third subfield with the authenticated sender,
32743 colon-separated, is appended to the A= item for a message arrival or
32744 delivery log line, if an AUTH argument to the SMTP MAIL command (see 33.2)
32745 was accepted or used.
32746
32747 * smtp_protocol_error: A log line is written for every SMTP protocol error
32748 encountered. Exim does not have perfect detection of all protocol errors
32749 because of transmission delays and the use of pipelining. If PIPELINING has
32750 been advertised to a client, an Exim server assumes that the client will
32751 use it, and therefore it does not count "expected" errors (for example,
32752 RCPT received after rejecting MAIL) as protocol errors.
32753
32754 * smtp_syntax_error: A log line is written for every SMTP syntax error
32755 encountered. An unrecognized command is treated as a syntax error. For an
32756 external connection, the host identity is given; for an internal connection
32757 using -bs the sender identification (normally the calling user) is given.
32758
32759 * subject: The subject of the message is added to the arrival log line,
32760 preceded by "T=" (T for "topic", since S is already used for "size"). Any
32761 MIME "words" in the subject are decoded. The print_topbitchars option
32762 specifies whether characters with values greater than 127 should be logged
32763 unchanged, or whether they should be rendered as escape sequences.
32764
32765 * tls_certificate_verified: An extra item is added to <= and => log lines
32766 when TLS is in use. The item is "CV=yes" if the peer's certificate was
32767 verified, and "CV=no" if not.
32768
32769 * tls_cipher: When a message is sent or received over an encrypted
32770 connection, the cipher suite used is added to the log line, preceded by X=.
32771
32772 * tls_peerdn: When a message is sent or received over an encrypted
32773 connection, and a certificate is supplied by the remote host, the peer DN
32774 is added to the log line, preceded by DN=.
32775
32776 * tls_sni: When a message is received over an encrypted connection, and the
32777 remote host provided the Server Name Indication extension, the SNI is added
32778 to the log line, preceded by SNI=.
32779
32780 * unknown_in_list: This setting causes a log entry to be written when the
32781 result of a list match is failure because a DNS lookup failed.
32782
32783
3278451.16 Message log
32785-----------------
32786
32787In addition to the general log files, Exim writes a log file for each message
32788that it handles. The names of these per-message logs are the message ids, and
32789they are kept in the msglog sub-directory of the spool directory. Each message
32790log contains copies of the log lines that apply to the message. This makes it
32791easier to inspect the status of an individual message without having to search
32792the main log. A message log is deleted when processing of the message is
32793complete, unless preserve_message_logs is set, but this should be used only
32794with great care because they can fill up your disk very quickly.
32795
32796On a heavily loaded system, it may be desirable to disable the use of
32797per-message logs, in order to reduce disk I/O. This can be done by setting the
32798message_logs option false.
32799
32800
32801
32802===============================================================================
3280352. EXIM UTILITIES
32804
32805A number of utility scripts and programs are supplied with Exim and are
32806described in this chapter. There is also the Exim Monitor, which is covered in
32807the next chapter. The utilities described here are:
32808
32809 52.1 exiwhat list what Exim processes are doing
32810 52.2 exiqgrep grep the queue
32811 52.3 exiqsumm summarize the queue
32812 52.4 exigrep search the main log
32813 52.5 exipick select messages on various criteria
32814 52.6 exicyclog cycle (rotate) log files
32815 52.7 eximstats extract statistics from the log
32816 52.8 exim_checkaccess check address acceptance from given IP
32817 52.9 exim_dbmbuild build a DBM file
32818 52.10 exinext extract retry information
32819 52.11 exim_dumpdb dump a hints database
32820 52.11 exim_tidydb clean up a hints database
32821 52.11 exim_fixdb patch a hints database
32822 52.15 exim_lock lock a mailbox file
32823
32824Another utility that might be of use to sites with many MTAs is Tom Kistner's
32825exilog. It provides log visualizations across multiple Exim servers. See http:/
32826/duncanthrax.net/exilog/ for details.
32827
32828
3282952.1 Finding out what Exim processes are doing (exiwhat)
32830--------------------------------------------------------
32831
32832On operating systems that can restart a system call after receiving a signal
32833(most modern OS), an Exim process responds to the SIGUSR1 signal by writing a
32834line describing what it is doing to the file exim-process.info in the Exim
32835spool directory. The exiwhat script sends the signal to all Exim processes it
32836can find, having first emptied the file. It then waits for one second to allow
32837the Exim processes to react before displaying the results. In order to run
32838exiwhat successfully you have to have sufficient privilege to send the signal
32839to the Exim processes, so it is normally run as root.
32840
32841Warning: This is not an efficient process. It is intended for occasional use by
32842system administrators. It is not sensible, for example, to set up a script that
32843sends SIGUSR1 signals to Exim processes at short intervals.
32844
32845Unfortunately, the ps command that exiwhat uses to find Exim processes varies
32846in different operating systems. Not only are different options used, but the
32847format of the output is different. For this reason, there are some system
32848configuration options that configure exactly how exiwhat works. If it doesn't
32849seem to be working for you, check the following compile-time options:
32850
32851EXIWHAT_PS_CMD the command for running ps
32852EXIWHAT_PS_ARG the argument for ps
32853EXIWHAT_EGREP_ARG the argument for egrep to select from ps output
32854EXIWHAT_KILL_ARG the argument for the kill command
32855
32856An example of typical output from exiwhat is
32857
32858164 daemon: -q1h, listening on port 25
3285910483 running queue: waiting for 0tAycK-0002ij-00 (10492)
3286010492 delivering 0tAycK-0002ij-00 to mail.ref.example
32861 [10.19.42.42] (editor@ref.example)
3286210592 handling incoming call from [192.168.243.242]
3286310628 accepting a local non-SMTP message
32864
32865The first number in the output line is the process number. The third line has
32866been split here, in order to fit it on the page.
32867
32868
3286952.2 Selective queue listing (exiqgrep)
32870---------------------------------------
32871
32872This utility is a Perl script contributed by Matt Hubbard. It runs
32873
32874exim -bpu
32875
32876or (in case -a switch is specified)
32877
32878exim -bp
32879
32880The -C option is used to specify an alternate exim.conf which might contain
32881alternate exim configuration the queue management might be using.
32882
32883to obtain a queue listing, and then greps the output to select messages that
32884match given criteria. The following selection options are available:
32885
32886-f <regex>
32887
32888 Match the sender address using a case-insensitive search. The field that is
32889 tested is enclosed in angle brackets, so you can test for bounce messages
32890 with
32891
32892 exiqgrep -f '^<>$'
32893
32894-r <regex>
32895
32896 Match a recipient address using a case-insensitve search. The field that is
32897 tested is not enclosed in angle brackets.
32898
32899-s <regex>
32900
32901 Match against the size field.
32902
32903-y <seconds>
32904
32905 Match messages that are younger than the given time.
32906
32907-o <seconds>
32908
32909 Match messages that are older than the given time.
32910
32911-z
32912
32913 Match only frozen messages.
32914
32915-x
32916
32917 Match only non-frozen messages.
32918
32919The following options control the format of the output:
32920
32921-c
32922
32923 Display only the count of matching messages.
32924
32925-l
32926
32927 Long format - display the full message information as output by Exim. This
32928 is the default.
32929
32930-i
32931
32932 Display message ids only.
32933
32934-b
32935
32936 Brief format - one line per message.
32937
32938-R
32939
32940 Display messages in reverse order.
32941
32942-a
32943
32944 Include delivered recipients in queue listing.
32945
32946There is one more option, -h, which outputs a list of options.
32947
32948
3294952.3 Summarizing the queue (exiqsumm)
32950-------------------------------------
32951
32952The exiqsumm utility is a Perl script which reads the output of "exim -bp" and
32953produces a summary of the messages on the queue. Thus, you use it by running a
32954command such as
32955
32956exim -bp | exiqsumm
32957
32958The output consists of one line for each domain that has messages waiting for
32959it, as in the following example:
32960
329613 2322 74m 66m msn.com.example
32962
32963Each line lists the number of pending deliveries for a domain, their total
32964volume, and the length of time that the oldest and the newest messages have
32965been waiting. Note that the number of pending deliveries is greater than the
32966number of messages when messages have more than one recipient.
32967
32968A summary line is output at the end. By default the output is sorted on the
32969domain name, but exiqsumm has the options -a and -c, which cause the output to
32970be sorted by oldest message and by count of messages, respectively. There are
32971also three options that split the messages for each domain into two or more
32972subcounts: -b separates bounce messages, -f separates frozen messages, and -s
32973separates messages according to their sender.
32974
32975The output of exim -bp contains the original addresses in the message, so this
32976also applies to the output from exiqsumm. No domains from addresses generated
32977by aliasing or forwarding are included (unless the one_time option of the
32978redirect router has been used to convert them into "top level" addresses).
32979
32980
3298152.4 Extracting specific information from the log (exigrep)
32982-----------------------------------------------------------
32983
32984The exigrep utility is a Perl script that searches one or more main log files
32985for entries that match a given pattern. When it finds a match, it extracts all
32986the log entries for the relevant message, not just those that match the
32987pattern. Thus, exigrep can extract complete log entries for a given message, or
32988all mail for a given user, or for a given host, for example. The input files
32989can be in Exim log format or syslog format. If a matching log line is not
32990associated with a specific message, it is included in exigrep's output without
32991any additional lines. The usage is:
32992
32993exigrep [-t<n>] [-I] [-l] [-v] <pattern> [<log file>] ...
32994
32995If no log file names are given on the command line, the standard input is read.
32996
32997The -t argument specifies a number of seconds. It adds an additional condition
32998for message selection. Messages that are complete are shown only if they spent
32999more than <n> seconds on the queue.
33000
33001By default, exigrep does case-insensitive matching. The -I option makes it
33002case-sensitive. This may give a performance improvement when searching large
33003log files. Without -I, the Perl pattern matches use Perl's "/i" option; with -I
33004they do not. In both cases it is possible to change the case sensitivity within
33005the pattern by using "(?i)" or "(?-i)".
33006
33007The -l option means "literal", that is, treat all characters in the pattern as
33008standing for themselves. Otherwise the pattern must be a Perl regular
33009expression.
33010
33011The -v option inverts the matching condition. That is, a line is selected if it
33012does not match the pattern.
33013
33014If the location of a zcat command is known from the definition of ZCAT_COMMAND
33015in Local/Makefile, exigrep automatically passes any file whose name ends in
33016COMPRESS_SUFFIX through zcat as it searches it.
33017
33018
3301952.5 Selecting messages by various criteria (exipick)
33020-----------------------------------------------------
33021
33022John Jetmore's exipick utility is included in the Exim distribution. It lists
33023messages from the queue according to a variety of criteria. For details of
33024exipick's facilities, visit the web page at http://www.exim.org/eximwiki/
33025ToolExipickManPage or run exipick with the --help option.
33026
33027
3302852.6 Cycling log files (exicyclog)
33029----------------------------------
33030
33031The exicyclog script can be used to cycle (rotate) mainlog and rejectlog files.
33032This is not necessary if only syslog is being used, or if you are using log
33033files with datestamps in their names (see section 51.3). Some operating systems
33034have their own standard mechanisms for log cycling, and these can be used
33035instead of exicyclog if preferred. There are two command line options for
33036exicyclog:
33037
33038 * -k <count> specifies the number of log files to keep, overriding the
33039 default that is set when Exim is built. The default default is 10.
33040
33041 * -l <path> specifies the log file path, in the same format as Exim's
33042 log_file_path option (for example, "/var/log/exim_%slog"), again overriding
33043 the script's default, which is to find the setting from Exim's
33044 configuration.
33045
33046Each time exicyclog is run the file names get "shuffled down" by one. If the
33047main log file name is mainlog (the default) then when exicyclog is run mainlog
33048becomes mainlog.01, the previous mainlog.01 becomes mainlog.02 and so on, up to
33049the limit that is set in the script or by the -k option. Log files whose
33050numbers exceed the limit are discarded. Reject logs are handled similarly.
33051
33052If the limit is greater than 99, the script uses 3-digit numbers such as
33053mainlog.001, mainlog.002, etc. If you change from a number less than 99 to one
33054that is greater, or vice versa, you will have to fix the names of any existing
33055log files.
33056
33057If no mainlog file exists, the script does nothing. Files that "drop off" the
33058end are deleted. All files with numbers greater than 01 are compressed, using a
33059compression command which is configured by the COMPRESS_COMMAND setting in
33060Local/Makefile. It is usual to run exicyclog daily from a root crontab entry of
33061the form
33062
330631 0 * * * su exim -c /usr/exim/bin/exicyclog
33064
33065assuming you have used the name "exim" for the Exim user. You can run exicyclog
33066as root if you wish, but there is no need.
33067
33068
3306952.7 Mail statistics (eximstats)
33070--------------------------------
33071
33072A Perl script called eximstats is provided for extracting statistical
33073information from log files. The output is either plain text, or HTML. Exim log
33074files are also supported by the Lire system produced by the LogReport
33075Foundation http://www.logreport.org.
33076
33077The eximstats script has been hacked about quite a bit over time. The latest
33078version is the result of some extensive revision by Steve Campbell. A lot of
33079information is given by default, but there are options for suppressing various
33080parts of it. Following any options, the arguments to the script are a list of
33081files, which should be main log files. For example:
33082
33083eximstats -nr /var/spool/exim/log/mainlog.01
33084
33085By default, eximstats extracts information about the number and volume of
33086messages received from or delivered to various hosts. The information is sorted
33087both by message count and by volume, and the top fifty hosts in each category
33088are listed on the standard output. Similar information, based on email
33089addresses or domains instead of hosts can be requested by means of various
33090options. For messages delivered and received locally, similar statistics are
33091also produced per user.
33092
33093The output also includes total counts and statistics about delivery errors, and
33094histograms showing the number of messages received and deliveries made in each
33095hour of the day. A delivery with more than one address in its envelope (for
33096example, an SMTP transaction with more than one RCPT command) is counted as a
33097single delivery by eximstats.
33098
33099Though normally more deliveries than receipts are reported (as messages may
33100have multiple recipients), it is possible for eximstats to report more messages
33101received than delivered, even though the queue is empty at the start and end of
33102the period in question. If an incoming message contains no valid recipients, no
33103deliveries are recorded for it. A bounce message is handled as an entirely
33104separate message.
33105
33106eximstats always outputs a grand total summary giving the volume and number of
33107messages received and deliveries made, and the number of hosts involved in each
33108case. It also outputs the number of messages that were delayed (that is, not
33109completely delivered at the first attempt), and the number that had at least
33110one address that failed.
33111
33112The remainder of the output is in sections that can be independently disabled
33113or modified by various options. It consists of a summary of deliveries by
33114transport, histograms of messages received and delivered per time interval
33115(default per hour), information about the time messages spent on the queue, a
33116list of relayed messages, lists of the top fifty sending hosts, local senders,
33117destination hosts, and destination local users by count and by volume, and a
33118list of delivery errors that occurred.
33119
33120The relay information lists messages that were actually relayed, that is, they
33121came from a remote host and were directly delivered to some other remote host,
33122without being processed (for example, for aliasing or forwarding) locally.
33123
33124There are quite a few options for eximstats to control exactly what it outputs.
33125These are documented in the Perl script itself, and can be extracted by running
33126the command perldoc on the script. For example:
33127
33128perldoc /usr/exim/bin/eximstats
33129
33130
3313152.8 Checking access policy (exim_checkaccess)
33132----------------------------------------------
33133
33134The -bh command line argument allows you to run a fake SMTP session with
33135debugging output, in order to check what Exim is doing when it is applying
33136policy controls to incoming SMTP mail. However, not everybody is sufficiently
33137familiar with the SMTP protocol to be able to make full use of -bh, and
33138sometimes you just want to answer the question "Does this address have access?"
33139without bothering with any further details.
33140
33141The exim_checkaccess utility is a "packaged" version of -bh. It takes two
33142arguments, an IP address and an email address:
33143
33144exim_checkaccess 10.9.8.7 A.User@a.domain.example
33145
33146The utility runs a call to Exim with the -bh option, to test whether the given
33147email address would be accepted in a RCPT command in a TCP/IP connection from
33148the host with the given IP address. The output of the utility is either the
33149word "accepted", or the SMTP error response, for example:
33150
33151Rejected:
33152550 Relay not permitted
33153
33154When running this test, the utility uses "<>" as the envelope sender address
33155for the MAIL command, but you can change this by providing additional options.
33156These are passed directly to the Exim command. For example, to specify that the
33157test is to be run with the sender address himself@there.example you can use:
33158
33159exim_checkaccess 10.9.8.7 A.User@a.domain.example \
33160 -f himself@there.example
33161
33162Note that these additional Exim command line items must be given after the two
33163mandatory arguments.
33164
33165Because the exim_checkaccess uses -bh, it does not perform callouts while
33166running its checks. You can run checks that include callouts by using -bhc, but
33167this is not yet available in a "packaged" form.
33168
33169
3317052.9 Making DBM files (exim_dbmbuild)
33171-------------------------------------
33172
33173The exim_dbmbuild program reads an input file containing keys and data in the
33174format used by the lsearch lookup (see section 9.3). It writes a DBM file using
33175the lower-cased alias names as keys and the remainder of the information as
33176data. The lower-casing can be prevented by calling the program with the -nolc
33177option.
33178
33179A terminating zero is included as part of the key string. This is expected by
33180the dbm lookup type. However, if the option -nozero is given, exim_dbmbuild
33181creates files without terminating zeroes in either the key strings or the data
33182strings. The dbmnz lookup type can be used with such files.
33183
33184The program requires two arguments: the name of the input file (which can be a
33185single hyphen to indicate the standard input), and the name of the output file.
33186It creates the output under a temporary name, and then renames it if all went
33187well.
33188
33189If the native DB interface is in use (USE_DB is set in a compile-time
33190configuration file - this is common in free versions of Unix) the two file
33191names must be different, because in this mode the Berkeley DB functions create
33192a single output file using exactly the name given. For example,
33193
33194exim_dbmbuild /etc/aliases /etc/aliases.db
33195
33196reads the system alias file and creates a DBM version of it in /etc/aliases.db.
33197
33198In systems that use the ndbm routines (mostly proprietary versions of Unix),
33199two files are used, with the suffixes .dir and .pag. In this environment, the
33200suffixes are added to the second argument of exim_dbmbuild, so it can be the
33201same as the first. This is also the case when the Berkeley functions are used
33202in compatibility mode (though this is not recommended), because in that case it
33203adds a .db suffix to the file name.
33204
33205If a duplicate key is encountered, the program outputs a warning, and when it
33206finishes, its return code is 1 rather than zero, unless the -noduperr option is
33207used. By default, only the first of a set of duplicates is used - this makes it
33208compatible with lsearch lookups. There is an option -lastdup which causes it to
33209use the data for the last duplicate instead. There is also an option -nowarn,
33210which stops it listing duplicate keys to stderr. For other errors, where it
33211doesn't actually make a new file, the return code is 2.
33212
33213
3321452.10 Finding individual retry times (exinext)
33215----------------------------------------------
33216
33217A utility called exinext (mostly a Perl script) provides the ability to fish
33218specific information out of the retry database. Given a mail domain (or a
33219complete address), it looks up the hosts for that domain, and outputs any retry
33220information for the hosts or for the domain. At present, the retry information
33221is obtained by running exim_dumpdb (see below) and post-processing the output.
33222For example:
33223
33224$ exinext piglet@milne.fict.example
33225kanga.milne.example:192.168.8.1 error 146: Connection refused
33226 first failed: 21-Feb-1996 14:57:34
33227 last tried: 21-Feb-1996 14:57:34
33228 next try at: 21-Feb-1996 15:02:34
33229roo.milne.example:192.168.8.3 error 146: Connection refused
33230 first failed: 20-Jan-1996 13:12:08
33231 last tried: 21-Feb-1996 11:42:03
33232 next try at: 21-Feb-1996 19:42:03
33233 past final cutoff time
33234
33235You can also give exinext a local part, without a domain, and it will give any
33236retry information for that local part in your default domain. A message id can
33237be used to obtain retry information pertaining to a specific message. This
33238exists only when an attempt to deliver a message to a remote host suffers a
33239message-specific error (see section 47.2). exinext is not particularly
33240efficient, but then it is not expected to be run very often.
33241
33242The exinext utility calls Exim to find out information such as the location of
33243the spool directory. The utility has -C and -D options, which are passed on to
33244the exim commands. The first specifies an alternate Exim configuration file,
33245and the second sets macros for use within the configuration file. These
33246features are mainly to help in testing, but might also be useful in
33247environments where more than one configuration file is in use.
33248
33249
3325052.11 Hints database maintenance
33251--------------------------------
33252
33253Three utility programs are provided for maintaining the DBM files that Exim
33254uses to contain its delivery hint information. Each program requires two
33255arguments. The first specifies the name of Exim's spool directory, and the
33256second is the name of the database it is to operate on. These are as follows:
33257
33258 * retry: the database of retry information
33259
33260 * wait-<transport name>: databases of information about messages waiting for
33261 remote hosts
33262
33263 * callout: the callout cache
33264
33265 * ratelimit: the data for implementing the ratelimit ACL condition
33266
33267 * misc: other hints data
33268
33269The misc database is used for
33270
33271 * Serializing ETRN runs (when smtp_etrn_serialize is set)
33272
33273 * Serializing delivery to a specific host (when serialize_hosts is set in an
33274 smtp transport)
33275
33276
3327752.12 exim_dumpdb
33278-----------------
33279
33280The entire contents of a database are written to the standard output by the
33281exim_dumpdb program, which has no options or arguments other than the spool and
33282database names. For example, to dump the retry database:
33283
33284exim_dumpdb /var/spool/exim retry
33285
33286Two lines of output are produced for each entry:
33287
33288T:mail.ref.example:192.168.242.242 146 77 Connection refused
3328931-Oct-1995 12:00:12 02-Nov-1995 12:21:39 02-Nov-1995 20:21:39 *
33290
33291The first item on the first line is the key of the record. It starts with one
33292of the letters R, or T, depending on whether it refers to a routing or
33293transport retry. For a local delivery, the next part is the local address; for
33294a remote delivery it is the name of the remote host, followed by its failing IP
33295address (unless retry_include_ip_address is set false on the smtp transport).
33296If the remote port is not the standard one (port 25), it is added to the IP
33297address. Then there follows an error code, an additional error code, and a
33298textual description of the error.
33299
33300The three times on the second line are the time of first failure, the time of
33301the last delivery attempt, and the computed time for the next attempt. The line
33302ends with an asterisk if the cutoff time for the last retry rule has been
33303exceeded.
33304
33305Each output line from exim_dumpdb for the wait-xxx databases consists of a host
33306name followed by a list of ids for messages that are or were waiting to be
33307delivered to that host. If there are a very large number for any one host,
33308continuation records, with a sequence number added to the host name, may be
33309seen. The data in these records is often out of date, because a message may be
33310routed to several alternative hosts, and Exim makes no effort to keep
33311cross-references.
33312
33313
3331452.13 exim_tidydb
33315-----------------
33316
33317The exim_tidydb utility program is used to tidy up the contents of a hints
33318database. If run with no options, it removes all records that are more than 30
33319days old. The age is calculated from the date and time that the record was last
33320updated. Note that, in the case of the retry database, it is not the time since
33321the first delivery failure. Information about a host that has been down for
33322more than 30 days will remain in the database, provided that the record is
33323updated sufficiently often.
33324
33325The cutoff date can be altered by means of the -t option, which must be
33326followed by a time. For example, to remove all records older than a week from
33327the retry database:
33328
33329exim_tidydb -t 7d /var/spool/exim retry
33330
33331Both the wait-xxx and retry databases contain items that involve message ids.
33332In the former these appear as data in records keyed by host - they were
33333messages that were waiting for that host - and in the latter they are the keys
33334for retry information for messages that have suffered certain types of error.
33335When exim_tidydb is run, a check is made to ensure that message ids in database
33336records are those of messages that are still on the queue. Message ids for
33337messages that no longer exist are removed from wait-xxx records, and if this
33338leaves any records empty, they are deleted. For the retry database, records
33339whose keys are non-existent message ids are removed. The exim_tidydb utility
33340outputs comments on the standard output whenever it removes information from
33341the database.
33342
33343Certain records are automatically removed by Exim when they are no longer
33344needed, but others are not. For example, if all the MX hosts for a domain are
33345down, a retry record is created for each one. If the primary MX host comes back
33346first, its record is removed when Exim successfully delivers to it, but the
33347records for the others remain because Exim has not tried to use those hosts.
33348
33349It is important, therefore, to run exim_tidydb periodically on all the hints
33350databases. You should do this at a quiet time of day, because it requires a
33351database to be locked (and therefore inaccessible to Exim) while it does its
33352work. Removing records from a DBM file does not normally make the file smaller,
33353but all the common DBM libraries are able to re-use the space that is released.
33354After an initial phase of increasing in size, the databases normally reach a
33355point at which they no longer get any bigger, as long as they are regularly
33356tidied.
33357
33358Warning: If you never run exim_tidydb, the space used by the hints databases is
33359likely to keep on increasing.
33360
33361
3336252.14 exim_fixdb
33363----------------
33364
33365The exim_fixdb program is a utility for interactively modifying databases. Its
33366main use is for testing Exim, but it might also be occasionally useful for
33367getting round problems in a live system. It has no options, and its interface
33368is somewhat crude. On entry, it prompts for input with a right angle-bracket. A
33369key of a database record can then be entered, and the data for that record is
33370displayed.
33371
33372If "d" is typed at the next prompt, the entire record is deleted. For all
33373except the retry database, that is the only operation that can be carried out.
33374For the retry database, each field is output preceded by a number, and data for
33375individual fields can be changed by typing the field number followed by new
33376data, for example:
33377
33378> 4 951102:1000
33379
33380resets the time of the next delivery attempt. Time values are given as a
33381sequence of digit pairs for year, month, day, hour, and minute. Colons can be
33382used as optional separators.
33383
33384
3338552.15 Mailbox maintenance (exim_lock)
33386-------------------------------------
33387
33388The exim_lock utility locks a mailbox file using the same algorithm as Exim.
33389For a discussion of locking issues, see section 26.3. Exim_lock can be used to
33390prevent any modification of a mailbox by Exim or a user agent while
33391investigating a problem. The utility requires the name of the file as its first
33392argument. If the locking is successful, the second argument is run as a command
33393(using C's system() function); if there is no second argument, the value of the
33394SHELL environment variable is used; if this is unset or empty, /bin/sh is run.
33395When the command finishes, the mailbox is unlocked and the utility ends. The
33396following options are available:
33397
33398-fcntl
33399
33400 Use fcntl() locking on the open mailbox.
33401
33402-flock
33403
33404 Use flock() locking on the open mailbox, provided the operating system
33405 supports it.
33406
33407-interval
33408
33409 This must be followed by a number, which is a number of seconds; it sets
33410 the interval to sleep between retries (default 3).
33411
33412-lockfile
33413
33414 Create a lock file before opening the mailbox.
33415
33416-mbx
33417
33418 Lock the mailbox using MBX rules.
33419
33420-q
33421
33422 Suppress verification output.
33423
33424-retries
33425
33426 This must be followed by a number; it sets the number of times to try to
33427 get the lock (default 10).
33428
33429-restore_time
33430
33431 This option causes exim_lock to restore the modified and read times to the
33432 locked file before exiting. This allows you to access a locked mailbox (for
33433 example, to take a backup copy) without disturbing the times that the user
33434 subsequently sees.
33435
33436-timeout
33437
33438 This must be followed by a number, which is a number of seconds; it sets a
33439 timeout to be used with a blocking fcntl() lock. If it is not set (the
33440 default), a non-blocking call is used.
33441
33442-v
33443
33444 Generate verbose output.
33445
33446If none of -fcntl, -flock, -lockfile or -mbx are given, the default is to
33447create a lock file and also to use fcntl() locking on the mailbox, which is the
33448same as Exim's default. The use of -flock or -fcntl requires that the file be
33449writeable; the use of -lockfile requires that the directory containing the file
33450be writeable. Locking by lock file does not last for ever; Exim assumes that a
33451lock file is expired if it is more than 30 minutes old.
33452
33453The -mbx option can be used with either or both of -fcntl or -flock. It assumes
33454-fcntl by default. MBX locking causes a shared lock to be taken out on the open
33455mailbox, and an exclusive lock on the file /tmp/.n.m where n and m are the
33456device number and inode number of the mailbox file. When the locking is
33457released, if an exclusive lock can be obtained for the mailbox, the file in /
33458tmp is deleted.
33459
33460The default output contains verification of the locking that takes place. The
33461-v option causes some additional information to be given. The -q option
33462suppresses all output except error messages.
33463
33464A command such as
33465
33466exim_lock /var/spool/mail/spqr
33467
33468runs an interactive shell while the file is locked, whereas
33469
33470exim_lock -q /var/spool/mail/spqr <<End
33471<some commands>
33472End
33473
33474runs a specific non-interactive sequence of commands while the file is locked,
33475suppressing all verification output. A single command can be run by a command
33476such as
33477
33478exim_lock -q /var/spool/mail/spqr \
33479 "cp /var/spool/mail/spqr /some/where"
33480
33481Note that if a command is supplied, it must be entirely contained within the
33482second argument - hence the quotes.
33483
33484
33485
33486===============================================================================
3348753. THE EXIM MONITOR
33488
33489The Exim monitor is an application which displays in an X window information
33490about the state of Exim's queue and what Exim is doing. An admin user can
33491perform certain operations on messages from this GUI interface; however all
33492such facilities are also available from the command line, and indeed, the
33493monitor itself makes use of the command line to perform any actions requested.
33494
33495
3349653.1 Running the monitor
33497------------------------
33498
33499The monitor is started by running the script called eximon. This is a shell
33500script that sets up a number of environment variables, and then runs the binary
33501called eximon.bin. The default appearance of the monitor window can be changed
33502by editing the Local/eximon.conf file created by editing exim_monitor/EDITME.
33503Comments in that file describe what the various parameters are for.
33504
33505The parameters that get built into the eximon script can be overridden for a
33506particular invocation by setting up environment variables of the same names,
33507preceded by "EXIMON_". For example, a shell command such as
33508
33509EXIMON_LOG_DEPTH=400 eximon
33510
33511(in a Bourne-compatible shell) runs eximon with an overriding setting of the
33512LOG_DEPTH parameter. If EXIMON_LOG_FILE_PATH is set in the environment, it
33513overrides the Exim log file configuration. This makes it possible to have
33514eximon tailing log data that is written to syslog, provided that MAIL.INFO
33515syslog messages are routed to a file on the local host.
33516
33517X resources can be used to change the appearance of the window in the normal
33518way. For example, a resource setting of the form
33519
33520Eximon*background: gray94
33521
33522changes the colour of the background to light grey rather than white. The
33523stripcharts are drawn with both the data lines and the reference lines in
33524black. This means that the reference lines are not visible when on top of the
33525data. However, their colour can be changed by setting a resource called
33526"highlight" (an odd name, but that's what the Athena stripchart widget uses).
33527For example, if your X server is running Unix, you could set up lighter
33528reference lines in the stripcharts by obeying
33529
33530xrdb -merge <<End
33531Eximon*highlight: gray
33532End
33533
33534In order to see the contents of messages on the queue, and to operate on them,
33535eximon must either be run as root or by an admin user.
33536
33537The command-line parameters of eximon are passed to eximon.bin and may contain
33538X11 resource parameters interpreted by the X11 library. In addition, if the
33539first parameter starts with the string "gdb" then it is removed and the binary
33540is invoked under gdb (the parameter is used as the gdb command-name, so
33541versioned variants of gdb can be invoked).
33542
33543The monitor's window is divided into three parts. The first contains one or
33544more stripcharts and two action buttons, the second contains a "tail" of the
33545main log file, and the third is a display of the queue of messages awaiting
33546delivery, with two more action buttons. The following sections describe these
33547different parts of the display.
33548
33549
3355053.2 The stripcharts
33551--------------------
33552
33553The first stripchart is always a count of messages on the queue. Its name can
33554be configured by setting QUEUE_STRIPCHART_NAME in the Local/eximon.conf file.
33555The remaining stripcharts are defined in the configuration script by regular
33556expression matches on log file entries, making it possible to display, for
33557example, counts of messages delivered to certain hosts or using certain
33558transports. The supplied defaults display counts of received and delivered
33559messages, and of local and SMTP deliveries. The default period between
33560stripchart updates is one minute; this can be adjusted by a parameter in the
33561Local/eximon.conf file.
33562
33563The stripchart displays rescale themselves automatically as the value they are
33564displaying changes. There are always 10 horizontal lines in each chart; the
33565title string indicates the value of each division when it is greater than one.
33566For example, "x2" means that each division represents a value of 2.
33567
33568It is also possible to have a stripchart which shows the percentage fullness of
33569a particular disk partition, which is useful when local deliveries are confined
33570to a single partition.
33571
33572This relies on the availability of the statvfs() function or equivalent in the
33573operating system. Most, but not all versions of Unix that support Exim have
33574this. For this particular stripchart, the top of the chart always represents
33575100%, and the scale is given as "x10%". This chart is configured by setting
33576SIZE_STRIPCHART and (optionally) SIZE_STRIPCHART_NAME in the Local/eximon.conf
33577file.
33578
33579
3358053.3 Main action buttons
33581------------------------
33582
33583Below the stripcharts there is an action button for quitting the monitor. Next
33584to this is another button marked "Size". They are placed here so that shrinking
33585the window to its default minimum size leaves just the queue count stripchart
33586and these two buttons visible. Pressing the "Size" button causes the window to
33587expand to its maximum size, unless it is already at the maximum, in which case
33588it is reduced to its minimum.
33589
33590When expanding to the maximum, if the window cannot be fully seen where it
33591currently is, it is moved back to where it was the last time it was at full
33592size. When it is expanding from its minimum size, the old position is
33593remembered, and next time it is reduced to the minimum it is moved back there.
33594
33595The idea is that you can keep a reduced window just showing one or two
33596stripcharts at a convenient place on your screen, easily expand it to show the
33597full window when required, and just as easily put it back to what it was. The
33598idea is copied from what the twm window manager does for its f.fullzoom action.
33599The minimum size of the window can be changed by setting the MIN_HEIGHT and
33600MIN_WIDTH values in Local/eximon.conf.
33601
33602Normally, the monitor starts up with the window at its full size, but it can be
33603built so that it starts up with the window at its smallest size, by setting
33604START_SMALL=yes in Local/eximon.conf.
33605
33606
3360753.4 The log display
33608--------------------
33609
33610The second section of the window is an area in which a display of the tail of
33611the main log is maintained. To save space on the screen, the timestamp on each
33612log line is shortened by removing the date and, if log_timezone is set, the
33613timezone. The log tail is not available when the only destination for logging
33614data is syslog, unless the syslog lines are routed to a local file whose name
33615is passed to eximon via the EXIMON_LOG_FILE_PATH environment variable.
33616
33617The log sub-window has a scroll bar at its lefthand side which can be used to
33618move back to look at earlier text, and the up and down arrow keys also have a
33619scrolling effect. The amount of log that is kept depends on the setting of
33620LOG_BUFFER in Local/eximon.conf, which specifies the amount of memory to use.
33621When this is full, the earlier 50% of data is discarded - this is much more
33622efficient than throwing it away line by line. The sub-window also has a
33623horizontal scroll bar for accessing the ends of long log lines. This is the
33624only means of horizontal scrolling; the right and left arrow keys are not
33625available. Text can be cut from this part of the window using the mouse in the
33626normal way. The size of this subwindow is controlled by parameters in the
33627configuration file Local/eximon.conf.
33628
33629Searches of the text in the log window can be carried out by means of the ^R
33630and ^S keystrokes, which default to a reverse and a forward search,
33631respectively. The search covers only the text that is displayed in the window.
33632It cannot go further back up the log.
33633
33634The point from which the search starts is indicated by a caret marker. This is
33635normally at the end of the text in the window, but can be positioned explicitly
33636by pointing and clicking with the left mouse button, and is moved automatically
33637by a successful search. If new text arrives in the window when it is scrolled
33638back, the caret remains where it is, but if the window is not scrolled back,
33639the caret is moved to the end of the new text.
33640
33641Pressing ^R or ^S pops up a window into which the search text can be typed.
33642There are buttons for selecting forward or reverse searching, for carrying out
33643the search, and for cancelling. If the "Search" button is pressed, the search
33644happens and the window remains so that further searches can be done. If the
33645"Return" key is pressed, a single search is done and the window is closed. If ^
33646C is typed the search is cancelled.
33647
33648The searching facility is implemented using the facilities of the Athena text
33649widget. By default this pops up a window containing both "search" and "replace"
33650options. In order to suppress the unwanted "replace" portion for eximon, a
33651modified version of the TextPop widget is distributed with Exim. However, the
33652linkers in BSDI and HP-UX seem unable to handle an externally provided version
33653of TextPop when the remaining parts of the text widget come from the standard
33654libraries. The compile-time option EXIMON_TEXTPOP can be unset to cut out the
33655modified TextPop, making it possible to build Eximon on these systems, at the
33656expense of having unwanted items in the search popup window.
33657
33658
3365953.5 The queue display
33660----------------------
33661
33662The bottom section of the monitor window contains a list of all messages that
33663are on the queue, which includes those currently being received or delivered,
33664as well as those awaiting delivery. The size of this subwindow is controlled by
33665parameters in the configuration file Local/eximon.conf, and the frequency at
33666which it is updated is controlled by another parameter in the same file - the
33667default is 5 minutes, since queue scans can be quite expensive. However, there
33668is an "Update" action button just above the display which can be used to force
33669an update of the queue display at any time.
33670
33671When a host is down for some time, a lot of pending mail can build up for it,
33672and this can make it hard to deal with other messages on the queue. To help
33673with this situation there is a button next to "Update" called "Hide". If
33674pressed, a dialogue box called "Hide addresses ending with" is put up. If you
33675type anything in here and press "Return", the text is added to a chain of such
33676texts, and if every undelivered address in a message matches at least one of
33677the texts, the message is not displayed.
33678
33679If there is an address that does not match any of the texts, all the addresses
33680are displayed as normal. The matching happens on the ends of addresses so, for
33681example, cam.ac.uk specifies all addresses in Cambridge, while
33682xxx@foo.com.example specifies just one specific address. When any hiding has
33683been set up, a button called "Unhide" is displayed. If pressed, it cancels all
33684hiding. Also, to ensure that hidden messages do not get forgotten, a hide
33685request is automatically cancelled after one hour.
33686
33687While the dialogue box is displayed, you can't press any buttons or do anything
33688else to the monitor window. For this reason, if you want to cut text from the
33689queue display to use in the dialogue box, you have to do the cutting before
33690pressing the "Hide" button.
33691
33692The queue display contains, for each unhidden queued message, the length of
33693time it has been on the queue, the size of the message, the message id, the
33694message sender, and the first undelivered recipient, all on one line. If it is
33695a bounce message, the sender is shown as "<>". If there is more than one
33696recipient to which the message has not yet been delivered, subsequent ones are
33697listed on additional lines, up to a maximum configured number, following which
33698an ellipsis is displayed. Recipients that have already received the message are
33699not shown.
33700
33701If a message is frozen, an asterisk is displayed at the left-hand side.
33702
33703The queue display has a vertical scroll bar, and can also be scrolled by means
33704of the arrow keys. Text can be cut from it using the mouse in the normal way.
33705The text searching facilities, as described above for the log window, are also
33706available, but the caret is always moved to the end of the text when the queue
33707display is updated.
33708
33709
3371053.6 The queue menu
33711-------------------
33712
33713If the shift key is held down and the left button is clicked when the mouse
33714pointer is over the text for any message, an action menu pops up, and the first
33715line of the queue display for the message is highlighted. This does not affect
33716any selected text.
33717
33718If you want to use some other event for popping up the menu, you can set the
33719MENU_EVENT parameter in Local/eximon.conf to change the default, or set
33720EXIMON_MENU_EVENT in the environment before starting the monitor. The value set
33721in this parameter is a standard X event description. For example, to run eximon
33722using ctrl rather than shift you could use
33723
33724EXIMON_MENU_EVENT='Ctrl<Btn1Down>' eximon
33725
33726The title of the menu is the message id, and it contains entries which act as
33727follows:
33728
33729 * message log: The contents of the message log for the message are displayed
33730 in a new text window.
33731
33732 * headers: Information from the spool file that contains the envelope
33733 information and headers is displayed in a new text window. See chapter 55
33734 for a description of the format of spool files.
33735
33736 * body: The contents of the spool file containing the body of the message are
33737 displayed in a new text window. There is a default limit of 20,000 bytes to
33738 the amount of data displayed. This can be changed by setting the BODY_MAX
33739 option at compile time, or the EXIMON_BODY_MAX option at run time.
33740
33741 * deliver message: A call to Exim is made using the -M option to request
33742 delivery of the message. This causes an automatic thaw if the message is
33743 frozen. The -v option is also set, and the output from Exim is displayed in
33744 a new text window. The delivery is run in a separate process, to avoid
33745 holding up the monitor while the delivery proceeds.
33746
33747 * freeze message: A call to Exim is made using the -Mf option to request that
33748 the message be frozen.
33749
33750 * thaw message: A call to Exim is made using the -Mt option to request that
33751 the message be thawed.
33752
33753 * give up on msg: A call to Exim is made using the -Mg option to request that
33754 Exim gives up trying to deliver the message. A bounce message is generated
33755 for any remaining undelivered addresses.
33756
33757 * remove message: A call to Exim is made using the -Mrm option to request
33758 that the message be deleted from the system without generating a bounce
33759 message.
33760
33761 * add recipient: A dialog box is displayed into which a recipient address can
33762 be typed. If the address is not qualified and the QUALIFY_DOMAIN parameter
33763 is set in Local/eximon.conf, the address is qualified with that domain.
33764 Otherwise it must be entered as a fully qualified address. Pressing RETURN
33765 causes a call to Exim to be made using the -Mar option to request that an
33766 additional recipient be added to the message, unless the entry box is
33767 empty, in which case no action is taken.
33768
33769 * mark delivered: A dialog box is displayed into which a recipient address
33770 can be typed. If the address is not qualified and the QUALIFY_DOMAIN
33771 parameter is set in Local/eximon.conf, the address is qualified with that
33772 domain. Otherwise it must be entered as a fully qualified address. Pressing
33773 RETURN causes a call to Exim to be made using the -Mmd option to mark the
33774 given recipient address as already delivered, unless the entry box is
33775 empty, in which case no action is taken.
33776
33777 * mark all delivered: A call to Exim is made using the -Mmad option to mark
33778 all recipient addresses as already delivered.
33779
33780 * edit sender: A dialog box is displayed initialized with the current
33781 sender's address. Pressing RETURN causes a call to Exim to be made using
33782 the -Mes option to replace the sender address, unless the entry box is
33783 empty, in which case no action is taken. If you want to set an empty sender
33784 (as in bounce messages), you must specify it as "<>". Otherwise, if the
33785 address is not qualified and the QUALIFY_DOMAIN parameter is set in Local/
33786 eximon.conf, the address is qualified with that domain.
33787
33788When a delivery is forced, a window showing the -v output is displayed. In
33789other cases when a call to Exim is made, if there is any output from Exim (in
33790particular, if the command fails) a window containing the command and the
33791output is displayed. Otherwise, the results of the action are normally apparent
33792from the log and queue displays. However, if you set ACTION_OUTPUT=yes in Local
33793/eximon.conf, a window showing the Exim command is always opened, even if no
33794output is generated.
33795
33796The queue display is automatically updated for actions such as freezing and
33797thawing, unless ACTION_QUEUE_UPDATE=no has been set in Local/eximon.conf. In
33798this case the "Update" button has to be used to force an update of the display
33799after one of these actions.
33800
33801In any text window that is displayed as result of a menu action, the normal
33802cut-and-paste facility is available, and searching can be carried out using ^R
33803and ^S, as described above for the log tail window.
33804
33805
33806
33807===============================================================================
3380854. SECURITY CONSIDERATIONS
33809
33810This chapter discusses a number of issues concerned with security, some of
33811which are also covered in other parts of this manual.
33812
33813For reasons that this author does not understand, some people have promoted
33814Exim as a "particularly secure" mailer. Perhaps it is because of the existence
33815of this chapter in the documentation. However, the intent of the chapter is
33816simply to describe the way Exim works in relation to certain security concerns,
33817not to make any specific claims about the effectiveness of its security as
33818compared with other MTAs.
33819
33820What follows is a description of the way Exim is supposed to be. Best efforts
33821have been made to try to ensure that the code agrees with the theory, but an
33822absence of bugs can never be guaranteed. Any that are reported will get fixed
33823as soon as possible.
33824
33825
3382654.1 Building a more "hardened" Exim
33827------------------------------------
33828
33829There are a number of build-time options that can be set in Local/Makefile to
33830create Exim binaries that are "harder" to attack, in particular by a rogue Exim
33831administrator who does not have the root password, or by someone who has
33832penetrated the Exim (but not the root) account. These options are as follows:
33833
33834 * ALT_CONFIG_PREFIX can be set to a string that is required to match the
33835 start of any file names used with the -C option. When it is set, these file
33836 names are also not allowed to contain the sequence "/../". (However, if the
33837 value of the -C option is identical to the value of CONFIGURE_FILE in Local
33838 /Makefile, Exim ignores -C and proceeds as usual.) There is no default
33839 setting for ALT_CONFIG_PREFIX.
33840
33841 If the permitted configuration files are confined to a directory to which
33842 only root has access, this guards against someone who has broken into the
33843 Exim account from running a privileged Exim with an arbitrary configuration
33844 file, and using it to break into other accounts.
33845
33846 * If a non-trusted configuration file (i.e. not the default configuration
33847 file or one which is trusted by virtue of being listed in the
33848 TRUSTED_CONFIG_LIST file) is specified with -C, or if macros are given with
33849 -D (but see the next item), then root privilege is retained only if the
33850 caller of Exim is root. This locks out the possibility of testing a
33851 configuration using -C right through message reception and delivery, even
33852 if the caller is root. The reception works, but by that time, Exim is
33853 running as the Exim user, so when it re-execs to regain privilege for the
33854 delivery, the use of -C causes privilege to be lost. However, root can test
33855 reception and delivery using two separate commands.
33856
33857 * The WHITELIST_D_MACROS build option declares some macros to be safe to
33858 override with -D if the real uid is one of root, the Exim run-time user or
33859 the CONFIGURE_OWNER, if defined. The potential impact of this option is
33860 limited by requiring the run-time value supplied to -D to match a regex
33861 that errs on the restrictive side. Requiring build-time selection of safe
33862 macros is onerous but this option is intended solely as a transition
33863 mechanism to permit previously-working configurations to continue to work
33864 after release 4.73.
33865
33866 * If DISABLE_D_OPTION is defined, the use of the -D command line option is
33867 disabled.
33868
33869 * FIXED_NEVER_USERS can be set to a colon-separated list of users that are
33870 never to be used for any deliveries. This is like the never_users runtime
33871 option, but it cannot be overridden; the runtime option adds additional
33872 users to the list. The default setting is "root"; this prevents a non-root
33873 user who is permitted to modify the runtime file from using Exim as a way
33874 to get root.
33875
33876
3387754.2 Root privilege
33878-------------------
33879
33880The Exim binary is normally setuid to root, which means that it gains root
33881privilege (runs as root) when it starts execution. In some special cases (for
33882example, when the daemon is not in use and there are no local deliveries), it
33883may be possible to run Exim setuid to some user other than root. This is
33884discussed in the next section. However, in most installations, root privilege
33885is required for two things:
33886
33887 * To set up a socket connected to the standard SMTP port (25) when
33888 initialising the listening daemon. If Exim is run from inetd, this
33889 privileged action is not required.
33890
33891 * To be able to change uid and gid in order to read users' .forward files and
33892 perform local deliveries as the receiving user or as specified in the
33893 configuration.
33894
33895It is not necessary to be root to do any of the other things Exim does, such as
33896receiving messages and delivering them externally over SMTP, and it is
33897obviously more secure if Exim does not run as root except when necessary. For
33898this reason, a user and group for Exim to use must be defined in Local/Makefile
33899. These are known as "the Exim user" and "the Exim group". Their values can be
33900changed by the run time configuration, though this is not recommended. Often a
33901user called exim is used, but some sites use mail or another user name
33902altogether.
33903
33904Exim uses setuid() whenever it gives up root privilege. This is a permanent
33905abdication; the process cannot regain root afterwards. Prior to release 4.00,
33906seteuid() was used in some circumstances, but this is no longer the case.
33907
33908After a new Exim process has interpreted its command line options, it changes
33909uid and gid in the following cases:
33910
33911 * If the -C option is used to specify an alternate configuration file, or if
33912 the -D option is used to define macro values for the configuration, and the
33913 calling process is not running as root, the uid and gid are changed to
33914 those of the calling process. However, if DISABLE_D_OPTION is defined in
33915 Local/Makefile, the -D option may not be used at all. If WHITELIST_D_MACROS
33916 is defined in Local/Makefile, then some macro values can be supplied if the
33917 calling process is running as root, the Exim run-time user or
33918 CONFIGURE_OWNER, if defined.
33919
33920 * If the expansion test option (-be) or one of the filter testing options (
33921 -bf or -bF) are used, the uid and gid are changed to those of the calling
33922 process.
33923
33924 * If the process is not a daemon process or a queue runner process or a
33925 delivery process or a process for testing address routing (started with -bt
33926 ), the uid and gid are changed to the Exim user and group. This means that
33927 Exim always runs under its own uid and gid when receiving messages. This
33928 also applies when testing address verification (the -bv option) and testing
33929 incoming message policy controls (the -bh option).
33930
33931 * For a daemon, queue runner, delivery, or address testing process, the uid
33932 remains as root at this stage, but the gid is changed to the Exim group.
33933
33934The processes that initially retain root privilege behave as follows:
33935
33936 * A daemon process changes the gid to the Exim group and the uid to the Exim
33937 user after setting up one or more listening sockets. The initgroups()
33938 function is called, so that if the Exim user is in any additional groups,
33939 they will be used during message reception.
33940
33941 * A queue runner process retains root privilege throughout its execution. Its
33942 job is to fork a controlled sequence of delivery processes.
33943
33944 * A delivery process retains root privilege throughout most of its execution,
33945 but any actual deliveries (that is, the transports themselves) are run in
33946 subprocesses which always change to a non-root uid and gid. For local
33947 deliveries this is typically the uid and gid of the owner of the mailbox;
33948 for remote deliveries, the Exim uid and gid are used. Once all the delivery
33949 subprocesses have been run, a delivery process changes to the Exim uid and
33950 gid while doing post-delivery tidying up such as updating the retry
33951 database and generating bounce and warning messages.
33952
33953 While the recipient addresses in a message are being routed, the delivery
33954 process runs as root. However, if a user's filter file has to be processed,
33955 this is done in a subprocess that runs under the individual user's uid and
33956 gid. A system filter is run as root unless system_filter_user is set.
33957
33958 * A process that is testing addresses (the -bt option) runs as root so that
33959 the routing is done in the same environment as a message delivery.
33960
33961
3396254.3 Running Exim without privilege
33963-----------------------------------
33964
33965Some installations like to run Exim in an unprivileged state for more of its
33966operation, for added security. Support for this mode of operation is provided
33967by the global option deliver_drop_privilege. When this is set, the uid and gid
33968are changed to the Exim user and group at the start of a delivery process (and
33969also queue runner and address testing processes). This means that address
33970routing is no longer run as root, and the deliveries themselves cannot change
33971to any other uid.
33972
33973Leaving the binary setuid to root, but setting deliver_drop_privilege means
33974that the daemon can still be started in the usual way, and it can respond
33975correctly to SIGHUP because the re-invocation regains root privilege.
33976
33977An alternative approach is to make Exim setuid to the Exim user and also setgid
33978to the Exim group. If you do this, the daemon must be started from a root
33979process. (Calling Exim from a root process makes it behave in the way it does
33980when it is setuid root.) However, the daemon cannot restart itself after a
33981SIGHUP signal because it cannot regain privilege.
33982
33983It is still useful to set deliver_drop_privilege in this case, because it stops
33984Exim from trying to re-invoke itself to do a delivery after a message has been
33985received. Such a re-invocation is a waste of resources because it has no
33986effect.
33987
33988If restarting the daemon is not an issue (for example, if mua_wrapper is set,
33989or inetd is being used instead of a daemon), having the binary setuid to the
33990Exim user seems a clean approach, but there is one complication:
33991
33992In this style of operation, Exim is running with the real uid and gid set to
33993those of the calling process, and the effective uid/gid set to Exim's values.
33994Ideally, any association with the calling process' uid/gid should be dropped,
33995that is, the real uid/gid should be reset to the effective values so as to
33996discard any privileges that the caller may have. While some operating systems
33997have a function that permits this action for a non-root effective uid, quite a
33998number of them do not. Because of this lack of standardization, Exim does not
33999address this problem at this time.
34000
34001For this reason, the recommended approach for "mostly unprivileged" running is
34002to keep the Exim binary setuid to root, and to set deliver_drop_privilege. This
34003also has the advantage of allowing a daemon to be used in the most
34004straightforward way.
34005
34006If you configure Exim not to run delivery processes as root, there are a number
34007of restrictions on what you can do:
34008
34009 * You can deliver only as the Exim user/group. You should explicitly use the
34010 user and group options to override routers or local transports that
34011 normally deliver as the recipient. This makes sure that configurations that
34012 work in this mode function the same way in normal mode. Any implicit or
34013 explicit specification of another user causes an error.
34014
34015 * Use of .forward files is severely restricted, such that it is usually not
34016 worthwhile to include them in the configuration.
34017
34018 * Users who wish to use .forward would have to make their home directory and
34019 the file itself accessible to the Exim user. Pipe and append-to-file
34020 entries, and their equivalents in Exim filters, cannot be used. While they
34021 could be enabled in the Exim user's name, that would be insecure and not
34022 very useful.
34023
34024 * Unless the local user mailboxes are all owned by the Exim user (possible in
34025 some POP3 or IMAP-only environments):
34026
34027 1. They must be owned by the Exim group and be writeable by that group.
34028 This implies you must set mode in the appendfile configuration, as well
34029 as the mode of the mailbox files themselves.
34030
34031 2. You must set no_check_owner, since most or all of the files will not be
34032 owned by the Exim user.
34033
34034 3. You must set file_must_exist, because Exim cannot set the owner
34035 correctly on a newly created mailbox when unprivileged. This also
34036 implies that new mailboxes need to be created manually.
34037
34038These restrictions severely restrict what can be done in local deliveries.
34039However, there are no restrictions on remote deliveries. If you are running a
34040gateway host that does no local deliveries, setting deliver_drop_privilege
34041gives more security at essentially no cost.
34042
34043If you are using the mua_wrapper facility (see chapter 50),
34044deliver_drop_privilege is forced to be true.
34045
34046
3404754.4 Delivering to local files
34048------------------------------
34049
34050Full details of the checks applied by appendfile before it writes to a file are
34051given in chapter 26.
34052
34053
3405454.5 Running local commands
34055---------------------------
34056
34057There are a number of ways in which an administrator can configure Exim to run
34058commands based upon received, untrustworthy, data. Further, in some
34059configurations a user who can control a .forward file can also arrange to run
34060commands. Configuration to check includes, but is not limited to:
34061
34062 * Use of use_shell in the pipe transport: various forms of shell command
34063 injection may be possible with this option present. It is dangerous and
34064 should be used only with considerable caution. Consider constraints which
34065 whitelist allowed characters in a variable which is to be used in a pipe
34066 transport that has use_shell enabled.
34067
34068 * A number of options such as forbid_filter_run, forbid_filter_perl,
34069 forbid_filter_dlfunc and so forth which restrict facilities available to
34070 .forward files in a redirect router. If Exim is running on a central mail
34071 hub to which ordinary users do not have shell access, but home directories
34072 are NFS mounted (for instance) then administrators should review the list
34073 of these forbid options available, and should bear in mind that the options
34074 that may need forbidding can change as new features are added between
34075 releases.
34076
34077 * The ${run...} expansion item does not use a shell by default, but
34078 administrators can configure use of /bin/sh as part of the command. Such
34079 invocations should be viewed with prejudicial suspicion.
34080
34081 * Administrators who use embedded Perl are advised to explore how Perl's
34082 taint checking might apply to their usage.
34083
34084 * Use of ${expand...} is somewhat analagous to shell's eval builtin and
34085 administrators are well advised to view its use with suspicion, in case
34086 (for instance) it allows a local-part to contain embedded Exim directives.
34087
34088 * Use of ${match_local_part...} and friends becomes more dangerous if Exim
34089 was built with EXPAND_LISTMATCH_RHS defined: the second string in each can
34090 reference arbitrary lists and files, rather than just being a list of
34091 opaque strings. The EXPAND_LISTMATCH_RHS option was added and set false by
34092 default because of real-world security vulnerabilities caused by its use
34093 with untrustworthy data injected in, for SQL injection attacks. Consider
34094 the use of the inlisti expansion condition instead.
34095
34096
3409754.6 Trust in configuration data
34098--------------------------------
34099
34100If configuration data for Exim can come from untrustworthy sources, there are
34101some issues to be aware of:
34102
34103 * Use of ${expand...} may provide a path for shell injection attacks.
34104
34105 * Letting untrusted data provide a regular expression is unwise.
34106
34107 * Using ${match...} to apply a fixed regular expression against untrusted
34108 data may result in pathological behaviour within PCRE. Be aware of what
34109 "backtracking" means and consider options for being more strict with a
34110 regular expression. Avenues to explore include limiting what can match
34111 (avoiding "." when "[a-z0-9]" or other character class will do), use of
34112 atomic grouping and possessive quantifiers or just not using regular
34113 expressions against untrusted data.
34114
34115 * It can be important to correctly use ${quote:...}, ${quote_local_part:...}
34116 and ${quote_<lookup-type>:...} expansion items to ensure that data is
34117 correctly constructed.
34118
34119 * Some lookups might return multiple results, even though normal usage is
34120 only expected to yield one result.
34121
34122
3412354.7 IPv4 source routing
34124------------------------
34125
34126Many operating systems suppress IP source-routed packets in the kernel, but
34127some cannot be made to do this, so Exim does its own check. It logs incoming
34128IPv4 source-routed TCP calls, and then drops them. Things are all different in
34129IPv6. No special checking is currently done.
34130
34131
3413254.8 The VRFY, EXPN, and ETRN commands in SMTP
34133----------------------------------------------
34134
34135Support for these SMTP commands is disabled by default. If required, they can
34136be enabled by defining suitable ACLs.
34137
34138
3413954.9 Privileged users
34140---------------------
34141
34142Exim recognizes two sets of users with special privileges. Trusted users are
34143able to submit new messages to Exim locally, but supply their own sender
34144addresses and information about a sending host. For other users submitting
34145local messages, Exim sets up the sender address from the uid, and doesn't
34146permit a remote host to be specified.
34147
34148However, an untrusted user is permitted to use the -f command line option in
34149the special form -f <> to indicate that a delivery failure for the message
34150should not cause an error report. This affects the message's envelope, but it
34151does not affect the Sender: header. Untrusted users may also be permitted to
34152use specific forms of address with the -f option by setting the
34153untrusted_set_sender option.
34154
34155Trusted users are used to run processes that receive mail messages from some
34156other mail domain and pass them on to Exim for delivery either locally, or over
34157the Internet. Exim trusts a caller that is running as root, as the Exim user,
34158as any user listed in the trusted_users configuration option, or under any
34159group listed in the trusted_groups option.
34160
34161Admin users are permitted to do things to the messages on Exim's queue. They
34162can freeze or thaw messages, cause them to be returned to their senders, remove
34163them entirely, or modify them in various ways. In addition, admin users can run
34164the Exim monitor and see all the information it is capable of providing, which
34165includes the contents of files on the spool.
34166
34167By default, the use of the -M and -q options to cause Exim to attempt delivery
34168of messages on its queue is restricted to admin users. This restriction can be
34169relaxed by setting the no_prod_requires_admin option. Similarly, the use of -bp
34170(and its variants) to list the contents of the queue is also restricted to
34171admin users. This restriction can be relaxed by setting
34172no_queue_list_requires_admin.
34173
34174Exim recognizes an admin user if the calling process is running as root or as
34175the Exim user or if any of the groups associated with the calling process is
34176the Exim group. It is not necessary actually to be running under the Exim
34177group. However, if admin users who are not root or the Exim user are to access
34178the contents of files on the spool via the Exim monitor (which runs
34179unprivileged), Exim must be built to allow group read access to its spool
34180files.
34181
34182
3418354.10 Spool files
34184-----------------
34185
34186Exim's spool directory and everything it contains is owned by the Exim user and
34187set to the Exim group. The mode for spool files is defined in the Local/
34188Makefile configuration file, and defaults to 0640. This means that any user who
34189is a member of the Exim group can access these files.
34190
34191
3419254.11 Use of argv[0]
34193--------------------
34194
34195Exim examines the last component of argv[0], and if it matches one of a set of
34196specific strings, Exim assumes certain options. For example, calling Exim with
34197the last component of argv[0] set to "rsmtp" is exactly equivalent to calling
34198it with the option -bS. There are no security implications in this.
34199
34200
3420154.12 Use of %f formatting
34202--------------------------
34203
34204The only use made of "%f" by Exim is in formatting load average values. These
34205are actually stored in integer variables as 1000 times the load average.
34206Consequently, their range is limited and so therefore is the length of the
34207converted output.
34208
34209
3421054.13 Embedded Exim path
34211------------------------
34212
34213Exim uses its own path name, which is embedded in the code, only when it needs
34214to re-exec in order to regain root privilege. Therefore, it is not root when it
34215does so. If some bug allowed the path to get overwritten, it would lead to an
34216arbitrary program's being run as exim, not as root.
34217
34218
3421954.14 Dynamic module directory
34220------------------------------
34221
34222Any dynamically loadable modules must be installed into the directory defined
34223in "LOOKUP_MODULE_DIR" in Local/Makefile for Exim to permit loading it.
34224
34225
3422654.15 Use of sprintf()
34227----------------------
34228
34229A large number of occurrences of "sprintf" in the code are actually calls to
34230string_sprintf(), a function that returns the result in malloc'd store. The
34231intermediate formatting is done into a large fixed buffer by a function that
34232runs through the format string itself, and checks the length of each conversion
34233before performing it, thus preventing buffer overruns.
34234
34235The remaining uses of sprintf() happen in controlled circumstances where the
34236output buffer is known to be sufficiently long to contain the converted string.
34237
34238
3423954.16 Use of debug_printf() and log_write()
34240-------------------------------------------
34241
34242Arbitrary strings are passed to both these functions, but they do their
34243formatting by calling the function string_vformat(), which runs through the
34244format string itself, and checks the length of each conversion.
34245
34246
3424754.17 Use of strcat() and strcpy()
34248----------------------------------
34249
34250These are used only in cases where the output buffer is known to be large
34251enough to hold the result.
34252
34253
34254
34255===============================================================================
3425655. FORMAT OF SPOOL FILES
34257
34258A message on Exim's queue consists of two files, whose names are the message id
34259followed by -D and -H, respectively. The data portion of the message is kept in
34260the -D file on its own. The message's envelope, status, and headers are all
34261kept in the -H file, whose format is described in this chapter. Each of these
34262two files contains the final component of its own name as its first line. This
34263is insurance against disk crashes where the directory is lost but the files
34264themselves are recoverable.
34265
34266Some people are tempted into editing -D files in order to modify messages. You
34267need to be extremely careful if you do this; it is not recommended and you are
34268on your own if you do it. Here are some of the pitfalls:
34269
34270 * You must ensure that Exim does not try to deliver the message while you are
34271 fiddling with it. The safest way is to take out a write lock on the -D
34272 file, which is what Exim itself does, using fcntl(). If you update the file
34273 in place, the lock will be retained. If you write a new file and rename it,
34274 the lock will be lost at the instant of rename.
34275
34276 * If you change the number of lines in the file, the value of $body_linecount
34277 , which is stored in the -H file, will be incorrect. At present, this value
34278 is not used by Exim, but there is no guarantee that this will always be the
34279 case.
34280
34281 * If the message is in MIME format, you must take care not to break it.
34282
34283 * If the message is cryptographically signed, any change will invalidate the
34284 signature.
34285
34286All in all, modifying -D files is fraught with danger.
34287
34288Files whose names end with -J may also be seen in the input directory (or its
34289subdirectories when split_spool_directory is set). These are journal files,
34290used to record addresses to which the message has been delivered during the
34291course of a delivery attempt. If there are still undelivered recipients at the
34292end, the -H file is updated, and the -J file is deleted. If, however, there is
34293some kind of crash (for example, a power outage) before this happens, the -J
34294file remains in existence. When Exim next processes the message, it notices the
34295-J file and uses it to update the -H file before starting the next delivery
34296attempt.
34297
34298
3429955.1 Format of the -H file
34300--------------------------
34301
34302The second line of the -H file contains the login name for the uid of the
34303process that called Exim to read the message, followed by the numerical uid and
34304gid. For a locally generated message, this is normally the user who sent the
34305message. For a message received over TCP/IP via the daemon, it is normally the
34306Exim user.
34307
34308The third line of the file contains the address of the message's sender as
34309transmitted in the envelope, contained in angle brackets. The sender address is
34310empty for bounce messages. For incoming SMTP mail, the sender address is given
34311in the MAIL command. For locally generated mail, the sender address is created
34312by Exim from the login name of the current user and the configured
34313qualify_domain. However, this can be overridden by the -f option or a leading
34314"From " line if the caller is trusted, or if the supplied address is "<>" or an
34315address that matches untrusted_set_senders.
34316
34317The fourth line contains two numbers. The first is the time that the message
34318was received, in the conventional Unix form - the number of seconds since the
34319start of the epoch. The second number is a count of the number of messages
34320warning of delayed delivery that have been sent to the sender.
34321
34322There follow a number of lines starting with a hyphen. These can appear in any
34323order, and are omitted when not relevant:
34324
34325-acl <number> <length>
34326
34327 This item is obsolete, and is not generated from Exim release 4.61 onwards;
34328 -aclc and -aclm are used instead. However, -acl is still recognized, to
34329 provide backward compatibility. In the old format, a line of this form is
34330 present for every ACL variable that is not empty. The number identifies the
34331 variable; the acl_cx variables are numbered 0-9 and the acl_mx variables
34332 are numbered 10-19. The length is the length of the data string for the
34333 variable. The string itself starts at the beginning of the next line, and
34334 is followed by a newline character. It may contain internal newlines.
34335
34336-aclc <rest-of-name> <length>
34337
34338 A line of this form is present for every ACL connection variable that is
34339 defined. Note that there is a space between -aclc and the rest of the name.
34340 The length is the length of the data string for the variable. The string
34341 itself starts at the beginning of the next line, and is followed by a
34342 newline character. It may contain internal newlines.
34343
34344-aclm <rest-of-name> <length>
34345
34346 A line of this form is present for every ACL message variable that is
34347 defined. Note that there is a space between -aclm and the rest of the name.
34348 The length is the length of the data string for the variable. The string
34349 itself starts at the beginning of the next line, and is followed by a
34350 newline character. It may contain internal newlines.
34351
34352-active_hostname <hostname>
34353
34354 This is present if, when the message was received over SMTP, the value of
34355 $smtp_active_hostname was different to the value of $primary_hostname.
34356
34357-allow_unqualified_recipient
34358
34359 This is present if unqualified recipient addresses are permitted in header
34360 lines (to stop such addresses from being qualified if rewriting occurs at
34361 transport time). Local messages that were input using -bnq and remote
34362 messages from hosts that match recipient_unqualified_hosts set this flag.
34363
34364-allow_unqualified_sender
34365
34366 This is present if unqualified sender addresses are permitted in header
34367 lines (to stop such addresses from being qualified if rewriting occurs at
34368 transport time). Local messages that were input using -bnq and remote
34369 messages from hosts that match sender_unqualified_hosts set this flag.
34370
34371-auth_id <text>
34372
34373 The id information for a message received on an authenticated SMTP
34374 connection - the value of the $authenticated_id variable.
34375
34376-auth_sender <address>
34377
34378 The address of an authenticated sender - the value of the
34379 $authenticated_sender variable.
34380
34381-body_linecount <number>
34382
34383 This records the number of lines in the body of the message, and is always
34384 present.
34385
34386-body_zerocount <number>
34387
34388 This records the number of binary zero bytes in the body of the message,
34389 and is present if the number is greater than zero.
34390
34391-deliver_firsttime
34392
34393 This is written when a new message is first added to the spool. When the
34394 spool file is updated after a deferral, it is omitted.
34395
34396-frozen <time>
34397
34398 The message is frozen, and the freezing happened at <time>.
34399
34400-helo_name <text>
34401
34402 This records the host name as specified by a remote host in a HELO or EHLO
34403 command.
34404
34405-host_address <address>.<port>
34406
34407 This records the IP address of the host from which the message was received
34408 and the remote port number that was used. It is omitted for locally
34409 generated messages.
34410
34411-host_auth <text>
34412
34413 If the message was received on an authenticated SMTP connection, this
34414 records the name of the authenticator - the value of the
34415 $sender_host_authenticated variable.
34416
34417-host_lookup_failed
34418
34419 This is present if an attempt to look up the sending host's name from its
34420 IP address failed. It corresponds to the $host_lookup_failed variable.
34421
34422-host_name <text>
34423
34424 This records the name of the remote host from which the message was
34425 received, if the host name was looked up from the IP address when the
34426 message was being received. It is not present if no reverse lookup was
34427 done.
34428
34429-ident <text>
34430
34431 For locally submitted messages, this records the login of the originating
34432 user, unless it was a trusted user and the -oMt option was used to specify
34433 an ident value. For messages received over TCP/IP, this records the ident
34434 string supplied by the remote host, if any.
34435
34436-interface_address <address>.<port>
34437
34438 This records the IP address of the local interface and the port number
34439 through which a message was received from a remote host. It is omitted for
34440 locally generated messages.
34441
34442-local
34443
34444 The message is from a local sender.
34445
34446-localerror
34447
34448 The message is a locally-generated bounce message.
34449
34450-local_scan <string>
34451
34452 This records the data string that was returned by the local_scan() function
34453 when the message was received - the value of the $local_scan_data variable.
34454 It is omitted if no data was returned.
34455
34456-manual_thaw
34457
34458 The message was frozen but has been thawed manually, that is, by an
34459 explicit Exim command rather than via the auto-thaw process.
34460
34461-N
34462
34463 A testing delivery process was started using the -N option to suppress any
34464 actual deliveries, but delivery was deferred. At any further delivery
34465 attempts, -N is assumed.
34466
34467-received_protocol
34468
34469 This records the value of the $received_protocol variable, which contains
34470 the name of the protocol by which the message was received.
34471
34472-sender_set_untrusted
34473
34474 The envelope sender of this message was set by an untrusted local caller
34475 (used to ensure that the caller is displayed in queue listings).
34476
34477-spam_score_int <number>
34478
34479 If a message was scanned by SpamAssassin, this is present. It records the
34480 value of $spam_score_int.
34481
34482-tls_certificate_verified
34483
34484 A TLS certificate was received from the client that sent this message, and
34485 the certificate was verified by the server.
34486
34487-tls_cipher <cipher name>
34488
34489 When the message was received over an encrypted connection, this records
34490 the name of the cipher suite that was used.
34491
34492-tls_peerdn <peer DN>
34493
34494 When the message was received over an encrypted connection, and a
34495 certificate was received from the client, this records the Distinguished
34496 Name from that certificate.
34497
34498Following the options there is a list of those addresses to which the message
34499is not to be delivered. This set of addresses is initialized from the command
34500line when the -t option is used and extract_addresses_remove_arguments is set;
34501otherwise it starts out empty. Whenever a successful delivery is made, the
34502address is added to this set. The addresses are kept internally as a balanced
34503binary tree, and it is a representation of that tree which is written to the
34504spool file. If an address is expanded via an alias or forward file, the
34505original address is added to the tree when deliveries to all its child
34506addresses are complete.
34507
34508If the tree is empty, there is a single line in the spool file containing just
34509the text "XX". Otherwise, each line consists of two letters, which are either Y
34510or N, followed by an address. The address is the value for the node of the
34511tree, and the letters indicate whether the node has a left branch and/or a
34512right branch attached to it, respectively. If branches exist, they immediately
34513follow. Here is an example of a three-node tree:
34514
34515YY darcy@austen.fict.example
34516NN alice@wonderland.fict.example
34517NN editor@thesaurus.ref.example
34518
34519After the non-recipients tree, there is a list of the message's recipients.
34520This is a simple list, preceded by a count. It includes all the original
34521recipients of the message, including those to whom the message has already been
34522delivered. In the simplest case, the list contains one address per line. For
34523example:
34524
345254
34526editor@thesaurus.ref.example
34527darcy@austen.fict.example
34528rdo@foundation
34529alice@wonderland.fict.example
34530
34531However, when a child address has been added to the top-level addresses as a
34532result of the use of the one_time option on a redirect router, each line is of
34533the following form:
34534
34535<top-level address> <errors_to address> <length>,<parent number>#<flag bits>
34536
34537The 01 flag bit indicates the presence of the three other fields that follow
34538the top-level address. Other bits may be used in future to support additional
34539fields. The <parent number> is the offset in the recipients list of the
34540original parent of the "one time" address. The first two fields are the
34541envelope sender that is associated with this address and its length. If the
34542length is zero, there is no special envelope sender (there are then two space
34543characters in the line). A non-empty field can arise from a redirect router
34544that has an errors_to setting.
34545
34546A blank line separates the envelope and status information from the headers
34547which follow. A header may occupy several lines of the file, and to save effort
34548when reading it in, each header is preceded by a number and an identifying
34549character. The number is the number of characters in the header, including any
34550embedded newlines and the terminating newline. The character is one of the
34551following:
34552
34553<blank> header in which Exim has no special interest
34554"B" Bcc: header
34555"C" Cc: header
34556"F" From: header
34557"I" Message-id: header
34558"P" Received: header - P for "postmark"
34559"R" Reply-To: header
34560"S" Sender: header
34561"T" To: header
34562"*" replaced or deleted header
34563
34564Deleted or replaced (rewritten) headers remain in the spool file for debugging
34565purposes. They are not transmitted when the message is delivered. Here is a
34566typical set of headers:
34567
34568111P Received: by hobbit.fict.example with local (Exim 4.00)
34569id 14y9EI-00026G-00; Fri, 11 May 2001 10:28:59 +0100
34570049 Message-Id: <E14y9EI-00026G-00@hobbit.fict.example>
34571038* X-rewrote-sender: bb@hobbit.fict.example
34572042* From: Bilbo Baggins <bb@hobbit.fict.example>
34573049F From: Bilbo Baggins <B.Baggins@hobbit.fict.example>
34574099* To: alice@wonderland.fict.example, rdo@foundation,
34575darcy@austen.fict.example, editor@thesaurus.ref.example
34576104T To: alice@wonderland.fict.example, rdo@foundation.example,
34577darcy@austen.fict.example, editor@thesaurus.ref.example
34578038 Date: Fri, 11 May 2001 10:28:59 +0100
34579
34580The asterisked headers indicate that the envelope sender, From: header, and To:
34581header have been rewritten, the last one because routing expanded the
34582unqualified domain foundation.
34583
34584
34585
34586===============================================================================
3458756. SUPPORT FOR DKIM (DOMAINKEYS IDENTIFIED MAIL)
34588
34589DKIM is a mechanism by which messages sent by some entity can be provably
34590linked to a domain which that entity controls. It permits reputation to be
34591tracked on a per-domain basis, rather than merely upon source IP address. DKIM
34592is documented in RFC 4871.
34593
34594Since version 4.70, DKIM support is compiled into Exim by default. It can be
34595disabled by setting DISABLE_DKIM=yes in Local/Makefile.
34596
34597Exim's DKIM implementation allows to
34598
34599 1. Sign outgoing messages: This function is implemented in the SMTP transport.
34600 It can co-exist with all other Exim features (including transport filters)
34601 except cutthrough delivery.
34602
34603 2. Verify signatures in incoming messages: This is implemented by an
34604 additional ACL (acl_smtp_dkim), which can be called several times per
34605 message, with different signature contexts.
34606
34607In typical Exim style, the verification implementation does not include any
34608default "policy". Instead it enables you to build your own policy using Exim's
34609standard controls.
34610
34611Please note that verification of DKIM signatures in incoming mail is turned on
34612by default for logging purposes. For each signature in incoming email, exim
34613will log a line displaying the most important signature details, and the
34614signature status. Here is an example (with line-breaks added for clarity):
34615
346162009-09-09 10:22:28 1MlIRf-0003LU-U3 DKIM:
34617 d=facebookmail.com s=q1-2009b
34618 c=relaxed/relaxed a=rsa-sha1
34619 i=@facebookmail.com t=1252484542 [verification succeeded]
34620
34621You might want to turn off DKIM verification processing entirely for internal
34622or relay mail sources. To do that, set the dkim_disable_verify ACL control
34623modifier. This should typically be done in the RCPT ACL, at points where you
34624accept mail from relay sources (internal hosts or authenticated senders).
34625
34626
3462756.1 Signing outgoing messages
34628------------------------------
34629
34630Signing is implemented by setting private options on the SMTP transport. These
34631options take (expandable) strings as arguments.
34632
34633+-----------+---------+-------------+--------------+
34634|dkim_domain|Use: smtp|Type: string*|Default: unset|
34635+-----------+---------+-------------+--------------+
34636
34637MANDATORY: The domain you want to sign with. The result of this expanded option
34638is put into the $dkim_domain expansion variable.
34639
34640+-------------+---------+-------------+--------------+
34641|dkim_selector|Use: smtp|Type: string*|Default: unset|
34642+-------------+---------+-------------+--------------+
34643
34644MANDATORY: This sets the key selector string. You can use the $dkim_domain
34645expansion variable to look up a matching selector. The result is put in the
34646expansion variable $dkim_selector which should be used in the dkim_private_key
34647option along with $dkim_domain.
34648
34649+----------------+---------+-------------+--------------+
34650|dkim_private_key|Use: smtp|Type: string*|Default: unset|
34651+----------------+---------+-------------+--------------+
34652
34653MANDATORY: This sets the private key to use. You can use the $dkim_domain and
34654$dkim_selector expansion variables to determine the private key to use. The
34655result can either
34656
34657 * be a valid RSA private key in ASCII armor, including line breaks.
34658
34659 * start with a slash, in which case it is treated as a file that contains the
34660 private key.
34661
34662 * be "0", "false" or the empty string, in which case the message will not be
34663 signed. This case will not result in an error, even if dkim_strict is set.
34664
34665+----------+---------+-------------+--------------+
34666|dkim_canon|Use: smtp|Type: string*|Default: unset|
34667+----------+---------+-------------+--------------+
34668
34669OPTIONAL: This option sets the canonicalization method used when signing a
34670message. The DKIM RFC currently supports two methods: "simple" and "relaxed".
34671The option defaults to "relaxed" when unset. Note: the current implementation
34672only supports using the same canonicalization method for both headers and body.
34673
34674+-----------+---------+-------------+--------------+
34675|dkim_strict|Use: smtp|Type: string*|Default: unset|
34676+-----------+---------+-------------+--------------+
34677
34678OPTIONAL: This option defines how Exim behaves when signing a message that
34679should be signed fails for some reason. When the expansion evaluates to either
34680"1" or "true", Exim will defer. Otherwise Exim will send the message unsigned.
34681You can use the $dkim_domain and $dkim_selector expansion variables here.
34682
34683+-----------------+---------+-------------+--------------+
34684|dkim_sign_headers|Use: smtp|Type: string*|Default: unset|
34685+-----------------+---------+-------------+--------------+
34686
34687OPTIONAL: When set, this option must expand to (or be specified as) a
34688colon-separated list of header names. Headers with these names will be included
34689in the message signature. When unspecified, the header names recommended in
34690RFC4871 will be used.
34691
34692
3469356.2 Verifying DKIM signatures in incoming mail
34694-----------------------------------------------
34695
34696Verification of DKIM signatures in incoming email is implemented via the
34697acl_smtp_dkim ACL. By default, this ACL is called once for each syntactically
34698(!) correct signature in the incoming message. A missing ACL definition
34699defaults to accept. If any ACL call does not acccept, the message is not
34700accepted. If a cutthrough delivery was in progress for the message it is
34701summarily dropped (having wasted the transmission effort).
34702
34703To evaluate the signature in the ACL a large number of expansion variables
34704containing the signature status and its details are set up during the runtime
34705of the ACL.
34706
34707Calling the ACL only for existing signatures is not sufficient to build more
34708advanced policies. For that reason, the global option dkim_verify_signers, and
34709a global expansion variable $dkim_signers exist.
34710
34711The global option dkim_verify_signers can be set to a colon-separated list of
34712DKIM domains or identities for which the ACL acl_smtp_dkim is called. It is
34713expanded when the message has been received. At this point, the expansion
34714variable $dkim_signers already contains a colon-separated list of signer
34715domains and identities for the message. When dkim_verify_signers is not
34716specified in the main configuration, it defaults as:
34717
34718dkim_verify_signers = $dkim_signers
34719
34720This leads to the default behaviour of calling acl_smtp_dkim for each DKIM
34721signature in the message. Current DKIM verifiers may want to explicitly call
34722the ACL for known domains or identities. This would be achieved as follows:
34723
34724dkim_verify_signers = paypal.com:ebay.com:$dkim_signers
34725
34726This would result in acl_smtp_dkim always being called for "paypal.com" and
34727"ebay.com", plus all domains and identities that have signatures in the
34728message. You can also be more creative in constructing your policy. For
34729example:
34730
34731dkim_verify_signers = $sender_address_domain:$dkim_signers
34732
34733If a domain or identity is listed several times in the (expanded) value of
34734dkim_verify_signers, the ACL is only called once for that domain or identity.
34735
34736Inside the acl_smtp_dkim, the following expansion variables are available (from
34737most to least important):
34738
34739$dkim_cur_signer
34740
34741 The signer that is being evaluated in this ACL run. This can be a domain or
34742 an identity. This is one of the list items from the expanded main option
34743 dkim_verify_signers (see above).
34744
34745$dkim_verify_status
34746
34747 A string describing the general status of the signature. One of
34748
34749 * none: There is no signature in the message for the current domain or
34750 identity (as reflected by $dkim_cur_signer).
34751
34752 * invalid: The signature could not be verified due to a processing error.
34753 More detail is available in $dkim_verify_reason.
34754
34755 * fail: Verification of the signature failed. More detail is available in
34756 $dkim_verify_reason.
34757
34758 * pass: The signature passed verification. It is valid.
34759
34760$dkim_verify_reason
34761
34762 A string giving a litte bit more detail when $dkim_verify_status is either
34763 "fail" or "invalid". One of
34764
34765 * pubkey_unavailable (when $dkim_verify_status="invalid"): The public key
34766 for the domain could not be retrieved. This may be a temporary problem.
34767
34768 * pubkey_syntax (when $dkim_verify_status="invalid"): The public key
34769 record for the domain is syntactically invalid.
34770
34771 * bodyhash_mismatch (when $dkim_verify_status="fail"): The calculated
34772 body hash does not match the one specified in the signature header.
34773 This means that the message body was modified in transit.
34774
34775 * signature_incorrect (when $dkim_verify_status="fail"): The signature
34776 could not be verified. This may mean that headers were modified,
34777 re-written or otherwise changed in a way which is incompatible with
34778 DKIM verification. It may of course also mean that the signature is
34779 forged.
34780
34781$dkim_domain
34782
34783 The signing domain. IMPORTANT: This variable is only populated if there is
34784 an actual signature in the message for the current domain or identity (as
34785 reflected by $dkim_cur_signer).
34786
34787$dkim_identity
34788
34789 The signing identity, if present. IMPORTANT: This variable is only
34790 populated if there is an actual signature in the message for the current
34791 domain or identity (as reflected by $dkim_cur_signer).
34792
34793$dkim_selector
34794
34795 The key record selector string.
34796
34797$dkim_algo
34798
34799 The algorithm used. One of 'rsa-sha1' or 'rsa-sha256'.
34800
34801$dkim_canon_body
34802
34803 The body canonicalization method. One of 'relaxed' or 'simple'.
34804
34805dkim_canon_headers
34806
34807 The header canonicalization method. One of 'relaxed' or 'simple'.
34808
34809$dkim_copiedheaders
34810
34811 A transcript of headers and their values which are included in the
34812 signature (copied from the 'z=' tag of the signature).
34813
34814$dkim_bodylength
34815
34816 The number of signed body bytes. If zero ("0"), the body is unsigned. If no
34817 limit was set by the signer, "9999999999999" is returned. This makes sure
34818 that this variable always expands to an integer value.
34819
34820$dkim_created
34821
34822 UNIX timestamp reflecting the date and time when the signature was created.
34823 When this was not specified by the signer, "0" is returned.
34824
34825$dkim_expires
34826
34827 UNIX timestamp reflecting the date and time when the signer wants the
34828 signature to be treated as "expired". When this was not specified by the
34829 signer, "9999999999999" is returned. This makes it possible to do useful
34830 integer size comparisons against this value.
34831
34832$dkim_headernames
34833
34834 A colon-separated list of names of headers included in the signature.
34835
34836$dkim_key_testing
34837
34838 "1" if the key record has the "testing" flag set, "0" if not.
34839
34840$dkim_key_nosubdomains
34841
34842 "1" if the key record forbids subdomaining, "0" otherwise.
34843
34844$dkim_key_srvtype
34845
34846 Service type (tag s=) from the key record. Defaults to "*" if not specified
34847 in the key record.
34848
34849$dkim_key_granularity
34850
34851 Key granularity (tag g=) from the key record. Defaults to "*" if not
34852 specified in the key record.
34853
34854$dkim_key_notes
34855
34856 Notes from the key record (tag n=).
34857
34858In addition, two ACL conditions are provided:
34859
34860dkim_signers
34861
34862 ACL condition that checks a colon-separated list of domains or identities
34863 for a match against the domain or identity that the ACL is currently
34864 verifying (reflected by $dkim_cur_signer). This is typically used to
34865 restrict an ACL verb to a group of domains or identities. For example:
34866
34867 # Warn when Mail purportedly from GMail has no signature at all
34868 warn log_message = GMail sender without DKIM signature
34869 sender_domains = gmail.com
34870 dkim_signers = gmail.com
34871 dkim_status = none
34872
34873dkim_status
34874
34875 ACL condition that checks a colon-separated list of possible DKIM
34876 verification results against the actual result of verification. This is
34877 typically used to restrict an ACL verb to a list of verification outcomes,
34878 for example:
34879
34880 deny message = Mail from Paypal with invalid/missing signature
34881 sender_domains = paypal.com:paypal.de
34882 dkim_signers = paypal.com:paypal.de
34883 dkim_status = none:invalid:fail
34884
34885 The possible status keywords are: 'none','invalid','fail' and 'pass'.
34886 Please see the documentation of the $dkim_verify_status expansion variable
34887 above for more information of what they mean.
34888
34889
34890
34891===============================================================================
3489257. ADDING NEW DRIVERS OR LOOKUP TYPES
34893
34894The following actions have to be taken in order to add a new router, transport,
34895authenticator, or lookup type to Exim:
34896
34897 1. Choose a name for the driver or lookup type that does not conflict with any
34898 existing name; I will use "newdriver" in what follows.
34899
34900 2. Add to src/EDITME the line:
34901
34902 <type>_NEWDRIVER=yes
34903
34904 where <type> is ROUTER, TRANSPORT, AUTH, or LOOKUP. If the code is not to
34905 be included in the binary by default, comment this line out. You should
34906 also add any relevant comments about the driver or lookup type.
34907
34908 3. Add to src/config.h.defaults the line:
34909
34910 #define <type>_NEWDRIVER
34911
34912 4. Edit src/drtables.c, adding conditional code to pull in the private header
34913 and create a table entry as is done for all the other drivers and lookup
34914 types.
34915
34916 5. Edit scripts/lookups-Makefile if this is a new lookup; there is a for-loop
34917 near the bottom, ranging the "name_mod" variable over a list of all
34918 lookups. Add your "NEWDRIVER" to that list. As long as the dynamic module
34919 would be named newdriver.so, you can use the simple form that most lookups
34920 have.
34921
34922 6. Edit Makefile in the appropriate sub-directory (src/routers, src/transports
34923 , src/auths, or src/lookups); add a line for the new driver or lookup type
34924 and add it to the definition of OBJ.
34925
34926 7. Create newdriver.h and newdriver.c in the appropriate sub-directory of src.
34927
34928 8. Edit scripts/MakeLinks and add commands to link the .h and .c files as for
34929 other drivers and lookups.
34930
34931Then all you need to do is write the code! A good way to start is to make a
34932proforma by copying an existing module of the same type, globally changing all
34933occurrences of the name, and cutting out most of the code. Note that any
34934options you create must be listed in alphabetical order, because the tables are
34935searched using a binary chop procedure.
34936
34937There is a README file in each of the sub-directories of src describing the
34938interface that is expected.
34939